firebase-tools 15.22.4 → 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/apiv2.js +91 -32
- package/lib/apphosting/backend.js +11 -4
- 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/commands/functions-delete.js +5 -3
- package/lib/commands/functions-lifecycle-list.js +94 -0
- package/lib/commands/functions-lifecycle-run.js +29 -0
- package/lib/commands/index.js +3 -0
- package/lib/database/import.js +3 -3
- package/lib/dataconnect/webhook.js +1 -2
- 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/backend.js +9 -0
- package/lib/deploy/functions/build.js +3 -0
- package/lib/deploy/functions/index.js +33 -1
- package/lib/deploy/functions/params.js +23 -15
- package/lib/deploy/functions/prepare.js +96 -1
- package/lib/deploy/functions/prompts.js +81 -0
- package/lib/deploy/functions/release/fabricator.js +79 -4
- package/lib/deploy/functions/release/index.js +45 -23
- package/lib/deploy/functions/release/lifecycle.js +79 -53
- package/lib/deploy/functions/release/planner.js +43 -5
- package/lib/deploy/functions/runtimes/discovery/index.js +4 -3
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +18 -1
- package/lib/deploy/functions/runtimes/node/index.js +1 -2
- package/lib/deploy/functions/runtimes/python/index.js +1 -2
- package/lib/deploy/hosting/index.js +30 -1
- package/lib/deploy/hosting/uploader.js +2 -3
- 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/downloadUtils.js +3 -1
- package/lib/emulator/auth/operations.js +18 -8
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/storage/apis/gcloud.js +61 -0
- package/lib/emulator/storage/multipart.js +82 -2
- package/lib/emulator/taskQueue.js +3 -11
- package/lib/extensions/extensionsHelper.js +6 -4
- package/lib/frameworks/utils.js +50 -1
- package/lib/gcp/iam.js +68 -2
- package/lib/gcp/knownRoles.json +99 -0
- package/lib/gcp/resourceManager.js +42 -1
- package/lib/gemini/fdcExperience.js +2 -2
- package/lib/hosting/initMiddleware.js +1 -1
- package/lib/hosting/proxy.js +57 -23
- package/lib/index.js +0 -1
- package/lib/management/apps.js +4 -2
- package/lib/profiler.js +1 -2
- package/lib/streamUtils.js +24 -0
- package/lib/track.js +1 -2
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +4 -21
- package/package.json +2 -4
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
exports.loadCodebaseBuild = loadCodebaseBuild;
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
const prepare_1 = require("../deploy/functions/prepare");
|
|
8
|
+
const projectConfig_1 = require("../functions/projectConfig");
|
|
9
|
+
const adminSdkConfig_1 = require("../emulator/adminSdkConfig");
|
|
10
|
+
const projectUtils_1 = require("../projectUtils");
|
|
11
|
+
const error_1 = require("../error");
|
|
12
|
+
const ensureApiEnabled = require("../ensureApiEnabled");
|
|
13
|
+
const api_1 = require("../api");
|
|
14
|
+
const prepareFunctionsUpload_1 = require("../deploy/functions/prepareFunctionsUpload");
|
|
15
|
+
const self = require("./functions-lifecycle-list");
|
|
16
|
+
async function loadCodebaseBuild(codebase, options) {
|
|
17
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
18
|
+
if (!options.config) {
|
|
19
|
+
throw new error_1.FirebaseError("Not in a Firebase project directory (firebase.json not found).");
|
|
20
|
+
}
|
|
21
|
+
const fnConfig = (0, projectConfig_1.normalizeAndValidate)(options.config.src.functions);
|
|
22
|
+
const hasCodebase = fnConfig.some((c) => c.codebase === codebase);
|
|
23
|
+
if (!hasCodebase) {
|
|
24
|
+
throw new error_1.FirebaseError(`Codebase "${codebase}" is not defined in firebase.json.`);
|
|
25
|
+
}
|
|
26
|
+
const firebaseConfig = await (0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(projectId);
|
|
27
|
+
if (!firebaseConfig) {
|
|
28
|
+
throw new error_1.FirebaseError("Admin SDK config unexpectedly undefined - have you run firebase init?");
|
|
29
|
+
}
|
|
30
|
+
let runtimeConfig = { firebase: firebaseConfig };
|
|
31
|
+
if (fnConfig.some(projectConfig_1.shouldUseRuntimeConfig)) {
|
|
32
|
+
try {
|
|
33
|
+
const runtimeConfigApiEnabled = await ensureApiEnabled.check(projectId, (0, api_1.runtimeconfigOrigin)(), "runtimeconfig", true);
|
|
34
|
+
if (runtimeConfigApiEnabled) {
|
|
35
|
+
runtimeConfig = { ...runtimeConfig, ...(await (0, prepareFunctionsUpload_1.getFunctionsConfig)(projectId)) };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
logger_1.logger.debug("Could not check Runtime Config API status, assuming disabled:", err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const wantBuilds = await (0, prepare_1.loadCodebases)(fnConfig, options, firebaseConfig, runtimeConfig, undefined);
|
|
43
|
+
const codebaseBuild = wantBuilds[codebase];
|
|
44
|
+
if (!codebaseBuild) {
|
|
45
|
+
throw new error_1.FirebaseError(`Failed to load build for codebase "${codebase}".`);
|
|
46
|
+
}
|
|
47
|
+
return codebaseBuild;
|
|
48
|
+
}
|
|
49
|
+
exports.command = new command_1.Command("functions:lifecycle:list <codebase>")
|
|
50
|
+
.description("list all the lifecycle hooks defined in a codebase")
|
|
51
|
+
.action(async (codebase, options) => {
|
|
52
|
+
const codebaseBuild = await self.loadCodebaseBuild(codebase, options);
|
|
53
|
+
const hooks = codebaseBuild.lifecycleHooks || {};
|
|
54
|
+
if (Object.keys(hooks).length === 0) {
|
|
55
|
+
logger_1.logger.info(`No lifecycle hooks configured for codebase "${codebase}".`);
|
|
56
|
+
return hooks;
|
|
57
|
+
}
|
|
58
|
+
for (const [event, hook] of Object.entries(hooks)) {
|
|
59
|
+
logger_1.logger.info(`\nEvent: ${event}`);
|
|
60
|
+
if ("task" in hook) {
|
|
61
|
+
logger_1.logger.info(` Action: Task`);
|
|
62
|
+
logger_1.logger.info(` Target Function: ${hook.task.function}`);
|
|
63
|
+
if (hook.task.body) {
|
|
64
|
+
logger_1.logger.info(` Body: ${JSON.stringify(hook.task.body, null, 2).replace(/\n/g, "\n ")}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if ("call" in hook) {
|
|
68
|
+
logger_1.logger.info(` Action: Call`);
|
|
69
|
+
logger_1.logger.info(` Target Function: ${hook.call.function}`);
|
|
70
|
+
if (hook.call.params) {
|
|
71
|
+
logger_1.logger.info(` Params: ${JSON.stringify(hook.call.params, null, 2).replace(/\n/g, "\n ")}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if ("http" in hook) {
|
|
75
|
+
logger_1.logger.info(` Action: HTTP`);
|
|
76
|
+
if (hook.http.function) {
|
|
77
|
+
logger_1.logger.info(` Target Function: ${hook.http.function}`);
|
|
78
|
+
}
|
|
79
|
+
if (hook.http.url) {
|
|
80
|
+
logger_1.logger.info(` URL: ${hook.http.url}`);
|
|
81
|
+
}
|
|
82
|
+
if (hook.http.method) {
|
|
83
|
+
logger_1.logger.info(` Method: ${hook.http.method}`);
|
|
84
|
+
}
|
|
85
|
+
if (hook.http.headers) {
|
|
86
|
+
logger_1.logger.info(` Headers: ${JSON.stringify(hook.http.headers, null, 2).replace(/\n/g, "\n ")}`);
|
|
87
|
+
}
|
|
88
|
+
if (hook.http.body) {
|
|
89
|
+
logger_1.logger.info(` Body: ${JSON.stringify(hook.http.body, null, 2).replace(/\n/g, "\n ")}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return hooks;
|
|
94
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const projectUtils_1 = require("../projectUtils");
|
|
6
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
7
|
+
const error_1 = require("../error");
|
|
8
|
+
const functions_lifecycle_list_1 = require("./functions-lifecycle-list");
|
|
9
|
+
const backend = require("../deploy/functions/backend");
|
|
10
|
+
const lifecycle_1 = require("../deploy/functions/release/lifecycle");
|
|
11
|
+
exports.command = new command_1.Command("functions:lifecycle:run <hookName> <codebase>")
|
|
12
|
+
.description("run a specific lifecycle hook in isolation")
|
|
13
|
+
.before(requirePermissions_1.requirePermissions, ["cloudfunctions.functions.list", "run.services.list"])
|
|
14
|
+
.action(async (hookName, codebase, options) => {
|
|
15
|
+
if (hookName !== "afterFirstDeploy" && hookName !== "afterRedeploy") {
|
|
16
|
+
throw new error_1.FirebaseError(`Invalid hook name "${hookName}". Supported hooks are "afterFirstDeploy" and "afterRedeploy".`);
|
|
17
|
+
}
|
|
18
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
19
|
+
const codebaseBuild = await (0, functions_lifecycle_list_1.loadCodebaseBuild)(codebase, options);
|
|
20
|
+
const hook = codebaseBuild.lifecycleHooks?.[hookName];
|
|
21
|
+
if (!hook) {
|
|
22
|
+
throw new error_1.FirebaseError(`No lifecycle hook "${hookName}" configured for codebase "${codebase}".`);
|
|
23
|
+
}
|
|
24
|
+
const context = {
|
|
25
|
+
projectId,
|
|
26
|
+
};
|
|
27
|
+
const existingBackend = await backend.existingBackend(context);
|
|
28
|
+
await (0, lifecycle_1.executeHook)(hookName, hook, existingBackend);
|
|
29
|
+
});
|
package/lib/commands/index.js
CHANGED
|
@@ -151,6 +151,9 @@ function load(client) {
|
|
|
151
151
|
client.functions.log = loadCommand("functions-log");
|
|
152
152
|
client.functions.shell = loadCommand("functions-shell");
|
|
153
153
|
client.functions.list = loadCommand("functions-list");
|
|
154
|
+
client.functions.lifecycle = {};
|
|
155
|
+
client.functions.lifecycle.list = loadCommand("functions-lifecycle-list");
|
|
156
|
+
client.functions.lifecycle.run = loadCommand("functions-lifecycle-run");
|
|
154
157
|
if (experiments.isEnabled("deletegcfartifacts")) {
|
|
155
158
|
client.functions.deletegcfartifacts = loadCommand("functions-deletegcfartifacts");
|
|
156
159
|
}
|
package/lib/database/import.js
CHANGED
|
@@ -6,7 +6,6 @@ const Filter = require("stream-json/filters/Filter");
|
|
|
6
6
|
const stream = require("stream");
|
|
7
7
|
const StreamObject = require("stream-json/streamers/StreamObject");
|
|
8
8
|
const apiv2_1 = require("../apiv2");
|
|
9
|
-
const node_fetch_1 = require("node-fetch");
|
|
10
9
|
const error_1 = require("../error");
|
|
11
10
|
const utils_1 = require("../utils");
|
|
12
11
|
class BatchChunks extends stream.Transform {
|
|
@@ -169,8 +168,9 @@ class DatabaseImporter {
|
|
|
169
168
|
}
|
|
170
169
|
catch (err) {
|
|
171
170
|
const isTimeoutErr = err instanceof error_1.FirebaseError &&
|
|
172
|
-
err.original
|
|
173
|
-
|
|
171
|
+
(err.original?.name === "AbortError" ||
|
|
172
|
+
err.original?.code === "ETIMEDOUT" ||
|
|
173
|
+
err.original?.cause?.code === "ETIMEDOUT");
|
|
174
174
|
if (isTimeoutErr) {
|
|
175
175
|
await new Promise((res) => setTimeout(res, this.nonFatalRetryTimeout));
|
|
176
176
|
return await doRequest();
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.port = exports.DEFAULT_PORT = exports.VSCODE_MESSAGE = void 0;
|
|
4
4
|
exports.sendVSCodeMessage = sendVSCodeMessage;
|
|
5
|
-
const node_fetch_1 = require("node-fetch");
|
|
6
5
|
const logger_1 = require("../logger");
|
|
7
6
|
var VSCODE_MESSAGE;
|
|
8
7
|
(function (VSCODE_MESSAGE) {
|
|
@@ -15,7 +14,7 @@ exports.port = process.env.VSCODE_WEBHOOK_PORT || exports.DEFAULT_PORT;
|
|
|
15
14
|
async function sendVSCodeMessage(body) {
|
|
16
15
|
const jsonBody = JSON.stringify(body);
|
|
17
16
|
try {
|
|
18
|
-
return await (
|
|
17
|
+
return await fetch(`http://localhost:${exports.port}/vscode/notify`, {
|
|
19
18
|
method: "POST",
|
|
20
19
|
headers: {
|
|
21
20
|
Accept: "application/json",
|
|
@@ -1,9 +1,34 @@
|
|
|
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 framework-centered web apps. See https://firebase.google.com/docs/app-hosting/frameworks-tooling#web-frameworks-and-app-hosting for a full list of supported frameworks.";
|
|
11
|
+
exports.detailedHelp = "App Hosting deploys Frameworks-based web application backends.\n\n" +
|
|
12
|
+
"Single backend configuration in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "apphosting": {\n' +
|
|
15
|
+
' "backendId": "my-backend-id",\n' +
|
|
16
|
+
' "rootDir": ".",\n' +
|
|
17
|
+
' "ignore": ["node_modules", ".git"]\n' +
|
|
18
|
+
" }\n" +
|
|
19
|
+
"}\n\n" +
|
|
20
|
+
"Multiple backends configuration:\n" +
|
|
21
|
+
"{\n" +
|
|
22
|
+
' "apphosting": [\n' +
|
|
23
|
+
" {\n" +
|
|
24
|
+
' "backendId": "my-backend-1",\n' +
|
|
25
|
+
' "rootDir": "apps/backend-1",\n' +
|
|
26
|
+
' "ignore": ["node_modules"]\n' +
|
|
27
|
+
" },\n" +
|
|
28
|
+
" {\n" +
|
|
29
|
+
' "backendId": "my-backend-2",\n' +
|
|
30
|
+
' "rootDir": "apps/backend-2",\n' +
|
|
31
|
+
' "ignore": ["node_modules"]\n' +
|
|
32
|
+
" }\n" +
|
|
33
|
+
" ]\n" +
|
|
34
|
+
"}";
|
package/lib/deploy/auth/index.js
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
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 configuration settings for Firebase Authentication providers.";
|
|
11
|
+
exports.detailedHelp = "Firebase Authentication configures identity providers and sign-in methods.\n\n" +
|
|
12
|
+
"Configuration format in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "auth": {\n' +
|
|
15
|
+
' "providers": {\n' +
|
|
16
|
+
' "anonymous": true,\n' +
|
|
17
|
+
' "emailPassword": true,\n' +
|
|
18
|
+
' "googleSignIn": {\n' +
|
|
19
|
+
' "authorizedRedirectUris": [\n' +
|
|
20
|
+
' "https://my-app.firebaseapp.com/__/auth/handler"\n' +
|
|
21
|
+
" ],\n" +
|
|
22
|
+
' "supportEmail": "support@example.com"\n' +
|
|
23
|
+
" }\n" +
|
|
24
|
+
" }\n" +
|
|
25
|
+
" }\n" +
|
|
26
|
+
"}";
|
|
@@ -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
|
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 security rules referenced by your project's firebase.json.";
|
|
11
|
+
exports.detailedHelp = "Realtime Database deploys rules to database instances.\n\n" +
|
|
12
|
+
"Single database configuration in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "database": {\n' +
|
|
15
|
+
' "rules": "database.rules"\n' +
|
|
16
|
+
" }\n" +
|
|
17
|
+
"}\n\n" +
|
|
18
|
+
"Multiple database instances configuration (by target or database ID):\n" +
|
|
19
|
+
"{\n" +
|
|
20
|
+
' "database": [\n' +
|
|
21
|
+
' { "target": "my-db-target", "rules": "rules.rules" },\n' +
|
|
22
|
+
' { "database": "my-database-id", "rules": "rules2.rules" }\n' +
|
|
23
|
+
" ]\n" +
|
|
24
|
+
"}";
|
|
@@ -1,9 +1,27 @@
|
|
|
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 Data Connect services, schemas, and connectors. Supports filtering:\n" +
|
|
11
|
+
" --only dataconnect:serviceId\n" +
|
|
12
|
+
" --only dataconnect:serviceId:connectorId\n" +
|
|
13
|
+
" --only dataconnect:serviceId:schema";
|
|
14
|
+
exports.detailedHelp = "Firebase Data Connect deploys services, GraphQL schemas, and connectors.\n\n" +
|
|
15
|
+
"Single service configuration in firebase.json:\n" +
|
|
16
|
+
"{\n" +
|
|
17
|
+
' "dataconnect": {\n' +
|
|
18
|
+
' "source": "dataconnect"\n' +
|
|
19
|
+
" }\n" +
|
|
20
|
+
"}\n\n" +
|
|
21
|
+
"Multiple services configuration:\n" +
|
|
22
|
+
"{\n" +
|
|
23
|
+
' "dataconnect": [\n' +
|
|
24
|
+
' { "source": "dataconnect-service-1" },\n' +
|
|
25
|
+
' { "source": "dataconnect-service-2" }\n' +
|
|
26
|
+
" ]\n" +
|
|
27
|
+
"}";
|
|
@@ -1,9 +1,17 @@
|
|
|
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 configuration changes to your installed Extension instances.";
|
|
11
|
+
exports.detailedHelp = "Firebase Extensions deploys settings and configuration environments for installed extension instances.\n\n" +
|
|
12
|
+
"Configuration format in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "extensions": {\n' +
|
|
15
|
+
' "my-extension-instance-id": "firebase/storage-resize-images@^0.1.0"\n' +
|
|
16
|
+
" }\n" +
|
|
17
|
+
"}";
|
|
@@ -1,9 +1,28 @@
|
|
|
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 and indexes referenced by your project's firebase.json.";
|
|
11
|
+
exports.detailedHelp = "Cloud Firestore deploys security rules and indexes to Firestore databases.\n\n" +
|
|
12
|
+
"Single database configuration in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "firestore": {\n' +
|
|
15
|
+
' "rules": "firestore.rules",\n' +
|
|
16
|
+
' "indexes": "firestore.indexes.json",\n' +
|
|
17
|
+
' "location": "us-east1",\n' +
|
|
18
|
+
' "edition": "standard",\n' +
|
|
19
|
+
' "dataAccessMode": "FIRESTORE_NATIVE"\n' +
|
|
20
|
+
" }\n" +
|
|
21
|
+
"}\n\n" +
|
|
22
|
+
"Multiple databases configuration (by target or database ID):\n" +
|
|
23
|
+
"{\n" +
|
|
24
|
+
' "firestore": [\n' +
|
|
25
|
+
' { "target": "my-firestore-target", "rules": "firestore.rules", "indexes": "indexes.json" },\n' +
|
|
26
|
+
' { "database": "another-db", "rules": "another.rules", "indexes": "another.indexes.json", "location": "europe-west1", "edition": "enterprise", "dataAccessMode": "MONGODB_COMPATIBLE" }\n' +
|
|
27
|
+
" ]\n" +
|
|
28
|
+
"}";
|
|
@@ -165,6 +165,7 @@ function of(...endpoints) {
|
|
|
165
165
|
function merge(...backends) {
|
|
166
166
|
const merged = of(...(0, functional_1.flattenArray)(backends.map((b) => allEndpoints(b))));
|
|
167
167
|
const apiToReasons = {};
|
|
168
|
+
const requiredRoles = new Set();
|
|
168
169
|
for (const b of backends) {
|
|
169
170
|
for (const { api, reason } of b.requiredAPIs) {
|
|
170
171
|
const reasons = apiToReasons[api] || new Set();
|
|
@@ -174,6 +175,11 @@ function merge(...backends) {
|
|
|
174
175
|
apiToReasons[api] = reasons;
|
|
175
176
|
}
|
|
176
177
|
merged.environmentVariables = { ...merged.environmentVariables, ...b.environmentVariables };
|
|
178
|
+
if (b.requiredRoles) {
|
|
179
|
+
for (const role of b.requiredRoles) {
|
|
180
|
+
requiredRoles.add(role);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
177
183
|
if (b.lifecycleHooks) {
|
|
178
184
|
merged.lifecycleHooks = { ...(merged.lifecycleHooks || {}), ...b.lifecycleHooks };
|
|
179
185
|
}
|
|
@@ -181,6 +187,9 @@ function merge(...backends) {
|
|
|
181
187
|
for (const [api, reasons] of Object.entries(apiToReasons)) {
|
|
182
188
|
merged.requiredAPIs.push({ api, reason: Array.from(reasons).join(" ") });
|
|
183
189
|
}
|
|
190
|
+
if (requiredRoles.size > 0) {
|
|
191
|
+
merged.requiredRoles = Array.from(requiredRoles);
|
|
192
|
+
}
|
|
184
193
|
return merged;
|
|
185
194
|
}
|
|
186
195
|
function isEmptyBackend(backend) {
|
|
@@ -263,6 +263,9 @@ function toBackend(build, paramValues) {
|
|
|
263
263
|
}
|
|
264
264
|
const bkend = backend.of(...bkEndpoints);
|
|
265
265
|
bkend.requiredAPIs = build.requiredAPIs;
|
|
266
|
+
if (build.requiredRoles) {
|
|
267
|
+
bkend.requiredRoles = build.requiredRoles;
|
|
268
|
+
}
|
|
266
269
|
if (build.lifecycleHooks) {
|
|
267
270
|
bkend.lifecycleHooks = build.lifecycleHooks;
|
|
268
271
|
}
|
|
@@ -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
|
+
"}";
|
|
@@ -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
|
}
|