firebase-tools-with-isolate 15.27.0 → 15.28.2-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/apphosting/backend.js +44 -10
- package/lib/apphosting/githubConnections.js +1 -1
- package/lib/apphosting/repo.js +1 -1
- package/lib/apphosting/rollout.js +1 -1
- package/lib/commands/ext-export.js +78 -17
- package/lib/commands/ext-migrate.js +36 -0
- package/lib/commands/ext-uninstall.js +35 -1
- package/lib/commands/functions-delete.js +19 -5
- package/lib/commands/functions-kits-install.js +18 -275
- package/lib/commands/functions-kits-list.js +27 -0
- package/lib/commands/functions-kits-uninstall.js +266 -0
- package/lib/commands/index.js +5 -0
- package/lib/config.js +34 -0
- package/lib/dataconnect/client.js +13 -2
- package/lib/dataconnect/schemaMigration.js +16 -5
- package/lib/deploy/extensions/secrets.js +18 -0
- package/lib/deploy/functions/ensure.js +29 -19
- package/lib/deploy/functions/functionsDeployHelper.js +39 -15
- package/lib/deploy/functions/prepare.js +51 -10
- package/lib/deploy/functions/release/fabricator.js +19 -3
- package/lib/deploy/functions/release/planner.js +8 -0
- 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/listExtensions.js +27 -3
- package/lib/extensions/migrate.js +171 -0
- package/lib/extensions/replacementRegistry.js +65 -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/functions/kits/env.js +38 -0
- package/lib/functions/kits/index.js +19 -0
- package/lib/functions/kits/install.js +709 -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/requireTosAcceptance.js +2 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/unzip.js +12 -2
- package/package.json +6 -5
- package/schema/firebase-config.json +1 -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
|
@@ -7,6 +7,7 @@ exports.createGitRepoLink = createGitRepoLink;
|
|
|
7
7
|
exports.ensureAppHostingComputeServiceAccount = ensureAppHostingComputeServiceAccount;
|
|
8
8
|
exports.promptNewBackendId = promptNewBackendId;
|
|
9
9
|
exports.createBackend = createBackend;
|
|
10
|
+
exports.defaultComputeServiceAccountExists = defaultComputeServiceAccountExists;
|
|
10
11
|
exports.setDefaultTrafficPolicy = setDefaultTrafficPolicy;
|
|
11
12
|
exports.deleteBackendAndPoll = deleteBackendAndPoll;
|
|
12
13
|
exports.promptLocation = promptLocation;
|
|
@@ -39,7 +40,7 @@ const DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME = "firebase-app-hosting-compute";
|
|
|
39
40
|
const apphostingPollerOptions = {
|
|
40
41
|
apiOrigin: (0, api_1.apphostingOrigin)(),
|
|
41
42
|
apiVersion: apphosting_1.API_VERSION,
|
|
42
|
-
masterTimeout:
|
|
43
|
+
masterTimeout: 60 * 60 * 1000,
|
|
43
44
|
maxBackoff: 10000,
|
|
44
45
|
};
|
|
45
46
|
async function tlsReady(url) {
|
|
@@ -190,6 +191,10 @@ async function createGitRepoLink(projectId, location, connectionId) {
|
|
|
190
191
|
await githubConnections.linkGitHubRepository(projectId, location, connectionId);
|
|
191
192
|
}
|
|
192
193
|
async function ensureAppHostingComputeServiceAccount(projectId, serviceAccount) {
|
|
194
|
+
await verifyRuntimeServiceAccountAccess(projectId, serviceAccount);
|
|
195
|
+
await provisionDefaultComputeServiceAccount(projectId);
|
|
196
|
+
}
|
|
197
|
+
async function verifyRuntimeServiceAccountAccess(projectId, serviceAccount) {
|
|
193
198
|
const sa = serviceAccount || defaultComputeServiceAccountEmail(projectId);
|
|
194
199
|
const name = `projects/${projectId}/serviceAccounts/${sa}`;
|
|
195
200
|
try {
|
|
@@ -206,7 +211,6 @@ async function ensureAppHostingComputeServiceAccount(projectId, serviceAccount)
|
|
|
206
211
|
throw new error_1.FirebaseError("Unexpected error occurred while testing for IAM service account permissions", { original: err });
|
|
207
212
|
}
|
|
208
213
|
}
|
|
209
|
-
await provisionDefaultComputeServiceAccount(projectId);
|
|
210
214
|
}
|
|
211
215
|
async function promptNewBackendId(projectId, location) {
|
|
212
216
|
while (true) {
|
|
@@ -266,13 +270,8 @@ async function createBackend(projectId, location, backendId, serviceAccount, rep
|
|
|
266
270
|
return await createBackendAndPoll();
|
|
267
271
|
}
|
|
268
272
|
async function provisionDefaultComputeServiceAccount(projectId) {
|
|
269
|
-
|
|
270
|
-
await
|
|
271
|
-
}
|
|
272
|
-
catch (err) {
|
|
273
|
-
if ((0, error_1.getErrStatus)(err) !== 409) {
|
|
274
|
-
throw err;
|
|
275
|
-
}
|
|
273
|
+
if (!(await defaultComputeServiceAccountExists(projectId))) {
|
|
274
|
+
await createDefaultComputeServiceAccount(projectId);
|
|
276
275
|
}
|
|
277
276
|
try {
|
|
278
277
|
await (0, resourceManager_1.addServiceAccountToRoles)(projectId, defaultComputeServiceAccountEmail(projectId), [
|
|
@@ -283,14 +282,49 @@ async function provisionDefaultComputeServiceAccount(projectId) {
|
|
|
283
282
|
], true);
|
|
284
283
|
}
|
|
285
284
|
catch (err) {
|
|
286
|
-
|
|
285
|
+
const status = (0, error_1.getErrStatus)(err);
|
|
286
|
+
if (status === 400) {
|
|
287
287
|
(0, utils_1.logWarning)("Your App Hosting compute service account is still being provisioned in the background. If you encounter an error, please try again after a few moments.");
|
|
288
288
|
}
|
|
289
|
+
else if (status === 403) {
|
|
290
|
+
(0, utils_1.logWarning)("Failed to grant roles to the default App Hosting compute service account. Make sure you " +
|
|
291
|
+
"have the resourcemanager.projects.setIamPolicy permission. If the service account " +
|
|
292
|
+
"already has these roles, this warning can be safely ignored.");
|
|
293
|
+
}
|
|
289
294
|
else {
|
|
290
295
|
throw err;
|
|
291
296
|
}
|
|
292
297
|
}
|
|
293
298
|
}
|
|
299
|
+
async function defaultComputeServiceAccountExists(projectId) {
|
|
300
|
+
try {
|
|
301
|
+
await iam.getServiceAccount(projectId, defaultComputeServiceAccountEmail(projectId));
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
catch (err) {
|
|
305
|
+
const status = (0, error_1.getErrStatus)(err);
|
|
306
|
+
if (status === 404 || status === 403) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
throw err;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async function createDefaultComputeServiceAccount(projectId) {
|
|
313
|
+
try {
|
|
314
|
+
await iam.createServiceAccount(projectId, DEFAULT_COMPUTE_SERVICE_ACCOUNT_NAME, "Default service account used to run builds and deploys for Firebase App Hosting", "Firebase App Hosting compute service account");
|
|
315
|
+
}
|
|
316
|
+
catch (err) {
|
|
317
|
+
const status = (0, error_1.getErrStatus)(err);
|
|
318
|
+
if (status === 403) {
|
|
319
|
+
(0, utils_1.logWarning)("Failed to create the default App Hosting compute service account. Make sure you have " +
|
|
320
|
+
"the iam.serviceAccounts.create permission. If the service account already exists, " +
|
|
321
|
+
"this warning can be safely ignored.");
|
|
322
|
+
}
|
|
323
|
+
else if (status !== 409) {
|
|
324
|
+
throw err;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
294
328
|
async function setDefaultTrafficPolicy(projectId, location, backendId, codebaseBranch) {
|
|
295
329
|
const traffic = {
|
|
296
330
|
rolloutPolicy: {
|
|
@@ -48,7 +48,7 @@ function parseConnectionName(name) {
|
|
|
48
48
|
const devConnectPollerOptions = {
|
|
49
49
|
apiOrigin: (0, api_1.developerConnectOrigin)(),
|
|
50
50
|
apiVersion: "v1",
|
|
51
|
-
masterTimeout:
|
|
51
|
+
masterTimeout: 60 * 60 * 1000,
|
|
52
52
|
maxBackoff: 10000,
|
|
53
53
|
};
|
|
54
54
|
function extractRepoSlugFromUri(cloneUri) {
|
package/lib/apphosting/repo.js
CHANGED
|
@@ -36,7 +36,7 @@ function parseConnectionName(name) {
|
|
|
36
36
|
const gcbPollerOptions = {
|
|
37
37
|
apiOrigin: (0, api_1.cloudbuildOrigin)(),
|
|
38
38
|
apiVersion: "v2",
|
|
39
|
-
masterTimeout:
|
|
39
|
+
masterTimeout: 60 * 60 * 1000,
|
|
40
40
|
maxBackoff: 10000,
|
|
41
41
|
};
|
|
42
42
|
function extractRepoSlugFromUri(remoteUri) {
|
|
@@ -14,7 +14,7 @@ const backend_1 = require("./backend");
|
|
|
14
14
|
const apphostingPollerOptions = {
|
|
15
15
|
apiOrigin: (0, api_1.apphostingOrigin)(),
|
|
16
16
|
apiVersion: apphosting.API_VERSION,
|
|
17
|
-
masterTimeout:
|
|
17
|
+
masterTimeout: 60 * 60 * 1000,
|
|
18
18
|
maxBackoff: 10000,
|
|
19
19
|
};
|
|
20
20
|
const GIT_COMMIT_SHA_REGEX = /^(?:[0-9a-f]{40}|[0-9a-f]{7})$/;
|
|
@@ -21,12 +21,17 @@ 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(
|
|
32
|
+
.option("--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")
|
|
@@ -101,39 +106,95 @@ async function fnHandler(options) {
|
|
|
101
106
|
logger_1.logger.info(`No extension matching instance ID ${options.instance} found`);
|
|
102
107
|
return;
|
|
103
108
|
}
|
|
109
|
+
if (instance.state !== "ACTIVE" && !options.force) {
|
|
110
|
+
throw new error_1.FirebaseError(`Extension ${options.instance} is in state ${instance.state}. To export a non-ACTIVE extension, use the --force option.`);
|
|
111
|
+
}
|
|
104
112
|
const instanceId = (0, utils_1.last)(instance.name.split("/")) ?? "";
|
|
105
113
|
if (instanceId !== options.instance) {
|
|
106
114
|
return;
|
|
107
115
|
}
|
|
108
116
|
const convertedEnv = (0, export_1.functionsEnvFromInstance)(instance);
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
const secretCount = Object.keys(convertedEnv).filter((key) => key.startsWith("FIREBASE_SECRET_REF_")).length;
|
|
118
|
+
const writeLocation = kitExportTarget(instanceId, projectId, options);
|
|
119
|
+
if ((0, env_1.hasUserEnvs)(writeLocation)) {
|
|
120
|
+
logger_1.logger.info(`Exported extensions config appears to already exist in /${instanceId}, aborting write.`);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
(0, utils_2.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
124
|
+
`Saving exported extensions config as a Function Kits .env file`);
|
|
125
|
+
(0, fs_1.mkdirSync)((0, path_1.resolve)(writeLocation.projectDir, writeLocation.configDir ?? instanceId), {
|
|
126
|
+
recursive: true,
|
|
127
|
+
});
|
|
128
|
+
(0, env_1.writeUserEnvs)(convertedEnv, writeLocation);
|
|
129
|
+
}
|
|
130
|
+
if (secretCount === 0) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (!(await (0, prompt_1.confirm)({
|
|
134
|
+
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.`,
|
|
135
|
+
nonInteractive: options.nonInteractive,
|
|
136
|
+
force: options.force,
|
|
137
|
+
default: true,
|
|
138
|
+
}))) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const secretsChanged = await (0, export_1.ejectSecretsFromInstance)(instance);
|
|
142
|
+
(0, utils_2.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
143
|
+
`Added functions-managed label to secrets: ${secretsChanged}`);
|
|
144
|
+
}
|
|
145
|
+
function kitExportTarget(instanceId, projectId, options) {
|
|
146
|
+
const firebaseConfig = config_1.Config.load(options, true);
|
|
147
|
+
const cwd = options.cwd ?? process.cwd();
|
|
148
|
+
if (typeof options.outputDir !== "undefined") {
|
|
149
|
+
return {
|
|
150
|
+
functionsSource: instanceId,
|
|
151
|
+
configDir: (0, path_1.resolve)(cwd, String(options.outputDir)),
|
|
152
|
+
projectId: projectId,
|
|
153
|
+
isEmulator: false,
|
|
154
|
+
projectDir: cwd,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
if (typeof options.kitInstance !== "undefined") {
|
|
158
|
+
if (!firebaseConfig) {
|
|
159
|
+
throw new error_1.FirebaseError("--kit-instance option was provided but no firebase.json available to look in for kit definitions.");
|
|
160
|
+
}
|
|
161
|
+
const functionsConfig = firebaseConfig.src.functions ?? [];
|
|
162
|
+
const validatedFunctions = (0, projectConfig_1.normalizeAndValidate)(functionsConfig);
|
|
163
|
+
for (const fn of validatedFunctions) {
|
|
164
|
+
if (!(0, projectConfig_1.isKitConfig)(fn)) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
for (const [kitInstanceId, configDirPath] of Object.entries(fn.instances)) {
|
|
168
|
+
if (kitInstanceId === options.kitInstance) {
|
|
169
|
+
const projectDir = options.projectRoot ?? cwd;
|
|
170
|
+
return {
|
|
171
|
+
functionsSource: instanceId,
|
|
172
|
+
configDir: (0, path_1.resolve)(projectDir, String(configDirPath)),
|
|
173
|
+
projectId: projectId,
|
|
174
|
+
isEmulator: false,
|
|
175
|
+
projectDir: projectDir,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
throw new error_1.FirebaseError(`Could not find kit instance "${options.kitInstance}" in firebase.json.`);
|
|
111
181
|
}
|
|
112
|
-
let writeLocationOpts;
|
|
113
182
|
if (typeof options.projectRoot !== "undefined") {
|
|
114
|
-
|
|
183
|
+
return {
|
|
115
184
|
functionsSource: instanceId,
|
|
116
|
-
configDir: (0, path_1.
|
|
185
|
+
configDir: (0, path_1.resolve)(options.projectRoot, instanceId),
|
|
117
186
|
projectId: projectId,
|
|
118
187
|
isEmulator: false,
|
|
119
188
|
projectDir: options.projectRoot,
|
|
120
189
|
};
|
|
121
190
|
}
|
|
122
191
|
else {
|
|
123
|
-
|
|
192
|
+
return {
|
|
124
193
|
functionsSource: instanceId,
|
|
125
|
-
configDir: instanceId,
|
|
194
|
+
configDir: (0, path_1.resolve)(cwd, instanceId),
|
|
126
195
|
projectId: projectId,
|
|
127
196
|
isEmulator: false,
|
|
128
|
-
projectDir:
|
|
197
|
+
projectDir: cwd,
|
|
129
198
|
};
|
|
130
199
|
}
|
|
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
200
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const checkMinRequiredVersion_1 = require("../checkMinRequiredVersion");
|
|
6
|
+
const command_1 = require("../command");
|
|
7
|
+
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const extensionsHelper_1 = require("../extensions/extensionsHelper");
|
|
9
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
10
|
+
const migrate_1 = require("../extensions/migrate");
|
|
11
|
+
const kits_1 = require("../functions/kits");
|
|
12
|
+
const logger_1 = require("../logger");
|
|
13
|
+
const utils_1 = require("../utils");
|
|
14
|
+
exports.command = new command_1.Command("ext:migrate")
|
|
15
|
+
.description("migrate an extension instance to a function kit")
|
|
16
|
+
.option("-p, --package <package>", "optional kit package override to use")
|
|
17
|
+
.option("-i, --ext-instance <instanceId>", "extension instance ID to migrate")
|
|
18
|
+
.option("-e, --extension <extensionRef>", "extension reference or name to migrate")
|
|
19
|
+
.before(requirePermissions_1.requirePermissions, ["firebaseextensions.instances.list"])
|
|
20
|
+
.before(extensionsHelper_1.ensureExtensionsApiEnabled)
|
|
21
|
+
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
22
|
+
.action(async (options) => {
|
|
23
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
24
|
+
if (options.package) {
|
|
25
|
+
(0, kits_1.validateNpmPackageName)(options.package);
|
|
26
|
+
}
|
|
27
|
+
const plan = await (0, migrate_1.createMigrationPlan)(projectId, {
|
|
28
|
+
package: options.package,
|
|
29
|
+
extInstance: options.extInstance,
|
|
30
|
+
extension: options.extension,
|
|
31
|
+
nonInteractive: options.nonInteractive,
|
|
32
|
+
});
|
|
33
|
+
(0, utils_1.logLabeledBullet)(extensionsHelper_1.logPrefix, `Selected instance ${clc.bold(plan.instanceId)} (${plan.kitPackage}) for migration.`);
|
|
34
|
+
logger_1.logger.info("TODO: Draw the rest of the owl");
|
|
35
|
+
return plan;
|
|
36
|
+
});
|
|
@@ -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" +
|