firebase-tools-with-isolate 15.36.0 → 15.38.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 (104) hide show
  1. package/lib/accountExporter.js +1 -1
  2. package/lib/accountImporter.js +15 -10
  3. package/lib/apiv2.js +66 -12
  4. package/lib/appUtils.js +103 -40
  5. package/lib/appdistribution/client.js +5 -1
  6. package/lib/apptesting/parseTestFiles.js +1 -1
  7. package/lib/auth.js +1 -1
  8. package/lib/bin/progressiveHelp.js +1 -1
  9. package/lib/command.js +1 -2
  10. package/lib/commands/appdistribution-distribute.js +5 -3
  11. package/lib/commands/crashlytics-events-get.js +46 -0
  12. package/lib/commands/crashlytics-events-list.js +68 -0
  13. package/lib/commands/crashlytics-heapdumps-enable.js +3 -4
  14. package/lib/commands/crashlytics-heapdumps-status.js +5 -3
  15. package/lib/commands/crashlytics-issues-get.js +65 -0
  16. package/lib/commands/crashlytics-reports-get.js +267 -0
  17. package/lib/commands/crashlytics-reports-list.js +42 -0
  18. package/lib/commands/dataconnect-services-list.js +8 -2
  19. package/lib/commands/ext-dev-init.js +1 -1
  20. package/lib/commands/hosting-channel-open.js +4 -1
  21. package/lib/commands/index.js +10 -0
  22. package/lib/commands/open.js +3 -1
  23. package/lib/commands/serve.js +1 -1
  24. package/lib/commands/use.js +1 -1
  25. package/lib/config.js +1 -1
  26. package/lib/crashlytics/commandUtils.js +227 -0
  27. package/lib/crashlytics/events.js +71 -73
  28. package/lib/crashlytics/filters.js +1 -1
  29. package/lib/crashlytics/profilingManager.js +63 -16
  30. package/lib/crashlytics/reports.js +5 -1
  31. package/lib/dataconnect/client.js +14 -8
  32. package/lib/deploy/dataconnect/release.js +2 -2
  33. package/lib/deploy/firestore/prepare.js +23 -17
  34. package/lib/deploy/functions/cel.js +1 -1
  35. package/lib/deploy/functions/deploy.js +2 -1
  36. package/lib/deploy/functions/prepare.js +28 -0
  37. package/lib/deploy/functions/release/fabricator.js +27 -3
  38. package/lib/deploy/functions/release/planner.js +3 -0
  39. package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
  40. package/lib/deploy/functions/runtimes/python/index.js +3 -0
  41. package/lib/deploy/functions/runtimes/supported/index.js +10 -4
  42. package/lib/deploy/functions/runtimes/supported/types.js +13 -1
  43. package/lib/deploy/run/deploy.js +40 -35
  44. package/lib/deploy/run/prereqs.js +0 -3
  45. package/lib/downloadUtils.js +2 -1
  46. package/lib/emulator/download.js +1 -0
  47. package/lib/emulator/downloadableEmulatorInfo.json +31 -31
  48. package/lib/emulator/downloadableEmulators.js +14 -2
  49. package/lib/emulator/events/types.js +0 -6
  50. package/lib/emulator/functionsEmulator.js +73 -1
  51. package/lib/emulator/functionsEmulatorRuntime.js +2 -2
  52. package/lib/emulator/storage/cloudFunctions.js +0 -1
  53. package/lib/emulator/storage/rules/runtime.js +0 -3
  54. package/lib/emulator/taskQueue.js +0 -12
  55. package/lib/experiments.js +10 -0
  56. package/lib/extensions/extensionsHelper.js +1 -4
  57. package/lib/extensions/listExtensions.js +1 -1
  58. package/lib/extensions/replacements.json +2 -1
  59. package/lib/firestore/delete.js +2 -3
  60. package/lib/firestore/fsConfig.js +100 -41
  61. package/lib/frameworks/next/constants.js +17 -14
  62. package/lib/frameworks/next/index.js +2 -2
  63. package/lib/frameworks/next/utils.js +6 -8
  64. package/lib/gcp/cloudbilling.js +2 -2
  65. package/lib/gcp/cloudbuild.js +0 -77
  66. package/lib/gcp/cloudscheduler.js +12 -0
  67. package/lib/gcp/cloudtasks.js +0 -4
  68. package/lib/gcp/devConnect.js +0 -6
  69. package/lib/gcp/iam.js +15 -1
  70. package/lib/gcp/resourceManager.js +1 -14
  71. package/lib/gcp/runv2.js +0 -27
  72. package/lib/gcp/secretManager.js +2 -2
  73. package/lib/gcp/storage.js +87 -4
  74. package/lib/hosting/api.js +29 -23
  75. package/lib/hosting/implicitInit.js +1 -1
  76. package/lib/hosting/proxy.js +1 -1
  77. package/lib/init/features/dataconnect/sdk.js +15 -5
  78. package/lib/init/features/firestore/rules.js +1 -1
  79. package/lib/init/features/functions/index.js +2 -2
  80. package/lib/init/features/functions/npm-dependencies.js +1 -1
  81. package/lib/init/features/storage/rules.js +1 -1
  82. package/lib/localFunction.js +3 -3
  83. package/lib/management/apps.js +7 -0
  84. package/lib/management/database.js +1 -1
  85. package/lib/mcp/apps/init/mcp-app.js +1 -1
  86. package/lib/mcp/apps/update_environment/mcp-app.js +1 -1
  87. package/lib/mcp/index.js +10 -4
  88. package/lib/mcp/tools/core/get_environment.js +1 -1
  89. package/lib/mcp/tools/crashlytics/events.js +2 -5
  90. package/lib/mcp/tools/crashlytics/reports.js +5 -14
  91. package/lib/mcp/util/apptesting/availability.js +3 -2
  92. package/lib/mcp/util/crashlytics/availability.js +59 -12
  93. package/lib/mcp/util/dataconnect/converter.js +1 -1
  94. package/lib/mcp/util.js +4 -0
  95. package/lib/profileReport.js +1 -1
  96. package/lib/profiler.js +1 -1
  97. package/lib/requireAuth.js +11 -7
  98. package/lib/rulesDeploy.js +0 -1
  99. package/lib/throttler/throttler.js +1 -1
  100. package/lib/tsconfig.publish.tsbuildinfo +1 -1
  101. package/lib/utils.js +1 -1
  102. package/package.json +15 -12
  103. package/schema/firebase-config.json +9 -3
  104. package/standalone/package.json +6 -1
@@ -187,7 +187,7 @@ async function serialExportUsers(projectId, options) {
187
187
  const userList = ret.body.users;
188
188
  if (userList && userList.length > 0) {
189
189
  options.writeUsersToFile(userList, options.format, options.writeStream);
190
- utils.logSuccess("Exported " + userList.length + " account(s) successfully.");
190
+ utils.logSuccess(`Exported ${String(userList.length)} account(s) successfully.`);
191
191
  if (!ret.body.nextPageToken) {
192
192
  return;
193
193
  }
@@ -46,11 +46,15 @@ const ALLOWED_PROVIDER_IDS = [
46
46
  "yahoo.com",
47
47
  ];
48
48
  function isValidBase64(str) {
49
- const expected = Buffer.from(str, "base64").toString("base64");
50
- if (str.length < expected.length && !str.endsWith("=")) {
51
- str += "=".repeat(expected.length - str.length);
49
+ if (typeof str !== "string") {
50
+ return false;
52
51
  }
53
- return expected === str;
52
+ const normalized = str.replace(/-/g, "+").replace(/_/g, "/");
53
+ const expected = Buffer.from(normalized, "base64").toString("base64");
54
+ const padded = normalized.length < expected.length && !normalized.endsWith("=")
55
+ ? normalized + "=".repeat(expected.length - normalized.length)
56
+ : normalized;
57
+ return expected === padded;
54
58
  }
55
59
  function toWebSafeBase64(data) {
56
60
  return data.replace(/\//g, "_").replace(/\+/g, "-");
@@ -178,6 +182,7 @@ function validateRequiredParameters(options) {
178
182
  return { valid: true };
179
183
  }
180
184
  const hashAlgo = options.hashAlgo.toUpperCase();
185
+ const hashAlgoName = String(options.hashAlgo);
181
186
  let roundsNum;
182
187
  switch (hashAlgo) {
183
188
  case "HMAC_SHA512":
@@ -185,7 +190,7 @@ function validateRequiredParameters(options) {
185
190
  case "HMAC_SHA1":
186
191
  case "HMAC_MD5":
187
192
  if (!options.hashKey || options.hashKey === "") {
188
- throw new error_1.FirebaseError("Must provide hash key(base64 encoded) for hash algorithm " + options.hashAlgo);
193
+ throw new error_1.FirebaseError("Must provide hash key(base64 encoded) for hash algorithm " + hashAlgoName);
189
194
  }
190
195
  return { hashAlgo: hashAlgo, hashKey: options.hashKey, valid: true };
191
196
  case "MD5":
@@ -203,20 +208,20 @@ function validateRequiredParameters(options) {
203
208
  case "PBKDF2_SHA256":
204
209
  roundsNum = parseInt(options.rounds, 10);
205
210
  if (isNaN(roundsNum) || roundsNum < 0 || roundsNum > 120000) {
206
- throw new error_1.FirebaseError("Must provide valid rounds(0..120000) for hash algorithm " + options.hashAlgo);
211
+ throw new error_1.FirebaseError("Must provide valid rounds(0..120000) for hash algorithm " + hashAlgoName);
207
212
  }
208
213
  return { hashAlgo: hashAlgo, rounds: options.rounds, valid: true };
209
214
  case "SCRYPT": {
210
215
  if (!options.hashKey || options.hashKey === "") {
211
- throw new error_1.FirebaseError("Must provide hash key(base64 encoded) for hash algorithm " + options.hashAlgo);
216
+ throw new error_1.FirebaseError("Must provide hash key(base64 encoded) for hash algorithm " + hashAlgoName);
212
217
  }
213
218
  roundsNum = parseInt(options.rounds, 10);
214
219
  if (isNaN(roundsNum) || roundsNum <= 0 || roundsNum > 8) {
215
- throw new error_1.FirebaseError("Must provide valid rounds(1..8) for hash algorithm " + options.hashAlgo);
220
+ throw new error_1.FirebaseError("Must provide valid rounds(1..8) for hash algorithm " + hashAlgoName);
216
221
  }
217
222
  const memCost = parseInt(options.memCost, 10);
218
223
  if (isNaN(memCost) || memCost <= 0 || memCost > 14) {
219
- throw new error_1.FirebaseError("Must provide valid memory cost(1..14) for hash algorithm " + options.hashAlgo);
224
+ throw new error_1.FirebaseError("Must provide valid memory cost(1..14) for hash algorithm " + hashAlgoName);
220
225
  }
221
226
  let saltSeparator = "";
222
227
  if (options.saltSeparator) {
@@ -294,7 +299,7 @@ function validateUserJson(userJson) {
294
299
  return {};
295
300
  }
296
301
  async function sendRequest(projectId, userList, hashOptions) {
297
- logger_1.logger.info("Starting importing " + userList.length + " account(s).");
302
+ logger_1.logger.info(`Starting importing ${userList.length} account(s).`);
298
303
  const postData = genUploadAccountPostBody(projectId, userList, hashOptions);
299
304
  return apiClient
300
305
  .post("/identitytoolkit/v3/relyingparty/uploadAccount", postData, {
package/lib/apiv2.js CHANGED
@@ -4,7 +4,9 @@ exports.Client = exports.CLI_OAUTH_PROJECT_NUMBER = exports.GOOG_USER_PROJECT_HE
4
4
  exports.setRefreshToken = setRefreshToken;
5
5
  exports.setAccessToken = setAccessToken;
6
6
  exports.getAccessToken = getAccessToken;
7
+ exports.bypassesProxy = bypassesProxy;
7
8
  exports.noKeepAliveAgent = noKeepAliveAgent;
9
+ exports.authTransporterAgent = authTransporterAgent;
8
10
  const url_1 = require("url");
9
11
  const stream_1 = require("stream");
10
12
  const undici_1 = require("undici");
@@ -64,11 +66,63 @@ function proxyURIFromEnv() {
64
66
  }
65
67
  return uri;
66
68
  }
69
+ const DEFAULT_PORTS = { "http:": 80, "https:": 443 };
70
+ function unbracket(host) {
71
+ return host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
72
+ }
73
+ function bypassesProxy(url, noProxy = process.env.no_proxy ?? process.env.NO_PROXY) {
74
+ if (!noProxy) {
75
+ return false;
76
+ }
77
+ const hostname = unbracket(url.hostname.toLowerCase());
78
+ const port = Number(url.port) || DEFAULT_PORTS[url.protocol] || 0;
79
+ for (const raw of noProxy.split(/[,\s]+/)) {
80
+ let entry = raw.trim().toLowerCase();
81
+ if (!entry) {
82
+ continue;
83
+ }
84
+ if (entry === "*") {
85
+ return true;
86
+ }
87
+ let entryPort;
88
+ const bracketed = /^\[([^\]]+)\](?::(.*))?$/.exec(entry);
89
+ if (bracketed) {
90
+ entry = bracketed[1];
91
+ entryPort = bracketed[2];
92
+ }
93
+ else if ((entry.match(/:/g) || []).length === 1) {
94
+ [entry, entryPort] = entry.split(":");
95
+ }
96
+ if (entryPort !== undefined) {
97
+ if (!/^\d+$/.test(entryPort) || Number(entryPort) === 0) {
98
+ continue;
99
+ }
100
+ if (Number(entryPort) !== port) {
101
+ continue;
102
+ }
103
+ }
104
+ entry = entry.replace(/^\*/, "");
105
+ if (entry.startsWith(".") ? hostname.endsWith(entry) : hostname === entry) {
106
+ return true;
107
+ }
108
+ }
109
+ return false;
110
+ }
111
+ function proxyURIForURL(url) {
112
+ const proxyURI = proxyURIFromEnv();
113
+ if (!proxyURI || bypassesProxy(url)) {
114
+ return undefined;
115
+ }
116
+ return proxyURI;
117
+ }
67
118
  const httpAgentNoKeepAlive = new http.Agent({ keepAlive: false });
68
119
  const httpsAgentNoKeepAlive = new https.Agent({ keepAlive: false });
69
120
  function noKeepAliveAgent(parsedURL) {
70
121
  return parsedURL.protocol === "https:" ? httpsAgentNoKeepAlive : httpAgentNoKeepAlive;
71
122
  }
123
+ function authTransporterAgent() {
124
+ return proxyURIFromEnv() ? undefined : noKeepAliveAgent;
125
+ }
72
126
  function isPrematureCloseError(err) {
73
127
  for (const candidate of [err, err?.original]) {
74
128
  if (!candidate) {
@@ -234,12 +288,13 @@ class Client {
234
288
  fetchURL += `?${queryString}`;
235
289
  }
236
290
  }
291
+ const loggedURL = options.skipLog?.queryParams ? this.requestURL(options) : fetchURL;
237
292
  const fetchOptions = {
238
293
  headers: options.headers,
239
294
  method: options.method,
240
295
  redirect: options.redirect,
241
296
  };
242
- const proxyURI = proxyURIFromEnv();
297
+ const proxyURI = proxyURIForURL(new url_1.URL(fetchURL));
243
298
  if (proxyURI) {
244
299
  fetchOptions.dispatcher = new undici_1.ProxyAgent({ uri: proxyURI });
245
300
  }
@@ -328,14 +383,17 @@ class Client {
328
383
  : thrown instanceof Error
329
384
  ? thrown
330
385
  : new Error(thrown);
331
- logger_1.logger.debug(`*** [apiv2] error from fetch(${fetchURL}, ${JSON.stringify(fetchOptions)}): ${err}`);
386
+ const loggedOptions = options.skipLog?.body
387
+ ? { ...fetchOptions, body: "[omitted]" }
388
+ : fetchOptions;
389
+ logger_1.logger.debug(`*** [apiv2] error from fetch(${loggedURL}, ${JSON.stringify(loggedOptions)}): ${err}`);
332
390
  const isAbortError = err.name.includes("AbortError");
333
391
  if (isAbortError) {
334
- throw new error_1.FirebaseError(`Timeout reached making request to ${fetchURL}`, {
392
+ throw new error_1.FirebaseError(`Timeout reached making request to ${loggedURL}`, {
335
393
  original: err,
336
394
  });
337
395
  }
338
- throw new error_1.FirebaseError(`Failed to make request to ${fetchURL}`, { original: err });
396
+ throw new error_1.FirebaseError(`Failed to make request to ${loggedURL}`, { original: err });
339
397
  }
340
398
  finally {
341
399
  if (reqTimeout) {
@@ -382,16 +440,13 @@ class Client {
382
440
  }
383
441
  }
384
442
  catch (err) {
385
- if (!disabledKeepAlive &&
386
- bodyReplayable &&
387
- !proxyURIFromEnv() &&
388
- isPrematureCloseError(err)) {
443
+ if (!disabledKeepAlive && bodyReplayable && !proxyURI && isPrematureCloseError(err)) {
389
444
  disabledKeepAlive = true;
390
445
  fetchOptions.agent = noKeepAliveAgent;
391
446
  const closeHeaders = new Headers(fetchOptions.headers);
392
447
  closeHeaders.set("Connection", "close");
393
448
  fetchOptions.headers = closeHeaders;
394
- logger_1.logger.debug(`*** [apiv2] retrying ${fetchURL} without keep-alive after a premature close error`);
449
+ logger_1.logger.debug(`*** [apiv2] retrying ${loggedURL} without keep-alive after a premature close error`);
395
450
  if (operation.retry(err instanceof Error ? err : new Error(`${err}`))) {
396
451
  return;
397
452
  }
@@ -406,13 +461,13 @@ class Client {
406
461
  setAccessToken(await getAccessToken());
407
462
  }
408
463
  if (options.retryCodes?.includes(res.status)) {
409
- const err = (0, responseToError_1.responseToError)({ statusCode: res.status }, body, fetchURL) || undefined;
464
+ const err = (0, responseToError_1.responseToError)({ statusCode: res.status }, body, loggedURL) || undefined;
410
465
  if (operation.retry(err)) {
411
466
  return;
412
467
  }
413
468
  }
414
469
  if (!options.resolveOnHTTPError) {
415
- return reject((0, responseToError_1.responseToError)({ statusCode: res.status }, body, fetchURL));
470
+ return reject((0, responseToError_1.responseToError)({ statusCode: res.status }, body, loggedURL));
416
471
  }
417
472
  }
418
473
  resolve({
@@ -471,7 +526,6 @@ function isLocalInsecureRequest(urlPrefix) {
471
526
  }
472
527
  class UndiciResponseCompat {
473
528
  constructor(undiciRes) {
474
- this.undiciRes = undiciRes;
475
529
  this.status = undiciRes.statusCode;
476
530
  this.ok = undiciRes.statusCode >= 200 && undiciRes.statusCode < 300;
477
531
  this.headers = new Headers();
package/lib/appUtils.js CHANGED
@@ -19,6 +19,7 @@ var Platform;
19
19
  Platform["IOS"] = "IOS";
20
20
  Platform["FLUTTER"] = "FLUTTER";
21
21
  Platform["ADMIN_NODE"] = "ADMIN_NODE";
22
+ Platform["UNITY"] = "UNITY";
22
23
  })(Platform || (exports.Platform = Platform = {}));
23
24
  var Framework;
24
25
  (function (Framework) {
@@ -33,21 +34,26 @@ async function getPlatformsFromFolder(dirPath) {
33
34
  return [...new Set(apps.map((app) => app.platform))];
34
35
  }
35
36
  async function detectApps(dirPath) {
36
- const [packageJsonFiles, pubSpecYamlFiles, srcMainFolders, xCodeProjects] = await Promise.all([
37
+ const [packageJsonFiles, pubSpecYamlFiles, srcMainFolders, xCodeProjects, unityVersionFiles] = await Promise.all([
37
38
  detectFiles(dirPath, "package.json"),
38
39
  detectFiles(dirPath, "pubspec.yaml"),
39
40
  detectFiles(dirPath, "src/main/"),
40
41
  detectFiles(dirPath, "*.xcodeproj/"),
42
+ detectFiles(dirPath, "ProjectSettings/ProjectVersion.txt"),
41
43
  ]);
42
- const [adminAndWebApps, flutterApps, androidAppsRaw, iosAppsRaw] = await Promise.all([
43
- Promise.all(packageJsonFiles.map((p) => packageJsonToAdminOrWebApp(dirPath, p))).then((r) => r.flat()),
44
+ const unityDirs = unityVersionFiles.map((f) => path.dirname(path.dirname(f)));
45
+ const [adminAndWebApps, flutterApps, androidAppsRaw, iosAppsRaw, unityApps] = await Promise.all([
46
+ Promise.all(packageJsonFiles.map((p) => packageJsonToAdminOrWebApp(dirPath, p, unityDirs))).then((r) => r.flat()),
44
47
  Promise.all(pubSpecYamlFiles.map((f) => processFlutterDir(dirPath, f))).then((r) => r.flat()),
45
48
  Promise.all(srcMainFolders.map((f) => processAndroidDir(dirPath, f))).then((r) => r.flat()),
46
49
  Promise.all(xCodeProjects.map((f) => processIosDir(dirPath, f))).then((r) => r.flat()),
50
+ Promise.all(unityVersionFiles.map((f) => processUnityDir(dirPath, f))).then((r) => r.flat()),
47
51
  ]);
48
- const androidApps = androidAppsRaw.filter((a) => !flutterApps.some((f) => isPathInside(f.directory, a.directory)));
49
- const iosApps = iosAppsRaw.filter((a) => !flutterApps.some((f) => isPathInside(f.directory, a.directory)));
50
- return [...flutterApps, ...androidApps, ...iosApps, ...adminAndWebApps];
52
+ const androidApps = androidAppsRaw.filter((a) => !flutterApps.some((f) => isPathInside(f.directory, a.directory)) &&
53
+ !unityApps.some((u) => isPathInside(u.directory, a.directory)));
54
+ const iosApps = iosAppsRaw.filter((a) => !flutterApps.some((f) => isPathInside(f.directory, a.directory)) &&
55
+ !unityApps.some((u) => isPathInside(u.directory, a.directory)));
56
+ return [...flutterApps, ...unityApps, ...androidApps, ...iosApps, ...adminAndWebApps];
51
57
  }
52
58
  async function processIosDir(dirPath, filePath) {
53
59
  const iosDir = path.dirname(filePath);
@@ -89,7 +95,7 @@ async function processAndroidDir(dirPath, filePath) {
89
95
  }
90
96
  async function processFlutterDir(dirPath, filePath) {
91
97
  const flutterDir = path.dirname(filePath);
92
- const flutterAppIds = await detectAppIdsForPlatform(dirPath, Platform.FLUTTER);
98
+ const flutterAppIds = await detectAppIdsForPlatform(path.join(dirPath, flutterDir), Platform.FLUTTER);
93
99
  if (flutterAppIds.length === 0) {
94
100
  return [
95
101
  {
@@ -98,20 +104,36 @@ async function processFlutterDir(dirPath, filePath) {
98
104
  },
99
105
  ];
100
106
  }
101
- const flutterApps = await Promise.all(flutterAppIds.map((app) => {
102
- const flutterApp = {
103
- platform: Platform.FLUTTER,
104
- directory: flutterDir,
105
- appId: app.appId,
106
- bundleId: app.bundleId,
107
- };
108
- return flutterApp;
107
+ return flutterAppIds.map((app) => ({
108
+ platform: Platform.FLUTTER,
109
+ directory: flutterDir,
110
+ appId: app.appId,
111
+ bundleId: app.bundleId,
112
+ }));
113
+ }
114
+ async function processUnityDir(dirPath, filePath) {
115
+ const unityDir = path.dirname(path.dirname(filePath));
116
+ const unityAppIds = await detectAppIdsForPlatform(path.join(dirPath, unityDir), Platform.UNITY);
117
+ if (unityAppIds.length === 0) {
118
+ return [
119
+ {
120
+ platform: Platform.UNITY,
121
+ directory: unityDir,
122
+ },
123
+ ];
124
+ }
125
+ return unityAppIds.map((app) => ({
126
+ platform: Platform.UNITY,
127
+ directory: unityDir,
128
+ appId: app.appId,
129
+ bundleId: app.bundleId,
109
130
  }));
110
- return flutterApps.flat();
111
131
  }
112
132
  function isPathInside(parent, child) {
113
133
  const relativePath = path.relative(parent, child);
114
- return !relativePath.startsWith(`..`);
134
+ return (!relativePath.startsWith(`..${path.sep}`) &&
135
+ relativePath !== ".." &&
136
+ !path.isAbsolute(relativePath));
115
137
  }
116
138
  function getAllDepsFromPackageJson(packageJson) {
117
139
  const devDependencies = Object.keys(packageJson.devDependencies ?? {});
@@ -119,8 +141,14 @@ function getAllDepsFromPackageJson(packageJson) {
119
141
  const allDeps = Array.from(new Set([...devDependencies, ...dependencies]));
120
142
  return allDeps;
121
143
  }
122
- async function packageJsonToAdminOrWebApp(dirPath, packageJsonFile) {
144
+ async function packageJsonToAdminOrWebApp(dirPath, packageJsonFile, unityDirs = []) {
123
145
  try {
146
+ const appDir = path.dirname(packageJsonFile);
147
+ const isUnityPackage = unityDirs.some((uDir) => isPathInside(path.join(uDir, "Packages"), appDir));
148
+ if (isUnityPackage) {
149
+ return [];
150
+ }
151
+ const isInsideUnity = unityDirs.some((uDir) => isPathInside(uDir, appDir));
124
152
  const fullPath = path.join(dirPath, packageJsonFile);
125
153
  const packageJson = JSON.parse((await fs.readFile(fullPath)).toString());
126
154
  const allDeps = getAllDepsFromPackageJson(packageJson);
@@ -128,14 +156,17 @@ async function packageJsonToAdminOrWebApp(dirPath, packageJsonFile) {
128
156
  if (allDeps.includes("firebase-admin") || allDeps.includes("firebase-functions")) {
129
157
  detectedApps.push({
130
158
  platform: Platform.ADMIN_NODE,
131
- directory: path.dirname(packageJsonFile),
159
+ directory: appDir,
132
160
  });
133
161
  }
134
- if (allDeps.includes("firebase") || detectedApps.length === 0) {
162
+ const frameworks = getFrameworksFromPackageJson(packageJson);
163
+ if (allDeps.includes("firebase") ||
164
+ (!isInsideUnity && detectedApps.length === 0) ||
165
+ (isInsideUnity && frameworks.length > 0)) {
135
166
  detectedApps.push({
136
167
  platform: Platform.WEB,
137
- directory: path.dirname(packageJsonFile),
138
- frameworks: getFrameworksFromPackageJson(packageJson),
168
+ directory: appDir,
169
+ frameworks,
139
170
  });
140
171
  }
141
172
  return detectedApps;
@@ -149,30 +180,53 @@ const WEB_FRAMEWORKS_SIGNALS = {
149
180
  react: ["react", "next"],
150
181
  angular: ["@angular/core"],
151
182
  };
183
+ function dedupeAppIdentifiers(identifiers) {
184
+ const byAppId = new Map();
185
+ for (const id of identifiers) {
186
+ const existing = byAppId.get(id.appId);
187
+ if (!existing || (!existing.bundleId && id.bundleId)) {
188
+ byAppId.set(id.appId, id);
189
+ }
190
+ }
191
+ return Array.from(byAppId.values());
192
+ }
193
+ async function extractFromFiles(dirPath, filePattern, extractFunc) {
194
+ const files = await detectFiles(dirPath, filePattern);
195
+ const allAppIds = await Promise.all(files.map(async (file) => {
196
+ try {
197
+ const fileContent = (await fs.readFile(path.join(dirPath, file))).toString();
198
+ return extractFunc(fileContent);
199
+ }
200
+ catch {
201
+ return [];
202
+ }
203
+ }));
204
+ return allAppIds.flat();
205
+ }
152
206
  async function detectAppIdsForPlatform(dirPath, platform) {
153
- let appIdFiles;
154
- let extractFunc;
155
207
  switch (platform) {
156
208
  case Platform.ANDROID:
157
- appIdFiles = await detectFiles(dirPath, "google-services*.json*");
158
- extractFunc = extractAppIdentifiersAndroid;
159
- break;
209
+ return extractFromFiles(dirPath, "google-services*.json*", extractAppIdentifiersAndroid);
160
210
  case Platform.IOS:
161
- appIdFiles = await detectFiles(dirPath, "GoogleService-*.plist*");
162
- extractFunc = extractAppIdentifierIos;
163
- break;
164
- case Platform.FLUTTER:
165
- appIdFiles = await detectFiles(dirPath, "firebase_options.dart");
166
- extractFunc = extractAppIdentifiersFlutter;
167
- break;
211
+ return extractFromFiles(dirPath, "GoogleService-*.plist*", extractAppIdentifierIos);
212
+ case Platform.FLUTTER: {
213
+ const [dartIds, androidIds, iosIds] = await Promise.all([
214
+ extractFromFiles(dirPath, "firebase_options*.dart", extractAppIdentifiersFlutter),
215
+ extractFromFiles(dirPath, "google-services*.json*", extractAppIdentifiersAndroid),
216
+ extractFromFiles(dirPath, "GoogleService-*.plist*", extractAppIdentifierIos),
217
+ ]);
218
+ return dedupeAppIdentifiers([...dartIds, ...androidIds, ...iosIds]);
219
+ }
220
+ case Platform.UNITY: {
221
+ const [androidIds, iosIds] = await Promise.all([
222
+ extractFromFiles(dirPath, "google-services*.json*", extractAppIdentifiersAndroid),
223
+ extractFromFiles(dirPath, "GoogleService-*.plist*", extractAppIdentifierIos),
224
+ ]);
225
+ return dedupeAppIdentifiers([...androidIds, ...iosIds]);
226
+ }
168
227
  default:
169
228
  return [];
170
229
  }
171
- const allAppIds = await Promise.all(appIdFiles.map(async (file) => {
172
- const fileContent = (await fs.readFile(path.join(dirPath, file))).toString();
173
- return extractFunc(fileContent);
174
- }));
175
- return allAppIds.flat();
176
230
  }
177
231
  function getFrameworksFromPackageJson(packageJson) {
178
232
  const allDeps = getAllDepsFromPackageJson(packageJson);
@@ -243,9 +297,18 @@ async function detectFiles(dirPath, filePattern) {
243
297
  "**/out/**",
244
298
  "**/.next/**",
245
299
  "**/coverage/**",
300
+ "**/Library/**",
301
+ "**/Temp/**",
302
+ "**/Obj/**",
303
+ "**/Logs/**",
304
+ "**/UserSettings/**",
305
+ "**/*.meta",
306
+ "**/.dart_tool/**",
307
+ "**/Pods/**",
308
+ "**/.symlinks/**",
246
309
  ],
247
310
  absolute: false,
248
- maxDepth: 4,
311
+ maxDepth: 8,
249
312
  };
250
313
  return (0, glob_1.glob)(`**/${filePattern}`, options);
251
314
  }
@@ -60,13 +60,17 @@ class AppDistributionClient {
60
60
  },
61
61
  };
62
62
  const queryParams = { updateMask: "release_notes.text" };
63
+ let response;
63
64
  try {
64
- await this.appDistroV1Client.patch(`/${releaseName}`, data, { queryParams });
65
+ response = await this.appDistroV1Client.patch(`/${releaseName}`, data, {
66
+ queryParams,
67
+ });
65
68
  }
66
69
  catch (err) {
67
70
  throw new error_1.FirebaseError(`failed to update release notes with ${(0, error_1.getErrMsg)(err)}`);
68
71
  }
69
72
  utils.logSuccess("added release notes successfully");
73
+ return response.body;
70
74
  }
71
75
  async distribute(releaseName, testerEmails = [], groupAliases = []) {
72
76
  if (testerEmails.length === 0 && groupAliases.length === 0) {
@@ -126,7 +126,7 @@ function toTestCaseInvocation(testDef, targetUri, defaultConfig) {
126
126
  testCase: {
127
127
  id: testDef.id,
128
128
  prerequisiteTestCaseId: testDef.prerequisiteTestCaseId,
129
- startUri: targetUri + route,
129
+ startUri: `${String(targetUri)}${String(route)}`,
130
130
  displayName: testDef.displayName,
131
131
  steps: steps.map((step) => (0, yaml_helper_1.fromYamlStep)(step)),
132
132
  },
package/lib/auth.js CHANGED
@@ -164,7 +164,7 @@ function setGlobalDefaultAccount(accountOrEmail) {
164
164
  }
165
165
  function open(url) {
166
166
  opn(url).catch((err) => {
167
- logger_1.logger.debug("Unable to open URL: " + err.stack);
167
+ logger_1.logger.debug(`Unable to open URL: ${(0, error_1.getErrStack)(err)}`);
168
168
  });
169
169
  }
170
170
  function invalidCredentialError() {
@@ -82,7 +82,7 @@ function setupProgressiveHelp(client) {
82
82
  nsCmd.action(() => {
83
83
  nsCmd.outputHelp();
84
84
  logger_1.logger.info();
85
- logger_1.logger.info(`To deploy ${targetName}, run: ${clc.bold("firebase deploy --only " + targetName)}`);
85
+ logger_1.logger.info(`To deploy ${targetName}, run: ${clc.bold(`firebase deploy --only ${String(targetName)}`)}`);
86
86
  logger_1.logger.info();
87
87
  });
88
88
  nsCmd.on("--help", () => {
package/lib/command.js CHANGED
@@ -68,7 +68,6 @@ class Command {
68
68
  return this;
69
69
  }
70
70
  register(client) {
71
- this.client = client;
72
71
  const program = client.cli;
73
72
  const cmd = program.command(this.cmd);
74
73
  if (this.descriptionText) {
@@ -298,7 +297,7 @@ function validateProjectId(project) {
298
297
  if (PROJECT_ID_REGEX.test(project)) {
299
298
  return;
300
299
  }
301
- (0, track_1.trackGA4)("error", {
300
+ void (0, track_1.trackGA4)("error", {
302
301
  error_type: "Error (User)",
303
302
  details: "Invalid project ID",
304
303
  });
@@ -40,6 +40,7 @@ exports.command = new command_1.Command("appdistribution:distribute <release-bin
40
40
  .option("--test-case-ids <string>", "a comma-separated list of test case IDs.")
41
41
  .option("--test-case-ids-file <file>", "path to file with a comma- or newline-separated list of test case IDs.")
42
42
  .option("--results-bucket <bucket>", "The name of a Google Cloud Storage bucket where raw results of any automated tests will be stored. If this flag is not set, Firebase creates a bucket for you. Note that the bucket must be owned by a billing-enabled project, and that using a non-default bucket will result in billing charges for the storage used.")
43
+ .help("With --json, the result field contains the uploaded release, including its URLs and updated release notes.")
43
44
  .before(requireAuth_1.requireAuth)
44
45
  .action(async (file, options) => {
45
46
  const appName = (0, options_parser_util_1.getAppName)(options);
@@ -60,7 +61,7 @@ exports.command = new command_1.Command("appdistribution:distribute <release-bin
60
61
  usernameResourceName: options.testUsernameResource,
61
62
  passwordResourceName: options.testPasswordResource,
62
63
  });
63
- await distribute(appName, distribution, testCases, testDevices, releaseNotes, testers, groups, options.testNonBlocking, loginCredential, resultsBucket);
64
+ return distribute(appName, distribution, testCases, testDevices, releaseNotes, testers, groups, options.testNonBlocking, loginCredential, resultsBucket);
64
65
  });
65
66
  async function distribute(appName, distribution, testCases, testDevices, releaseNotes, testers, groups, testNonBlocking, loginCredential, resultsBucket) {
66
67
  const requests = new client_1.AppDistributionClient();
@@ -99,7 +100,7 @@ async function distribute(appName, distribution, testCases, testDevices, release
99
100
  }
100
101
  }
101
102
  }
102
- const release = await (0, distribution_1.upload)(requests, appName, distribution);
103
+ let release = await (0, distribution_1.upload)(requests, appName, distribution);
103
104
  if (aabInfo && !aabInfo.testCertificate) {
104
105
  aabInfo = await requests.getAabInfo(appName);
105
106
  if (aabInfo.testCertificate) {
@@ -112,7 +113,7 @@ async function distribute(appName, distribution, testCases, testDevices, release
112
113
  `SHA-256 certificate fingerprint: ${aabInfo.testCertificate.hashSha256}`);
113
114
  }
114
115
  }
115
- await requests.updateReleaseNotes(release.name, releaseNotes);
116
+ release = (await requests.updateReleaseNotes(release.name, releaseNotes)) ?? release;
116
117
  await requests.distribute(release.name, testers, groups);
117
118
  if (testDevices.length) {
118
119
  utils.logBullet("starting automated test (note: this feature is in beta)");
@@ -138,4 +139,5 @@ async function distribute(appName, distribution, testCases, testDevices, release
138
139
  await (0, distribution_1.awaitTestResults)(releaseTests, requests);
139
140
  }
140
141
  }
142
+ return release;
141
143
  }
@@ -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 commandUtils_1 = require("../crashlytics/commandUtils");
6
+ const events_1 = require("../crashlytics/events");
7
+ const error_1 = require("../error");
8
+ const logger_1 = require("../logger");
9
+ const requireAuth_1 = require("../requireAuth");
10
+ exports.command = new command_1.Command("crashlytics:events:get <eventIds...>")
11
+ .description("get one or more Crashlytics events by event ID or resource name")
12
+ .option("--app <appId>", "the Firebase App ID")
13
+ .option("--max-frames <number>", `maximum stack frames per thread or exception (default: ${events_1.DEFAULT_MAX_FRAMES}, ignored when --full is set)`)
14
+ .option("--full", "include all threads, stack frames, logs, and breadcrumbs without truncation")
15
+ .option("-o, --output <path>", "write raw JSON output to a file")
16
+ .withForce("overwrite output file without prompting")
17
+ .before(requireAuth_1.requireAuth)
18
+ .action(async (eventIds, options) => {
19
+ const appId = (0, commandUtils_1.requireAppId)(options);
20
+ const rawIds = Array.isArray(eventIds)
21
+ ? eventIds.map((id) => String(id).trim()).filter(Boolean)
22
+ : [];
23
+ if (rawIds.length === 0) {
24
+ throw new error_1.FirebaseError("Must specify at least one '<eventId>'.", { exit: 1 });
25
+ }
26
+ if (rawIds.length > 100) {
27
+ throw new error_1.FirebaseError("Cannot request more than 100 events in a single call.", {
28
+ exit: 1,
29
+ });
30
+ }
31
+ const maxFrames = (0, commandUtils_1.parsePositiveIntOption)(options.maxFrames, "--max-frames", {
32
+ defaultValue: events_1.DEFAULT_MAX_FRAMES,
33
+ });
34
+ const resourceNames = rawIds.map((id) => (0, events_1.normalizeEventResourceName)(appId, id));
35
+ const response = await (0, events_1.batchGetEvents)(appId, resourceNames);
36
+ if (!(await (0, commandUtils_1.writeOutputFileIfRequested)(response, options))) {
37
+ const events = response.events || [];
38
+ if (events.length === 0) {
39
+ logger_1.logger.info("No matching events found.");
40
+ }
41
+ else {
42
+ logger_1.logger.info((0, events_1.toText)(events, { maxFrames, full: Boolean(options.full) }));
43
+ }
44
+ }
45
+ return response;
46
+ });