@ebay-dt/bonfire-node 0.1.0-alpha.0 → 0.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -4
- package/dist/agent-service.d.ts +42 -0
- package/dist/agent-service.d.ts.map +1 -0
- package/dist/agent-service.js +116 -0
- package/dist/agent-service.js.map +1 -0
- package/dist/claude.d.ts +50 -0
- package/dist/claude.d.ts.map +1 -0
- package/dist/claude.js +119 -0
- package/dist/claude.js.map +1 -0
- package/dist/cursor.d.ts +30 -0
- package/dist/cursor.d.ts.map +1 -0
- package/dist/cursor.js +57 -0
- package/dist/cursor.js.map +1 -0
- package/dist/deployment-provider.d.ts +32 -0
- package/dist/deployment-provider.d.ts.map +1 -0
- package/dist/deployment-provider.js +167 -0
- package/dist/deployment-provider.js.map +1 -0
- package/dist/duplicate.d.ts +3 -2
- package/dist/duplicate.d.ts.map +1 -1
- package/dist/duplicate.js +18 -18
- package/dist/duplicate.js.map +1 -1
- package/dist/executable.d.ts +16 -0
- package/dist/executable.d.ts.map +1 -0
- package/dist/executable.js +65 -0
- package/dist/executable.js.map +1 -0
- package/dist/git-repository.d.ts.map +1 -1
- package/dist/git-repository.js.map +1 -1
- package/dist/github-cli.d.ts.map +1 -1
- package/dist/github-cli.js +23 -3
- package/dist/github-cli.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/owned-destination.d.ts +2 -2
- package/dist/internal/owned-destination.d.ts.map +1 -1
- package/dist/internal/owned-destination.js +2 -2
- package/dist/internal/owned-destination.js.map +1 -1
- package/dist/internal/prototype-templates.d.ts +3 -2
- package/dist/internal/prototype-templates.d.ts.map +1 -1
- package/dist/internal/prototype-templates.js +13 -8
- package/dist/internal/prototype-templates.js.map +1 -1
- package/dist/internal/utils.d.ts +2 -0
- package/dist/internal/utils.d.ts.map +1 -1
- package/dist/internal/utils.js +6 -0
- package/dist/internal/utils.js.map +1 -1
- package/dist/lifecycle/dirty-state.d.ts.map +1 -1
- package/dist/lifecycle/dirty-state.js.map +1 -1
- package/dist/lifecycle/local-prototype-lifecycle.d.ts +22 -10
- package/dist/lifecycle/local-prototype-lifecycle.d.ts.map +1 -1
- package/dist/lifecycle/local-prototype-lifecycle.js +255 -6
- package/dist/lifecycle/local-prototype-lifecycle.js.map +1 -1
- package/dist/lifecycle/operation-gate.d.ts.map +1 -1
- package/dist/lifecycle/operation-gate.js.map +1 -1
- package/dist/lifecycle/runtime-context.d.ts.map +1 -1
- package/dist/lifecycle/runtime-context.js.map +1 -1
- package/dist/preferences.d.ts +19 -0
- package/dist/preferences.d.ts.map +1 -0
- package/dist/preferences.js +182 -0
- package/dist/preferences.js.map +1 -0
- package/dist/prepare-prototype-files.d.ts.map +1 -1
- package/dist/prepare-prototype-files.js.map +1 -1
- package/dist/process-runner.d.ts.map +1 -1
- package/dist/process-runner.js.map +1 -1
- package/dist/prototype-catalog.d.ts.map +1 -1
- package/dist/prototype-catalog.js +18 -7
- package/dist/prototype-catalog.js.map +1 -1
- package/dist/prototype-paths.d.ts +2 -0
- package/dist/prototype-paths.d.ts.map +1 -1
- package/dist/prototype-paths.js.map +1 -1
- package/dist/scaffold.d.ts +4 -2
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +7 -12
- package/dist/scaffold.js.map +1 -1
- package/dist/watcher.d.ts.map +1 -1
- package/dist/watcher.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-repository.d.ts","sourceRoot":"","sources":["../src/git-repository.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,C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VD,MAAM,MAAM,4BAA4B,GAAG;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,IAAI,CAAC,CAgEf;AAED,wBAAsB,UAAU,CAC9B,UAAU,EAAE,aAAa,EACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,CAAC,CAI1B;AAED,wBAAsB,WAAW,CAC/B,UAAU,EAAE,aAAa,EACzB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,wBAAsB,UAAU,CAC9B,UAAU,EAAE,aAAa,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,CAAC,CAWxB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,GAC5B,aAAa,CAsBf","sourcesContent":["import { isAbsolute } from \"node:path\";\nimport { simpleGit } 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":"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,kBAAkB;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC;IAE3D,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;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U,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CACjD,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,KAAK,MAAM,CACvD,CAAC;IACF,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;IAEtD,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC1D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,OAA6B;IAE7B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,kBAAkB,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAC;IAC1D,MAAM,sBAAsB,GAC1B,OAAO,CAAC,sBAAsB,IAAI,gCAAgC,CAAC;IACrE,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,uBAAuB,CAAC;IAEzE,0BAA0B,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACjD,0BAA0B,CACxB,sBAAsB,EACtB,0BAA0B,CAC3B,CAAC;IAEF,OAAO,IAAI,mBAAmB,CAAC;QAC7B,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,SAAS;QACT,sBAAsB;QACtB,cAAc;KACf,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { isAbsolute } from \"node:path\";\nimport { simpleGit } 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"]}
|
package/dist/github-cli.d.ts.map
CHANGED
|
@@ -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;
|
|
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,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,sBAAsB,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IACpC,aAAa,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7C;AAwGD,qBAAa,eAAgB,YAAW,mBAAmB;;IACzD,QAAQ,CAAC,QAAQ,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"]}
|
package/dist/github-cli.js
CHANGED
|
@@ -3,9 +3,11 @@ import { defaultGitHubCliProcessRunner, } from "./process-runner.js";
|
|
|
3
3
|
const GH_EXECUTABLE = "gh";
|
|
4
4
|
const IDENTITY_TIMEOUT = 10_000;
|
|
5
5
|
const IDENTITY_MAX_BUFFER = 1024 * 1024;
|
|
6
|
-
const DEVICE_LOGIN_TIMEOUT =
|
|
6
|
+
const DEVICE_LOGIN_TIMEOUT = 10_000;
|
|
7
7
|
const ACTIVE_LOGIN_WINDOW = 10 * 60 * 1000;
|
|
8
|
-
const
|
|
8
|
+
const GH_LOGIN_CODE_LABEL_PATTERN = /\bone[-\s]time\s+code\b/i;
|
|
9
|
+
const GH_DEVICE_CODE_PATTERN = /\b[A-Za-z0-9]+(?:-[A-Za-z0-9]+)+\b/;
|
|
10
|
+
const ANSI_ESCAPE_PATTERN = new RegExp(`${String.fromCharCode(27)}\\[[0-?]*[ -/]*[@-~]`, "g");
|
|
9
11
|
export class GitHubCliError extends Error {
|
|
10
12
|
reason;
|
|
11
13
|
constructor(message, reason = "unknown") {
|
|
@@ -20,6 +22,24 @@ function asFailure(error) {
|
|
|
20
22
|
function outputFrom(value) {
|
|
21
23
|
return typeof value === "string" ? value : "";
|
|
22
24
|
}
|
|
25
|
+
function extractDeviceCode(output) {
|
|
26
|
+
const cleanOutput = output.replace(ANSI_ESCAPE_PATTERN, "").replace(/\r/g, "");
|
|
27
|
+
const lines = cleanOutput.split("\n");
|
|
28
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
29
|
+
const line = lines[index];
|
|
30
|
+
if (line === undefined)
|
|
31
|
+
continue;
|
|
32
|
+
const label = line.match(GH_LOGIN_CODE_LABEL_PATTERN);
|
|
33
|
+
if (!label || label.index === undefined)
|
|
34
|
+
continue;
|
|
35
|
+
const remainder = line.slice(label.index + label[0].length);
|
|
36
|
+
const match = remainder.match(GH_DEVICE_CODE_PATTERN) ??
|
|
37
|
+
lines[index + 1]?.match(GH_DEVICE_CODE_PATTERN);
|
|
38
|
+
if (match)
|
|
39
|
+
return match[0];
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
23
43
|
function projectIdentityFields(value) {
|
|
24
44
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
25
45
|
return value;
|
|
@@ -183,7 +203,7 @@ export class GitHubCliClient {
|
|
|
183
203
|
const inspectOutput = (chunk) => {
|
|
184
204
|
output +=
|
|
185
205
|
typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
|
|
186
|
-
const code = output
|
|
206
|
+
const code = extractDeviceCode(output);
|
|
187
207
|
if (code)
|
|
188
208
|
settle(code);
|
|
189
209
|
};
|
package/dist/github-cli.js.map
CHANGED
|
@@ -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,KAAK,CAAC;AACnC,MAAM,mBAAmB,GAAG,EAA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f,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC;QAEF,MAAM,aAAa,GAAG,CAAC,KAA0B,EAAE,EAAE;YACnD,MAAM;gBACJ,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC1E,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;YACvC,IAAI,IAAI;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC;QAEF,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC7D,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QAChB,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QACxC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QACxC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;YACvB,IAAI,CAAC,OAAO;gBAAE,MAAM,CAAC,IAAI,CAAC,CAAC;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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
export { createDeploymentProvider, DeploymentProviderError, type CreateDeploymentProviderOptions, type DeploymentProvider, type DeploymentProviderErrorKind, type DeploymentProviderResult, } from "./deployment-provider.js";
|
|
1
2
|
export { GitHubCliClient, GitHubCliError, type GitHubCliClientLike, type GitHubCliClientOptions, type GitHubCliErrorReason, type GitHubCliWebLogin, } from "./github-cli.js";
|
|
2
3
|
export type { GitHubCliChildProcess, GitHubCliExecOptions, GitHubCliExecResult, GitHubCliOutputStream, GitHubCliProcessRunner, GitHubCliSpawnOptions, } from "./process-runner.js";
|
|
3
4
|
export { PrototypeCatalog, type PrototypeCatalogLike, } from "./prototype-catalog.js";
|
|
4
|
-
export type
|
|
5
|
+
export { resolvePrototypeCatalogPaths, type PrototypeCatalogOptions, type ResolvedPrototypeCatalogPaths, } from "./prototype-paths.js";
|
|
6
|
+
export { PrototypeAgentService, type PrototypeAgentServiceLike, type PrototypeAgentServiceOptions, } from "./agent-service.js";
|
|
7
|
+
export { ClaudeCodeLauncher, buildClaudeCodeAppleScript, type ClaudeCodeExecOptions, type ClaudeCodeExecResult, type ClaudeCodeLauncherLike, type ClaudeCodeLauncherOptions, type ClaudeCodePreflightResult, type ClaudeCodePreflightValue, type ClaudeCodeProcessRunner, } from "./claude.js";
|
|
8
|
+
export { CursorLauncher, type CursorChildProcess, type CursorLauncherLike, type CursorLauncherOptions, type CursorSpawn, type CursorSpawnOptions, } from "./cursor.js";
|
|
9
|
+
export { PathExecutableResolver, type ExecutableAccess, type ExecutableResolverLike, type ExecutableResolverOptions, } from "./executable.js";
|
|
10
|
+
export { PrototypePreferences, PrototypePreferencesError, type PrototypePreferencesErrorCode, type PrototypePreferencesLike, type PrototypePreferencesOptions, } from "./preferences.js";
|
|
5
11
|
export type { PreparePrototypeFiles, PreparePrototypeFilesRequest, } from "./prepare-prototype-files.js";
|
|
6
12
|
export { LocalPrototypeLifecycle, type LocalPrototypeLifecycleOptions, type PrototypeLifecycle, } from "./lifecycle/local-prototype-lifecycle.js";
|
|
7
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAA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AAwB,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
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
export { createDeploymentProvider, DeploymentProviderError, } from "./deployment-provider.js";
|
|
1
2
|
export { GitHubCliClient, GitHubCliError, } from "./github-cli.js";
|
|
2
3
|
export { PrototypeCatalog, } from "./prototype-catalog.js";
|
|
4
|
+
export { resolvePrototypeCatalogPaths, } from "./prototype-paths.js";
|
|
5
|
+
export { PrototypeAgentService, } from "./agent-service.js";
|
|
6
|
+
export { ClaudeCodeLauncher, buildClaudeCodeAppleScript, } from "./claude.js";
|
|
7
|
+
export { CursorLauncher, } from "./cursor.js";
|
|
8
|
+
export { PathExecutableResolver, } from "./executable.js";
|
|
9
|
+
export { PrototypePreferences, PrototypePreferencesError, } from "./preferences.js";
|
|
3
10
|
export { LocalPrototypeLifecycle, } from "./lifecycle/local-prototype-lifecycle.js";
|
|
4
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,GAKf,MAAM,iBAAiB,CAAC;AASzB,OAAO,EACL,gBAAgB,GAEjB,MAAM,wBAAwB,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,4 +1,4 @@
|
|
|
1
|
-
import { type PrototypeMetadata, type PrototypeRef } from "@ebay-dt/bonfire-core";
|
|
1
|
+
import { type PrototypeMetadata, type PrototypeRef, type ThemeRegistry } from "@ebay-dt/bonfire-core";
|
|
2
2
|
export type OwnedDestinationReceipt = Readonly<{
|
|
3
3
|
path: string;
|
|
4
4
|
repositoryRoot: string;
|
|
@@ -20,5 +20,5 @@ export declare function captureOwnedDestination(options: {
|
|
|
20
20
|
prototypeRoot: string;
|
|
21
21
|
}): Promise<OwnedDestinationReceipt>;
|
|
22
22
|
export declare function cleanupOwnedDestination(receipt: OwnedDestinationReceipt): Promise<void>;
|
|
23
|
-
export declare function validateOwnedDestination(receipt: OwnedDestinationReceipt, expectedFiles: readonly string[], ref: PrototypeRef): Promise<PrototypeMetadata>;
|
|
23
|
+
export declare function validateOwnedDestination(receipt: OwnedDestinationReceipt, expectedFiles: readonly string[], ref: PrototypeRef, themeRegistry?: ThemeRegistry): Promise<PrototypeMetadata>;
|
|
24
24
|
//# sourceMappingURL=owned-destination.d.ts.map
|
|
@@ -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,
|
|
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,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,uBAAuB,CAAC;IACjC,aAAa,EAAE,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"]}
|
|
@@ -149,7 +149,7 @@ async function validateTree(path) {
|
|
|
149
149
|
await validateTree(join(path, name));
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
export async function validateOwnedDestination(receipt, expectedFiles, ref) {
|
|
152
|
+
export async function validateOwnedDestination(receipt, expectedFiles, ref, themeRegistry) {
|
|
153
153
|
const root = await currentOwnedRoot(receipt);
|
|
154
154
|
if (root === null)
|
|
155
155
|
throw new OwnedDestinationError();
|
|
@@ -217,7 +217,7 @@ export async function validateOwnedDestination(receipt, expectedFiles, ref) {
|
|
|
217
217
|
}
|
|
218
218
|
let parsed;
|
|
219
219
|
try {
|
|
220
|
-
parsed = parsePrototypeMetadata(metadata);
|
|
220
|
+
parsed = parsePrototypeMetadata(metadata, { themeRegistry });
|
|
221
221
|
}
|
|
222
222
|
catch {
|
|
223
223
|
throw new OwnedDestinationError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owned-destination.js","sourceRoot":"","sources":["../../src/internal/owned-destination.ts"],"names":[],"mappings":"A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AAM,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,9 +1,10 @@
|
|
|
1
|
+
import type { PrototypeMetadata, PrototypeRef } from "@ebay-dt/bonfire-core";
|
|
1
2
|
export declare const GENERATED_FILES: readonly ["page.tsx", "app.tsx", "app.module.css", "components/.gitkeep", "metadata.json", "tsconfig.json", "css-modules.d.ts"];
|
|
2
3
|
export declare const COPYABLE_IMPLEMENTATION_FILES: readonly ["page.tsx", "app.tsx", "app.module.css"];
|
|
3
4
|
export declare function buildPageTsx(): string;
|
|
4
|
-
export declare function buildAppTsx(title: string, description: string | null): string;
|
|
5
|
+
export declare function buildAppTsx(title: string, description: string | null, ref: PrototypeRef): string;
|
|
5
6
|
export declare function buildAppCss(): string;
|
|
6
|
-
export declare function buildMetadataJson(title: string, description: string | null, authorLogin: string, authorName: string | null, timestamp: string): string;
|
|
7
|
+
export declare function buildMetadataJson(title: string, description: string | null, authorLogin: string, authorName: string | null, timestamp: string, theme?: PrototypeMetadata["theme"]): string;
|
|
7
8
|
export declare function buildTsConfig(repositoryRoot: string, destination: string): string;
|
|
8
9
|
export declare function buildCssModulesDeclaration(): string;
|
|
9
10
|
//# sourceMappingURL=prototype-templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototype-templates.d.ts","sourceRoot":"","sources":["../../src/internal/prototype-templates.ts"],"names":[],"mappings":"
|
|
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"]}
|
|
@@ -21,19 +21,23 @@ export default function Page() {
|
|
|
21
21
|
}
|
|
22
22
|
`;
|
|
23
23
|
}
|
|
24
|
-
export function buildAppTsx(title, description) {
|
|
25
|
-
const descriptionMarkup = description === null
|
|
26
|
-
? ""
|
|
27
|
-
: `
|
|
28
|
-
<p>{${JSON.stringify(description)}}</p>`;
|
|
24
|
+
export function buildAppTsx(title, description, ref) {
|
|
29
25
|
return `"use client";
|
|
30
26
|
|
|
27
|
+
import { PrototypeOnboardingCard } from "@ebay-dt/bonfire-react";
|
|
31
28
|
import styles from "./app.module.css";
|
|
32
29
|
|
|
33
30
|
export default function App() {
|
|
34
31
|
return (
|
|
35
32
|
<main className={styles.container}>
|
|
36
|
-
<
|
|
33
|
+
<PrototypeOnboardingCard
|
|
34
|
+
title={${JSON.stringify(title)}}
|
|
35
|
+
description={${JSON.stringify(description)}}
|
|
36
|
+
prototypeRef={{
|
|
37
|
+
login: ${JSON.stringify(ref.login)},
|
|
38
|
+
slug: ${JSON.stringify(ref.slug)},
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
37
41
|
</main>
|
|
38
42
|
);
|
|
39
43
|
}
|
|
@@ -43,13 +47,13 @@ export function buildAppCss() {
|
|
|
43
47
|
return `.container {
|
|
44
48
|
display: grid;
|
|
45
49
|
gap: 1rem;
|
|
46
|
-
min-
|
|
50
|
+
min-block-size: calc(100svh - var(--app-header-block-size, 0));
|
|
47
51
|
place-content: center;
|
|
48
52
|
padding: 2rem;
|
|
49
53
|
}
|
|
50
54
|
`;
|
|
51
55
|
}
|
|
52
|
-
export function buildMetadataJson(title, description, authorLogin, authorName, timestamp) {
|
|
56
|
+
export function buildMetadataJson(title, description, authorLogin, authorName, timestamp, theme) {
|
|
53
57
|
const metadata = {
|
|
54
58
|
title,
|
|
55
59
|
description,
|
|
@@ -58,6 +62,7 @@ export function buildMetadataJson(title, description, authorLogin, authorName, t
|
|
|
58
62
|
createdAt: timestamp,
|
|
59
63
|
updatedAt: timestamp,
|
|
60
64
|
previewUrl: null,
|
|
65
|
+
...(theme === undefined ? {} : { theme }),
|
|
61
66
|
};
|
|
62
67
|
return `${JSON.stringify(metadata, null, 2)}\n`;
|
|
63
68
|
}
|
|
@@ -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,
|
|
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","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"]}
|
package/dist/internal/utils.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type ProcessFailure = {
|
|
|
6
6
|
message?: unknown;
|
|
7
7
|
};
|
|
8
8
|
export declare function isRecord(value: unknown): value is UnknownRecord;
|
|
9
|
+
export declare function hasErrorCode(value: unknown, code: string): boolean;
|
|
10
|
+
export declare function isFileNotFound(value: unknown): boolean;
|
|
9
11
|
export declare function isNonEmptyString(value: unknown): value is string;
|
|
10
12
|
export declare function asFailure(value: unknown): ProcessFailure;
|
|
11
13
|
export declare function isPositiveInteger(value: number): boolean;
|