执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import inquirer = require("inquirer");
// @types/globby doesn't export types for GlobOptions, so we have to work a little bit to extract them:
// GlobOptions is the second parameter of the sync function, which can be extracted with the Parameters<T> type
import { sync as _sync } from 'globby';
type GlobOptions = Parameters<typeof _sync>[1];
import {HelperDelegate as HelperFunction} from 'handlebars';
 
interface NodePlopAPI {
  getGenerator(name: string): PlopGenerator;
  setGenerator(name: string, config: PlopGenerator): PlopGenerator;
 
  setPrompt(name: string, prompt: inquirer.PromptModule): void;
  setWelcomeMessage(message: string): void;
  getWelcomeMessage(): string;
  getGeneratorList(): { name: string; description: string }[];
  setPartial(name: string, str: string): void;
  getPartial(name: string): string;
  getPartialList(): string[];
  setHelper(name: string, fn: HelperFunction): void;
  getHelper(name: string): Function;
  getHelperList(): string[];
  setActionType(name: string, fn: CustomActionFunction): void;
  getActionType(name: string): ActionType;
  getActionTypeList(): string[];
 
  setPlopfilePath(filePath: string): void;
  getPlopfilePath(): string;
  getDestBasePath(): string;
 
  // plop.load functionality
  load(
    target: string[] | string,
    loadCfg: PlopCfg,
    includeOverride: boolean
  ): void;
  setDefaultInclude(inc: object): void;
  getDefaultInclude(): object;
 
  renderString(template: string, data: any): String; //set to any matching handlebars declaration
 
  // passthroughs for backward compatibility
  addPrompt(name: string, prompt: inquirer.PromptModule): void;
  addPartial(name: string, str: string): void;
  addHelper(name: string, fn: Function): void;
}
 
export interface PlopGenerator {
  description: string;
  prompts: inquirer.Question[];
  actions: ActionType[];
}
 
export type CustomActionFunction = (
  answers: object,
  config?: ActionConfig,
  plopfileApi?: NodePlopAPI
) => Promise<string> | string; // Check return type?
 
export type ActionType =
  | ActionConfig
  | AddManyActionConfig
  | ModifyActionConfig
  | AppendActionConfig
  | CustomActionFunction;
 
export interface ActionConfig {
  type: string;
  force: boolean;
  data: object;
  abortOnFail: boolean;
}
 
export interface AddActionConfig extends ActionConfig {
  type: "add";
  path: string;
  template: string;
  templateFile: string;
  skipIfExists: boolean;
}
 
export interface AddManyActionConfig
  extends Pick<AddActionConfig, Exclude<keyof AddActionConfig, "type">> {
  type: "addMany";
  destination: string;
  base: string;
  templateFiles: string;
  globOptions: GlobOptions;
  verbose: boolean;
}
 
export interface ModifyActionConfig extends ActionConfig {
  type: "modify";
  path: string;
  pattern: string | RegExp;
  template: string;
  templateFile: string;
 
export interface AppendActionConfig extends ActionConfig {
  type: "append";
  path: string;
  pattern: string | RegExp;
  unique: boolean;
  separator: string;
  template: string;
  templateFile: string;
}
 
export interface PlopCfg {
  force: boolean;
  destBasePath: string;
}
 
declare function nodePlop(plopfilePath: string, plopCfg?: PlopCfg): NodePlopAPI;
export default nodePlop;