@@ -107,7 +107,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
107
107
108
108
await builder . build ( )
109
109
110
- const deploy = await callCli ( [ 'deploy' , '--json' , '--dir' , 'public' ] , {
110
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' , '-- dir', 'public' ] , {
111
111
cwd : builder . directory ,
112
112
env : { NETLIFY_SITE_ID : context . siteId } ,
113
113
} ) . then ( ( output ) => JSON . parse ( output ) )
@@ -132,7 +132,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
132
132
133
133
await builder . build ( )
134
134
135
- const deploy = await callCli ( [ 'deploy' , '--json' , '--site' , SITE_NAME ] , {
135
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' , '-- site', SITE_NAME ] , {
136
136
cwd : builder . directory ,
137
137
} ) . then ( ( output ) => JSON . parse ( output ) )
138
138
@@ -156,7 +156,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
156
156
157
157
await builder . build ( )
158
158
159
- const deploy = await callCli ( [ 'deploy' , '--json' ] , {
159
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' ] , {
160
160
cwd : builder . directory ,
161
161
env : { NETLIFY_SITE_ID : context . siteId } ,
162
162
} ) . then ( ( output ) => JSON . parse ( output ) )
@@ -192,7 +192,9 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
192
192
}
193
193
194
194
await callCli ( [ 'build' ] , options )
195
- const deploy = await callCli ( [ 'deploy' , '--json' ] , options ) . then ( ( output ) => JSON . parse ( output ) )
195
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' ] , options ) . then ( ( output ) =>
196
+ JSON . parse ( output ) ,
197
+ )
196
198
197
199
// give edge functions manifest a couple ticks to propagate
198
200
await pause ( 500 )
@@ -236,8 +238,8 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
236
238
}
237
239
238
240
await callCli ( [ 'build' , '--cwd' , pathPrefix ] , options )
239
- const deploy = await callCli ( [ 'deploy' , '--json' , '--cwd' , pathPrefix ] , options ) . then ( ( output ) =>
240
- JSON . parse ( output ) ,
241
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' , '-- cwd', pathPrefix ] , options ) . then (
242
+ ( output ) => JSON . parse ( output ) ,
241
243
)
242
244
243
245
// give edge functions manifest a couple ticks to propagate
@@ -252,7 +254,73 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
252
254
} )
253
255
} )
254
256
255
- test ( 'should run build command before deploy when build flag is passed' , async ( t ) => {
257
+ test ( 'runs build command before deploy by default' , async ( t ) => {
258
+ await withSiteBuilder ( t , async ( builder ) => {
259
+ const content = '<h1>⊂◉‿◉つ</h1>'
260
+ builder
261
+ . withContentFile ( {
262
+ path : 'public/index.html' ,
263
+ content,
264
+ } )
265
+ . withNetlifyToml ( {
266
+ config : {
267
+ build : { publish : 'public' } ,
268
+ plugins : [ { package : './plugins/log-env' } ] ,
269
+ } ,
270
+ } )
271
+ . withBuildPlugin ( {
272
+ name : 'log-env' ,
273
+ plugin : {
274
+ async onSuccess ( ) {
275
+ const { DEPLOY_ID , DEPLOY_URL } = require ( 'process' ) . env
276
+ console . log ( `DEPLOY_ID: ${ DEPLOY_ID } ` )
277
+ console . log ( `DEPLOY_URL: ${ DEPLOY_URL } ` )
278
+ } ,
279
+ } ,
280
+ } )
281
+
282
+ await builder . build ( )
283
+
284
+ const output = await callCli ( [ 'deploy' ] , {
285
+ cwd : builder . directory ,
286
+ env : { NETLIFY_SITE_ID : context . siteId } ,
287
+ } )
288
+
289
+ t . expect ( output ) . toContain ( 'Netlify Build completed in' )
290
+ const [ , deployId ] = output . match ( / D E P L O Y _ I D : ( \w + ) / ) ?? [ ]
291
+ const [ , deployURL ] = output . match ( / D E P L O Y _ U R L : ( .+ ) / ) ?? [ ]
292
+
293
+ t . expect ( deployId ) . not . toEqual ( '0' )
294
+ t . expect ( deployURL ) . toContain ( `https://${ deployId } --` )
295
+ } )
296
+ } )
297
+
298
+ test ( 'should return valid json when --json is passed' , async ( t ) => {
299
+ await withSiteBuilder ( t , async ( builder ) => {
300
+ const content = '<h1>⊂◉‿◉つ</h1>'
301
+ builder
302
+ . withContentFile ( {
303
+ path : 'public/index.html' ,
304
+ content,
305
+ } )
306
+ . withNetlifyToml ( {
307
+ config : {
308
+ build : { publish : 'public' } ,
309
+ } ,
310
+ } )
311
+
312
+ await builder . build ( )
313
+
314
+ const output = await callCli ( [ 'deploy' , '--json' ] , {
315
+ cwd : builder . directory ,
316
+ env : { NETLIFY_SITE_ID : context . siteId } ,
317
+ } )
318
+
319
+ expect ( ( ) => JSON . parse ( output ) ) . not . toThrowError ( )
320
+ } )
321
+ } )
322
+
323
+ test ( 'does not run build command before deploy when --build=false flag is passed' , async ( t ) => {
256
324
await withSiteBuilder ( t , async ( builder ) => {
257
325
const content = '<h1>⊂◉‿◉つ</h1>'
258
326
builder
@@ -279,12 +347,12 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
279
347
280
348
await builder . build ( )
281
349
282
- const output = await callCli ( [ 'deploy' , '--build' ] , {
350
+ const output = await callCli ( [ 'deploy' , '--build' , 'false' ] , {
283
351
cwd : builder . directory ,
284
352
env : { NETLIFY_SITE_ID : context . siteId } ,
285
353
} )
286
354
287
- t . expect ( output . includes ( 'Netlify Build completed in' ) ) . toBe ( true )
355
+ t . expect ( output ) . not . toContain ( 'Netlify Build completed in' )
288
356
const [ , deployId ] = output . match ( / D E P L O Y _ I D : ( \w + ) / ) ?? [ ]
289
357
const [ , deployURL ] = output . match ( / D E P L O Y _ U R L : ( .+ ) / ) ?? [ ]
290
358
@@ -302,7 +370,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
302
370
} )
303
371
await builder . build ( )
304
372
305
- const deploy = await callCli ( [ 'deploy' , '--json' , '--dir' , 'public' ] , {
373
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' , '-- dir', 'public' ] , {
306
374
cwd : builder . directory ,
307
375
env : { NETLIFY_SITE_ID : context . siteId } ,
308
376
} ) . then ( ( output ) => JSON . parse ( output ) )
@@ -329,7 +397,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
329
397
} )
330
398
await builder . build ( )
331
399
332
- const deploy = await callCli ( [ 'deploy' , '--json' , '--dir' , 'public' , '--prod' ] , {
400
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' , '-- dir', 'public' , '--prod' ] , {
333
401
cwd : builder . directory ,
334
402
env : { NETLIFY_SITE_ID : context . siteId } ,
335
403
} ) . then ( ( output ) => JSON . parse ( output ) )
@@ -344,31 +412,6 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
344
412
} )
345
413
} )
346
414
347
- test ( 'should return valid json when both --build and --json are passed' , async ( t ) => {
348
- await withSiteBuilder ( t , async ( builder ) => {
349
- const content = '<h1>⊂◉‿◉つ</h1>'
350
- builder
351
- . withContentFile ( {
352
- path : 'public/index.html' ,
353
- content,
354
- } )
355
- . withNetlifyToml ( {
356
- config : {
357
- build : { publish : 'public' } ,
358
- } ,
359
- } )
360
-
361
- await builder . build ( )
362
-
363
- const output = await callCli ( [ 'deploy' , '--build' , '--json' ] , {
364
- cwd : builder . directory ,
365
- env : { NETLIFY_SITE_ID : context . siteId } ,
366
- } )
367
-
368
- JSON . parse ( output )
369
- } )
370
- } )
371
-
372
415
test ( 'should deploy hidden public folder but ignore hidden/__MACOSX files' , { retry : 3 } , async ( t ) => {
373
416
await withSiteBuilder ( t , async ( builder ) => {
374
417
builder
@@ -398,7 +441,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
398
441
399
442
await builder . build ( )
400
443
401
- const deploy = await callCli ( [ 'deploy' , '--json' ] , {
444
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' ] , {
402
445
cwd : builder . directory ,
403
446
env : { NETLIFY_SITE_ID : context . siteId } ,
404
447
} ) . then ( ( output ) => JSON . parse ( output ) )
@@ -443,7 +486,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
443
486
444
487
await builder . build ( )
445
488
446
- const deploy = await callCli ( [ 'deploy' , '--json' ] , {
489
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' ] , {
447
490
cwd : builder . directory ,
448
491
env : { NETLIFY_SITE_ID : context . siteId } ,
449
492
} ) . then ( ( output ) => JSON . parse ( output ) )
@@ -478,7 +521,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
478
521
479
522
await builder . build ( )
480
523
481
- const deploy = await callCli ( [ 'deploy' , '--json' ] , {
524
+ const deploy = await callCli ( [ 'deploy' , '--json' , '--build' , 'false' ] , {
482
525
cwd : builder . directory ,
483
526
env : { NETLIFY_SITE_ID : context . siteId } ,
484
527
} ) . then ( ( output ) => JSON . parse ( output ) )
@@ -497,7 +540,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
497
540
await builder . build ( )
498
541
499
542
try {
500
- await callCli ( [ 'deploy' , '--dir' , '.' ] , {
543
+ await callCli ( [ 'deploy' , '--build' , 'false' , '-- dir', '.' ] , {
501
544
cwd : builder . directory ,
502
545
env : { NETLIFY_SITE_ID : context . siteId } ,
503
546
} )
@@ -507,7 +550,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
507
550
} )
508
551
} )
509
552
510
- test ( 'should refresh configuration when --build is passed ' , async ( t ) => {
553
+ test ( 'refreshes configuration when building before deployment ' , async ( t ) => {
511
554
await withSiteBuilder ( t , async ( builder ) => {
512
555
await builder
513
556
. withContentFile ( {
@@ -542,7 +585,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
542
585
. build ( )
543
586
544
587
const { deploy_url : deployUrl } = ( await callCli (
545
- [ 'deploy' , '--build' , '-- json'] ,
588
+ [ 'deploy' , '--json' ] ,
546
589
{
547
590
cwd : builder . directory ,
548
591
env : { NETLIFY_SITE_ID : context . siteId } ,
@@ -652,7 +695,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
652
695
. build ( )
653
696
654
697
const { deploy_url : deployUrl } = ( await callCli (
655
- [ 'deploy' , '--build' , '-- json'] ,
698
+ [ 'deploy' , '--json' ] ,
656
699
{
657
700
cwd : builder . directory ,
658
701
env : { NETLIFY_SITE_ID : context . siteId } ,
@@ -700,7 +743,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
700
743
. build ( )
701
744
702
745
const { deploy_url : deployUrl } = ( await callCli (
703
- [ 'deploy' , '--build' , '-- json'] ,
746
+ [ 'deploy' , '--json' ] ,
704
747
{
705
748
cwd : builder . directory ,
706
749
env : { NETLIFY_SITE_ID : context . siteId } ,
@@ -758,7 +801,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
758
801
. build ( )
759
802
760
803
const deploy = ( await callCli (
761
- [ 'deploy' , '--json' , '--build' ] ,
804
+ [ 'deploy' , '--json' ] ,
762
805
{
763
806
cwd : builder . directory ,
764
807
env : { NETLIFY_SITE_ID : context . siteId } ,
@@ -843,7 +886,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
843
886
. build ( )
844
887
845
888
const { deploy_url : deployUrl } = ( await callCli (
846
- [ 'deploy' , '--json' ] ,
889
+ [ 'deploy' , '--json' , '--build' , 'false' ] ,
847
890
{
848
891
cwd : builder . directory ,
849
892
env : { NETLIFY_SITE_ID : context . siteId } ,
@@ -902,7 +945,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
902
945
. build ( )
903
946
904
947
const { deploy_url : deployUrl } = ( await callCli (
905
- [ 'deploy' , '--json' , '--skip-functions-cache' ] ,
948
+ [ 'deploy' , '--json' , '--build' , 'false' , '-- skip-functions-cache'] ,
906
949
{
907
950
cwd : builder . directory ,
908
951
env : { NETLIFY_SITE_ID : context . siteId } ,
@@ -963,7 +1006,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
963
1006
. build ( )
964
1007
965
1008
const { deploy_url : deployUrl } = ( await callCli (
966
- [ 'deploy' , '--json' ] ,
1009
+ [ 'deploy' , '--json' , '--build' , 'false' ] ,
967
1010
{
968
1011
cwd : builder . directory ,
969
1012
env : { NETLIFY_SITE_ID : context . siteId } ,
@@ -1022,7 +1065,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
1022
1065
1023
1066
await execa . command ( 'npm install' , { cwd : builder . directory } )
1024
1067
const { deploy_url : deployUrl } = ( await callCli (
1025
- [ 'deploy' , '--json' ] ,
1068
+ [ 'deploy' , '--json' , '--build' , 'false' ] ,
1026
1069
{
1027
1070
cwd : builder . directory ,
1028
1071
env : { NETLIFY_SITE_ID : context . siteId } ,
@@ -1037,13 +1080,13 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
1037
1080
1038
1081
setupFixtureTests ( 'next-app-without-config' , ( ) => {
1039
1082
test < FixtureTestContext > (
1040
- 'should run deploy with --build without any netlify specific configuration' ,
1083
+ 'build without error without any netlify specific configuration' ,
1041
1084
{
1042
1085
timeout : 300_000 ,
1043
1086
} ,
1044
1087
async ( { fixture } ) => {
1045
1088
const { deploy_url : deployUrl } = ( await callCli (
1046
- [ 'deploy' , '--build' , '-- json'] ,
1089
+ [ 'deploy' , '--json' ] ,
1047
1090
{
1048
1091
cwd : fixture . directory ,
1049
1092
env : { NETLIFY_SITE_ID : context . siteId } ,
@@ -1064,7 +1107,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
1064
1107
await withSiteBuilder ( t , async ( builder ) => {
1065
1108
await builder . build ( )
1066
1109
try {
1067
- await callCli ( [ 'deploy' , '--prod-if-unlocked' , '--prod' ] , {
1110
+ await callCli ( [ 'deploy' , '--build' , 'false' , '-- prod-if-unlocked', '--prod' ] , {
1068
1111
cwd : builder . directory ,
1069
1112
env : { NETLIFY_SITE_ID : context . siteId } ,
1070
1113
} )
0 commit comments