feat: improve prompt flow

This commit is contained in:
Evan You
2018-01-14 22:58:17 -05:00
parent 132b0db8e4
commit 06af371c04
5 changed files with 18 additions and 9 deletions

View File

@@ -169,7 +169,7 @@ module.exports = class Creator {
} else {
// manual
options = {
packageManager: answers.packageManager,
packageManager: answers.packageManager || loadOptions().packageManager,
plugins: {}
}
// run cb registered by prompt modules to finalize the options
@@ -242,7 +242,8 @@ module.exports = class Creator {
resolveOutroPrompts () {
const outroPrompts = []
if (hasYarn) {
const savedOptions = loadOptions()
if (hasYarn && !savedOptions.packageManager) {
outroPrompts.push({
name: 'packageManager',
when: isMode('manual'),
@@ -266,7 +267,7 @@ module.exports = class Creator {
name: 'save',
when: isMode('manual'),
type: 'confirm',
message: 'Save the preferences for future projects?'
message: 'Save the preferences for future projects? (You can always manually edit ~/.vuerc)'
})
return outroPrompts
}

View File

@@ -32,7 +32,10 @@ exports.defaults = {
packageManager: hasYarn ? 'yarn' : 'npm',
plugins: {
'@vue/cli-plugin-babel': {},
'@vue/cli-plugin-eslint': { config: 'base', lintOn: 'save' },
'@vue/cli-plugin-eslint': {
config: 'base',
lintOn: ['save', 'commit']
},
'@vue/cli-plugin-unit-mocha': {}
}
}

View File

@@ -5,7 +5,8 @@ module.exports = cli => {
cli.injectFeature({
name: 'Linter / Formatter',
value: 'linter',
short: 'Linter'
short: 'Linter',
checked: true
})
cli.injectPrompt({
@@ -48,11 +49,13 @@ module.exports = cli => {
choices: [
{
name: 'Lint on save',
value: 'save'
value: 'save',
checked: true
},
{
name: 'Lint and fix on commit' + (hasGit ? '' : chalk.red(' (requires Git)')),
value: 'commit'
value: 'commit',
checked: true
}
]
})

View File

@@ -1,7 +1,8 @@
module.exports = cli => {
cli.injectFeature({
name: 'Progressive Web App (PWA) Support',
value: 'pwa'
value: 'pwa',
short: 'PWA'
})
cli.onPromptComplete((answers, options) => {

View File

@@ -2,7 +2,8 @@ module.exports = cli => {
cli.injectFeature({
name: 'Unit Testing',
value: 'unit',
short: 'Unit'
short: 'Unit',
checked: true
})
cli.injectPrompt({