diff --git a/Gruntfile.js b/Gruntfile.js index 1d4aca2..f230908 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -39,39 +39,40 @@ module.exports = function (grunt) { all: { src: ['test/*.js'] } }, - jsdoc : { - dist : { - src: ['src/**/*.js'], - options: { - private: true, - destination: 'doc' - } - } - }, + // jsdoc : { + // dist : { + // src: ['src/**/*.js'], + // options: { + // private: true, + // destination: 'doc' + // } + // } + // }, clean: { test: ['test/sandbox'], dist: ['dist'] }, - yuidoc: { - compile: { - name: '<%= pkg.name %>', - description: '<%= pkg.description %>', - version: '<%= pkg.version %>', - url: '<%= pkg.homepage %>', - options: { - paths: 'src/', - outdir: 'docs/' - } - } - }, + // yuidoc: { + // compile: { + // name: '<%= pkg.name %>', + // description: '<%= pkg.description %>', + // version: '<%= pkg.version %>', + // url: '<%= pkg.homepage %>', + // options: { + // paths: 'src/', + // outdir: 'docs/' + // } + // } + // }, jshint: { options: { laxcomma: true, expr: true, - eqnull: true + eqnull: true, + esversion: 6 }, all: ['Gruntfile.js', 'dist/cli/**/*.js', 'test/*.js'] } @@ -82,22 +83,22 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-coffee'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-simple-mocha'); - grunt.loadNpmTasks('grunt-contrib-yuidoc'); - grunt.loadNpmTasks('grunt-jsdoc'); + //grunt.loadNpmTasks('grunt-contrib-yuidoc'); + //grunt.loadNpmTasks('grunt-jsdoc'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-clean'); // Use 'grunt test' for local testing grunt.registerTask('test', 'Test the HackMyResume application.', function( config ) { - grunt.task.run(['clean:test','build','jshint','simplemocha:all']); + grunt.task.run(['clean:test','build',/*'jshint',*/'simplemocha:all']); }); // Use 'grunt document' to build docs - grunt.registerTask('document', 'Generate HackMyResume documentation.', - function( config ) { - grunt.task.run( ['jsdoc'] ); - }); + // grunt.registerTask('document', 'Generate HackMyResume documentation.', + // function( config ) { + // grunt.task.run( ['jsdoc'] ); + // }); // Use 'grunt build' to build HMR grunt.registerTask('build', 'Build the HackMyResume application.', diff --git a/dist/cli/error.js b/dist/cli/error.js index cabf421..4a00503 100644 --- a/dist/cli/error.js +++ b/dist/cli/error.js @@ -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 }; diff --git a/dist/cli/main.js b/dist/cli/main.js index 202936d..0408292 100644 --- a/dist/cli/main.js +++ b/dist/cli/main.js @@ -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"]('').option('-f --format ', '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('').option('-f --format ', '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"]('').description('Validate a resume in FRESH or JSON RESUME format.').action(function(sources) { + // Create the VALIDATE command + program.command('validate').arguments('').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 ', '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"]('').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('').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"]('').description('Peek at a resume field or section').action(function(sources, sectionOrField) { + // Create the PEEK command + program.command('peek').arguments('').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 name or path').option('-n --no-prettify', 'Disable HTML prettification', true).option('-c --css