@@ -383,6 +383,94 @@ describe("publish", () => {
383
383
expect ( error ) . toMatchInlineSnapshot ( `undefined` ) ;
384
384
} ) ;
385
385
386
+ it ( "should walk directories except node_modules" , async ( ) => {
387
+ const assets = [
388
+ {
389
+ filePath : "assets/directory-1/file-1.txt" ,
390
+ content : "Content of file-1" ,
391
+ } ,
392
+ {
393
+ filePath : "assets/node_modules/file-2.txt" ,
394
+ content : "Content of file-2" ,
395
+ } ,
396
+ ] ;
397
+ const kvNamespace = {
398
+ title : "__test-name_sites_assets" ,
399
+ id : "__test-name_sites_assets-id" ,
400
+ } ;
401
+ writeWranglerToml ( "./index.js" , "assets" ) ;
402
+ writeEsmWorkerSource ( ) ;
403
+ writeAssets ( assets ) ;
404
+ mockUploadWorkerRequest ( ) ;
405
+ mockSubDomainRequest ( ) ;
406
+ mockListKVNamespacesRequest ( kvNamespace ) ;
407
+ mockKeyListRequest ( kvNamespace . id , [ ] ) ;
408
+ // Only expect file-1 to be uploaded
409
+ mockUploadAssetsToKVRequest ( kvNamespace . id , assets . slice ( 0 , 1 ) ) ;
410
+ const { stdout, stderr, error } = await runWrangler ( "publish" ) ;
411
+
412
+ expect ( stripTimings ( stdout ) ) . toMatchInlineSnapshot ( `
413
+ "reading assets/directory-1/file-1.txt...
414
+ uploading as assets/directory-1/file-1.2ca234f380.txt...
415
+ Uploaded
416
+ test-name
417
+ (TIMINGS)
418
+ Deployed
419
+ test-name
420
+ (TIMINGS)
421
+
422
+ test-name.test-sub-domain.workers.dev"
423
+ ` ) ;
424
+ expect ( stderr ) . toMatchInlineSnapshot ( `""` ) ;
425
+ expect ( error ) . toMatchInlineSnapshot ( `undefined` ) ;
426
+ } ) ;
427
+
428
+ it ( "should skip hidden files and directories except `.well-known`" , async ( ) => {
429
+ const assets = [
430
+ {
431
+ filePath : "assets/.hidden-file.txt" ,
432
+ content : "Content of hidden-file" ,
433
+ } ,
434
+ {
435
+ filePath : "assets/.hidden/file-1.txt" ,
436
+ content : "Content of file-1" ,
437
+ } ,
438
+ {
439
+ filePath : "assets/.well-known/file-2.txt" ,
440
+ content : "Content of file-2" ,
441
+ } ,
442
+ ] ;
443
+ const kvNamespace = {
444
+ title : "__test-name_sites_assets" ,
445
+ id : "__test-name_sites_assets-id" ,
446
+ } ;
447
+ writeWranglerToml ( "./index.js" , "assets" ) ;
448
+ writeEsmWorkerSource ( ) ;
449
+ writeAssets ( assets ) ;
450
+ mockUploadWorkerRequest ( ) ;
451
+ mockSubDomainRequest ( ) ;
452
+ mockListKVNamespacesRequest ( kvNamespace ) ;
453
+ mockKeyListRequest ( kvNamespace . id , [ ] ) ;
454
+ // Only expect file-2 to be uploaded
455
+ mockUploadAssetsToKVRequest ( kvNamespace . id , assets . slice ( 2 ) ) ;
456
+ const { stdout, stderr, error } = await runWrangler ( "publish" ) ;
457
+
458
+ expect ( stripTimings ( stdout ) ) . toMatchInlineSnapshot ( `
459
+ "reading assets/.well-known/file-2.txt...
460
+ uploading as assets/.well-known/file-2.5938485188.txt...
461
+ Uploaded
462
+ test-name
463
+ (TIMINGS)
464
+ Deployed
465
+ test-name
466
+ (TIMINGS)
467
+
468
+ test-name.test-sub-domain.workers.dev"
469
+ ` ) ;
470
+ expect ( stderr ) . toMatchInlineSnapshot ( `""` ) ;
471
+ expect ( error ) . toMatchInlineSnapshot ( `undefined` ) ;
472
+ } ) ;
473
+
386
474
it ( "should error if the asset is over 25Mb" , async ( ) => {
387
475
const assets = [
388
476
{
0 commit comments