Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/sxzz/create. Command-line for creating projects from templates.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107import type { TemplateNormalized } from './config.ts'import type { Arrayable, Awaitable } from '@antfu/utils'import type { DownloadTemplateOptions } from 'giget'
export interface ProjectInfo { url: string folderName: string path: string variables: Record<string, any> git?: { getName: () => Promise<string> getEmail: () => Promise<string> }}
export interface Context { project: ProjectInfo template: TemplateNormalized}
export interface ConfigGit { /** @default true */ init?: boolean /** @default false */ add?: boolean}
export type ConfigReplaceFrom = Arrayable<string | RegExp>export type ConfigReplaceFromCallback = ( options: { file: string } & Context,) => ConfigReplaceFromexport type ConfigReplaceTo = Arrayable<string>export type ConfigReplaceToCallback = ( options: { match: string file: string } & Context,) => string
export interface ConfigReplace { include?: Arrayable<string> exclude?: Arrayable<string> from: ConfigReplaceFrom | ConfigReplaceFromCallback to: ConfigReplaceTo | ConfigReplaceToCallback /** @default true */ all?: boolean /** @default false */ ignoreCase?: boolean}
export interface Choice { value: string label?: string hint?: string}
export type ConfigVariable = { message: string; initial?: string } & ( | { type: 'text' required?: boolean placeholder?: Callbackable<string> } | { type: 'select'; choices: string[] | Choice[] })
export type Callbackable<T> = Awaitable<T> | ((ctx: Context) => Awaitable<T>)
export interface ConfigTemplate { name: string color?: string children?: ConfigTemplate[] /** * Format: [provider]:repo[/subpath][#ref] * * See also https://github.com/unjs/giget#downloadtemplatesource-options */ url?: string giget?: DownloadTemplateOptions
git?: { /** @default true */ init?: boolean /** @default false */ add?: boolean name?: string email?: string }
variables?: Callbackable<Record<string, ConfigVariable>>
replaces?: | ({ items: Arrayable<Partial<ConfigReplace>> } & Partial<ConfigReplace>) | ConfigReplace[]
commands?: Callbackable<Arrayable<string>> cwd?: string}
export interface Config extends Pick< ConfigTemplate, 'git' | 'replaces' | 'variables' | 'commands' | 'cwd'> { templates?: Arrayable<ConfigTemplate>}