add.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.AddCommand = 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 AddCommand extends base_1.CapacitorCommand {
  8. async getMetadata() {
  9. return {
  10. name: 'add',
  11. type: 'project',
  12. summary: 'Add a native platform to your Ionic project',
  13. description: `
  14. ${(0, color_1.input)('ionic capacitor add')} will do the following:
  15. - Install the Capacitor platform package
  16. - Copy the native platform template into your project
  17. `,
  18. inputs: [
  19. {
  20. name: 'platform',
  21. summary: `The platform to add (e.g. ${['android', 'ios'].map(v => (0, color_1.input)(v)).join(', ')})`,
  22. validators: [cli_framework_1.validators.required],
  23. },
  24. ],
  25. };
  26. }
  27. async preRun(inputs, options, runinfo) {
  28. await this.preRunChecks(runinfo);
  29. if (!inputs[0]) {
  30. const platform = await this.env.prompt({
  31. type: 'list',
  32. name: 'platform',
  33. message: 'What platform would you like to add?',
  34. choices: ['android', 'ios'],
  35. });
  36. inputs[0] = platform.trim();
  37. }
  38. }
  39. async run(inputs, options) {
  40. const [platform] = inputs;
  41. await this.installPlatform(platform);
  42. }
  43. }
  44. exports.AddCommand = AddCommand;