firebase-tools 11.0.1 → 11.2.1

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 (214) 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 +7 -9
  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 +2 -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 +2 -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 +2 -1
  59. package/lib/commands/ext-update.js +2 -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 +16 -4
  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/prepare.js +2 -2
  139. package/lib/deploy/storage/prepare.js +1 -1
  140. package/lib/emulator/auth/apiSpec.js +14 -46
  141. package/lib/emulator/auth/index.js +1 -1
  142. package/lib/emulator/auth/operations.js +342 -93
  143. package/lib/emulator/auth/server.js +2 -2
  144. package/lib/emulator/auth/state.js +34 -32
  145. package/lib/emulator/commandUtils.js +1 -1
  146. package/lib/emulator/constants.js +1 -1
  147. package/lib/emulator/controller.js +7 -6
  148. package/lib/emulator/databaseEmulator.js +4 -4
  149. package/lib/emulator/download.js +1 -1
  150. package/lib/emulator/downloadableEmulators.js +5 -5
  151. package/lib/emulator/events/types.js +2 -3
  152. package/lib/emulator/firestoreEmulator.js +2 -2
  153. package/lib/emulator/functionsEmulator.js +31 -45
  154. package/lib/emulator/functionsEmulatorRuntime.js +12 -16
  155. package/lib/emulator/functionsEmulatorShared.js +7 -5
  156. package/lib/emulator/functionsRuntimeWorker.js +0 -6
  157. package/lib/emulator/hostingEmulator.js +1 -1
  158. package/lib/emulator/hub.js +1 -1
  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/encodeFirestoreValue.js +11 -8
  179. package/lib/fsAsync.js +3 -3
  180. package/lib/functions/events/v2.js +7 -1
  181. package/lib/functionsConfig.js +17 -14
  182. package/lib/functionsConfigClone.js +46 -46
  183. package/lib/gcp/cloudfunctions.js +2 -15
  184. package/lib/gcp/cloudfunctionsv2.js +17 -2
  185. package/lib/gcp/iam.js +1 -1
  186. package/lib/gcp/index.js +10 -10
  187. package/lib/gcp/rules.js +1 -1
  188. package/lib/gcp/runtimeconfig.js +45 -47
  189. package/lib/hosting/proxy.js +1 -1
  190. package/lib/index.js +29 -28
  191. package/lib/init/features/database.js +10 -2
  192. package/lib/init/features/functions/index.js +1 -1
  193. package/lib/init/features/functions/javascript.js +23 -20
  194. package/lib/init/features/functions/npm-dependencies.js +17 -14
  195. package/lib/init/features/functions/typescript.js +27 -24
  196. package/lib/init/features/hosting/github.js +6 -5
  197. package/lib/init/features/hosting/index.js +2 -2
  198. package/lib/loadCJSON.js +9 -6
  199. package/lib/localFunction.js +4 -4
  200. package/lib/logError.js +15 -12
  201. package/lib/parseBoltRules.js +15 -14
  202. package/lib/previews.js +1 -1
  203. package/lib/profileReport.js +504 -512
  204. package/lib/profiler.js +4 -4
  205. package/lib/prompt.js +1 -2
  206. package/lib/rc.js +1 -1
  207. package/lib/requireAuth.js +0 -1
  208. package/lib/responseToError.js +8 -5
  209. package/lib/rulesDeploy.js +2 -2
  210. package/lib/scopes.js +9 -9
  211. package/lib/serve/index.js +4 -5
  212. package/lib/utils.js +30 -6
  213. package/npm-shrinkwrap.json +537 -193
  214. package/package.json +17 -14
@@ -1,42 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const semver = require("semver");
4
5
  const pkg = require("../../package.json");
5
6
  const nodeVersion = process.version;
6
7
  if (!semver.satisfies(nodeVersion, pkg.engines.node)) {
7
- console.error("Firebase CLI v" +
8
- pkg.version +
9
- " is incompatible with Node.js " +
10
- nodeVersion +
11
- " Please upgrade Node.js to version " +
12
- pkg.engines.node);
8
+ console.error(`Firebase CLI v${pkg.version} is incompatible with Node.js ${nodeVersion} Please upgrade Node.js to version ${pkg.engines.node}`);
13
9
  process.exit(1);
14
10
  }
15
- const updateNotifier = require("update-notifier")({ pkg: pkg });
11
+ const updateNotifierPkg = require("update-notifier");
16
12
  const clc = require("cli-color");
17
13
  const TerminalRenderer = require("marked-terminal");
18
- const marked = require("marked").marked;
19
- marked.setOptions({
14
+ const updateNotifier = updateNotifierPkg({ pkg: pkg });
15
+ const marked_1 = require("marked");
16
+ marked_1.marked.setOptions({
20
17
  renderer: new TerminalRenderer(),
21
18
  });
22
19
  const updateMessage = `Update available ${clc.xterm(240)("{currentVersion}")} → ${clc.green("{latestVersion}")}\n` +
23
20
  `To update to the latest version using npm, run\n${clc.cyan("npm install -g firebase-tools")}\n` +
24
- `For other CLI management options, visit the ${marked("[CLI documentation](https://firebase.google.com/docs/cli#update-cli)")}`;
21
+ `For other CLI management options, visit the ${(0, marked_1.marked)("[CLI documentation](https://firebase.google.com/docs/cli#update-cli)")}`;
25
22
  updateNotifier.notify({ defer: true, isGlobal: true, message: updateMessage });
23
+ const node_path_1 = require("node:path");
24
+ const triple_beam_1 = require("triple-beam");
25
+ const cli_color_1 = require("cli-color");
26
+ const fs = require("node:fs");
27
+ const configstore_1 = require("../configstore");
28
+ const errorOut_1 = require("../errorOut");
29
+ const handlePreviewToggles_1 = require("../handlePreviewToggles");
30
+ const logger_1 = require("../logger");
26
31
  const client = require("..");
27
- const errorOut = require("../errorOut").errorOut;
28
- const winston = require("winston");
29
- const { SPLAT } = require("triple-beam");
30
- const { logger } = require("../logger");
31
- const fs = require("fs");
32
32
  const fsutils = require("../fsutils");
33
- const path = require("path");
34
- const ansiStrip = require("cli-color/strip");
35
- const { configstore } = require("../configstore");
36
- const _ = require("lodash");
37
- let args = process.argv.slice(2);
38
- const { handlePreviewToggles } = require("../handlePreviewToggles");
39
33
  const utils = require("../utils");
34
+ const winston = require("winston");
35
+ let args = process.argv.slice(2);
40
36
  let cmd;
41
37
  function findAvailableLogFile() {
42
38
  const candidates = ["firebase-debug.log"];
@@ -44,7 +40,7 @@ function findAvailableLogFile() {
44
40
  candidates.push(`firebase-debug.${i}.log`);
45
41
  }
46
42
  for (const c of candidates) {
47
- const logFilename = path.join(process.cwd(), c);
43
+ const logFilename = (0, node_path_1.join)(process.cwd(), c);
48
44
  try {
49
45
  const fd = fs.openSync(logFilename, "r+");
50
46
  fs.closeSync(fd);
@@ -59,43 +55,43 @@ function findAvailableLogFile() {
59
55
  throw new Error("Unable to obtain permissions for firebase-debug.log");
60
56
  }
61
57
  const logFilename = findAvailableLogFile();
62
- if (!process.env.DEBUG && _.includes(args, "--debug")) {
58
+ if (!process.env.DEBUG && args.includes("--debug")) {
63
59
  process.env.DEBUG = "true";
64
60
  }
65
61
  process.env.IS_FIREBASE_CLI = "true";
66
- logger.add(new winston.transports.File({
62
+ logger_1.logger.add(new winston.transports.File({
67
63
  level: "debug",
68
64
  filename: logFilename,
69
65
  format: winston.format.printf((info) => {
70
- const segments = [info.message, ...(info[SPLAT] || [])].map(utils.tryStringify);
71
- return `[${info.level}] ${ansiStrip(segments.join(" "))}`;
66
+ const segments = [info.message, ...(info[triple_beam_1.SPLAT] || [])].map(utils.tryStringify);
67
+ return `[${info.level}] ${(0, cli_color_1.strip)(segments.join(" "))}`;
72
68
  }),
73
69
  }));
74
- logger.debug(_.repeat("-", 70));
75
- logger.debug("Command: ", process.argv.join(" "));
76
- logger.debug("CLI Version: ", pkg.version);
77
- logger.debug("Platform: ", process.platform);
78
- logger.debug("Node Version: ", process.version);
79
- logger.debug("Time: ", new Date().toString());
70
+ logger_1.logger.debug("-".repeat(70));
71
+ logger_1.logger.debug("Command: ", process.argv.join(" "));
72
+ logger_1.logger.debug("CLI Version: ", pkg.version);
73
+ logger_1.logger.debug("Platform: ", process.platform);
74
+ logger_1.logger.debug("Node Version: ", process.version);
75
+ logger_1.logger.debug("Time: ", new Date().toString());
80
76
  if (utils.envOverrides.length) {
81
- logger.debug("Env Overrides:", utils.envOverrides.join(", "));
77
+ logger_1.logger.debug("Env Overrides:", utils.envOverrides.join(", "));
82
78
  }
83
- logger.debug(_.repeat("-", 70));
84
- logger.debug();
85
- require("../fetchMOTD").fetchMOTD();
86
- process.on("exit", function (code) {
79
+ logger_1.logger.debug("-".repeat(70));
80
+ logger_1.logger.debug();
81
+ const fetchMOTD_1 = require("../fetchMOTD");
82
+ (0, fetchMOTD_1.fetchMOTD)();
83
+ process.on("exit", (code) => {
87
84
  code = process.exitCode || code;
88
85
  if (!process.env.DEBUG && code < 2 && fsutils.fileExistsSync(logFilename)) {
89
86
  fs.unlinkSync(logFilename);
90
87
  }
91
88
  if (code > 0 && process.stdout.isTTY) {
92
- const lastError = configstore.get("lastError") || 0;
89
+ const lastError = configstore_1.configstore.get("lastError") || 0;
93
90
  const timestamp = Date.now();
94
91
  if (lastError > timestamp - 120000) {
95
92
  let help;
96
93
  if (code === 1 && cmd) {
97
- const commandName = _.get(_.last(cmd.args), "_name", "[command]");
98
- help = "Having trouble? Try " + clc.bold("firebase " + commandName + " --help");
94
+ help = "Having trouble? Try " + clc.bold("firebase [command] --help");
99
95
  }
100
96
  else {
101
97
  help = "Having trouble? Try again or contact support with contents of firebase-debug.log";
@@ -105,19 +101,18 @@ process.on("exit", function (code) {
105
101
  console.log(help);
106
102
  }
107
103
  }
108
- configstore.set("lastError", timestamp);
104
+ configstore_1.configstore.set("lastError", timestamp);
109
105
  }
110
106
  else {
111
- configstore.delete("lastError");
107
+ configstore_1.configstore.delete("lastError");
112
108
  }
113
109
  });
114
- require("exit-code");
115
- process.on("uncaughtException", function (err) {
116
- errorOut(err);
110
+ process.on("uncaughtException", (err) => {
111
+ (0, errorOut_1.errorOut)(err);
117
112
  });
118
- if (!handlePreviewToggles(args)) {
113
+ if (!(0, handlePreviewToggles_1.handlePreviewToggles)(args)) {
119
114
  cmd = client.cli.parse(process.argv);
120
- args = args.filter(function (arg) {
115
+ args = args.filter((arg) => {
121
116
  return arg.indexOf("-") < 0;
122
117
  });
123
118
  if (!args.length) {
@@ -1,34 +1,45 @@
1
1
  "use strict";
2
- var _ = require("lodash");
3
- var { FirebaseError } = require("./error");
4
- module.exports = function (options) {
5
- function numFilters(targetTypes) {
6
- return _.filter(options.only, function (opt) {
7
- var optChunks = opt.split(":");
8
- return _.includes(targetTypes, optChunks[0]) && optChunks.length > 1;
9
- }).length;
10
- }
11
- function targetContainsFilter(targetTypes) {
12
- return numFilters(targetTypes) > 1;
13
- }
14
- function targetDoesNotContainFilter(targetTypes) {
15
- return numFilters(targetTypes) === 0;
16
- }
17
- return new Promise(function (resolve, reject) {
18
- if (!options.only) {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkValidTargetFilters = void 0;
4
+ const deploy_1 = require("./commands/deploy");
5
+ const error_1 = require("./error");
6
+ function targetsForTypes(only, ...types) {
7
+ return only.filter((t) => {
8
+ if (t.includes(":")) {
9
+ return types.includes(t.split(":")[0]);
10
+ }
11
+ else {
12
+ return types.includes(t);
13
+ }
14
+ });
15
+ }
16
+ function targetsHaveFilters(...targets) {
17
+ return targets.some((t) => t.includes(":"));
18
+ }
19
+ function targetsHaveNoFilters(...targets) {
20
+ return targets.some((t) => !t.includes(":"));
21
+ }
22
+ async function checkValidTargetFilters(options) {
23
+ const only = !options.only ? [] : options.only.split(",");
24
+ return new Promise((resolve, reject) => {
25
+ if (!only.length) {
19
26
  return resolve();
20
27
  }
21
28
  if (options.except) {
22
- return reject(new FirebaseError("Cannot specify both --only and --except", {
23
- exit: 1,
24
- }));
29
+ return reject(new error_1.FirebaseError("Cannot specify both --only and --except"));
25
30
  }
26
- if (targetContainsFilter(["database", "storage", "hosting"])) {
27
- return reject(new FirebaseError("Filters specified with colons (e.g. --only functions:func1,functions:func2) are only supported for functions", { exit: 1 }));
31
+ const nonFilteredTypes = deploy_1.VALID_DEPLOY_TARGETS.filter((t) => !["hosting", "functions"].includes(t));
32
+ const targetsForNonFilteredTypes = targetsForTypes(only, ...nonFilteredTypes);
33
+ if (targetsForNonFilteredTypes.length && targetsHaveFilters(...targetsForNonFilteredTypes)) {
34
+ return reject(new error_1.FirebaseError("Filters specified with colons (e.g. --only functions:func1,functions:func2) are only supported for functions and hosting"));
28
35
  }
29
- if (targetContainsFilter(["functions"]) && targetDoesNotContainFilter(["functions"])) {
30
- return reject(new FirebaseError('Cannot specify "--only functions" and "--only functions:<filter>" at the same time', { exit: 1 }));
36
+ const targetsForFunctions = targetsForTypes(only, "functions");
37
+ if (targetsForFunctions.length &&
38
+ targetsHaveFilters(...targetsForFunctions) &&
39
+ targetsHaveNoFilters(...targetsForFunctions)) {
40
+ return reject(new error_1.FirebaseError('Cannot specify "--only functions" and "--only functions:<filter>" at the same time'));
31
41
  }
32
42
  return resolve();
33
43
  });
34
- };
44
+ }
45
+ exports.checkValidTargetFilters = checkValidTargetFilters;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const fs = require("fs-extra");
4
5
  const command_1 = require("../command");
5
6
  const utils = require("../utils");
@@ -18,7 +19,7 @@ function getReleaseNotes(releaseNotes, releaseNotesFile) {
18
19
  }
19
20
  return "";
20
21
  }
21
- module.exports = new command_1.Command("appdistribution:distribute <release-binary-file>")
22
+ exports.command = new command_1.Command("appdistribution:distribute <release-binary-file>")
22
23
  .description("upload a release binary")
23
24
  .option("--app <app_id>", "the app id of your Firebase app")
24
25
  .option("--release-notes <string>", "release notes to include")
@@ -1,11 +1,12 @@
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 utils = require("../utils");
5
6
  const requireAuth_1 = require("../requireAuth");
6
7
  const client_1 = require("../appdistribution/client");
7
8
  const options_parser_util_1 = require("../appdistribution/options-parser-util");
8
- module.exports = new command_1.Command("appdistribution:testers:add [emails...]")
9
+ exports.command = new command_1.Command("appdistribution:testers:add [emails...]")
9
10
  .description("add testers to project")
10
11
  .option("--file <file>", "a path to a file containing a list of tester emails to be added")
11
12
  .before(requireAuth_1.requireAuth)
@@ -1,5 +1,6 @@
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 utils = require("../utils");
5
6
  const requireAuth_1 = require("../requireAuth");
@@ -7,7 +8,7 @@ const error_1 = require("../error");
7
8
  const client_1 = require("../appdistribution/client");
8
9
  const options_parser_util_1 = require("../appdistribution/options-parser-util");
9
10
  const logger_1 = require("../logger");
10
- module.exports = new command_1.Command("appdistribution:testers:remove [emails...]")
11
+ exports.command = new command_1.Command("appdistribution:testers:remove [emails...]")
11
12
  .description("remove testers from a project")
12
13
  .option("--file <file>", "a path to a file containing a list of tester emails to be removed")
13
14
  .before(requireAuth_1.requireAuth)
@@ -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 projectUtils_1 = require("../projectUtils");
@@ -15,7 +16,7 @@ function getCertHashType(shaHash) {
15
16
  return apps_1.ShaCertificateType.SHA_256.toString();
16
17
  return apps_1.ShaCertificateType.SHA_CERTIFICATE_TYPE_UNSPECIFIED.toString();
17
18
  }
18
- module.exports = new command_1.Command("apps:android:sha:create <appId> <shaHash>")
19
+ exports.command = new command_1.Command("apps:android:sha:create <appId> <shaHash>")
19
20
  .description("add a SHA certificate hash for a given app id.")
20
21
  .before(requireAuth_1.requireAuth)
21
22
  .action(async (appId = "", shaHash = "", options) => {
@@ -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 projectUtils_1 = require("../projectUtils");
6
7
  const apps_1 = require("../management/apps");
7
8
  const requireAuth_1 = require("../requireAuth");
8
9
  const utils_1 = require("../utils");
9
- module.exports = new command_1.Command("apps:android:sha:delete <appId> <shaId>")
10
+ exports.command = new command_1.Command("apps:android:sha:delete <appId> <shaId>")
10
11
  .description("delete a SHA certificate hash for a given app id.")
11
12
  .before(requireAuth_1.requireAuth)
12
13
  .action(async (appId = "", shaId = "", 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 Table = require("cli-table");
4
5
  const command_1 = require("../command");
5
6
  const projectUtils_1 = require("../projectUtils");
@@ -29,7 +30,7 @@ function logCertificatesCount(count = 0) {
29
30
  logger_1.logger.info("");
30
31
  logger_1.logger.info(`${count} SHA hash(es) total.`);
31
32
  }
32
- module.exports = new command_1.Command("apps:android:sha:list <appId>")
33
+ exports.command = new command_1.Command("apps:android:sha:list <appId>")
33
34
  .description("list the SHA certificate hashes for a given app id. ")
34
35
  .before(requireAuth_1.requireAuth)
35
36
  .action(async (appId = "", 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 ora = require("ora");
5
6
  const command_1 = require("../command");
@@ -121,7 +122,7 @@ async function initiateWebAppCreation(options) {
121
122
  throw err;
122
123
  }
123
124
  }
124
- module.exports = new command_1.Command("apps:create [platform] [displayName]")
125
+ exports.command = new command_1.Command("apps:create [platform] [displayName]")
125
126
  .description("create a new Firebase app. [platform] can be IOS, ANDROID or WEB (case insensitive).")
126
127
  .option("-a, --package-name <packageName>", "required package name for the Android app")
127
128
  .option("-b, --bundle-id <bundleId>", "required bundle id for the iOS app")
@@ -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 ora = require("ora");
5
6
  const Table = require("cli-table");
@@ -28,7 +29,7 @@ function logAppCount(count = 0) {
28
29
  logger_1.logger.info("");
29
30
  logger_1.logger.info(`${count} app(s) total.`);
30
31
  }
31
- module.exports = new command_1.Command("apps:list [platform]")
32
+ exports.command = new command_1.Command("apps:list [platform]")
32
33
  .description("list the registered apps of a Firebase project. " +
33
34
  "Optionally filter apps by [platform]: IOS, ANDROID or WEB (case insensitive)")
34
35
  .before(requireAuth_1.requireAuth)
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const ora = require("ora");
4
5
  const fs = require("fs-extra");
5
6
  const command_1 = require("../command");
@@ -32,7 +33,7 @@ async function selectAppInteractively(apps, appPlatform) {
32
33
  choices,
33
34
  });
34
35
  }
35
- module.exports = new command_1.Command("apps:sdkconfig [platform] [appId]")
36
+ exports.command = new command_1.Command("apps:sdkconfig [platform] [appId]")
36
37
  .description("print the Google Services config of a Firebase app. " +
37
38
  "[platform] can be IOS, ANDROID or WEB (case insensitive)")
38
39
  .option("-o, --out [file]", "(optional) write config output to a file")
@@ -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 fs = require("fs");
5
6
  const os = require("os");
@@ -9,7 +10,7 @@ const projectUtils_1 = require("../projectUtils");
9
10
  const requirePermissions_1 = require("../requirePermissions");
10
11
  const accountExporter_1 = require("../accountExporter");
11
12
  const MAX_BATCH_SIZE = 1000;
12
- exports.default = new command_1.Command("auth:export [dataFile]")
13
+ exports.command = new command_1.Command("auth:export [dataFile]")
13
14
  .description("Export accounts from your Firebase project into a data file")
14
15
  .option("--format <format>", "Format of exported data (csv, json). Ignored if <dataFile> has format extension.")
15
16
  .before(requirePermissions_1.requirePermissions, ["firebaseauth.users.get"])
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const csv_parse_1 = require("csv-parse");
4
5
  const Chain = require("stream-chain");
5
6
  const clc = require("cli-color");
@@ -11,13 +12,9 @@ const error_1 = require("../error");
11
12
  const logger_1 = require("../logger");
12
13
  const projectUtils_1 = require("../projectUtils");
13
14
  const requirePermissions_1 = require("../requirePermissions");
14
- const accountImporter = require("../accountImporter");
15
+ const accountImporter_1 = require("../accountImporter");
15
16
  const MAX_BATCH_SIZE = 1000;
16
- const validateOptions = accountImporter.validateOptions;
17
- const validateUserJson = accountImporter.validateUserJson;
18
- const transArrayToUser = accountImporter.transArrayToUser;
19
- const serialImportUsers = accountImporter.serialImportUsers;
20
- module.exports = new command_1.Command("auth:import [dataFile]")
17
+ exports.command = new command_1.Command("auth:import [dataFile]")
21
18
  .description("import users into your Firebase project from a data file(.csv or .json)")
22
19
  .option("--hash-algo <hashAlgo>", "specify the hash algorithm used in password for these accounts")
23
20
  .option("--hash-key <hashKey>", "specify the key used in hash algorithm")
@@ -32,7 +29,7 @@ module.exports = new command_1.Command("auth:import [dataFile]")
32
29
  .before(requirePermissions_1.requirePermissions, ["firebaseauth.users.create", "firebaseauth.users.update"])
33
30
  .action(async (dataFile, options) => {
34
31
  const projectId = (0, projectUtils_1.needProjectId)(options);
35
- const checkRes = validateOptions(options);
32
+ const checkRes = (0, accountImporter_1.validateOptions)(options);
36
33
  if (!checkRes.valid) {
37
34
  return checkRes;
38
35
  }
@@ -60,7 +57,7 @@ module.exports = new command_1.Command("auth:import [dataFile]")
60
57
  const str = s.trim().replace(/^["|'](.*)["|']$/, "$1");
61
58
  return str === "" ? undefined : str;
62
59
  });
63
- const user = transArrayToUser(trimmed);
60
+ const user = (0, accountImporter_1.transArrayToUser)(trimmed);
64
61
  const err = user.error;
65
62
  if (err) {
66
63
  return reject(new error_1.FirebaseError(`Line ${counter} (${record.join(",")}) has invalid data format: ${err}`));
@@ -88,7 +85,7 @@ module.exports = new command_1.Command("auth:import [dataFile]")
88
85
  StreamArray.streamArray(),
89
86
  ({ value }) => {
90
87
  counter++;
91
- const user = validateUserJson(value);
88
+ const user = (0, accountImporter_1.validateUserJson)(value);
92
89
  const err = user.error;
93
90
  if (err) {
94
91
  throw new error_1.FirebaseError(`Validation Error: ${err}`);
@@ -112,6 +109,6 @@ module.exports = new command_1.Command("auth:import [dataFile]")
112
109
  }
113
110
  logger_1.logger.debug(`Preparing to import ${counter} user records in ${userListArr.length} batches.`);
114
111
  if (userListArr.length) {
115
- return serialImportUsers(projectId, hashOptions, userListArr, 0);
112
+ return (0, accountImporter_1.serialImportUsers)(projectId, hashOptions, userListArr, 0);
116
113
  }
117
114
  });
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const fs = require("fs-extra");
4
5
  const os = require("os");
5
6
  const path = require("path");
@@ -21,7 +22,7 @@ const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
21
22
  path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
22
23
  const JAR_VERSION = "2.8.0";
23
24
  const JAR_URL = `https://dl.google.com/android/maven2/com/google/firebase/firebase-crashlytics-buildtools/${JAR_VERSION}/firebase-crashlytics-buildtools-${JAR_VERSION}.jar`;
24
- exports.default = new command_1.Command("crashlytics:symbols:upload <symbolFiles...>")
25
+ exports.command = new command_1.Command("crashlytics:symbols:upload <symbolFiles...>")
25
26
  .description("Upload symbols for native code, to symbolicate stack traces.")
26
27
  .option("--app <appID>", "the app id of your Firebase app")
27
28
  .option("--generator [breakpad|csym]", "the symbol generator being used, defaults to breakpad.")
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
3
4
  const fs = require("fs");
4
5
  const url = require("url");
5
6
  const apiv2_1 = require("../apiv2");
@@ -12,7 +13,7 @@ const api_1 = require("../database/api");
12
13
  const requirePermissions_1 = require("../requirePermissions");
13
14
  const logger_1 = require("../logger");
14
15
  const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
15
- const responseToError = require("../responseToError");
16
+ const responseToError_1 = require("../responseToError");
16
17
  const utils = require("../utils");
17
18
  function applyStringOpts(dest, src, keys, jsonKeys) {
18
19
  for (const key of keys) {
@@ -33,7 +34,7 @@ function applyStringOpts(dest, src, keys, jsonKeys) {
33
34
  }
34
35
  }
35
36
  }
36
- exports.default = new command_1.Command("database:get <path>")
37
+ exports.command = new command_1.Command("database:get <path>")
37
38
  .description("fetch and print JSON data at the specified path")
38
39
  .option("-o, --output <filename>", "save output to the specified file")
39
40
  .option("--pretty", "pretty print response")
@@ -98,7 +99,7 @@ exports.default = new command_1.Command("database:get <path>")
98
99
  catch (e) {
99
100
  throw new error_1.FirebaseError("Malformed JSON response", { original: e, exit: 2 });
100
101
  }
101
- throw responseToError({ statusCode: res.status }, d);
102
+ throw (0, responseToError_1.responseToError)({ statusCode: res.status }, d);
102
103
  }
103
104
  res.body.pipe(outStream, { end: false });
104
105
  return new Promise((resolve) => {
@@ -1,5 +1,6 @@
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 logger_1 = require("../logger");
5
6
  const requirePermissions_1 = require("../requirePermissions");
@@ -10,7 +11,7 @@ const projectUtils_1 = require("../projectUtils");
10
11
  const getDefaultDatabaseInstance_1 = require("../getDefaultDatabaseInstance");
11
12
  const error_1 = require("../error");
12
13
  const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
13
- exports.default = new command_1.Command("database:instances:create <instanceName>")
14
+ exports.command = new command_1.Command("database:instances:create <instanceName>")
14
15
  .description("create a realtime database instance")
15
16
  .option("-l, --location <location>", "(optional) location for the database instance, defaults to us-central1")
16
17
  .before(requirePermissions_1.requirePermissions, ["firebasedatabase.instances.create"])
@@ -1,5 +1,6 @@
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 Table = require("cli-table");
5
6
  const clc = require("cli-color");
@@ -32,7 +33,7 @@ function logInstancesCount(count = 0) {
32
33
  logger_1.logger.info("");
33
34
  logger_1.logger.info(`${count} database instance(s) total.`);
34
35
  }
35
- let cmd = new command_1.Command("database:instances:list")
36
+ exports.command = new command_1.Command("database:instances:list")
36
37
  .description("list realtime database instances, optionally filtered by a specified location")
37
38
  .before(requirePermissions_1.requirePermissions, ["firebasedatabase.instances.list"])
38
39
  .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.DATABASE)
@@ -71,6 +72,5 @@ let cmd = new command_1.Command("database:instances:list")
71
72
  return instances;
72
73
  });
73
74
  if (previews_1.previews.rtdbmanagement) {
74
- cmd = cmd.option("-l, --location <location>", "(optional) location for the database instance, defaults to us-central1");
75
+ exports.command = exports.command.option("-l, --location <location>", "(optional) location for the database instance, defaults to us-central1");
75
76
  }
76
- exports.default = cmd;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const _ = require("lodash");
3
+ exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
6
6
  const database_1 = require("../management/database");
@@ -10,7 +10,7 @@ const profiler_1 = require("../profiler");
10
10
  const types_1 = require("../emulator/types");
11
11
  const commandUtils_1 = require("../emulator/commandUtils");
12
12
  const description = "profile the Realtime Database and generate a usage report";
13
- module.exports = new command_1.Command("database:profile")
13
+ exports.command = new command_1.Command("database:profile")
14
14
  .description(description)
15
15
  .option("-o, --output <filename>", "save the output to the specified file")
16
16
  .option("-d, --duration <seconds>", "collect database usage information for the specified number of seconds")
@@ -32,12 +32,12 @@ module.exports = new command_1.Command("database:profile")
32
32
  else if (options.parent.json && options.raw) {
33
33
  return utils.reject("Cannot output raw data in json format", { exit: 1 });
34
34
  }
35
- else if (options.input && _.has(options, "duration")) {
35
+ else if (options.input && options.duration !== undefined) {
36
36
  return utils.reject("Cannot specify a duration for input files", {
37
37
  exit: 1,
38
38
  });
39
39
  }
40
- else if (_.has(options, "duration") && options.duration <= 0) {
40
+ else if (options.duration !== undefined && options.duration <= 0) {
41
41
  return utils.reject("Must specify a positive number of seconds", {
42
42
  exit: 1,
43
43
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const _ = require("lodash");
3
+ exports.command = void 0;
4
4
  const clc = require("cli-color");
5
5
  const fs = require("fs");
6
6
  const apiv2_1 = require("../apiv2");
@@ -15,7 +15,7 @@ const url_1 = require("url");
15
15
  const logger_1 = require("../logger");
16
16
  const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
17
17
  const utils = require("../utils");
18
- exports.default = new command_1.Command("database:push <path> [infile]")
18
+ exports.command = new command_1.Command("database:push <path> [infile]")
19
19
  .description("add a new JSON object to a list of data in your Firebase")
20
20
  .option("-d, --data <data>", "specify escaped JSON directly")
21
21
  .option("--instance <instance>", "use the database <instance>.firebaseio.com (if omitted, use default database instance)")
@@ -24,7 +24,7 @@ exports.default = new command_1.Command("database:push <path> [infile]")
24
24
  .before(database_1.populateInstanceDetails)
25
25
  .before(commandUtils_1.printNoticeIfEmulated, types_1.Emulators.DATABASE)
26
26
  .action(async (path, infile, options) => {
27
- if (!_.startsWith(path, "/")) {
27
+ if (!path.startsWith("/")) {
28
28
  throw new error_1.FirebaseError("Path must begin with /");
29
29
  }
30
30
  const inStream = utils.stringToStream(options.data) || (infile ? fs.createReadStream(infile) : process.stdin);
@@ -47,7 +47,7 @@ exports.default = new command_1.Command("database:push <path> [infile]")
47
47
  logger_1.logger.debug(err);
48
48
  throw new error_1.FirebaseError(`Unexpected error while pushing data: ${err}`, { exit: 2 });
49
49
  }
50
- if (!_.endsWith(path, "/")) {
50
+ if (!path.endsWith("/")) {
51
51
  path += "/";
52
52
  }
53
53
  const consoleUrl = utils.getDatabaseViewDataUrl(origin, options.project, options.instance, path + res.body.name);
@@ -1,5 +1,6 @@
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 requireDatabaseInstance_1 = require("../requireDatabaseInstance");
5
6
  const requirePermissions_1 = require("../requirePermissions");
@@ -11,8 +12,7 @@ const api_1 = require("../database/api");
11
12
  const utils = require("../utils");
12
13
  const prompt_1 = require("../prompt");
13
14
  const clc = require("cli-color");
14
- const _ = require("lodash");
15
- module.exports = new command_1.Command("database:remove <path>")
15
+ exports.command = new command_1.Command("database:remove <path>")
16
16
  .description("remove data from your Firebase at the specified path")
17
17
  .option("-f, --force", "pass this option to bypass confirmation prompt")
18
18
  .option("--instance <instance>", "use the database <instance>.firebaseio.com (if omitted, use default database instance)")
@@ -21,7 +21,7 @@ module.exports = new command_1.Command("database:remove <path>")
21
21
  .before(database_1.populateInstanceDetails)
22
22
  .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.DATABASE)
23
23
  .action(async (path, options) => {
24
- if (!_.startsWith(path, "/")) {
24
+ if (!path.startsWith("/")) {
25
25
  return utils.reject("Path must begin with /", { exit: 1 });
26
26
  }
27
27
  const origin = (0, api_1.realtimeOriginOrEmulatorOrCustomUrl)(options.instanceDetails.databaseUrl);