Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
env.initWorkflow({ bundle });
//-- Load tasks
/* eslint-disable global-require */
process.stdout.write(`\n${env.logo} Gathering intel... `);
const gulp = require('gulp'); // gulp.js is really heavy on load
if (extension) {
extension.requireTask(taskName);
} else {
require(taskFile)();
}
terminal.echo(chalk.green(`\r${env.logo} Ready to roll `));
/* eslint-enable global-require */
//-- Run task
if (gulp.task(task)) {
terminal.spacer();
gulp.series(task)();
} else {
terminal.exit(`Task ${chalk.underline(task)} does not exists`);
}
}
checkInstalledWorkflow() {
// Check for asked version vs installed version
const requiredVersion = env.packageConfig.dependencies[env.packageName];
const installedVersion = env.workflowConfig.version;
if (semver.gt(requiredVersion, installedVersion)) {
terminal.echo(boxen(
`Workflow update available ${chalk.dim(installedVersion)} ${chalk.reset('→')} ${chalk.green(requiredVersion)}
The required version in your project's package.json
is greater than the installed one
Run ${chalk.cyan('nwayo install workflow')} to update`,
{
padding: 1,
margin: 0.5,
align: 'center',
borderColor: 'yellow'
}
));
terminal.exit();
}
return plumber((error) => {
terminal.spacer(2);
terminal.echo(`${emoji.get('monkey')} ${error.toString()}`);
terminal.exit();
});
}
const logGuard = (action, name, file) => {
switch (action) {
case START:
return `${emoji.get('guardsman')} Guard n°${__.totalGuards + 1} standing guard...`;
case ALERT:
return terminal.echo(`${emoji.get('mega')} Guard n°${__.totalGuards} alerted by ${chalk.magenta(file.split(`${paths.directory.root}/`)[1])} calling ${chalk.cyan(name)}`);
case END:
return terminal.echo(`${emoji.get('zzz')} Guard n°${__.activeGuards[name]} duty is completed ${chalk.cyan.dim(`(${name})`)}${
__.ignoredChanges[name] ? chalk.yellow(` ⚠ ${pluralize('change', __.ignoredChanges[name], true)} ${__.ignoredChanges[name] === 1 ? 'was' : 'were'} ignored`) : ''
}\n`);
default: return undefined;
}
};
error(error) {
terminal.error(`[nwayo-extension:${this.id} error]`);
terminal.echo(error);
terminal.exit();
}
//-- Reports
reporter('General', general);
reporter('Root strucure', root);
reporter('Bundles', bundles);
reporter('Components', components);
reporter('Workflow', workflow);
reporter('Vendors', vendors);
reporter('Sync between workflow and toolbox', sync);
//-- Totals
terminal.spacer(2);
if (totals.success) {
terminal.echo(chalk.green(`${pluralize('test', totals.success, true)} passed`));
}
if (totals.failure) {
terminal.echo(chalk.red(`${pluralize('test', totals.failure, true)} failed`));
}
terminal.spacer();
//-- Reward
if (totals.failure === 0) {
const reward = fss.readFile(`${paths.workflow.ressources}/doctor-reward`, 'utf8');
const pink = chalk.hex('#ff69b4');
const green = chalk.hex('#198c19');
terminal.echo(reward
reporter('Bundles', bundles);
reporter('Components', components);
reporter('Workflow', workflow);
reporter('Vendors', vendors);
reporter('Sync between workflow and toolbox', sync);
//-- Totals
terminal.spacer(2);
if (totals.success) {
terminal.echo(chalk.green(`${pluralize('test', totals.success, true)} passed`));
}
if (totals.failure) {
terminal.echo(chalk.red(`${pluralize('test', totals.failure, true)} failed`));
}
terminal.spacer();
//-- Reward
if (totals.failure === 0) {
const reward = fss.readFile(`${paths.workflow.ressources}/doctor-reward`, 'utf8');
const pink = chalk.hex('#ff69b4');
const green = chalk.hex('#198c19');
terminal.echo(reward
.replace(/_.--._/ug, `_${pink('.--.')}_`)
.replace(/`--'/ug, pink('`--\''))
.replace(/\(\)/ug, pink('()'))
.replace(/.==./ug, green('.==.')))
const reporter = (title, reports) => {
let success;
const titleColor = reports.summary.success ? chalk.green : chalk.red;
terminal.echo(`${chalk.cyan(title)} diagnosis ${titleColor(`${reports.summary.success ? '(^_^)' : 'ಠ_ಠ'} ${reports.summary.nb ? ` [${reports.summary.nb.success}/${reports.summary.nb.total}]` : ''}`)}\n`);
totals.success += reports.summary.nb.success;
totals.failure += reports.summary.nb.failure;
if (reports.summary.success && !verbose) {
terminal.echoIndent(chalk.green(`${figures.tick} ${reports.summary.nb.total === 1 ? reports.last.message : 'All tests passed'}`));
} else {
reports.list.forEach((test) => {
if (test.success && verbose) {
terminal.echoIndent(`${chalk.green(figures.tick)} ${chalk.dim(test.message)}`);
} else if (!test.success) {
let extra = '';
if (test.differences) {
}
if (totals.failure) {
terminal.echo(chalk.red(`${pluralize('test', totals.failure, true)} failed`));
}
terminal.spacer();
//-- Reward
if (totals.failure === 0) {
const reward = fss.readFile(`${paths.workflow.ressources}/doctor-reward`, 'utf8');
const pink = chalk.hex('#ff69b4');
const green = chalk.hex('#198c19');
terminal.echo(reward
.replace(/_.--._/ug, `_${pink('.--.')}_`)
.replace(/`--'/ug, pink('`--\''))
.replace(/\(\)/ug, pink('()'))
.replace(/.==./ug, green('.==.')))
;
terminal.spacer();
}
}