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
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const logger_1 = require("../logger");
4
5
  const rcVersion = require("../remoteconfig/versionslist");
5
6
  const command_1 = require("../command");
@@ -17,7 +18,7 @@ function pushTableContents(table, version) {
17
18
  version.updateTime ? (0, utils_1.datetimeString)(new Date(version.updateTime)) : "",
18
19
  ]);
19
20
  }
20
- module.exports = new command_1.Command("remoteconfig:versions:list")
21
+ exports.command = new command_1.Command("remoteconfig:versions:list")
21
22
  .description("get a list of Remote Config template versions that have been published for a Firebase project")
22
23
  .option("--limit <maxResults>", "limit the number of versions being returned. Pass '0' to fetch all versions.")
23
24
  .before(requireAuth_1.requireAuth)
@@ -1,27 +1,29 @@
1
1
  "use strict";
2
- var clc = require("cli-color");
3
- var _ = require("lodash");
4
- var { Command } = require("../command");
5
- const { logger } = require("../logger");
6
- var utils = require("../utils");
7
- var { requirePermissions } = require("../requirePermissions");
8
- var { requireConfig } = require("../requireConfig");
9
- var { serve } = require("../serve/index");
10
- var { filterTargets } = require("../filterTargets");
11
- var { needProjectNumber } = require("../projectUtils");
12
- var { FirebaseError } = require("../error");
13
- var VALID_TARGETS = ["hosting", "functions"];
14
- var REQUIRES_AUTH = ["hosting", "functions"];
15
- var ALL_TARGETS = _.union(VALID_TARGETS, ["database", "firestore"]);
16
- var filterOnly = (list, only) => {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const clc = require("cli-color");
5
+ const _ = require("lodash");
6
+ const command_1 = require("../command");
7
+ const logger_1 = require("../logger");
8
+ const utils = require("../utils");
9
+ const requirePermissions_1 = require("../requirePermissions");
10
+ const requireConfig_1 = require("../requireConfig");
11
+ const index_1 = require("../serve/index");
12
+ const filterTargets_1 = require("../filterTargets");
13
+ const projectUtils_1 = require("../projectUtils");
14
+ const error_1 = require("../error");
15
+ const VALID_TARGETS = ["hosting", "functions"];
16
+ const REQUIRES_AUTH = ["hosting", "functions"];
17
+ const ALL_TARGETS = _.union(VALID_TARGETS, ["database", "firestore"]);
18
+ function filterOnly(list, only = "") {
17
19
  if (!only) {
18
20
  return [];
19
21
  }
20
22
  return _.intersection(list, only.split(",").map((opt) => {
21
23
  return opt.split(":")[0];
22
24
  }));
23
- };
24
- module.exports = new Command("serve")
25
+ }
26
+ exports.command = new command_1.Command("serve")
25
27
  .description("start a local server for your static assets")
26
28
  .option("-p, --port <port>", "the port on which to listen (default: 5000)", 5000)
27
29
  .option("-o, --host <host>", "the host on which to listen (default: localhost)", "localhost")
@@ -33,28 +35,28 @@ module.exports = new Command("serve")
33
35
  filterOnly(REQUIRES_AUTH, options.only).length === 0) {
34
36
  return Promise.resolve();
35
37
  }
36
- return requireConfig(options)
37
- .then(() => requirePermissions(options))
38
- .then(() => needProjectNumber(options));
38
+ return (0, requireConfig_1.requireConfig)(options)
39
+ .then(() => (0, requirePermissions_1.requirePermissions)(options))
40
+ .then(() => (0, projectUtils_1.needProjectNumber)(options));
39
41
  })
40
42
  .action((options) => {
41
43
  options.targets = filterOnly(ALL_TARGETS, options.only);
42
44
  if (options.targets.includes("database") || options.targets.includes("firestore")) {
43
- throw new FirebaseError(`Please use ${clc.bold("firebase emulators:start")} to start the Realtime Database or Cloud Firestore emulators. ${clc.bold("firebase serve")} only supports Hosting and Cloud Functions.`);
45
+ throw new error_1.FirebaseError(`Please use ${clc.bold("firebase emulators:start")} to start the Realtime Database or Cloud Firestore emulators. ${clc.bold("firebase serve")} only supports Hosting and Cloud Functions.`);
44
46
  }
45
47
  options.targets = filterOnly(VALID_TARGETS, options.only);
46
48
  if (options.targets.length > 0) {
47
- return serve(options);
49
+ return (0, index_1.serve)(options);
48
50
  }
49
51
  if (options.config) {
50
- logger.info();
51
- logger.info(clc.bold(clc.white("===") + " Serving from '" + options.config.projectDir + "'..."));
52
- logger.info();
52
+ logger_1.logger.info();
53
+ logger_1.logger.info(clc.bold(clc.white("===") + " Serving from '" + options.config.projectDir + "'..."));
54
+ logger_1.logger.info();
53
55
  }
54
56
  else {
55
57
  utils.logWarning("No Firebase project directory detected. Serving static content from " +
56
58
  clc.bold(options.cwd || process.cwd()));
57
59
  }
58
- options.targets = filterTargets(options, VALID_TARGETS);
59
- return serve(options);
60
+ options.targets = (0, filterTargets_1.filterTargets)(options, VALID_TARGETS);
61
+ return (0, index_1.serve)(options);
60
62
  });
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const download_1 = require("../emulator/download");
5
6
  const types_1 = require("../emulator/types");
6
7
  const NAME = types_1.Emulators.DATABASE;
7
- exports.default = new command_1.Command(`setup:emulators:${NAME}`)
8
+ exports.command = new command_1.Command(`setup:emulators:${NAME}`)
8
9
  .description(`downloads the ${NAME} emulator`)
9
10
  .action(() => {
10
11
  return (0, download_1.downloadEmulator)(NAME);
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const download_1 = require("../emulator/download");
5
6
  const types_1 = require("../emulator/types");
6
7
  const NAME = types_1.Emulators.FIRESTORE;
7
- exports.default = new command_1.Command(`setup:emulators:${NAME}`)
8
+ exports.command = new command_1.Command(`setup:emulators:${NAME}`)
8
9
  .description(`downloads the ${NAME} emulator`)
9
10
  .action(() => {
10
11
  return (0, download_1.downloadEmulator)(NAME);
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const download_1 = require("../emulator/download");
5
6
  const types_1 = require("../emulator/types");
6
7
  const EMULATOR_NAME = types_1.Emulators.PUBSUB;
7
- exports.default = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
8
+ exports.command = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
8
9
  .description(`downloads the ${EMULATOR_NAME} emulator`)
9
10
  .action(() => {
10
11
  return (0, download_1.downloadEmulator)(EMULATOR_NAME);
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const download_1 = require("../emulator/download");
5
6
  const types_1 = require("../emulator/types");
6
7
  const EMULATOR_NAME = types_1.Emulators.STORAGE;
7
- exports.default = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
8
+ exports.command = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
8
9
  .description(`downloads the ${EMULATOR_NAME} emulator`)
9
10
  .action(() => {
10
11
  return (0, download_1.downloadEmulator)(EMULATOR_NAME);
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const command_1 = require("../command");
4
5
  const download_1 = require("../emulator/download");
5
6
  const types_1 = require("../emulator/types");
6
7
  const NAME = types_1.Emulators.UI;
7
- exports.default = new command_1.Command(`setup:emulators:${NAME}`)
8
+ exports.command = new command_1.Command(`setup:emulators:${NAME}`)
8
9
  .description(`downloads the ${NAME} emulator`)
9
10
  .action(() => {
10
11
  return (0, download_1.downloadEmulator)(NAME);
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const clc = require("cli-color");
4
5
  const command_1 = require("../command");
5
6
  const logger_1 = require("../logger");
6
7
  const requireConfig_1 = require("../requireConfig");
7
8
  const utils = require("../utils");
8
9
  const error_1 = require("../error");
9
- exports.default = new command_1.Command("target:apply <type> <name> <resources...>")
10
+ exports.command = new command_1.Command("target:apply <type> <name> <resources...>")
10
11
  .description("apply a deploy target to a resource")
11
12
  .before(requireConfig_1.requireConfig)
12
13
  .action((type, name, resources, options) => {
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const clc = require("cli-color");
4
5
  const command_1 = require("../command");
5
6
  const requireConfig_1 = require("../requireConfig");
6
7
  const utils = require("../utils");
7
- exports.default = new command_1.Command("target:clear <type> <target>")
8
+ exports.command = new command_1.Command("target:clear <type> <target>")
8
9
  .description("clear all resources from a named resource target")
9
10
  .before(requireConfig_1.requireConfig)
10
11
  .action((type, name, options) => {
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const clc = require("cli-color");
4
5
  const command_1 = require("../command");
5
6
  const requireConfig_1 = require("../requireConfig");
6
7
  const utils = require("../utils");
7
- exports.default = new command_1.Command("target:remove <type> <resource>")
8
+ exports.command = new command_1.Command("target:remove <type> <resource>")
8
9
  .description("remove a resource target")
9
10
  .before(requireConfig_1.requireConfig)
10
11
  .action((type, resource, options) => {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const clc = require("cli-color");
4
5
  const command_1 = require("../command");
5
6
  const logger_1 = require("../logger");
@@ -11,7 +12,7 @@ function logTargets(type, targets) {
11
12
  logger_1.logger.info(name, "(" + (resources || []).join(",") + ")");
12
13
  }
13
14
  }
14
- exports.default = new command_1.Command("target [type]")
15
+ exports.command = new command_1.Command("target [type]")
15
16
  .description("display configured deploy targets for the current project")
16
17
  .before(requireConfig_1.requireConfig)
17
18
  .action((type, options) => {
@@ -1,43 +1,45 @@
1
1
  "use strict";
2
- var _ = require("lodash");
3
- var clc = require("cli-color");
4
- var { Command } = require("../command");
5
- var { getFirebaseProject, listFirebaseProjects } = require("../management/projects");
6
- var { prompt } = require("../prompt");
7
- var { requireAuth } = require("../requireAuth");
8
- var { validateProjectId } = require("../command");
9
- const { logger } = require("../logger");
10
- var utils = require("../utils");
11
- var listAliases = function (options) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const _ = require("lodash");
5
+ const clc = require("cli-color");
6
+ const command_1 = require("../command");
7
+ const projects_1 = require("../management/projects");
8
+ const logger_1 = require("../logger");
9
+ const prompt_1 = require("../prompt");
10
+ const requireAuth_1 = require("../requireAuth");
11
+ const command_2 = require("../command");
12
+ const utils = require("../utils");
13
+ function listAliases(options) {
12
14
  if (options.rc.hasProjects) {
13
- logger.info("Project aliases for", clc.bold(options.projectRoot) + ":");
14
- logger.info();
15
- _.forEach(options.rc.projects, function (projectId, alias) {
16
- var listing = alias + " (" + projectId + ")";
15
+ logger_1.logger.info("Project aliases for", clc.bold(options.projectRoot) + ":");
16
+ logger_1.logger.info();
17
+ _.forEach(options.rc.projects, (projectId, alias) => {
18
+ const listing = alias + " (" + projectId + ")";
17
19
  if (options.project === projectId || options.projectAlias === alias) {
18
- logger.info(clc.cyan.bold("* " + listing));
20
+ logger_1.logger.info(clc.cyan.bold("* " + listing));
19
21
  }
20
22
  else {
21
- logger.info(" " + listing);
23
+ logger_1.logger.info(" " + listing);
22
24
  }
23
25
  });
24
- logger.info();
26
+ logger_1.logger.info();
25
27
  }
26
- logger.info("Run", clc.bold("firebase use --add"), "to define a new project alias.");
27
- };
28
- var verifyMessage = function (name) {
28
+ logger_1.logger.info("Run", clc.bold("firebase use --add"), "to define a new project alias.");
29
+ }
30
+ function verifyMessage(name) {
29
31
  return "please verify project " + clc.bold(name) + " exists and you have access.";
30
- };
31
- module.exports = new Command("use [alias_or_project_id]")
32
+ }
33
+ exports.command = new command_1.Command("use [alias_or_project_id]")
32
34
  .description("set an active Firebase project for your working directory")
33
35
  .option("--add", "create a new project alias interactively")
34
36
  .option("--alias <name>", "create a new alias for the provided project id")
35
37
  .option("--unalias <name>", "remove an already created project alias")
36
38
  .option("--clear", "clear the active project selection")
37
- .before(requireAuth)
38
- .action(function (newActive, options) {
39
- var aliasOpt;
40
- var i = process.argv.indexOf("--alias");
39
+ .before(requireAuth_1.requireAuth)
40
+ .action((newActive, options) => {
41
+ let aliasOpt;
42
+ const i = process.argv.indexOf("--alias");
41
43
  if (i >= 0 && process.argv.length > i + 1) {
42
44
  aliasOpt = process.argv[i + 1];
43
45
  }
@@ -48,11 +50,11 @@ module.exports = new Command("use [alias_or_project_id]")
48
50
  " to start a project directory in the current folder.");
49
51
  }
50
52
  if (newActive) {
51
- var project = null;
53
+ let project;
52
54
  const hasAlias = options.rc.hasProjectAlias(newActive);
53
55
  const resolvedProject = options.rc.resolveAlias(newActive);
54
- validateProjectId(resolvedProject);
55
- return getFirebaseProject(resolvedProject)
56
+ (0, command_2.validateProjectId)(resolvedProject);
57
+ return (0, projects_1.getFirebaseProject)(resolvedProject)
56
58
  .then((foundProject) => {
57
59
  project = foundProject;
58
60
  })
@@ -65,18 +67,18 @@ module.exports = new Command("use [alias_or_project_id]")
65
67
  return utils.reject("Cannot create alias " + clc.bold(aliasOpt) + ", " + verifyMessage(newActive));
66
68
  }
67
69
  options.rc.addProjectAlias(aliasOpt, newActive);
68
- logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
70
+ logger_1.logger.info("Created alias", clc.bold(aliasOpt), "for", resolvedProject + ".");
69
71
  }
70
72
  if (hasAlias) {
71
73
  if (!project) {
72
74
  return utils.reject("Unable to use alias " + clc.bold(newActive) + ", " + verifyMessage(resolvedProject));
73
75
  }
74
76
  utils.makeActiveProject(options.projectRoot, newActive);
75
- logger.info("Now using alias", clc.bold(newActive), "(" + resolvedProject + ")");
77
+ logger_1.logger.info("Now using alias", clc.bold(newActive), "(" + resolvedProject + ")");
76
78
  }
77
79
  else if (project) {
78
80
  utils.makeActiveProject(options.projectRoot, newActive);
79
- logger.info("Now using project", clc.bold(newActive));
81
+ logger_1.logger.info("Now using project", clc.bold(newActive));
80
82
  }
81
83
  else {
82
84
  return utils.reject("Invalid project selection, " + verifyMessage(newActive));
@@ -86,8 +88,8 @@ module.exports = new Command("use [alias_or_project_id]")
86
88
  else if (options.unalias) {
87
89
  if (options.rc.hasProjectAlias(options.unalias)) {
88
90
  options.rc.removeProjectAlias(options.unalias);
89
- logger.info("Removed alias", clc.bold(options.unalias));
90
- logger.info();
91
+ logger_1.logger.info("Removed alias", clc.bold(options.unalias));
92
+ logger_1.logger.info();
91
93
  listAliases(options);
92
94
  }
93
95
  }
@@ -99,9 +101,9 @@ module.exports = new Command("use [alias_or_project_id]")
99
101
  clc.bold("firebase use <project_id> --alias <alias>") +
100
102
  " instead.");
101
103
  }
102
- return listFirebaseProjects().then(function (projects) {
103
- var results = {};
104
- return prompt(results, [
104
+ return (0, projects_1.listFirebaseProjects)().then((projects) => {
105
+ const results = {};
106
+ return (0, prompt_1.prompt)(results, [
105
107
  {
106
108
  type: "list",
107
109
  name: "project",
@@ -112,49 +114,49 @@ module.exports = new Command("use [alias_or_project_id]")
112
114
  type: "input",
113
115
  name: "alias",
114
116
  message: "What alias do you want to use for this project? (e.g. staging)",
115
- validate: function (input) {
117
+ validate: (input) => {
116
118
  return input && input.length > 0;
117
119
  },
118
120
  },
119
- ]).then(function () {
121
+ ]).then(() => {
120
122
  options.rc.addProjectAlias(results.alias, results.project);
121
123
  utils.makeActiveProject(options.projectRoot, results.alias);
122
- logger.info();
123
- logger.info("Created alias", clc.bold(results.alias), "for", results.project + ".");
124
- logger.info("Now using alias", clc.bold(results.alias) + " (" + results.project + ")");
124
+ logger_1.logger.info();
125
+ logger_1.logger.info("Created alias", clc.bold(results.alias), "for", results.project + ".");
126
+ logger_1.logger.info("Now using alias", clc.bold(results.alias) + " (" + results.project + ")");
125
127
  });
126
128
  });
127
129
  }
128
130
  else if (options.clear) {
129
- utils.makeActiveProject(options.projectRoot, null);
131
+ utils.makeActiveProject(options.projectRoot, undefined);
130
132
  options.projectAlias = null;
131
133
  options.project = null;
132
- logger.info("Cleared active project.");
133
- logger.info();
134
+ logger_1.logger.info("Cleared active project.");
135
+ logger_1.logger.info();
134
136
  listAliases(options);
135
137
  }
136
138
  else {
137
139
  if (options.nonInteractive || !process.stdout.isTTY) {
138
140
  if (options.project) {
139
- logger.info(options.project);
141
+ logger_1.logger.info(options.project);
140
142
  return options.project;
141
143
  }
142
- return utils.reject("No active project", { exit: 1 });
144
+ return utils.reject("No active project");
143
145
  }
144
146
  if (options.projectAlias) {
145
- logger.info("Active Project:", clc.bold.cyan(options.projectAlias + " (" + options.project + ")"));
147
+ logger_1.logger.info("Active Project:", clc.bold.cyan(options.projectAlias + " (" + options.project + ")"));
146
148
  }
147
149
  else if (options.project) {
148
- logger.info("Active Project:", clc.bold.cyan(options.project));
150
+ logger_1.logger.info("Active Project:", clc.bold.cyan(options.project));
149
151
  }
150
152
  else {
151
- var msg = "No project is currently active";
153
+ let msg = "No project is currently active";
152
154
  if (options.rc.hasProjects) {
153
155
  msg += ", and no aliases have been created.";
154
156
  }
155
- logger.info(msg + ".");
157
+ logger_1.logger.info(msg + ".");
156
158
  }
157
- logger.info();
159
+ logger_1.logger.info();
158
160
  listAliases(options);
159
161
  return options.project;
160
162
  }
package/lib/config.js CHANGED
@@ -14,7 +14,7 @@ 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 = {}) {
@@ -95,7 +95,7 @@ class Config {
95
95
  throw e;
96
96
  }
97
97
  }
98
- return loadCJSON(fullPath);
98
+ return (0, loadCJSON_1.loadCJSON)(fullPath);
99
99
  case ".bolt":
100
100
  if (target === "database") {
101
101
  this.notes.databaseRules = "bolt";
@@ -125,7 +125,7 @@ class Config {
125
125
  }
126
126
  return outPath;
127
127
  }
128
- readProjectFile(p, options) {
128
+ readProjectFile(p, options = {}) {
129
129
  options = options || {};
130
130
  try {
131
131
  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,37 +1,39 @@
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 _ = require("lodash");
5
+ const clc = require("cli-color");
6
+ const path = require("path");
7
+ const error_1 = require("../../error");
8
+ const parseBoltRules_1 = require("../../parseBoltRules");
9
+ const rtdb = require("../../rtdb");
10
+ const utils = require("../../utils");
9
11
  const dbRulesConfig = require("../../database/rulesConfig");
10
- module.exports = function (context, options) {
11
- var rulesConfig = dbRulesConfig.getRulesConfig(context.projectId, options);
12
- var next = Promise.resolve();
12
+ function prepare(context, options) {
13
+ const rulesConfig = dbRulesConfig.getRulesConfig(context.projectId, options);
14
+ const next = Promise.resolve();
13
15
  if (!rulesConfig || rulesConfig.length === 0) {
14
16
  return next;
15
17
  }
16
- var ruleFiles = {};
17
- var deploys = [];
18
- rulesConfig.forEach(function (ruleConfig) {
18
+ const ruleFiles = {};
19
+ const deploys = [];
20
+ rulesConfig.forEach((ruleConfig) => {
19
21
  if (!ruleConfig.rules) {
20
22
  return;
21
23
  }
22
24
  ruleFiles[ruleConfig.rules] = null;
23
25
  deploys.push(ruleConfig);
24
26
  });
25
- _.forEach(ruleFiles, function (v, file) {
27
+ _.forEach(ruleFiles, (v, file) => {
26
28
  switch (path.extname(file)) {
27
29
  case ".json":
28
30
  ruleFiles[file] = options.config.readProjectFile(file);
29
31
  break;
30
32
  case ".bolt":
31
- ruleFiles[file] = parseBoltRules(file);
33
+ ruleFiles[file] = (0, parseBoltRules_1.parseBoltRules)(file);
32
34
  break;
33
35
  default:
34
- throw new FirebaseError("Unexpected rules format " + path.extname(file));
36
+ throw new error_1.FirebaseError("Unexpected rules format " + path.extname(file));
35
37
  }
36
38
  });
37
39
  context.database = {
@@ -39,14 +41,15 @@ module.exports = function (context, options) {
39
41
  ruleFiles: ruleFiles,
40
42
  };
41
43
  utils.logBullet(clc.bold.cyan("database: ") + "checking rules syntax...");
42
- return Promise.all(deploys.map(function (deploy) {
44
+ return Promise.all(deploys.map((deploy) => {
43
45
  return rtdb
44
46
  .updateRules(context.projectId, deploy.instance, ruleFiles[deploy.rules], { dryRun: true })
45
- .then(function () {
47
+ .then(() => {
46
48
  utils.logSuccess(clc.bold.green("database: ") +
47
49
  "rules syntax for database " +
48
50
  clc.bold(deploy.instance) +
49
51
  " is valid");
50
52
  });
51
53
  }));
52
- };
54
+ }
55
+ 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;
@@ -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 = {