@nodii/dev 0.6.84 → 0.6.85

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.84";
7
+ export const VERSION = "0.6.85";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
@@ -250,7 +250,7 @@ export function assertKnownSets(surfaces, scopes) {
250
250
  export function laneFigmaScope(lane) {
251
251
  const stored = lane?.freeze?.boundaries?.figma;
252
252
  if (Array.isArray(stored))
253
- return stored.map((file) => ({ fileKey: file.fileKey, componentSets: file.componentSetKeys ?? [] }));
253
+ return stored.map((file) => ({ fileKey: file.fileKey, componentSets: file.componentSetKeys ?? [], ...(file.creates?.length ? { creates: file.creates } : {}) }));
254
254
  const launch = lane?.launch?.figmaScopes;
255
255
  if (!Array.isArray(launch) || !launch.length) return null;
256
256
  try {
@@ -286,7 +286,14 @@ export function guidelineLookup(components) {
286
286
  };
287
287
  }
288
288
 
289
- export const SWAP_BOUNDARIES = (key = "<key>") => `\`nodii-dev lane freeze swap ${key} --section boundaries --file BOUNDARIES.json --reason TEXT\` (the whole section: repos plus figma: [{fileKey, componentSetKeys}]; start from \`nodii-dev lane freeze show ${key}\`)`;
289
+ export const SWAP_BOUNDARIES = (key = "<key>") => `\`nodii-dev lane freeze swap ${key} --section boundaries --file BOUNDARIES.json --reason TEXT\` (the whole section: repos plus figma: [{fileKey, componentSetKeys, creates: [{pageId, name}]}]; start from \`nodii-dev lane freeze show ${key}\`)`;
290
+
291
+ /** A create's name as Dev compares it (sameCreateName in the hub's scopes.ts). */
292
+ export const createName = (name) =>
293
+ String(name)
294
+ .normalize("NFKC")
295
+ .toLowerCase()
296
+ .replace(/[^\p{L}\p{N}]+/gu, "");
290
297
 
291
298
  const outside = (message, details) => new CliError("FIGMA_OUTSIDE_LANE_SCOPE", `${message} Change the scope only with ${SWAP_BOUNDARIES()}, or ask the coordinator to amend the lane.`, 2, details);
292
299
 
@@ -357,10 +364,19 @@ export async function assertWithinLaneScope(scope, fileKey, lockScopes, { catalo
357
364
  const file = scope.find((item) => item.fileKey === fileKey);
358
365
  if (!file)
359
366
  throw outside(`${fileKey} is outside this lane's Figma scope (${scope.length ? scope.map((item) => item.fileKey).join(", ") : "no Figma files"}).`, { fileKey, scope });
360
- if (lockScopes === null || !file.componentSets.length) return { checked: true, fileKey };
361
- const wide = lockScopes.length ? lockScopes.filter((item) => item.kind !== "component") : [{ kind: "file" }];
367
+ const creates = file.creates ?? [];
368
+ if (lockScopes === null || (!file.componentSets.length && !creates.length)) return { checked: true, fileKey };
369
+ // DS-254: a create the Freeze grants, on its page and under its name.
370
+ // A name with no letters or digits names nothing, so it matches nothing.
371
+ const granted = (item) => Boolean(item.pageId && createName(item.name ?? "")) && creates.some((create) => create.pageId === item.pageId && createName(create.name ?? "") === createName(item.name));
372
+ const ungranted = lockScopes.filter((item) => item.kind === "create" && !granted(item));
373
+ if (ungranted.length)
374
+ throw outside(`${ungranted.map((item) => `create "${item.name}" on page ${item.pageId}`).join(", ")} in ${fileKey} is not a create this lane's Freeze grants (${creates.length ? creates.map((create) => `"${create.name}" on page ${create.pageId}`).join(", ") : "none"}).`, { fileKey, scope: file });
375
+ const wide = lockScopes.length ? lockScopes.filter((item) => item.kind !== "component" && item.kind !== "create") : [{ kind: "file" }];
362
376
  if (wide.length)
363
- throw outside(`This lane may lock only its component sets in ${fileKey}, not ${wide.map((item) => item.kind).join(", ")}.`, { fileKey, scope: file });
377
+ throw outside(`This lane may lock only its component sets${creates.length ? " and granted creates" : ""} in ${fileKey}, not ${wide.map((item) => item.kind).join(", ")}.`, { fileKey, scope: file });
378
+ lockScopes = lockScopes.filter((item) => item.kind === "component");
379
+ if (!lockScopes.length) return { checked: true, fileKey };
364
380
  // Surfaces first; a DS set's key is looked up only when a node is still unaccounted for.
365
381
  const allowedBy = (sets) => new Set([...sets.values()].flatMap((set) => set.nodeIds));
366
382
  const sets = await componentSetsIn(fileKey, file.componentSets, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.84",
3
+ "version": "0.6.85",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {