Skip to content

Commit 7ef4922

Browse files
committed
Call apphosting local builds
1 parent cf9a048 commit 7ef4922

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

npm-shrinkwrap.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@
102102
]
103103
},
104104
"dependencies": {
105+
"@apphosting/build": "*",
106+
"@apphosting/common": "^0.0.8",
105107
"@electric-sql/pglite": "^0.3.3",
106108
"@electric-sql/pglite-tools": "^0.2.8",
107109
"@google-cloud/cloud-sql-connector": "^1.3.3",

src/apphosting/localbuilds.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { localBuild as localApphostingBuild } from "@apphosting/build";
2+
import { OutputBundleConfig } from "@apphosting/common";
3+
import { BuildConfig, Env, Availability } from "../gcp/apphosting";
4+
import { readFileSync } from "fs";
5+
import { join } from "path";
6+
import { fileExistsSync } from "../fsutils";
7+
import { load } from "js-yaml";
8+
import { FirebaseError } from "../error";
9+
10+
11+
export async function localBuild(
12+
projectRoot: string, framework: string): Promise<{annotations: Record<string, string>, buildConfig: BuildConfig}> {
13+
14+
const apphostingBuildOutput: OutputBundleConfig = await localApphostingBuild(projectRoot, framework);
15+
16+
const annotations: Record<string, string> = {};
17+
Object.entries(apphostingBuildOutput.metadata).forEach(([key, value]) => {
18+
annotations[key] = String(value);
19+
});
20+
21+
const env: Env[] | undefined = apphostingBuildOutput.runConfig.environmentVariables?.map(
22+
( {variable, value, availability} : Env) => {
23+
return {
24+
variable,
25+
value,
26+
availability,
27+
};
28+
});
29+
30+
return {
31+
annotations,
32+
buildConfig: {
33+
runCommand: apphostingBuildOutput.runConfig.runCommand,
34+
env,
35+
},
36+
}
37+
38+
}

0 commit comments

Comments
 (0)