mirror of
https://github.com/merlinhu1/truthmark.git
synced 2026-08-25 07:53:25 +02:00
* feat: add interactive platform selection to init * chore: remove completed OpenSpec artifacts * chore: remove implemented design note * fix: protect init lifecycle from unsafe config paths * fix: support clearing init platforms from CLI * docs: retire config command from repository rules * docs: align init lifecycle and clear-platform contracts * docs: keep repository guidance current-state focused * docs: limit cleanup to repository-native documents * docs: preserve historical version notes --------- Co-authored-by: MerlinH <merlinh221@gmail.com>
94 lines
2.8 KiB
TypeScript
94 lines
2.8 KiB
TypeScript
import { describe, it } from "node:test";
|
|
import { expect } from "expect";
|
|
|
|
import { runCli } from "../helpers/run-cli.js";
|
|
|
|
const forbiddenCommands = [
|
|
"packet",
|
|
"review",
|
|
"scan",
|
|
"doctor",
|
|
"build",
|
|
"realize",
|
|
];
|
|
|
|
describe("truthmark CLI", () => {
|
|
it("lists init and omits the retired config command in top-level help", async () => {
|
|
const result = await runCli(["--help"]);
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
expect(result.stdout).not.toContain("\n config ");
|
|
expect(result.stdout).toContain("init");
|
|
expect(result.stdout).toContain("uninstall");
|
|
expect(result.stdout).toContain("check");
|
|
expect(result.stdout).toContain("index");
|
|
expect(result.stdout).toContain("impact");
|
|
expect(result.stdout).not.toContain("context");
|
|
|
|
for (const command of forbiddenCommands) {
|
|
expect(result.stdout).not.toContain(command);
|
|
}
|
|
});
|
|
|
|
it("shows init help", async () => {
|
|
const result = await runCli(["init", "--help"]);
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
expect(result.stdout).toContain("Usage: truthmark init");
|
|
expect(result.stdout).toContain("--json");
|
|
expect(result.stdout).toContain("--platform <id>");
|
|
expect(result.stdout).toContain("--clear-platforms");
|
|
});
|
|
|
|
it("rejects the removed config command", async () => {
|
|
const result = await runCli(["config"]);
|
|
|
|
expect(result.exitCode).not.toBe(0);
|
|
expect(result.stderr).toContain("unknown command 'config'");
|
|
});
|
|
|
|
it("shows check help", async () => {
|
|
const result = await runCli(["check", "--help"]);
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
expect(result.stdout).toContain("Usage: truthmark check");
|
|
expect(result.stdout).toContain("--json");
|
|
expect(result.stdout).not.toContain("--workflow");
|
|
});
|
|
|
|
it("shows uninstall help with JSON and execution mode options", async () => {
|
|
const result = await runCli(["uninstall", "--help"]);
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
expect(result.stdout).toContain("Usage: truthmark uninstall");
|
|
expect(result.stdout).toContain("--dry-run");
|
|
expect(result.stdout).toContain("--apply");
|
|
expect(result.stdout).toContain("--json");
|
|
});
|
|
|
|
it("returns valid JSON for check", async () => {
|
|
const result = await runCli(["check", "--json"]);
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
|
|
const payload = JSON.parse(result.stdout) as {
|
|
command: string;
|
|
summary: string;
|
|
diagnostics: unknown[];
|
|
data?: {
|
|
scorecard?: {
|
|
schemaVersion?: string;
|
|
};
|
|
};
|
|
};
|
|
|
|
expect(payload.command).toBe("check");
|
|
expect(typeof payload.summary).toBe("string");
|
|
expect(payload.summary.length).toBeGreaterThan(0);
|
|
expect(Array.isArray(payload.diagnostics)).toBe(true);
|
|
expect(payload.data?.scorecard?.schemaVersion).toBe(
|
|
"truthmark-scorecard/v0",
|
|
);
|
|
});
|
|
});
|