Skip to content
Merged
2 changes: 1 addition & 1 deletion code/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"@babel/parser": "^7.26.9",
"@babel/traverse": "^7.26.9",
"@babel/types": "^7.26.8",
"@clack/prompts": "1.0.0-alpha.6",
"@clack/prompts": "1.0.0-alpha.7",
"@devtools-ds/object-inspector": "^1.1.2",
"@discoveryjs/json-ext": "^0.5.3",
"@emotion/cache": "^11.14.0",
Expand Down
33 changes: 29 additions & 4 deletions code/core/src/node-logger/prompts/prompt-functions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { logger } from '../../client-logger';
import { shouldLog } from '../logger';
import { error, log, shouldLog } from '../logger';
import { wrapTextForClack, wrapTextForClackHint } from '../wrap-utils';
import { getPromptProvider } from './prompt-config';
import type {
Expand Down Expand Up @@ -129,6 +128,20 @@ export const spinner = (options: SpinnerOptions): SpinnerInstance => {
spinnerInstance.stop(message);
}
},
cancel: (message?: string) => {
activeSpinner = null;
restoreConsoleLog();
if (shouldLog('info')) {
spinnerInstance.cancel(message);
}
},
error: (message?: string) => {
activeSpinner = null;
restoreConsoleLog();
if (shouldLog('error')) {
spinnerInstance.error(message);
}
},
message: (text: string) => {
if (shouldLog('info')) {
spinnerInstance.message(text);
Expand All @@ -138,7 +151,7 @@ export const spinner = (options: SpinnerOptions): SpinnerInstance => {

return wrappedSpinner;
} else {
const maybeLog = shouldLog('info') ? logger.log : (_: string) => {};
const maybeLog = shouldLog('info') ? log : (_: string) => {};

return {
start: (message) => {
Expand All @@ -151,6 +164,18 @@ export const spinner = (options: SpinnerOptions): SpinnerInstance => {
maybeLog(message);
}
},
cancel: (message) => {
if (message) {
maybeLog(message);
}
},
error: (message) => {
if (message) {
if (shouldLog('error')) {
error(message);
}
}
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
message: (message) => {
maybeLog(message);
},
Expand Down Expand Up @@ -199,7 +224,7 @@ export const taskLog = (options: TaskLogOptions): TaskLogInstance => {

return wrappedTaskLog;
} else {
const maybeLog = shouldLog('info') ? logger.log : (_: string) => {};
const maybeLog = shouldLog('info') ? log : (_: string) => {};

return {
message: (message: string) => {
Expand Down
2 changes: 2 additions & 0 deletions code/core/src/node-logger/prompts/prompt-provider-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export interface PromptOptions {
export interface SpinnerInstance {
start: (message?: string) => void;
stop: (message?: string) => void;
cancel: (message?: string) => void;
error: (message?: string) => void;
message: (text: string) => void;
}

Expand Down
8 changes: 8 additions & 0 deletions code/core/src/node-logger/prompts/prompt-provider-clack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ export class ClackPromptProvider extends PromptProvider {
logTracker.addLog('info', `${spinnerId}-stop: ${message}`);
task.stop(message);
},
cancel: (message) => {
logTracker.addLog('info', `${spinnerId}-cancel: ${message}`);
task.cancel(message);
},
error: (message) => {
logTracker.addLog('error', `${spinnerId}-error: ${message}`);
task.error(message);
},
};
}

Expand Down
4 changes: 2 additions & 2 deletions code/core/src/node-logger/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ export const executeTaskWithSpinner = async (

if (isAborted) {
logTracker.addLog('info', `${intro} aborted`);
task.stop(CLI_COLORS.warning(`${intro} aborted`));
task.cancel(CLI_COLORS.warning(`${intro} aborted`));
return;
}
const errorMessage = err instanceof Error ? (err.stack ?? err.message) : String(err);
logTracker.addLog('error', error, { error: errorMessage });
task.stop(CLI_COLORS.error(error));
task.error(CLI_COLORS.error(error));
throw err;
} finally {
cleanup?.();
Expand Down
2 changes: 1 addition & 1 deletion code/lib/create-storybook/src/scaffold-new-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const scaffoldNewProject = async (
cwd: targetDir,
});
} catch (e) {
spinner.stop(
spinner.error(
`Failed to create a new "${projectDisplayName}" project with ${packageManagerName}`
);
throw new GenerateNewProjectOnInitError({
Expand Down
20 changes: 10 additions & 10 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2104,24 +2104,24 @@ __metadata:
languageName: node
linkType: hard

"@clack/core@npm:1.0.0-alpha.6":
version: 1.0.0-alpha.6
resolution: "@clack/core@npm:1.0.0-alpha.6"
"@clack/core@npm:1.0.0-alpha.7":
version: 1.0.0-alpha.7
resolution: "@clack/core@npm:1.0.0-alpha.7"
dependencies:
picocolors: "npm:^1.0.0"
sisteransi: "npm:^1.0.5"
checksum: 10c0/5d8949d74bccda55d31510f481a93828f8341e2ecfde1c5809cdd3e5b4d9f2c8fd74e34a3a38062b73fcf8897178edceaa3f884b48943b6473991e878e69eda2
checksum: 10c0/e3d706101c57252d41c77abfb16d1f163bc9e4b81cacbc70c022a859c500ceb7024049d8ff907c8869dcaa9e141e4ef6bb57b83c46027fcdc188072f7b0cc728
languageName: node
linkType: hard

"@clack/prompts@npm:1.0.0-alpha.6":
version: 1.0.0-alpha.6
resolution: "@clack/prompts@npm:1.0.0-alpha.6"
"@clack/prompts@npm:1.0.0-alpha.7":
version: 1.0.0-alpha.7
resolution: "@clack/prompts@npm:1.0.0-alpha.7"
dependencies:
"@clack/core": "npm:1.0.0-alpha.6"
"@clack/core": "npm:1.0.0-alpha.7"
picocolors: "npm:^1.0.0"
sisteransi: "npm:^1.0.5"
checksum: 10c0/c6a18a805aba72ffc879d7870dda28596f5081ccba30808e0e1d7f7cd9c3fad93101ff252de3e0001de564fbe8d162ebd637de2c7c06c39c12301d2d876c9544
checksum: 10c0/21f657868fe538e260f0c79026cca909b51013ad8017a6951869c976dded786383b604db616fed2a799b40c300f7df672fa3e7f4c2e1484819c7fc482b2bd9bb
languageName: node
linkType: hard

Expand Down Expand Up @@ -25878,7 +25878,7 @@ __metadata:
"@babel/parser": "npm:^7.26.9"
"@babel/traverse": "npm:^7.26.9"
"@babel/types": "npm:^7.26.8"
"@clack/prompts": "npm:1.0.0-alpha.6"
"@clack/prompts": "npm:1.0.0-alpha.7"
"@devtools-ds/object-inspector": "npm:^1.1.2"
"@discoveryjs/json-ext": "npm:^0.5.3"
"@emotion/cache": "npm:^11.14.0"
Expand Down
2 changes: 1 addition & 1 deletion scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export const init: Task['run'] = async (
await executeCLIStep(steps.init, {
cwd,
optionValues: {
loglevel: debug ? 'debug' : 'info',
loglevel: 'debug',
yes: true,
...extra,
...(template.initOptions || {}),
Expand Down
Loading