@@ -7,7 +7,7 @@ import { createSpace } from '../spaces';
7
7
import type { Space } from '../spaces/actions' ;
8
8
import { mapiClient } from '../../api' ;
9
9
import { createEnvFile , fetchBlueprintRepositories , generateProject , generateSpaceUrl , openSpaceInBrowser } from './actions' ;
10
- import { blueprints } from './constants' ;
10
+ import { templates } from './constants' ;
11
11
12
12
// Mock all dependencies
13
13
vi . mock ( './actions' , ( ) => ( {
@@ -119,8 +119,8 @@ describe('createCommand', () => {
119
119
) ;
120
120
} ) ;
121
121
122
- describe ( 'blueprint validation' , ( ) => {
123
- it ( 'should accept valid blueprint via --blueprint flag' , async ( ) => {
122
+ describe ( 'template validation' , ( ) => {
123
+ it ( 'should accept valid template via --template flag' , async ( ) => {
124
124
const mockSpace = createMockSpace ( ) ;
125
125
126
126
vi . mocked ( generateProject ) . mockResolvedValue ( undefined ) ;
@@ -132,19 +132,80 @@ describe('createCommand', () => {
132
132
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
133
133
] ) ;
134
134
135
- await createCommand . parseAsync ( [ 'node' , 'test' , './my-project' , '--blueprint ' , 'react' ] ) ;
135
+ await createCommand . parseAsync ( [ 'node' , 'test' , './my-project' , '--template ' , 'react' ] ) ;
136
136
137
137
expect ( generateProject ) . toHaveBeenCalledWith ( 'react' , 'my-project' , expect . any ( String ) ) ;
138
138
139
139
// Check if createSpace was called (this is failing with 0 calls)
140
140
expect ( createSpace ) . toHaveBeenCalled ( ) ;
141
141
expect ( createSpace ) . toHaveBeenCalledWith ( {
142
142
name : 'My Project' ,
143
- domain : blueprints . REACT . location ,
143
+ domain : templates . REACT . location ,
144
144
} ) ;
145
145
} ) ;
146
146
147
- it ( 'should warn and show interactive selection for invalid blueprint' , async ( ) => {
147
+ it ( 'should warn and show interactive selection for invalid template' , async ( ) => {
148
+ vi . mocked ( select ) . mockResolvedValue ( 'vue' ) ;
149
+ vi . mocked ( input ) . mockResolvedValue ( './my-vue-project' ) ;
150
+
151
+ const mockSpace = createMockSpace ( ) ;
152
+
153
+ vi . mocked ( generateProject ) . mockResolvedValue ( undefined ) ;
154
+ vi . mocked ( createSpace ) . mockResolvedValue ( mockSpace ) ;
155
+ vi . mocked ( createEnvFile ) . mockResolvedValue ( undefined ) ;
156
+ vi . mocked ( openSpaceInBrowser ) . mockResolvedValue ( undefined ) ;
157
+ vi . mocked ( fetchBlueprintRepositories ) . mockResolvedValue ( [
158
+ { name : 'React' , value : 'react' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
159
+ { name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
160
+ ] ) ;
161
+
162
+ await createCommand . parseAsync ( [ 'node' , 'test' , '--template' , 'invalid-template' ] ) ;
163
+
164
+ expect ( konsola . warn ) . toHaveBeenCalledWith (
165
+ expect . stringContaining ( 'Invalid template "invalid-template"' ) ,
166
+ ) ;
167
+ expect ( select ) . toHaveBeenCalledWith ( expect . objectContaining ( {
168
+ message : 'Please select the technology you would like to use:' ,
169
+ } ) ) ;
170
+ } ) ;
171
+
172
+ it ( 'should accept valid template via deprecated --blueprint flag with warning' , async ( ) => {
173
+ const mockSpace = createMockSpace ( ) ;
174
+
175
+ vi . mocked ( generateProject ) . mockResolvedValue ( undefined ) ;
176
+ vi . mocked ( createSpace ) . mockResolvedValue ( mockSpace ) ;
177
+ vi . mocked ( createEnvFile ) . mockResolvedValue ( undefined ) ;
178
+ vi . mocked ( openSpaceInBrowser ) . mockResolvedValue ( undefined ) ;
179
+ vi . mocked ( fetchBlueprintRepositories ) . mockResolvedValue ( [
180
+ { name : 'React' , value : 'react' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
181
+ { name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
182
+ ] ) ;
183
+
184
+ await createCommand . parseAsync ( [ 'node' , 'test' , './my-project' , '--blueprint' , 'react' ] ) ;
185
+
186
+ expect ( konsola . warn ) . toHaveBeenCalledWith ( 'The --blueprint flag is deprecated. Please use --template instead.' ) ;
187
+ expect ( generateProject ) . toHaveBeenCalledWith ( 'react' , 'my-project' , expect . any ( String ) ) ;
188
+ } ) ;
189
+
190
+ it ( 'should prioritize --template over --blueprint when both are provided' , async ( ) => {
191
+ const mockSpace = createMockSpace ( ) ;
192
+
193
+ vi . mocked ( generateProject ) . mockResolvedValue ( undefined ) ;
194
+ vi . mocked ( createSpace ) . mockResolvedValue ( mockSpace ) ;
195
+ vi . mocked ( createEnvFile ) . mockResolvedValue ( undefined ) ;
196
+ vi . mocked ( openSpaceInBrowser ) . mockResolvedValue ( undefined ) ;
197
+ vi . mocked ( fetchBlueprintRepositories ) . mockResolvedValue ( [
198
+ { name : 'React' , value : 'react' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
199
+ { name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
200
+ ] ) ;
201
+
202
+ await createCommand . parseAsync ( [ 'node' , 'test' , './my-project' , '--blueprint' , 'react' , '--template' , 'vue' ] ) ;
203
+
204
+ expect ( konsola . warn ) . toHaveBeenCalledWith ( 'Both --blueprint and --template provided. Using --template and ignoring --blueprint.' ) ;
205
+ expect ( generateProject ) . toHaveBeenCalledWith ( 'vue' , 'my-project' , expect . any ( String ) ) ;
206
+ } ) ;
207
+
208
+ it ( 'should warn about deprecated --blueprint flag and show interactive selection for invalid value' , async ( ) => {
148
209
vi . mocked ( select ) . mockResolvedValue ( 'vue' ) ;
149
210
vi . mocked ( input ) . mockResolvedValue ( './my-vue-project' ) ;
150
211
@@ -161,8 +222,9 @@ describe('createCommand', () => {
161
222
162
223
await createCommand . parseAsync ( [ 'node' , 'test' , '--blueprint' , 'invalid-blueprint' ] ) ;
163
224
225
+ expect ( konsola . warn ) . toHaveBeenCalledWith ( 'The --blueprint flag is deprecated. Please use --template instead.' ) ;
164
226
expect ( konsola . warn ) . toHaveBeenCalledWith (
165
- expect . stringContaining ( 'Invalid blueprint "invalid-blueprint"' ) ,
227
+ expect . stringContaining ( 'Invalid template "invalid-blueprint"' ) ,
166
228
) ;
167
229
expect ( select ) . toHaveBeenCalledWith ( expect . objectContaining ( {
168
230
message : 'Please select the technology you would like to use:' ,
@@ -171,7 +233,7 @@ describe('createCommand', () => {
171
233
} ) ;
172
234
173
235
describe ( 'interactive mode' , ( ) => {
174
- it ( 'should prompt for blueprint selection when none provided' , async ( ) => {
236
+ it ( 'should prompt for template selection when none provided' , async ( ) => {
175
237
vi . mocked ( select ) . mockResolvedValue ( 'react' ) ;
176
238
vi . mocked ( input ) . mockResolvedValue ( './my-react-project' ) ;
177
239
@@ -266,7 +328,7 @@ describe('createCommand', () => {
266
328
vi . mocked ( createEnvFile ) . mockResolvedValue ( undefined ) ;
267
329
vi . mocked ( openSpaceInBrowser ) . mockResolvedValue ( undefined ) ;
268
330
269
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' ] ) ;
331
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' ] ) ;
270
332
271
333
// Verify project generation
272
334
expect ( generateProject ) . toHaveBeenCalledWith ( 'react' , 'my-project' , expect . any ( String ) ) ;
@@ -278,7 +340,7 @@ describe('createCommand', () => {
278
340
// Verify space creation
279
341
expect ( createSpace ) . toHaveBeenCalledWith ( {
280
342
name : 'My Project' ,
281
- domain : blueprints . REACT . location ,
343
+ domain : templates . REACT . location ,
282
344
} ) ;
283
345
284
346
// Verify .env file creation
@@ -304,7 +366,7 @@ describe('createCommand', () => {
304
366
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
305
367
] ) ;
306
368
307
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' ] ) ;
369
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' ] ) ;
308
370
309
371
expect ( handleError ) . toHaveBeenCalledWith ( generateError , undefined ) ;
310
372
} ) ;
@@ -319,7 +381,7 @@ describe('createCommand', () => {
319
381
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
320
382
] ) ;
321
383
322
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' ] ) ;
384
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' ] ) ;
323
385
324
386
expect ( generateProject ) . toHaveBeenCalled ( ) ;
325
387
expect ( handleError ) . toHaveBeenCalledWith ( spaceError , undefined ) ;
@@ -339,7 +401,7 @@ describe('createCommand', () => {
339
401
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
340
402
] ) ;
341
403
342
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' ] ) ;
404
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' ] ) ;
343
405
344
406
expect ( konsola . warn ) . toHaveBeenCalledWith ( 'Failed to create .env file: Permission denied' ) ;
345
407
expect ( konsola . info ) . toHaveBeenCalledWith (
@@ -364,7 +426,7 @@ describe('createCommand', () => {
364
426
vi . mocked ( openSpaceInBrowser ) . mockRejectedValue ( browserError ) ;
365
427
vi . mocked ( generateSpaceUrl ) . mockReturnValue ( 'https://app.storyblok.com/#/me/spaces/12345/dashboard' ) ;
366
428
367
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' ] ) ;
429
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' ] ) ;
368
430
369
431
expect ( konsola . warn ) . toHaveBeenCalledWith ( 'Failed to open browser: Failed to open browser' ) ;
370
432
expect ( generateSpaceUrl ) . toHaveBeenCalledWith ( 12345 , 'eu' ) ;
@@ -383,7 +445,7 @@ describe('createCommand', () => {
383
445
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
384
446
] ) ;
385
447
386
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' ] ) ;
448
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' ] ) ;
387
449
388
450
expect ( generateProject ) . not . toHaveBeenCalled ( ) ;
389
451
expect ( createSpace ) . not . toHaveBeenCalled ( ) ;
@@ -401,7 +463,7 @@ describe('createCommand', () => {
401
463
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
402
464
] ) ;
403
465
404
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' ] ) ;
466
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' ] ) ;
405
467
406
468
expect ( mapiClient ) . toHaveBeenCalledWith ( {
407
469
token : 'test-token' ,
@@ -410,14 +472,14 @@ describe('createCommand', () => {
410
472
} ) ;
411
473
} ) ;
412
474
413
- describe ( 'different blueprints ' , ( ) => {
475
+ describe ( 'different templates ' , ( ) => {
414
476
it . each ( [
415
477
[ 'react' , 'REACT' ] ,
416
478
[ 'vue' , 'VUE' ] ,
417
479
[ 'svelte' , 'SVELTE' ] ,
418
480
[ 'nuxt' , 'NUXT' ] ,
419
481
[ 'next' , 'NEXT' ] ,
420
- ] ) ( 'should handle %s blueprint correctly' , async ( blueprint , blueprintKey ) => {
482
+ ] ) ( 'should handle %s template correctly' , async ( template , templateKey ) => {
421
483
// Use createMockSpace to ensure the mock matches the Space type
422
484
const mockSpace = createMockSpace ( { id : 12345 , first_token : 'space-token-123' } ) ;
423
485
@@ -433,12 +495,12 @@ describe('createCommand', () => {
433
495
{ name : 'Next' , value : 'next' , template : '' , location : 'https://localhost:3000/' , description : '' , updated_at : '' } ,
434
496
] ) ;
435
497
436
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , blueprint ] ) ;
498
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , template ] ) ;
437
499
438
- expect ( generateProject ) . toHaveBeenCalledWith ( blueprint , 'my-project' , expect . any ( String ) ) ;
500
+ expect ( generateProject ) . toHaveBeenCalledWith ( template , 'my-project' , expect . any ( String ) ) ;
439
501
expect ( createSpace ) . toHaveBeenCalledWith ( {
440
502
name : 'My Project' ,
441
- domain : blueprints [ blueprintKey as keyof typeof blueprints ] . location ,
503
+ domain : templates [ templateKey as keyof typeof templates ] . location ,
442
504
} ) ;
443
505
} ) ;
444
506
} ) ;
@@ -457,7 +519,7 @@ describe('createCommand', () => {
457
519
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
458
520
] ) ;
459
521
460
- await createCommand . parseAsync ( [ 'node' , 'test' , './projects/my-project' , '--blueprint ' , 'react' ] ) ;
522
+ await createCommand . parseAsync ( [ 'node' , 'test' , './projects/my-project' , '--template ' , 'react' ] ) ;
461
523
462
524
expect ( generateProject ) . toHaveBeenCalledWith ( 'react' , 'my-project' , expect . stringContaining ( 'projects' ) ) ;
463
525
expect ( createEnvFile ) . toHaveBeenCalledWith ( expect . stringContaining ( 'my-project' ) , 'space-token-123' ) ;
@@ -476,7 +538,7 @@ describe('createCommand', () => {
476
538
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
477
539
] ) ;
478
540
479
- await createCommand . parseAsync ( [ 'node' , 'test' , '/absolute/path/my-project' , '--blueprint ' , 'react' ] ) ;
541
+ await createCommand . parseAsync ( [ 'node' , 'test' , '/absolute/path/my-project' , '--template ' , 'react' ] ) ;
480
542
481
543
expect ( generateProject ) . toHaveBeenCalledWith ( 'react' , 'my-project' , '/absolute/path' ) ;
482
544
} ) ;
@@ -490,7 +552,7 @@ describe('createCommand', () => {
490
552
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
491
553
] ) ;
492
554
493
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' , '--skip-space' ] ) ;
555
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' , '--skip-space' ] ) ;
494
556
495
557
// Verify project generation still happens
496
558
expect ( generateProject ) . toHaveBeenCalledWith ( 'react' , 'my-project' , expect . any ( String ) ) ;
@@ -545,7 +607,7 @@ describe('createCommand', () => {
545
607
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
546
608
] ) ;
547
609
548
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' , '--skip-space' ] ) ;
610
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' , '--skip-space' ] ) ;
549
611
550
612
// Should show project creation success
551
613
expect ( konsola . ok ) . toHaveBeenCalledWith (
@@ -574,7 +636,7 @@ describe('createCommand', () => {
574
636
{ name : 'Vue' , value : 'vue' , template : '' , location : 'https://localhost:5173/' , description : '' , updated_at : '' } ,
575
637
] ) ;
576
638
577
- await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--blueprint ' , 'react' , '--skip-space' ] ) ;
639
+ await createCommand . parseAsync ( [ 'node' , 'test' , 'my-project' , '--template ' , 'react' , '--skip-space' ] ) ;
578
640
579
641
// Should still handle the error properly
580
642
expect ( handleError ) . toHaveBeenCalledWith ( generateError , undefined ) ;
0 commit comments