mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
fix(cli): scale nested scan progress phases (#35)
This commit is contained in:
parent
da108e556c
commit
e1129dd6a9
2 changed files with 27 additions and 1 deletions
|
|
@ -573,6 +573,32 @@ describe('runKtxScan', () => {
|
|||
expect(io.stdout()).toContain('\n[90%] Building embeddings 1/4 batches\n');
|
||||
});
|
||||
|
||||
it('scales nested progress phases by the parent phase weight', async () => {
|
||||
const io = makeIo({ isTTY: true });
|
||||
const previousCi = process.env.CI;
|
||||
delete process.env.CI;
|
||||
|
||||
try {
|
||||
const progress = createCliScanProgress(io.io);
|
||||
await progress.update(0.82, 'Enriching schema metadata');
|
||||
const enrichmentProgress = progress.startPhase(0.18);
|
||||
await enrichmentProgress.update(0.05, 'Loaded schema snapshot with 56 tables');
|
||||
const descriptionProgress = enrichmentProgress.startPhase(0.45);
|
||||
await descriptionProgress.update(37 / 56, 'Generating descriptions 37/56 tables', { transient: true });
|
||||
await descriptionProgress.update(1, 'Generated descriptions for 56 tables');
|
||||
} finally {
|
||||
if (previousCi === undefined) {
|
||||
delete process.env.CI;
|
||||
} else {
|
||||
process.env.CI = previousCi;
|
||||
}
|
||||
}
|
||||
|
||||
expect(io.stdout()).toContain('\r[88%] Generating descriptions 37/56 tables');
|
||||
expect(io.stdout()).toContain('\n[91%] Generated descriptions for 56 tables\n');
|
||||
expect(io.stdout()).not.toContain('[100%] Generating descriptions 37/56 tables');
|
||||
});
|
||||
|
||||
it('flushes transient TTY progress messages before printing scan failures', async () => {
|
||||
await initKtxProject({ projectDir: tempDir, projectName: 'warehouse' });
|
||||
const runLocalScan = vi.fn(async (input: RunLocalScanOptions): Promise<LocalScanRunResult> => {
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ export function createCliScanProgress(
|
|||
io.stdout.write(`${line}\n`);
|
||||
},
|
||||
startPhase(phaseWeight: number) {
|
||||
return createCliScanProgress(io, state, state.progress, phaseWeight);
|
||||
return createCliScanProgress(io, state, state.progress, weight * phaseWeight);
|
||||
},
|
||||
flush() {
|
||||
if (!shouldWrite || !state.hasPendingTransient) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue