UNPKG

1.65 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const cli_framework_1 = require("@ionic/cli-framework");
4const color_1 = require("../../lib/color");
5const base_1 = require("./base");
6class AddCommand extends base_1.CapacitorCommand {
7 async getMetadata() {
8 return {
9 name: 'add',
10 type: 'project',
11 summary: 'Add a native platform to your Ionic project',
12 description: `
13${color_1.input('ionic capacitor add')} will do the following:
14- Add a new platform specific folder to your project (ios, android, or electron)
15 `,
16 inputs: [
17 {
18 name: 'platform',
19 summary: `The platform to add (e.g. ${['android', 'ios', 'electron'].map(v => color_1.input(v)).join(', ')})`,
20 validators: [cli_framework_1.validators.required],
21 },
22 ],
23 groups: ["beta" /* BETA */],
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 add?',
33 choices: ['android', 'ios', 'electron'],
34 });
35 inputs[0] = platform.trim();
36 }
37 }
38 async run(inputs, options) {
39 const [platform] = inputs;
40 const args = ['add'];
41 if (platform) {
42 args.push(platform);
43 }
44 await this.runCapacitor(args);
45 }
46}
47exports.AddCommand = AddCommand;