1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-02 20:37:08 +01:00

chore: update project dependencies

This commit is contained in:
hacksalot
2018-02-12 00:05:29 -05:00
parent 7144126175
commit c4f7350528
71 changed files with 1600 additions and 1737 deletions

38
dist/cli/error.js vendored
View File

@ -1,11 +1,11 @@
/**
Error-handling routines for HackMyResume.
@module cli/error
@license MIT. See LICENSE.md for details.
*/
(function() {
/**
Error-handling routines for HackMyResume.
@module cli/error
@license MIT. See LICENSE.md for details.
*/
/** Error handler for HackMyResume. All errors are handled here.
@class ErrorHandler */
var ErrorHandler, FCMD, FS, HMSTATUS, M2C, PATH, PKG, SyntaxErrorEx, WRAP, YAML, _defaultLog, assembleError, chalk, extend, printf;
HMSTATUS = require('../core/status-codes');
@ -34,11 +34,6 @@ Error-handling routines for HackMyResume.
require('string.prototype.startswith');
/** Error handler for HackMyResume. All errors are handled here.
@class ErrorHandler
*/
ErrorHandler = module.exports = {
init: function(debug, assert, silent) {
this.debug = debug;
@ -49,14 +44,20 @@ Error-handling routines for HackMyResume.
},
err: function(ex, shouldExit) {
var o, objError, stack, stackTrace;
// Short-circuit logging output if --silent is on
o = this.silent ? function() {} : _defaultLog;
if (ex.pass) {
// Special case; can probably be removed.
throw ex;
}
// Load error messages
this.msgs = this.msgs || require('./msg').errors;
// Handle packaged HMR exceptions
if (ex.fluenterror) {
// Output the error message
objError = assembleError.call(this, ex);
o(this['format_' + objError.etype](objError.msg));
// Output the stack (sometimes)
if (objError.withStack) {
stack = ex.stack || (ex.inner && ex.inner.stack);
stack && o(chalk.gray(stack));
@ -72,6 +73,7 @@ Error-handling routines for HackMyResume.
return process.exit(ex.fluenterror);
}
} else {
// Handle raw exceptions
o(ex);
stackTrace = ex.stack || (ex.inner && ex.inner.stack);
if (stackTrace && this.debug) {
@ -113,9 +115,15 @@ Error-handling routines for HackMyResume.
quit = false;
break;
case HMSTATUS.resumeNotFound:
//msg = M2C( this.msgs.resumeNotFound.msg, 'yellow' );
msg += M2C(FS.readFileSync(PATH.resolve(__dirname, 'help/' + ex.verb + '.txt'), 'utf8'), 'white', 'yellow');
break;
case HMSTATUS.missingCommand:
// msg = M2C( this.msgs.missingCommand.msg + " (", 'yellow');
// msg += Object.keys( FCMD.verbs ).map( (v, idx, ar) ->
// return ( if idx == ar.length - 1 then chalk.yellow('or ') else '') +
// chalk.yellow.bold(v.toUpperCase());
// ).join( chalk.yellow(', ')) + chalk.yellow(").\n\n");
msg += M2C(FS.readFileSync(PATH.resolve(__dirname, 'help/use.txt'), 'utf8'), 'white', 'yellow');
break;
case HMSTATUS.invalidCommand:
@ -224,6 +232,7 @@ Error-handling routines for HackMyResume.
etype = 'error';
break;
case HMSTATUS.createError:
// inner.code could be EPERM, EACCES, etc
msg = printf(M2C(this.msgs.createError.msg), ex.inner.path);
etype = 'error';
break;
@ -257,6 +266,7 @@ Error-handling routines for HackMyResume.
break;
case HMSTATUS.unknownSchema:
msg = M2C(this.msgs.unknownSchema.msg[0]);
//msg += "\n" + M2C( @msgs.unknownSchema.msg[1], 'yellow' )
etype = 'error';
break;
case HMSTATUS.themeHelperLoad:
@ -268,8 +278,8 @@ Error-handling routines for HackMyResume.
etype = 'error';
}
return {
msg: msg,
withStack: withStack,
msg: msg, // The error message to display
withStack: withStack, // Whether to include the stack
quit: quit,
etype: etype
};

123
dist/cli/main.js vendored
View File

@ -1,11 +1,28 @@
/**
Definition of the `main` function.
@module cli/main
@license MIT. See LICENSE.md for details.
*/
(function() {
/**
Definition of the `main` function.
@module cli/main
@license MIT. See LICENSE.md for details.
*/
/* Invoke a HackMyResume verb. */
/* Success handler for verb invocations. Calls process.exit by default */
/* Init options prior to setting up command infrastructure. */
/* Massage command-line args and setup Commander.js. */
/*
Initialize HackMyResume options.
TODO: Options loading is a little hacky, for two reasons:
- Commander.js idiosyncracies
- Need to accept JSON inputs from the command line.
*/
/* Simple logging placeholder. */
/*
A callable implementation of the HackMyResume CLI. Encapsulates the command
line interface as a single method accepting a parameter array.
@alias module:cli/main.main
@param rawArgs {Array} An array of command-line parameters. Will either be
process.argv (in production) or custom parameters (in test).
*/
/* Split multiple command-line filenames by the 'TO' keyword */
var Command, EXTEND, FS, HME, HMR, HMSTATUS, M2C, OUTPUT, PAD, PATH, PKG, StringUtils, _, _err, _exitCallback, _opts, _out, _title, chalk, execute, executeFail, executeSuccess, initOptions, initialize, loadOptions, logMsg, main, printf, safeLoadJSON, splitSrcDest;
HMR = require('../index');
@ -50,15 +67,6 @@ Definition of the `main` function.
_exitCallback = null;
/*
A callable implementation of the HackMyResume CLI. Encapsulates the command
line interface as a single method accepting a parameter array.
@alias module:cli/main.main
@param rawArgs {Array} An array of command-line parameters. Will either be
process.argv (in production) or custom parameters (in test).
*/
main = module.exports = function(rawArgs, exitCallback) {
var args, initInfo, program;
initInfo = initialize(rawArgs, exitCallback);
@ -66,33 +74,41 @@ Definition of the `main` function.
return;
}
args = initInfo.args;
// Create the top-level (application) command...
program = new Command('hackmyresume').version(PKG.version).description(chalk.yellow.bold('*** HackMyResume ***')).option('-s --silent', 'Run in silent mode').option('--no-color', 'Disable colors').option('--color', 'Enable colors').option('-d --debug', 'Enable diagnostics', false).option('-a --assert', 'Treat warnings as errors', false).option('-v --version', 'Show the version').allowUnknownOption();
program.jsonArgs = initInfo.options;
program.command('new')["arguments"]('<sources...>').option('-f --format <fmt>', 'FRESH or JRS format', 'FRESH').alias('create').description('Create resume(s) in FRESH or JSON RESUME format.').action((function(sources) {
// Create the NEW command
program.command('new').arguments('<sources...>').option('-f --format <fmt>', 'FRESH or JRS format', 'FRESH').alias('create').description('Create resume(s) in FRESH or JSON RESUME format.').action((function(sources) {
execute.call(this, sources, [], this.opts(), logMsg);
}));
program.command('validate')["arguments"]('<sources...>').description('Validate a resume in FRESH or JSON RESUME format.').action(function(sources) {
// Create the VALIDATE command
program.command('validate').arguments('<sources...>').description('Validate a resume in FRESH or JSON RESUME format.').action(function(sources) {
execute.call(this, sources, [], this.opts(), logMsg);
});
// Create the CONVERT command
program.command('convert').description('Convert a resume to/from FRESH or JSON RESUME format.').option('-f --format <fmt>', 'FRESH or JRS format and optional version', void 0).action(function() {
var x;
x = splitSrcDest.call(this);
execute.call(this, x.src, x.dst, this.opts(), logMsg);
});
program.command('analyze')["arguments"]('<sources...>').option('--private', 'Include resume fields marked as private', false).description('Analyze one or more resumes.').action(function(sources) {
// Create the ANALYZE command
program.command('analyze').arguments('<sources...>').option('--private', 'Include resume fields marked as private', false).description('Analyze one or more resumes.').action(function(sources) {
execute.call(this, sources, [], this.opts(), logMsg);
});
program.command('peek')["arguments"]('<sources...>').description('Peek at a resume field or section').action(function(sources, sectionOrField) {
// Create the PEEK command
program.command('peek').arguments('<sources...>').description('Peek at a resume field or section').action(function(sources, sectionOrField) {
var dst;
dst = sources && sources.length > 1 ? [sources.pop()] : [];
dst = (sources && sources.length > 1) ? [sources.pop()] : [];
execute.call(this, sources, dst, this.opts(), logMsg);
});
// Create the BUILD command
program.command('build').alias('generate').option('-t --theme <theme>', 'Theme name or path').option('-n --no-prettify', 'Disable HTML prettification', true).option('-c --css <option>', 'CSS linking / embedding').option('-p --pdf <engine>', 'PDF generation engine').option('--no-sort', 'Sort resume sections by date', false).option('--tips', 'Display theme tips and warnings.', false).option('--private', 'Include resume fields marked as private', false).option('--no-escape', "Turn off encoding in Handlebars themes.", false).description('Generate resume to multiple formats').action(function(sources, targets, options) {
var x;
x = splitSrcDest.call(this);
execute.call(this, x.src, x.dst, this.opts(), logMsg);
});
program.command('help')["arguments"]('[command]').description('Get help on a HackMyResume command').action(function(cmd) {
// Create the HELP command
program.command('help').arguments('[command]').description('Get help on a HackMyResume command').action(function(cmd) {
var manPage;
cmd = cmd || 'use';
manPage = FS.readFileSync(PATH.join(__dirname, 'help/' + cmd + '.txt'), 'utf8');
@ -106,9 +122,6 @@ Definition of the `main` function.
}
};
/* Massage command-line args and setup Commander.js. */
initialize = function(ar, exitCallback) {
var o;
_exitCallback = exitCallback || process.exit;
@ -131,6 +144,7 @@ Definition of the `main` function.
return null;
}
o.silent || logMsg(_title);
// Emit debug prelude if --debug was specified
if (o.debug) {
_out.log(chalk.cyan('The -d or --debug switch was specified. DEBUG mode engaged.'));
_out.log('');
@ -138,9 +152,12 @@ Definition of the `main` function.
_out.log(chalk.cyan(PAD(' Node.js:', 25, null, PAD.RIGHT)) + chalk.cyan.bold(process.version));
_out.log(chalk.cyan(PAD(' HackMyResume:', 25, null, PAD.RIGHT)) + chalk.cyan.bold('v' + PKG.version));
_out.log(chalk.cyan(PAD(' FRESCA:', 25, null, PAD.RIGHT)) + chalk.cyan.bold(PKG.dependencies.fresca));
//_out.log(chalk.cyan(PAD(' fresh-themes:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-themes'] ))
//_out.log(chalk.cyan(PAD(' fresh-jrs-converter:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-jrs-converter'] ))
_out.log('');
}
_err.init(o.debug, o.assert, o.silent);
// Handle invalid verbs here (a bit easier here than in commander.js)...
if (o.verb && !HMR.verbs[o.verb] && !HMR.alias[o.verb] && o.verb !== 'help') {
_err.err({
fluenterror: HMSTATUS.invalidCommand,
@ -148,6 +165,7 @@ Definition of the `main` function.
attempted: o.orgVerb
}, true);
}
// Override the .missingArgument behavior
Command.prototype.missingArgument = function(name) {
if (this.name() !== 'help') {
_err.err({
@ -156,6 +174,7 @@ Definition of the `main` function.
}, true);
}
};
// Override the .helpInformation behavior
Command.prototype.helpInformation = function() {
var manPage;
manPage = FS.readFileSync(PATH.join(__dirname, 'help/use.txt'), 'utf8');
@ -167,17 +186,16 @@ Definition of the `main` function.
};
};
/* Init options prior to setting up command infrastructure. */
initOptions = function(ar) {
oVerb;
/* jshint ignore:end */
var args, cleanArgs, inf, isAssert, isDebug, isMono, isNoEscape, isSilent, oJSON, oVerb, optStr, optsIdx, verb, vidx;
verb = '';
args = ar.slice();
cleanArgs = args.slice(2);
oJSON;
if (cleanArgs.length) {
// Support case-insensitive sub-commands (build, generate, validate, etc)
vidx = _.findIndex(cleanArgs, function(v) {
return v[0] !== '-';
});
@ -185,6 +203,7 @@ Definition of the `main` function.
oVerb = cleanArgs[vidx];
verb = args[vidx + 2] = oVerb.trim().toLowerCase();
}
// Remove --options --opts -o and process separately
optsIdx = _.findIndex(cleanArgs, function(v) {
return v === '-o' || v === '--options' || v === '--opts';
});
@ -192,12 +211,11 @@ Definition of the `main` function.
optStr = cleanArgs[optsIdx + 1];
args.splice(optsIdx + 2, 2);
if (optStr && (optStr = optStr.trim())) {
//var myJSON = JSON.parse(optStr);
if (optStr[0] === '{') {
// TODO: remove use of evil(). - hacksalot
/* jshint ignore:start */
oJSON = eval('(' + optStr + ')');
/* jshint ignore:end */
oJSON = eval('(' + optStr + ')'); // jshint ignore:line <-- no worky
} else {
inf = safeLoadJSON(optStr);
if (!inf.ex) {
@ -209,6 +227,7 @@ Definition of the `main` function.
}
}
}
// Grab the --debug flag, --silent, --assert and --no-color flags
isDebug = _.some(args, function(v) {
return v === '-d' || v === '--debug';
});
@ -237,35 +256,35 @@ Definition of the `main` function.
};
};
/* Invoke a HackMyResume verb. */
execute = function(src, dst, opts, log) {
var prom, v;
// Create the verb
v = new HMR.verbs[this.name()]();
// Initialize command-specific options
loadOptions.call(this, opts, this.parent.jsonArgs);
// Set up error/output handling
_opts.errHandler = v;
_out.init(_opts);
// Hook up event notifications
v.on('hmr:status', function() {
return _out["do"].apply(_out, arguments);
return _out.do.apply(_out, arguments);
});
v.on('hmr:error', function() {
return _err.err.apply(_err, arguments);
});
// Invoke the verb using promise syntax
prom = v.invoke.call(v, src, dst, _opts, log);
prom.then(executeSuccess, executeFail);
};
/* Success handler for verb invocations. Calls process.exit by default */
executeSuccess = function(obj) {};
// Can't call _exitCallback here (process.exit) when PDF is running in BK
//_exitCallback 0; return
/* Failure handler for verb invocations. Calls process.exit by default */
executeFail = function(err) {
var finalErrorCode, msgs;
//console.dir err
finalErrorCode = -1;
if (err) {
if (err.fluenterror) {
@ -286,19 +305,16 @@ Definition of the `main` function.
_exitCallback(finalErrorCode);
};
/*
Initialize HackMyResume options.
TODO: Options loading is a little hacky, for two reasons:
- Commander.js idiosyncracies
- Need to accept JSON inputs from the command line.
*/
loadOptions = function(o, cmdO) {
// o and this.opts() seem to be the same (command-specific options)
// Load the specified options file (if any) and apply options
if (cmdO) {
o = EXTEND(true, o, cmdO);
}
// Merge in command-line options
o = EXTEND(true, o, this.opts());
// Kludge parent-level options until piping issue is resolved
if (this.parent.silent !== void 0 && this.parent.silent !== null) {
o.silent = this.parent.silent;
}
@ -318,9 +334,6 @@ Definition of the `main` function.
EXTEND(true, _opts, o);
};
/* Split multiple command-line filenames by the 'TO' keyword */
splitSrcDest = function() {
var params, splitAt;
params = this.parent.args.filter(function(j) {
@ -328,14 +341,17 @@ Definition of the `main` function.
});
if (params.length === 0) {
throw {
//tmpName = @name()
fluenterror: HMSTATUS.resumeNotFound,
verb: this.name(),
quit: true
};
}
// Find the TO keyword, if any
splitAt = _.findIndex(params, function(p) {
return p.toLowerCase() === 'to';
});
// TO can't be the last keyword
if (splitAt === params.length - 1 && splitAt !== -1) {
logMsg(chalk.yellow('Please ') + chalk.yellow.bold('specify an output file') + chalk.yellow(' for this operation or ') + chalk.yellow.bold('omit the TO keyword') + chalk.yellow('.'));
return;
@ -346,9 +362,6 @@ Definition of the `main` function.
};
};
/* Simple logging placeholder. */
logMsg = function() {
return _opts.silent || console.log.apply(console.log, arguments);
};

12
dist/cli/msg.js vendored
View File

@ -1,11 +1,9 @@
/**
Message-handling routines for HackMyResume.
@module cli/msg
@license MIT. See LICENSE.md for details.
*/
(function() {
/**
Message-handling routines for HackMyResume.
@module cli/msg
@license MIT. See LICENSE.md for details.
*/
var PATH, YAML;
PATH = require('path');

40
dist/cli/out.js vendored
View File

@ -1,11 +1,9 @@
/**
Output routines for HackMyResume.
@license MIT. See LICENSE.md for details.
@module cli/out
*/
(function() {
/**
Output routines for HackMyResume.
@license MIT. See LICENSE.md for details.
@module cli/out
*/
var EXTEND, FS, HANDLEBARS, HME, LO, M2C, OutputHandler, PATH, YAML, _, chalk, dbgStyle, pad, printf;
chalk = require('chalk');
@ -34,29 +32,26 @@ Output routines for HackMyResume.
dbgStyle = 'cyan';
/** A stateful output module. All HMR console output handled here. */
module.exports = OutputHandler = (function() {
function OutputHandler(opts) {
module.exports = OutputHandler = class OutputHandler {
constructor(opts) {
this.init(opts);
return;
}
OutputHandler.prototype.init = function(opts) {
init(opts) {
this.opts = EXTEND(true, this.opts || {}, opts);
this.msgs = YAML.load(PATH.join(__dirname, 'msg.yml')).events;
};
}
OutputHandler.prototype.log = function(msg) {
log(msg) {
var finished;
msg = msg || '';
printf = require('printf');
finished = printf.apply(printf, arguments);
return this.opts.silent || console.log(finished);
};
}
OutputHandler.prototype["do"] = function(evt) {
do(evt) {
var L, WRAP, adj, info, msg, msgs, numFormats, output, rawTpl, sty, style, suffix, template, that, themeName, tot;
that = this;
L = function() {
@ -65,6 +60,9 @@ Output routines for HackMyResume.
switch (evt.sub) {
case HME.begin:
return this.opts.debug && L(M2C(this.msgs.begin.msg, dbgStyle), evt.cmd.toUpperCase());
//when HME.beforeCreate
//L( M2C( this.msgs.beforeCreate.msg, 'green' ), evt.fmt, evt.file )
//break;
case HME.afterCreate:
L(M2C(this.msgs.beforeCreate.msg, evt.isError ? 'red' : 'green'), evt.fmt, evt.file);
break;
@ -166,11 +164,13 @@ Output routines for HackMyResume.
break;
case HME.afterPeek:
sty = evt.error ? 'red' : (evt.target !== void 0 ? 'green' : 'yellow');
// "Peeking at 'someKey' in 'someFile'."
if (evt.requested) {
L(M2C(this.msgs.beforePeek.msg[0], sty), evt.requested, evt.file);
} else {
L(M2C(this.msgs.beforePeek.msg[1], sty), evt.file);
}
// If the key was present, print it
if (evt.target !== void 0 && !evt.error) {
return console.dir(evt.target, {
depth: null,
@ -182,11 +182,9 @@ Output routines for HackMyResume.
return L(chalk.red(evt.error.inner.inner));
}
}
};
}
return OutputHandler;
})();
};
}).call(this);