firebase-tools 15.23.0 → 15.25.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 +4 -2
- package/lib/appcheck/api.js +42 -0
- package/lib/appcheck/prompts.js +41 -0
- package/lib/appcheck/types.js +2 -0
- package/lib/bin/cli.js +9 -2
- package/lib/bin/progressiveHelp.js +126 -0
- package/lib/checkValidTargetFilters.js +1 -1
- package/lib/command.js +11 -10
- package/lib/commands/ailogic-config-get.js +75 -0
- package/lib/commands/ailogic-config-set.js +109 -0
- package/lib/commands/ailogic-providers-disable.js +39 -0
- package/lib/commands/ailogic-providers-enable.js +28 -0
- package/lib/commands/ailogic-providers-list.js +29 -0
- package/lib/commands/appcheck-debugtokens-create.js +95 -0
- package/lib/commands/appcheck-debugtokens-delete.js +48 -0
- package/lib/commands/appcheck-debugtokens-list.js +35 -0
- package/lib/commands/apps-sdkconfig.js +2 -23
- package/lib/commands/database-get.js +1 -1
- package/lib/commands/dataconnect-execute.js +1 -1
- package/lib/commands/deploy.js +27 -64
- package/lib/commands/index.js +15 -0
- package/lib/deploy/apphosting/index.js +26 -1
- package/lib/deploy/auth/index.js +18 -1
- package/lib/deploy/database/index.js +16 -1
- package/lib/deploy/dataconnect/index.js +19 -1
- package/lib/deploy/extensions/index.js +9 -1
- package/lib/deploy/firestore/index.js +20 -1
- package/lib/deploy/functions/build.js +93 -3
- package/lib/deploy/functions/index.js +33 -1
- package/lib/deploy/functions/params.js +68 -26
- package/lib/deploy/functions/prepare.js +34 -8
- package/lib/deploy/functions/prompts.js +19 -0
- package/lib/deploy/functions/release/index.js +19 -12
- package/lib/deploy/functions/release/lifecycle.js +38 -5
- package/lib/deploy/functions/release/planner.js +3 -1
- package/lib/deploy/functions/runtimes/node/index.js +8 -7
- package/lib/deploy/functions/runtimes/node/versioning.js +8 -3
- package/lib/deploy/functions/validate.js +5 -2
- package/lib/deploy/hosting/index.js +30 -1
- package/lib/deploy/hosting/uploader.js +2 -1
- package/lib/deploy/index.js +68 -8
- package/lib/deploy/remoteconfig/index.js +9 -1
- package/lib/deploy/storage/index.js +16 -1
- package/lib/emulator/dataconnect/pgliteServer.js +2 -1
- package/lib/emulator/downloadableEmulatorInfo.json +30 -30
- package/lib/emulator/downloadableEmulators.js +1 -0
- package/lib/emulator/hubExport.js +2 -1
- package/lib/emulator/storage/apis/firebase.js +24 -5
- package/lib/emulator/storage/apis/gcloud.js +16 -6
- package/lib/emulator/storage/rules/runtime.js +45 -33
- package/lib/emulator/storage/server.js +2 -5
- package/lib/emulator/storage/upload.js +1 -0
- package/lib/ensureApiEnabled.js +8 -0
- package/lib/experiments.js +16 -0
- package/lib/extensions/warnings.js +64 -0
- package/lib/frameworks/utils.js +50 -1
- package/lib/functions/env.js +22 -2
- package/lib/functions/secrets.js +4 -1
- package/lib/gcp/ailogic.js +165 -1
- package/lib/gcp/cloudfunctionsv2.js +7 -0
- package/lib/gcp/firedata.js +5 -1
- package/lib/gcp/serviceusage.js +26 -0
- package/lib/hosting/proxy.js +15 -3
- package/lib/index.js +0 -1
- package/lib/init/features/ailogic/index.js +3 -29
- package/lib/init/features/database.js +1 -1
- package/lib/management/apps.js +16 -5
- package/lib/mcp/onemcp/onemcp_server.js +28 -9
- package/lib/mcp/tools/core/get_security_rules.js +2 -1
- package/lib/profiler.js +1 -1
- package/lib/streamUtils.js +3 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +2 -2
package/lib/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.developerKnowledgeOrigin = exports.cloudTestingOrigin = exports.appTestingOrigin = exports.aiLogicProxyOrigin = exports.vertexAIOrigin = exports.cloudSQLAdminOrigin = exports.dataConnectLocalConnString = exports.dataconnectP4SADomain = exports.dataconnectOrigin = exports.githubClientSecret = exports.githubClientId = exports.computeOrigin = exports.secretManagerOrigin = exports.githubApiOrigin = exports.githubOrigin = exports.studioApiOrigin = exports.serviceUsageOrigin = exports.cloudRunApiOrigin = void 0;
|
|
3
|
+
exports.firebaseStorageOrigin = exports.storageOrigin = exports.runtimeconfigOrigin = exports.rulesOrigin = exports.resourceManagerOrigin = exports.crashlyticsApiOrigin = exports.messagingApiOrigin = exports.remoteConfigApiOrigin = exports.rtdbMetadataOrigin = exports.rtdbManagementOrigin = exports.realtimeOrigin = exports.extensionsTOSOrigin = exports.extensionsPublisherOrigin = exports.extensionsOrigin = exports.iamOrigin = exports.identityOrigin = exports.hostingOrigin = exports.googleOrigin = exports.pubsubOrigin = exports.cloudTasksOrigin = exports.cloudschedulerOrigin = exports.cloudbuildOrigin = exports.functionsDefaultRegion = exports.runOrigin = exports.functionsV2Origin = exports.functionsOrigin = exports.firestoreOrigin = exports.firestoreOriginOrEmulator = exports.firedataOrigin = exports.firebaseExtensionsRegistryOrigin = exports.firebaseApiOrigin = exports.eventarcOrigin = exports.consoleOrigin = exports.authManagementOrigin = exports.authOrigin = exports.apphostingGitHubAppInstallationURL = exports.apphostingP4SADomain = exports.apphostingOrigin = exports.appDistributionOrigin = exports.appCheckOrigin = exports.artifactRegistryDomain = exports.developerConnectP4SADomain = exports.developerConnectOrigin = exports.containerRegistryDomain = exports.cloudMonitoringOrigin = exports.cloudloggingOrigin = exports.cloudbillingOrigin = exports.clientSecret = exports.clientId = exports.authProxyOrigin = void 0;
|
|
4
|
+
exports.developerKnowledgeOrigin = exports.cloudTestingOrigin = exports.appTestingOrigin = exports.aiLogicProxyOrigin = exports.vertexAIOrigin = exports.cloudSQLAdminOrigin = exports.dataConnectLocalConnString = exports.dataconnectP4SADomain = exports.dataconnectOrigin = exports.githubClientSecret = exports.githubClientId = exports.computeOrigin = exports.secretManagerOrigin = exports.githubApiOrigin = exports.githubOrigin = exports.studioApiOrigin = exports.serviceUsageOrigin = exports.cloudRunApiOrigin = exports.hostingApiOrigin = void 0;
|
|
5
5
|
exports.getScopes = getScopes;
|
|
6
6
|
exports.setScopes = setScopes;
|
|
7
7
|
const constants_1 = require("./emulator/constants");
|
|
@@ -29,6 +29,8 @@ const developerConnectP4SADomain = () => utils.envOverride("DEVELOPERCONNECT_P4S
|
|
|
29
29
|
exports.developerConnectP4SADomain = developerConnectP4SADomain;
|
|
30
30
|
const artifactRegistryDomain = () => utils.envOverride("ARTIFACT_REGISTRY_DOMAIN", "https://artifactregistry.googleapis.com");
|
|
31
31
|
exports.artifactRegistryDomain = artifactRegistryDomain;
|
|
32
|
+
const appCheckOrigin = () => utils.envOverride("FIREBASE_APPCHECK_URL", "https://firebaseappcheck.googleapis.com");
|
|
33
|
+
exports.appCheckOrigin = appCheckOrigin;
|
|
32
34
|
const appDistributionOrigin = () => utils.envOverride("FIREBASE_APP_DISTRIBUTION_URL", "https://firebaseappdistribution.googleapis.com");
|
|
33
35
|
exports.appDistributionOrigin = appDistributionOrigin;
|
|
34
36
|
const apphostingOrigin = () => utils.envOverride("FIREBASE_APPHOSTING_URL", "https://firebaseapphosting.googleapis.com");
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.client = void 0;
|
|
4
|
+
exports.createDebugToken = createDebugToken;
|
|
5
|
+
exports.listDebugTokens = listDebugTokens;
|
|
6
|
+
exports.deleteDebugToken = deleteDebugToken;
|
|
7
|
+
const api_1 = require("../api");
|
|
8
|
+
const apiv2_1 = require("../apiv2");
|
|
9
|
+
const API_VERSION = "v1";
|
|
10
|
+
exports.client = new apiv2_1.Client({
|
|
11
|
+
urlPrefix: (0, api_1.appCheckOrigin)(),
|
|
12
|
+
auth: true,
|
|
13
|
+
apiVersion: API_VERSION,
|
|
14
|
+
});
|
|
15
|
+
async function createDebugToken(projectNumber, appId, displayName, token) {
|
|
16
|
+
const parent = `projects/${projectNumber}/apps/${appId}`;
|
|
17
|
+
const res = await exports.client.post(`${parent}/debugTokens`, {
|
|
18
|
+
displayName,
|
|
19
|
+
token,
|
|
20
|
+
});
|
|
21
|
+
return res.body;
|
|
22
|
+
}
|
|
23
|
+
async function listDebugTokens(projectNumber, appId) {
|
|
24
|
+
const parent = `projects/${projectNumber}/apps/${appId}`;
|
|
25
|
+
const debugTokens = [];
|
|
26
|
+
let pageToken = "";
|
|
27
|
+
do {
|
|
28
|
+
const queryParams = {};
|
|
29
|
+
if (pageToken) {
|
|
30
|
+
queryParams.pageToken = pageToken;
|
|
31
|
+
}
|
|
32
|
+
const res = await exports.client.get(`${parent}/debugTokens`, { queryParams });
|
|
33
|
+
if (res.body?.debugTokens) {
|
|
34
|
+
debugTokens.push(...res.body.debugTokens);
|
|
35
|
+
}
|
|
36
|
+
pageToken = res.body?.nextPageToken || "";
|
|
37
|
+
} while (pageToken);
|
|
38
|
+
return debugTokens;
|
|
39
|
+
}
|
|
40
|
+
async function deleteDebugToken(name) {
|
|
41
|
+
await exports.client.delete(name);
|
|
42
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOrPromptProjectAndAppId = void 0;
|
|
4
|
+
exports.getOrPromptAppId = getOrPromptAppId;
|
|
5
|
+
const apps_1 = require("../management/apps");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const appUtils_1 = require("../appUtils");
|
|
8
|
+
const error_1 = require("../error");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const clc = require("colorette");
|
|
11
|
+
async function getOrPromptAppId(options) {
|
|
12
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
13
|
+
logger_1.logger.info(`Active Project: ${clc.bold(projectId)}`);
|
|
14
|
+
if (options.app) {
|
|
15
|
+
return { projectId, appId: options.app };
|
|
16
|
+
}
|
|
17
|
+
const projectDir = options.cwd || process.cwd();
|
|
18
|
+
let apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.ANY);
|
|
19
|
+
if (!apps.length) {
|
|
20
|
+
throw new error_1.FirebaseError(`There are no apps associated with project ${projectId}.`);
|
|
21
|
+
}
|
|
22
|
+
const localApps = await (0, appUtils_1.detectApps)(projectDir);
|
|
23
|
+
const localAppIds = localApps.map((a) => a.appId).filter(Boolean);
|
|
24
|
+
if (localAppIds.length > 0) {
|
|
25
|
+
const filteredApps = apps.filter((app) => localAppIds.includes(app.appId));
|
|
26
|
+
if (filteredApps.length > 0) {
|
|
27
|
+
apps = filteredApps;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (apps.length === 1) {
|
|
31
|
+
return { projectId, appId: apps[0].appId };
|
|
32
|
+
}
|
|
33
|
+
else if (options.nonInteractive) {
|
|
34
|
+
throw new error_1.FirebaseError(`Project ${projectId} has multiple apps, must specify an app id.`);
|
|
35
|
+
}
|
|
36
|
+
const selectedApp = await (0, apps_1.selectAppInteractively)(apps, apps_1.AppPlatform.ANY, {
|
|
37
|
+
message: "Select the app to register a debug token for:",
|
|
38
|
+
});
|
|
39
|
+
return { projectId, appId: selectedApp.appId };
|
|
40
|
+
}
|
|
41
|
+
exports.getOrPromptProjectAndAppId = getOrPromptAppId;
|
package/lib/bin/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ const fs = require("node:fs");
|
|
|
11
11
|
const configstore_1 = require("../configstore");
|
|
12
12
|
const errorOut_1 = require("../errorOut");
|
|
13
13
|
const logger_1 = require("../logger");
|
|
14
|
+
const progressiveHelp_1 = require("./progressiveHelp");
|
|
14
15
|
const experiments_1 = require("../experiments");
|
|
15
16
|
(0, experiments_1.enableExperimentsFromCliEnvVariable)();
|
|
16
17
|
const client = require("..");
|
|
@@ -50,6 +51,10 @@ function cli(pkg) {
|
|
|
50
51
|
}
|
|
51
52
|
process.env.IS_FIREBASE_CLI = "true";
|
|
52
53
|
const logFilename = (0, logger_1.useFileLogger)();
|
|
54
|
+
const hasJson = args.includes("--json") || args.includes("-j");
|
|
55
|
+
if (!hasJson) {
|
|
56
|
+
(0, logger_1.useConsoleLoggers)();
|
|
57
|
+
}
|
|
53
58
|
logger_1.logger.debug("-".repeat(70));
|
|
54
59
|
logger_1.logger.debug("Command: ", process.argv.join(" "));
|
|
55
60
|
logger_1.logger.debug("CLI Version: ", pkg.version);
|
|
@@ -113,16 +118,18 @@ function cli(pkg) {
|
|
|
113
118
|
(0, errorOut_1.errorOut)(err);
|
|
114
119
|
});
|
|
115
120
|
const commandName = args[0];
|
|
121
|
+
const hasHelpFlag = args.includes("--help") || args.includes("-h");
|
|
116
122
|
const isHelp = !args.length ||
|
|
117
123
|
commandName === "help" ||
|
|
118
124
|
(args.length === 1 && commandName === "ext") ||
|
|
119
|
-
commandName === "--help"
|
|
120
|
-
|
|
125
|
+
commandName === "--help" ||
|
|
126
|
+
hasHelpFlag;
|
|
121
127
|
if (hasHelpFlag) {
|
|
122
128
|
client.getCommand(commandName);
|
|
123
129
|
}
|
|
124
130
|
if (isHelp) {
|
|
125
131
|
loadAllCommands(client);
|
|
132
|
+
(0, progressiveHelp_1.setupProgressiveHelp)(client);
|
|
126
133
|
}
|
|
127
134
|
if (!args.length) {
|
|
128
135
|
client.cli.help();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupProgressiveHelp = setupProgressiveHelp;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const NAMESPACE_DESCRIPTIONS = {
|
|
7
|
+
appdistribution: "manage App Distribution resources",
|
|
8
|
+
apphosting: "manage App Hosting resources",
|
|
9
|
+
apps: "manage Firebase apps",
|
|
10
|
+
auth: "manage Firebase Auth",
|
|
11
|
+
crashlytics: "manage Crashlytics symbols and mappings",
|
|
12
|
+
database: "manage Realtime Database",
|
|
13
|
+
dataconnect: "manage Data Connect resources",
|
|
14
|
+
emulators: "start and manage local Firebase emulators",
|
|
15
|
+
experiments: "enable and disable CLI experiments",
|
|
16
|
+
ext: "manage Firebase Extensions",
|
|
17
|
+
firestore: "manage Cloud Firestore resources",
|
|
18
|
+
functions: "manage Cloud Functions",
|
|
19
|
+
hosting: "manage Firebase Hosting sites and channels",
|
|
20
|
+
projects: "manage Firebase projects",
|
|
21
|
+
remoteconfig: "manage Remote Config",
|
|
22
|
+
target: "manage deploy targets",
|
|
23
|
+
};
|
|
24
|
+
function patchHelpInformation(cmd, prefix, program) {
|
|
25
|
+
const originalHelpInformation = cmd.helpInformation;
|
|
26
|
+
cmd.helpInformation = function () {
|
|
27
|
+
const filteredCommands = program.commands.filter((subCmd) => {
|
|
28
|
+
const name = subCmd.name();
|
|
29
|
+
if (prefix === "") {
|
|
30
|
+
return !name.includes(":");
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (!name.startsWith(prefix + ":")) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const remainder = name.slice(prefix.length + 1);
|
|
37
|
+
return !remainder.includes(":");
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const originalCommands = this.commands;
|
|
41
|
+
this.commands = filteredCommands;
|
|
42
|
+
const result = originalHelpInformation.call(this);
|
|
43
|
+
this.commands = originalCommands;
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function setupProgressiveHelp(client) {
|
|
48
|
+
const program = client.cli;
|
|
49
|
+
const existingNames = new Set(program.commands.map((cmd) => cmd.name()));
|
|
50
|
+
const allNamespaces = new Set();
|
|
51
|
+
for (const cmd of program.commands) {
|
|
52
|
+
const parts = cmd.name().split(":");
|
|
53
|
+
for (let i = 1; i < parts.length; i++) {
|
|
54
|
+
const ns = parts.slice(0, i).join(":");
|
|
55
|
+
allNamespaces.add(ns);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const ns of allNamespaces) {
|
|
59
|
+
if (!existingNames.has(ns)) {
|
|
60
|
+
const description = NAMESPACE_DESCRIPTIONS[ns] || `manage ${ns} resources`;
|
|
61
|
+
const nsCmd = program.command(ns);
|
|
62
|
+
nsCmd.description(description);
|
|
63
|
+
nsCmd.action(() => {
|
|
64
|
+
nsCmd.outputHelp();
|
|
65
|
+
});
|
|
66
|
+
nsCmd.on("--help", () => {
|
|
67
|
+
logger_1.logger.info();
|
|
68
|
+
logger_1.logger.info("To see more about a specific command, run:");
|
|
69
|
+
logger_1.logger.info(` ${clc.bold("firebase " + ns + ":<command> --help")}`);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const { TARGETS, VALID_DEPLOY_TARGETS } = require("../deploy");
|
|
75
|
+
for (const targetName of VALID_DEPLOY_TARGETS) {
|
|
76
|
+
const ns = `deploy:${targetName}`;
|
|
77
|
+
if (!existingNames.has(ns)) {
|
|
78
|
+
const target = TARGETS[targetName];
|
|
79
|
+
const description = target.help || `deploy ${targetName} resources`;
|
|
80
|
+
const nsCmd = program.command(ns);
|
|
81
|
+
nsCmd.description(description);
|
|
82
|
+
nsCmd.action(() => {
|
|
83
|
+
nsCmd.outputHelp();
|
|
84
|
+
logger_1.logger.info();
|
|
85
|
+
logger_1.logger.info(`To deploy ${targetName}, run: ${clc.bold("firebase deploy --only " + targetName)}`);
|
|
86
|
+
logger_1.logger.info();
|
|
87
|
+
});
|
|
88
|
+
nsCmd.on("--help", () => {
|
|
89
|
+
logger_1.logger.info();
|
|
90
|
+
logger_1.logger.info(clc.bold(`Detailed setup and configuration for ${targetName}:`));
|
|
91
|
+
logger_1.logger.info();
|
|
92
|
+
if (target && target.detailedHelp) {
|
|
93
|
+
logger_1.logger.info(target.detailedHelp);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
logger_1.logger.info(`Configuration for ${clc.bold(targetName)} is defined in your project's ${clc.bold("firebase.json")}.`);
|
|
97
|
+
logger_1.logger.info(`For more details, see the Firebase documentation:`);
|
|
98
|
+
logger_1.logger.info(` https://firebase.google.com/docs/cli#the_firebasejson_file`);
|
|
99
|
+
}
|
|
100
|
+
logger_1.logger.info();
|
|
101
|
+
logger_1.logger.info(clc.bold("General help for firebase deploy:"));
|
|
102
|
+
logger_1.logger.info();
|
|
103
|
+
const deployCmd = program.commands.find((c) => c.name() === "deploy");
|
|
104
|
+
if (deployCmd) {
|
|
105
|
+
deployCmd.outputHelp();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
}
|
|
113
|
+
const progTyped = program;
|
|
114
|
+
patchHelpInformation(progTyped, "", progTyped);
|
|
115
|
+
for (const cmd of program.commands) {
|
|
116
|
+
const name = cmd.name();
|
|
117
|
+
if (allNamespaces.has(name)) {
|
|
118
|
+
patchHelpInformation(cmd, name, progTyped);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
program.on("--help", () => {
|
|
122
|
+
logger_1.logger.info();
|
|
123
|
+
logger_1.logger.info("To see more about a specific namespace or command, run:");
|
|
124
|
+
logger_1.logger.info(` ${clc.bold("firebase <namespace|command> --help")}`);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkValidTargetFilters = checkValidTargetFilters;
|
|
4
|
-
const deploy_1 = require("./
|
|
4
|
+
const deploy_1 = require("./deploy");
|
|
5
5
|
const error_1 = require("./error");
|
|
6
6
|
function targetsForTypes(only, ...types) {
|
|
7
7
|
return only.filter((t) => {
|
package/lib/command.js
CHANGED
|
@@ -17,8 +17,9 @@ const auth_1 = require("./auth");
|
|
|
17
17
|
const projects_1 = require("./management/projects");
|
|
18
18
|
const studio_1 = require("./management/studio");
|
|
19
19
|
const requireAuth_1 = require("./requireAuth");
|
|
20
|
-
const logger_1 = require("./logger");
|
|
21
20
|
const env_1 = require("./env");
|
|
21
|
+
const experiments = require("./experiments");
|
|
22
|
+
const warnings_1 = require("./extensions/warnings");
|
|
22
23
|
function isCommandModule(value) {
|
|
23
24
|
return typeof value === "function" && typeof value.load === "function";
|
|
24
25
|
}
|
|
@@ -74,8 +75,7 @@ class Command {
|
|
|
74
75
|
if (this.aliases) {
|
|
75
76
|
cmd.aliases(this.aliases);
|
|
76
77
|
}
|
|
77
|
-
this.options.forEach((args) => {
|
|
78
|
-
const flags = args.shift();
|
|
78
|
+
this.options.forEach(([flags, ...args]) => {
|
|
79
79
|
cmd.option(flags, ...args);
|
|
80
80
|
});
|
|
81
81
|
if (this.helpText) {
|
|
@@ -90,9 +90,6 @@ class Command {
|
|
|
90
90
|
const start = process.uptime();
|
|
91
91
|
const options = (0, lodash_1.last)(args);
|
|
92
92
|
if (args.length - 1 > cmd._args.length) {
|
|
93
|
-
if (!(0, utils_1.getInheritedOption)(options, "json") && !options.isMCP) {
|
|
94
|
-
(0, logger_1.useConsoleLoggers)();
|
|
95
|
-
}
|
|
96
93
|
client.errorOut(new error_1.FirebaseError(`Too many arguments. Run ${clc.bold("firebase help " + this.name)} for usage instructions`, { exit: 1 }));
|
|
97
94
|
return;
|
|
98
95
|
}
|
|
@@ -172,9 +169,6 @@ class Command {
|
|
|
172
169
|
if ((0, utils_1.getInheritedOption)(options, "debug")) {
|
|
173
170
|
options.debug = true;
|
|
174
171
|
}
|
|
175
|
-
if (!(0, utils_1.getInheritedOption)(options, "json") && !options.isMCP) {
|
|
176
|
-
(0, logger_1.useConsoleLoggers)();
|
|
177
|
-
}
|
|
178
172
|
if ((0, utils_1.getInheritedOption)(options, "config")) {
|
|
179
173
|
options.configPath = (0, utils_1.getInheritedOption)(options, "config");
|
|
180
174
|
}
|
|
@@ -274,10 +268,17 @@ class Command {
|
|
|
274
268
|
}
|
|
275
269
|
const options = (0, lodash_1.last)(args);
|
|
276
270
|
await this.prepare(options);
|
|
271
|
+
if (this.name.startsWith("ext:") && experiments.isEnabled("extdeprecationwarnings")) {
|
|
272
|
+
(0, warnings_1.showDeprecationWarningBefore)(this.name, options);
|
|
273
|
+
}
|
|
277
274
|
for (const before of this.befores) {
|
|
278
275
|
await before.fn(options, ...before.args);
|
|
279
276
|
}
|
|
280
|
-
|
|
277
|
+
const result = await this.actionFn(...args);
|
|
278
|
+
if (this.name.startsWith("ext:") && experiments.isEnabled("extdeprecationwarnings")) {
|
|
279
|
+
(0, warnings_1.showDeprecationWarningAfter)(this.name, options);
|
|
280
|
+
}
|
|
281
|
+
return result;
|
|
281
282
|
};
|
|
282
283
|
}
|
|
283
284
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const ailogic = require("../gcp/ailogic");
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
|
+
const READABLE_CONFIG_PATHS = [
|
|
10
|
+
"providers",
|
|
11
|
+
...ailogic.PROVIDER_TYPES.map((p) => `providers.${p}`),
|
|
12
|
+
"security",
|
|
13
|
+
...ailogic.WRITABLE_CONFIG_PATHS.filter((p) => p.startsWith("security.")),
|
|
14
|
+
"monitoring",
|
|
15
|
+
...ailogic.WRITABLE_CONFIG_PATHS.filter((p) => p.startsWith("monitoring.")),
|
|
16
|
+
];
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return typeof value === "object" && value !== null;
|
|
19
|
+
}
|
|
20
|
+
exports.command = new command_1.Command("ailogic:config:get [path]")
|
|
21
|
+
.description("read AI Logic configuration")
|
|
22
|
+
.help(`prints the full AI Logic configuration for the active project as JSON. If [path] is given, prints only that section or value.
|
|
23
|
+
|
|
24
|
+
Valid values for [path]:
|
|
25
|
+
|
|
26
|
+
${READABLE_CONFIG_PATHS.map((p) => ` ${p}`).join("\n")}
|
|
27
|
+
|
|
28
|
+
For example, to check whether requests are restricted to authenticated users:
|
|
29
|
+
|
|
30
|
+
firebase ailogic:config:get security.auth-only`)
|
|
31
|
+
.before(requirePermissions_1.requirePermissions, ["firebasevertexai.config.get", "serviceusage.services.get"])
|
|
32
|
+
.action(async (path, options) => {
|
|
33
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
34
|
+
if (path) {
|
|
35
|
+
ailogic.assertKnownConfigPath(path, READABLE_CONFIG_PATHS);
|
|
36
|
+
}
|
|
37
|
+
if (!(await ailogic.isAILogicApiEnabled(projectId))) {
|
|
38
|
+
logger_1.logger.info("Firebase AI Logic is not enabled on this project.");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const config = await ailogic.getConfig(projectId);
|
|
42
|
+
const monitoringState = config.telemetryConfig?.mode === "ALL";
|
|
43
|
+
const sampleRatePercent = config.telemetryConfig?.samplingRate !== undefined
|
|
44
|
+
? Math.round(config.telemetryConfig.samplingRate * 100)
|
|
45
|
+
: 100;
|
|
46
|
+
const needsProviders = !path || path === "providers" || path.startsWith("providers.");
|
|
47
|
+
const enabledProviders = needsProviders ? await ailogic.listProviders(projectId) : [];
|
|
48
|
+
const configObj = {
|
|
49
|
+
...(needsProviders && {
|
|
50
|
+
providers: Object.fromEntries(ailogic.PROVIDER_TYPES.map((p) => [p, enabledProviders.includes(p)])),
|
|
51
|
+
}),
|
|
52
|
+
security: {
|
|
53
|
+
"auth-only": config.trafficFilter?.firebaseAuthRequired ?? false,
|
|
54
|
+
"template-only": config.trafficFilter?.templateOnly ?? false,
|
|
55
|
+
},
|
|
56
|
+
monitoring: {
|
|
57
|
+
state: monitoringState,
|
|
58
|
+
"sample-rate-percentage": sampleRatePercent,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
if (!path) {
|
|
62
|
+
logger_1.logger.info(JSON.stringify(configObj, null, 2));
|
|
63
|
+
return configObj;
|
|
64
|
+
}
|
|
65
|
+
let val = configObj;
|
|
66
|
+
for (const part of path.split(".")) {
|
|
67
|
+
if (!isRecord(val)) {
|
|
68
|
+
val = undefined;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
val = val[part];
|
|
72
|
+
}
|
|
73
|
+
logger_1.logger.info(typeof val === "object" ? JSON.stringify(val, null, 2) : String(val));
|
|
74
|
+
return val;
|
|
75
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const ailogic = require("../gcp/ailogic");
|
|
8
|
+
const clc = require("colorette");
|
|
9
|
+
const utils = require("../utils");
|
|
10
|
+
const error_1 = require("../error");
|
|
11
|
+
const prompt_1 = require("../prompt");
|
|
12
|
+
function parseBool(pathStr, value) {
|
|
13
|
+
const normalized = value.toLowerCase();
|
|
14
|
+
if (normalized !== "true" && normalized !== "false") {
|
|
15
|
+
throw new error_1.FirebaseError(`Value for ${clc.bold(pathStr)} must be 'true' or 'false'.`);
|
|
16
|
+
}
|
|
17
|
+
return normalized === "true";
|
|
18
|
+
}
|
|
19
|
+
function buildUpdate(pathStr, value) {
|
|
20
|
+
switch (pathStr) {
|
|
21
|
+
case "security.auth-only": {
|
|
22
|
+
const boolVal = parseBool(pathStr, value);
|
|
23
|
+
return {
|
|
24
|
+
config: { trafficFilter: { firebaseAuthRequired: boolVal } },
|
|
25
|
+
updateMask: "trafficFilter.firebaseAuthRequired",
|
|
26
|
+
normalizedValue: String(boolVal),
|
|
27
|
+
confirm: boolVal
|
|
28
|
+
? {
|
|
29
|
+
message: `Enabling ${clc.bold(pathStr)} will reject requests from unauthenticated users. Continue?`,
|
|
30
|
+
isAlreadyEnabled: (current) => current.trafficFilter?.firebaseAuthRequired ?? false,
|
|
31
|
+
}
|
|
32
|
+
: undefined,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
case "security.template-only": {
|
|
36
|
+
const boolVal = parseBool(pathStr, value);
|
|
37
|
+
return {
|
|
38
|
+
config: { trafficFilter: { templateOnly: boolVal } },
|
|
39
|
+
updateMask: "trafficFilter.templateOnly",
|
|
40
|
+
normalizedValue: String(boolVal),
|
|
41
|
+
confirm: boolVal
|
|
42
|
+
? {
|
|
43
|
+
message: `Enabling ${clc.bold(pathStr)} will reject requests not using templates. Continue?`,
|
|
44
|
+
isAlreadyEnabled: (current) => current.trafficFilter?.templateOnly ?? false,
|
|
45
|
+
}
|
|
46
|
+
: undefined,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
case "monitoring.state": {
|
|
50
|
+
const boolVal = parseBool(pathStr, value);
|
|
51
|
+
return {
|
|
52
|
+
config: { telemetryConfig: { mode: boolVal ? "ALL" : "NONE" } },
|
|
53
|
+
updateMask: "telemetryConfig.mode",
|
|
54
|
+
normalizedValue: String(boolVal),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
case "monitoring.sample-rate-percentage": {
|
|
58
|
+
if (!/^\d+$/.test(value) || Number(value) < 1 || Number(value) > 100) {
|
|
59
|
+
throw new error_1.FirebaseError(`Value for ${clc.bold(pathStr)} must be an integer in the range 1-100.`);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
config: { telemetryConfig: { samplingRate: Number(value) / 100 } },
|
|
63
|
+
updateMask: "telemetryConfig.samplingRate",
|
|
64
|
+
normalizedValue: String(Number(value)),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
default:
|
|
68
|
+
throw new error_1.FirebaseError(`Unknown configuration path: ${pathStr}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.command = new command_1.Command("ailogic:config:set <path> <value>")
|
|
72
|
+
.description("set one configuration value")
|
|
73
|
+
.help(`sets one AI Logic configuration value on the active project.
|
|
74
|
+
|
|
75
|
+
Valid values for <path>, and the <value> each accepts:
|
|
76
|
+
|
|
77
|
+
security.auth-only true|false - only allow requests from authenticated users
|
|
78
|
+
security.template-only true|false - only allow requests that use a server template
|
|
79
|
+
monitoring.state true|false - turn AI monitoring on or off
|
|
80
|
+
monitoring.sample-rate-percentage 1-100 - percentage of requests sampled for monitoring
|
|
81
|
+
|
|
82
|
+
For example, to only allow requests from authenticated users:
|
|
83
|
+
|
|
84
|
+
firebase ailogic:config:set security.auth-only true`)
|
|
85
|
+
.option("-f, --force", "bypass confirmation prompt")
|
|
86
|
+
.before(requirePermissions_1.requirePermissions, [
|
|
87
|
+
"firebasevertexai.config.update",
|
|
88
|
+
"firebasevertexai.config.get",
|
|
89
|
+
"serviceusage.services.get",
|
|
90
|
+
])
|
|
91
|
+
.action(async (pathStr, value, options) => {
|
|
92
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
93
|
+
ailogic.assertKnownConfigPath(pathStr, ailogic.WRITABLE_CONFIG_PATHS);
|
|
94
|
+
const update = buildUpdate(pathStr, value);
|
|
95
|
+
await ailogic.ensureAILogicApiEnabled(projectId, options);
|
|
96
|
+
if (update.confirm && !update.confirm.isAlreadyEnabled(await ailogic.getConfig(projectId))) {
|
|
97
|
+
const confirmed = await (0, prompt_1.confirm)({
|
|
98
|
+
message: update.confirm.message,
|
|
99
|
+
force: options.force,
|
|
100
|
+
nonInteractive: options.nonInteractive,
|
|
101
|
+
});
|
|
102
|
+
if (!confirmed) {
|
|
103
|
+
throw new error_1.FirebaseError("Command aborted.", { exit: 1 });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
await ailogic.updateConfig(projectId, update.config, [update.updateMask]);
|
|
107
|
+
utils.logSuccess(`Updated ${clc.bold(pathStr)} = ${update.normalizedValue}`);
|
|
108
|
+
return { path: pathStr, value: update.normalizedValue };
|
|
109
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const ailogic = require("../gcp/ailogic");
|
|
8
|
+
const clc = require("colorette");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const error_1 = require("../error");
|
|
11
|
+
const prompt_1 = require("../prompt");
|
|
12
|
+
exports.command = new command_1.Command("ailogic:providers:disable <providerType>")
|
|
13
|
+
.description("disable a Gemini API provider service")
|
|
14
|
+
.help(`disables the Google Cloud API that backs a Gemini API provider. Running apps that use the provider will no longer be able to invoke it.
|
|
15
|
+
|
|
16
|
+
Valid values for <providerType>:
|
|
17
|
+
|
|
18
|
+
gemini-developer-api the Gemini Developer API
|
|
19
|
+
gemini-agent-platform-api the Gemini API on the Agent Platform
|
|
20
|
+
|
|
21
|
+
For example:
|
|
22
|
+
|
|
23
|
+
firebase ailogic:providers:disable gemini-developer-api`)
|
|
24
|
+
.option("-f, --force", "bypass confirmation prompt")
|
|
25
|
+
.before(requirePermissions_1.requirePermissions, ["serviceusage.services.disable", "firebasevertexai.config.update"])
|
|
26
|
+
.action(async (providerType, options) => {
|
|
27
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
28
|
+
const provider = ailogic.parseProviderType(providerType);
|
|
29
|
+
const confirmed = await (0, prompt_1.confirm)({
|
|
30
|
+
message: `You are about to disable ${clc.bold(provider)}. This will stop running apps from invoking it. Are you sure?`,
|
|
31
|
+
force: options.force,
|
|
32
|
+
nonInteractive: options.nonInteractive,
|
|
33
|
+
});
|
|
34
|
+
if (!confirmed) {
|
|
35
|
+
throw new error_1.FirebaseError("Command aborted.", { exit: 1 });
|
|
36
|
+
}
|
|
37
|
+
await ailogic.disableProvider(projectId, provider);
|
|
38
|
+
logger_1.logger.info(clc.green(`Successfully disabled provider: ${clc.bold(provider)}`));
|
|
39
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const ailogic = require("../gcp/ailogic");
|
|
8
|
+
const clc = require("colorette");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
exports.command = new command_1.Command("ailogic:providers:enable <providerType>")
|
|
11
|
+
.description("enable a Gemini API provider service")
|
|
12
|
+
.help(`enables the Google Cloud APIs that back a Gemini API provider, along with the Firebase AI Logic API.
|
|
13
|
+
|
|
14
|
+
Valid values for <providerType>:
|
|
15
|
+
|
|
16
|
+
gemini-developer-api the Gemini Developer API
|
|
17
|
+
gemini-agent-platform-api the Gemini API on the Agent Platform; requires the Blaze (pay-as-you-go) plan
|
|
18
|
+
|
|
19
|
+
For example:
|
|
20
|
+
|
|
21
|
+
firebase ailogic:providers:enable gemini-developer-api`)
|
|
22
|
+
.before(requirePermissions_1.requirePermissions, ["serviceusage.services.enable", "firebasevertexai.config.update"])
|
|
23
|
+
.action(async (providerType, options) => {
|
|
24
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
25
|
+
const provider = ailogic.parseProviderType(providerType);
|
|
26
|
+
await ailogic.enableProvider(projectId, provider);
|
|
27
|
+
logger_1.logger.info(clc.green(`Successfully enabled provider: ${clc.bold(provider)}`));
|
|
28
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const ailogic = require("../gcp/ailogic");
|
|
8
|
+
const clc = require("colorette");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const Table = require("cli-table3");
|
|
11
|
+
exports.command = new command_1.Command("ailogic:providers:list")
|
|
12
|
+
.description("list which Gemini API providers are enabled")
|
|
13
|
+
.before(requirePermissions_1.requirePermissions, ["serviceusage.services.get"])
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
|
+
const enabledProviders = await ailogic.listProviders(projectId);
|
|
17
|
+
if (enabledProviders.length === 0) {
|
|
18
|
+
logger_1.logger.info(clc.bold("No Gemini API providers are enabled."));
|
|
19
|
+
return enabledProviders;
|
|
20
|
+
}
|
|
21
|
+
const tableHead = ["Provider", "Status"];
|
|
22
|
+
const table = new Table({ head: tableHead, style: { head: ["green"] } });
|
|
23
|
+
for (const provider of ailogic.PROVIDER_TYPES) {
|
|
24
|
+
const isEnabled = enabledProviders.includes(provider);
|
|
25
|
+
table.push([clc.bold(provider), isEnabled ? clc.green("Enabled") : clc.red("Disabled")]);
|
|
26
|
+
}
|
|
27
|
+
logger_1.logger.info(table.toString());
|
|
28
|
+
return enabledProviders;
|
|
29
|
+
});
|