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.

hosting-channel-list.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const colorette_1 = require("colorette");
  5. const Table = require("cli-table");
  6. const api_1 = require("../hosting/api");
  7. const command_1 = require("../command");
  8. const requirePermissions_1 = require("../requirePermissions");
  9. const projectUtils_1 = require("../projectUtils");
  10. const logger_1 = require("../logger");
  11. const requireConfig_1 = require("../requireConfig");
  12. const utils_1 = require("../utils");
  13. const requireHostingSite_1 = require("../requireHostingSite");
  14. const TABLE_HEAD = ["Channel ID", "Last Release Time", "URL", "Expire Time"];
  15. exports.command = new command_1.Command("hosting:channel:list")
  16. .description("list all Firebase Hosting channels for your project")
  17. .option("--site <siteName>", "list channels for the specified site")
  18. .before(requireConfig_1.requireConfig)
  19. .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
  20. .before(requireHostingSite_1.requireHostingSite)
  21. .action(async (options) => {
  22. const projectId = (0, projectUtils_1.needProjectId)(options);
  23. const siteId = options.site;
  24. const channels = await (0, api_1.listChannels)(projectId, siteId);
  25. const table = new Table({ head: TABLE_HEAD, style: { head: ["green"] } });
  26. for (const channel of channels) {
  27. const channelId = channel.name.split("/").pop();
  28. table.push([
  29. channelId,
  30. (0, utils_1.datetimeString)(new Date(channel.updateTime)),
  31. channel.url,
  32. channel.expireTime ? (0, utils_1.datetimeString)(new Date(channel.expireTime)) : "never",
  33. ]);
  34. }
  35. logger_1.logger.info();
  36. logger_1.logger.info(`Channels for site ${(0, colorette_1.bold)(siteId)}`);
  37. logger_1.logger.info();
  38. logger_1.logger.info(table.toString());
  39. return { channels };
  40. });