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.

ext-dev-list.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const clc = require("colorette");
  5. const Table = require("cli-table");
  6. const command_1 = require("../command");
  7. const error_1 = require("../error");
  8. const utils_1 = require("../utils");
  9. const extensionsApi_1 = require("../extensions/extensionsApi");
  10. const logger_1 = require("../logger");
  11. const extensionsHelper_1 = require("../extensions/extensionsHelper");
  12. const requireAuth_1 = require("../requireAuth");
  13. const extensionsUtils = require("../extensions/utils");
  14. exports.command = new command_1.Command("ext:dev:list <publisherId>")
  15. .description("list all published extensions associated with this publisher ID")
  16. .before(requireAuth_1.requireAuth)
  17. .action(async (publisherId) => {
  18. let extensions;
  19. try {
  20. extensions = await (0, extensionsApi_1.listExtensions)(publisherId);
  21. }
  22. catch (err) {
  23. throw new error_1.FirebaseError(err);
  24. }
  25. if (extensions.length < 1) {
  26. throw new error_1.FirebaseError(`There are no published extensions associated with publisher ID ${clc.bold(publisherId)}. This could happen for two reasons:\n` +
  27. " - The publisher ID doesn't exist or could be misspelled\n" +
  28. " - This publisher has not published any extensions\n\n" +
  29. "If you are expecting some extensions to appear, please make sure you have the correct publisher ID and try again.");
  30. }
  31. const table = new Table({
  32. head: ["Extension ID", "Version", "Published"],
  33. style: { head: ["yellow"] },
  34. });
  35. const sorted = extensions.sort((a, b) => new Date(b.createTime).valueOf() - new Date(a.createTime).valueOf());
  36. sorted.forEach((extension) => {
  37. table.push([
  38. (0, utils_1.last)(extension.ref.split("/")),
  39. extension.latestVersion,
  40. extension.createTime ? extensionsUtils.formatTimestamp(extension.createTime) : "",
  41. ]);
  42. });
  43. (0, utils_1.logLabeledBullet)(extensionsHelper_1.logPrefix, `list of published extensions for publisher ${clc.bold(publisherId)}:`);
  44. logger_1.logger.info(table.toString());
  45. return { extensions: sorted };
  46. });