firebase-tools 15.32.1 → 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/api.js +4 -2
- package/lib/apphosting/backend.js +1 -1
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +30 -23
- package/lib/commands/apps-create.js +34 -3
- 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/functions-kits-uninstall.js +43 -21
- package/lib/commands/functions-lifecycle-list.js +5 -6
- package/lib/commands/hosting-channel-deploy.js +3 -3
- package/lib/commands/hosting-clone.js +102 -31
- package/lib/commands/hosting-disable.js +5 -1
- 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 +17 -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/build.js +3 -0
- package/lib/deploy/functions/cel.js +89 -58
- package/lib/deploy/functions/functionsDeployHelper.js +10 -0
- package/lib/deploy/functions/prepare.js +25 -8
- package/lib/deploy/functions/release/executor.js +7 -3
- package/lib/deploy/functions/release/fabricator.js +42 -14
- package/lib/deploy/functions/release/planner.js +3 -2
- package/lib/deploy/functions/release/sourceTokenScraper.js +1 -1
- package/lib/deploy/functions/validate.js +16 -0
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/deploy/hosting/release.js +2 -2
- package/lib/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 +12 -11
- package/lib/firestore/validator.js +1 -1
- package/lib/frameworks/next/constants.js +20 -12
- package/lib/frameworks/next/index.js +3 -0
- package/lib/functions/env.js +4 -2
- package/lib/functions/projectConfig.js +10 -5
- package/lib/gcp/artifactregistry.js +20 -0
- package/lib/gcp/cloudsql/permissions.js +21 -32
- package/lib/gcp/cloudsql/permissionsSetup.js +6 -6
- package/lib/gcp/cloudtasks.js +14 -0
- package/lib/gcp/cloudtrace.js +38 -0
- package/lib/gcp/run.js +5 -0
- package/lib/gcp/runv2.js +32 -11
- package/lib/gcp/storage.js +9 -5
- package/lib/hosting/api.js +15 -15
- package/lib/hosting/runTags.js +1 -1
- package/lib/init/features/auth.js +46 -8
- 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/mcp/tools/firestore/converter.js +2 -2
- package/lib/mcp/util.js +11 -10
- package/lib/profileReport.js +12 -9
- 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
|
package/lib/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.developerKnowledgeOrigin = exports.cloudTestingOrigin = exports.appTestingOrigin = exports.aiLogicProxyOrigin = exports.vertexAIOrigin = exports.cloudSQLAdminOrigin = exports.dataConnectLocalConnString = exports.dataconnectP4SADomain = exports.dataconnectOrigin = exports.githubClientSecret = exports.githubClientId = exports.computeOrigin = exports.secretManagerOrigin = exports.githubApiOrigin = exports.githubOrigin = exports.studioApiOrigin = exports.serviceUsageOrigin = exports.cloudRunApiOrigin = exports.hostingApiOrigin = exports.firebaseStorageOrigin = exports.storageOrigin = void 0;
|
|
3
|
+
exports.rulesOrigin = exports.resourceManagerOrigin = exports.firebaseTelemetryAdminOrigin = exports.crashlyticsApiOrigin = exports.messagingApiOrigin = exports.remoteConfigApiOrigin = exports.rtdbMetadataOrigin = exports.rtdbManagementOrigin = exports.realtimeOrigin = exports.extensionsTOSOrigin = exports.extensionsPublisherOrigin = exports.extensionsOrigin = exports.iamOrigin = exports.identityOrigin = exports.hostingOrigin = exports.googleOrigin = exports.pubsubOrigin = exports.cloudTasksOrigin = exports.cloudschedulerOrigin = exports.cloudbuildOrigin = exports.functionsDefaultRegion = exports.runOrigin = exports.functionsV2Origin = exports.functionsOrigin = exports.firestoreOrigin = exports.firestoreOriginOrEmulator = exports.firedataOrigin = exports.firebaseExtensionsRegistryOrigin = exports.firebaseApiOrigin = exports.eventarcOrigin = exports.consoleOrigin = exports.authManagementOrigin = exports.authOrigin = exports.apphostingGitHubAppInstallationURL = exports.apphostingP4SADomain = exports.apphostingOrigin = exports.appDistributionOrigin = exports.appCheckOrigin = exports.apiKeysOrigin = exports.artifactRegistryDomain = exports.developerConnectP4SADomain = exports.developerConnectOrigin = exports.containerRegistryDomain = exports.cloudTraceOrigin = exports.cloudMonitoringOrigin = exports.cloudloggingOrigin = exports.cloudbillingOrigin = exports.clientSecret = exports.clientId = exports.authProxyOrigin = void 0;
|
|
4
|
+
exports.developerKnowledgeOrigin = exports.cloudTestingOrigin = exports.appTestingOrigin = exports.aiLogicProxyOrigin = exports.vertexAIOrigin = exports.cloudSQLAdminOrigin = exports.dataConnectLocalConnString = exports.dataconnectP4SADomain = exports.dataconnectOrigin = exports.githubClientSecret = exports.githubClientId = exports.computeOrigin = exports.secretManagerOrigin = exports.githubApiOrigin = exports.githubOrigin = exports.studioApiOrigin = exports.serviceUsageOrigin = exports.cloudRunApiOrigin = exports.hostingApiOrigin = exports.firebaseStorageOrigin = exports.storageOrigin = exports.runtimeconfigOrigin = void 0;
|
|
5
5
|
exports.getScopes = getScopes;
|
|
6
6
|
exports.setScopes = setScopes;
|
|
7
7
|
const constants_1 = require("./emulator/constants");
|
|
@@ -21,6 +21,8 @@ const cloudloggingOrigin = () => utils.envOverride("FIREBASE_CLOUDLOGGING_URL",
|
|
|
21
21
|
exports.cloudloggingOrigin = cloudloggingOrigin;
|
|
22
22
|
const cloudMonitoringOrigin = () => utils.envOverride("CLOUD_MONITORING_URL", "https://monitoring.googleapis.com");
|
|
23
23
|
exports.cloudMonitoringOrigin = cloudMonitoringOrigin;
|
|
24
|
+
const cloudTraceOrigin = () => utils.envOverride("CLOUD_TRACE_URL", "https://cloudtrace.googleapis.com");
|
|
25
|
+
exports.cloudTraceOrigin = cloudTraceOrigin;
|
|
24
26
|
const containerRegistryDomain = () => utils.envOverride("CONTAINER_REGISTRY_DOMAIN", "gcr.io");
|
|
25
27
|
exports.containerRegistryDomain = containerRegistryDomain;
|
|
26
28
|
const developerConnectOrigin = () => utils.envOverride("DEVELOPERCONNECT_URL", "https://developerconnect.googleapis.com");
|
|
@@ -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
|
});
|
|
@@ -9,6 +9,10 @@ const apps_1 = require("../management/apps");
|
|
|
9
9
|
const requireAuth_1 = require("../requireAuth");
|
|
10
10
|
const logger_1 = require("../logger");
|
|
11
11
|
const prompt_1 = require("../prompt");
|
|
12
|
+
const getDefaultHostingSite_1 = require("../getDefaultHostingSite");
|
|
13
|
+
const interactive_1 = require("../hosting/interactive");
|
|
14
|
+
const api_1 = require("../hosting/api");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
12
16
|
function logPostAppCreationInformation(appMetadata, appPlatform) {
|
|
13
17
|
logger_1.logger.info("");
|
|
14
18
|
logger_1.logger.info(`🎉🎉🎉 Your Firebase ${appPlatform} App is ready! 🎉🎉🎉`);
|
|
@@ -40,8 +44,9 @@ exports.command = new command_1.Command("apps:create [platform] [displayName]")
|
|
|
40
44
|
.before(requireAuth_1.requireAuth)
|
|
41
45
|
.action(async (platform = "", displayName, options) => {
|
|
42
46
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
let chosenPlatform = typeof platform === "string" ? platform : "";
|
|
48
|
+
if (!options.nonInteractive && !chosenPlatform) {
|
|
49
|
+
chosenPlatform = await (0, prompt_1.select)({
|
|
45
50
|
message: "Please choose the platform of the app:",
|
|
46
51
|
choices: [
|
|
47
52
|
{ name: "iOS", value: apps_1.AppPlatform.IOS },
|
|
@@ -50,13 +55,39 @@ exports.command = new command_1.Command("apps:create [platform] [displayName]")
|
|
|
50
55
|
],
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
|
-
const appPlatform = (0, apps_1.getAppPlatform)(
|
|
58
|
+
const appPlatform = (0, apps_1.getAppPlatform)(chosenPlatform);
|
|
54
59
|
if (appPlatform === apps_1.AppPlatform.ANY) {
|
|
55
60
|
throw new error_1.FirebaseError("App platform must be provided");
|
|
56
61
|
}
|
|
57
62
|
logger_1.logger.info(`Create your ${appPlatform} app in project ${clc.bold(projectId)}:`);
|
|
63
|
+
let newSiteId;
|
|
64
|
+
if (appPlatform === apps_1.AppPlatform.WEB) {
|
|
65
|
+
const existingSite = await (0, getDefaultHostingSite_1.getDefaultHostingSite)({ projectId }).catch((err) => {
|
|
66
|
+
if (err !== getDefaultHostingSite_1.errNoDefaultSite) {
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (existingSite) {
|
|
71
|
+
logger_1.logger.info(`Firebase Hosting site is present: ${clc.bold(existingSite)}.`);
|
|
72
|
+
}
|
|
73
|
+
else if (await (0, prompt_1.confirm)({
|
|
74
|
+
message: "A Firebase Hosting site is recommended for Web apps. Would you like to create a default site now?",
|
|
75
|
+
default: true,
|
|
76
|
+
nonInteractive: options.nonInteractive,
|
|
77
|
+
})) {
|
|
78
|
+
newSiteId = await (0, interactive_1.pickHostingSiteName)("", {
|
|
79
|
+
projectId,
|
|
80
|
+
nonInteractive: options.nonInteractive,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
58
84
|
options.displayName = displayName;
|
|
59
85
|
const appData = await (0, apps_1.sdkInit)(appPlatform, options);
|
|
86
|
+
if (newSiteId) {
|
|
87
|
+
await (0, api_1.createSite)(projectId, newSiteId, appData.appId);
|
|
88
|
+
logger_1.logger.info("");
|
|
89
|
+
(0, utils_1.logSuccess)(`Firebase Hosting site ${newSiteId} created!`);
|
|
90
|
+
}
|
|
60
91
|
logPostAppCreationInformation(appData, appPlatform);
|
|
61
92
|
return appData;
|
|
62
93
|
});
|
|
@@ -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
|
}, []);
|
|
@@ -13,6 +13,7 @@ const projectUtils_1 = require("../projectUtils");
|
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
14
|
const logger_1 = require("../logger");
|
|
15
15
|
const delete_1 = require("../deploy/functions/delete");
|
|
16
|
+
const ENV_FILE_PREFIX = ".env.";
|
|
16
17
|
exports.command = new command_1.Command("functions:kits:uninstall")
|
|
17
18
|
.description("uninstall a function kit or kit instance from your project. Deletes all running resources and the associated managed service account.")
|
|
18
19
|
.before(requireConfig_1.requireConfig)
|
|
@@ -73,10 +74,7 @@ async function handleInstance(options, config) {
|
|
|
73
74
|
const instanceConfigDirPath = kitForInstance.instances[instanceId];
|
|
74
75
|
const conservativeDeletion = nonstandardKitLayout(kitForInstance);
|
|
75
76
|
logger_1.logger.debug(`Kit ${kitForInstance.kit} uninstall mode: conservativeDeletion=${conservativeDeletion}`);
|
|
76
|
-
const
|
|
77
|
-
const envFileNames = configDirContents
|
|
78
|
-
.filter((f) => f.isFile() && f.name.startsWith(".env."))
|
|
79
|
-
.map((f) => f.name.slice(".env.".length));
|
|
77
|
+
const envFileNames = getInstanceEnvNames(config, instanceConfigDirPath);
|
|
80
78
|
const projectNamesInEnvs = envFileNames.map((envName) => options.rc ? options.rc.resolveAlias(envName) : envName);
|
|
81
79
|
if (projectNamesInEnvs.length > 0 && !projectNamesInEnvs.includes(projectId)) {
|
|
82
80
|
throw new error_1.FirebaseError(`Instance at ${instanceConfigDirPath} contains no .env file for current project`);
|
|
@@ -101,7 +99,7 @@ async function handleInstance(options, config) {
|
|
|
101
99
|
let filesystemNameForProject = projectId;
|
|
102
100
|
const envFilesWhichAliasToProject = envFileNames.filter((name) => (options.rc?.resolveAlias(name) || name) === projectId);
|
|
103
101
|
if (envFilesWhichAliasToProject.length > 1) {
|
|
104
|
-
throw new error_1.FirebaseError(`Instance ${instanceId} contains multiple .env files which ambiguously resolve to the current project ${envFilesWhichAliasToProject.map((s) =>
|
|
102
|
+
throw new error_1.FirebaseError(`Instance ${instanceId} contains multiple .env files which ambiguously resolve to the current project ${envFilesWhichAliasToProject.map((s) => ENV_FILE_PREFIX + s).join(", ")}`);
|
|
105
103
|
}
|
|
106
104
|
if (envFilesWhichAliasToProject.length === 1) {
|
|
107
105
|
filesystemNameForProject = envFilesWhichAliasToProject[0];
|
|
@@ -109,18 +107,8 @@ async function handleInstance(options, config) {
|
|
|
109
107
|
await uninstallProjectInstance(options, config, filesystemNameForProject, instanceId, instanceConfigDirPath);
|
|
110
108
|
}
|
|
111
109
|
async function uninstallInstance(options, config, instanceId, instanceConfigDirPath, onlyDeleteEmpty) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
for (const fileName of fileNames) {
|
|
115
|
-
if (!fileName.startsWith(".env.")) {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
const projectIdOrAlias = fileName.slice(".env.".length);
|
|
119
|
-
await uninstallProjectInstance(options, config, projectIdOrAlias, instanceId, instanceConfigDirPath);
|
|
120
|
-
}
|
|
121
|
-
if (!onlyDeleteEmpty || configDirEmpty(config, instanceConfigDirPath)) {
|
|
122
|
-
config.deleteProjectDir(instanceConfigDirPath);
|
|
123
|
-
}
|
|
110
|
+
await deleteInstancesFunctions(options, config, { [instanceId]: instanceConfigDirPath });
|
|
111
|
+
deleteInstanceConfigFiles(config, instanceConfigDirPath, onlyDeleteEmpty);
|
|
124
112
|
let functionsConfig = config.src.functions ?? [];
|
|
125
113
|
if (!Array.isArray(functionsConfig)) {
|
|
126
114
|
functionsConfig = [functionsConfig];
|
|
@@ -141,7 +129,7 @@ async function uninstallInstance(options, config, instanceId, instanceConfigDirP
|
|
|
141
129
|
}
|
|
142
130
|
async function uninstallProjectInstance(options, config, envName, instanceId, kitInstancePath) {
|
|
143
131
|
const projectId = options.rc?.resolveAlias(envName) || envName;
|
|
144
|
-
const envFilePath = (0, path_1.join)(kitInstancePath,
|
|
132
|
+
const envFilePath = (0, path_1.join)(kitInstancePath, `${ENV_FILE_PREFIX}${envName}`);
|
|
145
133
|
if (!config.projectFileExists(envFilePath)) {
|
|
146
134
|
throw new error_1.FirebaseError(`Expected to clean up project kit instance .env file at ${envFilePath}, but it doesn't exist.`);
|
|
147
135
|
}
|
|
@@ -155,10 +143,11 @@ async function uninstallProjectInstance(options, config, envName, instanceId, ki
|
|
|
155
143
|
}
|
|
156
144
|
async function uninstallKit(options, config, kit) {
|
|
157
145
|
const conservativeDeletion = nonstandardKitLayout(kit);
|
|
158
|
-
|
|
159
|
-
await uninstallInstance(options, config, instanceId, instanceConfigDir, conservativeDeletion);
|
|
160
|
-
}
|
|
146
|
+
await deleteInstancesFunctions(options, config, kit.instances);
|
|
161
147
|
if (conservativeDeletion) {
|
|
148
|
+
for (const instanceConfigDir of Object.values(kit.instances)) {
|
|
149
|
+
deleteInstanceConfigFiles(config, instanceConfigDir);
|
|
150
|
+
}
|
|
162
151
|
const instanceConfigDirParents = Object.values(kit.instances).map((p) => (0, posix_1.dirname)(p));
|
|
163
152
|
if (instanceConfigDirParents.length > 0 &&
|
|
164
153
|
instanceConfigDirParents.every((p) => p === instanceConfigDirParents[0]) &&
|
|
@@ -184,6 +173,33 @@ async function uninstallKit(options, config, kit) {
|
|
|
184
173
|
config.set("functions", functionsConfig);
|
|
185
174
|
config.writeProjectFile("firebase.json", config.src);
|
|
186
175
|
}
|
|
176
|
+
async function deleteInstancesFunctions(options, config, instances) {
|
|
177
|
+
const instancesByProject = new Map();
|
|
178
|
+
for (const [instanceId, instanceConfigDir] of Object.entries(instances)) {
|
|
179
|
+
for (const projectIdOrAlias of getInstanceEnvNames(config, instanceConfigDir)) {
|
|
180
|
+
const projectId = options.rc ? options.rc.resolveAlias(projectIdOrAlias) : projectIdOrAlias;
|
|
181
|
+
const list = instancesByProject.get(projectId) ?? [];
|
|
182
|
+
list.push(instanceId);
|
|
183
|
+
instancesByProject.set(projectId, list);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (const [projectId, instanceIds] of instancesByProject.entries()) {
|
|
187
|
+
const epFilters = instanceIds.map((id) => ({ codebase: id }));
|
|
188
|
+
const deployContext = { projectId, filters: epFilters };
|
|
189
|
+
const deletionCount = await (0, delete_1.deleteFunctionsByEndpointFilters)(deployContext, options);
|
|
190
|
+
if (deletionCount === 0) {
|
|
191
|
+
logger_1.logger.info(`No deployed functions found for instances: ${instanceIds.join(", ")}. This is normal if firebase deploy was never run.`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function deleteInstanceConfigFiles(config, instanceConfigDirPath, onlyDeleteEmpty = true) {
|
|
196
|
+
for (const projectIdOrAlias of getInstanceEnvNames(config, instanceConfigDirPath)) {
|
|
197
|
+
config.deleteProjectFile((0, path_1.join)(instanceConfigDirPath, `${ENV_FILE_PREFIX}${projectIdOrAlias}`));
|
|
198
|
+
}
|
|
199
|
+
if (!onlyDeleteEmpty || configDirEmpty(config, instanceConfigDirPath)) {
|
|
200
|
+
config.deleteProjectDir(instanceConfigDirPath);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
187
203
|
function nonstandardKitLayout(kitConfig) {
|
|
188
204
|
if (kitConfig.sourcePackage) {
|
|
189
205
|
if (kitConfig.source !== `function-kits/${kitConfig.kit}/source`) {
|
|
@@ -209,3 +225,9 @@ function configDirEmpty(config, projectRelativePath) {
|
|
|
209
225
|
}
|
|
210
226
|
return true;
|
|
211
227
|
}
|
|
228
|
+
function getInstanceEnvNames(config, instanceConfigDirPath) {
|
|
229
|
+
return config
|
|
230
|
+
.lsProjectDir(instanceConfigDirPath)
|
|
231
|
+
.filter((f) => f.isFile() && f.name.startsWith(ENV_FILE_PREFIX))
|
|
232
|
+
.map((f) => f.name.slice(ENV_FILE_PREFIX.length));
|
|
233
|
+
}
|
|
@@ -19,16 +19,13 @@ async function loadCodebaseBuild(codebase, options) {
|
|
|
19
19
|
throw new error_1.FirebaseError("Not in a Firebase project directory (firebase.json not found).");
|
|
20
20
|
}
|
|
21
21
|
const fnConfig = (0, projectConfig_1.normalizeAndValidate)(options.config.src.functions);
|
|
22
|
-
const
|
|
23
|
-
if (!hasCodebase) {
|
|
24
|
-
throw new error_1.FirebaseError(`Codebase "${codebase}" is not defined in firebase.json.`);
|
|
25
|
-
}
|
|
22
|
+
const codebaseConfig = (0, projectConfig_1.configForCodebase)(fnConfig, codebase);
|
|
26
23
|
const firebaseConfig = await (0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(projectId);
|
|
27
24
|
if (!firebaseConfig) {
|
|
28
25
|
throw new error_1.FirebaseError("Admin SDK config unexpectedly undefined - have you run firebase init?");
|
|
29
26
|
}
|
|
30
27
|
let runtimeConfig = { firebase: firebaseConfig };
|
|
31
|
-
if (
|
|
28
|
+
if ((0, projectConfig_1.shouldUseRuntimeConfig)(codebaseConfig)) {
|
|
32
29
|
try {
|
|
33
30
|
const runtimeConfigApiEnabled = await ensureApiEnabled.check(projectId, (0, api_1.runtimeconfigOrigin)(), "runtimeconfig", true);
|
|
34
31
|
if (runtimeConfigApiEnabled) {
|
|
@@ -39,7 +36,9 @@ async function loadCodebaseBuild(codebase, options) {
|
|
|
39
36
|
logger_1.logger.debug("Could not check Runtime Config API status, assuming disabled:", err);
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
const wantBuilds = await (0, prepare_1.loadCodebases)(fnConfig, options, firebaseConfig, runtimeConfig,
|
|
39
|
+
const wantBuilds = await (0, prepare_1.loadCodebases)(fnConfig, options, firebaseConfig, runtimeConfig, [
|
|
40
|
+
{ codebase },
|
|
41
|
+
]);
|
|
43
42
|
const codebaseBuild = wantBuilds[codebase];
|
|
44
43
|
if (!codebaseBuild) {
|
|
45
44
|
throw new error_1.FirebaseError(`Failed to load build for codebase "${codebase}".`);
|
|
@@ -112,13 +112,13 @@ async function hostingChannelDeployAction(channelId, options) {
|
|
|
112
112
|
if (d.expireTime) {
|
|
113
113
|
expires = `[expires ${(0, colorette_1.bold)((0, utils_1.datetimeString)(new Date(d.expireTime)))}]`;
|
|
114
114
|
}
|
|
115
|
-
const versionPrefix = `sites/${d.site}/versions/`;
|
|
115
|
+
const versionPrefix = `projects/${projectId}/sites/${d.site}/versions/`;
|
|
116
116
|
const versionName = versionNames.find((v) => {
|
|
117
|
-
return v.startsWith(versionPrefix);
|
|
117
|
+
return v.startsWith(versionPrefix) || v.startsWith(`sites/${d.site}/versions/`);
|
|
118
118
|
});
|
|
119
119
|
let version = "";
|
|
120
120
|
if (versionName) {
|
|
121
|
-
d.version = versionName.
|
|
121
|
+
d.version = (0, utils_1.last)(versionName.split("/")) || "";
|
|
122
122
|
version = ` [version ${(0, colorette_1.bold)(d.version)}]`;
|
|
123
123
|
}
|
|
124
124
|
(0, utils_1.logLabeledSuccess)(LOG_TAG, `Channel URL (${(0, colorette_1.bold)(d.site || d.target || "")}): ${d.url} ${expires}${version}`);
|