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
@@ -10,6 +10,7 @@ const emulatorLogger_1 = require("../emulatorLogger");
10
10
  const types_1 = require("../types");
11
11
  const server_1 = require("./server");
12
12
  const error_1 = require("../../error");
13
+ const track_1 = require("../../track");
13
14
  class AuthEmulator {
14
15
  constructor(args) {
15
16
  this.args = args;
@@ -37,8 +38,12 @@ class AuthEmulator {
37
38
  getName() {
38
39
  return types_1.Emulators.AUTH;
39
40
  }
40
- async importData(authExportDir, projectId) {
41
- const logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATABASE);
41
+ async importData(authExportDir, projectId, options) {
42
+ void (0, track_1.trackEmulator)("emulator_import", {
43
+ initiated_by: options.initiatedBy,
44
+ emulator_name: types_1.Emulators.AUTH,
45
+ });
46
+ const logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.AUTH);
42
47
  const { host, port } = this.getInfo();
43
48
  const configPath = path.join(authExportDir, "config.json");
44
49
  const configStat = await stat(configPath);
@@ -340,7 +340,7 @@ function batchCreate(state, reqBody) {
340
340
  }
341
341
  fields.emailVerified = !!userInfo.emailVerified;
342
342
  fields.disabled = !!userInfo.disabled;
343
- if (userInfo.mfaInfo) {
343
+ if (userInfo.mfaInfo && userInfo.mfaInfo.length > 0) {
344
344
  fields.mfaInfo = [];
345
345
  (0, errors_1.assert)(fields.email, "Second factor account requires email to be presented.");
346
346
  (0, errors_1.assert)(fields.emailVerified, "Second factor account requires email to be verified.");
@@ -1716,14 +1716,14 @@ function fakeFetchUserInfoFromIdp(providerId, claims, samlResponse) {
1716
1716
  switch (providerId) {
1717
1717
  case "google.com": {
1718
1718
  federatedId = `https://accounts.google.com/${rawId}`;
1719
- let granted_scopes = "openid https://www.googleapis.com/auth/userinfo.profile";
1719
+ let grantedScopes = "openid https://www.googleapis.com/auth/userinfo.profile";
1720
1720
  if (email) {
1721
- granted_scopes += " https://www.googleapis.com/auth/userinfo.email";
1721
+ grantedScopes += " https://www.googleapis.com/auth/userinfo.email";
1722
1722
  }
1723
1723
  response.firstName = claims.given_name;
1724
1724
  response.lastName = claims.family_name;
1725
1725
  response.rawUserInfo = JSON.stringify({
1726
- granted_scopes,
1726
+ granted_scopes: grantedScopes,
1727
1727
  id: rawId,
1728
1728
  name: displayName,
1729
1729
  given_name: claims.given_name,
@@ -2064,7 +2064,7 @@ function generateBlockingFunctionJwt(state, event, url, timeoutMs, user, options
2064
2064
  jwt.tenant_id = state.tenantId;
2065
2065
  jwt.user_record.tenant_id = state.tenantId;
2066
2066
  }
2067
- const provider_data = [];
2067
+ const providerData = [];
2068
2068
  if (user.providerUserInfo) {
2069
2069
  for (const providerUserInfo of user.providerUserInfo) {
2070
2070
  const provider = {
@@ -2075,12 +2075,12 @@ function generateBlockingFunctionJwt(state, event, url, timeoutMs, user, options
2075
2075
  uid: providerUserInfo.rawId,
2076
2076
  phone_number: providerUserInfo.phoneNumber,
2077
2077
  };
2078
- provider_data.push(provider);
2078
+ providerData.push(provider);
2079
2079
  }
2080
2080
  }
2081
- jwt.user_record.provider_data = provider_data;
2081
+ jwt.user_record.provider_data = providerData;
2082
2082
  if (user.mfaInfo) {
2083
- const enrolled_factors = [];
2083
+ const enrolledFactors = [];
2084
2084
  for (const mfaEnrollment of user.mfaInfo) {
2085
2085
  if (!mfaEnrollment.mfaEnrollmentId) {
2086
2086
  continue;
@@ -2092,10 +2092,10 @@ function generateBlockingFunctionJwt(state, event, url, timeoutMs, user, options
2092
2092
  phone_number: mfaEnrollment.phoneInfo,
2093
2093
  factor_id: state_1.PROVIDER_PHONE,
2094
2094
  };
2095
- enrolled_factors.push(enrolledFactor);
2095
+ enrolledFactors.push(enrolledFactor);
2096
2096
  }
2097
2097
  jwt.user_record.multi_factor = {
2098
- enrolled_factors,
2098
+ enrolled_factors: enrolledFactors,
2099
2099
  };
2100
2100
  }
2101
2101
  if (user.lastLoginAt || user.createdAt) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JAVA_DEPRECATION_WARNING = exports.checkJavaSupported = exports.emulatorExec = exports.shutdownWhenKilled = exports.setExportOnExitOptions = exports.parseInspectionPort = exports.beforeEmulatorCommand = exports.warnEmulatorNotSupported = exports.printNoticeIfEmulated = exports.DESC_TEST_PARAMS = exports.FLAG_TEST_PARAMS = exports.DESC_TEST_CONFIG = exports.FLAG_TEST_CONFIG = exports.DESC_UI = exports.FLAG_UI = exports.EXPORT_ON_EXIT_CWD_DANGER = exports.EXPORT_ON_EXIT_USAGE_ERROR = exports.DESC_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT_NAME = exports.DESC_IMPORT = exports.FLAG_IMPORT = exports.DESC_INSPECT_FUNCTIONS = exports.FLAG_INSPECT_FUNCTIONS = exports.DESC_ONLY = exports.FLAG_ONLY = void 0;
4
- const clc = require("cli-color");
3
+ exports.JAVA_DEPRECATION_WARNING = exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = exports.checkJavaMajorVersion = exports.emulatorExec = exports.shutdownWhenKilled = exports.setExportOnExitOptions = exports.parseInspectionPort = exports.beforeEmulatorCommand = exports.warnEmulatorNotSupported = exports.printNoticeIfEmulated = exports.DESC_TEST_PARAMS = exports.FLAG_TEST_PARAMS = exports.DESC_TEST_CONFIG = exports.FLAG_TEST_CONFIG = exports.DESC_UI = exports.FLAG_UI = exports.EXPORT_ON_EXIT_CWD_DANGER = exports.EXPORT_ON_EXIT_USAGE_ERROR = exports.DESC_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT_NAME = exports.DESC_IMPORT = exports.FLAG_IMPORT = exports.DESC_INSPECT_FUNCTIONS = exports.FLAG_INSPECT_FUNCTIONS = exports.DESC_ONLY = exports.FLAG_ONLY = void 0;
4
+ const clc = require("colorette");
5
5
  const childProcess = require("child_process");
6
6
  const controller = require("../emulator/controller");
7
7
  const config_1 = require("../config");
@@ -20,6 +20,7 @@ const prompt_1 = require("../prompt");
20
20
  const controller_1 = require("./controller");
21
21
  const fsutils = require("../fsutils");
22
22
  const Table = require("cli-table");
23
+ const track_1 = require("../track");
23
24
  exports.FLAG_ONLY = "--only <emulators>";
24
25
  exports.DESC_ONLY = "only specific emulators. " +
25
26
  "This is a comma separated list of emulator names. " +
@@ -43,7 +44,14 @@ exports.FLAG_TEST_CONFIG = "--test-config <firebase.json file>";
43
44
  exports.DESC_TEST_CONFIG = "A firebase.json style file. Used to configure the Firestore and Realtime Database emulators.";
44
45
  exports.FLAG_TEST_PARAMS = "--test-params <params.env file>";
45
46
  exports.DESC_TEST_PARAMS = "A .env file containing test param values for your emulated extension.";
46
- const DEFAULT_CONFIG = new config_1.Config({ database: {}, firestore: {}, functions: {}, hosting: {}, emulators: { auth: {}, pubsub: {} } }, {});
47
+ const DEFAULT_CONFIG = new config_1.Config({
48
+ eventarc: {},
49
+ database: {},
50
+ firestore: {},
51
+ functions: {},
52
+ hosting: {},
53
+ emulators: { auth: {}, pubsub: {} },
54
+ }, {});
47
55
  function printNoticeIfEmulated(options, emulator) {
48
56
  if (emulator !== types_1.Emulators.DATABASE && emulator !== types_1.Emulators.FIRESTORE) {
49
57
  return;
@@ -201,14 +209,10 @@ function shutdownWhenKilled(options) {
201
209
  ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"].forEach((signal) => {
202
210
  process.on(signal, processKillSignal(signal, res, rej, options));
203
211
  });
204
- })
205
- .then(() => {
206
- process.exit(0);
207
- })
208
- .catch((e) => {
212
+ }).catch((e) => {
209
213
  logger_1.logger.debug(e);
210
214
  utils.logLabeledWarning("emulators", "emulators failed to shut down cleanly, see firebase-debug.log for details.");
211
- process.exit(1);
215
+ throw e;
212
216
  });
213
217
  }
214
218
  exports.shutdownWhenKilled = shutdownWhenKilled;
@@ -247,6 +251,12 @@ async function runScript(script, extraEnv) {
247
251
  const address = registry_1.EmulatorRegistry.getInfoHostString(info);
248
252
  env[constants_1.Constants.FIREBASE_EMULATOR_HUB] = address;
249
253
  }
254
+ const eventarcInstance = registry_1.EmulatorRegistry.get(types_1.Emulators.EVENTARC);
255
+ if (eventarcInstance) {
256
+ const info = eventarcInstance.getInfo();
257
+ const address = registry_1.EmulatorRegistry.getInfoHostString(info);
258
+ env[constants_1.Constants.CLOUD_EVENTARC_EMULATOR_HOST] = address;
259
+ }
250
260
  const proc = childProcess.spawn(script, {
251
261
  stdio: ["inherit", "inherit", "inherit"],
252
262
  shell: true,
@@ -280,12 +290,15 @@ async function runScript(script, extraEnv) {
280
290
  });
281
291
  }
282
292
  async function emulatorExec(script, options) {
283
- shutdownWhenKilled(options);
284
293
  const projectId = (0, projectUtils_1.getProjectId)(options);
285
294
  const extraEnv = {};
286
295
  if (projectId) {
287
296
  extraEnv.GCLOUD_PROJECT = projectId;
288
297
  }
298
+ const session = (0, track_1.emulatorSession)();
299
+ if (session && session.debugMode) {
300
+ extraEnv[constants_1.Constants.FIREBASE_GA_SESSION] = JSON.stringify(session);
301
+ }
289
302
  let exitCode = 0;
290
303
  let deprecationNotices;
291
304
  try {
@@ -308,9 +321,8 @@ async function emulatorExec(script, options) {
308
321
  }
309
322
  exports.emulatorExec = emulatorExec;
310
323
  const JAVA_VERSION_REGEX = /version "([1-9][0-9]*)/;
311
- const MIN_SUPPORTED_JAVA_MAJOR_VERSION = 11;
312
324
  const JAVA_HINT = "Please make sure Java is installed and on your system PATH.";
313
- async function checkJavaSupported() {
325
+ async function checkJavaMajorVersion() {
314
326
  return new Promise((resolve, reject) => {
315
327
  var _a, _b;
316
328
  let child;
@@ -351,25 +363,30 @@ async function checkJavaSupported() {
351
363
  }
352
364
  });
353
365
  }).then((output) => {
366
+ let versionInt = -1;
354
367
  const match = output.match(JAVA_VERSION_REGEX);
355
368
  if (match) {
356
369
  const version = match[1];
357
- const versionInt = parseInt(version, 10);
370
+ versionInt = parseInt(version, 10);
358
371
  if (!versionInt) {
359
372
  utils.logLabeledWarning("emulators", `Failed to parse Java version. Got "${match[0]}".`, "warn");
360
373
  }
361
374
  else {
362
375
  logger_1.logger.debug(`Parsed Java major version: ${versionInt}`);
363
- return versionInt >= MIN_SUPPORTED_JAVA_MAJOR_VERSION;
364
376
  }
365
377
  }
366
378
  else {
367
379
  logger_1.logger.debug("java -version outputs:", output);
368
380
  logger_1.logger.warn(`Failed to parse Java version.`);
369
381
  }
370
- return false;
382
+ const session = (0, track_1.emulatorSession)();
383
+ if (session) {
384
+ session.javaMajorVersion = versionInt;
385
+ }
386
+ return versionInt;
371
387
  });
372
388
  }
373
- exports.checkJavaSupported = checkJavaSupported;
389
+ exports.checkJavaMajorVersion = checkJavaMajorVersion;
390
+ exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = 11;
374
391
  exports.JAVA_DEPRECATION_WARNING = "firebase-tools no longer supports Java version before 11. " +
375
392
  "Please upgrade to Java version 11 or above to continue using the emulators.";
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Constants = exports.EMULATOR_DESCRIPTION = exports.FIND_AVAILBLE_PORT_BY_DEFAULT = void 0;
3
+ exports.Constants = exports.DEFAULT_HOST = exports.EMULATOR_DESCRIPTION = exports.FIND_AVAILBLE_PORT_BY_DEFAULT = exports.DEFAULT_PORTS = void 0;
4
4
  const url = require("url");
5
- const DEFAULT_PORTS = {
5
+ exports.DEFAULT_PORTS = {
6
6
  ui: 4000,
7
7
  hub: 4400,
8
8
  logging: 4500,
@@ -14,6 +14,7 @@ const DEFAULT_PORTS = {
14
14
  database: 9000,
15
15
  auth: 9099,
16
16
  storage: 9199,
17
+ eventarc: 9299,
17
18
  };
18
19
  exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
19
20
  ui: true,
@@ -27,6 +28,7 @@ exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
27
28
  auth: false,
28
29
  storage: false,
29
30
  extensions: false,
31
+ eventarc: true,
30
32
  };
31
33
  exports.EMULATOR_DESCRIPTION = {
32
34
  ui: "Emulator UI",
@@ -40,8 +42,9 @@ exports.EMULATOR_DESCRIPTION = {
40
42
  auth: "Authentication Emulator",
41
43
  storage: "Storage Emulator",
42
44
  extensions: "Extensions Emulator",
45
+ eventarc: "Eventarc Emulator",
43
46
  };
44
- const DEFAULT_HOST = "localhost";
47
+ exports.DEFAULT_HOST = "localhost";
45
48
  class Constants {
46
49
  static getServiceName(service) {
47
50
  switch (service) {
@@ -63,15 +66,17 @@ class Constants {
63
66
  return "storage";
64
67
  case this.SERVICE_TEST_LAB:
65
68
  return "test lab";
69
+ case this.SERVICE_EVENTARC:
70
+ return "eventarc";
66
71
  default:
67
72
  return service;
68
73
  }
69
74
  }
70
75
  static getDefaultHost() {
71
- return DEFAULT_HOST;
76
+ return exports.DEFAULT_HOST;
72
77
  }
73
78
  static getDefaultPort(emulator) {
74
- return DEFAULT_PORTS[emulator];
79
+ return exports.DEFAULT_PORTS[emulator];
75
80
  }
76
81
  static description(name) {
77
82
  return exports.EMULATOR_DESCRIPTION[name];
@@ -82,7 +87,7 @@ class Constants {
82
87
  normalized = `http://${normalized}`;
83
88
  }
84
89
  const u = url.parse(normalized);
85
- return u.hostname || DEFAULT_HOST;
90
+ return u.hostname || exports.DEFAULT_HOST;
86
91
  }
87
92
  static isDemoProject(projectId) {
88
93
  return !!projectId && projectId.startsWith(this.FAKE_PROJECT_ID_PREFIX);
@@ -97,10 +102,13 @@ Constants.FIREBASE_DATABASE_EMULATOR_HOST = "FIREBASE_DATABASE_EMULATOR_HOST";
97
102
  Constants.FIREBASE_AUTH_EMULATOR_HOST = "FIREBASE_AUTH_EMULATOR_HOST";
98
103
  Constants.FIREBASE_STORAGE_EMULATOR_HOST = "FIREBASE_STORAGE_EMULATOR_HOST";
99
104
  Constants.CLOUD_STORAGE_EMULATOR_HOST = "STORAGE_EMULATOR_HOST";
105
+ Constants.CLOUD_EVENTARC_EMULATOR_HOST = "CLOUD_EVENTARC_EMULATOR_HOST";
100
106
  Constants.FIREBASE_EMULATOR_HUB = "FIREBASE_EMULATOR_HUB";
107
+ Constants.FIREBASE_GA_SESSION = "FIREBASE_GA_SESSION";
101
108
  Constants.SERVICE_FIRESTORE = "firestore.googleapis.com";
102
109
  Constants.SERVICE_REALTIME_DATABASE = "firebaseio.com";
103
110
  Constants.SERVICE_PUBSUB = "pubsub.googleapis.com";
111
+ Constants.SERVICE_EVENTARC = "eventarc.googleapis.com";
104
112
  Constants.SERVICE_ANALYTICS = "app-measurement.com";
105
113
  Constants.SERVICE_AUTH = "firebaseauth.googleapis.com";
106
114
  Constants.SERVICE_CRASHLYTICS = "fabric.io";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exportEmulatorData = exports.startAll = exports.shouldStart = exports.filterEmulatorTargets = exports.cleanShutdown = exports.onExit = exports.exportOnExit = exports.startEmulator = void 0;
4
- const clc = require("cli-color");
3
+ exports.exportEmulatorData = exports.startAll = exports.shouldStart = exports.filterEmulatorTargets = exports.cleanShutdown = exports.onExit = exports.exportOnExit = void 0;
4
+ const clc = require("colorette");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
7
7
  const logger_1 = require("../logger");
@@ -16,6 +16,7 @@ const auth_1 = require("./auth");
16
16
  const databaseEmulator_1 = require("./databaseEmulator");
17
17
  const firestoreEmulator_1 = require("./firestoreEmulator");
18
18
  const hostingEmulator_1 = require("./hostingEmulator");
19
+ const eventarcEmulator_1 = require("./eventarcEmulator");
19
20
  const error_1 = require("../error");
20
21
  const projectUtils_1 = require("../projectUtils");
21
22
  const pubsubEmulator_1 = require("./pubsubEmulator");
@@ -93,19 +94,13 @@ async function getAndCheckAddress(emulator, options) {
93
94
  }
94
95
  return { host, port };
95
96
  }
96
- async function startEmulator(instance) {
97
- const name = instance.getName();
98
- void (0, track_1.track)("Emulator Run", name);
99
- await registry_1.EmulatorRegistry.start(instance);
100
- }
101
- exports.startEmulator = startEmulator;
102
97
  async function exportOnExit(options) {
103
98
  const exportOnExitDir = options.exportOnExit;
104
99
  if (exportOnExitDir) {
105
100
  try {
106
101
  utils.logBullet(`Automatically exporting data using ${commandUtils_1.FLAG_EXPORT_ON_EXIT_NAME} "${exportOnExitDir}" ` +
107
102
  "please wait for the export to finish...");
108
- await exportEmulatorData(exportOnExitDir, options);
103
+ await exportEmulatorData(exportOnExitDir, options, "exit");
109
104
  }
110
105
  catch (e) {
111
106
  utils.logWarning(e);
@@ -215,9 +210,8 @@ async function startAll(options, showUI = true) {
215
210
  if (targets.length === 0) {
216
211
  throw new error_1.FirebaseError(`No emulators to start, run ${clc.bold("firebase init emulators")} to get started.`);
217
212
  }
218
- const deprecationNotices = [];
219
213
  if (targets.some(downloadableEmulators_1.requiresJava)) {
220
- if (!(await commandUtils.checkJavaSupported())) {
214
+ if ((await commandUtils.checkJavaMajorVersion()) < commandUtils_1.MIN_SUPPORTED_JAVA_MAJOR_VERSION) {
221
215
  utils.logLabeledError("emulators", commandUtils_1.JAVA_DEPRECATION_WARNING, "warn");
222
216
  throw new error_1.FirebaseError(commandUtils_1.JAVA_DEPRECATION_WARNING);
223
217
  }
@@ -225,7 +219,8 @@ async function startAll(options, showUI = true) {
225
219
  const hubLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.HUB);
226
220
  hubLogger.logLabeled("BULLET", "emulators", `Starting emulators: ${targets.join(", ")}`);
227
221
  const projectId = (0, projectUtils_1.getProjectId)(options) || "";
228
- if (constants_1.Constants.isDemoProject(projectId)) {
222
+ const isDemoProject = constants_1.Constants.isDemoProject(projectId);
223
+ if (isDemoProject) {
229
224
  hubLogger.logLabeled("BULLET", "emulators", `Detected demo project ID "${projectId}", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail.`);
230
225
  }
231
226
  const onlyOptions = options.only;
@@ -249,6 +244,15 @@ async function startAll(options, showUI = true) {
249
244
  await (0, frameworks_1.prepareFrameworks)(targets, options, options);
250
245
  }
251
246
  }
247
+ function startEmulator(instance) {
248
+ const name = instance.getName();
249
+ void (0, track_1.track)("Emulator Run", name);
250
+ void (0, track_1.trackEmulator)("emulator_run", {
251
+ emulator_name: name,
252
+ is_demo_project: String(isDemoProject),
253
+ });
254
+ return registry_1.EmulatorRegistry.start(instance);
255
+ }
252
256
  if (shouldStart(options, types_1.Emulators.HUB)) {
253
257
  const hubAddr = await getAndCheckAddress(types_1.Emulators.HUB, options);
254
258
  const hub = new hub_1.EmulatorHub(Object.assign({ projectId }, hubAddr));
@@ -264,6 +268,10 @@ async function startAll(options, showUI = true) {
264
268
  const foundMetadata = findExportMetadata(importDir);
265
269
  if (foundMetadata) {
266
270
  exportMetadata = foundMetadata;
271
+ void (0, track_1.trackEmulator)("emulator_import", {
272
+ initiated_by: "start",
273
+ emulator_name: types_1.Emulators.HUB,
274
+ });
267
275
  }
268
276
  else {
269
277
  hubLogger.logLabeled("WARN", "emulators", `Could not find import/export metadata file, ${clc.bold("skipping data import!")}`);
@@ -287,7 +295,7 @@ async function startAll(options, showUI = true) {
287
295
  }
288
296
  }
289
297
  if (shouldStart(options, types_1.Emulators.EXTENSIONS)) {
290
- const projectNumber = constants_1.Constants.isDemoProject(projectId)
298
+ const projectNumber = isDemoProject
291
299
  ? constants_1.Constants.FAKE_PROJECT_NUMBER
292
300
  : await (0, projectUtils_1.needProjectNumber)(options);
293
301
  const aliases = (0, projectUtils_1.getAliases)(options, projectId);
@@ -330,6 +338,12 @@ async function startAll(options, showUI = true) {
330
338
  projectAlias: options.projectAlias,
331
339
  });
332
340
  await startEmulator(functionsEmulator);
341
+ const eventarcAddr = await getAndCheckAddress(types_1.Emulators.EVENTARC, options);
342
+ const eventarcEmulator = new eventarcEmulator_1.EventarcEmulator({
343
+ host: eventarcAddr.host,
344
+ port: eventarcAddr.port,
345
+ });
346
+ await startEmulator(eventarcEmulator);
333
347
  }
334
348
  if (shouldStart(options, types_1.Emulators.FIRESTORE)) {
335
349
  const firestoreLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FIRESTORE);
@@ -346,6 +360,10 @@ async function startAll(options, showUI = true) {
346
360
  const exportMetadataFilePath = path.resolve(importDirAbsPath, exportMetadata.firestore.metadata_file);
347
361
  firestoreLogger.logLabeled("BULLET", "firestore", `Importing data from ${exportMetadataFilePath}`);
348
362
  args.seed_from_export = exportMetadataFilePath;
363
+ void (0, track_1.trackEmulator)("emulator_import", {
364
+ initiated_by: "start",
365
+ emulator_name: types_1.Emulators.FIRESTORE,
366
+ });
349
367
  }
350
368
  const config = options.config;
351
369
  const rulesLocalPath = (_a = config.src.firestore) === null || _a === void 0 ? void 0 : _a.rules;
@@ -407,6 +425,11 @@ async function startAll(options, showUI = true) {
407
425
  const importDirAbsPath = path.resolve(options.import);
408
426
  const databaseExportDir = path.resolve(importDirAbsPath, exportMetadata.database.path);
409
427
  const files = fs.readdirSync(databaseExportDir).filter((f) => f.endsWith(".json"));
428
+ void (0, track_1.trackEmulator)("emulator_import", {
429
+ initiated_by: "start",
430
+ emulator_name: types_1.Emulators.DATABASE,
431
+ count: files.length,
432
+ });
410
433
  for (const f of files) {
411
434
  const fPath = path.join(databaseExportDir, f);
412
435
  const ns = path.basename(f, ".json");
@@ -429,7 +452,7 @@ async function startAll(options, showUI = true) {
429
452
  utils.assertIsString(options.import);
430
453
  const importDirAbsPath = path.resolve(options.import);
431
454
  const authExportDir = path.resolve(importDirAbsPath, exportMetadata.auth.path);
432
- await authEmulator.importData(authExportDir, projectId);
455
+ await authEmulator.importData(authExportDir, projectId, { initiatedBy: "start" });
433
456
  }
434
457
  }
435
458
  if (shouldStart(options, types_1.Emulators.PUBSUB)) {
@@ -458,7 +481,7 @@ async function startAll(options, showUI = true) {
458
481
  utils.assertIsString(options.import);
459
482
  const importDirAbsPath = path.resolve(options.import);
460
483
  const storageExportDir = path.resolve(importDirAbsPath, exportMetadata.storage.path);
461
- storageEmulator.storageLayer.import(storageExportDir);
484
+ storageEmulator.storageLayer.import(storageExportDir, { initiatedBy: "start" });
462
485
  }
463
486
  }
464
487
  if (shouldStart(options, types_1.Emulators.HOSTING)) {
@@ -488,17 +511,26 @@ async function startAll(options, showUI = true) {
488
511
  const ui = new ui_1.EmulatorUI(Object.assign({ projectId: projectId, auto_download: true }, uiAddr));
489
512
  await startEmulator(ui);
490
513
  }
514
+ let serviceEmulatorCount = 0;
491
515
  const running = registry_1.EmulatorRegistry.listRunning();
492
516
  for (const name of running) {
493
517
  const instance = registry_1.EmulatorRegistry.get(name);
494
518
  if (instance) {
495
519
  await instance.connect();
496
520
  }
521
+ if (types_1.ALL_SERVICE_EMULATORS.includes(name)) {
522
+ serviceEmulatorCount++;
523
+ }
497
524
  }
498
- return { deprecationNotices };
525
+ void (0, track_1.trackEmulator)("emulators_started", {
526
+ count: serviceEmulatorCount,
527
+ count_all: running.length,
528
+ is_demo_project: String(isDemoProject),
529
+ });
530
+ return { deprecationNotices: [] };
499
531
  }
500
532
  exports.startAll = startAll;
501
- async function exportEmulatorData(exportPath, options) {
533
+ async function exportEmulatorData(exportPath, options, initiatedBy) {
502
534
  const projectId = options.project;
503
535
  if (!projectId) {
504
536
  throw new error_1.FirebaseError("Could not determine project ID, make sure you're running in a Firebase project directory or add the --project flag.", { exit: 1 });
@@ -536,7 +568,7 @@ async function exportEmulatorData(exportPath, options) {
536
568
  }
537
569
  utils.logBullet(`Exporting data to: ${exportAbsPath}`);
538
570
  try {
539
- await hubClient.postExport(exportAbsPath);
571
+ await hubClient.postExport({ path: exportAbsPath, initiatedBy });
540
572
  }
541
573
  catch (e) {
542
574
  throw new error_1.FirebaseError("Export request failed, see emulator logs for more information.", {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DatabaseEmulator = void 0;
4
4
  const chokidar = require("chokidar");
5
- const clc = require("cli-color");
5
+ const clc = require("colorette");
6
6
  const fs = require("fs");
7
7
  const path = require("path");
8
8
  const http = require("http");
@@ -7,7 +7,7 @@ const error_1 = require("../error");
7
7
  const childProcess = require("child_process");
8
8
  const utils = require("../utils");
9
9
  const emulatorLogger_1 = require("./emulatorLogger");
10
- const clc = require("cli-color");
10
+ const clc = require("colorette");
11
11
  const fs = require("fs-extra");
12
12
  const path = require("path");
13
13
  const os = require("os");
@@ -67,15 +67,15 @@ exports.DownloadDetails = {
67
67
  },
68
68
  }
69
69
  : {
70
- version: "1.8.1",
71
- downloadPath: path.join(CACHE_DIR, "ui-v1.8.1.zip"),
72
- unzipDir: path.join(CACHE_DIR, "ui-v1.8.1"),
73
- binaryPath: path.join(CACHE_DIR, "ui-v1.8.1", "server", "server.js"),
70
+ version: "1.9.0",
71
+ downloadPath: path.join(CACHE_DIR, "ui-v1.9.0.zip"),
72
+ unzipDir: path.join(CACHE_DIR, "ui-v1.9.0"),
73
+ binaryPath: path.join(CACHE_DIR, "ui-v1.9.0", "server", "server.js"),
74
74
  opts: {
75
75
  cacheDir: CACHE_DIR,
76
- remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.8.1.zip",
77
- expectedSize: 3056552,
78
- expectedChecksum: "92590fdda20f9883588438d9551111b5",
76
+ remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/ui-v1.9.0.zip",
77
+ expectedSize: 3062710,
78
+ expectedChecksum: "984597f41d497bd318dac131615eb9d5",
79
79
  namePrefix: "ui",
80
80
  },
81
81
  },
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EmulatorLogger = exports.Verbosity = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const utils = require("../utils");
6
6
  const logger_1 = require("../logger");
7
7
  const utils_1 = require("../utils");