Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
build(...args).catch(err => {
stopSpinner(false); // do not persist
error(err);
if (!process.env.VUE_CLI_TEST) {
process.exit(1);
}
});
async resolvePreset (name, clone) {
let preset
const savedPresets = loadOptions().presets || {}
if (name in savedPresets) {
preset = savedPresets[name]
} else if (name.endsWith('.json') || /^\./.test(name) || path.isAbsolute(name)) {
preset = await loadLocalPreset(path.resolve(name))
} else if (name.includes('/')) {
logWithSpinner(`Fetching remote preset ${chalk.cyan(name)}...`)
this.emit('creation', { event: 'fetch-remote-preset' })
try {
preset = await loadRemotePreset(name, clone)
stopSpinner()
} catch (e) {
stopSpinner()
error(`Failed fetching remote preset ${chalk.cyan(name)}:`)
throw e
}
}
// use default preset if user has not overwritten it
if (name === 'default' && !preset) {
preset = defaults.presets.default
}
if (!preset) {
error(`preset "${name}" not found.`)
const presets = Object.keys(savedPresets)
if (presets.length) {
log()
log(`available presets:\n${presets.join(`\n`)}`)
} else {
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', [
'ls-files',
'--exclude-standard',
'--modified',
'--others'
], {
cwd: context
})
if (stdout.trim()) {
log(` The following files have been updated / added:\n`)
webpack(webpackConfigs, (err, stats) => {
if (!runByHBuilderX && !runByAliIde) {
stopSpinner(false)
}
if (err) {
return reject(err)
}
if (stats.hasErrors()) {
/* eslint-disable prefer-promise-reject-errors */
return reject(`Build failed with errors.`)
}
if (!args.silent && process.env.UNI_PLATFORM !== 'app-plus') {
const targetDirShort = path.relative(
api.service.context,
process.env.UNI_OUTPUT_DIR
)
if (!isTestOrDebug && depsChanged) {
log(`π¦ Installing additional dependencies...`)
log()
const pm = new PackageManager({ context })
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(
if (!packagePath) {
throw new Error(
"Cannot found any file matches the RegExp '/^w(-?w?)*@(d.?){3}-?d{13}.tar(.gz)?$/'"
)
}
log()
log('upload package start...')
log()
await uploadCMD(args, path.join(dist, packagePath), moduleName)
log()
log('uploaded package successfully!')
log()
} catch (err) {
stopSpinner(false)
log(chalk.red(err))
throw err
}
}
)
webpack(api.resolveWebpackConfig(), (err, stats) => {
stopSpinner(false)
if (err) {
return reject(err)
}
if (stats.hasErrors()) {
return reject('Build failed with errors.')
}
if (!args.silent) {
const targetDirShort = path.relative(api.service.context, targetDir)
log(formatStats(stats, targetDirShort, api))
if (args.target === 'app' && !isLegacyBuild) {
if (!args.watch) {
done(
.on('error', (error) => {
stopSpinner(false)
log(chalk.red(`Publish module ${chalk.cyan(name)} failed`))
log(chalk.red(error))
reject(error)
})
.on('complete', (res, body) => {
Items: invalidationItems
}
}
}
try {
logWithSpinner(`Invalidating CloudFront distribution: ${this.config.options.cloudfrontId}`)
let data = await cloudfront.createInvalidation(params).promise()
info(`Invalidation ID: ${data['Invalidation']['Id']}`)
info(`Status: ${data['Invalidation']['Status']}`)
info(`Call Reference: ${data['Invalidation']['InvalidationBatch']['CallerReference']}`)
info(`See your AWS console for on-going status on this invalidation.`)
stopSpinner()
} catch (err) {
stopSpinner(false)
error('Cloudfront Error!!')
error(`Code: ${err.code}`)
error(`Message: ${err.message}`)
error(`AWS Request ID: ${err.requestId}`)
throw new Error('Cloudfront invalidation failed!')
}
}
}