Skip to content

Commit

Permalink
Add output bundle spec to common module (#244)
Browse files Browse the repository at this point in the history
* add output bundle spec to common module

* Update package.json

* packagelock

* address comments

* fix prettier

* add comment

* address comments

* address comments

* prettier

* address comment
  • Loading branch information
Yuangwang authored Sep 3, 2024
1 parent 7957560 commit 1a99446
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
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.
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.)
Expand Down

0 comments on commit 1a99446

Please sign in to comment.