|
1 | | -import { select } from '@inquirer/prompts'; |
2 | 1 | import ora from 'ora'; |
3 | 2 | import path from 'path'; |
4 | 3 | import { Validator } from '../core/validation/validator.js'; |
@@ -29,7 +28,7 @@ interface BulkItemResult { |
29 | 28 |
|
30 | 29 | export class ValidateCommand { |
31 | 30 | async execute(itemName: string | undefined, options: ExecuteOptions = {}): Promise<void> { |
32 | | - const interactive = isInteractive(options.noInteractive); |
| 31 | + const interactive = isInteractive(options); |
33 | 32 |
|
34 | 33 | // Handle bulk flags first |
35 | 34 | if (options.all || options.changes || options.specs) { |
@@ -64,6 +63,7 @@ export class ValidateCommand { |
64 | 63 | } |
65 | 64 |
|
66 | 65 | private async runInteractiveSelector(opts: { strict: boolean; json: boolean; concurrency?: string }): Promise<void> { |
| 66 | + const { select } = await import('@inquirer/prompts'); |
67 | 67 | const choice = await select({ |
68 | 68 | message: 'What would you like to validate?', |
69 | 69 | choices: [ |
@@ -212,6 +212,28 @@ export class ValidateCommand { |
212 | 212 | }); |
213 | 213 | } |
214 | 214 |
|
| 215 | + if (queue.length === 0) { |
| 216 | + spinner?.stop(); |
| 217 | + |
| 218 | + const summary = { |
| 219 | + totals: { items: 0, passed: 0, failed: 0 }, |
| 220 | + byType: { |
| 221 | + ...(scope.changes ? { change: { items: 0, passed: 0, failed: 0 } } : {}), |
| 222 | + ...(scope.specs ? { spec: { items: 0, passed: 0, failed: 0 } } : {}), |
| 223 | + }, |
| 224 | + } as const; |
| 225 | + |
| 226 | + if (opts.json) { |
| 227 | + const out = { items: [] as BulkItemResult[], summary, version: '1.0' }; |
| 228 | + console.log(JSON.stringify(out, null, 2)); |
| 229 | + } else { |
| 230 | + console.log('No items found to validate.'); |
| 231 | + } |
| 232 | + |
| 233 | + process.exitCode = 0; |
| 234 | + return; |
| 235 | + } |
| 236 | + |
215 | 237 | const results: BulkItemResult[] = []; |
216 | 238 | let index = 0; |
217 | 239 | let running = 0; |
@@ -301,5 +323,3 @@ function getPlannedType(index: number, changeIds: string[], specIds: string[]): |
301 | 323 | if (specIndex >= 0 && specIndex < specIds.length) return 'spec'; |
302 | 324 | return undefined; |
303 | 325 | } |
304 | | - |
305 | | - |
|
0 commit comments