firebase-tools-with-isolate 15.27.0 → 15.28.1
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/commands/ext-export.js +85 -20
- package/lib/commands/ext-uninstall.js +35 -1
- package/lib/commands/functions-delete.js +19 -5
- package/lib/commands/functions-kits-install.js +228 -105
- package/lib/commands/functions-kits-list.js +27 -0
- package/lib/commands/index.js +1 -0
- package/lib/dataconnect/client.js +11 -0
- package/lib/dataconnect/schemaMigration.js +16 -5
- package/lib/deploy/extensions/secrets.js +18 -0
- package/lib/deploy/functions/functionsDeployHelper.js +39 -15
- package/lib/deploy/functions/prepare.js +43 -9
- package/lib/deploy/functions/runtimes/dart/features.js +51 -0
- package/lib/deploy/functions/runtimes/dart/index.js +60 -16
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/functionsEmulator.js +4 -1
- package/lib/experiments.js +6 -0
- package/lib/extensions/export.js +26 -0
- package/lib/extensions/replacementRegistry.js +30 -0
- package/lib/extensions/replacements.json +464 -0
- package/lib/fetchMOTD.js +3 -0
- package/lib/functions/env.js +11 -0
- package/lib/functions/iac/export.js +16 -1
- package/lib/functions/kits/config.js +8 -0
- package/lib/gcp/secretManager.js +3 -3
- package/lib/init/features/functions/dart.js +1 -1
- package/lib/mcp/tools/core/deploy.js +2 -0
- package/lib/mcp/tools/core/login.js +59 -4
- package/lib/mcp/tools/dataconnect/compile.js +23 -2
- package/lib/mcp/tools/dataconnect/list_services.js +3 -4
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/unzip.js +12 -2
- package/package.json +2 -1
- package/templates/init/functions/dart/_gitignore +1 -0
- package/templates/init/functions/typescript/index.ts +3 -3
- package/templates/init/functions/typescript/package-ongraphrequest.lint.json +3 -3
- package/templates/init/functions/typescript/package.lint.json +3 -3
- package/templates/init/functions/typescript/tsconfig.dev.json +4 -0
|
@@ -21,18 +21,24 @@ const env_1 = require("../functions/env");
|
|
|
21
21
|
const fs_1 = require("fs");
|
|
22
22
|
const path_1 = require("path");
|
|
23
23
|
const utils_2 = require("../utils");
|
|
24
|
+
const config_1 = require("../config");
|
|
25
|
+
const projectConfig_1 = require("../functions/projectConfig");
|
|
26
|
+
const error_1 = require("../error");
|
|
24
27
|
const clc = require("colorette");
|
|
25
28
|
const experiments = require("../experiments");
|
|
26
29
|
exports.command = new command_1.Command("ext:export")
|
|
27
30
|
.description("export Extension instances installed on a project to a local Firebase directory")
|
|
28
31
|
.option(`--mode <target>`, `experimental: controls the target system of the export (supports "extensions", "functions")`)
|
|
29
|
-
.option(`--instance <instanceId>`, `scope the export to the single instance with the specified instance id`)
|
|
32
|
+
.option(`-e`, `--extension-instance <instanceId>`, `scope the export to the single instance with the specified instance id`)
|
|
33
|
+
.option(`-k`, "---kit-instance <kitId>", `write the .env export from --mode functions to the config path for a kit instance currently defined in firebase.json`)
|
|
34
|
+
.option(`--outputDir <path>`, `override the .env export from --mode functions to a specific arbitrary path`)
|
|
30
35
|
.before(requirePermissions_1.requirePermissions, ["firebaseextensions.instances.list"])
|
|
31
36
|
.before(extensionsHelper_1.ensureExtensionsApiEnabled)
|
|
32
37
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
33
38
|
.withForce()
|
|
34
39
|
.action(async (options) => {
|
|
35
|
-
if (experiments.isEnabled("extMigrationFeatures") &&
|
|
40
|
+
if (experiments.isEnabled("extMigrationFeatures") &&
|
|
41
|
+
(options.mode === "functions" || options.mode === "kits")) {
|
|
36
42
|
await fnHandler(options);
|
|
37
43
|
}
|
|
38
44
|
else {
|
|
@@ -47,10 +53,10 @@ async function extHandler(options) {
|
|
|
47
53
|
logger_1.logger.info(`No extension instances installed on ${projectId}, so there is nothing to export.`);
|
|
48
54
|
return;
|
|
49
55
|
}
|
|
50
|
-
if (options.
|
|
51
|
-
have = have.filter((s) => s.instanceId === options.
|
|
56
|
+
if (options.extensionInstance) {
|
|
57
|
+
have = have.filter((s) => s.instanceId === options.extensionInstance);
|
|
52
58
|
if (have.length === 0) {
|
|
53
|
-
logger_1.logger.info(`No extension instances installed on ${projectId} match specified instance ID ${options.
|
|
59
|
+
logger_1.logger.info(`No extension instances installed on ${projectId} match specified instance ID ${options.extensionInstance}.`);
|
|
54
60
|
return;
|
|
55
61
|
}
|
|
56
62
|
}
|
|
@@ -91,27 +97,94 @@ async function extHandler(options) {
|
|
|
91
97
|
(0, etags_1.saveEtags)(options.rc, projectId, have);
|
|
92
98
|
}
|
|
93
99
|
async function fnHandler(options) {
|
|
94
|
-
if (!options.
|
|
100
|
+
if (!options.extensionInstance) {
|
|
95
101
|
logger_1.logger.info(`ext:export must specify an --instance <instanceId> option when exporting to Functions. Use ext:list to find your instance IDs.`);
|
|
96
102
|
return;
|
|
97
103
|
}
|
|
98
104
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
99
|
-
const instance = await (0, extensionsApi_1.getInstance)(projectId, options.
|
|
105
|
+
const instance = await (0, extensionsApi_1.getInstance)(projectId, options.extensionInstance);
|
|
100
106
|
if (typeof instance === "undefined") {
|
|
101
|
-
logger_1.logger.info(`No extension matching instance ID ${options.
|
|
107
|
+
logger_1.logger.info(`No extension matching instance ID ${options.extensionInstance} found`);
|
|
102
108
|
return;
|
|
103
109
|
}
|
|
110
|
+
if (instance.state !== "ACTIVE" && !options.force) {
|
|
111
|
+
throw new error_1.FirebaseError(`Extension ${options.extensionInstance} is in state ${instance.state}. To export a non-ACTIVE extension, use the --force option.`);
|
|
112
|
+
}
|
|
104
113
|
const instanceId = (0, utils_1.last)(instance.name.split("/")) ?? "";
|
|
105
|
-
if (instanceId !== options.
|
|
114
|
+
if (instanceId !== options.extensionInstance) {
|
|
106
115
|
return;
|
|
107
116
|
}
|
|
117
|
+
let secretCount = 0;
|
|
108
118
|
const convertedEnv = (0, export_1.functionsEnvFromInstance)(instance);
|
|
109
119
|
for (const key of Object.keys(convertedEnv)) {
|
|
120
|
+
if (key.startsWith("FIREBASE_SECRET_REF_")) {
|
|
121
|
+
secretCount += 1;
|
|
122
|
+
}
|
|
110
123
|
console.log(`${key}=${convertedEnv[key]}`);
|
|
111
124
|
}
|
|
112
|
-
|
|
125
|
+
const writeLocation = kitExportTarget(instanceId, projectId, options);
|
|
126
|
+
if ((0, env_1.hasUserEnvs)(writeLocation)) {
|
|
127
|
+
logger_1.logger.info(`Exported extensions config appears to already exist in /${instanceId}, aborting write.`);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
(0, utils_2.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
131
|
+
`Saving exported extensions config as a Function Kits .env file`);
|
|
132
|
+
(0, fs_1.mkdirSync)((0, path_1.join)(writeLocation.projectDir, writeLocation.configDir ?? instanceId), {
|
|
133
|
+
recursive: true,
|
|
134
|
+
});
|
|
135
|
+
(0, env_1.writeUserEnvs)(convertedEnv, writeLocation);
|
|
136
|
+
}
|
|
137
|
+
if (secretCount === 0) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (!(await (0, prompt_1.confirm)({
|
|
141
|
+
message: `${secretCount} Cloud Secret Manager resources found in export. Remove from Extensions lifecycle management?\nThis is necessary to prevent extension uninstall from deleting potentially migrated secrets.`,
|
|
142
|
+
nonInteractive: options.nonInteractive,
|
|
143
|
+
force: options.force,
|
|
144
|
+
default: true,
|
|
145
|
+
}))) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const secretsChanged = await (0, export_1.ejectSecretsFromInstance)(instance);
|
|
149
|
+
(0, utils_2.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
150
|
+
`Added functions-managed label to secrets: ${secretsChanged}`);
|
|
151
|
+
}
|
|
152
|
+
function kitExportTarget(instanceId, projectId, options) {
|
|
153
|
+
const firebaseConfig = config_1.Config.load(options, true);
|
|
154
|
+
if (typeof options.outputDir !== "undefined") {
|
|
155
|
+
return {
|
|
156
|
+
functionsSource: instanceId,
|
|
157
|
+
configDir: String(options.outputDir),
|
|
158
|
+
projectId: projectId,
|
|
159
|
+
isEmulator: false,
|
|
160
|
+
projectDir: options.cwd ?? process.cwd(),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (typeof options.kitInstance !== "undefined") {
|
|
164
|
+
if (!firebaseConfig) {
|
|
165
|
+
throw new error_1.FirebaseError("--kit-instance option was provided but no firebase.json available to look in for kit definitions.");
|
|
166
|
+
}
|
|
167
|
+
const functionsConfig = firebaseConfig.src.functions ?? [];
|
|
168
|
+
const validatedFunctions = (0, projectConfig_1.normalizeAndValidate)(functionsConfig);
|
|
169
|
+
for (const fn of validatedFunctions) {
|
|
170
|
+
if (!(0, projectConfig_1.isKitConfig)(fn)) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
for (const [kitId, kitPath] of Object.entries(fn.instances)) {
|
|
174
|
+
if (kitId === options.kitInstance) {
|
|
175
|
+
return {
|
|
176
|
+
functionsSource: instanceId,
|
|
177
|
+
configDir: String(kitPath),
|
|
178
|
+
projectId: projectId,
|
|
179
|
+
isEmulator: false,
|
|
180
|
+
projectDir: options.projectRoot ?? process.cwd(),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
113
186
|
if (typeof options.projectRoot !== "undefined") {
|
|
114
|
-
|
|
187
|
+
return {
|
|
115
188
|
functionsSource: instanceId,
|
|
116
189
|
configDir: (0, path_1.join)(options.projectRoot, instanceId),
|
|
117
190
|
projectId: projectId,
|
|
@@ -120,7 +193,7 @@ async function fnHandler(options) {
|
|
|
120
193
|
};
|
|
121
194
|
}
|
|
122
195
|
else {
|
|
123
|
-
|
|
196
|
+
return {
|
|
124
197
|
functionsSource: instanceId,
|
|
125
198
|
configDir: instanceId,
|
|
126
199
|
projectId: projectId,
|
|
@@ -128,12 +201,4 @@ async function fnHandler(options) {
|
|
|
128
201
|
projectDir: options.cwd ?? process.cwd(),
|
|
129
202
|
};
|
|
130
203
|
}
|
|
131
|
-
if ((0, env_1.hasUserEnvs)(writeLocationOpts)) {
|
|
132
|
-
logger_1.logger.info(`Exported extensions config appears to already exist in /${instanceId}, aborting write.`);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
(0, utils_2.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
136
|
-
`Saving exported extensions config as a Function Kits .env file`);
|
|
137
|
-
(0, fs_1.mkdirSync)(instanceId, { recursive: true });
|
|
138
|
-
(0, env_1.writeUserEnvs)(convertedEnv, writeLocationOpts);
|
|
139
204
|
}
|
|
@@ -7,18 +7,52 @@ const extensionsHelper_1 = require("../extensions/extensionsHelper");
|
|
|
7
7
|
const requirePermissions_1 = require("../requirePermissions");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const manifest = require("../extensions/manifest");
|
|
10
|
+
const extensionsApi_1 = require("../extensions/extensionsApi");
|
|
11
|
+
const projectUtils_1 = require("../projectUtils");
|
|
12
|
+
const prompt_1 = require("../prompt");
|
|
13
|
+
const error_1 = require("../error");
|
|
10
14
|
exports.command = new command_1.Command("ext:uninstall <extensionInstanceId>")
|
|
11
15
|
.description("uninstall an extension that is installed in your Firebase project by instance ID")
|
|
12
16
|
.option("--local", "deprecated")
|
|
17
|
+
.option("--immediate", "immediately destroy GCP resources instead of waiting on next deploy. Can be run outside a firebase project directory.")
|
|
13
18
|
.withForce()
|
|
14
19
|
.before(requirePermissions_1.requirePermissions, ["firebaseextensions.instances.delete"])
|
|
15
20
|
.before(extensionsHelper_1.ensureExtensionsApiEnabled)
|
|
16
21
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
17
22
|
.before(extensionsHelper_1.diagnoseAndFixProject)
|
|
18
|
-
.action((instanceId, options) => {
|
|
23
|
+
.action(async (instanceId, options) => {
|
|
19
24
|
if (options.local) {
|
|
20
25
|
(0, utils_1.logLabeledWarning)(extensionsHelper_1.logPrefix, "As of firebase-tools@11.0.0, the `--local` flag is no longer required, as it is the default behavior.");
|
|
21
26
|
}
|
|
27
|
+
if (options.immediate) {
|
|
28
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
29
|
+
let config;
|
|
30
|
+
try {
|
|
31
|
+
config = manifest.loadConfig(options);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
(0, utils_1.logLabeledBullet)(extensionsHelper_1.logPrefix, "No firebase.json found. Proceeding to immediate extension instance teardown.");
|
|
35
|
+
}
|
|
36
|
+
if (config && manifest.instanceExists(instanceId, config)) {
|
|
37
|
+
manifest.removeFromManifest(instanceId, config);
|
|
38
|
+
}
|
|
39
|
+
if (!(await (0, prompt_1.confirm)({
|
|
40
|
+
message: `About to delete Extensions instance ${projectId}/${instanceId}, its associated resources, and service account. Continue?`,
|
|
41
|
+
nonInteractive: options.nonInteractive,
|
|
42
|
+
force: options.force,
|
|
43
|
+
default: true,
|
|
44
|
+
}))) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
await (0, extensionsApi_1.deleteInstance)(projectId, instanceId);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
throw new error_1.FirebaseError(`Error when attempting deletion: ${err instanceof Error ? err.message : String(err)}`, { original: err instanceof Error ? err : undefined });
|
|
52
|
+
}
|
|
53
|
+
(0, utils_1.logLabeledSuccess)(extensionsHelper_1.logPrefix, `Deleted Extensions instance ${projectId}/${instanceId}.`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
22
56
|
const config = manifest.loadConfig(options);
|
|
23
57
|
manifest.removeFromManifest(instanceId, config);
|
|
24
58
|
});
|
|
@@ -12,13 +12,14 @@ const requirePermissions_1 = require("../requirePermissions");
|
|
|
12
12
|
const helper = require("../deploy/functions/functionsDeployHelper");
|
|
13
13
|
const utils = require("../utils");
|
|
14
14
|
const backend = require("../deploy/functions/backend");
|
|
15
|
+
const projectConfig = require("../functions/projectConfig");
|
|
15
16
|
const planner = require("../deploy/functions/release/planner");
|
|
16
17
|
const fabricator = require("../deploy/functions/release/fabricator");
|
|
17
18
|
const executor = require("../deploy/functions/release/executor");
|
|
18
19
|
const reporter = require("../deploy/functions/release/reporter");
|
|
19
20
|
const getProjectNumber_1 = require("../getProjectNumber");
|
|
20
21
|
exports.command = new command_1.Command("functions:delete [filters...]")
|
|
21
|
-
.description("delete one or more Cloud Functions by name
|
|
22
|
+
.description("delete one or more Cloud Functions by name, group name, or codebase.")
|
|
22
23
|
.option("--region <region>", "Specify region of the function to be deleted. " +
|
|
23
24
|
"If omitted, functions from all regions whose names match the filters will be deleted. ")
|
|
24
25
|
.withForce()
|
|
@@ -29,17 +30,24 @@ exports.command = new command_1.Command("functions:delete [filters...]")
|
|
|
29
30
|
}
|
|
30
31
|
const context = {
|
|
31
32
|
projectId: (0, projectUtils_1.needProjectId)(options),
|
|
32
|
-
filters:
|
|
33
|
+
filters: [],
|
|
33
34
|
};
|
|
34
|
-
const [
|
|
35
|
+
const [firebaseConfig, letExistingBackend] = await Promise.all([
|
|
35
36
|
functionsConfig.getFirebaseConfig(options),
|
|
36
37
|
backend.existingBackend(context),
|
|
37
38
|
]);
|
|
39
|
+
let existingBackend = letExistingBackend;
|
|
38
40
|
await backend.checkAvailability(context, backend.empty());
|
|
39
|
-
const appEngineLocation = functionsConfig.getAppEngineLocation(
|
|
41
|
+
const appEngineLocation = functionsConfig.getAppEngineLocation(firebaseConfig);
|
|
40
42
|
if (options.region) {
|
|
41
|
-
existingBackend
|
|
43
|
+
existingBackend = backend.matchingBackend(existingBackend, (ep) => ep.region === options.region);
|
|
42
44
|
}
|
|
45
|
+
const activeCodebases = [
|
|
46
|
+
...new Set(backend
|
|
47
|
+
.allEndpoints(existingBackend)
|
|
48
|
+
.map((ep) => ep.codebase || projectConfig.DEFAULT_CODEBASE)),
|
|
49
|
+
];
|
|
50
|
+
context.filters = helper.parseDeleteFilters(filters, activeCodebases);
|
|
43
51
|
const plan = await planner.createDeploymentPlan({
|
|
44
52
|
wantBackend: backend.empty(),
|
|
45
53
|
haveBackend: existingBackend,
|
|
@@ -55,6 +63,12 @@ exports.command = new command_1.Command("functions:delete [filters...]")
|
|
|
55
63
|
if (allEpToDelete.length === 0) {
|
|
56
64
|
throw new error_1.FirebaseError(`The specified filters do not match any existing functions in project ${clc.bold(context.projectId)}.`);
|
|
57
65
|
}
|
|
66
|
+
const allEndpoints = backend.allEndpoints(existingBackend);
|
|
67
|
+
const collisions = helper.detectCodebaseAndIdCollisions(filters, activeCodebases, allEndpoints, projectConfig.DEFAULT_CODEBASE);
|
|
68
|
+
for (const c of collisions) {
|
|
69
|
+
utils.logLabeledBullet("functions", `Target '${clc.bold(c.filter)}' matches both a codebase and a function (${c.functionLabel}). Codebase deletion takes precedence. ` +
|
|
70
|
+
`(To delete the function instead, run: ${clc.bold(c.workaroundCommand)})`);
|
|
71
|
+
}
|
|
58
72
|
const deleteList = allEpToDelete.map((func) => `\t${helper.getFunctionLabel(func)}`).join("\n");
|
|
59
73
|
const confirmDeletion = await (0, prompt_1.confirm)({
|
|
60
74
|
message: "You are about to delete the following Cloud Functions:\n" +
|