firebase-tools-with-isolate 14.10.1-1 → 14.16.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/lib/api.js +5 -1
- package/lib/apphosting/backend.js +40 -15
- package/lib/apptesting/ensureProjectConfigured.js +56 -0
- package/lib/apptesting/invokeTests.js +40 -0
- package/lib/apptesting/parseTestFiles.js +75 -0
- package/lib/apptesting/types.js +18 -0
- package/lib/auth.js +37 -2
- package/lib/command.js +24 -5
- package/lib/commands/apphosting-backends-create.js +8 -5
- package/lib/commands/apptesting-execute.js +101 -0
- package/lib/commands/dataconnect-sdk-generate.js +28 -26
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/dataconnect-sql-diff.js +2 -2
- package/lib/commands/dataconnect-sql-grant.js +7 -2
- package/lib/commands/dataconnect-sql-migrate.js +2 -2
- package/lib/commands/dataconnect-sql-setup.js +3 -5
- package/lib/commands/dataconnect-sql-shell.js +2 -2
- package/lib/commands/ext-export.js +1 -1
- package/lib/commands/firestore-bulkdelete.js +73 -0
- package/lib/commands/firestore-databases-create.js +11 -0
- package/lib/commands/firestore-operations-cancel.js +44 -0
- package/lib/commands/firestore-operations-describe.js +29 -0
- package/lib/commands/firestore-operations-list.js +29 -0
- package/lib/commands/firestore-utils.js +15 -0
- package/lib/commands/functions-config-clone.js +2 -0
- package/lib/commands/functions-config-export.js +5 -2
- package/lib/commands/functions-config-get.js +2 -0
- package/lib/commands/functions-config-set.js +2 -0
- package/lib/commands/functions-config-unset.js +2 -0
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +24 -4
- package/lib/commands/internaltesting-functions-discover.js +20 -5
- package/lib/commands/login.js +13 -9
- package/lib/commands/use.js +5 -0
- package/lib/config.js +16 -4
- package/lib/crashlytics/addNote.js +27 -0
- package/lib/crashlytics/buildToolsJarHelper.js +1 -2
- package/lib/crashlytics/deleteNote.js +23 -0
- package/lib/crashlytics/getIssueDetails.js +26 -0
- package/lib/crashlytics/getSampleCrash.js +34 -0
- package/lib/crashlytics/listNotes.js +29 -0
- package/lib/crashlytics/listTopDevices.js +33 -0
- package/lib/crashlytics/listTopIssues.js +8 -23
- package/lib/crashlytics/listTopOperatingSystems.js +32 -0
- package/lib/crashlytics/listTopVersions.js +32 -0
- package/lib/crashlytics/updateIssue.js +35 -0
- package/lib/crashlytics/utils.js +38 -0
- package/lib/dataconnect/appFinder.js +102 -0
- package/lib/dataconnect/client.js +23 -15
- package/lib/dataconnect/ensureApis.js +6 -9
- package/lib/dataconnect/errors.js +7 -1
- package/lib/dataconnect/freeTrial.js +16 -38
- package/lib/dataconnect/load.js +105 -6
- package/lib/dataconnect/provisionCloudSql.js +67 -70
- package/lib/dataconnect/schemaMigration.js +219 -169
- package/lib/deploy/dataconnect/deploy.js +7 -9
- package/lib/deploy/dataconnect/prepare.js +7 -12
- package/lib/deploy/dataconnect/release.js +43 -31
- package/lib/deploy/firestore/deploy.js +10 -0
- package/lib/deploy/functions/backend.js +7 -1
- package/lib/deploy/functions/build.js +28 -14
- package/lib/deploy/functions/deploy.js +3 -2
- package/lib/deploy/functions/ensure.js +1 -1
- package/lib/deploy/functions/functionsDeployHelper.js +8 -1
- package/lib/deploy/functions/params.js +4 -0
- package/lib/deploy/functions/prepare.js +25 -13
- package/lib/deploy/functions/pricing.js +12 -5
- package/lib/deploy/functions/release/fabricator.js +25 -3
- package/lib/deploy/functions/release/reporter.js +1 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +52 -5
- package/lib/deploy/functions/runtimes/node/index.js +83 -51
- package/lib/emulator/auth/operations.js +10 -1
- package/lib/emulator/commandUtils.js +7 -1
- package/lib/emulator/controller.js +22 -34
- package/lib/emulator/dataconnectEmulator.js +27 -24
- package/lib/emulator/downloadableEmulatorInfo.json +18 -18
- package/lib/emulator/env.js +2 -1
- package/lib/emulator/functionsEmulator.js +12 -2
- package/lib/emulator/hub.js +11 -8
- package/lib/emulator/tasksEmulator.js +1 -1
- package/lib/emulator/ui.js +3 -1
- package/lib/env.js +18 -0
- package/lib/experiments.js +20 -0
- package/lib/extensions/extensionsHelper.js +4 -15
- package/lib/extensions/runtimes/common.js +3 -2
- package/lib/extensions/utils.js +1 -12
- package/lib/firestore/api-sort.js +96 -3
- package/lib/firestore/api-types.js +20 -1
- package/lib/firestore/api.js +144 -15
- package/lib/firestore/pretty-print.js +35 -1
- package/lib/firestore/validator.js +1 -1
- package/lib/functional.js +7 -1
- package/lib/functions/deprecationWarnings.js +21 -0
- package/lib/functions/env.js +31 -16
- package/lib/functions/projectConfig.js +87 -8
- package/lib/functions/secrets.js +3 -0
- package/lib/gcp/cloudfunctions.js +1 -6
- package/lib/gcp/cloudfunctionsv2.js +3 -39
- package/lib/gcp/cloudscheduler.js +1 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +4 -16
- package/lib/gcp/cloudsql/connect.js +4 -3
- package/lib/gcp/cloudsql/permissionsSetup.js +23 -16
- package/lib/gcp/k8s.js +32 -0
- package/lib/gcp/runv2.js +181 -0
- package/lib/gemini/fdcExperience.js +5 -3
- package/lib/init/features/aitools/claude.js +43 -0
- package/lib/init/features/aitools/cursor.js +61 -0
- package/lib/init/features/aitools/gemini.js +58 -0
- package/lib/init/features/aitools/index.js +28 -0
- package/lib/init/features/aitools/promptUpdater.js +111 -0
- package/lib/init/features/aitools/studio.js +17 -0
- package/lib/init/features/aitools/types.js +2 -0
- package/lib/init/features/aitools.js +83 -0
- package/lib/init/features/apptesting/index.js +34 -0
- package/lib/init/features/dataconnect/create_app.js +53 -0
- package/lib/init/features/dataconnect/index.js +280 -186
- package/lib/init/features/dataconnect/sdk.js +232 -144
- package/lib/init/features/index.js +8 -3
- package/lib/init/features/project.js +4 -0
- package/lib/init/index.js +18 -2
- package/lib/management/apps.js +3 -3
- package/lib/management/studio.js +120 -0
- package/lib/mcp/errors.js +5 -7
- package/lib/mcp/index.js +179 -61
- package/lib/mcp/logging-transport.js +23 -0
- package/lib/mcp/prompt.js +10 -0
- package/lib/mcp/prompts/core/deploy.js +101 -0
- package/lib/mcp/prompts/core/index.js +5 -0
- package/lib/mcp/prompts/crashlytics/connect.js +114 -0
- package/lib/mcp/prompts/crashlytics/index.js +5 -0
- package/lib/mcp/prompts/dataconnect/index.js +9 -0
- package/lib/mcp/prompts/dataconnect/schema.js +67 -0
- package/lib/mcp/prompts/index.js +47 -0
- package/lib/mcp/tools/apphosting/fetch_logs.js +22 -22
- package/lib/mcp/tools/apphosting/list_backends.js +10 -10
- package/lib/mcp/tools/auth/disable_user.js +7 -7
- package/lib/mcp/tools/auth/get_user.js +13 -6
- package/lib/mcp/tools/auth/index.js +10 -10
- package/lib/mcp/tools/auth/list_users.js +6 -6
- package/lib/mcp/tools/auth/set_claims.js +7 -7
- package/lib/mcp/tools/auth/set_sms_region_policy.js +6 -6
- package/lib/mcp/tools/core/consult_assistant.js +13 -8
- package/lib/mcp/tools/core/create_android_sha.js +9 -9
- package/lib/mcp/tools/core/create_app.js +7 -7
- package/lib/mcp/tools/core/create_project.js +13 -13
- package/lib/mcp/tools/core/get_admin_sdk_config.js +7 -7
- package/lib/mcp/tools/core/get_environment.js +8 -8
- package/lib/mcp/tools/core/get_project.js +5 -5
- package/lib/mcp/tools/core/get_sdk_config.js +19 -9
- package/lib/mcp/tools/core/index.js +28 -24
- package/lib/mcp/tools/core/init.js +39 -16
- package/lib/mcp/tools/core/list_apps.js +6 -6
- package/lib/mcp/tools/core/list_projects.js +6 -6
- package/lib/mcp/tools/core/login.js +46 -0
- package/lib/mcp/tools/core/logout.js +62 -0
- package/lib/mcp/tools/core/update_environment.js +10 -10
- package/lib/mcp/tools/crashlytics/add_note.js +32 -0
- package/lib/mcp/tools/crashlytics/constants.js +11 -0
- package/lib/mcp/tools/crashlytics/delete_note.js +35 -0
- package/lib/mcp/tools/crashlytics/get_issue_details.js +31 -0
- package/lib/mcp/tools/crashlytics/get_sample_crash.js +43 -0
- package/lib/mcp/tools/crashlytics/index.js +22 -2
- package/lib/mcp/tools/crashlytics/list_notes.js +37 -0
- package/lib/mcp/tools/crashlytics/list_top_devices.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_issues.js +12 -13
- package/lib/mcp/tools/crashlytics/list_top_operating_systems.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_versions.js +33 -0
- package/lib/mcp/tools/crashlytics/update_issue.js +37 -0
- package/lib/mcp/tools/database/get_data.js +49 -0
- package/lib/mcp/tools/database/get_rules.js +39 -0
- package/lib/mcp/tools/database/index.js +8 -0
- package/lib/mcp/tools/database/set_data.js +57 -0
- package/lib/mcp/tools/database/validate_rules.js +41 -0
- package/lib/mcp/tools/dataconnect/compile.js +43 -0
- package/lib/mcp/tools/dataconnect/execute.js +71 -0
- package/lib/mcp/tools/dataconnect/generate_operation.js +8 -8
- package/lib/mcp/tools/dataconnect/generate_schema.js +6 -6
- package/lib/mcp/tools/dataconnect/index.js +10 -18
- package/lib/mcp/tools/dataconnect/list_services.js +107 -11
- package/lib/mcp/tools/firestore/delete_document.js +13 -13
- package/lib/mcp/tools/firestore/get_documents.js +13 -13
- package/lib/mcp/tools/firestore/list_collections.js +7 -10
- package/lib/mcp/tools/firestore/query_collection.js +13 -13
- package/lib/mcp/tools/index.js +24 -18
- package/lib/mcp/tools/messaging/index.js +2 -2
- package/lib/mcp/tools/messaging/send_message.js +7 -7
- package/lib/mcp/tools/remoteconfig/get_template.js +5 -5
- package/lib/mcp/tools/remoteconfig/index.js +4 -4
- package/lib/mcp/tools/remoteconfig/publish_template.js +7 -7
- package/lib/mcp/tools/remoteconfig/rollback_template.js +6 -6
- package/lib/mcp/tools/rules/get_rules.js +8 -8
- package/lib/mcp/tools/rules/validate_rules.js +10 -10
- package/lib/mcp/tools/storage/get_download_url.js +8 -8
- package/lib/mcp/tools/storage/get_rules.js +8 -8
- package/lib/mcp/types.js +2 -0
- package/lib/mcp/util/dataconnect/compile.js +20 -0
- package/lib/mcp/util/dataconnect/content.js +655 -0
- package/lib/mcp/util/dataconnect/emulator.js +16 -0
- package/lib/mcp/util.js +5 -18
- package/lib/requireAuth.js +14 -4
- package/lib/rtdb.js +10 -6
- package/lib/scopes.js +2 -1
- package/lib/serve/functions.js +4 -3
- package/lib/timeout.js +21 -0
- package/lib/track.js +18 -1
- package/lib/unzip.js +13 -0
- package/lib/utils.js +76 -2
- package/package.json +6 -4
- package/prompts/FIREBASE.md +121 -0
- package/prompts/FIREBASE_FUNCTIONS.md +221 -0
- package/schema/apptesting-yaml.json +64 -0
- package/schema/firebase-config.json +163 -53
- package/templates/init/aitools/cursor-rules-header.txt +8 -0
- package/templates/init/aitools/gemini-extension.json +11 -0
- package/templates/init/apptesting/smoke_test.yaml +6 -0
- package/templates/init/dataconnect/connector.yaml +0 -16
- package/templates/init/dataconnect/dataconnect.yaml +2 -1
- package/templates/init/dataconnect/mutations.gql +29 -29
- package/templates/init/dataconnect/queries.gql +73 -73
- package/templates/init/dataconnect/schema.gql +48 -48
- package/templates/init/firestore/firestore.indexes.json +26 -1
- package/lib/dataconnect/fileUtils.js +0 -168
- package/lib/emulator/adminSdkConfig.test.js +0 -16
- package/lib/extensions/resolveSource.js +0 -23
- package/lib/firestore/api-sort.test.js +0 -74
- package/lib/firestore/backupUtils.test.js +0 -18
- package/lib/firestore/pretty-print.test.js +0 -61
- package/lib/firestore/util.test.js +0 -42
- package/lib/mcp/tools/dataconnect/emulator.js +0 -16
- package/lib/mcp/tools/dataconnect/execute_graphql.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_graphql_read.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_mutation.js +0 -62
- package/lib/mcp/tools/dataconnect/execute_query.js +0 -62
- package/lib/mcp/tools/dataconnect/get_connector.js +0 -31
- package/lib/mcp/tools/dataconnect/get_schema.js +0 -31
- /package/lib/mcp/{tools → util}/dataconnect/converter.js +0 -0
package/lib/mcp/util.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanSchema = exports.checkFeatureActive = exports.
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
3
|
+
exports.cleanSchema = exports.checkFeatureActive = exports.mcpError = exports.toContent = void 0;
|
|
5
4
|
const js_yaml_1 = require("js-yaml");
|
|
6
|
-
const os_1 = require("os");
|
|
7
5
|
const api_1 = require("../api");
|
|
8
6
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
7
|
+
const timeout_1 = require("../timeout");
|
|
9
8
|
function toContent(data, options) {
|
|
10
9
|
if (typeof data === "string")
|
|
11
10
|
return { content: [{ type: "text", text: data }] };
|
|
@@ -40,21 +39,8 @@ function mcpError(message, code) {
|
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
41
|
exports.mcpError = mcpError;
|
|
43
|
-
function commandExistsSync(command) {
|
|
44
|
-
try {
|
|
45
|
-
const isWindows = (0, os_1.platform)() === "win32";
|
|
46
|
-
const commandToCheck = isWindows
|
|
47
|
-
? `where "${command}" > nul 2> nul`
|
|
48
|
-
: `which "${command}" > /dev/null 2> /dev/null`;
|
|
49
|
-
(0, child_process_1.execSync)(commandToCheck);
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.commandExistsSync = commandExistsSync;
|
|
57
42
|
const SERVER_FEATURE_APIS = {
|
|
43
|
+
core: "",
|
|
58
44
|
firestore: (0, api_1.firestoreOrigin)(),
|
|
59
45
|
storage: (0, api_1.storageOrigin)(),
|
|
60
46
|
dataconnect: (0, api_1.dataconnectOrigin)(),
|
|
@@ -63,13 +49,14 @@ const SERVER_FEATURE_APIS = {
|
|
|
63
49
|
remoteconfig: (0, api_1.remoteConfigApiOrigin)(),
|
|
64
50
|
crashlytics: (0, api_1.crashlyticsApiOrigin)(),
|
|
65
51
|
apphosting: (0, api_1.apphostingOrigin)(),
|
|
52
|
+
database: (0, api_1.realtimeOrigin)(),
|
|
66
53
|
};
|
|
67
54
|
async function checkFeatureActive(feature, projectId, options) {
|
|
68
55
|
if (feature in (options?.config?.data || {}))
|
|
69
56
|
return true;
|
|
70
57
|
try {
|
|
71
58
|
if (projectId)
|
|
72
|
-
return await (0, ensureApiEnabled_1.check)(projectId, SERVER_FEATURE_APIS[feature], "", true);
|
|
59
|
+
return await (0, timeout_1.timeoutFallback)((0, ensureApiEnabled_1.check)(projectId, SERVER_FEATURE_APIS[feature], "", true), true, 3000);
|
|
73
60
|
}
|
|
74
61
|
catch (e) {
|
|
75
62
|
return true;
|
package/lib/requireAuth.js
CHANGED
|
@@ -10,6 +10,8 @@ const logger_1 = require("./logger");
|
|
|
10
10
|
const utils = require("./utils");
|
|
11
11
|
const scopes = require("./scopes");
|
|
12
12
|
const auth_1 = require("./auth");
|
|
13
|
+
const env_1 = require("./env");
|
|
14
|
+
const timeout_1 = require("./timeout");
|
|
13
15
|
const AUTH_ERROR_MESSAGE = `Command requires authentication, please run ${clc.bold("firebase login")}`;
|
|
14
16
|
let authClient;
|
|
15
17
|
let lastOptions;
|
|
@@ -27,13 +29,14 @@ async function autoAuth(options, authScopes) {
|
|
|
27
29
|
logger_1.logger.debug(`Running auto auth`);
|
|
28
30
|
let clientEmail;
|
|
29
31
|
try {
|
|
30
|
-
const
|
|
32
|
+
const timeoutMillis = (0, env_1.isFirebaseMcp)() ? 5000 : 15000;
|
|
33
|
+
const credentials = await (0, timeout_1.timeoutError)(client.getCredentials(), new error_1.FirebaseError(`Authenticating with default credentials timed out after ${timeoutMillis / 1000} seconds. Please try running \`firebase login\` instead.`), timeoutMillis);
|
|
31
34
|
clientEmail = credentials.client_email;
|
|
32
35
|
}
|
|
33
36
|
catch (e) {
|
|
34
37
|
logger_1.logger.debug(`Error getting account credentials.`);
|
|
35
38
|
}
|
|
36
|
-
if (
|
|
39
|
+
if ((0, env_1.isFirebaseStudio)() && token && clientEmail) {
|
|
37
40
|
const activeAccount = {
|
|
38
41
|
user: { email: clientEmail },
|
|
39
42
|
tokens: {
|
|
@@ -55,9 +58,13 @@ async function refreshAuth() {
|
|
|
55
58
|
return lastOptions.tokens;
|
|
56
59
|
}
|
|
57
60
|
exports.refreshAuth = refreshAuth;
|
|
58
|
-
async function requireAuth(options) {
|
|
61
|
+
async function requireAuth(options, skipAutoAuth = false) {
|
|
59
62
|
lastOptions = options;
|
|
60
|
-
|
|
63
|
+
const requiredScopes = [scopes.CLOUD_PLATFORM];
|
|
64
|
+
if ((0, env_1.isFirebaseStudio)()) {
|
|
65
|
+
requiredScopes.push(scopes.USERINFO_EMAIL);
|
|
66
|
+
}
|
|
67
|
+
api.setScopes(requiredScopes);
|
|
61
68
|
options.authScopes = api.getScopes();
|
|
62
69
|
const tokens = options.tokens;
|
|
63
70
|
const user = options.user;
|
|
@@ -75,6 +82,9 @@ async function requireAuth(options) {
|
|
|
75
82
|
else if (user && (!(0, auth_1.isExpired)(tokens) || tokens?.refresh_token)) {
|
|
76
83
|
logger_1.logger.debug(`> authorizing via signed-in user (${user.email})`);
|
|
77
84
|
}
|
|
85
|
+
else if (skipAutoAuth) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
78
88
|
else {
|
|
79
89
|
try {
|
|
80
90
|
return await autoAuth(options, options.authScopes);
|
package/lib/rtdb.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateRules = void 0;
|
|
3
|
+
exports.updateRulesWithClient = exports.updateRules = void 0;
|
|
4
4
|
const apiv2_1 = require("./apiv2");
|
|
5
5
|
const database_1 = require("./management/database");
|
|
6
6
|
const error_1 = require("./error");
|
|
7
7
|
const api_1 = require("./database/api");
|
|
8
8
|
const utils = require("./utils");
|
|
9
9
|
async function updateRules(projectId, instance, src, options = {}) {
|
|
10
|
-
const queryParams = {};
|
|
11
|
-
if (options.dryRun) {
|
|
12
|
-
queryParams.dryRun = "true";
|
|
13
|
-
}
|
|
14
10
|
const downstreamOptions = { instance: instance, project: projectId };
|
|
15
11
|
await (0, database_1.populateInstanceDetails)(downstreamOptions);
|
|
16
12
|
if (!downstreamOptions.instanceDetails) {
|
|
@@ -18,6 +14,14 @@ async function updateRules(projectId, instance, src, options = {}) {
|
|
|
18
14
|
}
|
|
19
15
|
const origin = utils.getDatabaseUrl((0, api_1.realtimeOriginOrCustomUrl)(downstreamOptions.instanceDetails.databaseUrl), instance, "");
|
|
20
16
|
const client = new apiv2_1.Client({ urlPrefix: origin });
|
|
17
|
+
return updateRulesWithClient(client, src, options);
|
|
18
|
+
}
|
|
19
|
+
exports.updateRules = updateRules;
|
|
20
|
+
async function updateRulesWithClient(client, src, options = {}) {
|
|
21
|
+
const queryParams = {};
|
|
22
|
+
if (options.dryRun) {
|
|
23
|
+
queryParams.dryRun = "true";
|
|
24
|
+
}
|
|
21
25
|
const response = await client.request({
|
|
22
26
|
method: "PUT",
|
|
23
27
|
path: ".settings/rules.json",
|
|
@@ -32,4 +36,4 @@ async function updateRules(projectId, instance, src, options = {}) {
|
|
|
32
36
|
throw new error_1.FirebaseError("Unexpected error while deploying database rules.", { exit: 2 });
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
|
-
exports.
|
|
39
|
+
exports.updateRulesWithClient = updateRulesWithClient;
|
package/lib/scopes.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLOUD_PUBSUB = exports.CLOUD_STORAGE = exports.CLOUD_PLATFORM = exports.FIREBASE_PLATFORM = exports.CLOUD_PROJECTS_READONLY = exports.EMAIL = exports.OPENID = void 0;
|
|
3
|
+
exports.CLOUD_PUBSUB = exports.CLOUD_STORAGE = exports.CLOUD_PLATFORM = exports.FIREBASE_PLATFORM = exports.CLOUD_PROJECTS_READONLY = exports.USERINFO_EMAIL = exports.EMAIL = exports.OPENID = void 0;
|
|
4
4
|
exports.OPENID = "openid";
|
|
5
5
|
exports.EMAIL = "email";
|
|
6
|
+
exports.USERINFO_EMAIL = "https://www.googleapis.com/auth/userinfo.email";
|
|
6
7
|
exports.CLOUD_PROJECTS_READONLY = "https://www.googleapis.com/auth/cloudplatformprojects.readonly";
|
|
7
8
|
exports.FIREBASE_PLATFORM = "https://www.googleapis.com/auth/firebase";
|
|
8
9
|
exports.CLOUD_PLATFORM = "https://www.googleapis.com/auth/cloud-platform";
|
package/lib/serve/functions.js
CHANGED
|
@@ -21,11 +21,12 @@ class FunctionsServer {
|
|
|
21
21
|
const config = projectConfig.normalizeAndValidate(options.config.src.functions);
|
|
22
22
|
const backends = [];
|
|
23
23
|
for (const cfg of config) {
|
|
24
|
-
const
|
|
24
|
+
const localCfg = projectConfig.requireLocal(cfg, "Remote sources are not supported in the Functions emulator.");
|
|
25
|
+
const functionsDir = path.join(options.config.projectDir, localCfg.source);
|
|
25
26
|
backends.push({
|
|
26
27
|
functionsDir,
|
|
27
|
-
codebase:
|
|
28
|
-
runtime:
|
|
28
|
+
codebase: localCfg.codebase,
|
|
29
|
+
runtime: localCfg.runtime,
|
|
29
30
|
env: {},
|
|
30
31
|
secretEnv: [],
|
|
31
32
|
});
|
package/lib/timeout.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.timeoutError = exports.timeoutFallback = void 0;
|
|
4
|
+
async function timeoutFallback(promise, value, timeoutMillis = 2000) {
|
|
5
|
+
return Promise.race([
|
|
6
|
+
promise,
|
|
7
|
+
new Promise((resolve) => setTimeout(() => resolve(value), timeoutMillis)),
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
exports.timeoutFallback = timeoutFallback;
|
|
11
|
+
async function timeoutError(promise, error, timeoutMillis = 5000) {
|
|
12
|
+
if (typeof error === "string")
|
|
13
|
+
error = new Error(error);
|
|
14
|
+
return Promise.race([
|
|
15
|
+
promise,
|
|
16
|
+
new Promise((resolve, reject) => {
|
|
17
|
+
setTimeout(() => reject(error || new Error("Operation timed out.")), timeoutMillis);
|
|
18
|
+
}),
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
exports.timeoutError = timeoutError;
|
package/lib/track.js
CHANGED
|
@@ -6,7 +6,21 @@ const uuid_1 = require("uuid");
|
|
|
6
6
|
const auth_1 = require("./auth");
|
|
7
7
|
const configstore_1 = require("./configstore");
|
|
8
8
|
const logger_1 = require("./logger");
|
|
9
|
+
const env_1 = require("./env");
|
|
9
10
|
const pkg = require("../package.json");
|
|
11
|
+
function detectAIAgent() {
|
|
12
|
+
if (process.env.CODEX_SANDBOX)
|
|
13
|
+
return "codex_cli";
|
|
14
|
+
if (process.env.CLAUDECODE)
|
|
15
|
+
return "claude_code";
|
|
16
|
+
if (process.env.GEMINI_CLI)
|
|
17
|
+
return "gemini_cli";
|
|
18
|
+
if (process.env.CURSOR_AGENT)
|
|
19
|
+
return "cursor";
|
|
20
|
+
if (process.env.OPENCODE)
|
|
21
|
+
return "open_code";
|
|
22
|
+
return "unknown";
|
|
23
|
+
}
|
|
10
24
|
exports.GA4_PROPERTIES = {
|
|
11
25
|
cli: {
|
|
12
26
|
measurementId: process.env.FIREBASE_CLI_GA4_MEASUREMENT_ID || "G-PDN0QWHQJR",
|
|
@@ -42,7 +56,10 @@ const GA4_USER_PROPS = {
|
|
|
42
56
|
value: process.env.FIREPIT_VERSION || "none",
|
|
43
57
|
},
|
|
44
58
|
is_firebase_studio: {
|
|
45
|
-
value:
|
|
59
|
+
value: (0, env_1.isFirebaseStudio)().toString(),
|
|
60
|
+
},
|
|
61
|
+
ai_agent: {
|
|
62
|
+
value: detectAIAgent(),
|
|
46
63
|
},
|
|
47
64
|
};
|
|
48
65
|
async function trackGA4(eventName, params, duration = 1) {
|
package/lib/unzip.js
CHANGED
|
@@ -57,6 +57,9 @@ const extractEntriesFromBuffer = async (data, outputDir) => {
|
|
|
57
57
|
logger_1.logger.debug(`[unzip] Entry: ${entry.fileName} (compressed_size=${entry.compressedSize} bytes, uncompressed_size=${entry.uncompressedSize} bytes)`);
|
|
58
58
|
entry.fileName = entry.fileName.replace(/\//g, path.sep);
|
|
59
59
|
const outputFilePath = path.normalize(path.join(outputDir, entry.fileName));
|
|
60
|
+
if (!isChildDir(outputDir, outputFilePath)) {
|
|
61
|
+
throw new error_1.FirebaseError(`ZIP contained an entry for ${outputFilePath}, a path outside of ${outputDir}`);
|
|
62
|
+
}
|
|
60
63
|
logger_1.logger.debug(`[unzip] Processing entry: ${entry.fileName}`);
|
|
61
64
|
if (entry.fileName.endsWith(path.sep)) {
|
|
62
65
|
logger_1.logger.debug(`[unzip] mkdir: ${outputFilePath}`);
|
|
@@ -82,6 +85,16 @@ const extractEntriesFromBuffer = async (data, outputDir) => {
|
|
|
82
85
|
position += entry.headerSize + entry.compressedSize + dataDescriptorSize;
|
|
83
86
|
}
|
|
84
87
|
};
|
|
88
|
+
function isChildDir(parentDir, potentialChild) {
|
|
89
|
+
try {
|
|
90
|
+
const resolvedParent = path.resolve(parentDir);
|
|
91
|
+
const resolvedChild = path.resolve(potentialChild);
|
|
92
|
+
return resolvedChild.startsWith(resolvedParent) && resolvedChild !== resolvedParent;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
85
98
|
const unzip = async (inputPath, outputDir) => {
|
|
86
99
|
const data = await fs.promises.readFile(inputPath);
|
|
87
100
|
await extractEntriesFromBuffer(data, outputDir);
|
package/lib/utils.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.promptForDirectory = exports.updateOrCreateGitignore = exports.readSecretValue = exports.generateId = exports.wrappedSafeLoad = exports.readFileFromDirectory = void 0;
|
|
3
|
+
exports.openInBrowserPopup = exports.openInBrowser = exports.connectableHostname = exports.randomInt = exports.debounce = exports.last = exports.cloneDeep = exports.groupBy = exports.assertIsStringOrUndefined = exports.assertIsNumber = exports.assertIsString = exports.thirtyDaysFromNow = exports.isRunningInWSL = exports.isCloudEnvironment = exports.datetimeString = exports.createDestroyer = exports.sleep = exports.promiseWithSpinner = exports.tryParse = exports.promiseProps = exports.withTimeout = exports.promiseWhile = exports.promiseAllSettled = exports.getFunctionsEventProvider = exports.endpoint = exports.makeActiveProject = exports.streamToString = exports.stringToStream = exports.explainStdin = exports.allSettled = exports.reject = exports.logLabeledError = exports.logLabeledWarning = exports.logWarningToStderr = exports.logWarning = exports.logLabeledBullet = exports.logBullet = exports.logLabeledSuccess = exports.logSuccess = exports.addSubdomain = exports.addDatabaseNamespace = exports.getDatabaseViewDataUrl = exports.getDatabaseUrl = exports.envOverride = exports.setVSCodeEnvVars = exports.getInheritedOption = exports.consoleUrl = exports.vscodeEnvVars = exports.envOverrides = exports.IS_WINDOWS = void 0;
|
|
4
|
+
exports.commandExistsSync = exports.newUniqueId = exports.deepEqual = exports.promptForDirectory = exports.updateOrCreateGitignore = exports.readSecretValue = exports.generatePassword = exports.generateId = exports.wrappedSafeLoad = exports.readFileFromDirectory = exports.getHostnameFromUrl = void 0;
|
|
5
5
|
const fs = require("fs-extra");
|
|
6
6
|
const tty = require("tty");
|
|
7
7
|
const path = require("node:path");
|
|
8
8
|
const yaml = require("yaml");
|
|
9
|
+
const crypto = require("node:crypto");
|
|
9
10
|
const _ = require("lodash");
|
|
10
11
|
const url = require("url");
|
|
11
12
|
const http = require("http");
|
|
@@ -23,6 +24,8 @@ const prompt_1 = require("./prompt");
|
|
|
23
24
|
const templates_1 = require("./templates");
|
|
24
25
|
const vsCodeUtils_1 = require("./vsCodeUtils");
|
|
25
26
|
const fsutils_1 = require("./fsutils");
|
|
27
|
+
const node_os_1 = require("node:os");
|
|
28
|
+
const node_child_process_1 = require("node:child_process");
|
|
26
29
|
exports.IS_WINDOWS = process.platform === "win32";
|
|
27
30
|
const SUCCESS_CHAR = exports.IS_WINDOWS ? "+" : "✔";
|
|
28
31
|
const WARNING_CHAR = exports.IS_WINDOWS ? "!" : "⚠";
|
|
@@ -115,6 +118,11 @@ function logWarning(message, type = "warn", data = undefined) {
|
|
|
115
118
|
logger_1.logger[type](clc.yellow(clc.bold(`${WARNING_CHAR} `)), message, data);
|
|
116
119
|
}
|
|
117
120
|
exports.logWarning = logWarning;
|
|
121
|
+
function logWarningToStderr(message) {
|
|
122
|
+
const prefix = clc.bold(`${WARNING_CHAR} `);
|
|
123
|
+
process.stderr.write(clc.yellow(prefix + message) + "\n");
|
|
124
|
+
}
|
|
125
|
+
exports.logWarningToStderr = logWarningToStderr;
|
|
118
126
|
function logLabeledWarning(label, message, type = "warn", data = undefined) {
|
|
119
127
|
logger_1.logger[type](clc.yellow(clc.bold(`${WARNING_CHAR} ${label}:`)), message, data);
|
|
120
128
|
}
|
|
@@ -541,6 +549,28 @@ function generateId(n = 6) {
|
|
|
541
549
|
return id;
|
|
542
550
|
}
|
|
543
551
|
exports.generateId = generateId;
|
|
552
|
+
function generatePassword(n = 20) {
|
|
553
|
+
const lower = "abcdefghijklmnopqrstuvwxyz";
|
|
554
|
+
const upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
555
|
+
const numbers = "0123456789";
|
|
556
|
+
const special = "!@#$%^&*()_+~`|}{[]:;?><,./-=";
|
|
557
|
+
const all = lower + upper + numbers + special;
|
|
558
|
+
let pw = "";
|
|
559
|
+
pw += lower[crypto.randomInt(lower.length)];
|
|
560
|
+
pw += upper[crypto.randomInt(upper.length)];
|
|
561
|
+
pw += numbers[crypto.randomInt(numbers.length)];
|
|
562
|
+
pw += special[crypto.randomInt(special.length)];
|
|
563
|
+
for (let i = 4; i < n; i++) {
|
|
564
|
+
pw += all[crypto.randomInt(all.length)];
|
|
565
|
+
}
|
|
566
|
+
const pwArray = pw.split("");
|
|
567
|
+
for (let i = pwArray.length - 1; i > 0; i--) {
|
|
568
|
+
const j = crypto.randomInt(i);
|
|
569
|
+
[pwArray[i], pwArray[j]] = [pwArray[j], pwArray[i]];
|
|
570
|
+
}
|
|
571
|
+
return pwArray.join("");
|
|
572
|
+
}
|
|
573
|
+
exports.generatePassword = generatePassword;
|
|
544
574
|
function readSecretValue(prompt, dataFile) {
|
|
545
575
|
if ((!dataFile || dataFile === "-") && tty.isatty(0)) {
|
|
546
576
|
return (0, prompt_1.password)({ message: prompt });
|
|
@@ -599,3 +629,47 @@ async function promptForDirectory(args) {
|
|
|
599
629
|
return dir;
|
|
600
630
|
}
|
|
601
631
|
exports.promptForDirectory = promptForDirectory;
|
|
632
|
+
function deepEqual(a, b) {
|
|
633
|
+
if (a === b) {
|
|
634
|
+
return true;
|
|
635
|
+
}
|
|
636
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
const keysA = Object.keys(a);
|
|
640
|
+
const keysB = Object.keys(b);
|
|
641
|
+
if (keysA.length !== keysB.length) {
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
for (const key of keysA) {
|
|
645
|
+
if (!keysB.includes(key) || !deepEqual(a[key], b[key])) {
|
|
646
|
+
return false;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return true;
|
|
650
|
+
}
|
|
651
|
+
exports.deepEqual = deepEqual;
|
|
652
|
+
function newUniqueId(recommended, existingIDs) {
|
|
653
|
+
let id = recommended;
|
|
654
|
+
let i = 1;
|
|
655
|
+
while (existingIDs.includes(id)) {
|
|
656
|
+
id = `${recommended}-${i}`;
|
|
657
|
+
i++;
|
|
658
|
+
}
|
|
659
|
+
return id;
|
|
660
|
+
}
|
|
661
|
+
exports.newUniqueId = newUniqueId;
|
|
662
|
+
function commandExistsSync(command) {
|
|
663
|
+
try {
|
|
664
|
+
const isWindows = (0, node_os_1.platform)() === "win32";
|
|
665
|
+
const commandToCheck = isWindows
|
|
666
|
+
? `where "${command}" > nul 2> nul`
|
|
667
|
+
: `which "${command}" > /dev/null 2> /dev/null`;
|
|
668
|
+
(0, node_child_process_1.execSync)(commandToCheck);
|
|
669
|
+
return true;
|
|
670
|
+
}
|
|
671
|
+
catch (error) {
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
exports.commandExistsSync = commandExistsSync;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools-with-isolate",
|
|
3
3
|
"description": "Command-Line Interface for Firebase with monorepo support",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.16.0",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"firebase": "lib/bin/firebase.js"
|
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
"lint:quiet": "npm run lint:ts -- --quiet && npm run lint:other",
|
|
24
24
|
"lint:ts": "eslint --config .eslintrc.js --ext .ts,.js .",
|
|
25
25
|
"mocha:fast": "mocha 'src/**/*.spec.{ts,js}'",
|
|
26
|
-
"mocha": "nyc mocha 'src/**/*.spec.{ts,js}'",
|
|
26
|
+
"mocha": "nyc --reporter=html mocha 'src/**/*.spec.{ts,js}'",
|
|
27
27
|
"prepare": "npm run clean && npm run build:publish",
|
|
28
28
|
"test": "npm run lint:quiet && npm run test:compile && npm run mocha",
|
|
29
|
+
"test:apptesting": "npm run lint:quiet && npm run test:compile && nyc mocha 'src/apptesting/*.spec.{ts,js}'",
|
|
29
30
|
"test:client-integration": "bash ./scripts/client-integration-tests/run.sh",
|
|
30
31
|
"test:compile": "tsc --project tsconfig.compile.json",
|
|
31
32
|
"test:management": "npm run lint:quiet && npm run test:compile && nyc mocha 'src/management/*.spec.{ts,js}'",
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
},
|
|
49
50
|
"files": [
|
|
50
51
|
"lib",
|
|
52
|
+
"prompts",
|
|
51
53
|
"schema",
|
|
52
54
|
"standalone",
|
|
53
55
|
"templates"
|
|
@@ -133,7 +135,7 @@
|
|
|
133
135
|
"glob": "^10.4.1",
|
|
134
136
|
"google-auth-library": "^9.11.0",
|
|
135
137
|
"ignore": "^7.0.4",
|
|
136
|
-
"isolate-package": "^1.24.0
|
|
138
|
+
"isolate-package": "^1.24.0",
|
|
137
139
|
"js-yaml": "^3.14.1",
|
|
138
140
|
"jsonwebtoken": "^9.0.0",
|
|
139
141
|
"leven": "^3.1.0",
|
|
@@ -241,7 +243,7 @@
|
|
|
241
243
|
"firebase-functions": "^4.3.1",
|
|
242
244
|
"google-discovery-to-swagger": "^2.1.0",
|
|
243
245
|
"googleapis": "^105.0.0",
|
|
244
|
-
"mocha": "^
|
|
246
|
+
"mocha": "^11.7.1",
|
|
245
247
|
"mock-fs": "5.2.0",
|
|
246
248
|
"next": "^14.1.0",
|
|
247
249
|
"nock": "^13.0.5",
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Firebase CLI Context
|
|
2
|
+
|
|
3
|
+
<project-structure>
|
|
4
|
+
```
|
|
5
|
+
project/
|
|
6
|
+
├── firebase.json # Main configuration
|
|
7
|
+
├── .firebaserc # Project aliases
|
|
8
|
+
├── firestore.rules # Security rules
|
|
9
|
+
├── functions/ # Cloud Functions
|
|
10
|
+
├── public/ # Hosting files
|
|
11
|
+
└── firebase-debug.log # Created when CLI commands fail
|
|
12
|
+
```
|
|
13
|
+
</project-structure>
|
|
14
|
+
|
|
15
|
+
## Common Commands
|
|
16
|
+
|
|
17
|
+
<example>
|
|
18
|
+
```bash
|
|
19
|
+
# Initialize new features
|
|
20
|
+
firebase init hosting
|
|
21
|
+
firebase init functions
|
|
22
|
+
firebase init firestore
|
|
23
|
+
|
|
24
|
+
# Deploy everything or specific services
|
|
25
|
+
|
|
26
|
+
firebase deploy
|
|
27
|
+
firebase deploy --only hosting
|
|
28
|
+
firebase deploy --only functions:processOrder,functions:sendEmail
|
|
29
|
+
firebase deploy --except functions
|
|
30
|
+
|
|
31
|
+
# Switch between projects
|
|
32
|
+
|
|
33
|
+
firebase use staging
|
|
34
|
+
firebase use production
|
|
35
|
+
```
|
|
36
|
+
</example>
|
|
37
|
+
|
|
38
|
+
## Local Development
|
|
39
|
+
|
|
40
|
+
<example>
|
|
41
|
+
```bash
|
|
42
|
+
# Start all emulators
|
|
43
|
+
firebase emulators:start
|
|
44
|
+
|
|
45
|
+
# Start specific emulators
|
|
46
|
+
firebase emulators:start --only functions,firestore
|
|
47
|
+
|
|
48
|
+
# Common emulator URLs
|
|
49
|
+
# Emulator UI: http://localhost:4000
|
|
50
|
+
# Functions: http://localhost:5001
|
|
51
|
+
# Firestore: http://localhost:8080
|
|
52
|
+
# Hosting: http://localhost:5000
|
|
53
|
+
````
|
|
54
|
+
|
|
55
|
+
</example>
|
|
56
|
+
|
|
57
|
+
## Debugging Failed Commands
|
|
58
|
+
|
|
59
|
+
<example>
|
|
60
|
+
```bash
|
|
61
|
+
# When any firebase command fails
|
|
62
|
+
cat firebase-debug.log # Contains detailed error traces
|
|
63
|
+
|
|
64
|
+
# Common fixes for errors in debug log
|
|
65
|
+
|
|
66
|
+
firebase login --reauth # Fix authentication errors
|
|
67
|
+
firebase use # Fix wrong project errors
|
|
68
|
+
|
|
69
|
+
````
|
|
70
|
+
</example>
|
|
71
|
+
|
|
72
|
+
## Complete Workflow Example
|
|
73
|
+
|
|
74
|
+
<example>
|
|
75
|
+
```bash
|
|
76
|
+
# Clone and setup a Firebase project
|
|
77
|
+
git clone https://github.com/example/my-app
|
|
78
|
+
cd my-app
|
|
79
|
+
|
|
80
|
+
# Initialize Firebase in existing project
|
|
81
|
+
firebase init
|
|
82
|
+
|
|
83
|
+
# Start local development
|
|
84
|
+
firebase emulators:start
|
|
85
|
+
|
|
86
|
+
# Make changes, then deploy to staging
|
|
87
|
+
firebase use staging
|
|
88
|
+
firebase deploy
|
|
89
|
+
|
|
90
|
+
# Deploy to production
|
|
91
|
+
firebase use production
|
|
92
|
+
firebase deploy --only hosting,firestore
|
|
93
|
+
````
|
|
94
|
+
|
|
95
|
+
</example>
|
|
96
|
+
|
|
97
|
+
## Service Detection in firebase.json
|
|
98
|
+
|
|
99
|
+
<example>
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"hosting": {
|
|
103
|
+
"public": "dist",
|
|
104
|
+
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
|
|
105
|
+
},
|
|
106
|
+
"functions": {
|
|
107
|
+
"source": "functions",
|
|
108
|
+
"runtime": "nodejs20"
|
|
109
|
+
},
|
|
110
|
+
"firestore": {
|
|
111
|
+
"rules": "firestore.rules",
|
|
112
|
+
"indexes": "firestore.indexes.json"
|
|
113
|
+
},
|
|
114
|
+
"emulators": {
|
|
115
|
+
"functions": { "port": 5001 },
|
|
116
|
+
"firestore": { "port": 8080 },
|
|
117
|
+
"hosting": { "port": 5000 }
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
</example>
|