firebase-tools 15.31.0 → 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 +5 -6
- package/lib/database/import.js +6 -7
- package/lib/deploy/functions/params.js +3 -2
- 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 +1 -1
- 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 stream_chain_1 = require("stream-chain");
|
|
6
5
|
const clc = require("colorette");
|
|
7
6
|
const fs = require("fs-extra");
|
|
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
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,11 +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 =
|
|
82
|
+
const pipeline = chain([
|
|
84
83
|
inStream,
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
pick.withParser({ filter: /^users$/ }),
|
|
85
|
+
streamArray(),
|
|
87
86
|
({ value }) => {
|
|
88
87
|
counter++;
|
|
89
88
|
const user = (0, accountImporter_1.validateUserJson)(value);
|
package/lib/database/import.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const stream_chain_1 = require("stream-chain");
|
|
4
3
|
const clc = require("colorette");
|
|
5
|
-
const filter_js_1 = require("stream-json/filters/filter.js");
|
|
6
4
|
const stream = require("stream");
|
|
7
|
-
const stream_object_js_1 = require("stream-json/streamers/stream-object.js");
|
|
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}`, {
|
|
@@ -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
|
};
|
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_js_1 = require("stream-json/filters/pick.js");
|
|
21
|
-
const stream_object_js_1 = require("stream-json/streamers/stream-object.js");
|
|
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
|
+
}
|