@nodii/dev 0.6.120 → 0.6.121

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/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
4
  import { homedir, platform } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.120";
7
+ export const VERSION = "0.6.121";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/review.js CHANGED
@@ -13,6 +13,7 @@ import { CliError, encode } from "./core.js";
13
13
  import { pickerPrompt } from "./gather.js";
14
14
  import { componentSetsIn, designCatalogSets } from "./figma-scope.js";
15
15
  import { gitPrivatePath } from "./safety.js";
16
+ import { GENERATED_PAGE_GLOB, GENERATED_SUFFIX, hasGeneratedPageStamp } from "./surface.js";
16
17
 
17
18
  const execFileAsync = promisify(execFile);
18
19
  export const CHECKS = ["rules", "figma", "code"];
@@ -128,8 +129,17 @@ export async function repoGeneratedPaths(request, repo) {
128
129
  */
129
130
  export const GENERATED_DATA_PATHS = ["docs/figma-ux-ds/figma/surface-trees/"];
130
131
 
131
- /** One exclude pathspec per prefix, never per file, so a big regeneration cannot hit E2BIG. */
132
- export const generatedPathspecs = (prefixes) => prefixes.map((prefix) => `:(exclude,glob)${prefix}**`);
132
+ /**
133
+ * NODII-DEV-CLI-77: a generated product page is the generator's output from
134
+ * its Surface tree, and the surface-gen-equal gate refuses one that differs.
135
+ * It is left out only while it carries the generator's stamp; a page without
136
+ * the stamp is reviewed like any hand-written file.
137
+ */
138
+ export const GENERATED_PAGE_PATHS = [GENERATED_PAGE_GLOB];
139
+ const isGeneratedPagePath = (path) => path.startsWith(GENERATED_PAGE_GLOB.slice(0, GENERATED_PAGE_GLOB.indexOf("*"))) && path.endsWith(GENERATED_SUFFIX);
140
+
141
+ /** One exclude pathspec per prefix or glob, never per file, so a big regeneration cannot hit E2BIG. A prefix covers everything under it. */
142
+ export const generatedPathspecs = (prefixes) => prefixes.map((prefix) => `:(exclude,glob)${prefix.includes("*") ? prefix : `${prefix}**`}`);
133
143
 
134
144
  /**
135
145
  * DEV-REV-6: the worktree against its origin/main merge base, tracked and
@@ -144,12 +154,20 @@ export async function laneDiff(cwd, { exec = execFileAsync, generatedPaths = []
144
154
  const mergeBase = (await git("merge-base", "origin/main", "HEAD")).trim();
145
155
  const changedNames = async (...specs) => (await git("diff", "--name-only", mergeBase, ...(specs.length ? ["--", ".", ...specs] : []))).split("\n").map((x) => x.trim()).filter(Boolean);
146
156
  const untrackedNames = async (...specs) => (await git("ls-files", "--others", "--exclude-standard", "-z", ...(specs.length ? ["--", ".", ...specs] : []))).split("\0").filter(Boolean);
147
- const specs = generatedPathspecs([...GENERATED_DATA_PATHS, ...generatedPaths]);
157
+ const specs = generatedPathspecs([...GENERATED_DATA_PATHS, ...GENERATED_PAGE_PATHS, ...generatedPaths]);
148
158
  const tracked = await git("diff", "--no-color", "--no-ext-diff", mergeBase);
149
159
  const names = await changedNames();
150
160
  const untracked = await untrackedNames();
151
161
  const kept = new Set(specs.length ? [...await changedNames(...specs), ...await untrackedNames(...specs)] : [...names, ...untracked]);
152
162
  const paths = [...new Set([...names, ...untracked])];
163
+ // A page left out by the glob alone, without the generator's stamp, goes back to the reviewer.
164
+ // A deleted page has no text to stamp; its removal is not hand-written code.
165
+ const unstamped = [];
166
+ for (const path of paths) {
167
+ if (kept.has(path) || !isGeneratedPagePath(path) || generatedPaths.some((prefix) => !prefix.includes("*") && path.startsWith(prefix))) continue;
168
+ const text = await readFile(join(cwd, path), "utf8").catch((error) => { if (error.code === "ENOENT") return null; throw error; });
169
+ if (text !== null && !hasGeneratedPageStamp(text)) { kept.add(path); unstamped.push(path); }
170
+ }
153
171
  const generated = paths.filter((path) => !kept.has(path));
154
172
  const added = [];
155
173
  const reviewAdded = [];
@@ -161,7 +179,12 @@ export async function laneDiff(cwd, { exec = execFileAsync, generatedPaths = []
161
179
  added.push(chunk);
162
180
  if (kept.has(path)) reviewAdded.push(chunk);
163
181
  }
164
- const reviewTracked = names.some((path) => !kept.has(path)) ? await git("diff", "--no-color", "--no-ext-diff", mergeBase, "--", ".", ...specs) : tracked;
182
+ const unstampedTracked = unstamped.filter((path) => names.includes(path));
183
+ // Every tracked path kept (unstamped pages included): the whole diff is the review text.
184
+ const reviewTracked = names.some((path) => !kept.has(path))
185
+ ? await git("diff", "--no-color", "--no-ext-diff", mergeBase, "--", ".", ...specs) +
186
+ (unstampedTracked.length ? await git("diff", "--no-color", "--no-ext-diff", mergeBase, "--", ...unstampedTracked.map((path) => `:(literal)${path}`)) : "")
187
+ : tracked;
165
188
  return { mergeBase, text: tracked + added.join(""), reviewText: reviewTracked + reviewAdded.join(""), paths, generated };
166
189
  }
167
190
 
package/dist/surface.js CHANGED
@@ -35,6 +35,11 @@ import { createRenderer } from "./vendor/render-templates.mjs";
35
35
  export const GENERATOR_FORMAT = 7;
36
36
  export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
37
37
  export const GENERATED_SUFFIX = ".surface.generated.tsx";
38
+ /** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
39
+ export const GENERATED_PAGE_GLOB = `packages/blocks/src/product-pages/**/*${GENERATED_SUFFIX}`;
40
+ 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/;
41
+ /** True when a product page's text opens with the stamp `surface generate` writes (the header below). */
42
+ export const hasGeneratedPageStamp = (text) => PAGE_STAMP.test(text);
38
43
  const CATALOG_PATH = "packages/blocks/src/product-pages/catalog.ts";
39
44
  const DS_FILE_META = "infra/figma/figma-file.json";
40
45
  const ONE_TO_ONE_SNAPSHOT = "docs/figma-ux-ds/figma/1to1/figma-file.snapshot.json";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.120",
3
+ "version": "0.6.121",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {