Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output bundle spec to common module #244

Merged
merged 14 commits into from
Sep 3, 2024
14 changes: 13 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/@apphosting/common/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
54 changes: 54 additions & 0 deletions packages/@apphosting/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -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.
tonyjhuang marked this conversation as resolved.
Show resolved Hide resolved
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;
sjjj986 marked this conversation as resolved.
Show resolved Hide resolved
}

// 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,
tonyjhuang marked this conversation as resolved.
Show resolved Hide resolved
}

// Options to configure the build of a framework application
export interface BuildOptions {
// command to run build script (e.g. "npm", "nx", etc.)
Expand Down
Loading