firebase-tools 15.32.1 → 15.33.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/commands/apps-create.js +34 -3
- package/lib/commands/functions-kits-uninstall.js +43 -21
- package/lib/commands/functions-lifecycle-list.js +5 -6
- package/lib/commands/hosting-channel-deploy.js +3 -3
- package/lib/commands/hosting-clone.js +60 -29
- package/lib/commands/hosting-disable.js +5 -1
- package/lib/crashlytics/onboarding.js +17 -2
- package/lib/deploy/functions/build.js +3 -0
- package/lib/deploy/functions/cel.js +89 -58
- package/lib/deploy/functions/functionsDeployHelper.js +10 -0
- package/lib/deploy/functions/prepare.js +25 -8
- package/lib/deploy/functions/release/fabricator.js +1 -5
- package/lib/deploy/functions/release/planner.js +3 -2
- package/lib/deploy/functions/validate.js +16 -0
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/deploy/hosting/release.js +2 -2
- package/lib/experiments.js +12 -0
- package/lib/frameworks/next/constants.js +20 -12
- package/lib/frameworks/next/index.js +3 -0
- package/lib/functions/env.js +4 -2
- package/lib/gcp/artifactregistry.js +20 -0
- package/lib/gcp/cloudtasks.js +14 -0
- package/lib/gcp/cloudtrace.js +38 -0
- package/lib/gcp/run.js +5 -0
- package/lib/gcp/runv2.js +32 -11
- package/lib/hosting/api.js +15 -15
- package/lib/hosting/runTags.js +1 -1
- package/lib/init/features/auth.js +46 -8
- package/lib/mcp/tools/firestore/converter.js +2 -2
- package/lib/mcp/util.js +11 -10
- package/lib/profileReport.js +4 -4
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -10,9 +10,10 @@ const CMP = /((?:!=)|(?:==)|(?:>=)|(?:<=)|>|<)/.source;
|
|
|
10
10
|
const identityRegexp = /{{ params\.(\S+) }}/;
|
|
11
11
|
const dualComparisonRegexp = new RegExp(/{{ params\.(\S+) CMP params\.(\S+) }}/.source.replace("CMP", CMP));
|
|
12
12
|
const comparisonRegexp = new RegExp(/{{ params\.(\S+) CMP (.+) }}/.source.replace("CMP", CMP));
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
13
|
+
const EXPR_PREFIX = "{{ ";
|
|
14
|
+
const EXPR_SUFFIX = " }}";
|
|
15
|
+
const QUESTION_TOKEN = " ? ";
|
|
16
|
+
const COLON_TOKEN = " : ";
|
|
16
17
|
function listEquals(a, b) {
|
|
17
18
|
return a.every((item) => b.includes(item)) && b.every((item) => a.includes(item));
|
|
18
19
|
}
|
|
@@ -28,36 +29,74 @@ function isComparisonExpression(value) {
|
|
|
28
29
|
function isDualComparisonExpression(value) {
|
|
29
30
|
return dualComparisonRegexp.test(value);
|
|
30
31
|
}
|
|
31
|
-
function isTernaryExpression(value) {
|
|
32
|
-
return ternaryRegexp.test(value);
|
|
33
|
-
}
|
|
34
|
-
function isLiteralTernaryExpression(value) {
|
|
35
|
-
return literalTernaryRegexp.test(value);
|
|
36
|
-
}
|
|
37
|
-
function isDualTernaryExpression(value) {
|
|
38
|
-
return dualTernaryRegexp.test(value);
|
|
39
|
-
}
|
|
40
32
|
class ExprParseError extends error_1.FirebaseError {
|
|
41
33
|
}
|
|
42
34
|
exports.ExprParseError = ExprParseError;
|
|
35
|
+
function parseTernary(expr) {
|
|
36
|
+
if (!expr.startsWith(EXPR_PREFIX) || !expr.endsWith(EXPR_SUFFIX)) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const body = expr.slice(EXPR_PREFIX.length, -EXPR_SUFFIX.length);
|
|
40
|
+
let inQuotes = false;
|
|
41
|
+
let depth = 0;
|
|
42
|
+
let question = -1;
|
|
43
|
+
let colon = -1;
|
|
44
|
+
for (let i = 0; i < body.length; i++) {
|
|
45
|
+
if (inQuotes && body[i] === "\\") {
|
|
46
|
+
i++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (body[i] === '"') {
|
|
50
|
+
inQuotes = !inQuotes;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (inQuotes)
|
|
54
|
+
continue;
|
|
55
|
+
if (body.startsWith(QUESTION_TOKEN, i)) {
|
|
56
|
+
if (depth === 0) {
|
|
57
|
+
question = i;
|
|
58
|
+
}
|
|
59
|
+
depth++;
|
|
60
|
+
i += QUESTION_TOKEN.length - 1;
|
|
61
|
+
}
|
|
62
|
+
else if (body.startsWith(COLON_TOKEN, i)) {
|
|
63
|
+
if (depth > 0) {
|
|
64
|
+
depth--;
|
|
65
|
+
if (depth === 0) {
|
|
66
|
+
colon = i;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
i += COLON_TOKEN.length - 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (question === -1) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (colon === -1) {
|
|
77
|
+
throw new ExprParseError(`Malformed CEL ternary expression '${expr}'`);
|
|
78
|
+
}
|
|
79
|
+
const condition = body.slice(0, question).trim();
|
|
80
|
+
const ifTrue = body.slice(question + QUESTION_TOKEN.length, colon).trim();
|
|
81
|
+
const ifFalse = body.slice(colon + COLON_TOKEN.length).trim();
|
|
82
|
+
if (!condition || !ifTrue || !ifFalse) {
|
|
83
|
+
throw new ExprParseError(`Malformed CEL ternary expression '${expr}'`);
|
|
84
|
+
}
|
|
85
|
+
return { condition, ifTrue, ifFalse };
|
|
86
|
+
}
|
|
43
87
|
function resolveExpression(wantType, expr, params) {
|
|
44
88
|
expr = preprocessLists(wantType, expr, params);
|
|
45
89
|
if (isIdentityExpression(expr)) {
|
|
46
90
|
return resolveIdentity(wantType, expr, params);
|
|
47
91
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
else if (isLiteralTernaryExpression(expr)) {
|
|
52
|
-
return resolveLiteralTernary(wantType, expr, params);
|
|
92
|
+
const ternary = parseTernary(expr);
|
|
93
|
+
if (ternary) {
|
|
94
|
+
return resolveTernary({ wantType, expr, parts: ternary, params });
|
|
53
95
|
}
|
|
54
|
-
else if (
|
|
55
|
-
return resolveTernary(wantType, expr, params);
|
|
56
|
-
}
|
|
57
|
-
else if (isDualComparisonExpression(expr)) {
|
|
96
|
+
else if (wantType === "boolean" && isDualComparisonExpression(expr)) {
|
|
58
97
|
return resolveDualComparison(expr, params);
|
|
59
98
|
}
|
|
60
|
-
else if (isComparisonExpression(expr)) {
|
|
99
|
+
else if (wantType === "boolean" && isComparisonExpression(expr)) {
|
|
61
100
|
return resolveComparison(expr, params);
|
|
62
101
|
}
|
|
63
102
|
else {
|
|
@@ -261,53 +300,45 @@ function resolveDualComparison(expr, params) {
|
|
|
261
300
|
throw new ExprParseError(`could not infer type of param ${lhsName} used in comparison operation`);
|
|
262
301
|
}
|
|
263
302
|
}
|
|
264
|
-
function resolveTernary(
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
return resolveParamListOrLiteral(wantType, match[5], params);
|
|
276
|
-
}
|
|
303
|
+
function resolveTernary(options) {
|
|
304
|
+
const { wantType, expr, parts, params } = options;
|
|
305
|
+
const isTrue = resolveTernaryCondition(expr, parts.condition, params);
|
|
306
|
+
return resolveTernaryBranch({
|
|
307
|
+
wantType,
|
|
308
|
+
expr,
|
|
309
|
+
branch: isTrue ? parts.ifTrue : parts.ifFalse,
|
|
310
|
+
params,
|
|
311
|
+
});
|
|
277
312
|
}
|
|
278
|
-
function
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
|
|
313
|
+
function resolveTernaryCondition(expr, condition, params) {
|
|
314
|
+
const conditionExpr = `${EXPR_PREFIX}${condition}${EXPR_SUFFIX}`;
|
|
315
|
+
if (isDualComparisonExpression(conditionExpr)) {
|
|
316
|
+
return resolveDualComparison(conditionExpr, params);
|
|
282
317
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (isTrue) {
|
|
286
|
-
return resolveParamListOrLiteral(wantType, match[4], params);
|
|
318
|
+
else if (isComparisonExpression(conditionExpr)) {
|
|
319
|
+
return resolveComparison(conditionExpr, params);
|
|
287
320
|
}
|
|
288
|
-
|
|
289
|
-
return resolveParamListOrLiteral(wantType, match[5], params);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
function resolveLiteralTernary(wantType, expr, params) {
|
|
293
|
-
const match = literalTernaryRegexp.exec(expr);
|
|
321
|
+
const match = identityRegexp.exec(conditionExpr);
|
|
294
322
|
if (!match) {
|
|
295
|
-
throw new ExprParseError(
|
|
323
|
+
throw new ExprParseError(`CEL ternary expression '${expr}' is conditioned on an unsupported form`);
|
|
296
324
|
}
|
|
297
325
|
const paramName = match[1];
|
|
298
|
-
const paramValue = params[
|
|
326
|
+
const paramValue = params[paramName];
|
|
299
327
|
if (!paramValue) {
|
|
300
|
-
throw new ExprParseError(
|
|
328
|
+
throw new ExprParseError(`CEL ternary expression '${expr}' references missing param ${paramName}`);
|
|
301
329
|
}
|
|
302
330
|
if (!paramValue.legalBoolean) {
|
|
303
|
-
throw new ExprParseError(
|
|
331
|
+
throw new ExprParseError(`CEL ternary expression '${expr}' is conditional on non-boolean param ${paramName}`);
|
|
304
332
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
333
|
+
return paramValue.asBoolean();
|
|
334
|
+
}
|
|
335
|
+
function resolveTernaryBranch(options) {
|
|
336
|
+
const { wantType, expr, branch, params } = options;
|
|
337
|
+
const nested = parseTernary(`${EXPR_PREFIX}${branch}${EXPR_SUFFIX}`);
|
|
338
|
+
if (nested) {
|
|
339
|
+
return resolveTernary({ wantType, expr, parts: nested, params });
|
|
310
340
|
}
|
|
341
|
+
return resolveParamListOrLiteral(wantType, branch, params);
|
|
311
342
|
}
|
|
312
343
|
function resolveParamListOrLiteral(wantType, field, params) {
|
|
313
344
|
const match = paramRegexp.exec(field);
|
|
@@ -7,6 +7,7 @@ exports.parseFunctionSelector = parseFunctionSelector;
|
|
|
7
7
|
exports.getEndpointFilters = getEndpointFilters;
|
|
8
8
|
exports.getHumanFriendlyPlatformName = getHumanFriendlyPlatformName;
|
|
9
9
|
exports.getFunctionLabel = getFunctionLabel;
|
|
10
|
+
exports.generationDowngradeMessage = generationDowngradeMessage;
|
|
10
11
|
exports.targetCodebases = targetCodebases;
|
|
11
12
|
exports.groupEndpointsByCodebase = groupEndpointsByCodebase;
|
|
12
13
|
exports.isCodebaseFiltered = isCodebaseFiltered;
|
|
@@ -101,6 +102,15 @@ function getFunctionLabel(fn) {
|
|
|
101
102
|
}
|
|
102
103
|
return id;
|
|
103
104
|
}
|
|
105
|
+
function generationDowngradeMessage(want, have) {
|
|
106
|
+
if (want.platform !== "gcfv1" || have.platform === "gcfv1") {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const from = have.platform === "gcfv2" ? "GCFv2" : "Cloud Run";
|
|
110
|
+
return (`[${getFunctionLabel(want)}] Functions cannot be downgraded from ${from} to GCFv1. ` +
|
|
111
|
+
`To recreate it as GCFv1, delete the existing function first: ` +
|
|
112
|
+
`firebase functions:delete ${want.id} --region ${want.region}`);
|
|
113
|
+
}
|
|
104
114
|
function targetCodebases(config, filters) {
|
|
105
115
|
const codebasesFromConfig = getCodebasesFromConfig(config);
|
|
106
116
|
if (!filters) {
|
|
@@ -23,6 +23,7 @@ const experiments = require("../../experiments");
|
|
|
23
23
|
const ensureApiEnabled = require("../../ensureApiEnabled");
|
|
24
24
|
const functionsConfig = require("../../functionsConfig");
|
|
25
25
|
const functionsEnv = require("../../functions/env");
|
|
26
|
+
const params = require("./params");
|
|
26
27
|
const runtimes = require("./runtimes");
|
|
27
28
|
const supported = require("./runtimes/supported");
|
|
28
29
|
const validate = require("./validate");
|
|
@@ -206,12 +207,11 @@ async function prepare(context, options, payload) {
|
|
|
206
207
|
const rawUserEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
207
208
|
const { userEnvs: userEnvs, secretRefs: secretRefs } = partitionUserEnvs(rawUserEnvs);
|
|
208
209
|
const envs = { ...userEnvs, ...firebaseEnvs };
|
|
210
|
+
const parsedSecretRefs = (0, functional_1.mapObject)(secretRefs, (unparsed) => build.parseSecretRef(unparsed));
|
|
211
|
+
await build.applyEnvSecretBindingsToBuild(wantBuild, parsedSecretRefs);
|
|
209
212
|
const relevantEndpoints = backend
|
|
210
213
|
.allEndpoints(existingBackend)
|
|
211
214
|
.filter((e) => e.codebase === codebase || e.codebase === undefined);
|
|
212
|
-
await resolveDefaultRegionsForBuild(wantBuild, backend.of(...relevantEndpoints));
|
|
213
|
-
const parsedSecretRefs = (0, functional_1.mapObject)(secretRefs, (unparsed) => build.parseSecretRef(unparsed));
|
|
214
|
-
await build.applyEnvSecretBindingsToBuild(wantBuild, parsedSecretRefs);
|
|
215
215
|
const { backend: wantBackend, envs: resolvedEnvs, secretRefs: resolvedSecretRefs, } = await build.resolveBackend({
|
|
216
216
|
build: wantBuild,
|
|
217
217
|
firebaseConfig,
|
|
@@ -219,6 +219,7 @@ async function prepare(context, options, payload) {
|
|
|
219
219
|
codebase,
|
|
220
220
|
nonInteractive: options.nonInteractive,
|
|
221
221
|
isEmulator: false,
|
|
222
|
+
resolveRegions: (b, paramValues) => resolveDefaultRegionsForBuild(b, backend.of(...relevantEndpoints), paramValues),
|
|
222
223
|
});
|
|
223
224
|
functionsEnv.writeResolvedParams(resolvedEnvs, userEnvs, userEnvOpt);
|
|
224
225
|
if (experiments.isEnabled("secretEnvParams") &&
|
|
@@ -276,6 +277,7 @@ async function prepare(context, options, payload) {
|
|
|
276
277
|
context.codebaseDeployEvents[codebase].runtime = wantBuild.runtime;
|
|
277
278
|
}
|
|
278
279
|
validate.endpointsAreUnique(wantBackends);
|
|
280
|
+
validate.noGenerationDowngrades(wantBackends, existingBackend);
|
|
279
281
|
context.sources = {};
|
|
280
282
|
for (const [codebase, wantBackend] of Object.entries(wantBackends)) {
|
|
281
283
|
const cfg = (0, projectConfig_1.configForCodebase)(context.config, codebase);
|
|
@@ -352,7 +354,7 @@ async function prepare(context, options, payload) {
|
|
|
352
354
|
validate.checkFiltersIntegrity(wantBackends, context.filters);
|
|
353
355
|
(0, applyHash_1.applyBackendHashToBackends)(wantBackends, context);
|
|
354
356
|
}
|
|
355
|
-
async function resolveDefaultRegionsForBuild(buildObj, have) {
|
|
357
|
+
async function resolveDefaultRegionsForBuild(buildObj, have, paramValues = {}) {
|
|
356
358
|
for (const [id, endpoint] of Object.entries(buildObj.endpoints)) {
|
|
357
359
|
if (!endpoint.region?.length || endpoint.region.includes(build.REGION_TBD)) {
|
|
358
360
|
let resolvedRegion = services_1.FALLBACK_DEPLOYMENT_REGION;
|
|
@@ -370,7 +372,7 @@ async function resolveDefaultRegionsForBuild(buildObj, have) {
|
|
|
370
372
|
}
|
|
371
373
|
else {
|
|
372
374
|
try {
|
|
373
|
-
resolvedRegion = await resolveRegionForTrigger(endpoint);
|
|
375
|
+
resolvedRegion = await resolveRegionForTrigger(endpoint, paramValues);
|
|
374
376
|
}
|
|
375
377
|
catch (err) {
|
|
376
378
|
logger_1.logger.debug(`Failed to resolve region for endpoint ${id}. Defaulting to ${services_1.FALLBACK_DEPLOYMENT_REGION}.`, (0, error_1.getErrStack)(err));
|
|
@@ -380,9 +382,24 @@ async function resolveDefaultRegionsForBuild(buildObj, have) {
|
|
|
380
382
|
}
|
|
381
383
|
}
|
|
382
384
|
}
|
|
383
|
-
async function resolveRegionForTrigger(endpoint) {
|
|
384
|
-
|
|
385
|
-
|
|
385
|
+
async function resolveRegionForTrigger(endpoint, paramValues = {}) {
|
|
386
|
+
let targetEndpoint = endpoint;
|
|
387
|
+
if (Object.keys(paramValues).length > 0 && build.isEventTriggered(endpoint)) {
|
|
388
|
+
targetEndpoint = {
|
|
389
|
+
...endpoint,
|
|
390
|
+
eventTrigger: {
|
|
391
|
+
...endpoint.eventTrigger,
|
|
392
|
+
...(endpoint.eventTrigger.eventFilters && {
|
|
393
|
+
eventFilters: (0, functional_1.mapObject)(endpoint.eventTrigger.eventFilters, (v) => params.resolveString(v, paramValues)),
|
|
394
|
+
}),
|
|
395
|
+
...(endpoint.eventTrigger.eventFilterPathPatterns && {
|
|
396
|
+
eventFilterPathPatterns: (0, functional_1.mapObject)(endpoint.eventTrigger.eventFilterPathPatterns, (v) => params.resolveString(v, paramValues)),
|
|
397
|
+
}),
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
const service = (0, services_1.serviceForEndpoint)(targetEndpoint);
|
|
402
|
+
return await service.getDefaultRegion(targetEndpoint);
|
|
386
403
|
}
|
|
387
404
|
function inferDetailsFromExisting(want, have, usedDotenv) {
|
|
388
405
|
for (const wantE of backend.allEndpoints(want)) {
|
|
@@ -871,12 +871,8 @@ class Fabricator {
|
|
|
871
871
|
.catch(rethrowAsUnlessNotFound(endpoint, "delete schedule"));
|
|
872
872
|
}
|
|
873
873
|
async disableTaskQueue(endpoint) {
|
|
874
|
-
const update = {
|
|
875
|
-
name: cloudtasks.queueNameForEndpoint(endpoint),
|
|
876
|
-
state: "DISABLED",
|
|
877
|
-
};
|
|
878
874
|
await this.executor
|
|
879
|
-
.run(() => cloudtasks.
|
|
875
|
+
.run(() => cloudtasks.disableQueue(cloudtasks.queueNameForEndpoint(endpoint)))
|
|
880
876
|
.catch(rethrowAs(endpoint, "disable task queue"));
|
|
881
877
|
}
|
|
882
878
|
async unregisterBlockingTrigger(endpoint) {
|
|
@@ -250,8 +250,9 @@ function checkForIllegalUpdate(want, have) {
|
|
|
250
250
|
if (wantType !== haveType && !upgradingHttpsFunction) {
|
|
251
251
|
throw new error_1.FirebaseError(`[${(0, functionsDeployHelper_1.getFunctionLabel)(want)}] Changing from ${haveType} function to ${wantType} function is not allowed. Please delete your function and create a new one instead.`);
|
|
252
252
|
}
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
const downgrade = (0, functionsDeployHelper_1.generationDowngradeMessage)(want, have);
|
|
254
|
+
if (downgrade) {
|
|
255
|
+
throw new error_1.FirebaseError(downgrade);
|
|
255
256
|
}
|
|
256
257
|
exports.checkForV2Upgrade(want, have);
|
|
257
258
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MAX_V2_SCHEDULE_ATTEMPT_DEADLINE_SECONDS = exports.DEFAULT_V2_SCHEDULE_ATTEMPT_DEADLINE_SECONDS = void 0;
|
|
4
4
|
exports.endpointsAreValid = endpointsAreValid;
|
|
5
|
+
exports.noGenerationDowngrades = noGenerationDowngrades;
|
|
5
6
|
exports.cpuConfigIsValid = cpuConfigIsValid;
|
|
6
7
|
exports.validateTimeoutConfig = validateTimeoutConfig;
|
|
7
8
|
exports.endpointsAreUnique = endpointsAreUnique;
|
|
@@ -85,6 +86,21 @@ function endpointsAreValid(wantBackend, existingBackend) {
|
|
|
85
86
|
}
|
|
86
87
|
cpuConfigIsValid(endpoints);
|
|
87
88
|
}
|
|
89
|
+
function noGenerationDowngrades(wantBackends, existingBackend) {
|
|
90
|
+
const msgs = [];
|
|
91
|
+
for (const wantBackend of Object.values(wantBackends)) {
|
|
92
|
+
for (const want of backend.allEndpoints(wantBackend).sort(backend.compareFunctions)) {
|
|
93
|
+
const have = existingBackend.endpoints[want.region]?.[want.id];
|
|
94
|
+
const msg = have && (0, functionsDeployHelper_1.generationDowngradeMessage)(want, have);
|
|
95
|
+
if (msg) {
|
|
96
|
+
msgs.push(msg);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (msgs.length) {
|
|
101
|
+
throw new error_1.FirebaseError(msgs.join("\n"));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
88
104
|
function cpuConfigIsValid(endpoints) {
|
|
89
105
|
const gcfV1WithCPU = matchingIds(endpoints, (endpoint) => endpoint.platform === "gcfv1" && typeof endpoint["cpu"] !== "undefined");
|
|
90
106
|
if (gcfV1WithCPU.length) {
|
|
@@ -105,7 +105,7 @@ async function prepare(context, options) {
|
|
|
105
105
|
(0, track_1.trackGA4)("hosting_version", {
|
|
106
106
|
framework: config.webFramework || "classic",
|
|
107
107
|
}),
|
|
108
|
-
api.createVersion(config.site, version),
|
|
108
|
+
api.createVersion(context.projectId, config.site, version),
|
|
109
109
|
]);
|
|
110
110
|
return versionName;
|
|
111
111
|
}));
|
|
@@ -21,7 +21,7 @@ async function release(context, options, functionsPayload) {
|
|
|
21
21
|
config: await (0, convertConfig_1.convertConfig)(context, functionsPayload, deploy),
|
|
22
22
|
};
|
|
23
23
|
const versionId = utils.last(deploy.version.split("/"));
|
|
24
|
-
const finalizedVersion = await api.updateVersion(deploy.config.site, versionId, update);
|
|
24
|
+
const finalizedVersion = await api.updateVersion(context.projectId, deploy.config.site, versionId, update);
|
|
25
25
|
logger_1.logger.debug(`[hosting] finalized version for ${deploy.config.site}:${finalizedVersion}`);
|
|
26
26
|
utils.logLabeledSuccess(`hosting[${deploy.config.site}]`, "version finalized");
|
|
27
27
|
utils.logLabeledBullet(`hosting[${deploy.config.site}]`, "releasing new version...");
|
|
@@ -32,7 +32,7 @@ async function release(context, options, functionsPayload) {
|
|
|
32
32
|
if (options.message) {
|
|
33
33
|
otherReleaseOpts.message = options.message;
|
|
34
34
|
}
|
|
35
|
-
const release = await api.createRelease(deploy.config.site, context.hostingChannel || "live", deploy.version, otherReleaseOpts);
|
|
35
|
+
const release = await api.createRelease(context.projectId, deploy.config.site, context.hostingChannel || "live", deploy.version, otherReleaseOpts);
|
|
36
36
|
logger_1.logger.debug("[hosting] release:", release);
|
|
37
37
|
utils.logLabeledSuccess(`hosting[${deploy.config.site}]`, "release complete");
|
|
38
38
|
}));
|
package/lib/experiments.js
CHANGED
|
@@ -150,6 +150,13 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
150
150
|
default: true,
|
|
151
151
|
public: true,
|
|
152
152
|
},
|
|
153
|
+
directcloudrun: {
|
|
154
|
+
shortDescription: "Build and deploy web apps directly to Cloud Run services",
|
|
155
|
+
fullDescription: "Enables `firebase init run`, `firebase deploy --only run`, and the " +
|
|
156
|
+
"`firebase run:services:update` command. " +
|
|
157
|
+
"These are in preview and may change.",
|
|
158
|
+
public: false,
|
|
159
|
+
},
|
|
153
160
|
dataconnect: {
|
|
154
161
|
shortDescription: "Deprecated. Previosuly, enabled SQL Connect related features.",
|
|
155
162
|
fullDescription: "Deprecated. Previously, enabled SQL Connect related features.",
|
|
@@ -211,6 +218,11 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
211
218
|
default: false,
|
|
212
219
|
public: false,
|
|
213
220
|
},
|
|
221
|
+
crashlyticsWebTrace: {
|
|
222
|
+
shortDescription: "Enable provisioning Cloud Trace storage during web app onboarding.",
|
|
223
|
+
default: false,
|
|
224
|
+
public: false,
|
|
225
|
+
},
|
|
214
226
|
secretEnvParams: {
|
|
215
227
|
shortDescription: "Enable reading the backing resource binding for a Functions secret param from .env",
|
|
216
228
|
default: true,
|
|
@@ -23,34 +23,42 @@ const WEBPACK_LAYERS_NAMES = {
|
|
|
23
23
|
reactServerComponents: "rsc",
|
|
24
24
|
serverSideRendering: "ssr",
|
|
25
25
|
actionBrowser: "action-browser",
|
|
26
|
-
|
|
26
|
+
apiNode: "api-node",
|
|
27
|
+
apiEdge: "api-edge",
|
|
27
28
|
middleware: "middleware",
|
|
29
|
+
instrument: "instrument",
|
|
28
30
|
edgeAsset: "edge-asset",
|
|
29
31
|
appPagesBrowser: "app-pages-browser",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
pagesDirBrowser: "pages-dir-browser",
|
|
33
|
+
pagesDirEdge: "pages-dir-edge",
|
|
34
|
+
pagesDirNode: "pages-dir-node",
|
|
32
35
|
};
|
|
33
36
|
exports.WEBPACK_LAYERS = {
|
|
34
37
|
...WEBPACK_LAYERS_NAMES,
|
|
35
38
|
GROUP: {
|
|
36
|
-
|
|
39
|
+
builtinReact: [WEBPACK_LAYERS_NAMES.reactServerComponents, WEBPACK_LAYERS_NAMES.actionBrowser],
|
|
40
|
+
serverOnly: [
|
|
37
41
|
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
38
42
|
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
39
|
-
WEBPACK_LAYERS_NAMES.
|
|
40
|
-
WEBPACK_LAYERS_NAMES.appRouteHandler,
|
|
41
|
-
],
|
|
42
|
-
nonClientServerTarget: [
|
|
43
|
+
WEBPACK_LAYERS_NAMES.instrument,
|
|
43
44
|
WEBPACK_LAYERS_NAMES.middleware,
|
|
44
|
-
WEBPACK_LAYERS_NAMES.api,
|
|
45
45
|
],
|
|
46
|
-
|
|
46
|
+
neutralTarget: [WEBPACK_LAYERS_NAMES.apiNode, WEBPACK_LAYERS_NAMES.apiEdge],
|
|
47
|
+
clientOnly: [WEBPACK_LAYERS_NAMES.serverSideRendering, WEBPACK_LAYERS_NAMES.appPagesBrowser],
|
|
48
|
+
bundled: [
|
|
47
49
|
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
48
50
|
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
49
|
-
WEBPACK_LAYERS_NAMES.appMetadataRoute,
|
|
50
|
-
WEBPACK_LAYERS_NAMES.appRouteHandler,
|
|
51
51
|
WEBPACK_LAYERS_NAMES.serverSideRendering,
|
|
52
52
|
WEBPACK_LAYERS_NAMES.appPagesBrowser,
|
|
53
53
|
WEBPACK_LAYERS_NAMES.shared,
|
|
54
|
+
WEBPACK_LAYERS_NAMES.instrument,
|
|
55
|
+
WEBPACK_LAYERS_NAMES.middleware,
|
|
56
|
+
],
|
|
57
|
+
appPages: [
|
|
58
|
+
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
59
|
+
WEBPACK_LAYERS_NAMES.serverSideRendering,
|
|
60
|
+
WEBPACK_LAYERS_NAMES.appPagesBrowser,
|
|
61
|
+
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
54
62
|
],
|
|
55
63
|
},
|
|
56
64
|
};
|
|
@@ -290,9 +290,12 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
|
|
|
290
290
|
{
|
|
291
291
|
srcRoute: null,
|
|
292
292
|
initialRevalidateSeconds: false,
|
|
293
|
+
initialExpireSeconds: undefined,
|
|
293
294
|
dataRoute: "",
|
|
294
295
|
experimentalPPR: false,
|
|
296
|
+
renderingMode: undefined,
|
|
295
297
|
prefetchDataRoute: "",
|
|
298
|
+
allowHeader: [],
|
|
296
299
|
},
|
|
297
300
|
];
|
|
298
301
|
}));
|
package/lib/functions/env.js
CHANGED
|
@@ -240,9 +240,11 @@ function writeUserEnvs(toWrite, envOpts) {
|
|
|
240
240
|
}
|
|
241
241
|
function checkForDuplicateKeys(isEmulator, keys, fullEnv, envsWithoutLocal) {
|
|
242
242
|
for (const key of keys) {
|
|
243
|
-
const definedInEnv =
|
|
243
|
+
const definedInEnv = Object.prototype.hasOwnProperty.call(fullEnv, key);
|
|
244
244
|
if (definedInEnv) {
|
|
245
|
-
if (envsWithoutLocal &&
|
|
245
|
+
if (envsWithoutLocal &&
|
|
246
|
+
isEmulator &&
|
|
247
|
+
Object.prototype.hasOwnProperty.call(envsWithoutLocal, key)) {
|
|
246
248
|
(0, utils_1.logWarning)(clc.cyan(clc.yellow("functions: ")) +
|
|
247
249
|
`Writing parameter ${key} to emulator-specific config .env.local. This will overwrite your existing definition only when emulating.`);
|
|
248
250
|
continue;
|
|
@@ -5,11 +5,14 @@ exports.ensureApiEnabled = ensureApiEnabled;
|
|
|
5
5
|
exports.deletePackage = deletePackage;
|
|
6
6
|
exports.getRepository = getRepository;
|
|
7
7
|
exports.updateRepository = updateRepository;
|
|
8
|
+
exports.ensureDockerRepository = ensureDockerRepository;
|
|
8
9
|
const apiv2_1 = require("../apiv2");
|
|
9
10
|
const api_1 = require("../api");
|
|
10
11
|
const metaprogramming_1 = require("../metaprogramming");
|
|
11
12
|
const api = require("../ensureApiEnabled");
|
|
12
13
|
const proto = require("./proto");
|
|
14
|
+
const error_1 = require("../error");
|
|
15
|
+
const operation_poller_1 = require("../operation-poller");
|
|
13
16
|
exports.API_VERSION = "v1";
|
|
14
17
|
const client = new apiv2_1.Client({
|
|
15
18
|
urlPrefix: (0, api_1.artifactRegistryDomain)(),
|
|
@@ -39,3 +42,20 @@ async function updateRepository(repo) {
|
|
|
39
42
|
});
|
|
40
43
|
return res.body;
|
|
41
44
|
}
|
|
45
|
+
async function ensureDockerRepository(projectId, location, repositoryId) {
|
|
46
|
+
try {
|
|
47
|
+
await getRepository(`projects/${projectId}/locations/${location}/repositories/${repositoryId}`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if ((0, error_1.getErrStatus)(err) !== 404) {
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const res = await client.post(`/projects/${projectId}/locations/${location}/repositories`, { format: "DOCKER" }, { queryParams: { repositoryId } });
|
|
56
|
+
await (0, operation_poller_1.pollOperation)({
|
|
57
|
+
apiOrigin: (0, api_1.artifactRegistryDomain)(),
|
|
58
|
+
apiVersion: exports.API_VERSION,
|
|
59
|
+
operationResourceName: res.body.name,
|
|
60
|
+
});
|
|
61
|
+
}
|
package/lib/gcp/cloudtasks.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.createQueue = createQueue;
|
|
|
5
5
|
exports.getQueue = getQueue;
|
|
6
6
|
exports.updateQueue = updateQueue;
|
|
7
7
|
exports.upsertQueue = upsertQueue;
|
|
8
|
+
exports.disableQueue = disableQueue;
|
|
8
9
|
exports.purgeQueue = purgeQueue;
|
|
9
10
|
exports.deleteQueue = deleteQueue;
|
|
10
11
|
exports.enqueueTask = enqueueTask;
|
|
@@ -72,6 +73,19 @@ async function upsertQueue(queue) {
|
|
|
72
73
|
throw err;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
76
|
+
async function disableQueue(name) {
|
|
77
|
+
try {
|
|
78
|
+
await module.exports.getQueue(name);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
const responseError = err;
|
|
82
|
+
if (responseError.context?.response?.statusCode === 404) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
await module.exports.updateQueue({ name, state: "DISABLED" });
|
|
88
|
+
}
|
|
75
89
|
async function purgeQueue(name) {
|
|
76
90
|
await client.post(`${name}:purge`);
|
|
77
91
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.provisionTraceStorage = provisionTraceStorage;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const API_VERSION = "v2";
|
|
8
|
+
const getTraceClient = () => new apiv2_1.Client({
|
|
9
|
+
urlPrefix: (0, api_1.cloudTraceOrigin)(),
|
|
10
|
+
auth: true,
|
|
11
|
+
apiVersion: API_VERSION,
|
|
12
|
+
});
|
|
13
|
+
async function provisionTraceStorage(projectId) {
|
|
14
|
+
const TRACE_ID = "33fc0d8c45bb4e5cebb29f047931270d";
|
|
15
|
+
const SPAN_ID = "f8fde40b437488e5";
|
|
16
|
+
const now = new Date();
|
|
17
|
+
const later = new Date(now.getTime() + 1000);
|
|
18
|
+
const payload = {
|
|
19
|
+
name: `projects/${projectId}`,
|
|
20
|
+
spans: [
|
|
21
|
+
{
|
|
22
|
+
name: `projects/${projectId}/traces/${TRACE_ID}/spans/${SPAN_ID}`,
|
|
23
|
+
spanId: SPAN_ID,
|
|
24
|
+
displayName: { value: "/welcome" },
|
|
25
|
+
startTime: now.toISOString(),
|
|
26
|
+
endTime: later.toISOString(),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
await getTraceClient().post(`/projects/${projectId}/traces:batchWrite`, payload);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
throw new error_1.FirebaseError(`Failed to provision trace storage for project ${projectId}: ${(0, error_1.getErrMsg)(err)}`, {
|
|
35
|
+
original: (0, error_1.getError)(err),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
package/lib/gcp/run.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.getIamPolicy = getIamPolicy;
|
|
|
11
11
|
exports.setInvokerCreate = setInvokerCreate;
|
|
12
12
|
exports.setInvokerUpdate = setInvokerUpdate;
|
|
13
13
|
exports.fetchServiceLogs = fetchServiceLogs;
|
|
14
|
+
exports.listLocations = listLocations;
|
|
14
15
|
const apiv2_1 = require("../apiv2");
|
|
15
16
|
const error_1 = require("../error");
|
|
16
17
|
const api_1 = require("../api");
|
|
@@ -166,3 +167,7 @@ async function fetchServiceLogs(projectId, serviceId) {
|
|
|
166
167
|
});
|
|
167
168
|
}
|
|
168
169
|
}
|
|
170
|
+
async function listLocations(projectId) {
|
|
171
|
+
const res = await client.get(`/projects/${projectId}/locations`);
|
|
172
|
+
return res.body?.locations?.map((l) => l.locationId) ?? [];
|
|
173
|
+
}
|