firebase-tools 15.33.0 → 15.34.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/README.md +9 -0
- package/lib/apphosting/backend.js +1 -1
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +30 -23
- package/lib/commands/crashlytics-heapdumps-disable.js +26 -0
- package/lib/commands/crashlytics-heapdumps-enable.js +54 -0
- package/lib/commands/crashlytics-heapdumps-status.js +32 -0
- package/lib/commands/deploy.js +3 -0
- package/lib/commands/hosting-clone.js +49 -9
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +7 -0
- package/lib/commands/run-services-update.js +16 -0
- package/lib/crashlytics/onboarding.js +2 -2
- package/lib/crashlytics/profilingManager.js +195 -0
- package/lib/deploy/apphosting/prepare.js +1 -0
- package/lib/deploy/auth/deploy.js +1 -1
- package/lib/deploy/auth/prepare.js +6 -7
- package/lib/deploy/firestore/prepare.js +5 -5
- package/lib/deploy/functions/release/executor.js +7 -3
- package/lib/deploy/functions/release/fabricator.js +41 -9
- package/lib/deploy/functions/release/sourceTokenScraper.js +1 -1
- package/lib/deploy/index.js +5 -0
- package/lib/deploy/run/args.js +2 -0
- package/lib/deploy/run/buildEnv.js +72 -0
- package/lib/deploy/run/deploy.js +214 -0
- package/lib/deploy/run/index.js +23 -0
- package/lib/deploy/run/prepare.js +47 -0
- package/lib/deploy/run/prereqs.js +32 -0
- package/lib/deploy/run/release.js +9 -0
- package/lib/deploy/run/update.js +50 -0
- package/lib/deploy/run/util.js +73 -0
- package/lib/emulator/apphosting/serve.js +1 -1
- package/lib/emulator/auth/utils.js +1 -1
- package/lib/emulator/commandUtils.js +7 -3
- package/lib/emulator/dataconnect/pgliteServer.js +1 -1
- package/lib/emulator/dataconnectEmulator.js +1 -1
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +1 -3
- package/lib/emulator/eventarcEmulator.js +1 -1
- package/lib/emulator/functionsEmulatorShared.js +1 -41
- package/lib/experiments.js +1 -12
- package/lib/firestore/validator.js +1 -1
- package/lib/functions/projectConfig.js +10 -5
- package/lib/gcp/cloudsql/permissions.js +21 -32
- package/lib/gcp/cloudsql/permissionsSetup.js +6 -6
- package/lib/gcp/storage.js +9 -5
- package/lib/init/features/index.js +4 -1
- package/lib/init/features/run.js +159 -0
- package/lib/init/index.js +6 -0
- package/lib/profileReport.js +8 -5
- package/lib/throttler/throttler.js +1 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +2 -8
- package/schema/firebaserc.json +133 -0
- package/lib/mcp/resources/guides/init_data_connect.js +0 -30
- package/lib/mcp/resources/guides/init_rtdb.js +0 -30
package/README.md
CHANGED
|
@@ -9,6 +9,15 @@ The Firebase Command Line Interface (CLI) Tools can be used to test, manage, and
|
|
|
9
9
|
|
|
10
10
|
To get started with the Firebase CLI, read the full list of commands below or check out the [documentation](https://firebase.google.com/docs/cli).
|
|
11
11
|
|
|
12
|
+
> [!TIP]
|
|
13
|
+
> Using an AI assistant? Install [Firebase agent skills](https://github.com/firebase/agent-skills) to give it Firebase-specific knowledge, best practices, and workflows, including how to use the Firebase CLI and MCP server effectively:
|
|
14
|
+
>
|
|
15
|
+
> ```bash
|
|
16
|
+
> npx skills add firebase/agent-skills
|
|
17
|
+
> ```
|
|
18
|
+
>
|
|
19
|
+
> See the [Firebase agent skills documentation](https://firebase.google.com/docs/ai-assistance/agent-skills) for more information.
|
|
20
|
+
|
|
12
21
|
## Installation
|
|
13
22
|
|
|
14
23
|
### Node Package
|
|
@@ -50,7 +50,7 @@ async function tlsReady(url) {
|
|
|
50
50
|
}
|
|
51
51
|
catch (err) {
|
|
52
52
|
const maybeNodeError = err;
|
|
53
|
-
if (
|
|
53
|
+
if (maybeNodeError?.cause?.code?.includes("HANDSHAKE_FAILURE") ||
|
|
54
54
|
"EPROTO" === maybeNodeError?.code) {
|
|
55
55
|
return false;
|
|
56
56
|
}
|
package/lib/command.js
CHANGED
|
@@ -21,6 +21,7 @@ const env_1 = require("./env");
|
|
|
21
21
|
const experiments = require("./experiments");
|
|
22
22
|
const warnings_1 = require("./extensions/warnings");
|
|
23
23
|
const prompt_1 = require("./prompt");
|
|
24
|
+
const logger_1 = require("./logger");
|
|
24
25
|
function isCommandModule(value) {
|
|
25
26
|
return typeof value === "function" && typeof value.load === "function";
|
|
26
27
|
}
|
|
@@ -109,22 +110,23 @@ class Command {
|
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
const duration = Math.floor((process.uptime() - start) * 1000);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
await (0, utils_1.withTimeout)(5000, Promise.all([
|
|
122
|
-
trackSuccess,
|
|
123
|
-
(0, track_1.trackEmulator)("command_success", {
|
|
113
|
+
try {
|
|
114
|
+
const trackSuccess = (0, track_1.trackGA4)("command_execution", {
|
|
115
|
+
command_name: this.name,
|
|
116
|
+
result: "success",
|
|
117
|
+
interactive: (0, utils_1.getInheritedOption)(options, "nonInteractive") ? "false" : "true",
|
|
118
|
+
}, duration);
|
|
119
|
+
const tracks = [trackSuccess];
|
|
120
|
+
if (isEmulator) {
|
|
121
|
+
tracks.push((0, track_1.trackEmulator)("command_success", {
|
|
124
122
|
command_name: this.name,
|
|
125
123
|
duration,
|
|
126
|
-
})
|
|
127
|
-
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
await (0, utils_1.withTimeout)(5000, Promise.all(tracks));
|
|
127
|
+
}
|
|
128
|
+
catch (gaErr) {
|
|
129
|
+
logger_1.logger.debug("Analytics tracking failed during success path:", gaErr);
|
|
128
130
|
}
|
|
129
131
|
process.exit();
|
|
130
132
|
})
|
|
@@ -138,20 +140,25 @@ class Command {
|
|
|
138
140
|
});
|
|
139
141
|
}
|
|
140
142
|
const duration = Math.floor((process.uptime() - start) * 1000);
|
|
141
|
-
|
|
142
|
-
(0, track_1.trackGA4)("command_execution", {
|
|
143
|
+
try {
|
|
144
|
+
const trackError = (0, track_1.trackGA4)("command_execution", {
|
|
143
145
|
command_name: this.name,
|
|
144
146
|
result: "error",
|
|
145
147
|
interactive: (0, utils_1.getInheritedOption)(options, "nonInteractive") ? "false" : "true",
|
|
146
|
-
}, duration)
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
}, duration);
|
|
149
|
+
const tracks = [trackError];
|
|
150
|
+
if (isEmulator) {
|
|
151
|
+
tracks.push((0, track_1.trackEmulator)("command_error", {
|
|
149
152
|
command_name: this.name,
|
|
150
153
|
duration,
|
|
151
|
-
error_type: err
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
error_type: err?.exit === 1 ? "user" : "unexpected",
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
await (0, utils_1.withTimeout)(5000, Promise.all(tracks));
|
|
158
|
+
}
|
|
159
|
+
catch (gaErr) {
|
|
160
|
+
logger_1.logger.debug("Analytics tracking failed during error path:", gaErr);
|
|
161
|
+
}
|
|
155
162
|
client.errorOut(err);
|
|
156
163
|
});
|
|
157
164
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const requireAuth_1 = require("../requireAuth");
|
|
9
|
+
const profilingManager_1 = require("../crashlytics/profilingManager");
|
|
10
|
+
exports.command = new command_1.Command("crashlytics:heapdumps:disable")
|
|
11
|
+
.description("disable Crashlytics heap dump collection for an Android app")
|
|
12
|
+
.option("--app <appID>", "the app id of your Firebase Android app")
|
|
13
|
+
.before(requireAuth_1.requireAuth)
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
|
+
const appId = await (0, profilingManager_1.resolveAndroidAppId)(projectId, options);
|
|
17
|
+
await (0, profilingManager_1.disableHeapDumpCollection)(appId);
|
|
18
|
+
logger_1.logger.info("");
|
|
19
|
+
logger_1.logger.info(clc.bold("Heap Dump Collection Details:"));
|
|
20
|
+
logger_1.logger.info(` App ID: ${clc.cyan(appId)}`);
|
|
21
|
+
logger_1.logger.info(` Status: ${clc.red("Disabled")}`);
|
|
22
|
+
return {
|
|
23
|
+
appId,
|
|
24
|
+
heapDumpCollectionEnabled: false,
|
|
25
|
+
};
|
|
26
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
const projectUtils_1 = require("../projectUtils");
|
|
9
|
+
const prompt_1 = require("../prompt");
|
|
10
|
+
const requireAuth_1 = require("../requireAuth");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
const cloudbilling = require("../gcp/cloudbilling");
|
|
13
|
+
const profilingManager_1 = require("../crashlytics/profilingManager");
|
|
14
|
+
exports.command = new command_1.Command("crashlytics:heapdumps:enable")
|
|
15
|
+
.description("enable Crashlytics heap dump collection for an Android app")
|
|
16
|
+
.option("--app <appID>", "the app id of your Firebase Android app")
|
|
17
|
+
.option("--location <location>", `the location for the Cloud Storage bucket (default: ${profilingManager_1.DEFAULT_BUCKET_LOCATION})`, profilingManager_1.DEFAULT_BUCKET_LOCATION)
|
|
18
|
+
.withForce("automatically configure without prompting for confirmation")
|
|
19
|
+
.before(requireAuth_1.requireAuth)
|
|
20
|
+
.action(async (options) => {
|
|
21
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
22
|
+
const appId = await (0, profilingManager_1.resolveAndroidAppId)(projectId, options);
|
|
23
|
+
const location = options.location || profilingManager_1.DEFAULT_BUCKET_LOCATION;
|
|
24
|
+
const isBillingEnabled = await cloudbilling.checkBillingEnabled(projectId);
|
|
25
|
+
if (!isBillingEnabled) {
|
|
26
|
+
throw new error_1.FirebaseError(`Project '${projectId}' is not on the Blaze (pay-as-you-go) plan. Crashlytics heap dump collection requires the Blaze plan for Google Cloud Storage.\n` +
|
|
27
|
+
`To upgrade your project, visit: ${(0, utils_1.consoleUrl)(projectId, "/usage/details")}`);
|
|
28
|
+
}
|
|
29
|
+
const bucketName = (0, profilingManager_1.createBucketName)(appId);
|
|
30
|
+
const confirmed = await (0, prompt_1.confirm)({
|
|
31
|
+
message: `Enable Crashlytics heap dump collection for ${appId} using Cloud Storage bucket '${bucketName}' in ${location} (with ${profilingManager_1.DEFAULT_FILE_TTL_DAYS}-day file TTL)?`,
|
|
32
|
+
default: true,
|
|
33
|
+
force: options.force,
|
|
34
|
+
nonInteractive: options.nonInteractive,
|
|
35
|
+
});
|
|
36
|
+
if (!confirmed) {
|
|
37
|
+
logger_1.logger.info("Heap dump collection enablement canceled.");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
await (0, profilingManager_1.enableHeapDumpCollection)(projectId, appId, location);
|
|
41
|
+
logger_1.logger.info("");
|
|
42
|
+
logger_1.logger.info(clc.bold("Heap Dump Collection Details:"));
|
|
43
|
+
logger_1.logger.info(` App ID: ${clc.cyan(appId)}`);
|
|
44
|
+
logger_1.logger.info(` GCS Bucket: ${clc.cyan(bucketName)}`);
|
|
45
|
+
logger_1.logger.info(` File TTL: ${clc.cyan(`${profilingManager_1.DEFAULT_FILE_TTL_DAYS} days`)}`);
|
|
46
|
+
logger_1.logger.info(` Status: ${clc.green("Enabled")}`);
|
|
47
|
+
logger_1.logger.info("");
|
|
48
|
+
logger_1.logger.info(`View collected heap dumps in the Firebase Console: ${(0, utils_1.consoleUrl)(projectId, `/crashlytics/app/${appId}`)}`);
|
|
49
|
+
return {
|
|
50
|
+
appId,
|
|
51
|
+
bucketName,
|
|
52
|
+
heapDumpCollectionEnabled: true,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const Table = require("cli-table3");
|
|
6
|
+
const command_1 = require("../command");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
const projectUtils_1 = require("../projectUtils");
|
|
9
|
+
const requireAuth_1 = require("../requireAuth");
|
|
10
|
+
const profilingManager_1 = require("../crashlytics/profilingManager");
|
|
11
|
+
exports.command = new command_1.Command("crashlytics:heapdumps:status")
|
|
12
|
+
.description("get Crashlytics heap dump collection status and configuration for an Android app")
|
|
13
|
+
.option("--app <appID>", "the app id of your Firebase Android app")
|
|
14
|
+
.before(requireAuth_1.requireAuth)
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
17
|
+
const appId = await (0, profilingManager_1.resolveAndroidAppId)(projectId, options);
|
|
18
|
+
const config = await (0, profilingManager_1.getProfilingManagerConfig)(appId);
|
|
19
|
+
const tableHead = ["App ID", "Collection Status", "Cloud Storage Bucket"];
|
|
20
|
+
const table = new Table({ head: tableHead, style: { head: ["green"] } });
|
|
21
|
+
table.push([
|
|
22
|
+
appId,
|
|
23
|
+
config.heapDumpCollectionEnabled ? clc.green("Enabled") : clc.red("Disabled"),
|
|
24
|
+
config.gcsBucket || clc.yellow("(none)"),
|
|
25
|
+
]);
|
|
26
|
+
logger_1.logger.info("");
|
|
27
|
+
logger_1.logger.info(table.toString());
|
|
28
|
+
return {
|
|
29
|
+
appId,
|
|
30
|
+
...config,
|
|
31
|
+
};
|
|
32
|
+
});
|
package/lib/commands/deploy.js
CHANGED
|
@@ -67,6 +67,9 @@ exports.command
|
|
|
67
67
|
if (options.filteredTargets.includes("ailogic")) {
|
|
68
68
|
experiments.assertEnabled("ailogic", "deploy AI Logic resources");
|
|
69
69
|
}
|
|
70
|
+
if (options.filteredTargets.includes("run")) {
|
|
71
|
+
experiments.assertEnabled("directcloudrun", "deploy Cloud Run services");
|
|
72
|
+
}
|
|
70
73
|
const permissions = options.filteredTargets.reduce((perms, target) => {
|
|
71
74
|
return perms.concat(deploy_1.TARGET_PERMISSIONS[target]);
|
|
72
75
|
}, []);
|
|
@@ -12,13 +12,25 @@ const logger_1 = require("../logger");
|
|
|
12
12
|
const projectUtils_1 = require("../projectUtils");
|
|
13
13
|
exports.command = new command_1.Command("hosting:clone <source> <targetChannel>")
|
|
14
14
|
.description("clone a version from one site to another")
|
|
15
|
-
.help(`<source> and <targetChannel> accept the following
|
|
15
|
+
.help(`<source> and <targetChannel> accept the following formats:
|
|
16
|
+
- [<projectId>:]<siteId>:<channelId>
|
|
17
|
+
- [<projectId>:]<siteId>@<versionId> (source only)
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
Site projects are automatically discovered if omitted.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
For example, to copy the content for a site \`my-site\` from a preview channel \`staging\` to a \`live\` channel:
|
|
22
|
+
|
|
23
|
+
firebase hosting:clone my-site:staging my-site:live
|
|
24
|
+
|
|
25
|
+
To clone across different Firebase projects:
|
|
26
|
+
|
|
27
|
+
firebase hosting:clone site-a:live site-b:live --project=project-b
|
|
28
|
+
# or explicitly:
|
|
29
|
+
firebase hosting:clone project-a:site-a:live project-b:site-b:live`)
|
|
20
30
|
.before(requireAuth_1.requireAuth)
|
|
21
|
-
.action(async (source
|
|
31
|
+
.action(async (source, targetChannel, options) => {
|
|
32
|
+
source = source || "";
|
|
33
|
+
targetChannel = targetChannel || "";
|
|
22
34
|
let sourceProjectId;
|
|
23
35
|
let sourceSiteId;
|
|
24
36
|
let sourceChannelId;
|
|
@@ -53,13 +65,15 @@ For example, to copy the content for a site \`my-site\` from a preview channel \
|
|
|
53
65
|
[targetSiteId, targetChannelId] = targetParts;
|
|
54
66
|
}
|
|
55
67
|
if (!sourceSiteId || (!sourceChannelId && !sourceVersion)) {
|
|
56
|
-
throw new error_1.FirebaseError(`"${source}" is not a valid source. Must be in the form "<site>:<channel>" or "<site>@<version>"`);
|
|
68
|
+
throw new error_1.FirebaseError(`"${source}" is not a valid source. Must be in the form "[<project>:]<site>:<channel>" or "[<project>:]<site>@<version>"`);
|
|
57
69
|
}
|
|
58
70
|
if (!targetSiteId || !targetChannelId) {
|
|
59
|
-
throw new error_1.FirebaseError(`"${targetChannel}" is not a valid target channel. Must be in the form "<site>:<channel>" (to clone to the active website, use "live" as the channel).`);
|
|
71
|
+
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).`);
|
|
60
72
|
}
|
|
61
|
-
sourceProjectId =
|
|
62
|
-
|
|
73
|
+
[sourceProjectId, targetProjectId] = await Promise.all([
|
|
74
|
+
resolveProjectId(sourceSiteId, sourceProjectId, options),
|
|
75
|
+
resolveProjectId(targetSiteId, targetProjectId, options),
|
|
76
|
+
]);
|
|
63
77
|
targetChannelId = (0, api_1.normalizeName)(targetChannelId);
|
|
64
78
|
if (sourceChannelId) {
|
|
65
79
|
sourceChannelId = (0, api_1.normalizeName)(sourceChannelId);
|
|
@@ -77,7 +91,7 @@ For example, to copy the content for a site \`my-site\` from a preview channel \
|
|
|
77
91
|
else if (sourceChannelId) {
|
|
78
92
|
const sChannel = await (0, api_1.getChannel)(sourceProjectId, sourceSiteId, sourceChannelId);
|
|
79
93
|
if (!sChannel) {
|
|
80
|
-
throw new error_1.FirebaseError(`Could not find the channel ${(0, colorette_1.bold)(sourceChannelId)} for site ${(0, colorette_1.bold)(sourceSiteId)}.`);
|
|
94
|
+
throw new error_1.FirebaseError(`Could not find the channel ${(0, colorette_1.bold)(sourceChannelId)} for site ${(0, colorette_1.bold)(sourceSiteId)} in project ${(0, colorette_1.bold)(sourceProjectId)}.`);
|
|
81
95
|
}
|
|
82
96
|
sourceVersionName = sChannel.release?.version?.name;
|
|
83
97
|
if (!sourceVersionName) {
|
|
@@ -130,3 +144,29 @@ For example, to copy the content for a site \`my-site\` from a preview channel \
|
|
|
130
144
|
utils.logSuccess(`Site ${(0, colorette_1.bold)(sourceSiteId)} ${sourceChannelId ? "channel" : "version"} ${(0, colorette_1.bold)(sourceChannelId || sourceVersion || sourceVersionName)} has been cloned to site ${(0, colorette_1.bold)(targetSiteId)} channel ${(0, colorette_1.bold)(targetChannelId)}.`);
|
|
131
145
|
utils.logSuccess(`Channel URL (${targetChannelId}): ${tChannel.url}`);
|
|
132
146
|
});
|
|
147
|
+
function parseProjectId(name) {
|
|
148
|
+
const matches = /^projects\/([^/]+)/.exec(name);
|
|
149
|
+
return matches ? matches[1] || "" : "";
|
|
150
|
+
}
|
|
151
|
+
async function resolveProjectId(siteId, explicitProjectId, options) {
|
|
152
|
+
if (explicitProjectId) {
|
|
153
|
+
return explicitProjectId;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
const site = await (0, api_1.getSite)("-", siteId);
|
|
157
|
+
const projectId = parseProjectId(site.name);
|
|
158
|
+
if (projectId) {
|
|
159
|
+
return projectId;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
if (e instanceof error_1.FirebaseError && e.status === 404) {
|
|
164
|
+
throw new error_1.FirebaseError(`Could not find the site ${(0, colorette_1.bold)(siteId)}.`, {
|
|
165
|
+
original: e,
|
|
166
|
+
status: 404,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
logger_1.logger.debug(`[hosting] unable to resolve project for site ${siteId} via site lookup:`, e);
|
|
170
|
+
}
|
|
171
|
+
return (0, projectUtils_1.needProjectId)(options);
|
|
172
|
+
}
|
package/lib/commands/index.js
CHANGED
|
@@ -80,6 +80,10 @@ function load(client) {
|
|
|
80
80
|
client.crashlytics.sourcemap = {};
|
|
81
81
|
client.crashlytics.sourcemap.upload = loadCommand("crashlytics-sourcemap-upload");
|
|
82
82
|
}
|
|
83
|
+
client.crashlytics.heapdumps = {};
|
|
84
|
+
client.crashlytics.heapdumps.enable = loadCommand("crashlytics-heapdumps-enable");
|
|
85
|
+
client.crashlytics.heapdumps.disable = loadCommand("crashlytics-heapdumps-disable");
|
|
86
|
+
client.crashlytics.heapdumps.status = loadCommand("crashlytics-heapdumps-status");
|
|
83
87
|
client.database = {};
|
|
84
88
|
client.database.get = loadCommand("database-get");
|
|
85
89
|
client.database.import = loadCommand("database-import");
|
|
@@ -285,6 +289,11 @@ function load(client) {
|
|
|
285
289
|
client.remoteconfig.experiments.get = loadCommand("remoteconfig-experiments-get");
|
|
286
290
|
client.remoteconfig.experiments.list = loadCommand("remoteconfig-experiments-list");
|
|
287
291
|
client.remoteconfig.experiments.delete = loadCommand("remoteconfig-experiments-delete");
|
|
292
|
+
if (experiments.isEnabled("directcloudrun")) {
|
|
293
|
+
client.run = {};
|
|
294
|
+
client.run.services = {};
|
|
295
|
+
client.run.services.update = loadCommand("run-services-update");
|
|
296
|
+
}
|
|
288
297
|
client.serve = loadCommand("serve");
|
|
289
298
|
client.setup = {};
|
|
290
299
|
client.setup.emulators = {};
|
package/lib/commands/init.js
CHANGED
|
@@ -94,6 +94,13 @@ let choices = [
|
|
|
94
94
|
checked: false,
|
|
95
95
|
},
|
|
96
96
|
];
|
|
97
|
+
if ((0, experiments_1.isEnabled)("directcloudrun")) {
|
|
98
|
+
choices.push({
|
|
99
|
+
value: "run",
|
|
100
|
+
name: "Cloud Run: Create or update a Cloud Run service and deploy your web app to it",
|
|
101
|
+
checked: false,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
97
104
|
if ((0, experiments_1.isEnabled)("fdcwebhooks")) {
|
|
98
105
|
choices.push({
|
|
99
106
|
value: "dataconnect:resolver",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const deploy_1 = require("../deploy");
|
|
6
|
+
const update_1 = require("../deploy/run/update");
|
|
7
|
+
const requireConfig_1 = require("../requireConfig");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
exports.command = new command_1.Command("run:services:update <serviceId>")
|
|
10
|
+
.description("update the settings of a Cloud Run service, then build and deploy it")
|
|
11
|
+
.option("--region <region>", "the service's region, if firebase.json lists the service ID in more than one region")
|
|
12
|
+
.option("--base-image <baseImage>", "set the base image (e.g. nodejs22) and enable automatic base image updates")
|
|
13
|
+
.option("--clear-base-image", "clear the base image and disable automatic base image updates")
|
|
14
|
+
.before(requireConfig_1.requireConfig)
|
|
15
|
+
.before(requirePermissions_1.requirePermissions, deploy_1.TARGET_PERMISSIONS.run)
|
|
16
|
+
.action((serviceId, options) => (0, update_1.updateService)(serviceId, options.region, options));
|
|
@@ -47,7 +47,7 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
47
47
|
(0, ensureApiEnabled_1.ensure)(projectId, exports.CRASHLYTICS_TELEMETRY_SERVICE, "crashlytics", false),
|
|
48
48
|
(0, ensureApiEnabled_1.ensure)(projectId, "firebasetelemetryadmin.googleapis.com", "crashlytics", false),
|
|
49
49
|
];
|
|
50
|
-
if (experiments.isEnabled("
|
|
50
|
+
if (experiments.isEnabled("crashlyticsWebBreadcrumbs")) {
|
|
51
51
|
requiredApis.push((0, ensureApiEnabled_1.ensure)(projectId, "cloudtrace.googleapis.com", "crashlytics", false));
|
|
52
52
|
}
|
|
53
53
|
await Promise.all(requiredApis);
|
|
@@ -78,7 +78,7 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
78
78
|
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Cloud Logging routing sink '${exports.CRASHLYTICS_TELEMETRY_SINK_ID}'...`);
|
|
79
79
|
const sink = await (0, cloudlogging_1.createOrUpdateLogSink)(projectId, exports.CRASHLYTICS_TELEMETRY_SINK_ID, destination, filter);
|
|
80
80
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Cloud Logging routing sink configured.");
|
|
81
|
-
if (experiments.isEnabled("
|
|
81
|
+
if (experiments.isEnabled("crashlyticsWebBreadcrumbs")) {
|
|
82
82
|
(0, utils_1.logLabeledBullet)("crashlytics", "Provisioning Cloud Trace storage...");
|
|
83
83
|
try {
|
|
84
84
|
await (0, cloudtrace_1.provisionTraceStorage)(projectId);
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_LIFECYCLE_RULES = exports.DEFAULT_CORS_RULES = exports.DEFAULT_FILE_TTL_DAYS = exports.DEFAULT_BUCKET_LOCATION = exports.DEFAULT_CORS_ORIGINS = exports.HEAP_DUMP_BUCKET_PREFIX = exports.STORAGE_OBJECT_CREATOR_ROLE = exports.CRASHLYTICS_SERVICE_NAME = void 0;
|
|
4
|
+
exports.getCrashlyticsV1Client = getCrashlyticsV1Client;
|
|
5
|
+
exports.parseAndroidHashedId = parseAndroidHashedId;
|
|
6
|
+
exports.createBucketName = createBucketName;
|
|
7
|
+
exports.getCrashlyticsP4sa = getCrashlyticsP4sa;
|
|
8
|
+
exports.resolveAndroidAppId = resolveAndroidAppId;
|
|
9
|
+
exports.getProfilingManagerConfig = getProfilingManagerConfig;
|
|
10
|
+
exports.updateProfilingManagerConfig = updateProfilingManagerConfig;
|
|
11
|
+
exports.ensureHeapDumpStorageBucket = ensureHeapDumpStorageBucket;
|
|
12
|
+
exports.ensureHeapDumpP4saRole = ensureHeapDumpP4saRole;
|
|
13
|
+
exports.enableHeapDumpCollection = enableHeapDumpCollection;
|
|
14
|
+
exports.disableHeapDumpCollection = disableHeapDumpCollection;
|
|
15
|
+
const apiv2_1 = require("../apiv2");
|
|
16
|
+
const api_1 = require("../api");
|
|
17
|
+
const error_1 = require("../error");
|
|
18
|
+
const logger_1 = require("../logger");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const utils_2 = require("./utils");
|
|
21
|
+
const storage = require("../gcp/storage");
|
|
22
|
+
const resourceManager = require("../gcp/resourceManager");
|
|
23
|
+
const serviceusage = require("../gcp/serviceusage");
|
|
24
|
+
const apps_1 = require("../management/apps");
|
|
25
|
+
function getCrashlyticsV1Client() {
|
|
26
|
+
return new apiv2_1.Client({
|
|
27
|
+
urlPrefix: (0, api_1.crashlyticsApiOrigin)(),
|
|
28
|
+
apiVersion: "v1",
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.CRASHLYTICS_SERVICE_NAME = "firebasecrashlytics.googleapis.com";
|
|
32
|
+
exports.STORAGE_OBJECT_CREATOR_ROLE = "roles/storage.objectCreator";
|
|
33
|
+
exports.HEAP_DUMP_BUCKET_PREFIX = "firebasecrashlytics-heap-dumps-";
|
|
34
|
+
exports.DEFAULT_CORS_ORIGINS = ["https://console.firebase.google.com"];
|
|
35
|
+
exports.DEFAULT_BUCKET_LOCATION = "us-east1";
|
|
36
|
+
exports.DEFAULT_FILE_TTL_DAYS = 90;
|
|
37
|
+
exports.DEFAULT_CORS_RULES = [
|
|
38
|
+
{
|
|
39
|
+
origin: exports.DEFAULT_CORS_ORIGINS,
|
|
40
|
+
method: ["GET", "HEAD", "OPTIONS"],
|
|
41
|
+
responseHeader: ["Content-Type", "Access-Control-Allow-Origin", "Content-Length"],
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
exports.DEFAULT_LIFECYCLE_RULES = [
|
|
45
|
+
{
|
|
46
|
+
action: { type: "Delete" },
|
|
47
|
+
condition: { age: exports.DEFAULT_FILE_TTL_DAYS },
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
const ANDROID_APP_ID_REGEX = /^\d+:(\d+):android:([a-fA-F0-9]+)$/;
|
|
51
|
+
function parseAndroidHashedId(appId) {
|
|
52
|
+
const match = ANDROID_APP_ID_REGEX.exec(appId);
|
|
53
|
+
if (!match) {
|
|
54
|
+
throw new error_1.FirebaseError(`App ID '${appId}' is not a valid Android app ID (expected format '1:<project-number>:android:<hash>'). ` +
|
|
55
|
+
"Heap dump collection is only supported for Android apps. " +
|
|
56
|
+
"Run 'firebase apps:list ANDROID' to view valid Android app IDs for your project.");
|
|
57
|
+
}
|
|
58
|
+
return match[2].toLowerCase();
|
|
59
|
+
}
|
|
60
|
+
function createBucketName(appId) {
|
|
61
|
+
return `${exports.HEAP_DUMP_BUCKET_PREFIX}${parseAndroidHashedId(appId)}`;
|
|
62
|
+
}
|
|
63
|
+
function getCrashlyticsP4sa(projectNumber) {
|
|
64
|
+
return `service-${projectNumber}@gcp-sa-crashlytics.iam.gserviceaccount.com`;
|
|
65
|
+
}
|
|
66
|
+
async function resolveAndroidAppId(projectId, options) {
|
|
67
|
+
if (options.app) {
|
|
68
|
+
parseAndroidHashedId(options.app);
|
|
69
|
+
return options.app;
|
|
70
|
+
}
|
|
71
|
+
const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.ANDROID);
|
|
72
|
+
if (apps.length === 0) {
|
|
73
|
+
throw new error_1.FirebaseError(`No Android apps found in project '${projectId}'. Heap dump collection is only supported for Android apps.\n` +
|
|
74
|
+
"You can register an Android app using 'firebase apps:create ANDROID <package-name>'");
|
|
75
|
+
}
|
|
76
|
+
if (apps.length === 1) {
|
|
77
|
+
return apps[0].appId;
|
|
78
|
+
}
|
|
79
|
+
if (options.nonInteractive) {
|
|
80
|
+
throw new error_1.FirebaseError(`Project '${projectId}' has multiple Android apps. Please specify an app ID with '--app <appID>'.`);
|
|
81
|
+
}
|
|
82
|
+
const selectedApp = await (0, apps_1.selectAppInteractively)(apps, apps_1.AppPlatform.ANDROID, {
|
|
83
|
+
message: "Select an Android app:",
|
|
84
|
+
});
|
|
85
|
+
return selectedApp.appId;
|
|
86
|
+
}
|
|
87
|
+
async function getProfilingManagerConfig(appId) {
|
|
88
|
+
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
89
|
+
logger_1.logger.debug(`[crashlytics] getProfilingManagerConfig called with appId: ${appId}`);
|
|
90
|
+
const response = await getCrashlyticsV1Client().request({
|
|
91
|
+
method: "GET",
|
|
92
|
+
headers: {
|
|
93
|
+
"Content-Type": "application/json",
|
|
94
|
+
},
|
|
95
|
+
path: `/projects/${projectNumber}/apps/${appId}/appconfig:profilingManager`,
|
|
96
|
+
timeout: utils_2.TIMEOUT,
|
|
97
|
+
});
|
|
98
|
+
const config = response.body?.configuration || {};
|
|
99
|
+
return {
|
|
100
|
+
gcsBucket: config.gcsBucket || "",
|
|
101
|
+
heapDumpCollectionEnabled: config.heapDumpCollectionEnabled ?? false,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async function updateProfilingManagerConfig(appId, config) {
|
|
105
|
+
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
106
|
+
logger_1.logger.debug(`[crashlytics] updateProfilingManagerConfig called with appId: ${appId}, config: ${JSON.stringify(config)}`);
|
|
107
|
+
await getCrashlyticsV1Client().request({
|
|
108
|
+
method: "POST",
|
|
109
|
+
headers: {
|
|
110
|
+
"Content-Type": "application/json",
|
|
111
|
+
},
|
|
112
|
+
path: `/projects/${projectNumber}/apps/${appId}/appconfig:profilingManager`,
|
|
113
|
+
body: {
|
|
114
|
+
projectNumber,
|
|
115
|
+
gmpAppId: appId,
|
|
116
|
+
configuration: {
|
|
117
|
+
gcsBucket: config.gcsBucket ?? "",
|
|
118
|
+
heapDumpCollectionEnabled: config.heapDumpCollectionEnabled ?? false,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
timeout: utils_2.TIMEOUT,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async function ensureHeapDumpStorageBucket(projectId, appId, location = exports.DEFAULT_BUCKET_LOCATION) {
|
|
125
|
+
const bucketName = createBucketName(appId);
|
|
126
|
+
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
127
|
+
try {
|
|
128
|
+
const bucket = await storage.getBucket(bucketName);
|
|
129
|
+
if (bucket.projectNumber && String(bucket.projectNumber) !== projectNumber) {
|
|
130
|
+
throw new error_1.FirebaseError(`Cloud Storage bucket '${bucketName}' already exists and is owned by another project.`);
|
|
131
|
+
}
|
|
132
|
+
const patchPayload = {};
|
|
133
|
+
const hasConsoleCors = bucket.cors?.some((rule) => exports.DEFAULT_CORS_ORIGINS.every((origin) => rule.origin?.includes(origin)));
|
|
134
|
+
if (!hasConsoleCors) {
|
|
135
|
+
patchPayload.cors = [...(bucket.cors ?? []), ...exports.DEFAULT_CORS_RULES];
|
|
136
|
+
}
|
|
137
|
+
const hasDeleteLifecycle = bucket.lifecycle?.rule?.some((rule) => rule.action.type === "Delete" && rule.condition.age !== undefined);
|
|
138
|
+
if (!hasDeleteLifecycle) {
|
|
139
|
+
patchPayload.lifecycle = {
|
|
140
|
+
rule: [...(bucket.lifecycle?.rule ?? []), ...exports.DEFAULT_LIFECYCLE_RULES],
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (Object.keys(patchPayload).length > 0) {
|
|
144
|
+
logger_1.logger.debug(`[crashlytics] Bucket ${bucketName} found without full configuration. Patching ${Object.keys(patchPayload).join(", ")}.`);
|
|
145
|
+
await storage.patchBucket(bucketName, patchPayload);
|
|
146
|
+
}
|
|
147
|
+
return bucketName;
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
const status = (0, error_1.getErrStatus)(err);
|
|
151
|
+
if (status !== 404) {
|
|
152
|
+
throw err;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
logger_1.logger.debug(`[crashlytics] Creating GCS bucket ${bucketName} in ${location}...`);
|
|
156
|
+
await storage.createBucket(projectId, {
|
|
157
|
+
name: bucketName,
|
|
158
|
+
location,
|
|
159
|
+
cors: exports.DEFAULT_CORS_RULES,
|
|
160
|
+
lifecycle: { rule: exports.DEFAULT_LIFECYCLE_RULES },
|
|
161
|
+
}, true);
|
|
162
|
+
return bucketName;
|
|
163
|
+
}
|
|
164
|
+
async function ensureHeapDumpP4saRole(projectId, projectNumber) {
|
|
165
|
+
await serviceusage.generateServiceIdentityAndPoll(projectNumber, exports.CRASHLYTICS_SERVICE_NAME, "crashlytics");
|
|
166
|
+
const p4saEmail = getCrashlyticsP4sa(projectNumber);
|
|
167
|
+
const hasRole = await resourceManager.serviceAccountHasRoles(projectId, p4saEmail, [exports.STORAGE_OBJECT_CREATOR_ROLE], true);
|
|
168
|
+
if (!hasRole) {
|
|
169
|
+
logger_1.logger.debug(`[crashlytics] Adding ${exports.STORAGE_OBJECT_CREATOR_ROLE} to ${p4saEmail}...`);
|
|
170
|
+
await resourceManager.addServiceAccountToRoles(projectId, p4saEmail, [exports.STORAGE_OBJECT_CREATOR_ROLE], true);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async function enableHeapDumpCollection(projectId, appId, location = exports.DEFAULT_BUCKET_LOCATION) {
|
|
174
|
+
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
175
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring Google Cloud Storage bucket...");
|
|
176
|
+
const bucketName = await ensureHeapDumpStorageBucket(projectId, appId, location);
|
|
177
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring service agent permissions...");
|
|
178
|
+
await ensureHeapDumpP4saRole(projectId, projectNumber);
|
|
179
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Enabling Crashlytics heap dump collection...");
|
|
180
|
+
await updateProfilingManagerConfig(appId, {
|
|
181
|
+
gcsBucket: bucketName,
|
|
182
|
+
heapDumpCollectionEnabled: true,
|
|
183
|
+
});
|
|
184
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Successfully enabled Crashlytics heap dump collection!");
|
|
185
|
+
return bucketName;
|
|
186
|
+
}
|
|
187
|
+
async function disableHeapDumpCollection(appId) {
|
|
188
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Disabling Crashlytics heap dump collection...");
|
|
189
|
+
const currentConfig = await getProfilingManagerConfig(appId);
|
|
190
|
+
await updateProfilingManagerConfig(appId, {
|
|
191
|
+
gcsBucket: currentConfig.gcsBucket,
|
|
192
|
+
heapDumpCollectionEnabled: false,
|
|
193
|
+
});
|
|
194
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Successfully disabled Crashlytics heap dump collection!");
|
|
195
|
+
}
|
|
@@ -4,6 +4,7 @@ exports.default = default_1;
|
|
|
4
4
|
exports.injectEnvVarsFromApphostingConfig = injectEnvVarsFromApphostingConfig;
|
|
5
5
|
exports.injectAutoInitEnvVars = injectAutoInitEnvVars;
|
|
6
6
|
exports.getBackendConfigs = getBackendConfigs;
|
|
7
|
+
exports.prepareLocalBuildScratchDirectory = prepareLocalBuildScratchDirectory;
|
|
7
8
|
exports.injectAngularEnvVars = injectAngularEnvVars;
|
|
8
9
|
const crypto = require("crypto");
|
|
9
10
|
const fs = require("fs");
|