fix: 前置发布构建的 Node 版本门禁
This commit is contained in:
1 parent
ab17f80607
commit
b101d169c9
3 files changed
+25
-2
No files matched your search
@@ -0,0 +1,9 @@
|
||||
export function nodeMajor(version = process.versions.node) {
|
||||
return Number(String(version).replace(/^v/, "").split(".")[0]);
|
||||
}
|
||||
|
||||
export function assertSupportedNode(version = process.versions.node) {
|
||||
if (nodeMajor(version) !== 24) {
|
||||
throw new Error(`Node.js 24 is required to build the release (current: ${version})`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { assertSupportedNode, nodeMajor } from "./node-version.mjs";
|
||||
|
||||
test("接受 Node 24 及 v 前缀版本号", () => {
|
||||
assert.doesNotThrow(() => assertSupportedNode("24.16.0"));
|
||||
assert.doesNotThrow(() => assertSupportedNode("v24.16.0"));
|
||||
assert.equal(nodeMajor("v24.16.0"), 24);
|
||||
});
|
||||
|
||||
test("拒绝非 Node 24 并给出可操作错误", () => {
|
||||
assert.throws(() => assertSupportedNode("22.22.2"), /Node\.js 24 is required/);
|
||||
assert.throws(() => assertSupportedNode("25.0.0"), /current: 25\.0\.0/);
|
||||
});
|
||||
@@ -7,6 +7,7 @@ import { spawnSync } from "node:child_process";
|
||||
import { createRequire } from "node:module";
|
||||
import { checkPackage } from "./check-package.mjs";
|
||||
import { verifyRuntimePreflight } from "./runtime-preflight.mjs";
|
||||
import { assertSupportedNode } from "./node-version.mjs";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { findLeaks, loadConfig } = require("../../apps/taro/config/mask-taro.cjs");
|
||||
@@ -174,8 +175,6 @@ async function buildTemplateCatalog() {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
if (Number(process.versions.node.split(".")[0]) !== 24)
|
||||
throw new Error("Node.js 24 is required to build the release");
|
||||
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$/.test(version))
|
||||
throw new Error("Invalid release version");
|
||||
const adminDist = path.join(root, "apps/admin/dist");
|
||||
@@ -260,6 +259,7 @@ async function main() {
|
||||
console.log("checksum: " + path.relative(root, archive + ".sha256"));
|
||||
}
|
||||
|
||||
assertSupportedNode();
|
||||
run("pnpm", ["build:admin:preview"]);
|
||||
assertNoStackFingerprint("apps/admin/dist");
|
||||
run("pnpm", ["--filter", "@personal-brand/config", "build"]);
|
||||
|
||||
Reference in new issue
Block a user