firebase-tools 15.30.3-main.1 → 15.31.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.
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const csv_parse_1 = require("csv-parse");
5
- const Chain = require("stream-chain");
5
+ const stream_chain_1 = require("stream-chain");
6
6
  const clc = require("colorette");
7
7
  const fs = require("fs-extra");
8
- const Pick = require("stream-json/filters/Pick");
9
- const StreamArray = require("stream-json/streamers/StreamArray");
8
+ const pick_js_1 = require("stream-json/filters/pick.js");
9
+ const stream_array_js_1 = require("stream-json/streamers/stream-array.js");
10
10
  const command_1 = require("../command");
11
11
  const error_1 = require("../error");
12
12
  const logger_1 = require("../logger");
@@ -80,9 +80,10 @@ exports.command = new command_1.Command("auth:import [dataFile]")
80
80
  }
81
81
  else {
82
82
  userListArr = await new Promise((resolve, reject) => {
83
- const pipeline = new Chain([
84
- Pick.withParser({ filter: /^users$/ }),
85
- StreamArray.streamArray(),
83
+ const pipeline = (0, stream_chain_1.chain)([
84
+ inStream,
85
+ pick_js_1.pick.withParser({ filter: /^users$/ }),
86
+ (0, stream_array_js_1.streamArray)(),
86
87
  ({ value }) => {
87
88
  counter++;
88
89
  const user = (0, accountImporter_1.validateUserJson)(value);
@@ -97,14 +98,22 @@ exports.command = new command_1.Command("auth:import [dataFile]")
97
98
  }
98
99
  },
99
100
  ]);
100
- pipeline.once("error", reject);
101
- pipeline.on("finish", () => {
101
+ let completed = false;
102
+ const onDone = () => {
103
+ if (completed) {
104
+ return;
105
+ }
106
+ completed = true;
102
107
  if (currentBatch.length) {
103
108
  batches.push(currentBatch);
109
+ currentBatch = [];
104
110
  }
105
111
  resolve(batches);
106
- });
107
- inStream.pipe(pipeline);
112
+ };
113
+ pipeline.once("error", reject);
114
+ pipeline.once("finish", onDone);
115
+ pipeline.once("end", onDone);
116
+ pipeline.resume();
108
117
  });
109
118
  }
110
119
  logger_1.logger.debug(`Preparing to import ${counter} user records in ${userListArr.length} batches.`);
@@ -41,7 +41,8 @@ exports.command = new command_1.Command("crashlytics:sourcemap:upload [mappingFi
41
41
  ignoreStrings: ["node_modules", ".git"],
42
42
  maxDepth: 20,
43
43
  });
44
- const mappings = await (0, sourcemap_1.findSourceMapMappings)(files, rootDir);
44
+ const baseDir = path.basename(filePath) === ".next" ? path.dirname(filePath) : filePath;
45
+ const mappings = await (0, sourcemap_1.findSourceMapMappings)(files, baseDir);
45
46
  const result = await (0, sourcemap_1.uploadSourceMaps)(mappings, {
46
47
  projectId,
47
48
  bucketName,
@@ -24,6 +24,8 @@ const utils_1 = require("../utils");
24
24
  const gcs = require("../gcp/storage");
25
25
  const archiveFile_1 = require("../archiveFile");
26
26
  exports.CONCURRENCY = 25;
27
+ const ANGULAR_DIST_DIR = "dist";
28
+ const ANGULAR_BROWSER_DIR = "browser";
27
29
  function checkGoogleAppID(options) {
28
30
  if (!options.app) {
29
31
  throw new error_1.FirebaseError("set --app <appId> to a valid Firebase application id, e.g. 1:00000000:android:0000000");
@@ -287,9 +289,15 @@ async function uploadSourceMaps(mappings, request) {
287
289
  }
288
290
  async function uploadMap(request, attemptsRemaining = 0) {
289
291
  const { projectId, mappingFile, obfuscatedFilePath, bucketName, appVersion, options } = request;
290
- const filePath = path.relative(options.projectRoot ?? process.cwd(), mappingFile);
291
- const obfuscatedPath = obfuscatedFilePath
292
- .split(path.sep)
292
+ const rootDir = options.projectRoot ?? process.cwd();
293
+ const relativeToRoot = path.relative(rootDir, mappingFile);
294
+ const resolvedCheckPath = path.resolve(rootDir, relativeToRoot);
295
+ const filePath = !fs.existsSync(resolvedCheckPath) && fs.existsSync(mappingFile) ? mappingFile : relativeToRoot;
296
+ const pathSegments = obfuscatedFilePath.split(path.sep);
297
+ const browserIndex = pathSegments.lastIndexOf(ANGULAR_BROWSER_DIR);
298
+ const isAngularBuildDir = filePath.split(path.sep).includes(ANGULAR_DIST_DIR);
299
+ const normalizedSegments = isAngularBuildDir && browserIndex !== -1 ? pathSegments.slice(browserIndex + 1) : pathSegments;
300
+ const obfuscatedPath = normalizedSegments
293
301
  .map((p) => (p === ".next" ? "_next" : p))
294
302
  .filter((p) => p !== "dev")
295
303
  .join("/");
@@ -338,22 +346,44 @@ async function uploadMap(request, attemptsRemaining = 0) {
338
346
  function normalizeFileName(fileName) {
339
347
  return fileName.replaceAll(/\//g, "-");
340
348
  }
349
+ function isAlreadyExistsError(e) {
350
+ if (e.status !== 400) {
351
+ return false;
352
+ }
353
+ const message = e.message.toLowerCase();
354
+ const bodyMessage = (e.context?.body?.error?.message ?? "").toLowerCase();
355
+ return message.includes("already exists") || bodyMessage.includes("already exists");
356
+ }
341
357
  async function registerSourceMap(sourceMap) {
342
358
  const client = new apiv2_1.Client({
343
359
  urlPrefix: "https://firebasetelemetryadmin.googleapis.com",
344
360
  auth: true,
345
361
  apiVersion: "v1alpha",
346
362
  });
347
- try {
363
+ const patchSourceMap = async () => {
348
364
  await client.patch(sourceMap.name, sourceMap, { queryParams: { allowMissing: "true" } });
349
365
  logger_1.logger.debug(`Registered source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry service`);
366
+ };
367
+ try {
368
+ await patchSourceMap();
350
369
  }
351
370
  catch (e) {
352
371
  if (e instanceof error_1.FirebaseError) {
353
372
  if (e.status === 409) {
354
373
  return;
355
374
  }
375
+ if (isAlreadyExistsError(e)) {
376
+ try {
377
+ logger_1.logger.debug(`Source map ${sourceMap.obfuscatedFilePath} already exists, deleting and re-registering`);
378
+ await client.delete(sourceMap.name);
379
+ await patchSourceMap();
380
+ return;
381
+ }
382
+ catch (retryErr) {
383
+ throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry service:\n${retryErr instanceof Error ? retryErr.message : String(retryErr)}`, { original: retryErr instanceof Error ? retryErr : undefined });
384
+ }
385
+ }
356
386
  }
357
- throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry service:\n${e instanceof Error ? e.message : String(e)}`);
387
+ throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry service:\n${e instanceof Error ? e.message : String(e)}`, { original: e instanceof Error ? e : undefined });
358
388
  }
359
389
  }
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Chain = require("stream-chain");
3
+ const stream_chain_1 = require("stream-chain");
4
4
  const clc = require("colorette");
5
- const Filter = require("stream-json/filters/Filter");
5
+ const filter_js_1 = require("stream-json/filters/filter.js");
6
6
  const stream = require("stream");
7
- const StreamObject = require("stream-json/streamers/StreamObject");
7
+ const stream_object_js_1 = require("stream-json/streamers/stream-object.js");
8
8
  const apiv2_1 = require("../apiv2");
9
9
  const error_1 = require("../error");
10
10
  const utils_1 = require("../utils");
@@ -132,13 +132,13 @@ class DatabaseImporter {
132
132
  };
133
133
  return new Promise((resolve, reject) => {
134
134
  const responses = [];
135
- const pipeline = new Chain([
135
+ const pipeline = (0, stream_chain_1.chain)([
136
136
  this.inStream,
137
- Filter.withParser({
137
+ filter_js_1.filter.withParser({
138
138
  filter: this.computeFilterString(this.dataPath) || (() => true),
139
139
  pathSeparator: "/",
140
140
  }),
141
- StreamObject.streamObject(),
141
+ (0, stream_object_js_1.streamObject)(),
142
142
  ]);
143
143
  pipeline
144
144
  .on("error", (err) => reject(new error_1.FirebaseError(`Invalid data; couldn't parse JSON object, array, or value. ${err.message}`, {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DockerHelper = exports.ContainerRegistryCleaner = exports.NoopArtifactRegistryCleaner = exports.ArtifactRegistryCleaner = void 0;
3
+ exports.DockerHelper = exports.ContainerRegistryCleaner = exports.ArtifactRegistryCleaner = void 0;
4
4
  exports.cleanupBuildImages = cleanupBuildImages;
5
5
  exports.listGcfPaths = listGcfPaths;
6
6
  exports.deleteGcfArtifacts = deleteGcfArtifacts;
@@ -134,12 +134,6 @@ ArtifactRegistryCleaner.POLLER_OPTIONS = {
134
134
  apiVersion: artifactregistry.API_VERSION,
135
135
  masterTimeout: 5 * 60 * 1000,
136
136
  };
137
- class NoopArtifactRegistryCleaner extends ArtifactRegistryCleaner {
138
- cleanupFunction() {
139
- return Promise.resolve();
140
- }
141
- }
142
- exports.NoopArtifactRegistryCleaner = NoopArtifactRegistryCleaner;
143
137
  class ContainerRegistryCleaner {
144
138
  constructor() {
145
139
  this.helpers = {};
@@ -54,36 +54,36 @@
54
54
  },
55
55
  "dataconnect": {
56
56
  "darwin": {
57
- "version": "3.4.20",
58
- "expectedSize": 33787120,
59
- "expectedChecksum": "a8c044198a62239fc20a31ef545f8eea",
60
- "expectedChecksumSHA256": "4cbef4430bb5ad72f8fbe2293b938463a1e912b5c17b5577c6546343fe3149a9",
61
- "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.20",
62
- "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.20"
57
+ "version": "3.4.21",
58
+ "expectedSize": 33807728,
59
+ "expectedChecksum": "c9830bf36efd861a179a7d0f1b476d96",
60
+ "expectedChecksumSHA256": "3862f23631fa99ea5114fd59b968b081bab5ac372867591b2d421864f4b30cf7",
61
+ "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.21",
62
+ "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.21"
63
63
  },
64
64
  "darwin_arm64": {
65
- "version": "3.4.20",
66
- "expectedSize": 31883698,
67
- "expectedChecksum": "8c8cf2b1c8b99cb7ebd459ca383aa8ed",
68
- "expectedChecksumSHA256": "873e9aab3aa09a946d4a729e5755d38c5d607655796f5a031f7b21c339fa5ef7",
69
- "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.20",
70
- "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.20"
65
+ "version": "3.4.21",
66
+ "expectedSize": 31900354,
67
+ "expectedChecksum": "06baade26a1f16728b6278c5b39166a7",
68
+ "expectedChecksumSHA256": "b5df8bb2c55535d77a07b90f4c8120975afb3bac39bacfc74cb945fb8e828378",
69
+ "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.21",
70
+ "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.21"
71
71
  },
72
72
  "win32": {
73
- "version": "3.4.20",
74
- "expectedSize": 33819136,
75
- "expectedChecksum": "2bb404ba566f5e2d7224a802c860035c",
76
- "expectedChecksumSHA256": "5e613eddc18378c8b917a94bd7380e6174918ccb29f5bed915927434078bc4a7",
77
- "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.20",
78
- "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.20.exe"
73
+ "version": "3.4.21",
74
+ "expectedSize": 33837056,
75
+ "expectedChecksum": "dbe075ff9320eb9783481f74beccafee",
76
+ "expectedChecksumSHA256": "72ddbf8418f54d5e7827204ac3ac88c80a42e445ee0afd1a021cb2dad9196eb0",
77
+ "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.21",
78
+ "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.21.exe"
79
79
  },
80
80
  "linux": {
81
- "version": "3.4.20",
82
- "expectedSize": 32911544,
83
- "expectedChecksum": "9ae887603b8085e50ff992dd7c86385c",
84
- "expectedChecksumSHA256": "0500ecb9f22c8e26df1f650e656497b542f26b47b3b5730fde850a918643ca2f",
85
- "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.20",
86
- "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.20"
81
+ "version": "3.4.21",
82
+ "expectedSize": 32927928,
83
+ "expectedChecksum": "5b42b3b114d52bec9962f5ba2f8548c7",
84
+ "expectedChecksumSHA256": "504a5a751a4e3ac6851d6e5dc70caefee698570ead7fe2ef324019dc54c6c473",
85
+ "remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.21",
86
+ "downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.21"
87
87
  }
88
88
  }
89
89
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractParamsFromPath = extractParamsFromPath;
4
4
  exports.isValidWildcardMatch = isValidWildcardMatch;
5
5
  exports.trimSlashes = trimSlashes;
6
- exports.removePathSegments = removePathSegments;
7
6
  exports.parseRuntimeVersion = parseRuntimeVersion;
8
7
  exports.parseVersionString = parseVersionString;
9
8
  exports.compareVersionStrings = compareVersionStrings;
@@ -47,9 +46,6 @@ function trimSlashes(str) {
47
46
  .filter((c) => c)
48
47
  .join("/");
49
48
  }
50
- function removePathSegments(path, count) {
51
- return trimSlashes(path).split("/").slice(count).join("/");
52
- }
53
49
  function parseRuntimeVersion(runtime) {
54
50
  if (!runtime) {
55
51
  return undefined;
@@ -17,8 +17,8 @@ const semver_1 = require("semver");
17
17
  const clc = require("colorette");
18
18
  const stream_chain_1 = require("stream-chain");
19
19
  const stream_json_1 = require("stream-json");
20
- const Pick_1 = require("stream-json/filters/Pick");
21
- const StreamObject_1 = require("stream-json/streamers/StreamObject");
20
+ const pick_js_1 = require("stream-json/filters/pick.js");
21
+ const stream_object_js_1 = require("stream-json/streamers/stream-object.js");
22
22
  const fsutils_1 = require("../../fsutils");
23
23
  const prompt_1 = require("../../prompt");
24
24
  const error_1 = require("../../error");
@@ -404,8 +404,8 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
404
404
  const pipeline = (0, stream_chain_1.chain)([
405
405
  npmLs.stdout,
406
406
  (0, stream_json_1.parser)({ packValues: false, packKeys: true, streamValues: false }),
407
- (0, Pick_1.pick)({ filter: "dependencies" }),
408
- (0, StreamObject_1.streamObject)(),
407
+ (0, pick_js_1.pick)({ filter: "dependencies" }),
408
+ (0, stream_object_js_1.streamObject)(),
409
409
  ({ key, value }) => [
410
410
  key,
411
411
  ...(0, utils_2.allDependencyNames)(value),