firebase-tools-with-isolate 15.26.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/appcheck/api.js +19 -0
- package/lib/appcheck/providers.js +240 -0
- package/lib/commands/appcheck-apps-list.js +78 -0
- package/lib/commands/appcheck-debugtokens-create.js +2 -2
- package/lib/commands/appcheck-debugtokens-delete.js +2 -2
- package/lib/commands/appcheck-debugtokens-list.js +2 -2
- package/lib/commands/appcheck-prompts.js +55 -0
- package/lib/commands/appcheck-providers-get.js +73 -0
- package/lib/commands/appcheck-providers-list.js +67 -0
- package/lib/commands/appcheck-providers-set.js +96 -0
- package/lib/commands/ext-export.js +140 -3
- package/lib/commands/ext-uninstall.js +35 -1
- package/lib/commands/functions-delete.js +19 -5
- package/lib/commands/functions-kits-install.js +417 -0
- package/lib/commands/functions-kits-list.js +27 -0
- package/lib/commands/index.js +11 -0
- package/lib/crashlytics/filters.js +12 -4
- package/lib/crashlytics/reports.js +2 -0
- package/lib/crashlytics/types.js +8 -1
- 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/backend.js +11 -1
- package/lib/deploy/functions/build.js +1 -1
- package/lib/deploy/functions/functionsDeployHelper.js +39 -15
- package/lib/deploy/functions/params.js +5 -1
- package/lib/deploy/functions/prepare.js +69 -22
- package/lib/deploy/functions/prompts.js +1 -1
- package/lib/deploy/functions/release/lifecycle.js +11 -0
- package/lib/deploy/functions/release/planner.js +5 -2
- package/lib/deploy/functions/runtimes/dart/features.js +51 -0
- package/lib/deploy/functions/runtimes/dart/index.js +60 -16
- package/lib/emulator/controller.js +1 -0
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/functionsEmulator.js +7 -2
- package/lib/experiments.js +17 -5
- package/lib/extensions/export.js +73 -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 +31 -7
- package/lib/functions/iac/export.js +16 -1
- package/lib/functions/kits/config.js +8 -0
- package/lib/functions/projectConfig.js +19 -11
- package/lib/functions/python.js +1 -1
- package/lib/gcp/runv2.js +1 -0
- package/lib/gcp/secretManager.js +3 -3
- package/lib/init/features/functions/dart.js +1 -1
- package/lib/mcp/onemcp/index.js +2 -1
- package/lib/mcp/onemcp/onemcp_server.js +38 -11
- package/lib/mcp/prompts/crashlytics/connect.js +1 -1
- package/lib/mcp/resources/guides/crashlytics_issues.js +3 -3
- package/lib/mcp/resources/guides/crashlytics_reports.js +32 -11
- package/lib/mcp/tool.js +5 -0
- package/lib/mcp/tools/core/deploy.js +2 -0
- package/lib/mcp/tools/core/login.js +59 -4
- package/lib/mcp/tools/crashlytics/notes.js +3 -3
- package/lib/mcp/tools/crashlytics/reports.js +2 -0
- package/lib/mcp/tools/dataconnect/compile.js +23 -2
- package/lib/mcp/tools/dataconnect/list_services.js +3 -4
- package/lib/mcp/util/crashlytics/availability.js +54 -1
- package/lib/serve/functions.js +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/unzip.js +12 -2
- package/package.json +2 -1
- package/schema/firebase-config.json +3 -3
- package/templates/init/functions/dart/_gitignore +1 -0
- package/templates/init/functions/typescript/index-kit-migration.ts +49 -0
- package/templates/init/functions/typescript/index-kit.ts +35 -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
- package/lib/appcheck/prompts.js +0 -41
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const requireAuth_1 = require("../requireAuth");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const api_1 = require("../appcheck/api");
|
|
12
|
+
const providers_1 = require("../appcheck/providers");
|
|
13
|
+
const appcheck_prompts_1 = require("./appcheck-prompts");
|
|
14
|
+
exports.command = new command_1.Command("appcheck:providers:set <provider>")
|
|
15
|
+
.description("configure an App Check attestation provider for an app")
|
|
16
|
+
.help(`configures one attestation provider for one app.
|
|
17
|
+
|
|
18
|
+
<provider> is one of:
|
|
19
|
+
|
|
20
|
+
${(0, providers_1.providerHelp)()}
|
|
21
|
+
|
|
22
|
+
Flags per provider:
|
|
23
|
+
|
|
24
|
+
all --token-ttl <30m|1h|1d, between 30m and 7d>
|
|
25
|
+
device-check --key-id <id> --private-key <value or @file>
|
|
26
|
+
recaptcha-enterprise --site-key <key> --min-score <0.0-1.0>
|
|
27
|
+
recaptcha-v3 --site-secret <value or @file> --min-score <0.0-1.0>
|
|
28
|
+
play-integrity --min-device-integrity <${Object.keys(providers_1.DEVICE_INTEGRITY_LEVELS).join("|")}>
|
|
29
|
+
--[no-]require-licensed --[no-]allow-unrecognized-version
|
|
30
|
+
app-attest only --token-ttl
|
|
31
|
+
|
|
32
|
+
Secrets accept @path to read a file, so a private key does not end up in your shell history.
|
|
33
|
+
|
|
34
|
+
On iOS and Android, use \`recaptcha-enterprise\` for the reCAPTCHA attestation provider that the mobile SDKs added in June 2026 (Apple 12.15.0, Android firebase-appcheck-recaptcha 19.0.0). It is in public preview there and uses the same site key settings as the web provider.
|
|
35
|
+
|
|
36
|
+
This command changes how a token is checked, it does not turn enforcement on. Use \`appcheck:services:set\` for that.
|
|
37
|
+
|
|
38
|
+
For example:
|
|
39
|
+
|
|
40
|
+
\`firebase appcheck:providers:set device-check --app 1:123:ios:abc --key-id ABCD1234EF --private-key @AuthKey.p8\``)
|
|
41
|
+
.option("--app <appId>", "the app id of your Firebase app")
|
|
42
|
+
.option("--token-ttl <duration>", "how long App Check tokens stay valid, e.g. 30m, 1h, 1d")
|
|
43
|
+
.option("--key-id <keyId>", "device-check: the Apple key identifier")
|
|
44
|
+
.option("--private-key <value>", "device-check: the .p8 contents, or @path to the file")
|
|
45
|
+
.option("--site-key <siteKey>", "recaptcha-enterprise: the reCAPTCHA Enterprise site key")
|
|
46
|
+
.option("--site-secret <value>", "recaptcha-v3: the site secret, or @path to a file")
|
|
47
|
+
.option("--min-score <score>", "recaptcha: minimum score to accept, 0.0 to 1.0")
|
|
48
|
+
.option("--min-device-integrity <level>", `play-integrity: minimum device level (${Object.keys(providers_1.DEVICE_INTEGRITY_LEVELS).join(", ")})`)
|
|
49
|
+
.option("--require-licensed", "play-integrity: require the LICENSED account verdict")
|
|
50
|
+
.option("--no-require-licensed", "play-integrity: stop requiring the LICENSED verdict")
|
|
51
|
+
.option("--allow-unrecognized-version", "play-integrity: allow unrecognized app versions")
|
|
52
|
+
.option("--no-allow-unrecognized-version", "play-integrity: reject unrecognized app versions")
|
|
53
|
+
.before(requireAuth_1.requireAuth)
|
|
54
|
+
.before(requirePermissions_1.requirePermissions, [
|
|
55
|
+
"firebaseappcheck.appAttestConfig.update",
|
|
56
|
+
"firebaseappcheck.deviceCheckConfig.update",
|
|
57
|
+
"firebaseappcheck.playIntegrityConfig.update",
|
|
58
|
+
"firebaseappcheck.recaptchaEnterpriseConfig.update",
|
|
59
|
+
"firebaseappcheck.recaptchaV3Config.update",
|
|
60
|
+
])
|
|
61
|
+
.action(async (provider, options) => {
|
|
62
|
+
const providerType = (0, providers_1.parseProviderType)(provider);
|
|
63
|
+
const { update, updateMask } = (0, providers_1.buildProviderUpdate)(providerType, options);
|
|
64
|
+
const { appId, platform } = await (0, appcheck_prompts_1.getOrPromptApp)(options, `Select the app to configure ${providerType} for:`);
|
|
65
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
66
|
+
(0, providers_1.assertProviderSupportsPlatform)(providerType, platform, appId);
|
|
67
|
+
const result = await (0, api_1.updateProviderConfig)(projectNumber, appId, providerType, update, updateMask);
|
|
68
|
+
(0, utils_1.logSuccess)(`Updated ${clc.bold(providerType)} for app ${clc.bold(appId)}.`);
|
|
69
|
+
if (result.keyId) {
|
|
70
|
+
logger_1.logger.info(` Key id: ${result.keyId}`);
|
|
71
|
+
}
|
|
72
|
+
if (result.privateKeySet) {
|
|
73
|
+
logger_1.logger.info(` Private key: set`);
|
|
74
|
+
}
|
|
75
|
+
if (result.siteKey) {
|
|
76
|
+
logger_1.logger.info(` Site key: ${result.siteKey}`);
|
|
77
|
+
}
|
|
78
|
+
if (result.siteSecretSet) {
|
|
79
|
+
logger_1.logger.info(` Site secret: set`);
|
|
80
|
+
}
|
|
81
|
+
const minScore = result.riskAnalysis?.minValidScore ?? result.minValidScore;
|
|
82
|
+
if (minScore !== undefined) {
|
|
83
|
+
logger_1.logger.info(` Min score: ${minScore}`);
|
|
84
|
+
}
|
|
85
|
+
if (result.deviceIntegrity?.minDeviceRecognitionLevel) {
|
|
86
|
+
logger_1.logger.info(` Min device: ${result.deviceIntegrity.minDeviceRecognitionLevel}`);
|
|
87
|
+
}
|
|
88
|
+
if (providerType === "play-integrity") {
|
|
89
|
+
const licensed = result.accountDetails?.requireLicensed ?? false;
|
|
90
|
+
const unrecognized = result.appIntegrity?.allowUnrecognizedVersion ?? false;
|
|
91
|
+
logger_1.logger.info(` Licensed: ${licensed ? "required" : "not required"}`);
|
|
92
|
+
logger_1.logger.info(` Unrecognized versions: ${unrecognized ? "allowed" : "not allowed"}`);
|
|
93
|
+
}
|
|
94
|
+
logger_1.logger.info(` Token TTL: ${(0, providers_1.formatTokenTtl)(result.tokenTtl)}`);
|
|
95
|
+
return result;
|
|
96
|
+
});
|
|
@@ -15,20 +15,51 @@ const logger_1 = require("../logger");
|
|
|
15
15
|
const projectUtils_1 = require("../projectUtils");
|
|
16
16
|
const prompt_1 = require("../prompt");
|
|
17
17
|
const requirePermissions_1 = require("../requirePermissions");
|
|
18
|
+
const extensionsApi_1 = require("../extensions/extensionsApi");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const env_1 = require("../functions/env");
|
|
21
|
+
const fs_1 = require("fs");
|
|
22
|
+
const path_1 = require("path");
|
|
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");
|
|
27
|
+
const clc = require("colorette");
|
|
28
|
+
const experiments = require("../experiments");
|
|
18
29
|
exports.command = new command_1.Command("ext:export")
|
|
19
|
-
.description("export
|
|
30
|
+
.description("export Extension instances installed on a project to a local Firebase directory")
|
|
31
|
+
.option(`--mode <target>`, `experimental: controls the target system of the export (supports "extensions", "functions")`)
|
|
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`)
|
|
20
35
|
.before(requirePermissions_1.requirePermissions, ["firebaseextensions.instances.list"])
|
|
21
36
|
.before(extensionsHelper_1.ensureExtensionsApiEnabled)
|
|
22
37
|
.before(checkMinRequiredVersion_1.checkMinRequiredVersion, "extMinVersion")
|
|
23
38
|
.withForce()
|
|
24
39
|
.action(async (options) => {
|
|
40
|
+
if (experiments.isEnabled("extMigrationFeatures") &&
|
|
41
|
+
(options.mode === "functions" || options.mode === "kits")) {
|
|
42
|
+
await fnHandler(options);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
await extHandler(options);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
async function extHandler(options) {
|
|
25
49
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
26
50
|
const projectNumber = await (0, getProjectNumber_1.getProjectNumber)(options);
|
|
27
|
-
|
|
51
|
+
let have = await Promise.all(await planner.have(projectId));
|
|
28
52
|
if (have.length === 0) {
|
|
29
53
|
logger_1.logger.info(`No extension instances installed on ${projectId}, so there is nothing to export.`);
|
|
30
54
|
return;
|
|
31
55
|
}
|
|
56
|
+
if (options.extensionInstance) {
|
|
57
|
+
have = have.filter((s) => s.instanceId === options.extensionInstance);
|
|
58
|
+
if (have.length === 0) {
|
|
59
|
+
logger_1.logger.info(`No extension instances installed on ${projectId} match specified instance ID ${options.extensionInstance}.`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
32
63
|
const [withRef, withoutRef] = (0, functional_1.partition)(have, (s) => !!s.ref);
|
|
33
64
|
const withRefSubbed = await Promise.all(withRef.map(async (i) => {
|
|
34
65
|
const subbed = await (0, export_1.setSecretParamsToLatest)(i);
|
|
@@ -64,4 +95,110 @@ exports.command = new command_1.Command("ext:export")
|
|
|
64
95
|
force: options.force,
|
|
65
96
|
}, true);
|
|
66
97
|
(0, etags_1.saveEtags)(options.rc, projectId, have);
|
|
67
|
-
}
|
|
98
|
+
}
|
|
99
|
+
async function fnHandler(options) {
|
|
100
|
+
if (!options.extensionInstance) {
|
|
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.`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
105
|
+
const instance = await (0, extensionsApi_1.getInstance)(projectId, options.extensionInstance);
|
|
106
|
+
if (typeof instance === "undefined") {
|
|
107
|
+
logger_1.logger.info(`No extension matching instance ID ${options.extensionInstance} found`);
|
|
108
|
+
return;
|
|
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
|
+
}
|
|
113
|
+
const instanceId = (0, utils_1.last)(instance.name.split("/")) ?? "";
|
|
114
|
+
if (instanceId !== options.extensionInstance) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
let secretCount = 0;
|
|
118
|
+
const convertedEnv = (0, export_1.functionsEnvFromInstance)(instance);
|
|
119
|
+
for (const key of Object.keys(convertedEnv)) {
|
|
120
|
+
if (key.startsWith("FIREBASE_SECRET_REF_")) {
|
|
121
|
+
secretCount += 1;
|
|
122
|
+
}
|
|
123
|
+
console.log(`${key}=${convertedEnv[key]}`);
|
|
124
|
+
}
|
|
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
|
+
}
|
|
186
|
+
if (typeof options.projectRoot !== "undefined") {
|
|
187
|
+
return {
|
|
188
|
+
functionsSource: instanceId,
|
|
189
|
+
configDir: (0, path_1.join)(options.projectRoot, instanceId),
|
|
190
|
+
projectId: projectId,
|
|
191
|
+
isEmulator: false,
|
|
192
|
+
projectDir: options.projectRoot,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
return {
|
|
197
|
+
functionsSource: instanceId,
|
|
198
|
+
configDir: instanceId,
|
|
199
|
+
projectId: projectId,
|
|
200
|
+
isEmulator: false,
|
|
201
|
+
projectDir: options.cwd ?? process.cwd(),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
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" +
|