firebase-tools 10.7.1 → 10.9.0

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.
Files changed (63) hide show
  1. package/lib/commands/ext-configure.js +26 -15
  2. package/lib/commands/ext-export.js +14 -5
  3. package/lib/commands/ext-install.js +31 -2
  4. package/lib/commands/ext-update.js +17 -10
  5. package/lib/commands/functions-list.js +12 -20
  6. package/lib/commands/functions-secrets-set.js +1 -13
  7. package/lib/deploy/extensions/planner.js +12 -0
  8. package/lib/deploy/extensions/tasks.js +13 -0
  9. package/lib/deploy/functions/backend.js +47 -14
  10. package/lib/deploy/functions/build.js +28 -9
  11. package/lib/deploy/functions/checkIam.js +65 -53
  12. package/lib/deploy/functions/containerCleaner.js +8 -7
  13. package/lib/deploy/functions/functionsDeployHelper.js +1 -1
  14. package/lib/deploy/functions/prepare.js +42 -15
  15. package/lib/deploy/functions/pricing.js +2 -2
  16. package/lib/deploy/functions/release/executor.js +1 -1
  17. package/lib/deploy/functions/release/fabricator.js +66 -11
  18. package/lib/deploy/functions/release/index.js +0 -21
  19. package/lib/deploy/functions/runtimes/discovery/index.js +2 -1
  20. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +13 -1
  21. package/lib/deploy/functions/runtimes/golang/index.js +3 -0
  22. package/lib/deploy/functions/runtimes/node/index.js +23 -20
  23. package/lib/deploy/functions/runtimes/node/parseTriggers.js +108 -1
  24. package/lib/deploy/functions/services/storage.js +6 -12
  25. package/lib/deploy/functions/validate.js +80 -16
  26. package/lib/deploy/index.js +2 -1
  27. package/lib/emulator/auth/cloudFunctions.js +6 -2
  28. package/lib/emulator/auth/operations.js +0 -1
  29. package/lib/emulator/auth/server.js +8 -1
  30. package/lib/emulator/auth/state.js +27 -24
  31. package/lib/emulator/controller.js +10 -5
  32. package/lib/emulator/databaseEmulator.js +36 -3
  33. package/lib/emulator/downloadableEmulators.js +18 -34
  34. package/lib/emulator/extensionsEmulator.js +4 -1
  35. package/lib/emulator/functionsEmulator.js +6 -7
  36. package/lib/emulator/functionsEmulatorRuntime.js +1 -1
  37. package/lib/emulator/functionsEmulatorShared.js +3 -0
  38. package/lib/emulator/functionsEmulatorUtils.js +5 -1
  39. package/lib/emulator/storage/apis/firebase.js +26 -4
  40. package/lib/extensions/askUserForEventsConfig.js +97 -0
  41. package/lib/extensions/export.js +7 -0
  42. package/lib/extensions/extensionsApi.js +47 -7
  43. package/lib/extensions/manifest.js +1 -1
  44. package/lib/extensions/paramHelper.js +2 -0
  45. package/lib/extensions/updateHelper.js +7 -1
  46. package/lib/extensions/warnings.js +11 -4
  47. package/lib/frameworks/index.js +111 -0
  48. package/lib/functions/functionslog.js +4 -9
  49. package/lib/gcp/cloudfunctions.js +1 -1
  50. package/lib/gcp/cloudfunctionsv2.js +14 -9
  51. package/lib/gcp/serviceusage.js +24 -0
  52. package/lib/hosting/normalizedHostingConfigs.js +3 -0
  53. package/lib/previews.js +1 -1
  54. package/lib/serve/index.js +2 -1
  55. package/lib/throttler/throttler.js +2 -1
  56. package/npm-shrinkwrap.json +315 -534
  57. package/package.json +4 -4
  58. package/templates/extensions/javascript/package.lint.json +5 -5
  59. package/templates/extensions/javascript/package.nolint.json +3 -3
  60. package/templates/extensions/typescript/package.lint.json +8 -7
  61. package/templates/extensions/typescript/package.nolint.json +2 -1
  62. package/templates/init/functions/typescript/package.lint.json +1 -0
  63. package/templates/init/functions/typescript/package.nolint.json +5 -5
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.endpointFromFunction = exports.functionFromEndpoint = exports.deleteFunction = exports.updateFunction = exports.listAllFunctions = exports.listFunctions = exports.getFunction = exports.createFunction = exports.generateUploadUrl = exports.megabytes = exports.BLOCKING_LABEL = exports.CODEBASE_LABEL = exports.API_VERSION = void 0;
3
+ exports.endpointFromFunction = exports.functionFromEndpoint = exports.deleteFunction = exports.updateFunction = exports.listAllFunctions = exports.listFunctions = exports.getFunction = exports.createFunction = exports.generateUploadUrl = exports.mebibytes = exports.BLOCKING_LABEL = exports.CODEBASE_LABEL = exports.API_VERSION = void 0;
4
4
  const clc = require("cli-color");
5
5
  const apiv2_1 = require("../apiv2");
6
6
  const error_1 = require("../error");
@@ -39,7 +39,7 @@ const BYTES_PER_UNIT = {
39
39
  Gi: 1 << 30,
40
40
  Ti: 1 << 40,
41
41
  };
42
- function megabytes(memory) {
42
+ function mebibytes(memory) {
43
43
  const re = /^([0-9]+(\.[0-9]*)?)(Ki|Mi|Gi|Ti|k|M|G|T|([eE]([0-9]+)))?$/;
44
44
  const matches = re.exec(memory);
45
45
  if (!matches) {
@@ -54,14 +54,18 @@ function megabytes(memory) {
54
54
  const suffix = matches[3] || "";
55
55
  bytes = quantity * BYTES_PER_UNIT[suffix];
56
56
  }
57
- return bytes / 1e6;
57
+ return bytes / (1 << 20);
58
58
  }
59
- exports.megabytes = megabytes;
59
+ exports.mebibytes = mebibytes;
60
60
  function functionsOpLogReject(funcName, type, err) {
61
61
  var _a, _b;
62
+ utils.logWarning(clc.bold.yellow("functions:") + ` ${err === null || err === void 0 ? void 0 : err.message}`);
62
63
  if (((_b = (_a = err === null || err === void 0 ? void 0 : err.context) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.statusCode) === 429) {
63
64
  utils.logWarning(`${clc.bold.yellow("functions:")} got "Quota Exceeded" error while trying to ${type} ${funcName}. Waiting to retry...`);
64
65
  }
66
+ else if (err === null || err === void 0 ? void 0 : err.message.includes("If you recently started to use Eventarc, it may take a few minutes before all necessary permissions are propagated to the Service Agent")) {
67
+ utils.logWarning(`${clc.bold.yellow("functions:")} since this is your first time using functions v2, we need a little bit longer to finish setting everything up, please retry the deployment in a few minutes.`);
68
+ }
65
69
  else {
66
70
  utils.logWarning(clc.bold.yellow("functions:") + " failed to " + type + " function " + funcName);
67
71
  }
@@ -133,7 +137,7 @@ async function listFunctionsInternal(projectId, region) {
133
137
  }
134
138
  }
135
139
  async function updateFunction(cloudFunction) {
136
- const fieldMasks = proto.fieldMasks(cloudFunction, "labels", "serviceConfig.environmentVariables");
140
+ const fieldMasks = proto.fieldMasks(cloudFunction, "labels", "serviceConfig.environmentVariables", "serviceConfig.secretEnvironmentVariables");
137
141
  try {
138
142
  const queryParams = {
139
143
  updateMask: fieldMasks.join(","),
@@ -178,8 +182,9 @@ function functionFromEndpoint(endpoint, source) {
178
182
  serviceConfig: {},
179
183
  };
180
184
  proto.copyIfPresent(gcfFunction, endpoint, "labels");
181
- proto.copyIfPresent(gcfFunction.serviceConfig, endpoint, "environmentVariables", "serviceAccountEmail", "ingressSettings", "timeoutSeconds");
182
- proto.renameIfPresent(gcfFunction.serviceConfig, endpoint, "availableMemory", "availableMemoryMb", (mb) => `${mb}M`);
185
+ proto.copyIfPresent(gcfFunction.serviceConfig, endpoint, "environmentVariables", "secretEnvironmentVariables", "serviceAccountEmail", "ingressSettings", "timeoutSeconds");
186
+ const mem = endpoint.availableMemoryMb || backend.DEFAULT_MEMORY;
187
+ gcfFunction.serviceConfig.availableMemory = mem > 1024 ? `${mem / 1024}Gi` : `${mem}Mi`;
183
188
  proto.renameIfPresent(gcfFunction.serviceConfig, endpoint, "minInstanceCount", "minInstances");
184
189
  proto.renameIfPresent(gcfFunction.serviceConfig, endpoint, "maxInstanceCount", "maxInstances");
185
190
  if (endpoint.vpc) {
@@ -288,8 +293,8 @@ function endpointFromFunction(gcfFunction) {
288
293
  const endpoint = Object.assign(Object.assign({ platform: "gcfv2", id,
289
294
  project,
290
295
  region }, trigger), { entryPoint: gcfFunction.buildConfig.entryPoint, runtime: gcfFunction.buildConfig.runtime, uri: gcfFunction.serviceConfig.uri });
291
- proto.copyIfPresent(endpoint, gcfFunction.serviceConfig, "serviceAccountEmail", "ingressSettings", "environmentVariables", "timeoutSeconds");
292
- proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "availableMemoryMb", "availableMemory", megabytes);
296
+ proto.copyIfPresent(endpoint, gcfFunction.serviceConfig, "serviceAccountEmail", "ingressSettings", "environmentVariables", "secretEnvironmentVariables", "timeoutSeconds");
297
+ proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "availableMemoryMb", "availableMemory", mebibytes);
293
298
  proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "minInstances", "minInstanceCount");
294
299
  proto.renameIfPresent(endpoint, gcfFunction.serviceConfig, "maxInstances", "maxInstanceCount");
295
300
  proto.copyIfPresent(endpoint, gcfFunction, "labels");
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateServiceIdentity = void 0;
4
+ const cli_color_1 = require("cli-color");
5
+ const api_1 = require("../api");
6
+ const apiv2_1 = require("../apiv2");
7
+ const error_1 = require("../error");
8
+ const utils = require("../utils");
9
+ const apiClient = new apiv2_1.Client({
10
+ urlPrefix: api_1.serviceUsageOrigin,
11
+ apiVersion: "v1beta1",
12
+ });
13
+ async function generateServiceIdentity(projectNumber, service, prefix) {
14
+ utils.logLabeledBullet(prefix, `generating the service identity for ${(0, cli_color_1.bold)(service)}...`);
15
+ try {
16
+ return await apiClient.post(`projects/${projectNumber}/services/${service}:generateServiceIdentity`);
17
+ }
18
+ catch (err) {
19
+ throw new error_1.FirebaseError(`Error generating the service identity for ${service}.`, {
20
+ original: err,
21
+ });
22
+ }
23
+ }
24
+ exports.generateServiceIdentity = generateServiceIdentity;
@@ -57,6 +57,9 @@ function filterExcept(configs, exceptOption) {
57
57
  return filteredConfigs;
58
58
  }
59
59
  function normalizedHostingConfigs(cmdOptions, options = {}) {
60
+ const normalizedHostingConfigs = cmdOptions.normalizedHostingConfigs;
61
+ if (normalizedHostingConfigs)
62
+ return normalizedHostingConfigs;
60
63
  let configs = (0, lodash_1.cloneDeep)(cmdOptions.config.get("hosting"));
61
64
  if (!configs) {
62
65
  return [];
package/lib/previews.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.previews = void 0;
4
4
  const lodash_1 = require("lodash");
5
5
  const configstore_1 = require("./configstore");
6
- exports.previews = Object.assign({ rtdbrules: false, ext: false, extdev: false, extensionsemulator: false, rtdbmanagement: false, functionsv2: false, golang: false, deletegcfartifacts: false, artifactregistry: false, emulatoruisnapshot: false, frameworkawareness: false }, configstore_1.configstore.get("previews"));
6
+ exports.previews = Object.assign({ rtdbrules: false, ext: false, extdev: false, rtdbmanagement: false, golang: false, deletegcfartifacts: false, artifactregistry: false, emulatoruisnapshot: false, frameworkawareness: false, functionsparams: false }, configstore_1.configstore.get("previews"));
7
7
  if (process.env.FIREBASE_CLI_PREVIEWS) {
8
8
  process.env.FIREBASE_CLI_PREVIEWS.split(",").forEach((feature) => {
9
9
  if ((0, lodash_1.has)(exports.previews, feature)) {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serve = void 0;
4
4
  const _ = require("lodash");
5
5
  const logger_1 = require("../logger");
6
+ const frameworks_1 = require("../frameworks");
6
7
  const previews_1 = require("../previews");
7
8
  const { FunctionsServer } = require("./functions");
8
9
  const TARGETS = {
@@ -15,7 +16,7 @@ async function serve(options) {
15
16
  if (previews_1.previews.frameworkawareness &&
16
17
  targetNames.includes("hosting") &&
17
18
  [].concat(options.config.get("hosting")).some((it) => it.source)) {
18
- await require("firebase-frameworks").prepare(targetNames, { project: options.projectId }, options);
19
+ await (0, frameworks_1.prepareFrameworks)(targetNames, options, options);
19
20
  }
20
21
  await Promise.all(_.map(targetNames, (targetName) => {
21
22
  return TARGETS[targetName].start(options);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Throttler = exports.timeToWait = void 0;
3
+ exports.Throttler = exports.timeToWait = exports.backoff = void 0;
4
4
  const logger_1 = require("../logger");
5
5
  const retries_exhausted_error_1 = require("./errors/retries-exhausted-error");
6
6
  const timeout_error_1 = require("./errors/timeout-error");
@@ -9,6 +9,7 @@ function backoff(retryNumber, delay, maxDelay) {
9
9
  setTimeout(resolve, timeToWait(retryNumber, delay, maxDelay));
10
10
  });
11
11
  }
12
+ exports.backoff = backoff;
12
13
  function timeToWait(retryNumber, delay, maxDelay) {
13
14
  return Math.min(delay * Math.pow(2, retryNumber), maxDelay);
14
15
  }