mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-14 17:47:08 +01:00
Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
aacd50cebe | |||
ad75cdf02a | |||
67e4e87275 | |||
4a98e0bb25 | |||
06294a90b5 | |||
f7c05f49b2 | |||
e20007721e | |||
19b6627df7 | |||
68f943745c | |||
2a7963450e | |||
ceaef3e1c4 | |||
1b4056371b | |||
9dd759ffa2 | |||
befa26cbb2 | |||
31e2e12769 | |||
f728004c4c | |||
61386308a0 | |||
2e5a68d942 | |||
cf15738f58 | |||
d4a3a08aff | |||
b1d987c3b4 | |||
a2b482f60b | |||
189f37b6a1 | |||
6e4263e58c | |||
293f7e118a | |||
961152850d | |||
0724ffe7f2 | |||
782068463c | |||
f4dd72683b | |||
9de7601a2a | |||
7ab2df6696 |
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -1,8 +1,7 @@
|
|||||||
# Auto detect text files and perform LF normalization
|
# Auto detect text files and perform LF normalization
|
||||||
* text=auto
|
* text=auto
|
||||||
|
*.js text eol=lf
|
||||||
# Custom for Visual Studio
|
*.json text eol=lf
|
||||||
*.cs diff=csharp
|
|
||||||
|
|
||||||
# Standard to msysgit
|
# Standard to msysgit
|
||||||
*.doc diff=astextplain
|
*.doc diff=astextplain
|
||||||
|
89
README.md
89
README.md
@ -4,7 +4,20 @@ fluentcmd
|
|||||||
|
|
||||||
FluentCMD is a **hackable, data-driven, dev-friendly resume authoring tool** with support for HTML, Markdown, Word, PDF, plain text, smoke signal, carrier pigeon, and other arbitrary-format resumes and CVs.
|
FluentCMD is a **hackable, data-driven, dev-friendly resume authoring tool** with support for HTML, Markdown, Word, PDF, plain text, smoke signal, carrier pigeon, and other arbitrary-format resumes and CVs.
|
||||||
|
|
||||||
[][8]
|
```bash
|
||||||
|
>fluentcmd resume.json -o out/resume.all -t modern
|
||||||
|
|
||||||
|
*** FluentCMD v0.5.0 ***
|
||||||
|
Reading JSON resume: foo/resume.json
|
||||||
|
Applying MODERN Theme (7 formats)
|
||||||
|
Generating HTML resume: out/resume.html
|
||||||
|
Generating TXT resume: out/resume.txt
|
||||||
|
Generating DOC resume: out/resume.doc
|
||||||
|
Generating PDF resume: out/resume.pdf
|
||||||
|
Generating JSON resume: out/resume.json
|
||||||
|
Generating MARKDOWN resume: out/resume.md
|
||||||
|
Generating YAML resume: out/resume.yml
|
||||||
|
```
|
||||||
|
|
||||||
Looking for a desktop GUI version with pretty timelines and graphs? Check out [FluentCV Desktop][7].
|
Looking for a desktop GUI version with pretty timelines and graphs? Check out [FluentCV Desktop][7].
|
||||||
|
|
||||||
@ -13,7 +26,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.
|
||||||
@ -26,53 +39,76 @@ FluentCMD requires a recent version of [Node.js][4] and [NPM][5]. Then:
|
|||||||
|
|
||||||
1. (Optional, for PDF support) Install the latest official [wkhtmltopdf][3] binary for your platform.
|
1. (Optional, for PDF support) Install the latest official [wkhtmltopdf][3] binary for your platform.
|
||||||
2. Install **fluentcmd** by running `npm install fluentcmd -g`.
|
2. Install **fluentcmd** by running `npm install fluentcmd -g`.
|
||||||
3. You're ready to go!
|
3. You're ready to go.
|
||||||
|
|
||||||
## Use
|
## Use
|
||||||
|
|
||||||
Assuming you've got a JSON-formatted resume handy, generating resumes in different formats and combinations easy. Just run:
|
Assuming you've got a JSON-formatted resume handy, generating resumes in different formats and combinations easy. Just run:
|
||||||
|
|
||||||
`fluentcmd [inputs] [outputs] [-t theme]`.
|
```bash
|
||||||
|
fluentcmd [inputs] [outputs] [-t theme].
|
||||||
|
```
|
||||||
|
|
||||||
Where `[inputs]` is one or more .json resume files, `[outputs]` is one or more destination resumes, 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 resume.all -t informatic
|
fluentcmd resume.json -o out/resume.all -t modern
|
||||||
|
|
||||||
# Generate a specific resume format
|
# Generate a specific resume format
|
||||||
fluentcmd resume.json resume.html -t informatic
|
fluentcmd resume.json -o out/resume.html
|
||||||
fluentcmd resume.json resume.txt -t informatic
|
fluentcmd resume.json -o out/resume.pdf
|
||||||
fluentcmd resume.json resume.pdf -t informatic
|
fluentcmd resume.json -o out/resume.md
|
||||||
fluentcmd resume.json resume.doc -t informatic
|
fluentcmd resume.json -o out/resume.doc
|
||||||
|
fluentcmd resume.json -o out/resume.json
|
||||||
|
fluentcmd resume.json -o out/resume.txt
|
||||||
|
fluentcmd resume.json -o out/resume.yml
|
||||||
|
|
||||||
|
# Specify 2 inputs and 3 outputs
|
||||||
|
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.1.0 ***
|
*** FluentCMD v0.5.0 ***
|
||||||
Reading JSON resume: foo/resume.json
|
Reading JSON resume: foo/resume.json
|
||||||
|
Applying MODERN Theme (7 formats)
|
||||||
Generating HTML resume: out/resume.html
|
Generating HTML resume: out/resume.html
|
||||||
Generating TXT resume: out/resume.txt
|
Generating TXT resume: out/resume.txt
|
||||||
Generating DOC resume: out/resume.doc
|
Generating DOC resume: out/resume.doc
|
||||||
Generating PDF resume: out/resume.pdf
|
Generating PDF resume: out/resume.pdf
|
||||||
|
Generating JSON resume: out/resume.json
|
||||||
|
Generating MARKDOWN resume: out/resume.md
|
||||||
|
Generating YAML resume: out/resume.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
## Advanced
|
## Advanced
|
||||||
|
|
||||||
|
### Applying a theme
|
||||||
|
|
||||||
|
You can specify a predefined or custom theme via the optional `-t` parameter. For a predefined theme, include the theme name. For a custom theme, include the path to the custom theme's folder.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fluentcmd resume.json -t modern
|
||||||
|
fluentcmd resume.json -t ~/foo/bar/my-custom-theme/
|
||||||
|
```
|
||||||
|
|
||||||
|
As of v0.5.0, available predefined themes are `modern`, `minimist`, and `hello-world`.
|
||||||
|
|
||||||
### Merging resumes
|
### Merging resumes
|
||||||
|
|
||||||
You can **merge multiple resumes together** by specifying them in order from most generic to most specific:
|
You can **merge multiple resumes together** by specifying them in order from most generic to most specific:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Merge specific.json onto base.json and generate all formats
|
# Merge specific.json onto base.json and generate all formats
|
||||||
fluentcmd base.json specific.json resume.all
|
fluentcmd base.json specific.json -o resume.all
|
||||||
```
|
```
|
||||||
|
|
||||||
This can be useful for overriding a base (generic) resume with information from a specific (targeted) resume. For example, you might override your generic catch-all "software developer" resume with specific details from your targeted "game developer" resume, or combine two partial resumes into a "complete" resume. Merging follows conventional [extend()][9]-style behavior and there's no arbitrary limit to how many resumes you can merge:
|
This can be useful for overriding a base (generic) resume with information from a specific (targeted) resume. For example, you might override your generic catch-all "software developer" resume with specific details from your targeted "game developer" resume, or combine two partial resumes into a "complete" resume. Merging follows conventional [extend()][9]-style behavior and there's no arbitrary limit to how many resumes you can merge:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
fluentcmd in1.json in2.json in3.json in4.json out.html out.doc
|
fluentcmd in1.json in2.json in3.json in4.json -o out.html -o out.doc
|
||||||
Reading JSON resume: in1.json
|
Reading JSON resume: in1.json
|
||||||
Reading JSON resume: in2.json
|
Reading JSON resume: in2.json
|
||||||
Reading JSON resume: in3.json
|
Reading JSON resume: in3.json
|
||||||
@ -88,13 +124,13 @@ You can specify **multiple output targets** and FluentCMD will build them:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Generate out1.doc, out1.pdf, and foo.txt from me.json.
|
# Generate out1.doc, out1.pdf, and foo.txt from me.json.
|
||||||
fluentcmd me.json out1.doc out1.pdf foo.txt
|
fluentcmd me.json -o out1.doc -o out1.pdf -o foo.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also omit the output file(s) and/or theme completely:
|
You can also omit the output file(s) and/or theme completely:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Equivalent to "fluentcmd resume.json resume.all -t informatic"
|
# Equivalent to "fluentcmd resume.json resume.all -t modern"
|
||||||
fluentcmd resume.json
|
fluentcmd resume.json
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -104,14 +140,26 @@ The special `.all` extension tells FluentCMD to generate all supported output fo
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Generate all resume formats (HTML, PDF, DOC, TXT, etc.)
|
# Generate all resume formats (HTML, PDF, DOC, TXT, etc.)
|
||||||
fluentcmd input.json output.all
|
fluentcmd me.json -o out/resume.all
|
||||||
```
|
```
|
||||||
|
|
||||||
..tells FluentCV to read `input.json` and generate `output.doc`, `output.html`, `output.txt`, `output.pdf`. That's more or less equivalent to:
|
..tells FluentCV to read `me.json` and generate `out/resume.md`, `out/resume.doc`, `out/resume.html`, `out/resume.txt`, `out/resume.pdf`, and `out/resume.json`.
|
||||||
|
|
||||||
|
### Prettifying
|
||||||
|
|
||||||
|
FluentCMD applies [js-beautify][10]-style HTML prettification by default to HTML-formatted resumes. To disable prettification, the `--nopretty` or `-n` flag can be used:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Generate all resume formats (HTML, PDF, DOC, TXT)
|
fluentcmd resume.json out.all --nopretty
|
||||||
fluentcmd input.json output.doc output.html output.txt output.pdf
|
```
|
||||||
|
|
||||||
|
### Silent Mode
|
||||||
|
|
||||||
|
Use `-s` or `--silent` to run in silent mode:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fluentcmd resume.json -o someFile.all -s
|
||||||
|
fluentcmd resume.json -o someFile.all --silent
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
@ -127,3 +175,4 @@ MIT. Go crazy. See [LICENSE.md][1] for details.
|
|||||||
[7]: http://fluentcv.com
|
[7]: http://fluentcv.com
|
||||||
[8]: https://youtu.be/N9wsjroVlu8
|
[8]: https://youtu.be/N9wsjroVlu8
|
||||||
[9]: https://api.jquery.com/jquery.extend/
|
[9]: https://api.jquery.com/jquery.extend/
|
||||||
|
[10]: https://github.com/beautify-web/js-beautify
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fluentcmd",
|
"name": "fluentcmd",
|
||||||
"version": "0.1.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",
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,31 +9,39 @@ module.exports = function () {
|
|||||||
var path = require( 'path' )
|
var path = require( 'path' )
|
||||||
, extend = require( './utils/extend' )
|
, extend = require( './utils/extend' )
|
||||||
, unused = require('./utils/string')
|
, unused = require('./utils/string')
|
||||||
, FLUENT = require('fluentlib')
|
, fs = require('fs')
|
||||||
, _ = require('underscore')
|
, _ = require('underscore')
|
||||||
, rez, _log;
|
, FLUENT = require('fluentlib')
|
||||||
|
, PATH = require('path')
|
||||||
|
, MKDIRP = require('mkdirp')
|
||||||
|
, rez, _log, _err;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Given a source JSON resume, a destination resume path, and a theme file,
|
Given a source JSON resume, a destination resume path, and a theme file,
|
||||||
generate 0..N resumes in the desired formats.
|
generate 0..N resumes in the desired formats.
|
||||||
@param src Path to the source JSON resume file: "rez/resume.json".
|
@param src Path to the source JSON resume file: "rez/resume.json".
|
||||||
@param dst An array of paths to the target resume file(s).
|
@param dst An array of paths to the target resume file(s).
|
||||||
@param theme Friendly name of the resume theme. Defaults to "informatic".
|
@param theme Friendly name of the resume theme. Defaults to "modern".
|
||||||
@param logger Optional logging override.
|
@param logger Optional logging override.
|
||||||
*/
|
*/
|
||||||
function gen( src, dst, theme, logger ) {
|
function gen( src, dst, opts, logger, errHandler ) {
|
||||||
|
|
||||||
_log = logger || console.log;
|
_log = logger || console.log;
|
||||||
_opts.theme = theme;
|
_err = errHandler || error;
|
||||||
var msg = '';
|
|
||||||
|
//_opts = extend( true, _opts, opts );
|
||||||
|
_opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern';
|
||||||
|
_opts.prettify = opts.prettify === true ? _opts.prettify : false;
|
||||||
|
|
||||||
// Load input resumes...
|
// Load input resumes...
|
||||||
|
if(!src || !src.length) { throw { fluenterror: 3 }; }
|
||||||
var sheets = src.map( function( res ) {
|
var sheets = src.map( function( res ) {
|
||||||
_log( 'Reading JSON resume: ' + res );
|
_log( 'Reading JSON resume: ' + res );
|
||||||
return (new FLUENT.Sheet()).open( res );
|
return (new FLUENT.Sheet()).open( res );
|
||||||
});
|
});
|
||||||
|
|
||||||
// Merge input resumes...
|
// Merge input resumes...
|
||||||
|
var msg = '';
|
||||||
rez = _.reduceRight( sheets, function( a, b, idx ) {
|
rez = _.reduceRight( sheets, function( a, b, idx ) {
|
||||||
msg += ((idx == sheets.length - 2) ? 'Merging ' + a.meta.fileName : '')
|
msg += ((idx == sheets.length - 2) ? 'Merging ' + a.meta.fileName : '')
|
||||||
+ ' onto ' + b.meta.fileName;
|
+ ' onto ' + b.meta.fileName;
|
||||||
@ -41,16 +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 to.replace(/all$/g,z.name); }) : [to]);
|
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: 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 };
|
||||||
@ -61,34 +85,28 @@ 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( f ) {
|
function single( fi, theme ) {
|
||||||
try {
|
try {
|
||||||
// Get the output file type (pdf, html, txt, etc)
|
var f = fi.file, fType = fi.fmt.ext, fName = path.basename( f, '.' + fType );
|
||||||
var fType = path.extname( f ).trim().toLowerCase().substr(1);
|
var fObj = _.property( fi.fmt.pre )( theme.formats );
|
||||||
var fName = path.basename( f, '.' + fType );
|
var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.pre );
|
||||||
|
_log( 'Generating ' + fi.fmt.title.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f ) );
|
||||||
// Get the format object (if any) corresponding to that type, and assemble
|
var theFormat = _fmts.filter( function( fmt ) {
|
||||||
// the final output file path for the generated resume.
|
return fmt.name === fi.fmt.pre;
|
||||||
var fObj = _fmts.filter( function(_f) { return _f.name === fType; } )[0];
|
})[0];
|
||||||
var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.ext );
|
MKDIRP( path.dirname(fOut) ); // Ensure dest folder exists; don't bug user
|
||||||
|
theFormat.gen.generate( rez, fOut, _opts );
|
||||||
// Generate!
|
|
||||||
_log( 'Generating ' + fType.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f) );
|
|
||||||
return fObj.gen.generate( rez, fOut, _opts.theme );
|
|
||||||
}
|
}
|
||||||
catch( ex ) {
|
catch( ex ) {
|
||||||
err( ex );
|
_err( ex );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handle an exception.
|
Handle an exception.
|
||||||
*/
|
*/
|
||||||
function err( ex ) {
|
function error( ex ) {
|
||||||
var msg = ex.toString();
|
throw ex;
|
||||||
var idx = msg.indexOf('Error: ');
|
|
||||||
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
|
|
||||||
_log( 'ERROR: ' + trimmed.toString() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,15 +116,24 @@ module.exports = function () {
|
|||||||
{ name: 'html', ext: 'html', gen: new FLUENT.HtmlGenerator() },
|
{ name: 'html', ext: 'html', gen: new FLUENT.HtmlGenerator() },
|
||||||
{ 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: 'md', ext: 'md', fmt: 'txt', gen: new FLUENT.MarkdownGenerator() },
|
||||||
|
{ name: 'json', ext: 'json', gen: new FLUENT.JsonGenerator() },
|
||||||
|
{ name: 'yml', ext: 'yml', fmt: 'yml', gen: new FLUENT.JsonYamlGenerator() }
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Default options.
|
Default FluentCMD options.
|
||||||
*/
|
*/
|
||||||
var _opts = {
|
var _opts = {
|
||||||
theme: 'informatic',
|
theme: 'modern',
|
||||||
}
|
prettify: { // ← See https://github.com/beautify-web/js-beautify#options
|
||||||
|
indent_size: 2,
|
||||||
|
unformatted: ['em','strong'],
|
||||||
|
max_char: 80, // ← See lib/html.js in above-linked repo
|
||||||
|
//wrap_line_length: 120, ← Don't use this
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Internal module interface. Used by FCV Desktop and HMR.
|
Internal module interface. Used by FCV Desktop and HMR.
|
||||||
|
61
src/index.js
61
src/index.js
@ -6,19 +6,62 @@ Command-line interface (CLI) for FluentCMD via Node.js.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var ARGS = require( 'minimist' )
|
var ARGS = require( 'minimist' )
|
||||||
, FCMD = require( './fluentcmd');
|
, FCMD = require( './fluentcmd')
|
||||||
|
, PKG = require('../package.json');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log( '*** FluentCMD v0.1.0 ***' );
|
var opts = { };
|
||||||
if( process.argv.length <= 2 ) { throw 'Please specify a JSON resume file.'; }
|
main();
|
||||||
var args = ARGS( process.argv.slice(2) );
|
|
||||||
var src = args._.filter( function( a ) { return a.endsWith('.json'); });
|
|
||||||
var dst = args._.filter( function( a ) { return !a.endsWith('.json'); });
|
|
||||||
FCMD.generate( src, dst, args.t || 'informatic' );
|
|
||||||
process.platform !== 'win32' && console.log('\n');
|
|
||||||
}
|
}
|
||||||
catch( ex ) {
|
catch( ex ) {
|
||||||
var msg = ex.toString();
|
handleError( ex );
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
|
||||||
|
// Setup.
|
||||||
|
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
|
||||||
|
var src = args._ || [];
|
||||||
|
var dst = (args.o && ((typeof args.o === 'string' && [ args.o ]) || args.o)) || [];
|
||||||
|
dst = (dst === true) ? [] : dst; // Handle -o with missing output file
|
||||||
|
|
||||||
|
// Generate!
|
||||||
|
FCMD.generate( src, dst, opts, logMsg );
|
||||||
|
process.platform !== 'win32' && console.log('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
function logMsg( msg ) {
|
||||||
|
opts.silent || console.log( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOpts( args ) {
|
||||||
|
var noPretty = args['nopretty'] || args.n;
|
||||||
|
noPretty = noPretty && (noPretty === true || noPretty === 'true');
|
||||||
|
return {
|
||||||
|
theme: args.t || 'modern',
|
||||||
|
prettify: !noPretty,
|
||||||
|
silent: args.s || args.silent
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleError( ex ) {
|
||||||
|
var msg = '';
|
||||||
|
if( ex.fluenterror ){
|
||||||
|
switch( ex.fluenterror ) { // TODO: Remove magic numbers
|
||||||
|
case 1: msg = "The specified theme couldn't be found: " + ex.data; break;
|
||||||
|
case 2: msg = "Couldn't copy CSS file to destination folder"; break;
|
||||||
|
case 3: msg = "Please specify a valid JSON resume file."; break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = ex.toString();
|
||||||
|
}
|
||||||
|
|
||||||
var idx = msg.indexOf('Error: ');
|
var idx = msg.indexOf('Error: ');
|
||||||
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
|
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
|
||||||
console.log( 'ERROR: ' + trimmed.toString() );
|
console.log( 'ERROR: ' + trimmed.toString() );
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
};
|
Reference in New Issue
Block a user