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
|
@@ -0,0 +1,159 @@
|
|
|
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 deploy_1 = require("../../deploy");
|
|
8
|
+
const prereqs_1 = require("../../deploy/run/prereqs");
|
|
9
|
+
const util_1 = require("../../deploy/run/util");
|
|
10
|
+
const error_1 = require("../../error");
|
|
11
|
+
const fsutils_1 = require("../../fsutils");
|
|
12
|
+
const run = require("../../gcp/run");
|
|
13
|
+
const runv2 = require("../../gcp/runv2");
|
|
14
|
+
const prompt_1 = require("../../prompt");
|
|
15
|
+
const requirePermissions_1 = require("../../requirePermissions");
|
|
16
|
+
const utils_1 = require("../../utils");
|
|
17
|
+
const DEFAULT_IGNORE = ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"];
|
|
18
|
+
const SERVICE_ID_REGEX = /^[a-z]([-a-z0-9]{0,47}[a-z0-9])?$/;
|
|
19
|
+
async function askQuestions(setup, config, options) {
|
|
20
|
+
const projectId = setup.projectId;
|
|
21
|
+
if (!projectId) {
|
|
22
|
+
throw new error_1.FirebaseError("Cloud Run requires a Firebase project. Run firebase use --add first.");
|
|
23
|
+
}
|
|
24
|
+
await (0, requirePermissions_1.requirePermissions)({ ...options, projectId }, prereqs_1.RUN_PERMISSIONS);
|
|
25
|
+
await (0, prereqs_1.prereqs)(projectId);
|
|
26
|
+
let existing;
|
|
27
|
+
const action = await (0, prompt_1.select)({
|
|
28
|
+
message: "Please select an option",
|
|
29
|
+
choices: [
|
|
30
|
+
{ name: "Create a new service and deploy", value: "create" },
|
|
31
|
+
{ name: "Update an existing service and deploy", value: "update" },
|
|
32
|
+
],
|
|
33
|
+
default: "create",
|
|
34
|
+
});
|
|
35
|
+
if (action === "update") {
|
|
36
|
+
existing = await promptExistingService(projectId);
|
|
37
|
+
}
|
|
38
|
+
let serviceId;
|
|
39
|
+
let region;
|
|
40
|
+
if (existing) {
|
|
41
|
+
({ region, serviceId } = parseServiceName(existing.name));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
region = await (0, prompt_1.select)({
|
|
45
|
+
message: "Which region should this service be deployed to?",
|
|
46
|
+
choices: await run.listLocations(projectId),
|
|
47
|
+
default: "us-central1",
|
|
48
|
+
});
|
|
49
|
+
serviceId = await promptNewServiceId(projectId, region);
|
|
50
|
+
}
|
|
51
|
+
const savedEntry = findRunEntry(getRunEntries(config), serviceId, region);
|
|
52
|
+
const localBuild = await (0, prompt_1.select)({
|
|
53
|
+
message: "Would you like to build your app locally or remotely?",
|
|
54
|
+
choices: [
|
|
55
|
+
{ name: "Build remotely on Cloud Build", value: false },
|
|
56
|
+
{ name: "Build locally", value: true },
|
|
57
|
+
],
|
|
58
|
+
default: savedEntry?.localBuild === true,
|
|
59
|
+
});
|
|
60
|
+
const rawBaseImage = await (0, prompt_1.input)({
|
|
61
|
+
message: localBuild
|
|
62
|
+
? "Which base image should your app use? (e.g. nodejs20, nodejs22)"
|
|
63
|
+
: "Which base image should your app use, if any? (e.g. nodejs20, nodejs22)",
|
|
64
|
+
default: (0, util_1.mainContainer)(existing?.template)?.baseImageUri,
|
|
65
|
+
validate: (img) => localBuild && !img.trim() ? "Local builds require a base image." : true,
|
|
66
|
+
});
|
|
67
|
+
const baseImage = (rawBaseImage || "").trim();
|
|
68
|
+
const rootDir = await promptRootDir(config.projectDir, savedEntry?.rootDir ?? "/");
|
|
69
|
+
const runInfo = { serviceId, region, baseImage, rootDir };
|
|
70
|
+
if (localBuild) {
|
|
71
|
+
runInfo.localBuild = true;
|
|
72
|
+
}
|
|
73
|
+
setup.featureInfo = { ...setup.featureInfo, run: runInfo };
|
|
74
|
+
}
|
|
75
|
+
async function promptExistingService(projectId) {
|
|
76
|
+
const allServices = await runv2.listServices(projectId, false);
|
|
77
|
+
const services = allServices.filter((s) => !s.labels?.[runv2.CLIENT_NAME_LABEL]);
|
|
78
|
+
if (services.length === 0) {
|
|
79
|
+
(0, utils_1.logBullet)("No Cloud Run services to update. Creating a new service instead.");
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const choices = services.map((service) => {
|
|
83
|
+
const { serviceId, region } = parseServiceName(service.name);
|
|
84
|
+
return { name: `${serviceId} (${region})`, value: service };
|
|
85
|
+
});
|
|
86
|
+
return (0, prompt_1.select)({
|
|
87
|
+
message: "Which service would you like to update?",
|
|
88
|
+
choices,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function parseServiceName(name) {
|
|
92
|
+
const parts = name.split("/");
|
|
93
|
+
return { region: parts[3], serviceId: parts[5] };
|
|
94
|
+
}
|
|
95
|
+
async function promptNewServiceId(projectId, region) {
|
|
96
|
+
return (0, prompt_1.input)({
|
|
97
|
+
message: "Please enter a unique ID for your service",
|
|
98
|
+
validate: async (id) => {
|
|
99
|
+
if (!SERVICE_ID_REGEX.test(id)) {
|
|
100
|
+
return "Use up to 49 lowercase letters, digits, and hyphens, starting with a letter and not ending with a hyphen.";
|
|
101
|
+
}
|
|
102
|
+
const existing = await (0, util_1.getExistingService)(projectId, region, id);
|
|
103
|
+
if (existing) {
|
|
104
|
+
return `A service named ${id} already exists in ${region}.`;
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async function promptRootDir(projectDir, defaultDir) {
|
|
111
|
+
return (0, prompt_1.input)({
|
|
112
|
+
message: "Specify your app's root directory relative to your firebase.json directory",
|
|
113
|
+
default: defaultDir,
|
|
114
|
+
validate: (dir) => {
|
|
115
|
+
const absPath = path.join(projectDir, dir);
|
|
116
|
+
if (!(0, fsutils_1.dirExistsSync)(absPath)) {
|
|
117
|
+
return `Directory ${absPath} does not exist. Please enter a valid directory.`;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async function actuate(setup, config, options) {
|
|
124
|
+
const info = setup.featureInfo?.run;
|
|
125
|
+
if (!info) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const service = { serviceId: info.serviceId, rootDir: info.rootDir, region: info.region };
|
|
129
|
+
if (info.localBuild) {
|
|
130
|
+
upsertRunConfig({ ...service, localBuild: true }, config);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
upsertRunConfig(service, config);
|
|
134
|
+
}
|
|
135
|
+
await (0, deploy_1.deploy)(["run"], { ...options, projectId: setup.projectId, config, only: `run:${(0, util_1.fullServiceName)(info)}` }, { baseImage: info.baseImage || null });
|
|
136
|
+
}
|
|
137
|
+
function upsertRunConfig(service, config) {
|
|
138
|
+
const entries = getRunEntries(config);
|
|
139
|
+
const existing = findRunEntry(entries, service.serviceId, service.region);
|
|
140
|
+
if (existing) {
|
|
141
|
+
existing.rootDir = service.rootDir;
|
|
142
|
+
if (service.localBuild) {
|
|
143
|
+
existing.localBuild = true;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
delete existing.localBuild;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
entries.push({ ...service, ignore: DEFAULT_IGNORE });
|
|
151
|
+
}
|
|
152
|
+
config.set("run", entries.length === 1 ? entries[0] : entries);
|
|
153
|
+
}
|
|
154
|
+
function getRunEntries(config) {
|
|
155
|
+
return [config.src.run ?? []].flat();
|
|
156
|
+
}
|
|
157
|
+
function findRunEntry(entries, serviceId, region) {
|
|
158
|
+
return entries.find((e) => e.serviceId === serviceId && e.region === region);
|
|
159
|
+
}
|
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/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;
|