Skip to content

Commit bdce327

Browse files
NicolappsConvex, Inc.
authored andcommitted
eslint: ensure we don’t publish an alpha version with the latest tag (#41790)
GitOrigin-RevId: 8977d1e17e50b11916d1e86be5356b43e192de11
1 parent f6229f2 commit bdce327

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

npm-packages/@convex-dev/eslint-plugin/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"test:watch": "vitest",
1111
"prepare": "tshy",
1212
"lint": "eslint .",
13-
"prepublishOnly": "node src/scripts/checkVersion.mjs"
13+
"prepublishOnly": "node src/scripts/check-version.mjs",
14+
"prepack": "node src/scripts/dont-publish-alpha-as-latest.mjs"
1415
},
1516
"dependencies": {
1617
"@typescript-eslint/utils": "~8.38.0"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env node
2+
3+
import { fileURLToPath } from "node:url";
4+
import { dirname, join } from "node:path";
5+
import { readFileSync } from "node:fs";
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = dirname(__filename);
9+
10+
const packageJsonPath = join(__dirname, "../../package.json");
11+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
12+
const version = packageJson.version;
13+
14+
// Check if this is an alpha version
15+
const isAlpha = version.includes("alpha") || version.includes("-alpha.");
16+
17+
if (isAlpha) {
18+
// For alpha versions, require --tag=alpha
19+
const npmTag = process.env.npm_config_tag;
20+
21+
if (!npmTag || npmTag === "latest") {
22+
console.error(
23+
`❌ Alpha version ${version} cannot be published to "latest" tag`,
24+
);
25+
console.error("Use: npm publish --tag=alpha");
26+
process.exit(1);
27+
}
28+
29+
if (npmTag !== "alpha") {
30+
console.error(
31+
`❌ Alpha version ${version} should use --tag=alpha, not --tag=${npmTag}`,
32+
);
33+
console.error("Use: npm publish --tag=alpha");
34+
process.exit(1);
35+
}
36+
37+
console.log(`✅ Publishing alpha version ${version} with --tag=alpha`);
38+
} else {
39+
// For stable versions, warn if not using latest
40+
const npmTag = process.env.npm_config_tag;
41+
if (npmTag && npmTag !== "latest") {
42+
console.warn(
43+
`⚠️ Publishing stable version ${version} with --tag=${npmTag}`,
44+
);
45+
console.warn("Did you mean to use --tag=latest or no tag?");
46+
} else {
47+
console.log(`✅ Publishing stable version ${version}`);
48+
}
49+
}

0 commit comments

Comments
 (0)