1- import { writeManifestToBundle , compressBundle } from './bundle.js'
1+ import { writeManifestToBundle , compressBundle , BUNDLE_EXCLUSION_PATTERNS } from './bundle.js'
22import { AppInterface } from '../models/app/app.js'
33import { describe , test , expect , vi } from 'vitest'
44import { joinPath } from '@shopify/cli-kit/node/path'
@@ -53,7 +53,7 @@ describe('compressBundle', () => {
5353 expect ( zip ) . toHaveBeenCalledWith ( {
5454 inputDirectory : inputDir ,
5555 outputZipPath : outputZip ,
56- matchFilePattern : [ '**/*' , '!**/*.js.map' ] ,
56+ matchFilePattern : [ '**/*' , ... BUNDLE_EXCLUSION_PATTERNS ] ,
5757 } )
5858 expect ( brotliCompress ) . not . toHaveBeenCalled ( )
5959 } )
@@ -74,7 +74,7 @@ describe('compressBundle', () => {
7474 // Then
7575 expect ( zip ) . toHaveBeenCalledWith (
7676 expect . objectContaining ( {
77- matchFilePattern : [ '**/*' , '!**/*.js.map' ] ,
77+ matchFilePattern : [ '**/*' , ... BUNDLE_EXCLUSION_PATTERNS ] ,
7878 } ) ,
7979 )
8080 } )
@@ -95,7 +95,7 @@ describe('compressBundle', () => {
9595 expect ( brotliCompress ) . toHaveBeenCalledWith ( {
9696 inputDirectory : inputDir ,
9797 outputPath : outputBr ,
98- matchFilePattern : [ '**/*' , '!**/*.js.map' ] ,
98+ matchFilePattern : [ '**/*' , ... BUNDLE_EXCLUSION_PATTERNS ] ,
9999 } )
100100 expect ( zip ) . not . toHaveBeenCalled ( )
101101 } )
@@ -116,7 +116,48 @@ describe('compressBundle', () => {
116116 // Then
117117 expect ( brotliCompress ) . toHaveBeenCalledWith (
118118 expect . objectContaining ( {
119- matchFilePattern : [ '**/*' , '!**/*.js.map' ] ,
119+ matchFilePattern : [ '**/*' , ...BUNDLE_EXCLUSION_PATTERNS ] ,
120+ } ) ,
121+ )
122+ } )
123+ } )
124+
125+ test ( 'excludes .metafile.json files from the zip' , async ( ) => {
126+ await inTemporaryDirectory ( async ( tmpDir ) => {
127+ // Given
128+ const inputDir = joinPath ( tmpDir , 'input' )
129+ const outputZip = joinPath ( tmpDir , 'output.zip' )
130+ await mkdir ( inputDir )
131+ await writeFile ( joinPath ( inputDir , 'test.txt' ) , 'test content' )
132+ await writeFile ( joinPath ( inputDir , 'main.metafile.json' ) , '{"inputs":{},"outputs":{}}' )
133+
134+ // When
135+ await compressBundle ( inputDir , outputZip )
136+
137+ // Then
138+ expect ( zip ) . toHaveBeenCalledWith (
139+ expect . objectContaining ( {
140+ matchFilePattern : [ '**/*' , ...BUNDLE_EXCLUSION_PATTERNS ] ,
141+ } ) ,
142+ )
143+ } )
144+ } )
145+
146+ test ( 'uses custom file patterns as-is when provided' , async ( ) => {
147+ await inTemporaryDirectory ( async ( tmpDir ) => {
148+ // Given
149+ const inputDir = joinPath ( tmpDir , 'input' )
150+ const outputZip = joinPath ( tmpDir , 'output.zip' )
151+ await mkdir ( inputDir )
152+ await writeFile ( joinPath ( inputDir , 'test.txt' ) , 'test content' )
153+
154+ // When
155+ await compressBundle ( inputDir , outputZip , [ 'ext1/**' , 'manifest.json' ] )
156+
157+ // Then
158+ expect ( zip ) . toHaveBeenCalledWith (
159+ expect . objectContaining ( {
160+ matchFilePattern : [ 'ext1/**' , 'manifest.json' ] ,
120161 } ) ,
121162 )
122163 } )
0 commit comments