@@ -2,7 +2,6 @@ import * as clc from "colorette";
22import * as fs from "fs" ;
33import * as path from "path" ;
44import * as fsConfig from "../firestore/fsConfig" ;
5- import * as proto from "../gcp/proto" ;
65
76import { logger } from "../logger" ;
87import { trackEmulator , trackGA4 } from "../track" ;
@@ -43,7 +42,7 @@ import { getProjectDefaultAccount } from "../auth";
4342import { Options } from "../options" ;
4443import { ParsedTriggerDefinition } from "./functionsEmulatorShared" ;
4544import { ExtensionsEmulator } from "./extensionsEmulator" ;
46- import { normalizeAndValidate , requireLocal } from "../functions/projectConfig" ;
45+ import { isKitConfig , normalizeAndValidate , requireLocal } from "../functions/projectConfig" ;
4746import { requiresJava } from "./downloadableEmulators" ;
4847import { prepareFrameworks } from "../frameworks" ;
4948import * as experiments from "../experiments" ;
@@ -542,22 +541,39 @@ export async function startAll(
542541 `Cannot load functions from ${ functionsDir } because it has invalid runtime ${ runtime as string } ` ,
543542 ) ;
544543 }
545- const backend : EmulatableBackend = {
546- functionsDir,
547- runtime,
548- codebase : localCfg . codebase ,
549- prefix : localCfg . prefix ,
550- env : {
551- ...options . extDevEnv ,
552- } ,
553- secretEnv : [ ] , // CF3 secrets are bound to specific functions, so we'll get them during trigger discovery.
554- // TODO(b/213335255): predefinedTriggers and nodeMajorVersion are here to support ext:dev:emulators:* commands.
555- // Ideally, we should handle that case via ExtensionEmulator.
556- predefinedTriggers : options . extDevTriggers as ParsedTriggerDefinition [ ] | undefined ,
557- ignore : localCfg . ignore ,
558- } ;
559- proto . convertIfPresent ( backend , localCfg , "configDir" , ( cd ) => path . join ( projectDir , cd ) ) ;
560- emulatableBackends . push ( backend ) ;
544+
545+ if ( isKitConfig ( localCfg ) ) {
546+ for ( const [ instanceId , configDir ] of Object . entries ( localCfg . instances ) ) {
547+ const backend : EmulatableBackend = {
548+ functionsDir,
549+ runtime,
550+ codebase : instanceId ,
551+ configDir : path . join ( projectDir , configDir ) ,
552+ env : {
553+ ...options . extDevEnv ,
554+ } ,
555+ secretEnv : [ ] ,
556+ predefinedTriggers : options . extDevTriggers as ParsedTriggerDefinition [ ] | undefined ,
557+ ignore : localCfg . ignore ,
558+ } ;
559+ emulatableBackends . push ( backend ) ;
560+ }
561+ } else {
562+ const backend : EmulatableBackend = {
563+ functionsDir,
564+ runtime,
565+ codebase : localCfg . codebase ,
566+ ...( localCfg . prefix ? { prefix : localCfg . prefix } : { } ) ,
567+ ...( localCfg . configDir ? { configDir : path . join ( projectDir , localCfg . configDir ) } : { } ) ,
568+ env : {
569+ ...options . extDevEnv ,
570+ } ,
571+ secretEnv : [ ] ,
572+ predefinedTriggers : options . extDevTriggers as ParsedTriggerDefinition [ ] | undefined ,
573+ ignore : localCfg . ignore ,
574+ } ;
575+ emulatableBackends . push ( backend ) ;
576+ }
561577 }
562578 }
563579
0 commit comments