refactor(cli): share styled select prompt helper
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user