@ebay-dt/bonfire-node 0.1.0-alpha.1 → 0.1.0-alpha.3

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.
Files changed (48) hide show
  1. package/README.md +10 -2
  2. package/dist/agent-service.d.ts.map +1 -1
  3. package/dist/agent-service.js.map +1 -1
  4. package/dist/claude.d.ts.map +1 -1
  5. package/dist/claude.js.map +1 -1
  6. package/dist/cursor.d.ts.map +1 -1
  7. package/dist/cursor.js.map +1 -1
  8. package/dist/deployment-provider.d.ts.map +1 -1
  9. package/dist/deployment-provider.js.map +1 -1
  10. package/dist/duplicate.d.ts.map +1 -1
  11. package/dist/duplicate.js.map +1 -1
  12. package/dist/executable.d.ts.map +1 -1
  13. package/dist/executable.js.map +1 -1
  14. package/dist/git-repository.d.ts.map +1 -1
  15. package/dist/git-repository.js.map +1 -1
  16. package/dist/github-cli.d.ts.map +1 -1
  17. package/dist/github-cli.js.map +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal/owned-destination.d.ts.map +1 -1
  21. package/dist/internal/owned-destination.js.map +1 -1
  22. package/dist/internal/prototype-templates.d.ts.map +1 -1
  23. package/dist/internal/prototype-templates.js.map +1 -1
  24. package/dist/internal/utils.d.ts.map +1 -1
  25. package/dist/internal/utils.js.map +1 -1
  26. package/dist/lifecycle/dirty-state.d.ts.map +1 -1
  27. package/dist/lifecycle/dirty-state.js.map +1 -1
  28. package/dist/lifecycle/local-prototype-lifecycle.d.ts.map +1 -1
  29. package/dist/lifecycle/local-prototype-lifecycle.js.map +1 -1
  30. package/dist/lifecycle/operation-gate.d.ts.map +1 -1
  31. package/dist/lifecycle/operation-gate.js.map +1 -1
  32. package/dist/lifecycle/runtime-context.d.ts.map +1 -1
  33. package/dist/lifecycle/runtime-context.js.map +1 -1
  34. package/dist/preferences.d.ts.map +1 -1
  35. package/dist/preferences.js.map +1 -1
  36. package/dist/prepare-prototype-files.d.ts.map +1 -1
  37. package/dist/prepare-prototype-files.js.map +1 -1
  38. package/dist/process-runner.d.ts.map +1 -1
  39. package/dist/process-runner.js.map +1 -1
  40. package/dist/prototype-catalog.d.ts.map +1 -1
  41. package/dist/prototype-catalog.js.map +1 -1
  42. package/dist/prototype-paths.d.ts.map +1 -1
  43. package/dist/prototype-paths.js.map +1 -1
  44. package/dist/scaffold.d.ts.map +1 -1
  45. package/dist/scaffold.js.map +1 -1
  46. package/dist/watcher.d.ts.map +1 -1
  47. package/dist/watcher.js.map +1 -1
  48. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"git-repository.js","sourceRoot":"","sources":["../src/git-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAE7B,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAC3C,MAAM,uBAAuB,GAAG;IAC9B,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,mBAAmB;CAC3B,CAAC;AACF,MAAM,0BAA0B,GAAG;IACjC,mBAAmB;IACnB,yBAAyB;CAC1B,CAAC;AA2DF,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,IAAI,CAAyB;IAC7B,SAAS,CAAS;IAE3B,YAAY,IAA4B,EAAE,SAAiB;QACzD,KAAK,CAAC,yBAAyB,SAAS,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AA2BD,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,KAAK,YAAY,kB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} from \"simple-git\";\nimport {\n asFailure,\n isNonEmptyString,\n isPositiveInteger,\n isRecord,\n} from \"./internal/utils.js\";\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst DEFAULT_MAX_CONCURRENT_PROCESSES = 1;\nconst DEFAULT_COMMIT_IDENTITY = {\n name: \"Bonfire\",\n email: \"bonfire@localhost\",\n};\nconst NOTHING_TO_COMMIT_MESSAGES = [\n \"nothing to commit\",\n \"nothing added to commit\",\n];\n\nexport type GitCommitIdentity = {\n name: string;\n email: string;\n};\n\nexport type GitRepositoryOptions = {\n repositoryRoot: string;\n timeoutMs?: number;\n maxConcurrentProcesses?: number;\n commitIdentity?: GitCommitIdentity;\n};\n\nexport type GitStatusFile = {\n path: string;\n index: string;\n workingDirectory: string;\n from?: string;\n};\n\nexport type GitStatusSnapshot = {\n current: string | null;\n files: readonly GitStatusFile[];\n clean: boolean;\n};\n\nexport type GitRemoteSnapshot = {\n name: string;\n fetchUrl: string | null;\n pushUrl: string | null;\n};\n\nexport type GitBranchSnapshot = {\n current: string | null;\n all: readonly string[];\n};\n\nexport type GitCommitSnapshot = {\n branch: string;\n commit: string;\n root: boolean;\n};\n\nexport type GitCommitResult = GitCommitSnapshot | null;\n\nexport type GitPushResult = {\n remoteStatus: \"pushed\" | \"local-only\";\n};\n\nexport type GitRepositoryErrorKind =\n | \"missing-git\"\n | \"timeout\"\n | \"conflict\"\n | \"command-failure\"\n | \"malformed-output\"\n | \"invalid-configuration\"\n | \"unexpected\";\n\nexport class GitRepositoryError extends Error {\n readonly kind: GitRepositoryErrorKind;\n readonly operation: string;\n\n constructor(kind: GitRepositoryErrorKind, operation: string) {\n super(`Git operation failed: ${operation}`);\n this.name = \"GitRepositoryError\";\n this.kind = kind;\n this.operation = operation;\n }\n}\n\nexport interface GitRepository {\n readonly repositoryRoot: string;\n currentBranch(): Promise<string>;\n status(pathspecs?: readonly string[]): Promise<GitStatusSnapshot>;\n remotes(): Promise<readonly GitRemoteSnapshot[]>;\n branches(): Promise<GitBranchSnapshot>;\n fetch(remote: string, branch: string): Promise<void>;\n checkout(args: readonly string[]): Promise<void>;\n checkoutLocalBranch(branch: string): Promise<void>;\n merge(args: readonly string[]): Promise<void>;\n add(pathspecs: readonly string[]): Promise<void>;\n commit(\n message: string,\n pathspecs?: readonly string[],\n ): Promise<GitCommitResult>;\n push(\n remote: string,\n branch: string,\n options?: readonly string[],\n ): Promise<void>;\n restore(pathspecs: readonly string[]): Promise<void>;\n clean(mode: string, pathspecs: readonly string[]): Promise<void>;\n raw(args: readonly string[]): Promise<string>;\n}\n\nfunction classifyError(error: unknown): GitRepositoryErrorKind {\n if (error instanceof GitRepositoryError) return error.kind;\n\n const failure = asFailure(error);\n const message = typeof failure.message === \"string\" ? failure.message : \"\";\n const normalized = message.toLowerCase();\n\n if (failure.code === \"ENOENT\" || normalized.includes(\"enoent\")) {\n return \"missing-git\";\n }\n\n if (\n failure.code === \"ETIMEDOUT\" ||\n failure.killed === true ||\n failure.signal === \"SIGTERM\" ||\n normalized.includes(\"timed out\") ||\n normalized.includes(\"timeout\")\n ) {\n return \"timeout\";\n }\n\n if (\n normalized.includes(\"conflict\") ||\n normalized.includes(\"would be overwritten\") ||\n normalized.includes(\"unmerged paths\")\n ) {\n return \"conflict\";\n }\n\n if (isRecord(error) || error instanceof Error) return \"command-failure\";\n return \"unexpected\";\n}\n\nfunction normalizeError(operation: string, error: unknown) {\n if (error instanceof GitRepositoryError) return error;\n return new GitRepositoryError(classifyError(error), operation);\n}\n\nfunction assertValidPositiveInteger(value: number, option: string) {\n if (!isPositiveInteger(value)) {\n throw new GitRepositoryError(\"invalid-configuration\", option);\n }\n}\n\nfunction assertValidBranchName(value: string, option: string) {\n if (\n !isNonEmptyString(value) ||\n value.startsWith(\"-\") ||\n value.includes(\"\\0\") ||\n /\\s/u.test(value) ||\n value.includes(\"@{\") ||\n value.split(/[\\\\/]/u).some((segment) => segment === \"..\")\n ) {\n throw new GitRepositoryError(\"invalid-configuration\", option);\n }\n}\n\nfunction assertValidPathspec(pathspec: string) {\n if (\n !isNonEmptyString(pathspec) ||\n isAbsolute(pathspec) ||\n /^[A-Za-z]:[\\\\/]/u.test(pathspec) ||\n pathspec.startsWith(\"\\\\\") ||\n pathspec.startsWith(\"-\") ||\n pathspec.startsWith(\":\") ||\n pathspec.includes(\"\\0\") ||\n pathspec.includes(\"*\") ||\n pathspec.includes(\"?\") ||\n pathspec.includes(\"[\") ||\n pathspec.includes(\"]\") ||\n pathspec === \".\" ||\n pathspec.split(/[\\\\/]/u).some((segment) => segment === \"..\")\n ) {\n throw new GitRepositoryError(\"invalid-configuration\", \"pathspec\");\n }\n}\n\nfunction assertValidPathspecs(pathspecs: readonly string[]) {\n if (pathspecs.length === 0) {\n throw new GitRepositoryError(\"invalid-configuration\", \"pathspec\");\n }\n for (const pathspec of pathspecs) assertValidPathspec(pathspec);\n return [...pathspecs];\n}\n\nfunction assertValidArguments(args: readonly string[], operation: string) {\n if (\n args.some(\n (argument) => !isNonEmptyString(argument) || argument.includes(\"\\0\"),\n )\n ) {\n throw new GitRepositoryError(\"invalid-configuration\", operation);\n }\n return [...args];\n}\n\nfunction isNothingToCommit(error: unknown) {\n const failure = asFailure(error);\n const message = typeof failure.message === \"string\" ? failure.message : \"\";\n return NOTHING_TO_COMMIT_MESSAGES.some((needle) =>\n message.toLowerCase().includes(needle),\n );\n}\n\nclass SimpleGitRepository implements GitRepository {\n readonly repositoryRoot: string;\n readonly #git;\n\n constructor(options: Required<GitRepositoryOptions>) {\n this.repositoryRoot = options.repositoryRoot;\n this.#git = simpleGit(options.repositoryRoot, {\n baseDir: options.repositoryRoot,\n maxConcurrentProcesses: options.maxConcurrentProcesses,\n config: [\n `user.name=${options.commitIdentity.name}`,\n `user.email=${options.commitIdentity.email}`,\n ],\n timeout: { block: options.timeoutMs },\n });\n }\n\n async #execute<Value>(operation: string, action: () => Promise<Value>) {\n try {\n return await action();\n } catch (error) {\n throw normalizeError(operation, error);\n }\n }\n\n async currentBranch() {\n const result = await this.#execute(\"current-branch\", () =>\n this.#git.revparse([\"--abbrev-ref\", \"HEAD\"]),\n );\n if (!isNonEmptyString(result) || result.trim().length === 0) {\n throw new GitRepositoryError(\"malformed-output\", \"current-branch\");\n }\n return result.trim();\n }\n\n async status(pathspecs?: readonly string[]) {\n const validatedPathspecs =\n pathspecs === undefined ? undefined : assertValidPathspecs(pathspecs);\n const result = await this.#execute(\"status\", () =>\n validatedPathspecs === undefined\n ? this.#git.status()\n : this.#git.status([\"--\", ...validatedPathspecs]),\n );\n\n if (\n !isRecord(result) ||\n !Array.isArray(result.files) ||\n (typeof result.current !== \"string\" && result.current !== null) ||\n typeof result.isClean !== \"function\"\n ) {\n throw new GitRepositoryError(\"malformed-output\", \"status\");\n }\n\n const files: GitStatusFile[] = [];\n for (const file of result.files) {\n if (!isRecord(file)) {\n throw new GitRepositoryError(\"malformed-output\", \"status\");\n }\n if (\n typeof file.path !== \"string\" ||\n typeof file.index !== \"string\" ||\n typeof file.working_dir !== \"string\"\n ) {\n throw new GitRepositoryError(\"malformed-output\", \"status\");\n }\n\n files.push({\n path: file.path,\n index: file.index,\n workingDirectory: file.working_dir,\n ...(typeof file.from === \"string\" ? { from: file.from } : {}),\n });\n }\n\n let clean: boolean;\n try {\n clean = result.isClean();\n } catch {\n throw new GitRepositoryError(\"malformed-output\", \"status\");\n }\n if (typeof clean !== \"boolean\") {\n throw new GitRepositoryError(\"malformed-output\", \"status\");\n }\n\n return {\n current: result.current,\n files,\n clean,\n } satisfies GitStatusSnapshot;\n }\n\n async remotes() {\n const result = await this.#execute(\"remotes\", () =>\n this.#git.getRemotes(true),\n );\n if (!Array.isArray(result)) {\n throw new GitRepositoryError(\"malformed-output\", \"remotes\");\n }\n\n const remotes: GitRemoteSnapshot[] = [];\n for (const remote of result) {\n if (!isRecord(remote) || typeof remote.name !== \"string\") {\n throw new GitRepositoryError(\"malformed-output\", \"remotes\");\n }\n const refs = remote.refs;\n if (!isRecord(refs)) {\n throw new GitRepositoryError(\"malformed-output\", \"remotes\");\n }\n if (typeof refs.fetch !== \"string\" || typeof refs.push !== \"string\") {\n throw new GitRepositoryError(\"malformed-output\", \"remotes\");\n }\n\n remotes.push({\n name: remote.name,\n fetchUrl: refs.fetch,\n pushUrl: refs.push,\n });\n }\n return remotes;\n }\n\n async branches() {\n const result = await this.#execute(\"branches\", () =>\n this.#git.branch([\"-a\"]),\n );\n if (\n !isRecord(result) ||\n !Array.isArray(result.all) ||\n (typeof result.current !== \"string\" && result.current !== null) ||\n !result.all.every((branch) => typeof branch === \"string\")\n ) {\n throw new GitRepositoryError(\"malformed-output\", \"branches\");\n }\n\n return {\n current: result.current,\n all: [...result.all],\n } satisfies GitBranchSnapshot;\n }\n\n async fetch(remote: string, branch: string) {\n assertValidBranchName(remote, \"remote\");\n assertValidBranchName(branch, \"branch\");\n await this.#execute(\"fetch\", () => this.#git.fetch(remote, branch));\n }\n\n async checkout(args: readonly string[]) {\n const validatedArgs = assertValidArguments(args, \"checkout\");\n await this.#execute(\"checkout\", () => this.#git.checkout(validatedArgs));\n }\n\n async checkoutLocalBranch(branch: string) {\n assertValidBranchName(branch, \"branch\");\n await this.#execute(\"checkout-local-branch\", () =>\n this.#git.checkoutLocalBranch(branch),\n );\n }\n\n async merge(args: readonly string[]) {\n const validatedArgs = assertValidArguments(args, \"merge\");\n await this.#execute(\"merge\", () => this.#git.merge(validatedArgs));\n }\n\n async add(pathspecs: readonly string[]) {\n const validatedPathspecs = assertValidPathspecs(pathspecs);\n await this.#execute(\"add\", () => this.#git.add(validatedPathspecs));\n }\n\n async commit(message: string, pathspecs?: readonly string[]) {\n if (!isNonEmptyString(message)) {\n throw new GitRepositoryError(\"invalid-configuration\", \"commit-message\");\n }\n const validatedPathspecs =\n pathspecs === undefined ? undefined : assertValidPathspecs(pathspecs);\n\n let result: unknown;\n try {\n result =\n validatedPathspecs === undefined\n ? await this.#git.commit(message)\n : await this.#git.commit(message, [...validatedPathspecs]);\n } catch (error) {\n if (isNothingToCommit(error)) return null;\n throw normalizeError(\"commit\", error);\n }\n if (\n !isRecord(result) ||\n typeof result.branch !== \"string\" ||\n typeof result.commit !== \"string\" ||\n typeof result.root !== \"boolean\"\n ) {\n throw new GitRepositoryError(\"malformed-output\", \"commit\");\n }\n\n return {\n branch: result.branch,\n commit: result.commit,\n root: result.root,\n } satisfies GitCommitSnapshot;\n }\n\n async push(remote: string, branch: string, options: readonly string[] = []) {\n assertValidBranchName(remote, \"remote\");\n assertValidBranchName(branch, \"branch\");\n const validatedOptions = assertValidArguments(options, \"push\");\n await this.#execute(\"push\", () =>\n this.#git.push(remote, branch, validatedOptions),\n );\n }\n\n async restore(pathspecs: readonly string[]) {\n const validatedPathspecs = assertValidPathspecs(pathspecs);\n await this.#execute(\"restore\", () =>\n this.#git.checkout([\"--\", ...validatedPathspecs]),\n );\n }\n\n async clean(mode: string, pathspecs: readonly string[]) {\n if (!/^[a-z]+$/u.test(mode)) {\n throw new GitRepositoryError(\"invalid-configuration\", \"clean-mode\");\n }\n const validatedPathspecs = assertValidPathspecs(pathspecs);\n await this.#execute(\"clean\", () =>\n this.#git.clean(mode, validatedPathspecs),\n );\n }\n\n async raw(args: readonly string[]) {\n const validatedArgs = assertValidArguments(args, \"raw\");\n const result = await this.#execute(\"raw\", () =>\n this.#git.raw(validatedArgs),\n );\n if (typeof result !== \"string\") {\n throw new GitRepositoryError(\"malformed-output\", \"raw\");\n }\n return result;\n }\n}\n\nexport type PrepareIdentityBranchOptions = {\n identityBranch: string;\n primaryBranch: string;\n remote: string;\n};\n\nexport async function prepareIdentityBranch(\n repository: GitRepository,\n options: PrepareIdentityBranchOptions,\n): Promise<void> {\n assertValidBranchName(options.identityBranch, \"identity-branch\");\n assertValidBranchName(options.primaryBranch, \"primary-branch\");\n assertValidBranchName(options.remote, \"remote\");\n\n const currentBranch = await repository.currentBranch();\n if (currentBranch === options.identityBranch) return;\n\n const status = await repository.status();\n if (!status.clean) {\n throw new GitRepositoryError(\"conflict\", \"prepare-identity-branch\");\n }\n\n const remotes = await repository.remotes();\n const configuredRemote = remotes.some(\n (remote) => remote.name === options.remote,\n );\n if (configuredRemote) {\n await repository.fetch(options.remote, options.primaryBranch);\n }\n\n const branches = await repository.branches();\n const hasLocalPrimary = branches.all.includes(options.primaryBranch);\n const remotePrimary = `remotes/${options.remote}/${options.primaryBranch}`;\n const hasRemotePrimary =\n configuredRemote && branches.all.includes(remotePrimary);\n if (!hasLocalPrimary && !hasRemotePrimary) {\n throw new GitRepositoryError(\"command-failure\", \"primary-branch\");\n }\n\n if (hasLocalPrimary) {\n await repository.checkout([options.primaryBranch]);\n } else {\n await repository.checkout([\n \"-b\",\n options.primaryBranch,\n \"--track\",\n `${options.remote}/${options.primaryBranch}`,\n ]);\n }\n if (configuredRemote) {\n await repository.merge([\n `${options.remote}/${options.primaryBranch}`,\n \"--ff-only\",\n ]);\n }\n\n if (branches.all.includes(options.identityBranch)) {\n await repository.checkout([options.identityBranch]);\n return;\n }\n\n const remoteBranch = `remotes/${options.remote}/${options.identityBranch}`;\n if (branches.all.includes(remoteBranch)) {\n await repository.checkout([\n \"-b\",\n options.identityBranch,\n \"--track\",\n `${options.remote}/${options.identityBranch}`,\n ]);\n return;\n }\n\n await repository.checkoutLocalBranch(options.identityBranch);\n}\n\nexport async function commitPath(\n repository: GitRepository,\n pathspec: string,\n message: string,\n): Promise<GitCommitResult> {\n const validatedPathspecs = assertValidPathspecs([pathspec]);\n await repository.add(validatedPathspecs);\n return repository.commit(message, validatedPathspecs);\n}\n\nexport async function discardPath(\n repository: GitRepository,\n pathspec: string,\n): Promise<void> {\n const validatedPathspec = assertValidPathspecs([pathspec])[0]!;\n await repository.raw([\"reset\", \"HEAD\", \"--\", validatedPathspec]);\n await repository.restore([validatedPathspec]);\n await repository.clean(\"fd\", [validatedPathspec]);\n}\n\nexport async function pushBranch(\n repository: GitRepository,\n remote: string,\n branch: string,\n): Promise<GitPushResult> {\n assertValidBranchName(remote, \"remote\");\n assertValidBranchName(branch, \"branch\");\n\n const hasRemote = (await repository.remotes()).some(\n (configuredRemote) => configuredRemote.name === remote,\n );\n if (!hasRemote) return { remoteStatus: \"local-only\" };\n\n await repository.push(remote, branch, [\"--set-upstream\"]);\n return { remoteStatus: \"pushed\" };\n}\n\nexport function createGitRepository(\n options: GitRepositoryOptions,\n): GitRepository {\n if (!isAbsolute(options.repositoryRoot)) {\n throw new GitRepositoryError(\"invalid-configuration\", \"repository-root\");\n }\n\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const maxConcurrentProcesses =\n options.maxConcurrentProcesses ?? DEFAULT_MAX_CONCURRENT_PROCESSES;\n const commitIdentity = options.commitIdentity ?? DEFAULT_COMMIT_IDENTITY;\n\n assertValidPositiveInteger(timeoutMs, \"timeout\");\n assertValidPositiveInteger(\n maxConcurrentProcesses,\n \"max-concurrent-processes\",\n );\n\n return new SimpleGitRepository({\n repositoryRoot: options.repositoryRoot,\n timeoutMs,\n maxConcurrentProcesses,\n commitIdentity,\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"github-cli.d.ts","sourceRoot":"","sources":["../src/github-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,qBAAqB,CAAC;AAsB7B,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAE7E,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAEtC,YAAY,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,oBAAgC,EAIpE;CACF;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAA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,EAAE,MAAM,CAAC;IAI1B,YAAY,OAAO,EAAE,sBAAsB,EAG1C;IAEK,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,CA+BxC;IAEK,aAAa,+BA6GlB;CACF","sourcesContent":["import {\n parseBonfireIdentity,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n defaultGitHubCliProcessRunner,\n type GitHubCliChildProcess,\n type GitHubCliProcessRunner,\n} from \"./process-runner.js\";\n\nconst GH_EXECUTABLE = \"gh\";\nconst IDENTITY_TIMEOUT = 10_000;\nconst IDENTITY_MAX_BUFFER = 1024 * 1024;\nconst DEVICE_LOGIN_TIMEOUT = 10_000;\nconst ACTIVE_LOGIN_WINDOW = 10 * 60 * 1000;\nconst GH_LOGIN_CODE_LABEL_PATTERN = /\\bone[-\\s]time\\s+code\\b/i;\nconst GH_DEVICE_CODE_PATTERN = /\\b[A-Za-z0-9]+(?:-[A-Za-z0-9]+)+\\b/;\nconst ANSI_ESCAPE_PATTERN = new RegExp(\n `${String.fromCharCode(27)}\\\\[[0-?]*[ -/]*[@-~]`,\n \"g\",\n);\n\ntype GitHubCliFailure = {\n code?: unknown;\n killed?: unknown;\n signal?: unknown;\n stderr?: unknown;\n stdout?: unknown;\n};\n\nexport type GitHubCliErrorReason = \"missing\" | \"unauthenticated\" | \"unknown\";\n\nexport class GitHubCliError extends Error {\n readonly reason: GitHubCliErrorReason;\n\n constructor(message: string, reason: GitHubCliErrorReason = \"unknown\") {\n super(message);\n this.name = \"GitHubCliError\";\n this.reason = reason;\n }\n}\n\nexport type GitHubCliWebLogin = {\n code: string | null;\n deviceUrl: string;\n};\n\nexport type GitHubCliClientOptions = {\n hostname: string;\n process?: GitHubCliProcessRunner;\n};\n\nexport interface GitHubCliClientLike {\n getUser(): Promise<BonfireIdentity>;\n startWebLogin(): Promise<GitHubCliWebLogin>;\n}\n\ntype ActiveLogin = {\n child: GitHubCliChildProcess;\n code: string | null;\n settled: boolean;\n startedAt: number;\n promise: Promise<GitHubCliWebLogin>;\n};\n\nfunction asFailure(error: unknown): GitHubCliFailure {\n return error && typeof error === \"object\" ? (error as GitHubCliFailure) : {};\n}\n\nfunction outputFrom(value: unknown): string {\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction extractDeviceCode(output: string): string | null {\n const cleanOutput = output.replace(ANSI_ESCAPE_PATTERN, \"\").replace(/\\r/g, \"\");\n const lines = cleanOutput.split(\"\\n\");\n\n for (let index = 0; index < lines.length; index += 1) {\n const line = lines[index];\n if (line === undefined) continue;\n const label = line.match(GH_LOGIN_CODE_LABEL_PATTERN);\n if (!label || label.index === undefined) continue;\n\n const remainder = line.slice(label.index + label[0].length);\n const match =\n remainder.match(GH_DEVICE_CODE_PATTERN) ??\n lines[index + 1]?.match(GH_DEVICE_CODE_PATTERN);\n if (match) return match[0];\n }\n\n return null;\n}\n\nfunction projectIdentityFields(value: unknown) {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return value;\n }\n\n const record = value as Record<string, unknown>;\n return {\n login: record.login,\n ...(Object.hasOwn(record, \"name\") ? { name: record.name } : {}),\n avatar_url: record.avatar_url,\n };\n}\n\nfunction isUnauthenticatedOutput(output: string): boolean {\n const normalized = output.toLowerCase();\n return (\n normalized.includes(\"gh auth login\") ||\n normalized.includes(\"not logged into\") ||\n normalized.includes(\"authentication required\") ||\n normalized.includes(\"must authenticate\") ||\n /\\b(?:http(?:\\s+status)?\\s*)?401\\b/.test(normalized)\n );\n}\n\nfunction describeFailure(failure: GitHubCliFailure): string {\n if (failure.code === \"ENOENT\") {\n return \"GitHub CLI (`gh`) is not installed or is not available on PATH.\";\n }\n\n if (\n failure.code === \"ETIMEDOUT\" ||\n failure.killed === true ||\n failure.signal === \"SIGTERM\"\n ) {\n return \"GitHub CLI command timed out.\";\n }\n\n if (failure.code === \"ERR_CHILD_PROCESS_STDIO_MAXBUFFER\") {\n return \"GitHub CLI output exceeded the allowed limit.\";\n }\n\n return \"GitHub CLI command failed.\";\n}\n\nfunction commandFailure(error: unknown, hostname: string): GitHubCliError {\n const failure = asFailure(error);\n const output = `${outputFrom(failure.stdout)}\\n${outputFrom(failure.stderr)}`;\n const guidance = ` Run: gh auth login --hostname ${hostname}`;\n\n if (failure.code === \"ENOENT\") {\n return new GitHubCliError(\n `GitHub CLI (\\`gh\\`) is not installed or is not available on PATH.${guidance}`,\n \"missing\",\n );\n }\n\n if (isUnauthenticatedOutput(output)) {\n return new GitHubCliError(\n `GitHub CLI is not authenticated for ${hostname}.${guidance}`,\n \"unauthenticated\",\n );\n }\n\n return new GitHubCliError(`${describeFailure(failure)}${guidance}`);\n}\n\nexport class GitHubCliClient implements GitHubCliClientLike {\n readonly hostname: string;\n readonly #process: GitHubCliProcessRunner;\n #activeLogin: ActiveLogin | null = null;\n\n constructor(options: GitHubCliClientOptions) {\n this.hostname = options.hostname;\n this.#process = options.process ?? defaultGitHubCliProcessRunner;\n }\n\n async getUser(): Promise<BonfireIdentity> {\n const args = [\"api\", \"--hostname\", this.hostname, \"user\"];\n let result;\n\n try {\n result = await this.#process.execFile(GH_EXECUTABLE, args, {\n timeout: IDENTITY_TIMEOUT,\n maxBuffer: IDENTITY_MAX_BUFFER,\n });\n } catch (error) {\n throw commandFailure(error, this.hostname);\n }\n\n if (isUnauthenticatedOutput(`${result.stdout}\\n${result.stderr}`)) {\n throw commandFailure(result, this.hostname);\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(result.stdout);\n } catch {\n throw new GitHubCliError(\n `GitHub CLI returned malformed user data. Run: gh auth login --hostname ${this.hostname}`,\n );\n }\n\n try {\n return parseBonfireIdentity(projectIdentityFields(parsed));\n } catch {\n throw new GitHubCliError(\"GitHub CLI returned an invalid user profile.\");\n }\n }\n\n async startWebLogin() {\n const activeLogin = this.#activeLogin;\n if (activeLogin) {\n const withinReuseWindow =\n Date.now() - activeLogin.startedAt < ACTIVE_LOGIN_WINDOW;\n if (\n !activeLogin.settled ||\n (activeLogin.code !== null && withinReuseWindow)\n ) {\n return activeLogin.promise;\n }\n\n try {\n activeLogin.child.kill(\"SIGTERM\");\n } catch {\n throw new GitHubCliError(\n \"The previous GitHub CLI login could not be terminated.\",\n );\n }\n this.#activeLogin = null;\n }\n\n const spawn = this.#process.spawn;\n if (!spawn) {\n throw new GitHubCliError(\"GitHub CLI device login is unavailable.\");\n }\n\n let child: GitHubCliChildProcess;\n try {\n child = spawn(\n GH_EXECUTABLE,\n [\n \"auth\",\n \"login\",\n \"--hostname\",\n this.hostname,\n \"--web\",\n \"--clipboard\",\n \"--git-protocol\",\n \"ssh\",\n \"--skip-ssh-key\",\n ],\n { stdio: [\"ignore\", \"pipe\", \"pipe\"] },\n );\n } catch (error) {\n throw commandFailure(error, this.hostname);\n }\n\n let resolveLogin!: (login: GitHubCliWebLogin) => void;\n let rejectLogin!: (error: GitHubCliError) => void;\n const promise = new Promise<GitHubCliWebLogin>((resolve, reject) => {\n resolveLogin = resolve;\n rejectLogin = reject;\n });\n const login: ActiveLogin = {\n child,\n code: null,\n settled: false,\n startedAt: Date.now(),\n promise,\n };\n this.#activeLogin = login;\n\n let output = \"\";\n let settled = false;\n let timer: ReturnType<typeof setTimeout>;\n\n const clearActiveLogin = () => {\n if (this.#activeLogin?.child === child) this.#activeLogin = null;\n };\n\n const settle = (code: string | null) => {\n if (settled) return;\n settled = true;\n login.code = code;\n login.settled = true;\n clearTimeout(timer);\n resolveLogin({\n code,\n deviceUrl: `https://${this.hostname}/login/device`,\n });\n };\n\n const fail = (error: unknown) => {\n clearActiveLogin();\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n rejectLogin(commandFailure(error, this.hostname));\n };\n\n const inspectOutput = (chunk: string | Uint8Array) => {\n output +=\n typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString(\"utf8\");\n const code = extractDeviceCode(output);\n if (code) settle(code);\n };\n\n timer = setTimeout(() => settle(null), DEVICE_LOGIN_TIMEOUT);\n timer.unref?.();\n child.stdout?.on(\"data\", inspectOutput);\n child.stderr?.on(\"data\", inspectOutput);\n child.once(\"error\", fail);\n child.once(\"close\", () => {\n if (!settled) settle(null);\n clearActiveLogin();\n });\n\n return promise;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"github-cli.js","sourceRoot":"","sources":["../src/github-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAErB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,6BAA6B,GAG9B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,mBAAmB,GAAG,IAAI,GAAG,IAAI,CAAC;AACxC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC3C,MAAM,2BAA2B,GAAG,0BAA0B,CAAC;AAC/D,MAAM,sBAAsB,GAAG,oCAAoC,CAAC;AACpE,MAAM,mBAAmB,GAAG,IAAI,MAAM,CACpC,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,sBAAsB,EAChD,GAAG,CACJ,CAAC;AAYF,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,MAAM,CAAuB;IAEtC,YAAY,OAAe,EAAE,MAAM,GAAyB,SAAS;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAyBD,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,KAA0B,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/E,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,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C;YAC3B,gBAAgB,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import {\n parseBonfireIdentity,\n type BonfireIdentity,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n defaultGitHubCliProcessRunner,\n type GitHubCliChildProcess,\n type GitHubCliProcessRunner,\n} from \"./process-runner.js\";\n\nconst GH_EXECUTABLE = \"gh\";\nconst IDENTITY_TIMEOUT = 10_000;\nconst IDENTITY_MAX_BUFFER = 1024 * 1024;\nconst DEVICE_LOGIN_TIMEOUT = 10_000;\nconst ACTIVE_LOGIN_WINDOW = 10 * 60 * 1000;\nconst GH_LOGIN_CODE_LABEL_PATTERN = /\\bone[-\\s]time\\s+code\\b/i;\nconst GH_DEVICE_CODE_PATTERN = /\\b[A-Za-z0-9]+(?:-[A-Za-z0-9]+)+\\b/;\nconst ANSI_ESCAPE_PATTERN = new RegExp(\n `${String.fromCharCode(27)}\\\\[[0-?]*[ -/]*[@-~]`,\n \"g\",\n);\n\ntype GitHubCliFailure = {\n code?: unknown;\n killed?: unknown;\n signal?: unknown;\n stderr?: unknown;\n stdout?: unknown;\n};\n\nexport type GitHubCliErrorReason = \"missing\" | \"unauthenticated\" | \"unknown\";\n\nexport class GitHubCliError extends Error {\n readonly reason: GitHubCliErrorReason;\n\n constructor(message: string, reason: GitHubCliErrorReason = \"unknown\") {\n super(message);\n this.name = \"GitHubCliError\";\n this.reason = reason;\n }\n}\n\nexport type GitHubCliWebLogin = {\n code: string | null;\n deviceUrl: string;\n};\n\nexport type GitHubCliClientOptions = {\n hostname: string;\n process?: GitHubCliProcessRunner;\n};\n\nexport interface GitHubCliClientLike {\n getUser(): Promise<BonfireIdentity>;\n startWebLogin(): Promise<GitHubCliWebLogin>;\n}\n\ntype ActiveLogin = {\n child: GitHubCliChildProcess;\n code: string | null;\n settled: boolean;\n startedAt: number;\n promise: Promise<GitHubCliWebLogin>;\n};\n\nfunction asFailure(error: unknown): GitHubCliFailure {\n return error && typeof error === \"object\" ? (error as GitHubCliFailure) : {};\n}\n\nfunction outputFrom(value: unknown): string {\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction extractDeviceCode(output: string): string | null {\n const cleanOutput = output.replace(ANSI_ESCAPE_PATTERN, \"\").replace(/\\r/g, \"\");\n const lines = cleanOutput.split(\"\\n\");\n\n for (let index = 0; index < lines.length; index += 1) {\n const line = lines[index];\n if (line === undefined) continue;\n const label = line.match(GH_LOGIN_CODE_LABEL_PATTERN);\n if (!label || label.index === undefined) continue;\n\n const remainder = line.slice(label.index + label[0].length);\n const match =\n remainder.match(GH_DEVICE_CODE_PATTERN) ??\n lines[index + 1]?.match(GH_DEVICE_CODE_PATTERN);\n if (match) return match[0];\n }\n\n return null;\n}\n\nfunction projectIdentityFields(value: unknown) {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return value;\n }\n\n const record = value as Record<string, unknown>;\n return {\n login: record.login,\n ...(Object.hasOwn(record, \"name\") ? { name: record.name } : {}),\n avatar_url: record.avatar_url,\n };\n}\n\nfunction isUnauthenticatedOutput(output: string): boolean {\n const normalized = output.toLowerCase();\n return (\n normalized.includes(\"gh auth login\") ||\n normalized.includes(\"not logged into\") ||\n normalized.includes(\"authentication required\") ||\n normalized.includes(\"must authenticate\") ||\n /\\b(?:http(?:\\s+status)?\\s*)?401\\b/.test(normalized)\n );\n}\n\nfunction describeFailure(failure: GitHubCliFailure): string {\n if (failure.code === \"ENOENT\") {\n return \"GitHub CLI (`gh`) is not installed or is not available on PATH.\";\n }\n\n if (\n failure.code === \"ETIMEDOUT\" ||\n failure.killed === true ||\n failure.signal === \"SIGTERM\"\n ) {\n return \"GitHub CLI command timed out.\";\n }\n\n if (failure.code === \"ERR_CHILD_PROCESS_STDIO_MAXBUFFER\") {\n return \"GitHub CLI output exceeded the allowed limit.\";\n }\n\n return \"GitHub CLI command failed.\";\n}\n\nfunction commandFailure(error: unknown, hostname: string): GitHubCliError {\n const failure = asFailure(error);\n const output = `${outputFrom(failure.stdout)}\\n${outputFrom(failure.stderr)}`;\n const guidance = ` Run: gh auth login --hostname ${hostname}`;\n\n if (failure.code === \"ENOENT\") {\n return new GitHubCliError(\n `GitHub CLI (\\`gh\\`) is not installed or is not available on PATH.${guidance}`,\n \"missing\",\n );\n }\n\n if (isUnauthenticatedOutput(output)) {\n return new GitHubCliError(\n `GitHub CLI is not authenticated for ${hostname}.${guidance}`,\n \"unauthenticated\",\n );\n }\n\n return new GitHubCliError(`${describeFailure(failure)}${guidance}`);\n}\n\nexport class GitHubCliClient implements GitHubCliClientLike {\n readonly hostname: string;\n readonly #process: GitHubCliProcessRunner;\n #activeLogin: ActiveLogin | null = null;\n\n constructor(options: GitHubCliClientOptions) {\n this.hostname = options.hostname;\n this.#process = options.process ?? defaultGitHubCliProcessRunner;\n }\n\n async getUser(): Promise<BonfireIdentity> {\n const args = [\"api\", \"--hostname\", this.hostname, \"user\"];\n let result;\n\n try {\n result = await this.#process.execFile(GH_EXECUTABLE, args, {\n timeout: IDENTITY_TIMEOUT,\n maxBuffer: IDENTITY_MAX_BUFFER,\n });\n } catch (error) {\n throw commandFailure(error, this.hostname);\n }\n\n if (isUnauthenticatedOutput(`${result.stdout}\\n${result.stderr}`)) {\n throw commandFailure(result, this.hostname);\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(result.stdout);\n } catch {\n throw new GitHubCliError(\n `GitHub CLI returned malformed user data. Run: gh auth login --hostname ${this.hostname}`,\n );\n }\n\n try {\n return parseBonfireIdentity(projectIdentityFields(parsed));\n } catch {\n throw new GitHubCliError(\"GitHub CLI returned an invalid user profile.\");\n }\n }\n\n async startWebLogin() {\n const activeLogin = this.#activeLogin;\n if (activeLogin) {\n const withinReuseWindow =\n Date.now() - activeLogin.startedAt < ACTIVE_LOGIN_WINDOW;\n if (\n !activeLogin.settled ||\n (activeLogin.code !== null && withinReuseWindow)\n ) {\n return activeLogin.promise;\n }\n\n try {\n activeLogin.child.kill(\"SIGTERM\");\n } catch {\n throw new GitHubCliError(\n \"The previous GitHub CLI login could not be terminated.\",\n );\n }\n this.#activeLogin = null;\n }\n\n const spawn = this.#process.spawn;\n if (!spawn) {\n throw new GitHubCliError(\"GitHub CLI device login is unavailable.\");\n }\n\n let child: GitHubCliChildProcess;\n try {\n child = spawn(\n GH_EXECUTABLE,\n [\n \"auth\",\n \"login\",\n \"--hostname\",\n this.hostname,\n \"--web\",\n \"--clipboard\",\n \"--git-protocol\",\n \"ssh\",\n \"--skip-ssh-key\",\n ],\n { stdio: [\"ignore\", \"pipe\", \"pipe\"] },\n );\n } catch (error) {\n throw commandFailure(error, this.hostname);\n }\n\n let resolveLogin!: (login: GitHubCliWebLogin) => void;\n let rejectLogin!: (error: GitHubCliError) => void;\n const promise = new Promise<GitHubCliWebLogin>((resolve, reject) => {\n resolveLogin = resolve;\n rejectLogin = reject;\n });\n const login: ActiveLogin = {\n child,\n code: null,\n settled: false,\n startedAt: Date.now(),\n promise,\n };\n this.#activeLogin = login;\n\n let output = \"\";\n let settled = false;\n let timer: ReturnType<typeof setTimeout>;\n\n const clearActiveLogin = () => {\n if (this.#activeLogin?.child === child) this.#activeLogin = null;\n };\n\n const settle = (code: string | null) => {\n if (settled) return;\n settled = true;\n login.code = code;\n login.settled = true;\n clearTimeout(timer);\n resolveLogin({\n code,\n deviceUrl: `https://${this.hostname}/login/device`,\n });\n };\n\n const fail = (error: unknown) => {\n clearActiveLogin();\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n rejectLogin(commandFailure(error, this.hostname));\n };\n\n const inspectOutput = (chunk: string | Uint8Array) => {\n output +=\n typeof chunk === \"string\" ? chunk : Buffer.from(chunk).toString(\"utf8\");\n const code = extractDeviceCode(output);\n if (code) settle(code);\n };\n\n timer = setTimeout(() => settle(null), DEVICE_LOGIN_TIMEOUT);\n timer.unref?.();\n child.stdout?.on(\"data\", inspectOutput);\n child.stderr?.on(\"data\", inspectOutput);\n child.once(\"error\", fail);\n child.once(\"close\", () => {\n if (!settled) settle(null);\n clearActiveLogin();\n });\n\n return promise;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,+BAA+B,EACpC,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,EACf,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,GACvB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gBAAgB,EAChB,KAAK,oBAAoB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,4BAA4B,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,GACnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,GAClC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,KAAK,gBAAgB,E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EAC9B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,GAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,KAAK,6BAA6B,EAClC,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,GACjC,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,GACxB,MAAM,0CAA0C,CAAC","sourcesContent":["export {\n createDeploymentProvider,\n DeploymentProviderError,\n type CreateDeploymentProviderOptions,\n type DeploymentProvider,\n type DeploymentProviderErrorKind,\n type DeploymentProviderResult,\n} from \"./deployment-provider.js\";\nexport {\n GitHubCliClient,\n GitHubCliError,\n type GitHubCliClientLike,\n type GitHubCliClientOptions,\n type GitHubCliErrorReason,\n type GitHubCliWebLogin,\n} from \"./github-cli.js\";\nexport type {\n GitHubCliChildProcess,\n GitHubCliExecOptions,\n GitHubCliExecResult,\n GitHubCliOutputStream,\n GitHubCliProcessRunner,\n GitHubCliSpawnOptions,\n} from \"./process-runner.js\";\nexport {\n PrototypeCatalog,\n type PrototypeCatalogLike,\n} from \"./prototype-catalog.js\";\nexport {\n resolvePrototypeCatalogPaths,\n type PrototypeCatalogOptions,\n type ResolvedPrototypeCatalogPaths,\n} from \"./prototype-paths.js\";\nexport {\n PrototypeAgentService,\n type PrototypeAgentServiceLike,\n type PrototypeAgentServiceOptions,\n} from \"./agent-service.js\";\nexport {\n ClaudeCodeLauncher,\n buildClaudeCodeAppleScript,\n type ClaudeCodeExecOptions,\n type ClaudeCodeExecResult,\n type ClaudeCodeLauncherLike,\n type ClaudeCodeLauncherOptions,\n type ClaudeCodePreflightResult,\n type ClaudeCodePreflightValue,\n type ClaudeCodeProcessRunner,\n} from \"./claude.js\";\nexport {\n CursorLauncher,\n type CursorChildProcess,\n type CursorLauncherLike,\n type CursorLauncherOptions,\n type CursorSpawn,\n type CursorSpawnOptions,\n} from \"./cursor.js\";\nexport {\n PathExecutableResolver,\n type ExecutableAccess,\n type ExecutableResolverLike,\n type ExecutableResolverOptions,\n} from \"./executable.js\";\nexport {\n PrototypePreferences,\n PrototypePreferencesError,\n type PrototypePreferencesErrorCode,\n type PrototypePreferencesLike,\n type PrototypePreferencesOptions,\n} from \"./preferences.js\";\nexport type {\n PreparePrototypeFiles,\n PreparePrototypeFilesRequest,\n} from \"./prepare-prototype-files.js\";\nexport {\n LocalPrototypeLifecycle,\n type LocalPrototypeLifecycleOptions,\n type PrototypeLifecycle,\n} from \"./lifecycle/local-prototype-lifecycle.js\";\n"]}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GAKxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,EACf,cAAc,GAKf,MAAM,iBAAiB,CAAC;AASzB,OAAO,EACL,gBAAgB,GAEjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,4BAA4B,GAG7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAQ3B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,GAMf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,GAIvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,GAI1B,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,uBAAuB,GAGxB,MAAM,0CAA0C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GAKxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,EACf,cAAc,GAKf,MAAM,iBAAiB,CAAC;AASzB,OAAO,EACL,gBAAgB,GAEjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,4BAA4B,GAG7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAQ3B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,GAMf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,GAIvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,GAI1B,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,uBAAuB,GAGxB,MAAM,0CAA0C,CAAC","sourcesContent":["export {\n createDeploymentProvider,\n DeploymentProviderError,\n type CreateDeploymentProviderOptions,\n type DeploymentProvider,\n type DeploymentProviderErrorKind,\n type DeploymentProviderResult,\n} from \"./deployment-provider.js\";\nexport {\n GitHubCliClient,\n GitHubCliError,\n type GitHubCliClientLike,\n type GitHubCliClientOptions,\n type GitHubCliErrorReason,\n type GitHubCliWebLogin,\n} from \"./github-cli.js\";\nexport type {\n GitHubCliChildProcess,\n GitHubCliExecOptions,\n GitHubCliExecResult,\n GitHubCliOutputStream,\n GitHubCliProcessRunner,\n GitHubCliSpawnOptions,\n} from \"./process-runner.js\";\nexport {\n PrototypeCatalog,\n type PrototypeCatalogLike,\n} from \"./prototype-catalog.js\";\nexport {\n resolvePrototypeCatalogPaths,\n type PrototypeCatalogOptions,\n type ResolvedPrototypeCatalogPaths,\n} from \"./prototype-paths.js\";\nexport {\n PrototypeAgentService,\n type PrototypeAgentServiceLike,\n type PrototypeAgentServiceOptions,\n} from \"./agent-service.js\";\nexport {\n ClaudeCodeLauncher,\n buildClaudeCodeAppleScript,\n type ClaudeCodeExecOptions,\n type ClaudeCodeExecResult,\n type ClaudeCodeLauncherLike,\n type ClaudeCodeLauncherOptions,\n type ClaudeCodePreflightResult,\n type ClaudeCodePreflightValue,\n type ClaudeCodeProcessRunner,\n} from \"./claude.js\";\nexport {\n CursorLauncher,\n type CursorChildProcess,\n type CursorLauncherLike,\n type CursorLauncherOptions,\n type CursorSpawn,\n type CursorSpawnOptions,\n} from \"./cursor.js\";\nexport {\n PathExecutableResolver,\n type ExecutableAccess,\n type ExecutableResolverLike,\n type ExecutableResolverOptions,\n} from \"./executable.js\";\nexport {\n PrototypePreferences,\n PrototypePreferencesError,\n type PrototypePreferencesErrorCode,\n type PrototypePreferencesLike,\n type PrototypePreferencesOptions,\n} from \"./preferences.js\";\nexport type {\n PreparePrototypeFiles,\n PreparePrototypeFilesRequest,\n} from \"./prepare-prototype-files.js\";\nexport {\n LocalPrototypeLifecycle,\n type LocalPrototypeLifecycleOptions,\n type PrototypeLifecycle,\n} from \"./lifecycle/local-prototype-lifecycle.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"owned-destination.d.ts","sourceRoot":"","sources":["../../src/internal/owned-destination.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAY/B,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,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SAAS,MAAM,EAAE,CAAC;CAClC,CAAC,CAAC;AAEH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,cAGC;CACF;AAkCD,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAiBnC;AA6DD,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAOf;AAsCD,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,uBAAuB,EAChC,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,GAAG,EAAE,YAAY,EACjB,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CAqF5B","sourcesContent":["import { constants } from \"node:fs\";\nimport { lstat, open, readdir, rm, rmdir } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, sep } from \"node:path\";\nimport {\n parsePrototypeMetadata,\n type PrototypeMetadata,\n type PrototypeRef,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\n\nconst FILE_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);\nconst BLOCKED_DIRECTORY_NAMES = new Set([\n \".next\",\n \".turbo\",\n \"build\",\n \"coverage\",\n \"dist\",\n \"node_modules\",\n]);\n\nexport type OwnedDestinationReceipt = Readonly<{\n path: string;\n repositoryRoot: string;\n prototypeRoot: string;\n device: number;\n inode: number;\n}>;\n\nexport type OwnedDestinationResult = Readonly<{\n destination: string;\n receipt: OwnedDestinationReceipt;\n expectedFiles: readonly string[];\n}>;\n\nexport class OwnedDestinationError extends Error {\n constructor() {\n super(\"Invalid owned prototype destination\");\n this.name = \"OwnedDestinationError\";\n }\n}\n\nfunction isContained(root: string, path: string) {\n const pathFromRoot = relative(root, path);\n return (\n pathFromRoot.length > 0 &&\n pathFromRoot !== \"..\" &&\n !pathFromRoot.startsWith(`..${sep}`) &&\n !isAbsolute(pathFromRoot)\n );\n}\n\nfunction assertContainedDestination(\n path: string,\n repositoryRoot: string,\n prototypeRoot: string,\n) {\n if (\n !isAbsolute(path) ||\n !isContained(repositoryRoot, path) ||\n !isContained(prototypeRoot, path)\n ) {\n throw new OwnedDestinationError();\n }\n}\n\nasync function readStats(path: string) {\n try {\n return await lstat(path);\n } catch {\n throw new OwnedDestinationError();\n }\n}\n\nexport async function captureOwnedDestination(options: {\n path: string;\n repositoryRoot: string;\n prototypeRoot: string;\n}): Promise<OwnedDestinationReceipt> {\n assertContainedDestination(\n options.path,\n options.repositoryRoot,\n options.prototypeRoot,\n );\n const stats = await readStats(options.path);\n if (!stats.isDirectory() || stats.isSymbolicLink()) {\n throw new OwnedDestinationError();\n }\n return {\n path: options.path,\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n device: stats.dev,\n inode: stats.ino,\n };\n}\n\nasync function currentOwnedRoot(receipt: OwnedDestinationReceipt) {\n assertContainedDestination(\n receipt.path,\n receipt.repositoryRoot,\n receipt.prototypeRoot,\n );\n let stats;\n try {\n stats = await lstat(receipt.path);\n } catch (error) {\n if (\n error !== null &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return null;\n }\n throw new OwnedDestinationError();\n }\n if (\n !stats.isDirectory() ||\n stats.isSymbolicLink() ||\n stats.dev !== receipt.device ||\n stats.ino !== receipt.inode\n ) {\n return null;\n }\n return stats;\n}\n\nasync function removeTree(path: string): Promise<void> {\n let stats;\n try {\n stats = await lstat(path);\n } catch (error) {\n if (\n error !== null &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return;\n }\n throw error;\n }\n\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n await rm(path, { force: true });\n return;\n }\n\n const entries = await readdir(path);\n for (const entry of entries) {\n await removeTree(join(path, entry));\n }\n await rmdir(path);\n}\n\nexport async function cleanupOwnedDestination(\n receipt: OwnedDestinationReceipt,\n): Promise<void> {\n if ((await currentOwnedRoot(receipt)) === null) return;\n try {\n await removeTree(receipt.path);\n } catch {\n throw new OwnedDestinationError();\n }\n}\n\nasync function readRegularFile(path: string) {\n const stats = await readStats(path);\n if (!stats.isFile() || stats.isSymbolicLink()) {\n throw new OwnedDestinationError();\n }\n let file;\n try {\n file = await open(path, FILE_OPEN_FLAGS);\n return await file.readFile(\"utf8\");\n } catch {\n throw new OwnedDestinationError();\n } finally {\n await file?.close().catch(() => undefined);\n }\n}\n\nasync function validateTree(path: string): Promise<void> {\n const stats = await readStats(path);\n if (stats.isSymbolicLink()) throw new OwnedDestinationError();\n if (stats.isFile()) return;\n if (!stats.isDirectory()) throw new OwnedDestinationError();\n\n let entries;\n try {\n entries = await readdir(path);\n } catch {\n throw new OwnedDestinationError();\n }\n for (const name of entries) {\n if (name.startsWith(\".env\") || BLOCKED_DIRECTORY_NAMES.has(name)) {\n throw new OwnedDestinationError();\n }\n await validateTree(join(path, name));\n }\n}\n\nexport async function validateOwnedDestination(\n receipt: OwnedDestinationReceipt,\n expectedFiles: readonly string[],\n ref: PrototypeRef,\n themeRegistry?: ThemeRegistry,\n): Promise<PrototypeMetadata> {\n const root = await currentOwnedRoot(receipt);\n if (root === null) throw new OwnedDestinationError();\n await validateTree(receipt.path);\n if ((await currentOwnedRoot(receipt)) === null) {\n throw new OwnedDestinationError();\n }\n\n const componentsPath = join(receipt.path, \"components\");\n const componentsStats = await readStats(componentsPath);\n if (!componentsStats.isDirectory() || componentsStats.isSymbolicLink()) {\n throw new OwnedDestinationError();\n }\n\n for (const expectedFile of expectedFiles) {\n if (expectedFile === \"components/.gitkeep\") continue;\n const path = join(receipt.path, expectedFile);\n const stats = await readStats(path);\n if (!stats.isFile() || stats.isSymbolicLink()) {\n throw new OwnedDestinationError();\n }\n }\n\n let componentEntries;\n try {\n componentEntries = await readdir(componentsPath);\n } catch {\n throw new OwnedDestinationError();\n }\n const hasComponentFiles = componentEntries.some(\n (name) => name !== \".gitkeep\",\n );\n const markerPath = join(componentsPath, \".gitkeep\");\n let markerStats;\n try {\n markerStats = await lstat(markerPath);\n } catch (error) {\n if (\n !hasComponentFiles &&\n error !== null &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n throw new OwnedDestinationError();\n }\n if (\n hasComponentFiles &&\n error !== null &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n markerStats = null;\n } else {\n throw new OwnedDestinationError();\n }\n }\n if (\n markerStats !== null &&\n markerStats !== undefined &&\n !markerStats.isFile()\n ) {\n throw new OwnedDestinationError();\n }\n\n let metadata;\n try {\n metadata = JSON.parse(\n await readRegularFile(join(receipt.path, \"metadata.json\")),\n );\n } catch {\n throw new OwnedDestinationError();\n }\n let parsed;\n try {\n parsed = parsePrototypeMetadata(metadata, { themeRegistry });\n } catch {\n throw new OwnedDestinationError();\n }\n if (parsed.authorLogin !== ref.login) throw new OwnedDestinationError();\n if ((await currentOwnedRoot(receipt)) === null) {\n throw new OwnedDestinationError();\n }\n return parsed;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"owned-destination.js","sourceRoot":"","sources":["../../src/internal/owned-destination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EACL,sBAAsB,GAIvB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,eAAe,GAAG,SAAS,CAAC,QAAQ,GAAG,CAAC,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;AACzE,MAAM,uBAAu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,KAAK,CAAC,IAAI,KAAK,QAAQ,EACvB,CAAC;YACD,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,qBAAqB,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;IACD,IACE,WAAW,KAAK,IAAI;QACpB,WAAW,KAAK,SAAS;QACzB,CAAC,WAAW,CAAC,MAAM,EAAE,EACrB,CAAC;QACD,MAAM,IAAI,qBAAqB,EAAE,CAAC;IACpC,CAAC;IAED,IAAI,QAAQ,CAAC;IACb,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CACnB,MAAM,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAC3D,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,qBAAqB,EAAE,CAAC;IACpC,CAAC;IACD,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,sBAAsB,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,qBAAqB,EAAE,CAAC;IACpC,CAAC;IACD,IAAI,MAAM,CAAC,WAAW,KAAK,GAAG,CAAC,KAAK;QAAE,MAAM,IAAI,qBAAqB,EAAE,CAAC;IACxE,IAAI,CAAC,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/C,MAAM,IAAI,qBAAqB,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { constants } from \"node:fs\";\nimport { lstat, open, readdir, rm, rmdir } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, sep } from \"node:path\";\nimport {\n parsePrototypeMetadata,\n type PrototypeMetadata,\n type PrototypeRef,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\n\nconst FILE_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);\nconst BLOCKED_DIRECTORY_NAMES = new Set([\n \".next\",\n \".turbo\",\n \"build\",\n \"coverage\",\n \"dist\",\n \"node_modules\",\n]);\n\nexport type OwnedDestinationReceipt = Readonly<{\n path: string;\n repositoryRoot: string;\n prototypeRoot: string;\n device: number;\n inode: number;\n}>;\n\nexport type OwnedDestinationResult = Readonly<{\n destination: string;\n receipt: OwnedDestinationReceipt;\n expectedFiles: readonly string[];\n}>;\n\nexport class OwnedDestinationError extends Error {\n constructor() {\n super(\"Invalid owned prototype destination\");\n this.name = \"OwnedDestinationError\";\n }\n}\n\nfunction isContained(root: string, path: string) {\n const pathFromRoot = relative(root, path);\n return (\n pathFromRoot.length > 0 &&\n pathFromRoot !== \"..\" &&\n !pathFromRoot.startsWith(`..${sep}`) &&\n !isAbsolute(pathFromRoot)\n );\n}\n\nfunction assertContainedDestination(\n path: string,\n repositoryRoot: string,\n prototypeRoot: string,\n) {\n if (\n !isAbsolute(path) ||\n !isContained(repositoryRoot, path) ||\n !isContained(prototypeRoot, path)\n ) {\n throw new OwnedDestinationError();\n }\n}\n\nasync function readStats(path: string) {\n try {\n return await lstat(path);\n } catch {\n throw new OwnedDestinationError();\n }\n}\n\nexport async function captureOwnedDestination(options: {\n path: string;\n repositoryRoot: string;\n prototypeRoot: string;\n}): Promise<OwnedDestinationReceipt> {\n assertContainedDestination(\n options.path,\n options.repositoryRoot,\n options.prototypeRoot,\n );\n const stats = await readStats(options.path);\n if (!stats.isDirectory() || stats.isSymbolicLink()) {\n throw new OwnedDestinationError();\n }\n return {\n path: options.path,\n repositoryRoot: options.repositoryRoot,\n prototypeRoot: options.prototypeRoot,\n device: stats.dev,\n inode: stats.ino,\n };\n}\n\nasync function currentOwnedRoot(receipt: OwnedDestinationReceipt) {\n assertContainedDestination(\n receipt.path,\n receipt.repositoryRoot,\n receipt.prototypeRoot,\n );\n let stats;\n try {\n stats = await lstat(receipt.path);\n } catch (error) {\n if (\n error !== null &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return null;\n }\n throw new OwnedDestinationError();\n }\n if (\n !stats.isDirectory() ||\n stats.isSymbolicLink() ||\n stats.dev !== receipt.device ||\n stats.ino !== receipt.inode\n ) {\n return null;\n }\n return stats;\n}\n\nasync function removeTree(path: string): Promise<void> {\n let stats;\n try {\n stats = await lstat(path);\n } catch (error) {\n if (\n error !== null &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n return;\n }\n throw error;\n }\n\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n await rm(path, { force: true });\n return;\n }\n\n const entries = await readdir(path);\n for (const entry of entries) {\n await removeTree(join(path, entry));\n }\n await rmdir(path);\n}\n\nexport async function cleanupOwnedDestination(\n receipt: OwnedDestinationReceipt,\n): Promise<void> {\n if ((await currentOwnedRoot(receipt)) === null) return;\n try {\n await removeTree(receipt.path);\n } catch {\n throw new OwnedDestinationError();\n }\n}\n\nasync function readRegularFile(path: string) {\n const stats = await readStats(path);\n if (!stats.isFile() || stats.isSymbolicLink()) {\n throw new OwnedDestinationError();\n }\n let file;\n try {\n file = await open(path, FILE_OPEN_FLAGS);\n return await file.readFile(\"utf8\");\n } catch {\n throw new OwnedDestinationError();\n } finally {\n await file?.close().catch(() => undefined);\n }\n}\n\nasync function validateTree(path: string): Promise<void> {\n const stats = await readStats(path);\n if (stats.isSymbolicLink()) throw new OwnedDestinationError();\n if (stats.isFile()) return;\n if (!stats.isDirectory()) throw new OwnedDestinationError();\n\n let entries;\n try {\n entries = await readdir(path);\n } catch {\n throw new OwnedDestinationError();\n }\n for (const name of entries) {\n if (name.startsWith(\".env\") || BLOCKED_DIRECTORY_NAMES.has(name)) {\n throw new OwnedDestinationError();\n }\n await validateTree(join(path, name));\n }\n}\n\nexport async function validateOwnedDestination(\n receipt: OwnedDestinationReceipt,\n expectedFiles: readonly string[],\n ref: PrototypeRef,\n themeRegistry?: ThemeRegistry,\n): Promise<PrototypeMetadata> {\n const root = await currentOwnedRoot(receipt);\n if (root === null) throw new OwnedDestinationError();\n await validateTree(receipt.path);\n if ((await currentOwnedRoot(receipt)) === null) {\n throw new OwnedDestinationError();\n }\n\n const componentsPath = join(receipt.path, \"components\");\n const componentsStats = await readStats(componentsPath);\n if (!componentsStats.isDirectory() || componentsStats.isSymbolicLink()) {\n throw new OwnedDestinationError();\n }\n\n for (const expectedFile of expectedFiles) {\n if (expectedFile === \"components/.gitkeep\") continue;\n const path = join(receipt.path, expectedFile);\n const stats = await readStats(path);\n if (!stats.isFile() || stats.isSymbolicLink()) {\n throw new OwnedDestinationError();\n }\n }\n\n let componentEntries;\n try {\n componentEntries = await readdir(componentsPath);\n } catch {\n throw new OwnedDestinationError();\n }\n const hasComponentFiles = componentEntries.some(\n (name) => name !== \".gitkeep\",\n );\n const markerPath = join(componentsPath, \".gitkeep\");\n let markerStats;\n try {\n markerStats = await lstat(markerPath);\n } catch (error) {\n if (\n !hasComponentFiles &&\n error !== null &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n throw new OwnedDestinationError();\n }\n if (\n hasComponentFiles &&\n error !== null &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ) {\n markerStats = null;\n } else {\n throw new OwnedDestinationError();\n }\n }\n if (\n markerStats !== null &&\n markerStats !== undefined &&\n !markerStats.isFile()\n ) {\n throw new OwnedDestinationError();\n }\n\n let metadata;\n try {\n metadata = JSON.parse(\n await readRegularFile(join(receipt.path, \"metadata.json\")),\n );\n } catch {\n throw new OwnedDestinationError();\n }\n let parsed;\n try {\n parsed = parsePrototypeMetadata(metadata, { themeRegistry });\n } catch {\n throw new OwnedDestinationError();\n }\n if (parsed.authorLogin !== ref.login) throw new OwnedDestinationError();\n if ((await currentOwnedRoot(receipt)) === null) {\n throw new OwnedDestinationError();\n }\n return parsed;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prototype-templates.d.ts","sourceRoot":"","sources":["../../src/internal/prototype-templates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE7E,eAAO,MAAM,eAAe,YAC1B,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,kBAAkB,CACV,CAAC;AAEX,eAAO,MAAM,6BAA6B,YACxC,UAAU,EACV,SAAS,EACT,gBAAgB,CACR,CAAC;AAEX,wBAAgB,YAAY,WAO3B;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,GAAG,EAAE,YAAY,UAsBlB;AAED,wBAAgB,WAAW,WAS1B;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,UAanC;AAED,wBAAgB,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAMxE;AAED,wBAAgB,0BAA0B,WAMzC"}
1
+ {"version":3,"file":"prototype-templates.d.ts","sourceRoot":"","sources":["../../src/internal/prototype-templates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE7E,eAAO,MAAM,eAAe,YAC1B,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,kBAAkB,CACV,CAAC;AAEX,eAAO,MAAM,6BAA6B,YACxC,UAAU,EACV,SAAS,EACT,gBAAgB,CACR,CAAC;AAEX,wBAAgB,YAAY,WAO3B;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,GAAG,EAAE,YAAY,UAsBlB;AAED,wBAAgB,WAAW,WAS1B;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,UAanC;AAED,wBAAgB,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAMxE;AAED,wBAAgB,0BAA0B,WAMzC","sourcesContent":["import { join, relative, sep } from \"node:path\";\nimport type { PrototypeMetadata, PrototypeRef } from \"@ebay-dt/bonfire-core\";\n\nexport const GENERATED_FILES = [\n \"page.tsx\",\n \"app.tsx\",\n \"app.module.css\",\n \"components/.gitkeep\",\n \"metadata.json\",\n \"tsconfig.json\",\n \"css-modules.d.ts\",\n] as const;\n\nexport const COPYABLE_IMPLEMENTATION_FILES = [\n \"page.tsx\",\n \"app.tsx\",\n \"app.module.css\",\n] as const;\n\nexport function buildPageTsx() {\n return `import App from \"./app\";\n\nexport default function Page() {\n return <App />;\n}\n`;\n}\n\nexport function buildAppTsx(\n title: string,\n description: string | null,\n ref: PrototypeRef,\n) {\n return `\"use client\";\n\nimport { PrototypeOnboardingCard } from \"@ebay-dt/bonfire-react\";\nimport styles from \"./app.module.css\";\n\nexport default function App() {\n return (\n <main className={styles.container}>\n <PrototypeOnboardingCard\n title={${JSON.stringify(title)}}\n description={${JSON.stringify(description)}}\n prototypeRef={{\n login: ${JSON.stringify(ref.login)},\n slug: ${JSON.stringify(ref.slug)},\n }}\n />\n </main>\n );\n}\n`;\n}\n\nexport function buildAppCss() {\n return `.container {\n display: grid;\n gap: 1rem;\n min-block-size: calc(100svh - var(--app-header-block-size, 0));\n place-content: center;\n padding: 2rem;\n}\n`;\n}\n\nexport function buildMetadataJson(\n title: string,\n description: string | null,\n authorLogin: string,\n authorName: string | null,\n timestamp: string,\n theme?: PrototypeMetadata[\"theme\"],\n) {\n const metadata: PrototypeMetadata = {\n title,\n description,\n authorLogin,\n authorName,\n createdAt: timestamp,\n updatedAt: timestamp,\n previewUrl: null,\n ...(theme === undefined ? {} : { theme }),\n };\n return `${JSON.stringify(metadata, null, 2)}\\n`;\n}\n\nexport function buildTsConfig(repositoryRoot: string, destination: string) {\n const relativeRepositoryRoot = relative(destination, repositoryRoot);\n const extension = join(relativeRepositoryRoot, \"tsconfig.json\")\n .split(sep)\n .join(\"/\");\n return `${JSON.stringify({ extends: extension }, null, 2)}\\n`;\n}\n\nexport function buildCssModulesDeclaration() {\n return `declare module \"*.module.css\" {\n const classes: Record<string, string>;\n export default classes;\n}\n`;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prototype-templates.js","sourceRoot":"","sources":["../../src/internal/prototype-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU;IACV,SAAS;IACT,gBAAgB;IAChB,qBAAqB;IACrB,eAAe;IACf,eAAe;IACf,kBAAkB;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,UAAU;IACV,SAAS;IACT,gBAAgB;CACR,CAAC;AAEX,MAAM,UAAU,YAAY;IAC1B,OAAO;;;;;CAKR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,KAAa,EACb,WAA0B,EAC1B,GAAiB;IAEjB,OAAO;;;;;;;;;iBASQ,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;uBACf,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;;mBAE/B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;kBAC1B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;;;;;;CAMzC,CAAC;AACF,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO;;;;;;;CAOR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,KAAa,EACb,WAA0B,EAC1B,WAAmB,EACnB,UAAyB,EACzB,SAAiB,EACjB,KAAkC;IAElC,MAAM,QAAQ,GAAsB;QAClC,KAAK;QACL,WAAW;QACX,WAAW;QACX,UAAU;QACV,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,UAAU,EAAE,IAAI;QAChB,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;KAC1C,CAAC;IACF,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,cAAsB,EAAE,WAAmB;IACvE,MAAM,sBAAsB,GAAG,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IACrE,MAAM,SAAS,GAAG,IAAI,CAAC,sBAAsB,EAAE,eAAe,CAAC;SAC5D,KAAK,CAAC,GAAG,CAAC;SACV,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,OAAO;;;;CAIR,CAAC;AACF,CAAC"}
1
+ {"version":3,"file":"prototype-templates.js","sourceRoot":"","sources":["../../src/internal/prototype-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,U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I,CAAC,sBAAsB,EAAE,eAAe,CAAC;SAC5D,KAAK,CAAC,GAAG,CAAC;SACV,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,OAAO;;;;CAIR,CAAC;AACF,CAAC","sourcesContent":["import { join, relative, sep } from \"node:path\";\nimport type { PrototypeMetadata, PrototypeRef } from \"@ebay-dt/bonfire-core\";\n\nexport const GENERATED_FILES = [\n \"page.tsx\",\n \"app.tsx\",\n \"app.module.css\",\n \"components/.gitkeep\",\n \"metadata.json\",\n \"tsconfig.json\",\n \"css-modules.d.ts\",\n] as const;\n\nexport const COPYABLE_IMPLEMENTATION_FILES = [\n \"page.tsx\",\n \"app.tsx\",\n \"app.module.css\",\n] as const;\n\nexport function buildPageTsx() {\n return `import App from \"./app\";\n\nexport default function Page() {\n return <App />;\n}\n`;\n}\n\nexport function buildAppTsx(\n title: string,\n description: string | null,\n ref: PrototypeRef,\n) {\n return `\"use client\";\n\nimport { PrototypeOnboardingCard } from \"@ebay-dt/bonfire-react\";\nimport styles from \"./app.module.css\";\n\nexport default function App() {\n return (\n <main className={styles.container}>\n <PrototypeOnboardingCard\n title={${JSON.stringify(title)}}\n description={${JSON.stringify(description)}}\n prototypeRef={{\n login: ${JSON.stringify(ref.login)},\n slug: ${JSON.stringify(ref.slug)},\n }}\n />\n </main>\n );\n}\n`;\n}\n\nexport function buildAppCss() {\n return `.container {\n display: grid;\n gap: 1rem;\n min-block-size: calc(100svh - var(--app-header-block-size, 0));\n place-content: center;\n padding: 2rem;\n}\n`;\n}\n\nexport function buildMetadataJson(\n title: string,\n description: string | null,\n authorLogin: string,\n authorName: string | null,\n timestamp: string,\n theme?: PrototypeMetadata[\"theme\"],\n) {\n const metadata: PrototypeMetadata = {\n title,\n description,\n authorLogin,\n authorName,\n createdAt: timestamp,\n updatedAt: timestamp,\n previewUrl: null,\n ...(theme === undefined ? {} : { theme }),\n };\n return `${JSON.stringify(metadata, null, 2)}\\n`;\n}\n\nexport function buildTsConfig(repositoryRoot: string, destination: string) {\n const relativeRepositoryRoot = relative(destination, repositoryRoot);\n const extension = join(relativeRepositoryRoot, \"tsconfig.json\")\n .split(sep)\n .join(\"/\");\n return `${JSON.stringify({ extends: extension }, null, 2)}\\n`;\n}\n\nexport function buildCssModulesDeclaration() {\n return `declare module \"*.module.css\" {\n const classes: Record<string, string>;\n export default classes;\n}\n`;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAE/D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAElE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEhE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAExD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAExD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAE/D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAElE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEhE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAExD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAExD","sourcesContent":["export type UnknownRecord = Record<string, unknown>;\n\nexport type ProcessFailure = {\n code?: unknown;\n killed?: unknown;\n signal?: unknown;\n message?: unknown;\n};\n\nexport function isRecord(value: unknown): value is UnknownRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function hasErrorCode(value: unknown, code: string): boolean {\n return isRecord(value) && \"code\" in value && value.code === code;\n}\n\nexport function isFileNotFound(value: unknown): boolean {\n return hasErrorCode(value, \"ENOENT\");\n}\n\nexport function isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0;\n}\n\nexport function asFailure(value: unknown): ProcessFailure {\n return isRecord(value) ? value : {};\n}\n\nexport function isPositiveInteger(value: number): boolean {\n return Number.isInteger(value) && value > 0;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/internal/utils.ts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ACnE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["export type UnknownRecord = Record<string, unknown>;\n\nexport type ProcessFailure = {\n code?: unknown;\n killed?: unknown;\n signal?: unknown;\n message?: unknown;\n};\n\nexport function isRecord(value: unknown): value is UnknownRecord {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function hasErrorCode(value: unknown, code: string): boolean {\n return isRecord(value) && \"code\" in value && value.code === code;\n}\n\nexport function isFileNotFound(value: unknown): boolean {\n return hasErrorCode(value, \"ENOENT\");\n}\n\nexport function isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0;\n}\n\nexport function asFailure(value: unknown): ProcessFailure {\n return isRecord(value) ? value : {};\n}\n\nexport function isPositiveInteger(value: number): boolean {\n return Number.isInteger(value) && value > 0;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"dirty-state.d.ts","sourceRoot":"","sources":["../../src/lifecycle/dirty-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,qBAAqB,CAAC;CAC9B,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,EAC5C,YAAY,EAAE,OAAO,GACpB,oBAAoB,CAStB"}
1
+ {"version":3,"file":"dirty-state.d.ts","sourceRoot":"","sources":["../../src/lifecycle/dirty-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,qBAAqB,CAAC;CAC9B,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,EAC5C,YAAY,EAAE,OAAO,GACpB,oBAAoB,CAStB","sourcesContent":["import type {\n DirtyObservationStatus,\n DirtyObservationValue,\n} from \"@ebay-dt/bonfire-core\";\n\nexport type DirtyStateTransition = {\n changed: boolean;\n value: DirtyObservationValue;\n};\n\nexport function applyDirtyObservation(\n previous: DirtyObservationStatus | undefined,\n currentDirty: boolean,\n): DirtyStateTransition {\n const value: DirtyObservationValue = {\n status: currentDirty ? \"dirty\" : \"clean\",\n };\n\n return {\n changed: previous === undefined || previous !== value.status,\n value,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"dirty-state.js","sourceRoot":"","sources":["../../src/lifecycle/dirty-state.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,qBAAqB,CACnC,QAA4C,EAC5C,YAAqB;IAErB,MAAM,KAAK,GAA0B;QACnC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;KACzC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM;QAC5D,KAAK;KACN,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"dirty-state.js","sourceRoot":"","sources":["../../src/lifecycle/dirty-state.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,qBAAqB,CACnC,QAA4C,EAC5C,YAAqB;IAErB,MAAM,KAAK,GAA0B;QACnC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;KACzC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,KAAK,CAAC,MAAM;QAC5D,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import type {\n DirtyObservationStatus,\n DirtyObservationValue,\n} from \"@ebay-dt/bonfire-core\";\n\nexport type DirtyStateTransition = {\n changed: boolean;\n value: DirtyObservationValue;\n};\n\nexport function applyDirtyObservation(\n previous: DirtyObservationStatus | undefined,\n currentDirty: boolean,\n): DirtyStateTransition {\n const value: DirtyObservationValue = {\n status: currentDirty ? \"dirty\" : \"clean\",\n };\n\n return {\n changed: previous === undefined || previous !== value.status,\n value,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"local-prototype-lifecycle.d.ts","sourceRoot":"","sources":["../../src/lifecycle/local-prototype-lifecycle.ts"],"names":[],"mappings":"AAIA,OAAO,EAcL,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAEpB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAEvB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAU/B,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,yBAAyB,CAAC;AAMjC,OAAO,KAAK,EACV,qBAAqB,EAEtB,MAAM,+BAA+B,CAA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kBAAkB,CAAC,CAAC,CA8C9C;IAEK,MAAM,CACV,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAuBhD;IAEK,aAAa,CACjB,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAWjD;IAEK,MAAM,CACV,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAkF3C;IAEK,IAAI,CACR,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAW9C;IAEK,OAAO,CACX,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAWjD;IAEK,SAAS,CACb,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,eAAe,CAAC,uBAAuB,CAAC,CAAC,CA8DnD;CACF","sourcesContent":["import { constants } from \"node:fs\";\nimport { lstat, open, rename, rm, writeFile } from \"node:fs/promises\";\nimport { randomUUID } from \"node:crypto\";\nimport { join, relative, sep } from \"node:path\";\nimport {\n definePrototypeRef,\n getPrototypeUrl,\n LifecycleInputError,\n lifecycleFailure,\n lifecycleSuccess,\n parseCreatePrototypeInput,\n parseDuplicatePrototypeInput,\n parseEditPrototypeInput,\n parseBonfireIdentity,\n parsePrototypeCommandInput,\n parsePrototypeMetadata,\n slugifyPrototypeTitle,\n PrototypeRefError,\n type BranchPreparationValue,\n type CreatePrototypeInput,\n type CreatePrototypeValue,\n type DeletePrototypeValue,\n type DeploymentValue,\n type DeploymentWarningCode,\n type DirtyObservationValue,\n type DiscardPrototypeValue,\n type DuplicatePrototypeInput,\n type DuplicatePrototypeValue,\n type EditPrototypeInput,\n type EditPrototypeValue,\n type LifecycleErrorCode,\n type LifecycleResult,\n type BonfireIdentity,\n type PrototypeCommandInput,\n type SavePrototypeValue,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n commitPath,\n discardPath,\n GitRepositoryError,\n prepareIdentityBranch,\n pushBranch,\n type GitRepository,\n} from \"../git-repository.js\";\nimport { duplicatePrototype, PrototypeDuplicateError } from \"../duplicate.js\";\nimport {\n PrototypeCatalog,\n type PrototypeCatalogLike,\n} from \"../prototype-catalog.js\";\nimport { PrototypeScaffoldError, scaffoldPrototype } from \"../scaffold.js\";\nimport {\n createPrototypeLifecycleRuntime,\n type PrototypeLifecycleRuntimeContext,\n} from \"./runtime-context.js\";\nimport type {\n PreparePrototypeFiles,\n PreparePrototypeFilesRequest,\n} from \"../prepare-prototype-files.js\";\nimport {\n cleanupOwnedDestination,\n validateOwnedDestination,\n type OwnedDestinationReceipt,\n} from \"../internal/owned-destination.js\";\nimport {\n RepositoryBusyError,\n withRepositoryOperation,\n} from \"./operation-gate.js\";\nimport {\n DeploymentProviderError,\n type DeploymentProvider,\n} from \"../deployment-provider.js\";\n\ntype LifecycleMethod<Input, Value> = (\n identity: BonfireIdentity,\n input: Input,\n) => Promise<LifecycleResult<Value>>;\n\nexport type PrototypeLifecycle = {\n prepareBranch(\n identity: BonfireIdentity,\n ): Promise<LifecycleResult<BranchPreparationValue>>;\n create: LifecycleMethod<CreatePrototypeInput, CreatePrototypeValue>;\n duplicate: LifecycleMethod<DuplicatePrototypeInput, DuplicatePrototypeValue>;\n edit: LifecycleMethod<EditPrototypeInput, EditPrototypeValue>;\n delete: LifecycleMethod<PrototypeCommandInput, DeletePrototypeValue>;\n getDirtyState: LifecycleMethod<PrototypeCommandInput, DirtyObservationValue>;\n save: LifecycleMethod<PrototypeCommandInput, SavePrototypeValue>;\n discard: LifecycleMethod<PrototypeCommandInput, DiscardPrototypeValue>;\n deploy: LifecycleMethod<PrototypeCommandInput, DeploymentValue>;\n};\n\nexport type LocalPrototypeLifecycleOptions = {\n repositoryRoot: string;\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n automaticBranchSwitch?: \"enabled\" | \"disabled\";\n commitIdentity?: {\n name: string;\n email: string;\n };\n catalog?: PrototypeCatalogLike;\n preparePrototypeFiles?: PreparePrototypeFiles;\n deploymentProvider?: DeploymentProvider;\n applicationId?: string;\n themeRegistry?: ThemeRegistry;\n};\n\ntype InternalLocalPrototypeLifecycleOptions = LocalPrototypeLifecycleOptions & {\n runtime?: PrototypeLifecycleRuntimeContext;\n};\n\nfunction repositoryRelativePath(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n) {\n const absolutePath = join(runtime.prototypeRoot, ref.login, ref.slug);\n return relative(runtime.repositoryRoot, absolutePath).split(sep).join(\"/\");\n}\n\nfunction destinationRef(identity: BonfireIdentity, title: string) {\n const slug = slugifyPrototypeTitle(title);\n if (slug === null)\n throw new PrototypeRefError(\"title\", \"must produce a slug\");\n return definePrototypeRef({ login: identity.login, slug });\n}\n\nclass PrototypeNotFoundError extends Error {}\nclass PrototypeOwnershipError extends Error {}\nclass PrototypeMetadataFileError extends Error {}\nclass DeploymentUnavailableError extends Error {}\n\nfunction metadataPath(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n) {\n return join(runtime.prototypeRoot, ref.login, ref.slug, \"metadata.json\");\n}\n\nasync function assertPrototypeDirectory(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n) {\n const paths = [\n runtime.prototypeRoot,\n join(runtime.prototypeRoot, ref.login),\n join(runtime.prototypeRoot, ref.login, ref.slug),\n ];\n\n try {\n for (const path of paths) {\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new PrototypeMetadataFileError();\n }\n }\n } catch (error) {\n if (error instanceof PrototypeMetadataFileError) throw error;\n throw new PrototypeMetadataFileError();\n }\n}\n\nasync function readMetadataDocument(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n themeRegistry?: ThemeRegistry,\n) {\n const path = metadataPath(runtime, ref);\n try {\n const file = await open(\n path,\n constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0),\n );\n try {\n const source = await file.readFile(\"utf8\");\n const document: unknown = JSON.parse(source);\n parsePrototypeMetadata(document, { themeRegistry });\n if (\n typeof document !== \"object\" ||\n document === null ||\n Array.isArray(document)\n ) {\n throw new PrototypeMetadataFileError();\n }\n return { ...(document as Record<string, unknown>) };\n } finally {\n await file.close();\n }\n } catch (error) {\n if (error instanceof PrototypeMetadataFileError) throw error;\n throw new PrototypeMetadataFileError();\n }\n}\n\nasync function removePrototypeDirectory(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n) {\n await assertPrototypeDirectory(runtime, ref);\n try {\n await rm(join(runtime.prototypeRoot, ref.login, ref.slug), {\n force: false,\n recursive: true,\n });\n } catch {\n throw new PrototypeMetadataFileError();\n }\n}\n\nasync function writeMetadataDocument(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n document: Record<string, unknown>,\n) {\n const path = metadataPath(runtime, ref);\n const temporaryPath = `${path}.${randomUUID()}.tmp`;\n\n try {\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || !stats.isFile()) {\n throw new PrototypeMetadataFileError();\n }\n await writeFile(temporaryPath, `${JSON.stringify(document, null, 2)}\\n`, {\n encoding: \"utf8\",\n flag: \"wx\",\n });\n await rename(temporaryPath, path);\n } catch (error) {\n if (error instanceof PrototypeMetadataFileError) throw error;\n throw new PrototypeMetadataFileError();\n } finally {\n await rm(temporaryPath, { force: true }).catch(() => undefined);\n }\n}\n\nasync function mergeIdentityBranchToPrimary(\n repository: GitRepository,\n options: {\n branch: string;\n primaryBranch: string;\n remote: string;\n },\n) {\n if (options.branch === options.primaryBranch) return;\n\n const hasRemote = (await repository.remotes()).some(\n (remote) => remote.name === options.remote,\n );\n if (!hasRemote) return;\n\n await repository.checkout([options.primaryBranch]);\n try {\n await repository.merge([\n options.branch,\n \"--no-ff\",\n \"-m\",\n `merge: ${options.branch}`,\n ]);\n await repository.push(options.remote, options.primaryBranch);\n } finally {\n await repository.checkout([options.branch]);\n }\n}\n\nfunction mapError(error: unknown): LifecycleErrorCode {\n if (error instanceof PrototypeNotFoundError) return \"not-found\";\n if (error instanceof PrototypeOwnershipError) return \"forbidden\";\n if (error instanceof PrototypeMetadataFileError) return \"filesystem-failure\";\n if (error instanceof RepositoryBusyError) return \"repository-busy\";\n if (\n error instanceof PrototypeRefError ||\n error instanceof LifecycleInputError\n ) {\n return \"invalid-input\";\n }\n if (error instanceof GitRepositoryError) {\n if (error.kind === \"timeout\") return \"timeout\";\n if (error.kind === \"conflict\") return \"working-tree-conflict\";\n if (error.kind === \"invalid-configuration\") return \"unexpected-failure\";\n return \"git-failure\";\n }\n if (error instanceof PrototypeScaffoldError) {\n if (error.kind === \"collision\") return \"already-exists\";\n if (error.kind === \"invalid-input\") return \"invalid-input\";\n return \"filesystem-failure\";\n }\n if (error instanceof PrototypeDuplicateError) {\n if (error.kind === \"source-not-found\") return \"not-found\";\n if (error.kind === \"collision\") return \"already-exists\";\n if (error.kind === \"invalid-source\") return \"invalid-input\";\n return \"filesystem-failure\";\n }\n if (error instanceof DeploymentUnavailableError) {\n return \"deployment-unavailable\";\n }\n if (error instanceof DeploymentProviderError) {\n return error.kind === \"timeout\" ? \"timeout\" : \"deployment-failure\";\n }\n return \"unexpected-failure\";\n}\n\nfunction resultFrom<Value>(\n operation: () => Promise<Value>,\n): Promise<LifecycleResult<Value>> {\n return operation()\n .then(lifecycleSuccess)\n .catch((error: unknown) => lifecycleFailure(mapError(error)));\n}\n\nexport class LocalPrototypeLifecycle implements PrototypeLifecycle {\n readonly #runtime: PrototypeLifecycleRuntimeContext;\n readonly #catalog: PrototypeCatalogLike;\n readonly #repository: GitRepository;\n readonly #preparePrototypeFiles: PreparePrototypeFiles;\n readonly #deploymentProvider?: DeploymentProvider;\n readonly #applicationId?: string;\n readonly #themeRegistry?: ThemeRegistry;\n\n constructor(options: LocalPrototypeLifecycleOptions) {\n const internalOptions = options as InternalLocalPrototypeLifecycleOptions;\n this.#runtime =\n internalOptions.runtime ??\n createPrototypeLifecycleRuntime(internalOptions);\n this.#themeRegistry = options.themeRegistry;\n this.#catalog =\n internalOptions.catalog ??\n new PrototypeCatalog({\n ...this.#runtime,\n themeRegistry: this.#themeRegistry,\n });\n this.#repository = this.#runtime.gitRepository;\n this.#preparePrototypeFiles =\n internalOptions.preparePrototypeFiles ?? (() => undefined);\n this.#deploymentProvider = internalOptions.deploymentProvider;\n this.#applicationId = internalOptions.applicationId;\n if (\n this.#deploymentProvider &&\n (typeof this.#applicationId !== \"string\" ||\n this.#applicationId.length === 0)\n ) {\n throw new TypeError(\n \"applicationId must be provided when deploymentProvider is configured\",\n );\n }\n }\n\n async #verifiedIdentity(identity: BonfireIdentity) {\n return parseBonfireIdentity(identity);\n }\n\n async #currentBranch() {\n const branch = await this.#repository.currentBranch();\n if (branch === \"HEAD\" || branch.length === 0) {\n throw new GitRepositoryError(\"conflict\", \"current-branch\");\n }\n return branch;\n }\n\n async #ownedPrototype(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ) {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parsePrototypeCommandInput(input);\n if (normalizedInput.ref.login !== verifiedIdentity.login) {\n throw new PrototypeOwnershipError();\n }\n const summary = await this.#catalog.getSummary(normalizedInput.ref);\n if (!summary) {\n throw new PrototypeNotFoundError();\n }\n\n return {\n ref: normalizedInput.ref,\n path: repositoryRelativePath(this.#runtime, normalizedInput.ref),\n summary,\n };\n }\n\n async #prepareMutationBranch(login: string) {\n if (this.#runtime.automaticBranchSwitch === \"disabled\") {\n return this.#currentBranch();\n }\n\n await prepareIdentityBranch(this.#repository, {\n identityBranch: login,\n primaryBranch: this.#runtime.primaryBranch,\n remote: this.#runtime.remote,\n });\n return login;\n }\n\n async #prepareDestination(\n receipt: OwnedDestinationReceipt,\n expectedFiles: readonly string[],\n request: PreparePrototypeFilesRequest,\n ) {\n try {\n const frozenRequest = Object.freeze({\n ...request,\n ref: Object.freeze({ ...request.ref }),\n identity: Object.freeze({ ...request.identity }),\n ...(request.operation === \"duplicate\"\n ? { source: Object.freeze({ ...request.source }) }\n : {}),\n }) as PreparePrototypeFilesRequest;\n await this.#preparePrototypeFiles(frozenRequest);\n await validateOwnedDestination(\n receipt,\n expectedFiles,\n request.ref,\n this.#themeRegistry,\n );\n } catch {\n try {\n await cleanupOwnedDestination(receipt);\n } catch {\n // The failure remains a finite filesystem failure without retrying cleanup.\n }\n throw new PrototypeScaffoldError(\"filesystem\");\n }\n }\n\n async prepareBranch(\n identity: BonfireIdentity,\n ): Promise<LifecycleResult<BranchPreparationValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n if (this.#runtime.automaticBranchSwitch === \"disabled\") {\n await this.#currentBranch();\n return { status: \"disabled\" } satisfies BranchPreparationValue;\n }\n\n await prepareIdentityBranch(this.#repository, {\n identityBranch: verifiedIdentity.login,\n primaryBranch: this.#runtime.primaryBranch,\n remote: this.#runtime.remote,\n });\n return { status: \"ready\" } satisfies BranchPreparationValue;\n },\n );\n });\n }\n\n async create(\n identity: BonfireIdentity,\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parseCreatePrototypeInput(\n input,\n this.#themeRegistry,\n );\n const ref = destinationRef(verifiedIdentity, normalizedInput.title);\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n if (await this.#catalog.getSummary(ref)) {\n throw new PrototypeScaffoldError(\"collision\");\n }\n\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n const prepared = await scaffoldPrototype({\n paths: this.#runtime,\n ref,\n title: normalizedInput.title,\n description: normalizedInput.description,\n authorName: verifiedIdentity.name,\n theme: normalizedInput.theme,\n themeRegistry: this.#themeRegistry,\n });\n await this.#prepareDestination(\n prepared.receipt,\n prepared.expectedFiles,\n {\n operation: \"create\",\n repositoryRoot: this.#runtime.repositoryRoot,\n prototypeRoot: this.#runtime.prototypeRoot,\n prototypePath: prepared.destination,\n ref,\n identity: verifiedIdentity,\n title: normalizedInput.title,\n description: normalizedInput.description,\n },\n );\n await commitPath(\n this.#repository,\n repositoryRelativePath(this.#runtime, ref),\n `init: ${ref.slug}`,\n );\n const push = await pushBranch(\n this.#repository,\n this.#runtime.remote,\n branch,\n );\n\n return {\n ref,\n url: getPrototypeUrl(ref),\n remoteStatus: push.remoteStatus,\n } satisfies CreatePrototypeValue;\n },\n );\n });\n }\n\n async edit(\n identity: BonfireIdentity,\n input: EditPrototypeInput,\n ): Promise<LifecycleResult<EditPrototypeValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parseEditPrototypeInput(\n input,\n this.#themeRegistry,\n );\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n const { ref, path } = await this.#ownedPrototype(verifiedIdentity, {\n ref: normalizedInput.ref,\n });\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n await assertPrototypeDirectory(this.#runtime, ref);\n const document = await readMetadataDocument(\n this.#runtime,\n ref,\n this.#themeRegistry,\n );\n const metadata = parsePrototypeMetadata(document, {\n themeRegistry: this.#themeRegistry,\n });\n if (metadata.authorLogin !== ref.login) {\n throw new PrototypeNotFoundError();\n }\n\n await writeMetadataDocument(this.#runtime, ref, {\n ...document,\n title: normalizedInput.title,\n description: normalizedInput.description,\n updatedAt: new Date().toISOString(),\n ...(normalizedInput.theme === undefined\n ? {}\n : { theme: normalizedInput.theme }),\n });\n await commitPath(this.#repository, path, `edit: ${ref.slug}`);\n await pushBranch(this.#repository, this.#runtime.remote, branch);\n\n return { edited: true, ref } satisfies EditPrototypeValue;\n },\n );\n });\n }\n\n async delete(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parsePrototypeCommandInput(input);\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n const { ref, path } = await this.#ownedPrototype(\n verifiedIdentity,\n normalizedInput,\n );\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n await removePrototypeDirectory(this.#runtime, ref);\n await commitPath(this.#repository, path, `delete: ${ref.slug}`);\n await pushBranch(this.#repository, this.#runtime.remote, branch);\n\n return { deleted: true, ref } satisfies DeletePrototypeValue;\n },\n );\n });\n }\n\n async getDirtyState(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DirtyObservationValue>> {\n return resultFrom(async () => {\n const { path, summary } = await this.#ownedPrototype(identity, input);\n const status = await this.#repository.status([path]);\n return {\n status: status.files.length > 0 ? \"dirty\" : \"clean\",\n ...(summary.previewUrl !== undefined\n ? { previewUrl: summary.previewUrl }\n : {}),\n } satisfies DirtyObservationValue;\n });\n }\n\n async deploy(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parsePrototypeCommandInput(input);\n if (!this.#deploymentProvider) {\n throw new DeploymentUnavailableError();\n }\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n const { ref, path } = await this.#ownedPrototype(\n verifiedIdentity,\n normalizedInput,\n );\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n await assertPrototypeDirectory(this.#runtime, ref);\n const document = await readMetadataDocument(\n this.#runtime,\n ref,\n this.#themeRegistry,\n );\n const metadata = parsePrototypeMetadata(document, {\n themeRegistry: this.#themeRegistry,\n });\n if (metadata.authorLogin !== ref.login) {\n throw new PrototypeNotFoundError();\n }\n await commitPath(this.#repository, path, `deploy: ${ref.slug}`);\n await pushBranch(this.#repository, this.#runtime.remote, branch);\n\n const deployment = await this.#deploymentProvider!.deploy({\n applicationId: this.#applicationId!,\n login: verifiedIdentity.login,\n });\n const previewUrl = new URL(\n getPrototypeUrl(ref).slice(1),\n `${deployment.url.replace(/\\/+$/, \"\")}/`,\n ).toString();\n\n let warning: DeploymentWarningCode | undefined;\n try {\n await writeMetadataDocument(this.#runtime, ref, {\n ...document,\n previewUrl,\n updatedAt: new Date().toISOString(),\n });\n await commitPath(\n this.#repository,\n path,\n `deploy: ${ref.slug} (metadata)`,\n );\n await pushBranch(this.#repository, this.#runtime.remote, branch);\n } catch {\n warning = \"metadata-persistence-failed\";\n }\n\n if (warning === undefined) {\n try {\n await mergeIdentityBranchToPrimary(this.#repository, {\n branch,\n primaryBranch: this.#runtime.primaryBranch,\n remote: this.#runtime.remote,\n });\n } catch {\n warning = \"primary-merge-failed\";\n }\n }\n\n return {\n deployed: true,\n ref,\n previewUrl,\n deploymentId: deployment.deploymentId,\n readyState: deployment.readyState,\n warning,\n } satisfies DeploymentValue;\n },\n );\n });\n }\n\n async save(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>> {\n return resultFrom(async () => {\n const { ref, path } = await this.#ownedPrototype(identity, input);\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n await commitPath(this.#repository, path, `save: ${ref.slug}`);\n return { saved: true } satisfies SavePrototypeValue;\n },\n );\n });\n }\n\n async discard(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>> {\n return resultFrom(async () => {\n const { path } = await this.#ownedPrototype(identity, input);\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n await discardPath(this.#repository, path);\n return { discarded: true } satisfies DiscardPrototypeValue;\n },\n );\n });\n }\n\n async duplicate(\n identity: BonfireIdentity,\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parseDuplicatePrototypeInput(input);\n if (!(await this.#catalog.getSummary(normalizedInput.source))) {\n throw new PrototypeDuplicateError(\"source-not-found\");\n }\n const ref = destinationRef(verifiedIdentity, normalizedInput.title);\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n if (await this.#catalog.getSummary(ref)) {\n throw new PrototypeDuplicateError(\"collision\");\n }\n\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n const prepared = await duplicatePrototype({\n paths: this.#runtime,\n source: normalizedInput.source,\n destination: ref,\n title: normalizedInput.title,\n description: normalizedInput.description,\n authorName: verifiedIdentity.name,\n themeRegistry: this.#themeRegistry,\n });\n await this.#prepareDestination(\n prepared.receipt,\n prepared.expectedFiles,\n {\n operation: \"duplicate\",\n repositoryRoot: this.#runtime.repositoryRoot,\n prototypeRoot: this.#runtime.prototypeRoot,\n prototypePath: prepared.destination,\n ref,\n source: normalizedInput.source,\n identity: verifiedIdentity,\n title: normalizedInput.title,\n description: normalizedInput.description,\n },\n );\n await commitPath(\n this.#repository,\n repositoryRelativePath(this.#runtime, ref),\n `init: ${ref.slug}`,\n );\n const push = await pushBranch(\n this.#repository,\n this.#runtime.remote,\n branch,\n );\n\n return {\n ref,\n url: getPrototypeUrl(ref),\n remoteStatus: push.remoteStatus,\n } satisfies DuplicatePrototypeValue;\n },\n );\n });\n }\n}\n"]}