Compare commits

...

17 Commits

Author SHA1 Message Date
Austin Merrick
3d1afb8f63 Update usage of input prompts 2024-03-28 09:19:07 -07:00
Austin Merrick
4e8da2c60c Create input abstraction 2024-03-28 09:18:42 -07:00
Austin Merrick
8706d857a9 Update tests 2024-03-28 09:12:04 -07:00
Austin Merrick
8b903da18c Use components 2024-03-28 09:11:52 -07:00
Erika Rowland
7c693edef5 Add custom components 2024-03-28 09:11:29 -07:00
Austin Merrick
fa467e3613 Prepare for custom inputs 2024-03-27 17:39:31 -07:00
Austin Merrick
75d85e0f4a Move @inquirer/prompts to devDependencies 2024-03-26 12:08:49 -07:00
Austin Merrick
909d36fef3 Merge branch 'main' into austinmerrick/zero-1580-replace-inquirer-dependency-with-inquirerprompts-or 2024-03-26 11:08:33 -07:00
Austin Merrick
fa425339d0 Add changeset 2024-03-26 10:39:58 -07:00
Austin Merrick
d2396b0cf9 Update integration tests 2024-03-26 10:39:58 -07:00
Austin Merrick
7a8101e3bd Remove problematic test
The usage of `jest.useFakeTimers().setSystemTime(new Date('2023-12-08'));` makes the "should remove a project" test fail. Really strange behavior so not sure why.
2024-03-26 10:39:58 -07:00
Austin Merrick
7023ea0d64 Remove inquirer dependency 2024-03-26 10:39:58 -07:00
Austin Merrick
b7cb5c6ae3 Remove usage of old inquirer 2024-03-26 10:39:58 -07:00
Austin Merrick
c87bd35e69 Update unit tests 2024-03-26 10:39:58 -07:00
Austin Merrick
f8a3b43bed Convert client.prompt instances to use new API 2024-03-26 10:39:58 -07:00
Austin Merrick
bdf338b790 Expose inquirer prompts from client 2024-03-26 10:37:04 -07:00
Austin Merrick
9481572c6d Install @inquirer/prompts 2024-03-20 12:27:44 -07:00
37 changed files with 1526 additions and 462 deletions

View File

@@ -0,0 +1,5 @@
---
'vercel': patch
---
Replace `inquirer` with `@inquirer/prompts`

View File

@@ -47,6 +47,9 @@
"devDependencies": {
"@alex_neo/jest-expect-message": "1.0.5",
"@edge-runtime/node-utils": "2.3.0",
"@inquirer/core": "7.1.0",
"@inquirer/prompts": "4.3.0",
"@inquirer/type": "1.2.1",
"@next/env": "11.1.2",
"@sentry/node": "5.5.0",
"@sindresorhus/slugify": "0.11.0",
@@ -126,7 +129,6 @@
"glob": "7.1.2",
"http-proxy": "1.18.1",
"ini": "3.0.0",
"inquirer": "7.0.4",
"is-docker": "2.2.1",
"is-port-reachable": "3.1.0",
"is-url": "1.2.2",

View File

@@ -278,9 +278,7 @@ export default async function bisect(client: Client): Promise<number> {
if (openEnabled) {
await open(testUrl);
}
const answer = await client.prompt({
type: 'expand',
name: 'action',
action = await client.input.expand({
message: 'Select an action:',
choices: [
{ key: 'g', name: 'Good', value: 'good' },
@@ -288,7 +286,6 @@ export default async function bisect(client: Client): Promise<number> {
{ key: 's', name: 'Skip', value: 'skip' },
],
});
action = answer.action;
}
if (action === 'good') {
@@ -342,11 +339,7 @@ function getCommit(deployment: Deployment) {
async function prompt(client: Client, message: string): Promise<string> {
// eslint-disable-next-line no-constant-condition
while (true) {
const { val } = await client.prompt({
type: 'input',
name: 'val',
message,
});
const val = await client.input.text({ message });
if (val) {
return val;
} else {

View File

@@ -102,7 +102,7 @@ function readConfirmation(output: Output, msg: string, certs: Cert[]) {
}).replace(/^(.*)/gm, ' $1')}\n`
);
output.print(
`${chalk.bold.red('> Are you sure?')} ${chalk.gray('[y/N] ')}`
`${chalk.bold.red('> Are you sure?')} ${chalk.gray('(y/N) ')}`
);
process.stdin
.on('data', d => {

View File

@@ -75,7 +75,7 @@ function readConfirmation(
}).replace(/^(.*)/gm, ' $1')}\n`
);
output.print(
`${chalk.bold.red('> Are you sure?')} ${chalk.gray('[y/N] ')}`
`${chalk.bold.red('> Are you sure?')} ${chalk.gray('(y/N) ')}`
);
process.stdin
.on('data', d => {

View File

@@ -29,9 +29,6 @@ export default async function add(
args: string[],
output: Output
) {
// improve the way we show inquirer prompts
require('../../util/input/patch-inquirer');
const stdInput = await readStandardInput(client.stdin);
let [envName, envTargetArg, envGitBranch] = args;
@@ -67,15 +64,11 @@ export default async function add(
}
while (!envName) {
const { inputName } = await client.prompt({
type: 'input',
name: 'inputName',
envName = await client.input({
message: `Whats the name of the variable?`,
});
envName = inputName;
if (!inputName) {
if (!envName) {
output.error('Name cannot be empty');
}
}
@@ -107,9 +100,7 @@ export default async function add(
if (stdInput) {
envValue = stdInput;
} else {
const { inputValue } = await client.prompt({
type: 'input',
name: 'inputValue',
const inputValue = await client.input.text({
message: `Whats the value of ${envName}?`,
});
@@ -117,16 +108,12 @@ export default async function add(
}
while (envTargets.length === 0) {
const { inputTargets } = await client.prompt({
name: 'inputTargets',
type: 'checkbox',
envTargets = await client.input.checkbox({
message: `Add ${envName} to which Environments (select multiple)?`,
choices,
});
envTargets = inputTargets;
if (inputTargets.length === 0) {
if (envTargets.length === 0) {
output.error('Please select at least one Environment');
}
}
@@ -137,9 +124,7 @@ export default async function add(
envTargets.length === 1 &&
envTargets[0] === 'preview'
) {
const { inputValue } = await client.prompt({
type: 'input',
name: 'inputValue',
const inputValue = await client.input.text({
message: `Add ${envName} to which Git branch? (leave empty for all Preview branches)?`,
});
envGitBranch = inputValue || '';

View File

@@ -29,9 +29,6 @@ export default async function rm(
args: string[],
output: Output
) {
// improve the way we show inquirer prompts
require('../../util/input/patch-inquirer');
if (args.length > 3) {
output.error(
`Invalid number of arguments. Usage: ${getCommandName(
@@ -44,9 +41,7 @@ export default async function rm(
let [envName, envTarget, envGitBranch] = args;
while (!envName) {
const { inputName } = await client.prompt({
type: 'input',
name: 'inputName',
const inputName = await client.input({
message: `Whats the name of the variable?`,
});
@@ -86,9 +81,7 @@ export default async function rm(
}
while (envs.length > 1) {
const { id } = await client.prompt({
name: 'id',
type: 'list',
const id = await client.select({
message: `Remove ${envName} from which Environments?`,
choices: envs.map(env => ({ value: env.id, name: formatEnvTarget(env) })),
});

View File

@@ -277,7 +277,7 @@ function readConfirmation(
}
output.print(
`${chalk.bold.red('> Are you sure?')} ${chalk.gray('[y/N] ')}`
`${chalk.bold.red('> Are you sure?')} ${chalk.gray('(y/N) ')}`
);
process.stdin

View File

@@ -1,5 +1,9 @@
import { bold } from 'chalk';
import inquirer from 'inquirer';
import input from './custom-input/input';
import select from './custom-input/select';
import checkbox from './custom-input/checkbox';
import expand from './custom-input/expand';
import confirm from './custom-input/confirm';
import { EventEmitter } from 'events';
import { URL } from 'url';
import { VercelConfig } from '@vercel/client';
@@ -66,8 +70,8 @@ export default class Client extends EventEmitter implements Stdio {
agent?: Agent;
localConfig?: VercelConfig;
localConfigPath?: string;
prompt!: inquirer.PromptModule;
requestIdCounter: number;
input;
constructor(opts: ClientOptions) {
super();
@@ -83,7 +87,18 @@ export default class Client extends EventEmitter implements Stdio {
this.localConfig = opts.localConfig;
this.localConfigPath = opts.localConfigPath;
this.requestIdCounter = 1;
this._createPromptModule();
this.input = {
text: (opts: Parameters<typeof input>[0]) =>
input(opts, { input: this.stdin, output: this.stderr }),
checkbox: <T>(opts: Parameters<typeof checkbox<T>>[0]) =>
checkbox<T>(opts, { input: this.stdin, output: this.stderr }),
expand: (opts: Parameters<typeof expand>[0]) =>
expand(opts, { input: this.stdin, output: this.stderr }),
confirm: (opts: Parameters<typeof confirm>[0]) =>
confirm(opts, { input: this.stdin, output: this.stderr }),
select: <T>(opts: Parameters<typeof select<T>>[0]) =>
select<T>(opts, { input: this.stdin, output: this.stderr }),
};
}
retry<T>(fn: RetryFunction<T>, { retries = 3, maxTimeout = Infinity } = {}) {
@@ -229,13 +244,6 @@ export default class Client extends EventEmitter implements Stdio {
this.output.debug(`Retrying: ${error}\n${error.stack}`);
};
_createPromptModule() {
this.prompt = inquirer.createPromptModule({
input: this.stdin as NodeJS.ReadStream,
output: this.stderr as NodeJS.WriteStream,
});
}
get cwd(): string {
return process.cwd();
}

View File

@@ -0,0 +1,272 @@
import {
createPrompt,
useState,
useKeypress,
usePrefix,
usePagination,
useMemo,
makeTheme,
isUpKey,
isDownKey,
isSpaceKey,
isNumberKey,
isEnterKey,
ValidationError,
Separator,
type Theme,
} from '@inquirer/core';
import type { PartialDeep } from '@inquirer/type';
import chalk from 'chalk';
import figures from './util/figures';
import ansiEscapes from 'ansi-escapes';
import isUnicodeSupported from './util/is-unicode-supported';
const unicode = isUnicodeSupported();
const s = (c: string, fallback: string) => (unicode ? c : fallback);
const S_STEP_ACTIVE = s('◆', '*');
const S_STEP_SUBMIT = s('◇', 'o');
const S_BAR = s('│', '|');
const S_CHECKBOX_SELECTED = s('◼', '[+]');
const S_CHECKBOX_INACTIVE = s('◻', '[ ]');
type Status = 'pending' | 'done';
const symbol = (state: Status) => {
switch (state) {
case 'pending':
return chalk.cyan(S_STEP_ACTIVE);
case 'done':
return chalk.green(S_STEP_SUBMIT);
}
};
type CheckboxTheme = {
icon: {
checked: string;
unchecked: string;
cursor: string;
};
style: {
disabledChoice: (text: string) => string;
renderSelectedChoices: <T>(
selectedChoices: ReadonlyArray<Choice<T>>,
allChoices: ReadonlyArray<Choice<T> | Separator>
) => string;
};
};
const checkboxTheme: CheckboxTheme = {
icon: {
checked: chalk.green(figures.circleFilled),
unchecked: figures.circle,
cursor: figures.pointer,
},
style: {
disabledChoice: (text: string) => chalk.dim(`- ${text}`),
renderSelectedChoices: selectedChoices =>
selectedChoices.map(choice => choice.name || choice.value).join(', '),
},
};
type Choice<Value> = {
name?: string;
value: Value;
disabled?: boolean | string;
checked?: boolean;
type?: never;
};
type Config<Value> = {
message: string;
prefix?: string;
pageSize?: number;
instructions?: string | boolean;
choices: ReadonlyArray<Choice<Value> | Separator>;
loop?: boolean;
required?: boolean;
validate?: (
items: ReadonlyArray<Item<Value>>
) => boolean | string | Promise<string | boolean>;
theme?: PartialDeep<Theme<CheckboxTheme>>;
};
type Item<Value> = Separator | Choice<Value>;
function isSelectable<Value>(item: Item<Value>): item is Choice<Value> {
return !Separator.isSeparator(item) && !item.disabled;
}
function isChecked<Value>(item: Item<Value>): item is Choice<Value> {
return isSelectable(item) && Boolean(item.checked);
}
function toggle<Value>(item: Item<Value>): Item<Value> {
return isSelectable(item) ? { ...item, checked: !item.checked } : item;
}
function check(checked: boolean) {
return function <Value>(item: Item<Value>): Item<Value> {
return isSelectable(item) ? { ...item, checked } : item;
};
}
export default createPrompt(
<Value>(config: Config<Value>, done: (value: Array<Value>) => void) => {
const {
instructions,
pageSize = 7,
loop = true,
choices,
required,
validate = () => true,
} = config;
const theme = makeTheme<CheckboxTheme>(checkboxTheme, config.theme);
const prefix = usePrefix({ theme });
const [status, setStatus] = useState<Status>('pending');
const [items, setItems] = useState<ReadonlyArray<Item<Value>>>(
choices.map(choice => ({ ...choice }))
);
const bounds = useMemo(() => {
const first = items.findIndex(isSelectable);
// TODO: Replace with `findLastIndex` when it's available.
const last =
items.length - 1 - [...items].reverse().findIndex(isSelectable);
if (first < 0) {
throw new ValidationError(
'[checkbox prompt] No selectable choices. All choices are disabled.'
);
}
return { first, last };
}, [items]);
const [active, setActive] = useState(bounds.first);
const [showHelpTip, setShowHelpTip] = useState(true);
const [errorMsg, setError] = useState<string | undefined>(undefined);
useKeypress(async key => {
if (isEnterKey(key)) {
const selection = items.filter(isChecked);
const isValid = await validate([...selection]);
if (required && !items.some(isChecked)) {
setError('At least one choice must be selected');
} else if (isValid === true) {
setStatus('done');
done(selection.map(choice => choice.value));
} else {
setError(isValid || 'You must select a valid value');
}
} else if (isUpKey(key) || isDownKey(key)) {
if (
loop ||
(isUpKey(key) && active !== bounds.first) ||
(isDownKey(key) && active !== bounds.last)
) {
const offset = isUpKey(key) ? -1 : 1;
let next = active;
do {
next = (next + offset + items.length) % items.length;
} while (!isSelectable(items[next]!));
setActive(next);
}
} else if (isSpaceKey(key)) {
setError(undefined);
setShowHelpTip(false);
setItems(
items.map((choice, i) => (i === active ? toggle(choice) : choice))
);
} else if (key.name === 'a') {
const selectAll = Boolean(
items.find(choice => isSelectable(choice) && !choice.checked)
);
setItems(items.map(check(selectAll)));
} else if (key.name === 'i') {
setItems(items.map(toggle));
} else if (isNumberKey(key)) {
// Adjust index to start at 1
const position = Number(key.name) - 1;
const item = items[position];
if (item != null && isSelectable(item)) {
setActive(position);
setItems(
items.map((choice, i) => (i === position ? toggle(choice) : choice))
);
}
}
});
const message = theme.style.message(config.message);
const page = usePagination<Item<Value>>({
items,
active,
renderItem({ item, isActive }: { item: Item<Value>; isActive: boolean }) {
if (Separator.isSeparator(item)) {
return `${chalk.cyan(S_BAR)} ${item.separator}`;
}
const line = item.name || item.value;
if (item.disabled) {
const disabledLabel =
typeof item.disabled === 'string' ? item.disabled : '(disabled)';
return `${chalk.cyan(S_BAR)} ${theme.style.disabledChoice(
`${line} ${disabledLabel}`
)}`;
}
const checkbox = item.checked
? S_CHECKBOX_SELECTED
: S_CHECKBOX_INACTIVE;
const color = isActive ? theme.style.highlight : (x: string) => x;
// const cursor = isActive ? " " : " ";
return `${chalk.cyan(S_BAR)} ${color(`${checkbox} ${line}`)}`;
},
pageSize,
loop,
theme,
});
let helpTip = '';
if (showHelpTip && (instructions === undefined || instructions)) {
if (typeof instructions === 'string') {
helpTip = instructions;
} else {
const keys = [
`${theme.style.key('space')} to select`,
`${theme.style.key('a')} to toggle all`,
`${theme.style.key('i')} to invert selection`,
`and ${theme.style.key('enter')} to proceed`,
];
helpTip = ` (Press ${keys.join(', ')})`;
}
}
const title_basic = `${chalk.gray(S_BAR)}\n${symbol(
status
)} ${prefix} ${message}`;
const title_with_help = `${title_basic}${helpTip}\n`;
const title_without_help = `${title_basic}\n`;
if (status === 'done') {
const selection = items.filter(isChecked);
const answer = theme.style.answer(
theme.style.renderSelectedChoices(selection, items)
);
return `${title_without_help}${chalk.gray(S_BAR)} ${answer}`;
}
let error = '';
if (errorMsg) {
error = theme.style.error(errorMsg);
}
return `${title_with_help}${page}\n${error}${ansiEscapes.cursorHide}`;
}
);
export { Separator };

View File

@@ -0,0 +1,128 @@
import {
createPrompt,
useState,
useKeypress,
isEnterKey,
makeTheme,
isUpKey,
isDownKey,
type Theme,
type KeypressEvent,
} from '@inquirer/core';
import type { PartialDeep } from '@inquirer/type';
import isUnicodeSupported from './util/is-unicode-supported';
import chalk from 'chalk';
import ansiEscapes from 'ansi-escapes';
const unicode = isUnicodeSupported();
const s = (c: string, fallback: string) => (unicode ? c : fallback);
const S_STEP_ACTIVE = s('◆', '*');
const S_STEP_SUBMIT = s('◇', 'o');
const S_BAR = s('│', '|');
const S_BAR_END = s('└', '—');
const S_RADIO_ACTIVE = s('●', '>');
const S_RADIO_INACTIVE = s('○', ' ');
type Status = 'pending' | 'done';
const symbol = (state: Status) => {
switch (state) {
case 'pending':
return chalk.cyan(S_STEP_ACTIVE);
case 'done':
return chalk.green(S_STEP_SUBMIT);
}
};
type ConfirmConfig = {
message: string;
default?: CursorState;
active?: string;
inactive?: string;
transformer?: (value: boolean) => string;
theme?: PartialDeep<Theme>;
};
const isLeftKey = (key: KeypressEvent): boolean =>
// The left key
key.name === 'left' ||
// Vim keybinding
key.name === 'h' ||
// Emacs keybinding
(key.ctrl && key.name === 'b');
const isRightKey = (key: KeypressEvent): boolean =>
// The right key
key.name === 'right' ||
// Vim keybinding
key.name === 'l' ||
// Emacs keybinding
(key.ctrl && key.name === 'f');
export type CursorState = 'yes' | 'no';
export default createPrompt<boolean, ConfirmConfig>((config, done) => {
const { transformer = answer => (answer ? 'yes' : 'no') } = config;
const [status, setStatus] = useState<Status>('pending');
const [value, setValue] = useState('');
const [cursorStatus, setCursorStatus] = useState<CursorState>(
(config.default ? 'yes' : 'no') ?? 'yes'
);
const theme = makeTheme(config.theme);
const active = config.active ?? 'Yes';
const inactive = config.active ?? 'No';
const toggle = (cursor_state: CursorState): CursorState => {
if (cursor_state === 'yes') {
return 'no';
} else {
return 'yes';
}
};
useKeypress(key => {
if (isEnterKey(key)) {
let answer = cursorStatus === 'yes';
setValue(transformer(answer));
setStatus('done');
done(answer);
} else if (
isUpKey(key) ||
isDownKey(key) ||
isLeftKey(key) ||
isRightKey(key)
) {
setCursorStatus(toggle(cursorStatus));
// setValue(rl.line);
}
});
const message = theme.style.message(config.message);
const title = `${chalk.gray(S_BAR)}\n${symbol(status)} ${message}\n`;
const output = (status: Status) => {
switch (status) {
case 'done':
return `${title}${chalk.gray(S_BAR)} ${chalk.dim(
value === 'yes' ? active : inactive
)}`;
default:
return `${title}${chalk.cyan(S_BAR)} ${
cursorStatus === 'yes'
? `${chalk.green(S_RADIO_ACTIVE)} ${active}`
: `${chalk.dim(S_RADIO_INACTIVE)} ${chalk.dim(active)}`
} ${chalk.dim('/')} ${
cursorStatus === 'no'
? `${chalk.green(S_RADIO_ACTIVE)} ${inactive}`
: `${chalk.dim(S_RADIO_INACTIVE)} ${chalk.dim(inactive)}`
} \n${chalk.cyan(S_BAR_END)} \n${ansiEscapes.cursorHide} `;
}
};
return output(status);
});

View File

@@ -0,0 +1,161 @@
import {
createPrompt,
useState,
useKeypress,
usePrefix,
isEnterKey,
makeTheme,
type Theme,
} from '@inquirer/core';
import type { PartialDeep } from '@inquirer/type';
import chalk from 'chalk';
import isUnicodeSupported from './util/is-unicode-supported';
const unicode = isUnicodeSupported();
const s = (c: string, fallback: string) => (unicode ? c : fallback);
const S_STEP_ACTIVE = s('◆', '*');
const S_STEP_SUBMIT = s('◇', 'o');
const S_BAR = s('│', '|');
const S_BAR_END = s('└', '—');
type Status = 'pending' | 'done';
const symbol = (state: Status) => {
switch (state) {
case 'pending':
return chalk.cyan(S_STEP_ACTIVE);
case 'done':
return chalk.green(S_STEP_SUBMIT);
}
};
type ExpandChoice =
| { key: string; name: string }
| { key: string; value: string }
| { key: string; name: string; value: string };
type ExpandConfig = {
message: string;
choices: ReadonlyArray<ExpandChoice>;
default?: string;
expanded?: boolean;
theme?: PartialDeep<Theme>;
};
const helpChoice = {
key: 'h',
name: 'Help, list all options',
value: undefined,
};
function getChoiceKey(choice: ExpandChoice, key: 'name' | 'value'): string {
if (key === 'name') {
if ('name' in choice) return choice.name;
return choice.value;
}
if ('value' in choice) return choice.value;
return choice.name;
}
export default createPrompt<string, ExpandConfig>((config, done) => {
const {
choices,
default: defaultKey = 'h',
expanded: defaultExpandState = false,
} = config;
const [status, setStatus] = useState<string>('pending');
const [value, setValue] = useState<string>('');
const [expanded, setExpanded] = useState<boolean>(defaultExpandState);
const [errorMsg, setError] = useState<string | undefined>(undefined);
const theme = makeTheme(config.theme);
const prefix = usePrefix({ theme });
useKeypress((event, rl) => {
if (isEnterKey(event)) {
const answer = (value || defaultKey).toLowerCase();
if (answer === 'h' && !expanded) {
setExpanded(true);
} else {
const selectedChoice = choices.find(({ key }) => key === answer);
if (selectedChoice) {
const finalValue = getChoiceKey(selectedChoice, 'value');
setValue(finalValue);
setStatus('done');
done(finalValue);
} else if (value === '') {
setError('Please input a value');
} else {
setError(`"${chalk.red(value)}" isn't an available option`);
}
}
} else {
setValue(rl.line);
setError(undefined);
}
});
const message = theme.style.message(config.message);
const title = `${chalk.gray(S_BAR)}\n${symbol(status)} ${prefix} ${message}`;
if (status === 'done') {
// TODO: `value` should be the display name instead of the raw value.
return `${title}\n${chalk.gray(S_BAR)} ${theme.style.answer(value)}`;
}
const allChoices = expanded ? choices : [...choices, helpChoice];
// Collapsed display style
let longChoices = '';
let shortChoices = allChoices
.map(choice => {
if (choice.key === defaultKey) {
return choice.key.toUpperCase();
}
return choice.key;
})
.join('');
shortChoices = ` ${theme.style.defaultAnswer(shortChoices)}`;
// Expanded display style
if (expanded) {
shortChoices = '';
longChoices = allChoices
.map(choice => {
const line = ` ${choice.key}) ${getChoiceKey(choice, 'name')}`;
if (choice.key === value.toLowerCase()) {
return `${chalk.cyan(S_BAR)} ${theme.style.highlight(line)}`;
}
return `${chalk.cyan(S_BAR)} ${line}`;
})
.join('\n');
}
let helpTip = '';
const currentOption = allChoices.find(
({ key }) => key === value.toLowerCase()
);
if (currentOption) {
helpTip = `${chalk.cyan(S_BAR)} ${chalk.cyan('>>')} ${getChoiceKey(
currentOption,
'name'
)} `;
}
let error = '';
if (errorMsg) {
error = theme.style.error(errorMsg);
}
return [
`${title}${shortChoices} \n${chalk.cyan(S_BAR)} ${value}`,
`${[longChoices, helpTip, error, chalk.cyan(S_BAR_END)]
.filter(Boolean)
.join('\n')}`,
];
});

View File

@@ -0,0 +1,129 @@
import {
createPrompt,
useState,
useKeypress,
isEnterKey,
isBackspaceKey,
makeTheme,
type Theme,
} from '@inquirer/core';
import type { PartialDeep } from '@inquirer/type';
import chalk from 'chalk';
import ansiEscapes from 'ansi-escapes';
import isUnicodeSupported from './util/is-unicode-supported';
const unicode = isUnicodeSupported();
const s = (c: string, fallback: string) => (unicode ? c : fallback);
const S_STEP_ACTIVE = s('◆', '*');
const S_STEP_CANCEL = s('■', 'x');
const S_STEP_SUBMIT = s('◇', 'o');
const S_BAR = s('│', '|');
const S_BAR_END = s('└', '—');
type InputConfig = {
message: string;
default?: string;
transformer?: (value: string, { isFinal }: { isFinal: boolean }) => string;
validate?: (value: string) => boolean | string | Promise<string | boolean>;
theme?: PartialDeep<Theme>;
};
type Status = 'pending' | 'loading' | 'done';
const symbol = (state: Status) => {
switch (state) {
case 'pending':
return chalk.cyan(S_STEP_ACTIVE);
case 'loading':
return chalk.red(S_STEP_CANCEL);
case 'done':
return chalk.green(S_STEP_SUBMIT);
}
};
export default createPrompt<string, InputConfig>((config, done) => {
const { validate = () => true } = config;
const theme = makeTheme(config.theme);
const [status, setStatus] = useState<Status>('pending');
const [cursorIndex, setCursorIndex] = useState<number>(0);
const [defaultValue = '', setDefaultValue] = useState<string>(
config.default || ''
);
const [errorMsg, setError] = useState<string | undefined>(undefined);
const [value, setValue] = useState<string>('');
useKeypress(async (key, rl) => {
// Ignore keypress while our prompt is doing other processing.
if (status !== 'pending') {
return;
}
setCursorIndex(rl.cursor);
if (isEnterKey(key)) {
const answer = value || defaultValue;
setStatus('loading');
const isValid = await validate(answer);
if (isValid === true) {
setValue(answer);
setStatus('done');
done(answer);
} else {
// Reset the readline line value to the previous value. On line event, the value
// get cleared, forcing the user to re-enter the value instead of fixing it.
rl.write(value);
setError(isValid || 'You must provide a valid value');
setStatus('pending');
}
} else if (isBackspaceKey(key) && !value) {
setDefaultValue('');
} else if (key.name === 'tab' && !value) {
setDefaultValue('');
rl.clearLine(0); // Remove the tab character.
rl.write(defaultValue);
setValue(defaultValue);
} else {
setValue(rl.line);
setError(undefined);
}
});
const message = theme.style.message(config.message);
let formattedValue = value;
if (typeof config.transformer === 'function') {
formattedValue = config.transformer(value, { isFinal: status === 'done' });
} else if (status === 'done') {
formattedValue = theme.style.answer(value);
}
let error = '';
if (errorMsg) {
error = theme.style.error(errorMsg);
}
let valueWithCursor: any;
if (cursorIndex && cursorIndex >= value.length) {
valueWithCursor = `${value}${chalk.inverse(chalk.hidden(' '))}`;
} else {
const s1 = value.slice(0, cursorIndex);
const s2 = value.slice(cursorIndex);
if (s2.length !== 0)
valueWithCursor = `${s1}${chalk.inverse(s2[0])}${s2.slice(1)}`;
else valueWithCursor = `${s1}${chalk.inverse(' ')}`;
}
const title = `${chalk.gray(S_BAR)}\n${symbol(status)} ${message}\n`;
const output = (status: any) => {
switch (status) {
case 'done':
return `${title}${chalk.gray(S_BAR)} ${formattedValue}`;
default:
return `${title}${chalk.cyan(S_BAR)} ${valueWithCursor}\n${chalk.cyan(
S_BAR_END
)}\n${ansiEscapes.cursorHide}`;
}
};
return [output(status), error];
});

View File

@@ -0,0 +1,229 @@
import {
createPrompt,
useState,
useKeypress,
usePrefix,
usePagination,
useRef,
useMemo,
isBackspaceKey,
isEnterKey,
isUpKey,
isDownKey,
isNumberKey,
Separator,
ValidationError,
makeTheme,
type Theme,
} from '@inquirer/core';
import type { PartialDeep } from '@inquirer/type';
import chalk from 'chalk';
import figures from './util/figures';
import ansiEscapes from 'ansi-escapes';
import isUnicodeSupported from './util/is-unicode-supported';
const unicode = isUnicodeSupported();
const s = (c: string, fallback: string) => (unicode ? c : fallback);
const S_STEP_ACTIVE = s('◆', '*');
const S_STEP_SUBMIT = s('◇', 'o');
const S_BAR = s('│', '|');
const S_BAR_END = s('└', '—');
const S_RADIO_ACTIVE = s('●', '>');
const S_RADIO_INACTIVE = s('○', ' ');
type SelectTheme = {
icon: { cursor: string };
style: { disabled: (text: string) => string };
};
const selectTheme: SelectTheme = {
icon: { cursor: figures.pointer },
style: { disabled: (text: string) => chalk.dim(`- ${text}`) },
};
type Choice<Value> = {
value: Value;
name?: string;
description?: string;
disabled?: boolean | string;
type?: never;
};
type SelectConfig<Value> = {
message: string;
choices: ReadonlyArray<Choice<Value> | Separator>;
pageSize?: number;
loop?: boolean;
default?: unknown;
theme?: PartialDeep<Theme<SelectTheme>>;
};
type Item<Value> = Separator | Choice<Value>;
function isSelectable<Value>(item: Item<Value>): item is Choice<Value> {
return !Separator.isSeparator(item) && !item.disabled;
}
type Status = 'pending' | 'done';
const symbol = (state: Status) => {
switch (state) {
case 'pending':
return chalk.cyan(S_STEP_ACTIVE);
case 'done':
return chalk.green(S_STEP_SUBMIT);
}
};
export default createPrompt(
<Value>(
config: SelectConfig<Value>,
done: (value: Value) => void
): string => {
const { choices: items, loop = true, pageSize = 7 } = config;
const firstRender = useRef(true);
const theme = makeTheme<SelectTheme>(selectTheme, config.theme);
const prefix = usePrefix({ theme });
const [status, setStatus] = useState<Status>('pending');
const searchTimeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(
undefined
);
const bounds = useMemo(() => {
const first = items.findIndex(isSelectable);
// TODO: Replace with `findLastIndex` when it's available.
const last =
items.length - 1 - [...items].reverse().findIndex(isSelectable);
if (first < 0)
throw new ValidationError(
'[select prompt] No selectable choices. All choices are disabled.'
);
return { first, last };
}, [items]);
const defaultItemIndex = useMemo(() => {
if (!('default' in config)) return -1;
return items.findIndex(
item => isSelectable(item) && item.value === config.default
);
}, [config.default, items]);
const [active, setActive] = useState(
defaultItemIndex === -1 ? bounds.first : defaultItemIndex
);
// Safe to assume the cursor position always point to a Choice.
const selectedChoice = items[active] as Choice<Value>;
useKeypress((key, rl) => {
clearTimeout(searchTimeoutRef.current);
if (isEnterKey(key)) {
setStatus('done');
done(selectedChoice.value);
} else if (isUpKey(key) || isDownKey(key)) {
rl.clearLine(0);
if (
loop ||
(isUpKey(key) && active !== bounds.first) ||
(isDownKey(key) && active !== bounds.last)
) {
const offset = isUpKey(key) ? -1 : 1;
let next = active;
do {
next = (next + offset + items.length) % items.length;
} while (!isSelectable(items[next]!));
setActive(next);
}
} else if (isNumberKey(key)) {
rl.clearLine(0);
const position = Number(key.name) - 1;
const item = items[position];
if (item != null && isSelectable(item)) {
setActive(position);
}
} else if (isBackspaceKey(key)) {
rl.clearLine(0);
} else {
// Default to search
const searchTerm = rl.line.toLowerCase();
const matchIndex = items.findIndex(item => {
if (Separator.isSeparator(item) || !isSelectable(item)) return false;
return String(item.name || item.value)
.toLowerCase()
.startsWith(searchTerm);
});
if (matchIndex >= 0) {
setActive(matchIndex);
}
searchTimeoutRef.current = setTimeout(() => {
rl.clearLine(0);
}, 700);
}
});
const message = theme.style.message(config.message);
let helpTip;
if (firstRender.current && items.length <= pageSize) {
firstRender.current = false;
helpTip = theme.style.help('(Use arrow keys)');
}
const page = usePagination<Item<Value>>({
items,
active,
renderItem({ item, isActive }: { item: Item<Value>; isActive: boolean }) {
if (Separator.isSeparator(item)) {
return `${chalk.cyan(S_BAR)} ${item.separator}`;
}
const line = item.name || item.value;
if (item.disabled) {
const disabledLabel =
typeof item.disabled === 'string' ? item.disabled : '(disabled)';
return theme.style.disabled(`${line} ${disabledLabel}`);
}
const color = isActive ? theme.style.highlight : (x: string) => x;
const cursor = isActive ? S_RADIO_ACTIVE : S_RADIO_INACTIVE;
return `${chalk.cyan(S_BAR)} ${color(`${cursor} ${line}`)}`;
},
pageSize,
loop,
theme,
});
const title = `${chalk.gray(S_BAR)}\n${symbol(status)} ${[
prefix,
message,
helpTip,
]
.filter(Boolean)
.join(' ')}\n`;
if (status === 'done') {
const answer =
selectedChoice.name ||
// TODO: Could we enforce that at the type level? Name should be defined for non-string values.
String(selectedChoice.value);
return `${title}${chalk.gray(S_BAR)} ${theme.style.answer(answer)}`;
}
const choiceDescription = selectedChoice.description
? `\n${selectedChoice.description}`
: ``;
return `${title}${page}${choiceDescription}\n${chalk.cyan(S_BAR_END)}${
ansiEscapes.cursorHide
} `;
}
);
export { Separator };

View File

@@ -0,0 +1,307 @@
/*
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import isUnicodeSupported from './is-unicode-supported';
const common = {
circleQuestionMark: '(?)',
questionMarkPrefix: '(?)',
square: '█',
squareDarkShade: '▓',
squareMediumShade: '▒',
squareLightShade: '░',
squareTop: '▀',
squareBottom: '▄',
squareLeft: '▌',
squareRight: '▐',
squareCenter: '■',
bullet: '●',
dot: '',
ellipsis: '…',
pointerSmall: '',
triangleUp: '▲',
triangleUpSmall: '▴',
triangleDown: '▼',
triangleDownSmall: '▾',
triangleLeftSmall: '◂',
triangleRightSmall: '▸',
home: '⌂',
heart: '♥',
musicNote: '♪',
musicNoteBeamed: '♫',
arrowUp: '↑',
arrowDown: '↓',
arrowLeft: '←',
arrowRight: '→',
arrowLeftRight: '↔',
arrowUpDown: '↕',
almostEqual: '≈',
notEqual: '≠',
lessOrEqual: '≤',
greaterOrEqual: '≥',
identical: '≡',
infinity: '∞',
subscriptZero: '₀',
subscriptOne: '₁',
subscriptTwo: '₂',
subscriptThree: '₃',
subscriptFour: '₄',
subscriptFive: '₅',
subscriptSix: '₆',
subscriptSeven: '₇',
subscriptEight: '₈',
subscriptNine: '₉',
oneHalf: '½',
oneThird: '⅓',
oneQuarter: '¼',
oneFifth: '⅕',
oneSixth: '⅙',
oneEighth: '⅛',
twoThirds: '⅔',
twoFifths: '⅖',
threeQuarters: '¾',
threeFifths: '⅗',
threeEighths: '⅜',
fourFifths: '⅘',
fiveSixths: '⅚',
fiveEighths: '⅝',
sevenEighths: '⅞',
line: '─',
lineBold: '━',
lineDouble: '═',
lineDashed0: '┄',
lineDashed1: '┅',
lineDashed2: '┈',
lineDashed3: '┉',
lineDashed4: '╌',
lineDashed5: '╍',
lineDashed6: '╴',
lineDashed7: '╶',
lineDashed8: '╸',
lineDashed9: '╺',
lineDashed10: '╼',
lineDashed11: '╾',
lineDashed12: '',
lineDashed13: '',
lineDashed14: '',
lineDashed15: '',
lineVertical: '│',
lineVerticalBold: '┃',
lineVerticalDouble: '║',
lineVerticalDashed0: '┆',
lineVerticalDashed1: '┇',
lineVerticalDashed2: '┊',
lineVerticalDashed3: '┋',
lineVerticalDashed4: '╎',
lineVerticalDashed5: '╏',
lineVerticalDashed6: '╵',
lineVerticalDashed7: '╷',
lineVerticalDashed8: '╹',
lineVerticalDashed9: '╻',
lineVerticalDashed10: '╽',
lineVerticalDashed11: '╿',
lineDownLeft: '┐',
lineDownLeftArc: '╮',
lineDownBoldLeftBold: '┓',
lineDownBoldLeft: '┒',
lineDownLeftBold: '┑',
lineDownDoubleLeftDouble: '╗',
lineDownDoubleLeft: '╖',
lineDownLeftDouble: '╕',
lineDownRight: '┌',
lineDownRightArc: '╭',
lineDownBoldRightBold: '┏',
lineDownBoldRight: '┎',
lineDownRightBold: '┍',
lineDownDoubleRightDouble: '╔',
lineDownDoubleRight: '╓',
lineDownRightDouble: '╒',
lineUpLeft: '┘',
lineUpLeftArc: '╯',
lineUpBoldLeftBold: '┛',
lineUpBoldLeft: '┚',
lineUpLeftBold: '┙',
lineUpDoubleLeftDouble: '╝',
lineUpDoubleLeft: '╜',
lineUpLeftDouble: '╛',
lineUpRight: '└',
lineUpRightArc: '╰',
lineUpBoldRightBold: '┗',
lineUpBoldRight: '┖',
lineUpRightBold: '┕',
lineUpDoubleRightDouble: '╚',
lineUpDoubleRight: '╙',
lineUpRightDouble: '╘',
lineUpDownLeft: '┤',
lineUpBoldDownBoldLeftBold: '┫',
lineUpBoldDownBoldLeft: '┨',
lineUpDownLeftBold: '┥',
lineUpBoldDownLeftBold: '┩',
lineUpDownBoldLeftBold: '┪',
lineUpDownBoldLeft: '┧',
lineUpBoldDownLeft: '┦',
lineUpDoubleDownDoubleLeftDouble: '╣',
lineUpDoubleDownDoubleLeft: '╢',
lineUpDownLeftDouble: '╡',
lineUpDownRight: '├',
lineUpBoldDownBoldRightBold: '┣',
lineUpBoldDownBoldRight: '┠',
lineUpDownRightBold: '┝',
lineUpBoldDownRightBold: '┡',
lineUpDownBoldRightBold: '┢',
lineUpDownBoldRight: '┟',
lineUpBoldDownRight: '┞',
lineUpDoubleDownDoubleRightDouble: '╠',
lineUpDoubleDownDoubleRight: '╟',
lineUpDownRightDouble: '╞',
lineDownLeftRight: '┬',
lineDownBoldLeftBoldRightBold: '┳',
lineDownLeftBoldRightBold: '┯',
lineDownBoldLeftRight: '┰',
lineDownBoldLeftBoldRight: '┱',
lineDownBoldLeftRightBold: '┲',
lineDownLeftRightBold: '┮',
lineDownLeftBoldRight: '┭',
lineDownDoubleLeftDoubleRightDouble: '╦',
lineDownDoubleLeftRight: '╥',
lineDownLeftDoubleRightDouble: '╤',
lineUpLeftRight: '┴',
lineUpBoldLeftBoldRightBold: '┻',
lineUpLeftBoldRightBold: '┷',
lineUpBoldLeftRight: '┸',
lineUpBoldLeftBoldRight: '┹',
lineUpBoldLeftRightBold: '┺',
lineUpLeftRightBold: '┶',
lineUpLeftBoldRight: '┵',
lineUpDoubleLeftDoubleRightDouble: '╩',
lineUpDoubleLeftRight: '╨',
lineUpLeftDoubleRightDouble: '╧',
lineUpDownLeftRight: '┼',
lineUpBoldDownBoldLeftBoldRightBold: '╋',
lineUpDownBoldLeftBoldRightBold: '╈',
lineUpBoldDownLeftBoldRightBold: '╇',
lineUpBoldDownBoldLeftRightBold: '╊',
lineUpBoldDownBoldLeftBoldRight: '╉',
lineUpBoldDownLeftRight: '╀',
lineUpDownBoldLeftRight: '╁',
lineUpDownLeftBoldRight: '┽',
lineUpDownLeftRightBold: '┾',
lineUpBoldDownBoldLeftRight: '╂',
lineUpDownLeftBoldRightBold: '┿',
lineUpBoldDownLeftBoldRight: '╃',
lineUpBoldDownLeftRightBold: '╄',
lineUpDownBoldLeftBoldRight: '╅',
lineUpDownBoldLeftRightBold: '╆',
lineUpDoubleDownDoubleLeftDoubleRightDouble: '╬',
lineUpDoubleDownDoubleLeftRight: '╫',
lineUpDownLeftDoubleRightDouble: '╪',
lineCross: '',
lineBackslash: '╲',
lineSlash: '',
};
const specialMainSymbols = {
tick: '✔',
info: '',
warning: '⚠',
cross: '✘',
squareSmall: '◻',
squareSmallFilled: '◼',
circle: '◯',
circleFilled: '◉',
circleDotted: '◌',
circleDouble: '◎',
circleCircle: 'ⓞ',
circleCross: 'ⓧ',
circlePipe: 'Ⓘ',
radioOn: '◉',
radioOff: '◯',
checkboxOn: '☒',
checkboxOff: '☐',
checkboxCircleOn: 'ⓧ',
checkboxCircleOff: 'Ⓘ',
pointer: '',
triangleUpOutline: '△',
triangleLeft: '◀',
triangleRight: '▶',
lozenge: '◆',
lozengeOutline: '◇',
hamburger: '☰',
smiley: '㋡',
mustache: '෴',
star: '★',
play: '▶',
nodejs: '⬢',
oneSeventh: '⅐',
oneNinth: '⅑',
oneTenth: '⅒',
};
const specialFallbackSymbols = {
tick: '√',
info: 'i',
warning: '‼',
cross: '×',
squareSmall: '□',
squareSmallFilled: '■',
circle: '( )',
circleFilled: '(*)',
circleDotted: '( )',
circleDouble: '( )',
circleCircle: '(○)',
circleCross: '(×)',
circlePipe: '(│)',
radioOn: '(*)',
radioOff: '( )',
checkboxOn: '[×]',
checkboxOff: '[ ]',
checkboxCircleOn: '(×)',
checkboxCircleOff: '( )',
pointer: '>',
triangleUpOutline: '∆',
triangleLeft: '◄',
triangleRight: '►',
lozenge: '♦',
lozengeOutline: '◊',
hamburger: '≡',
smiley: '☺',
mustache: '┌─┐',
star: '✶',
play: '►',
nodejs: '♦',
oneSeventh: '1/7',
oneNinth: '1/9',
oneTenth: '1/10',
};
export const mainSymbols = { ...common, ...specialMainSymbols };
export const fallbackSymbols = { ...common, ...specialFallbackSymbols };
const shouldUseMain = isUnicodeSupported();
const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
export default figures;
const replacements = Object.entries(specialMainSymbols);
// On terminals which do not support Unicode symbols, substitute them to other symbols
export const replaceSymbols = (
string,
{ useFallback = !shouldUseMain } = {}
) => {
if (useFallback) {
for (const [key, mainSymbol] of replacements) {
string = string.replaceAll(mainSymbol, fallbackSymbols[key]);
}
}
return string;
};

View File

@@ -0,0 +1,28 @@
/*
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
export default function isUnicodeSupported() {
if (process.platform !== 'win32') {
return process.env.TERM !== 'linux'; // Linux console (kernel)
}
return (
Boolean(process.env.WT_SESSION) || // Windows Terminal
Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
process.env.ConEmuTask === '{cmd::Cmder}' || // ConEmu and cmder
process.env.TERM_PROGRAM === 'Terminus-Sublime' ||
process.env.TERM_PROGRAM === 'vscode' ||
process.env.TERM === 'xterm-256color' ||
process.env.TERM === 'alacritty' ||
process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm'
);
}

View File

@@ -5,14 +5,8 @@ export default async function confirm(
message: string,
preferred: boolean
): Promise<boolean> {
require('./patch-inquirer');
const answers = await client.prompt({
type: 'confirm',
name: 'value',
return client.input.confirm({
message,
default: preferred,
});
return answers.value;
}

View File

@@ -1,4 +1,3 @@
import inquirer from 'inquirer';
import confirm from './confirm';
import chalk from 'chalk';
import frameworkList, { Framework } from '@vercel/frameworks';
@@ -140,33 +139,16 @@ export default async function editProjectSettings(
[]
);
const { settingFields } = await inquirer.prompt<{
settingFields: Array<
Exclude<
ConfigKeys,
'framework' | 'commandForIgnoringBuildStep' | 'installCommand'
>
>;
}>({
name: 'settingFields',
type: 'checkbox',
const settingFields = (await client.input.checkbox({
message: 'Which settings would you like to overwrite (select multiple)?',
choices,
});
})) as ConfigKeys[];
for (let setting of settingFields) {
const field = settingMap[setting];
const answers = await inquirer.prompt<{
[k in Exclude<
ConfigKeys,
'framework' | 'commandForIgnoringBuildStep' | 'installCommand'
>]: string;
}>({
type: 'input',
name: setting,
settings[setting] = await client.input({
message: `What's your ${chalk.bold(field)}?`,
});
settings[setting] = answers[setting];
}
return settings;
}

View File

@@ -78,12 +78,9 @@ export default async function inputProject(
let project: Project | ProjectNotFound | null = null;
while (!project || project instanceof ProjectNotFound) {
const answers = await client.prompt({
type: 'input',
name: 'existingProjectName',
message: `Whats the name of your existing project?`,
const projectName = await client.input({
message: 'Whats the name of your existing project?',
});
const projectName = answers.existingProjectName as string;
if (!projectName) {
output.error(`Project name cannot be empty`);
@@ -109,13 +106,10 @@ export default async function inputProject(
let newProjectName: string | null = null;
while (!newProjectName) {
const answers = await client.prompt({
type: 'input',
name: 'newProjectName',
newProjectName = await client.input({
message: `Whats your projects name?`,
default: !detectedProject ? slugifiedName : undefined,
});
newProjectName = answers.newProjectName as string;
if (!newProjectName) {
output.error(`Project name cannot be empty`);

View File

@@ -14,9 +14,7 @@ export async function inputRootDirectory(
// eslint-disable-next-line no-constant-condition
while (true) {
const { rootDirectory } = await client.prompt({
type: 'input',
name: 'rootDirectory',
const rootDirectory = await client.input({
message: `In which directory is your code located?`,
transformer: (input: string) => {
return `${chalk.dim(`./`)}${input}`;

View File

@@ -1,4 +1,4 @@
import inquirer from 'inquirer';
import { Separator } from '@inquirer/prompts';
import stripAnsi from 'strip-ansi';
import Client from '../client';
import eraseLines from '../output/erase-lines';
@@ -14,7 +14,7 @@ interface ListSeparator {
separator: string;
}
export type ListChoice = ListEntry | ListSeparator | typeof inquirer.Separator;
export type ListChoice = ListEntry | ListSeparator | typeof Separator;
interface ListOptions {
message: string;
@@ -54,8 +54,6 @@ export default async function list(
eraseFinalAnswer = false, // If true, the line with the final answer that inquirer prints will be erased before returning
}: ListOptions
): Promise<string> {
require('./patch-inquirer');
let biggestLength = 0;
let selected: string | undefined;
@@ -70,14 +68,14 @@ export default async function list(
}
const choices = _choices.map(choice => {
if (choice instanceof inquirer.Separator) {
if (choice instanceof Separator) {
return choice;
}
if ('separator' in choice) {
const prefix = `── ${choice.separator} `;
const suffix = '─'.repeat(biggestLength - getLength(prefix));
return new inquirer.Separator(`${prefix}${suffix}`);
return new Separator(`${prefix}${suffix}`);
}
if ('short' in choice) {
@@ -93,11 +91,11 @@ export default async function list(
if (separator) {
for (let i = 0; i < choices.length; i += 2) {
choices.splice(i, 0, new inquirer.Separator(' '));
choices.splice(i, 0, new Separator(' '));
}
}
const cancelSeparator = new inquirer.Separator('─'.repeat(biggestLength));
const cancelSeparator = new Separator('─'.repeat(biggestLength));
const _cancel = {
name: 'Cancel',
value: '',
@@ -110,18 +108,16 @@ export default async function list(
choices.push(cancelSeparator, _cancel);
}
const answer = await client.prompt({
name: 'value',
type: 'list',
default: selected,
const answer = await client.select({
message,
choices,
pageSize,
default: selected,
});
if (eraseFinalAnswer === true) {
process.stdout.write(eraseLines(2));
}
return answer.value;
return answer;
}

View File

@@ -1,210 +0,0 @@
import chalk from 'chalk';
import inquirer from 'inquirer';
import Prompt from 'inquirer/lib/prompts/base';
import Choice from 'inquirer/lib/objects/choice';
import Separator from 'inquirer/lib/objects/separator';
/**
* Here we patch inquirer with some tweaks:
* - update "list" to use ● and ○ and hide tips
* - update "checkbox" to use ◻︎ and ◼︎ and hide tips
* - use '?' before questions
* - do not apply color to question's answer
*/
// adjusted from https://github.com/SBoudrias/Inquirer.js/blob/942908f17319343d1acc7b876f990797c5695918/packages/inquirer/lib/prompts/base.js#L126
const getQuestion = function (this: Prompt) {
let message = `${chalk.gray('?')} ${this.opt.message} `;
if (this.opt.type === 'confirm') {
if (this.opt.default === 'y/N') {
message += `[y/${chalk.bold('N')}] `;
} else {
message += `[${chalk.bold('Y')}/n] `;
}
}
// Append the default if available, and if question isn't answered
else if (this.opt.default != null && this.status !== 'answered') {
message += chalk.dim(`(${this.opt.default}) `);
}
return message;
};
inquirer.prompt.prompts.list.prototype.getQuestion = getQuestion;
inquirer.prompt.prompts.checkbox.prototype.getQuestion = getQuestion;
inquirer.prompt.prompts.input.prototype.getQuestion = getQuestion;
inquirer.prompt.prompts.confirm.prototype.getQuestion = getQuestion;
// adjusted from https://github.com/SBoudrias/Inquirer.js/blob/942908f17319343d1acc7b876f990797c5695918/packages/inquirer/lib/prompts/list.js#L80
inquirer.prompt.prompts.list.prototype.render = function () {
// Render question
let message = this.getQuestion();
// Render choices or answer depending on the state
if (this.status === 'answered') {
message += this.opt.choices.getChoice(this.selected).short;
} else {
let choicesStr = listRender(this.opt.choices, this.selected);
let indexPosition = this.opt.choices.indexOf(
this.opt.choices.getChoice(this.selected)
);
message +=
'\n' +
this.paginator.paginate(choicesStr, indexPosition, this.opt.pageSize);
}
this.firstRender = false;
this.screen.render(message);
};
function listRender(choices: (Choice | Separator)[], pointer: number) {
let output = '';
let separatorOffset = 0;
choices.forEach((choice, i) => {
if (choice.type === 'separator') {
separatorOffset++;
output += ' ' + choice + '\n';
return;
}
if (choice.disabled) {
separatorOffset++;
output += ' - ' + choice.name;
output +=
' (' +
(typeof choice.disabled === 'string' ? choice.disabled : 'Disabled') +
')';
output += '\n';
return;
}
let isSelected = i - separatorOffset === pointer;
let line = (isSelected ? '● ' : '○ ') + choice.name;
if (isSelected) {
line = chalk.cyan(line);
}
output += line + ' \n';
});
return output.replace(/\n$/, '');
}
// adjusted from https://github.com/SBoudrias/Inquirer.js/blob/942908f17319343d1acc7b876f990797c5695918/packages/inquirer/lib/prompts/checkbox.js#L84
inquirer.prompt.prompts.checkbox.prototype.render = function (error?: string) {
// Render question
let message = this.getQuestion();
let bottomContent = '';
if (!this.spaceKeyPressed) {
message +=
'(Press ' +
chalk.cyan.bold('<space>') +
' to select, ' +
chalk.cyan.bold('<a>') +
' to toggle all, ' +
chalk.cyan.bold('<i>') +
' to invert selection)';
}
// Render choices or answer depending on the state
if (this.status === 'answered') {
message += this.selection.length > 0 ? this.selection.join(', ') : 'None';
} else {
let choicesStr = renderChoices(this.opt.choices, this.pointer);
let indexPosition = this.opt.choices.indexOf(
this.opt.choices.getChoice(this.pointer)
);
message +=
'\n' +
this.paginator.paginate(choicesStr, indexPosition, this.opt.pageSize);
}
if (error) {
bottomContent = chalk.red('>> ') + error;
}
this.screen.render(message, bottomContent);
};
function renderChoices(choices: (Choice | Separator)[], pointer: number) {
let output = '';
let separatorOffset = 0;
choices.forEach(function (choice, i) {
if (choice.type === 'separator') {
separatorOffset++;
output += '' + choice + '\n';
return;
}
if (choice.disabled) {
separatorOffset++;
output += '- ' + choice.name;
output +=
' (' +
(typeof choice.disabled === 'string' ? choice.disabled : 'Disabled') +
')';
} else {
if (i - separatorOffset === pointer) {
output += chalk.cyan(
(choice.checked ? ' ▪︎' : ' ▫︎') + ' ' + choice.name
);
} else {
output += chalk.cyan(
(choice.checked ? ' ▪︎' : ' ▫︎') + ' ' + choice.name
);
}
}
output += '\n';
});
return output.replace(/\n$/, '');
}
// adjusted from https://github.com/SBoudrias/Inquirer.js/blob/942908f17319343d1acc7b876f990797c5695918/packages/inquirer/lib/prompts/input.js#L44
inquirer.prompt.prompts.input.prototype.render = function (error?: string) {
let bottomContent = '';
let appendContent = '';
let message = this.getQuestion();
let transformer = this.opt.transformer;
let isFinal = this.status === 'answered';
if (isFinal) {
appendContent = this.answer;
} else {
appendContent = this.rl.line;
}
if (transformer) {
message += transformer(appendContent, this.answers, { isFinal });
} else {
message += appendContent;
}
if (error) {
bottomContent = chalk.red('>> ') + error;
}
this.screen.render(message, bottomContent);
};
// adjusted from https://github.com/SBoudrias/Inquirer.js/blob/942908f17319343d1acc7b876f990797c5695918/packages/inquirer/lib/prompts/confirm.js#L64
inquirer.prompt.prompts.confirm.prototype.render = function (answer?: boolean) {
let message = this.getQuestion();
if (this.status === 'answered') {
message += answer ? 'y' : 'n';
} else {
message += this.rl.line;
}
this.screen.render(message);
return this;
};

View File

@@ -10,7 +10,6 @@ export default async function selectOrg(
question: string,
autoConfirm?: boolean
): Promise<Org> {
require('./patch-inquirer');
const {
output,
config: { currentTeam },
@@ -52,14 +51,9 @@ export default async function selectOrg(
return choices[defaultChoiceIndex].value;
}
const answers = await client.prompt({
type: 'list',
name: 'org',
return await client.select({
message: question,
choices,
default: defaultChoiceIndex,
default: choices[defaultChoiceIndex].value,
});
const org = answers.org;
return org;
}

View File

@@ -1,5 +1,5 @@
import chalk from 'chalk';
import inquirer from 'inquirer';
import { Separator } from '@inquirer/prompts';
import pluralize from 'pluralize';
import { homedir } from 'os';
import slugify from '@sindresorhus/slugify';
@@ -144,16 +144,13 @@ export async function ensureRepoLink(
if (yes) {
remoteName = defaultRemote;
} else {
const answer = await client.prompt({
type: 'list',
name: 'value',
remoteName = await client.select({
message: 'Which Git remote should be used?',
choices: remoteNames.map(name => {
return { name: name, value: name };
}),
default: defaultRemote,
});
remoteName = answer.value;
}
}
const repoUrl = remoteUrls[remoteName];
@@ -222,15 +219,13 @@ export async function ensureRepoLink(
selected = projects;
} else {
const addSeparators = projects.length > 0 && detectedProjectsCount > 0;
const answer = await client.prompt({
type: 'checkbox',
name: 'selected',
selected = await client.input.checkbox({
message: `Which Projects should be ${
projects.length ? 'linked to' : 'created'
}?`,
choices: [
...(addSeparators
? [new inquirer.Separator('----- Existing Projects -----')]
? [new Separator('----- Existing Projects -----')]
: []),
...projects.map(project => {
return {
@@ -240,7 +235,7 @@ export async function ensureRepoLink(
};
}),
...(addSeparators
? [new inquirer.Separator('----- New Projects to be created -----')]
? [new Separator('----- New Projects to be created -----')]
: []),
...Array.from(detectedProjects.entries()).flatMap(
([rootDirectory, frameworks]) =>
@@ -267,9 +262,16 @@ export async function ensureRepoLink(
};
})
),
],
] as (
| Separator
| {
newProject?: boolean;
name: string;
value: Project | NewProject;
checked: boolean;
}
)[],
});
selected = answer.selected;
}
if (selected.length === 0) {

View File

@@ -62,12 +62,7 @@ export async function readInput(
while (!input) {
try {
const { val } = await client.prompt({
type: 'input',
name: 'val',
message,
});
input = val;
input = await client.input({ message });
} catch (err: any) {
console.log(); // \n

View File

@@ -97,16 +97,13 @@ async function getProjectLinkFromRepoLink(
} else {
const selectableProjects =
projects.length > 0 ? projects : repoLink.repoConfig.projects;
const { p } = await client.prompt({
name: 'p',
type: 'list',
project = await client.select({
message: `Please select a Project:`,
choices: selectableProjects.map(p => ({
value: p,
name: p.name,
})),
});
project = p;
}
if (project) {
return {

View File

@@ -1,3 +1,4 @@
import stripAnsi from 'strip-ansi';
import type { CLIProcess } from './types';
function getPromptErrorDetails(
@@ -54,7 +55,7 @@ export default async function waitForPrompt(
};
const onData = (rawChunk: Buffer) => {
const chunk = rawChunk.toString();
const chunk = stripAnsi(rawChunk.toString());
mostRecentChunk = chunk;
console.log('> ' + chunk);

View File

@@ -617,7 +617,7 @@ test('ensure we render a prompt when deploying home directory', async () => {
binaryPath,
[directory, '--public', '--name', session, '--force'],
{
input: 'N',
input: 'N\n',
}
);
@@ -625,7 +625,7 @@ test('ensure we render a prompt when deploying home directory', async () => {
expect(exitCode, formatOutput({ stdout, stderr })).toBe(0);
expect(stderr).toContain(
'You are deploying your home directory. Do you want to continue? [y/N]'
'You are deploying your home directory. Do you want to continue? (y/N)'
);
expect(stderr).toContain('Canceled');
});

View File

@@ -93,8 +93,6 @@ export class MockClient extends Client {
this.stderr.pause();
this.stderr.isTTY = true;
this._createPromptModule();
this.output = new Output(this.stderr);
this.argv = [];

View File

@@ -7,6 +7,7 @@ import {
import type { Readable } from 'stream';
import type { MatcherState } from 'expect';
import type { MatcherHintOptions } from 'jest-matcher-utils';
import stripAnsi from 'strip-ansi';
export async function toOutput(
this: MatcherState,
@@ -27,7 +28,7 @@ export async function toOutput(
matcherHint(matcherName, 'stream', 'test', matcherHintOptions) + '\n\n';
function onData(data: string) {
output += data;
output += stripAnsi(data);
if (output.includes(test)) {
cleanup();
resolve({

View File

@@ -79,7 +79,7 @@ describe('git', () => {
const gitPromise = git(client);
await expect(client.stderr).toOutput('Set up');
client.stdin.write('y\n');
client.stdin.write('\n');
await expect(client.stderr).toOutput(
'Which scope should contain your project?'
@@ -87,12 +87,12 @@ describe('git', () => {
client.stdin.write('\r');
await expect(client.stderr).toOutput('Found project');
client.stdin.write('y\n');
client.stdin.write('\n');
await expect(client.stderr).toOutput(
`Do you still want to connect https://github.com/user2/repo2?`
);
client.stdin.write('y\n');
client.stdin.write('h\n'); // vim left to switch from default no
await expect(client.stderr).toOutput(
`Connecting Git remote: https://github.com/user2/repo2`
@@ -425,7 +425,7 @@ describe('git', () => {
await expect(client.stderr).toOutput(
`Are you sure you want to disconnect user/repo from your project?`
);
client.stdin.write('y\n');
client.stdin.write('h\n'); // vim left to switch from default no
await expect(client.stderr).toOutput('Disconnected user/repo.');
const newProjectData: Project = await client.fetch(
@@ -526,9 +526,9 @@ describe('git', () => {
`Found a repository in your local Git Config: https://github.com/user/repo`
);
await expect(client.stderr).toOutput(
`Do you still want to connect https://github.com/user2/repo2? [y/N]`
`Do you still want to connect https://github.com/user2/repo2?`
);
client.stdin.write('y\n');
client.stdin.write('h\n'); // vim left to switch from default no
await expect(client.stderr).toOutput(
`Connecting Git remote: https://github.com/user2/repo2`
);
@@ -574,9 +574,9 @@ describe('git', () => {
`Found multiple Git repositories in your local Git config:\n • origin: https://github.com/user/repo.git\n • secondary: https://github.com/user/repo2.git`
);
await expect(client.stderr).toOutput(
`Do you still want to connect https://github.com/user3/repo3? [y/N]`
`Do you still want to connect https://github.com/user3/repo3?`
);
client.stdin.write('y\n');
client.stdin.write('h\n'); // vim left to switch away from default no
await expect(client.stderr).toOutput(
`Connecting Git remote: https://github.com/user3/repo3`

View File

@@ -26,16 +26,17 @@ describe('link', () => {
client.cwd = cwd;
const exitCodePromise = link(client);
client.stderr.pipe(process.stderr);
await expect(client.stderr).toOutput('Set up');
client.stdin.write('y\n');
client.stdin.write('\n');
await expect(client.stderr).toOutput(
'Which scope should contain your project?'
);
client.stdin.write('y\n');
client.stdin.write('\n');
await expect(client.stderr).toOutput('Link to it?');
client.stdin.write('y\n');
client.stdin.write('\n');
await expect(client.stderr).toOutput(
`Linked to ${user.username}/${project.name} (created .vercel and added it to .gitignore)`

View File

@@ -54,7 +54,7 @@ describe('login', () => {
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\r'); // Return key
await expect(client.stderr).toOutput('? Enter your email address:');
await expect(client.stderr).toOutput('Enter your email address:');
client.stdin.write(`${user.email}\n`);
@@ -77,7 +77,7 @@ describe('login', () => {
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\r'); // Return key
await expect(client.stderr).toOutput('? Enter your email address:');
await expect(client.stderr).toOutput('Enter your email address:');
client.stdin.write(`${user.email}\n`);
@@ -119,7 +119,7 @@ describe('login', () => {
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\r'); // Return key
await expect(client.stderr).toOutput('? Enter your email address:');
await expect(client.stderr).toOutput('Enter your email address:');
client.stdin.write(`${user.email}\n`);
@@ -162,7 +162,7 @@ describe('login', () => {
client.stdin.write('\x1B[B'); // Down arrow
client.stdin.write('\r'); // Return key
await expect(client.stderr).toOutput('? Enter your email address:');
await expect(client.stderr).toOutput('Enter your email address:');
client.stdin.write(`${user.email}\n`);

View File

@@ -45,55 +45,6 @@ describe('project', () => {
expect(data).toEqual([project.project.name, 'https://foobar.com']);
});
it('should list projects running on an soon-to-be-deprecated Node.js version', async () => {
jest.useFakeTimers().setSystemTime(new Date('2023-12-08'));
const user = useUser();
useTeams('team_dummy');
const project = useProject({
...defaultProject,
nodeVersion: '16.x',
});
client.setArgv('project', 'ls', '--update-required');
await projects(client);
const lines = createLineIterator(client.stderr);
let line = await lines.next();
expect(line.value).toEqual(`Fetching projects in ${user.username}`);
line = await lines.next();
expect(line.value).toEqual(
'WARN! The following Node.js versions will be deprecated soon: 16.x. Please upgrade your projects immediately.'
);
line = await lines.next();
expect(line.value).toEqual(
'> For more information visit: https://vercel.com/docs/functions/serverless-functions/runtimes/node-js#node.js-version'
);
line = await lines.next();
expect(line.value).toContain(user.username);
// empty line
line = await lines.next();
expect(line.value).toEqual('');
line = await lines.next();
const header = parseSpacedTableRow(line.value!);
expect(header).toEqual([
'Project Name',
'Latest Production URL',
'Updated',
]);
line = await lines.next();
const data = parseSpacedTableRow(line.value!);
data.pop();
expect(data).toEqual([project.project.name, 'https://foobar.com']);
jest.clearAllTimers();
});
it('should list projects when there is no production deployment', async () => {
const user = useUser();
useTeams('team_dummy');

View File

@@ -113,7 +113,7 @@ describe('promote', () => {
`Fetching deployment "${previousDeployment.url}" in ${previousDeployment.creator?.username}`
);
await expect(client.stderr).toOutput(
'? This deployment does not target production, therefore promotion will not apply\n production environment variables. Are you sure you want to continue?'
'This deployment does not target production, therefore promotion will not \napply production environment variables. Are you sure you want to continue?'
);
// say "no" to the prompt
@@ -136,7 +136,7 @@ describe('promote', () => {
`Fetching deployment "${previousDeployment.url}" in ${previousDeployment.creator?.username}`
);
await expect(client.stderr).toOutput(
'? This deployment does not target production, therefore promotion will not apply\n production environment variables. Are you sure you want to continue?'
'This deployment does not target production, therefore promotion will not \napply production environment variables. Are you sure you want to continue?'
);
// say "yes" to the prompt

View File

@@ -4,29 +4,29 @@ import { client } from '../../mocks/client';
describe('confirm()', () => {
it('should work with multiple prompts', async () => {
// true (explicit)
let confirmedPromise = confirm(client, 'Explictly true?', false);
await expect(client.stderr).toOutput('Explictly true? [y/N]');
client.stdin.write('yes\n');
let confirmedPromise = confirm(client, 'Explicitly true?', false);
await expect(client.stderr).toOutput('Explicitly true?');
client.stdin.write('h\n'); // vim left
let confirmed = await confirmedPromise;
expect(confirmed).toEqual(true);
// false (explicit)
confirmedPromise = confirm(client, 'Explcitly false?', true);
await expect(client.stderr).toOutput('Explcitly false? [Y/n]');
client.stdin.write('no\n');
confirmedPromise = confirm(client, 'Explicitly false?', true);
await expect(client.stderr).toOutput('Explicitly false?');
client.stdin.write('l\n'); // vim right
confirmed = await confirmedPromise;
expect(confirmed).toEqual(false);
// true (default)
confirmedPromise = confirm(client, 'Default true?', true);
await expect(client.stderr).toOutput('Default true? [Y/n]');
await expect(client.stderr).toOutput('Default true?');
client.stdin.write('\n');
confirmed = await confirmedPromise;
expect(confirmed).toEqual(true);
// false (default)
confirmedPromise = confirm(client, 'Default false?', false);
await expect(client.stderr).toOutput('Default false? [y/N]');
await expect(client.stderr).toOutput('Default false?');
client.stdin.write('\n');
confirmed = await confirmedPromise;
expect(confirmed).toEqual(false);

202
pnpm-lock.yaml generated
View File

@@ -1,5 +1,9 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
@@ -352,6 +356,15 @@ importers:
'@edge-runtime/node-utils':
specifier: 2.3.0
version: 2.3.0
'@inquirer/core':
specifier: 7.1.0
version: 7.1.0
'@inquirer/prompts':
specifier: 4.3.0
version: 4.3.0
'@inquirer/type':
specifier: 1.2.1
version: 1.2.1
'@next/env':
specifier: 11.1.2
version: 11.1.2
@@ -589,9 +602,6 @@ importers:
ini:
specifier: 3.0.0
version: 3.0.0
inquirer:
specifier: 7.0.4
version: 7.0.4
is-docker:
specifier: 2.2.1
version: 2.2.1
@@ -3104,6 +3114,121 @@ packages:
/@iarna/toml@2.2.3:
resolution: {integrity: sha512-FmuxfCuolpLl0AnQ2NHSzoUKWEJDFl63qXjzdoWBVyFCXzMGm1spBzk7LeHNoVCiWCF7mRVms9e6jEV9+MoPbg==}
/@inquirer/checkbox@2.2.0:
resolution: {integrity: sha512-L+owhbEm98dnP15XtT/8D1+nNvQecf8HngVFYTJaDR0jlfIeOHFHRbjhLKoVYxks85yY8mLaYXVZQLU46KTkXg==}
engines: {node: '>=18'}
dependencies:
'@inquirer/core': 7.1.0
'@inquirer/type': 1.2.1
ansi-escapes: 4.3.2
chalk: 4.1.2
figures: 3.2.0
dev: true
/@inquirer/confirm@3.1.0:
resolution: {integrity: sha512-nH5mxoTEoqk6WpoBz80GMpDSm9jH5V9AF8n+JZAZfMzd9gHeEG9w1o3KawPRR72lfzpP+QxBHLkOKLEApwhDiQ==}
engines: {node: '>=18'}
dependencies:
'@inquirer/core': 7.1.0
'@inquirer/type': 1.2.1
dev: true
/@inquirer/core@7.1.0:
resolution: {integrity: sha512-FRCiDiU54XHt5B/D8hX4twwZuzSP244ANHbu3R7CAsJfiv1dUOz24ePBgCZjygEjDUi6BWIJuk4eWLKJ7LATUw==}
engines: {node: '>=18'}
dependencies:
'@inquirer/type': 1.2.1
'@types/mute-stream': 0.0.4
'@types/node': 20.11.30
'@types/wrap-ansi': 3.0.0
ansi-escapes: 4.3.2
chalk: 4.1.2
cli-spinners: 2.9.2
cli-width: 4.1.0
figures: 3.2.0
mute-stream: 1.0.0
run-async: 3.0.0
signal-exit: 4.1.0
strip-ansi: 6.0.1
wrap-ansi: 6.2.0
dev: true
/@inquirer/editor@2.1.0:
resolution: {integrity: sha512-gBxebaZLATrQyjZnuPLcfM2WxjZG6rjEmnzepJb/0bypi1PgWt9rZoH+a/j1uJx/tF+jhYrvSBr8McEOWcyAWg==}
engines: {node: '>=18'}
dependencies:
'@inquirer/core': 7.1.0
'@inquirer/type': 1.2.1
external-editor: 3.1.0
dev: true
/@inquirer/expand@2.1.0:
resolution: {integrity: sha512-jQgF7ImxxsX4MM8BUk33ffOvx3YOlaEqNCLTxBk7eZ5KOqOshmUq9FnOMnacUXpu7MJtkV/DJHubFiC/q4NF6g==}
engines: {node: '>=18'}
dependencies:
'@inquirer/core': 7.1.0
'@inquirer/type': 1.2.1
chalk: 4.1.2
figures: 3.2.0
dev: true
/@inquirer/input@2.1.0:
resolution: {integrity: sha512-o57pST+xxZfGww1h4G7ISiX37KlLcajhKgKGG7/h8J6ClWtsyqwMv1el9Ds/4geuYN/HcPj0MyX9gTEO62UpcA==}
engines: {node: '>=18'}
dependencies:
'@inquirer/core': 7.1.0
'@inquirer/type': 1.2.1
dev: true
/@inquirer/password@2.1.0:
resolution: {integrity: sha512-93x0Rpq75SP9u4s3zh4UcSKvn8KBGgyF3tKN7bNQp3bseROR0uJgySDp8iTQpcTfhJy41R+2Jr4xNLKGhr6Gzw==}
engines: {node: '>=18'}
dependencies:
'@inquirer/core': 7.1.0
'@inquirer/type': 1.2.1
ansi-escapes: 4.3.2
dev: true
/@inquirer/prompts@4.3.0:
resolution: {integrity: sha512-bSpFHqCnHrfmYgIMEFmA2YPPKxyw3n3ouI5S8m4N8krztJm1hFpQ8SdsZbBPRytoMaVvUgkASmiC0ih2VhDW9g==}
engines: {node: '>=18'}
dependencies:
'@inquirer/checkbox': 2.2.0
'@inquirer/confirm': 3.1.0
'@inquirer/core': 7.1.0
'@inquirer/editor': 2.1.0
'@inquirer/expand': 2.1.0
'@inquirer/input': 2.1.0
'@inquirer/password': 2.1.0
'@inquirer/rawlist': 2.1.0
'@inquirer/select': 2.2.0
dev: true
/@inquirer/rawlist@2.1.0:
resolution: {integrity: sha512-PykR/2LwcXcCeglDVj3OVVNrbhY2cyHTveWoSm9FmnksDtQDIXJqYgYGgvPOdPsDIj3VGVBKSXYNk+kHaQv0gw==}
engines: {node: '>=18'}
dependencies:
'@inquirer/core': 7.1.0
'@inquirer/type': 1.2.1
chalk: 4.1.2
dev: true
/@inquirer/select@2.2.0:
resolution: {integrity: sha512-Pml3DhVM1LnfqasUMIzaBtw+s5UjM5k0bzDeWrWOgqAMWe16AOg0DcAhXHf+SYbnj2CFBeP/TvkvedL4aAEWww==}
engines: {node: '>=18'}
dependencies:
'@inquirer/core': 7.1.0
'@inquirer/type': 1.2.1
ansi-escapes: 4.3.2
chalk: 4.1.2
figures: 3.2.0
dev: true
/@inquirer/type@1.2.1:
resolution: {integrity: sha512-xwMfkPAxeo8Ji/IxfUSqzRi0/+F2GIqJmpc5/thelgMGsjNZcjDDRBO9TLXT1s/hdx/mK5QbVIvgoLIFgXhTMQ==}
engines: {node: '>=18'}
dev: true
/@isaacs/cliui@8.0.2:
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
engines: {node: '>=12'}
@@ -4619,6 +4744,12 @@ packages:
'@types/node': 16.18.11
dev: true
/@types/mute-stream@0.0.4:
resolution: {integrity: sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==}
dependencies:
'@types/node': 16.18.11
dev: true
/@types/next-server@8.0.0:
resolution: {integrity: sha512-TYWT510LScQJU6ACRqcnnK1IBdeZsXCOGgMvZrAgghQ6TXD1xE92qdTHh051WtXrcm9OjisZhI0Jx3i9PU3IuA==}
dependencies:
@@ -4670,6 +4801,12 @@ packages:
/@types/node@16.18.11:
resolution: {integrity: sha512-3oJbGBUWuS6ahSnEq1eN2XrCyf4YsWI8OyCvo7c64zQJNplk3mO84t53o8lfTk+2ji59g5ycfc6qQ3fdHliHuA==}
/@types/node@20.11.30:
resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==}
dependencies:
undici-types: 5.26.5
dev: true
/@types/normalize-package-data@2.4.1:
resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}
dev: true
@@ -4857,6 +4994,10 @@ packages:
resolution: {integrity: sha512-ASCxdbsrwNfSMXALlC3Decif9rwDMu+80KGp5zI2RLRotfMsTv7fHL8W8VDp24wymzDyIFudhUeSCugrgRFfHQ==}
dev: true
/@types/wrap-ansi@3.0.0:
resolution: {integrity: sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==}
dev: true
/@types/write-json-file@2.2.1:
resolution: {integrity: sha512-JdO/UpPm9RrtQBNVcZdt3M7j3mHO/kXaea9LBGx3UgWJd1f9BkIWP7jObLBG6ZtRyqp7KzLFEsaPhWcidVittA==}
dev: true
@@ -6733,6 +6874,11 @@ packages:
engines: {node: '>=6'}
dev: true
/cli-spinners@2.9.2:
resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==}
engines: {node: '>=6'}
dev: true
/cli-table3@0.6.3:
resolution: {integrity: sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==}
engines: {node: 10.* || >= 12.*}
@@ -6750,8 +6896,9 @@ packages:
string-width: 1.0.2
dev: true
/cli-width@2.2.1:
resolution: {integrity: sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==}
/cli-width@4.1.0:
resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==}
engines: {node: '>= 12'}
dev: true
/clipboardy@1.2.2:
@@ -9660,25 +9807,6 @@ packages:
resolution: {integrity: sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==}
dev: true
/inquirer@7.0.4:
resolution: {integrity: sha512-Bu5Td5+j11sCkqfqmUTiwv+tWisMtP0L7Q8WrqA2C/BbBhy1YTdFrvjjlrKq8oagA/tLQBski2Gcx/Sqyi2qSQ==}
engines: {node: '>=6.0.0'}
dependencies:
ansi-escapes: 4.3.2
chalk: 2.4.2
cli-cursor: 3.1.0
cli-width: 2.2.1
external-editor: 3.1.0
figures: 3.2.0
lodash: 4.17.21
mute-stream: 0.0.8
run-async: 2.4.1
rxjs: 6.6.7
string-width: 4.2.3
strip-ansi: 5.2.0
through: 2.3.8
dev: true
/internal-slot@1.0.5:
resolution: {integrity: sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==}
engines: {node: '>= 0.4'}
@@ -11962,8 +12090,9 @@ packages:
readable-stream: 2.3.7
dev: true
/mute-stream@0.0.8:
resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==}
/mute-stream@1.0.0:
resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
dev: true
/mz@2.7.0:
@@ -13455,8 +13584,8 @@ packages:
fsevents: 2.3.2
dev: true
/run-async@2.4.1:
resolution: {integrity: sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==}
/run-async@3.0.0:
resolution: {integrity: sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==}
engines: {node: '>=0.12.0'}
dev: true
@@ -13651,6 +13780,11 @@ packages:
resolution: {integrity: sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==}
engines: {node: '>=14'}
/signal-exit@4.1.0:
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
engines: {node: '>=14'}
dev: true
/sisteransi@1.0.5:
resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
dev: true
@@ -14300,10 +14434,6 @@ packages:
readable-stream: 3.6.2
dev: true
/through@2.3.8:
resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==}
dev: true
/time-span@4.0.0:
resolution: {integrity: sha512-MyqZCTGLDZ77u4k+jqg4UlrzPTPZ49NDlaekU6uuFaJLzPIN1woaRXCbGeqOfxwc3Y37ZROGAJ614Rdv7Olt+g==}
engines: {node: '>=10'}
@@ -14866,6 +14996,10 @@ packages:
which-boxed-primitive: 1.0.2
dev: true
/undici-types@5.26.5:
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
dev: true
/undici@5.26.5:
resolution: {integrity: sha512-cSb4bPFd5qgR7qr2jYAi0hlX9n5YKK2ONKkLFkxl+v/9BvC0sOpZjBHDBSXc5lWAf5ty9oZdRXytBIHzgUcerw==}
engines: {node: '>=14.0'}
@@ -15545,7 +15679,3 @@ packages:
/zwitch@2.0.4:
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
dev: true
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false