@@ -44,25 +44,28 @@ qux($1)
4444
4545test ( 'api: extendPackage' , async ( ) => {
4646 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+ } )
6669
6770 await generator . generate ( )
6871
@@ -79,14 +82,17 @@ test('api: extendPackage', async () => {
7982} )
8083
8184test ( '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+ } )
9096
9197 await generator . generate ( )
9298
@@ -97,7 +103,7 @@ test('api: extendPackage function', async () => {
97103} )
98104
99105test ( 'api: extendPackage merge dependencies' , async ( ) => {
100- const generator = new Generator ( '/' , { } , [
106+ const generator = new Generator ( '/' , { plugins : [
101107 {
102108 id : 'test1' ,
103109 apply : api => {
@@ -120,7 +126,7 @@ test('api: extendPackage merge dependencies', async () => {
120126 } )
121127 }
122128 }
123- ] )
129+ ] } )
124130
125131 await generator . generate ( )
126132
@@ -135,7 +141,7 @@ test('api: extendPackage merge dependencies', async () => {
135141} )
136142
137143test ( 'api: warn invalid dep range' , async ( ) => {
138- new Generator ( '/' , { } , [
144+ new Generator ( '/' , { plugins : [
139145 {
140146 id : 'test1' ,
141147 apply : api => {
@@ -146,7 +152,7 @@ test('api: warn invalid dep range', async () => {
146152 } )
147153 }
148154 }
149- ] )
155+ ] } )
150156
151157 expect ( logs . warn . some ( ( [ msg ] ) => {
152158 return (
@@ -157,7 +163,7 @@ test('api: warn invalid dep range', async () => {
157163} )
158164
159165test ( 'api: extendPackage dependencies conflict' , async ( ) => {
160- new Generator ( '/' , { } , [
166+ new Generator ( '/' , { plugins : [
161167 {
162168 id : 'test1' ,
163169 apply : api => {
@@ -178,7 +184,7 @@ test('api: extendPackage dependencies conflict', async () => {
178184 } )
179185 }
180186 }
181- ] )
187+ ] } )
182188
183189 expect ( logs . warn . some ( ( [ msg ] ) => {
184190 return (
@@ -191,7 +197,7 @@ test('api: extendPackage dependencies conflict', async () => {
191197} )
192198
193199test ( 'api: render fs directory' , async ( ) => {
194- const generator = new Generator ( '/' , { } , [
200+ const generator = new Generator ( '/' , { plugins : [
195201 {
196202 id : 'test1' ,
197203 apply : api => {
@@ -201,7 +207,7 @@ test('api: render fs directory', async () => {
201207 n : 1
202208 }
203209 }
204- ] )
210+ ] } )
205211
206212 await generator . generate ( )
207213
@@ -212,7 +218,7 @@ test('api: render fs directory', async () => {
212218} )
213219
214220test ( 'api: render object' , async ( ) => {
215- const generator = new Generator ( '/' , { } , [
221+ const generator = new Generator ( '/' , { plugins : [
216222 {
217223 id : 'test1' ,
218224 apply : api => {
@@ -225,7 +231,7 @@ test('api: render object', async () => {
225231 n : 2
226232 }
227233 }
228- ] )
234+ ] } )
229235
230236 await generator . generate ( )
231237
@@ -234,7 +240,7 @@ test('api: render object', async () => {
234240} )
235241
236242test ( 'api: render middleware' , async ( ) => {
237- const generator = new Generator ( '/' , { } , [
243+ const generator = new Generator ( '/' , { plugins : [
238244 {
239245 id : 'test1' ,
240246 apply : ( api , options ) => {
@@ -247,7 +253,7 @@ test('api: render middleware', async () => {
247253 n : 3
248254 }
249255 }
250- ] )
256+ ] } )
251257
252258 await generator . generate ( )
253259
@@ -256,7 +262,7 @@ test('api: render middleware', async () => {
256262} )
257263
258264test ( 'api: hasPlugin' , ( ) => {
259- new Generator ( '/' , { } , [
265+ new Generator ( '/' , { plugins : [
260266 {
261267 id : 'foo' ,
262268 apply : api => {
@@ -275,32 +281,35 @@ test('api: hasPlugin', () => {
275281 id : '@vue/cli-plugin-baz' ,
276282 apply : ( ) => { }
277283 }
278- ] )
284+ ] } )
279285} )
280286
281287test ( 'api: onCreateComplete' , ( ) => {
282288 const fn = ( ) => { }
283289 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+ }
289297 }
290- }
291- ] , cbs )
298+ ] ,
299+ completeCbs : cbs
300+ } )
292301 expect ( cbs ) . toContain ( fn )
293302} )
294303
295304test ( 'api: resolve' , ( ) => {
296- new Generator ( '/foo/bar' , { } , [
305+ new Generator ( '/foo/bar' , { plugins : [
297306 {
298307 id : 'test' ,
299308 apply : api => {
300309 expect ( api . resolve ( 'baz' ) ) . toBe ( path . resolve ( '/foo/bar' , 'baz' ) )
301310 }
302311 }
303- ] )
312+ ] } )
304313} )
305314
306315test ( 'extract config files' , async ( ) => {
@@ -322,14 +331,14 @@ test('extract config files', async () => {
322331 }
323332 }
324333
325- const generator = new Generator ( '/' , { } , [
334+ const generator = new Generator ( '/' , { plugins : [
326335 {
327336 id : 'test' ,
328337 apply : api => {
329338 api . extendPackage ( configs )
330339 }
331340 }
332- ] )
341+ ] } )
333342
334343 await generator . generate ( {
335344 extractConfigFiles : true
0 commit comments