firebase-tools 11.2.0 → 11.2.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/checkValidTargetFilters.js +1 -1
- package/lib/deploy/functions/prepare.js +1 -1
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +1 -1
- package/lib/emulator/downloadableEmulators.js +5 -5
- package/lib/emulator/functionsEmulator.js +4 -8
- package/lib/emulator/functionsEmulatorRuntime.js +5 -9
- package/lib/emulator/functionsEmulatorShared.js +7 -5
- package/lib/emulator/functionsRuntimeWorker.js +0 -6
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@ function targetsHaveNoFilters(...targets) {
|
|
|
20
20
|
return targets.some((t) => !t.includes(":"));
|
|
21
21
|
}
|
|
22
22
|
async function checkValidTargetFilters(options) {
|
|
23
|
-
const only =
|
|
23
|
+
const only = !options.only ? [] : options.only.split(",");
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
25
|
if (!only.length) {
|
|
26
26
|
return resolve();
|
|
@@ -39,7 +39,7 @@ async function prepare(context, options, payload) {
|
|
|
39
39
|
ensureApiEnabled.ensure(projectId, "cloudfunctions.googleapis.com", "functions"),
|
|
40
40
|
ensureApiEnabled.check(projectId, "runtimeconfig.googleapis.com", "runtimeconfig", true),
|
|
41
41
|
ensure.cloudBuildEnabled(projectId),
|
|
42
|
-
ensureApiEnabled.
|
|
42
|
+
ensureApiEnabled.ensure(projectId, "artifactregistry.googleapis.com", "artifactregistry"),
|
|
43
43
|
]);
|
|
44
44
|
const firebaseConfig = await functionsConfig.getFirebaseConfig(options);
|
|
45
45
|
context.firebaseConfig = firebaseConfig;
|
|
@@ -179,7 +179,7 @@ function addResourcesToBuild(projectId, runtime, annotation, want) {
|
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
const endpointId = annotation.name;
|
|
182
|
-
const endpoint = Object.assign({ platform: annotation.platform || "gcfv1", region: regions, project: projectId, entryPoint: annotation.entryPoint, runtime: runtime, serviceAccount: annotation.serviceAccountEmail ||
|
|
182
|
+
const endpoint = Object.assign({ platform: annotation.platform || "gcfv1", region: regions, project: projectId, entryPoint: annotation.entryPoint, runtime: runtime, serviceAccount: annotation.serviceAccountEmail || null }, triggered);
|
|
183
183
|
if (annotation.vpcConnector != null) {
|
|
184
184
|
let maybeId = annotation.vpcConnector;
|
|
185
185
|
if (maybeId && !maybeId.includes("/")) {
|
|
@@ -29,13 +29,13 @@ exports.DownloadDetails = {
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
firestore: {
|
|
32
|
-
downloadPath: path.join(CACHE_DIR, "cloud-firestore-emulator-v1.14.
|
|
33
|
-
version: "1.14.
|
|
32
|
+
downloadPath: path.join(CACHE_DIR, "cloud-firestore-emulator-v1.14.4.jar"),
|
|
33
|
+
version: "1.14.4",
|
|
34
34
|
opts: {
|
|
35
35
|
cacheDir: CACHE_DIR,
|
|
36
|
-
remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.14.
|
|
37
|
-
expectedSize:
|
|
38
|
-
expectedChecksum: "
|
|
36
|
+
remoteUrl: "https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.14.4.jar",
|
|
37
|
+
expectedSize: 61017177,
|
|
38
|
+
expectedChecksum: "953d10e73798484aa0b84c45005faadb",
|
|
39
39
|
namePrefix: "cloud-firestore-emulator",
|
|
40
40
|
},
|
|
41
41
|
},
|
|
@@ -778,9 +778,10 @@ class FunctionsEmulator {
|
|
|
778
778
|
}
|
|
779
779
|
const runtimeEnv = this.getRuntimeEnvs(backend, trigger);
|
|
780
780
|
const secretEnvs = await this.resolveSecretEnvs(backend, trigger);
|
|
781
|
+
const socketPath = (0, functionsEmulatorShared_1.getTemporarySocketPath)();
|
|
781
782
|
const childProcess = spawn(opts.nodeBinary, args, {
|
|
782
783
|
cwd: backend.functionsDir,
|
|
783
|
-
env: Object.assign(Object.assign(Object.assign({ node: opts.nodeBinary }, process.env), runtimeEnv), secretEnvs),
|
|
784
|
+
env: Object.assign(Object.assign(Object.assign(Object.assign({ node: opts.nodeBinary }, process.env), runtimeEnv), secretEnvs), { PORT: socketPath }),
|
|
784
785
|
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
785
786
|
});
|
|
786
787
|
if (!childProcess.stderr) {
|
|
@@ -812,6 +813,7 @@ class FunctionsEmulator {
|
|
|
812
813
|
}),
|
|
813
814
|
events: emitter,
|
|
814
815
|
cwd: backend.functionsDir,
|
|
816
|
+
socketPath,
|
|
815
817
|
shutdown: () => {
|
|
816
818
|
childProcess.kill();
|
|
817
819
|
},
|
|
@@ -950,12 +952,6 @@ class FunctionsEmulator {
|
|
|
950
952
|
await worker.waitForSocketReady();
|
|
951
953
|
void (0, track_1.track)(EVENT_INVOKE, "https");
|
|
952
954
|
this.logger.log("DEBUG", `[functions] Runtime ready! Sending request!`);
|
|
953
|
-
if (!worker.lastArgs) {
|
|
954
|
-
throw new error_1.FirebaseError("Cannot execute on a worker with no arguments");
|
|
955
|
-
}
|
|
956
|
-
if (!worker.lastArgs.frb.socketPath) {
|
|
957
|
-
throw new error_1.FirebaseError(`Cannot execute on a worker without a socketPath: ${JSON.stringify(worker.lastArgs)}`);
|
|
958
|
-
}
|
|
959
955
|
const url = new url_1.URL(`${req.protocol}://${req.hostname}${req.url}`);
|
|
960
956
|
const path = `${url.pathname}${url.search}`.replace(new RegExp(`\/${this.args.projectId}\/[^\/]*\/${triggerName}\/?`), "/");
|
|
961
957
|
this.logger.log("DEBUG", `[functions] Got req.url=${req.url}, mapping to path=${path}`);
|
|
@@ -963,7 +959,7 @@ class FunctionsEmulator {
|
|
|
963
959
|
method,
|
|
964
960
|
path,
|
|
965
961
|
headers: req.headers,
|
|
966
|
-
socketPath: worker.
|
|
962
|
+
socketPath: worker.runtime.socketPath,
|
|
967
963
|
}, (runtimeRes) => {
|
|
968
964
|
function forwardStatusAndHeaders() {
|
|
969
965
|
res.status(runtimeRes.statusCode || 200);
|
|
@@ -485,14 +485,9 @@ async function initializeFunctionsConfigHelper(frb) {
|
|
|
485
485
|
function rawBodySaver(req, res, buf) {
|
|
486
486
|
req.rawBody = buf;
|
|
487
487
|
}
|
|
488
|
-
async function processHTTPS(trigger
|
|
488
|
+
async function processHTTPS(trigger) {
|
|
489
489
|
const ephemeralServer = express();
|
|
490
490
|
const functionRouter = express.Router();
|
|
491
|
-
const socketPath = frb.socketPath;
|
|
492
|
-
if (!socketPath) {
|
|
493
|
-
new types_1.EmulatorLog("FATAL", "runtime-error", "Called processHTTPS with no socketPath").log();
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
491
|
await new Promise((resolveEphemeralServer, rejectEphemeralServer) => {
|
|
497
492
|
const handler = async (req, res) => {
|
|
498
493
|
try {
|
|
@@ -534,8 +529,9 @@ async function processHTTPS(trigger, frb) {
|
|
|
534
529
|
}));
|
|
535
530
|
functionRouter.all("*", handler);
|
|
536
531
|
ephemeralServer.use([`/`, `/*`], functionRouter);
|
|
537
|
-
logDebug(`Attempting to listen to
|
|
538
|
-
const instance = ephemeralServer.listen(
|
|
532
|
+
logDebug(`Attempting to listen to port: ${process.env.PORT}`);
|
|
533
|
+
const instance = ephemeralServer.listen(process.env.PORT, () => {
|
|
534
|
+
logDebug(`Listening to port: ${process.env.PORT}`);
|
|
539
535
|
new types_1.EmulatorLog("SYSTEM", "runtime-status", "ready", { state: "ready" }).log();
|
|
540
536
|
});
|
|
541
537
|
instance.on("error", rejectEphemeralServer);
|
|
@@ -640,7 +636,7 @@ async function invokeTrigger(trigger, frb) {
|
|
|
640
636
|
await processBackground(trigger, frb, FUNCTION_SIGNATURE);
|
|
641
637
|
break;
|
|
642
638
|
case "http":
|
|
643
|
-
await processHTTPS(trigger
|
|
639
|
+
await processHTTPS(trigger);
|
|
644
640
|
break;
|
|
645
641
|
}
|
|
646
642
|
if (timeoutId) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toBackendInfo = exports.getSecretLocalPath = exports.getSignatureType = exports.formatHost = exports.findModuleRoot = exports.waitForBody = exports.getServiceFromEventType = exports.getFunctionService = exports.getTemporarySocketPath = exports.getEmulatedTriggersFromDefinitions = exports.emulatedFunctionsByRegion = exports.emulatedFunctionsFromEndpoints = exports.prepareEndpoints = exports.EmulatedTrigger = exports.HttpConstants = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
4
|
const os = require("os");
|
|
6
5
|
const path = require("path");
|
|
7
6
|
const fs = require("fs");
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
8
|
+
const _ = require("lodash");
|
|
8
9
|
const backend = require("../deploy/functions/backend");
|
|
9
10
|
const constants_1 = require("./constants");
|
|
10
11
|
const proto_1 = require("../gcp/proto");
|
|
@@ -142,12 +143,13 @@ function getEmulatedTriggersFromDefinitions(definitions, module) {
|
|
|
142
143
|
}, {});
|
|
143
144
|
}
|
|
144
145
|
exports.getEmulatedTriggersFromDefinitions = getEmulatedTriggersFromDefinitions;
|
|
145
|
-
function getTemporarySocketPath(
|
|
146
|
+
function getTemporarySocketPath() {
|
|
147
|
+
const rand = (0, crypto_1.randomBytes)(8).toString("hex");
|
|
146
148
|
if (process.platform === "win32") {
|
|
147
|
-
return path.join("\\\\?\\pipe",
|
|
149
|
+
return path.join("\\\\?\\pipe", `fire_emu_${rand}`);
|
|
148
150
|
}
|
|
149
151
|
else {
|
|
150
|
-
return path.join(os.tmpdir(), `fire_emu_${
|
|
152
|
+
return path.join(os.tmpdir(), `fire_emu_${rand}.sock`);
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
exports.getTemporarySocketPath = getTemporarySocketPath;
|
|
@@ -239,7 +241,7 @@ function formatHost(info) {
|
|
|
239
241
|
}
|
|
240
242
|
exports.formatHost = formatHost;
|
|
241
243
|
function getSignatureType(def) {
|
|
242
|
-
if (def.httpsTrigger) {
|
|
244
|
+
if (def.httpsTrigger || def.blockingTrigger) {
|
|
243
245
|
return "http";
|
|
244
246
|
}
|
|
245
247
|
return def.platform === "gcfv2" ? "cloudevent" : "event";
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RuntimeWorkerPool = exports.RuntimeWorker = exports.RuntimeWorkerState = void 0;
|
|
4
4
|
const uuid = require("uuid");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
|
-
const functionsEmulatorShared_1 = require("./functionsEmulatorShared");
|
|
7
6
|
const events_1 = require("events");
|
|
8
7
|
const emulatorLogger_1 = require("./emulatorLogger");
|
|
9
8
|
const error_1 = require("../error");
|
|
@@ -42,13 +41,8 @@ class RuntimeWorker {
|
|
|
42
41
|
}
|
|
43
42
|
execute(frb, opts) {
|
|
44
43
|
const execFrb = Object.assign({}, frb);
|
|
45
|
-
if (!execFrb.socketPath) {
|
|
46
|
-
execFrb.socketPath = (0, functionsEmulatorShared_1.getTemporarySocketPath)(this.runtime.pid, this.runtime.cwd);
|
|
47
|
-
this.log(`Assigning socketPath: ${execFrb.socketPath}`);
|
|
48
|
-
}
|
|
49
44
|
const args = { frb: execFrb, opts };
|
|
50
45
|
this.state = RuntimeWorkerState.BUSY;
|
|
51
|
-
this.lastArgs = args;
|
|
52
46
|
this.runtime.send(args);
|
|
53
47
|
}
|
|
54
48
|
get state() {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.1",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "firebase-tools",
|
|
9
|
-
"version": "11.2.
|
|
9
|
+
"version": "11.2.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@google-cloud/pubsub": "^3.0.1",
|