Files
vue-cli/packages/@vue/cli/lib/Migrator.js
Haoqun Jiang 02a0e8a187 feat: vue upgrade monorepo support, --from option, and a new vue migrate --from command (#5091)
* 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
2020-01-28 16:32:35 +08:00

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()
}
}