🎨 Replace colors module with chalk module

This commit is contained in:
brunosimon
2017-12-26 14:29:00 +01:00
parent 494bd401b9
commit 73bc3e174a
8 changed files with 87 additions and 59 deletions
+7 -6
View File
@@ -1,5 +1,6 @@
const ids = require('./ids.js')
const robotNames = require('./assets/data/robot-names.json')
const chalk = require('chalk')
const HTMLEntities = require('html-entities')
class Chat
@@ -38,8 +39,8 @@ class Chat
// Debug
if(this.config.debug >= 1)
{
console.log('chat > socket'.green.bold + ' - ' + 'connection'.cyan + ' - ' + socket.id.cyan)
console.log('chat > user'.green.bold + ' - ' + 'create'.cyan + ' - ' + user.name.cyan)
console.log(`${chalk.green.bold('chat > socket')} - ${chalk.cyan('connection')} - ${chalk.cyan(socket.id)}`)
console.log(`${chalk.green.bold('chat > user')} - ${chalk.cyan('create')} - ${chalk.cyan(user.name)}`)
}
// Send user infos
@@ -71,7 +72,7 @@ class Chat
// Debug
if(this.config.debug >= 1)
{
console.log('chat > socket'.green.bold + ' - ' + 'message'.cyan + ' - ' + user.name.cyan + ' - ' + data.text.cyan)
console.log(`${chalk.green.bold('chat > socket')} - ${chalk.cyan('message')} - ${chalk.cyan(user.name)} - ${chalk.cyan(data.text)}`)
}
})
@@ -93,7 +94,7 @@ class Chat
// Debug
if(this.config.debug >= 1)
{
console.log('chat > socket'.green.bold + ' - ' + 'update_user'.cyan + ' - ' + (oldName + ' > ' + user.name).cyan)
console.log(`${chalk.green.bold('chat > socket')} - ${chalk.cyan('update_user')} - ${chalk.cyan(oldName + ' > ' + user.name)}`)
}
})
@@ -106,14 +107,14 @@ class Chat
// Debug
if(this.config.debug >= 1)
{
console.log('chat > socket'.green.bold + ' - ' + 'alert'.cyan + ' - ' + user.name.cyan)
console.log(`${chalk.green.bold('chat > socket')} - ${chalk.cyan('alert')} - ${chalk.cyan(user.name)}`)
}
})
// On disconnect
socket.on('disconnect', () =>
{
console.log('chat > socket'.green.bold + ' - ' + 'disconnect'.cyan + ' - ' + user.name.cyan)
console.log(`${chalk.green.bold('chat > socket')} - ${chalk.cyan('disconnect')} - ${chalk.cyan(user.name)}`)
})
})
}
+12 -11
View File
@@ -5,9 +5,10 @@ const Watcher = require('./watcher.js')
const Projects = require('./projects.js')
const socketIo = require('socket.io')
const util = require('util')
const colors = require('colors')
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
const gradientString = require('gradient-string')
const packageJson = require('../package.json')
/**
@@ -21,7 +22,7 @@ class App
constructor()
{
console.log()
console.log('---'.rainbow + ' keppler '.bold.white + packageJson.version.bold.white + ' ----------------------'.rainbow)
console.log(`${gradientString.pastel('----------------------')} ${chalk.white.bold('keppler')} ${chalk.white.bold(packageJson.version)} ${gradientString.pastel('----------------------')}`)
console.log()
this.setConfig()
@@ -157,7 +158,7 @@ class App
for(const _configKey in this.config)
{
const _configValue = '' + this.config[_configKey]
console.log('app > config'.green.bold + ' - ' + _configKey.cyan + ' - ' + _configValue.cyan)
console.log(`${chalk.green.bold('app > config')} - ${chalk.cyan(_configKey)} - ${chalk.cyan(_configValue)}`)
}
}
}
@@ -176,8 +177,8 @@ class App
},
() =>
{
console.log('error'.red)
console.log('app'.green.bold + ' - ' + 'keppler seems to be running already'.cyan)
console.log(chalk.red('error'))
console.log(`${chalk.green.bold('app')} - ${chalk.cyan('keppler seems to be running already')}`)
}
)
}
@@ -211,7 +212,7 @@ class App
// Debug
if(this.config.debug >= 1)
{
console.log('app > socket'.green.bold + ' - ' + 'connect'.cyan + ' - ' + socket.id.cyan)
console.log(`${chalk.green.bold('app > socket')} - ${chalk.cyan('connect')} - ${chalk.cyan(socket.id)}`)
}
// Start project
@@ -225,7 +226,7 @@ class App
// Debug
if(this.config.debug >= 1)
{
console.log('app > socket'.green.bold + ' - ' + 'start_project'.cyan + ' - ' + project.slug.cyan)
console.log(`${chalk.green.bold('app > socket')} - ${chalk.cyan('start_project')} - ${chalk.cyan(project.slug)}`)
}
if(this.config.debug >= 2)
{
@@ -244,7 +245,7 @@ class App
// Debug
if(this.config.debug >= 1)
{
console.log('app > socket'.green.bold + ' - ' + 'update_file'.cyan + ' - ' + data.path.cyan)
console.log(`${chalk.green.bold('app > socket')} - ${chalk.cyan('update_file')} - ${chalk.cyan(data.path)}`)
}
if(this.config.debug >= 2)
{
@@ -261,7 +262,7 @@ class App
// Debug
if(this.config.debug >= 1)
{
console.log('app > socket'.green.bold + ' - ' + 'update_file'.cyan + ' - ' + data.path.cyan)
console.log(`${chalk.green.bold('app > socket')} - ${chalk.cyan('create_file')} - ${chalk.cyan(data.path)}`)
}
if(this.config.debug >= 2)
{
@@ -278,7 +279,7 @@ class App
// Debug
if(this.config.debug >= 1)
{
console.log('app > socket'.green.bold + ' - ' + 'update_file'.cyan + ' - ' + data.path.cyan)
console.log(`${chalk.green.bold('app > socket')} - ${chalk.cyan('delete_file')} - ${chalk.cyan(data.path)}`)
}
if(this.config.debug >= 2)
{
@@ -294,7 +295,7 @@ class App
// Debug
if(this.config.debug >= 1)
{
console.log('app > socket'.green.bold + ' - ' + 'disconnect'.cyan + ' - ' + socket.id.cyan)
console.log(`${chalk.green.bold('app > socket')} - ${chalk.cyan('disconnect')} - ${chalk.cyan(socket.id)}`)
}
})
})
+5 -4
View File
@@ -6,6 +6,7 @@ const JSZip = require('jszip')
const glob = require('glob')
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
class Project
{
@@ -50,7 +51,7 @@ class Project
// Debug
if(this.config.debug >= 1)
{
console.log('project > socket'.green.bold + ' - ' + 'connection'.cyan + ' - ' + socket.id.cyan)
console.log(`${chalk.green.bold('project > socket')} - ${chalk.cyan('connection')} - ${chalk.cyan(socket.id)}`)
}
})
}
@@ -63,7 +64,7 @@ class Project
// Debug
if(this.config.debug >= 1)
{
console.log('project > zip'.green.bold + ' - ' + 'from cache'.cyan)
console.log(`${chalk.green.bold('project > zip')} - ${chalk.cyan('from cache')}`)
}
return this.zipBuffer
@@ -96,7 +97,7 @@ class Project
// Debug
if(this.config.debug >= 1)
{
console.log('project > zip'.green.bold + ' - ' + 'create'.cyan)
console.log(`${chalk.green.bold('project > zip')} - ${chalk.cyan('create')}`)
}
return this.zipBuffer
@@ -106,7 +107,7 @@ class Project
*/
addTestContents()
{
console.log('project'.green.bold + ' - ' + 'add test contents'.cyan)
console.log(`${chalk.green.bold('project')} - ${chalk.cyan('add test content')}`)
// Add some with true contents
this.files.createVersion('./test/file.css', `body {
+2 -1
View File
@@ -1,4 +1,5 @@
const Project = require('./project.js')
const chalk = require('chalk')
class Projects
{
@@ -26,7 +27,7 @@ class Projects
if(this.config.debug >= 1)
{
console.log('projects > socket'.green.bold + ' - ' + 'connection'.cyan + ' - ' + socket.id.cyan)
console.log(`${chalk.green.bold('projects > socket')} - ${chalk.cyan('connection')} - ${chalk.cyan(socket.id)}`)
}
})
}
+4 -5
View File
@@ -4,6 +4,7 @@ const helmet = require('helmet')
const http = require('http')
const colors = require('colors')
const path = require('path')
const chalk = require('chalk')
/**
* Site class
@@ -53,7 +54,7 @@ class Site
{
if(this.config.debug >= 1)
{
console.log('site'.green.bold + ' - ' + 'already running'.cyan)
console.log(`${chalk.green.bold('site')} - ${chalk.cyan('already running')}`)
}
// Callback
@@ -68,7 +69,7 @@ class Site
{
if(this.config.debug >= 1)
{
console.log('site'.green.bold + ' - ' + 'unknow error'.cyan)
console.log(`${chalk.green.bold('site')} - ${chalk.cyan('unknown error')}`)
console.log(error)
}
@@ -86,7 +87,7 @@ class Site
// URL
if(this.config.debug >= 1)
{
console.log('site'.green.bold + ' - ' + 'started'.cyan)
console.log(`${chalk.green.bold('site')} - ${chalk.cyan('started')}`)
}
if(typeof this.success === 'function')
@@ -103,8 +104,6 @@ class Site
{
this.express.use('/', express.static(path.join(__dirname, '../site/dist')))
console.log('/' + _project.slug + '/download')
// Project download route
this.express.get('/' + _project.slug + '/download', (request, response) =>
{
+9 -8
View File
@@ -6,6 +6,7 @@ const socketIoClient = require('socket.io-client')
const opener = require('opener')
const nodeNotifier = require('node-notifier')
const path = require('path')
const chalk = require('chalk')
/**
* Watcher class
@@ -49,7 +50,7 @@ class Watcher
// Debug
if(this.config.debug)
{
console.log('watcher > socket'.green.bold + ' - ' + 'connect'.cyan)
console.log(`${chalk.green.bold('watcher > socket')} - ${chalk.cyan('connect')}`)
}
})
@@ -59,7 +60,7 @@ class Watcher
// Debug
if(this.config.debug)
{
console.log('watcher > socket'.green.bold + ' - ' + 'disconnect'.cyan)
console.log(`${chalk.green.bold('watcher > socket')} - ${chalk.cyan('disconnect')}`)
}
})
@@ -127,7 +128,7 @@ class Watcher
if(this.config.debug >= 1)
{
console.log('watcher'.green.bold + ' - ' + 'start watching'.cyan + ' - ' + this.path.cyan)
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('start watching')} - ${chalk.cyan(this.path)}`)
}
// Add event
@@ -172,7 +173,7 @@ class Watcher
// Debug
if(this.config.debug >= 1)
{
console.log('watcher'.green.bold + ' - ' + 'add'.cyan + ' - ' + relativePath.cyan)
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('add')} - ${chalk.cyan(relativePath)}`)
}
})
@@ -218,7 +219,7 @@ class Watcher
// Debug
if(this.config.debug >= 1)
{
console.log('watcher'.green.bold + ' - ' + 'change'.cyan + ' - ' + relativePath.cyan)
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('change')} - ${chalk.cyan(relativePath)}`)
}
})
@@ -234,7 +235,7 @@ class Watcher
// Debug
if(this.config.debug >= 1)
{
console.log('watcher'.green.bold + ' - ' + 'unlink'.cyan + ' - ' + relativePath.cyan)
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('unlink')} - ${chalk.cyan(relativePath)}`)
}
})
@@ -250,7 +251,7 @@ class Watcher
// Debug
if(this.config.debug >= 1)
{
console.log('watcher'.green.bold + ' - ' + 'addDir'.cyan + ' - ' + relativePath.cyan)
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('addDir')} - ${chalk.cyan(relativePath)}`)
}
})
@@ -266,7 +267,7 @@ class Watcher
// Debug
if(this.config.debug >= 1)
{
console.log('watcher'.green.bold + ' - ' + 'unlinkDir'.cyan + ' - ' + relativePath.cyan)
console.log(`${chalk.green.bold('watcher')} - ${chalk.cyan('unlinkDir')} - ${chalk.cyan(relativePath)}`)
}
})
}
+37 -22
View File
@@ -1332,30 +1332,27 @@
}
},
"chalk": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.0.1.tgz",
"integrity": "sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0g==",
"dev": true,
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz",
"integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==",
"requires": {
"ansi-styles": "3.2.0",
"escape-string-regexp": "1.0.5",
"supports-color": "4.2.1"
"supports-color": "4.5.0"
},
"dependencies": {
"ansi-styles": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz",
"integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==",
"dev": true,
"requires": {
"color-convert": "1.9.0"
}
},
"supports-color": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.1.tgz",
"integrity": "sha512-qxzYsob3yv6U+xMzPrv170y8AwGP7i74g+pbixCfD6rgso8BscLT2qXIuz6TpOaiJZ3mFgT5O9lyT9nMU4LfaA==",
"dev": true,
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz",
"integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=",
"requires": {
"has-flag": "2.0.0"
}
@@ -1508,7 +1505,6 @@
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz",
"integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=",
"dev": true,
"requires": {
"color-name": "1.1.3"
}
@@ -1516,8 +1512,7 @@
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
},
"color-string": {
"version": "0.3.0",
@@ -2442,8 +2437,7 @@
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
},
"eslint": {
"version": "4.3.0",
@@ -3837,6 +3831,15 @@
"version": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
},
"gradient-string": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/gradient-string/-/gradient-string-1.0.0.tgz",
"integrity": "sha512-1jCBcPk2I9lmL8YBofayR7XQrrT9FYaihyooDNtcgxnsKVabGJi3N7WDFm2oMODGjQyvy51Vq5TKFB5oaOIY9Q==",
"requires": {
"chalk": "2.3.0",
"tinygradient": "0.3.1"
}
},
"growly": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
@@ -3892,8 +3895,7 @@
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
"dev": true
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE="
},
"hash-base": {
"version": "2.0.2",
@@ -4203,7 +4205,7 @@
"integrity": "sha512-G6WnRmdTt2jvJvY+aY+M0AO4YlbxE+slKPZb+jG2P2U9Tyxi3h1fYZ/DgiFU6DC6bv3XIEJoZt+f/kNh8BrWFw==",
"dev": true,
"requires": {
"chalk": "2.0.1",
"chalk": "2.3.0",
"source-map": "0.5.6",
"supports-color": "4.2.1"
}
@@ -5905,7 +5907,7 @@
"integrity": "sha512-G6WnRmdTt2jvJvY+aY+M0AO4YlbxE+slKPZb+jG2P2U9Tyxi3h1fYZ/DgiFU6DC6bv3XIEJoZt+f/kNh8BrWFw==",
"dev": true,
"requires": {
"chalk": "2.0.1",
"chalk": "2.3.0",
"source-map": "0.5.6",
"supports-color": "4.2.1"
}
@@ -5937,7 +5939,7 @@
"integrity": "sha512-G6WnRmdTt2jvJvY+aY+M0AO4YlbxE+slKPZb+jG2P2U9Tyxi3h1fYZ/DgiFU6DC6bv3XIEJoZt+f/kNh8BrWFw==",
"dev": true,
"requires": {
"chalk": "2.0.1",
"chalk": "2.3.0",
"source-map": "0.5.6",
"supports-color": "4.2.1"
}
@@ -5969,7 +5971,7 @@
"integrity": "sha512-G6WnRmdTt2jvJvY+aY+M0AO4YlbxE+slKPZb+jG2P2U9Tyxi3h1fYZ/DgiFU6DC6bv3XIEJoZt+f/kNh8BrWFw==",
"dev": true,
"requires": {
"chalk": "2.0.1",
"chalk": "2.3.0",
"source-map": "0.5.6",
"supports-color": "4.2.1"
}
@@ -6001,7 +6003,7 @@
"integrity": "sha512-G6WnRmdTt2jvJvY+aY+M0AO4YlbxE+slKPZb+jG2P2U9Tyxi3h1fYZ/DgiFU6DC6bv3XIEJoZt+f/kNh8BrWFw==",
"dev": true,
"requires": {
"chalk": "2.0.1",
"chalk": "2.3.0",
"source-map": "0.5.6",
"supports-color": "4.2.1"
}
@@ -7303,6 +7305,19 @@
"setimmediate": "1.0.5"
}
},
"tinycolor2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.4.1.tgz",
"integrity": "sha1-9PrTM0R7wLB9TcjpIJ2POaisd+g="
},
"tinygradient": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/tinygradient/-/tinygradient-0.3.1.tgz",
"integrity": "sha1-LZ5PvjSMSX7RHih6QzaDWz/RECI=",
"requires": {
"tinycolor2": "1.4.1"
}
},
"tmp": {
"version": "0.0.31",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
+11 -2
View File
@@ -2,7 +2,15 @@
"name": "keppler",
"version": "1.2.1",
"description": "Real time code sharing for your lectures and presentations",
"keywords": ["keppler", "teach", "learn", "code", "presentation", "live-coding", "share"],
"keywords": [
"keppler",
"teach",
"learn",
"code",
"presentation",
"live-coding",
"share"
],
"bin": {
"keppler": "bin/index.js"
},
@@ -24,11 +32,13 @@
},
"homepage": "https://github.com/brunosimon/keppler",
"dependencies": {
"chalk": "^2.3.0",
"chokidar": "^1.7.0",
"colors": "^1.1.2",
"diff": "^3.3.0",
"express": "^4.15.3",
"glob": "^7.1.2",
"gradient-string": "^1.0.0",
"helmet": "^3.8.1",
"html-entities": "^1.2.1",
"ip": "^1.1.5",
@@ -51,7 +61,6 @@
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^2.0.1",
"connect-history-api-fallback": "^1.3.0",
"copy-to-clipboard": "^3.0.8",
"copy-webpack-plugin": "^4.0.1",