firebase-tools 13.7.1 → 13.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apphosting/githubConnections.js +3 -3
- package/lib/apphosting/index.js +9 -3
- package/lib/commands/firestore-databases-create.js +1 -0
- package/lib/commands/firestore-databases-restore.js +1 -0
- package/lib/commands/index.js +0 -6
- package/lib/deploy/firestore/prepare.js +4 -2
- package/lib/deploy/functions/deploy.js +2 -2
- package/lib/deploy/functions/prepare.js +1 -0
- package/lib/deploy/functions/pricing.js +2 -2
- package/lib/downloadUtils.js +1 -0
- package/lib/firestore/pretty-print.js +5 -0
- package/lib/frameworks/astro/index.js +1 -1
- package/package.json +1 -1
- package/lib/commands/apphosting-builds-create.js +0 -32
- package/lib/commands/apphosting-builds-get.js +0 -18
- package/lib/commands/apphosting-rollouts-create.js +0 -26
- package/lib/commands/apphosting-rollouts-list.js +0 -21
|
@@ -64,7 +64,7 @@ async function linkGitHubRepository(projectId, location) {
|
|
|
64
64
|
let connection;
|
|
65
65
|
do {
|
|
66
66
|
if (repoCloneUri === ADD_CONN_CHOICE) {
|
|
67
|
-
existingConns.push(await createFullyInstalledConnection(projectId, location, generateConnectionId(), oauthConn));
|
|
67
|
+
existingConns.push(await createFullyInstalledConnection(projectId, location, generateConnectionId(), oauthConn, true));
|
|
68
68
|
}
|
|
69
69
|
const selection = await promptCloneUri(projectId, existingConns);
|
|
70
70
|
repoCloneUri = selection.cloneUri;
|
|
@@ -81,10 +81,10 @@ async function linkGitHubRepository(projectId, location) {
|
|
|
81
81
|
return repo;
|
|
82
82
|
}
|
|
83
83
|
exports.linkGitHubRepository = linkGitHubRepository;
|
|
84
|
-
async function createFullyInstalledConnection(projectId, location, connectionId, oauthConn) {
|
|
84
|
+
async function createFullyInstalledConnection(projectId, location, connectionId, oauthConn, withNewInstallation = false) {
|
|
85
85
|
var _a, _b;
|
|
86
86
|
let conn = await createConnection(projectId, location, connectionId, {
|
|
87
|
-
appInstallationId: (_a = oauthConn.githubConfig) === null || _a === void 0 ? void 0 : _a.appInstallationId,
|
|
87
|
+
appInstallationId: withNewInstallation ? undefined : (_a = oauthConn.githubConfig) === null || _a === void 0 ? void 0 : _a.appInstallationId,
|
|
88
88
|
authorizerCredential: (_b = oauthConn.githubConfig) === null || _b === void 0 ? void 0 : _b.authorizerCredential,
|
|
89
89
|
});
|
|
90
90
|
while (conn.installationState.stage !== "COMPLETE") {
|
package/lib/apphosting/index.js
CHANGED
|
@@ -58,7 +58,13 @@ async function doSetup(projectId, location, serviceAccount, withDevConnect) {
|
|
|
58
58
|
const gitRepositoryConnection = withDevConnect
|
|
59
59
|
? await githubConnections.linkGitHubRepository(projectId, location)
|
|
60
60
|
: await repo.linkGitHubRepository(projectId, location);
|
|
61
|
-
const
|
|
61
|
+
const rootDir = await (0, prompt_1.promptOnce)({
|
|
62
|
+
name: "rootDir",
|
|
63
|
+
type: "input",
|
|
64
|
+
default: "/",
|
|
65
|
+
message: "Specify the path to the root of the app you would like to deploy (relative to the repo root)",
|
|
66
|
+
});
|
|
67
|
+
const backend = await createBackend(projectId, location, backendId, gitRepositoryConnection, serviceAccount, rootDir);
|
|
62
68
|
const branch = await (0, prompt_1.promptOnce)({
|
|
63
69
|
name: "branch",
|
|
64
70
|
type: "input",
|
|
@@ -106,13 +112,13 @@ async function promptNewBackendId(projectId, location, prompt) {
|
|
|
106
112
|
function defaultComputeServiceAccountEmail(projectId) {
|
|
107
113
|
return `${DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME}@${projectId}.iam.gserviceaccount.com`;
|
|
108
114
|
}
|
|
109
|
-
async function createBackend(projectId, location, backendId, repository, serviceAccount) {
|
|
115
|
+
async function createBackend(projectId, location, backendId, repository, serviceAccount, rootDir = "/") {
|
|
110
116
|
const defaultServiceAccount = defaultComputeServiceAccountEmail(projectId);
|
|
111
117
|
const backendReqBody = {
|
|
112
118
|
servingLocality: "GLOBAL_ACCESS",
|
|
113
119
|
codebase: {
|
|
114
120
|
repository: `${repository.name}`,
|
|
115
|
-
rootDirectory:
|
|
121
|
+
rootDirectory: rootDir,
|
|
116
122
|
},
|
|
117
123
|
labels: deploymentTool.labels(),
|
|
118
124
|
serviceAccount: serviceAccount || defaultServiceAccount,
|
|
@@ -52,6 +52,7 @@ exports.command = new command_1.Command("firestore:databases:create <database>")
|
|
|
52
52
|
logger_1.logger.info("Please be sure to configure Firebase rules in your Firebase config file for\n" +
|
|
53
53
|
"the new database. By default, created databases will have closed rules that\n" +
|
|
54
54
|
"block any incoming third-party traffic.");
|
|
55
|
+
logger_1.logger.info(`Your database may be viewed at ${printer.firebaseConsoleDatabaseUrl(options.project, database)}`);
|
|
55
56
|
}
|
|
56
57
|
return databaseResp;
|
|
57
58
|
});
|
|
@@ -37,6 +37,7 @@ exports.command = new command_1.Command("firestore:databases:restore")
|
|
|
37
37
|
logger_1.logger.info("Please be sure to configure Firebase rules in your Firebase config file for\n" +
|
|
38
38
|
"the new database. By default, created databases will have closed rules that\n" +
|
|
39
39
|
"block any incoming third-party traffic.");
|
|
40
|
+
logger_1.logger.info(`Once the restore is complete, your database may be viewed at ${printer.firebaseConsoleDatabaseUrl(options.project, databaseId)}`);
|
|
40
41
|
}
|
|
41
42
|
return databaseResp;
|
|
42
43
|
});
|
package/lib/commands/index.js
CHANGED
|
@@ -162,17 +162,11 @@ function load(client) {
|
|
|
162
162
|
client.apphosting.backends.create = loadCommand("apphosting-backends-create");
|
|
163
163
|
client.apphosting.backends.get = loadCommand("apphosting-backends-get");
|
|
164
164
|
client.apphosting.backends.delete = loadCommand("apphosting-backends-delete");
|
|
165
|
-
client.apphosting.builds = {};
|
|
166
|
-
client.apphosting.builds.get = loadCommand("apphosting-builds-get");
|
|
167
|
-
client.apphosting.builds.create = loadCommand("apphosting-builds-create");
|
|
168
165
|
client.apphosting.secrets = {};
|
|
169
166
|
client.apphosting.secrets.set = loadCommand("apphosting-secrets-set");
|
|
170
167
|
client.apphosting.secrets.grantaccess = loadCommand("apphosting-secrets-grantaccess");
|
|
171
168
|
client.apphosting.secrets.describe = loadCommand("apphosting-secrets-describe");
|
|
172
169
|
client.apphosting.secrets.access = loadCommand("apphosting-secrets-access");
|
|
173
|
-
client.apphosting.rollouts = {};
|
|
174
|
-
client.apphosting.rollouts.create = loadCommand("apphosting-rollouts-create");
|
|
175
|
-
client.apphosting.rollouts.list = loadCommand("apphosting-rollouts-list");
|
|
176
170
|
}
|
|
177
171
|
client.login = loadCommand("login");
|
|
178
172
|
client.login.add = loadCommand("login-add");
|
|
@@ -27,9 +27,11 @@ async function default_1(context, options) {
|
|
|
27
27
|
const targets = options.only.split(",");
|
|
28
28
|
const excludeRules = targets.indexOf("firestore:indexes") >= 0;
|
|
29
29
|
const excludeIndexes = targets.indexOf("firestore:rules") >= 0;
|
|
30
|
+
const includeRules = targets.indexOf("firestore:rules") >= 0;
|
|
31
|
+
const includeIndexes = targets.indexOf("firestore:indexes") >= 0;
|
|
30
32
|
const onlyFirestore = targets.indexOf("firestore") >= 0;
|
|
31
|
-
context.firestoreIndexes = !excludeIndexes || onlyFirestore;
|
|
32
|
-
context.firestoreRules = !excludeRules || onlyFirestore;
|
|
33
|
+
context.firestoreIndexes = !excludeIndexes || includeIndexes || onlyFirestore;
|
|
34
|
+
context.firestoreRules = !excludeRules || includeRules || onlyFirestore;
|
|
33
35
|
}
|
|
34
36
|
else {
|
|
35
37
|
context.firestoreIndexes = true;
|
|
@@ -25,7 +25,7 @@ async function uploadSourceV1(projectId, source, wantBackend) {
|
|
|
25
25
|
stream: fs.createReadStream(source.functionsSourceV1),
|
|
26
26
|
};
|
|
27
27
|
if (process.env.GOOGLE_CLOUD_QUOTA_PROJECT) {
|
|
28
|
-
(0, utils_1.logLabeledWarning)("functions", "
|
|
28
|
+
(0, utils_1.logLabeledWarning)("functions", "GOOGLE_CLOUD_QUOTA_PROJECT is not usable when uploading source for Cloud Functions.");
|
|
29
29
|
}
|
|
30
30
|
await gcs.upload(uploadOpts, uploadUrl, {
|
|
31
31
|
"x-goog-content-length-range": "0,104857600",
|
|
@@ -44,7 +44,7 @@ async function uploadSourceV2(projectId, source, wantBackend) {
|
|
|
44
44
|
stream: fs.createReadStream(source.functionsSourceV2),
|
|
45
45
|
};
|
|
46
46
|
if (process.env.GOOGLE_CLOUD_QUOTA_PROJECT) {
|
|
47
|
-
(0, utils_1.logLabeledWarning)("functions", "
|
|
47
|
+
(0, utils_1.logLabeledWarning)("functions", "GOOGLE_CLOUD_QUOTA_PROJECT is not usable when uploading source for Cloud Functions.");
|
|
48
48
|
}
|
|
49
49
|
await gcs.upload(uploadOpts, res.uploadUrl, undefined, true);
|
|
50
50
|
return res.storageSource;
|
|
@@ -285,6 +285,7 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
|
|
|
285
285
|
projectId,
|
|
286
286
|
sourceDir,
|
|
287
287
|
projectDir: options.config.projectDir,
|
|
288
|
+
runtime: codebaseConfig.runtime,
|
|
288
289
|
};
|
|
289
290
|
const firebaseJsonRuntime = codebaseConfig.runtime;
|
|
290
291
|
if (firebaseJsonRuntime && !supported.isRuntime(firebaseJsonRuntime)) {
|
|
@@ -107,7 +107,7 @@ const MB_TO_GHZ = {
|
|
|
107
107
|
32768: 8 * VCPU_TO_GHZ,
|
|
108
108
|
};
|
|
109
109
|
function canCalculateMinInstanceCost(endpoint) {
|
|
110
|
-
if (
|
|
110
|
+
if (endpoint.minInstances === undefined || endpoint.minInstances === null) {
|
|
111
111
|
return true;
|
|
112
112
|
}
|
|
113
113
|
if (endpoint.platform === "gcfv1") {
|
|
@@ -132,7 +132,7 @@ function monthlyMinInstanceCost(endpoints) {
|
|
|
132
132
|
gcfv2: { 1: { ram: 0, cpu: 0 }, 2: { ram: 0, cpu: 0 } },
|
|
133
133
|
};
|
|
134
134
|
for (const endpoint of endpoints) {
|
|
135
|
-
if (
|
|
135
|
+
if (endpoint.minInstances === undefined || endpoint.minInstances === null) {
|
|
136
136
|
continue;
|
|
137
137
|
}
|
|
138
138
|
const ramMb = endpoint.availableMemoryMb || backend.DEFAULT_MEMORY;
|
package/lib/downloadUtils.js
CHANGED
|
@@ -13,6 +13,7 @@ async function downloadToTmp(remoteUrl) {
|
|
|
13
13
|
const tmpfile = tmp.fileSync();
|
|
14
14
|
const writeStream = fs.createWriteStream(tmpfile.name);
|
|
15
15
|
const res = await c.request({
|
|
16
|
+
ignoreQuotaProject: true,
|
|
16
17
|
method: "GET",
|
|
17
18
|
path: u.pathname,
|
|
18
19
|
queryParams: u.searchParams,
|
|
@@ -7,6 +7,7 @@ const sort = require("./api-sort");
|
|
|
7
7
|
const types = require("./api-types");
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const util = require("./util");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
10
11
|
class PrettyPrint {
|
|
11
12
|
prettyPrintIndexes(indexes) {
|
|
12
13
|
if (indexes.length === 0) {
|
|
@@ -163,6 +164,10 @@ class PrettyPrint {
|
|
|
163
164
|
prettyDatabaseString(database) {
|
|
164
165
|
return clc.yellow(typeof database === "string" ? database : database.name);
|
|
165
166
|
}
|
|
167
|
+
firebaseConsoleDatabaseUrl(project, databaseId) {
|
|
168
|
+
const urlFriendlyDatabaseId = databaseId === "(default)" ? "-default-" : databaseId;
|
|
169
|
+
return (0, utils_1.consoleUrl)(project, `/firestore/databases/${urlFriendlyDatabaseId}/data`);
|
|
170
|
+
}
|
|
166
171
|
prettyFieldString(field) {
|
|
167
172
|
let result = "";
|
|
168
173
|
const parsedName = util.parseFieldName(field.name);
|
|
@@ -10,7 +10,7 @@ const utils_2 = require("./utils");
|
|
|
10
10
|
exports.name = "Astro";
|
|
11
11
|
exports.support = "experimental";
|
|
12
12
|
exports.type = 2;
|
|
13
|
-
exports.supportedRange = "2 -
|
|
13
|
+
exports.supportedRange = "2 - 4";
|
|
14
14
|
async function discover(dir) {
|
|
15
15
|
if (!(0, fs_extra_1.existsSync)((0, path_1.join)(dir, "package.json")))
|
|
16
16
|
return;
|
package/package.json
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command = void 0;
|
|
4
|
-
const apphosting = require("../gcp/apphosting");
|
|
5
|
-
const logger_1 = require("../logger");
|
|
6
|
-
const command_1 = require("../command");
|
|
7
|
-
const projectUtils_1 = require("../projectUtils");
|
|
8
|
-
exports.command = new command_1.Command("apphosting:builds:create <backendId>")
|
|
9
|
-
.description("create a build for an App Hosting backend")
|
|
10
|
-
.option("-l, --location <location>", "specify the region of the backend", "us-central1")
|
|
11
|
-
.option("-i, --id <buildId>", "id of the build (defaults to autogenerating a random id)", "")
|
|
12
|
-
.option("-b, --branch <branch>", "repository branch to deploy (defaults to 'main')", "main")
|
|
13
|
-
.before(apphosting.ensureApiEnabled)
|
|
14
|
-
.action(async (backendId, options) => {
|
|
15
|
-
var _a;
|
|
16
|
-
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
17
|
-
const location = options.location;
|
|
18
|
-
const buildId = options.buildId ||
|
|
19
|
-
(await apphosting.getNextRolloutId(projectId, location, backendId));
|
|
20
|
-
const branch = (_a = options.branch) !== null && _a !== void 0 ? _a : "main";
|
|
21
|
-
const op = await apphosting.createBuild(projectId, location, backendId, buildId, {
|
|
22
|
-
source: {
|
|
23
|
-
codebase: {
|
|
24
|
-
branch,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
logger_1.logger.info(`Started a build for backend ${backendId} on branch ${branch}.`);
|
|
29
|
-
logger_1.logger.info("Check status by running:");
|
|
30
|
-
logger_1.logger.info(`\tfirebase apphosting:builds:get ${backendId} ${buildId} --location ${location}`);
|
|
31
|
-
return op;
|
|
32
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command = void 0;
|
|
4
|
-
const apphosting = require("../gcp/apphosting");
|
|
5
|
-
const logger_1 = require("../logger");
|
|
6
|
-
const command_1 = require("../command");
|
|
7
|
-
const projectUtils_1 = require("../projectUtils");
|
|
8
|
-
exports.command = new command_1.Command("apphosting:builds:get <backendId> <buildId>")
|
|
9
|
-
.description("get a build for an App Hosting backend")
|
|
10
|
-
.option("-l, --location <location>", "specify the region of the backend", "us-central1")
|
|
11
|
-
.before(apphosting.ensureApiEnabled)
|
|
12
|
-
.action(async (backendId, buildId, options) => {
|
|
13
|
-
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
|
-
const location = options.location;
|
|
15
|
-
const build = await apphosting.getBuild(projectId, location, backendId, buildId);
|
|
16
|
-
logger_1.logger.info(JSON.stringify(build, null, 2));
|
|
17
|
-
return build;
|
|
18
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command = void 0;
|
|
4
|
-
const apphosting = require("../gcp/apphosting");
|
|
5
|
-
const logger_1 = require("../logger");
|
|
6
|
-
const command_1 = require("../command");
|
|
7
|
-
const projectUtils_1 = require("../projectUtils");
|
|
8
|
-
exports.command = new command_1.Command("apphosting:rollouts:create <backendId> <buildId>")
|
|
9
|
-
.description("create a rollout using a build for an App Hosting backend")
|
|
10
|
-
.option("-l, --location <location>", "specify the region of the backend", "us-central1")
|
|
11
|
-
.option("-i, --id <rolloutId>", "id of the rollout (defaults to autogenerating a random id)", "")
|
|
12
|
-
.before(apphosting.ensureApiEnabled)
|
|
13
|
-
.action(async (backendId, buildId, options) => {
|
|
14
|
-
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
15
|
-
const location = options.location;
|
|
16
|
-
const rolloutId = options.buildId ||
|
|
17
|
-
(await apphosting.getNextRolloutId(projectId, location, backendId));
|
|
18
|
-
const build = `projects/${projectId}/backends/${backendId}/builds/${buildId}`;
|
|
19
|
-
const op = await apphosting.createRollout(projectId, location, backendId, rolloutId, {
|
|
20
|
-
build,
|
|
21
|
-
});
|
|
22
|
-
logger_1.logger.info(`Started a rollout for backend ${backendId} with build ${buildId}.`);
|
|
23
|
-
logger_1.logger.info("Check status by running:");
|
|
24
|
-
logger_1.logger.info(`\tfirebase apphosting:rollouts:list --location ${location}`);
|
|
25
|
-
return op;
|
|
26
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command = void 0;
|
|
4
|
-
const apphosting = require("../gcp/apphosting");
|
|
5
|
-
const logger_1 = require("../logger");
|
|
6
|
-
const command_1 = require("../command");
|
|
7
|
-
const projectUtils_1 = require("../projectUtils");
|
|
8
|
-
exports.command = new command_1.Command("apphosting:rollouts:list <backendId>")
|
|
9
|
-
.description("list rollouts of an App Hosting backend")
|
|
10
|
-
.option("-l, --location <location>", "region of the rollouts (defaults to listing rollouts from all regions)", "-")
|
|
11
|
-
.before(apphosting.ensureApiEnabled)
|
|
12
|
-
.action(async (backendId, options) => {
|
|
13
|
-
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
|
-
const location = options.location;
|
|
15
|
-
const rollouts = await apphosting.listRollouts(projectId, location, backendId);
|
|
16
|
-
if (rollouts.unreachable) {
|
|
17
|
-
logger_1.logger.error(`WARNING: the following locations were unreachable: ${rollouts.unreachable.join(", ")}`);
|
|
18
|
-
}
|
|
19
|
-
logger_1.logger.info(JSON.stringify(rollouts.rollouts, null, 2));
|
|
20
|
-
return rollouts;
|
|
21
|
-
});
|