@@ -298,28 +298,54 @@ export async function runPlugin(
298
298
)
299
299
}
300
300
301
- await Promise . all ( [ bundleEdgeFunctions ( ) , bundleFunctions ( ) , uploadBlobs ( ctx , base . blobDir ) ] )
301
+ await Promise . all ( [ bundleEdgeFunctions ( ) , bundleFunctions ( ) , uploadBlobs ( ctx , base ) ] )
302
302
303
303
return options
304
304
}
305
305
306
- export async function uploadBlobs ( ctx : FixtureTestContext , blobsDir : string ) {
307
- const files = await glob ( '**/*' , {
308
- dot : true ,
309
- cwd : blobsDir ,
310
- } )
306
+ export async function uploadBlobs ( ctx : FixtureTestContext , pluginContext : PluginContext ) {
307
+ if ( pluginContext . blobsStrategy === 'frameworks-api' ) {
308
+ const files = await glob ( '**/blob' , {
309
+ dot : true ,
310
+ cwd : pluginContext . blobDir ,
311
+ } )
311
312
312
- const keys = files . filter ( ( file ) => ! basename ( file ) . startsWith ( '$' ) )
313
- await Promise . all (
314
- keys . map ( async ( key ) => {
315
- const { dir, base } = parse ( key )
316
- const metaFile = join ( blobsDir , dir , `$${ base } .json` )
317
- const metadata = await readFile ( metaFile , 'utf-8' )
318
- . then ( ( meta ) => JSON . parse ( meta ) )
319
- . catch ( ( ) => ( { } ) )
320
- await ctx . blobStore . set ( key , await readFile ( join ( blobsDir , key ) , 'utf-8' ) , { metadata } )
321
- } ) ,
322
- )
313
+ await Promise . all (
314
+ files . map ( async ( blobFilePath ) => {
315
+ const { dir : key } = parse ( blobFilePath )
316
+ const metaFile = join ( pluginContext . blobDir , key , `blob.meta.json` )
317
+ const metadata = await readFile ( metaFile , 'utf-8' )
318
+ . then ( ( meta ) => JSON . parse ( meta ) )
319
+ . catch ( ( ) => ( { } ) )
320
+ await ctx . blobStore . set (
321
+ key ,
322
+ await readFile ( join ( pluginContext . blobDir , blobFilePath ) , 'utf-8' ) ,
323
+ {
324
+ metadata,
325
+ } ,
326
+ )
327
+ } ) ,
328
+ )
329
+ } else {
330
+ const files = await glob ( '**/*' , {
331
+ dot : true ,
332
+ cwd : pluginContext . blobDir ,
333
+ } )
334
+
335
+ const keys = files . filter ( ( file ) => ! basename ( file ) . startsWith ( '$' ) )
336
+ await Promise . all (
337
+ keys . map ( async ( key ) => {
338
+ const { dir, base } = parse ( key )
339
+ const metaFile = join ( pluginContext . blobDir , dir , `$${ base } .json` )
340
+ const metadata = await readFile ( metaFile , 'utf-8' )
341
+ . then ( ( meta ) => JSON . parse ( meta ) )
342
+ . catch ( ( ) => ( { } ) )
343
+ await ctx . blobStore . set ( key , await readFile ( join ( pluginContext . blobDir , key ) , 'utf-8' ) , {
344
+ metadata,
345
+ } )
346
+ } ) ,
347
+ )
348
+ }
323
349
}
324
350
325
351
const DEFAULT_FLAGS = {
0 commit comments