Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await generator.generate({
extractConfigFiles: true,
checkExisting: true
})
const newDeps = generator.pkg.dependencies
const newDevDeps = generator.pkg.devDependencies
const depsChanged =
JSON.stringify(newDeps) !== JSON.stringify(pkg.dependencies) ||
JSON.stringify(newDevDeps) !== JSON.stringify(pkg.devDependencies)
if (!isTestOrDebug && depsChanged) {
log(`π¦ Installing additional dependencies...`)
log()
const packageManager =
loadOptions().packageManager || (hasProjectYarn(context) ? 'yarn' : 'npm')
await installDeps(context, packageManager, plugin.options && plugin.options.registry)
}
if (createCompleteCbs.length) {
logWithSpinner('β', `Running completion hooks...`)
for (const cb of createCompleteCbs) {
await cb()
}
stopSpinner()
log()
}
log(`${chalk.green('β')} Successfully invoked generator for plugin: ${chalk.cyan(plugin.id)}`)
// εεΊεͺδΊζδ»ΆεηδΊζΉε
if (!process.env.VUE_CLI_TEST && hasProjectGit(context)) {
const { stdout } = await execa('git', [
console.log(chalk.yellow(` Since you are using a non-root baseUrl, the hot-reload socket`))
console.log(chalk.yellow(` will not be able to infer the correct URL to connect. You should`))
console.log(chalk.yellow(` explicitly specify the URL via ${chalk.blue(`devServer.public`)}.`))
console.log()
}
console.log(chalk.yellow(` Access the dev server via ${chalk.cyan(
`${protocol}://localhost:${options.baseUrl}`
)}`))
}
console.log()
if (isFirstCompile) {
isFirstCompile = false
if (!isProduction) {
const buildCommand = hasProjectYarn(api.getCwd()) ? `yarn build` : `npm run build`
console.log(` Note that the development build is not optimized.`)
console.log(` To create a production build, run ${chalk.cyan(buildCommand)}.`)
} else {
console.log(` App is served in production mode.`)
console.log(` Note this is for preview or E2E testing only.`)
}
console.log()
if (args.open || projectDevServerOptions.open) {
const pageUri = (projectDevServerOptions.openPage && typeof projectDevServerOptions.openPage === 'string')
? projectDevServerOptions.openPage
: ''
openBrowser(urls.localUrlForBrowser + pageUri)
}
// Send final app URL
console.log(chalk.yellow(` Since you are using a non-root publicPath, the hot-reload socket`))
console.log(chalk.yellow(` will not be able to infer the correct URL to connect. You should`))
console.log(chalk.yellow(` explicitly specify the URL via ${chalk.blue(`devServer.public`)}.`))
console.log()
}
console.log(chalk.yellow(` Access the dev server via ${chalk.cyan(
`${protocol}://localhost:${options.publicPath}`
)}`))
}
console.log()
if (isFirstCompile) {
isFirstCompile = false
if (!isProduction) {
const buildCommand = hasProjectYarn(api.getCwd()) ? `yarn build` : hasProjectPnpm(api.getCwd()) ? `pnpm run build` : `npm run build`
console.log(` Note that the development build is not optimized.`)
console.log(` To create a production build, run ${chalk.cyan(buildCommand)}.`)
} else {
console.log(` App is served in production mode.`)
console.log(` Note this is for preview or E2E testing only.`)
}
console.log()
if (args.open || projectDevServerOptions.open) {
const pageUri = (projectDevServerOptions.openPage && typeof projectDevServerOptions.openPage === 'string')
? projectDevServerOptions.openPage
: ''
openBrowser(localUrlForBrowser + pageUri)
}
// Send final app URL
exports.auditProject = async function (cwd) {
try {
if (hasProjectYarn(cwd)) {
const child = await execa('yarn', [
'audit',
'--json',
'--non-interactive',
'--no-progress'
], {
cwd,
reject: false
})
if (child.stderr) {
const errLines = child.stderr.split('\n').map(l => l.trim()).filter(l => l)
const error = errLines.find(l => l.startsWith('Error:'))
if (error) {
throw new Error(error.substr('Error:'.length).trim())
}
function updateScriptDescription(options) {
const hasYarn = hasProjectYarn(process.cwd())
const packageManager = hasYarn ? 'yarn' : 'npm'
let scriptDescription = ''
for (var option in options) {
if (!options[option]) {
continue;
}
let scripts = descriptions[option]
scriptDescription += Object.keys(scripts).map(key => {
return [
`\n### ${scripts[key]}`,
'```',
`${packageManager} run ${key}`,
'```',
''
].join('\n')
function getCommand (cwd) {
if (!cwd) {
return loadOptions().packageManager || (hasYarn() ? 'yarn' : hasPnpm3OrLater() ? 'pnpm' : 'npm')
}
return hasProjectYarn(cwd) ? 'yarn' : hasProjectPnpm(cwd) ? 'pnpm' : 'npm'
}
exports.getCommand = function (cwd = undefined) {
if (!cwd) {
return loadOptions().packageManager || (hasYarn() ? 'yarn' : hasPnpm3OrLater() ? 'pnpm' : 'npm')
}
return hasProjectYarn(cwd) ? 'yarn' : hasProjectPnpm(cwd) ? 'pnpm' : 'npm'
}
constructor ({ context, forcePackageManager } = {}) {
this.context = context
if (forcePackageManager) {
this.bin = forcePackageManager
} else if (context) {
this.bin = hasProjectYarn(context) ? 'yarn' : hasProjectPnpm(context) ? 'pnpm' : 'npm'
} else {
this.bin = loadOptions().packageManager || (hasYarn() ? 'yarn' : hasPnpm3OrLater() ? 'pnpm' : 'npm')
}
if (!SUPPORTED_PACKAGE_MANAGERS.includes(this.bin)) {
log()
warn(
`The package manager ${chalk.red(this.bin)} is ${chalk.red('not officially supported')}.\n` +
`It will be treated like ${chalk.cyan('npm')}, but compatibility issues may occur.\n` +
`See if you can use ${chalk.cyan('--registry')} instead.`
)
PACKAGE_MANAGER_CONFIG[this.bin] = PACKAGE_MANAGER_CONFIG.npm
}
}