firebase-tools 15.34.1 → 15.34.2
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/apps-android-sha-create.js +1 -1
- package/lib/commands/apps-android-sha-delete.js +1 -1
- package/lib/commands/apps-android-sha-list.js +1 -1
- package/lib/commands/index.js +2 -4
- package/lib/crashlytics/onboarding.js +7 -16
- package/lib/deploy/functions/release/fabricator.js +6 -3
- package/lib/emulator/downloadableEmulatorInfo.json +22 -22
- package/lib/emulator/firestoreEmulator.js +5 -0
- package/lib/emulator/functionsEmulator.js +22 -7
- package/lib/emulator/pubsubEmulator.js +64 -11
- package/lib/emulator/storage/rules/manager.js +31 -15
- package/lib/emulator/taskQueue.js +5 -4
- package/lib/experiments.js +0 -5
- package/lib/extensions/emulator/specHelper.js +0 -4
- package/lib/extensions/extensionsHelper.js +0 -49
- package/lib/extensions/runtimes/common.js +0 -12
- package/lib/extensions/updateHelper.js +2 -88
- package/lib/frameworks/angular/utils.js +3 -2
- package/lib/gcp/cloudlogging.js +0 -54
- package/lib/init/features/aitools/promptUpdater.js +3 -2
- package/lib/mcp/errors.js +1 -1
- package/lib/mcp/util/dataconnect/converter.js +0 -29
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +9 -5
- package/lib/apphosting/repo.js +0 -243
|
@@ -19,7 +19,7 @@ function getCertHashType(shaHash) {
|
|
|
19
19
|
exports.command = new command_1.Command("apps:android:sha:create <appId> <shaHash>")
|
|
20
20
|
.description("add a SHA certificate hash for a given app id")
|
|
21
21
|
.before(requireAuth_1.requireAuth)
|
|
22
|
-
.action(async (appId
|
|
22
|
+
.action(async (appId, shaHash, options) => {
|
|
23
23
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
24
24
|
const shaCertificate = await (0, utils_1.promiseWithSpinner)(async () => await (0, apps_1.createAppAndroidSha)(projectId, appId, {
|
|
25
25
|
shaHash: shaHash,
|
|
@@ -10,7 +10,7 @@ const utils_1 = require("../utils");
|
|
|
10
10
|
exports.command = new command_1.Command("apps:android:sha:delete <appId> <shaId>")
|
|
11
11
|
.description("delete a SHA certificate hash for a given app id")
|
|
12
12
|
.before(requireAuth_1.requireAuth)
|
|
13
|
-
.action(async (appId
|
|
13
|
+
.action(async (appId, shaId, options) => {
|
|
14
14
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
15
15
|
await (0, utils_1.promiseWithSpinner)(async () => await (0, apps_1.deleteAppAndroidSha)(projectId, appId, shaId), `Deleting Android SHA certificate hash with SHA id ${clc.bold(shaId)} and Android app Id ${clc.bold(appId)}`);
|
|
16
16
|
});
|
|
@@ -33,7 +33,7 @@ function logCertificatesCount(count = 0) {
|
|
|
33
33
|
exports.command = new command_1.Command("apps:android:sha:list <appId>")
|
|
34
34
|
.description("list the SHA certificate hashes for a given app id")
|
|
35
35
|
.before(requireAuth_1.requireAuth)
|
|
36
|
-
.action(async (appId
|
|
36
|
+
.action(async (appId, options) => {
|
|
37
37
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
38
38
|
const shaCertificates = await (0, utils_1.promiseWithSpinner)(async () => await (0, apps_1.listAppAndroidSha)(projectId, appId), "Preparing the list of your Firebase Android app SHA certificate hashes");
|
|
39
39
|
logCertificatesList(shaCertificates);
|
package/lib/commands/index.js
CHANGED
|
@@ -76,10 +76,8 @@ function load(client) {
|
|
|
76
76
|
client.crashlytics.mappingfile = {};
|
|
77
77
|
client.crashlytics.mappingfile.generateid = loadCommand("crashlytics-mappingfile-generateid");
|
|
78
78
|
client.crashlytics.mappingfile.upload = loadCommand("crashlytics-mappingfile-upload");
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
client.crashlytics.sourcemap.upload = loadCommand("crashlytics-sourcemap-upload");
|
|
82
|
-
}
|
|
79
|
+
client.crashlytics.sourcemap = {};
|
|
80
|
+
client.crashlytics.sourcemap.upload = loadCommand("crashlytics-sourcemap-upload");
|
|
83
81
|
client.crashlytics.heapdumps = {};
|
|
84
82
|
client.crashlytics.heapdumps.enable = loadCommand("crashlytics-heapdumps-enable");
|
|
85
83
|
client.crashlytics.heapdumps.disable = loadCommand("crashlytics-heapdumps-disable");
|
|
@@ -6,7 +6,6 @@ const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const experiments = require("../experiments");
|
|
8
8
|
const cloudbilling_1 = require("../gcp/cloudbilling");
|
|
9
|
-
const cloudlogging_1 = require("../gcp/cloudlogging");
|
|
10
9
|
const alerts_1 = require("./alerts");
|
|
11
10
|
const firebasetelemetry_1 = require("./firebasetelemetry");
|
|
12
11
|
const types_1 = require("./types");
|
|
@@ -63,7 +62,7 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
63
62
|
try {
|
|
64
63
|
await (0, apikeys_1.updateAppApiKeyRestriction)({
|
|
65
64
|
apiKey: appConfig.apiKey,
|
|
66
|
-
service: exports.
|
|
65
|
+
service: exports.CLIENT_TELEMETRY_SERVICE,
|
|
67
66
|
});
|
|
68
67
|
(0, utils_1.logLabeledSuccess)("crashlytics", "API key restrictions updated for Crashlytics Telemetry.");
|
|
69
68
|
}
|
|
@@ -73,16 +72,8 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
73
72
|
}
|
|
74
73
|
else {
|
|
75
74
|
(0, utils_1.logLabeledWarning)("crashlytics", `No API key found for this app. If you configure an API key later, ` +
|
|
76
|
-
`please rerun this command or manually add '${exports.
|
|
75
|
+
`please rerun this command or manually add '${exports.CLIENT_TELEMETRY_SERVICE}' to its allowed APIs in the Google Cloud Console if the key is restricted.`);
|
|
77
76
|
}
|
|
78
|
-
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Cloud Logging bucket '${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}'...`);
|
|
79
|
-
const bucket = await (0, cloudlogging_1.createOrUpdateLogBucket)(projectId, exports.CRASHLYTICS_TELEMETRY_BUCKET_ID, "global", true);
|
|
80
|
-
(0, utils_1.logLabeledSuccess)("crashlytics", "Cloud Logging bucket configured.");
|
|
81
|
-
const destination = `logging.googleapis.com/projects/${projectId}/locations/global/buckets/${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}`;
|
|
82
|
-
const filter = `resource.type="${exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE}"`;
|
|
83
|
-
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Cloud Logging routing sink '${exports.CRASHLYTICS_TELEMETRY_SINK_ID}'...`);
|
|
84
|
-
const sink = await (0, cloudlogging_1.createOrUpdateLogSink)(projectId, exports.CRASHLYTICS_TELEMETRY_SINK_ID, destination, filter);
|
|
85
|
-
(0, utils_1.logLabeledSuccess)("crashlytics", "Cloud Logging routing sink configured.");
|
|
86
77
|
if (experiments.isEnabled("crashlyticsWebBreadcrumbs")) {
|
|
87
78
|
(0, utils_1.logLabeledBullet)("crashlytics", "Provisioning Cloud Trace storage...");
|
|
88
79
|
try {
|
|
@@ -97,12 +88,12 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
97
88
|
const config = await (0, firebasetelemetry_1.createOrUpdateTelemetryConfig)(projectId, appId, `projects/${projectId}/locations/global/buckets/${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}`, 1);
|
|
98
89
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Crashlytics telemetry configured successfully.");
|
|
99
90
|
if (options.nonInteractive) {
|
|
100
|
-
return {
|
|
91
|
+
return { config };
|
|
101
92
|
}
|
|
102
93
|
const userEmail = await resolveAuthenticatedUserEmail(options);
|
|
103
94
|
if (!userEmail) {
|
|
104
95
|
(0, utils_1.logLabeledWarning)("crashlytics", "Unable to determine authenticated user email for alert setup. You can configure alerts later in the Firebase Console.");
|
|
105
|
-
return {
|
|
96
|
+
return { config };
|
|
106
97
|
}
|
|
107
98
|
const selectedAlerts = await (0, prompt_1.checkbox)({
|
|
108
99
|
message: "Which email alerts would you like to enable? (Optional)",
|
|
@@ -120,16 +111,16 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
120
111
|
],
|
|
121
112
|
});
|
|
122
113
|
if (selectedAlerts.length === 0) {
|
|
123
|
-
return {
|
|
114
|
+
return { config };
|
|
124
115
|
}
|
|
125
116
|
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Crashlytics email alerts for ${userEmail}...`);
|
|
126
117
|
try {
|
|
127
118
|
const alertPolicies = await (0, alerts_1.enableAlerts)(projectId, appId, selectedAlerts, userEmail);
|
|
128
119
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Crashlytics email alerts configured successfully.");
|
|
129
|
-
return {
|
|
120
|
+
return { config, alertPolicies };
|
|
130
121
|
}
|
|
131
122
|
catch (err) {
|
|
132
123
|
(0, utils_1.logLabeledWarning)("crashlytics", (0, error_1.getErrMsg)(err));
|
|
133
|
-
return {
|
|
124
|
+
return { config };
|
|
134
125
|
}
|
|
135
126
|
}
|
|
@@ -578,8 +578,9 @@ class Fabricator {
|
|
|
578
578
|
invoker = ["public"];
|
|
579
579
|
}
|
|
580
580
|
if (invoker) {
|
|
581
|
+
const invokerUpdate = invoker;
|
|
581
582
|
await this.executor
|
|
582
|
-
.run(() => gcf.setInvokerUpdate(endpoint.project, backend.functionName(endpoint),
|
|
583
|
+
.run(() => gcf.setInvokerUpdate(endpoint.project, backend.functionName(endpoint), invokerUpdate))
|
|
583
584
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
584
585
|
}
|
|
585
586
|
}
|
|
@@ -653,8 +654,9 @@ class Fabricator {
|
|
|
653
654
|
: [await gce.getDefaultServiceAccount(this.projectNumber)];
|
|
654
655
|
}
|
|
655
656
|
if (invoker) {
|
|
657
|
+
const invokerUpdate = invoker;
|
|
656
658
|
await this.executor
|
|
657
|
-
.run(() => run.setInvokerUpdate(endpoint.project, serviceName,
|
|
659
|
+
.run(() => run.setInvokerUpdate(endpoint.project, serviceName, invokerUpdate))
|
|
658
660
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
659
661
|
}
|
|
660
662
|
}
|
|
@@ -758,8 +760,9 @@ class Fabricator {
|
|
|
758
760
|
invoker = endpoint.httpsTrigger.invoker === null ? ["public"] : endpoint.httpsTrigger.invoker;
|
|
759
761
|
}
|
|
760
762
|
if (invoker) {
|
|
763
|
+
const invokerUpdate = invoker;
|
|
761
764
|
await this.executor
|
|
762
|
-
.run(() => run.setInvokerUpdate(endpoint.project, serviceName,
|
|
765
|
+
.run(() => run.setInvokerUpdate(endpoint.project, serviceName, invokerUpdate))
|
|
763
766
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
764
767
|
}
|
|
765
768
|
}
|
|
@@ -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.25",
|
|
58
|
+
"expectedSize": 35760048,
|
|
59
|
+
"expectedChecksum": "357570277013f47df1908542d8de4adf",
|
|
60
|
+
"expectedChecksumSHA256": "28520242e277523b66da7ccc9e255e265547471896ee842d820c32ae4d861aa9",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.25",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.25"
|
|
63
63
|
},
|
|
64
64
|
"darwin_arm64": {
|
|
65
|
-
"version": "3.4.
|
|
65
|
+
"version": "3.4.25",
|
|
66
66
|
"expectedSize": 33727618,
|
|
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.
|
|
67
|
+
"expectedChecksum": "f5326947b1de0dfb3d817292188be7ab",
|
|
68
|
+
"expectedChecksumSHA256": "11bf1a66434e32e63e39c2c0e758fc5aa1fcc8bf844062404f73a06e8509c9a9",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.25",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.25"
|
|
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.25",
|
|
74
|
+
"expectedSize": 35740672,
|
|
75
|
+
"expectedChecksum": "da426d34d42478414d11dfa338c5574a",
|
|
76
|
+
"expectedChecksumSHA256": "ac73a8a4f6051382287bb91e5bdab25d500600c17be215ee6372f77586e7f8d6",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.25",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.25.exe"
|
|
79
79
|
},
|
|
80
80
|
"linux": {
|
|
81
|
-
"version": "3.4.
|
|
81
|
+
"version": "3.4.25",
|
|
82
82
|
"expectedSize": 34762914,
|
|
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.
|
|
83
|
+
"expectedChecksum": "1db9678c3c0f1461a9d6a4b0139da409",
|
|
84
|
+
"expectedChecksumSHA256": "6925e7484fc7357f99169411e72dfee490c8ec63de5a49c05fc8c53ad756d9e9",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.25",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.25"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -21,6 +21,11 @@ class FirestoreEmulator {
|
|
|
21
21
|
if (this.args.rules && this.args.project_id) {
|
|
22
22
|
const rulesPath = this.args.rules;
|
|
23
23
|
this.rulesWatcher = chokidar.watch(rulesPath, { persistent: true, ignoreInitial: true });
|
|
24
|
+
this.rulesWatcher.on("error", (err) => {
|
|
25
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
26
|
+
utils.logLabeledWarning("firestore", `Could not watch ${rulesPath} for changes, so rules hot reloading is disabled: ${message}. ` +
|
|
27
|
+
"If your environment does not support file watching, set CHOKIDAR_USEPOLLING=1 to fall back to polling.");
|
|
28
|
+
});
|
|
24
29
|
this.rulesWatcher.on("change", async () => {
|
|
25
30
|
await new Promise((res) => setTimeout(res, 5));
|
|
26
31
|
utils.logLabeledBullet("firestore", "Change detected, updating rules...");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FunctionsEmulator = exports.TCPConn = exports.IPCConn = void 0;
|
|
4
|
+
exports.createIgnoredFilter = createIgnoredFilter;
|
|
4
5
|
const fs = require("fs");
|
|
5
6
|
const path = require("path");
|
|
6
7
|
const express = require("express");
|
|
@@ -15,6 +16,7 @@ const track_1 = require("../track");
|
|
|
15
16
|
const constants_1 = require("./constants");
|
|
16
17
|
const types_1 = require("./types");
|
|
17
18
|
const chokidar = require("chokidar");
|
|
19
|
+
const minimatch = require("minimatch");
|
|
18
20
|
const portfinder = require("portfinder");
|
|
19
21
|
const spawn = require("cross-spawn");
|
|
20
22
|
const functionsEmulatorShared_1 = require("./functionsEmulatorShared");
|
|
@@ -64,6 +66,25 @@ class TCPConn {
|
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
exports.TCPConn = TCPConn;
|
|
69
|
+
function createIgnoredFilter(ignore) {
|
|
70
|
+
const ignored = [
|
|
71
|
+
/(^|[\/\\])\../,
|
|
72
|
+
/.+\.log/,
|
|
73
|
+
/.+?[\\\/]node_modules[\\\/].+?/,
|
|
74
|
+
/.+?[\\\/]venv[\\\/].+?/,
|
|
75
|
+
];
|
|
76
|
+
if (ignore) {
|
|
77
|
+
const minimatchInstances = ignore.map((pattern) => {
|
|
78
|
+
const p = pattern.startsWith("**/") ? pattern : `**/${pattern}`;
|
|
79
|
+
return new minimatch.Minimatch(p, { dot: true });
|
|
80
|
+
});
|
|
81
|
+
ignored.push((filePath) => {
|
|
82
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
83
|
+
return minimatchInstances.some((m) => m.match(normalized));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return ignored;
|
|
87
|
+
}
|
|
67
88
|
class FunctionsEmulator {
|
|
68
89
|
static getHttpFunctionUrl(projectId, name, region, info) {
|
|
69
90
|
let url;
|
|
@@ -298,13 +319,7 @@ class FunctionsEmulator {
|
|
|
298
319
|
}
|
|
299
320
|
else {
|
|
300
321
|
const watcher = chokidar.watch(backend.functionsDir, {
|
|
301
|
-
ignored:
|
|
302
|
-
/(^|[\/\\])\../,
|
|
303
|
-
/.+\.log/,
|
|
304
|
-
/.+?[\\\/]node_modules[\\\/].+?/,
|
|
305
|
-
/.+?[\\\/]venv[\\\/].+?/,
|
|
306
|
-
...(backend.ignore?.map((i) => `**/${i}`) ?? []),
|
|
307
|
-
],
|
|
322
|
+
ignored: createIgnoredFilter(backend.ignore),
|
|
308
323
|
persistent: true,
|
|
309
324
|
});
|
|
310
325
|
this.watchers.push(watcher);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PubsubEmulator = void 0;
|
|
3
|
+
exports.PubsubEmulator = exports.SUBSCRIPTION_CLOSE_TIMEOUT_MS = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
5
|
const pubsub_1 = require("@google-cloud/pubsub");
|
|
6
6
|
const downloadableEmulators = require("./downloadableEmulators");
|
|
@@ -12,6 +12,24 @@ const registry_1 = require("./registry");
|
|
|
12
12
|
const child_process_1 = require("child_process");
|
|
13
13
|
const PUBSUB_KILL_COMMAND = "pubsub_pids=$(ps aux | grep '[p]ubsub-emulator' | awk '{print $2}');" +
|
|
14
14
|
" if [ ! -z '$pubsub_pids' ]; then kill -9 $pubsub_pids; fi;";
|
|
15
|
+
exports.SUBSCRIPTION_CLOSE_TIMEOUT_MS = 2000;
|
|
16
|
+
async function withTimeout(promise, timeoutMs, timeoutMessage) {
|
|
17
|
+
let timer;
|
|
18
|
+
try {
|
|
19
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
20
|
+
timer = setTimeout(() => {
|
|
21
|
+
reject(new Error(timeoutMessage));
|
|
22
|
+
}, timeoutMs);
|
|
23
|
+
timer.unref?.();
|
|
24
|
+
});
|
|
25
|
+
return await Promise.race([promise, timeoutPromise]);
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
if (timer !== undefined) {
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
15
33
|
class PubsubEmulator {
|
|
16
34
|
get pubsub() {
|
|
17
35
|
if (!this._pubsub) {
|
|
@@ -36,13 +54,47 @@ class PubsubEmulator {
|
|
|
36
54
|
}
|
|
37
55
|
async stop() {
|
|
38
56
|
try {
|
|
39
|
-
|
|
57
|
+
const closePromises = Array.from(this.subscriptionForTopic.values()).map(async (sub) => {
|
|
58
|
+
try {
|
|
59
|
+
await withTimeout(sub.close(), exports.SUBSCRIPTION_CLOSE_TIMEOUT_MS, "Timed out waiting " +
|
|
60
|
+
exports.SUBSCRIPTION_CLOSE_TIMEOUT_MS +
|
|
61
|
+
"ms for subscription " +
|
|
62
|
+
sub.name +
|
|
63
|
+
" to close");
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
this.logger.logLabeled("DEBUG", "pubsub", "Failed to close subscription " +
|
|
67
|
+
sub.name +
|
|
68
|
+
": " +
|
|
69
|
+
(err instanceof Error ? err.message : String(err)));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
await Promise.all(closePromises);
|
|
73
|
+
this.subscriptionForTopic.clear();
|
|
74
|
+
this.triggersForTopic.clear();
|
|
75
|
+
if (this._pubsub) {
|
|
76
|
+
try {
|
|
77
|
+
await withTimeout(this._pubsub.close(), exports.SUBSCRIPTION_CLOSE_TIMEOUT_MS, "Timed out waiting " + exports.SUBSCRIPTION_CLOSE_TIMEOUT_MS + "ms for pubsub client to close");
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
this.logger.logLabeled("DEBUG", "pubsub", "Failed to close pubsub client: " + (err instanceof Error ? err.message : String(err)));
|
|
81
|
+
}
|
|
82
|
+
this._pubsub = undefined;
|
|
83
|
+
}
|
|
40
84
|
}
|
|
41
|
-
catch (
|
|
42
|
-
this.logger.logLabeled("DEBUG", "pubsub",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
85
|
+
catch (err) {
|
|
86
|
+
this.logger.logLabeled("DEBUG", "pubsub", "Error during pubsub client cleanup: " + (err instanceof Error ? err.message : String(err)));
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
try {
|
|
90
|
+
await downloadableEmulators.stop(types_1.Emulators.PUBSUB);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
this.logger.logLabeled("DEBUG", "pubsub", e instanceof Error ? e.message : String(e));
|
|
94
|
+
if (process.platform !== "win32") {
|
|
95
|
+
const buffer = (0, child_process_1.execSync)(PUBSUB_KILL_COMMAND);
|
|
96
|
+
this.logger.logLabeled("DEBUG", "pubsub", "Pubsub kill output: " + JSON.stringify(buffer));
|
|
97
|
+
}
|
|
46
98
|
}
|
|
47
99
|
}
|
|
48
100
|
}
|
|
@@ -95,16 +147,17 @@ class PubsubEmulator {
|
|
|
95
147
|
}
|
|
96
148
|
async addTrigger(topicName, triggerKey, signatureType) {
|
|
97
149
|
this.logger.logLabeled("DEBUG", "pubsub", `addTrigger(${topicName}, ${triggerKey}, ${signatureType})`);
|
|
98
|
-
const sub = await this.maybeCreateTopicAndSub(topicName);
|
|
99
150
|
const triggers = this.triggersForTopic.get(topicName) || [];
|
|
100
|
-
if (triggers.some((t) => t.triggerKey === triggerKey)
|
|
101
|
-
this.subscriptionForTopic.has(topicName)) {
|
|
151
|
+
if (triggers.some((t) => t.triggerKey === triggerKey)) {
|
|
102
152
|
this.logger.logLabeled("DEBUG", "pubsub", "Trigger already exists");
|
|
103
153
|
return;
|
|
104
154
|
}
|
|
155
|
+
if (!this.subscriptionForTopic.has(topicName)) {
|
|
156
|
+
const sub = await this.maybeCreateTopicAndSub(topicName);
|
|
157
|
+
this.subscriptionForTopic.set(topicName, sub);
|
|
158
|
+
}
|
|
105
159
|
triggers.push({ triggerKey, signatureType });
|
|
106
160
|
this.triggersForTopic.set(topicName, triggers);
|
|
107
|
-
this.subscriptionForTopic.set(topicName, sub);
|
|
108
161
|
}
|
|
109
162
|
ensureFunctionsClient() {
|
|
110
163
|
if (this.client !== undefined)
|
|
@@ -6,6 +6,8 @@ const emulatorLogger_1 = require("../../emulatorLogger");
|
|
|
6
6
|
const types_1 = require("../../types");
|
|
7
7
|
const runtime_1 = require("./runtime");
|
|
8
8
|
const fsutils_1 = require("../../../fsutils");
|
|
9
|
+
const WATCHER_READY_TIMEOUT_MS = 1000;
|
|
10
|
+
const WATCHER_CHANGE_DELAY_MS = 5;
|
|
9
11
|
function createStorageRulesManager(rules, runtime) {
|
|
10
12
|
return Array.isArray(rules)
|
|
11
13
|
? new ResourceBasedStorageRulesManager(rules, runtime)
|
|
@@ -20,7 +22,7 @@ class DefaultStorageRulesManager {
|
|
|
20
22
|
}
|
|
21
23
|
async start() {
|
|
22
24
|
const issues = await this.loadRuleset();
|
|
23
|
-
this.updateWatcher(this._rules.name);
|
|
25
|
+
await this.updateWatcher(this._rules.name);
|
|
24
26
|
return issues;
|
|
25
27
|
}
|
|
26
28
|
getRuleset() {
|
|
@@ -30,20 +32,34 @@ class DefaultStorageRulesManager {
|
|
|
30
32
|
await this._watcher.close();
|
|
31
33
|
}
|
|
32
34
|
updateWatcher(rulesFile) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const message =
|
|
45
|
-
this._logger.logLabeled("DEBUG", "storage", `A
|
|
46
|
-
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
const timer = setTimeout(resolve, WATCHER_READY_TIMEOUT_MS);
|
|
37
|
+
timer.unref?.();
|
|
38
|
+
this._watcher = chokidar
|
|
39
|
+
.watch(rulesFile, { persistent: true, ignoreInitial: true })
|
|
40
|
+
.once("ready", () => {
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
resolve();
|
|
43
|
+
})
|
|
44
|
+
.on("error", (err) => {
|
|
45
|
+
clearTimeout(timer);
|
|
46
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
47
|
+
this._logger.logLabeled("DEBUG", "storage", `A storage rules file watcher error occurred: ${message}`);
|
|
48
|
+
resolve();
|
|
49
|
+
})
|
|
50
|
+
.on("change", async () => {
|
|
51
|
+
await new Promise((res) => setTimeout(res, WATCHER_CHANGE_DELAY_MS));
|
|
52
|
+
try {
|
|
53
|
+
const content = (0, fsutils_1.readFile)(rulesFile);
|
|
54
|
+
this._rules.content = content;
|
|
55
|
+
this._logger.logLabeled("BULLET", "storage", "Change detected, updating rules for Cloud Storage...");
|
|
56
|
+
await this.loadRuleset();
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
60
|
+
this._logger.logLabeled("DEBUG", "storage", `A rule file change was detected, but there was an error reading it: ${message}`);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
47
63
|
});
|
|
48
64
|
}
|
|
49
65
|
async loadRuleset() {
|
|
@@ -179,10 +179,10 @@ class TaskQueue {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
async runTask(dispatchIndex) {
|
|
182
|
-
|
|
182
|
+
const emulatedTask = this.dispatches[dispatchIndex];
|
|
183
|
+
if (emulatedTask === null) {
|
|
183
184
|
throw new Error("Trying to dispatch a nonexistent task");
|
|
184
185
|
}
|
|
185
|
-
const emulatedTask = this.dispatches[dispatchIndex];
|
|
186
186
|
if (emulatedTask.metadata.lastRunTime !== null &&
|
|
187
187
|
Date.now() - emulatedTask.metadata.lastRunTime < emulatedTask.metadata.currentBackoff * 1000) {
|
|
188
188
|
return;
|
|
@@ -237,10 +237,11 @@ class TaskQueue {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
handleRetry(dispatchIndex) {
|
|
240
|
-
|
|
240
|
+
const task = this.dispatches[dispatchIndex];
|
|
241
|
+
if (task === null) {
|
|
241
242
|
throw new Error("Trying to retry a nonexistent task");
|
|
242
243
|
}
|
|
243
|
-
const { metadata } =
|
|
244
|
+
const { metadata } = task;
|
|
244
245
|
const { retryConfig } = this.config;
|
|
245
246
|
if (this.shouldStopRetrying(metadata, retryConfig)) {
|
|
246
247
|
metadata.status = TaskStatus.FAILED;
|
package/lib/experiments.js
CHANGED
|
@@ -197,11 +197,6 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
197
197
|
default: true,
|
|
198
198
|
public: false,
|
|
199
199
|
},
|
|
200
|
-
crashlyticsWeb: {
|
|
201
|
-
shortDescription: "Enable the ability to upload source maps for web apps to Crashlytics.",
|
|
202
|
-
default: false,
|
|
203
|
-
public: true,
|
|
204
|
-
},
|
|
205
200
|
crashlyticsWebBreadcrumbs: {
|
|
206
201
|
shortDescription: "Enable provisioning Cloud Trace storage during web app onboarding.",
|
|
207
202
|
default: false,
|
|
@@ -4,7 +4,6 @@ exports.DEFAULT_RUNTIME = void 0;
|
|
|
4
4
|
exports.readExtensionYaml = readExtensionYaml;
|
|
5
5
|
exports.readPostinstall = readPostinstall;
|
|
6
6
|
exports.getFunctionResourcesWithParamSubstitution = getFunctionResourcesWithParamSubstitution;
|
|
7
|
-
exports.getFunctionProperties = getFunctionProperties;
|
|
8
7
|
exports.getRuntime = getRuntime;
|
|
9
8
|
const supported = require("../../deploy/functions/runtimes/supported");
|
|
10
9
|
const error_1 = require("../../error");
|
|
@@ -41,9 +40,6 @@ function getFunctionResourcesWithParamSubstitution(extensionSpec, params) {
|
|
|
41
40
|
const rawResources = extensionSpec.resources.filter((resource) => validFunctionTypes.includes(resource.type));
|
|
42
41
|
return (0, extensionsHelper_1.substituteParams)(rawResources, params);
|
|
43
42
|
}
|
|
44
|
-
function getFunctionProperties(resources) {
|
|
45
|
-
return resources.map((r) => r.properties);
|
|
46
|
-
}
|
|
47
43
|
exports.DEFAULT_RUNTIME = supported.latest("nodejs");
|
|
48
44
|
function getRuntime(resources) {
|
|
49
45
|
if (resources.length === 0) {
|
|
@@ -6,7 +6,6 @@ exports.getFirebaseProjectParams = getFirebaseProjectParams;
|
|
|
6
6
|
exports.substituteParams = substituteParams;
|
|
7
7
|
exports.substituteSecretParams = substituteSecretParams;
|
|
8
8
|
exports.populateDefaultParams = populateDefaultParams;
|
|
9
|
-
exports.validateCommandLineParams = validateCommandLineParams;
|
|
10
9
|
exports.validateSpec = validateSpec;
|
|
11
10
|
exports.promptForValidInstanceId = promptForValidInstanceId;
|
|
12
11
|
exports.promptForValidRepoURI = promptForValidRepoURI;
|
|
@@ -23,7 +22,6 @@ exports.createSourceFromLocation = createSourceFromLocation;
|
|
|
23
22
|
exports.getPublisherProjectFromName = getPublisherProjectFromName;
|
|
24
23
|
exports.displayReleaseNotes = displayReleaseNotes;
|
|
25
24
|
exports.promptForRepeatInstance = promptForRepeatInstance;
|
|
26
|
-
exports.instanceIdExists = instanceIdExists;
|
|
27
25
|
exports.isUrlPath = isUrlPath;
|
|
28
26
|
exports.isLocalPath = isLocalPath;
|
|
29
27
|
exports.isLocalOrURLPath = isLocalOrURLPath;
|
|
@@ -47,7 +45,6 @@ const functionsConfig_1 = require("../functionsConfig");
|
|
|
47
45
|
const adminSdkConfig_1 = require("../emulator/adminSdkConfig");
|
|
48
46
|
const error_1 = require("../error");
|
|
49
47
|
const diagnose_1 = require("./diagnose");
|
|
50
|
-
const askUserForParam_1 = require("./askUserForParam");
|
|
51
48
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
52
49
|
const storage_1 = require("../gcp/storage");
|
|
53
50
|
const projectUtils_1 = require("../projectUtils");
|
|
@@ -82,13 +79,6 @@ exports.logPrefix = "extensions";
|
|
|
82
79
|
const VALID_LICENSES = ["apache-2.0"];
|
|
83
80
|
exports.URL_REGEX = /^https:/;
|
|
84
81
|
exports.EXTENSIONS_BUCKET_NAME = (0, utils_1.envOverride)("FIREBASE_EXTENSIONS_UPLOAD_BUCKET", "firebase-ext-eap-uploads");
|
|
85
|
-
const AUTOPOPULATED_PARAM_NAMES = [
|
|
86
|
-
"PROJECT_ID",
|
|
87
|
-
"STORAGE_BUCKET",
|
|
88
|
-
"EXT_INSTANCE_ID",
|
|
89
|
-
"DATABASE_INSTANCE",
|
|
90
|
-
"DATABASE_URL",
|
|
91
|
-
];
|
|
92
82
|
exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = {
|
|
93
83
|
PROJECT_ID: "project-id",
|
|
94
84
|
STORAGE_BUCKET: "project-id.appspot.com",
|
|
@@ -185,25 +175,6 @@ function populateDefaultParams(paramVars, paramSpecs) {
|
|
|
185
175
|
}
|
|
186
176
|
return newParams;
|
|
187
177
|
}
|
|
188
|
-
function validateCommandLineParams(envVars, paramSpec) {
|
|
189
|
-
const paramNames = paramSpec.map((p) => p.param);
|
|
190
|
-
const misnamedParams = Object.keys(envVars).filter((key) => {
|
|
191
|
-
return !paramNames.includes(key) && !AUTOPOPULATED_PARAM_NAMES.includes(key);
|
|
192
|
-
});
|
|
193
|
-
if (misnamedParams.length) {
|
|
194
|
-
logger_1.logger.warn("Warning: The following params were specified in your env file but do not exist in the extension spec: " +
|
|
195
|
-
`${misnamedParams.join(", ")}.`);
|
|
196
|
-
}
|
|
197
|
-
let allParamsValid = true;
|
|
198
|
-
for (const param of paramSpec) {
|
|
199
|
-
if (!(0, askUserForParam_1.checkResponse)(envVars[param.param], param)) {
|
|
200
|
-
allParamsValid = false;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (!allParamsValid) {
|
|
204
|
-
throw new error_1.FirebaseError(`Some param values are not valid. Please check your params file.`);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
178
|
function validateSpec(spec) {
|
|
208
179
|
const errors = [];
|
|
209
180
|
if (!spec.name) {
|
|
@@ -799,26 +770,6 @@ async function promptForRepeatInstance(projectName, extensionName) {
|
|
|
799
770
|
],
|
|
800
771
|
});
|
|
801
772
|
}
|
|
802
|
-
async function instanceIdExists(projectId, instanceId) {
|
|
803
|
-
try {
|
|
804
|
-
await (0, extensionsApi_1.getInstance)(projectId, instanceId);
|
|
805
|
-
}
|
|
806
|
-
catch (err) {
|
|
807
|
-
if (err instanceof error_1.FirebaseError) {
|
|
808
|
-
if (err.status === 404) {
|
|
809
|
-
return false;
|
|
810
|
-
}
|
|
811
|
-
const msg = `Unexpected error when checking if instance ID exists: ${err.message}`;
|
|
812
|
-
throw new error_1.FirebaseError(msg, {
|
|
813
|
-
original: err,
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
else {
|
|
817
|
-
throw err;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
return true;
|
|
821
|
-
}
|
|
822
773
|
function isUrlPath(extInstallPath) {
|
|
823
774
|
return extInstallPath.startsWith("https:");
|
|
824
775
|
}
|
|
@@ -11,9 +11,7 @@ exports.writeSDK = writeSDK;
|
|
|
11
11
|
exports.getCodebaseDir = getCodebaseDir;
|
|
12
12
|
exports.getInstallPathPrefix = getInstallPathPrefix;
|
|
13
13
|
exports.toTitleCase = toTitleCase;
|
|
14
|
-
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
15
14
|
exports.lowercaseFirstLetter = lowercaseFirstLetter;
|
|
16
|
-
exports.snakeToCamelCase = snakeToCamelCase;
|
|
17
15
|
exports.longestCommonPrefix = longestCommonPrefix;
|
|
18
16
|
const fs = require("fs");
|
|
19
17
|
const path = require("path");
|
|
@@ -186,19 +184,9 @@ function getInstallPathPrefix(options) {
|
|
|
186
184
|
function toTitleCase(txt) {
|
|
187
185
|
return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
|
|
188
186
|
}
|
|
189
|
-
function capitalizeFirstLetter(txt) {
|
|
190
|
-
return txt.charAt(0).toUpperCase() + txt.substring(1);
|
|
191
|
-
}
|
|
192
187
|
function lowercaseFirstLetter(txt) {
|
|
193
188
|
return txt.charAt(0).toLowerCase() + txt.substring(1);
|
|
194
189
|
}
|
|
195
|
-
function snakeToCamelCase(txt) {
|
|
196
|
-
let ret = txt.toLowerCase();
|
|
197
|
-
ret = ret.replace(/_/g, " ");
|
|
198
|
-
ret = ret.replace(/\w\S*/g, toTitleCase);
|
|
199
|
-
ret = ret.charAt(0).toLowerCase() + ret.substring(1);
|
|
200
|
-
return ret;
|
|
201
|
-
}
|
|
202
190
|
function longestCommonPrefix(arr) {
|
|
203
191
|
if (arr.length === 0) {
|
|
204
192
|
return "";
|