firebase-tools 15.34.0 → 15.34.2
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/lib/auth.js +10 -5
- package/lib/commands/apps-android-sha-create.js +1 -1
- package/lib/commands/apps-android-sha-delete.js +1 -1
- package/lib/commands/apps-android-sha-list.js +1 -1
- package/lib/commands/deploy.js +4 -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 +14 -0
- 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 +2 -4
- package/lib/commands/run-services-update.js +2 -0
- package/lib/crashlytics/alerts.js +1 -11
- package/lib/crashlytics/onboarding.js +15 -19
- package/lib/deploy/functions/params.js +1 -0
- package/lib/deploy/functions/release/fabricator.js +6 -3
- package/lib/deploy/hosting/prepare.js +3 -0
- package/lib/deploy/run/deploy.js +36 -8
- package/lib/deploy/run/prepare.js +54 -2
- package/lib/deploy/run/update.js +2 -1
- package/lib/deploy/run/util.js +2 -0
- package/lib/emulator/auth/cloudFunctions.js +47 -18
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/firestoreEmulator.js +5 -0
- package/lib/emulator/functionsEmulator.js +22 -7
- package/lib/emulator/pubsubEmulator.js +64 -11
- package/lib/emulator/storage/rules/manager.js +31 -15
- package/lib/emulator/taskQueue.js +5 -4
- package/lib/experiments.js +0 -10
- package/lib/extensions/emulator/specHelper.js +0 -4
- package/lib/extensions/extensionsHelper.js +0 -49
- package/lib/extensions/runtimes/common.js +0 -12
- package/lib/extensions/updateHelper.js +2 -88
- package/lib/frameworks/angular/utils.js +3 -2
- package/lib/gcp/cloudlogging.js +0 -54
- package/lib/init/features/aitools/promptUpdater.js +3 -2
- package/lib/init/features/run.js +40 -1
- package/lib/mcp/errors.js +1 -1
- package/lib/mcp/index.js +19 -3
- package/lib/mcp/util/dataconnect/converter.js +0 -29
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +15 -5
- package/lib/apphosting/repo.js +0 -243
|
@@ -6,7 +6,6 @@ exports.getFirebaseProjectParams = getFirebaseProjectParams;
|
|
|
6
6
|
exports.substituteParams = substituteParams;
|
|
7
7
|
exports.substituteSecretParams = substituteSecretParams;
|
|
8
8
|
exports.populateDefaultParams = populateDefaultParams;
|
|
9
|
-
exports.validateCommandLineParams = validateCommandLineParams;
|
|
10
9
|
exports.validateSpec = validateSpec;
|
|
11
10
|
exports.promptForValidInstanceId = promptForValidInstanceId;
|
|
12
11
|
exports.promptForValidRepoURI = promptForValidRepoURI;
|
|
@@ -23,7 +22,6 @@ exports.createSourceFromLocation = createSourceFromLocation;
|
|
|
23
22
|
exports.getPublisherProjectFromName = getPublisherProjectFromName;
|
|
24
23
|
exports.displayReleaseNotes = displayReleaseNotes;
|
|
25
24
|
exports.promptForRepeatInstance = promptForRepeatInstance;
|
|
26
|
-
exports.instanceIdExists = instanceIdExists;
|
|
27
25
|
exports.isUrlPath = isUrlPath;
|
|
28
26
|
exports.isLocalPath = isLocalPath;
|
|
29
27
|
exports.isLocalOrURLPath = isLocalOrURLPath;
|
|
@@ -47,7 +45,6 @@ const functionsConfig_1 = require("../functionsConfig");
|
|
|
47
45
|
const adminSdkConfig_1 = require("../emulator/adminSdkConfig");
|
|
48
46
|
const error_1 = require("../error");
|
|
49
47
|
const diagnose_1 = require("./diagnose");
|
|
50
|
-
const askUserForParam_1 = require("./askUserForParam");
|
|
51
48
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
52
49
|
const storage_1 = require("../gcp/storage");
|
|
53
50
|
const projectUtils_1 = require("../projectUtils");
|
|
@@ -82,13 +79,6 @@ exports.logPrefix = "extensions";
|
|
|
82
79
|
const VALID_LICENSES = ["apache-2.0"];
|
|
83
80
|
exports.URL_REGEX = /^https:/;
|
|
84
81
|
exports.EXTENSIONS_BUCKET_NAME = (0, utils_1.envOverride)("FIREBASE_EXTENSIONS_UPLOAD_BUCKET", "firebase-ext-eap-uploads");
|
|
85
|
-
const AUTOPOPULATED_PARAM_NAMES = [
|
|
86
|
-
"PROJECT_ID",
|
|
87
|
-
"STORAGE_BUCKET",
|
|
88
|
-
"EXT_INSTANCE_ID",
|
|
89
|
-
"DATABASE_INSTANCE",
|
|
90
|
-
"DATABASE_URL",
|
|
91
|
-
];
|
|
92
82
|
exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = {
|
|
93
83
|
PROJECT_ID: "project-id",
|
|
94
84
|
STORAGE_BUCKET: "project-id.appspot.com",
|
|
@@ -185,25 +175,6 @@ function populateDefaultParams(paramVars, paramSpecs) {
|
|
|
185
175
|
}
|
|
186
176
|
return newParams;
|
|
187
177
|
}
|
|
188
|
-
function validateCommandLineParams(envVars, paramSpec) {
|
|
189
|
-
const paramNames = paramSpec.map((p) => p.param);
|
|
190
|
-
const misnamedParams = Object.keys(envVars).filter((key) => {
|
|
191
|
-
return !paramNames.includes(key) && !AUTOPOPULATED_PARAM_NAMES.includes(key);
|
|
192
|
-
});
|
|
193
|
-
if (misnamedParams.length) {
|
|
194
|
-
logger_1.logger.warn("Warning: The following params were specified in your env file but do not exist in the extension spec: " +
|
|
195
|
-
`${misnamedParams.join(", ")}.`);
|
|
196
|
-
}
|
|
197
|
-
let allParamsValid = true;
|
|
198
|
-
for (const param of paramSpec) {
|
|
199
|
-
if (!(0, askUserForParam_1.checkResponse)(envVars[param.param], param)) {
|
|
200
|
-
allParamsValid = false;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (!allParamsValid) {
|
|
204
|
-
throw new error_1.FirebaseError(`Some param values are not valid. Please check your params file.`);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
178
|
function validateSpec(spec) {
|
|
208
179
|
const errors = [];
|
|
209
180
|
if (!spec.name) {
|
|
@@ -799,26 +770,6 @@ async function promptForRepeatInstance(projectName, extensionName) {
|
|
|
799
770
|
],
|
|
800
771
|
});
|
|
801
772
|
}
|
|
802
|
-
async function instanceIdExists(projectId, instanceId) {
|
|
803
|
-
try {
|
|
804
|
-
await (0, extensionsApi_1.getInstance)(projectId, instanceId);
|
|
805
|
-
}
|
|
806
|
-
catch (err) {
|
|
807
|
-
if (err instanceof error_1.FirebaseError) {
|
|
808
|
-
if (err.status === 404) {
|
|
809
|
-
return false;
|
|
810
|
-
}
|
|
811
|
-
const msg = `Unexpected error when checking if instance ID exists: ${err.message}`;
|
|
812
|
-
throw new error_1.FirebaseError(msg, {
|
|
813
|
-
original: err,
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
else {
|
|
817
|
-
throw err;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
return true;
|
|
821
|
-
}
|
|
822
773
|
function isUrlPath(extInstallPath) {
|
|
823
774
|
return extInstallPath.startsWith("https:");
|
|
824
775
|
}
|
|
@@ -11,9 +11,7 @@ exports.writeSDK = writeSDK;
|
|
|
11
11
|
exports.getCodebaseDir = getCodebaseDir;
|
|
12
12
|
exports.getInstallPathPrefix = getInstallPathPrefix;
|
|
13
13
|
exports.toTitleCase = toTitleCase;
|
|
14
|
-
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
15
14
|
exports.lowercaseFirstLetter = lowercaseFirstLetter;
|
|
16
|
-
exports.snakeToCamelCase = snakeToCamelCase;
|
|
17
15
|
exports.longestCommonPrefix = longestCommonPrefix;
|
|
18
16
|
const fs = require("fs");
|
|
19
17
|
const path = require("path");
|
|
@@ -186,19 +184,9 @@ function getInstallPathPrefix(options) {
|
|
|
186
184
|
function toTitleCase(txt) {
|
|
187
185
|
return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
|
|
188
186
|
}
|
|
189
|
-
function capitalizeFirstLetter(txt) {
|
|
190
|
-
return txt.charAt(0).toUpperCase() + txt.substring(1);
|
|
191
|
-
}
|
|
192
187
|
function lowercaseFirstLetter(txt) {
|
|
193
188
|
return txt.charAt(0).toLowerCase() + txt.substring(1);
|
|
194
189
|
}
|
|
195
|
-
function snakeToCamelCase(txt) {
|
|
196
|
-
let ret = txt.toLowerCase();
|
|
197
|
-
ret = ret.replace(/_/g, " ");
|
|
198
|
-
ret = ret.replace(/\w\S*/g, toTitleCase);
|
|
199
|
-
ret = ret.charAt(0).toLowerCase() + ret.substring(1);
|
|
200
|
-
return ret;
|
|
201
|
-
}
|
|
202
190
|
function longestCommonPrefix(arr) {
|
|
203
191
|
if (arr.length === 0) {
|
|
204
192
|
return "";
|
|
@@ -1,59 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExistingSourceOrigin = getExistingSourceOrigin;
|
|
4
|
-
exports.warningUpdateToOtherSource = warningUpdateToOtherSource;
|
|
5
3
|
exports.update = update;
|
|
6
|
-
exports.updateFromLocalSource = updateFromLocalSource;
|
|
7
|
-
exports.updateFromUrlSource = updateFromUrlSource;
|
|
8
4
|
exports.inferUpdateSource = inferUpdateSource;
|
|
9
|
-
const clc = require("colorette");
|
|
10
5
|
const semver = require("semver");
|
|
11
6
|
const error_1 = require("../error");
|
|
12
|
-
const logger_1 = require("../logger");
|
|
13
7
|
const extensionsApi = require("./extensionsApi");
|
|
14
8
|
const extensionsHelper_1 = require("./extensionsHelper");
|
|
15
|
-
const utils = require("../utils");
|
|
16
|
-
const displayExtensionInfo_1 = require("./displayExtensionInfo");
|
|
17
|
-
function invalidSourceErrMsgTemplate(instanceId, source) {
|
|
18
|
-
return `Unable to update from the source \`${clc.bold(source)}\`. To update this instance, you can either:\n
|
|
19
|
-
- Run \`${clc.bold("firebase ext:update " + instanceId)}\` to update from the published source.\n
|
|
20
|
-
- Check your directory path or URL, then run \`${clc.bold("firebase ext:update " + instanceId + " <otherSource>")}\` to update from a local directory or URL source.`;
|
|
21
|
-
}
|
|
22
|
-
async function getExistingSourceOrigin(projectId, instanceId) {
|
|
23
|
-
const instance = await extensionsApi.getInstance(projectId, instanceId);
|
|
24
|
-
return instance && instance.config.extensionRef
|
|
25
|
-
? extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION
|
|
26
|
-
: extensionsHelper_1.SourceOrigin.LOCAL;
|
|
27
|
-
}
|
|
28
|
-
function showUpdateVersionInfo(instanceId, from, to, source) {
|
|
29
|
-
if (source) {
|
|
30
|
-
source = clc.bold(source);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
source = "version";
|
|
34
|
-
}
|
|
35
|
-
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `Updating ${clc.bold(instanceId)} from version ${clc.bold(from)} to ${source} (${clc.bold(to)})`);
|
|
36
|
-
if (semver.lt(to, from)) {
|
|
37
|
-
utils.logLabeledWarning(extensionsHelper_1.logPrefix, "The version you are updating to is less than the current version for this extension. This extension may not be backwards compatible.");
|
|
38
|
-
}
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
function warningUpdateToOtherSource(sourceOrigin) {
|
|
42
|
-
let targetText;
|
|
43
|
-
if ([extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION, extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION_VERSION].includes(sourceOrigin)) {
|
|
44
|
-
targetText = "published extension";
|
|
45
|
-
}
|
|
46
|
-
else if (sourceOrigin === extensionsHelper_1.SourceOrigin.LOCAL) {
|
|
47
|
-
targetText = "local directory";
|
|
48
|
-
}
|
|
49
|
-
else if (sourceOrigin === extensionsHelper_1.SourceOrigin.URL) {
|
|
50
|
-
targetText = "URL";
|
|
51
|
-
}
|
|
52
|
-
const warning = `All the instance's resources and logic will be overwritten to use the source code and files from the ${targetText}.\n`;
|
|
53
|
-
logger_1.logger.info(warning);
|
|
54
|
-
}
|
|
55
9
|
async function update(updateOptions) {
|
|
56
|
-
const { projectId, instanceId,
|
|
10
|
+
const { projectId, instanceId, extRef, params, systemParams, canEmitEvents, allowedEventTypes, eventarcChannel, } = updateOptions;
|
|
57
11
|
if (extRef) {
|
|
58
12
|
return await extensionsApi.updateInstanceFromRegistry({
|
|
59
13
|
projectId,
|
|
@@ -66,47 +20,7 @@ async function update(updateOptions) {
|
|
|
66
20
|
eventarcChannel,
|
|
67
21
|
});
|
|
68
22
|
}
|
|
69
|
-
|
|
70
|
-
return await extensionsApi.updateInstance({
|
|
71
|
-
projectId,
|
|
72
|
-
instanceId,
|
|
73
|
-
extensionSource: source,
|
|
74
|
-
params,
|
|
75
|
-
systemParams,
|
|
76
|
-
canEmitEvents,
|
|
77
|
-
allowedEventTypes,
|
|
78
|
-
eventarcChannel,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
throw new error_1.FirebaseError(`Neither a source nor a version of the extension was supplied for ${instanceId}. Please make sure this is a valid extension and try again.`);
|
|
82
|
-
}
|
|
83
|
-
async function updateFromLocalSource(projectId, instanceId, localSource, existingSpec) {
|
|
84
|
-
await (0, displayExtensionInfo_1.displayExtensionVersionInfo)({ spec: existingSpec });
|
|
85
|
-
let source;
|
|
86
|
-
try {
|
|
87
|
-
source = await (0, extensionsHelper_1.createSourceFromLocation)(projectId, localSource);
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
throw new error_1.FirebaseError(invalidSourceErrMsgTemplate(instanceId, localSource));
|
|
91
|
-
}
|
|
92
|
-
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `${clc.bold("You are updating this extension instance to a local source.")}`);
|
|
93
|
-
showUpdateVersionInfo(instanceId, existingSpec.version, source.spec.version, localSource);
|
|
94
|
-
warningUpdateToOtherSource(extensionsHelper_1.SourceOrigin.LOCAL);
|
|
95
|
-
return source.name;
|
|
96
|
-
}
|
|
97
|
-
async function updateFromUrlSource(projectId, instanceId, urlSource, existingSpec) {
|
|
98
|
-
await (0, displayExtensionInfo_1.displayExtensionVersionInfo)({ spec: existingSpec });
|
|
99
|
-
let source;
|
|
100
|
-
try {
|
|
101
|
-
source = await (0, extensionsHelper_1.createSourceFromLocation)(projectId, urlSource);
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
throw new error_1.FirebaseError(invalidSourceErrMsgTemplate(instanceId, urlSource));
|
|
105
|
-
}
|
|
106
|
-
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `${clc.bold("You are updating this extension instance to a URL source.")}`);
|
|
107
|
-
showUpdateVersionInfo(instanceId, existingSpec.version, source.spec.version, urlSource);
|
|
108
|
-
warningUpdateToOtherSource(extensionsHelper_1.SourceOrigin.URL);
|
|
109
|
-
return source.name;
|
|
23
|
+
throw new error_1.FirebaseError(`A version of the extension was not supplied for ${instanceId}. Please make sure this is a valid extension and try again.`);
|
|
110
24
|
}
|
|
111
25
|
function inferUpdateSource(updateSource, existingRef) {
|
|
112
26
|
if (!updateSource) {
|
|
@@ -207,9 +207,10 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
if (deployTarget) {
|
|
210
|
+
const target = deployTarget;
|
|
210
211
|
const options = await architectHost
|
|
211
|
-
.getOptionsForTarget(
|
|
212
|
-
.catch(() => workspaceProject.targets.get(
|
|
212
|
+
.getOptionsForTarget(target)
|
|
213
|
+
.catch(() => workspaceProject.targets.get(target.target)?.options);
|
|
213
214
|
if (!options)
|
|
214
215
|
throw new error_1.FirebaseError("Unable to get options for ng-deploy.");
|
|
215
216
|
if (options.buildTarget) {
|
package/lib/gcp/cloudlogging.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listEntries = listEntries;
|
|
4
|
-
exports.createOrUpdateLogBucket = createOrUpdateLogBucket;
|
|
5
|
-
exports.createOrUpdateLogSink = createOrUpdateLogSink;
|
|
6
4
|
const api_1 = require("../api");
|
|
7
5
|
const apiv2_1 = require("../apiv2");
|
|
8
6
|
const error_1 = require("../error");
|
|
@@ -31,55 +29,3 @@ async function listEntries(projectId, filter, pageSize, order, pageToken) {
|
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
async function createOrUpdateLogBucket(projectId, bucketId, location = "global", analyticsEnabled = true) {
|
|
35
|
-
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudloggingOrigin)(), apiVersion: API_VERSION });
|
|
36
|
-
const path = `/projects/${projectId}/locations/${location}/buckets`;
|
|
37
|
-
try {
|
|
38
|
-
const res = await client.post(`${path}?bucketId=${bucketId}`, { analyticsEnabled });
|
|
39
|
-
return res.body;
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
if (err.status === 409) {
|
|
43
|
-
try {
|
|
44
|
-
const patchRes = await client.patch(`${path}/${bucketId}?updateMask=analyticsEnabled`, { analyticsEnabled });
|
|
45
|
-
return patchRes.body;
|
|
46
|
-
}
|
|
47
|
-
catch (patchErr) {
|
|
48
|
-
const msg = patchErr.message || JSON.stringify(patchErr.body) || patchErr;
|
|
49
|
-
throw new error_1.FirebaseError(`Failed to patch log bucket ${bucketId} (status ${patchErr.status}): ${msg}`, { original: patchErr });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const msg = err.message || JSON.stringify(err.body) || err;
|
|
53
|
-
if (typeof msg === "string" && msg.toLowerCase().includes("billing account")) {
|
|
54
|
-
throw new error_1.FirebaseError(`Creating a Cloud Logging bucket requires a valid linked billing account (Blaze plan). Please attach a billing account to project ${projectId} and try again.`, { original: err });
|
|
55
|
-
}
|
|
56
|
-
throw new error_1.FirebaseError(`Failed to create or update log bucket ${bucketId} (status ${err.status}): ${msg}`, { original: err });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function createOrUpdateLogSink(projectId, sinkName, destination, filter) {
|
|
60
|
-
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.cloudloggingOrigin)(), apiVersion: API_VERSION });
|
|
61
|
-
const path = `/projects/${projectId}/sinks`;
|
|
62
|
-
const body = {
|
|
63
|
-
name: sinkName,
|
|
64
|
-
destination,
|
|
65
|
-
filter,
|
|
66
|
-
};
|
|
67
|
-
try {
|
|
68
|
-
const res = await client.post(path, body);
|
|
69
|
-
return res.body;
|
|
70
|
-
}
|
|
71
|
-
catch (err) {
|
|
72
|
-
if (err.status === 409) {
|
|
73
|
-
try {
|
|
74
|
-
const putRes = await client.put(`${path}/${sinkName}`, body);
|
|
75
|
-
return putRes.body;
|
|
76
|
-
}
|
|
77
|
-
catch (putErr) {
|
|
78
|
-
const msg = putErr.message || JSON.stringify(putErr.body) || putErr;
|
|
79
|
-
throw new error_1.FirebaseError(`Failed to update log sink ${sinkName} (status ${putErr.status}): ${msg}`, { original: putErr });
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const msg = err.message || JSON.stringify(err.body) || err;
|
|
83
|
-
throw new error_1.FirebaseError(`Failed to create or update log sink ${sinkName} (status ${err.status}): ${msg}`, { original: err });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -66,10 +66,11 @@ async function updateFirebaseSection(config, filePath, enabledFeatures, options)
|
|
|
66
66
|
finalContent = options?.header ? `${options.header}\n\n${newSection}` : newSection;
|
|
67
67
|
}
|
|
68
68
|
else if (match) {
|
|
69
|
+
const start = match.index;
|
|
69
70
|
finalContent =
|
|
70
|
-
currentContent.substring(0,
|
|
71
|
+
currentContent.substring(0, start) +
|
|
71
72
|
newSection +
|
|
72
|
-
currentContent.substring(
|
|
73
|
+
currentContent.substring(start + match[0].length);
|
|
73
74
|
}
|
|
74
75
|
else {
|
|
75
76
|
const separator = currentContent.endsWith("\n") ? "\n" : "\n\n";
|
package/lib/init/features/run.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.askQuestions = askQuestions;
|
|
|
4
4
|
exports.actuate = actuate;
|
|
5
5
|
exports.upsertRunConfig = upsertRunConfig;
|
|
6
6
|
const path = require("path");
|
|
7
|
+
const app_1 = require("../../apphosting/app");
|
|
7
8
|
const deploy_1 = require("../../deploy");
|
|
8
9
|
const prereqs_1 = require("../../deploy/run/prereqs");
|
|
9
10
|
const util_1 = require("../../deploy/run/util");
|
|
@@ -11,6 +12,7 @@ const error_1 = require("../../error");
|
|
|
11
12
|
const fsutils_1 = require("../../fsutils");
|
|
12
13
|
const run = require("../../gcp/run");
|
|
13
14
|
const runv2 = require("../../gcp/runv2");
|
|
15
|
+
const apps_1 = require("../../management/apps");
|
|
14
16
|
const prompt_1 = require("../../prompt");
|
|
15
17
|
const requirePermissions_1 = require("../../requirePermissions");
|
|
16
18
|
const utils_1 = require("../../utils");
|
|
@@ -48,6 +50,7 @@ async function askQuestions(setup, config, options) {
|
|
|
48
50
|
});
|
|
49
51
|
serviceId = await promptNewServiceId(projectId, region);
|
|
50
52
|
}
|
|
53
|
+
const appId = existing?.annotations?.[util_1.FIREBASE_APP_ANNOTATION] ?? (await promptWebApp(projectId));
|
|
51
54
|
const savedEntry = findRunEntry(getRunEntries(config), serviceId, region);
|
|
52
55
|
const localBuild = await (0, prompt_1.select)({
|
|
53
56
|
message: "Would you like to build your app locally or remotely?",
|
|
@@ -70,8 +73,32 @@ async function askQuestions(setup, config, options) {
|
|
|
70
73
|
if (localBuild) {
|
|
71
74
|
runInfo.localBuild = true;
|
|
72
75
|
}
|
|
76
|
+
if (appId) {
|
|
77
|
+
runInfo.appId = appId;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
runInfo.createWebApp = true;
|
|
81
|
+
}
|
|
73
82
|
setup.featureInfo = { ...setup.featureInfo, run: runInfo };
|
|
74
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
|
+
}
|
|
75
102
|
async function promptExistingService(projectId) {
|
|
76
103
|
const allServices = await runv2.listServices(projectId, false);
|
|
77
104
|
const services = allServices.filter((s) => !s.labels?.[runv2.CLIENT_NAME_LABEL]);
|
|
@@ -132,7 +159,19 @@ async function actuate(setup, config, options) {
|
|
|
132
159
|
else {
|
|
133
160
|
upsertRunConfig(service, config);
|
|
134
161
|
}
|
|
135
|
-
|
|
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);
|
|
136
175
|
}
|
|
137
176
|
function upsertRunConfig(service, config) {
|
|
138
177
|
const entries = getRunEntries(config);
|
package/lib/mcp/errors.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.mcpAuthError = mcpAuthError;
|
|
|
6
6
|
const util_1 = require("./util");
|
|
7
7
|
exports.NO_PROJECT_ERROR = (0, util_1.mcpError)("To proceed requires an active project. Use the `firebase_update_environment` tool to set a project ID", "PRECONDITION_FAILED");
|
|
8
8
|
function noProjectDirectory(projectRoot) {
|
|
9
|
-
return (0, util_1.mcpError)(`The current project directory '${projectRoot || "<NO PROJECT DIRECTORY FOUND>"}' does not exist. Please use the '
|
|
9
|
+
return (0, util_1.mcpError)(`The current project directory '${projectRoot || "<NO PROJECT DIRECTORY FOUND>"}' does not exist. Please use the 'firebase_update_environment' tool to target a different project directory.`);
|
|
10
10
|
}
|
|
11
11
|
function mcpAuthError(skipADC) {
|
|
12
12
|
if (skipADC) {
|
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";
|
|
@@ -1,38 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.schemaToText = schemaToText;
|
|
4
|
-
exports.connectorToText = connectorToText;
|
|
5
|
-
exports.sourceToText = sourceToText;
|
|
6
3
|
exports.graphqlResponseToToolResponse = graphqlResponseToToolResponse;
|
|
7
4
|
exports.parseVariables = parseVariables;
|
|
8
|
-
const js_yaml_1 = require("js-yaml");
|
|
9
5
|
const types_1 = require("../../../dataconnect/types");
|
|
10
6
|
const util_1 = require("../../util");
|
|
11
|
-
function schemaToText(s) {
|
|
12
|
-
return ((0, js_yaml_1.dump)({
|
|
13
|
-
name: s.name,
|
|
14
|
-
datasources: s.datasources,
|
|
15
|
-
}) +
|
|
16
|
-
"\n\n" +
|
|
17
|
-
sourceToText(s.source));
|
|
18
|
-
}
|
|
19
|
-
function connectorToText(s) {
|
|
20
|
-
return ((0, js_yaml_1.dump)({
|
|
21
|
-
name: s.name,
|
|
22
|
-
}) +
|
|
23
|
-
"\n\n" +
|
|
24
|
-
sourceToText(s.source));
|
|
25
|
-
}
|
|
26
|
-
function sourceToText(s) {
|
|
27
|
-
let output = "";
|
|
28
|
-
s.files?.forEach((f) => {
|
|
29
|
-
output += `\n# ${f.path}`;
|
|
30
|
-
output += "\n```graphql\n";
|
|
31
|
-
output += `${f.content.trim()}\n`;
|
|
32
|
-
output += "```\n";
|
|
33
|
-
});
|
|
34
|
-
return output;
|
|
35
|
-
}
|
|
36
7
|
function graphqlResponseToToolResponse(g) {
|
|
37
8
|
if ((0, types_1.isGraphQLResponse)(g)) {
|
|
38
9
|
const isError = g.errors?.length > 0;
|