From dcc1e2a0daeb86897cf44c9ab6cd3af0b50ad890 Mon Sep 17 00:00:00 2001 From: Aryan Falahatpisheh Date: Wed, 20 May 2026 12:31:42 -0400 Subject: [PATCH 1/4] get rid of Universal Maker hack and make the toProcessEnv method cleaner and easier to read. --- src/apphosting/localbuilds.ts | 51 +++++++++++------------------------ 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/src/apphosting/localbuilds.ts b/src/apphosting/localbuilds.ts index c0c553b640f..f67ce8b2032 100644 --- a/src/apphosting/localbuilds.ts +++ b/src/apphosting/localbuilds.ts @@ -42,9 +42,9 @@ function executeUniversalMakerBinary( addedEnv: Record = {}, ): void { try { - const bundleOutput = path.join(projectRoot, "bundle_output"); - fs.removeSync(bundleOutput); - fs.ensureDirSync(bundleOutput); + const targetAppHosting = path.join(projectRoot, ".apphosting"); + fs.removeSync(targetAppHosting); + fs.ensureDirSync(targetAppHosting); const res = childProcess.spawnSync( universalMakerBinary, @@ -55,7 +55,7 @@ function executeUniversalMakerBinary( ...process.env, ...addedEnv, X_GOOGLE_TARGET_PLATFORM: "fah", - FIREBASE_OUTPUT_BUNDLE_DIR: bundleOutput, + FIREBASE_OUTPUT_BUNDLE_DIR: targetAppHosting, }, stdio: "pipe", }, @@ -126,23 +126,7 @@ function processUniversalMakerOutput(projectRoot: string): AppHostingBuildOutput const outputRaw = fs.readFileSync(outputFilePath, "utf-8"); fs.unlinkSync(outputFilePath); // Clean up temporary metadata file - const bundleOutput = path.join(projectRoot, "bundle_output"); - const targetAppHosting = path.join(projectRoot, ".apphosting"); - // Universal Maker has a bug where it accidentally empties bundle.yaml if we tell it to output directly to .apphosting. - // To avoid this, we output to bundle_output first, and then safely move the files over. - if (fs.existsSync(bundleOutput)) { - fs.ensureDirSync(targetAppHosting); - const files = fs.readdirSync(bundleOutput); - for (const file of files) { - const dest = path.join(targetAppHosting, file); - if (fs.existsSync(dest)) { - fs.removeSync(dest); - } - fs.moveSync(path.join(bundleOutput, file), dest); - } - fs.removeSync(bundleOutput); - } let umOutput: UniversalMakerOutput; try { @@ -270,22 +254,19 @@ export async function localBuild( }; } -async function toProcessEnv(projectId: string, env: EnvMap): Promise { - const entries = await Promise.all( - Object.entries(env).map(async ([key, value]) => { - if (value.availability && !value.availability.includes("BUILD")) { - return null; - } +async function toProcessEnv(projectId: string, env: EnvMap): Promise> { + const buildVars = Object.entries(env).filter(([, value]) => { + return !value.availability || value.availability.includes("BUILD"); + }); - if (value.secret) { - const resolvedValue = await loadSecret(projectId, value.secret); - return [key, resolvedValue]; - } else { - return [key, value.value || ""]; - } - }), + const resolvedEntries = await Promise.all( + buildVars.map(async ([key, value]) => { + const resolvedValue = value.secret + ? await loadSecret(projectId, value.secret) + : value.value || ""; + return [key, resolvedValue]; + }) ); - const filteredEntries = entries.filter((entry): entry is [string, string] => entry !== null); - return Object.fromEntries(filteredEntries) as NodeJS.ProcessEnv; + return Object.fromEntries(resolvedEntries); } From 8f5a50e8bb33e85dffee083c580808e7397a339b Mon Sep 17 00:00:00 2001 From: Aryan Falahatpisheh Date: Wed, 20 May 2026 14:10:10 -0400 Subject: [PATCH 2/4] style: auto-format and lint fixes for local_build_remove_um_hack --- src/apphosting/localbuilds.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/apphosting/localbuilds.ts b/src/apphosting/localbuilds.ts index b70c6bc131e..8fb02f4733f 100644 --- a/src/apphosting/localbuilds.ts +++ b/src/apphosting/localbuilds.ts @@ -126,8 +126,6 @@ function processUniversalMakerOutput(projectRoot: string): AppHostingBuildOutput const outputRaw = fs.readFileSync(outputFilePath, "utf-8"); fs.unlinkSync(outputFilePath); // Clean up temporary metadata file - - let umOutput: UniversalMakerOutput; try { umOutput = JSON.parse(outputRaw) as UniversalMakerOutput; @@ -268,7 +266,7 @@ async function toProcessEnv(projectId: string, env: EnvMap): Promise Date: Wed, 20 May 2026 14:10:44 -0400 Subject: [PATCH 3/4] style: fix TS linter warnings in localbuilds.ts --- src/apphosting/localbuilds.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apphosting/localbuilds.ts b/src/apphosting/localbuilds.ts index 8fb02f4733f..5dd08fc034d 100644 --- a/src/apphosting/localbuilds.ts +++ b/src/apphosting/localbuilds.ts @@ -229,7 +229,7 @@ export async function localBuild( const addedEnv = await toProcessEnv(projectId, env); const apphostingBuildOutput = await runUniversalMaker( projectRoot, - addedEnv as Record, + addedEnv, ); const annotations: Record = Object.fromEntries( @@ -269,5 +269,5 @@ async function toProcessEnv(projectId: string, env: EnvMap): Promise; } From 530d7d54d4aa95db0a9063ca8d2d5548e774cb17 Mon Sep 17 00:00:00 2001 From: Aryan Falahatpisheh Date: Wed, 20 May 2026 14:11:34 -0400 Subject: [PATCH 4/4] style: resolve ESLint single-line formatting error in localbuilds.ts --- src/apphosting/localbuilds.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/apphosting/localbuilds.ts b/src/apphosting/localbuilds.ts index 5dd08fc034d..ee041ceb07b 100644 --- a/src/apphosting/localbuilds.ts +++ b/src/apphosting/localbuilds.ts @@ -227,10 +227,7 @@ export async function localBuild( } const addedEnv = await toProcessEnv(projectId, env); - const apphostingBuildOutput = await runUniversalMaker( - projectRoot, - addedEnv, - ); + const apphostingBuildOutput = await runUniversalMaker(projectRoot, addedEnv); const annotations: Record = Object.fromEntries( Object.entries(apphostingBuildOutput.metadata).map(([key, value]) => [key, String(value)]),