firebase-tools-with-isolate 15.30.1 → 15.31.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 +19 -10
- package/lib/commands/crashlytics-sourcemap-upload.js +2 -1
- package/lib/commands/ext-migrate.js +1 -1
- package/lib/crashlytics/sourcemap.js +35 -5
- package/lib/database/import.js +6 -6
- package/lib/deploy/functions/build.js +44 -13
- package/lib/deploy/functions/containerCleaner.js +1 -7
- package/lib/deploy/functions/params.js +40 -84
- package/lib/deploy/functions/prepare.js +7 -4
- package/lib/deploy/functions/runtimes/python/index.js +48 -17
- package/lib/emulator/auth/cloudFunctions.js +40 -5
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/functionsEmulator.js +13 -4
- package/lib/emulator/functionsEmulatorShared.js +14 -3
- package/lib/emulator/functionsEmulatorUtils.js +0 -4
- package/lib/experiments.js +6 -1
- package/lib/extensions/export.js +21 -11
- package/lib/extensions/replacements.json +15 -22
- package/lib/frameworks/next/index.js +4 -4
- package/lib/fsutils.js +20 -2
- package/lib/functions/kits/install.js +143 -78
- package/lib/functions/python.js +82 -0
- package/lib/management/projects.js +14 -0
- package/lib/prompt.js +4 -0
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +6 -11
- package/templates/init/functions/typescript/index-kit.ts +1 -1
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +0 -1
- package/lib/deploy/functions/runtimes/discovery/mockDiscoveryServer.js +0 -14
|
@@ -13,6 +13,10 @@ const logger_1 = require("../../../../logger");
|
|
|
13
13
|
const python_1 = require("../../../../functions/python");
|
|
14
14
|
const error_1 = require("../../../../error");
|
|
15
15
|
const functional_1 = require("../../../../functional");
|
|
16
|
+
const utils_1 = require("../../../../utils");
|
|
17
|
+
const FORCE_KILL_DELAY_MS = 10000;
|
|
18
|
+
const SHUTDOWN_TIMEOUT_MS = 15000;
|
|
19
|
+
const QUITQUITQUIT_TIMEOUT_MS = 5000;
|
|
16
20
|
async function tryCreateDelegate(context) {
|
|
17
21
|
const requirementsTextPath = path.join(context.sourceDir, "requirements.txt");
|
|
18
22
|
if (!(await (0, util_1.promisify)(fs.exists)(requirementsTextPath))) {
|
|
@@ -120,31 +124,58 @@ class Delegate {
|
|
|
120
124
|
};
|
|
121
125
|
const args = [this.bin, `"${path.join(modulesDir, "private", "serving.py")}"`];
|
|
122
126
|
logger_1.logger.debug(`Running admin server with args: ${JSON.stringify(args)} and env: ${JSON.stringify(envWithAdminPort)} in ${this.sourceDir}`);
|
|
123
|
-
const childProcess = (0, python_1.runWithVirtualEnv)(args, this.sourceDir, envWithAdminPort
|
|
127
|
+
const childProcess = (0, python_1.runWithVirtualEnv)(args, this.sourceDir, envWithAdminPort, {
|
|
128
|
+
detached: !utils_1.IS_WINDOWS,
|
|
129
|
+
});
|
|
124
130
|
childProcess.stdout?.on("data", (chunk) => {
|
|
125
131
|
logger_1.logger.info(chunk.toString("utf8"));
|
|
126
132
|
});
|
|
127
133
|
childProcess.stderr?.on("data", (chunk) => {
|
|
128
134
|
logger_1.logger.error(chunk.toString("utf8"));
|
|
129
135
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}, 10000);
|
|
142
|
-
clearTimeout(quitTimeout);
|
|
143
|
-
return new Promise((resolve, reject) => {
|
|
144
|
-
childProcess.once("exit", resolve);
|
|
145
|
-
childProcess.once("error", reject);
|
|
136
|
+
const exited = new Promise((resolve) => {
|
|
137
|
+
childProcess.once("exit", () => resolve());
|
|
138
|
+
childProcess.once("error", () => resolve());
|
|
139
|
+
});
|
|
140
|
+
(0, python_1.trackVirtualEnvChild)(childProcess);
|
|
141
|
+
return Promise.resolve(() => this.shutdownAdmin(childProcess, port, exited));
|
|
142
|
+
}
|
|
143
|
+
async shutdownAdmin(childProcess, port, exited) {
|
|
144
|
+
try {
|
|
145
|
+
await fetch(`http://127.0.0.1:${port}/__/quitquitquit`, {
|
|
146
|
+
signal: AbortSignal.timeout(QUITQUITQUIT_TIMEOUT_MS),
|
|
146
147
|
});
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
logger_1.logger.debug("Failed to call quitquitquit. This often means the server failed to start", e);
|
|
151
|
+
}
|
|
152
|
+
const forceKill = setTimeout(() => {
|
|
153
|
+
if (childProcess.pid) {
|
|
154
|
+
logger_1.logger.debug(`Discovery admin server on port ${port} did not shut down when asked. Force-killing it.`);
|
|
155
|
+
(0, python_1.killProcessTree)(childProcess.pid);
|
|
156
|
+
}
|
|
157
|
+
}, FORCE_KILL_DELAY_MS);
|
|
158
|
+
let giveUp;
|
|
159
|
+
const timedOut = new Promise((resolve) => {
|
|
160
|
+
giveUp = setTimeout(() => resolve(false), SHUTDOWN_TIMEOUT_MS);
|
|
147
161
|
});
|
|
162
|
+
try {
|
|
163
|
+
const exitedCleanly = await Promise.race([exited.then(() => true), timedOut]);
|
|
164
|
+
if (exitedCleanly) {
|
|
165
|
+
(0, python_1.untrackVirtualEnvChild)(childProcess);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
logger_1.logger.debug(`Discovery admin server on port ${port} survived being force-killed. ` +
|
|
169
|
+
`Continuing without it; it may need to be cleaned up manually.`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
clearTimeout(forceKill);
|
|
174
|
+
clearTimeout(giveUp);
|
|
175
|
+
childProcess.stdout?.destroy();
|
|
176
|
+
childProcess.stderr?.destroy();
|
|
177
|
+
childProcess.unref();
|
|
178
|
+
}
|
|
148
179
|
}
|
|
149
180
|
async discoverBuild(_configValues, envs) {
|
|
150
181
|
let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
|
|
@@ -5,6 +5,10 @@ const crypto_1 = require("crypto");
|
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const emulatorLogger_1 = require("../emulatorLogger");
|
|
7
7
|
const registry_1 = require("../registry");
|
|
8
|
+
const AUTH_V2_ACTION_MAP = {
|
|
9
|
+
create: "created",
|
|
10
|
+
delete: "deleted",
|
|
11
|
+
};
|
|
8
12
|
class AuthCloudFunction {
|
|
9
13
|
constructor(projectId) {
|
|
10
14
|
this.projectId = projectId;
|
|
@@ -16,17 +20,32 @@ class AuthCloudFunction {
|
|
|
16
20
|
if (!this.enabled)
|
|
17
21
|
return;
|
|
18
22
|
const userInfoPayload = this.createUserInfoPayload(user);
|
|
19
|
-
const
|
|
23
|
+
const legacyEventBody = this.createEventRequestBody(action, userInfoPayload);
|
|
24
|
+
const v2CloudEventBody = this.createCloudEventRequestBody(action, userInfoPayload);
|
|
20
25
|
const c = registry_1.EmulatorRegistry.client(types_1.Emulators.FUNCTIONS);
|
|
21
|
-
|
|
26
|
+
const errStatus = [];
|
|
22
27
|
let err;
|
|
23
28
|
try {
|
|
24
|
-
|
|
29
|
+
const legacyRes = await c.post(`/functions/projects/${this.projectId}/trigger_multicast`, legacyEventBody);
|
|
30
|
+
if (legacyRes.status !== 200) {
|
|
31
|
+
errStatus.push(legacyRes.status);
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
34
|
catch (e) {
|
|
27
|
-
err = e;
|
|
35
|
+
err = e instanceof Error ? e : new Error(String(e));
|
|
28
36
|
}
|
|
29
|
-
|
|
37
|
+
try {
|
|
38
|
+
const v2Res = await c.post(`/functions/projects/${this.projectId}/trigger_multicast`, v2CloudEventBody, {
|
|
39
|
+
headers: { "Content-Type": "application/cloudevents+json; charset=UTF-8" },
|
|
40
|
+
});
|
|
41
|
+
if (v2Res.status !== 200) {
|
|
42
|
+
errStatus.push(v2Res.status);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
err = e instanceof Error ? e : new Error(String(e));
|
|
47
|
+
}
|
|
48
|
+
if (err || errStatus.length > 0) {
|
|
30
49
|
this.logger.logLabeled("WARN", "functions", `Firebase Authentication function was not triggered due to emulation error. Please file a bug.`);
|
|
31
50
|
}
|
|
32
51
|
}
|
|
@@ -43,6 +62,22 @@ class AuthCloudFunction {
|
|
|
43
62
|
data: userInfoPayload,
|
|
44
63
|
};
|
|
45
64
|
}
|
|
65
|
+
createCloudEventRequestBody(action, userInfoPayload) {
|
|
66
|
+
const ceAction = AUTH_V2_ACTION_MAP[action];
|
|
67
|
+
const cloudEvent = {
|
|
68
|
+
specversion: "1.0",
|
|
69
|
+
id: (0, crypto_1.randomUUID)(),
|
|
70
|
+
time: new Date().toISOString(),
|
|
71
|
+
type: `google.firebase.auth.user.v2.${ceAction}`,
|
|
72
|
+
source: `//identitytoolkit.googleapis.com/projects/${this.projectId}`,
|
|
73
|
+
subject: `users/${userInfoPayload.uid}`,
|
|
74
|
+
data: action === "create" ? { value: userInfoPayload } : { oldValue: userInfoPayload },
|
|
75
|
+
};
|
|
76
|
+
if (userInfoPayload.tenantId) {
|
|
77
|
+
cloudEvent.tenantid = userInfoPayload.tenantId;
|
|
78
|
+
}
|
|
79
|
+
return cloudEvent;
|
|
80
|
+
}
|
|
46
81
|
createUserInfoPayload(user) {
|
|
47
82
|
return {
|
|
48
83
|
uid: user.localId,
|
|
@@ -54,36 +54,36 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dataconnect": {
|
|
56
56
|
"darwin": {
|
|
57
|
-
"version": "3.4.
|
|
58
|
-
"expectedSize":
|
|
59
|
-
"expectedChecksum": "
|
|
60
|
-
"expectedChecksumSHA256": "
|
|
61
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.
|
|
62
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
57
|
+
"version": "3.4.21",
|
|
58
|
+
"expectedSize": 33807728,
|
|
59
|
+
"expectedChecksum": "c9830bf36efd861a179a7d0f1b476d96",
|
|
60
|
+
"expectedChecksumSHA256": "3862f23631fa99ea5114fd59b968b081bab5ac372867591b2d421864f4b30cf7",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.21",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.21"
|
|
63
63
|
},
|
|
64
64
|
"darwin_arm64": {
|
|
65
|
-
"version": "3.4.
|
|
66
|
-
"expectedSize":
|
|
67
|
-
"expectedChecksum": "
|
|
68
|
-
"expectedChecksumSHA256": "
|
|
69
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.
|
|
70
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
65
|
+
"version": "3.4.21",
|
|
66
|
+
"expectedSize": 31900354,
|
|
67
|
+
"expectedChecksum": "06baade26a1f16728b6278c5b39166a7",
|
|
68
|
+
"expectedChecksumSHA256": "b5df8bb2c55535d77a07b90f4c8120975afb3bac39bacfc74cb945fb8e828378",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.21",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.21"
|
|
71
71
|
},
|
|
72
72
|
"win32": {
|
|
73
|
-
"version": "3.4.
|
|
74
|
-
"expectedSize":
|
|
75
|
-
"expectedChecksum": "
|
|
76
|
-
"expectedChecksumSHA256": "
|
|
77
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.
|
|
78
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
73
|
+
"version": "3.4.21",
|
|
74
|
+
"expectedSize": 33837056,
|
|
75
|
+
"expectedChecksum": "dbe075ff9320eb9783481f74beccafee",
|
|
76
|
+
"expectedChecksumSHA256": "72ddbf8418f54d5e7827204ac3ac88c80a42e445ee0afd1a021cb2dad9196eb0",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.21",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.21.exe"
|
|
79
79
|
},
|
|
80
80
|
"linux": {
|
|
81
|
-
"version": "3.4.
|
|
82
|
-
"expectedSize":
|
|
83
|
-
"expectedChecksum": "
|
|
84
|
-
"expectedChecksumSHA256": "
|
|
85
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.
|
|
86
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
81
|
+
"version": "3.4.21",
|
|
82
|
+
"expectedSize": 32927928,
|
|
83
|
+
"expectedChecksum": "5b42b3b114d52bec9962f5ba2f8548c7",
|
|
84
|
+
"expectedChecksumSHA256": "504a5a751a4e3ac6851d6e5dc70caefee698570ead7fe2ef324019dc54c6c473",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.21",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.21"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -170,12 +170,18 @@ class FunctionsEmulator {
|
|
|
170
170
|
else {
|
|
171
171
|
triggerKey = `${this.args.projectId}:${event.eventType}`;
|
|
172
172
|
}
|
|
173
|
-
if (event.data
|
|
173
|
+
if (event.data?.bucket) {
|
|
174
174
|
triggerKey += `:${event.data.bucket}`;
|
|
175
175
|
}
|
|
176
176
|
const triggers = this.multicastTriggers[triggerKey] || [];
|
|
177
177
|
const { host, port } = this.getInfo();
|
|
178
|
-
|
|
178
|
+
const eventTenantId = (0, functionsEmulatorShared_1.getEventTenantId)(event);
|
|
179
|
+
for (const triggerId of triggers) {
|
|
180
|
+
const record = this.getTriggerRecordByKey(triggerId);
|
|
181
|
+
const filterTenantId = record?.def?.eventTrigger?.eventFilters?.tenantid;
|
|
182
|
+
if (filterTenantId && filterTenantId !== eventTenantId) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
179
185
|
const work = () => {
|
|
180
186
|
return new Promise((resolve, reject) => {
|
|
181
187
|
const trigReq = http.request({
|
|
@@ -193,7 +199,7 @@ class FunctionsEmulator {
|
|
|
193
199
|
};
|
|
194
200
|
work.type = `${triggerId}-${new Date().toISOString()}`;
|
|
195
201
|
this.workQueue.submit(work);
|
|
196
|
-
}
|
|
202
|
+
}
|
|
197
203
|
res.json({ status: "multicast_acknowledged" });
|
|
198
204
|
};
|
|
199
205
|
const listBackendsHandler = (req, res) => {
|
|
@@ -378,7 +384,10 @@ class FunctionsEmulator {
|
|
|
378
384
|
await this.args.extensionsEmulator.addDynamicExtensions(emulatableBackend.codebase, discoveredBuild);
|
|
379
385
|
await this.loadDynamicExtensionBackends();
|
|
380
386
|
}
|
|
381
|
-
build.
|
|
387
|
+
build.applyEndpointPrefix(discoveredBuild, emulatableBackend.prefix || "");
|
|
388
|
+
if (emulatableBackend.env?.FIREBASE_KIT_INSTANCE_ID) {
|
|
389
|
+
build.applyKitSecretRefPrefix(discoveredBuild, emulatableBackend.env.FIREBASE_KIT_INSTANCE_ID);
|
|
390
|
+
}
|
|
382
391
|
const resolution = await (0, build_1.resolveBackend)({
|
|
383
392
|
build: discoveredBuild,
|
|
384
393
|
firebaseConfig: JSON.parse(firebaseConfig),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmulatedTrigger = exports.EVENTARC_SOURCE_ENV = void 0;
|
|
4
|
+
exports.getEventTenantId = getEventTenantId;
|
|
4
5
|
exports.eventServiceImplemented = eventServiceImplemented;
|
|
5
6
|
exports.prepareEndpoints = prepareEndpoints;
|
|
6
7
|
exports.emulatedFunctionsFromEndpoints = emulatedFunctionsFromEndpoints;
|
|
@@ -36,7 +37,17 @@ const V2_EVENTS = [
|
|
|
36
37
|
...events.v2.STORAGE_EVENTS,
|
|
37
38
|
...events.v2.DATABASE_EVENTS,
|
|
38
39
|
...events.v2.FIRESTORE_EVENTS,
|
|
40
|
+
...events.v2.AUTH_EVENTS,
|
|
39
41
|
];
|
|
42
|
+
function getEventTenantId(eventPayload) {
|
|
43
|
+
if (!eventPayload || typeof eventPayload !== "object") {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
if (typeof eventPayload.tenantid === "string") {
|
|
47
|
+
return eventPayload.tenantid;
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
40
51
|
exports.EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE";
|
|
41
52
|
class EmulatedTrigger {
|
|
42
53
|
constructor(definition, module) {
|
|
@@ -229,12 +240,12 @@ function getServiceFromEventType(eventType) {
|
|
|
229
240
|
if (eventType.includes("firebasealerts")) {
|
|
230
241
|
return constants_1.Constants.SERVICE_FIREALERTS;
|
|
231
242
|
}
|
|
232
|
-
if (eventType.includes("analytics")) {
|
|
233
|
-
return constants_1.Constants.SERVICE_ANALYTICS;
|
|
234
|
-
}
|
|
235
243
|
if (eventType.includes("auth")) {
|
|
236
244
|
return constants_1.Constants.SERVICE_AUTH;
|
|
237
245
|
}
|
|
246
|
+
if (eventType.includes("analytics")) {
|
|
247
|
+
return constants_1.Constants.SERVICE_ANALYTICS;
|
|
248
|
+
}
|
|
238
249
|
if (eventType.includes("crashlytics")) {
|
|
239
250
|
return constants_1.Constants.SERVICE_CRASHLYTICS;
|
|
240
251
|
}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.extractParamsFromPath = extractParamsFromPath;
|
|
4
4
|
exports.isValidWildcardMatch = isValidWildcardMatch;
|
|
5
5
|
exports.trimSlashes = trimSlashes;
|
|
6
|
-
exports.removePathSegments = removePathSegments;
|
|
7
6
|
exports.parseRuntimeVersion = parseRuntimeVersion;
|
|
8
7
|
exports.parseVersionString = parseVersionString;
|
|
9
8
|
exports.compareVersionStrings = compareVersionStrings;
|
|
@@ -47,9 +46,6 @@ function trimSlashes(str) {
|
|
|
47
46
|
.filter((c) => c)
|
|
48
47
|
.join("/");
|
|
49
48
|
}
|
|
50
|
-
function removePathSegments(path, count) {
|
|
51
|
-
return trimSlashes(path).split("/").slice(count).join("/");
|
|
52
|
-
}
|
|
53
49
|
function parseRuntimeVersion(runtime) {
|
|
54
50
|
if (!runtime) {
|
|
55
51
|
return undefined;
|
package/lib/experiments.js
CHANGED
|
@@ -224,7 +224,12 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
224
224
|
fdcapimigration: {
|
|
225
225
|
shortDescription: "Enable the FDC API schema migration path.",
|
|
226
226
|
fullDescription: "API based Schema Migration behind experimental flag.",
|
|
227
|
-
default:
|
|
227
|
+
default: false,
|
|
228
|
+
public: false,
|
|
229
|
+
},
|
|
230
|
+
writeDefaultSecretBindings: {
|
|
231
|
+
shortDescription: "Write Cloud Secret Manager bindings to the default resource ID to .env.",
|
|
232
|
+
default: false,
|
|
228
233
|
public: false,
|
|
229
234
|
},
|
|
230
235
|
});
|
package/lib/extensions/export.js
CHANGED
|
@@ -121,16 +121,30 @@ function resolveMigratedMemory(liveSystemParams = {}, specSystemParams = []) {
|
|
|
121
121
|
}
|
|
122
122
|
return v2 ?? v1;
|
|
123
123
|
}
|
|
124
|
+
function resolveLiveSecret(specParam, liveParams) {
|
|
125
|
+
const val = liveParams[specParam.param];
|
|
126
|
+
if (!val && !specParam.required) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
if (!val) {
|
|
130
|
+
throw new error_1.FirebaseError(`Secret ${specParam.param} was defined in the extension spec, but is missing in live deployed secrets.`, { exit: 1 });
|
|
131
|
+
}
|
|
132
|
+
return val;
|
|
133
|
+
}
|
|
124
134
|
function functionsEnvFromInstance(instance) {
|
|
125
135
|
const liveParams = instance.config?.params || {};
|
|
126
136
|
const liveSystemParams = instance.config?.systemParams || {};
|
|
127
137
|
const specParams = instance.config?.source?.spec?.params || [];
|
|
128
138
|
const specSystemParams = instance.config?.source?.spec?.systemParams || [];
|
|
129
139
|
const envs = {};
|
|
130
|
-
|
|
140
|
+
for (const specParam of specParams) {
|
|
131
141
|
if (specParam.type === "SECRET") {
|
|
142
|
+
const val = resolveLiveSecret(specParam, liveParams);
|
|
143
|
+
if (!val) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
132
146
|
const renamed = "FIREBASE_SECRET_REF_" + specParam.param;
|
|
133
|
-
envs[renamed] =
|
|
147
|
+
envs[renamed] = val;
|
|
134
148
|
}
|
|
135
149
|
else if (specParam.param in liveParams) {
|
|
136
150
|
envs[specParam.param] = liveParams[specParam.param];
|
|
@@ -138,7 +152,7 @@ function functionsEnvFromInstance(instance) {
|
|
|
138
152
|
else {
|
|
139
153
|
envs[specParam.param] = specParam.default ?? "";
|
|
140
154
|
}
|
|
141
|
-
}
|
|
155
|
+
}
|
|
142
156
|
for (const [sysParamName, sysParamValue] of Object.entries(liveSystemParams)) {
|
|
143
157
|
if (MEMORY_PARAMS.has(sysParamName)) {
|
|
144
158
|
continue;
|
|
@@ -181,12 +195,9 @@ async function secretsNeedingEjection(instance) {
|
|
|
181
195
|
const liveParams = instance.config?.params || {};
|
|
182
196
|
const secretParams = (instance.config?.source?.spec?.params ?? []).filter((p) => p.type === "SECRET");
|
|
183
197
|
const checks = secretParams.map(async (specParam) => {
|
|
184
|
-
const
|
|
185
|
-
const resourceName = liveParams[secretName];
|
|
198
|
+
const resourceName = resolveLiveSecret(specParam, liveParams);
|
|
186
199
|
if (!resourceName) {
|
|
187
|
-
|
|
188
|
-
secretName +
|
|
189
|
-
" was defined in the extension spec, but is missing in live deployed secrets.", { exit: 1 });
|
|
200
|
+
return undefined;
|
|
190
201
|
}
|
|
191
202
|
const match = resourceName.match(secretManager_1.SECRET_VERSION_NAME_REGEX);
|
|
192
203
|
if (!match?.groups) {
|
|
@@ -208,10 +219,9 @@ async function ejectSecretsFromInstance(instance) {
|
|
|
208
219
|
if (specParam.type !== "SECRET") {
|
|
209
220
|
continue;
|
|
210
221
|
}
|
|
211
|
-
const
|
|
212
|
-
const resourceName = liveParams[secretName];
|
|
222
|
+
const resourceName = resolveLiveSecret(specParam, liveParams);
|
|
213
223
|
if (!resourceName) {
|
|
214
|
-
|
|
224
|
+
continue;
|
|
215
225
|
}
|
|
216
226
|
const match = resourceName.match(secretManager_1.SECRET_VERSION_NAME_REGEX);
|
|
217
227
|
if (!match?.groups) {
|
|
@@ -1,48 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"replacements": {
|
|
3
3
|
"firebase/delete-user-data": {
|
|
4
|
-
"status": "
|
|
5
|
-
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/delete-user-data/README.md"
|
|
6
|
-
"npmPackage": "@firebase-function-kits/delete-user-data"
|
|
4
|
+
"status": "PENDING_PUBLISHER",
|
|
5
|
+
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/delete-user-data/README.md"
|
|
7
6
|
},
|
|
8
7
|
"firebase/firestore-bigquery-export": {
|
|
9
8
|
"status": "REPLACEMENT_AVAILABLE",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
9
|
+
"npmPackage": "@firebase-function-kits/firestore-bigquery-export",
|
|
10
|
+
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-bigquery-export/README.md"
|
|
12
11
|
},
|
|
13
12
|
"firebase/firestore-bundle-builder": {
|
|
14
13
|
"status": "PENDING_PUBLISHER",
|
|
15
14
|
"extensionRepositoryUrl": "https://github.com/firebase/firestore-bundle-builder/blob/master/README.md"
|
|
16
15
|
},
|
|
17
16
|
"firebase/firestore-counter": {
|
|
18
|
-
"status": "
|
|
19
|
-
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-counter/README.md"
|
|
20
|
-
"npmPackage": "@firebase-function-kits/firestore-counter"
|
|
17
|
+
"status": "PENDING_PUBLISHER",
|
|
18
|
+
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-counter/README.md"
|
|
21
19
|
},
|
|
22
20
|
"firebase/firestore-send-email": {
|
|
23
|
-
"status": "
|
|
24
|
-
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-send-email/README.md"
|
|
25
|
-
"npmPackage": "@firebase-function-kits/firestore-send-email"
|
|
21
|
+
"status": "PENDING_PUBLISHER",
|
|
22
|
+
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-send-email/README.md"
|
|
26
23
|
},
|
|
27
24
|
"firebase/firestore-shorten-urls-bitly": {
|
|
28
25
|
"status": "PENDING_PUBLISHER",
|
|
29
|
-
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/main/firestore-shorten-urls-bitly/README.md"
|
|
30
|
-
"npmPackage": "@firebase/firestore-shorten-urls-bitly"
|
|
26
|
+
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/main/firestore-shorten-urls-bitly/README.md"
|
|
31
27
|
},
|
|
32
28
|
"firebase/firestore-translate-text": {
|
|
33
|
-
"status": "
|
|
34
|
-
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-translate-text/README.md"
|
|
35
|
-
"npmPackage": "@firebase-function-kits/firestore-translate-text"
|
|
29
|
+
"status": "PENDING_PUBLISHER",
|
|
30
|
+
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/firestore-translate-text/README.md"
|
|
36
31
|
},
|
|
37
32
|
"firebase/rtdb-limit-child-nodes": {
|
|
38
|
-
"status": "
|
|
39
|
-
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/rtdb-limit-child-nodes/README.md"
|
|
40
|
-
"npmPackage": "@firebase-function-kits/rtdb-limit-child-nodes"
|
|
33
|
+
"status": "PENDING_PUBLISHER",
|
|
34
|
+
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/rtdb-limit-child-nodes/README.md"
|
|
41
35
|
},
|
|
42
36
|
"firebase/storage-resize-images": {
|
|
43
|
-
"status": "
|
|
44
|
-
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/storage-resize-images/README.md"
|
|
45
|
-
"npmPackage": "@firebase-function-kits/storage-resize-images"
|
|
37
|
+
"status": "PENDING_PUBLISHER",
|
|
38
|
+
"extensionRepositoryUrl": "https://github.com/firebase/extensions/tree/kits/storage-resize-images/README.md"
|
|
46
39
|
},
|
|
47
40
|
"googlecloud/bigquery-firestore-export": {
|
|
48
41
|
"status": "PENDING_PUBLISHER",
|
|
@@ -17,8 +17,8 @@ const semver_1 = require("semver");
|
|
|
17
17
|
const clc = require("colorette");
|
|
18
18
|
const stream_chain_1 = require("stream-chain");
|
|
19
19
|
const stream_json_1 = require("stream-json");
|
|
20
|
-
const
|
|
21
|
-
const
|
|
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
22
|
const fsutils_1 = require("../../fsutils");
|
|
23
23
|
const prompt_1 = require("../../prompt");
|
|
24
24
|
const error_1 = require("../../error");
|
|
@@ -404,8 +404,8 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
|
|
|
404
404
|
const pipeline = (0, stream_chain_1.chain)([
|
|
405
405
|
npmLs.stdout,
|
|
406
406
|
(0, stream_json_1.parser)({ packValues: false, packKeys: true, streamValues: false }),
|
|
407
|
-
(0,
|
|
408
|
-
(0,
|
|
407
|
+
(0, pick_js_1.pick)({ filter: "dependencies" }),
|
|
408
|
+
(0, stream_object_js_1.streamObject)(),
|
|
409
409
|
({ key, value }) => [
|
|
410
410
|
key,
|
|
411
411
|
...(0, utils_2.allDependencyNames)(value),
|
package/lib/fsutils.js
CHANGED
|
@@ -5,10 +5,12 @@ exports.dirExistsSync = dirExistsSync;
|
|
|
5
5
|
exports.readFile = readFile;
|
|
6
6
|
exports.listFiles = listFiles;
|
|
7
7
|
exports.moveAll = moveAll;
|
|
8
|
+
exports.removeDirectoryIfEmpty = removeDirectoryIfEmpty;
|
|
8
9
|
const fs_1 = require("fs");
|
|
9
10
|
const path = require("path");
|
|
11
|
+
const fs = require("fs-extra");
|
|
10
12
|
const error_1 = require("./error");
|
|
11
|
-
const
|
|
13
|
+
const logger_1 = require("./logger");
|
|
12
14
|
function fileExistsSync(path) {
|
|
13
15
|
try {
|
|
14
16
|
return (0, fs_1.statSync)(path).isFile();
|
|
@@ -56,6 +58,22 @@ function moveAll(srcDir, destDir) {
|
|
|
56
58
|
const srcPath = path.join(srcDir, f);
|
|
57
59
|
if (srcPath === destDir)
|
|
58
60
|
continue;
|
|
59
|
-
|
|
61
|
+
fs.moveSync(srcPath, path.join(destDir, f));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function removeDirectoryIfEmpty(absDirPath) {
|
|
65
|
+
try {
|
|
66
|
+
if (await fs.pathExists(absDirPath)) {
|
|
67
|
+
const stat = await fs.stat(absDirPath);
|
|
68
|
+
if (stat.isDirectory()) {
|
|
69
|
+
const entries = await fs.readdir(absDirPath);
|
|
70
|
+
if (entries.length === 0) {
|
|
71
|
+
await fs.remove(absDirPath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
logger_1.logger.debug(`Failed to clean up directory '${absDirPath}' if empty: ${(0, error_1.getErrMsg)(err)}`);
|
|
60
78
|
}
|
|
61
79
|
}
|