index.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.VueViteProject = void 0;
  4. const tslib_1 = require("tslib");
  5. const chalk_1 = tslib_1.__importDefault(require("chalk"));
  6. const debug_1 = require("debug");
  7. const lodash = tslib_1.__importStar(require("lodash"));
  8. const path = tslib_1.__importStar(require("path"));
  9. const __1 = require("../");
  10. const errors_1 = require("../../errors");
  11. const debug = (0, debug_1.debug)('ionic:lib:project:vue');
  12. class VueViteProject extends __1.Project {
  13. constructor() {
  14. super(...arguments);
  15. this.type = 'vue';
  16. }
  17. async getInfo() {
  18. const [[ionicVuePkg, ionicVuePkgPath],] = await Promise.all([
  19. this.getPackageJson('@ionic/vue'),
  20. ]);
  21. return [
  22. ...(await super.getInfo()),
  23. {
  24. group: 'ionic',
  25. name: 'Ionic Framework',
  26. key: 'framework',
  27. value: ionicVuePkg ? `@ionic/vue ${ionicVuePkg.version}` : 'not installed',
  28. path: ionicVuePkgPath,
  29. },
  30. ];
  31. }
  32. /**
  33. * We can't detect Vue project types. We don't know what they look like!
  34. */
  35. async detected() {
  36. try {
  37. const pkg = await this.requirePackageJson();
  38. const deps = lodash.assign({}, pkg.dependencies, pkg.devDependencies);
  39. if (typeof deps['@ionic/vue'] === 'string') {
  40. debug(`${chalk_1.default.bold('@ionic/vue')} detected in ${chalk_1.default.bold('package.json')}`);
  41. return true;
  42. }
  43. }
  44. catch (e) {
  45. // ignore
  46. }
  47. return false;
  48. }
  49. async getDefaultDistDir() {
  50. return 'dist';
  51. }
  52. async requireBuildRunner() {
  53. const { VueViteBuildRunner } = await Promise.resolve().then(() => tslib_1.__importStar(require('./build')));
  54. const deps = { ...this.e, project: this };
  55. return new VueViteBuildRunner(deps);
  56. }
  57. async requireServeRunner() {
  58. const { VueServeRunner } = await Promise.resolve().then(() => tslib_1.__importStar(require('./serve')));
  59. const deps = { ...this.e, project: this };
  60. return new VueServeRunner(deps);
  61. }
  62. async requireGenerateRunner() {
  63. throw new errors_1.RunnerNotFoundException(`Cannot perform generate for Vue projects.\n` +
  64. `Since you're using the ${chalk_1.default.bold('Vue')} project type, this command won't work. The Ionic CLI doesn't know how to generate framework components for Vue projects.`);
  65. }
  66. setPrimaryTheme(themeColor) {
  67. const themePath = path.join(this.directory, 'src', 'theme', 'variables.css');
  68. return this.writeThemeColor(themePath, themeColor);
  69. }
  70. }
  71. exports.VueViteProject = VueViteProject;