copy.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.CopyCommand = void 0;
  4. const tslib_1 = require("tslib");
  5. const color_1 = require("../../lib/color");
  6. const base_1 = require("./base");
  7. const semver = tslib_1.__importStar(require("semver"));
  8. class CopyCommand extends base_1.CapacitorCommand {
  9. async getMetadata() {
  10. const options = [
  11. {
  12. name: 'build',
  13. summary: 'Do not invoke an Ionic build',
  14. type: Boolean,
  15. default: true,
  16. },
  17. {
  18. name: 'inline',
  19. summary: 'Use inline source maps (only available on capacitor 4.2.0+)',
  20. type: Boolean,
  21. default: false
  22. }
  23. ];
  24. const runner = this.project && await this.project.getBuildRunner();
  25. if (runner) {
  26. const libmetadata = await runner.getCommandMetadata();
  27. options.push(...libmetadata.options || []);
  28. }
  29. return {
  30. name: 'copy',
  31. type: 'project',
  32. summary: 'Copy web assets to native platforms',
  33. description: `
  34. ${(0, color_1.input)('ionic capacitor copy')} will do the following:
  35. - Perform an Ionic build, which compiles web assets
  36. - Copy web assets to Capacitor native platform(s)
  37. `,
  38. inputs: [
  39. {
  40. name: 'platform',
  41. summary: `The platform to copy (e.g. ${['android', 'ios'].map(v => (0, color_1.input)(v)).join(', ')})`,
  42. },
  43. ],
  44. options,
  45. };
  46. }
  47. async preRun(inputs, options, runinfo) {
  48. await this.preRunChecks(runinfo);
  49. if (inputs[0]) {
  50. await this.checkForPlatformInstallation(inputs[0]);
  51. }
  52. }
  53. async run(inputs, options) {
  54. const [platform] = inputs;
  55. if (options.build) {
  56. await this.runBuild(inputs, options);
  57. }
  58. const args = ['copy'];
  59. const capVersion = await this.getCapacitorVersion();
  60. if (semver.gte(capVersion, "4.2.0") && options.inline) {
  61. args.push("--inline");
  62. }
  63. if (platform) {
  64. args.push(platform);
  65. }
  66. await this.runCapacitor(args);
  67. }
  68. }
  69. exports.CopyCommand = CopyCommand;