@forgecart/cli 2.202610020748.0 → 2.202610020857.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/dist/src/cli.js +2 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/design-system-seat.d.ts +69 -0
- package/dist/src/commands/design-system-seat.js +92 -0
- package/dist/src/commands/design-system-seat.js.map +1 -0
- package/dist/src/commands/design-system.d.ts +27 -0
- package/dist/src/commands/design-system.js +145 -0
- package/dist/src/commands/design-system.js.map +1 -0
- package/dist/src/commands/init.js +22 -8
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/package-manifest.js +1 -4
- package/dist/src/commands/package-manifest.js.map +1 -1
- package/dist/src/commands/refresh.d.ts +9 -3
- package/dist/src/commands/refresh.js +12 -3
- package/dist/src/commands/refresh.js.map +1 -1
- package/dist/src/commands/template-manifest.d.ts +18 -3
- package/dist/src/commands/template-manifest.js +19 -6
- package/dist/src/commands/template-manifest.js.map +1 -1
- package/dist/src/json.d.ts +6 -0
- package/dist/src/json.js +9 -0
- package/dist/src/json.js.map +1 -0
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { createDesignSystemCommand } from './commands/design-system.js';
|
|
2
3
|
import { createInitCommand } from './commands/init.js';
|
|
3
4
|
import { createDeleteCommand, createDeployCommand, createEnvCommand, createInitApplicationCommand, createListCommand, createLogsCommand, createScaleCommand, createStatusCommand, createWhoamiCommand, } from './commands/placeholders.js';
|
|
4
5
|
import { createRefreshCommand } from './commands/refresh.js';
|
|
@@ -27,6 +28,7 @@ export function createProgram() {
|
|
|
27
28
|
.version(CLI_VERSION);
|
|
28
29
|
program.addCommand(createInitCommand());
|
|
29
30
|
program.addCommand(createRefreshCommand());
|
|
31
|
+
program.addCommand(createDesignSystemCommand());
|
|
30
32
|
program.addCommand(createInitApplicationCommand());
|
|
31
33
|
program.addCommand(createDeployCommand());
|
|
32
34
|
program.addCommand(createListCommand());
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,EAC5B,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAY9E;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,WAAW,CAAC;SACjB,WAAW,CAAC,iEAAiE,CAAC;SAC9E,OAAO,CAAC,WAAW,CAAC,CAAC;IAExB,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,4BAA4B,EAAE,CAAC,CAAC;IACnD,OAAO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CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace design-system seat (#2773) — the merchant's choice of UI
|
|
3
|
+
* framework and content mode for the storefront, stamped with the moment it
|
|
4
|
+
* was recorded.
|
|
5
|
+
*
|
|
6
|
+
* The seat is an optional top-level member of the template manifest
|
|
7
|
+
* (`template-manifest.ts`), and `.forgecart/config.json` mirrors it: the
|
|
8
|
+
* `design-system` command writes both, and every `init` re-run carries the
|
|
9
|
+
* manifest's seat into the config it rewrites. A workspace scaffolded before
|
|
10
|
+
* the seat existed carries none and reads as unset, never as an error.
|
|
11
|
+
*
|
|
12
|
+
* Validation is shape-only — the framework is a lowercase id and the content
|
|
13
|
+
* mode one of {@link ContentMode}. Which frameworks a template can render is
|
|
14
|
+
* the template's concern, not the seat's.
|
|
15
|
+
*/
|
|
16
|
+
/** What the storefront's pages start with: the template's example content, or none. */
|
|
17
|
+
export declare enum ContentMode {
|
|
18
|
+
EXAMPLE = "example",
|
|
19
|
+
BLANK = "blank"
|
|
20
|
+
}
|
|
21
|
+
/** A design-system choice: the UI framework id and the content mode. */
|
|
22
|
+
export interface DesignSystemChoice {
|
|
23
|
+
uiFramework: string;
|
|
24
|
+
contentMode: ContentMode;
|
|
25
|
+
}
|
|
26
|
+
/** The recorded seat: a choice, stamped with the ISO-8601 moment it was recorded. */
|
|
27
|
+
export interface DesignSystemSeat extends DesignSystemChoice {
|
|
28
|
+
recordedAt: string;
|
|
29
|
+
}
|
|
30
|
+
/** The seat as `forgecart design-system --json` reports it — every field null while unset. */
|
|
31
|
+
export interface DesignSystemView {
|
|
32
|
+
uiFramework: string | null;
|
|
33
|
+
contentMode: ContentMode | null;
|
|
34
|
+
recordedAt: string | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The design-system member a refresh reports beside its per-file verdicts: the
|
|
38
|
+
* choice the workspace recorded (null while unset) against the one the bundled
|
|
39
|
+
* template renders. The two differ when the merchant chose a design system the
|
|
40
|
+
* template does not render.
|
|
41
|
+
*/
|
|
42
|
+
export interface DesignSystemPartition {
|
|
43
|
+
recorded: DesignSystemChoice | null;
|
|
44
|
+
rendered: DesignSystemChoice;
|
|
45
|
+
}
|
|
46
|
+
/** The longest UI framework id the seat records. */
|
|
47
|
+
export declare const UI_FRAMEWORK_ID_MAX_LENGTH = 64;
|
|
48
|
+
/**
|
|
49
|
+
* Whether `value` is a UI framework id the seat records: lowercase letters and
|
|
50
|
+
* digits in hyphen-separated segments (`shadcn`, `chakra-ui`), never empty and
|
|
51
|
+
* never starting with a hyphen.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isUiFrameworkId(value: string): boolean;
|
|
54
|
+
/** Whether `value` names a {@link ContentMode}. */
|
|
55
|
+
export declare function isContentMode(value: string): value is ContentMode;
|
|
56
|
+
/**
|
|
57
|
+
* The seat a stored `designSystem` value records, or null when it records none
|
|
58
|
+
* — absent, or not a well-formed seat. A malformed seat reads as unset, the
|
|
59
|
+
* safe direction: the next recorded choice replaces it.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseDesignSystemSeat(value: unknown): DesignSystemSeat | null;
|
|
62
|
+
/** The seat as the command reports it: its three fields, each null while unset. */
|
|
63
|
+
export declare function viewDesignSystem(seat: DesignSystemSeat | undefined): DesignSystemView;
|
|
64
|
+
/** The design-system member of a refresh report for a workspace recording `seat`. */
|
|
65
|
+
export declare function designSystemPartition(seat: DesignSystemSeat | undefined): DesignSystemPartition;
|
|
66
|
+
/** Whether two choices name the same UI framework and content mode. */
|
|
67
|
+
export declare function sameDesignSystem(a: DesignSystemChoice, b: DesignSystemChoice): boolean;
|
|
68
|
+
/** A choice in words, as the human output prints it: `shadcn (example content)`. */
|
|
69
|
+
export declare function describeDesignSystem({ uiFramework, contentMode }: DesignSystemChoice): string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { isJsonObject } from '../json.js';
|
|
2
|
+
/**
|
|
3
|
+
* The workspace design-system seat (#2773) — the merchant's choice of UI
|
|
4
|
+
* framework and content mode for the storefront, stamped with the moment it
|
|
5
|
+
* was recorded.
|
|
6
|
+
*
|
|
7
|
+
* The seat is an optional top-level member of the template manifest
|
|
8
|
+
* (`template-manifest.ts`), and `.forgecart/config.json` mirrors it: the
|
|
9
|
+
* `design-system` command writes both, and every `init` re-run carries the
|
|
10
|
+
* manifest's seat into the config it rewrites. A workspace scaffolded before
|
|
11
|
+
* the seat existed carries none and reads as unset, never as an error.
|
|
12
|
+
*
|
|
13
|
+
* Validation is shape-only — the framework is a lowercase id and the content
|
|
14
|
+
* mode one of {@link ContentMode}. Which frameworks a template can render is
|
|
15
|
+
* the template's concern, not the seat's.
|
|
16
|
+
*/
|
|
17
|
+
/** What the storefront's pages start with: the template's example content, or none. */
|
|
18
|
+
export var ContentMode;
|
|
19
|
+
(function (ContentMode) {
|
|
20
|
+
ContentMode["EXAMPLE"] = "example";
|
|
21
|
+
ContentMode["BLANK"] = "blank";
|
|
22
|
+
})(ContentMode || (ContentMode = {}));
|
|
23
|
+
/** The design system the bundled storefront template renders: daisyUI with example content. */
|
|
24
|
+
const BUNDLED_TEMPLATE_DESIGN_SYSTEM = {
|
|
25
|
+
uiFramework: 'daisyui',
|
|
26
|
+
contentMode: ContentMode.EXAMPLE,
|
|
27
|
+
};
|
|
28
|
+
/** One segment of a UI framework id: lowercase letters and digits. */
|
|
29
|
+
const UI_FRAMEWORK_ID_SEGMENT = /^[a-z0-9]+$/;
|
|
30
|
+
/** The longest UI framework id the seat records. */
|
|
31
|
+
export const UI_FRAMEWORK_ID_MAX_LENGTH = 64;
|
|
32
|
+
const CONTENT_MODES = new Set(Object.values(ContentMode));
|
|
33
|
+
/**
|
|
34
|
+
* Whether `value` is a UI framework id the seat records: lowercase letters and
|
|
35
|
+
* digits in hyphen-separated segments (`shadcn`, `chakra-ui`), never empty and
|
|
36
|
+
* never starting with a hyphen.
|
|
37
|
+
*/
|
|
38
|
+
export function isUiFrameworkId(value) {
|
|
39
|
+
return (value.length <= UI_FRAMEWORK_ID_MAX_LENGTH &&
|
|
40
|
+
value.split('-').every((segment) => UI_FRAMEWORK_ID_SEGMENT.test(segment)));
|
|
41
|
+
}
|
|
42
|
+
/** Whether `value` names a {@link ContentMode}. */
|
|
43
|
+
export function isContentMode(value) {
|
|
44
|
+
return CONTENT_MODES.has(value);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The seat a stored `designSystem` value records, or null when it records none
|
|
48
|
+
* — absent, or not a well-formed seat. A malformed seat reads as unset, the
|
|
49
|
+
* safe direction: the next recorded choice replaces it.
|
|
50
|
+
*/
|
|
51
|
+
export function parseDesignSystemSeat(value) {
|
|
52
|
+
if (!isJsonObject(value))
|
|
53
|
+
return null;
|
|
54
|
+
const { uiFramework, contentMode, recordedAt } = value;
|
|
55
|
+
if (typeof uiFramework !== 'string' || !isUiFrameworkId(uiFramework))
|
|
56
|
+
return null;
|
|
57
|
+
if (typeof contentMode !== 'string' || !isContentMode(contentMode))
|
|
58
|
+
return null;
|
|
59
|
+
if (typeof recordedAt !== 'string' || Number.isNaN(Date.parse(recordedAt)))
|
|
60
|
+
return null;
|
|
61
|
+
return { uiFramework, contentMode, recordedAt };
|
|
62
|
+
}
|
|
63
|
+
/** The seat as the command reports it: its three fields, each null while unset. */
|
|
64
|
+
export function viewDesignSystem(seat) {
|
|
65
|
+
return {
|
|
66
|
+
uiFramework: seat?.uiFramework ?? null,
|
|
67
|
+
contentMode: seat?.contentMode ?? null,
|
|
68
|
+
recordedAt: seat?.recordedAt ?? null,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** The design-system member of a refresh report for a workspace recording `seat`. */
|
|
72
|
+
export function designSystemPartition(seat) {
|
|
73
|
+
return {
|
|
74
|
+
recorded: recordedChoice(seat),
|
|
75
|
+
rendered: { ...BUNDLED_TEMPLATE_DESIGN_SYSTEM },
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Whether two choices name the same UI framework and content mode. */
|
|
79
|
+
export function sameDesignSystem(a, b) {
|
|
80
|
+
return a.uiFramework === b.uiFramework && a.contentMode === b.contentMode;
|
|
81
|
+
}
|
|
82
|
+
/** A choice in words, as the human output prints it: `shadcn (example content)`. */
|
|
83
|
+
export function describeDesignSystem({ uiFramework, contentMode }) {
|
|
84
|
+
return `${uiFramework} (${contentMode} content)`;
|
|
85
|
+
}
|
|
86
|
+
/** The choice a seat records, without its stamp; null while unset. */
|
|
87
|
+
function recordedChoice(seat) {
|
|
88
|
+
if (seat === undefined)
|
|
89
|
+
return null;
|
|
90
|
+
return { uiFramework: seat.uiFramework, contentMode: seat.contentMode };
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=design-system-seat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-system-seat.js","sourceRoot":"","sources":["../../../src/commands/design-system-seat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AAEH,uFAAuF;AACvF,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,8BAAe,CAAA;AACjB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AA+BD,+FAA+F;AAC/F,MAAM,8BAA8B,GAAiC;IACnE,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,WAAW,CAAC,OAAO;CACjC,CAAC;AAEF,sEAAsE;AACtE,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAE9C,oDAAoD;AACpD,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAE7C,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,OAAO,CACL,KAAK,CAAC,MAAM,IAAI,0BAA0B;QAC1C,KAAK,CAAC,K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;KAChD,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,gBAAgB,CAAC,CAAqB,EAAE,CAAqB;IAC3E,OAAO,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,CAAC;AAC5E,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,oBAAoB,CAAC,EAAE,WAAW,EAAE,WAAW,EAAsB;IACnF,OAAO,GAAG,WAAW,KAAK,WAAW,WAAW,CAAC;AACnD,CAAC;AAED,sEAAsE;AACtE,SAAS,cAAc,CAAC,IAAkC;IACxD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* `forgecart design-system` (#2773) — read or record the workspace's design
|
|
4
|
+
* system: the UI framework and the content mode the merchant chose for the
|
|
5
|
+
* storefront (`design-system-seat.ts`).
|
|
6
|
+
*
|
|
7
|
+
* Without flags it reports the seat the template manifest records — every field
|
|
8
|
+
* null for a workspace that records none. With `--ui-framework` and
|
|
9
|
+
* `--content-mode` it records the choice, stamped with the moment it was
|
|
10
|
+
* recorded, in both copies under one stamp: the template manifest's seat and
|
|
11
|
+
* its mirror in `.forgecart/config.json`. Both copies are staged in full beside
|
|
12
|
+
* their files before either is renamed over its file, the manifest — the copy
|
|
13
|
+
* every reader trusts — first; a write that fails before the renames leaves
|
|
14
|
+
* both files as they stood, and `init` re-mirrors the manifest's seat into the
|
|
15
|
+
* config on every run. `--json` prints the seat as the machine seam the admin
|
|
16
|
+
* API parses.
|
|
17
|
+
*/
|
|
18
|
+
interface DesignSystemOptions {
|
|
19
|
+
uiFramework?: string;
|
|
20
|
+
contentMode?: string;
|
|
21
|
+
json?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Run `forgecart design-system`. */
|
|
24
|
+
export declare function runDesignSystem(name: string | undefined, options: DesignSystemOptions): Promise<void>;
|
|
25
|
+
/** Build the `design-system [name]` command. */
|
|
26
|
+
export declare function createDesignSystemCommand(): Command;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { isJsonObject } from '../json.js';
|
|
5
|
+
import { print } from '../output.js';
|
|
6
|
+
import { ContentMode, UI_FRAMEWORK_ID_MAX_LENGTH, describeDesignSystem, isContentMode, isUiFrameworkId, viewDesignSystem, } from './design-system-seat.js';
|
|
7
|
+
import { TEMPLATE_MANIFEST_RELPATH, readTemplateManifest, serializeTemplateManifest, templateManifestPath, } from './template-manifest.js';
|
|
8
|
+
/** The workspace config the seat is mirrored into, workspace-relative. */
|
|
9
|
+
const WORKSPACE_CONFIG_RELPATH = '.forgecart/config.json';
|
|
10
|
+
/** Run `forgecart design-system`. */
|
|
11
|
+
export async function runDesignSystem(name, options) {
|
|
12
|
+
const choice = requestedChoice(options);
|
|
13
|
+
const targetDir = name ? resolve(process.cwd(), name) : process.cwd();
|
|
14
|
+
const config = await readWorkspaceConfig(targetDir);
|
|
15
|
+
if (choice === null) {
|
|
16
|
+
const manifest = await readTemplateManifest(targetDir);
|
|
17
|
+
printSeat(manifest?.designSystem, options.json === true);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
printSeat(await recordDesignSystem(targetDir, config, choice), options.json === true);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The choice the flags request, or null when they request none — a read. The
|
|
24
|
+
* two flags name one choice, so one without the other is refused, as is a
|
|
25
|
+
* value outside its grammar, before any file is read.
|
|
26
|
+
*/
|
|
27
|
+
function requestedChoice({ uiFramework, contentMode, }) {
|
|
28
|
+
if (uiFramework === undefined && contentMode === undefined)
|
|
29
|
+
return null;
|
|
30
|
+
if (uiFramework === undefined || contentMode === undefined) {
|
|
31
|
+
throw new Error('--ui-framework and --content-mode record one design system together: pass both to record it, or neither to read it.');
|
|
32
|
+
}
|
|
33
|
+
if (!isUiFrameworkId(uiFramework)) {
|
|
34
|
+
throw new Error(`--ui-framework "${uiFramework}" is not a UI framework id: lowercase letters and digits, hyphen-separated, at most ${String(UI_FRAMEWORK_ID_MAX_LENGTH)} characters.`);
|
|
35
|
+
}
|
|
36
|
+
if (!isContentMode(contentMode)) {
|
|
37
|
+
throw new Error(`--content-mode "${contentMode}" is not a content mode: pass ${Object.values(ContentMode).join(' or ')}.`);
|
|
38
|
+
}
|
|
39
|
+
return { uiFramework, contentMode };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The workspace's `.forgecart/config.json` as a JSON object — the file `init`
|
|
43
|
+
* writes, whose presence marks an initialized storefront. Its own keys are kept
|
|
44
|
+
* verbatim when the seat is mirrored into it.
|
|
45
|
+
*/
|
|
46
|
+
async function readWorkspaceConfig(targetDir) {
|
|
47
|
+
let raw;
|
|
48
|
+
try {
|
|
49
|
+
raw = await readFile(workspaceConfigPath(targetDir), 'utf8');
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error.code !== 'ENOENT')
|
|
53
|
+
throw error;
|
|
54
|
+
throw new Error(`design-system requires an initialized storefront at ${targetDir} (no ${WORKSPACE_CONFIG_RELPATH} found).`, { cause: error });
|
|
55
|
+
}
|
|
56
|
+
return parseWorkspaceConfig(raw, targetDir);
|
|
57
|
+
}
|
|
58
|
+
function parseWorkspaceConfig(raw, targetDir) {
|
|
59
|
+
let parsed;
|
|
60
|
+
try {
|
|
61
|
+
parsed = JSON.parse(raw);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw new Error(unreadableConfigMessage(targetDir), { cause: error });
|
|
65
|
+
}
|
|
66
|
+
if (!isJsonObject(parsed))
|
|
67
|
+
throw new Error(unreadableConfigMessage(targetDir));
|
|
68
|
+
return parsed;
|
|
69
|
+
}
|
|
70
|
+
function unreadableConfigMessage(targetDir) {
|
|
71
|
+
return `${WORKSPACE_CONFIG_RELPATH} at ${targetDir} is not a JSON object, so the design system cannot be mirrored into it.`;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Record `choice` in the template manifest's seat and in its config mirror,
|
|
75
|
+
* under one stamp. A workspace without a readable manifest has no seat to
|
|
76
|
+
* record into; its first `forgecart refresh` mints the manifest.
|
|
77
|
+
*/
|
|
78
|
+
async function recordDesignSystem(targetDir, config, choice) {
|
|
79
|
+
const manifest = await readTemplateManifest(targetDir);
|
|
80
|
+
if (manifest === null) {
|
|
81
|
+
throw new Error(`design-system requires a readable ${TEMPLATE_MANIFEST_RELPATH} at ${targetDir}; run \`forgecart refresh\` to mint it.`);
|
|
82
|
+
}
|
|
83
|
+
const seat = { ...choice, recordedAt: new Date().toISOString() };
|
|
84
|
+
const nextManifest = { ...manifest, designSystem: seat };
|
|
85
|
+
await landTogether([
|
|
86
|
+
{ path: templateManifestPath(targetDir), content: serializeTemplateManifest(nextManifest) },
|
|
87
|
+
{
|
|
88
|
+
path: workspaceConfigPath(targetDir),
|
|
89
|
+
content: `${JSON.stringify({ ...config, designSystem: seat }, null, 2)}\n`,
|
|
90
|
+
},
|
|
91
|
+
]);
|
|
92
|
+
return seat;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Land every write together: each is staged in full beside its file, then the
|
|
96
|
+
* staged files are renamed over theirs in order — a rename within one
|
|
97
|
+
* directory replaces a file whole. A write that fails removes what it staged,
|
|
98
|
+
* and one that fails before the first rename leaves every file as it stood.
|
|
99
|
+
*/
|
|
100
|
+
async function landTogether(writes) {
|
|
101
|
+
try {
|
|
102
|
+
for (const { path, content } of writes) {
|
|
103
|
+
await writeFile(stagingPath(path), content, 'utf8');
|
|
104
|
+
}
|
|
105
|
+
for (const { path } of writes) {
|
|
106
|
+
await rename(stagingPath(path), path);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
await Promise.all(writes.map(({ path }) => rm(stagingPath(path), { force: true })));
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** Where a write is staged: beside its file, named for this process. */
|
|
115
|
+
function stagingPath(path) {
|
|
116
|
+
return `${path}.${String(process.pid)}.staged`;
|
|
117
|
+
}
|
|
118
|
+
function workspaceConfigPath(targetDir) {
|
|
119
|
+
return join(targetDir, ...WORKSPACE_CONFIG_RELPATH.split('/'));
|
|
120
|
+
}
|
|
121
|
+
/** Report the seat: the `--json` view, or one line for a human. */
|
|
122
|
+
function printSeat(seat, json) {
|
|
123
|
+
if (json) {
|
|
124
|
+
print(JSON.stringify(viewDesignSystem(seat)));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (seat === undefined) {
|
|
128
|
+
print('No design system recorded.');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
print(`Design system: ${describeDesignSystem(seat)}, recorded ${seat.recordedAt}.`);
|
|
132
|
+
}
|
|
133
|
+
/** Build the `design-system [name]` command. */
|
|
134
|
+
export function createDesignSystemCommand() {
|
|
135
|
+
return new Command('design-system')
|
|
136
|
+
.description("Read or record the storefront's design system (UI framework and content mode) in the workspace manifest")
|
|
137
|
+
.argument('[name]', 'Target directory name (defaults to the current directory)')
|
|
138
|
+
.option('--ui-framework <id>', 'UI framework id to record, with --content-mode (e.g. shadcn)')
|
|
139
|
+
.option('--content-mode <mode>', `Content mode to record, with --ui-framework (${Object.values(ContentMode).join(' or ')})`)
|
|
140
|
+
.option('--json', 'Print the recorded design system as JSON')
|
|
141
|
+
.action(async (name, options) => {
|
|
142
|
+
await runDesignSystem(name, options);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=design-system.js.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;IAClE,IAAI,IAAI,EAAE,CAAC;QACT,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACpC,OAAO;IACT,CAAC;IACD,KAAK,CAAC,kBAAkB,oBAAoB,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;AACtF,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,yBAAyB;IACvC,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC;SAChC,WAAW,CACV,yGAAyG,CAC1G;SACA,QAAQ,CAAC,QAAQ,EAAE,2DAA2D,CAAC;SAC/E,MAAM,CAAC,qBAAqB,EAAE,8DAA8D,CAAC;SAC7F,MAAM,CACL,uBAAuB,EACvB,gDAAgD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAC3F;SACA,MAAM,CAAC,QAAQ,EAAE,0CAA0C,CAAC;SAC5D,MAAM,CAAC,KAAK,EAAE,IAAwB,EAAE,OAA4B,EAAE,EAAE;QACvE,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { Command } from 'commander';
|
|
|
5
5
|
import { print } from '../output.js';
|
|
6
6
|
import { QuestionPromptAdapter } from '../question/question-prompt.adapter.js';
|
|
7
7
|
import { readPackageVersion } from '../version.js';
|
|
8
|
-
import { writeTemplateManifest } from './template-manifest.js';
|
|
8
|
+
import { readTemplateManifest, writeTemplateManifest } from './template-manifest.js';
|
|
9
9
|
/**
|
|
10
10
|
* Default shop API base, INCLUDING the mounted path. The API serves the shop
|
|
11
11
|
* GraphQL endpoint at `/shop-api` (`app/forgecart/src/main.ts`), and the SDK
|
|
@@ -125,13 +125,14 @@ async function writeDepsReadyMarker(targetDir, plan) {
|
|
|
125
125
|
await writeFile(markerPath, `${JSON.stringify(marker, null, 2)}\n`, 'utf8');
|
|
126
126
|
}
|
|
127
127
|
/** Build the `.forgecart/config.json` payload. */
|
|
128
|
-
function buildConfig(channelToken, options) {
|
|
128
|
+
function buildConfig(channelToken, options, designSystem) {
|
|
129
129
|
return {
|
|
130
130
|
version: '2.0',
|
|
131
131
|
channelToken,
|
|
132
132
|
apiUrl: options.apiUrl,
|
|
133
133
|
hasApplication: options.application ?? false,
|
|
134
134
|
storefrontPath: '.',
|
|
135
|
+
designSystem,
|
|
135
136
|
};
|
|
136
137
|
}
|
|
137
138
|
/**
|
|
@@ -225,16 +226,28 @@ async function readFileIfPresent(path) {
|
|
|
225
226
|
* client env). Shared by the full scaffold and the `--config-only` serve-in-place
|
|
226
227
|
* path, so both write byte-identical config — the only difference is whether the
|
|
227
228
|
* template tree was copied first. `config.json` is pure platform state and is
|
|
228
|
-
* rewritten wholesale
|
|
229
|
+
* rewritten wholesale, mirroring the design-system seat the workspace's template
|
|
230
|
+
* manifest records (#2773) — every provisioning drive re-runs init, and a
|
|
231
|
+
* rewrite without it would drop the mirror; `.env` is merge-preserved (#1123 —
|
|
232
|
+
* see mergeEnv).
|
|
229
233
|
*/
|
|
230
|
-
async function writeChannelConfig(targetDir, channelToken, options) {
|
|
234
|
+
async function writeChannelConfig(targetDir, channelToken, options, designSystem) {
|
|
231
235
|
const configDir = join(targetDir, '.forgecart');
|
|
232
236
|
await mkdir(configDir, { recursive: true });
|
|
233
|
-
await writeFile(join(configDir, 'config.json'), `${JSON.stringify(buildConfig(channelToken, options), null, 2)}\n`, 'utf8');
|
|
237
|
+
await writeFile(join(configDir, 'config.json'), `${JSON.stringify(buildConfig(channelToken, options, designSystem), null, 2)}\n`, 'utf8');
|
|
234
238
|
const envPath = join(targetDir, '.env');
|
|
235
239
|
const existingEnv = await readFileIfPresent(envPath);
|
|
236
240
|
await writeFile(envPath, mergeEnv(existingEnv, channelToken, options), 'utf8');
|
|
237
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* The design-system seat the workspace at `targetDir` already records (#2773),
|
|
244
|
+
* or undefined when it records none. The seat belongs to the workspace, not to
|
|
245
|
+
* an init run: both init paths carry it into the files they rewrite.
|
|
246
|
+
*/
|
|
247
|
+
async function recordedDesignSystem(targetDir) {
|
|
248
|
+
const manifest = await readTemplateManifest(targetDir);
|
|
249
|
+
return manifest?.designSystem;
|
|
250
|
+
}
|
|
238
251
|
/** Print the post-scaffold next steps. */
|
|
239
252
|
function printNextSteps(targetDir, application, depsInstalled) {
|
|
240
253
|
print('');
|
|
@@ -280,6 +293,7 @@ export async function runInit(name, options) {
|
|
|
280
293
|
throw new Error('A channel token is required. Pass it with --token <token> (or -t <token>).');
|
|
281
294
|
}
|
|
282
295
|
const targetDir = name ? resolve(process.cwd(), name) : process.cwd();
|
|
296
|
+
const designSystem = await recordedDesignSystem(targetDir);
|
|
283
297
|
// Serve-in-place: the target is already a warm storefront materialized from the
|
|
284
298
|
// image's pre-warmed tree (node_modules + a warm `.next`). Write only the
|
|
285
299
|
// per-channel config + env and return — copying the template would clobber the
|
|
@@ -288,7 +302,7 @@ export async function runInit(name, options) {
|
|
|
288
302
|
if (!(await isFile(join(targetDir, 'package.json')))) {
|
|
289
303
|
throw new Error(`--config-only requires an existing storefront at ${targetDir} (no package.json found).`);
|
|
290
304
|
}
|
|
291
|
-
await writeChannelConfig(targetDir, channelToken, options);
|
|
305
|
+
await writeChannelConfig(targetDir, channelToken, options, designSystem);
|
|
292
306
|
printConfigOnly(targetDir);
|
|
293
307
|
return;
|
|
294
308
|
}
|
|
@@ -304,11 +318,11 @@ export async function runInit(name, options) {
|
|
|
304
318
|
recursive: true,
|
|
305
319
|
});
|
|
306
320
|
}
|
|
307
|
-
await writeChannelConfig(targetDir, channelToken, options);
|
|
321
|
+
await writeChannelConfig(targetDir, channelToken, options, designSystem);
|
|
308
322
|
await writeDepsReadyMarker(targetDir, plan);
|
|
309
323
|
// Inventory the render for `forgecart refresh` (#1116) — hashed from the
|
|
310
324
|
// plan's template dir, the exact bytes the copy above landed.
|
|
311
|
-
await writeTemplateManifest(targetDir, plan.templateDir, readPackageVersion());
|
|
325
|
+
await writeTemplateManifest(targetDir, plan.templateDir, readPackageVersion(), designSystem);
|
|
312
326
|
printNextSteps(name ?? '.', options.application ?? false, plan.source === 'warmed');
|
|
313
327
|
}
|
|
314
328
|
/** Build the `init [name]` command, carrying the question adapter's three flags. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CA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AAyB,EACzB,8EAA8E,CAC/E;SACA,MAAM,CACL,iBAAiB,EACjB,yDAAyD,EACzD,oBAAoB,CACrB;SACA,MAAM,CACL,yBAAyB,EACzB,2IAA2I,CAC5I;SACA,MAAM,CACL,uBAAuB,EACvB,+KAA+K,CAChL;SACA,MAAM,CAAC,mBAAmB,EAAE,uDAAuD,CAAC;SACpF,MAAM,CACL,eAAe,EACf,+FAA+F,CAChG;SACA,MAAM,CAAC,KAAK,EAAE,IAAwB,EAAE,OAAoB,EAAE,EAAE;QAC/D,MAAM,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IACL,OAAO,qBAAqB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isJsonObject } from '../json.js';
|
|
1
2
|
/**
|
|
2
3
|
* The storefront's package manifest under `forgecart refresh --adopt` (#2666).
|
|
3
4
|
*
|
|
@@ -87,8 +88,4 @@ function parseJson(bytes, copy) {
|
|
|
87
88
|
function unmergeableMessage(copy) {
|
|
88
89
|
return `Cannot adopt ${PACKAGE_MANIFEST_RELPATH}: ${copy} is not a JSON object, so the packages the workspace declares cannot be merged into the template's.`;
|
|
89
90
|
}
|
|
90
|
-
/** A JSON object — neither null nor an array. */
|
|
91
|
-
function isJsonObject(value) {
|
|
92
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
93
|
-
}
|
|
94
91
|
//# sourceMappingURL=package-manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manifest.js","sourceRoot":"","sources":["../../../src/commands/package-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,uDAAuD;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC;AAEvD,6DAA6D;AAC7D,MAAM,iBAAiB,GAAG;IACxB,cAAc;IACd,iBAAiB;IACjB,kBA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|
+
import { type DesignSystemPartition } from './design-system-seat.js';
|
|
2
3
|
/**
|
|
3
4
|
* `forgecart refresh` (#1116) — re-render the platform-owned template files
|
|
4
5
|
* of an EXISTING workspace from the CLI's bundled template, under the
|
|
@@ -21,14 +22,17 @@ import { Command } from 'commander';
|
|
|
21
22
|
* so a refresh that stops on a file it cannot decide — an adopted
|
|
22
23
|
* `package.json` whose packages cannot be read — leaves the workspace as it
|
|
23
24
|
* found it. The refresh always (re)writes the manifest, so a pre-manifest
|
|
24
|
-
* workspace becomes precise after its first refresh
|
|
25
|
-
* (
|
|
25
|
+
* workspace becomes precise after its first refresh; the design-system seat
|
|
26
|
+
* the manifest records (#2773) is carried into the rewritten manifest as it
|
|
27
|
+
* stands, and the report names it beside the per-file verdicts — the seat
|
|
28
|
+
* lives in `.forgecart/`, so no verdict can. The JSON report (`--json`) is the
|
|
29
|
+
* machine seam the provisioning orchestrator parses.
|
|
26
30
|
*/
|
|
27
31
|
interface RefreshOptions {
|
|
28
32
|
json?: boolean;
|
|
29
33
|
adopt?: string[];
|
|
30
34
|
}
|
|
31
|
-
/** Per-file verdicts, in report shape. */
|
|
35
|
+
/** Per-file verdicts and the design system, in report shape. */
|
|
32
36
|
export interface RefreshReport {
|
|
33
37
|
rendered: string[];
|
|
34
38
|
conflicts: string[];
|
|
@@ -36,6 +40,8 @@ export interface RefreshReport {
|
|
|
36
40
|
upToDate: string[];
|
|
37
41
|
/** True when package.json was re-rendered — the driver must re-install. */
|
|
38
42
|
dependenciesChanged: boolean;
|
|
43
|
+
/** The design system the workspace records against the one the template renders (#2773). */
|
|
44
|
+
designSystem: DesignSystemPartition;
|
|
39
45
|
}
|
|
40
46
|
/** Run `forgecart refresh`. */
|
|
41
47
|
export declare function runRefresh(name: string | undefined, options: RefreshOptions): Promise<void>;
|
|
@@ -3,9 +3,10 @@ import { dirname, join, resolve } from 'node:path';
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { print } from '../output.js';
|
|
5
5
|
import { readPackageVersion } from '../version.js';
|
|
6
|
+
import { describeDesignSystem, designSystemPartition, sameDesignSystem, } from './design-system-seat.js';
|
|
6
7
|
import { getStorefrontTemplateDir } from './init.js';
|
|
7
8
|
import { PACKAGE_MANIFEST_RELPATH, adoptPackageManifest } from './package-manifest.js';
|
|
8
|
-
import {
|
|
9
|
+
import { TEMPLATE_MANIFEST_SCHEMA_VERSION, hashContent, listTemplateFiles, readTemplateManifest, serializeTemplateManifest, templateManifestPath, } from './template-manifest.js';
|
|
9
10
|
/** True if the path exists and is a regular file. */
|
|
10
11
|
async function isFile(path) {
|
|
11
12
|
try {
|
|
@@ -122,13 +123,15 @@ export async function runRefresh(name, options) {
|
|
|
122
123
|
if (!(await isFile(join(targetDir, PACKAGE_MANIFEST_RELPATH)))) {
|
|
123
124
|
throw new Error(`refresh requires an existing storefront at ${targetDir} (no package.json found).`);
|
|
124
125
|
}
|
|
125
|
-
const
|
|
126
|
+
const manifest = await readTemplateManifest(targetDir);
|
|
127
|
+
const decisions = await decideTemplateFiles(targetDir, getStorefrontTemplateDir(), manifest, new Set(options.adopt ?? []));
|
|
126
128
|
const report = {
|
|
127
129
|
rendered: [],
|
|
128
130
|
conflicts: [],
|
|
129
131
|
adopted: [],
|
|
130
132
|
upToDate: [],
|
|
131
133
|
dependenciesChanged: false,
|
|
134
|
+
designSystem: designSystemPartition(manifest?.designSystem),
|
|
132
135
|
};
|
|
133
136
|
const nextFiles = {};
|
|
134
137
|
for (const decision of decisions) {
|
|
@@ -140,9 +143,10 @@ export async function runRefresh(name, options) {
|
|
|
140
143
|
templateVersion: readPackageVersion(),
|
|
141
144
|
generatedAt: new Date().toISOString(),
|
|
142
145
|
files: nextFiles,
|
|
146
|
+
designSystem: manifest?.designSystem,
|
|
143
147
|
};
|
|
144
148
|
await mkdir(join(targetDir, '.forgecart'), { recursive: true });
|
|
145
|
-
await writeFile(
|
|
149
|
+
await writeFile(templateManifestPath(targetDir), serializeTemplateManifest(nextManifest), 'utf8');
|
|
146
150
|
if (options.json) {
|
|
147
151
|
print(JSON.stringify(report));
|
|
148
152
|
return;
|
|
@@ -163,6 +167,11 @@ function printSummary(report) {
|
|
|
163
167
|
if (report.dependenciesChanged) {
|
|
164
168
|
print('package.json changed — run your package manager install before the next dev boot.');
|
|
165
169
|
}
|
|
170
|
+
const { recorded, rendered } = report.designSystem;
|
|
171
|
+
if (recorded !== null && !sameDesignSystem(recorded, rendered)) {
|
|
172
|
+
print(`Design system: the workspace records ${describeDesignSystem(recorded)}; ` +
|
|
173
|
+
`the template renders ${describeDesignSystem(rendered)}.`);
|
|
174
|
+
}
|
|
166
175
|
}
|
|
167
176
|
/** Build the `refresh [name]` command. */
|
|
168
177
|
export function createRefreshCommand() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.js","sourceRoot":"","sources":["../../../src/commands/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"refresh.js","sourceRoot":"","sources":["../../../src/commands/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW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CAAC;YACvC,KAAK,CAAC,KAAK,OAAO,0BAA0B,OAAO,gCAAgC,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IACD,IAAI,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC/B,KAAK,CAAC,mFAAmF,CAAC,CAAC;IAC7F,CAAC;IACD,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC;IACnD,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC/D,KAAK,CACH,wCAAwC,oBAAoB,CAAC,QAAQ,CAAC,IAAI;YACxE,wBAAwB,oBAAoB,CAAC,QAAQ,CAAC,GAAG,CAC5D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC;SAC1B,WAAW,CACV,8IAA8I,CAC/I;SACA,QAAQ,CAAC,QAAQ,EAAE,2DAA2D,CAAC;SAC/E,MAAM,CACL,sBAAsB,EACtB,yEAAyE,CAC1E;SACA,MAAM,CAAC,QAAQ,EAAE,mEAAmE,CAAC;SACrF,MAAM,CAAC,KAAK,EAAE,IAAwB,EAAE,OAAuB,EAAE,EAAE;QAClE,MAAM,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DesignSystemSeat } from './design-system-seat.js';
|
|
1
2
|
/**
|
|
2
3
|
* The template manifest — the file-ownership partition's source of truth
|
|
3
4
|
* (#1116). Written by `forgecart init` when it renders the template, read by
|
|
@@ -14,6 +15,13 @@ export interface TemplateManifest {
|
|
|
14
15
|
generatedAt: string;
|
|
15
16
|
/** posix relpath → sha256 hex of the rendered content. */
|
|
16
17
|
files: Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* The workspace's recorded design system (#2773), absent until one is
|
|
20
|
+
* recorded. It belongs to the workspace, not to a render: `init` and
|
|
21
|
+
* `refresh` carry it into every manifest they write, and `.forgecart/` is
|
|
22
|
+
* never inventoried, so it stays outside the per-file partition.
|
|
23
|
+
*/
|
|
24
|
+
designSystem?: DesignSystemSeat;
|
|
17
25
|
}
|
|
18
26
|
export declare const TEMPLATE_MANIFEST_SCHEMA_VERSION = 1;
|
|
19
27
|
/** sha256 hex of file content — the manifest's and refresh's shared hash. */
|
|
@@ -24,15 +32,22 @@ export declare function hashContent(content: Buffer | string): string;
|
|
|
24
32
|
* nested paths inherit their root's verdict).
|
|
25
33
|
*/
|
|
26
34
|
export declare function listTemplateFiles(templateDir: string): Promise<string[]>;
|
|
35
|
+
/** The manifest's absolute path in the workspace at `targetDir`. */
|
|
36
|
+
export declare function templateManifestPath(targetDir: string): string;
|
|
37
|
+
/** The bytes every manifest writer lands: two-space JSON with a final newline. */
|
|
38
|
+
export declare function serializeTemplateManifest(manifest: TemplateManifest): string;
|
|
27
39
|
/**
|
|
28
40
|
* Inventory the just-rendered template into the workspace's manifest. Hashes
|
|
29
41
|
* the TEMPLATE side of the copy — the bytes that actually landed — so a
|
|
30
|
-
* later refresh can prove per-file pristineness.
|
|
42
|
+
* later refresh can prove per-file pristineness. `designSystem` is the seat
|
|
43
|
+
* the workspace already recorded, carried over; a fresh workspace has none.
|
|
31
44
|
*/
|
|
32
|
-
export declare function writeTemplateManifest(targetDir: string, templateDir: string, templateVersion: string): Promise<void>;
|
|
45
|
+
export declare function writeTemplateManifest(targetDir: string, templateDir: string, templateVersion: string, designSystem: DesignSystemSeat | undefined): Promise<void>;
|
|
33
46
|
/**
|
|
34
47
|
* Read a workspace's manifest. Absent OR unreadable → null: the workspace is
|
|
35
48
|
* treated as pre-manifest, where refresh refuses every divergent file until
|
|
36
|
-
* explicitly adopted — the safe direction for a corrupt inventory too.
|
|
49
|
+
* explicitly adopted — the safe direction for a corrupt inventory too. A
|
|
50
|
+
* design-system seat that is not well-formed reads as unset, by the same
|
|
51
|
+
* reasoning: the next recorded choice replaces it.
|
|
37
52
|
*/
|
|
38
53
|
export declare function readTemplateManifest(targetDir: string): Promise<TemplateManifest | null>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { readFile, readdir, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
+
import { parseDesignSystemSeat } from './design-system-seat.js';
|
|
4
5
|
/**
|
|
5
6
|
* The template manifest — the file-ownership partition's source of truth
|
|
6
7
|
* (#1116). Written by `forgecart init` when it renders the template, read by
|
|
@@ -70,12 +71,21 @@ async function walk(dir, relPrefix, ignored, out) {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
74
|
+
/** The manifest's absolute path in the workspace at `targetDir`. */
|
|
75
|
+
export function templateManifestPath(targetDir) {
|
|
76
|
+
return join(targetDir, ...TEMPLATE_MANIFEST_RELPATH.split('/'));
|
|
77
|
+
}
|
|
78
|
+
/** The bytes every manifest writer lands: two-space JSON with a final newline. */
|
|
79
|
+
export function serializeTemplateManifest(manifest) {
|
|
80
|
+
return `${JSON.stringify(manifest, null, 2)}\n`;
|
|
81
|
+
}
|
|
73
82
|
/**
|
|
74
83
|
* Inventory the just-rendered template into the workspace's manifest. Hashes
|
|
75
84
|
* the TEMPLATE side of the copy — the bytes that actually landed — so a
|
|
76
|
-
* later refresh can prove per-file pristineness.
|
|
85
|
+
* later refresh can prove per-file pristineness. `designSystem` is the seat
|
|
86
|
+
* the workspace already recorded, carried over; a fresh workspace has none.
|
|
77
87
|
*/
|
|
78
|
-
export async function writeTemplateManifest(targetDir, templateDir, templateVersion) {
|
|
88
|
+
export async function writeTemplateManifest(targetDir, templateDir, templateVersion, designSystem) {
|
|
79
89
|
const files = {};
|
|
80
90
|
for (const relpath of await listTemplateFiles(templateDir)) {
|
|
81
91
|
files[relpath] = hashContent(await readFile(join(templateDir, ...relpath.split('/'))));
|
|
@@ -85,18 +95,21 @@ export async function writeTemplateManifest(targetDir, templateDir, templateVers
|
|
|
85
95
|
templateVersion,
|
|
86
96
|
generatedAt: new Date().toISOString(),
|
|
87
97
|
files,
|
|
98
|
+
designSystem,
|
|
88
99
|
};
|
|
89
|
-
await writeFile(
|
|
100
|
+
await writeFile(templateManifestPath(targetDir), serializeTemplateManifest(manifest), 'utf8');
|
|
90
101
|
}
|
|
91
102
|
/**
|
|
92
103
|
* Read a workspace's manifest. Absent OR unreadable → null: the workspace is
|
|
93
104
|
* treated as pre-manifest, where refresh refuses every divergent file until
|
|
94
|
-
* explicitly adopted — the safe direction for a corrupt inventory too.
|
|
105
|
+
* explicitly adopted — the safe direction for a corrupt inventory too. A
|
|
106
|
+
* design-system seat that is not well-formed reads as unset, by the same
|
|
107
|
+
* reasoning: the next recorded choice replaces it.
|
|
95
108
|
*/
|
|
96
109
|
export async function readTemplateManifest(targetDir) {
|
|
97
110
|
let raw;
|
|
98
111
|
try {
|
|
99
|
-
raw = await readFile(
|
|
112
|
+
raw = await readFile(templateManifestPath(targetDir), 'utf8');
|
|
100
113
|
}
|
|
101
114
|
catch (error) {
|
|
102
115
|
if (error.code === 'ENOENT')
|
|
@@ -107,7 +120,7 @@ export async function readTemplateManifest(targetDir) {
|
|
|
107
120
|
const parsed = JSON.parse(raw);
|
|
108
121
|
if (parsed.schemaVersion !== TEMPLATE_MANIFEST_SCHEMA_VERSION)
|
|
109
122
|
return null;
|
|
110
|
-
return parsed;
|
|
123
|
+
return { ...parsed, designSystem: parseDesignSystemSeat(parsed.designSystem) ?? undefined };
|
|
111
124
|
}
|
|
112
125
|
catch {
|
|
113
126
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-manifest.js","sourceRoot":"","sources":["../../../src/commands/template-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,Q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,CAAC,CAAC;AAChG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,SAAiB;IAC1D,IAAI,GAAW,CAAC;IAChB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,QAAQ,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QACpE,MAAM,KAAK,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;QACnD,IAAI,MAAM,CAAC,aAAa,KAAK,gCAAgC;YAAE,OAAO,IAAI,CAAC;QAC3E,OAAO,EAAE,GAAG,MAAM,EAAE,YAAY,EAAE,qBAAqB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,SAAS,EAAE,CAAC;IAC9F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON shape guards shared by the commands that read the workspace's JSON files
|
|
3
|
+
* (`package.json`, `.forgecart/config.json`, the template manifest).
|
|
4
|
+
*/
|
|
5
|
+
/** A JSON object — neither null nor an array. */
|
|
6
|
+
export declare function isJsonObject(value: unknown): value is Record<string, unknown>;
|
package/dist/src/json.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON shape guards shared by the commands that read the workspace's JSON files
|
|
3
|
+
* (`package.json`, `.forgecart/config.json`, the template manifest).
|
|
4
|
+
*/
|
|
5
|
+
/** A JSON object — neither null nor an array. */
|
|
6
|
+
export function isJsonObject(value) {
|
|
7
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/json.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iDAAiD;AACjD,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|