|
1 | 1 | import fs from 'node:fs'; |
2 | 2 | import path from 'node:path'; |
| 3 | +import { PUBLIC_COMMANDS } from '../src/command-catalog.ts'; |
| 4 | +import { listCommandMetadata } from '../src/commands/command-metadata.ts'; |
3 | 5 |
|
4 | 6 | const EMPTY_COVERAGE_METRIC = { pct: 0 }; |
5 | 7 | const EMPTY_STATEMENT_COVERAGE = { covered: 0, pct: 0, total: 0 }; |
6 | 8 |
|
7 | 9 | let ROOT = process.cwd(); |
8 | 10 | let COVERAGE_SUMMARY = path.join(ROOT, 'coverage/coverage-summary.json'); |
9 | | -let COMMAND_CATALOG_SOURCE = ''; |
10 | 11 | let clientCommandMethods = new Map(); |
11 | 12 |
|
12 | 13 | export function buildIntegrationProgressModel({ root = process.cwd() } = {}) { |
13 | 14 | ROOT = root; |
14 | 15 | COVERAGE_SUMMARY = path.join(ROOT, 'coverage/coverage-summary.json'); |
15 | 16 | const handlerTestDir = path.join(ROOT, 'src/daemon/handlers/__tests__'); |
16 | 17 | const providerScenarioDir = path.join(ROOT, 'test/integration/provider-scenarios'); |
17 | | - const commandCatalog = path.join(ROOT, 'src/command-catalog.ts'); |
18 | 18 | const commandContractFiles = listFiles(path.join(ROOT, 'src/commands'), (file) => |
19 | 19 | file.endsWith(`${path.sep}index.ts`), |
20 | 20 | ); |
21 | | - COMMAND_CATALOG_SOURCE = fs.readFileSync(commandCatalog, 'utf8'); |
22 | 21 | clientCommandMethods = readClientCommandMethods(commandContractFiles); |
23 | 22 |
|
24 | 23 | const handlerTests = listFiles(handlerTestDir, (file) => file.endsWith('.test.ts')); |
@@ -417,19 +416,15 @@ function summarizePublicCommandCoverage(files) { |
417 | 416 | } |
418 | 417 |
|
419 | 418 | function readPublicCommands() { |
420 | | - return [...readPublicCommandEntries().values()].sort(); |
421 | | -} |
422 | | - |
423 | | -function readPublicCommandEntries() { |
424 | | - const match = COMMAND_CATALOG_SOURCE.match(/export const PUBLIC_COMMANDS = \{([\s\S]*?)\} as const;/); |
425 | | - if (!match) { |
426 | | - throw new Error('Unable to find PUBLIC_COMMANDS in src/command-catalog.ts'); |
427 | | - } |
428 | | - const commands = new Map(); |
429 | | - for (const command of match[1].matchAll(/\b([A-Za-z0-9_]+):\s*'([^']+)'/g)) { |
430 | | - commands.set(command[1], command[2]); |
431 | | - } |
432 | | - return commands; |
| 419 | + const metadataNames = new Set(listCommandMetadata().map((metadata) => metadata.name)); |
| 420 | + return Object.values(PUBLIC_COMMANDS) |
| 421 | + .map((name) => { |
| 422 | + if (!metadataNames.has(name)) { |
| 423 | + throw new Error(`Missing command metadata for public command: ${name}`); |
| 424 | + } |
| 425 | + return name; |
| 426 | + }) |
| 427 | + .sort(); |
433 | 428 | } |
434 | 429 |
|
435 | 430 | function readClientCommandMethods(commandContractFiles) { |
|
0 commit comments