Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

functions-config-clone.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. });