create-eigen-game 0.14.2 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as destinationProblem, c as insideWorkTree, d as scaffoldGame, l as normaliseTerminalWidth, n as applicationId, o as detectPackageManager, s as firebaseReadiness, t as addContinuousIntegration, u as plainReporter } from "./src-B8zHulnO.js";
2
+ import { a as destinationProblem, c as insideWorkTree, d as scaffoldGame, l as normaliseTerminalWidth, n as applicationId, o as detectPackageManager, s as firebaseReadiness, t as addContinuousIntegration, u as plainReporter } from "./src-u6yY0kJD.js";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { basename, dirname, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
@@ -19,6 +19,17 @@ const ORG = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)+$/;
19
19
  /** The default, which an empty answer accepts. */
20
20
  const DEFAULT_ORG = "com.example";
21
21
  const bar = color.gray(S_BAR);
22
+ /**
23
+ * Clack's public `confirm` type allows any symbol even though the prompt only
24
+ * returns its cancellation symbol. Keep that dependency detail at this
25
+ * boundary, and fail loudly if a future Clack version introduces another
26
+ * non-boolean result instead of silently treating it as "yes".
27
+ */
28
+ function booleanAnswer(answer) {
29
+ if (isCancel(answer)) return null;
30
+ if (typeof answer !== "boolean") throw new TypeError("A confirmation prompt returned neither a boolean nor Clack's cancellation symbol.");
31
+ return answer;
32
+ }
22
33
  /** A `com.acme.chess` answer to a game called `chess`, which yields `com.acme.chess.chess`. */
23
34
  function repeatsGameName(org, game) {
24
35
  return org.split(".").at(-1) === game;
@@ -66,14 +77,14 @@ async function askForOrg(game, registering, io = {}) {
66
77
  if (org === "" || org === "com.example") return void 0;
67
78
  const shorter = repeatsGameName(org, game) ? withoutGameName(org) : void 0;
68
79
  if (shorter !== void 0) {
69
- const shorten = await confirm({
80
+ const shouldShorten = booleanAnswer(await confirm({
70
81
  message: `That gives ${color.yellow(`${org}.${game}`)}, the game name twice. Use ${color.green(shorter)} instead?`,
71
82
  initialValue: true,
72
83
  input,
73
84
  output
74
- });
75
- if (isCancel(shorten)) return null;
76
- if (shorten) return shorter;
85
+ }));
86
+ if (shouldShorten === null) return null;
87
+ if (shouldShorten) return shorter;
77
88
  }
78
89
  return org;
79
90
  }
@@ -93,13 +104,12 @@ async function ask(message, initialValue, hint, io) {
93
104
  const input = io.input ?? process.stdin;
94
105
  const output = io.output ?? process.stdout;
95
106
  output.write(`${bar}\n${bar} ${color.dim(hint)}\n`);
96
- const answer = await confirm({
107
+ return booleanAnswer(await confirm({
97
108
  message,
98
109
  initialValue,
99
110
  input,
100
111
  output
101
- });
102
- return isCancel(answer) ? null : answer;
112
+ }));
103
113
  }
104
114
  /**
105
115
  * Asked only when {@link firebaseReadiness} found something missing, and
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../src/prompt.ts","../src/summary.ts","../src/cli.ts"],"sourcesContent":["/**\n * Every question this CLI asks, in one module so the wording lives together\n * and can be asserted. `cli.ts` is the bin entry and runs `main` on import,\n * which makes anything defined there untestable.\n *\n * The organization prompt is the reason this drops to `@clack/core` rather\n * than using `@clack/prompts`' `text`. The suffix: `flutter create --org X\n * --project-name Y` derives `X.Y`, so the organization is a *prefix*, and the\n * reliable way to say so is to render the rest of the identifier, dimmed,\n * while it is being typed. `text` has no hook for that; a custom `TextPrompt`\n * render returns a string, so it does.\n *\n * Everything else comes from `@clack/prompts` rather than being drawn here.\n * Its symbols are exported for exactly this, and they are not constants: each\n * falls back to ASCII on a terminal that cannot show the box-drawing\n * characters, which a hand-typed `│` cannot do.\n */\nimport type { Readable, Writable } from \"node:stream\";\nimport { TextPrompt } from \"@clack/core\";\nimport { confirm, isCancel, S_BAR, S_BAR_END, select, symbol } from \"@clack/prompts\";\nimport color from \"picocolors\";\nimport type { PackageManager } from \"./index.js\";\n\n/**\n * Where a question reads its answer from. Parameters for the same reason every\n * clack prompt takes them: a prompt is otherwise the one part of a CLI that\n * cannot be driven by a test.\n */\nexport interface Io {\n input?: Readable;\n output?: Writable;\n}\n\n/**\n * Two or more dot-separated Java identifiers. `flutter create --org` accepts\n * anything and defers the complaint to Gradle, which reports it as a manifest\n * error in a generated file, so `com.example-games` costs a full scaffold and\n * a first build before anyone learns that a hyphen is not legal in a package\n * segment.\n */\nexport const ORG = /^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$/;\n\n/** The default, which an empty answer accepts. */\nexport const DEFAULT_ORG = \"com.example\";\n\nconst bar = color.gray(S_BAR);\n\n/** A `com.acme.chess` answer to a game called `chess`, which yields `com.acme.chess.chess`. */\nexport function repeatsGameName(org: string, game: string): boolean {\n return org.split(\".\").at(-1) === game;\n}\n\n/** The organization implied by an answer that already ends in the game name. */\nexport function withoutGameName(org: string): string | undefined {\n const shorter = org.split(\".\").slice(0, -1).join(\".\");\n return ORG.test(shorter) ? shorter : undefined;\n}\n\n/**\n * Asks, with the game name rendered dimmed after the cursor so the shape of\n * the answer is visible while it is being given.\n *\n * Returns the organization, `undefined` for the default, or `null` when\n * cancelled.\n *\n * `input` and `output` default to this process's, and are parameters for the\n * same reason every clack prompt takes them: a prompt is otherwise the one\n * part of a CLI that cannot be driven by a test.\n */\nexport async function askForOrg(game: string, registering: boolean, io: Io = {}): Promise<string | undefined | null> {\n const input = io.input ?? process.stdin;\n const output = io.output ?? process.stdout;\n const suffix = color.dim(`.${game}`);\n const prompt = new TextPrompt({\n input,\n output,\n // An empty answer is the default, not a mistake.\n validate: (value) => (value === undefined || value === \"\" || ORG.test(value) ? undefined : \"Two or more dot-separated segments, as in com.example or dev.yourname.games.\"),\n render() {\n const typed = String(this.value ?? \"\");\n const shown = typed === \"\" ? `${color.dim(DEFAULT_ORG)}${suffix}` : `${this.userInputWithCursor}${suffix}`;\n const problem = this.state === \"error\" ? `\\n${bar} ${color.yellow(this.error ?? \"\")}` : \"\";\n return [`${bar}`, `${symbol(this.state)} Organization in reverse domain notation`, `${bar} ${shown}${problem}`, color.gray(S_BAR_END)].join(\"\\n\");\n },\n });\n\n // The two things that make this answer permanent, said before it is given\n // rather than after: Google Play freezes the identifier at the first upload,\n // and FlutterFire matches an existing Android app on exactly this string, so\n // it also decides whether the run adopts an app the chosen Firebase project\n // already has or registers a new one.\n output.write(`${bar} ${color.dim(\"Prefixes the Android applicationId, which Google Play makes permanent at first upload.\")}\\n`);\n if (registering) output.write(`${bar} ${color.dim(\"Also the Android app registered in the Firebase project you pick next.\")}\\n`);\n\n const answer = await prompt.prompt();\n if (isCancel(answer)) return null;\n\n const org = String(answer).trim();\n if (org === \"\" || org === DEFAULT_ORG) return undefined;\n\n // The mistake the dimmed suffix is there to prevent, caught for the person\n // who pasted an identifier rather than typing one and never watched it grow.\n const shorter = repeatsGameName(org, game) ? withoutGameName(org) : undefined;\n if (shorter !== undefined) {\n const shorten = await confirm({\n message: `That gives ${color.yellow(`${org}.${game}`)}, the game name twice. Use ${color.green(shorter)} instead?`,\n initialValue: true,\n input,\n output,\n });\n if (isCancel(shorten)) return null;\n if (shorten) return shorter;\n }\n\n return org;\n}\n\n/**\n * A yes/no question, with its reason on the line above.\n *\n * The three below share this so cancellation is handled in one place: ^C\n * during any question has to mean the run stops having written nothing, and\n * that is only true if every call site checks. `null` is that answer.\n *\n * `hint` is written rather than passed to `confirm`, which has nowhere to put\n * it. It is the same dimmed line the organization prompt uses, and carries the\n * thing that makes the default the default: a question whose answer is\n * pre-chosen owes the reader why.\n */\nasync function ask(message: string, initialValue: boolean, hint: string, io: Io): Promise<boolean | null> {\n const input = io.input ?? process.stdin;\n const output = io.output ?? process.stdout;\n output.write(`${bar}\\n${bar} ${color.dim(hint)}\\n`);\n const answer = await confirm({ message, initialValue, input, output });\n return isCancel(answer) ? null : answer;\n}\n\n/**\n * Asked only when {@link firebaseReadiness} found something missing, and\n * defaulted to \"no\" because the honest answer usually is: the tools are two\n * commands away, and the alternative is an app that throws at launch until\n * they are installed anyway.\n */\nexport function askToScaffoldWithoutFirebase(io: Io = {}): Promise<boolean | null> {\n return ask(\"Scaffold anyway, and connect Firebase yourself later?\", false, \"Everything except the app's sign-in still works, and `firebase:configure` finishes the job.\", io);\n}\n\n/** Defaulted to yes: the scaffold is a few hundred generated files, and a commit is what makes the first `git diff` the first game change rather than all of them. */\nexport function askForGit(io: Io = {}): Promise<boolean | null> {\n return ask(\"Initialise a git repository and commit the scaffold?\", true, \"Commits once, so your first diff is your first game change.\", io);\n}\n\n/**\n * Defaulted to no, and the hint says why rather than leaving it as an\n * arbitrary-looking choice: `release.yml` needs an upload keystore and a Play\n * service account, so a project that takes the workflows before it has either\n * gets a red `main` from its first push.\n */\nexport function askForWorkflows(io: Io = {}): Promise<boolean | null> {\n return ask(\"Add the GitHub Actions workflows?\", false, \"Release needs a signing keystore and a Play service account, so this fails until you have both. `add workflows` writes them later.\", io);\n}\n\n/**\n * The package manager, asked only when nothing else could say.\n *\n * `npm create` and `pnpm create` both set `npm_config_user_agent`, so this is\n * reached by the paths that do not: a global install, or running the binary\n * directly. Rare, but it decides what every generated script says, and the old\n * silent fallback to pnpm was a guess printed into a project's package.json.\n */\nexport async function askForPackageManager(io: Io = {}): Promise<PackageManager | null> {\n const answer = await select({\n message: \"Which package manager should the generated scripts use?\",\n options: [\n { value: \"pnpm\", label: \"pnpm\" },\n { value: \"npm\", label: \"npm\" },\n ],\n input: io.input ?? process.stdin,\n output: io.output ?? process.stdout,\n });\n return isCancel(answer) ? null : (answer as PackageManager);\n}\n","/**\n * The closing summary, and the only output of a scaffold anyone reads.\n *\n * A run drives several tools with plenty to say, so where the project went,\n * what to edit, and what to run are worth restating at the bottom. Returned in\n * pieces rather than as one block, because the CLI renders each in a different\n * shape: the outcomes as status lines, the commands as a boxed note, the\n * destination as the closing line.\n *\n * Its own module so it can be asserted: `cli.ts` is the bin entry and runs\n * `main` on import, which makes anything defined there untestable. The package\n * `exports` map does not expose this, so it is internal despite being\n * importable by the tests.\n */\nimport type { PackageManager, ScaffoldResult } from \"./index.js\";\n\nexport interface Summary {\n /** What became of the repository and of Firebase, when there is something to say. */\n status: string[];\n /** The commands worth having, as one block. */\n next: string;\n /** One-line asides, after the block. */\n footnotes: string[];\n /** The closing line. */\n headline: string;\n}\n\n/** Two-column rows, aligned to the widest left cell. */\nfunction columns(rows: [string, string][]): string[] {\n const width = Math.max(...rows.map(([left]) => left.length));\n return rows.map(([left, right]) => ` ${left.padEnd(width)} ${right}`);\n}\n\nexport function summarise(result: ScaffoldResult, manager: PackageManager, workflows: boolean): Summary {\n const run = manager === \"npm\" ? \"npm run\" : \"pnpm\";\n const status: string[] = [];\n\n // Only the outcomes that leave the reader something to know. `failed` has\n // already warned, in more detail than a summary line could carry.\n if (result.git === \"committed\") status.push(`Committed as \"Scaffold ${result.name}\"`);\n if (result.git === \"existing\") status.push(\"Created inside a repository you already had, so nothing was committed\");\n // `failed` has warned already, and the step reappears below as the next\n // thing to run, which is the whole of the advice.\n if (result.firebase === \"configured\") status.push(result.git === \"committed\" ? \"Firebase is configured, and everything it generated is in that commit\" : \"Firebase is configured\");\n if (result.link?.projectId != null) status.push(`FIREBASE_PROJECT_ID is set to ${result.link.projectId}, and app-config.json points at the local Worker`);\n\n // What is left, and only what is left. Everything here comes from the\n // Firebase console rather than from any CLI, which is why a scaffold that\n // filled in everything it could still ends with a list: the web target\n // refuses to start without a VAPID key, and there is no OAuth client to copy\n // until somebody enables the provider that creates it.\n const remaining: [string, string][] = [];\n if (result.link !== undefined) {\n if (result.link.googleWebClientId === null) {\n remaining.push([\"Enable Google sign-in\", \"Console > Authentication > Sign-in method\"]);\n remaining.push([\"GOOGLE_WEB_CLIENT_ID\", \"that same page, under Web SDK configuration\"]);\n }\n remaining.push([\"FIREBASE_VAPID_KEY\", \"Console > Project settings > Cloud Messaging > Web configuration\"]);\n }\n\n const next = [\n \"Write the game\",\n ...columns([\n [\"server/src/module/v1.ts\", \"the authoritative rules\"],\n [\"app/lib/game/v1/rules.dart\", \"the presentation twin\"],\n ]),\n \"\",\n `Then, from ${result.name}/`,\n ...columns([\n [`cd server && ${run} test:watch`, \"rules and twin fixtures\"],\n [`cd server && ${run} dev`, \"the Worker, on http://localhost:8787\"],\n [`${run} contract`, \"regenerate after a schema change\"],\n // Named here because it is the one step the game itself cannot do\n // without: rules, fixtures and the Worker all run unconfigured, and the\n // app throws `Firebase is not configured` at launch until this has run\n // once.\n ...(result.firebase === \"configured\" ? [] : [[`${run} firebase:configure`, \"connect Firebase before the app runs\"] as [string, string]]),\n ]),\n ...(remaining.length === 0 ? [] : [\"\", \"Before the app runs, from the Firebase console\", ...columns(remaining), \"\", \" The values go in app/app-config.json. Both are public, not secrets.\"]),\n ].join(\"\\n\");\n\n const footnotes = [\"Docs: https://eigeninteractive.com\"];\n if (!workflows) footnotes.unshift(\"No CI workflows yet: `create-eigen-game add workflows` writes them when shipping is the next step.\");\n\n return { status, next, footnotes, headline: `${result.name} is ready, at ${result.root}` };\n}\n","#!/usr/bin/env node\nimport { readFileSync } from \"node:fs\";\nimport { basename, dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parseArgs } from \"node:util\";\nimport { cancel, intro, isCI, isTTY, log, note, outro, taskLog } from \"@clack/prompts\";\nimport color from \"picocolors\";\nimport { addContinuousIntegration, applicationId, destinationProblem, detectPackageManager, type FirebaseProblem, firebaseReadiness, insideWorkTree, normaliseTerminalWidth, type PackageManager, plainReporter, type Reporter, scaffoldGame } from \"./index.js\";\nimport { askForGit, askForOrg, askForPackageManager, askForWorkflows, askToScaffoldWithoutFirebase, DEFAULT_ORG, ORG } from \"./prompt.js\";\nimport { summarise } from \"./summary.js\";\n\nconst version = (JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), \"../package.json\"), \"utf8\")) as { version: string }).version;\n\nconst PREREQUISITES = \"https://eigeninteractive.com/docs/getting-started/prerequisites\";\n\nconst help = `Usage: create-eigen-game <game-slug> [options]\n create-eigen-game add workflows [directory] [options]\n\nCreates one repository containing an EigenInteractive Cloudflare Worker and\nFlutter app, and commits it. The destination basename is the lowercase\nkebab-case game slug; the CLI derives the display name, Dart package name, and\nDart/TypeScript type prefix from it.\n\nEvery option below answers a question the CLI would otherwise ask. Pass it to\nskip the question; leave it out to be asked. With no terminal to ask on (CI, a\npipe, an agent session) an unanswered question is an error rather than a\ndefault quietly chosen for you, and the message prints the command to re-run.\n\nOptions:\n --org <reverse-domain> Android/iOS organization. The applicationId is this\n plus the game name, as in com.example.my_game, and\n Google Play makes it permanent at first upload\n --firebase-project <id>\n The Firebase project to configure against. Also the\n form that works with no terminal, since otherwise\n FlutterFire asks\n --no-firebase Do not configure Firebase, leaving firebase:configure\n as a step for later\n --git, --no-git Initialise a repository and commit the scaffold\n --workflows, --no-workflows\n Emit the GitHub Actions workflows. release.yml needs\n an upload keystore and a Play service account, so it\n fails on every push until both exist\n --package-manager <pm> npm or pnpm. Taken from the invoking package manager\n when there is one, so this is for global installs\n -h, --help Show this help\n -v, --version Show the version\n\nCommands:\n add workflows [directory]\n Add the workflows to an existing project, for when\n you are ready to ship rather than at scaffold time.\n Defaults to the current directory.`;\n\nnormaliseTerminalWidth(process.stdout);\n\n/**\n * Whether to draw, using clack's own predicates rather than a hand-rolled\n * `isTTY`, the same pair `taskLog` consults internally. A pipe has nowhere to\n * put a redraw, and a CI log is read after the fact, in full, by someone who\n * wants every line a tool printed.\n */\nconst decorated = isTTY(process.stdout) && !isCI();\n\n/**\n * The CLI's voice, in whichever of the two registers this terminal supports.\n *\n * Every message goes through here so the undecorated path cannot drift into\n * being the untested one.\n */\nconst ui = decorated\n ? {\n open: () => intro(color.inverse(\" EigenInteractive \")),\n info: (message: string) => log.info(message),\n warn: (message: string) => log.warn(message),\n success: (message: string) => log.success(message),\n block: (body: string) => note(body, \"Next\"),\n close: (message: string) => outro(color.bold(message)),\n stop: (message: string) => cancel(message),\n }\n : {\n open: () => console.log(\"\\nEigenInteractive\\n\"),\n info: (message: string) => console.log(message),\n warn: (message: string) => console.warn(message),\n success: (message: string) => console.log(message),\n block: (body: string) => console.log(`\\n${body}\\n`),\n close: (message: string) => console.log(message),\n stop: (message: string) => console.error(message),\n };\n\nfunction resolveManager(requested: string | undefined): PackageManager | undefined {\n if (requested === undefined) return undefined;\n if (requested !== \"npm\" && requested !== \"pnpm\") {\n throw new Error(\"--package-manager must be npm or pnpm\");\n }\n return requested;\n}\n\n/**\n * Why a scaffold asks about a second service at all, said once, before the\n * first question rather than in the error that follows it.\n *\n * Firebase is not an integration this engine offers; it is where a player\n * comes from. Somebody meeting that for the first time deserves the reason in\n * the same breath as the requirement, and deserves to know the size of it:\n * one free project, shared by every game they build.\n */\nfunction greet(): void {\n ui.open();\n ui.info(\"A game is one repository with two halves: a Cloudflare Worker that owns the rules,\\nand a Flutter app for Android and the web. This writes both, wired together and\\nalready playable.\");\n ui.info(\n `Firebase signs your players in. The Worker verifies Firebase ID tokens to decide who\\nholds a seat, and sends turn notifications through the same project, so a scaffolded\\napp throws ${color.dim(\"Firebase is not configured\")} at launch until one is connected.\\n\\nIt is free to start, one project serves every game you build, and this connects yours\\nas it goes. ${color.dim(PREREQUISITES)}`,\n );\n}\n\n/** What is missing, and the one command that fixes each: the same list the warning and the parting message are both built from. */\nfunction firebaseReport(problems: FirebaseProblem[]): string {\n const lines = problems.flatMap((problem) => [` ${problem.reason}`, ` ${color.cyan(problem.fix)}`]);\n // `dart pub global activate` does not put the binary on PATH, which is the\n // next thing to go wrong for anyone who has just run the command above.\n if (problems.some((problem) => problem.fix.startsWith(\"dart pub\"))) {\n lines.push(` ${color.dim('…then, if your shell cannot find it: export PATH=\"$PATH\":\"$HOME/.pub-cache/bin\"')}`);\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * The parting message when someone answers \"no\" to scaffolding without\n * Firebase: every command they need, in the order they run in.\n *\n * Deliberately not a failure of the scaffold: nothing has been written, they\n * asked for that, and the exit code is non-zero only so a script that wrapped\n * this can tell there is no project.\n */\nfunction stopForFirebase(problems: FirebaseProblem[]): void {\n // The commands only. What each one is for is in the warning directly above,\n // and a `note` draws a box sized to its longest line, so repeating the\n // reasons here is what makes it wrap into something unreadable at 80\n // columns, which is exactly the width this is most likely to be read at.\n note(`${problems.map((problem) => ` ${color.cyan(problem.fix)}`).join(\"\\n\")}\\n\\nThen run this again.\\n${color.dim(PREREQUISITES)}`, \"Set up Firebase\");\n ui.stop(\"Nothing was written.\");\n process.exitCode = 1;\n}\n\n/**\n * The error for a run with no terminal and an unanswered question.\n *\n * The strictness is the point: a default applied where nobody can see it is\n * how `com.example.my_game` reaches Google Play, which freezes it at the first\n * upload. What keeps that from being merely annoying is this message: the\n * whole command, with every default already filled in, so the fix is one\n * paste and the one value worth changing is visible in it.\n */\nfunction unanswered(directory: string, missing: { flags: string; suggestion: string }[]): string {\n const command = [\"npx create-eigen-game\", directory, ...missing.map((question) => question.suggestion)].join(\" \");\n return [`No terminal to ask on, so every answer has to come from a flag. These were not given:`, \"\", ...missing.map((question) => ` ${question.flags}`), \"\", \"That command, with each default filled in. Read them before you run it:\", \"\", ` ${command}`].join(\"\\n\");\n}\n\n/** `--foo` and `--no-foo`, which `parseArgs` has no notion of: `undefined` means nobody said, which is what makes it a question. */\nfunction flagPair(yes: boolean | undefined, no: boolean | undefined, name: string): boolean | undefined {\n if (yes === true && no === true) throw new Error(`--${name} and --no-${name} contradict each other`);\n if (yes === true) return true;\n if (no === true) return false;\n return undefined;\n}\n\n/** `--org \"\"` falls through to the default rather than failing, matching what an empty answer to the prompt does. */\nfunction resolveOrg(value: string): string | undefined {\n if (value.trim() === \"\") return undefined;\n if (!ORG.test(value)) {\n throw new Error(`invalid organization: ${value}\\n\\nUse reverse domain notation: two or more dot-separated segments of letters, digits and underscores, each starting with a letter, as in ${DEFAULT_ORG} or dev.yourname.games.`);\n }\n return value;\n}\n\n/**\n * Shows each step running, and keeps its output only when it fails.\n *\n * Every tool a scaffold drives has plenty to say (pub resolving 179\n * dependencies, two icon generators, a package manager) and none of it is\n * read while it scrolls past. `taskLog` is exactly that bargain: the stream is\n * visible while the step runs, cleared when it succeeds, and left on screen\n * when it does not, so a failure is still debuggable from what is in the\n * terminal.\n *\n * `handOver` is the exception, and the reason `interactive` exists at all.\n * FlutterFire asks which Firebase project to use, so that step needs the\n * terminal rather than a captured pipe.\n */\nfunction clackReporter(): Reporter {\n // `taskLog` redraws by clearing lines, which is an escape-sequence storm in\n // anything that is not a terminal: a CI log, a pipe, `scaffold-e2e.mjs`.\n // There, the honest thing is the plain reporter: every tool's output, in\n // full, which is what a log gets read for anyway.\n if (!decorated) return plainReporter;\n\n let task: ReturnType<typeof taskLog> | undefined;\n let interactive = false;\n\n return {\n step(label, body) {\n task = taskLog({ title: label });\n try {\n const value = body();\n task.success(label);\n return value;\n } catch (error) {\n task.error(label);\n throw error;\n } finally {\n task = undefined;\n }\n },\n handOver(label, body) {\n log.step(`${label} ${color.dim(\"(FlutterFire takes over here)\")}`);\n interactive = true;\n try {\n return body();\n } finally {\n interactive = false;\n }\n },\n emit(output) {\n const text = output.trimEnd();\n if (text !== \"\") task?.message(text);\n },\n warn(message) {\n ui.warn(message);\n },\n get interactive() {\n return interactive;\n },\n };\n}\n\nasync function main(args: string[]): Promise<void> {\n const { values, positionals } = parseArgs({\n args,\n allowPositionals: true,\n strict: true,\n options: {\n help: { type: \"boolean\", short: \"h\" },\n version: { type: \"boolean\", short: \"v\" },\n org: { type: \"string\" },\n \"firebase-project\": { type: \"string\" },\n // Each negation is declared under the name it is typed with, because\n // `parseArgs` has no boolean negation of its own. `flagPair` puts the\n // two halves back together, and the third state, neither given, is the\n // one that matters: it is what turns the flag into a question.\n \"no-firebase\": { type: \"boolean\" },\n git: { type: \"boolean\" },\n \"no-git\": { type: \"boolean\" },\n workflows: { type: \"boolean\" },\n \"no-workflows\": { type: \"boolean\" },\n \"package-manager\": { type: \"string\" },\n },\n });\n\n if (values.help) {\n console.log(help);\n return;\n }\n if (values.version) {\n console.log(version);\n return;\n }\n\n const requestedManager = resolveManager(values[\"package-manager\"]);\n\n if (positionals[0] === \"add\") {\n // `ci` is the name this shipped under, and it is written into the README\n // of every project already scaffolded. Those READMEs are on disk and are\n // not going to be edited, so the old spelling keeps working; only the new\n // one is documented.\n if (positionals[1] !== \"workflows\" && positionals[1] !== \"ci\") {\n throw new Error(`unknown subcommand: add ${positionals[1] ?? \"\"}\\n\\n${help}`.trim());\n }\n if (positionals.length > 3) {\n throw new Error(`expected at most one directory\\n\\n${help}`);\n }\n const result = addContinuousIntegration({\n directory: positionals[2] ?? process.cwd(),\n packageManager: requestedManager,\n });\n console.log(`Added ${result.files.join(\" and \")} in ${result.root}`);\n return;\n }\n\n if (positionals.length !== 1) {\n throw new Error(`expected exactly one destination directory\\n\\n${help}`);\n }\n\n const directory = positionals[0];\n\n // Everything that makes the command impossible, before the greeting rather\n // than after the last question. `applicationId` validates the slug;\n // `destinationProblem` is the one `scaffoldGame` would raise at the far end,\n // asked here instead. Being told the directory was occupied *after* giving\n // an organization is the same insult as being told about `flutterfire` after\n // two minutes of Flutter and pub.\n const game = basename(resolve(directory));\n applicationId(directory);\n const occupied = destinationProblem(directory);\n if (occupied !== undefined) throw new Error(occupied);\n\n greet();\n\n // Every question this run will ask, settled before any of it starts. A flag\n // is an answer already given; anything left over is asked, or, with nothing\n // to ask on, collected here and reported together, so one re-run can carry\n // all of them.\n const interactive = process.stdin.isTTY === true;\n const missing: { flags: string; suggestion: string }[] = [];\n const cancelled = () => {\n ui.stop(\"Nothing was written.\");\n process.exitCode = 130;\n };\n\n /**\n * Records a question that could not be asked, and hands back the default it\n * suggested. The value is never used, since `missing` throws before anything\n * is written, but returning it keeps each answer definitely typed instead of\n * carrying a `| undefined` all the way to the scaffold call.\n */\n const needsFlag = <T>(flags: string, suggestion: string, fallback: T): T => {\n missing.push({ flags, suggestion });\n return fallback;\n };\n\n // Firebase goes first because it is the only answer that can end the run,\n // and ending it after the organization prompt would mean asking for a\n // permanent decision about a project that never gets created.\n const project = values[\"firebase-project\"]?.trim();\n if (project === \"\") throw new Error(\"--firebase-project needs a project id\");\n if (project !== undefined && values[\"no-firebase\"] === true) {\n throw new Error(\"--firebase-project and --no-firebase contradict each other\");\n }\n\n let firebase: boolean | string = false;\n if (project !== undefined) {\n firebase = project;\n } else if (values[\"no-firebase\"] !== true) {\n const readiness = firebaseReadiness();\n if (readiness.ready) {\n // Nothing for this CLI to ask: FlutterFire runs its own project picker\n // during the scaffold, and needs a terminal to do it.\n if (interactive) firebase = true;\n else firebase = needsFlag(\"--firebase-project <id>, or --no-firebase\", \"--no-firebase\", false);\n } else {\n ui.warn(`Firebase is not set up on this machine:\\n\\n${firebaseReport(readiness.problems)}`);\n if (!interactive) {\n firebase = needsFlag(\"--no-firebase, to scaffold without it\", \"--no-firebase\", false);\n } else {\n const carryOn = await askToScaffoldWithoutFirebase();\n if (carryOn === null) return cancelled();\n if (!carryOn) return stopForFirebase(readiness.problems);\n }\n }\n }\n\n let org: string | undefined;\n if (values.org !== undefined) {\n org = resolveOrg(values.org);\n } else if (interactive) {\n const answer = await askForOrg(game.replaceAll(\"-\", \"_\"), firebase !== false);\n if (answer === null) return cancelled();\n org = answer;\n } else {\n org = needsFlag(\"--org <reverse-domain>\", `--org ${DEFAULT_ORG}`, undefined);\n }\n\n // A destination inside a repository someone already has is not a question:\n // `scaffoldGame` declines to nest one repository in another whatever it is\n // told, and says so in the summary.\n let git = flagPair(values.git, values[\"no-git\"], \"git\");\n if (git === undefined && insideWorkTree(directory)) git = true;\n if (git === undefined) {\n if (!interactive) git = needsFlag(\"--git or --no-git\", \"--git\", true);\n else {\n const answer = await askForGit();\n if (answer === null) return cancelled();\n git = answer;\n }\n }\n\n let workflows = flagPair(values.workflows, values[\"no-workflows\"], \"workflows\");\n if (workflows === undefined) {\n if (!interactive) workflows = needsFlag(\"--workflows or --no-workflows\", \"--no-workflows\", false);\n else {\n const answer = await askForWorkflows();\n if (answer === null) return cancelled();\n workflows = answer;\n }\n }\n\n // Reached only when nothing else could say. `npm create` and `pnpm create`\n // both announce themselves in `npm_config_user_agent`. What is left is a\n // global install, where the old silent fallback to pnpm was a guess written\n // into every script in the generated project.\n let manager = requestedManager ?? detectPackageManager();\n if (manager === undefined) {\n if (!interactive) manager = needsFlag(\"--package-manager <npm|pnpm>\", \"--package-manager pnpm\", \"pnpm\" as PackageManager);\n else {\n const answer = await askForPackageManager();\n if (answer === null) return cancelled();\n manager = answer;\n }\n }\n\n if (missing.length > 0) throw new Error(unanswered(directory, missing));\n\n ui.success(`applicationId ${color.bold(applicationId(directory, org))}`);\n\n const result = scaffoldGame({\n directory,\n org,\n packageManager: manager,\n ci: workflows,\n git,\n firebase,\n reporter: clackReporter(),\n });\n\n const { status, next, footnotes, headline } = summarise(result, manager, workflows);\n for (const line of status) ui.success(line);\n ui.block(next);\n for (const line of footnotes) ui.info(line);\n ui.close(headline);\n}\n\ntry {\n await main(process.argv.slice(2));\n} catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n ui.stop(`create-eigen-game: ${message}`);\n process.exitCode = 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwCA,MAAa,MAAM;;AAGnB,MAAa,cAAc;AAE3B,MAAM,MAAM,MAAM,KAAK,KAAK;;AAG5B,SAAgB,gBAAgB,KAAa,MAAuB;CAClE,OAAO,IAAI,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM;AACnC;;AAGA,SAAgB,gBAAgB,KAAiC;CAC/D,MAAM,UAAU,IAAI,MAAM,GAAG,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,GAAG;CACpD,OAAO,IAAI,KAAK,OAAO,IAAI,UAAU,KAAA;AACvC;;;;;;;;;;;;AAaA,eAAsB,UAAU,MAAc,aAAsB,KAAS,CAAC,GAAuC;CACnH,MAAM,QAAQ,GAAG,SAAS,QAAQ;CAClC,MAAM,SAAS,GAAG,UAAU,QAAQ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,MAAwB;OACnH;GACH,MAAM,SAAS,MAAM,qBAAqB;GAC1C,IAAI,WAAW,MAAM,OAAO,UAAU;GACtC,UAAU;EACZ;CACF;CAEA,IAAI,QAAQ,SAAS,GAAG,MAAM,IAAI,MAAM,WAAW,WAAW,OAAO,CAAC;CAEtE,GAAG,QAAQ,iBAAiB,MAAM,KAAK,cAAc,WAAW,GAAG,CAAC,GAAG;CAYvE,MAAM,EAAE,QAAQ,MAAM,WAAW,aAAa,UAV/B,aAAa;EAC1B;EACA;EACA,gBAAgB;EAChB,IAAI;EACJ;EACA;EACA,UAAU,cAAc;CAC1B,CAEwD,GAAQ,SAAS,SAAS;CAClF,KAAK,MAAM,QAAQ,QAAQ,GAAG,QAAQ,IAAI;CAC1C,GAAG,MAAM,IAAI;CACb,KAAK,MAAM,QAAQ,WAAW,GAAG,KAAK,IAAI;CAC1C,GAAG,MAAM,QAAQ;AACnB;AAEA,IAAI;CACF,MAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC;AAClC,SAAS,OAAgB;CACvB,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACrE,GAAG,KAAK,sBAAsB,SAAS;CACvC,QAAQ,WAAW;AACrB"}
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/prompt.ts","../src/summary.ts","../src/cli.ts"],"sourcesContent":["/**\n * Every question this CLI asks, in one module so the wording lives together\n * and can be asserted. `cli.ts` is the bin entry and runs `main` on import,\n * which makes anything defined there untestable.\n *\n * The organization prompt is the reason this drops to `@clack/core` rather\n * than using `@clack/prompts`' `text`. The suffix: `flutter create --org X\n * --project-name Y` derives `X.Y`, so the organization is a *prefix*, and the\n * reliable way to say so is to render the rest of the identifier, dimmed,\n * while it is being typed. `text` has no hook for that; a custom `TextPrompt`\n * render returns a string, so it does.\n *\n * Everything else comes from `@clack/prompts` rather than being drawn here.\n * Its symbols are exported for exactly this, and they are not constants: each\n * falls back to ASCII on a terminal that cannot show the box-drawing\n * characters, which a hand-typed `│` cannot do.\n */\nimport type { Readable, Writable } from \"node:stream\";\nimport { TextPrompt } from \"@clack/core\";\nimport { confirm, isCancel, S_BAR, S_BAR_END, select, symbol } from \"@clack/prompts\";\nimport color from \"picocolors\";\nimport type { PackageManager } from \"./index.js\";\n\n/**\n * Where a question reads its answer from. Parameters for the same reason every\n * clack prompt takes them: a prompt is otherwise the one part of a CLI that\n * cannot be driven by a test.\n */\nexport interface Io {\n input?: Readable;\n output?: Writable;\n}\n\n/**\n * Two or more dot-separated Java identifiers. `flutter create --org` accepts\n * anything and defers the complaint to Gradle, which reports it as a manifest\n * error in a generated file, so `com.example-games` costs a full scaffold and\n * a first build before anyone learns that a hyphen is not legal in a package\n * segment.\n */\nexport const ORG = /^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$/;\n\n/** The default, which an empty answer accepts. */\nexport const DEFAULT_ORG = \"com.example\";\n\nconst bar = color.gray(S_BAR);\n\n/**\n * Clack's public `confirm` type allows any symbol even though the prompt only\n * returns its cancellation symbol. Keep that dependency detail at this\n * boundary, and fail loudly if a future Clack version introduces another\n * non-boolean result instead of silently treating it as \"yes\".\n */\nfunction booleanAnswer(answer: boolean | symbol): boolean | null {\n if (isCancel(answer)) return null;\n if (typeof answer !== \"boolean\") throw new TypeError(\"A confirmation prompt returned neither a boolean nor Clack's cancellation symbol.\");\n return answer;\n}\n\n/** A `com.acme.chess` answer to a game called `chess`, which yields `com.acme.chess.chess`. */\nexport function repeatsGameName(org: string, game: string): boolean {\n return org.split(\".\").at(-1) === game;\n}\n\n/** The organization implied by an answer that already ends in the game name. */\nexport function withoutGameName(org: string): string | undefined {\n const shorter = org.split(\".\").slice(0, -1).join(\".\");\n return ORG.test(shorter) ? shorter : undefined;\n}\n\n/**\n * Asks, with the game name rendered dimmed after the cursor so the shape of\n * the answer is visible while it is being given.\n *\n * Returns the organization, `undefined` for the default, or `null` when\n * cancelled.\n *\n * `input` and `output` default to this process's, and are parameters for the\n * same reason every clack prompt takes them: a prompt is otherwise the one\n * part of a CLI that cannot be driven by a test.\n */\nexport async function askForOrg(game: string, registering: boolean, io: Io = {}): Promise<string | undefined | null> {\n const input = io.input ?? process.stdin;\n const output = io.output ?? process.stdout;\n const suffix = color.dim(`.${game}`);\n const prompt = new TextPrompt({\n input,\n output,\n // An empty answer is the default, not a mistake.\n validate: (value) => (value === undefined || value === \"\" || ORG.test(value) ? undefined : \"Two or more dot-separated segments, as in com.example or dev.yourname.games.\"),\n render() {\n const typed = String(this.value ?? \"\");\n const shown = typed === \"\" ? `${color.dim(DEFAULT_ORG)}${suffix}` : `${this.userInputWithCursor}${suffix}`;\n const problem = this.state === \"error\" ? `\\n${bar} ${color.yellow(this.error ?? \"\")}` : \"\";\n return [`${bar}`, `${symbol(this.state)} Organization in reverse domain notation`, `${bar} ${shown}${problem}`, color.gray(S_BAR_END)].join(\"\\n\");\n },\n });\n\n // The two things that make this answer permanent, said before it is given\n // rather than after: Google Play freezes the identifier at the first upload,\n // and FlutterFire matches an existing Android app on exactly this string, so\n // it also decides whether the run adopts an app the chosen Firebase project\n // already has or registers a new one.\n output.write(`${bar} ${color.dim(\"Prefixes the Android applicationId, which Google Play makes permanent at first upload.\")}\\n`);\n if (registering) output.write(`${bar} ${color.dim(\"Also the Android app registered in the Firebase project you pick next.\")}\\n`);\n\n const answer = await prompt.prompt();\n if (isCancel(answer)) return null;\n\n const org = String(answer).trim();\n if (org === \"\" || org === DEFAULT_ORG) return undefined;\n\n // The mistake the dimmed suffix is there to prevent, caught for the person\n // who pasted an identifier rather than typing one and never watched it grow.\n const shorter = repeatsGameName(org, game) ? withoutGameName(org) : undefined;\n if (shorter !== undefined) {\n const shorten = await confirm({\n message: `That gives ${color.yellow(`${org}.${game}`)}, the game name twice. Use ${color.green(shorter)} instead?`,\n initialValue: true,\n input,\n output,\n });\n const shouldShorten = booleanAnswer(shorten);\n if (shouldShorten === null) return null;\n if (shouldShorten) return shorter;\n }\n\n return org;\n}\n\n/**\n * A yes/no question, with its reason on the line above.\n *\n * The three below share this so cancellation is handled in one place: ^C\n * during any question has to mean the run stops having written nothing, and\n * that is only true if every call site checks. `null` is that answer.\n *\n * `hint` is written rather than passed to `confirm`, which has nowhere to put\n * it. It is the same dimmed line the organization prompt uses, and carries the\n * thing that makes the default the default: a question whose answer is\n * pre-chosen owes the reader why.\n */\nasync function ask(message: string, initialValue: boolean, hint: string, io: Io): Promise<boolean | null> {\n const input = io.input ?? process.stdin;\n const output = io.output ?? process.stdout;\n output.write(`${bar}\\n${bar} ${color.dim(hint)}\\n`);\n const answer = await confirm({ message, initialValue, input, output });\n return booleanAnswer(answer);\n}\n\n/**\n * Asked only when {@link firebaseReadiness} found something missing, and\n * defaulted to \"no\" because the honest answer usually is: the tools are two\n * commands away, and the alternative is an app that throws at launch until\n * they are installed anyway.\n */\nexport function askToScaffoldWithoutFirebase(io: Io = {}): Promise<boolean | null> {\n return ask(\"Scaffold anyway, and connect Firebase yourself later?\", false, \"Everything except the app's sign-in still works, and `firebase:configure` finishes the job.\", io);\n}\n\n/** Defaulted to yes: the scaffold is a few hundred generated files, and a commit is what makes the first `git diff` the first game change rather than all of them. */\nexport function askForGit(io: Io = {}): Promise<boolean | null> {\n return ask(\"Initialise a git repository and commit the scaffold?\", true, \"Commits once, so your first diff is your first game change.\", io);\n}\n\n/**\n * Defaulted to no, and the hint says why rather than leaving it as an\n * arbitrary-looking choice: `release.yml` needs an upload keystore and a Play\n * service account, so a project that takes the workflows before it has either\n * gets a red `main` from its first push.\n */\nexport function askForWorkflows(io: Io = {}): Promise<boolean | null> {\n return ask(\"Add the GitHub Actions workflows?\", false, \"Release needs a signing keystore and a Play service account, so this fails until you have both. `add workflows` writes them later.\", io);\n}\n\n/**\n * The package manager, asked only when nothing else could say.\n *\n * `npm create` and `pnpm create` both set `npm_config_user_agent`, so this is\n * reached by the paths that do not: a global install, or running the binary\n * directly. Rare, but it decides what every generated script says, and the old\n * silent fallback to pnpm was a guess printed into a project's package.json.\n */\nexport async function askForPackageManager(io: Io = {}): Promise<PackageManager | null> {\n const answer = await select({\n message: \"Which package manager should the generated scripts use?\",\n options: [\n { value: \"pnpm\", label: \"pnpm\" },\n { value: \"npm\", label: \"npm\" },\n ],\n input: io.input ?? process.stdin,\n output: io.output ?? process.stdout,\n });\n return isCancel(answer) ? null : (answer as PackageManager);\n}\n","/**\n * The closing summary, and the only output of a scaffold anyone reads.\n *\n * A run drives several tools with plenty to say, so where the project went,\n * what to edit, and what to run are worth restating at the bottom. Returned in\n * pieces rather than as one block, because the CLI renders each in a different\n * shape: the outcomes as status lines, the commands as a boxed note, the\n * destination as the closing line.\n *\n * Its own module so it can be asserted: `cli.ts` is the bin entry and runs\n * `main` on import, which makes anything defined there untestable. The package\n * `exports` map does not expose this, so it is internal despite being\n * importable by the tests.\n */\nimport type { PackageManager, ScaffoldResult } from \"./index.js\";\n\nexport interface Summary {\n /** What became of the repository and of Firebase, when there is something to say. */\n status: string[];\n /** The commands worth having, as one block. */\n next: string;\n /** One-line asides, after the block. */\n footnotes: string[];\n /** The closing line. */\n headline: string;\n}\n\n/** Two-column rows, aligned to the widest left cell. */\nfunction columns(rows: [string, string][]): string[] {\n const width = Math.max(...rows.map(([left]) => left.length));\n return rows.map(([left, right]) => ` ${left.padEnd(width)} ${right}`);\n}\n\nexport function summarise(result: ScaffoldResult, manager: PackageManager, workflows: boolean): Summary {\n const run = manager === \"npm\" ? \"npm run\" : \"pnpm\";\n const status: string[] = [];\n\n // Only the outcomes that leave the reader something to know. `failed` has\n // already warned, in more detail than a summary line could carry.\n if (result.git === \"committed\") status.push(`Committed as \"Scaffold ${result.name}\"`);\n if (result.git === \"existing\") status.push(\"Created inside a repository you already had, so nothing was committed\");\n // `failed` has warned already, and the step reappears below as the next\n // thing to run, which is the whole of the advice.\n if (result.firebase === \"configured\") status.push(result.git === \"committed\" ? \"Firebase is configured, and everything it generated is in that commit\" : \"Firebase is configured\");\n if (result.link?.projectId != null) status.push(`FIREBASE_PROJECT_ID is set to ${result.link.projectId}, and app-config.json points at the local Worker`);\n\n // What is left, and only what is left. Everything here comes from the\n // Firebase console rather than from any CLI, which is why a scaffold that\n // filled in everything it could still ends with a list: the web target\n // refuses to start without a VAPID key, and there is no OAuth client to copy\n // until somebody enables the provider that creates it.\n const remaining: [string, string][] = [];\n if (result.link !== undefined) {\n if (result.link.googleWebClientId === null) {\n remaining.push([\"Enable Google sign-in\", \"Console > Authentication > Sign-in method\"]);\n remaining.push([\"GOOGLE_WEB_CLIENT_ID\", \"that same page, under Web SDK configuration\"]);\n }\n remaining.push([\"FIREBASE_VAPID_KEY\", \"Console > Project settings > Cloud Messaging > Web configuration\"]);\n }\n\n const next = [\n \"Write the game\",\n ...columns([\n [\"server/src/module/v1.ts\", \"the authoritative rules\"],\n [\"app/lib/game/v1/rules.dart\", \"the presentation twin\"],\n ]),\n \"\",\n `Then, from ${result.name}/`,\n ...columns([\n [`cd server && ${run} test:watch`, \"rules and twin fixtures\"],\n [`cd server && ${run} dev`, \"the Worker, on http://localhost:8787\"],\n [`${run} contract`, \"regenerate after a schema change\"],\n // Named here because it is the one step the game itself cannot do\n // without: rules, fixtures and the Worker all run unconfigured, and the\n // app throws `Firebase is not configured` at launch until this has run\n // once.\n ...(result.firebase === \"configured\" ? [] : [[`${run} firebase:configure`, \"connect Firebase before the app runs\"] as [string, string]]),\n ]),\n ...(remaining.length === 0 ? [] : [\"\", \"Before the app runs, from the Firebase console\", ...columns(remaining), \"\", \" The values go in app/app-config.json. Both are public, not secrets.\"]),\n ].join(\"\\n\");\n\n const footnotes = [\"Docs: https://eigeninteractive.com\"];\n if (!workflows) footnotes.unshift(\"No CI workflows yet: `create-eigen-game add workflows` writes them when shipping is the next step.\");\n\n return { status, next, footnotes, headline: `${result.name} is ready, at ${result.root}` };\n}\n","#!/usr/bin/env node\nimport { readFileSync } from \"node:fs\";\nimport { basename, dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parseArgs } from \"node:util\";\nimport { cancel, intro, isCI, isTTY, log, note, outro, taskLog } from \"@clack/prompts\";\nimport color from \"picocolors\";\nimport { addContinuousIntegration, applicationId, destinationProblem, detectPackageManager, type FirebaseProblem, firebaseReadiness, insideWorkTree, normaliseTerminalWidth, type PackageManager, plainReporter, type Reporter, scaffoldGame } from \"./index.js\";\nimport { askForGit, askForOrg, askForPackageManager, askForWorkflows, askToScaffoldWithoutFirebase, DEFAULT_ORG, ORG } from \"./prompt.js\";\nimport { summarise } from \"./summary.js\";\n\nconst version = (JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), \"../package.json\"), \"utf8\")) as { version: string }).version;\n\nconst PREREQUISITES = \"https://eigeninteractive.com/docs/getting-started/prerequisites\";\n\nconst help = `Usage: create-eigen-game <game-slug> [options]\n create-eigen-game add workflows [directory] [options]\n\nCreates one repository containing an EigenInteractive Cloudflare Worker and\nFlutter app, and commits it. The destination basename is the lowercase\nkebab-case game slug; the CLI derives the display name, Dart package name, and\nDart/TypeScript type prefix from it.\n\nEvery option below answers a question the CLI would otherwise ask. Pass it to\nskip the question; leave it out to be asked. With no terminal to ask on (CI, a\npipe, an agent session) an unanswered question is an error rather than a\ndefault quietly chosen for you, and the message prints the command to re-run.\n\nOptions:\n --org <reverse-domain> Android/iOS organization. The applicationId is this\n plus the game name, as in com.example.my_game, and\n Google Play makes it permanent at first upload\n --firebase-project <id>\n The Firebase project to configure against. Also the\n form that works with no terminal, since otherwise\n FlutterFire asks\n --no-firebase Do not configure Firebase, leaving firebase:configure\n as a step for later\n --git, --no-git Initialise a repository and commit the scaffold\n --workflows, --no-workflows\n Emit the GitHub Actions workflows. release.yml needs\n an upload keystore and a Play service account, so it\n fails on every push until both exist\n --package-manager <pm> npm or pnpm. Taken from the invoking package manager\n when there is one, so this is for global installs\n -h, --help Show this help\n -v, --version Show the version\n\nCommands:\n add workflows [directory]\n Add the workflows to an existing project, for when\n you are ready to ship rather than at scaffold time.\n Defaults to the current directory.`;\n\nnormaliseTerminalWidth(process.stdout);\n\n/**\n * Whether to draw, using clack's own predicates rather than a hand-rolled\n * `isTTY`, the same pair `taskLog` consults internally. A pipe has nowhere to\n * put a redraw, and a CI log is read after the fact, in full, by someone who\n * wants every line a tool printed.\n */\nconst decorated = isTTY(process.stdout) && !isCI();\n\n/**\n * The CLI's voice, in whichever of the two registers this terminal supports.\n *\n * Every message goes through here so the undecorated path cannot drift into\n * being the untested one.\n */\nconst ui = decorated\n ? {\n open: () => intro(color.inverse(\" EigenInteractive \")),\n info: (message: string) => log.info(message),\n warn: (message: string) => log.warn(message),\n success: (message: string) => log.success(message),\n block: (body: string) => note(body, \"Next\"),\n close: (message: string) => outro(color.bold(message)),\n stop: (message: string) => cancel(message),\n }\n : {\n open: () => console.log(\"\\nEigenInteractive\\n\"),\n info: (message: string) => console.log(message),\n warn: (message: string) => console.warn(message),\n success: (message: string) => console.log(message),\n block: (body: string) => console.log(`\\n${body}\\n`),\n close: (message: string) => console.log(message),\n stop: (message: string) => console.error(message),\n };\n\nfunction resolveManager(requested: string | undefined): PackageManager | undefined {\n if (requested === undefined) return undefined;\n if (requested !== \"npm\" && requested !== \"pnpm\") {\n throw new Error(\"--package-manager must be npm or pnpm\");\n }\n return requested;\n}\n\n/**\n * Why a scaffold asks about a second service at all, said once, before the\n * first question rather than in the error that follows it.\n *\n * Firebase is not an integration this engine offers; it is where a player\n * comes from. Somebody meeting that for the first time deserves the reason in\n * the same breath as the requirement, and deserves to know the size of it:\n * one free project, shared by every game they build.\n */\nfunction greet(): void {\n ui.open();\n ui.info(\"A game is one repository with two halves: a Cloudflare Worker that owns the rules,\\nand a Flutter app for Android and the web. This writes both, wired together and\\nalready playable.\");\n ui.info(\n `Firebase signs your players in. The Worker verifies Firebase ID tokens to decide who\\nholds a seat, and sends turn notifications through the same project, so a scaffolded\\napp throws ${color.dim(\"Firebase is not configured\")} at launch until one is connected.\\n\\nIt is free to start, one project serves every game you build, and this connects yours\\nas it goes. ${color.dim(PREREQUISITES)}`,\n );\n}\n\n/** What is missing, and the one command that fixes each: the same list the warning and the parting message are both built from. */\nfunction firebaseReport(problems: FirebaseProblem[]): string {\n const lines = problems.flatMap((problem) => [` ${problem.reason}`, ` ${color.cyan(problem.fix)}`]);\n // `dart pub global activate` does not put the binary on PATH, which is the\n // next thing to go wrong for anyone who has just run the command above.\n if (problems.some((problem) => problem.fix.startsWith(\"dart pub\"))) {\n lines.push(` ${color.dim('…then, if your shell cannot find it: export PATH=\"$PATH\":\"$HOME/.pub-cache/bin\"')}`);\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * The parting message when someone answers \"no\" to scaffolding without\n * Firebase: every command they need, in the order they run in.\n *\n * Deliberately not a failure of the scaffold: nothing has been written, they\n * asked for that, and the exit code is non-zero only so a script that wrapped\n * this can tell there is no project.\n */\nfunction stopForFirebase(problems: FirebaseProblem[]): void {\n // The commands only. What each one is for is in the warning directly above,\n // and a `note` draws a box sized to its longest line, so repeating the\n // reasons here is what makes it wrap into something unreadable at 80\n // columns, which is exactly the width this is most likely to be read at.\n note(`${problems.map((problem) => ` ${color.cyan(problem.fix)}`).join(\"\\n\")}\\n\\nThen run this again.\\n${color.dim(PREREQUISITES)}`, \"Set up Firebase\");\n ui.stop(\"Nothing was written.\");\n process.exitCode = 1;\n}\n\n/**\n * The error for a run with no terminal and an unanswered question.\n *\n * The strictness is the point: a default applied where nobody can see it is\n * how `com.example.my_game` reaches Google Play, which freezes it at the first\n * upload. What keeps that from being merely annoying is this message: the\n * whole command, with every default already filled in, so the fix is one\n * paste and the one value worth changing is visible in it.\n */\nfunction unanswered(directory: string, missing: { flags: string; suggestion: string }[]): string {\n const command = [\"npx create-eigen-game\", directory, ...missing.map((question) => question.suggestion)].join(\" \");\n return [`No terminal to ask on, so every answer has to come from a flag. These were not given:`, \"\", ...missing.map((question) => ` ${question.flags}`), \"\", \"That command, with each default filled in. Read them before you run it:\", \"\", ` ${command}`].join(\"\\n\");\n}\n\n/** `--foo` and `--no-foo`, which `parseArgs` has no notion of: `undefined` means nobody said, which is what makes it a question. */\nfunction flagPair(yes: boolean | undefined, no: boolean | undefined, name: string): boolean | undefined {\n if (yes === true && no === true) throw new Error(`--${name} and --no-${name} contradict each other`);\n if (yes === true) return true;\n if (no === true) return false;\n return undefined;\n}\n\n/** `--org \"\"` falls through to the default rather than failing, matching what an empty answer to the prompt does. */\nfunction resolveOrg(value: string): string | undefined {\n if (value.trim() === \"\") return undefined;\n if (!ORG.test(value)) {\n throw new Error(`invalid organization: ${value}\\n\\nUse reverse domain notation: two or more dot-separated segments of letters, digits and underscores, each starting with a letter, as in ${DEFAULT_ORG} or dev.yourname.games.`);\n }\n return value;\n}\n\n/**\n * Shows each step running, and keeps its output only when it fails.\n *\n * Every tool a scaffold drives has plenty to say (pub resolving 179\n * dependencies, two icon generators, a package manager) and none of it is\n * read while it scrolls past. `taskLog` is exactly that bargain: the stream is\n * visible while the step runs, cleared when it succeeds, and left on screen\n * when it does not, so a failure is still debuggable from what is in the\n * terminal.\n *\n * `handOver` is the exception, and the reason `interactive` exists at all.\n * FlutterFire asks which Firebase project to use, so that step needs the\n * terminal rather than a captured pipe.\n */\nfunction clackReporter(): Reporter {\n // `taskLog` redraws by clearing lines, which is an escape-sequence storm in\n // anything that is not a terminal: a CI log, a pipe, `scaffold-e2e.mjs`.\n // There, the honest thing is the plain reporter: every tool's output, in\n // full, which is what a log gets read for anyway.\n if (!decorated) return plainReporter;\n\n let task: ReturnType<typeof taskLog> | undefined;\n let interactive = false;\n\n return {\n step(label, body) {\n task = taskLog({ title: label });\n try {\n const value = body();\n task.success(label);\n return value;\n } catch (error) {\n task.error(label);\n throw error;\n } finally {\n task = undefined;\n }\n },\n handOver(label, body) {\n log.step(`${label} ${color.dim(\"(FlutterFire takes over here)\")}`);\n interactive = true;\n try {\n return body();\n } finally {\n interactive = false;\n }\n },\n emit(output) {\n const text = output.trimEnd();\n if (text !== \"\") task?.message(text);\n },\n warn(message) {\n ui.warn(message);\n },\n get interactive() {\n return interactive;\n },\n };\n}\n\nasync function main(args: string[]): Promise<void> {\n const { values, positionals } = parseArgs({\n args,\n allowPositionals: true,\n strict: true,\n options: {\n help: { type: \"boolean\", short: \"h\" },\n version: { type: \"boolean\", short: \"v\" },\n org: { type: \"string\" },\n \"firebase-project\": { type: \"string\" },\n // Each negation is declared under the name it is typed with, because\n // `parseArgs` has no boolean negation of its own. `flagPair` puts the\n // two halves back together, and the third state, neither given, is the\n // one that matters: it is what turns the flag into a question.\n \"no-firebase\": { type: \"boolean\" },\n git: { type: \"boolean\" },\n \"no-git\": { type: \"boolean\" },\n workflows: { type: \"boolean\" },\n \"no-workflows\": { type: \"boolean\" },\n \"package-manager\": { type: \"string\" },\n },\n });\n\n if (values.help) {\n console.log(help);\n return;\n }\n if (values.version) {\n console.log(version);\n return;\n }\n\n const requestedManager = resolveManager(values[\"package-manager\"]);\n\n if (positionals[0] === \"add\") {\n // `ci` is the name this shipped under, and it is written into the README\n // of every project already scaffolded. Those READMEs are on disk and are\n // not going to be edited, so the old spelling keeps working; only the new\n // one is documented.\n if (positionals[1] !== \"workflows\" && positionals[1] !== \"ci\") {\n throw new Error(`unknown subcommand: add ${positionals[1] ?? \"\"}\\n\\n${help}`.trim());\n }\n if (positionals.length > 3) {\n throw new Error(`expected at most one directory\\n\\n${help}`);\n }\n const result = addContinuousIntegration({\n directory: positionals[2] ?? process.cwd(),\n packageManager: requestedManager,\n });\n console.log(`Added ${result.files.join(\" and \")} in ${result.root}`);\n return;\n }\n\n if (positionals.length !== 1) {\n throw new Error(`expected exactly one destination directory\\n\\n${help}`);\n }\n\n const directory = positionals[0];\n\n // Everything that makes the command impossible, before the greeting rather\n // than after the last question. `applicationId` validates the slug;\n // `destinationProblem` is the one `scaffoldGame` would raise at the far end,\n // asked here instead. Being told the directory was occupied *after* giving\n // an organization is the same insult as being told about `flutterfire` after\n // two minutes of Flutter and pub.\n const game = basename(resolve(directory));\n applicationId(directory);\n const occupied = destinationProblem(directory);\n if (occupied !== undefined) throw new Error(occupied);\n\n greet();\n\n // Every question this run will ask, settled before any of it starts. A flag\n // is an answer already given; anything left over is asked, or, with nothing\n // to ask on, collected here and reported together, so one re-run can carry\n // all of them.\n const interactive = process.stdin.isTTY === true;\n const missing: { flags: string; suggestion: string }[] = [];\n const cancelled = () => {\n ui.stop(\"Nothing was written.\");\n process.exitCode = 130;\n };\n\n /**\n * Records a question that could not be asked, and hands back the default it\n * suggested. The value is never used, since `missing` throws before anything\n * is written, but returning it keeps each answer definitely typed instead of\n * carrying a `| undefined` all the way to the scaffold call.\n */\n const needsFlag = <T>(flags: string, suggestion: string, fallback: T): T => {\n missing.push({ flags, suggestion });\n return fallback;\n };\n\n // Firebase goes first because it is the only answer that can end the run,\n // and ending it after the organization prompt would mean asking for a\n // permanent decision about a project that never gets created.\n const project = values[\"firebase-project\"]?.trim();\n if (project === \"\") throw new Error(\"--firebase-project needs a project id\");\n if (project !== undefined && values[\"no-firebase\"] === true) {\n throw new Error(\"--firebase-project and --no-firebase contradict each other\");\n }\n\n let firebase: boolean | string = false;\n if (project !== undefined) {\n firebase = project;\n } else if (values[\"no-firebase\"] !== true) {\n const readiness = firebaseReadiness();\n if (readiness.ready) {\n // Nothing for this CLI to ask: FlutterFire runs its own project picker\n // during the scaffold, and needs a terminal to do it.\n if (interactive) firebase = true;\n else firebase = needsFlag(\"--firebase-project <id>, or --no-firebase\", \"--no-firebase\", false);\n } else {\n ui.warn(`Firebase is not set up on this machine:\\n\\n${firebaseReport(readiness.problems)}`);\n if (!interactive) {\n firebase = needsFlag(\"--no-firebase, to scaffold without it\", \"--no-firebase\", false);\n } else {\n const carryOn = await askToScaffoldWithoutFirebase();\n if (carryOn === null) return cancelled();\n if (!carryOn) return stopForFirebase(readiness.problems);\n }\n }\n }\n\n let org: string | undefined;\n if (values.org !== undefined) {\n org = resolveOrg(values.org);\n } else if (interactive) {\n const answer = await askForOrg(game.replaceAll(\"-\", \"_\"), firebase !== false);\n if (answer === null) return cancelled();\n org = answer;\n } else {\n org = needsFlag(\"--org <reverse-domain>\", `--org ${DEFAULT_ORG}`, undefined);\n }\n\n // A destination inside a repository someone already has is not a question:\n // `scaffoldGame` declines to nest one repository in another whatever it is\n // told, and says so in the summary.\n let git = flagPair(values.git, values[\"no-git\"], \"git\");\n if (git === undefined && insideWorkTree(directory)) git = true;\n if (git === undefined) {\n if (!interactive) git = needsFlag(\"--git or --no-git\", \"--git\", true);\n else {\n const answer = await askForGit();\n if (answer === null) return cancelled();\n git = answer;\n }\n }\n\n let workflows = flagPair(values.workflows, values[\"no-workflows\"], \"workflows\");\n if (workflows === undefined) {\n if (!interactive) workflows = needsFlag(\"--workflows or --no-workflows\", \"--no-workflows\", false);\n else {\n const answer = await askForWorkflows();\n if (answer === null) return cancelled();\n workflows = answer;\n }\n }\n\n // Reached only when nothing else could say. `npm create` and `pnpm create`\n // both announce themselves in `npm_config_user_agent`. What is left is a\n // global install, where the old silent fallback to pnpm was a guess written\n // into every script in the generated project.\n let manager = requestedManager ?? detectPackageManager();\n if (manager === undefined) {\n if (!interactive) manager = needsFlag(\"--package-manager <npm|pnpm>\", \"--package-manager pnpm\", \"pnpm\" as PackageManager);\n else {\n const answer = await askForPackageManager();\n if (answer === null) return cancelled();\n manager = answer;\n }\n }\n\n if (missing.length > 0) throw new Error(unanswered(directory, missing));\n\n ui.success(`applicationId ${color.bold(applicationId(directory, org))}`);\n\n const result = scaffoldGame({\n directory,\n org,\n packageManager: manager,\n ci: workflows,\n git,\n firebase,\n reporter: clackReporter(),\n });\n\n const { status, next, footnotes, headline } = summarise(result, manager, workflows);\n for (const line of status) ui.success(line);\n ui.block(next);\n for (const line of footnotes) ui.info(line);\n ui.close(headline);\n}\n\ntry {\n await main(process.argv.slice(2));\n} catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n ui.stop(`create-eigen-game: ${message}`);\n process.exitCode = 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwCA,MAAa,MAAM;;AAGnB,MAAa,cAAc;AAE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,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACrE,GAAG,KAAK,sBAAsB,SAAS;CACvC,QAAQ,WAAW;AACrB"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as destinationProblem, c as insideWorkTree, d as scaffoldGame, i as decodeUtf8, l as normaliseTerminalWidth, n as applicationId, o as detectPackageManager, r as capturingRunner, s as firebaseReadiness, t as addContinuousIntegration, u as plainReporter } from "./src-B8zHulnO.js";
1
+ import { a as destinationProblem, c as insideWorkTree, d as scaffoldGame, i as decodeUtf8, l as normaliseTerminalWidth, n as applicationId, o as detectPackageManager, r as capturingRunner, s as firebaseReadiness, t as addContinuousIntegration, u as plainReporter } from "./src-u6yY0kJD.js";
2
2
  export { addContinuousIntegration, applicationId, capturingRunner, decodeUtf8, destinationProblem, detectPackageManager, firebaseReadiness, insideWorkTree, normaliseTerminalWidth, plainReporter, scaffoldGame };
@@ -231,7 +231,7 @@ const engineVersion = engineRange(JSON.parse(readFileSync(resolve(packageRoot, "
231
231
  * that still speaks the 0.3.x wire.
232
232
  *
233
233
  * Raised to 0.7.0 for the 0.5.x engine line and the `PlayerLimits` client API.
234
- * vNext later simplified the wire again: versions are a contiguous prefix and
234
+ * The platform later simplified the wire again: versions are a contiguous prefix and
235
235
  * generic mutation identities are gone. The next Flutter release must raise
236
236
  * this floor before the corresponding scaffolder is published.
237
237
  *
@@ -833,4 +833,4 @@ function scaffoldGame(options) {
833
833
  //#endregion
834
834
  export { destinationProblem as a, insideWorkTree as c, scaffoldGame as d, decodeUtf8 as i, normaliseTerminalWidth as l, applicationId as n, detectPackageManager as o, capturingRunner as r, firebaseReadiness as s, addContinuousIntegration as t, plainReporter as u };
835
835
 
836
- //# sourceMappingURL=src-B8zHulnO.js.map
836
+ //# sourceMappingURL=src-u6yY0kJD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-u6yY0kJD.js","names":[],"sources":["../src/engine-range.ts","../src/link-firebase.ts","../src/index.ts"],"sourcesContent":["/**\n * Where the engine range emitted into a scaffolded project comes from.\n *\n * Its own module because the two branches below execute in different worlds,\n * one only inside this repository and the other only inside a published tarball,\n * and a function whose published-only path never runs in CI is a function that\n * is not tested. `src/index.ts` uses it; the package `exports` map does not\n * expose it, so it is internal despite being importable by the tests.\n */\n\n/** The dependency whose version the scaffolder emits into the generated server. */\nexport const ENGINE_PACKAGE = \"@eigeninteractive/server\";\n\n/**\n * The engine range for a scaffolded project, from this package's own\n * `@eigeninteractive/server` devDependency.\n *\n * That number is not maintained by anyone: it is the version CI compiled the\n * templates against, because `pnpm -r typecheck` runs\n * `tsc -p templates/worker/tsconfig.json` inside this workspace. Emitting\n * anything else would mean shipping templates paired with an engine no build\n * ever saw.\n *\n * It replaced a derivation from this package's OWN version, which was correct\n * only while `create-eigen-game` sat in the `fixed` changesets group, and that\n * membership is what forced an engine-wide release for every scaffolder-only\n * change. Reading the dependency keeps the guarantee and drops the coupling.\n *\n * Two branches, because the same manifest reads differently in the two places\n * this runs:\n *\n * - **Published tarball**: pnpm rewrites `workspace:*` to the exact version\n * while packing, so the manifest already states it (`\"0.2.0\"`), and no\n * sibling package exists on disk to consult.\n * - **This workspace**: the manifest still says `workspace:*`, which names no\n * version, so the sibling package is read directly.\n *\n * @param declared the raw `@eigeninteractive/server` devDependency value\n * @param readSiblingVersion consulted only for the `workspace:` protocol\n */\nexport function engineRange(declared: string | undefined, readSiblingVersion: () => string | undefined): string {\n if (!declared) {\n throw new Error(`create-eigen-game has no ${ENGINE_PACKAGE} devDependency, which is where the engine range it emits comes from`);\n }\n\n const version = declared.startsWith(\"workspace:\") ? readSiblingVersion() : declared;\n\n if (!version) {\n throw new Error(`create-eigen-game declares ${ENGINE_PACKAGE} as \"${declared}\" but the workspace package could not be read, so there is no engine version to emit`);\n }\n\n // pnpm packs `workspace:*` as a bare version, which is what makes the caret\n // below correct. Asserting it means a change in that behaviour fails here\n // rather than emitting something like `^^0.3.0` into a real project.\n if (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {\n throw new Error(`expected an exact ${ENGINE_PACKAGE} version to build a range from, got \"${version}\"`);\n }\n\n return `^${version}`;\n}\n","/**\n * Reads the two deployment values that exist only once a Firebase project\n * does, so the closing summary can name what is still missing.\n *\n * Reading only. `configure_firebase` writes them, into `wrangler.jsonc` and\n * `app-config.json`, because it is also what a project runs later when\n * reconfiguring, and one implementation is what keeps the scaffold-time path\n * and the re-run path identical. This module exists so the summary can tell\n * the difference between \"filled in\" and \"still owed\", not to do it again.\n *\n * Its own module for the same reason `summary.ts` is: `index.ts` runs a\n * scaffold, and this is worth asserting without one. The package `exports` map\n * does not expose it.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\n/** What the Firebase step managed to settle, and what it left for the console. */\nexport interface FirebaseLink {\n /** The project now in `wrangler.jsonc`, or null when FlutterFire recorded none. */\n projectId: string | null;\n /** The OAuth web client now in `app-config.json`, or null when Google sign-in is not enabled yet. */\n googleWebClientId: string | null;\n}\n\nfunction readJson(path: string): unknown {\n if (!existsSync(path)) return undefined;\n try {\n return JSON.parse(readFileSync(path, \"utf8\"));\n } catch {\n // A file this step only reads is never worth failing a finished scaffold\n // for. The value counts as unset, and the summary says so.\n return undefined;\n }\n}\n\n/**\n * The project FlutterFire recorded for the Dart output this app uses.\n *\n * `firebase.json` is FlutterFire's own record rather than something this\n * scaffold writes, so it is read defensively: a shape that does not match is\n * treated as \"not configured\", which is the same answer as a run that never\n * happened.\n */\nexport function configuredProject(appRoot: string): string | null {\n const record = readJson(resolve(appRoot, \"firebase.json\")) as { flutter?: { platforms?: { dart?: Record<string, { projectId?: unknown }> } } } | undefined;\n const projectId = record?.flutter?.platforms?.dart?.[\"lib/firebase_options.dart\"]?.projectId;\n return typeof projectId === \"string\" && projectId !== \"\" ? projectId : null;\n}\n\n/**\n * The OAuth web client id that `configure_firebase` copied into\n * `app-config.json`, when there was one to copy.\n *\n * Empty is an ordinary outcome rather than a failure. Firebase creates that\n * client when the Google sign-in provider is enabled, which is a console\n * action no CLI can perform, so a project that has never had it enabled has\n * nothing to offer here.\n */\nexport function configuredWebClientId(appRoot: string): string | null {\n const config = readJson(resolve(appRoot, \"app-config.json\")) as Record<string, unknown> | undefined;\n const value = config?.GOOGLE_WEB_CLIENT_ID;\n return typeof value === \"string\" && value !== \"\" ? value : null;\n}\n\n/** What the Firebase step settled, for the summary to report. */\nexport function readFirebaseLink(root: string): FirebaseLink {\n const appRoot = resolve(root, \"app\");\n return { projectId: configuredProject(appRoot), googleWebClientId: configuredWebClientId(appRoot) };\n}\n","import { execFileSync } from \"node:child_process\";\nimport { appendFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmdirSync, rmSync, statSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, relative, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { ENGINE_PACKAGE, engineRange } from \"./engine-range.js\";\nimport { type FirebaseLink, readFirebaseLink } from \"./link-firebase.js\";\n\nexport type { FirebaseLink } from \"./link-firebase.js\";\n\nexport type PackageManager = \"npm\" | \"pnpm\";\n\nexport type Runner = (command: string, args: string[], cwd: string) => void;\n\n/**\n * Where a scaffold says what it is doing, so that presentation belongs to the\n * caller and this module only has to name things.\n *\n * The default is the behaviour a library caller expects with no opinion:\n * subprocesses inherit the terminal and warnings go to `console.warn`. The CLI\n * substitutes one that captures each step's output and shows it only if the\n * step fails.\n */\nexport interface Reporter {\n /** Runs `body` as one named step. Its subprocesses can be captured. */\n step<T>(label: string, body: () => T): T;\n /**\n * Runs `body` as a step that owns the terminal, because something inside it\n * asks questions. FlutterFire is the only one.\n */\n handOver<T>(label: string, body: () => T): T;\n /** Output from a subprocess inside the current step. */\n emit(output: string): void;\n /** A failure the scaffold survives. */\n warn(message: string): void;\n /** Whether subprocesses must inherit the terminal rather than be captured. */\n readonly interactive: boolean;\n}\n\n/**\n * Gives a terminal that reports no width the width clack would have assumed.\n *\n * A pty can report itself as a TTY and set `columns` to 0. `script` does, and\n * so do some container terminals. clack falls back to 80 for a stream with no\n * `columns` at all, but `0` is a number and satisfies that check, so the width\n * it draws its rules from goes negative and a scaffold dies partway through\n * with `RangeError: Invalid string length`. Supplying the default its check\n * misses is better than giving up the drawing.\n */\nexport function normaliseTerminalWidth(stream: { isTTY?: boolean; columns?: number }): void {\n if (stream.isTTY === true && (stream.columns ?? 0) < 1) stream.columns = 80;\n}\n\n/** Runs every step plainly, which is what a library caller gets by default. */\nexport const plainReporter: Reporter = {\n step: (_label, body) => body(),\n handOver: (_label, body) => body(),\n emit: (output) => process.stdout.write(output),\n warn: (message) => console.warn(`create-eigen-game: ${message}`),\n interactive: true,\n};\n\n/**\n * The runner a scaffold uses when the caller has not supplied one: it asks the\n * reporter whether the terminal is spoken for.\n *\n * `interactive` inherits, which is the only way FlutterFire can put a question\n * on screen and read the answer. Otherwise both streams are captured and\n * handed to the reporter: on success so it can discard them, and on failure\n * so the reason survives.\n */\nexport function capturingRunner(reporter: Reporter): Runner {\n return (command, args, cwd) => {\n if (reporter.interactive) {\n execFileSync(command, args, { cwd, stdio: \"inherit\" });\n return;\n }\n try {\n reporter.emit(execFileSync(command, args, { cwd, encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"pipe\"] }));\n } catch (error: unknown) {\n // Both streams, because which one a tool failed on is its own business:\n // pub explains itself on stdout, Gradle on stderr.\n const { stdout, stderr } = error as { stdout?: string; stderr?: string };\n reporter.emit(`${stdout ?? \"\"}${stderr ?? \"\"}`);\n throw error;\n }\n };\n}\n\nexport interface ScaffoldOptions {\n directory: string;\n org?: string;\n packageManager?: PackageManager;\n /**\n * Run Flutter, package installation, and contract/payload generation.\n * Kept as a programmatic test seam; the public CLI always bootstraps both\n * halves of the combined project.\n */\n bootstrap?: boolean;\n /**\n * Emit the GitHub Actions workflows. Off by default; see the call site for\n * why, and `addContinuousIntegration` for adding them to an existing\n * project later.\n */\n ci?: boolean;\n /**\n * Initialise a repository and commit the scaffold. Defaults to `bootstrap`,\n * because the commit is only worth having once the generated files exist.\n */\n git?: boolean;\n /**\n * Configure Firebase before the first commit, by running the Flutter\n * client's `configure_firebase`. A string names the project to use; `true`\n * lets FlutterFire ask, which is also where a project can be created.\n *\n * Explicit here, though the CLI turns it on by default: this is the one step\n * that reaches outside the destination directory, and a library caller\n * should say so rather than discover it. {@link firebaseReadiness} is how\n * the CLI decides.\n */\n firebase?: boolean | string;\n /**\n * Runs the bootstrap subprocesses. A seam: the tests substitute a recorder,\n * and `scripts/scaffold-e2e.mjs` wraps it to point the generated server at\n * this workspace's engine rather than npm's copy.\n */\n run?: Runner;\n /**\n * Where the scaffold says what it is doing. See {@link Reporter}; the\n * default runs every step plainly.\n */\n reporter?: Reporter;\n}\n\n/**\n * What became of the repository, so the CLI's closing summary can say rather\n * than guess. `failed` has already warned by the time it is returned, and\n * carries no advice of its own.\n */\nexport type GitOutcome = \"committed\" | \"existing\" | \"skipped\" | \"failed\";\n\nexport interface ScaffoldResult {\n root: string;\n name: string;\n git: GitOutcome;\n /**\n * Whether Firebase was configured, so the summary can either stop naming the\n * step or spell it out. `failed` has already warned.\n */\n firebase: \"configured\" | \"failed\" | \"skipped\";\n /**\n * What the Firebase step made knowable and this scaffold therefore filled\n * in. Absent unless `firebase` is `configured`, since there is nothing to\n * read otherwise.\n */\n link?: FirebaseLink;\n}\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), \"..\");\nconst templatesRoot = resolve(packageRoot, \"templates\");\n\n/**\n * The engine range emitted into a scaffolded project's package.json.\n *\n * Read from this package's `@eigeninteractive/server` devDependency rather than\n * from its own version. See `engine-range.ts` for why that is the version the\n * templates are known to compile against, and what it replaced.\n */\nconst engineVersion = engineRange((JSON.parse(readFileSync(resolve(packageRoot, \"package.json\"), \"utf8\")) as { devDependencies?: Record<string, string> }).devDependencies?.[ENGINE_PACKAGE], () => {\n // Only reached in this workspace, where the manifest still says\n // `workspace:*`. A published tarball has no sibling here and never asks.\n const sibling = resolve(packageRoot, \"../server/package.json\");\n return existsSync(sibling) ? (JSON.parse(readFileSync(sibling, \"utf8\")) as { version: string }).version : undefined;\n});\n\n/**\n * The Flutter client range installed into the app half.\n *\n * A stated version, not a derived or resolved one. The Dart templates import\n * `package:eigen_flutter/eigen_flutter.dart` and\n * `package:eigen_flutter/testing/twin_fixtures.dart` and are written against a\n * specific Dart API. `eigen_flutter` is published and versioned separately from\n * this package even though both now live in the platform monorepo, so a source\n * location cannot compute which released version the template should request.\n * Only compiling a scaffolded app establishes it, which the platform gate does\n * on every change.\n *\n * This briefly resolved from pub.dev instead: \"the newest `eigen_flutter` whose\n * own `eigen_api` constraint targets the engine line being scaffolded\". That\n * predicate is wrong. The `eigen_api` constraint describes the WIRE the integration\n * speaks, not the Dart API these templates call, and the two move\n * independently: a future `eigen_flutter` may legitimately keep `eigen_api:\n * ^0.2.0` while renaming everything the templates touch. It would have been\n * selected, and the generated app would not compile.\n *\n * A caret RANGE rather than an exact version, so it still improves without a\n * republish: `flutter pub add eigen_flutter@^0.4.0` already picks the newest\n * 0.4.x at scaffold time, which is the part the pub.dev lookup was duplicating.\n * What it deliberately cannot do is cross to 0.5.x, the one move that needs a\n * human to confirm the templates still compile.\n *\n * Staleness is therefore a failing check rather than a broken scaffold: this is\n * only ever a release behind, never wrong.\n *\n * Raised to 0.4.0 with the engine's session-snapshot wire. This is the one kind\n * of bump that is not merely an improvement: a scaffold writes both halves, and\n * the worker half is this repository's own line, so the client integration has to\n * speak that line's socket. `eigen_flutter` 0.4.0 is the first that does, and\n * every 0.3.x pins `eigen_api: ^0.2.0`, which cannot read a 0.3.x engine at all.\n * A scaffold pinning 0.3.x would therefore resolve, compile, and then fail to\n * render a game, which is the worst of the three.\n *\n * Raised to 0.4.1 for `EngineConfig.authDomain`, which the generated\n * `main.dart` passes. Additive, so pre-1.0 it is a patch and `^0.4.0` would\n * still resolve it, but `^0.4.0` also still resolves 0.4.0, where the parameter\n * does not exist and the scaffold would not compile. The floor is what makes\n * the generated code and the installed shell agree.\n *\n * Raised to 0.6.0 with the engine's opaque pagination cursors, and this is the\n * same *required* kind of bump the 0.4.0 note describes rather than an\n * improvement. The 0.4.x engine line takes `cursor` as an opaque string and\n * returns `nextCursor` on every paged response; `eigen_flutter` 0.6.0 is the\n * first integration that pins `eigen_api: ^0.4.0` and can read it. Everything below\n * that pins `eigen_api: ^0.3.0` or older, so a scaffold left on `^0.4.1` would\n * install the engine's current line beside a shell that cannot read a single\n * paged list from it: it resolves, it compiles, and then the lobby and history\n * are empty. 0.5.0 is skipped for the same reason, being a web-design release\n * that still speaks the 0.3.x wire.\n *\n * Raised to 0.7.0 for the 0.5.x engine line and the `PlayerLimits` client API.\n * The platform later simplified the wire again: versions are a contiguous prefix and\n * generic mutation identities are gone. The next Flutter release must raise\n * this floor before the corresponding scaffolder is published.\n *\n * Note that this floor and the engine range are raised in one commit on\n * purpose. The scaffolder writes both halves, and `updateInternalDependencies`\n * republishes this package whenever the engine version moves, so between an\n * engine line crossing and this line moving there is a published scaffolder\n * that pairs a new worker with an old shell. That window is real and this is\n * what closes it.\n *\n * The 0.7.0 raise is the exception that shows where that promise cannot hold. A\n * floor names a *published* `eigen_flutter`, and `eigen_flutter` publishes at the\n * end of the release chain, after the npm packages this scaffolder ships with --\n * so at the moment the engine crossed to 0.5.x there was no 0.7.0 to point at,\n * and `create-eigen-game@0.12.0` went out pairing a `^0.5.0` worker with a 0.6.0\n * integration. A Flutter line move therefore costs a follow-up scaffolder patch, and\n * `scripts/scaffold-e2e.mjs` is what refuses to let it be forgotten: it resolves\n * both halves for real and compares the wire lines they land on.\n */\nconst flutterClientVersion = \"^0.9.0\";\n\n/** Complete first-party app shell installed by the standard scaffold. */\nconst flutterShellVersion = \"^0.1.0\";\n\n/** Optional Firebase adapter installed by the standard app scaffold. */\nconst firebaseAdapterVersion = \"^0.2.0\";\n\n/** Development-only contract compiler installed into the generated app. */\nconst dartCodegenVersion = \"^0.1.0\";\n\nconst gameSlug = (value: string): string => {\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value)) {\n throw new Error(\"destination directory name must be a lowercase kebab-case slug, for example my-game\");\n }\n return value;\n};\n\nconst dartName = (value: string): string => value.replaceAll(\"-\", \"_\");\n\n/**\n * The Android `applicationId`, and iOS bundle id, a scaffold at `directory`\n * will produce, so the CLI can show it rather than describe it.\n *\n * `flutter create --org X --project-name Y` derives `X.Y`. The organization is\n * the *prefix*, not the whole identifier, which is the part worth seeing\n * before answering: Google Play makes it permanent at first upload.\n */\nexport function applicationId(directory: string, org?: string): string {\n return `${org?.trim() || \"com.example\"}.${dartName(gameSlug(basename(resolve(directory))))}`;\n}\n\nconst title = (value: string): string =>\n value\n .split(\"-\")\n .map((part) => `${part[0]?.toUpperCase() ?? \"\"}${part.slice(1)}`)\n .join(\" \");\n\nconst identifier = (value: string): string => {\n const pascal = value\n .split(\"-\")\n .map((part) => `${part[0]?.toUpperCase() ?? \"\"}${part.slice(1)}`)\n .join(\"\");\n return /^[0-9]/.test(pascal) ? `Game${pascal}` : pascal;\n};\n\nexport function detectPackageManager(userAgent = process.env.npm_config_user_agent): PackageManager | undefined {\n if (userAgent?.startsWith(\"pnpm/\")) return \"pnpm\";\n if (userAgent?.startsWith(\"npm/\")) return \"npm\";\n return undefined;\n}\n\n/**\n * Substitutes the scaffold's tokens, of which there are two deliberate kinds.\n *\n * `{{BRACED}}` for values that have no valid example: a package manager,\n * an engine version, an Android package id. They appear only in manifests,\n * READMEs, workflows and the `Appfile`: files nothing compiles.\n *\n * Bare words (`ExampleGame`, `example-game`, …) for names a real example game\n * genuinely has. This is what keeps `templates/worker` and the Dart templates\n * VALID, COMPILING SOURCE rather than text with holes in it, which the rest of\n * this package leans on hard: `typecheck` runs `tsc` over `templates/worker`,\n * the tests `import` its game module directly and build a real contract from\n * it, and the `scaffold` job compiles the Dart templates. Bracing these would\n * trade all of that for a marker.\n *\n * The cost, and the one rule for template authors: a template file cannot\n * contain the literal string `example-game`, `Example Game`, `ExampleGame` or\n * `example_game` and keep it; every occurrence is rewritten, in prose and in\n * code alike. Write around it, or brace a new token instead.\n *\n * Note this means the set of files carrying a token changes whenever someone\n * writes one into an existing file. Nothing needs to track that: `renderTree`\n * decides what to rewrite from the bytes, not from a list of paths.\n */\nfunction render(contents: string, name: string, manager: PackageManager, packageId: string): string {\n const replacements: ReadonlyArray<readonly [string, string]> = [\n [\"@game/example-game-server\", `@game/${name}-server`],\n [\"{{PACKAGE_MANAGER}}\", manager],\n [\"{{PACKAGE_ID}}\", packageId],\n [\"{{ENGINE_VERSION}}\", engineVersion],\n [\"ExampleGame\", identifier(name)],\n [\"Example Game\", title(name)],\n [\"example_game\", dartName(name)],\n [\"example-game\", name],\n ];\n return replacements.reduce((result, [from, to]) => result.replaceAll(from, to), contents);\n}\n\n/**\n * True when the bytes are valid UTF-8.\n *\n * This is not a guess at whether a file is \"binary\"; it is the precondition\n * of the operation. Token substitution is `String.replaceAll`, so a file that\n * cannot be decoded cannot take part, and one that can is safe to rewrite.\n *\n * Deliberately not an extension list. A DENY list (`.png`, `.jar`, …) fails\n * silently in the dangerous direction: the day someone adds a `.webp`, it is\n * corrupted with no error. An ALLOW list fails the safe way but fits this tree\n * badly: `Gemfile`, `Fastfile`, `.nvmrc`, `.fvmrc` and `.ruby-version` all\n * need rendering and none carry a usable extension, so it would have to be a\n * list of extensions *and* a list of bare filenames, both drifting.\n *\n * `.template` is not the signal either, despite the name: it marks files a\n * language server must not claim before they have an enclosing package. Five\n * of them contain no token at all, and nine token-bearing files are not\n * marked, so the two concepts are orthogonal here.\n *\n * `renderTree`'s test pins the resulting classification for the whole tree, so\n * this stays a reviewed decision rather than an invisible one.\n */\nconst utf8 = new TextDecoder(\"utf-8\", { fatal: true });\n\nexport function decodeUtf8(bytes: Buffer): string | undefined {\n try {\n return utf8.decode(bytes);\n } catch {\n return undefined;\n }\n}\n\nfunction renderTree(source: string, destination: string, name: string, manager: PackageManager, packageId: string): void {\n cpSync(source, destination, { recursive: true });\n // Walks the TEMPLATE, not the destination. The app overlay renders on top of\n // a `flutter create` result, so walking the destination meant rewriting\n // every file Flutter had just generated, including its binaries, for files\n // this scaffolder does not own and has no business touching.\n const visit = (directory: string): void => {\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n const templatePath = resolve(directory, entry.name);\n if (entry.isDirectory()) {\n visit(templatePath);\n continue;\n }\n if (!entry.isFile()) continue;\n\n const rendered = resolve(destination, relative(source, templatePath));\n const text = decodeUtf8(readFileSync(templatePath));\n // Undecodable files are already in place from the copy above, byte for\n // byte. Only decodable ones are rewritten.\n if (text !== undefined) {\n writeFileSync(rendered, render(text, name, manager, packageId));\n }\n // Template-only source must not be claimed by language servers before\n // it has an enclosing generated package. Restore the real extension\n // only in the rendered project.\n if (entry.name.endsWith(\".template\")) {\n renameSync(rendered, rendered.slice(0, -\".template\".length));\n }\n }\n };\n visit(source);\n\n // npm deliberately excludes files named `.gitignore` from package\n // tarballs. Their packaged twins live outside the C3 template so a direct\n // Git-based C3 render does not inherit a scaffolder-only helper file.\n const packagedGitignore = resolve(templatesRoot, \"scaffold\", `${basename(source)}.gitignore`);\n if (existsSync(packagedGitignore)) {\n writeFileSync(resolve(destination, \".gitignore\"), render(readFileSync(packagedGitignore, \"utf8\"), name, manager, packageId));\n }\n}\n\nfunction packageCommand(manager: PackageManager, operation: \"install\" | \"contract\" | \"cf-typegen\"): [string, string[]] {\n if (operation === \"install\") return [manager, [\"install\"]];\n return [manager, [\"run\", operation]];\n}\n\n/**\n * Appends `block` to a file this scaffolder does not own, as its own paragraph.\n *\n * **Append, never insert.** That is the rule the three callers below follow, and\n * it is what keeps them from competing with `flutter create` and `flutterfire\n * configure` for position in the same files. A pure append cannot collide with\n * whatever those tools write above it; the one edit here that ever needed a\n * position, prepending a Kotlin `import`, was broken by an AGP upgrade and has\n * since been rewritten away. See MAINTAINERS.md for the whole doctrine, including\n * why FlutterFire's `// START:`/`// END:` marker comments are deliberately not\n * copied.\n *\n * `contents` is passed in rather than read here because every caller has already\n * read the file to decide whether its block is present, and two of them assert\n * on the shape of what they found. This owns the whitespace and nothing else.\n *\n * That is worth one function because it was previously written three times with\n * two different answers, so the desugaring block got a blank line before it and\n * the other two did not, and the two Gradle blocks ended up flush against each\n * other in every generated project. Separation belongs to the append, so the\n * block constants carry no leading or trailing newline of their own.\n */\nfunction appendBlock(path: string, contents: string, block: string): void {\n appendFileSync(path, `${contents.endsWith(\"\\n\") ? \"\" : \"\\n\"}\\n${block}\\n`);\n}\n\nconst androidDesugaring = `// flutter_local_notifications requires desugaring in the application module.\n// A library plugin cannot enable this compiler setting transitively.\nandroid {\n compileOptions {\n isCoreLibraryDesugaringEnabled = true\n }\n}\n\ndependencies {\n coreLibraryDesugaring(\"com.android.tools:desugar_jdk_libs:2.1.4\")\n}`;\n\nfunction enableAndroidCoreLibraryDesugaring(appRoot: string): void {\n const gradlePath = resolve(appRoot, \"android/app/build.gradle.kts\");\n const gradle = readFileSync(gradlePath, \"utf8\");\n if (!gradle.includes('id(\"com.android.application\")')) {\n throw new Error(`Flutter created an unexpected Android application build file: ${gradlePath}`);\n }\n const settingExists = gradle.includes(\"isCoreLibraryDesugaringEnabled\");\n const dependencyExists = gradle.includes(\"coreLibraryDesugaring(\");\n if (settingExists && dependencyExists) return;\n if (settingExists || dependencyExists) {\n throw new Error(`Flutter created an incomplete Android core library desugaring configuration: ${gradlePath}`);\n }\n appendBlock(gradlePath, gradle, androidDesugaring);\n}\n\n// A second top-level `android { }` block is valid Gradle Kotlin DSL, since Gradle\n// merges repeated extension-configuration blocks in one file, which is what\n// lets this stay a pure append, same as the desugaring block above. A second\n// top-level `plugins { }` block is NOT valid (Gradle allows exactly one per\n// script), which is why the Crashlytics Gradle plugin registration,\n// `flutterfire configure`'s own territory, is deliberately left alone here.\n//\n// Parsed with the Kotlin stdlib rather than `java.util.Properties`, which is\n// what keeps this appendable. `Properties` would need a real `import`, and\n// Kotlin requires imports before every other top-level declaration, so using it\n// meant also reaching into the very start of a file this scaffolder does not\n// own. A fully-qualified `java.util.Properties()` reference was tried to avoid\n// that, and does not resolve under AGP 9's Kotlin DSL script compilation\n// (`flutter create`'s current default): \"Unresolved reference 'util'\".\n// Confirmed by actually building a scaffolded project, not just reading it.\nconst androidReleaseSigning = `val releaseKeyProperties: Map<String, String> =\n rootProject.file(\"key.properties\")\n .takeIf { it.exists() }\n ?.readLines()\n ?.map { it.trim() }\n ?.filter { it.isNotEmpty() && !it.startsWith(\"#\") && it.contains(\"=\") }\n ?.associate { it.substringBefore(\"=\").trim() to it.substringAfter(\"=\").trim() }\n .orEmpty()\n\nandroid {\n signingConfigs {\n create(\"release\") {\n storeFile = releaseKeyProperties[\"storeFile\"]?.let { file(it) }\n storePassword = releaseKeyProperties[\"storePassword\"]\n keyAlias = releaseKeyProperties[\"keyAlias\"]\n keyPassword = releaseKeyProperties[\"keyPassword\"]\n }\n }\n buildTypes {\n release {\n signingConfig = if (releaseKeyProperties[\"storeFile\"] != null)\n signingConfigs.getByName(\"release\")\n else\n signingConfigs.getByName(\"debug\")\n isMinifyEnabled = true\n isShrinkResources = true\n proguardFiles(\n getDefaultProguardFile(\"proguard-android-optimize.txt\"),\n \"proguard-rules.pro\",\n )\n }\n }\n}`;\n\nfunction enableAndroidReleaseSigning(appRoot: string): void {\n const gradlePath = resolve(appRoot, \"android/app/build.gradle.kts\");\n const gradle = readFileSync(gradlePath, \"utf8\");\n // Not `gradle.includes(\"signingConfigs\")`, because Flutter's own template already\n // contains that substring (`signingConfig = signingConfigs.getByName(\"debug\")`),\n // so that check would always short-circuit and never append anything.\n if (gradle.includes(\"releaseKeyProperties\")) return;\n // A pure append. This previously also PREPENDED `import java.util.Properties`,\n // the most position-dependent edit here and the one already broken once by an\n // AGP upgrade; see the block above for what replaced it.\n appendBlock(gradlePath, gradle, androidReleaseSigning);\n}\n\n// `flutter_launcher_icons`/`flutter_native_splash` read these as plain\n// top-level pubspec keys, so appending is safe regardless of what\n// `flutter create` already wrote under `flutter:`. Deliberately omits\n// `ios`/`macos`, since `scaffoldGame` only creates `--platforms android,web`, and\n// `flutter_launcher_icons` errors if told to target a platform whose\n// directory doesn't exist.\n// The colours are the EigenInteractive palette (ink #1B1E24, paper #F4F1EA) because the\n// shipped placeholder art is the EigenInteractive mark: the adaptive foreground is the\n// reversed, light-on-dark variant, so an ink background is what makes it\n// legible. Rebranding a game means replacing the four PNGs *and* these\n// colours together. See https://eigeninteractive.com/docs/ship-it/branding.\nconst launcherIconsAndSplashConfig = `flutter_launcher_icons:\n android: true\n web:\n generate: true\n image_path: \"assets/icon/icon.png\"\n image_path: \"assets/icon/icon.png\"\n adaptive_icon_background: \"#1B1E24\"\n adaptive_icon_foreground: \"assets/icon/icon_foreground.png\"\n min_sdk_android: 21\n\nflutter_native_splash:\n color: \"#F4F1EA\"\n color_dark: \"#1B1E24\"\n image: assets/icon/splash.png\n image_dark: assets/icon/splash_dark.png\n fullscreen: true\n android_12:\n color: \"#F4F1EA\"\n color_dark: \"#1B1E24\"\n image: assets/icon/splash.png\n image_dark: assets/icon/splash_dark.png\n icon_background_color: \"#F4F1EA\"\n icon_background_color_dark: \"#1B1E24\"\n web: true`;\n\nfunction configureLauncherIconsAndSplash(appRoot: string): void {\n const pubspecPath = resolve(appRoot, \"pubspec.yaml\");\n const pubspec = readFileSync(pubspecPath, \"utf8\");\n if (pubspec.includes(\"flutter_launcher_icons:\")) return;\n appendBlock(pubspecPath, pubspec, launcherIconsAndSplashConfig);\n}\n\nexport interface AddContinuousIntegrationOptions {\n directory: string;\n /** Overrides the manager recorded in the project's own package.json. */\n packageManager?: PackageManager;\n}\n\n/**\n * Adds the GitHub Actions workflows to an existing generated project.\n *\n * The companion to `ci: false`: a game can be built and played locally for as\n * long as its author likes, then gain the same PR gate and signed release\n * pipeline a `--ci` scaffold would have produced.\n */\nexport function addContinuousIntegration(options: AddContinuousIntegrationOptions): { root: string; files: string[] } {\n const root = resolve(options.directory);\n const manifestPath = resolve(root, \"package.json\");\n if (!existsSync(manifestPath) || !existsSync(resolve(root, \"server\")) || !existsSync(resolve(root, \"app\"))) {\n throw new Error(`not an EigenInteractive game project (expected package.json, server/ and app/): ${root}`);\n }\n\n const manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as {\n name?: string;\n scripts?: Record<string, string>;\n };\n const name = gameSlug(manifest.name ?? basename(root));\n\n // The generated `contract` script embeds the manager the project was\n // scaffolded with (`cd server && pnpm run contract && …`), which is a more\n // reliable signal than a lockfile: it is present before anything is\n // installed, and it is what the project actually uses.\n const recorded = manifest.scripts?.contract?.includes(\"pnpm \") ? \"pnpm\" : manifest.scripts?.contract?.includes(\"npm \") ? \"npm\" : undefined;\n const manager = options.packageManager ?? recorded ?? detectPackageManager() ?? \"pnpm\";\n\n // Only `{{PACKAGE_MANAGER}}` appears in these templates, but the real\n // package id is read back rather than reconstructed, so a project scaffolded\n // under a different `--org` cannot be silently rewritten to `com.example`.\n const appfile = resolve(root, \"app/fastlane/Appfile\");\n const packageId = existsSync(appfile) ? (/package_name\\(\"([^\"]+)\"\\)/.exec(readFileSync(appfile, \"utf8\"))?.[1] ?? `com.example.${dartName(name)}`) : `com.example.${dartName(name)}`;\n\n const workflows = resolve(root, \".github/workflows\");\n const existing = existsSync(workflows) ? readdirSync(workflows).filter((f) => f === \"checks.yml\" || f === \"release.yml\") : [];\n if (existing.length > 0) {\n throw new Error(`refusing to overwrite existing workflows: ${existing.join(\", \")}`);\n }\n\n renderTree(resolve(templatesRoot, \"ci\"), root, name, manager, packageId);\n return { root, files: [\".github/workflows/checks.yml\", \".github/workflows/release.yml\"] };\n}\n\n/** Asks a command a question. `ok` is \"ran and succeeded\"; a tool that is not installed and one that fails are both `false`, because neither can be used. */\nexport type Probe = (command: string, args: string[]) => { ok: boolean; stdout: string };\n\nconst probeCommand: Probe = (command, args) => {\n try {\n return { ok: true, stdout: execFileSync(command, args, { encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"] }) };\n } catch {\n return { ok: false, stdout: \"\" };\n }\n};\n\n/** One thing standing between this machine and a configured Firebase project, and the single command that clears it. */\nexport interface FirebaseProblem {\n /** Said as a sentence fragment, so it reads after \"Firebase is not set up here:\". */\n reason: string;\n /** The one command that fixes this, and nothing else. */\n fix: string;\n}\n\nexport type FirebaseReadiness = { ready: true } | { ready: false; problems: FirebaseProblem[] };\n\n/**\n * Whether this machine can configure Firebase, asked *before* the scaffold\n * rather than after it.\n *\n * `configure_firebase` runs the same three checks and is the authority on\n * them; this one exists only to move the answer earlier. Learning that\n * `flutterfire` is missing costs nothing here and costs two minutes of Flutter\n * and pub at the far end, which is where the step actually runs.\n *\n * Every problem, not the first one. The checks are independent (two CLIs from\n * two ecosystems, plus a sign-in) so short-circuiting turns one setup into a\n * sequence of runs that each reveal the next missing piece. Reported in the\n * order they have to be fixed in: the CLI, then the sign-in it stores, then\n * the bridge that consumes both.\n *\n * The sign-in check fails open, for the same reason it does there: only an\n * answer that positively reports no accounts counts as \"no\", so a `firebase`\n * that errors or grows a different output shape is left to the command that\n * actually needs the credentials.\n */\nexport function firebaseReadiness(probe: Probe = probeCommand): FirebaseReadiness {\n const problems: FirebaseProblem[] = [];\n\n if (probe(\"firebase\", [\"--version\"]).ok) {\n if (signedOut(probe)) problems.push({ reason: \"no Google account is signed in to the Firebase CLI\", fix: \"firebase login\" });\n } else {\n // Nothing to say about the sign-in: the CLI that would answer is the one\n // that is missing, and `firebase login` is what installing leads to anyway.\n // Google's own installer, which picks a standalone binary or npm to suit\n // the machine. `npm install -g firebase-tools` also works and is what this\n // used to print, but it needs a global npm prefix the reader may not have\n // write access to, and it is not the install the Firebase docs lead with.\n problems.push({ reason: \"the `firebase` CLI is not installed\", fix: \"curl -sL https://firebase.tools | bash\" });\n }\n\n if (!probe(\"flutterfire\", [\"--version\"]).ok) {\n problems.push({ reason: \"the `flutterfire` CLI is not installed\", fix: \"dart pub global activate flutterfire_cli\" });\n }\n\n return problems.length === 0 ? { ready: true } : { ready: false, problems };\n}\n\n/**\n * Whether the Firebase CLI holds no credentials.\n *\n * `login:list --json` prints the stored refresh and access tokens along with\n * the account list. Read the shape, count the entries, and never surface the\n * output: not in a warning, not in a captured stream, not on the failure\n * path. That is why this returns a boolean rather than the response.\n */\nfunction signedOut(probe: Probe): boolean {\n const accounts = probe(\"firebase\", [\"login:list\", \"--json\"]);\n if (!accounts.ok) return false;\n try {\n const { result } = JSON.parse(accounts.stdout) as { result?: unknown };\n return Array.isArray(result) && result.length === 0;\n } catch {\n // Unparseable is not evidence of anything.\n return false;\n }\n}\n\n/**\n * Whether the scaffold would land inside a repository that already exists.\n *\n * Asked of the nearest ancestor that exists, because the destination does not\n * yet. The point is not to change what {@link scaffoldGame} does, which already\n * declines to nest a repository, but to stop the CLI asking a question whose\n * answer cannot matter.\n */\n/**\n * Why this destination cannot be scaffolded into, said as a whole message, or\n * `undefined` when there is nothing in the way.\n *\n * A directory that exists and is *empty* is not in the way, since people make\n * one out of habit, so it is removed and rewritten rather than refused over\n * nothing. Anything with contents in it is refused, and a cloned repository is\n * not an exception: `.git` is in the way like any other entry, and the message\n * names it. Publishing into one would mean parking `.git`, renaming staging\n * over the top and putting it back, with a failure in the middle able to\n * orphan a remote, which is a lot of care to spend on a flow that has a\n * one-line alternative.\n *\n * Refused, and deliberately not offered as a \"remove it and continue?\"\n * question, which is where several scaffolders in this family go. This one\n * writes ninety-odd files and runs `flutter create`; the cost of getting that\n * answer wrong against a mistyped path has no upper bound, and `rm -rf` is one\n * command that belongs to the person who can see what is in there. Every other\n * question this CLI asks is reversible. This one would not be.\n *\n * Exported so the CLI can ask it before the first question rather than after\n * the last one. {@link scaffoldGame} asks it again, for callers that are not\n * the CLI.\n */\nexport function destinationProblem(directory: string): string | undefined {\n const root = resolve(directory);\n if (!existsSync(root)) return undefined;\n\n if (!statSync(root).isDirectory()) return `${root} already exists, and is a file.`;\n\n const entries = readdirSync(root);\n if (entries.length === 0) return undefined;\n\n // Named, not counted. \"not empty\" invites an `ls`; the three that are\n // actually there usually settle whether this was the wrong path or a\n // directory that has already been scaffolded once.\n const shown = entries.slice(0, 3).sort().join(\", \");\n const rest = entries.length > 3 ? `, and ${entries.length - 3} more` : \"\";\n return `${root} already exists, and is not empty: it holds ${shown}${rest}.\\n\\nScaffold somewhere else, or clear it out yourself. This will not delete a directory you already had.`;\n}\n\nexport function insideWorkTree(directory: string, probe: Probe = probeCommand): boolean {\n let candidate = resolve(directory);\n while (!existsSync(candidate)) {\n const parent = dirname(candidate);\n if (parent === candidate) return false;\n candidate = parent;\n }\n return probe(\"git\", [\"-C\", candidate, \"rev-parse\", \"--is-inside-work-tree\"]).ok;\n}\n\n/**\n * Runs the Flutter client's `configure_firebase` against the generated app.\n *\n * The command owns everything about how Firebase is configured: which\n * platforms, which CLIs must exist, whether anyone is signed in, and what to\n * do when no project has been chosen yet. This only decides *when*: before the\n * scaffold commit, so a configured project is committed configured.\n *\n * Not fatal. Every failure here (a missing `flutterfire`, no Google login, a\n * cancelled picker) leaves a complete and usable project that is exactly what\n * a scaffold without `--firebase` produces, so it warns with the command to\n * re-run and lets the commit happen.\n */\nfunction configureFirebase(appRoot: string, project: boolean | string, run: Runner, reporter: Reporter): \"configured\" | \"failed\" {\n // FlutterFire asks before overwriting `firebase_options.dart`, and the\n // scaffold has just written one, a throwing placeholder whose entire\n // purpose is to be replaced by this step. Answering that is a question with\n // one right answer, so the placeholder is moved out of the way and the\n // question never gets asked.\n const placeholder = resolve(appRoot, \"lib/firebase_options.dart\");\n const parked = `${placeholder}.placeholder`;\n const parking = existsSync(placeholder);\n if (parking) renameSync(placeholder, parked);\n\n try {\n // `dart run` compiles the package executable on first use and says so.\n // Doing it against `--help`, which returns immediately, moves that noise\n // into a step whose output can be captured; the real run cannot be, since\n // FlutterFire prompts through it.\n reporter.step(\"Preparing the Firebase configurator\", () => run(\"dart\", [\"run\", \"eigen_firebase:configure_firebase\", \"--help\"], appRoot));\n // `--worker` is what makes this fill in `FIREBASE_PROJECT_ID` as well as\n // the app's own values. An app-only repository omits it and gets the app\n // half; a combined scaffold has the Worker one directory over.\n reporter.handOver(\"Configuring Firebase\", () => run(\"dart\", [\"run\", \"eigen_firebase:configure_firebase\", \"--worker\", \"../server\", ...(typeof project === \"string\" ? [\"--project\", project] : [])], appRoot));\n if (parking) rmSync(parked, { force: true });\n return \"configured\";\n } catch {\n // Back only if nothing took its place. FlutterFire writes\n // `firebase_options.dart` before the service worker configuration is\n // derived from it, so a late failure leaves a real one that is worth more\n // than the placeholder.\n if (parking) {\n if (existsSync(placeholder)) rmSync(parked, { force: true });\n else renameSync(parked, placeholder);\n }\n reporter.warn(\"Could not configure Firebase. The project is complete. Run `firebase:configure` yourself, then commit what it writes.\");\n return \"failed\";\n }\n}\n\n/**\n * Commits the scaffold, so the first `git diff` is the first game change.\n *\n * This matters more here than in a scaffolder that only writes source. The\n * bootstrap runs `flutter_launcher_icons` and `flutter_native_splash`, which\n * write generated-but-committed files across `android/`, `web/` and\n * `assets/`; without a baseline the first branding change is indistinguishable\n * from the ninety files the scaffolder happened to produce.\n *\n * Nothing here is fatal. The project is complete and valid before this runs,\n * so a missing `git`, or the unconfigured `user.email` that a fresh CI image\n * has, warns and leaves the tree alone rather than discarding a scaffold that\n * took two minutes of Flutter and pub to produce.\n */\nfunction initialiseRepository(root: string, name: string, run: Runner, reporter: Reporter): GitOutcome {\n // Scaffolding inside an existing checkout (a monorepo, or a repository\n // created ahead of time) is a legitimate thing to do, and a nested\n // repository there is silent breakage: the outer `git add` records a gitlink\n // and the app's files never leave the machine. Asked directly rather than\n // through `run`, because it is a question, not a step.\n try {\n execFileSync(\"git\", [\"rev-parse\", \"--is-inside-work-tree\"], { cwd: root, stdio: \"ignore\" });\n return \"existing\";\n } catch {\n // Not inside a work tree, which is the case this function is for.\n }\n\n try {\n run(\"git\", [\"init\", \"--quiet\"], root);\n run(\"git\", [\"add\", \"--all\"], root);\n } catch {\n reporter.warn(\"Could not initialise a git repository. The project is complete. Run `git init` yourself when ready.\");\n return \"failed\";\n }\n\n try {\n run(\"git\", [\"commit\", \"--quiet\", \"--message\", `Scaffold ${name}`], root);\n } catch {\n reporter.warn(`Initialised a repository and staged the scaffold, but could not commit it. Set \\`user.name\\` and \\`user.email\\`, then \\`git commit -m \"Scaffold ${name}\"\\`.`);\n return \"failed\";\n }\n\n return \"committed\";\n}\n\nexport function scaffoldGame(options: ScaffoldOptions): ScaffoldResult {\n const root = resolve(options.directory);\n const name = gameSlug(basename(root));\n const manager = options.packageManager ?? detectPackageManager() ?? \"pnpm\";\n const org = options.org?.trim() || \"com.example\";\n // Fastlane's `Appfile` names the same package the build actually produces,\n // and the CLI shows the same one before asking.\n const packageId = applicationId(root, org);\n const bootstrap = options.bootstrap ?? true;\n const reporter = options.reporter ?? plainReporter;\n const run = options.run ?? capturingRunner(reporter);\n\n const occupied = destinationProblem(root);\n if (occupied !== undefined) throw new Error(occupied);\n // Empty, or `destinationProblem` would have said so. Removed rather than\n // scaffolded into, because the rename below publishes the staging directory\n // *as* this path and cannot do that while something is standing there.\n if (existsSync(root)) rmdirSync(root);\n\n mkdirSync(dirname(root), { recursive: true });\n\n // Build beside the destination and publish it with one rename. Failed\n // subprocesses never leave a half-scaffolded project at the requested path.\n const stagingRoot = mkdtempSync(resolve(dirname(root), `.${basename(root)}-`));\n try {\n const serverRoot = resolve(stagingRoot, \"server\");\n const appRoot = resolve(stagingRoot, \"app\");\n\n renderTree(resolve(templatesRoot, \"worker\"), serverRoot, name, manager, packageId);\n renderTree(resolve(templatesRoot, \"project\"), stagingRoot, name, manager, packageId);\n // Opt-in. release.yml wants an upload keystore and a Play service account\n // that a brand-new project does not have, so generating it by default\n // means a red X on main from the first push until someone sets both up.\n // `create-eigen-game add ci` writes the same files whenever it is wanted.\n if (options.ci) renderTree(resolve(templatesRoot, \"ci\"), stagingRoot, name, manager, packageId);\n\n if (bootstrap) {\n reporter.step(\"Creating the Flutter app\", () => {\n run(\"flutter\", [\"create\", \"--empty\", \"--platforms\", \"android,web\", \"--project-name\", dartName(name), \"--org\", org, appRoot], stagingRoot);\n enableAndroidCoreLibraryDesugaring(appRoot);\n enableAndroidReleaseSigning(appRoot);\n });\n } else {\n mkdirSync(appRoot, { recursive: true });\n }\n renderTree(resolve(templatesRoot, \"app-overlay\"), appRoot, name, manager, packageId);\n\n if (bootstrap) {\n reporter.step(\"Adding the Flutter packages\", () => {\n configureLauncherIconsAndSplash(appRoot);\n run(\"flutter\", [\"pub\", \"add\", `eigen_flutter@${flutterClientVersion}`, `eigen_shell@${flutterShellVersion}`, `eigen_firebase@${firebaseAdapterVersion}`, \"firebase_core@^4.9.0\"], appRoot);\n run(\"flutter\", [\"pub\", \"add\", `dev:eigen_codegen@${dartCodegenVersion}`, \"dev:flutter_launcher_icons\", \"dev:flutter_native_splash\"], appRoot);\n });\n // Actually apply the icons rather than only configuring them. Both tools\n // write generated files (mipmaps, `web/icons/`, splash drawables and\n // styles) that are committed, not built; leaving them unrun would ship\n // Flutter's own blue logo until a game author happened to notice.\n reporter.step(\"Generating the icons and splash\", () => {\n run(\"dart\", [\"run\", \"flutter_launcher_icons\"], appRoot);\n run(\"dart\", [\"run\", \"flutter_native_splash:create\"], appRoot);\n });\n const [install, installArgs] = packageCommand(manager, \"install\");\n const [typegen, typegenArgs] = packageCommand(manager, \"cf-typegen\");\n reporter.step(\"Installing the Worker packages\", () => {\n run(install, installArgs, serverRoot);\n // `worker-configuration.d.ts` is committed, and its header stamps the\n // workerd version that produced the runtime types. `wrangler` floats\n // on a caret and Cloudflare ships workerd about weekly, so the copy in\n // `templates/worker` is stale for every scaffold made more than a few\n // days after it was last regenerated, and `wrangler dev` opens by\n // saying the types might be out of date. Regenerating against the\n // wrangler that was just installed, rather than the one this package\n // was built with, is what makes that true. It has to follow the server\n // install for the same reason it is worth doing: it reads the wrangler\n // that install resolved.\n run(typegen, typegenArgs, serverRoot);\n // The root holds Biome, which lints and formats both the Worker and\n // the repository's own JSON. Installed after the server so a failure\n // here costs the cheaper of the two.\n run(install, installArgs, stagingRoot);\n });\n const [contract, contractArgs] = packageCommand(manager, \"contract\");\n reporter.step(\"Generating the contract and payloads\", () => {\n run(contract, contractArgs, serverRoot);\n run(\"dart\", [\"run\", \"eigen_codegen:generate_payloads\", \"--contract\", \"../server/game-contract.json\", \"--output\", \"lib/game/generated/payloads.dart\", \"--fixtures-output\", \"test/fixtures\"], appRoot);\n });\n }\n\n renameSync(stagingRoot, root);\n } catch (error) {\n rmSync(stagingRoot, { recursive: true, force: true });\n throw error;\n }\n\n // Both steps below are deliberately outside the staging guard: the project\n // is published by this point, and neither a Firebase project that could not\n // be configured nor a repository that failed to initialise is a reason to\n // delete two minutes of Flutter and pub.\n //\n // Firebase first, so what it writes (`firebase.json`,\n // `android/app/google-services.json`, the real `firebase_options.dart` and\n // `web/firebase-config.js` in place of the throwing placeholders, and\n // FlutterFire's two Gradle edits) lands in the scaffold commit rather than\n // arriving as the project's first diff.\n const firebase = options.firebase ? configureFirebase(resolve(root, \"app\"), options.firebase, run, reporter) : \"skipped\";\n // What that step settled, so the summary can name what it did not.\n // `configure_firebase` does the writing, including into the Worker's\n // wrangler.jsonc, which is what `--worker` above is for.\n const link = firebase === \"configured\" ? readFirebaseLink(root) : undefined;\n const git = (options.git ?? bootstrap) ? initialiseRepository(root, name, run, reporter) : \"skipped\";\n\n return { root, name, git, firebase, link };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAWA,MAAa,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6B9B,SAAgB,YAAY,UAA8B,oBAAsD;CAC9G,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,4BAA4B,eAAe,oEAAoE;CAGjI,MAAM,UAAU,SAAS,WAAW,YAAY,IAAI,mBAAmB,IAAI;CAE3E,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,8BAA8B,eAAe,OAAO,SAAS,qFAAqF;CAMpK,IAAI,CAAC,sCAAsC,KAAK,OAAO,GACrD,MAAM,IAAI,MAAM,qBAAqB,eAAe,uC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tD,IAAI,QAAQ,CAAC,OAAO,8BAA8B,GAAG,OAAO;GAC9D,CAAC;GACD,MAAM,CAAC,SAAS,eAAe,eAAe,SAAS,SAAS;GAChE,MAAM,CAAC,SAAS,eAAe,eAAe,SAAS,YAAY;GACnE,SAAS,KAAK,wCAAwC;IACpD,IAAI,SAAS,aAAa,UAAU;IAWpC,IAAI,SAAS,aAAa,UAAU;IAIpC,IAAI,SAAS,aAAa,WAAW;GACvC,CAAC;GACD,MAAM,CAAC,UAAU,gBAAgB,eAAe,SAAS,UAAU;GACnE,SAAS,KAAK,8CAA8C;IAC1D,IAAI,UAAU,cAAc,UAAU;IACtC,IAAI,QAAQ;KAAC;KAAO;KAAmC;KAAc;KAAgC;KAAY;KAAoC;KAAqB;IAAe,GAAG,OAAO;GACrM,CAAC;EACH;EAEA,WAAW,aAAa,IAAI;CAC9B,SAAS,OAAO;EACd,OAAO,aAAa;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACpD,MAAM;CACR;CAYA,MAAM,WAAW,QAAQ,WAAW,kBAAkB,QAAQ,MAAM,KAAK,GAAG,QAAQ,UAAU,KAAK,QAAQ,IAAI;CAI/G,MAAM,OAAO,aAAa,eAAe,iBAAiB,IAAI,IAAI,KAAA;CAGlE,OAAO;EAAE;EAAM;EAAM,KAFR,QAAQ,OAAO,YAAa,qBAAqB,MAAM,MAAM,KAAK,QAAQ,IAAI;EAEjE;EAAU;CAAK;AAC3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-eigen-game",
3
- "version": "0.14.2",
3
+ "version": "0.15.0",
4
4
  "license": "MIT",
5
5
  "description": "Scaffold an EigenInteractive game Worker and Flutter app without cloning the engine repositories.",
6
6
  "type": "module",
@@ -19,19 +19,19 @@
19
19
  "templates"
20
20
  ],
21
21
  "dependencies": {
22
- "@clack/core": "^1.4.3",
23
- "@clack/prompts": "^1.7.0",
22
+ "@clack/core": "^1.5.0",
23
+ "@clack/prompts": "^1.8.0",
24
24
  "picocolors": "^1.1.1"
25
25
  },
26
26
  "devDependencies": {
27
- "@types/node": "^26.4.1",
27
+ "@types/node": "^26.5.0",
28
28
  "typescript": "~6.0.2",
29
29
  "vitest": "^4.1.11",
30
- "wrangler": "^4.129.0",
31
- "zod": "^4.4.3",
32
- "@eigeninteractive/rules": "0.6.1",
33
- "@eigeninteractive/server": "0.6.1",
34
- "@eigeninteractive/testkit": "0.6.1"
30
+ "wrangler": "^4.130.0",
31
+ "zod": "^4.5.4",
32
+ "@eigeninteractive/rules": "0.7.0",
33
+ "@eigeninteractive/testkit": "0.7.0",
34
+ "@eigeninteractive/server": "0.7.0"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=22"
package/src/index.ts CHANGED
@@ -227,7 +227,7 @@ const engineVersion = engineRange((JSON.parse(readFileSync(resolve(packageRoot,
227
227
  * that still speaks the 0.3.x wire.
228
228
  *
229
229
  * Raised to 0.7.0 for the 0.5.x engine line and the `PlayerLimits` client API.
230
- * vNext later simplified the wire again: versions are a contiguous prefix and
230
+ * The platform later simplified the wire again: versions are a contiguous prefix and
231
231
  * generic mutation identities are gone. The next Flutter release must raise
232
232
  * this floor before the corresponding scaffolder is published.
233
233
  *
package/src/prompt.ts CHANGED
@@ -45,6 +45,18 @@ export const DEFAULT_ORG = "com.example";
45
45
 
46
46
  const bar = color.gray(S_BAR);
47
47
 
48
+ /**
49
+ * Clack's public `confirm` type allows any symbol even though the prompt only
50
+ * returns its cancellation symbol. Keep that dependency detail at this
51
+ * boundary, and fail loudly if a future Clack version introduces another
52
+ * non-boolean result instead of silently treating it as "yes".
53
+ */
54
+ function booleanAnswer(answer: boolean | symbol): boolean | null {
55
+ if (isCancel(answer)) return null;
56
+ if (typeof answer !== "boolean") throw new TypeError("A confirmation prompt returned neither a boolean nor Clack's cancellation symbol.");
57
+ return answer;
58
+ }
59
+
48
60
  /** A `com.acme.chess` answer to a game called `chess`, which yields `com.acme.chess.chess`. */
49
61
  export function repeatsGameName(org: string, game: string): boolean {
50
62
  return org.split(".").at(-1) === game;
@@ -108,8 +120,9 @@ export async function askForOrg(game: string, registering: boolean, io: Io = {})
108
120
  input,
109
121
  output,
110
122
  });
111
- if (isCancel(shorten)) return null;
112
- if (shorten) return shorter;
123
+ const shouldShorten = booleanAnswer(shorten);
124
+ if (shouldShorten === null) return null;
125
+ if (shouldShorten) return shorter;
113
126
  }
114
127
 
115
128
  return org;
@@ -132,7 +145,7 @@ async function ask(message: string, initialValue: boolean, hint: string, io: Io)
132
145
  const output = io.output ?? process.stdout;
133
146
  output.write(`${bar}\n${bar} ${color.dim(hint)}\n`);
134
147
  const answer = await confirm({ message, initialValue, input, output });
135
- return isCancel(answer) ? null : answer;
148
+ return booleanAnswer(answer);
136
149
  }
137
150
 
138
151
  /**