@@ -37,7 +37,7 @@ describe("publish", () => {
37
37
} ) ;
38
38
39
39
it ( "should be able to use the `build.upload.main` config as the entry-point for ESM sources" , async ( ) => {
40
- writeWranglerToml ( "./index.js" ) ;
40
+ writeWranglerToml ( { main : "./index.js" } ) ;
41
41
writeEsmWorkerSource ( ) ;
42
42
mockUploadWorkerRequest ( ) ;
43
43
mockSubDomainRequest ( ) ;
@@ -57,6 +57,35 @@ describe("publish", () => {
57
57
expect ( stderr ) . toMatchInlineSnapshot ( `""` ) ;
58
58
expect ( error ) . toMatchInlineSnapshot ( `undefined` ) ;
59
59
} ) ;
60
+
61
+ it ( "should warn if there is a `site.entry-point` configuration" , async ( ) => {
62
+ writeWranglerToml ( {
63
+ entryPoint : "./index.js" ,
64
+ } ) ;
65
+ writeEsmWorkerSource ( ) ;
66
+ mockUploadWorkerRequest ( ) ;
67
+ mockSubDomainRequest ( ) ;
68
+
69
+ const { stdout, stderr, error, warnings } = await runWrangler (
70
+ "publish ./index.js"
71
+ ) ;
72
+
73
+ expect ( stripTimings ( stdout ) ) . toMatchInlineSnapshot ( `
74
+ "Uploaded
75
+ test-name
76
+ (TIMINGS)
77
+ Deployed
78
+ test-name
79
+ (TIMINGS)
80
+
81
+ test-name.test-sub-domain.workers.dev"
82
+ ` ) ;
83
+ expect ( stderr ) . toMatchInlineSnapshot ( `""` ) ;
84
+ expect ( error ) . toMatchInlineSnapshot ( `undefined` ) ;
85
+ expect ( warnings ) . toMatchInlineSnapshot (
86
+ `"Deprecation notice: The \`site.entry-point\` config field is no longer used. Please remove it from the \`wrangler.toml\` file."`
87
+ ) ;
88
+ } ) ;
60
89
} ) ;
61
90
62
91
describe ( "asset upload" , ( ) => {
@@ -69,7 +98,7 @@ describe("publish", () => {
69
98
title : "__test-name_sites_assets" ,
70
99
id : "__test-name_sites_assets-id" ,
71
100
} ;
72
- writeWranglerToml ( "./index.js" , "assets" ) ;
101
+ writeWranglerToml ( { main : "./index.js" , bucket : "assets" } ) ;
73
102
writeEsmWorkerSource ( ) ;
74
103
writeAssets ( assets ) ;
75
104
mockUploadWorkerRequest ( ) ;
@@ -106,7 +135,7 @@ describe("publish", () => {
106
135
title : "__test-name_sites_assets" ,
107
136
id : "__test-name_sites_assets-id" ,
108
137
} ;
109
- writeWranglerToml ( "./index.js" , "assets" ) ;
138
+ writeWranglerToml ( { main : "./index.js" , bucket : "assets" } ) ;
110
139
writeEsmWorkerSource ( ) ;
111
140
writeAssets ( assets ) ;
112
141
mockUploadWorkerRequest ( ) ;
@@ -148,7 +177,7 @@ describe("publish", () => {
148
177
title : "__test-name_sites_assets" ,
149
178
id : "__test-name_sites_assets-id" ,
150
179
} ;
151
- writeWranglerToml ( "./index.js" , "assets" ) ;
180
+ writeWranglerToml ( { main : "./index.js" , bucket : "assets" } ) ;
152
181
writeEsmWorkerSource ( ) ;
153
182
writeAssets ( assets ) ;
154
183
mockUploadWorkerRequest ( ) ;
@@ -189,7 +218,7 @@ describe("publish", () => {
189
218
title : "__test-name_sites_assets" ,
190
219
id : "__test-name_sites_assets-id" ,
191
220
} ;
192
- writeWranglerToml ( "./index.js" , "assets" ) ;
221
+ writeWranglerToml ( { main : "./index.js" , bucket : "assets" } ) ;
193
222
writeEsmWorkerSource ( ) ;
194
223
writeAssets ( assets ) ;
195
224
mockUploadWorkerRequest ( ) ;
@@ -230,7 +259,11 @@ describe("publish", () => {
230
259
title : "__test-name_sites_assets" ,
231
260
id : "__test-name_sites_assets-id" ,
232
261
} ;
233
- writeWranglerToml ( "./index.js" , "assets" , [ "file-1.txt" ] ) ;
262
+ writeWranglerToml ( {
263
+ main : "./index.js" ,
264
+ bucket : "assets" ,
265
+ include : [ "file-1.txt" ] ,
266
+ } ) ;
234
267
writeEsmWorkerSource ( ) ;
235
268
writeAssets ( assets ) ;
236
269
mockUploadWorkerRequest ( ) ;
@@ -269,7 +302,11 @@ describe("publish", () => {
269
302
title : "__test-name_sites_assets" ,
270
303
id : "__test-name_sites_assets-id" ,
271
304
} ;
272
- writeWranglerToml ( "./index.js" , "assets" , undefined , [ "file-2.txt" ] ) ;
305
+ writeWranglerToml ( {
306
+ main : "./index.js" ,
307
+ bucket : "assets" ,
308
+ exclude : [ "file-2.txt" ] ,
309
+ } ) ;
273
310
writeEsmWorkerSource ( ) ;
274
311
writeAssets ( assets ) ;
275
312
mockUploadWorkerRequest ( ) ;
@@ -308,7 +345,11 @@ describe("publish", () => {
308
345
title : "__test-name_sites_assets" ,
309
346
id : "__test-name_sites_assets-id" ,
310
347
} ;
311
- writeWranglerToml ( "./index.js" , "assets" , [ "file-2.txt" ] ) ;
348
+ writeWranglerToml ( {
349
+ main : "./index.js" ,
350
+ bucket : "assets" ,
351
+ include : [ "file-2.txt" ] ,
352
+ } ) ;
312
353
writeEsmWorkerSource ( ) ;
313
354
writeAssets ( assets ) ;
314
355
mockUploadWorkerRequest ( ) ;
@@ -349,9 +390,11 @@ describe("publish", () => {
349
390
title : "__test-name_sites_assets" ,
350
391
id : "__test-name_sites_assets-id" ,
351
392
} ;
352
- writeWranglerToml ( "./index.js" , "assets" , undefined , [
353
- "assets/file-1.txt" ,
354
- ] ) ;
393
+ writeWranglerToml ( {
394
+ main : "./index.js" ,
395
+ bucket : "assets" ,
396
+ exclude : [ "assets/file-1.txt" ] ,
397
+ } ) ;
355
398
writeEsmWorkerSource ( ) ;
356
399
writeAssets ( assets ) ;
357
400
mockUploadWorkerRequest ( ) ;
@@ -398,7 +441,7 @@ describe("publish", () => {
398
441
title : "__test-name_sites_assets" ,
399
442
id : "__test-name_sites_assets-id" ,
400
443
} ;
401
- writeWranglerToml ( "./index.js" , "assets" ) ;
444
+ writeWranglerToml ( { main : "./index.js" , bucket : "assets" } ) ;
402
445
writeEsmWorkerSource ( ) ;
403
446
writeAssets ( assets ) ;
404
447
mockUploadWorkerRequest ( ) ;
@@ -444,7 +487,7 @@ describe("publish", () => {
444
487
title : "__test-name_sites_assets" ,
445
488
id : "__test-name_sites_assets-id" ,
446
489
} ;
447
- writeWranglerToml ( "./index.js" , "assets" ) ;
490
+ writeWranglerToml ( { main : "./index.js" , bucket : "assets" } ) ;
448
491
writeEsmWorkerSource ( ) ;
449
492
writeAssets ( assets ) ;
450
493
mockUploadWorkerRequest ( ) ;
@@ -487,9 +530,11 @@ describe("publish", () => {
487
530
title : "__test-name_sites_assets" ,
488
531
id : "__test-name_sites_assets-id" ,
489
532
} ;
490
- writeWranglerToml ( "./index.js" , "assets" , undefined , [
491
- "assets/file-1.txt" ,
492
- ] ) ;
533
+ writeWranglerToml ( {
534
+ main : "./index.js" ,
535
+ bucket : "assets" ,
536
+ exclude : [ "assets/file-1.txt" ] ,
537
+ } ) ;
493
538
writeEsmWorkerSource ( ) ;
494
539
writeAssets ( assets ) ;
495
540
mockUploadWorkerRequest ( ) ;
@@ -523,7 +568,7 @@ describe("publish", () => {
523
568
title : "__test-name_sites_assets" ,
524
569
id : "__test-name_sites_assets-id" ,
525
570
} ;
526
- writeWranglerToml ( "./index.js" , "assets" ) ;
571
+ writeWranglerToml ( { main : "./index.js" , bucket : "assets" } ) ;
527
572
writeEsmWorkerSource ( ) ;
528
573
writeAssets ( [ longFilePathAsset ] ) ;
529
574
mockUploadWorkerRequest ( ) ;
@@ -550,22 +595,30 @@ describe("publish", () => {
550
595
} ) ;
551
596
552
597
/** Write a mock wrangler.toml file to disk. */
553
- function writeWranglerToml (
554
- main ?: string ,
555
- bucket ?: string ,
556
- include ?: string [ ] ,
557
- exclude ?: string [ ]
558
- ) {
598
+ function writeWranglerToml ( {
599
+ main,
600
+ bucket,
601
+ include,
602
+ exclude,
603
+ entryPoint,
604
+ } : {
605
+ main ?: string ;
606
+ bucket ?: string ;
607
+ include ?: string [ ] ;
608
+ exclude ?: string [ ] ;
609
+ entryPoint ?: string ;
610
+ } = { } ) {
559
611
fs . writeFileSync (
560
612
"./wrangler.toml" ,
561
613
[
562
614
`compatibility_date = "2022-01-12"` ,
563
615
`name = "test-name"` ,
564
616
main !== undefined ? `[build.upload]\nmain = "${ main } "` : "" ,
565
- bucket || include || exclude ? "[site]" : "" ,
617
+ bucket || include || exclude || entryPoint ? "[site]" : "" ,
566
618
bucket !== undefined ? `bucket = "${ bucket } "` : "" ,
567
619
include !== undefined ? `include = ${ JSON . stringify ( include ) } ` : "" ,
568
620
exclude !== undefined ? `exclude = ${ JSON . stringify ( exclude ) } ` : "" ,
621
+ entryPoint !== undefined ? `entry-point = "${ entryPoint } "` : "" ,
569
622
] . join ( "\n" ) ,
570
623
"utf-8"
571
624
) ;
0 commit comments