first commit

This commit is contained in:
2025-10-26 23:10:15 +08:00
commit 8f0345b7be
14961 changed files with 2356381 additions and 0 deletions

63
node_modules/inquirer/dist/commonjs/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,63 @@
/**
* Inquirer.js
* A collection of common interactive command line user interfaces.
*/
import { Separator } from '@inquirer/prompts';
import type { Prettify } from '@inquirer/type';
import PromptsRunner from './ui/prompt.ts';
import type { LegacyPromptConstructor, PromptFn } from './ui/prompt.ts';
import type { Answers, CustomQuestion, UnnamedDistinctQuestion, StreamOptions } from './types.ts';
import { Observable } from 'rxjs';
export type { QuestionMap, Question, DistinctQuestion, Answers, PromptSession, } from './types.ts';
type PromptReturnType<T> = Promise<Prettify<T>> & {
ui: PromptsRunner<Prettify<T>>;
};
/**
* Create a new self-contained prompt module.
*/
export declare function createPromptModule<Prompts extends Record<string, Record<string, unknown>> = never>(opt?: StreamOptions): {
<const A extends Answers, PrefilledAnswers extends Answers = object>(questions: ((UnnamedDistinctQuestion<PrefilledAnswers & A extends infer T ? { [K in keyof T]: T[K]; } : never> | CustomQuestion<PrefilledAnswers & A extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never, Prompts>) & {
name: Extract<keyof PrefilledAnswers, string> | Extract<keyof A, string>;
})[], answers?: PrefilledAnswers): PromptReturnType<Prettify<PrefilledAnswers & A>>;
<const A extends Answers, PrefilledAnswers extends Answers = object>(questions: { [name in keyof A]: UnnamedDistinctQuestion<PrefilledAnswers & A extends infer T ? { [K in keyof T]: T[K]; } : never> | CustomQuestion<PrefilledAnswers & A extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never, Prompts>; }, answers?: PrefilledAnswers): PromptReturnType<Prettify<PrefilledAnswers & Answers<Extract<keyof A, string>>>>;
<const A extends Answers, PrefilledAnswers extends Answers = object>(questions: Observable<(UnnamedDistinctQuestion<PrefilledAnswers & A extends infer T ? { [K in keyof T]: T[K]; } : never> | CustomQuestion<PrefilledAnswers & A extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never, Prompts>) & {
name: Extract<keyof PrefilledAnswers, string> | Extract<keyof A, string>;
}>, answers?: PrefilledAnswers): PromptReturnType<Prettify<PrefilledAnswers & A>>;
<const A extends Answers, PrefilledAnswers extends Answers = object>(questions: (UnnamedDistinctQuestion<A & PrefilledAnswers> | CustomQuestion<A & PrefilledAnswers, Prompts>) & {
name: Extract<keyof A, string> | Extract<keyof PrefilledAnswers, string>;
}, answers?: PrefilledAnswers): PromptReturnType<PrefilledAnswers & A>;
prompts: {
[x: string]: LegacyPromptConstructor | PromptFn<any, any>;
};
registerPrompt(name: string, prompt: LegacyPromptConstructor | PromptFn): /*elided*/ any;
restoreDefaultPrompts(): void;
};
declare function registerPrompt(name: string, newPrompt: LegacyPromptConstructor): void;
declare function restoreDefaultPrompts(): void;
declare const inquirer: {
prompt: {
<const A extends Answers, PrefilledAnswers extends Answers = object>(questions: (UnnamedDistinctQuestion<PrefilledAnswers & A extends infer T ? { [K in keyof T]: T[K]; } : never> & {
name: Extract<keyof PrefilledAnswers, string> | Extract<keyof A, string>;
})[], answers?: PrefilledAnswers | undefined): PromptReturnType<PrefilledAnswers & A extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never>;
<const A extends Answers, PrefilledAnswers extends Answers = object>(questions: { [name in keyof A]: UnnamedDistinctQuestion<PrefilledAnswers & A extends infer T ? { [K in keyof T]: T[K]; } : never>; }, answers?: PrefilledAnswers | undefined): PromptReturnType<PrefilledAnswers & Answers<Extract<keyof A, string>> extends infer T ? { [K in keyof T]: T[K]; } : never>;
<const A extends Answers, PrefilledAnswers extends Answers = object>(questions: Observable<UnnamedDistinctQuestion<PrefilledAnswers & A extends infer T ? { [K in keyof T]: T[K]; } : never> & {
name: Extract<keyof PrefilledAnswers, string> | Extract<keyof A, string>;
}>, answers?: PrefilledAnswers | undefined): PromptReturnType<PrefilledAnswers & A extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never>;
<const A extends Answers, PrefilledAnswers extends Answers = object>(questions: UnnamedDistinctQuestion<A & PrefilledAnswers> & {
name: Extract<keyof A, string> | Extract<keyof PrefilledAnswers, string>;
}, answers?: PrefilledAnswers | undefined): PromptReturnType<PrefilledAnswers & A>;
prompts: {
[x: string]: LegacyPromptConstructor | PromptFn<any, any>;
};
registerPrompt(name: string, prompt: LegacyPromptConstructor | PromptFn): /*elided*/ any;
restoreDefaultPrompts(): void;
};
ui: {
Prompt: typeof PromptsRunner;
};
createPromptModule: typeof createPromptModule;
registerPrompt: typeof registerPrompt;
restoreDefaultPrompts: typeof restoreDefaultPrompts;
Separator: typeof Separator;
};
export default inquirer;

73
node_modules/inquirer/dist/commonjs/index.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
"use strict";
/**
* Inquirer.js
* A collection of common interactive command line user interfaces.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPromptModule = createPromptModule;
const prompts_1 = require("@inquirer/prompts");
const prompt_ts_1 = __importDefault(require("./ui/prompt.js"));
const builtInPrompts = {
input: prompts_1.input,
select: prompts_1.select,
/** @deprecated `list` is now named `select` */
list: prompts_1.select,
number: prompts_1.number,
confirm: prompts_1.confirm,
rawlist: prompts_1.rawlist,
expand: prompts_1.expand,
checkbox: prompts_1.checkbox,
password: prompts_1.password,
editor: prompts_1.editor,
search: prompts_1.search,
};
/**
* Create a new self-contained prompt module.
*/
function createPromptModule(opt) {
function promptModule(questions, answers) {
const runner = new prompt_ts_1.default(promptModule.prompts, opt);
const promptPromise = runner.run(questions, answers);
return Object.assign(promptPromise, { ui: runner });
}
promptModule.prompts = { ...builtInPrompts };
/**
* Register a prompt type
*/
promptModule.registerPrompt = function (name, prompt) {
promptModule.prompts[name] = prompt;
return this;
};
/**
* Register the defaults provider prompts
*/
promptModule.restoreDefaultPrompts = function () {
promptModule.prompts = { ...builtInPrompts };
};
return promptModule;
}
/**
* Public CLI helper interface
*/
const prompt = createPromptModule();
// Expose helper functions on the top level for easiest usage by common users
function registerPrompt(name, newPrompt) {
prompt.registerPrompt(name, newPrompt);
}
function restoreDefaultPrompts() {
prompt.restoreDefaultPrompts();
}
const inquirer = {
prompt,
ui: {
Prompt: prompt_ts_1.default,
},
createPromptModule,
registerPrompt,
restoreDefaultPrompts,
Separator: prompts_1.Separator,
};
exports.default = inquirer;

3
node_modules/inquirer/dist/commonjs/package.json generated vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"type": "commonjs"
}

61
node_modules/inquirer/dist/commonjs/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,61 @@
import { checkbox, confirm, editor, expand, input, number, password, rawlist, search, select } from '@inquirer/prompts';
import type { Context, DistributiveMerge, Prettify } from '@inquirer/type';
import { Observable } from 'rxjs';
export type Answers<Key extends string = string> = Record<Key, any>;
type AsyncCallbackFunction<R> = (...args: [error: null | undefined, value: R] | [error: Error, value: undefined]) => void;
export type AsyncGetterFunction<R, A extends Answers> = (this: {
async: () => AsyncCallbackFunction<R>;
}, answers: Prettify<Partial<A>>) => void | R | Promise<R>;
/**
* Allows to inject a custom question type into inquirer module.
*
* @example
* ```ts
* declare module 'inquirer' {
* interface QuestionMap {
* custom: { message: string };
* }
* }
* ```
*
* Globally defined question types are not correct.
*/
export interface QuestionMap {
__dummy: {
message: string;
};
}
type KeyValueOrAsyncGetterFunction<T, k extends string, A extends Answers> = T extends Record<string, any> ? T[k] | AsyncGetterFunction<T[k], A> : never;
export type Question<A extends Answers = Answers, Type extends string = string> = {
type: Type;
name: string;
message: string | AsyncGetterFunction<string, A>;
default?: any;
choices?: any;
filter?: (answer: any, answers: Partial<A>) => any;
askAnswered?: boolean;
when?: boolean | AsyncGetterFunction<boolean, A>;
};
type QuestionWithGetters<Type extends string, Q extends Record<string, any>, A extends Answers> = DistributiveMerge<Q, {
type: Type;
askAnswered?: boolean;
when?: boolean | AsyncGetterFunction<boolean, A>;
filter?(input: any, answers: A): any;
message: KeyValueOrAsyncGetterFunction<Q, 'message', A>;
default?: KeyValueOrAsyncGetterFunction<Q, 'default', A>;
choices?: KeyValueOrAsyncGetterFunction<Q, 'choices', A>;
}>;
export type UnnamedDistinctQuestion<A extends Answers = object> = QuestionWithGetters<'checkbox', Parameters<typeof checkbox>[0] & {
default: unknown[];
}, A> | QuestionWithGetters<'confirm', Parameters<typeof confirm>[0], A> | QuestionWithGetters<'editor', Parameters<typeof editor>[0], A> | QuestionWithGetters<'expand', Parameters<typeof expand>[0], A> | QuestionWithGetters<'input', Parameters<typeof input>[0], A> | QuestionWithGetters<'number', Parameters<typeof number>[0], A> | QuestionWithGetters<'password', Parameters<typeof password>[0], A> | QuestionWithGetters<'rawlist', Parameters<typeof rawlist>[0], A> | QuestionWithGetters<'search', Parameters<typeof search>[0], A> | QuestionWithGetters<'list', Parameters<typeof select>[0], A> | QuestionWithGetters<'select', Parameters<typeof select>[0], A>;
export type DistinctQuestion<A extends Answers = Answers> = Prettify<UnnamedDistinctQuestion<A> & {
name: Extract<keyof A, string>;
}>;
export type CustomQuestion<A extends Answers, Q extends Record<string, Record<string, any>>> = {
[key in Extract<keyof Q, string>]: Readonly<QuestionWithGetters<key, Q[key], A>>;
}[Extract<keyof Q, string>];
export type PromptSession<A extends Answers = Answers, Q extends Question<A> = Question<A>> = Q[] | Record<string, Omit<Q, 'name'>> | Observable<Q> | Q;
export type StreamOptions = Prettify<Context & {
skipTTYChecks?: boolean;
}>;
export {};

2
node_modules/inquirer/dist/commonjs/types.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

60
node_modules/inquirer/dist/commonjs/ui/prompt.d.ts generated vendored Normal file
View File

@@ -0,0 +1,60 @@
import { Observable } from 'rxjs';
import type { InquirerReadline } from '@inquirer/type';
import type { Answers, PromptSession, StreamOptions } from '../types.ts';
export declare const _: {
set: (obj: Record<string, unknown>, path: string | undefined, value: unknown) => void;
get: (obj: object, path?: string | number | symbol, defaultValue?: unknown) => any;
};
export interface PromptBase {
/**
* Runs the prompt.
*
* @returns
* The result of the prompt.
*/
run(): Promise<any>;
}
/**
* Provides the functionality to initialize new prompts.
*/
export interface LegacyPromptConstructor {
/**
* Initializes a new instance of a prompt.
*
* @param question
* The question to prompt.
*
* @param readLine
* An object for reading from the command-line.
*
* @param answers
* The answers provided by the user.
*/
new (question: any, readLine: InquirerReadline, answers: Record<string, any>): PromptBase;
}
export type PromptFn<Value = any, Config = any> = (config: Config, context: StreamOptions & {
signal: AbortSignal;
}) => Promise<Value>;
/**
* Provides a set of prompt-constructors.
*/
export type PromptCollection = Record<string, PromptFn | LegacyPromptConstructor>;
/**
* Base interface class other can inherits from
*/
export default class PromptsRunner<A extends Answers> {
private prompts;
answers: Partial<A>;
process: Observable<any>;
private abortController;
private opt;
constructor(prompts: PromptCollection, opt?: StreamOptions);
run(questions: PromptSession<A>, answers?: Partial<A>): Promise<A>;
private prepareQuestion;
private fetchAnswer;
/**
* Close the interface and cleanup listeners
*/
close: () => void;
private shouldRun;
}

270
node_modules/inquirer/dist/commonjs/ui/prompt.js generated vendored Normal file
View File

@@ -0,0 +1,270 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports._ = void 0;
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment */
const node_readline_1 = __importDefault(require("node:readline"));
const rxjs_1 = require("rxjs");
const run_async_1 = __importDefault(require("run-async"));
const mute_stream_1 = __importDefault(require("mute-stream"));
const core_1 = require("@inquirer/core");
const ansi_1 = require("@inquirer/ansi");
exports._ = {
set: (obj, path = '', value) => {
let pointer = obj;
path.split('.').forEach((key, index, arr) => {
if (key === '__proto__' || key === 'constructor')
return;
if (index === arr.length - 1) {
pointer[key] = value;
}
else if (!(key in pointer) || typeof pointer[key] !== 'object') {
pointer[key] = {};
}
pointer = pointer[key];
});
},
get: (obj, path = '', defaultValue) => {
const travel = (regexp) => String.prototype.split
.call(path, regexp)
.filter(Boolean)
.reduce(
// @ts-expect-error implicit any on res[key]
(res, key) => (res == null ? res : res[key]), obj);
const result = travel(/[,[\]]+?/) || travel(/[,.[\]]+?/);
return result === undefined || result === obj ? defaultValue : result;
},
};
/**
* Resolve a question property value if it is passed as a function.
* This method will overwrite the property on the question object with the received value.
*/
async function fetchAsyncQuestionProperty(question, prop, answers) {
const propGetter = question[prop];
if (typeof propGetter === 'function') {
return (0, run_async_1.default)(propGetter)(answers);
}
return propGetter;
}
class TTYError extends Error {
name = 'TTYError';
isTtyError = true;
}
function setupReadlineOptions(opt) {
// Inquirer 8.x:
// opt.skipTTYChecks = opt.skipTTYChecks === undefined ? opt.input !== undefined : opt.skipTTYChecks;
opt.skipTTYChecks = opt.skipTTYChecks === undefined ? true : opt.skipTTYChecks;
// Default `input` to stdin
const input = opt.input || process.stdin;
// Check if prompt is being called in TTY environment
// If it isn't return a failed promise
// @ts-expect-error: ignore isTTY type error
if (!opt.skipTTYChecks && !input.isTTY) {
throw new TTYError('Prompts can not be meaningfully rendered in non-TTY environments');
}
// Add mute capabilities to the output
const ms = new mute_stream_1.default();
ms.pipe(opt.output || process.stdout);
const output = ms;
return {
terminal: true,
...opt,
input,
output,
};
}
function isQuestionArray(questions) {
return Array.isArray(questions);
}
function isQuestionMap(questions) {
return Object.values(questions).every((maybeQuestion) => typeof maybeQuestion === 'object' &&
!Array.isArray(maybeQuestion) &&
maybeQuestion != null);
}
function isPromptConstructor(prompt) {
return Boolean(prompt.prototype &&
'run' in prompt.prototype &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
typeof prompt.prototype.run === 'function');
}
/**
* Base interface class other can inherits from
*/
class PromptsRunner {
prompts;
answers = {};
process = rxjs_1.EMPTY;
abortController = new AbortController();
opt;
constructor(prompts, opt = {}) {
this.opt = opt;
this.prompts = prompts;
}
async run(questions, answers) {
this.abortController = new AbortController();
// Keep global reference to the answers
this.answers = typeof answers === 'object' ? { ...answers } : {};
let obs;
if (isQuestionArray(questions)) {
obs = (0, rxjs_1.from)(questions);
}
else if ((0, rxjs_1.isObservable)(questions)) {
obs = questions;
}
else if (isQuestionMap(questions)) {
// Case: Called with a set of { name: question }
obs = (0, rxjs_1.from)(Object.entries(questions).map(([name, question]) => {
return Object.assign({}, question, { name });
}));
}
else {
// Case: Called with a single question config
obs = (0, rxjs_1.from)([questions]);
}
this.process = obs.pipe((0, rxjs_1.concatMap)((question) => (0, rxjs_1.of)(question).pipe((0, rxjs_1.concatMap)((question) => (0, rxjs_1.from)(this.shouldRun(question).then((shouldRun) => {
if (shouldRun) {
return question;
}
return;
})).pipe((0, rxjs_1.filter)((val) => val != null))), (0, rxjs_1.concatMap)((question) => (0, rxjs_1.defer)(() => (0, rxjs_1.from)(this.fetchAnswer(question)))))));
return (0, rxjs_1.lastValueFrom)(this.process.pipe((0, rxjs_1.reduce)((answersObj, answer) => {
exports._.set(answersObj, answer.name, answer.answer);
return answersObj;
}, this.answers)))
.then(() => this.answers)
.finally(() => this.close());
}
prepareQuestion = async (question) => {
const [message, defaultValue, resolvedChoices] = await Promise.all([
fetchAsyncQuestionProperty(question, 'message', this.answers),
fetchAsyncQuestionProperty(question, 'default', this.answers),
fetchAsyncQuestionProperty(question, 'choices', this.answers),
]);
let choices;
if (Array.isArray(resolvedChoices)) {
choices = resolvedChoices.map((choice) => {
const choiceObj = typeof choice !== 'object' || choice == null
? { name: choice, value: choice }
: {
...choice,
value: 'value' in choice
? choice.value
: 'name' in choice
? choice.name
: undefined,
};
if ('value' in choiceObj && Array.isArray(defaultValue)) {
// Add checked to question for backward compatibility. default was supported as alternative of per choice checked.
return {
checked: defaultValue.includes(choiceObj.value),
...choiceObj,
};
}
return choiceObj;
});
}
return Object.assign({}, question, {
message,
default: defaultValue,
choices,
type: question.type in this.prompts ? question.type : 'input',
});
};
fetchAnswer = async (rawQuestion) => {
const question = await this.prepareQuestion(rawQuestion);
const prompt = this.prompts[question.type];
if (prompt == null) {
throw new Error(`Prompt for type ${question.type} not found`);
}
let cleanupSignal;
const promptFn = isPromptConstructor(prompt)
? (q, opt) => new Promise((resolve, reject) => {
const { signal } = opt;
if (signal.aborted) {
reject(new core_1.AbortPromptError({ cause: signal.reason }));
return;
}
const rl = node_readline_1.default.createInterface(setupReadlineOptions(opt));
/**
* Handle the ^C exit
*/
const onForceClose = () => {
this.close();
process.kill(process.pid, 'SIGINT');
console.log('');
};
const onClose = () => {
process.removeListener('exit', onForceClose);
rl.removeListener('SIGINT', onForceClose);
rl.setPrompt('');
rl.output.unmute();
rl.output.write(ansi_1.cursorShow);
rl.output.end();
rl.close();
};
// Make sure new prompt start on a newline when closing
process.on('exit', onForceClose);
rl.on('SIGINT', onForceClose);
const activePrompt = new prompt(q, rl, this.answers);
const cleanup = () => {
onClose();
cleanupSignal?.();
};
const abort = () => {
reject(new core_1.AbortPromptError({ cause: signal.reason }));
cleanup();
};
signal.addEventListener('abort', abort);
cleanupSignal = () => {
signal.removeEventListener('abort', abort);
cleanupSignal = undefined;
};
activePrompt.run().then(resolve, reject).finally(cleanup);
})
: prompt;
let cleanupModuleSignal;
const { signal: moduleSignal } = this.opt;
if (moduleSignal?.aborted) {
this.abortController.abort(moduleSignal.reason);
}
else if (moduleSignal) {
const abort = () => this.abortController.abort(moduleSignal.reason);
moduleSignal.addEventListener('abort', abort);
cleanupModuleSignal = () => {
moduleSignal.removeEventListener('abort', abort);
};
}
const { filter = (value) => value } = question;
const { signal } = this.abortController;
return promptFn(question, { ...this.opt, signal })
.then((answer) => ({
name: question.name,
answer: filter(answer, this.answers),
}))
.finally(() => {
cleanupSignal?.();
cleanupModuleSignal?.();
});
};
/**
* Close the interface and cleanup listeners
*/
close = () => {
this.abortController.abort();
};
shouldRun = async (question) => {
if (question.askAnswered !== true &&
exports._.get(this.answers, question.name) !== undefined) {
return false;
}
const { when } = question;
if (typeof when === 'function') {
const shouldRun = await (0, run_async_1.default)(when)(this.answers);
return Boolean(shouldRun);
}
return when !== false;
};
}
exports.default = PromptsRunner;