Skip to content

Commit 0afd418

Browse files
feat(release): infer the next version when omitted
Figma increments by exactly 1 per publish, so the number is derivable. Omitting it now infers current+1 and prints the assumption prominently — the repo version only means anything if it matches what Figma assigned, and the tag still isn't pushed automatically. Publishing itself stays manual: Figma exposes no API for it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a494b5f commit 0afd418

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

scripts/release.mjs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
* is no API to read it back), so you pass the number shown in Figma's publish
77
* dialog. Everything downstream is derived from it.
88
*
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
1112
*
1213
* With no arguments it reports which plugins have unpublished changes.
1314
*
@@ -53,18 +54,31 @@ function status() {
5354
: ` ${p.padEnd(18)} v${String(v).padEnd(4)} up to date with ${tag}\n`,
5455
);
5556
}
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');
5758
}
5859

59-
const [, , plugin, version] = process.argv;
60+
const [, , plugin] = process.argv;
61+
let version = process.argv[3];
6062

6163
if (!plugin) { status(); process.exit(0); }
6264

6365
if (!plugins.includes(plugin)) {
6466
process.stderr.write(`Unknown plugin "${plugin}". Known: ${plugins.join(', ')}\n`);
6567
process.exit(1);
6668
}
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)) {
6882
process.stderr.write(
6983
'Version must be the integer Figma shows when publishing to Community, e.g. 5.\n',
7084
);
@@ -101,6 +115,11 @@ sh('git', ['commit', '-m', `${plugin} v${version}`], { stdio: 'inherit' });
101115
sh('git', ['tag', '-a', tag, '-m', `${plugin} v${version}`], { stdio: 'inherit' });
102116

103117
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+
: '') +
104123
`\nTagged ${tag}. Not pushed.\n` +
105124
` Review, then: git push origin main --follow-tags\n` +
106125
` Then publish v${version} in Figma and cut the GitHub Release from ${tag}.\n` +

0 commit comments

Comments
 (0)