firebase-tools 11.4.2 → 11.7.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 (202) hide show
  1. package/lib/accountImporter.js +1 -1
  2. package/lib/auth.js +3 -4
  3. package/lib/bin/firebase.js +4 -4
  4. package/lib/command.js +35 -10
  5. package/lib/commands/apps-android-sha-create.js +1 -1
  6. package/lib/commands/apps-android-sha-delete.js +1 -1
  7. package/lib/commands/apps-create.js +1 -1
  8. package/lib/commands/apps-list.js +1 -1
  9. package/lib/commands/auth-export.js +1 -1
  10. package/lib/commands/auth-import.js +1 -1
  11. package/lib/commands/crashlytics-mappingfile-generateid.js +26 -0
  12. package/lib/commands/crashlytics-mappingfile-upload.js +46 -0
  13. package/lib/commands/crashlytics-symbols-upload.js +18 -87
  14. package/lib/commands/database-instances-list.js +1 -1
  15. package/lib/commands/database-push.js +1 -1
  16. package/lib/commands/database-remove.js +1 -1
  17. package/lib/commands/database-set.js +1 -1
  18. package/lib/commands/database-update.js +1 -1
  19. package/lib/commands/emulators-exec.js +4 -1
  20. package/lib/commands/emulators-export.js +5 -2
  21. package/lib/commands/emulators-start.js +24 -18
  22. package/lib/commands/ext-dev-deprecate.js +1 -1
  23. package/lib/commands/ext-dev-emulators-exec.js +1 -1
  24. package/lib/commands/ext-dev-emulators-start.js +1 -1
  25. package/lib/commands/ext-dev-extension-delete.js +1 -1
  26. package/lib/commands/ext-dev-list.js +1 -1
  27. package/lib/commands/ext-dev-publish.js +4 -1
  28. package/lib/commands/ext-dev-register.js +1 -1
  29. package/lib/commands/ext-dev-undeprecate.js +1 -1
  30. package/lib/commands/ext-dev-unpublish.js +1 -1
  31. package/lib/commands/ext-dev-usage.js +1 -1
  32. package/lib/commands/ext-info.js +1 -1
  33. package/lib/commands/ext-install.js +2 -2
  34. package/lib/commands/ext-update.js +1 -1
  35. package/lib/commands/ext.js +1 -1
  36. package/lib/commands/firestore-delete.js +2 -2
  37. package/lib/commands/firestore-indexes-list.js +3 -3
  38. package/lib/commands/functions-config-clone.js +1 -1
  39. package/lib/commands/functions-config-export.js +1 -1
  40. package/lib/commands/functions-config-set.js +1 -1
  41. package/lib/commands/functions-config-unset.js +1 -1
  42. package/lib/commands/functions-delete.js +3 -1
  43. package/lib/commands/functions-secrets-get.js +2 -0
  44. package/lib/commands/functions-secrets-set.js +1 -1
  45. package/lib/commands/help.js +1 -1
  46. package/lib/commands/hosting-channel-create.js +5 -5
  47. package/lib/commands/hosting-channel-delete.js +3 -3
  48. package/lib/commands/hosting-channel-deploy.js +6 -6
  49. package/lib/commands/hosting-channel-list.js +2 -2
  50. package/lib/commands/hosting-channel-open.js +2 -2
  51. package/lib/commands/hosting-clone.js +8 -8
  52. package/lib/commands/hosting-disable.js +1 -1
  53. package/lib/commands/hosting-sites-create.js +4 -4
  54. package/lib/commands/hosting-sites-delete.js +4 -4
  55. package/lib/commands/hosting-sites-list.js +2 -2
  56. package/lib/commands/index.js +3 -0
  57. package/lib/commands/init.js +5 -5
  58. package/lib/commands/login-add.js +1 -1
  59. package/lib/commands/login-ci.js +2 -2
  60. package/lib/commands/login-list.js +1 -1
  61. package/lib/commands/login-use.js +1 -1
  62. package/lib/commands/login.js +3 -3
  63. package/lib/commands/logout.js +1 -1
  64. package/lib/commands/open.js +3 -3
  65. package/lib/commands/projects-list.js +2 -2
  66. package/lib/commands/serve.js +1 -1
  67. package/lib/commands/target-apply.js +1 -1
  68. package/lib/commands/target-clear.js +1 -1
  69. package/lib/commands/target-remove.js +1 -1
  70. package/lib/commands/target.js +1 -1
  71. package/lib/commands/use.js +7 -7
  72. package/lib/config.js +1 -1
  73. package/lib/crashlytics/buildToolsJarHelper.js +51 -0
  74. package/lib/deploy/database/prepare.js +3 -3
  75. package/lib/deploy/database/release.js +3 -3
  76. package/lib/deploy/extensions/deploymentSummary.js +1 -1
  77. package/lib/deploy/extensions/errors.js +1 -1
  78. package/lib/deploy/extensions/secrets.js +1 -1
  79. package/lib/deploy/extensions/tasks.js +2 -2
  80. package/lib/deploy/firestore/deploy.js +2 -2
  81. package/lib/deploy/firestore/prepare.js +2 -2
  82. package/lib/deploy/functions/backend.js +4 -4
  83. package/lib/deploy/functions/build.js +78 -8
  84. package/lib/deploy/functions/checkIam.js +9 -8
  85. package/lib/deploy/functions/containerCleaner.js +2 -2
  86. package/lib/deploy/functions/deploy.js +2 -2
  87. package/lib/deploy/functions/ensure.js +1 -1
  88. package/lib/deploy/functions/params.js +15 -15
  89. package/lib/deploy/functions/prepare.js +1 -1
  90. package/lib/deploy/functions/prepareFunctionsUpload.js +2 -2
  91. package/lib/deploy/functions/prompts.js +1 -1
  92. package/lib/deploy/functions/release/fabricator.js +24 -7
  93. package/lib/deploy/functions/release/index.js +3 -1
  94. package/lib/deploy/functions/release/reporter.js +1 -1
  95. package/lib/deploy/functions/runtimes/discovery/index.js +1 -16
  96. package/lib/deploy/functions/runtimes/discovery/parsing.js +16 -0
  97. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +59 -131
  98. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +1 -1
  99. package/lib/deploy/functions/runtimes/node/parseTriggers.js +2 -6
  100. package/lib/deploy/functions/runtimes/node/versioning.js +4 -4
  101. package/lib/deploy/functions/validate.js +1 -1
  102. package/lib/deploy/hosting/deploy.js +10 -9
  103. package/lib/deploy/hosting/uploader.js +2 -2
  104. package/lib/deploy/hosting/validate.js +2 -2
  105. package/lib/deploy/index.js +7 -7
  106. package/lib/deploy/lifecycleHooks.js +5 -2
  107. package/lib/deploy/storage/prepare.js +5 -3
  108. package/lib/deploy/storage/release.js +7 -6
  109. package/lib/emulator/auth/index.js +7 -2
  110. package/lib/emulator/auth/operations.js +10 -10
  111. package/lib/emulator/commandUtils.js +33 -16
  112. package/lib/emulator/constants.js +14 -6
  113. package/lib/emulator/controller.js +50 -18
  114. package/lib/emulator/databaseEmulator.js +1 -1
  115. package/lib/emulator/downloadableEmulators.js +8 -8
  116. package/lib/emulator/emulatorLogger.js +1 -1
  117. package/lib/emulator/eventarcEmulator.js +148 -0
  118. package/lib/emulator/extensionsEmulator.js +5 -3
  119. package/lib/emulator/firestoreEmulator.js +1 -1
  120. package/lib/emulator/functionsEmulator.js +66 -14
  121. package/lib/emulator/functionsEmulatorRuntime.js +12 -23
  122. package/lib/emulator/functionsEmulatorShared.js +6 -1
  123. package/lib/emulator/hub.js +7 -3
  124. package/lib/emulator/hubClient.js +2 -2
  125. package/lib/emulator/hubExport.js +22 -2
  126. package/lib/emulator/loggingEmulator.js +2 -2
  127. package/lib/emulator/registry.js +1 -0
  128. package/lib/emulator/storage/apis/firebase.js +26 -12
  129. package/lib/emulator/storage/apis/gcloud.js +15 -8
  130. package/lib/emulator/storage/files.js +21 -4
  131. package/lib/emulator/storage/multipart.js +6 -5
  132. package/lib/emulator/storage/rules/runtime.js +3 -3
  133. package/lib/emulator/storage/rules/utils.js +4 -2
  134. package/lib/emulator/storage/server.js +2 -1
  135. package/lib/emulator/storage/upload.js +1 -0
  136. package/lib/emulator/types.js +4 -0
  137. package/lib/emulator/ui.js +7 -2
  138. package/lib/ensureApiEnabled.js +7 -7
  139. package/lib/extensions/askUserForConsent.js +1 -1
  140. package/lib/extensions/askUserForEventsConfig.js +1 -1
  141. package/lib/extensions/askUserForParam.js +1 -1
  142. package/lib/extensions/changelog.js +2 -2
  143. package/lib/extensions/checkProjectBilling.js +2 -2
  144. package/lib/extensions/displayExtensionInfo.js +1 -1
  145. package/lib/extensions/extensionsApi.js +3 -2
  146. package/lib/extensions/extensionsHelper.js +30 -2
  147. package/lib/extensions/listExtensions.js +1 -1
  148. package/lib/extensions/manifest.js +1 -1
  149. package/lib/extensions/metricsUtils.js +1 -1
  150. package/lib/extensions/paramHelper.js +1 -1
  151. package/lib/extensions/updateHelper.js +2 -2
  152. package/lib/extensions/warnings.js +2 -2
  153. package/lib/fetchMOTD.js +1 -1
  154. package/lib/firestore/delete.js +1 -1
  155. package/lib/firestore/indexes.js +2 -2
  156. package/lib/firestore/validator.js +1 -1
  157. package/lib/functions/env.js +11 -11
  158. package/lib/functions/runtimeConfigExport.js +1 -1
  159. package/lib/functionsConfig.js +1 -1
  160. package/lib/functionsConfigClone.js +1 -1
  161. package/lib/functionsShellCommandAction.js +1 -1
  162. package/lib/gcp/cloudfunctions.js +3 -3
  163. package/lib/gcp/cloudfunctionsv2.js +5 -5
  164. package/lib/gcp/cloudscheduler.js +63 -22
  165. package/lib/gcp/cloudtasks.js +17 -1
  166. package/lib/gcp/serviceusage.js +2 -2
  167. package/lib/handlePreviewToggles.js +4 -4
  168. package/lib/hosting/implicitInit.js +1 -1
  169. package/lib/hosting/normalizedHostingConfigs.js +3 -3
  170. package/lib/index.js +2 -2
  171. package/lib/init/features/database.js +1 -1
  172. package/lib/init/features/emulators.js +1 -1
  173. package/lib/init/features/firestore/index.js +2 -2
  174. package/lib/init/features/firestore/indexes.js +1 -1
  175. package/lib/init/features/firestore/rules.js +1 -1
  176. package/lib/init/features/functions/golang.js +1 -1
  177. package/lib/init/features/functions/index.js +8 -1
  178. package/lib/init/features/hosting/github.js +9 -9
  179. package/lib/init/features/hosting/index.js +1 -1
  180. package/lib/init/features/project.js +1 -1
  181. package/lib/init/features/remoteconfig.js +1 -1
  182. package/lib/init/features/storage.js +1 -1
  183. package/lib/init/index.js +1 -1
  184. package/lib/logError.js +3 -3
  185. package/lib/management/projects.js +1 -1
  186. package/lib/parseBoltRules.js +1 -1
  187. package/lib/profileReport.js +2 -2
  188. package/lib/projectUtils.js +1 -1
  189. package/lib/rc.js +1 -1
  190. package/lib/requireAuth.js +1 -1
  191. package/lib/requireDatabaseInstance.js +2 -2
  192. package/lib/requirePermissions.js +2 -2
  193. package/lib/rulesDeploy.js +11 -12
  194. package/lib/serve/hosting.js +2 -1
  195. package/lib/serve/index.js +15 -0
  196. package/lib/track.js +122 -3
  197. package/lib/utils.js +24 -11
  198. package/npm-shrinkwrap.json +523 -294
  199. package/package.json +6 -4
  200. package/schema/firebase-config.json +12 -0
  201. package/templates/extensions/CHANGELOG.md +1 -7
  202. package/templates/hosting/init.js +6 -2
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serialImportUsers = exports.validateUserJson = exports.validateOptions = exports.transArrayToUser = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const apiv2_1 = require("./apiv2");
6
6
  const api_1 = require("./api");
7
7
  const logger_1 = require("./logger");
package/lib/auth.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logout = exports.getAccessToken = exports.findAccountByEmail = exports.loginGithub = exports.loginGoogle = exports.setGlobalDefaultAccount = exports.setProjectAccount = exports.loginAdditionalAccount = exports.selectAccount = exports.setRefreshToken = exports.setActiveAccount = exports.getAllAccounts = exports.getAdditionalAccounts = exports.getProjectDefaultAccount = exports.getGlobalDefaultAccount = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const FormData = require("form-data");
6
6
  const fs = require("fs");
7
7
  const http = require("http");
@@ -21,7 +21,6 @@ const scopes = require("./scopes");
21
21
  const defaultCredentials_1 = require("./defaultCredentials");
22
22
  const uuid_1 = require("uuid");
23
23
  const crypto_1 = require("crypto");
24
- const cli_color_1 = require("cli-color");
25
24
  const track_1 = require("./track");
26
25
  const api_1 = require("./api");
27
26
  portfinder.basePort = 9005;
@@ -294,7 +293,7 @@ async function loginRemotely() {
294
293
  logger_1.logger.info();
295
294
  logger_1.logger.info("1. Take note of your session ID:");
296
295
  logger_1.logger.info();
297
- logger_1.logger.info(` ${(0, cli_color_1.bold)(sessionId.substring(0, 5).toUpperCase())}`);
296
+ logger_1.logger.info(` ${clc.bold(sessionId.substring(0, 5).toUpperCase())}`);
298
297
  logger_1.logger.info();
299
298
  logger_1.logger.info("2. Visit the URL below on any device and follow the instructions to get your code:");
300
299
  logger_1.logger.info();
@@ -366,7 +365,7 @@ async function loginWithLocalhost(port, callbackUrl, authUrl, successTemplate, g
366
365
  server.listen(port, () => {
367
366
  logger_1.logger.info();
368
367
  logger_1.logger.info("Visit this URL on this device to log in:");
369
- logger_1.logger.info(clc.bold.underline(authUrl));
368
+ logger_1.logger.info(clc.bold(clc.underline(authUrl)));
370
369
  logger_1.logger.info();
371
370
  logger_1.logger.info("Waiting for authentication...");
372
371
  open(authUrl);
@@ -9,20 +9,20 @@ if (!semver.satisfies(nodeVersion, pkg.engines.node)) {
9
9
  process.exit(1);
10
10
  }
11
11
  const updateNotifierPkg = require("update-notifier");
12
- const clc = require("cli-color");
12
+ const clc = require("colorette");
13
13
  const TerminalRenderer = require("marked-terminal");
14
14
  const updateNotifier = updateNotifierPkg({ pkg: pkg });
15
15
  const marked_1 = require("marked");
16
16
  marked_1.marked.setOptions({
17
17
  renderer: new TerminalRenderer(),
18
18
  });
19
- const updateMessage = `Update available ${clc.xterm(240)("{currentVersion}")} → ${clc.green("{latestVersion}")}\n` +
19
+ const updateMessage = `Update available ${clc.gray("{currentVersion}")} → ${clc.green("{latestVersion}")}\n` +
20
20
  `To update to the latest version using npm, run\n${clc.cyan("npm install -g firebase-tools")}\n` +
21
21
  `For other CLI management options, visit the ${(0, marked_1.marked)("[CLI documentation](https://firebase.google.com/docs/cli#update-cli)")}`;
22
22
  updateNotifier.notify({ defer: true, isGlobal: true, message: updateMessage });
23
23
  const node_path_1 = require("node:path");
24
24
  const triple_beam_1 = require("triple-beam");
25
- const cli_color_1 = require("cli-color");
25
+ const stripAnsi = require("strip-ansi");
26
26
  const fs = require("node:fs");
27
27
  const configstore_1 = require("../configstore");
28
28
  const errorOut_1 = require("../errorOut");
@@ -64,7 +64,7 @@ logger_1.logger.add(new winston.transports.File({
64
64
  filename: logFilename,
65
65
  format: winston.format.printf((info) => {
66
66
  const segments = [info.message, ...(info[triple_beam_1.SPLAT] || [])].map(utils.tryStringify);
67
- return `[${info.level}] ${(0, cli_color_1.strip)(segments.join(" "))}`;
67
+ return `[${info.level}] ${stripAnsi(segments.join(" "))}`;
68
68
  }),
69
69
  }));
70
70
  logger_1.logger.debug("-".repeat(70));
package/lib/command.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateProjectId = exports.Command = void 0;
4
- const cli_color_1 = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const lodash_1 = require("lodash");
6
6
  const error_1 = require("./error");
7
7
  const utils_1 = require("./utils");
@@ -10,7 +10,6 @@ const config_1 = require("./config");
10
10
  const configstore_1 = require("./configstore");
11
11
  const detectProjectRoot_1 = require("./detectProjectRoot");
12
12
  const track_1 = require("./track");
13
- const clc = require("cli-color");
14
13
  const auth_1 = require("./auth");
15
14
  const projects_1 = require("./management/projects");
16
15
  const requireAuth_1 = require("./requireAuth");
@@ -71,22 +70,39 @@ class Command {
71
70
  this.positionalArgs = cmd._args;
72
71
  cmd.action((...args) => {
73
72
  const runner = this.runner();
74
- const start = new Date().getTime();
73
+ const start = process.uptime();
75
74
  const options = (0, lodash_1.last)(args);
76
75
  if (args.length - 1 > cmd._args.length) {
77
- client.errorOut(new error_1.FirebaseError(`Too many arguments. Run ${(0, cli_color_1.bold)("firebase help " + this.name)} for usage instructions`, { exit: 1 }));
76
+ client.errorOut(new error_1.FirebaseError(`Too many arguments. Run ${clc.bold("firebase help " + this.name)} for usage instructions`, { exit: 1 }));
78
77
  return;
79
78
  }
79
+ const isEmulator = this.name.includes("emulator") || this.name === "serve";
80
+ if (isEmulator) {
81
+ void (0, track_1.trackEmulator)("command_start", { command_name: this.name });
82
+ }
80
83
  runner(...args)
81
- .then((result) => {
84
+ .then(async (result) => {
82
85
  if ((0, utils_1.getInheritedOption)(options, "json")) {
83
86
  console.log(JSON.stringify({
84
87
  status: "success",
85
88
  result: result,
86
89
  }, null, 2));
87
90
  }
88
- const duration = new Date().getTime() - start;
89
- void (0, track_1.track)(this.name, "success", duration).then(() => process.exit());
91
+ const duration = Math.floor((process.uptime() - start) * 1000);
92
+ const trackSuccess = (0, track_1.track)(this.name, "success", duration);
93
+ if (!isEmulator) {
94
+ await (0, utils_1.withTimeout)(5000, trackSuccess);
95
+ }
96
+ else {
97
+ await (0, utils_1.withTimeout)(5000, Promise.all([
98
+ trackSuccess,
99
+ (0, track_1.trackEmulator)("command_success", {
100
+ command_name: this.name,
101
+ duration,
102
+ }),
103
+ ]));
104
+ }
105
+ process.exit();
90
106
  })
91
107
  .catch(async (err) => {
92
108
  if ((0, utils_1.getInheritedOption)(options, "json")) {
@@ -95,9 +111,18 @@ class Command {
95
111
  error: err.message,
96
112
  }, null, 2));
97
113
  }
98
- const duration = Date.now() - start;
99
- const errorEvent = err.exit === 1 ? "Error (User)" : "Error (Unexpected)";
100
- await Promise.all([(0, track_1.track)(this.name, "error", duration), (0, track_1.track)(errorEvent, "", duration)]);
114
+ const duration = Math.floor((process.uptime() - start) * 1000);
115
+ await (0, utils_1.withTimeout)(5000, Promise.all([
116
+ (0, track_1.track)(this.name, "error", duration),
117
+ (0, track_1.track)(err.exit === 1 ? "Error (User)" : "Error (Unexpected)", "", duration),
118
+ isEmulator
119
+ ? (0, track_1.trackEmulator)("command_error", {
120
+ command_name: this.name,
121
+ duration,
122
+ error_type: err.exit === 1 ? "user" : "unexpected",
123
+ })
124
+ : Promise.resolve(),
125
+ ]));
101
126
  client.errorOut(err);
102
127
  });
103
128
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const command_1 = require("../command");
6
6
  const projectUtils_1 = require("../projectUtils");
7
7
  const apps_1 = require("../management/apps");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const command_1 = require("../command");
6
6
  const projectUtils_1 = require("../projectUtils");
7
7
  const apps_1 = require("../management/apps");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const ora = require("ora");
6
6
  const command_1 = require("../command");
7
7
  const projectUtils_1 = require("../projectUtils");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const ora = require("ora");
6
6
  const Table = require("cli-table");
7
7
  const command_1 = require("../command");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const fs = require("fs");
6
6
  const os = require("os");
7
7
  const command_1 = require("../command");
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const csv_parse_1 = require("csv-parse");
5
5
  const Chain = require("stream-chain");
6
- const clc = require("cli-color");
6
+ const clc = require("colorette");
7
7
  const fs = require("fs-extra");
8
8
  const Pick = require("stream-json/filters/Pick");
9
9
  const StreamArray = require("stream-json/streamers/StreamArray");
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const command_1 = require("../command");
5
+ const utils = require("../utils");
6
+ const buildToolsJarHelper_1 = require("../crashlytics/buildToolsJarHelper");
7
+ const error_1 = require("../error");
8
+ exports.command = new command_1.Command("crashlytics:mappingfile:generateid")
9
+ .description("generate a mapping file id and write it to an Android resource file, which will be built into the app")
10
+ .option("--resource-file <resourceFile>", "path to the Android resource XML file that will be created or updated.")
11
+ .action(async (options) => {
12
+ const debug = !!options.debug;
13
+ const resourceFilePath = options.resourceFile;
14
+ if (!resourceFilePath) {
15
+ throw new error_1.FirebaseError("set --resource-file <resourceFile> to an Android resource file path, e.g. app/src/main/res/values/crashlytics.xml");
16
+ }
17
+ const jarFile = await (0, buildToolsJarHelper_1.fetchBuildtoolsJar)();
18
+ const jarOptions = { resourceFilePath };
19
+ utils.logBullet(`Updating resource file: ${resourceFilePath}`);
20
+ const generateIdArgs = buildArgs(jarOptions);
21
+ (0, buildToolsJarHelper_1.runBuildtoolsCommand)(jarFile, generateIdArgs, debug);
22
+ utils.logBullet("Successfully updated mapping file id");
23
+ });
24
+ function buildArgs(options) {
25
+ return ["-injectMappingFileIdIntoResource", options.resourceFilePath, "-verbose"];
26
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const command_1 = require("../command");
5
+ const error_1 = require("../error");
6
+ const utils = require("../utils");
7
+ const buildToolsJarHelper_1 = require("../crashlytics/buildToolsJarHelper");
8
+ exports.command = new command_1.Command("crashlytics:mappingfile:upload <mappingFile>")
9
+ .description("upload a ProGuard/R8-compatible mapping file to deobfuscate stack traces")
10
+ .option("--app <appID>", "the app id of your Firebase app")
11
+ .option("--resource-file <resourceFile>", "path to the Android resource XML file that includes the mapping file id")
12
+ .action(async (mappingFile, options) => {
13
+ const app = getGoogleAppID(options);
14
+ const debug = !!options.debug;
15
+ if (!mappingFile) {
16
+ throw new error_1.FirebaseError("set `--mapping-file <mappingFile>` to a valid mapping file path, e.g. app/build/outputs/mapping.txt");
17
+ }
18
+ const mappingFilePath = mappingFile;
19
+ const resourceFilePath = options.resourceFile;
20
+ if (!resourceFilePath) {
21
+ throw new error_1.FirebaseError("set --resource-file <resourceFile> to a valid Android resource file path, e.g. app/main/res/values/strings.xml");
22
+ }
23
+ const jarFile = await (0, buildToolsJarHelper_1.fetchBuildtoolsJar)();
24
+ const jarOptions = { app, mappingFilePath, resourceFilePath };
25
+ utils.logBullet(`Uploading mapping file: ${mappingFilePath}`);
26
+ const uploadArgs = buildArgs(jarOptions);
27
+ (0, buildToolsJarHelper_1.runBuildtoolsCommand)(jarFile, uploadArgs, debug);
28
+ utils.logBullet("Successfully uploaded mapping file");
29
+ });
30
+ function getGoogleAppID(options) {
31
+ if (!options.app) {
32
+ throw new error_1.FirebaseError("set --app <appId> to a valid Firebase application id, e.g. 1:00000000:android:0000000");
33
+ }
34
+ return options.app;
35
+ }
36
+ function buildArgs(options) {
37
+ return [
38
+ "-uploadMappingFile",
39
+ options.mappingFilePath,
40
+ "-resourceFile",
41
+ options.resourceFilePath,
42
+ "-googleAppId",
43
+ options.app,
44
+ "-verbose",
45
+ ];
46
+ }
@@ -1,44 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const fs = require("fs-extra");
5
4
  const os = require("os");
6
5
  const path = require("path");
7
- const spawn = require("cross-spawn");
8
6
  const uuid = require("uuid");
9
7
  const command_1 = require("../command");
10
- const downloadUtils = require("../downloadUtils");
11
8
  const error_1 = require("../error");
12
- const logger_1 = require("../logger");
13
- const rimraf = require("rimraf");
14
9
  const utils = require("../utils");
10
+ const buildToolsJarHelper_1 = require("../crashlytics/buildToolsJarHelper");
15
11
  var SymbolGenerator;
16
12
  (function (SymbolGenerator) {
17
13
  SymbolGenerator["breakpad"] = "breakpad";
18
14
  SymbolGenerator["csym"] = "csym";
19
15
  })(SymbolGenerator || (SymbolGenerator = {}));
20
16
  const SYMBOL_CACHE_ROOT_DIR = process.env.FIREBASE_CRASHLYTICS_CACHE_PATH || os.tmpdir();
21
- const JAR_CACHE_DIR = process.env.FIREBASE_CRASHLYTICS_BUILDTOOLS_PATH ||
22
- path.join(os.homedir(), ".cache", "firebase", "crashlytics", "buildtools");
23
- const JAR_VERSION = "2.8.0";
24
- const JAR_URL = `https://dl.google.com/android/maven2/com/google/firebase/firebase-crashlytics-buildtools/${JAR_VERSION}/firebase-crashlytics-buildtools-${JAR_VERSION}.jar`;
25
17
  exports.command = new command_1.Command("crashlytics:symbols:upload <symbolFiles...>")
26
- .description("Upload symbols for native code, to symbolicate stack traces.")
18
+ .description("upload symbols for native code, to symbolicate stack traces")
27
19
  .option("--app <appID>", "the app id of your Firebase app")
28
- .option("--generator [breakpad|csym]", "the symbol generator being used, defaults to breakpad.")
20
+ .option("--generator [breakpad|csym]", "the symbol generator being used, default is breakpad")
29
21
  .option("--dry-run", "generate symbols without uploading them")
30
- .option("--debug", "print debug output and logging from the underlying uploader tool")
31
22
  .action(async (symbolFiles, options) => {
32
- const app = getGoogleAppID(options) || "";
23
+ const app = getGoogleAppID(options);
33
24
  const generator = getSymbolGenerator(options);
34
25
  const dryRun = !!options.dryRun;
35
26
  const debug = !!options.debug;
36
- let jarFile = await downloadBuiltoolsJar();
37
- if (process.env.LOCAL_JAR) {
38
- jarFile = process.env.LOCAL_JAR;
39
- }
27
+ const jarFile = await (0, buildToolsJarHelper_1.fetchBuildtoolsJar)();
40
28
  const jarOptions = {
41
- jarFile,
42
29
  app,
43
30
  generator,
44
31
  cachePath: path.join(SYMBOL_CACHE_ROOT_DIR, `crashlytics-${uuid.v4()}`, "nativeSymbols", app.replace(/:/g, "-"), generator),
@@ -48,32 +35,22 @@ exports.command = new command_1.Command("crashlytics:symbols:upload <symbolFiles
48
35
  for (const symbolFile of symbolFiles) {
49
36
  utils.logBullet(`Generating symbols for ${symbolFile}`);
50
37
  const generateArgs = buildArgs(Object.assign(Object.assign({}, jarOptions), { symbolFile }));
51
- const output = runJar(generateArgs, debug);
52
- if (output.length > 0) {
53
- utils.logBullet(output);
54
- }
55
- else {
56
- utils.logBullet(`Generated symbols for ${symbolFile}`);
57
- utils.logBullet(`Output Path: ${jarOptions.cachePath}`);
58
- }
38
+ (0, buildToolsJarHelper_1.runBuildtoolsCommand)(jarFile, generateArgs, debug);
39
+ utils.logBullet(`Generated symbols for ${symbolFile}`);
40
+ utils.logBullet(`Output Path: ${jarOptions.cachePath}`);
59
41
  }
60
42
  if (dryRun) {
61
43
  utils.logBullet("Skipping upload because --dry-run was passed");
62
44
  return;
63
45
  }
64
- utils.logBullet(`Uploading all generated symbols`);
46
+ utils.logBullet(`Uploading all generated symbols...`);
65
47
  const uploadArgs = buildArgs(Object.assign(Object.assign({}, jarOptions), { generate: false }));
66
- const output = runJar(uploadArgs, debug);
67
- if (output.length > 0) {
68
- utils.logBullet(output);
69
- }
70
- else {
71
- utils.logBullet("Successfully uploaded all symbols");
72
- }
48
+ (0, buildToolsJarHelper_1.runBuildtoolsCommand)(jarFile, uploadArgs, debug);
49
+ utils.logBullet("Successfully uploaded all symbols");
73
50
  });
74
51
  function getGoogleAppID(options) {
75
52
  if (!options.app) {
76
- throw new error_1.FirebaseError("set the --app option to a valid Firebase app id and try again");
53
+ throw new error_1.FirebaseError("set --app <appId> to a valid Firebase application id, e.g. 1:00000000:android:0000000");
77
54
  }
78
55
  return options.app;
79
56
  }
@@ -86,62 +63,16 @@ function getSymbolGenerator(options) {
86
63
  }
87
64
  return options.generator;
88
65
  }
89
- async function downloadBuiltoolsJar() {
90
- const jarPath = path.join(JAR_CACHE_DIR, `crashlytics-buildtools-${JAR_VERSION}.jar`);
91
- if (fs.existsSync(jarPath)) {
92
- logger_1.logger.debug(`Buildtools Jar already downloaded at ${jarPath}`);
93
- return jarPath;
94
- }
95
- if (fs.existsSync(JAR_CACHE_DIR)) {
96
- logger_1.logger.debug(`Deleting Jar cache at ${JAR_CACHE_DIR} because the CLI was run with a newer Jar version`);
97
- rimraf.sync(JAR_CACHE_DIR);
98
- }
99
- utils.logBullet("Downloading buildtools.jar to " + jarPath);
100
- utils.logBullet("For open source licenses used by this command, look in the META-INF directory in the buildtools.jar file");
101
- const tmpfile = await downloadUtils.downloadToTmp(JAR_URL);
102
- fs.mkdirSync(JAR_CACHE_DIR, { recursive: true });
103
- fs.copySync(tmpfile, jarPath);
104
- return jarPath;
105
- }
106
66
  function buildArgs(options) {
107
67
  const baseArgs = [
108
- "-jar",
109
- options.jarFile,
110
- `-symbolGenerator=${options.generator}`,
111
- `-symbolFileCacheDir=${options.cachePath}`,
68
+ "-symbolGenerator",
69
+ options.generator,
70
+ "-symbolFileCacheDir",
71
+ options.cachePath,
112
72
  "-verbose",
113
73
  ];
114
74
  if (options.generate) {
115
- return baseArgs.concat(["-generateNativeSymbols", `-unstrippedLibrary=${options.symbolFile}`]);
116
- }
117
- return baseArgs.concat([
118
- "-uploadNativeSymbols",
119
- `-googleAppId=${options.app}`,
120
- ]);
121
- }
122
- function runJar(args, debug) {
123
- var _a, _b, _c;
124
- const outputs = spawn.sync("java", args, {
125
- stdio: debug ? "inherit" : "pipe",
126
- });
127
- if (outputs.status || 0 > 0) {
128
- if (!debug) {
129
- utils.logWarning(((_a = outputs.stdout) === null || _a === void 0 ? void 0 : _a.toString()) || "An unknown error occurred");
130
- }
131
- throw new error_1.FirebaseError("Failed to upload symbols");
132
- }
133
- if (!debug) {
134
- let logRegex = /(Generated symbol file.*$)/m;
135
- let matched = (((_b = outputs.stdout) === null || _b === void 0 ? void 0 : _b.toString()) || "").match(logRegex);
136
- if (matched) {
137
- return matched[1];
138
- }
139
- logRegex = /(Crashlytics symbol file uploaded successfully.*$)/m;
140
- matched = (((_c = outputs.stdout) === null || _c === void 0 ? void 0 : _c.toString()) || "").match(logRegex);
141
- if (matched) {
142
- return matched[1];
143
- }
144
- return "";
75
+ return baseArgs.concat(["-generateNativeSymbols", "-unstrippedLibrary", options.symbolFile]);
145
76
  }
146
- return "";
77
+ return baseArgs.concat(["-uploadNativeSymbols", "-googleAppId", options.app]);
147
78
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const Table = require("cli-table");
6
- const clc = require("cli-color");
6
+ const clc = require("colorette");
7
7
  const ora = require("ora");
8
8
  const logger_1 = require("../logger");
9
9
  const requirePermissions_1 = require("../requirePermissions");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const fs = require("fs");
6
6
  const apiv2_1 = require("../apiv2");
7
7
  const command_1 = require("../command");
@@ -11,7 +11,7 @@ const database_1 = require("../management/database");
11
11
  const api_1 = require("../database/api");
12
12
  const utils = require("../utils");
13
13
  const prompt_1 = require("../prompt");
14
- const clc = require("cli-color");
14
+ const clc = require("colorette");
15
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")
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const fs = require("fs");
6
6
  const apiv2_1 = require("../apiv2");
7
7
  const command_1 = require("../command");
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const url_1 = require("url");
5
- const clc = require("cli-color");
5
+ const clc = require("colorette");
6
6
  const fs = require("fs");
7
7
  const apiv2_1 = require("../apiv2");
8
8
  const command_1 = require("../command");
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const commandUtils = require("../emulator/commandUtils");
6
+ const commandUtils_1 = require("../emulator/commandUtils");
6
7
  exports.command = new command_1.Command("emulators:exec <script>")
7
8
  .before(commandUtils.setExportOnExitOptions)
8
9
  .before(commandUtils.beforeEmulatorCommand)
@@ -12,4 +13,6 @@ exports.command = new command_1.Command("emulators:exec <script>")
12
13
  .option(commandUtils.FLAG_IMPORT, commandUtils.DESC_IMPORT)
13
14
  .option(commandUtils.FLAG_EXPORT_ON_EXIT, commandUtils.DESC_EXPORT_ON_EXIT)
14
15
  .option(commandUtils.FLAG_UI, commandUtils.DESC_UI)
15
- .action(commandUtils.emulatorExec);
16
+ .action((script, options) => {
17
+ return Promise.race([(0, commandUtils_1.shutdownWhenKilled)(options), (0, commandUtils_1.emulatorExec)(script, options)]);
18
+ });
@@ -4,8 +4,11 @@ exports.command = void 0;
4
4
  const command_1 = require("../command");
5
5
  const controller = require("../emulator/controller");
6
6
  const commandUtils = require("../emulator/commandUtils");
7
- exports.command = new command_1.Command("emulators:export <path>")
7
+ const COMMAND_NAME = "emulators:export";
8
+ exports.command = new command_1.Command(`${COMMAND_NAME} <path>`)
8
9
  .description("export data from running emulators")
9
10
  .withForce("overwrite any export data in the target directory")
10
11
  .option(commandUtils.FLAG_ONLY, commandUtils.DESC_ONLY)
11
- .action(controller.exportEmulatorData);
12
+ .action((exportPath, options) => {
13
+ return controller.exportEmulatorData(exportPath, options, COMMAND_NAME);
14
+ });
@@ -7,7 +7,7 @@ const commandUtils = require("../emulator/commandUtils");
7
7
  const logger_1 = require("../logger");
8
8
  const registry_1 = require("../emulator/registry");
9
9
  const types_1 = require("../emulator/types");
10
- const clc = require("cli-color");
10
+ const clc = require("colorette");
11
11
  const constants_1 = require("../emulator/constants");
12
12
  const utils_1 = require("../utils");
13
13
  const Table = require("cli-table");
@@ -22,16 +22,28 @@ exports.command = new command_1.Command("emulators:start")
22
22
  .option(commandUtils.FLAG_INSPECT_FUNCTIONS, commandUtils.DESC_INSPECT_FUNCTIONS)
23
23
  .option(commandUtils.FLAG_IMPORT, commandUtils.DESC_IMPORT)
24
24
  .option(commandUtils.FLAG_EXPORT_ON_EXIT, commandUtils.DESC_EXPORT_ON_EXIT)
25
- .action(async (options) => {
25
+ .action((options) => {
26
26
  const killSignalPromise = commandUtils.shutdownWhenKilled(options);
27
- let deprecationNotices;
28
- try {
29
- ({ deprecationNotices } = await controller.startAll(options));
30
- }
31
- catch (e) {
32
- await controller.cleanShutdown();
33
- throw e;
34
- }
27
+ return Promise.race([
28
+ killSignalPromise,
29
+ (async () => {
30
+ let deprecationNotices;
31
+ try {
32
+ ({ deprecationNotices } = await controller.startAll(options));
33
+ }
34
+ catch (e) {
35
+ await controller.cleanShutdown();
36
+ throw e;
37
+ }
38
+ printEmulatorOverview(options);
39
+ for (const notice of deprecationNotices) {
40
+ (0, utils_1.logLabeledWarning)("emulators", notice, "warn");
41
+ }
42
+ return killSignalPromise;
43
+ })(),
44
+ ]);
45
+ });
46
+ function printEmulatorOverview(options) {
35
47
  const reservedPorts = [];
36
48
  for (const internalEmulator of [types_1.Emulators.LOGGING]) {
37
49
  const info = registry_1.EmulatorRegistry.getInfo(internalEmulator);
@@ -71,9 +83,7 @@ exports.command = new command_1.Command("emulators:start")
71
83
  return [
72
84
  emulatorName,
73
85
  registry_1.EmulatorRegistry.getInfoHostString(info),
74
- isSupportedByUi && uiInfo
75
- ? stylizeLink(`${uiUrl}/${emulator}`)
76
- : clc.blackBright("n/a"),
86
+ isSupportedByUi && uiInfo ? stylizeLink(`${uiUrl}/${emulator}`) : clc.blackBright("n/a"),
77
87
  ];
78
88
  })
79
89
  .map((col) => col.slice(0, head.length))
@@ -93,8 +103,4 @@ ${clc.blackBright(" Other reserved ports:")} ${reservedPortsString}
93
103
  ${extensionsTable}
94
104
  Issues? Report them at ${stylizeLink("https://github.com/firebase/firebase-tools/issues")} and attach the *-debug.log files.
95
105
  `);
96
- for (const notice of deprecationNotices) {
97
- (0, utils_1.logLabeledWarning)("emulators", notice, "warn");
98
- }
99
- await killSignalPromise;
100
- });
106
+ }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const semver = require("semver");
6
6
  const refs = require("../extensions/refs");
7
7
  const utils = require("../utils");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
6
6
  const command_1 = require("../command");
7
7
  const error_1 = require("../error");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const command_1 = require("../command");
6
6
  const commandUtils = require("../emulator/commandUtils");
7
7
  const error_1 = require("../error");