@nodii/dev 0.6.81 → 0.6.82
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 +13 -0
- package/dist/core.js +1 -1
- package/dist/figma-scope.js +28 -41
- package/dist/review.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -271,6 +271,19 @@ Sibling sections don't conflict. Dev
|
|
|
271
271
|
refuses an overlap with `SCOPE_CONFLICT`; the CLI prints Dev's message, then
|
|
272
272
|
the set holding the overlapping scope. `figma lock` without `--scope` locks the
|
|
273
273
|
whole file, as older CLIs do, and that conflicts with every other set.
|
|
274
|
+
|
|
275
|
+
**A DS component set in the Freeze (NODII-DEV-CLI-70).** A lane may lock only
|
|
276
|
+
the component sets its Freeze names. A Surface's nodes come from the DS
|
|
277
|
+
catalog (`registry.json`). A DS component set (Empty State, Pagination) is not
|
|
278
|
+
a Surface, so its node comes from the design catalogue
|
|
279
|
+
(`design-catalog.json`): the entry whose `figma.componentSetKey` (or
|
|
280
|
+
`figma.componentKey`) is the key names its `figma.fileKey` and
|
|
281
|
+
`figma.nodeId`. `lane check`'s Figma boundary resolves it the same way. The
|
|
282
|
+
CLI never reads Figma REST for this. A key in neither catalogue is refused with
|
|
283
|
+
`FIGMA_KEY_UNKNOWN`; the fix is to publish the key on its design catalogue
|
|
284
|
+
entry in the design-system repository (the Figma MCP's
|
|
285
|
+
`search_design_system` returns it as `componentSetKey`).
|
|
286
|
+
|
|
274
287
|
`figma scope add` widens a set you hold, with the same check; nothing is ever
|
|
275
288
|
widened silently. `figma scope set` narrows a set you hold to exactly the
|
|
276
289
|
scopes you give, and releases the rest for other sets: for example, a set
|
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.
|
|
7
|
+
export const VERSION = "0.6.82";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/figma-scope.js
CHANGED
|
@@ -290,50 +290,37 @@ export const SWAP_BOUNDARIES = (key = "<key>") => `\`nodii-dev lane freeze swap
|
|
|
290
290
|
|
|
291
291
|
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
292
|
|
|
293
|
-
const setLookups = new Map();
|
|
294
|
-
export const clearComponentSetLookups = () => setLookups.clear();
|
|
295
|
-
|
|
296
293
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
294
|
+
* How a key the DS catalog does not list as a Surface (a DS component set,
|
|
295
|
+
* NODII-DEV-CLI-70) resolves: the design catalogue entry that publishes it
|
|
296
|
+
* (figma.componentSetKey or figma.componentKey) names its file and node. Both
|
|
297
|
+
* come from the DS repository's build, not from a lane-given flag, and the CLI
|
|
298
|
+
* never reads Figma REST for them (operator ruling of 3 Nov: Figma through the
|
|
299
|
+
* MCP). NODII_DEV_DS_DESIGN_CATALOG_URL can point the read elsewhere, as
|
|
300
|
+
* NODII_DEV_DS_REGISTRY_URL can for the registry. A catalogue with no entries
|
|
301
|
+
* list is refused, never read as empty. One read of the catalogue per lookup.
|
|
302
302
|
*/
|
|
303
|
-
export function
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
if (!
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
try {
|
|
315
|
-
const meta = (await get(`/component_sets/${encodeURIComponent(key)}`))?.meta;
|
|
316
|
-
return meta?.node_id && meta?.file_key ? { key, fileKey: meta.file_key, nodeId: meta.node_id, name: meta.name ?? null } : null;
|
|
317
|
-
} catch (error) {
|
|
318
|
-
if (error?.code === "FIGMA_NOT_FOUND") return null;
|
|
319
|
-
throw error;
|
|
320
|
-
}
|
|
321
|
-
})();
|
|
322
|
-
// A failed read is not remembered; the next caller asks again.
|
|
323
|
-
lookup.catch(() => setLookups.delete(key));
|
|
324
|
-
setLookups.set(key, lookup);
|
|
325
|
-
}
|
|
326
|
-
return setLookups.get(key);
|
|
303
|
+
export function designCatalogSets({ fetchImpl = fetch, url = process.env.NODII_DEV_DS_DESIGN_CATALOG_URL || DS_DESIGN_CATALOG_URL } = {}) {
|
|
304
|
+
let entries;
|
|
305
|
+
return async (key) => {
|
|
306
|
+
entries ??= fetchDsJson(url, { fetchImpl }).then((catalog) => {
|
|
307
|
+
if (!Array.isArray(catalog?.entries)) throw new CliError("DS_CATALOG_INVALID", "The design catalogue has no entries list.", 1);
|
|
308
|
+
return catalog.entries;
|
|
309
|
+
});
|
|
310
|
+
const entry = (await entries).find((item) => [item?.figma?.componentSetKey, item?.figma?.componentKey].includes(key));
|
|
311
|
+
if (!entry?.figma?.fileKey || !entry.figma.nodeId) return null;
|
|
312
|
+
return { key, fileKey: entry.figma.fileKey, nodeId: entry.figma.nodeId, name: entry.title ?? entry.key ?? null };
|
|
313
|
+
};
|
|
327
314
|
}
|
|
328
315
|
|
|
329
316
|
/**
|
|
330
317
|
* What each published set key in a file names (MW8-20): a Surface's nodes and
|
|
331
|
-
* state frames from the DS catalog; else, through `lookupSet`, the
|
|
332
|
-
*
|
|
333
|
-
* node as the one frame. `onlyIfNeeded(resolvedSoFar)` returning false skips
|
|
334
|
-
*
|
|
318
|
+
* state frames from the DS catalog; else, through `lookupSet`, the design
|
|
319
|
+
* catalogue entry that publishes the key (a DS component set,
|
|
320
|
+
* NODII-DEV-CLI-70), its own node as the one frame. `onlyIfNeeded(resolvedSoFar)` returning false skips
|
|
321
|
+
* those lookups. A key that names nothing in this file is refused.
|
|
335
322
|
*/
|
|
336
|
-
export async function componentSetsIn(fileKey, keys, { surfaces = [], lookupSet =
|
|
323
|
+
export async function componentSetsIn(fileKey, keys, { surfaces = [], lookupSet = designCatalogSets(), onlyIfNeeded } = {}) {
|
|
337
324
|
const sets = new Map();
|
|
338
325
|
for (const key of keys) {
|
|
339
326
|
const surface = surfaces.find((item) => item.componentSetKey === key && item.fileKey === fileKey);
|
|
@@ -344,10 +331,10 @@ export async function componentSetsIn(fileKey, keys, { surfaces = [], lookupSet
|
|
|
344
331
|
for (const key of rest) {
|
|
345
332
|
const set = await lookupSet(key);
|
|
346
333
|
if (!set)
|
|
347
|
-
throw new CliError("FIGMA_KEY_UNKNOWN", `${key} is neither a Surface in the DS catalog nor a component set Figma
|
|
334
|
+
throw new CliError("FIGMA_KEY_UNKNOWN", `${key} is neither a Surface in the DS catalog nor the published key of a design catalogue entry. A DS component set is resolved only through the design catalogue (figma.componentSetKey beside figma.nodeId), so publish its key there, in the design-system repository: the Figma MCP's search_design_system returns it as componentSetKey.`, 1, { fileKey, key });
|
|
348
335
|
if (set.fileKey !== fileKey)
|
|
349
336
|
throw new CliError("FIGMA_KEY_UNKNOWN", `${key}${set.name ? ` (${set.name})` : ""} is in file ${set.fileKey}, not ${fileKey}.`, 1, { fileKey, key, setFileKey: set.fileKey });
|
|
350
|
-
sets.set(key, { key, fileKey, name: set.name, nodeIds: [set.nodeId], frames: [{ nodeId: set.nodeId, state: "default" }] });
|
|
337
|
+
sets.set(key, { key, fileKey, name: set.name ?? null, nodeIds: [set.nodeId], frames: [{ nodeId: set.nodeId, state: "default" }] });
|
|
351
338
|
}
|
|
352
339
|
return sets;
|
|
353
340
|
}
|
|
@@ -357,7 +344,7 @@ export async function componentSetsIn(fileKey, keys, { surfaces = [], lookupSet
|
|
|
357
344
|
* write (lockScopes = null) outside the lane's scope. `scope` null = the lane
|
|
358
345
|
* declared none, so nothing is bounded here.
|
|
359
346
|
*/
|
|
360
|
-
export async function assertWithinLaneScope(scope, fileKey, lockScopes, { catalog = loadDsCatalog, lookupSet =
|
|
347
|
+
export async function assertWithinLaneScope(scope, fileKey, lockScopes, { catalog = loadDsCatalog, lookupSet = designCatalogSets() } = {}) {
|
|
361
348
|
if (scope === null) return { checked: false };
|
|
362
349
|
const file = scope.find((item) => item.fileKey === fileKey);
|
|
363
350
|
if (!file)
|
|
@@ -366,7 +353,7 @@ export async function assertWithinLaneScope(scope, fileKey, lockScopes, { catalo
|
|
|
366
353
|
const wide = lockScopes.length ? lockScopes.filter((item) => item.kind !== "component") : [{ kind: "file" }];
|
|
367
354
|
if (wide.length)
|
|
368
355
|
throw outside(`This lane may lock only its component sets in ${fileKey}, not ${wide.map((item) => item.kind).join(", ")}.`, { fileKey, scope: file });
|
|
369
|
-
// Surfaces first;
|
|
356
|
+
// Surfaces first; a DS set's key is looked up only when a node is still unaccounted for.
|
|
370
357
|
const allowedBy = (sets) => new Set([...sets.values()].flatMap((set) => set.nodeIds));
|
|
371
358
|
const sets = await componentSetsIn(fileKey, file.componentSets, {
|
|
372
359
|
surfaces: await catalog(),
|
package/dist/review.js
CHANGED
|
@@ -10,7 +10,7 @@ import { dirname, join } from "node:path";
|
|
|
10
10
|
import { promisify } from "node:util";
|
|
11
11
|
import { CliError, encode } from "./core.js";
|
|
12
12
|
import { pickerPrompt } from "./gather.js";
|
|
13
|
-
import { componentSetsIn,
|
|
13
|
+
import { componentSetsIn, designCatalogSets } from "./figma-scope.js";
|
|
14
14
|
import { gitPrivatePath } from "./safety.js";
|
|
15
15
|
|
|
16
16
|
const execFileAsync = promisify(execFile);
|
|
@@ -414,10 +414,10 @@ export const frameUrl = (fileKey, nodeId) => `https://www.figma.com/design/${fil
|
|
|
414
414
|
/**
|
|
415
415
|
* The frames in the Freeze's Figma boundary: each component set's state
|
|
416
416
|
* nodes from the DS catalog (its main node as "default" when it has none),
|
|
417
|
-
* or, for a DS component set, its own node as
|
|
418
|
-
* key (NODII-DEV-CLI-70); a whole-file boundary is the whole file.
|
|
417
|
+
* or, for a DS component set, its own node as the design catalogue
|
|
418
|
+
* publishes it under the key (NODII-DEV-CLI-70); a whole-file boundary is the whole file.
|
|
419
419
|
*/
|
|
420
|
-
export async function boundaryFrames(figma, { catalog, lookupSet =
|
|
420
|
+
export async function boundaryFrames(figma, { catalog, lookupSet = designCatalogSets() } = {}) {
|
|
421
421
|
const surfaces = figma.some((file) => file.componentSetKeys?.length) ? await catalog() : [];
|
|
422
422
|
const frames = [];
|
|
423
423
|
for (const file of figma) {
|