-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
/
Copy pathGeneratorAPI.js
56 lines (42 loc) · 1.04 KB
/
GeneratorAPI.js
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
module.exports = class GeneratorAPI {
constructor (creator, generator) {
this.creator = creator
this.generator = generator
}
injectFeature (feature) {
this.creator.featurePrompt.choices.push(feature)
}
injectOptionForFeature (featureName, option) {
const feature = this.creator.featurePrompt.choices.find(f => {
return f.name === featureName
})
if (!feature) {
throw new Error(
`injectOptionForFeature error in generator "${
this.generator.id
}": feature "${featureName}" does not exist.`
)
}
feature.choices.push(option)
}
injectPrompt (prompt) {
this.creator.injectedPrompts.push(prompt)
}
onPromptComplete (cb) {
this.creator.promptCompleteCbs.push(cb)
}
injectDeps (deps) {
}
injectScripts (scripts) {
}
injectPackageFields (fields) {
}
injectFilesMiddleware (middleware) {
this.creator.fileMiddlewares.push(middleware)
}
renderFile (file) {
}
onCreateComplete (msg) {
this.creator.onCreateCompleteCbs.push(cb)
}
}