Skip to content

Commit 2748f41

Browse files
committed
Rename frameworks to apphosting.
1 parent 3237e26 commit 2748f41

File tree

14 files changed

+80
-87
lines changed

14 files changed

+80
-87
lines changed

src/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ export const serviceUsageOrigin = utils.envOverride(
179179
"FIREBASE_SERVICE_USAGE_URL",
180180
"https://serviceusage.googleapis.com"
181181
);
182-
export const frameworksOrigin = utils.envOverride(
183-
"FRAMEWORKS_URL",
184-
"https://placeholder.googleapis.com"
182+
export const apphostingOrigin = utils.envOverride(
183+
"APPHOSTING_URL",
184+
"https://firebaseapphosting.googleapis.com"
185185
);
186186
export const githubOrigin = utils.envOverride("GITHUB_URL", "https://github.com");
187187
export const githubApiOrigin = utils.envOverride("GITHUB_API_URL", "https://api.github.com");

src/commands/frameworks-backends-create.ts renamed to src/commands/apphosting-backends-create.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { Command } from "../command";
22
import { Options } from "../options";
33
import { needProjectId } from "../projectUtils";
44
import requireInteractive from "../requireInteractive";
5-
import { doSetup } from "../init/features/frameworks";
6-
import { ensureApiEnabled } from "../gcp/frameworks";
5+
import { doSetup } from "../init/features/apphosting";
6+
import { ensureApiEnabled } from "../gcp/apphosting";
77

8-
export const command = new Command("backends:create")
8+
export const command = new Command("apphosting:backends:create")
99
.description("Create a backend in a Firebase project")
1010
.option("-l, --location <location>", "Specify the region of the backend", "")
1111
.before(ensureApiEnabled)

src/commands/frameworks-backends-delete.ts renamed to src/commands/apphosting-backends-delete.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { Command } from "../command";
22
import { Options } from "../options";
33
import { needProjectId } from "../projectUtils";
44
import { FirebaseError } from "../error";
5-
import * as gcp from "../gcp/frameworks";
65
import { promptOnce } from "../prompt";
7-
import * as utils from "../utils";
86
import { logger } from "../logger";
9-
import { DEFAULT_REGION } from "../init/features/frameworks/constants";
10-
import { ensureApiEnabled } from "../gcp/frameworks";
7+
import { DEFAULT_REGION } from "../init/features/apphosting/constants";
8+
import * as utils from "../utils";
9+
import * as apphosting from "../gcp/apphosting";
1110

1211
const Table = require("cli-table");
1312

@@ -21,12 +20,12 @@ const TABLE_HEAD = [
2120
"Updated Date",
2221
];
2322

24-
export const command = new Command("backends:delete")
23+
export const command = new Command("apphosting:backends:delete")
2524
.description("Delete a backend from a Firebase project")
2625
.option("-l, --location <location>", "App Backend location", "")
2726
.option("-s, --backend <backend>", "Backend Id", "")
2827
.withForce()
29-
.before(ensureApiEnabled)
28+
.before(apphosting.ensureApiEnabled)
3029
.action(async (options: Options) => {
3130
const projectId = needProjectId(options);
3231
let location = options.location as string;
@@ -36,7 +35,9 @@ export const command = new Command("backends:delete")
3635
}
3736

3837
if (!location) {
39-
const allowedLocations = (await gcp.listLocations(projectId)).map((loc) => loc.locationId);
38+
const allowedLocations = (await apphosting.listLocations(projectId)).map(
39+
(loc) => loc.locationId
40+
);
4041
location = await promptOnce({
4142
name: "region",
4243
type: "list",
@@ -54,7 +55,7 @@ export const command = new Command("backends:delete")
5455

5556
let backend;
5657
try {
57-
backend = await gcp.getBackend(projectId, location, backendId);
58+
backend = await apphosting.getBackend(projectId, location, backendId);
5859
populateTable(backend, table);
5960
} catch (err: any) {
6061
throw new FirebaseError(`No backends found with given parameters. Command aborted.`, {
@@ -79,7 +80,7 @@ export const command = new Command("backends:delete")
7980
}
8081

8182
try {
82-
await gcp.deleteBackend(projectId, location, backendId);
83+
await apphosting.deleteBackend(projectId, location, backendId);
8384
utils.logSuccess(`Successfully deleted the backend: ${backendId}`);
8485
} catch (err: any) {
8586
throw new FirebaseError(
@@ -91,7 +92,7 @@ export const command = new Command("backends:delete")
9192
return backend;
9293
});
9394

94-
function populateTable(backend: gcp.Backend, table: any) {
95+
function populateTable(backend: apphosting.Backend, table: any) {
9596
const [location, , backendId] = backend.name.split("/").slice(3, 6);
9697
const entry = [
9798
backendId,

src/commands/frameworks-backends-get.ts renamed to src/commands/apphosting-backends-get.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
import * as gcp from "../gcp/frameworks";
21
import { Command } from "../command";
32
import { Options } from "../options";
43
import { needProjectId } from "../projectUtils";
54
import { FirebaseError } from "../error";
65
import { logger } from "../logger";
7-
import { ensureApiEnabled } from "../gcp/frameworks";
86
import { logWarning } from "../utils";
7+
import * as apphosting from "../gcp/apphosting";
98

109
const Table = require("cli-table");
1110
const COLUMN_LENGTH = 20;
1211
const TABLE_HEAD = ["Backend Id", "Repository", "Location", "URL", "Created Date", "Updated Date"];
13-
export const command = new Command("backends:get <backendId>")
12+
export const command = new Command("apphosting:backends:get <backendId>")
1413
.description("Get backend details of a Firebase project")
1514
.option("-l, --location <location>", "App Backend location", "-")
16-
.before(ensureApiEnabled)
15+
.before(apphosting.ensureApiEnabled)
1716
.action(async (backendId: string, options: Options) => {
1817
const projectId = needProjectId(options);
1918
const location = options.location as string;
2019

21-
let backendsList: gcp.Backend[] = [];
20+
let backendsList: apphosting.Backend[] = [];
2221
const table = new Table({
2322
head: TABLE_HEAD,
2423
style: { head: ["green"] },
2524
});
2625
table.colWidths = COLUMN_LENGTH;
2726
try {
2827
if (location !== "-") {
29-
const backendInRegion = await gcp.getBackend(projectId, location, backendId);
28+
const backendInRegion = await apphosting.getBackend(projectId, location, backendId);
3029
backendsList.push(backendInRegion);
3130
populateTable(backendInRegion, table);
3231
} else {
33-
const resp = await gcp.listBackends(projectId, "-");
32+
const resp = await apphosting.listBackends(projectId, "-");
3433
const allBackends = resp.backends || [];
3534
backendsList = allBackends.filter((bkd) => bkd.name.split("/").pop() === backendId);
3635
backendsList.forEach((bkd) => populateTable(bkd, table));
@@ -49,7 +48,7 @@ export const command = new Command("backends:get <backendId>")
4948
return backendsList[0];
5049
});
5150

52-
function populateTable(backend: gcp.Backend, table: any) {
51+
function populateTable(backend: apphosting.Backend, table: any) {
5352
const [location, , backendId] = backend.name.split("/").slice(3, 6);
5453
const entry = [
5554
backendId,

src/commands/frameworks-backends-list.ts renamed to src/commands/apphosting-backends-list.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import { Command } from "../command";
22
import { Options } from "../options";
33
import { needProjectId } from "../projectUtils";
4-
import * as gcp from "../gcp/frameworks";
54
import { FirebaseError } from "../error";
65
import { logger } from "../logger";
7-
import { ensureApiEnabled } from "../gcp/frameworks";
6+
import * as apphosting from "../gcp/apphosting";
87

98
const Table = require("cli-table");
109
const COLUMN_LENGTH = 20;
1110
const TABLE_HEAD = ["Backend Id", "Repository", "Location", "URL", "Created Date", "Updated Date"];
12-
export const command = new Command("backends:list")
11+
export const command = new Command("apphosting:backends:list")
1312
.description("List backends of a Firebase project.")
1413
.option("-l, --location <location>", "App Backend location", "-")
15-
.before(ensureApiEnabled)
14+
.before(apphosting.ensureApiEnabled)
1615
.action(async (options: Options) => {
1716
const projectId = needProjectId(options);
1817
const location = options.location as string;
@@ -21,9 +20,9 @@ export const command = new Command("backends:list")
2120
style: { head: ["green"] },
2221
});
2322
table.colWidths = COLUMN_LENGTH;
24-
const backendsList: gcp.Backend[] = [];
23+
const backendsList: apphosting.Backend[] = [];
2524
try {
26-
const backendsPerRegion = await gcp.listBackends(projectId, location);
25+
const backendsPerRegion = await apphosting.listBackends(projectId, location);
2726
backendsList.push(...(backendsPerRegion.backends || []));
2827
populateTable(backendsList, table);
2928
logger.info(table.toString());
@@ -37,7 +36,7 @@ export const command = new Command("backends:list")
3736
return backendsList;
3837
});
3938

40-
function populateTable(backends: gcp.Backend[], table: any) {
39+
function populateTable(backends: apphosting.Backend[], table: any) {
4140
for (const backend of backends) {
4241
const [location, , backendId] = backend.name.split("/").slice(3, 6);
4342
const entry = [

src/commands/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ export function load(client: any): any {
151151
client.internaltesting.functions.discover = loadCommand("internaltesting-functions-discover");
152152
}
153153
if (experiments.isEnabled("internalframeworks")) {
154-
client.frameworks = {};
155-
client.frameworks.backends = {};
156-
client.frameworks.backends.list = loadCommand("frameworks-backends-list");
157-
client.frameworks.backends.create = loadCommand("frameworks-backends-create");
158-
client.frameworks.backends.get = loadCommand("frameworks-backends-get");
159-
client.frameworks.backends.delete = loadCommand("frameworks-backends-delete");
154+
client.apphosting = {};
155+
client.apphosting.backends = {};
156+
client.apphosting.backends.list = loadCommand("apphosting-backends-list");
157+
client.apphosting.backends.create = loadCommand("apphosting-backends-create");
158+
client.apphosting.backends.get = loadCommand("apphosting-backends-get");
159+
client.apphosting.backends.delete = loadCommand("apphosting-backends-delete");
160160
}
161161
client.login = loadCommand("login");
162162
client.login.add = loadCommand("login-add");

src/gcp/frameworks.ts renamed to src/gcp/apphosting.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Client } from "../apiv2";
22
import { needProjectId } from "../projectUtils";
3-
import { frameworksOrigin } from "../api";
3+
import { apphostingOrigin } from "../api";
44
import { ensure } from "../ensureApiEnabled";
55

6-
export const API_HOST = new URL(frameworksOrigin).host;
6+
export const API_HOST = new URL(apphostingOrigin).host;
77
export const API_VERSION = "v1alpha";
88

99
const client = new Client({
10-
urlPrefix: frameworksOrigin,
10+
urlPrefix: apphostingOrigin,
1111
auth: true,
1212
apiVersion: API_VERSION,
1313
});

src/init/features/frameworks/index.ts renamed to src/init/features/apphosting/index.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
import * as clc from "colorette";
22
import * as repo from "./repo";
33
import * as poller from "../../../operation-poller";
4-
import * as gcp from "../../../gcp/frameworks";
4+
import * as apphosting from "../../../gcp/apphosting";
55
import { logBullet, logSuccess, logWarning } from "../../../utils";
6-
import { frameworksOrigin } from "../../../api";
7-
import { Backend, BackendOutputOnlyFields } from "../../../gcp/frameworks";
6+
import { apphostingOrigin } from "../../../api";
7+
import { Backend, BackendOutputOnlyFields, API_VERSION } from "../../../gcp/apphosting";
88
import { Repository } from "../../../gcp/cloudbuild";
9-
import { API_VERSION } from "../../../gcp/frameworks";
109
import { FirebaseError } from "../../../error";
1110
import { promptOnce } from "../../../prompt";
1211
import { DEFAULT_REGION } from "./constants";
1312
import { ensure } from "../../../ensureApiEnabled";
1413

15-
const frameworksPollerOptions: Omit<poller.OperationPollerOptions, "operationResourceName"> = {
16-
apiOrigin: frameworksOrigin,
14+
const apphostingPollerOptions: Omit<poller.OperationPollerOptions, "operationResourceName"> = {
15+
apiOrigin: apphostingOrigin,
1716
apiVersion: API_VERSION,
1817
masterTimeout: 25 * 60 * 1_000,
1918
maxBackoff: 10_000,
2019
};
2120

2221
/**
23-
* Setup new frameworks project.
22+
* Set up a new App Hosting backend.
2423
*/
2524
export async function doSetup(setup: any, projectId: string): Promise<void> {
26-
setup.frameworks = {};
27-
2825
await Promise.all([
29-
ensure(projectId, "cloudbuild.googleapis.com", "frameworks", true),
30-
ensure(projectId, "secretmanager.googleapis.com", "frameworks", true),
31-
ensure(projectId, "run.googleapis.com", "frameworks", true),
32-
ensure(projectId, "artifactregistry.googleapis.com", "frameworks", true),
26+
ensure(projectId, "cloudbuild.googleapis.com", "apphosting", true),
27+
ensure(projectId, "secretmanager.googleapis.com", "apphosting", true),
28+
ensure(projectId, "run.googleapis.com", "apphosting", true),
29+
ensure(projectId, "artifactregistry.googleapis.com", "apphosting", true),
3330
]);
3431

35-
const allowedLocations = (await gcp.listLocations(projectId)).map((loc) => loc.locationId);
32+
const allowedLocations = (await apphosting.listLocations(projectId)).map((loc) => loc.locationId);
3633

3734
if (setup.location) {
3835
if (!allowedLocations.includes(setup.location)) {
@@ -57,7 +54,7 @@ export async function doSetup(setup: any, projectId: string): Promise<void> {
5754
message: "Create a name for your backend [1-30 characters]",
5855
});
5956
try {
60-
await gcp.getBackend(projectId, location, backendId);
57+
await apphosting.getBackend(projectId, location, backendId);
6158
} catch (err: any) {
6259
if (err.status === 404) {
6360
break;
@@ -75,7 +72,7 @@ export async function doSetup(setup: any, projectId: string): Promise<void> {
7572
logSuccess(`Successfully created backend:\n\t${backend.name}`);
7673
logSuccess(`Your site is being deployed at:\n\thttps://${backend.uri}`);
7774
logSuccess(
78-
`View the rollout status by running:\n\tfirebase backends:get ${backendId} --project ${projectId}`
75+
`View the rollout status by running:\n\tfirebase apphosting:backends:get ${backendId} --project ${projectId}`
7976
);
8077
}
8178
}
@@ -133,9 +130,9 @@ export async function createBackend(
133130
backendReqBoby: Omit<Backend, BackendOutputOnlyFields>,
134131
backendId: string
135132
): Promise<Backend> {
136-
const op = await gcp.createBackend(projectId, location, backendReqBoby, backendId);
133+
const op = await apphosting.createBackend(projectId, location, backendReqBoby, backendId);
137134
const backend = await poller.pollOperation<Backend>({
138-
...frameworksPollerOptions,
135+
...apphostingPollerOptions,
139136
pollerName: `create-${projectId}-${location}-${backendId}`,
140137
operationResourceName: op.name,
141138
});

src/init/features/frameworks/repo.ts renamed to src/init/features/apphosting/repo.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export interface ConnectionNameParts {
1515
id: string;
1616
}
1717

18-
const FRAMEWORKS_CONN_PATTERN = /.+\/frameworks-github-conn-.+$/;
19-
const FRAMEWORKS_OAUTH_CONN_NAME = "frameworks-github-oauth";
18+
const APPHOSTING_CONN_PATTERN = /.+\/apphosting-github-conn-.+$/;
19+
const APPHOSTING_OAUTH_CONN_NAME = "apphosting-github-oauth";
2020
const CONNECTION_NAME_REGEX =
2121
/^projects\/(?<projectId>[^\/]+)\/locations\/(?<location>[^\/]+)\/connections\/(?<id>[^\/]+)$/;
2222

@@ -69,7 +69,7 @@ function generateRepositoryId(remoteUri: string): string | undefined {
6969
*/
7070
function generateConnectionId(): string {
7171
const randomHash = Math.random().toString(36).slice(6);
72-
return `frameworks-github-conn-${randomHash}`;
72+
return `apphosting-github-conn-${randomHash}`;
7373
}
7474

7575
/**
@@ -80,13 +80,13 @@ export async function linkGitHubRepository(
8080
location: string
8181
): Promise<gcb.Repository> {
8282
utils.logBullet(clc.bold(`${clc.yellow("===")} Set up a GitHub connection`));
83-
const existingConns = await listFrameworksConnections(projectId);
83+
const existingConns = await listAppHostingConnections(projectId);
8484
if (existingConns.length < 1) {
8585
const grantSuccess = await promptSecretManagerAdminGrant(projectId);
8686
if (!grantSuccess) {
8787
throw new FirebaseError("Insufficient IAM permissions to create a new connection to GitHub");
8888
}
89-
let oauthConn = await getOrCreateConnection(projectId, location, FRAMEWORKS_OAUTH_CONN_NAME);
89+
let oauthConn = await getOrCreateConnection(projectId, location, APPHOSTING_OAUTH_CONN_NAME);
9090
while (oauthConn.installationState.stage === "PENDING_USER_OAUTH") {
9191
oauthConn = await promptConnectionAuth(oauthConn);
9292
}
@@ -301,11 +301,11 @@ export async function getOrCreateRepository(
301301
return repo;
302302
}
303303

304-
export async function listFrameworksConnections(projectId: string) {
304+
export async function listAppHostingConnections(projectId: string) {
305305
const conns = await gcb.listConnections(projectId, "-");
306306
return conns.filter(
307307
(conn) =>
308-
FRAMEWORKS_CONN_PATTERN.test(conn.name) &&
308+
APPHOSTING_CONN_PATTERN.test(conn.name) &&
309309
conn.installationState.stage === "COMPLETE" &&
310310
!conn.disabled
311311
);

0 commit comments

Comments
 (0)