firebase-tools 15.23.0 → 15.25.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/api.js +4 -2
- package/lib/appcheck/api.js +42 -0
- package/lib/appcheck/prompts.js +41 -0
- package/lib/appcheck/types.js +2 -0
- package/lib/bin/cli.js +9 -2
- package/lib/bin/progressiveHelp.js +126 -0
- package/lib/checkValidTargetFilters.js +1 -1
- package/lib/command.js +11 -10
- package/lib/commands/ailogic-config-get.js +75 -0
- package/lib/commands/ailogic-config-set.js +109 -0
- package/lib/commands/ailogic-providers-disable.js +39 -0
- package/lib/commands/ailogic-providers-enable.js +28 -0
- package/lib/commands/ailogic-providers-list.js +29 -0
- package/lib/commands/appcheck-debugtokens-create.js +95 -0
- package/lib/commands/appcheck-debugtokens-delete.js +48 -0
- package/lib/commands/appcheck-debugtokens-list.js +35 -0
- package/lib/commands/apps-sdkconfig.js +2 -23
- package/lib/commands/database-get.js +1 -1
- package/lib/commands/dataconnect-execute.js +1 -1
- package/lib/commands/deploy.js +27 -64
- package/lib/commands/index.js +15 -0
- package/lib/deploy/apphosting/index.js +26 -1
- package/lib/deploy/auth/index.js +18 -1
- package/lib/deploy/database/index.js +16 -1
- package/lib/deploy/dataconnect/index.js +19 -1
- package/lib/deploy/extensions/index.js +9 -1
- package/lib/deploy/firestore/index.js +20 -1
- package/lib/deploy/functions/build.js +93 -3
- package/lib/deploy/functions/index.js +33 -1
- package/lib/deploy/functions/params.js +68 -26
- package/lib/deploy/functions/prepare.js +34 -8
- package/lib/deploy/functions/prompts.js +19 -0
- package/lib/deploy/functions/release/index.js +19 -12
- package/lib/deploy/functions/release/lifecycle.js +38 -5
- package/lib/deploy/functions/release/planner.js +3 -1
- package/lib/deploy/functions/runtimes/node/index.js +8 -7
- package/lib/deploy/functions/runtimes/node/versioning.js +8 -3
- package/lib/deploy/functions/validate.js +5 -2
- package/lib/deploy/hosting/index.js +30 -1
- package/lib/deploy/hosting/uploader.js +2 -1
- package/lib/deploy/index.js +68 -8
- package/lib/deploy/remoteconfig/index.js +9 -1
- package/lib/deploy/storage/index.js +16 -1
- package/lib/emulator/dataconnect/pgliteServer.js +2 -1
- package/lib/emulator/downloadableEmulatorInfo.json +30 -30
- package/lib/emulator/downloadableEmulators.js +1 -0
- package/lib/emulator/hubExport.js +2 -1
- package/lib/emulator/storage/apis/firebase.js +24 -5
- package/lib/emulator/storage/apis/gcloud.js +16 -6
- package/lib/emulator/storage/rules/runtime.js +45 -33
- package/lib/emulator/storage/server.js +2 -5
- package/lib/emulator/storage/upload.js +1 -0
- package/lib/ensureApiEnabled.js +8 -0
- package/lib/experiments.js +16 -0
- package/lib/extensions/warnings.js +64 -0
- package/lib/frameworks/utils.js +50 -1
- package/lib/functions/env.js +22 -2
- package/lib/functions/secrets.js +4 -1
- package/lib/gcp/ailogic.js +165 -1
- package/lib/gcp/cloudfunctionsv2.js +7 -0
- package/lib/gcp/firedata.js +5 -1
- package/lib/gcp/serviceusage.js +26 -0
- package/lib/hosting/proxy.js +15 -3
- package/lib/index.js +0 -1
- package/lib/init/features/ailogic/index.js +3 -29
- package/lib/init/features/database.js +1 -1
- package/lib/management/apps.js +16 -5
- package/lib/mcp/onemcp/onemcp_server.js +28 -9
- package/lib/mcp/tools/core/get_security_rules.js +2 -1
- package/lib/profiler.js +1 -1
- package/lib/streamUtils.js +3 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.REGION_TBD = void 0;
|
|
3
|
+
exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.SECRET_REF_LONG_RE = exports.SECRET_REF_SHORT_RE = exports.GCP_SECRET_ID_PATTERN = exports.SECRET_REF_PREFIX = exports.REGION_TBD = void 0;
|
|
4
4
|
exports.empty = empty;
|
|
5
5
|
exports.of = of;
|
|
6
6
|
exports.isHttpsTriggered = isHttpsTriggered;
|
|
@@ -14,13 +14,32 @@ exports.resolveBackend = resolveBackend;
|
|
|
14
14
|
exports.envWithTypes = envWithTypes;
|
|
15
15
|
exports.toBackend = toBackend;
|
|
16
16
|
exports.applyPrefix = applyPrefix;
|
|
17
|
+
exports.applyEnvSecretBindings = applyEnvSecretBindings;
|
|
18
|
+
exports.parseSecretRef = parseSecretRef;
|
|
17
19
|
const backend = require("./backend");
|
|
18
20
|
const proto = require("../../gcp/proto");
|
|
19
21
|
const params = require("./params");
|
|
22
|
+
const logger_1 = require("../../logger");
|
|
20
23
|
const error_1 = require("../../error");
|
|
21
24
|
const functional_1 = require("../../functional");
|
|
22
25
|
const cel_1 = require("./cel");
|
|
23
26
|
exports.REGION_TBD = "REGION_TBD";
|
|
27
|
+
exports.SECRET_REF_PREFIX = "FIREBASE_SECRET_REF_";
|
|
28
|
+
const GCP_PROJECT_ID_PATTERN = "([a-z][-a-z0-9]{4,28}[a-z0-9])";
|
|
29
|
+
exports.GCP_SECRET_ID_PATTERN = "([a-zA-Z0-9-_]+)";
|
|
30
|
+
exports.SECRET_REF_SHORT_RE = new RegExp("^" +
|
|
31
|
+
exports.GCP_SECRET_ID_PATTERN +
|
|
32
|
+
"(?:[:#@]" +
|
|
33
|
+
"([a-z0-9-_]+)" +
|
|
34
|
+
")?$");
|
|
35
|
+
exports.SECRET_REF_LONG_RE = new RegExp("^" +
|
|
36
|
+
"projects/" +
|
|
37
|
+
GCP_PROJECT_ID_PATTERN +
|
|
38
|
+
"/secrets/" +
|
|
39
|
+
exports.GCP_SECRET_ID_PATTERN +
|
|
40
|
+
"(?:(?:/versions/|:|#|@)" +
|
|
41
|
+
"([a-z0-9-_]+)" +
|
|
42
|
+
")?$");
|
|
24
43
|
function empty() {
|
|
25
44
|
return {
|
|
26
45
|
requiredAPIs: [],
|
|
@@ -63,8 +82,8 @@ exports.AllIngressSettings = [
|
|
|
63
82
|
"ALLOW_INTERNAL_AND_GCLB",
|
|
64
83
|
];
|
|
65
84
|
async function resolveBackend(opts) {
|
|
66
|
-
const paramValues = await params.resolveParams(opts.build.params, opts.firebaseConfig, envWithTypes(opts.build.params, opts.userEnvs), opts.nonInteractive, opts.isEmulator);
|
|
67
|
-
return { backend: toBackend(opts.build, paramValues), envs: paramValues };
|
|
85
|
+
const { paramValues: paramValues, secretRefs: secretRefs } = await params.resolveParams(opts.build.params, opts.firebaseConfig, envWithTypes(opts.build.params, opts.userEnvs), opts.nonInteractive, opts.isEmulator, opts.force);
|
|
86
|
+
return { backend: toBackend(opts.build, paramValues), envs: paramValues, secretRefs: secretRefs };
|
|
68
87
|
}
|
|
69
88
|
function envWithTypes(definedParams, rawEnvs) {
|
|
70
89
|
const out = {};
|
|
@@ -404,3 +423,74 @@ function applyPrefix(build, prefix) {
|
|
|
404
423
|
}
|
|
405
424
|
}
|
|
406
425
|
}
|
|
426
|
+
function applyEnvSecretBindings(build, envSecrets) {
|
|
427
|
+
if (envSecrets.empty) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
logger_1.logger.debug(`Attempting to merge .env secret bindings ${JSON.stringify(envSecrets)} into declared secrets...)}`);
|
|
431
|
+
for (const endpointName of Object.keys(build.endpoints)) {
|
|
432
|
+
logger_1.logger.debug(`${endpointName} declared secrets: ${JSON.stringify(build.endpoints[endpointName].secretEnvironmentVariables)}`);
|
|
433
|
+
}
|
|
434
|
+
for (const key of Object.keys(envSecrets)) {
|
|
435
|
+
const secretRef = envSecrets[key];
|
|
436
|
+
const { projectId, secretId, version } = secretRef;
|
|
437
|
+
for (const param of build.params) {
|
|
438
|
+
if (param.type === "secret" && param.name.toUpperCase() === key) {
|
|
439
|
+
param.resourceId = secretId;
|
|
440
|
+
param.version = version;
|
|
441
|
+
param.inLocalEnvironment = true;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
for (const endpointName of Object.keys(build.endpoints)) {
|
|
445
|
+
const endpoint = build.endpoints[endpointName];
|
|
446
|
+
if (projectId && projectId !== endpoint.project) {
|
|
447
|
+
throw new error_1.FirebaseError(`Secret binding ${key} referenced unsupported cross-project secret in '${projectId}'`);
|
|
448
|
+
}
|
|
449
|
+
let notFound = true;
|
|
450
|
+
for (const envVar of endpoint.secretEnvironmentVariables ?? []) {
|
|
451
|
+
if (envVar.key === key) {
|
|
452
|
+
notFound = false;
|
|
453
|
+
envVar.secret = secretId;
|
|
454
|
+
if (typeof secretRef.version !== "undefined") {
|
|
455
|
+
envVar.version = version;
|
|
456
|
+
envVar.allowVersionPinning = true;
|
|
457
|
+
}
|
|
458
|
+
logger_1.logger.debug(`Merged secret: ${JSON.stringify(envVar)}`);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (notFound) {
|
|
462
|
+
logger_1.logger.warn(`.env files contain a secret binding ${key} which has not been configured as a secret param via defineSecret().`);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function parseSecretRef(ref) {
|
|
468
|
+
const shortMatch = exports.SECRET_REF_SHORT_RE.exec(ref);
|
|
469
|
+
if (shortMatch) {
|
|
470
|
+
const output = {
|
|
471
|
+
secretId: shortMatch[1],
|
|
472
|
+
};
|
|
473
|
+
if (shortMatch[2] !== undefined) {
|
|
474
|
+
output.version = shortMatch[2];
|
|
475
|
+
if (ref.includes("#") || ref.includes("@")) {
|
|
476
|
+
throw new error_1.FirebaseError(`Malformed secret binding '${ref}'; secret versions are specified with ':'`);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return output;
|
|
480
|
+
}
|
|
481
|
+
const longMatch = exports.SECRET_REF_LONG_RE.exec(ref);
|
|
482
|
+
if (longMatch) {
|
|
483
|
+
const output = {
|
|
484
|
+
projectId: longMatch[1],
|
|
485
|
+
secretId: longMatch[2],
|
|
486
|
+
};
|
|
487
|
+
if (longMatch[3] !== undefined) {
|
|
488
|
+
output.version = longMatch[3];
|
|
489
|
+
if (ref.includes("#") || ref.includes("@")) {
|
|
490
|
+
throw new error_1.FirebaseError(`Malformed secret binding '${ref}'; secret versions are specified with ':'`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return output;
|
|
494
|
+
}
|
|
495
|
+
throw new error_1.FirebaseError(`Unknown format for secret binding '${ref}'`);
|
|
496
|
+
}
|
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.release = exports.deploy = exports.prepare = void 0;
|
|
3
|
+
exports.detailedHelp = exports.help = exports.release = exports.deploy = exports.prepare = void 0;
|
|
4
4
|
var prepare_1 = require("./prepare");
|
|
5
5
|
Object.defineProperty(exports, "prepare", { enumerable: true, get: function () { return prepare_1.prepare; } });
|
|
6
6
|
var deploy_1 = require("./deploy");
|
|
7
7
|
Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.deploy; } });
|
|
8
8
|
var release_1 = require("./release");
|
|
9
9
|
Object.defineProperty(exports, "release", { enumerable: true, get: function () { return release_1.release; } });
|
|
10
|
+
exports.help = "Deploys functions from the functions directory. Supports filtering function deploys:\n" +
|
|
11
|
+
" --only functions:func1,functions:func2 (scoped function deploy)\n" +
|
|
12
|
+
" --only functions:group.subgroup (scoped by export group)\n" +
|
|
13
|
+
" --only functions:codebase:func (scoped by codebase and function)";
|
|
14
|
+
exports.detailedHelp = "Cloud Functions deploys functions source code from your local codebases.\n\n" +
|
|
15
|
+
"Single codebase configuration in firebase.json:\n" +
|
|
16
|
+
"{\n" +
|
|
17
|
+
' "functions": {\n' +
|
|
18
|
+
' "source": "functions",\n' +
|
|
19
|
+
' "codebase": "default",\n' +
|
|
20
|
+
' "runtime": "nodejs20",\n' +
|
|
21
|
+
' "predeploy": [\n' +
|
|
22
|
+
' "npm --prefix \\"$RESOURCE_DIR\\" run lint",\n' +
|
|
23
|
+
' "npm --prefix \\"$RESOURCE_DIR\\" run build"\n' +
|
|
24
|
+
" ]\n" +
|
|
25
|
+
" }\n" +
|
|
26
|
+
"}\n\n" +
|
|
27
|
+
"Multiple codebases configuration:\n" +
|
|
28
|
+
"{\n" +
|
|
29
|
+
' "functions": [\n' +
|
|
30
|
+
" {\n" +
|
|
31
|
+
' "source": "functions-backend",\n' +
|
|
32
|
+
' "codebase": "backend",\n' +
|
|
33
|
+
' "runtime": "nodejs20"\n' +
|
|
34
|
+
" },\n" +
|
|
35
|
+
" {\n" +
|
|
36
|
+
' "source": "functions-frontend",\n' +
|
|
37
|
+
' "codebase": "frontend",\n' +
|
|
38
|
+
' "runtime": "nodejs22"\n' +
|
|
39
|
+
" }\n" +
|
|
40
|
+
" ]\n" +
|
|
41
|
+
"}";
|
|
@@ -14,11 +14,13 @@ const logger_1 = require("../../logger");
|
|
|
14
14
|
const error_1 = require("../../error");
|
|
15
15
|
const prompt_1 = require("../../prompt");
|
|
16
16
|
const secrets_1 = require("../../functions/secrets");
|
|
17
|
+
const build = require("./build");
|
|
17
18
|
const functional_1 = require("../../functional");
|
|
18
19
|
const secretManager = require("../../gcp/secretManager");
|
|
19
20
|
const storage_1 = require("../../gcp/storage");
|
|
20
21
|
const cel_1 = require("./cel");
|
|
21
22
|
const secretManager_1 = require("../../gcp/secretManager");
|
|
23
|
+
const experiments = require("../../experiments");
|
|
22
24
|
function dependenciesCEL(expr) {
|
|
23
25
|
const deps = [];
|
|
24
26
|
const paramCapture = /{{ params\.(\w+) }}/g;
|
|
@@ -160,8 +162,9 @@ function canSatisfyParam(param, value) {
|
|
|
160
162
|
}
|
|
161
163
|
(0, functional_1.assertExhaustive)(param);
|
|
162
164
|
}
|
|
163
|
-
async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive, isEmulator = false) {
|
|
165
|
+
async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive, force, isEmulator = false) {
|
|
164
166
|
const paramValues = populateDefaultParams(firebaseConfig);
|
|
167
|
+
const secretRefs = {};
|
|
165
168
|
const [resolved, outstanding] = (0, functional_1.partition)(params, (param) => {
|
|
166
169
|
return {}.hasOwnProperty.call(userEnvs, param.name);
|
|
167
170
|
});
|
|
@@ -171,7 +174,7 @@ async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive, i
|
|
|
171
174
|
const [needSecret, needPrompt] = (0, functional_1.partition)(outstanding, (param) => param.type === "secret");
|
|
172
175
|
if (!isEmulator) {
|
|
173
176
|
for (const param of needSecret) {
|
|
174
|
-
await
|
|
177
|
+
secretRefs[param.name] = await ensureSecret(param, firebaseConfig.projectId, nonInteractive, force);
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
if (nonInteractive && needPrompt.length > 0) {
|
|
@@ -191,7 +194,7 @@ async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive, i
|
|
|
191
194
|
}
|
|
192
195
|
paramValues[param.name] = await promptParam(param, firebaseConfig.projectId, paramDefault);
|
|
193
196
|
}
|
|
194
|
-
return paramValues;
|
|
197
|
+
return { paramValues: paramValues, secretRefs: secretRefs };
|
|
195
198
|
}
|
|
196
199
|
function populateDefaultParams(config) {
|
|
197
200
|
const defaultParams = {};
|
|
@@ -221,24 +224,45 @@ function populateDefaultParams(config) {
|
|
|
221
224
|
}
|
|
222
225
|
return defaultParams;
|
|
223
226
|
}
|
|
224
|
-
async function
|
|
225
|
-
const
|
|
227
|
+
async function ensureSecret(secretParam, projectId, nonInteractive, force) {
|
|
228
|
+
const resourceId = secretParam.resourceId || secretParam.name;
|
|
229
|
+
const version = secretParam.version || "latest";
|
|
230
|
+
let secretAlreadyExisted = false;
|
|
231
|
+
const metadata = await secretManager.getSecretMetadata(projectId, resourceId, version);
|
|
226
232
|
if (!metadata.secret) {
|
|
227
233
|
if (nonInteractive) {
|
|
228
|
-
throw new error_1.FirebaseError(`In non-interactive mode but have no value for the secret
|
|
234
|
+
throw new error_1.FirebaseError(`In non-interactive mode but have no value for the secret ${secretParam.name}: ${resourceId}\n\n` +
|
|
229
235
|
"Set this secret before deploying:\n" +
|
|
230
|
-
`\tfirebase functions:secrets:set ${
|
|
236
|
+
`\tfirebase functions:secrets:set ${resourceId}${secretParam.format === "json" ? " --format=json --data-file <file.json>" : ""}`);
|
|
231
237
|
}
|
|
232
|
-
|
|
238
|
+
if (experiments.isEnabled("secretEnvParams") && typeof secretParam.resourceId === "undefined") {
|
|
239
|
+
if (force) {
|
|
240
|
+
logger_1.logger.info(`--force: Using default resource ID for secret ${secretParam.name}`);
|
|
241
|
+
secretParam.resourceId = secretParam.name;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
secretParam.resourceId = await (0, prompt_1.input)({
|
|
245
|
+
default: secretParam.name,
|
|
246
|
+
message: `What resource ID do you want to use for the backing Secret resource for secret param ${secretParam.name}?`,
|
|
247
|
+
validate: (id) => {
|
|
248
|
+
if (new RegExp(`^${build.GCP_SECRET_ID_PATTERN}$`).test(id)) {
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
return "GCP Secret identifiers must contain only letters, numbers, underscores, and hyphens.";
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return ensureSecret(secretParam, projectId, nonInteractive, force);
|
|
256
|
+
}
|
|
257
|
+
const promptMessage = `The value for this secret (${secretParam.name}) will be stored in Cloud Secret Manager (https://cloud.google.com/secret-manager/pricing) as ${resourceId}. Enter ${secretParam.format === "json" ? "a JSON value" : "a value"} for ${secretParam.label || secretParam.name}:`;
|
|
233
258
|
const secretValue = await (0, prompt_1.password)({
|
|
234
259
|
message: promptMessage,
|
|
235
260
|
});
|
|
236
261
|
if (secretParam.format === "json") {
|
|
237
262
|
(0, secrets_1.validateJsonSecret)(secretParam.name, secretValue);
|
|
238
263
|
}
|
|
239
|
-
await secretManager.createSecret(projectId,
|
|
240
|
-
await secretManager.addVersion(projectId,
|
|
241
|
-
return;
|
|
264
|
+
await secretManager.createSecret(projectId, resourceId, (0, secretManager_1.labels)());
|
|
265
|
+
await secretManager.addVersion(projectId, resourceId, secretValue);
|
|
242
266
|
}
|
|
243
267
|
else if (!metadata.secretVersion) {
|
|
244
268
|
throw new error_1.FirebaseError(`Cloud Secret Manager has no latest version of the secret defined by param ${secretParam.label || secretParam.name}`);
|
|
@@ -247,6 +271,16 @@ async function handleSecret(secretParam, projectId, nonInteractive) {
|
|
|
247
271
|
metadata.secretVersion.state === "DISABLED") {
|
|
248
272
|
throw new error_1.FirebaseError(`Cloud Secret Manager's latest version of secret '${secretParam.label || secretParam.name} is in illegal state ${metadata.secretVersion.state}`);
|
|
249
273
|
}
|
|
274
|
+
else {
|
|
275
|
+
secretAlreadyExisted = true;
|
|
276
|
+
}
|
|
277
|
+
const secretRefString = typeof version === "undefined" ? resourceId : `${resourceId}:${version}`;
|
|
278
|
+
if (experiments.isEnabled("secretEnvParams")) {
|
|
279
|
+
if (!secretParam.inLocalEnvironment && secretAlreadyExisted) {
|
|
280
|
+
logger_1.logger.info(`Onetime (firebase-tools x.y.z+): storing a reference to existing secret ${secretParam.name}=${secretRefString} in .env files.`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return secretRefString;
|
|
250
284
|
}
|
|
251
285
|
async function promptParam(param, projectId, resolvedDefault) {
|
|
252
286
|
if (param.type === "string") {
|
|
@@ -285,14 +319,14 @@ async function promptList(param, projectId, resolvedDefault) {
|
|
|
285
319
|
prompt += ` \n(${param.description})`;
|
|
286
320
|
}
|
|
287
321
|
prompt += "\nSelect an option with the arrow keys, and use Enter to confirm your choice. ";
|
|
288
|
-
return promptSelectMultiple(prompt, param.input, resolvedDefault, (res) => res);
|
|
322
|
+
return promptSelectMultiple(prompt, param.input, resolvedDefault, param.input.multiSelect.nonEmpty, (res) => res);
|
|
289
323
|
}
|
|
290
324
|
else if (isTextInput(param.input)) {
|
|
291
325
|
prompt = `Enter a list of strings (delimiter: ${param.delimiter ? param.delimiter : ","}) for ${param.label || param.name}:`;
|
|
292
326
|
if (param.description) {
|
|
293
327
|
prompt += ` \n(${param.description})`;
|
|
294
328
|
}
|
|
295
|
-
return promptText(prompt, param.input, resolvedDefault, (res) => {
|
|
329
|
+
return promptText(prompt, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => {
|
|
296
330
|
return res.split(param.delimiter || ",");
|
|
297
331
|
});
|
|
298
332
|
}
|
|
@@ -301,7 +335,7 @@ async function promptList(param, projectId, resolvedDefault) {
|
|
|
301
335
|
if (param.description) {
|
|
302
336
|
prompt += ` \n(${param.description})`;
|
|
303
337
|
}
|
|
304
|
-
return promptResourceStrings(prompt, param.input, projectId);
|
|
338
|
+
return promptResourceStrings(prompt, param.input, projectId, false);
|
|
305
339
|
}
|
|
306
340
|
else {
|
|
307
341
|
(0, functional_1.assertExhaustive)(param.input);
|
|
@@ -330,7 +364,7 @@ async function promptBooleanParam(param, resolvedDefault) {
|
|
|
330
364
|
if (param.description) {
|
|
331
365
|
prompt += ` \n(${param.description})`;
|
|
332
366
|
}
|
|
333
|
-
return promptText(prompt, param.input, resolvedDefault, isTruthyInput);
|
|
367
|
+
return promptText(prompt, param.input, resolvedDefault, false, isTruthyInput);
|
|
334
368
|
}
|
|
335
369
|
else if (isResourceInput(param.input)) {
|
|
336
370
|
throw new error_1.FirebaseError("Boolean params cannot have Cloud Resource selector inputs");
|
|
@@ -368,7 +402,7 @@ async function promptStringParam(param, projectId, resolvedDefault) {
|
|
|
368
402
|
if (param.description) {
|
|
369
403
|
prompt += ` \n(${param.description})`;
|
|
370
404
|
}
|
|
371
|
-
return promptText(prompt, param.input, resolvedDefault, (res) => res);
|
|
405
|
+
return promptText(prompt, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => res);
|
|
372
406
|
}
|
|
373
407
|
else {
|
|
374
408
|
(0, functional_1.assertExhaustive)(param.input);
|
|
@@ -404,7 +438,7 @@ async function promptIntParam(param, resolvedDefault) {
|
|
|
404
438
|
if (param.description) {
|
|
405
439
|
prompt += ` \n(${param.description})`;
|
|
406
440
|
}
|
|
407
|
-
return promptText(prompt, param.input, resolvedDefault, (res) => {
|
|
441
|
+
return promptText(prompt, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => {
|
|
408
442
|
if (isNaN(+res)) {
|
|
409
443
|
return { message: `"${res}" could not be converted to a number.` };
|
|
410
444
|
}
|
|
@@ -439,10 +473,10 @@ async function promptResourceString(prompt, input, projectId, resolvedDefault) {
|
|
|
439
473
|
return promptSelect(prompt, forgedInput, resolvedDefault, (res) => res);
|
|
440
474
|
default:
|
|
441
475
|
logger_1.logger.warn(`Warning: unknown resource type ${input.resource.type}; defaulting to raw text input...`);
|
|
442
|
-
return promptText(prompt, { text: {} }, resolvedDefault, (res) => res);
|
|
476
|
+
return promptText(prompt, { text: {} }, resolvedDefault, true, (res) => res);
|
|
443
477
|
}
|
|
444
478
|
}
|
|
445
|
-
async function promptResourceStrings(prompt, input, projectId) {
|
|
479
|
+
async function promptResourceStrings(prompt, input, projectId, enforceNonEmpty) {
|
|
446
480
|
const notFound = new error_1.FirebaseError(`No instances of ${input.resource.type} found.`);
|
|
447
481
|
switch (input.resource.type) {
|
|
448
482
|
case "storage.googleapis.com/Bucket":
|
|
@@ -457,16 +491,16 @@ async function promptResourceStrings(prompt, input, projectId) {
|
|
|
457
491
|
}),
|
|
458
492
|
},
|
|
459
493
|
};
|
|
460
|
-
return promptSelectMultiple(prompt, forgedInput, undefined, (res) => res);
|
|
494
|
+
return promptSelectMultiple(prompt, forgedInput, undefined, enforceNonEmpty, (res) => res);
|
|
461
495
|
default:
|
|
462
496
|
logger_1.logger.warn(`Warning: unknown resource type ${input.resource.type}; defaulting to raw text input...`);
|
|
463
|
-
return promptText(prompt, { text: {} }, undefined, (res) => res.split(","));
|
|
497
|
+
return promptText(prompt, { text: {} }, undefined, enforceNonEmpty, (res) => res.split(","));
|
|
464
498
|
}
|
|
465
499
|
}
|
|
466
500
|
function shouldRetry(obj) {
|
|
467
501
|
return typeof obj === "object" && obj.message !== undefined;
|
|
468
502
|
}
|
|
469
|
-
async function promptText(prompt, textInput, resolvedDefault, converter) {
|
|
503
|
+
async function promptText(prompt, textInput, resolvedDefault, enforceNonEmpty = false, converter) {
|
|
470
504
|
const res = await (0, prompt_1.input)({
|
|
471
505
|
default: resolvedDefault,
|
|
472
506
|
message: prompt,
|
|
@@ -476,13 +510,17 @@ async function promptText(prompt, textInput, resolvedDefault, converter) {
|
|
|
476
510
|
if (!userRe.test(res)) {
|
|
477
511
|
logger_1.logger.error(textInput.text.validationErrorMessage ||
|
|
478
512
|
`Input did not match provided validator ${userRe.toString()}, retrying...`);
|
|
479
|
-
return promptText(prompt, textInput, resolvedDefault, converter);
|
|
513
|
+
return promptText(prompt, textInput, resolvedDefault, enforceNonEmpty, converter);
|
|
480
514
|
}
|
|
481
515
|
}
|
|
516
|
+
if (enforceNonEmpty && res === "") {
|
|
517
|
+
logger_1.logger.error(`A non-empty value is required, retrying......`);
|
|
518
|
+
return promptText(prompt, textInput, resolvedDefault, enforceNonEmpty, converter);
|
|
519
|
+
}
|
|
482
520
|
const converted = converter(res.toString());
|
|
483
521
|
if (shouldRetry(converted)) {
|
|
484
522
|
logger_1.logger.error(converted.message);
|
|
485
|
-
return promptText(prompt, textInput, resolvedDefault, converter);
|
|
523
|
+
return promptText(prompt, textInput, resolvedDefault, enforceNonEmpty, converter);
|
|
486
524
|
}
|
|
487
525
|
return converted;
|
|
488
526
|
}
|
|
@@ -505,7 +543,7 @@ async function promptSelect(prompt, input, resolvedDefault, converter) {
|
|
|
505
543
|
}
|
|
506
544
|
return converted;
|
|
507
545
|
}
|
|
508
|
-
async function promptSelectMultiple(prompt, input, resolvedDefault, converter) {
|
|
546
|
+
async function promptSelectMultiple(prompt, input, resolvedDefault, enforceNonEmpty = false, converter) {
|
|
509
547
|
const response = await (0, prompt_1.checkbox)({
|
|
510
548
|
default: resolvedDefault,
|
|
511
549
|
message: prompt,
|
|
@@ -520,7 +558,11 @@ async function promptSelectMultiple(prompt, input, resolvedDefault, converter) {
|
|
|
520
558
|
const converted = converter(response);
|
|
521
559
|
if (shouldRetry(converted)) {
|
|
522
560
|
logger_1.logger.error(converted.message);
|
|
523
|
-
return promptSelectMultiple(prompt, input, resolvedDefault, converter);
|
|
561
|
+
return promptSelectMultiple(prompt, input, resolvedDefault, enforceNonEmpty, converter);
|
|
562
|
+
}
|
|
563
|
+
if (enforceNonEmpty && Array.isArray(converted) && converted.length === 0) {
|
|
564
|
+
logger_1.logger.error(`A non-empty value is required, retrying...`);
|
|
565
|
+
return promptSelectMultiple(prompt, input, resolvedDefault, enforceNonEmpty, converter);
|
|
524
566
|
}
|
|
525
567
|
return converted;
|
|
526
568
|
}
|
|
@@ -12,6 +12,7 @@ exports.resolveDefaultTimeout = resolveDefaultTimeout;
|
|
|
12
12
|
exports.loadCodebases = loadCodebases;
|
|
13
13
|
exports.warnIfNewGenkitFunctionIsMissingSecrets = warnIfNewGenkitFunctionIsMissingSecrets;
|
|
14
14
|
exports.ensureAllRequiredAPIsEnabled = ensureAllRequiredAPIsEnabled;
|
|
15
|
+
exports.partitionUserEnvs = partitionUserEnvs;
|
|
15
16
|
const clc = require("colorette");
|
|
16
17
|
const proto = require("../../gcp/proto");
|
|
17
18
|
const backend = require("./backend");
|
|
@@ -47,7 +48,7 @@ const prompt = require("../../prompt");
|
|
|
47
48
|
const iam = require("../../gcp/iam");
|
|
48
49
|
const resourcemanager = require("../../gcp/resourceManager");
|
|
49
50
|
exports.EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE";
|
|
50
|
-
async function discoverSecurityDetails(codebase, want, have, projectId) {
|
|
51
|
+
async function discoverSecurityDetails(codebase, want, have, projectId, filters) {
|
|
51
52
|
const requiredRoles = want.requiredRoles;
|
|
52
53
|
const firstHave = backend.allEndpoints(have)[0];
|
|
53
54
|
let existingManagedSA;
|
|
@@ -58,19 +59,25 @@ async function discoverSecurityDetails(codebase, want, have, projectId) {
|
|
|
58
59
|
? firstHave.serviceAccount
|
|
59
60
|
: undefined;
|
|
60
61
|
}
|
|
62
|
+
const isPartiallyFiltered = !!(filters &&
|
|
63
|
+
filters.some((f) => (!f.codebase || f.codebase === codebase) && f.idChunks && f.idChunks.length > 0));
|
|
64
|
+
const isEnrolling = !!requiredRoles && !existingManagedSA;
|
|
65
|
+
const isUnenrolling = !requiredRoles && !!existingManagedSA && !!haveRolesEtag;
|
|
66
|
+
if (isPartiallyFiltered && (isEnrolling || isUnenrolling)) {
|
|
67
|
+
throw new error_1.FirebaseError("To ensure a whole codebase is migrated cleanly, you may not deploy only part of a " +
|
|
68
|
+
"codebase when opting into or out of declarative security (starting or no longer using `requireRoles`)");
|
|
69
|
+
}
|
|
61
70
|
if (!requiredRoles && (!existingManagedSA || !haveRolesEtag)) {
|
|
62
71
|
return {};
|
|
63
72
|
}
|
|
64
73
|
if (requiredRoles &&
|
|
65
|
-
backend.someEndpoint(want, (e) => typeof e.serviceAccount === "string" &&
|
|
66
|
-
e.serviceAccount !== "default" &&
|
|
67
|
-
!e.serviceAccount.startsWith("firebase-fn-"))) {
|
|
74
|
+
backend.someEndpoint(want, (e) => typeof e.serviceAccount === "string" && !e.serviceAccount.startsWith("firebase-fn-"))) {
|
|
68
75
|
throw new error_1.FirebaseError(`Cannot use explicit custom service accounts on functions while using declarative security in codebase ${codebase}.`);
|
|
69
76
|
}
|
|
70
77
|
if (!requiredRoles && existingManagedSA && haveRolesEtag) {
|
|
71
78
|
for (const endpoint of backend.allEndpoints(want)) {
|
|
72
79
|
if (!endpoint.serviceAccount || endpoint.serviceAccount === existingManagedSA) {
|
|
73
|
-
endpoint.serviceAccount =
|
|
80
|
+
endpoint.serviceAccount = null;
|
|
74
81
|
}
|
|
75
82
|
if (endpoint.labels) {
|
|
76
83
|
delete endpoint.labels["firebase-declarative-security-etag"];
|
|
@@ -180,20 +187,27 @@ async function prepare(context, options, payload) {
|
|
|
180
187
|
projectAlias: options.projectAlias,
|
|
181
188
|
};
|
|
182
189
|
proto.convertIfPresent(userEnvOpt, localCfg, "configDir", (cd) => options.config.path(cd));
|
|
183
|
-
const
|
|
190
|
+
const rawUserEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
191
|
+
const { userEnvs: userEnvs, secretRefs: secretRefs } = partitionUserEnvs(rawUserEnvs);
|
|
184
192
|
const envs = { ...userEnvs, ...firebaseEnvs };
|
|
185
193
|
const relevantEndpoints = backend
|
|
186
194
|
.allEndpoints(existingBackend)
|
|
187
195
|
.filter((e) => e.codebase === codebase || e.codebase === undefined);
|
|
188
196
|
await resolveDefaultRegionsForBuild(wantBuild, backend.of(...relevantEndpoints));
|
|
189
|
-
const
|
|
197
|
+
const parsedSecretRefs = (0, functional_1.mapObject)(secretRefs, (unparsed) => build.parseSecretRef(unparsed));
|
|
198
|
+
build.applyEnvSecretBindings(wantBuild, parsedSecretRefs);
|
|
199
|
+
const { backend: wantBackend, envs: resolvedEnvs, secretRefs: resolvedSecretRefs, } = await build.resolveBackend({
|
|
190
200
|
build: wantBuild,
|
|
191
201
|
firebaseConfig,
|
|
192
202
|
userEnvs,
|
|
193
203
|
nonInteractive: options.nonInteractive,
|
|
204
|
+
force: options.force,
|
|
194
205
|
isEmulator: false,
|
|
195
206
|
});
|
|
196
207
|
functionsEnv.writeResolvedParams(resolvedEnvs, userEnvs, userEnvOpt);
|
|
208
|
+
if (experiments.isEnabled("secretEnvParams")) {
|
|
209
|
+
functionsEnv.writeResolvedSecretRefs(resolvedSecretRefs, secretRefs, userEnvOpt);
|
|
210
|
+
}
|
|
197
211
|
let hasEnvsFromParams = false;
|
|
198
212
|
wantBackend.environmentVariables = envs;
|
|
199
213
|
for (const envName of Object.keys(resolvedEnvs)) {
|
|
@@ -284,7 +298,7 @@ async function prepare(context, options, payload) {
|
|
|
284
298
|
const haveBackends = (0, functionsDeployHelper_1.groupEndpointsByCodebase)(wantBackends, backend.allEndpoints(existingBackend));
|
|
285
299
|
for (const [codebase, wantBackend] of Object.entries(wantBackends)) {
|
|
286
300
|
const haveBackend = haveBackends[codebase] || backend.empty();
|
|
287
|
-
const security = await discoverSecurityDetails(codebase, wantBackend, haveBackend, projectId);
|
|
301
|
+
const security = await discoverSecurityDetails(codebase, wantBackend, haveBackend, projectId, context.filters);
|
|
288
302
|
payload.functions[codebase] = { wantBackend, haveBackend, ...security };
|
|
289
303
|
}
|
|
290
304
|
for (const [codebase, { wantBackend, haveBackend }] of Object.entries(payload.functions)) {
|
|
@@ -580,3 +594,15 @@ async function ensureAllRequiredAPIsEnabled(projectNumber, wantBackend = backend
|
|
|
580
594
|
await ensureApiEnabled.ensure(projectNumber, (0, api_1.secretManagerOrigin)(), "functions", false);
|
|
581
595
|
}
|
|
582
596
|
}
|
|
597
|
+
function partitionUserEnvs(allEnvs) {
|
|
598
|
+
const [secretRefs, userEnvs] = Object.entries(allEnvs).reduce((accumulatedSplit, [k, v]) => {
|
|
599
|
+
if (k.startsWith(build.SECRET_REF_PREFIX)) {
|
|
600
|
+
accumulatedSplit[0][k.replace(build.SECRET_REF_PREFIX, "")] = v;
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
accumulatedSplit[1][k] = v;
|
|
604
|
+
}
|
|
605
|
+
return accumulatedSplit;
|
|
606
|
+
}, [{}, {}]);
|
|
607
|
+
return { userEnvs: userEnvs, secretRefs: secretRefs };
|
|
608
|
+
}
|
|
@@ -6,6 +6,7 @@ exports.promptForUnsafeMigration = promptForUnsafeMigration;
|
|
|
6
6
|
exports.promptForMinInstances = promptForMinInstances;
|
|
7
7
|
exports.promptForCleanupPolicyDays = promptForCleanupPolicyDays;
|
|
8
8
|
exports.promptForSecurityChanges = promptForSecurityChanges;
|
|
9
|
+
exports.promptForLifecycleEvent = promptForLifecycleEvent;
|
|
9
10
|
const clc = require("colorette");
|
|
10
11
|
const functionsDeployHelper_1 = require("./functionsDeployHelper");
|
|
11
12
|
const error_1 = require("../../error");
|
|
@@ -253,3 +254,21 @@ async function promptForSecurityChanges(plan, options) {
|
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
256
|
}
|
|
257
|
+
async function promptForLifecycleEvent(codebase, wantBackend, options) {
|
|
258
|
+
const hooks = wantBackend.lifecycleHooks || {};
|
|
259
|
+
const choices = [];
|
|
260
|
+
for (const hookName of Object.keys(hooks)) {
|
|
261
|
+
choices.push({ name: hookName, value: hookName });
|
|
262
|
+
}
|
|
263
|
+
if (choices.length === 0) {
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
choices.push({ name: "skip (default)", value: "skip" });
|
|
267
|
+
const selection = await (0, prompt_1.select)({
|
|
268
|
+
message: `We cannot determine whether this deployment is a first deploy or a redeploy for codebase "${codebase}" because it is recovering from a previous partial failure.`,
|
|
269
|
+
choices,
|
|
270
|
+
default: "skip",
|
|
271
|
+
nonInteractive: options?.nonInteractive,
|
|
272
|
+
});
|
|
273
|
+
return selection === "skip" ? undefined : selection;
|
|
274
|
+
}
|
|
@@ -18,7 +18,6 @@ const error_1 = require("../../../error");
|
|
|
18
18
|
const getProjectNumber_1 = require("../../../getProjectNumber");
|
|
19
19
|
const extensions_1 = require("../../extensions");
|
|
20
20
|
const artifacts = require("../../../functions/artifacts");
|
|
21
|
-
const supported_1 = require("../runtimes/supported");
|
|
22
21
|
const lifecycle_1 = require("./lifecycle");
|
|
23
22
|
async function release(context, options, payload) {
|
|
24
23
|
if (context.extensions && payload.extensions) {
|
|
@@ -92,22 +91,22 @@ async function release(context, options, payload) {
|
|
|
92
91
|
reporter.printErrors(summary);
|
|
93
92
|
const wantBackend = backend.merge(...Object.values(payload.functions).map((p) => p.wantBackend));
|
|
94
93
|
printTriggerUrls(wantBackend, projectNumber);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const allErrors = summary.results.filter((r) => r.error).map((r) => r.error);
|
|
100
|
-
if (allErrors.length === 0) {
|
|
101
|
-
for (const [codebase, { wantBackend: w, haveBackend: h }] of Object.entries(payload.functions)) {
|
|
102
|
-
await (0, lifecycle_1.executeLifecycleHooks)(w, h, plan, codebase);
|
|
94
|
+
for (const [codebase, { wantBackend: w, haveBackend: h }] of Object.entries(payload.functions)) {
|
|
95
|
+
const { errors } = getCodebaseDeployStats(codebase, w, h, summary);
|
|
96
|
+
if (errors.length === 0) {
|
|
97
|
+
await (0, lifecycle_1.executeLifecycleHooks)(w, h, plan, codebase, options);
|
|
103
98
|
}
|
|
104
99
|
}
|
|
105
100
|
await setupArtifactCleanupPolicies(options, options.projectId, Object.keys(wantBackend.endpoints));
|
|
101
|
+
const allErrors = summary.results.filter((r) => r.error).map((r) => r.error);
|
|
106
102
|
if (allErrors.length) {
|
|
107
103
|
for (const [codebase, { wantBackend: w, haveBackend: h }] of Object.entries(payload.functions)) {
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
|
|
104
|
+
const { errors } = getCodebaseDeployStats(codebase, w, h, summary);
|
|
105
|
+
if (errors.length > 0) {
|
|
106
|
+
const event = (0, lifecycle_1.determineLifecycleEvent)(h);
|
|
107
|
+
if (w.lifecycleHooks?.[event]) {
|
|
108
|
+
utils.logLabeledWarning("functions", `Lifecycle hook "${event}" for codebase "${codebase}" was configured but not executed because one or more function deployments failed.`);
|
|
109
|
+
}
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
const opts = allErrors.length === 1 ? { original: allErrors[0] } : { children: allErrors };
|
|
@@ -138,6 +137,14 @@ function printTriggerUrls(results, projectNumber) {
|
|
|
138
137
|
logger_1.logger.info(clc.bold("Function URL"), `(${(0, functionsDeployHelper_1.getFunctionLabel)(httpsFunc)}):`, httpsFunc.uri);
|
|
139
138
|
}
|
|
140
139
|
}
|
|
140
|
+
function getCodebaseDeployStats(codebase, wantBackend, haveBackend, summary) {
|
|
141
|
+
const cb = codebase || "default";
|
|
142
|
+
const results = summary.results.filter((r) => (r.endpoint.codebase ?? "default") === cb ||
|
|
143
|
+
!!wantBackend.endpoints[r.endpoint.region]?.[r.endpoint.id] ||
|
|
144
|
+
!!haveBackend.endpoints[r.endpoint.region]?.[r.endpoint.id]);
|
|
145
|
+
const errors = results.filter((r) => r.error);
|
|
146
|
+
return { results, errors };
|
|
147
|
+
}
|
|
141
148
|
async function setupArtifactCleanupPolicies(options, projectId, locations) {
|
|
142
149
|
if (locations.length === 0) {
|
|
143
150
|
return;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.determineLifecycleEvent = determineLifecycleEvent;
|
|
4
|
+
exports.hasLifecycleHooks = hasLifecycleHooks;
|
|
5
|
+
exports.isRecoveryDeployment = isRecoveryDeployment;
|
|
4
6
|
exports.executeLifecycleHooks = executeLifecycleHooks;
|
|
5
7
|
exports.executeHook = executeHook;
|
|
6
8
|
const backend = require("../backend");
|
|
@@ -11,15 +13,46 @@ const cloudtasks = require("../../../gcp/cloudtasks");
|
|
|
11
13
|
const computeEngine = require("../../../gcp/computeEngine");
|
|
12
14
|
const projects_1 = require("../../../management/projects");
|
|
13
15
|
const functional_1 = require("../../../functional");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const prompts = require("../prompts");
|
|
17
|
+
function determineLifecycleEvent(haveBackend) {
|
|
18
|
+
const hasExistingEndpoints = backend.someEndpoint(haveBackend, (ep) => ep.state !== "FAILED");
|
|
16
19
|
if (!hasExistingEndpoints) {
|
|
17
20
|
return "afterFirstDeploy";
|
|
18
21
|
}
|
|
19
22
|
return "afterRedeploy";
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
function hasLifecycleHooks(backendSpec) {
|
|
25
|
+
return !!(backendSpec.lifecycleHooks && Object.keys(backendSpec.lifecycleHooks).length > 0);
|
|
26
|
+
}
|
|
27
|
+
function isRecoveryDeployment(wantBackend, haveBackend) {
|
|
28
|
+
const wantEndpoints = backend.allEndpoints(wantBackend);
|
|
29
|
+
const haveEndpoints = backend.allEndpoints(haveBackend);
|
|
30
|
+
const wantHashes = new Set(wantEndpoints.map((ep) => ep.hash).filter((h) => !!h));
|
|
31
|
+
if (!wantHashes.size) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const hasSameHash = haveEndpoints.some((ep) => ep.hash && wantHashes.has(ep.hash));
|
|
35
|
+
if (!hasSameHash) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const hasNetNewFunctions = wantEndpoints.some((wantEp) => !backend.findEndpoint(haveBackend, (haveEp) => haveEp.id === wantEp.id && haveEp.region === wantEp.region && haveEp.state !== "FAILED"));
|
|
39
|
+
return hasNetNewFunctions;
|
|
40
|
+
}
|
|
41
|
+
async function executeLifecycleHooks(wantBackend, haveBackend, plan, codebase, options) {
|
|
42
|
+
if (!hasLifecycleHooks(wantBackend)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
let event;
|
|
46
|
+
if (isRecoveryDeployment(wantBackend, haveBackend)) {
|
|
47
|
+
event = await prompts.promptForLifecycleEvent(codebase ?? "default", wantBackend, options);
|
|
48
|
+
if (!event) {
|
|
49
|
+
(0, utils_1.logLabeledBullet)("functions", `Skipping lifecycle hooks for codebase "${codebase ?? "default"}".`);
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
event = determineLifecycleEvent(haveBackend);
|
|
55
|
+
}
|
|
23
56
|
const hooks = wantBackend.lifecycleHooks || {};
|
|
24
57
|
const hook = hooks[event];
|
|
25
58
|
if (!hook) {
|