Files
e3edcc8afa feat: v2.3.0 add interactive platform selection to init (#38)
* 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>
2026-07-31 18:54:10 +10:00

86 lines
2.2 KiB
TypeScript

import { describe, it } from "node:test";
import { expect } from "expect";
import { parse } from "yaml";
import {
renderConfig,
updateConfigPlatforms,
} from "../../src/config/render.js";
describe("config rendering", () => {
it("renders the existing host-neutral version-2 defaults", () => {
const text = renderConfig([]);
const config = parse(text) as Record<string, unknown>;
expect(config.version).toBe(2);
expect(config).not.toHaveProperty("platforms");
expect(config.truthmark).toEqual({
workspace: "docs/truthmark",
generated: { portal: { enabled: false } },
});
});
it("renders selected platforms in catalog order", () => {
const config = parse(renderConfig(["cursor", "codex"])) as {
platforms: string[];
};
expect(config.platforms).toEqual(["codex", "cursor"]);
});
it("updates only platforms while preserving comments and supported values", () => {
const source = `# repository config
version: 2
# host ownership
platforms:
- codex
truthmark:
workspace: custom/truth
generated:
portal:
enabled: true
frontmatter:
required:
- status
ignore:
- output/**
`;
const updated = updateConfigPlatforms(source, ["cursor"]);
const config = parse(updated) as {
platforms: string[];
truthmark: { workspace: string };
ignore: string[];
};
expect(updated).toContain("# repository config");
expect(updated).toContain("# host ownership");
expect(config.platforms).toEqual(["cursor"]);
expect(config.truthmark.workspace).toBe("custom/truth");
expect(config.ignore).toEqual(["output/**"]);
});
it("removes the platforms key for host-neutral selection", () => {
const source = renderConfig(["codex"]);
const config = parse(updateConfigPlatforms(source, [])) as Record<
string,
unknown
>;
expect(config).not.toHaveProperty("platforms");
});
it("keeps source bytes when normalized selection is unchanged", () => {
const source = `# keep bytes
version: 2
platforms: [codex, cursor]
truthmark:
workspace: docs/truthmark
generated:
portal: { enabled: false }
`;
expect(updateConfigPlatforms(source, ["cursor", "codex"])).toBe(source);
});
});