@dataparade/cli 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +1 -1
- package/dist/src/ai-enrichment/providers/platform-proxy-provider.js +6 -1
- package/dist/src/cli/scan-interrupt-handlers.d.ts +34 -0
- package/dist/src/cli/scan-interrupt-handlers.js +105 -0
- package/dist/src/cli.js +99 -28
- package/dist/src/config/scan-env.d.ts +5 -2
- package/dist/src/config/scan-env.js +8 -2
- package/dist/src/platform-api/scan-quota-client.d.ts +3 -1
- package/dist/src/platform-api/scan-quota-client.js +41 -28
- package/dist/src/ui/scan-progress-renderer.d.ts +24 -0
- package/dist/src/ui/scan-progress-renderer.js +91 -0
- package/dist/src/ui/types.d.ts +5 -0
- package/dist/tests/unit/ai-enrichment/platform-proxy-provider.spec.js +26 -0
- package/dist/tests/unit/cli/scan-interrupt-handlers.spec.d.ts +1 -0
- package/dist/tests/unit/cli/scan-interrupt-handlers.spec.js +154 -0
- package/dist/tests/unit/cli/scan-quota-flow.spec.js +2 -2
- package/dist/tests/unit/platform-api/read-cli-api-error-message.spec.js +2 -2
- package/dist/tests/unit/ui/scan-progress-renderer.spec.js +134 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PlatformProxyProvider = void 0;
|
|
4
4
|
const lambda_init_error_1 = require("../lambda-init-error");
|
|
5
5
|
const fetch_failure_1 = require("../../platform-api/fetch-failure");
|
|
6
|
+
const scan_env_1 = require("../../config/scan-env");
|
|
6
7
|
const DEFAULT_NETWORK_RETRY_DELAYS_MS = [1000, 2000];
|
|
7
8
|
function resolvePollTimeoutMs(configured) {
|
|
8
9
|
if (typeof configured === 'number' &&
|
|
@@ -95,7 +96,11 @@ class PlatformProxyProvider {
|
|
|
95
96
|
if (attempt >= delays.length || !(0, fetch_failure_1.isTransientFetchError)(err)) {
|
|
96
97
|
throw (0, fetch_failure_1.toApiReachabilityError)(err, url, method, attempt + 1);
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
+
// The Clack UI owns the terminal; a final failure still surfaces
|
|
100
|
+
// through the scan error ("Tried N times").
|
|
101
|
+
if (!(0, scan_env_1.isScanAiDebugSuppressed)()) {
|
|
102
|
+
console.warn(`[dataparade-ai] ${(0, fetch_failure_1.describeRequestTarget)(url, method)} failed (${(0, fetch_failure_1.fetchFailureDetail)(err)}). Retrying (${attempt + 1}/${delays.length}).`);
|
|
103
|
+
}
|
|
99
104
|
await this.wait(delays[attempt] ?? 0);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type CliScanQuotaCompletionStatus = 'none' | 'in_flight' | 'done';
|
|
2
|
+
export type CliScanInterruptSignal = 'SIGINT' | 'SIGTERM' | 'SIGHUP';
|
|
3
|
+
export declare const CLI_SCAN_INTERRUPT_EXIT_CODES: Record<CliScanInterruptSignal, number>;
|
|
4
|
+
/** Cap how long Ctrl+C waits on a hung complete API before exiting. */
|
|
5
|
+
export declare const CLI_SCAN_INTERRUPT_COMPLETE_TIMEOUT_MS = 2500;
|
|
6
|
+
export type CliScanInterruptProcess = {
|
|
7
|
+
on(event: string, listener: (...args: unknown[]) => void): CliScanInterruptProcess | unknown;
|
|
8
|
+
off?(event: string, listener: (...args: unknown[]) => void): CliScanInterruptProcess | unknown;
|
|
9
|
+
removeListener?(event: string, listener: (...args: unknown[]) => void): CliScanInterruptProcess | unknown;
|
|
10
|
+
};
|
|
11
|
+
export type InstallCliScanInterruptHandlersInput = {
|
|
12
|
+
proc: CliScanInterruptProcess;
|
|
13
|
+
exit: (code: number) => void;
|
|
14
|
+
getState: () => {
|
|
15
|
+
apiKey?: string;
|
|
16
|
+
jobId?: string;
|
|
17
|
+
completionStatus: CliScanQuotaCompletionStatus;
|
|
18
|
+
/** Pending normal-path complete, awaited (bounded) instead of duplicated. */
|
|
19
|
+
inFlight?: Promise<unknown>;
|
|
20
|
+
};
|
|
21
|
+
/** Claim the completion so the scan's own paths don't report it again. */
|
|
22
|
+
setCompletionStatus: (status: CliScanQuotaCompletionStatus) => void;
|
|
23
|
+
onAbortUi: () => void;
|
|
24
|
+
reportFailed: (input: {
|
|
25
|
+
apiKey: string;
|
|
26
|
+
jobId: string;
|
|
27
|
+
timeoutMs: number;
|
|
28
|
+
}) => Promise<void>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Release the CLI scan lock on Ctrl+C / kill / hangup, then exit.
|
|
32
|
+
* Returns uninstall(); safe to call more than once.
|
|
33
|
+
*/
|
|
34
|
+
export declare function installCliScanInterruptHandlers(input: InstallCliScanInterruptHandlersInput): () => void;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLI_SCAN_INTERRUPT_COMPLETE_TIMEOUT_MS = exports.CLI_SCAN_INTERRUPT_EXIT_CODES = void 0;
|
|
4
|
+
exports.installCliScanInterruptHandlers = installCliScanInterruptHandlers;
|
|
5
|
+
exports.CLI_SCAN_INTERRUPT_EXIT_CODES = {
|
|
6
|
+
SIGINT: 130,
|
|
7
|
+
SIGTERM: 143,
|
|
8
|
+
SIGHUP: 129,
|
|
9
|
+
};
|
|
10
|
+
/** Cap how long Ctrl+C waits on a hung complete API before exiting. */
|
|
11
|
+
exports.CLI_SCAN_INTERRUPT_COMPLETE_TIMEOUT_MS = 2_500;
|
|
12
|
+
const SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
13
|
+
/** Below this, a follow-up report can't realistically land before exit. */
|
|
14
|
+
const MIN_REPORT_WINDOW_MS = 250;
|
|
15
|
+
/** Resolve when `promise` settles or `ms` elapses, whichever comes first. */
|
|
16
|
+
async function settleWithin(promise, ms) {
|
|
17
|
+
let timer;
|
|
18
|
+
try {
|
|
19
|
+
await Promise.race([
|
|
20
|
+
promise.then(() => undefined, () => undefined),
|
|
21
|
+
new Promise((resolve) => {
|
|
22
|
+
timer = setTimeout(resolve, ms);
|
|
23
|
+
}),
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
if (timer)
|
|
28
|
+
clearTimeout(timer);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Release the CLI scan lock on Ctrl+C / kill / hangup, then exit.
|
|
33
|
+
* Returns uninstall(); safe to call more than once.
|
|
34
|
+
*/
|
|
35
|
+
function installCliScanInterruptHandlers(input) {
|
|
36
|
+
let handling = false;
|
|
37
|
+
let uninstalled = false;
|
|
38
|
+
const remove = (event, listener) => {
|
|
39
|
+
if (typeof input.proc.off === 'function') {
|
|
40
|
+
input.proc.off(event, listener);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (typeof input.proc.removeListener === 'function') {
|
|
44
|
+
input.proc.removeListener(event, listener);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const onSignal = (signal) => {
|
|
48
|
+
const code = exports.CLI_SCAN_INTERRUPT_EXIT_CODES[signal];
|
|
49
|
+
if (handling) {
|
|
50
|
+
input.exit(code);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
handling = true;
|
|
54
|
+
void (async () => {
|
|
55
|
+
const deadline = Date.now() + exports.CLI_SCAN_INTERRUPT_COMPLETE_TIMEOUT_MS;
|
|
56
|
+
try {
|
|
57
|
+
input.onAbortUi();
|
|
58
|
+
const pending = input.getState();
|
|
59
|
+
if (pending.completionStatus === 'in_flight' && pending.inFlight) {
|
|
60
|
+
// Let the scan's own complete land; exiting now could cut it off.
|
|
61
|
+
await settleWithin(pending.inFlight, deadline - Date.now());
|
|
62
|
+
}
|
|
63
|
+
// Re-read: a failed in-flight complete resets the status to 'none'.
|
|
64
|
+
const state = input.getState();
|
|
65
|
+
const remainingMs = deadline - Date.now();
|
|
66
|
+
if (state.apiKey &&
|
|
67
|
+
state.jobId &&
|
|
68
|
+
state.completionStatus === 'none' &&
|
|
69
|
+
remainingMs >= MIN_REPORT_WINDOW_MS) {
|
|
70
|
+
input.setCompletionStatus('in_flight');
|
|
71
|
+
try {
|
|
72
|
+
await input.reportFailed({
|
|
73
|
+
apiKey: state.apiKey,
|
|
74
|
+
jobId: state.jobId,
|
|
75
|
+
timeoutMs: remainingMs,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Lock release must not block exit.
|
|
80
|
+
}
|
|
81
|
+
// Exiting either way; keep the scan's finally from reporting again.
|
|
82
|
+
input.setCompletionStatus('done');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
input.exit(code);
|
|
87
|
+
}
|
|
88
|
+
})();
|
|
89
|
+
};
|
|
90
|
+
const listeners = SIGNALS.map((signal) => {
|
|
91
|
+
const listener = () => {
|
|
92
|
+
onSignal(signal);
|
|
93
|
+
};
|
|
94
|
+
input.proc.on(signal, listener);
|
|
95
|
+
return { signal, listener };
|
|
96
|
+
});
|
|
97
|
+
return () => {
|
|
98
|
+
if (uninstalled)
|
|
99
|
+
return;
|
|
100
|
+
uninstalled = true;
|
|
101
|
+
for (const { signal, listener } of listeners) {
|
|
102
|
+
remove(signal, listener);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
package/dist/src/cli.js
CHANGED
|
@@ -64,6 +64,7 @@ const telemetry_client_1 = require("./platform-api/telemetry-client");
|
|
|
64
64
|
const cli_scan_failure_report_1 = require("./platform-api/cli-scan-failure-report");
|
|
65
65
|
const scan_config_schema_1 = require("./core/schema/scan-config.schema");
|
|
66
66
|
const scanner_1 = require("../vendor/scanner/dist/src/index.js");
|
|
67
|
+
const scan_interrupt_handlers_1 = require("./cli/scan-interrupt-handlers");
|
|
67
68
|
const scan_progress_renderer_1 = require("./ui/scan-progress-renderer");
|
|
68
69
|
/** The scanner is vendored into the CLI; its version is the commit the CLI depends on. */
|
|
69
70
|
function scannerVersionFromPackage() {
|
|
@@ -191,7 +192,9 @@ function createProgram() {
|
|
|
191
192
|
.action(async (path, options) => {
|
|
192
193
|
let cliQuotaJobId;
|
|
193
194
|
let platformQuotaApiKey;
|
|
194
|
-
let
|
|
195
|
+
let progressUi;
|
|
196
|
+
let quotaCompletionStatus = 'none';
|
|
197
|
+
let quotaCompletionInFlight;
|
|
195
198
|
let fallbackFailureMessage = 'CLI scan did not complete successfully';
|
|
196
199
|
let reportedFailure;
|
|
197
200
|
let sentryScanRoot;
|
|
@@ -201,6 +204,15 @@ function createProgram() {
|
|
|
201
204
|
// True once Clack owns the terminal: raw `[scan]` lines would break its
|
|
202
205
|
// guide rail, so they go through the renderer or are skipped.
|
|
203
206
|
let friendlyTty = false;
|
|
207
|
+
// Errors close the Clack UI as a plain sentence; logs (CI, non-TTY)
|
|
208
|
+
// keep the `[scan] …:` prefix so they stay greppable.
|
|
209
|
+
const reportScanError = (logLine, friendlyText) => {
|
|
210
|
+
if (friendlyTty && progressUi) {
|
|
211
|
+
progressUi.fail(friendlyText);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
console.error(logLine);
|
|
215
|
+
};
|
|
204
216
|
// Parse and validate --git-context if provided
|
|
205
217
|
let parsedGitContext;
|
|
206
218
|
if (options.gitContext) {
|
|
@@ -236,6 +248,35 @@ function createProgram() {
|
|
|
236
248
|
apiKey: workspaceApiKey,
|
|
237
249
|
cliVersion: package_json_1.default.version,
|
|
238
250
|
});
|
|
251
|
+
const uninstallInterruptHandlers = (0, scan_interrupt_handlers_1.installCliScanInterruptHandlers)({
|
|
252
|
+
proc: process,
|
|
253
|
+
exit: (code) => {
|
|
254
|
+
process.exit(code);
|
|
255
|
+
},
|
|
256
|
+
getState: () => ({
|
|
257
|
+
apiKey: platformQuotaApiKey,
|
|
258
|
+
jobId: cliQuotaJobId,
|
|
259
|
+
completionStatus: quotaCompletionStatus,
|
|
260
|
+
inFlight: quotaCompletionInFlight,
|
|
261
|
+
}),
|
|
262
|
+
setCompletionStatus: (status) => {
|
|
263
|
+
quotaCompletionStatus = status;
|
|
264
|
+
},
|
|
265
|
+
onAbortUi: () => {
|
|
266
|
+
progressUi?.abort('Scan cancelled');
|
|
267
|
+
},
|
|
268
|
+
reportFailed: async ({ apiKey, jobId, timeoutMs }) => {
|
|
269
|
+
const { cliScanComplete } = await Promise.resolve().then(() => __importStar(require('./platform-api/scan-quota-client')));
|
|
270
|
+
await cliScanComplete({
|
|
271
|
+
apiKey,
|
|
272
|
+
jobId,
|
|
273
|
+
status: 'failed',
|
|
274
|
+
failureCode: 'scan_interrupted',
|
|
275
|
+
failureMessage: 'You stopped this scan',
|
|
276
|
+
timeoutMs,
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
});
|
|
239
280
|
try {
|
|
240
281
|
const rootPathArg = path || '.';
|
|
241
282
|
// Load dataparade.config.json from the directory being scanned, not
|
|
@@ -268,15 +309,16 @@ function createProgram() {
|
|
|
268
309
|
Promise.resolve().then(() => __importStar(require('./core/pipeline/scan-pipeline'))),
|
|
269
310
|
Promise.resolve().then(() => __importStar(require('./core/pipeline/graph-mapping'))),
|
|
270
311
|
]);
|
|
271
|
-
const
|
|
312
|
+
const ui = await (0, scan_progress_renderer_1.createScanProgressRenderer)({
|
|
272
313
|
isTTY: Boolean(isInteractive),
|
|
273
314
|
noColor: Boolean(typeof process.env.NO_COLOR === 'string' &&
|
|
274
315
|
process.env.NO_COLOR.length > 0),
|
|
275
316
|
projectLabel: resolvedScanRoot,
|
|
276
317
|
version: package_json_1.default.version,
|
|
277
318
|
});
|
|
278
|
-
progressUi
|
|
279
|
-
|
|
319
|
+
progressUi = ui;
|
|
320
|
+
ui.start();
|
|
321
|
+
friendlyTty = ui.usesClackChrome;
|
|
280
322
|
(0, scan_env_1.setScanAiDebugSuppressed)(friendlyTty && !options.aiVerbose);
|
|
281
323
|
// Technical meters, shown as one block after the scan (TTY) or
|
|
282
324
|
// printed as before (non-TTY).
|
|
@@ -348,7 +390,7 @@ function createProgram() {
|
|
|
348
390
|
config.cliQuotaJobId = undefined;
|
|
349
391
|
config.anonSessionToken = undefined;
|
|
350
392
|
sentryAiMode = 'none';
|
|
351
|
-
|
|
393
|
+
ui.warn(`AI enrichment unavailable (${(0, fetch_failure_1.describeUnavailableReason)(setupError)}); continuing with a structural scan. Use --no-ai-inference to skip this step.`);
|
|
352
394
|
};
|
|
353
395
|
// Quota preflight for platform billing. Structural-only scans (AI off) do not use quota API.
|
|
354
396
|
if (workspaceApiKey && !usesByok && config.enableAiInference) {
|
|
@@ -449,14 +491,17 @@ function createProgram() {
|
|
|
449
491
|
failurePhase: 'config_validation',
|
|
450
492
|
failureCode: 'invalid_configuration',
|
|
451
493
|
});
|
|
452
|
-
|
|
494
|
+
const configErrors = configValidation.errors
|
|
495
|
+
.map((e) => ` - ${e}`)
|
|
496
|
+
.join('\n');
|
|
497
|
+
reportScanError(`[scan] invalid configuration:\n${configErrors}`, `Invalid configuration:\n${configErrors}`);
|
|
453
498
|
process.exitCode = 2;
|
|
454
499
|
return;
|
|
455
500
|
}
|
|
456
501
|
if (isInteractive && warnings.length > 0) {
|
|
457
502
|
if (friendlyTty) {
|
|
458
503
|
for (const w of warnings)
|
|
459
|
-
|
|
504
|
+
ui.warn(w);
|
|
460
505
|
}
|
|
461
506
|
else {
|
|
462
507
|
console.warn(`[scan] warnings:\n${warnings.map((w) => ` - ${w}`).join('\n')}`);
|
|
@@ -470,13 +515,13 @@ function createProgram() {
|
|
|
470
515
|
progressUi.warn(tree.warning);
|
|
471
516
|
}
|
|
472
517
|
const orchestratorResult = await runScanPipeline(resolvedScanRoot, config, (progress) => {
|
|
473
|
-
|
|
518
|
+
ui.onProgress(progress);
|
|
474
519
|
}, (recognition) => {
|
|
475
|
-
|
|
520
|
+
ui.onRecognition(recognition);
|
|
476
521
|
});
|
|
477
522
|
const { scanResult, redFlags } = orchestratorResult;
|
|
478
523
|
if (scanResult.aiInferenceSummary) {
|
|
479
|
-
|
|
524
|
+
ui.onAiResult({
|
|
480
525
|
proposalsApplied: scanResult.aiInferenceSummary.proposalsApplied,
|
|
481
526
|
});
|
|
482
527
|
}
|
|
@@ -504,7 +549,7 @@ function createProgram() {
|
|
|
504
549
|
}
|
|
505
550
|
// Friendly TTY only shows the block on request (--ai-verbose).
|
|
506
551
|
if (!friendlyTty || options.aiVerbose) {
|
|
507
|
-
|
|
552
|
+
ui.showTechnicalDetails('Scan details', technicalLines);
|
|
508
553
|
}
|
|
509
554
|
for (const w of scanResult.warnings ?? []) {
|
|
510
555
|
if (w.startsWith('ai-provider:')) {
|
|
@@ -517,10 +562,10 @@ function createProgram() {
|
|
|
517
562
|
failurePhase: 'ai_provider',
|
|
518
563
|
failureCode: 'ai_provider_warning',
|
|
519
564
|
});
|
|
520
|
-
|
|
565
|
+
ui.warn(w);
|
|
521
566
|
}
|
|
522
567
|
else if (w.startsWith('red-flag:')) {
|
|
523
|
-
|
|
568
|
+
ui.warn(w);
|
|
524
569
|
}
|
|
525
570
|
}
|
|
526
571
|
if (scanResult.errors?.length) {
|
|
@@ -564,7 +609,7 @@ function createProgram() {
|
|
|
564
609
|
const message = graphError instanceof Error
|
|
565
610
|
? graphError.message
|
|
566
611
|
: 'Unknown error while building diagram graph.';
|
|
567
|
-
|
|
612
|
+
reportScanError(`[scan] warning: unable to build diagram graph: ${message}`, `Could not build the diagram: ${message}`);
|
|
568
613
|
}
|
|
569
614
|
process.exitCode = 1;
|
|
570
615
|
}
|
|
@@ -593,7 +638,7 @@ function createProgram() {
|
|
|
593
638
|
scannerVersion: scannerVersionFromPackage(),
|
|
594
639
|
});
|
|
595
640
|
// Friendly TTY/plain progress line (additive).
|
|
596
|
-
|
|
641
|
+
ui.onWroteDataflow(dataflowOutputPath);
|
|
597
642
|
// Machine line for scripts / CI (non-TTY). The friendly TTY UI
|
|
598
643
|
// shows the path in its own success line instead.
|
|
599
644
|
if (!friendlyTty) {
|
|
@@ -624,7 +669,7 @@ function createProgram() {
|
|
|
624
669
|
quiet: friendlyTty,
|
|
625
670
|
});
|
|
626
671
|
if (uploadResult.previewUrl) {
|
|
627
|
-
|
|
672
|
+
ui.onPreviewUrl(uploadResult.previewUrl, uploadResult.notice);
|
|
628
673
|
}
|
|
629
674
|
}
|
|
630
675
|
catch (uploadError) {
|
|
@@ -632,7 +677,7 @@ function createProgram() {
|
|
|
632
677
|
? uploadError.message
|
|
633
678
|
: 'Unknown upload error.';
|
|
634
679
|
if (friendlyTty) {
|
|
635
|
-
|
|
680
|
+
ui.warn(`Auto-upload failed: ${uploadMessage}`);
|
|
636
681
|
}
|
|
637
682
|
else {
|
|
638
683
|
console.error(`[scan] Auto-upload failed: ${uploadMessage}`);
|
|
@@ -642,7 +687,7 @@ function createProgram() {
|
|
|
642
687
|
progressUi.onUploadFailed(describeAutoUploadFailure(uploadError, dataflowOutputPath, Boolean(workspaceApiKey)));
|
|
643
688
|
}
|
|
644
689
|
}
|
|
645
|
-
|
|
690
|
+
ui.finish();
|
|
646
691
|
}
|
|
647
692
|
catch (dataflowError) {
|
|
648
693
|
reportedFailure = {
|
|
@@ -663,15 +708,18 @@ function createProgram() {
|
|
|
663
708
|
const message = dataflowError instanceof Error
|
|
664
709
|
? dataflowError.message
|
|
665
710
|
: 'Unknown error while writing dataflow.json.';
|
|
666
|
-
|
|
711
|
+
reportScanError(`[scan] error: failed to write dataflow.json: ${message}`, `Could not save dataflow.json: ${message}`);
|
|
667
712
|
process.exitCode = 1;
|
|
668
713
|
}
|
|
669
714
|
}
|
|
670
|
-
if (platformQuotaApiKey &&
|
|
715
|
+
if (platformQuotaApiKey &&
|
|
716
|
+
cliQuotaJobId &&
|
|
717
|
+
quotaCompletionStatus === 'none') {
|
|
671
718
|
const { cliScanComplete } = await Promise.resolve().then(() => __importStar(require('./platform-api/scan-quota-client')));
|
|
672
719
|
const exitFailed = (process.exitCode ?? 0) !== 0;
|
|
673
720
|
const platformAiMode = (0, validate_scan_ai_1.resolveAiMode)(config) === 'platform';
|
|
674
|
-
|
|
721
|
+
quotaCompletionStatus = 'in_flight';
|
|
722
|
+
quotaCompletionInFlight = cliScanComplete({
|
|
675
723
|
apiKey: platformQuotaApiKey,
|
|
676
724
|
jobId: cliQuotaJobId,
|
|
677
725
|
status: exitFailed ? 'failed' : 'completed',
|
|
@@ -685,7 +733,18 @@ function createProgram() {
|
|
|
685
733
|
? (reportedFailure?.message ?? fallbackFailureMessage)
|
|
686
734
|
: undefined,
|
|
687
735
|
});
|
|
688
|
-
|
|
736
|
+
try {
|
|
737
|
+
await quotaCompletionInFlight;
|
|
738
|
+
quotaCompletionStatus = 'done';
|
|
739
|
+
}
|
|
740
|
+
catch (completeError) {
|
|
741
|
+
// Not reported: let the finally (or an interrupt) retry as failed.
|
|
742
|
+
quotaCompletionStatus = 'none';
|
|
743
|
+
throw completeError;
|
|
744
|
+
}
|
|
745
|
+
finally {
|
|
746
|
+
quotaCompletionInFlight = undefined;
|
|
747
|
+
}
|
|
689
748
|
// The Clack outro already closes the run in friendly TTY.
|
|
690
749
|
if (isInteractive && !friendlyTty) {
|
|
691
750
|
console.log('[scan] Scan finished — you can start a new scan now.');
|
|
@@ -719,11 +778,13 @@ function createProgram() {
|
|
|
719
778
|
? 'scan_already_running'
|
|
720
779
|
: 'scan_exception',
|
|
721
780
|
});
|
|
722
|
-
|
|
781
|
+
// Clack: the error closes the live spinner. A raw line would land
|
|
782
|
+
// mid-spinner and Clack would add its own "Canceled" on exit.
|
|
783
|
+
reportScanError(quotaBlocked
|
|
723
784
|
? `[scan] workspace quota: ${message}`
|
|
724
785
|
: scanInProgress
|
|
725
786
|
? `[scan] scan in progress: ${message}`
|
|
726
|
-
: `Scan failed: ${message}`);
|
|
787
|
+
: `Scan failed: ${message}`, quotaBlocked || scanInProgress ? message : `Scan failed: ${message}`);
|
|
727
788
|
process.exitCode = 1;
|
|
728
789
|
}
|
|
729
790
|
finally {
|
|
@@ -744,25 +805,35 @@ function createProgram() {
|
|
|
744
805
|
});
|
|
745
806
|
if (platformQuotaApiKey &&
|
|
746
807
|
cliQuotaJobId &&
|
|
747
|
-
|
|
808
|
+
quotaCompletionStatus === 'none') {
|
|
748
809
|
try {
|
|
749
810
|
const { cliScanComplete } = await Promise.resolve().then(() => __importStar(require('./platform-api/scan-quota-client')));
|
|
750
|
-
|
|
811
|
+
quotaCompletionStatus = 'in_flight';
|
|
812
|
+
quotaCompletionInFlight = cliScanComplete({
|
|
751
813
|
apiKey: platformQuotaApiKey,
|
|
752
814
|
jobId: cliQuotaJobId,
|
|
753
815
|
status: 'failed',
|
|
754
816
|
failureCode: reportedFailure?.code ?? 'scan_failed',
|
|
755
817
|
failureMessage: reportedFailure?.message ?? fallbackFailureMessage,
|
|
756
818
|
});
|
|
757
|
-
|
|
758
|
-
|
|
819
|
+
await quotaCompletionInFlight;
|
|
820
|
+
quotaCompletionStatus = 'done';
|
|
821
|
+
// Clack already closed the run with the error line.
|
|
822
|
+
if (isInteractive && !friendlyTty) {
|
|
759
823
|
console.log('[scan] Scan finished — you can start a new scan now.');
|
|
760
824
|
}
|
|
761
825
|
}
|
|
762
826
|
catch {
|
|
763
827
|
// Quota report failure must not mask the original scan error.
|
|
828
|
+
quotaCompletionStatus = 'none';
|
|
829
|
+
}
|
|
830
|
+
finally {
|
|
831
|
+
quotaCompletionInFlight = undefined;
|
|
764
832
|
}
|
|
765
833
|
}
|
|
834
|
+
// Last: Ctrl+C during the usage event or complete above must still
|
|
835
|
+
// release the lock.
|
|
836
|
+
uninstallInterruptHandlers();
|
|
766
837
|
}
|
|
767
838
|
});
|
|
768
839
|
program
|
|
@@ -5,9 +5,12 @@ export declare function resolveByokModel(env: NodeJS.ProcessEnv): string | undef
|
|
|
5
5
|
export declare function resolveScanAiInference(env: NodeJS.ProcessEnv): string | undefined;
|
|
6
6
|
export declare function resolveHostedInferProxyUrl(env: NodeJS.ProcessEnv): string | undefined;
|
|
7
7
|
/**
|
|
8
|
-
* Mute SCAN_AI_DEBUG logs
|
|
9
|
-
* raw `[dataparade-ai]` lines
|
|
8
|
+
* Mute SCAN_AI_DEBUG logs and transient AI notices (e.g. network retries) for
|
|
9
|
+
* this run. The interactive progress UI sets this: raw `[dataparade-ai]` lines
|
|
10
|
+
* written mid-spinner break its layout.
|
|
10
11
|
*/
|
|
11
12
|
export declare function setScanAiDebugSuppressed(suppressed: boolean): void;
|
|
13
|
+
/** True while the interactive UI owns the terminal (see setScanAiDebugSuppressed). */
|
|
14
|
+
export declare function isScanAiDebugSuppressed(): boolean;
|
|
12
15
|
/** Extra provider HTTP / normalization logging (all providers, not OpenAI-only). */
|
|
13
16
|
export declare function isScanAiDebugEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
@@ -7,6 +7,7 @@ exports.resolveByokModel = resolveByokModel;
|
|
|
7
7
|
exports.resolveScanAiInference = resolveScanAiInference;
|
|
8
8
|
exports.resolveHostedInferProxyUrl = resolveHostedInferProxyUrl;
|
|
9
9
|
exports.setScanAiDebugSuppressed = setScanAiDebugSuppressed;
|
|
10
|
+
exports.isScanAiDebugSuppressed = isScanAiDebugSuppressed;
|
|
10
11
|
exports.isScanAiDebugEnabled = isScanAiDebugEnabled;
|
|
11
12
|
function resolveWorkspaceApiKey(env) {
|
|
12
13
|
const value = env.DATAPARADE_WORKSPACE_API_KEY?.trim();
|
|
@@ -40,12 +41,17 @@ function parseTruthyEnvFlag(value) {
|
|
|
40
41
|
}
|
|
41
42
|
let scanAiDebugSuppressed = false;
|
|
42
43
|
/**
|
|
43
|
-
* Mute SCAN_AI_DEBUG logs
|
|
44
|
-
* raw `[dataparade-ai]` lines
|
|
44
|
+
* Mute SCAN_AI_DEBUG logs and transient AI notices (e.g. network retries) for
|
|
45
|
+
* this run. The interactive progress UI sets this: raw `[dataparade-ai]` lines
|
|
46
|
+
* written mid-spinner break its layout.
|
|
45
47
|
*/
|
|
46
48
|
function setScanAiDebugSuppressed(suppressed) {
|
|
47
49
|
scanAiDebugSuppressed = suppressed;
|
|
48
50
|
}
|
|
51
|
+
/** True while the interactive UI owns the terminal (see setScanAiDebugSuppressed). */
|
|
52
|
+
function isScanAiDebugSuppressed() {
|
|
53
|
+
return scanAiDebugSuppressed;
|
|
54
|
+
}
|
|
49
55
|
/** Extra provider HTTP / normalization logging (all providers, not OpenAI-only). */
|
|
50
56
|
function isScanAiDebugEnabled(env = process.env) {
|
|
51
57
|
if (scanAiDebugSuppressed)
|
|
@@ -26,8 +26,10 @@ export declare function cliScanPreflight(input: {
|
|
|
26
26
|
export declare function cliScanComplete(input: {
|
|
27
27
|
apiKey: string;
|
|
28
28
|
jobId: string;
|
|
29
|
-
status:
|
|
29
|
+
status: 'completed' | 'failed';
|
|
30
30
|
aiTokensUsed?: number;
|
|
31
31
|
failureCode?: string;
|
|
32
32
|
failureMessage?: string;
|
|
33
|
+
/** Optional fetch abort timeout (e.g. interrupt path). */
|
|
34
|
+
timeoutMs?: number;
|
|
33
35
|
}): Promise<void>;
|
|
@@ -9,8 +9,8 @@ const read_cli_api_error_message_1 = require("./read-cli-api-error-message");
|
|
|
9
9
|
class CliScanQuotaExceededError extends Error {
|
|
10
10
|
constructor(message) {
|
|
11
11
|
super(message);
|
|
12
|
-
this.code =
|
|
13
|
-
this.name =
|
|
12
|
+
this.code = 'scan_quota_exceeded';
|
|
13
|
+
this.name = 'CliScanQuotaExceededError';
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.CliScanQuotaExceededError = CliScanQuotaExceededError;
|
|
@@ -18,20 +18,20 @@ exports.CliScanQuotaExceededError = CliScanQuotaExceededError;
|
|
|
18
18
|
class CliScanAlreadyRunningError extends Error {
|
|
19
19
|
constructor(message) {
|
|
20
20
|
super(message);
|
|
21
|
-
this.code =
|
|
22
|
-
this.name =
|
|
21
|
+
this.code = 'scan_already_running';
|
|
22
|
+
this.name = 'CliScanAlreadyRunningError';
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.CliScanAlreadyRunningError = CliScanAlreadyRunningError;
|
|
26
26
|
function buildHeaders(apiKey) {
|
|
27
27
|
return {
|
|
28
28
|
Authorization: `Bearer ${apiKey}`,
|
|
29
|
-
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
async function cliScanPreflight(input) {
|
|
33
33
|
const res = await fetch(`${(0, dataparade_api_base_url_1.getDataparadeApiBaseUrl)()}/api/scans/cli/preflight`, {
|
|
34
|
-
method:
|
|
34
|
+
method: 'POST',
|
|
35
35
|
headers: buildHeaders(input.apiKey),
|
|
36
36
|
body: JSON.stringify({
|
|
37
37
|
enableAi: input.enableAi,
|
|
@@ -53,10 +53,10 @@ async function cliScanPreflight(input) {
|
|
|
53
53
|
catch {
|
|
54
54
|
// ignore
|
|
55
55
|
}
|
|
56
|
-
if (res.status === 403 && code ===
|
|
56
|
+
if (res.status === 403 && code === 'scan_quota_exceeded') {
|
|
57
57
|
throw new CliScanQuotaExceededError(message);
|
|
58
58
|
}
|
|
59
|
-
if (res.status === 409 && code ===
|
|
59
|
+
if (res.status === 409 && code === 'scan_already_running') {
|
|
60
60
|
throw new CliScanAlreadyRunningError(message);
|
|
61
61
|
}
|
|
62
62
|
throw new Error(message);
|
|
@@ -64,26 +64,39 @@ async function cliScanPreflight(input) {
|
|
|
64
64
|
return (await res.json());
|
|
65
65
|
}
|
|
66
66
|
async function cliScanComplete(input) {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
const controller = typeof input.timeoutMs === 'number' && input.timeoutMs > 0
|
|
68
|
+
? new AbortController()
|
|
69
|
+
: undefined;
|
|
70
|
+
const timer = controller
|
|
71
|
+
? setTimeout(() => controller.abort(), input.timeoutMs)
|
|
72
|
+
: undefined;
|
|
73
|
+
try {
|
|
74
|
+
const res = await fetch(`${(0, dataparade_api_base_url_1.getDataparadeApiBaseUrl)()}/api/scans/cli/${encodeURIComponent(input.jobId)}/complete`, {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
headers: buildHeaders(input.apiKey),
|
|
77
|
+
signal: controller?.signal,
|
|
78
|
+
body: JSON.stringify({
|
|
79
|
+
status: input.status,
|
|
80
|
+
aiTokensUsed: input.aiTokensUsed,
|
|
81
|
+
failureCode: input.failureCode,
|
|
82
|
+
failureMessage: input.failureMessage,
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
if (!res.ok) {
|
|
86
|
+
const fallback = `Scan complete report failed (${res.status})`;
|
|
87
|
+
let message = fallback;
|
|
88
|
+
try {
|
|
89
|
+
const body = await res.json();
|
|
90
|
+
message = (0, read_cli_api_error_message_1.readCliApiErrorMessage)(body, fallback).message;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// ignore
|
|
94
|
+
}
|
|
95
|
+
throw new Error(message);
|
|
86
96
|
}
|
|
87
|
-
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
if (timer)
|
|
100
|
+
clearTimeout(timer);
|
|
88
101
|
}
|
|
89
102
|
}
|
|
@@ -33,8 +33,15 @@ export declare class ScanProgressRenderer {
|
|
|
33
33
|
private readonly version?;
|
|
34
34
|
private readonly columns?;
|
|
35
35
|
private readonly colorDepth?;
|
|
36
|
+
private readonly stdin?;
|
|
36
37
|
private readonly clack;
|
|
37
38
|
private started;
|
|
39
|
+
/**
|
|
40
|
+
* Set once the run is closed (finish/abort/fail). The scan keeps running
|
|
41
|
+
* while the interrupt handler reports to the API, and work queued behind a
|
|
42
|
+
* blocking phase must not draw new steps under "Scan cancelled".
|
|
43
|
+
*/
|
|
44
|
+
private closed;
|
|
38
45
|
private recognitionHandled;
|
|
39
46
|
private activeStep;
|
|
40
47
|
private spinner;
|
|
@@ -72,7 +79,24 @@ export declare class ScanProgressRenderer {
|
|
|
72
79
|
*/
|
|
73
80
|
showTechnicalDetails(title: string, lines: string[]): void;
|
|
74
81
|
finish(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Cancel an in-flight scan UI (Ctrl+C). Stops the spinner with a red mark
|
|
84
|
+
* in Clack mode; prints a short line in plain mode. Does not run finish().
|
|
85
|
+
*/
|
|
86
|
+
abort(message?: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* End the scan UI on an error: closes the active spinner with the error
|
|
89
|
+
* mark (or logs an error line between steps). Does not run finish().
|
|
90
|
+
*/
|
|
91
|
+
fail(message: string): void;
|
|
75
92
|
private transitionTo;
|
|
93
|
+
/**
|
|
94
|
+
* Clack's spinner puts stdin in raw mode, where Ctrl+C is a keypress it
|
|
95
|
+
* answers with process.exit(0) — skipping our SIGINT handler and leaving
|
|
96
|
+
* the scan job running. The spinner only writes, so hand Ctrl+C back to
|
|
97
|
+
* the terminal as a real signal.
|
|
98
|
+
*/
|
|
99
|
+
private restoreSignalKeys;
|
|
76
100
|
private completeActiveStep;
|
|
77
101
|
private runTeachingStep;
|
|
78
102
|
private prompts;
|
|
@@ -86,6 +86,12 @@ function formatProjectLabel(projectPath) {
|
|
|
86
86
|
class ScanProgressRenderer {
|
|
87
87
|
constructor(options, clack) {
|
|
88
88
|
this.started = false;
|
|
89
|
+
/**
|
|
90
|
+
* Set once the run is closed (finish/abort/fail). The scan keeps running
|
|
91
|
+
* while the interrupt handler reports to the API, and work queued behind a
|
|
92
|
+
* blocking phase must not draw new steps under "Scan cancelled".
|
|
93
|
+
*/
|
|
94
|
+
this.closed = false;
|
|
89
95
|
this.recognitionHandled = false;
|
|
90
96
|
this.activeStep = null;
|
|
91
97
|
this.spinner = null;
|
|
@@ -102,6 +108,7 @@ class ScanProgressRenderer {
|
|
|
102
108
|
this.version = options.version;
|
|
103
109
|
this.columns = options.columns;
|
|
104
110
|
this.colorDepth = options.colorDepth;
|
|
111
|
+
this.stdin = options.stdin;
|
|
105
112
|
this.writeLine =
|
|
106
113
|
options.writeLine ??
|
|
107
114
|
((line) => {
|
|
@@ -145,6 +152,8 @@ class ScanProgressRenderer {
|
|
|
145
152
|
}
|
|
146
153
|
}
|
|
147
154
|
onProgress(progress) {
|
|
155
|
+
if (this.closed)
|
|
156
|
+
return;
|
|
148
157
|
this.start();
|
|
149
158
|
switch (progress.phase) {
|
|
150
159
|
case 'ingest':
|
|
@@ -169,6 +178,8 @@ class ScanProgressRenderer {
|
|
|
169
178
|
}
|
|
170
179
|
}
|
|
171
180
|
onRecognition(payload) {
|
|
181
|
+
if (this.closed)
|
|
182
|
+
return;
|
|
172
183
|
if (this.recognitionHandled)
|
|
173
184
|
return;
|
|
174
185
|
this.recognitionHandled = true;
|
|
@@ -196,6 +207,8 @@ class ScanProgressRenderer {
|
|
|
196
207
|
}
|
|
197
208
|
/** Close the AI step with one plain-language result line. */
|
|
198
209
|
onAiResult(result) {
|
|
210
|
+
if (this.closed)
|
|
211
|
+
return;
|
|
199
212
|
if (this.activeStep !== 'ai_enrichment')
|
|
200
213
|
return;
|
|
201
214
|
this.completeActiveStep();
|
|
@@ -208,6 +221,8 @@ class ScanProgressRenderer {
|
|
|
208
221
|
}
|
|
209
222
|
}
|
|
210
223
|
onWroteDataflow(outputPath) {
|
|
224
|
+
if (this.closed)
|
|
225
|
+
return;
|
|
211
226
|
this.start();
|
|
212
227
|
this.completeActiveStep();
|
|
213
228
|
const label = 'Saved your data-flow map';
|
|
@@ -225,6 +240,8 @@ class ScanProgressRenderer {
|
|
|
225
240
|
}
|
|
226
241
|
/** Store preview URL for the "What to do next" note. Machine line stays in upload. */
|
|
227
242
|
onPreviewUrl(previewUrl, notice) {
|
|
243
|
+
if (this.closed)
|
|
244
|
+
return;
|
|
228
245
|
this.previewUrl = previewUrl;
|
|
229
246
|
this.previewNotice = notice;
|
|
230
247
|
}
|
|
@@ -250,6 +267,8 @@ class ScanProgressRenderer {
|
|
|
250
267
|
* keeps the `[scan] …` stderr line scripts may grep for.
|
|
251
268
|
*/
|
|
252
269
|
warn(message) {
|
|
270
|
+
if (this.closed)
|
|
271
|
+
return;
|
|
253
272
|
if (this.useClack) {
|
|
254
273
|
this.prompts().log.warn(message);
|
|
255
274
|
}
|
|
@@ -262,6 +281,8 @@ class ScanProgressRenderer {
|
|
|
262
281
|
* Clack folds them into one dimmed note so they don't break the guide rail.
|
|
263
282
|
*/
|
|
264
283
|
showTechnicalDetails(title, lines) {
|
|
284
|
+
if (this.closed)
|
|
285
|
+
return;
|
|
265
286
|
if (lines.length === 0)
|
|
266
287
|
return;
|
|
267
288
|
if (this.useClack) {
|
|
@@ -278,6 +299,9 @@ class ScanProgressRenderer {
|
|
|
278
299
|
}
|
|
279
300
|
}
|
|
280
301
|
finish() {
|
|
302
|
+
if (this.closed)
|
|
303
|
+
return;
|
|
304
|
+
this.closed = true;
|
|
281
305
|
this.completeActiveStep();
|
|
282
306
|
const nextSteps = [];
|
|
283
307
|
let closing = 'All done — nice work.';
|
|
@@ -320,6 +344,59 @@ class ScanProgressRenderer {
|
|
|
320
344
|
this.writePlain(closing);
|
|
321
345
|
}
|
|
322
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* Cancel an in-flight scan UI (Ctrl+C). Stops the spinner with a red mark
|
|
349
|
+
* in Clack mode; prints a short line in plain mode. Does not run finish().
|
|
350
|
+
*/
|
|
351
|
+
abort(message = 'Scan cancelled') {
|
|
352
|
+
if (this.closed)
|
|
353
|
+
return;
|
|
354
|
+
this.closed = true;
|
|
355
|
+
if (this.useClack && this.spinner) {
|
|
356
|
+
if (typeof this.spinner.cancel === 'function') {
|
|
357
|
+
this.spinner.cancel(message);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
this.spinner.stop(message);
|
|
361
|
+
}
|
|
362
|
+
this.spinner = null;
|
|
363
|
+
this.activeStep = null;
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
this.activeStep = null;
|
|
367
|
+
if (this.useClack) {
|
|
368
|
+
// Between steps: a raw line would break Clack's guide rail.
|
|
369
|
+
this.prompts().log.warn(message);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
this.writePlain(message);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* End the scan UI on an error: closes the active spinner with the error
|
|
376
|
+
* mark (or logs an error line between steps). Does not run finish().
|
|
377
|
+
*/
|
|
378
|
+
fail(message) {
|
|
379
|
+
if (this.closed)
|
|
380
|
+
return;
|
|
381
|
+
this.closed = true;
|
|
382
|
+
if (this.useClack && this.spinner) {
|
|
383
|
+
if (typeof this.spinner.error === 'function') {
|
|
384
|
+
this.spinner.error(message);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
this.spinner.stop(message);
|
|
388
|
+
}
|
|
389
|
+
this.spinner = null;
|
|
390
|
+
this.activeStep = null;
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
this.activeStep = null;
|
|
394
|
+
if (this.useClack) {
|
|
395
|
+
this.prompts().log.error(message);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
this.writePlain(message);
|
|
399
|
+
}
|
|
323
400
|
transitionTo(step) {
|
|
324
401
|
if (this.activeStep === step || this.completedSteps.has(step)) {
|
|
325
402
|
return;
|
|
@@ -330,11 +407,24 @@ class ScanProgressRenderer {
|
|
|
330
407
|
if (this.useClack) {
|
|
331
408
|
this.spinner = this.prompts().spinner({ withGuide: true });
|
|
332
409
|
this.spinner.start(label);
|
|
410
|
+
this.restoreSignalKeys();
|
|
333
411
|
}
|
|
334
412
|
else {
|
|
335
413
|
this.writePlain(`… ${label}`);
|
|
336
414
|
}
|
|
337
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Clack's spinner puts stdin in raw mode, where Ctrl+C is a keypress it
|
|
418
|
+
* answers with process.exit(0) — skipping our SIGINT handler and leaving
|
|
419
|
+
* the scan job running. The spinner only writes, so hand Ctrl+C back to
|
|
420
|
+
* the terminal as a real signal.
|
|
421
|
+
*/
|
|
422
|
+
restoreSignalKeys() {
|
|
423
|
+
const stdin = this.stdin;
|
|
424
|
+
if (stdin?.isTTY && typeof stdin.setRawMode === 'function') {
|
|
425
|
+
stdin.setRawMode(false);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
338
428
|
completeActiveStep() {
|
|
339
429
|
if (!this.activeStep)
|
|
340
430
|
return;
|
|
@@ -396,6 +486,7 @@ async function createScanProgressRenderer(options) {
|
|
|
396
486
|
projectLabel: options?.projectLabel,
|
|
397
487
|
version: options?.version,
|
|
398
488
|
columns: options?.columns ?? process.stdout.columns,
|
|
489
|
+
stdin: options?.stdin ?? process.stdin,
|
|
399
490
|
colorDepth: options?.colorDepth ??
|
|
400
491
|
(typeof process.stdout.getColorDepth === 'function'
|
|
401
492
|
? process.stdout.getColorDepth()
|
package/dist/src/ui/types.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export interface ScanProgressRendererOptions {
|
|
|
25
25
|
writeLine?: (line: string) => void;
|
|
26
26
|
/** Injected Clack module. Tests pass a mock; production loads the ESM package. */
|
|
27
27
|
prompts?: typeof import('@clack/prompts');
|
|
28
|
+
/** Terminal input whose raw mode the spinner toggles. Defaults to process.stdin. */
|
|
29
|
+
stdin?: {
|
|
30
|
+
isTTY?: boolean;
|
|
31
|
+
setRawMode?: (mode: boolean) => unknown;
|
|
32
|
+
};
|
|
28
33
|
}
|
|
29
34
|
export interface TeachingLineGroups {
|
|
30
35
|
routes: string[];
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const platform_proxy_provider_1 = require("../../../src/ai-enrichment/providers/platform-proxy-provider");
|
|
4
|
+
const scan_env_1 = require("../../../src/config/scan-env");
|
|
4
5
|
describe('PlatformProxyProvider', () => {
|
|
5
6
|
const originalFetch = global.fetch;
|
|
6
7
|
afterEach(() => {
|
|
7
8
|
global.fetch = originalFetch;
|
|
9
|
+
(0, scan_env_1.setScanAiDebugSuppressed)(false);
|
|
10
|
+
jest.restoreAllMocks();
|
|
8
11
|
});
|
|
9
12
|
it('submits a task and polls until completed', async () => {
|
|
10
13
|
const calls = [];
|
|
@@ -199,4 +202,27 @@ describe('PlatformProxyProvider', () => {
|
|
|
199
202
|
});
|
|
200
203
|
await expect(provider.infer({ prompt: 'test', model: 'gpt-4o-mini' })).rejects.toThrow('Could not reach the DataParade API (POST http://localhost:3000/api/scans/cli/ai/infer/tasks): ECONNRESET: other side closed. Tried 3 times. Run the scan again.');
|
|
201
204
|
});
|
|
205
|
+
it('keeps retry notices out of the terminal while the progress UI owns it', async () => {
|
|
206
|
+
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => { });
|
|
207
|
+
global.fetch = jest.fn(async () => {
|
|
208
|
+
const err = new TypeError('fetch failed');
|
|
209
|
+
err.cause = Object.assign(new Error('other side closed'), {
|
|
210
|
+
code: 'ECONNRESET',
|
|
211
|
+
});
|
|
212
|
+
throw err;
|
|
213
|
+
});
|
|
214
|
+
const provider = new platform_proxy_provider_1.PlatformProxyProvider({
|
|
215
|
+
apiBaseUrl: 'http://localhost:3000',
|
|
216
|
+
workspaceApiKey: 'dp_anon_test',
|
|
217
|
+
jobId: 'job-1',
|
|
218
|
+
networkRetryDelaysMs: [0],
|
|
219
|
+
sleep: async () => undefined,
|
|
220
|
+
});
|
|
221
|
+
(0, scan_env_1.setScanAiDebugSuppressed)(true);
|
|
222
|
+
await expect(provider.infer({ prompt: 'test', model: 'gpt-4o-mini' })).rejects.toThrow('Tried 2 times');
|
|
223
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
224
|
+
(0, scan_env_1.setScanAiDebugSuppressed)(false);
|
|
225
|
+
await expect(provider.infer({ prompt: 'test', model: 'gpt-4o-mini' })).rejects.toThrow('Tried 2 times');
|
|
226
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Retrying (1/1)'));
|
|
227
|
+
});
|
|
202
228
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_events_1 = require("node:events");
|
|
4
|
+
const scan_interrupt_handlers_1 = require("../../../src/cli/scan-interrupt-handlers");
|
|
5
|
+
describe('installCliScanInterruptHandlers', () => {
|
|
6
|
+
function setup(options) {
|
|
7
|
+
const proc = new node_events_1.EventEmitter();
|
|
8
|
+
const exits = [];
|
|
9
|
+
const abortUi = jest.fn();
|
|
10
|
+
const reportFailed = jest.fn().mockResolvedValue(undefined);
|
|
11
|
+
let completionStatus = options?.completionStatus ?? 'none';
|
|
12
|
+
const uninstall = (0, scan_interrupt_handlers_1.installCliScanInterruptHandlers)({
|
|
13
|
+
proc,
|
|
14
|
+
exit: (code) => {
|
|
15
|
+
exits.push(code);
|
|
16
|
+
},
|
|
17
|
+
getState: () => ({
|
|
18
|
+
apiKey: options?.apiKey ?? 'dp_live_test',
|
|
19
|
+
jobId: options?.jobId ?? 'job-1',
|
|
20
|
+
completionStatus,
|
|
21
|
+
inFlight: options?.inFlight,
|
|
22
|
+
}),
|
|
23
|
+
setCompletionStatus: (status) => {
|
|
24
|
+
completionStatus = status;
|
|
25
|
+
},
|
|
26
|
+
onAbortUi: abortUi,
|
|
27
|
+
reportFailed,
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
proc,
|
|
31
|
+
exits,
|
|
32
|
+
abortUi,
|
|
33
|
+
reportFailed,
|
|
34
|
+
uninstall,
|
|
35
|
+
setCompletionStatus: (status) => {
|
|
36
|
+
completionStatus = status;
|
|
37
|
+
},
|
|
38
|
+
getCompletionStatus: () => completionStatus,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
jest.useRealTimers();
|
|
43
|
+
});
|
|
44
|
+
it('reports scan_interrupted once on SIGINT and exits 130', async () => {
|
|
45
|
+
const { proc, exits, abortUi, reportFailed, uninstall } = setup();
|
|
46
|
+
proc.emit('SIGINT');
|
|
47
|
+
await Promise.resolve();
|
|
48
|
+
await Promise.resolve();
|
|
49
|
+
expect(abortUi).toHaveBeenCalledTimes(1);
|
|
50
|
+
expect(reportFailed).toHaveBeenCalledTimes(1);
|
|
51
|
+
const [reportInput] = reportFailed.mock.calls[0];
|
|
52
|
+
expect(reportInput.apiKey).toBe('dp_live_test');
|
|
53
|
+
expect(reportInput.jobId).toBe('job-1');
|
|
54
|
+
expect(reportInput.timeoutMs).toBeGreaterThan(0);
|
|
55
|
+
expect(reportInput.timeoutMs).toBeLessThanOrEqual(scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_COMPLETE_TIMEOUT_MS);
|
|
56
|
+
expect(exits).toEqual([scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_EXIT_CODES.SIGINT]);
|
|
57
|
+
uninstall();
|
|
58
|
+
});
|
|
59
|
+
it('exits immediately on a second signal without reporting again', async () => {
|
|
60
|
+
const { proc, exits, reportFailed, uninstall } = setup();
|
|
61
|
+
let resolveReport;
|
|
62
|
+
reportFailed.mockImplementation(() => new Promise((resolve) => {
|
|
63
|
+
resolveReport = resolve;
|
|
64
|
+
}));
|
|
65
|
+
proc.emit('SIGINT');
|
|
66
|
+
await Promise.resolve();
|
|
67
|
+
expect(reportFailed).toHaveBeenCalledTimes(1);
|
|
68
|
+
proc.emit('SIGINT');
|
|
69
|
+
expect(exits).toEqual([scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_EXIT_CODES.SIGINT]);
|
|
70
|
+
expect(reportFailed).toHaveBeenCalledTimes(1);
|
|
71
|
+
resolveReport?.();
|
|
72
|
+
await Promise.resolve();
|
|
73
|
+
await Promise.resolve();
|
|
74
|
+
expect(exits).toEqual([
|
|
75
|
+
scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_EXIT_CODES.SIGINT,
|
|
76
|
+
scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_EXIT_CODES.SIGINT,
|
|
77
|
+
]);
|
|
78
|
+
uninstall();
|
|
79
|
+
});
|
|
80
|
+
it('waits for an in-flight complete instead of reporting again', async () => {
|
|
81
|
+
let resolveInFlight;
|
|
82
|
+
const inFlight = new Promise((resolve) => {
|
|
83
|
+
resolveInFlight = resolve;
|
|
84
|
+
});
|
|
85
|
+
const { proc, exits, reportFailed, uninstall, setCompletionStatus } = setup({ completionStatus: 'in_flight', inFlight });
|
|
86
|
+
proc.emit('SIGTERM');
|
|
87
|
+
await Promise.resolve();
|
|
88
|
+
expect(exits).toEqual([]);
|
|
89
|
+
// The scan's own complete lands.
|
|
90
|
+
setCompletionStatus('done');
|
|
91
|
+
resolveInFlight?.();
|
|
92
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
93
|
+
expect(reportFailed).not.toHaveBeenCalled();
|
|
94
|
+
expect(exits).toEqual([scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_EXIT_CODES.SIGTERM]);
|
|
95
|
+
uninstall();
|
|
96
|
+
});
|
|
97
|
+
it('reports scan_interrupted when the in-flight complete fails', async () => {
|
|
98
|
+
let rejectInFlight;
|
|
99
|
+
const inFlight = new Promise((_resolve, reject) => {
|
|
100
|
+
rejectInFlight = reject;
|
|
101
|
+
});
|
|
102
|
+
const { proc, exits, reportFailed, uninstall, setCompletionStatus } = setup({ completionStatus: 'in_flight', inFlight });
|
|
103
|
+
proc.emit('SIGINT');
|
|
104
|
+
await Promise.resolve();
|
|
105
|
+
// The scan path resets the status when its complete throws.
|
|
106
|
+
setCompletionStatus('none');
|
|
107
|
+
rejectInFlight?.(new Error('network down'));
|
|
108
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
109
|
+
expect(reportFailed).toHaveBeenCalledTimes(1);
|
|
110
|
+
expect(exits).toEqual([scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_EXIT_CODES.SIGINT]);
|
|
111
|
+
uninstall();
|
|
112
|
+
});
|
|
113
|
+
it('claims the completion so the scan path does not report again', async () => {
|
|
114
|
+
const { proc, reportFailed, uninstall, getCompletionStatus } = setup();
|
|
115
|
+
let statusDuringReport;
|
|
116
|
+
reportFailed.mockImplementation(() => {
|
|
117
|
+
statusDuringReport = getCompletionStatus();
|
|
118
|
+
return Promise.resolve();
|
|
119
|
+
});
|
|
120
|
+
proc.emit('SIGINT');
|
|
121
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
122
|
+
expect(statusDuringReport).toBe('in_flight');
|
|
123
|
+
expect(getCompletionStatus()).toBe('done');
|
|
124
|
+
uninstall();
|
|
125
|
+
});
|
|
126
|
+
it('does not block exit when the complete API hangs past the timeout', async () => {
|
|
127
|
+
jest.useFakeTimers();
|
|
128
|
+
const { proc, exits, reportFailed, uninstall } = setup();
|
|
129
|
+
reportFailed.mockImplementation(({ timeoutMs }) => new Promise((_resolve, reject) => {
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
reject(new Error('aborted'));
|
|
132
|
+
}, timeoutMs);
|
|
133
|
+
}));
|
|
134
|
+
proc.emit('SIGHUP');
|
|
135
|
+
await Promise.resolve();
|
|
136
|
+
expect(reportFailed).toHaveBeenCalledTimes(1);
|
|
137
|
+
expect(exits).toEqual([]);
|
|
138
|
+
await jest.advanceTimersByTimeAsync(scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_COMPLETE_TIMEOUT_MS);
|
|
139
|
+
await Promise.resolve();
|
|
140
|
+
await Promise.resolve();
|
|
141
|
+
expect(exits).toEqual([scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_EXIT_CODES.SIGHUP]);
|
|
142
|
+
uninstall();
|
|
143
|
+
});
|
|
144
|
+
it('uses exit codes 130, 143, and 129 for SIGINT, SIGTERM, and SIGHUP', async () => {
|
|
145
|
+
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
|
|
146
|
+
const { proc, exits, uninstall } = setup();
|
|
147
|
+
proc.emit(signal);
|
|
148
|
+
await Promise.resolve();
|
|
149
|
+
await Promise.resolve();
|
|
150
|
+
expect(exits).toEqual([scan_interrupt_handlers_1.CLI_SCAN_INTERRUPT_EXIT_CODES[signal]]);
|
|
151
|
+
uninstall();
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -64,11 +64,11 @@ describe('scan quota flow', () => {
|
|
|
64
64
|
statusCode: 409,
|
|
65
65
|
message: {
|
|
66
66
|
code: 'scan_already_running',
|
|
67
|
-
message: '
|
|
67
|
+
message: 'Another scan is already running in this workspace. Wait for it to finish, if it was stopped, it is released automatically after 60 minutes of inactivity.',
|
|
68
68
|
},
|
|
69
69
|
}, 409));
|
|
70
70
|
await (0, cli_1.run)(['node', 'cli', 'scan', tempRoot, '--ai-inference']);
|
|
71
|
-
expect(errorSpy).toHaveBeenCalledWith('[scan] scan in progress:
|
|
71
|
+
expect(errorSpy).toHaveBeenCalledWith('[scan] scan in progress: Another scan is already running in this workspace. Wait for it to finish, if it was stopped, it is released automatically after 60 minutes of inactivity.');
|
|
72
72
|
errorSpy.mockRestore();
|
|
73
73
|
});
|
|
74
74
|
it('reports failed completion when preflight succeeds but config validation fails', async () => {
|
|
@@ -16,11 +16,11 @@ describe("readCliApiErrorMessage", () => {
|
|
|
16
16
|
statusCode: 409,
|
|
17
17
|
message: {
|
|
18
18
|
code: "scan_already_running",
|
|
19
|
-
message: "
|
|
19
|
+
message: "Another scan is already running in this workspace. Wait for it to finish, if it was stopped, it is released automatically after 60 minutes of inactivity.",
|
|
20
20
|
},
|
|
21
21
|
}, "fallback")).toEqual({
|
|
22
22
|
code: "scan_already_running",
|
|
23
|
-
message: "
|
|
23
|
+
message: "Another scan is already running in this workspace. Wait for it to finish, if it was stopped, it is released automatically after 60 minutes of inactivity.",
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
it("joins validation message arrays", () => {
|
|
@@ -37,6 +37,8 @@ jest.mock('@clack/prompts', () => {
|
|
|
37
37
|
const spin = {
|
|
38
38
|
start: jest.fn(),
|
|
39
39
|
stop: jest.fn(),
|
|
40
|
+
cancel: jest.fn(),
|
|
41
|
+
error: jest.fn(),
|
|
40
42
|
message: jest.fn(),
|
|
41
43
|
};
|
|
42
44
|
return {
|
|
@@ -49,6 +51,7 @@ jest.mock('@clack/prompts', () => {
|
|
|
49
51
|
success: jest.fn(),
|
|
50
52
|
step: jest.fn(),
|
|
51
53
|
warn: jest.fn(),
|
|
54
|
+
error: jest.fn(),
|
|
52
55
|
},
|
|
53
56
|
};
|
|
54
57
|
});
|
|
@@ -293,4 +296,135 @@ describe('ScanProgressRenderer', () => {
|
|
|
293
296
|
'[scan] ai-usage: provider_calls=1 tokens_total=10',
|
|
294
297
|
]);
|
|
295
298
|
});
|
|
299
|
+
it('abort cancels the active spinner and skips the finish outro', async () => {
|
|
300
|
+
const { lines, writeLine } = captureLines();
|
|
301
|
+
const ui = await (0, scan_progress_renderer_1.createScanProgressRenderer)({
|
|
302
|
+
isTTY: true,
|
|
303
|
+
noColor: false,
|
|
304
|
+
writeLine,
|
|
305
|
+
prompts,
|
|
306
|
+
});
|
|
307
|
+
const spin = prompts.spinner();
|
|
308
|
+
prompts.spinner.mockClear();
|
|
309
|
+
ui.onProgress({
|
|
310
|
+
phase: 'ingest',
|
|
311
|
+
filesProcessed: 0,
|
|
312
|
+
totalFiles: 0,
|
|
313
|
+
progress: 0.05,
|
|
314
|
+
});
|
|
315
|
+
expect(prompts.spinner).toHaveBeenCalledTimes(1);
|
|
316
|
+
ui.abort('Scan cancelled');
|
|
317
|
+
expect(spin.cancel).toHaveBeenCalledWith('Scan cancelled');
|
|
318
|
+
expect(spin.stop).not.toHaveBeenCalled();
|
|
319
|
+
expect(prompts.outro).not.toHaveBeenCalled();
|
|
320
|
+
expect(lines.some((line) => line.includes('All done'))).toBe(false);
|
|
321
|
+
});
|
|
322
|
+
it('hands Ctrl+C back to the terminal after starting a spinner', async () => {
|
|
323
|
+
const { writeLine } = captureLines();
|
|
324
|
+
const stdin = { isTTY: true, setRawMode: jest.fn() };
|
|
325
|
+
const ui = await (0, scan_progress_renderer_1.createScanProgressRenderer)({
|
|
326
|
+
isTTY: true,
|
|
327
|
+
noColor: false,
|
|
328
|
+
writeLine,
|
|
329
|
+
prompts,
|
|
330
|
+
stdin,
|
|
331
|
+
});
|
|
332
|
+
ui.onProgress({
|
|
333
|
+
phase: 'ingest',
|
|
334
|
+
filesProcessed: 0,
|
|
335
|
+
totalFiles: 0,
|
|
336
|
+
progress: 0.05,
|
|
337
|
+
});
|
|
338
|
+
expect(stdin.setRawMode).toHaveBeenLastCalledWith(false);
|
|
339
|
+
});
|
|
340
|
+
it('abort between steps uses a Clack log line, not a raw write', async () => {
|
|
341
|
+
const { lines, writeLine } = captureLines();
|
|
342
|
+
const ui = await (0, scan_progress_renderer_1.createScanProgressRenderer)({
|
|
343
|
+
isTTY: true,
|
|
344
|
+
noColor: false,
|
|
345
|
+
writeLine,
|
|
346
|
+
prompts,
|
|
347
|
+
});
|
|
348
|
+
ui.abort('Scan cancelled');
|
|
349
|
+
expect(prompts.log.warn).toHaveBeenCalledWith('Scan cancelled');
|
|
350
|
+
expect(lines).not.toContain('Scan cancelled');
|
|
351
|
+
expect(prompts.outro).not.toHaveBeenCalled();
|
|
352
|
+
});
|
|
353
|
+
it('fail closes the active spinner with the error mark', async () => {
|
|
354
|
+
const { writeLine } = captureLines();
|
|
355
|
+
const ui = await (0, scan_progress_renderer_1.createScanProgressRenderer)({
|
|
356
|
+
isTTY: true,
|
|
357
|
+
noColor: false,
|
|
358
|
+
writeLine,
|
|
359
|
+
prompts,
|
|
360
|
+
});
|
|
361
|
+
const spin = prompts.spinner();
|
|
362
|
+
prompts.spinner.mockClear();
|
|
363
|
+
ui.onProgress({
|
|
364
|
+
phase: 'ingest',
|
|
365
|
+
filesProcessed: 0,
|
|
366
|
+
totalFiles: 0,
|
|
367
|
+
progress: 0.05,
|
|
368
|
+
});
|
|
369
|
+
ui.fail('Scan failed: API unreachable');
|
|
370
|
+
expect(spin.error).toHaveBeenCalledWith('Scan failed: API unreachable');
|
|
371
|
+
expect(prompts.outro).not.toHaveBeenCalled();
|
|
372
|
+
});
|
|
373
|
+
it('fail between steps logs a Clack error line', async () => {
|
|
374
|
+
const { lines, writeLine } = captureLines();
|
|
375
|
+
const ui = await (0, scan_progress_renderer_1.createScanProgressRenderer)({
|
|
376
|
+
isTTY: true,
|
|
377
|
+
noColor: false,
|
|
378
|
+
writeLine,
|
|
379
|
+
prompts,
|
|
380
|
+
});
|
|
381
|
+
ui.fail('Another scan is already running in this workspace.');
|
|
382
|
+
expect(prompts.log.error).toHaveBeenCalledWith('Another scan is already running in this workspace.');
|
|
383
|
+
expect(lines).toHaveLength(0);
|
|
384
|
+
});
|
|
385
|
+
it('ignores progress that arrives after the scan was cancelled', async () => {
|
|
386
|
+
const { lines, writeLine } = captureLines();
|
|
387
|
+
const ui = await (0, scan_progress_renderer_1.createScanProgressRenderer)({
|
|
388
|
+
isTTY: false,
|
|
389
|
+
noColor: true,
|
|
390
|
+
writeLine,
|
|
391
|
+
});
|
|
392
|
+
ui.onProgress({
|
|
393
|
+
phase: 'ingest',
|
|
394
|
+
filesProcessed: 0,
|
|
395
|
+
totalFiles: 0,
|
|
396
|
+
progress: 0.05,
|
|
397
|
+
});
|
|
398
|
+
ui.abort('Scan cancelled');
|
|
399
|
+
const linesAtAbort = lines.length;
|
|
400
|
+
// Work queued behind a blocking phase lands after Ctrl+C.
|
|
401
|
+
ui.onProgress({
|
|
402
|
+
phase: 'ai_enrichment',
|
|
403
|
+
filesProcessed: 0,
|
|
404
|
+
totalFiles: 0,
|
|
405
|
+
progress: 0.6,
|
|
406
|
+
});
|
|
407
|
+
ui.warn('late warning');
|
|
408
|
+
ui.fail('Scan failed: late');
|
|
409
|
+
ui.finish();
|
|
410
|
+
expect(lines).toHaveLength(linesAtAbort);
|
|
411
|
+
expect(lines[lines.length - 1]).toBe('Scan cancelled');
|
|
412
|
+
});
|
|
413
|
+
it('abort prints a plain cancellation line when Clack is off', async () => {
|
|
414
|
+
const { lines, writeLine } = captureLines();
|
|
415
|
+
const ui = await (0, scan_progress_renderer_1.createScanProgressRenderer)({
|
|
416
|
+
isTTY: false,
|
|
417
|
+
noColor: false,
|
|
418
|
+
writeLine,
|
|
419
|
+
});
|
|
420
|
+
ui.onProgress({
|
|
421
|
+
phase: 'ingest',
|
|
422
|
+
filesProcessed: 0,
|
|
423
|
+
totalFiles: 0,
|
|
424
|
+
progress: 0.05,
|
|
425
|
+
});
|
|
426
|
+
ui.abort('Scan cancelled');
|
|
427
|
+
expect(lines).toContain('Scan cancelled');
|
|
428
|
+
expect(lines.some((line) => line.includes('All done'))).toBe(false);
|
|
429
|
+
});
|
|
296
430
|
});
|