|
6 | 6 | * is no API to read it back), so you pass the number shown in Figma's publish |
7 | 7 | * dialog. Everything downstream is derived from it. |
8 | 8 | * |
9 | | - * node scripts/release.mjs <plugin> <version> |
10 | | - * node scripts/release.mjs impact-atlas 5 |
| 9 | + * node scripts/release.mjs <plugin> [version] |
| 10 | + * node scripts/release.mjs impact-atlas 6 explicit |
| 11 | + * node scripts/release.mjs impact-atlas infers current+1 |
11 | 12 | * |
12 | 13 | * With no arguments it reports which plugins have unpublished changes. |
13 | 14 | * |
@@ -53,18 +54,31 @@ function status() { |
53 | 54 | : ` ${p.padEnd(18)} v${String(v).padEnd(4)} up to date with ${tag}\n`, |
54 | 55 | ); |
55 | 56 | } |
56 | | - process.stdout.write('\nRelease: node scripts/release.mjs <plugin> <version>\n\n'); |
| 57 | + process.stdout.write('\nRelease: node scripts/release.mjs <plugin> [version] (version inferred as current+1 if omitted)\n\n'); |
57 | 58 | } |
58 | 59 |
|
59 | | -const [, , plugin, version] = process.argv; |
| 60 | +const [, , plugin] = process.argv; |
| 61 | +let version = process.argv[3]; |
60 | 62 |
|
61 | 63 | if (!plugin) { status(); process.exit(0); } |
62 | 64 |
|
63 | 65 | if (!plugins.includes(plugin)) { |
64 | 66 | process.stderr.write(`Unknown plugin "${plugin}". Known: ${plugins.join(', ')}\n`); |
65 | 67 | process.exit(1); |
66 | 68 | } |
67 | | -if (!/^\d+$/.test(version || '')) { |
| 69 | +// Figma increments the version by exactly 1 on each publish, so the next number |
| 70 | +// is derivable. Omitting it infers current+1; the inference is printed loudly |
| 71 | +// because the repo version is only meaningful if it matches what Figma assigned. |
| 72 | +let inferred = false; |
| 73 | +if (!version) { |
| 74 | + const cur = readPkg(plugin).version; |
| 75 | + if (!/^\d+$/.test(String(cur))) { |
| 76 | + process.stderr.write(`Cannot infer the next version from "${cur}". Pass it explicitly.\n`); |
| 77 | + process.exit(1); |
| 78 | + } |
| 79 | + version = String(Number(cur) + 1); |
| 80 | + inferred = true; |
| 81 | +} else if (!/^\d+$/.test(version)) { |
68 | 82 | process.stderr.write( |
69 | 83 | 'Version must be the integer Figma shows when publishing to Community, e.g. 5.\n', |
70 | 84 | ); |
@@ -101,6 +115,11 @@ sh('git', ['commit', '-m', `${plugin} v${version}`], { stdio: 'inherit' }); |
101 | 115 | sh('git', ['tag', '-a', tag, '-m', `${plugin} v${version}`], { stdio: 'inherit' }); |
102 | 116 |
|
103 | 117 | process.stdout.write( |
| 118 | + (inferred |
| 119 | + ? `\n⚠️ Version inferred as v${version} (previous was v${prev}).\n` + |
| 120 | + ` Confirm this matches Figma's publish dialog before pushing — the repo\n` + |
| 121 | + ` version is only useful if it equals the Community one.\n` |
| 122 | + : '') + |
104 | 123 | `\nTagged ${tag}. Not pushed.\n` + |
105 | 124 | ` Review, then: git push origin main --follow-tags\n` + |
106 | 125 | ` Then publish v${version} in Figma and cut the GitHub Release from ${tag}.\n` + |
|
0 commit comments