/// import * as child_process from 'child_process'; import * as stream from 'stream'; import stream__default, { Writable, Readable } from 'stream'; type Dict = Record; type Arrayable = T | T[]; type Default = Dict; declare function mri(args?: string[], options?: mri.Options): mri.Argv; declare namespace mri { export interface Options { boolean?: Arrayable; string?: Arrayable; alias?: Dict>; default?: Dict; unknown?(flag: string): void; } export type Argv = T & { _: string[]; } } declare type Content = Buffer | NodeJS.ReadableStream | null; /** * Virtual File * * Like simplified vinyl, no dependencies. * * TODO: extends Blob (Node v15): https://nodejs.org/api/buffer.html#buffer_class_blob */ declare class VFile { #private; get contents(): Content; set contents(v: Content); get path(): string; set path(v: string); get dirname(): string; set dirname(v: string); get basename(): string; set basename(v: string); get extname(): string; set extname(v: string); get base(): string; set base(v: string); get relative(): string; isBuffer(): boolean; } // Type definitions for prompts 2.0 declare function prompts( questions: prompts.PromptObject | Array>, options?: prompts.Options ): Promise>; declare namespace prompts { // Circular reference from prompts const prompt: any; function inject(arr: ReadonlyArray): void; namespace inject { const prototype: {}; } function override(obj: { [key: string]: any }): void; namespace override { const prototype: {}; } namespace prompts { function autocomplete(args: PromptObject): any; function confirm(args: PromptObject): void; function date(args: PromptObject): any; function invisible(args: PromptObject): any; function list(args: PromptObject): any; function multiselect(args: PromptObject): any; function number(args: PromptObject): void; function password(args: PromptObject): any; function select(args: PromptObject): void; function text(args: PromptObject): void; function toggle(args: PromptObject): void; } // Based upon: https://github.com/terkelg/prompts/blob/d7d2c37a0009e3235b2e88a7d5cdbb114ac271b2/lib/elements/select.js#L29 interface Choice { title: string; value?: any; disabled?: boolean | undefined; selected?: boolean | undefined; description?: string | undefined; } interface Options { onSubmit?: ((prompt: PromptObject, answer: any, answers: any[]) => void) | undefined; onCancel?: ((prompt: PromptObject, answers: any) => void) | undefined; } interface PromptObject { type: PromptType | Falsy | PrevCaller; name: ValueOrFunc; message?: ValueOrFunc | undefined; initial?: InitialReturnValue | PrevCaller> | undefined; style?: string | PrevCaller | undefined; format?: PrevCaller | undefined; validate?: PrevCaller> | undefined; onState?: PrevCaller | undefined; min?: number | PrevCaller | undefined; max?: number | PrevCaller | undefined; float?: boolean | PrevCaller | undefined; round?: number | PrevCaller | undefined; instructions?: string | boolean | undefined; increment?: number | PrevCaller | undefined; separator?: string | PrevCaller | undefined; active?: string | PrevCaller | undefined; inactive?: string | PrevCaller | undefined; choices?: Choice[] | PrevCaller | undefined; hint?: string | PrevCaller | undefined; warn?: string | PrevCaller | undefined; suggest?: ((input: any, choices: Choice[]) => Promise) | undefined; limit?: number | PrevCaller | undefined; mask?: string | PrevCaller | undefined; stdout?: Writable | undefined; stdin?: Readable | undefined; } type Answers = { [id in T]: any }; type PrevCaller = ( prev: any, values: Answers, prompt: PromptObject ) => R; type Falsy = false | null | undefined; type PromptType = "text" | "password" | "invisible" | "number" | "confirm" | "list" | "toggle" | "select" | "multiselect" | "autocomplete" | "date" | "autocompleteMultiselect"; type ValueOrFunc = T | PrevCaller; type InitialReturnValue = string | number | boolean | Date; } declare type Argv = { clone?: true; }; declare type ParsedArgv = mri.Argv; declare type Generator = (api: API, context: Context) => Promise; declare type Awaited = T extends PromiseLike ? Awaited : T; declare type ReturnPair = Awaited>; declare type API = ReturnPair[1]; declare type Context = Omit; declare const loadGenerator: (argv: ParsedArgv, { mock }?: any) => Promise & { dev?: boolean | undefined; silent?: boolean | undefined; client?: "auto" | "yarn" | "npm" | undefined; }) => Promise; gitInit: (message?: string, { cwd, stdio }?: child_process.SpawnOptions) => Promise; prompts: typeof prompts; src: (globs: string[], options?: undefined) => stream__default.Transform; dest: (folder: string) => stream__default.Transform; pipeline: typeof stream__default.pipeline.__promisify__; packages: (patch: object | ((content: object, file: VFile) => object)) => stream__default.Transform; modify: { (match: (RegExp | ((file: VFile) => boolean)) | undefined, fn: (file: VFile) => void | VFile): stream__default.Transform; text: (match: RegExp | ((file: VFile) => boolean), fn: (file: VFile, content: string) => string) => stream__default.Transform; json: (match: (RegExp | ((file: VFile) => boolean)) | undefined, fn: (file: VFile, content: object) => object, { finalNewline, space }?: { finalNewline?: boolean | undefined; space?: string | undefined; }) => stream__default.Transform; rename: (match: RegExp | ((file: VFile) => boolean), fn: (file: VFile, info: { name: string; ext: string; dir: string; }) => void | { name: string; ext: string; dir: string; }) => stream__default.Transform; }; template: (data: object, { ext, test, render, options, }?: { ext?: RegExp | undefined; test?: RegExp | undefined; render?: ((content: string, data: object, options?: object | undefined) => string) | undefined; options?: object | undefined; }) => stream__default.Transform; }, { path: string; name: string; argv: ParsedArgv; }]>; declare const _default: (argv: ParsedArgv, opts?: any) => Promise; declare const run: (args: string[], usage: string | undefined, opts: mri.Options) => Promise; declare const mock: (generator: string, directory: string, { answers, api, context }?: any) => Promise<{ data: Record; dest(): stream.Transform; readonly files: string[]; readFile(file: string): string; }>; export { Argv, Generator, ParsedArgv, VFile, _default as create, mri as minimist, mock, run };