Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
({ stats, previousFileSizes, warnings }) => {
if (warnings.length) {
console.log(chalk.yellow('Compiled with warnings.\n'));
console.log(warnings.join('\n\n'));
console.log(
'\nSearch for the ' +
chalk.underline(chalk.yellow('keywords')) +
' to learn more about each warning.'
);
console.log(
'To ignore, add ' +
chalk.cyan('// eslint-disable-next-line') +
' to the line before.\n'
);
} else {
console.log(chalk.green('Compiled successfully.\n'));
}
console.log('File sizes after gzip:\n');
printFileSizesAfterBuild(
stats,
previousFileSizes,
paths.appBuild,
( { stats, previousFileSizes, warnings } ) => {
if ( warnings.length ) {
console.log( chalk.yellow( 'Compiled with warnings.\n' ) );
console.log( warnings.join( '\n\n' ) );
console.log(
'\nSearch for the ' +
chalk.underline( chalk.yellow( 'keywords' ) ) +
' to learn more about each warning.'
);
console.log(
'To ignore, add ' +
chalk.cyan( '// eslint-disable-next-line' ) +
' to the line before.\n'
);
} else {
console.log( chalk.green( 'Compiled successfully.\n' ) );
}
console.log( 'File sizes after gzip:\n' );
printFileSizesAfterBuild(
stats,
previousFileSizes,
paths.appBuild,
({ stats, previousFileSizes, warnings }) => {
if (warnings.length) {
console.log(chalk.yellow('Compiled with warnings.\n'));
console.log(warnings.join('\n\n'));
console.log(
'\nSearch for the ' +
chalk.underline(chalk.yellow('keywords')) +
' to learn more about each warning.'
);
console.log(
'To ignore, add ' +
chalk.cyan('// eslint-disable-next-line') +
' to the line before.\n'
);
} else {
console.log(chalk.green('Compiled successfully.\n'));
}
console.log('File sizes after gzip:\n');
printFileSizesAfterBuild(
stats,
previousFileSizes,
paths.appBuild,
Object.keys(exports).forEach((name) => {
// If the same dependency is in the project we want to warn the user
if (allDependencies[name]) {
matches.push({
name,
...exports[name],
});
}
});
if (matches.length) {
log.warn(
`You have some dependencies in your package.json that also have been exported by extensions. This is probably a mistake.
${underline('Roc will prioritize the ones exported by the extensions.')}
You can override this by adding "#" to the start of the require/import in the code, see documentation for more info.
Dependencies that is both exported and in the projects package.json:
${matches.map((match) => `- ${bold(match.name)} ${dim('from')} ` +
`${bold(match.extension)} ${dim('with version')} ${bold(match.version)}`).join('\n')}`,
'Dependencies'
);
}
}
.then(function(role) {
// Create or update the Lambda function
const task = `Creating lambda functions: ${chalk.underline(config.tools.resources.apiGateway)}, ${chalk.underline(config.tools.resources.lambdaVersion)}`;
return logger.task(task, function(resolve, reject) {
// Bundle the Lambda function code
const apiLambdaPath = path.resolve(__dirname, '../cf-resources/api-gateway-resource/index.js');
const versionLambdaPath = path.resolve(__dirname, '../cf-resources/lambda-version-resource/index.js');
const context = {
directories: {
cwd: process.cwd(),
root: path.join(path.resolve(__dirname), '../deploy'),
staging: path.resolve(os.tmpdir(), 'lambda-tools-single-tools-setup')
},
lambdas: [
{
name: config.tools.resources.apiGateway,
module: 'index',
function convert(value, mapping) {
const val = mapping.converter(value);
const validationResult = isValid(val, mapping.validator);
if (validationResult === true) {
return val;
}
// Make sure that we got something from the conversion.
const message = val !== undefined && val !== null && val.toString().length > 0 ?
`Received ${underline(JSON.stringify(value))} and it was converted to ` +
`${underline(JSON.stringify(val))}. ` :
'';
log.warn(
`There was a problem when trying to automatically convert ${bold(mapping.name)}. This ` +
`value will be ignored.\n\n` +
message + validationResult,
'Conversion Problem'
);
return undefined;
}
process.on('uncaughtException', err => {
if (err.code === 'EADDRINUSE') {
console.error(chalk.bold.red(
`You have another server running at port ${config.serverPort} somewhere, shut it down first`
));
console.log();
console.log('You can change the port using the `serverPort` option in your dvhb.config.js:');
console.log(chalk.underline(consts.DOCS_CONFIG));
}
else {
console.error(chalk.bold.red(err.message));
}
process.exit(1);
});
}
console.log(`${chalk.gray('github')} ${command.command}`)
if (command.aliases) {
for (const alias of command.aliases) {
console.log(chalk.gray(`github ${alias}`))
}
}
console.log()
const [title, body] = command.description.split('\n', 1)
console.log(chalk.bold(title))
if (body) {
console.log(body)
}
const { options, args } = command
if (options) {
console.log(chalk.underline('\nOptions:'))
printTable(
Object.keys(options)
.map(k => [k, options[k]] as [string, IOption])
.map(([optionName, option]) => [
[optionName, ...(option.aliases || [])]
.map(dasherizeOption)
.map(x => chalk.bold.blue(x))
.join(chalk.gray(', ')),
option.description,
chalk.gray(`[${chalk.underline(option.type)}]`),
])
)
}
if (args && args.length) {
console.log(chalk.underline('\nArguments:'))
printTable(
_.each(urls, function(url) {
console.log(' ' + chalk.underline(url));
});
console.log();