No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions-config-set.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 error_1 = require("../error");
  7. const logger_1 = require("../logger");
  8. const projectUtils_1 = require("../projectUtils");
  9. const requirePermissions_1 = require("../requirePermissions");
  10. const functionsConfig = require("../functionsConfig");
  11. const utils = require("../utils");
  12. exports.command = new command_1.Command("functions:config:set [values...]")
  13. .description("set environment config with key=value syntax")
  14. .before(requirePermissions_1.requirePermissions, [
  15. "runtimeconfig.configs.list",
  16. "runtimeconfig.configs.create",
  17. "runtimeconfig.configs.get",
  18. "runtimeconfig.configs.update",
  19. "runtimeconfig.configs.delete",
  20. "runtimeconfig.variables.list",
  21. "runtimeconfig.variables.create",
  22. "runtimeconfig.variables.get",
  23. "runtimeconfig.variables.update",
  24. "runtimeconfig.variables.delete",
  25. ])
  26. .before(functionsConfig.ensureApi)
  27. .action(async (args, options) => {
  28. if (!args.length) {
  29. throw new error_1.FirebaseError(`Must supply at least one key/value pair, e.g. ${clc.bold('app.name="My App"')}`);
  30. }
  31. const projectId = (0, projectUtils_1.needProjectId)(options);
  32. const parsed = functionsConfig.parseSetArgs(args);
  33. const promises = [];
  34. for (const item of parsed) {
  35. if (item.val === undefined) {
  36. throw new error_1.FirebaseError(`Unexpected undefined value for varId "${item.varId}`, { exit: 2 });
  37. }
  38. promises.push(functionsConfig.setVariablesRecursive(projectId, item.configId, item.varId, item.val));
  39. }
  40. await Promise.all(promises);
  41. utils.logSuccess("Functions config updated.");
  42. logger_1.logger.info(`\nPlease deploy your functions for the change to take effect by running ${clc.bold("firebase deploy --only functions")}\n`);
  43. });