Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

functions-config-get.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const lodash_1 = require("lodash");
  5. const path_1 = require("path");
  6. const command_1 = require("../command");
  7. const logger_1 = require("../logger");
  8. const projectUtils_1 = require("../projectUtils");
  9. const requirePermissions_1 = require("../requirePermissions");
  10. const functionsConfig = require("../functionsConfig");
  11. async function materialize(projectId, path) {
  12. if (path === undefined) {
  13. return functionsConfig.materializeAll(projectId);
  14. }
  15. const parts = path.split(".");
  16. const configId = parts[0];
  17. const configName = (0, path_1.join)("projects", projectId, "configs", configId);
  18. const result = await functionsConfig.materializeConfig(configName, {});
  19. const query = parts.join(".");
  20. return query ? (0, lodash_1.get)(result, query) : result;
  21. }
  22. exports.command = new command_1.Command("functions:config:get [path]")
  23. .description("fetch environment config stored at the given path")
  24. .before(requirePermissions_1.requirePermissions, [
  25. "runtimeconfig.configs.list",
  26. "runtimeconfig.configs.get",
  27. "runtimeconfig.variables.list",
  28. "runtimeconfig.variables.get",
  29. ])
  30. .before(functionsConfig.ensureApi)
  31. .action(async (path, options) => {
  32. const result = await materialize((0, projectUtils_1.needProjectId)(options), path);
  33. logger_1.logger.info(JSON.stringify(result, null, 2));
  34. return result;
  35. });