firebase-tools 15.33.0 → 15.34.1
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/auth.js +10 -5
- 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 +7 -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 +63 -9
- 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 +9 -0
- package/lib/commands/init.js +7 -0
- package/lib/commands/run-services-update.js +18 -0
- package/lib/crashlytics/alerts.js +1 -11
- package/lib/crashlytics/onboarding.js +10 -5
- 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/params.js +1 -0
- 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/hosting/prepare.js +3 -0
- 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 +242 -0
- package/lib/deploy/run/index.js +23 -0
- package/lib/deploy/run/prepare.js +99 -0
- package/lib/deploy/run/prereqs.js +32 -0
- package/lib/deploy/run/release.js +9 -0
- package/lib/deploy/run/update.js +51 -0
- package/lib/deploy/run/util.js +75 -0
- package/lib/emulator/apphosting/serve.js +1 -1
- package/lib/emulator/auth/cloudFunctions.js +47 -18
- 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 -17
- 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 +198 -0
- package/lib/init/index.js +6 -0
- package/lib/mcp/index.js +19 -3
- 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 +8 -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/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"));
|
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
|
@@ -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() {
|
|
@@ -67,6 +70,9 @@ exports.command
|
|
|
67
70
|
if (options.filteredTargets.includes("ailogic")) {
|
|
68
71
|
experiments.assertEnabled("ailogic", "deploy AI Logic resources");
|
|
69
72
|
}
|
|
73
|
+
if (options.filteredTargets.includes("run")) {
|
|
74
|
+
experiments.assertEnabled("directcloudrun", "deploy Cloud Run services");
|
|
75
|
+
}
|
|
70
76
|
const permissions = options.filteredTargets.reduce((perms, target) => {
|
|
71
77
|
return perms.concat(deploy_1.TARGET_PERMISSIONS[target]);
|
|
72
78
|
}, []);
|
|
@@ -82,6 +88,7 @@ exports.command
|
|
|
82
88
|
await (0, requireDatabaseInstance_1.requireDatabaseInstance)(options);
|
|
83
89
|
}
|
|
84
90
|
if (options.filteredTargets.includes("hosting")) {
|
|
91
|
+
await (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true);
|
|
85
92
|
let shouldCreateSite = false;
|
|
86
93
|
try {
|
|
87
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,15 +10,29 @@ 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
|
-
.help(`<source> and <targetChannel> accept the following
|
|
17
|
+
.help(`<source> and <targetChannel> accept the following formats:
|
|
18
|
+
- [<projectId>:]<siteId>:<channelId>
|
|
19
|
+
- [<projectId>:]<siteId>@<versionId> (source only)
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
Site projects are automatically discovered if omitted.
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
For example, to copy the content for a site \`my-site\` from a preview channel \`staging\` to a \`live\` channel:
|
|
24
|
+
|
|
25
|
+
firebase hosting:clone my-site:staging my-site:live
|
|
26
|
+
|
|
27
|
+
To clone across different Firebase projects:
|
|
28
|
+
|
|
29
|
+
firebase hosting:clone site-a:live site-b:live --project=project-b
|
|
30
|
+
# or explicitly:
|
|
31
|
+
firebase hosting:clone project-a:site-a:live project-b:site-b:live`)
|
|
20
32
|
.before(requireAuth_1.requireAuth)
|
|
21
|
-
.action(async (source
|
|
33
|
+
.action(async (source, targetChannel, options) => {
|
|
34
|
+
source = source || "";
|
|
35
|
+
targetChannel = targetChannel || "";
|
|
22
36
|
let sourceProjectId;
|
|
23
37
|
let sourceSiteId;
|
|
24
38
|
let sourceChannelId;
|
|
@@ -53,13 +67,27 @@ For example, to copy the content for a site \`my-site\` from a preview channel \
|
|
|
53
67
|
[targetSiteId, targetChannelId] = targetParts;
|
|
54
68
|
}
|
|
55
69
|
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>"`);
|
|
70
|
+
throw new error_1.FirebaseError(`"${source}" is not a valid source. Must be in the form "[<project>:]<site>:<channel>" or "[<project>:]<site>@<version>"`);
|
|
57
71
|
}
|
|
58
72
|
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).`);
|
|
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).`);
|
|
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
|
+
}
|
|
79
|
+
[sourceProjectId, targetProjectId] = await Promise.all([
|
|
80
|
+
resolveProjectId(sourceSiteId, sourceProjectId, options),
|
|
81
|
+
resolveProjectId(targetSiteId, targetProjectId, options),
|
|
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));
|
|
60
89
|
}
|
|
61
|
-
|
|
62
|
-
targetProjectId = targetProjectId || (0, projectUtils_1.needProjectId)(options);
|
|
90
|
+
await Promise.all(ensurePromises);
|
|
63
91
|
targetChannelId = (0, api_1.normalizeName)(targetChannelId);
|
|
64
92
|
if (sourceChannelId) {
|
|
65
93
|
sourceChannelId = (0, api_1.normalizeName)(sourceChannelId);
|
|
@@ -77,7 +105,7 @@ For example, to copy the content for a site \`my-site\` from a preview channel \
|
|
|
77
105
|
else if (sourceChannelId) {
|
|
78
106
|
const sChannel = await (0, api_1.getChannel)(sourceProjectId, sourceSiteId, sourceChannelId);
|
|
79
107
|
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)}.`);
|
|
108
|
+
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
109
|
}
|
|
82
110
|
sourceVersionName = sChannel.release?.version?.name;
|
|
83
111
|
if (!sourceVersionName) {
|
|
@@ -130,3 +158,29 @@ For example, to copy the content for a site \`my-site\` from a preview channel \
|
|
|
130
158
|
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
159
|
utils.logSuccess(`Channel URL (${targetChannelId}): ${tChannel.url}`);
|
|
132
160
|
});
|
|
161
|
+
function parseProjectId(name) {
|
|
162
|
+
const matches = /^projects\/([^/]+)/.exec(name);
|
|
163
|
+
return matches ? matches[1] || "" : "";
|
|
164
|
+
}
|
|
165
|
+
async function resolveProjectId(siteId, explicitProjectId, options) {
|
|
166
|
+
if (explicitProjectId) {
|
|
167
|
+
return explicitProjectId;
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
const site = await (0, api_1.getSite)("-", siteId);
|
|
171
|
+
const projectId = parseProjectId(site.name);
|
|
172
|
+
if (projectId) {
|
|
173
|
+
return projectId;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch (e) {
|
|
177
|
+
if (e instanceof error_1.FirebaseError && e.status === 404) {
|
|
178
|
+
throw new error_1.FirebaseError(`Could not find the site ${(0, colorette_1.bold)(siteId)}.`, {
|
|
179
|
+
original: e,
|
|
180
|
+
status: 404,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
logger_1.logger.debug(`[hosting] unable to resolve project for site ${siteId} via site lookup:`, e);
|
|
184
|
+
}
|
|
185
|
+
return (0, projectUtils_1.needProjectId)(options);
|
|
186
|
+
}
|
|
@@ -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
|
@@ -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,18 @@
|
|
|
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
|
+
.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")
|
|
16
|
+
.before(requireConfig_1.requireConfig)
|
|
17
|
+
.before(requirePermissions_1.requirePermissions, deploy_1.TARGET_PERMISSIONS.run)
|
|
18
|
+
.action((serviceId, options) => (0, update_1.updateService)(serviceId, options.region, options));
|