@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 @@
|
|
|
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,E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AAC,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,CAAC;oBACtC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;oBACpB,YAAY,EAAE,IAAI,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC;iBAC9D,CAAC,CAAC;gBACH,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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type PrototypeCatalogOptions = {
|
|
2
|
+
repositoryRoot: string;
|
|
3
|
+
prototypeRoot?: string;
|
|
4
|
+
};
|
|
5
|
+
export type ResolvedPrototypeCatalogPaths = {
|
|
6
|
+
repositoryRoot: string;
|
|
7
|
+
prototypeRoot: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class PrototypeCatalogPathError extends Error {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
constructor(path: string, message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare function resolvePrototypeCatalogPaths(options: PrototypeCatalogOptions): ResolvedPrototypeCatalogPaths;
|
|
14
|
+
//# sourceMappingURL=prototype-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prototype-paths.d.ts","sourceRoot":"","sources":["../src/prototype-paths.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAIxC;CACF;AAuID,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,uBAAuB,GAC/B,6BAA6B,CAqB/B"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { lstatSync, realpathSync } from "node:fs";
|
|
2
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
const CONVENTIONAL_PROTOTYPE_ROOT = join("src", "app", "(prototypes)");
|
|
4
|
+
export class PrototypeCatalogPathError extends Error {
|
|
5
|
+
path;
|
|
6
|
+
constructor(path, message) {
|
|
7
|
+
super(`Invalid prototype catalog path at ${path}: ${message}`);
|
|
8
|
+
this.name = "PrototypeCatalogPathError";
|
|
9
|
+
this.path = path;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function assertAbsoluteRepositoryRoot(repositoryRoot) {
|
|
13
|
+
if (typeof repositoryRoot !== "string" || !isAbsolute(repositoryRoot)) {
|
|
14
|
+
throw new PrototypeCatalogPathError("repositoryRoot", "must be an absolute path");
|
|
15
|
+
}
|
|
16
|
+
return resolve(repositoryRoot);
|
|
17
|
+
}
|
|
18
|
+
function resolvePrototypeRoot(repositoryRoot, prototypeRoot) {
|
|
19
|
+
if (prototypeRoot === undefined) {
|
|
20
|
+
return join(repositoryRoot, CONVENTIONAL_PROTOTYPE_ROOT);
|
|
21
|
+
}
|
|
22
|
+
if (typeof prototypeRoot !== "string" || prototypeRoot.length === 0) {
|
|
23
|
+
throw new PrototypeCatalogPathError("prototypeRoot", "must be a nonempty path");
|
|
24
|
+
}
|
|
25
|
+
if (prototypeRoot.split(/[\\/]/u).some((segment) => segment === "..")) {
|
|
26
|
+
throw new PrototypeCatalogPathError("prototypeRoot", "must not contain traversal segments");
|
|
27
|
+
}
|
|
28
|
+
return isAbsolute(prototypeRoot)
|
|
29
|
+
? resolve(prototypeRoot)
|
|
30
|
+
: resolve(repositoryRoot, prototypeRoot);
|
|
31
|
+
}
|
|
32
|
+
function assertContained(repositoryRoot, prototypeRoot) {
|
|
33
|
+
const relativePath = relative(repositoryRoot, prototypeRoot);
|
|
34
|
+
if (relativePath.length === 0 ||
|
|
35
|
+
relativePath === ".." ||
|
|
36
|
+
relativePath.startsWith(`..${sep}`) ||
|
|
37
|
+
isAbsolute(relativePath)) {
|
|
38
|
+
throw new PrototypeCatalogPathError("prototypeRoot", "must be contained within repositoryRoot");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function assertDirectory(path, label) {
|
|
42
|
+
let stats;
|
|
43
|
+
try {
|
|
44
|
+
stats = lstatSync(path);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error &&
|
|
48
|
+
typeof error === "object" &&
|
|
49
|
+
"code" in error &&
|
|
50
|
+
error.code === "ENOENT") {
|
|
51
|
+
throw new PrototypeCatalogPathError(label, "does not exist");
|
|
52
|
+
}
|
|
53
|
+
throw new PrototypeCatalogPathError(label, "could not be inspected");
|
|
54
|
+
}
|
|
55
|
+
if (stats.isSymbolicLink()) {
|
|
56
|
+
throw new PrototypeCatalogPathError(label, "must not be a symbolic link");
|
|
57
|
+
}
|
|
58
|
+
if (!stats.isDirectory()) {
|
|
59
|
+
throw new PrototypeCatalogPathError(label, "must be a directory");
|
|
60
|
+
}
|
|
61
|
+
return realpathSync(path);
|
|
62
|
+
}
|
|
63
|
+
function pathExists(path) {
|
|
64
|
+
try {
|
|
65
|
+
lstatSync(path);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (error &&
|
|
70
|
+
typeof error === "object" &&
|
|
71
|
+
"code" in error &&
|
|
72
|
+
error.code === "ENOENT") {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
throw new PrototypeCatalogPathError("prototypeRoot", "could not be inspected");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function realPathForMissingTarget(path) {
|
|
79
|
+
let current = path;
|
|
80
|
+
const missingSegments = [];
|
|
81
|
+
while (!pathExists(current)) {
|
|
82
|
+
const parent = dirname(current);
|
|
83
|
+
if (parent === current) {
|
|
84
|
+
throw new PrototypeCatalogPathError("prototypeRoot", "could not resolve its existing parent");
|
|
85
|
+
}
|
|
86
|
+
missingSegments.unshift(current.slice(parent.length + 1));
|
|
87
|
+
current = parent;
|
|
88
|
+
}
|
|
89
|
+
let realPath = realpathSync(current);
|
|
90
|
+
for (const segment of missingSegments)
|
|
91
|
+
realPath = join(realPath, segment);
|
|
92
|
+
return realPath;
|
|
93
|
+
}
|
|
94
|
+
function assertRealContainment(repositoryRealPath, prototypeRealPath) {
|
|
95
|
+
const relativePath = relative(repositoryRealPath, prototypeRealPath);
|
|
96
|
+
if (relativePath.length === 0 ||
|
|
97
|
+
relativePath === ".." ||
|
|
98
|
+
relativePath.startsWith(`..${sep}`) ||
|
|
99
|
+
isAbsolute(relativePath)) {
|
|
100
|
+
throw new PrototypeCatalogPathError("prototypeRoot", "escapes repositoryRoot through a symbolic link");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function resolvePrototypeCatalogPaths(options) {
|
|
104
|
+
const repositoryRoot = assertAbsoluteRepositoryRoot(options?.repositoryRoot);
|
|
105
|
+
const prototypeRoot = resolvePrototypeRoot(repositoryRoot, options?.prototypeRoot);
|
|
106
|
+
assertContained(repositoryRoot, prototypeRoot);
|
|
107
|
+
const repositoryRealPath = assertDirectory(repositoryRoot, "repositoryRoot");
|
|
108
|
+
let prototypeRealPath;
|
|
109
|
+
if (pathExists(prototypeRoot)) {
|
|
110
|
+
prototypeRealPath = assertDirectory(prototypeRoot, "prototypeRoot");
|
|
111
|
+
}
|
|
112
|
+
else if (options?.prototypeRoot !== undefined) {
|
|
113
|
+
throw new PrototypeCatalogPathError("prototypeRoot", "does not exist");
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
prototypeRealPath = realPathForMissingTarget(prototypeRoot);
|
|
117
|
+
}
|
|
118
|
+
assertRealContainment(repositoryRealPath, prototypeRealPath);
|
|
119
|
+
return { repositoryRoot, prototypeRoot };
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=prototype-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prototype-paths.js","sourceRoot":"","sources":["../src/prototype-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAE9E,MAAM,2BAA2B,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;AAYvE,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,qCAAqC,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,IAAI,GAA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AAe,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IAE/C,MAAM,kBAAkB,GAAG,eAAe,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAC7E,IAAI,iBAAyB,CAAC;IAE9B,IAAI,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAC9B,iBAAiB,GAAG,eAAe,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IACtE,CAAC;SAAM,IAAI,OAAO,EAAE,aAAa,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,IAAI,yBAAyB,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC;IACzE,CAAC;SAAM,CAAC;QACN,iBAAiB,GAAG,wBAAwB,CAAC,aAAa,CAAC,CAAC;IAC9D,CAAC;IAED,qBAAqB,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,CAAC;IAC7D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type PrototypeRef } from "@ebay-dt/bonfire-core";
|
|
2
|
+
import type { ResolvedPrototypeCatalogPaths } from "./prototype-paths.js";
|
|
3
|
+
import { type OwnedDestinationResult } from "./internal/owned-destination.js";
|
|
4
|
+
type SafeWriteFile = (path: string, content: string, options: {
|
|
5
|
+
encoding: "utf8";
|
|
6
|
+
flag: "wx";
|
|
7
|
+
}) => Promise<void>;
|
|
8
|
+
export type PrototypeScaffoldOptions = {
|
|
9
|
+
paths: Pick<ResolvedPrototypeCatalogPaths, "repositoryRoot" | "prototypeRoot">;
|
|
10
|
+
ref: PrototypeRef;
|
|
11
|
+
title: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
authorName: string | null;
|
|
14
|
+
clock?: () => Date;
|
|
15
|
+
writeFile?: SafeWriteFile;
|
|
16
|
+
};
|
|
17
|
+
export type PrototypeScaffoldErrorKind = "collision" | "filesystem" | "invalid-input";
|
|
18
|
+
export declare class PrototypeScaffoldError extends Error {
|
|
19
|
+
readonly kind: PrototypeScaffoldErrorKind;
|
|
20
|
+
constructor(kind: PrototypeScaffoldErrorKind);
|
|
21
|
+
}
|
|
22
|
+
export declare function scaffoldPrototype({ paths, ref, title, description, authorName, clock, writeFile, }: PrototypeScaffoldOptions): Promise<OwnedDestinationResult>;
|
|
23
|
+
export { GENERATED_FILES } from "./internal/prototype-templates.js";
|
|
24
|
+
//# sourceMappingURL=scaffold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAUA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AAWzC,KAAK,aAAa,GAAG,CACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,KACtC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,IAAI,CACT,6BAA6B,EAC7B,gBAAgB,GAAG,eAAe,CACnC,CAAC;IACF,GAAG,EAAE,YAAY,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GACpC,WAAW,GAAG,YAAY,GAAG,eAAe,CAAC;AAE/C,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAE1C,YAAY,IAAI,EAAE,0BAA0B,EAI3C;CACF;AAuJD,wBAAsB,iBAAiB,CAAC,EACtC,KAAK,EACL,GAAG,EACH,KAAK,EACL,WAAW,EACX,UAAU,EACV,KAAwB,EACxB,SAA0B,GAC3B,EAAE,wBAAwB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA2F5D;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/scaffold.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { lstat, mkdir, open, rm, rmdir, writeFile as writeFileAsync, } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { definePrototypeRef, parsePrototypeMetadata, } from "@ebay-dt/bonfire-core";
|
|
5
|
+
import { captureOwnedDestination, } from "./internal/owned-destination.js";
|
|
6
|
+
import { buildAppCss, buildAppTsx, buildCssModulesDeclaration, buildMetadataJson, buildPageTsx, buildTsConfig, GENERATED_FILES, } from "./internal/prototype-templates.js";
|
|
7
|
+
export class PrototypeScaffoldError extends Error {
|
|
8
|
+
kind;
|
|
9
|
+
constructor(kind) {
|
|
10
|
+
super(`Prototype scaffold failed: ${kind}`);
|
|
11
|
+
this.name = "PrototypeScaffoldError";
|
|
12
|
+
this.kind = kind;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function destinationFor(prototypeRoot, ref) {
|
|
16
|
+
const normalizedRef = definePrototypeRef(ref);
|
|
17
|
+
return join(prototypeRoot, normalizedRef.login, normalizedRef.slug);
|
|
18
|
+
}
|
|
19
|
+
async function assertDirectory(path) {
|
|
20
|
+
try {
|
|
21
|
+
const stats = await lstat(path);
|
|
22
|
+
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
|
23
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof PrototypeScaffoldError)
|
|
28
|
+
throw error;
|
|
29
|
+
if (isMissing(error))
|
|
30
|
+
return;
|
|
31
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function isMissing(error) {
|
|
35
|
+
return (error !== null &&
|
|
36
|
+
typeof error === "object" &&
|
|
37
|
+
"code" in error &&
|
|
38
|
+
error.code === "ENOENT");
|
|
39
|
+
}
|
|
40
|
+
async function ensureDirectory(path) {
|
|
41
|
+
try {
|
|
42
|
+
await mkdir(path, { recursive: true });
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
46
|
+
}
|
|
47
|
+
await assertDirectory(path);
|
|
48
|
+
}
|
|
49
|
+
async function ownedPath(path) {
|
|
50
|
+
const stats = await lstat(path);
|
|
51
|
+
return { path, device: stats.dev, inode: stats.ino };
|
|
52
|
+
}
|
|
53
|
+
async function reserveDestination(path, paths) {
|
|
54
|
+
try {
|
|
55
|
+
await mkdir(path);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error !== null &&
|
|
59
|
+
typeof error === "object" &&
|
|
60
|
+
"code" in error &&
|
|
61
|
+
error.code === "EEXIST") {
|
|
62
|
+
throw new PrototypeScaffoldError("collision");
|
|
63
|
+
}
|
|
64
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
return await captureOwnedDestination({
|
|
68
|
+
path,
|
|
69
|
+
repositoryRoot: paths.repositoryRoot,
|
|
70
|
+
prototypeRoot: paths.prototypeRoot,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// The newly created path is retained because ownership was not proven.
|
|
75
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function createDirectory(path) {
|
|
79
|
+
try {
|
|
80
|
+
await mkdir(path);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
84
|
+
}
|
|
85
|
+
await assertDirectory(path);
|
|
86
|
+
return ownedPath(path);
|
|
87
|
+
}
|
|
88
|
+
async function writeNewFile(path, content, writeFile) {
|
|
89
|
+
try {
|
|
90
|
+
await writeFile(path, content, { encoding: "utf8", flag: "wx" });
|
|
91
|
+
return await ownedPath(path);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function readWrittenMetadata(path) {
|
|
98
|
+
const file = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
99
|
+
try {
|
|
100
|
+
return await file.readFile("utf8");
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
await file.close();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function removeIncompleteDestination(files, directories) {
|
|
107
|
+
try {
|
|
108
|
+
for (const owned of [...files].reverse()) {
|
|
109
|
+
const current = await lstat(owned.path).catch(() => null);
|
|
110
|
+
if (current !== null &&
|
|
111
|
+
!current.isSymbolicLink() &&
|
|
112
|
+
current.dev === owned.device &&
|
|
113
|
+
current.ino === owned.inode) {
|
|
114
|
+
await rm(owned.path, { force: true });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
for (const owned of [...directories].reverse()) {
|
|
118
|
+
const current = await lstat(owned.path).catch(() => null);
|
|
119
|
+
if (current !== null &&
|
|
120
|
+
current.isDirectory() &&
|
|
121
|
+
!current.isSymbolicLink() &&
|
|
122
|
+
current.dev === owned.device &&
|
|
123
|
+
current.ino === owned.inode) {
|
|
124
|
+
await rmdir(owned.path);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export async function scaffoldPrototype({ paths, ref, title, description, authorName, clock = () => new Date(), writeFile = writeFileAsync, }) {
|
|
133
|
+
const normalizedRef = definePrototypeRef(ref);
|
|
134
|
+
const destination = destinationFor(paths.prototypeRoot, normalizedRef);
|
|
135
|
+
const timestamp = clock().toISOString();
|
|
136
|
+
const metadata = buildMetadataJson(title, description, normalizedRef.login, authorName, timestamp);
|
|
137
|
+
parsePrototypeMetadata(JSON.parse(metadata));
|
|
138
|
+
await ensureDirectory(paths.prototypeRoot);
|
|
139
|
+
await ensureDirectory(dirname(destination));
|
|
140
|
+
const ownedFiles = [];
|
|
141
|
+
const receipt = await reserveDestination(destination, paths);
|
|
142
|
+
const ownedDirectories = [receipt];
|
|
143
|
+
try {
|
|
144
|
+
ownedDirectories.push(await createDirectory(join(destination, "components")));
|
|
145
|
+
ownedFiles.push(await writeNewFile(join(destination, "page.tsx"), buildPageTsx(), writeFile));
|
|
146
|
+
ownedFiles.push(await writeNewFile(join(destination, "app.tsx"), buildAppTsx(title, description), writeFile));
|
|
147
|
+
ownedFiles.push(await writeNewFile(join(destination, "app.module.css"), buildAppCss(), writeFile));
|
|
148
|
+
ownedFiles.push(await writeNewFile(join(destination, "components/.gitkeep"), "", writeFile));
|
|
149
|
+
ownedFiles.push(await writeNewFile(join(destination, "metadata.json"), metadata, writeFile));
|
|
150
|
+
ownedFiles.push(await writeNewFile(join(destination, "tsconfig.json"), buildTsConfig(paths.repositoryRoot, destination), writeFile));
|
|
151
|
+
ownedFiles.push(await writeNewFile(join(destination, "css-modules.d.ts"), buildCssModulesDeclaration(), writeFile));
|
|
152
|
+
const writtenMetadata = await readWrittenMetadata(join(destination, "metadata.json"));
|
|
153
|
+
parsePrototypeMetadata(JSON.parse(writtenMetadata));
|
|
154
|
+
return {
|
|
155
|
+
destination,
|
|
156
|
+
receipt,
|
|
157
|
+
expectedFiles: Object.freeze([...GENERATED_FILES]),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
try {
|
|
162
|
+
await removeIncompleteDestination(ownedFiles, ownedDirectories);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
166
|
+
}
|
|
167
|
+
if (error instanceof PrototypeScaffoldError)
|
|
168
|
+
throw error;
|
|
169
|
+
throw new PrototypeScaffoldError("filesystem");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export { GENERATED_FILES } from "./internal/prototype-templates.js";
|
|
173
|
+
//# sourceMappingURL=scaffold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,EAAE,EACF,KAAK,EACL,SAAS,IAAI,cAAc,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GAEvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,uBAAuB,GAExB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,WAAW,EACX,WAAW,EACX,0BAA0B,EAC1B,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAwB3C,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACtC,IAAI,CAA6B;IAE1C,YAAY,IAAgC;QAC1C,KAAK,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,SAAS,cAAc,CAAC,aAAqB,EAAE,GAAiB;IAC9D,MAAM,aAAa,GAAG,kBAAkB,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;YACL,WAAW;YACX,OAAO;YACP,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC;SACnD,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,2BAA2B,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAClE,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,sBAAsB,CAAC,YAAY,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,KAAK,YAAY,sBAAsB;YAAE,MAAM,KAAK,CAAC;QACzD,MAAM,IAAI,sBAAsB,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ChokidarOptions, type FSWatcher } from "chokidar";
|
|
2
|
+
import { type DirtyObservationValue, type PrototypeRef } from "@ebay-dt/bonfire-core";
|
|
3
|
+
import { type GitRepository } from "./git-repository.js";
|
|
4
|
+
export type PrototypeWatchRequest = {
|
|
5
|
+
ref: PrototypeRef;
|
|
6
|
+
initial?: DirtyObservationValue;
|
|
7
|
+
onChange(value: DirtyObservationValue): void;
|
|
8
|
+
};
|
|
9
|
+
export type PrototypeWatcher = {
|
|
10
|
+
subscribe(request: PrototypeWatchRequest): () => void;
|
|
11
|
+
};
|
|
12
|
+
export type PrototypeWatcherOptions = {
|
|
13
|
+
repositoryRoot: string;
|
|
14
|
+
prototypeRoot: string;
|
|
15
|
+
gitRepository?: GitRepository;
|
|
16
|
+
debounceMs?: number;
|
|
17
|
+
watch?: (paths: string[], options: ChokidarOptions) => FSWatcher;
|
|
18
|
+
};
|
|
19
|
+
export declare function createPrototypeWatcher(options: PrototypeWatcherOptions): PrototypeWatcher;
|
|
20
|
+
//# sourceMappingURL=watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../src/watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,SAAS,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAa9E,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,YAAY,CAAC;IAClB,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,IAAI,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,eAAe,KAAK,SAAS,CAAC;CAClE,CAAC;AAwLF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,CAElB"}
|
package/dist/watcher.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { watch as chokidarWatch, } from "chokidar";
|
|
2
|
+
import { definePrototypeRef, } from "@ebay-dt/bonfire-core";
|
|
3
|
+
import { join, relative, sep } from "node:path";
|
|
4
|
+
import { createGitRepository } from "./git-repository.js";
|
|
5
|
+
import { applyDirtyObservation } from "./lifecycle/dirty-state.js";
|
|
6
|
+
const DEFAULT_DEBOUNCE_MS = 250;
|
|
7
|
+
const WATCH_EVENTS = [
|
|
8
|
+
"add",
|
|
9
|
+
"addDir",
|
|
10
|
+
"change",
|
|
11
|
+
"unlink",
|
|
12
|
+
"unlinkDir",
|
|
13
|
+
];
|
|
14
|
+
const WATCH_PATHS = [".git/HEAD", ".git/index", ".git/refs/heads"];
|
|
15
|
+
function keyFor(ref) {
|
|
16
|
+
return `${ref.login}/${ref.slug}`;
|
|
17
|
+
}
|
|
18
|
+
function pathFor(repositoryRoot, prototypeRoot, ref) {
|
|
19
|
+
return relative(repositoryRoot, join(prototypeRoot, ref.login, ref.slug))
|
|
20
|
+
.split(sep)
|
|
21
|
+
.join("/");
|
|
22
|
+
}
|
|
23
|
+
class LocalPrototypeWatcher {
|
|
24
|
+
#repositoryRoot;
|
|
25
|
+
#prototypeRoot;
|
|
26
|
+
#gitRepository;
|
|
27
|
+
#debounceMs;
|
|
28
|
+
#watch;
|
|
29
|
+
#subscribers = new Set();
|
|
30
|
+
#stateCache = new Map();
|
|
31
|
+
#watcher = null;
|
|
32
|
+
#debounceTimer = null;
|
|
33
|
+
#ticking = false;
|
|
34
|
+
#pendingRetick = false;
|
|
35
|
+
constructor(options) {
|
|
36
|
+
this.#repositoryRoot = options.repositoryRoot;
|
|
37
|
+
this.#prototypeRoot = options.prototypeRoot;
|
|
38
|
+
this.#gitRepository =
|
|
39
|
+
options.gitRepository ??
|
|
40
|
+
createGitRepository({ repositoryRoot: options.repositoryRoot });
|
|
41
|
+
this.#debounceMs = options.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
42
|
+
this.#watch = options.watch ?? chokidarWatch;
|
|
43
|
+
}
|
|
44
|
+
subscribe(request) {
|
|
45
|
+
const ref = Object.freeze(definePrototypeRef(request.ref));
|
|
46
|
+
const subscriber = {
|
|
47
|
+
...request,
|
|
48
|
+
ref,
|
|
49
|
+
key: keyFor(ref),
|
|
50
|
+
};
|
|
51
|
+
this.#subscribers.add(subscriber);
|
|
52
|
+
this.#ensureStarted();
|
|
53
|
+
if (!this.#stateCache.has(subscriber.key)) {
|
|
54
|
+
if (subscriber.initial !== undefined) {
|
|
55
|
+
this.#stateCache.set(subscriber.key, subscriber.initial);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
void this.#seed(subscriber);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
let active = true;
|
|
62
|
+
return () => {
|
|
63
|
+
if (!active)
|
|
64
|
+
return;
|
|
65
|
+
active = false;
|
|
66
|
+
this.#subscribers.delete(subscriber);
|
|
67
|
+
if (this.#subscribers.size === 0)
|
|
68
|
+
this.#stop();
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
#ensureStarted() {
|
|
72
|
+
if (this.#watcher)
|
|
73
|
+
return;
|
|
74
|
+
const paths = [
|
|
75
|
+
this.#prototypeRoot,
|
|
76
|
+
...WATCH_PATHS.map((path) => join(this.#repositoryRoot, path)),
|
|
77
|
+
];
|
|
78
|
+
const options = {
|
|
79
|
+
persistent: true,
|
|
80
|
+
ignoreInitial: true,
|
|
81
|
+
followSymlinks: false,
|
|
82
|
+
ignored: [/\.next/, /node_modules/],
|
|
83
|
+
};
|
|
84
|
+
const watcher = this.#watch(paths, options);
|
|
85
|
+
for (const event of WATCH_EVENTS) {
|
|
86
|
+
watcher.on(event, () => this.#scheduleTick());
|
|
87
|
+
}
|
|
88
|
+
watcher.on("error", () => {
|
|
89
|
+
console.error("[bonfire watcher] filesystem observation failed");
|
|
90
|
+
});
|
|
91
|
+
this.#watcher = watcher;
|
|
92
|
+
}
|
|
93
|
+
#scheduleTick() {
|
|
94
|
+
if (this.#debounceTimer)
|
|
95
|
+
clearTimeout(this.#debounceTimer);
|
|
96
|
+
this.#debounceTimer = setTimeout(() => {
|
|
97
|
+
this.#debounceTimer = null;
|
|
98
|
+
void this.#tick();
|
|
99
|
+
}, this.#debounceMs);
|
|
100
|
+
}
|
|
101
|
+
async #read(ref) {
|
|
102
|
+
const path = pathFor(this.#repositoryRoot, this.#prototypeRoot, ref);
|
|
103
|
+
const status = await this.#gitRepository.status([path]);
|
|
104
|
+
return {
|
|
105
|
+
status: status.files.length > 0 ? "dirty" : "clean",
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async #seed(subscriber) {
|
|
109
|
+
try {
|
|
110
|
+
const value = await this.#read(subscriber.ref);
|
|
111
|
+
if (this.#subscribers.has(subscriber) &&
|
|
112
|
+
!this.#stateCache.has(subscriber.key)) {
|
|
113
|
+
this.#stateCache.set(subscriber.key, value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
console.error("[bonfire watcher] Git observation failed");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async #tick() {
|
|
121
|
+
if (this.#ticking) {
|
|
122
|
+
this.#pendingRetick = true;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
this.#ticking = true;
|
|
126
|
+
try {
|
|
127
|
+
const seen = new Set();
|
|
128
|
+
for (const subscriber of this.#subscribers) {
|
|
129
|
+
if (seen.has(subscriber.key))
|
|
130
|
+
continue;
|
|
131
|
+
seen.add(subscriber.key);
|
|
132
|
+
let current;
|
|
133
|
+
try {
|
|
134
|
+
current = await this.#read(subscriber.ref);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
console.error("[bonfire watcher] Git observation failed");
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const previous = this.#stateCache.get(subscriber.key)?.status;
|
|
141
|
+
const transition = applyDirtyObservation(previous, current.status === "dirty");
|
|
142
|
+
if (!transition.changed)
|
|
143
|
+
continue;
|
|
144
|
+
this.#stateCache.set(subscriber.key, transition.value);
|
|
145
|
+
for (const candidate of this.#subscribers) {
|
|
146
|
+
if (candidate.key !== subscriber.key)
|
|
147
|
+
continue;
|
|
148
|
+
try {
|
|
149
|
+
candidate.onChange(transition.value);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
console.error("[bonfire watcher] subscriber callback failed");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
this.#ticking = false;
|
|
159
|
+
if (this.#pendingRetick) {
|
|
160
|
+
this.#pendingRetick = false;
|
|
161
|
+
void this.#tick();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
#stop() {
|
|
166
|
+
if (this.#debounceTimer)
|
|
167
|
+
clearTimeout(this.#debounceTimer);
|
|
168
|
+
this.#debounceTimer = null;
|
|
169
|
+
this.#stateCache.clear();
|
|
170
|
+
const watcher = this.#watcher;
|
|
171
|
+
this.#watcher = null;
|
|
172
|
+
if (watcher) {
|
|
173
|
+
void watcher.close().catch(() => {
|
|
174
|
+
console.error("[bonfire watcher] filesystem cleanup failed");
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
export function createPrototypeWatcher(options) {
|
|
180
|
+
return new LocalPrototypeWatcher(options);
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher.js","sourceRoot":"","sources":["../src/watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,aAAa,GAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,kBAAkB,GAGnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAsB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,YAAY,GAAG;IACnB,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,WAAW;CACH,CAAC;AACX,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,iBAAiB,CAAU,CAAC;AAwB5E,SA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OAAO,CAAC,CAAC;AAC5C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ebay-dt/bonfire-node",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Node.js adapters for Bonfire.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=24"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./watcher": {
|
|
21
|
+
"types": "./dist/watcher.d.ts",
|
|
22
|
+
"import": "./dist/watcher.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.corp.ebay.com/Design-Technology/bonfire",
|
|
28
|
+
"directory": "packages/node"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@ebay-dt/bonfire-core": "0.1.0-alpha.0",
|
|
35
|
+
"chokidar": "^5.0.0",
|
|
36
|
+
"simple-git": "^3.36.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@repo/eslint-config": "0.0.0",
|
|
40
|
+
"@repo/typescript-config": "0.0.0",
|
|
41
|
+
"@types/node": "20.19.43",
|
|
42
|
+
"eslint": "10.9.1",
|
|
43
|
+
"typescript": "7.0.2",
|
|
44
|
+
"vitest": "^5.0.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc -p tsconfig.build.json",
|
|
48
|
+
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
|
|
49
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
50
|
+
"lint": "eslint .",
|
|
51
|
+
"test": "vitest run --passWithNoTests --exclude 'dist/**'"
|
|
52
|
+
}
|
|
53
|
+
}
|