Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prompt for additional features #106

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
128 changes: 124 additions & 4 deletions lib/commands/basic/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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(() =>{
Expand All @@ -88,7 +208,7 @@ let fetchTemplate = (template) => {
}
showTables();
});
}, 5000);
}, 9000);
}
};

Expand Down Expand Up @@ -149,4 +269,4 @@ exports.initializeProject = (appName) => {
});
}, 1000);

};
};
43 changes: 12 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.