create-eigen-game 0.12.0 → 0.13.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.
@@ -78,7 +78,7 @@ var engineVersion = engineRange(JSON.parse(readFileSync2(resolve2(packageRoot, "
78
78
  const sibling = resolve2(packageRoot, "../server/package.json");
79
79
  return existsSync2(sibling) ? JSON.parse(readFileSync2(sibling, "utf8")).version : void 0;
80
80
  });
81
- var flutterClientVersion = "^0.6.0";
81
+ var flutterClientVersion = "^0.7.0";
82
82
  var gameSlug = (value) => {
83
83
  if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value)) {
84
84
  throw new Error("destination directory name must be a lowercase kebab-case slug, for example my-game");
@@ -436,4 +436,4 @@ export {
436
436
  insideWorkTree,
437
437
  scaffoldGame
438
438
  };
439
- //# sourceMappingURL=chunk-6BBSWZN4.js.map
439
+ //# sourceMappingURL=chunk-L7EVXO3Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/engine-range.ts","../src/link-firebase.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\";\nimport { type FirebaseLink, readFirebaseLink } from \"./link-firebase.js\";\n\nexport type { FirebaseLink } from \"./link-firebase.js\";\n\nexport type PackageManager = \"npm\" | \"pnpm\";\n\nexport type Runner = (command: string, args: string[], cwd: string) => void;\n\n/**\n * Where a scaffold says what it is doing, so that presentation belongs to the\n * caller and this module only has to name things.\n *\n * The default is the behaviour a library caller expects with no opinion:\n * subprocesses inherit the terminal and warnings go to `console.warn`. The CLI\n * substitutes one that captures each step's output and shows it only if the\n * step fails.\n */\nexport interface Reporter {\n /** Runs `body` as one named step. Its subprocesses can be captured. */\n step<T>(label: string, body: () => T): T;\n /**\n * Runs `body` as a step that owns the terminal, because something inside it\n * asks questions. FlutterFire is the only one.\n */\n handOver<T>(label: string, body: () => T): T;\n /** Output from a subprocess inside the current step. */\n emit(output: string): void;\n /** A failure the scaffold survives. */\n warn(message: string): void;\n /** Whether subprocesses must inherit the terminal rather than be captured. */\n readonly interactive: boolean;\n}\n\n/**\n * Gives a terminal that reports no width the width clack would have assumed.\n *\n * A pty can report itself as a TTY and set `columns` to 0. `script` does, and\n * so do some container terminals. clack falls back to 80 for a stream with no\n * `columns` at all, but `0` is a number and satisfies that check, so the width\n * it draws its rules from goes negative and a scaffold dies partway through\n * with `RangeError: Invalid string length`. Supplying the default its check\n * misses is better than giving up the drawing.\n */\nexport function normaliseTerminalWidth(stream: { isTTY?: boolean; columns?: number }): void {\n if (stream.isTTY === true && (stream.columns ?? 0) < 1) stream.columns = 80;\n}\n\n/** Runs every step plainly, which is what a library caller gets by default. */\nexport const plainReporter: Reporter = {\n step: (_label, body) => body(),\n handOver: (_label, body) => body(),\n emit: (output) => process.stdout.write(output),\n warn: (message) => console.warn(`create-eigen-game: ${message}`),\n interactive: true,\n};\n\n/**\n * The runner a scaffold uses when the caller has not supplied one: it asks the\n * reporter whether the terminal is spoken for.\n *\n * `interactive` inherits, which is the only way FlutterFire can put a question\n * on screen and read the answer. Otherwise both streams are captured and\n * handed to the reporter: on success so it can discard them, and on failure\n * so the reason survives.\n */\nexport function capturingRunner(reporter: Reporter): Runner {\n return (command, args, cwd) => {\n if (reporter.interactive) {\n execFileSync(command, args, { cwd, stdio: \"inherit\" });\n return;\n }\n try {\n reporter.emit(execFileSync(command, args, { cwd, encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"pipe\"] }));\n } catch (error: unknown) {\n // Both streams, because which one a tool failed on is its own business:\n // pub explains itself on stdout, Gradle on stderr.\n const { stdout, stderr } = error as { stdout?: string; stderr?: string };\n reporter.emit(`${stdout ?? \"\"}${stderr ?? \"\"}`);\n throw error;\n }\n };\n}\n\nexport interface ScaffoldOptions {\n directory: string;\n org?: string;\n packageManager?: PackageManager;\n /**\n * Run Flutter, package installation, and contract/payload generation.\n * Kept as a programmatic test seam; the public CLI always bootstraps both\n * halves of the combined project.\n */\n bootstrap?: boolean;\n /**\n * Emit the GitHub Actions workflows. Off by default; see the call site for\n * why, and `addContinuousIntegration` for adding them to an existing\n * project later.\n */\n ci?: boolean;\n /**\n * Initialise a repository and commit the scaffold. Defaults to `bootstrap`,\n * because the commit is only worth having once the generated files exist.\n */\n git?: boolean;\n /**\n * Configure Firebase before the first commit, by running the Flutter\n * client's `configure_firebase`. A string names the project to use; `true`\n * lets FlutterFire ask, which is also where a project can be created.\n *\n * Explicit here, though the CLI turns it on by default: this is the one step\n * that reaches outside the destination directory, and a library caller\n * should say so rather than discover it. {@link firebaseReadiness} is how\n * the CLI decides.\n */\n firebase?: boolean | string;\n /**\n * Runs the bootstrap subprocesses. A seam: the tests substitute a recorder,\n * and `scripts/scaffold-e2e.mjs` wraps it to point the generated server at\n * this workspace's engine rather than npm's copy.\n */\n run?: Runner;\n /**\n * Where the scaffold says what it is doing. See {@link Reporter}; the\n * default runs every step plainly.\n */\n reporter?: Reporter;\n}\n\n/**\n * What became of the repository, so the CLI's closing summary can say rather\n * than guess. `failed` has already warned by the time it is returned, and\n * carries no advice of its own.\n */\nexport type GitOutcome = \"committed\" | \"existing\" | \"skipped\" | \"failed\";\n\nexport interface ScaffoldResult {\n root: string;\n name: string;\n git: GitOutcome;\n /**\n * Whether Firebase was configured, so the summary can either stop naming the\n * step or spell it out. `failed` has already warned.\n */\n firebase: \"configured\" | \"failed\" | \"skipped\";\n /**\n * What the Firebase step made knowable and this scaffold therefore filled\n * in. Absent unless `firebase` is `configured`, since there is nothing to\n * read otherwise.\n */\n link?: FirebaseLink;\n}\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), \"..\");\nconst templatesRoot = resolve(packageRoot, \"templates\");\n\n/**\n * The engine range emitted into a scaffolded project's package.json.\n *\n * Read from this package's `@eigeninteractive/server` devDependency rather than\n * from its own version. See `engine-range.ts` for why that is the version the\n * templates are known to compile against, and what it replaced.\n */\nconst engineVersion = engineRange((JSON.parse(readFileSync(resolve(packageRoot, \"package.json\"), \"utf8\")) as { devDependencies?: Record<string, string> }).devDependencies?.[ENGINE_PACKAGE], () => {\n // Only reached in this workspace, where the manifest still says\n // `workspace:*`. A published tarball has no sibling here and never asks.\n const sibling = resolve(packageRoot, \"../server/package.json\");\n return existsSync(sibling) ? (JSON.parse(readFileSync(sibling, \"utf8\")) as { version: string }).version : undefined;\n});\n\n/**\n * The Flutter client range installed into the app half.\n *\n * A stated version, not a derived or resolved one. The Dart templates import\n * `package:eigen_flutter/eigen_flutter.dart` and\n * `package:eigen_flutter/testing/twin_fixtures.dart` and are written against a\n * specific Dart API. `eigen_flutter` is published and versioned separately from\n * this package even though both now live in the platform monorepo, so a source\n * location cannot compute which released version the template should request.\n * Only compiling a scaffolded app establishes it, which the platform gate does\n * on every change.\n *\n * This briefly resolved from pub.dev instead: \"the newest `eigen_flutter` whose\n * own `eigen_api` constraint targets the engine line being scaffolded\". That\n * predicate is wrong. The `eigen_api` constraint describes the WIRE the 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.4.0` already picks the newest\n * 0.4.x at scaffold time, which is the part the pub.dev lookup was duplicating.\n * What it deliberately cannot do is cross to 0.5.x, the one move that needs a\n * human to confirm the templates still compile.\n *\n * Staleness is therefore a failing check rather than a broken scaffold: this is\n * only ever a release behind, never wrong.\n *\n * Raised to 0.4.0 with the engine's session-snapshot wire. This is the one kind\n * of bump that is not merely an improvement: a scaffold writes both halves, and\n * the worker half is this repository's own line, so the shell it installs has to\n * speak that line's socket. `eigen_flutter` 0.4.0 is the first that does, and\n * every 0.3.x pins `eigen_api: ^0.2.0`, which cannot read a 0.3.x engine at all.\n * A scaffold pinning 0.3.x would therefore resolve, compile, and then fail to\n * render a game, which is the worst of the three.\n *\n * Raised to 0.4.1 for `EngineConfig.authDomain`, which the generated\n * `main.dart` passes. Additive, so pre-1.0 it is a patch and `^0.4.0` would\n * still resolve it, but `^0.4.0` also still resolves 0.4.0, where the parameter\n * does not exist and the scaffold would not compile. The floor is what makes\n * the generated code and the installed shell agree.\n *\n * Raised to 0.6.0 with the engine's opaque pagination cursors, and this is the\n * same *required* kind of bump the 0.4.0 note describes rather than an\n * improvement. The 0.4.x engine line takes `cursor` as an opaque string and\n * returns `nextCursor` on every paged response; `eigen_flutter` 0.6.0 is the\n * first shell that pins `eigen_api: ^0.4.0` and can read it. Everything below\n * that pins `eigen_api: ^0.3.0` or older, so a scaffold left on `^0.4.1` would\n * install the engine's current line beside a shell that cannot read a single\n * paged list from it: it resolves, it compiles, and then the lobby and history\n * are empty. 0.5.0 is skipped for the same reason, being a web-design release\n * that still speaks the 0.3.x wire.\n *\n * Raised to 0.7.0 for the 0.5.x engine line, and required in both of the senses\n * above at once. The wire changed -- `clientSchemaVersions` replaced\n * `clientSchemaVersion` and every mutation now carries `Idempotency-Key` -- and\n * `eigen_flutter` 0.7.0 is the first shell pinning `eigen_api: ^0.5.0` that can\n * speak it. The generated code changed too: the app overlay's `rules.dart`\n * implements `playerLimits` and returns a `PlayerLimits`, neither of which exists\n * before 0.7.0, so a scaffold left on `^0.6.0` does not even compile.\n *\n * Note that this floor and the engine range are raised in one commit on\n * purpose. The scaffolder writes both halves, and `updateInternalDependencies`\n * republishes this package whenever the engine version moves, so between an\n * engine line crossing and this line moving there is a published scaffolder\n * that pairs a new worker with an old shell. That window is real and this is\n * what closes it.\n *\n * The 0.7.0 raise is the exception that shows where that promise cannot hold. A\n * floor names a *published* `eigen_flutter`, and `eigen_flutter` publishes at the\n * end of the release chain, after the npm packages this scaffolder ships with --\n * so at the moment the engine crossed to 0.5.x there was no 0.7.0 to point at,\n * and `create-eigen-game@0.12.0` went out pairing a `^0.5.0` worker with a 0.6.0\n * shell. A Flutter line move therefore costs a follow-up scaffolder patch, and\n * `scripts/scaffold-e2e.mjs` is what refuses to let it be forgotten: it resolves\n * both halves for real and compares the wire lines they land on.\n */\nconst flutterClientVersion = \"^0.7.0\";\n\nconst gameSlug = (value: string): string => {\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value)) {\n throw new Error(\"destination directory name must be a lowercase kebab-case slug, for example my-game\");\n }\n return value;\n};\n\nconst dartName = (value: string): string => value.replaceAll(\"-\", \"_\");\n\n/**\n * The Android `applicationId`, and iOS bundle id, a scaffold at `directory`\n * will produce, so the CLI can show it rather than describe it.\n *\n * `flutter create --org X --project-name Y` derives `X.Y`. The organization is\n * the *prefix*, not the whole identifier, which is the part worth seeing\n * before answering: Google Play makes it permanent at first upload.\n */\nexport function applicationId(directory: string, org?: string): string {\n return `${org?.trim() || \"com.example\"}.${dartName(gameSlug(basename(resolve(directory))))}`;\n}\n\nconst title = (value: string): string =>\n value\n .split(\"-\")\n .map((part) => `${part[0]?.toUpperCase() ?? \"\"}${part.slice(1)}`)\n .join(\" \");\n\nconst identifier = (value: string): string => {\n const pascal = value\n .split(\"-\")\n .map((part) => `${part[0]?.toUpperCase() ?? \"\"}${part.slice(1)}`)\n .join(\"\");\n return /^[0-9]/.test(pascal) ? `Game${pascal}` : pascal;\n};\n\nexport function detectPackageManager(userAgent = process.env.npm_config_user_agent): PackageManager | undefined {\n if (userAgent?.startsWith(\"pnpm/\")) return \"pnpm\";\n if (userAgent?.startsWith(\"npm/\")) return \"npm\";\n return undefined;\n}\n\n/**\n * Substitutes the scaffold's tokens, of which there are two deliberate kinds.\n *\n * `{{BRACED}}` for values that have no valid example: a package manager,\n * an engine version, an Android package id. They appear only in manifests,\n * READMEs, workflows and the `Appfile`: files nothing compiles.\n *\n * Bare words (`ExampleGame`, `example-game`, …) for names a real example game\n * genuinely has. This is what keeps `templates/worker` and the Dart templates\n * VALID, COMPILING SOURCE rather than text with holes in it, which the rest of\n * this package leans on hard: `typecheck` runs `tsc` over `templates/worker`,\n * the tests `import` its game module directly and build a real contract from\n * it, and the `scaffold` job compiles the Dart templates. Bracing these would\n * trade all of that for a marker.\n *\n * The cost, and the one rule for template authors: a template file cannot\n * contain the literal string `example-game`, `Example Game`, `ExampleGame` or\n * `example_game` and keep it; every occurrence is rewritten, in prose and in\n * code alike. Write around it, or brace a new token instead.\n *\n * Note this means the set of files carrying a token changes whenever someone\n * writes one into an existing file. Nothing needs to track that: `renderTree`\n * decides what to rewrite from the bytes, not from a list of paths.\n */\nfunction render(contents: string, name: string, manager: PackageManager, packageId: string): string {\n const replacements: ReadonlyArray<readonly [string, string]> = [\n [\"@game/example-game-server\", `@game/${name}-server`],\n [\"{{PACKAGE_MANAGER}}\", manager],\n [\"{{PACKAGE_ID}}\", packageId],\n [\"{{ENGINE_VERSION}}\", engineVersion],\n [\"ExampleGame\", identifier(name)],\n [\"Example Game\", title(name)],\n [\"example_game\", dartName(name)],\n [\"example-game\", name],\n ];\n return replacements.reduce((result, [from, to]) => result.replaceAll(from, to), contents);\n}\n\n/**\n * True when the bytes are valid UTF-8.\n *\n * This is not a guess at whether a file is \"binary\"; it is the precondition\n * of the operation. Token substitution is `String.replaceAll`, so a file that\n * cannot be decoded cannot take part, and one that can is safe to rewrite.\n *\n * Deliberately not an extension list. A DENY list (`.png`, `.jar`, …) fails\n * silently in the dangerous direction: the day someone adds a `.webp`, it is\n * corrupted with no error. An ALLOW list fails the safe way but fits this tree\n * badly: `Gemfile`, `Fastfile`, `.nvmrc`, `.fvmrc` and `.ruby-version` all\n * need rendering and none carry a usable extension, so it would have to be a\n * list of extensions *and* a list of bare filenames, both drifting.\n *\n * `.template` is not the signal either, despite the name: it marks files a\n * language server must not claim before they have an enclosing package. Five\n * of them contain no token at all, and nine token-bearing files are not\n * marked, so the two concepts are orthogonal here.\n *\n * `renderTree`'s test pins the resulting classification for the whole tree, so\n * this stays a reviewed decision rather than an invisible one.\n */\nconst utf8 = new TextDecoder(\"utf-8\", { fatal: true });\n\nexport function decodeUtf8(bytes: Buffer): string | undefined {\n try {\n return utf8.decode(bytes);\n } catch {\n return undefined;\n }\n}\n\nfunction renderTree(source: string, destination: string, name: string, manager: PackageManager, packageId: string): void {\n cpSync(source, destination, { recursive: true });\n // Walks the TEMPLATE, not the destination. The app overlay renders on top of\n // a `flutter create` result, so walking the destination meant rewriting\n // every file Flutter had just generated, including its binaries, for files\n // this scaffolder does not own and has no business touching.\n const visit = (directory: string): void => {\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n const templatePath = resolve(directory, entry.name);\n if (entry.isDirectory()) {\n visit(templatePath);\n continue;\n }\n if (!entry.isFile()) continue;\n\n const rendered = resolve(destination, relative(source, templatePath));\n const text = decodeUtf8(readFileSync(templatePath));\n // Undecodable files are already in place from the copy above, byte for\n // byte. Only decodable ones are rewritten.\n if (text !== undefined) {\n writeFileSync(rendered, render(text, name, manager, packageId));\n }\n // Template-only source must not be claimed by language servers before\n // it has an enclosing generated package. Restore the real extension\n // only in the rendered project.\n if (entry.name.endsWith(\".template\")) {\n renameSync(rendered, rendered.slice(0, -\".template\".length));\n }\n }\n };\n visit(source);\n\n // npm deliberately excludes files named `.gitignore` from package\n // tarballs. Their packaged twins live outside the C3 template so a direct\n // Git-based C3 render does not inherit a scaffolder-only helper file.\n const packagedGitignore = resolve(templatesRoot, \"scaffold\", `${basename(source)}.gitignore`);\n if (existsSync(packagedGitignore)) {\n writeFileSync(resolve(destination, \".gitignore\"), render(readFileSync(packagedGitignore, \"utf8\"), name, manager, packageId));\n }\n}\n\nfunction packageCommand(manager: PackageManager, operation: \"install\" | \"contract\" | \"cf-typegen\"): [string, string[]] {\n if (operation === \"install\") return [manager, [\"install\"]];\n return [manager, [\"run\", operation]];\n}\n\n/**\n * Appends `block` to a file this scaffolder does not own, as its own paragraph.\n *\n * **Append, never insert.** That is the rule the three callers below follow, and\n * it is what keeps them from competing with `flutter create` and `flutterfire\n * configure` for position in the same files. A pure append cannot collide with\n * whatever those tools write above it; the one edit here that ever needed a\n * position, prepending a Kotlin `import`, was broken by an AGP upgrade and has\n * since been rewritten away. See MAINTAINERS.md for the whole doctrine, including\n * why FlutterFire's `// START:`/`// END:` marker comments are deliberately not\n * copied.\n *\n * `contents` is passed in rather than read here because every caller has already\n * read the file to decide whether its block is present, and two of them assert\n * on the shape of what they found. This owns the whitespace and nothing else.\n *\n * That is worth one function because it was previously written three times with\n * two different answers, so the desugaring block got a blank line before it and\n * the other two did not, and the two Gradle blocks ended up flush against each\n * other in every generated project. Separation belongs to the append, so the\n * block constants carry no leading or trailing newline of their own.\n */\nfunction appendBlock(path: string, contents: string, block: string): void {\n appendFileSync(path, `${contents.endsWith(\"\\n\") ? \"\" : \"\\n\"}\\n${block}\\n`);\n}\n\nconst androidDesugaring = `// flutter_local_notifications requires desugaring in the application module.\n// A library plugin cannot enable this compiler setting transitively.\nandroid {\n compileOptions {\n isCoreLibraryDesugaringEnabled = true\n }\n}\n\ndependencies {\n coreLibraryDesugaring(\"com.android.tools:desugar_jdk_libs:2.1.4\")\n}`;\n\nfunction enableAndroidCoreLibraryDesugaring(appRoot: string): void {\n const gradlePath = resolve(appRoot, \"android/app/build.gradle.kts\");\n const gradle = readFileSync(gradlePath, \"utf8\");\n if (!gradle.includes('id(\"com.android.application\")')) {\n throw new Error(`Flutter created an unexpected Android application build file: ${gradlePath}`);\n }\n const settingExists = gradle.includes(\"isCoreLibraryDesugaringEnabled\");\n const dependencyExists = gradle.includes(\"coreLibraryDesugaring(\");\n if (settingExists && dependencyExists) return;\n if (settingExists || dependencyExists) {\n throw new Error(`Flutter created an incomplete Android core library desugaring configuration: ${gradlePath}`);\n }\n appendBlock(gradlePath, gradle, androidDesugaring);\n}\n\n// A second top-level `android { }` block is valid Gradle Kotlin DSL, since Gradle\n// merges repeated extension-configuration blocks in one file, which is what\n// lets this stay a pure append, same as the desugaring block above. A second\n// top-level `plugins { }` block is NOT valid (Gradle allows exactly one per\n// script), which is why the Crashlytics Gradle plugin registration,\n// `flutterfire configure`'s own territory, is deliberately left alone here.\n//\n// Parsed with the Kotlin stdlib rather than `java.util.Properties`, which is\n// what keeps this appendable. `Properties` would need a real `import`, and\n// Kotlin requires imports before every other top-level declaration, so using it\n// meant also reaching into the very start of a file this scaffolder does not\n// own. A fully-qualified `java.util.Properties()` reference was tried to avoid\n// that, and does not resolve under AGP 9's Kotlin DSL script compilation\n// (`flutter create`'s current default): \"Unresolved reference 'util'\".\n// Confirmed by actually building a scaffolded project, not just reading it.\nconst androidReleaseSigning = `val releaseKeyProperties: Map<String, String> =\n rootProject.file(\"key.properties\")\n .takeIf { it.exists() }\n ?.readLines()\n ?.map { it.trim() }\n ?.filter { it.isNotEmpty() && !it.startsWith(\"#\") && it.contains(\"=\") }\n ?.associate { it.substringBefore(\"=\").trim() to it.substringAfter(\"=\").trim() }\n .orEmpty()\n\nandroid {\n signingConfigs {\n create(\"release\") {\n storeFile = releaseKeyProperties[\"storeFile\"]?.let { file(it) }\n storePassword = releaseKeyProperties[\"storePassword\"]\n keyAlias = releaseKeyProperties[\"keyAlias\"]\n keyPassword = releaseKeyProperties[\"keyPassword\"]\n }\n }\n buildTypes {\n release {\n signingConfig = if (releaseKeyProperties[\"storeFile\"] != null)\n signingConfigs.getByName(\"release\")\n else\n signingConfigs.getByName(\"debug\")\n isMinifyEnabled = true\n isShrinkResources = true\n proguardFiles(\n getDefaultProguardFile(\"proguard-android-optimize.txt\"),\n \"proguard-rules.pro\",\n )\n }\n }\n}`;\n\nfunction enableAndroidReleaseSigning(appRoot: string): void {\n const gradlePath = resolve(appRoot, \"android/app/build.gradle.kts\");\n const gradle = readFileSync(gradlePath, \"utf8\");\n // Not `gradle.includes(\"signingConfigs\")`, because Flutter's own template already\n // contains that substring (`signingConfig = signingConfigs.getByName(\"debug\")`),\n // so that check would always short-circuit and never append anything.\n if (gradle.includes(\"releaseKeyProperties\")) return;\n // A pure append. This previously also PREPENDED `import java.util.Properties`,\n // the most position-dependent edit here and the one already broken once by an\n // AGP upgrade; see the block above for what replaced it.\n appendBlock(gradlePath, gradle, androidReleaseSigning);\n}\n\n// `flutter_launcher_icons`/`flutter_native_splash` read these as plain\n// top-level pubspec keys, so appending is safe regardless of what\n// `flutter create` already wrote under `flutter:`. Deliberately omits\n// `ios`/`macos`, since `scaffoldGame` only creates `--platforms android,web`, and\n// `flutter_launcher_icons` errors if told to target a platform whose\n// directory doesn't exist.\n// The colours are the EigenInteractive palette (ink #1B1E24, paper #F4F1EA) because the\n// shipped placeholder art is the EigenInteractive mark: the adaptive foreground is the\n// reversed, light-on-dark variant, so an ink background is what makes it\n// legible. Rebranding a game means replacing the four PNGs *and* these\n// colours together. See https://eigeninteractive.com/docs/ship-it/branding.\nconst launcherIconsAndSplashConfig = `flutter_launcher_icons:\n android: true\n web:\n generate: true\n image_path: \"assets/icon/icon.png\"\n image_path: \"assets/icon/icon.png\"\n adaptive_icon_background: \"#1B1E24\"\n adaptive_icon_foreground: \"assets/icon/icon_foreground.png\"\n min_sdk_android: 21\n\nflutter_native_splash:\n color: \"#F4F1EA\"\n color_dark: \"#1B1E24\"\n image: assets/icon/splash.png\n image_dark: assets/icon/splash_dark.png\n fullscreen: true\n android_12:\n color: \"#F4F1EA\"\n color_dark: \"#1B1E24\"\n image: assets/icon/splash.png\n image_dark: assets/icon/splash_dark.png\n icon_background_color: \"#F4F1EA\"\n icon_background_color_dark: \"#1B1E24\"\n web: true`;\n\nfunction configureLauncherIconsAndSplash(appRoot: string): void {\n const pubspecPath = resolve(appRoot, \"pubspec.yaml\");\n const pubspec = readFileSync(pubspecPath, \"utf8\");\n if (pubspec.includes(\"flutter_launcher_icons:\")) return;\n appendBlock(pubspecPath, pubspec, launcherIconsAndSplashConfig);\n}\n\nexport interface AddContinuousIntegrationOptions {\n directory: string;\n /** Overrides the manager recorded in the project's own package.json. */\n packageManager?: PackageManager;\n}\n\n/**\n * Adds the GitHub Actions workflows to an existing generated project.\n *\n * The companion to `ci: false`: a game can be built and played locally for as\n * long as its author likes, then gain the same PR gate and signed release\n * pipeline a `--ci` scaffold would have produced.\n */\nexport function addContinuousIntegration(options: AddContinuousIntegrationOptions): { root: string; files: string[] } {\n const root = resolve(options.directory);\n const manifestPath = resolve(root, \"package.json\");\n if (!existsSync(manifestPath) || !existsSync(resolve(root, \"server\")) || !existsSync(resolve(root, \"app\"))) {\n throw new Error(`not an EigenInteractive game project (expected package.json, server/ and app/): ${root}`);\n }\n\n const manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as {\n name?: string;\n scripts?: Record<string, string>;\n };\n const name = gameSlug(manifest.name ?? basename(root));\n\n // The generated `contract` script embeds the manager the project was\n // scaffolded with (`cd server && pnpm run contract && …`), which is a more\n // reliable signal than a lockfile: it is present before anything is\n // installed, and it is what the project actually uses.\n const recorded = manifest.scripts?.contract?.includes(\"pnpm \") ? \"pnpm\" : manifest.scripts?.contract?.includes(\"npm \") ? \"npm\" : undefined;\n const manager = options.packageManager ?? recorded ?? detectPackageManager() ?? \"pnpm\";\n\n // Only `{{PACKAGE_MANAGER}}` appears in these templates, but the real\n // package id is read back rather than reconstructed, so a project scaffolded\n // under a different `--org` cannot be silently rewritten to `com.example`.\n const appfile = resolve(root, \"app/fastlane/Appfile\");\n const packageId = existsSync(appfile) ? (/package_name\\(\"([^\"]+)\"\\)/.exec(readFileSync(appfile, \"utf8\"))?.[1] ?? `com.example.${dartName(name)}`) : `com.example.${dartName(name)}`;\n\n const workflows = resolve(root, \".github/workflows\");\n const existing = existsSync(workflows) ? readdirSync(workflows).filter((f) => f === \"checks.yml\" || f === \"release.yml\") : [];\n if (existing.length > 0) {\n throw new Error(`refusing to overwrite existing workflows: ${existing.join(\", \")}`);\n }\n\n renderTree(resolve(templatesRoot, \"ci\"), root, name, manager, packageId);\n return { root, files: [\".github/workflows/checks.yml\", \".github/workflows/release.yml\"] };\n}\n\n/** Asks a command a question. `ok` is \"ran and succeeded\"; a tool that is not installed and one that fails are both `false`, because neither can be used. */\nexport type Probe = (command: string, args: string[]) => { ok: boolean; stdout: string };\n\nconst probeCommand: Probe = (command, args) => {\n try {\n return { ok: true, stdout: execFileSync(command, args, { encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"] }) };\n } catch {\n return { ok: false, stdout: \"\" };\n }\n};\n\n/** One thing standing between this machine and a configured Firebase project, and the single command that clears it. */\nexport interface FirebaseProblem {\n /** Said as a sentence fragment, so it reads after \"Firebase is not set up here:\". */\n reason: string;\n /** The one command that fixes this, and nothing else. */\n fix: string;\n}\n\nexport type FirebaseReadiness = { ready: true } | { ready: false; problems: FirebaseProblem[] };\n\n/**\n * Whether this machine can configure Firebase, asked *before* the scaffold\n * rather than after it.\n *\n * `configure_firebase` runs the same three checks and is the authority on\n * them; this one exists only to move the answer earlier. Learning that\n * `flutterfire` is missing costs nothing here and costs two minutes of Flutter\n * and pub at the far end, which is where the step actually runs.\n *\n * Every problem, not the first one. The checks are independent (two CLIs from\n * two ecosystems, plus a sign-in) so short-circuiting turns one setup into a\n * sequence of runs that each reveal the next missing piece. Reported in the\n * order they have to be fixed in: the CLI, then the sign-in it stores, then\n * the bridge that consumes both.\n *\n * The sign-in check fails open, for the same reason it does there: only an\n * answer that positively reports no accounts counts as \"no\", so a `firebase`\n * that errors or grows a different output shape is left to the command that\n * actually needs the credentials.\n */\nexport function firebaseReadiness(probe: Probe = probeCommand): FirebaseReadiness {\n const problems: FirebaseProblem[] = [];\n\n if (probe(\"firebase\", [\"--version\"]).ok) {\n if (signedOut(probe)) problems.push({ reason: \"no Google account is signed in to the Firebase CLI\", fix: \"firebase login\" });\n } else {\n // Nothing to say about the sign-in: the CLI that would answer is the one\n // that is missing, and `firebase login` is what installing leads to anyway.\n // Google's own installer, which picks a standalone binary or npm to suit\n // the machine. `npm install -g firebase-tools` also works and is what this\n // used to print, but it needs a global npm prefix the reader may not have\n // write access to, and it is not the install the Firebase docs lead with.\n problems.push({ reason: \"the `firebase` CLI is not installed\", fix: \"curl -sL https://firebase.tools | bash\" });\n }\n\n if (!probe(\"flutterfire\", [\"--version\"]).ok) {\n problems.push({ reason: \"the `flutterfire` CLI is not installed\", fix: \"dart pub global activate flutterfire_cli\" });\n }\n\n return problems.length === 0 ? { ready: true } : { ready: false, problems };\n}\n\n/**\n * Whether the Firebase CLI holds no credentials.\n *\n * `login:list --json` prints the stored refresh and access tokens along with\n * the account list. Read the shape, count the entries, and never surface the\n * output: not in a warning, not in a captured stream, not on the failure\n * path. That is why this returns a boolean rather than the response.\n */\nfunction signedOut(probe: Probe): boolean {\n const accounts = probe(\"firebase\", [\"login:list\", \"--json\"]);\n if (!accounts.ok) return false;\n try {\n const { result } = JSON.parse(accounts.stdout) as { result?: unknown };\n return Array.isArray(result) && result.length === 0;\n } catch {\n // Unparseable is not evidence of anything.\n return false;\n }\n}\n\n/**\n * Whether the scaffold would land inside a repository that already exists.\n *\n * Asked of the nearest ancestor that exists, because the destination does not\n * yet. The point is not to change what {@link scaffoldGame} does, which already\n * declines to nest a repository, but to stop the CLI asking a question whose\n * answer cannot matter.\n */\n/**\n * Why this destination cannot be scaffolded into, said as a whole message, or\n * `undefined` when there is nothing in the way.\n *\n * A directory that exists and is *empty* is not in the way, since people make\n * one out of habit, so it is removed and rewritten rather than refused over\n * nothing. Anything with contents in it is refused, and a cloned repository is\n * not an exception: `.git` is in the way like any other entry, and the message\n * names it. Publishing into one would mean parking `.git`, renaming staging\n * over the top and putting it back, with a failure in the middle able to\n * orphan a remote, which is a lot of care to spend on a flow that has a\n * one-line alternative.\n *\n * Refused, and deliberately not offered as a \"remove it and continue?\"\n * question, which is where several scaffolders in this family go. This one\n * writes ninety-odd files and runs `flutter create`; the cost of getting that\n * answer wrong against a mistyped path has no upper bound, and `rm -rf` is one\n * command that belongs to the person who can see what is in there. Every other\n * question this CLI asks is reversible. This one would not be.\n *\n * Exported so the CLI can ask it before the first question rather than after\n * the last one. {@link scaffoldGame} asks it again, for callers that are not\n * the CLI.\n */\nexport function destinationProblem(directory: string): string | undefined {\n const root = resolve(directory);\n if (!existsSync(root)) return undefined;\n\n if (!statSync(root).isDirectory()) return `${root} already exists, and is a file.`;\n\n const entries = readdirSync(root);\n if (entries.length === 0) return undefined;\n\n // Named, not counted. \"not empty\" invites an `ls`; the three that are\n // actually there usually settle whether this was the wrong path or a\n // directory that has already been scaffolded once.\n const shown = entries.slice(0, 3).sort().join(\", \");\n const rest = entries.length > 3 ? `, and ${entries.length - 3} more` : \"\";\n return `${root} already exists, and is not empty: it holds ${shown}${rest}.\\n\\nScaffold somewhere else, or clear it out yourself. This will not delete a directory you already had.`;\n}\n\nexport function insideWorkTree(directory: string, probe: Probe = probeCommand): boolean {\n let candidate = resolve(directory);\n while (!existsSync(candidate)) {\n const parent = dirname(candidate);\n if (parent === candidate) return false;\n candidate = parent;\n }\n return probe(\"git\", [\"-C\", candidate, \"rev-parse\", \"--is-inside-work-tree\"]).ok;\n}\n\n/**\n * Runs the Flutter client's `configure_firebase` against the generated app.\n *\n * The command owns everything about how Firebase is configured: which\n * platforms, which CLIs must exist, whether anyone is signed in, and what to\n * do when no project has been chosen yet. This only decides *when*: before the\n * scaffold commit, so a configured project is committed configured.\n *\n * Not fatal. Every failure here (a missing `flutterfire`, no Google login, a\n * cancelled picker) leaves a complete and usable project that is exactly what\n * a scaffold without `--firebase` produces, so it warns with the command to\n * re-run and lets the commit happen.\n */\nfunction configureFirebase(appRoot: string, project: boolean | string, run: Runner, reporter: Reporter): \"configured\" | \"failed\" {\n // FlutterFire asks before overwriting `firebase_options.dart`, and the\n // scaffold has just written one, a throwing placeholder whose entire\n // purpose is to be replaced by this step. Answering that is a question with\n // one right answer, so the placeholder is moved out of the way and the\n // question never gets asked.\n const placeholder = resolve(appRoot, \"lib/firebase_options.dart\");\n const parked = `${placeholder}.placeholder`;\n const parking = existsSync(placeholder);\n if (parking) renameSync(placeholder, parked);\n\n try {\n // `dart run` compiles the package executable on first use and says so.\n // Doing it against `--help`, which returns immediately, moves that noise\n // into a step whose output can be captured; the real run cannot be, since\n // FlutterFire prompts through it.\n reporter.step(\"Preparing the Firebase configurator\", () => run(\"dart\", [\"run\", \"eigen_flutter:configure_firebase\", \"--help\"], appRoot));\n // `--worker` is what makes this fill in `FIREBASE_PROJECT_ID` as well as\n // the app's own values. An app-only repository omits it and gets the app\n // half; a combined scaffold has the Worker one directory over.\n reporter.handOver(\"Configuring Firebase\", () => run(\"dart\", [\"run\", \"eigen_flutter:configure_firebase\", \"--worker\", \"../server\", ...(typeof project === \"string\" ? [\"--project\", project] : [])], appRoot));\n if (parking) rmSync(parked, { force: true });\n return \"configured\";\n } catch {\n // Back only if nothing took its place. FlutterFire writes\n // `firebase_options.dart` before the service worker configuration is\n // derived from it, so a late failure leaves a real one that is worth more\n // than the placeholder.\n if (parking) {\n if (existsSync(placeholder)) rmSync(parked, { force: true });\n else renameSync(parked, placeholder);\n }\n reporter.warn(\"Could not configure Firebase. The project is complete. Run `firebase:configure` yourself, then commit what it writes.\");\n return \"failed\";\n }\n}\n\n/**\n * Commits the scaffold, so the first `git diff` is the first game change.\n *\n * This matters more here than in a scaffolder that only writes source. The\n * bootstrap runs `flutter_launcher_icons` and `flutter_native_splash`, which\n * write generated-but-committed files across `android/`, `web/` and\n * `assets/`; without a baseline the first branding change is indistinguishable\n * from the ninety files the scaffolder happened to produce.\n *\n * Nothing here is fatal. The project is complete and valid before this runs,\n * so a missing `git`, or the unconfigured `user.email` that a fresh CI image\n * has, warns and leaves the tree alone rather than discarding a scaffold that\n * took two minutes of Flutter and pub to produce.\n */\nfunction initialiseRepository(root: string, name: string, run: Runner, reporter: Reporter): GitOutcome {\n // Scaffolding inside an existing checkout (a monorepo, or a repository\n // created ahead of time) is a legitimate thing to do, and a nested\n // repository there is silent breakage: the outer `git add` records a gitlink\n // and the app's files never leave the machine. Asked directly rather than\n // through `run`, because it is a question, not a step.\n try {\n execFileSync(\"git\", [\"rev-parse\", \"--is-inside-work-tree\"], { cwd: root, stdio: \"ignore\" });\n return \"existing\";\n } catch {\n // Not inside a work tree, which is the case this function is for.\n }\n\n try {\n run(\"git\", [\"init\", \"--quiet\"], root);\n run(\"git\", [\"add\", \"--all\"], root);\n } catch {\n reporter.warn(\"Could not initialise a git repository. The project is complete. Run `git init` yourself when ready.\");\n return \"failed\";\n }\n\n try {\n run(\"git\", [\"commit\", \"--quiet\", \"--message\", `Scaffold ${name}`], root);\n } catch {\n reporter.warn(`Initialised a repository and staged the scaffold, but could not commit it. Set \\`user.name\\` and \\`user.email\\`, then \\`git commit -m \"Scaffold ${name}\"\\`.`);\n return \"failed\";\n }\n\n return \"committed\";\n}\n\nexport function scaffoldGame(options: ScaffoldOptions): ScaffoldResult {\n const root = resolve(options.directory);\n const name = gameSlug(basename(root));\n const manager = options.packageManager ?? detectPackageManager() ?? \"pnpm\";\n const org = options.org?.trim() || \"com.example\";\n // Fastlane's `Appfile` names the same package the build actually produces,\n // and the CLI shows the same one before asking.\n const packageId = applicationId(root, org);\n const bootstrap = options.bootstrap ?? true;\n const reporter = options.reporter ?? plainReporter;\n const run = options.run ?? capturingRunner(reporter);\n\n const occupied = destinationProblem(root);\n if (occupied !== undefined) throw new Error(occupied);\n // Empty, or `destinationProblem` would have said so. Removed rather than\n // scaffolded into, because the rename below publishes the staging directory\n // *as* this path and cannot do that while something is standing there.\n if (existsSync(root)) rmdirSync(root);\n\n mkdirSync(dirname(root), { recursive: true });\n\n // Build beside the destination and publish it with one rename. Failed\n // subprocesses never leave a half-scaffolded project at the requested path.\n const stagingRoot = mkdtempSync(resolve(dirname(root), `.${basename(root)}-`));\n try {\n const serverRoot = resolve(stagingRoot, \"server\");\n const appRoot = resolve(stagingRoot, \"app\");\n\n renderTree(resolve(templatesRoot, \"worker\"), serverRoot, name, manager, packageId);\n renderTree(resolve(templatesRoot, \"project\"), stagingRoot, name, manager, packageId);\n // Opt-in. release.yml wants an upload keystore and a Play service account\n // that a brand-new project does not have, so generating it by default\n // means a red X on main from the first push until someone sets both up.\n // `create-eigen-game add ci` writes the same files whenever it is wanted.\n if (options.ci) renderTree(resolve(templatesRoot, \"ci\"), stagingRoot, name, manager, packageId);\n\n if (bootstrap) {\n reporter.step(\"Creating the Flutter app\", () => {\n run(\"flutter\", [\"create\", \"--empty\", \"--platforms\", \"android,web\", \"--project-name\", dartName(name), \"--org\", org, appRoot], stagingRoot);\n enableAndroidCoreLibraryDesugaring(appRoot);\n enableAndroidReleaseSigning(appRoot);\n });\n } else {\n mkdirSync(appRoot, { recursive: true });\n }\n renderTree(resolve(templatesRoot, \"app-overlay\"), appRoot, name, manager, packageId);\n\n if (bootstrap) {\n reporter.step(\"Adding the Flutter packages\", () => {\n configureLauncherIconsAndSplash(appRoot);\n run(\"flutter\", [\"pub\", \"add\", `eigen_flutter@${flutterClientVersion}`, \"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 // What that step settled, so the summary can name what it did not.\n // `configure_firebase` does the writing, including into the Worker's\n // wrangler.jsonc, which is what `--worker` above is for.\n const link = firebase === \"configured\" ? readFirebaseLink(root) : undefined;\n const git = (options.git ?? bootstrap) ? initialiseRepository(root, name, run, reporter) : \"skipped\";\n\n return { root, name, git, firebase, link };\n}\n","/**\n * Where the engine range emitted into a scaffolded project comes from.\n *\n * Its own module because the two branches below execute in different worlds,\n * one only inside this repository and the other only inside a published tarball,\n * and a function whose published-only path never runs in CI is a function that\n * is not tested. `src/index.ts` uses it; the package `exports` map does not\n * expose it, so it is internal despite being importable by the tests.\n */\n\n/** The dependency whose version the scaffolder emits into the generated server. */\nexport const ENGINE_PACKAGE = \"@eigeninteractive/server\";\n\n/**\n * The engine range for a scaffolded project, from this package's own\n * `@eigeninteractive/server` devDependency.\n *\n * That number is not maintained by anyone: it is the version CI compiled the\n * templates against, because `pnpm -r typecheck` runs\n * `tsc -p templates/worker/tsconfig.json` inside this workspace. Emitting\n * anything else would mean shipping templates paired with an engine no build\n * ever saw.\n *\n * It replaced a derivation from this package's OWN version, which was correct\n * only while `create-eigen-game` sat in the `fixed` changesets group, and that\n * membership is what forced an engine-wide release for every scaffolder-only\n * change. Reading the dependency keeps the guarantee and drops the coupling.\n *\n * Two branches, because the same manifest reads differently in the two places\n * this runs:\n *\n * - **Published tarball**: pnpm rewrites `workspace:*` to the exact version\n * while packing, so the manifest already states it (`\"0.2.0\"`), and no\n * sibling package exists on disk to consult.\n * - **This workspace**: the manifest still says `workspace:*`, which names no\n * version, so the sibling package is read directly.\n *\n * @param declared the raw `@eigeninteractive/server` devDependency value\n * @param readSiblingVersion consulted only for the `workspace:` protocol\n */\nexport function engineRange(declared: string | undefined, readSiblingVersion: () => string | undefined): string {\n if (!declared) {\n throw new Error(`create-eigen-game has no ${ENGINE_PACKAGE} devDependency, which is where the engine range it emits comes from`);\n }\n\n const version = declared.startsWith(\"workspace:\") ? readSiblingVersion() : declared;\n\n if (!version) {\n throw new Error(`create-eigen-game declares ${ENGINE_PACKAGE} as \"${declared}\" but the workspace package could not be read, so there is no engine version to emit`);\n }\n\n // pnpm packs `workspace:*` as a bare version, which is what makes the caret\n // below correct. Asserting it means a change in that behaviour fails here\n // rather than emitting something like `^^0.3.0` into a real project.\n if (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {\n throw new Error(`expected an exact ${ENGINE_PACKAGE} version to build a range from, got \"${version}\"`);\n }\n\n return `^${version}`;\n}\n","/**\n * Reads the two deployment values that exist only once a Firebase project\n * does, so the closing summary can name what is still missing.\n *\n * Reading only. `configure_firebase` writes them, into `wrangler.jsonc` and\n * `app-config.json`, because it is also what a project runs later when\n * reconfiguring, and one implementation is what keeps the scaffold-time path\n * and the re-run path identical. This module exists so the summary can tell\n * the difference between \"filled in\" and \"still owed\", not to do it again.\n *\n * Its own module for the same reason `summary.ts` is: `index.ts` runs a\n * scaffold, and this is worth asserting without one. The package `exports` map\n * does not expose it.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\n/** What the Firebase step managed to settle, and what it left for the console. */\nexport interface FirebaseLink {\n /** The project now in `wrangler.jsonc`, or null when FlutterFire recorded none. */\n projectId: string | null;\n /** The OAuth web client now in `app-config.json`, or null when Google sign-in is not enabled yet. */\n googleWebClientId: string | null;\n}\n\nfunction readJson(path: string): unknown {\n if (!existsSync(path)) return undefined;\n try {\n return JSON.parse(readFileSync(path, \"utf8\"));\n } catch {\n // A file this step only reads is never worth failing a finished scaffold\n // for. The value counts as unset, and the summary says so.\n return undefined;\n }\n}\n\n/**\n * The project FlutterFire recorded for the Dart output this app uses.\n *\n * `firebase.json` is FlutterFire's own record rather than something this\n * scaffold writes, so it is read defensively: a shape that does not match is\n * treated as \"not configured\", which is the same answer as a run that never\n * happened.\n */\nexport function configuredProject(appRoot: string): string | null {\n const record = readJson(resolve(appRoot, \"firebase.json\")) as { flutter?: { platforms?: { dart?: Record<string, { projectId?: unknown }> } } } | undefined;\n const projectId = record?.flutter?.platforms?.dart?.[\"lib/firebase_options.dart\"]?.projectId;\n return typeof projectId === \"string\" && projectId !== \"\" ? projectId : null;\n}\n\n/**\n * The OAuth web client id that `configure_firebase` copied into\n * `app-config.json`, when there was one to copy.\n *\n * Empty is an ordinary outcome rather than a failure. Firebase creates that\n * client when the Google sign-in provider is enabled, which is a console\n * action no CLI can perform, so a project that has never had it enabled has\n * nothing to offer here.\n */\nexport function configuredWebClientId(appRoot: string): string | null {\n const config = readJson(resolve(appRoot, \"app-config.json\")) as Record<string, unknown> | undefined;\n const value = config?.GOOGLE_WEB_CLIENT_ID;\n return typeof value === \"string\" && value !== \"\" ? value : null;\n}\n\n/** What the Firebase step settled, for the summary to report. */\nexport function readFirebaseLink(root: string): FirebaseLink {\n const appRoot = resolve(root, \"app\");\n return { projectId: configuredProject(appRoot), googleWebClientId: configuredWebClientId(appRoot) };\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB,QAAQ,cAAAA,aAAY,WAAW,aAAa,aAAa,gBAAAC,eAAc,YAAY,WAAW,QAAQ,UAAU,qBAAqB;AAC9J,SAAS,UAAU,SAAS,UAAU,WAAAC,gBAAe;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;;;AC7CA,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe;AAUxB,SAAS,SAAS,MAAuB;AACvC,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO;AAC9B,MAAI;AACF,WAAO,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;AAAA,EAC9C,QAAQ;AAGN,WAAO;AAAA,EACT;AACF;AAUO,SAAS,kBAAkB,SAAgC;AAChE,QAAM,SAAS,SAAS,QAAQ,SAAS,eAAe,CAAC;AACzD,QAAM,YAAY,QAAQ,SAAS,WAAW,OAAO,2BAA2B,GAAG;AACnF,SAAO,OAAO,cAAc,YAAY,cAAc,KAAK,YAAY;AACzE;AA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Sync"]}
package/dist/cli.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  #!/usr/bin/env node
2
+ export {};
package/dist/cli.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  normaliseTerminalWidth,
10
10
  plainReporter,
11
11
  scaffoldGame
12
- } from "./chunk-6BBSWZN4.js";
12
+ } from "./chunk-L7EVXO3Y.js";
13
13
 
14
14
  // src/cli.ts
15
15
  import { readFileSync } from "fs";
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Where the engine range emitted into a scaffolded project comes from.
3
+ *
4
+ * Its own module because the two branches below execute in different worlds,
5
+ * one only inside this repository and the other only inside a published tarball,
6
+ * and a function whose published-only path never runs in CI is a function that
7
+ * is not tested. `src/index.ts` uses it; the package `exports` map does not
8
+ * expose it, so it is internal despite being importable by the tests.
9
+ */
10
+ /** The dependency whose version the scaffolder emits into the generated server. */
11
+ export declare const ENGINE_PACKAGE = "@eigeninteractive/server";
12
+ /**
13
+ * The engine range for a scaffolded project, from this package's own
14
+ * `@eigeninteractive/server` devDependency.
15
+ *
16
+ * That number is not maintained by anyone: it is the version CI compiled the
17
+ * templates against, because `pnpm -r typecheck` runs
18
+ * `tsc -p templates/worker/tsconfig.json` inside this workspace. Emitting
19
+ * anything else would mean shipping templates paired with an engine no build
20
+ * ever saw.
21
+ *
22
+ * It replaced a derivation from this package's OWN version, which was correct
23
+ * only while `create-eigen-game` sat in the `fixed` changesets group, and that
24
+ * membership is what forced an engine-wide release for every scaffolder-only
25
+ * change. Reading the dependency keeps the guarantee and drops the coupling.
26
+ *
27
+ * Two branches, because the same manifest reads differently in the two places
28
+ * this runs:
29
+ *
30
+ * - **Published tarball**: pnpm rewrites `workspace:*` to the exact version
31
+ * while packing, so the manifest already states it (`"0.2.0"`), and no
32
+ * sibling package exists on disk to consult.
33
+ * - **This workspace**: the manifest still says `workspace:*`, which names no
34
+ * version, so the sibling package is read directly.
35
+ *
36
+ * @param declared the raw `@eigeninteractive/server` devDependency value
37
+ * @param readSiblingVersion consulted only for the `workspace:` protocol
38
+ */
39
+ export declare function engineRange(declared: string | undefined, readSiblingVersion: () => string | undefined): string;
package/dist/index.d.ts CHANGED
@@ -1,13 +1,7 @@
1
- /** What the Firebase step managed to settle, and what it left for the console. */
2
- interface FirebaseLink {
3
- /** The project now in `wrangler.jsonc`, or null when FlutterFire recorded none. */
4
- projectId: string | null;
5
- /** The OAuth web client now in `app-config.json`, or null when Google sign-in is not enabled yet. */
6
- googleWebClientId: string | null;
7
- }
8
-
9
- type PackageManager = "npm" | "pnpm";
10
- type Runner = (command: string, args: string[], cwd: string) => void;
1
+ import { type FirebaseLink } from "./link-firebase.js";
2
+ export type { FirebaseLink } from "./link-firebase.js";
3
+ export type PackageManager = "npm" | "pnpm";
4
+ export type Runner = (command: string, args: string[], cwd: string) => void;
11
5
  /**
12
6
  * Where a scaffold says what it is doing, so that presentation belongs to the
13
7
  * caller and this module only has to name things.
@@ -17,7 +11,7 @@ type Runner = (command: string, args: string[], cwd: string) => void;
17
11
  * substitutes one that captures each step's output and shows it only if the
18
12
  * step fails.
19
13
  */
20
- interface Reporter {
14
+ export interface Reporter {
21
15
  /** Runs `body` as one named step. Its subprocesses can be captured. */
22
16
  step<T>(label: string, body: () => T): T;
23
17
  /**
@@ -42,12 +36,12 @@ interface Reporter {
42
36
  * with `RangeError: Invalid string length`. Supplying the default its check
43
37
  * misses is better than giving up the drawing.
44
38
  */
45
- declare function normaliseTerminalWidth(stream: {
39
+ export declare function normaliseTerminalWidth(stream: {
46
40
  isTTY?: boolean;
47
41
  columns?: number;
48
42
  }): void;
49
43
  /** Runs every step plainly, which is what a library caller gets by default. */
50
- declare const plainReporter: Reporter;
44
+ export declare const plainReporter: Reporter;
51
45
  /**
52
46
  * The runner a scaffold uses when the caller has not supplied one: it asks the
53
47
  * reporter whether the terminal is spoken for.
@@ -57,8 +51,8 @@ declare const plainReporter: Reporter;
57
51
  * handed to the reporter: on success so it can discard them, and on failure
58
52
  * so the reason survives.
59
53
  */
60
- declare function capturingRunner(reporter: Reporter): Runner;
61
- interface ScaffoldOptions {
54
+ export declare function capturingRunner(reporter: Reporter): Runner;
55
+ export interface ScaffoldOptions {
62
56
  directory: string;
63
57
  org?: string;
64
58
  packageManager?: PackageManager;
@@ -107,8 +101,8 @@ interface ScaffoldOptions {
107
101
  * than guess. `failed` has already warned by the time it is returned, and
108
102
  * carries no advice of its own.
109
103
  */
110
- type GitOutcome = "committed" | "existing" | "skipped" | "failed";
111
- interface ScaffoldResult {
104
+ export type GitOutcome = "committed" | "existing" | "skipped" | "failed";
105
+ export interface ScaffoldResult {
112
106
  root: string;
113
107
  name: string;
114
108
  git: GitOutcome;
@@ -132,10 +126,10 @@ interface ScaffoldResult {
132
126
  * the *prefix*, not the whole identifier, which is the part worth seeing
133
127
  * before answering: Google Play makes it permanent at first upload.
134
128
  */
135
- declare function applicationId(directory: string, org?: string): string;
136
- declare function detectPackageManager(userAgent?: string | undefined): PackageManager | undefined;
137
- declare function decodeUtf8(bytes: Buffer): string | undefined;
138
- interface AddContinuousIntegrationOptions {
129
+ export declare function applicationId(directory: string, org?: string): string;
130
+ export declare function detectPackageManager(userAgent?: string | undefined): PackageManager | undefined;
131
+ export declare function decodeUtf8(bytes: Buffer): string | undefined;
132
+ export interface AddContinuousIntegrationOptions {
139
133
  directory: string;
140
134
  /** Overrides the manager recorded in the project's own package.json. */
141
135
  packageManager?: PackageManager;
@@ -147,23 +141,23 @@ interface AddContinuousIntegrationOptions {
147
141
  * long as its author likes, then gain the same PR gate and signed release
148
142
  * pipeline a `--ci` scaffold would have produced.
149
143
  */
150
- declare function addContinuousIntegration(options: AddContinuousIntegrationOptions): {
144
+ export declare function addContinuousIntegration(options: AddContinuousIntegrationOptions): {
151
145
  root: string;
152
146
  files: string[];
153
147
  };
154
148
  /** 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. */
155
- type Probe = (command: string, args: string[]) => {
149
+ export type Probe = (command: string, args: string[]) => {
156
150
  ok: boolean;
157
151
  stdout: string;
158
152
  };
159
153
  /** One thing standing between this machine and a configured Firebase project, and the single command that clears it. */
160
- interface FirebaseProblem {
154
+ export interface FirebaseProblem {
161
155
  /** Said as a sentence fragment, so it reads after "Firebase is not set up here:". */
162
156
  reason: string;
163
157
  /** The one command that fixes this, and nothing else. */
164
158
  fix: string;
165
159
  }
166
- type FirebaseReadiness = {
160
+ export type FirebaseReadiness = {
167
161
  ready: true;
168
162
  } | {
169
163
  ready: false;
@@ -189,7 +183,7 @@ type FirebaseReadiness = {
189
183
  * that errors or grows a different output shape is left to the command that
190
184
  * actually needs the credentials.
191
185
  */
192
- declare function firebaseReadiness(probe?: Probe): FirebaseReadiness;
186
+ export declare function firebaseReadiness(probe?: Probe): FirebaseReadiness;
193
187
  /**
194
188
  * Whether the scaffold would land inside a repository that already exists.
195
189
  *
@@ -222,8 +216,6 @@ declare function firebaseReadiness(probe?: Probe): FirebaseReadiness;
222
216
  * the last one. {@link scaffoldGame} asks it again, for callers that are not
223
217
  * the CLI.
224
218
  */
225
- declare function destinationProblem(directory: string): string | undefined;
226
- declare function insideWorkTree(directory: string, probe?: Probe): boolean;
227
- declare function scaffoldGame(options: ScaffoldOptions): ScaffoldResult;
228
-
229
- export { type AddContinuousIntegrationOptions, type FirebaseLink, 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 };
219
+ export declare function destinationProblem(directory: string): string | undefined;
220
+ export declare function insideWorkTree(directory: string, probe?: Probe): boolean;
221
+ export declare function scaffoldGame(options: ScaffoldOptions): ScaffoldResult;
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  normaliseTerminalWidth,
11
11
  plainReporter,
12
12
  scaffoldGame
13
- } from "./chunk-6BBSWZN4.js";
13
+ } from "./chunk-L7EVXO3Y.js";
14
14
  export {
15
15
  addContinuousIntegration,
16
16
  applicationId,
@@ -0,0 +1,28 @@
1
+ /** What the Firebase step managed to settle, and what it left for the console. */
2
+ export interface FirebaseLink {
3
+ /** The project now in `wrangler.jsonc`, or null when FlutterFire recorded none. */
4
+ projectId: string | null;
5
+ /** The OAuth web client now in `app-config.json`, or null when Google sign-in is not enabled yet. */
6
+ googleWebClientId: string | null;
7
+ }
8
+ /**
9
+ * The project FlutterFire recorded for the Dart output this app uses.
10
+ *
11
+ * `firebase.json` is FlutterFire's own record rather than something this
12
+ * scaffold writes, so it is read defensively: a shape that does not match is
13
+ * treated as "not configured", which is the same answer as a run that never
14
+ * happened.
15
+ */
16
+ export declare function configuredProject(appRoot: string): string | null;
17
+ /**
18
+ * The OAuth web client id that `configure_firebase` copied into
19
+ * `app-config.json`, when there was one to copy.
20
+ *
21
+ * Empty is an ordinary outcome rather than a failure. Firebase creates that
22
+ * client when the Google sign-in provider is enabled, which is a console
23
+ * action no CLI can perform, so a project that has never had it enabled has
24
+ * nothing to offer here.
25
+ */
26
+ export declare function configuredWebClientId(appRoot: string): string | null;
27
+ /** What the Firebase step settled, for the summary to report. */
28
+ export declare function readFirebaseLink(root: string): FirebaseLink;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Every question this CLI asks, in one module so the wording lives together
3
+ * and can be asserted. `cli.ts` is the bin entry and runs `main` on import,
4
+ * which makes anything defined there untestable.
5
+ *
6
+ * The organization prompt is the reason this drops to `@clack/core` rather
7
+ * than using `@clack/prompts`' `text`. The suffix: `flutter create --org X
8
+ * --project-name Y` derives `X.Y`, so the organization is a *prefix*, and the
9
+ * reliable way to say so is to render the rest of the identifier, dimmed,
10
+ * while it is being typed. `text` has no hook for that; a custom `TextPrompt`
11
+ * render returns a string, so it does.
12
+ *
13
+ * Everything else comes from `@clack/prompts` rather than being drawn here.
14
+ * Its symbols are exported for exactly this, and they are not constants: each
15
+ * falls back to ASCII on a terminal that cannot show the box-drawing
16
+ * characters, which a hand-typed `│` cannot do.
17
+ */
18
+ import type { Readable, Writable } from "node:stream";
19
+ import type { PackageManager } from "./index.js";
20
+ /**
21
+ * Where a question reads its answer from. Parameters for the same reason every
22
+ * clack prompt takes them: a prompt is otherwise the one part of a CLI that
23
+ * cannot be driven by a test.
24
+ */
25
+ export interface Io {
26
+ input?: Readable;
27
+ output?: Writable;
28
+ }
29
+ /**
30
+ * Two or more dot-separated Java identifiers. `flutter create --org` accepts
31
+ * anything and defers the complaint to Gradle, which reports it as a manifest
32
+ * error in a generated file, so `com.example-games` costs a full scaffold and
33
+ * a first build before anyone learns that a hyphen is not legal in a package
34
+ * segment.
35
+ */
36
+ export declare const ORG: RegExp;
37
+ /** The default, which an empty answer accepts. */
38
+ export declare const DEFAULT_ORG = "com.example";
39
+ /** A `com.acme.chess` answer to a game called `chess`, which yields `com.acme.chess.chess`. */
40
+ export declare function repeatsGameName(org: string, game: string): boolean;
41
+ /** The organization implied by an answer that already ends in the game name. */
42
+ export declare function withoutGameName(org: string): string | undefined;
43
+ /**
44
+ * Asks, with the game name rendered dimmed after the cursor so the shape of
45
+ * the answer is visible while it is being given.
46
+ *
47
+ * Returns the organization, `undefined` for the default, or `null` when
48
+ * cancelled.
49
+ *
50
+ * `input` and `output` default to this process's, and are parameters for the
51
+ * same reason every clack prompt takes them: a prompt is otherwise the one
52
+ * part of a CLI that cannot be driven by a test.
53
+ */
54
+ export declare function askForOrg(game: string, registering: boolean, io?: Io): Promise<string | undefined | null>;
55
+ /**
56
+ * Asked only when {@link firebaseReadiness} found something missing, and
57
+ * defaulted to "no" because the honest answer usually is: the tools are two
58
+ * commands away, and the alternative is an app that throws at launch until
59
+ * they are installed anyway.
60
+ */
61
+ export declare function askToScaffoldWithoutFirebase(io?: Io): Promise<boolean | null>;
62
+ /** 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. */
63
+ export declare function askForGit(io?: Io): Promise<boolean | null>;
64
+ /**
65
+ * Defaulted to no, and the hint says why rather than leaving it as an
66
+ * arbitrary-looking choice: `release.yml` needs an upload keystore and a Play
67
+ * service account, so a project that takes the workflows before it has either
68
+ * gets a red `main` from its first push.
69
+ */
70
+ export declare function askForWorkflows(io?: Io): Promise<boolean | null>;
71
+ /**
72
+ * The package manager, asked only when nothing else could say.
73
+ *
74
+ * `npm create` and `pnpm create` both set `npm_config_user_agent`, so this is
75
+ * reached by the paths that do not: a global install, or running the binary
76
+ * directly. Rare, but it decides what every generated script says, and the old
77
+ * silent fallback to pnpm was a guess printed into a project's package.json.
78
+ */
79
+ export declare function askForPackageManager(io?: Io): Promise<PackageManager | null>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The closing summary, and the only output of a scaffold anyone reads.
3
+ *
4
+ * A run drives several tools with plenty to say, so where the project went,
5
+ * what to edit, and what to run are worth restating at the bottom. Returned in
6
+ * pieces rather than as one block, because the CLI renders each in a different
7
+ * shape: the outcomes as status lines, the commands as a boxed note, the
8
+ * destination as the closing line.
9
+ *
10
+ * Its own module so it can be asserted: `cli.ts` is the bin entry and runs
11
+ * `main` on import, which makes anything defined there untestable. The package
12
+ * `exports` map does not expose this, so it is internal despite being
13
+ * importable by the tests.
14
+ */
15
+ import type { PackageManager, ScaffoldResult } from "./index.js";
16
+ export interface Summary {
17
+ /** What became of the repository and of Firebase, when there is something to say. */
18
+ status: string[];
19
+ /** The commands worth having, as one block. */
20
+ next: string;
21
+ /** One-line asides, after the block. */
22
+ footnotes: string[];
23
+ /** The closing line. */
24
+ headline: string;
25
+ }
26
+ export declare function summarise(result: ScaffoldResult, manager: PackageManager, workflows: boolean): Summary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-eigen-game",
3
- "version": "0.12.0",
3
+ "version": "0.13.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",
@@ -25,13 +25,13 @@
25
25
  "devDependencies": {
26
26
  "@types/node": "^26.1.1",
27
27
  "tsup": "^8.5.1",
28
- "typescript": "^5.9.3",
28
+ "typescript": "~6.0.2",
29
29
  "vitest": "^4.1.10",
30
30
  "wrangler": "^4.110.0",
31
31
  "zod": "^4.4.3",
32
- "@eigeninteractive/rules": "0.5.0",
33
- "@eigeninteractive/server": "0.5.0",
34
- "@eigeninteractive/testkit": "0.5.0"
32
+ "@eigeninteractive/rules": "0.5.1",
33
+ "@eigeninteractive/testkit": "0.5.1",
34
+ "@eigeninteractive/server": "0.5.1"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=22"
@@ -48,7 +48,7 @@
48
48
  "url": "https://github.com/eigeninteractive/eigen-platform/issues"
49
49
  },
50
50
  "scripts": {
51
- "build": "tsup src/index.ts src/cli.ts --format esm --dts --sourcemap --clean",
51
+ "build": "tsup src/index.ts src/cli.ts --format esm --sourcemap --clean && tsc -p tsconfig.build.json",
52
52
  "test": "vitest run",
53
53
  "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p templates/worker/tsconfig.json"
54
54
  }
@@ -46,7 +46,7 @@
46
46
  "devDependencies": {
47
47
  "@eigeninteractive/testkit": "{{ENGINE_VERSION}}",
48
48
  "@types/node": "^26.1.1",
49
- "typescript": "^5.9.3",
49
+ "typescript": "~6.0.2",
50
50
  "vitest": "^4.1.10",
51
51
  "wrangler": "^4.110.0"
52
52
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/engine-range.ts","../src/link-firebase.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\";\nimport { type FirebaseLink, readFirebaseLink } from \"./link-firebase.js\";\n\nexport type { FirebaseLink } from \"./link-firebase.js\";\n\nexport type PackageManager = \"npm\" | \"pnpm\";\n\nexport type Runner = (command: string, args: string[], cwd: string) => void;\n\n/**\n * Where a scaffold says what it is doing, so that presentation belongs to the\n * caller and this module only has to name things.\n *\n * The default is the behaviour a library caller expects with no opinion:\n * subprocesses inherit the terminal and warnings go to `console.warn`. The CLI\n * substitutes one that captures each step's output and shows it only if the\n * step fails.\n */\nexport interface Reporter {\n /** Runs `body` as one named step. Its subprocesses can be captured. */\n step<T>(label: string, body: () => T): T;\n /**\n * Runs `body` as a step that owns the terminal, because something inside it\n * asks questions. FlutterFire is the only one.\n */\n handOver<T>(label: string, body: () => T): T;\n /** Output from a subprocess inside the current step. */\n emit(output: string): void;\n /** A failure the scaffold survives. */\n warn(message: string): void;\n /** Whether subprocesses must inherit the terminal rather than be captured. */\n readonly interactive: boolean;\n}\n\n/**\n * Gives a terminal that reports no width the width clack would have assumed.\n *\n * A pty can report itself as a TTY and set `columns` to 0. `script` does, and\n * so do some container terminals. clack falls back to 80 for a stream with no\n * `columns` at all, but `0` is a number and satisfies that check, so the width\n * it draws its rules from goes negative and a scaffold dies partway through\n * with `RangeError: Invalid string length`. Supplying the default its check\n * misses is better than giving up the drawing.\n */\nexport function normaliseTerminalWidth(stream: { isTTY?: boolean; columns?: number }): void {\n if (stream.isTTY === true && (stream.columns ?? 0) < 1) stream.columns = 80;\n}\n\n/** Runs every step plainly, which is what a library caller gets by default. */\nexport const plainReporter: Reporter = {\n step: (_label, body) => body(),\n handOver: (_label, body) => body(),\n emit: (output) => process.stdout.write(output),\n warn: (message) => console.warn(`create-eigen-game: ${message}`),\n interactive: true,\n};\n\n/**\n * The runner a scaffold uses when the caller has not supplied one: it asks the\n * reporter whether the terminal is spoken for.\n *\n * `interactive` inherits, which is the only way FlutterFire can put a question\n * on screen and read the answer. Otherwise both streams are captured and\n * handed to the reporter: on success so it can discard them, and on failure\n * so the reason survives.\n */\nexport function capturingRunner(reporter: Reporter): Runner {\n return (command, args, cwd) => {\n if (reporter.interactive) {\n execFileSync(command, args, { cwd, stdio: \"inherit\" });\n return;\n }\n try {\n reporter.emit(execFileSync(command, args, { cwd, encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"pipe\"] }));\n } catch (error: unknown) {\n // Both streams, because which one a tool failed on is its own business:\n // pub explains itself on stdout, Gradle on stderr.\n const { stdout, stderr } = error as { stdout?: string; stderr?: string };\n reporter.emit(`${stdout ?? \"\"}${stderr ?? \"\"}`);\n throw error;\n }\n };\n}\n\nexport interface ScaffoldOptions {\n directory: string;\n org?: string;\n packageManager?: PackageManager;\n /**\n * Run Flutter, package installation, and contract/payload generation.\n * Kept as a programmatic test seam; the public CLI always bootstraps both\n * halves of the combined project.\n */\n bootstrap?: boolean;\n /**\n * Emit the GitHub Actions workflows. Off by default; see the call site for\n * why, and `addContinuousIntegration` for adding them to an existing\n * project later.\n */\n ci?: boolean;\n /**\n * Initialise a repository and commit the scaffold. Defaults to `bootstrap`,\n * because the commit is only worth having once the generated files exist.\n */\n git?: boolean;\n /**\n * Configure Firebase before the first commit, by running the Flutter\n * client's `configure_firebase`. A string names the project to use; `true`\n * lets FlutterFire ask, which is also where a project can be created.\n *\n * Explicit here, though the CLI turns it on by default: this is the one step\n * that reaches outside the destination directory, and a library caller\n * should say so rather than discover it. {@link firebaseReadiness} is how\n * the CLI decides.\n */\n firebase?: boolean | string;\n /**\n * Runs the bootstrap subprocesses. A seam: the tests substitute a recorder,\n * and `scripts/scaffold-e2e.mjs` wraps it to point the generated server at\n * this workspace's engine rather than npm's copy.\n */\n run?: Runner;\n /**\n * Where the scaffold says what it is doing. See {@link Reporter}; the\n * default runs every step plainly.\n */\n reporter?: Reporter;\n}\n\n/**\n * What became of the repository, so the CLI's closing summary can say rather\n * than guess. `failed` has already warned by the time it is returned, and\n * carries no advice of its own.\n */\nexport type GitOutcome = \"committed\" | \"existing\" | \"skipped\" | \"failed\";\n\nexport interface ScaffoldResult {\n root: string;\n name: string;\n git: GitOutcome;\n /**\n * Whether Firebase was configured, so the summary can either stop naming the\n * step or spell it out. `failed` has already warned.\n */\n firebase: \"configured\" | \"failed\" | \"skipped\";\n /**\n * What the Firebase step made knowable and this scaffold therefore filled\n * in. Absent unless `firebase` is `configured`, since there is nothing to\n * read otherwise.\n */\n link?: FirebaseLink;\n}\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), \"..\");\nconst templatesRoot = resolve(packageRoot, \"templates\");\n\n/**\n * The engine range emitted into a scaffolded project's package.json.\n *\n * Read from this package's `@eigeninteractive/server` devDependency rather than\n * from its own version. See `engine-range.ts` for why that is the version the\n * templates are known to compile against, and what it replaced.\n */\nconst engineVersion = engineRange((JSON.parse(readFileSync(resolve(packageRoot, \"package.json\"), \"utf8\")) as { devDependencies?: Record<string, string> }).devDependencies?.[ENGINE_PACKAGE], () => {\n // Only reached in this workspace, where the manifest still says\n // `workspace:*`. A published tarball has no sibling here and never asks.\n const sibling = resolve(packageRoot, \"../server/package.json\");\n return existsSync(sibling) ? (JSON.parse(readFileSync(sibling, \"utf8\")) as { version: string }).version : undefined;\n});\n\n/**\n * The Flutter client range installed into the app half.\n *\n * A stated version, not a derived or resolved one. The Dart templates import\n * `package:eigen_flutter/eigen_flutter.dart` and\n * `package:eigen_flutter/testing/twin_fixtures.dart` and are written against a\n * specific Dart API. `eigen_flutter` is published and versioned separately from\n * this package even though both now live in the platform monorepo, so a source\n * location cannot compute which released version the template should request.\n * Only compiling a scaffolded app establishes it, which the platform gate does\n * on every change.\n *\n * This briefly resolved from pub.dev instead: \"the newest `eigen_flutter` whose\n * own `eigen_api` constraint targets the engine line being scaffolded\". That\n * predicate is wrong. The `eigen_api` constraint describes the WIRE the 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.4.0` already picks the newest\n * 0.4.x at scaffold time, which is the part the pub.dev lookup was duplicating.\n * What it deliberately cannot do is cross to 0.5.x, the one move that needs a\n * human to confirm the templates still compile.\n *\n * Staleness is therefore a failing check rather than a broken scaffold: this is\n * only ever a release behind, never wrong.\n *\n * Raised to 0.4.0 with the engine's session-snapshot wire. This is the one kind\n * of bump that is not merely an improvement: a scaffold writes both halves, and\n * the worker half is this repository's own line, so the shell it installs has to\n * speak that line's socket. `eigen_flutter` 0.4.0 is the first that does, and\n * every 0.3.x pins `eigen_api: ^0.2.0`, which cannot read a 0.3.x engine at all.\n * A scaffold pinning 0.3.x would therefore resolve, compile, and then fail to\n * render a game, which is the worst of the three.\n *\n * Raised to 0.4.1 for `EngineConfig.authDomain`, which the generated\n * `main.dart` passes. Additive, so pre-1.0 it is a patch and `^0.4.0` would\n * still resolve it, but `^0.4.0` also still resolves 0.4.0, where the parameter\n * does not exist and the scaffold would not compile. The floor is what makes\n * the generated code and the installed shell agree.\n *\n * Raised to 0.6.0 with the engine's opaque pagination cursors, and this is the\n * same *required* kind of bump the 0.4.0 note describes rather than an\n * improvement. The 0.4.x engine line takes `cursor` as an opaque string and\n * returns `nextCursor` on every paged response; `eigen_flutter` 0.6.0 is the\n * first shell that pins `eigen_api: ^0.4.0` and can read it. Everything below\n * that pins `eigen_api: ^0.3.0` or older, so a scaffold left on `^0.4.1` would\n * install the engine's current line beside a shell that cannot read a single\n * paged list from it: it resolves, it compiles, and then the lobby and history\n * are empty. 0.5.0 is skipped for the same reason, being a web-design release\n * that still speaks the 0.3.x wire.\n *\n * Note that this floor and the engine range are raised in one commit on\n * purpose. The scaffolder writes both halves, and `updateInternalDependencies`\n * republishes this package whenever the engine version moves, so between an\n * engine line crossing and this line moving there is a published scaffolder\n * that pairs a new worker with an old shell. That window is real and this is\n * what closes it.\n */\nconst flutterClientVersion = \"^0.6.0\";\n\nconst gameSlug = (value: string): string => {\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value)) {\n throw new Error(\"destination directory name must be a lowercase kebab-case slug, for example my-game\");\n }\n return value;\n};\n\nconst dartName = (value: string): string => value.replaceAll(\"-\", \"_\");\n\n/**\n * The Android `applicationId`, and iOS bundle id, a scaffold at `directory`\n * will produce, so the CLI can show it rather than describe it.\n *\n * `flutter create --org X --project-name Y` derives `X.Y`. The organization is\n * the *prefix*, not the whole identifier, which is the part worth seeing\n * before answering: Google Play makes it permanent at first upload.\n */\nexport function applicationId(directory: string, org?: string): string {\n return `${org?.trim() || \"com.example\"}.${dartName(gameSlug(basename(resolve(directory))))}`;\n}\n\nconst title = (value: string): string =>\n value\n .split(\"-\")\n .map((part) => `${part[0]?.toUpperCase() ?? \"\"}${part.slice(1)}`)\n .join(\" \");\n\nconst identifier = (value: string): string => {\n const pascal = value\n .split(\"-\")\n .map((part) => `${part[0]?.toUpperCase() ?? \"\"}${part.slice(1)}`)\n .join(\"\");\n return /^[0-9]/.test(pascal) ? `Game${pascal}` : pascal;\n};\n\nexport function detectPackageManager(userAgent = process.env.npm_config_user_agent): PackageManager | undefined {\n if (userAgent?.startsWith(\"pnpm/\")) return \"pnpm\";\n if (userAgent?.startsWith(\"npm/\")) return \"npm\";\n return undefined;\n}\n\n/**\n * Substitutes the scaffold's tokens, of which there are two deliberate kinds.\n *\n * `{{BRACED}}` for values that have no valid example: a package manager,\n * an engine version, an Android package id. They appear only in manifests,\n * READMEs, workflows and the `Appfile`: files nothing compiles.\n *\n * Bare words (`ExampleGame`, `example-game`, …) for names a real example game\n * genuinely has. This is what keeps `templates/worker` and the Dart templates\n * VALID, COMPILING SOURCE rather than text with holes in it, which the rest of\n * this package leans on hard: `typecheck` runs `tsc` over `templates/worker`,\n * the tests `import` its game module directly and build a real contract from\n * it, and the `scaffold` job compiles the Dart templates. Bracing these would\n * trade all of that for a marker.\n *\n * The cost, and the one rule for template authors: a template file cannot\n * contain the literal string `example-game`, `Example Game`, `ExampleGame` or\n * `example_game` and keep it; every occurrence is rewritten, in prose and in\n * code alike. Write around it, or brace a new token instead.\n *\n * Note this means the set of files carrying a token changes whenever someone\n * writes one into an existing file. Nothing needs to track that: `renderTree`\n * decides what to rewrite from the bytes, not from a list of paths.\n */\nfunction render(contents: string, name: string, manager: PackageManager, packageId: string): string {\n const replacements: ReadonlyArray<readonly [string, string]> = [\n [\"@game/example-game-server\", `@game/${name}-server`],\n [\"{{PACKAGE_MANAGER}}\", manager],\n [\"{{PACKAGE_ID}}\", packageId],\n [\"{{ENGINE_VERSION}}\", engineVersion],\n [\"ExampleGame\", identifier(name)],\n [\"Example Game\", title(name)],\n [\"example_game\", dartName(name)],\n [\"example-game\", name],\n ];\n return replacements.reduce((result, [from, to]) => result.replaceAll(from, to), contents);\n}\n\n/**\n * True when the bytes are valid UTF-8.\n *\n * This is not a guess at whether a file is \"binary\"; it is the precondition\n * of the operation. Token substitution is `String.replaceAll`, so a file that\n * cannot be decoded cannot take part, and one that can is safe to rewrite.\n *\n * Deliberately not an extension list. A DENY list (`.png`, `.jar`, …) fails\n * silently in the dangerous direction: the day someone adds a `.webp`, it is\n * corrupted with no error. An ALLOW list fails the safe way but fits this tree\n * badly: `Gemfile`, `Fastfile`, `.nvmrc`, `.fvmrc` and `.ruby-version` all\n * need rendering and none carry a usable extension, so it would have to be a\n * list of extensions *and* a list of bare filenames, both drifting.\n *\n * `.template` is not the signal either, despite the name: it marks files a\n * language server must not claim before they have an enclosing package. Five\n * of them contain no token at all, and nine token-bearing files are not\n * marked, so the two concepts are orthogonal here.\n *\n * `renderTree`'s test pins the resulting classification for the whole tree, so\n * this stays a reviewed decision rather than an invisible one.\n */\nconst utf8 = new TextDecoder(\"utf-8\", { fatal: true });\n\nexport function decodeUtf8(bytes: Buffer): string | undefined {\n try {\n return utf8.decode(bytes);\n } catch {\n return undefined;\n }\n}\n\nfunction renderTree(source: string, destination: string, name: string, manager: PackageManager, packageId: string): void {\n cpSync(source, destination, { recursive: true });\n // Walks the TEMPLATE, not the destination. The app overlay renders on top of\n // a `flutter create` result, so walking the destination meant rewriting\n // every file Flutter had just generated, including its binaries, for files\n // this scaffolder does not own and has no business touching.\n const visit = (directory: string): void => {\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n const templatePath = resolve(directory, entry.name);\n if (entry.isDirectory()) {\n visit(templatePath);\n continue;\n }\n if (!entry.isFile()) continue;\n\n const rendered = resolve(destination, relative(source, templatePath));\n const text = decodeUtf8(readFileSync(templatePath));\n // Undecodable files are already in place from the copy above, byte for\n // byte. Only decodable ones are rewritten.\n if (text !== undefined) {\n writeFileSync(rendered, render(text, name, manager, packageId));\n }\n // Template-only source must not be claimed by language servers before\n // it has an enclosing generated package. Restore the real extension\n // only in the rendered project.\n if (entry.name.endsWith(\".template\")) {\n renameSync(rendered, rendered.slice(0, -\".template\".length));\n }\n }\n };\n visit(source);\n\n // npm deliberately excludes files named `.gitignore` from package\n // tarballs. Their packaged twins live outside the C3 template so a direct\n // Git-based C3 render does not inherit a scaffolder-only helper file.\n const packagedGitignore = resolve(templatesRoot, \"scaffold\", `${basename(source)}.gitignore`);\n if (existsSync(packagedGitignore)) {\n writeFileSync(resolve(destination, \".gitignore\"), render(readFileSync(packagedGitignore, \"utf8\"), name, manager, packageId));\n }\n}\n\nfunction packageCommand(manager: PackageManager, operation: \"install\" | \"contract\" | \"cf-typegen\"): [string, string[]] {\n if (operation === \"install\") return [manager, [\"install\"]];\n return [manager, [\"run\", operation]];\n}\n\n/**\n * Appends `block` to a file this scaffolder does not own, as its own paragraph.\n *\n * **Append, never insert.** That is the rule the three callers below follow, and\n * it is what keeps them from competing with `flutter create` and `flutterfire\n * configure` for position in the same files. A pure append cannot collide with\n * whatever those tools write above it; the one edit here that ever needed a\n * position, prepending a Kotlin `import`, was broken by an AGP upgrade and has\n * since been rewritten away. See MAINTAINERS.md for the whole doctrine, including\n * why FlutterFire's `// START:`/`// END:` marker comments are deliberately not\n * copied.\n *\n * `contents` is passed in rather than read here because every caller has already\n * read the file to decide whether its block is present, and two of them assert\n * on the shape of what they found. This owns the whitespace and nothing else.\n *\n * That is worth one function because it was previously written three times with\n * two different answers, so the desugaring block got a blank line before it and\n * the other two did not, and the two Gradle blocks ended up flush against each\n * other in every generated project. Separation belongs to the append, so the\n * block constants carry no leading or trailing newline of their own.\n */\nfunction appendBlock(path: string, contents: string, block: string): void {\n appendFileSync(path, `${contents.endsWith(\"\\n\") ? \"\" : \"\\n\"}\\n${block}\\n`);\n}\n\nconst androidDesugaring = `// flutter_local_notifications requires desugaring in the application module.\n// A library plugin cannot enable this compiler setting transitively.\nandroid {\n compileOptions {\n isCoreLibraryDesugaringEnabled = true\n }\n}\n\ndependencies {\n coreLibraryDesugaring(\"com.android.tools:desugar_jdk_libs:2.1.4\")\n}`;\n\nfunction enableAndroidCoreLibraryDesugaring(appRoot: string): void {\n const gradlePath = resolve(appRoot, \"android/app/build.gradle.kts\");\n const gradle = readFileSync(gradlePath, \"utf8\");\n if (!gradle.includes('id(\"com.android.application\")')) {\n throw new Error(`Flutter created an unexpected Android application build file: ${gradlePath}`);\n }\n const settingExists = gradle.includes(\"isCoreLibraryDesugaringEnabled\");\n const dependencyExists = gradle.includes(\"coreLibraryDesugaring(\");\n if (settingExists && dependencyExists) return;\n if (settingExists || dependencyExists) {\n throw new Error(`Flutter created an incomplete Android core library desugaring configuration: ${gradlePath}`);\n }\n appendBlock(gradlePath, gradle, androidDesugaring);\n}\n\n// A second top-level `android { }` block is valid Gradle Kotlin DSL, since Gradle\n// merges repeated extension-configuration blocks in one file, which is what\n// lets this stay a pure append, same as the desugaring block above. A second\n// top-level `plugins { }` block is NOT valid (Gradle allows exactly one per\n// script), which is why the Crashlytics Gradle plugin registration,\n// `flutterfire configure`'s own territory, is deliberately left alone here.\n//\n// Parsed with the Kotlin stdlib rather than `java.util.Properties`, which is\n// what keeps this appendable. `Properties` would need a real `import`, and\n// Kotlin requires imports before every other top-level declaration, so using it\n// meant also reaching into the very start of a file this scaffolder does not\n// own. A fully-qualified `java.util.Properties()` reference was tried to avoid\n// that, and does not resolve under AGP 9's Kotlin DSL script compilation\n// (`flutter create`'s current default): \"Unresolved reference 'util'\".\n// Confirmed by actually building a scaffolded project, not just reading it.\nconst androidReleaseSigning = `val releaseKeyProperties: Map<String, String> =\n rootProject.file(\"key.properties\")\n .takeIf { it.exists() }\n ?.readLines()\n ?.map { it.trim() }\n ?.filter { it.isNotEmpty() && !it.startsWith(\"#\") && it.contains(\"=\") }\n ?.associate { it.substringBefore(\"=\").trim() to it.substringAfter(\"=\").trim() }\n .orEmpty()\n\nandroid {\n signingConfigs {\n create(\"release\") {\n storeFile = releaseKeyProperties[\"storeFile\"]?.let { file(it) }\n storePassword = releaseKeyProperties[\"storePassword\"]\n keyAlias = releaseKeyProperties[\"keyAlias\"]\n keyPassword = releaseKeyProperties[\"keyPassword\"]\n }\n }\n buildTypes {\n release {\n signingConfig = if (releaseKeyProperties[\"storeFile\"] != null)\n signingConfigs.getByName(\"release\")\n else\n signingConfigs.getByName(\"debug\")\n isMinifyEnabled = true\n isShrinkResources = true\n proguardFiles(\n getDefaultProguardFile(\"proguard-android-optimize.txt\"),\n \"proguard-rules.pro\",\n )\n }\n }\n}`;\n\nfunction enableAndroidReleaseSigning(appRoot: string): void {\n const gradlePath = resolve(appRoot, \"android/app/build.gradle.kts\");\n const gradle = readFileSync(gradlePath, \"utf8\");\n // Not `gradle.includes(\"signingConfigs\")`, because Flutter's own template already\n // contains that substring (`signingConfig = signingConfigs.getByName(\"debug\")`),\n // so that check would always short-circuit and never append anything.\n if (gradle.includes(\"releaseKeyProperties\")) return;\n // A pure append. This previously also PREPENDED `import java.util.Properties`,\n // the most position-dependent edit here and the one already broken once by an\n // AGP upgrade; see the block above for what replaced it.\n appendBlock(gradlePath, gradle, androidReleaseSigning);\n}\n\n// `flutter_launcher_icons`/`flutter_native_splash` read these as plain\n// top-level pubspec keys, so appending is safe regardless of what\n// `flutter create` already wrote under `flutter:`. Deliberately omits\n// `ios`/`macos`, since `scaffoldGame` only creates `--platforms android,web`, and\n// `flutter_launcher_icons` errors if told to target a platform whose\n// directory doesn't exist.\n// The colours are the EigenInteractive palette (ink #1B1E24, paper #F4F1EA) because the\n// shipped placeholder art is the EigenInteractive mark: the adaptive foreground is the\n// reversed, light-on-dark variant, so an ink background is what makes it\n// legible. Rebranding a game means replacing the four PNGs *and* these\n// colours together. See https://eigeninteractive.com/docs/ship-it/branding.\nconst launcherIconsAndSplashConfig = `flutter_launcher_icons:\n android: true\n web:\n generate: true\n image_path: \"assets/icon/icon.png\"\n image_path: \"assets/icon/icon.png\"\n adaptive_icon_background: \"#1B1E24\"\n adaptive_icon_foreground: \"assets/icon/icon_foreground.png\"\n min_sdk_android: 21\n\nflutter_native_splash:\n color: \"#F4F1EA\"\n color_dark: \"#1B1E24\"\n image: assets/icon/splash.png\n image_dark: assets/icon/splash_dark.png\n fullscreen: true\n android_12:\n color: \"#F4F1EA\"\n color_dark: \"#1B1E24\"\n image: assets/icon/splash.png\n image_dark: assets/icon/splash_dark.png\n icon_background_color: \"#F4F1EA\"\n icon_background_color_dark: \"#1B1E24\"\n web: true`;\n\nfunction configureLauncherIconsAndSplash(appRoot: string): void {\n const pubspecPath = resolve(appRoot, \"pubspec.yaml\");\n const pubspec = readFileSync(pubspecPath, \"utf8\");\n if (pubspec.includes(\"flutter_launcher_icons:\")) return;\n appendBlock(pubspecPath, pubspec, launcherIconsAndSplashConfig);\n}\n\nexport interface AddContinuousIntegrationOptions {\n directory: string;\n /** Overrides the manager recorded in the project's own package.json. */\n packageManager?: PackageManager;\n}\n\n/**\n * Adds the GitHub Actions workflows to an existing generated project.\n *\n * The companion to `ci: false`: a game can be built and played locally for as\n * long as its author likes, then gain the same PR gate and signed release\n * pipeline a `--ci` scaffold would have produced.\n */\nexport function addContinuousIntegration(options: AddContinuousIntegrationOptions): { root: string; files: string[] } {\n const root = resolve(options.directory);\n const manifestPath = resolve(root, \"package.json\");\n if (!existsSync(manifestPath) || !existsSync(resolve(root, \"server\")) || !existsSync(resolve(root, \"app\"))) {\n throw new Error(`not an EigenInteractive game project (expected package.json, server/ and app/): ${root}`);\n }\n\n const manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as {\n name?: string;\n scripts?: Record<string, string>;\n };\n const name = gameSlug(manifest.name ?? basename(root));\n\n // The generated `contract` script embeds the manager the project was\n // scaffolded with (`cd server && pnpm run contract && …`), which is a more\n // reliable signal than a lockfile: it is present before anything is\n // installed, and it is what the project actually uses.\n const recorded = manifest.scripts?.contract?.includes(\"pnpm \") ? \"pnpm\" : manifest.scripts?.contract?.includes(\"npm \") ? \"npm\" : undefined;\n const manager = options.packageManager ?? recorded ?? detectPackageManager() ?? \"pnpm\";\n\n // Only `{{PACKAGE_MANAGER}}` appears in these templates, but the real\n // package id is read back rather than reconstructed, so a project scaffolded\n // under a different `--org` cannot be silently rewritten to `com.example`.\n const appfile = resolve(root, \"app/fastlane/Appfile\");\n const packageId = existsSync(appfile) ? (/package_name\\(\"([^\"]+)\"\\)/.exec(readFileSync(appfile, \"utf8\"))?.[1] ?? `com.example.${dartName(name)}`) : `com.example.${dartName(name)}`;\n\n const workflows = resolve(root, \".github/workflows\");\n const existing = existsSync(workflows) ? readdirSync(workflows).filter((f) => f === \"checks.yml\" || f === \"release.yml\") : [];\n if (existing.length > 0) {\n throw new Error(`refusing to overwrite existing workflows: ${existing.join(\", \")}`);\n }\n\n renderTree(resolve(templatesRoot, \"ci\"), root, name, manager, packageId);\n return { root, files: [\".github/workflows/checks.yml\", \".github/workflows/release.yml\"] };\n}\n\n/** Asks a command a question. `ok` is \"ran and succeeded\"; a tool that is not installed and one that fails are both `false`, because neither can be used. */\nexport type Probe = (command: string, args: string[]) => { ok: boolean; stdout: string };\n\nconst probeCommand: Probe = (command, args) => {\n try {\n return { ok: true, stdout: execFileSync(command, args, { encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"] }) };\n } catch {\n return { ok: false, stdout: \"\" };\n }\n};\n\n/** One thing standing between this machine and a configured Firebase project, and the single command that clears it. */\nexport interface FirebaseProblem {\n /** Said as a sentence fragment, so it reads after \"Firebase is not set up here:\". */\n reason: string;\n /** The one command that fixes this, and nothing else. */\n fix: string;\n}\n\nexport type FirebaseReadiness = { ready: true } | { ready: false; problems: FirebaseProblem[] };\n\n/**\n * Whether this machine can configure Firebase, asked *before* the scaffold\n * rather than after it.\n *\n * `configure_firebase` runs the same three checks and is the authority on\n * them; this one exists only to move the answer earlier. Learning that\n * `flutterfire` is missing costs nothing here and costs two minutes of Flutter\n * and pub at the far end, which is where the step actually runs.\n *\n * Every problem, not the first one. The checks are independent (two CLIs from\n * two ecosystems, plus a sign-in) so short-circuiting turns one setup into a\n * sequence of runs that each reveal the next missing piece. Reported in the\n * order they have to be fixed in: the CLI, then the sign-in it stores, then\n * the bridge that consumes both.\n *\n * The sign-in check fails open, for the same reason it does there: only an\n * answer that positively reports no accounts counts as \"no\", so a `firebase`\n * that errors or grows a different output shape is left to the command that\n * actually needs the credentials.\n */\nexport function firebaseReadiness(probe: Probe = probeCommand): FirebaseReadiness {\n const problems: FirebaseProblem[] = [];\n\n if (probe(\"firebase\", [\"--version\"]).ok) {\n if (signedOut(probe)) problems.push({ reason: \"no Google account is signed in to the Firebase CLI\", fix: \"firebase login\" });\n } else {\n // Nothing to say about the sign-in: the CLI that would answer is the one\n // that is missing, and `firebase login` is what installing leads to anyway.\n // Google's own installer, which picks a standalone binary or npm to suit\n // the machine. `npm install -g firebase-tools` also works and is what this\n // used to print, but it needs a global npm prefix the reader may not have\n // write access to, and it is not the install the Firebase docs lead with.\n problems.push({ reason: \"the `firebase` CLI is not installed\", fix: \"curl -sL https://firebase.tools | bash\" });\n }\n\n if (!probe(\"flutterfire\", [\"--version\"]).ok) {\n problems.push({ reason: \"the `flutterfire` CLI is not installed\", fix: \"dart pub global activate flutterfire_cli\" });\n }\n\n return problems.length === 0 ? { ready: true } : { ready: false, problems };\n}\n\n/**\n * Whether the Firebase CLI holds no credentials.\n *\n * `login:list --json` prints the stored refresh and access tokens along with\n * the account list. Read the shape, count the entries, and never surface the\n * output: not in a warning, not in a captured stream, not on the failure\n * path. That is why this returns a boolean rather than the response.\n */\nfunction signedOut(probe: Probe): boolean {\n const accounts = probe(\"firebase\", [\"login:list\", \"--json\"]);\n if (!accounts.ok) return false;\n try {\n const { result } = JSON.parse(accounts.stdout) as { result?: unknown };\n return Array.isArray(result) && result.length === 0;\n } catch {\n // Unparseable is not evidence of anything.\n return false;\n }\n}\n\n/**\n * Whether the scaffold would land inside a repository that already exists.\n *\n * Asked of the nearest ancestor that exists, because the destination does not\n * yet. The point is not to change what {@link scaffoldGame} does, which already\n * declines to nest a repository, but to stop the CLI asking a question whose\n * answer cannot matter.\n */\n/**\n * Why this destination cannot be scaffolded into, said as a whole message, or\n * `undefined` when there is nothing in the way.\n *\n * A directory that exists and is *empty* is not in the way, since people make\n * one out of habit, so it is removed and rewritten rather than refused over\n * nothing. Anything with contents in it is refused, and a cloned repository is\n * not an exception: `.git` is in the way like any other entry, and the message\n * names it. Publishing into one would mean parking `.git`, renaming staging\n * over the top and putting it back, with a failure in the middle able to\n * orphan a remote, which is a lot of care to spend on a flow that has a\n * one-line alternative.\n *\n * Refused, and deliberately not offered as a \"remove it and continue?\"\n * question, which is where several scaffolders in this family go. This one\n * writes ninety-odd files and runs `flutter create`; the cost of getting that\n * answer wrong against a mistyped path has no upper bound, and `rm -rf` is one\n * command that belongs to the person who can see what is in there. Every other\n * question this CLI asks is reversible. This one would not be.\n *\n * Exported so the CLI can ask it before the first question rather than after\n * the last one. {@link scaffoldGame} asks it again, for callers that are not\n * the CLI.\n */\nexport function destinationProblem(directory: string): string | undefined {\n const root = resolve(directory);\n if (!existsSync(root)) return undefined;\n\n if (!statSync(root).isDirectory()) return `${root} already exists, and is a file.`;\n\n const entries = readdirSync(root);\n if (entries.length === 0) return undefined;\n\n // Named, not counted. \"not empty\" invites an `ls`; the three that are\n // actually there usually settle whether this was the wrong path or a\n // directory that has already been scaffolded once.\n const shown = entries.slice(0, 3).sort().join(\", \");\n const rest = entries.length > 3 ? `, and ${entries.length - 3} more` : \"\";\n return `${root} already exists, and is not empty: it holds ${shown}${rest}.\\n\\nScaffold somewhere else, or clear it out yourself. This will not delete a directory you already had.`;\n}\n\nexport function insideWorkTree(directory: string, probe: Probe = probeCommand): boolean {\n let candidate = resolve(directory);\n while (!existsSync(candidate)) {\n const parent = dirname(candidate);\n if (parent === candidate) return false;\n candidate = parent;\n }\n return probe(\"git\", [\"-C\", candidate, \"rev-parse\", \"--is-inside-work-tree\"]).ok;\n}\n\n/**\n * Runs the Flutter client's `configure_firebase` against the generated app.\n *\n * The command owns everything about how Firebase is configured: which\n * platforms, which CLIs must exist, whether anyone is signed in, and what to\n * do when no project has been chosen yet. This only decides *when*: before the\n * scaffold commit, so a configured project is committed configured.\n *\n * Not fatal. Every failure here (a missing `flutterfire`, no Google login, a\n * cancelled picker) leaves a complete and usable project that is exactly what\n * a scaffold without `--firebase` produces, so it warns with the command to\n * re-run and lets the commit happen.\n */\nfunction configureFirebase(appRoot: string, project: boolean | string, run: Runner, reporter: Reporter): \"configured\" | \"failed\" {\n // FlutterFire asks before overwriting `firebase_options.dart`, and the\n // scaffold has just written one, a throwing placeholder whose entire\n // purpose is to be replaced by this step. Answering that is a question with\n // one right answer, so the placeholder is moved out of the way and the\n // question never gets asked.\n const placeholder = resolve(appRoot, \"lib/firebase_options.dart\");\n const parked = `${placeholder}.placeholder`;\n const parking = existsSync(placeholder);\n if (parking) renameSync(placeholder, parked);\n\n try {\n // `dart run` compiles the package executable on first use and says so.\n // Doing it against `--help`, which returns immediately, moves that noise\n // into a step whose output can be captured; the real run cannot be, since\n // FlutterFire prompts through it.\n reporter.step(\"Preparing the Firebase configurator\", () => run(\"dart\", [\"run\", \"eigen_flutter:configure_firebase\", \"--help\"], appRoot));\n // `--worker` is what makes this fill in `FIREBASE_PROJECT_ID` as well as\n // the app's own values. An app-only repository omits it and gets the app\n // half; a combined scaffold has the Worker one directory over.\n reporter.handOver(\"Configuring Firebase\", () => run(\"dart\", [\"run\", \"eigen_flutter:configure_firebase\", \"--worker\", \"../server\", ...(typeof project === \"string\" ? [\"--project\", project] : [])], appRoot));\n if (parking) rmSync(parked, { force: true });\n return \"configured\";\n } catch {\n // Back only if nothing took its place. FlutterFire writes\n // `firebase_options.dart` before the service worker configuration is\n // derived from it, so a late failure leaves a real one that is worth more\n // than the placeholder.\n if (parking) {\n if (existsSync(placeholder)) rmSync(parked, { force: true });\n else renameSync(parked, placeholder);\n }\n reporter.warn(\"Could not configure Firebase. The project is complete. Run `firebase:configure` yourself, then commit what it writes.\");\n return \"failed\";\n }\n}\n\n/**\n * Commits the scaffold, so the first `git diff` is the first game change.\n *\n * This matters more here than in a scaffolder that only writes source. The\n * bootstrap runs `flutter_launcher_icons` and `flutter_native_splash`, which\n * write generated-but-committed files across `android/`, `web/` and\n * `assets/`; without a baseline the first branding change is indistinguishable\n * from the ninety files the scaffolder happened to produce.\n *\n * Nothing here is fatal. The project is complete and valid before this runs,\n * so a missing `git`, or the unconfigured `user.email` that a fresh CI image\n * has, warns and leaves the tree alone rather than discarding a scaffold that\n * took two minutes of Flutter and pub to produce.\n */\nfunction initialiseRepository(root: string, name: string, run: Runner, reporter: Reporter): GitOutcome {\n // Scaffolding inside an existing checkout (a monorepo, or a repository\n // created ahead of time) is a legitimate thing to do, and a nested\n // repository there is silent breakage: the outer `git add` records a gitlink\n // and the app's files never leave the machine. Asked directly rather than\n // through `run`, because it is a question, not a step.\n try {\n execFileSync(\"git\", [\"rev-parse\", \"--is-inside-work-tree\"], { cwd: root, stdio: \"ignore\" });\n return \"existing\";\n } catch {\n // Not inside a work tree, which is the case this function is for.\n }\n\n try {\n run(\"git\", [\"init\", \"--quiet\"], root);\n run(\"git\", [\"add\", \"--all\"], root);\n } catch {\n reporter.warn(\"Could not initialise a git repository. The project is complete. Run `git init` yourself when ready.\");\n return \"failed\";\n }\n\n try {\n run(\"git\", [\"commit\", \"--quiet\", \"--message\", `Scaffold ${name}`], root);\n } catch {\n reporter.warn(`Initialised a repository and staged the scaffold, but could not commit it. Set \\`user.name\\` and \\`user.email\\`, then \\`git commit -m \"Scaffold ${name}\"\\`.`);\n return \"failed\";\n }\n\n return \"committed\";\n}\n\nexport function scaffoldGame(options: ScaffoldOptions): ScaffoldResult {\n const root = resolve(options.directory);\n const name = gameSlug(basename(root));\n const manager = options.packageManager ?? detectPackageManager() ?? \"pnpm\";\n const org = options.org?.trim() || \"com.example\";\n // Fastlane's `Appfile` names the same package the build actually produces,\n // and the CLI shows the same one before asking.\n const packageId = applicationId(root, org);\n const bootstrap = options.bootstrap ?? true;\n const reporter = options.reporter ?? plainReporter;\n const run = options.run ?? capturingRunner(reporter);\n\n const occupied = destinationProblem(root);\n if (occupied !== undefined) throw new Error(occupied);\n // Empty, or `destinationProblem` would have said so. Removed rather than\n // scaffolded into, because the rename below publishes the staging directory\n // *as* this path and cannot do that while something is standing there.\n if (existsSync(root)) rmdirSync(root);\n\n mkdirSync(dirname(root), { recursive: true });\n\n // Build beside the destination and publish it with one rename. Failed\n // subprocesses never leave a half-scaffolded project at the requested path.\n const stagingRoot = mkdtempSync(resolve(dirname(root), `.${basename(root)}-`));\n try {\n const serverRoot = resolve(stagingRoot, \"server\");\n const appRoot = resolve(stagingRoot, \"app\");\n\n renderTree(resolve(templatesRoot, \"worker\"), serverRoot, name, manager, packageId);\n renderTree(resolve(templatesRoot, \"project\"), stagingRoot, name, manager, packageId);\n // Opt-in. release.yml wants an upload keystore and a Play service account\n // that a brand-new project does not have, so generating it by default\n // means a red X on main from the first push until someone sets both up.\n // `create-eigen-game add ci` writes the same files whenever it is wanted.\n if (options.ci) renderTree(resolve(templatesRoot, \"ci\"), stagingRoot, name, manager, packageId);\n\n if (bootstrap) {\n reporter.step(\"Creating the Flutter app\", () => {\n run(\"flutter\", [\"create\", \"--empty\", \"--platforms\", \"android,web\", \"--project-name\", dartName(name), \"--org\", org, appRoot], stagingRoot);\n enableAndroidCoreLibraryDesugaring(appRoot);\n enableAndroidReleaseSigning(appRoot);\n });\n } else {\n mkdirSync(appRoot, { recursive: true });\n }\n renderTree(resolve(templatesRoot, \"app-overlay\"), appRoot, name, manager, packageId);\n\n if (bootstrap) {\n reporter.step(\"Adding the Flutter packages\", () => {\n configureLauncherIconsAndSplash(appRoot);\n run(\"flutter\", [\"pub\", \"add\", `eigen_flutter@${flutterClientVersion}`, \"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 // What that step settled, so the summary can name what it did not.\n // `configure_firebase` does the writing, including into the Worker's\n // wrangler.jsonc, which is what `--worker` above is for.\n const link = firebase === \"configured\" ? readFirebaseLink(root) : undefined;\n const git = (options.git ?? bootstrap) ? initialiseRepository(root, name, run, reporter) : \"skipped\";\n\n return { root, name, git, firebase, link };\n}\n","/**\n * Where the engine range emitted into a scaffolded project comes from.\n *\n * Its own module because the two branches below execute in different worlds,\n * one only inside this repository and the other only inside a published tarball,\n * and a function whose published-only path never runs in CI is a function that\n * is not tested. `src/index.ts` uses it; the package `exports` map does not\n * expose it, so it is internal despite being importable by the tests.\n */\n\n/** The dependency whose version the scaffolder emits into the generated server. */\nexport const ENGINE_PACKAGE = \"@eigeninteractive/server\";\n\n/**\n * The engine range for a scaffolded project, from this package's own\n * `@eigeninteractive/server` devDependency.\n *\n * That number is not maintained by anyone: it is the version CI compiled the\n * templates against, because `pnpm -r typecheck` runs\n * `tsc -p templates/worker/tsconfig.json` inside this workspace. Emitting\n * anything else would mean shipping templates paired with an engine no build\n * ever saw.\n *\n * It replaced a derivation from this package's OWN version, which was correct\n * only while `create-eigen-game` sat in the `fixed` changesets group, and that\n * membership is what forced an engine-wide release for every scaffolder-only\n * change. Reading the dependency keeps the guarantee and drops the coupling.\n *\n * Two branches, because the same manifest reads differently in the two places\n * this runs:\n *\n * - **Published tarball**: pnpm rewrites `workspace:*` to the exact version\n * while packing, so the manifest already states it (`\"0.2.0\"`), and no\n * sibling package exists on disk to consult.\n * - **This workspace**: the manifest still says `workspace:*`, which names no\n * version, so the sibling package is read directly.\n *\n * @param declared the raw `@eigeninteractive/server` devDependency value\n * @param readSiblingVersion consulted only for the `workspace:` protocol\n */\nexport function engineRange(declared: string | undefined, readSiblingVersion: () => string | undefined): string {\n if (!declared) {\n throw new Error(`create-eigen-game has no ${ENGINE_PACKAGE} devDependency, which is where the engine range it emits comes from`);\n }\n\n const version = declared.startsWith(\"workspace:\") ? readSiblingVersion() : declared;\n\n if (!version) {\n throw new Error(`create-eigen-game declares ${ENGINE_PACKAGE} as \"${declared}\" but the workspace package could not be read, so there is no engine version to emit`);\n }\n\n // pnpm packs `workspace:*` as a bare version, which is what makes the caret\n // below correct. Asserting it means a change in that behaviour fails here\n // rather than emitting something like `^^0.3.0` into a real project.\n if (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {\n throw new Error(`expected an exact ${ENGINE_PACKAGE} version to build a range from, got \"${version}\"`);\n }\n\n return `^${version}`;\n}\n","/**\n * Reads the two deployment values that exist only once a Firebase project\n * does, so the closing summary can name what is still missing.\n *\n * Reading only. `configure_firebase` writes them, into `wrangler.jsonc` and\n * `app-config.json`, because it is also what a project runs later when\n * reconfiguring, and one implementation is what keeps the scaffold-time path\n * and the re-run path identical. This module exists so the summary can tell\n * the difference between \"filled in\" and \"still owed\", not to do it again.\n *\n * Its own module for the same reason `summary.ts` is: `index.ts` runs a\n * scaffold, and this is worth asserting without one. The package `exports` map\n * does not expose it.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\n/** What the Firebase step managed to settle, and what it left for the console. */\nexport interface FirebaseLink {\n /** The project now in `wrangler.jsonc`, or null when FlutterFire recorded none. */\n projectId: string | null;\n /** The OAuth web client now in `app-config.json`, or null when Google sign-in is not enabled yet. */\n googleWebClientId: string | null;\n}\n\nfunction readJson(path: string): unknown {\n if (!existsSync(path)) return undefined;\n try {\n return JSON.parse(readFileSync(path, \"utf8\"));\n } catch {\n // A file this step only reads is never worth failing a finished scaffold\n // for. The value counts as unset, and the summary says so.\n return undefined;\n }\n}\n\n/**\n * The project FlutterFire recorded for the Dart output this app uses.\n *\n * `firebase.json` is FlutterFire's own record rather than something this\n * scaffold writes, so it is read defensively: a shape that does not match is\n * treated as \"not configured\", which is the same answer as a run that never\n * happened.\n */\nexport function configuredProject(appRoot: string): string | null {\n const record = readJson(resolve(appRoot, \"firebase.json\")) as { flutter?: { platforms?: { dart?: Record<string, { projectId?: unknown }> } } } | undefined;\n const projectId = record?.flutter?.platforms?.dart?.[\"lib/firebase_options.dart\"]?.projectId;\n return typeof projectId === \"string\" && projectId !== \"\" ? projectId : null;\n}\n\n/**\n * The OAuth web client id that `configure_firebase` copied into\n * `app-config.json`, when there was one to copy.\n *\n * Empty is an ordinary outcome rather than a failure. Firebase creates that\n * client when the Google sign-in provider is enabled, which is a console\n * action no CLI can perform, so a project that has never had it enabled has\n * nothing to offer here.\n */\nexport function configuredWebClientId(appRoot: string): string | null {\n const config = readJson(resolve(appRoot, \"app-config.json\")) as Record<string, unknown> | undefined;\n const value = config?.GOOGLE_WEB_CLIENT_ID;\n return typeof value === \"string\" && value !== \"\" ? value : null;\n}\n\n/** What the Firebase step settled, for the summary to report. */\nexport function readFirebaseLink(root: string): FirebaseLink {\n const appRoot = resolve(root, \"app\");\n return { projectId: configuredProject(appRoot), googleWebClientId: configuredWebClientId(appRoot) };\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB,QAAQ,cAAAA,aAAY,WAAW,aAAa,aAAa,gBAAAC,eAAc,YAAY,WAAW,QAAQ,UAAU,qBAAqB;AAC9J,SAAS,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