mirror of https://github.com/TryGhost/Ghost.git
replace colors with chalk everywhere
issue #5259 - removes the colors dependency - adds in chalk dependency, and migrates everything to use that - reduces some specs now that the log calls are cleaner
This commit is contained in:
parent
f6b56ad865
commit
f26179ae6a
17
Gruntfile.js
17
Gruntfile.js
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
// **Debug tip:** If you have any problems with any Grunt tasks, try running them with the `--verbose` command
|
||||
var _ = require('lodash'),
|
||||
colors = require('colors'),
|
||||
chalk = require('chalk'),
|
||||
fs = require('fs-extra'),
|
||||
moment = require('moment'),
|
||||
getTopContribs = require('top-gh-contribs'),
|
||||
|
@ -41,9 +41,6 @@ var _ = require('lodash'),
|
|||
// ## Grunt configuration
|
||||
|
||||
configureGrunt = function (grunt) {
|
||||
// *This is not useful but required for jshint*
|
||||
colors.setTheme({silly: 'rainbow'});
|
||||
|
||||
// #### Load all grunt tasks
|
||||
//
|
||||
// Find all of the task which start with `grunt-` and load them, rather than explicitly declaring them all
|
||||
|
@ -281,10 +278,10 @@ var _ = require('lodash'),
|
|||
},
|
||||
bg: true,
|
||||
stdout: function (out) {
|
||||
grunt.log.writeln('Ember-cli::'.cyan + out);
|
||||
grunt.log.writeln(chalk.cyan('Ember-cli::') + out);
|
||||
},
|
||||
stderror: function (error) {
|
||||
grunt.log.error('Ember-cli::'.red + error.red);
|
||||
grunt.log.error(chalk.red('Ember-cli::' + error));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -756,9 +753,9 @@ var _ = require('lodash'),
|
|||
grunt.registerTask('master-warn',
|
||||
'Outputs a warning to runners of grunt prod, that master shouldn\'t be used for live blogs',
|
||||
function () {
|
||||
console.log('>', 'Always two there are, no more, no less. A master and a'.red,
|
||||
'stable'.red.bold + '.'.red);
|
||||
console.log('Use the', 'stable'.bold, 'branch for live blogs.', 'Never'.bold, 'master!');
|
||||
console.log('>', chalk.red('Always two there are, no more, no less. A master and a'),
|
||||
chalk.bold.red('stable') + chalk.red('.'));
|
||||
console.log('Use the', chalk.bold('stable'), 'branch for live blogs.', chalk.bold('Never'), 'master!');
|
||||
});
|
||||
|
||||
// ### Build About Page *(Utility Task)*
|
||||
|
@ -779,7 +776,7 @@ var _ = require('lodash'),
|
|||
|
||||
if (fs.existsSync(templatePath) && !grunt.option('force')) {
|
||||
grunt.log.writeln('Contributors template already exists.');
|
||||
grunt.log.writeln('Skipped'.bold);
|
||||
grunt.log.writeln(chalk.bold('Skipped'));
|
||||
return done();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
var path = require('path'),
|
||||
Promise = require('bluebird'),
|
||||
chalk = require('chalk'),
|
||||
crypto = require('crypto'),
|
||||
fs = require('fs'),
|
||||
url = require('url'),
|
||||
|
@ -423,7 +424,7 @@ ConfigManager.prototype.displayDeprecated = function (item, properties, address)
|
|||
if (properties.length) {
|
||||
return self.displayDeprecated(item[property], properties, address);
|
||||
}
|
||||
errorText = 'The configuration property [' + address.join('.').bold + '] has been deprecated.';
|
||||
errorText = 'The configuration property [' + chalk.bold(address.join('.')) + '] has been deprecated.';
|
||||
explanationText = 'This will be removed in a future version, please update your config.js file.';
|
||||
helpText = 'Please check http://support.ghost.org/config for the most up-to-date example.';
|
||||
errors.logWarn(errorText, explanationText, helpText);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*jslint regexp: true */
|
||||
var _ = require('lodash'),
|
||||
colors = require('colors'),
|
||||
chalk = require('chalk'),
|
||||
path = require('path'),
|
||||
Promise = require('bluebird'),
|
||||
hbs = require('express-hbs'),
|
||||
|
@ -20,9 +20,6 @@ var _ = require('lodash'),
|
|||
// Paths for views
|
||||
userErrorTemplateExists = false;
|
||||
|
||||
// This is not useful but required for jshint
|
||||
colors.setTheme({silly: 'rainbow'});
|
||||
|
||||
// Shim right now to deal with circular dependencies.
|
||||
// @TODO(hswolff): remove circular dependency and lazy require.
|
||||
function getConfigModule() {
|
||||
|
@ -63,9 +60,7 @@ errors = {
|
|||
if ((process.env.NODE_ENV === 'development' ||
|
||||
process.env.NODE_ENV === 'staging' ||
|
||||
process.env.NODE_ENV === 'production')) {
|
||||
var msg = [component.cyan + ':'.cyan, info.cyan];
|
||||
|
||||
console.info.apply(console, msg);
|
||||
console.info(chalk.cyan(component + ':', info));
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -74,14 +69,14 @@ errors = {
|
|||
process.env.NODE_ENV === 'staging' ||
|
||||
process.env.NODE_ENV === 'production')) {
|
||||
warn = warn || 'no message supplied';
|
||||
var msgs = ['\nWarning:'.yellow, warn.yellow, '\n'];
|
||||
var msgs = [chalk.yellow('\nWarning:', warn), '\n'];
|
||||
|
||||
if (context) {
|
||||
msgs.push(context.white, '\n');
|
||||
msgs.push(chalk.white(context), '\n');
|
||||
}
|
||||
|
||||
if (help) {
|
||||
msgs.push(help.green);
|
||||
msgs.push(chalk.green(help));
|
||||
}
|
||||
|
||||
// add a new line
|
||||
|
@ -126,14 +121,14 @@ errors = {
|
|||
if ((process.env.NODE_ENV === 'development' ||
|
||||
process.env.NODE_ENV === 'staging' ||
|
||||
process.env.NODE_ENV === 'production')) {
|
||||
msgs = ['\nERROR:'.red, err.red, '\n'];
|
||||
msgs = [chalk.red('\nERROR:', err), '\n'];
|
||||
|
||||
if (context) {
|
||||
msgs.push(context.white, '\n');
|
||||
msgs.push(chalk.white(context), '\n');
|
||||
}
|
||||
|
||||
if (help) {
|
||||
msgs.push(help.green);
|
||||
msgs.push(chalk.green(help));
|
||||
}
|
||||
|
||||
// add a new line
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var Promise = require('bluebird'),
|
||||
chalk = require('chalk'),
|
||||
fs = require('fs'),
|
||||
semver = require('semver'),
|
||||
packageInfo = require('../../package.json'),
|
||||
|
@ -49,12 +50,12 @@ GhostServer.prototype.logStartMessages = function () {
|
|||
if (!semver.satisfies(process.versions.node, packageInfo.engines.node) &&
|
||||
!semver.satisfies(process.versions.node, packageInfo.engines.iojs)) {
|
||||
console.log(
|
||||
'\nERROR: Unsupported version of Node'.red,
|
||||
'\nGhost needs Node version'.red,
|
||||
packageInfo.engines.node.yellow,
|
||||
'you are using version'.red,
|
||||
process.versions.node.yellow,
|
||||
'\nPlease go to http://nodejs.org to get a supported version'.green
|
||||
chalk.red('\nERROR: Unsupported version of Node'),
|
||||
chalk.red('\nGhost needs Node version'),
|
||||
chalk.yellow(packageInfo.engines.node),
|
||||
chalk.red('you are using version'),
|
||||
chalk.yellow(process.versions.node),
|
||||
chalk.green('\nPlease go to http://nodejs.org to get a supported version')
|
||||
);
|
||||
|
||||
process.exit(0);
|
||||
|
@ -63,24 +64,24 @@ GhostServer.prototype.logStartMessages = function () {
|
|||
// Startup & Shutdown messages
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
console.log(
|
||||
'Ghost is running...'.green,
|
||||
chalk.green('Ghost is running...'),
|
||||
'\nYour blog is now available on',
|
||||
config.url,
|
||||
'\nCtrl+C to shut down'.grey
|
||||
chalk.gray('\nCtrl+C to shut down')
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
('Ghost is running in ' + process.env.NODE_ENV + '...').green,
|
||||
chalk.green('Ghost is running in ' + process.env.NODE_ENV + '...'),
|
||||
'\nListening on',
|
||||
config.getSocket() || config.server.host + ':' + config.server.port,
|
||||
'\nUrl configured as:',
|
||||
config.url,
|
||||
'\nCtrl+C to shut down'.grey
|
||||
chalk.gray('\nCtrl+C to shut down')
|
||||
);
|
||||
}
|
||||
|
||||
function shutdown() {
|
||||
console.log('\nGhost has shut down'.red);
|
||||
console.log(chalk.red('\nGhost has shut down'));
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
console.log(
|
||||
'\nYour blog is now offline'
|
||||
|
@ -101,7 +102,7 @@ GhostServer.prototype.logStartMessages = function () {
|
|||
};
|
||||
|
||||
GhostServer.prototype.logShutdownMessages = function () {
|
||||
console.log('Ghost is closing connections'.red);
|
||||
console.log(chalk.red('Ghost is closing connections'));
|
||||
};
|
||||
|
||||
GhostServer.prototype.logUpgradeWarning = function () {
|
||||
|
@ -198,7 +199,7 @@ GhostServer.prototype.restart = function () {
|
|||
|
||||
// To be called after `stop`
|
||||
GhostServer.prototype.hammertime = function () {
|
||||
console.log('Can\'t touch this'.green);
|
||||
console.log(chalk.green('Can\'t touch this'));
|
||||
|
||||
return Promise.resolve(this);
|
||||
};
|
||||
|
|
|
@ -688,10 +688,7 @@ describe('Config', function () {
|
|||
|
||||
logStub.calledOnce.should.be.true;
|
||||
|
||||
logStub.calledWithMatch(null, 'updateCheck').should.be.false;
|
||||
logStub.calledWithMatch('', 'updateCheck').should.be.true;
|
||||
logStub.calledWithMatch(sinon.match.string, 'updateCheck').should.be.true;
|
||||
logStub.calledWithMatch(sinon.match.number, 'updateCheck').should.be.false;
|
||||
logStub.calledWithMatch('updateCheck').should.be.true;
|
||||
|
||||
// Future tests: This is important here!
|
||||
resetEnvironment();
|
||||
|
@ -706,10 +703,7 @@ describe('Config', function () {
|
|||
|
||||
logStub.calledOnce.should.be.true;
|
||||
|
||||
logStub.calledWithMatch(null, 'updateCheck').should.be.false;
|
||||
logStub.calledWithMatch('', 'updateCheck').should.be.true;
|
||||
logStub.calledWithMatch(sinon.match.string, 'updateCheck').should.be.true;
|
||||
logStub.calledWithMatch(sinon.match.number, 'updateCheck').should.be.false;
|
||||
logStub.calledWithMatch('updateCheck').should.be.true;
|
||||
|
||||
// Future tests: This is important here!
|
||||
resetEnvironment();
|
||||
|
@ -726,10 +720,7 @@ describe('Config', function () {
|
|||
|
||||
logStub.calledOnce.should.be.true;
|
||||
|
||||
logStub.calledWithMatch(null, 'mail.fromaddress').should.be.false;
|
||||
logStub.calledWithMatch('', 'mail.fromaddress').should.be.true;
|
||||
logStub.calledWithMatch(sinon.match.string, 'mail.fromaddress').should.be.true;
|
||||
logStub.calledWithMatch(sinon.match.number, 'mail.fromaddress').should.be.false;
|
||||
logStub.calledWithMatch('mail.fromaddress').should.be.true;
|
||||
|
||||
// Future tests: This is important here!
|
||||
resetEnvironment();
|
||||
|
@ -745,10 +736,7 @@ describe('Config', function () {
|
|||
config.checkDeprecated();
|
||||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWithMatch(null, 'mail.fromaddress').should.be.false;
|
||||
logStub.calledWithMatch('', 'mail.fromaddress').should.be.true;
|
||||
logStub.calledWithMatch(sinon.match.string, 'mail.fromaddress').should.be.true;
|
||||
logStub.calledWithMatch(sinon.match.number, 'mail.fromaddress').should.be.false;
|
||||
logStub.calledWithMatch('mail.fromaddress').should.be.true;
|
||||
|
||||
// Future tests: This is important here!
|
||||
resetEnvironment();
|
||||
|
|
|
@ -9,15 +9,12 @@ var should = require('should'),
|
|||
|
||||
// Stuff we are testing
|
||||
|
||||
colors = require('colors'),
|
||||
chalk = require('chalk'),
|
||||
config = rewire('../../server/config'),
|
||||
errors = rewire('../../server/errors'),
|
||||
// storing current environment
|
||||
currentEnv = process.env.NODE_ENV;
|
||||
|
||||
// This is not useful but required for jshint
|
||||
colors.setTheme({silly: 'rainbow'});
|
||||
|
||||
describe('Error handling', function () {
|
||||
// Just getting rid of jslint unused error
|
||||
should.exist(errors);
|
||||
|
@ -73,7 +70,7 @@ describe('Error handling', function () {
|
|||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith(
|
||||
'\nWarning: no message supplied'.yellow, '\n');
|
||||
chalk.yellow('\nWarning: no message supplied'), '\n');
|
||||
|
||||
// Future tests: This is important here!
|
||||
resetEnvironment();
|
||||
|
@ -85,7 +82,7 @@ describe('Error handling', function () {
|
|||
errors.logWarn(errorText);
|
||||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith(('\nWarning: ' + errorText).yellow, '\n');
|
||||
logStub.calledWith(chalk.yellow('\nWarning: ' + errorText), '\n');
|
||||
|
||||
// Future tests: This is important here!
|
||||
resetEnvironment();
|
||||
|
@ -99,7 +96,7 @@ describe('Error handling', function () {
|
|||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith(
|
||||
('\nWarning: ' + errorText).yellow, '\n', contextText.white, '\n'
|
||||
chalk.yellow('\nWarning: ' + errorText), '\n', chalk.white(contextText), '\n'
|
||||
);
|
||||
|
||||
// Future tests: This is important here!
|
||||
|
@ -115,7 +112,7 @@ describe('Error handling', function () {
|
|||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith(
|
||||
('\nWarning: ' + errorText).yellow, '\n', contextText.white, '\n', helpText.green, '\n'
|
||||
chalk.yellow('\nWarning: ' + errorText), '\n', chalk.white(contextText), '\n', chalk.green(helpText), '\n'
|
||||
);
|
||||
|
||||
// Future tests: This is important here!
|
||||
|
@ -145,7 +142,7 @@ describe('Error handling', function () {
|
|||
|
||||
// Calls log with message on Error objects
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith('\nERROR:'.red, err.message.red, '\n', '\n', err.stack, '\n').should.be.true;
|
||||
logStub.calledWith(chalk.red('\nERROR:', err.message), '\n', '\n', err.stack, '\n').should.be.true;
|
||||
});
|
||||
|
||||
it('logs errors from strings', function () {
|
||||
|
@ -155,7 +152,7 @@ describe('Error handling', function () {
|
|||
|
||||
// Calls log with string on strings
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith('\nERROR:'.red, err.red, '\n').should.be.true;
|
||||
logStub.calledWith(chalk.red('\nERROR:', err), '\n').should.be.true;
|
||||
});
|
||||
|
||||
it('logs errors from an error object and two string arguments', function () {
|
||||
|
@ -167,7 +164,7 @@ describe('Error handling', function () {
|
|||
// Calls log with message on Error objects
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith(
|
||||
'\nERROR:'.red, err.message.red, '\n', message.white, '\n', message.green, '\n', err.stack, '\n'
|
||||
chalk.red('\nERROR:', err.message), '\n', chalk.white(message), '\n', chalk.green(message), '\n', err.stack, '\n'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -179,7 +176,7 @@ describe('Error handling', function () {
|
|||
// Calls log with message on Error objects
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith(
|
||||
'\nERROR:'.red, message.red, '\n', message.white, '\n', message.green, '\n'
|
||||
chalk.red('\nERROR:', message), '\n', chalk.white(message), '\n', chalk.green(message), '\n'
|
||||
).should.be.true;
|
||||
});
|
||||
|
||||
|
@ -192,7 +189,7 @@ describe('Error handling', function () {
|
|||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith(
|
||||
'\nERROR:'.red, 'An unknown error occurred.'.red, '\n', message.white, '\n', message.green, '\n'
|
||||
chalk.red('\nERROR:', 'An unknown error occurred.'), '\n', chalk.white(message), '\n', chalk.green(message), '\n'
|
||||
).should.be.true;
|
||||
});
|
||||
|
||||
|
@ -204,7 +201,7 @@ describe('Error handling', function () {
|
|||
// Calls log with message on Error objects
|
||||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith('\nERROR:'.red, message.red, '\n', message.green, '\n').should.be.true;
|
||||
logStub.calledWith(chalk.red('\nERROR:', message), '\n', chalk.green(message), '\n').should.be.true;
|
||||
});
|
||||
|
||||
it('logs errors from an undefined help argument', function () {
|
||||
|
@ -215,7 +212,7 @@ describe('Error handling', function () {
|
|||
// Calls log with message on Error objects
|
||||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith('\nERROR:'.red, message.red, '\n', message.white, '\n').should.be.true;
|
||||
logStub.calledWith(chalk.red('\nERROR:', message), '\n', chalk.white(message), '\n').should.be.true;
|
||||
});
|
||||
|
||||
it('logs errors from a null error argument', function () {
|
||||
|
@ -227,7 +224,7 @@ describe('Error handling', function () {
|
|||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.calledWith(
|
||||
'\nERROR:'.red, 'An unknown error occurred.'.red, '\n', message.white, '\n', message.green, '\n'
|
||||
chalk.red('\nERROR:', 'An unknown error occurred.'), '\n', chalk.white(message), '\n', chalk.green(message), '\n'
|
||||
).should.be.true;
|
||||
});
|
||||
|
||||
|
@ -239,7 +236,7 @@ describe('Error handling', function () {
|
|||
// Calls log with message on Error objects
|
||||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.firstCall.calledWith('\nERROR:'.red, message.red, '\n', message.green, '\n').should.be.true;
|
||||
logStub.firstCall.calledWith(chalk.red('\nERROR:', message), '\n', chalk.green(message), '\n').should.be.true;
|
||||
});
|
||||
|
||||
it('logs errors from a null help argument', function () {
|
||||
|
@ -250,7 +247,7 @@ describe('Error handling', function () {
|
|||
// Calls log with message on Error objects
|
||||
|
||||
logStub.calledOnce.should.be.true;
|
||||
logStub.firstCall.calledWith('\nERROR:'.red, message.red, '\n', message.white, '\n').should.be.true;
|
||||
logStub.firstCall.calledWith(chalk.red('\nERROR:', message), '\n', chalk.white(message), '\n').should.be.true;
|
||||
});
|
||||
|
||||
it('logs promise errors and redirects', function (done) {
|
||||
|
@ -268,7 +265,7 @@ describe('Error handling', function () {
|
|||
}, errors.logErrorWithRedirect('test1', null, null, '/testurl', req, res));
|
||||
|
||||
Promise.reject().catch(function () {
|
||||
logStub.calledWith('\nERROR:'.red, 'test1'.red).should.equal(true);
|
||||
logStub.calledWith(chalk.red('\nERROR:', 'test1')).should.equal(true);
|
||||
logStub.restore();
|
||||
|
||||
redirectStub.calledWith('/testurl').should.equal(true);
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
"body-parser": "1.10.0",
|
||||
"bookshelf": "0.7.9",
|
||||
"busboy": "0.2.9",
|
||||
"chalk": "1.0.0",
|
||||
"cheerio": "0.18.0",
|
||||
"colors": "0.6.2",
|
||||
"compression": "1.2.2",
|
||||
"connect-slashes": "1.3.0",
|
||||
"cookie-session": "1.1.0",
|
||||
|
|
Loading…
Reference in New Issue