Skip to content

Commit

Permalink
Merge 00ee4e0 into b37e382
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Aug 25, 2017
2 parents b37e382 + 00ee4e0 commit d9c5b59
Show file tree
Hide file tree
Showing 30 changed files with 217 additions and 169 deletions.
26 changes: 13 additions & 13 deletions index.js
Expand Up @@ -3,13 +3,13 @@
var fs = require('fs');
var path = require('path');
var log = require('gulplog');
var chalk = require('chalk');
var yargs = require('yargs');
var Liftoff = require('liftoff');
var tildify = require('tildify');
var interpret = require('interpret');
var v8flags = require('v8flags');
var findRange = require('semver-greatest-satisfied-range');
var ansi = require('./lib/shared/ansi');
var exit = require('./lib/shared/exit');
var cliOptions = require('./lib/shared/cliOptions');
var completion = require('./lib/shared/completion');
Expand Down Expand Up @@ -53,8 +53,8 @@ var cli = new Liftoff({
});

var usage =
'\n' + chalk.bold('Usage:') +
' gulp ' + chalk.blue('[options]') + ' tasks';
'\n' + ansi.bold('Usage:') +
' gulp ' + ansi.blue('[options]') + ' tasks';

var parser = yargs.usage(usage, cliOptions);
var opts = parser.argv;
Expand All @@ -63,16 +63,16 @@ var opts = parser.argv;
toConsole(log, opts);

cli.on('require', function(name) {
log.info('Requiring external module', chalk.magenta(name));
log.info('Requiring external module', ansi.magenta(name));
});

cli.on('requireFail', function(name) {
log.error(chalk.red('Failed to load external module'), chalk.magenta(name));
log.error(ansi.red('Failed to load external module'), ansi.magenta(name));
});

cli.on('respawn', function(flags, child) {
var nodeFlags = chalk.magenta(flags.join(', '));
var pid = chalk.magenta(child.pid);
var nodeFlags = ansi.magenta(flags.join(', '));
var pid = ansi.magenta(child.pid);
log.info('Node flags detected:', nodeFlags);
log.info('Respawned to PID:', pid);
});
Expand Down Expand Up @@ -138,15 +138,15 @@ function handleArguments(env) {

if (!env.modulePath) {
log.error(
chalk.red('Local gulp not found in'),
chalk.magenta(tildify(env.cwd))
ansi.red('Local gulp not found in'),
ansi.magenta(tildify(env.cwd))
);
log.error(chalk.red('Try running: npm install gulp'));
log.error(ansi.red('Try running: npm install gulp'));
exit(1);
}

if (!env.configPath) {
log.error(chalk.red('No gulpfile found'));
log.error(ansi.red('No gulpfile found'));
exit(1);
}

Expand All @@ -156,7 +156,7 @@ function handleArguments(env) {
process.chdir(env.cwd);
log.info(
'Working directory changed to',
chalk.magenta(tildify(env.cwd))
ansi.magenta(tildify(env.cwd))
);
}

Expand All @@ -165,7 +165,7 @@ function handleArguments(env) {

if (!range) {
return log.error(
chalk.red('Unsupported gulp version', env.modulePackage.version)
ansi.red('Unsupported gulp version', env.modulePackage.version)
);
}

Expand Down
26 changes: 26 additions & 0 deletions lib/shared/ansi.js
@@ -0,0 +1,26 @@
'use strict';

var red = require('ansi-red');
var green = require('ansi-green');
var blue = require('ansi-blue');
var magenta = require('ansi-magenta');
var cyan = require('ansi-cyan');
var white = require('ansi-white');
var gray = require('ansi-gray');
var bgred = require('ansi-bgred');
var bold = require('ansi-bold');
var strip = require('strip-color');

module.exports = {
red: red,
green: green,
blue: blue,
magenta: magenta,
cyan: cyan,
white: white,
gray: gray,
bgred: bgred,
bold: bold,
strip: strip,
};

36 changes: 18 additions & 18 deletions lib/shared/cliOptions.js
@@ -1,109 +1,109 @@
'use strict';

var chalk = require('chalk');
var ansi = require('./ansi');

module.exports = {
help: {
alias: 'h',
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Show this help.'),
},
version: {
alias: 'v',
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Print the global and local gulp versions.'),
},
require: {
type: 'string',
requiresArg: true,
desc: chalk.gray(
desc: ansi.gray(
'Will require a module before running the gulpfile. ' +
'This is useful for transpilers but also has other applications.'),
},
gulpfile: {
type: 'string',
requiresArg: true,
desc: chalk.gray(
desc: ansi.gray(
'Manually set path of gulpfile. Useful if you have multiple gulpfiles. ' +
'This will set the CWD to the gulpfile directory as well.'),
},
cwd: {
type: 'string',
requiresArg: true,
desc: chalk.gray(
desc: ansi.gray(
'Manually set the CWD. The search for the gulpfile, ' +
'as well as the relativity of all requires will be from here.'),
},
verify: {
desc: chalk.gray(
desc: ansi.gray(
'Will verify plugins referenced in project\'s package.json against ' +
'the plugins blacklist.'),
},
tasks: {
alias: 'T',
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Print the task dependency tree for the loaded gulpfile.'),
},
'tasks-simple': {
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Print a plaintext list of tasks for the loaded gulpfile.'),
},
'tasks-json': {
desc: chalk.gray(
desc: ansi.gray(
'Print the task dependency tree, ' +
'in JSON format, for the loaded gulpfile.'),
},
'tasks-depth': {
alias: 'depth',
type: 'number',
requiresArg: true,
desc: chalk.gray(
desc: ansi.gray(
'Specify the depth of the task dependency tree.'),
},
'compact-tasks': {
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Reduce the output of task dependency tree by printing ' +
'only top tasks and their child tasks.'),
},
'sort-tasks': {
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Will sort top tasks of task dependency tree.'),
},
color: {
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Will force gulp and gulp plugins to display colors, ' +
'even when no color support is detected.'),
},
'no-color': {
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Will force gulp and gulp plugins to not display colors, ' +
'even when color support is detected.'),
},
silent: {
alias: 'S',
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Suppress all gulp logging.'),
},
continue: {
type: 'boolean',
desc: chalk.gray(
desc: ansi.gray(
'Continue execution of tasks upon failure.'),
},
'log-level': {
alias: 'L',
// Type isn't needed because count acts as a boolean
count: true,
// Can't use `default` because it seems to be off by one
desc: chalk.gray(
desc: ansi.gray(
'Set the loglevel. -L for least verbose and -LLLL for most verbose. ' +
'-LLL is default.'),
},
Expand Down
4 changes: 2 additions & 2 deletions lib/shared/log/blacklistError.js
@@ -1,12 +1,12 @@
'use strict';

var chalk = require('chalk');
var log = require('gulplog');

var ansi = require('../ansi');
var exit = require('../exit');

function logBlacklistError(err) {
log.error(chalk.red('Error: failed to retrieve plugins black-list'));
log.error(ansi.red('Error: failed to retrieve plugins black-list'));
log.error(err.message); // Avoid duplicating for each version
exit(1);
}
Expand Down
14 changes: 7 additions & 7 deletions lib/shared/log/tasks.js
@@ -1,11 +1,11 @@
'use strict';

var archy = require('archy');
var chalk = require('chalk');
var log = require('gulplog');

var sortBy = require('lodash.sortby');
var isObject = require('lodash.isplainobject');
var ansi = require('../ansi');
var isString = require('../is-string');

var copyTree = require('./copy-tree');
Expand Down Expand Up @@ -145,20 +145,20 @@ function printTreeList(lines, spacer, lineInfos) {
lines.forEach(function(branch, index) {
var info = lineInfos[index];

var line = chalk.white(branch);
var line = ansi.white(branch);

if (info.type === 'top') {
line += chalk.cyan(info.name);
line += ansi.cyan(info.name);
if (info.desc.length > 0) {
line += spacer(index) + chalk.white(info.desc);
line += spacer(index) + ansi.white(info.desc);
}
} else if (info.type === 'option') {
line += chalk.magenta(info.name);
line += ansi.magenta(info.name);
if (info.desc.length > 0) {
line += spacer(index) + chalk.white('…' + info.desc);
line += spacer(index) + ansi.white('…' + info.desc);
}
} else { // If (info.type === 'child') {
line += chalk.white(info.name);
line += ansi.white(info.name);
}

log.info(line);
Expand Down
8 changes: 4 additions & 4 deletions lib/shared/log/verify.js
@@ -1,25 +1,25 @@
'use strict';

var chalk = require('chalk');
var log = require('gulplog');

var ansi = require('../ansi');
var exit = require('../exit');

function logVerify(blacklisted) {
var pluginNames = Object.keys(blacklisted);

if (!pluginNames.length) {
log.info(
chalk.green('There are no blacklisted plugins in this project')
ansi.green('There are no blacklisted plugins in this project')
);
exit(0);
}

log.warn(chalk.red('Blacklisted plugins found in this project:'));
log.warn(ansi.red('Blacklisted plugins found in this project:'));

pluginNames.map(function(pluginName) {
var reason = blacklisted[pluginName];
log.warn(chalk.bgRed(pluginName) + ': ' + reason);
log.warn(ansi.bgred(pluginName) + ': ' + reason);
});

exit(1);
Expand Down
6 changes: 3 additions & 3 deletions lib/versioned/^3.7.0/index.js
@@ -1,13 +1,13 @@
'use strict';

var chalk = require('chalk');
var log = require('gulplog');
var stdout = require('mute-stdout');
var tildify = require('tildify');

var taskTree = require('./taskTree');

var logTasks = require('../../shared/log/tasks');
var ansi = require('../../shared/ansi');
var isString = require('../../shared/is-string');
var logEvents = require('./log/events');
var logTasksSimple = require('./log/tasksSimple');
Expand All @@ -24,7 +24,7 @@ function execute(opts, env, config) {

// This is what actually loads up the gulpfile
var exported = require(env.configPath);
log.info('Using gulpfile', chalk.magenta(tildify(env.configPath)));
log.info('Using gulpfile', ansi.magenta(tildify(env.configPath)));

var gulpInst = require(env.modulePath);
logEvents(gulpInst);
Expand All @@ -45,7 +45,7 @@ function execute(opts, env, config) {
if (config.description && isString(config.description)) {
tree.label = config.description;
} else {
tree.label = 'Tasks for ' + chalk.magenta(tildify(env.configPath));
tree.label = 'Tasks for ' + ansi.magenta(tildify(env.configPath));
}
return logTasks(tree, opts, function(task) {
return gulpInst.tasks[task].fn;
Expand Down

0 comments on commit d9c5b59

Please sign in to comment.