firebase-tools 11.0.0 → 11.2.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 (223) hide show
  1. package/lib/accountExporter.js +11 -4
  2. package/lib/accountImporter.js +93 -95
  3. package/lib/api.js +77 -218
  4. package/lib/apiv2.js +5 -4
  5. package/lib/appdistribution/client.js +23 -34
  6. package/lib/auth.js +72 -52
  7. package/lib/bin/firebase.js +42 -47
  8. package/lib/checkValidTargetFilters.js +36 -25
  9. package/lib/commands/appdistribution-distribute.js +2 -1
  10. package/lib/commands/appdistribution-testers-add.js +2 -1
  11. package/lib/commands/appdistribution-testers-remove.js +2 -1
  12. package/lib/commands/apps-android-sha-create.js +2 -1
  13. package/lib/commands/apps-android-sha-delete.js +2 -1
  14. package/lib/commands/apps-android-sha-list.js +2 -1
  15. package/lib/commands/apps-create.js +2 -1
  16. package/lib/commands/apps-list.js +2 -1
  17. package/lib/commands/apps-sdkconfig.js +2 -1
  18. package/lib/commands/auth-export.js +2 -1
  19. package/lib/commands/auth-import.js +7 -10
  20. package/lib/commands/crashlytics-symbols-upload.js +2 -1
  21. package/lib/commands/database-get.js +4 -3
  22. package/lib/commands/database-instances-create.js +2 -1
  23. package/lib/commands/database-instances-list.js +3 -3
  24. package/lib/commands/database-profile.js +4 -4
  25. package/lib/commands/database-push.js +4 -4
  26. package/lib/commands/database-remove.js +3 -3
  27. package/lib/commands/database-rules-canary.js +2 -1
  28. package/lib/commands/database-rules-get.js +2 -1
  29. package/lib/commands/database-rules-list.js +2 -1
  30. package/lib/commands/database-rules-release.js +2 -1
  31. package/lib/commands/database-rules-stage.js +2 -1
  32. package/lib/commands/database-set.js +3 -3
  33. package/lib/commands/database-settings-get.js +2 -1
  34. package/lib/commands/database-settings-set.js +2 -1
  35. package/lib/commands/database-update.js +2 -1
  36. package/lib/commands/deploy.js +26 -25
  37. package/lib/commands/emulators-exec.js +2 -1
  38. package/lib/commands/emulators-export.js +2 -1
  39. package/lib/commands/emulators-start.js +2 -1
  40. package/lib/commands/experimental-functions-shell.js +10 -8
  41. package/lib/commands/ext-configure.js +6 -1
  42. package/lib/commands/ext-dev-deprecate.js +2 -1
  43. package/lib/commands/ext-dev-emulators-exec.js +3 -2
  44. package/lib/commands/ext-dev-emulators-start.js +3 -2
  45. package/lib/commands/ext-dev-extension-delete.js +2 -1
  46. package/lib/commands/ext-dev-init.js +2 -1
  47. package/lib/commands/ext-dev-list.js +8 -8
  48. package/lib/commands/ext-dev-publish.js +2 -1
  49. package/lib/commands/ext-dev-register.js +2 -1
  50. package/lib/commands/ext-dev-undeprecate.js +2 -1
  51. package/lib/commands/ext-dev-unpublish.js +2 -1
  52. package/lib/commands/ext-dev-usage.js +2 -1
  53. package/lib/commands/ext-export.js +2 -1
  54. package/lib/commands/ext-info.js +14 -14
  55. package/lib/commands/ext-install.js +6 -1
  56. package/lib/commands/ext-list.js +2 -1
  57. package/lib/commands/ext-sources-create.js +2 -1
  58. package/lib/commands/ext-uninstall.js +7 -1
  59. package/lib/commands/ext-update.js +6 -1
  60. package/lib/commands/ext.js +4 -4
  61. package/lib/commands/firestore-delete.js +2 -1
  62. package/lib/commands/firestore-indexes-list.js +2 -1
  63. package/lib/commands/functions-config-clone.js +4 -3
  64. package/lib/commands/functions-config-export.js +2 -1
  65. package/lib/commands/functions-config-get.js +2 -1
  66. package/lib/commands/functions-config-set.js +2 -1
  67. package/lib/commands/functions-config-unset.js +2 -1
  68. package/lib/commands/functions-delete.js +3 -8
  69. package/lib/commands/functions-deletegcfartifacts.js +2 -1
  70. package/lib/commands/functions-list.js +2 -1
  71. package/lib/commands/functions-log.js +2 -1
  72. package/lib/commands/functions-secrets-access.js +2 -1
  73. package/lib/commands/functions-secrets-destroy.js +2 -1
  74. package/lib/commands/functions-secrets-get.js +2 -1
  75. package/lib/commands/functions-secrets-prune.js +2 -1
  76. package/lib/commands/functions-secrets-set.js +2 -1
  77. package/lib/commands/functions-shell.js +12 -10
  78. package/lib/commands/help.js +2 -1
  79. package/lib/commands/hosting-channel-create.js +2 -1
  80. package/lib/commands/hosting-channel-delete.js +2 -1
  81. package/lib/commands/hosting-channel-deploy.js +2 -1
  82. package/lib/commands/hosting-channel-list.js +2 -1
  83. package/lib/commands/hosting-channel-open.js +2 -1
  84. package/lib/commands/hosting-clone.js +2 -1
  85. package/lib/commands/hosting-disable.js +2 -1
  86. package/lib/commands/hosting-sites-create.js +2 -1
  87. package/lib/commands/hosting-sites-delete.js +2 -1
  88. package/lib/commands/hosting-sites-get.js +2 -1
  89. package/lib/commands/hosting-sites-list.js +2 -1
  90. package/lib/commands/index.js +23 -13
  91. package/lib/commands/init.js +47 -43
  92. package/lib/commands/login-add.js +2 -1
  93. package/lib/commands/login-ci.js +2 -1
  94. package/lib/commands/login-list.js +2 -1
  95. package/lib/commands/login-use.js +2 -1
  96. package/lib/commands/login.js +2 -1
  97. package/lib/commands/logout.js +2 -1
  98. package/lib/commands/open.js +7 -7
  99. package/lib/commands/projects-addfirebase.js +2 -1
  100. package/lib/commands/projects-create.js +2 -1
  101. package/lib/commands/projects-list.js +2 -1
  102. package/lib/commands/remoteconfig-get.js +2 -1
  103. package/lib/commands/remoteconfig-rollback.js +2 -1
  104. package/lib/commands/remoteconfig-versions-list.js +2 -1
  105. package/lib/commands/serve.js +30 -30
  106. package/lib/commands/setup-emulators-database.js +2 -1
  107. package/lib/commands/setup-emulators-firestore.js +2 -1
  108. package/lib/commands/setup-emulators-pubsub.js +2 -1
  109. package/lib/commands/setup-emulators-storage.js +2 -1
  110. package/lib/commands/setup-emulators-ui.js +2 -1
  111. package/lib/commands/target-apply.js +2 -1
  112. package/lib/commands/target-clear.js +2 -1
  113. package/lib/commands/target-remove.js +2 -1
  114. package/lib/commands/target.js +2 -1
  115. package/lib/commands/use.js +54 -53
  116. package/lib/config.js +7 -6
  117. package/lib/deploy/database/deploy.js +3 -2
  118. package/lib/deploy/database/index.js +8 -5
  119. package/lib/deploy/database/prepare.js +22 -20
  120. package/lib/deploy/database/release.js +12 -9
  121. package/lib/deploy/extensions/secrets.js +3 -3
  122. package/lib/deploy/firestore/prepare.js +2 -2
  123. package/lib/deploy/functions/build.js +33 -20
  124. package/lib/deploy/functions/ensure.js +1 -11
  125. package/lib/deploy/functions/prepare.js +3 -13
  126. package/lib/deploy/functions/prepareFunctionsUpload.js +2 -3
  127. package/lib/deploy/functions/release/fabricator.js +0 -1
  128. package/lib/deploy/functions/release/index.js +1 -5
  129. package/lib/deploy/functions/runtimes/discovery/index.js +18 -3
  130. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +188 -54
  131. package/lib/deploy/functions/runtimes/golang/index.js +2 -22
  132. package/lib/deploy/functions/runtimes/node/index.js +3 -7
  133. package/lib/deploy/functions/runtimes/node/parseTriggers.js +15 -3
  134. package/lib/deploy/functions/services/database.js +14 -0
  135. package/lib/deploy/functions/services/index.js +14 -0
  136. package/lib/deploy/index.js +3 -3
  137. package/lib/deploy/lifecycleHooks.js +27 -27
  138. package/lib/deploy/remoteconfig/functions.js +18 -14
  139. package/lib/deploy/remoteconfig/prepare.js +2 -2
  140. package/lib/deploy/storage/prepare.js +1 -1
  141. package/lib/emulator/auth/apiSpec.js +14 -46
  142. package/lib/emulator/auth/index.js +1 -1
  143. package/lib/emulator/auth/operations.js +342 -93
  144. package/lib/emulator/auth/server.js +2 -2
  145. package/lib/emulator/auth/state.js +34 -32
  146. package/lib/emulator/commandUtils.js +1 -1
  147. package/lib/emulator/constants.js +1 -1
  148. package/lib/emulator/controller.js +7 -6
  149. package/lib/emulator/databaseEmulator.js +11 -9
  150. package/lib/emulator/download.js +1 -1
  151. package/lib/emulator/events/types.js +2 -3
  152. package/lib/emulator/firestoreEmulator.js +12 -14
  153. package/lib/emulator/functionsEmulator.js +65 -77
  154. package/lib/emulator/functionsEmulatorRuntime.js +7 -7
  155. package/lib/emulator/hostingEmulator.js +1 -1
  156. package/lib/emulator/hub.js +1 -1
  157. package/lib/emulator/hubClient.js +11 -22
  158. package/lib/emulator/hubExport.js +26 -16
  159. package/lib/emulator/loggingEmulator.js +1 -1
  160. package/lib/emulator/pubsubEmulator.js +1 -1
  161. package/lib/emulator/storage/crc.js +4 -4
  162. package/lib/emulator/storage/index.js +1 -1
  163. package/lib/emulator/types.js +1 -1
  164. package/lib/errorOut.js +2 -2
  165. package/lib/extensions/askUserForConsent.js +1 -2
  166. package/lib/extensions/askUserForParam.js +15 -18
  167. package/lib/extensions/emulator/optionsHelper.js +4 -4
  168. package/lib/extensions/extensionsApi.js +1 -22
  169. package/lib/extensions/extensionsHelper.js +6 -6
  170. package/lib/extensions/listExtensions.js +9 -10
  171. package/lib/extensions/manifest.js +2 -2
  172. package/lib/extensions/resolveSource.js +11 -7
  173. package/lib/extensions/secretsUtils.js +3 -3
  174. package/lib/extensions/types.js +24 -0
  175. package/lib/extensions/updateHelper.js +1 -1
  176. package/lib/extensions/utils.js +1 -2
  177. package/lib/extensions/warnings.js +3 -3
  178. package/lib/firestore/checkDatabaseType.js +4 -5
  179. package/lib/firestore/encodeFirestoreValue.js +11 -8
  180. package/lib/firestore/indexes.js +17 -34
  181. package/lib/fsAsync.js +3 -3
  182. package/lib/functions/events/v2.js +7 -1
  183. package/lib/functionsConfig.js +17 -14
  184. package/lib/functionsConfigClone.js +46 -46
  185. package/lib/gcp/cloudfunctions.js +2 -15
  186. package/lib/gcp/cloudfunctionsv2.js +17 -2
  187. package/lib/gcp/iam.js +1 -1
  188. package/lib/gcp/index.js +10 -10
  189. package/lib/gcp/rules.js +1 -1
  190. package/lib/gcp/runtimeconfig.js +45 -47
  191. package/lib/gcp/storage.js +2 -4
  192. package/lib/hosting/cloudRunProxy.js +19 -15
  193. package/lib/hosting/proxy.js +1 -1
  194. package/lib/index.js +29 -28
  195. package/lib/init/features/database.js +11 -5
  196. package/lib/init/features/functions/index.js +1 -1
  197. package/lib/init/features/functions/javascript.js +23 -20
  198. package/lib/init/features/functions/npm-dependencies.js +17 -14
  199. package/lib/init/features/functions/typescript.js +27 -24
  200. package/lib/init/features/hosting/github.js +6 -5
  201. package/lib/init/features/hosting/index.js +2 -2
  202. package/lib/loadCJSON.js +9 -6
  203. package/lib/localFunction.js +4 -4
  204. package/lib/logError.js +15 -12
  205. package/lib/management/apps.js +47 -43
  206. package/lib/management/database.js +33 -31
  207. package/lib/management/projects.js +13 -7
  208. package/lib/parseBoltRules.js +15 -14
  209. package/lib/previews.js +1 -1
  210. package/lib/profileReport.js +504 -512
  211. package/lib/profiler.js +4 -4
  212. package/lib/prompt.js +1 -2
  213. package/lib/rc.js +1 -1
  214. package/lib/requireAuth.js +0 -1
  215. package/lib/responseToError.js +8 -5
  216. package/lib/rtdb.js +31 -29
  217. package/lib/rulesDeploy.js +2 -2
  218. package/lib/scopes.js +9 -9
  219. package/lib/serve/index.js +4 -5
  220. package/lib/utils.js +30 -6
  221. package/npm-shrinkwrap.json +877 -279
  222. package/package.json +19 -16
  223. package/standalone/package.json +1 -1
package/lib/config.js CHANGED
@@ -14,10 +14,11 @@ const projectPath_1 = require("./projectPath");
14
14
  const utils = require("./utils");
15
15
  const firebaseConfigValidate_1 = require("./firebaseConfigValidate");
16
16
  const logger_1 = require("./logger");
17
- const loadCJSON = require("./loadCJSON");
17
+ const loadCJSON_1 = require("./loadCJSON");
18
18
  const parseBoltRules = require("./parseBoltRules");
19
19
  class Config {
20
20
  constructor(src, options = {}) {
21
+ var _a;
21
22
  this.data = {};
22
23
  this.defaults = {};
23
24
  this.notes = {};
@@ -31,8 +32,8 @@ class Config {
31
32
  clc.bold("firebase use --add") +
32
33
  " instead");
33
34
  }
34
- if (_.has(this._src, "rules")) {
35
- _.set(this._src, "database.rules", this._src.rules);
35
+ if ((_a = this._src) === null || _a === void 0 ? void 0 : _a.rules) {
36
+ this._src.database = Object.assign(Object.assign({}, this._src.database), { rules: this._src.rules });
36
37
  }
37
38
  Config.MATERIALIZE_TARGETS.forEach((target) => {
38
39
  if (_.get(this._src, target)) {
@@ -58,7 +59,7 @@ class Config {
58
59
  let out = this.parseFile(target, val);
59
60
  const segments = target.split(".");
60
61
  const lastSegment = segments[segments.length - 1];
61
- if (Object.keys(out).length === 1 && _.has(out, lastSegment)) {
62
+ if (Object.keys(out).length === 1 && out[lastSegment]) {
62
63
  out = out[lastSegment];
63
64
  }
64
65
  return out;
@@ -95,7 +96,7 @@ class Config {
95
96
  throw e;
96
97
  }
97
98
  }
98
- return loadCJSON(fullPath);
99
+ return (0, loadCJSON_1.loadCJSON)(fullPath);
99
100
  case ".bolt":
100
101
  if (target === "database") {
101
102
  this.notes.databaseRules = "bolt";
@@ -125,7 +126,7 @@ class Config {
125
126
  }
126
127
  return outPath;
127
128
  }
128
- readProjectFile(p, options) {
129
+ readProjectFile(p, options = {}) {
129
130
  options = options || {};
130
131
  try {
131
132
  const content = fs.readFileSync(this.path(p), "utf8");
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- async function default_1() { }
4
- exports.default = default_1;
3
+ exports.deploy = void 0;
4
+ async function deploy() { }
5
+ exports.deploy = deploy;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
- module.exports = {
3
- prepare: require("./prepare"),
4
- release: require("./release"),
5
- deploy: require("./deploy").default,
6
- };
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.release = exports.deploy = exports.prepare = void 0;
4
+ var prepare_1 = require("./prepare");
5
+ Object.defineProperty(exports, "prepare", { enumerable: true, get: function () { return prepare_1.prepare; } });
6
+ var deploy_1 = require("./deploy");
7
+ Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.deploy; } });
8
+ var release_1 = require("./release");
9
+ Object.defineProperty(exports, "release", { enumerable: true, get: function () { return release_1.release; } });
@@ -1,52 +1,54 @@
1
1
  "use strict";
2
- var _ = require("lodash");
3
- var clc = require("cli-color");
4
- var path = require("path");
5
- var { FirebaseError } = require("../../error");
6
- var parseBoltRules = require("../../parseBoltRules");
7
- var rtdb = require("../../rtdb");
8
- var utils = require("../../utils");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepare = void 0;
4
+ const clc = require("cli-color");
5
+ const path = require("path");
6
+ const error_1 = require("../../error");
7
+ const parseBoltRules_1 = require("../../parseBoltRules");
8
+ const rtdb = require("../../rtdb");
9
+ const utils = require("../../utils");
9
10
  const dbRulesConfig = require("../../database/rulesConfig");
10
- module.exports = function (context, options) {
11
- var rulesConfig = dbRulesConfig.getRulesConfig(context.projectId, options);
12
- var next = Promise.resolve();
11
+ function prepare(context, options) {
12
+ const rulesConfig = dbRulesConfig.getRulesConfig(context.projectId, options);
13
+ const next = Promise.resolve();
13
14
  if (!rulesConfig || rulesConfig.length === 0) {
14
15
  return next;
15
16
  }
16
- var ruleFiles = {};
17
- var deploys = [];
18
- rulesConfig.forEach(function (ruleConfig) {
17
+ const ruleFiles = {};
18
+ const deploys = [];
19
+ rulesConfig.forEach((ruleConfig) => {
19
20
  if (!ruleConfig.rules) {
20
21
  return;
21
22
  }
22
23
  ruleFiles[ruleConfig.rules] = null;
23
24
  deploys.push(ruleConfig);
24
25
  });
25
- _.forEach(ruleFiles, function (v, file) {
26
+ for (const file of Object.keys(ruleFiles)) {
26
27
  switch (path.extname(file)) {
27
28
  case ".json":
28
29
  ruleFiles[file] = options.config.readProjectFile(file);
29
30
  break;
30
31
  case ".bolt":
31
- ruleFiles[file] = parseBoltRules(file);
32
+ ruleFiles[file] = (0, parseBoltRules_1.parseBoltRules)(file);
32
33
  break;
33
34
  default:
34
- throw new FirebaseError("Unexpected rules format " + path.extname(file));
35
+ throw new error_1.FirebaseError("Unexpected rules format " + path.extname(file));
35
36
  }
36
- });
37
+ }
37
38
  context.database = {
38
39
  deploys: deploys,
39
40
  ruleFiles: ruleFiles,
40
41
  };
41
42
  utils.logBullet(clc.bold.cyan("database: ") + "checking rules syntax...");
42
- return Promise.all(deploys.map(function (deploy) {
43
+ return Promise.all(deploys.map((deploy) => {
43
44
  return rtdb
44
45
  .updateRules(context.projectId, deploy.instance, ruleFiles[deploy.rules], { dryRun: true })
45
- .then(function () {
46
+ .then(() => {
46
47
  utils.logSuccess(clc.bold.green("database: ") +
47
48
  "rules syntax for database " +
48
49
  clc.bold(deploy.instance) +
49
50
  " is valid");
50
51
  });
51
52
  }));
52
- };
53
+ }
54
+ exports.prepare = prepare;
@@ -1,27 +1,30 @@
1
1
  "use strict";
2
- var clc = require("cli-color");
3
- var rtdb = require("../../rtdb");
4
- var utils = require("../../utils");
5
- module.exports = function (context) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.release = void 0;
4
+ const clc = require("cli-color");
5
+ const rtdb = require("../../rtdb");
6
+ const utils = require("../../utils");
7
+ function release(context) {
6
8
  if (!context.projectId ||
7
9
  !context.database ||
8
10
  !context.database.deploys ||
9
11
  !context.database.ruleFiles) {
10
12
  return Promise.resolve();
11
13
  }
12
- var deploys = context.database.deploys;
13
- var ruleFiles = context.database.ruleFiles;
14
+ const deploys = context.database.deploys;
15
+ const ruleFiles = context.database.ruleFiles;
14
16
  utils.logBullet(clc.bold.cyan("database: ") + "releasing rules...");
15
- return Promise.all(deploys.map(function (deploy) {
17
+ return Promise.all(deploys.map((deploy) => {
16
18
  return rtdb
17
19
  .updateRules(context.projectId, deploy.instance, ruleFiles[deploy.rules], {
18
20
  dryRun: false,
19
21
  })
20
- .then(function () {
22
+ .then(() => {
21
23
  utils.logSuccess(clc.bold.green("database: ") +
22
24
  "rules for database " +
23
25
  clc.bold(deploy.instance) +
24
26
  " released successfully");
25
27
  });
26
28
  }));
27
- };
29
+ }
30
+ exports.release = release;
@@ -6,7 +6,7 @@ const secretUtils = require("../../extensions/secretsUtils");
6
6
  const secretManager = require("../../gcp/secretManager");
7
7
  const planner_1 = require("./planner");
8
8
  const askUserForParam_1 = require("../../extensions/askUserForParam");
9
- const extensionsApi_1 = require("../../extensions/extensionsApi");
9
+ const types_1 = require("../../extensions/types");
10
10
  const error_1 = require("../../error");
11
11
  const logger_1 = require("../../logger");
12
12
  const utils_1 = require("../../utils");
@@ -34,7 +34,7 @@ async function checkSpecForSecrets(i) {
34
34
  }
35
35
  exports.checkSpecForSecrets = checkSpecForSecrets;
36
36
  const secretsInSpec = (spec) => {
37
- return spec.params.filter((p) => p.type === extensionsApi_1.ParamType.SECRET);
37
+ return spec.params.filter((p) => p.type === types_1.ParamType.SECRET);
38
38
  };
39
39
  async function handleSecretsCreateInstance(i, nonInteractive) {
40
40
  const extensionVersion = await (0, planner_1.getExtensionVersion)(i);
@@ -49,7 +49,7 @@ async function handleSecretsUpdateInstance(i, prevSpec, nonInteractive) {
49
49
  const secretParams = secretsInSpec(extensionVersion.spec);
50
50
  for (const s of secretParams) {
51
51
  const prevParam = prevExtensionVersion.spec.params.find((p) => p.param === s.param);
52
- if ((prevParam === null || prevParam === void 0 ? void 0 : prevParam.type) === extensionsApi_1.ParamType.SECRET && prevSpec.params[prevParam === null || prevParam === void 0 ? void 0 : prevParam.param]) {
52
+ if ((prevParam === null || prevParam === void 0 ? void 0 : prevParam.type) === types_1.ParamType.SECRET && prevSpec.params[prevParam === null || prevParam === void 0 ? void 0 : prevParam.param]) {
53
53
  await handleSecretParamForUpdate(s, i, prevSpec.params[prevParam === null || prevParam === void 0 ? void 0 : prevParam.param], nonInteractive);
54
54
  }
55
55
  else {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const _ = require("lodash");
4
4
  const clc = require("cli-color");
5
- const loadCJSON = require("../../loadCJSON");
5
+ const loadCJSON_1 = require("../../loadCJSON");
6
6
  const rulesDeploy_1 = require("../../rulesDeploy");
7
7
  const utils = require("../../utils");
8
8
  async function prepareRules(context, options) {
@@ -22,7 +22,7 @@ function prepareIndexes(context, options) {
22
22
  }
23
23
  const indexesFileName = options.config.src.firestore.indexes;
24
24
  const indexesPath = options.config.path(indexesFileName);
25
- const parsedSrc = loadCJSON(indexesPath);
25
+ const parsedSrc = (0, loadCJSON_1.loadCJSON)(indexesPath);
26
26
  utils.logBullet(`${clc.bold.cyan("firestore:")} reading indexes from ${clc.bold(indexesFileName)}...`);
27
27
  context.firestore = context.firestore || {};
28
28
  context.firestore.indexes = {
@@ -56,44 +56,46 @@ function resolveBackend(build, userEnvs) {
56
56
  if (!userEnvs.hasOwnProperty(expectedEnv)) {
57
57
  throw new error_1.FirebaseError("Build specified parameter " +
58
58
  expectedEnv +
59
- " but it was not present in the user dotenv files");
59
+ " but it was not present in the user dotenv files or Cloud Secret Manager");
60
60
  }
61
61
  }
62
62
  const bkEndpoints = [];
63
63
  for (const endpointId of Object.keys(build.endpoints)) {
64
- const endpoint = build.endpoints[endpointId];
65
- let regions = endpoint.region;
64
+ const bdEndpoint = build.endpoints[endpointId];
65
+ let regions = bdEndpoint.region;
66
66
  if (typeof regions === "undefined") {
67
67
  regions = [api.functionsDefaultRegion];
68
68
  }
69
69
  for (const region of regions) {
70
- const trigger = discoverTrigger(endpoint);
71
- if (typeof endpoint.platform === "undefined") {
70
+ const trigger = discoverTrigger(bdEndpoint);
71
+ if (typeof bdEndpoint.platform === "undefined") {
72
72
  throw new error_1.FirebaseError("platform can't be undefined");
73
73
  }
74
- if (!isMemoryOption(endpoint.availableMemoryMb)) {
74
+ if (!isMemoryOption(bdEndpoint.availableMemoryMb)) {
75
75
  throw new error_1.FirebaseError("available memory must be a supported value, if present");
76
76
  }
77
77
  let timeout;
78
- if (endpoint.timeoutSeconds) {
79
- timeout = resolveInt(endpoint.timeoutSeconds);
78
+ if (bdEndpoint.timeoutSeconds) {
79
+ timeout = resolveInt(bdEndpoint.timeoutSeconds);
80
80
  }
81
81
  else {
82
82
  timeout = 60;
83
83
  }
84
- const bkEndpoint = Object.assign({ id: endpointId, project: endpoint.project, region: region, entryPoint: endpoint.entryPoint, platform: endpoint.platform, runtime: endpoint.runtime, timeoutSeconds: timeout }, trigger);
85
- proto.renameIfPresent(bkEndpoint, endpoint, "maxInstances", "maxInstances", resolveInt);
86
- proto.renameIfPresent(bkEndpoint, endpoint, "minInstances", "minInstances", resolveInt);
87
- proto.renameIfPresent(bkEndpoint, endpoint, "concurrency", "concurrency", resolveInt);
88
- proto.copyIfPresent(bkEndpoint, endpoint, "ingressSettings", "availableMemoryMb", "environmentVariables", "labels");
89
- if (endpoint.vpc) {
84
+ const bkEndpoint = Object.assign({ id: endpointId, project: bdEndpoint.project, region: region, entryPoint: bdEndpoint.entryPoint, platform: bdEndpoint.platform, runtime: bdEndpoint.runtime, timeoutSeconds: timeout }, trigger);
85
+ proto.renameIfPresent(bkEndpoint, bdEndpoint, "maxInstances", "maxInstances", resolveInt);
86
+ proto.renameIfPresent(bkEndpoint, bdEndpoint, "minInstances", "minInstances", resolveInt);
87
+ proto.renameIfPresent(bkEndpoint, bdEndpoint, "concurrency", "concurrency", resolveInt);
88
+ proto.copyIfPresent(bkEndpoint, bdEndpoint, "ingressSettings", "availableMemoryMb", "environmentVariables", "labels");
89
+ proto.copyIfPresent(bkEndpoint, bdEndpoint, "secretEnvironmentVariables");
90
+ if (bdEndpoint.vpc) {
90
91
  bkEndpoint.vpc = {
91
- connector: resolveString(endpoint.vpc.connector).replace("$REGION", region),
92
+ connector: resolveString(bdEndpoint.vpc.connector).replace("$REGION", region),
92
93
  };
93
- proto.copyIfPresent(bkEndpoint.vpc, endpoint.vpc, "egressSettings");
94
+ proto.copyIfPresent(bkEndpoint.vpc, bdEndpoint.vpc, "egressSettings");
94
95
  }
95
- if (endpoint.serviceAccount) {
96
- bkEndpoint.serviceAccountEmail = endpoint.serviceAccount;
96
+ proto.renameIfPresent(bkEndpoint, bdEndpoint, "serviceAccountEmail", "serviceAccount");
97
+ if ("serviceAccountEmail" in bkEndpoint && !bdEndpoint.serviceAccount) {
98
+ delete bkEndpoint.serviceAccountEmail;
97
99
  }
98
100
  bkEndpoints.push(bkEndpoint);
99
101
  }
@@ -116,7 +118,7 @@ function discoverTrigger(endpoint) {
116
118
  trigger = { callableTrigger: {} };
117
119
  }
118
120
  else if ("blockingTrigger" in endpoint) {
119
- throw new error_1.FirebaseError("blocking triggers not supported");
121
+ trigger = { blockingTrigger: endpoint.blockingTrigger };
120
122
  }
121
123
  else if ("eventTrigger" in endpoint) {
122
124
  const bkEventFilters = {};
@@ -143,7 +145,18 @@ function discoverTrigger(endpoint) {
143
145
  schedule: resolveString(endpoint.scheduleTrigger.schedule),
144
146
  timeZone: resolveString(endpoint.scheduleTrigger.timeZone),
145
147
  };
146
- proto.renameIfPresent(bkSchedule, endpoint.scheduleTrigger, "retryConfig", "retryConfig", resolveInt);
148
+ const bkRetry = {};
149
+ if (endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds) {
150
+ bkRetry.maxBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds));
151
+ }
152
+ if (endpoint.scheduleTrigger.retryConfig.minBackoffSeconds) {
153
+ bkRetry.minBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.minBackoffSeconds));
154
+ }
155
+ if (endpoint.scheduleTrigger.retryConfig.maxRetrySeconds) {
156
+ bkRetry.maxRetryDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxRetrySeconds));
157
+ }
158
+ proto.copyIfPresent(bkRetry, endpoint.scheduleTrigger.retryConfig, "retryCount", "maxDoublings");
159
+ bkSchedule.retryConfig = bkRetry;
147
160
  trigger = { scheduleTrigger: bkSchedule };
148
161
  }
149
162
  else if ("taskQueueTrigger" in endpoint) {
@@ -1,17 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.secretAccess = exports.maybeEnableAR = exports.cloudBuildEnabled = exports.defaultServiceAccount = void 0;
3
+ exports.secretAccess = exports.cloudBuildEnabled = exports.defaultServiceAccount = void 0;
4
4
  const clc = require("cli-color");
5
5
  const ensureApiEnabled_1 = require("../../ensureApiEnabled");
6
6
  const error_1 = require("../../error");
7
7
  const utils_1 = require("../../utils");
8
8
  const secretManager_1 = require("../../gcp/secretManager");
9
- const previews_1 = require("../../previews");
10
9
  const projects_1 = require("../../management/projects");
11
10
  const functional_1 = require("../../functional");
12
11
  const track_1 = require("../../track");
13
12
  const backend = require("./backend");
14
- const ensureApiEnabled = require("../../ensureApiEnabled");
15
13
  const FAQ_URL = "https://firebase.google.com/support/faq#functions-runtime";
16
14
  const CLOUD_BUILD_API = "cloudbuild.googleapis.com";
17
15
  async function defaultServiceAccount(e) {
@@ -66,14 +64,6 @@ async function cloudBuildEnabled(projectId) {
66
64
  }
67
65
  }
68
66
  exports.cloudBuildEnabled = cloudBuildEnabled;
69
- async function maybeEnableAR(projectId) {
70
- if (!previews_1.previews.artifactregistry) {
71
- return ensureApiEnabled.check(projectId, "artifactregistry.googleapis.com", "functions", true);
72
- }
73
- await ensureApiEnabled.ensure(projectId, "artifactregistry.googleapis.com", "functions");
74
- return true;
75
- }
76
- exports.maybeEnableAR = maybeEnableAR;
77
67
  async function secretsToServiceAccounts(b) {
78
68
  const secretsToSa = {};
79
69
  for (const e of backend.allEndpoints(b)) {
@@ -21,7 +21,6 @@ const triggerRegionHelper_1 = require("./triggerRegionHelper");
21
21
  const checkIam_1 = require("./checkIam");
22
22
  const error_1 = require("../../error");
23
23
  const projectConfig_1 = require("../../functions/projectConfig");
24
- const previews_1 = require("../../previews");
25
24
  const v1_1 = require("../../functions/events/v1");
26
25
  const serviceusage_1 = require("../../gcp/serviceusage");
27
26
  function hasUserConfig(config) {
@@ -40,9 +39,8 @@ async function prepare(context, options, payload) {
40
39
  ensureApiEnabled.ensure(projectId, "cloudfunctions.googleapis.com", "functions"),
41
40
  ensureApiEnabled.check(projectId, "runtimeconfig.googleapis.com", "runtimeconfig", true),
42
41
  ensure.cloudBuildEnabled(projectId),
43
- ensure.maybeEnableAR(projectId),
42
+ ensureApiEnabled.check(projectId, "artifactregistry.googleapis.com", "artifactregistry"),
44
43
  ]);
45
- context.artifactRegistryEnabled = checkAPIsEnabled[3];
46
44
  const firebaseConfig = await functionsConfig.getFirebaseConfig(options);
47
45
  context.firebaseConfig = firebaseConfig;
48
46
  let runtimeConfig = { firebase: firebaseConfig };
@@ -79,15 +77,8 @@ async function prepare(context, options, payload) {
79
77
  };
80
78
  const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
81
79
  const envs = Object.assign(Object.assign({}, userEnvs), firebaseEnvs);
82
- let wantBackend;
83
- if (previews_1.previews.functionsparams) {
84
- const wantBuild = await runtimeDelegate.discoverBuild(runtimeConfig, firebaseEnvs);
85
- wantBackend = build.resolveBackend(wantBuild, userEnvs);
86
- }
87
- else {
88
- logger_1.logger.debug(`Analyzing ${runtimeDelegate.name} backend spec`);
89
- wantBackend = await runtimeDelegate.discoverSpec(runtimeConfig, firebaseEnvs);
90
- }
80
+ const wantBuild = await runtimeDelegate.discoverBuild(runtimeConfig, firebaseEnvs);
81
+ const wantBackend = build.resolveBackend(wantBuild, userEnvs);
91
82
  wantBackend.environmentVariables = envs;
92
83
  for (const endpoint of backend.allEndpoints(wantBackend)) {
93
84
  endpoint.environmentVariables = wantBackend.environmentVariables;
@@ -145,7 +136,6 @@ async function prepare(context, options, payload) {
145
136
  }));
146
137
  if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv2")) {
147
138
  const V2_APIS = [
148
- "artifactregistry.googleapis.com",
149
139
  "run.googleapis.com",
150
140
  "eventarc.googleapis.com",
151
141
  "pubsub.googleapis.com",
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prepareFunctionsUpload = exports.getFunctionsConfig = void 0;
4
- const _ = require("lodash");
5
4
  const archiver = require("archiver");
6
5
  const clc = require("cli-color");
7
6
  const filesize = require("filesize");
@@ -54,12 +53,12 @@ async function packageSource(sourceDir, config, runtimeConfig) {
54
53
  ignore.push("firebase-debug.log", "firebase-debug.*.log", CONFIG_DEST_FILE);
55
54
  try {
56
55
  const files = await fsAsync.readdirRecursive({ path: sourceDir, ignore: ignore });
57
- _.forEach(files, (file) => {
56
+ for (const file of files) {
58
57
  archive.file(file.name, {
59
58
  name: path.relative(sourceDir, file.name),
60
59
  mode: file.mode,
61
60
  });
62
- });
61
+ }
63
62
  if (typeof runtimeConfig !== "undefined") {
64
63
  archive.append(JSON.stringify(runtimeConfig, null, 2), {
65
64
  name: CONFIG_DEST_FILE,
@@ -36,7 +36,6 @@ const gcfV2PollerOptions = {
36
36
  masterTimeout: 25 * 60 * 1000,
37
37
  maxBackoff: 10000,
38
38
  };
39
- const DEFAULT_GCFV2_CONCURRENCY = 80;
40
39
  const rethrowAs = (endpoint, op) => (err) => {
41
40
  logger_1.logger.error(err.message);
42
41
  throw new reporter.DeploymentError(endpoint, op, err);
@@ -63,11 +63,7 @@ async function release(context, options, payload) {
63
63
  const deletedEndpoints = Object.values(plan)
64
64
  .map((r) => r.endpointsToDelete)
65
65
  .reduce(functional_1.reduceFlat, []);
66
- const opts = {};
67
- if (!context.artifactRegistryEnabled) {
68
- opts.ar = new containerCleaner.NoopArtifactRegistryCleaner();
69
- }
70
- await containerCleaner.cleanupBuildImages(haveEndpoints, deletedEndpoints, opts);
66
+ await containerCleaner.cleanupBuildImages(haveEndpoints, deletedEndpoints);
71
67
  const allErrors = summary.results.filter((r) => r.error).map((r) => r.error);
72
68
  if (allErrors.length) {
73
69
  const opts = allErrors.length === 1 ? { original: allErrors[0] } : { children: allErrors };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.detectFromPort = exports.detectFromYaml = exports.yamlToBackend = exports.readFileAsync = void 0;
3
+ exports.detectFromPort = exports.detectFromYaml = exports.yamlToBuild = exports.yamlToBackend = exports.readFileAsync = void 0;
4
4
  const node_fetch_1 = require("node-fetch");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
@@ -26,6 +26,21 @@ function yamlToBackend(yaml, project, region, runtime) {
26
26
  }
27
27
  }
28
28
  exports.yamlToBackend = yamlToBackend;
29
+ function yamlToBuild(yaml, project, region, runtime) {
30
+ try {
31
+ if (!yaml.specVersion) {
32
+ throw new error_1.FirebaseError("Expect manifest yaml to specify a version number");
33
+ }
34
+ if (yaml.specVersion === "v1alpha1") {
35
+ return v1alpha1.buildFromV1Alpha1(yaml, project, region, runtime);
36
+ }
37
+ throw new error_1.FirebaseError("It seems you are using a newer SDK than this version of the CLI can handle. Please update your CLI with `npm install -g firebase-tools`");
38
+ }
39
+ catch (err) {
40
+ throw new error_1.FirebaseError("Failed to parse build specification", { children: [err] });
41
+ }
42
+ }
43
+ exports.yamlToBuild = yamlToBuild;
29
44
  async function detectFromYaml(directory, project, runtime) {
30
45
  let text;
31
46
  try {
@@ -42,7 +57,7 @@ async function detectFromYaml(directory, project, runtime) {
42
57
  }
43
58
  logger_1.logger.debug("Found functions.yaml. Got spec:", text);
44
59
  const parsed = yaml.load(text);
45
- return yamlToBackend(parsed, project, api.functionsDefaultRegion, runtime);
60
+ return yamlToBuild(parsed, project, api.functionsDefaultRegion, runtime);
46
61
  }
47
62
  exports.detectFromYaml = detectFromYaml;
48
63
  async function detectFromPort(port, project, runtime, timeout = 30000) {
@@ -74,6 +89,6 @@ async function detectFromPort(port, project, runtime, timeout = 30000) {
74
89
  logger_1.logger.debug("Failed to parse functions.yaml", err);
75
90
  throw new error_1.FirebaseError(`Failed to load function definition from source: ${text}`);
76
91
  }
77
- return yamlToBackend(parsed, project, api.functionsDefaultRegion, runtime);
92
+ return yamlToBuild(parsed, project, api.functionsDefaultRegion, runtime);
78
93
  }
79
94
  exports.detectFromPort = detectFromPort;