Няма описание
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const command_1 = require("../command");
  5. const error_1 = require("../error");
  6. const prompt_1 = require("../prompt");
  7. const requireAuth_1 = require("../requireAuth");
  8. const rollback_1 = require("../remoteconfig/rollback");
  9. const requirePermissions_1 = require("../requirePermissions");
  10. const versionslist_1 = require("../remoteconfig/versionslist");
  11. const projectUtils_1 = require("../projectUtils");
  12. exports.command = new command_1.Command("remoteconfig:rollback")
  13. .description("roll back a project's published Remote Config template to the one specified by the provided version number")
  14. .before(requireAuth_1.requireAuth)
  15. .before(requirePermissions_1.requirePermissions, ["cloudconfig.configs.get", "cloudconfig.configs.update"])
  16. .option("-v, --version-number <versionNumber>", "rollback to the specified version of the template")
  17. .withForce()
  18. .action(async (options) => {
  19. var _a;
  20. const templateVersion = await (0, versionslist_1.getVersions)((0, projectUtils_1.needProjectId)(options), 1);
  21. let targetVersion = 0;
  22. if (options.versionNumber) {
  23. targetVersion = options.versionNumber;
  24. }
  25. else {
  26. if ((_a = templateVersion === null || templateVersion === void 0 ? void 0 : templateVersion.versions[0]) === null || _a === void 0 ? void 0 : _a.versionNumber) {
  27. const latestVersion = templateVersion.versions[0].versionNumber.toString();
  28. const previousVersion = parseInt(latestVersion) - 1;
  29. targetVersion = previousVersion;
  30. }
  31. }
  32. if (targetVersion <= 0) {
  33. throw new error_1.FirebaseError(`Failed to rollback Firebase Remote Config template for project to version` +
  34. targetVersion +
  35. `. ` +
  36. `Invalid Version Number`);
  37. }
  38. const confirm = await (0, prompt_1.promptOnce)({
  39. type: "confirm",
  40. name: "force",
  41. message: "Proceed to rollback template to version " + targetVersion + "?",
  42. default: false,
  43. }, options);
  44. if (!confirm) {
  45. return;
  46. }
  47. return (0, rollback_1.rollbackTemplate)((0, projectUtils_1.needProjectId)(options), targetVersion);
  48. });