@ebay-dt/bonfire-cli 0.3.0-alpha.4 → 0.3.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/dist/branch-prepare.d.ts.map +1 -1
- package/dist/branch-prepare.js +4 -1
- package/dist/branch-prepare.js.map +1 -1
- package/dist/command.d.ts +2 -0
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +47 -8
- package/dist/command.js.map +1 -1
- package/dist/release-versions.d.ts +1 -1
- package/dist/release-versions.d.ts.map +1 -1
- package/dist/release-versions.js +1 -1
- package/dist/release-versions.js.map +1 -1
- package/package.json +4 -4
- package/templates/instance/src/actions/preferences.ts +16 -0
- package/templates/instance/src/app/(prototypes)/layout.tsx +10 -1
- package/templates/instance/src/app/(system)/layout.tsx +4 -0
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ Use the context commands explicitly from an instance repository:
|
|
|
65
65
|
|
|
66
66
|
```sh
|
|
67
67
|
bonfire context sync [--check] [--skip-prototypes] [--root <root>]
|
|
68
|
-
bonfire context install [--check] --app-id <app-id> [--root <root>]
|
|
68
|
+
bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>]
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
`sync` writes deterministic repository projections and `sync --check` performs
|
|
@@ -73,7 +73,17 @@ the same validation without writing. Both default `--root` to the current
|
|
|
73
73
|
working directory and print only generated paths and status. `--skip-prototypes` excludes prototype discovery for both sync and check; generated app `check` uses it to validate root context only. Prototype `AGENTS.md`, `CLAUDE.md`, and `.claude/settings.json` are local ignored outputs, regenerated on non-production dev startup when eligible, rather than committed. `install` installs
|
|
74
74
|
canonical skills and merges MCP definitions into the user's Cursor MCP
|
|
75
75
|
configuration while preserving unrelated entries. `install --check` validates
|
|
76
|
-
machine state without changing it.
|
|
76
|
+
machine state without changing it, including with force flags; unresolved conflicts are reported.
|
|
77
|
+
|
|
78
|
+
By default, conflicting individual skills and MCP servers are skipped with warnings, preserving existing configuration while other entries are installed. Warnings exit successfully. Use `--force-skills` or `--force-mcp` to replace conflicts in that category, or `--force` for both. Replacements are backed up and their locations printed. Only provided names are replaced; unrelated global skills and MCP JSON entries are preserved. Skill names are shared globally, so replacing one affects other applications using that name. Unreadable or invalid configuration and safety failures remain errors.
|
|
79
|
+
|
|
80
|
+
For generated application scripts, for example:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
pnpm context:install --force-skills
|
|
84
|
+
pnpm context:install --force-mcp
|
|
85
|
+
pnpm context:install --force
|
|
86
|
+
```
|
|
77
87
|
|
|
78
88
|
## Branch preparation
|
|
79
89
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-prepare.d.ts","sourceRoot":"","sources":["../src/branch-prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAQlE,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAEhE,MAAM,MAAM,oBAAoB,GAAG,CACjC,IAAI,EAAE,MAAM,KACT,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAElD,MAAM,MAAM,yBAAyB,GAAG;IACtC,2BAA2B,CAAC,EAAE,OAAO,sBAAsB,CAAC;IAC5D,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,mBAAmB,CAAC;IACzE,SAAS,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,eAAe,GAAG,qBAAqB,CAAC,CAAC;IAC9E,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,0BAA0B,CAAC,EAAE,WAAW,CACtC,kBAAkB,CAAC,4BAA4B,CAAC,CACjD,CAAC;IACF,uBAAuB,CAAC,EAAE,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;CACzE,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AA+DD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,2BAA2B,EACpC,YAAY,EAAE,yBAAyB,GACtC,OAAO,CAAC,MAAM,CAAC,CAgUjB","sourcesContent":["import { missingInstalledSkills } from \"@ebay-dt/bonfire-context\";\nimport nextEnv from \"@next/env\";\nimport {\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n parseHostname,\n type BranchPreparationDiagnostic,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n GitHubCliError,\n LocalPrototypeLifecycle,\n type DependencyInstaller,\n type GitHubCliClientLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { styleText } from \"node:util\";\nimport type { BranchPrepareCommandOptions } from \"./command.js\";\n\nexport type CliEnvironmentLoader = (\n root: string,\n) => Readonly<Record<string, string | undefined>>;\n\nexport type BranchPrepareDependencies = {\n checkMissingInstalledSkills?: typeof missingInstalledSkills;\n environment?: Readonly<Record<string, string | undefined>>;\n loadEnvironment?: CliEnvironmentLoader;\n githubCli?: GitHubCliClientLike;\n createGitHubCli?: (options: { hostname: string }) => GitHubCliClientLike;\n lifecycle?: Pick<PrototypeLifecycle, \"prepareBranch\" | \"prepareDependencies\">;\n installDependencies?: DependencyInstaller;\n regenerateGeneratedContext?: NonNullable<\n PrototypeLifecycle[\"regenerateGeneratedContext\"]\n >;\n untrackGeneratedContext?: PrototypeLifecycle[\"untrackGeneratedContext\"];\n};\n\nexport class BranchPrepareError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"BranchPrepareError\";\n }\n}\n\nconst diagnosticStages: Record<BranchPreparationDiagnostic[\"stage\"], string> = {\n \"checkout-identity-branch\": \"checking out the identity branch\",\n \"configure-identity-upstream\": \"configuring the identity upstream\",\n \"prepare-reconciliation\": \"preparing reconciliation\",\n \"compose-baseline-tree\": \"composing the baseline tree\",\n \"create-baseline-commit\": \"creating the baseline commit\",\n \"apply-platform-patch\": \"applying the platform patch\",\n \"update-identity-ref\": \"updating the identity reference\",\n \"verify-reconciliation\": \"verifying reconciliation\",\n \"rollback-platform-patch\": \"rolling back the platform patch\",\n};\n\nconst diagnosticReasons: Record<BranchPreparationDiagnostic[\"reason\"], string> =\n {\n \"index-locked\": \"the Git index is locked\",\n \"patch-does-not-apply\": \"the patch does not apply\",\n \"identity-missing\": \"Git identity is missing\",\n \"ref-changed\": \"the reference changed\",\n \"permission-denied\": \"permission was denied\",\n \"missing-path-or-object\": \"a path or object is missing\",\n \"worktree-obstruction\": \"the working tree obstructs the operation\",\n \"worktree-changed\": \"the working tree changed\",\n unknown: \"the cause is unknown\",\n };\n\nfunction printDiagnostic(\n label: string,\n diagnostic: BranchPreparationDiagnostic,\n) {\n const ownData = (key: string): unknown => {\n try {\n const descriptor = Object.getOwnPropertyDescriptor(diagnostic, key);\n return descriptor && \"value\" in descriptor ? descriptor.value : undefined;\n } catch {\n return undefined;\n }\n };\n const stageValue = ownData(\"stage\");\n const reasonValue = ownData(\"reason\");\n const exitValue = ownData(\"exitCode\");\n const stage =\n typeof stageValue === \"string\" &&\n Object.hasOwn(diagnosticStages, stageValue)\n ? diagnosticStages[stageValue as BranchPreparationDiagnostic[\"stage\"]]\n : \"an unknown stage\";\n const reason =\n typeof reasonValue === \"string\" &&\n Object.hasOwn(diagnosticReasons, reasonValue)\n ? diagnosticReasons[reasonValue as BranchPreparationDiagnostic[\"reason\"]]\n : diagnosticReasons.unknown;\n const exitCode =\n typeof exitValue === \"number\" && Number.isSafeInteger(exitValue)\n ? ` (exit code ${exitValue})`\n : \"\";\n console.log(`${label}: ${stage}: ${reason}${exitCode}.`);\n}\n\nfunction loadEnvironment(root: string) {\n return nextEnv.loadEnvConfig(root, true, undefined, false).combinedEnv;\n}\n\nexport async function runBranchPrepare(\n options: BranchPrepareCommandOptions,\n dependencies: BranchPrepareDependencies,\n): Promise<number> {\n const root = resolve(options.root);\n const environment =\n dependencies.environment ??\n dependencies.loadEnvironment?.(root) ??\n loadEnvironment(root);\n // This guard must precede marker reads, identity resolution, and all Git\n // collaborators. A direct production invocation must remain read-only even\n // when a previous development install left recovery state behind.\n if (environment.NODE_ENV === \"production\") {\n return 0;\n }\n\n const checkSkills = async () => {\n try {\n const missing = await (\n dependencies.checkMissingInstalledSkills ?? missingInstalledSkills\n )({ repositoryRoot: root });\n if (missing.length)\n console.warn(\n `\n${styleText([\"bold\", \"yellow\"], \"⚠ AGENT SKILLS SETUP NEEDED\", { stream: process.stderr })}\n\nStop the dev server, then run:\n\n pnpm context:install\n\nRestart with pnpm dev.\n`,\n );\n } catch {\n console.warn(\n \"Unable to check installed skills; continuing branch preparation.\",\n );\n }\n };\n\n const generatedLifecycle = () =>\n new LocalPrototypeLifecycle({\n repositoryRoot: root,\n prototypeRoot: options.prototypeRoot ?? environment.BF_PROTOTYPE_ROOT,\n remote: options.remote ?? environment.BF_GIT_REMOTE,\n primaryBranch:\n options.primaryBranch ?? environment.BF_PROTOTYPE_BASE_BRANCH,\n automaticBranchSwitch: parseAutomaticBranchSwitchSetting(\n environment.BF_DISABLE_AUTO_BRANCH_SWITCH,\n ),\n gitMode: parseGitModeSetting(environment.BF_GIT_MODE),\n });\n const ignoredPaths = new Set<string>();\n const configuredRoot =\n options.prototypeRoot ??\n environment.BF_PROTOTYPE_ROOT ??\n \"src/app/(prototypes)\";\n const relativeRoot = relative(root, resolve(root, configuredRoot));\n const safeRoot =\n relativeRoot &&\n relativeRoot !== \"..\" &&\n !relativeRoot.startsWith(`..${sep}`) &&\n !isAbsolute(relativeRoot) &&\n !configuredRoot.split(/[\\\\/]/u).includes(\"..\")\n ? relativeRoot\n .split(sep)\n .join(\"/\")\n .replace(/[\\\\*?[\\] ]/gu, \"\\\\$&\")\n : undefined;\n const regenerate = async () => {\n try {\n const result = await (\n dependencies.regenerateGeneratedContext ??\n (() => generatedLifecycle().regenerateGeneratedContext())\n )();\n if (!result.ok)\n console.warn(\n `Generated context regeneration skipped: ${result.error.code}.`,\n );\n else {\n for (const [reason, paths] of Object.entries(result.value.skipped)) {\n if (reason === \"not ignored\")\n paths.forEach((path) => ignoredPaths.add(path));\n else if (reason !== \"tracked\" && paths.length)\n console.warn(\n `Generated context regeneration skipped (${reason}): ${paths.join(\", \")}.`,\n );\n }\n }\n } catch {\n console.warn(\n \"Generated context regeneration failed; continuing branch preparation.\",\n );\n }\n if (ignoredPaths.size)\n console.warn(\n `Generated context skipped: ${[...ignoredPaths].join(\", \")}. ${\n safeRoot\n ? `Add these .gitignore patterns:\\n${[\"AGENTS.md\", \"CLAUDE.md\", \".claude/settings.json\"].map((file) => `/${safeRoot}/*/*/${file}`).join(\"\\n\")}`\n : \"Check the configured prototype root before adding .gitignore patterns.\"\n }`,\n );\n };\n const untrack = async (\n identity: Parameters<PrototypeLifecycle[\"untrackGeneratedContext\"]>[0],\n ) => {\n try {\n const result = await (\n dependencies.untrackGeneratedContext ??\n ((user) => generatedLifecycle().untrackGeneratedContext(user))\n )(identity);\n if (!result.ok)\n console.warn(\n `Generated context untrack skipped: ${result.error.code}.`,\n );\n else if (result.value.status === \"skipped\") {\n const { reason, paths } = result.value;\n if (\n reason === \"wrong-branch\" ||\n reason === \"HEAD is not the identity branch.\"\n )\n return;\n if (\n reason ===\n \"Generated context is not ignored; add the recommended ignore rules before untracking.\"\n )\n paths.forEach((path) => ignoredPaths.add(path));\n else\n console.warn(\n `Generated context untrack skipped: ${reason}${paths.length ? ` (${paths.join(\", \")})` : \"\"}`,\n );\n }\n } catch {\n console.warn(\n \"Generated context untrack failed; continuing branch preparation.\",\n );\n }\n };\n\n const mode = parseAutomaticBranchSwitchSetting(\n environment.BF_DISABLE_AUTO_BRANCH_SWITCH,\n );\n const gitMode = parseGitModeSetting(environment.BF_GIT_MODE);\n\n if (gitMode === \"manual\") {\n console.log(\"Git management is in manual mode.\");\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n if (mode === \"disabled\") {\n console.log(\"Automatic branch switching is disabled.\");\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n // Explicit --hostname wins. Generated scripts use --default-hostname so\n // Next-compatible .env.local loading can supply BF_GITHUB_HOSTNAME first.\n const hostname = parseHostname(\n options.hostname ??\n environment.BF_GITHUB_HOSTNAME ??\n options.defaultHostname,\n );\n const lifecycle =\n dependencies.lifecycle ??\n new LocalPrototypeLifecycle({\n repositoryRoot: root,\n prototypeRoot: options.prototypeRoot ?? environment.BF_PROTOTYPE_ROOT,\n remote: options.remote ?? environment.BF_GIT_REMOTE,\n primaryBranch:\n options.primaryBranch ?? environment.BF_PROTOTYPE_BASE_BRANCH,\n automaticBranchSwitch: mode,\n gitMode,\n installDependencies: dependencies.installDependencies,\n });\n const prepareDependencies = lifecycle.prepareDependencies;\n if (prepareDependencies !== undefined) {\n console.log(\"Checking pending dependency preparation...\");\n const pending = await prepareDependencies.call(\n lifecycle,\n [],\n dependencies.installDependencies,\n );\n if (!pending.ok) {\n throw new BranchPrepareError(\"Unable to prepare project dependencies.\");\n }\n if (pending.value.status === \"failed\") {\n throw new BranchPrepareError(\n \"Dependency preparation failed; the development server was not started.\",\n );\n }\n if (pending.value.status === \"prepared\") {\n console.log(\"Pending project dependencies prepared.\");\n }\n }\n\n const githubCli =\n dependencies.githubCli ??\n dependencies.createGitHubCli?.({ hostname }) ??\n new GitHubCliClient({ hostname });\n let identity;\n try {\n identity = await githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n (error.reason === \"missing\" || error.reason === \"unauthenticated\")\n ) {\n console.log(\n \"Branch preparation deferred; GitHub CLI authentication is not available.\",\n );\n await regenerate();\n await checkSkills();\n return 0;\n }\n throw new BranchPrepareError(\"Unable to resolve GitHub CLI identity.\");\n }\n\n console.log(\"Synchronizing project platform...\");\n const result = await lifecycle.prepareBranch(identity);\n if (!result.ok) {\n throw new BranchPrepareError(\n `Branch preparation failed with ${result.error.code}.`,\n );\n }\n\n if (result.value.status === \"deferred\") {\n console.log(\n result.value.reason === \"dirty-worktree\"\n ? \"Branch preparation deferred: uncommitted changes outside the prototype folder; platform updates were not applied.\"\n : `Branch preparation deferred; repository attention: ${result.value.reason}.`,\n );\n // A dirty/offline check that made no changes is safe to leave for the\n // existing environment. Never launch after a partially applied update.\n if (\n result.value.effects.changed ||\n result.value.effects.pushed ||\n result.value.effects.reconciledPaths.length > 0 ||\n (result.value.effects.platformPaths?.length ?? 0) > 0 ||\n (result.value.effects.dependencyPaths?.length ?? 0) > 0 ||\n result.value.effects.preparationRequired === true ||\n result.value.effects.restartRequired\n ) {\n throw new BranchPrepareError(\n \"Branch preparation was only partially completed; the development server was not started.\",\n );\n }\n await regenerate();\n await checkSkills();\n return 0;\n }\n if (result.value.status === \"unsafe\") {\n console.log(\n `Branch preparation requires repository attention (${result.value.reason}).`,\n );\n if (result.value.diagnostic)\n printDiagnostic(\"Branch preparation diagnostic\", result.value.diagnostic);\n if (result.value.rollbackDiagnostic)\n printDiagnostic(\n \"Branch preparation rollback diagnostic\",\n result.value.rollbackDiagnostic,\n );\n const effects = result.value.effects;\n const actualContentTransition =\n effects.reconciledPaths.length > 0 ||\n (effects.platformPaths?.length ?? 0) > 0 ||\n (effects.dependencyPaths?.length ?? 0) > 0 ||\n effects.preparationRequired === true ||\n effects.restartRequired;\n // History-only checkpoints and other no-effect safety refusals do not\n // justify taking down startup. A partial checkout/platform/dependency\n // transition still does: the existing environment must not run against\n // an unsafe working tree.\n if (!actualContentTransition) {\n await regenerate();\n await checkSkills();\n return 0;\n }\n throw new BranchPrepareError(\n \"Branch preparation was only partially completed; the development server was not started.\",\n );\n }\n if (result.value.status === \"disabled\") {\n console.log(\n \"Branch preparation skipped; synchronization is disabled by configuration.\",\n );\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n await untrack(identity);\n await regenerate();\n\n const dependencyPaths = result.value.effects.dependencyPaths ?? [];\n const managedPathChanged =\n dependencyPaths.length > 0 ||\n result.value.effects.preparationRequired === true;\n if (managedPathChanged) {\n console.log(\"Installing updated project dependencies...\");\n if (prepareDependencies !== undefined) {\n const preparation = await prepareDependencies.call(\n lifecycle,\n dependencyPaths,\n dependencies.installDependencies,\n );\n if (!preparation.ok || preparation.value.status === \"failed\") {\n throw new BranchPrepareError(\n \"Dependency preparation failed; the development server was not started.\",\n );\n }\n } else {\n throw new BranchPrepareError(\n \"This lifecycle does not support dependency preparation; the development server was not started.\",\n );\n }\n }\n\n await checkSkills();\n console.log(\"Branch preparation complete.\");\n return 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"branch-prepare.d.ts","sourceRoot":"","sources":["../src/branch-prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAQlE,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAEhE,MAAM,MAAM,oBAAoB,GAAG,CACjC,IAAI,EAAE,MAAM,KACT,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAElD,MAAM,MAAM,yBAAyB,GAAG;IACtC,2BAA2B,CAAC,EAAE,OAAO,sBAAsB,CAAC;IAC5D,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,mBAAmB,CAAC;IACzE,SAAS,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,eAAe,GAAG,qBAAqB,CAAC,CAAC;IAC9E,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,0BAA0B,CAAC,EAAE,WAAW,CACtC,kBAAkB,CAAC,4BAA4B,CAAC,CACjD,CAAC;IACF,uBAAuB,CAAC,EAAE,kBAAkB,CAAC,yBAAyB,CAAC,CAAC;CACzE,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AA+DD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,2BAA2B,EACpC,YAAY,EAAE,yBAAyB,GACtC,OAAO,CAAC,MAAM,CAAC,CAmUjB","sourcesContent":["import { missingInstalledSkills } from \"@ebay-dt/bonfire-context\";\nimport nextEnv from \"@next/env\";\nimport {\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n parseHostname,\n type BranchPreparationDiagnostic,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n GitHubCliError,\n LocalPrototypeLifecycle,\n type DependencyInstaller,\n type GitHubCliClientLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { styleText } from \"node:util\";\nimport type { BranchPrepareCommandOptions } from \"./command.js\";\n\nexport type CliEnvironmentLoader = (\n root: string,\n) => Readonly<Record<string, string | undefined>>;\n\nexport type BranchPrepareDependencies = {\n checkMissingInstalledSkills?: typeof missingInstalledSkills;\n environment?: Readonly<Record<string, string | undefined>>;\n loadEnvironment?: CliEnvironmentLoader;\n githubCli?: GitHubCliClientLike;\n createGitHubCli?: (options: { hostname: string }) => GitHubCliClientLike;\n lifecycle?: Pick<PrototypeLifecycle, \"prepareBranch\" | \"prepareDependencies\">;\n installDependencies?: DependencyInstaller;\n regenerateGeneratedContext?: NonNullable<\n PrototypeLifecycle[\"regenerateGeneratedContext\"]\n >;\n untrackGeneratedContext?: PrototypeLifecycle[\"untrackGeneratedContext\"];\n};\n\nexport class BranchPrepareError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"BranchPrepareError\";\n }\n}\n\nconst diagnosticStages: Record<BranchPreparationDiagnostic[\"stage\"], string> = {\n \"checkout-identity-branch\": \"checking out the identity branch\",\n \"configure-identity-upstream\": \"configuring the identity upstream\",\n \"prepare-reconciliation\": \"preparing reconciliation\",\n \"compose-baseline-tree\": \"composing the baseline tree\",\n \"create-baseline-commit\": \"creating the baseline commit\",\n \"apply-platform-patch\": \"applying the platform patch\",\n \"update-identity-ref\": \"updating the identity reference\",\n \"verify-reconciliation\": \"verifying reconciliation\",\n \"rollback-platform-patch\": \"rolling back the platform patch\",\n};\n\nconst diagnosticReasons: Record<BranchPreparationDiagnostic[\"reason\"], string> =\n {\n \"index-locked\": \"the Git index is locked\",\n \"patch-does-not-apply\": \"the patch does not apply\",\n \"identity-missing\": \"Git identity is missing\",\n \"ref-changed\": \"the reference changed\",\n \"permission-denied\": \"permission was denied\",\n \"missing-path-or-object\": \"a path or object is missing\",\n \"worktree-obstruction\": \"the working tree obstructs the operation\",\n \"worktree-changed\": \"the working tree changed\",\n unknown: \"the cause is unknown\",\n };\n\nfunction printDiagnostic(\n label: string,\n diagnostic: BranchPreparationDiagnostic,\n) {\n const ownData = (key: string): unknown => {\n try {\n const descriptor = Object.getOwnPropertyDescriptor(diagnostic, key);\n return descriptor && \"value\" in descriptor ? descriptor.value : undefined;\n } catch {\n return undefined;\n }\n };\n const stageValue = ownData(\"stage\");\n const reasonValue = ownData(\"reason\");\n const exitValue = ownData(\"exitCode\");\n const stage =\n typeof stageValue === \"string\" &&\n Object.hasOwn(diagnosticStages, stageValue)\n ? diagnosticStages[stageValue as BranchPreparationDiagnostic[\"stage\"]]\n : \"an unknown stage\";\n const reason =\n typeof reasonValue === \"string\" &&\n Object.hasOwn(diagnosticReasons, reasonValue)\n ? diagnosticReasons[reasonValue as BranchPreparationDiagnostic[\"reason\"]]\n : diagnosticReasons.unknown;\n const exitCode =\n typeof exitValue === \"number\" && Number.isSafeInteger(exitValue)\n ? ` (exit code ${exitValue})`\n : \"\";\n console.log(`${label}: ${stage}: ${reason}${exitCode}.`);\n}\n\nfunction loadEnvironment(root: string) {\n return nextEnv.loadEnvConfig(root, true, undefined, false).combinedEnv;\n}\n\nexport async function runBranchPrepare(\n options: BranchPrepareCommandOptions,\n dependencies: BranchPrepareDependencies,\n): Promise<number> {\n const root = resolve(options.root);\n const environment =\n dependencies.environment ??\n dependencies.loadEnvironment?.(root) ??\n loadEnvironment(root);\n // This guard must precede marker reads, identity resolution, and all Git\n // collaborators. A direct production invocation must remain read-only even\n // when a previous development install left recovery state behind.\n if (environment.NODE_ENV === \"production\") {\n return 0;\n }\n\n const checkSkills = async () => {\n try {\n const missing = await (\n dependencies.checkMissingInstalledSkills ?? missingInstalledSkills\n )({ repositoryRoot: root });\n if (missing.length)\n console.warn(\n `\n${styleText([\"bold\", \"yellow\"], \"⚠ AGENT SKILLS SETUP NEEDED\", { stream: process.stderr })}\n\nStop the dev server, then run:\n\n pnpm context:install\n\nRestart with pnpm dev.\n`,\n );\n } catch {\n console.warn(\n \"Unable to check installed skills; continuing branch preparation.\",\n );\n }\n };\n\n const generatedLifecycle = () =>\n new LocalPrototypeLifecycle({\n repositoryRoot: root,\n prototypeRoot: options.prototypeRoot ?? environment.BF_PROTOTYPE_ROOT,\n remote: options.remote ?? environment.BF_GIT_REMOTE,\n primaryBranch:\n options.primaryBranch ?? environment.BF_PROTOTYPE_BASE_BRANCH,\n automaticBranchSwitch: parseAutomaticBranchSwitchSetting(\n environment.BF_DISABLE_AUTO_BRANCH_SWITCH,\n ),\n gitMode: parseGitModeSetting(environment.BF_GIT_MODE),\n });\n const ignoredPaths = new Set<string>();\n const configuredRoot =\n options.prototypeRoot ??\n environment.BF_PROTOTYPE_ROOT ??\n \"src/app/(prototypes)\";\n const relativeRoot = relative(root, resolve(root, configuredRoot));\n const safeRoot =\n relativeRoot &&\n relativeRoot !== \"..\" &&\n !relativeRoot.startsWith(`..${sep}`) &&\n !isAbsolute(relativeRoot) &&\n !configuredRoot.split(/[\\\\/]/u).includes(\"..\")\n ? relativeRoot\n .split(sep)\n .join(\"/\")\n .replace(/[\\\\*?[\\] ]/gu, \"\\\\$&\")\n : undefined;\n const regenerate = async () => {\n try {\n const result = await (\n dependencies.regenerateGeneratedContext ??\n (() => generatedLifecycle().regenerateGeneratedContext())\n )();\n if (!result.ok)\n console.warn(\n \"diagnostic\" in result &&\n result.diagnostic === \"missing-prototype-context-source\"\n ? \"Generated context regeneration skipped: required context source context/PROTOTYPE.md is missing or unreadable.\"\n : `Generated context regeneration skipped: ${result.error.code}.`,\n );\n else {\n for (const [reason, paths] of Object.entries(result.value.skipped)) {\n if (reason === \"not ignored\")\n paths.forEach((path) => ignoredPaths.add(path));\n else if (reason !== \"tracked\" && paths.length)\n console.warn(\n `Generated context regeneration skipped (${reason}): ${paths.join(\", \")}.`,\n );\n }\n }\n } catch {\n console.warn(\n \"Generated context regeneration failed; continuing branch preparation.\",\n );\n }\n if (ignoredPaths.size)\n console.warn(\n `Generated context skipped: ${[...ignoredPaths].join(\", \")}. ${\n safeRoot\n ? `Add these .gitignore patterns:\\n${[\"AGENTS.md\", \"CLAUDE.md\", \".claude/settings.json\"].map((file) => `/${safeRoot}/*/*/${file}`).join(\"\\n\")}`\n : \"Check the configured prototype root before adding .gitignore patterns.\"\n }`,\n );\n };\n const untrack = async (\n identity: Parameters<PrototypeLifecycle[\"untrackGeneratedContext\"]>[0],\n ) => {\n try {\n const result = await (\n dependencies.untrackGeneratedContext ??\n ((user) => generatedLifecycle().untrackGeneratedContext(user))\n )(identity);\n if (!result.ok)\n console.warn(\n `Generated context untrack skipped: ${result.error.code}.`,\n );\n else if (result.value.status === \"skipped\") {\n const { reason, paths } = result.value;\n if (\n reason === \"wrong-branch\" ||\n reason === \"HEAD is not the identity branch.\"\n )\n return;\n if (\n reason ===\n \"Generated context is not ignored; add the recommended ignore rules before untracking.\"\n )\n paths.forEach((path) => ignoredPaths.add(path));\n else\n console.warn(\n `Generated context untrack skipped: ${reason}${paths.length ? ` (${paths.join(\", \")})` : \"\"}`,\n );\n }\n } catch {\n console.warn(\n \"Generated context untrack failed; continuing branch preparation.\",\n );\n }\n };\n\n const mode = parseAutomaticBranchSwitchSetting(\n environment.BF_DISABLE_AUTO_BRANCH_SWITCH,\n );\n const gitMode = parseGitModeSetting(environment.BF_GIT_MODE);\n\n if (gitMode === \"manual\") {\n console.log(\"Git management is in manual mode.\");\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n if (mode === \"disabled\") {\n console.log(\"Automatic branch switching is disabled.\");\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n // Explicit --hostname wins. Generated scripts use --default-hostname so\n // Next-compatible .env.local loading can supply BF_GITHUB_HOSTNAME first.\n const hostname = parseHostname(\n options.hostname ??\n environment.BF_GITHUB_HOSTNAME ??\n options.defaultHostname,\n );\n const lifecycle =\n dependencies.lifecycle ??\n new LocalPrototypeLifecycle({\n repositoryRoot: root,\n prototypeRoot: options.prototypeRoot ?? environment.BF_PROTOTYPE_ROOT,\n remote: options.remote ?? environment.BF_GIT_REMOTE,\n primaryBranch:\n options.primaryBranch ?? environment.BF_PROTOTYPE_BASE_BRANCH,\n automaticBranchSwitch: mode,\n gitMode,\n installDependencies: dependencies.installDependencies,\n });\n const prepareDependencies = lifecycle.prepareDependencies;\n if (prepareDependencies !== undefined) {\n console.log(\"Checking pending dependency preparation...\");\n const pending = await prepareDependencies.call(\n lifecycle,\n [],\n dependencies.installDependencies,\n );\n if (!pending.ok) {\n throw new BranchPrepareError(\"Unable to prepare project dependencies.\");\n }\n if (pending.value.status === \"failed\") {\n throw new BranchPrepareError(\n \"Dependency preparation failed; the development server was not started.\",\n );\n }\n if (pending.value.status === \"prepared\") {\n console.log(\"Pending project dependencies prepared.\");\n }\n }\n\n const githubCli =\n dependencies.githubCli ??\n dependencies.createGitHubCli?.({ hostname }) ??\n new GitHubCliClient({ hostname });\n let identity;\n try {\n identity = await githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n (error.reason === \"missing\" || error.reason === \"unauthenticated\")\n ) {\n console.log(\n \"Branch preparation deferred; GitHub CLI authentication is not available.\",\n );\n await regenerate();\n await checkSkills();\n return 0;\n }\n throw new BranchPrepareError(\"Unable to resolve GitHub CLI identity.\");\n }\n\n console.log(\"Synchronizing project platform...\");\n const result = await lifecycle.prepareBranch(identity);\n if (!result.ok) {\n throw new BranchPrepareError(\n `Branch preparation failed with ${result.error.code}.`,\n );\n }\n\n if (result.value.status === \"deferred\") {\n console.log(\n result.value.reason === \"dirty-worktree\"\n ? \"Branch preparation deferred: uncommitted changes outside the prototype folder; platform updates were not applied.\"\n : `Branch preparation deferred; repository attention: ${result.value.reason}.`,\n );\n // A dirty/offline check that made no changes is safe to leave for the\n // existing environment. Never launch after a partially applied update.\n if (\n result.value.effects.changed ||\n result.value.effects.pushed ||\n result.value.effects.reconciledPaths.length > 0 ||\n (result.value.effects.platformPaths?.length ?? 0) > 0 ||\n (result.value.effects.dependencyPaths?.length ?? 0) > 0 ||\n result.value.effects.preparationRequired === true ||\n result.value.effects.restartRequired\n ) {\n throw new BranchPrepareError(\n \"Branch preparation was only partially completed; the development server was not started.\",\n );\n }\n await regenerate();\n await checkSkills();\n return 0;\n }\n if (result.value.status === \"unsafe\") {\n console.log(\n `Branch preparation requires repository attention (${result.value.reason}).`,\n );\n if (result.value.diagnostic)\n printDiagnostic(\"Branch preparation diagnostic\", result.value.diagnostic);\n if (result.value.rollbackDiagnostic)\n printDiagnostic(\n \"Branch preparation rollback diagnostic\",\n result.value.rollbackDiagnostic,\n );\n const effects = result.value.effects;\n const actualContentTransition =\n effects.reconciledPaths.length > 0 ||\n (effects.platformPaths?.length ?? 0) > 0 ||\n (effects.dependencyPaths?.length ?? 0) > 0 ||\n effects.preparationRequired === true ||\n effects.restartRequired;\n // History-only checkpoints and other no-effect safety refusals do not\n // justify taking down startup. A partial checkout/platform/dependency\n // transition still does: the existing environment must not run against\n // an unsafe working tree.\n if (!actualContentTransition) {\n await regenerate();\n await checkSkills();\n return 0;\n }\n throw new BranchPrepareError(\n \"Branch preparation was only partially completed; the development server was not started.\",\n );\n }\n if (result.value.status === \"disabled\") {\n console.log(\n \"Branch preparation skipped; synchronization is disabled by configuration.\",\n );\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n await untrack(identity);\n await regenerate();\n\n const dependencyPaths = result.value.effects.dependencyPaths ?? [];\n const managedPathChanged =\n dependencyPaths.length > 0 ||\n result.value.effects.preparationRequired === true;\n if (managedPathChanged) {\n console.log(\"Installing updated project dependencies...\");\n if (prepareDependencies !== undefined) {\n const preparation = await prepareDependencies.call(\n lifecycle,\n dependencyPaths,\n dependencies.installDependencies,\n );\n if (!preparation.ok || preparation.value.status === \"failed\") {\n throw new BranchPrepareError(\n \"Dependency preparation failed; the development server was not started.\",\n );\n }\n } else {\n throw new BranchPrepareError(\n \"This lifecycle does not support dependency preparation; the development server was not started.\",\n );\n }\n }\n\n await checkSkills();\n console.log(\"Branch preparation complete.\");\n return 0;\n}\n"]}
|
package/dist/branch-prepare.js
CHANGED
|
@@ -118,7 +118,10 @@ Restart with pnpm dev.
|
|
|
118
118
|
const result = await (dependencies.regenerateGeneratedContext ??
|
|
119
119
|
(() => generatedLifecycle().regenerateGeneratedContext()))();
|
|
120
120
|
if (!result.ok)
|
|
121
|
-
console.warn(
|
|
121
|
+
console.warn("diagnostic" in result &&
|
|
122
|
+
result.diagnostic === "missing-prototype-context-source"
|
|
123
|
+
? "Generated context regeneration skipped: required context source context/PROTOTYPE.md is missing or unreadable."
|
|
124
|
+
: `Generated context regeneration skipped: ${result.error.code}.`);
|
|
122
125
|
else {
|
|
123
126
|
for (const [reason, paths] of Object.entries(result.value.skipped)) {
|
|
124
127
|
if (reason === "not ignored")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-prepare.js","sourceRoot":"","sources":["../src/branch-prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,EACL,iCAAiC,EACjC,mBAAmB,EACnB,aAAa,GAEd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,GAIxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAqBtC,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,gBAAgB,GAAyD;IAC7E,0BAA0B,EAAE,kCAAkC;IAC9D,6BAA6B,EAAE,mCAAmC;IAClE,wBAAwB,EAAE,0BAA0B;IACpD,uBAAuB,EAAE,6BAA6B;IACtD,wBAAwB,EAAE,8BAA8B;IACxD,sBAAsB,EAAE,6BAA6B;IACrD,qBAAqB,EAAE,iCAAiC;IACxD,uBAAuB,EAAE,0BAA0B;IACnD,yBAAyB,EAAE,iCAAiC;CAC7D,CAAC;AAEF,MAAM,iBAAiB,GACrB;IACE,cAAc,EAAE,yBAAyB;IACzC,sBAAsB,EAAE,0BAA0B;IAClD,kBAAkB,EAAE,yBAAyB;IAC7C,aAAa,EAAE,uBAAuB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1B,wEAAwE,CACzE,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,kBAAkB,CAC1B,iGAAiG,CAClG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,WAAW,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAC5C,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["import { missingInstalledSkills } from \"@ebay-dt/bonfire-context\";\nimport nextEnv from \"@next/env\";\nimport {\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n parseHostname,\n type BranchPreparationDiagnostic,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n GitHubCliError,\n LocalPrototypeLifecycle,\n type DependencyInstaller,\n type GitHubCliClientLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { styleText } from \"node:util\";\nimport type { BranchPrepareCommandOptions } from \"./command.js\";\n\nexport type CliEnvironmentLoader = (\n root: string,\n) => Readonly<Record<string, string | undefined>>;\n\nexport type BranchPrepareDependencies = {\n checkMissingInstalledSkills?: typeof missingInstalledSkills;\n environment?: Readonly<Record<string, string | undefined>>;\n loadEnvironment?: CliEnvironmentLoader;\n githubCli?: GitHubCliClientLike;\n createGitHubCli?: (options: { hostname: string }) => GitHubCliClientLike;\n lifecycle?: Pick<PrototypeLifecycle, \"prepareBranch\" | \"prepareDependencies\">;\n installDependencies?: DependencyInstaller;\n regenerateGeneratedContext?: NonNullable<\n PrototypeLifecycle[\"regenerateGeneratedContext\"]\n >;\n untrackGeneratedContext?: PrototypeLifecycle[\"untrackGeneratedContext\"];\n};\n\nexport class BranchPrepareError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"BranchPrepareError\";\n }\n}\n\nconst diagnosticStages: Record<BranchPreparationDiagnostic[\"stage\"], string> = {\n \"checkout-identity-branch\": \"checking out the identity branch\",\n \"configure-identity-upstream\": \"configuring the identity upstream\",\n \"prepare-reconciliation\": \"preparing reconciliation\",\n \"compose-baseline-tree\": \"composing the baseline tree\",\n \"create-baseline-commit\": \"creating the baseline commit\",\n \"apply-platform-patch\": \"applying the platform patch\",\n \"update-identity-ref\": \"updating the identity reference\",\n \"verify-reconciliation\": \"verifying reconciliation\",\n \"rollback-platform-patch\": \"rolling back the platform patch\",\n};\n\nconst diagnosticReasons: Record<BranchPreparationDiagnostic[\"reason\"], string> =\n {\n \"index-locked\": \"the Git index is locked\",\n \"patch-does-not-apply\": \"the patch does not apply\",\n \"identity-missing\": \"Git identity is missing\",\n \"ref-changed\": \"the reference changed\",\n \"permission-denied\": \"permission was denied\",\n \"missing-path-or-object\": \"a path or object is missing\",\n \"worktree-obstruction\": \"the working tree obstructs the operation\",\n \"worktree-changed\": \"the working tree changed\",\n unknown: \"the cause is unknown\",\n };\n\nfunction printDiagnostic(\n label: string,\n diagnostic: BranchPreparationDiagnostic,\n) {\n const ownData = (key: string): unknown => {\n try {\n const descriptor = Object.getOwnPropertyDescriptor(diagnostic, key);\n return descriptor && \"value\" in descriptor ? descriptor.value : undefined;\n } catch {\n return undefined;\n }\n };\n const stageValue = ownData(\"stage\");\n const reasonValue = ownData(\"reason\");\n const exitValue = ownData(\"exitCode\");\n const stage =\n typeof stageValue === \"string\" &&\n Object.hasOwn(diagnosticStages, stageValue)\n ? diagnosticStages[stageValue as BranchPreparationDiagnostic[\"stage\"]]\n : \"an unknown stage\";\n const reason =\n typeof reasonValue === \"string\" &&\n Object.hasOwn(diagnosticReasons, reasonValue)\n ? diagnosticReasons[reasonValue as BranchPreparationDiagnostic[\"reason\"]]\n : diagnosticReasons.unknown;\n const exitCode =\n typeof exitValue === \"number\" && Number.isSafeInteger(exitValue)\n ? ` (exit code ${exitValue})`\n : \"\";\n console.log(`${label}: ${stage}: ${reason}${exitCode}.`);\n}\n\nfunction loadEnvironment(root: string) {\n return nextEnv.loadEnvConfig(root, true, undefined, false).combinedEnv;\n}\n\nexport async function runBranchPrepare(\n options: BranchPrepareCommandOptions,\n dependencies: BranchPrepareDependencies,\n): Promise<number> {\n const root = resolve(options.root);\n const environment =\n dependencies.environment ??\n dependencies.loadEnvironment?.(root) ??\n loadEnvironment(root);\n // This guard must precede marker reads, identity resolution, and all Git\n // collaborators. A direct production invocation must remain read-only even\n // when a previous development install left recovery state behind.\n if (environment.NODE_ENV === \"production\") {\n return 0;\n }\n\n const checkSkills = async () => {\n try {\n const missing = await (\n dependencies.checkMissingInstalledSkills ?? missingInstalledSkills\n )({ repositoryRoot: root });\n if (missing.length)\n console.warn(\n `\n${styleText([\"bold\", \"yellow\"], \"⚠ AGENT SKILLS SETUP NEEDED\", { stream: process.stderr })}\n\nStop the dev server, then run:\n\n pnpm context:install\n\nRestart with pnpm dev.\n`,\n );\n } catch {\n console.warn(\n \"Unable to check installed skills; continuing branch preparation.\",\n );\n }\n };\n\n const generatedLifecycle = () =>\n new LocalPrototypeLifecycle({\n repositoryRoot: root,\n prototypeRoot: options.prototypeRoot ?? environment.BF_PROTOTYPE_ROOT,\n remote: options.remote ?? environment.BF_GIT_REMOTE,\n primaryBranch:\n options.primaryBranch ?? environment.BF_PROTOTYPE_BASE_BRANCH,\n automaticBranchSwitch: parseAutomaticBranchSwitchSetting(\n environment.BF_DISABLE_AUTO_BRANCH_SWITCH,\n ),\n gitMode: parseGitModeSetting(environment.BF_GIT_MODE),\n });\n const ignoredPaths = new Set<string>();\n const configuredRoot =\n options.prototypeRoot ??\n environment.BF_PROTOTYPE_ROOT ??\n \"src/app/(prototypes)\";\n const relativeRoot = relative(root, resolve(root, configuredRoot));\n const safeRoot =\n relativeRoot &&\n relativeRoot !== \"..\" &&\n !relativeRoot.startsWith(`..${sep}`) &&\n !isAbsolute(relativeRoot) &&\n !configuredRoot.split(/[\\\\/]/u).includes(\"..\")\n ? relativeRoot\n .split(sep)\n .join(\"/\")\n .replace(/[\\\\*?[\\] ]/gu, \"\\\\$&\")\n : undefined;\n const regenerate = async () => {\n try {\n const result = await (\n dependencies.regenerateGeneratedContext ??\n (() => generatedLifecycle().regenerateGeneratedContext())\n )();\n if (!result.ok)\n console.warn(\n `Generated context regeneration skipped: ${result.error.code}.`,\n );\n else {\n for (const [reason, paths] of Object.entries(result.value.skipped)) {\n if (reason === \"not ignored\")\n paths.forEach((path) => ignoredPaths.add(path));\n else if (reason !== \"tracked\" && paths.length)\n console.warn(\n `Generated context regeneration skipped (${reason}): ${paths.join(\", \")}.`,\n );\n }\n }\n } catch {\n console.warn(\n \"Generated context regeneration failed; continuing branch preparation.\",\n );\n }\n if (ignoredPaths.size)\n console.warn(\n `Generated context skipped: ${[...ignoredPaths].join(\", \")}. ${\n safeRoot\n ? `Add these .gitignore patterns:\\n${[\"AGENTS.md\", \"CLAUDE.md\", \".claude/settings.json\"].map((file) => `/${safeRoot}/*/*/${file}`).join(\"\\n\")}`\n : \"Check the configured prototype root before adding .gitignore patterns.\"\n }`,\n );\n };\n const untrack = async (\n identity: Parameters<PrototypeLifecycle[\"untrackGeneratedContext\"]>[0],\n ) => {\n try {\n const result = await (\n dependencies.untrackGeneratedContext ??\n ((user) => generatedLifecycle().untrackGeneratedContext(user))\n )(identity);\n if (!result.ok)\n console.warn(\n `Generated context untrack skipped: ${result.error.code}.`,\n );\n else if (result.value.status === \"skipped\") {\n const { reason, paths } = result.value;\n if (\n reason === \"wrong-branch\" ||\n reason === \"HEAD is not the identity branch.\"\n )\n return;\n if (\n reason ===\n \"Generated context is not ignored; add the recommended ignore rules before untracking.\"\n )\n paths.forEach((path) => ignoredPaths.add(path));\n else\n console.warn(\n `Generated context untrack skipped: ${reason}${paths.length ? ` (${paths.join(\", \")})` : \"\"}`,\n );\n }\n } catch {\n console.warn(\n \"Generated context untrack failed; continuing branch preparation.\",\n );\n }\n };\n\n const mode = parseAutomaticBranchSwitchSetting(\n environment.BF_DISABLE_AUTO_BRANCH_SWITCH,\n );\n const gitMode = parseGitModeSetting(environment.BF_GIT_MODE);\n\n if (gitMode === \"manual\") {\n console.log(\"Git management is in manual mode.\");\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n if (mode === \"disabled\") {\n console.log(\"Automatic branch switching is disabled.\");\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n // Explicit --hostname wins. Generated scripts use --default-hostname so\n // Next-compatible .env.local loading can supply BF_GITHUB_HOSTNAME first.\n const hostname = parseHostname(\n options.hostname ??\n environment.BF_GITHUB_HOSTNAME ??\n options.defaultHostname,\n );\n const lifecycle =\n dependencies.lifecycle ??\n new LocalPrototypeLifecycle({\n repositoryRoot: root,\n prototypeRoot: options.prototypeRoot ?? environment.BF_PROTOTYPE_ROOT,\n remote: options.remote ?? environment.BF_GIT_REMOTE,\n primaryBranch:\n options.primaryBranch ?? environment.BF_PROTOTYPE_BASE_BRANCH,\n automaticBranchSwitch: mode,\n gitMode,\n installDependencies: dependencies.installDependencies,\n });\n const prepareDependencies = lifecycle.prepareDependencies;\n if (prepareDependencies !== undefined) {\n console.log(\"Checking pending dependency preparation...\");\n const pending = await prepareDependencies.call(\n lifecycle,\n [],\n dependencies.installDependencies,\n );\n if (!pending.ok) {\n throw new BranchPrepareError(\"Unable to prepare project dependencies.\");\n }\n if (pending.value.status === \"failed\") {\n throw new BranchPrepareError(\n \"Dependency preparation failed; the development server was not started.\",\n );\n }\n if (pending.value.status === \"prepared\") {\n console.log(\"Pending project dependencies prepared.\");\n }\n }\n\n const githubCli =\n dependencies.githubCli ??\n dependencies.createGitHubCli?.({ hostname }) ??\n new GitHubCliClient({ hostname });\n let identity;\n try {\n identity = await githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n (error.reason === \"missing\" || error.reason === \"unauthenticated\")\n ) {\n console.log(\n \"Branch preparation deferred; GitHub CLI authentication is not available.\",\n );\n await regenerate();\n await checkSkills();\n return 0;\n }\n throw new BranchPrepareError(\"Unable to resolve GitHub CLI identity.\");\n }\n\n console.log(\"Synchronizing project platform...\");\n const result = await lifecycle.prepareBranch(identity);\n if (!result.ok) {\n throw new BranchPrepareError(\n `Branch preparation failed with ${result.error.code}.`,\n );\n }\n\n if (result.value.status === \"deferred\") {\n console.log(\n result.value.reason === \"dirty-worktree\"\n ? \"Branch preparation deferred: uncommitted changes outside the prototype folder; platform updates were not applied.\"\n : `Branch preparation deferred; repository attention: ${result.value.reason}.`,\n );\n // A dirty/offline check that made no changes is safe to leave for the\n // existing environment. Never launch after a partially applied update.\n if (\n result.value.effects.changed ||\n result.value.effects.pushed ||\n result.value.effects.reconciledPaths.length > 0 ||\n (result.value.effects.platformPaths?.length ?? 0) > 0 ||\n (result.value.effects.dependencyPaths?.length ?? 0) > 0 ||\n result.value.effects.preparationRequired === true ||\n result.value.effects.restartRequired\n ) {\n throw new BranchPrepareError(\n \"Branch preparation was only partially completed; the development server was not started.\",\n );\n }\n await regenerate();\n await checkSkills();\n return 0;\n }\n if (result.value.status === \"unsafe\") {\n console.log(\n `Branch preparation requires repository attention (${result.value.reason}).`,\n );\n if (result.value.diagnostic)\n printDiagnostic(\"Branch preparation diagnostic\", result.value.diagnostic);\n if (result.value.rollbackDiagnostic)\n printDiagnostic(\n \"Branch preparation rollback diagnostic\",\n result.value.rollbackDiagnostic,\n );\n const effects = result.value.effects;\n const actualContentTransition =\n effects.reconciledPaths.length > 0 ||\n (effects.platformPaths?.length ?? 0) > 0 ||\n (effects.dependencyPaths?.length ?? 0) > 0 ||\n effects.preparationRequired === true ||\n effects.restartRequired;\n // History-only checkpoints and other no-effect safety refusals do not\n // justify taking down startup. A partial checkout/platform/dependency\n // transition still does: the existing environment must not run against\n // an unsafe working tree.\n if (!actualContentTransition) {\n await regenerate();\n await checkSkills();\n return 0;\n }\n throw new BranchPrepareError(\n \"Branch preparation was only partially completed; the development server was not started.\",\n );\n }\n if (result.value.status === \"disabled\") {\n console.log(\n \"Branch preparation skipped; synchronization is disabled by configuration.\",\n );\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n await untrack(identity);\n await regenerate();\n\n const dependencyPaths = result.value.effects.dependencyPaths ?? [];\n const managedPathChanged =\n dependencyPaths.length > 0 ||\n result.value.effects.preparationRequired === true;\n if (managedPathChanged) {\n console.log(\"Installing updated project dependencies...\");\n if (prepareDependencies !== undefined) {\n const preparation = await prepareDependencies.call(\n lifecycle,\n dependencyPaths,\n dependencies.installDependencies,\n );\n if (!preparation.ok || preparation.value.status === \"failed\") {\n throw new BranchPrepareError(\n \"Dependency preparation failed; the development server was not started.\",\n );\n }\n } else {\n throw new BranchPrepareError(\n \"This lifecycle does not support dependency preparation; the development server was not started.\",\n );\n }\n }\n\n await checkSkills();\n console.log(\"Branch preparation complete.\");\n return 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"branch-prepare.js","sourceRoot":"","sources":["../src/branch-prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,EACL,iCAAiC,EACjC,mBAAmB,EACnB,aAAa,GAEd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,GAIxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAqBtC,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,gBAAgB,GAAyD;IAC7E,0BAA0B,EAAE,kCAAkC;IAC9D,6BAA6B,EAAE,mCAAmC;IAClE,wBAAwB,EAAE,0BAA0B;IACpD,uBAAuB,EAAE,6BAA6B;IACtD,wBAAwB,EAAE,8BAA8B;IACxD,sBAAsB,EAAE,6BAA6B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CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;QAC1D,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;YACtC,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAChD,SAAS,EACT,eAAe,EACf,YAAY,CAAC,mBAAmB,CACjC,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC7D,MAAM,IAAI,kBAAkB,CAC1B,wEAAwE,CACzE,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,kBAAkB,CAC1B,iGAAiG,CAClG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,WAAW,EAAE,CAAC;IACpB,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAC5C,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["import { missingInstalledSkills } from \"@ebay-dt/bonfire-context\";\nimport nextEnv from \"@next/env\";\nimport {\n parseAutomaticBranchSwitchSetting,\n parseGitModeSetting,\n parseHostname,\n type BranchPreparationDiagnostic,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n GitHubCliClient,\n GitHubCliError,\n LocalPrototypeLifecycle,\n type DependencyInstaller,\n type GitHubCliClientLike,\n type PrototypeLifecycle,\n} from \"@ebay-dt/bonfire-node\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { styleText } from \"node:util\";\nimport type { BranchPrepareCommandOptions } from \"./command.js\";\n\nexport type CliEnvironmentLoader = (\n root: string,\n) => Readonly<Record<string, string | undefined>>;\n\nexport type BranchPrepareDependencies = {\n checkMissingInstalledSkills?: typeof missingInstalledSkills;\n environment?: Readonly<Record<string, string | undefined>>;\n loadEnvironment?: CliEnvironmentLoader;\n githubCli?: GitHubCliClientLike;\n createGitHubCli?: (options: { hostname: string }) => GitHubCliClientLike;\n lifecycle?: Pick<PrototypeLifecycle, \"prepareBranch\" | \"prepareDependencies\">;\n installDependencies?: DependencyInstaller;\n regenerateGeneratedContext?: NonNullable<\n PrototypeLifecycle[\"regenerateGeneratedContext\"]\n >;\n untrackGeneratedContext?: PrototypeLifecycle[\"untrackGeneratedContext\"];\n};\n\nexport class BranchPrepareError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"BranchPrepareError\";\n }\n}\n\nconst diagnosticStages: Record<BranchPreparationDiagnostic[\"stage\"], string> = {\n \"checkout-identity-branch\": \"checking out the identity branch\",\n \"configure-identity-upstream\": \"configuring the identity upstream\",\n \"prepare-reconciliation\": \"preparing reconciliation\",\n \"compose-baseline-tree\": \"composing the baseline tree\",\n \"create-baseline-commit\": \"creating the baseline commit\",\n \"apply-platform-patch\": \"applying the platform patch\",\n \"update-identity-ref\": \"updating the identity reference\",\n \"verify-reconciliation\": \"verifying reconciliation\",\n \"rollback-platform-patch\": \"rolling back the platform patch\",\n};\n\nconst diagnosticReasons: Record<BranchPreparationDiagnostic[\"reason\"], string> =\n {\n \"index-locked\": \"the Git index is locked\",\n \"patch-does-not-apply\": \"the patch does not apply\",\n \"identity-missing\": \"Git identity is missing\",\n \"ref-changed\": \"the reference changed\",\n \"permission-denied\": \"permission was denied\",\n \"missing-path-or-object\": \"a path or object is missing\",\n \"worktree-obstruction\": \"the working tree obstructs the operation\",\n \"worktree-changed\": \"the working tree changed\",\n unknown: \"the cause is unknown\",\n };\n\nfunction printDiagnostic(\n label: string,\n diagnostic: BranchPreparationDiagnostic,\n) {\n const ownData = (key: string): unknown => {\n try {\n const descriptor = Object.getOwnPropertyDescriptor(diagnostic, key);\n return descriptor && \"value\" in descriptor ? descriptor.value : undefined;\n } catch {\n return undefined;\n }\n };\n const stageValue = ownData(\"stage\");\n const reasonValue = ownData(\"reason\");\n const exitValue = ownData(\"exitCode\");\n const stage =\n typeof stageValue === \"string\" &&\n Object.hasOwn(diagnosticStages, stageValue)\n ? diagnosticStages[stageValue as BranchPreparationDiagnostic[\"stage\"]]\n : \"an unknown stage\";\n const reason =\n typeof reasonValue === \"string\" &&\n Object.hasOwn(diagnosticReasons, reasonValue)\n ? diagnosticReasons[reasonValue as BranchPreparationDiagnostic[\"reason\"]]\n : diagnosticReasons.unknown;\n const exitCode =\n typeof exitValue === \"number\" && Number.isSafeInteger(exitValue)\n ? ` (exit code ${exitValue})`\n : \"\";\n console.log(`${label}: ${stage}: ${reason}${exitCode}.`);\n}\n\nfunction loadEnvironment(root: string) {\n return nextEnv.loadEnvConfig(root, true, undefined, false).combinedEnv;\n}\n\nexport async function runBranchPrepare(\n options: BranchPrepareCommandOptions,\n dependencies: BranchPrepareDependencies,\n): Promise<number> {\n const root = resolve(options.root);\n const environment =\n dependencies.environment ??\n dependencies.loadEnvironment?.(root) ??\n loadEnvironment(root);\n // This guard must precede marker reads, identity resolution, and all Git\n // collaborators. A direct production invocation must remain read-only even\n // when a previous development install left recovery state behind.\n if (environment.NODE_ENV === \"production\") {\n return 0;\n }\n\n const checkSkills = async () => {\n try {\n const missing = await (\n dependencies.checkMissingInstalledSkills ?? missingInstalledSkills\n )({ repositoryRoot: root });\n if (missing.length)\n console.warn(\n `\n${styleText([\"bold\", \"yellow\"], \"⚠ AGENT SKILLS SETUP NEEDED\", { stream: process.stderr })}\n\nStop the dev server, then run:\n\n pnpm context:install\n\nRestart with pnpm dev.\n`,\n );\n } catch {\n console.warn(\n \"Unable to check installed skills; continuing branch preparation.\",\n );\n }\n };\n\n const generatedLifecycle = () =>\n new LocalPrototypeLifecycle({\n repositoryRoot: root,\n prototypeRoot: options.prototypeRoot ?? environment.BF_PROTOTYPE_ROOT,\n remote: options.remote ?? environment.BF_GIT_REMOTE,\n primaryBranch:\n options.primaryBranch ?? environment.BF_PROTOTYPE_BASE_BRANCH,\n automaticBranchSwitch: parseAutomaticBranchSwitchSetting(\n environment.BF_DISABLE_AUTO_BRANCH_SWITCH,\n ),\n gitMode: parseGitModeSetting(environment.BF_GIT_MODE),\n });\n const ignoredPaths = new Set<string>();\n const configuredRoot =\n options.prototypeRoot ??\n environment.BF_PROTOTYPE_ROOT ??\n \"src/app/(prototypes)\";\n const relativeRoot = relative(root, resolve(root, configuredRoot));\n const safeRoot =\n relativeRoot &&\n relativeRoot !== \"..\" &&\n !relativeRoot.startsWith(`..${sep}`) &&\n !isAbsolute(relativeRoot) &&\n !configuredRoot.split(/[\\\\/]/u).includes(\"..\")\n ? relativeRoot\n .split(sep)\n .join(\"/\")\n .replace(/[\\\\*?[\\] ]/gu, \"\\\\$&\")\n : undefined;\n const regenerate = async () => {\n try {\n const result = await (\n dependencies.regenerateGeneratedContext ??\n (() => generatedLifecycle().regenerateGeneratedContext())\n )();\n if (!result.ok)\n console.warn(\n \"diagnostic\" in result &&\n result.diagnostic === \"missing-prototype-context-source\"\n ? \"Generated context regeneration skipped: required context source context/PROTOTYPE.md is missing or unreadable.\"\n : `Generated context regeneration skipped: ${result.error.code}.`,\n );\n else {\n for (const [reason, paths] of Object.entries(result.value.skipped)) {\n if (reason === \"not ignored\")\n paths.forEach((path) => ignoredPaths.add(path));\n else if (reason !== \"tracked\" && paths.length)\n console.warn(\n `Generated context regeneration skipped (${reason}): ${paths.join(\", \")}.`,\n );\n }\n }\n } catch {\n console.warn(\n \"Generated context regeneration failed; continuing branch preparation.\",\n );\n }\n if (ignoredPaths.size)\n console.warn(\n `Generated context skipped: ${[...ignoredPaths].join(\", \")}. ${\n safeRoot\n ? `Add these .gitignore patterns:\\n${[\"AGENTS.md\", \"CLAUDE.md\", \".claude/settings.json\"].map((file) => `/${safeRoot}/*/*/${file}`).join(\"\\n\")}`\n : \"Check the configured prototype root before adding .gitignore patterns.\"\n }`,\n );\n };\n const untrack = async (\n identity: Parameters<PrototypeLifecycle[\"untrackGeneratedContext\"]>[0],\n ) => {\n try {\n const result = await (\n dependencies.untrackGeneratedContext ??\n ((user) => generatedLifecycle().untrackGeneratedContext(user))\n )(identity);\n if (!result.ok)\n console.warn(\n `Generated context untrack skipped: ${result.error.code}.`,\n );\n else if (result.value.status === \"skipped\") {\n const { reason, paths } = result.value;\n if (\n reason === \"wrong-branch\" ||\n reason === \"HEAD is not the identity branch.\"\n )\n return;\n if (\n reason ===\n \"Generated context is not ignored; add the recommended ignore rules before untracking.\"\n )\n paths.forEach((path) => ignoredPaths.add(path));\n else\n console.warn(\n `Generated context untrack skipped: ${reason}${paths.length ? ` (${paths.join(\", \")})` : \"\"}`,\n );\n }\n } catch {\n console.warn(\n \"Generated context untrack failed; continuing branch preparation.\",\n );\n }\n };\n\n const mode = parseAutomaticBranchSwitchSetting(\n environment.BF_DISABLE_AUTO_BRANCH_SWITCH,\n );\n const gitMode = parseGitModeSetting(environment.BF_GIT_MODE);\n\n if (gitMode === \"manual\") {\n console.log(\"Git management is in manual mode.\");\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n if (mode === \"disabled\") {\n console.log(\"Automatic branch switching is disabled.\");\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n // Explicit --hostname wins. Generated scripts use --default-hostname so\n // Next-compatible .env.local loading can supply BF_GITHUB_HOSTNAME first.\n const hostname = parseHostname(\n options.hostname ??\n environment.BF_GITHUB_HOSTNAME ??\n options.defaultHostname,\n );\n const lifecycle =\n dependencies.lifecycle ??\n new LocalPrototypeLifecycle({\n repositoryRoot: root,\n prototypeRoot: options.prototypeRoot ?? environment.BF_PROTOTYPE_ROOT,\n remote: options.remote ?? environment.BF_GIT_REMOTE,\n primaryBranch:\n options.primaryBranch ?? environment.BF_PROTOTYPE_BASE_BRANCH,\n automaticBranchSwitch: mode,\n gitMode,\n installDependencies: dependencies.installDependencies,\n });\n const prepareDependencies = lifecycle.prepareDependencies;\n if (prepareDependencies !== undefined) {\n console.log(\"Checking pending dependency preparation...\");\n const pending = await prepareDependencies.call(\n lifecycle,\n [],\n dependencies.installDependencies,\n );\n if (!pending.ok) {\n throw new BranchPrepareError(\"Unable to prepare project dependencies.\");\n }\n if (pending.value.status === \"failed\") {\n throw new BranchPrepareError(\n \"Dependency preparation failed; the development server was not started.\",\n );\n }\n if (pending.value.status === \"prepared\") {\n console.log(\"Pending project dependencies prepared.\");\n }\n }\n\n const githubCli =\n dependencies.githubCli ??\n dependencies.createGitHubCli?.({ hostname }) ??\n new GitHubCliClient({ hostname });\n let identity;\n try {\n identity = await githubCli.getUser();\n } catch (error) {\n if (\n error instanceof GitHubCliError &&\n (error.reason === \"missing\" || error.reason === \"unauthenticated\")\n ) {\n console.log(\n \"Branch preparation deferred; GitHub CLI authentication is not available.\",\n );\n await regenerate();\n await checkSkills();\n return 0;\n }\n throw new BranchPrepareError(\"Unable to resolve GitHub CLI identity.\");\n }\n\n console.log(\"Synchronizing project platform...\");\n const result = await lifecycle.prepareBranch(identity);\n if (!result.ok) {\n throw new BranchPrepareError(\n `Branch preparation failed with ${result.error.code}.`,\n );\n }\n\n if (result.value.status === \"deferred\") {\n console.log(\n result.value.reason === \"dirty-worktree\"\n ? \"Branch preparation deferred: uncommitted changes outside the prototype folder; platform updates were not applied.\"\n : `Branch preparation deferred; repository attention: ${result.value.reason}.`,\n );\n // A dirty/offline check that made no changes is safe to leave for the\n // existing environment. Never launch after a partially applied update.\n if (\n result.value.effects.changed ||\n result.value.effects.pushed ||\n result.value.effects.reconciledPaths.length > 0 ||\n (result.value.effects.platformPaths?.length ?? 0) > 0 ||\n (result.value.effects.dependencyPaths?.length ?? 0) > 0 ||\n result.value.effects.preparationRequired === true ||\n result.value.effects.restartRequired\n ) {\n throw new BranchPrepareError(\n \"Branch preparation was only partially completed; the development server was not started.\",\n );\n }\n await regenerate();\n await checkSkills();\n return 0;\n }\n if (result.value.status === \"unsafe\") {\n console.log(\n `Branch preparation requires repository attention (${result.value.reason}).`,\n );\n if (result.value.diagnostic)\n printDiagnostic(\"Branch preparation diagnostic\", result.value.diagnostic);\n if (result.value.rollbackDiagnostic)\n printDiagnostic(\n \"Branch preparation rollback diagnostic\",\n result.value.rollbackDiagnostic,\n );\n const effects = result.value.effects;\n const actualContentTransition =\n effects.reconciledPaths.length > 0 ||\n (effects.platformPaths?.length ?? 0) > 0 ||\n (effects.dependencyPaths?.length ?? 0) > 0 ||\n effects.preparationRequired === true ||\n effects.restartRequired;\n // History-only checkpoints and other no-effect safety refusals do not\n // justify taking down startup. A partial checkout/platform/dependency\n // transition still does: the existing environment must not run against\n // an unsafe working tree.\n if (!actualContentTransition) {\n await regenerate();\n await checkSkills();\n return 0;\n }\n throw new BranchPrepareError(\n \"Branch preparation was only partially completed; the development server was not started.\",\n );\n }\n if (result.value.status === \"disabled\") {\n console.log(\n \"Branch preparation skipped; synchronization is disabled by configuration.\",\n );\n await regenerate();\n await checkSkills();\n return 0;\n }\n\n await untrack(identity);\n await regenerate();\n\n const dependencyPaths = result.value.effects.dependencyPaths ?? [];\n const managedPathChanged =\n dependencyPaths.length > 0 ||\n result.value.effects.preparationRequired === true;\n if (managedPathChanged) {\n console.log(\"Installing updated project dependencies...\");\n if (prepareDependencies !== undefined) {\n const preparation = await prepareDependencies.call(\n lifecycle,\n dependencyPaths,\n dependencies.installDependencies,\n );\n if (!preparation.ok || preparation.value.status === \"failed\") {\n throw new BranchPrepareError(\n \"Dependency preparation failed; the development server was not started.\",\n );\n }\n } else {\n throw new BranchPrepareError(\n \"This lifecycle does not support dependency preparation; the development server was not started.\",\n );\n }\n }\n\n await checkSkills();\n console.log(\"Branch preparation complete.\");\n return 0;\n}\n"]}
|
package/dist/command.d.ts
CHANGED
package/dist/command.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAE3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AAEtB,qBAAa,cAA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AAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,iBAAiB,CAUpE;AAqFD,wBAAsB,GAAG,CACvB,IAAI,GAAE,SAAS,MAAM,EAA0B,EAC/C,YAAY,GAAE,eAAoB,GACjC,OAAO,CAAC,MAAM,CAAC,CA4DjB","sourcesContent":["import {\n checkContext,\n checkContextInstallation,\n installContext,\n syncContext,\n type ContextInstallCheckResult,\n type ContextInstallResult,\n type ContextInstallOptions,\n type ContextSyncResult,\n} from \"@ebay-dt/bonfire-context\";\nimport { prepare, PrepareError } from \"./prepare.js\";\nimport {\n BranchPrepareError,\n runBranchPrepare,\n type BranchPrepareDependencies,\n} from \"./branch-prepare.js\";\nimport {\n convert,\n convertDefaults,\n defaultConvertOptions,\n humanizeAppId,\n type ConvertOptions,\n} from \"./convert.js\";\n\nexport class CliSyntaxError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CliSyntaxError\";\n }\n}\n\nexport type PrepareCommandOptions = {\n command: \"prepare\";\n root: string;\n};\n\nexport type BranchPrepareCommandOptions = {\n command: \"branch\";\n root: string;\n hostname?: string;\n defaultHostname?: string;\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n};\n\nexport type ContextCommandOptions =\n | {\n command: \"context\";\n context: \"sync\";\n root: string;\n check: boolean;\n skipPrototypes: boolean;\n }\n | {\n command: \"context\";\n context: \"install\";\n root: string;\n appId: string;\n check: boolean;\n };\n\nexport type ConvertCommandOptions = ConvertOptions & { command: \"convert\" };\n\ntype CliCommandOptions =\n | PrepareCommandOptions\n | BranchPrepareCommandOptions\n | ContextCommandOptions\n | ConvertCommandOptions;\n\nexport type CliDependencies = BranchPrepareDependencies & {\n contextInstall?: (\n options: ContextInstallOptions,\n ) => Promise<ContextInstallResult>;\n contextInstallCheck?: (\n options: ContextInstallOptions,\n ) => Promise<ContextInstallCheckResult>;\n};\n\nfunction parseRootOption(\n argv: readonly string[],\n start: number,\n): { root: string; nextIndex: number } {\n const value = argv[start + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(\"The --root option requires a value\");\n }\n return { root: value, nextIndex: start + 2 };\n}\n\nfunction parsePrepareArgs(argv: readonly string[]): PrepareCommandOptions {\n let root = process.cwd();\n let rootProvided = false;\n for (let index = 1; index < argv.length;) {\n if (argv[index] !== \"--root\") {\n throw new CliSyntaxError(`Unknown option: ${argv[index]}`);\n }\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n }\n return { command: \"prepare\", root };\n}\n\nfunction parseContextArgs(argv: readonly string[]): ContextCommandOptions {\n const context = argv[1];\n if (context !== \"sync\" && context !== \"install\") {\n throw new CliSyntaxError(\n \"Usage: bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] --app-id <app-id> [--root <root>]\",\n );\n }\n\n let root = process.cwd();\n let appId: string | undefined;\n let check = false;\n let skipPrototypes = false;\n let rootProvided = false;\n let appIdProvided = false;\n let checkProvided = false;\n\n for (let index = 2; index < argv.length;) {\n const option = argv[index];\n if (option === \"--check\") {\n if (checkProvided) {\n throw new CliSyntaxError(\n \"The --check option may only be provided once\",\n );\n }\n check = true;\n checkProvided = true;\n index += 1;\n continue;\n }\n if (option === \"--skip-prototypes\" && context === \"sync\") {\n if (skipPrototypes) {\n throw new CliSyntaxError(\n \"The --skip-prototypes option may only be provided once\",\n );\n }\n skipPrototypes = true;\n index += 1;\n continue;\n }\n if (option === \"--root\") {\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n continue;\n }\n if (option === \"--app-id\") {\n if (appIdProvided) {\n throw new CliSyntaxError(\n \"The --app-id option may only be provided once\",\n );\n }\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(\"The --app-id option requires a value\");\n }\n appId = value;\n appIdProvided = true;\n index += 2;\n continue;\n }\n throw new CliSyntaxError(`Unknown option: ${option}`);\n }\n\n if (context === \"install\") {\n if (appId === undefined) {\n throw new CliSyntaxError(\n \"Usage: bonfire context install [--check] --app-id <app-id> [--root <root>]\",\n );\n }\n return { command: \"context\", context, root, appId, check };\n }\n if (appId !== undefined) {\n throw new CliSyntaxError(\"The --app-id option is only valid for install\");\n }\n return { command: \"context\", context, root, check, skipPrototypes };\n}\n\nfunction parseConvertArgs(argv: readonly string[]): ConvertCommandOptions {\n const defaults = defaultConvertOptions();\n let root: string | undefined;\n let appId: string | undefined;\n let name: string | undefined;\n let packageName = defaults.packageName;\n let hostname = convertDefaults.hostname;\n let deploymentEndpoint = convertDefaults.deploymentEndpoint;\n let withoutData = false;\n let dryRun = false;\n let skipInstall = false;\n const seen = new Set<string>();\n\n for (let index = 1; index < argv.length;) {\n const option = argv[index];\n if (!option) throw new CliSyntaxError(\"Missing convert option\");\n if (\n option === \"--without-data\" ||\n option === \"--dry-run\" ||\n option === \"--skip-install\"\n ) {\n if (seen.has(option))\n throw new CliSyntaxError(`${option} may only be provided once`);\n seen.add(option);\n if (option === \"--without-data\") withoutData = true;\n if (option === \"--dry-run\") dryRun = true;\n if (option === \"--skip-install\") skipInstall = true;\n index += 1;\n continue;\n }\n const setters: Record<string, (value: string) => void> = {\n \"--root\": (value) => {\n root = value;\n },\n \"--app-id\": (value) => {\n appId = value;\n },\n \"--name\": (value) => {\n name = value;\n },\n \"--package-name\": (value) => {\n packageName = value;\n },\n \"--hostname\": (value) => {\n hostname = value;\n },\n \"--deployment-endpoint\": (value) => {\n deploymentEndpoint = value;\n },\n };\n const setter = setters[option];\n if (!setter) throw new CliSyntaxError(`Unknown option: ${option}`);\n if (seen.has(option))\n throw new CliSyntaxError(`${option} may only be provided once`);\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\"))\n throw new CliSyntaxError(`${option} requires a value`);\n seen.add(option);\n setter(value);\n index += 2;\n }\n if (!root || !appId) {\n throw new CliSyntaxError(\n \"Usage: bonfire convert --root <next-app> --app-id <app-id> [--name <display-name>] [--hostname <hostname>] [--without-data] [--dry-run] [--skip-install]\",\n );\n }\n return {\n command: \"convert\",\n root,\n appId,\n name: name ?? humanizeAppId(appId),\n packageName,\n hostname,\n deploymentEndpoint,\n withItemData: !withoutData,\n dryRun,\n skipInstall,\n };\n}\n\nfunction parseBranchPrepareArgs(\n argv: readonly string[],\n): BranchPrepareCommandOptions {\n let root = process.cwd();\n let hostname: string | undefined;\n let defaultHostname: string | undefined;\n let prototypeRoot: string | undefined;\n let remote: string | undefined;\n let primaryBranch: string | undefined;\n let rootProvided = false;\n let hostnameProvided = false;\n let defaultHostnameProvided = false;\n let prototypeRootProvided = false;\n let remoteProvided = false;\n let primaryBranchProvided = false;\n\n for (let index = 2; index < argv.length;) {\n const option = argv[index];\n if (option === \"--root\") {\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n continue;\n }\n if (\n option === \"--prototype-root\" ||\n option === \"--remote\" ||\n option === \"--primary\"\n ) {\n const provided =\n option === \"--prototype-root\"\n ? prototypeRootProvided\n : option === \"--remote\"\n ? remoteProvided\n : primaryBranchProvided;\n if (provided) {\n throw new CliSyntaxError(`${option} may only be provided once`);\n }\n if (option === \"--prototype-root\") prototypeRootProvided = true;\n if (option === \"--remote\") remoteProvided = true;\n if (option === \"--primary\") primaryBranchProvided = true;\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(`${option} requires a value`);\n }\n if (option === \"--prototype-root\") prototypeRoot = value;\n if (option === \"--remote\") remote = value;\n if (option === \"--primary\") primaryBranch = value;\n index += 2;\n continue;\n }\n if (option === \"--hostname\" || option === \"--default-hostname\") {\n const isDefault = option === \"--default-hostname\";\n const provided = isDefault ? defaultHostnameProvided : hostnameProvided;\n if (provided) {\n throw new CliSyntaxError(\n `The ${option} option may only be provided once`,\n );\n }\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(`The ${option} option requires a value`);\n }\n if (isDefault) {\n defaultHostname = value;\n defaultHostnameProvided = true;\n } else {\n hostname = value;\n hostnameProvided = true;\n }\n index += 2;\n continue;\n }\n throw new CliSyntaxError(`Unknown option: ${option}`);\n }\n\n return {\n command: \"branch\",\n root,\n ...(hostname === undefined ? {} : { hostname }),\n ...(defaultHostname === undefined ? {} : { defaultHostname }),\n ...(prototypeRoot === undefined ? {} : { prototypeRoot }),\n ...(remote === undefined ? {} : { remote }),\n ...(primaryBranch === undefined ? {} : { primaryBranch }),\n };\n}\n\nexport function parseArgs(argv: readonly string[]): CliCommandOptions {\n if (argv[0] === \"convert\") return parseConvertArgs(argv);\n if (argv[0] === \"context\") return parseContextArgs(argv);\n if (argv[0] === \"prepare\") return parsePrepareArgs(argv);\n if (argv[0] === \"branch\" && argv[1] === \"prepare\") {\n return parseBranchPrepareArgs(argv);\n }\n throw new CliSyntaxError(\n \"Usage: bonfire convert --root <next-app> --app-id <app-id> [options] | bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] --app-id <app-id> [--root <root>] | bonfire prepare [--root <application-root>] | bonfire branch prepare --root <application-root> [--hostname <hostname>] [--default-hostname <hostname>] [--prototype-root <root>] [--remote <name>] [--primary <branch>]\",\n );\n}\n\nfunction printContextIssues(result: {\n issues: readonly { kind: string; path: string }[];\n}) {\n for (const issue of result.issues) {\n console.error(`- ${issue.kind}: ${issue.path}`);\n }\n}\n\nfunction printContextSyncSummary(result: ContextSyncResult) {\n if (result.written.length > 0) {\n console.log(`Written: ${result.written.join(\", \")}`);\n }\n if (result.removed.length > 0) {\n console.log(`Removed: ${result.removed.join(\", \")}`);\n }\n}\n\nasync function runContextCommand(\n options: ContextCommandOptions,\n dependencies: CliDependencies,\n): Promise<number> {\n if (options.context === \"install\") {\n if (options.check) {\n const result = await (\n dependencies.contextInstallCheck ?? checkContextInstallation\n )({\n repositoryRoot: options.root,\n appId: options.appId,\n });\n if (!result.ok) {\n console.error(\"Context install check failed:\");\n printContextIssues(result);\n return 1;\n }\n console.log(\"Context install check passed.\");\n return 0;\n }\n const result = await (dependencies.contextInstall ?? installContext)({\n repositoryRoot: options.root,\n appId: options.appId,\n });\n const skills = result.skills.map(\n (skill) => `${skill.name} (${skill.status})`,\n );\n const mcp = result.mcp.map((server) => `${server.name} (${server.status})`);\n console.log(\n skills.length > 0\n ? `Context skills: ${skills.join(\", \")}`\n : \"No context skills configured.\",\n );\n if (mcp.length > 0) console.log(`Context MCP: ${mcp.join(\", \")}`);\n console.log(\"Context install complete.\");\n return 0;\n }\n\n if (options.check) {\n const result = await checkContext({\n repositoryRoot: options.root,\n skipPrototypes: options.skipPrototypes,\n });\n if (!result.ok) {\n console.error(\"Context sync check failed:\");\n printContextIssues(result);\n return 1;\n }\n console.log(\"Context sync check passed.\");\n return 0;\n }\n\n const result = await syncContext({\n repositoryRoot: options.root,\n skipPrototypes: options.skipPrototypes,\n });\n if (!result.ok) {\n console.error(\"Context sync failed:\");\n printContextIssues(result);\n return 1;\n }\n printContextSyncSummary(result);\n console.log(\"Context sync complete.\");\n return 0;\n}\n\nexport async function run(\n argv: readonly string[] = process.argv.slice(2),\n dependencies: CliDependencies = {},\n): Promise<number> {\n const isBranchPrepare = argv[0] === \"branch\";\n const isContext = argv[0] === \"context\";\n const isConvert = argv[0] === \"convert\";\n try {\n const options = parseArgs(argv);\n switch (options.command) {\n case \"context\":\n return await runContextCommand(options, dependencies);\n case \"convert\":\n await convert(options);\n return 0;\n case \"branch\":\n return await runBranchPrepare(options, dependencies);\n case \"prepare\": {\n const result = await prepare(options);\n const descriptions = {\n environment: \"the process environment\",\n existing: \".env.local\",\n generated: \"a newly generated value in .env.local\",\n } as const;\n console.log(\n `Bonfire preparation complete; BF_SESSION_SECRET came from ${descriptions[result.source]}.`,\n );\n return 0;\n }\n }\n } catch (error) {\n if (error instanceof CliSyntaxError) {\n console.error(`bonfire: ${error.message}`);\n return 2;\n }\n if (isContext) {\n const message =\n error instanceof Error ? error.message : \"an unknown error occurred\";\n console.error(`bonfire context failed: ${message}`);\n return 1;\n }\n if (isBranchPrepare) {\n const message =\n error instanceof BranchPrepareError\n ? error.message\n : \"Unable to load branch preparation configuration.\";\n console.error(`bonfire branch prepare failed: ${message}`);\n return 1;\n }\n if (isConvert) {\n const message =\n error instanceof Error ? error.message : \"an unknown error occurred\";\n console.error(`bonfire convert failed: ${message}`);\n return 1;\n }\n\n const message =\n error instanceof PrepareError || error instanceof Error\n ? error.message\n : \"an unknown error occurred\";\n console.error(`bonfire prepare failed: ${message}`);\n return 1;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAE3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AAEtB,qBAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,QAAQ,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B;IACE,OAAO,EAAE,SAAS,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;CACzB,GACD;IACE,OAAO,EAAE,SAAS,CAAC;IACnB,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC;AAE5E,KAAK,iBAAiB,GAClB,qBAAqB,GACrB,2BAA2B,GAC3B,qBAAqB,GACrB,qBAAqB,CAAC;AAE1B,MAAM,MAAM,eAAe,GAAG,yBAAyB,GAAG;IACxD,cAAc,CAAC,EAAE,CACf,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACnC,mBAAmB,CAAC,EAAE,CACpB,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACzC,CAAC;AAsTF,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,iBAAiB,CAUpE;AAyGD,wBAAsB,GAAG,CACvB,IAAI,GAAE,SAAS,MAAM,EAA0B,EAC/C,YAAY,GAAE,eAAoB,GACjC,OAAO,CAAC,MAAM,CAAC,CA4DjB","sourcesContent":["import {\n checkContext,\n checkContextInstallation,\n installContext,\n syncContext,\n type ContextInstallCheckResult,\n type ContextInstallResult,\n type ContextInstallOptions,\n type ContextSyncResult,\n} from \"@ebay-dt/bonfire-context\";\nimport { prepare, PrepareError } from \"./prepare.js\";\nimport {\n BranchPrepareError,\n runBranchPrepare,\n type BranchPrepareDependencies,\n} from \"./branch-prepare.js\";\nimport {\n convert,\n convertDefaults,\n defaultConvertOptions,\n humanizeAppId,\n type ConvertOptions,\n} from \"./convert.js\";\n\nexport class CliSyntaxError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CliSyntaxError\";\n }\n}\n\nexport type PrepareCommandOptions = {\n command: \"prepare\";\n root: string;\n};\n\nexport type BranchPrepareCommandOptions = {\n command: \"branch\";\n root: string;\n hostname?: string;\n defaultHostname?: string;\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n};\n\nexport type ContextCommandOptions =\n | {\n command: \"context\";\n context: \"sync\";\n root: string;\n check: boolean;\n skipPrototypes: boolean;\n }\n | {\n command: \"context\";\n context: \"install\";\n root: string;\n appId: string;\n check: boolean;\n forceSkills?: boolean;\n forceMcp?: boolean;\n };\n\nexport type ConvertCommandOptions = ConvertOptions & { command: \"convert\" };\n\ntype CliCommandOptions =\n | PrepareCommandOptions\n | BranchPrepareCommandOptions\n | ContextCommandOptions\n | ConvertCommandOptions;\n\nexport type CliDependencies = BranchPrepareDependencies & {\n contextInstall?: (\n options: ContextInstallOptions,\n ) => Promise<ContextInstallResult>;\n contextInstallCheck?: (\n options: ContextInstallOptions,\n ) => Promise<ContextInstallCheckResult>;\n};\n\nfunction parseRootOption(\n argv: readonly string[],\n start: number,\n): { root: string; nextIndex: number } {\n const value = argv[start + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(\"The --root option requires a value\");\n }\n return { root: value, nextIndex: start + 2 };\n}\n\nfunction parsePrepareArgs(argv: readonly string[]): PrepareCommandOptions {\n let root = process.cwd();\n let rootProvided = false;\n for (let index = 1; index < argv.length;) {\n if (argv[index] !== \"--root\") {\n throw new CliSyntaxError(`Unknown option: ${argv[index]}`);\n }\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n }\n return { command: \"prepare\", root };\n}\n\nfunction parseContextArgs(argv: readonly string[]): ContextCommandOptions {\n const context = argv[1];\n if (context !== \"sync\" && context !== \"install\") {\n throw new CliSyntaxError(\n \"Usage: bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>]\",\n );\n }\n\n let root = process.cwd();\n let appId: string | undefined;\n let check = false;\n let skipPrototypes = false;\n let rootProvided = false;\n let appIdProvided = false;\n let checkProvided = false;\n const forceFlags = new Set<string>();\n\n for (let index = 2; index < argv.length;) {\n const option = argv[index];\n if (\n context === \"install\" &&\n (option === \"--force\" ||\n option === \"--force-skills\" ||\n option === \"--force-mcp\")\n ) {\n if (forceFlags.has(option))\n throw new CliSyntaxError(\n `The ${option} option may only be provided once`,\n );\n forceFlags.add(option);\n index += 1;\n continue;\n }\n if (option === \"--check\") {\n if (checkProvided) {\n throw new CliSyntaxError(\n \"The --check option may only be provided once\",\n );\n }\n check = true;\n checkProvided = true;\n index += 1;\n continue;\n }\n if (option === \"--skip-prototypes\" && context === \"sync\") {\n if (skipPrototypes) {\n throw new CliSyntaxError(\n \"The --skip-prototypes option may only be provided once\",\n );\n }\n skipPrototypes = true;\n index += 1;\n continue;\n }\n if (option === \"--root\") {\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n continue;\n }\n if (option === \"--app-id\") {\n if (appIdProvided) {\n throw new CliSyntaxError(\n \"The --app-id option may only be provided once\",\n );\n }\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(\"The --app-id option requires a value\");\n }\n appId = value;\n appIdProvided = true;\n index += 2;\n continue;\n }\n throw new CliSyntaxError(`Unknown option: ${option}`);\n }\n\n if (context === \"install\") {\n if (appId === undefined) {\n throw new CliSyntaxError(\n \"Usage: bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>]\",\n );\n }\n return {\n command: \"context\",\n context,\n root,\n appId,\n check,\n ...(forceFlags.has(\"--force\") || forceFlags.has(\"--force-skills\")\n ? { forceSkills: true }\n : {}),\n ...(forceFlags.has(\"--force\") || forceFlags.has(\"--force-mcp\")\n ? { forceMcp: true }\n : {}),\n };\n }\n if (appId !== undefined) {\n throw new CliSyntaxError(\"The --app-id option is only valid for install\");\n }\n return { command: \"context\", context, root, check, skipPrototypes };\n}\n\nfunction parseConvertArgs(argv: readonly string[]): ConvertCommandOptions {\n const defaults = defaultConvertOptions();\n let root: string | undefined;\n let appId: string | undefined;\n let name: string | undefined;\n let packageName = defaults.packageName;\n let hostname = convertDefaults.hostname;\n let deploymentEndpoint = convertDefaults.deploymentEndpoint;\n let withoutData = false;\n let dryRun = false;\n let skipInstall = false;\n const seen = new Set<string>();\n\n for (let index = 1; index < argv.length;) {\n const option = argv[index];\n if (!option) throw new CliSyntaxError(\"Missing convert option\");\n if (\n option === \"--without-data\" ||\n option === \"--dry-run\" ||\n option === \"--skip-install\"\n ) {\n if (seen.has(option))\n throw new CliSyntaxError(`${option} may only be provided once`);\n seen.add(option);\n if (option === \"--without-data\") withoutData = true;\n if (option === \"--dry-run\") dryRun = true;\n if (option === \"--skip-install\") skipInstall = true;\n index += 1;\n continue;\n }\n const setters: Record<string, (value: string) => void> = {\n \"--root\": (value) => {\n root = value;\n },\n \"--app-id\": (value) => {\n appId = value;\n },\n \"--name\": (value) => {\n name = value;\n },\n \"--package-name\": (value) => {\n packageName = value;\n },\n \"--hostname\": (value) => {\n hostname = value;\n },\n \"--deployment-endpoint\": (value) => {\n deploymentEndpoint = value;\n },\n };\n const setter = setters[option];\n if (!setter) throw new CliSyntaxError(`Unknown option: ${option}`);\n if (seen.has(option))\n throw new CliSyntaxError(`${option} may only be provided once`);\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\"))\n throw new CliSyntaxError(`${option} requires a value`);\n seen.add(option);\n setter(value);\n index += 2;\n }\n if (!root || !appId) {\n throw new CliSyntaxError(\n \"Usage: bonfire convert --root <next-app> --app-id <app-id> [--name <display-name>] [--hostname <hostname>] [--without-data] [--dry-run] [--skip-install]\",\n );\n }\n return {\n command: \"convert\",\n root,\n appId,\n name: name ?? humanizeAppId(appId),\n packageName,\n hostname,\n deploymentEndpoint,\n withItemData: !withoutData,\n dryRun,\n skipInstall,\n };\n}\n\nfunction parseBranchPrepareArgs(\n argv: readonly string[],\n): BranchPrepareCommandOptions {\n let root = process.cwd();\n let hostname: string | undefined;\n let defaultHostname: string | undefined;\n let prototypeRoot: string | undefined;\n let remote: string | undefined;\n let primaryBranch: string | undefined;\n let rootProvided = false;\n let hostnameProvided = false;\n let defaultHostnameProvided = false;\n let prototypeRootProvided = false;\n let remoteProvided = false;\n let primaryBranchProvided = false;\n\n for (let index = 2; index < argv.length;) {\n const option = argv[index];\n if (option === \"--root\") {\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n continue;\n }\n if (\n option === \"--prototype-root\" ||\n option === \"--remote\" ||\n option === \"--primary\"\n ) {\n const provided =\n option === \"--prototype-root\"\n ? prototypeRootProvided\n : option === \"--remote\"\n ? remoteProvided\n : primaryBranchProvided;\n if (provided) {\n throw new CliSyntaxError(`${option} may only be provided once`);\n }\n if (option === \"--prototype-root\") prototypeRootProvided = true;\n if (option === \"--remote\") remoteProvided = true;\n if (option === \"--primary\") primaryBranchProvided = true;\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(`${option} requires a value`);\n }\n if (option === \"--prototype-root\") prototypeRoot = value;\n if (option === \"--remote\") remote = value;\n if (option === \"--primary\") primaryBranch = value;\n index += 2;\n continue;\n }\n if (option === \"--hostname\" || option === \"--default-hostname\") {\n const isDefault = option === \"--default-hostname\";\n const provided = isDefault ? defaultHostnameProvided : hostnameProvided;\n if (provided) {\n throw new CliSyntaxError(\n `The ${option} option may only be provided once`,\n );\n }\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(`The ${option} option requires a value`);\n }\n if (isDefault) {\n defaultHostname = value;\n defaultHostnameProvided = true;\n } else {\n hostname = value;\n hostnameProvided = true;\n }\n index += 2;\n continue;\n }\n throw new CliSyntaxError(`Unknown option: ${option}`);\n }\n\n return {\n command: \"branch\",\n root,\n ...(hostname === undefined ? {} : { hostname }),\n ...(defaultHostname === undefined ? {} : { defaultHostname }),\n ...(prototypeRoot === undefined ? {} : { prototypeRoot }),\n ...(remote === undefined ? {} : { remote }),\n ...(primaryBranch === undefined ? {} : { primaryBranch }),\n };\n}\n\nexport function parseArgs(argv: readonly string[]): CliCommandOptions {\n if (argv[0] === \"convert\") return parseConvertArgs(argv);\n if (argv[0] === \"context\") return parseContextArgs(argv);\n if (argv[0] === \"prepare\") return parsePrepareArgs(argv);\n if (argv[0] === \"branch\" && argv[1] === \"prepare\") {\n return parseBranchPrepareArgs(argv);\n }\n throw new CliSyntaxError(\n \"Usage: bonfire convert --root <next-app> --app-id <app-id> [options] | bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>] | bonfire prepare [--root <application-root>] | bonfire branch prepare --root <application-root> [--hostname <hostname>] [--default-hostname <hostname>] [--prototype-root <root>] [--remote <name>] [--primary <branch>]\",\n );\n}\n\nfunction printContextIssues(result: {\n issues: readonly { kind: string; path: string }[];\n}) {\n for (const issue of result.issues) {\n console.error(`- ${issue.kind}: ${issue.path}`);\n }\n}\n\nfunction printContextSyncSummary(result: ContextSyncResult) {\n if (result.written.length > 0) {\n console.log(`Written: ${result.written.join(\", \")}`);\n }\n if (result.removed.length > 0) {\n console.log(`Removed: ${result.removed.join(\", \")}`);\n }\n}\n\nasync function runContextCommand(\n options: ContextCommandOptions,\n dependencies: CliDependencies,\n): Promise<number> {\n if (options.context === \"install\") {\n if (options.check) {\n const result = await (\n dependencies.contextInstallCheck ?? checkContextInstallation\n )({\n repositoryRoot: options.root,\n appId: options.appId,\n });\n if (!result.ok) {\n console.error(\"Context install check failed:\");\n printContextIssues(result);\n return 1;\n }\n console.log(\"Context install check passed.\");\n return 0;\n }\n const result = await (dependencies.contextInstall ?? installContext)({\n repositoryRoot: options.root,\n appId: options.appId,\n ...(options.forceSkills ? { forceSkills: true } : {}),\n ...(options.forceMcp ? { forceMcp: true } : {}),\n });\n for (const backup of result.backups ?? []) {\n console.log(\n `Backup ${backup.kind}: ${backup.path} -> ${backup.backupPath}`,\n );\n }\n for (const warning of result.warnings ?? []) {\n console.warn(\n `Skipped ${warning.kind} ${warning.name} at ${warning.path}; keeping existing configuration. Use --force-${warning.kind === \"skill\" ? \"skills\" : \"mcp\"} to replace it.`,\n );\n }\n const skills = result.skills\n .filter((skill) => skill.status !== \"skipped\")\n .map((skill) => `${skill.name} (${skill.status})`);\n const mcp = result.mcp\n .filter((server) => server.status !== \"skipped\")\n .map((server) => `${server.name} (${server.status})`);\n console.log(\n skills.length > 0\n ? `Context skills: ${skills.join(\", \")}`\n : result.skills.length === 0\n ? \"No context skills configured.\"\n : \"No context skills installed.\",\n );\n if (mcp.length > 0) console.log(`Context MCP: ${mcp.join(\", \")}`);\n console.log(\n result.warnings?.length\n ? \"Context installation finished with warnings.\"\n : \"Context install complete.\",\n );\n return 0;\n }\n\n if (options.check) {\n const result = await checkContext({\n repositoryRoot: options.root,\n skipPrototypes: options.skipPrototypes,\n });\n if (!result.ok) {\n console.error(\"Context sync check failed:\");\n printContextIssues(result);\n return 1;\n }\n console.log(\"Context sync check passed.\");\n return 0;\n }\n\n const result = await syncContext({\n repositoryRoot: options.root,\n skipPrototypes: options.skipPrototypes,\n });\n if (!result.ok) {\n console.error(\"Context sync failed:\");\n printContextIssues(result);\n return 1;\n }\n printContextSyncSummary(result);\n console.log(\"Context sync complete.\");\n return 0;\n}\n\nexport async function run(\n argv: readonly string[] = process.argv.slice(2),\n dependencies: CliDependencies = {},\n): Promise<number> {\n const isBranchPrepare = argv[0] === \"branch\";\n const isContext = argv[0] === \"context\";\n const isConvert = argv[0] === \"convert\";\n try {\n const options = parseArgs(argv);\n switch (options.command) {\n case \"context\":\n return await runContextCommand(options, dependencies);\n case \"convert\":\n await convert(options);\n return 0;\n case \"branch\":\n return await runBranchPrepare(options, dependencies);\n case \"prepare\": {\n const result = await prepare(options);\n const descriptions = {\n environment: \"the process environment\",\n existing: \".env.local\",\n generated: \"a newly generated value in .env.local\",\n } as const;\n console.log(\n `Bonfire preparation complete; BF_SESSION_SECRET came from ${descriptions[result.source]}.`,\n );\n return 0;\n }\n }\n } catch (error) {\n if (error instanceof CliSyntaxError) {\n console.error(`bonfire: ${error.message}`);\n return 2;\n }\n if (isContext) {\n const message =\n error instanceof Error ? error.message : \"an unknown error occurred\";\n console.error(`bonfire context failed: ${message}`);\n return 1;\n }\n if (isBranchPrepare) {\n const message =\n error instanceof BranchPrepareError\n ? error.message\n : \"Unable to load branch preparation configuration.\";\n console.error(`bonfire branch prepare failed: ${message}`);\n return 1;\n }\n if (isConvert) {\n const message =\n error instanceof Error ? error.message : \"an unknown error occurred\";\n console.error(`bonfire convert failed: ${message}`);\n return 1;\n }\n\n const message =\n error instanceof PrepareError || error instanceof Error\n ? error.message\n : \"an unknown error occurred\";\n console.error(`bonfire prepare failed: ${message}`);\n return 1;\n }\n}\n"]}
|
package/dist/command.js
CHANGED
|
@@ -35,7 +35,7 @@ function parsePrepareArgs(argv) {
|
|
|
35
35
|
function parseContextArgs(argv) {
|
|
36
36
|
const context = argv[1];
|
|
37
37
|
if (context !== "sync" && context !== "install") {
|
|
38
|
-
throw new CliSyntaxError("Usage: bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] --app-id <app-id> [--root <root>]");
|
|
38
|
+
throw new CliSyntaxError("Usage: bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>]");
|
|
39
39
|
}
|
|
40
40
|
let root = process.cwd();
|
|
41
41
|
let appId;
|
|
@@ -44,8 +44,19 @@ function parseContextArgs(argv) {
|
|
|
44
44
|
let rootProvided = false;
|
|
45
45
|
let appIdProvided = false;
|
|
46
46
|
let checkProvided = false;
|
|
47
|
+
const forceFlags = new Set();
|
|
47
48
|
for (let index = 2; index < argv.length;) {
|
|
48
49
|
const option = argv[index];
|
|
50
|
+
if (context === "install" &&
|
|
51
|
+
(option === "--force" ||
|
|
52
|
+
option === "--force-skills" ||
|
|
53
|
+
option === "--force-mcp")) {
|
|
54
|
+
if (forceFlags.has(option))
|
|
55
|
+
throw new CliSyntaxError(`The ${option} option may only be provided once`);
|
|
56
|
+
forceFlags.add(option);
|
|
57
|
+
index += 1;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
49
60
|
if (option === "--check") {
|
|
50
61
|
if (checkProvided) {
|
|
51
62
|
throw new CliSyntaxError("The --check option may only be provided once");
|
|
@@ -90,9 +101,21 @@ function parseContextArgs(argv) {
|
|
|
90
101
|
}
|
|
91
102
|
if (context === "install") {
|
|
92
103
|
if (appId === undefined) {
|
|
93
|
-
throw new CliSyntaxError("Usage: bonfire context install [--check] --app-id <app-id> [--root <root>]");
|
|
104
|
+
throw new CliSyntaxError("Usage: bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>]");
|
|
94
105
|
}
|
|
95
|
-
return {
|
|
106
|
+
return {
|
|
107
|
+
command: "context",
|
|
108
|
+
context,
|
|
109
|
+
root,
|
|
110
|
+
appId,
|
|
111
|
+
check,
|
|
112
|
+
...(forceFlags.has("--force") || forceFlags.has("--force-skills")
|
|
113
|
+
? { forceSkills: true }
|
|
114
|
+
: {}),
|
|
115
|
+
...(forceFlags.has("--force") || forceFlags.has("--force-mcp")
|
|
116
|
+
? { forceMcp: true }
|
|
117
|
+
: {}),
|
|
118
|
+
};
|
|
96
119
|
}
|
|
97
120
|
if (appId !== undefined) {
|
|
98
121
|
throw new CliSyntaxError("The --app-id option is only valid for install");
|
|
@@ -276,7 +299,7 @@ export function parseArgs(argv) {
|
|
|
276
299
|
if (argv[0] === "branch" && argv[1] === "prepare") {
|
|
277
300
|
return parseBranchPrepareArgs(argv);
|
|
278
301
|
}
|
|
279
|
-
throw new CliSyntaxError("Usage: bonfire convert --root <next-app> --app-id <app-id> [options] | bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] --app-id <app-id> [--root <root>] | bonfire prepare [--root <application-root>] | bonfire branch prepare --root <application-root> [--hostname <hostname>] [--default-hostname <hostname>] [--prototype-root <root>] [--remote <name>] [--primary <branch>]");
|
|
302
|
+
throw new CliSyntaxError("Usage: bonfire convert --root <next-app> --app-id <app-id> [options] | bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>] | bonfire prepare [--root <application-root>] | bonfire branch prepare --root <application-root> [--hostname <hostname>] [--default-hostname <hostname>] [--prototype-root <root>] [--remote <name>] [--primary <branch>]");
|
|
280
303
|
}
|
|
281
304
|
function printContextIssues(result) {
|
|
282
305
|
for (const issue of result.issues) {
|
|
@@ -309,15 +332,31 @@ async function runContextCommand(options, dependencies) {
|
|
|
309
332
|
const result = await (dependencies.contextInstall ?? installContext)({
|
|
310
333
|
repositoryRoot: options.root,
|
|
311
334
|
appId: options.appId,
|
|
335
|
+
...(options.forceSkills ? { forceSkills: true } : {}),
|
|
336
|
+
...(options.forceMcp ? { forceMcp: true } : {}),
|
|
312
337
|
});
|
|
313
|
-
const
|
|
314
|
-
|
|
338
|
+
for (const backup of result.backups ?? []) {
|
|
339
|
+
console.log(`Backup ${backup.kind}: ${backup.path} -> ${backup.backupPath}`);
|
|
340
|
+
}
|
|
341
|
+
for (const warning of result.warnings ?? []) {
|
|
342
|
+
console.warn(`Skipped ${warning.kind} ${warning.name} at ${warning.path}; keeping existing configuration. Use --force-${warning.kind === "skill" ? "skills" : "mcp"} to replace it.`);
|
|
343
|
+
}
|
|
344
|
+
const skills = result.skills
|
|
345
|
+
.filter((skill) => skill.status !== "skipped")
|
|
346
|
+
.map((skill) => `${skill.name} (${skill.status})`);
|
|
347
|
+
const mcp = result.mcp
|
|
348
|
+
.filter((server) => server.status !== "skipped")
|
|
349
|
+
.map((server) => `${server.name} (${server.status})`);
|
|
315
350
|
console.log(skills.length > 0
|
|
316
351
|
? `Context skills: ${skills.join(", ")}`
|
|
317
|
-
:
|
|
352
|
+
: result.skills.length === 0
|
|
353
|
+
? "No context skills configured."
|
|
354
|
+
: "No context skills installed.");
|
|
318
355
|
if (mcp.length > 0)
|
|
319
356
|
console.log(`Context MCP: ${mcp.join(", ")}`);
|
|
320
|
-
console.log(
|
|
357
|
+
console.log(result.warnings?.length
|
|
358
|
+
? "Context installation finished with warnings."
|
|
359
|
+
: "Context install complete.");
|
|
321
360
|
return 0;
|
|
322
361
|
}
|
|
323
362
|
if (options.check) {
|
package/dist/command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,WAAW,GAKZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,aAAa,GAEd,MAAM,cAAc,CAAC;AAEtB,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAkDD,SAAS,eAAe,CACtB,IAAuB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C,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;YACpD,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,OAAO,GACX,KAAK,YAAY,YAAY,IAAI,KAAK,YAAY,KAAK;YACrD,CAAC,CAAC,KAAK,CAAC,OAAO;YACf,CAAC,CAAC,2BAA2B,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC","sourcesContent":["import {\n checkContext,\n checkContextInstallation,\n installContext,\n syncContext,\n type ContextInstallCheckResult,\n type ContextInstallResult,\n type ContextInstallOptions,\n type ContextSyncResult,\n} from \"@ebay-dt/bonfire-context\";\nimport { prepare, PrepareError } from \"./prepare.js\";\nimport {\n BranchPrepareError,\n runBranchPrepare,\n type BranchPrepareDependencies,\n} from \"./branch-prepare.js\";\nimport {\n convert,\n convertDefaults,\n defaultConvertOptions,\n humanizeAppId,\n type ConvertOptions,\n} from \"./convert.js\";\n\nexport class CliSyntaxError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CliSyntaxError\";\n }\n}\n\nexport type PrepareCommandOptions = {\n command: \"prepare\";\n root: string;\n};\n\nexport type BranchPrepareCommandOptions = {\n command: \"branch\";\n root: string;\n hostname?: string;\n defaultHostname?: string;\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n};\n\nexport type ContextCommandOptions =\n | {\n command: \"context\";\n context: \"sync\";\n root: string;\n check: boolean;\n skipPrototypes: boolean;\n }\n | {\n command: \"context\";\n context: \"install\";\n root: string;\n appId: string;\n check: boolean;\n };\n\nexport type ConvertCommandOptions = ConvertOptions & { command: \"convert\" };\n\ntype CliCommandOptions =\n | PrepareCommandOptions\n | BranchPrepareCommandOptions\n | ContextCommandOptions\n | ConvertCommandOptions;\n\nexport type CliDependencies = BranchPrepareDependencies & {\n contextInstall?: (\n options: ContextInstallOptions,\n ) => Promise<ContextInstallResult>;\n contextInstallCheck?: (\n options: ContextInstallOptions,\n ) => Promise<ContextInstallCheckResult>;\n};\n\nfunction parseRootOption(\n argv: readonly string[],\n start: number,\n): { root: string; nextIndex: number } {\n const value = argv[start + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(\"The --root option requires a value\");\n }\n return { root: value, nextIndex: start + 2 };\n}\n\nfunction parsePrepareArgs(argv: readonly string[]): PrepareCommandOptions {\n let root = process.cwd();\n let rootProvided = false;\n for (let index = 1; index < argv.length;) {\n if (argv[index] !== \"--root\") {\n throw new CliSyntaxError(`Unknown option: ${argv[index]}`);\n }\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n }\n return { command: \"prepare\", root };\n}\n\nfunction parseContextArgs(argv: readonly string[]): ContextCommandOptions {\n const context = argv[1];\n if (context !== \"sync\" && context !== \"install\") {\n throw new CliSyntaxError(\n \"Usage: bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] --app-id <app-id> [--root <root>]\",\n );\n }\n\n let root = process.cwd();\n let appId: string | undefined;\n let check = false;\n let skipPrototypes = false;\n let rootProvided = false;\n let appIdProvided = false;\n let checkProvided = false;\n\n for (let index = 2; index < argv.length;) {\n const option = argv[index];\n if (option === \"--check\") {\n if (checkProvided) {\n throw new CliSyntaxError(\n \"The --check option may only be provided once\",\n );\n }\n check = true;\n checkProvided = true;\n index += 1;\n continue;\n }\n if (option === \"--skip-prototypes\" && context === \"sync\") {\n if (skipPrototypes) {\n throw new CliSyntaxError(\n \"The --skip-prototypes option may only be provided once\",\n );\n }\n skipPrototypes = true;\n index += 1;\n continue;\n }\n if (option === \"--root\") {\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n continue;\n }\n if (option === \"--app-id\") {\n if (appIdProvided) {\n throw new CliSyntaxError(\n \"The --app-id option may only be provided once\",\n );\n }\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(\"The --app-id option requires a value\");\n }\n appId = value;\n appIdProvided = true;\n index += 2;\n continue;\n }\n throw new CliSyntaxError(`Unknown option: ${option}`);\n }\n\n if (context === \"install\") {\n if (appId === undefined) {\n throw new CliSyntaxError(\n \"Usage: bonfire context install [--check] --app-id <app-id> [--root <root>]\",\n );\n }\n return { command: \"context\", context, root, appId, check };\n }\n if (appId !== undefined) {\n throw new CliSyntaxError(\"The --app-id option is only valid for install\");\n }\n return { command: \"context\", context, root, check, skipPrototypes };\n}\n\nfunction parseConvertArgs(argv: readonly string[]): ConvertCommandOptions {\n const defaults = defaultConvertOptions();\n let root: string | undefined;\n let appId: string | undefined;\n let name: string | undefined;\n let packageName = defaults.packageName;\n let hostname = convertDefaults.hostname;\n let deploymentEndpoint = convertDefaults.deploymentEndpoint;\n let withoutData = false;\n let dryRun = false;\n let skipInstall = false;\n const seen = new Set<string>();\n\n for (let index = 1; index < argv.length;) {\n const option = argv[index];\n if (!option) throw new CliSyntaxError(\"Missing convert option\");\n if (\n option === \"--without-data\" ||\n option === \"--dry-run\" ||\n option === \"--skip-install\"\n ) {\n if (seen.has(option))\n throw new CliSyntaxError(`${option} may only be provided once`);\n seen.add(option);\n if (option === \"--without-data\") withoutData = true;\n if (option === \"--dry-run\") dryRun = true;\n if (option === \"--skip-install\") skipInstall = true;\n index += 1;\n continue;\n }\n const setters: Record<string, (value: string) => void> = {\n \"--root\": (value) => {\n root = value;\n },\n \"--app-id\": (value) => {\n appId = value;\n },\n \"--name\": (value) => {\n name = value;\n },\n \"--package-name\": (value) => {\n packageName = value;\n },\n \"--hostname\": (value) => {\n hostname = value;\n },\n \"--deployment-endpoint\": (value) => {\n deploymentEndpoint = value;\n },\n };\n const setter = setters[option];\n if (!setter) throw new CliSyntaxError(`Unknown option: ${option}`);\n if (seen.has(option))\n throw new CliSyntaxError(`${option} may only be provided once`);\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\"))\n throw new CliSyntaxError(`${option} requires a value`);\n seen.add(option);\n setter(value);\n index += 2;\n }\n if (!root || !appId) {\n throw new CliSyntaxError(\n \"Usage: bonfire convert --root <next-app> --app-id <app-id> [--name <display-name>] [--hostname <hostname>] [--without-data] [--dry-run] [--skip-install]\",\n );\n }\n return {\n command: \"convert\",\n root,\n appId,\n name: name ?? humanizeAppId(appId),\n packageName,\n hostname,\n deploymentEndpoint,\n withItemData: !withoutData,\n dryRun,\n skipInstall,\n };\n}\n\nfunction parseBranchPrepareArgs(\n argv: readonly string[],\n): BranchPrepareCommandOptions {\n let root = process.cwd();\n let hostname: string | undefined;\n let defaultHostname: string | undefined;\n let prototypeRoot: string | undefined;\n let remote: string | undefined;\n let primaryBranch: string | undefined;\n let rootProvided = false;\n let hostnameProvided = false;\n let defaultHostnameProvided = false;\n let prototypeRootProvided = false;\n let remoteProvided = false;\n let primaryBranchProvided = false;\n\n for (let index = 2; index < argv.length;) {\n const option = argv[index];\n if (option === \"--root\") {\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n continue;\n }\n if (\n option === \"--prototype-root\" ||\n option === \"--remote\" ||\n option === \"--primary\"\n ) {\n const provided =\n option === \"--prototype-root\"\n ? prototypeRootProvided\n : option === \"--remote\"\n ? remoteProvided\n : primaryBranchProvided;\n if (provided) {\n throw new CliSyntaxError(`${option} may only be provided once`);\n }\n if (option === \"--prototype-root\") prototypeRootProvided = true;\n if (option === \"--remote\") remoteProvided = true;\n if (option === \"--primary\") primaryBranchProvided = true;\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(`${option} requires a value`);\n }\n if (option === \"--prototype-root\") prototypeRoot = value;\n if (option === \"--remote\") remote = value;\n if (option === \"--primary\") primaryBranch = value;\n index += 2;\n continue;\n }\n if (option === \"--hostname\" || option === \"--default-hostname\") {\n const isDefault = option === \"--default-hostname\";\n const provided = isDefault ? defaultHostnameProvided : hostnameProvided;\n if (provided) {\n throw new CliSyntaxError(\n `The ${option} option may only be provided once`,\n );\n }\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(`The ${option} option requires a value`);\n }\n if (isDefault) {\n defaultHostname = value;\n defaultHostnameProvided = true;\n } else {\n hostname = value;\n hostnameProvided = true;\n }\n index += 2;\n continue;\n }\n throw new CliSyntaxError(`Unknown option: ${option}`);\n }\n\n return {\n command: \"branch\",\n root,\n ...(hostname === undefined ? {} : { hostname }),\n ...(defaultHostname === undefined ? {} : { defaultHostname }),\n ...(prototypeRoot === undefined ? {} : { prototypeRoot }),\n ...(remote === undefined ? {} : { remote }),\n ...(primaryBranch === undefined ? {} : { primaryBranch }),\n };\n}\n\nexport function parseArgs(argv: readonly string[]): CliCommandOptions {\n if (argv[0] === \"convert\") return parseConvertArgs(argv);\n if (argv[0] === \"context\") return parseContextArgs(argv);\n if (argv[0] === \"prepare\") return parsePrepareArgs(argv);\n if (argv[0] === \"branch\" && argv[1] === \"prepare\") {\n return parseBranchPrepareArgs(argv);\n }\n throw new CliSyntaxError(\n \"Usage: bonfire convert --root <next-app> --app-id <app-id> [options] | bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] --app-id <app-id> [--root <root>] | bonfire prepare [--root <application-root>] | bonfire branch prepare --root <application-root> [--hostname <hostname>] [--default-hostname <hostname>] [--prototype-root <root>] [--remote <name>] [--primary <branch>]\",\n );\n}\n\nfunction printContextIssues(result: {\n issues: readonly { kind: string; path: string }[];\n}) {\n for (const issue of result.issues) {\n console.error(`- ${issue.kind}: ${issue.path}`);\n }\n}\n\nfunction printContextSyncSummary(result: ContextSyncResult) {\n if (result.written.length > 0) {\n console.log(`Written: ${result.written.join(\", \")}`);\n }\n if (result.removed.length > 0) {\n console.log(`Removed: ${result.removed.join(\", \")}`);\n }\n}\n\nasync function runContextCommand(\n options: ContextCommandOptions,\n dependencies: CliDependencies,\n): Promise<number> {\n if (options.context === \"install\") {\n if (options.check) {\n const result = await (\n dependencies.contextInstallCheck ?? checkContextInstallation\n )({\n repositoryRoot: options.root,\n appId: options.appId,\n });\n if (!result.ok) {\n console.error(\"Context install check failed:\");\n printContextIssues(result);\n return 1;\n }\n console.log(\"Context install check passed.\");\n return 0;\n }\n const result = await (dependencies.contextInstall ?? installContext)({\n repositoryRoot: options.root,\n appId: options.appId,\n });\n const skills = result.skills.map(\n (skill) => `${skill.name} (${skill.status})`,\n );\n const mcp = result.mcp.map((server) => `${server.name} (${server.status})`);\n console.log(\n skills.length > 0\n ? `Context skills: ${skills.join(\", \")}`\n : \"No context skills configured.\",\n );\n if (mcp.length > 0) console.log(`Context MCP: ${mcp.join(\", \")}`);\n console.log(\"Context install complete.\");\n return 0;\n }\n\n if (options.check) {\n const result = await checkContext({\n repositoryRoot: options.root,\n skipPrototypes: options.skipPrototypes,\n });\n if (!result.ok) {\n console.error(\"Context sync check failed:\");\n printContextIssues(result);\n return 1;\n }\n console.log(\"Context sync check passed.\");\n return 0;\n }\n\n const result = await syncContext({\n repositoryRoot: options.root,\n skipPrototypes: options.skipPrototypes,\n });\n if (!result.ok) {\n console.error(\"Context sync failed:\");\n printContextIssues(result);\n return 1;\n }\n printContextSyncSummary(result);\n console.log(\"Context sync complete.\");\n return 0;\n}\n\nexport async function run(\n argv: readonly string[] = process.argv.slice(2),\n dependencies: CliDependencies = {},\n): Promise<number> {\n const isBranchPrepare = argv[0] === \"branch\";\n const isContext = argv[0] === \"context\";\n const isConvert = argv[0] === \"convert\";\n try {\n const options = parseArgs(argv);\n switch (options.command) {\n case \"context\":\n return await runContextCommand(options, dependencies);\n case \"convert\":\n await convert(options);\n return 0;\n case \"branch\":\n return await runBranchPrepare(options, dependencies);\n case \"prepare\": {\n const result = await prepare(options);\n const descriptions = {\n environment: \"the process environment\",\n existing: \".env.local\",\n generated: \"a newly generated value in .env.local\",\n } as const;\n console.log(\n `Bonfire preparation complete; BF_SESSION_SECRET came from ${descriptions[result.source]}.`,\n );\n return 0;\n }\n }\n } catch (error) {\n if (error instanceof CliSyntaxError) {\n console.error(`bonfire: ${error.message}`);\n return 2;\n }\n if (isContext) {\n const message =\n error instanceof Error ? error.message : \"an unknown error occurred\";\n console.error(`bonfire context failed: ${message}`);\n return 1;\n }\n if (isBranchPrepare) {\n const message =\n error instanceof BranchPrepareError\n ? error.message\n : \"Unable to load branch preparation configuration.\";\n console.error(`bonfire branch prepare failed: ${message}`);\n return 1;\n }\n if (isConvert) {\n const message =\n error instanceof Error ? error.message : \"an unknown error occurred\";\n console.error(`bonfire convert failed: ${message}`);\n return 1;\n }\n\n const message =\n error instanceof PrepareError || error instanceof Error\n ? error.message\n : \"an unknown error occurred\";\n console.error(`bonfire prepare failed: ${message}`);\n return 1;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,WAAW,GAKZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,aAAa,GAEd,MAAM,cAAc,CAAC;AAEtB,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAoDD,SAAS,eAAe,CACtB,IAAuB,EACvB,KAAa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AI,SAAS,EAAE,CAAC;YACd,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;YACpD,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,OAAO,GACX,KAAK,YAAY,kBAAkB;gBACjC,CAAC,CAAC,KAAK,CAAC,OAAO;gBACf,CAAC,CAAC,kDAAkD,CAAC;YACzD,OAAO,CAAC,KAAK,CAAC,kCAAkC,OAAO,EAAE,CAAC,CAAC;YAC3D,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;YACpD,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,OAAO,GACX,KAAK,YAAY,YAAY,IAAI,KAAK,YAAY,KAAK;YACrD,CAAC,CAAC,KAAK,CAAC,OAAO;YACf,CAAC,CAAC,2BAA2B,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC","sourcesContent":["import {\n checkContext,\n checkContextInstallation,\n installContext,\n syncContext,\n type ContextInstallCheckResult,\n type ContextInstallResult,\n type ContextInstallOptions,\n type ContextSyncResult,\n} from \"@ebay-dt/bonfire-context\";\nimport { prepare, PrepareError } from \"./prepare.js\";\nimport {\n BranchPrepareError,\n runBranchPrepare,\n type BranchPrepareDependencies,\n} from \"./branch-prepare.js\";\nimport {\n convert,\n convertDefaults,\n defaultConvertOptions,\n humanizeAppId,\n type ConvertOptions,\n} from \"./convert.js\";\n\nexport class CliSyntaxError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CliSyntaxError\";\n }\n}\n\nexport type PrepareCommandOptions = {\n command: \"prepare\";\n root: string;\n};\n\nexport type BranchPrepareCommandOptions = {\n command: \"branch\";\n root: string;\n hostname?: string;\n defaultHostname?: string;\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n};\n\nexport type ContextCommandOptions =\n | {\n command: \"context\";\n context: \"sync\";\n root: string;\n check: boolean;\n skipPrototypes: boolean;\n }\n | {\n command: \"context\";\n context: \"install\";\n root: string;\n appId: string;\n check: boolean;\n forceSkills?: boolean;\n forceMcp?: boolean;\n };\n\nexport type ConvertCommandOptions = ConvertOptions & { command: \"convert\" };\n\ntype CliCommandOptions =\n | PrepareCommandOptions\n | BranchPrepareCommandOptions\n | ContextCommandOptions\n | ConvertCommandOptions;\n\nexport type CliDependencies = BranchPrepareDependencies & {\n contextInstall?: (\n options: ContextInstallOptions,\n ) => Promise<ContextInstallResult>;\n contextInstallCheck?: (\n options: ContextInstallOptions,\n ) => Promise<ContextInstallCheckResult>;\n};\n\nfunction parseRootOption(\n argv: readonly string[],\n start: number,\n): { root: string; nextIndex: number } {\n const value = argv[start + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(\"The --root option requires a value\");\n }\n return { root: value, nextIndex: start + 2 };\n}\n\nfunction parsePrepareArgs(argv: readonly string[]): PrepareCommandOptions {\n let root = process.cwd();\n let rootProvided = false;\n for (let index = 1; index < argv.length;) {\n if (argv[index] !== \"--root\") {\n throw new CliSyntaxError(`Unknown option: ${argv[index]}`);\n }\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n }\n return { command: \"prepare\", root };\n}\n\nfunction parseContextArgs(argv: readonly string[]): ContextCommandOptions {\n const context = argv[1];\n if (context !== \"sync\" && context !== \"install\") {\n throw new CliSyntaxError(\n \"Usage: bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>]\",\n );\n }\n\n let root = process.cwd();\n let appId: string | undefined;\n let check = false;\n let skipPrototypes = false;\n let rootProvided = false;\n let appIdProvided = false;\n let checkProvided = false;\n const forceFlags = new Set<string>();\n\n for (let index = 2; index < argv.length;) {\n const option = argv[index];\n if (\n context === \"install\" &&\n (option === \"--force\" ||\n option === \"--force-skills\" ||\n option === \"--force-mcp\")\n ) {\n if (forceFlags.has(option))\n throw new CliSyntaxError(\n `The ${option} option may only be provided once`,\n );\n forceFlags.add(option);\n index += 1;\n continue;\n }\n if (option === \"--check\") {\n if (checkProvided) {\n throw new CliSyntaxError(\n \"The --check option may only be provided once\",\n );\n }\n check = true;\n checkProvided = true;\n index += 1;\n continue;\n }\n if (option === \"--skip-prototypes\" && context === \"sync\") {\n if (skipPrototypes) {\n throw new CliSyntaxError(\n \"The --skip-prototypes option may only be provided once\",\n );\n }\n skipPrototypes = true;\n index += 1;\n continue;\n }\n if (option === \"--root\") {\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n continue;\n }\n if (option === \"--app-id\") {\n if (appIdProvided) {\n throw new CliSyntaxError(\n \"The --app-id option may only be provided once\",\n );\n }\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(\"The --app-id option requires a value\");\n }\n appId = value;\n appIdProvided = true;\n index += 2;\n continue;\n }\n throw new CliSyntaxError(`Unknown option: ${option}`);\n }\n\n if (context === \"install\") {\n if (appId === undefined) {\n throw new CliSyntaxError(\n \"Usage: bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>]\",\n );\n }\n return {\n command: \"context\",\n context,\n root,\n appId,\n check,\n ...(forceFlags.has(\"--force\") || forceFlags.has(\"--force-skills\")\n ? { forceSkills: true }\n : {}),\n ...(forceFlags.has(\"--force\") || forceFlags.has(\"--force-mcp\")\n ? { forceMcp: true }\n : {}),\n };\n }\n if (appId !== undefined) {\n throw new CliSyntaxError(\"The --app-id option is only valid for install\");\n }\n return { command: \"context\", context, root, check, skipPrototypes };\n}\n\nfunction parseConvertArgs(argv: readonly string[]): ConvertCommandOptions {\n const defaults = defaultConvertOptions();\n let root: string | undefined;\n let appId: string | undefined;\n let name: string | undefined;\n let packageName = defaults.packageName;\n let hostname = convertDefaults.hostname;\n let deploymentEndpoint = convertDefaults.deploymentEndpoint;\n let withoutData = false;\n let dryRun = false;\n let skipInstall = false;\n const seen = new Set<string>();\n\n for (let index = 1; index < argv.length;) {\n const option = argv[index];\n if (!option) throw new CliSyntaxError(\"Missing convert option\");\n if (\n option === \"--without-data\" ||\n option === \"--dry-run\" ||\n option === \"--skip-install\"\n ) {\n if (seen.has(option))\n throw new CliSyntaxError(`${option} may only be provided once`);\n seen.add(option);\n if (option === \"--without-data\") withoutData = true;\n if (option === \"--dry-run\") dryRun = true;\n if (option === \"--skip-install\") skipInstall = true;\n index += 1;\n continue;\n }\n const setters: Record<string, (value: string) => void> = {\n \"--root\": (value) => {\n root = value;\n },\n \"--app-id\": (value) => {\n appId = value;\n },\n \"--name\": (value) => {\n name = value;\n },\n \"--package-name\": (value) => {\n packageName = value;\n },\n \"--hostname\": (value) => {\n hostname = value;\n },\n \"--deployment-endpoint\": (value) => {\n deploymentEndpoint = value;\n },\n };\n const setter = setters[option];\n if (!setter) throw new CliSyntaxError(`Unknown option: ${option}`);\n if (seen.has(option))\n throw new CliSyntaxError(`${option} may only be provided once`);\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\"))\n throw new CliSyntaxError(`${option} requires a value`);\n seen.add(option);\n setter(value);\n index += 2;\n }\n if (!root || !appId) {\n throw new CliSyntaxError(\n \"Usage: bonfire convert --root <next-app> --app-id <app-id> [--name <display-name>] [--hostname <hostname>] [--without-data] [--dry-run] [--skip-install]\",\n );\n }\n return {\n command: \"convert\",\n root,\n appId,\n name: name ?? humanizeAppId(appId),\n packageName,\n hostname,\n deploymentEndpoint,\n withItemData: !withoutData,\n dryRun,\n skipInstall,\n };\n}\n\nfunction parseBranchPrepareArgs(\n argv: readonly string[],\n): BranchPrepareCommandOptions {\n let root = process.cwd();\n let hostname: string | undefined;\n let defaultHostname: string | undefined;\n let prototypeRoot: string | undefined;\n let remote: string | undefined;\n let primaryBranch: string | undefined;\n let rootProvided = false;\n let hostnameProvided = false;\n let defaultHostnameProvided = false;\n let prototypeRootProvided = false;\n let remoteProvided = false;\n let primaryBranchProvided = false;\n\n for (let index = 2; index < argv.length;) {\n const option = argv[index];\n if (option === \"--root\") {\n if (rootProvided) {\n throw new CliSyntaxError(\"The --root option may only be provided once\");\n }\n const parsed = parseRootOption(argv, index);\n root = parsed.root;\n rootProvided = true;\n index = parsed.nextIndex;\n continue;\n }\n if (\n option === \"--prototype-root\" ||\n option === \"--remote\" ||\n option === \"--primary\"\n ) {\n const provided =\n option === \"--prototype-root\"\n ? prototypeRootProvided\n : option === \"--remote\"\n ? remoteProvided\n : primaryBranchProvided;\n if (provided) {\n throw new CliSyntaxError(`${option} may only be provided once`);\n }\n if (option === \"--prototype-root\") prototypeRootProvided = true;\n if (option === \"--remote\") remoteProvided = true;\n if (option === \"--primary\") primaryBranchProvided = true;\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(`${option} requires a value`);\n }\n if (option === \"--prototype-root\") prototypeRoot = value;\n if (option === \"--remote\") remote = value;\n if (option === \"--primary\") primaryBranch = value;\n index += 2;\n continue;\n }\n if (option === \"--hostname\" || option === \"--default-hostname\") {\n const isDefault = option === \"--default-hostname\";\n const provided = isDefault ? defaultHostnameProvided : hostnameProvided;\n if (provided) {\n throw new CliSyntaxError(\n `The ${option} option may only be provided once`,\n );\n }\n const value = argv[index + 1];\n if (!value || value.startsWith(\"--\")) {\n throw new CliSyntaxError(`The ${option} option requires a value`);\n }\n if (isDefault) {\n defaultHostname = value;\n defaultHostnameProvided = true;\n } else {\n hostname = value;\n hostnameProvided = true;\n }\n index += 2;\n continue;\n }\n throw new CliSyntaxError(`Unknown option: ${option}`);\n }\n\n return {\n command: \"branch\",\n root,\n ...(hostname === undefined ? {} : { hostname }),\n ...(defaultHostname === undefined ? {} : { defaultHostname }),\n ...(prototypeRoot === undefined ? {} : { prototypeRoot }),\n ...(remote === undefined ? {} : { remote }),\n ...(primaryBranch === undefined ? {} : { primaryBranch }),\n };\n}\n\nexport function parseArgs(argv: readonly string[]): CliCommandOptions {\n if (argv[0] === \"convert\") return parseConvertArgs(argv);\n if (argv[0] === \"context\") return parseContextArgs(argv);\n if (argv[0] === \"prepare\") return parsePrepareArgs(argv);\n if (argv[0] === \"branch\" && argv[1] === \"prepare\") {\n return parseBranchPrepareArgs(argv);\n }\n throw new CliSyntaxError(\n \"Usage: bonfire convert --root <next-app> --app-id <app-id> [options] | bonfire context sync [--check] [--skip-prototypes] [--root <root>] | bonfire context install [--check] [--force-skills] [--force-mcp] [--force] --app-id <app-id> [--root <root>] | bonfire prepare [--root <application-root>] | bonfire branch prepare --root <application-root> [--hostname <hostname>] [--default-hostname <hostname>] [--prototype-root <root>] [--remote <name>] [--primary <branch>]\",\n );\n}\n\nfunction printContextIssues(result: {\n issues: readonly { kind: string; path: string }[];\n}) {\n for (const issue of result.issues) {\n console.error(`- ${issue.kind}: ${issue.path}`);\n }\n}\n\nfunction printContextSyncSummary(result: ContextSyncResult) {\n if (result.written.length > 0) {\n console.log(`Written: ${result.written.join(\", \")}`);\n }\n if (result.removed.length > 0) {\n console.log(`Removed: ${result.removed.join(\", \")}`);\n }\n}\n\nasync function runContextCommand(\n options: ContextCommandOptions,\n dependencies: CliDependencies,\n): Promise<number> {\n if (options.context === \"install\") {\n if (options.check) {\n const result = await (\n dependencies.contextInstallCheck ?? checkContextInstallation\n )({\n repositoryRoot: options.root,\n appId: options.appId,\n });\n if (!result.ok) {\n console.error(\"Context install check failed:\");\n printContextIssues(result);\n return 1;\n }\n console.log(\"Context install check passed.\");\n return 0;\n }\n const result = await (dependencies.contextInstall ?? installContext)({\n repositoryRoot: options.root,\n appId: options.appId,\n ...(options.forceSkills ? { forceSkills: true } : {}),\n ...(options.forceMcp ? { forceMcp: true } : {}),\n });\n for (const backup of result.backups ?? []) {\n console.log(\n `Backup ${backup.kind}: ${backup.path} -> ${backup.backupPath}`,\n );\n }\n for (const warning of result.warnings ?? []) {\n console.warn(\n `Skipped ${warning.kind} ${warning.name} at ${warning.path}; keeping existing configuration. Use --force-${warning.kind === \"skill\" ? \"skills\" : \"mcp\"} to replace it.`,\n );\n }\n const skills = result.skills\n .filter((skill) => skill.status !== \"skipped\")\n .map((skill) => `${skill.name} (${skill.status})`);\n const mcp = result.mcp\n .filter((server) => server.status !== \"skipped\")\n .map((server) => `${server.name} (${server.status})`);\n console.log(\n skills.length > 0\n ? `Context skills: ${skills.join(\", \")}`\n : result.skills.length === 0\n ? \"No context skills configured.\"\n : \"No context skills installed.\",\n );\n if (mcp.length > 0) console.log(`Context MCP: ${mcp.join(\", \")}`);\n console.log(\n result.warnings?.length\n ? \"Context installation finished with warnings.\"\n : \"Context install complete.\",\n );\n return 0;\n }\n\n if (options.check) {\n const result = await checkContext({\n repositoryRoot: options.root,\n skipPrototypes: options.skipPrototypes,\n });\n if (!result.ok) {\n console.error(\"Context sync check failed:\");\n printContextIssues(result);\n return 1;\n }\n console.log(\"Context sync check passed.\");\n return 0;\n }\n\n const result = await syncContext({\n repositoryRoot: options.root,\n skipPrototypes: options.skipPrototypes,\n });\n if (!result.ok) {\n console.error(\"Context sync failed:\");\n printContextIssues(result);\n return 1;\n }\n printContextSyncSummary(result);\n console.log(\"Context sync complete.\");\n return 0;\n}\n\nexport async function run(\n argv: readonly string[] = process.argv.slice(2),\n dependencies: CliDependencies = {},\n): Promise<number> {\n const isBranchPrepare = argv[0] === \"branch\";\n const isContext = argv[0] === \"context\";\n const isConvert = argv[0] === \"convert\";\n try {\n const options = parseArgs(argv);\n switch (options.command) {\n case \"context\":\n return await runContextCommand(options, dependencies);\n case \"convert\":\n await convert(options);\n return 0;\n case \"branch\":\n return await runBranchPrepare(options, dependencies);\n case \"prepare\": {\n const result = await prepare(options);\n const descriptions = {\n environment: \"the process environment\",\n existing: \".env.local\",\n generated: \"a newly generated value in .env.local\",\n } as const;\n console.log(\n `Bonfire preparation complete; BF_SESSION_SECRET came from ${descriptions[result.source]}.`,\n );\n return 0;\n }\n }\n } catch (error) {\n if (error instanceof CliSyntaxError) {\n console.error(`bonfire: ${error.message}`);\n return 2;\n }\n if (isContext) {\n const message =\n error instanceof Error ? error.message : \"an unknown error occurred\";\n console.error(`bonfire context failed: ${message}`);\n return 1;\n }\n if (isBranchPrepare) {\n const message =\n error instanceof BranchPrepareError\n ? error.message\n : \"Unable to load branch preparation configuration.\";\n console.error(`bonfire branch prepare failed: ${message}`);\n return 1;\n }\n if (isConvert) {\n const message =\n error instanceof Error ? error.message : \"an unknown error occurred\";\n console.error(`bonfire convert failed: ${message}`);\n return 1;\n }\n\n const message =\n error instanceof PrepareError || error instanceof Error\n ? error.message\n : \"an unknown error occurred\";\n console.error(`bonfire prepare failed: ${message}`);\n return 1;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-versions.d.ts","sourceRoot":"","sources":["../src/release-versions.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAC/C,eAAO,MAAM,cAAc,UAAU,CAAC","sourcesContent":["// Generated by scripts/generate-release-versions.mjs during the package build.\nexport const BONFIRE_VERSION = \"0.3.0-alpha.
|
|
1
|
+
{"version":3,"file":"release-versions.d.ts","sourceRoot":"","sources":["../src/release-versions.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAC/C,eAAO,MAAM,cAAc,UAAU,CAAC","sourcesContent":["// Generated by scripts/generate-release-versions.mjs during the package build.\nexport const BONFIRE_VERSION = \"0.3.0-alpha.6\";\nexport const PRESET_VERSION = \"0.1.0\";\n"]}
|
package/dist/release-versions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-versions.js","sourceRoot":"","sources":["../src/release-versions.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC","sourcesContent":["// Generated by scripts/generate-release-versions.mjs during the package build.\nexport const BONFIRE_VERSION = \"0.3.0-alpha.
|
|
1
|
+
{"version":3,"file":"release-versions.js","sourceRoot":"","sources":["../src/release-versions.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC","sourcesContent":["// Generated by scripts/generate-release-versions.mjs during the package build.\nexport const BONFIRE_VERSION = \"0.3.0-alpha.6\";\nexport const PRESET_VERSION = \"0.1.0\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebay-dt/bonfire-cli",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.6",
|
|
4
4
|
"description": "The Bonfire command-line tool.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ebay-dt/bonfire-context": "0.3.0-alpha.
|
|
34
|
+
"@ebay-dt/bonfire-context": "0.3.0-alpha.6",
|
|
35
35
|
"@next/env": "16.3.4",
|
|
36
|
-
"@ebay-dt/bonfire-core": "0.3.0-alpha.
|
|
37
|
-
"@ebay-dt/bonfire-node": "0.3.0-alpha.
|
|
36
|
+
"@ebay-dt/bonfire-core": "0.3.0-alpha.6",
|
|
37
|
+
"@ebay-dt/bonfire-node": "0.3.0-alpha.6"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@repo/eslint-config": "0.0.0",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
|
|
3
|
+
import type { TerminalApp } from "@ebay-dt/bonfire-core";
|
|
4
|
+
import { bonfire } from "@/bonfire";
|
|
5
|
+
|
|
6
|
+
export async function readPreferences() {
|
|
7
|
+
return bonfire.preferences.read();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function updatePreferences(terminal: TerminalApp) {
|
|
11
|
+
return bonfire.preferences.update(terminal);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function availablePreferenceTerminals() {
|
|
15
|
+
return bonfire.preferences.availableTerminals();
|
|
16
|
+
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
PrototypeEnvironment,
|
|
7
7
|
} from "@ebay-dt/bonfire-react";
|
|
8
8
|
import { bonfire } from "@/bonfire";
|
|
9
|
+
import { availablePreferenceTerminals, readPreferences, updatePreferences } from "@/actions/preferences";
|
|
9
10
|
import { openInClaudeCode, openInCursor } from "@/actions/agents";
|
|
10
11
|
|
|
11
12
|
export default async function PrototypesLayout({
|
|
@@ -19,7 +20,15 @@ export default async function PrototypesLayout({
|
|
|
19
20
|
if (prototype === null) notFound();
|
|
20
21
|
|
|
21
22
|
const agentActions = { openInClaudeCode, openInCursor };
|
|
22
|
-
const header =
|
|
23
|
+
const header = (
|
|
24
|
+
<AppHeader
|
|
25
|
+
{...headerProps}
|
|
26
|
+
agentActions={agentActions}
|
|
27
|
+
{...(process.env.NODE_ENV !== "production"
|
|
28
|
+
? { preferencesActions: { read: readPreferences, update: updatePreferences, availableTerminals: availablePreferenceTerminals } }
|
|
29
|
+
: {})}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
23
32
|
|
|
24
33
|
const shell = (
|
|
25
34
|
<PrototypeControlsShell header={header}>{children}</PrototypeControlsShell>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { AppHeader } from "@ebay-dt/bonfire-react";
|
|
3
3
|
import { bonfire } from "@/bonfire";
|
|
4
|
+
import { availablePreferenceTerminals, readPreferences, updatePreferences } from "@/actions/preferences";
|
|
4
5
|
import { openInClaudeCode, openInCursor } from "@/actions/agents";
|
|
5
6
|
|
|
6
7
|
export default async function SystemLayout({
|
|
@@ -13,6 +14,9 @@ export default async function SystemLayout({
|
|
|
13
14
|
<AppHeader
|
|
14
15
|
{...headerProps}
|
|
15
16
|
agentActions={{ openInClaudeCode, openInCursor }}
|
|
17
|
+
{...(process.env.NODE_ENV !== "production"
|
|
18
|
+
? { preferencesActions: { read: readPreferences, update: updatePreferences, availableTerminals: availablePreferenceTerminals } }
|
|
19
|
+
: {})}
|
|
16
20
|
/>
|
|
17
21
|
{children}
|
|
18
22
|
</>
|