Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions apps/cli/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ora, { Ora } from 'ora';
import { Spinner } from 'picospinner';

const isIpcMode = Boolean( process.send );

Expand Down Expand Up @@ -45,11 +45,11 @@ export class LoggerError extends Error {
}

export class Logger< T extends string > {
public spinner: Ora;
public spinner: Spinner;
private currentAction: T | 'keyValuePair' | null = null;

constructor() {
this.spinner = ora();
this.spinner = new Spinner();
}

public reportStart( action: T, message: string ) {
Expand All @@ -63,7 +63,8 @@ export class Logger< T extends string > {
progressCallback!( message );
return;
}
this.spinner.start( message );
this.spinner.setText( message );
this.spinner.start();
}

public reportProgress( message: string ) {
Expand All @@ -78,11 +79,11 @@ export class Logger< T extends string > {
}

// Update the spinner text and force render
this.spinner.text = message;
if ( ! this.spinner.isSpinning ) {
this.spinner.start( message );
this.spinner.setText( message );
if ( ! this.spinner.running ) {
this.spinner.start();
} else {
this.spinner.render();
this.spinner.refresh();
}
}

Expand All @@ -92,7 +93,7 @@ export class Logger< T extends string > {
} else if ( progressCallback ) {
progressCallback!( message );
} else if ( shouldClearSpinner ) {
this.spinner.clear();
this.spinner.stop();
} else {
this.spinner.succeed( message );
}
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"fs-extra": "^11.3.4",
"http-proxy": "^1.18.1",
"node-forge": "^1.3.3",
"ora": "^8.2.0",
"patch-package": "^8.0.1",
"picospinner": "^3.0.0",
"playwright": "^1.52.0",
"semver": "^7.7.4",
"tar": "^7.5.13",
Expand Down
25 changes: 13 additions & 12 deletions apps/cli/vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,19 @@ vi.mock( 'lockfile', () => {
};
} );

vi.mock( 'ora', () => {
const mockOra = () => ( {
start: vi.fn().mockReturnThis(),
stop: vi.fn().mockReturnThis(),
succeed: vi.fn().mockReturnThis(),
fail: vi.fn().mockReturnThis(),
warn: vi.fn().mockReturnThis(),
info: vi.fn().mockReturnThis(),
text: '',
isSpinning: false,
} );
vi.mock( 'picospinner', () => {
class MockSpinner {
start = vi.fn().mockReturnThis();
stop = vi.fn().mockReturnThis();
succeed = vi.fn().mockReturnThis();
fail = vi.fn().mockReturnThis();
warn = vi.fn().mockReturnThis();
info = vi.fn().mockReturnThis();
setText = vi.fn().mockReturnThis();
refresh = vi.fn().mockReturnThis();
running = false;
}
return {
default: mockOra,
Spinner: MockSpinner,
};
} );
25 changes: 13 additions & 12 deletions apps/studio/vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,19 @@ vi.mock( 'atomically', () => ( {
writeFile: vi.fn(),
} ) );

vi.mock( 'ora', () => {
const mockOra = () => ( {
start: vi.fn().mockReturnThis(),
stop: vi.fn().mockReturnThis(),
succeed: vi.fn().mockReturnThis(),
fail: vi.fn().mockReturnThis(),
warn: vi.fn().mockReturnThis(),
info: vi.fn().mockReturnThis(),
text: '',
isSpinning: false,
} );
vi.mock( 'picospinner', () => {
class MockSpinner {
start = vi.fn().mockReturnThis();
stop = vi.fn().mockReturnThis();
succeed = vi.fn().mockReturnThis();
fail = vi.fn().mockReturnThis();
warn = vi.fn().mockReturnThis();
info = vi.fn().mockReturnThis();
setText = vi.fn().mockReturnThis();
refresh = vi.fn().mockReturnThis();
running = false;
}
return {
default: mockOra,
Spinner: MockSpinner,
};
} );
Loading
Loading