refactor(cli): share styled select prompt helper

This commit is contained in:
Peter Steinberger
2026-02-18 17:34:38 +00:00
parent 8b48e0c615
commit 005e1d5fd1
4 changed files with 68 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
import { confirm, isCancel, select } from "@clack/prompts";
import { confirm, isCancel } from "@clack/prompts";
import { readConfigFileSnapshot } from "../../config/config.js";
import {
formatUpdateChannelLabel,
@@ -7,7 +7,8 @@ import {
} from "../../infra/update-channels.js";
import { checkUpdateStatus } from "../../infra/update-check.js";
import { defaultRuntime } from "../../runtime.js";
import { stylePromptHint, stylePromptMessage } from "../../terminal/prompt-style.js";
import { selectStyled } from "../../terminal/prompt-select-styled.js";
import { stylePromptMessage } from "../../terminal/prompt-style.js";
import { theme } from "../../terminal/theme.js";
import { pathExists } from "../../utils.js";
import {
@@ -19,15 +20,6 @@ import {
} from "./shared.js";
import { updateCommand } from "./update-command.js";
const selectStyled = <T>(params: Parameters<typeof select<T>>[0]) =>
select({
...params,
message: stylePromptMessage(params.message),
options: params.options.map((opt) =>
opt.hint === undefined ? opt : { ...opt, hint: stylePromptHint(opt.hint) },
),
});
export async function updateWizardCommand(opts: UpdateWizardOptions = {}): Promise<void> {
if (!process.stdin.isTTY) {
defaultRuntime.error(