GSI - Employe Self Service Mobile
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.

53 lines
2.4 KiB

2 months ago
  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 functionsConfigClone_1 = require("../functionsConfigClone");
  12. const utils = require("../utils");
  13. exports.command = new command_1.Command("functions:config:clone")
  14. .description("clone environment config from another project")
  15. .option("--from <projectId>", "the project from which to clone configuration")
  16. .option("--only <keys>", "a comma-separated list of keys to clone")
  17. .option("--except <keys>", "a comma-separated list of keys to not clone")
  18. .before(requirePermissions_1.requirePermissions, [
  19. "runtimeconfig.configs.list",
  20. "runtimeconfig.configs.create",
  21. "runtimeconfig.configs.get",
  22. "runtimeconfig.configs.update",
  23. "runtimeconfig.configs.delete",
  24. "runtimeconfig.variables.list",
  25. "runtimeconfig.variables.create",
  26. "runtimeconfig.variables.get",
  27. "runtimeconfig.variables.update",
  28. "runtimeconfig.variables.delete",
  29. ])
  30. .before(functionsConfig.ensureApi)
  31. .action(async (options) => {
  32. const projectId = (0, projectUtils_1.needProjectId)(options);
  33. if (!options.from) {
  34. throw new error_1.FirebaseError(`Must specify a source project in ${clc.bold("--from <projectId>")} option.`);
  35. }
  36. else if (options.from === projectId) {
  37. throw new error_1.FirebaseError("From project and destination can't be the same project.");
  38. }
  39. else if (options.only && options.except) {
  40. throw new error_1.FirebaseError("Cannot use both --only and --except at the same time.");
  41. }
  42. let only;
  43. let except = [];
  44. if (options.only) {
  45. only = options.only.split(",");
  46. }
  47. else if (options.except) {
  48. except = options.except.split(",");
  49. }
  50. await (0, functionsConfigClone_1.functionsConfigClone)(options.from, projectId, only, except);
  51. utils.logSuccess(`Cloned functions config from ${clc.bold(options.from)} into ${clc.bold(projectId)}`);
  52. logger_1.logger.info(`\nPlease deploy your functions for the change to take effect by running ${clc.bold("firebase deploy --only functions")}\n`);
  53. });