@nodii/dev 0.6.6 → 0.6.7

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 CHANGED
@@ -144,8 +144,21 @@ nodii-dev figma submit CHANGE_SET --file SUBMISSION.json
144
144
  nodii-dev figma apply CHANGE_SET --figma-version VERSION
145
145
  nodii-dev figma published CHANGE_SET --figma-version VERSION
146
146
  nodii-dev figma abandon CHANGE_SET
147
+ nodii-dev figma withdraw CHANGE_SET # take back a submit before anything is decided
147
148
  nodii-dev figma release FILE_KEY
148
149
 
150
+ ```
151
+
152
+ `figma withdraw` moves a change set you hold from `in_review` back to
153
+ `editing`, as long as no item has been decided (Dev's
154
+ `withdrawDesignChangeSet`). Dev refuses when the change set doesn't exist
155
+ (`CHANGE_SET_NOT_FOUND`), isn't in review (`CHANGE_SET_NOT_IN_REVIEW`), you
156
+ aren't its holder or an operator (`WITHDRAW_NOT_ALLOWED`), or an item is
157
+ already decided (`CHANGE_SET_HAS_DECISIONS`: ask the reviewer to request
158
+ changes instead). The CLI prints each refusal in plain words and keeps the
159
+ code.
160
+
161
+ ```bash
149
162
  nodii-dev hook claude-figma-pre # reads Claude Code hook JSON on stdin
150
163
  nodii-dev hook claude-figma-post # reads Claude Code hook JSON on stdin
151
164
  nodii-dev hook print-settings # prints managed-settings JSON; writes nothing
package/dist/cli.js CHANGED
@@ -68,6 +68,7 @@ Usage: nodii-dev <command> [options] [--json]
68
68
  design guideline propose ENTRY --file FILE.md [--summary TEXT] [--dry-run]
69
69
  design changeset list [--entry KEY] [--state STATE] | show ID
70
70
  figma lock|check|log-write|submit|apply|published|abandon|release
71
+ figma withdraw CHANGE_SET # holder takes back a submit: in_review -> editing
71
72
  hook claude-figma-pre|claude-figma-post|print-settings
72
73
  setup [--yes|--check] # dry-run by default
73
74
  harness install|update [--include-drafts[=false]] [--adopt PATH,...] [--dry-run]
@@ -268,6 +269,25 @@ export function transitionBody(f) {
268
269
  return { to, ...(note ? { note } : {}) };
269
270
  }
270
271
 
272
+ // Dev's refusals of withdrawDesignChangeSet, said in terms of what to do next.
273
+ const WITHDRAW_REFUSALS = {
274
+ CHANGE_SET_NOT_FOUND: (id) => `No change set ${id} in Dev.`,
275
+ CHANGE_SET_NOT_IN_REVIEW: (id) => `${id} is not in review; only a submitted (in_review) change set can be withdrawn.`,
276
+ WITHDRAW_NOT_ALLOWED: (id) => `You don't hold ${id}; only its holder (or an operator) can withdraw it.`,
277
+ CHANGE_SET_HAS_DECISIONS: (id) => `${id} already has a decided item, so it can't be withdrawn; ask the reviewer to request changes instead.`,
278
+ };
279
+
280
+ export async function figmaWithdraw(id, { request = devRequest } = {}) {
281
+ if (!id) throw new CliError("USAGE", "figma withdraw CHANGE_SET", 2);
282
+ try {
283
+ return await request("POST", `/api/v1/design/change-sets/${encode(id)}/withdraw`, {});
284
+ } catch (error) {
285
+ const say = WITHDRAW_REFUSALS[error?.code];
286
+ if (!say) throw error;
287
+ throw new CliError(error.code, say(id), error.exitCode ?? 1, error.details);
288
+ }
289
+ }
290
+
271
291
  export async function main(argv = process.argv.slice(2)) {
272
292
  if (argv.length === 1 && ["--version", "-v"].includes(argv[0]))
273
293
  return console.log(VERSION);
@@ -574,6 +594,8 @@ export async function main(argv = process.argv.slice(2)) {
574
594
  json,
575
595
  );
576
596
  }
597
+ if (action === "withdraw")
598
+ return emit(await figmaWithdraw(rest[0]), json, `Withdrew ${rest[0]}; it is back in editing.`);
577
599
  if (action === "release")
578
600
  return emit(
579
601
  await devRequest(
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.6";
7
+ export const VERSION = "0.6.7";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");