Ingen beskrivning
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ext-dev-undeprecate.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const clc = require("colorette");
  5. const semver = require("semver");
  6. const refs = require("../extensions/refs");
  7. const utils = require("../utils");
  8. const command_1 = require("../command");
  9. const prompt_1 = require("../prompt");
  10. const extensionsHelper_1 = require("../extensions/extensionsHelper");
  11. const extensionsApi_1 = require("../extensions/extensionsApi");
  12. const versionHelper_1 = require("../extensions/versionHelper");
  13. const requireAuth_1 = require("../requireAuth");
  14. const error_1 = require("../error");
  15. exports.command = new command_1.Command("ext:dev:undeprecate <extensionRef> <versionPredicate>")
  16. .description("undeprecate extension versions that match the version predicate")
  17. .before(requireAuth_1.requireAuth)
  18. .before(extensionsHelper_1.ensureExtensionsApiEnabled)
  19. .action(async (extensionRef, versionPredicate, options) => {
  20. const { publisherId, extensionId, version } = refs.parse(extensionRef);
  21. if (version) {
  22. throw new error_1.FirebaseError(`The input extension reference must be of the format ${clc.bold("<publisherId>/<extensionId>")}. Version should be supplied in the version predicate argument.`);
  23. }
  24. if (!publisherId || !extensionId) {
  25. throw new error_1.FirebaseError(`Error parsing publisher ID and extension ID from extension reference '${clc.bold(extensionRef)}'. Please use the format '${clc.bold("<publisherId>/<extensionId>")}'.`);
  26. }
  27. const { comparator, targetSemVer } = (0, versionHelper_1.parseVersionPredicate)(versionPredicate);
  28. const filter = `id${comparator}"${targetSemVer}"`;
  29. const extensionVersions = await (0, extensionsApi_1.listExtensionVersions)(extensionRef, filter);
  30. extensionVersions
  31. .sort((ev1, ev2) => {
  32. return -semver.compare(ev1.spec.version, ev2.spec.version);
  33. })
  34. .forEach((extensionVersion) => {
  35. utils.logLabeledBullet(extensionVersion.ref, extensionVersion.state);
  36. });
  37. if (extensionVersions.length > 0) {
  38. if (!options.force) {
  39. const confirmMessage = "You are about to undeprecate these extension version(s). Do you wish to continue?";
  40. const consent = await (0, prompt_1.promptOnce)({
  41. type: "confirm",
  42. message: confirmMessage,
  43. default: false,
  44. });
  45. if (!consent) {
  46. throw new error_1.FirebaseError("Undeprecation canceled.");
  47. }
  48. }
  49. }
  50. else {
  51. throw new error_1.FirebaseError("No extension versions matched the version predicate.");
  52. }
  53. await utils.allSettled(extensionVersions.map(async (extensionVersion) => {
  54. await (0, extensionsApi_1.undeprecateExtensionVersion)(extensionVersion.ref);
  55. }));
  56. utils.logLabeledSuccess(extensionsHelper_1.logPrefix, "successfully undeprecated extension version(s).");
  57. });