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
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.askQuestions = askQuestions;
|
|
4
|
+
exports.actuate = actuate;
|
|
5
|
+
exports.upsertRunConfig = upsertRunConfig;
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const app_1 = require("../../apphosting/app");
|
|
8
|
+
const deploy_1 = require("../../deploy");
|
|
9
|
+
const prereqs_1 = require("../../deploy/run/prereqs");
|
|
10
|
+
const util_1 = require("../../deploy/run/util");
|
|
11
|
+
const error_1 = require("../../error");
|
|
12
|
+
const fsutils_1 = require("../../fsutils");
|
|
13
|
+
const run = require("../../gcp/run");
|
|
14
|
+
const runv2 = require("../../gcp/runv2");
|
|
15
|
+
const apps_1 = require("../../management/apps");
|
|
16
|
+
const prompt_1 = require("../../prompt");
|
|
17
|
+
const requirePermissions_1 = require("../../requirePermissions");
|
|
18
|
+
const utils_1 = require("../../utils");
|
|
19
|
+
const DEFAULT_IGNORE = ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"];
|
|
20
|
+
const SERVICE_ID_REGEX = /^[a-z]([-a-z0-9]{0,47}[a-z0-9])?$/;
|
|
21
|
+
async function askQuestions(setup, config, options) {
|
|
22
|
+
const projectId = setup.projectId;
|
|
23
|
+
if (!projectId) {
|
|
24
|
+
throw new error_1.FirebaseError("Cloud Run requires a Firebase project. Run firebase use --add first.");
|
|
25
|
+
}
|
|
26
|
+
await (0, requirePermissions_1.requirePermissions)({ ...options, projectId }, prereqs_1.RUN_PERMISSIONS);
|
|
27
|
+
await (0, prereqs_1.prereqs)(projectId);
|
|
28
|
+
let existing;
|
|
29
|
+
const action = await (0, prompt_1.select)({
|
|
30
|
+
message: "Please select an option",
|
|
31
|
+
choices: [
|
|
32
|
+
{ name: "Create a new service and deploy", value: "create" },
|
|
33
|
+
{ name: "Update an existing service and deploy", value: "update" },
|
|
34
|
+
],
|
|
35
|
+
default: "create",
|
|
36
|
+
});
|
|
37
|
+
if (action === "update") {
|
|
38
|
+
existing = await promptExistingService(projectId);
|
|
39
|
+
}
|
|
40
|
+
let serviceId;
|
|
41
|
+
let region;
|
|
42
|
+
if (existing) {
|
|
43
|
+
({ region, serviceId } = parseServiceName(existing.name));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
region = await (0, prompt_1.select)({
|
|
47
|
+
message: "Which region should this service be deployed to?",
|
|
48
|
+
choices: await run.listLocations(projectId),
|
|
49
|
+
default: "us-central1",
|
|
50
|
+
});
|
|
51
|
+
serviceId = await promptNewServiceId(projectId, region);
|
|
52
|
+
}
|
|
53
|
+
const appId = existing?.annotations?.[util_1.FIREBASE_APP_ANNOTATION] ?? (await promptWebApp(projectId));
|
|
54
|
+
const savedEntry = findRunEntry(getRunEntries(config), serviceId, region);
|
|
55
|
+
const localBuild = await (0, prompt_1.select)({
|
|
56
|
+
message: "Would you like to build your app locally or remotely?",
|
|
57
|
+
choices: [
|
|
58
|
+
{ name: "Build remotely on Cloud Build", value: false },
|
|
59
|
+
{ name: "Build locally", value: true },
|
|
60
|
+
],
|
|
61
|
+
default: savedEntry?.localBuild === true,
|
|
62
|
+
});
|
|
63
|
+
const rawBaseImage = await (0, prompt_1.input)({
|
|
64
|
+
message: localBuild
|
|
65
|
+
? "Which base image should your app use? (e.g. nodejs20, nodejs22)"
|
|
66
|
+
: "Which base image should your app use, if any? (e.g. nodejs20, nodejs22)",
|
|
67
|
+
default: (0, util_1.mainContainer)(existing?.template)?.baseImageUri,
|
|
68
|
+
validate: (img) => localBuild && !img.trim() ? "Local builds require a base image." : true,
|
|
69
|
+
});
|
|
70
|
+
const baseImage = (rawBaseImage || "").trim();
|
|
71
|
+
const rootDir = await promptRootDir(config.projectDir, savedEntry?.rootDir ?? "/");
|
|
72
|
+
const runInfo = { serviceId, region, baseImage, rootDir };
|
|
73
|
+
if (localBuild) {
|
|
74
|
+
runInfo.localBuild = true;
|
|
75
|
+
}
|
|
76
|
+
if (appId) {
|
|
77
|
+
runInfo.appId = appId;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
runInfo.createWebApp = true;
|
|
81
|
+
}
|
|
82
|
+
setup.featureInfo = { ...setup.featureInfo, run: runInfo };
|
|
83
|
+
}
|
|
84
|
+
async function promptWebApp(projectId) {
|
|
85
|
+
const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.WEB);
|
|
86
|
+
if (!apps.length) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
const choice = await (0, prompt_1.select)({
|
|
90
|
+
message: "Which Firebase web app should this service use for Firebase SDK auto-initialization?",
|
|
91
|
+
choices: [
|
|
92
|
+
{ name: "Create a new web app", value: app_1.webApps.CREATE_NEW_FIREBASE_WEB_APP },
|
|
93
|
+
...apps.map((app) => ({
|
|
94
|
+
name: app.displayName ? `${app.displayName} (${app.appId})` : app.appId,
|
|
95
|
+
value: app.appId,
|
|
96
|
+
})),
|
|
97
|
+
],
|
|
98
|
+
default: app_1.webApps.CREATE_NEW_FIREBASE_WEB_APP,
|
|
99
|
+
});
|
|
100
|
+
return choice === app_1.webApps.CREATE_NEW_FIREBASE_WEB_APP ? undefined : choice;
|
|
101
|
+
}
|
|
102
|
+
async function promptExistingService(projectId) {
|
|
103
|
+
const allServices = await runv2.listServices(projectId, false);
|
|
104
|
+
const services = allServices.filter((s) => !s.labels?.[runv2.CLIENT_NAME_LABEL]);
|
|
105
|
+
if (services.length === 0) {
|
|
106
|
+
(0, utils_1.logBullet)("No Cloud Run services to update. Creating a new service instead.");
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const choices = services.map((service) => {
|
|
110
|
+
const { serviceId, region } = parseServiceName(service.name);
|
|
111
|
+
return { name: `${serviceId} (${region})`, value: service };
|
|
112
|
+
});
|
|
113
|
+
return (0, prompt_1.select)({
|
|
114
|
+
message: "Which service would you like to update?",
|
|
115
|
+
choices,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function parseServiceName(name) {
|
|
119
|
+
const parts = name.split("/");
|
|
120
|
+
return { region: parts[3], serviceId: parts[5] };
|
|
121
|
+
}
|
|
122
|
+
async function promptNewServiceId(projectId, region) {
|
|
123
|
+
return (0, prompt_1.input)({
|
|
124
|
+
message: "Please enter a unique ID for your service",
|
|
125
|
+
validate: async (id) => {
|
|
126
|
+
if (!SERVICE_ID_REGEX.test(id)) {
|
|
127
|
+
return "Use up to 49 lowercase letters, digits, and hyphens, starting with a letter and not ending with a hyphen.";
|
|
128
|
+
}
|
|
129
|
+
const existing = await (0, util_1.getExistingService)(projectId, region, id);
|
|
130
|
+
if (existing) {
|
|
131
|
+
return `A service named ${id} already exists in ${region}.`;
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
async function promptRootDir(projectDir, defaultDir) {
|
|
138
|
+
return (0, prompt_1.input)({
|
|
139
|
+
message: "Specify your app's root directory relative to your firebase.json directory",
|
|
140
|
+
default: defaultDir,
|
|
141
|
+
validate: (dir) => {
|
|
142
|
+
const absPath = path.join(projectDir, dir);
|
|
143
|
+
if (!(0, fsutils_1.dirExistsSync)(absPath)) {
|
|
144
|
+
return `Directory ${absPath} does not exist. Please enter a valid directory.`;
|
|
145
|
+
}
|
|
146
|
+
return true;
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
async function actuate(setup, config, options) {
|
|
151
|
+
const info = setup.featureInfo?.run;
|
|
152
|
+
if (!info) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const service = { serviceId: info.serviceId, rootDir: info.rootDir, region: info.region };
|
|
156
|
+
if (info.localBuild) {
|
|
157
|
+
upsertRunConfig({ ...service, localBuild: true }, config);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
upsertRunConfig(service, config);
|
|
161
|
+
}
|
|
162
|
+
const settings = { baseImage: info.baseImage || null };
|
|
163
|
+
let appId = info.appId;
|
|
164
|
+
if (info.createWebApp) {
|
|
165
|
+
appId = (await app_1.webApps.getOrCreateWebApp(setup.projectId, null, info.serviceId))?.id;
|
|
166
|
+
if (!appId) {
|
|
167
|
+
throw new error_1.FirebaseError(`Couldn't create a Firebase web app for service ${info.serviceId}. Delete an unused web ` +
|
|
168
|
+
`app in the Firebase console, or run "firebase init run" again and pick an existing app.`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (appId) {
|
|
172
|
+
settings.appId = appId;
|
|
173
|
+
}
|
|
174
|
+
await (0, deploy_1.deploy)(["run"], { ...options, projectId: setup.projectId, config, only: `run:${(0, util_1.fullServiceName)(info)}` }, settings);
|
|
175
|
+
}
|
|
176
|
+
function upsertRunConfig(service, config) {
|
|
177
|
+
const entries = getRunEntries(config);
|
|
178
|
+
const existing = findRunEntry(entries, service.serviceId, service.region);
|
|
179
|
+
if (existing) {
|
|
180
|
+
existing.rootDir = service.rootDir;
|
|
181
|
+
if (service.localBuild) {
|
|
182
|
+
existing.localBuild = true;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
delete existing.localBuild;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
entries.push({ ...service, ignore: DEFAULT_IGNORE });
|
|
190
|
+
}
|
|
191
|
+
config.set("run", entries.length === 1 ? entries[0] : entries);
|
|
192
|
+
}
|
|
193
|
+
function getRunEntries(config) {
|
|
194
|
+
return [config.src.run ?? []].flat();
|
|
195
|
+
}
|
|
196
|
+
function findRunEntry(entries, serviceId, region) {
|
|
197
|
+
return entries.find((e) => e.serviceId === serviceId && e.region === region);
|
|
198
|
+
}
|
package/lib/init/index.js
CHANGED
|
@@ -80,6 +80,12 @@ const featuresList = [
|
|
|
80
80
|
askQuestions: features.agentSkillsAskQuestions,
|
|
81
81
|
actuate: features.agentSkillsActuate,
|
|
82
82
|
},
|
|
83
|
+
{
|
|
84
|
+
name: "run",
|
|
85
|
+
displayName: "Cloud Run",
|
|
86
|
+
askQuestions: features.runAskQuestions,
|
|
87
|
+
actuate: features.runActuate,
|
|
88
|
+
},
|
|
83
89
|
];
|
|
84
90
|
const featureMap = new Map(featuresList.map((feature) => [feature.name, feature]));
|
|
85
91
|
async function init(setup, config, options) {
|
package/lib/mcp/index.js
CHANGED
|
@@ -97,7 +97,6 @@ class FirebaseMcpServer {
|
|
|
97
97
|
this.currentLogLevel = params.level;
|
|
98
98
|
return {};
|
|
99
99
|
});
|
|
100
|
-
void this.detectProjectSetup();
|
|
101
100
|
}
|
|
102
101
|
ready() {
|
|
103
102
|
if (this._ready)
|
|
@@ -238,8 +237,19 @@ class FirebaseMcpServer {
|
|
|
238
237
|
}
|
|
239
238
|
_getFirebaseCliCommand() {
|
|
240
239
|
if (!this.cliCommand) {
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
try {
|
|
241
|
+
const testCommand = crossSpawn.sync(FirebaseMcpServer.DEFAULT_FIREBASE_CLI_COMMAND, ["--version"], {
|
|
242
|
+
timeout: FirebaseMcpServer.CLI_VERSION_CHECK_TIMEOUT_MS,
|
|
243
|
+
stdio: "ignore",
|
|
244
|
+
});
|
|
245
|
+
this.cliCommand =
|
|
246
|
+
testCommand.error || testCommand.status !== 0
|
|
247
|
+
? FirebaseMcpServer.FALLBACK_FIREBASE_CLI_COMMAND
|
|
248
|
+
: FirebaseMcpServer.DEFAULT_FIREBASE_CLI_COMMAND;
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
this.cliCommand = FirebaseMcpServer.FALLBACK_FIREBASE_CLI_COMMAND;
|
|
252
|
+
}
|
|
243
253
|
}
|
|
244
254
|
return this.cliCommand;
|
|
245
255
|
}
|
|
@@ -391,6 +401,9 @@ class FirebaseMcpServer {
|
|
|
391
401
|
return resolved.result;
|
|
392
402
|
}
|
|
393
403
|
async start(options) {
|
|
404
|
+
void this.detectProjectSetup().catch((err) => {
|
|
405
|
+
this.logger.error(`Failed to detect project setup: ${err instanceof Error ? err.message : String(err)}`);
|
|
406
|
+
});
|
|
394
407
|
if (options?.useSSE) {
|
|
395
408
|
const app = express();
|
|
396
409
|
app.use(cors());
|
|
@@ -492,3 +505,6 @@ class FirebaseMcpServer {
|
|
|
492
505
|
}
|
|
493
506
|
}
|
|
494
507
|
exports.FirebaseMcpServer = FirebaseMcpServer;
|
|
508
|
+
FirebaseMcpServer.CLI_VERSION_CHECK_TIMEOUT_MS = 2000;
|
|
509
|
+
FirebaseMcpServer.DEFAULT_FIREBASE_CLI_COMMAND = "firebase";
|
|
510
|
+
FirebaseMcpServer.FALLBACK_FIREBASE_CLI_COMMAND = "npx firebase-tools@latest";
|
package/lib/profileReport.js
CHANGED
|
@@ -13,7 +13,6 @@ const _ = require("lodash");
|
|
|
13
13
|
const readline = require("readline");
|
|
14
14
|
const error_1 = require("./error");
|
|
15
15
|
const logger_1 = require("./logger");
|
|
16
|
-
const DATA_LINE_REGEX = /^data: /;
|
|
17
16
|
const BANDWIDTH_NOTE = "NOTE: The numbers reported here are only estimates of the data" +
|
|
18
17
|
" payloads from read operations. They are NOT a valid measure of your bandwidth bill.";
|
|
19
18
|
const SPEED_NOTE = "NOTE: Speeds are reported at millisecond resolution and" +
|
|
@@ -24,11 +23,11 @@ const SPEED_NOTE = "NOTE: Speeds are reported at millisecond resolution and" +
|
|
|
24
23
|
const COLLAPSE_THRESHOLD = 25;
|
|
25
24
|
const COLLAPSE_WILDCARD = ["$wildcard"];
|
|
26
25
|
function extractJSON(line, input) {
|
|
27
|
-
if (!input && !
|
|
26
|
+
if (!input && !line.startsWith("data: ")) {
|
|
28
27
|
return null;
|
|
29
28
|
}
|
|
30
29
|
else if (!input) {
|
|
31
|
-
line = line.substring(
|
|
30
|
+
line = line.substring(6);
|
|
32
31
|
}
|
|
33
32
|
try {
|
|
34
33
|
return JSON.parse(line);
|
|
@@ -466,8 +465,12 @@ class ProfileReport {
|
|
|
466
465
|
}
|
|
467
466
|
}
|
|
468
467
|
});
|
|
469
|
-
rl.on("error", () => {
|
|
470
|
-
reject(
|
|
468
|
+
rl.on("error", (err) => {
|
|
469
|
+
reject(err instanceof Error
|
|
470
|
+
? err
|
|
471
|
+
: new error_1.FirebaseError("There was an error creating the report.", {
|
|
472
|
+
original: err,
|
|
473
|
+
}));
|
|
471
474
|
});
|
|
472
475
|
outStream.on("error", () => {
|
|
473
476
|
errored = true;
|