Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.action((name, cmd) => {
const options = cleanArgs(cmd)
if (minimist(process.argv.slice(3))._.length > 1) {
console.log(chalk.yellow('\n Info: You provided more than one argument. The first one will be used as the app\'s name, the rest are ignored.'))
}
// --git makes commander to default git to true
if (process.argv.includes('-g') || process.argv.includes('--git')) {
options.forceGit = true
}
require('../lib/create')(name, options)
})
// legacy support for vuex
if (preset.vuex) {
preset.plugins['@vue/cli-plugin-vuex'] = {}
}
const packageManager = (
cliOptions.packageManager ||
loadOptions().packageManager ||
(hasYarn() ? 'yarn' : null) ||
(hasPnpm3OrLater() ? 'pnpm' : 'npm')
)
const pm = new PackageManager({ context, forcePackageManager: packageManager })
await clearConsole()
logWithSpinner(`✨`, `Creating project in ${chalk.yellow(context)}.`)
this.emit('creation', { event: 'creating' })
// get latest CLI version
const { current, latest } = await getVersions()
let latestMinor = `${semver.major(latest)}.${semver.minor(latest)}.0`
if (
// if the latest version contains breaking changes
/major/.test(semver.diff(current, latest)) ||
// or if using `next` branch of cli
(semver.gte(current, latest) && semver.prerelease(current))
) {
// fallback to the current cli version number
latestMinor = current
}
// generate package.json with plugin dependencies
let metadata = metadataCache.get(id)
if (metadata) {
return metadata
}
try {
metadata = await (new PackageManager({ context: cwd.get() })).getMetadata(id)
} catch (e) {
// No connection?
}
if (metadata) {
metadataCache.set(id, metadata)
return metadata
} else {
log('Dependencies', chalk.yellow(`Can't load metadata`), id)
}
}
if (!deps) return
let name
// official
if (deps[(name = `@vue/cli-plugin-${pluginName}`)]) {
return name
}
// full id, scoped short, or default short
if (deps[(name = resolvePluginId(pluginName))]) {
return name
}
}
const id = findPlugin(pkg.devDependencies) || findPlugin(pkg.dependencies)
if (!id) {
throw new Error(
`Cannot resolve plugin ${chalk.yellow(pluginName)} from package.json. ` +
`Did you forget to install it?`
)
}
const pluginGenerator = loadModule(`${id}/generator`, context)
if (!pluginGenerator) {
throw new Error(`Plugin ${id} does not have a generator.`)
}
// resolve options if no command line options (other than --registry) are passed,
// and the plugin contains a prompt module.
// eslint-disable-next-line prefer-const
let { registry, $inlineOptions, ...pluginOptions } = options
if ($inlineOptions) {
try {
pluginOptions = JSON.parse($inlineOptions)
.action((cmd) => {
program.outputHelp()
console.log(` ` + chalk.red(`Unknown command ${chalk.yellow(cmd)}.`))
console.log()
suggestCommands(cmd)
})
api.registerCommand('test:e2e', {
description: 'run end-to-end tests with nightwatch',
usage: 'vue-cli-service test:e2e [options]',
options: {
'--url': 'run end-to-end tests against given url instead of auto-starting dev server',
'--config': 'use custom nightwatch config file (overrides internals)',
'--headless': 'use chrome or firefox in headless mode',
'--parallel': 'enable parallel mode via test workers (only available in chromedriver)',
'--use-selenium': 'use Selenium standalone server instead of chromedriver or geckodriver',
'-e, --env': 'specify comma-delimited browser envs to run in (default: chrome)',
'-t, --test': 'specify a test to run by name',
'-f, --filter': 'glob to filter tests by filename'
},
details:
`All Nightwatch CLI options are also supported.\n` +
chalk.yellow(`https://nightwatchjs.org/guide/running-tests/#command-line-options`)
}, (args, rawArgs) => {
if (args.env && args.env.includes('firefox')) {
try {
require('geckodriver')
} catch (e) {
error(`To run e2e tests in Firefox, you need to install ${chalk.yellow.bold('geckodriver')} first.`)
process.exit(1)
}
}
if (installedBrowsers.chrome) {
const userVersion = installedBrowsers.chrome
const driverVersion = require('chromedriver').version
const userMajor = userVersion.match(/^(\d+)\./)[1]
const driverMajor = driverVersion.match(/^(\d+)\./)[1]
enhanceErrorMessages('optionMissingArgument', (option, flag) => {
return `Missing required argument for option ${chalk.yellow(option.flags)}` + (
flag ? `, got ${chalk.yellow(flag)}` : ``
)
})
async function addRouter (context) {
const options = await inquirer.prompt([{
name: 'routerHistoryMode',
type: 'confirm',
message: `Use history mode for router? ${chalk.yellow(`(Requires proper server setup for index fallback in production)`)}`
}])
invoke.runGenerator(context, {
id: 'core:router',
apply: loadModule('@vue/cli-service/generator/router', context),
options
})
}