list.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.IntegrationsListCommand = void 0;
  4. const tslib_1 = require("tslib");
  5. const utils_terminal_1 = require("@ionic/utils-terminal");
  6. const chalk_1 = tslib_1.__importDefault(require("chalk"));
  7. const color_1 = require("../../lib/color");
  8. const command_1 = require("../../lib/command");
  9. const errors_1 = require("../../lib/errors");
  10. const integrations_1 = require("../../lib/integrations");
  11. class IntegrationsListCommand extends command_1.Command {
  12. async getMetadata() {
  13. return {
  14. name: 'list',
  15. type: 'project',
  16. summary: 'List available and active integrations in your app',
  17. description: `
  18. This command will print the status of integrations in Ionic projects. Integrations can be ${(0, color_1.strong)('enabled')} (added and enabled), ${(0, color_1.strong)('disabled')} (added but disabled), and ${(0, color_1.strong)('not added')} (never added to the project).
  19. - To enable or add integrations, see ${(0, color_1.input)('ionic integrations enable --help')}
  20. - To disable integrations, see ${(0, color_1.input)('ionic integrations disable --help')}
  21. `,
  22. };
  23. }
  24. async run(inputs, options) {
  25. const { project } = this;
  26. if (!project) {
  27. throw new errors_1.FatalException(`Cannot run ${(0, color_1.input)('ionic integrations list')} outside a project directory.`);
  28. }
  29. const integrations = await Promise.all(integrations_1.INTEGRATION_NAMES.map(async (name) => project.createIntegration(name)));
  30. const status = (name) => {
  31. const c = project.config.get('integrations')[name];
  32. if (c) {
  33. if (c.enabled === false) {
  34. return chalk_1.default.dim.red('disabled');
  35. }
  36. return chalk_1.default.green('enabled');
  37. }
  38. return chalk_1.default.dim('not added');
  39. };
  40. this.env.log.rawmsg((0, utils_terminal_1.columnar)(integrations.map(i => [(0, color_1.input)(i.name), i.summary, status(i.name)]), { headers: ['name', 'summary', 'status'] }));
  41. }
  42. }
  43. exports.IntegrationsListCommand = IntegrationsListCommand;