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": { 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", diff --git a/packages/@apphosting/common/src/index.ts b/packages/@apphosting/common/src/index.ts index ac24ac95..0ac67445 100644 --- a/packages/@apphosting/common/src/index.ts +++ b/packages/@apphosting/common/src/index.ts @@ -1,5 +1,59 @@ import { spawn } from "child_process"; +// Output bundle metadata specifications to be written to bundle.yaml +export interface OutputBundleConfig { + 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 + 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. + concurrency?: number; + // The number of CPUs used in a single server instance. + cpu?: number; + // The amount of memory available for a server instance. + 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. + maxInstances?: number; +} + +// Additonal fields needed for identifying the framework and adapter being used +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; + // 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" + frameworkVersion?: string; +} + +// 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 only RUNTIME is supported + availability: Availability.Runtime[]; +} + +// Represents where environment variables are made available +enum Availability { + // Runtime environment variables are available on the server when the app is run + Runtime, +} + // Options to configure the build of a framework application export interface BuildOptions { // command to run build script (e.g. "npm", "nx", etc.)