UNPKG

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