Skip to content

Commit df93f46

Browse files
committed
fix: fix vueVersion prompt & typescript plugin invocation order
1 parent f7b4fa7 commit df93f46

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

packages/@vue/cli/lib/Creator.js

+21-2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ module.exports = class Creator extends EventEmitter {
111111
}
112112
}
113113

114+
// Introducing this hack because typescript plugin must be invoked after router.
115+
// Currently we rely on the `plugins` object enumeration order,
116+
// which depends on the order of the field initialization.
117+
// FIXME: Remove this ugly hack after the plugin ordering API settled down
118+
if (preset.plugins['@vue/cli-plugin-router'] && preset.plugins['@vue/cli-plugin-typescript']) {
119+
const tmp = preset.plugins['@vue/cli-plugin-typescript']
120+
delete preset.plugins['@vue/cli-plugin-typescript']
121+
preset.plugins['@vue/cli-plugin-typescript'] = tmp
122+
}
123+
114124
// legacy support for vuex
115125
if (preset.vuex) {
116126
preset.plugins['@vue/cli-plugin-vuex'] = {}
@@ -423,7 +433,6 @@ module.exports = class Creator extends EventEmitter {
423433
]
424434
}
425435
const vueVersionPrompt = {
426-
when: answers => answers.preset === 'default',
427436
name: 'vueVersion',
428437
type: 'list',
429438
message: `Choose a version of Vue.js that you want to start the project with`,
@@ -532,10 +541,20 @@ module.exports = class Creator extends EventEmitter {
532541
return isManualMode(answers) && originalWhen(answers)
533542
}
534543
})
544+
545+
const vueVersionPromptForDefaultPreset = Object.assign({
546+
when: answers => answers.preset === 'default'
547+
}, this.vueVersionPrompt)
548+
549+
const vueVersionPromptAsAFeature = Object.assign({
550+
when: answers => answers.features.includes['vueVersion']
551+
}, this.vueVersionPrompt)
552+
535553
const prompts = [
536554
this.presetPrompt,
537-
this.vueVersionPrompt,
555+
vueVersionPromptForDefaultPreset,
538556
this.featurePrompt,
557+
vueVersionPromptAsAFeature,
539558
...this.injectedPrompts,
540559
...this.outroPrompts
541560
]

0 commit comments

Comments
 (0)