mirror of
https://github.com/certd/certd.git
synced 2026-06-15 21:57:33 +08:00
chore: 1
This commit is contained in:
+2
-1
@@ -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",
|
||||
|
||||
@@ -76,5 +76,5 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/publishlab/node-acme-client/issues"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -52,5 +52,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -49,5 +49,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -27,5 +27,5 @@
|
||||
"prettier": "^2.8.8",
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -34,5 +34,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -59,5 +59,5 @@
|
||||
"fetch"
|
||||
]
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -36,5 +36,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -69,5 +69,5 @@
|
||||
"typeorm": "^0.3.11",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -49,5 +49,5 @@
|
||||
"typeorm": "^0.3.11",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -41,5 +41,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -61,5 +61,5 @@
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"gitHead": "678b70cee8510a2b5217788c5db9469f49cbd439"
|
||||
"gitHead": "01c91ba294f88bd07fddf9358c4301bbb4027916"
|
||||
}
|
||||
|
||||
@@ -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} 个包版本已存在`);
|
||||
Reference in New Issue
Block a user