firebase-tools 15.23.0 → 15.24.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/bin/cli.js +9 -2
- package/lib/bin/progressiveHelp.js +126 -0
- package/lib/checkValidTargetFilters.js +1 -1
- package/lib/command.js +0 -7
- package/lib/commands/dataconnect-execute.js +1 -1
- package/lib/commands/deploy.js +27 -64
- 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/index.js +33 -1
- package/lib/deploy/functions/params.js +23 -15
- package/lib/deploy/functions/prepare.js +12 -6
- 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/hosting/index.js +30 -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/downloadableEmulatorInfo.json +24 -24
- package/lib/frameworks/utils.js +50 -1
- package/lib/hosting/proxy.js +15 -3
- package/lib/index.js +0 -1
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -285,14 +285,14 @@ async function promptList(param, projectId, resolvedDefault) {
|
|
|
285
285
|
prompt += ` \n(${param.description})`;
|
|
286
286
|
}
|
|
287
287
|
prompt += "\nSelect an option with the arrow keys, and use Enter to confirm your choice. ";
|
|
288
|
-
return promptSelectMultiple(prompt, param.input, resolvedDefault, (res) => res);
|
|
288
|
+
return promptSelectMultiple(prompt, param.input, resolvedDefault, param.input.multiSelect.nonEmpty, (res) => res);
|
|
289
289
|
}
|
|
290
290
|
else if (isTextInput(param.input)) {
|
|
291
291
|
prompt = `Enter a list of strings (delimiter: ${param.delimiter ? param.delimiter : ","}) for ${param.label || param.name}:`;
|
|
292
292
|
if (param.description) {
|
|
293
293
|
prompt += ` \n(${param.description})`;
|
|
294
294
|
}
|
|
295
|
-
return promptText(prompt, param.input, resolvedDefault, (res) => {
|
|
295
|
+
return promptText(prompt, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => {
|
|
296
296
|
return res.split(param.delimiter || ",");
|
|
297
297
|
});
|
|
298
298
|
}
|
|
@@ -301,7 +301,7 @@ async function promptList(param, projectId, resolvedDefault) {
|
|
|
301
301
|
if (param.description) {
|
|
302
302
|
prompt += ` \n(${param.description})`;
|
|
303
303
|
}
|
|
304
|
-
return promptResourceStrings(prompt, param.input, projectId);
|
|
304
|
+
return promptResourceStrings(prompt, param.input, projectId, false);
|
|
305
305
|
}
|
|
306
306
|
else {
|
|
307
307
|
(0, functional_1.assertExhaustive)(param.input);
|
|
@@ -330,7 +330,7 @@ async function promptBooleanParam(param, resolvedDefault) {
|
|
|
330
330
|
if (param.description) {
|
|
331
331
|
prompt += ` \n(${param.description})`;
|
|
332
332
|
}
|
|
333
|
-
return promptText(prompt, param.input, resolvedDefault, isTruthyInput);
|
|
333
|
+
return promptText(prompt, param.input, resolvedDefault, false, isTruthyInput);
|
|
334
334
|
}
|
|
335
335
|
else if (isResourceInput(param.input)) {
|
|
336
336
|
throw new error_1.FirebaseError("Boolean params cannot have Cloud Resource selector inputs");
|
|
@@ -368,7 +368,7 @@ async function promptStringParam(param, projectId, resolvedDefault) {
|
|
|
368
368
|
if (param.description) {
|
|
369
369
|
prompt += ` \n(${param.description})`;
|
|
370
370
|
}
|
|
371
|
-
return promptText(prompt, param.input, resolvedDefault, (res) => res);
|
|
371
|
+
return promptText(prompt, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => res);
|
|
372
372
|
}
|
|
373
373
|
else {
|
|
374
374
|
(0, functional_1.assertExhaustive)(param.input);
|
|
@@ -404,7 +404,7 @@ async function promptIntParam(param, resolvedDefault) {
|
|
|
404
404
|
if (param.description) {
|
|
405
405
|
prompt += ` \n(${param.description})`;
|
|
406
406
|
}
|
|
407
|
-
return promptText(prompt, param.input, resolvedDefault, (res) => {
|
|
407
|
+
return promptText(prompt, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => {
|
|
408
408
|
if (isNaN(+res)) {
|
|
409
409
|
return { message: `"${res}" could not be converted to a number.` };
|
|
410
410
|
}
|
|
@@ -439,10 +439,10 @@ async function promptResourceString(prompt, input, projectId, resolvedDefault) {
|
|
|
439
439
|
return promptSelect(prompt, forgedInput, resolvedDefault, (res) => res);
|
|
440
440
|
default:
|
|
441
441
|
logger_1.logger.warn(`Warning: unknown resource type ${input.resource.type}; defaulting to raw text input...`);
|
|
442
|
-
return promptText(prompt, { text: {} }, resolvedDefault, (res) => res);
|
|
442
|
+
return promptText(prompt, { text: {} }, resolvedDefault, true, (res) => res);
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
-
async function promptResourceStrings(prompt, input, projectId) {
|
|
445
|
+
async function promptResourceStrings(prompt, input, projectId, enforceNonEmpty) {
|
|
446
446
|
const notFound = new error_1.FirebaseError(`No instances of ${input.resource.type} found.`);
|
|
447
447
|
switch (input.resource.type) {
|
|
448
448
|
case "storage.googleapis.com/Bucket":
|
|
@@ -457,16 +457,16 @@ async function promptResourceStrings(prompt, input, projectId) {
|
|
|
457
457
|
}),
|
|
458
458
|
},
|
|
459
459
|
};
|
|
460
|
-
return promptSelectMultiple(prompt, forgedInput, undefined, (res) => res);
|
|
460
|
+
return promptSelectMultiple(prompt, forgedInput, undefined, enforceNonEmpty, (res) => res);
|
|
461
461
|
default:
|
|
462
462
|
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(","));
|
|
463
|
+
return promptText(prompt, { text: {} }, undefined, enforceNonEmpty, (res) => res.split(","));
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
function shouldRetry(obj) {
|
|
467
467
|
return typeof obj === "object" && obj.message !== undefined;
|
|
468
468
|
}
|
|
469
|
-
async function promptText(prompt, textInput, resolvedDefault, converter) {
|
|
469
|
+
async function promptText(prompt, textInput, resolvedDefault, enforceNonEmpty = false, converter) {
|
|
470
470
|
const res = await (0, prompt_1.input)({
|
|
471
471
|
default: resolvedDefault,
|
|
472
472
|
message: prompt,
|
|
@@ -476,13 +476,17 @@ async function promptText(prompt, textInput, resolvedDefault, converter) {
|
|
|
476
476
|
if (!userRe.test(res)) {
|
|
477
477
|
logger_1.logger.error(textInput.text.validationErrorMessage ||
|
|
478
478
|
`Input did not match provided validator ${userRe.toString()}, retrying...`);
|
|
479
|
-
return promptText(prompt, textInput, resolvedDefault, converter);
|
|
479
|
+
return promptText(prompt, textInput, resolvedDefault, enforceNonEmpty, converter);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
+
if (enforceNonEmpty && res === "") {
|
|
483
|
+
logger_1.logger.error(`A non-empty value is required, retrying......`);
|
|
484
|
+
return promptText(prompt, textInput, resolvedDefault, enforceNonEmpty, converter);
|
|
485
|
+
}
|
|
482
486
|
const converted = converter(res.toString());
|
|
483
487
|
if (shouldRetry(converted)) {
|
|
484
488
|
logger_1.logger.error(converted.message);
|
|
485
|
-
return promptText(prompt, textInput, resolvedDefault, converter);
|
|
489
|
+
return promptText(prompt, textInput, resolvedDefault, enforceNonEmpty, converter);
|
|
486
490
|
}
|
|
487
491
|
return converted;
|
|
488
492
|
}
|
|
@@ -505,7 +509,7 @@ async function promptSelect(prompt, input, resolvedDefault, converter) {
|
|
|
505
509
|
}
|
|
506
510
|
return converted;
|
|
507
511
|
}
|
|
508
|
-
async function promptSelectMultiple(prompt, input, resolvedDefault, converter) {
|
|
512
|
+
async function promptSelectMultiple(prompt, input, resolvedDefault, enforceNonEmpty = false, converter) {
|
|
509
513
|
const response = await (0, prompt_1.checkbox)({
|
|
510
514
|
default: resolvedDefault,
|
|
511
515
|
message: prompt,
|
|
@@ -520,7 +524,11 @@ async function promptSelectMultiple(prompt, input, resolvedDefault, converter) {
|
|
|
520
524
|
const converted = converter(response);
|
|
521
525
|
if (shouldRetry(converted)) {
|
|
522
526
|
logger_1.logger.error(converted.message);
|
|
523
|
-
return promptSelectMultiple(prompt, input, resolvedDefault, converter);
|
|
527
|
+
return promptSelectMultiple(prompt, input, resolvedDefault, enforceNonEmpty, converter);
|
|
528
|
+
}
|
|
529
|
+
if (enforceNonEmpty && Array.isArray(converted) && converted.length === 0) {
|
|
530
|
+
logger_1.logger.error(`A non-empty value is required, retrying...`);
|
|
531
|
+
return promptSelectMultiple(prompt, input, resolvedDefault, enforceNonEmpty, converter);
|
|
524
532
|
}
|
|
525
533
|
return converted;
|
|
526
534
|
}
|
|
@@ -47,7 +47,7 @@ const prompt = require("../../prompt");
|
|
|
47
47
|
const iam = require("../../gcp/iam");
|
|
48
48
|
const resourcemanager = require("../../gcp/resourceManager");
|
|
49
49
|
exports.EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE";
|
|
50
|
-
async function discoverSecurityDetails(codebase, want, have, projectId) {
|
|
50
|
+
async function discoverSecurityDetails(codebase, want, have, projectId, filters) {
|
|
51
51
|
const requiredRoles = want.requiredRoles;
|
|
52
52
|
const firstHave = backend.allEndpoints(have)[0];
|
|
53
53
|
let existingManagedSA;
|
|
@@ -58,19 +58,25 @@ async function discoverSecurityDetails(codebase, want, have, projectId) {
|
|
|
58
58
|
? firstHave.serviceAccount
|
|
59
59
|
: undefined;
|
|
60
60
|
}
|
|
61
|
+
const isPartiallyFiltered = !!(filters &&
|
|
62
|
+
filters.some((f) => (!f.codebase || f.codebase === codebase) && f.idChunks && f.idChunks.length > 0));
|
|
63
|
+
const isEnrolling = !!requiredRoles && !existingManagedSA;
|
|
64
|
+
const isUnenrolling = !requiredRoles && !!existingManagedSA && !!haveRolesEtag;
|
|
65
|
+
if (isPartiallyFiltered && (isEnrolling || isUnenrolling)) {
|
|
66
|
+
throw new error_1.FirebaseError("To ensure a whole codebase is migrated cleanly, you may not deploy only part of a " +
|
|
67
|
+
"codebase when opting into or out of declarative security (starting or no longer using `requireRoles`)");
|
|
68
|
+
}
|
|
61
69
|
if (!requiredRoles && (!existingManagedSA || !haveRolesEtag)) {
|
|
62
70
|
return {};
|
|
63
71
|
}
|
|
64
72
|
if (requiredRoles &&
|
|
65
|
-
backend.someEndpoint(want, (e) => typeof e.serviceAccount === "string" &&
|
|
66
|
-
e.serviceAccount !== "default" &&
|
|
67
|
-
!e.serviceAccount.startsWith("firebase-fn-"))) {
|
|
73
|
+
backend.someEndpoint(want, (e) => typeof e.serviceAccount === "string" && !e.serviceAccount.startsWith("firebase-fn-"))) {
|
|
68
74
|
throw new error_1.FirebaseError(`Cannot use explicit custom service accounts on functions while using declarative security in codebase ${codebase}.`);
|
|
69
75
|
}
|
|
70
76
|
if (!requiredRoles && existingManagedSA && haveRolesEtag) {
|
|
71
77
|
for (const endpoint of backend.allEndpoints(want)) {
|
|
72
78
|
if (!endpoint.serviceAccount || endpoint.serviceAccount === existingManagedSA) {
|
|
73
|
-
endpoint.serviceAccount =
|
|
79
|
+
endpoint.serviceAccount = null;
|
|
74
80
|
}
|
|
75
81
|
if (endpoint.labels) {
|
|
76
82
|
delete endpoint.labels["firebase-declarative-security-etag"];
|
|
@@ -284,7 +290,7 @@ async function prepare(context, options, payload) {
|
|
|
284
290
|
const haveBackends = (0, functionsDeployHelper_1.groupEndpointsByCodebase)(wantBackends, backend.allEndpoints(existingBackend));
|
|
285
291
|
for (const [codebase, wantBackend] of Object.entries(wantBackends)) {
|
|
286
292
|
const haveBackend = haveBackends[codebase] || backend.empty();
|
|
287
|
-
const security = await discoverSecurityDetails(codebase, wantBackend, haveBackend, projectId);
|
|
293
|
+
const security = await discoverSecurityDetails(codebase, wantBackend, haveBackend, projectId, context.filters);
|
|
288
294
|
payload.functions[codebase] = { wantBackend, haveBackend, ...security };
|
|
289
295
|
}
|
|
290
296
|
for (const [codebase, { wantBackend, haveBackend }] of Object.entries(payload.functions)) {
|
|
@@ -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) {
|
|
@@ -83,7 +83,9 @@ async function createDeploymentPlan(args) {
|
|
|
83
83
|
let rolesToRemove;
|
|
84
84
|
let serviceAccountToCreate;
|
|
85
85
|
let serviceAccountToDelete;
|
|
86
|
-
const isFiltered = !!(filters &&
|
|
86
|
+
const isFiltered = !!(filters &&
|
|
87
|
+
filters.some((f) => f.idChunks && f.idChunks.length > 0) &&
|
|
88
|
+
!deleteAll);
|
|
87
89
|
if (requiredRoles) {
|
|
88
90
|
rolesToAdd = requiredRoles.filter((r) => !roles.includes(r));
|
|
89
91
|
rolesToRemove = roles.filter((r) => !requiredRoles.includes(r));
|
|
@@ -1,9 +1,38 @@
|
|
|
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 static web apps to Firebase Hosting, including assets, redirects, rewrites and headers.";
|
|
11
|
+
exports.detailedHelp = "Firebase Hosting deploys web assets, redirects, rewrites, and header configurations.\n\n" +
|
|
12
|
+
"Single site configuration in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "hosting": {\n' +
|
|
15
|
+
' "public": "public",\n' +
|
|
16
|
+
' "ignore": [\n' +
|
|
17
|
+
' "firebase.json",\n' +
|
|
18
|
+
' "**/.*",\n' +
|
|
19
|
+
' "**/node_modules/**"\n' +
|
|
20
|
+
" ],\n" +
|
|
21
|
+
' "rewrites": [\n' +
|
|
22
|
+
' { "source": "**", "destination": "/index.html" }\n' +
|
|
23
|
+
" ]\n" +
|
|
24
|
+
" }\n" +
|
|
25
|
+
"}\n\n" +
|
|
26
|
+
"Multiple sites configuration (by site ID or deploy target):\n" +
|
|
27
|
+
"{\n" +
|
|
28
|
+
' "hosting": [\n' +
|
|
29
|
+
" {\n" +
|
|
30
|
+
' "site": "my-site-id",\n' +
|
|
31
|
+
' "public": "dist"\n' +
|
|
32
|
+
" },\n" +
|
|
33
|
+
" {\n" +
|
|
34
|
+
' "target": "my-site-target",\n' +
|
|
35
|
+
' "public": "build"\n' +
|
|
36
|
+
" }\n" +
|
|
37
|
+
" ]\n" +
|
|
38
|
+
"}";
|
package/lib/deploy/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deploy = exports.isDeployingWebFramework = void 0;
|
|
3
|
+
exports.deploy = exports.isDeployingWebFramework = exports.TARGETS = exports.TARGET_PERMISSIONS = exports.VALID_DEPLOY_TARGETS = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const api_1 = require("../api");
|
|
@@ -24,11 +24,71 @@ const AppHostingTarget = require("./apphosting");
|
|
|
24
24
|
const AuthTarget = require("./auth");
|
|
25
25
|
const frameworks_1 = require("../frameworks");
|
|
26
26
|
const prepare_1 = require("./hosting/prepare");
|
|
27
|
-
const utils_2 = require("../utils");
|
|
28
|
-
const deploy_1 = require("../commands/deploy");
|
|
29
27
|
const requirePermissions_1 = require("../requirePermissions");
|
|
30
28
|
const context_1 = require("./dataconnect/context");
|
|
31
|
-
|
|
29
|
+
exports.VALID_DEPLOY_TARGETS = [
|
|
30
|
+
"database",
|
|
31
|
+
"storage",
|
|
32
|
+
"firestore",
|
|
33
|
+
"functions",
|
|
34
|
+
"hosting",
|
|
35
|
+
"remoteconfig",
|
|
36
|
+
"extensions",
|
|
37
|
+
"dataconnect",
|
|
38
|
+
"apphosting",
|
|
39
|
+
"auth",
|
|
40
|
+
];
|
|
41
|
+
exports.TARGET_PERMISSIONS = {
|
|
42
|
+
database: ["firebasedatabase.instances.update"],
|
|
43
|
+
hosting: ["firebasehosting.sites.update"],
|
|
44
|
+
functions: [
|
|
45
|
+
"cloudfunctions.functions.list",
|
|
46
|
+
"cloudfunctions.functions.create",
|
|
47
|
+
"cloudfunctions.functions.get",
|
|
48
|
+
"cloudfunctions.functions.update",
|
|
49
|
+
"cloudfunctions.functions.delete",
|
|
50
|
+
"cloudfunctions.operations.get",
|
|
51
|
+
],
|
|
52
|
+
firestore: [
|
|
53
|
+
"datastore.indexes.list",
|
|
54
|
+
"datastore.indexes.create",
|
|
55
|
+
"datastore.indexes.update",
|
|
56
|
+
"datastore.indexes.delete",
|
|
57
|
+
],
|
|
58
|
+
storage: [
|
|
59
|
+
"firebaserules.releases.create",
|
|
60
|
+
"firebaserules.rulesets.create",
|
|
61
|
+
"firebaserules.releases.update",
|
|
62
|
+
],
|
|
63
|
+
remoteconfig: ["cloudconfig.configs.get", "cloudconfig.configs.update"],
|
|
64
|
+
dataconnect: [
|
|
65
|
+
"cloudsql.databases.create",
|
|
66
|
+
"cloudsql.databases.update",
|
|
67
|
+
"cloudsql.instances.connect",
|
|
68
|
+
"cloudsql.instances.create",
|
|
69
|
+
"cloudsql.instances.get",
|
|
70
|
+
"cloudsql.instances.list",
|
|
71
|
+
"cloudsql.instances.update",
|
|
72
|
+
"cloudsql.users.create",
|
|
73
|
+
"firebasedataconnect.connectors.create",
|
|
74
|
+
"firebasedataconnect.connectors.delete",
|
|
75
|
+
"firebasedataconnect.connectors.list",
|
|
76
|
+
"firebasedataconnect.connectors.update",
|
|
77
|
+
"firebasedataconnect.operations.get",
|
|
78
|
+
"firebasedataconnect.services.create",
|
|
79
|
+
"firebasedataconnect.services.delete",
|
|
80
|
+
"firebasedataconnect.services.update",
|
|
81
|
+
"firebasedataconnect.services.list",
|
|
82
|
+
"firebasedataconnect.schemas.create",
|
|
83
|
+
"firebasedataconnect.schemas.delete",
|
|
84
|
+
"firebasedataconnect.schemas.list",
|
|
85
|
+
"firebasedataconnect.schemas.update",
|
|
86
|
+
],
|
|
87
|
+
apphosting: [],
|
|
88
|
+
extensions: [],
|
|
89
|
+
auth: ["firebase.projects.update", "firebaseauth.configs.update"],
|
|
90
|
+
};
|
|
91
|
+
exports.TARGETS = {
|
|
32
92
|
hosting: HostingTarget,
|
|
33
93
|
database: DatabaseTarget,
|
|
34
94
|
firestore: FirestoreTarget,
|
|
@@ -84,10 +144,10 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
84
144
|
if (!targetNames.includes("functions")) {
|
|
85
145
|
targetNames.unshift("functions");
|
|
86
146
|
try {
|
|
87
|
-
await (0, requirePermissions_1.requirePermissions)(options,
|
|
147
|
+
await (0, requirePermissions_1.requirePermissions)(options, exports.TARGET_PERMISSIONS["functions"]);
|
|
88
148
|
}
|
|
89
149
|
catch (e) {
|
|
90
|
-
if ((0,
|
|
150
|
+
if ((0, utils_1.isRunningInGithubAction)()) {
|
|
91
151
|
throw new error_1.FirebaseError("It looks like you are deploying a Hosting site along with Cloud Functions " +
|
|
92
152
|
"using a GitHub action version that did not include Cloud Functions " +
|
|
93
153
|
"permissions. Please reinstall the GitHub action with" +
|
|
@@ -101,7 +161,7 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
101
161
|
await (0, prepare_1.addPinnedFunctionsToOnlyString)(context, options);
|
|
102
162
|
}
|
|
103
163
|
for (const targetName of targetNames) {
|
|
104
|
-
const target = TARGETS[targetName];
|
|
164
|
+
const target = exports.TARGETS[targetName];
|
|
105
165
|
if (!target) {
|
|
106
166
|
return Promise.reject(new error_1.FirebaseError(`${(0, colorette_1.bold)(targetName)} is not a valid deploy target`));
|
|
107
167
|
}
|
|
@@ -138,7 +198,7 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
138
198
|
};
|
|
139
199
|
const duration = Date.now() - startTime;
|
|
140
200
|
const params = Object.assign({}, baseParams);
|
|
141
|
-
Object.keys(TARGETS).reduce((accum, t) => {
|
|
201
|
+
Object.keys(exports.TARGETS).reduce((accum, t) => {
|
|
142
202
|
accum[t] = "false";
|
|
143
203
|
return accum;
|
|
144
204
|
}, params);
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deploy = exports.release = exports.prepare = void 0;
|
|
3
|
+
exports.detailedHelp = exports.help = exports.deploy = exports.release = exports.prepare = void 0;
|
|
4
4
|
const prepare_1 = require("./prepare");
|
|
5
5
|
exports.prepare = prepare_1.default;
|
|
6
6
|
const release_1 = require("./release");
|
|
7
7
|
exports.release = release_1.default;
|
|
8
8
|
const deploy_1 = require("./deploy");
|
|
9
9
|
exports.deploy = deploy_1.default;
|
|
10
|
+
exports.help = "Deploys Remote Config templates defined in your project's firebase.json.";
|
|
11
|
+
exports.detailedHelp = "Firebase Remote Config deploys client-facing templates and configurations.\n\n" +
|
|
12
|
+
"Configuration format in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "remoteconfig": {\n' +
|
|
15
|
+
' "template": "remoteconfig.template.json"\n' +
|
|
16
|
+
" }\n" +
|
|
17
|
+
"}";
|
|
@@ -1,9 +1,24 @@
|
|
|
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
|
const prepare_1 = require("./prepare");
|
|
5
5
|
exports.prepare = prepare_1.default;
|
|
6
6
|
const deploy_1 = require("./deploy");
|
|
7
7
|
exports.deploy = deploy_1.default;
|
|
8
8
|
const release_1 = require("./release");
|
|
9
9
|
exports.release = release_1.default;
|
|
10
|
+
exports.help = "Deploys security rules for Cloud Storage buckets defined in your project's firebase.json.";
|
|
11
|
+
exports.detailedHelp = "Cloud Storage deploys security rules to Storage buckets.\n\n" +
|
|
12
|
+
"Single bucket configuration in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "storage": {\n' +
|
|
15
|
+
' "rules": "storage.rules"\n' +
|
|
16
|
+
" }\n" +
|
|
17
|
+
"}\n\n" +
|
|
18
|
+
"Multiple buckets configuration (requires bucket name and rules file):\n" +
|
|
19
|
+
"{\n" +
|
|
20
|
+
' "storage": [\n' +
|
|
21
|
+
' { "bucket": "my-app-bucket-1", "rules": "storage-1.rules" },\n' +
|
|
22
|
+
' { "bucket": "my-app-bucket-2", "rules": "storage-2.rules", "target": "my-storage-target" }\n' +
|
|
23
|
+
" ]\n" +
|
|
24
|
+
"}";
|
|
@@ -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.16",
|
|
58
|
+
"expectedSize": 32877328,
|
|
59
|
+
"expectedChecksum": "48d472d8a9b009153d127bb0af9c0c77",
|
|
60
|
+
"expectedChecksumSHA256": "c4764168d79977047a8891ef52a450a4843b36d6d506e35a2147abeee01d7dd0",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.16",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.16"
|
|
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.16",
|
|
66
|
+
"expectedSize": 30995666,
|
|
67
|
+
"expectedChecksum": "71055082dbcf0a95451ac63839463a13",
|
|
68
|
+
"expectedChecksumSHA256": "b31dc5e60046474c66033209ac93105b91195fffa0a4a50bba73fda2cbb14ba7",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.16",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.16"
|
|
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.16",
|
|
74
|
+
"expectedSize": 32919040,
|
|
75
|
+
"expectedChecksum": "d53acc32d9a996d99f8a8ac0abc82b04",
|
|
76
|
+
"expectedChecksumSHA256": "962f6cbc62d39da102d49c463f225846ce64438bc95bdc28ee8f35b92b7bd6ef",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.16",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.16.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.16",
|
|
82
|
+
"expectedSize": 32030904,
|
|
83
|
+
"expectedChecksum": "240d642c408929e609d75eeeefe22689",
|
|
84
|
+
"expectedChecksumSHA256": "9963b3f1f011bf236a2a9908ebd7a282b79cd44405e77bdf8a566fd1c00dc4c7",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.16",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.16"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|