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/lib/hosting/api.js
CHANGED
|
@@ -56,7 +56,7 @@ const apiClient = new apiv2_1.Client({
|
|
|
56
56
|
apiVersion: "v1beta1",
|
|
57
57
|
auth: true,
|
|
58
58
|
});
|
|
59
|
-
async function getChannel(project
|
|
59
|
+
async function getChannel(project, site, channelId) {
|
|
60
60
|
try {
|
|
61
61
|
const res = await apiClient.get(`/projects/${project}/sites/${site}/channels/${channelId}`);
|
|
62
62
|
return res.body;
|
|
@@ -68,7 +68,7 @@ async function getChannel(project = "-", site, channelId) {
|
|
|
68
68
|
throw e;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
async function listChannels(project
|
|
71
|
+
async function listChannels(project, site) {
|
|
72
72
|
const channels = [];
|
|
73
73
|
let nextPageToken = "";
|
|
74
74
|
for (;;) {
|
|
@@ -90,30 +90,30 @@ async function listChannels(project = "-", site) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
async function createChannel(project
|
|
93
|
+
async function createChannel(project, site, channelId, ttlMillis = expireUtils_1.DEFAULT_DURATION) {
|
|
94
94
|
const res = await apiClient.post(`/projects/${project}/sites/${site}/channels?channelId=${channelId}`, { ttl: `${ttlMillis / 1000}s` });
|
|
95
95
|
return res.body;
|
|
96
96
|
}
|
|
97
|
-
async function updateChannelTtl(project
|
|
97
|
+
async function updateChannelTtl(project, site, channelId, ttlMillis = ONE_WEEK_MS) {
|
|
98
98
|
const res = await apiClient.patch(`/projects/${project}/sites/${site}/channels/${channelId}`, { ttl: `${ttlMillis / 1000}s` }, { queryParams: { updateMask: "ttl" } });
|
|
99
99
|
return res.body;
|
|
100
100
|
}
|
|
101
|
-
async function deleteChannel(project
|
|
101
|
+
async function deleteChannel(project, site, channelId) {
|
|
102
102
|
await apiClient.delete(`/projects/${project}/sites/${site}/channels/${channelId}`);
|
|
103
103
|
}
|
|
104
|
-
async function createVersion(siteId, version) {
|
|
105
|
-
const res = await apiClient.post(
|
|
104
|
+
async function createVersion(project, siteId, version) {
|
|
105
|
+
const res = await apiClient.post(`/projects/${project}/sites/${siteId}/versions`, version);
|
|
106
106
|
return res.body.name;
|
|
107
107
|
}
|
|
108
|
-
async function updateVersion(site, versionId, version) {
|
|
109
|
-
const res = await apiClient.patch(
|
|
108
|
+
async function updateVersion(project, site, versionId, version) {
|
|
109
|
+
const res = await apiClient.patch(`/projects/${project}/sites/${site}/versions/${versionId}`, version, {
|
|
110
110
|
queryParams: {
|
|
111
111
|
updateMask: proto.fieldMasks(version, "labels", "config").join(","),
|
|
112
112
|
},
|
|
113
113
|
});
|
|
114
114
|
return res.body;
|
|
115
115
|
}
|
|
116
|
-
async function listVersions(site) {
|
|
116
|
+
async function listVersions(project, site) {
|
|
117
117
|
let pageToken = undefined;
|
|
118
118
|
const versions = [];
|
|
119
119
|
do {
|
|
@@ -121,7 +121,7 @@ async function listVersions(site) {
|
|
|
121
121
|
if (pageToken) {
|
|
122
122
|
queryParams.pageToken = pageToken;
|
|
123
123
|
}
|
|
124
|
-
const res = await apiClient.get(
|
|
124
|
+
const res = await apiClient.get(`/projects/${project}/sites/${site}/versions`, {
|
|
125
125
|
queryParams,
|
|
126
126
|
});
|
|
127
127
|
versions.push(...(res.body.versions ?? []));
|
|
@@ -129,8 +129,8 @@ async function listVersions(site) {
|
|
|
129
129
|
} while (pageToken);
|
|
130
130
|
return versions;
|
|
131
131
|
}
|
|
132
|
-
async function cloneVersion(site, versionName, finalize = false) {
|
|
133
|
-
const res = await apiClient.post(`/projects
|
|
132
|
+
async function cloneVersion(project, site, versionName, finalize = false) {
|
|
133
|
+
const res = await apiClient.post(`/projects/${project}/sites/${site}/versions:clone`, {
|
|
134
134
|
sourceVersion: versionName,
|
|
135
135
|
finalize,
|
|
136
136
|
});
|
|
@@ -143,8 +143,8 @@ async function cloneVersion(site, versionName, finalize = false) {
|
|
|
143
143
|
});
|
|
144
144
|
return pollRes;
|
|
145
145
|
}
|
|
146
|
-
async function createRelease(site, channel, version, partialRelease) {
|
|
147
|
-
const res = await apiClient.post(`/projects
|
|
146
|
+
async function createRelease(project, site, channel, version, partialRelease) {
|
|
147
|
+
const res = await apiClient.post(`/projects/${project}/sites/${site}/channels/${channel}/releases`, partialRelease, { queryParams: { versionName: version } });
|
|
148
148
|
return res.body;
|
|
149
149
|
}
|
|
150
150
|
async function listSites(project) {
|
package/lib/hosting/runTags.js
CHANGED
|
@@ -14,7 +14,7 @@ exports.TODO_TAG_NAME = "this is an invalid tag name so it cannot be real";
|
|
|
14
14
|
async function gcTagsForServices(project, services) {
|
|
15
15
|
const validTagsByServiceByRegion = {};
|
|
16
16
|
const sites = await api.listSites(project);
|
|
17
|
-
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(node_path_1.posix.basename(site.name))));
|
|
17
|
+
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(project, node_path_1.posix.basename(site.name))));
|
|
18
18
|
const activeVersions = [...(0, functional_1.flattenArray)(allVersionsNested)].filter((version) => {
|
|
19
19
|
return version.status === "CREATED" || version.status === "FINALIZED";
|
|
20
20
|
});
|
|
@@ -5,7 +5,11 @@ exports.actuate = actuate;
|
|
|
5
5
|
const clc = require("colorette");
|
|
6
6
|
const prompt_1 = require("../../prompt");
|
|
7
7
|
const logger_1 = require("../../logger");
|
|
8
|
-
|
|
8
|
+
const getDefaultHostingSite_1 = require("../../getDefaultHostingSite");
|
|
9
|
+
const interactive_1 = require("../../hosting/interactive");
|
|
10
|
+
const api_1 = require("../../hosting/api");
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
async function askQuestions(setup, config, options) {
|
|
9
13
|
const authConfig = setup.config.auth;
|
|
10
14
|
const choices = [
|
|
11
15
|
{
|
|
@@ -38,33 +42,67 @@ async function askQuestions(setup) {
|
|
|
38
42
|
if (providers.includes("google")) {
|
|
39
43
|
logger_1.logger.info("");
|
|
40
44
|
logger_1.logger.info("Configuring Google Sign-In...");
|
|
45
|
+
const projectId = setup.projectId;
|
|
46
|
+
const defaultDisplayName = authConfig?.providers?.googleSignIn?.oAuthBrandDisplayName || projectId || "My App";
|
|
41
47
|
const oAuthBrandDisplayName = await (0, prompt_1.input)({
|
|
42
48
|
message: "What display name would you like to use for your OAuth brand?",
|
|
43
|
-
default:
|
|
44
|
-
setup.project?.projectId ||
|
|
45
|
-
"My App",
|
|
49
|
+
default: defaultDisplayName,
|
|
46
50
|
});
|
|
51
|
+
const defaultEmail = authConfig?.providers?.googleSignIn?.supportEmail ||
|
|
52
|
+
(projectId ? `support@${projectId}.firebaseapp.com` : undefined);
|
|
47
53
|
const supportEmail = await (0, prompt_1.input)({
|
|
48
54
|
message: "What support email would you like to register for your OAuth brand?",
|
|
49
|
-
default:
|
|
50
|
-
(setup.project ? `support@${setup.project.projectId}.firebaseapp.com` : undefined),
|
|
55
|
+
default: defaultEmail,
|
|
51
56
|
});
|
|
52
57
|
providersConfig.googleSignIn = {
|
|
53
58
|
oAuthBrandDisplayName,
|
|
54
59
|
supportEmail,
|
|
55
60
|
};
|
|
56
61
|
}
|
|
62
|
+
let newSiteId;
|
|
63
|
+
if (setup.projectId) {
|
|
64
|
+
let existingSite = setup.featureInfo?.hosting?.newSiteId;
|
|
65
|
+
if (!existingSite) {
|
|
66
|
+
try {
|
|
67
|
+
existingSite = await (0, getDefaultHostingSite_1.getDefaultHostingSite)({ projectId: setup.projectId });
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
if (err !== getDefaultHostingSite_1.errNoDefaultSite) {
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (existingSite) {
|
|
76
|
+
logger_1.logger.info(`Firebase Hosting site is present: ${clc.bold(existingSite)}.`);
|
|
77
|
+
}
|
|
78
|
+
else if (await (0, prompt_1.confirm)({
|
|
79
|
+
message: "A Firebase Hosting site is required for Firebase Authentication. Would you like to create a default site now?",
|
|
80
|
+
default: true,
|
|
81
|
+
nonInteractive: options?.nonInteractive,
|
|
82
|
+
})) {
|
|
83
|
+
newSiteId = await (0, interactive_1.pickHostingSiteName)("", {
|
|
84
|
+
projectId: setup.projectId,
|
|
85
|
+
nonInteractive: options?.nonInteractive,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
57
89
|
if (!setup.featureInfo) {
|
|
58
90
|
setup.featureInfo = {};
|
|
59
91
|
}
|
|
60
|
-
setup.featureInfo.auth = { providers: providersConfig };
|
|
92
|
+
setup.featureInfo.auth = { providers: providersConfig, newSiteId };
|
|
61
93
|
}
|
|
62
94
|
async function actuate(setup, config) {
|
|
63
95
|
const authConfig = setup.featureInfo?.auth;
|
|
64
96
|
if (!authConfig) {
|
|
65
97
|
return;
|
|
66
98
|
}
|
|
67
|
-
|
|
99
|
+
if (authConfig.newSiteId && setup.projectId) {
|
|
100
|
+
await (0, api_1.createSite)(setup.projectId, authConfig.newSiteId);
|
|
101
|
+
logger_1.logger.info("");
|
|
102
|
+
(0, utils_1.logSuccess)(`Firebase Hosting site ${authConfig.newSiteId} created!`);
|
|
103
|
+
logger_1.logger.info("");
|
|
104
|
+
}
|
|
105
|
+
config.set("auth", { providers: authConfig.providers });
|
|
68
106
|
config.writeProjectFile("firebase.json", config.src);
|
|
69
107
|
logger_1.logger.info("");
|
|
70
108
|
logger_1.logger.info("Generated firebase.json with auth configuration.");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.agentSkillsActuate = exports.agentSkillsAskQuestions = exports.authActuate = exports.authAskQuestions = exports.aiLogicActuate = exports.aiLogicAskQuestions = exports.aitools = exports.apptestingAcutate = exports.apptestingAskQuestions = exports.genkit = exports.apphosting = exports.dataconnectResolverActuate = exports.dataconnectResolverAskQuestions = exports.dataconnectSdkActuate = exports.dataconnectSdkAskQuestions = exports.dataconnectActuate = exports.dataconnectAskQuestions = exports.hostingGithub = exports.remoteconfig = exports.project = exports.extensions = exports.emulators = exports.storageActuate = exports.storageAskQuestions = exports.hostingActuate = exports.hostingAskQuestions = exports.functionsActuate = exports.functionsAskQuestions = exports.firestoreActuate = exports.firestoreAskQuestions = exports.databaseActuate = exports.databaseAskQuestions = exports.account = void 0;
|
|
3
|
+
exports.runActuate = exports.runAskQuestions = exports.agentSkillsActuate = exports.agentSkillsAskQuestions = exports.authActuate = exports.authAskQuestions = exports.aiLogicActuate = exports.aiLogicAskQuestions = exports.aitools = exports.apptestingAcutate = exports.apptestingAskQuestions = exports.genkit = exports.apphosting = exports.dataconnectResolverActuate = exports.dataconnectResolverAskQuestions = exports.dataconnectSdkActuate = exports.dataconnectSdkAskQuestions = exports.dataconnectActuate = exports.dataconnectAskQuestions = exports.hostingGithub = exports.remoteconfig = exports.project = exports.extensions = exports.emulators = exports.storageActuate = exports.storageAskQuestions = exports.hostingActuate = exports.hostingAskQuestions = exports.functionsActuate = exports.functionsAskQuestions = exports.firestoreActuate = exports.firestoreAskQuestions = exports.databaseActuate = exports.databaseAskQuestions = exports.account = void 0;
|
|
4
4
|
var account_1 = require("./account");
|
|
5
5
|
Object.defineProperty(exports, "account", { enumerable: true, get: function () { return account_1.doSetup; } });
|
|
6
6
|
var database_1 = require("./database");
|
|
@@ -55,3 +55,6 @@ Object.defineProperty(exports, "authActuate", { enumerable: true, get: function
|
|
|
55
55
|
var agentSkills_1 = require("./agentSkills");
|
|
56
56
|
Object.defineProperty(exports, "agentSkillsAskQuestions", { enumerable: true, get: function () { return agentSkills_1.askQuestions; } });
|
|
57
57
|
Object.defineProperty(exports, "agentSkillsActuate", { enumerable: true, get: function () { return agentSkills_1.actuate; } });
|
|
58
|
+
var run_1 = require("./run");
|
|
59
|
+
Object.defineProperty(exports, "runAskQuestions", { enumerable: true, get: function () { return run_1.askQuestions; } });
|
|
60
|
+
Object.defineProperty(exports, "runActuate", { enumerable: true, get: function () { return run_1.actuate; } });
|
|
@@ -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) {
|
|
@@ -28,9 +28,9 @@ function convertInputToValue(inputValue) {
|
|
|
28
28
|
return { arrayValue: arrayValue };
|
|
29
29
|
}
|
|
30
30
|
else if (typeof inputValue === "object") {
|
|
31
|
-
if (
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(inputValue, "latitude") &&
|
|
32
32
|
typeof inputValue.latitude === "number" &&
|
|
33
|
-
|
|
33
|
+
Object.prototype.hasOwnProperty.call(inputValue, "longitude") &&
|
|
34
34
|
typeof inputValue.longitude === "number") {
|
|
35
35
|
return { geoPointValue: inputValue };
|
|
36
36
|
}
|
package/lib/mcp/util.js
CHANGED
|
@@ -114,13 +114,13 @@ function deepClean(obj, isRootLevel = false) {
|
|
|
114
114
|
return obj;
|
|
115
115
|
}
|
|
116
116
|
const cleanedObj = { ...obj };
|
|
117
|
-
if (
|
|
117
|
+
if (Object.prototype.hasOwnProperty.call(cleanedObj, "$schema")) {
|
|
118
118
|
delete cleanedObj.$schema;
|
|
119
119
|
}
|
|
120
|
-
if (
|
|
120
|
+
if (Object.prototype.hasOwnProperty.call(cleanedObj, "additionalProperties")) {
|
|
121
121
|
delete cleanedObj.additionalProperties;
|
|
122
122
|
}
|
|
123
|
-
if (
|
|
123
|
+
if (Object.prototype.hasOwnProperty.call(cleanedObj, "type")) {
|
|
124
124
|
const currentType = cleanedObj.type;
|
|
125
125
|
if (Array.isArray(currentType)) {
|
|
126
126
|
let filteredTypes = currentType.filter((t) => t !== "null");
|
|
@@ -159,12 +159,12 @@ function deepClean(obj, isRootLevel = false) {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
if (
|
|
162
|
+
if (Object.prototype.hasOwnProperty.call(cleanedObj, "properties") &&
|
|
163
163
|
typeof cleanedObj.properties === "object" &&
|
|
164
164
|
cleanedObj.properties !== null) {
|
|
165
165
|
const newProperties = {};
|
|
166
166
|
for (const key in cleanedObj.properties) {
|
|
167
|
-
if (
|
|
167
|
+
if (Object.prototype.hasOwnProperty.call(cleanedObj.properties, key)) {
|
|
168
168
|
const cleanedPropertySchema = deepClean(cleanedObj.properties[key], false);
|
|
169
169
|
if (cleanedPropertySchema !== null) {
|
|
170
170
|
newProperties[key] = cleanedPropertySchema;
|
|
@@ -178,7 +178,7 @@ function deepClean(obj, isRootLevel = false) {
|
|
|
178
178
|
cleanedObj.properties = newProperties;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
if (
|
|
181
|
+
if (Object.prototype.hasOwnProperty.call(cleanedObj, "items") &&
|
|
182
182
|
typeof cleanedObj.items === "object" &&
|
|
183
183
|
cleanedObj.items !== null) {
|
|
184
184
|
const cleanedItemsSchema = deepClean(cleanedObj.items, false);
|
|
@@ -191,12 +191,12 @@ function deepClean(obj, isRootLevel = false) {
|
|
|
191
191
|
}
|
|
192
192
|
const defKeywords = ["$defs", "definitions"];
|
|
193
193
|
for (const keyword of defKeywords) {
|
|
194
|
-
if (
|
|
194
|
+
if (Object.prototype.hasOwnProperty.call(cleanedObj, keyword) &&
|
|
195
195
|
typeof cleanedObj[keyword] === "object" &&
|
|
196
196
|
cleanedObj[keyword] !== null) {
|
|
197
197
|
const newDefs = {};
|
|
198
198
|
for (const defKey in cleanedObj[keyword]) {
|
|
199
|
-
if (cleanedObj[keyword]
|
|
199
|
+
if (Object.prototype.hasOwnProperty.call(cleanedObj[keyword], defKey)) {
|
|
200
200
|
const cleanedDef = deepClean(cleanedObj[keyword][defKey], false);
|
|
201
201
|
if (cleanedDef !== null) {
|
|
202
202
|
newDefs[defKey] = cleanedDef;
|
|
@@ -213,7 +213,8 @@ function deepClean(obj, isRootLevel = false) {
|
|
|
213
213
|
}
|
|
214
214
|
const schemaArrayKeywords = ["anyOf", "allOf", "oneOf"];
|
|
215
215
|
for (const keyword of schemaArrayKeywords) {
|
|
216
|
-
if (
|
|
216
|
+
if (Object.prototype.hasOwnProperty.call(cleanedObj, keyword) &&
|
|
217
|
+
Array.isArray(cleanedObj[keyword])) {
|
|
217
218
|
const newSchemaArray = cleanedObj[keyword]
|
|
218
219
|
.map((subSchema) => deepClean(subSchema, false))
|
|
219
220
|
.filter((subSchema) => subSchema !== null);
|
|
@@ -228,7 +229,7 @@ function deepClean(obj, isRootLevel = false) {
|
|
|
228
229
|
return cleanedObj;
|
|
229
230
|
}
|
|
230
231
|
function cleanSchema(schema) {
|
|
231
|
-
if (schema &&
|
|
232
|
+
if (schema && Object.prototype.hasOwnProperty.call(schema, "type")) {
|
|
232
233
|
const topLevelType = schema.type;
|
|
233
234
|
if (topLevelType === "array") {
|
|
234
235
|
return {};
|
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);
|
|
@@ -120,10 +119,10 @@ class ProfileReport {
|
|
|
120
119
|
opStats.rejected = 0;
|
|
121
120
|
}
|
|
122
121
|
opStats.times += 1;
|
|
123
|
-
if (
|
|
122
|
+
if (Object.prototype.hasOwnProperty.call(data, "millis")) {
|
|
124
123
|
opStats.millis += data.millis;
|
|
125
124
|
}
|
|
126
|
-
if (
|
|
125
|
+
if (Object.prototype.hasOwnProperty.call(data, "pendingTime")) {
|
|
127
126
|
opStats.pendingCount++;
|
|
128
127
|
opStats.pendingTime += data.pendingTime;
|
|
129
128
|
}
|
|
@@ -143,10 +142,10 @@ class ProfileReport {
|
|
|
143
142
|
}
|
|
144
143
|
const node = opType[path];
|
|
145
144
|
node.times += 1;
|
|
146
|
-
if (
|
|
145
|
+
if (Object.prototype.hasOwnProperty.call(data, "millis")) {
|
|
147
146
|
node.millis += data.millis;
|
|
148
147
|
}
|
|
149
|
-
if (
|
|
148
|
+
if (Object.prototype.hasOwnProperty.call(data, "pendingTime")) {
|
|
150
149
|
node.pendingCount++;
|
|
151
150
|
node.pendingTime += data.pendingTime;
|
|
152
151
|
}
|
|
@@ -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;
|