From 829fbb619b7ced00714f5dc173371a1a3713fddb Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Thu, 6 Oct 2022 14:46:29 -0700 Subject: [PATCH 1/7] Pass singleProjectMode config down to auth and database emulators.. --- src/emulator/controller.ts | 3 +++ src/emulator/databaseEmulator.ts | 1 + src/emulator/downloadableEmulators.ts | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/emulator/controller.ts b/src/emulator/controller.ts index 022653ac751..6b3d474fc96 100644 --- a/src/emulator/controller.ts +++ b/src/emulator/controller.ts @@ -389,6 +389,8 @@ export async function startAll( // 1) The service must have a top-level entry in firebase.json or an entry in the emulators{} object // 2) If the --only flag is passed, then this list is the intersection const targets = filterEmulatorTargets(options); + const singleProjectModeEnabled = options.config.src.emulators?.singleProjectMode === undefined || + options.config.src.emulators?.singleProjectMode options.targets = targets; const singleProjectModeEnabled = options.config.src.emulators?.singleProjectMode === undefined || @@ -712,6 +714,7 @@ export async function startAll( port: databaseAddr.port, projectId, auto_download: true, + single_project_mode: "Warning", }; // Try to fetch the default RTDB instance for a project, but don't hard-fail if we diff --git a/src/emulator/databaseEmulator.ts b/src/emulator/databaseEmulator.ts index 786f4d1995f..6f83184de21 100644 --- a/src/emulator/databaseEmulator.ts +++ b/src/emulator/databaseEmulator.ts @@ -21,6 +21,7 @@ export interface DatabaseEmulatorArgs { functions_emulator_port?: number; functions_emulator_host?: string; auto_download?: boolean; + single_project_mode?: string; } export class DatabaseEmulator implements EmulatorInstance { diff --git a/src/emulator/downloadableEmulators.ts b/src/emulator/downloadableEmulators.ts index c342e2a2431..97b038a33d1 100644 --- a/src/emulator/downloadableEmulators.ts +++ b/src/emulator/downloadableEmulators.ts @@ -144,7 +144,13 @@ const Commands: { [s in DownloadableEmulators]: DownloadableEmulatorCommand } = database: { binary: "java", args: ["-Duser.language=en", "-jar", getExecPath(Emulators.DATABASE)], - optionalArgs: ["port", "host", "functions_emulator_port", "functions_emulator_host"], + optionalArgs: [ + "port", + "host", + "functions_emulator_port", + "functions_emulator_host", + "single_project_mode", + ], joinArgs: false, }, firestore: { From 393c6fc44ddfb8ca7268873c21809257c1d77406 Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Thu, 6 Oct 2022 14:47:40 -0700 Subject: [PATCH 2/7] Single project mode for the auth emulator. (#4996) * Single project mode for the auth emulator. If set, the emulator will reject calls for project IDs that aren't the default project ID. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3a11ecccd..a6a6a555cb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ - Enables single project mode for the auth emulator (#5068). - Fixes issue deploying to Hosting with i18n enabled. - Fixes issue where deploying to Hosting without Functions permissions would cause deployments to fail with 403 "Permission Denied" errors. (#5071) +- Enable single project mode for the auth emulator (#5068). From c887cc01d76c2506281254224e8144e7c371dda4 Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Thu, 6 Oct 2022 12:10:08 -0700 Subject: [PATCH 3/7] More stuff --- src/emulator/controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/emulator/controller.ts b/src/emulator/controller.ts index 6b3d474fc96..52b02f7f10c 100644 --- a/src/emulator/controller.ts +++ b/src/emulator/controller.ts @@ -714,7 +714,8 @@ export async function startAll( port: databaseAddr.port, projectId, auto_download: true, - single_project_mode: "Warning", + // Only set the flag (at all) if singleProjectMode is enabled. + single_project_mode: singleProjectModeEnabled ? "Warning" : undefined, }; // Try to fetch the default RTDB instance for a project, but don't hard-fail if we From 80125bd925c6ac0e4db84e293841e21f06a149ed Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Thu, 6 Oct 2022 12:12:21 -0700 Subject: [PATCH 4/7] Duplicate assignment --- src/emulator/controller.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/emulator/controller.ts b/src/emulator/controller.ts index 52b02f7f10c..8e2ba913a09 100644 --- a/src/emulator/controller.ts +++ b/src/emulator/controller.ts @@ -389,8 +389,6 @@ export async function startAll( // 1) The service must have a top-level entry in firebase.json or an entry in the emulators{} object // 2) If the --only flag is passed, then this list is the intersection const targets = filterEmulatorTargets(options); - const singleProjectModeEnabled = options.config.src.emulators?.singleProjectMode === undefined || - options.config.src.emulators?.singleProjectMode options.targets = targets; const singleProjectModeEnabled = options.config.src.emulators?.singleProjectMode === undefined || From 5a59294533e1e47ac05fa129b737d3974b82f430 Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Thu, 6 Oct 2022 13:59:31 -0700 Subject: [PATCH 5/7] Bump the database emulator version to 4.10.0. --- src/emulator/downloadableEmulators.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/emulator/downloadableEmulators.ts b/src/emulator/downloadableEmulators.ts index 97b038a33d1..f8e385334e5 100644 --- a/src/emulator/downloadableEmulators.ts +++ b/src/emulator/downloadableEmulators.ts @@ -27,14 +27,14 @@ const CACHE_DIR = export const DownloadDetails: { [s in DownloadableEmulators]: EmulatorDownloadDetails } = { database: { - downloadPath: path.join(CACHE_DIR, "firebase-database-emulator-v4.9.0.jar"), - version: "4.9.0", + downloadPath: path.join(CACHE_DIR, "firebase-database-emulator-v4.10.0.jar"), + version: "4.10.0", opts: { cacheDir: CACHE_DIR, remoteUrl: - "https://storage.googleapis.com/firebase-preview-drop/emulator/firebase-database-emulator-v4.9.0.jar", - expectedSize: 34204485, - expectedChecksum: "1c3f5974f0ee5559ebf27b56f2e62108", + "https://storage.googleapis.com/firebase-preview-drop/emulator/firebase-database-emulator-v4.10.0.jar", + expectedSize: 34230230, + expectedChecksum: "e99b23f0e723813de4f4ea0e879b46b0", namePrefix: "firebase-database-emulator", }, }, From 50d569b009dac285490321e1b302704d09067429 Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Thu, 6 Oct 2022 14:51:13 -0700 Subject: [PATCH 6/7] Changelog updates --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6a6a555cb3..de7395136ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -- Enables single project mode for the auth emulator (#5068). +- Enables single project mode for the auth emulator (#4996). - Fixes issue deploying to Hosting with i18n enabled. - Fixes issue where deploying to Hosting without Functions permissions would cause deployments to fail with 403 "Permission Denied" errors. (#5071) -- Enable single project mode for the auth emulator (#5068). +- Enable single project mode for the database emulator (#5068). From 415c4f7b3b46f687ee02a23398a41276f6ecab09 Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Thu, 6 Oct 2022 16:59:50 -0700 Subject: [PATCH 7/7] Changelog --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de7395136ed..c86f3ecd431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1 @@ -- Enables single project mode for the auth emulator (#4996). -- Fixes issue deploying to Hosting with i18n enabled. -- Fixes issue where deploying to Hosting without Functions permissions would cause deployments to fail with 403 "Permission Denied" errors. (#5071) - Enable single project mode for the database emulator (#5068).