Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exit(message) {
if (message && !argv['completion-logic']) {
const { terminal } = require('@absolunet/terminal');
terminal.exit(message);
} else {
process.exit(); // eslint-disable-line no-process-exit, unicorn/no-process-exit
}
}
if (scopedMatch !== null) {
normalizedName = `${scopedMatch[1]}${prefix}${scopedMatch[2]}`;
} else {
const namedMatch = (/^[a-z0-9-]+$/u).exec(name);
if (namedMatch !== null) {
normalizedName = `${prefix}${name}`;
} else {
normalizedName = name;
}
}
let extension;
try {
extension = require(normalizedName); // eslint-disable-line global-require
} catch (error) {
terminal.exit(`Extension '${name}' not found`);
}
extension.init({ options: CONFIG.extensions[name].options });
enabled[extension.id] = extension;
}
});
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();
}
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`);
}
}
initCli(globalUsage) {
terminal.setDefault({
logo: env.logo,
color: 'cyan',
lang: 'en'
});
cli.init({
pkg: { name: env.id, bin: { [env.id]: '' } } // eslint-disable-line unicorn/prevent-abbreviations
});
cli.initTasksList(paths.workflow.cliTasks);
const tasks = ['assets', 'icons', 'local', 'scripts', 'styles'];
const installScopes = ['workflow', 'vendors'];
async cli(meowCli) {
cli.refuseArguments(meowCli);
const { verbose: flagVerbose } = cli.validateFlags(meowCli, {
verbose: ow.boolean
});
verbose = flagVerbose;
terminal.spacer();
const spinner = terminal.startSpinner(`Diagnosing ${chalk.cyan(env.packageConfig.name)}...`);
//-- Load here to speed up spinner first display
/* eslint-disable global-require */
const pluralize = require('pluralize');
const fss = require('@absolunet/fss');
const paths = require('~/helpers/paths');
const tester = require('~/helpers/doctor/tester');
/* eslint-enable global-require */
const [general, root, bundles, components, workflow, vendors, sync] = await Promise.all([
tester.general(),
tester.root(),
tester.bundles(),
tester.components(),
module.exports = ({ cliPkg, cliPath, cliUsage }) => {
//-- Initialize
util.initCli(cliUsage);
//-- Don't you dare sudo me
if (cli.isRoot()) {
terminal.dontSudoMe();
//-- Initialize CLI
} else {
const cliBin = ` cli${chalk.yellow('@')}${cliPkg.version} ${cliPath}`;
const workflowBin = `workflow${chalk.yellow('@')}${env.workflowConfig.version} ${paths.workflow.root}`;
cli.tasksRouter(meow({
pkg: cliPkg, // eslint-disable-line unicorn/prevent-abbreviations
description: `${env.logo} ${env.workflowConfig.definition}`,
help: `${cli.fullUsage}\n${cliBin}\n${workflowBin}`
}));
}
};
async cli(meowCli) {
cli.refuseArguments(meowCli);
const { verbose: flagVerbose } = cli.validateFlags(meowCli, {
verbose: ow.boolean
});
verbose = flagVerbose;
terminal.spacer();
const spinner = terminal.startSpinner(`Diagnosing ${chalk.cyan(env.packageConfig.name)}...`);
//-- Load here to speed up spinner first display
/* eslint-disable global-require */
const pluralize = require('pluralize');
const fss = require('@absolunet/fss');
const paths = require('~/helpers/paths');
const tester = require('~/helpers/doctor/tester');
/* eslint-enable global-require */
const [general, root, bundles, components, workflow, vendors, sync] = await Promise.all([
tester.general(),
tester.root(),
tester.bundles(),
tester.components(),
tester.workflowUpdates(),
error(error) {
terminal.error(`[nwayo-extension:${this.id} error]`);
terminal.echo(error);
terminal.exit();
}