Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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')) ||
#!/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',
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 })
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
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)
}
}
function checkNodeVersion(wanted, id) {
if (!semver.satisfies(process.version, wanted)) {
console.log(chalk.red(
'你正在用的 node 版本是:' + process.version +
'\n需要的版本:' + wanted + '\n请升级你的 node 版本.'
))
process.exit(1)
}
}
].some(id => {
if (!matchesPluginId(_id, id)) {
return false
}
if (!_version) {
return true
}
const version = this.pm.getInstalledVersion(id)
return semver.satisfies(version, _version)
})
}