From 29e033f67e2efb6f121fbd51d582dd49001962cb Mon Sep 17 00:00:00 2001 From: Anisha Date: Tue, 16 Apr 2019 14:03:45 +0530 Subject: [PATCH] prompt for additional features --- .DS_Store | Bin 0 -> 6148 bytes lib/commands/basic/init.js | 128 +++++++++++++++++++++++++++++++++++-- package-lock.json | 43 ++++--------- 3 files changed, 136 insertions(+), 35 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e5bb7fae2befc6b495808ddc277d57093db06a24 GIT binary patch literal 6148 zcmeHKJx>Bb5Pb_*AW)!o11;f-QEH)jhE38Py*!^YN~)L z@Y@xTcejWE9x!W7bMNmlSN1=x*-cb&f^*c-!5NykK$m!kHqwCi9`JU^>mnuRhImRZ z;|^!8*}GznCyeqr%x;jQf+6OZ;huGl$#}#<#sTX!U_}@)YKTP;_YuSuF=gICKB~|U zqRQNJixoFndyjri-4M;*mNeVOGy1GxLO;eG4)`RgXtHS!5cQTbRD%qg_AZJo^R{rw z8tYWKy}ni>YArK3RQp#7@XQt~RUE2U1yli5;9CLtKE!N-iO0;L{dCaTD*!R#v^Dna z&p$Di31Z?gbI2K*aa5wC8h^zw{_bELo$HB@&m1~BjD0fm_$M2GLoxp9VPYE&lQ>kb z3aA2k1&VH1lk>m1`Tn0L=|~k&1^$!*CQ5s0gIn@v>&oWjtc}@j*~BC+b7(1a{y4TB eIg0n#tZ^-t4l(hVIphpYe*~-y>QsRrRp1Lk^^*bs literal 0 HcmV?d00001 diff --git a/lib/commands/basic/init.js b/lib/commands/basic/init.js index 5127570cf..b4246f716 100644 --- a/lib/commands/basic/init.js +++ b/lib/commands/basic/init.js @@ -46,6 +46,105 @@ let showTables = () => { console.log(' Do not delete mevn.json file'); }; +// Prompt for choosing additional features (ESLint, JSHint, JSLint, Prettier) +let installFeature = (wantfeature, template) => { + if(wantfeature){ + inquirer.prompt([{ + name : 'feature', + type: 'list', + message: 'Please select additional feature', + choices : ['ESLint','JSHint','JSLint','Prettier'] + }]) + .then((answer) => { + if (answer.feature === 'ESLint') { + if (template === 'nuxt') { + shell.echo('Installing ESLint for your nuxt template : server'); + shell.cd(`${projectName}/server`); + shell.exec('npm install eslint'); + shell.cd('../..'); + } + else { + // configuring client + shell.echo('Installing ESLint for your '+ template + ' template : client'); + shell.cd(`${projectName}/client`); + shell.exec('npm install eslint'); + shell.cd('../..'); + //configuring server + shell.echo('Installing ESLint for your '+ template + ' template : server'); + shell.cd(`${projectName}/server`); + shell.exec('npm install eslint'); + shell.cd('../..'); + } + } + + if (answer.feature === 'JSHint') { + if (template === 'nuxt') { + shell.echo('Installing JSHint for your nuxt template : server'); + shell.cd(`${projectName}/server`); + shell.exec('npm install jshint'); + shell.cd('../..'); + } + else { + // configuring client + shell.echo('Installing JSHint for your '+ template + ' template : client'); + shell.cd(`${projectName}/client`); + shell.exec('npm install jshint'); + shell.cd('../..'); + //configuring server + shell.echo('Installing JSHint for your '+ template + ' template : server'); + shell.cd(`${projectName}/server`); + shell.exec('npm install jshint'); + shell.cd('../..'); + } + } + + if (answer.feature === 'JSLint') { + if (template === 'nuxt') { + shell.echo('Installing JSLint for your nuxt template : server'); + shell.cd(`${projectName}/server`); + shell.exec('npm install jslint'); + shell.cd('../..'); + } + else { + // configuring client + shell.echo('Installing JSLint for your '+ template + ' template : client'); + shell.cd(`${projectName}/client`); + shell.exec('npm install jslint'); + shell.cd('../..'); + //configuring server + shell.echo('Installing JSLint for your '+ template + ' template : server'); + shell.cd(`${projectName}/server`); + shell.exec('npm install jslint'); + shell.cd('../..'); + } + } + + if (answer.feature === 'Prettier') { + if (template === 'nuxt') { + shell.echo('Installing Prettier for your nuxt template server'); + shell.cd(`${projectName}/server`); + shell.exec('npm install prettier'); + shell.cd('../..'); + } + else { + // configuring client + shell.echo('Installing Prettier for your '+ template + ' template : client'); + shell.cd(`${projectName}/client`); + shell.exec('npm install prettier'); + shell.cd('../..'); + //configuring server + shell.echo('\nInstalling Prettier for your '+ template + ' template : server'); + shell.cd(`${projectName}/server`); + shell.exec('npm install prettier'); + shell.cd('../..'); + } + } + }); + } else { + console.log('Continue..'); + } +}; + let fetchTemplate = (template) => { let templateDir = 'mevn-boilerplate'; if (template !== 'basic') { @@ -62,10 +161,31 @@ let fetchTemplate = (template) => { clearInterval(fetchSpinner); logUpdate.clear(); showTables(); - - }, 5000); + }, 1000); fs.writeFileSync(`./${projectName}/mevn.json`, projectConfig.join('\n').toString()); + + // Prompt for additional features + if (template) { + setTimeout(() => { + inquirer.prompt([{ + name: 'wantfeature', + type:'list', + message:'Do you want any additional features?', + choices:['Yes','No'] + }]) + .then((choice) => { + if(choice.wantfeature === 'Yes') + { + installFeature(choice.wantfeature, template); + } + else if(choice.wantfeature === 'No') + { + console.log('\n'); + } + }); + }, 2000); + } if (template === 'nuxt') { setTimeout(() =>{ @@ -88,7 +208,7 @@ let fetchTemplate = (template) => { } showTables(); }); - }, 5000); + }, 9000); } }; @@ -149,4 +269,4 @@ exports.initializeProject = (appName) => { }); }, 1000); -}; +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0cba5c80c..ff03b5261 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mevn-cli", - "version": "1.1.9", + "version": "1.2.5", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -5639,8 +5639,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -5661,14 +5660,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5683,20 +5680,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -5813,8 +5807,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -5826,7 +5819,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5841,7 +5833,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5849,14 +5840,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5875,7 +5864,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -5956,8 +5944,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -5969,7 +5956,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -6055,8 +6041,7 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -6092,7 +6077,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -6112,7 +6096,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -6156,14 +6139,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true } } },