From b77d82aed9f86c7d9ca0c5f644a3ef94d13feaee Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Thu, 8 Aug 2024 13:00:25 -0700 Subject: [PATCH 01/10] add output bundle spec to common module --- packages/@apphosting/common/src/index.ts | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/packages/@apphosting/common/src/index.ts b/packages/@apphosting/common/src/index.ts index ac24ac95..1a8043c5 100644 --- a/packages/@apphosting/common/src/index.ts +++ b/packages/@apphosting/common/src/index.ts @@ -1,5 +1,58 @@ import { spawn } from "child_process"; +// Output bundle specifications to be written to bundle.yaml +export interface OutputBundle { + version: "v1alpha"; + serverConfig: ServerConfig; + metadata: Metadata; +} + +// Fields needed to configure the App Hosting server +interface ServerConfig { + // Command to start the server (e.g. ["node", "dist/index.js"]) assume this command is run from the root dir of the workspace + runCommand: string[]; + // Environment variable present in the server execution environment. + environmentVariables?: EnvVarConfig[]; + // The maximum number of concurrent requests that each server instance can receive. + // Defaults to 80. + concurrency?: number; + // The number of CPUs used in a single server instance. + // Defaults to 1. + cpu?: "fractional" | 1 | 2 | 4 | 6 | 8; + // The amount of memory available for a server instance. + // Commonly one of: "256" | "512" | "1024" | "2048" | "4096" | "8192" | "16384" + // Defaults to 512MiB. + memoryMiB?: string; + // The limit on the minimum number of function instances that may coexist at a given time. + // Defaults to 0. + minInstances?: number; + // The limit on the maximum number of function instances that may coexist at a given time. + // Defaults to 100. + maxInstances?: number; +} + +// Additonal fields needed for adapter identification +interface Metadata { + // Name of the adapter (this should be the npm package name) + adapterNpmPackageName: string; + // Version of the adapter + adapterVersion?: string; + // Name of the framework that is being supported + framework: string; + // Version of the framework that is being supported + frameworkVersion?: string; +} + +// Configs necessary to define environment variables +interface EnvVarConfig { + // Name of the variable + variable: string; + // Value associated with the variable + value: string; + // Where the variable will be available, for now this will always be RUNTIME + availability: "RUNTIME"[]; +} + // Options to configure the build of a framework application export interface BuildOptions { // command to run build script (e.g. "npm", "nx", etc.) From a48b66f328ff28dd99034668f39efca015ee7408 Mon Sep 17 00:00:00 2001 From: Yuangwang Date: Tue, 27 Aug 2024 17:24:50 -0400 Subject: [PATCH 02/10] Update package.json --- packages/@apphosting/common/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@apphosting/common/package.json b/packages/@apphosting/common/package.json index 819f0561..b598da48 100644 --- a/packages/@apphosting/common/package.json +++ b/packages/@apphosting/common/package.json @@ -1,6 +1,6 @@ { "name": "@apphosting/common", - "version": "0.0.2", + "version": "0.0.3", "description": "Shared library code for App Hosting framework adapters", "author": { "name": "Firebase", From 4ed5abd0110b14c7246af462711c5a1364ec62e5 Mon Sep 17 00:00:00 2001 From: yuangwang Date: Tue, 27 Aug 2024 18:07:49 -0400 Subject: [PATCH 03/10] packagelock --- package-lock.json | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 218c4bd4..da0c525a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25659,6 +25659,12 @@ "zone.js": "~0.14.0" } }, + "packages/@apphosting/adapter-angular/node_modules/@apphosting/common": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@apphosting/common/-/common-0.0.2.tgz", + "integrity": "sha512-ab+vq1ntGo1YoKvyYRptkQt3QE86dg+tSZYFSCt9ovEtFjV/zepOGW8hvhnWLpNGErcyE7f2cExySOiLZW/ZPQ==", + "license": "Apache-2.0" + }, "packages/@apphosting/adapter-angular/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", @@ -25727,6 +25733,12 @@ } } }, + "packages/@apphosting/adapter-nextjs/node_modules/@apphosting/common": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@apphosting/common/-/common-0.0.2.tgz", + "integrity": "sha512-ab+vq1ntGo1YoKvyYRptkQt3QE86dg+tSZYFSCt9ovEtFjV/zepOGW8hvhnWLpNGErcyE7f2cExySOiLZW/ZPQ==", + "license": "Apache-2.0" + }, "packages/@apphosting/build": { "version": "0.1.0", "license": "Apache-2.0", @@ -25800,7 +25812,7 @@ } }, "packages/@apphosting/common": { - "version": "0.0.2", + "version": "0.0.3", "license": "Apache-2.0" }, "packages/@apphosting/create": { From 9408d8f1369051d85ca67836bf5c09f866fad9d5 Mon Sep 17 00:00:00 2001 From: yuangwang Date: Thu, 29 Aug 2024 16:48:26 -0400 Subject: [PATCH 04/10] address comments --- packages/@apphosting/common/src/index.ts | 33 ++++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/@apphosting/common/src/index.ts b/packages/@apphosting/common/src/index.ts index 1a8043c5..5bbf006e 100644 --- a/packages/@apphosting/common/src/index.ts +++ b/packages/@apphosting/common/src/index.ts @@ -1,17 +1,17 @@ import { spawn } from "child_process"; -// Output bundle specifications to be written to bundle.yaml -export interface OutputBundle { - version: "v1alpha"; +// Output bundle metadata specifications to be written to bundle.yaml +export interface OutputBundleConfigs{ + version: "v1"; serverConfig: ServerConfig; metadata: Metadata; } // Fields needed to configure the App Hosting server interface ServerConfig { - // Command to start the server (e.g. ["node", "dist/index.js"]) assume this command is run from the root dir of the workspace + // Command to start the server (e.g. ["node", "dist/index.js"]). Assume this command is run from the root dir of the workspace runCommand: string[]; - // Environment variable present in the server execution environment. + // Environment variables set when the app is run environmentVariables?: EnvVarConfig[]; // The maximum number of concurrent requests that each server instance can receive. // Defaults to 80. @@ -31,26 +31,31 @@ interface ServerConfig { maxInstances?: number; } -// Additonal fields needed for adapter identification +// Additonal fields needed for identifying the framework and adapter being used interface Metadata { - // Name of the adapter (this should be the npm package name) - adapterNpmPackageName: string; - // Version of the adapter + // Name of the adapter (this should be the official package name) + adapterPackageName: string; + // Version of the adapter adapterVersion?: string; - // Name of the framework that is being supported + // Name of the framework that is being supported, e.g. "angular" framework: string; - // Version of the framework that is being supported + // Version of the framework that is being supported, e.g. "18.0.1" frameworkVersion?: string; } -// Configs necessary to define environment variables +// Represents a single environment variable. interface EnvVarConfig { // Name of the variable variable: string; // Value associated with the variable value: string; - // Where the variable will be available, for now this will always be RUNTIME - availability: "RUNTIME"[]; + // Where the variable will be available, for now only RUNTIME is supported + availability: Availabilities.Runtime[]; +} + +// Represents where environment variables are available from +enum Availabilities { + Runtime, } // Options to configure the build of a framework application From fb460670169e0839113a03c59b1bf550291995a7 Mon Sep 17 00:00:00 2001 From: yuangwang Date: Thu, 29 Aug 2024 17:03:21 -0400 Subject: [PATCH 05/10] fix prettier --- packages/@apphosting/common/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@apphosting/common/src/index.ts b/packages/@apphosting/common/src/index.ts index 5bbf006e..59359db0 100644 --- a/packages/@apphosting/common/src/index.ts +++ b/packages/@apphosting/common/src/index.ts @@ -1,7 +1,7 @@ import { spawn } from "child_process"; // Output bundle metadata specifications to be written to bundle.yaml -export interface OutputBundleConfigs{ +export interface OutputBundleConfigs { version: "v1"; serverConfig: ServerConfig; metadata: Metadata; @@ -35,7 +35,7 @@ interface ServerConfig { interface Metadata { // Name of the adapter (this should be the official package name) adapterPackageName: string; - // Version of the adapter + // Version of the adapter adapterVersion?: string; // Name of the framework that is being supported, e.g. "angular" framework: string; From 006ca24c9c53a80cd36920ed5ce7a34bc066425e Mon Sep 17 00:00:00 2001 From: yuangwang Date: Thu, 29 Aug 2024 17:07:29 -0400 Subject: [PATCH 06/10] add comment --- packages/@apphosting/common/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@apphosting/common/src/index.ts b/packages/@apphosting/common/src/index.ts index 59359db0..1e3f757e 100644 --- a/packages/@apphosting/common/src/index.ts +++ b/packages/@apphosting/common/src/index.ts @@ -33,9 +33,9 @@ interface ServerConfig { // Additonal fields needed for identifying the framework and adapter being used interface Metadata { - // Name of the adapter (this should be the official package name) + // Name of the adapter (this should be the official package name) e.g. "@apphosting/adapter-nextjs" adapterPackageName: string; - // Version of the adapter + // Version of the adapter, e.g. "18.0.1" adapterVersion?: string; // Name of the framework that is being supported, e.g. "angular" framework: string; From 71797db6c9f009cbc83d9e12ad23d54ad577ae8c Mon Sep 17 00:00:00 2001 From: yuangwang Date: Tue, 3 Sep 2024 16:27:35 -0400 Subject: [PATCH 07/10] address comments --- packages/@apphosting/common/src/index.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/@apphosting/common/src/index.ts b/packages/@apphosting/common/src/index.ts index 1e3f757e..84d47680 100644 --- a/packages/@apphosting/common/src/index.ts +++ b/packages/@apphosting/common/src/index.ts @@ -1,7 +1,7 @@ import { spawn } from "child_process"; // Output bundle metadata specifications to be written to bundle.yaml -export interface OutputBundleConfigs { +export interface OutputBundleConfig { version: "v1"; serverConfig: ServerConfig; metadata: Metadata; @@ -9,25 +9,20 @@ export interface OutputBundleConfigs { // Fields needed to configure the App Hosting server interface ServerConfig { - // Command to start the server (e.g. ["node", "dist/index.js"]). Assume this command is run from the root dir of the workspace - runCommand: string[]; + // Command to start the server (e.g. "node dist/index.js"). Assume this command is run from the root dir of the workspace + runCommand: string; // Environment variables set when the app is run environmentVariables?: EnvVarConfig[]; + // See https://firebase.google.com/docs/reference/apphosting/rest/v1beta/projects.locations.backends.builds#runconfig for documentation on the next fields // The maximum number of concurrent requests that each server instance can receive. - // Defaults to 80. concurrency?: number; // The number of CPUs used in a single server instance. - // Defaults to 1. - cpu?: "fractional" | 1 | 2 | 4 | 6 | 8; + cpu?: number; // The amount of memory available for a server instance. - // Commonly one of: "256" | "512" | "1024" | "2048" | "4096" | "8192" | "16384" - // Defaults to 512MiB. memoryMiB?: string; // The limit on the minimum number of function instances that may coexist at a given time. - // Defaults to 0. minInstances?: number; // The limit on the maximum number of function instances that may coexist at a given time. - // Defaults to 100. maxInstances?: number; } @@ -50,11 +45,12 @@ interface EnvVarConfig { // Value associated with the variable value: string; // Where the variable will be available, for now only RUNTIME is supported - availability: Availabilities.Runtime[]; + availability: Availability.Runtime[]; } -// Represents where environment variables are available from -enum Availabilities { +// Represents where environment variables are made available +enum Availability { + // Runtime environment variables are available on the server when the app is run Runtime, } From 9c9929b7c757427cfc1e432c3a30ca6e31f19930 Mon Sep 17 00:00:00 2001 From: yuangwang Date: Tue, 3 Sep 2024 16:28:20 -0400 Subject: [PATCH 08/10] address comments --- packages/@apphosting/common/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@apphosting/common/src/index.ts b/packages/@apphosting/common/src/index.ts index 84d47680..f3cf640a 100644 --- a/packages/@apphosting/common/src/index.ts +++ b/packages/@apphosting/common/src/index.ts @@ -31,7 +31,7 @@ interface Metadata { // Name of the adapter (this should be the official package name) e.g. "@apphosting/adapter-nextjs" adapterPackageName: string; // Version of the adapter, e.g. "18.0.1" - adapterVersion?: string; + adapterVersion: string; // Name of the framework that is being supported, e.g. "angular" framework: string; // Version of the framework that is being supported, e.g. "18.0.1" From 91766c520817effe9149dde8aa180fca99682290 Mon Sep 17 00:00:00 2001 From: yuangwang Date: Tue, 3 Sep 2024 16:29:31 -0400 Subject: [PATCH 09/10] prettier --- packages/@apphosting/common/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@apphosting/common/src/index.ts b/packages/@apphosting/common/src/index.ts index f3cf640a..f97bac25 100644 --- a/packages/@apphosting/common/src/index.ts +++ b/packages/@apphosting/common/src/index.ts @@ -50,7 +50,7 @@ interface EnvVarConfig { // Represents where environment variables are made available enum Availability { - // Runtime environment variables are available on the server when the app is run + // Runtime environment variables are available on the server when the app is run Runtime, } From f947fbb06ff87204e8836b035df3e07daddcddac Mon Sep 17 00:00:00 2001 From: yuangwang Date: Tue, 3 Sep 2024 16:41:31 -0400 Subject: [PATCH 10/10] address comment --- packages/@apphosting/common/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@apphosting/common/src/index.ts b/packages/@apphosting/common/src/index.ts index f97bac25..0ac67445 100644 --- a/packages/@apphosting/common/src/index.ts +++ b/packages/@apphosting/common/src/index.ts @@ -19,7 +19,7 @@ interface ServerConfig { // The number of CPUs used in a single server instance. cpu?: number; // The amount of memory available for a server instance. - memoryMiB?: string; + memoryMiB?: number; // The limit on the minimum number of function instances that may coexist at a given time. minInstances?: number; // The limit on the maximum number of function instances that may coexist at a given time.