mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-03 04:47:07 +01:00
Asynchrony.
This commit is contained in:
11
dist/cli/error.js
vendored
11
dist/cli/error.js
vendored
@ -35,8 +35,7 @@ Error-handling routines for HackMyResume.
|
||||
require('string.prototype.startswith');
|
||||
|
||||
|
||||
/**
|
||||
Error handler for HackMyResume. All errors are handled here.
|
||||
/** Error handler for HackMyResume. All errors are handled here.
|
||||
@class ErrorHandler
|
||||
*/
|
||||
|
||||
@ -62,7 +61,7 @@ Error-handling routines for HackMyResume.
|
||||
stack = ex.stack || (ex.inner && ex.inner.stack);
|
||||
stack && o(chalk.gray(stack));
|
||||
}
|
||||
if (ex.quit || objError.quit) {
|
||||
if (shouldExit) {
|
||||
if (this.debug) {
|
||||
o(chalk.cyan('Exiting with error code ' + ex.fluenterror.toString()));
|
||||
}
|
||||
@ -221,6 +220,10 @@ Error-handling routines for HackMyResume.
|
||||
msg = ex;
|
||||
}
|
||||
etype = 'error';
|
||||
break;
|
||||
case HMSTATUS.createError:
|
||||
msg = printf(M2C(this.msgs.createError.msg), ex.inner.path);
|
||||
etype = 'error';
|
||||
}
|
||||
return {
|
||||
msg: msg,
|
||||
@ -231,3 +234,5 @@ Error-handling routines for HackMyResume.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=error.js.map
|
||||
|
44
dist/cli/main.js
vendored
44
dist/cli/main.js
vendored
@ -6,7 +6,7 @@ Definition of the `main` function.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var Command, EXTEND, FS, HME, HMR, HMSTATUS, OUTPUT, PAD, PATH, PKG, StringUtils, _, _opts, _out, _title, chalk, execute, initOptions, initialize, loadOptions, logMsg, main, safeLoadJSON, splitSrcDest;
|
||||
var Command, EXTEND, FS, HME, HMR, HMSTATUS, OUTPUT, PAD, PATH, PKG, StringUtils, _, _err, _exitCallback, _opts, _out, _title, chalk, execute, initOptions, initialize, loadOptions, logMsg, main, safeLoadJSON, splitSrcDest;
|
||||
|
||||
HMR = require('../index');
|
||||
|
||||
@ -42,6 +42,10 @@ Definition of the `main` function.
|
||||
|
||||
_out = new OUTPUT(_opts);
|
||||
|
||||
_err = require('./error');
|
||||
|
||||
_exitCallback = null;
|
||||
|
||||
|
||||
/*
|
||||
A callable implementation of the HackMyResume CLI. Encapsulates the command
|
||||
@ -51,9 +55,9 @@ Definition of the `main` function.
|
||||
process.argv (in production) or custom parameters (in test).
|
||||
*/
|
||||
|
||||
main = module.exports = function(rawArgs) {
|
||||
main = module.exports = function(rawArgs, exitCallback) {
|
||||
var args, initInfo, program;
|
||||
initInfo = initialize(rawArgs);
|
||||
initInfo = initialize(rawArgs, exitCallback);
|
||||
args = initInfo.args;
|
||||
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;
|
||||
@ -92,8 +96,9 @@ Definition of the `main` function.
|
||||
|
||||
/* Massage command-line args and setup Commander.js. */
|
||||
|
||||
initialize = function(ar) {
|
||||
initialize = function(ar, exitCallback) {
|
||||
var o;
|
||||
_exitCallback = exitCallback || process.exit;
|
||||
o = initOptions(ar);
|
||||
o.silent || logMsg(_title);
|
||||
if (o.debug) {
|
||||
@ -105,12 +110,13 @@ Definition of the `main` function.
|
||||
_out.log(chalk.cyan(PAD(' FRESCA:', 25, null, PAD.RIGHT)) + chalk.cyan.bold(PKG.dependencies.fresca));
|
||||
_out.log('');
|
||||
}
|
||||
_err.init(o.debug, o.assert, o.silent);
|
||||
if (o.verb && !HMR.verbs[o.verb] && !HMR.alias[o.verb]) {
|
||||
throw {
|
||||
_err.err({
|
||||
fluenterror: HMSTATUS.invalidCommand,
|
||||
quit: true,
|
||||
attempted: o.orgVerb
|
||||
};
|
||||
}, true);
|
||||
}
|
||||
Command.prototype.missingArgument = function(name) {
|
||||
if (this.name() !== 'new') {
|
||||
@ -136,7 +142,7 @@ Definition of the `main` function.
|
||||
|
||||
initOptions = function(ar) {
|
||||
oVerb;
|
||||
var args, cleanArgs, inf, isDebug, isMono, isSilent, oJSON, oVerb, optStr, optsIdx, verb, vidx;
|
||||
var args, cleanArgs, inf, isAssert, isDebug, isMono, isSilent, oJSON, oVerb, optStr, optsIdx, verb, vidx;
|
||||
verb = '';
|
||||
args = ar.slice();
|
||||
cleanArgs = args.slice(2);
|
||||
@ -177,6 +183,9 @@ Definition of the `main` function.
|
||||
isSilent = _.some(args, function(v) {
|
||||
return v === '-s' || v === '--silent';
|
||||
});
|
||||
isAssert = _.some(args, function(v) {
|
||||
return v === '-a' || v === '--assert';
|
||||
});
|
||||
isMono = _.some(args, function(v) {
|
||||
return v === '--no-color';
|
||||
});
|
||||
@ -184,6 +193,7 @@ Definition of the `main` function.
|
||||
color: !isMono,
|
||||
debug: isDebug,
|
||||
silent: isSilent,
|
||||
assert: isAssert,
|
||||
orgVerb: oVerb,
|
||||
verb: verb,
|
||||
json: oJSON,
|
||||
@ -195,24 +205,22 @@ Definition of the `main` function.
|
||||
/* Invoke a HackMyResume verb. */
|
||||
|
||||
execute = function(src, dst, opts, log) {
|
||||
var hand, v;
|
||||
loadOptions.call(this, opts, this.parent.jsonArgs);
|
||||
hand = require('./error');
|
||||
hand.init(_opts.debug, _opts.assert, _opts.silent);
|
||||
var onFail, prom, v;
|
||||
v = new HMR.verbs[this.name()]();
|
||||
loadOptions.call(this, opts, this.parent.jsonArgs);
|
||||
_opts.errHandler = v;
|
||||
_out.init(_opts);
|
||||
v.on('hmr:status', function() {
|
||||
return _out["do"].apply(_out, arguments);
|
||||
});
|
||||
v.on('hmr:error', function() {
|
||||
return hand.err.apply(hand, arguments);
|
||||
return _err.err.apply(_err, arguments);
|
||||
});
|
||||
v.invoke.call(v, src, dst, _opts, log);
|
||||
if (v.errorCode) {
|
||||
console.log('Exiting with error code ' + v.errorCode);
|
||||
return process.exit(v.errorCode);
|
||||
}
|
||||
prom = v.invoke.call(v, src, dst, _opts, log);
|
||||
onFail = function(err) {
|
||||
_exitCallback(err.fluenterror ? err.fluenterror : err);
|
||||
};
|
||||
prom.then((function() {}), onFail);
|
||||
};
|
||||
|
||||
|
||||
@ -282,3 +290,5 @@ Definition of the `main` function.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=main.js.map
|
||||
|
2
dist/cli/msg.js
vendored
2
dist/cli/msg.js
vendored
@ -15,3 +15,5 @@ Message-handling routines for HackMyResume.
|
||||
module.exports = YAML.load(PATH.join(__dirname, 'msg.yml'));
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=msg.js.map
|
||||
|
4
dist/cli/msg.yml
vendored
4
dist/cli/msg.yml
vendored
@ -3,6 +3,8 @@ events:
|
||||
msg: Invoking **%s** command.
|
||||
beforeCreate:
|
||||
msg: Creating new **%s** resume: **%s**
|
||||
afterCreate:
|
||||
msg: Creating new **%s** resume: **%s**
|
||||
afterRead:
|
||||
msg: Reading **%s** resume: **%s**
|
||||
beforeTheme:
|
||||
@ -96,3 +98,5 @@ errors:
|
||||
msg: "Invalid number of parameters. Expected: **%s**."
|
||||
missingParam:
|
||||
msg: The '**%s**' parameter was needed but not supplied.
|
||||
createError:
|
||||
msg: Failed to create **'%s'**.
|
||||
|
6
dist/cli/out.js
vendored
6
dist/cli/out.js
vendored
@ -60,8 +60,8 @@ Output routines for HackMyResume.
|
||||
switch (evt.sub) {
|
||||
case HME.begin:
|
||||
return this.opts.debug && L(M2C(this.msgs.begin.msg, dbgStyle), evt.cmd.toUpperCase());
|
||||
case HME.beforeCreate:
|
||||
L(M2C(this.msgs.beforeCreate.msg, 'green'), evt.fmt, evt.file);
|
||||
case HME.afterCreate:
|
||||
L(M2C(this.msgs.beforeCreate.msg, evt.isError ? 'red' : 'green'), evt.fmt, evt.file);
|
||||
break;
|
||||
case HME.beforeTheme:
|
||||
return this.opts.debug && L(M2C(this.msgs.beforeTheme.msg, dbgStyle), evt.theme.toUpperCase());
|
||||
@ -155,3 +155,5 @@ Output routines for HackMyResume.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=out.js.map
|
||||
|
2
dist/core/abstract-resume.js
vendored
2
dist/core/abstract-resume.js
vendored
@ -69,3 +69,5 @@ Definition of the AbstractResume class.
|
||||
module.exports = AbstractResume;
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=abstract-resume.js.map
|
||||
|
2
dist/core/default-formats.js
vendored
2
dist/core/default-formats.js
vendored
@ -58,3 +58,5 @@ Event code definitions.
|
||||
];
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=default-formats.js.map
|
||||
|
2
dist/core/default-options.js
vendored
2
dist/core/default-options.js
vendored
@ -16,3 +16,5 @@ Event code definitions.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=default-options.js.map
|
||||
|
2
dist/core/event-codes.js
vendored
2
dist/core/event-codes.js
vendored
@ -37,3 +37,5 @@ Event code definitions.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=event-codes.js.map
|
||||
|
2
dist/core/fluent-date.js
vendored
2
dist/core/fluent-date.js
vendored
@ -103,3 +103,5 @@ The HackMyResume date representation.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=fluent-date.js.map
|
||||
|
2
dist/core/fresh-resume.js
vendored
2
dist/core/fresh-resume.js
vendored
@ -517,3 +517,5 @@ Definition of the FRESHResume class.
|
||||
module.exports = FreshResume;
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=fresh-resume.js.map
|
||||
|
2
dist/core/fresh-theme.js
vendored
2
dist/core/fresh-theme.js
vendored
@ -277,3 +277,5 @@ Definition of the FRESHTheme class.
|
||||
module.exports = FRESHTheme;
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=fresh-theme.js.map
|
||||
|
2
dist/core/jrs-resume.js
vendored
2
dist/core/jrs-resume.js
vendored
@ -429,3 +429,5 @@ Definition of the JRSResume class.
|
||||
module.exports = JRSResume;
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=jrs-resume.js.map
|
||||
|
2
dist/core/jrs-theme.js
vendored
2
dist/core/jrs-theme.js
vendored
@ -103,3 +103,5 @@ Definition of the JRSTheme class.
|
||||
module.exports = JRSTheme;
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=jrs-theme.js.map
|
||||
|
15
dist/core/resume-factory.js
vendored
15
dist/core/resume-factory.js
vendored
@ -83,7 +83,7 @@ Definition of the ResumeFactory class.
|
||||
};
|
||||
|
||||
_parse = function(fileName, opts, eve) {
|
||||
var ex, orgFormat, rawData, ret;
|
||||
var orgFormat, rawData, ret;
|
||||
rawData = null;
|
||||
try {
|
||||
eve && eve.stat(HME.beforeRead, {
|
||||
@ -108,20 +108,15 @@ Definition of the ResumeFactory class.
|
||||
});
|
||||
return ret;
|
||||
} catch (_error) {
|
||||
ex = {
|
||||
return {
|
||||
fluenterror: rawData ? HACKMYSTATUS.parseError : HACKMYSTATUS.readError,
|
||||
inner: _error,
|
||||
raw: rawData,
|
||||
file: fileName,
|
||||
shouldExit: false
|
||||
file: fileName
|
||||
};
|
||||
opts.quit && (ex.quit = true);
|
||||
eve && eve.err(ex.fluenterror, ex);
|
||||
if (opts["throw"]) {
|
||||
throw ex;
|
||||
}
|
||||
return ex;
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=resume-factory.js.map
|
||||
|
5
dist/core/status-codes.js
vendored
5
dist/core/status-codes.js
vendored
@ -31,7 +31,10 @@ Status codes for HackMyResume.
|
||||
compileTemplate: 21,
|
||||
themeLoad: 22,
|
||||
invalidParamCount: 23,
|
||||
missingParam: 24
|
||||
missingParam: 24,
|
||||
createError: 25
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=status-codes.js.map
|
||||
|
2
dist/generators/base-generator.js
vendored
2
dist/generators/base-generator.js
vendored
@ -31,3 +31,5 @@ Definition of the BaseGenerator class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=base-generator.js.map
|
||||
|
2
dist/generators/html-generator.js
vendored
2
dist/generators/html-generator.js
vendored
@ -40,3 +40,5 @@ Definition of the HTMLGenerator class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=html-generator.js.map
|
||||
|
15
dist/generators/html-pdf-cli-generator.js
vendored
15
dist/generators/html-pdf-cli-generator.js
vendored
@ -46,8 +46,19 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/* Low-level error callback for spawn(). May be called after HMR process
|
||||
termination, so object references may not be valid here. That's okay; if
|
||||
the references are invalid, the error was already logged. We could use
|
||||
spawn-watch here but that causes issues on legacy Node.js.
|
||||
*/
|
||||
onError: function(ex, param) {
|
||||
param.errHandler.err(HMSTATUS.pdfGeneration, ex);
|
||||
var ref;
|
||||
if ((ref = param.errHandler) != null) {
|
||||
if (typeof ref.err === "function") {
|
||||
ref.err(HMSTATUS.pdfGeneration, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -86,3 +97,5 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=html-pdf-cli-generator.js.map
|
||||
|
2
dist/generators/html-png-generator.js
vendored
2
dist/generators/html-png-generator.js
vendored
@ -62,3 +62,5 @@ Definition of the HtmlPngGenerator class.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=html-png-generator.js.map
|
||||
|
2
dist/generators/json-generator.js
vendored
2
dist/generators/json-generator.js
vendored
@ -43,3 +43,5 @@ Definition of the JsonGenerator class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=json-generator.js.map
|
||||
|
5
dist/generators/json-yaml-generator.js
vendored
5
dist/generators/json-yaml-generator.js
vendored
@ -31,8 +31,11 @@ Definition of the JsonYamlGenerator class.
|
||||
generate: function(rez, f, opts) {
|
||||
var data;
|
||||
data = YAML.stringify(JSON.parse(rez.stringify()), Infinity, 2);
|
||||
return FS.writeFileSync(f, data, 'utf8');
|
||||
FS.writeFileSync(f, data, 'utf8');
|
||||
return data;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=json-yaml-generator.js.map
|
||||
|
2
dist/generators/latex-generator.js
vendored
2
dist/generators/latex-generator.js
vendored
@ -22,3 +22,5 @@ Definition of the LaTeXGenerator class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=latex-generator.js.map
|
||||
|
2
dist/generators/markdown-generator.js
vendored
2
dist/generators/markdown-generator.js
vendored
@ -22,3 +22,5 @@ Definition of the MarkdownGenerator class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=markdown-generator.js.map
|
||||
|
2
dist/generators/template-generator.js
vendored
2
dist/generators/template-generator.js
vendored
@ -241,3 +241,5 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=template-generator.js.map
|
||||
|
2
dist/generators/text-generator.js
vendored
2
dist/generators/text-generator.js
vendored
@ -22,3 +22,5 @@ Definition of the TextGenerator class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=text-generator.js.map
|
||||
|
2
dist/generators/word-generator.js
vendored
2
dist/generators/word-generator.js
vendored
@ -17,3 +17,5 @@ Definition of the WordGenerator class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=word-generator.js.map
|
||||
|
2
dist/generators/xml-generator.js
vendored
2
dist/generators/xml-generator.js
vendored
@ -22,3 +22,5 @@ Definition of the XMLGenerator class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=xml-generator.js.map
|
||||
|
2
dist/generators/yaml-generator.js
vendored
2
dist/generators/yaml-generator.js
vendored
@ -22,3 +22,5 @@ Definition of the YAMLGenerator class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=yaml-generator.js.map
|
||||
|
2
dist/helpers/console-helpers.js
vendored
2
dist/helpers/console-helpers.js
vendored
@ -62,3 +62,5 @@ Generic template helper definitions for command-line output.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=console-helpers.js.map
|
||||
|
2
dist/helpers/generic-helpers.js
vendored
2
dist/helpers/generic-helpers.js
vendored
@ -614,3 +614,5 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=generic-helpers.js.map
|
||||
|
2
dist/helpers/handlebars-helpers.js
vendored
2
dist/helpers/handlebars-helpers.js
vendored
@ -27,3 +27,5 @@ Template helper definitions for Handlebars.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=handlebars-helpers.js.map
|
||||
|
2
dist/helpers/underscore-helpers.js
vendored
2
dist/helpers/underscore-helpers.js
vendored
@ -34,3 +34,5 @@ Template helper definitions for Underscore.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=underscore-helpers.js.map
|
||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
@ -47,3 +47,5 @@ API facade for HackMyCore.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
2
dist/inspectors/gap-inspector.js
vendored
2
dist/inspectors/gap-inspector.js
vendored
@ -136,3 +136,5 @@ Employment gap analysis for HackMyResume.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=gap-inspector.js.map
|
||||
|
2
dist/inspectors/keyword-inspector.js
vendored
2
dist/inspectors/keyword-inspector.js
vendored
@ -59,3 +59,5 @@ Keyword analysis for HackMyResume.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=keyword-inspector.js.map
|
||||
|
2
dist/inspectors/totals-inspector.js
vendored
2
dist/inspectors/totals-inspector.js
vendored
@ -47,3 +47,5 @@ Section analysis for HackMyResume.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=totals-inspector.js.map
|
||||
|
2
dist/renderers/handlebars-generator.js
vendored
2
dist/renderers/handlebars-generator.js
vendored
@ -98,3 +98,5 @@ Definition of the HandlebarsGenerator class.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=handlebars-generator.js.map
|
||||
|
2
dist/renderers/jrs-generator.js
vendored
2
dist/renderers/jrs-generator.js
vendored
@ -57,3 +57,5 @@ Definition of the JRSGenerator class.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=jrs-generator.js.map
|
||||
|
2
dist/renderers/underscore-generator.js
vendored
2
dist/renderers/underscore-generator.js
vendored
@ -58,3 +58,5 @@ Definition of the UnderscoreGenerator class.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=underscore-generator.js.map
|
||||
|
2
dist/utils/file-contains.js
vendored
2
dist/utils/file-contains.js
vendored
@ -10,3 +10,5 @@ Definition of the SyntaxErrorEx class.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=file-contains.js.map
|
||||
|
2
dist/utils/html-to-wpml.js
vendored
2
dist/utils/html-to-wpml.js
vendored
@ -59,3 +59,5 @@ Definition of the Markdown to WordProcessingML conversion routine.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=html-to-wpml.js.map
|
||||
|
2
dist/utils/md2chalk.js
vendored
2
dist/utils/md2chalk.js
vendored
@ -26,3 +26,5 @@ Inline Markdown-to-Chalk conversion routines.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=md2chalk.js.map
|
||||
|
2
dist/utils/rasterize.js
vendored
2
dist/utils/rasterize.js
vendored
@ -75,3 +75,5 @@
|
||||
}
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=rasterize.js.map
|
||||
|
2
dist/utils/safe-json-loader.js
vendored
2
dist/utils/safe-json-loader.js
vendored
@ -30,3 +30,5 @@ Definition of the SafeJsonLoader class.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=safe-json-loader.js.map
|
||||
|
2
dist/utils/safe-spawn.js
vendored
2
dist/utils/safe-spawn.js
vendored
@ -42,3 +42,5 @@ exception
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=safe-spawn.js.map
|
||||
|
2
dist/utils/string-transformer.js
vendored
2
dist/utils/string-transformer.js
vendored
@ -60,3 +60,5 @@ Object string transformation.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=string-transformer.js.map
|
||||
|
2
dist/utils/string.js
vendored
2
dist/utils/string.js
vendored
@ -25,3 +25,5 @@ See: http://stackoverflow.com/a/32800728/4942583
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=string.js.map
|
||||
|
2
dist/utils/syntax-error-ex.js
vendored
2
dist/utils/syntax-error-ex.js
vendored
@ -37,3 +37,5 @@ See: http://stackoverflow.com/q/13323356
|
||||
module.exports = SyntaxErrorEx;
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=syntax-error-ex.js.map
|
||||
|
60
dist/verbs/analyze.js
vendored
60
dist/verbs/analyze.js
vendored
@ -6,7 +6,7 @@ Implementation of the 'analyze' verb for HackMyResume.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var AnalyzeVerb, HMEVENT, HMSTATUS, MKDIRP, PATH, ResumeFactory, Verb, _, _analyze, _loadInspectors, analyze, chalk;
|
||||
var AnalyzeVerb, HMEVENT, HMSTATUS, MKDIRP, PATH, ResumeFactory, Verb, _, _analyze, _analyzeOne, _loadInspectors, chalk;
|
||||
|
||||
MKDIRP = require('mkdirp');
|
||||
|
||||
@ -24,46 +24,56 @@ Implementation of the 'analyze' verb for HackMyResume.
|
||||
|
||||
chalk = require('chalk');
|
||||
|
||||
|
||||
/** An invokable resume analysis command. */
|
||||
|
||||
AnalyzeVerb = module.exports = Verb.extend({
|
||||
init: function() {
|
||||
return this._super('analyze', analyze);
|
||||
return this._super('analyze', _analyze);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
Run the 'analyze' command.
|
||||
*/
|
||||
/** Private workhorse for the 'analyze' command. */
|
||||
|
||||
analyze = function(sources, dst, opts) {
|
||||
var nlzrs;
|
||||
_analyze = function(sources, dst, opts) {
|
||||
var nlzrs, results;
|
||||
if (!sources || !sources.length) {
|
||||
throw {
|
||||
fluenterror: HMSTATUS.resumeNotFound,
|
||||
this.err(HMSTATUS.resumeNotFound, {
|
||||
quit: true
|
||||
};
|
||||
});
|
||||
return null;
|
||||
}
|
||||
nlzrs = _loadInspectors();
|
||||
return _.each(sources, function(src) {
|
||||
var result;
|
||||
result = ResumeFactory.loadOne(src, {
|
||||
results = _.map(sources, function(src) {
|
||||
var r;
|
||||
r = ResumeFactory.loadOne(src, {
|
||||
format: 'FRESH',
|
||||
objectify: true
|
||||
}, this);
|
||||
if (result.fluenterror) {
|
||||
return this.setError(result.fluenterror, result);
|
||||
if (opts.assert && this.hasError()) {
|
||||
return {};
|
||||
}
|
||||
if (r.fluenterror) {
|
||||
r.quit = opts.assert;
|
||||
this.err(r.fluenterror, r);
|
||||
return r;
|
||||
} else {
|
||||
return _analyze.call(this, result, nlzrs, opts);
|
||||
return _analyzeOne.call(this, r, nlzrs, opts);
|
||||
}
|
||||
}, this);
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(this.errorCode);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Analyze a single resume.
|
||||
*/
|
||||
/** Analyze a single resume. */
|
||||
|
||||
_analyze = function(resumeObject, nlzrs, opts) {
|
||||
_analyzeOne = function(resumeObject, nlzrs, opts) {
|
||||
var info, rez, safeFormat;
|
||||
rez = resumeObject.rez;
|
||||
safeFormat = rez.meta && rez.meta.format && rez.meta.format.startsWith('FRESH') ? 'FRESH' : 'JRS';
|
||||
@ -74,16 +84,12 @@ Implementation of the 'analyze' verb for HackMyResume.
|
||||
info = _.mapObject(nlzrs, function(val, key) {
|
||||
return val.run(rez);
|
||||
});
|
||||
return this.stat(HMEVENT.afterAnalyze, {
|
||||
this.stat(HMEVENT.afterAnalyze, {
|
||||
info: info
|
||||
});
|
||||
return info;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Load inspectors.
|
||||
*/
|
||||
|
||||
_loadInspectors = function() {
|
||||
return {
|
||||
totals: require('../inspectors/totals-inspector'),
|
||||
@ -93,3 +99,5 @@ Implementation of the 'analyze' verb for HackMyResume.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=analyze.js.map
|
||||
|
63
dist/verbs/build.js
vendored
63
dist/verbs/build.js
vendored
@ -6,7 +6,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var BuildVerb, FRESHTheme, FS, HMEVENT, HMSTATUS, JRSTheme, MD, MKDIRP, PATH, RConverter, RTYPES, ResumeFactory, Verb, _, _err, _fmts, _log, _opts, _rezObj, addFreebieFormats, build, expand, extend, loadTheme, parsePath, prep, single, verifyOutputs, verifyTheme;
|
||||
var BuildVerb, FRESHTheme, FS, HMEVENT, HMSTATUS, JRSTheme, MD, MKDIRP, PATH, RConverter, RTYPES, ResumeFactory, Verb, _, _addFreebieFormats, _build, _err, _expand, _fmts, _loadTheme, _log, _opts, _prep, _rezObj, _single, _verifyOutputs, _verifyTheme, addFreebieFormats, build, expand, extend, loadTheme, parsePath, prep, single, verifyOutputs, verifyTheme;
|
||||
|
||||
_ = require('underscore');
|
||||
|
||||
@ -74,7 +74,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
|
||||
/** Create a new build verb. */
|
||||
init: function() {
|
||||
return this._super('build', build);
|
||||
return this._super('build', _build);
|
||||
}
|
||||
});
|
||||
|
||||
@ -87,15 +87,15 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
@param opts Generation options.
|
||||
*/
|
||||
|
||||
build = function(src, dst, opts) {
|
||||
var ex, inv, isFRESH, mixed, newEx, orgFormat, problemSheets, rez, sheetObjects, sheets, tFolder, targets, theme, toFormat;
|
||||
_build = function(src, dst, opts) {
|
||||
var inv, isFRESH, mixed, newEx, orgFormat, problemSheets, results, rez, sheetObjects, sheets, tFolder, targets, theme, toFormat;
|
||||
if (!src || !src.length) {
|
||||
this.err(HMSTATUS.resumeNotFound, {
|
||||
quit: true
|
||||
});
|
||||
return null;
|
||||
}
|
||||
prep(src, dst, opts);
|
||||
_prep(src, dst, opts);
|
||||
sheetObjects = ResumeFactory.load(src, {
|
||||
format: null,
|
||||
objectify: false,
|
||||
@ -120,14 +120,13 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
theme: _opts.theme
|
||||
});
|
||||
try {
|
||||
tFolder = verifyTheme.call(this, _opts.theme);
|
||||
theme = _opts.themeObj = loadTheme(tFolder);
|
||||
addFreebieFormats(theme);
|
||||
tFolder = _verifyTheme.call(this, _opts.theme);
|
||||
theme = _opts.themeObj = _loadTheme(tFolder);
|
||||
_addFreebieFormats(theme);
|
||||
} catch (_error) {
|
||||
ex = _error;
|
||||
newEx = {
|
||||
fluenterror: HMSTATUS.themeLoad,
|
||||
inner: ex,
|
||||
inner: _error,
|
||||
attempted: _opts.theme,
|
||||
quit: true
|
||||
};
|
||||
@ -137,7 +136,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
this.stat(HMEVENT.afterTheme, {
|
||||
theme: theme
|
||||
});
|
||||
inv = verifyOutputs.call(this, dst, theme);
|
||||
inv = _verifyOutputs.call(this, dst, theme);
|
||||
if (inv && inv.length) {
|
||||
this.err(HMSTATUS.invalidFormat, {
|
||||
data: inv,
|
||||
@ -187,15 +186,28 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
theme: theme
|
||||
});
|
||||
_rezObj = new RTYPES[toFormat]().parseJSON(rez);
|
||||
targets = expand(dst, theme);
|
||||
targets = _expand(dst, theme);
|
||||
_.each(targets, function(t) {
|
||||
return t.final = single.call(this, t, theme, targets);
|
||||
if (this.hasError() && opts.assert) {
|
||||
return {};
|
||||
}
|
||||
t.final = _single.call(this, t, theme, targets);
|
||||
if (t.final.fluenterror) {
|
||||
t.final.quit = opts.assert;
|
||||
this.err(t.final.fluenterror, t.final);
|
||||
}
|
||||
}, this);
|
||||
return {
|
||||
results = {
|
||||
sheet: _rezObj,
|
||||
targets: targets,
|
||||
processed: targets
|
||||
};
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(results);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
@ -203,7 +215,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
Prepare for a BUILD run.
|
||||
*/
|
||||
|
||||
prep = function(src, dst, opts) {
|
||||
_prep = function(src, dst, opts) {
|
||||
_opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern';
|
||||
_opts.prettify = opts.prettify === true;
|
||||
_opts.css = opts.css;
|
||||
@ -226,7 +238,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
@param theme A FRESHTheme or JRSTheme object.
|
||||
*/
|
||||
|
||||
single = function(targInfo, theme, finished) {
|
||||
_single = function(targInfo, theme, finished) {
|
||||
var e, ex, f, fName, fType, outFolder, ret, theFormat;
|
||||
ret = null;
|
||||
ex = null;
|
||||
@ -268,11 +280,12 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
});
|
||||
if (ex) {
|
||||
if (ex.fluenterror) {
|
||||
this.err(ex.fluenterror, ex);
|
||||
ret = ex;
|
||||
} else {
|
||||
this.err(HMSTATUS.generateError, {
|
||||
ret = {
|
||||
fluenterror: HMSTATUS.generateError,
|
||||
inner: ex
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -281,7 +294,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
|
||||
/** Ensure that user-specified outputs/targets are valid. */
|
||||
|
||||
verifyOutputs = function(targets, theme) {
|
||||
_verifyOutputs = function(targets, theme) {
|
||||
this.stat(HMEVENT.verifyOutputs, {
|
||||
targets: targets,
|
||||
theme: theme
|
||||
@ -308,7 +321,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
@param theTheme A FRESHTheme or JRSTheme object.
|
||||
*/
|
||||
|
||||
addFreebieFormats = function(theTheme) {
|
||||
_addFreebieFormats = function(theTheme) {
|
||||
theTheme.formats.json = theTheme.formats.json || {
|
||||
freebie: true,
|
||||
title: 'json',
|
||||
@ -347,7 +360,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
@param theTheme A FRESHTheme or JRSTheme object.
|
||||
*/
|
||||
|
||||
expand = function(dst, theTheme) {
|
||||
_expand = function(dst, theTheme) {
|
||||
var destColl, targets;
|
||||
destColl = (dst && dst.length && dst) || [PATH.normalize('out/resume.all')];
|
||||
targets = [];
|
||||
@ -378,7 +391,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
Verify the specified theme name/path.
|
||||
*/
|
||||
|
||||
verifyTheme = function(themeNameOrPath) {
|
||||
_verifyTheme = function(themeNameOrPath) {
|
||||
var exists, tFolder;
|
||||
tFolder = PATH.join(parsePath(require.resolve('fresh-themes')).dirname, '/themes/', themeNameOrPath);
|
||||
exists = require('path-exists').sync;
|
||||
@ -399,7 +412,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
theme.
|
||||
*/
|
||||
|
||||
loadTheme = function(tFolder) {
|
||||
_loadTheme = function(tFolder) {
|
||||
var theTheme;
|
||||
theTheme = _opts.theme.indexOf('jsonresume-theme-') > -1 ? new JRSTheme().open(tFolder) : new FRESHTheme().open(tFolder);
|
||||
_opts.themeObj = theTheme;
|
||||
@ -407,3 +420,5 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=build.js.map
|
||||
|
98
dist/verbs/convert.js
vendored
98
dist/verbs/convert.js
vendored
@ -6,7 +6,7 @@ Implementation of the 'convert' verb for HackMyResume.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var ConvertVerb, HMEVENT, HMSTATUS, ResumeFactory, Verb, _, chalk, convert;
|
||||
var ConvertVerb, HMEVENT, HMSTATUS, ResumeFactory, Verb, _, _convert, _convertOne, chalk;
|
||||
|
||||
ResumeFactory = require('../core/resume-factory');
|
||||
|
||||
@ -22,67 +22,87 @@ Implementation of the 'convert' verb for HackMyResume.
|
||||
|
||||
ConvertVerb = module.exports = Verb.extend({
|
||||
init: function() {
|
||||
return this._super('convert', convert);
|
||||
return this._super('convert', _convert);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
Convert between FRESH and JRS formats.
|
||||
/** Private workhorse method. Convert 0..N resumes between FRESH and JRS
|
||||
formats.
|
||||
*/
|
||||
|
||||
convert = function(srcs, dst, opts) {
|
||||
_convert = function(srcs, dst, opts) {
|
||||
var results;
|
||||
if (!srcs || !srcs.length) {
|
||||
throw {
|
||||
fluenterror: 6,
|
||||
this.err(HMSTATUS.resumeNotFound, {
|
||||
quit: true
|
||||
};
|
||||
});
|
||||
return null;
|
||||
}
|
||||
if (!dst || !dst.length) {
|
||||
if (srcs.length === 1) {
|
||||
throw {
|
||||
fluenterror: HMSTATUS.inputOutputParity,
|
||||
this.err(HMSTATUS.inputOutputParity, {
|
||||
quit: true
|
||||
};
|
||||
});
|
||||
} else if (srcs.length === 2) {
|
||||
dst = dst || [];
|
||||
dst.push(srcs.pop());
|
||||
} else {
|
||||
throw {
|
||||
fluenterror: HMSTATUS.inputOutputParity,
|
||||
this.err(HMSTATUS.inputOutputParity, {
|
||||
quit: true
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
if (srcs && dst && srcs.length && dst.length && srcs.length !== dst.length) {
|
||||
throw {
|
||||
fluenterror: HMSTATUS.inputOutputParity({
|
||||
quit: true
|
||||
})
|
||||
};
|
||||
this.err(HMSTATUS.inputOutputParity, {
|
||||
quit: true
|
||||
});
|
||||
}
|
||||
_.each(srcs, function(src, idx) {
|
||||
var rinfo, s, srcFmt, targetFormat;
|
||||
rinfo = ResumeFactory.loadOne(src, {
|
||||
format: null,
|
||||
objectify: true,
|
||||
"throw": false
|
||||
});
|
||||
if (rinfo.fluenterror) {
|
||||
this.err(rinfo.fluenterror, rinfo);
|
||||
return;
|
||||
results = _.map(srcs, function(src, idx) {
|
||||
var r;
|
||||
if (opts.assert && this.hasError()) {
|
||||
return {};
|
||||
}
|
||||
s = rinfo.rez;
|
||||
srcFmt = ((s.basics && s.basics.imp) || s.imp).orgFormat === 'JRS' ? 'JRS' : 'FRESH';
|
||||
targetFormat = srcFmt === 'JRS' ? 'FRESH' : 'JRS';
|
||||
this.stat(HMEVENT.beforeConvert, {
|
||||
srcFile: rinfo.file,
|
||||
srcFmt: srcFmt,
|
||||
dstFile: dst[idx],
|
||||
dstFmt: targetFormat
|
||||
});
|
||||
s.saveAs(dst[idx], targetFormat);
|
||||
r = _convertOne.call(this, src, dst, idx);
|
||||
if (r.fluenterror) {
|
||||
r.quit = opts.assert;
|
||||
this.err(r.fluenterror, r);
|
||||
}
|
||||
return r;
|
||||
}, this);
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(results);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/** Private workhorse method. Convert a single resume. */
|
||||
|
||||
_convertOne = function(src, dst, idx) {
|
||||
var rinfo, s, srcFmt, targetFormat;
|
||||
rinfo = ResumeFactory.loadOne(src, {
|
||||
format: null,
|
||||
objectify: true
|
||||
});
|
||||
if (rinfo.fluenterror) {
|
||||
return rinfo;
|
||||
}
|
||||
s = rinfo.rez;
|
||||
srcFmt = ((s.basics && s.basics.imp) || s.imp).orgFormat === 'JRS' ? 'JRS' : 'FRESH';
|
||||
targetFormat = srcFmt === 'JRS' ? 'FRESH' : 'JRS';
|
||||
this.stat(HMEVENT.beforeConvert, {
|
||||
srcFile: rinfo.file,
|
||||
srcFmt: srcFmt,
|
||||
dstFile: dst[idx],
|
||||
dstFmt: targetFormat
|
||||
});
|
||||
s.saveAs(dst[idx], targetFormat);
|
||||
return s;
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=convert.js.map
|
||||
|
66
dist/verbs/create.js
vendored
66
dist/verbs/create.js
vendored
@ -6,7 +6,7 @@ Implementation of the 'create' verb for HackMyResume.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var CreateVerb, HMEVENT, HMSTATUS, MKDIRP, PATH, Verb, _, chalk, create;
|
||||
var CreateVerb, HMEVENT, HMSTATUS, MKDIRP, PATH, Verb, _, _create, _createOne, chalk;
|
||||
|
||||
MKDIRP = require('mkdirp');
|
||||
|
||||
@ -24,24 +24,48 @@ Implementation of the 'create' verb for HackMyResume.
|
||||
|
||||
CreateVerb = module.exports = Verb.extend({
|
||||
init: function() {
|
||||
return this._super('new', create);
|
||||
return this._super('new', _create);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
Create a new empty resume in either FRESH or JRS format.
|
||||
*/
|
||||
/** Create a new empty resume in either FRESH or JRS format. */
|
||||
|
||||
create = function(src, dst, opts) {
|
||||
_create = function(src, dst, opts) {
|
||||
var results;
|
||||
if (!src || !src.length) {
|
||||
throw {
|
||||
fluenterror: HMSTATUS.createNameMissing,
|
||||
this.err(HMSTATUS.createNameMissing, {
|
||||
quit: true
|
||||
};
|
||||
});
|
||||
return null;
|
||||
}
|
||||
_.each(src, function(t) {
|
||||
var RezClass, safeFmt;
|
||||
results = _.map(src, function(t) {
|
||||
var r;
|
||||
if (opts.assert && this.hasError()) {
|
||||
return {};
|
||||
}
|
||||
r = _createOne.call(this, t, opts);
|
||||
if (r.fluenterror) {
|
||||
r.quit = opts.assert;
|
||||
this.err(r.fluenterror, r);
|
||||
}
|
||||
return r;
|
||||
}, this);
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(results);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/** Create a single new resume */
|
||||
|
||||
_createOne = function(t, opts) {
|
||||
var RezClass, newRez, ret, safeFmt;
|
||||
try {
|
||||
ret = null;
|
||||
safeFmt = opts.format.toUpperCase();
|
||||
this.stat(HMEVENT.beforeCreate, {
|
||||
fmt: safeFmt,
|
||||
@ -49,12 +73,24 @@ Implementation of the 'create' verb for HackMyResume.
|
||||
});
|
||||
MKDIRP.sync(PATH.dirname(t));
|
||||
RezClass = require('../core/' + safeFmt.toLowerCase() + '-resume');
|
||||
RezClass["default"]().save(t);
|
||||
return this.stat(HMEVENT.afterCreate, {
|
||||
newRez = RezClass["default"]();
|
||||
newRez.save(t);
|
||||
ret = newRez;
|
||||
} catch (_error) {
|
||||
ret = {
|
||||
fluenterror: HMSTATUS.createError,
|
||||
inner: _error
|
||||
};
|
||||
} finally {
|
||||
this.stat(HMEVENT.afterCreate, {
|
||||
fmt: safeFmt,
|
||||
file: t
|
||||
file: t,
|
||||
isError: ret.fluenterror
|
||||
});
|
||||
}, this);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=create.js.map
|
||||
|
87
dist/verbs/peek.js
vendored
87
dist/verbs/peek.js
vendored
@ -6,7 +6,7 @@ Implementation of the 'peek' verb for HackMyResume.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var HMEVENT, HMSTATUS, PeekVerb, Verb, _, __, peek, safeLoadJSON;
|
||||
var HMEVENT, HMSTATUS, PeekVerb, Verb, _, __, _peek, _peekOne, safeLoadJSON;
|
||||
|
||||
Verb = require('../verbs/verb');
|
||||
|
||||
@ -22,49 +22,74 @@ Implementation of the 'peek' verb for HackMyResume.
|
||||
|
||||
PeekVerb = module.exports = Verb.extend({
|
||||
init: function() {
|
||||
return this._super('peek', peek);
|
||||
return this._super('peek', _peek);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/** Peek at a resume, resume section, or resume field. */
|
||||
|
||||
peek = function(src, dst, opts) {
|
||||
var objPath;
|
||||
_peek = function(src, dst, opts) {
|
||||
var objPath, results;
|
||||
if (!src || !src.length) {
|
||||
({
|
||||
"throw": {
|
||||
fluenterror: HMSTATUS.resumeNotFound
|
||||
}
|
||||
this.err(HMSTATUS.resumeNotFound, {
|
||||
quit: true
|
||||
});
|
||||
return null;
|
||||
}
|
||||
objPath = (dst && dst[0]) || '';
|
||||
_.each(src, function(t) {
|
||||
var errCode, obj, tgt;
|
||||
this.stat(HMEVENT.beforePeek, {
|
||||
file: t,
|
||||
target: objPath
|
||||
});
|
||||
obj = safeLoadJSON(t);
|
||||
tgt = null;
|
||||
if (!obj.ex) {
|
||||
tgt = objPath ? __.get(obj.json, objPath) : obj.json;
|
||||
results = _.map(src, function(t) {
|
||||
var tgt;
|
||||
if (opts.assert && this.hasError()) {
|
||||
return {};
|
||||
}
|
||||
this.stat(HMEVENT.afterPeek, {
|
||||
file: t,
|
||||
requested: objPath,
|
||||
target: tgt,
|
||||
error: obj.ex
|
||||
});
|
||||
if (obj.ex) {
|
||||
errCode = obj.ex.operation === 'parse' ? HMSTATUS.parseError : HMSTATUS.readError;
|
||||
if (errCode === HMSTATUS.readError) {
|
||||
obj.ex.quiet = true;
|
||||
}
|
||||
this.setError(errCode, obj.ex);
|
||||
return this.err(errCode, obj.ex);
|
||||
tgt = _peekOne.call(this, t, objPath);
|
||||
if (tgt.fluenterror) {
|
||||
tgt.quit = opts.assert;
|
||||
return this.err(tgt.fluenterror, tgt);
|
||||
}
|
||||
}, this);
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(this.errorCode);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/** Peek at a single resume, resume section, or resume field. */
|
||||
|
||||
_peekOne = function(t, objPath) {
|
||||
var errCode, obj, tgt;
|
||||
this.stat(HMEVENT.beforePeek, {
|
||||
file: t,
|
||||
target: objPath
|
||||
});
|
||||
obj = safeLoadJSON(t);
|
||||
tgt = null;
|
||||
if (!obj.ex) {
|
||||
tgt = objPath ? __.get(obj.json, objPath) : obj.json;
|
||||
}
|
||||
this.stat(HMEVENT.afterPeek, {
|
||||
file: t,
|
||||
requested: objPath,
|
||||
target: tgt,
|
||||
error: obj.ex
|
||||
});
|
||||
if (obj.ex) {
|
||||
errCode = obj.ex.operation === 'parse' ? HMSTATUS.parseError : HMSTATUS.readError;
|
||||
if (errCode === HMSTATUS.readError) {
|
||||
obj.ex.quiet = true;
|
||||
}
|
||||
return {
|
||||
fluenterror: errCode,
|
||||
inner: obj.ex
|
||||
};
|
||||
}
|
||||
return tgt;
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=peek.js.map
|
||||
|
123
dist/verbs/validate.js
vendored
123
dist/verbs/validate.js
vendored
@ -6,7 +6,7 @@ Implementation of the 'validate' verb for HackMyResume.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var FS, HMEVENT, HMSTATUS, ResumeFactory, SyntaxErrorEx, ValidateVerb, Verb, _, chalk, safeLoadJSON, validate;
|
||||
var FS, HMEVENT, HMSTATUS, ResumeFactory, SyntaxErrorEx, ValidateVerb, Verb, _, _validate, _validateOne, chalk, safeLoadJSON;
|
||||
|
||||
FS = require('fs');
|
||||
|
||||
@ -31,72 +31,95 @@ Implementation of the 'validate' verb for HackMyResume.
|
||||
|
||||
ValidateVerb = module.exports = Verb.extend({
|
||||
init: function() {
|
||||
return this._super('validate', validate);
|
||||
return this._super('validate', _validate);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/** Validate 1 to N resumes in FRESH or JSON Resume format. */
|
||||
|
||||
validate = function(sources, unused, opts) {
|
||||
var schemas, validator;
|
||||
_validate = function(sources, unused, opts) {
|
||||
var results, schemas, validator;
|
||||
if (!sources || !sources.length) {
|
||||
throw {
|
||||
fluenterror: HMSTATUS.resumeNotFoundAlt,
|
||||
this.err(HMSTATUS.resumeNotFoundAlt, {
|
||||
quit: true
|
||||
};
|
||||
});
|
||||
return null;
|
||||
}
|
||||
validator = require('is-my-json-valid');
|
||||
schemas = {
|
||||
fresh: require('fresca'),
|
||||
jars: require('../core/resume.json')
|
||||
};
|
||||
return _.map(sources, function(t) {
|
||||
var errCode, errors, fmt, json, obj, ret;
|
||||
ret = {
|
||||
file: t,
|
||||
isValid: false
|
||||
};
|
||||
obj = safeLoadJSON(t);
|
||||
if (!obj.ex) {
|
||||
json = obj.json;
|
||||
fmt = json.basics ? 'jrs' : 'fresh';
|
||||
errors = [];
|
||||
try {
|
||||
validate = validator(schemas[fmt], {
|
||||
formats: {
|
||||
date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/
|
||||
}
|
||||
});
|
||||
ret.isValid = validate(json);
|
||||
if (!ret.isValid) {
|
||||
errors = validate.errors;
|
||||
}
|
||||
} catch (_error) {
|
||||
ret.ex = _error;
|
||||
}
|
||||
} else {
|
||||
errCode = obj.ex.operation === 'parse' ? HMSTATUS.parseError : HMSTATUS.readError;
|
||||
if (errCode === HMSTATUS.readError) {
|
||||
obj.ex.quiet = true;
|
||||
}
|
||||
this.setError(errCode, obj.ex);
|
||||
this.err(errCode, obj.ex);
|
||||
results = _.map(sources, function(t) {
|
||||
var r;
|
||||
if (this.hasError() && opts.assert) {
|
||||
return {};
|
||||
}
|
||||
this.stat(HMEVENT.afterValidate, {
|
||||
file: t,
|
||||
isValid: ret.isValid,
|
||||
fmt: fmt != null ? fmt.replace('jars', 'JSON Resume') : void 0,
|
||||
errors: errors
|
||||
});
|
||||
if (opts.assert && !ret.isValid) {
|
||||
throw {
|
||||
fluenterror: HMSTATUS.invalid,
|
||||
shouldExit: true
|
||||
};
|
||||
r = _validateOne.call(this, t, validator, schemas);
|
||||
if (r.fluenterror) {
|
||||
console.log(r);
|
||||
r.quit = opts.assert;
|
||||
this.err(r.fluenterror, r);
|
||||
}
|
||||
return ret;
|
||||
return r;
|
||||
}, this);
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(this.errorCode);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
_validateOne = function(t, validator, schemas) {
|
||||
var errCode, errors, fmt, json, obj, ret, validate;
|
||||
ret = {
|
||||
file: t,
|
||||
isValid: false
|
||||
};
|
||||
obj = safeLoadJSON(t);
|
||||
if (obj.ex) {
|
||||
errCode = obj.ex.operation === 'parse' ? HMSTATUS.parseError : HMSTATUS.readError;
|
||||
if (errCode === HMSTATUS.readError) {
|
||||
obj.ex.quiet = true;
|
||||
}
|
||||
return {
|
||||
fluenterror: errCode,
|
||||
inner: obj.ex
|
||||
};
|
||||
}
|
||||
json = obj.json;
|
||||
fmt = json.basics ? 'jrs' : 'fresh';
|
||||
errors = [];
|
||||
try {
|
||||
validate = validator(schemas[fmt], {
|
||||
formats: {
|
||||
date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/
|
||||
}
|
||||
});
|
||||
ret.isValid = validate(json);
|
||||
if (!ret.isValid) {
|
||||
errors = validate.errors;
|
||||
}
|
||||
} catch (_error) {
|
||||
ret.ex = _error;
|
||||
}
|
||||
this.stat(HMEVENT.afterValidate, {
|
||||
file: t,
|
||||
isValid: ret.isValid,
|
||||
fmt: fmt != null ? fmt.replace('jars', 'JSON Resume') : void 0,
|
||||
errors: errors
|
||||
});
|
||||
if (opts.assert && !ret.isValid) {
|
||||
return {
|
||||
fluenterror: HMSTATUS.invalid,
|
||||
errors: errors
|
||||
};
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=validate.js.map
|
||||
|
27
dist/verbs/verb.js
vendored
27
dist/verbs/verb.js
vendored
@ -6,7 +6,7 @@ Definition of the Verb class.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var Class, EVENTS, HMEVENT, Verb;
|
||||
var Class, EVENTS, HMEVENT, Promise, Verb;
|
||||
|
||||
Class = require('../utils/class');
|
||||
|
||||
@ -14,6 +14,8 @@ Definition of the Verb class.
|
||||
|
||||
HMEVENT = require('../core/event-codes');
|
||||
|
||||
Promise = require('pinkie-promise');
|
||||
|
||||
|
||||
/**
|
||||
An instantiation of a HackMyResume command.
|
||||
@ -25,19 +27,23 @@ Definition of the Verb class.
|
||||
/** Constructor. Automatically called at creation. */
|
||||
init: function(moniker, workhorse) {
|
||||
this.moniker = moniker;
|
||||
this.emitter = new EVENTS.EventEmitter();
|
||||
this.workhorse = workhorse;
|
||||
this.emitter = new EVENTS.EventEmitter();
|
||||
},
|
||||
|
||||
/** Invoke the command. */
|
||||
invoke: function() {
|
||||
var ret;
|
||||
var argsArray, that;
|
||||
this.stat(HMEVENT.begin, {
|
||||
cmd: this.moniker
|
||||
});
|
||||
ret = this.workhorse.apply(this, arguments);
|
||||
this.stat(HMEVENT.end);
|
||||
return ret;
|
||||
argsArray = Array.prototype.slice.call(arguments);
|
||||
that = this;
|
||||
return this.promise = new Promise(function(res, rej) {
|
||||
that.resolve = res;
|
||||
that.reject = rej;
|
||||
that.workhorse.apply(that, argsArray);
|
||||
});
|
||||
},
|
||||
|
||||
/** Forward subscriptions to the event emitter. */
|
||||
@ -58,6 +64,10 @@ Definition of the Verb class.
|
||||
payload = payload || {};
|
||||
payload.sub = payload.fluenterror = errorCode;
|
||||
payload["throw"] = hot;
|
||||
this.setError(errorCode, payload);
|
||||
if (payload.quit) {
|
||||
this.reject(payload);
|
||||
}
|
||||
this.fire('error', payload);
|
||||
if (hot) {
|
||||
throw payload;
|
||||
@ -72,6 +82,9 @@ Definition of the Verb class.
|
||||
this.fire('status', payload);
|
||||
return true;
|
||||
},
|
||||
hasError: function() {
|
||||
return this.errorCode || this.errorObj;
|
||||
},
|
||||
|
||||
/** Associate error info with the invocation. */
|
||||
setError: function(code, obj) {
|
||||
@ -81,3 +94,5 @@ Definition of the Verb class.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=verb.js.map
|
||||
|
Reference in New Issue
Block a user