create-eigen-game 0.8.0 → 0.9.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/README.md CHANGED
@@ -9,12 +9,32 @@ pnpm create eigen-game my-game
9
9
  npm create eigen-game@latest my-game
10
10
  ```
11
11
 
12
- The command detects npm or pnpm from the invoking package manager. Pass
13
- `--package-manager npm|pnpm` to override it and `--org games.example` to set
14
- the Flutter organization. The destination basename is the one required
15
- lowercase kebab-case slug. The CLI derives the display name (`My Game`), Dart
16
- package name (`my_game`), and type prefix (`MyGame`) from `my-game`; there is no
17
- separate name or prefix input.
12
+ The destination basename is the one required lowercase kebab-case slug. The CLI
13
+ derives the display name (`My Game`), Dart package name (`my_game`), and type
14
+ prefix (`MyGame`) from `my-game`; there is no separate name or prefix input.
15
+
16
+ Everything else is asked. Each question has exactly one flag that answers it,
17
+ so passing the flag skips the question:
18
+
19
+ | Question | Flag |
20
+ | --- | --- |
21
+ | The Android/iOS organization, which prefixes the permanent `applicationId` | `--org <reverse-domain>` |
22
+ | Which Firebase project to configure against, or whether to skip it | `--firebase-project <id>`, `--no-firebase` |
23
+ | Initialise a repository and commit the scaffold | `--git`, `--no-git` |
24
+ | Emit the GitHub Actions workflows | `--workflows`, `--no-workflows` |
25
+ | Which package manager the generated scripts use | `--package-manager npm\|pnpm` |
26
+
27
+ The package manager is only asked when nothing else can say — `npm create` and
28
+ `pnpm create` both announce themselves. The Firebase question only appears when
29
+ the `firebase` and `flutterfire` CLIs are not both installed and signed in, and
30
+ its default is to stop rather than scaffold, since a scaffolded app throws
31
+ `Firebase is not configured` at launch until a project is connected.
32
+
33
+ With no terminal to ask on — CI, a pipe, an agent session — an unanswered
34
+ question is an error rather than a default chosen where nobody can see it, and
35
+ the message prints the whole command to re-run with each default filled in.
36
+ `--org` is why: `com.example.my_game` is permanent once Google Play has taken
37
+ an upload.
18
38
 
19
39
  The generated project has two application-owned halves:
20
40
 
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
2
  import { execFileSync } from "child_process";
3
- import { appendFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
3
+ import { appendFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmdirSync, rmSync, statSync, writeFileSync } from "fs";
4
4
  import { basename, dirname, relative, resolve } from "path";
5
5
  import { fileURLToPath } from "url";
6
6
 
@@ -122,7 +122,7 @@ function renderTree(source, destination, name, manager, packageId) {
122
122
  }
123
123
  function packageCommand(manager, operation) {
124
124
  if (operation === "install") return [manager, ["install"]];
125
- return [manager, ["run", "contract"]];
125
+ return [manager, ["run", operation]];
126
126
  }
127
127
  var androidDesugaring = `// flutter_local_notifications requires desugaring in the application module.
128
128
  // A library plugin cannot enable this compiler setting transitively.
@@ -249,25 +249,48 @@ var probeCommand = (command, args) => {
249
249
  return { ok: false, stdout: "" };
250
250
  }
251
251
  };
252
- var firebaseTools = {
253
- flutterfire: "dart pub global activate flutterfire_cli",
254
- firebase: "npm install -g firebase-tools"
255
- };
256
252
  function firebaseReadiness(probe = probeCommand) {
257
- for (const [tool, fix] of Object.entries(firebaseTools)) {
258
- if (!probe(tool, ["--version"]).ok) return { ready: false, reason: `\`${tool}\` is not installed`, fix };
253
+ const problems = [];
254
+ if (probe("firebase", ["--version"]).ok) {
255
+ if (signedOut(probe)) problems.push({ reason: "no Google account is signed in to the Firebase CLI", fix: "firebase login" });
256
+ } else {
257
+ problems.push({ reason: "the `firebase` CLI is not installed", fix: "npm install -g firebase-tools" });
258
+ }
259
+ if (!probe("flutterfire", ["--version"]).ok) {
260
+ problems.push({ reason: "the `flutterfire` CLI is not installed", fix: "dart pub global activate flutterfire_cli" });
259
261
  }
262
+ return problems.length === 0 ? { ready: true } : { ready: false, problems };
263
+ }
264
+ function signedOut(probe) {
260
265
  const accounts = probe("firebase", ["login:list", "--json"]);
261
- if (accounts.ok) {
262
- try {
263
- const { result } = JSON.parse(accounts.stdout);
264
- if (Array.isArray(result) && result.length === 0) {
265
- return { ready: false, reason: "no Google account is signed in to the Firebase CLI", fix: "firebase login" };
266
- }
267
- } catch {
268
- }
266
+ if (!accounts.ok) return false;
267
+ try {
268
+ const { result } = JSON.parse(accounts.stdout);
269
+ return Array.isArray(result) && result.length === 0;
270
+ } catch {
271
+ return false;
272
+ }
273
+ }
274
+ function destinationProblem(directory) {
275
+ const root = resolve(directory);
276
+ if (!existsSync(root)) return void 0;
277
+ if (!statSync(root).isDirectory()) return `${root} already exists, and is a file.`;
278
+ const entries = readdirSync(root);
279
+ if (entries.length === 0) return void 0;
280
+ const shown = entries.slice(0, 3).sort().join(", ");
281
+ const rest = entries.length > 3 ? `, and ${entries.length - 3} more` : "";
282
+ return `${root} already exists, and is not empty \u2014 it holds ${shown}${rest}.
283
+
284
+ Scaffold somewhere else, or clear it out yourself. This will not delete a directory you already had.`;
285
+ }
286
+ function insideWorkTree(directory, probe = probeCommand) {
287
+ let candidate = resolve(directory);
288
+ while (!existsSync(candidate)) {
289
+ const parent = dirname(candidate);
290
+ if (parent === candidate) return false;
291
+ candidate = parent;
269
292
  }
270
- return { ready: true };
293
+ return probe("git", ["-C", candidate, "rev-parse", "--is-inside-work-tree"]).ok;
271
294
  }
272
295
  function configureFirebase(appRoot, project, run, reporter) {
273
296
  const placeholder = resolve(appRoot, "lib/firebase_options.dart");
@@ -318,7 +341,9 @@ function scaffoldGame(options) {
318
341
  const bootstrap = options.bootstrap ?? true;
319
342
  const reporter = options.reporter ?? plainReporter;
320
343
  const run = options.run ?? capturingRunner(reporter);
321
- if (existsSync(root)) throw new Error(`target already exists: ${root}`);
344
+ const occupied = destinationProblem(root);
345
+ if (occupied !== void 0) throw new Error(occupied);
346
+ if (existsSync(root)) rmdirSync(root);
322
347
  mkdirSync(dirname(root), { recursive: true });
323
348
  const stagingRoot = mkdtempSync(resolve(dirname(root), `.${basename(root)}-`));
324
349
  try {
@@ -348,8 +373,10 @@ function scaffoldGame(options) {
348
373
  run("dart", ["run", "flutter_native_splash:create"], appRoot);
349
374
  });
350
375
  const [install, installArgs] = packageCommand(manager, "install");
376
+ const [typegen, typegenArgs] = packageCommand(manager, "cf-typegen");
351
377
  reporter.step("Installing the Worker packages", () => {
352
378
  run(install, installArgs, serverRoot);
379
+ run(typegen, typegenArgs, serverRoot);
353
380
  run(install, installArgs, stagingRoot);
354
381
  });
355
382
  const [contract, contractArgs] = packageCommand(manager, "contract");
@@ -377,6 +404,8 @@ export {
377
404
  decodeUtf8,
378
405
  addContinuousIntegration,
379
406
  firebaseReadiness,
407
+ destinationProblem,
408
+ insideWorkTree,
380
409
  scaffoldGame
381
410
  };
382
- //# sourceMappingURL=chunk-6WJG743G.js.map
411
+ //# sourceMappingURL=chunk-XTTEOV5U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/engine-range.ts"],"sourcesContent":["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\";\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\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 — and `eigen_flutter` lives in another repository, versioned\n * independently, so nothing in this repository can compute which release that\n * is. Only compiling a scaffolded app establishes it, which is what the\n * `scaffold` job in checks.yml does 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 shell\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.3.0` already picks the newest\n * 0.3.x at scaffold time, which is the part the pub.dev lookup was duplicating.\n * What it deliberately cannot do is cross to 0.4.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.3.0 because the notification icon moved into `eigen_flutter`'s\n * Android plugin: the scaffold stopped shipping `ic_notification.xml`, so a\n * game resolving 0.2.x would reference a drawable nothing provides.\n */\nconst flutterClientVersion = \"^0.3.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\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 appendFileSync(gradlePath, `${gradle.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\"}${androidDesugaring}\\n`);\n}\n\n// A second top-level `android { }` block is valid Gradle Kotlin DSL — 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// `Properties` needs a real `import`, prepended separately below — a\n// fully-qualified `java.util.Properties()` reference here was tried first,\n// to avoid needing to touch the top of the file at all, but fails to\n// 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\")` — 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 // because Kotlin requires imports before every other top-level declaration —\n // which meant reaching into the very start of a file this scaffolder does\n // not own, the most position-dependent edit here and the one already broken\n // once by an AGP upgrade. Parsing `key.properties` with the Kotlin stdlib\n // needs no import, so the edit is now append-only and cannot collide with\n // whatever Flutter or `flutterfire configure` writes above it.\n appendFileSync(gradlePath, `${gradle.endsWith(\"\\n\") ? \"\" : \"\\n\"}${androidReleaseSigning}\\n`);\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` — `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 = `\nflutter_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`;\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 appendFileSync(pubspecPath, `${pubspec.endsWith(\"\\n\") ? \"\" : \"\\n\"}${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 problems.push({ reason: \"the `firebase` CLI is not installed\", fix: \"npm install -g firebase-tools\" });\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 — it 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 — people make one\n * 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_flutter:configure_firebase\", \"--help\"], appRoot));\n reporter.handOver(\"Configuring Firebase\", () => run(\"dart\", [\"run\", \"eigen_flutter:configure_firebase\", ...(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}`, \"firebase_core@^4.9.0\", \"firebase_messaging@^16.2.2\"], appRoot);\n run(\"flutter\", [\"pub\", \"add\", \"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_flutter: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 const git = (options.git ?? bootstrap) ? initialiseRepository(root, name, run, reporter) : \"skipped\";\n\n return { root, name, git, firebase };\n}\n","/**\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, 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"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB,QAAQ,YAAY,WAAW,aAAa,aAAa,cAAc,YAAY,WAAW,QAAQ,UAAU,qBAAqB;AAC9J,SAAS,UAAU,SAAS,UAAU,eAAe;AACrD,SAAS,qB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AK,SAAS;AACrC;","names":[]}
package/dist/cli.js CHANGED
@@ -2,22 +2,26 @@
2
2
  import {
3
3
  addContinuousIntegration,
4
4
  applicationId,
5
+ destinationProblem,
5
6
  detectPackageManager,
6
7
  firebaseReadiness,
8
+ insideWorkTree,
7
9
  normaliseTerminalWidth,
8
10
  plainReporter,
9
11
  scaffoldGame
10
- } from "./chunk-6WJG743G.js";
12
+ } from "./chunk-XTTEOV5U.js";
11
13
 
12
14
  // src/cli.ts
13
- import { basename, resolve } from "path";
15
+ import { readFileSync } from "fs";
16
+ import { basename, dirname, resolve } from "path";
17
+ import { fileURLToPath } from "url";
14
18
  import { parseArgs } from "util";
15
19
  import { cancel, intro, isCI, isTTY, log, note, outro, taskLog } from "@clack/prompts";
16
20
  import color2 from "picocolors";
17
21
 
18
22
  // src/prompt.ts
19
23
  import { TextPrompt } from "@clack/core";
20
- import { confirm, isCancel, S_BAR, S_BAR_END, symbol } from "@clack/prompts";
24
+ import { confirm, isCancel, S_BAR, S_BAR_END, select, symbol } from "@clack/prompts";
21
25
  import color from "picocolors";
22
26
  var ORG = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)+$/;
23
27
  var DEFAULT_ORG = "com.example";
@@ -67,13 +71,43 @@ ${bar} ${color.yellow(this.error ?? "")}` : "";
67
71
  }
68
72
  return org;
69
73
  }
74
+ async function ask(message, initialValue, hint, io) {
75
+ const input = io.input ?? process.stdin;
76
+ const output = io.output ?? process.stdout;
77
+ output.write(`${bar}
78
+ ${bar} ${color.dim(hint)}
79
+ `);
80
+ const answer = await confirm({ message, initialValue, input, output });
81
+ return isCancel(answer) ? null : answer;
82
+ }
83
+ function askToScaffoldWithoutFirebase(io = {}) {
84
+ 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);
85
+ }
86
+ function askForGit(io = {}) {
87
+ return ask("Initialise a git repository and commit the scaffold?", true, "Commits once, so your first diff is your first game change.", io);
88
+ }
89
+ function askForWorkflows(io = {}) {
90
+ 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);
91
+ }
92
+ async function askForPackageManager(io = {}) {
93
+ const answer = await select({
94
+ message: "Which package manager should the generated scripts use?",
95
+ options: [
96
+ { value: "pnpm", label: "pnpm" },
97
+ { value: "npm", label: "npm" }
98
+ ],
99
+ input: io.input ?? process.stdin,
100
+ output: io.output ?? process.stdout
101
+ });
102
+ return isCancel(answer) ? null : answer;
103
+ }
70
104
 
71
105
  // src/summary.ts
72
106
  function columns(rows) {
73
107
  const width = Math.max(...rows.map(([left]) => left.length));
74
108
  return rows.map(([left, right]) => ` ${left.padEnd(width)} ${right}`);
75
109
  }
76
- function summarise(result, manager, ci) {
110
+ function summarise(result, manager, workflows) {
77
111
  const run = manager === "npm" ? "npm run" : "pnpm";
78
112
  const status = [];
79
113
  if (result.git === "committed") status.push(`Committed as "Scaffold ${result.name}"`);
@@ -99,46 +133,55 @@ function summarise(result, manager, ci) {
99
133
  ])
100
134
  ].join("\n");
101
135
  const footnotes = ["Docs: https://eigeninteractive.com"];
102
- if (!ci) footnotes.unshift("No CI workflows yet: `create-eigen-game add ci` writes them when shipping is the next step.");
136
+ if (!workflows) footnotes.unshift("No CI workflows yet: `create-eigen-game add workflows` writes them when shipping is the next step.");
103
137
  return { status, next, footnotes, headline: `${result.name} is ready, at ${result.root}` };
104
138
  }
105
139
 
106
140
  // src/cli.ts
141
+ var version = JSON.parse(readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../package.json"), "utf8")).version;
142
+ var PREREQUISITES = "https://eigeninteractive.com/docs/getting-started/prerequisites";
107
143
  var help = `Usage: create-eigen-game <game-slug> [options]
108
- create-eigen-game add ci [directory] [options]
144
+ create-eigen-game add workflows [directory] [options]
109
145
 
110
146
  Creates one repository containing an EigenInteractive Cloudflare Worker and
111
147
  Flutter app, and commits it. The destination basename is the lowercase
112
148
  kebab-case game slug; the CLI derives the display name, Dart package name, and
113
149
  Dart/TypeScript type prefix from it.
114
150
 
151
+ Every option below answers a question the CLI would otherwise ask. Pass it to
152
+ skip the question; leave it out to be asked. With no terminal to ask on \u2014 CI, a
153
+ pipe, an agent session \u2014 an unanswered question is an error rather than a
154
+ default quietly chosen for you, and the message prints the command to re-run.
155
+
115
156
  Options:
116
- --ci Also emit the GitHub Actions workflows (off by
117
- default: release.yml needs an upload keystore and a
118
- Play service account, so it fails until both exist)
119
- --org <reverse-domain> Android/iOS organization (default: com.example). The
120
- applicationId is this plus the game name, as in
121
- com.example.my_game. Asked for when omitted.
122
- --no-firebase Do not configure Firebase. Firebase is configured
123
- before the first commit by default, whenever the two
124
- CLIs are installed and signed in; this skips it and
125
- prints the command to run later
157
+ --org <reverse-domain> Android/iOS organization. The applicationId is this
158
+ plus the game name, as in com.example.my_game, and
159
+ Google Play makes it permanent at first upload
126
160
  --firebase-project <id>
127
- The Firebase project to configure against, instead of
128
- being asked. Works without a terminal, which is how
129
- CI drives the step
130
- --no-git Do not initialise a repository or commit the scaffold
131
- --package-manager <pm> npm or pnpm (defaults to the invoking package manager)
161
+ The Firebase project to configure against. Also the
162
+ form that works with no terminal, since otherwise
163
+ FlutterFire asks
164
+ --no-firebase Do not configure Firebase, leaving firebase:configure
165
+ as a step for later
166
+ --git, --no-git Initialise a repository and commit the scaffold
167
+ --workflows, --no-workflows
168
+ Emit the GitHub Actions workflows. release.yml needs
169
+ an upload keystore and a Play service account, so it
170
+ fails on every push until both exist
171
+ --package-manager <pm> npm or pnpm. Taken from the invoking package manager
172
+ when there is one, so this is for global installs
132
173
  -h, --help Show this help
174
+ -v, --version Show the version
133
175
 
134
176
  Commands:
135
- add ci [directory] Add the workflows to an existing project, for when
177
+ add workflows [directory]
178
+ Add the workflows to an existing project, for when
136
179
  you are ready to ship rather than at scaffold time.
137
180
  Defaults to the current directory.`;
138
181
  normaliseTerminalWidth(process.stdout);
139
182
  var decorated = isTTY(process.stdout) && !isCI();
140
183
  var ui = decorated ? {
141
- open: () => intro(color2.inverse(" create-eigen-game ")),
184
+ open: () => intro(color2.inverse(" EigenInteractive ")),
142
185
  info: (message) => log.info(message),
143
186
  warn: (message) => log.warn(message),
144
187
  success: (message) => log.success(message),
@@ -146,7 +189,7 @@ var ui = decorated ? {
146
189
  close: (message) => outro(color2.bold(message)),
147
190
  stop: (message) => cancel(message)
148
191
  } : {
149
- open: () => console.log("\ncreate-eigen-game\n"),
192
+ open: () => console.log("\nEigenInteractive\n"),
150
193
  info: (message) => console.log(message),
151
194
  warn: (message) => console.warn(message),
152
195
  success: (message) => console.log(message),
@@ -163,24 +206,42 @@ function resolveManager(requested) {
163
206
  }
164
207
  return requested;
165
208
  }
166
- function chooseFirebase(disabled, project) {
167
- if (project !== void 0) {
168
- if (project.trim() === "") throw new Error("--firebase-project needs a project id");
169
- return project.trim();
170
- }
171
- if (disabled === true) return false;
172
- if (!process.stdin.isTTY) {
173
- ui.info("No terminal to choose a Firebase project on, so Firebase is left unconfigured.\nName one with --firebase-project <id>, or configure it later.");
174
- return false;
175
- }
176
- const readiness = firebaseReadiness();
177
- if (readiness.ready) return true;
178
- ui.warn(`Skipping Firebase: ${readiness.reason}.
209
+ function greet() {
210
+ ui.open();
211
+ 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.");
212
+ ui.info(
213
+ `Firebase signs your players in. The Worker verifies Firebase ID tokens to decide who
214
+ holds a seat, and sends turn notifications through the same project \u2014 so a scaffolded
215
+ app throws ${color2.dim("Firebase is not configured")} at launch until one is connected.
179
216
 
180
- ${color2.cyan(readiness.fix)}
217
+ It is free to start, one project serves every game you build, and this connects yours
218
+ as it goes. ${color2.dim(PREREQUISITES)}`
219
+ );
220
+ }
221
+ function firebaseReport(problems) {
222
+ const lines = problems.flatMap((problem) => [` ${problem.reason}`, ` ${color2.cyan(problem.fix)}`]);
223
+ if (problems.some((problem) => problem.fix.startsWith("dart pub"))) {
224
+ lines.push(` ${color2.dim('\u2026then, if your shell cannot find it: export PATH="$PATH":"$HOME/.pub-cache/bin"')}`);
225
+ }
226
+ return lines.join("\n");
227
+ }
228
+ function stopForFirebase(problems) {
229
+ note(`${problems.map((problem) => ` ${color2.cyan(problem.fix)}`).join("\n")}
181
230
 
182
- The scaffold does not need it, and ends by naming the command that finishes the job.`);
183
- return false;
231
+ Then run this again.
232
+ ${color2.dim(PREREQUISITES)}`, "Set up Firebase");
233
+ ui.stop("Nothing was written.");
234
+ process.exitCode = 1;
235
+ }
236
+ function unanswered(directory, missing) {
237
+ const command = ["npx create-eigen-game", directory, ...missing.map((question) => question.suggestion)].join(" ");
238
+ 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 \u2014 read them before you run it:", "", ` ${command}`].join("\n");
239
+ }
240
+ function flagPair(yes, no, name) {
241
+ if (yes === true && no === true) throw new Error(`--${name} and --no-${name} contradict each other`);
242
+ if (yes === true) return true;
243
+ if (no === true) return false;
244
+ return void 0;
184
245
  }
185
246
  function resolveOrg(value) {
186
247
  if (value.trim() === "") return void 0;
@@ -237,13 +298,18 @@ async function main(args) {
237
298
  strict: true,
238
299
  options: {
239
300
  help: { type: "boolean", short: "h" },
240
- ci: { type: "boolean" },
301
+ version: { type: "boolean", short: "v" },
241
302
  org: { type: "string" },
242
- // Declared under the name it is typed with, as `no-git` is: `parseArgs`
243
- // has no boolean negation.
244
- "no-firebase": { type: "boolean" },
245
303
  "firebase-project": { type: "string" },
304
+ // Each negation is declared under the name it is typed with, because
305
+ // `parseArgs` has no boolean negation of its own. `flagPair` puts the
306
+ // two halves back together, and the third state — neither given — is the
307
+ // one that matters: it is what turns the flag into a question.
308
+ "no-firebase": { type: "boolean" },
309
+ git: { type: "boolean" },
246
310
  "no-git": { type: "boolean" },
311
+ workflows: { type: "boolean" },
312
+ "no-workflows": { type: "boolean" },
247
313
  "package-manager": { type: "string" }
248
314
  }
249
315
  });
@@ -251,9 +317,13 @@ async function main(args) {
251
317
  console.log(help);
252
318
  return;
253
319
  }
320
+ if (values.version) {
321
+ console.log(version);
322
+ return;
323
+ }
254
324
  const requestedManager = resolveManager(values["package-manager"]);
255
325
  if (positionals[0] === "add") {
256
- if (positionals[1] !== "ci") {
326
+ if (positionals[1] !== "workflows" && positionals[1] !== "ci") {
257
327
  throw new Error(`unknown subcommand: add ${positionals[1] ?? ""}
258
328
 
259
329
  ${help}`.trim());
@@ -276,34 +346,97 @@ ${help}`);
276
346
  ${help}`);
277
347
  }
278
348
  const directory = positionals[0];
279
- const manager = requestedManager ?? detectPackageManager() ?? "pnpm";
280
- ui.open();
281
349
  const game = basename(resolve(directory));
282
350
  applicationId(directory);
283
- const firebase = chooseFirebase(values["no-firebase"], values["firebase-project"]);
351
+ const occupied = destinationProblem(directory);
352
+ if (occupied !== void 0) throw new Error(occupied);
353
+ greet();
354
+ const interactive = process.stdin.isTTY === true;
355
+ const missing = [];
356
+ const cancelled = () => {
357
+ ui.stop("Nothing was written.");
358
+ process.exitCode = 130;
359
+ };
360
+ const needsFlag = (flags, suggestion, fallback) => {
361
+ missing.push({ flags, suggestion });
362
+ return fallback;
363
+ };
364
+ const project = values["firebase-project"]?.trim();
365
+ if (project === "") throw new Error("--firebase-project needs a project id");
366
+ if (project !== void 0 && values["no-firebase"] === true) {
367
+ throw new Error("--firebase-project and --no-firebase contradict each other");
368
+ }
369
+ let firebase = false;
370
+ if (project !== void 0) {
371
+ firebase = project;
372
+ } else if (values["no-firebase"] !== true) {
373
+ const readiness = firebaseReadiness();
374
+ if (readiness.ready) {
375
+ if (interactive) firebase = true;
376
+ else firebase = needsFlag("--firebase-project <id>, or --no-firebase", "--no-firebase", false);
377
+ } else {
378
+ ui.warn(`Firebase is not set up on this machine:
379
+
380
+ ${firebaseReport(readiness.problems)}`);
381
+ if (!interactive) {
382
+ firebase = needsFlag("--no-firebase, to scaffold without it", "--no-firebase", false);
383
+ } else {
384
+ const carryOn = await askToScaffoldWithoutFirebase();
385
+ if (carryOn === null) return cancelled();
386
+ if (!carryOn) return stopForFirebase(readiness.problems);
387
+ }
388
+ }
389
+ }
284
390
  let org;
285
- if (values.org === void 0 && process.stdin.isTTY) {
391
+ if (values.org !== void 0) {
392
+ org = resolveOrg(values.org);
393
+ } else if (interactive) {
286
394
  const answer = await askForOrg(game.replaceAll("-", "_"), firebase !== false);
287
- if (answer === null) {
288
- ui.stop("Nothing was written.");
289
- process.exitCode = 130;
290
- return;
291
- }
395
+ if (answer === null) return cancelled();
292
396
  org = answer;
293
- } else if (values.org !== void 0) {
294
- org = resolveOrg(values.org);
397
+ } else {
398
+ org = needsFlag("--org <reverse-domain>", `--org ${DEFAULT_ORG}`, void 0);
399
+ }
400
+ let git = flagPair(values.git, values["no-git"], "git");
401
+ if (git === void 0 && insideWorkTree(directory)) git = true;
402
+ if (git === void 0) {
403
+ if (!interactive) git = needsFlag("--git or --no-git", "--git", true);
404
+ else {
405
+ const answer = await askForGit();
406
+ if (answer === null) return cancelled();
407
+ git = answer;
408
+ }
409
+ }
410
+ let workflows = flagPair(values.workflows, values["no-workflows"], "workflows");
411
+ if (workflows === void 0) {
412
+ if (!interactive) workflows = needsFlag("--workflows or --no-workflows", "--no-workflows", false);
413
+ else {
414
+ const answer = await askForWorkflows();
415
+ if (answer === null) return cancelled();
416
+ workflows = answer;
417
+ }
418
+ }
419
+ let manager = requestedManager ?? detectPackageManager();
420
+ if (manager === void 0) {
421
+ if (!interactive) manager = needsFlag("--package-manager <npm|pnpm>", "--package-manager pnpm", "pnpm");
422
+ else {
423
+ const answer = await askForPackageManager();
424
+ if (answer === null) return cancelled();
425
+ manager = answer;
426
+ }
295
427
  }
428
+ if (missing.length > 0) throw new Error(unanswered(directory, missing));
296
429
  ui.success(`applicationId ${color2.bold(applicationId(directory, org))}`);
297
430
  const result = scaffoldGame({
298
431
  directory,
299
432
  org,
300
433
  packageManager: manager,
301
- ci: values.ci,
302
- git: !values["no-git"],
434
+ ci: workflows,
435
+ git,
303
436
  firebase,
304
437
  reporter: clackReporter()
305
438
  });
306
- const { status, next, footnotes, headline } = summarise(result, manager, values.ci === true);
439
+ const { status, next, footnotes, headline } = summarise(result, manager, workflows);
307
440
  for (const line of status) ui.success(line);
308
441
  ui.block(next);
309
442
  for (const line of footnotes) ui.info(line);
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/prompt.ts","../src/summary.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { basename, resolve } from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { cancel, intro, isCI, isTTY, log, note, outro, taskLog } from \"@clack/prompts\";\nimport color from \"picocolors\";\nimport { addContinuousIntegration, applicationId, detectPackageManager, firebaseReadiness, normaliseTerminalWidth, type PackageManager, plainReporter, type Reporter, scaffoldGame } from \"./index.js\";\nimport { askForOrg, DEFAULT_ORG, ORG } from \"./prompt.js\";\nimport { summarise } from \"./summary.js\";\n\nconst help = `Usage: create-eigen-game <game-slug> [options]\n create-eigen-game add ci [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\nOptions:\n --ci Also emit the GitHub Actions workflows (off by\n default: release.yml needs an upload keystore and a\n Play service account, so it fails until both exist)\n --org <reverse-domain> Android/iOS organization (default: com.example). The\n applicationId is this plus the game name, as in\n com.example.my_game. Asked for when omitted.\n --no-firebase Do not configure Firebase. Firebase is configured\n before the first commit by default, whenever the two\n CLIs are installed and signed in; this skips it and\n prints the command to run later\n --firebase-project <id>\n The Firebase project to configure against, instead of\n being asked. Works without a terminal, which is how\n CI drives the step\n --no-git Do not initialise a repository or commit the scaffold\n --package-manager <pm> npm or pnpm (defaults to the invoking package manager)\n -h, --help Show this help\n\nCommands:\n add ci [directory] 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(\" create-eigen-game \")),\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(\"\\ncreate-eigen-game\\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 * Whether this run configures Firebase, and against which project.\n *\n * On by default, because a scaffold that stops short of it is not a runnable\n * app: `firebase_options.dart` is a throwing placeholder until this has run,\n * so the first `flutter run` ends at `Firebase is not configured`. Doing it\n * before the scaffold commit also keeps the six files it writes out of the\n * project's first diff.\n *\n * Never at the cost of the scaffold, though. Everything that would make the\n * step fail — no CLIs, no login, no terminal to answer the project prompt on —\n * turns it off and says so, here, before the two minutes of Flutter and pub\n * rather than after them. What is left is exactly a `--no-firebase` scaffold,\n * and the summary ends by naming the command that finishes the job.\n */\nfunction chooseFirebase(disabled: boolean | undefined, project: string | undefined): boolean | string {\n // An explicitly named project settles it: FlutterFire has nothing to ask, so\n // this is also the form that works on a machine with no terminal.\n if (project !== undefined) {\n if (project.trim() === \"\") throw new Error(\"--firebase-project needs a project id\");\n return project.trim();\n }\n if (disabled === true) return false;\n\n if (!process.stdin.isTTY) {\n ui.info(\"No terminal to choose a Firebase project on, so Firebase is left unconfigured.\\nName one with --firebase-project <id>, or configure it later.\");\n return false;\n }\n\n const readiness = firebaseReadiness();\n if (readiness.ready) return true;\n\n ui.warn(`Skipping Firebase: ${readiness.reason}.\\n\\n ${color.cyan(readiness.fix)}\\n\\nThe scaffold does not need it, and ends by naming the command that finishes the job.`);\n return false;\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 ci: { type: \"boolean\" },\n org: { type: \"string\" },\n // Declared under the name it is typed with, as `no-git` is: `parseArgs`\n // has no boolean negation.\n \"no-firebase\": { type: \"boolean\" },\n \"firebase-project\": { type: \"string\" },\n \"no-git\": { type: \"boolean\" },\n \"package-manager\": { type: \"string\" },\n },\n });\n\n if (values.help) {\n console.log(help);\n return;\n }\n\n const requestedManager = resolveManager(values[\"package-manager\"]);\n\n if (positionals[0] === \"add\") {\n if (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 const manager = requestedManager ?? detectPackageManager() ?? \"pnpm\";\n\n ui.open();\n\n // Both decisions about what this run will do, settled before any of it\n // starts. `applicationId` validates the slug on the way, so a destination\n // that cannot be a game name fails here rather than after the first prompt.\n const game = basename(resolve(directory));\n applicationId(directory);\n const firebase = chooseFirebase(values[\"no-firebase\"], values[\"firebase-project\"]);\n\n let org: string | undefined;\n if (values.org === undefined && process.stdin.isTTY) {\n const answer = await askForOrg(game.replaceAll(\"-\", \"_\"), firebase !== false);\n if (answer === null) {\n ui.stop(\"Nothing was written.\");\n process.exitCode = 130;\n return;\n }\n org = answer;\n } else if (values.org !== undefined) {\n org = resolveOrg(values.org);\n }\n\n ui.success(`applicationId ${color.bold(applicationId(directory, org))}`);\n\n const result = scaffoldGame({\n directory,\n org,\n packageManager: manager,\n ci: values.ci,\n git: !values[\"no-git\"],\n firebase,\n reporter: clackReporter(),\n });\n\n const { status, next, footnotes, headline } = summarise(result, manager, values.ci === true);\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","/**\n * The organization prompt, which is the one question this CLI asks and the one\n * answer that is expensive to get wrong.\n *\n * Its own module because it drops to `@clack/core` rather than using\n * `@clack/prompts`' `text`. The reason is 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, symbol } from \"@clack/prompts\";\nimport color from \"picocolors\";\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: { input?: Readable; output?: Writable } = {}): 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 * 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, ci: 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\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 ].join(\"\\n\");\n\n const footnotes = [\"Docs: https://eigeninteractive.com\"];\n if (!ci) footnotes.unshift(\"No CI workflows yet: `create-eigen-game add ci` writes them when shipping is the next step.\");\n\n return { status, next, footnotes, headline: `${result.name} is ready, at ${result.root}` };\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,UAAU,eAAe;AAClC,SAAS,iBAAiB;AAC1B,SAAS,QAAQ,OAAO,MAAM,OAAO,KAAK,MAAM,OAAO,eAAe;AACtE,OAAOA,YAAW;;;ACalB,SAAS,kBAAkB;AAC3B,SAAS,SAAS,UAAU,OAAO,WAAW,cAAc;AAC5D,OAAO,WAAW;AASX,IAAM,MAAM;AAGZ,IAAM,cAAc;AAE3B,IAAM,MAAM,MAAM,KAAK,KAAK;AAGrB,SAAS,gBAAgB,KAAa,MAAuB;AAClE,SAAO,IAAI,MAAM,GAAG,EAAE,GAAG,EAAE,MAAM;AACnC;AAGO,SAAS,gBAAgB,KAAiC;AAC/D,QAAM,UAAU,IAAI,MAAM,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG;AACpD,SAAO,IAAI,KAAK,OAA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,UAAU,QAAQ,SAAS,OAAO,OAAO,IAAI;AAC3F,aAAW,QAAQ,OAAQ,IAAG,QAAQ,IAAI;AAC1C,KAAG,MAAM,IAAI;AACb,aAAW,QAAQ,UAAW,IAAG,KAAK,IAAI;AAC1C,KAAG,MAAM,QAAQ;AACnB;AAEA,IAAI;AACF,QAAM,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC;AAClC,SAAS,OAAgB;AACvB,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,KAAG,KAAK,sBAAsB,OAAO,EAAE;AACvC,UAAQ,WAAW;AACrB;","names":["color","color","result"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/prompt.ts","../src/summary.ts"],"sourcesContent":["#!/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 — `missing` throws before anything is\n * 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","/**\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\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 ].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"],"mappings":";;;;;;;;;;;;;;AACA,SAAS,oBAAoB;AAC7B,SAAS,UAAU,SAAS,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142,18 @@ type Probe = (command: string, args: string[]) => {
142
142
  ok: boolean;
143
143
  stdout: string;
144
144
  };
145
+ /** One thing standing between this machine and a configured Firebase project, and the single command that clears it. */
146
+ interface FirebaseProblem {
147
+ /** Said as a sentence fragment, so it reads after "Firebase is not set up here:". */
148
+ reason: string;
149
+ /** The one command that fixes this, and nothing else. */
150
+ fix: string;
151
+ }
145
152
  type FirebaseReadiness = {
146
153
  ready: true;
147
154
  } | {
148
155
  ready: false;
149
- reason: string;
150
- fix: string;
156
+ problems: FirebaseProblem[];
151
157
  };
152
158
  /**
153
159
  * Whether this machine can configure Firebase, asked *before* the scaffold
@@ -158,12 +164,52 @@ type FirebaseReadiness = {
158
164
  * `flutterfire` is missing costs nothing here and costs two minutes of Flutter
159
165
  * and pub at the far end, which is where the step actually runs.
160
166
  *
167
+ * Every problem, not the first one. The checks are independent — two CLIs from
168
+ * two ecosystems, plus a sign-in — so short-circuiting turns one setup into a
169
+ * sequence of runs that each reveal the next missing piece. Reported in the
170
+ * order they have to be fixed in: the CLI, then the sign-in it stores, then
171
+ * the bridge that consumes both.
172
+ *
161
173
  * The sign-in check fails open, for the same reason it does there: only an
162
174
  * answer that positively reports no accounts counts as "no", so a `firebase`
163
175
  * that errors or grows a different output shape is left to the command that
164
176
  * actually needs the credentials.
165
177
  */
166
178
  declare function firebaseReadiness(probe?: Probe): FirebaseReadiness;
179
+ /**
180
+ * Whether the scaffold would land inside a repository that already exists.
181
+ *
182
+ * Asked of the nearest ancestor that exists, because the destination does not
183
+ * yet. The point is not to change what {@link scaffoldGame} does — it already
184
+ * declines to nest a repository — but to stop the CLI asking a question whose
185
+ * answer cannot matter.
186
+ */
187
+ /**
188
+ * Why this destination cannot be scaffolded into, said as a whole message, or
189
+ * `undefined` when there is nothing in the way.
190
+ *
191
+ * A directory that exists and is *empty* is not in the way — people make one
192
+ * out of habit — so it is removed and rewritten rather than refused over
193
+ * nothing. Anything with contents in it is refused, and a cloned repository is
194
+ * not an exception: `.git` is in the way like any other entry, and the message
195
+ * names it. Publishing into one would mean parking `.git`, renaming staging
196
+ * over the top and putting it back, with a failure in the middle able to
197
+ * orphan a remote — which is a lot of care to spend on a flow that has a
198
+ * one-line alternative.
199
+ *
200
+ * Refused, and deliberately not offered as a "remove it and continue?"
201
+ * question, which is where several scaffolders in this family go. This one
202
+ * writes ninety-odd files and runs `flutter create`; the cost of getting that
203
+ * answer wrong against a mistyped path has no upper bound, and `rm -rf` is one
204
+ * command that belongs to the person who can see what is in there. Every other
205
+ * question this CLI asks is reversible. This one would not be.
206
+ *
207
+ * Exported so the CLI can ask it before the first question rather than after
208
+ * the last one — {@link scaffoldGame} asks it again, for callers that are not
209
+ * the CLI.
210
+ */
211
+ declare function destinationProblem(directory: string): string | undefined;
212
+ declare function insideWorkTree(directory: string, probe?: Probe): boolean;
167
213
  declare function scaffoldGame(options: ScaffoldOptions): ScaffoldResult;
168
214
 
169
- export { type AddContinuousIntegrationOptions, type FirebaseReadiness, type GitOutcome, type PackageManager, type Probe, type Reporter, type Runner, type ScaffoldOptions, type ScaffoldResult, addContinuousIntegration, applicationId, capturingRunner, decodeUtf8, detectPackageManager, firebaseReadiness, normaliseTerminalWidth, plainReporter, scaffoldGame };
215
+ export { type AddContinuousIntegrationOptions, type FirebaseProblem, type FirebaseReadiness, type GitOutcome, type PackageManager, type Probe, type Reporter, type Runner, type ScaffoldOptions, type ScaffoldResult, addContinuousIntegration, applicationId, capturingRunner, decodeUtf8, destinationProblem, detectPackageManager, firebaseReadiness, insideWorkTree, normaliseTerminalWidth, plainReporter, scaffoldGame };
package/dist/index.js CHANGED
@@ -3,19 +3,23 @@ import {
3
3
  applicationId,
4
4
  capturingRunner,
5
5
  decodeUtf8,
6
+ destinationProblem,
6
7
  detectPackageManager,
7
8
  firebaseReadiness,
9
+ insideWorkTree,
8
10
  normaliseTerminalWidth,
9
11
  plainReporter,
10
12
  scaffoldGame
11
- } from "./chunk-6WJG743G.js";
13
+ } from "./chunk-XTTEOV5U.js";
12
14
  export {
13
15
  addContinuousIntegration,
14
16
  applicationId,
15
17
  capturingRunner,
16
18
  decodeUtf8,
19
+ destinationProblem,
17
20
  detectPackageManager,
18
21
  firebaseReadiness,
22
+ insideWorkTree,
19
23
  normaliseTerminalWidth,
20
24
  plainReporter,
21
25
  scaffoldGame
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-eigen-game",
3
- "version": "0.8.0",
3
+ "version": "0.9.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",
@@ -30,8 +30,8 @@
30
30
  "wrangler": "^4.110.0",
31
31
  "zod": "^4.4.3",
32
32
  "@eigeninteractive/rules": "0.2.4",
33
- "@eigeninteractive/testkit": "0.2.4",
34
- "@eigeninteractive/server": "0.2.4"
33
+ "@eigeninteractive/server": "0.2.4",
34
+ "@eigeninteractive/testkit": "0.2.4"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=22"
@@ -168,11 +168,12 @@ upload keystore and a Play service account that a new project does not have
168
168
  ship, from the project root:
169
169
 
170
170
  ```sh
171
- npx create-eigen-game add ci
171
+ npx create-eigen-game add workflows
172
172
  ```
173
173
 
174
- That writes `.github/workflows/checks.yml` and `release.yml`. (Passing
175
- `--ci` at scaffold time does the same thing up front.)
174
+ That writes `.github/workflows/checks.yml` and `release.yml`. (Answering yes to
175
+ the workflows question at scaffold time, or passing `--workflows`, does the same
176
+ thing up front.)
176
177
 
177
178
  `release.yml` builds a signed, obfuscated Android App
178
179
  Bundle on every push to `main` and uploads it to the Play Store internal
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/engine-range.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport { appendFileSync, cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, 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\";\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\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 — and `eigen_flutter` lives in another repository, versioned\n * independently, so nothing in this repository can compute which release that\n * is. Only compiling a scaffolded app establishes it, which is what the\n * `scaffold` job in checks.yml does 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 shell\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.3.0` already picks the newest\n * 0.3.x at scaffold time, which is the part the pub.dev lookup was duplicating.\n * What it deliberately cannot do is cross to 0.4.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.3.0 because the notification icon moved into `eigen_flutter`'s\n * Android plugin: the scaffold stopped shipping `ic_notification.xml`, so a\n * game resolving 0.2.x would reference a drawable nothing provides.\n */\nconst flutterClientVersion = \"^0.3.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\"): [string, string[]] {\n if (operation === \"install\") return [manager, [\"install\"]];\n return [manager, [\"run\", \"contract\"]];\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 appendFileSync(gradlePath, `${gradle.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\"}${androidDesugaring}\\n`);\n}\n\n// A second top-level `android { }` block is valid Gradle Kotlin DSL — 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// `Properties` needs a real `import`, prepended separately below — a\n// fully-qualified `java.util.Properties()` reference here was tried first,\n// to avoid needing to touch the top of the file at all, but fails to\n// 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\")` — 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 // because Kotlin requires imports before every other top-level declaration —\n // which meant reaching into the very start of a file this scaffolder does\n // not own, the most position-dependent edit here and the one already broken\n // once by an AGP upgrade. Parsing `key.properties` with the Kotlin stdlib\n // needs no import, so the edit is now append-only and cannot collide with\n // whatever Flutter or `flutterfire configure` writes above it.\n appendFileSync(gradlePath, `${gradle.endsWith(\"\\n\") ? \"\" : \"\\n\"}${androidReleaseSigning}\\n`);\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` — `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 = `\nflutter_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`;\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 appendFileSync(pubspecPath, `${pubspec.endsWith(\"\\n\") ? \"\" : \"\\n\"}${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/** What each Firebase tool needs, for a machine that has neither. */\nconst firebaseTools: Record<string, string> = {\n flutterfire: \"dart pub global activate flutterfire_cli\",\n firebase: \"npm install -g firebase-tools\",\n};\n\nexport type FirebaseReadiness = { ready: true } | { ready: false; reason: string; fix: string };\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 * 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 for (const [tool, fix] of Object.entries(firebaseTools)) {\n if (!probe(tool, [\"--version\"]).ok) return { ready: false, reason: `\\`${tool}\\` is not installed`, fix };\n }\n\n const accounts = probe(\"firebase\", [\"login:list\", \"--json\"]);\n if (accounts.ok) {\n try {\n const { result } = JSON.parse(accounts.stdout) as { result?: unknown };\n if (Array.isArray(result) && result.length === 0) {\n return { ready: false, reason: \"no Google account is signed in to the Firebase CLI\", fix: \"firebase login\" };\n }\n } catch {\n // Unparseable is not evidence of anything.\n }\n }\n\n return { ready: true };\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_flutter:configure_firebase\", \"--help\"], appRoot));\n reporter.handOver(\"Configuring Firebase\", () => run(\"dart\", [\"run\", \"eigen_flutter:configure_firebase\", ...(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 if (existsSync(root)) throw new Error(`target already exists: ${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}`, \"firebase_core@^4.9.0\", \"firebase_messaging@^16.2.2\"], appRoot);\n run(\"flutter\", [\"pub\", \"add\", \"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 reporter.step(\"Installing the Worker packages\", () => {\n run(install, installArgs, 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_flutter: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 const git = (options.git ?? bootstrap) ? initialiseRepository(root, name, run, reporter) : \"skipped\";\n\n return { root, name, git, firebase };\n}\n","/**\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, 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"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB,QAAQ,YAAY,WAAW,aAAa,aAAa,cAAc,YAAY,QAAQ,qBAAqB;AACzI,SAAS,UAAU,SAAS,UAAU,eAAe;AACrD,SAAS,qBAAqB;;;ACQvB,IAAM,iBAAiB;AA6BvB,SAAS,YAAY,UAA8B,oBAAsD;AAC9G,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,4BAA4B,cAAc,qEAAqE;AAAA,EACjI;AAEA,QAAM,UAAU,SAAS,WAAW,YAAY,IAAI,mBAAmB,IAAI;AAE3E,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,8BAA8B,cAAc,QAAQ,QAAQ,sFAAsF;AAAA,EACpK;AAKA,MAAI,CAAC,sCAAsC,KAAK,OAAO,GAAG;AACxD,UAAM,IAAI,MAAM,qBAAqB,cAAc,wCAAwC,OAAO,GAAG;AAAA,EACvG;AAEA,SAAO,IAAI,OAAO;AACpB;;;ADdO,SAAS,uBAAuB,QAAqD;AAC1F,MAAI,OAAO,UAAU,SAAS,OAAO,WAAW,KAAK,EAAG,QAAO,UAAU;AAC3E;AAGO,IAAM,gBAA0B;AAAA,EACrC,MAAM,CAAC,QAAQ,SAAS,KAAK;AAAA,EAC7B,UAAU,CAAC,Q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