@nodii/dev 0.6.117 → 0.6.118
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/cli.js +21 -5
- package/dist/core.js +1 -1
- package/dist/figma.js +51 -10
- package/dist/flags.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -60,6 +60,8 @@ import {
|
|
|
60
60
|
readLaneReads,
|
|
61
61
|
figmaWithdrawItemsText,
|
|
62
62
|
WITHDRAW_ITEMS_USAGE,
|
|
63
|
+
removedNodesFrom,
|
|
64
|
+
removedNodesInReads,
|
|
63
65
|
withdrawItemsFrom,
|
|
64
66
|
checkSubmitPayload,
|
|
65
67
|
assertContext,
|
|
@@ -70,7 +72,7 @@ import {
|
|
|
70
72
|
scopesFrom,
|
|
71
73
|
conformanceLines,
|
|
72
74
|
} from "./figma.js";
|
|
73
|
-
export { figmaLock, figmaWithdrawItems, figmaWithdrawItemsText, submitMode, withdrawItemsFrom } from "./figma.js";
|
|
75
|
+
export { figmaLock, figmaWithdrawItems, figmaWithdrawItemsText, removedNodesFrom, removedNodesInReads, submitMode, withdrawItemsFrom } from "./figma.js";
|
|
74
76
|
import { tuneCommand } from "./tune.js";
|
|
75
77
|
import { TUNING_MODELS, pickerModelName, pickerPin, measurePickerLatency, pickTimingStats, pickTimingText, pickTimingsPath, readPickTimings } from "./gather.js";
|
|
76
78
|
import { docsCommand, rulebookCommand, rulesCommand } from "./upload.js";
|
|
@@ -231,12 +233,15 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
231
233
|
# lane's agent, even from a stopped lane. The target can hold no other lock on
|
|
232
234
|
# the file (TARGET_HOLDS_FILE_LOCK)
|
|
233
235
|
figma withdraw CHANGE_SET # holder takes back a submit: in_review -> editing (or a re-submit -> applying)
|
|
234
|
-
figma withdraw CHANGE_SET --items ID[,ID] --reason TEXT [--lane-reads FILE]
|
|
236
|
+
figma withdraw CHANGE_SET --items ID[,ID] --reason TEXT [--lane-reads FILE [--removed-nodes NODE[,NODE]]]
|
|
235
237
|
# holder, coordinator or operator: take rejected items (item or node ids)
|
|
236
238
|
# out of an applying set so apply takes the approved ones. Each item's nodes
|
|
237
239
|
# must be back at the set's base version first (CHANGE_ITEM_NOT_AT_BASE lists
|
|
238
240
|
# the ones that differ); a withdrawn item never publishes, and the scopes only
|
|
239
|
-
# it sat in are released
|
|
241
|
+
# it sat in are released. --removed-nodes: nodes you deleted (sent as
|
|
242
|
+
# removedNodeIds); Dev takes each as gone when your reads list it in gone and
|
|
243
|
+
# its /nodes entry is null or the empty ghost Figma answers for a deleted
|
|
244
|
+
# component or variant
|
|
240
245
|
figma resubmit CHANGE_SET PAYLOAD.json [--sync] [--dry-run] [--lane-reads FILE]
|
|
241
246
|
# holder re-submits every rejected item: applying -> in_review, round + 1;
|
|
242
247
|
# each item needs context, each variant name and context; writeUp optional
|
|
@@ -1453,8 +1458,19 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1453
1458
|
}
|
|
1454
1459
|
if (action === "withdraw") {
|
|
1455
1460
|
if (rest.length > 1) throw new CliError("USAGE", `figma withdraw CHANGE_SET | ${WITHDRAW_ITEMS_USAGE}`, 2);
|
|
1456
|
-
if (f.items !== undefined)
|
|
1457
|
-
|
|
1461
|
+
if (f.items !== undefined) {
|
|
1462
|
+
const items = withdrawItemsFrom(f);
|
|
1463
|
+
const removedNodeIds = removedNodesFrom(f);
|
|
1464
|
+
const laneReads = f["lane-reads"] ? await readLaneReads(f["lane-reads"]) : undefined;
|
|
1465
|
+
if (removedNodeIds) removedNodesInReads(removedNodeIds, laneReads);
|
|
1466
|
+
return emit(
|
|
1467
|
+
await figmaWithdrawItems(rest[0], items, f.reason === true ? "" : f.reason, { laneReads, removedNodeIds }).catch((error) => { throw laneReadsRefusal(error); }),
|
|
1468
|
+
json,
|
|
1469
|
+
(p) => figmaWithdrawItemsText(rest[0], p.data),
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
if (f["removed-nodes"] !== undefined)
|
|
1473
|
+
throw new CliError("USAGE", `--removed-nodes goes with --items: ${WITHDRAW_ITEMS_USAGE}`, 2);
|
|
1458
1474
|
if (f.reason !== undefined)
|
|
1459
1475
|
throw new CliError("USAGE", `--reason goes with --items: ${WITHDRAW_ITEMS_USAGE} (a whole submit is withdrawn with: figma withdraw CHANGE_SET)`, 2);
|
|
1460
1476
|
return emit(await figmaWithdraw(rest[0]), json, (p) => `Withdrew ${rest[0]}; it is back in ${p.data?.state ?? "editing"}.`);
|
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.118";
|
|
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.js
CHANGED
|
@@ -952,7 +952,7 @@ export function figmaPublishPlanText(plan) {
|
|
|
952
952
|
].join("\n");
|
|
953
953
|
}
|
|
954
954
|
|
|
955
|
-
export const WITHDRAW_ITEMS_USAGE = "figma withdraw CHANGE_SET --items ID[,ID] --reason TEXT";
|
|
955
|
+
export const WITHDRAW_ITEMS_USAGE = "figma withdraw CHANGE_SET --items ID[,ID] --reason TEXT [--lane-reads FILE [--removed-nodes NODE[,NODE]]]";
|
|
956
956
|
|
|
957
957
|
/** `--items A,B --items C` → ["A", "B", "C"], each an item id or a Figma node id. */
|
|
958
958
|
export function withdrawItemsFrom(flags) {
|
|
@@ -963,6 +963,32 @@ export function withdrawItemsFrom(flags) {
|
|
|
963
963
|
return items;
|
|
964
964
|
}
|
|
965
965
|
|
|
966
|
+
/**
|
|
967
|
+
* `--removed-nodes 47:9554,47-9501` → the Figma node ids the lane deleted
|
|
968
|
+
* (a figma.com link's 47-9501 is 47:9501), sent as removedNodeIds (hub-312).
|
|
969
|
+
* Dev takes each as absent only with the lane's reads: in their `gone`, with a
|
|
970
|
+
* /nodes entry at the version read that is null or the empty ghost Figma
|
|
971
|
+
* answers for a deleted component or variant. So it goes with --lane-reads.
|
|
972
|
+
*/
|
|
973
|
+
export function removedNodesFrom(flags) {
|
|
974
|
+
if (flags["removed-nodes"] === undefined) return undefined;
|
|
975
|
+
const ids = [...new Set([flags["removed-nodes"]].flat().flatMap(nodeIdList).map(nodeId))];
|
|
976
|
+
if (!ids.length) throw new CliError("USAGE", `--removed-nodes needs Figma node ids: ${WITHDRAW_ITEMS_USAGE}`, 2);
|
|
977
|
+
const bad = ids.filter((x) => !BARE_NODE_ID.test(x));
|
|
978
|
+
if (bad.length) throw new CliError("USAGE", `--removed-nodes takes Figma node ids (like 47:9554), not: ${bad.join(", ")}`, 2);
|
|
979
|
+
if (!flags["lane-reads"] || flags["lane-reads"] === true)
|
|
980
|
+
throw new CliError("USAGE", `--removed-nodes goes with --lane-reads FILE: Dev takes a node as deleted only when your reads show it gone. ${WITHDRAW_ITEMS_USAGE}`, 2);
|
|
981
|
+
return ids;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/** Each removed node must be in the reads' `gone`, or Dev refuses it; say so before calling Dev. */
|
|
985
|
+
export function removedNodesInReads(ids, reads) {
|
|
986
|
+
const gone = new Set(Array.isArray(reads?.gone) ? reads.gone : []);
|
|
987
|
+
const missing = ids.filter((x) => !gone.has(x));
|
|
988
|
+
if (missing.length)
|
|
989
|
+
throw new CliError("USAGE", `--removed-nodes ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} not in your lane reads' gone list. Read ${missing.length === 1 ? "it" : "them"} through the Figma MCP and list ${missing.length === 1 ? "it" : "them"} in gone if deleted, then run this again. Nothing was sent.`, 2);
|
|
990
|
+
}
|
|
991
|
+
|
|
966
992
|
const indented = (ids) => ids.map((x) => ` ${x}`);
|
|
967
993
|
|
|
968
994
|
// Dev's refusals of withdrawDesignChangeItems, said in terms of what to do next.
|
|
@@ -972,13 +998,22 @@ const WITHDRAW_ITEMS_REFUSALS = {
|
|
|
972
998
|
INVALID_CHANGE_SET_STATE: (id, message) => `${message}\nItems are withdrawn only while ${id} is applying (decided, with rejected items). Check it with: nodii-dev figma changeset show ${id}`,
|
|
973
999
|
CHANGE_SET_HAS_NO_BASE_VERSION: (id, message) => `${message}\nDev can't tell whether the items' nodes are back at base, so it can't withdraw them.`,
|
|
974
1000
|
CHANGE_SET_CHANGED: (id, message) => `${message}\n${id} changed while withdrawing; read it with nodii-dev figma changeset show ${id} and run this again.`,
|
|
975
|
-
CHANGE_ITEM_NOT_AT_BASE: (id, message, d) => {
|
|
976
|
-
const
|
|
977
|
-
if (!
|
|
1001
|
+
CHANGE_ITEM_NOT_AT_BASE: (id, message, d, removed = []) => {
|
|
1002
|
+
const all = d?.nodeIds ?? [];
|
|
1003
|
+
if (!all.length) return message;
|
|
1004
|
+
// A node named in --removed-nodes that Dev still finds: Dev's own words say
|
|
1005
|
+
// why (not in the reads' gone, or still in the file). The rest differ from base.
|
|
1006
|
+
const named = all.filter((n) => removed.includes(n));
|
|
1007
|
+
const nodes = all.filter((n) => !removed.includes(n));
|
|
978
1008
|
return [
|
|
979
|
-
|
|
980
|
-
...
|
|
981
|
-
|
|
1009
|
+
...(named.length ? [message] : []),
|
|
1010
|
+
...(nodes.length
|
|
1011
|
+
? [
|
|
1012
|
+
`${nodes.length} node(s) of ${d?.changeSetId ?? id} still differ from its base version${d?.baseVersion ? ` (${d.baseVersion})` : ""}:`,
|
|
1013
|
+
...indented(nodes),
|
|
1014
|
+
"Put each back as it was at base (remove it if the set added it), then run this again. Nothing was withdrawn.",
|
|
1015
|
+
]
|
|
1016
|
+
: ["Nothing was withdrawn."]),
|
|
982
1017
|
].join("\n");
|
|
983
1018
|
},
|
|
984
1019
|
CHANGE_ITEM_NOT_REJECTED: (id, message, d) => {
|
|
@@ -1004,14 +1039,20 @@ const WITHDRAW_ITEMS_REFUSALS = {
|
|
|
1004
1039
|
* must already be back at the set's base version; apply then takes the
|
|
1005
1040
|
* approved items alone, and the scopes only those items sat in are released.
|
|
1006
1041
|
*/
|
|
1007
|
-
export async function figmaWithdrawItems(id, items, reason, { request = devRequest, laneReads } = {}) {
|
|
1042
|
+
export async function figmaWithdrawItems(id, items, reason, { request = devRequest, laneReads, removedNodeIds } = {}) {
|
|
1008
1043
|
if (!id || !items?.length) throw new CliError("USAGE", WITHDRAW_ITEMS_USAGE, 2);
|
|
1009
1044
|
if (typeof reason !== "string" || !reason.trim()) throw new CliError("USAGE", `--reason needs a reason: ${WITHDRAW_ITEMS_USAGE}`, 2);
|
|
1045
|
+
const removed = removedNodeIds?.length ? removedNodeIds : null;
|
|
1010
1046
|
try {
|
|
1011
|
-
return await request("POST", `/api/v1/design/change-sets/${encode(id)}/withdraw-items`, {
|
|
1047
|
+
return await request("POST", `/api/v1/design/change-sets/${encode(id)}/withdraw-items`, {
|
|
1048
|
+
items,
|
|
1049
|
+
reason: reason.trim(),
|
|
1050
|
+
...(removed ? { removedNodeIds: removed } : {}),
|
|
1051
|
+
...(laneReads ? { laneReads } : {}),
|
|
1052
|
+
});
|
|
1012
1053
|
} catch (error) {
|
|
1013
1054
|
const say = WITHDRAW_ITEMS_REFUSALS[error?.code];
|
|
1014
|
-
if (say) throw new CliError(error.code, say(id, error.message, error.details), error.exitCode ?? 1, error.details);
|
|
1055
|
+
if (say) throw new CliError(error.code, say(id, error.message, error.details, removed ?? []), error.exitCode ?? 1, error.details);
|
|
1015
1056
|
throw scopeRefusal(error, id) ?? error;
|
|
1016
1057
|
}
|
|
1017
1058
|
}
|
package/dist/flags.js
CHANGED
|
@@ -67,7 +67,7 @@ export const COMMAND_FLAGS = {
|
|
|
67
67
|
"docs ratify": ["domain", "decision", ...WAIT],
|
|
68
68
|
"figma submit": ["file", "figma-version", ...SUBMIT_MODE, "dry-run", "lane-reads"],
|
|
69
69
|
"figma resubmit": [...SUBMIT_MODE, "dry-run", "lane-reads"],
|
|
70
|
-
"figma withdraw": ["items", "reason", "lane-reads"],
|
|
70
|
+
"figma withdraw": ["items", "reason", "lane-reads", "removed-nodes"],
|
|
71
71
|
"figma lane-reads-script": ["nodes"],
|
|
72
72
|
"figma abandon": ["file"],
|
|
73
73
|
// hub-260: list takes these; show takes none.
|