mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
c70aee247e
* refactor(scripts): migrate JavaScript tools to TypeScript * fix(ci): keep changed-scope preflight zero-install * fix(ci): preserve zero-install script owners * fix(ci): complete script migration follow-through * fix(release): keep stable closeout zero-install * fix(scripts): preserve standalone execution boundaries * fix(scripts): repair standalone loader boundaries * fix(scripts): normalize gateway observation ids * fix(scripts): keep Docker packager standalone * test(scripts): preserve rebase cleanup helpers * test(sessions): use tracked temp directory
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
#!/usr/bin/env node
|
|
|
|
// Enforces core tsgo project boundaries and sparse-checkout safety.
|
|
import { spawnSync } from "node:child_process";
|
|
import { resolveRepoToolBinPath } from "./lib/local-heavy-check-runtime.mts";
|
|
import { createManagedCommandInvocation } from "./lib/managed-child-process.mts";
|
|
import { resolveRepoRoot } from "./lib/repo-root.mjs";
|
|
const repoRoot = resolveRepoRoot(import.meta.url);
|
|
const tsgoPath = resolveRepoToolBinPath("tsgo", { cwd: repoRoot });
|
|
|
|
const coreGraphs = [
|
|
{ name: "core", config: "tsconfig.core.json" },
|
|
{ name: "ui", config: "tsconfig.ui.json" },
|
|
{ name: "core-test", config: "test/tsconfig/tsconfig.core.test.json" },
|
|
{ name: "core-test-agents", config: "test/tsconfig/tsconfig.core.test.agents.json" },
|
|
{ name: "core-test-non-agents", config: "test/tsconfig/tsconfig.core.test.non-agents.json" },
|
|
];
|
|
function normalizeFilePath(filePath: string) {
|
|
const normalized = filePath.trim().replaceAll("\\", "/");
|
|
const normalizedRoot = repoRoot.replaceAll("\\", "/");
|
|
if (normalized.startsWith(`${normalizedRoot}/`)) {
|
|
return normalized.slice(normalizedRoot.length + 1);
|
|
}
|
|
return normalized;
|
|
}
|
|
|
|
function listGraphFiles(graph: (typeof coreGraphs)[number]) {
|
|
const tsgo = createManagedCommandInvocation({
|
|
args: ["-p", graph.config, "--pretty", "false", "--listFilesOnly"],
|
|
bin: tsgoPath,
|
|
});
|
|
const result = spawnSync(tsgo.command, tsgo.args, {
|
|
cwd: repoRoot,
|
|
encoding: "utf8",
|
|
maxBuffer: 256 * 1024 * 1024,
|
|
shell: tsgo.shell,
|
|
windowsVerbatimArguments: tsgo.windowsVerbatimArguments,
|
|
});
|
|
if (result.error) {
|
|
throw result.error;
|
|
}
|
|
if ((result.status ?? 1) !== 0) {
|
|
const output = [result.stdout, result.stderr].filter(Boolean).join("\n");
|
|
throw new Error(`${graph.name} file listing failed with exit code ${result.status}\n${output}`);
|
|
}
|
|
return (result.stdout ?? "").split(/\r?\n/u).map(normalizeFilePath).filter(Boolean);
|
|
}
|
|
|
|
const violations: string[] = [];
|
|
for (const graph of coreGraphs) {
|
|
const extensionFiles = listGraphFiles(graph).filter((file) => file.startsWith("extensions/"));
|
|
for (const file of extensionFiles) {
|
|
violations.push(`${graph.name}: ${file}`);
|
|
}
|
|
}
|
|
|
|
if (violations.length > 0) {
|
|
console.error("Core tsgo graphs must not include bundled extension files:");
|
|
for (const violation of violations) {
|
|
console.error(`- ${violation}`);
|
|
}
|
|
console.error(
|
|
"Move extension-owned behavior behind plugin SDK contracts, public artifacts, or extension-local tests.",
|
|
);
|
|
process.exit(1);
|
|
}
|