MCPcopy Create free account
hub / github.com/dailydotdev/apps / runInspect

Function runInspect

packages/world-cli/bin/world.js:210–265  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

208}
209
210async function runInspect() {
211 const handle = positional[0] ?? process.env.WORLD_USER;
212 if (!handle) die("Usage: world inspect <handle> [--json]");
213
214 const { user, districts } = await fetchWorld(handle, { api: DEFAULT_API });
215 if (!districts.length) {
216 die(
217 `${user.name}'s world is empty or private. A private world returns nothing to an anonymous reader, which is what this is.`
218 );
219 }
220
221 const realms = [];
222 for (const district of districts) {
223 const realm = realmOf(district.niche);
224 if (!realm) continue;
225 let group = realms.find(({ id }) => id === realm);
226 if (!group) {
227 group = { id: realm, name: REALM_NAMES[realm], districts: [] };
228 realms.push(group);
229 }
230 group.districts.push({
231 topic: district.topic,
232 slug: district.niche,
233 level: district.level,
234 reads: district.reads,
235 families: unlockedFamilies(district.level),
236 });
237 }
238
239 realms.forEach((realm) => {
240 realm.reads = realm.districts.reduce(
241 (total, district) => total + district.reads,
242 0
243 );
244 realm.level = realmLevelOf(realm.reads);
245 realm.families = unlockedFamilies(realm.level);
246 });
247
248 const result = {
249 user: { id: user.id, handle: user.username, name: user.name },
250 realms,
251 };
252
253 if (flag("json")) {
254 process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
255 return;
256 }
257
258 process.stdout.write(`${user.name}'s world\n`);
259 realms.forEach((realm) => {
260 process.stdout.write(`\n${realm.name} realm level ${realm.level}\n`);
261 realm.districts.forEach((district) => {
262 process.stdout.write(` ${district.topic} level ${district.level}\n`);
263 });
264 });
265}
266
267async function runCheck() {

Callers

nothing calls this directly

Calls 7

fetchWorldFunction · 0.90
realmOfFunction · 0.90
unlockedFamiliesFunction · 0.90
realmLevelOfFunction · 0.90
dieFunction · 0.85
flagFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected