firebase-tools 15.30.3-main.2 → 15.32.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.
- package/lib/commands/auth-import.js +18 -10
- package/lib/commands/crashlytics-sourcemap-upload.js +2 -1
- package/lib/crashlytics/sourcemap.js +35 -5
- package/lib/database/import.js +6 -7
- package/lib/deploy/functions/containerCleaner.js +1 -7
- package/lib/deploy/functions/params.js +3 -2
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/functionsEmulatorUtils.js +0 -4
- package/lib/experiments.js +7 -7
- package/lib/frameworks/next/index.js +6 -8
- package/lib/functions/kits/install.js +17 -1
- package/lib/gcp/resourceManager.js +1 -1
- package/lib/management/projects.js +1 -1
- package/lib/streamJson.js +36 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/templates/init/functions/typescript/index-kit.ts +1 -1
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +0 -1
- package/lib/deploy/functions/runtimes/discovery/mockDiscoveryServer.js +0 -14
- package/lib/firestore/checkDatabaseType.js +0 -24
|
@@ -2,16 +2,14 @@
|
|
|
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");
|
|
6
5
|
const clc = require("colorette");
|
|
7
6
|
const fs = require("fs-extra");
|
|
8
|
-
const Pick = require("stream-json/filters/Pick");
|
|
9
|
-
const StreamArray = require("stream-json/streamers/StreamArray");
|
|
10
7
|
const command_1 = require("../command");
|
|
11
8
|
const error_1 = require("../error");
|
|
12
9
|
const logger_1 = require("../logger");
|
|
13
10
|
const projectUtils_1 = require("../projectUtils");
|
|
14
11
|
const requirePermissions_1 = require("../requirePermissions");
|
|
12
|
+
const streamJson_1 = require("../streamJson");
|
|
15
13
|
const accountImporter_1 = require("../accountImporter");
|
|
16
14
|
const MAX_BATCH_SIZE = 1000;
|
|
17
15
|
exports.command = new command_1.Command("auth:import [dataFile]")
|
|
@@ -79,10 +77,12 @@ exports.command = new command_1.Command("auth:import [dataFile]")
|
|
|
79
77
|
});
|
|
80
78
|
}
|
|
81
79
|
else {
|
|
80
|
+
const { chain, pick, streamArray } = await (0, streamJson_1.loadStreamJson)();
|
|
82
81
|
userListArr = await new Promise((resolve, reject) => {
|
|
83
|
-
const pipeline =
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
const pipeline = chain([
|
|
83
|
+
inStream,
|
|
84
|
+
pick.withParser({ filter: /^users$/ }),
|
|
85
|
+
streamArray(),
|
|
86
86
|
({ value }) => {
|
|
87
87
|
counter++;
|
|
88
88
|
const user = (0, accountImporter_1.validateUserJson)(value);
|
|
@@ -97,14 +97,22 @@ exports.command = new command_1.Command("auth:import [dataFile]")
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
]);
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
let completed = false;
|
|
101
|
+
const onDone = () => {
|
|
102
|
+
if (completed) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
completed = true;
|
|
102
106
|
if (currentBatch.length) {
|
|
103
107
|
batches.push(currentBatch);
|
|
108
|
+
currentBatch = [];
|
|
104
109
|
}
|
|
105
110
|
resolve(batches);
|
|
106
|
-
}
|
|
107
|
-
|
|
111
|
+
};
|
|
112
|
+
pipeline.once("error", reject);
|
|
113
|
+
pipeline.once("finish", onDone);
|
|
114
|
+
pipeline.once("end", onDone);
|
|
115
|
+
pipeline.resume();
|
|
108
116
|
});
|
|
109
117
|
}
|
|
110
118
|
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
|
|
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
|
|
291
|
-
const
|
|
292
|
-
|
|
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
|
-
|
|
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
|
}
|
package/lib/database/import.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Chain = require("stream-chain");
|
|
4
3
|
const clc = require("colorette");
|
|
5
|
-
const Filter = require("stream-json/filters/Filter");
|
|
6
4
|
const stream = require("stream");
|
|
7
|
-
const StreamObject = require("stream-json/streamers/StreamObject");
|
|
8
5
|
const apiv2_1 = require("../apiv2");
|
|
9
6
|
const error_1 = require("../error");
|
|
7
|
+
const streamJson_1 = require("../streamJson");
|
|
10
8
|
const utils_1 = require("../utils");
|
|
11
9
|
class BatchChunks extends stream.Transform {
|
|
12
10
|
constructor(maxSize, opts) {
|
|
@@ -109,7 +107,8 @@ class DatabaseImporter {
|
|
|
109
107
|
", then rerun this command.", { exit: 2 });
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
|
-
readAndWriteChunks() {
|
|
110
|
+
async readAndWriteChunks() {
|
|
111
|
+
const { chain, filter, streamObject } = await (0, streamJson_1.loadStreamJson)();
|
|
113
112
|
const { dbUrl, payloadSize } = this;
|
|
114
113
|
const chunkData = this.chunkData.bind(this);
|
|
115
114
|
const doWriteBatch = this.doWriteBatch.bind(this);
|
|
@@ -132,13 +131,13 @@ class DatabaseImporter {
|
|
|
132
131
|
};
|
|
133
132
|
return new Promise((resolve, reject) => {
|
|
134
133
|
const responses = [];
|
|
135
|
-
const pipeline =
|
|
134
|
+
const pipeline = chain([
|
|
136
135
|
this.inStream,
|
|
137
|
-
|
|
136
|
+
filter.withParser({
|
|
138
137
|
filter: this.computeFilterString(this.dataPath) || (() => true),
|
|
139
138
|
pathSeparator: "/",
|
|
140
139
|
}),
|
|
141
|
-
|
|
140
|
+
streamObject(),
|
|
142
141
|
]);
|
|
143
142
|
pipeline
|
|
144
143
|
.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.
|
|
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 = {};
|
|
@@ -485,7 +485,7 @@ async function promptText(prompt, textInput, resolvedDefault, enforceNonEmpty =
|
|
|
485
485
|
}
|
|
486
486
|
async function promptSelect(prompt, input, resolvedDefault, converter) {
|
|
487
487
|
const response = await (0, prompt_1.select)({
|
|
488
|
-
default: resolvedDefault,
|
|
488
|
+
default: resolvedDefault?.toString(),
|
|
489
489
|
message: prompt,
|
|
490
490
|
instructions: "(Use arrow keys to navigate, and Enter to confirm your choice)",
|
|
491
491
|
choices: input.select.options.map((option) => {
|
|
@@ -504,13 +504,14 @@ async function promptSelect(prompt, input, resolvedDefault, converter) {
|
|
|
504
504
|
return converted;
|
|
505
505
|
}
|
|
506
506
|
async function promptSelectMultiple(prompt, input, resolvedDefault, enforceNonEmpty = false, converter) {
|
|
507
|
+
const preselected = new Set((resolvedDefault ?? []).map(String));
|
|
507
508
|
const response = await (0, prompt_1.checkbox)({
|
|
508
509
|
default: resolvedDefault,
|
|
509
510
|
message: prompt,
|
|
510
511
|
instructions: "(Press Space to select, and Enter to confirm your choices)",
|
|
511
512
|
choices: input.multiSelect.options.map((option) => {
|
|
512
513
|
return {
|
|
513
|
-
checked:
|
|
514
|
+
checked: preselected.has(option.value.toString()),
|
|
514
515
|
name: option.label,
|
|
515
516
|
value: option.value.toString(),
|
|
516
517
|
};
|
|
@@ -54,36 +54,36 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dataconnect": {
|
|
56
56
|
"darwin": {
|
|
57
|
-
"version": "3.4.
|
|
58
|
-
"expectedSize":
|
|
59
|
-
"expectedChecksum": "
|
|
60
|
-
"expectedChecksumSHA256": "
|
|
61
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.
|
|
62
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
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.
|
|
66
|
-
"expectedSize":
|
|
67
|
-
"expectedChecksum": "
|
|
68
|
-
"expectedChecksumSHA256": "
|
|
69
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.
|
|
70
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
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.
|
|
74
|
-
"expectedSize":
|
|
75
|
-
"expectedChecksum": "
|
|
76
|
-
"expectedChecksumSHA256": "
|
|
77
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.
|
|
78
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
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.
|
|
82
|
-
"expectedSize":
|
|
83
|
-
"expectedChecksum": "
|
|
84
|
-
"expectedChecksumSHA256": "
|
|
85
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.
|
|
86
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
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;
|
package/lib/experiments.js
CHANGED
|
@@ -81,8 +81,8 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
81
81
|
kits: {
|
|
82
82
|
shortDescription: "Enable Functions Kits.",
|
|
83
83
|
fullDescription: "Adds support for Function Kits.",
|
|
84
|
-
public:
|
|
85
|
-
default:
|
|
84
|
+
public: true,
|
|
85
|
+
default: true,
|
|
86
86
|
},
|
|
87
87
|
emulatoruisnapshot: {
|
|
88
88
|
shortDescription: "Load pre-release versions of the emulator UI",
|
|
@@ -207,9 +207,9 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
207
207
|
public: true,
|
|
208
208
|
},
|
|
209
209
|
secretEnvParams: {
|
|
210
|
-
shortDescription: "Enable
|
|
211
|
-
default:
|
|
212
|
-
public:
|
|
210
|
+
shortDescription: "Enable reading the backing resource binding for a Functions secret param from .env",
|
|
211
|
+
default: true,
|
|
212
|
+
public: true,
|
|
213
213
|
},
|
|
214
214
|
extdeprecationwarnings: {
|
|
215
215
|
shortDescription: "Show deprecation warnings for Firebase Extensions CLI commands.",
|
|
@@ -218,8 +218,8 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
218
218
|
},
|
|
219
219
|
extMigrationFeatures: {
|
|
220
220
|
shortDescription: "Enable features intended to assist with the migration of Extension instances to Kits.",
|
|
221
|
-
default:
|
|
222
|
-
public:
|
|
221
|
+
default: true,
|
|
222
|
+
public: true,
|
|
223
223
|
},
|
|
224
224
|
fdcapimigration: {
|
|
225
225
|
shortDescription: "Enable the FDC API schema migration path.",
|
|
@@ -15,11 +15,8 @@ const fs_extra_1 = require("fs-extra");
|
|
|
15
15
|
const url_1 = require("url");
|
|
16
16
|
const semver_1 = require("semver");
|
|
17
17
|
const clc = require("colorette");
|
|
18
|
-
const stream_chain_1 = require("stream-chain");
|
|
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");
|
|
22
18
|
const fsutils_1 = require("../../fsutils");
|
|
19
|
+
const streamJson_1 = require("../../streamJson");
|
|
23
20
|
const prompt_1 = require("../../prompt");
|
|
24
21
|
const error_1 = require("../../error");
|
|
25
22
|
const utils_1 = require("../utils");
|
|
@@ -395,17 +392,18 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
|
|
|
395
392
|
if (!esbuild) {
|
|
396
393
|
throw new error_1.FirebaseError(`Failed to load esbuild from path: ${esbuildPath}`);
|
|
397
394
|
}
|
|
395
|
+
const { chain, parser, pick, streamObject } = await (0, streamJson_1.loadStreamJson)();
|
|
398
396
|
const productionDeps = await new Promise((resolve) => {
|
|
399
397
|
const dependencies = [];
|
|
400
398
|
const npmLs = (0, cross_spawn_1.spawn)("npm", ["ls", "--omit=dev", "--all", "--json=true"], {
|
|
401
399
|
cwd: sourceDir,
|
|
402
400
|
timeout: constants_1.NPM_COMMAND_TIMEOUT_MILLIES,
|
|
403
401
|
});
|
|
404
|
-
const pipeline =
|
|
402
|
+
const pipeline = chain([
|
|
405
403
|
npmLs.stdout,
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
404
|
+
parser({ packValues: false, packKeys: true, streamValues: false }),
|
|
405
|
+
pick({ filter: "dependencies" }),
|
|
406
|
+
streamObject(),
|
|
409
407
|
({ key, value }) => [
|
|
410
408
|
key,
|
|
411
409
|
...(0, utils_2.allDependencyNames)(value),
|
|
@@ -4,6 +4,7 @@ exports.FUNCTION_KITS_DIR = exports.DEFAULT_TEMPLATE = exports.TEMPLATES = void
|
|
|
4
4
|
exports.generateUniqueId = generateUniqueId;
|
|
5
5
|
exports.parseNpmPackageSpecifier = parseNpmPackageSpecifier;
|
|
6
6
|
exports.validateNpmPackageName = validateNpmPackageName;
|
|
7
|
+
exports.validateNpmPackageExists = validateNpmPackageExists;
|
|
7
8
|
exports.sanitizePackageNameToKitName = sanitizePackageNameToKitName;
|
|
8
9
|
exports.isThirdPartyPackage = isThirdPartyPackage;
|
|
9
10
|
exports.checkPackageHasShrinkwrap = checkPackageHasShrinkwrap;
|
|
@@ -100,6 +101,18 @@ function validateNpmPackageName(packageNameOrSpecifier) {
|
|
|
100
101
|
throw new error_1.FirebaseError(`Invalid NPM package name '${packageNameOrSpecifier}'. Package names must be valid npm package specifiers (e.g. 'my-kit' or '@scope/my-kit').`);
|
|
101
102
|
}
|
|
102
103
|
}
|
|
104
|
+
async function validateNpmPackageExists(rawPkgName) {
|
|
105
|
+
validateNpmPackageName(rawPkgName);
|
|
106
|
+
try {
|
|
107
|
+
const output = await (0, spawn_1.spawnWithOutput)("npm", ["view", rawPkgName, "version"]);
|
|
108
|
+
if (!output.trim()) {
|
|
109
|
+
throw new Error(`No version found for '${rawPkgName}'`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
throw new error_1.FirebaseError(`NPM package '${rawPkgName}' could not be found in the npm registry. Please verify the package name and version.`, { original: err instanceof Error ? err : undefined });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
103
116
|
function sanitizePackageNameToKitName(packageNameOrSpecifier) {
|
|
104
117
|
const { packageName } = parseNpmPackageSpecifier(packageNameOrSpecifier);
|
|
105
118
|
const parts = packageName.split("/");
|
|
@@ -881,7 +894,7 @@ async function resolvePackageSource(options) {
|
|
|
881
894
|
if (!rawPkgName) {
|
|
882
895
|
throw new error_1.FirebaseError("Set the --package option to a valid NPM package and try again.");
|
|
883
896
|
}
|
|
884
|
-
|
|
897
|
+
await validateNpmPackageExists(rawPkgName);
|
|
885
898
|
const { packageName } = parseNpmPackageSpecifier(rawPkgName);
|
|
886
899
|
const isThirdParty = await promptSecurityConfirmation({
|
|
887
900
|
rawPkgName,
|
|
@@ -930,6 +943,9 @@ async function installKitOrInstance(options) {
|
|
|
930
943
|
if (options.directory && options.template) {
|
|
931
944
|
throw new error_1.FirebaseError("Cannot specify --template with --directory.");
|
|
932
945
|
}
|
|
946
|
+
if (options.package) {
|
|
947
|
+
validateNpmPackageName(options.package);
|
|
948
|
+
}
|
|
933
949
|
const originalFunctions = (0, utils_1.cloneDeep)(options.config.src.functions);
|
|
934
950
|
const createdPaths = [];
|
|
935
951
|
let kitId;
|
|
@@ -60,7 +60,7 @@ async function addServiceAccountToRoles(projectId, serviceAccountName, roles, sk
|
|
|
60
60
|
(0, iam_1.mergeBindings)(projectPolicy, requiredBindings);
|
|
61
61
|
return await setIamPolicy(projectId, projectPolicy, "bindings");
|
|
62
62
|
}, {
|
|
63
|
-
retries:
|
|
63
|
+
retries: 7,
|
|
64
64
|
delay: 1000,
|
|
65
65
|
maxDelay: 5000,
|
|
66
66
|
retryPredicate: isRetryableIamError,
|
|
@@ -286,7 +286,7 @@ async function addFirebaseToCloudProject(projectId) {
|
|
|
286
286
|
catch (err) {
|
|
287
287
|
logger_1.logger.debug(err.message);
|
|
288
288
|
if (isTosNotAcceptedError(err)) {
|
|
289
|
-
throw new error_1.FirebaseError(`Failed to add Firebase to Google Cloud Platform project ${clc.bold(projectId)} because your account has not accepted the Firebase Terms of Service. Please accept the Terms of Service in the Firebase console at ${api.consoleOrigin()} and try again.`, { exit: 2, original: err });
|
|
289
|
+
throw new error_1.FirebaseError(`Failed to add Firebase to Google Cloud Platform project ${clc.bold(projectId)} because your account has not accepted the Firebase Terms of Service. Please accept the Terms of Service in the Firebase console at ${api.consoleOrigin()}/?forceCheckTos=true and try again.`, { exit: 2, original: err });
|
|
290
290
|
}
|
|
291
291
|
throw new error_1.FirebaseError("Failed to add Firebase to Google Cloud Platform project. See firebase-debug.log for more info.", { exit: 2, original: err });
|
|
292
292
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadStreamJson = loadStreamJson;
|
|
4
|
+
const url_1 = require("url");
|
|
5
|
+
const importModule = new Function("url", "return import(url)");
|
|
6
|
+
const nodeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
|
|
7
|
+
async function load(specifier) {
|
|
8
|
+
return importModule((0, url_1.pathToFileURL)(nodeRequire.resolve(specifier)).href);
|
|
9
|
+
}
|
|
10
|
+
let loaded;
|
|
11
|
+
function loadStreamJson() {
|
|
12
|
+
if (!loaded) {
|
|
13
|
+
loaded = (async () => {
|
|
14
|
+
const [streamChain, streamJson, pick, filter, streamArray, streamObject] = await Promise.all([
|
|
15
|
+
load("stream-chain"),
|
|
16
|
+
load("stream-json"),
|
|
17
|
+
load("stream-json/filters/pick.js"),
|
|
18
|
+
load("stream-json/filters/filter.js"),
|
|
19
|
+
load("stream-json/streamers/stream-array.js"),
|
|
20
|
+
load("stream-json/streamers/stream-object.js"),
|
|
21
|
+
]);
|
|
22
|
+
return {
|
|
23
|
+
chain: streamChain.chain,
|
|
24
|
+
parser: streamJson.parser,
|
|
25
|
+
pick: pick.pick,
|
|
26
|
+
filter: filter.filter,
|
|
27
|
+
streamArray: streamArray.streamArray,
|
|
28
|
+
streamObject: streamObject.streamObject,
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
loaded.catch(() => {
|
|
32
|
+
loaded = undefined;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return loaded;
|
|
36
|
+
}
|