import { exec } from 'shelljs'; export class FeatrueList { constructor (projectType:string, featrueList:Array) { // 1 创建项目目录 this.createProjectFile(projectType, featrueList); } private createProjectFile (projectType:string, featrueList:string[]) { // 判断项目类型 // 根据项目类型实现对应的功能 switch (projectType) { case 'vue': this.createVueFeatrue(featrueList); console.log(featrueList); break; case 'react': this.createReactFeatrue(featrueList); break; default: } } private createReactFeatrue (featrueList) { if (featrueList.includes('eslint')) { this.createEslint(); } if (featrueList.includes('commitizen')) { this.createCommitizen(); } if (featrueList.includes('husky')) { this.createHusky(); } if (featrueList.includes('ts')) { this.createTs(); } } private createVueFeatrue (featrueList:string[]) { if (featrueList.includes('eslint')) { this.createEslint(); } if (featrueList.includes('commitizen')) { this.createCommitizen(); } if (featrueList.includes('husky')) { this.createHusky(); } if (featrueList.includes('ts')) { this.createTs(); } } private createEslint () { exec('npm i eslint@8.14.0 eslint-config-standard@17.0.0 eslint-plugin-vue@8.7.1 -D'); // exec('eslint --init'); } private createCommitizen () { console.log('commitizen'); } private createHusky () { console.log('husky'); } private createTs () { console.log('Ts'); } }