open.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.OpenCommand = void 0;
  4. const cli_framework_1 = require("@ionic/cli-framework");
  5. const color_1 = require("../../lib/color");
  6. const base_1 = require("./base");
  7. class OpenCommand extends base_1.CapacitorCommand {
  8. async getMetadata() {
  9. return {
  10. name: 'open',
  11. type: 'project',
  12. summary: 'Open the IDE for a given native platform project',
  13. description: `
  14. ${(0, color_1.input)('ionic capacitor open')} will do the following:
  15. - Open the IDE for your native project (Xcode for iOS, Android Studio for Android)
  16. `,
  17. inputs: [
  18. {
  19. name: 'platform',
  20. summary: `The platform to open (e.g. ${['android', 'ios'].map(v => (0, color_1.input)(v)).join(', ')})`,
  21. validators: [cli_framework_1.validators.required],
  22. },
  23. ],
  24. };
  25. }
  26. async preRun(inputs, options, runinfo) {
  27. await this.preRunChecks(runinfo);
  28. if (!inputs[0]) {
  29. const platform = await this.env.prompt({
  30. type: 'list',
  31. name: 'platform',
  32. message: 'What platform would you like to open?',
  33. choices: ['android', 'ios'],
  34. });
  35. inputs[0] = platform.trim();
  36. }
  37. await this.checkForPlatformInstallation(inputs[0]);
  38. }
  39. async run(inputs, options) {
  40. const [platform] = inputs;
  41. const args = ['open'];
  42. if (platform) {
  43. args.push(platform);
  44. }
  45. await this.runCapacitor(args);
  46. }
  47. }
  48. exports.OpenCommand = OpenCommand;