mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 16:30:11 +00:00
Move output messages to YAML.
This commit is contained in:
parent
88879257e6
commit
fc67f680ee
46
src/cli/msg.yml
Normal file
46
src/cli/msg.yml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
beforeCreate:
|
||||||
|
msg: Creating new **%s** resume: **%s**
|
||||||
|
beforeRead:
|
||||||
|
msg: Reading resume: **%s**
|
||||||
|
beforeTheme:
|
||||||
|
msg: Verifying theme: **%s**
|
||||||
|
afterTheme:
|
||||||
|
msg: Verifying outputs: ???
|
||||||
|
beforeMerge:
|
||||||
|
msg:
|
||||||
|
- Merging **%s**
|
||||||
|
- " onto **%s**"
|
||||||
|
afterMerge:
|
||||||
|
msg: Applying **%s** theme (%s format%s)
|
||||||
|
afterBuild:
|
||||||
|
msg:
|
||||||
|
- "The **%s** theme says:"
|
||||||
|
- |
|
||||||
|
"For best results view JSON Resume themes over a
|
||||||
|
local or remote HTTP connection. For example:
|
||||||
|
|
||||||
|
npm install http-server -g
|
||||||
|
http-server <resume-folder>
|
||||||
|
|
||||||
|
For more information, see the README."
|
||||||
|
beforeGenerate:
|
||||||
|
msg:
|
||||||
|
- " (with %s)"
|
||||||
|
- "Skipping %s resume: %s"
|
||||||
|
- "Generating **%s** resume: **%s**"
|
||||||
|
beforeAnalyze:
|
||||||
|
msg: "Analyzing **%s** resume: **%s**"
|
||||||
|
beforeConvert:
|
||||||
|
msg: "Converting **%s** (**%s**) to **%s** (**%s**)"
|
||||||
|
afterValidate:
|
||||||
|
msg:
|
||||||
|
- "Validating **%s** against the **%s** schema: "
|
||||||
|
- "VALID!"
|
||||||
|
- "INVALID"
|
||||||
|
- "BROKEN"
|
||||||
|
beforePeek:
|
||||||
|
msg:
|
||||||
|
- Peeking at **%s** in **%s**
|
||||||
|
- Peeking at **%s**
|
||||||
|
afterPeek:
|
||||||
|
msg: "The specified key **%s** was not found in **%s**."
|
@ -20,6 +20,8 @@ Output routines for HackMyResume.
|
|||||||
, FS = require('fs')
|
, FS = require('fs')
|
||||||
, EXTEND = require('../utils/extend')
|
, EXTEND = require('../utils/extend')
|
||||||
, HANDLEBARS = require('handlebars')
|
, HANDLEBARS = require('handlebars')
|
||||||
|
, YAML = require('yamljs')
|
||||||
|
, printf = require('printf')
|
||||||
, pad = require('string-padding');
|
, pad = require('string-padding');
|
||||||
|
|
||||||
|
|
||||||
@ -33,6 +35,7 @@ Output routines for HackMyResume.
|
|||||||
|
|
||||||
init: function( opts ) {
|
init: function( opts ) {
|
||||||
this.opts = EXTEND( true, this.opts || { }, opts );
|
this.opts = EXTEND( true, this.opts || { }, opts );
|
||||||
|
this.msgs = YAML.load(PATH.join( __dirname, 'msg.yml' ));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -60,41 +63,43 @@ Output routines for HackMyResume.
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.beforeCreate:
|
case HME.beforeCreate:
|
||||||
L(
|
L( M2C( this.msgs.beforeCreate.msg, 'green' ), evt.fmt, evt.file );
|
||||||
M2C('Creating new **%s** resume: **%s**', 'green'),
|
|
||||||
evt.fmt, evt.file
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.beforeRead:
|
case HME.beforeRead:
|
||||||
L(
|
L(
|
||||||
M2C('Reading resume: **%s**', 'cyan'), evt.file
|
M2C( this.msgs.beforeRead.msg, 'cyan' ), evt.file
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HME.afterRead:
|
||||||
|
break;
|
||||||
|
|
||||||
case HME.beforeTheme:
|
case HME.beforeTheme:
|
||||||
this.opts.debug && L(
|
this.opts.debug &&
|
||||||
M2C('Verifying theme: **%s**', 'cyan'), evt.theme.toUpperCase()
|
L( M2C( this.msgs.beforeTheme.msg, 'cyan'), evt.theme.toUpperCase() );
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.afterTheme:
|
case HME.afterTheme:
|
||||||
this.theme = evt.theme;
|
this.theme = evt.theme;
|
||||||
this.opts.debug && L( M2C('Verifying outputs: ???', 'cyan') );
|
this.opts.debug && L( M2C(this.msgs.beforeTheme.msg, 'cyan'), evt.theme );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.beforeMerge:
|
case HME.beforeMerge:
|
||||||
var msg = '';
|
var msg = '';
|
||||||
evt.f.reverse().forEach( function( a, idx ) {
|
evt.f.reverse().forEach( function( a, idx ) {
|
||||||
msg += ((idx === 0) ? chalk.cyan('Merging ') :
|
msg += printf(
|
||||||
chalk.cyan(' onto ')) + chalk.cyan.bold(a.i().file);
|
((idx === 0) ?
|
||||||
});
|
this.msgs.beforeMerge.msg[0] :
|
||||||
L( msg );
|
this.msgs.beforeMerge.msg[1] ), a.i().file
|
||||||
|
);
|
||||||
|
}, this);
|
||||||
|
L( M2C(msg, 'cyan') );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.afterMerge:
|
case HME.afterMerge:
|
||||||
var numFormats = Object.keys( this.theme.formats ).length;
|
var numFormats = Object.keys( this.theme.formats ).length;
|
||||||
L( M2C('Applying **%s** theme (%s format%s)', 'yellow'),
|
L( M2C(this.msgs.afterMerge.msg, 'yellow'),
|
||||||
this.theme.name.toUpperCase(),
|
this.theme.name.toUpperCase(),
|
||||||
numFormats, ( numFormats === 1 ? '' : 's') );
|
numFormats, ( numFormats === 1 ? '' : 's') );
|
||||||
break;
|
break;
|
||||||
@ -105,21 +110,12 @@ Output routines for HackMyResume.
|
|||||||
if( this.opts.tips && (this.theme.message || this.theme.render) ) {
|
if( this.opts.tips && (this.theme.message || this.theme.render) ) {
|
||||||
var WRAP = require('word-wrap');
|
var WRAP = require('word-wrap');
|
||||||
if( this.theme.message ) {
|
if( this.theme.message ) {
|
||||||
L( WRAP( chalk.gray('The ' + themeName + ' theme says: "') +
|
L( M2C( this.msgs.afterBuild.msg[0], 'cyan' ), themeName );
|
||||||
chalk.white(this.theme.message) + chalk.gray('"'),
|
L( M2C( this.theme.message, 'white' ));
|
||||||
{ width: this.opts.wrap, indent: '' } ));
|
|
||||||
}
|
}
|
||||||
else if ( this.theme.render ) {
|
else if ( this.theme.render ) {
|
||||||
L( M2C( 'The **' + themeName + '** theme says:', 'cyan'));
|
L( M2C( this.msgs.afterBuild.msg[0], 'cyan'), themeName);
|
||||||
L( WRAP( '"For best results view JSON Resume themes over a ' +
|
L( M2C( this.msgs.afterBuild.msg[1], 'white'));
|
||||||
'local or remote HTTP connection. For example:',
|
|
||||||
{ width: this.opts.wrap, indent: '' })
|
|
||||||
);
|
|
||||||
L('');
|
|
||||||
L(' npm install http-server -g\r' +
|
|
||||||
' http-server <resume-folder>' );
|
|
||||||
L('');
|
|
||||||
L(chalk.white('For more information, see the README."'));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,28 +126,23 @@ Output routines for HackMyResume.
|
|||||||
if( evt.fmt === 'pdf' ) {
|
if( evt.fmt === 'pdf' ) {
|
||||||
if( this.opts.pdf ) {
|
if( this.opts.pdf ) {
|
||||||
if( this.opts.pdf !== 'none' ) {
|
if( this.opts.pdf !== 'none' ) {
|
||||||
suffix = chalk.green(' (with ' + this.opts.pdf + ')');
|
suffix = printf( M2C( this.msgs.beforeGenerate.msg[0], 'green' ), this.opts.pdf );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
L( chalk.gray('Skipping ') +
|
L( M2C( this.msgs.beforeGenerate.msg[1], 'gray' ),
|
||||||
chalk.white.bold( pad(evt.fmt.toUpperCase(),4,null,pad.RIGHT)) +
|
evt.fmt.toUpperCase(), evt.file );
|
||||||
chalk.gray(' resume') + suffix + chalk.green(': ') +
|
|
||||||
chalk.white( evt.file ));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
L( chalk.green('Generating ') +
|
L( M2C( this.msgs.beforeGenerate.msg[2] + suffix, 'green' ),
|
||||||
chalk.green.bold(
|
pad(evt.fmt.toUpperCase(),4,null,pad.RIGHT),
|
||||||
pad(evt.fmt.toUpperCase(),4,null,pad.RIGHT)) +
|
PATH.relative(process.cwd(), evt.file ));
|
||||||
chalk.green(' resume') + suffix + chalk.green(': ') +
|
|
||||||
chalk.green.bold( PATH.relative(process.cwd(), evt.file )) );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.beforeAnalyze:
|
case HME.beforeAnalyze:
|
||||||
L(chalk.cyan('Analyzing ') + chalk.cyan.bold(evt.fmt) +
|
L( M2C( this.msgs.beforeAnalyze.msg, 'cyan' ), evt.fmt, evt.file);
|
||||||
chalk.cyan(' resume: ') + chalk.cyan.bold(evt.file));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.afterAnalyze:
|
case HME.afterAnalyze:
|
||||||
@ -167,17 +158,20 @@ Output routines for HackMyResume.
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.beforeConvert:
|
case HME.beforeConvert:
|
||||||
// TODO: Core should not log
|
L( M2C( this.msgs.beforeConvert.msg, 'green' ),
|
||||||
L( chalk.green('Converting ') + chalk.green.bold(evt.srcFile) +
|
evt.srcFile, evt.srcFmt, evt.dstFile, evt.dstFmt
|
||||||
chalk.green(' (' + evt.srcFmt + ') to ') + chalk.green.bold(evt.dstFile) +
|
);
|
||||||
chalk.green(' (' + evt.dstFmt + ').'));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.afterValidate:
|
case HME.afterValidate:
|
||||||
var style = evt.isValid ? 'green' : 'yellow';
|
var style = evt.isValid ? 'green' : 'yellow';
|
||||||
L( chalk.white('Validating ') + chalk.white.bold(evt.file) + chalk.white(' against ') +
|
L(
|
||||||
chalk.white.bold( evt.fmt ).toUpperCase() +
|
M2C( this.msgs.afterValidate.msg[0], 'white' ) +
|
||||||
chalk.white(' schema: ') + chalk[style].bold(evt.isValid ? 'VALID!' : 'INVALID'));
|
chalk[style].bold( evt.isValid ?
|
||||||
|
this.msgs.afterValidate.msg[1] :
|
||||||
|
this.msgs.afterValidate.msg[2] ),
|
||||||
|
evt.file, evt.fmt
|
||||||
|
);
|
||||||
|
|
||||||
if( evt.errors ) {
|
if( evt.errors ) {
|
||||||
_.each(evt.errors, function(err,idx) {
|
_.each(evt.errors, function(err,idx) {
|
||||||
@ -191,16 +185,16 @@ Output routines for HackMyResume.
|
|||||||
|
|
||||||
case HME.beforePeek:
|
case HME.beforePeek:
|
||||||
if( evt.target )
|
if( evt.target )
|
||||||
L(M2C('Peeking at **%s** in **%s**...', 'cyan'), evt.target, evt.file);
|
L(M2C(this.msgs.beforePeek.msg[0], 'cyan'), evt.target, evt.file);
|
||||||
else
|
else
|
||||||
L(M2C('Peeking at **%s**...', 'cyan'), evt.file);
|
L(M2C(this.msgs.beforePeek.msg[1], 'cyan'), evt.file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HME.afterPeek:
|
case HME.afterPeek:
|
||||||
if( evt.target )
|
if( evt.target )
|
||||||
console.dir( evt.target, { depth: null, colors: true } );
|
console.dir( evt.target, { depth: null, colors: true } );
|
||||||
else
|
else
|
||||||
L(M2C('The specified key **%s** was not found in **%s**.', 'yellow'), evt.requested, evt.file);
|
L(M2C( this.msgs.afterPeek.msg, 'yellow'), evt.requested, evt.file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ Implementation of the 'peek' verb for HackMyResume.
|
|||||||
if( obj.ex ) {
|
if( obj.ex ) {
|
||||||
this.err( obj.ex.fluenterror, obj.ex );
|
this.err( obj.ex.fluenterror, obj.ex );
|
||||||
}
|
}
|
||||||
var targ = objPath ? __.get( obj.json, objPath ) : obj;
|
var targ = objPath ? __.get( obj.json, objPath ) : obj.json;
|
||||||
|
|
||||||
this.stat( HMEVENT.afterPeek, { file: t, requested: objPath, target: targ } );
|
this.stat( HMEVENT.afterPeek, { file: t, requested: objPath, target: targ } );
|
||||||
}, this);
|
}, this);
|
||||||
|
Loading…
Reference in New Issue
Block a user