firebase-tools 15.31.0 → 15.32.1
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/accountImporter.js +6 -3
- package/lib/api.js +2 -4
- package/lib/apphosting/secrets/index.js +7 -2
- package/lib/command.js +1 -1
- package/lib/commands/auth-import.js +5 -6
- package/lib/config.js +1 -0
- package/lib/crashlytics/alerts.js +122 -0
- package/lib/crashlytics/onboarding.js +54 -1
- package/lib/crashlytics/sourcemap.js +46 -11
- package/lib/crashlytics/types.js +6 -1
- package/lib/database/import.js +6 -7
- package/lib/deploy/functions/params.js +7 -4
- package/lib/emulator/auth/operations.js +8 -4
- package/lib/emulator/databaseEmulator.js +7 -3
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/emulatorLogger.js +2 -1
- package/lib/emulator/functionsEmulatorRuntime.js +2 -1
- package/lib/experiments.js +11 -6
- package/lib/extensions/warnings.js +48 -7
- package/lib/frameworks/next/index.js +1 -25
- package/lib/frameworks/next/utils.js +28 -0
- package/lib/functions/kits/install.js +17 -1
- package/lib/gcp/cloudmonitoring.js +80 -3
- package/lib/gcp/cloudtasks.js +1 -1
- package/lib/gcp/resourceManager.js +1 -1
- package/lib/init/features/hosting/index.js +4 -2
- package/lib/management/apps.js +4 -2
- package/lib/management/projects.js +1 -1
- package/lib/scopes.js +1 -3
- package/lib/streamJson.js +37 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +0 -15
- package/package.json +10 -9
- package/schema/firebase-config.json +41 -0
- package/lib/firestore/checkDatabaseType.js +0 -24
|
@@ -17,6 +17,7 @@ class DatabaseEmulator {
|
|
|
17
17
|
constructor(args) {
|
|
18
18
|
this.args = args;
|
|
19
19
|
this.importedNamespaces = [];
|
|
20
|
+
this.rulesWatchers = [];
|
|
20
21
|
this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATABASE);
|
|
21
22
|
}
|
|
22
23
|
async start() {
|
|
@@ -32,8 +33,9 @@ class DatabaseEmulator {
|
|
|
32
33
|
this.logger.logLabeled("WARN_ONCE", "database", "Could not determine your Realtime Database instance name, so rules hot reloading is disabled.");
|
|
33
34
|
continue;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
this.
|
|
36
|
+
const watcher = chokidar.watch(c.rules, { persistent: true, ignoreInitial: true });
|
|
37
|
+
this.rulesWatchers.push(watcher);
|
|
38
|
+
watcher.on("change", async () => {
|
|
37
39
|
await new Promise((res) => setTimeout(res, 5));
|
|
38
40
|
this.logger.logLabeled("BULLET", "database", `Change detected, updating rules for ${c.instance}...`);
|
|
39
41
|
try {
|
|
@@ -67,7 +69,9 @@ class DatabaseEmulator {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
|
-
stop() {
|
|
72
|
+
async stop() {
|
|
73
|
+
await Promise.allSettled(this.rulesWatchers.map((w) => w.close()));
|
|
74
|
+
this.rulesWatchers = [];
|
|
71
75
|
return downloadableEmulators.stop(types_1.Emulators.DATABASE);
|
|
72
76
|
}
|
|
73
77
|
getInfo() {
|
|
@@ -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.22",
|
|
58
|
+
"expectedSize": 33825952,
|
|
59
|
+
"expectedChecksum": "525d67a835615fae6dd2f0a2bfd4611c",
|
|
60
|
+
"expectedChecksumSHA256": "cb4e770c275e4b1202ecc5a05e5897636998ed7410f22c3fc594f4c17b0456b3",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.22",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.22"
|
|
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.22",
|
|
66
|
+
"expectedSize": 31935234,
|
|
67
|
+
"expectedChecksum": "f329037c0651536096e7233ead853857",
|
|
68
|
+
"expectedChecksumSHA256": "df4e0db2970d64e1176dda4875ca38ec4c20cc189bc80a758f462b638addda9c",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.22",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.22"
|
|
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.22",
|
|
74
|
+
"expectedSize": 33855488,
|
|
75
|
+
"expectedChecksum": "7cdc7e6b54e22b61b2b6426df10bdd02",
|
|
76
|
+
"expectedChecksumSHA256": "05454f691c6b2259d2b838e715952105e89dd73184f5eac7dbfe131804f2dc26",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.22",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.22.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.22",
|
|
82
|
+
"expectedSize": 32948408,
|
|
83
|
+
"expectedChecksum": "7ba899a01fc2819c3235b57c1badaf6e",
|
|
84
|
+
"expectedChecksumSHA256": "2a6eb1ccb8b5419cf22f3fdf87d94b6caf1c6c573115fdcd9baa7ea78274c024",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.22",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.22"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -181,7 +181,7 @@ You can probably fix this by running "npm install ${systemLog.data.name}@latest"
|
|
|
181
181
|
case "missing-package-json":
|
|
182
182
|
this.log("WARN", `The Cloud Functions directory you specified does not have a "package.json" file, so we can't load it.`);
|
|
183
183
|
break;
|
|
184
|
-
case "function-code-resolution-failed":
|
|
184
|
+
case "function-code-resolution-failed": {
|
|
185
185
|
this.log("WARN", systemLog.data.error);
|
|
186
186
|
const helper = ["We were unable to load your functions code. (see above)"];
|
|
187
187
|
if (systemLog.data.isPotentially.wrong_directory) {
|
|
@@ -195,6 +195,7 @@ You can probably fix this by running "npm install ${systemLog.data.name}@latest"
|
|
|
195
195
|
}
|
|
196
196
|
utils.logWarning(helper.join("\n"), "warn", this.data);
|
|
197
197
|
break;
|
|
198
|
+
}
|
|
198
199
|
case "function-runtimeconfig-json-invalid":
|
|
199
200
|
this.log("WARN", "Found .runtimeconfig.json but the JSON format is invalid.");
|
|
200
201
|
break;
|
|
@@ -575,7 +575,7 @@ async function main() {
|
|
|
575
575
|
}
|
|
576
576
|
switch (FUNCTION_SIGNATURE) {
|
|
577
577
|
case "event":
|
|
578
|
-
case "cloudevent":
|
|
578
|
+
case "cloudevent": {
|
|
579
579
|
let reqBody;
|
|
580
580
|
const rawBody = req.rawBody;
|
|
581
581
|
if (types_2.EventUtils.isBinaryCloudEvent(req)) {
|
|
@@ -588,6 +588,7 @@ async function main() {
|
|
|
588
588
|
await processBackground(trigger, reqBody, FUNCTION_SIGNATURE);
|
|
589
589
|
res.send({ status: "acknowledged" });
|
|
590
590
|
break;
|
|
591
|
+
}
|
|
591
592
|
case "http":
|
|
592
593
|
await runHTTPS(trigger, [req, res]);
|
|
593
594
|
}
|
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",
|
|
@@ -206,11 +206,16 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
206
206
|
default: false,
|
|
207
207
|
public: true,
|
|
208
208
|
},
|
|
209
|
-
|
|
210
|
-
shortDescription: "Enable
|
|
209
|
+
crashlyticsWebAlerts: {
|
|
210
|
+
shortDescription: "Enable configuring Crashlytics email alerts during web app onboarding.",
|
|
211
211
|
default: false,
|
|
212
212
|
public: false,
|
|
213
213
|
},
|
|
214
|
+
secretEnvParams: {
|
|
215
|
+
shortDescription: "Enable reading the backing resource binding for a Functions secret param from .env",
|
|
216
|
+
default: true,
|
|
217
|
+
public: true,
|
|
218
|
+
},
|
|
214
219
|
extdeprecationwarnings: {
|
|
215
220
|
shortDescription: "Show deprecation warnings for Firebase Extensions CLI commands.",
|
|
216
221
|
default: true,
|
|
@@ -218,8 +223,8 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
218
223
|
},
|
|
219
224
|
extMigrationFeatures: {
|
|
220
225
|
shortDescription: "Enable features intended to assist with the migration of Extension instances to Kits.",
|
|
221
|
-
default:
|
|
222
|
-
public:
|
|
226
|
+
default: true,
|
|
227
|
+
public: true,
|
|
223
228
|
},
|
|
224
229
|
fdcapimigration: {
|
|
225
230
|
shortDescription: "Enable the FDC API schema migration path.",
|
|
@@ -12,6 +12,9 @@ const planner_1 = require("../deploy/extensions/planner");
|
|
|
12
12
|
const error_1 = require("../error");
|
|
13
13
|
const logger_1 = require("../logger");
|
|
14
14
|
const utils = require("../utils");
|
|
15
|
+
const replacementRegistry_1 = require("./replacementRegistry");
|
|
16
|
+
const manifest = require("./manifest");
|
|
17
|
+
const refs = require("./refs");
|
|
15
18
|
const toListEntry = (i) => {
|
|
16
19
|
const idAndRef = (0, deploymentSummary_1.humanReadable)(i);
|
|
17
20
|
const sourceCodeLink = `\n\t[Source Code](${i.extensionVersion?.buildSourceUri ?? i.extensionVersion?.sourceDownloadUri})`;
|
|
@@ -43,6 +46,7 @@ function outOfBandChangesWarning(instanceIds, isDynamic) {
|
|
|
43
46
|
`\nIf you proceed with this deployment, those changes will be overwritten.${extra}`);
|
|
44
47
|
}
|
|
45
48
|
const FAQ_URL = "https://firebase.google.com/docs/extensions/faq-and-troubleshooting";
|
|
49
|
+
const BANNER_BORDER = "=".repeat(80);
|
|
46
50
|
const WARN_BEFORE_COMMANDS = new Set([
|
|
47
51
|
"ext:install",
|
|
48
52
|
"ext:configure",
|
|
@@ -56,7 +60,7 @@ const WARN_STRONGLY_BEFORE_COMMANDS = new Set([
|
|
|
56
60
|
"ext:dev:usage",
|
|
57
61
|
"ext:dev:undeprecate",
|
|
58
62
|
]);
|
|
59
|
-
const WARN_AFTER_COMMANDS = new Set(["ext:list", "ext:info"]);
|
|
63
|
+
const WARN_AFTER_COMMANDS = new Set(["ext:list", "ext:info", "ext:export"]);
|
|
60
64
|
function isSilenced(options) {
|
|
61
65
|
const opts = options;
|
|
62
66
|
if (opts?.json ||
|
|
@@ -77,7 +81,23 @@ function isSilenced(options) {
|
|
|
77
81
|
}
|
|
78
82
|
return false;
|
|
79
83
|
}
|
|
80
|
-
function
|
|
84
|
+
function resolveExtensionRef(commandName, options, args = []) {
|
|
85
|
+
const firstArg = typeof args[0] === "string" ? args[0] : undefined;
|
|
86
|
+
if (!firstArg || (0, extensionsHelper_1.isLocalPath)(firstArg)) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const ref = commandName === "ext:configure" || commandName === "ext:update"
|
|
91
|
+
? manifest.getInstanceRef(firstArg, manifest.loadConfig(options))
|
|
92
|
+
: refs.parse(firstArg);
|
|
93
|
+
return refs.toExtensionRef(ref);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
logger_1.logger.debug(`Could not resolve extension ref for deprecation warning: ${String(err)}`);
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function showDeprecationWarningBefore(commandName, options, args = []) {
|
|
81
101
|
if (commandName === "ext:dev:register") {
|
|
82
102
|
throw new error_1.FirebaseError(`ext:dev:register is disabled. Registering new publisher profile IDs is no longer supported.\n` +
|
|
83
103
|
`The Firebase Extensions service will shut down on March 31, 2027.\n` +
|
|
@@ -87,18 +107,39 @@ function showDeprecationWarningBefore(commandName, options) {
|
|
|
87
107
|
return;
|
|
88
108
|
}
|
|
89
109
|
if (WARN_BEFORE_COMMANDS.has(commandName)) {
|
|
90
|
-
|
|
110
|
+
let actionLine = "We recommend migrating active instances to function kits.";
|
|
111
|
+
const ref = resolveExtensionRef(commandName, options, args);
|
|
112
|
+
if (ref) {
|
|
113
|
+
try {
|
|
114
|
+
const registry = await (0, replacementRegistry_1.getReplacementsRegistry)();
|
|
115
|
+
const npmPackage = (0, replacementRegistry_1.getReplacementPackageName)(ref, registry);
|
|
116
|
+
if (npmPackage) {
|
|
117
|
+
actionLine = `Recommended replacement: ${npmPackage}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
logger_1.logger.debug(`Failed to resolve replacement info for warning: ${String(err)}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
logger_1.logger.warn(clc.yellow(`${BANNER_BORDER}\n` +
|
|
125
|
+
`⚠ Firebase Extensions will shut down on March 31, 2027.\n` +
|
|
126
|
+
`${actionLine}\n` +
|
|
127
|
+
`Learn more & view migration steps: ${FAQ_URL}\n` +
|
|
128
|
+
`${BANNER_BORDER}`));
|
|
91
129
|
}
|
|
92
130
|
else if (WARN_STRONGLY_BEFORE_COMMANDS.has(commandName)) {
|
|
93
|
-
logger_1.logger.warn(clc.yellow(
|
|
131
|
+
logger_1.logger.warn(clc.yellow(`${BANNER_BORDER}\n` +
|
|
94
132
|
`⚠ Notice for Publishers: Firebase Extensions will shut down on March 31, 2027.\n` +
|
|
95
|
-
`Learn more: ${FAQ_URL}\n` +
|
|
96
|
-
|
|
133
|
+
`Learn more & view migration steps: ${FAQ_URL}\n` +
|
|
134
|
+
`${BANNER_BORDER}`));
|
|
97
135
|
}
|
|
98
136
|
}
|
|
99
137
|
function showDeprecationWarningAfter(commandName, options) {
|
|
100
138
|
if (isSilenced(options) || !WARN_AFTER_COMMANDS.has(commandName)) {
|
|
101
139
|
return;
|
|
102
140
|
}
|
|
103
|
-
|
|
141
|
+
if (commandName === "ext:export" && options.mode === "functions") {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
logger_1.logger.warn(clc.yellow(`⚠ Notice: Firebase Extensions will shut down on March 31, 2027. Learn more & view migration steps: ${FAQ_URL}`));
|
|
104
145
|
}
|
|
@@ -15,10 +15,6 @@ 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");
|
|
23
19
|
const prompt_1 = require("../../prompt");
|
|
24
20
|
const error_1 = require("../../error");
|
|
@@ -395,27 +391,7 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
|
|
|
395
391
|
if (!esbuild) {
|
|
396
392
|
throw new error_1.FirebaseError(`Failed to load esbuild from path: ${esbuildPath}`);
|
|
397
393
|
}
|
|
398
|
-
const productionDeps = await
|
|
399
|
-
const dependencies = [];
|
|
400
|
-
const npmLs = (0, cross_spawn_1.spawn)("npm", ["ls", "--omit=dev", "--all", "--json=true"], {
|
|
401
|
-
cwd: sourceDir,
|
|
402
|
-
timeout: constants_1.NPM_COMMAND_TIMEOUT_MILLIES,
|
|
403
|
-
});
|
|
404
|
-
const pipeline = (0, stream_chain_1.chain)([
|
|
405
|
-
npmLs.stdout,
|
|
406
|
-
(0, stream_json_1.parser)({ packValues: false, packKeys: true, streamValues: false }),
|
|
407
|
-
(0, pick_js_1.pick)({ filter: "dependencies" }),
|
|
408
|
-
(0, stream_object_js_1.streamObject)(),
|
|
409
|
-
({ key, value }) => [
|
|
410
|
-
key,
|
|
411
|
-
...(0, utils_2.allDependencyNames)(value),
|
|
412
|
-
],
|
|
413
|
-
]);
|
|
414
|
-
pipeline.on("data", (it) => dependencies.push(it));
|
|
415
|
-
pipeline.on("end", () => {
|
|
416
|
-
resolve([...new Set(dependencies)]);
|
|
417
|
-
});
|
|
418
|
-
});
|
|
394
|
+
const productionDeps = await (0, utils_2.getProductionDependencyNames)(sourceDir);
|
|
419
395
|
const esbuildArgs = {
|
|
420
396
|
entryPoints: [(0, path_1.join)(sourceDir, configFile)],
|
|
421
397
|
outfile: (0, path_1.join)(destDir, configFile),
|
|
@@ -18,6 +18,7 @@ exports.isUsingNextImageInServerComponent = isUsingNextImageInServerComponent;
|
|
|
18
18
|
exports.isUsingNextImageInClientComponent = isUsingNextImageInClientComponent;
|
|
19
19
|
exports.isUsingAppDirectory = isUsingAppDirectory;
|
|
20
20
|
exports.allDependencyNames = allDependencyNames;
|
|
21
|
+
exports.getProductionDependencyNames = getProductionDependencyNames;
|
|
21
22
|
exports.getMiddlewareMatcherRegexes = getMiddlewareMatcherRegexes;
|
|
22
23
|
exports.getNonStaticRoutes = getNonStaticRoutes;
|
|
23
24
|
exports.getNonStaticServerComponents = getNonStaticServerComponents;
|
|
@@ -43,6 +44,9 @@ const utils_1 = require("../utils");
|
|
|
43
44
|
const constants_1 = require("./constants");
|
|
44
45
|
const fsutils_1 = require("../../fsutils");
|
|
45
46
|
const utils_2 = require("../../utils");
|
|
47
|
+
const cross_spawn_1 = require("cross-spawn");
|
|
48
|
+
const streamJson_1 = require("../../streamJson");
|
|
49
|
+
const constants_2 = require("../constants");
|
|
46
50
|
const child_process_1 = require("child_process");
|
|
47
51
|
const error_1 = require("../../error");
|
|
48
52
|
exports.I18N_SOURCE = /\/:nextInternalLocale(\([^\)]+\))?/;
|
|
@@ -175,6 +179,30 @@ function allDependencyNames(mod) {
|
|
|
175
179
|
const dependencyNames = Object.keys(mod.dependencies).reduce((acc, it) => [...acc, it, ...allDependencyNames(mod.dependencies[it])], []);
|
|
176
180
|
return dependencyNames;
|
|
177
181
|
}
|
|
182
|
+
async function getProductionDependencyNames(sourceDir) {
|
|
183
|
+
const { chain, many, parser, pick, streamObject } = await (0, streamJson_1.loadStreamJson)();
|
|
184
|
+
return new Promise((resolve, reject) => {
|
|
185
|
+
const dependencies = [];
|
|
186
|
+
const npmLs = (0, cross_spawn_1.spawn)("npm", ["ls", "--omit=dev", "--all", "--json=true"], {
|
|
187
|
+
cwd: sourceDir,
|
|
188
|
+
timeout: constants_2.NPM_COMMAND_TIMEOUT_MILLIES,
|
|
189
|
+
});
|
|
190
|
+
npmLs.on("error", reject);
|
|
191
|
+
if (!npmLs.stdout) {
|
|
192
|
+
return reject(new error_1.FirebaseError("Failed to capture npm ls output"));
|
|
193
|
+
}
|
|
194
|
+
const pipeline = chain([
|
|
195
|
+
npmLs.stdout,
|
|
196
|
+
parser({ packValues: false, packKeys: true, streamValues: false }),
|
|
197
|
+
pick({ filter: "dependencies" }),
|
|
198
|
+
streamObject(),
|
|
199
|
+
({ key, value }) => many([key, ...allDependencyNames(value)]),
|
|
200
|
+
]);
|
|
201
|
+
pipeline.on("data", (it) => dependencies.push(it));
|
|
202
|
+
pipeline.on("error", reject);
|
|
203
|
+
pipeline.on("end", () => resolve([...new Set(dependencies)]));
|
|
204
|
+
});
|
|
205
|
+
}
|
|
178
206
|
function getMiddlewareMatcherRegexes(middlewareManifest, functionsConfigManifest) {
|
|
179
207
|
const middlewareObjectValues = Object.values(middlewareManifest.middleware);
|
|
180
208
|
const middlewareMatchers = [];
|
|
@@ -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;
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ValueType = exports.Reducer = exports.MetricKind = exports.Aligner = exports.TimeSeriesView = exports.CLOUD_MONITORING_VERSION = void 0;
|
|
4
4
|
exports.queryTimeSeries = queryTimeSeries;
|
|
5
|
+
exports.listNotificationChannels = listNotificationChannels;
|
|
6
|
+
exports.createNotificationChannel = createNotificationChannel;
|
|
7
|
+
exports.getAlertPolicy = getAlertPolicy;
|
|
8
|
+
exports.updateAlertPolicy = updateAlertPolicy;
|
|
5
9
|
const api_1 = require("../api");
|
|
6
10
|
const apiv2_1 = require("../apiv2");
|
|
7
11
|
const error_1 = require("../error");
|
|
@@ -63,15 +67,88 @@ async function queryTimeSeries(query, project) {
|
|
|
63
67
|
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
64
68
|
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
65
69
|
});
|
|
70
|
+
const queryParams = {};
|
|
71
|
+
for (const [key, value] of Object.entries(query)) {
|
|
72
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
73
|
+
queryParams[key] = value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
66
76
|
try {
|
|
67
77
|
const res = await client.get(`/projects/${project}/timeSeries/`, {
|
|
68
|
-
queryParams
|
|
78
|
+
queryParams,
|
|
69
79
|
});
|
|
70
80
|
return res.body.timeSeries;
|
|
71
81
|
}
|
|
72
82
|
catch (err) {
|
|
73
|
-
throw new error_1.FirebaseError(`Failed to get Cloud Monitoring metric: ${err}`, {
|
|
74
|
-
status: err
|
|
83
|
+
throw new error_1.FirebaseError(`Failed to get Cloud Monitoring metric: ${(0, error_1.getErrMsg)(err)}`, {
|
|
84
|
+
status: (0, error_1.getErrStatus)(err),
|
|
85
|
+
original: (0, error_1.getError)(err),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function listNotificationChannels(project, filter) {
|
|
90
|
+
const client = new apiv2_1.Client({
|
|
91
|
+
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
92
|
+
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
93
|
+
});
|
|
94
|
+
try {
|
|
95
|
+
const res = await client.get(`/projects/${project}/notificationChannels`, filter ? { queryParams: { filter } } : {});
|
|
96
|
+
return res.body?.notificationChannels ?? [];
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
throw new error_1.FirebaseError(`Failed to list Cloud Monitoring notification channels: ${(0, error_1.getErrMsg)(err)}`, {
|
|
100
|
+
status: (0, error_1.getErrStatus)(err),
|
|
101
|
+
original: (0, error_1.getError)(err),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function createNotificationChannel(project, channel) {
|
|
106
|
+
const client = new apiv2_1.Client({
|
|
107
|
+
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
108
|
+
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
109
|
+
});
|
|
110
|
+
try {
|
|
111
|
+
const res = await client.post(`/projects/${project}/notificationChannels`, channel);
|
|
112
|
+
return res.body;
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
throw new error_1.FirebaseError(`Failed to create Cloud Monitoring notification channel: ${(0, error_1.getErrMsg)(err)}`, {
|
|
116
|
+
status: (0, error_1.getErrStatus)(err),
|
|
117
|
+
original: (0, error_1.getError)(err),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function getAlertPolicy(name) {
|
|
122
|
+
const client = new apiv2_1.Client({
|
|
123
|
+
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
124
|
+
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
125
|
+
});
|
|
126
|
+
const path = name.startsWith("/") ? name : `/${name}`;
|
|
127
|
+
try {
|
|
128
|
+
const res = await client.get(path);
|
|
129
|
+
return res.body;
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
throw new error_1.FirebaseError(`Failed to get Cloud Monitoring alert policy ${name}: ${(0, error_1.getErrMsg)(err)}`, {
|
|
133
|
+
status: (0, error_1.getErrStatus)(err),
|
|
134
|
+
original: (0, error_1.getError)(err),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function updateAlertPolicy(policy, updateMask) {
|
|
139
|
+
const client = new apiv2_1.Client({
|
|
140
|
+
urlPrefix: (0, api_1.cloudMonitoringOrigin)(),
|
|
141
|
+
apiVersion: exports.CLOUD_MONITORING_VERSION,
|
|
142
|
+
});
|
|
143
|
+
const path = policy.name.startsWith("/") ? policy.name : `/${policy.name}`;
|
|
144
|
+
try {
|
|
145
|
+
const res = await client.patch(path, policy, updateMask ? { queryParams: { updateMask } } : {});
|
|
146
|
+
return res.body;
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
throw new error_1.FirebaseError(`Failed to update Cloud Monitoring alert policy ${policy.name}: ${(0, error_1.getErrMsg)(err)}`, {
|
|
150
|
+
status: (0, error_1.getErrStatus)(err),
|
|
151
|
+
original: (0, error_1.getError)(err),
|
|
75
152
|
});
|
|
76
153
|
}
|
|
77
154
|
}
|
package/lib/gcp/cloudtasks.js
CHANGED
|
@@ -108,7 +108,7 @@ async function setEnqueuer(name, invoker, assumeEmpty = false) {
|
|
|
108
108
|
const invokerMembers = proto.getInvokerMembers(invoker, project);
|
|
109
109
|
while (true) {
|
|
110
110
|
const policy = {
|
|
111
|
-
bindings: existing.bindings.filter((binding) => binding.role !== ENQUEUER_ROLE),
|
|
111
|
+
bindings: (existing.bindings || []).filter((binding) => binding.role !== ENQUEUER_ROLE),
|
|
112
112
|
etag: existing.etag,
|
|
113
113
|
version: existing.version,
|
|
114
114
|
};
|
|
@@ -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,
|
|
@@ -30,7 +30,7 @@ async function askQuestions(setup, config, options) {
|
|
|
30
30
|
case "nuxt2":
|
|
31
31
|
case "express":
|
|
32
32
|
case "svelekit":
|
|
33
|
-
case "sveltekit":
|
|
33
|
+
case "sveltekit": {
|
|
34
34
|
logger_1.logger.info();
|
|
35
35
|
const useAppHosting = await (0, prompt_1.confirm)({
|
|
36
36
|
message: `Detected a ${frameworkName} codebase with SSR features. We can't guarantee that ` +
|
|
@@ -47,7 +47,8 @@ async function askQuestions(setup, config, options) {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
break;
|
|
50
|
-
|
|
50
|
+
}
|
|
51
|
+
default: {
|
|
51
52
|
logger_1.logger.info();
|
|
52
53
|
logger_1.logger.info(`Detected a ${frameworkName} codebase with SSR features. We can't guarantee that ` +
|
|
53
54
|
`this site will work on Firebase Hosting, which is optimized for static sites. Another ` +
|
|
@@ -62,6 +63,7 @@ async function askQuestions(setup, config, options) {
|
|
|
62
63
|
throw new error_1.FirebaseError("Hosting initialization cancelled.", { exit: 1 });
|
|
63
64
|
}
|
|
64
65
|
break;
|
|
66
|
+
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
setup.featureInfo = setup.featureInfo || {};
|
package/lib/management/apps.js
CHANGED
|
@@ -169,14 +169,16 @@ async function sdkInit(appPlatform, options) {
|
|
|
169
169
|
}
|
|
170
170
|
async function getSdkOutputPath(appDir, platform, config) {
|
|
171
171
|
switch (platform) {
|
|
172
|
-
case AppPlatform.ANDROID:
|
|
172
|
+
case AppPlatform.ANDROID: {
|
|
173
173
|
const androidPath = await findIntelligentPathForAndroid(appDir, config);
|
|
174
174
|
return path.join(androidPath, "google-services.json");
|
|
175
|
+
}
|
|
175
176
|
case AppPlatform.WEB:
|
|
176
177
|
return path.join(appDir, "firebase-js-config.json");
|
|
177
|
-
case AppPlatform.IOS:
|
|
178
|
+
case AppPlatform.IOS: {
|
|
178
179
|
const iosPath = await findIntelligentPathForIOS(appDir, config);
|
|
179
180
|
return path.join(iosPath, "GoogleService-Info.plist");
|
|
181
|
+
}
|
|
180
182
|
}
|
|
181
183
|
throw new error_1.FirebaseError("Platform " + platform.toString() + " is not supported yet.");
|
|
182
184
|
}
|
|
@@ -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
|
}
|
package/lib/scopes.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CLOUD_PLATFORM = exports.FIREBASE_PLATFORM = exports.CLOUD_PROJECTS_READONLY = exports.USERINFO_EMAIL = exports.EMAIL = exports.OPENID = void 0;
|
|
4
4
|
exports.OPENID = "openid";
|
|
5
5
|
exports.EMAIL = "email";
|
|
6
6
|
exports.USERINFO_EMAIL = "https://www.googleapis.com/auth/userinfo.email";
|
|
7
7
|
exports.CLOUD_PROJECTS_READONLY = "https://www.googleapis.com/auth/cloudplatformprojects.readonly";
|
|
8
8
|
exports.FIREBASE_PLATFORM = "https://www.googleapis.com/auth/firebase";
|
|
9
9
|
exports.CLOUD_PLATFORM = "https://www.googleapis.com/auth/cloud-platform";
|
|
10
|
-
exports.CLOUD_STORAGE = "https://www.googleapis.com/auth/devstorage.read_write";
|
|
11
|
-
exports.CLOUD_PUBSUB = "https://www.googleapis.com/auth/pubsub";
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
many: streamChain.many,
|
|
25
|
+
parser: streamJson.parser,
|
|
26
|
+
pick: pick.pick,
|
|
27
|
+
filter: filter.filter,
|
|
28
|
+
streamArray: streamArray.streamArray,
|
|
29
|
+
streamObject: streamObject.streamObject,
|
|
30
|
+
};
|
|
31
|
+
})();
|
|
32
|
+
loaded.catch(() => {
|
|
33
|
+
loaded = undefined;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return loaded;
|
|
37
|
+
}
|