()
| 375 | } |
| 376 | |
| 377 | async function runDev() { |
| 378 | const handle = positional[0] ?? process.env.WORLD_USER; |
| 379 | if (!handle) die("Usage: world dev <handle> [--dir builders]"); |
| 380 | |
| 381 | const { user, districts } = await fetchWorld(handle, { api: DEFAULT_API }); |
| 382 | if (!districts.length) { |
| 383 | die( |
| 384 | `${user.name}'s world is empty or private. A private world returns nothing to an anonymous reader, which is what this is.` |
| 385 | ); |
| 386 | } |
| 387 | |
| 388 | const directory = resolve(flag("dir") ?? "builders"); |
| 389 | await mkdir(directory, { recursive: true }); |
| 390 | const port = Number(flag("port") ?? 4321); |
| 391 | const targets = districts |
| 392 | .map((district) => ({ |
| 393 | ...district, |
| 394 | realm: realmOf(district.niche), |
| 395 | families: unlockedFamilies(district.level), |
| 396 | })) |
| 397 | .filter((district) => !!district.realm); |
| 398 | |
| 399 | await startDev({ |
| 400 | directory, |
| 401 | port, |
| 402 | user, |
| 403 | targets, |
| 404 | }); |
| 405 | |
| 406 | process.stdout.write( |
| 407 | [ |
| 408 | "", |
| 409 | ` ${user.name}'s world`, |
| 410 | ` project ${directory}`, |
| 411 | ` districts ${targets.length} available across realm object sets`, |
| 412 | ` user @${user.username ?? handle}`, |
| 413 | "", |
| 414 | " daily.dev connects automatically while Program your world is open.", |
| 415 | " Changed realm object sets are synchronized as one transaction. Ctrl-C to stop.", |
| 416 | " The owner publishes the reviewed preview with Save changes in daily.dev.", |
| 417 | "", |
| 418 | ].join("\n") |
| 419 | ); |
| 420 | } |
| 421 | |
| 422 | async function runPalette() { |
| 423 | const realm = flag("realm") ?? "frame"; |
nothing calls this directly
no test coverage detected