-
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Port sentry init to consola + output system
Goal
Replace all @clack/prompts usage in src/lib/init/ with consola equivalents.
Remove the @clack/prompts dependency entirely (or at least from init/).
@clack/prompts → consola mapping
| @clack/prompts | consola equivalent | Notes |
|---|---|---|
intro("text") |
logger.box("text") |
Box-styled intro |
outro("text") |
logger.box("text") or logger.success("text") |
Outro styling |
cancel("text") |
logger.error("text") |
Red cancel message |
note(body, title) |
logger.box({ title, message: body }) |
Box with title |
log.info(msg) |
logger.info(msg) |
Direct 1:1 |
log.warn(msg) |
logger.warn(msg) |
Direct 1:1 |
log.error(msg) |
logger.error(msg) |
Direct 1:1 |
spinner() |
logger.start(msg) / logger.success(msg) |
Consola spinner |
confirm({ message }) |
logger.prompt(message, { type: "confirm" }) |
Returns boolean | Symbol |
select({ message, options }) |
logger.prompt(message, { type: "select", options }) |
Options format differs |
multiselect({ message, options }) |
logger.prompt(message, { type: "multiselect", options }) |
Same |
isCancel(value) |
value === Symbol(clack:cancel) or strict !== true |
Consola uses same Symbol |
Files to change (6 files, ~1826 lines total)
1. clack-utils.ts (96 lines) → rename to wizard-utils.ts
- Remove
@clack/promptsimport abortIfCancelled: use consola's cancel Symbol checkcancel()→logger.error()- Keep feature info, labels, sorting (no clack dependency)
2. git.ts (93 lines)
confirm→logger.prompt(msg, { type: "confirm" })isCancel→ strict equality check (result !== true)log.info/warn→logger.info/warn
3. interactive.ts (152 lines)
confirm→logger.prompt(msg, { type: "confirm" })select→logger.prompt(msg, { type: "select", options: [...] })multiselect→logger.prompt(msg, { type: "multiselect", options: [...] })log.info/error→logger.info/error- consola select options:
{ label, value, hint? }(same as clack)
4. local-ops.ts (780 lines)
isCancel→ Symbol checkselect→logger.prompt(msg, { type: "select", options })
5. formatters.ts (111 lines)
cancel→logger.errorlog.*→logger.*note(body, title)→logger.box({ title, message: body })outro(text)→logger.success(text)orlogger.box(text)
6. wizard-runner.ts (418 lines) — heaviest
cancel→logger.errorconfirm→logger.promptintro→logger.boxlog.*→logger.*spinner()→ consolalogger.start/logger.success/logger.fail- The spinner API differs: clack returns an object with
.start()/.stop()/.message(),
consola useslogger.start(msg)to start andlogger.success(msg)to stop. - The suspend/resume loop uses
spin.message("...")to update the spinner text.
With consola, we can calllogger.start(newMsg)to update.
- The spinner API differs: clack returns an object with
Cancel handling
Consola's prompt() returns Symbol(clack:cancel) on Ctrl+C (it uses @clack/prompts internally).
isCancel() from @clack/prompts checks this Symbol. We can either:
- Import
isCancelfrom consola (if exposed), or - Check
typeof result === "symbol"(simpler, more portable)
Spinner replacement
clack spinner API:
const spin = spinner();
spin.start("Loading...");
spin.message("Still loading...");
spin.stop("Done");
spin.stop("Failed", 1); // errorconsola spinner API:
logger.start("Loading..."); // starts spinner
logger.start("Still loading..."); // updates message
logger.success("Done"); // stops with success
logger.fail("Failed"); // stops with failureThe key difference: clack's spinner is an object you pass around; consola's is
method calls on the logger instance. For the wizard runner, which passes the
spinner to handleSuspendedStep, we need to either:
- Pass the logger instance instead
- Create a wrapper that matches the old API
Execution order
- Create
wizard-utils.tsfromclack-utils.ts(rename, remove clack imports) - Migrate
git.ts - Migrate
interactive.ts - Migrate
local-ops.ts - Migrate
formatters.ts - Migrate
wizard-runner.ts(spinner is the hard part) - Delete
clack-utils.ts - Remove
@clack/promptsfrom package.json (if no other usage) - Run tests, typecheck, lint
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request