-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathfunctions-config-unset.ts
More file actions
49 lines (47 loc) · 1.79 KB
/
functions-config-unset.ts
File metadata and controls
49 lines (47 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as clc from "colorette";
import { Command } from "../command";
import { logger } from "../logger";
import { requirePermissions } from "../requirePermissions";
import { needProjectId } from "../projectUtils";
import * as functionsConfig from "../functionsConfig";
import * as runtimeconfig from "../gcp/runtimeconfig";
import * as utils from "../utils";
import { FirebaseError } from "../error";
export const command = new Command("functions:config:unset [keys...]")
.description("unset environment config at the specified path(s)")
.before(functionsConfig.ensureLegacyRuntimeConfigCommandsEnabled)
.before(requirePermissions, [
"runtimeconfig.configs.list",
"runtimeconfig.configs.create",
"runtimeconfig.configs.get",
"runtimeconfig.configs.update",
"runtimeconfig.configs.delete",
"runtimeconfig.variables.list",
"runtimeconfig.variables.create",
"runtimeconfig.variables.get",
"runtimeconfig.variables.update",
"runtimeconfig.variables.delete",
])
.before(functionsConfig.ensureApi)
.action(async (args, options) => {
if (!args.length) {
throw new FirebaseError("Must supply at least one key");
}
const projectId = needProjectId(options);
const parsed = functionsConfig.parseUnsetArgs(args);
await Promise.all(
parsed.map((item) => {
if (item.varId === "") {
return runtimeconfig.configs.delete(projectId, item.configId);
}
return runtimeconfig.variables.delete(projectId, item.configId, item.varId);
}),
);
utils.logSuccess("Environment updated.");
logger.info(
`\nPlease deploy your functions for the change to take effect by running ${clc.bold(
"firebase deploy --only functions",
)}\n`,
);
functionsConfig.logFunctionsConfigDeprecationWarning();
});