@@ -44,25 +44,28 @@ qux($1)
44
44
45
45
test ( 'api: extendPackage' , async ( ) => {
46
46
const generator = new Generator ( '/' , {
47
- name : 'hello' ,
48
- list : [ 1 ] ,
49
- vue : {
50
- foo : 1 ,
51
- bar : 2
52
- }
53
- } , [ {
54
- id : 'test' ,
55
- apply : api => {
56
- api . extendPackage ( {
57
- name : 'hello2' ,
58
- list : [ 2 ] ,
59
- vue : {
60
- foo : 2 ,
61
- baz : 3
62
- }
63
- } )
64
- }
65
- } ] )
47
+ pkg : {
48
+ name : 'hello' ,
49
+ list : [ 1 ] ,
50
+ vue : {
51
+ foo : 1 ,
52
+ bar : 2
53
+ }
54
+ } ,
55
+ plugins : [ {
56
+ id : 'test' ,
57
+ apply : api => {
58
+ api . extendPackage ( {
59
+ name : 'hello2' ,
60
+ list : [ 2 ] ,
61
+ vue : {
62
+ foo : 2 ,
63
+ baz : 3
64
+ }
65
+ } )
66
+ }
67
+ } ]
68
+ } )
66
69
67
70
await generator . generate ( )
68
71
@@ -79,14 +82,17 @@ test('api: extendPackage', async () => {
79
82
} )
80
83
81
84
test ( 'api: extendPackage function' , async ( ) => {
82
- const generator = new Generator ( '/' , { foo : 1 } , [ {
83
- id : 'test' ,
84
- apply : api => {
85
- api . extendPackage ( pkg => ( {
86
- foo : pkg . foo + 1
87
- } ) )
88
- }
89
- } ] )
85
+ const generator = new Generator ( '/' , {
86
+ pkg : { foo : 1 } ,
87
+ plugins : [ {
88
+ id : 'test' ,
89
+ apply : api => {
90
+ api . extendPackage ( pkg => ( {
91
+ foo : pkg . foo + 1
92
+ } ) )
93
+ }
94
+ } ]
95
+ } )
90
96
91
97
await generator . generate ( )
92
98
@@ -97,7 +103,7 @@ test('api: extendPackage function', async () => {
97
103
} )
98
104
99
105
test ( 'api: extendPackage merge dependencies' , async ( ) => {
100
- const generator = new Generator ( '/' , { } , [
106
+ const generator = new Generator ( '/' , { plugins : [
101
107
{
102
108
id : 'test1' ,
103
109
apply : api => {
@@ -120,7 +126,7 @@ test('api: extendPackage merge dependencies', async () => {
120
126
} )
121
127
}
122
128
}
123
- ] )
129
+ ] } )
124
130
125
131
await generator . generate ( )
126
132
@@ -135,7 +141,7 @@ test('api: extendPackage merge dependencies', async () => {
135
141
} )
136
142
137
143
test ( 'api: warn invalid dep range' , async ( ) => {
138
- new Generator ( '/' , { } , [
144
+ new Generator ( '/' , { plugins : [
139
145
{
140
146
id : 'test1' ,
141
147
apply : api => {
@@ -146,7 +152,7 @@ test('api: warn invalid dep range', async () => {
146
152
} )
147
153
}
148
154
}
149
- ] )
155
+ ] } )
150
156
151
157
expect ( logs . warn . some ( ( [ msg ] ) => {
152
158
return (
@@ -157,7 +163,7 @@ test('api: warn invalid dep range', async () => {
157
163
} )
158
164
159
165
test ( 'api: extendPackage dependencies conflict' , async ( ) => {
160
- new Generator ( '/' , { } , [
166
+ new Generator ( '/' , { plugins : [
161
167
{
162
168
id : 'test1' ,
163
169
apply : api => {
@@ -178,7 +184,7 @@ test('api: extendPackage dependencies conflict', async () => {
178
184
} )
179
185
}
180
186
}
181
- ] )
187
+ ] } )
182
188
183
189
expect ( logs . warn . some ( ( [ msg ] ) => {
184
190
return (
@@ -191,7 +197,7 @@ test('api: extendPackage dependencies conflict', async () => {
191
197
} )
192
198
193
199
test ( 'api: render fs directory' , async ( ) => {
194
- const generator = new Generator ( '/' , { } , [
200
+ const generator = new Generator ( '/' , { plugins : [
195
201
{
196
202
id : 'test1' ,
197
203
apply : api => {
@@ -201,7 +207,7 @@ test('api: render fs directory', async () => {
201
207
n : 1
202
208
}
203
209
}
204
- ] )
210
+ ] } )
205
211
206
212
await generator . generate ( )
207
213
@@ -212,7 +218,7 @@ test('api: render fs directory', async () => {
212
218
} )
213
219
214
220
test ( 'api: render object' , async ( ) => {
215
- const generator = new Generator ( '/' , { } , [
221
+ const generator = new Generator ( '/' , { plugins : [
216
222
{
217
223
id : 'test1' ,
218
224
apply : api => {
@@ -225,7 +231,7 @@ test('api: render object', async () => {
225
231
n : 2
226
232
}
227
233
}
228
- ] )
234
+ ] } )
229
235
230
236
await generator . generate ( )
231
237
@@ -234,7 +240,7 @@ test('api: render object', async () => {
234
240
} )
235
241
236
242
test ( 'api: render middleware' , async ( ) => {
237
- const generator = new Generator ( '/' , { } , [
243
+ const generator = new Generator ( '/' , { plugins : [
238
244
{
239
245
id : 'test1' ,
240
246
apply : ( api , options ) => {
@@ -247,7 +253,7 @@ test('api: render middleware', async () => {
247
253
n : 3
248
254
}
249
255
}
250
- ] )
256
+ ] } )
251
257
252
258
await generator . generate ( )
253
259
@@ -256,7 +262,7 @@ test('api: render middleware', async () => {
256
262
} )
257
263
258
264
test ( 'api: hasPlugin' , ( ) => {
259
- new Generator ( '/' , { } , [
265
+ new Generator ( '/' , { plugins : [
260
266
{
261
267
id : 'foo' ,
262
268
apply : api => {
@@ -275,32 +281,35 @@ test('api: hasPlugin', () => {
275
281
id : '@vue/cli-plugin-baz' ,
276
282
apply : ( ) => { }
277
283
}
278
- ] )
284
+ ] } )
279
285
} )
280
286
281
287
test ( 'api: onCreateComplete' , ( ) => {
282
288
const fn = ( ) => { }
283
289
const cbs = [ ]
284
- new Generator ( '/' , { } , [
285
- {
286
- id : 'test' ,
287
- apply : api => {
288
- api . onCreateComplete ( fn )
290
+ new Generator ( '/' , {
291
+ plugins : [
292
+ {
293
+ id : 'test' ,
294
+ apply : api => {
295
+ api . onCreateComplete ( fn )
296
+ }
289
297
}
290
- }
291
- ] , cbs )
298
+ ] ,
299
+ completeCbs : cbs
300
+ } )
292
301
expect ( cbs ) . toContain ( fn )
293
302
} )
294
303
295
304
test ( 'api: resolve' , ( ) => {
296
- new Generator ( '/foo/bar' , { } , [
305
+ new Generator ( '/foo/bar' , { plugins : [
297
306
{
298
307
id : 'test' ,
299
308
apply : api => {
300
309
expect ( api . resolve ( 'baz' ) ) . toBe ( path . resolve ( '/foo/bar' , 'baz' ) )
301
310
}
302
311
}
303
- ] )
312
+ ] } )
304
313
} )
305
314
306
315
test ( 'extract config files' , async ( ) => {
@@ -322,14 +331,14 @@ test('extract config files', async () => {
322
331
}
323
332
}
324
333
325
- const generator = new Generator ( '/' , { } , [
334
+ const generator = new Generator ( '/' , { plugins : [
326
335
{
327
336
id : 'test' ,
328
337
apply : api => {
329
338
api . extendPackage ( configs )
330
339
}
331
340
}
332
- ] )
341
+ ] } )
333
342
334
343
await generator . generate ( {
335
344
extractConfigFiles : true
0 commit comments