-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathfunctions-config-get.ts
More file actions
36 lines (33 loc) · 1.31 KB
/
functions-config-get.ts
File metadata and controls
36 lines (33 loc) · 1.31 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
import { get } from "lodash";
import { join } from "path";
import { Command } from "../command";
import { logger } from "../logger";
import { needProjectId } from "../projectUtils";
import { requirePermissions } from "../requirePermissions";
import * as functionsConfig from "../functionsConfig";
async function materialize(projectId: string, path?: string): Promise<any> {
if (path === undefined) {
return functionsConfig.materializeAll(projectId);
}
const parts = path.split(".");
const configId = parts[0];
const configName = join("projects", projectId, "configs", configId);
const result = await functionsConfig.materializeConfig(configName, {});
const query = parts.join(".");
return query ? get(result, query) : result;
}
export const command = new Command("functions:config:get [path]")
.description("fetch environment config stored at the given path")
.before(requirePermissions, [
"runtimeconfig.configs.list",
"runtimeconfig.configs.get",
"runtimeconfig.variables.list",
"runtimeconfig.variables.get",
])
.before(functionsConfig.ensureApi)
.action(async (path, options) => {
const result = await materialize(needProjectId(options), path);
logger.info(JSON.stringify(result, null, 2));
functionsConfig.logFunctionsConfigDeprecationWarning();
return result;
});