Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 {
log(`you don't seem to have any saved preset.`)
log(`run vue-cli in manual mode to create a preset.`)
}
exit(1)
}
return preset
}
}
fs.writeFileSync(
path.join(bundleOutputDir, `legacy-assets-${page}.html.json`),
'[]'
)
})
// Set the base url so that the app protocol is used
options.baseUrl = pluginOptions.customFileProtocol || 'app://./'
// Set publicPath as well (replaced baseUrl since @vue/cli 3.3.0)
options.publicPath = pluginOptions.customFileProtocol || 'app://./'
info('Bundling render process:')
// Build the render process with the custom args
try {
await api.service.run('build', vueArgs)
} catch (e) {
error(
'Vue CLI build failed. Please resolve any issues with your build and try again.'
)
process.exit(1)
}
// Copy package.json to output dir
const pkg = JSON.parse(
fs.readFileSync(api.resolve('./package.json'), 'utf8')
)
const externals = getExternals(api, pluginOptions)
// https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/223
// Strip non-externals from dependencies so they won't be copied into app.asar
Object.keys(pkg.dependencies).forEach(dependency => {
if (!Object.keys(externals).includes(dependency)) {
delete pkg.dependencies[dependency]
}
})
async function createBucket (options) {
let createParams = {
Bucket: options.bucket,
ACL: options.acl
}
// Create bucket
try {
await S3.createBucket(createParams).promise()
} catch (createErr) {
error(`Bucket: ${options.bucket} could not be created. AWS Error: ${createErr.toString()}.`)
return false
}
info(`Bucket: ${options.bucket} created.`)
return true
}
Suffix: options.staticIndexPage
}
}
}
// use custom WebsiteConfiguration if set
if (options.staticWebsiteConfiguration) {
staticParams.WebsiteConfiguration = options.staticWebsiteConfiguration
}
// enable static hosting
try {
await S3.putBucketWebsite(staticParams).promise()
info(`Static Hosting is enabled.`)
} catch (staticErr) {
error(`Static Hosting could not be enabled on bucket: ${options.bucket}. AWS Error: ${staticErr.toString()}.`)
}
}
const load = path => {
try {
const res = loadEnv(path)
logger(path, res)
} catch (err) {
// only ignore error if file is not found
if (err.toString().indexOf('ENOENT') < 0) {
error(err)
}
}
}
return upgrade(...args).catch(err => {
error(err)
if (!process.env.VUE_CLI_TEST) {
process.exit(1)
}
})
}
module.exports = function inspect (paths, args) {
const cwd = process.cwd()
let servicePath
try {
servicePath = resolve.sync('@vue/cli-service', { basedir: cwd })
} catch (e) {
const { error } = require('@vue/cli-shared-utils')
error(
`Failed to locate @vue/cli-service.\n` +
`Note that \`vue inspect\` is an alias of \`vue-cli-service inspect\`\n` +
`and can only be used in a project where @vue/cli-service is locally installed.`
)
process.exit(1)
}
const binPath = path.resolve(servicePath, '../../bin/vue-cli-service.js')
if (fs.existsSync(binPath)) {
execa('node', [
binPath,
'inspect',
...(args.mode ? ['--mode', args.mode] : []),
...(args.rule ? ['--rule', args.rule] : []),
...(args.plugin ? ['--plugin', args.plugin] : []),
...(args.rules ? ['--rules'] : []),
...(args.plugins ? ['--plugins'] : []),
return add(...args).catch(err => {
error(err)
if (!process.env.VUE_CLI_TEST) {
process.exit(1)
}
})
}
return configure(...args).catch(err => {
error(err)
if (!process.env.VUE_CLI_TEST) {
process.exit(1)
}
})
}
IndexDocument: {
Suffix: this.options.staticIndexPage
}
}
}
if (this.options.staticWebsiteConfiguration) {
params.WebsiteConfiguration = this.options.staticWebsiteConfiguration
}
try {
logWithSpinner('Bucket: enabling static hosting...')
await this.connection.putBucketWebsite(params).promise()
stopSpinner()
} catch (e) {
error(`Static hosting could not be enabled on bucket: ${this.name}`)
throw new Error(`AWS Error: ${e.toString()}`)
}
}