Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,14 +667,19 @@ export function createProgram(BUILTIN_CLIS: string, USER_CLIS: string, pluginsDi

// ── Built-in: validate / verify ───────────────────────────────────────────

program
const validateCmd = program
.command('validate')
.description('Validate CLI definitions')
.argument('[target]', 'site or site/name')
.action(async (target) => {
const { validateClisWithTarget, renderValidationReport } = await import('./validate.js');
console.log(renderValidationReport(validateClisWithTarget([BUILTIN_CLIS, USER_CLIS], target)));
});
.option('-f, --format <fmt>', OUTPUT_FORMAT_HELP, 'table');
validateCmd.action(async (target, opts) => {
const fmt = resolveOutputFormat(opts.format);
if (fmt === null) return;
const { validateClisWithTarget, renderValidationReport } = await import('./validate.js');
const report = validateClisWithTarget([BUILTIN_CLIS, USER_CLIS], target);
if (fmt === 'table') console.log(renderValidationReport(report));
else renderOutput(report, { fmt });
});

program
.command('verify')
Expand Down
23 changes: 23 additions & 0 deletions tests/e2e/management.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,29 @@ describe('management commands E2E', () => {
expect(stdout).toContain('PASS');
});

it('validate -f json produces a structured report', async () => {
const { stdout, code } = await runManagementCli(['validate', '-f', 'json']);
expect(code).toBe(0);
const data = parseJsonOutput(stdout);
expect(data).toMatchObject({ ok: true, errors: 0 });
expect(Array.isArray(data.results)).toBe(true);
expect(typeof data.commands).toBe('number');
});

it('validate -f yaml produces a structured report', async () => {
const { stdout, code } = await runManagementCli(['validate', '-f', 'yaml']);
expect(code).toBe(0);
expect(stdout).toContain('ok: true');
expect(stdout).toContain('results:');
});

it('validate without -f still prints the human-readable report', async () => {
const { stdout, code } = await runManagementCli(['validate']);
expect(code).toBe(0);
expect(stdout).toContain(`validate: PASS`);
expect(stdout).toContain('Checked');
});

// ── verify ──
it('verify runs validation without smoke tests', async () => {
const { stdout, code } = await runManagementCli(['verify']);
Expand Down