Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
} else if (paths.length === 1) {
res = get(config, paths[0])
} else {
res = config
}
const output = toString(res, { verbose })
console.log(highlight(output, { language: 'js' }))
// Log explanation for Nameless Rules
if (hasUnnamedRule) {
console.log(`--- ${chalk.green('Footnotes')} ---`)
console.log(`*: ${chalk.green(
'Nameless Rules'
)} were added through the ${chalk.green(
'configureWebpack()'
)} API (possibly by a plugin) instead of ${chalk.green(
'chainWebpack()'
)} (recommended).
You can run ${chalk.green(
'vue-cli-service inspect'
)} without any arguments to inspect the full config and read these rules' config.`)
}
}
)
}
const output = toString(res, { verbose })
console.log(highlight(output, { language: 'js' }))
// Log explanation for Nameless Rules
if (hasUnnamedRule) {
console.log(`--- ${chalk.green('Footnotes')} ---`)
console.log(`*: ${chalk.green(
'Nameless Rules'
)} were added through the ${chalk.green(
'configureWebpack()'
)} API (possibly by a plugin) instead of ${chalk.green(
'chainWebpack()'
)} (recommended).
You can run ${chalk.green(
'vue-cli-service inspect'
)} without any arguments to inspect the full config and read these rules' config.`)
}
}
)
paths.forEach(path => {
res[path] = get(config, path)
})
} else if (paths.length === 1) {
res = get(config, paths[0])
} else {
res = config
}
const output = toString(res, { verbose })
console.log(highlight(output, { language: 'js' }))
// Log explanation for Nameless Rules
if (hasUnnamedRule) {
console.log(`--- ${chalk.green('Footnotes')} ---`)
console.log(`*: ${chalk.green(
'Nameless Rules'
)} were added through the ${chalk.green(
'configureWebpack()'
)} API (possibly by a plugin) instead of ${chalk.green(
'chainWebpack()'
)} (recommended).
You can run ${chalk.green(
'vue-cli-service inspect'
)} without any arguments to inspect the full config and read these rules' config.`)
}
}
)
res = {}
paths.forEach(path => {
res[path] = get(config, path)
})
} else if (paths.length === 1) {
res = get(config, paths[0])
} else {
res = config
}
const output = toString(res, { verbose })
console.log(highlight(output, { language: 'js' }))
// Log explanation for Nameless Rules
if (hasUnnamedRule) {
console.log(`--- ${chalk.green('Footnotes')} ---`)
console.log(`*: ${chalk.green(
'Nameless Rules'
)} were added through the ${chalk.green(
'configureWebpack()'
)} API (possibly by a plugin) instead of ${chalk.green(
'chainWebpack()'
)} (recommended).
You can run ${chalk.green(
'vue-cli-service inspect'
)} without any arguments to inspect the full config and read these rules' config.`)
}
}
)
const entry = exports.checkExistEntries(api, [
portalEntry,
'./src/router/routes.js',
'./src/routes.js',
mainEntry
]) /* 否则,使用 路由 文件 */
/* 如果是产品环境 build,且未匹配到指定的 entry 文件 */
if (!isDev && !entry) {
log(
`[${PLUGIN_NAME}] we expect default entries like following ${JSON.stringify(
entry
)},
also support entry customization by 'vue.config.js => entry' property but
it must be ${chalk.bgWhite(chalk.yellow('pure'))} & ${chalk.bgWhite(
chalk.green('no any side effects')
)}.`
)
}
return entry
}
await pm.install()
}
if (afterInvokeCbs.length || afterAnyInvokeCbs.length) {
logWithSpinner('⚓', `Running completion hooks...`)
for (const cb of afterInvokeCbs) {
await cb()
}
for (const cb of afterAnyInvokeCbs) {
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', [
'ls-files',
'--exclude-standard',
'--modified',
'--others'
], {
cwd: context
})
if (stdout.trim()) {
log(` The following files have been updated / added:\n`)
log(
chalk.red(
stdout
.split(/\r?\n/g)
.map(line => ` ${line}`)
`\n Commands:\n`
)
const commands = api.service.commands
const padLength = getPadLength(commands)
for (const name in commands) {
if (name !== 'help') {
const opts = commands[name].opts || {}
console.log(` ${
chalk.blue(name.padEnd(padLength))
}${
opts.description || ''
}`)
}
}
console.log(`\n run ${
chalk.green(`vue-cli-service help [command]`)
} for usage of a specific command.\n`)
}
let hasChainWebpackOption = false;
const vueConfig = api.resolve('vue.config.js');
if (fs.existsSync(vueConfig)) {
let projectOptions = require(vueConfig);
if (projectOptions.chainWebpack) {
hasChainWebpackOption = true;
}
}
if (hasChainWebpackOption) {
const {chalk} = require('@vue/cli-shared-utils');
const message = `Please add the following config to your ${chalk.cyan('chainWebpack')} method:` +
'\n\n' +
chalk.green(`config.module.rule('svg-sprite').use('svgo-loader').loader('svgo-loader');`);
api.exitLog(message, 'info');
} else {
api.extendPackage({
vue: {
chainWebpack,
},
});
}
}
};
const packageName = resolvePluginId(pluginName)
log()
log(`📦 Installing ${chalk.cyan(packageName)}...`)
log()
const pm = new PackageManager({ context })
const cliVersion = require('../package.json').version
if (isOfficialPlugin(packageName) && semver.prerelease(cliVersion)) {
await pm.add(`${packageName}@^${cliVersion}`)
} else {
await pm.add(packageName)
}
log(`${chalk.green('✔')} Successfully installed plugin: ${chalk.cyan(packageName)}`)
log()
const generatorPath = resolveModule(`${packageName}/generator`, context)
if (generatorPath) {
invoke(pluginName, options, context)
} else {
log(`Plugin ${packageName} does not have a generator to invoke`)
}
}
if (process.env.VUE_CLI_TEST) {
title += ' ' + chalk.blue.bold('TEST')
}
if (process.env.VUE_CLI_DEBUG) {
title += ' ' + chalk.magenta.bold('DEBUG')
}
if (error) {
title += '\n' + chalk.red('Failed to check for updates')
}
if (checkUpdate && !error && semver.gt(latest, current)) {
if (process.env.VUE_CLI_API_MODE) {
title += chalk.green(` 🌟️ New version available: ${latest}`)
} else {
let upgradeMessage = `New version available ${chalk.magenta(current)} → ${chalk.green(latest)}`
try {
const command = await getInstallationCommand()
let name = require('../../package.json').name
if (semver.prerelease(latest)) {
name += '@next'
}
if (command) {
upgradeMessage +=
`\nRun ${chalk.yellow(`${command} ${name}`)} to update!`
}
} catch (e) {}
const upgradeBox = require('boxen')(upgradeMessage, {
align: 'center',