mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-21 06:39:56 -06:00
* refactor(migrator): rename `installed` to `baseVersion` * feat: `vue upgrade --from` option and a new `vue migrate` command * fix: fix support for `vuePlugins.resolveFrom` option * chore: add a fixme comment * fix: use loadModule instead of manually calculating the package.json path This also fixes support for monorepo. (TODO: tests) * fix: treat `resolveFrom` as `context`, fixing edge cases * fix: use read-pkg instead of loadModule, avoid messing up require cache * fix: getInstalledVersion still requires `loadModule` to support monorepo
42 lines
791 B
JavaScript
42 lines
791 B
JavaScript
const Generator = require('./Generator')
|
|
const MigratorAPI = require('./MigratorAPI')
|
|
|
|
module.exports = class Migrator extends Generator {
|
|
constructor (context, {
|
|
plugin,
|
|
|
|
pkg = {},
|
|
afterInvokeCbs = [],
|
|
files = {},
|
|
invoking = false
|
|
} = {}) {
|
|
super(context, {
|
|
pkg,
|
|
plugins: [],
|
|
afterInvokeCbs,
|
|
files,
|
|
invoking
|
|
})
|
|
|
|
this.migratorPlugin = plugin
|
|
this.invoking = invoking
|
|
}
|
|
|
|
async generate () {
|
|
const plugin = this.migratorPlugin
|
|
|
|
// apply migrators from plugins
|
|
const api = new MigratorAPI(
|
|
plugin.id,
|
|
plugin.baseVersion,
|
|
this,
|
|
plugin.options,
|
|
this.rootOptions
|
|
)
|
|
|
|
await plugin.apply(api, plugin.options, this.rootOptions, this.invoking)
|
|
|
|
await super.generate()
|
|
}
|
|
}
|