mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 08:20:11 +00:00
Merge pull request #6 from fluentdesk/feat/partial-formats
Feat/partial formats
This commit is contained in:
commit
ad75cdf02a
@ -13,7 +13,7 @@ Looking for a desktop GUI version with pretty timelines and graphs? Check out [F
|
|||||||
- Runs on OS X, Linux, and Windows.
|
- Runs on OS X, Linux, and Windows.
|
||||||
- Store your resume data as a durable, versionable JSON, YML, or XML document.
|
- Store your resume data as a durable, versionable JSON, YML, or XML document.
|
||||||
- Generate multiple targeted resumes in multiple formats, based on your needs.
|
- Generate multiple targeted resumes in multiple formats, based on your needs.
|
||||||
- Output to HTML, PDF, Markdown, Word, JSON, XML, or other arbitrary formats.
|
- Output to HTML, PDF, Markdown, Word, JSON, YAML, XML, or a custom format.
|
||||||
- Never update one piece of information in four different resumes again.
|
- Never update one piece of information in four different resumes again.
|
||||||
- Compatible with the [JSON Resume standard][6] and [authoring tools][7].
|
- Compatible with the [JSON Resume standard][6] and [authoring tools][7].
|
||||||
- Free and open-source through the MIT license.
|
- Free and open-source through the MIT license.
|
||||||
@ -39,7 +39,7 @@ fluentcmd [inputs] [outputs] [-t theme].
|
|||||||
Where `[inputs]` is one or more .json resume files, separated by spaces; `[outputs]` is one or more destination resumes, each prefaced with the `-o` option; and `[theme]` is the desired theme. For example:
|
Where `[inputs]` is one or more .json resume files, separated by spaces; `[outputs]` is one or more destination resumes, each prefaced with the `-o` option; and `[theme]` is the desired theme. For example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Generate all resume formats (HTML, PDF, DOC, TXT)
|
# Generate all resume formats (HTML, PDF, DOC, TXT, YML, etc.)
|
||||||
fluentcmd resume.json -o out/resume.all -t modern
|
fluentcmd resume.json -o out/resume.all -t modern
|
||||||
|
|
||||||
# Generate a specific resume format
|
# Generate a specific resume format
|
||||||
@ -49,6 +49,7 @@ fluentcmd resume.json -o out/resume.md
|
|||||||
fluentcmd resume.json -o out/resume.doc
|
fluentcmd resume.json -o out/resume.doc
|
||||||
fluentcmd resume.json -o out/resume.json
|
fluentcmd resume.json -o out/resume.json
|
||||||
fluentcmd resume.json -o out/resume.txt
|
fluentcmd resume.json -o out/resume.txt
|
||||||
|
fluentcmd resume.json -o out/resume.yml
|
||||||
|
|
||||||
# Specify 2 inputs and 3 outputs
|
# Specify 2 inputs and 3 outputs
|
||||||
fluentcmd in1.json in2.json -o out.html -o out.doc -o out.pdf
|
fluentcmd in1.json in2.json -o out.html -o out.doc -o out.pdf
|
||||||
@ -57,7 +58,7 @@ fluentcmd in1.json in2.json -o out.html -o out.doc -o out.pdf
|
|||||||
You should see something to the effect of:
|
You should see something to the effect of:
|
||||||
|
|
||||||
```
|
```
|
||||||
*** FluentCMD v0.4.0 ***
|
*** FluentCMD v0.5.0 ***
|
||||||
Reading JSON resume: foo/resume.json
|
Reading JSON resume: foo/resume.json
|
||||||
Generating HTML resume: out/resume.html
|
Generating HTML resume: out/resume.html
|
||||||
Generating TXT resume: out/resume.txt
|
Generating TXT resume: out/resume.txt
|
||||||
@ -78,7 +79,7 @@ fluentcmd resume.json -t modern
|
|||||||
fluentcmd resume.json -t ~/foo/bar/my-custom-theme/
|
fluentcmd resume.json -t ~/foo/bar/my-custom-theme/
|
||||||
```
|
```
|
||||||
|
|
||||||
As of v0.4.0, available predefined themes are `modern`, `minimist`, and `hello-world`.
|
As of v0.5.0, available predefined themes are `modern`, `minimist`, and `hello-world`.
|
||||||
|
|
||||||
### Merging resumes
|
### Merging resumes
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fluentcmd",
|
"name": "fluentcmd",
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"description": "Generate beautiful, targeted resumes from your command line or shell.",
|
"description": "Generate beautiful, targeted resumes from your command line or shell.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -24,8 +24,10 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/fluentdesk/fluentcmd",
|
"homepage": "https://github.com/fluentdesk/fluentcmd",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fluentlib": "fluentdesk/fluentlib#v0.3.0",
|
"fluentlib": "fluentdesk/fluentlib#v0.4.0",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"underscore": "^1.8.3"
|
"mkdirp": "^0.5.1",
|
||||||
|
"underscore": "^1.8.3",
|
||||||
|
"watermark": "fluentdesk/watermark#v0.3.1-alpha"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ module.exports = function () {
|
|||||||
, fs = require('fs')
|
, fs = require('fs')
|
||||||
, _ = require('underscore')
|
, _ = require('underscore')
|
||||||
, FLUENT = require('fluentlib')
|
, FLUENT = require('fluentlib')
|
||||||
|
, PATH = require('path')
|
||||||
|
, MKDIRP = require('mkdirp')
|
||||||
, rez, _log, _err;
|
, rez, _log, _err;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +28,7 @@ module.exports = function () {
|
|||||||
|
|
||||||
_log = logger || console.log;
|
_log = logger || console.log;
|
||||||
_err = errHandler || error;
|
_err = errHandler || error;
|
||||||
|
|
||||||
//_opts = extend( true, _opts, opts );
|
//_opts = extend( true, _opts, opts );
|
||||||
_opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern';
|
_opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern';
|
||||||
_opts.prettify = opts.prettify === true ? _opts.prettify : false;
|
_opts.prettify = opts.prettify === true ? _opts.prettify : false;
|
||||||
@ -47,17 +49,32 @@ module.exports = function () {
|
|||||||
});
|
});
|
||||||
msg && _log(msg);
|
msg && _log(msg);
|
||||||
|
|
||||||
|
// Load the active theme
|
||||||
|
// Verify the specified theme name/path
|
||||||
|
var tFolder = PATH.resolve( __dirname, '../node_modules/watermark/themes', _opts.theme );
|
||||||
|
var exists = require('./utils/file-exists');
|
||||||
|
if (!exists( tFolder )) {
|
||||||
|
tFolder = PATH.resolve( _opts.theme );
|
||||||
|
if (!exists( tFolder )) {
|
||||||
|
throw { fluenterror: 1, data: _opts.theme };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var theTheme = new FLUENT.Theme().open( tFolder );
|
||||||
|
_opts.themeObj = theTheme;
|
||||||
|
_log( 'Applying ' + theTheme.name.toUpperCase() + ' theme (' + Object.keys(theTheme.formats).length + ' formats)' );
|
||||||
|
|
||||||
// Expand output resumes... (can't use map() here)
|
// Expand output resumes... (can't use map() here)
|
||||||
var targets = [];
|
var targets = [];
|
||||||
|
var that = this;
|
||||||
( (dst && dst.length && dst) || ['resume.all'] ).forEach( function(t) {
|
( (dst && dst.length && dst) || ['resume.all'] ).forEach( function(t) {
|
||||||
var to = path.resolve(t), pa = path.parse(to), fmat = pa.ext || '.all';
|
var to = path.resolve(t), pa = path.parse(to), fmat = pa.ext || '.all';
|
||||||
targets.push.apply(targets, fmat === '.all' ?
|
targets.push.apply(targets, fmat === '.all' ?
|
||||||
_fmts.map(function(z){ return { file: to.replace(/all$/g,z.ext), fmt: z } })
|
Object.keys( theTheme.formats ).map(function(k){ var z = theTheme.formats[k]; return { file: to.replace(/all$/g,z.pre), fmt: z } })
|
||||||
: [{ file: to, fmt: _.findWhere( _fmts, { ext: fmat.substring(1) }) }]);
|
: [{ file: to, fmt: theTheme.getFormat( fmat.slice(1) ) }]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run the transformation!
|
// Run the transformation!
|
||||||
var finished = targets.map( single );
|
var finished = targets.map( function(t) { return single(t, theTheme); } );
|
||||||
|
|
||||||
// Don't send the client back empty-handed
|
// Don't send the client back empty-handed
|
||||||
return { sheet: rez, targets: targets, processed: finished };
|
return { sheet: rez, targets: targets, processed: finished };
|
||||||
@ -68,13 +85,17 @@ module.exports = function () {
|
|||||||
@param f Full path to the destination resume to generate, for example,
|
@param f Full path to the destination resume to generate, for example,
|
||||||
"/foo/bar/resume.pdf" or "c:\foo\bar\resume.txt".
|
"/foo/bar/resume.pdf" or "c:\foo\bar\resume.txt".
|
||||||
*/
|
*/
|
||||||
function single( fi ) {
|
function single( fi, theme ) {
|
||||||
try {
|
try {
|
||||||
var f = fi.file, fType = fi.fmt.ext, fName = path.basename( f, '.' + fType );
|
var f = fi.file, fType = fi.fmt.ext, fName = path.basename( f, '.' + fType );
|
||||||
var fObj = _fmts.filter( function(_f) { return _f.ext === fType; } )[0];
|
var fObj = _.property( fi.fmt.pre )( theme.formats );
|
||||||
var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.ext );
|
var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.pre );
|
||||||
_log( 'Generating ' + fi.fmt.name.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f ) );
|
_log( 'Generating ' + fi.fmt.title.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f ) );
|
||||||
return fObj.gen.generate( rez, fOut, _opts );
|
var theFormat = _fmts.filter( function( fmt ) {
|
||||||
|
return fmt.name === fi.fmt.pre;
|
||||||
|
})[0];
|
||||||
|
MKDIRP( path.dirname(fOut) ); // Ensure dest folder exists; don't bug user
|
||||||
|
theFormat.gen.generate( rez, fOut, _opts );
|
||||||
}
|
}
|
||||||
catch( ex ) {
|
catch( ex ) {
|
||||||
_err( ex );
|
_err( ex );
|
||||||
@ -96,8 +117,9 @@ module.exports = function () {
|
|||||||
{ name: 'txt', ext: 'txt', gen: new FLUENT.TextGenerator() },
|
{ name: 'txt', ext: 'txt', gen: new FLUENT.TextGenerator() },
|
||||||
{ name: 'doc', ext: 'doc', fmt: 'xml', gen: new FLUENT.WordGenerator() },
|
{ name: 'doc', ext: 'doc', fmt: 'xml', gen: new FLUENT.WordGenerator() },
|
||||||
{ name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new FLUENT.HtmlPdfGenerator() },
|
{ name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new FLUENT.HtmlPdfGenerator() },
|
||||||
{ name: 'markdown', ext: 'md', fmt: 'txt', gen: new FLUENT.MarkdownGenerator() },
|
{ name: 'md', ext: 'md', fmt: 'txt', gen: new FLUENT.MarkdownGenerator() },
|
||||||
{ name: 'json', ext: 'json', gen: new FLUENT.JsonGenerator() }
|
{ name: 'json', ext: 'json', gen: new FLUENT.JsonGenerator() },
|
||||||
|
{ name: 'yml', ext: 'yml', fmt: 'yml', gen: new FLUENT.JsonYamlGenerator() }
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
16
src/index.js
16
src/index.js
@ -10,6 +10,7 @@ var ARGS = require( 'minimist' )
|
|||||||
, PKG = require('../package.json');
|
, PKG = require('../package.json');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
var opts = { };
|
||||||
main();
|
main();
|
||||||
}
|
}
|
||||||
catch( ex ) {
|
catch( ex ) {
|
||||||
@ -17,27 +18,34 @@ catch( ex ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
|
||||||
// Setup.
|
// Setup.
|
||||||
console.log( '*** FluentCMD v' + PKG.version + ' ***' );
|
|
||||||
if( process.argv.length <= 2 ) { throw { fluenterror: 3 }; }
|
if( process.argv.length <= 2 ) { throw { fluenterror: 3 }; }
|
||||||
|
var args = ARGS( process.argv.slice(2) );
|
||||||
|
opts = getOpts( args );
|
||||||
|
logMsg( '*** FluentCMD v' + PKG.version + ' ***' );
|
||||||
|
|
||||||
// Convert arguments to source files, target files, options
|
// Convert arguments to source files, target files, options
|
||||||
var args = ARGS( process.argv.slice(2) );
|
|
||||||
var src = args._ || [];
|
var src = args._ || [];
|
||||||
var dst = (args.o && ((typeof args.o === 'string' && [ args.o ]) || args.o)) || [];
|
var dst = (args.o && ((typeof args.o === 'string' && [ args.o ]) || args.o)) || [];
|
||||||
dst = (dst === true) ? [] : dst; // Handle -o with missing output file
|
dst = (dst === true) ? [] : dst; // Handle -o with missing output file
|
||||||
|
|
||||||
// Generate!
|
// Generate!
|
||||||
FCMD.generate( src, dst, getOpts( args ) );
|
FCMD.generate( src, dst, opts, logMsg );
|
||||||
process.platform !== 'win32' && console.log('\n');
|
process.platform !== 'win32' && console.log('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function logMsg( msg ) {
|
||||||
|
opts.silent || console.log( msg );
|
||||||
|
}
|
||||||
|
|
||||||
function getOpts( args ) {
|
function getOpts( args ) {
|
||||||
var noPretty = args['nopretty'] || args.n;
|
var noPretty = args['nopretty'] || args.n;
|
||||||
noPretty = noPretty && (noPretty === true || noPretty === 'true');
|
noPretty = noPretty && (noPretty === true || noPretty === 'true');
|
||||||
return {
|
return {
|
||||||
theme: args.t || 'modern',
|
theme: args.t || 'modern',
|
||||||
prettify: !noPretty
|
prettify: !noPretty,
|
||||||
|
silent: args.s || args.silent
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
src/utils/file-exists.js
Normal file
18
src/utils/file-exists.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
File-exists checker for Node.js.
|
||||||
|
@license Copyright (c) 2015 | James M. Devlin
|
||||||
|
*/
|
||||||
|
|
||||||
|
var FS = require('fs');
|
||||||
|
|
||||||
|
// Yup, this is now the recommended way to check for file existence on Node.
|
||||||
|
// fs.exists is deprecated and the recommended fs.statSync/lstatSync throws
|
||||||
|
// exceptions on non-existent paths :)
|
||||||
|
module.exports = function (path) {
|
||||||
|
try {
|
||||||
|
FS.statSync( path );
|
||||||
|
return true;
|
||||||
|
} catch( err ) {
|
||||||
|
return !(err && err.code === 'ENOENT');
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user