firebase-tools 13.7.0 → 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.
@@ -58,14 +58,13 @@ async function linkGitHubRepository(projectId, location) {
58
58
  const oauthConn = await getOrCreateOauthConnection(projectId, location);
59
59
  const existingConns = await listAppHostingConnections(projectId);
60
60
  if (existingConns.length === 0) {
61
- utils.logBullet("no connections exist");
62
61
  existingConns.push(await createFullyInstalledConnection(projectId, location, generateConnectionId(), oauthConn));
63
62
  }
64
63
  let repoCloneUri;
65
64
  let connection;
66
65
  do {
67
66
  if (repoCloneUri === ADD_CONN_CHOICE) {
68
- existingConns.push(await createFullyInstalledConnection(projectId, location, generateConnectionId(), oauthConn));
67
+ existingConns.push(await createFullyInstalledConnection(projectId, location, generateConnectionId(), oauthConn, true));
69
68
  }
70
69
  const selection = await promptCloneUri(projectId, existingConns);
71
70
  repoCloneUri = selection.cloneUri;
@@ -82,10 +81,10 @@ async function linkGitHubRepository(projectId, location) {
82
81
  return repo;
83
82
  }
84
83
  exports.linkGitHubRepository = linkGitHubRepository;
85
- async function createFullyInstalledConnection(projectId, location, connectionId, oauthConn) {
84
+ async function createFullyInstalledConnection(projectId, location, connectionId, oauthConn, withNewInstallation = false) {
86
85
  var _a, _b;
87
86
  let conn = await createConnection(projectId, location, connectionId, {
88
- 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,
89
88
  authorizerCredential: (_b = oauthConn.githubConfig) === null || _b === void 0 ? void 0 : _b.authorizerCredential,
90
89
  });
91
90
  while (conn.installationState.stage !== "COMPLETE") {
@@ -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 backend = await createBackend(projectId, location, backendId, gitRepositoryConnection, serviceAccount);
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
  });
@@ -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", "GOOGLE_CLOUD_QUTOA_PROJECT is not usable when uploading source for Cloud 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", "GOOGLE_CLOUD_QUTOA_PROJECT is not usable when uploading source for Cloud 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 (!endpoint.minInstances) {
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 (!endpoint.minInstances) {
135
+ if (endpoint.minInstances === undefined || endpoint.minInstances === null) {
136
136
  continue;
137
137
  }
138
138
  const ramMb = endpoint.availableMemoryMb || backend.DEFAULT_MEMORY;
@@ -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,
@@ -309,11 +309,8 @@ async function startAll(options, showUI = true, runningTestScript = false) {
309
309
  utils.assertIsStringOrUndefined(options.extDevDir);
310
310
  for (const cfg of functionsCfg) {
311
311
  const functionsDir = path.join(projectDir, cfg.source);
312
- let runtime = ((_e = options.extDevRuntime) !== null && _e !== void 0 ? _e : cfg.runtime);
313
- if (!runtime) {
314
- runtime = (0, supported_1.latest)("nodejs");
315
- }
316
- if (!(0, supported_1.isRuntime)(runtime)) {
312
+ const runtime = ((_e = options.extDevRuntime) !== null && _e !== void 0 ? _e : cfg.runtime);
313
+ if (runtime && !(0, supported_1.isRuntime)(runtime)) {
317
314
  throw new error_1.FirebaseError(`Cannot load functions from ${functionsDir} because it has invalid runtime ${runtime}`);
318
315
  }
319
316
  emulatableBackends.push({
@@ -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 - 3";
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,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "13.7.0",
3
+ "version": "13.7.2",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
@@ -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
- });