Files
tutti/tools/scripts/run-repository-checks.mjs
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

71 lines
2.0 KiB
JavaScript

import { execFileSync } from "node:child_process";
import { readFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { selectRepositoryChecks } from "./repository-checks.mjs";
import { runValidationLanes } from "./run-validation-lanes.mjs";
const scriptDirectory = dirname(fileURLToPath(import.meta.url));
const workspaceRoot = resolve(scriptDirectory, "../..");
const group = readOption("--group");
const base = readOption("--base");
const head = readOption("--head") ?? "HEAD";
if (!group || !base) {
throw new Error("--group and --base are required");
}
const changedFiles = execFileSync(
"git",
["diff", "--name-only", `${base}...${head}`],
{ cwd: workspaceRoot, encoding: "utf8" }
)
.split("\n")
.map((line) => line.trim())
.filter(Boolean);
const checks = selectRepositoryChecks(changedFiles, { group });
if (checks.length === 0) {
console.log(`repository checks skipped for ${group}`);
process.exit(0);
}
const pnpmCommand = resolvePnpmCommand();
const result = await runValidationLanes({
lanes: checks.map((check) => ({
command: [...pnpmCommand, "run", check.script],
key: check.key,
label: check.label
})),
maxParallel: 3,
summaryLabel: `${group} repository checks`,
tailLines: 100,
tmpDirectoryName: `repository-checks/${group}`,
workspaceRoot
});
process.exit(result.exitCode);
function resolvePnpmCommand() {
const fallback = [process.platform === "win32" ? "pnpm.cmd" : "pnpm"];
try {
const packageJson = JSON.parse(
readFileSync(join(workspaceRoot, "package.json"), "utf8")
);
const match = /^pnpm@(.+)$/u.exec(String(packageJson.packageManager ?? ""));
return match
? [
process.platform === "win32" ? "corepack.cmd" : "corepack",
`pnpm@${match[1]}`
]
: fallback;
} catch {
return fallback;
}
}
function readOption(name) {
const index = process.argv.indexOf(name);
return index === -1 ? null : (process.argv[index + 1] ?? null);
}