File tree Expand file tree Collapse file tree 1 file changed +32
-3
lines changed Expand file tree Collapse file tree 1 file changed +32
-3
lines changed Original file line number Diff line number Diff line change 1
1
module . exports = api => {
2
2
api . describeConfig ( {
3
- // 唯一的配置 ID
4
3
id : 'vueconf.demo' ,
5
- // 展示名称
6
4
name : 'vueconf' ,
7
- // 该配置所有可能的文件
8
5
files : {
9
6
vue : {
10
7
js : [ 'vue.config.js' ]
11
8
}
9
+ } ,
10
+ onRead : ( {
11
+ data
12
+ } ) => {
13
+ return {
14
+ prompts : [ {
15
+ name : 'themeColor' ,
16
+ type : 'color' ,
17
+ message : '选择一种配置的颜色' ,
18
+ default : '#4DBA87' ,
19
+ value : data . vue . pluginOptions && data . vue . pluginOptions . vueconf && data . vue . pluginOptions . vueconf . themeColor
20
+ } ,
21
+ {
22
+ name : 'welcome' ,
23
+ type : 'input' ,
24
+ message : '项目介绍' ,
25
+ description : '请输入这个项目的介绍' ,
26
+ default : 'Learn React' ,
27
+ value : data . vue . pluginOptions && data . vue . pluginOptions . vueconf && data . vue . pluginOptions . vueconf . welcome
28
+ }
29
+ ]
30
+ }
31
+ } ,
32
+ onWrite : async ( {
33
+ api,
34
+ prompts
35
+ } ) => {
36
+ const result = { }
37
+ for ( const prompt of prompts ) {
38
+ result [ `pluginOptions.vueconf.${ prompt . id } ` ] = await api . getAnswer ( prompt . id )
39
+ }
40
+ api . setData ( 'vue' , result )
12
41
}
13
42
} )
14
43
}
You can’t perform that action at this time.
0 commit comments