This commit is contained in:
xiaojunnuo
2026-05-21 23:23:20 +08:00
parent 01c91ba294
commit 784ef8a6a4
13 changed files with 94 additions and 12 deletions
+2 -1
View File
@@ -20,6 +20,7 @@
"devb": "lerna run dev-build",
"i-all": "lerna link && lerna exec npm install ",
"publish": "pnpm run prepublishOnly2 && lerna publish --force-publish=pro/plus-core --conventional-commits && pnpm run afterpublishOnly ",
"publish2":" npm run pub_all && pnpm run afterpublishOnly",
"afterpublishOnly": "pnpm run copylogs && time /t >trigger/build.trigger && git add ./trigger/build.trigger && git commit -m \"build: trigger build image\" && TIMEOUT /T 10 && pnpm run commitAll",
"transform-sql": "cd ./packages/ui/certd-server/db/ && node --experimental-json-modules transform.js",
"plugin-doc-gen": "cd ./packages/ui/certd-server/ && pnpm run export-metadata",
@@ -39,7 +40,7 @@
"test:unit": "cross-env NODE_ENV=unittest pnpm -r --workspace-concurrency=1 run test:unit",
"pub": "echo 1",
"dev": "pnpm run -r --parallel compile ",
"pub_all":"pnpm run -r --parallel pub ",
"pub_all": "node ./scripts/pub-all.js",
"release": "time /t >trigger/release.trigger && git add trigger/release.trigger && git commit -m \"build: release\" && git push",
"publish_to_atomgit": "node --experimental-json-modules ./scripts/publish-atomgit.js",
"publish_to_gitee": "node --experimental-json-modules ./scripts/publish-gitee.js",
+1 -1
View File
@@ -76,5 +76,5 @@
"bugs": {
"url": "https://github.com/publishlab/node-acme-client/issues"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -52,5 +52,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -49,5 +49,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -27,5 +27,5 @@
"prettier": "^2.8.8",
"tslib": "^2.8.1"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -34,5 +34,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -59,5 +59,5 @@
"fetch"
]
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -36,5 +36,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -69,5 +69,5 @@
"typeorm": "^0.3.11",
"typescript": "^5.4.2"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -49,5 +49,5 @@
"typeorm": "^0.3.11",
"typescript": "^5.4.2"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -41,5 +41,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+1 -1
View File
@@ -61,5 +61,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
}
+81
View File
@@ -0,0 +1,81 @@
import childProcess from "child_process";
import fs from "fs";
import path from "path";
function run(command, args, options = {}) {
const result = childProcess.spawnSync(command, args, {
stdio: options.stdio ?? "pipe",
shell: process.platform === "win32",
encoding: "utf-8",
...options,
});
if (result.error) {
throw result.error;
}
return result;
}
function printOutput(result) {
if (result.stdout) {
process.stdout.write(result.stdout);
}
if (result.stderr) {
process.stderr.write(result.stderr);
}
}
function isAlreadyPublishedError(result) {
const output = `${result.stdout ?? ""}\n${result.stderr ?? ""}`;
return output.includes("You cannot publish over the previously published versions");
}
function getWorkspacePackages() {
const result = run("pnpm", ["list", "-r", "--depth", "-1", "--json"], {
stdio: "pipe",
});
if (result.status !== 0) {
console.error(result.stderr);
throw new Error("获取 workspace 包列表失败");
}
return JSON.parse(result.stdout);
}
function hasPubScript(packagePath) {
const packageJsonPath = path.join(packagePath, "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
return Boolean(packageJson.scripts?.pub);
}
const packages = getWorkspacePackages().filter(item => item.name !== "root");
let skippedCount = 0;
let alreadyPublishedCount = 0;
for (const item of packages) {
const packagePath = item.path;
if (!hasPubScript(packagePath)) {
skippedCount++;
console.log(`[pub_all] 跳过 ${item.name},未定义 pub 脚本`);
continue;
}
console.log(`\n[pub_all] 开始发布 ${item.name}`);
const result = run("pnpm", ["--dir", packagePath, "run", "pub"]);
printOutput(result);
if (result.status === 0) {
console.log(`[pub_all] ${item.name} 发布完成`);
} else if (isAlreadyPublishedError(result)) {
alreadyPublishedCount++;
console.warn(`[pub_all] ${item.name} 当前版本已发布,继续发布其他包`);
} else {
console.error(`[pub_all] ${item.name} 发布失败,停止发布`);
process.exit(result.status ?? 1);
}
}
console.log(`\n[pub_all] 发布任务完成,跳过 ${skippedCount} 个未定义 pub 脚本的包,${alreadyPublishedCount} 个包版本已存在`);