1 | import inquirer = require("inquirer");
|
2 |
|
3 |
|
4 | import { GlobbyOptions } from 'globby';
|
5 | import {HelperDelegate as HelperFunction} from 'handlebars';
|
6 |
|
7 | export interface NodePlopAPI {
|
8 | getGenerator(name: string): PlopGenerator;
|
9 | setGenerator(name: string, config: PlopGenerator): PlopGenerator;
|
10 |
|
11 | setPrompt(name: string, prompt: inquirer.PromptModule): void;
|
12 | setWelcomeMessage(message: string): void;
|
13 | getWelcomeMessage(): string;
|
14 | getGeneratorList(): { name: string; description: string }[];
|
15 | setPartial(name: string, str: string): void;
|
16 | getPartial(name: string): string;
|
17 | getPartialList(): string[];
|
18 | setHelper(name: string, fn: HelperFunction): void;
|
19 | getHelper(name: string): Function;
|
20 | getHelperList(): string[];
|
21 | setActionType(name: string, fn: CustomActionFunction): void;
|
22 | getActionType(name: string): ActionType;
|
23 | getActionTypeList(): string[];
|
24 |
|
25 | setPlopfilePath(filePath: string): void;
|
26 | getPlopfilePath(): string;
|
27 | getDestBasePath(): string;
|
28 |
|
29 |
|
30 | load(
|
31 | target: string[] | string,
|
32 | loadCfg: PlopCfg,
|
33 | includeOverride: boolean
|
34 | ): void;
|
35 | setDefaultInclude(inc: object): void;
|
36 | getDefaultInclude(): object;
|
37 |
|
38 | renderString(template: string, data: any): String;
|
39 |
|
40 |
|
41 | addPrompt(name: string, prompt: inquirer.PromptModule): void;
|
42 | addPartial(name: string, str: string): void;
|
43 | addHelper(name: string, fn: Function): void;
|
44 | }
|
45 |
|
46 | export interface PlopGenerator {
|
47 | description: string;
|
48 | prompts: inquirer.Question[];
|
49 | actions: ActionType[];
|
50 | }
|
51 |
|
52 | export type CustomActionFunction = (
|
53 | answers: object,
|
54 | config?: ActionConfig,
|
55 | plopfileApi?: NodePlopAPI
|
56 | ) => Promise<string> | string;
|
57 |
|
58 | export type ActionType =
|
59 | | ActionConfig
|
60 | | AddManyActionConfig
|
61 | | ModifyActionConfig
|
62 | | AppendActionConfig
|
63 | | CustomActionFunction;
|
64 |
|
65 | export interface ActionConfig {
|
66 | type: string;
|
67 | force: boolean;
|
68 | data: object;
|
69 | abortOnFail: boolean;
|
70 | }
|
71 |
|
72 | export interface AddActionConfig extends ActionConfig {
|
73 | type: "add";
|
74 | path: string;
|
75 | template: string;
|
76 | templateFile: string;
|
77 | skipIfExists: boolean;
|
78 | }
|
79 |
|
80 | export interface AddManyActionConfig
|
81 | extends Pick<AddActionConfig, Exclude<keyof AddActionConfig, "type">> {
|
82 | type: "addMany";
|
83 | destination: string;
|
84 | base: string;
|
85 | templateFiles: string;
|
86 | globOptions: GlobbyOptions;
|
87 | verbose: boolean;
|
88 | }
|
89 |
|
90 | export interface ModifyActionConfig extends ActionConfig {
|
91 | type: "modify";
|
92 | path: string;
|
93 | pattern: string | RegExp;
|
94 | template: string;
|
95 | templateFile: string;
|
96 | }
|
97 |
|
98 | export interface AppendActionConfig extends ActionConfig {
|
99 | type: "append";
|
100 | path: string;
|
101 | pattern: string | RegExp;
|
102 | unique: boolean;
|
103 | separator: string;
|
104 | template: string;
|
105 | templateFile: string;
|
106 | }
|
107 |
|
108 | export interface PlopCfg {
|
109 | force: boolean;
|
110 | destBasePath: string;
|
111 | }
|
112 |
|
113 | declare function nodePlop(plopfilePath: string, plopCfg?: PlopCfg): NodePlopAPI;
|
114 | export default nodePlop;
|