fix: package complete Windows bridge runtime
CI / Client installer (macos-latest) (push) Canceled after 0s
CI / Client installer (ubuntu-latest) (push) Canceled after 0s
CI / Client installer (windows-latest) (push) Canceled after 0s
CI / test (22) (push) Canceled after 0s
CI / test (24) (push) Canceled after 0s
CI / release-smoke (push) Canceled after 0s
CI / Client installer (macos-latest) (push) Canceled after 0s
CI / Client installer (ubuntu-latest) (push) Canceled after 0s
CI / Client installer (windows-latest) (push) Canceled after 0s
CI / test (22) (push) Canceled after 0s
CI / test (24) (push) Canceled after 0s
CI / release-smoke (push) Canceled after 0s
This commit is contained in:
@@ -44,7 +44,7 @@ mkdirSync(out, { recursive: true, mode: 0o755 });
|
||||
execFileSync("npm", ["run", "build"], { stdio: "inherit", env: npmEnvironment() });
|
||||
|
||||
mkdirSync(join(clientStaging, "dist", "src"), { recursive: true });
|
||||
for (const name of ["bridge.js", "entrypoint.js", "client-installer.js", "approval-contract.js"]) {
|
||||
for (const name of ["bridge.js", "entrypoint.js", "client-installer.js", "approval-contract.js", "version.js"]) {
|
||||
cpSync(resolve("dist", "src", name), join(clientStaging, "dist", "src", name));
|
||||
}
|
||||
cpSync(resolve("skills/dingtalk-approval"), join(clientStaging, "skill", "dingtalk-approval"), { recursive: true });
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { createHash, createPublicKey, verify as verifySignature } from "node:crypto";
|
||||
import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { basename, join, resolve, sep } from "node:path";
|
||||
import { basename, dirname, join, resolve, sep } from "node:path";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
@@ -54,6 +54,7 @@ try {
|
||||
scanTree(clientRoot);
|
||||
const packageMetadata = JSON.parse(readFileSync(join(root, "client", "package", "package.json"), "utf8"));
|
||||
if (packageMetadata.name !== "dingtalk-approval-client" || packageMetadata.version !== version) throw new Error("客户端 package.json 名称或版本不一致");
|
||||
assertRelativeModuleClosure(join(root, "client", "package", "dist", "src"));
|
||||
if (JSON.stringify(Object.keys(packageMetadata.bin ?? {}).sort()) !== JSON.stringify(["dingtalk-approval", "dingtalk-approval-bridge"])) {
|
||||
throw new Error("客户端只能发布安装 CLI 和 Bridge 两个 bin");
|
||||
}
|
||||
@@ -154,6 +155,20 @@ function releaseKeyId(value) {
|
||||
return createHash("sha256").update(der).digest("hex");
|
||||
}
|
||||
function existsFile(path) { try { return statSync(path).isFile(); } catch { return false; } }
|
||||
function assertRelativeModuleClosure(rootPath) {
|
||||
const prefix = `${resolve(rootPath)}${sep}`;
|
||||
for (const path of walk(rootPath)) {
|
||||
if (!path.endsWith(".js")) continue;
|
||||
const body = readFileSync(path, "utf8");
|
||||
const imports = body.matchAll(/(?:\bfrom\s*|\bimport\s*)["'](\.\.?\/[^"']+\.js)["']/g);
|
||||
for (const match of imports) {
|
||||
const target = resolve(dirname(path), match[1]);
|
||||
if (!target.startsWith(prefix) || !existsFile(target)) {
|
||||
throw new Error(`客户端模块依赖缺失:${match[1]}(由 ${path.slice(prefix.length)} 导入)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function scanTree(rootPath) {
|
||||
for (const path of walk(rootPath)) {
|
||||
if (statSync(path).size > 2_000_000) continue;
|
||||
|
||||
Reference in New Issue
Block a user