@@ -44,7 +44,7 @@ export async function generateFunctions(suitePatterns, options = {}) {
44
44
projectId : overrideProjectId = process . env . PROJECT_ID ,
45
45
region : overrideRegion = process . env . REGION ,
46
46
sdkTarball = process . env . SDK_TARBALL || "file:firebase-functions-local.tgz" ,
47
- quiet = false
47
+ quiet = false ,
48
48
} = options ;
49
49
50
50
const log = quiet ? ( ) => { } : console . log . bind ( console ) ;
@@ -71,7 +71,9 @@ export async function generateFunctions(suitePatterns, options = {}) {
71
71
} else if ( pattern . startsWith ( "v2" ) ) {
72
72
configPath = join ( ROOT_DIR , "config" , "v2" , "suites.yaml" ) ;
73
73
} else {
74
- throw new Error ( `Cannot auto-detect config file for pattern '${ pattern } '. Use --config option.` ) ;
74
+ throw new Error (
75
+ `Cannot auto-detect config file for pattern '${ pattern } '. Use --config option.`
76
+ ) ;
75
77
}
76
78
}
77
79
suitesToAdd = getSuitesByPattern ( pattern , configPath ) ;
@@ -84,7 +86,9 @@ export async function generateFunctions(suitePatterns, options = {}) {
84
86
} else if ( pattern . startsWith ( "v2_" ) ) {
85
87
configPath = join ( ROOT_DIR , "config" , "v2" , "suites.yaml" ) ;
86
88
} else {
87
- throw new Error ( `Cannot auto-detect config file for suite '${ pattern } '. Use --config option.` ) ;
89
+ throw new Error (
90
+ `Cannot auto-detect config file for suite '${ pattern } '. Use --config option.`
91
+ ) ;
88
92
}
89
93
}
90
94
suitesToAdd = [ getSuiteConfig ( pattern , configPath ) ] ;
@@ -217,10 +221,14 @@ export async function generateFunctions(suitePatterns, options = {}) {
217
221
testRunId,
218
222
sdkTarball,
219
223
timestamp : new Date ( ) . toISOString ( ) ,
224
+ v1ProjectId : "functions-integration-tests" ,
225
+ v2ProjectId : "functions-integration-tests-v2" ,
220
226
} ;
221
227
222
228
// Generate the test file for this suite
223
- if ( generateFromTemplate ( templatePath , `functions/src/${ version } /${ service } -tests.ts` , context ) ) {
229
+ if (
230
+ generateFromTemplate ( templatePath , `functions/src/${ version } /${ service } -tests.ts` , context )
231
+ ) {
224
232
// Collect dependencies
225
233
Object . assign ( allDependencies , suite . dependencies || { } ) ;
226
234
Object . assign ( allDevDependencies , suite . devDependencies || { } ) ;
@@ -230,8 +238,8 @@ export async function generateFunctions(suitePatterns, options = {}) {
230
238
name,
231
239
service,
232
240
version,
233
- projectId : suite . projectId , // Store projectId per suite
234
- region : suite . region , // Store region per suite
241
+ projectId : suite . projectId , // Store projectId per suite
242
+ region : suite . region , // Store region per suite
235
243
functions : suite . functions . map ( ( f ) => `${ f . name } ${ testRunId } ` ) ,
236
244
} ) ;
237
245
}
@@ -271,8 +279,8 @@ export async function generateFunctions(suitePatterns, options = {}) {
271
279
// Replace {{sdkTarball}} placeholder in all dependencies
272
280
const processedDependencies = { } ;
273
281
for ( const [ key , value ] of Object . entries ( allDependencies ) ) {
274
- if ( typeof value === ' string' && value . includes ( ' {{sdkTarball}}' ) ) {
275
- processedDependencies [ key ] = value . replace ( ' {{sdkTarball}}' , sdkTarball ) ;
282
+ if ( typeof value === " string" && value . includes ( " {{sdkTarball}}" ) ) {
283
+ processedDependencies [ key ] = value . replace ( " {{sdkTarball}}" , sdkTarball ) ;
276
284
} else {
277
285
processedDependencies [ key ] = value ;
278
286
}
@@ -311,7 +319,12 @@ export async function generateFunctions(suitePatterns, options = {}) {
311
319
// Copy the SDK tarball into the functions directory if using local SDK
312
320
if ( sdkTarball . startsWith ( "file:" ) ) {
313
321
const tarballSourcePath = join ( ROOT_DIR , "firebase-functions-local.tgz" ) ;
314
- const tarballDestPath = join ( ROOT_DIR , "generated" , "functions" , "firebase-functions-local.tgz" ) ;
322
+ const tarballDestPath = join (
323
+ ROOT_DIR ,
324
+ "generated" ,
325
+ "functions" ,
326
+ "firebase-functions-local.tgz"
327
+ ) ;
315
328
316
329
if ( existsSync ( tarballSourcePath ) ) {
317
330
copyFileSync ( tarballSourcePath , tarballDestPath ) ;
@@ -323,7 +336,12 @@ export async function generateFunctions(suitePatterns, options = {}) {
323
336
}
324
337
325
338
log ( "\n✨ Generation complete!" ) ;
326
- log ( ` Generated ${ generatedSuites . length } suite(s) with ${ generatedSuites . reduce ( ( acc , s ) => acc + s . functions . length , 0 ) } function(s)` ) ;
339
+ log (
340
+ ` Generated ${ generatedSuites . length } suite(s) with ${ generatedSuites . reduce (
341
+ ( acc , s ) => acc + s . functions . length ,
342
+ 0
343
+ ) } function(s)`
344
+ ) ;
327
345
log ( "\nNext steps:" ) ;
328
346
log ( " 1. cd generated/functions && npm install" ) ;
329
347
log ( " 2. npm run build" ) ;
@@ -369,13 +387,13 @@ if (import.meta.url === `file://${process.argv[1]}`) {
369
387
if ( existsSync ( v1ConfigPath ) ) {
370
388
console . log ( "\n📁 V1 Suites (config/v1/suites.yaml):" ) ;
371
389
const v1Suites = listAvailableSuites ( v1ConfigPath ) ;
372
- v1Suites . forEach ( suite => console . log ( ` - ${ suite } ` ) ) ;
390
+ v1Suites . forEach ( ( suite ) => console . log ( ` - ${ suite } ` ) ) ;
373
391
}
374
392
375
393
if ( existsSync ( v2ConfigPath ) ) {
376
394
console . log ( "\n📁 V2 Suites (config/v2/suites.yaml):" ) ;
377
395
const v2Suites = listAvailableSuites ( v2ConfigPath ) ;
378
- v2Suites . forEach ( suite => console . log ( ` - ${ suite } ` ) ) ;
396
+ v2Suites . forEach ( ( suite ) => console . log ( ` - ${ suite } ` ) ) ;
379
397
}
380
398
381
399
process . exit ( 0 ) ;
@@ -391,9 +409,9 @@ if (import.meta.url === `file://${process.argv[1]}`) {
391
409
}
392
410
393
411
// Check for --use-published-sdk
394
- const sdkIndex = args . findIndex ( arg => arg . startsWith ( "--use-published-sdk=" ) ) ;
412
+ const sdkIndex = args . findIndex ( ( arg ) => arg . startsWith ( "--use-published-sdk=" ) ) ;
395
413
if ( sdkIndex !== - 1 ) {
396
- usePublishedSDK = args [ sdkIndex ] . split ( '=' ) [ 1 ] ;
414
+ usePublishedSDK = args [ sdkIndex ] . split ( "=" ) [ 1 ] ;
397
415
args . splice ( sdkIndex , 1 ) ;
398
416
}
399
417
@@ -419,11 +437,11 @@ if (import.meta.url === `file://${process.argv[1]}`) {
419
437
configPath,
420
438
projectId : process . env . PROJECT_ID ,
421
439
region : process . env . REGION ,
422
- sdkTarball
440
+ sdkTarball,
423
441
} )
424
- . then ( ( ) => process . exit ( 0 ) )
425
- . catch ( ( error ) => {
426
- console . error ( `❌ ${ error . message } ` ) ;
427
- process . exit ( 1 ) ;
428
- } ) ;
429
- }
442
+ . then ( ( ) => process . exit ( 0 ) )
443
+ . catch ( ( error ) => {
444
+ console . error ( `❌ ${ error . message } ` ) ;
445
+ process . exit ( 1 ) ;
446
+ } ) ;
447
+ }
0 commit comments