Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

apps-list.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const clc = require("colorette");
  5. const ora = require("ora");
  6. const Table = require("cli-table");
  7. const command_1 = require("../command");
  8. const projectUtils_1 = require("../projectUtils");
  9. const apps_1 = require("../management/apps");
  10. const requireAuth_1 = require("../requireAuth");
  11. const logger_1 = require("../logger");
  12. const NOT_SPECIFIED = clc.yellow("[Not specified]");
  13. function logAppsList(apps) {
  14. if (apps.length === 0) {
  15. logger_1.logger.info(clc.bold("No apps found."));
  16. return;
  17. }
  18. const tableHead = ["App Display Name", "App ID", "Platform"];
  19. const table = new Table({ head: tableHead, style: { head: ["green"] } });
  20. apps.forEach(({ appId, displayName, platform }) => {
  21. table.push([displayName || NOT_SPECIFIED, appId, platform]);
  22. });
  23. logger_1.logger.info(table.toString());
  24. }
  25. function logAppCount(count = 0) {
  26. if (count === 0) {
  27. return;
  28. }
  29. logger_1.logger.info("");
  30. logger_1.logger.info(`${count} app(s) total.`);
  31. }
  32. exports.command = new command_1.Command("apps:list [platform]")
  33. .description("list the registered apps of a Firebase project. " +
  34. "Optionally filter apps by [platform]: IOS, ANDROID or WEB (case insensitive)")
  35. .before(requireAuth_1.requireAuth)
  36. .action(async (platform, options) => {
  37. const projectId = (0, projectUtils_1.needProjectId)(options);
  38. const appPlatform = (0, apps_1.getAppPlatform)(platform || "");
  39. let apps;
  40. const spinner = ora("Preparing the list of your Firebase " +
  41. `${appPlatform === apps_1.AppPlatform.ANY ? "" : appPlatform + " "}apps`).start();
  42. try {
  43. apps = await (0, apps_1.listFirebaseApps)(projectId, appPlatform);
  44. }
  45. catch (err) {
  46. spinner.fail();
  47. throw err;
  48. }
  49. spinner.succeed();
  50. logAppsList(apps);
  51. logAppCount(apps.length);
  52. return apps;
  53. });