MigratorAPI.js 697 B

1234567891011121314151617181920212223
  1. const { semver } = require('@vue/cli-shared-utils')
  2. const GeneratorAPI = require('./GeneratorAPI')
  3. class MigratorAPI extends GeneratorAPI {
  4. /**
  5. * @param {string} id - Id of the owner plugin
  6. * @param {Migrator} migrator - The invoking Migrator instance
  7. * @param {object} options - options passed to this plugin
  8. * @param {object} rootOptions - root options (the entire preset)
  9. */
  10. constructor (id, baseVersion, migrator, options, rootOptions) {
  11. super(id, migrator, options, rootOptions)
  12. this.baseVersion = baseVersion
  13. this.migrator = this.generator
  14. }
  15. fromVersion (range) {
  16. return semver.satisfies(this.baseVersion, range)
  17. }
  18. }
  19. module.exports = MigratorAPI