firebase-tools 10.9.2 → 11.1.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 (181) hide show
  1. package/README.md +15 -9
  2. package/lib/accountImporter.js +92 -93
  3. package/lib/api.js +77 -218
  4. package/lib/apiv2.js +5 -4
  5. package/lib/appdistribution/client.js +16 -25
  6. package/lib/auth.js +69 -47
  7. package/lib/bin/firebase.js +42 -47
  8. package/lib/checkValidTargetFilters.js +13 -12
  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 +8 -3
  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 +2 -1
  25. package/lib/commands/database-push.js +2 -1
  26. package/lib/commands/database-remove.js +2 -1
  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 +2 -1
  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 +23 -21
  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 +56 -120
  42. package/lib/commands/ext-dev-deprecate.js +2 -1
  43. package/lib/commands/ext-dev-emulators-exec.js +13 -7
  44. package/lib/commands/ext-dev-emulators-start.js +12 -27
  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 +2 -1
  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 +2 -1
  55. package/lib/commands/ext-install.js +14 -198
  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 +9 -92
  59. package/lib/commands/ext-update.js +67 -225
  60. package/lib/commands/ext.js +2 -1
  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 +2 -1
  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 +2 -1
  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 +29 -27
  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 -52
  116. package/lib/config.js +3 -3
  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 -19
  120. package/lib/deploy/database/release.js +12 -9
  121. package/lib/deploy/firestore/prepare.js +2 -2
  122. package/lib/deploy/functions/build.js +32 -20
  123. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +187 -54
  124. package/lib/deploy/functions/runtimes/node/parseTriggers.js +14 -2
  125. package/lib/deploy/functions/services/database.js +14 -0
  126. package/lib/deploy/functions/services/index.js +14 -0
  127. package/lib/deploy/index.js +3 -3
  128. package/lib/deploy/lifecycleHooks.js +23 -20
  129. package/lib/deploy/remoteconfig/functions.js +18 -14
  130. package/lib/deploy/remoteconfig/prepare.js +2 -2
  131. package/lib/emulator/auth/apiSpec.js +14 -46
  132. package/lib/emulator/auth/operations.js +6 -29
  133. package/lib/emulator/auth/state.js +2 -25
  134. package/lib/emulator/commandUtils.js +1 -1
  135. package/lib/emulator/controller.js +3 -3
  136. package/lib/emulator/databaseEmulator.js +9 -7
  137. package/lib/emulator/downloadableEmulators.js +6 -6
  138. package/lib/emulator/extensionsEmulator.js +7 -3
  139. package/lib/emulator/firestoreEmulator.js +10 -12
  140. package/lib/emulator/functionsEmulator.js +39 -42
  141. package/lib/emulator/hubClient.js +11 -22
  142. package/lib/emulator/hubExport.js +26 -16
  143. package/lib/emulator/portUtils.js +2 -0
  144. package/lib/emulator/storage/crc.js +3 -0
  145. package/lib/emulator/storage/rules/runtime.js +1 -1
  146. package/lib/errorOut.js +2 -2
  147. package/lib/extensions/extensionsHelper.js +4 -5
  148. package/lib/extensions/manifest.js +5 -11
  149. package/lib/firebaseConfigValidate.js +1 -1
  150. package/lib/firestore/checkDatabaseType.js +4 -5
  151. package/lib/firestore/indexes.js +17 -34
  152. package/lib/functions/events/v2.js +7 -1
  153. package/lib/functionsConfigClone.js +43 -41
  154. package/lib/gcp/cloudfunctionsv2.js +17 -2
  155. package/lib/gcp/iam.js +1 -1
  156. package/lib/gcp/index.js +10 -10
  157. package/lib/gcp/runtimeconfig.js +45 -47
  158. package/lib/gcp/storage.js +2 -4
  159. package/lib/hosting/cloudRunProxy.js +19 -15
  160. package/lib/index.js +29 -28
  161. package/lib/init/features/database.js +11 -5
  162. package/lib/init/features/functions/index.js +1 -1
  163. package/lib/init/features/functions/javascript.js +23 -20
  164. package/lib/init/features/functions/npm-dependencies.js +17 -14
  165. package/lib/init/features/functions/typescript.js +27 -24
  166. package/lib/init/features/hosting/github.js +5 -4
  167. package/lib/loadCJSON.js +9 -6
  168. package/lib/logError.js +15 -12
  169. package/lib/management/apps.js +47 -43
  170. package/lib/management/database.js +33 -31
  171. package/lib/management/projects.js +13 -7
  172. package/lib/parseBoltRules.js +15 -14
  173. package/lib/profileReport.js +503 -511
  174. package/lib/profiler.js +4 -4
  175. package/lib/requireAuth.js +0 -1
  176. package/lib/responseToError.js +8 -5
  177. package/lib/rtdb.js +31 -29
  178. package/lib/scopes.js +9 -9
  179. package/npm-shrinkwrap.json +1485 -670
  180. package/package.json +21 -22
  181. package/standalone/package.json +1 -1
package/lib/profiler.js CHANGED
@@ -9,8 +9,8 @@ const abort_controller_1 = require("abort-controller");
9
9
  const apiv2_1 = require("./apiv2");
10
10
  const api_1 = require("./database/api");
11
11
  const logger_1 = require("./logger");
12
- const ProfileReport = require("./profileReport");
13
- const responseToError = require("./responseToError");
12
+ const profileReport_1 = require("./profileReport");
13
+ const responseToError_1 = require("./responseToError");
14
14
  const utils = require("./utils");
15
15
  tmp.setGracefulCleanup();
16
16
  async function profiler(options) {
@@ -38,7 +38,7 @@ async function profiler(options) {
38
38
  isInput: !!options.input,
39
39
  collapse: options.collapse,
40
40
  };
41
- const report = new ProfileReport(dataFile, outStream, reportOptions);
41
+ const report = new profileReport_1.ProfileReport(dataFile, outStream, reportOptions);
42
42
  return report.generate();
43
43
  };
44
44
  if (options.input) {
@@ -56,7 +56,7 @@ async function profiler(options) {
56
56
  signal: controller.signal,
57
57
  });
58
58
  if (res.response.status >= 400) {
59
- throw responseToError(res.response, await res.response.text());
59
+ throw (0, responseToError_1.responseToError)(res.response, await res.response.text());
60
60
  }
61
61
  if (!options.duration) {
62
62
  spinner.start();
@@ -22,7 +22,6 @@ function getAuthClient(config) {
22
22
  async function autoAuth(options, authScopes) {
23
23
  const client = getAuthClient({ scopes: authScopes, projectId: options.project });
24
24
  const token = await client.getAccessToken();
25
- api.setAccessToken(token);
26
25
  token !== null ? apiv2.setAccessToken(token) : false;
27
26
  }
28
27
  async function requireAuth(options) {
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.responseToError = void 0;
2
4
  const _ = require("lodash");
3
- const { FirebaseError } = require("./error");
4
- module.exports = function (response, body) {
5
+ const error_1 = require("./error");
6
+ function responseToError(response, body) {
5
7
  if (response.statusCode < 400) {
6
- return null;
8
+ return;
7
9
  }
8
10
  if (typeof body === "string") {
9
11
  if (response.statusCode === 404) {
@@ -44,7 +46,7 @@ module.exports = function (response, body) {
44
46
  exitCode = 1;
45
47
  }
46
48
  _.unset(response, "request.headers");
47
- return new FirebaseError(message, {
49
+ return new error_1.FirebaseError(message, {
48
50
  context: {
49
51
  body: body,
50
52
  response: response,
@@ -52,4 +54,5 @@ module.exports = function (response, body) {
52
54
  exit: exitCode,
53
55
  status: response.statusCode,
54
56
  });
55
- };
57
+ }
58
+ exports.responseToError = responseToError;
package/lib/rtdb.js CHANGED
@@ -1,33 +1,35 @@
1
1
  "use strict";
2
- var api = require("./api");
3
- var { FirebaseError } = require("./error");
4
- var utils = require("./utils");
5
- const { populateInstanceDetails } = require("./management/database");
6
- const { realtimeOriginOrCustomUrl } = require("./database/api");
7
- exports.updateRules = function (projectId, instance, src, options) {
8
- options = options || {};
9
- var path = ".settings/rules.json";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateRules = void 0;
4
+ const apiv2_1 = require("./apiv2");
5
+ const database_1 = require("./management/database");
6
+ const error_1 = require("./error");
7
+ const api_1 = require("./database/api");
8
+ const utils = require("./utils");
9
+ async function updateRules(projectId, instance, src, options = {}) {
10
+ const queryParams = {};
10
11
  if (options.dryRun) {
11
- path += "?dryRun=true";
12
+ queryParams.dryRun = "true";
12
13
  }
13
- var downstreamOptions = { instance: instance, project: projectId };
14
- return populateInstanceDetails(downstreamOptions)
15
- .then(function () {
16
- const origin = utils.getDatabaseUrl(realtimeOriginOrCustomUrl(downstreamOptions.instanceDetails.databaseUrl), instance, "");
17
- return api.request("PUT", path, {
18
- origin: origin,
19
- auth: true,
20
- data: src,
21
- json: false,
22
- resolveOnHTTPError: true,
23
- });
24
- })
25
- .then(function (response) {
26
- if (response.status === 400) {
27
- throw new FirebaseError("Syntax error in database rules:\n\n" + JSON.parse(response.body).error);
28
- }
29
- else if (response.status > 400) {
30
- throw new FirebaseError("Unexpected error while deploying database rules.", { exit: 2 });
31
- }
14
+ const downstreamOptions = { instance: instance, project: projectId };
15
+ await (0, database_1.populateInstanceDetails)(downstreamOptions);
16
+ if (!downstreamOptions.instanceDetails) {
17
+ throw new error_1.FirebaseError(`Could not get instance details`, { exit: 2 });
18
+ }
19
+ const origin = utils.getDatabaseUrl((0, api_1.realtimeOriginOrCustomUrl)(downstreamOptions.instanceDetails.databaseUrl), instance, "");
20
+ const client = new apiv2_1.Client({ urlPrefix: origin });
21
+ const response = await client.request({
22
+ method: "PUT",
23
+ path: ".settings/rules.json",
24
+ queryParams,
25
+ body: src,
26
+ resolveOnHTTPError: true,
32
27
  });
33
- };
28
+ if (response.status === 400) {
29
+ throw new error_1.FirebaseError(`Syntax error in database rules:\n\n${response.body.error}`);
30
+ }
31
+ else if (response.status > 400) {
32
+ throw new error_1.FirebaseError("Unexpected error while deploying database rules.", { exit: 2 });
33
+ }
34
+ }
35
+ exports.updateRules = updateRules;
package/lib/scopes.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- module.exports = {
3
- OPENID: "openid",
4
- EMAIL: "email",
5
- CLOUD_PROJECTS_READONLY: "https://www.googleapis.com/auth/cloudplatformprojects.readonly",
6
- FIREBASE_PLATFORM: "https://www.googleapis.com/auth/firebase",
7
- CLOUD_PLATFORM: "https://www.googleapis.com/auth/cloud-platform",
8
- CLOUD_STORAGE: "https://www.googleapis.com/auth/devstorage.read_write",
9
- CLOUD_PUBSUB: "https://www.googleapis.com/auth/pubsub",
10
- };
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLOUD_PUBSUB = exports.CLOUD_STORAGE = exports.CLOUD_PLATFORM = exports.FIREBASE_PLATFORM = exports.CLOUD_PROJECTS_READONLY = exports.EMAIL = exports.OPENID = void 0;
4
+ exports.OPENID = "openid";
5
+ exports.EMAIL = "email";
6
+ exports.CLOUD_PROJECTS_READONLY = "https://www.googleapis.com/auth/cloudplatformprojects.readonly";
7
+ exports.FIREBASE_PLATFORM = "https://www.googleapis.com/auth/firebase";
8
+ exports.CLOUD_PLATFORM = "https://www.googleapis.com/auth/cloud-platform";
9
+ exports.CLOUD_STORAGE = "https://www.googleapis.com/auth/devstorage.read_write";
10
+ exports.CLOUD_PUBSUB = "https://www.googleapis.com/auth/pubsub";