How to use the @vue/cli-shared-utils.semver.satisfies function in @vue/cli-shared-utils

To help you get started, we’ve selected a few @vue/cli-shared-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vue-cli / packages / @vue / cli / bin / vue.js View on Github external
// Setting edit distance to 60% of the input string's length
didYouMean.threshold = 0.6

function checkNodeVersion (wanted, id) {
  if (!semver.satisfies(process.version, wanted)) {
    console.log(chalk.red(
      'You are using Node ' + process.version + ', but this version of ' + id +
      ' requires Node ' + wanted + '.\nPlease upgrade your Node version.'
    ))
    process.exit(1)
  }
}

checkNodeVersion(requiredVersion, '@vue/cli')

if (semver.satisfies(process.version, '9.x')) {
  console.log(chalk.red(
    `You are using Node ${process.version}.\n` +
    `Node.js 9.x has already reached end-of-life and will not be supported in future major releases.\n` +
    `It's strongly recommended to use an active LTS version instead.`
  ))
}

const fs = require('fs')
const path = require('path')
const slash = require('slash')
const minimist = require('minimist')

// enter debug mode when creating test repo
if (
  slash(process.cwd()).indexOf('/packages/test') > 0 && (
    fs.existsSync(path.resolve(process.cwd(), '../@vue')) ||
github vuejs / vue-cli / packages / @vue / cli-service / bin / vue-cli-service.js View on Github external
#!/usr/bin/env node

const { semver, error } = require('@vue/cli-shared-utils')
const requiredVersion = require('../package.json').engines.node

if (!semver.satisfies(process.version, requiredVersion)) {
  error(
    `You are using Node ${process.version}, but vue-cli-service ` +
    `requires Node ${requiredVersion}.\nPlease upgrade your Node version.`
  )
  process.exit(1)
}

const Service = require('../lib/Service')
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd())

const rawArgv = process.argv.slice(2)
const args = require('minimist')(rawArgv, {
  boolean: [
    // build
    'modern',
    'report',
github vuejs / vue-cli / packages / @vue / cli / lib / add.js View on Github external
async function add (pluginName, options = {}, context = process.cwd()) {
  if (!(await confirmIfGitDirty(context))) {
    return
  }

  // for `vue add` command in 3.x projects
  const servicePkg = loadModule('@vue/cli-service/package.json', context)
  if (servicePkg && semver.satisfies(servicePkg.version, '3.x')) {
    // special internal "plugins"
    if (/^(@vue\/)?router$/.test(pluginName)) {
      return addRouter(context)
    }
    if (/^(@vue\/)?vuex$/.test(pluginName)) {
      return addVuex(context)
    }
  }

  const packageName = resolvePluginId(pluginName)

  log()
  log(`📦  Installing ${chalk.cyan(packageName)}...`)
  log()

  const pm = new PackageManager({ context })
github vuejs / vue-cli / packages / @vue / cli-ui / ui-defaults / suggestions.js View on Github external
async function install (api, id) {
  api.setProgress({
    status: 'org.vue.cli-service.suggestions.progress',
    args: [id],
    progress: -1
  })

  const context = api.getCwd()

  let error

  try {
    const servicePkg = loadModule('@vue/cli-service/package.json', context)
    // @vue/cli-plugin-router is not compatible with @vue/cli-service v3,
    // so we have to check for the version and call the right generator
    if (semver.satisfies(servicePkg.version, '3.x')) {
      await invoke.runGenerator(context, {
        id: `core:${id}`,
        apply: loadModule(`@vue/cli-service/generator/${id}`, context)
      })
    } else {
      // FIXME: a temporary fix for adding router plugin
      // should implement a plugin prompt ui later
      await add(id, { $inlineOptions: '{}' }, context)
    }
  } catch (e) {
    error = e
  }

  api.removeProgress()

  if (error) throw error
github vuejs / vue-cli / packages / @vue / cli / bin / vue.js View on Github external
function checkNodeVersion (wanted, id) {
  if (!semver.satisfies(process.version, wanted)) {
    console.log(chalk.red(
      'You are using Node ' + process.version + ', but this version of ' + id +
      ' requires Node ' + wanted + '.\nPlease upgrade your Node version.'
    ))
    process.exit(1)
  }
}
github luoxue-victor / webpack-box / packages / packages-cli / cli / bin / packages-box.js View on Github external
function checkNodeVersion(wanted, id) {
  if (!semver.satisfies(process.version, wanted)) {
    console.log(chalk.red(
      '你正在用的 node 版本是:' + process.version +
      '\n需要的版本:' + wanted + '\n请升级你的 node 版本.'
    ))
    process.exit(1)
  }
}
github vuejs / vue-cli / packages / @vue / cli / lib / Generator.js View on Github external
].some(id => {
      if (!matchesPluginId(_id, id)) {
        return false
      }

      if (!_version) {
        return true
      }

      const version = this.pm.getInstalledVersion(id)
      return semver.satisfies(version, _version)
    })
  }