Skip to content
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"docs:settings": "tsx ./scripts/generate-settings-doc.ts",
"docs:keybindings": "tsx ./scripts/generate-keybindings-doc.ts",
"eval:inventory": "tsx ./scripts/eval-inventory-cli.ts",
"eval:inventory:json": "tsx ./scripts/eval-inventory-cli.ts --json",
"build": "node scripts/build.js",
"build-and-start": "npm run build && npm run start --",
"build:vscode": "node scripts/build_vscode_companion.js",
Expand Down
31 changes: 24 additions & 7 deletions scripts/eval-inventory-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,40 @@
* @fileoverview CLI entry point for the eval inventory command.
*
* Scans all eval source files, runs the static analyzer on each,
* and prints a human-readable inventory report grouped by policy,
* file, and suite.
* and prints an inventory report grouped by policy, file, and suite.
*
* Usage:
* npm run eval:inventory
* npm run eval:inventory -- --json
* npm run eval:inventory -- --root /path/to/repo
* npm run eval:inventory -- --root /path/to/repo --json
*/

import {
collectInventory,
formatInventoryJson,
formatInventoryReport,
} from './utils/eval-inventory.js';

async function main() {
const rootFlagIndex = process.argv.indexOf('--root');
const repoRoot =
rootFlagIndex !== -1 && process.argv[rootFlagIndex + 1]
? process.argv[rootFlagIndex + 1]
: process.cwd();
const rootFlagValue =
rootFlagIndex !== -1 ? process.argv[rootFlagIndex + 1] : undefined;
if (rootFlagIndex !== -1 && rootFlagValue === undefined) {
console.error(
'Error: --root requires a directory path argument but none was provided.',
);
process.exit(1);
}
if (rootFlagValue && rootFlagValue.startsWith('--')) {
console.error(
`Error: --root value "${rootFlagValue}" looks like a flag. Provide a valid directory path.`,
);
process.exit(1);
}
const repoRoot = rootFlagValue ?? process.cwd();

const jsonMode = process.argv.includes('--json');

const result = await collectInventory(repoRoot);

Expand All @@ -37,7 +52,9 @@ async function main() {
process.exit(1);
}

console.log(formatInventoryReport(result));
console.log(
jsonMode ? formatInventoryJson(result) : formatInventoryReport(result),
);
}

main().catch((error) => {
Expand Down
Loading
Loading