@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.
Files changed (77) hide show
  1. package/README.md +77 -4
  2. package/dist/agent-service.d.ts +42 -0
  3. package/dist/agent-service.d.ts.map +1 -0
  4. package/dist/agent-service.js +116 -0
  5. package/dist/agent-service.js.map +1 -0
  6. package/dist/claude.d.ts +50 -0
  7. package/dist/claude.d.ts.map +1 -0
  8. package/dist/claude.js +119 -0
  9. package/dist/claude.js.map +1 -0
  10. package/dist/cursor.d.ts +30 -0
  11. package/dist/cursor.d.ts.map +1 -0
  12. package/dist/cursor.js +57 -0
  13. package/dist/cursor.js.map +1 -0
  14. package/dist/deployment-provider.d.ts +32 -0
  15. package/dist/deployment-provider.d.ts.map +1 -0
  16. package/dist/deployment-provider.js +167 -0
  17. package/dist/deployment-provider.js.map +1 -0
  18. package/dist/duplicate.d.ts +3 -2
  19. package/dist/duplicate.d.ts.map +1 -1
  20. package/dist/duplicate.js +18 -18
  21. package/dist/duplicate.js.map +1 -1
  22. package/dist/executable.d.ts +16 -0
  23. package/dist/executable.d.ts.map +1 -0
  24. package/dist/executable.js +65 -0
  25. package/dist/executable.js.map +1 -0
  26. package/dist/git-repository.d.ts.map +1 -1
  27. package/dist/git-repository.js.map +1 -1
  28. package/dist/github-cli.d.ts.map +1 -1
  29. package/dist/github-cli.js +23 -3
  30. package/dist/github-cli.js.map +1 -1
  31. package/dist/index.d.ts +7 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +7 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/internal/owned-destination.d.ts +2 -2
  36. package/dist/internal/owned-destination.d.ts.map +1 -1
  37. package/dist/internal/owned-destination.js +2 -2
  38. package/dist/internal/owned-destination.js.map +1 -1
  39. package/dist/internal/prototype-templates.d.ts +3 -2
  40. package/dist/internal/prototype-templates.d.ts.map +1 -1
  41. package/dist/internal/prototype-templates.js +13 -8
  42. package/dist/internal/prototype-templates.js.map +1 -1
  43. package/dist/internal/utils.d.ts +2 -0
  44. package/dist/internal/utils.d.ts.map +1 -1
  45. package/dist/internal/utils.js +6 -0
  46. package/dist/internal/utils.js.map +1 -1
  47. package/dist/lifecycle/dirty-state.d.ts.map +1 -1
  48. package/dist/lifecycle/dirty-state.js.map +1 -1
  49. package/dist/lifecycle/local-prototype-lifecycle.d.ts +22 -10
  50. package/dist/lifecycle/local-prototype-lifecycle.d.ts.map +1 -1
  51. package/dist/lifecycle/local-prototype-lifecycle.js +255 -6
  52. package/dist/lifecycle/local-prototype-lifecycle.js.map +1 -1
  53. package/dist/lifecycle/operation-gate.d.ts.map +1 -1
  54. package/dist/lifecycle/operation-gate.js.map +1 -1
  55. package/dist/lifecycle/runtime-context.d.ts.map +1 -1
  56. package/dist/lifecycle/runtime-context.js.map +1 -1
  57. package/dist/preferences.d.ts +19 -0
  58. package/dist/preferences.d.ts.map +1 -0
  59. package/dist/preferences.js +182 -0
  60. package/dist/preferences.js.map +1 -0
  61. package/dist/prepare-prototype-files.d.ts.map +1 -1
  62. package/dist/prepare-prototype-files.js.map +1 -1
  63. package/dist/process-runner.d.ts.map +1 -1
  64. package/dist/process-runner.js.map +1 -1
  65. package/dist/prototype-catalog.d.ts.map +1 -1
  66. package/dist/prototype-catalog.js +18 -7
  67. package/dist/prototype-catalog.js.map +1 -1
  68. package/dist/prototype-paths.d.ts +2 -0
  69. package/dist/prototype-paths.d.ts.map +1 -1
  70. package/dist/prototype-paths.js.map +1 -1
  71. package/dist/scaffold.d.ts +4 -2
  72. package/dist/scaffold.d.ts.map +1 -1
  73. package/dist/scaffold.js +7 -12
  74. package/dist/scaffold.js.map +1 -1
  75. package/dist/watcher.d.ts.map +1 -1
  76. package/dist/watcher.js.map +1 -1
  77. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"local-prototype-lifecycle.js","sourceRoot":"","sources":["../../src/lifecycle/local-prototype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,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAC1C,SAAS,GAAG,CAAC,IAAI,EAAE,CACpB,CAAC;gBACF,MAAM,IAAI,GAAG,MAAM,UAAU,CAC3B,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,QAAQ,CAAC,MAAM,EACpB,MAAM,CACP,CAAC;gBAEF,OAAO;oBACL,GAAG;oBACH,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC;oBACzB,YAAY,EAAE,IAAI,CAAC,YAAY;iBACE,CAAC;YACtC,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"local-prototype-lifecycle.js","sourceRoot":"","sources":["../../src/lifecycle/local-prototype-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,GAmBlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,GAEX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EACL,gBAAgB,GAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,sBAAsB,EA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AE,eAAe,CAAC,WAAW;iBACzC,CACF,CAAC;gBACF,MAAM,UAAU,CACd,IAAI,CAAC,WAAW,EAChB,sBAAsB,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAC1C,SAAS,GAAG,CAAC,IAAI,EAAE,CACpB,CAAC;gBACF,MAAM,IAAI,GAAG,MAAM,UAAU,CAC3B,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,QAAQ,CAAC,MAAM,EACpB,MAAM,CACP,CAAC;gBAEF,OAAO;oBACL,GAAG;oBACH,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC;oBACzB,YAAY,EAAE,IAAI,CAAC,YAAY;iBACE,CAAC;YACtC,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { constants } from \"node:fs\";\nimport { lstat, open, rename, rm, writeFile } from \"node:fs/promises\";\nimport { randomUUID } from \"node:crypto\";\nimport { join, relative, sep } from \"node:path\";\nimport {\n definePrototypeRef,\n getPrototypeUrl,\n LifecycleInputError,\n lifecycleFailure,\n lifecycleSuccess,\n parseCreatePrototypeInput,\n parseDuplicatePrototypeInput,\n parseEditPrototypeInput,\n parseBonfireIdentity,\n parsePrototypeCommandInput,\n parsePrototypeMetadata,\n slugifyPrototypeTitle,\n PrototypeRefError,\n type BranchPreparationValue,\n type CreatePrototypeInput,\n type CreatePrototypeValue,\n type DeletePrototypeValue,\n type DeploymentValue,\n type DeploymentWarningCode,\n type DirtyObservationValue,\n type DiscardPrototypeValue,\n type DuplicatePrototypeInput,\n type DuplicatePrototypeValue,\n type EditPrototypeInput,\n type EditPrototypeValue,\n type LifecycleErrorCode,\n type LifecycleResult,\n type BonfireIdentity,\n type PrototypeCommandInput,\n type SavePrototypeValue,\n type ThemeRegistry,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n commitPath,\n discardPath,\n GitRepositoryError,\n prepareIdentityBranch,\n pushBranch,\n type GitRepository,\n} from \"../git-repository.js\";\nimport { duplicatePrototype, PrototypeDuplicateError } from \"../duplicate.js\";\nimport {\n PrototypeCatalog,\n type PrototypeCatalogLike,\n} from \"../prototype-catalog.js\";\nimport { PrototypeScaffoldError, scaffoldPrototype } from \"../scaffold.js\";\nimport {\n createPrototypeLifecycleRuntime,\n type PrototypeLifecycleRuntimeContext,\n} from \"./runtime-context.js\";\nimport type {\n PreparePrototypeFiles,\n PreparePrototypeFilesRequest,\n} from \"../prepare-prototype-files.js\";\nimport {\n cleanupOwnedDestination,\n validateOwnedDestination,\n type OwnedDestinationReceipt,\n} from \"../internal/owned-destination.js\";\nimport {\n RepositoryBusyError,\n withRepositoryOperation,\n} from \"./operation-gate.js\";\nimport {\n DeploymentProviderError,\n type DeploymentProvider,\n} from \"../deployment-provider.js\";\n\ntype LifecycleMethod<Input, Value> = (\n identity: BonfireIdentity,\n input: Input,\n) => Promise<LifecycleResult<Value>>;\n\nexport type PrototypeLifecycle = {\n prepareBranch(\n identity: BonfireIdentity,\n ): Promise<LifecycleResult<BranchPreparationValue>>;\n create: LifecycleMethod<CreatePrototypeInput, CreatePrototypeValue>;\n duplicate: LifecycleMethod<DuplicatePrototypeInput, DuplicatePrototypeValue>;\n edit: LifecycleMethod<EditPrototypeInput, EditPrototypeValue>;\n delete: LifecycleMethod<PrototypeCommandInput, DeletePrototypeValue>;\n getDirtyState: LifecycleMethod<PrototypeCommandInput, DirtyObservationValue>;\n save: LifecycleMethod<PrototypeCommandInput, SavePrototypeValue>;\n discard: LifecycleMethod<PrototypeCommandInput, DiscardPrototypeValue>;\n deploy: LifecycleMethod<PrototypeCommandInput, DeploymentValue>;\n};\n\nexport type LocalPrototypeLifecycleOptions = {\n repositoryRoot: string;\n prototypeRoot?: string;\n remote?: string;\n primaryBranch?: string;\n automaticBranchSwitch?: \"enabled\" | \"disabled\";\n commitIdentity?: {\n name: string;\n email: string;\n };\n catalog?: PrototypeCatalogLike;\n preparePrototypeFiles?: PreparePrototypeFiles;\n deploymentProvider?: DeploymentProvider;\n applicationId?: string;\n themeRegistry?: ThemeRegistry;\n};\n\ntype InternalLocalPrototypeLifecycleOptions = LocalPrototypeLifecycleOptions & {\n runtime?: PrototypeLifecycleRuntimeContext;\n};\n\nfunction repositoryRelativePath(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n) {\n const absolutePath = join(runtime.prototypeRoot, ref.login, ref.slug);\n return relative(runtime.repositoryRoot, absolutePath).split(sep).join(\"/\");\n}\n\nfunction destinationRef(identity: BonfireIdentity, title: string) {\n const slug = slugifyPrototypeTitle(title);\n if (slug === null)\n throw new PrototypeRefError(\"title\", \"must produce a slug\");\n return definePrototypeRef({ login: identity.login, slug });\n}\n\nclass PrototypeNotFoundError extends Error {}\nclass PrototypeOwnershipError extends Error {}\nclass PrototypeMetadataFileError extends Error {}\nclass DeploymentUnavailableError extends Error {}\n\nfunction metadataPath(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n) {\n return join(runtime.prototypeRoot, ref.login, ref.slug, \"metadata.json\");\n}\n\nasync function assertPrototypeDirectory(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n) {\n const paths = [\n runtime.prototypeRoot,\n join(runtime.prototypeRoot, ref.login),\n join(runtime.prototypeRoot, ref.login, ref.slug),\n ];\n\n try {\n for (const path of paths) {\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new PrototypeMetadataFileError();\n }\n }\n } catch (error) {\n if (error instanceof PrototypeMetadataFileError) throw error;\n throw new PrototypeMetadataFileError();\n }\n}\n\nasync function readMetadataDocument(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n themeRegistry?: ThemeRegistry,\n) {\n const path = metadataPath(runtime, ref);\n try {\n const file = await open(\n path,\n constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0),\n );\n try {\n const source = await file.readFile(\"utf8\");\n const document: unknown = JSON.parse(source);\n parsePrototypeMetadata(document, { themeRegistry });\n if (\n typeof document !== \"object\" ||\n document === null ||\n Array.isArray(document)\n ) {\n throw new PrototypeMetadataFileError();\n }\n return { ...(document as Record<string, unknown>) };\n } finally {\n await file.close();\n }\n } catch (error) {\n if (error instanceof PrototypeMetadataFileError) throw error;\n throw new PrototypeMetadataFileError();\n }\n}\n\nasync function removePrototypeDirectory(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n) {\n await assertPrototypeDirectory(runtime, ref);\n try {\n await rm(join(runtime.prototypeRoot, ref.login, ref.slug), {\n force: false,\n recursive: true,\n });\n } catch {\n throw new PrototypeMetadataFileError();\n }\n}\n\nasync function writeMetadataDocument(\n runtime: PrototypeLifecycleRuntimeContext,\n ref: { login: string; slug: string },\n document: Record<string, unknown>,\n) {\n const path = metadataPath(runtime, ref);\n const temporaryPath = `${path}.${randomUUID()}.tmp`;\n\n try {\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || !stats.isFile()) {\n throw new PrototypeMetadataFileError();\n }\n await writeFile(temporaryPath, `${JSON.stringify(document, null, 2)}\\n`, {\n encoding: \"utf8\",\n flag: \"wx\",\n });\n await rename(temporaryPath, path);\n } catch (error) {\n if (error instanceof PrototypeMetadataFileError) throw error;\n throw new PrototypeMetadataFileError();\n } finally {\n await rm(temporaryPath, { force: true }).catch(() => undefined);\n }\n}\n\nasync function mergeIdentityBranchToPrimary(\n repository: GitRepository,\n options: {\n branch: string;\n primaryBranch: string;\n remote: string;\n },\n) {\n if (options.branch === options.primaryBranch) return;\n\n const hasRemote = (await repository.remotes()).some(\n (remote) => remote.name === options.remote,\n );\n if (!hasRemote) return;\n\n await repository.checkout([options.primaryBranch]);\n try {\n await repository.merge([\n options.branch,\n \"--no-ff\",\n \"-m\",\n `merge: ${options.branch}`,\n ]);\n await repository.push(options.remote, options.primaryBranch);\n } finally {\n await repository.checkout([options.branch]);\n }\n}\n\nfunction mapError(error: unknown): LifecycleErrorCode {\n if (error instanceof PrototypeNotFoundError) return \"not-found\";\n if (error instanceof PrototypeOwnershipError) return \"forbidden\";\n if (error instanceof PrototypeMetadataFileError) return \"filesystem-failure\";\n if (error instanceof RepositoryBusyError) return \"repository-busy\";\n if (\n error instanceof PrototypeRefError ||\n error instanceof LifecycleInputError\n ) {\n return \"invalid-input\";\n }\n if (error instanceof GitRepositoryError) {\n if (error.kind === \"timeout\") return \"timeout\";\n if (error.kind === \"conflict\") return \"working-tree-conflict\";\n if (error.kind === \"invalid-configuration\") return \"unexpected-failure\";\n return \"git-failure\";\n }\n if (error instanceof PrototypeScaffoldError) {\n if (error.kind === \"collision\") return \"already-exists\";\n if (error.kind === \"invalid-input\") return \"invalid-input\";\n return \"filesystem-failure\";\n }\n if (error instanceof PrototypeDuplicateError) {\n if (error.kind === \"source-not-found\") return \"not-found\";\n if (error.kind === \"collision\") return \"already-exists\";\n if (error.kind === \"invalid-source\") return \"invalid-input\";\n return \"filesystem-failure\";\n }\n if (error instanceof DeploymentUnavailableError) {\n return \"deployment-unavailable\";\n }\n if (error instanceof DeploymentProviderError) {\n return error.kind === \"timeout\" ? \"timeout\" : \"deployment-failure\";\n }\n return \"unexpected-failure\";\n}\n\nfunction resultFrom<Value>(\n operation: () => Promise<Value>,\n): Promise<LifecycleResult<Value>> {\n return operation()\n .then(lifecycleSuccess)\n .catch((error: unknown) => lifecycleFailure(mapError(error)));\n}\n\nexport class LocalPrototypeLifecycle implements PrototypeLifecycle {\n readonly #runtime: PrototypeLifecycleRuntimeContext;\n readonly #catalog: PrototypeCatalogLike;\n readonly #repository: GitRepository;\n readonly #preparePrototypeFiles: PreparePrototypeFiles;\n readonly #deploymentProvider?: DeploymentProvider;\n readonly #applicationId?: string;\n readonly #themeRegistry?: ThemeRegistry;\n\n constructor(options: LocalPrototypeLifecycleOptions) {\n const internalOptions = options as InternalLocalPrototypeLifecycleOptions;\n this.#runtime =\n internalOptions.runtime ??\n createPrototypeLifecycleRuntime(internalOptions);\n this.#themeRegistry = options.themeRegistry;\n this.#catalog =\n internalOptions.catalog ??\n new PrototypeCatalog({\n ...this.#runtime,\n themeRegistry: this.#themeRegistry,\n });\n this.#repository = this.#runtime.gitRepository;\n this.#preparePrototypeFiles =\n internalOptions.preparePrototypeFiles ?? (() => undefined);\n this.#deploymentProvider = internalOptions.deploymentProvider;\n this.#applicationId = internalOptions.applicationId;\n if (\n this.#deploymentProvider &&\n (typeof this.#applicationId !== \"string\" ||\n this.#applicationId.length === 0)\n ) {\n throw new TypeError(\n \"applicationId must be provided when deploymentProvider is configured\",\n );\n }\n }\n\n async #verifiedIdentity(identity: BonfireIdentity) {\n return parseBonfireIdentity(identity);\n }\n\n async #currentBranch() {\n const branch = await this.#repository.currentBranch();\n if (branch === \"HEAD\" || branch.length === 0) {\n throw new GitRepositoryError(\"conflict\", \"current-branch\");\n }\n return branch;\n }\n\n async #ownedPrototype(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ) {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parsePrototypeCommandInput(input);\n if (normalizedInput.ref.login !== verifiedIdentity.login) {\n throw new PrototypeOwnershipError();\n }\n const summary = await this.#catalog.getSummary(normalizedInput.ref);\n if (!summary) {\n throw new PrototypeNotFoundError();\n }\n\n return {\n ref: normalizedInput.ref,\n path: repositoryRelativePath(this.#runtime, normalizedInput.ref),\n summary,\n };\n }\n\n async #prepareMutationBranch(login: string) {\n if (this.#runtime.automaticBranchSwitch === \"disabled\") {\n return this.#currentBranch();\n }\n\n await prepareIdentityBranch(this.#repository, {\n identityBranch: login,\n primaryBranch: this.#runtime.primaryBranch,\n remote: this.#runtime.remote,\n });\n return login;\n }\n\n async #prepareDestination(\n receipt: OwnedDestinationReceipt,\n expectedFiles: readonly string[],\n request: PreparePrototypeFilesRequest,\n ) {\n try {\n const frozenRequest = Object.freeze({\n ...request,\n ref: Object.freeze({ ...request.ref }),\n identity: Object.freeze({ ...request.identity }),\n ...(request.operation === \"duplicate\"\n ? { source: Object.freeze({ ...request.source }) }\n : {}),\n }) as PreparePrototypeFilesRequest;\n await this.#preparePrototypeFiles(frozenRequest);\n await validateOwnedDestination(\n receipt,\n expectedFiles,\n request.ref,\n this.#themeRegistry,\n );\n } catch {\n try {\n await cleanupOwnedDestination(receipt);\n } catch {\n // The failure remains a finite filesystem failure without retrying cleanup.\n }\n throw new PrototypeScaffoldError(\"filesystem\");\n }\n }\n\n async prepareBranch(\n identity: BonfireIdentity,\n ): Promise<LifecycleResult<BranchPreparationValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n if (this.#runtime.automaticBranchSwitch === \"disabled\") {\n await this.#currentBranch();\n return { status: \"disabled\" } satisfies BranchPreparationValue;\n }\n\n await prepareIdentityBranch(this.#repository, {\n identityBranch: verifiedIdentity.login,\n primaryBranch: this.#runtime.primaryBranch,\n remote: this.#runtime.remote,\n });\n return { status: \"ready\" } satisfies BranchPreparationValue;\n },\n );\n });\n }\n\n async create(\n identity: BonfireIdentity,\n input: CreatePrototypeInput,\n ): Promise<LifecycleResult<CreatePrototypeValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parseCreatePrototypeInput(\n input,\n this.#themeRegistry,\n );\n const ref = destinationRef(verifiedIdentity, normalizedInput.title);\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n if (await this.#catalog.getSummary(ref)) {\n throw new PrototypeScaffoldError(\"collision\");\n }\n\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n const prepared = await scaffoldPrototype({\n paths: this.#runtime,\n ref,\n title: normalizedInput.title,\n description: normalizedInput.description,\n authorName: verifiedIdentity.name,\n theme: normalizedInput.theme,\n themeRegistry: this.#themeRegistry,\n });\n await this.#prepareDestination(\n prepared.receipt,\n prepared.expectedFiles,\n {\n operation: \"create\",\n repositoryRoot: this.#runtime.repositoryRoot,\n prototypeRoot: this.#runtime.prototypeRoot,\n prototypePath: prepared.destination,\n ref,\n identity: verifiedIdentity,\n title: normalizedInput.title,\n description: normalizedInput.description,\n },\n );\n await commitPath(\n this.#repository,\n repositoryRelativePath(this.#runtime, ref),\n `init: ${ref.slug}`,\n );\n const push = await pushBranch(\n this.#repository,\n this.#runtime.remote,\n branch,\n );\n\n return {\n ref,\n url: getPrototypeUrl(ref),\n remoteStatus: push.remoteStatus,\n } satisfies CreatePrototypeValue;\n },\n );\n });\n }\n\n async edit(\n identity: BonfireIdentity,\n input: EditPrototypeInput,\n ): Promise<LifecycleResult<EditPrototypeValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parseEditPrototypeInput(\n input,\n this.#themeRegistry,\n );\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n const { ref, path } = await this.#ownedPrototype(verifiedIdentity, {\n ref: normalizedInput.ref,\n });\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n await assertPrototypeDirectory(this.#runtime, ref);\n const document = await readMetadataDocument(\n this.#runtime,\n ref,\n this.#themeRegistry,\n );\n const metadata = parsePrototypeMetadata(document, {\n themeRegistry: this.#themeRegistry,\n });\n if (metadata.authorLogin !== ref.login) {\n throw new PrototypeNotFoundError();\n }\n\n await writeMetadataDocument(this.#runtime, ref, {\n ...document,\n title: normalizedInput.title,\n description: normalizedInput.description,\n updatedAt: new Date().toISOString(),\n ...(normalizedInput.theme === undefined\n ? {}\n : { theme: normalizedInput.theme }),\n });\n await commitPath(this.#repository, path, `edit: ${ref.slug}`);\n await pushBranch(this.#repository, this.#runtime.remote, branch);\n\n return { edited: true, ref } satisfies EditPrototypeValue;\n },\n );\n });\n }\n\n async delete(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeletePrototypeValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parsePrototypeCommandInput(input);\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n const { ref, path } = await this.#ownedPrototype(\n verifiedIdentity,\n normalizedInput,\n );\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n await removePrototypeDirectory(this.#runtime, ref);\n await commitPath(this.#repository, path, `delete: ${ref.slug}`);\n await pushBranch(this.#repository, this.#runtime.remote, branch);\n\n return { deleted: true, ref } satisfies DeletePrototypeValue;\n },\n );\n });\n }\n\n async getDirtyState(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DirtyObservationValue>> {\n return resultFrom(async () => {\n const { path, summary } = await this.#ownedPrototype(identity, input);\n const status = await this.#repository.status([path]);\n return {\n status: status.files.length > 0 ? \"dirty\" : \"clean\",\n ...(summary.previewUrl !== undefined\n ? { previewUrl: summary.previewUrl }\n : {}),\n } satisfies DirtyObservationValue;\n });\n }\n\n async deploy(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DeploymentValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parsePrototypeCommandInput(input);\n if (!this.#deploymentProvider) {\n throw new DeploymentUnavailableError();\n }\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n const { ref, path } = await this.#ownedPrototype(\n verifiedIdentity,\n normalizedInput,\n );\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n await assertPrototypeDirectory(this.#runtime, ref);\n const document = await readMetadataDocument(\n this.#runtime,\n ref,\n this.#themeRegistry,\n );\n const metadata = parsePrototypeMetadata(document, {\n themeRegistry: this.#themeRegistry,\n });\n if (metadata.authorLogin !== ref.login) {\n throw new PrototypeNotFoundError();\n }\n await commitPath(this.#repository, path, `deploy: ${ref.slug}`);\n await pushBranch(this.#repository, this.#runtime.remote, branch);\n\n const deployment = await this.#deploymentProvider!.deploy({\n applicationId: this.#applicationId!,\n login: verifiedIdentity.login,\n });\n const previewUrl = new URL(\n getPrototypeUrl(ref).slice(1),\n `${deployment.url.replace(/\\/+$/, \"\")}/`,\n ).toString();\n\n let warning: DeploymentWarningCode | undefined;\n try {\n await writeMetadataDocument(this.#runtime, ref, {\n ...document,\n previewUrl,\n updatedAt: new Date().toISOString(),\n });\n await commitPath(\n this.#repository,\n path,\n `deploy: ${ref.slug} (metadata)`,\n );\n await pushBranch(this.#repository, this.#runtime.remote, branch);\n } catch {\n warning = \"metadata-persistence-failed\";\n }\n\n if (warning === undefined) {\n try {\n await mergeIdentityBranchToPrimary(this.#repository, {\n branch,\n primaryBranch: this.#runtime.primaryBranch,\n remote: this.#runtime.remote,\n });\n } catch {\n warning = \"primary-merge-failed\";\n }\n }\n\n return {\n deployed: true,\n ref,\n previewUrl,\n deploymentId: deployment.deploymentId,\n readyState: deployment.readyState,\n warning,\n } satisfies DeploymentValue;\n },\n );\n });\n }\n\n async save(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<SavePrototypeValue>> {\n return resultFrom(async () => {\n const { ref, path } = await this.#ownedPrototype(identity, input);\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n await commitPath(this.#repository, path, `save: ${ref.slug}`);\n return { saved: true } satisfies SavePrototypeValue;\n },\n );\n });\n }\n\n async discard(\n identity: BonfireIdentity,\n input: PrototypeCommandInput,\n ): Promise<LifecycleResult<DiscardPrototypeValue>> {\n return resultFrom(async () => {\n const { path } = await this.#ownedPrototype(identity, input);\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n await discardPath(this.#repository, path);\n return { discarded: true } satisfies DiscardPrototypeValue;\n },\n );\n });\n }\n\n async duplicate(\n identity: BonfireIdentity,\n input: DuplicatePrototypeInput,\n ): Promise<LifecycleResult<DuplicatePrototypeValue>> {\n return resultFrom(async () => {\n const verifiedIdentity = await this.#verifiedIdentity(identity);\n const normalizedInput = parseDuplicatePrototypeInput(input);\n if (!(await this.#catalog.getSummary(normalizedInput.source))) {\n throw new PrototypeDuplicateError(\"source-not-found\");\n }\n const ref = destinationRef(verifiedIdentity, normalizedInput.title);\n\n return withRepositoryOperation(\n this.#runtime.repositoryRealPath,\n async () => {\n if (await this.#catalog.getSummary(ref)) {\n throw new PrototypeDuplicateError(\"collision\");\n }\n\n const branch = await this.#prepareMutationBranch(\n verifiedIdentity.login,\n );\n const prepared = await duplicatePrototype({\n paths: this.#runtime,\n source: normalizedInput.source,\n destination: ref,\n title: normalizedInput.title,\n description: normalizedInput.description,\n authorName: verifiedIdentity.name,\n themeRegistry: this.#themeRegistry,\n });\n await this.#prepareDestination(\n prepared.receipt,\n prepared.expectedFiles,\n {\n operation: \"duplicate\",\n repositoryRoot: this.#runtime.repositoryRoot,\n prototypeRoot: this.#runtime.prototypeRoot,\n prototypePath: prepared.destination,\n ref,\n source: normalizedInput.source,\n identity: verifiedIdentity,\n title: normalizedInput.title,\n description: normalizedInput.description,\n },\n );\n await commitPath(\n this.#repository,\n repositoryRelativePath(this.#runtime, ref),\n `init: ${ref.slug}`,\n );\n const push = await pushBranch(\n this.#repository,\n this.#runtime.remote,\n branch,\n );\n\n return {\n ref,\n url: getPrototypeUrl(ref),\n remoteStatus: push.remoteStatus,\n } satisfies DuplicatePrototypeValue;\n },\n );\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"operation-gate.d.ts","sourceRoot":"","sources":["../../src/lifecycle/operation-gate.ts"],"names":[],"mappings":"AAQA,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAG,iBAAiB,CAAU;IAE3C,cAGC;CACF;AAOD,wBAAgB,0BAA0B,CAAC,cAAc,EAAE,MAAM,UAEhE;AAED,wBAAsB,uBAAuB,CAAC,KAAK,EACjD,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,GAC1C,OAAO,CAAC,KAAK,CAAC,CAchB"}
1
+ {"version":3,"file":"operation-gate.d.ts","sourceRoot":"","sources":["../../src/lifecycle/operation-gate.ts"],"names":[],"mappings":"AAQA,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAG,iBAAiB,CAAU;IAE3C,cAGC;CACF;AAOD,wBAAgB,0BAA0B,CAAC,cAAc,EAAE,MAAM,UAEhE;AAED,wBAAsB,uBAAuB,CAAC,KAAK,EACjD,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,GAC1C,OAAO,CAAC,KAAK,CAAC,CAchB","sourcesContent":["import { realpathSync } from \"node:fs\";\n\nconst GLOBAL_GATE_KEY = \"__bonfirePrototypeLifecycleOperationGates\";\n\ntype OperationGateGlobal = typeof globalThis & {\n [GLOBAL_GATE_KEY]?: Set<string>;\n};\n\nexport class RepositoryBusyError extends Error {\n readonly code = \"repository-busy\" as const;\n\n constructor() {\n super(\"A Bonfire repository operation is already in progress.\");\n this.name = \"RepositoryBusyError\";\n }\n}\n\nfunction getActiveRepositories() {\n const global = globalThis as OperationGateGlobal;\n return (global[GLOBAL_GATE_KEY] ??= new Set<string>());\n}\n\nexport function canonicalizeRepositoryPath(repositoryRoot: string) {\n return realpathSync(repositoryRoot);\n}\n\nexport async function withRepositoryOperation<Value>(\n repositoryRoot: string,\n operation: () => Value | PromiseLike<Value>,\n): Promise<Value> {\n const canonicalRoot = canonicalizeRepositoryPath(repositoryRoot);\n const activeRepositories = getActiveRepositories();\n\n if (activeRepositories.has(canonicalRoot)) {\n throw new RepositoryBusyError();\n }\n\n activeRepositories.add(canonicalRoot);\n try {\n return await operation();\n } finally {\n activeRepositories.delete(canonicalRoot);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"operation-gate.js","sourceRoot":"","sources":["../../src/lifecycle/operation-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,eAAe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C,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,SAAS,qBAAqB;IAC5B,MAAM,MAAM,GAAG,UAAiC,CAAC;IACjD,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,IAAI,GAAG,EAAU,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,cAAsB;IAC/D,OAAO,YAAY,CAAC,cAAc,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,cAAsB,EACtB,SAA2C;IAE3C,MAAM,aAAa,GAAG,0BAA0B,CAAC,cAAc,CAAC,CAAC;IACjE,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;IAEnD,IAAI,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,mBAAmB,EAAE,CAAC;IAClC,CAAC;IAED,kBAAkB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACtC,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,EAAE,CAAC;IAC3B,CAAC;YAAS,CAAC;QACT,kBAAkB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC","sourcesContent":["import { realpathSync } from \"node:fs\";\n\nconst GLOBAL_GATE_KEY = \"__bonfirePrototypeLifecycleOperationGates\";\n\ntype OperationGateGlobal = typeof globalThis & {\n [GLOBAL_GATE_KEY]?: Set<string>;\n};\n\nexport class RepositoryBusyError extends Error {\n readonly code = \"repository-busy\" as const;\n\n constructor() {\n super(\"A Bonfire repository operation is already in progress.\");\n this.name = \"RepositoryBusyError\";\n }\n}\n\nfunction getActiveRepositories() {\n const global = globalThis as OperationGateGlobal;\n return (global[GLOBAL_GATE_KEY] ??= new Set<string>());\n}\n\nexport function canonicalizeRepositoryPath(repositoryRoot: string) {\n return realpathSync(repositoryRoot);\n}\n\nexport async function withRepositoryOperation<Value>(\n repositoryRoot: string,\n operation: () => Value | PromiseLike<Value>,\n): Promise<Value> {\n const canonicalRoot = canonicalizeRepositoryPath(repositoryRoot);\n const activeRepositories = getActiveRepositories();\n\n if (activeRepositories.has(canonicalRoot)) {\n throw new RepositoryBusyError();\n }\n\n activeRepositories.add(canonicalRoot);\n try {\n return await operation();\n } finally {\n activeRepositories.delete(canonicalRoot);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-context.d.ts","sourceRoot":"","sources":["../../src/lifecycle/runtime-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EACnC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAS9B,MAAM,MAAM,gCAAgC,GAAG,uBAAuB,GAAG;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC,qBAAqB,CAAC,EAAE,yBAAyB,CAAC;IAClD,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG,6BAA6B,GAAG;IAC7E,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,yBAAyB,CAAC;IACjD,cAAc,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC5C,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AASF,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,gCAAgC,CA4BlC"}
1
+ {"version":3,"file":"runtime-context.d.ts","sourceRoot":"","sources":["../../src/lifecycle/runtime-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EACnC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAS9B,MAAM,MAAM,gCAAgC,GAAG,uBAAuB,GAAG;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC,qBAAqB,CAAC,EAAE,yBAAyB,CAAC;IAClD,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG,6BAA6B,GAAG;IAC7E,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,yBAAyB,CAAC;IACjD,cAAc,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC5C,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AASF,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,gCAAgC,CA4BlC","sourcesContent":["import { realpathSync } from \"node:fs\";\nimport type { AutomaticBranchSwitchMode } from \"@ebay-dt/bonfire-core\";\nimport {\n resolvePrototypeCatalogPaths,\n type PrototypeCatalogOptions,\n type ResolvedPrototypeCatalogPaths,\n} from \"../prototype-paths.js\";\nimport {\n createGitRepository,\n type GitCommitIdentity,\n type GitRepository,\n} from \"../git-repository.js\";\n\nconst DEFAULT_REMOTE = \"origin\";\nconst DEFAULT_PRIMARY_BRANCH = \"main\";\nconst DEFAULT_COMMIT_IDENTITY: GitCommitIdentity = {\n name: \"Bonfire\",\n email: \"bonfire@localhost\",\n};\n\nexport type PrototypeLifecycleRuntimeOptions = PrototypeCatalogOptions & {\n remote?: string;\n primaryBranch?: string;\n commitIdentity?: GitCommitIdentity;\n automaticBranchSwitch?: AutomaticBranchSwitchMode;\n gitRepository?: GitRepository;\n};\n\nexport type PrototypeLifecycleRuntimeContext = ResolvedPrototypeCatalogPaths & {\n repositoryRealPath: string;\n remote: string;\n primaryBranch: string;\n automaticBranchSwitch: AutomaticBranchSwitchMode;\n commitIdentity: Readonly<GitCommitIdentity>;\n gitRepository: GitRepository;\n};\n\nfunction requireNonEmptyOption(value: string | undefined, option: string) {\n if (value !== undefined && value.length === 0) {\n throw new TypeError(`${option} must be a nonempty string`);\n }\n return value;\n}\n\nexport function createPrototypeLifecycleRuntime(\n options: PrototypeLifecycleRuntimeOptions,\n): PrototypeLifecycleRuntimeContext {\n const paths = resolvePrototypeCatalogPaths(options);\n const repositoryRealPath = realpathSync(paths.repositoryRoot);\n const remote =\n requireNonEmptyOption(options.remote, \"remote\") ?? DEFAULT_REMOTE;\n const primaryBranch =\n requireNonEmptyOption(options.primaryBranch, \"primaryBranch\") ??\n DEFAULT_PRIMARY_BRANCH;\n const automaticBranchSwitch = options.automaticBranchSwitch ?? \"enabled\";\n const commitIdentity = Object.freeze({\n ...DEFAULT_COMMIT_IDENTITY,\n ...options.commitIdentity,\n });\n\n return {\n ...paths,\n repositoryRealPath,\n remote,\n primaryBranch,\n automaticBranchSwitch,\n commitIdentity,\n gitRepository:\n options.gitRepository ??\n createGitRepository({\n repositoryRoot: paths.repositoryRoot,\n commitIdentity,\n }),\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-context.js","sourceRoot":"","sources":["../../src/lifecycle/runtime-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EACL,4BAA4B,GAG7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,mBAAmB,GAGpB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,cAAc,GAAG,QAAQ,CAAC;AAChC,MAAM,s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,KAAK,CAAC,cAAc;gBACpC,cAAc;aACf,CAAC;KACL,CAAC;AACJ,CAAC","sourcesContent":["import { realpathSync } from \"node:fs\";\nimport type { AutomaticBranchSwitchMode } from \"@ebay-dt/bonfire-core\";\nimport {\n resolvePrototypeCatalogPaths,\n type PrototypeCatalogOptions,\n type ResolvedPrototypeCatalogPaths,\n} from \"../prototype-paths.js\";\nimport {\n createGitRepository,\n type GitCommitIdentity,\n type GitRepository,\n} from \"../git-repository.js\";\n\nconst DEFAULT_REMOTE = \"origin\";\nconst DEFAULT_PRIMARY_BRANCH = \"main\";\nconst DEFAULT_COMMIT_IDENTITY: GitCommitIdentity = {\n name: \"Bonfire\",\n email: \"bonfire@localhost\",\n};\n\nexport type PrototypeLifecycleRuntimeOptions = PrototypeCatalogOptions & {\n remote?: string;\n primaryBranch?: string;\n commitIdentity?: GitCommitIdentity;\n automaticBranchSwitch?: AutomaticBranchSwitchMode;\n gitRepository?: GitRepository;\n};\n\nexport type PrototypeLifecycleRuntimeContext = ResolvedPrototypeCatalogPaths & {\n repositoryRealPath: string;\n remote: string;\n primaryBranch: string;\n automaticBranchSwitch: AutomaticBranchSwitchMode;\n commitIdentity: Readonly<GitCommitIdentity>;\n gitRepository: GitRepository;\n};\n\nfunction requireNonEmptyOption(value: string | undefined, option: string) {\n if (value !== undefined && value.length === 0) {\n throw new TypeError(`${option} must be a nonempty string`);\n }\n return value;\n}\n\nexport function createPrototypeLifecycleRuntime(\n options: PrototypeLifecycleRuntimeOptions,\n): PrototypeLifecycleRuntimeContext {\n const paths = resolvePrototypeCatalogPaths(options);\n const repositoryRealPath = realpathSync(paths.repositoryRoot);\n const remote =\n requireNonEmptyOption(options.remote, \"remote\") ?? DEFAULT_REMOTE;\n const primaryBranch =\n requireNonEmptyOption(options.primaryBranch, \"primaryBranch\") ??\n DEFAULT_PRIMARY_BRANCH;\n const automaticBranchSwitch = options.automaticBranchSwitch ?? \"enabled\";\n const commitIdentity = Object.freeze({\n ...DEFAULT_COMMIT_IDENTITY,\n ...options.commitIdentity,\n });\n\n return {\n ...paths,\n repositoryRealPath,\n remote,\n primaryBranch,\n automaticBranchSwitch,\n commitIdentity,\n gitRepository:\n options.gitRepository ??\n createGitRepository({\n repositoryRoot: paths.repositoryRoot,\n commitIdentity,\n }),\n };\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { type UserPreferences } from "@ebay-dt/bonfire-core";
2
+ import type { PrototypeLifecycleRuntimeContext } from "./lifecycle/runtime-context.js";
3
+ export type PrototypePreferencesOptions = Pick<PrototypeLifecycleRuntimeContext, "prototypeRoot">;
4
+ export interface PrototypePreferencesLike {
5
+ read(login: string): Promise<UserPreferences>;
6
+ update(login: string, preferences: Partial<UserPreferences>): Promise<UserPreferences>;
7
+ }
8
+ export type PrototypePreferencesErrorCode = "invalid-login" | "unsafe-path" | "read-failed" | "write-failed";
9
+ export declare class PrototypePreferencesError extends Error {
10
+ readonly code: PrototypePreferencesErrorCode;
11
+ constructor(code: PrototypePreferencesErrorCode);
12
+ }
13
+ export declare class PrototypePreferences implements PrototypePreferencesLike {
14
+ #private;
15
+ constructor(options: PrototypePreferencesOptions);
16
+ read(login: string): Promise<UserPreferences>;
17
+ update(login: string, preferences: Partial<UserPreferences>): Promise<UserPreferences>;
18
+ }
19
+ //# sourceMappingURL=preferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../src/preferences.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAOvF,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAC5C,gCAAgC,EAChC,eAAe,CAChB,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9C,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,OAAO,CAAC,eAAe,CAAC,GACpC,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7B;AAED,MAAM,MAAM,6BAA6B,GACvC,eAAe,GAAG,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC;AAEnE,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,EAAE,6BAA6B,CAAC;IAE7C,YAAY,IAAI,EAAE,6BAA6B,EAI9C;CACF;AAqJD,qBAAa,oBAAqB,YAAW,wBAAwB;;IAGnE,YAAY,OAAO,EAAE,2BAA2B,EAE/C;IAEK,IAAI,CAAC,KAAK,EAAE,MAAM,4BAGvB;IAEK,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,eAAe,CAAC,4BAWhE;CACF","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport { lstat, mkdir, open, rename, rm } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport {\n definePrototypeRef,\n parseUserPreferences,\n PrototypeRefError,\n type UserPreferences,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycleRuntimeContext } from \"./lifecycle/runtime-context.js\";\nimport { hasErrorCode, isFileNotFound, isRecord } from \"./internal/utils.js\";\n\nconst PREFERENCES_FILE = \"preferences.json\";\nconst TEMP_FILE_PREFIX = \".preferences-\";\nconst FILE_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);\n\nexport type PrototypePreferencesOptions = Pick<\n PrototypeLifecycleRuntimeContext,\n \"prototypeRoot\"\n>;\n\nexport interface PrototypePreferencesLike {\n read(login: string): Promise<UserPreferences>;\n update(\n login: string,\n preferences: Partial<UserPreferences>,\n ): Promise<UserPreferences>;\n}\n\nexport type PrototypePreferencesErrorCode =\n \"invalid-login\" | \"unsafe-path\" | \"read-failed\" | \"write-failed\";\n\nexport class PrototypePreferencesError extends Error {\n readonly code: PrototypePreferencesErrorCode;\n\n constructor(code: PrototypePreferencesErrorCode) {\n super(\"Unable to access prototype preferences\");\n this.name = \"PrototypePreferencesError\";\n this.code = code;\n }\n}\n\ntype PreferenceDocument = Record<string, unknown>;\n\nconst writeQueues = new Map<string, Promise<unknown>>();\n\nfunction isFileExists(error: unknown) {\n return hasErrorCode(error, \"EEXIST\");\n}\n\nfunction isSymlinkError(error: unknown) {\n return hasErrorCode(error, \"ELOOP\");\n}\n\nfunction normalizeLogin(login: string) {\n try {\n return definePrototypeRef({ login, slug: \"preferences\" }).login;\n } catch (error) {\n if (error instanceof PrototypeRefError) {\n throw new PrototypePreferencesError(\"invalid-login\");\n }\n throw error;\n }\n}\n\nfunction preferencePath(prototypeRoot: string, login: string) {\n const normalizedLogin = normalizeLogin(login);\n const userDirectory = join(prototypeRoot, normalizedLogin);\n return {\n userDirectory,\n path: join(userDirectory, PREFERENCES_FILE),\n };\n}\n\nasync function assertDirectory(path: string) {\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new PrototypePreferencesError(\"unsafe-path\");\n }\n}\n\nasync function assertSafeUserDirectory(path: string) {\n try {\n await assertDirectory(path);\n } catch (error) {\n if (!isFileNotFound(error)) {\n if (error instanceof PrototypePreferencesError) throw error;\n throw new PrototypePreferencesError(\"write-failed\");\n }\n try {\n await mkdir(path, { recursive: true, mode: 0o700 });\n await assertDirectory(path);\n } catch (nestedError) {\n if (nestedError instanceof PrototypePreferencesError) throw nestedError;\n throw new PrototypePreferencesError(\n isFileNotFound(nestedError) ? \"unsafe-path\" : \"write-failed\",\n );\n }\n }\n}\n\nasync function assertSafePreferenceFile(path: string) {\n try {\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || !stats.isFile()) {\n throw new PrototypePreferencesError(\"unsafe-path\");\n }\n } catch (error) {\n if (!isFileNotFound(error)) throw error;\n }\n}\n\nasync function readDocument(userDirectory: string, path: string) {\n try {\n await assertDirectory(userDirectory);\n await assertSafePreferenceFile(path);\n const file = await open(path, FILE_OPEN_FLAGS);\n try {\n const source = await file.readFile(\"utf8\");\n try {\n const value = JSON.parse(source);\n return isRecord(value) ? value : {};\n } catch {\n return {};\n }\n } finally {\n await file.close();\n }\n } catch (error) {\n if (error instanceof PrototypePreferencesError) throw error;\n if (isFileNotFound(error)) return {};\n if (isSymlinkError(error)) {\n throw new PrototypePreferencesError(\"unsafe-path\");\n }\n throw new PrototypePreferencesError(\"read-failed\");\n }\n}\n\nasync function writeAtomically(path: string, source: string) {\n let temporaryPath: string | undefined;\n\n try {\n for (let attempt = 0; attempt < 3; attempt += 1) {\n temporaryPath = join(\n dirname(path),\n `${TEMP_FILE_PREFIX}${randomUUID()}.tmp`,\n );\n try {\n const file = await open(temporaryPath, \"wx\", 0o600);\n try {\n await file.writeFile(source, \"utf8\");\n await file.sync();\n } finally {\n await file.close();\n }\n break;\n } catch (error) {\n if (!isFileExists(error) || attempt === 2) throw error;\n temporaryPath = undefined;\n }\n }\n\n await assertSafePreferenceFile(path);\n await rename(temporaryPath!, path);\n } catch (error) {\n if (error instanceof PrototypePreferencesError) throw error;\n throw new PrototypePreferencesError(\"write-failed\");\n } finally {\n if (temporaryPath !== undefined) {\n await rm(temporaryPath, { force: true }).catch(() => undefined);\n }\n }\n}\n\nasync function withWriteLock<Value>(\n path: string,\n operation: () => Promise<Value>,\n) {\n const previous = writeQueues.get(path) ?? Promise.resolve();\n const current = previous.catch(() => undefined).then(operation);\n writeQueues.set(path, current);\n\n try {\n return await current;\n } finally {\n if (writeQueues.get(path) === current) writeQueues.delete(path);\n }\n}\n\nexport class PrototypePreferences implements PrototypePreferencesLike {\n readonly #prototypeRoot: string;\n\n constructor(options: PrototypePreferencesOptions) {\n this.#prototypeRoot = options.prototypeRoot;\n }\n\n async read(login: string) {\n const { userDirectory, path } = preferencePath(this.#prototypeRoot, login);\n return parseUserPreferences(await readDocument(userDirectory, path));\n }\n\n async update(login: string, preferences: Partial<UserPreferences>) {\n const { userDirectory, path } = preferencePath(this.#prototypeRoot, login);\n\n return withWriteLock(path, async () => {\n await assertSafeUserDirectory(userDirectory);\n const existing = await readDocument(userDirectory, path);\n const supported = parseUserPreferences(preferences);\n const next = { ...existing, ...supported };\n await writeAtomically(path, `${JSON.stringify(next, null, 2)}\\n`);\n return parseUserPreferences(next);\n });\n }\n}\n"]}
@@ -0,0 +1,182 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { constants } from "node:fs";
3
+ import { lstat, mkdir, open, rename, rm } from "node:fs/promises";
4
+ import { dirname, join } from "node:path";
5
+ import { definePrototypeRef, parseUserPreferences, PrototypeRefError, } from "@ebay-dt/bonfire-core";
6
+ import { hasErrorCode, isFileNotFound, isRecord } from "./internal/utils.js";
7
+ const PREFERENCES_FILE = "preferences.json";
8
+ const TEMP_FILE_PREFIX = ".preferences-";
9
+ const FILE_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);
10
+ export class PrototypePreferencesError extends Error {
11
+ code;
12
+ constructor(code) {
13
+ super("Unable to access prototype preferences");
14
+ this.name = "PrototypePreferencesError";
15
+ this.code = code;
16
+ }
17
+ }
18
+ const writeQueues = new Map();
19
+ function isFileExists(error) {
20
+ return hasErrorCode(error, "EEXIST");
21
+ }
22
+ function isSymlinkError(error) {
23
+ return hasErrorCode(error, "ELOOP");
24
+ }
25
+ function normalizeLogin(login) {
26
+ try {
27
+ return definePrototypeRef({ login, slug: "preferences" }).login;
28
+ }
29
+ catch (error) {
30
+ if (error instanceof PrototypeRefError) {
31
+ throw new PrototypePreferencesError("invalid-login");
32
+ }
33
+ throw error;
34
+ }
35
+ }
36
+ function preferencePath(prototypeRoot, login) {
37
+ const normalizedLogin = normalizeLogin(login);
38
+ const userDirectory = join(prototypeRoot, normalizedLogin);
39
+ return {
40
+ userDirectory,
41
+ path: join(userDirectory, PREFERENCES_FILE),
42
+ };
43
+ }
44
+ async function assertDirectory(path) {
45
+ const stats = await lstat(path);
46
+ if (stats.isSymbolicLink() || !stats.isDirectory()) {
47
+ throw new PrototypePreferencesError("unsafe-path");
48
+ }
49
+ }
50
+ async function assertSafeUserDirectory(path) {
51
+ try {
52
+ await assertDirectory(path);
53
+ }
54
+ catch (error) {
55
+ if (!isFileNotFound(error)) {
56
+ if (error instanceof PrototypePreferencesError)
57
+ throw error;
58
+ throw new PrototypePreferencesError("write-failed");
59
+ }
60
+ try {
61
+ await mkdir(path, { recursive: true, mode: 0o700 });
62
+ await assertDirectory(path);
63
+ }
64
+ catch (nestedError) {
65
+ if (nestedError instanceof PrototypePreferencesError)
66
+ throw nestedError;
67
+ throw new PrototypePreferencesError(isFileNotFound(nestedError) ? "unsafe-path" : "write-failed");
68
+ }
69
+ }
70
+ }
71
+ async function assertSafePreferenceFile(path) {
72
+ try {
73
+ const stats = await lstat(path);
74
+ if (stats.isSymbolicLink() || !stats.isFile()) {
75
+ throw new PrototypePreferencesError("unsafe-path");
76
+ }
77
+ }
78
+ catch (error) {
79
+ if (!isFileNotFound(error))
80
+ throw error;
81
+ }
82
+ }
83
+ async function readDocument(userDirectory, path) {
84
+ try {
85
+ await assertDirectory(userDirectory);
86
+ await assertSafePreferenceFile(path);
87
+ const file = await open(path, FILE_OPEN_FLAGS);
88
+ try {
89
+ const source = await file.readFile("utf8");
90
+ try {
91
+ const value = JSON.parse(source);
92
+ return isRecord(value) ? value : {};
93
+ }
94
+ catch {
95
+ return {};
96
+ }
97
+ }
98
+ finally {
99
+ await file.close();
100
+ }
101
+ }
102
+ catch (error) {
103
+ if (error instanceof PrototypePreferencesError)
104
+ throw error;
105
+ if (isFileNotFound(error))
106
+ return {};
107
+ if (isSymlinkError(error)) {
108
+ throw new PrototypePreferencesError("unsafe-path");
109
+ }
110
+ throw new PrototypePreferencesError("read-failed");
111
+ }
112
+ }
113
+ async function writeAtomically(path, source) {
114
+ let temporaryPath;
115
+ try {
116
+ for (let attempt = 0; attempt < 3; attempt += 1) {
117
+ temporaryPath = join(dirname(path), `${TEMP_FILE_PREFIX}${randomUUID()}.tmp`);
118
+ try {
119
+ const file = await open(temporaryPath, "wx", 0o600);
120
+ try {
121
+ await file.writeFile(source, "utf8");
122
+ await file.sync();
123
+ }
124
+ finally {
125
+ await file.close();
126
+ }
127
+ break;
128
+ }
129
+ catch (error) {
130
+ if (!isFileExists(error) || attempt === 2)
131
+ throw error;
132
+ temporaryPath = undefined;
133
+ }
134
+ }
135
+ await assertSafePreferenceFile(path);
136
+ await rename(temporaryPath, path);
137
+ }
138
+ catch (error) {
139
+ if (error instanceof PrototypePreferencesError)
140
+ throw error;
141
+ throw new PrototypePreferencesError("write-failed");
142
+ }
143
+ finally {
144
+ if (temporaryPath !== undefined) {
145
+ await rm(temporaryPath, { force: true }).catch(() => undefined);
146
+ }
147
+ }
148
+ }
149
+ async function withWriteLock(path, operation) {
150
+ const previous = writeQueues.get(path) ?? Promise.resolve();
151
+ const current = previous.catch(() => undefined).then(operation);
152
+ writeQueues.set(path, current);
153
+ try {
154
+ return await current;
155
+ }
156
+ finally {
157
+ if (writeQueues.get(path) === current)
158
+ writeQueues.delete(path);
159
+ }
160
+ }
161
+ export class PrototypePreferences {
162
+ #prototypeRoot;
163
+ constructor(options) {
164
+ this.#prototypeRoot = options.prototypeRoot;
165
+ }
166
+ async read(login) {
167
+ const { userDirectory, path } = preferencePath(this.#prototypeRoot, login);
168
+ return parseUserPreferences(await readDocument(userDirectory, path));
169
+ }
170
+ async update(login, preferences) {
171
+ const { userDirectory, path } = preferencePath(this.#prototypeRoot, login);
172
+ return withWriteLock(path, async () => {
173
+ await assertSafeUserDirectory(userDirectory);
174
+ const existing = await readDocument(userDirectory, path);
175
+ const supported = parseUserPreferences(preferences);
176
+ const next = { ...existing, ...supported };
177
+ await writeAtomically(path, `${JSON.stringify(next, null, 2)}\n`);
178
+ return parseUserPreferences(next);
179
+ });
180
+ }
181
+ }
182
+ //# sourceMappingURL=preferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.js","sourceRoot":"","sources":["../src/preferences.ts"],"names":[],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AC,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,WAAqC;QAC/D,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QAE3E,OAAO,aAAa,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;YACpC,MAAM,uBAAuB,CAAC,aAAa,CAAC,CAAC;YAC7C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YACzD,MAAM,SAAS,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;YACpD,MAAM,IAAI,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC;YAC3C,MAAM,eAAe,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;YAClE,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { constants } from \"node:fs\";\nimport { lstat, mkdir, open, rename, rm } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport {\n definePrototypeRef,\n parseUserPreferences,\n PrototypeRefError,\n type UserPreferences,\n} from \"@ebay-dt/bonfire-core\";\nimport type { PrototypeLifecycleRuntimeContext } from \"./lifecycle/runtime-context.js\";\nimport { hasErrorCode, isFileNotFound, isRecord } from \"./internal/utils.js\";\n\nconst PREFERENCES_FILE = \"preferences.json\";\nconst TEMP_FILE_PREFIX = \".preferences-\";\nconst FILE_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);\n\nexport type PrototypePreferencesOptions = Pick<\n PrototypeLifecycleRuntimeContext,\n \"prototypeRoot\"\n>;\n\nexport interface PrototypePreferencesLike {\n read(login: string): Promise<UserPreferences>;\n update(\n login: string,\n preferences: Partial<UserPreferences>,\n ): Promise<UserPreferences>;\n}\n\nexport type PrototypePreferencesErrorCode =\n \"invalid-login\" | \"unsafe-path\" | \"read-failed\" | \"write-failed\";\n\nexport class PrototypePreferencesError extends Error {\n readonly code: PrototypePreferencesErrorCode;\n\n constructor(code: PrototypePreferencesErrorCode) {\n super(\"Unable to access prototype preferences\");\n this.name = \"PrototypePreferencesError\";\n this.code = code;\n }\n}\n\ntype PreferenceDocument = Record<string, unknown>;\n\nconst writeQueues = new Map<string, Promise<unknown>>();\n\nfunction isFileExists(error: unknown) {\n return hasErrorCode(error, \"EEXIST\");\n}\n\nfunction isSymlinkError(error: unknown) {\n return hasErrorCode(error, \"ELOOP\");\n}\n\nfunction normalizeLogin(login: string) {\n try {\n return definePrototypeRef({ login, slug: \"preferences\" }).login;\n } catch (error) {\n if (error instanceof PrototypeRefError) {\n throw new PrototypePreferencesError(\"invalid-login\");\n }\n throw error;\n }\n}\n\nfunction preferencePath(prototypeRoot: string, login: string) {\n const normalizedLogin = normalizeLogin(login);\n const userDirectory = join(prototypeRoot, normalizedLogin);\n return {\n userDirectory,\n path: join(userDirectory, PREFERENCES_FILE),\n };\n}\n\nasync function assertDirectory(path: string) {\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new PrototypePreferencesError(\"unsafe-path\");\n }\n}\n\nasync function assertSafeUserDirectory(path: string) {\n try {\n await assertDirectory(path);\n } catch (error) {\n if (!isFileNotFound(error)) {\n if (error instanceof PrototypePreferencesError) throw error;\n throw new PrototypePreferencesError(\"write-failed\");\n }\n try {\n await mkdir(path, { recursive: true, mode: 0o700 });\n await assertDirectory(path);\n } catch (nestedError) {\n if (nestedError instanceof PrototypePreferencesError) throw nestedError;\n throw new PrototypePreferencesError(\n isFileNotFound(nestedError) ? \"unsafe-path\" : \"write-failed\",\n );\n }\n }\n}\n\nasync function assertSafePreferenceFile(path: string) {\n try {\n const stats = await lstat(path);\n if (stats.isSymbolicLink() || !stats.isFile()) {\n throw new PrototypePreferencesError(\"unsafe-path\");\n }\n } catch (error) {\n if (!isFileNotFound(error)) throw error;\n }\n}\n\nasync function readDocument(userDirectory: string, path: string) {\n try {\n await assertDirectory(userDirectory);\n await assertSafePreferenceFile(path);\n const file = await open(path, FILE_OPEN_FLAGS);\n try {\n const source = await file.readFile(\"utf8\");\n try {\n const value = JSON.parse(source);\n return isRecord(value) ? value : {};\n } catch {\n return {};\n }\n } finally {\n await file.close();\n }\n } catch (error) {\n if (error instanceof PrototypePreferencesError) throw error;\n if (isFileNotFound(error)) return {};\n if (isSymlinkError(error)) {\n throw new PrototypePreferencesError(\"unsafe-path\");\n }\n throw new PrototypePreferencesError(\"read-failed\");\n }\n}\n\nasync function writeAtomically(path: string, source: string) {\n let temporaryPath: string | undefined;\n\n try {\n for (let attempt = 0; attempt < 3; attempt += 1) {\n temporaryPath = join(\n dirname(path),\n `${TEMP_FILE_PREFIX}${randomUUID()}.tmp`,\n );\n try {\n const file = await open(temporaryPath, \"wx\", 0o600);\n try {\n await file.writeFile(source, \"utf8\");\n await file.sync();\n } finally {\n await file.close();\n }\n break;\n } catch (error) {\n if (!isFileExists(error) || attempt === 2) throw error;\n temporaryPath = undefined;\n }\n }\n\n await assertSafePreferenceFile(path);\n await rename(temporaryPath!, path);\n } catch (error) {\n if (error instanceof PrototypePreferencesError) throw error;\n throw new PrototypePreferencesError(\"write-failed\");\n } finally {\n if (temporaryPath !== undefined) {\n await rm(temporaryPath, { force: true }).catch(() => undefined);\n }\n }\n}\n\nasync function withWriteLock<Value>(\n path: string,\n operation: () => Promise<Value>,\n) {\n const previous = writeQueues.get(path) ?? Promise.resolve();\n const current = previous.catch(() => undefined).then(operation);\n writeQueues.set(path, current);\n\n try {\n return await current;\n } finally {\n if (writeQueues.get(path) === current) writeQueues.delete(path);\n }\n}\n\nexport class PrototypePreferences implements PrototypePreferencesLike {\n readonly #prototypeRoot: string;\n\n constructor(options: PrototypePreferencesOptions) {\n this.#prototypeRoot = options.prototypeRoot;\n }\n\n async read(login: string) {\n const { userDirectory, path } = preferencePath(this.#prototypeRoot, login);\n return parseUserPreferences(await readDocument(userDirectory, path));\n }\n\n async update(login: string, preferences: Partial<UserPreferences>) {\n const { userDirectory, path } = preferencePath(this.#prototypeRoot, login);\n\n return withWriteLock(path, async () => {\n await assertSafeUserDirectory(userDirectory);\n const existing = await readDocument(userDirectory, path);\n const supported = parseUserPreferences(preferences);\n const next = { ...existing, ...supported };\n await writeAtomically(path, `${JSON.stringify(next, null, 2)}\\n`);\n return parseUserPreferences(next);\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-prototype-files.d.ts","sourceRoot":"","sources":["../src/prepare-prototype-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE3E,MAAM,MAAM,4BAA4B,GACpC,QAAQ,CAAC;IACP,SAAS,EAAE,QAAQ,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,YAAY,CAAC;IAClB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC,GACF,QAAQ,CAAC;IACP,SAAS,EAAE,WAAW,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,YAAY,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC,CAAC;AAEP,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,4BAA4B,KAClC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"prepare-prototype-files.d.ts","sourceRoot":"","sources":["../src/prepare-prototype-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE3E,MAAM,MAAM,4BAA4B,GACpC,QAAQ,CAAC;IACP,SAAS,EAAE,QAAQ,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,YAAY,CAAC;IAClB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC,GACF,QAAQ,CAAC;IACP,SAAS,EAAE,WAAW,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,YAAY,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC,CAAC;AAEP,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,4BAA4B,KAClC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import type { BonfireIdentity, PrototypeRef } from \"@ebay-dt/bonfire-core\";\n\nexport type PreparePrototypeFilesRequest =\n | Readonly<{\n operation: \"create\";\n repositoryRoot: string;\n prototypeRoot: string;\n prototypePath: string;\n ref: PrototypeRef;\n identity: BonfireIdentity;\n title: string;\n description: string | null;\n }>\n | Readonly<{\n operation: \"duplicate\";\n repositoryRoot: string;\n prototypeRoot: string;\n prototypePath: string;\n ref: PrototypeRef;\n source: PrototypeRef;\n identity: BonfireIdentity;\n title: string;\n description: string | null;\n }>;\n\nexport type PreparePrototypeFiles = (\n request: PreparePrototypeFilesRequest,\n) => void | Promise<void>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-prototype-files.js","sourceRoot":"","sources":["../src/prepare-prototype-files.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"prepare-prototype-files.js","sourceRoot":"","sources":["../src/prepare-prototype-files.ts"],"names":[],"mappings":"","sourcesContent":["import type { BonfireIdentity, PrototypeRef } from \"@ebay-dt/bonfire-core\";\n\nexport type PreparePrototypeFilesRequest =\n | Readonly<{\n operation: \"create\";\n repositoryRoot: string;\n prototypeRoot: string;\n prototypePath: string;\n ref: PrototypeRef;\n identity: BonfireIdentity;\n title: string;\n description: string | null;\n }>\n | Readonly<{\n operation: \"duplicate\";\n repositoryRoot: string;\n prototypeRoot: string;\n prototypePath: string;\n ref: PrototypeRef;\n source: PrototypeRef;\n identity: BonfireIdentity;\n title: string;\n description: string | null;\n }>;\n\nexport type PreparePrototypeFiles = (\n request: PreparePrototypeFilesRequest,\n) => void | Promise<void>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"process-runner.d.ts","sourceRoot":"","sources":["../src/process-runner.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,CACA,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,KAAK,IAAI,GAC7C,qBAAqB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,qBAA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,MAAM,GAAG,UAAU,KAAK,IAAI,GAC7C,qBAAqB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACrC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACrC,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,KAAK,OAAO,CAAC;IACpD,IAAI,CACF,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,qBAAqB,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,qBAAqB,CAAC;CACnE,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,CACR,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,oBAAoB,KAC1B,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,CACN,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,qBAAqB,KAC3B,qBAAqB,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,sBAsB3C,CAAC","sourcesContent":["import {\n execFile as nodeExecFile,\n spawn as nodeSpawn,\n} from \"node:child_process\";\n\nexport type GitHubCliExecOptions = {\n timeout: number;\n maxBuffer: number;\n};\n\nexport type GitHubCliExecResult = {\n stdout: string;\n stderr: string;\n};\n\nexport type GitHubCliOutputStream = {\n on(\n event: \"data\",\n listener: (chunk: string | Uint8Array) => void,\n ): GitHubCliOutputStream;\n};\n\nexport type GitHubCliChildProcess = {\n stdout: GitHubCliOutputStream | null;\n stderr: GitHubCliOutputStream | null;\n kill: (signal?: NodeJS.Signals | number) => boolean;\n once(\n event: \"error\",\n listener: (error: unknown) => void,\n ): GitHubCliChildProcess;\n once(event: \"close\", listener: () => void): GitHubCliChildProcess;\n};\n\nexport type GitHubCliSpawnOptions = {\n stdio: [\"ignore\", \"pipe\", \"pipe\"];\n};\n\nexport type GitHubCliProcessRunner = {\n execFile: (\n executable: string,\n args: readonly string[],\n options: GitHubCliExecOptions,\n ) => Promise<GitHubCliExecResult>;\n spawn?: (\n executable: string,\n args: readonly string[],\n options: GitHubCliSpawnOptions,\n ) => GitHubCliChildProcess;\n};\n\nexport const defaultGitHubCliProcessRunner: GitHubCliProcessRunner = {\n execFile(executable, args, options) {\n return new Promise((resolve, reject) => {\n nodeExecFile(\n executable,\n [...args],\n { ...options, encoding: \"utf8\" },\n (error, stdout, stderr) => {\n if (error) {\n Object.assign(error, { stdout, stderr });\n reject(error);\n return;\n }\n\n resolve({ stdout, stderr });\n },\n );\n });\n },\n spawn(executable, args, options) {\n return nodeSpawn(executable, [...args], options) as GitHubCliChildProcess;\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"process-runner.js","sourceRoot":"","sources":["../src/process-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,IAAI,YAAY,EACxB,KAAK,IAAI,SAAS,GACnB,MAAM,oBAAoB,CAAC;AA+C5B,MAAM,CAAC,MAAM,6BAA6B,GAA2B;IACnE,QAAQ,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO;QAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,YAAY,CACV,UAAU,EACV,CAAC,GAAG,IAAI,CAAC,EACT,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAChC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBACxB,IAAI,KAAK,EAAE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AI,EAAE,OAAO;QAC7B,OAAO,SAAS,CAAC,UAAU,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,OAAO,CAA0B,CAAC;IAC5E,CAAC;CACF,CAAC","sourcesContent":["import {\n execFile as nodeExecFile,\n spawn as nodeSpawn,\n} from \"node:child_process\";\n\nexport type GitHubCliExecOptions = {\n timeout: number;\n maxBuffer: number;\n};\n\nexport type GitHubCliExecResult = {\n stdout: string;\n stderr: string;\n};\n\nexport type GitHubCliOutputStream = {\n on(\n event: \"data\",\n listener: (chunk: string | Uint8Array) => void,\n ): GitHubCliOutputStream;\n};\n\nexport type GitHubCliChildProcess = {\n stdout: GitHubCliOutputStream | null;\n stderr: GitHubCliOutputStream | null;\n kill: (signal?: NodeJS.Signals | number) => boolean;\n once(\n event: \"error\",\n listener: (error: unknown) => void,\n ): GitHubCliChildProcess;\n once(event: \"close\", listener: () => void): GitHubCliChildProcess;\n};\n\nexport type GitHubCliSpawnOptions = {\n stdio: [\"ignore\", \"pipe\", \"pipe\"];\n};\n\nexport type GitHubCliProcessRunner = {\n execFile: (\n executable: string,\n args: readonly string[],\n options: GitHubCliExecOptions,\n ) => Promise<GitHubCliExecResult>;\n spawn?: (\n executable: string,\n args: readonly string[],\n options: GitHubCliSpawnOptions,\n ) => GitHubCliChildProcess;\n};\n\nexport const defaultGitHubCliProcessRunner: GitHubCliProcessRunner = {\n execFile(executable, args, options) {\n return new Promise((resolve, reject) => {\n nodeExecFile(\n executable,\n [...args],\n { ...options, encoding: \"utf8\" },\n (error, stdout, stderr) => {\n if (error) {\n Object.assign(error, { stdout, stderr });\n reject(error);\n return;\n }\n\n resolve({ stdout, stderr });\n },\n );\n });\n },\n spawn(executable, args, options) {\n return nodeSpawn(executable, [...args], options) as GitHubCliChildProcess;\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prototype-catalog.d.ts","sourceRoot":"","sources":["../src/prototype-catalog.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAEtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,uBAAuB,EAE7B,MAAM,sBAAsB,CAAC;AAS9B,MAAM,WAAW,oBAAoB;IACnC,IAAI,IAAI,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC,CAAC;IAC7C,UAAU,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACjE;AAiED,qBAAa,gBAAiB,YAAW,oBAAoB;;IAG3D,YAAY,OAAO,EAAE,uBAAuB,EAE3C;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA0BpE;IAEK,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAiCxC;CACF"}
1
+ {"version":3,"file":"prototype-catalog.d.ts","sourceRoot":"","sources":["../src/prototype-catalog.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAGtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,uBAAuB,EAE7B,MAAM,sBAAsB,CAAC;AAS9B,MAAM,WAAW,oBAAoB;IACnC,IAAI,IAAI,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC,CAAC;IAC7C,UAAU,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;CACjE;AA+ED,qBAAa,gBAAiB,YAAW,oBAAoB;;IAI3D,YAAY,OAAO,EAAE,uBAAuB,EAG3C;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA6BpE;IAEK,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAoCxC;CACF","sourcesContent":["import { constants, type Dirent } from \"node:fs\";\nimport { lstat, open, readdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport {\n createDefaultPrototypeTheme,\n definePrototypeRef,\n definePrototypeSummary,\n parsePrototypeMetadata,\n type PrototypeMetadata,\n type PrototypeRef,\n type PrototypeSummary,\n type ThemeRegistry,\n PrototypeRefError,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n resolvePrototypeCatalogPaths,\n type PrototypeCatalogOptions,\n type ResolvedPrototypeCatalogPaths,\n} from \"./prototype-paths.js\";\n\nconst FILE_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);\n\ntype LocatedPrototype = {\n ref: PrototypeRef;\n absolutePath: string;\n};\n\nexport interface PrototypeCatalogLike {\n scan(): Promise<readonly PrototypeSummary[]>;\n getSummary(ref: PrototypeRef): Promise<PrototypeSummary | null>;\n}\n\nasync function readDirectory(path: string): Promise<Dirent[] | null> {\n try {\n const before = await lstat(path);\n if (before.isSymbolicLink() || !before.isDirectory()) return null;\n\n const entries = await readdir(path, { withFileTypes: true });\n const after = await lstat(path);\n if (after.isSymbolicLink() || !after.isDirectory()) return null;\n return entries;\n } catch {\n return null;\n }\n}\n\nasync function readMetadata(\n path: string,\n themeRegistry?: ThemeRegistry,\n): Promise<PrototypeMetadata | null> {\n try {\n const file = await open(path, FILE_OPEN_FLAGS);\n try {\n const source = await file.readFile(\"utf8\");\n const metadata = parsePrototypeMetadata(JSON.parse(source), {\n themeRegistry,\n });\n if (themeRegistry && metadata.theme === undefined) {\n return {\n ...metadata,\n theme: createDefaultPrototypeTheme(themeRegistry),\n };\n }\n return metadata;\n } finally {\n await file.close();\n }\n } catch {\n return null;\n }\n}\n\nfunction parseLoginSegment(login: string) {\n try {\n return definePrototypeRef({ login, slug: \"prototype\" }).login;\n } catch (error) {\n if (error instanceof PrototypeRefError) return null;\n throw error;\n }\n}\n\nfunction parseSlugSegment(login: string, slug: string) {\n try {\n return definePrototypeRef({ login, slug }).slug;\n } catch (error) {\n if (error instanceof PrototypeRefError) return null;\n throw error;\n }\n}\n\nasync function readLocatedSummary(\n located: LocatedPrototype,\n themeRegistry?: ThemeRegistry,\n): Promise<PrototypeSummary | null> {\n const metadata = await readMetadata(\n join(located.absolutePath, \"metadata.json\"),\n themeRegistry,\n );\n if (metadata === null || metadata.authorLogin !== located.ref.login) {\n return null;\n }\n\n try {\n return definePrototypeSummary(metadata, located.ref);\n } catch {\n return null;\n }\n}\n\nexport class PrototypeCatalog implements PrototypeCatalogLike {\n readonly #paths: ResolvedPrototypeCatalogPaths;\n readonly #themeRegistry?: ThemeRegistry;\n\n constructor(options: PrototypeCatalogOptions) {\n this.#paths = resolvePrototypeCatalogPaths(options);\n this.#themeRegistry = options.themeRegistry;\n }\n\n async getSummary(ref: PrototypeRef): Promise<PrototypeSummary | null> {\n const normalizedRef = definePrototypeRef(ref);\n const prototypePath = join(\n this.#paths.prototypeRoot,\n normalizedRef.login,\n normalizedRef.slug,\n );\n const loginEntries = await readDirectory(\n join(this.#paths.prototypeRoot, normalizedRef.login),\n );\n if (loginEntries === null) return null;\n\n const prototypeEntries = await readDirectory(prototypePath);\n if (prototypeEntries === null) return null;\n if (\n prototypeEntries.some(\n (entry) => entry.name === \"metadata.json\" && entry.isSymbolicLink(),\n )\n ) {\n return null;\n }\n\n return readLocatedSummary(\n {\n ref: normalizedRef,\n absolutePath: prototypePath,\n },\n this.#themeRegistry,\n );\n }\n\n async scan(): Promise<PrototypeSummary[]> {\n const summaries: PrototypeSummary[] = [];\n const loginEntries = await readDirectory(this.#paths.prototypeRoot);\n if (loginEntries === null) return summaries;\n\n for (const loginEntry of loginEntries) {\n if (!loginEntry.isDirectory() || loginEntry.isSymbolicLink()) continue;\n const login = parseLoginSegment(loginEntry.name);\n if (login === null) continue;\n\n const loginPath = join(\n /*turbopackIgnore: true*/ this.#paths.prototypeRoot,\n login,\n );\n const slugEntries = await readDirectory(loginPath);\n if (slugEntries === null) continue;\n\n for (const slugEntry of slugEntries) {\n if (!slugEntry.isDirectory() || slugEntry.isSymbolicLink()) continue;\n const slug = parseSlugSegment(login, slugEntry.name);\n if (slug === null) continue;\n\n const result = await readLocatedSummary(\n {\n ref: { login, slug },\n absolutePath: join(/*turbopackIgnore: true*/ loginPath, slug),\n },\n this.#themeRegistry,\n );\n if (result !== null) summaries.push(result);\n }\n }\n\n return summaries.sort((left, right) =>\n left.url < right.url ? -1 : left.url > right.url ? 1 : 0,\n );\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { constants } from "node:fs";
2
2
  import { lstat, open, readdir } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- import { definePrototypeRef, definePrototypeSummary, parsePrototypeMetadata, PrototypeRefError, } from "@ebay-dt/bonfire-core";
4
+ import { createDefaultPrototypeTheme, definePrototypeRef, definePrototypeSummary, parsePrototypeMetadata, PrototypeRefError, } from "@ebay-dt/bonfire-core";
5
5
  import { resolvePrototypeCatalogPaths, } from "./prototype-paths.js";
6
6
  const FILE_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);
7
7
  async function readDirectory(path) {
@@ -19,12 +19,21 @@ async function readDirectory(path) {
19
19
  return null;
20
20
  }
21
21
  }
22
- async function readMetadata(path) {
22
+ async function readMetadata(path, themeRegistry) {
23
23
  try {
24
24
  const file = await open(path, FILE_OPEN_FLAGS);
25
25
  try {
26
26
  const source = await file.readFile("utf8");
27
- return parsePrototypeMetadata(JSON.parse(source));
27
+ const metadata = parsePrototypeMetadata(JSON.parse(source), {
28
+ themeRegistry,
29
+ });
30
+ if (themeRegistry && metadata.theme === undefined) {
31
+ return {
32
+ ...metadata,
33
+ theme: createDefaultPrototypeTheme(themeRegistry),
34
+ };
35
+ }
36
+ return metadata;
28
37
  }
29
38
  finally {
30
39
  await file.close();
@@ -54,8 +63,8 @@ function parseSlugSegment(login, slug) {
54
63
  throw error;
55
64
  }
56
65
  }
57
- async function readLocatedSummary(located) {
58
- const metadata = await readMetadata(join(located.absolutePath, "metadata.json"));
66
+ async function readLocatedSummary(located, themeRegistry) {
67
+ const metadata = await readMetadata(join(located.absolutePath, "metadata.json"), themeRegistry);
59
68
  if (metadata === null || metadata.authorLogin !== located.ref.login) {
60
69
  return null;
61
70
  }
@@ -68,8 +77,10 @@ async function readLocatedSummary(located) {
68
77
  }
69
78
  export class PrototypeCatalog {
70
79
  #paths;
80
+ #themeRegistry;
71
81
  constructor(options) {
72
82
  this.#paths = resolvePrototypeCatalogPaths(options);
83
+ this.#themeRegistry = options.themeRegistry;
73
84
  }
74
85
  async getSummary(ref) {
75
86
  const normalizedRef = definePrototypeRef(ref);
@@ -86,7 +97,7 @@ export class PrototypeCatalog {
86
97
  return readLocatedSummary({
87
98
  ref: normalizedRef,
88
99
  absolutePath: prototypePath,
89
- });
100
+ }, this.#themeRegistry);
90
101
  }
91
102
  async scan() {
92
103
  const summaries = [];
@@ -113,7 +124,7 @@ export class PrototypeCatalog {
113
124
  const result = await readLocatedSummary({
114
125
  ref: { login, slug },
115
126
  absolutePath: join(/*turbopackIgnore: true*/ loginPath, slug),
116
- });
127
+ }, this.#themeRegistry);
117
128
  if (result !== null)
118
129
  summaries.push(result);
119
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"prototype-catalog.js","sourceRoot":"","sources":["../src/prototype-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EAItB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,4BAA4B,GAG7B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,eAAe,GAAG,SAAS,CAAC,QAAQ,GAAG,CAAC,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;AAYzE,KAAK,UAAU,aAAa,CAAC,IAAY;IACvC,IA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AC,IAAI,CAAC,CAAC;YACjD,IAAI,KAAK,KAAK,IAAI;gBAAE,SAAS;YAE7B,MAAM,SAAS,GAAG,IAAI;YACpB,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EACnD,KAAK,CACN,CAAC;YACF,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,CAAC;YACnD,IAAI,WAAW,KAAK,IAAI;gBAAE,SAAS;YAEnC,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE,CAAC;gBACpC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC,cAAc,EAAE;oBAAE,SAAS;gBACrE,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;gBACrD,IAAI,IAAI,KAAK,IAAI;oBAAE,SAAS;gBAE5B,MAAM,MAAM,GAAG,MAAM,kBAAkB,CACrC;oBACE,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;oBACpB,YAAY,EAAE,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC;iBAC9D,EACD,IAAI,CAAC,cAAc,CACpB,CAAC;gBACF,IAAI,MAAM,KAAK,IAAI;oBAAE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACpC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACzD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { constants, type Dirent } from \"node:fs\";\nimport { lstat, open, readdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport {\n createDefaultPrototypeTheme,\n definePrototypeRef,\n definePrototypeSummary,\n parsePrototypeMetadata,\n type PrototypeMetadata,\n type PrototypeRef,\n type PrototypeSummary,\n type ThemeRegistry,\n PrototypeRefError,\n} from \"@ebay-dt/bonfire-core\";\nimport {\n resolvePrototypeCatalogPaths,\n type PrototypeCatalogOptions,\n type ResolvedPrototypeCatalogPaths,\n} from \"./prototype-paths.js\";\n\nconst FILE_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);\n\ntype LocatedPrototype = {\n ref: PrototypeRef;\n absolutePath: string;\n};\n\nexport interface PrototypeCatalogLike {\n scan(): Promise<readonly PrototypeSummary[]>;\n getSummary(ref: PrototypeRef): Promise<PrototypeSummary | null>;\n}\n\nasync function readDirectory(path: string): Promise<Dirent[] | null> {\n try {\n const before = await lstat(path);\n if (before.isSymbolicLink() || !before.isDirectory()) return null;\n\n const entries = await readdir(path, { withFileTypes: true });\n const after = await lstat(path);\n if (after.isSymbolicLink() || !after.isDirectory()) return null;\n return entries;\n } catch {\n return null;\n }\n}\n\nasync function readMetadata(\n path: string,\n themeRegistry?: ThemeRegistry,\n): Promise<PrototypeMetadata | null> {\n try {\n const file = await open(path, FILE_OPEN_FLAGS);\n try {\n const source = await file.readFile(\"utf8\");\n const metadata = parsePrototypeMetadata(JSON.parse(source), {\n themeRegistry,\n });\n if (themeRegistry && metadata.theme === undefined) {\n return {\n ...metadata,\n theme: createDefaultPrototypeTheme(themeRegistry),\n };\n }\n return metadata;\n } finally {\n await file.close();\n }\n } catch {\n return null;\n }\n}\n\nfunction parseLoginSegment(login: string) {\n try {\n return definePrototypeRef({ login, slug: \"prototype\" }).login;\n } catch (error) {\n if (error instanceof PrototypeRefError) return null;\n throw error;\n }\n}\n\nfunction parseSlugSegment(login: string, slug: string) {\n try {\n return definePrototypeRef({ login, slug }).slug;\n } catch (error) {\n if (error instanceof PrototypeRefError) return null;\n throw error;\n }\n}\n\nasync function readLocatedSummary(\n located: LocatedPrototype,\n themeRegistry?: ThemeRegistry,\n): Promise<PrototypeSummary | null> {\n const metadata = await readMetadata(\n join(located.absolutePath, \"metadata.json\"),\n themeRegistry,\n );\n if (metadata === null || metadata.authorLogin !== located.ref.login) {\n return null;\n }\n\n try {\n return definePrototypeSummary(metadata, located.ref);\n } catch {\n return null;\n }\n}\n\nexport class PrototypeCatalog implements PrototypeCatalogLike {\n readonly #paths: ResolvedPrototypeCatalogPaths;\n readonly #themeRegistry?: ThemeRegistry;\n\n constructor(options: PrototypeCatalogOptions) {\n this.#paths = resolvePrototypeCatalogPaths(options);\n this.#themeRegistry = options.themeRegistry;\n }\n\n async getSummary(ref: PrototypeRef): Promise<PrototypeSummary | null> {\n const normalizedRef = definePrototypeRef(ref);\n const prototypePath = join(\n this.#paths.prototypeRoot,\n normalizedRef.login,\n normalizedRef.slug,\n );\n const loginEntries = await readDirectory(\n join(this.#paths.prototypeRoot, normalizedRef.login),\n );\n if (loginEntries === null) return null;\n\n const prototypeEntries = await readDirectory(prototypePath);\n if (prototypeEntries === null) return null;\n if (\n prototypeEntries.some(\n (entry) => entry.name === \"metadata.json\" && entry.isSymbolicLink(),\n )\n ) {\n return null;\n }\n\n return readLocatedSummary(\n {\n ref: normalizedRef,\n absolutePath: prototypePath,\n },\n this.#themeRegistry,\n );\n }\n\n async scan(): Promise<PrototypeSummary[]> {\n const summaries: PrototypeSummary[] = [];\n const loginEntries = await readDirectory(this.#paths.prototypeRoot);\n if (loginEntries === null) return summaries;\n\n for (const loginEntry of loginEntries) {\n if (!loginEntry.isDirectory() || loginEntry.isSymbolicLink()) continue;\n const login = parseLoginSegment(loginEntry.name);\n if (login === null) continue;\n\n const loginPath = join(\n /*turbopackIgnore: true*/ this.#paths.prototypeRoot,\n login,\n );\n const slugEntries = await readDirectory(loginPath);\n if (slugEntries === null) continue;\n\n for (const slugEntry of slugEntries) {\n if (!slugEntry.isDirectory() || slugEntry.isSymbolicLink()) continue;\n const slug = parseSlugSegment(login, slugEntry.name);\n if (slug === null) continue;\n\n const result = await readLocatedSummary(\n {\n ref: { login, slug },\n absolutePath: join(/*turbopackIgnore: true*/ loginPath, slug),\n },\n this.#themeRegistry,\n );\n if (result !== null) summaries.push(result);\n }\n }\n\n return summaries.sort((left, right) =>\n left.url < right.url ? -1 : left.url > right.url ? 1 : 0,\n );\n }\n}\n"]}
@@ -1,6 +1,8 @@
1
+ import type { ThemeRegistry } from "@ebay-dt/bonfire-core";
1
2
  export type PrototypeCatalogOptions = {
2
3
  repositoryRoot: string;
3
4
  prototypeRoot?: string;
5
+ themeRegistry?: ThemeRegistry;
4
6
  };
5
7
  export type ResolvedPrototypeCatalogPaths = {
6
8
  repositoryRoot: string;