firebase-tools 15.34.0 → 15.34.2
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/auth.js +10 -5
- package/lib/commands/apps-android-sha-create.js +1 -1
- package/lib/commands/apps-android-sha-delete.js +1 -1
- package/lib/commands/apps-android-sha-list.js +1 -1
- package/lib/commands/deploy.js +4 -0
- package/lib/commands/hosting-channel-create.js +3 -0
- package/lib/commands/hosting-channel-delete.js +3 -0
- package/lib/commands/hosting-channel-deploy.js +3 -0
- package/lib/commands/hosting-channel-list.js +3 -0
- package/lib/commands/hosting-channel-open.js +3 -0
- package/lib/commands/hosting-clone.js +14 -0
- package/lib/commands/hosting-disable.js +2 -0
- package/lib/commands/hosting-sites-create.js +3 -0
- package/lib/commands/hosting-sites-delete.js +3 -0
- package/lib/commands/hosting-sites-get.js +3 -0
- package/lib/commands/hosting-sites-list.js +3 -0
- package/lib/commands/index.js +2 -4
- package/lib/commands/run-services-update.js +2 -0
- package/lib/crashlytics/alerts.js +1 -11
- package/lib/crashlytics/onboarding.js +15 -19
- package/lib/deploy/functions/params.js +1 -0
- package/lib/deploy/functions/release/fabricator.js +6 -3
- package/lib/deploy/hosting/prepare.js +3 -0
- package/lib/deploy/run/deploy.js +36 -8
- package/lib/deploy/run/prepare.js +54 -2
- package/lib/deploy/run/update.js +2 -1
- package/lib/deploy/run/util.js +2 -0
- package/lib/emulator/auth/cloudFunctions.js +47 -18
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/firestoreEmulator.js +5 -0
- package/lib/emulator/functionsEmulator.js +22 -7
- package/lib/emulator/pubsubEmulator.js +64 -11
- package/lib/emulator/storage/rules/manager.js +31 -15
- package/lib/emulator/taskQueue.js +5 -4
- package/lib/experiments.js +0 -10
- package/lib/extensions/emulator/specHelper.js +0 -4
- package/lib/extensions/extensionsHelper.js +0 -49
- package/lib/extensions/runtimes/common.js +0 -12
- package/lib/extensions/updateHelper.js +2 -88
- package/lib/frameworks/angular/utils.js +3 -2
- package/lib/gcp/cloudlogging.js +0 -54
- package/lib/init/features/aitools/promptUpdater.js +3 -2
- package/lib/init/features/run.js +40 -1
- package/lib/mcp/errors.js +1 -1
- package/lib/mcp/index.js +19 -3
- package/lib/mcp/util/dataconnect/converter.js +0 -29
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +15 -5
- package/lib/apphosting/repo.js +0 -243
package/lib/auth.js
CHANGED
|
@@ -30,7 +30,6 @@ const http = require("http");
|
|
|
30
30
|
const jwt = require("jsonwebtoken");
|
|
31
31
|
const opn = require("open");
|
|
32
32
|
const portfinder = require("portfinder");
|
|
33
|
-
const url = require("url");
|
|
34
33
|
const apiv2 = require("./apiv2");
|
|
35
34
|
const configstore_1 = require("./configstore");
|
|
36
35
|
const error_1 = require("./error");
|
|
@@ -415,10 +414,16 @@ async function loginWithLocalhostGitHub(port) {
|
|
|
415
414
|
async function loginWithLocalhost(port, callbackUrl, authUrl, successHtml, getTokens) {
|
|
416
415
|
return new Promise((resolve, reject) => {
|
|
417
416
|
const server = http.createServer(async (req, res) => {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
417
|
+
let searchParams;
|
|
418
|
+
try {
|
|
419
|
+
searchParams = new URL(req.url || "", callbackUrl).searchParams;
|
|
420
|
+
}
|
|
421
|
+
catch {
|
|
422
|
+
searchParams = new URLSearchParams();
|
|
423
|
+
}
|
|
424
|
+
const queryState = searchParams.get("state");
|
|
425
|
+
const queryCode = searchParams.get("code");
|
|
426
|
+
if (queryState !== _nonce || !queryCode) {
|
|
422
427
|
const html = await (0, templates_1.readTemplate)("loginFailure.html");
|
|
423
428
|
respondHtml(req, res, 400, html);
|
|
424
429
|
reject(new error_1.FirebaseError("Unexpected error while logging in"));
|
|
@@ -19,7 +19,7 @@ function getCertHashType(shaHash) {
|
|
|
19
19
|
exports.command = new command_1.Command("apps:android:sha:create <appId> <shaHash>")
|
|
20
20
|
.description("add a SHA certificate hash for a given app id")
|
|
21
21
|
.before(requireAuth_1.requireAuth)
|
|
22
|
-
.action(async (appId
|
|
22
|
+
.action(async (appId, shaHash, options) => {
|
|
23
23
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
24
24
|
const shaCertificate = await (0, utils_1.promiseWithSpinner)(async () => await (0, apps_1.createAppAndroidSha)(projectId, appId, {
|
|
25
25
|
shaHash: shaHash,
|
|
@@ -10,7 +10,7 @@ const utils_1 = require("../utils");
|
|
|
10
10
|
exports.command = new command_1.Command("apps:android:sha:delete <appId> <shaId>")
|
|
11
11
|
.description("delete a SHA certificate hash for a given app id")
|
|
12
12
|
.before(requireAuth_1.requireAuth)
|
|
13
|
-
.action(async (appId
|
|
13
|
+
.action(async (appId, shaId, options) => {
|
|
14
14
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
15
15
|
await (0, utils_1.promiseWithSpinner)(async () => await (0, apps_1.deleteAppAndroidSha)(projectId, appId, shaId), `Deleting Android SHA certificate hash with SHA id ${clc.bold(shaId)} and Android app Id ${clc.bold(appId)}`);
|
|
16
16
|
});
|
|
@@ -33,7 +33,7 @@ function logCertificatesCount(count = 0) {
|
|
|
33
33
|
exports.command = new command_1.Command("apps:android:sha:list <appId>")
|
|
34
34
|
.description("list the SHA certificate hashes for a given app id")
|
|
35
35
|
.before(requireAuth_1.requireAuth)
|
|
36
|
-
.action(async (appId
|
|
36
|
+
.action(async (appId, options) => {
|
|
37
37
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
38
38
|
const shaCertificates = await (0, utils_1.promiseWithSpinner)(async () => await (0, apps_1.listAppAndroidSha)(projectId, appId), "Preparing the list of your Firebase Android app SHA certificate hashes");
|
|
39
39
|
logCertificatesList(shaCertificates);
|
package/lib/commands/deploy.js
CHANGED
|
@@ -16,6 +16,9 @@ const colorette_1 = require("colorette");
|
|
|
16
16
|
const interactive_1 = require("../hosting/interactive");
|
|
17
17
|
const utils_1 = require("../utils");
|
|
18
18
|
const api_1 = require("../hosting/api");
|
|
19
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
20
|
+
const api_2 = require("../api");
|
|
21
|
+
const projectUtils_1 = require("../projectUtils");
|
|
19
22
|
const experiments = require("../experiments");
|
|
20
23
|
const clc = require("colorette");
|
|
21
24
|
function getDeployHelp() {
|
|
@@ -85,6 +88,7 @@ exports.command
|
|
|
85
88
|
await (0, requireDatabaseInstance_1.requireDatabaseInstance)(options);
|
|
86
89
|
}
|
|
87
90
|
if (options.filteredTargets.includes("hosting")) {
|
|
91
|
+
await (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true);
|
|
88
92
|
let shouldCreateSite = false;
|
|
89
93
|
try {
|
|
90
94
|
await (0, requireHostingSite_1.requireHostingSite)(options);
|
|
@@ -15,6 +15,8 @@ const requireConfig_1 = require("../requireConfig");
|
|
|
15
15
|
const marked_1 = require("marked");
|
|
16
16
|
const requireHostingSite_1 = require("../requireHostingSite");
|
|
17
17
|
const getDefaultHostingSite_1 = require("../getDefaultHostingSite");
|
|
18
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
19
|
+
const api_2 = require("../api");
|
|
18
20
|
const LOG_TAG = "hosting:channel";
|
|
19
21
|
exports.command = new command_1.Command("hosting:channel:create [channelId]")
|
|
20
22
|
.description("create a Firebase Hosting channel")
|
|
@@ -22,6 +24,7 @@ exports.command = new command_1.Command("hosting:channel:create [channelId]")
|
|
|
22
24
|
.option("--site <siteId>", "site for which to create the channel")
|
|
23
25
|
.before(requireConfig_1.requireConfig)
|
|
24
26
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
|
|
27
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
|
|
25
28
|
.before(async (options) => {
|
|
26
29
|
try {
|
|
27
30
|
await (0, requireHostingSite_1.requireHostingSite)(options);
|
|
@@ -12,12 +12,15 @@ const requirePermissions_1 = require("../requirePermissions");
|
|
|
12
12
|
const projectUtils_1 = require("../projectUtils");
|
|
13
13
|
const requireConfig_1 = require("../requireConfig");
|
|
14
14
|
const logger_1 = require("../logger");
|
|
15
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
16
|
+
const api_2 = require("../api");
|
|
15
17
|
exports.command = new command_1.Command("hosting:channel:delete <channelId>")
|
|
16
18
|
.description("delete a Firebase Hosting channel")
|
|
17
19
|
.withForce()
|
|
18
20
|
.option("--site <siteId>", "site in which the channel exists")
|
|
19
21
|
.before(requireConfig_1.requireConfig)
|
|
20
22
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
|
|
23
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
|
|
21
24
|
.before(requireHostingSite_1.requireHostingSite)
|
|
22
25
|
.action(async (channelId, options) => {
|
|
23
26
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
@@ -16,6 +16,8 @@ const utils_1 = require("../utils");
|
|
|
16
16
|
const config_1 = require("../hosting/config");
|
|
17
17
|
const marked_1 = require("marked");
|
|
18
18
|
const requireHostingSite_1 = require("../requireHostingSite");
|
|
19
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
20
|
+
const api_2 = require("../api");
|
|
19
21
|
const LOG_TAG = "hosting:channel";
|
|
20
22
|
exports.command = new command_1.Command("hosting:channel:deploy [channelId]")
|
|
21
23
|
.description("deploy to a specific Firebase Hosting channel")
|
|
@@ -25,6 +27,7 @@ exports.command = new command_1.Command("hosting:channel:deploy [channelId]")
|
|
|
25
27
|
.option("--no-authorized-domains", "do not sync channel domains with Firebase Auth")
|
|
26
28
|
.before(requireConfig_1.requireConfig)
|
|
27
29
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
|
|
30
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
|
|
28
31
|
.before(requireHostingSite_1.requireHostingSite)
|
|
29
32
|
.action(hostingChannelDeployAction);
|
|
30
33
|
async function hostingChannelDeployAction(channelId, options) {
|
|
@@ -11,12 +11,15 @@ const logger_1 = require("../logger");
|
|
|
11
11
|
const requireConfig_1 = require("../requireConfig");
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
13
|
const requireHostingSite_1 = require("../requireHostingSite");
|
|
14
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
15
|
+
const api_2 = require("../api");
|
|
14
16
|
const TABLE_HEAD = ["Channel ID", "Last Release Time", "URL", "Expire Time"];
|
|
15
17
|
exports.command = new command_1.Command("hosting:channel:list")
|
|
16
18
|
.description("list all Firebase Hosting channels for your project")
|
|
17
19
|
.option("--site <siteName>", "list channels for the specified site")
|
|
18
20
|
.before(requireConfig_1.requireConfig)
|
|
19
21
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
|
|
22
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
|
|
20
23
|
.before(requireHostingSite_1.requireHostingSite)
|
|
21
24
|
.action(async (options) => {
|
|
22
25
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
@@ -13,12 +13,15 @@ const requireConfig_1 = require("../requireConfig");
|
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
14
|
const requireHostingSite_1 = require("../requireHostingSite");
|
|
15
15
|
const prompt_1 = require("../prompt");
|
|
16
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
17
|
+
const api_2 = require("../api");
|
|
16
18
|
exports.command = new command_1.Command("hosting:channel:open [channelId]")
|
|
17
19
|
.description("opens the URL for a Firebase Hosting channel")
|
|
18
20
|
.help("if unable to open the URL in a browser, it will be displayed in the output")
|
|
19
21
|
.option("--site <siteId>", "the site to which the channel belongs")
|
|
20
22
|
.before(requireConfig_1.requireConfig)
|
|
21
23
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.get"])
|
|
24
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
|
|
22
25
|
.before(requireHostingSite_1.requireHostingSite)
|
|
23
26
|
.action(async (channelId, options) => {
|
|
24
27
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
@@ -10,6 +10,8 @@ const utils = require("../utils");
|
|
|
10
10
|
const requireAuth_1 = require("../requireAuth");
|
|
11
11
|
const logger_1 = require("../logger");
|
|
12
12
|
const projectUtils_1 = require("../projectUtils");
|
|
13
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
14
|
+
const api_2 = require("../api");
|
|
13
15
|
exports.command = new command_1.Command("hosting:clone <source> <targetChannel>")
|
|
14
16
|
.description("clone a version from one site to another")
|
|
15
17
|
.help(`<source> and <targetChannel> accept the following formats:
|
|
@@ -70,10 +72,22 @@ To clone across different Firebase projects:
|
|
|
70
72
|
if (!targetSiteId || !targetChannelId) {
|
|
71
73
|
throw new error_1.FirebaseError(`"${targetChannel}" is not a valid target channel. Must be in the form "[<project>:]<site>:<channel>" (to clone to the active website, use "live" as the channel).`);
|
|
72
74
|
}
|
|
75
|
+
const defaultProjectId = !sourceProjectId || !targetProjectId ? (0, projectUtils_1.getProjectId)(options) : undefined;
|
|
76
|
+
if (defaultProjectId) {
|
|
77
|
+
await (0, ensureApiEnabled_1.ensure)(defaultProjectId, (0, api_2.hostingApiOrigin)(), "hosting", true);
|
|
78
|
+
}
|
|
73
79
|
[sourceProjectId, targetProjectId] = await Promise.all([
|
|
74
80
|
resolveProjectId(sourceSiteId, sourceProjectId, options),
|
|
75
81
|
resolveProjectId(targetSiteId, targetProjectId, options),
|
|
76
82
|
]);
|
|
83
|
+
const ensurePromises = [];
|
|
84
|
+
if (sourceProjectId !== defaultProjectId) {
|
|
85
|
+
ensurePromises.push((0, ensureApiEnabled_1.ensure)(sourceProjectId, (0, api_2.hostingApiOrigin)(), "hosting", true));
|
|
86
|
+
}
|
|
87
|
+
if (targetProjectId !== defaultProjectId && targetProjectId !== sourceProjectId) {
|
|
88
|
+
ensurePromises.push((0, ensureApiEnabled_1.ensure)(targetProjectId, (0, api_2.hostingApiOrigin)(), "hosting", true));
|
|
89
|
+
}
|
|
90
|
+
await Promise.all(ensurePromises);
|
|
77
91
|
targetChannelId = (0, api_1.normalizeName)(targetChannelId);
|
|
78
92
|
if (sourceChannelId) {
|
|
79
93
|
sourceChannelId = (0, api_1.normalizeName)(sourceChannelId);
|
|
@@ -10,11 +10,13 @@ const requireHostingSite_1 = require("../requireHostingSite");
|
|
|
10
10
|
const requirePermissions_1 = require("../requirePermissions");
|
|
11
11
|
const projectUtils_1 = require("../projectUtils");
|
|
12
12
|
const utils = require("../utils");
|
|
13
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
13
14
|
exports.command = new command_1.Command("hosting:disable")
|
|
14
15
|
.description("stop serving web traffic to your Firebase Hosting site")
|
|
15
16
|
.option("-f, --force", "skip confirmation")
|
|
16
17
|
.option("-s, --site <siteName>", "the site to disable")
|
|
17
18
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
|
|
19
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_1.hostingApiOrigin)(), "hosting", true))
|
|
18
20
|
.before(requireHostingSite_1.requireHostingSite)
|
|
19
21
|
.action(async (options) => {
|
|
20
22
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
@@ -10,11 +10,14 @@ const projectUtils_1 = require("../projectUtils");
|
|
|
10
10
|
const requirePermissions_1 = require("../requirePermissions");
|
|
11
11
|
const api_1 = require("../hosting/api");
|
|
12
12
|
const error_1 = require("../error");
|
|
13
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
14
|
+
const api_2 = require("../api");
|
|
13
15
|
const LOG_TAG = "hosting:sites";
|
|
14
16
|
exports.command = new command_1.Command("hosting:sites:create [siteId]")
|
|
15
17
|
.description("create a Firebase Hosting site")
|
|
16
18
|
.option("--app <appId>", "specify an existing Firebase Web App ID")
|
|
17
19
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
|
|
20
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
|
|
18
21
|
.action(async (siteId, options) => {
|
|
19
22
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
20
23
|
const appId = options.app;
|
|
@@ -11,12 +11,15 @@ const requirePermissions_1 = require("../requirePermissions");
|
|
|
11
11
|
const projectUtils_1 = require("../projectUtils");
|
|
12
12
|
const requireConfig_1 = require("../requireConfig");
|
|
13
13
|
const logger_1 = require("../logger");
|
|
14
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
15
|
+
const api_2 = require("../api");
|
|
14
16
|
const LOG_TAG = "hosting:sites";
|
|
15
17
|
exports.command = new command_1.Command("hosting:sites:delete <siteId>")
|
|
16
18
|
.description("delete a Firebase Hosting site")
|
|
17
19
|
.withForce()
|
|
18
20
|
.before(requireConfig_1.requireConfig)
|
|
19
21
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.delete"])
|
|
22
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
|
|
20
23
|
.action(async (siteId, options) => {
|
|
21
24
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
22
25
|
if (!siteId) {
|
|
@@ -8,9 +8,12 @@ const requirePermissions_1 = require("../requirePermissions");
|
|
|
8
8
|
const projectUtils_1 = require("../projectUtils");
|
|
9
9
|
const logger_1 = require("../logger");
|
|
10
10
|
const error_1 = require("../error");
|
|
11
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
12
|
+
const api_2 = require("../api");
|
|
11
13
|
exports.command = new command_1.Command("hosting:sites:get <siteId>")
|
|
12
14
|
.description("print info about a Firebase Hosting site")
|
|
13
15
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.get"])
|
|
16
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
|
|
14
17
|
.action(async (siteId, options) => {
|
|
15
18
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
19
|
if (!siteId) {
|
|
@@ -8,10 +8,13 @@ const api_1 = require("../hosting/api");
|
|
|
8
8
|
const requirePermissions_1 = require("../requirePermissions");
|
|
9
9
|
const projectUtils_1 = require("../projectUtils");
|
|
10
10
|
const logger_1 = require("../logger");
|
|
11
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
12
|
+
const api_2 = require("../api");
|
|
11
13
|
const TABLE_HEAD = ["Site ID", "Default URL", "App ID (if set)"];
|
|
12
14
|
exports.command = new command_1.Command("hosting:sites:list")
|
|
13
15
|
.description("list Firebase Hosting sites")
|
|
14
16
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.get"])
|
|
17
|
+
.before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
|
|
15
18
|
.action(async (options) => {
|
|
16
19
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
17
20
|
const sites = await (0, api_1.listSites)(projectId);
|
package/lib/commands/index.js
CHANGED
|
@@ -76,10 +76,8 @@ function load(client) {
|
|
|
76
76
|
client.crashlytics.mappingfile = {};
|
|
77
77
|
client.crashlytics.mappingfile.generateid = loadCommand("crashlytics-mappingfile-generateid");
|
|
78
78
|
client.crashlytics.mappingfile.upload = loadCommand("crashlytics-mappingfile-upload");
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
client.crashlytics.sourcemap.upload = loadCommand("crashlytics-sourcemap-upload");
|
|
82
|
-
}
|
|
79
|
+
client.crashlytics.sourcemap = {};
|
|
80
|
+
client.crashlytics.sourcemap.upload = loadCommand("crashlytics-sourcemap-upload");
|
|
83
81
|
client.crashlytics.heapdumps = {};
|
|
84
82
|
client.crashlytics.heapdumps.enable = loadCommand("crashlytics-heapdumps-enable");
|
|
85
83
|
client.crashlytics.heapdumps.disable = loadCommand("crashlytics-heapdumps-disable");
|
|
@@ -11,6 +11,8 @@ exports.command = new command_1.Command("run:services:update <serviceId>")
|
|
|
11
11
|
.option("--region <region>", "the service's region, if firebase.json lists the service ID in more than one region")
|
|
12
12
|
.option("--base-image <baseImage>", "set the base image (e.g. nodejs22) and enable automatic base image updates")
|
|
13
13
|
.option("--clear-base-image", "clear the base image and disable automatic base image updates")
|
|
14
|
+
.option("--app <appId>", "associate a Firebase Web App ID for SDK auto-initialization")
|
|
15
|
+
.option("--clear-app", "disassociate the Firebase Web App and disable SDK auto-initialization")
|
|
14
16
|
.before(requireConfig_1.requireConfig)
|
|
15
17
|
.before(requirePermissions_1.requirePermissions, deploy_1.TARGET_PERMISSIONS.run)
|
|
16
18
|
.action((serviceId, options) => (0, update_1.updateService)(serviceId, options.region, options));
|
|
@@ -103,20 +103,10 @@ async function enableAlerts(projectId, appId, alertTypes, userEmail) {
|
|
|
103
103
|
exit: 1,
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
return await Promise.all(alertTypes.map(async (alertType) => {
|
|
107
107
|
const { policy } = await enableAlert(projectId, appId, alertType, {
|
|
108
108
|
channelName,
|
|
109
109
|
});
|
|
110
110
|
return policy;
|
|
111
111
|
}));
|
|
112
|
-
const policies = [];
|
|
113
|
-
for (const res of results) {
|
|
114
|
-
if (res.status === "fulfilled") {
|
|
115
|
-
policies.push(res.value);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
logger_1.logger.debug(`[crashlytics] Failed to enable alert: ${(0, error_1.getErrMsg)(res.reason)}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return policies;
|
|
122
112
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CRASHLYTICS_TELEMETRY_SERVICE = exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE = exports.CRASHLYTICS_TELEMETRY_SINK_ID = exports.CRASHLYTICS_TELEMETRY_BUCKET_ID = void 0;
|
|
3
|
+
exports.CLIENT_TELEMETRY_SERVICE = exports.CRASHLYTICS_SERVICE = exports.CRASHLYTICS_TELEMETRY_ADMIN_SERVICE = exports.CRASHLYTICS_TELEMETRY_SERVICE = exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE = exports.CRASHLYTICS_TELEMETRY_SINK_ID = exports.CRASHLYTICS_TELEMETRY_BUCKET_ID = void 0;
|
|
4
4
|
exports.onboardCrashlyticsWeb = onboardCrashlyticsWeb;
|
|
5
5
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const experiments = require("../experiments");
|
|
8
8
|
const cloudbilling_1 = require("../gcp/cloudbilling");
|
|
9
|
-
const cloudlogging_1 = require("../gcp/cloudlogging");
|
|
10
9
|
const alerts_1 = require("./alerts");
|
|
11
10
|
const firebasetelemetry_1 = require("./firebasetelemetry");
|
|
12
11
|
const types_1 = require("./types");
|
|
@@ -21,6 +20,9 @@ exports.CRASHLYTICS_TELEMETRY_BUCKET_ID = "firebase-telemetry";
|
|
|
21
20
|
exports.CRASHLYTICS_TELEMETRY_SINK_ID = "firebase-telemetry-routing";
|
|
22
21
|
exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE = "firebasetelemetry.googleapis.com/App";
|
|
23
22
|
exports.CRASHLYTICS_TELEMETRY_SERVICE = "firebasetelemetry.googleapis.com";
|
|
23
|
+
exports.CRASHLYTICS_TELEMETRY_ADMIN_SERVICE = "firebasetelemetryadmin.googleapis.com";
|
|
24
|
+
exports.CRASHLYTICS_SERVICE = "firebasecrashlytics.googleapis.com";
|
|
25
|
+
exports.CLIENT_TELEMETRY_SERVICE = "clienttelemetry.googleapis.com";
|
|
24
26
|
async function resolveAuthenticatedUserEmail(options) {
|
|
25
27
|
if (options.user?.email) {
|
|
26
28
|
return options.user.email;
|
|
@@ -45,7 +47,9 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
45
47
|
(0, utils_1.logLabeledBullet)("crashlytics", "Enabling required telemetry APIs...");
|
|
46
48
|
const requiredApis = [
|
|
47
49
|
(0, ensureApiEnabled_1.ensure)(projectId, exports.CRASHLYTICS_TELEMETRY_SERVICE, "crashlytics", false),
|
|
48
|
-
(0, ensureApiEnabled_1.ensure)(projectId,
|
|
50
|
+
(0, ensureApiEnabled_1.ensure)(projectId, exports.CRASHLYTICS_TELEMETRY_ADMIN_SERVICE, "crashlytics", false),
|
|
51
|
+
(0, ensureApiEnabled_1.ensure)(projectId, exports.CRASHLYTICS_SERVICE, "crashlytics", false),
|
|
52
|
+
(0, ensureApiEnabled_1.ensure)(projectId, exports.CLIENT_TELEMETRY_SERVICE, "crashlytics", false),
|
|
49
53
|
];
|
|
50
54
|
if (experiments.isEnabled("crashlyticsWebBreadcrumbs")) {
|
|
51
55
|
requiredApis.push((0, ensureApiEnabled_1.ensure)(projectId, "cloudtrace.googleapis.com", "crashlytics", false));
|
|
@@ -58,7 +62,7 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
58
62
|
try {
|
|
59
63
|
await (0, apikeys_1.updateAppApiKeyRestriction)({
|
|
60
64
|
apiKey: appConfig.apiKey,
|
|
61
|
-
service: exports.
|
|
65
|
+
service: exports.CLIENT_TELEMETRY_SERVICE,
|
|
62
66
|
});
|
|
63
67
|
(0, utils_1.logLabeledSuccess)("crashlytics", "API key restrictions updated for Crashlytics Telemetry.");
|
|
64
68
|
}
|
|
@@ -68,16 +72,8 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
68
72
|
}
|
|
69
73
|
else {
|
|
70
74
|
(0, utils_1.logLabeledWarning)("crashlytics", `No API key found for this app. If you configure an API key later, ` +
|
|
71
|
-
`please rerun this command or manually add '${exports.
|
|
75
|
+
`please rerun this command or manually add '${exports.CLIENT_TELEMETRY_SERVICE}' to its allowed APIs in the Google Cloud Console if the key is restricted.`);
|
|
72
76
|
}
|
|
73
|
-
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Cloud Logging bucket '${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}'...`);
|
|
74
|
-
const bucket = await (0, cloudlogging_1.createOrUpdateLogBucket)(projectId, exports.CRASHLYTICS_TELEMETRY_BUCKET_ID, "global", true);
|
|
75
|
-
(0, utils_1.logLabeledSuccess)("crashlytics", "Cloud Logging bucket configured.");
|
|
76
|
-
const destination = `logging.googleapis.com/projects/${projectId}/locations/global/buckets/${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}`;
|
|
77
|
-
const filter = `resource.type="${exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE}"`;
|
|
78
|
-
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Cloud Logging routing sink '${exports.CRASHLYTICS_TELEMETRY_SINK_ID}'...`);
|
|
79
|
-
const sink = await (0, cloudlogging_1.createOrUpdateLogSink)(projectId, exports.CRASHLYTICS_TELEMETRY_SINK_ID, destination, filter);
|
|
80
|
-
(0, utils_1.logLabeledSuccess)("crashlytics", "Cloud Logging routing sink configured.");
|
|
81
77
|
if (experiments.isEnabled("crashlyticsWebBreadcrumbs")) {
|
|
82
78
|
(0, utils_1.logLabeledBullet)("crashlytics", "Provisioning Cloud Trace storage...");
|
|
83
79
|
try {
|
|
@@ -91,13 +87,13 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
91
87
|
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring Crashlytics telemetry for web app...");
|
|
92
88
|
const config = await (0, firebasetelemetry_1.createOrUpdateTelemetryConfig)(projectId, appId, `projects/${projectId}/locations/global/buckets/${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}`, 1);
|
|
93
89
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Crashlytics telemetry configured successfully.");
|
|
94
|
-
if (
|
|
95
|
-
return {
|
|
90
|
+
if (options.nonInteractive) {
|
|
91
|
+
return { config };
|
|
96
92
|
}
|
|
97
93
|
const userEmail = await resolveAuthenticatedUserEmail(options);
|
|
98
94
|
if (!userEmail) {
|
|
99
95
|
(0, utils_1.logLabeledWarning)("crashlytics", "Unable to determine authenticated user email for alert setup. You can configure alerts later in the Firebase Console.");
|
|
100
|
-
return {
|
|
96
|
+
return { config };
|
|
101
97
|
}
|
|
102
98
|
const selectedAlerts = await (0, prompt_1.checkbox)({
|
|
103
99
|
message: "Which email alerts would you like to enable? (Optional)",
|
|
@@ -115,16 +111,16 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
115
111
|
],
|
|
116
112
|
});
|
|
117
113
|
if (selectedAlerts.length === 0) {
|
|
118
|
-
return {
|
|
114
|
+
return { config };
|
|
119
115
|
}
|
|
120
116
|
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Crashlytics email alerts for ${userEmail}...`);
|
|
121
117
|
try {
|
|
122
118
|
const alertPolicies = await (0, alerts_1.enableAlerts)(projectId, appId, selectedAlerts, userEmail);
|
|
123
119
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Crashlytics email alerts configured successfully.");
|
|
124
|
-
return {
|
|
120
|
+
return { config, alertPolicies };
|
|
125
121
|
}
|
|
126
122
|
catch (err) {
|
|
127
123
|
(0, utils_1.logLabeledWarning)("crashlytics", (0, error_1.getErrMsg)(err));
|
|
128
|
-
return {
|
|
124
|
+
return { config };
|
|
129
125
|
}
|
|
130
126
|
}
|
|
@@ -251,6 +251,7 @@ async function ensureSecret(secretParam, projectId, nonInteractive) {
|
|
|
251
251
|
const promptMessage = `Enter ${secretParam.format === "json" ? "a JSON value" : "a value"} for ${label}:`;
|
|
252
252
|
const secretValue = await (0, prompt_1.password)({
|
|
253
253
|
message: promptMessage,
|
|
254
|
+
validate: (val) => (val !== "" ? true : "Secrets cannot have an empty value."),
|
|
254
255
|
});
|
|
255
256
|
if (secretParam.format === "json") {
|
|
256
257
|
(0, secrets_1.validateJsonSecret)(secretParam.name, secretValue);
|
|
@@ -578,8 +578,9 @@ class Fabricator {
|
|
|
578
578
|
invoker = ["public"];
|
|
579
579
|
}
|
|
580
580
|
if (invoker) {
|
|
581
|
+
const invokerUpdate = invoker;
|
|
581
582
|
await this.executor
|
|
582
|
-
.run(() => gcf.setInvokerUpdate(endpoint.project, backend.functionName(endpoint),
|
|
583
|
+
.run(() => gcf.setInvokerUpdate(endpoint.project, backend.functionName(endpoint), invokerUpdate))
|
|
583
584
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
584
585
|
}
|
|
585
586
|
}
|
|
@@ -653,8 +654,9 @@ class Fabricator {
|
|
|
653
654
|
: [await gce.getDefaultServiceAccount(this.projectNumber)];
|
|
654
655
|
}
|
|
655
656
|
if (invoker) {
|
|
657
|
+
const invokerUpdate = invoker;
|
|
656
658
|
await this.executor
|
|
657
|
-
.run(() => run.setInvokerUpdate(endpoint.project, serviceName,
|
|
659
|
+
.run(() => run.setInvokerUpdate(endpoint.project, serviceName, invokerUpdate))
|
|
658
660
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
659
661
|
}
|
|
660
662
|
}
|
|
@@ -758,8 +760,9 @@ class Fabricator {
|
|
|
758
760
|
invoker = endpoint.httpsTrigger.invoker === null ? ["public"] : endpoint.httpsTrigger.invoker;
|
|
759
761
|
}
|
|
760
762
|
if (invoker) {
|
|
763
|
+
const invokerUpdate = invoker;
|
|
761
764
|
await this.executor
|
|
762
|
-
.run(() => run.setInvokerUpdate(endpoint.project, serviceName,
|
|
765
|
+
.run(() => run.setInvokerUpdate(endpoint.project, serviceName, invokerUpdate))
|
|
763
766
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
764
767
|
}
|
|
765
768
|
}
|
|
@@ -15,6 +15,8 @@ const utils = require("../../utils");
|
|
|
15
15
|
const backend = require("../functions/backend");
|
|
16
16
|
const ensureTargeted_1 = require("../../functions/ensureTargeted");
|
|
17
17
|
const frameworks_1 = require("../../frameworks");
|
|
18
|
+
const ensureApiEnabled_1 = require("../../ensureApiEnabled");
|
|
19
|
+
const api_1 = require("../../api");
|
|
18
20
|
function handlePublicDirectoryFlag(options) {
|
|
19
21
|
if (options.public) {
|
|
20
22
|
if (Array.isArray(options.config.get("hosting"))) {
|
|
@@ -73,6 +75,7 @@ async function prepare(context, options) {
|
|
|
73
75
|
if (configs.length === 0) {
|
|
74
76
|
return Promise.resolve();
|
|
75
77
|
}
|
|
78
|
+
await (0, ensureApiEnabled_1.ensure)(context.projectId, (0, api_1.hostingApiOrigin)(), "hosting", true);
|
|
76
79
|
const versions = await Promise.all(configs.map(async (config) => {
|
|
77
80
|
await api.getSite(context.projectId, config.site);
|
|
78
81
|
const labels = {
|
package/lib/deploy/run/deploy.js
CHANGED
|
@@ -144,6 +144,14 @@ function revisionTemplate(svc, image, message) {
|
|
|
144
144
|
else {
|
|
145
145
|
delete container.baseImageUri;
|
|
146
146
|
}
|
|
147
|
+
const wasLinked = svc.existing?.annotations?.[util_2.FIREBASE_APP_ANNOTATION] !== undefined;
|
|
148
|
+
const otherEnv = (container.env || []).filter((e) => e.name !== "FIREBASE_CONFIG");
|
|
149
|
+
if (svc.autoInit) {
|
|
150
|
+
container.env = [...otherEnv, { name: "FIREBASE_CONFIG", value: svc.autoInit.firebaseConfig }];
|
|
151
|
+
}
|
|
152
|
+
else if (wasLinked) {
|
|
153
|
+
container.env = otherEnv;
|
|
154
|
+
}
|
|
147
155
|
if (message) {
|
|
148
156
|
template.annotations = { ...template.annotations, [DEPLOY_MESSAGE_ANNOTATION]: message };
|
|
149
157
|
}
|
|
@@ -170,31 +178,51 @@ function localBuildTemplate(svc, build, builtApp, message) {
|
|
|
170
178
|
}
|
|
171
179
|
return template;
|
|
172
180
|
}
|
|
181
|
+
function serviceAnnotationsToDeploy(svc) {
|
|
182
|
+
const annotations = { ...svc.existing?.annotations };
|
|
183
|
+
if (svc.autoInit) {
|
|
184
|
+
annotations[util_2.FIREBASE_APP_ANNOTATION] = svc.autoInit.appId;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
delete annotations[util_2.FIREBASE_APP_ANNOTATION];
|
|
188
|
+
}
|
|
189
|
+
return annotations;
|
|
190
|
+
}
|
|
173
191
|
function rollOut(projectId, svc, template) {
|
|
192
|
+
const annotations = serviceAnnotationsToDeploy(svc);
|
|
174
193
|
if (svc.existing) {
|
|
175
|
-
return deployRevision(svc.existing, template);
|
|
194
|
+
return deployRevision(svc.existing, template, annotations);
|
|
176
195
|
}
|
|
177
|
-
return createNewService(projectId, svc.config, template);
|
|
196
|
+
return createNewService(projectId, svc.config, template, annotations);
|
|
178
197
|
}
|
|
179
|
-
function createNewService(projectId, config, template) {
|
|
198
|
+
function createNewService(projectId, config, template, annotations) {
|
|
180
199
|
const { serviceId, region } = config;
|
|
181
|
-
|
|
200
|
+
const service = {
|
|
182
201
|
name: `projects/${projectId}/locations/${region}/services/${serviceId}`,
|
|
202
|
+
annotations,
|
|
183
203
|
template,
|
|
184
204
|
client: "cli-firebase",
|
|
185
205
|
invokerIamDisabled: true,
|
|
186
206
|
ingress: "INGRESS_TRAFFIC_ALL",
|
|
187
|
-
}
|
|
207
|
+
};
|
|
208
|
+
return runv2.createService(projectId, region, serviceId, service, {
|
|
209
|
+
pollTimeoutMs: ROLLOUT_TIMEOUT_MS,
|
|
210
|
+
});
|
|
188
211
|
}
|
|
189
|
-
function deployRevision(service, template) {
|
|
212
|
+
function deployRevision(service, template, annotations) {
|
|
190
213
|
const tags = (service.traffic || [])
|
|
191
214
|
.filter((t) => t.tag)
|
|
192
215
|
.map((t) => ({ type: t.type, revision: t.revision, tag: t.tag }));
|
|
193
|
-
|
|
216
|
+
const update = {
|
|
194
217
|
name: service.name,
|
|
218
|
+
annotations,
|
|
195
219
|
template,
|
|
196
220
|
traffic: [{ type: "TRAFFIC_TARGET_ALLOCATION_TYPE_LATEST", percent: 100 }, ...tags],
|
|
197
|
-
}
|
|
221
|
+
};
|
|
222
|
+
return runv2.updateService(update, {
|
|
223
|
+
updateMask: ["template", "traffic", "annotations"],
|
|
224
|
+
pollTimeoutMs: ROLLOUT_TIMEOUT_MS,
|
|
225
|
+
});
|
|
198
226
|
}
|
|
199
227
|
function toAppHostingConfig(config) {
|
|
200
228
|
return {
|