@ebay-dt/bonfire-node 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/duplicate.d.ts +24 -0
- package/dist/duplicate.d.ts.map +1 -0
- package/dist/duplicate.js +333 -0
- package/dist/duplicate.js.map +1 -0
- package/dist/git-repository.d.ts +73 -0
- package/dist/git-repository.d.ts.map +1 -0
- package/dist/git-repository.js +385 -0
- package/dist/git-repository.js.map +1 -0
- package/dist/github-cli.d.ts +27 -0
- package/dist/github-cli.d.ts.map +1 -0
- package/dist/github-cli.js +203 -0
- package/dist/github-cli.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/owned-destination.d.ts +24 -0
- package/dist/internal/owned-destination.d.ts.map +1 -0
- package/dist/internal/owned-destination.js +232 -0
- package/dist/internal/owned-destination.js.map +1 -0
- package/dist/internal/prototype-templates.d.ts +9 -0
- package/dist/internal/prototype-templates.d.ts.map +1 -0
- package/dist/internal/prototype-templates.js +78 -0
- package/dist/internal/prototype-templates.js.map +1 -0
- package/dist/internal/utils.d.ts +12 -0
- package/dist/internal/utils.d.ts.map +1 -0
- package/dist/internal/utils.js +13 -0
- package/dist/internal/utils.js.map +1 -0
- package/dist/lifecycle/dirty-state.d.ts +7 -0
- package/dist/lifecycle/dirty-state.d.ts.map +1 -0
- package/dist/lifecycle/dirty-state.js +10 -0
- package/dist/lifecycle/dirty-state.js.map +1 -0
- package/dist/lifecycle/local-prototype-lifecycle.d.ts +35 -0
- package/dist/lifecycle/local-prototype-lifecycle.d.ts.map +1 -0
- package/dist/lifecycle/local-prototype-lifecycle.js +265 -0
- package/dist/lifecycle/local-prototype-lifecycle.js.map +1 -0
- package/dist/lifecycle/operation-gate.d.ts +7 -0
- package/dist/lifecycle/operation-gate.d.ts.map +1 -0
- package/dist/lifecycle/operation-gate.js +31 -0
- package/dist/lifecycle/operation-gate.js.map +1 -0
- package/dist/lifecycle/runtime-context.d.ts +20 -0
- package/dist/lifecycle/runtime-context.d.ts.map +1 -0
- package/dist/lifecycle/runtime-context.js +41 -0
- package/dist/lifecycle/runtime-context.js.map +1 -0
- package/dist/prepare-prototype-files.d.ts +23 -0
- package/dist/prepare-prototype-files.d.ts.map +1 -0
- package/dist/prepare-prototype-files.js +2 -0
- package/dist/prepare-prototype-files.js.map +1 -0
- package/dist/process-runner.d.ts +27 -0
- package/dist/process-runner.d.ts.map +1 -0
- package/dist/process-runner.js +19 -0
- package/dist/process-runner.js.map +1 -0
- package/dist/prototype-catalog.d.ts +13 -0
- package/dist/prototype-catalog.d.ts.map +1 -0
- package/dist/prototype-catalog.js +124 -0
- package/dist/prototype-catalog.js.map +1 -0
- package/dist/prototype-paths.d.ts +14 -0
- package/dist/prototype-paths.d.ts.map +1 -0
- package/dist/prototype-paths.js +121 -0
- package/dist/prototype-paths.js.map +1 -0
- package/dist/scaffold.d.ts +24 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +173 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/watcher.d.ts +20 -0
- package/dist/watcher.d.ts.map +1 -0
- package/dist/watcher.js +182 -0
- package/dist/watcher.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { join, relative, sep } from "node:path";
|
|
2
|
+
import { definePrototypeRef, getPrototypeUrl, LifecycleInputError, lifecycleFailure, lifecycleSuccess, parseCreatePrototypeInput, parseDuplicatePrototypeInput, parseBonfireIdentity, parsePrototypeCommandInput, slugifyPrototypeTitle, PrototypeRefError, } from "@ebay-dt/bonfire-core";
|
|
3
|
+
import { commitPath, discardPath, GitRepositoryError, prepareIdentityBranch, pushBranch, } from "../git-repository.js";
|
|
4
|
+
import { duplicatePrototype, PrototypeDuplicateError } from "../duplicate.js";
|
|
5
|
+
import { PrototypeCatalog, } from "../prototype-catalog.js";
|
|
6
|
+
import { PrototypeScaffoldError, scaffoldPrototype } from "../scaffold.js";
|
|
7
|
+
import { createPrototypeLifecycleRuntime, } from "./runtime-context.js";
|
|
8
|
+
import { cleanupOwnedDestination, validateOwnedDestination, } from "../internal/owned-destination.js";
|
|
9
|
+
import { RepositoryBusyError, withRepositoryOperation, } from "./operation-gate.js";
|
|
10
|
+
function repositoryRelativePath(runtime, ref) {
|
|
11
|
+
const absolutePath = join(runtime.prototypeRoot, ref.login, ref.slug);
|
|
12
|
+
return relative(runtime.repositoryRoot, absolutePath).split(sep).join("/");
|
|
13
|
+
}
|
|
14
|
+
function destinationRef(identity, title) {
|
|
15
|
+
const slug = slugifyPrototypeTitle(title);
|
|
16
|
+
if (slug === null)
|
|
17
|
+
throw new PrototypeRefError("title", "must produce a slug");
|
|
18
|
+
return definePrototypeRef({ login: identity.login, slug });
|
|
19
|
+
}
|
|
20
|
+
class PrototypeNotFoundError extends Error {
|
|
21
|
+
}
|
|
22
|
+
class PrototypeOwnershipError extends Error {
|
|
23
|
+
}
|
|
24
|
+
function mapError(error) {
|
|
25
|
+
if (error instanceof PrototypeNotFoundError)
|
|
26
|
+
return "not-found";
|
|
27
|
+
if (error instanceof PrototypeOwnershipError)
|
|
28
|
+
return "forbidden";
|
|
29
|
+
if (error instanceof RepositoryBusyError)
|
|
30
|
+
return "repository-busy";
|
|
31
|
+
if (error instanceof PrototypeRefError ||
|
|
32
|
+
error instanceof LifecycleInputError) {
|
|
33
|
+
return "invalid-input";
|
|
34
|
+
}
|
|
35
|
+
if (error instanceof GitRepositoryError) {
|
|
36
|
+
if (error.kind === "timeout")
|
|
37
|
+
return "timeout";
|
|
38
|
+
if (error.kind === "conflict")
|
|
39
|
+
return "working-tree-conflict";
|
|
40
|
+
if (error.kind === "invalid-configuration")
|
|
41
|
+
return "unexpected-failure";
|
|
42
|
+
return "git-failure";
|
|
43
|
+
}
|
|
44
|
+
if (error instanceof PrototypeScaffoldError) {
|
|
45
|
+
if (error.kind === "collision")
|
|
46
|
+
return "already-exists";
|
|
47
|
+
if (error.kind === "invalid-input")
|
|
48
|
+
return "invalid-input";
|
|
49
|
+
return "filesystem-failure";
|
|
50
|
+
}
|
|
51
|
+
if (error instanceof PrototypeDuplicateError) {
|
|
52
|
+
if (error.kind === "source-not-found")
|
|
53
|
+
return "not-found";
|
|
54
|
+
if (error.kind === "collision")
|
|
55
|
+
return "already-exists";
|
|
56
|
+
if (error.kind === "invalid-source")
|
|
57
|
+
return "invalid-input";
|
|
58
|
+
return "filesystem-failure";
|
|
59
|
+
}
|
|
60
|
+
return "unexpected-failure";
|
|
61
|
+
}
|
|
62
|
+
function resultFrom(operation) {
|
|
63
|
+
return operation()
|
|
64
|
+
.then(lifecycleSuccess)
|
|
65
|
+
.catch((error) => lifecycleFailure(mapError(error)));
|
|
66
|
+
}
|
|
67
|
+
export class LocalPrototypeLifecycle {
|
|
68
|
+
#runtime;
|
|
69
|
+
#catalog;
|
|
70
|
+
#repository;
|
|
71
|
+
#preparePrototypeFiles;
|
|
72
|
+
constructor(options) {
|
|
73
|
+
const internalOptions = options;
|
|
74
|
+
this.#runtime =
|
|
75
|
+
internalOptions.runtime ??
|
|
76
|
+
createPrototypeLifecycleRuntime(internalOptions);
|
|
77
|
+
this.#catalog =
|
|
78
|
+
internalOptions.catalog ?? new PrototypeCatalog(this.#runtime);
|
|
79
|
+
this.#repository = this.#runtime.gitRepository;
|
|
80
|
+
this.#preparePrototypeFiles =
|
|
81
|
+
internalOptions.preparePrototypeFiles ?? (() => undefined);
|
|
82
|
+
}
|
|
83
|
+
async #verifiedIdentity(identity) {
|
|
84
|
+
return parseBonfireIdentity(identity);
|
|
85
|
+
}
|
|
86
|
+
async #currentBranch() {
|
|
87
|
+
const branch = await this.#repository.currentBranch();
|
|
88
|
+
if (branch === "HEAD" || branch.length === 0) {
|
|
89
|
+
throw new GitRepositoryError("conflict", "current-branch");
|
|
90
|
+
}
|
|
91
|
+
return branch;
|
|
92
|
+
}
|
|
93
|
+
async #ownedPrototype(identity, input) {
|
|
94
|
+
const verifiedIdentity = await this.#verifiedIdentity(identity);
|
|
95
|
+
const normalizedInput = parsePrototypeCommandInput(input);
|
|
96
|
+
if (normalizedInput.ref.login !== verifiedIdentity.login) {
|
|
97
|
+
throw new PrototypeOwnershipError();
|
|
98
|
+
}
|
|
99
|
+
if (!(await this.#catalog.getSummary(normalizedInput.ref))) {
|
|
100
|
+
throw new PrototypeNotFoundError();
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
ref: normalizedInput.ref,
|
|
104
|
+
path: repositoryRelativePath(this.#runtime, normalizedInput.ref),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async #prepareMutationBranch(login) {
|
|
108
|
+
if (this.#runtime.automaticBranchSwitch === "disabled") {
|
|
109
|
+
return this.#currentBranch();
|
|
110
|
+
}
|
|
111
|
+
await prepareIdentityBranch(this.#repository, {
|
|
112
|
+
identityBranch: login,
|
|
113
|
+
primaryBranch: this.#runtime.primaryBranch,
|
|
114
|
+
remote: this.#runtime.remote,
|
|
115
|
+
});
|
|
116
|
+
return login;
|
|
117
|
+
}
|
|
118
|
+
async #prepareDestination(receipt, expectedFiles, request) {
|
|
119
|
+
try {
|
|
120
|
+
const frozenRequest = Object.freeze({
|
|
121
|
+
...request,
|
|
122
|
+
ref: Object.freeze({ ...request.ref }),
|
|
123
|
+
identity: Object.freeze({ ...request.identity }),
|
|
124
|
+
...(request.operation === "duplicate"
|
|
125
|
+
? { source: Object.freeze({ ...request.source }) }
|
|
126
|
+
: {}),
|
|
127
|
+
});
|
|
128
|
+
await this.#preparePrototypeFiles(frozenRequest);
|
|
129
|
+
await validateOwnedDestination(receipt, expectedFiles, request.ref);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
try {
|
|
133
|
+
await cleanupOwnedDestination(receipt);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// The failure remains a finite filesystem failure without retrying cleanup.
|
|
137
|
+
}
|
|
138
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async prepareBranch(identity) {
|
|
142
|
+
return resultFrom(async () => {
|
|
143
|
+
const verifiedIdentity = await this.#verifiedIdentity(identity);
|
|
144
|
+
return withRepositoryOperation(this.#runtime.repositoryRealPath, async () => {
|
|
145
|
+
if (this.#runtime.automaticBranchSwitch === "disabled") {
|
|
146
|
+
await this.#currentBranch();
|
|
147
|
+
return { status: "disabled" };
|
|
148
|
+
}
|
|
149
|
+
await prepareIdentityBranch(this.#repository, {
|
|
150
|
+
identityBranch: verifiedIdentity.login,
|
|
151
|
+
primaryBranch: this.#runtime.primaryBranch,
|
|
152
|
+
remote: this.#runtime.remote,
|
|
153
|
+
});
|
|
154
|
+
return { status: "ready" };
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
async create(identity, input) {
|
|
159
|
+
return resultFrom(async () => {
|
|
160
|
+
const verifiedIdentity = await this.#verifiedIdentity(identity);
|
|
161
|
+
const normalizedInput = parseCreatePrototypeInput(input);
|
|
162
|
+
const ref = destinationRef(verifiedIdentity, normalizedInput.title);
|
|
163
|
+
return withRepositoryOperation(this.#runtime.repositoryRealPath, async () => {
|
|
164
|
+
if (await this.#catalog.getSummary(ref)) {
|
|
165
|
+
throw new PrototypeScaffoldError("collision");
|
|
166
|
+
}
|
|
167
|
+
const branch = await this.#prepareMutationBranch(verifiedIdentity.login);
|
|
168
|
+
const prepared = await scaffoldPrototype({
|
|
169
|
+
paths: this.#runtime,
|
|
170
|
+
ref,
|
|
171
|
+
title: normalizedInput.title,
|
|
172
|
+
description: normalizedInput.description,
|
|
173
|
+
authorName: verifiedIdentity.name,
|
|
174
|
+
});
|
|
175
|
+
await this.#prepareDestination(prepared.receipt, prepared.expectedFiles, {
|
|
176
|
+
operation: "create",
|
|
177
|
+
repositoryRoot: this.#runtime.repositoryRoot,
|
|
178
|
+
prototypeRoot: this.#runtime.prototypeRoot,
|
|
179
|
+
prototypePath: prepared.destination,
|
|
180
|
+
ref,
|
|
181
|
+
identity: verifiedIdentity,
|
|
182
|
+
title: normalizedInput.title,
|
|
183
|
+
description: normalizedInput.description,
|
|
184
|
+
});
|
|
185
|
+
await commitPath(this.#repository, repositoryRelativePath(this.#runtime, ref), `init: ${ref.slug}`);
|
|
186
|
+
const push = await pushBranch(this.#repository, this.#runtime.remote, branch);
|
|
187
|
+
return {
|
|
188
|
+
ref,
|
|
189
|
+
url: getPrototypeUrl(ref),
|
|
190
|
+
remoteStatus: push.remoteStatus,
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async getDirtyState(identity, input) {
|
|
196
|
+
return resultFrom(async () => {
|
|
197
|
+
const { path } = await this.#ownedPrototype(identity, input);
|
|
198
|
+
const status = await this.#repository.status([path]);
|
|
199
|
+
return {
|
|
200
|
+
status: status.files.length > 0 ? "dirty" : "clean",
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
async save(identity, input) {
|
|
205
|
+
return resultFrom(async () => {
|
|
206
|
+
const { ref, path } = await this.#ownedPrototype(identity, input);
|
|
207
|
+
return withRepositoryOperation(this.#runtime.repositoryRealPath, async () => {
|
|
208
|
+
await commitPath(this.#repository, path, `save: ${ref.slug}`);
|
|
209
|
+
return { saved: true };
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async discard(identity, input) {
|
|
214
|
+
return resultFrom(async () => {
|
|
215
|
+
const { path } = await this.#ownedPrototype(identity, input);
|
|
216
|
+
return withRepositoryOperation(this.#runtime.repositoryRealPath, async () => {
|
|
217
|
+
await discardPath(this.#repository, path);
|
|
218
|
+
return { discarded: true };
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
async duplicate(identity, input) {
|
|
223
|
+
return resultFrom(async () => {
|
|
224
|
+
const verifiedIdentity = await this.#verifiedIdentity(identity);
|
|
225
|
+
const normalizedInput = parseDuplicatePrototypeInput(input);
|
|
226
|
+
if (!(await this.#catalog.getSummary(normalizedInput.source))) {
|
|
227
|
+
throw new PrototypeDuplicateError("source-not-found");
|
|
228
|
+
}
|
|
229
|
+
const ref = destinationRef(verifiedIdentity, normalizedInput.title);
|
|
230
|
+
return withRepositoryOperation(this.#runtime.repositoryRealPath, async () => {
|
|
231
|
+
if (await this.#catalog.getSummary(ref)) {
|
|
232
|
+
throw new PrototypeDuplicateError("collision");
|
|
233
|
+
}
|
|
234
|
+
const branch = await this.#prepareMutationBranch(verifiedIdentity.login);
|
|
235
|
+
const prepared = await duplicatePrototype({
|
|
236
|
+
paths: this.#runtime,
|
|
237
|
+
source: normalizedInput.source,
|
|
238
|
+
destination: ref,
|
|
239
|
+
title: normalizedInput.title,
|
|
240
|
+
description: normalizedInput.description,
|
|
241
|
+
authorName: verifiedIdentity.name,
|
|
242
|
+
});
|
|
243
|
+
await this.#prepareDestination(prepared.receipt, prepared.expectedFiles, {
|
|
244
|
+
operation: "duplicate",
|
|
245
|
+
repositoryRoot: this.#runtime.repositoryRoot,
|
|
246
|
+
prototypeRoot: this.#runtime.prototypeRoot,
|
|
247
|
+
prototypePath: prepared.destination,
|
|
248
|
+
ref,
|
|
249
|
+
source: normalizedInput.source,
|
|
250
|
+
identity: verifiedIdentity,
|
|
251
|
+
title: normalizedInput.title,
|
|
252
|
+
description: normalizedInput.description,
|
|
253
|
+
});
|
|
254
|
+
await commitPath(this.#repository, repositoryRelativePath(this.#runtime, ref), `init: ${ref.slug}`);
|
|
255
|
+
const push = await pushBranch(this.#repository, this.#runtime.remote, branch);
|
|
256
|
+
return {
|
|
257
|
+
ref,
|
|
258
|
+
url: getPrototypeUrl(ref),
|
|
259
|
+
remoteStatus: push.remoteStatus,
|
|
260
|
+
};
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=local-prototype-lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-prototype-lifecycle.js","sourceRoot":"","sources":["../../src/lifecycle/local-prototype-lifecycle.ts"],"names":[],"mappings":"AAAA,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,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,GAelB,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,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EACL,+BAA+B,GAEhC,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GAEzB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AA8C7B,SAAS,sBAAsB,CAC7B,OAAyC,EACzC,GAAoC;IAEpC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,cAAc,CAAC,QAA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KAAK;oBAC5B,WAAW,EAAE,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class RepositoryBusyError extends Error {
|
|
2
|
+
readonly code: "repository-busy";
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
export declare function canonicalizeRepositoryPath(repositoryRoot: string): string;
|
|
6
|
+
export declare function withRepositoryOperation<Value>(repositoryRoot: string, operation: () => Value | PromiseLike<Value>): Promise<Value>;
|
|
7
|
+
//# sourceMappingURL=operation-gate.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
const GLOBAL_GATE_KEY = "__bonfirePrototypeLifecycleOperationGates";
|
|
3
|
+
export class RepositoryBusyError extends Error {
|
|
4
|
+
code = "repository-busy";
|
|
5
|
+
constructor() {
|
|
6
|
+
super("A Bonfire repository operation is already in progress.");
|
|
7
|
+
this.name = "RepositoryBusyError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function getActiveRepositories() {
|
|
11
|
+
const global = globalThis;
|
|
12
|
+
return (global[GLOBAL_GATE_KEY] ??= new Set());
|
|
13
|
+
}
|
|
14
|
+
export function canonicalizeRepositoryPath(repositoryRoot) {
|
|
15
|
+
return realpathSync(repositoryRoot);
|
|
16
|
+
}
|
|
17
|
+
export async function withRepositoryOperation(repositoryRoot, operation) {
|
|
18
|
+
const canonicalRoot = canonicalizeRepositoryPath(repositoryRoot);
|
|
19
|
+
const activeRepositories = getActiveRepositories();
|
|
20
|
+
if (activeRepositories.has(canonicalRoot)) {
|
|
21
|
+
throw new RepositoryBusyError();
|
|
22
|
+
}
|
|
23
|
+
activeRepositories.add(canonicalRoot);
|
|
24
|
+
try {
|
|
25
|
+
return await operation();
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
activeRepositories.delete(canonicalRoot);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=operation-gate.js.map
|
|
@@ -0,0 +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,GAAG,2CAA2C,CAAC;AAMpE,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,GAAG,iBAA0B,CAAC;IAE3C;QACE,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAChE,IAAI,CAAC,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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AutomaticBranchSwitchMode } from "@ebay-dt/bonfire-core";
|
|
2
|
+
import { type PrototypeCatalogOptions, type ResolvedPrototypeCatalogPaths } from "../prototype-paths.js";
|
|
3
|
+
import { type GitCommitIdentity, type GitRepository } from "../git-repository.js";
|
|
4
|
+
export type PrototypeLifecycleRuntimeOptions = PrototypeCatalogOptions & {
|
|
5
|
+
remote?: string;
|
|
6
|
+
primaryBranch?: string;
|
|
7
|
+
commitIdentity?: GitCommitIdentity;
|
|
8
|
+
automaticBranchSwitch?: AutomaticBranchSwitchMode;
|
|
9
|
+
gitRepository?: GitRepository;
|
|
10
|
+
};
|
|
11
|
+
export type PrototypeLifecycleRuntimeContext = ResolvedPrototypeCatalogPaths & {
|
|
12
|
+
repositoryRealPath: string;
|
|
13
|
+
remote: string;
|
|
14
|
+
primaryBranch: string;
|
|
15
|
+
automaticBranchSwitch: AutomaticBranchSwitchMode;
|
|
16
|
+
commitIdentity: Readonly<GitCommitIdentity>;
|
|
17
|
+
gitRepository: GitRepository;
|
|
18
|
+
};
|
|
19
|
+
export declare function createPrototypeLifecycleRuntime(options: PrototypeLifecycleRuntimeOptions): PrototypeLifecycleRuntimeContext;
|
|
20
|
+
//# sourceMappingURL=runtime-context.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { resolvePrototypeCatalogPaths, } from "../prototype-paths.js";
|
|
3
|
+
import { createGitRepository, } from "../git-repository.js";
|
|
4
|
+
const DEFAULT_REMOTE = "origin";
|
|
5
|
+
const DEFAULT_PRIMARY_BRANCH = "main";
|
|
6
|
+
const DEFAULT_COMMIT_IDENTITY = {
|
|
7
|
+
name: "Bonfire",
|
|
8
|
+
email: "bonfire@localhost",
|
|
9
|
+
};
|
|
10
|
+
function requireNonEmptyOption(value, option) {
|
|
11
|
+
if (value !== undefined && value.length === 0) {
|
|
12
|
+
throw new TypeError(`${option} must be a nonempty string`);
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
export function createPrototypeLifecycleRuntime(options) {
|
|
17
|
+
const paths = resolvePrototypeCatalogPaths(options);
|
|
18
|
+
const repositoryRealPath = realpathSync(paths.repositoryRoot);
|
|
19
|
+
const remote = requireNonEmptyOption(options.remote, "remote") ?? DEFAULT_REMOTE;
|
|
20
|
+
const primaryBranch = requireNonEmptyOption(options.primaryBranch, "primaryBranch") ??
|
|
21
|
+
DEFAULT_PRIMARY_BRANCH;
|
|
22
|
+
const automaticBranchSwitch = options.automaticBranchSwitch ?? "enabled";
|
|
23
|
+
const commitIdentity = Object.freeze({
|
|
24
|
+
...DEFAULT_COMMIT_IDENTITY,
|
|
25
|
+
...options.commitIdentity,
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
...paths,
|
|
29
|
+
repositoryRealPath,
|
|
30
|
+
remote,
|
|
31
|
+
primaryBranch,
|
|
32
|
+
automaticBranchSwitch,
|
|
33
|
+
commitIdentity,
|
|
34
|
+
gitRepository: options.gitRepository ??
|
|
35
|
+
createGitRepository({
|
|
36
|
+
repositoryRoot: paths.repositoryRoot,
|
|
37
|
+
commitIdentity,
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=runtime-context.js.map
|
|
@@ -0,0 +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,sBAAsB,GAAG,MAAM,CAAC;AACtC,MAAM,uBAAuB,GAAsB;IACjD,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,mBAAmB;CAC3B,CAAC;AAmBF,SAAS,qBAAqB,CAAC,KAAyB,EAAE,MAAc;IACtE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CAAC,GAAG,MAAM,4BAA4B,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,OAAyC;IAEzC,MAAM,KAAK,GAAG,4BAA4B,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,kBAAkB,GAAG,YAAY,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC9D,MAAM,MAAM,GACV,qBAAqB,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,cAAc,CAAC;IACpE,MAAM,aAAa,GACjB,qBAAqB,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC;QAC7D,sBAAsB,CAAC;IACzB,MAAM,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,IAAI,SAAS,CAAC;IACzE,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;QACnC,GAAG,uBAAuB;QAC1B,GAAG,OAAO,CAAC,cAAc;KAC1B,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,KAAK;QACR,kBAAkB;QAClB,MAAM;QACN,aAAa;QACb,qBAAqB;QACrB,cAAc;QACd,aAAa,EACX,OAAO,CAAC,aAAa;YACrB,mBAAmB,CAAC;gBAClB,cAAc,EAAE,KAAK,CAAC,cAAc;gBACpC,cAAc;aACf,CAAC;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BonfireIdentity, PrototypeRef } from "@ebay-dt/bonfire-core";
|
|
2
|
+
export type PreparePrototypeFilesRequest = Readonly<{
|
|
3
|
+
operation: "create";
|
|
4
|
+
repositoryRoot: string;
|
|
5
|
+
prototypeRoot: string;
|
|
6
|
+
prototypePath: string;
|
|
7
|
+
ref: PrototypeRef;
|
|
8
|
+
identity: BonfireIdentity;
|
|
9
|
+
title: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
}> | Readonly<{
|
|
12
|
+
operation: "duplicate";
|
|
13
|
+
repositoryRoot: string;
|
|
14
|
+
prototypeRoot: string;
|
|
15
|
+
prototypePath: string;
|
|
16
|
+
ref: PrototypeRef;
|
|
17
|
+
source: PrototypeRef;
|
|
18
|
+
identity: BonfireIdentity;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string | null;
|
|
21
|
+
}>;
|
|
22
|
+
export type PreparePrototypeFiles = (request: PreparePrototypeFilesRequest) => void | Promise<void>;
|
|
23
|
+
//# sourceMappingURL=prepare-prototype-files.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-prototype-files.js","sourceRoot":"","sources":["../src/prepare-prototype-files.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type GitHubCliExecOptions = {
|
|
2
|
+
timeout: number;
|
|
3
|
+
maxBuffer: number;
|
|
4
|
+
};
|
|
5
|
+
export type GitHubCliExecResult = {
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
};
|
|
9
|
+
export type GitHubCliOutputStream = {
|
|
10
|
+
on(event: "data", listener: (chunk: string | Uint8Array) => void): GitHubCliOutputStream;
|
|
11
|
+
};
|
|
12
|
+
export type GitHubCliChildProcess = {
|
|
13
|
+
stdout: GitHubCliOutputStream | null;
|
|
14
|
+
stderr: GitHubCliOutputStream | null;
|
|
15
|
+
kill: (signal?: NodeJS.Signals | number) => boolean;
|
|
16
|
+
once(event: "error", listener: (error: unknown) => void): GitHubCliChildProcess;
|
|
17
|
+
once(event: "close", listener: () => void): GitHubCliChildProcess;
|
|
18
|
+
};
|
|
19
|
+
export type GitHubCliSpawnOptions = {
|
|
20
|
+
stdio: ["ignore", "pipe", "pipe"];
|
|
21
|
+
};
|
|
22
|
+
export type GitHubCliProcessRunner = {
|
|
23
|
+
execFile: (executable: string, args: readonly string[], options: GitHubCliExecOptions) => Promise<GitHubCliExecResult>;
|
|
24
|
+
spawn?: (executable: string, args: readonly string[], options: GitHubCliSpawnOptions) => GitHubCliChildProcess;
|
|
25
|
+
};
|
|
26
|
+
export declare const defaultGitHubCliProcessRunner: GitHubCliProcessRunner;
|
|
27
|
+
//# sourceMappingURL=process-runner.d.ts.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { execFile as nodeExecFile, spawn as nodeSpawn, } from "node:child_process";
|
|
2
|
+
export const defaultGitHubCliProcessRunner = {
|
|
3
|
+
execFile(executable, args, options) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
nodeExecFile(executable, [...args], { ...options, encoding: "utf8" }, (error, stdout, stderr) => {
|
|
6
|
+
if (error) {
|
|
7
|
+
Object.assign(error, { stdout, stderr });
|
|
8
|
+
reject(error);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
resolve({ stdout, stderr });
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
spawn(executable, args, options) {
|
|
16
|
+
return nodeSpawn(executable, [...args], options);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=process-runner.js.map
|
|
@@ -0,0 +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,CAAC;oBACV,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;oBACzC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACd,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAC9B,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO;QAC7B,OAAO,SAAS,CAAC,UAAU,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,OAAO,CAA0B,CAAC;IAC5E,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PrototypeRef, type PrototypeSummary } from "@ebay-dt/bonfire-core";
|
|
2
|
+
import { type PrototypeCatalogOptions } from "./prototype-paths.js";
|
|
3
|
+
export interface PrototypeCatalogLike {
|
|
4
|
+
scan(): Promise<readonly PrototypeSummary[]>;
|
|
5
|
+
getSummary(ref: PrototypeRef): Promise<PrototypeSummary | null>;
|
|
6
|
+
}
|
|
7
|
+
export declare class PrototypeCatalog implements PrototypeCatalogLike {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(options: PrototypeCatalogOptions);
|
|
10
|
+
getSummary(ref: PrototypeRef): Promise<PrototypeSummary | null>;
|
|
11
|
+
scan(): Promise<PrototypeSummary[]>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=prototype-catalog.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { lstat, open, readdir } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { definePrototypeRef, definePrototypeSummary, parsePrototypeMetadata, PrototypeRefError, } from "@ebay-dt/bonfire-core";
|
|
5
|
+
import { resolvePrototypeCatalogPaths, } from "./prototype-paths.js";
|
|
6
|
+
const FILE_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);
|
|
7
|
+
async function readDirectory(path) {
|
|
8
|
+
try {
|
|
9
|
+
const before = await lstat(path);
|
|
10
|
+
if (before.isSymbolicLink() || !before.isDirectory())
|
|
11
|
+
return null;
|
|
12
|
+
const entries = await readdir(path, { withFileTypes: true });
|
|
13
|
+
const after = await lstat(path);
|
|
14
|
+
if (after.isSymbolicLink() || !after.isDirectory())
|
|
15
|
+
return null;
|
|
16
|
+
return entries;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function readMetadata(path) {
|
|
23
|
+
try {
|
|
24
|
+
const file = await open(path, FILE_OPEN_FLAGS);
|
|
25
|
+
try {
|
|
26
|
+
const source = await file.readFile("utf8");
|
|
27
|
+
return parsePrototypeMetadata(JSON.parse(source));
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
await file.close();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function parseLoginSegment(login) {
|
|
38
|
+
try {
|
|
39
|
+
return definePrototypeRef({ login, slug: "prototype" }).login;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error instanceof PrototypeRefError)
|
|
43
|
+
return null;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function parseSlugSegment(login, slug) {
|
|
48
|
+
try {
|
|
49
|
+
return definePrototypeRef({ login, slug }).slug;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error instanceof PrototypeRefError)
|
|
53
|
+
return null;
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function readLocatedSummary(located) {
|
|
58
|
+
const metadata = await readMetadata(join(located.absolutePath, "metadata.json"));
|
|
59
|
+
if (metadata === null || metadata.authorLogin !== located.ref.login) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
return definePrototypeSummary(metadata, located.ref);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export class PrototypeCatalog {
|
|
70
|
+
#paths;
|
|
71
|
+
constructor(options) {
|
|
72
|
+
this.#paths = resolvePrototypeCatalogPaths(options);
|
|
73
|
+
}
|
|
74
|
+
async getSummary(ref) {
|
|
75
|
+
const normalizedRef = definePrototypeRef(ref);
|
|
76
|
+
const prototypePath = join(this.#paths.prototypeRoot, normalizedRef.login, normalizedRef.slug);
|
|
77
|
+
const loginEntries = await readDirectory(join(this.#paths.prototypeRoot, normalizedRef.login));
|
|
78
|
+
if (loginEntries === null)
|
|
79
|
+
return null;
|
|
80
|
+
const prototypeEntries = await readDirectory(prototypePath);
|
|
81
|
+
if (prototypeEntries === null)
|
|
82
|
+
return null;
|
|
83
|
+
if (prototypeEntries.some((entry) => entry.name === "metadata.json" && entry.isSymbolicLink())) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return readLocatedSummary({
|
|
87
|
+
ref: normalizedRef,
|
|
88
|
+
absolutePath: prototypePath,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async scan() {
|
|
92
|
+
const summaries = [];
|
|
93
|
+
const loginEntries = await readDirectory(this.#paths.prototypeRoot);
|
|
94
|
+
if (loginEntries === null)
|
|
95
|
+
return summaries;
|
|
96
|
+
for (const loginEntry of loginEntries) {
|
|
97
|
+
if (!loginEntry.isDirectory() || loginEntry.isSymbolicLink())
|
|
98
|
+
continue;
|
|
99
|
+
const login = parseLoginSegment(loginEntry.name);
|
|
100
|
+
if (login === null)
|
|
101
|
+
continue;
|
|
102
|
+
const loginPath = join(
|
|
103
|
+
/*turbopackIgnore: true*/ this.#paths.prototypeRoot, login);
|
|
104
|
+
const slugEntries = await readDirectory(loginPath);
|
|
105
|
+
if (slugEntries === null)
|
|
106
|
+
continue;
|
|
107
|
+
for (const slugEntry of slugEntries) {
|
|
108
|
+
if (!slugEntry.isDirectory() || slugEntry.isSymbolicLink())
|
|
109
|
+
continue;
|
|
110
|
+
const slug = parseSlugSegment(login, slugEntry.name);
|
|
111
|
+
if (slug === null)
|
|
112
|
+
continue;
|
|
113
|
+
const result = await readLocatedSummary({
|
|
114
|
+
ref: { login, slug },
|
|
115
|
+
absolutePath: join(/*turbopackIgnore: true*/ loginPath, slug),
|
|
116
|
+
});
|
|
117
|
+
if (result !== null)
|
|
118
|
+
summaries.push(result);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return summaries.sort((left, right) => left.url < right.url ? -1 : left.url > right.url ? 1 : 0);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=prototype-catalog.js.map
|