-
Notifications
You must be signed in to change notification settings - Fork 970
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utility commands for app hosting.
- Loading branch information
Showing
8 changed files
with
149 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as apphosting from "../gcp/apphosting"; | ||
import { logger } from "../logger"; | ||
import { Command } from "../command"; | ||
import { Options } from "../options"; | ||
import { generateId } from "../utils"; | ||
import { needProjectId } from "../projectUtils"; | ||
|
||
export const command = new Command("apphosting:builds:create <backendId>") | ||
.description("Create a build for an App Hosting backend") | ||
.option("-l, --location <location>", "Specify the region of the backend", "us-central1") | ||
.option("-i, --id <buildId>", "Id of the build. If not present, autogenerate a random id", "") | ||
.option("-b, --branch <branch>", "Repository branch to deploy. Defaults to 'main'", "main") | ||
.before(apphosting.ensureApiEnabled) | ||
.action(async (backendId: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const location = options.location as string; | ||
const buildId = (options.buildId as string) || generateId(); | ||
const branch = options.branch as string; | ||
|
||
const op = await apphosting.createBuild(projectId, location, backendId, buildId, { | ||
source: { | ||
codebase: { | ||
branch: "main", | ||
}, | ||
}, | ||
}); | ||
|
||
logger.info(`Started a build for backend ${backendId} on branch ${branch}.`); | ||
logger.info("Check status by running:"); | ||
logger.info(`\tfirebase apphosting:builds:get ${backendId} ${buildId} --location ${location}`); | ||
return op; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as apphosting from "../gcp/apphosting"; | ||
import { logger } from "../logger"; | ||
import { Command } from "../command"; | ||
import { Options } from "../options"; | ||
import { needProjectId } from "../projectUtils"; | ||
|
||
export const command = new Command("apphosting:builds:get <backendId> <buildId>") | ||
.description("Create a build for an App Hosting backend") | ||
.option("-l, --location <location>", "Specify the region of the backend", "us-central1") | ||
.before(apphosting.ensureApiEnabled) | ||
.action(async (backendId: string, buildId: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const location = options.location as string; | ||
const build = await apphosting.getBuild(projectId, location, backendId, buildId); | ||
logger.info(JSON.stringify(build, null, 2)); | ||
return build; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as apphosting from "../gcp/apphosting"; | ||
import { logger } from "../logger"; | ||
import { Command } from "../command"; | ||
import { Options } from "../options"; | ||
import { needProjectId } from "../projectUtils"; | ||
import { generateId } from "../utils"; | ||
|
||
export const command = new Command("apphosting:rollouts:create <backendId> <buildId>") | ||
.description("Create a build for an App Hosting backend") | ||
.option("-l, --location <location>", "Specify the region of the backend", "us-central1") | ||
.option("-i, --id <rolloutId>", "Id of the rollout. If not present, autogenerate a random id", "") | ||
.before(apphosting.ensureApiEnabled) | ||
.action(async (backendId: string, buildId: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const location = options.location as string; | ||
const rolloutId = (options.buildId as string) || generateId(); | ||
const build = `projects/${projectId}/backends/${backendId}/builds/${buildId}`; | ||
const op = await apphosting.createRollout(projectId, location, backendId, rolloutId, { | ||
build, | ||
}); | ||
logger.info(`Started a rollout for backend ${backendId} with build ${buildId}.`); | ||
logger.info("Check status by running:"); | ||
logger.info(`\tfirebase apphosting:rollouts:list --location ${location}`); | ||
return op; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as apphosting from "../gcp/apphosting"; | ||
import { logger } from "../logger"; | ||
import { Command } from "../command"; | ||
import { Options } from "../options"; | ||
import { needProjectId } from "../projectUtils"; | ||
|
||
export const command = new Command("apphosting:rollouts:list <backendId>") | ||
.description("List rollouts of an App Hosting backend") | ||
.option( | ||
"-l, --location <location>", | ||
"Rgion of the rollouts. Defaults to listing rollouts from all regions", | ||
"-" | ||
) | ||
.before(apphosting.ensureApiEnabled) | ||
.action(async (backendId: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const location = options.location as string; | ||
const rollouts = await apphosting.listRollouts(projectId, location, backendId); | ||
logger.info(JSON.stringify(rollouts, null, 2)); | ||
return rollouts; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters