69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { execFileSync } from "node:child_process";
|
|
import { existsSync, readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import test from "node:test";
|
|
|
|
const ROOT = process.cwd();
|
|
const MACOS_HOME_PATH_PATTERN = /\/Users\/[^/\s]+\//;
|
|
const EMBEDDED_LOCAL_TOKEN_PATTERN = /LOCAL_API_TOKEN\s*[:=]\s*["'][^"']{8,}["']/;
|
|
const PUBLIC_FILES = [
|
|
"README.md",
|
|
"docs/ARCHITECTURE.md",
|
|
"docs/PROGRESS.md",
|
|
"docs/mission.runbook.md",
|
|
"ecosystem.config.cjs",
|
|
"mission.config.json",
|
|
"scripts/run_verifier.sh",
|
|
"scripts/mc_dod_evaluator.py",
|
|
"scripts/mc_rollback_plan.py",
|
|
"workflows/pandas_v3_autopilot.lobster",
|
|
];
|
|
|
|
test("repo includes baseline open-source release metadata", () => {
|
|
assert(existsSync(path.join(ROOT, ".gitignore")), "Expected .gitignore to exist.");
|
|
assert(existsSync(path.join(ROOT, "LICENSE")), "Expected LICENSE to exist.");
|
|
|
|
const ignore = readFileSync(path.join(ROOT, ".gitignore"), "utf8");
|
|
assert.match(ignore, /(^|\n)node_modules\/(\n|$)/);
|
|
assert.match(ignore, /(^|\n)dist\/(\n|$)/);
|
|
assert.match(ignore, /(^|\n)runtime\/(\n|$)/);
|
|
|
|
const license = readFileSync(path.join(ROOT, "LICENSE"), "utf8");
|
|
assert.match(license, /MIT License/);
|
|
|
|
const pkg = JSON.parse(readFileSync(path.join(ROOT, "package.json"), "utf8"));
|
|
assert.notEqual(pkg.private, true);
|
|
assert.equal(pkg.license, "MIT");
|
|
});
|
|
|
|
test("public-facing files do not embed machine-specific paths or local token values", () => {
|
|
for (const relativePath of PUBLIC_FILES) {
|
|
const content = readFileSync(path.join(ROOT, relativePath), "utf8");
|
|
assert.equal(MACOS_HOME_PATH_PATTERN.test(content), false, `${relativePath} still contains a macOS home path.`);
|
|
assert.equal(
|
|
EMBEDDED_LOCAL_TOKEN_PATTERN.test(content),
|
|
false,
|
|
`${relativePath} still contains an embedded LOCAL_API_TOKEN value.`,
|
|
);
|
|
}
|
|
});
|
|
|
|
test("gateway URL can be overridden from env for non-local installations", () => {
|
|
const output = execFileSync(
|
|
process.execPath,
|
|
[
|
|
"--import",
|
|
"tsx",
|
|
"--eval",
|
|
"process.env.GATEWAY_URL='ws://example.invalid:9999'; const mod = require('./src/config.ts'); process.stdout.write(String(mod.GATEWAY_URL));",
|
|
],
|
|
{
|
|
cwd: ROOT,
|
|
encoding: "utf8",
|
|
},
|
|
).trim();
|
|
|
|
assert.equal(output, "ws://example.invalid:9999");
|
|
});
|