firebase-tools-with-isolate 15.11.0-3 → 15.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/agentSkills.js +70 -0
- package/lib/api.js +3 -1
- package/lib/apphosting/backend.js +22 -3
- package/lib/apphosting/config.js +19 -2
- package/lib/apphosting/localbuilds.js +25 -4
- package/lib/apphosting/prompts.js +35 -0
- package/lib/bin/mcp.js +5 -1
- package/lib/commands/apphosting-backends-create.js +19 -2
- package/lib/commands/apphosting-backends-list.js +25 -5
- package/lib/commands/ext-info.js +5 -1
- package/lib/commands/functions-delete.js +1 -0
- package/lib/commands/functions-export.js +40 -0
- package/lib/commands/index.js +3 -0
- package/lib/commands/init.js +1 -0
- package/lib/deploy/apphosting/deploy.js +11 -6
- package/lib/deploy/apphosting/prepare.js +88 -4
- package/lib/deploy/apphosting/release.js +2 -5
- package/lib/deploy/apphosting/util.js +45 -2
- package/lib/deploy/functions/prepare.js +5 -1
- package/lib/deploy/functions/prepareFunctionsUpload.js +5 -2
- package/lib/deploy/functions/release/fabricator.js +4 -3
- package/lib/deploy/functions/release/index.js +5 -0
- package/lib/deploy/functions/services/ailogic.js +68 -0
- package/lib/deploy/functions/services/index.js +4 -0
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/storage/rules/manager.js +10 -3
- package/lib/emulator/storage/rules/runtime.js +9 -7
- package/lib/experiments.js +22 -0
- package/lib/extensions/listExtensions.js +2 -0
- package/lib/firebase_studio/migrate.js +30 -61
- package/lib/functions/iac/export.js +36 -0
- package/lib/functions/iac/terraform.js +146 -0
- package/lib/gcp/ailogic.js +108 -0
- package/lib/gcp/apphosting.js +6 -0
- package/lib/gcp/cloudfunctionsv2.js +24 -0
- package/lib/gcp/cloudsql/cloudsqladmin.js +1 -1
- package/lib/init/features/agentSkills.js +26 -0
- package/lib/init/features/apphosting.js +11 -2
- package/lib/init/features/dataconnect/sdk.js +26 -12
- package/lib/init/features/functions/index.js +7 -4
- package/lib/init/features/index.js +4 -1
- package/lib/init/index.js +6 -0
- package/lib/mcp/index.js +1 -1
- package/lib/mcp/tools/core/read_resources.js +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +8 -0
- package/package.json +7 -5
- package/standalone/package.json +1 -1
- package/templates/extensions/typescript/package.lint.json +1 -1
- package/templates/extensions/typescript/package.nolint.json +1 -1
- package/templates/extensions/typescript/tsconfig.json +1 -0
- package/templates/init/functions/typescript/package-ongraphrequest.lint.json +1 -1
- package/templates/init/functions/typescript/package-ongraphrequest.nolint.json +1 -1
- package/templates/init/functions/typescript/package.lint.json +1 -1
- package/templates/init/functions/typescript/package.nolint.json +1 -1
- package/templates/init/functions/typescript/tsconfig.json +1 -0
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@ All workflows use Node 24 and npm OIDC trusted publishing (provenance).
|
|
|
97
97
|
|
|
98
98
|
- **[`sync-upstream.yml`](.github/workflows/sync-upstream.yml)** — Runs daily (09:00 UTC) and on manual dispatch. Checks for new upstream firebase-tools releases and opens a PR with the synced result. Can target a specific version.
|
|
99
99
|
|
|
100
|
-
- **[`update-isolate.yml`](.github/workflows/update-isolate.yml)** — Updates the `isolate-package` dependency to a given version, bumps the fork's pre-release number (e.g. `15.13.0-0` → `15.13.0-1`), and
|
|
100
|
+
- **[`update-isolate.yml`](.github/workflows/update-isolate.yml)** — Updates the `isolate-package` dependency to a given version, bumps the fork's pre-release number (e.g. `15.13.0-0` → `15.13.0-1`), and opens a PR targeting `main`. Follow up with the publish workflow to release to npm. Follow up with the publish workflow to release to npm.
|
|
101
101
|
|
|
102
102
|
- **[`publish.yml`](.github/workflows/publish.yml)** — Publishes the fork to npm. Choose `next` for pre-release testing or `latest` to promote a stable release (which strips the pre-release suffix, e.g. `15.13.0-0` → `15.13.0`). Creates a git tag and GitHub release.
|
|
103
103
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promptForAgentSkills = promptForAgentSkills;
|
|
4
|
+
exports.installAgentSkills = installAgentSkills;
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const utils = require("./utils");
|
|
7
|
+
const prompt = require("./prompt");
|
|
8
|
+
const error_1 = require("./error");
|
|
9
|
+
async function promptForAgentSkills() {
|
|
10
|
+
return prompt.confirm({
|
|
11
|
+
message: "Would you like to install agent skills for Firebase?",
|
|
12
|
+
default: true,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async function installAgentSkills(options) {
|
|
16
|
+
if (!utils.commandExistsSync("npx")) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const args = [
|
|
20
|
+
"-y",
|
|
21
|
+
"skills",
|
|
22
|
+
"add",
|
|
23
|
+
"firebase/agent-skills",
|
|
24
|
+
"--skill",
|
|
25
|
+
"*",
|
|
26
|
+
"-y",
|
|
27
|
+
];
|
|
28
|
+
if (options.agentName) {
|
|
29
|
+
args.push("-a", options.agentName);
|
|
30
|
+
}
|
|
31
|
+
if (options.global) {
|
|
32
|
+
args.push("-g");
|
|
33
|
+
}
|
|
34
|
+
if (options.background) {
|
|
35
|
+
utils.logBullet("Installing Agent skills in the background...");
|
|
36
|
+
try {
|
|
37
|
+
const child = (0, child_process_1.spawn)("npx", args, {
|
|
38
|
+
cwd: options.cwd,
|
|
39
|
+
stdio: "ignore",
|
|
40
|
+
detached: true,
|
|
41
|
+
shell: process.platform === "win32",
|
|
42
|
+
});
|
|
43
|
+
child.unref();
|
|
44
|
+
utils.logSuccess("Agent skills installation started");
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
utils.logWarning(`Could not start Agent skills installation: ${(0, error_1.getErrMsg)(err)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
utils.logBullet("Adding Agent skills...");
|
|
52
|
+
try {
|
|
53
|
+
const result = (0, child_process_1.spawnSync)("npx", args, {
|
|
54
|
+
cwd: options.cwd,
|
|
55
|
+
stdio: "ignore",
|
|
56
|
+
shell: process.platform === "win32",
|
|
57
|
+
});
|
|
58
|
+
if (result.error) {
|
|
59
|
+
throw result.error;
|
|
60
|
+
}
|
|
61
|
+
if (result.status !== 0) {
|
|
62
|
+
throw new Error(`npx skills add exited with code ${result.status}`);
|
|
63
|
+
}
|
|
64
|
+
utils.logSuccess("Added Agent skills");
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
utils.logWarning(`Could not add Agent skills: ${(0, error_1.getErrMsg)(err)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
package/lib/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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.dynamicLinksKey = exports.dynamicLinksOrigin = exports.consoleOrigin = exports.authManagementOrigin = exports.authOrigin = exports.apphostingGitHubAppInstallationURL = exports.apphostingP4SADomain = exports.apphostingOrigin = exports.appDistributionOrigin = 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.cloudAiCompanionOrigin = 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 = exports.firebaseStorageOrigin = void 0;
|
|
4
|
+
exports.developerKnowledgeOrigin = exports.cloudTestingOrigin = exports.appTestingOrigin = exports.cloudAiCompanionOrigin = 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 = exports.firebaseStorageOrigin = void 0;
|
|
5
5
|
exports.getScopes = getScopes;
|
|
6
6
|
exports.setScopes = setScopes;
|
|
7
7
|
const constants_1 = require("./emulator/constants");
|
|
@@ -146,6 +146,8 @@ const cloudSQLAdminOrigin = () => utils.envOverride("CLOUD_SQL_URL", "https://sq
|
|
|
146
146
|
exports.cloudSQLAdminOrigin = cloudSQLAdminOrigin;
|
|
147
147
|
const vertexAIOrigin = () => utils.envOverride("VERTEX_AI_URL", "https://aiplatform.googleapis.com");
|
|
148
148
|
exports.vertexAIOrigin = vertexAIOrigin;
|
|
149
|
+
const aiLogicProxyOrigin = () => utils.envOverride("AI_LOGIC_PROXY_URL", "https://firebasevertexai.googleapis.com");
|
|
150
|
+
exports.aiLogicProxyOrigin = aiLogicProxyOrigin;
|
|
149
151
|
const cloudAiCompanionOrigin = () => utils.envOverride("CLOUD_AI_COMPANION_URL", "https://cloudaicompanion.googleapis.com");
|
|
150
152
|
exports.cloudAiCompanionOrigin = cloudAiCompanionOrigin;
|
|
151
153
|
const appTestingOrigin = () => utils.envOverride("FIREBASE_APP_TESTING_URL", "https://firebaseapptesting.googleapis.com");
|
|
@@ -34,6 +34,8 @@ const ora = require("ora");
|
|
|
34
34
|
const node_fetch_1 = require("node-fetch");
|
|
35
35
|
const rollout_1 = require("./rollout");
|
|
36
36
|
const fuzzy = require("fuzzy");
|
|
37
|
+
const experiments_1 = require("../experiments");
|
|
38
|
+
const prompts_1 = require("./prompts");
|
|
37
39
|
const DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME = "firebase-app-hosting-compute";
|
|
38
40
|
const apphostingPollerOptions = {
|
|
39
41
|
apiOrigin: (0, api_1.apphostingOrigin)(),
|
|
@@ -64,7 +66,7 @@ async function awaitTlsReady(url) {
|
|
|
64
66
|
}
|
|
65
67
|
} while (!ready);
|
|
66
68
|
}
|
|
67
|
-
async function doSetup(projectId, nonInteractive, webAppName, backendId, serviceAccount, primaryRegion, rootDir) {
|
|
69
|
+
async function doSetup(projectId, nonInteractive, webAppName, backendId, serviceAccount, primaryRegion, rootDir, runtime, automaticBaseImageUpdatesDisabled) {
|
|
68
70
|
await ensureRequiredApisEnabled(projectId);
|
|
69
71
|
await ensureAppHostingComputeServiceAccount(projectId, serviceAccount ? serviceAccount : null);
|
|
70
72
|
let location = primaryRegion;
|
|
@@ -97,12 +99,25 @@ async function doSetup(projectId, nonInteractive, webAppName, backendId, service
|
|
|
97
99
|
if (!location || !backendId) {
|
|
98
100
|
throw new error_1.FirebaseError("Internal error: location or backendId is not defined.");
|
|
99
101
|
}
|
|
102
|
+
if (runtime === undefined && (0, experiments_1.isEnabled)("abiu")) {
|
|
103
|
+
if (nonInteractive) {
|
|
104
|
+
runtime = prompts_1.DEFAULT_RUNTIME;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
runtime = await (0, prompts_1.promptRuntime)(projectId, location);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (automaticBaseImageUpdatesDisabled === undefined && (0, experiments_1.isEnabled)("abiu")) {
|
|
111
|
+
if (!nonInteractive) {
|
|
112
|
+
automaticBaseImageUpdatesDisabled = !(await (0, prompts_1.promptAutomaticBaseImageUpdates)());
|
|
113
|
+
}
|
|
114
|
+
}
|
|
100
115
|
const webApp = await app_1.webApps.getOrCreateWebApp(projectId, webAppName ? webAppName : null, backendId);
|
|
101
116
|
if (!webApp) {
|
|
102
117
|
(0, utils_1.logWarning)(`Firebase web app not set`);
|
|
103
118
|
}
|
|
104
119
|
const createBackendSpinner = ora("Creating your new backend...").start();
|
|
105
|
-
const backend = await createBackend(projectId, location, backendId, serviceAccount ? serviceAccount : null, gitRepositoryLink, webApp?.id, rootDir);
|
|
120
|
+
const backend = await createBackend(projectId, location, backendId, serviceAccount ? serviceAccount : null, gitRepositoryLink, webApp?.id, rootDir, runtime, automaticBaseImageUpdatesDisabled);
|
|
106
121
|
createBackendSpinner.succeed(`Successfully created backend!\n\t${backend.name}\n`);
|
|
107
122
|
if (nonInteractive) {
|
|
108
123
|
return;
|
|
@@ -227,7 +242,7 @@ async function promptNewBackendId(projectId, location) {
|
|
|
227
242
|
function defaultComputeServiceAccountEmail(projectId) {
|
|
228
243
|
return `${DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME}@${projectId}.iam.gserviceaccount.com`;
|
|
229
244
|
}
|
|
230
|
-
async function createBackend(projectId, location, backendId, serviceAccount, repository, webAppId, rootDir = "/") {
|
|
245
|
+
async function createBackend(projectId, location, backendId, serviceAccount, repository, webAppId, rootDir = "/", runtime, automaticBaseImageUpdatesDisabled) {
|
|
231
246
|
const defaultServiceAccount = defaultComputeServiceAccountEmail(projectId);
|
|
232
247
|
const backendReqBody = {
|
|
233
248
|
servingLocality: "GLOBAL_ACCESS",
|
|
@@ -241,6 +256,10 @@ async function createBackend(projectId, location, backendId, serviceAccount, rep
|
|
|
241
256
|
serviceAccount: serviceAccount || defaultServiceAccount,
|
|
242
257
|
appId: webAppId,
|
|
243
258
|
};
|
|
259
|
+
if ((0, experiments_1.isEnabled)("abiu")) {
|
|
260
|
+
backendReqBody.runtime = { value: runtime ?? "" };
|
|
261
|
+
backendReqBody.automaticBaseImageUpdatesDisabled = automaticBaseImageUpdatesDisabled;
|
|
262
|
+
}
|
|
244
263
|
async function createBackendAndPoll() {
|
|
245
264
|
const op = await apphosting.createBackend(projectId, location, backendReqBody, backendId);
|
|
246
265
|
return await poller.pollOperation({
|
package/lib/apphosting/config.js
CHANGED
|
@@ -12,6 +12,7 @@ exports.maybeAddSecretToYaml = maybeAddSecretToYaml;
|
|
|
12
12
|
exports.maybeGenerateEmulatorYaml = maybeGenerateEmulatorYaml;
|
|
13
13
|
exports.overrideChosenEnv = overrideChosenEnv;
|
|
14
14
|
exports.suggestedTestKeyName = suggestedTestKeyName;
|
|
15
|
+
exports.splitEnvVars = splitEnvVars;
|
|
15
16
|
const path_1 = require("path");
|
|
16
17
|
const fs_1 = require("fs");
|
|
17
18
|
const yaml = require("yaml");
|
|
@@ -23,7 +24,6 @@ const yaml_1 = require("./yaml");
|
|
|
23
24
|
const logger_1 = require("../logger");
|
|
24
25
|
const csm = require("../gcp/secretManager");
|
|
25
26
|
const error_1 = require("../error");
|
|
26
|
-
const path_2 = require("path");
|
|
27
27
|
exports.APPHOSTING_BASE_YAML_FILE = "apphosting.yaml";
|
|
28
28
|
exports.APPHOSTING_EMULATORS_YAML_FILE = "apphosting.emulator.yaml";
|
|
29
29
|
exports.APPHOSTING_LOCAL_YAML_FILE = "apphosting.local.yaml";
|
|
@@ -69,7 +69,7 @@ function load(yamlPath) {
|
|
|
69
69
|
const dynamicDispatch = exports;
|
|
70
70
|
async function getAppHostingConfiguration(backendDir) {
|
|
71
71
|
const appHostingConfigPaths = dynamicDispatch.listAppHostingFilesInPath(backendDir);
|
|
72
|
-
const fileNameToPathMap = Object.fromEntries(appHostingConfigPaths.map((path) => [(0,
|
|
72
|
+
const fileNameToPathMap = Object.fromEntries(appHostingConfigPaths.map((path) => [(0, path_1.basename)(path), path]));
|
|
73
73
|
const output = yaml_1.AppHostingYamlConfig.empty();
|
|
74
74
|
const baseFilePath = fileNameToPathMap[exports.APPHOSTING_BASE_YAML_FILE];
|
|
75
75
|
const emulatorsFilePath = fileNameToPathMap[exports.APPHOSTING_EMULATORS_YAML_FILE];
|
|
@@ -246,3 +246,20 @@ async function overrideChosenEnv(projectId, env) {
|
|
|
246
246
|
function suggestedTestKeyName(variable) {
|
|
247
247
|
return "test-" + variable.replace(/_/g, "-").toLowerCase();
|
|
248
248
|
}
|
|
249
|
+
function splitEnvVars(env) {
|
|
250
|
+
const build = {};
|
|
251
|
+
const runtime = {};
|
|
252
|
+
for (const [key, val] of Object.entries(env)) {
|
|
253
|
+
const envVal = { ...val };
|
|
254
|
+
if (envVal.value !== undefined) {
|
|
255
|
+
envVal.value = String(envVal.value);
|
|
256
|
+
}
|
|
257
|
+
if (val.availability?.includes("BUILD") || !val.availability) {
|
|
258
|
+
build[key] = envVal;
|
|
259
|
+
}
|
|
260
|
+
if (val.availability?.includes("RUNTIME") || !val.availability) {
|
|
261
|
+
runtime[key] = envVal;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return { build, runtime };
|
|
265
|
+
}
|
|
@@ -2,10 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.localBuild = localBuild;
|
|
4
4
|
const build_1 = require("@apphosting/build");
|
|
5
|
-
async function localBuild(projectRoot, framework) {
|
|
6
|
-
const
|
|
5
|
+
async function localBuild(projectRoot, framework, env = {}) {
|
|
6
|
+
const originalEnv = { ...process.env };
|
|
7
|
+
const addedEnv = toProcessEnv(env);
|
|
8
|
+
for (const [key, value] of Object.entries(addedEnv)) {
|
|
9
|
+
process.env[key] = value;
|
|
10
|
+
}
|
|
11
|
+
let apphostingBuildOutput;
|
|
12
|
+
try {
|
|
13
|
+
apphostingBuildOutput = await (0, build_1.localBuild)(projectRoot, framework);
|
|
14
|
+
}
|
|
15
|
+
finally {
|
|
16
|
+
for (const key in process.env) {
|
|
17
|
+
if (!(key in originalEnv)) {
|
|
18
|
+
delete process.env[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const [key, value] of Object.entries(originalEnv)) {
|
|
22
|
+
process.env[key] = value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
7
25
|
const annotations = Object.fromEntries(Object.entries(apphostingBuildOutput.metadata).map(([key, value]) => [key, String(value)]));
|
|
8
|
-
const
|
|
26
|
+
const discoveredEnv = apphostingBuildOutput.runConfig.environmentVariables?.map(({ variable, value, availability }) => ({
|
|
9
27
|
variable,
|
|
10
28
|
value,
|
|
11
29
|
availability,
|
|
@@ -15,7 +33,10 @@ async function localBuild(projectRoot, framework) {
|
|
|
15
33
|
annotations,
|
|
16
34
|
buildConfig: {
|
|
17
35
|
runCommand: apphostingBuildOutput.runConfig.runCommand,
|
|
18
|
-
env:
|
|
36
|
+
env: discoveredEnv ?? [],
|
|
19
37
|
},
|
|
20
38
|
};
|
|
21
39
|
}
|
|
40
|
+
function toProcessEnv(env) {
|
|
41
|
+
return Object.fromEntries(Object.entries(env).map(([key, value]) => [key, value.value || ""]));
|
|
42
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_RUNTIME = void 0;
|
|
4
|
+
exports.promptRuntime = promptRuntime;
|
|
5
|
+
exports.promptAutomaticBaseImageUpdates = promptAutomaticBaseImageUpdates;
|
|
6
|
+
const prompt_1 = require("../prompt");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const apphosting = require("../gcp/apphosting");
|
|
9
|
+
exports.DEFAULT_RUNTIME = "nodejs";
|
|
10
|
+
async function promptRuntime(projectId, location) {
|
|
11
|
+
const choices = [{ name: "Node.js (default)", value: exports.DEFAULT_RUNTIME }];
|
|
12
|
+
try {
|
|
13
|
+
const supportedRuntimes = await apphosting.listSupportedRuntimes(projectId, location);
|
|
14
|
+
for (const r of supportedRuntimes) {
|
|
15
|
+
if (r.runtimeId !== exports.DEFAULT_RUNTIME) {
|
|
16
|
+
choices.push({ name: r.runtimeId, value: r.runtimeId });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
(0, utils_1.logWarning)("Failed to list supported runtimes. Falling back to hardcoded list.");
|
|
22
|
+
choices.push({ name: "nodejs22", value: "nodejs22" });
|
|
23
|
+
}
|
|
24
|
+
return await (0, prompt_1.select)({
|
|
25
|
+
message: "Which runtime do you want to use?",
|
|
26
|
+
choices: choices,
|
|
27
|
+
default: exports.DEFAULT_RUNTIME,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async function promptAutomaticBaseImageUpdates() {
|
|
31
|
+
return await (0, prompt_1.confirm)({
|
|
32
|
+
message: "Would you like to enable Automatic Base Image Updates (ABIU)?",
|
|
33
|
+
default: true,
|
|
34
|
+
});
|
|
35
|
+
}
|
package/lib/bin/mcp.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.mcp = mcp;
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
+
const promises_1 = require("fs/promises");
|
|
7
|
+
const os_1 = require("os");
|
|
6
8
|
const util_1 = require("util");
|
|
7
9
|
const logger_1 = require("../logger");
|
|
8
10
|
const index_1 = require("../mcp/index");
|
|
@@ -82,7 +84,9 @@ async function mcp() {
|
|
|
82
84
|
if (earlyExit)
|
|
83
85
|
return;
|
|
84
86
|
(0, env_1.setFirebaseMcp)(true);
|
|
85
|
-
(0,
|
|
87
|
+
const mcpLogDir = (0, path_1.join)((0, os_1.homedir)(), ".cache", "firebase");
|
|
88
|
+
await (0, promises_1.mkdir)(mcpLogDir, { recursive: true });
|
|
89
|
+
(0, logger_1.useFileLogger)((0, path_1.join)(mcpLogDir, "firebase-debug.log"));
|
|
86
90
|
const activeFeatures = (values.only || "")
|
|
87
91
|
.split(",")
|
|
88
92
|
.map((f) => f.trim())
|
|
@@ -7,6 +7,7 @@ const projectUtils_1 = require("../projectUtils");
|
|
|
7
7
|
const requireAuth_1 = require("../requireAuth");
|
|
8
8
|
const backend_1 = require("../apphosting/backend");
|
|
9
9
|
const apphosting_1 = require("../gcp/apphosting");
|
|
10
|
+
const experiments = require("../experiments");
|
|
10
11
|
const firedata_1 = require("../gcp/firedata");
|
|
11
12
|
const requireTosAcceptance_1 = require("../requireTosAcceptance");
|
|
12
13
|
exports.command = new command_1.Command("apphosting:backends:create")
|
|
@@ -15,7 +16,15 @@ exports.command = new command_1.Command("apphosting:backends:create")
|
|
|
15
16
|
.option("--backend <backend>", "specify the name of the new backend. Required with --non-interactive.")
|
|
16
17
|
.option("-s, --service-account <serviceAccount>", "specify the service account used to run the server", "")
|
|
17
18
|
.option("--primary-region <primaryRegion>", "specify the primary region for the backend. Required with --non-interactive.")
|
|
18
|
-
.option("--root-dir <rootDir>", "specify the root directory for the backend.")
|
|
19
|
+
.option("--root-dir <rootDir>", "specify the root directory for the backend.");
|
|
20
|
+
const abiuEnabled = experiments.isEnabled("abiu");
|
|
21
|
+
if (abiuEnabled) {
|
|
22
|
+
exports.command
|
|
23
|
+
.option("--runtime [runtime]", "specify the runtime for the backend (e.g., nodejs, nodejs22)")
|
|
24
|
+
.option("--automatic-base-image-updates", "enable automatic base image updates")
|
|
25
|
+
.option("--no-automatic-base-image-updates", "disable automatic base image updates");
|
|
26
|
+
}
|
|
27
|
+
exports.command
|
|
19
28
|
.before(requireAuth_1.requireAuth)
|
|
20
29
|
.before(apphosting_1.ensureApiEnabled)
|
|
21
30
|
.before((0, requireTosAcceptance_1.requireTosAcceptance)(firedata_1.APPHOSTING_TOS_ID))
|
|
@@ -24,5 +33,13 @@ exports.command = new command_1.Command("apphosting:backends:create")
|
|
|
24
33
|
if (options.nonInteractive && (options.backend == null || options.primaryRegion == null)) {
|
|
25
34
|
throw new error_1.FirebaseError(`--non-interactive option requires --backend and --primary-region`);
|
|
26
35
|
}
|
|
27
|
-
|
|
36
|
+
const abiuAllowed = experiments.isEnabled("abiu");
|
|
37
|
+
if (!abiuAllowed && (options.runtime || options.automaticBaseImageUpdates !== undefined)) {
|
|
38
|
+
throw new error_1.FirebaseError("The --runtime and --automatic-base-image-updates flags are only available when the 'abiu' experiment is enabled. To enable it, run 'firebase experiments:enable abiu'.");
|
|
39
|
+
}
|
|
40
|
+
const runtime = abiuAllowed && typeof options.runtime === "string" ? options.runtime : undefined;
|
|
41
|
+
const automaticBaseImageUpdatesDisabled = abiuAllowed
|
|
42
|
+
? options.automaticBaseImageUpdates === false
|
|
43
|
+
: undefined;
|
|
44
|
+
return (0, backend_1.doSetup)(projectId, options.nonInteractive, options.app, options.backend, options.serviceAccount, options.primaryRegion, options.rootDir, runtime, automaticBaseImageUpdatesDisabled);
|
|
28
45
|
});
|
|
@@ -9,8 +9,8 @@ const logger_1 = require("../logger");
|
|
|
9
9
|
const projectUtils_1 = require("../projectUtils");
|
|
10
10
|
const requireAuth_1 = require("../requireAuth");
|
|
11
11
|
const apphosting = require("../gcp/apphosting");
|
|
12
|
+
const experiments_1 = require("../experiments");
|
|
12
13
|
const Table = require("cli-table3");
|
|
13
|
-
const TABLE_HEAD = ["Backend", "Repository", "URL", "Primary Region", "Updated Date"];
|
|
14
14
|
exports.command = new command_1.Command("apphosting:backends:list")
|
|
15
15
|
.description("list Firebase App Hosting backends")
|
|
16
16
|
.before(requireAuth_1.requireAuth)
|
|
@@ -29,19 +29,39 @@ exports.command = new command_1.Command("apphosting:backends:list")
|
|
|
29
29
|
return backends;
|
|
30
30
|
});
|
|
31
31
|
function printBackendsTable(backends) {
|
|
32
|
+
const abiuEnabled = (0, experiments_1.isEnabled)("abiu");
|
|
33
|
+
const head = ["Backend", "Repository", "URL", "Primary Region"];
|
|
34
|
+
if (abiuEnabled) {
|
|
35
|
+
head.push("ABIU");
|
|
36
|
+
head.push("Runtime");
|
|
37
|
+
}
|
|
38
|
+
head.push("Updated Date");
|
|
32
39
|
const table = new Table({
|
|
33
|
-
head:
|
|
40
|
+
head: head,
|
|
34
41
|
style: { head: ["green"] },
|
|
35
42
|
});
|
|
36
43
|
for (const backend of backends) {
|
|
37
44
|
const { location, id } = apphosting.parseBackendName(backend.name);
|
|
38
|
-
|
|
45
|
+
const row = [
|
|
39
46
|
id,
|
|
40
47
|
backend.codebase?.repository?.split("/").pop() ?? "",
|
|
41
48
|
backend.uri.startsWith("https:") ? backend.uri : "https://" + backend.uri,
|
|
42
49
|
location,
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
];
|
|
51
|
+
if (abiuEnabled) {
|
|
52
|
+
let abiuStatus = "N/A";
|
|
53
|
+
const runtimeValue = backend.runtime?.value ?? "";
|
|
54
|
+
if (runtimeValue === "" || runtimeValue === "nodejs") {
|
|
55
|
+
abiuStatus = "Disabled";
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
abiuStatus = backend.automaticBaseImageUpdatesDisabled ? "Disabled" : "Enabled";
|
|
59
|
+
}
|
|
60
|
+
row.push(abiuStatus);
|
|
61
|
+
row.push(backend.runtime?.value ?? "N/A");
|
|
62
|
+
}
|
|
63
|
+
row.push((0, utils_1.datetimeString)(new Date(backend.updateTime)));
|
|
64
|
+
table.push(row);
|
|
45
65
|
}
|
|
46
66
|
logger_1.logger.info(table.toString());
|
|
47
67
|
}
|
package/lib/commands/ext-info.js
CHANGED
|
@@ -19,6 +19,7 @@ exports.command = new command_1.Command("ext:info <extensionName>")
|
|
|
19
19
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
20
20
|
.action(async (extensionName, options) => {
|
|
21
21
|
let spec;
|
|
22
|
+
let version;
|
|
22
23
|
if ((0, localHelper_1.isLocalExtension)(extensionName)) {
|
|
23
24
|
if (!options.markdown) {
|
|
24
25
|
utils.logLabeledBullet(extensionsHelper_1.logPrefix, `reading extension from directory: ${extensionName}`);
|
|
@@ -39,7 +40,7 @@ exports.command = new command_1.Command("ext:info <extensionName>")
|
|
|
39
40
|
const [name, version] = extensionName.split("@");
|
|
40
41
|
extensionName = `firebase/${name}@${version || "latest"}`;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
version = await extensionsApi.getExtensionVersion(extensionName);
|
|
43
44
|
spec = version.spec;
|
|
44
45
|
}
|
|
45
46
|
if (!options.markdown) {
|
|
@@ -56,6 +57,9 @@ exports.command = new command_1.Command("ext:info <extensionName>")
|
|
|
56
57
|
const url = spec.author?.url;
|
|
57
58
|
const urlMarkdown = url ? `(**[${url}](${url})**)` : "";
|
|
58
59
|
lines.push(`**Author**: ${authorName} ${urlMarkdown}`);
|
|
60
|
+
if (version?.sourceDownloadUri) {
|
|
61
|
+
lines.push(`**Download URL**: ${version.sourceDownloadUri}`);
|
|
62
|
+
}
|
|
59
63
|
if (spec.description) {
|
|
60
64
|
lines.push(`**Description**: ${spec.description}`);
|
|
61
65
|
}
|
|
@@ -75,6 +75,7 @@ exports.command = new command_1.Command("functions:delete [filters...]")
|
|
|
75
75
|
try {
|
|
76
76
|
const fab = new fabricator.Fabricator({
|
|
77
77
|
functionExecutor,
|
|
78
|
+
runFunctionExecutor: functionExecutor,
|
|
78
79
|
appEngineLocation,
|
|
79
80
|
executor: new executor.QueueExecutor({}),
|
|
80
81
|
sources: {},
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const error_1 = require("../error");
|
|
6
|
+
const iac = require("../functions/iac/export");
|
|
7
|
+
const projectConfig_1 = require("../functions/projectConfig");
|
|
8
|
+
const clc = require("colorette");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const EXPORTERS = {
|
|
11
|
+
internal: iac.getInternalIac,
|
|
12
|
+
};
|
|
13
|
+
exports.command = new command_1.Command("functions:export")
|
|
14
|
+
.description("export Cloud Functions code and configuration")
|
|
15
|
+
.option("--format <format>", `Format of the output. Can be ${Object.keys(EXPORTERS).join(", ")}.`)
|
|
16
|
+
.option("--codebase <codebase>", "Optional codebase to export. If not specified, exports the default or only codebase.")
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
if (!options.format || !Object.keys(EXPORTERS).includes(options.format)) {
|
|
19
|
+
throw new error_1.FirebaseError(`Must specify --format as ${Object.keys(EXPORTERS).join(", ")}.`);
|
|
20
|
+
}
|
|
21
|
+
const config = (0, projectConfig_1.normalizeAndValidate)(options.config?.src?.functions);
|
|
22
|
+
let codebaseConfig;
|
|
23
|
+
if (options.codebase) {
|
|
24
|
+
codebaseConfig = (0, projectConfig_1.configForCodebase)(config, options.codebase);
|
|
25
|
+
}
|
|
26
|
+
else if (config.length === 1) {
|
|
27
|
+
codebaseConfig = config[0];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
codebaseConfig = (0, projectConfig_1.configForCodebase)(config, "default");
|
|
31
|
+
}
|
|
32
|
+
if (!codebaseConfig.source) {
|
|
33
|
+
throw new error_1.FirebaseError("Codebase does not have a local source directory.");
|
|
34
|
+
}
|
|
35
|
+
const manifest = await EXPORTERS[options.format](options, codebaseConfig);
|
|
36
|
+
for (const [file, contents] of Object.entries(manifest)) {
|
|
37
|
+
logger_1.logger.info(`Manifest file: ${clc.bold(file)}`);
|
|
38
|
+
logger_1.logger.info(contents);
|
|
39
|
+
}
|
|
40
|
+
});
|
package/lib/commands/index.js
CHANGED
|
@@ -141,6 +141,9 @@ function load(client) {
|
|
|
141
141
|
client.functions.config.set = loadCommand("functions-config-set");
|
|
142
142
|
client.functions.config.unset = loadCommand("functions-config-unset");
|
|
143
143
|
client.functions.delete = loadCommand("functions-delete");
|
|
144
|
+
if (experiments.isEnabled("functionsiac")) {
|
|
145
|
+
client.functions.export = loadCommand("functions-export");
|
|
146
|
+
}
|
|
144
147
|
client.functions.log = loadCommand("functions-log");
|
|
145
148
|
client.functions.shell = loadCommand("functions-shell");
|
|
146
149
|
client.functions.list = loadCommand("functions-list");
|
package/lib/commands/init.js
CHANGED
|
@@ -228,6 +228,7 @@ async function initAction(feature, options) {
|
|
|
228
228
|
if (setup.features.includes("dataconnect") && setup.features.includes("dataconnect:sdk")) {
|
|
229
229
|
setup.features = setup.features.filter((f) => f !== "dataconnect:sdk");
|
|
230
230
|
}
|
|
231
|
+
setup.features.push("agentSkills");
|
|
231
232
|
await (0, init_1.init)(setup, config, options);
|
|
232
233
|
await postInitSaves(setup, config);
|
|
233
234
|
if (setup.instructions.length) {
|
|
@@ -8,7 +8,8 @@ const gcs = require("../../gcp/storage");
|
|
|
8
8
|
const getProjectNumber_1 = require("../../getProjectNumber");
|
|
9
9
|
const projectUtils_1 = require("../../projectUtils");
|
|
10
10
|
const utils_1 = require("../../utils");
|
|
11
|
-
const
|
|
11
|
+
const util = require("./util");
|
|
12
|
+
const experiments = require("../../experiments");
|
|
12
13
|
async function default_1(context, options) {
|
|
13
14
|
if (Object.entries(context.backendConfigs).length === 0) {
|
|
14
15
|
return;
|
|
@@ -52,24 +53,28 @@ async function default_1(context, options) {
|
|
|
52
53
|
await Promise.all(Object.values(context.backendConfigs).map(async (cfg) => {
|
|
53
54
|
const rootDir = options.projectRoot ?? process.cwd();
|
|
54
55
|
let builtAppDir;
|
|
55
|
-
|
|
56
|
+
const isLocalBuild = !!cfg.localBuild;
|
|
57
|
+
if (isLocalBuild) {
|
|
58
|
+
experiments.assertEnabled("apphostinglocalbuilds", "App Hosting local builds");
|
|
56
59
|
builtAppDir = context.backendLocalBuilds[cfg.backendId].buildDir;
|
|
57
60
|
if (!builtAppDir) {
|
|
58
61
|
throw new error_1.FirebaseError(`No local build dir found for ${cfg.backendId}`);
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
const zippedSourcePath =
|
|
62
|
-
|
|
64
|
+
const zippedSourcePath = isLocalBuild
|
|
65
|
+
? await util.createLocalBuildTarArchive(cfg, rootDir, builtAppDir)
|
|
66
|
+
: await util.createSourceDeployArchive(cfg, rootDir);
|
|
67
|
+
(0, utils_1.logLabeledBullet)("apphosting", `Zipped ${isLocalBuild ? "built app" : "source"} for backend ${cfg.backendId}`);
|
|
63
68
|
const backendLocation = context.backendLocations[cfg.backendId];
|
|
64
69
|
if (!backendLocation) {
|
|
65
70
|
throw new error_1.FirebaseError(`Failed to find location for backend ${cfg.backendId}. Please contact support with the contents of your firebase-debug.log to report your issue.`);
|
|
66
71
|
}
|
|
67
|
-
(0, utils_1.logLabeledBullet)("apphosting", `Uploading ${
|
|
72
|
+
(0, utils_1.logLabeledBullet)("apphosting", `Uploading ${isLocalBuild ? "built app" : "source"} for backend ${cfg.backendId}...`);
|
|
68
73
|
const bucketName = bucketsPerLocation[backendLocation];
|
|
69
74
|
const { bucket, object } = await gcs.uploadObject({
|
|
70
75
|
file: zippedSourcePath,
|
|
71
76
|
stream: fs.createReadStream(zippedSourcePath),
|
|
72
|
-
}, bucketName);
|
|
77
|
+
}, bucketName, isLocalBuild ? gcs.ContentType.TAR : gcs.ContentType.ZIP);
|
|
73
78
|
(0, utils_1.logLabeledBullet)("apphosting", `Uploaded at gs://${bucket}/${object}`);
|
|
74
79
|
context.backendStorageUris[cfg.backendId] =
|
|
75
80
|
`gs://${bucketName}/${path.basename(zippedSourcePath)}`;
|