UNPKG

2.16 kBTypeScriptView Raw
1import { CompilerType, CSSType, FrameworkType, NpmType } from '@tarojs/binding';
2import Creator from './creator';
3import type { ITemplates } from './fetchTemplate';
4export interface IProjectConf {
5 projectName: string;
6 projectDir: string;
7 npm: NpmType;
8 templateSource: string;
9 clone?: boolean;
10 template: string;
11 description?: string;
12 typescript?: boolean;
13 css: CSSType;
14 date?: string;
15 src?: string;
16 sourceRoot?: string;
17 env?: string;
18 autoInstall?: boolean;
19 hideDefaultTemplate?: boolean;
20 framework: FrameworkType;
21 compiler?: CompilerType;
22}
23type CustomPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
24type IProjectConfOptions = CustomPartial<IProjectConf, 'projectName' | 'projectDir' | 'template' | 'css' | 'npm' | 'framework' | 'templateSource'>;
25interface AskMethods {
26 (conf: IProjectConfOptions, prompts: Record<string, unknown>[], choices?: ITemplates[]): void;
27}
28export default class Project extends Creator {
29 rootPath: string;
30 conf: IProjectConfOptions;
31 constructor(options: IProjectConfOptions);
32 init(): void;
33 create(): Promise<void>;
34 ask(): Promise<{
35 projectName: string;
36 projectDir: string;
37 npm: NpmType;
38 templateSource: string;
39 clone?: boolean | undefined;
40 template: string;
41 description?: string | undefined;
42 typescript?: boolean | undefined;
43 css: CSSType;
44 date?: string | undefined;
45 src?: string | undefined;
46 sourceRoot?: string | undefined;
47 env?: string | undefined;
48 autoInstall?: boolean | undefined;
49 hideDefaultTemplate?: boolean | undefined;
50 framework: FrameworkType;
51 compiler?: CompilerType | undefined;
52 }>;
53 askProjectName: AskMethods;
54 askDescription: AskMethods;
55 askTypescript: AskMethods;
56 askCSS: AskMethods;
57 askCompiler: AskMethods;
58 askFramework: AskMethods;
59 askTemplateSource: AskMethods;
60 askTemplate: AskMethods;
61 askNpm: AskMethods;
62 fetchTemplates(answers: IProjectConf): Promise<ITemplates[]>;
63 write(cb?: () => void): void;
64}
65export {};