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/prompts import
abortIfCancelled: use consola's cancel Symbol check
cancel() → 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 check
select → logger.prompt(msg, { type: "select", options })
5. formatters.ts (111 lines)
cancel → logger.error
log.* → logger.*
note(body, title) → logger.box({ title, message: body })
outro(text) → logger.success(text) or logger.box(text)
6. wizard-runner.ts (418 lines) — heaviest
cancel → logger.error
confirm → logger.prompt
intro → logger.box
log.* → logger.*
spinner() → consola logger.start/logger.success/logger.fail
- The spinner API differs: clack returns an object with
.start()/.stop()/.message(),
consola uses logger.start(msg) to start and logger.success(msg) to stop.
- The suspend/resume loop uses
spin.message("...") to update the spinner text.
With consola, we can call logger.start(newMsg) to update.
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
isCancel from 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); // error
consola spinner API:
logger.start("Loading..."); // starts spinner
logger.start("Still loading..."); // updates message
logger.success("Done"); // stops with success
logger.fail("Failed"); // stops with failure
The 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.ts from clack-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/prompts from package.json (if no other usage)
- Run tests, typecheck, lint
Port
sentry initto consola + output systemGoal
Replace all
@clack/promptsusage insrc/lib/init/withconsolaequivalents.Remove the
@clack/promptsdependency entirely (or at least from init/).@clack/prompts → consola mapping
intro("text")logger.box("text")outro("text")logger.box("text")orlogger.success("text")cancel("text")logger.error("text")note(body, title)logger.box({ title, message: body })log.info(msg)logger.info(msg)log.warn(msg)logger.warn(msg)log.error(msg)logger.error(msg)spinner()logger.start(msg)/logger.success(msg)confirm({ message })logger.prompt(message, { type: "confirm" })boolean | Symbolselect({ message, options })logger.prompt(message, { type: "select", options })multiselect({ message, options })logger.prompt(message, { type: "multiselect", options })isCancel(value)value === Symbol(clack:cancel)or strict!== trueFiles to change (6 files, ~1826 lines total)
1.
clack-utils.ts(96 lines) → rename towizard-utils.ts@clack/promptsimportabortIfCancelled: use consola's cancel Symbol checkcancel()→logger.error()2.
git.ts(93 lines)confirm→logger.prompt(msg, { type: "confirm" })isCancel→ strict equality check (result !== true)log.info/warn→logger.info/warn3.
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{ 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) — heaviestcancel→logger.errorconfirm→logger.promptintro→logger.boxlog.*→logger.*spinner()→ consolalogger.start/logger.success/logger.fail.start()/.stop()/.message(),consola uses
logger.start(msg)to start andlogger.success(msg)to stop.spin.message("...")to update the spinner text.With consola, we can call
logger.start(newMsg)to update.Cancel handling
Consola's
prompt()returnsSymbol(clack:cancel)on Ctrl+C (it uses @clack/prompts internally).isCancel()from @clack/prompts checks this Symbol. We can either:isCancelfrom consola (if exposed), ortypeof result === "symbol"(simpler, more portable)Spinner replacement
clack spinner API:
consola spinner API:
The 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:Execution order
wizard-utils.tsfromclack-utils.ts(rename, remove clack imports)git.tsinteractive.tslocal-ops.tsformatters.tswizard-runner.ts(spinner is the hard part)clack-utils.ts@clack/promptsfrom package.json (if no other usage)