@nodii/dev 0.6.201 → 0.6.202
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/cli.js +2 -1
- package/dist/core.js +1 -1
- package/dist/surface.js +19 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1315,6 +1315,13 @@ product-page catalog names the Surface by its published component-set key
|
|
|
1315
1315
|
That map is keyed by variant node id, so `--fetch` joins it while it reads
|
|
1316
1316
|
and the tree keeps only each variant's state name; no node id is committed
|
|
1317
1317
|
(MW8-20). A tree that still holds one is refused with `SURFACE_TREE_STALE`.
|
|
1318
|
+
Each page it writes carries the version stamp `// Generator: @nodii/dev X`
|
|
1319
|
+
(the running CLI's version) on line 4, after the `// Surface:` line, exactly
|
|
1320
|
+
as design-system's `surface-gen.mjs stamp --version X` writes it, so no
|
|
1321
|
+
separate stamp step is needed (NODII-DEV-CLI-276). A page already stamped is
|
|
1322
|
+
rewritten with one stamp, the running version's. Only the written file is
|
|
1323
|
+
stamped: print mode, the corpus gate and a stamped version's replay see the
|
|
1324
|
+
generator's output, and `--check` ignores the stamp line.
|
|
1318
1325
|
- **Loading flows down (NODII-DEV-CLI-260, MW6-29).** Every Surface takes an
|
|
1319
1326
|
optional `loading?: boolean`, and every view passes it to each DS part that
|
|
1320
1327
|
draws its own skeleton, whether or not its template draws the prop: `status`
|
package/dist/cli.js
CHANGED
|
@@ -217,7 +217,8 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
217
217
|
# a Surface -> its product page's presentational code, from Code Connect
|
|
218
218
|
# (MW8-17), in a design-system checkout. --fetch reads Figma (FIGMA_PAT, one
|
|
219
219
|
# call per 8 s); --write writes <page>.surface.generated.tsx (and, with --fetch,
|
|
220
|
-
# the committed tree)
|
|
220
|
+
# the committed tree), stamped "// Generator: @nodii/dev X" on line 4;
|
|
221
|
+
# --check refuses a difference (the surface-gen-equal gate; the stamp is none);
|
|
221
222
|
# --report writes the unmapped layers per file (U08-14), .md or .json;
|
|
222
223
|
# --all --fetch skips and reports a Surface that is not published;
|
|
223
224
|
# --post-scoreboard comments the per-module scoreboard on the issue;
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/pr
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { basename, dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.202";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/surface.js
CHANGED
|
@@ -48,6 +48,22 @@ export const GENERATED_PAGE_GLOB = `packages/blocks/src/product-pages/**/*${GENE
|
|
|
48
48
|
const PAGE_STAMP = /^\/\/ GENERATED by `nodii-dev surface generate` [^\n]*\n\/\/ regenerate with [^\n]*\n\/\/ Surface: [^\n]+ · Figma file \S+ @ version \S+ · format \d+\n/;
|
|
49
49
|
/** True when a product page's text opens with the stamp `surface generate` writes (the header below). */
|
|
50
50
|
export const hasGeneratedPageStamp = (text) => PAGE_STAMP.test(text);
|
|
51
|
+
/**
|
|
52
|
+
* The version stamp `--write` puts on every page it writes (NODII-DEV-CLI-276), byte-for-byte
|
|
53
|
+
* design-system's `infra/code-connect/surface-gen.mjs` (its STAMP_RE, stripStamp, applyStamp):
|
|
54
|
+
* the line after `// Surface:`, naming the running @nodii/dev. Only the written file carries it;
|
|
55
|
+
* the generator's output (print mode, the corpus gate, a stamped version's replay) never does.
|
|
56
|
+
*/
|
|
57
|
+
const GENERATOR_STAMP = /^\/\/ Generator: @nodii\/dev (\d+\.\d+\.\d+)\r?\n/m;
|
|
58
|
+
/** The page without its stamp line: what the generator emitted. */
|
|
59
|
+
export const stripGeneratorStamp = (text) => text.replace(GENERATOR_STAMP, "");
|
|
60
|
+
/** The page stamped with `version`, replacing any stamp it had, so a page carries one. */
|
|
61
|
+
export function applyGeneratorStamp(text, version = VERSION) {
|
|
62
|
+
const lines = stripGeneratorStamp(text).split("\n");
|
|
63
|
+
const at = lines.findIndex((line) => line.startsWith("// Surface:"));
|
|
64
|
+
lines.splice(at === -1 ? 1 : at + 1, 0, `// Generator: @nodii/dev ${version}`);
|
|
65
|
+
return lines.join("\n");
|
|
66
|
+
}
|
|
51
67
|
const CATALOG_PATH = "packages/blocks/src/product-pages/catalog.ts";
|
|
52
68
|
const DS_FILE_META = "infra/figma/figma-file.json";
|
|
53
69
|
const ONE_TO_ONE_SNAPSHOT = "docs/figma-ux-ds/figma/1to1/figma-file.snapshot.json";
|
|
@@ -4404,7 +4420,7 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
|
|
|
4404
4420
|
r.file = relative(root, out);
|
|
4405
4421
|
r.wrapperFile = null;
|
|
4406
4422
|
if (f.write) {
|
|
4407
|
-
writeFileSync(out, r.code);
|
|
4423
|
+
writeFileSync(out, applyGeneratorStamp(r.code));
|
|
4408
4424
|
// The route's wrapper, only where no page is yet (wrapperCode).
|
|
4409
4425
|
const page = r.wrapper ? join(root, r.row.sourcePath) : null;
|
|
4410
4426
|
if (page && !existsSync(page)) {
|
|
@@ -4413,7 +4429,8 @@ export async function surfaceCommand(action, rest, f, deps = {}) {
|
|
|
4413
4429
|
}
|
|
4414
4430
|
} else if (f.check) {
|
|
4415
4431
|
const current = existsSync(out) ? readFileSync(out, "utf8") : null;
|
|
4416
|
-
|
|
4432
|
+
// The stamp names the version that wrote the page; it is no difference in the generator's output.
|
|
4433
|
+
if (current === null || stripGeneratorStamp(current) !== r.code) differences.push({ id: r.row.id, file: r.file, reason: current === null ? "missing" : "differs" });
|
|
4417
4434
|
}
|
|
4418
4435
|
}
|
|
4419
4436
|
|