disable.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.IntegrationsDisableCommand = void 0;
  4. const cli_framework_1 = require("@ionic/cli-framework");
  5. const guards_1 = require("../../guards");
  6. const color_1 = require("../../lib/color");
  7. const command_1 = require("../../lib/command");
  8. const errors_1 = require("../../lib/errors");
  9. const integrations_1 = require("../../lib/integrations");
  10. class IntegrationsDisableCommand extends command_1.Command {
  11. async getMetadata() {
  12. return {
  13. name: 'disable',
  14. type: 'project',
  15. summary: 'Disable an integration',
  16. description: `
  17. Integrations, such as Cordova, can be disabled with this command.
  18. `,
  19. inputs: [
  20. {
  21. name: 'name',
  22. summary: `The integration to disable (e.g. ${integrations_1.INTEGRATION_NAMES.map(i => (0, color_1.input)(i)).join(', ')})`,
  23. validators: [cli_framework_1.validators.required, (0, cli_framework_1.contains)(integrations_1.INTEGRATION_NAMES, {})],
  24. },
  25. ],
  26. };
  27. }
  28. async run(inputs, options) {
  29. const [name] = inputs;
  30. if (!this.project) {
  31. throw new errors_1.FatalException(`Cannot run ${(0, color_1.input)('ionic integrations disable')} outside a project directory.`);
  32. }
  33. if (!(0, guards_1.isIntegrationName)(name)) {
  34. throw new errors_1.FatalException(`Don't know about ${(0, color_1.input)(name)} integration!`);
  35. }
  36. const integration = await this.project.createIntegration(name);
  37. try {
  38. if (!integration.isAdded() || !integration.isEnabled()) {
  39. this.env.log.info(`Integration ${(0, color_1.input)(name)} already disabled.`);
  40. }
  41. else {
  42. await integration.disable();
  43. this.env.log.ok(`Integration ${(0, color_1.input)(name)} disabled!`);
  44. }
  45. }
  46. catch (e) {
  47. if (e instanceof cli_framework_1.BaseError) {
  48. throw new errors_1.FatalException(e.message);
  49. }
  50. throw e;
  51. }
  52. }
  53. }
  54. exports.IntegrationsDisableCommand = IntegrationsDisableCommand;