Files
vue-cli/packages/@vue/cli/lib/MigratorAPI.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

24 lines
697 B
JavaScript

const { semver } = require('@vue/cli-shared-utils')
const GeneratorAPI = require('./GeneratorAPI')
class MigratorAPI extends GeneratorAPI {
/**
* @param {string} id - Id of the owner plugin
* @param {Migrator} migrator - The invoking Migrator instance
* @param {object} options - options passed to this plugin
* @param {object} rootOptions - root options (the entire preset)
*/
constructor (id, baseVersion, migrator, options, rootOptions) {
super(id, migrator, options, rootOptions)
this.baseVersion = baseVersion
this.migrator = this.generator
}
fromVersion (range) {
return semver.satisfies(this.baseVersion, range)
}
}
module.exports = MigratorAPI