mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-12 00:27:08 +01:00
Compare commits
210 Commits
Author | SHA1 | Date | |
---|---|---|---|
c7a271a794 | |||
1c03b579b6 | |||
500f9d9d6d | |||
ab6e7ee1a0 | |||
8cccd2ffbb | |||
c6efdeca05 | |||
42d249b407 | |||
8a46d642e5 | |||
b7cd01597e | |||
73c5674af8 | |||
b077ff42e4 | |||
1bc3485812 | |||
7597eda198 | |||
3badb46ae4 | |||
30affe351d | |||
407f9f8cd7 | |||
922c1968ca | |||
093a2c6a56 | |||
031b666b0a | |||
033b29fd3a | |||
c4f7350528 | |||
7144126175 | |||
a5739f337f | |||
98f20c368c | |||
2281b4ea7f | |||
7196bff27c | |||
7cfdb95a04 | |||
58fe46dc83 | |||
17e5c6c172 | |||
ea3c72845e | |||
06805578a2 | |||
20815d7eff | |||
8648befcdd | |||
c08c5f0fa3 | |||
38a073b09a | |||
2346562428 | |||
2bf5bb72cf | |||
7262578c81 | |||
66f3cb15c9 | |||
6f07141b0d | |||
dc88073bcc | |||
8c81a54565 | |||
8dca5b76e7 | |||
2767b16b47 | |||
f1343add71 | |||
81d9d5f157 | |||
caca653666 | |||
55196c2766 | |||
00067d012a | |||
9da69c3310 | |||
02f0af1ff8 | |||
b1515fc656 | |||
ba719166f7 | |||
db6ec47dcc | |||
f53c316ecb | |||
e889481ad8 | |||
2b31f5bb58 | |||
7912ec9ef5 | |||
e6e0b135ed | |||
54d056c4b7 | |||
157a2a6145 | |||
688767d415 | |||
1dbb78c53f | |||
9c096541ce | |||
5161a3a823 | |||
76a386c9df | |||
7d78deec5f | |||
a265fb633d | |||
069506e86d | |||
7f656175f0 | |||
94fc54174c | |||
231357badc | |||
fde2146a0b | |||
c6adab7f9e | |||
7f7c936897 | |||
a9e35203c2 | |||
c913de4bf7 | |||
6b125ed907 | |||
17259cedbf | |||
12a14dadeb | |||
35fb2f5dac | |||
097e81caf8 | |||
6adf195281 | |||
79c304a08b | |||
394d5cf821 | |||
6092f985f2 | |||
2c26c21144 | |||
6bd0b817af | |||
97fe171775 | |||
9718c652ab | |||
9aad6d6138 | |||
d25f8d0f97 | |||
d2d9039abb | |||
3dc6ff2158 | |||
36f5f46753 | |||
8cc6334cd1 | |||
b7ef40709e | |||
efe97ad793 | |||
a243354044 | |||
92c477e139 | |||
ec591b9432 | |||
419c935d82 | |||
d31f6caf50 | |||
7e2a3c3e7e | |||
406d3358eb | |||
98ef625d7b | |||
be8a7a8361 | |||
37720677f0 | |||
0cd59416b8 | |||
abdeeb4385 | |||
bb7944bee7 | |||
9de1156144 | |||
9ae2703eeb | |||
a3ed56dd15 | |||
214c53a3ab | |||
ba6b8d45f5 | |||
3c166a21a0 | |||
fe46d15031 | |||
664eea752f | |||
fed59b704e | |||
3cf850ea0e | |||
1b0bc87b60 | |||
5d3b993737 | |||
917fd8e3f3 | |||
6ac2cd490b | |||
8100190978 | |||
7c36ff8331 | |||
255a518565 | |||
2d595350c6 | |||
ca92d41d9e | |||
3f8e795c61 | |||
9927e79900 | |||
dbef9f0a35 | |||
c889664c31 | |||
7a60cd0bab | |||
964350d3c7 | |||
b57d9f05af | |||
b26799f9fc | |||
daeffd27b5 | |||
f87eb46549 | |||
da7cd28734 | |||
31e0bb69cc | |||
5c248cca2a | |||
f83eb018e8 | |||
317a250917 | |||
aaa5e1fc1f | |||
1bc4263a46 | |||
e191af1fb0 | |||
7c0a9bcc02 | |||
d894f62607 | |||
2758038858 | |||
661fb91861 | |||
3c551eb923 | |||
5bf4bda6de | |||
49ae016f08 | |||
89957aed76 | |||
233025ddcc | |||
11dd8952d8 | |||
d7c83613df | |||
a456093f13 | |||
dd4851498a | |||
f72b02a0f4 | |||
63a0c78fc5 | |||
fd39cc9fd9 | |||
70f45d468d | |||
212b01092c | |||
36d641801b | |||
bd278268f6 | |||
abe31e30e0 | |||
314d8d8763 | |||
ed0792e8f8 | |||
90765bf90b | |||
f1ba7765ee | |||
27c7a0264a | |||
8e806dc04f | |||
8ec6b5ed6a | |||
4ef4ec5d42 | |||
2f523b845b | |||
1c416f39d3 | |||
1de0eff7b3 | |||
f8a39b0908 | |||
d69e4635be | |||
4b7d594502 | |||
896b7055c1 | |||
0f65e4c9f3 | |||
e9971eb882 | |||
beb60d4074 | |||
4440d23584 | |||
aca67cec29 | |||
75a953aa73 | |||
15a0af8410 | |||
9f811336e4 | |||
a07faf6d50 | |||
f098ed507f | |||
80c36b96bc | |||
630cf59cfb | |||
165eb5d9cd | |||
d12e970af5 | |||
cf18c5d90d | |||
0497696dcf | |||
d007bd9bf6 | |||
5838b085c7 | |||
58b6ad841e | |||
fc937e3ec8 | |||
8652c7ecdf | |||
c882235eff | |||
d6c5239f9e | |||
4b2db3f720 | |||
9736777828 | |||
d3194fba19 |
17
.eslintrc.yml
Normal file
17
.eslintrc.yml
Normal file
@ -0,0 +1,17 @@
|
||||
env:
|
||||
es6: true
|
||||
node: true
|
||||
extends: 'eslint:recommended'
|
||||
rules:
|
||||
# indent:
|
||||
# - error
|
||||
# - 4
|
||||
linebreak-style:
|
||||
- error
|
||||
- unix
|
||||
quotes:
|
||||
- error
|
||||
- single
|
||||
semi:
|
||||
- error
|
||||
- always
|
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -1,9 +1,11 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
|
||||
* text=auto
|
||||
*.js text eol=lf
|
||||
*.json text eol=lf
|
||||
|
||||
# Standard to msysgit
|
||||
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
@ -14,3 +16,7 @@
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
|
||||
# Git LFS
|
||||
|
||||
*.ai filter=lfs diff=lfs merge=lfs -text
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,9 +1,9 @@
|
||||
node_modules/
|
||||
tests/sandbox/
|
||||
doc/
|
||||
docs/
|
||||
local/
|
||||
npm-debug.log
|
||||
*.map
|
||||
|
||||
# Emacs detritus
|
||||
# -*- mode: gitignore; -*-
|
||||
|
13
.npmignore
Normal file
13
.npmignore
Normal file
@ -0,0 +1,13 @@
|
||||
assets/
|
||||
test/
|
||||
doc/
|
||||
.travis.yml
|
||||
.eslintrc.yml
|
||||
Gruntfile.js
|
||||
.gitattributes
|
||||
ROADMAP.md
|
||||
BUILDING.md
|
||||
CONTRIBUTING.md
|
||||
CHANGELOG.md
|
||||
FAQ.md
|
||||
*.map
|
28
.travis.yml
28
.travis.yml
@ -1,9 +1,23 @@
|
||||
sudo: required
|
||||
before_install:
|
||||
# Prevents a shared object .so error when running wkhtmltopdf on certain
|
||||
# platforms (e.g., vanilla Ubuntu 16.04 LTS). Not necessary on current Travis.
|
||||
# - sudo apt-get install libxrender1
|
||||
install:
|
||||
# Install & link HackMyResume
|
||||
- npm install && npm link
|
||||
# Download and extract the latest wkhtmltopdf binaries
|
||||
- mkdir tmp && wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz -O tmp/wk.tar.xz
|
||||
- tar -xf tmp/wk.tar.xz -C ./tmp
|
||||
# Copy wkhtmltopdf binaries to /usr/bin (also makes them path-accessible)
|
||||
- sudo cp -R ./tmp/wkhtmltox/bin/* /usr/bin/
|
||||
# Now you can invoke "wkhtmltopdf" and "wkhtmltoimage" safely in tests.
|
||||
- wkhtmltopdf -V
|
||||
- wkhtmltoimage -V
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
- "0.12"
|
||||
- "4.0"
|
||||
- "4.1"
|
||||
- "4.2"
|
||||
- "5.0"
|
||||
- "6"
|
||||
- "7"
|
||||
- "8"
|
||||
- "9"
|
||||
- "lts/*"
|
||||
|
50
BUILDING.md
Normal file
50
BUILDING.md
Normal file
@ -0,0 +1,50 @@
|
||||
Building
|
||||
========
|
||||
|
||||
*See [CONTRIBUTING.md][contrib] for more information on contributing to the
|
||||
HackMyResume or FluentCV projects.*
|
||||
|
||||
HackMyResume is a standard Node.js command line app implemented in a mix of
|
||||
CoffeeScript and JavaScript. Setting up a build environment is easy:
|
||||
|
||||
|
||||
## Prerequisites ##
|
||||
|
||||
1. OS: Linux, OS X, or Windows
|
||||
|
||||
2. Install [Node.js][node] and [Grunt][grunt].
|
||||
|
||||
|
||||
## Set up a build environment ###
|
||||
|
||||
1. Fork [hacksalot/HackMyResume][hmr] to your GitHub account.
|
||||
|
||||
2. Clone your fork locally.
|
||||
|
||||
3. From within the top-level HackMyResume folder, run `npm install` to install
|
||||
project dependencies.
|
||||
|
||||
4. Create a new branch, based on the latest HackMyResume `dev` branch, to
|
||||
contain your work.
|
||||
|
||||
5. Run `npm link` in the HackMyResume folder so that the `hackmyresume` command
|
||||
will reference your local installation (you may need to
|
||||
`npm uninstall -g hackmyresume` first).
|
||||
|
||||
## Making changes
|
||||
|
||||
1. HackMyResume sources live in the [`/src`][src] folder.
|
||||
|
||||
2. When you're ready to submit your changes, run `grunt test` to run the HMR
|
||||
test suite. Fix any errors that occur.
|
||||
|
||||
3. Commit and push your changes.
|
||||
|
||||
4. Submit a pull request targeting the HackMyResume `dev` branch.
|
||||
|
||||
|
||||
[node]: https://nodejs.org/en/
|
||||
[grunt]: http://gruntjs.com/
|
||||
[hmr]: https://github.com/hacksalot/HackMyResume
|
||||
[src]: https://github.com/hacksalot/HackMyResume/tree/master/src
|
||||
[contrib]: https://github.com/hacksalot/HackMyResume/blob/master/CONTRIBUTING.md
|
201
CHANGELOG.md
201
CHANGELOG.md
@ -1,5 +1,199 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
## v1.9.0-beta
|
||||
|
||||
*Welcome to the first new version of HackMyResume in over a year. The purpose of
|
||||
this release is to gather feature enhancements and bug fixes collected over the
|
||||
past 18 months as we reorganize, rebrand, and prepare for the 2.0 release.*
|
||||
|
||||
### Added
|
||||
|
||||
- Support for **private resume fields**. Mark any non-leaf node in your resume
|
||||
JSON with the `private` property and it will be omitted from outbound resumes.
|
||||
|
||||
```json
|
||||
"employment": {
|
||||
"history": [
|
||||
{
|
||||
"employer": "Acme Real Estate"
|
||||
},
|
||||
{
|
||||
"employer": "Area 51 Alien Research Laboratory",
|
||||
"private": true
|
||||
},
|
||||
{
|
||||
"employer": "H&R Block"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
- Support for **PDF generation through WeasyPrint** in addition to the
|
||||
existing support for wkhtmltopdf and PhantomJS.
|
||||
|
||||
- Theme authors can now develop and package **custom Handlebars theme helpers**
|
||||
via the `helpers` key of the `theme.json` file (FRESH themes only) (#158).
|
||||
|
||||
- Help system has been updated with a `HELP` command and dedicated help pages
|
||||
for each command.
|
||||
|
||||
- Theme authors can **relocate theme assets** with the `baseFolder` property in
|
||||
the FRESH `theme.json`.
|
||||
|
||||
- HackMyResume will now **validate the options file** (if any) loaded with `-o`
|
||||
or `--options` and warn the user if necessary.
|
||||
|
||||
- Ability to **disable Handlebars encoding/escaping** of resume fields with
|
||||
`--no-escape`.
|
||||
|
||||
- Introduced the [fresh-test-themes][ftt] project as a repository for simple,
|
||||
test-only resume themes in the FRESH format.
|
||||
|
||||
### Changed
|
||||
|
||||
- Dropped support for Node 4 and 5. HackMyResume officially runs on Node 6+.
|
||||
|
||||
- The FRESCA project has been renamed to [fresh-resume-schema][fresca]. FRESCA
|
||||
is still the nickname.
|
||||
|
||||
- The HackMyResume web page has moved to https://fluentdesk.com/hackmyresume.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed an issue that would cause the `convert` command to detect the inbound
|
||||
resume type (FRESH or JRS) incorrectly (#162).
|
||||
|
||||
- Fixed an issue where generating new JRS resumes would cause a `null` or
|
||||
`undefined` error (#165).
|
||||
|
||||
- Fixed an issue preventing mixed-case themes from being loaded (#172).
|
||||
|
||||
- Fixed an issue requiring JSON Resume themes contain `json-resume-theme` in the
|
||||
theme path (#173).
|
||||
|
||||
- Fixed an issue that would cause strange `@@@@` characters to appear in
|
||||
generated resumes (#207, #168, #198).
|
||||
|
||||
- Fixed an issue that would cause resume generation to hang after a JSON Resume
|
||||
themed resume was generated (#182).
|
||||
|
||||
- Fixed an issue that would cause nothing to be generated for Markdown (.md)
|
||||
formats (#179).
|
||||
|
||||
- Fixed an issue that would prevent a JRS resume from being converted to FRESH
|
||||
via the `convert` command (#180).
|
||||
|
||||
- Fixed an issue that would cause broken styling for JSON Resume themes (#155).
|
||||
|
||||
### Internal
|
||||
|
||||
- Tests: fixed resume duration tests (#181).
|
||||
|
||||
- Style: move to
|
||||
|
||||
## v1.8.0
|
||||
|
||||
### Added
|
||||
|
||||
- Updated `Awesome` theme to latest version of [Awesome-CV][acv].
|
||||
|
||||
- Introduced new theme helpers: `pad`, `date`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed an issue where the `Awesome` theme wouldn't correctly generate LaTeX
|
||||
outputs (#138).
|
||||
|
||||
- Emit a line number for syntax errors around embedded newlines in JSON strings
|
||||
(#137).
|
||||
|
||||
- Fix several PDF / PNG generation errors (#132, others).
|
||||
|
||||
- Display a more helpful error message when attempting to generate a PDF or PNG
|
||||
on a machine where PhantomJS and/or wkhtmltopdf are either not installed or
|
||||
not path-accessible.
|
||||
|
||||
- Fixed an issue that would cause long-running PDF/PNG generation to fail in
|
||||
certain environments.
|
||||
|
||||
- Fixed an issue involving an unhelpful spawn-related exception (#136).
|
||||
|
||||
### Internal
|
||||
|
||||
- JSHint will no longer gripe at the use of `== null` and `!= null` in
|
||||
CoffeeScript transpilation.
|
||||
|
||||
- Introduced [template-friendly Awesome-CV fork][awefork] to isolate template
|
||||
expansion logic & provide better durability for HackMyResume's `awesome` theme.
|
||||
|
||||
- Fixed a couple temporary regressions (#139, #140) on the dev branch.
|
||||
|
||||
- Additional tests.
|
||||
|
||||
- Minor breaking HackMyResume API changes.
|
||||
|
||||
## v1.7.4
|
||||
|
||||
### Added
|
||||
|
||||
- [Build instructions](https://github.com/hacksalot/HackMyResume/blob/master/BUILDING.md).
|
||||
|
||||
### Changed
|
||||
|
||||
- More precise date handling.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Issue with incomplete PDF generation (#127).
|
||||
|
||||
- Issue with building JSON Resume themes (#128).
|
||||
|
||||
- Issue with generating `.json` output format by itself (#97).
|
||||
|
||||
## v1.7.3
|
||||
|
||||
### Fixed
|
||||
|
||||
- Issue with generated PDFs being chopped off and displaying a mysterious sequence of numbers of unknown and possibly alien origin (#127).
|
||||
|
||||
- Unsightly border on Modern:PDF.
|
||||
|
||||
- Modern|Positive:PDF formats now correctly reference their PDF-specific CSS files.
|
||||
|
||||
- `Incorrect helper use` warning in Positive:DOC.
|
||||
|
||||
## v1.7.2
|
||||
|
||||
### Changed
|
||||
|
||||
- Interim release supporting FluentCV Desktop.
|
||||
|
||||
### Internal
|
||||
|
||||
- Moved [HackMyCore](https://github.com/hacksalot/HackMyCore) dependency to
|
||||
submodule.
|
||||
|
||||
## v1.7.1
|
||||
|
||||
### Changed
|
||||
|
||||
- Caffeinate. CoffeeScript now used throughout
|
||||
[HackMyResume](https://github.com/hacksalot/HackMyResume) and
|
||||
[HackMyCore](https://github.com/hacksalot/HackMyCore); generated JavaScript
|
||||
lives in `/dist`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Issue with generating a single PDF with the `.pdf` extension (#99).
|
||||
|
||||
## v1.7.0
|
||||
|
||||
### Changed
|
||||
|
||||
- [Internal] Relocated HMR processing code to the
|
||||
[HackMyCore](https://github.com/hacksalot/HackMyCore) project. Shouldn't affect
|
||||
normal use.
|
||||
|
||||
## v1.6.0
|
||||
|
||||
### Major Improvements
|
||||
@ -302,5 +496,8 @@ theme.
|
||||
[i92]: https://github.com/hacksalot/HackMyResume/issues/92
|
||||
[i101]: https://github.com/hacksalot/HackMyResume/issues/101
|
||||
[i111]: https://github.com/hacksalot/HackMyResume/issues/111
|
||||
[fresca]: https://github.com/fluentdesk/FRESCA
|
||||
[themes]: https://github.com/fluentdesk/fresh-themes
|
||||
[fresca]: https://github.com/fresh-standard/fresh-resume-schema
|
||||
[themes]: https://github.com/fresh-standard/fresh-themes
|
||||
[awefork]: https://github.com/fluentdesk/Awesome-CV
|
||||
[acv]: https://github.com/posquit0/Awesome-CV
|
||||
[ftt]: https://github.com/fresh-standard/fresh-test-themes
|
||||
|
@ -4,17 +4,11 @@ Contributing
|
||||
*Note: HackMyResume is also available as [FluentCV][fcv]. Contributors are
|
||||
credited in both.*
|
||||
|
||||
HackMyResume needs your help! Our contribution workflow is based on [GitHub
|
||||
Flow][flow] and we respond to all pull requests and issues, usually within 24
|
||||
hours. HackMyResume has no corporate affiliation and no commercial basis, which
|
||||
allows the project to maintain a strict user-first policy, rapid development
|
||||
velocity, and a liberal stance on contributions and exotic functionality in
|
||||
keeping with the spirit (and name) of the tool.
|
||||
|
||||
In short, your code is welcome here.
|
||||
|
||||
## How To Contribute
|
||||
|
||||
*See [BUILDING.md][building] for instructions on setting up a HackMyResume
|
||||
development environment.*
|
||||
|
||||
1. Optional: [**open an issue**][iss] identifying the feature or bug you'd like
|
||||
to implement or fix. This step isn't required — you can start hacking away on
|
||||
HackMyResume without clearing it with us — but helps avoid duplication of work
|
||||
@ -25,7 +19,7 @@ similar; call it whatever you like) to perform your work in.
|
||||
4. **Install dependencies** by running `npm install` in the top-level
|
||||
HackMyResume folder.
|
||||
5. Make your **commits** as usual.
|
||||
6. **Verify** your changes locally with `npm test`.
|
||||
6. **Verify** your changes locally with `grunt test`.
|
||||
7. **Push** your commits.
|
||||
7. **Submit a pull request** from your feature branch to the HackMyResume `dev`
|
||||
branch.
|
||||
@ -39,7 +33,7 @@ HackMyResume is currently maintained by [hacksalot][ha] with assistance from
|
||||
or internal inquiries to:
|
||||
|
||||
```
|
||||
admin@hackmyresume.com
|
||||
admin@fluentdesk.com
|
||||
```
|
||||
|
||||
You can reach hacksalot directly at:
|
||||
@ -48,7 +42,7 @@ You can reach hacksalot directly at:
|
||||
hacksalot@indevious.com
|
||||
```
|
||||
|
||||
Thanks! See you out there in the trenches.
|
||||
Thanks for your interest in the HackMyResume project.
|
||||
|
||||
[fcv]: https://github.com/fluentdesk/fluentcv
|
||||
[flow]: https://guides.github.com/introduction/flow/
|
||||
@ -56,3 +50,4 @@ Thanks! See you out there in the trenches.
|
||||
[ha]: https://github.com/hacksalot
|
||||
[th]: https://github.com/tomheon
|
||||
[awesome]: https://github.com/hacksalot/HackMyResume/graphs/contributors
|
||||
[building]: https://github.com/hacksalot/HackMyResume/blob/master/BUILDING.md
|
||||
|
53
Gruntfile.js
53
Gruntfile.js
@ -17,54 +17,29 @@ module.exports = function (grunt) {
|
||||
all: { src: ['test/*.js'] }
|
||||
},
|
||||
|
||||
jsdoc : {
|
||||
dist : {
|
||||
src: ['src/**/*.js'],
|
||||
options: {
|
||||
private: true,
|
||||
destination: 'doc'
|
||||
}
|
||||
}
|
||||
clean: {
|
||||
test: ['test/sandbox']
|
||||
},
|
||||
|
||||
clean: ['test/sandbox'],
|
||||
|
||||
yuidoc: {
|
||||
compile: {
|
||||
name: '<%= pkg.name %>',
|
||||
description: '<%= pkg.description %>',
|
||||
version: '<%= pkg.version %>',
|
||||
url: '<%= pkg.homepage %>',
|
||||
options: {
|
||||
paths: 'src/',
|
||||
//themedir: 'path/to/custom/theme/',
|
||||
outdir: 'docs/'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
jshint: {
|
||||
options: {
|
||||
laxcomma: true,
|
||||
expr: true
|
||||
},
|
||||
all: ['Gruntfile.js', 'src/**/*.js', 'test/*.js']
|
||||
eslint: {
|
||||
target: ['Gruntfile.js', 'src/**/*.js', 'test/*.js']
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
grunt.initConfig( opts );
|
||||
|
||||
grunt.loadNpmTasks('grunt-simple-mocha');
|
||||
grunt.loadNpmTasks('grunt-contrib-yuidoc');
|
||||
grunt.loadNpmTasks('grunt-jsdoc');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-eslint');
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
|
||||
grunt.registerTask('test', 'Test the HackMyResume library.',
|
||||
function( config ) { grunt.task.run(['clean','jshint','simplemocha:all']); });
|
||||
grunt.registerTask('document', 'Generate HackMyResume library documentation.',
|
||||
function( config ) { grunt.task.run( ['jsdoc'] ); });
|
||||
grunt.registerTask('default', [ 'test', 'jsdoc' ]);
|
||||
// Use 'grunt test' for local testing
|
||||
grunt.registerTask('test', 'Test the HackMyResume application.',
|
||||
function() {
|
||||
grunt.task.run(['clean:test','eslint','simplemocha:all']);
|
||||
}
|
||||
);
|
||||
|
||||
// Default task - nothing to do but test
|
||||
grunt.registerTask('default', [ 'test' ]);
|
||||
|
||||
};
|
||||
|
22
LICENSE.md
22
LICENSE.md
@ -1,22 +0,0 @@
|
||||
The MIT License
|
||||
===============
|
||||
|
||||
Copyright (c) 2016 hacksalot (https://github.com/hacksalot)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
===============
|
||||
|
||||
Copyright (c) 2015-2018
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
218
README.md
218
README.md
@ -1,16 +1,17 @@
|
||||
HackMyResume
|
||||
============
|
||||
===
|
||||
|
||||
[![Latest release][img-release]][latest-release]
|
||||
[![Build status (MASTER)][img-master]][travis-url-master]
|
||||
[![Build status (DEV)][img-dev]][travis-url-dev]
|
||||
[![Join the chat at https://gitter.im/hacksalot/HackMyResume][badge]][gh]
|
||||
|
||||
*Create polished résumés and CVs in multiple formats from your command line or
|
||||
shell. Author in clean Markdown and JSON, export to Word, HTML, PDF, LaTeX,
|
||||
plain text, and other arbitrary formats. Fight the power, save trees. Compatible
|
||||
with [FRESH][fresca] and [JRS][6] resumes.*
|
||||
|
||||

|
||||

|
||||
|
||||
HackMyResume is a dev-friendly, local-only Swiss Army knife for resumes and CVs.
|
||||
Use it to:
|
||||
@ -26,6 +27,8 @@ metrics.
|
||||
HackMyResume is built with Node.js and runs on recent versions of OS X, Linux,
|
||||
or Windows. View the [FAQ](FAQ.md).
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
- OS X, Linux, and Windows.
|
||||
@ -61,9 +64,9 @@ Alternately, install the latest bleeding-edge version (updated daily):
|
||||
HackMyResume tries not to impose a specific PDF engine requirement on
|
||||
the user, but will instead work with whatever PDF engines you have installed.
|
||||
|
||||
Currently, HackMyResume's PDF generation requires either [Phantom.js][2] or
|
||||
[wkhtmltopdf][3] to be installed on your system and the `phantomjs` and/or
|
||||
`wkhtmltopdf` binaries to be accessible on your PATH. This is an optional
|
||||
Currently, HackMyResume's PDF generation requires one of [Phantom.js][2],
|
||||
[wkhtmltopdf][3], or [WeasyPrint][11] to be installed on your system and the
|
||||
corresponding binary to be accessible on your PATH. This is an optional
|
||||
requirement for users who care about PDF formats. If you don't care about PDF
|
||||
formats, skip this step.
|
||||
|
||||
@ -90,7 +93,7 @@ Then when you're ready to generate your resume, just reference the location of
|
||||
the theme folder as you installed it:
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD resume.json TO out/resume.all -t node_modules/jsonresume-theme-classy
|
||||
hackmyresume build resume.json TO out/resume.all -t node_modules/jsonresume-theme-classy
|
||||
```
|
||||
|
||||
Note: You can use install themes anywhere on your file system. You don't need a
|
||||
@ -107,26 +110,26 @@ Use it when you need to submit, upload, print, or email resumes in specific
|
||||
formats.
|
||||
|
||||
```bash
|
||||
# hackmyresume BUILD <INPUTS...> TO <OUTPUTS...> [-t THEME]
|
||||
hackmyresume BUILD resume.json TO out/resume.all
|
||||
hackmyresume BUILD r1.json r2.json TO out/rez.html out/rez.md foo/rez.all
|
||||
# hackmyresume build <INPUTS...> TO <OUTPUTS...> [-t THEME]
|
||||
hackmyresume build resume.json TO out/resume.all
|
||||
hackmyresume build r1.json r2.json TO out/rez.html out/rez.md foo/rez.all
|
||||
```
|
||||
|
||||
- **new** creates a new resume in FRESH or JSON Resume format.
|
||||
|
||||
```bash
|
||||
# hackmyresume NEW <OUTPUTS...> [-f <FORMAT>]
|
||||
hackmyresume NEW resume.json
|
||||
hackmyresume NEW resume.json -f fresh
|
||||
hackmyresume NEW r1.json r2.json -f jrs
|
||||
# hackmyresume new <OUTPUTS...> [-f <FORMAT>]
|
||||
hackmyresume new resume.json
|
||||
hackmyresume new resume.json -f fresh
|
||||
hackmyresume new r1.json r2.json -f jrs
|
||||
```
|
||||
|
||||
- **analyze** inspects your resume for keywords, duration, and other metrics.
|
||||
|
||||
```bash
|
||||
# hackmyresume ANALYZE <INPUTS...>
|
||||
hackmyresume ANALYZE resume.json
|
||||
hackmyresume ANALYZE r1.json r2.json
|
||||
# hackmyresume analyze <INPUTS...>
|
||||
hackmyresume analyze resume.json
|
||||
hackmyresume analyze r1.json r2.json
|
||||
```
|
||||
|
||||
- **convert** converts your source resume between FRESH and JSON Resume
|
||||
@ -134,29 +137,29 @@ formats. Use it to convert between the two formats to take advantage of tools
|
||||
and services.
|
||||
|
||||
```bash
|
||||
# hackmyresume CONVERT <INPUTS...> TO <OUTPUTS...>
|
||||
hackmyresume CONVERT resume.json TO resume-jrs.json
|
||||
hackmyresume CONVERT 1.json 2.json 3.json TO out/1.json out/2.json out/3.json
|
||||
# hackmyresume convert <INPUTS...> TO <OUTPUTS...>
|
||||
hackmyresume convert resume.json TO resume-jrs.json
|
||||
hackmyresume convert 1.json 2.json 3.json TO out/1.json out/2.json out/3.json
|
||||
```
|
||||
|
||||
- **validate** validates the specified resume against either the FRESH or JSON
|
||||
Resume schema. Use it to make sure your resume data is sufficient and complete.
|
||||
|
||||
```bash
|
||||
# hackmyresume VALIDATE <INPUTS...>
|
||||
hackmyresume VALIDATE resume.json
|
||||
hackmyresume VALIDATE r1.json r2.json r3.json
|
||||
# hackmyresume validate <INPUTS...>
|
||||
hackmyresume validate resume.json
|
||||
hackmyresume validate r1.json r2.json r3.json
|
||||
```
|
||||
|
||||
- **peek** echoes your resume or any field, property, or object path on your
|
||||
resume to standard output.
|
||||
|
||||
```bash
|
||||
# hackmyresume PEEK <INPUTS...> [OBJECT-PATH]
|
||||
hackmyresume PEEK rez.json # Echo the whole resume
|
||||
hackmyresume PEEK rez.json info.brief # Echo the "info.brief" field
|
||||
hackmyresume PEEK rez.json employment.history[1] # Echo the 1st job
|
||||
hackmyresume PEEK rez.json rez2.json info.brief # Compare value
|
||||
# hackmyresume peek <INPUTS...> [OBJECT-PATH]
|
||||
hackmyresume peek rez.json # Echo the whole resume
|
||||
hackmyresume peek rez.json info.brief # Echo the "info.brief" field
|
||||
hackmyresume peek rez.json employment.history[1] # Echo the 1st job
|
||||
hackmyresume peek rez.json rez2.json info.brief # Compare value
|
||||
```
|
||||
|
||||
## Supported Output Formats
|
||||
@ -183,7 +186,7 @@ Assuming you've got a JSON-formatted resume handy, generating resumes in
|
||||
different formats and combinations is easy. Just run:
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD <INPUTS> <OUTPUTS> [-t theme].
|
||||
hackmyresume build <inputs> to <outputs> [-t theme].
|
||||
```
|
||||
|
||||
Where `<INPUTS>` is one or more .json resume files, separated by spaces;
|
||||
@ -192,19 +195,19 @@ theme (default to Modern). For example:
|
||||
|
||||
```bash
|
||||
# Generate all resume formats (HTML, PDF, DOC, TXT, YML, etc.)
|
||||
hackmyresume BUILD resume.json TO out/resume.all -t modern
|
||||
hackmyresume build resume.json TO out/resume.all -t modern
|
||||
|
||||
# Generate a specific resume format
|
||||
hackmyresume BUILD resume.json TO out/resume.html
|
||||
hackmyresume BUILD resume.json TO out/resume.pdf
|
||||
hackmyresume BUILD resume.json TO out/resume.md
|
||||
hackmyresume BUILD resume.json TO out/resume.doc
|
||||
hackmyresume BUILD resume.json TO out/resume.json
|
||||
hackmyresume BUILD resume.json TO out/resume.txt
|
||||
hackmyresume BUILD resume.json TO out/resume.yml
|
||||
hackmyresume build resume.json TO out/resume.html
|
||||
hackmyresume build resume.json TO out/resume.pdf
|
||||
hackmyresume build resume.json TO out/resume.md
|
||||
hackmyresume build resume.json TO out/resume.doc
|
||||
hackmyresume build resume.json TO out/resume.json
|
||||
hackmyresume build resume.json TO out/resume.txt
|
||||
hackmyresume build resume.json TO out/resume.yml
|
||||
|
||||
# Specify 2 inputs and 3 outputs
|
||||
hackmyresume BUILD in1.json in2.json TO out.html out.doc out.pdf
|
||||
hackmyresume build in1.json in2.json TO out.html out.doc out.pdf
|
||||
```
|
||||
|
||||
You should see something to the effect of:
|
||||
@ -231,16 +234,16 @@ installed first). To specify a theme when generating your resume, use the `-t`
|
||||
or `--theme` parameter:
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD resume.json TO out/rez.all -t [theme]
|
||||
hackmyresume build resume.json TO out/rez.all -t [theme]
|
||||
```
|
||||
|
||||
The `[theme]` parameter can be the name of a predefined theme OR the path to any
|
||||
FRESH or JSON Resume theme folder:
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD resume.json TO out/rez.all -t modern
|
||||
hackmyresume BUILD resume.json TO OUT.rez.all -t ../some-folder/my-custom-theme/
|
||||
hackmyresume BUILD resume.json TO OUT.rez.all -t node_modules/jsonresume-theme-classy
|
||||
hackmyresume build resume.json TO out/rez.all -t modern
|
||||
hackmyresume build resume.json TO OUT.rez.all -t ../some-folder/my-custom-theme/
|
||||
hackmyresume build resume.json TO OUT.rez.all -t node_modules/jsonresume-theme-classy
|
||||
```
|
||||
|
||||
FRESH themes are currently pre-installed with HackMyResume. JSON Resume themes
|
||||
@ -264,7 +267,7 @@ most generic to most specific:
|
||||
|
||||
```bash
|
||||
# Merge specific.json onto base.json and generate all formats
|
||||
hackmyresume BUILD base.json specific.json TO resume.all
|
||||
hackmyresume build base.json specific.json TO resume.all
|
||||
```
|
||||
|
||||
This can be useful for overriding a base (generic) resume with information from
|
||||
@ -275,7 +278,7 @@ resume. Merging follows conventional [extend()][9]-style behavior and there's
|
||||
no arbitrary limit to how many resumes you can merge:
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD in1.json in2.json in3.json in4.json TO out.html out.doc
|
||||
hackmyresume build in1.json in2.json in3.json in4.json TO out.html out.doc
|
||||
Reading JSON resume: in1.json
|
||||
Reading JSON resume: in2.json
|
||||
Reading JSON resume: in3.json
|
||||
@ -291,7 +294,7 @@ You can specify **multiple output targets** and HackMyResume will build them:
|
||||
|
||||
```bash
|
||||
# Generate out1.doc, out1.pdf, and foo.txt from me.json.
|
||||
hackmyresume BUILD me.json TO out1.doc out1.pdf foo.txt
|
||||
hackmyresume build me.json TO out1.doc out1.pdf foo.txt
|
||||
```
|
||||
|
||||
### Using .all
|
||||
@ -301,7 +304,7 @@ formats for the given resume. For example, this...
|
||||
|
||||
```bash
|
||||
# Generate all resume formats (HTML, PDF, DOC, TXT, etc.)
|
||||
hackmyresume BUILD me.json TO out/resume.all
|
||||
hackmyresume build me.json TO out/resume.all
|
||||
```
|
||||
|
||||
..tells HackMyResume to read `me.json` and generate `out/resume.md`,
|
||||
@ -316,19 +319,21 @@ and formats with the `--pdf none` switch.*
|
||||
HackMyResume takes a unique approach to PDF generation. Instead of enforcing
|
||||
a specific PDF engine on users, HackMyResume will attempt to work with whatever
|
||||
PDF engine you have installed through the engine's command-line interface (CLI).
|
||||
Currently that means one or both of...
|
||||
Currently that means any of...
|
||||
|
||||
- [wkhtmltopdf][3]
|
||||
- [Phantom.js][3]
|
||||
- [Phantom.js][2]
|
||||
- [WeasyPrint][11]
|
||||
|
||||
..with support for other engines planned in the future. But for now, **one or
|
||||
both of these engines must be installed and accessible on your PATH in order to
|
||||
generate PDF resumes with HackMyResume**. That means you should be able to
|
||||
more of these engines must be installed and accessible on your PATH in order
|
||||
to generate PDF resumes with HackMyResume**. That means you should be able to
|
||||
invoke either of these tools directly from your shell or terminal without error:
|
||||
|
||||
```bash
|
||||
wkhtmltopdf input.html output.pdf
|
||||
phantomjs script.js input.html output.pdf
|
||||
weasyprint input.html output.pdf
|
||||
```
|
||||
|
||||
Assuming you've installed one or both of these engines on your system, you can
|
||||
@ -336,9 +341,10 @@ tell HackMyResume which flavor of PDF generation to use via the `--pdf` option
|
||||
(`-p` for short):
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD resume.json TO out.all --pdf phantom
|
||||
hackmyresume BUILD resume.json TO out.all --pdf wkhtmltopdf
|
||||
hackmyresume BUILD resume.json TO out.all --pdf none
|
||||
hackmyresume build resume.json TO out.all --pdf phantom
|
||||
hackmyresume build resume.json TO out.all --pdf wkhtmltopdf
|
||||
hackmyresume build resume.json TO out.all --pdf weasyprint
|
||||
hackmyresume build resume.json TO out.all --pdf none
|
||||
```
|
||||
|
||||
### Analyzing
|
||||
@ -347,7 +353,7 @@ HackMyResume can analyze your resume for keywords, employment gaps, and other
|
||||
metrics. Run:
|
||||
|
||||
```bash
|
||||
hackmyresume ANALYZE <my-resume>.json
|
||||
hackmyresume analyze <my-resume>.json
|
||||
```
|
||||
|
||||
Depending on the HackMyResume version, you should see output similar to:
|
||||
@ -444,7 +450,7 @@ resumes, use the `validate` command:
|
||||
|
||||
```bash
|
||||
# Validate myresume.json against either the FRESH or JSON Resume schema.
|
||||
hackmyresume VALIDATE resumeA.json resumeB.json
|
||||
hackmyresume validate resumeA.json resumeB.json
|
||||
```
|
||||
|
||||
HackMyResume will validate each specified resume in turn:
|
||||
@ -461,7 +467,7 @@ HackMyResume can convert between the [FRESH][fresca] and [JSON Resume][6]
|
||||
formats. Just run:
|
||||
|
||||
```bash
|
||||
hackmyresume CONVERT <INPUTS> <OUTPUTS>
|
||||
hackmyresume convert <INPUTS> <OUTPUTS>
|
||||
```
|
||||
|
||||
where <INPUTS> is one or more resumes in FRESH or JSON Resume format, and
|
||||
@ -475,31 +481,34 @@ You can pass options into HackMyResume via an external options or ".hackmyrc"
|
||||
file with the `--options` or `-o` switch:
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD resume.json -o path/to/options.json
|
||||
hackmyresume build resume.json -o path/to/options.json
|
||||
```
|
||||
|
||||
The options file can contain any documented HackMyResume option, including
|
||||
`theme`, `silent`, `debug`, `pdf`, `css`, and other settings.
|
||||
|
||||
```javascript
|
||||
```json
|
||||
{
|
||||
// Set the default theme to "compact"
|
||||
"theme": "compact",
|
||||
// Change the "employment" section title text to "Work"
|
||||
|
||||
"sectionTitles": {
|
||||
"employment": "Work"
|
||||
},
|
||||
|
||||
"wkhtmltopdf": {
|
||||
"margin-top": "20mm"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If a particular option is specified both on the command line and in an external
|
||||
options file, the explicit command-line option takes precedence.
|
||||
If an option is specified on both the command line and in an external options
|
||||
file, the command-line option wins.
|
||||
|
||||
```bash
|
||||
# path/to/options.json specifes the POSITIVE theme
|
||||
# -t parameter specifies the COMPACT theme
|
||||
# The -t parameter wins.
|
||||
hackmyresume BUILD resume.json -o path/to/options.json -t compact
|
||||
hackmyresume build resume.json -o path/to/options.json -t compact
|
||||
> Reading resume: resume.json
|
||||
> Applying COMPACT theme (7 formats)
|
||||
```
|
||||
@ -511,7 +520,7 @@ HTML-formatted resumes. To disable prettification, the `--no-prettify` or `-n`
|
||||
flag can be used:
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD resume.json out.all --no-prettify
|
||||
hackmyresume build resume.json out.all --no-prettify
|
||||
```
|
||||
|
||||
### Silent Mode
|
||||
@ -519,8 +528,8 @@ hackmyresume BUILD resume.json out.all --no-prettify
|
||||
Use `-s` or `--silent` to run in silent mode:
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD resume.json -o someFile.all -s
|
||||
hackmyresume BUILD resume.json -o someFile.all --silent
|
||||
hackmyresume build resume.json -o someFile.all -s
|
||||
hackmyresume build resume.json -o someFile.all --silent
|
||||
```
|
||||
|
||||
### Debug Mode
|
||||
@ -529,15 +538,80 @@ Use `-d` or `--debug` to force HMR to emit a call stack when errors occur. In
|
||||
the future, this option will emit detailed error logging.
|
||||
|
||||
```bash
|
||||
hackmyresume BUILD resume.json -d
|
||||
hackmyresume ANALYZE resume.json --debug
|
||||
hackmyresume build resume.json -d
|
||||
hackmyresume analyze resume.json --debug
|
||||
```
|
||||
|
||||
### Disable Encoding
|
||||
|
||||
Use the `--no-escape` option to disable encoding in Handlebars themes. Note:
|
||||
this option has no effect for non-Handlebars themes.
|
||||
|
||||
```bash
|
||||
hackmyresume build resume.json --no-escape
|
||||
```
|
||||
|
||||
### Private Resume Fields
|
||||
|
||||
Have a gig, education stint, membership, or other relevant history that you'd
|
||||
like to hide from *most* (e.g. public) resumes but sometimes show on others? Tag it with
|
||||
`"private": true` to omit it from outbound generated resumes by default.
|
||||
|
||||
|
||||
```json
|
||||
"employment": {
|
||||
"history": [
|
||||
{
|
||||
"employer": "Acme Real Estate"
|
||||
},
|
||||
{
|
||||
"employer": "Area 51 Alien Research Laboratory",
|
||||
"private": true
|
||||
},
|
||||
{
|
||||
"employer": "H&R Block"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Then, when you want a copy of your resume that includes the private gig / stint
|
||||
/ etc., tell HackMyResume that it's OK to emit private fields. The way you do
|
||||
that is with the `--private` switch.
|
||||
|
||||
```bash
|
||||
hackmyresume build resume.json private-resume.all --private
|
||||
```
|
||||
|
||||
|
||||
### Custom theme helpers
|
||||
|
||||
You can attach your own custom Handlebars helpers to a FRESH theme with the
|
||||
`helpers` key of your theme's `theme.json` file.
|
||||
|
||||
```js
|
||||
{
|
||||
"title": "my-cool-theme",
|
||||
|
||||
// ...
|
||||
|
||||
"helpers": [
|
||||
"../path/to/helpers/*.js",
|
||||
"some-other-helper.js"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
HackMyResume will attempt to load each path or glob and register any specified
|
||||
files with [Handlebars.registerHelper][hrh], making them available to your
|
||||
theme.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
HackMyResume is a community-driven free and open source project under the MIT
|
||||
License. Contributions are encouraged and we respond to all PRs and issues,
|
||||
usually within 24 hours. See [CONTRIBUTING.md][contribute] for details.
|
||||
License. Contributions are encouraged and we respond to all PRs and issues in
|
||||
time. See [CONTRIBUTING.md][contribute] for details.
|
||||
|
||||
## License
|
||||
|
||||
@ -553,8 +627,9 @@ MIT. Go crazy. See [LICENSE.md][1] for details.
|
||||
[8]: https://youtu.be/N9wsjroVlu8
|
||||
[9]: https://api.jquery.com/jquery.extend/
|
||||
[10]: https://github.com/beautify-web/js-beautify
|
||||
[11]: http://weasyprint.org/
|
||||
[fresh]: https://github.com/fluentdesk/FRESH
|
||||
[fresca]: https://github.com/fluentdesk/FRESCA
|
||||
[fresca]: https://github.com/fresh-standard/fresh-resume-schema
|
||||
[dry]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
|
||||
[img-release]: https://img.shields.io/github/release/hacksalot/HackMyResume.svg?label=version
|
||||
[img-master]: https://img.shields.io/travis/hacksalot/HackMyResume/master.svg
|
||||
@ -565,3 +640,6 @@ MIT. Go crazy. See [LICENSE.md][1] for details.
|
||||
[contribute]: CONTRIBUTING.md
|
||||
[fresh-themes]: https://github.com/fluentdesk/fresh-themes
|
||||
[jrst]: https://www.npmjs.com/search?q=jsonresume-theme
|
||||
[gh]: https://gitter.im/hacksalot/HackMyResume?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
||||
[badge]: https://badges.gitter.im/hacksalot/HackMyResume.svg
|
||||
[hrh]: http://handlebarsjs.com/reference.html#base-registerHelper
|
||||
|
107
ROADMAP.md
Normal file
107
ROADMAP.md
Normal file
@ -0,0 +1,107 @@
|
||||
Development Roadmap
|
||||
===================
|
||||
|
||||
## Short-Term
|
||||
|
||||
### FluentCV Desktop: Beta 1
|
||||
|
||||
The **FluentCV Desktop 1.0 beta release** will present HackMyResume
|
||||
functionality in a cross-platform desktop application for OS X, Linux, and
|
||||
Windows.
|
||||
|
||||
### GitHub Integration
|
||||
|
||||
HackMyResume will offer GitHub integration for versioned resume storage and
|
||||
retrieval via the `COMMIT` or `STORE` command(s) starting in 1.7.0 or 1.8.0.
|
||||
|
||||
### fresh-themes 1.0.0
|
||||
|
||||
The **fresh-themes 1.0** release will bring 100% coverage of the FRESH and JRS
|
||||
object models—all resume sections and fields—along with
|
||||
documentation, theme developer's guide, new themes, and a freeze to the FRESH
|
||||
theme structure.
|
||||
|
||||
### Better LaTeX support
|
||||
|
||||
Including Markdown-to-LaTeX translation and more LaTeX-driven themes / formats.
|
||||
|
||||
### StackOverflow and LinkedIn support
|
||||
|
||||
Will start appearing in v1.7.0, with incremental improvements in 1.8.0 and
|
||||
beyond.
|
||||
|
||||
### Improved resume sorting and arranging
|
||||
|
||||
**Better resume sorting** of items and sections: ascending, descending, by
|
||||
date or other criteria ([#67][i67]).
|
||||
|
||||
### Remote resume / theme loading
|
||||
|
||||
Support remote loading of themes and resumes over `http`, `https`, and
|
||||
`git://`. Enable these usage patterns:
|
||||
|
||||
```bash
|
||||
hackmyresume build https://somesite.com/my-resume.json -t informatic
|
||||
|
||||
hackmyresume build resume.json -t npm:fresh-theme-ergonomic
|
||||
|
||||
hackmyresume analyze https://github.com/foo/my-resume
|
||||
```
|
||||
|
||||
### 100% code coverage
|
||||
|
||||
Should reduce certain classes of errors and allow HMR to display a nifty 100%
|
||||
code coverage badge.
|
||||
|
||||
### Improved **documentation and samples**
|
||||
|
||||
Expanded documentation and samples throughout.
|
||||
|
||||
## Mid-Term
|
||||
|
||||
### Cover letters and job descriptions
|
||||
|
||||
Add support for schema-driven **cover letters** and **job descriptions**.
|
||||
|
||||
### Character Sheets
|
||||
|
||||
HackMyResume 2.0 will ship with support for, yes, RPG-style character sheets.
|
||||
This will demonstrate the tool's ability to flow arbitrary JSON to concrete
|
||||
document(s) and provide unique albeit niche functionality around various games
|
||||
([#117][i117]).
|
||||
|
||||
### Rich text (.rtf) output formats
|
||||
|
||||
Basic support for **rich text** `.rtf` output formats.
|
||||
|
||||
### Investigate: groff support
|
||||
|
||||
Investigate adding [**groff**][groff] support, because that would, indeed, be
|
||||
[dope][d] ([#37][i37]).
|
||||
|
||||
### Investigate: org-mode support
|
||||
|
||||
Investigate adding [**org mode**][om] support ([#38][i38]).
|
||||
|
||||
### Investigate: Scribus
|
||||
|
||||
Investigate adding [**Scribus SLA**][scri] support ([#54][i54]).
|
||||
|
||||
### Support JSON Resume 1.0.0
|
||||
|
||||
When released.
|
||||
|
||||
## Long-Term
|
||||
|
||||
- TBD
|
||||
|
||||
[groff]: http://www.gnu.org/software/groff/
|
||||
[om]: http://orgmode.org/
|
||||
[scri]: https://en.wikipedia.org/wiki/Scribus
|
||||
[d]: https://github.com/hacksalot/HackMyResume/issues/37#issue-123818674
|
||||
[i37]: https://github.com/hacksalot/HackMyResume/issues/37
|
||||
[i38]: https://github.com/hacksalot/HackMyResume/issues/38
|
||||
[i54]: https://github.com/hacksalot/HackMyResume/issues/54
|
||||
[i67]: https://github.com/hacksalot/HackMyResume/issues/67
|
||||
[i107]: https://github.com/hacksalot/HackMyResume/issues/107
|
||||
[i117]: https://github.com/hacksalot/HackMyResume/issues/117
|
Binary file not shown.
Before Width: | Height: | Size: 83 KiB |
Binary file not shown.
Before Width: | Height: | Size: 83 KiB |
BIN
assets/hmr_analyze.png
Normal file
BIN
assets/hmr_analyze.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
assets/hmr_build.png
Normal file
BIN
assets/hmr_build.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
3
assets/logo/hackmyresume-logo.ai
Normal file
3
assets/logo/hackmyresume-logo.ai
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a476ee59e7d86b5a7599780b5efca57ee6b6d60e1a722343277057ea793703b6
|
||||
size 1642116
|
BIN
assets/logo/hackmyresume-logo.png
Normal file
BIN
assets/logo/hackmyresume-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
2800
npm-shrinkwrap.json
generated
Normal file
2800
npm-shrinkwrap.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
63
package.json
63
package.json
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "hackmyresume",
|
||||
"version": "1.6.0",
|
||||
"version": "1.9.0",
|
||||
"description": "Generate polished résumés and CVs in HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML, YAML, smoke signal, and carrier pigeon.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/hacksalot/HackMyResume.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt clean && mocha",
|
||||
"test": "grunt clean:test && mocha --exit",
|
||||
"grunt": "grunt"
|
||||
},
|
||||
"keywords": [
|
||||
@ -31,6 +31,7 @@
|
||||
"author": "hacksalot <hacksalot@indevious.com> (https://github.com/hacksalot)",
|
||||
"contributors": [
|
||||
"aruberto (https://github.com/aruberto)",
|
||||
"daniele-rapagnani (https://github.com/daniele-rapagnani)",
|
||||
"jjanusch (https://github.com/driftdev)",
|
||||
"robertmain (https://github.com/robertmain)",
|
||||
"tomheon (https://github.com/tomheon)",
|
||||
@ -42,61 +43,67 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/hacksalot/HackMyResume/issues"
|
||||
},
|
||||
"main": "src/hackmyapi.js",
|
||||
"bin": {
|
||||
"hackmyresume": "src/index.js"
|
||||
"hackmyresume": "src/cli/index.js"
|
||||
},
|
||||
"main": "src/index.js",
|
||||
"homepage": "https://github.com/hacksalot/HackMyResume",
|
||||
"dependencies": {
|
||||
"chalk": "^1.1.1",
|
||||
"chalk": "^2.3.1",
|
||||
"commander": "^2.9.0",
|
||||
"copy": "^0.1.3",
|
||||
"copy": "^0.3.1",
|
||||
"escape-latex": "^1.0.0",
|
||||
"extend": "^3.0.0",
|
||||
"fresca": "~0.6.0",
|
||||
"fresh-jrs-converter": "^0.2.0",
|
||||
"fresh-resume-starter": "^0.2.2",
|
||||
"fresh-themes": "~0.13.0-beta",
|
||||
"fs-extra": "^0.24.0",
|
||||
"fresh-jrs-converter": "^1.0.0",
|
||||
"fresh-resume-schema": "^1.0.0-beta",
|
||||
"fresh-resume-starter": "^0.3.1",
|
||||
"fresh-resume-validator": "^0.2.0",
|
||||
"fresh-themes": "^0.17.0-beta",
|
||||
"fs-extra": "^5.0.0",
|
||||
"glob": "^7.1.2",
|
||||
"handlebars": "^4.0.5",
|
||||
"html": "0.0.10",
|
||||
"is-my-json-valid": "^2.12.2",
|
||||
"html": "^1.0.0",
|
||||
"is-my-json-valid": "^2.12.4",
|
||||
"json-lint": "^0.1.0",
|
||||
"jst": "0.0.13",
|
||||
"lodash": "^3.10.1",
|
||||
"jsonlint": "^1.6.2",
|
||||
"lodash": "^4.17.5",
|
||||
"marked": "^0.3.5",
|
||||
"mkdirp": "^0.5.1",
|
||||
"moment": "^2.10.6",
|
||||
"parse-filepath": "^0.6.3",
|
||||
"path-exists": "^2.1.0",
|
||||
"moment": "^2.11.1",
|
||||
"parse-filepath": "^1.0.2",
|
||||
"path-exists": "^3.0.0",
|
||||
"pinkie-promise": "^2.0.0",
|
||||
"printf": "^0.2.3",
|
||||
"recursive-readdir-sync": "^1.0.6",
|
||||
"simple-html-tokenizer": "^0.2.0",
|
||||
"simple-html-tokenizer": "^0.4.3",
|
||||
"slash": "^1.0.0",
|
||||
"string-padding": "^1.0.2",
|
||||
"string.prototype.endswith": "^0.2.0",
|
||||
"string.prototype.startswith": "^0.2.0",
|
||||
"traverse": "^0.6.6",
|
||||
"underscore": "^1.8.3",
|
||||
"webshot": "^0.16.0",
|
||||
"word-wrap": "^1.1.0",
|
||||
"xml-escape": "^1.0.0",
|
||||
"yamljs": "^0.2.4"
|
||||
"yamljs": "^0.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "*",
|
||||
"fresh-test-resumes": "^0.6.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"dir-compare": "^1.4.0",
|
||||
"fresh-test-resumes": "^0.9.2",
|
||||
"fresh-test-themes": "^0.2.0",
|
||||
"fresh-theme-underscore": "^0.1.1",
|
||||
"grunt": "*",
|
||||
"grunt-cli": "^0.1.13",
|
||||
"grunt-contrib-clean": "^0.7.0",
|
||||
"grunt-contrib-jshint": "^0.11.3",
|
||||
"grunt-contrib-yuidoc": "^0.10.0",
|
||||
"grunt-jsdoc": "^1.1.0",
|
||||
"grunt-contrib-clean": "^1.1.0",
|
||||
"grunt-contrib-coffee": "^2.0.0",
|
||||
"grunt-contrib-copy": "^1.0.0",
|
||||
"grunt-eslint": "^20.1.0",
|
||||
"grunt-simple-mocha": "*",
|
||||
"jsonresume-theme-boilerplate": "^0.1.2",
|
||||
"jsonresume-theme-classy": "^1.0.9",
|
||||
"jsonresume-theme-modern": "0.0.18",
|
||||
"jsonresume-theme-sceptile": "^1.0.5",
|
||||
"mocha": "*",
|
||||
"resample": "fluentdesk/resample"
|
||||
"stripcolorcodes": "^0.1.0"
|
||||
}
|
||||
}
|
||||
|
552
src/cli/error.js
552
src/cli/error.js
@ -1,3 +1,9 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Error-handling routines for HackMyResume.
|
||||
@module cli/error
|
||||
@ -6,275 +12,317 @@ Error-handling routines for HackMyResume.
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const FS = require('fs');
|
||||
const PATH = require('path');
|
||||
const WRAP = require('word-wrap');
|
||||
const M2C = require('../utils/md2chalk');
|
||||
const chalk = require('chalk');
|
||||
const extend = require('extend');
|
||||
const printf = require('printf');
|
||||
const SyntaxErrorEx = require('../utils/syntax-error-ex');
|
||||
require('string.prototype.startswith');
|
||||
|
||||
|
||||
|
||||
var HMSTATUS = require('../core/status-codes')
|
||||
, PKG = require('../../package.json')
|
||||
, FS = require('fs')
|
||||
, FCMD = require('../hackmyapi')
|
||||
, PATH = require('path')
|
||||
, WRAP = require('word-wrap')
|
||||
, M2C = require('../utils/md2chalk.js')
|
||||
, chalk = require('chalk')
|
||||
, extend = require('extend')
|
||||
, YAML = require('yamljs')
|
||||
, printf = require('printf')
|
||||
, SyntaxErrorEx = require('../utils/syntax-error-ex');
|
||||
require('string.prototype.startswith');
|
||||
/** Error handler for HackMyResume. All errors are handled here.
|
||||
@class ErrorHandler */
|
||||
module.exports = {
|
||||
|
||||
init( debug, assert, silent ) {
|
||||
this.debug = debug;
|
||||
this.assert = assert;
|
||||
this.silent = silent;
|
||||
this.msgs = require('./msg').errors;
|
||||
return this;
|
||||
},
|
||||
|
||||
err( ex, shouldExit ) {
|
||||
|
||||
/**
|
||||
Error handler for HackMyResume. All errors are handled here.
|
||||
@class ErrorHandler
|
||||
*/
|
||||
var ErrorHandler = module.exports = {
|
||||
// Short-circuit logging output if --silent is on
|
||||
let stack;
|
||||
const o = this.silent ? function() {} : _defaultLog;
|
||||
|
||||
// Special case; can probably be removed.
|
||||
if (ex.pass) { throw ex; }
|
||||
|
||||
// Load error messages
|
||||
this.msgs = this.msgs || require('./msg').errors;
|
||||
|
||||
init: function( debug, assert, silent ) {
|
||||
this.debug = debug;
|
||||
this.assert = assert;
|
||||
this.silent = silent;
|
||||
this.msgs = require('./msg.js').errors;
|
||||
return this;
|
||||
},
|
||||
// Handle packaged HMR exceptions
|
||||
if (ex.fluenterror) {
|
||||
|
||||
// Output the error message
|
||||
const objError = assembleError.call(this, ex);
|
||||
o( this[ `format_${objError.etype}` ]( objError.msg ));
|
||||
|
||||
|
||||
err: function( ex, shouldExit ) {
|
||||
|
||||
// Short-circuit logging output if --silent is on
|
||||
var o = this.silent ? function() { } : _defaultLog;
|
||||
|
||||
// Special case; can probably be removed.
|
||||
if( ex.pass ) throw ex;
|
||||
|
||||
// Load error messages
|
||||
this.msgs = this.msgs || require('./msg.js').errors;
|
||||
|
||||
// Handle packaged HMR exceptions
|
||||
if( ex.fluenterror ) {
|
||||
|
||||
// Output the error message
|
||||
var objError = assembleError.call( this, ex );
|
||||
o( this[ 'format_' + objError.etype ]( objError.msg ));
|
||||
|
||||
// Output the stack (sometimes)
|
||||
if( objError.withStack ) {
|
||||
var stack = ex.stack || (ex.inner && ex.inner.stack);
|
||||
stack && o( chalk.gray( stack ) );
|
||||
}
|
||||
|
||||
// Quit if necessary
|
||||
if( ex.quit || objError.quit ) {
|
||||
this.debug && o(
|
||||
chalk.cyan('Exiting with error code ' + ex.fluenterror.toString()));
|
||||
if( this.assert ) { ex.pass = true; throw ex; }
|
||||
process.exit( ex.fluenterror );
|
||||
}
|
||||
|
||||
// Output the stack (sometimes)
|
||||
if (objError.withStack) {
|
||||
stack = ex.stack || (ex.inner && ex.inner.stack);
|
||||
stack && o( chalk.gray( stack ) );
|
||||
}
|
||||
|
||||
// Handle raw exceptions
|
||||
else {
|
||||
o( ex );
|
||||
var stackTrace = ex.stack || (ex.inner && ex.inner.stack);
|
||||
if( stackTrace && this.debug )
|
||||
o( M2C(ex.stack || ex.inner.stack, 'gray') );
|
||||
// Quit if necessary
|
||||
if (shouldExit || ex.exit) {
|
||||
if (this.debug) {
|
||||
o(chalk.cyan(`Exiting with error code ${ex.fluenterror.toString()}`));
|
||||
}
|
||||
if (this.assert) {
|
||||
ex.pass = true;
|
||||
throw ex;
|
||||
}
|
||||
return process.exit(ex.fluenterror);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
format_error: function( msg ) {
|
||||
msg = msg || '';
|
||||
return chalk.red.bold(
|
||||
msg.toUpperCase().startsWith('ERROR:') ? msg : 'Error: ' + msg );
|
||||
},
|
||||
|
||||
|
||||
|
||||
format_warning: function( brief, msg ) {
|
||||
return chalk.yellow(brief) + chalk.yellow(msg || '');
|
||||
},
|
||||
|
||||
|
||||
format_custom: function( msg ) {
|
||||
return msg;
|
||||
// Handle raw exceptions
|
||||
} else {
|
||||
o(ex);
|
||||
const stackTrace = ex.stack || (ex.inner && ex.inner.stack);
|
||||
if (stackTrace && this.debug) {
|
||||
return o(M2C(ex.stack || ex.inner.stack, 'gray'));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
format_error( msg ) {
|
||||
msg = msg || '';
|
||||
return chalk.red.bold( msg.toUpperCase().startsWith('ERROR:') ? msg : `Error: ${msg}` );
|
||||
},
|
||||
|
||||
|
||||
format_warning( brief, msg ) {
|
||||
return chalk.yellow(brief) + chalk.yellow(msg || '');
|
||||
},
|
||||
|
||||
|
||||
format_custom( msg ) { return msg; }
|
||||
};
|
||||
|
||||
|
||||
var _defaultLog = function() { return console.log.apply(console.log, arguments); }; // eslint-disable-line no-console
|
||||
|
||||
|
||||
|
||||
|
||||
var assembleError = function( ex ) {
|
||||
|
||||
let se;
|
||||
let msg = '';
|
||||
let withStack = false;
|
||||
let quit = false;
|
||||
let etype = 'warning';
|
||||
if (this.debug) { withStack = true; }
|
||||
|
||||
switch (ex.fluenterror) {
|
||||
|
||||
case HMSTATUS.themeNotFound:
|
||||
msg = printf( M2C( this.msgs.themeNotFound.msg, 'yellow' ), ex.data);
|
||||
break;
|
||||
|
||||
case HMSTATUS.copyCSS:
|
||||
msg = M2C( this.msgs.copyCSS.msg, 'red' );
|
||||
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:
|
||||
msg = printf( M2C( this.msgs.invalidCommand.msg, 'yellow'), ex.attempted );
|
||||
break;
|
||||
|
||||
case HMSTATUS.resumeNotFoundAlt:
|
||||
msg = M2C( this.msgs.resumeNotFoundAlt.msg, 'yellow' );
|
||||
break;
|
||||
|
||||
case HMSTATUS.inputOutputParity:
|
||||
msg = M2C( this.msgs.inputOutputParity.msg );
|
||||
break;
|
||||
|
||||
case HMSTATUS.createNameMissing:
|
||||
msg = M2C( this.msgs.createNameMissing.msg );
|
||||
break;
|
||||
|
||||
case HMSTATUS.pdfGeneration:
|
||||
msg = M2C( this.msgs.pdfGeneration.msg, 'bold' );
|
||||
if (ex.inner) { msg += chalk.red(`\n${ex.inner}`); }
|
||||
quit = false;
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.invalid:
|
||||
msg = M2C( this.msgs.invalid.msg, 'red' );
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.generateError:
|
||||
msg = (ex.inner && ex.inner.toString()) || ex;
|
||||
quit = false;
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.fileSaveError:
|
||||
msg = printf( M2C( this.msgs.fileSaveError.msg ), (ex.inner || ex).toString() );
|
||||
etype = 'error';
|
||||
quit = false;
|
||||
break;
|
||||
|
||||
case HMSTATUS.invalidFormat:
|
||||
ex.data.forEach( function(d) {
|
||||
return msg += printf( M2C( this.msgs.invalidFormat.msg, 'bold' ),
|
||||
ex.theme.name.toUpperCase(), d.format.toUpperCase());
|
||||
}
|
||||
, this);
|
||||
break;
|
||||
|
||||
case HMSTATUS.missingParam:
|
||||
msg = printf(M2C( this.msgs.missingParam.msg ), ex.expected, ex.helper);
|
||||
break;
|
||||
|
||||
case HMSTATUS.invalidHelperUse:
|
||||
msg = printf( M2C( this.msgs.invalidHelperUse.msg ), ex.helper );
|
||||
if (ex.error) {
|
||||
msg += `\n--> ${assembleError.call( this, extend( true, {}, ex, {fluenterror: ex.error} )).msg}`;
|
||||
}
|
||||
//msg += printf( '\n--> ' + M2C( this.msgs.invalidParamCount.msg ), ex.expected );
|
||||
quit = false;
|
||||
etype = 'warning';
|
||||
break;
|
||||
|
||||
case HMSTATUS.notOnPath:
|
||||
msg = printf( M2C(this.msgs.notOnPath.msg, 'bold'), ex.engine);
|
||||
quit = false;
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.readError:
|
||||
if (!ex.quiet) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(printf( M2C(this.msgs.readError.msg, 'red'), ex.file));
|
||||
}
|
||||
msg = ex.inner.toString();
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.mixedMerge:
|
||||
msg = M2C(this.msgs.mixedMerge.msg);
|
||||
quit = false;
|
||||
break;
|
||||
|
||||
case HMSTATUS.invokeTemplate:
|
||||
msg = M2C(this.msgs.invokeTemplate.msg, 'red');
|
||||
msg += M2C( `\n${WRAP(ex.inner.toString(), { width: 60, indent: ' ' })}`, 'gray' );
|
||||
etype = 'custom';
|
||||
break;
|
||||
|
||||
case HMSTATUS.compileTemplate:
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.themeLoad:
|
||||
msg = M2C( printf( this.msgs.themeLoad.msg, ex.attempted.toUpperCase() ), 'red');
|
||||
if (ex.inner && ex.inner.fluenterror) {
|
||||
msg += M2C('\nError: ', 'red') + assembleError.call( this, ex.inner ).msg;
|
||||
}
|
||||
quit = true;
|
||||
etype = 'custom';
|
||||
break;
|
||||
|
||||
case HMSTATUS.parseError:
|
||||
if (SyntaxErrorEx.is(ex.inner)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(printf( M2C(this.msgs.readError.msg, 'red'), ex.file ));
|
||||
se = new SyntaxErrorEx(ex, ex.raw);
|
||||
if ((se.line != null) && (se.col != null)) {
|
||||
msg = printf(M2C( this.msgs.parseError.msg[0], 'red' ), se.line, se.col);
|
||||
} else if (se.line != null) {
|
||||
msg = printf(M2C( this.msgs.parseError.msg[1], 'red' ), se.line);
|
||||
} else {
|
||||
msg = M2C(this.msgs.parseError.msg[2], 'red');
|
||||
}
|
||||
} else if (ex.inner && (ex.inner.line != null) && (ex.inner.col != null)) {
|
||||
msg = printf( M2C( this.msgs.parseError.msg[0], 'red' ), ex.inner.line, ex.inner.col);
|
||||
} else {
|
||||
msg = ex;
|
||||
}
|
||||
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;
|
||||
|
||||
case HMSTATUS.validateError:
|
||||
msg = printf(M2C( this.msgs.validateError.msg ), ex.inner.toString());
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.invalidOptionsFile:
|
||||
msg = M2C(this.msgs.invalidOptionsFile.msg[0]);
|
||||
if (SyntaxErrorEx.is(ex.inner)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(printf( M2C(this.msgs.readError.msg, 'red'), ex.file ));
|
||||
se = new SyntaxErrorEx(ex, ex.raw);
|
||||
if ((se.line != null) && (se.col != null)) {
|
||||
msg += printf(M2C( this.msgs.parseError.msg[0], 'red' ), se.line, se.col);
|
||||
} else if (se.line != null) {
|
||||
msg += printf(M2C( this.msgs.parseError.msg[1], 'red' ), se.line);
|
||||
} else {
|
||||
msg += M2C(this.msgs.parseError.msg[2], 'red');
|
||||
}
|
||||
} else if (ex.inner && (ex.inner.line != null) && (ex.inner.col != null)) {
|
||||
msg += printf( M2C( this.msgs.parseError.msg[0], 'red' ), ex.inner.line, ex.inner.col);
|
||||
} else {
|
||||
msg += ex;
|
||||
}
|
||||
msg += this.msgs.invalidOptionsFile.msg[1];
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.optionsFileNotFound:
|
||||
msg = M2C( this.msgs.optionsFileNotFound.msg );
|
||||
etype = 'error';
|
||||
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:
|
||||
msg = printf(M2C( this.msgs.themeHelperLoad.msg ), ex.glob);
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.invalidSchemaVersion:
|
||||
msg = printf(M2C( this.msgs.invalidSchemaVersion.msg ), ex.data);
|
||||
etype = 'error';
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
msg, // The error message to display
|
||||
withStack, // Whether to include the stack
|
||||
quit,
|
||||
etype
|
||||
};
|
||||
|
||||
|
||||
|
||||
function _defaultLog() {
|
||||
console.log.apply( console.log, arguments );
|
||||
}
|
||||
|
||||
|
||||
|
||||
function assembleError( ex ) {
|
||||
|
||||
var msg = '', withStack = false, quit = false, etype = 'warning';
|
||||
if( this.debug ) withStack = true;
|
||||
|
||||
switch( ex.fluenterror ) {
|
||||
|
||||
case HMSTATUS.themeNotFound:
|
||||
msg = printf( M2C( this.msgs.themeNotFound.msg, 'yellow' ), ex.data);
|
||||
break;
|
||||
|
||||
case HMSTATUS.copyCSS:
|
||||
msg = M2C( this.msgs.copyCSS.msg, 'red' );
|
||||
quit = false;
|
||||
break;
|
||||
|
||||
case HMSTATUS.resumeNotFound:
|
||||
msg = M2C( this.msgs.resumeNotFound.msg, 'yellow' );
|
||||
break;
|
||||
|
||||
case HMSTATUS.missingCommand:
|
||||
msg = M2C( this.msgs.missingCommand.msg + " (", 'yellow');
|
||||
msg += Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
|
||||
return (idx === ar.length - 1 ? chalk.yellow('or ') : '') +
|
||||
chalk.yellow.bold(v.toUpperCase());
|
||||
}).join( chalk.yellow(', ')) + chalk.yellow(").\n\n");
|
||||
|
||||
msg += chalk.gray(FS.readFileSync(
|
||||
PATH.resolve(__dirname, '../cli/use.txt'), 'utf8' ));
|
||||
break;
|
||||
|
||||
case HMSTATUS.invalidCommand:
|
||||
msg = printf( M2C( this.msgs.invalidCommand.msg, 'yellow'), ex.attempted );
|
||||
break;
|
||||
|
||||
case HMSTATUS.resumeNotFoundAlt:
|
||||
msg = M2C( this.msgs.resumeNotFoundAlt.msg, 'yellow' );
|
||||
break;
|
||||
|
||||
case HMSTATUS.inputOutputParity:
|
||||
msg = M2C( this.msgs.inputOutputParity.msg );
|
||||
break;
|
||||
|
||||
case HMSTATUS.createNameMissing:
|
||||
msg = M2C( this.msgs.createNameMissing.msg );
|
||||
break;
|
||||
|
||||
case HMSTATUS.pdfGeneration:
|
||||
msg = M2C( this.msgs.pdfGeneration.msg, 'bold' );
|
||||
if( ex.inner ) msg += chalk.red('\n' + ex.inner);
|
||||
withStack = true; quit = false; etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.invalid:
|
||||
msg = M2C( this.msgs.invalid.msg, 'red' );
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.generateError:
|
||||
msg = (ex.inner && ex.inner.toString()) || ex;
|
||||
quit = false;
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.fileSaveError:
|
||||
msg = printf( M2C( this.msgs.fileSaveError.msg ), (ex.inner || ex).toString() );
|
||||
etype = 'error';
|
||||
quit = false;
|
||||
break;
|
||||
|
||||
case HMSTATUS.invalidFormat:
|
||||
ex.data.forEach(function(d){
|
||||
msg += printf( M2C( this.msgs.invalidFormat.msg, 'bold' ),
|
||||
ex.theme.name.toUpperCase(), d.format.toUpperCase());
|
||||
}, this);
|
||||
break;
|
||||
|
||||
case HMSTATUS.missingParam:
|
||||
msg = printf( M2C( this.msgs.missingParam.msg ), ex.expected, ex.helper );
|
||||
break;
|
||||
|
||||
case HMSTATUS.invalidHelperUse:
|
||||
msg = printf( M2C( this.msgs.invalidHelperUse.msg ), ex.helper );
|
||||
if( ex.error ) {
|
||||
msg += '\n--> ' + assembleError.call( this, extend( true, {}, ex, {fluenterror: ex.error} )).msg;
|
||||
//msg += printf( '\n--> ' + M2C( this.msgs.invalidParamCount.msg ), ex.expected );
|
||||
}
|
||||
quit = false;
|
||||
etype = 'warning';
|
||||
break;
|
||||
|
||||
case HMSTATUS.notOnPath:
|
||||
msg = printf( M2C(this.msgs.notOnPath.msg, 'bold'), ex.engine);
|
||||
quit = false;
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.readError:
|
||||
if( !ex.quiet )
|
||||
console.error(printf( M2C(this.msgs.readError.msg, 'red'), ex.file));
|
||||
msg = ex.inner.toString();
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.mixedMerge:
|
||||
msg = M2C( this.msgs.mixedMerge.msg );
|
||||
quit = false;
|
||||
break;
|
||||
|
||||
case HMSTATUS.invokeTemplate:
|
||||
msg = M2C( this.msgs.invokeTemplate.msg, 'red' );
|
||||
msg += M2C( '\n' + WRAP(ex.inner.toString(), { width: 60, indent: ' ' }), 'gray' );
|
||||
etype = 'custom';
|
||||
break;
|
||||
|
||||
case HMSTATUS.compileTemplate:
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
case HMSTATUS.themeLoad:
|
||||
msg = M2C( printf( this.msgs.themeLoad.msg, ex.attempted.toUpperCase() ), 'red');
|
||||
if( ex.inner && ex.inner.fluenterror ) {
|
||||
msg += M2C('\nError: ', 'red') + assembleError.call( this, ex.inner ).msg;
|
||||
}
|
||||
quit = true;
|
||||
etype = 'custom';
|
||||
break;
|
||||
|
||||
case HMSTATUS.parseError:
|
||||
if( SyntaxErrorEx.is( ex.inner )) {
|
||||
console.error( printf( M2C(this.msgs.readError.msg, 'red'), ex.file ) );
|
||||
var se = new SyntaxErrorEx( ex, ex.raw );
|
||||
msg = printf( M2C( this.msgs.parseError.msg, 'red' ),
|
||||
se.line, se.col);
|
||||
}
|
||||
else if( ex.inner && ex.inner.line !== undefined && ex.inner.col !== undefined ) {
|
||||
msg = printf( M2C( this.msgs.parseError.msg, 'red' ),
|
||||
ex.inner.line, ex.inner.col);
|
||||
}
|
||||
else {
|
||||
msg = ex;
|
||||
}
|
||||
etype = 'error';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
msg: msg, // The error message to display
|
||||
withStack: withStack, // Whether to include the stack
|
||||
quit: quit,
|
||||
etype: etype
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}());
|
||||
};
|
||||
|
25
src/cli/help/analyze.txt
Normal file
25
src/cli/help/analyze.txt
Normal file
@ -0,0 +1,25 @@
|
||||
**analyze** | Analyze a resume for statistical insight
|
||||
|
||||
Usage:
|
||||
|
||||
**hackmyresume ANALYZE <resume>**
|
||||
|
||||
The ANALYZE command evaluates the specified resume(s) for
|
||||
coverage, duration, gaps, keywords, and other metrics.
|
||||
|
||||
This command can be run against multiple resumes. Each
|
||||
will be analyzed in turn.
|
||||
|
||||
Parameters:
|
||||
|
||||
**<resume>**
|
||||
|
||||
Path to a FRESH or JRS resume. Multiple resumes can be
|
||||
specified, separated by spaces.
|
||||
|
||||
hackmyresume ANALYZE resume.json
|
||||
hackmyresume ANALYZE r1.json r2.json r3.json
|
||||
|
||||
Options:
|
||||
|
||||
**None.**
|
69
src/cli/help/build.txt
Normal file
69
src/cli/help/build.txt
Normal file
@ -0,0 +1,69 @@
|
||||
**build** | Generate themed resumes in multiple formats
|
||||
|
||||
Usage:
|
||||
|
||||
**hackmyresume BUILD <resume> TO <target> [--theme]**
|
||||
**[--pdf] [--no-escape] [--private]**
|
||||
|
||||
The BUILD command generates themed resumes and CVs in
|
||||
multiple formats. Use it to create outbound resumes in
|
||||
specific formats such HTML, MS Word, and PDF.
|
||||
|
||||
Parameters:
|
||||
|
||||
**<resume>**
|
||||
|
||||
Path to a FRESH or JRS resume (*.json) containing your
|
||||
resume data. Multiple resumes may be specified.
|
||||
|
||||
If multiple resumes are specified, they will be merged
|
||||
into a single resume prior to transformation.
|
||||
|
||||
**<target>**
|
||||
|
||||
Path to the desired output resume. Multiple resumes
|
||||
may be specified. The file extension will determine
|
||||
the format.
|
||||
|
||||
.all Generate all supported formats
|
||||
.html HTML 5
|
||||
.doc MS Word
|
||||
.pdf Adobe Acrobat PDF
|
||||
.txt plain text
|
||||
.md Markdown
|
||||
.png PNG Image
|
||||
.latex LaTeX
|
||||
|
||||
Note: not all formats are supported by all themes!
|
||||
Check the theme's documentation for details or use
|
||||
the .all extension to build all available formats.
|
||||
|
||||
Options:
|
||||
|
||||
**--theme -t <theme-name-or-path>**
|
||||
|
||||
Path to a FRESH or JSON Resume theme OR the name of a
|
||||
built-in theme. Valid theme names are 'modern',
|
||||
'positive', 'compact', 'awesome', and 'basis'.
|
||||
|
||||
**--pdf -p <engine>**
|
||||
|
||||
Specify the PDF engine to use. Legal values are
|
||||
'none', 'wkhtmltopdf', 'phantom', or 'weasyprint'.
|
||||
|
||||
**--no-escape**
|
||||
|
||||
Disable escaping / encoding of resume data during
|
||||
resume generation. Handlebars themes only.
|
||||
|
||||
**--private**
|
||||
|
||||
Include resume fields marked as private.
|
||||
|
||||
Notes:
|
||||
|
||||
The BUILD command can be run against multiple source as well
|
||||
as multiple target resumes. If multiple source resumes are
|
||||
provided, they will be merged into a single source resume
|
||||
before generation. If multiple output resumes are provided,
|
||||
each will be generated in turn.
|
33
src/cli/help/convert.txt
Normal file
33
src/cli/help/convert.txt
Normal file
@ -0,0 +1,33 @@
|
||||
**convert** | Convert resumes between FRESH and JRS formats
|
||||
|
||||
Usage:
|
||||
|
||||
**hackmyresume CONVERT <resume> TO <target> [--format]**
|
||||
|
||||
The CONVERT command converts one or more resume documents
|
||||
between the FRESH Resume Schema and JSON Resume formats.
|
||||
|
||||
Parameters:
|
||||
|
||||
**<resume>**
|
||||
|
||||
Path to a FRESH or JRS resume. Multiple resumes can be
|
||||
specified.
|
||||
|
||||
**<targets>**
|
||||
|
||||
The path of the converted resume. Multiple resumes can
|
||||
be specified, one per provided input resume.
|
||||
|
||||
Options:
|
||||
|
||||
**--format -f <fmt>**
|
||||
|
||||
The desired format for the new resume(s). Valid values
|
||||
are 'FRESH', 'JRS', or, to target the latest edge
|
||||
version of the JSON Resume Schema, 'JRS@1'.
|
||||
|
||||
If this parameter is omitted, the destination format
|
||||
will be inferred from the source resume's format. If
|
||||
the source format is FRESH, the destination format
|
||||
will be JSON Resume, and vice-versa.
|
23
src/cli/help/help.txt
Normal file
23
src/cli/help/help.txt
Normal file
@ -0,0 +1,23 @@
|
||||
**help** | View help on a specific HackMyResume command
|
||||
|
||||
Usage:
|
||||
|
||||
**hackmyresume HELP [<command>]**
|
||||
|
||||
The HELP command displays help information for a specific
|
||||
HackMyResume command, including the HELP command itself.
|
||||
|
||||
Parameters:
|
||||
|
||||
**<command>**
|
||||
|
||||
The HackMyResume command to view help information for.
|
||||
Must be BUILD, NEW, CONVERT, ANALYZE, VALIDATE, PEEK,
|
||||
or HELP.
|
||||
|
||||
hackmyresume help convert
|
||||
hackmyresume help help
|
||||
|
||||
Options:
|
||||
|
||||
**None.**
|
29
src/cli/help/new.txt
Normal file
29
src/cli/help/new.txt
Normal file
@ -0,0 +1,29 @@
|
||||
**new** | Create a new FRESH or JRS resume document
|
||||
|
||||
Usage:
|
||||
|
||||
**hackmyresume NEW <fileName> [--format]**
|
||||
|
||||
The NEW command generates a new resume document in FRESH
|
||||
or JSON Resume format. This document can serve as an
|
||||
official source of truth for your resume and career data
|
||||
as well an input to tools like HackMyResume.
|
||||
|
||||
Parameters:
|
||||
|
||||
**<fileName>**
|
||||
|
||||
The filename (relative or absolute path) of the resume
|
||||
to be created. Multiple resume paths can be specified,
|
||||
and each will be created in turn.
|
||||
|
||||
hackmyresume NEW resume.json
|
||||
hackmyresume NEW r1.json foo/r2.json ../r3.json
|
||||
|
||||
Options:
|
||||
|
||||
**--format -f <fmt>**
|
||||
|
||||
The desired format for the new resume(s). Valid values
|
||||
are 'FRESH', 'JRS', or, to target the latest edge
|
||||
version of the JSON Resume Schema, 'JRS@1'.
|
31
src/cli/help/peek.txt
Normal file
31
src/cli/help/peek.txt
Normal file
@ -0,0 +1,31 @@
|
||||
**peek** | View portions of a resume from the command line
|
||||
|
||||
Usage:
|
||||
|
||||
**hackmyresume PEEK <resume> <at>**
|
||||
|
||||
The PEEK command displays a specific piece or part of the
|
||||
resume without requiring the resume to be opened in an
|
||||
editor.
|
||||
|
||||
Parameters:
|
||||
|
||||
**<resume>**
|
||||
|
||||
Path to a FRESH or JRS resume. Multiple resumes can be
|
||||
specified, separated by spaces.
|
||||
|
||||
hackmyresume PEEK r1.json r2.json r3.json "employment.history[2]"
|
||||
|
||||
**<at>**
|
||||
|
||||
The resume property or field to be displayed. Can be
|
||||
any valid resume path, for example:
|
||||
|
||||
education[0]
|
||||
info.name
|
||||
employment.history[3].start
|
||||
|
||||
Options:
|
||||
|
||||
**None.**
|
70
src/cli/help/use.txt
Normal file
70
src/cli/help/use.txt
Normal file
@ -0,0 +1,70 @@
|
||||
**HackMyResume** | A Swiss Army knife for resumes and CVs
|
||||
|
||||
Usage:
|
||||
|
||||
**hackmyresume [--version] [--help] [--silent] [--debug]**
|
||||
**[--options] [--no-colors] <command> [<args>]**
|
||||
|
||||
Commands: (type "hackmyresume help COMMAND" for details)
|
||||
|
||||
**BUILD** Build your resume to the destination format(s).
|
||||
**ANALYZE** Analyze your resume for keywords, gaps, and metrics.
|
||||
**VALIDATE** Validate your resume for errors and typos.
|
||||
**NEW** Create a new resume in FRESH or JSON Resume format.
|
||||
**CONVERT** Convert your resume between FRESH and JSON Resume.
|
||||
**PEEK** View a specific field or element on your resume.
|
||||
**HELP** View help on a specific HackMyResume command.
|
||||
|
||||
Common Tasks:
|
||||
|
||||
Generate a resume in a specific format (HTML, Word, PDF, etc.)
|
||||
|
||||
**hackmyresume build rez.json to out/rez.html**
|
||||
**hackmyresume build rez.json to out/rez.doc**
|
||||
**hackmyresume build rez.json to out/rez.pdf**
|
||||
**hackmyresume build rez.json to out/rez.txt**
|
||||
**hackmyresume build rez.json to out/rez.md**
|
||||
**hackmyresume build rez.json to out/rez.png**
|
||||
**hackmyresume build rez.json to out/rez.tex**
|
||||
|
||||
Build a resume to ALL available formats:
|
||||
|
||||
**hackmyresume build rez.json to out/rez.all**
|
||||
|
||||
Build a resume with a specific theme:
|
||||
|
||||
**hackmyresume build rez.json to out/rez.all -t themeName**
|
||||
|
||||
Create a new empty resume:
|
||||
|
||||
**hackmyresume new rez.json**
|
||||
|
||||
Convert a resume between FRESH and JRS formats:
|
||||
|
||||
**hackmyresume convert rez.json converted.json**
|
||||
|
||||
Analyze a resume for important metrics
|
||||
|
||||
**hackmyresume analyze rez.json**
|
||||
|
||||
Find more resume themes:
|
||||
|
||||
**https://www.npmjs.com/search?q=jsonresume-theme**
|
||||
**https://www.npmjs.com/search?q=fresh-theme**
|
||||
**https://github.com/fresh-standard/fresh-themes**
|
||||
|
||||
Validate a resume's structure and syntax:
|
||||
|
||||
**hackmyresume validate resume.json**
|
||||
|
||||
View help on a specific command:
|
||||
|
||||
**hackmyresume help [build|convert|new|analyze|validate|peek|help]**
|
||||
|
||||
Submit a bug or request:
|
||||
|
||||
**https://githut.com/hacksalot/HackMyResume/issues**
|
||||
|
||||
HackMyResume is free and open source software published
|
||||
under the MIT license. For more information, visit the
|
||||
HackMyResume website or GitHub project page.
|
26
src/cli/help/validate.txt
Normal file
26
src/cli/help/validate.txt
Normal file
@ -0,0 +1,26 @@
|
||||
**validate** | Validate a resume for correctness
|
||||
|
||||
Usage:
|
||||
|
||||
**hackmyresume VALIDATE <resume> [--assert]**
|
||||
|
||||
The VALIDATE command validates a FRESH or JRS document
|
||||
against its governing schema, verifying that the resume
|
||||
is correctly structured and formatted.
|
||||
|
||||
Parameters:
|
||||
|
||||
**<resume>**
|
||||
|
||||
Path to a FRESH or JRS resume. Multiple resumes can be
|
||||
specified.
|
||||
|
||||
hackmyresume ANALYZE resume.json
|
||||
hackmyresume ANALYZE r1.json r2.json r3.json
|
||||
|
||||
Options:
|
||||
|
||||
**--assert -a**
|
||||
|
||||
Tell HackMyResume to return a non-zero process exit
|
||||
code if a resume fails to validate.
|
22
src/cli/index.js
Normal file
22
src/cli/index.js
Normal file
@ -0,0 +1,22 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Command-line interface (CLI) for HackMyResume.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module index.js
|
||||
*/
|
||||
|
||||
|
||||
|
||||
try {
|
||||
|
||||
require('./main')( process.argv );
|
||||
|
||||
}
|
||||
catch( ex ) {
|
||||
|
||||
require('./error').err( ex, true );
|
||||
|
||||
}
|
662
src/cli/main.js
662
src/cli/main.js
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the `main` function.
|
||||
@module cli/main
|
||||
@ -6,326 +11,411 @@ Definition of the `main` function.
|
||||
|
||||
|
||||
|
||||
(function(){
|
||||
const HMR = require('../index');
|
||||
const PKG = require('../../package.json');
|
||||
const FS = require('fs');
|
||||
const EXTEND = require('extend');
|
||||
const chalk = require('chalk');
|
||||
const PATH = require('path');
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const safeLoadJSON = require('../utils/safe-json-loader');
|
||||
//StringUtils = require '../utils/string.js'
|
||||
const _ = require('underscore');
|
||||
const OUTPUT = require('./out');
|
||||
const PAD = require('string-padding');
|
||||
const { Command } = require('commander');
|
||||
const M2C = require('../utils/md2chalk');
|
||||
const printf = require('printf');
|
||||
const _opts = { };
|
||||
const _title = chalk.white.bold(`\n*** HackMyResume v${PKG.version} ***`);
|
||||
const _out = new OUTPUT( _opts );
|
||||
const _err = require('./error');
|
||||
let _exitCallback = null;
|
||||
|
||||
|
||||
|
||||
var HMR = require( '../hackmyapi')
|
||||
, PKG = require('../../package.json')
|
||||
, FS = require('fs')
|
||||
, EXTEND = require('extend')
|
||||
, chalk = require('chalk')
|
||||
, PATH = require('path')
|
||||
, HMSTATUS = require('../core/status-codes')
|
||||
, HME = require('../core/event-codes')
|
||||
, safeLoadJSON = require('../utils/safe-json-loader')
|
||||
, StringUtils = require('../utils/string.js')
|
||||
, _ = require('underscore')
|
||||
, OUTPUT = require('./out')
|
||||
, PAD = require('string-padding')
|
||||
, Command = require('commander').Command;
|
||||
/*
|
||||
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).
|
||||
*/
|
||||
module.exports = function( rawArgs, exitCallback ) {
|
||||
|
||||
var _opts = { };
|
||||
var _title = chalk.white.bold('\n*** HackMyResume v' +PKG.version+ ' ***');
|
||||
var _out = new OUTPUT( _opts );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
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).
|
||||
*/
|
||||
var main = module.exports = function( rawArgs ) {
|
||||
|
||||
var initInfo = initialize( rawArgs );
|
||||
var args = initInfo.args;
|
||||
|
||||
// Create the top-level (application) command...
|
||||
var 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;
|
||||
|
||||
// Create the NEW command
|
||||
program
|
||||
.command('new')
|
||||
.arguments('<sources...>')
|
||||
.option('-f --format <fmt>', 'FRESH or JRS format', 'FRESH')
|
||||
.alias('create')
|
||||
.description('Create resume(s) in FRESH or JSON RESUME format.')
|
||||
.action(function( sources ) {
|
||||
execute.call( this, sources, [], this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the VALIDATE command
|
||||
program
|
||||
.command('validate')
|
||||
.arguments('<sources...>')
|
||||
.description('Validate a resume in FRESH or JSON RESUME format.')
|
||||
.action(function(sources) {
|
||||
execute.call( this, sources, [], this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the CONVERT command
|
||||
program
|
||||
.command('convert')
|
||||
.description('Convert a resume to/from FRESH or JSON RESUME format.')
|
||||
.action(function() {
|
||||
var x = splitSrcDest.call( this );
|
||||
execute.call( this, x.src, x.dst, this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the ANALYZE command
|
||||
program
|
||||
.command('analyze')
|
||||
.arguments('<sources...>')
|
||||
.description('Analyze one or more resumes.')
|
||||
.action(function( sources ) {
|
||||
execute.call( this, sources, [], this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the PEEK command
|
||||
program
|
||||
.command('peek')
|
||||
.arguments('<sources...>')
|
||||
.description('Peek at a resume field or section')
|
||||
.action(function( sources, sectionOrField ) {
|
||||
var dst = (sources && sources.length > 1) ? [sources.pop()] : [];
|
||||
execute.call( this, sources, dst, this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the BUILD command
|
||||
program
|
||||
.command('build')
|
||||
.alias('generate')
|
||||
.option('-t --theme <theme>', 'Theme name or path')
|
||||
.option('-n --no-prettify', 'Disable HTML prettification', true)
|
||||
.option('-c --css <option>', 'CSS linking / embedding')
|
||||
.option('-p --pdf <engine>', 'PDF generation engine')
|
||||
.option('--no-sort', 'Sort resume sections by date', false)
|
||||
.option('--tips', 'Display theme tips and warnings.', false)
|
||||
.description('Generate resume to multiple formats')
|
||||
.action(function( sources, targets, options ) {
|
||||
var x = splitSrcDest.call( this );
|
||||
execute.call( this, x.src, x.dst, this.opts(), logMsg);
|
||||
});
|
||||
|
||||
program.parse( args );
|
||||
|
||||
if (!program.args.length) { throw { fluenterror: 4 }; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Massage command-line args and setup Commander.js. */
|
||||
function initialize( ar ) {
|
||||
|
||||
var o = initOptions( ar );
|
||||
|
||||
o.silent || logMsg( _title );
|
||||
|
||||
// Emit debug prelude if --debug was specified
|
||||
if( o.debug ) {
|
||||
_out.log(chalk.cyan('The -d or --debug switch was specified. DEBUG mode engaged.'));
|
||||
_out.log('');
|
||||
_out.log(chalk.cyan(PAD(' Platform:',25, null, PAD.RIGHT)) + chalk.cyan.bold( process.platform === 'win32' ? 'windows' : process.platform ));
|
||||
_out.log(chalk.cyan(PAD(' Node.js:',25, null, PAD.RIGHT)) + chalk.cyan.bold( process.version ));
|
||||
_out.log(chalk.cyan(PAD(' HackMyResume:',25, null, PAD.RIGHT)) + chalk.cyan.bold('v' + PKG.version ));
|
||||
_out.log(chalk.cyan(PAD(' FRESCA:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies.fresca ));
|
||||
_out.log(chalk.cyan(PAD(' fresh-themes:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-themes'] ));
|
||||
_out.log(chalk.cyan(PAD(' fresh-jrs-converter:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-jrs-converter'] ));
|
||||
_out.log('');
|
||||
}
|
||||
|
||||
// Handle invalid verbs here (a bit easier here than in commander.js)...
|
||||
if( o.verb && !HMR.verbs[ o.verb ] && !HMR.alias[ o.verb ] ) {
|
||||
throw { fluenterror: HMSTATUS.invalidCommand, quit: true,
|
||||
attempted: o.orgVerb };
|
||||
}
|
||||
|
||||
// Override the .missingArgument behavior
|
||||
Command.prototype.missingArgument = function(name) {
|
||||
if( this.name() !== 'new' ) {
|
||||
throw { fluenterror: HMSTATUS.resumeNotFound, quit: true };
|
||||
}
|
||||
};
|
||||
|
||||
// Override the .helpInformation behavior
|
||||
Command.prototype.helpInformation = function() {
|
||||
var manPage = FS.readFileSync(
|
||||
PATH.join(__dirname, 'use.txt'), 'utf8' );
|
||||
return chalk.green.bold(manPage);
|
||||
};
|
||||
|
||||
return {
|
||||
args: o.args,
|
||||
options: o.json
|
||||
};
|
||||
const initInfo = initialize( rawArgs, exitCallback );
|
||||
if (initInfo === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { args } = initInfo;
|
||||
|
||||
// Create the top-level (application) command...
|
||||
const 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;
|
||||
|
||||
// Create the NEW command
|
||||
program
|
||||
.command('new')
|
||||
.arguments('<sources...>')
|
||||
.option('-f --format <fmt>', 'FRESH or JRS format', 'FRESH')
|
||||
.alias('create')
|
||||
.description('Create resume(s) in FRESH or JSON RESUME format.')
|
||||
.action((function( sources ) {
|
||||
execute.call( this, sources, [], this.opts(), logMsg);
|
||||
})
|
||||
);
|
||||
|
||||
// Create the VALIDATE command
|
||||
program
|
||||
.command('validate')
|
||||
.arguments('<sources...>')
|
||||
.description('Validate a resume in FRESH or JSON RESUME format.')
|
||||
.action(function(sources) {
|
||||
execute.call( this, sources, [], this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the CONVERT command
|
||||
program
|
||||
.command('convert')
|
||||
.description('Convert a resume to/from FRESH or JSON RESUME format.')
|
||||
.option('-f --format <fmt>', 'FRESH or JRS format and optional version', undefined)
|
||||
.action(function() {
|
||||
const x = splitSrcDest.call( this );
|
||||
execute.call( this, x.src, x.dst, this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the ANALYZE command
|
||||
program
|
||||
.command('analyze')
|
||||
.arguments('<sources...>')
|
||||
.option('--private', 'Include resume fields marked as private', false)
|
||||
.description('Analyze one or more resumes.')
|
||||
.action(function( sources ) {
|
||||
execute.call( this, sources, [], this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the PEEK command
|
||||
program
|
||||
.command('peek')
|
||||
.arguments('<sources...>')
|
||||
.description('Peek at a resume field or section')
|
||||
//.action(( sources, sectionOrField ) ->
|
||||
.action(function( sources ) {
|
||||
const dst = (sources && (sources.length > 1)) ? [sources.pop()] : [];
|
||||
execute.call( this, sources, dst, this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the BUILD command
|
||||
program
|
||||
.command('build')
|
||||
.alias('generate')
|
||||
.option('-t --theme <theme>', 'Theme name or path')
|
||||
.option('-n --no-prettify', 'Disable HTML prettification', true)
|
||||
.option('-c --css <option>', 'CSS linking / embedding')
|
||||
.option('-p --pdf <engine>', 'PDF generation engine')
|
||||
.option('--no-sort', 'Sort resume sections by date', false)
|
||||
.option('--tips', 'Display theme tips and warnings.', false)
|
||||
.option('--private', 'Include resume fields marked as private', false)
|
||||
.option('--no-escape', 'Turn off encoding in Handlebars themes.', false)
|
||||
.description('Generate resume to multiple formats')
|
||||
//.action(( sources, targets, options ) ->
|
||||
.action(function() {
|
||||
const x = splitSrcDest.call( this );
|
||||
execute.call( this, x.src, x.dst, this.opts(), logMsg);
|
||||
});
|
||||
|
||||
// Create the HELP command
|
||||
program
|
||||
.command('help')
|
||||
.arguments('[command]')
|
||||
.description('Get help on a HackMyResume command')
|
||||
.action(function( cmd ) {
|
||||
cmd = cmd || 'use';
|
||||
const manPage = FS.readFileSync(
|
||||
PATH.join(__dirname, `help/${cmd}.txt`),
|
||||
'utf8');
|
||||
_out.log(M2C(manPage, 'white', 'yellow.bold'));
|
||||
});
|
||||
|
||||
program.parse( args );
|
||||
|
||||
if (!program.args.length) {
|
||||
throw {fluenterror: 4};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** Init options prior to setting up command infrastructure. */
|
||||
function initOptions( ar ) {
|
||||
var oVerb, verb = '', args = ar.slice(), cleanArgs = args.slice(2), oJSON;
|
||||
if( cleanArgs.length ) {
|
||||
|
||||
// Support case-insensitive sub-commands (build, generate, validate, etc)
|
||||
var vidx = _.findIndex( cleanArgs, function(v){ return v[0] !== '-'; });
|
||||
if( vidx !== -1 ) {
|
||||
oVerb = cleanArgs[ vidx ];
|
||||
verb = args[ vidx + 2 ] = oVerb.trim().toLowerCase();
|
||||
}
|
||||
/* Massage command-line args and setup Commander.js. */
|
||||
var initialize = function( ar, exitCallback ) {
|
||||
|
||||
// Remove --options --opts -o and process separately
|
||||
var optsIdx = _.findIndex( cleanArgs, function(v){
|
||||
return v === '-o' || v === '--options' || v === '--opts';
|
||||
_exitCallback = exitCallback || process.exit;
|
||||
const o = initOptions(ar);
|
||||
if (o.ex) {
|
||||
_err.init(false, true, false);
|
||||
if( o.ex.op === 'parse' ) {
|
||||
_err.err({
|
||||
fluenterror: o.ex.op === 'parse' ? HMSTATUS.invalidOptionsFile : HMSTATUS.optionsFileNotFound,
|
||||
inner: o.ex.inner,
|
||||
quit: true
|
||||
});
|
||||
if(optsIdx !== -1) {
|
||||
var optStr = cleanArgs[ optsIdx + 1];
|
||||
args.splice( optsIdx + 2, 2 );
|
||||
if( optStr && (optStr = optStr.trim()) ) {
|
||||
//var myJSON = JSON.parse(optStr);
|
||||
if( optStr[0] === '{')
|
||||
oJSON = eval('(' + optStr + ')'); // jshint ignore:line
|
||||
else {
|
||||
var inf = safeLoadJSON( optStr );
|
||||
if( !inf.ex )
|
||||
oJSON = inf.json;
|
||||
// TODO: Error handling
|
||||
} else {
|
||||
_err.err({fluenterror: HMSTATUS.optionsFileNotFound, inner: o.ex.inner, quit: true});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
o.silent || logMsg( _title );
|
||||
|
||||
// Emit debug prelude if --debug was specified
|
||||
if (o.debug) {
|
||||
_out.log(chalk.cyan('The -d or --debug switch was specified. DEBUG mode engaged.'));
|
||||
_out.log('');
|
||||
_out.log(chalk.cyan(PAD(' Platform:',25, null, PAD.RIGHT)) + chalk.cyan.bold( process.platform === 'win32' ? 'windows' : process.platform ));
|
||||
_out.log(chalk.cyan(PAD(' Node.js:',25, null, PAD.RIGHT)) + chalk.cyan.bold( process.version ));
|
||||
_out.log(chalk.cyan(PAD(' HackMyResume:',25, null, PAD.RIGHT)) + chalk.cyan.bold(`v${PKG.version}` ));
|
||||
_out.log(chalk.cyan(PAD(' FRESCA:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies.fresca ));
|
||||
//_out.log(chalk.cyan(PAD(' fresh-themes:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-themes'] ))
|
||||
//_out.log(chalk.cyan(PAD(' fresh-jrs-converter:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-jrs-converter'] ))
|
||||
_out.log('');
|
||||
}
|
||||
|
||||
_err.init(o.debug, o.assert, o.silent);
|
||||
|
||||
// Handle invalid verbs here (a bit easier here than in commander.js)...
|
||||
if (o.verb && !HMR.verbs[ o.verb ] && !HMR.alias[ o.verb ] && (o.verb !== 'help')) {
|
||||
_err.err({fluenterror: HMSTATUS.invalidCommand, quit: true, attempted: o.orgVerb}, true);
|
||||
}
|
||||
|
||||
// Override the .missingArgument behavior
|
||||
Command.prototype.missingArgument = function() {
|
||||
if (this.name() !== 'help') {
|
||||
_err.err({
|
||||
verb: this.name(),
|
||||
fluenterror: HMSTATUS.resumeNotFound
|
||||
}
|
||||
, true);
|
||||
}
|
||||
};
|
||||
|
||||
// Override the .helpInformation behavior
|
||||
Command.prototype.helpInformation = function() {
|
||||
const manPage = FS.readFileSync(
|
||||
PATH.join(__dirname, 'help/use.txt'), 'utf8' );
|
||||
return M2C(manPage, 'white', 'yellow');
|
||||
};
|
||||
|
||||
return {
|
||||
args: o.args,
|
||||
options: o.json
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Init options prior to setting up command infrastructure. */
|
||||
var initOptions = function( ar ) {
|
||||
|
||||
let oJSON, oVerb;
|
||||
oVerb;
|
||||
let verb = '';
|
||||
const args = ar.slice();
|
||||
const cleanArgs = args.slice( 2 );
|
||||
oJSON;
|
||||
|
||||
if (cleanArgs.length) {
|
||||
|
||||
// Support case-insensitive sub-commands (build, generate, validate, etc)
|
||||
const vidx = _.findIndex(cleanArgs, v => v[0] !== '-');
|
||||
if (vidx !== -1) {
|
||||
oVerb = cleanArgs[ vidx ];
|
||||
verb = (args[ vidx + 2 ] = oVerb.trim().toLowerCase());
|
||||
}
|
||||
|
||||
// Remove --options --opts -o and process separately
|
||||
const optsIdx = _.findIndex(cleanArgs, v => (v === '-o') || (v === '--options') || (v === '--opts'));
|
||||
|
||||
if (optsIdx !== -1) {
|
||||
let optStr = cleanArgs[ optsIdx + 1];
|
||||
args.splice( optsIdx + 2, 2 );
|
||||
if (optStr && (optStr = optStr.trim())) {
|
||||
//var myJSON = JSON.parse(optStr);
|
||||
if( optStr[0] === '{') {
|
||||
// TODO: remove use of evil(). - hacksalot
|
||||
/* jshint ignore:start */
|
||||
oJSON = eval(`(${optStr})`); // jshint ignore:line <-- no worky
|
||||
/* jshint ignore:end */
|
||||
} else {
|
||||
const inf = safeLoadJSON( optStr );
|
||||
if( !inf.ex ) {
|
||||
oJSON = inf.json;
|
||||
} else {
|
||||
return inf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Grab the --debug flag
|
||||
var isDebug = _.some( args, function(v) {
|
||||
return v === '-d' || v === '--debug';
|
||||
});
|
||||
|
||||
// Grab the --silent flag
|
||||
var isSilent = _.some( args, function(v) {
|
||||
return v === '-s' || v === '--silent';
|
||||
});
|
||||
|
||||
return {
|
||||
debug: isDebug,
|
||||
silent: isSilent,
|
||||
orgVerb: oVerb,
|
||||
verb: verb,
|
||||
json: oJSON,
|
||||
args: args
|
||||
};
|
||||
}
|
||||
|
||||
// Grab the --debug flag, --silent, --assert and --no-color flags
|
||||
const isDebug = _.some(args, v => (v === '-d') || (v === '--debug'));
|
||||
const isSilent = _.some(args, v => (v === '-s') || (v === '--silent'));
|
||||
const isAssert = _.some(args, v => (v === '-a') || (v === '--assert'));
|
||||
const isMono = _.some(args, v => v === '--no-color');
|
||||
const isNoEscape = _.some(args, v => v === '--no-escape');
|
||||
|
||||
|
||||
/** Invoke a HackMyResume verb. */
|
||||
function execute( src, dst, opts, log ) {
|
||||
|
||||
loadOptions.call( this, opts, this.parent.jsonArgs );
|
||||
var hand = require( './error' );
|
||||
hand.init( _opts.debug, _opts.assert, _opts.silent );
|
||||
var v = new HMR.verbs[ this.name() ]();
|
||||
_opts.errHandler = v;
|
||||
_out.init( _opts );
|
||||
v.on( 'hmr:status', function() { _out.do.apply( _out, arguments ); });
|
||||
v.on( 'hmr:error', function() {
|
||||
hand.err.apply( hand, arguments );
|
||||
});
|
||||
v.invoke.call( v, src, dst, _opts, log );
|
||||
if( v.errorCode )
|
||||
process.exit(v.errorCode);
|
||||
}
|
||||
return {
|
||||
color: !isMono,
|
||||
debug: isDebug,
|
||||
silent: isSilent,
|
||||
assert: isAssert,
|
||||
noescape: isNoEscape,
|
||||
orgVerb: oVerb,
|
||||
verb,
|
||||
json: oJSON,
|
||||
args
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
function loadOptions( o, cmdO ) {
|
||||
/* Invoke a HackMyResume verb. */
|
||||
var execute = function( src, dst, opts, log ) {
|
||||
|
||||
// o and this.opts() seem to be the same (command-specific options)
|
||||
// Create the verb
|
||||
const v = new (HMR.verbs[ this.name() ])();
|
||||
|
||||
// Load the specified options file (if any) and apply options
|
||||
if( cmdO )
|
||||
o = EXTEND(true, o, cmdO);
|
||||
// Initialize command-specific options
|
||||
loadOptions.call(this, opts, this.parent.jsonArgs);
|
||||
|
||||
// Merge in command-line options
|
||||
o = EXTEND( true, o, this.opts() );
|
||||
// Set up error/output handling
|
||||
_opts.errHandler = v;
|
||||
_out.init(_opts);
|
||||
|
||||
// Kludge parent-level options until piping issue is resolved
|
||||
if( this.parent.silent !== undefined && this.parent.silent !== null)
|
||||
o.silent = this.parent.silent;
|
||||
if( this.parent.debug !== undefined && this.parent.debug !== null)
|
||||
o.debug = this.parent.debug;
|
||||
if( this.parent.assert !== undefined && this.parent.assert !== null)
|
||||
o.assert = this.parent.assert;
|
||||
// Hook up event notifications
|
||||
v.on('hmr:status', function() { return _out.do.apply(_out, arguments); });
|
||||
v.on('hmr:error', function() { return _err.err.apply(_err, arguments); });
|
||||
|
||||
if( o.debug ) {
|
||||
logMsg(chalk.cyan('OPTIONS:') + '\n');
|
||||
_.each(o, function(val, key) {
|
||||
logMsg(chalk.cyan(' %s') + chalk.cyan.bold(' %s'),
|
||||
PAD(key,22,null,PAD.RIGHT), val);
|
||||
});
|
||||
logMsg('');
|
||||
// Invoke the verb using promise syntax
|
||||
const prom = v.invoke.call(v, src, dst, _opts, log);
|
||||
prom.then(executeSuccess, executeFail);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Success handler for verb invocations. Calls process.exit by default */
|
||||
var executeSuccess = function() {};
|
||||
// Can't call _exitCallback here (process.exit) when PDF is running in BK
|
||||
//_exitCallback 0; return
|
||||
|
||||
|
||||
|
||||
/* Failure handler for verb invocations. Calls process.exit by default */
|
||||
var executeFail = function(err) {
|
||||
//console.dir err
|
||||
let finalErrorCode = -1;
|
||||
if (err) {
|
||||
if (err.fluenterror) {
|
||||
finalErrorCode = err.fluenterror;
|
||||
} else if (err.length) {
|
||||
finalErrorCode = err[0].fluenterror;
|
||||
} else {
|
||||
finalErrorCode = err;
|
||||
}
|
||||
}
|
||||
if (_opts.debug) {
|
||||
const msgs = require('./msg').errors;
|
||||
logMsg(printf(M2C( msgs.exiting.msg, 'cyan' ), finalErrorCode));
|
||||
if (err.stack) { logMsg(err.stack); }
|
||||
}
|
||||
_exitCallback(finalErrorCode);
|
||||
};
|
||||
|
||||
// Cache
|
||||
EXTEND(true, _opts, o);
|
||||
|
||||
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
var loadOptions = function( o, cmdO ) {
|
||||
|
||||
// o and this.opts() seem to be the same (command-specific options)
|
||||
|
||||
// Load the specified options file (if any) and apply options
|
||||
if( cmdO ) {
|
||||
o = EXTEND(true, o, cmdO);
|
||||
}
|
||||
|
||||
// Merge in command-line options
|
||||
o = EXTEND( true, o, this.opts() );
|
||||
|
||||
|
||||
/** Split multiple command-line filenames by the 'TO' keyword */
|
||||
function splitSrcDest() {
|
||||
|
||||
var params = this.parent.args.filter(function(j) { return String.is(j); });
|
||||
if( params.length === 0 )
|
||||
throw { fluenterror: HMSTATUS.resumeNotFound, quit: true };
|
||||
|
||||
// Find the TO keyword, if any
|
||||
var splitAt = _.findIndex( params, function(p) {
|
||||
return p.toLowerCase() === 'to';
|
||||
});
|
||||
|
||||
// TO can't be the last keyword
|
||||
if( splitAt === params.length - 1 && splitAt !== -1 ) {
|
||||
logMsg(chalk.yellow('Please ') +
|
||||
chalk.yellow.bold('specify an output file') +
|
||||
chalk.yellow(' for this operation or ') +
|
||||
chalk.yellow.bold('omit the TO keyword') +
|
||||
chalk.yellow('.') );
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
src: params.slice(0, splitAt === -1 ? undefined : splitAt ),
|
||||
dst: splitAt === -1 ? [] : params.slice( splitAt + 1 )
|
||||
};
|
||||
// Kludge parent-level options until piping issue is resolved
|
||||
if ((this.parent.silent !== undefined) && (this.parent.silent !== null)) {
|
||||
o.silent = this.parent.silent;
|
||||
}
|
||||
if ((this.parent.debug !== undefined) && (this.parent.debug !== null)) {
|
||||
o.debug = this.parent.debug;
|
||||
}
|
||||
if ((this.parent.assert !== undefined) && (this.parent.assert !== null)) {
|
||||
o.assert = this.parent.assert;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Simple logging placeholder. */
|
||||
function logMsg() {
|
||||
_opts.silent || console.log.apply( console.log, arguments );
|
||||
if (o.debug) {
|
||||
logMsg(chalk.cyan('OPTIONS:') + '\n');
|
||||
_.each(o, (val, key) =>
|
||||
logMsg(chalk.cyan(' %s') + chalk.cyan.bold(' %s'),
|
||||
PAD(key,22,null,PAD.RIGHT), val)
|
||||
);
|
||||
logMsg('');
|
||||
}
|
||||
|
||||
// Cache
|
||||
EXTEND( true, _opts, o );
|
||||
};
|
||||
|
||||
/* Split multiple command-line filenames by the 'TO' keyword */
|
||||
var splitSrcDest = function() {
|
||||
|
||||
const params = this.parent.args.filter(j => String.is(j));
|
||||
if (params.length === 0) {
|
||||
//tmpName = @name()
|
||||
throw { fluenterror: HMSTATUS.resumeNotFound, verb: this.name(), quit: true };
|
||||
}
|
||||
|
||||
// Find the TO keyword, if any
|
||||
const splitAt = _.findIndex( params, p => p.toLowerCase() === 'to');
|
||||
|
||||
// TO can't be the last keyword
|
||||
if ((splitAt === (params.length - 1)) && (splitAt !== -1)) {
|
||||
logMsg(chalk.yellow('Please ') +
|
||||
chalk.yellow.bold('specify an output file') +
|
||||
chalk.yellow(' for this operation or ') +
|
||||
chalk.yellow.bold('omit the TO keyword') +
|
||||
chalk.yellow('.') );
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
src: params.slice(0, splitAt === -1 ? undefined : splitAt ),
|
||||
dst: splitAt === -1 ? [] : params.slice( splitAt + 1 )
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
}());
|
||||
|
||||
/* Simple logging placeholder. */
|
||||
var logMsg = function() {
|
||||
// eslint-disable-next-line no-console
|
||||
return _opts.silent || console.log.apply( console.log, arguments );
|
||||
};
|
||||
|
@ -1,18 +1,10 @@
|
||||
/**
|
||||
Message-handling routines for HackMyResume.
|
||||
@module msg.js
|
||||
@module cli/msg
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
var PATH = require('path');
|
||||
var YAML = require('yamljs');
|
||||
|
||||
var cache = module.exports = function() {
|
||||
return cache ? cache : YAML.load( PATH.join(__dirname, 'msg.yml') );
|
||||
}();
|
||||
|
||||
}());
|
||||
const PATH = require('path');
|
||||
const YAML = require('yamljs');
|
||||
module.exports = YAML.load(PATH.join(__dirname, 'msg.yml'));
|
||||
|
@ -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:
|
||||
@ -41,6 +43,8 @@ events:
|
||||
- "VALID!"
|
||||
- "INVALID"
|
||||
- "BROKEN"
|
||||
- "MISSING"
|
||||
- "ERROR"
|
||||
beforePeek:
|
||||
msg:
|
||||
- Peeking at **%s** in **%s**
|
||||
@ -79,7 +83,10 @@ errors:
|
||||
readError:
|
||||
msg: Reading **???** resume: **%s**
|
||||
parseError:
|
||||
msg: Invalid or corrupt JSON on line %s column %s.
|
||||
msg:
|
||||
- Invalid or corrupt JSON on line %s column %s.
|
||||
- Invalid or corrupt JSON on line %s.
|
||||
- Invalid or corrupt JSON.
|
||||
invalidHelperUse:
|
||||
msg: "**Warning**: Incorrect use of the **%s** theme helper."
|
||||
fileSaveError:
|
||||
@ -96,3 +103,39 @@ errors:
|
||||
msg: "Invalid number of parameters. Expected: **%s**."
|
||||
missingParam:
|
||||
msg: The '**%s**' parameter was needed but not supplied.
|
||||
createError:
|
||||
msg: Failed to create **'%s'**.
|
||||
exiting:
|
||||
msg: Exiting with status code **%s**.
|
||||
validateError:
|
||||
msg: "An error occurred during validation:\n%s"
|
||||
invalidOptionsFile:
|
||||
msg:
|
||||
- "The specified options file is invalid:\n"
|
||||
- "\nMake sure the options file contains valid JSON."
|
||||
optionsFileNotFound:
|
||||
msg: "The specified options file is missing or inaccessible."
|
||||
unknownSchema:
|
||||
msg:
|
||||
- "Unknown resume schema. Did you specify a valid FRESH or JRS resume?"
|
||||
- |
|
||||
At a minimum, a FRESH resume must include a "name" field and a "meta"
|
||||
property.
|
||||
|
||||
"name": "John Doe",
|
||||
"meta": {
|
||||
"format": "FRESH@0.1.0"
|
||||
}
|
||||
|
||||
JRS-format resumes must include a "basics" section with a "name":
|
||||
|
||||
"basics": {
|
||||
"name": "John Doe"
|
||||
}
|
||||
themeHelperLoad:
|
||||
msg: >-
|
||||
An error occurred while attempting to load the '%s' theme helper. Is the
|
||||
theme correctly installed?
|
||||
dummy: dontcare
|
||||
invalidSchemaVersion:
|
||||
msg: "'%s' is not recognized as a valid schema version."
|
||||
|
331
src/cli/out.js
331
src/cli/out.js
@ -1,229 +1,204 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Output routines for HackMyResume.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module out.js
|
||||
@module cli/out
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const chalk = require('chalk');
|
||||
const HME = require('../core/event-codes');
|
||||
const _ = require('underscore');
|
||||
const M2C = require('../utils/md2chalk.js');
|
||||
const PATH = require('path');
|
||||
const FS = require('fs');
|
||||
const EXTEND = require('extend');
|
||||
const HANDLEBARS = require('handlebars');
|
||||
const YAML = require('yamljs');
|
||||
let printf = require('printf');
|
||||
const pad = require('string-padding');
|
||||
const dbgStyle = 'cyan';
|
||||
|
||||
|
||||
|
||||
var chalk = require('chalk')
|
||||
, HME = require('../core/event-codes')
|
||||
, _ = require('underscore')
|
||||
, Class = require('../utils/class.js')
|
||||
, M2C = require('../utils/md2chalk.js')
|
||||
, PATH = require('path')
|
||||
, LO = require('lodash')
|
||||
, FS = require('fs')
|
||||
, EXTEND = require('extend')
|
||||
, HANDLEBARS = require('handlebars')
|
||||
, YAML = require('yamljs')
|
||||
, printf = require('printf')
|
||||
, pad = require('string-padding')
|
||||
, dbgStyle = 'cyan';
|
||||
/** A stateful output module. All HMR console output handled here. */
|
||||
class OutputHandler {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
A stateful output module. All HMR console output handled here.
|
||||
*/
|
||||
var OutputHandler = module.exports = Class.extend({
|
||||
constructor( opts ) {
|
||||
this.init(opts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
init: function( opts ) {
|
||||
this.opts = EXTEND( true, this.opts || { }, opts );
|
||||
this.msgs = YAML.load(PATH.join( __dirname, 'msg.yml' )).events;
|
||||
},
|
||||
init(opts) {
|
||||
this.opts = EXTEND( true, this.opts || { }, opts );
|
||||
this.msgs = YAML.load(PATH.join( __dirname, 'msg.yml' )).events;
|
||||
}
|
||||
|
||||
|
||||
|
||||
log: function( msg ) {
|
||||
msg = msg || '';
|
||||
var printf = require('printf');
|
||||
var finished = printf.apply( printf, arguments );
|
||||
this.opts.silent || console.log( finished );
|
||||
},
|
||||
log() {
|
||||
printf = require('printf');
|
||||
const finished = printf.apply( printf, arguments );
|
||||
return this.opts.silent || console.log( finished ); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
|
||||
|
||||
do: function( evt ) {
|
||||
do( evt ) {
|
||||
|
||||
var that = this;
|
||||
function L() {
|
||||
that.log.apply( that, arguments );
|
||||
}
|
||||
const that = this;
|
||||
const L = function() { return that.log.apply( that, arguments ); };
|
||||
|
||||
switch( evt.sub ) {
|
||||
switch (evt.sub) {
|
||||
|
||||
case HME.begin:
|
||||
this.opts.debug &&
|
||||
L( M2C( this.msgs.begin.msg, dbgStyle), evt.cmd.toUpperCase() );
|
||||
break;
|
||||
case HME.begin:
|
||||
return this.opts.debug &&
|
||||
L( M2C( this.msgs.begin.msg, dbgStyle), evt.cmd.toUpperCase() );
|
||||
|
||||
case HME.error:
|
||||
break;
|
||||
//when HME.beforeCreate
|
||||
//L( M2C( this.msgs.beforeCreate.msg, 'green' ), evt.fmt, evt.file )
|
||||
//break;
|
||||
|
||||
case HME.beforeCreate:
|
||||
L( M2C( this.msgs.beforeCreate.msg, 'green' ), evt.fmt, evt.file );
|
||||
break;
|
||||
case HME.afterCreate:
|
||||
L( M2C( this.msgs.beforeCreate.msg, evt.isError ? 'red' : 'green' ), evt.fmt, evt.file );
|
||||
break;
|
||||
|
||||
case HME.beforeRead:
|
||||
break;
|
||||
case HME.beforeTheme:
|
||||
return this.opts.debug &&
|
||||
L( M2C( this.msgs.beforeTheme.msg, dbgStyle), evt.theme.toUpperCase() );
|
||||
|
||||
case HME.afterRead:
|
||||
break;
|
||||
case HME.afterParse:
|
||||
return L( M2C( this.msgs.afterRead.msg, 'gray', 'white.dim'), evt.fmt.toUpperCase(), evt.file );
|
||||
|
||||
case HME.beforeTheme:
|
||||
this.opts.debug &&
|
||||
L( M2C( this.msgs.beforeTheme.msg, dbgStyle), evt.theme.toUpperCase() );
|
||||
break;
|
||||
case HME.beforeMerge:
|
||||
var msg = '';
|
||||
evt.f.reverse().forEach(function( a, idx ) {
|
||||
return msg += printf( (idx === 0 ? this.msgs.beforeMerge.msg[0] : this.msgs.beforeMerge.msg[1]), a.file );
|
||||
}
|
||||
, this);
|
||||
return L( M2C(msg, (evt.mixed ? 'yellow' : 'gray'), 'white.dim') );
|
||||
|
||||
case HME.afterParse:
|
||||
L(
|
||||
M2C( this.msgs.afterRead.msg, 'gray', 'white.dim'), evt.fmt.toUpperCase(), evt.file
|
||||
);
|
||||
case HME.applyTheme:
|
||||
this.theme = evt.theme;
|
||||
var numFormats = Object.keys( evt.theme.formats ).length;
|
||||
return L( M2C(this.msgs.applyTheme.msg,
|
||||
evt.status === 'error' ? 'red' : 'gray',
|
||||
evt.status === 'error' ? 'bold' : 'white.dim'),
|
||||
evt.theme.name.toUpperCase(),
|
||||
numFormats, numFormats === 1 ? '' : 's' );
|
||||
|
||||
break;
|
||||
|
||||
case HME.afterTheme:
|
||||
break;
|
||||
|
||||
case HME.beforeMerge:
|
||||
var msg = '';
|
||||
evt.f.reverse().forEach( function( a, idx ) {
|
||||
msg += printf(
|
||||
((idx === 0) ?
|
||||
this.msgs.beforeMerge.msg[0] :
|
||||
this.msgs.beforeMerge.msg[1] ), a.file
|
||||
);
|
||||
}, this);
|
||||
L( M2C(msg, evt.mixed ? 'yellow' : 'gray', 'white.dim') );
|
||||
break;
|
||||
|
||||
case HME.afterMerge:
|
||||
break;
|
||||
|
||||
case HME.applyTheme:
|
||||
this.theme = evt.theme;
|
||||
var numFormats = Object.keys( evt.theme.formats ).length;
|
||||
L( M2C(this.msgs.applyTheme.msg, evt.status === 'error' ? 'red' : 'gray', evt.status === 'error' ? 'bold' : 'white.dim'),
|
||||
evt.theme.name.toUpperCase(),
|
||||
numFormats, ( numFormats === 1 ? '' : 's') );
|
||||
break;
|
||||
|
||||
case HME.end:
|
||||
if( evt.cmd === 'build' ) {
|
||||
var themeName = this.theme.name.toUpperCase();
|
||||
if( this.opts.tips && (this.theme.message || this.theme.render) ) {
|
||||
var WRAP = require('word-wrap');
|
||||
if( this.theme.message ) {
|
||||
L( M2C( this.msgs.afterBuild.msg[0], 'cyan' ), themeName );
|
||||
L( M2C( this.theme.message, 'white' ));
|
||||
}
|
||||
else if ( this.theme.render ) {
|
||||
L( M2C( this.msgs.afterBuild.msg[0], 'cyan'), themeName);
|
||||
L( M2C( this.msgs.afterBuild.msg[1], 'white'));
|
||||
}
|
||||
case HME.end:
|
||||
if (evt.cmd === 'build') {
|
||||
const themeName = this.theme.name.toUpperCase();
|
||||
if (this.opts.tips && (this.theme.message || this.theme.render)) {
|
||||
if (this.theme.message) {
|
||||
L( M2C( this.msgs.afterBuild.msg[0], 'cyan' ), themeName );
|
||||
return L( M2C( this.theme.message, 'white' ));
|
||||
} else if (this.theme.render) {
|
||||
L( M2C( this.msgs.afterBuild.msg[0], 'cyan'), themeName);
|
||||
return L( M2C( this.msgs.afterBuild.msg[1], 'white'));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case HME.afterGenerate:
|
||||
var suffix = '';
|
||||
if( evt.fmt === 'pdf' ) {
|
||||
if( this.opts.pdf ) {
|
||||
if( this.opts.pdf !== 'none' ) {
|
||||
suffix = printf( M2C( this.msgs.afterGenerate.msg[0], evt.error ? 'red' : 'green' ), this.opts.pdf );
|
||||
}
|
||||
else {
|
||||
L( M2C( this.msgs.afterGenerate.msg[1], 'gray' ),
|
||||
evt.fmt.toUpperCase(), evt.file );
|
||||
return;
|
||||
}
|
||||
case HME.afterGenerate:
|
||||
var suffix = '';
|
||||
if (evt.fmt === 'pdf') {
|
||||
if (this.opts.pdf) {
|
||||
if (this.opts.pdf !== 'none') {
|
||||
suffix = printf( M2C( this.msgs.afterGenerate.msg[0], evt.error ? 'red' : 'green' ), this.opts.pdf );
|
||||
} else {
|
||||
L( M2C( this.msgs.afterGenerate.msg[1], 'gray' ), evt.fmt.toUpperCase(), evt.file );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
L( M2C( this.msgs.afterGenerate.msg[2] + suffix, evt.error ? 'red' : 'green' ),
|
||||
pad(evt.fmt.toUpperCase(),4,null,pad.RIGHT),
|
||||
PATH.relative(process.cwd(), evt.file ));
|
||||
break;
|
||||
return L( M2C( this.msgs.afterGenerate.msg[2] + suffix, evt.error ? 'red' : 'green' ),
|
||||
pad( evt.fmt.toUpperCase(),4,null,pad.RIGHT ),
|
||||
PATH.relative( process.cwd(), evt.file ) );
|
||||
|
||||
case HME.beforeAnalyze:
|
||||
L( M2C( this.msgs.beforeAnalyze.msg, 'green' ), evt.fmt, evt.file);
|
||||
break;
|
||||
case HME.beforeAnalyze:
|
||||
return L( M2C( this.msgs.beforeAnalyze.msg, 'green' ), evt.fmt, evt.file);
|
||||
|
||||
case HME.afterAnalyze:
|
||||
var info = evt.info;
|
||||
var rawTpl = FS.readFileSync( PATH.join( __dirname, 'analyze.hbs' ), 'utf8');
|
||||
HANDLEBARS.registerHelper( require('../helpers/console-helpers') );
|
||||
var template = HANDLEBARS.compile(rawTpl, { strict: false, assumeObjects: false });
|
||||
var tot = 0;
|
||||
info.keywords.forEach(function(g) { tot += g.count; });
|
||||
info.keywords.totalKeywords = tot;
|
||||
var output = template( info );
|
||||
this.log( chalk.cyan(output) );
|
||||
break;
|
||||
case HME.afterAnalyze:
|
||||
var { info } = evt;
|
||||
var rawTpl = FS.readFileSync( PATH.join( __dirname, 'analyze.hbs' ), 'utf8');
|
||||
HANDLEBARS.registerHelper( require('../helpers/console-helpers') );
|
||||
var template = HANDLEBARS.compile(rawTpl, { strict: false, assumeObjects: false });
|
||||
var tot = 0;
|
||||
info.keywords.forEach(g => tot += g.count);
|
||||
info.keywords.totalKeywords = tot;
|
||||
var output = template( info );
|
||||
return this.log( chalk.cyan(output) );
|
||||
|
||||
case HME.beforeConvert:
|
||||
L( M2C( this.msgs.beforeConvert.msg, 'green' ),
|
||||
evt.srcFile, evt.srcFmt, evt.dstFile, evt.dstFmt
|
||||
);
|
||||
break;
|
||||
case HME.beforeConvert:
|
||||
return L( M2C( this.msgs.beforeConvert.msg, evt.error ? 'red' : 'green' ),
|
||||
evt.srcFile, evt.srcFmt, evt.dstFile, evt.dstFmt
|
||||
);
|
||||
|
||||
case HME.afterInlineConvert:
|
||||
L( M2C( this.msgs.afterInlineConvert.msg, 'gray', 'white.dim' ),
|
||||
evt.file, evt.fmt );
|
||||
break;
|
||||
case HME.afterInlineConvert:
|
||||
return L( M2C( this.msgs.afterInlineConvert.msg, 'gray', 'white.dim' ),
|
||||
evt.file, evt.fmt );
|
||||
|
||||
case HME.afterValidate:
|
||||
var style = evt.isValid ? 'green' : 'yellow';
|
||||
L(
|
||||
M2C( this.msgs.afterValidate.msg[0], 'white' ) +
|
||||
chalk[style].bold( evt.isValid ?
|
||||
this.msgs.afterValidate.msg[1] :
|
||||
this.msgs.afterValidate.msg[2] ),
|
||||
evt.file, evt.fmt
|
||||
);
|
||||
case HME.afterValidate:
|
||||
var style = 'red';
|
||||
var adj = '';
|
||||
var msgs = this.msgs.afterValidate.msg;
|
||||
switch (evt.status) {
|
||||
case 'valid': style = 'green'; adj = msgs[1]; break;
|
||||
case 'invalid': style = 'yellow'; adj = msgs[2]; break;
|
||||
case 'broken': style = 'red'; adj = msgs[3]; break;
|
||||
case 'missing': style = 'red'; adj = msgs[4]; break;
|
||||
case 'unknown': style = 'red'; adj = msgs[5]; break;
|
||||
}
|
||||
evt.schema = evt.schema.replace('jars','JSON Resume').toUpperCase();
|
||||
L(M2C( msgs[0], 'white' ) + chalk[style].bold(adj), evt.file, evt.schema);
|
||||
|
||||
if( evt.errors ) {
|
||||
_.each(evt.errors, function(err,idx) {
|
||||
L( chalk.yellow.bold('--> ') +
|
||||
chalk.yellow(err.field.replace('data.','resume.').toUpperCase() + ' ' +
|
||||
err.message) );
|
||||
}, this);
|
||||
if (evt.violations) {
|
||||
_.each(evt.violations, function(err) {
|
||||
L( chalk.yellow.bold('--> ') +
|
||||
chalk.yellow(err.field.replace('data.','resume.').toUpperCase() +
|
||||
' ' + err.message));
|
||||
}
|
||||
break;
|
||||
, this);
|
||||
}
|
||||
return;
|
||||
|
||||
case HME.beforePeek:
|
||||
// if( evt.target )
|
||||
// L(M2C(this.msgs.beforePeek.msg[0], evt.isError ? 'red' : 'green'), evt.target, evt.file);
|
||||
// else
|
||||
// L(M2C(this.msgs.beforePeek.msg[1], evt.isError ? 'red' : 'green'), evt.file);
|
||||
break;
|
||||
case HME.afterPeek:
|
||||
var sty = evt.error ? 'red' : ( evt.target !== undefined ? 'green' : 'yellow' );
|
||||
|
||||
case HME.afterPeek:
|
||||
var sty = evt.error ? 'red' : ( evt.target !== undefined ? 'green' : 'yellow' );
|
||||
if( evt.requested )
|
||||
L(M2C(this.msgs.beforePeek.msg[0], sty), evt.requested, evt.file);
|
||||
else
|
||||
L(M2C(this.msgs.beforePeek.msg[1], sty), evt.file);
|
||||
// "Peeking at 'someKey' in 'someFile'."
|
||||
if (evt.requested) {
|
||||
L(M2C(this.msgs.beforePeek.msg[0], sty), evt.requested, evt.file);
|
||||
} else {
|
||||
L(M2C(this.msgs.beforePeek.msg[1], sty), evt.file);
|
||||
}
|
||||
|
||||
if( evt.target !== undefined )
|
||||
console.dir( evt.target, { depth: null, colors: true } );
|
||||
else if( !evt.error )
|
||||
L(M2C( this.msgs.afterPeek.msg, 'yellow'), evt.requested, evt.file);
|
||||
break;
|
||||
// If the key was present, print it
|
||||
if ((evt.target !== undefined) && !evt.error) {
|
||||
// eslint-disable-next-line no-console
|
||||
return console.dir( evt.target, { depth: null, colors: true } );
|
||||
|
||||
}
|
||||
// If the key was not present, but no error occurred, print it
|
||||
} else if (!evt.error) {
|
||||
return L(M2C( this.msgs.afterPeek.msg, 'yellow'), evt.requested, evt.file);
|
||||
|
||||
} else if (evt.error) {
|
||||
return L(chalk.red( evt.error.inner.inner ));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}());
|
||||
module.exports = OutputHandler;
|
||||
|
@ -1,51 +0,0 @@
|
||||
Usage:
|
||||
|
||||
hackmyresume <command> <sources> [TO <targets>] [<options>]
|
||||
|
||||
Available commands:
|
||||
|
||||
BUILD Build your resume to the destination format(s).
|
||||
ANALYZE Analyze your resume for keywords, gaps, and metrics.
|
||||
VALIDATE Validate your resume for errors and typos.
|
||||
CONVERT Convert your resume between FRESH and JSON Resume.
|
||||
NEW Create a new resume in FRESH or JSON Resume format.
|
||||
PEEK View a specific field or element on your resume.
|
||||
|
||||
Available options:
|
||||
|
||||
--theme -t Path to a FRESH or JSON Resume theme.
|
||||
--pdf -p Specify the PDF engine to use (wkhtmltopdf or phantom).
|
||||
--options -o Load options from an external JSON file.
|
||||
--format -f The format (FRESH or JSON Resume) to use.
|
||||
--debug -d Emit extended debugging info.
|
||||
--assert -a Treat resume validation warnings as errors.
|
||||
--no-colors Disable terminal colors.
|
||||
--tips Display theme messages and tips.
|
||||
--help -h Display help documentation.
|
||||
--version -v Display the current version.
|
||||
|
||||
Not all options are supported for all commands. For example, the
|
||||
--theme option is only supported for the BUILD command.
|
||||
|
||||
Examples:
|
||||
|
||||
hackmyresume BUILD resume.json TO out/resume.all --theme modern
|
||||
hackmyresume ANALYZE resume.json
|
||||
hackmyresume NEW my-new-resume.json --format JRS
|
||||
hackmyresume CONVERT resume-fresh.json TO resume-jrs.json
|
||||
hackmyresume VALIDATE resume.json
|
||||
hackmyresume PEEK resume.json employment[2].summary
|
||||
|
||||
Tips:
|
||||
|
||||
- You can specify multiple sources and/or targets for all commands.
|
||||
- You can use any FRESH or JSON Resume theme with HackMyResume.
|
||||
- Specify a file extension of .all to generate your resume to all
|
||||
available formats supported by the theme. (BUILD command.)
|
||||
- The --theme parameter can specify either the name of a preinstalled
|
||||
theme, or the path to a local FRESH or JSON Resume theme.
|
||||
- Visit https://www.npmjs.com/search?q=jsonresume-theme for a full
|
||||
listing of all available JSON Resume themes.
|
||||
- Visit https://github.com/fluentdesk/fresh-themes for a complete
|
||||
listing of all available FRESH themes.
|
||||
- Report bugs to https://githut.com/hacksalot/HackMyResume/issues.
|
@ -1,21 +1,18 @@
|
||||
(function(){
|
||||
/*
|
||||
Event code definitions.
|
||||
@module core/default-formats
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
/**
|
||||
Supported resume formats.
|
||||
*/
|
||||
|
||||
module.exports = [
|
||||
|
||||
{ name: 'html', ext: 'html', gen: new (require('../generators/html-generator'))() },
|
||||
{ name: 'txt', ext: 'txt', gen: new (require('../generators/text-generator'))() },
|
||||
{ name: 'doc', ext: 'doc', fmt: 'xml', gen: new (require('../generators/word-generator'))() },
|
||||
{ name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new (require('../generators/html-pdf-cli-generator'))() },
|
||||
{ name: 'png', ext: 'png', fmt: 'html', is: false, gen: new (require('../generators/html-png-generator'))() },
|
||||
{ name: 'md', ext: 'md', fmt: 'txt', gen: new (require('../generators/markdown-generator'))() },
|
||||
{ name: 'json', ext: 'json', gen: new (require('../generators/json-generator'))() },
|
||||
{ name: 'yml', ext: 'yml', fmt: 'yml', gen: new (require('../generators/json-yaml-generator'))() },
|
||||
{ name: 'latex', ext: 'tex', fmt: 'latex', gen: new (require('../generators/latex-generator'))() }
|
||||
|
||||
];
|
||||
|
||||
}());
|
||||
/** Supported resume formats. */
|
||||
module.exports = [
|
||||
{ name: 'html', ext: 'html', gen: new (require('../generators/html-generator'))() },
|
||||
{ name: 'txt', ext: 'txt', gen: new (require('../generators/text-generator'))() },
|
||||
{ name: 'doc', ext: 'doc', fmt: 'xml', gen: new (require('../generators/word-generator'))() },
|
||||
{ name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new (require('../generators/html-pdf-cli-generator'))() },
|
||||
{ name: 'png', ext: 'png', fmt: 'html', is: false, gen: new (require('../generators/html-png-generator'))() },
|
||||
{ name: 'md', ext: 'md', fmt: 'txt', gen: new (require('../generators/markdown-generator'))() },
|
||||
{ name: 'json', ext: 'json', gen: new (require('../generators/json-generator'))() },
|
||||
{ name: 'yml', ext: 'yml', fmt: 'yml', gen: new (require('../generators/json-yaml-generator'))() },
|
||||
{ name: 'latex', ext: 'tex', fmt: 'latex', gen: new (require('../generators/latex-generator'))() }
|
||||
];
|
||||
|
@ -1,13 +1,15 @@
|
||||
(function(){
|
||||
/*
|
||||
Event code definitions.
|
||||
@module core/default-options
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
||||
module.exports = {
|
||||
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
|
||||
|
@ -1,46 +1,39 @@
|
||||
/**
|
||||
/*
|
||||
Event code definitions.
|
||||
@module event-codes.js
|
||||
@module core/event-codes
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function(){
|
||||
|
||||
var val = 0;
|
||||
|
||||
module.exports = {
|
||||
|
||||
error: -1,
|
||||
success: 0,
|
||||
begin: 1,
|
||||
end: 2,
|
||||
beforeRead: 3,
|
||||
afterRead: 4,
|
||||
beforeCreate: 5,
|
||||
afterCreate: 6,
|
||||
beforeTheme: 7,
|
||||
afterTheme: 8,
|
||||
beforeMerge: 9,
|
||||
afterMerge: 10,
|
||||
beforeGenerate: 11,
|
||||
afterGenerate: 12,
|
||||
beforeAnalyze: 13,
|
||||
afterAnalyze: 14,
|
||||
beforeConvert: 15,
|
||||
afterConvert: 16,
|
||||
verifyOutputs: 17,
|
||||
beforeParse: 18,
|
||||
afterParse: 19,
|
||||
beforePeek: 20,
|
||||
afterPeek: 21,
|
||||
beforeInlineConvert: 22,
|
||||
afterInlineConvert: 23,
|
||||
beforeValidate: 24,
|
||||
afterValidate: 25
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
module.exports = {
|
||||
error: -1,
|
||||
success: 0,
|
||||
begin: 1,
|
||||
end: 2,
|
||||
beforeRead: 3,
|
||||
afterRead: 4,
|
||||
beforeCreate: 5,
|
||||
afterCreate: 6,
|
||||
beforeTheme: 7,
|
||||
afterTheme: 8,
|
||||
beforeMerge: 9,
|
||||
afterMerge: 10,
|
||||
beforeGenerate: 11,
|
||||
afterGenerate: 12,
|
||||
beforeAnalyze: 13,
|
||||
afterAnalyze: 14,
|
||||
beforeConvert: 15,
|
||||
afterConvert: 16,
|
||||
verifyOutputs: 17,
|
||||
beforeParse: 18,
|
||||
afterParse: 19,
|
||||
beforePeek: 20,
|
||||
afterPeek: 21,
|
||||
beforeInlineConvert: 22,
|
||||
afterInlineConvert: 23,
|
||||
beforeValidate: 24,
|
||||
afterValidate: 25,
|
||||
beforeWrite: 26,
|
||||
afterWrite: 27,
|
||||
applyTheme: 28
|
||||
};
|
||||
|
@ -1,95 +1,95 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS104: Avoid inline assignments
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
The HackMyResume date representation.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module core/fluent-date
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
var moment = require('moment');
|
||||
|
||||
/**
|
||||
Create a FluentDate from a string or Moment date object. There are a few date
|
||||
formats to be aware of here.
|
||||
1. The words "Present" and "Now", referring to the current date
|
||||
2. The default "YYYY-MM-DD" format used in JSON Resume ("2015-02-10")
|
||||
3. Year-and-month only ("2015-04")
|
||||
4. Year-only "YYYY" ("2015")
|
||||
5. The friendly HackMyResume "mmm YYYY" format ("Mar 2015" or "Dec 2008")
|
||||
6. Empty dates ("", " ")
|
||||
7. Any other date format that Moment.js can parse from
|
||||
Note: Moment can transparently parse all or most of these, without requiring us
|
||||
to specify a date format...but for maximum parsing safety and to avoid Moment
|
||||
deprecation warnings, it's recommended to either a) explicitly specify the date
|
||||
format or b) use an ISO format. For clarity, we handle these cases explicitly.
|
||||
@class FluentDate
|
||||
*/
|
||||
function FluentDate( dt ) {
|
||||
this.rep = this.fmt( dt );
|
||||
const moment = require('moment');
|
||||
require('../utils/string');
|
||||
|
||||
/**
|
||||
Create a FluentDate from a string or Moment date object. There are a few date
|
||||
formats to be aware of here.
|
||||
1. The words "Present" and "Now", referring to the current date
|
||||
2. The default "YYYY-MM-DD" format used in JSON Resume ("2015-02-10")
|
||||
3. Year-and-month only ("2015-04")
|
||||
4. Year-only "YYYY" ("2015")
|
||||
5. The friendly HackMyResume "mmm YYYY" format ("Mar 2015" or "Dec 2008")
|
||||
6. Empty dates ("", " ")
|
||||
7. Any other date format that Moment.js can parse from
|
||||
Note: Moment can transparently parse all or most of these, without requiring us
|
||||
to specify a date format...but for maximum parsing safety and to avoid Moment
|
||||
deprecation warnings, it's recommended to either a) explicitly specify the date
|
||||
format or b) use an ISO format. For clarity, we handle these cases explicitly.
|
||||
@class FluentDate
|
||||
*/
|
||||
|
||||
class FluentDate {
|
||||
|
||||
constructor(dt) {
|
||||
this.rep = this.fmt(dt);
|
||||
}
|
||||
|
||||
FluentDate/*.prototype*/.fmt = function( dt, throws ) {
|
||||
static isCurrent(dt) {
|
||||
return !dt || (String.is(dt) && /^(present|now|current)$/.test(dt));
|
||||
}
|
||||
}
|
||||
|
||||
throws = (throws === undefined || throws === null) || throws;
|
||||
const months = {};
|
||||
const abbr = {};
|
||||
moment.months().forEach((m,idx) => months[m.toLowerCase()] = idx+1);
|
||||
moment.monthsShort().forEach((m,idx) => abbr[m.toLowerCase()]=idx+1);
|
||||
abbr.sept = 9;
|
||||
module.exports = FluentDate;
|
||||
|
||||
if( (typeof dt === 'string' || dt instanceof String) ) {
|
||||
dt = dt.toLowerCase().trim();
|
||||
if( /^(present|now|current)$/.test(dt) ) { // "Present", "Now"
|
||||
return moment();
|
||||
FluentDate.fmt = function( dt, throws ) {
|
||||
|
||||
throws = ((throws === undefined) || (throws === null)) || throws;
|
||||
|
||||
if ((typeof dt === 'string') || dt instanceof String) {
|
||||
dt = dt.toLowerCase().trim();
|
||||
if (/^(present|now|current)$/.test(dt)) { // "Present", "Now"
|
||||
return moment();
|
||||
} else if (/^\D+\s+\d{4}$/.test(dt)) { // "Mar 2015"
|
||||
let left;
|
||||
const parts = dt.split(' ');
|
||||
const month = (months[parts[0]] || abbr[parts[0]]);
|
||||
const temp = parts[1] + '-' + ((left = month < 10) != null ? left : `0${{month : month.toString()}}`);
|
||||
return moment(temp, 'YYYY-MM');
|
||||
} else if (/^\d{4}-\d{1,2}$/.test(dt)) { // "2015-03", "1998-4"
|
||||
return moment(dt, 'YYYY-MM');
|
||||
} else if (/^\s*\d{4}\s*$/.test(dt)) { // "2015"
|
||||
return moment(dt, 'YYYY');
|
||||
} else if (/^\s*$/.test(dt)) { // "", " "
|
||||
return moment();
|
||||
} else {
|
||||
const mt = moment(dt);
|
||||
if (mt.isValid()) {
|
||||
return mt;
|
||||
}
|
||||
else if( /^\D+\s+\d{4}$/.test(dt) ) { // "Mar 2015"
|
||||
var parts = dt.split(' ');
|
||||
var month = (months[parts[0]] || abbr[parts[0]]);
|
||||
var temp = parts[1] + '-' + (month < 10 ? '0' + month : month.toString());
|
||||
return moment( temp, 'YYYY-MM' );
|
||||
if (throws) {
|
||||
throw 'Invalid date format encountered.';
|
||||
}
|
||||
else if( /^\d{4}-\d{1,2}$/.test(dt) ) { // "2015-03", "1998-4"
|
||||
return moment( dt, 'YYYY-MM' );
|
||||
}
|
||||
else if( /^\s*\d{4}\s*$/.test(dt) ) { // "2015"
|
||||
return moment( dt, 'YYYY' );
|
||||
}
|
||||
else if( /^\s*$/.test(dt) ) { // "", " "
|
||||
var defTime = {
|
||||
isNull: true,
|
||||
isBefore: function( other ) {
|
||||
return( other && !other.isNull ) ? true : false;
|
||||
},
|
||||
isAfter: function( other ) {
|
||||
return( other && !other.isNull ) ? false : false;
|
||||
},
|
||||
unix: function() { return 0; },
|
||||
format: function() { return ''; },
|
||||
diff: function() { return 0; }
|
||||
};
|
||||
return defTime;
|
||||
}
|
||||
else {
|
||||
var mt = moment( dt );
|
||||
if(mt.isValid())
|
||||
return mt;
|
||||
if( throws )
|
||||
throw 'Invalid date format encountered.';
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( !dt ) {
|
||||
return moment();
|
||||
}
|
||||
else if( dt.isValid && dt.isValid() )
|
||||
return dt;
|
||||
if( throws )
|
||||
throw 'Unknown date object encountered.';
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
var months = {}, abbr = {};
|
||||
moment.months().forEach(function(m,idx){months[m.toLowerCase()]=idx+1;});
|
||||
moment.monthsShort().forEach(function(m,idx){abbr[m.toLowerCase()]=idx+1;});
|
||||
abbr.sept = 9;
|
||||
|
||||
module.exports = FluentDate;
|
||||
|
||||
}());
|
||||
} else {
|
||||
if (!dt) {
|
||||
return moment();
|
||||
} else if (dt.isValid && dt.isValid()) {
|
||||
return dt;
|
||||
}
|
||||
if (throws) {
|
||||
throw 'Unknown date object encountered.';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
@ -1,3 +1,9 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the FRESHResume class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@ -6,56 +12,35 @@ Definition of the FRESHResume class.
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const FS = require('fs');
|
||||
const extend = require('extend');
|
||||
let validator = require('is-my-json-valid');
|
||||
const _ = require('underscore');
|
||||
const __ = require('lodash');
|
||||
const XML = require('xml-escape');
|
||||
const MD = require('marked');
|
||||
const CONVERTER = require('fresh-jrs-converter');
|
||||
const JRSResume = require('./jrs-resume');
|
||||
|
||||
|
||||
|
||||
var FS = require('fs')
|
||||
, extend = require('extend')
|
||||
, validator = require('is-my-json-valid')
|
||||
, _ = require('underscore')
|
||||
, __ = require('lodash')
|
||||
, PATH = require('path')
|
||||
, moment = require('moment')
|
||||
, XML = require('xml-escape')
|
||||
, MD = require('marked')
|
||||
, CONVERTER = require('fresh-jrs-converter')
|
||||
, JRSResume = require('./jrs-resume');
|
||||
/**
|
||||
A FRESH resume or CV. FRESH resumes are backed by JSON, and each FreshResume
|
||||
object is an instantiation of that JSON decorated with utility methods.
|
||||
@constructor
|
||||
*/
|
||||
class FreshResume {// extends AbstractResume
|
||||
|
||||
|
||||
|
||||
/**
|
||||
A FRESH resume or CV. FRESH resumes are backed by JSON, and each FreshResume
|
||||
object is an instantiation of that JSON decorated with utility methods.
|
||||
@constructor
|
||||
*/
|
||||
function FreshResume() {
|
||||
|
||||
/** Initialize the the FreshResume from JSON string data. */
|
||||
parse( stringData, opts ) {
|
||||
this.imp = this.imp != null ? this.imp : {raw: stringData};
|
||||
return this.parseJSON(JSON.parse( stringData ), opts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the FreshResume from file.
|
||||
*/
|
||||
FreshResume.prototype.open = function( file, opts ) {
|
||||
var raw = FS.readFileSync( file, 'utf8' );
|
||||
var ret = this.parse( raw, opts );
|
||||
this.imp.file = file;
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the the FreshResume from JSON string data.
|
||||
*/
|
||||
FreshResume.prototype.parse = function( stringData, opts ) {
|
||||
return this.parseJSON( JSON.parse( stringData ), opts );
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the FreshResume from JSON.
|
||||
Open and parse the specified FRESH resume. Merge the JSON object model onto
|
||||
@ -69,70 +54,83 @@ Definition of the FRESHResume class.
|
||||
compute: Prepare computed resume totals.
|
||||
}
|
||||
*/
|
||||
FreshResume.prototype.parseJSON = function( rep, opts ) {
|
||||
parseJSON( rep, opts ) {
|
||||
|
||||
// Ignore any element with the 'ignore: true' designator.
|
||||
var that = this, traverse = require('traverse'), ignoreList = [];
|
||||
var scrubbed = traverse( rep ).map( function( x ) {
|
||||
if( !this.isLeaf && this.node.ignore ) {
|
||||
if ( this.node.ignore === true || this.node.ignore === 'true' ) {
|
||||
ignoreList.push( this.node );
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
let scrubbed;
|
||||
if (opts && opts.privatize) {
|
||||
// Ignore any element with the 'ignore: true' or 'private: true' designator.
|
||||
const scrubber = require('../utils/resume-scrubber');
|
||||
var ret = scrubber.scrubResume(rep, opts);
|
||||
scrubbed = ret.scrubbed;
|
||||
}
|
||||
|
||||
// Now apply the resume representation onto this object
|
||||
extend( true, this, scrubbed );
|
||||
extend(true, this, opts && opts.privatize ? scrubbed : rep);
|
||||
|
||||
// If the resume already has a .imp object, then we are being called from
|
||||
// If the resume has already been processed, then we are being called from
|
||||
// the .dupe method, and there's no need to do any post processing
|
||||
if( !this.imp ) {
|
||||
if (!(this.imp != null ? this.imp.processed : undefined)) {
|
||||
// Set up metadata TODO: Clean up metadata on the object model.
|
||||
opts = opts || { };
|
||||
if( opts.imp === undefined || opts.imp ) {
|
||||
if ((opts.imp === undefined) || opts.imp) {
|
||||
this.imp = this.imp || { };
|
||||
this.imp.title = (opts.title || this.imp.title) || this.name;
|
||||
if (!this.imp.raw) {
|
||||
this.imp.raw = JSON.stringify(rep);
|
||||
}
|
||||
}
|
||||
this.imp.processed = true;
|
||||
// Parse dates, sort dates, and calculate computed values
|
||||
(opts.date === undefined || opts.date) && _parseDates.call( this );
|
||||
(opts.sort === undefined || opts.sort) && this.sort();
|
||||
(opts.compute === undefined || opts.compute) && (this.computed = {
|
||||
((opts.date === undefined) || opts.date) && _parseDates.call( this );
|
||||
((opts.sort === undefined) || opts.sort) && this.sort();
|
||||
((opts.compute === undefined) || opts.compute) && (this.computed = {
|
||||
numYears: this.duration(),
|
||||
keywords: this.keywords()
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Save the sheet to disk (for environments that have disk access).
|
||||
*/
|
||||
FreshResume.prototype.save = function( filename ) {
|
||||
/** Save the sheet to disk (for environments that have disk access). */
|
||||
save( filename ) {
|
||||
this.imp.file = filename || this.imp.file;
|
||||
FS.writeFileSync( this.imp.file, this.stringify(), 'utf8' );
|
||||
FS.writeFileSync(this.imp.file, this.stringify(), 'utf8');
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Save the sheet to disk in a specific format, either FRESH or JSON Resume.
|
||||
*/
|
||||
FreshResume.prototype.saveAs = function( filename, format ) {
|
||||
saveAs( filename, format ) {
|
||||
|
||||
if( format !== 'JRS' ) {
|
||||
// If format isn't specified, default to FRESH
|
||||
const safeFormat = (format && format.trim()) || 'FRESH';
|
||||
|
||||
// Validate against the FRESH version regex
|
||||
// freshVersionReg = require '../utils/fresh-version-regex'
|
||||
// if (not freshVersionReg().test( safeFormat ))
|
||||
// throw badVer: safeFormat
|
||||
|
||||
const parts = safeFormat.split('@');
|
||||
|
||||
if (parts[0] === 'FRESH') {
|
||||
this.imp.file = filename || this.imp.file;
|
||||
FS.writeFileSync( this.imp.file, this.stringify(), 'utf8' );
|
||||
}
|
||||
else {
|
||||
var newRep = CONVERTER.toJRS( this );
|
||||
FS.writeFileSync( filename, JRSResume.stringify( newRep ), 'utf8' );
|
||||
FS.writeFileSync(this.imp.file, this.stringify(), 'utf8');
|
||||
|
||||
} else if (parts[0] === 'JRS') {
|
||||
const useEdgeSchema = parts.length > 1 ? parts[1] === '1' : false;
|
||||
const newRep = CONVERTER.toJRS(this, {edge: useEdgeSchema});
|
||||
FS.writeFileSync(filename, JRSResume.stringify( newRep ), 'utf8');
|
||||
} else {
|
||||
throw {badVer: safeFormat};
|
||||
}
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -143,28 +141,12 @@ Definition of the FRESHResume class.
|
||||
We do it this way to create a true clone of the object without re-running any
|
||||
of the associated processing.
|
||||
*/
|
||||
FreshResume.prototype.dupe = function() {
|
||||
var jso = extend( true, { }, this );
|
||||
var rnew = new FreshResume();
|
||||
rnew.parseJSON( jso, { } );
|
||||
dupe() {
|
||||
const jso = extend(true, { }, this);
|
||||
const rnew = new FreshResume();
|
||||
rnew.parseJSON(jso, { });
|
||||
return rnew;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Convert the supplied FreshResume to a JSON string, sanitizing meta-properties
|
||||
along the way.
|
||||
*/
|
||||
FreshResume.stringify = function( obj ) {
|
||||
function replacer( key,value ) { // Exclude these keys from stringification
|
||||
return _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||
'safe', 'result', 'isModified', 'htmlPreview', 'display_progress_bar'],
|
||||
function( val ) { return key.trim() === val; }
|
||||
) ? undefined : value;
|
||||
}
|
||||
return JSON.stringify( obj, replacer, 2 );
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -172,9 +154,7 @@ Definition of the FRESHResume class.
|
||||
Convert this object to a JSON string, sanitizing meta-properties along the
|
||||
way.
|
||||
*/
|
||||
FreshResume.prototype.stringify = function() {
|
||||
return FreshResume.stringify( this );
|
||||
};
|
||||
stringify() { return FreshResume.stringify(this); }
|
||||
|
||||
|
||||
|
||||
@ -183,11 +163,11 @@ Definition of the FRESHResume class.
|
||||
a transformation function (such as a Markdown filter or XML encoder).
|
||||
TODO: Move this out of FRESHResume.
|
||||
*/
|
||||
FreshResume.prototype.transformStrings = function( filt, transformer ) {
|
||||
var ret = this.dupe();
|
||||
var trx = require('../utils/string-transformer');
|
||||
return trx( ret, filt, transformer );
|
||||
};
|
||||
transformStrings( filt, transformer ) {
|
||||
const ret = this.dupe();
|
||||
const trx = require('../utils/string-transformer');
|
||||
return trx(ret, filt, transformer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -195,21 +175,19 @@ Definition of the FRESHResume class.
|
||||
Create a copy of this resume in which all fields have been interpreted as
|
||||
Markdown.
|
||||
*/
|
||||
FreshResume.prototype.markdownify = function() {
|
||||
markdownify() {
|
||||
|
||||
function MDIN( txt ){
|
||||
return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
||||
}
|
||||
const MDIN = txt => MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
||||
|
||||
function trx(key, val) {
|
||||
if( key === 'summary' ) {
|
||||
const trx = function( key, val ) {
|
||||
if (key === 'summary') {
|
||||
return MD(val);
|
||||
}
|
||||
return MDIN(val);
|
||||
}
|
||||
};
|
||||
|
||||
return this.transformStrings( ['skills','url','start','end','date'], trx );
|
||||
};
|
||||
return this.transformStrings(['skills','url','start','end','date'], trx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -217,62 +195,64 @@ Definition of the FRESHResume class.
|
||||
Create a copy of this resume in which all fields have been interpreted as
|
||||
Markdown.
|
||||
*/
|
||||
FreshResume.prototype.xmlify = function() {
|
||||
function trx(key, val) {
|
||||
return XML(val);
|
||||
}
|
||||
return this.transformStrings( [], trx );
|
||||
};
|
||||
xmlify() {
|
||||
const trx = (key, val) => XML(val);
|
||||
return this.transformStrings([], trx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Return the resume format.
|
||||
*/
|
||||
FreshResume.prototype.format = function() {
|
||||
return 'FRESH';
|
||||
};
|
||||
/** Return the resume format. */
|
||||
format() { return 'FRESH'; }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Return internal metadata. Create if it doesn't exist.
|
||||
*/
|
||||
FreshResume.prototype.i = function() {
|
||||
this.imp = (this.imp || { });
|
||||
return this.imp;
|
||||
};
|
||||
i() { return this.imp = this.imp || { }; }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Return a unique list of all keywords across all skills.
|
||||
Return a unique list of all skills declared in the resume.
|
||||
*/
|
||||
FreshResume.prototype.keywords = function() {
|
||||
var flatSkills = [];
|
||||
if( this.skills ) {
|
||||
if( this.skills.sets ) {
|
||||
flatSkills = this.skills.sets.map(function(sk) { return sk.skills; })
|
||||
.reduce(function(a,b) { return a.concat(b); });
|
||||
|
||||
// TODO: Several problems here:
|
||||
// 1) Confusing name. Easily confused with the keyword-inspector module, which
|
||||
// parses resume body text looking for these same keywords. This should probably
|
||||
// be renamed.
|
||||
//
|
||||
// 2) Doesn't bother trying to integrate skills.list with skills.sets if they
|
||||
// happen to declare different skills, and if skills.sets declares ONE skill and
|
||||
// skills.list declared 50, only 1 skill will be registered.
|
||||
//
|
||||
// 3) In the future, skill.sets should only be able to use skills declared in
|
||||
// skills.list. That is, skills.list is the official record of a candidate's
|
||||
// declared skills. skills.sets is just a way of grouping those into skillsets
|
||||
// for easier consumption.
|
||||
|
||||
keywords() {
|
||||
let flatSkills = [];
|
||||
if (this.skills) {
|
||||
if (this.skills.sets) {
|
||||
flatSkills = this.skills.sets.map(sk => sk.skills).reduce( (a,b) => a.concat(b));
|
||||
} else if (this.skills.list) {
|
||||
flatSkills = flatSkills.concat( this.skills.list.map(sk => sk.name) );
|
||||
}
|
||||
else if( this.skills.list ) {
|
||||
flatSkills = flatSkills.concat( this.skills.list.map(function(sk) {
|
||||
return sk.name;
|
||||
}));
|
||||
}
|
||||
flatSkills = _.uniq( flatSkills );
|
||||
flatSkills = _.uniq(flatSkills);
|
||||
}
|
||||
return flatSkills;
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Reset the sheet to an empty state. TODO: refactor/review
|
||||
*/
|
||||
FreshResume.prototype.clear = function( clearMeta ) {
|
||||
clear( clearMeta ) {
|
||||
clearMeta = ((clearMeta === undefined) && true) || clearMeta;
|
||||
clearMeta && (delete this.imp);
|
||||
if (clearMeta) { delete this.imp; }
|
||||
delete this.computed; // Don't use Object.keys() here
|
||||
delete this.employment;
|
||||
delete this.service;
|
||||
@ -282,75 +262,62 @@ Definition of the FRESHResume class.
|
||||
delete this.writing;
|
||||
delete this.interests;
|
||||
delete this.skills;
|
||||
delete this.social;
|
||||
};
|
||||
return delete this.social;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get a safe count of the number of things in a section.
|
||||
*/
|
||||
FreshResume.prototype.count = function( obj ) {
|
||||
if( !obj ) return 0;
|
||||
if( obj.history ) return obj.history.length;
|
||||
if( obj.sets ) return obj.sets.length;
|
||||
count( obj ) {
|
||||
if (!obj) { return 0; }
|
||||
if (obj.history) { return obj.history.length; }
|
||||
if (obj.sets) { return obj.sets.length; }
|
||||
return obj.length || 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get the default (starter) sheet.
|
||||
*/
|
||||
FreshResume.default = function() {
|
||||
return new FreshResume().parseJSON( require('fresh-resume-starter') );
|
||||
};
|
||||
/** Add work experience to the sheet. */
|
||||
add( moniker ) {
|
||||
const defSheet = FreshResume.default();
|
||||
const newObject =
|
||||
defSheet[moniker].history
|
||||
? extend( true, {}, defSheet[ moniker ].history[0] )
|
||||
:
|
||||
moniker === 'skills'
|
||||
? extend( true, {}, defSheet.skills.sets[0] )
|
||||
: extend( true, {}, defSheet[ moniker ][0] );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Add work experience to the sheet.
|
||||
*/
|
||||
FreshResume.prototype.add = function( moniker ) {
|
||||
var defSheet = FreshResume.default();
|
||||
var newObject = defSheet[moniker].history ?
|
||||
$.extend( true, {}, defSheet[ moniker ].history[0] ) :
|
||||
(moniker === 'skills' ?
|
||||
$.extend( true, {}, defSheet.skills.sets[0] ) :
|
||||
$.extend( true, {}, defSheet[ moniker ][0] ));
|
||||
this[ moniker ] = this[ moniker ] || [];
|
||||
if( this[ moniker ].history )
|
||||
this[ moniker ].history.push( newObject );
|
||||
else if( moniker === 'skills' )
|
||||
this.skills.sets.push( newObject );
|
||||
else
|
||||
this[ moniker ].push( newObject );
|
||||
if (this[ moniker ].history) {
|
||||
this[ moniker ].history.push(newObject);
|
||||
} else if (moniker === 'skills') {
|
||||
this.skills.sets.push(newObject);
|
||||
} else {
|
||||
this[ moniker ].push(newObject);
|
||||
}
|
||||
return newObject;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Determine if the sheet includes a specific social profile (eg, GitHub).
|
||||
*/
|
||||
FreshResume.prototype.hasProfile = function( socialNetwork ) {
|
||||
hasProfile( socialNetwork ) {
|
||||
socialNetwork = socialNetwork.trim().toLowerCase();
|
||||
return this.social && _.some( this.social, function(p) {
|
||||
return p.network.trim().toLowerCase() === socialNetwork;
|
||||
});
|
||||
};
|
||||
return this.social && _.some(this.social, p => p.network.trim().toLowerCase() === socialNetwork);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Return the specified network profile.
|
||||
*/
|
||||
FreshResume.prototype.getProfile = function( socialNetwork ) {
|
||||
/** Return the specified network profile. */
|
||||
getProfile( socialNetwork ) {
|
||||
socialNetwork = socialNetwork.trim().toLowerCase();
|
||||
return this.social && _.find( this.social, function(sn) {
|
||||
return sn.network.trim().toLowerCase() === socialNetwork;
|
||||
});
|
||||
};
|
||||
return this.social && _.find(this.social, sn => sn.network.trim().toLowerCase() === socialNetwork);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -358,72 +325,45 @@ Definition of the FRESHResume class.
|
||||
Return an array of profiles for the specified network, for when the user
|
||||
has multiple eg. GitHub accounts.
|
||||
*/
|
||||
FreshResume.prototype.getProfiles = function( socialNetwork ) {
|
||||
getProfiles( socialNetwork ) {
|
||||
socialNetwork = socialNetwork.trim().toLowerCase();
|
||||
return this.social && _.filter( this.social, function(sn){
|
||||
return sn.network.trim().toLowerCase() === socialNetwork;
|
||||
});
|
||||
};
|
||||
return this.social && _.filter(this.social, sn => sn.network.trim().toLowerCase() === socialNetwork);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Determine if the sheet includes a specific skill.
|
||||
*/
|
||||
FreshResume.prototype.hasSkill = function( skill ) {
|
||||
/** Determine if the sheet includes a specific skill. */
|
||||
hasSkill( skill ) {
|
||||
skill = skill.trim().toLowerCase();
|
||||
return this.skills && _.some( this.skills, function(sk) {
|
||||
return sk.keywords && _.some( sk.keywords, function(kw) {
|
||||
return kw.trim().toLowerCase() === skill;
|
||||
});
|
||||
});
|
||||
};
|
||||
return this.skills && _.some(this.skills, sk =>
|
||||
sk.keywords && _.some(sk.keywords, kw => kw.trim().toLowerCase() === skill)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Validate the sheet against the FRESH Resume schema.
|
||||
*/
|
||||
FreshResume.prototype.isValid = function( info ) {
|
||||
var schemaObj = require('fresca');
|
||||
var validator = require('is-my-json-valid');
|
||||
var validate = validator( schemaObj, { // See Note [1].
|
||||
/** Validate the sheet against the FRESH Resume schema. */
|
||||
isValid() {
|
||||
const schemaObj = require('fresh-resume-schema');
|
||||
validator = require('is-my-json-valid');
|
||||
const validate = validator( schemaObj, { // See Note [1].
|
||||
formats: { date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/ }
|
||||
});
|
||||
var ret = validate( this );
|
||||
if( !ret ) {
|
||||
const ret = validate(this);
|
||||
if (!ret) {
|
||||
this.imp = this.imp || { };
|
||||
this.imp.validationErrors = validate.errors;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Calculate the total duration of the sheet. Assumes this.work has been sorted
|
||||
by start date descending, perhaps via a call to Sheet.sort().
|
||||
@returns The total duration of the sheet's work history, that is, the number
|
||||
of years between the start date of the earliest job on the resume and the
|
||||
*latest end date of all jobs in the work history*. This last condition is for
|
||||
sheets that have overlapping jobs.
|
||||
*/
|
||||
FreshResume.prototype.duration = function(unit) {
|
||||
unit = unit || 'years';
|
||||
var empHist = __.get(this, 'employment.history');
|
||||
if( empHist && empHist.length ) {
|
||||
var firstJob = _.last( empHist );
|
||||
var careerStart = firstJob.start ? firstJob.safe.start : '';
|
||||
if ((typeof careerStart === 'string' || careerStart instanceof String) &&
|
||||
!careerStart.trim())
|
||||
return 0;
|
||||
var careerLast = _.max( empHist, function( w ) {
|
||||
return( w.safe && w.safe.end ) ? w.safe.end.unix() : moment().unix();
|
||||
});
|
||||
return careerLast.safe.end.diff( careerStart, unit );
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
duration(unit) {
|
||||
const inspector = require('../inspectors/duration-inspector');
|
||||
return inspector.run(this, 'employment.history', 'start', 'end', unit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -431,93 +371,108 @@ Definition of the FRESHResume class.
|
||||
Sort dated things on the sheet by start date descending. Assumes that dates
|
||||
on the sheet have been processed with _parseDates().
|
||||
*/
|
||||
FreshResume.prototype.sort = function( ) {
|
||||
sort() {
|
||||
|
||||
function byDateDesc(a,b) {
|
||||
return( a.safe.start.isBefore(b.safe.start) ) ? 1
|
||||
: ( a.safe.start.isAfter(b.safe.start) && -1 ) || 0;
|
||||
}
|
||||
const byDateDesc = function(a,b) {
|
||||
if (a.safe.start.isBefore(b.safe.start)) {
|
||||
return 1;
|
||||
} else { if (a.safe.start.isAfter(b.safe.start)) { return -1; } else { return 0; } }
|
||||
};
|
||||
|
||||
function sortSection( key ) {
|
||||
var ar = __.get(this, key);
|
||||
if( ar && ar.length ) {
|
||||
var datedThings = obj.filter( function(o) { return o.start; } );
|
||||
datedThings.sort( byDateDesc );
|
||||
const sortSection = function( key ) {
|
||||
const ar = __.get(this, key);
|
||||
if (ar && ar.length) {
|
||||
const datedThings = ar.filter(o => o.start);
|
||||
return datedThings.sort( byDateDesc );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
sortSection( 'employment.history' );
|
||||
sortSection( 'education.history' );
|
||||
sortSection( 'service.history' );
|
||||
sortSection( 'projects' );
|
||||
sortSection('employment.history');
|
||||
sortSection('education.history');
|
||||
sortSection('service.history');
|
||||
sortSection('projects');
|
||||
|
||||
// this.awards && this.awards.sort( function(a, b) {
|
||||
// return( a.safeDate.isBefore(b.safeDate) ) ? 1
|
||||
// : ( a.safeDate.isAfter(b.safeDate) && -1 ) || 0;
|
||||
// });
|
||||
this.writing && this.writing.sort( function(a, b) {
|
||||
return( a.safe.date.isBefore(b.safe.date) ) ? 1
|
||||
: ( a.safe.date.isAfter(b.safe.date) && -1 ) || 0;
|
||||
return this.writing && this.writing.sort(function(a, b) {
|
||||
if (a.safe.date.isBefore(b.safe.date)) {
|
||||
return 1;
|
||||
} else { return ( a.safe.date.isAfter(b.safe.date) && -1 ) || 0; }
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Convert human-friendly dates into formal Moment.js dates for all collections.
|
||||
We don't want to lose the raw textual date as entered by the user, so we store
|
||||
the Moment-ified date as a separate property with a prefix of .safe. For ex:
|
||||
job.startDate is the date as entered by the user. job.safeStartDate is the
|
||||
parsed Moment.js date that we actually use in processing.
|
||||
*/
|
||||
function _parseDates() {
|
||||
|
||||
var _fmt = require('./fluent-date').fmt;
|
||||
var that = this;
|
||||
|
||||
// TODO: refactor recursion
|
||||
function replaceDatesInObject( obj ) {
|
||||
|
||||
if( !obj ) return;
|
||||
if( Object.prototype.toString.call( obj ) === '[object Array]' ) {
|
||||
obj.forEach(function(elem){
|
||||
replaceDatesInObject( elem );
|
||||
});
|
||||
}
|
||||
else if (typeof obj === 'object') {
|
||||
if( obj._isAMomentObject || obj.safe )
|
||||
return;
|
||||
Object.keys( obj ).forEach(function(key) {
|
||||
replaceDatesInObject( obj[key] );
|
||||
});
|
||||
['start','end','date'].forEach( function(val) {
|
||||
if( (obj[val] !== undefined) && (!obj.safe || !obj.safe[val] )) {
|
||||
obj.safe = obj.safe || { };
|
||||
obj.safe[ val ] = _fmt( obj[val] );
|
||||
if( obj[val] && (val === 'start') && !obj.end ) {
|
||||
obj.safe.end = _fmt('current');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Object.keys( this ).forEach(function(member){
|
||||
replaceDatesInObject( that[ member ] );
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Export the Sheet function/ctor.
|
||||
*/
|
||||
module.exports = FreshResume;
|
||||
/**
|
||||
Get the default (starter) sheet.
|
||||
*/
|
||||
FreshResume.default = () => new FreshResume().parseJSON(require('fresh-resume-starter').fresh);
|
||||
|
||||
|
||||
|
||||
}());
|
||||
/**
|
||||
Convert the supplied FreshResume to a JSON string, sanitizing meta-properties
|
||||
along the way.
|
||||
*/
|
||||
FreshResume.stringify = function( obj ) {
|
||||
const replacer = function( key,value ) { // Exclude these keys from stringification
|
||||
const exKeys = ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||
'safe', 'result', 'isModified', 'htmlPreview', 'display_progress_bar'];
|
||||
if (_.some( exKeys, val => key.trim() === val)) {
|
||||
return undefined; } else { return value; }
|
||||
};
|
||||
return JSON.stringify(obj, replacer, 2);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Convert human-friendly dates into formal Moment.js dates for all collections.
|
||||
We don't want to lose the raw textual date as entered by the user, so we store
|
||||
the Moment-ified date as a separate property with a prefix of .safe. For ex:
|
||||
job.startDate is the date as entered by the user. job.safeStartDate is the
|
||||
parsed Moment.js date that we actually use in processing.
|
||||
*/
|
||||
var _parseDates = function() {
|
||||
|
||||
const _fmt = require('./fluent-date').fmt;
|
||||
const that = this;
|
||||
|
||||
// TODO: refactor recursion
|
||||
var replaceDatesInObject = function( obj ) {
|
||||
|
||||
if (!obj) { return; }
|
||||
if (Object.prototype.toString.call( obj ) === '[object Array]') {
|
||||
obj.forEach(elem => replaceDatesInObject( elem ));
|
||||
return;
|
||||
} else if (typeof obj === 'object') {
|
||||
if (obj._isAMomentObject || obj.safe) {
|
||||
return;
|
||||
}
|
||||
Object.keys( obj ).forEach(key => replaceDatesInObject(obj[key]));
|
||||
['start','end','date'].forEach(function(val) {
|
||||
if ((obj[val] !== undefined) && (!obj.safe || !obj.safe[val])) {
|
||||
obj.safe = obj.safe || { };
|
||||
obj.safe[ val ] = _fmt(obj[val]);
|
||||
if (obj[val] && (val === 'start') && !obj.end) {
|
||||
obj.safe.end = _fmt('current');
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
Object.keys( this ).forEach(function(member) {
|
||||
replaceDatesInObject(that[member]);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Export the Sheet function/ctor. */
|
||||
module.exports = FreshResume;
|
||||
|
||||
|
||||
|
||||
// Note 1: Adjust default date validation to allow YYYY and YYYY-MM formats
|
||||
// in addition to YYYY-MM-DD. The original regex:
|
||||
|
@ -1,338 +1,253 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS103: Rewrite code to no longer use __guard__
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the FRESHTheme class.
|
||||
@module fresh-theme.js
|
||||
@module core/fresh-theme
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
const FS = require('fs');
|
||||
const _ = require('underscore');
|
||||
const PATH = require('path');
|
||||
const parsePath = require('parse-filepath');
|
||||
const EXTEND = require('extend');
|
||||
const HMSTATUS = require('./status-codes');
|
||||
const loadSafeJson = require('../utils/safe-json-loader');
|
||||
const READFILES = require('recursive-readdir-sync');
|
||||
|
||||
|
||||
|
||||
var FS = require('fs')
|
||||
, validator = require('is-my-json-valid')
|
||||
, _ = require('underscore')
|
||||
, PATH = require('path')
|
||||
, parsePath = require('parse-filepath')
|
||||
, pathExists = require('path-exists').sync
|
||||
, EXTEND = require('extend')
|
||||
, HMSTATUS = require('./status-codes')
|
||||
, moment = require('moment')
|
||||
, loadSafeJson = require('../utils/safe-json-loader')
|
||||
, READFILES = require('recursive-readdir-sync');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The FRESHTheme class is a representation of a FRESH theme
|
||||
asset. See also: JRSTheme.
|
||||
@class FRESHTheme
|
||||
*/
|
||||
function FRESHTheme() {
|
||||
/* A representation of a FRESH theme asset.
|
||||
@class FRESHTheme */
|
||||
class FRESHTheme {
|
||||
|
||||
constructor() {
|
||||
this.baseFolder = 'src';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Open and parse the specified theme.
|
||||
*/
|
||||
FRESHTheme.prototype.open = function( themeFolder ) {
|
||||
/* Open and parse the specified theme. */
|
||||
open( themeFolder ) {
|
||||
|
||||
this.folder = themeFolder;
|
||||
|
||||
// Open the [theme-name].json file; should have the same name as folder
|
||||
var pathInfo = parsePath( themeFolder );
|
||||
|
||||
// Set up a formats hash for the theme
|
||||
var formatsHash = { };
|
||||
let formatsHash = { };
|
||||
|
||||
// Load the theme
|
||||
var themeFile = PATH.join( themeFolder, 'theme.json' );
|
||||
var themeInfo = loadSafeJson( themeFile );
|
||||
if( themeInfo.ex ) throw {
|
||||
fluenterror: themeInfo.ex.operation === 'parse' ?
|
||||
HMSTATUS.parseError : HMSTATUS.readError,
|
||||
const themeFile = PATH.join(themeFolder, 'theme.json');
|
||||
const themeInfo = loadSafeJson(themeFile);
|
||||
if (themeInfo.ex) {
|
||||
throw{
|
||||
fluenterror:
|
||||
themeInfo.ex.op === 'parse'
|
||||
? HMSTATUS.parseError
|
||||
: HMSTATUS.readError,
|
||||
inner: themeInfo.ex.inner
|
||||
};
|
||||
|
||||
var that = this;
|
||||
};
|
||||
}
|
||||
|
||||
// Move properties from the theme JSON file to the theme object
|
||||
EXTEND( true, this, themeInfo.json );
|
||||
EXTEND(true, this, themeInfo.json);
|
||||
|
||||
// Check for an "inherits" entry in the theme JSON.
|
||||
if( this.inherits ) {
|
||||
var cached = { };
|
||||
_.each( this.inherits, function(th, key) {
|
||||
var themesFolder = require.resolve('fresh-themes');
|
||||
var d = parsePath( themeFolder ).dirname;
|
||||
var themePath = PATH.join(d, th);
|
||||
if (this.inherits) {
|
||||
const cached = { };
|
||||
_.each(this.inherits, function(th, key) {
|
||||
// First, see if this is one of the predefined FRESH themes. There are
|
||||
// only a handful of these, but they may change over time, so we need to
|
||||
// query the official source of truth: the fresh-themes repository, which
|
||||
// mounts the themes conveniently by name to the module object, and which
|
||||
// is embedded locally inside the HackMyResume installation.
|
||||
// TODO: merge this code with
|
||||
let themePath;
|
||||
const themesObj = require('fresh-themes');
|
||||
if (_.has(themesObj.themes, th)) {
|
||||
themePath = PATH.join(
|
||||
parsePath( require.resolve('fresh-themes') ).dirname,
|
||||
'/themes/',
|
||||
th
|
||||
);
|
||||
} else {
|
||||
const d = parsePath( th ).dirname;
|
||||
themePath = PATH.join(d, th);
|
||||
}
|
||||
|
||||
cached[ th ] = cached[th] || new FRESHTheme().open( themePath );
|
||||
formatsHash[ key ] = cached[ th ].getFormat( key );
|
||||
return formatsHash[ key ] = cached[ th ].getFormat( key );
|
||||
});
|
||||
}
|
||||
|
||||
// Check for an explicit "formats" entry in the theme JSON. If it has one,
|
||||
// then this theme declares its files explicitly.
|
||||
if( !!this.formats ) {
|
||||
formatsHash = loadExplicit.call( this, formatsHash );
|
||||
this.explicit = true;
|
||||
}
|
||||
else {
|
||||
formatsHash = loadImplicit.call( this, formatsHash );
|
||||
}
|
||||
// Load theme files
|
||||
formatsHash = _load.call(this, formatsHash);
|
||||
|
||||
// Cache
|
||||
this.formats = formatsHash;
|
||||
|
||||
// Set the official theme name
|
||||
this.name = parsePath( this.folder ).name;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Determine if the theme supports the specified output format.
|
||||
*/
|
||||
FRESHTheme.prototype.hasFormat = function( fmt ) {
|
||||
return _.has( this.formats, fmt );
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Determine if the theme supports the specified output format.
|
||||
*/
|
||||
FRESHTheme.prototype.getFormat = function( fmt ) {
|
||||
return this.formats[ fmt ];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Load the theme implicitly, by scanning the theme folder for
|
||||
files. TODO: Refactor duplicated code with loadExplicit.
|
||||
*/
|
||||
function loadImplicit(formatsHash) {
|
||||
|
||||
// Set up a hash of formats supported by this theme.
|
||||
var that = this;
|
||||
var major = false;
|
||||
|
||||
// Establish the base theme folder
|
||||
var tplFolder = PATH.join( this.folder, 'src' );
|
||||
|
||||
// Iterate over all files in the theme folder, producing an array, fmts,
|
||||
// containing info for each file. While we're doing that, also build up
|
||||
// the formatsHash object.
|
||||
var fmts = READFILES(tplFolder).map( function(absPath) {
|
||||
|
||||
// If this file lives in a specific format folder within the theme,
|
||||
// such as "/latex" or "/html", then that format is the output format
|
||||
// for all files within the folder.
|
||||
var pathInfo = parsePath(absPath);
|
||||
var outFmt = '', isMajor = false;
|
||||
var portion = pathInfo.dirname.replace(tplFolder,'');
|
||||
if( portion && portion.trim() ) {
|
||||
if( portion[1] === '_' ) return;
|
||||
var reg = /^(?:\/|\\)(html|latex|doc|pdf|png|partials)(?:\/|\\)?/ig;
|
||||
var res = reg.exec( portion );
|
||||
if( res ) {
|
||||
if( res[1] !== 'partials' ) {
|
||||
outFmt = res[1];
|
||||
}
|
||||
else {
|
||||
that.partials = that.partials || [];
|
||||
that.partials.push( { name: pathInfo.name, path: absPath } );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, the output format is inferred from the filename, as in
|
||||
// compact-[outputformat].[extension], for ex, compact-pdf.html.
|
||||
if( !outFmt ) {
|
||||
var idx = pathInfo.name.lastIndexOf('-');
|
||||
outFmt = (idx === -1) ? pathInfo.name : pathInfo.name.substr(idx + 1);
|
||||
isMajor = true;
|
||||
}
|
||||
|
||||
// We should have a valid output format now.
|
||||
formatsHash[ outFmt ] = formatsHash[outFmt] || {
|
||||
outFormat: outFmt,
|
||||
files: []
|
||||
};
|
||||
|
||||
// Create the file representation object.
|
||||
var obj = {
|
||||
action: 'transform',
|
||||
path: absPath,
|
||||
major: isMajor,
|
||||
orgPath: PATH.relative(tplFolder, absPath),
|
||||
ext: pathInfo.extname.slice(1),
|
||||
title: friendlyName( outFmt ),
|
||||
pre: outFmt,
|
||||
// outFormat: outFmt || pathInfo.name,
|
||||
data: FS.readFileSync( absPath, 'utf8' ),
|
||||
css: null
|
||||
};
|
||||
|
||||
// Add this file to the list of files for this format type.
|
||||
formatsHash[ outFmt ].files.push( obj );
|
||||
return obj;
|
||||
});
|
||||
|
||||
// Now, get all the CSS files...
|
||||
(this.cssFiles = fmts.filter(function( fmt ){
|
||||
return fmt && (fmt.ext === 'css');
|
||||
}))
|
||||
|
||||
// For each CSS file, get its corresponding HTML file. It's possible that
|
||||
// a theme can have a CSS file but *no* HTML file, as when a theme author
|
||||
// creates a pure CSS override of an existing theme.
|
||||
.forEach(function( cssf ) {
|
||||
|
||||
var idx = _.findIndex(fmts, function( fmt ) {
|
||||
return fmt && fmt.pre === cssf.pre && fmt.ext === 'html';
|
||||
});
|
||||
cssf.major = false;
|
||||
if( idx > -1) {
|
||||
fmts[ idx ].css = cssf.data;
|
||||
fmts[ idx ].cssPath = cssf.path;
|
||||
}
|
||||
else {
|
||||
if( that.inherits ) {
|
||||
// Found a CSS file without an HTML file in a theme that inherits
|
||||
// from another theme. This is the override CSS file.
|
||||
that.overrides = { file: cssf.path, data: cssf.data };
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return formatsHash;
|
||||
}
|
||||
|
||||
/* Determine if the theme supports the specified output format. */
|
||||
hasFormat( fmt ) { return _.has(this.formats, fmt); }
|
||||
|
||||
/* Determine if the theme supports the specified output format. */
|
||||
getFormat( fmt ) { return this.formats[ fmt ]; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Load the theme explicitly, by following the 'formats' hash
|
||||
in the theme's JSON settings file.
|
||||
*/
|
||||
function loadExplicit(formatsHash) {
|
||||
|
||||
// Housekeeping
|
||||
var tplFolder = PATH.join( this.folder, 'src' );
|
||||
var act = null;
|
||||
var that = this;
|
||||
/* Load and parse theme source files. */
|
||||
var _load = function(formatsHash) {
|
||||
|
||||
// Iterate over all files in the theme folder, producing an array, fmts,
|
||||
// containing info for each file. While we're doing that, also build up
|
||||
// the formatsHash object.
|
||||
var fmts = READFILES( tplFolder ).map( function( absPath ) {
|
||||
const that = this;
|
||||
const tplFolder = PATH.join(this.folder, this.baseFolder);
|
||||
|
||||
act = null;
|
||||
// If this file is mentioned in the theme's JSON file under "transforms"
|
||||
var pathInfo = parsePath(absPath);
|
||||
var absPathSafe = absPath.trim().toLowerCase();
|
||||
var outFmt = _.find(
|
||||
Object.keys( that.formats ),
|
||||
function( fmtKey ) {
|
||||
var fmtVal = that.formats[ fmtKey ];
|
||||
return _.some( fmtVal.transform, function(fpath) {
|
||||
var absPathB = PATH.join( that.folder, fpath )
|
||||
.trim().toLowerCase();
|
||||
return absPathB === absPathSafe;
|
||||
});
|
||||
});
|
||||
if( outFmt ) {
|
||||
act = 'transform';
|
||||
}
|
||||
// Iterate over all files in the theme folder, producing an array, fmts,
|
||||
// containing info for each file. While we're doing that, also build up
|
||||
// the formatsHash object.
|
||||
const fmts = READFILES(tplFolder).map(function(absPath) {
|
||||
return _loadOne.call(this, absPath, formatsHash, tplFolder);
|
||||
}
|
||||
, this);
|
||||
|
||||
// If this file lives in a specific format folder within the theme,
|
||||
// such as "/latex" or "/html", then that format is the output format
|
||||
// for all files within the folder.
|
||||
if( !outFmt ) {
|
||||
var portion = pathInfo.dirname.replace(tplFolder,'');
|
||||
if( portion && portion.trim() ) {
|
||||
var reg = /^(?:\/|\\)(html|latex|doc|pdf)(?:\/|\\)?/ig;
|
||||
var res = reg.exec( portion );
|
||||
res && (outFmt = res[1]);
|
||||
}
|
||||
}
|
||||
// Now, get all the CSS files...
|
||||
this.cssFiles = fmts.filter(fmt => fmt && (fmt.ext === 'css'));
|
||||
|
||||
// Otherwise, the output format is inferred from the filename, as in
|
||||
// compact-[outputformat].[extension], for ex, compact-pdf.html.
|
||||
if( !outFmt ) {
|
||||
var idx = pathInfo.name.lastIndexOf('-');
|
||||
outFmt = (idx === -1) ? pathInfo.name : pathInfo.name.substr(idx + 1);
|
||||
}
|
||||
|
||||
// We should have a valid output format now.
|
||||
formatsHash[ outFmt ] =
|
||||
formatsHash[ outFmt ] || {
|
||||
outFormat: outFmt,
|
||||
files: [],
|
||||
symLinks: that.formats[ outFmt ].symLinks
|
||||
};
|
||||
|
||||
// Create the file representation object.
|
||||
var obj = {
|
||||
action: act,
|
||||
orgPath: PATH.relative(that.folder, absPath),
|
||||
path: absPath,
|
||||
ext: pathInfo.extname.slice(1),
|
||||
title: friendlyName( outFmt ),
|
||||
pre: outFmt,
|
||||
// outFormat: outFmt || pathInfo.name,
|
||||
data: FS.readFileSync( absPath, 'utf8' ),
|
||||
css: null
|
||||
};
|
||||
|
||||
// Add this file to the list of files for this format type.
|
||||
formatsHash[ outFmt ].files.push( obj );
|
||||
return obj;
|
||||
});
|
||||
|
||||
// Now, get all the CSS files...
|
||||
(this.cssFiles = fmts.filter(function( fmt ){
|
||||
return fmt.ext === 'css';
|
||||
}))
|
||||
|
||||
// For each CSS file, get its corresponding HTML file
|
||||
.forEach(function( cssf ) {
|
||||
// For each CSS file, get its corresponding HTML file
|
||||
var idx = _.findIndex(fmts, function( fmt ) {
|
||||
return fmt.pre === cssf.pre && fmt.ext === 'html';
|
||||
});
|
||||
// For each CSS file, get its corresponding HTML file. It's possible that
|
||||
// a theme can have a CSS file but *no* HTML file, as when a theme author
|
||||
// creates a pure CSS override of an existing theme.
|
||||
this.cssFiles.forEach(function(cssf) {
|
||||
const idx = _.findIndex(fmts, fmt => fmt && (fmt.pre === cssf.pre) && (fmt.ext === 'html'));
|
||||
cssf.major = false;
|
||||
if (idx > -1) {
|
||||
fmts[ idx ].css = cssf.data;
|
||||
fmts[ idx ].cssPath = cssf.path;
|
||||
});
|
||||
return fmts[ idx ].cssPath = cssf.path;
|
||||
} else {
|
||||
if (that.inherits) {
|
||||
// Found a CSS file without an HTML file in a theme that inherits
|
||||
// from another theme. This is the override CSS file.
|
||||
return that.overrides = { file: cssf.path, data: cssf.data };
|
||||
}
|
||||
}});
|
||||
|
||||
// Remove CSS files from the formats array
|
||||
fmts = fmts.filter( function( fmt) {
|
||||
return fmt.ext !== 'css';
|
||||
});
|
||||
// Now, save all the javascript file paths to a theme property.
|
||||
const jsFiles = fmts.filter(fmt => fmt && (fmt.ext === 'js'));
|
||||
this.jsFiles = jsFiles.map(jsf => jsf['path']);
|
||||
|
||||
return formatsHash;
|
||||
return formatsHash;
|
||||
};
|
||||
|
||||
|
||||
/* Load a single theme file. */
|
||||
var _loadOne = function( absPath, formatsHash, tplFolder ) {
|
||||
|
||||
const pathInfo = parsePath(absPath);
|
||||
if (pathInfo.basename.toLowerCase() === 'theme.json') { return; }
|
||||
|
||||
const absPathSafe = absPath.trim().toLowerCase();
|
||||
let outFmt = '';
|
||||
let act = 'copy';
|
||||
let isPrimary = false;
|
||||
|
||||
// If this is an "explicit" theme, all files of importance are specified in
|
||||
// the "transform" section of the theme.json file.
|
||||
if (this.explicit) {
|
||||
|
||||
outFmt = _.find(Object.keys( this.formats ), function( fmtKey ) {
|
||||
const fmtVal = this.formats[ fmtKey ];
|
||||
return _.some(fmtVal.transform, function(fpath) {
|
||||
const absPathB = PATH.join( this.folder, fpath ).trim().toLowerCase();
|
||||
return absPathB === absPathSafe;
|
||||
}
|
||||
, this);
|
||||
}
|
||||
, this);
|
||||
if (outFmt) { act = 'transform'; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Return a more friendly name for certain formats.
|
||||
TODO: Refactor
|
||||
*/
|
||||
function friendlyName( val ) {
|
||||
val = val.trim().toLowerCase();
|
||||
var friendly = { yml: 'yaml', md: 'markdown', txt: 'text' };
|
||||
return friendly[val] || val;
|
||||
if (!outFmt) {
|
||||
// If this file lives in a specific format folder within the theme,
|
||||
// such as "/latex" or "/html", then that format is the implicit output
|
||||
// format for all files within the folder
|
||||
const portion = pathInfo.dirname.replace(tplFolder,'');
|
||||
if (portion && portion.trim()) {
|
||||
if (portion[1] === '_') { return; }
|
||||
const reg = /^(?:\/|\\)(html|latex|doc|pdf|png|partials)(?:\/|\\)?/ig;
|
||||
const res = reg.exec( portion );
|
||||
if (res) {
|
||||
if (res[1] !== 'partials') {
|
||||
outFmt = res[1];
|
||||
if (!this.explicit) { act = 'transform'; }
|
||||
} else {
|
||||
this.partials = this.partials || [];
|
||||
this.partials.push( { name: pathInfo.name, path: absPath } );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, the output format is inferred from the filename, as in
|
||||
// compact-[outputformat].[extension], for ex, compact-pdf.html
|
||||
if (!outFmt) {
|
||||
const idx = pathInfo.name.lastIndexOf('-');
|
||||
outFmt = idx === -1 ? pathInfo.name : pathInfo.name.substr(idx+1);
|
||||
if (!this.explicit) { act = 'transform'; }
|
||||
const defFormats = require('./default-formats');
|
||||
isPrimary = _.some(defFormats, form => (form.name === outFmt) && (pathInfo.extname !== '.css'));
|
||||
}
|
||||
|
||||
// Make sure we have a valid formatsHash
|
||||
formatsHash[ outFmt ] = formatsHash[outFmt] || {
|
||||
outFormat: outFmt,
|
||||
files: []
|
||||
};
|
||||
|
||||
module.exports = FRESHTheme;
|
||||
// Move symlink descriptions from theme.json to the format
|
||||
if (__guard__(this.formats != null ? this.formats[outFmt ] : undefined, x => x.symLinks)) {
|
||||
formatsHash[ outFmt ].symLinks = this.formats[ outFmt ].symLinks;
|
||||
}
|
||||
|
||||
// Create the file representation object
|
||||
const obj = {
|
||||
action: act,
|
||||
primary: isPrimary,
|
||||
path: absPath,
|
||||
orgPath: PATH.relative(tplFolder, absPath),
|
||||
ext: pathInfo.extname.slice(1),
|
||||
title: friendlyName(outFmt),
|
||||
pre: outFmt,
|
||||
// outFormat: outFmt || pathInfo.name,
|
||||
data: FS.readFileSync(absPath, 'utf8'),
|
||||
css: null
|
||||
};
|
||||
|
||||
// Add this file to the list of files for this format type.
|
||||
formatsHash[ outFmt ].files.push( obj );
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
/* Return a more friendly name for certain formats. */
|
||||
var friendlyName = function( val ) {
|
||||
val = (val && val.trim().toLowerCase()) || '';
|
||||
const friendly = { yml: 'yaml', md: 'markdown', txt: 'text' };
|
||||
return friendly[val] || val;
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports = FRESHTheme;
|
||||
|
||||
function __guard__(value, transform) {
|
||||
return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined;
|
||||
}
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS206: Consider reworking classes to avoid initClass
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the JRSResume class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@ -6,56 +13,48 @@ Definition of the JRSResume class.
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const FS = require('fs');
|
||||
const extend = require('extend');
|
||||
let validator = require('is-my-json-valid');
|
||||
const _ = require('underscore');
|
||||
const PATH = require('path');
|
||||
const CONVERTER = require('fresh-jrs-converter');
|
||||
|
||||
|
||||
|
||||
var FS = require('fs')
|
||||
, extend = require('extend')
|
||||
, validator = require('is-my-json-valid')
|
||||
, _ = require('underscore')
|
||||
, PATH = require('path')
|
||||
, MD = require('marked')
|
||||
, CONVERTER = require('fresh-jrs-converter')
|
||||
, moment = require('moment');
|
||||
/**
|
||||
A JRS resume or CV. JRS resumes are backed by JSON, and each JRSResume object
|
||||
is an instantiation of that JSON decorated with utility methods.
|
||||
@class JRSResume
|
||||
*/
|
||||
|
||||
|
||||
class JRSResume {
|
||||
|
||||
/**
|
||||
A JRS resume or CV. JRS resumes are backed by JSON, and each JRSResume object
|
||||
is an instantiation of that JSON decorated with utility methods.
|
||||
@class JRSResume
|
||||
*/
|
||||
function JRSResume() {
|
||||
|
||||
static initClass() {
|
||||
/** Reset the sheet to an empty state. */
|
||||
// clear = function( clearMeta ) {
|
||||
// clearMeta = ((clearMeta === undefined) && true) || clearMeta;
|
||||
// if (clearMeta) { delete this.imp; }
|
||||
// delete this.basics.computed; // Don't use Object.keys() here
|
||||
// delete this.work;
|
||||
// delete this.volunteer;
|
||||
// delete this.education;
|
||||
// delete this.awards;
|
||||
// delete this.publications;
|
||||
// delete this.interests;
|
||||
// delete this.skills;
|
||||
// return delete this.basics.profiles;
|
||||
// };
|
||||
// extends AbstractResume
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the JSResume from file.
|
||||
*/
|
||||
JRSResume.prototype.open = function( file, title ) {
|
||||
//this.imp = { fileName: file }; <-- schema violation, tuck it into .basics
|
||||
this.basics = {
|
||||
imp: {
|
||||
file: file,
|
||||
raw: FS.readFileSync( file, 'utf8' )
|
||||
}
|
||||
};
|
||||
return this.parse( this.basics.imp.raw, title );
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the the JSResume from string.
|
||||
*/
|
||||
JRSResume.prototype.parse = function( stringData, opts ) {
|
||||
opts = opts || { };
|
||||
var rep = JSON.parse( stringData );
|
||||
return this.parseJSON( rep, opts );
|
||||
};
|
||||
/** Initialize the the JSResume from string. */
|
||||
parse( stringData, opts ) {
|
||||
this.imp = this.imp != null ? this.imp : {raw: stringData};
|
||||
return this.parseJSON(JSON.parse( stringData ), opts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -72,117 +71,87 @@ Definition of the JRSResume class.
|
||||
compute: Prepare computed resume totals.
|
||||
}
|
||||
*/
|
||||
JRSResume.prototype.parseJSON = function( rep, opts ) {
|
||||
parseJSON( rep, opts ) {
|
||||
let scrubbed;
|
||||
opts = opts || { };
|
||||
|
||||
// Ignore any element with the 'ignore: true' designator.
|
||||
var that = this, traverse = require('traverse'), ignoreList = [];
|
||||
var scrubbed = traverse( rep ).map( function( x ) {
|
||||
if( !this.isLeaf && this.node.ignore ) {
|
||||
if ( this.node.ignore === true || this.node.ignore === 'true' ) {
|
||||
ignoreList.push( this.node );
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (opts.privatize) {
|
||||
const scrubber = require('../utils/resume-scrubber');
|
||||
// Ignore any element with the 'ignore: true' or 'private: true' designator.
|
||||
var ret = scrubber.scrubResume(rep, opts);
|
||||
scrubbed = ret.scrubbed;
|
||||
}
|
||||
|
||||
// Extend resume properties onto ourself.
|
||||
extend( true, this, scrubbed );
|
||||
extend(true, this, opts.privatize ? scrubbed : rep);
|
||||
|
||||
// Set up metadata
|
||||
if( opts.imp === undefined || opts.imp ) {
|
||||
this.basics.imp = this.basics.imp || { };
|
||||
this.basics.imp.title =
|
||||
(opts.title || this.basics.imp.title) || this.basics.name;
|
||||
this.basics.imp.orgFormat = 'JRS';
|
||||
if (!(this.imp != null ? this.imp.processed : undefined)) {
|
||||
// Set up metadata TODO: Clean up metadata on the object model.
|
||||
opts = opts || { };
|
||||
if ((opts.imp === undefined) || opts.imp) {
|
||||
this.imp = this.imp || { };
|
||||
this.imp.title = (opts.title || this.imp.title) || this.basics.name;
|
||||
if (!this.imp.raw) {
|
||||
this.imp.raw = JSON.stringify(rep);
|
||||
}
|
||||
}
|
||||
this.imp.processed = true;
|
||||
}
|
||||
// Parse dates, sort dates, and calculate computed values
|
||||
(opts.date === undefined || opts.date) && _parseDates.call( this );
|
||||
(opts.sort === undefined || opts.sort) && this.sort();
|
||||
(opts.compute === undefined || opts.compute) && (this.basics.computed = {
|
||||
numYears: this.duration(),
|
||||
keywords: this.keywords()
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Save the sheet to disk (for environments that have disk access).
|
||||
*/
|
||||
JRSResume.prototype.save = function( filename ) {
|
||||
this.basics.imp.file = filename || this.basics.imp.file;
|
||||
FS.writeFileSync(this.basics.imp.file, this.stringify( this ), 'utf8');
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Save the sheet to disk in a specific format, either FRESH or JRS.
|
||||
*/
|
||||
JRSResume.prototype.saveAs = function( filename, format ) {
|
||||
|
||||
if( format === 'JRS' ) {
|
||||
this.basics.imp.file = filename || this.basics.imp.file;
|
||||
FS.writeFileSync( this.basics.imp.file, this.stringify(), 'utf8' );
|
||||
}
|
||||
else {
|
||||
var newRep = CONVERTER.toFRESH( this );
|
||||
var stringRep = CONVERTER.toSTRING( newRep );
|
||||
FS.writeFileSync( filename, stringRep, 'utf8' );
|
||||
((opts.date === undefined) || opts.date) && _parseDates.call( this );
|
||||
((opts.sort === undefined) || opts.sort) && this.sort();
|
||||
if ((opts.compute === undefined) || opts.compute) {
|
||||
this.basics.computed = {
|
||||
numYears: this.duration(),
|
||||
keywords: this.keywords()
|
||||
};
|
||||
}
|
||||
return this;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Return the resume format.
|
||||
*/
|
||||
JRSResume.prototype.format = function() {
|
||||
return 'JRS';
|
||||
};
|
||||
/** Save the sheet to disk (for environments that have disk access). */
|
||||
save( filename ) {
|
||||
this.imp.file = filename || this.imp.file;
|
||||
FS.writeFileSync(this.imp.file, this.stringify( this ), 'utf8');
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Convert this object to a JSON string, sanitizing meta-properties along the
|
||||
way. Don't override .toString().
|
||||
*/
|
||||
JRSResume.stringify = function( obj ) {
|
||||
function replacer( key,value ) { // Exclude these keys from stringification
|
||||
return _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
||||
'isModified', 'htmlPreview', 'display_progress_bar'],
|
||||
function( val ) { return key.trim() === val; }
|
||||
) ? undefined : value;
|
||||
/** Save the sheet to disk in a specific format, either FRESH or JRS. */
|
||||
saveAs( filename, format ) {
|
||||
if (format === 'JRS') {
|
||||
this.imp.file = filename || this.imp.file;
|
||||
FS.writeFileSync( this.imp.file, this.stringify(), 'utf8' );
|
||||
} else {
|
||||
const newRep = CONVERTER.toFRESH(this);
|
||||
const stringRep = CONVERTER.toSTRING(newRep);
|
||||
FS.writeFileSync(filename, stringRep, 'utf8');
|
||||
}
|
||||
return JSON.stringify( obj, replacer, 2 );
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
JRSResume.prototype.stringify = function() {
|
||||
return JRSResume.stringify( this );
|
||||
};
|
||||
/** Return the resume format. */
|
||||
format() { return 'JRS'; }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Return a unique list of all keywords across all skills.
|
||||
*/
|
||||
JRSResume.prototype.keywords = function() {
|
||||
var flatSkills = [];
|
||||
if( this.skills && this.skills.length ) {
|
||||
this.skills.forEach( function( s ) {
|
||||
flatSkills = _.union( flatSkills, s.keywords );
|
||||
});
|
||||
stringify() { return JRSResume.stringify( this ); }
|
||||
|
||||
|
||||
|
||||
/** Return a unique list of all keywords across all skills. */
|
||||
keywords() {
|
||||
let flatSkills = [];
|
||||
if (this.skills && this.skills.length) {
|
||||
this.skills.forEach( s => flatSkills = _.union(flatSkills, s.keywords));
|
||||
}
|
||||
return flatSkills;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -191,125 +160,66 @@ Definition of the JRSResume class.
|
||||
JSON Resume v0.0.0 doesn't allow additional properties at the root level,
|
||||
so tuck this into the .basic sub-object.
|
||||
*/
|
||||
JRSResume.prototype.i = function() {
|
||||
this.basics = this.basics || { };
|
||||
this.basics.imp = this.basics.imp || { };
|
||||
return this.basics.imp;
|
||||
};
|
||||
i() {
|
||||
return this.imp = this.imp != null ? this.imp : { };
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Reset the sheet to an empty state.
|
||||
*/
|
||||
JRSResume.prototype.clear = function( clearMeta ) {
|
||||
clearMeta = ((clearMeta === undefined) && true) || clearMeta;
|
||||
clearMeta && (delete this.imp);
|
||||
delete this.basics.computed; // Don't use Object.keys() here
|
||||
delete this.work;
|
||||
delete this.volunteer;
|
||||
delete this.education;
|
||||
delete this.awards;
|
||||
delete this.publications;
|
||||
delete this.interests;
|
||||
delete this.skills;
|
||||
delete this.basics.profiles;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Get the default (empty) sheet.
|
||||
*/
|
||||
JRSResume.default = function() {
|
||||
return new JRSResume().open(
|
||||
PATH.join( __dirname, 'empty-jrs.json'), 'Empty'
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Add work experience to the sheet.
|
||||
*/
|
||||
JRSResume.prototype.add = function( moniker ) {
|
||||
var defSheet = JRSResume.default();
|
||||
var newObject = $.extend( true, {}, defSheet[ moniker ][0] );
|
||||
/** Add work experience to the sheet. */
|
||||
add( moniker ) {
|
||||
const defSheet = JRSResume.default();
|
||||
const newObject = extend( true, {}, defSheet[ moniker ][0] );
|
||||
this[ moniker ] = this[ moniker ] || [];
|
||||
this[ moniker ].push( newObject );
|
||||
return newObject;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Determine if the sheet includes a specific social profile (eg, GitHub).
|
||||
*/
|
||||
JRSResume.prototype.hasProfile = function( socialNetwork ) {
|
||||
/** Determine if the sheet includes a specific social profile (eg, GitHub). */
|
||||
hasProfile( socialNetwork ) {
|
||||
socialNetwork = socialNetwork.trim().toLowerCase();
|
||||
return this.basics.profiles && _.some( this.basics.profiles, function(p) {
|
||||
return p.network.trim().toLowerCase() === socialNetwork;
|
||||
});
|
||||
};
|
||||
return this.basics.profiles && _.some(this.basics.profiles, p => p.network.trim().toLowerCase() === socialNetwork);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Determine if the sheet includes a specific skill.
|
||||
*/
|
||||
JRSResume.prototype.hasSkill = function( skill ) {
|
||||
/** Determine if the sheet includes a specific skill. */
|
||||
hasSkill( skill ) {
|
||||
skill = skill.trim().toLowerCase();
|
||||
return this.skills && _.some( this.skills, function(sk) {
|
||||
return sk.keywords && _.some( sk.keywords, function(kw) {
|
||||
return kw.trim().toLowerCase() === skill;
|
||||
});
|
||||
});
|
||||
};
|
||||
return this.skills && _.some(this.skills, sk =>
|
||||
sk.keywords && _.some(sk.keywords, kw => kw.trim().toLowerCase() === skill)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Validate the sheet against the JSON Resume schema.
|
||||
*/
|
||||
JRSResume.prototype.isValid = function( ) { // TODO: ↓ fix this path ↓
|
||||
var schema = FS.readFileSync( PATH.join( __dirname, 'resume.json' ),'utf8');
|
||||
var schemaObj = JSON.parse( schema );
|
||||
var validator = require('is-my-json-valid');
|
||||
var validate = validator( schemaObj, { // Note [1]
|
||||
/** Validate the sheet against the JSON Resume schema. */
|
||||
isValid( ) { // TODO: ↓ fix this path ↓
|
||||
const schema = FS.readFileSync(PATH.join( __dirname, 'resume.json' ), 'utf8');
|
||||
const schemaObj = JSON.parse(schema);
|
||||
validator = require('is-my-json-valid');
|
||||
const validate = validator( schemaObj, { // Note [1]
|
||||
formats: { date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/ }
|
||||
});
|
||||
var ret = validate( this );
|
||||
if( !ret ) {
|
||||
this.basics.imp = this.basics.imp || { };
|
||||
this.basics.imp.validationErrors = validate.errors;
|
||||
const temp = this.imp;
|
||||
delete this.imp;
|
||||
const ret = validate(this);
|
||||
this.imp = temp;
|
||||
if (!ret) {
|
||||
this.imp = this.imp || { };
|
||||
this.imp.validationErrors = validate.errors;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Calculate the total duration of the sheet. Assumes this.work has been sorted
|
||||
by start date descending, perhaps via a call to Sheet.sort().
|
||||
@returns The total duration of the sheet's work history, that is, the number
|
||||
of years between the start date of the earliest job on the resume and the
|
||||
*latest end date of all jobs in the work history*. This last condition is for
|
||||
sheets that have overlapping jobs.
|
||||
*/
|
||||
JRSResume.prototype.duration = function( unit ) {
|
||||
unit = unit || 'years';
|
||||
if( this.work && this.work.length ) {
|
||||
var careerStart = this.work[ this.work.length - 1].safeStartDate;
|
||||
if ((typeof careerStart === 'string' || careerStart instanceof String) &&
|
||||
!careerStart.trim())
|
||||
return 0;
|
||||
var careerLast = _.max( this.work, function( w ) {
|
||||
return w.safeEndDate.unix();
|
||||
}).safeEndDate;
|
||||
return careerLast.diff( careerStart, unit );
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
duration(unit) {
|
||||
const inspector = require('../inspectors/duration-inspector');
|
||||
return inspector.run(this, 'work', 'startDate', 'endDate', unit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -317,35 +227,38 @@ Definition of the JRSResume class.
|
||||
Sort dated things on the sheet by start date descending. Assumes that dates
|
||||
on the sheet have been processed with _parseDates().
|
||||
*/
|
||||
JRSResume.prototype.sort = function( ) {
|
||||
sort( ) {
|
||||
|
||||
this.work && this.work.sort( byDateDesc );
|
||||
this.education && this.education.sort( byDateDesc );
|
||||
this.volunteer && this.volunteer.sort( byDateDesc );
|
||||
const byDateDesc = function(a,b) {
|
||||
if (a.safeStartDate.isBefore(b.safeStartDate)) {
|
||||
return 1;
|
||||
} else { return ( a.safeStartDate.isAfter(b.safeStartDate) && -1 ) || 0; }
|
||||
};
|
||||
|
||||
this.awards && this.awards.sort( function(a, b) {
|
||||
return( a.safeDate.isBefore(b.safeDate) ) ? 1
|
||||
: ( a.safeDate.isAfter(b.safeDate) && -1 ) || 0;
|
||||
});
|
||||
this.publications && this.publications.sort( function(a, b) {
|
||||
return( a.safeReleaseDate.isBefore(b.safeReleaseDate) ) ? 1
|
||||
: ( a.safeReleaseDate.isAfter(b.safeReleaseDate) && -1 ) || 0;
|
||||
this.work && this.work.sort(byDateDesc);
|
||||
this.education && this.education.sort(byDateDesc);
|
||||
this.volunteer && this.volunteer.sort(byDateDesc);
|
||||
|
||||
this.awards && this.awards.sort(function(a, b) {
|
||||
if (a.safeDate.isBefore(b.safeDate)) {
|
||||
return 1;
|
||||
} else { return (a.safeDate.isAfter(b.safeDate) && -1 ) || 0; }
|
||||
});
|
||||
|
||||
function byDateDesc(a,b) {
|
||||
return( a.safeStartDate.isBefore(b.safeStartDate) ) ? 1
|
||||
: ( a.safeStartDate.isAfter(b.safeStartDate) && -1 ) || 0;
|
||||
}
|
||||
|
||||
};
|
||||
return this.publications && this.publications.sort(function(a, b) {
|
||||
if ( a.safeReleaseDate.isBefore(b.safeReleaseDate) ) {
|
||||
return 1;
|
||||
} else { return ( a.safeReleaseDate.isAfter(b.safeReleaseDate) && -1 ) || 0; }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
JRSResume.prototype.dupe = function() {
|
||||
var rnew = new JRSResume();
|
||||
rnew.parse( this.stringify(), { } );
|
||||
dupe() {
|
||||
const rnew = new JRSResume();
|
||||
rnew.parse(this.stringify(), { });
|
||||
return rnew;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -353,102 +266,83 @@ Definition of the JRSResume class.
|
||||
Create a copy of this resume in which all fields have been interpreted as
|
||||
Markdown.
|
||||
*/
|
||||
JRSResume.prototype.harden = function() {
|
||||
harden() {
|
||||
|
||||
var that = this;
|
||||
var ret = this.dupe();
|
||||
const ret = this.dupe();
|
||||
|
||||
function HD(txt) {
|
||||
return '@@@@~' + txt + '~@@@@';
|
||||
}
|
||||
const HD = txt => `@@@@~${txt}~@@@@`;
|
||||
|
||||
function HDIN(txt){
|
||||
//return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
||||
return HD(txt);
|
||||
}
|
||||
// const HDIN = txt =>
|
||||
// //return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
||||
// HD(txt)
|
||||
// ;
|
||||
|
||||
// TODO: refactor recursion
|
||||
function hardenStringsInObject( obj, inline ) {
|
||||
|
||||
if( !obj ) return;
|
||||
inline = inline === undefined || inline;
|
||||
|
||||
|
||||
if( Object.prototype.toString.call( obj ) === '[object Array]' ) {
|
||||
obj.forEach(function(elem, idx, ar){
|
||||
if( typeof elem === 'string' || elem instanceof String )
|
||||
ar[idx] = inline ? HDIN(elem) : HD( elem );
|
||||
else
|
||||
hardenStringsInObject( elem );
|
||||
});
|
||||
}
|
||||
else if (typeof obj === 'object') {
|
||||
Object.keys( obj ).forEach(function(key) {
|
||||
var sub = obj[key];
|
||||
if( typeof sub === 'string' || sub instanceof String ) {
|
||||
if( _.contains(['skills','url','website','startDate','endDate',
|
||||
'releaseDate','date','phone','email','address','postalCode',
|
||||
'city','country','region'], key) )
|
||||
return;
|
||||
if( key === 'summary' )
|
||||
obj[key] = HD( obj[key] );
|
||||
else
|
||||
obj[key] = inline ? HDIN( obj[key] ) : HD( obj[key] );
|
||||
}
|
||||
else
|
||||
hardenStringsInObject( sub );
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Object.keys( ret ).forEach(function(member){
|
||||
hardenStringsInObject( ret[ member ] );
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Convert human-friendly dates into formal Moment.js dates for all collections.
|
||||
We don't want to lose the raw textual date as entered by the user, so we store
|
||||
the Moment-ified date as a separate property with a prefix of .safe. For ex:
|
||||
job.startDate is the date as entered by the user. job.safeStartDate is the
|
||||
parsed Moment.js date that we actually use in processing.
|
||||
*/
|
||||
function _parseDates() {
|
||||
|
||||
var _fmt = require('./fluent-date').fmt;
|
||||
|
||||
this.work && this.work.forEach( function(job) {
|
||||
job.safeStartDate = _fmt( job.startDate );
|
||||
job.safeEndDate = _fmt( job.endDate );
|
||||
});
|
||||
this.education && this.education.forEach( function(edu) {
|
||||
edu.safeStartDate = _fmt( edu.startDate );
|
||||
edu.safeEndDate = _fmt( edu.endDate );
|
||||
});
|
||||
this.volunteer && this.volunteer.forEach( function(vol) {
|
||||
vol.safeStartDate = _fmt( vol.startDate );
|
||||
vol.safeEndDate = _fmt( vol.endDate );
|
||||
});
|
||||
this.awards && this.awards.forEach( function(awd) {
|
||||
awd.safeDate = _fmt( awd.date );
|
||||
});
|
||||
this.publications && this.publications.forEach( function(pub) {
|
||||
pub.safeReleaseDate = _fmt( pub.releaseDate );
|
||||
});
|
||||
const transformer = require('../utils/string-transformer');
|
||||
return transformer(ret,
|
||||
[ 'skills','url','website','startDate','endDate', 'releaseDate', 'date',
|
||||
'phone','email','address','postalCode','city','country','region',
|
||||
'safeStartDate','safeEndDate' ],
|
||||
(key, val) => HD(val));
|
||||
}
|
||||
}
|
||||
|
||||
JRSResume.initClass();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Export the JRSResume function/ctor.
|
||||
*/
|
||||
module.exports = JRSResume;
|
||||
|
||||
/** Get the default (empty) sheet. */
|
||||
JRSResume.default = () => new JRSResume().parseJSON(require('fresh-resume-starter').jrs);
|
||||
|
||||
|
||||
|
||||
}());
|
||||
/**
|
||||
Convert this object to a JSON string, sanitizing meta-properties along the
|
||||
way. Don't override .toString().
|
||||
*/
|
||||
JRSResume.stringify = function( obj ) {
|
||||
const replacer = function( key,value ) { // Exclude these keys from stringification
|
||||
const temp = _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
||||
'isModified', 'htmlPreview', 'display_progress_bar'],
|
||||
val => key.trim() === val);
|
||||
if (temp) { return undefined; } else { return value; }
|
||||
};
|
||||
return JSON.stringify(obj, replacer, 2);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Convert human-friendly dates into formal Moment.js dates for all collections.
|
||||
We don't want to lose the raw textual date as entered by the user, so we store
|
||||
the Moment-ified date as a separate property with a prefix of .safe. For ex:
|
||||
job.startDate is the date as entered by the user. job.safeStartDate is the
|
||||
parsed Moment.js date that we actually use in processing.
|
||||
*/
|
||||
var _parseDates = function() {
|
||||
|
||||
const _fmt = require('./fluent-date').fmt;
|
||||
|
||||
this.work && this.work.forEach(function(job) {
|
||||
job.safeStartDate = _fmt( job.startDate );
|
||||
return job.safeEndDate = _fmt( job.endDate );
|
||||
});
|
||||
this.education && this.education.forEach(function(edu) {
|
||||
edu.safeStartDate = _fmt( edu.startDate );
|
||||
return edu.safeEndDate = _fmt( edu.endDate );
|
||||
});
|
||||
this.volunteer && this.volunteer.forEach(function(vol) {
|
||||
vol.safeStartDate = _fmt( vol.startDate );
|
||||
return vol.safeEndDate = _fmt( vol.endDate );
|
||||
});
|
||||
this.awards && this.awards.forEach(awd => awd.safeDate = _fmt( awd.date ));
|
||||
return this.publications && this.publications.forEach(pub => pub.safeReleaseDate = _fmt( pub.releaseDate ));
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Export the JRSResume class.
|
||||
*/
|
||||
module.exports = JRSResume;
|
||||
|
@ -1,49 +1,45 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the JRSTheme class.
|
||||
@module jrs-theme.js
|
||||
@module core/jrs-theme
|
||||
@license MIT. See LICENSE.MD for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
const _ = require('underscore');
|
||||
const PATH = require('path');
|
||||
const pathExists = require('path-exists').sync;
|
||||
const errors = require('./status-codes');
|
||||
|
||||
|
||||
|
||||
var _ = require('underscore')
|
||||
, PATH = require('path')
|
||||
, parsePath = require('parse-filepath')
|
||||
, pathExists = require('path-exists').sync;
|
||||
/**
|
||||
The JRSTheme class is a representation of a JSON Resume theme asset.
|
||||
@class JRSTheme
|
||||
*/
|
||||
class JRSTheme {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The JRSTheme class is a representation of a JSON Resume theme asset.
|
||||
@class JRSTheme
|
||||
*/
|
||||
function JRSTheme() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Open and parse the specified theme.
|
||||
Open and parse the specified JRS theme.
|
||||
@method open
|
||||
*/
|
||||
JRSTheme.prototype.open = function( thFolder ) {
|
||||
open( thFolder ) {
|
||||
|
||||
this.folder = thFolder;
|
||||
//const pathInfo = parsePath(thFolder);
|
||||
|
||||
// Open the [theme-name].json file; should have the same
|
||||
// name as folder
|
||||
var pathInfo = parsePath( thFolder );
|
||||
|
||||
// Open and parse the theme's package.json file.
|
||||
var pkgJsonPath = PATH.join( thFolder, 'package.json' );
|
||||
if( pathExists( pkgJsonPath )) {
|
||||
|
||||
var thApi = require( thFolder )
|
||||
, thPkg = require( pkgJsonPath );
|
||||
|
||||
// Open and parse the theme's package.json file
|
||||
const pkgJsonPath = PATH.join(thFolder, 'package.json');
|
||||
if (pathExists(pkgJsonPath)) {
|
||||
const thApi = require(thFolder); // Requiring the folder yields whatever the package.json's "main" is set to
|
||||
const thPkg = require(pkgJsonPath); // Get the package.json as JSON
|
||||
this.name = thPkg.name;
|
||||
this.render = (thApi && thApi.render) || undefined;
|
||||
this.engine = 'jrs';
|
||||
@ -52,32 +48,32 @@ Definition of the JRSTheme class.
|
||||
// properties necessary to allow JSON Resume themes to share a rendering
|
||||
// path with FRESH themes.
|
||||
this.formats = {
|
||||
html: { outFormat: 'html', files: [
|
||||
{
|
||||
html: {
|
||||
outFormat: 'html',
|
||||
files: [{
|
||||
action: 'transform',
|
||||
render: this.render,
|
||||
major: true,
|
||||
primary: true,
|
||||
ext: 'html',
|
||||
css: null
|
||||
}
|
||||
]},
|
||||
pdf: { outFormat: 'pdf', files: [
|
||||
{
|
||||
}]
|
||||
},
|
||||
pdf: {
|
||||
outFormat: 'pdf',
|
||||
files: [{
|
||||
action: 'transform',
|
||||
render: this.render,
|
||||
major: true,
|
||||
primary: true,
|
||||
ext: 'pdf',
|
||||
css: null
|
||||
}
|
||||
]}
|
||||
}]
|
||||
}
|
||||
};
|
||||
} else {
|
||||
throw {fluenterror: errors.missingPackageJSON};
|
||||
}
|
||||
else {
|
||||
throw { fluenterror: HACKMYSTATUS.missingPackageJSON };
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -85,9 +81,7 @@ Definition of the JRSTheme class.
|
||||
Determine if the theme supports the output format.
|
||||
@method hasFormat
|
||||
*/
|
||||
JRSTheme.prototype.hasFormat = function( fmt ) {
|
||||
return _.has( this.formats, fmt );
|
||||
};
|
||||
hasFormat( fmt ) { return _.has(this.formats, fmt); }
|
||||
|
||||
|
||||
|
||||
@ -95,14 +89,8 @@ Definition of the JRSTheme class.
|
||||
Return the requested output format.
|
||||
@method getFormat
|
||||
*/
|
||||
JRSTheme.prototype.getFormat = function( fmt ) {
|
||||
return this.formats[ fmt ];
|
||||
};
|
||||
getFormat( fmt ) { return this.formats[ fmt ]; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
module.exports = JRSTheme;
|
||||
|
||||
|
||||
|
||||
}());
|
||||
module.exports = JRSTheme;
|
||||
|
@ -1,138 +1,127 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the ResumeFactory class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module resume-factory.js
|
||||
@module core/resume-factory
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function(){
|
||||
const FS = require('fs');
|
||||
const HMS = require('./status-codes');
|
||||
const HME = require('./event-codes');
|
||||
const ResumeConverter = require('fresh-jrs-converter');
|
||||
const resumeDetect = require('../utils/resume-detector');
|
||||
require('string.prototype.startswith');
|
||||
|
||||
|
||||
|
||||
var FS = require('fs'),
|
||||
HACKMYSTATUS = require('./status-codes'),
|
||||
HME = require('./event-codes'),
|
||||
ResumeConverter = require('fresh-jrs-converter'),
|
||||
chalk = require('chalk'),
|
||||
SyntaxErrorEx = require('../utils/syntax-error-ex'),
|
||||
_ = require('underscore');
|
||||
require('string.prototype.startswith');
|
||||
/**
|
||||
A simple factory class for FRESH and JSON Resumes.
|
||||
@class ResumeFactory
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
A simple factory class for FRESH and JSON Resumes.
|
||||
@class ResumeFactory
|
||||
*/
|
||||
var ResumeFactory = module.exports = {
|
||||
Load one or more resumes from disk.
|
||||
|
||||
@param {Object} opts An options object with settings for the factory as well
|
||||
as passthrough settings for FRESHResume or JRSResume. Structure:
|
||||
|
||||
|
||||
/**
|
||||
Load one or more resumes from disk.
|
||||
|
||||
@param {Object} opts An options object with settings for the factory as well
|
||||
as passthrough settings for FRESHResume or JRSResume. Structure:
|
||||
|
||||
{
|
||||
format: 'FRESH', // Format to open as. ('FRESH', 'JRS', null)
|
||||
objectify: true, // FRESH/JRSResume or raw JSON?
|
||||
inner: { // Passthru options for FRESH/JRSResume
|
||||
sort: false
|
||||
}
|
||||
{
|
||||
format: 'FRESH', // Format to open as. ('FRESH', 'JRS', null)
|
||||
objectify: true, // FRESH/JRSResume or raw JSON?
|
||||
inner: { // Passthru options for FRESH/JRSResume
|
||||
sort: false
|
||||
}
|
||||
|
||||
*/
|
||||
load: function ( sources, opts, emitter ) {
|
||||
|
||||
return sources.map( function( src ) {
|
||||
return this.loadOne( src, opts, emitter );
|
||||
}, this);
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Load a single resume from disk.
|
||||
*/
|
||||
loadOne: function( src, opts, emitter ) {
|
||||
|
||||
var toFormat = opts.format; // Can be null
|
||||
var objectify = opts.objectify;
|
||||
|
||||
// Get the destination format. Can be 'fresh', 'jrs', or null/undefined.
|
||||
toFormat && (toFormat = toFormat.toLowerCase().trim());
|
||||
|
||||
// Load and parse the resume JSON
|
||||
var info = _parse( src, opts, emitter );
|
||||
if( info.fluenterror ) return info;
|
||||
|
||||
// Determine the resume format: FRESH or JRS
|
||||
var json = info.json;
|
||||
var orgFormat = ( json.meta && json.meta.format &&
|
||||
json.meta.format.startsWith('FRESH@') ) ?
|
||||
'fresh' : 'jrs';
|
||||
|
||||
// Convert between formats if necessary
|
||||
if( toFormat && (orgFormat !== toFormat) ) {
|
||||
json = ResumeConverter[ 'to' + toFormat.toUpperCase() ]( json );
|
||||
}
|
||||
|
||||
// Objectify the resume, that is, convert it from JSON to a FRESHResume
|
||||
// or JRSResume object.
|
||||
var rez;
|
||||
if( objectify ) {
|
||||
var ResumeClass = require('../core/' + (toFormat || orgFormat) + '-resume');
|
||||
rez = new ResumeClass().parseJSON( json, opts.inner );
|
||||
rez.i().file = src;
|
||||
}
|
||||
|
||||
return {
|
||||
file: src,
|
||||
json: info.json,
|
||||
rez: rez
|
||||
};
|
||||
*/
|
||||
load( sources, opts, emitter ) {
|
||||
return sources.map( function(src) {
|
||||
return this.loadOne( src, opts, emitter );
|
||||
}
|
||||
};
|
||||
, this);
|
||||
},
|
||||
|
||||
|
||||
/** Load a single resume from disk. */
|
||||
loadOne( src, opts, emitter ) {
|
||||
|
||||
function _parse( fileName, opts, eve ) {
|
||||
let toFormat = opts.format; // Can be null
|
||||
|
||||
var rawData;
|
||||
try {
|
||||
// Get the destination format. Can be 'fresh', 'jrs', or null/undefined.
|
||||
toFormat && (toFormat = toFormat.toLowerCase().trim());
|
||||
|
||||
// Read the file
|
||||
eve && eve.stat( HME.beforeRead, { file: fileName });
|
||||
rawData = FS.readFileSync( fileName, 'utf8' );
|
||||
eve && eve.stat( HME.afterRead, { file: fileName, data: rawData });
|
||||
// Load and parse the resume JSON
|
||||
const info = _parse(src, opts, emitter);
|
||||
if (info.fluenterror) { return info; }
|
||||
|
||||
// Parse the file
|
||||
eve && eve.stat( HME.beforeParse, { data: rawData });
|
||||
var ret = { json: JSON.parse( rawData ) };
|
||||
var orgFormat = ( ret.json.meta && ret.json.meta.format &&
|
||||
ret.json.meta.format.startsWith('FRESH@') ) ?
|
||||
'fresh' : 'jrs';
|
||||
eve && eve.stat( HME.afterParse, { file: fileName, data: ret.json, fmt: orgFormat } );
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch( e ) {
|
||||
// Can be ENOENT, EACCES, SyntaxError, etc.
|
||||
var ex = {
|
||||
fluenterror: rawData ? HACKMYSTATUS.parseError : HACKMYSTATUS.readError,
|
||||
inner: e, raw: rawData, file: fileName, shouldExit: false
|
||||
};
|
||||
opts.quit && (ex.quit = true);
|
||||
eve && eve.err( ex.fluenterror, ex );
|
||||
if( opts.throw ) throw ex;
|
||||
return ex;
|
||||
// Determine the resume format: FRESH or JRS
|
||||
let { json } = info;
|
||||
const orgFormat = resumeDetect(json);
|
||||
if (orgFormat === 'unk') {
|
||||
info.fluenterror = HMS.unknownSchema;
|
||||
return info;
|
||||
}
|
||||
|
||||
// Convert between formats if necessary
|
||||
if (toFormat && ( orgFormat !== toFormat )) {
|
||||
json = ResumeConverter[ `to${toFormat.toUpperCase()}` ](json);
|
||||
}
|
||||
|
||||
// Objectify the resume, that is, convert it from JSON to a FRESHResume
|
||||
// or JRSResume object.
|
||||
let rez = null;
|
||||
if (opts.objectify) {
|
||||
const reqLib = `../core/${toFormat || orgFormat}-resume`;
|
||||
const ResumeClass = require(reqLib);
|
||||
rez = new ResumeClass().parseJSON( json, opts.inner );
|
||||
rez.i().file = src;
|
||||
}
|
||||
|
||||
return {
|
||||
file: src,
|
||||
json: info.json,
|
||||
rez
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var _parse = function( fileName, opts, eve ) {
|
||||
|
||||
}());
|
||||
let rawData = null;
|
||||
try {
|
||||
|
||||
// Read the file
|
||||
eve && eve.stat( HME.beforeRead, { file: fileName });
|
||||
rawData = FS.readFileSync( fileName, 'utf8' );
|
||||
eve && eve.stat( HME.afterRead, { file: fileName, data: rawData });
|
||||
|
||||
// Parse the file
|
||||
eve && eve.stat(HME.beforeParse, { data: rawData });
|
||||
const ret = { json: JSON.parse( rawData ) };
|
||||
const orgFormat =
|
||||
ret.json.meta && ret.json.meta.format && ret.json.meta.format.startsWith('FRESH@')
|
||||
? 'fresh' : 'jrs';
|
||||
|
||||
eve && eve.stat(HME.afterParse, { file: fileName, data: ret.json, fmt: orgFormat });
|
||||
return ret;
|
||||
} catch (err) {
|
||||
// Can be ENOENT, EACCES, SyntaxError, etc.
|
||||
return {
|
||||
fluenterror: rawData ? HMS.parseError : HMS.readError,
|
||||
inner: err,
|
||||
raw: rawData,
|
||||
file: fileName
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -1,37 +1,41 @@
|
||||
/**
|
||||
Status codes for HackMyResume.
|
||||
@module status-codes.js
|
||||
@module core/status-codes
|
||||
@license MIT. See LICENSE.MD for details.
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
module.exports = {
|
||||
success: 0,
|
||||
themeNotFound: 1,
|
||||
copyCss: 2,
|
||||
resumeNotFound: 3,
|
||||
missingCommand: 4,
|
||||
invalidCommand: 5,
|
||||
resumeNotFoundAlt: 6,
|
||||
inputOutputParity: 7,
|
||||
createNameMissing: 8,
|
||||
pdfgeneration: 9,
|
||||
missingPackageJSON: 10,
|
||||
invalid: 11,
|
||||
invalidFormat: 12,
|
||||
notOnPath: 13,
|
||||
readError: 14,
|
||||
parseError: 15,
|
||||
fileSaveError: 16,
|
||||
generateError: 17,
|
||||
invalidHelperUse: 18,
|
||||
mixedMerge: 19,
|
||||
invokeTemplate: 20,
|
||||
compileTemplate: 21,
|
||||
themeLoad: 22,
|
||||
invalidParamCount: 23,
|
||||
missingParam: 24
|
||||
};
|
||||
|
||||
}());
|
||||
module.exports = {
|
||||
success: 0,
|
||||
themeNotFound: 1,
|
||||
copyCss: 2,
|
||||
resumeNotFound: 3,
|
||||
missingCommand: 4,
|
||||
invalidCommand: 5,
|
||||
resumeNotFoundAlt: 6,
|
||||
inputOutputParity: 7,
|
||||
createNameMissing: 8,
|
||||
pdfGeneration: 9,
|
||||
missingPackageJSON: 10,
|
||||
invalid: 11,
|
||||
invalidFormat: 12,
|
||||
notOnPath: 13,
|
||||
readError: 14,
|
||||
parseError: 15,
|
||||
fileSaveError: 16,
|
||||
generateError: 17,
|
||||
invalidHelperUse: 18,
|
||||
mixedMerge: 19,
|
||||
invokeTemplate: 20,
|
||||
compileTemplate: 21,
|
||||
themeLoad: 22,
|
||||
invalidParamCount: 23,
|
||||
missingParam: 24,
|
||||
createError: 25,
|
||||
validateError: 26,
|
||||
invalidOptionsFile: 27,
|
||||
optionsFileNotFound: 28,
|
||||
unknownSchema: 29,
|
||||
themeHelperLoad: 30,
|
||||
invalidSchemaVersion: 31
|
||||
};
|
||||
|
@ -1,39 +1,37 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS206: Consider reworking classes to avoid initClass
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the BaseGenerator class.
|
||||
@module base-generator.js
|
||||
@module generators/base-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
// Use J. Resig's nifty class implementation
|
||||
var Class = require( '../utils/class' );
|
||||
|
||||
/**
|
||||
The BaseGenerator class is the root of the generator hierarchy. Functionality
|
||||
common to ALL generators lives here.
|
||||
*/
|
||||
|
||||
var BaseGenerator = module.exports = Class.extend({
|
||||
|
||||
/**
|
||||
Base-class initialize.
|
||||
*/
|
||||
init: function( outputFormat ) {
|
||||
this.format = outputFormat;
|
||||
},
|
||||
|
||||
/**
|
||||
Status codes.
|
||||
*/
|
||||
codes: require('../core/status-codes'),
|
||||
|
||||
/**
|
||||
Generator options.
|
||||
*/
|
||||
opts: {
|
||||
/**
|
||||
The BaseGenerator class is the root of the generator hierarchy. Functionality
|
||||
common to ALL generators lives here.
|
||||
*/
|
||||
|
||||
let BaseGenerator;
|
||||
module.exports = (BaseGenerator = (function() {
|
||||
BaseGenerator = class BaseGenerator {
|
||||
static initClass() {
|
||||
|
||||
/** Status codes. */
|
||||
this.prototype.codes = require('../core/status-codes');
|
||||
|
||||
/** Generator options. */
|
||||
this.prototype.opts = { };
|
||||
}
|
||||
|
||||
});
|
||||
}());
|
||||
/** Base-class initialize. */
|
||||
constructor( format ) {
|
||||
this.format = format;
|
||||
}
|
||||
};
|
||||
BaseGenerator.initClass();
|
||||
return BaseGenerator;
|
||||
})());
|
||||
|
@ -1,34 +1,39 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the HTMLGenerator class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module html-generator.js
|
||||
@module generators/html-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var TemplateGenerator = require('./template-generator')
|
||||
, FS = require('fs-extra')
|
||||
, HTML = require( 'html' )
|
||||
, PATH = require('path');
|
||||
require('string.prototype.endswith');
|
||||
|
||||
var HtmlGenerator = module.exports = TemplateGenerator.extend({
|
||||
const TemplateGenerator = require('./template-generator');
|
||||
const HTML = require('html');
|
||||
require('string.prototype.endswith');
|
||||
|
||||
init: function() {
|
||||
this._super( 'html' );
|
||||
},
|
||||
|
||||
/**
|
||||
Copy satellite CSS files to the destination and optionally pretty-print
|
||||
the HTML resume prior to saving.
|
||||
*/
|
||||
onBeforeSave: function( info ) {
|
||||
if( info.outputFile.endsWith('.css') )
|
||||
return info.mk;
|
||||
return this.opts.prettify ?
|
||||
HTML.prettyPrint( info.mk, this.opts.prettify ) : info.mk;
|
||||
|
||||
class HtmlGenerator extends TemplateGenerator {
|
||||
|
||||
constructor() { super('html'); }
|
||||
|
||||
/**
|
||||
Copy satellite CSS files to the destination and optionally pretty-print
|
||||
the HTML resume prior to saving.
|
||||
*/
|
||||
onBeforeSave( info ) {
|
||||
if (info.outputFile.endsWith('.css')) {
|
||||
return info.mk;
|
||||
}
|
||||
if (this.opts.prettify) {
|
||||
return HTML.prettyPrint(info.mk, this.opts.prettify);
|
||||
} else { return info.mk; }
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
module.exports = HtmlGenerator;
|
||||
|
@ -1,113 +1,129 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS103: Rewrite code to no longer use __guard__
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the HtmlPdfCLIGenerator class.
|
||||
@module html-pdf-generator.js
|
||||
@module generators/html-pdf-generator.js
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const TemplateGenerator = require('./template-generator');
|
||||
const FS = require('fs-extra');
|
||||
const PATH = require('path');
|
||||
const SLASH = require('slash');
|
||||
const _ = require('underscore');
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const SPAWN = require('../utils/safe-spawn');
|
||||
|
||||
|
||||
/**
|
||||
An HTML-driven PDF resume generator for HackMyResume. Talks to Phantom,
|
||||
wkhtmltopdf, and other PDF engines over a CLI (command-line interface).
|
||||
If an engine isn't installed for a particular platform, error out gracefully.
|
||||
*/
|
||||
|
||||
class HtmlPdfCLIGenerator extends TemplateGenerator {
|
||||
|
||||
|
||||
|
||||
var TemplateGenerator = require('./template-generator')
|
||||
, FS = require('fs-extra')
|
||||
, HTML = require( 'html' )
|
||||
, PATH = require('path')
|
||||
, SPAWN = require('../utils/safe-spawn')
|
||||
, SLASH = require('slash');
|
||||
constructor() { super('pdf', 'html'); }
|
||||
|
||||
|
||||
|
||||
/** Generate the binary PDF. */
|
||||
onBeforeSave( info ) {
|
||||
//console.dir _.omit( info, 'mk' ), depth: null, colors: true
|
||||
if ((info.ext !== 'html') && (info.ext !== 'pdf')) { return info.mk; }
|
||||
let safe_eng = info.opts.pdf || 'wkhtmltopdf';
|
||||
if (safe_eng === 'phantom') { safe_eng = 'phantomjs'; }
|
||||
if (_.has(engines, safe_eng)) {
|
||||
this.errHandler = info.opts.errHandler;
|
||||
engines[ safe_eng ].call(this, info.mk, info.outputFile, info.opts, this.onError);
|
||||
return null; // halt further processing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 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(ex, param) {
|
||||
__guardMethod__(param.errHandler, 'err', o => o.err(HMSTATUS.pdfGeneration, ex));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HtmlPdfCLIGenerator;
|
||||
|
||||
// TODO: Move each engine to a separate module
|
||||
var engines = {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
An HTML-driven PDF resume generator for HackMyResume. Talks to Phantom,
|
||||
wkhtmltopdf, and other PDF engines over a CLI (command-line interface).
|
||||
If an engine isn't installed for a particular platform, error out gracefully.
|
||||
Generate a PDF from HTML using wkhtmltopdf's CLI interface.
|
||||
Spawns a child process with `wkhtmltopdf <source> <target>`. wkhtmltopdf
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease wkhtmltopdf rendering
|
||||
*/
|
||||
var HtmlPdfCLIGenerator = module.exports = TemplateGenerator.extend({
|
||||
wkhtmltopdf(markup, fOut, opts, on_error) {
|
||||
// Save the markup to a temporary file
|
||||
const tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
|
||||
// Prepare wkhtmltopdf arguments.
|
||||
let wkopts = _.extend({'margin-top': '10mm', 'margin-bottom': '10mm'}, opts.wkhtmltopdf);
|
||||
wkopts = _.flatten(_.map(wkopts, (v, k) => [`--${k}`, v]));
|
||||
const wkargs = wkopts.concat([ tempFile, fOut ]);
|
||||
|
||||
SPAWN('wkhtmltopdf', wkargs , false, on_error, this);
|
||||
},
|
||||
|
||||
|
||||
|
||||
init: function() {
|
||||
this._super( 'pdf', 'html' );
|
||||
},
|
||||
/**
|
||||
Generate a PDF from HTML using Phantom's CLI interface.
|
||||
Spawns a child process with `phantomjs <script> <source> <target>`. Phantom
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease Phantom rendering
|
||||
*/
|
||||
phantomjs( markup, fOut, opts, on_error ) {
|
||||
// Save the markup to a temporary file
|
||||
const tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
let scriptPath = PATH.relative(process.cwd(), PATH.resolve( __dirname, '../utils/rasterize.js' ));
|
||||
scriptPath = SLASH(scriptPath);
|
||||
const sourcePath = SLASH(PATH.relative( process.cwd(), tempFile));
|
||||
const destPath = SLASH(PATH.relative( process.cwd(), fOut));
|
||||
SPAWN('phantomjs', [ scriptPath, sourcePath, destPath ], false, on_error, this);
|
||||
},
|
||||
|
||||
/**
|
||||
Generate a PDF from HTML using WeasyPrint's CLI interface.
|
||||
Spawns a child process with `weasyprint <source> <target>`. Weasy Print
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
*/
|
||||
weasyprint( markup, fOut, opts, on_error ) {
|
||||
// Save the markup to a temporary file
|
||||
const tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
|
||||
SPAWN('weasyprint', [tempFile, fOut], false, on_error, this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
Generate the binary PDF.
|
||||
*/
|
||||
onBeforeSave: function( info ) {
|
||||
|
||||
try {
|
||||
var safe_eng = info.opts.pdf || 'wkhtmltopdf';
|
||||
if( safe_eng !== 'none' )
|
||||
engines[ safe_eng ].call( this, info.mk, info.outputFile );
|
||||
return null; // halt further processing
|
||||
}
|
||||
catch(ex) {
|
||||
// { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', ... }
|
||||
// { [Error: ENOENT] }
|
||||
throw ( ex.inner && ex.inner.code === 'ENOENT' ) ?
|
||||
{ fluenterror: this.codes.notOnPath, inner: ex.inner, engine: ex.cmd,
|
||||
stack: ex.inner && ex.inner.stack } :
|
||||
{ fluenterror: this.codes.pdfGeneration, inner: ex, stack: ex.stack };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
// TODO: Move each engine to a separate module
|
||||
var engines = {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Generate a PDF from HTML using wkhtmltopdf's CLI interface.
|
||||
Spawns a child process with `wkhtmltopdf <source> <target>`. wkhtmltopdf
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease wkhtmltopdf rendering
|
||||
*/
|
||||
wkhtmltopdf: function(markup, fOut) {
|
||||
|
||||
// Save the markup to a temporary file
|
||||
var tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync( tempFile, markup, 'utf8' );
|
||||
var info = SPAWN( 'wkhtmltopdf', [ tempFile, fOut ] );
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Generate a PDF from HTML using Phantom's CLI interface.
|
||||
Spawns a child process with `phantomjs <script> <source> <target>`. Phantom
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease Phantom rendering
|
||||
*/
|
||||
phantom: function( markup, fOut ) {
|
||||
|
||||
// Save the markup to a temporary file
|
||||
var tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync( tempFile, markup, 'utf8' );
|
||||
var scriptPath = SLASH( PATH.relative( process.cwd(),
|
||||
PATH.resolve( __dirname, '../utils/rasterize.js' ) ) );
|
||||
var sourcePath = SLASH( PATH.relative( process.cwd(), tempFile) );
|
||||
var destPath = SLASH( PATH.relative( process.cwd(), fOut) );
|
||||
var info = SPAWN('phantomjs', [ scriptPath, sourcePath, destPath ]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
function __guardMethod__(obj, methodName, transform) {
|
||||
if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') {
|
||||
return transform(obj, methodName);
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
@ -1,66 +1,58 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the HtmlPngGenerator class.
|
||||
@module generators/html-png-generator
|
||||
@license MIT. See LICENSE.MD for details.
|
||||
@module html-png-generator.js
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const TemplateGenerator = require('./template-generator');
|
||||
const FS = require('fs-extra');
|
||||
const SLASH = require('slash');
|
||||
const SPAWN = require('../utils/safe-spawn');
|
||||
const PATH = require('path');
|
||||
|
||||
|
||||
/**
|
||||
An HTML-based PNG resume generator for HackMyResume.
|
||||
*/
|
||||
class HtmlPngGenerator extends TemplateGenerator {
|
||||
|
||||
var TemplateGenerator = require('./template-generator')
|
||||
, FS = require('fs-extra')
|
||||
, HTML = require( 'html' );
|
||||
constructor() { super('png', 'html'); }
|
||||
|
||||
invoke( /*rez, themeMarkup, cssInfo, opts*/ ) {}
|
||||
// TODO: Not currently called or callable.
|
||||
|
||||
|
||||
/**
|
||||
An HTML-based PNG resume generator for HackMyResume.
|
||||
*/
|
||||
var HtmlPngGenerator = module.exports = TemplateGenerator.extend({
|
||||
|
||||
|
||||
|
||||
init: function() {
|
||||
this._super( 'png', 'html' );
|
||||
},
|
||||
|
||||
|
||||
|
||||
invoke: function( rez, themeMarkup, cssInfo, opts ) {
|
||||
// TODO: Not currently called or callable.
|
||||
},
|
||||
|
||||
|
||||
|
||||
generate: function( rez, f, opts ) {
|
||||
var htmlResults = opts.targets.filter(function(t){
|
||||
return t.fmt.outFormat === 'html';
|
||||
});
|
||||
var htmlFile = htmlResults[0].final.files.filter(function(fl){
|
||||
return fl.info.ext === 'html';
|
||||
});
|
||||
png( htmlFile[0].data, f );
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Generate a PNG from HTML.
|
||||
*/
|
||||
function png( markup, fOut ) {
|
||||
// TODO: Which Webshot syntax?
|
||||
// require('webshot')( markup , { encoding: 'binary', siteType: 'html' } )
|
||||
// .pipe( FS.createWriteStream( fOut ) );
|
||||
require('webshot')( markup , fOut, { siteType: 'html' }, function(err) { } );
|
||||
generate( rez, f, opts ) {
|
||||
const htmlResults = opts.targets.filter(t => t.fmt.outFormat === 'html');
|
||||
const htmlFile = htmlResults[0].final.files.filter(fl => fl.info.ext === 'html');
|
||||
phantom(htmlFile[0].data, f);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = HtmlPngGenerator;
|
||||
|
||||
/**
|
||||
Generate a PDF from HTML using Phantom's CLI interface.
|
||||
Spawns a child process with `phantomjs <script> <source> <target>`. Phantom
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease Phantom rendering
|
||||
*/
|
||||
|
||||
}());
|
||||
var phantom = function( markup, fOut ) {
|
||||
|
||||
// Save the markup to a temporary file
|
||||
const tempFile = fOut.replace(/\.png$/i, '.png.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
const scriptPath = SLASH( PATH.relative( process.cwd(),
|
||||
PATH.resolve( __dirname, '../utils/rasterize.js' ) ) );
|
||||
const sourcePath = SLASH( PATH.relative( process.cwd(), tempFile) );
|
||||
const destPath = SLASH( PATH.relative( process.cwd(), fOut) );
|
||||
SPAWN('phantomjs', [ scriptPath, sourcePath, destPath ]);
|
||||
};
|
||||
|
@ -1,36 +1,33 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the JsonGenerator class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module json-generator.js
|
||||
@module generators/json-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
var BaseGenerator = require('./base-generator');
|
||||
var FS = require('fs');
|
||||
var _ = require('underscore');
|
||||
const BaseGenerator = require('./base-generator');
|
||||
const FS = require('fs');
|
||||
const FJCV = require('fresh-jrs-converter');
|
||||
|
||||
/**
|
||||
The JsonGenerator generates a JSON resume directly.
|
||||
*/
|
||||
var JsonGenerator = module.exports = BaseGenerator.extend({
|
||||
/** The JsonGenerator generates a FRESH or JRS resume as an output. */
|
||||
|
||||
init: function(){
|
||||
this._super( 'json' );
|
||||
},
|
||||
class JsonGenerator extends BaseGenerator {
|
||||
|
||||
invoke: function( rez ) {
|
||||
// TODO: merge with FCVD
|
||||
function replacer( key,value ) { // Exclude these keys from stringification
|
||||
return _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
||||
'isModified', 'htmlPreview', 'safe' ],
|
||||
function( val ) { return key.trim() === val; }
|
||||
) ? undefined : value;
|
||||
}
|
||||
return JSON.stringify( rez, replacer, 2 );
|
||||
},
|
||||
constructor() { super('json'); }
|
||||
|
||||
generate: function( rez, f ) {
|
||||
FS.writeFileSync( f, this.invoke(rez), 'utf8' );
|
||||
invoke( rez ) {
|
||||
let altRez = FJCV[ `to${rez.format() === 'FRESH' ? 'JRS' : 'FRESH'}` ](rez);
|
||||
return altRez = FJCV.toSTRING( altRez );
|
||||
}
|
||||
//altRez.stringify()
|
||||
|
||||
});
|
||||
generate( rez, f ) {
|
||||
FS.writeFileSync(f, this.invoke(rez), 'utf8');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = JsonGenerator;
|
||||
|
@ -1,37 +1,41 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the JsonYamlGenerator class.
|
||||
@module json-yaml-generator.js
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module generators/json-yaml-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var BaseGenerator = require('./base-generator');
|
||||
var FS = require('fs');
|
||||
var YAML = require('yamljs');
|
||||
|
||||
/**
|
||||
JsonYamlGenerator takes a JSON resume object and translates it directly to
|
||||
JSON without a template, producing an equivalent YAML-formatted resume. See
|
||||
also YamlGenerator (yaml-generator.js).
|
||||
*/
|
||||
|
||||
var JsonYamlGenerator = module.exports = BaseGenerator.extend({
|
||||
|
||||
init: function(){
|
||||
this._super( 'yml' );
|
||||
},
|
||||
|
||||
invoke: function( rez, themeMarkup, cssInfo, opts ) {
|
||||
return YAML.stringify( JSON.parse( rez.stringify() ), Infinity, 2 );
|
||||
},
|
||||
|
||||
generate: function( rez, f, opts ) {
|
||||
var data = YAML.stringify( JSON.parse( rez.stringify() ), Infinity, 2 );
|
||||
FS.writeFileSync( f, data, 'utf8' );
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
const BaseGenerator = require('./base-generator');
|
||||
const FS = require('fs');
|
||||
const YAML = require('yamljs');
|
||||
|
||||
}());
|
||||
|
||||
|
||||
/**
|
||||
JsonYamlGenerator takes a JSON resume object and translates it directly to
|
||||
JSON without a template, producing an equivalent YAML-formatted resume. See
|
||||
also YamlGenerator (yaml-generator.js).
|
||||
*/
|
||||
|
||||
class JsonYamlGenerator extends BaseGenerator {
|
||||
|
||||
constructor() { super('yml'); }
|
||||
|
||||
invoke( rez/*, themeMarkup, cssInfo, opts*/ ) {
|
||||
return YAML.stringify(JSON.parse( rez.stringify() ), Infinity, 2);
|
||||
}
|
||||
|
||||
generate( rez, f/*, opts */) {
|
||||
const data = YAML.stringify(JSON.parse( rez.stringify() ), Infinity, 2);
|
||||
FS.writeFileSync(f, data, 'utf8');
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = JsonYamlGenerator;
|
||||
|
@ -1,18 +1,17 @@
|
||||
/**
|
||||
Definition of the LaTeXGenerator class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module latex-generator.js
|
||||
@module generators/latex-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
var TemplateGenerator = require('./template-generator');
|
||||
const TemplateGenerator = require('./template-generator');
|
||||
|
||||
/**
|
||||
LaTeXGenerator generates a LaTeX resume via TemplateGenerator.
|
||||
*/
|
||||
var LaTeXGenerator = module.exports = TemplateGenerator.extend({
|
||||
class LaTeXGenerator extends TemplateGenerator {
|
||||
|
||||
init: function(){
|
||||
this._super( 'latex', 'tex' );
|
||||
}
|
||||
constructor() { super('latex', 'tex'); }
|
||||
}
|
||||
|
||||
});
|
||||
module.exports = LaTeXGenerator;
|
||||
|
@ -1,18 +1,17 @@
|
||||
/**
|
||||
Definition of the MarkdownGenerator class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module markdown-generator.js
|
||||
@module generators/markdown-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
var TemplateGenerator = require('./template-generator');
|
||||
const TemplateGenerator = require('./template-generator');
|
||||
|
||||
/**
|
||||
MarkdownGenerator generates a Markdown-formatted resume via TemplateGenerator.
|
||||
*/
|
||||
var MarkdownGenerator = module.exports = TemplateGenerator.extend({
|
||||
class MarkdownGenerator extends TemplateGenerator {
|
||||
|
||||
init: function(){
|
||||
this._super( 'md', 'txt' );
|
||||
}
|
||||
constructor() { super('md', 'txt'); }
|
||||
}
|
||||
|
||||
});
|
||||
module.exports = MarkdownGenerator;
|
||||
|
@ -1,244 +1,283 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the TemplateGenerator class. TODO: Refactor
|
||||
@module generators/template-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module template-generator.js
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const FS = require('fs-extra');
|
||||
const _ = require('underscore');
|
||||
const MD = require('marked');
|
||||
const XML = require('xml-escape');
|
||||
const PATH = require('path');
|
||||
const parsePath = require('parse-filepath');
|
||||
const MKDIRP = require('mkdirp');
|
||||
const BaseGenerator = require('./base-generator');
|
||||
const EXTEND = require('extend');
|
||||
|
||||
|
||||
|
||||
var FS = require( 'fs-extra' )
|
||||
, _ = require( 'underscore' )
|
||||
, MD = require( 'marked' )
|
||||
, XML = require( 'xml-escape' )
|
||||
, PATH = require('path')
|
||||
, parsePath = require('parse-filepath')
|
||||
, MKDIRP = require('mkdirp')
|
||||
, BaseGenerator = require( './base-generator' )
|
||||
, EXTEND = require('extend')
|
||||
, FRESHTheme = require('../core/fresh-theme')
|
||||
, JRSTheme = require('../core/jrs-theme');
|
||||
/**
|
||||
TemplateGenerator performs resume generation via local Handlebar or Underscore
|
||||
style template expansion and is appropriate for text-based formats like HTML,
|
||||
plain text, and XML versions of Microsoft Word, Excel, and OpenOffice.
|
||||
@class TemplateGenerator
|
||||
*/
|
||||
|
||||
class TemplateGenerator extends BaseGenerator {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
TemplateGenerator performs resume generation via local Handlebar or Underscore
|
||||
style template expansion and is appropriate for text-based formats like HTML,
|
||||
plain text, and XML versions of Microsoft Word, Excel, and OpenOffice.
|
||||
@class TemplateGenerator
|
||||
*/
|
||||
var TemplateGenerator = module.exports = BaseGenerator.extend({
|
||||
/** Constructor. Set the output format and template format for this
|
||||
generator. Will usually be called by a derived generator such as
|
||||
HTMLGenerator or MarkdownGenerator. */
|
||||
|
||||
constructor( outputFormat, templateFormat/*, cssFile */) {
|
||||
super(outputFormat);
|
||||
this.tplFormat = templateFormat || outputFormat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Constructor. Set the output format and template format for this
|
||||
generator. Will usually be called by a derived generator such as
|
||||
HTMLGenerator or MarkdownGenerator. */
|
||||
/** Generate a resume using string-based inputs and outputs without touching
|
||||
the filesystem.
|
||||
@method invoke
|
||||
@param rez A FreshResume object.
|
||||
@param opts Generator options.
|
||||
@returns {Array} An array of objects representing the generated output
|
||||
files. */
|
||||
|
||||
init: function( outputFormat, templateFormat, cssFile ){
|
||||
this._super( outputFormat );
|
||||
this.tplFormat = templateFormat || outputFormat;
|
||||
},
|
||||
invoke( rez, opts ) {
|
||||
|
||||
opts =
|
||||
opts
|
||||
? (this.opts = EXTEND( true, { }, _defaultOpts, opts ))
|
||||
: this.opts;
|
||||
|
||||
// Sort such that CSS files are processed before others
|
||||
const curFmt = opts.themeObj.getFormat( this.format );
|
||||
curFmt.files = _.sortBy(curFmt.files, fi => fi.ext !== 'css');
|
||||
|
||||
/** Generate a resume using string-based inputs and outputs without touching
|
||||
the filesystem.
|
||||
@method invoke
|
||||
@param rez A FreshResume object.
|
||||
@param opts Generator options.
|
||||
@returns {Array} An array of objects representing the generated output
|
||||
files. */
|
||||
|
||||
invoke: function( rez, opts ) {
|
||||
|
||||
opts = opts ?
|
||||
(this.opts = EXTEND( true, { }, _defaultOpts, opts )) :
|
||||
this.opts;
|
||||
|
||||
// Sort such that CSS files are processed before others
|
||||
var curFmt = opts.themeObj.getFormat( this.format );
|
||||
curFmt.files = _.sortBy( curFmt.files, function(fi) {
|
||||
return fi.ext !== 'css';
|
||||
});
|
||||
|
||||
// Run the transformation!
|
||||
var results = curFmt.files.map( function( tplInfo, idx ) {
|
||||
var trx = this.single( rez, tplInfo.data, this.format, opts, opts.themeObj, curFmt );
|
||||
if( tplInfo.ext === 'css' ) { curFmt.files[idx].data = trx; }
|
||||
else if( tplInfo.ext === 'html' ) {
|
||||
// Run the transformation!
|
||||
const results = curFmt.files.map(function( tplInfo, idx ) {
|
||||
let trx;
|
||||
if (tplInfo.action === 'transform') {
|
||||
trx = this.transform(rez, tplInfo.data, this.format, opts, opts.themeObj, curFmt);
|
||||
if (tplInfo.ext === 'css') {
|
||||
curFmt.files[idx].data = trx;
|
||||
} else { tplInfo.ext === 'html'; }
|
||||
}
|
||||
//tplInfo.css contains the CSS data loaded by theme
|
||||
//tplInfo.cssPath contains the absolute path to the source CSS File
|
||||
}
|
||||
return { info: tplInfo, data: trx };
|
||||
}, this);
|
||||
//else {}
|
||||
// Images and non-transformable binary files
|
||||
if (typeof opts.onTransform === 'function') {
|
||||
opts.onTransform(tplInfo);
|
||||
}
|
||||
return {info: tplInfo, data: trx};
|
||||
}
|
||||
, this);
|
||||
|
||||
return {
|
||||
files: results
|
||||
};
|
||||
|
||||
},
|
||||
return {files: results};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Generate a resume using file-based inputs and outputs. Requires access
|
||||
to the local filesystem.
|
||||
@method generate
|
||||
@param rez A FreshResume object.
|
||||
@param f Full path to the output resume file to generate.
|
||||
@param opts Generator options. */
|
||||
/** Generate a resume using file-based inputs and outputs. Requires access
|
||||
to the local filesystem.
|
||||
@method generate
|
||||
@param rez A FreshResume object.
|
||||
@param f Full path to the output resume file to generate.
|
||||
@param opts Generator options. */
|
||||
|
||||
generate: function( rez, f, opts ) {
|
||||
generate( rez, f, opts ) {
|
||||
|
||||
// Prepare
|
||||
this.opts = EXTEND( true, { }, _defaultOpts, opts );
|
||||
// Prepare
|
||||
this.opts = EXTEND(true, { }, _defaultOpts, opts);
|
||||
|
||||
// Call the string-based generation method to perform the generation.
|
||||
var genInfo = this.invoke( rez, null );
|
||||
// Call the string-based generation method
|
||||
const genInfo = this.invoke(rez, null);
|
||||
const outFolder = parsePath( f ).dirname;
|
||||
const curFmt = opts.themeObj.getFormat(this.format);
|
||||
|
||||
var outFolder = parsePath( f ).dirname;
|
||||
var curFmt = opts.themeObj.getFormat( this.format );
|
||||
// Process individual files within this format. For example, the HTML
|
||||
// output format for a theme may have multiple HTML files, CSS files,
|
||||
// etc. Process them here.
|
||||
genInfo.files.forEach(function( file ) {
|
||||
|
||||
// Process individual files within this format. For example, the HTML
|
||||
// output format for a theme may have multiple HTML files, CSS files,
|
||||
// etc. Process them here.
|
||||
genInfo.files.forEach(function( file ){
|
||||
// console.dir _.omit(file.info,'cssData','data','css' )
|
||||
|
||||
// Pre-processing
|
||||
file.info.orgPath = file.info.orgPath || ''; // <-- For JRS themes
|
||||
var thisFilePath = PATH.join( outFolder, file.info.orgPath );
|
||||
if( this.onBeforeSave ) {
|
||||
file.data = this.onBeforeSave({
|
||||
theme: opts.themeObj,
|
||||
outputFile: (file.info.major ? f : thisFilePath),
|
||||
mk: file.data,
|
||||
opts: this.opts
|
||||
});
|
||||
if( !file.data ) return; // PDF etc
|
||||
}
|
||||
// Pre-processing
|
||||
file.info.orgPath = file.info.orgPath || '';
|
||||
const thisFilePath =
|
||||
file.info.primary
|
||||
? f
|
||||
: PATH.join(outFolder, file.info.orgPath);
|
||||
|
||||
// Write the file
|
||||
var fileName = file.info.major ? f : thisFilePath;
|
||||
MKDIRP.sync( PATH.dirname( fileName ) );
|
||||
FS.writeFileSync( fileName, file.data,
|
||||
{ encoding: 'utf8', flags: 'w' } );
|
||||
|
||||
// Post-processing
|
||||
this.onAfterSave && this.onAfterSave(
|
||||
{ outputFile: fileName, mk: file.data, opts: this.opts } );
|
||||
|
||||
}, this);
|
||||
|
||||
// Some themes require a symlink structure. If so, create it.
|
||||
if( curFmt.symLinks ) {
|
||||
Object.keys( curFmt.symLinks ).forEach( function(loc) {
|
||||
var absLoc = PATH.join(outFolder, loc);
|
||||
var absTarg = PATH.join(PATH.dirname(absLoc), curFmt.symLinks[loc]);
|
||||
// 'file', 'dir', or 'junction' (Windows only)
|
||||
var type = parsePath( absLoc ).extname ? 'file' : 'junction';
|
||||
FS.symlinkSync( absTarg, absLoc, type);
|
||||
if ((file.info.action !== 'copy') && this.onBeforeSave) {
|
||||
file.data = this.onBeforeSave({
|
||||
theme: opts.themeObj,
|
||||
outputFile: thisFilePath,
|
||||
mk: file.data,
|
||||
opts: this.opts,
|
||||
ext: file.info.ext
|
||||
});
|
||||
if (!file.data) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return genInfo;
|
||||
// Write the file
|
||||
if (typeof opts.beforeWrite === 'function') {
|
||||
opts.beforeWrite({data: thisFilePath});
|
||||
}
|
||||
MKDIRP.sync(PATH.dirname( thisFilePath ));
|
||||
|
||||
},
|
||||
if (file.info.action !== 'copy') {
|
||||
FS.writeFileSync(thisFilePath, file.data, {encoding: 'utf8', flags: 'w'});
|
||||
} else {
|
||||
FS.copySync(file.info.path, thisFilePath);
|
||||
}
|
||||
if (typeof opts.afterWrite === 'function') {
|
||||
opts.afterWrite({data: thisFilePath});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Perform a single resume resume transformation using string-based inputs
|
||||
and outputs without touching the local file system.
|
||||
@param json A FRESH or JRS resume object.
|
||||
@param jst The stringified template data
|
||||
@param format The format name, such as "html" or "latex"
|
||||
@param cssInfo Needs to be refactored.
|
||||
@param opts Options and passthrough data. */
|
||||
|
||||
single: function( json, jst, format, opts, theme, curFmt ) {
|
||||
this.opts.freezeBreaks && ( jst = freeze(jst) );
|
||||
|
||||
var eng = require( '../renderers/' + theme.engine + '-generator' );
|
||||
var result = eng.generate( json, jst, format, curFmt, opts, theme );
|
||||
|
||||
this.opts.freezeBreaks && ( result = unfreeze(result) );
|
||||
return result;
|
||||
// Post-processing
|
||||
if (this.onAfterSave) {
|
||||
return this.onAfterSave({outputFile: thisFilePath, mk: file.data, opts: this.opts});
|
||||
}
|
||||
}
|
||||
|
||||
, this);
|
||||
|
||||
});
|
||||
// Some themes require a symlink structure. If so, create it.
|
||||
createSymLinks(curFmt, outFolder);
|
||||
|
||||
|
||||
|
||||
/** Export the TemplateGenerator function/ctor. */
|
||||
module.exports = TemplateGenerator;
|
||||
|
||||
|
||||
|
||||
|
||||
/** Freeze newlines for protection against errant JST parsers. */
|
||||
function freeze( markup ) {
|
||||
return markup
|
||||
.replace( _reg.regN, _defaultOpts.nSym )
|
||||
.replace( _reg.regR, _defaultOpts.rSym );
|
||||
return genInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Unfreeze newlines when the coast is clear. */
|
||||
function unfreeze( markup ) {
|
||||
return markup
|
||||
.replace( _reg.regSymR, '\r' )
|
||||
.replace( _reg.regSymN, '\n' );
|
||||
}
|
||||
/** Perform a single resume resume transformation using string-based inputs
|
||||
and outputs without touching the local file system.
|
||||
@param json A FRESH or JRS resume object.
|
||||
@param jst The stringified template data
|
||||
@param format The format name, such as "html" or "latex"
|
||||
@param cssInfo Needs to be refactored.
|
||||
@param opts Options and passthrough data. */
|
||||
|
||||
|
||||
|
||||
/** Default template generator options. */
|
||||
var _defaultOpts = {
|
||||
engine: 'underscore',
|
||||
keepBreaks: true,
|
||||
freezeBreaks: false,
|
||||
nSym: '&newl;', // newline entity
|
||||
rSym: '&retn;', // return entity
|
||||
template: {
|
||||
interpolate: /\{\{(.+?)\}\}/g,
|
||||
escape: /\{\{\=(.+?)\}\}/g,
|
||||
evaluate: /\{\%(.+?)\%\}/g,
|
||||
comment: /\{\#(.+?)\#\}/g
|
||||
},
|
||||
filters: {
|
||||
out: function( txt ) { return txt; },
|
||||
raw: function( txt ) { return txt; },
|
||||
xml: function( txt ) { return XML(txt); },
|
||||
md: function( txt ) { return MD( txt || '' ); },
|
||||
mdin: function( txt ) {
|
||||
return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
||||
},
|
||||
lower: function( txt ) { return txt.toLowerCase(); },
|
||||
link: function( name, url ) { return url ?
|
||||
'<a href="' + url + '">' + name + '</a>' : name; }
|
||||
},
|
||||
prettify: { // ← See https://github.com/beautify-web/js-beautify#options
|
||||
indent_size: 2,
|
||||
unformatted: ['em','strong','a'],
|
||||
max_char: 80, // ← See lib/html.js in above-linked repo
|
||||
//wrap_line_length: 120, <-- Don't use this
|
||||
transform( json, jst, format, opts, theme, curFmt ) {
|
||||
if (this.opts.freezeBreaks) {
|
||||
jst = freeze(jst);
|
||||
}
|
||||
};
|
||||
const eng = require(`../renderers/${theme.engine}-generator`);
|
||||
let result = eng.generate(json, jst, format, curFmt, opts, theme);
|
||||
if (this.opts.freezeBreaks) {
|
||||
result = unfreeze(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = TemplateGenerator;
|
||||
|
||||
|
||||
|
||||
/** Regexes for linebreak preservation. */
|
||||
var _reg = {
|
||||
regN: new RegExp( '\n', 'g' ),
|
||||
regR: new RegExp( '\r', 'g' ),
|
||||
regSymN: new RegExp( _defaultOpts.nSym, 'g' ),
|
||||
regSymR: new RegExp( _defaultOpts.rSym, 'g' )
|
||||
};
|
||||
var createSymLinks = function( curFmt, outFolder ) {
|
||||
// Some themes require a symlink structure. If so, create it.
|
||||
if (curFmt.symLinks) {
|
||||
Object.keys( curFmt.symLinks ).forEach(function(loc) {
|
||||
const absLoc = PATH.join(outFolder, loc);
|
||||
const absTarg = PATH.join(PATH.dirname(absLoc), curFmt.symLinks[loc]);
|
||||
// Set type to 'file', 'dir', or 'junction' (Windows only)
|
||||
const type = parsePath( absLoc ).extname ? 'file' : 'junction';
|
||||
|
||||
try {
|
||||
return FS.symlinkSync(absTarg, absLoc, type);
|
||||
} catch (err) {
|
||||
let succeeded = false;
|
||||
if (err.code === 'EEXIST') {
|
||||
FS.unlinkSync(absLoc);
|
||||
try {
|
||||
FS.symlinkSync(absTarg, absLoc, type);
|
||||
succeeded = true;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
if (!succeeded) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** Freeze newlines for protection against errant JST parsers. */
|
||||
var freeze = function( markup ) {
|
||||
markup.replace( _reg.regN, _defaultOpts.nSym );
|
||||
return markup.replace( _reg.regR, _defaultOpts.rSym );
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
/** Unfreeze newlines when the coast is clear. */
|
||||
var unfreeze = function( markup ) {
|
||||
markup.replace(_reg.regSymR, '\r');
|
||||
return markup.replace(_reg.regSymN, '\n');
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Default template generator options. */
|
||||
var _defaultOpts = {
|
||||
engine: 'underscore',
|
||||
keepBreaks: true,
|
||||
freezeBreaks: false,
|
||||
nSym: '&newl;', // newline entity
|
||||
rSym: '&retn;', // return entity
|
||||
template: {
|
||||
interpolate: /\{\{(.+?)\}\}/g,
|
||||
escape: /\{\{=(.+?)\}\}/g,
|
||||
evaluate: /\{%(.+?)%\}/g,
|
||||
comment: /\{#(.+?)#\}/g
|
||||
},
|
||||
filters: {
|
||||
out( txt ) { return txt; },
|
||||
raw( txt ) { return txt; },
|
||||
xml( txt ) { return XML(txt); },
|
||||
md( txt ) { return MD( txt || '' ); },
|
||||
mdin( txt ) { return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, ''); },
|
||||
lower( txt ) { return txt.toLowerCase(); },
|
||||
link( name, url ) {
|
||||
if (url) { return `<a href="${url}">${name}</a>`; } else { return name; }
|
||||
}
|
||||
},
|
||||
prettify: { // ← See https://github.com/beautify-web/js-beautify#options
|
||||
indent_size: 2,
|
||||
unformatted: ['em','strong','a'],
|
||||
max_char: 80
|
||||
} // ← See lib/html.js in above-linked repo
|
||||
};
|
||||
//wrap_line_length: 120, <-- Don't use this
|
||||
|
||||
|
||||
|
||||
/** Regexes for linebreak preservation. */
|
||||
/* eslint-disable no-control-regex */
|
||||
var _reg = {
|
||||
regN: new RegExp( '\n', 'g' ),
|
||||
regR: new RegExp( '\r', 'g' ),
|
||||
regSymN: new RegExp( _defaultOpts.nSym, 'g' ),
|
||||
regSymR: new RegExp( _defaultOpts.rSym, 'g' )
|
||||
};
|
||||
/* eslint-enable no-control-regex */
|
||||
|
@ -1,20 +1,16 @@
|
||||
/**
|
||||
Definition of the TextGenerator class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module text-generator.js
|
||||
@module generators/text-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
var TemplateGenerator = require('./template-generator');
|
||||
const TemplateGenerator = require('./template-generator');
|
||||
|
||||
/**
|
||||
The TextGenerator generates a plain-text resume via the TemplateGenerator.
|
||||
*/
|
||||
var TextGenerator = TemplateGenerator.extend({
|
||||
|
||||
init: function(){
|
||||
this._super( 'txt' );
|
||||
},
|
||||
|
||||
});
|
||||
class TextGenerator extends TemplateGenerator {
|
||||
constructor() { super('txt'); }
|
||||
}
|
||||
|
||||
module.exports = TextGenerator;
|
||||
|
@ -1,19 +1,14 @@
|
||||
/**
|
||||
/*
|
||||
Definition of the WordGenerator class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module word-generator.js
|
||||
@module generators/word-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var TemplateGenerator = require('./template-generator');
|
||||
var WordGenerator = module.exports = TemplateGenerator.extend({
|
||||
const TemplateGenerator = require('./template-generator');
|
||||
|
||||
init: function(){
|
||||
this._super( 'doc', 'xml' );
|
||||
}
|
||||
class WordGenerator extends TemplateGenerator {
|
||||
constructor() { super('doc', 'xml'); }
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}());
|
||||
module.exports = WordGenerator;
|
||||
|
@ -1,18 +1,14 @@
|
||||
/**
|
||||
Definition of the XMLGenerator class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module xml-generator.js
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module generatprs/xml-generator
|
||||
*/
|
||||
|
||||
var BaseGenerator = require('./base-generator');
|
||||
const BaseGenerator = require('./base-generator');
|
||||
|
||||
/**
|
||||
The XmlGenerator generates an XML resume via the TemplateGenerator.
|
||||
*/
|
||||
var XMLGenerator = module.exports = BaseGenerator.extend({
|
||||
/** The XmlGenerator generates an XML resume via the TemplateGenerator. */
|
||||
class XMLGenerator extends BaseGenerator {
|
||||
constructor() { super('xml'); }
|
||||
}
|
||||
|
||||
init: function(){
|
||||
this._super( 'xml' );
|
||||
},
|
||||
|
||||
});
|
||||
module.exports = XMLGenerator;
|
||||
|
@ -1,24 +1,19 @@
|
||||
/**
|
||||
Definition of the YAMLGenerator class.
|
||||
@module yaml-generator.js
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
const TemplateGenerator = require('./template-generator');
|
||||
|
||||
var TemplateGenerator = require('./template-generator');
|
||||
/**
|
||||
YamlGenerator generates a YAML-formatted resume via TemplateGenerator.
|
||||
*/
|
||||
|
||||
/**
|
||||
YamlGenerator generates a YAML-formatted resume via TemplateGenerator.
|
||||
*/
|
||||
class YAMLGenerator extends TemplateGenerator {
|
||||
constructor() { super('yml', 'yml'); }
|
||||
}
|
||||
|
||||
var YAMLGenerator = module.exports = TemplateGenerator.extend({
|
||||
|
||||
init: function(){
|
||||
this._super( 'yml', 'yml' );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
module.exports = YAMLGenerator;
|
||||
|
@ -1,51 +0,0 @@
|
||||
/**
|
||||
External API surface for HackMyResume.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module hackmyapi.js
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The formal HackMyResume API.
|
||||
*/
|
||||
var HackMyAPI = module.exports = {
|
||||
verbs: {
|
||||
build: require('./verbs/build'),
|
||||
analyze: require('./verbs/analyze'),
|
||||
validate: require('./verbs/validate'),
|
||||
convert: require('./verbs/convert'),
|
||||
new: require('./verbs/create'),
|
||||
peek: require('./verbs/peek')
|
||||
},
|
||||
alias: {
|
||||
generate: require('./verbs/build'),
|
||||
create: require('./verbs/create')
|
||||
},
|
||||
options: require('./core/default-options'),
|
||||
formats: require('./core/default-formats'),
|
||||
Sheet: require('./core/fresh-resume'),
|
||||
FRESHResume: require('./core/fresh-resume'),
|
||||
JRSResume: require('./core/jrs-resume'),
|
||||
FRESHTheme: require('./core/fresh-theme'),
|
||||
JRSTheme: require('./core/jrs-theme'),
|
||||
FluentDate: require('./core/fluent-date'),
|
||||
HtmlGenerator: require('./generators/html-generator'),
|
||||
TextGenerator: require('./generators/text-generator'),
|
||||
HtmlPdfCliGenerator: require('./generators/html-pdf-cli-generator'),
|
||||
WordGenerator: require('./generators/word-generator'),
|
||||
MarkdownGenerator: require('./generators/markdown-generator'),
|
||||
JsonGenerator: require('./generators/json-generator'),
|
||||
YamlGenerator: require('./generators/yaml-generator'),
|
||||
JsonYamlGenerator: require('./generators/json-yaml-generator'),
|
||||
LaTeXGenerator: require('./generators/latex-generator'),
|
||||
HtmlPngGenerator: require('./generators/html-png-generator')
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
77
src/helpers/block-helpers.js
Normal file
77
src/helpers/block-helpers.js
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Block helper definitions for HackMyResume / FluentCV.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module helpers/generic-helpers
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const LO = require('lodash');
|
||||
const _ = require('underscore');
|
||||
require('../utils/string');
|
||||
|
||||
|
||||
|
||||
/** Block helper function definitions. */
|
||||
module.exports = {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Emit the enclosed content if the resume has a section with
|
||||
the specified name. Otherwise, emit an empty string ''.
|
||||
*/
|
||||
|
||||
section( title, options ) {
|
||||
title = title.trim().toLowerCase();
|
||||
const obj = LO.get(this.r, title);
|
||||
let ret = '';
|
||||
if (obj) {
|
||||
if (_.isArray(obj)) {
|
||||
if (obj.length) {
|
||||
ret = options.fn(this);
|
||||
}
|
||||
} else if (_.isObject(obj)) {
|
||||
if ((obj.history && obj.history.length) || (obj.sets && obj.sets.length)) {
|
||||
ret = options.fn(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
|
||||
|
||||
|
||||
ifHasSkill( rez, skill, options ) {
|
||||
const skUp = skill.toUpperCase();
|
||||
const ret = _.some(rez.skills.list, sk => (skUp.toUpperCase() === sk.name.toUpperCase()) && sk.years
|
||||
, this);
|
||||
if (ret) { return options.fn(this); }
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
Emit the enclosed content if the resume has the named
|
||||
property or subproperty.
|
||||
*/
|
||||
|
||||
has( title, options ) {
|
||||
title = title && title.trim().toLowerCase();
|
||||
if (LO.get(this.r, title)) {
|
||||
return options.fn(this);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Return true if either value is truthy.
|
||||
@method either
|
||||
*/
|
||||
either( lhs, rhs, options ) { if (lhs || rhs) { return options.fn(this); } }
|
||||
};
|
@ -1,67 +1,67 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Generic template helper definitions for command-line output.
|
||||
@module console-helpers.js
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
const PAD = require('string-padding');
|
||||
const LO = require('lodash');
|
||||
const CHALK = require('chalk');
|
||||
const _ = require('underscore');
|
||||
require('../utils/string');
|
||||
|
||||
|
||||
|
||||
var PAD = require('string-padding')
|
||||
, LO = require('lodash')
|
||||
, CHALK = require('chalk')
|
||||
, _ = require('underscore');
|
||||
require('../utils/string');
|
||||
module.exports = {
|
||||
|
||||
|
||||
|
||||
var consoleFormatHelpers = module.exports = {
|
||||
|
||||
v: function( val, defaultVal, padding, style ) {
|
||||
retVal = ( val === null || val === undefined ) ? defaultVal : val;
|
||||
var spaces = 0;
|
||||
if( String.is(padding) ) {
|
||||
spaces = parseInt( padding, 10 );
|
||||
if( isNaN(spaces) ) spaces = 0;
|
||||
}
|
||||
else if( _.isNumber(padding) ) {
|
||||
spaces = padding;
|
||||
}
|
||||
|
||||
if( spaces !== 0 )
|
||||
retVal = PAD( retVal, Math.abs(spaces), null, spaces > 0 ? PAD.LEFT : PAD.RIGHT );
|
||||
|
||||
if( style && String.is( style )) {
|
||||
retVal = LO.get( CHALK, style )( retVal );
|
||||
}
|
||||
|
||||
return retVal;
|
||||
},
|
||||
|
||||
gapLength: function(val) {
|
||||
if( val < 35 )
|
||||
return CHALK.green.bold(val);
|
||||
else if( val < 95 )
|
||||
return CHALK.yellow.bold(val);
|
||||
else
|
||||
return CHALK.red.bold(val);
|
||||
},
|
||||
|
||||
style: function( val, style ) {
|
||||
return LO.get( CHALK, style )( val );
|
||||
},
|
||||
|
||||
isPlural: function( val, options ) {
|
||||
if( val > 1 )
|
||||
return options.fn(this);
|
||||
},
|
||||
|
||||
pad: function( val, spaces ) {
|
||||
return PAD(val, Math.abs(spaces), null, spaces > 0 ? PAD.LEFT : PAD.RIGHT );
|
||||
v( val, defaultVal, padding, style ) {
|
||||
let retVal = ( (val === null) || (val === undefined) ) ? defaultVal : val;
|
||||
let spaces = 0;
|
||||
if (String.is(padding)) {
|
||||
spaces = parseInt(padding, 10);
|
||||
if (isNaN(spaces)) { spaces = 0; }
|
||||
} else if (_.isNumber(padding)) {
|
||||
spaces = padding;
|
||||
}
|
||||
};
|
||||
|
||||
if (spaces !== 0) {
|
||||
retVal = PAD(retVal, Math.abs(spaces), null, spaces > 0 ? PAD.LEFT : PAD.RIGHT);
|
||||
}
|
||||
|
||||
if (style && String.is( style )) {
|
||||
retVal = LO.get( CHALK, style )( retVal );
|
||||
}
|
||||
return retVal;
|
||||
},
|
||||
|
||||
}());
|
||||
gapLength(val) {
|
||||
if (val < 35) {
|
||||
return CHALK.green.bold(val);
|
||||
} else if (val < 95) {
|
||||
return CHALK.yellow.bold(val);
|
||||
} else {
|
||||
return CHALK.red.bold(val);
|
||||
}
|
||||
},
|
||||
|
||||
style( val, style ) {
|
||||
return LO.get( CHALK, style )( val );
|
||||
},
|
||||
|
||||
isPlural( val, options ) {
|
||||
if (val > 1) {
|
||||
return options.fn(this);
|
||||
}
|
||||
},
|
||||
|
||||
pad( val, spaces ) {
|
||||
return PAD(val, Math.abs(spaces), null, spaces > 0 ? PAD.LEFT : PAD.RIGHT);
|
||||
}
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +1,89 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
|
||||
/**
|
||||
Template helper definitions for Handlebars.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module handlebars-helpers.js
|
||||
*/
|
||||
|
||||
const HANDLEBARS = require('handlebars');
|
||||
const _ = require('underscore');
|
||||
const helpers = require('./generic-helpers');
|
||||
const path = require('path');
|
||||
const blockHelpers = require('./block-helpers');
|
||||
const HMS = require('../core/status-codes');
|
||||
|
||||
(function() {
|
||||
/**
|
||||
Register useful Handlebars helpers.
|
||||
@method registerHelpers
|
||||
*/
|
||||
|
||||
var HANDLEBARS = require('handlebars')
|
||||
, _ = require('underscore')
|
||||
, helpers = require('./generic-helpers');
|
||||
module.exports = function( theme, rez, opts ) {
|
||||
|
||||
/**
|
||||
Register useful Handlebars helpers.
|
||||
@method registerHelpers
|
||||
*/
|
||||
module.exports = function( theme, opts ) {
|
||||
helpers.theme = theme;
|
||||
helpers.opts = opts;
|
||||
helpers.type = 'handlebars';
|
||||
|
||||
helpers.theme = theme;
|
||||
helpers.opts = opts;
|
||||
HANDLEBARS.registerHelper( helpers );
|
||||
// Prepare generic helpers for use with Handlebars. We do this by wrapping them
|
||||
// in a Handlebars-aware wrapper which calls the helper internally.
|
||||
const wrappedHelpers = _.mapObject(helpers, function( hVal/*, hKey*/ ) {
|
||||
if (_.isFunction(hVal)) {
|
||||
return _.wrap(hVal, function(func) {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
args.shift(); // lose the 1st element (func) [^1]
|
||||
//args.pop() # lose the last element (HB options hash)
|
||||
args[ args.length - 1 ] = rez; // replace w/ resume object
|
||||
return func.apply(this, args);
|
||||
}); // call the generic helper
|
||||
}
|
||||
return hVal;
|
||||
}
|
||||
, this);
|
||||
HANDLEBARS.registerHelper(wrappedHelpers);
|
||||
|
||||
};
|
||||
// Prepare Handlebars-specific helpers - "blockHelpers" is really a misnomer
|
||||
// since any kind of Handlebars-specific helper can live here
|
||||
HANDLEBARS.registerHelper(blockHelpers);
|
||||
|
||||
}());
|
||||
// Register any theme-provided custom helpers...
|
||||
|
||||
// Normalize "theme.helpers" (string or array) to an array
|
||||
if (_.isString(theme.helpers)) { theme.helpers = [ theme.helpers ]; }
|
||||
|
||||
if (_.isArray(theme.helpers)) {
|
||||
const glob = require('glob');
|
||||
const slash = require('slash');
|
||||
let curGlob = null;
|
||||
try {
|
||||
_.each(theme.helpers, function(fGlob) { // foreach theme.helpers entry
|
||||
curGlob = fGlob; // ..cache in case of exception
|
||||
fGlob = path.join(theme.folder, fGlob); // ..make relative to theme
|
||||
const files = glob.sync(slash(fGlob)); // ..expand the glob
|
||||
if (files.length > 0) { // ..guard against empty glob
|
||||
_.each(files, function(f) { // ..loop over concrete paths
|
||||
HANDLEBARS.registerHelper(require(f)); // ..register the path
|
||||
});
|
||||
} else {
|
||||
throw {fluenterror: HMS.themeHelperLoad, inner: null, glob: fGlob};
|
||||
}
|
||||
});
|
||||
return;
|
||||
} catch (ex) {
|
||||
throw{
|
||||
fluenterror: HMS.themeHelperLoad,
|
||||
inner: ex,
|
||||
glob: curGlob, exit: true
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// [^1]: This little bit of acrobatics ensures that our generic helpers are
|
||||
// called as generic helpers, not as Handlebars-specific helpers. This allows
|
||||
// them to be used in other templating engines, like Underscore. If you need a
|
||||
// Handlebars-specific helper with normal Handlebars context and options, put it
|
||||
// in block-helpers.coffee.
|
||||
|
@ -1,34 +1,35 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Template helper definitions for Underscore.
|
||||
@license MIT. Copyright (c) 2016 hacksalot (https://github.com/hacksalot)
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module handlebars-helpers.js
|
||||
*/
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
var HANDLEBARS = require('handlebars')
|
||||
, _ = require('underscore')
|
||||
, helpers = require('./generic-helpers');
|
||||
const _ = require('underscore');
|
||||
const helpers = require('./generic-helpers');
|
||||
|
||||
/**
|
||||
Register useful Underscore helpers.
|
||||
@method registerHelpers
|
||||
*/
|
||||
module.exports = function( theme, opts, cssInfo, ctx, eng ) {
|
||||
|
||||
helpers.theme = theme;
|
||||
helpers.opts = opts;
|
||||
helpers.cssInfo = cssInfo;
|
||||
helpers.engine = eng;
|
||||
ctx.h = helpers;
|
||||
|
||||
_.each( helpers, function( hVal, hKey ) {
|
||||
if( _.isFunction( hVal )) {
|
||||
_.bind( hVal, ctx );
|
||||
}
|
||||
}, this);
|
||||
|
||||
};
|
||||
|
||||
}());
|
||||
/**
|
||||
Register useful Underscore helpers.
|
||||
@method registerHelpers
|
||||
*/
|
||||
module.exports = function( theme, opts, cssInfo, ctx, eng ) {
|
||||
helpers.theme = theme;
|
||||
helpers.opts = opts;
|
||||
helpers.cssInfo = cssInfo;
|
||||
helpers.engine = eng;
|
||||
ctx.h = helpers;
|
||||
_.each(helpers, function( hVal ) {
|
||||
if (_.isFunction(hVal)) {
|
||||
return _.bind(hVal, ctx);
|
||||
}
|
||||
}
|
||||
, this);
|
||||
};
|
||||
|
48
src/index.js
48
src/index.js
@ -1,22 +1,46 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Command-line interface (CLI) for HackMyResume.
|
||||
External API surface for HackMyResume.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module index.js
|
||||
@module hackmycore/index
|
||||
*/
|
||||
|
||||
|
||||
|
||||
try {
|
||||
/** API facade for HackMyResume. */
|
||||
|
||||
require('./cli/main')( process.argv );
|
||||
module.exports = {
|
||||
|
||||
}
|
||||
catch( ex ) {
|
||||
verbs: {
|
||||
build: require('./verbs/build'),
|
||||
analyze: require('./verbs/analyze'),
|
||||
validate: require('./verbs/validate'),
|
||||
convert: require('./verbs/convert'),
|
||||
new: require('./verbs/create'),
|
||||
peek: require('./verbs/peek')
|
||||
},
|
||||
|
||||
require('./cli/error').err( ex, true );
|
||||
alias: {
|
||||
generate: require('./verbs/build'),
|
||||
create: require('./verbs/create')
|
||||
},
|
||||
|
||||
}
|
||||
options: require('./core/default-options'),
|
||||
formats: require('./core/default-formats'),
|
||||
Sheet: require('./core/fresh-resume'),
|
||||
FRESHResume: require('./core/fresh-resume'),
|
||||
JRSResume: require('./core/jrs-resume'),
|
||||
FRESHTheme: require('./core/fresh-theme'),
|
||||
JRSTheme: require('./core/jrs-theme'),
|
||||
ResumeFactory: require('./core/resume-factory'),
|
||||
FluentDate: require('./core/fluent-date'),
|
||||
HtmlGenerator: require('./generators/html-generator'),
|
||||
TextGenerator: require('./generators/text-generator'),
|
||||
HtmlPdfCliGenerator: require('./generators/html-pdf-cli-generator'),
|
||||
WordGenerator: require('./generators/word-generator'),
|
||||
MarkdownGenerator: require('./generators/markdown-generator'),
|
||||
JsonGenerator: require('./generators/json-generator'),
|
||||
YamlGenerator: require('./generators/yaml-generator'),
|
||||
JsonYamlGenerator: require('./generators/json-yaml-generator'),
|
||||
LaTeXGenerator: require('./generators/latex-generator'),
|
||||
HtmlPngGenerator: require('./generators/html-png-generator')
|
||||
};
|
||||
|
54
src/inspectors/duration-inspector.js
Normal file
54
src/inspectors/duration-inspector.js
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const FluentDate = require('../core/fluent-date');
|
||||
const _ = require('underscore');
|
||||
const lo = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
Compute the total duration of the work history.
|
||||
@returns The total duration of the sheet's work history, that is, the number
|
||||
of years between the start date of the earliest job on the resume and the
|
||||
*latest end date of all jobs in the work history*. This last condition is for
|
||||
sheets that have overlapping jobs.
|
||||
*/
|
||||
run(rez, collKey, startKey, endKey, unit) {
|
||||
unit = unit || 'years';
|
||||
const hist = lo.get(rez, collKey);
|
||||
if (!hist || !hist.length) { return 0; }
|
||||
|
||||
// BEGIN CODE DUPLICATION --> src/inspectors/gap-inspector.coffee (TODO)
|
||||
|
||||
// Convert the candidate's employment history to an array of dates,
|
||||
// where each element in the array is a start date or an end date of a
|
||||
// job -- it doesn't matter which.
|
||||
let new_e = hist.map(function( job ) {
|
||||
let obj = _.pick( job, [startKey, endKey] );
|
||||
// Synthesize an end date if this is a "current" gig
|
||||
if (!_.has(obj, endKey)) { obj[endKey] = 'current'; }
|
||||
if (obj && (obj[startKey] || obj[endKey])) {
|
||||
obj = _.pairs(obj);
|
||||
obj[0][1] = FluentDate.fmt( obj[0][1] );
|
||||
if (obj.length > 1) {
|
||||
obj[1][1] = FluentDate.fmt( obj[1][1] );
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
});
|
||||
|
||||
// Flatten the array, remove empties, and sort
|
||||
new_e = _.filter(_.flatten( new_e, true ), v => v && v.length && v[0] && v[0].length);
|
||||
if (!new_e || !new_e.length) { return 0; }
|
||||
new_e = _.sortBy(new_e, elem => elem[1].unix());
|
||||
|
||||
// END CODE DUPLICATION
|
||||
|
||||
const firstDate = _.first( new_e )[1];
|
||||
const lastDate = _.last( new_e )[1];
|
||||
return lastDate.diff(firstDate, unit);
|
||||
}
|
||||
};
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Employment gap analysis for HackMyResume.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@ -6,161 +11,147 @@ Employment gap analysis for HackMyResume.
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const _ = require('underscore');
|
||||
const FluentDate = require('../core/fluent-date');
|
||||
const moment = require('moment');
|
||||
const LO = require('lodash');
|
||||
|
||||
|
||||
|
||||
var _ = require('underscore');
|
||||
var FluentDate = require('../core/fluent-date');
|
||||
var moment = require('moment');
|
||||
var LO = require('lodash');
|
||||
|
||||
/**
|
||||
Identify gaps in the candidate's employment history.
|
||||
*/
|
||||
module.exports = {
|
||||
|
||||
moniker: 'gap-inspector',
|
||||
|
||||
/**
|
||||
Identify gaps in the candidate's employment history.
|
||||
Run the Gap Analyzer on a resume.
|
||||
@method run
|
||||
@return {Array} An array of object representing gaps in the candidate's
|
||||
employment history. Each object provides the start, end, and duration of the
|
||||
gap:
|
||||
{ <-- gap
|
||||
start: // A Moment.js date
|
||||
end: // A Moment.js date
|
||||
duration: // Gap length
|
||||
}
|
||||
*/
|
||||
var gapInspector = module.exports = {
|
||||
|
||||
run(rez) {
|
||||
|
||||
// This is what we'll return
|
||||
const coverage = {
|
||||
gaps: [],
|
||||
overlaps: [],
|
||||
pct: '0%',
|
||||
duration: {
|
||||
total: 0,
|
||||
work: 0,
|
||||
gaps: 0
|
||||
}
|
||||
};
|
||||
|
||||
moniker: 'gap-inspector',
|
||||
// Missing employment section? Bye bye.
|
||||
const hist = LO.get(rez, 'employment.history');
|
||||
|
||||
if (!hist || !hist.length) { return coverage; }
|
||||
|
||||
|
||||
/**
|
||||
Run the Gap Analyzer on a resume.
|
||||
@method run
|
||||
@return {Array} An array of object representing gaps in the candidate's
|
||||
employment history. Each object provides the start, end, and duration of the
|
||||
gap:
|
||||
{ <-- gap
|
||||
start: // A Moment.js date
|
||||
end: // A Moment.js date
|
||||
duration: // Gap length
|
||||
}
|
||||
*/
|
||||
run: function( rez ) {
|
||||
|
||||
// This is what we'll return
|
||||
var coverage = {
|
||||
gaps: [],
|
||||
overlaps: [],
|
||||
duration: {
|
||||
total: 0,
|
||||
work: 0,
|
||||
gaps: 0
|
||||
},
|
||||
pct: '0%'
|
||||
};
|
||||
|
||||
// Missing employment section? Bye bye.
|
||||
var hist = LO.get( rez, 'employment.history' );
|
||||
if( !hist || !hist.length ) { return coverage; }
|
||||
|
||||
// Convert the candidate's employment history to an array of dates,
|
||||
// where each element in the array is a start date or an end date of a
|
||||
// job -- it doesn't matter which.
|
||||
var new_e = hist.map( function( job ){
|
||||
var obj = _.pick( job, ['start', 'end'] );
|
||||
if( obj && (obj.start || obj.end)) {
|
||||
obj = _.pairs( obj );
|
||||
obj[0][1] = FluentDate.fmt( obj[0][1] );
|
||||
if( obj.length > 1 )
|
||||
obj[1][1] = FluentDate.fmt( obj[1][1] );
|
||||
}
|
||||
return obj;
|
||||
});
|
||||
|
||||
|
||||
// Flatten the array, remove empties, and sort
|
||||
new_e = _.filter( _.flatten( new_e, true ), function(v) {
|
||||
return ( v && v.length && v[0] && v[0].length );
|
||||
});
|
||||
if( !new_e || !new_e.length ) return coverage;
|
||||
new_e = _.sortBy( new_e, function( elem ) { return elem[1].unix(); });
|
||||
|
||||
// Iterate over elements in the array. Each time a start date is found,
|
||||
// increment a reference count. Each time an end date is found, decrement
|
||||
// the reference count. When the reference count reaches 0, we have a gap.
|
||||
// When the reference count is > 0, the candidate is employed. When the
|
||||
// reference count reaches 2, the candidate is overlapped.
|
||||
|
||||
var num_gaps = 0, ref_count = 0, total_gap_days = 0, gap_start;
|
||||
|
||||
new_e.forEach( function(point) {
|
||||
|
||||
var inc = point[0] === 'start' ? 1 : -1;
|
||||
ref_count += inc;
|
||||
|
||||
// If the ref count just reached 0, start a new GAP
|
||||
if( ref_count === 0 ) {
|
||||
coverage.gaps.push( { start: point[1], end: null });
|
||||
}
|
||||
|
||||
// If the ref count reached 1 by rising, end the last GAP
|
||||
else if( ref_count === 1 && inc === 1 ) {
|
||||
var lastGap = _.last( coverage.gaps );
|
||||
if( lastGap ) {
|
||||
lastGap.end = point[1];
|
||||
lastGap.duration = lastGap.end.diff( lastGap.start, 'days' );
|
||||
total_gap_days += lastGap.duration;
|
||||
}
|
||||
}
|
||||
|
||||
// If the ref count reaches 2 by rising, start a new OVERLAP
|
||||
else if( ref_count === 2 && inc === 1 ) {
|
||||
coverage.overlaps.push( { start: point[1], end: null });
|
||||
}
|
||||
|
||||
// If the ref count reaches 1 by falling, end the last OVERLAP
|
||||
else if( ref_count === 1 && inc === -1 ) {
|
||||
var lastOver = _.last( coverage.overlaps );
|
||||
if( lastOver ) {
|
||||
lastOver.end = point[1];
|
||||
lastOver.duration = lastOver.end.diff( lastOver.start, 'days' );
|
||||
if( lastOver.duration === 0 ) {
|
||||
coverage.overlaps.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// It's possible that the last gap/overlap didn't have an explicit .end
|
||||
// date.If so, set the end date to the present date and compute the
|
||||
// duration normally.
|
||||
if( coverage.overlaps.length ) {
|
||||
var o = _.last( coverage.overlaps );
|
||||
if( o && !o.end ) {
|
||||
o.end = moment();
|
||||
o.duration = o.end.diff( o.start, 'days' );
|
||||
// Convert the candidate's employment history to an array of dates,
|
||||
// where each element in the array is a start date or an end date of a
|
||||
// job -- it doesn't matter which.
|
||||
let new_e = hist.map( function( job ) {
|
||||
let obj = _.pick( job, ['start', 'end'] );
|
||||
if (obj && (obj.start || obj.end)) {
|
||||
obj = _.pairs( obj );
|
||||
obj[0][1] = FluentDate.fmt( obj[0][1] );
|
||||
if (obj.length > 1) {
|
||||
obj[1][1] = FluentDate.fmt( obj[1][1] );
|
||||
}
|
||||
}
|
||||
if( coverage.gaps.length ) {
|
||||
var g = _.last( coverage.gaps );
|
||||
if( g && !g.end ) {
|
||||
g.end = moment();
|
||||
g.duration = g.end.diff( g.start, 'days' );
|
||||
return obj;
|
||||
});
|
||||
|
||||
// Flatten the array, remove empties, and sort
|
||||
new_e = _.filter(_.flatten( new_e, true ), v => v && v.length && v[0] && v[0].length);
|
||||
|
||||
if (!new_e || !new_e.length) { return coverage; }
|
||||
new_e = _.sortBy(new_e, elem => elem[1].unix());
|
||||
|
||||
// Iterate over elements in the array. Each time a start date is found,
|
||||
// increment a reference count. Each time an end date is found, decrement
|
||||
// the reference count. When the reference count reaches 0, we have a gap.
|
||||
// When the reference count is > 0, the candidate is employed. When the
|
||||
// reference count reaches 2, the candidate is overlapped.
|
||||
|
||||
let ref_count = 0;
|
||||
let total_gap_days = 0;
|
||||
|
||||
new_e.forEach(function(point) {
|
||||
|
||||
const inc = point[0] === 'start' ? 1 : -1;
|
||||
ref_count += inc;
|
||||
|
||||
// If the ref count just reached 0, start a new GAP
|
||||
if (ref_count === 0) {
|
||||
return coverage.gaps.push( { start: point[1], end: null });
|
||||
|
||||
// If the ref count reached 1 by rising, end the last GAP
|
||||
} else if ((ref_count === 1) && (inc === 1)) {
|
||||
const lastGap = _.last( coverage.gaps );
|
||||
if (lastGap) {
|
||||
lastGap.end = point[1];
|
||||
lastGap.duration = lastGap.end.diff( lastGap.start, 'days' );
|
||||
return total_gap_days += lastGap.duration;
|
||||
}
|
||||
|
||||
// If the ref count reaches 2 by rising, start a new OVERLAP
|
||||
} else if ((ref_count === 2) && (inc === 1)) {
|
||||
return coverage.overlaps.push( { start: point[1], end: null });
|
||||
|
||||
// If the ref count reaches 1 by falling, end the last OVERLAP
|
||||
} else if ((ref_count === 1) && (inc === -1)) {
|
||||
const lastOver = _.last( coverage.overlaps );
|
||||
if (lastOver) {
|
||||
lastOver.end = point[1];
|
||||
lastOver.duration = lastOver.end.diff( lastOver.start, 'days' );
|
||||
if (lastOver.duration === 0) {
|
||||
return coverage.overlaps.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Package data for return to the client
|
||||
var tdur = rez.duration('days');
|
||||
var dur = {
|
||||
total: tdur,
|
||||
work: tdur - total_gap_days,
|
||||
gaps: total_gap_days
|
||||
};
|
||||
coverage.pct = ( dur.total > 0 && dur.work > 0 ) ?
|
||||
((((dur.total - dur.gaps) / dur.total) * 100)).toFixed(1) + '%' :
|
||||
'???';
|
||||
coverage.duration = dur;
|
||||
return coverage;
|
||||
|
||||
// It's possible that the last gap/overlap didn't have an explicit .end
|
||||
// date.If so, set the end date to the present date and compute the
|
||||
// duration normally.
|
||||
if (coverage.overlaps.length) {
|
||||
const o = _.last( coverage.overlaps );
|
||||
if (o && !o.end) {
|
||||
o.end = moment();
|
||||
o.duration = o.end.diff( o.start, 'days' );
|
||||
}
|
||||
}
|
||||
|
||||
if (coverage.gaps.length) {
|
||||
const g = _.last( coverage.gaps );
|
||||
if (g && !g.end) {
|
||||
g.end = moment();
|
||||
g.duration = g.end.diff( g.start, 'days' );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
// Package data for return to the client
|
||||
const tdur = rez.duration('days');
|
||||
const dur = {
|
||||
total: tdur,
|
||||
work: tdur - total_gap_days,
|
||||
gaps: total_gap_days
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
coverage.pct = (dur.total > 0) && (dur.work > 0) ? ((((dur.total - dur.gaps) / dur.total) * 100)).toFixed(1) + '%' : '???';
|
||||
coverage.duration = dur;
|
||||
return coverage;
|
||||
}
|
||||
};
|
||||
|
@ -1,98 +1,74 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Keyword analysis for HackMyResume.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module keyword-inspector.js
|
||||
@module inspectors/keyword-inspector
|
||||
*/
|
||||
|
||||
/**
|
||||
Analyze the resume's use of keywords.
|
||||
TODO: BUG: Keyword search regex is inaccurate, especially for one or two
|
||||
letter keywords like "C" or "CLI".
|
||||
@class keywordInspector
|
||||
*/
|
||||
module.exports = {
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
|
||||
var _ = require('underscore');
|
||||
var FluentDate = require('../core/fluent-date');
|
||||
|
||||
|
||||
/** A unique name for this inspector. */
|
||||
moniker: 'keyword-inspector',
|
||||
|
||||
/**
|
||||
Analyze the resume's use of keywords.
|
||||
TODO: BUG: Keyword search regex is inaccurate, especially for one or two
|
||||
letter keywords like "C" or "CLI".
|
||||
@class keywordInspector
|
||||
Run the Keyword Inspector on a resume.
|
||||
@method run
|
||||
@return An collection of statistical keyword data.
|
||||
*/
|
||||
var keywordInspector = module.exports = {
|
||||
run( rez ) {
|
||||
|
||||
// "Quote" or safely escape a keyword so it can be used as a regex. For
|
||||
// example, if the keyword is "C++", yield "C\+\+".
|
||||
// http://stackoverflow.com/a/2593661/4942583
|
||||
const regex_quote = str => (str + '').replace(/[.?*+^$[\]\\(){}|-]/ig, '\\$&');
|
||||
|
||||
// Create a searchable plain-text digest of the resume
|
||||
// TODO: BUG: Don't search within keywords for other keywords. Job A
|
||||
// declares the "foo" keyword. Job B declares the "foo & bar" keyword. Job
|
||||
// B's mention of "foobar" should not count as a mention of "foo".
|
||||
// To achieve this, remove keywords from the search digest and treat them
|
||||
// separately.
|
||||
let searchable = '';
|
||||
rez.transformStrings(['imp', 'computed', 'safe'], ( key, val ) => searchable += ` ${val}`);
|
||||
|
||||
/**
|
||||
A unique name for this inspector.
|
||||
*/
|
||||
moniker: 'keyword-inspector',
|
||||
// Assemble a regex skeleton we can use to test for keywords with a bit
|
||||
// more
|
||||
const prefix = `(?:${['^', '\\s+', '[\\.,]+'].join('|')})`;
|
||||
const suffix = `(?:${['$', '\\s+', '[\\.,]+'].join('|')})`;
|
||||
|
||||
return rez.keywords().map(function(kw) {
|
||||
|
||||
// 1. Using word boundary or other regex class is inaccurate
|
||||
//
|
||||
// var regex = new RegExp( '\\b' + regex_quote( kw )/* + '\\b'*/, 'ig');
|
||||
//
|
||||
// 2. Searching for the raw keyword is inaccurate ("C" will match any
|
||||
// word containing a 'c'!).
|
||||
//
|
||||
// var regex = new RegExp( regex_quote( kw ), 'ig');
|
||||
//
|
||||
// 3. Instead, use a custom regex with special delimeters.
|
||||
|
||||
/**
|
||||
Run the Keyword Inspector on a resume.
|
||||
@method run
|
||||
@return An collection of statistical keyword data.
|
||||
*/
|
||||
run: function( rez ) {
|
||||
|
||||
// "Quote" or safely escape a keyword so it can be used as a regex. For
|
||||
// example, if the keyword is "C++", yield "C\+\+".
|
||||
// http://stackoverflow.com/a/2593661/4942583
|
||||
function regex_quote(str) {
|
||||
return (str + '').replace(/[.?*+^$[\]\\(){}|-]/ig, "\\$&");
|
||||
const regex_str = prefix + regex_quote( kw ) + suffix;
|
||||
const regex = new RegExp( regex_str, 'ig');
|
||||
let count = 0;
|
||||
while (regex.exec( searchable ) !== null) {
|
||||
count++;
|
||||
}
|
||||
|
||||
// Create a searchable plain-text digest of the resume
|
||||
// TODO: BUG: Don't search within keywords for other keywords. Job A
|
||||
// declares the "foo" keyword. Job B declares the "foo & bar" keyword. Job
|
||||
// B's mention of "foobar" should not count as a mention of "foo".
|
||||
// To achieve this, remove keywords from the search digest and treat them
|
||||
// separately.
|
||||
var searchable = '';
|
||||
rez.transformStrings( ['imp', 'computed', 'safe'], function trxString( key, val ) {
|
||||
searchable += ' ' + val;
|
||||
});
|
||||
|
||||
// Assemble a regex skeleton we can use to test for keywords with a bit
|
||||
// more
|
||||
var prefix = '(?:' + ['^', '\\s+', '[\\.,]+'].join('|') + ')';
|
||||
var suffix = '(?:' + ['$', '\\s+', '[\\.,]+'].join('|') + ')';
|
||||
|
||||
return rez.keywords().map(function(kw) {
|
||||
|
||||
// 1. Using word boundary or other regex class is inaccurate
|
||||
//
|
||||
// var regex = new RegExp( '\\b' + regex_quote( kw )/* + '\\b'*/, 'ig');
|
||||
//
|
||||
// 2. Searching for the raw keyword is inaccurate ("C" will match any
|
||||
// word containing a 'c'!).
|
||||
//
|
||||
// var regex = new RegExp( regex_quote( kw ), 'ig');
|
||||
//
|
||||
// 3. Instead, use a custom regex with special delimeters.
|
||||
|
||||
var regex_str = prefix + regex_quote( kw ) + suffix;
|
||||
var regex = new RegExp( regex_str, 'ig');
|
||||
var myArray, count = 0;
|
||||
while ((myArray = regex.exec( searchable )) !== null) {
|
||||
count++;
|
||||
}
|
||||
return {
|
||||
name: kw,
|
||||
count: count
|
||||
};
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
return {
|
||||
name: kw,
|
||||
count
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1,63 +1,46 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Section analysis for HackMyResume.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module totals-inspector.js
|
||||
@module inspectors/totals-inspector
|
||||
*/
|
||||
|
||||
const _ = require('underscore');
|
||||
|
||||
/**
|
||||
Retrieve sectional overview and summary information.
|
||||
@class totalsInspector
|
||||
*/
|
||||
module.exports = {
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
|
||||
var _ = require('underscore');
|
||||
var FluentDate = require('../core/fluent-date');
|
||||
|
||||
|
||||
moniker: 'totals-inspector',
|
||||
|
||||
/**
|
||||
Retrieve sectional overview and summary information.
|
||||
@class totalsInspector
|
||||
Run the Totals Inspector on a resume.
|
||||
@method run
|
||||
@return An object containing summary information for each section on the
|
||||
resume.
|
||||
*/
|
||||
var totalsInspector = module.exports = {
|
||||
run( rez ) {
|
||||
|
||||
const sectionTotals = { };
|
||||
_.each(rez, function(val, key) {
|
||||
if (_.isArray( val ) && !_.isString(val)) {
|
||||
return sectionTotals[ key ] = val.length;
|
||||
} else if (val.history && _.isArray( val.history )) {
|
||||
return sectionTotals[ key ] = val.history.length;
|
||||
} else if (val.sets && _.isArray( val.sets )) {
|
||||
return sectionTotals[ key ] = val.sets.length;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
moniker: 'totals-inspector',
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Run the Totals Inspector on a resume.
|
||||
@method run
|
||||
@return An object containing summary information for each section on the
|
||||
resume.
|
||||
*/
|
||||
run: function( rez ) {
|
||||
|
||||
var sectionTotals = { };
|
||||
_.each( rez, function(val, key){
|
||||
if( _.isArray( val ) && !_.isString(val) ) {
|
||||
sectionTotals[ key ] = val.length;
|
||||
}
|
||||
else if( val.history && _.isArray( val.history ) ) {
|
||||
sectionTotals[ key ] = val.history.length;
|
||||
}
|
||||
else if( val.sets && _.isArray( val.sets ) ) {
|
||||
sectionTotals[ key ] = val.sets.length;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
totals: sectionTotals,
|
||||
numSections: Object.keys( sectionTotals ).length
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
return {
|
||||
totals: sectionTotals,
|
||||
numSections: Object.keys( sectionTotals ).length
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the HandlebarsGenerator class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@ -5,115 +10,109 @@ Definition of the HandlebarsGenerator class.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const _ = require('underscore');
|
||||
const HANDLEBARS = require('handlebars');
|
||||
const FS = require('fs');
|
||||
const registerHelpers = require('../helpers/handlebars-helpers');
|
||||
const PATH = require('path');
|
||||
const parsePath = require('parse-filepath');
|
||||
const READFILES = require('recursive-readdir-sync');
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const SLASH = require('slash');
|
||||
|
||||
|
||||
|
||||
var _ = require('underscore')
|
||||
, HANDLEBARS = require('handlebars')
|
||||
, FS = require('fs')
|
||||
, registerHelpers = require('../helpers/handlebars-helpers')
|
||||
, PATH = require('path')
|
||||
, parsePath = require('parse-filepath')
|
||||
, READFILES = require('recursive-readdir-sync')
|
||||
, HMSTATUS = require('../core/status-codes')
|
||||
, SLASH = require('slash');
|
||||
/**
|
||||
Perform template-based resume generation using Handlebars.js.
|
||||
@class HandlebarsGenerator
|
||||
*/
|
||||
module.exports = {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Perform template-based resume generation using Handlebars.js.
|
||||
@class HandlebarsGenerator
|
||||
*/
|
||||
var HandlebarsGenerator = module.exports = {
|
||||
generateSimple( data, tpl ) {
|
||||
|
||||
|
||||
|
||||
generateSimple: function( data, tpl ) {
|
||||
|
||||
try {
|
||||
// Compile and run the Handlebars template.
|
||||
var template = HANDLEBARS.compile( tpl, { strict: false, assumeObjects: false } );
|
||||
return template( data );
|
||||
let template;
|
||||
try {
|
||||
// Compile and run the Handlebars template.
|
||||
template = HANDLEBARS.compile(tpl, {
|
||||
strict: false,
|
||||
assumeObjects: false,
|
||||
noEscape: data.opts.noescape
|
||||
}
|
||||
catch( ex ) {
|
||||
throw {
|
||||
fluenterror: template ?
|
||||
HMSTATUS.invokeTemplate : HMSTATUS.compileTemplate,
|
||||
inner: ex
|
||||
};
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
generate: function( json, jst, format, curFmt, opts, theme ) {
|
||||
|
||||
// Set up partials and helpers
|
||||
registerPartials( format, theme );
|
||||
registerHelpers( theme, opts );
|
||||
|
||||
// Preprocess text
|
||||
var encData = json;
|
||||
( format === 'html' || format === 'pdf' ) && (encData = json.markdownify());
|
||||
( format === 'doc' ) && (encData = json.xmlify());
|
||||
|
||||
// Set up the context
|
||||
var ctx = {
|
||||
r: encData,
|
||||
RAW: json,
|
||||
filt: opts.filters,
|
||||
format: format,
|
||||
opts: opts,
|
||||
engine: this,
|
||||
results: curFmt.files,
|
||||
headFragment: opts.headFragment || ''
|
||||
};
|
||||
|
||||
// Render the template
|
||||
return this.generateSimple( ctx, jst );
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
function registerPartials(format, theme) {
|
||||
if( _.contains( ['html','doc','md','txt'], format )) {
|
||||
|
||||
// Locate the global partials folder
|
||||
var partialsFolder = PATH.join(
|
||||
parsePath( require.resolve('fresh-themes') ).dirname,
|
||||
'/partials/',
|
||||
format
|
||||
);
|
||||
return template(data);
|
||||
} catch (err) {
|
||||
throw{
|
||||
fluenterror:
|
||||
HMSTATUS[ template ? 'invokeTemplate' : 'compileTemplate' ],
|
||||
inner: err
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
// Register global partials in the /partials/[format] folder
|
||||
// TODO: Only do this once per HMR invocation.
|
||||
_.each( READFILES( partialsFolder, function(error){ }), function( el ) {
|
||||
var pathInfo = parsePath( el );
|
||||
var name = SLASH( PATH.relative( partialsFolder, el )
|
||||
.replace(/\.(?:html|xml|hbs|md|txt)$/i, '') );
|
||||
var tplData = FS.readFileSync( el, 'utf8' );
|
||||
var compiledTemplate = HANDLEBARS.compile( tplData );
|
||||
HANDLEBARS.registerPartial( name, compiledTemplate );
|
||||
theme.partialsInitialized = true;
|
||||
});
|
||||
|
||||
|
||||
generate( json, jst, format, curFmt, opts, theme ) {
|
||||
|
||||
// Preprocess text
|
||||
let encData = json;
|
||||
if ((format === 'html') || (format === 'pdf')) {
|
||||
encData = json.markdownify();
|
||||
}
|
||||
if( format === 'doc' ) {
|
||||
encData = json.xmlify();
|
||||
}
|
||||
|
||||
// Register theme-specific partials
|
||||
_.each( theme.partials, function( el ) {
|
||||
var tplData = FS.readFileSync( el.path, 'utf8' );
|
||||
var compiledTemplate = HANDLEBARS.compile( tplData );
|
||||
HANDLEBARS.registerPartial( el.name, compiledTemplate );
|
||||
// Set up partials and helpers
|
||||
registerPartials(format, theme);
|
||||
registerHelpers(theme, encData, opts);
|
||||
|
||||
// Set up the context
|
||||
const ctx = {
|
||||
r: encData,
|
||||
RAW: json,
|
||||
filt: opts.filters,
|
||||
format,
|
||||
opts,
|
||||
engine: this,
|
||||
results: curFmt.files,
|
||||
headFragment: opts.headFragment || ''
|
||||
};
|
||||
|
||||
// Render the template
|
||||
return this.generateSimple(ctx, jst);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
var registerPartials = function(format, theme) {
|
||||
|
||||
if (_.contains( ['html','doc','md','txt','pdf'], format )) {
|
||||
|
||||
// Locate the global partials folder
|
||||
const partialsFolder = PATH.join(
|
||||
parsePath( require.resolve('fresh-themes') ).dirname,
|
||||
'/partials/',
|
||||
format === 'pdf' ? 'html' : format
|
||||
);
|
||||
|
||||
// Register global partials in the /partials/[format] folder
|
||||
// TODO: Only do this once per HMR invocation.
|
||||
_.each(READFILES( partialsFolder ), function( el ) {
|
||||
const name = SLASH(PATH.relative( partialsFolder, el ).replace(/\.(?:html|xml|hbs|md|txt)$/i, ''));
|
||||
const tplData = FS.readFileSync(el, 'utf8');
|
||||
const compiledTemplate = HANDLEBARS.compile(tplData);
|
||||
HANDLEBARS.registerPartial(name, compiledTemplate);
|
||||
return theme.partialsInitialized = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}());
|
||||
// Register theme-specific partials
|
||||
return _.each(theme.partials, function( el ) {
|
||||
const tplData = FS.readFileSync(el.path, 'utf8');
|
||||
const compiledTemplate = HANDLEBARS.compile(tplData);
|
||||
return HANDLEBARS.registerPartial(el.name, compiledTemplate);
|
||||
});
|
||||
};
|
||||
|
@ -1,65 +1,45 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the JRSGenerator class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module jrs-generator.js
|
||||
@module renderers/jrs-generator
|
||||
*/
|
||||
|
||||
const MD = require('marked');
|
||||
|
||||
/**
|
||||
Perform template-based resume generation for JSON Resume themes.
|
||||
@class JRSGenerator
|
||||
*/
|
||||
|
||||
(function() {
|
||||
module.exports = {
|
||||
|
||||
generate( json, jst, format, cssInfo, opts, theme ) {
|
||||
|
||||
// Disable JRS theme chatter (console.log, console.error, etc.)
|
||||
const turnoff = ['log', 'error', 'dir'];
|
||||
const org = turnoff.map(function(c) {
|
||||
const ret = console[c]; // eslint-disable-line no-console
|
||||
console[c] = function() {}; // eslint-disable-line no-console
|
||||
return ret;
|
||||
});
|
||||
|
||||
var _ = require('underscore')
|
||||
, HANDLEBARS = require('handlebars')
|
||||
, FS = require('fs')
|
||||
, registerHelpers = require('../helpers/handlebars-helpers')
|
||||
, PATH = require('path')
|
||||
, parsePath = require('parse-filepath')
|
||||
, READFILES = require('recursive-readdir-sync')
|
||||
, SLASH = require('slash')
|
||||
, MD = require('marked');
|
||||
// Freeze and render
|
||||
let rezHtml = theme.render(json.harden());
|
||||
|
||||
// Turn logging back on
|
||||
turnoff.forEach((c, idx) => console[c] = org[idx]); // eslint-disable-line no-console
|
||||
|
||||
|
||||
/**
|
||||
Perform template-based resume generation for JSON Resume themes.
|
||||
@class JRSGenerator
|
||||
*/
|
||||
var JRSGenerator = module.exports = {
|
||||
|
||||
|
||||
|
||||
|
||||
generate: function( json, jst, format, cssInfo, opts, theme ) {
|
||||
|
||||
// Disable JRS theme chatter (console.log, console.error, etc.)
|
||||
var off = ['log', 'error', 'dir'], org = off.map(function(c){
|
||||
var ret = console[c]; console[c] = function(){}; return ret;
|
||||
});
|
||||
|
||||
// Freeze and render
|
||||
var rezHtml = theme.render( json.harden() );
|
||||
|
||||
// Turn logging back on
|
||||
off.forEach(function(c, idx){ console[c] = org[idx]; });
|
||||
|
||||
// Unfreeze and apply Markdown
|
||||
rezHtml = rezHtml.replace( /@@@@~.*?~@@@@/gm, function(val){
|
||||
return MDIN( val.replace( /~@@@@/gm,'' ).replace( /@@@@~/gm,'' ) );
|
||||
});
|
||||
|
||||
return rezHtml;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
function MDIN(txt) { // TODO: Move this
|
||||
return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
||||
// Unfreeze and apply Markdown
|
||||
return rezHtml = rezHtml.replace(/@@@@~[\s\S]*?~@@@@/g, val => MDIN( val.replace( /~@@@@/g,'' ).replace( /@@@@~/g,'' ) ));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}());
|
||||
var MDIN = txt => // TODO: Move this
|
||||
MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '')
|
||||
;
|
||||
|
@ -1,73 +1,90 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the UnderscoreGenerator class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module underscore-generator.js
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
const _ = require('underscore');
|
||||
const registerHelpers = require('../helpers/underscore-helpers');
|
||||
require('../utils/string');
|
||||
const escapeLaTeX = require('escape-latex');
|
||||
|
||||
/**
|
||||
Perform template-based resume generation using Underscore.js.
|
||||
@class UnderscoreGenerator
|
||||
*/
|
||||
module.exports = {
|
||||
|
||||
|
||||
|
||||
var _ = require('underscore')
|
||||
, registerHelpers = require('../helpers/underscore-helpers')
|
||||
, HMSTATUS = require('../core/status-codes');
|
||||
|
||||
|
||||
/**
|
||||
Perform template-based resume generation using Underscore.js.
|
||||
@class UnderscoreGenerator
|
||||
*/
|
||||
var UnderscoreGenerator = module.exports = {
|
||||
|
||||
generateSimple: function( data, tpl ) {
|
||||
|
||||
try {
|
||||
// Compile and run the Handlebars template.
|
||||
var template = _.template( tpl );
|
||||
return template( data );
|
||||
}
|
||||
catch( ex ) {
|
||||
throw {
|
||||
fluenterror: template ?
|
||||
HMSTATUS.invokeTemplate : HMSTATUS.compileTemplate,
|
||||
inner: ex
|
||||
};
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
generate: function( json, jst, format, cssInfo, opts, theme ) {
|
||||
|
||||
// Tweak underscore's default template delimeters
|
||||
var delims = (opts.themeObj && opts.themeObj.delimeters) || opts.template;
|
||||
if( opts.themeObj && opts.themeObj.delimeters ) {
|
||||
delims = _.mapObject( delims, function(val,key) {
|
||||
return new RegExp( val, "ig");
|
||||
});
|
||||
}
|
||||
_.templateSettings = delims;
|
||||
|
||||
// Strip {# comments #}
|
||||
jst = jst.replace( delims.comment, '');
|
||||
|
||||
var ctx = {
|
||||
r: format === 'html' || format === 'pdf' || format === 'png' ? json.markdownify() : json,
|
||||
filt: opts.filters,
|
||||
XML: require('xml-escape'),
|
||||
RAW: json,
|
||||
cssInfo: cssInfo,
|
||||
//engine: this,
|
||||
headFragment: opts.headFragment || '',
|
||||
opts: opts
|
||||
generateSimple( data, tpl ) {
|
||||
let t;
|
||||
try {
|
||||
// Compile and run the Handlebars template.
|
||||
t = _.template(tpl);
|
||||
return t(data);
|
||||
} catch (err) {
|
||||
//console.dir _error
|
||||
const HMS = require('../core/status-codes');
|
||||
throw{
|
||||
fluenterror: HMS[t ? 'invokeTemplate' : 'compileTemplate'],
|
||||
inner: err
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
registerHelpers( theme, opts, cssInfo, ctx, this );
|
||||
|
||||
return this.generateSimple( ctx, jst );
|
||||
|
||||
generate( json, jst, format, cssInfo, opts, theme ) {
|
||||
|
||||
// Tweak underscore's default template delimeters
|
||||
let delims = (opts.themeObj && opts.themeObj.delimeters) || opts.template;
|
||||
if (opts.themeObj && opts.themeObj.delimeters) {
|
||||
delims = _.mapObject(delims, (val) => new RegExp(val, 'ig'));
|
||||
}
|
||||
_.templateSettings = delims;
|
||||
|
||||
// Massage resume strings / text
|
||||
let r = null;
|
||||
switch (format) {
|
||||
case 'html': r = json.markdownify(); break;
|
||||
case 'pdf': r = json.markdownify(); break;
|
||||
case 'png': r = json.markdownify(); break;
|
||||
case 'latex':
|
||||
var traverse = require('traverse');
|
||||
r = traverse(json).map(function() {
|
||||
if (this.isLeaf && String.is(this.node)) {
|
||||
return escapeLaTeX(this.node);
|
||||
}
|
||||
return this.node;
|
||||
});
|
||||
break;
|
||||
default: r = json;
|
||||
}
|
||||
|
||||
};
|
||||
// Set up the context
|
||||
const ctx = {
|
||||
r,
|
||||
filt: opts.filters,
|
||||
XML: require('xml-escape'),
|
||||
RAW: json,
|
||||
cssInfo,
|
||||
//engine: @
|
||||
headFragment: opts.headFragment || '',
|
||||
opts
|
||||
};
|
||||
|
||||
// Link to our helpers
|
||||
registerHelpers(theme, opts, cssInfo, ctx, this);
|
||||
|
||||
|
||||
}());
|
||||
// Generate!
|
||||
return this.generateSimple(ctx, jst);
|
||||
}
|
||||
};
|
||||
|
@ -1,72 +0,0 @@
|
||||
/**
|
||||
Definition of John Resig's `Class` class.
|
||||
@module class.js
|
||||
*/
|
||||
|
||||
/* Simple JavaScript Inheritance
|
||||
* By John Resig http://ejohn.org/
|
||||
* MIT Licensed.
|
||||
* http://ejohn.org/blog/simple-javascript-inheritance/
|
||||
*/
|
||||
// Inspired by base2 and Prototype
|
||||
(function(){
|
||||
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
|
||||
|
||||
// The base Class implementation (does nothing)
|
||||
this.Class = function(){};
|
||||
module.exports = Class;
|
||||
|
||||
// Create a new Class that inherits from this class
|
||||
Class.extend = function(prop) {
|
||||
var _super = this.prototype;
|
||||
|
||||
// Instantiate a base class (but only create the instance,
|
||||
// don't run the init constructor)
|
||||
initializing = true;
|
||||
var prototype = new this();
|
||||
initializing = false;
|
||||
|
||||
// Copy the properties over onto the new prototype
|
||||
for (var name in prop) {
|
||||
// Check if we're overwriting an existing function
|
||||
prototype[name] = typeof prop[name] == "function" &&
|
||||
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
|
||||
(function(name, fn){
|
||||
return function() {
|
||||
var tmp = this._super;
|
||||
|
||||
// Add a new ._super() method that is the same method
|
||||
// but on the super-class
|
||||
this._super = _super[name];
|
||||
|
||||
// The method only need to be bound temporarily, so we
|
||||
// remove it when we're done executing
|
||||
var ret = fn.apply(this, arguments);
|
||||
this._super = tmp;
|
||||
|
||||
return ret;
|
||||
};
|
||||
})(name, prop[name]) : // jshint ignore:line
|
||||
prop[name];
|
||||
}
|
||||
|
||||
// The dummy class constructor
|
||||
function Class() {
|
||||
// All construction is actually done in the init method
|
||||
if ( !initializing && this.init )
|
||||
this.init.apply(this, arguments);
|
||||
}
|
||||
|
||||
// Populate our constructed prototype object
|
||||
Class.prototype = prototype;
|
||||
|
||||
// Enforce the constructor to be what we expect
|
||||
Class.prototype.constructor = Class;
|
||||
|
||||
// And make this class extendable
|
||||
Class.extend = arguments.callee;
|
||||
|
||||
return Class;
|
||||
};
|
||||
|
||||
})();
|
@ -1,12 +1,11 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the SyntaxErrorEx class.
|
||||
@module file-contains.js
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
module.exports = function( file, needle ) {
|
||||
return require('fs').readFileSync(file,'utf-8').indexOf( needle ) > -1;
|
||||
};
|
||||
|
||||
}());
|
||||
module.exports = ( file, needle ) => require('fs').readFileSync(file,'utf-8').indexOf( needle ) > -1;
|
||||
|
27
src/utils/fresh-version-regex.js
Normal file
27
src/utils/fresh-version-regex.js
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Defines a regex suitable for matching FRESH versions.
|
||||
@module file-contains.js
|
||||
*/
|
||||
|
||||
// Set up a regex that matches all of the following:
|
||||
//
|
||||
// - FRESH
|
||||
// - JRS
|
||||
// - FRESCA
|
||||
// - FRESH@1.0.0
|
||||
// - FRESH@1.0
|
||||
// - FRESH@1
|
||||
// - JRS@0.16.0
|
||||
// - JRS@0.16
|
||||
// - JRS@0
|
||||
//
|
||||
// Don't use a SEMVER regex (eg, NPM's semver-regex) because a) we want to
|
||||
// support partial semvers like "0" or "1.2" and b) we'll expand this later to
|
||||
// support fully scoped FRESH versions.
|
||||
|
||||
module.exports = () => RegExp('^(FRESH|FRESCA|JRS)(?:@(\\d+(?:\\.\\d+)?(?:\\.\\d+)?))?$');
|
@ -1,66 +1,65 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the Markdown to WordProcessingML conversion routine.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@module html-to-wpml.js
|
||||
@module utils/html-to-wpml
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
var _ = require('underscore');
|
||||
var HTML5Tokenizer = require('simple-html-tokenizer');
|
||||
const XML = require('xml-escape');
|
||||
const _ = require('underscore');
|
||||
const HTML5Tokenizer = require('simple-html-tokenizer');
|
||||
|
||||
module.exports = function( html ) {
|
||||
module.exports = function( html ) {
|
||||
|
||||
// Tokenize the HTML stream.
|
||||
var tokens = HTML5Tokenizer.tokenize( html );
|
||||
// Tokenize the HTML stream.
|
||||
let is_bold, is_italic, is_link, link_url;
|
||||
const tokens = HTML5Tokenizer.tokenize( html );
|
||||
let final = (is_bold = (is_italic = (is_link = (link_url = ''))));
|
||||
|
||||
var final = '', is_bold, is_italic, is_link, link_url;
|
||||
// Process <em>, <strong>, and <a> elements in the HTML stream, producing
|
||||
// equivalent WordProcessingML that can be dumped into a <w:p> or other
|
||||
// text container element.
|
||||
_.each(tokens, function( tok ) {
|
||||
|
||||
// Process <em>, <strong>, and <a> elements in the HTML stream, producing
|
||||
// equivalent WordProcessingML that can be dumped into a <w:p> or other
|
||||
// text container element.
|
||||
_.each( tokens, function( tok ) {
|
||||
switch (tok.type) {
|
||||
|
||||
switch( tok.type ) {
|
||||
case 'StartTag':
|
||||
switch (tok.tagName) {
|
||||
case 'p': return final += '<w:p>';
|
||||
case 'strong': return is_bold = true;
|
||||
case 'em': return is_italic = true;
|
||||
case 'a':
|
||||
is_link = true;
|
||||
return link_url = tok.attributes.filter(attr => attr[0] === 'href')[0][1];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'StartTag':
|
||||
switch( tok.tagName ) {
|
||||
case 'p': final += '<w:p>'; break;
|
||||
case 'strong': is_bold = true; break;
|
||||
case 'em': is_italic = true; break;
|
||||
case 'a':
|
||||
is_link = true;
|
||||
link_url = tok.attributes.filter(function(attr){
|
||||
return attr[0] === 'href'; }
|
||||
)[0][1];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'EndTag':
|
||||
switch (tok.tagName) {
|
||||
case 'p': return final += '</w:p>';
|
||||
case 'strong': return is_bold = false;
|
||||
case 'em': return is_italic = false;
|
||||
case 'a': return is_link = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'EndTag':
|
||||
switch( tok.tagName ) {
|
||||
case 'p': final += '</w:p>'; break;
|
||||
case 'strong': is_bold = false; break;
|
||||
case 'em': is_italic = false; break;
|
||||
case 'a': is_link = false; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Chars':
|
||||
if( tok.chars.trim().length ) {
|
||||
var style = is_bold ? '<w:b/>' : '';
|
||||
style += is_italic ? '<w:i/>': '';
|
||||
case 'Chars':
|
||||
if( tok.chars.trim().length ) {
|
||||
let style = is_bold ? '<w:b/>' : '';
|
||||
style += is_italic ? '<w:i/>' : '';
|
||||
style += is_link ? '<w:rStyle w:val="Hyperlink"/>' : '';
|
||||
final +=
|
||||
(is_link ? ('<w:hlink w:dest="' + link_url + '">') : '') +
|
||||
'<w:r><w:rPr>' + style + '</w:rPr><w:t>' + tok.chars +
|
||||
return final +=
|
||||
(is_link ? (`<w:hlink w:dest="${link_url}">`) : '') +
|
||||
'<w:r><w:rPr>' + style + '</w:rPr><w:t>' + XML(tok.chars) +
|
||||
'</w:t></w:r>' + (is_link ? '</w:hlink>' : '');
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
return final;
|
||||
|
||||
};
|
||||
|
||||
}());
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
return final;
|
||||
};
|
||||
|
@ -1,19 +1,20 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Inline Markdown-to-Chalk conversion routines.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module md2chalk.js
|
||||
@module utils/md2chalk
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
var MD = require('marked');
|
||||
var CHALK = require('chalk');
|
||||
var LO = require('lodash');
|
||||
const CHALK = require('chalk');
|
||||
const LO = require('lodash');
|
||||
|
||||
module.exports = function( v, style, boldStyle ) {
|
||||
boldStyle = boldStyle || 'bold';
|
||||
var temp = v.replace(/\*\*(.*?)\*\*/g, LO.get( CHALK, boldStyle )('$1'));
|
||||
return style ? LO.get( CHALK, style )(temp) : temp;
|
||||
};
|
||||
|
||||
}());
|
||||
module.exports = function( v, style, boldStyle ) {
|
||||
boldStyle = boldStyle || 'bold';
|
||||
const temp = v.replace(/\*\*(.*?)\*\*/g, LO.get( CHALK, boldStyle )('$1'));
|
||||
if (style) { return LO.get( CHALK, style )(temp); } else { return temp; }
|
||||
};
|
||||
|
@ -1,12 +1,16 @@
|
||||
// Exemplar script for generating documents with Phantom.js.
|
||||
// https://raw.githubusercontent.com/ariya/phantomjs/master/examples/rasterize.js
|
||||
|
||||
/* eslint-disable */
|
||||
(function() {
|
||||
|
||||
// Exemplar script for generating documents with Phantom.js.
|
||||
// https://raw.githubusercontent.com/ariya/phantomjs/master/examples/rasterize.js
|
||||
// Converted to CoffeeScript by hacksalot
|
||||
"use strict";
|
||||
var page = require('webpage').create(),
|
||||
system = require('system'),
|
||||
address, output, size;
|
||||
var address, output, page, pageHeight, pageWidth, size, system;
|
||||
|
||||
page = require('webpage').create();
|
||||
|
||||
system = require('system');
|
||||
|
||||
address = output = size = null;
|
||||
|
||||
if (system.args.length < 3 || system.args.length > 5) {
|
||||
console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
|
||||
@ -17,35 +21,56 @@
|
||||
} else {
|
||||
address = system.args[1];
|
||||
output = system.args[2];
|
||||
page.viewportSize = { width: 600, height: 600 };
|
||||
page.viewportSize = {
|
||||
width: 600,
|
||||
height: 600
|
||||
};
|
||||
if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") {
|
||||
size = system.args[3].split('*');
|
||||
page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' }
|
||||
: { format: system.args[3], orientation: 'portrait', margin: '1cm' };
|
||||
page.paperSize = size.length === 2 ? {
|
||||
width: size[0],
|
||||
height: size[1],
|
||||
margin: '0px'
|
||||
} : {
|
||||
format: system.args[3],
|
||||
orientation: 'portrait',
|
||||
margin: '1cm'
|
||||
};
|
||||
} else if (system.args.length > 3 && system.args[3].substr(-2) === "px") {
|
||||
size = system.args[3].split('*');
|
||||
if (size.length === 2) {
|
||||
pageWidth = parseInt(size[0], 10);
|
||||
pageHeight = parseInt(size[1], 10);
|
||||
page.viewportSize = { width: pageWidth, height: pageHeight };
|
||||
page.clipRect = { top: 0, left: 0, width: pageWidth, height: pageHeight };
|
||||
page.viewportSize = {
|
||||
width: pageWidth,
|
||||
height: pageHeight
|
||||
};
|
||||
page.clipRect = {
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: pageWidth,
|
||||
height: pageHeight
|
||||
};
|
||||
} else {
|
||||
console.log("size:", system.args[3]);
|
||||
pageWidth = parseInt(system.args[3], 10);
|
||||
pageHeight = parseInt(pageWidth * 3/4, 10); // it's as good an assumption as any
|
||||
console.log ("pageHeight:",pageHeight);
|
||||
page.viewportSize = { width: pageWidth, height: pageHeight };
|
||||
pageHeight = parseInt(pageWidth * 3 / 4, 10); // it's as good an assumption as any
|
||||
console.log("pageHeight:", pageHeight);
|
||||
page.viewportSize = {
|
||||
width: pageWidth,
|
||||
height: pageHeight
|
||||
};
|
||||
}
|
||||
}
|
||||
if (system.args.length > 4) {
|
||||
page.zoomFactor = system.args[4];
|
||||
}
|
||||
page.open(address, function (status) {
|
||||
page.open(address, function(status) {
|
||||
if (status !== 'success') {
|
||||
console.log('Unable to load the address!');
|
||||
phantom.exit(1);
|
||||
} else {
|
||||
window.setTimeout(function () {
|
||||
return window.setTimeout(function() {
|
||||
page.render(output);
|
||||
phantom.exit();
|
||||
}, 200);
|
||||
@ -53,4 +78,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
}());
|
||||
}).call(this);
|
||||
|
||||
/* eslint-enable */
|
||||
//# sourceMappingURL=rasterize.js.map
|
||||
|
20
src/utils/resume-detector.js
Normal file
20
src/utils/resume-detector.js
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the ResumeDetector class.
|
||||
@module utils/resume-detector
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
module.exports = function( rez ) {
|
||||
if (rez.meta && rez.meta.format) { //&& rez.meta.format.substr(0, 5).toUpperCase() == 'FRESH'
|
||||
return 'fresh';
|
||||
} else if (rez.basics) {
|
||||
return 'jrs';
|
||||
} else {
|
||||
return 'unk';
|
||||
}
|
||||
};
|
62
src/utils/resume-scrubber.js
Normal file
62
src/utils/resume-scrubber.js
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
|
||||
const _ = require('underscore');
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
Removes ignored or private fields from a resume object
|
||||
@returns an object with the following structure:
|
||||
{
|
||||
scrubbed: the processed resume object
|
||||
ignoreList: an array of ignored nodes that were removed
|
||||
privateList: an array of private nodes that were removed
|
||||
}
|
||||
*/
|
||||
scrubResume(rep, opts) {
|
||||
const traverse = require('traverse');
|
||||
const ignoreList = [];
|
||||
const privateList = [];
|
||||
const includePrivates = opts && opts.private;
|
||||
|
||||
const scrubbed = traverse( rep ).map(function() { // [^1]
|
||||
if (!this.isLeaf) {
|
||||
if ((this.node.ignore === true) || (this.node.ignore === 'true')) {
|
||||
ignoreList.push(this.node);
|
||||
this.delete();
|
||||
} else if (((this.node.private === true) || (this.node.private === 'true')) && !includePrivates) {
|
||||
privateList.push(this.node);
|
||||
this.delete();
|
||||
}
|
||||
}
|
||||
if (_.isArray(this.node)) { // [^2]
|
||||
this.after(function() {
|
||||
this.update(_.compact(this.node));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
scrubbed,
|
||||
ingoreList: ignoreList,
|
||||
privateList
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// [^1]: As of v0.6.6, the NPM traverse library has a quirk when attempting
|
||||
// to remove array elements directly using traverse's `this.remove`. See:
|
||||
//
|
||||
// https://github.com/substack/js-traverse/issues/48
|
||||
//
|
||||
// [^2]: The workaround is to use traverse's 'this.delete' to nullify the value
|
||||
// first, followed by removal with something like _.compact.
|
||||
//
|
||||
// https://github.com/substack/js-traverse/issues/48#issuecomment-142607200
|
||||
//
|
@ -1,46 +1,34 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the SafeJsonLoader class.
|
||||
@module syntax-error-ex.js
|
||||
@module utils/safe-json-loader
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
const FS = require('fs');
|
||||
const SyntaxErrorEx = require('./syntax-error-ex');
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
|
||||
var FS = require('fs')
|
||||
, SyntaxErrorEx = require('./syntax-error-ex');
|
||||
|
||||
|
||||
|
||||
module.exports = function loadSafeJson( file ) {
|
||||
|
||||
var ret = { };
|
||||
try {
|
||||
|
||||
ret.raw = FS.readFileSync( file, 'utf8' );
|
||||
ret.json = JSON.parse( ret.raw );
|
||||
|
||||
}
|
||||
catch( ex ) {
|
||||
|
||||
// If we get here, either FS.readFileSync or JSON.parse failed.
|
||||
// We'll return HMSTATUS.readError or HMSTATUS.parseError.
|
||||
var retRaw = ret.raw && ret.raw.trim();
|
||||
|
||||
ret.ex = {
|
||||
operation: retRaw ? 'parse' : 'read',
|
||||
inner: SyntaxErrorEx.is( ex ) ? (new SyntaxErrorEx( ex, retRaw )) : ex,
|
||||
file: file
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}());
|
||||
module.exports = function( file ) {
|
||||
const ret = { };
|
||||
try {
|
||||
ret.raw = FS.readFileSync( file, 'utf8' );
|
||||
ret.json = JSON.parse( ret.raw );
|
||||
} catch (err) {
|
||||
// If we get here, either FS.readFileSync or JSON.parse failed.
|
||||
// We'll return HMSTATUS.readError or HMSTATUS.parseError.
|
||||
const retRaw = ret.raw && ret.raw.trim();
|
||||
ret.ex = {
|
||||
op: retRaw ? 'parse' : 'read',
|
||||
inner:
|
||||
SyntaxErrorEx.is( err )
|
||||
? (new SyntaxErrorEx( err, retRaw ))
|
||||
: err,
|
||||
file
|
||||
};
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
@ -1,45 +1,44 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Safe spawn utility for HackMyResume / FluentCV.
|
||||
@module safe-spawn.js
|
||||
@module utils/safe-spawn
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
/** Safely spawn a process synchronously or asynchronously without throwing an
|
||||
exception */
|
||||
module.exports = function( cmd, args, isSync, callback, param ) {
|
||||
|
||||
try {
|
||||
// .spawnSync not available on earlier Node.js, so default to .spawn
|
||||
const spawn = require('child_process')[ isSync ? 'spawnSync' : 'spawn'];
|
||||
const info = spawn(cmd, args);
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
|
||||
module.exports = function( cmd, args, isSync ) {
|
||||
|
||||
try {
|
||||
|
||||
var spawn = require('child_process')[ isSync? 'spawnSync' : 'spawn'];
|
||||
var info = spawn( cmd, args );
|
||||
|
||||
if( !isSync ) {
|
||||
info.on('error', function(err) {
|
||||
throw {
|
||||
cmd: 'wkhtmltopdf',
|
||||
inner: err
|
||||
};
|
||||
});
|
||||
}
|
||||
else {
|
||||
if( info.error ) {
|
||||
throw {
|
||||
cmd: 'wkhtmltopdf',
|
||||
inner: info.error
|
||||
};
|
||||
// Check for error depending on whether we're sync or async TODO: Promises
|
||||
if (!isSync) {
|
||||
info.on('error', function(err) {
|
||||
if (typeof callback === 'function') {
|
||||
callback(err, param);
|
||||
}
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
if (info.error) {
|
||||
if (typeof callback === 'function') {
|
||||
callback(info.error, param);
|
||||
}
|
||||
return {cmd, inner: info.error};
|
||||
}
|
||||
|
||||
}
|
||||
catch( ex ) {
|
||||
|
||||
} catch (ex) {
|
||||
if (typeof callback === 'function') {
|
||||
callback(ex, param);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
return ex;
|
||||
}
|
||||
};
|
||||
|
@ -1,65 +1,56 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Object string transformation.
|
||||
@module string-transformer.js
|
||||
@module utils/string-transformer
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
const _ = require('underscore');
|
||||
const moment = require('moment');
|
||||
|
||||
/**
|
||||
Create a copy of this object in which all string fields have been run through
|
||||
a transformation function (such as a Markdown filter or XML encoder).
|
||||
*/
|
||||
|
||||
(function() {
|
||||
module.exports = function( ret, filt, transformer ) {
|
||||
|
||||
// TODO: refactor recursion
|
||||
var transformStringsInObject = function( obj, filters ) {
|
||||
if (!obj) { return; }
|
||||
if (moment.isMoment(obj)) { return; }
|
||||
|
||||
|
||||
var _ = require('underscore');
|
||||
var moment = require('moment');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Create a copy of this object in which all string fields have been run through
|
||||
a transformation function (such as a Markdown filter or XML encoder).
|
||||
*/
|
||||
module.exports = function( ret, filt, transformer ) {
|
||||
|
||||
var that = this;
|
||||
|
||||
// TODO: refactor recursion
|
||||
function transformStringsInObject( obj, filters ) {
|
||||
|
||||
if( !obj ) return;
|
||||
if( moment.isMoment( obj ) ) return;
|
||||
|
||||
if( _.isArray( obj ) ) {
|
||||
obj.forEach( function(elem, idx, ar) {
|
||||
if( typeof elem === 'string' || elem instanceof String )
|
||||
ar[idx] = transformer( null, elem );
|
||||
else if (_.isObject(elem))
|
||||
transformStringsInObject( elem, filters );
|
||||
});
|
||||
}
|
||||
else if (_.isObject( obj )) {
|
||||
Object.keys( obj ).forEach(function(k) {
|
||||
if( filters.length && _.contains(filters, k) )
|
||||
return;
|
||||
var sub = obj[k];
|
||||
if( typeof sub === 'string' || sub instanceof String ) {
|
||||
obj[k] = transformer( k, sub );
|
||||
}
|
||||
else if (_.isObject( sub ))
|
||||
transformStringsInObject( sub, filters );
|
||||
});
|
||||
}
|
||||
|
||||
if (_.isArray( obj )) {
|
||||
return obj.forEach(function(elem, idx, ar) {
|
||||
if ((typeof elem === 'string') || elem instanceof String) {
|
||||
return ar[idx] = transformer( null, elem );
|
||||
} else if (_.isObject(elem)) {
|
||||
return transformStringsInObject( elem, filters );
|
||||
}
|
||||
});
|
||||
} else if (_.isObject( obj )) {
|
||||
return Object.keys( obj ).forEach(function(k) {
|
||||
if (filters.length && _.contains(filters, k)) {
|
||||
return;
|
||||
}
|
||||
const sub = obj[k];
|
||||
if ((typeof sub === 'string') || sub instanceof String) {
|
||||
return obj[k] = transformer( k, sub );
|
||||
} else if (_.isObject( sub )) {
|
||||
return transformStringsInObject( sub, filters );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Object.keys( ret ).forEach(function(member){
|
||||
if( !filt || !filt.length || !_.contains(filt, member) )
|
||||
transformStringsInObject( ret[ member ], filt || [] );
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
Object.keys( ret ).forEach(function(member) {
|
||||
if (!filt || !filt.length || !_.contains(filt, member)) {
|
||||
return transformStringsInObject( ret[ member ], filt || [] );
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
Definitions of string utility functions.
|
||||
@module string.js
|
||||
@module utils/string
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -9,18 +9,7 @@ See: http://stackoverflow.com/a/32800728/4942583
|
||||
@method isNullOrWhitespace
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
String.isNullOrWhitespace = function( input ) {
|
||||
return !input || !input.trim();
|
||||
};
|
||||
|
||||
String.prototype.endsWith = function(suffix) {
|
||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||
};
|
||||
|
||||
String.is = function( val ) {
|
||||
return typeof val === 'string' || val instanceof String;
|
||||
};
|
||||
|
||||
}());
|
||||
String.isNullOrWhitespace = input => !input || !input.trim();
|
||||
String.prototype.endsWith = function(suffix) { return this.indexOf(suffix, this.length - suffix.length) !== -1; };
|
||||
String.is = val => (typeof val === 'string') || val instanceof String;
|
||||
|
@ -1,35 +1,43 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the SyntaxErrorEx class.
|
||||
@module syntax-error-ex.js
|
||||
@module utils/syntax-error-ex
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
|
||||
/**
|
||||
Represents a SyntaxError exception with line and column info.
|
||||
Collect syntax error information from the provided exception object. The
|
||||
JavaScript `SyntaxError` exception isn't interpreted uniformly across environ-
|
||||
ments, so we reparse on error to grab the line and column.
|
||||
See: http://stackoverflow.com/q/13323356
|
||||
@class SyntaxErrorEx
|
||||
*/
|
||||
|
||||
function SyntaxErrorEx( ex, rawData ) {
|
||||
|
||||
var lineNum = null, colNum = null;
|
||||
var JSONLint = require('json-lint');
|
||||
var lint = JSONLint( rawData, { comments: false } );
|
||||
this.line = (lint.error ? lint.line : '???');
|
||||
this.col = (lint.error ? lint.character : '???');
|
||||
/**
|
||||
Represents a SyntaxError exception with line and column info.
|
||||
Collect syntax error information from the provided exception object. The
|
||||
JavaScript `SyntaxError` exception isn't interpreted uniformly across environ-
|
||||
ments, so we reparse on error to grab the line and column.
|
||||
See: http://stackoverflow.com/q/13323356
|
||||
@class SyntaxErrorEx
|
||||
*/
|
||||
|
||||
class SyntaxErrorEx {
|
||||
constructor( ex, rawData ) {
|
||||
let JSONLint = require('json-lint');
|
||||
const lint = JSONLint(rawData, { comments: false });
|
||||
if (lint.error) { [this.line, this.col] = Array.from([lint.line, lint.character]); }
|
||||
if (!lint.error) {
|
||||
JSONLint = require('jsonlint');
|
||||
try {
|
||||
JSONLint.parse(rawData);
|
||||
} catch (err) {
|
||||
this.line = (/on line (\d+)/.exec(err))[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SyntaxErrorEx.is = function( ex ) {
|
||||
return ex instanceof SyntaxError;
|
||||
};
|
||||
|
||||
module.exports = SyntaxErrorEx;
|
||||
// Return true if the supplied parameter is a JavaScript SyntaxError
|
||||
SyntaxErrorEx.is = ex => ex instanceof SyntaxError;
|
||||
|
||||
}());
|
||||
module.exports = SyntaxErrorEx;
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Implementation of the 'analyze' verb for HackMyResume.
|
||||
@module verbs/analyze
|
||||
@ -6,89 +11,79 @@ Implementation of the 'analyze' verb for HackMyResume.
|
||||
|
||||
|
||||
|
||||
(function(){
|
||||
const HMEVENT = require('../core/event-codes');
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const _ = require('underscore');
|
||||
const ResumeFactory = require('../core/resume-factory');
|
||||
const Verb = require('../verbs/verb');
|
||||
|
||||
|
||||
|
||||
var MKDIRP = require('mkdirp')
|
||||
, PATH = require('path')
|
||||
, HMEVENT = require('../core/event-codes')
|
||||
, HMSTATUS = require('../core/status-codes')
|
||||
, _ = require('underscore')
|
||||
, ResumeFactory = require('../core/resume-factory')
|
||||
, Verb = require('../verbs/verb')
|
||||
, chalk = require('chalk');
|
||||
/** An invokable resume analysis command. */
|
||||
class AnalyzeVerb extends Verb {
|
||||
constructor() { super('analyze', _analyze); }
|
||||
}
|
||||
|
||||
module.exports = AnalyzeVerb;
|
||||
|
||||
|
||||
|
||||
var AnalyzeVerb = module.exports = Verb.extend({
|
||||
/** Private workhorse for the 'analyze' command. */
|
||||
var _analyze = function( sources, dst, opts ) {
|
||||
|
||||
init: function() {
|
||||
this._super('analyze');
|
||||
},
|
||||
if (!sources || !sources.length) {
|
||||
this.err(HMSTATUS.resumeNotFound, { quit: true });
|
||||
return null;
|
||||
}
|
||||
|
||||
invoke: function() {
|
||||
this.stat( HMEVENT.begin, { cmd: 'analyze' });
|
||||
analyze.apply( this, arguments );
|
||||
this.stat( HMEVENT.end );
|
||||
const nlzrs = _loadInspectors();
|
||||
const results = _.map(sources, function(src) {
|
||||
const r = ResumeFactory.loadOne(src, { format: 'FRESH', objectify: true, inner: {
|
||||
private: opts.private === true
|
||||
}
|
||||
}, this);
|
||||
if (opts.assert && this.hasError()) { return { }; }
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Run the 'analyze' command.
|
||||
*/
|
||||
function analyze( sources, dst, opts ) {
|
||||
if( !sources || !sources.length )
|
||||
throw { fluenterror: HMSTATUS.resumeNotFound, quit: true };
|
||||
|
||||
var nlzrs = _loadInspectors();
|
||||
|
||||
_.each(sources, function(src) {
|
||||
var result = ResumeFactory.loadOne( src, {
|
||||
format: 'FRESH', objectify: true
|
||||
}, this);
|
||||
if( result.fluenterror )
|
||||
this.setError( result.fluenterror, result );
|
||||
else
|
||||
_analyze.call(this, result, nlzrs, opts );
|
||||
}, this);
|
||||
|
||||
if (r.fluenterror) {
|
||||
r.quit = opts.assert;
|
||||
this.err(r.fluenterror, r);
|
||||
return r;
|
||||
} else {
|
||||
return _analyzeOne.call(this, r, nlzrs, opts);
|
||||
}
|
||||
}
|
||||
, this);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Analyze a single resume.
|
||||
*/
|
||||
function _analyze( resumeObject, nlzrs, opts ) {
|
||||
var rez = resumeObject.rez;
|
||||
var safeFormat =
|
||||
(rez.meta && rez.meta.format && rez.meta.format.startsWith('FRESH')) ?
|
||||
'FRESH' : 'JRS';
|
||||
|
||||
this.stat( HMEVENT.beforeAnalyze, { fmt: safeFormat, file: resumeObject.file });
|
||||
var info = _.mapObject( nlzrs, function(val, key) {
|
||||
return val.run( resumeObject.rez );
|
||||
});
|
||||
this.stat( HMEVENT.afterAnalyze, { info: info } );
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(this.errorCode);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Load inspectors.
|
||||
*/
|
||||
function _loadInspectors() {
|
||||
return {
|
||||
totals: require('../inspectors/totals-inspector'),
|
||||
coverage: require('../inspectors/gap-inspector'),
|
||||
keywords: require('../inspectors/keyword-inspector')
|
||||
};
|
||||
}
|
||||
/** Analyze a single resume. */
|
||||
var _analyzeOne = function( resumeObject, nlzrs ) {
|
||||
const { rez } = resumeObject;
|
||||
const safeFormat =
|
||||
rez.meta && rez.meta.format && rez.meta.format.startsWith('FRESH')
|
||||
? 'FRESH' : 'JRS';
|
||||
|
||||
this.stat( HMEVENT.beforeAnalyze, { fmt: safeFormat, file: resumeObject.file });
|
||||
const info = _.mapObject(nlzrs, (val) => val.run(rez));
|
||||
this.stat(HMEVENT.afterAnalyze, { info });
|
||||
return info;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
var _loadInspectors = () =>
|
||||
({
|
||||
totals: require('../inspectors/totals-inspector'),
|
||||
coverage: require('../inspectors/gap-inspector'),
|
||||
keywords: require('../inspectors/keyword-inspector')
|
||||
})
|
||||
;
|
||||
|
@ -1,3 +1,9 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Implementation of the 'build' verb for HackMyResume.
|
||||
@module verbs/build
|
||||
@ -6,380 +12,430 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const _ = require('underscore');
|
||||
const PATH = require('path');
|
||||
const MKDIRP = require('mkdirp');
|
||||
const extend = require('extend');
|
||||
const parsePath = require('parse-filepath');
|
||||
const RConverter = require('fresh-jrs-converter');
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const HMEVENT = require('../core/event-codes');
|
||||
const RTYPES = {
|
||||
FRESH: require('../core/fresh-resume'),
|
||||
JRS: require('../core/jrs-resume')
|
||||
};
|
||||
const _opts = require('../core/default-options');
|
||||
const FRESHTheme = require('../core/fresh-theme');
|
||||
const JRSTheme = require('../core/jrs-theme');
|
||||
const ResumeFactory = require('../core/resume-factory');
|
||||
const _fmts = require('../core/default-formats');
|
||||
const Verb = require('../verbs/verb');
|
||||
|
||||
//const _err = null;
|
||||
//const _log = null;
|
||||
let _rezObj = null;
|
||||
//const build = null;
|
||||
//const prep = null;
|
||||
//const single = null;
|
||||
//const verifyOutputs = null;
|
||||
//const addFreebieFormats = null;
|
||||
//const expand = null;
|
||||
//const verifyTheme = null;
|
||||
//const loadTheme = null;
|
||||
|
||||
/** An invokable resume generation command. */
|
||||
class BuildVerb extends Verb {
|
||||
|
||||
/** Create a new build verb. */
|
||||
constructor() { super('build', _build); }
|
||||
}
|
||||
|
||||
|
||||
module.exports = BuildVerb;
|
||||
|
||||
|
||||
|
||||
var _ = require('underscore')
|
||||
, PATH = require('path')
|
||||
, FS = require('fs')
|
||||
, MD = require('marked')
|
||||
, MKDIRP = require('mkdirp')
|
||||
, extend = require('extend')
|
||||
, parsePath = require('parse-filepath')
|
||||
, RConverter = require('fresh-jrs-converter')
|
||||
, HMSTATUS = require('../core/status-codes')
|
||||
, HMEVENT = require('../core/event-codes')
|
||||
, RTYPES = { FRESH: require('../core/fresh-resume'),
|
||||
JRS: require('../core/jrs-resume') }
|
||||
, _opts = require('../core/default-options')
|
||||
, FRESHTheme = require('../core/fresh-theme')
|
||||
, JRSTheme = require('../core/jrs-theme')
|
||||
, ResumeFactory = require('../core/resume-factory')
|
||||
, _fmts = require('../core/default-formats')
|
||||
, Verb = require('../verbs/verb');
|
||||
/**
|
||||
Given a source resume in FRESH or JRS format, a destination resume path, and a
|
||||
theme file, generate 0..N resumes in the desired formats.
|
||||
@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 opts Generation options.
|
||||
*/
|
||||
var _build = function( src, dst, opts ) {
|
||||
|
||||
var _err, _log, _rezObj;
|
||||
|
||||
|
||||
|
||||
/** An invokable resume generation command. */
|
||||
var BuildVerb = module.exports = Verb.extend({
|
||||
|
||||
/** Create a new build verb. */
|
||||
init: function() {
|
||||
this._super('build');
|
||||
},
|
||||
|
||||
/** Invoke the Build command. */
|
||||
invoke: function() {
|
||||
this.stat( HMEVENT.begin, { cmd: 'build' } );
|
||||
var ret = build.apply( this, arguments );
|
||||
this.stat( HMEVENT.end );
|
||||
return ret;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Given a source resume in FRESH or JRS format, a destination resume path, and a
|
||||
theme file, generate 0..N resumes in the desired formats.
|
||||
@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 theme Friendly name of the resume theme. Defaults to "modern".
|
||||
@param logger Optional logging override.
|
||||
*/
|
||||
function build( src, dst, opts ) {
|
||||
|
||||
if( !src || !src.length ) {
|
||||
this.err( HMSTATUS.resumeNotFound, { quit: true } );
|
||||
}
|
||||
|
||||
prep( src, dst, opts );
|
||||
|
||||
// Load input resumes as JSON...
|
||||
var sheetObjects = ResumeFactory.load(src, {
|
||||
format: null, objectify: false, quit: true, inner: { sort: _opts.sort }
|
||||
}, this);
|
||||
|
||||
// Explicit check for any resume loading errors...
|
||||
if( !sheetObjects ||
|
||||
_.some( sheetObjects, function(so) { return so.fluenterror; } ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var sheets = sheetObjects.map(function(r) { return r.json; });
|
||||
|
||||
// Load the theme...
|
||||
var theme;
|
||||
this.stat( HMEVENT.beforeTheme, { theme: _opts.theme });
|
||||
try {
|
||||
var tFolder = verifyTheme.call( this, _opts.theme );
|
||||
theme = _opts.themeObj = loadTheme( tFolder );
|
||||
}
|
||||
catch( ex ) {
|
||||
var newEx = {
|
||||
fluenterror: HMSTATUS.themeLoad,
|
||||
inner: ex,
|
||||
attempted: _opts.theme
|
||||
};
|
||||
this.err( HMSTATUS.themeLoad, newEx );
|
||||
return null;
|
||||
}
|
||||
this.stat( HMEVENT.afterTheme, { theme: theme });
|
||||
|
||||
// Check for invalid outputs...
|
||||
var inv = verifyOutputs.call( this, dst, theme );
|
||||
if( inv && inv.length ) {
|
||||
this.err( HMSTATUS.invalidFormat, { data: inv, theme: theme } );
|
||||
}
|
||||
|
||||
// Merge input resumes, yielding a single source resume.
|
||||
var rez;
|
||||
if( sheets.length > 1 ) {
|
||||
var isFRESH = !sheets[0].basics;
|
||||
var mixed = _.any( sheets, function(s) { return isFRESH ? s.basics : !s.basics; });
|
||||
this.stat( HMEVENT.beforeMerge, { f: _.clone(sheetObjects), mixed: mixed });
|
||||
if( mixed ) {
|
||||
this.err( HMSTATUS.mixedMerge );
|
||||
}
|
||||
rez = _.reduceRight( sheets, function( a, b, idx ) {
|
||||
return extend( true, b, a );
|
||||
});
|
||||
this.stat( HMEVENT.afterMerge, { r: rez } );
|
||||
}
|
||||
else {
|
||||
rez = sheets[0];
|
||||
}
|
||||
|
||||
// Convert the merged source resume to the theme's format, if necessary
|
||||
var orgFormat = rez.basics ? 'JRS' : 'FRESH';
|
||||
var toFormat = theme.render ? 'JRS' : 'FRESH';
|
||||
if( toFormat !== orgFormat ) {
|
||||
this.stat( HMEVENT.beforeInlineConvert );
|
||||
rez = RConverter[ 'to' + toFormat ]( rez );
|
||||
this.stat( HMEVENT.afterInlineConvert, { file: sheetObjects[0].file, fmt: toFormat });
|
||||
}
|
||||
|
||||
// Add freebie formats to the theme
|
||||
addFreebieFormats( theme );
|
||||
this.stat( HMEVENT.applyTheme, { r: rez, theme: theme });
|
||||
|
||||
// Load the resume into a FRESHResume or JRSResume object
|
||||
_rezObj = new (RTYPES[ toFormat ])().parseJSON( rez );
|
||||
|
||||
// Expand output resumes...
|
||||
var targets = expand( dst, theme );
|
||||
|
||||
// Run the transformation!
|
||||
_.each(targets, function(t) {
|
||||
t.final = single.call( this, t, theme, targets );
|
||||
}, this);
|
||||
|
||||
// Don't send the client back empty-handed
|
||||
return { sheet: _rezObj, targets: targets, processed: targets };
|
||||
let err;
|
||||
if (!src || !src.length) {
|
||||
this.err(HMSTATUS.resumeNotFound, {quit: true});
|
||||
return null;
|
||||
}
|
||||
|
||||
_prep.call(this, src, dst, opts);
|
||||
|
||||
// Load input resumes as JSON...
|
||||
const sheetObjects = ResumeFactory.load(src, {
|
||||
format: null, objectify: false, quit: true, inner: {
|
||||
sort: _opts.sort,
|
||||
private: _opts.private
|
||||
}
|
||||
}
|
||||
, this);
|
||||
|
||||
/**
|
||||
Prepare for a BUILD run.
|
||||
*/
|
||||
function prep( src, dst, opts ) {
|
||||
|
||||
// Cherry-pick options //_opts = extend( true, _opts, opts );
|
||||
_opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern';
|
||||
_opts.prettify = opts.prettify === true;
|
||||
_opts.css = opts.css;
|
||||
_opts.pdf = opts.pdf;
|
||||
_opts.wrap = opts.wrap || 60;
|
||||
_opts.stitles = opts.sectionTitles;
|
||||
_opts.tips = opts.tips;
|
||||
_opts.errHandler = opts.errHandler;
|
||||
_opts.noTips = opts.noTips;
|
||||
_opts.debug = opts.debug;
|
||||
_opts.sort = opts.sort;
|
||||
|
||||
// If two or more files are passed to the GENERATE command and the TO
|
||||
// keyword is omitted, the last file specifies the output file.
|
||||
( src.length > 1 && ( !dst || !dst.length ) ) && dst.push( src.pop() );
|
||||
|
||||
// Explicit check for any resume loading errors...
|
||||
const problemSheets = _.filter(sheetObjects, so => so.fluenterror);
|
||||
if (problemSheets && problemSheets.length) {
|
||||
problemSheets[0].quit = true; // can't go on
|
||||
this.err(problemSheets[0].fluenterror, problemSheets[0]);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the collection of raw JSON sheets
|
||||
const sheets = sheetObjects.map(r => r.json);
|
||||
|
||||
|
||||
/**
|
||||
Generate a single target resume such as "out/rez.html" or "out/rez.doc".
|
||||
TODO: Refactor.
|
||||
@param targInfo Information for the target resume.
|
||||
@param theme A FRESHTheme or JRSTheme object.
|
||||
*/
|
||||
function single( targInfo, theme, finished ) {
|
||||
|
||||
var ret, ex, f = targInfo.file;
|
||||
|
||||
try {
|
||||
|
||||
if( !targInfo.fmt ) { return; }
|
||||
var fType = targInfo.fmt.outFormat
|
||||
, fName = PATH.basename(f, '.' + fType)
|
||||
, theFormat;
|
||||
|
||||
this.stat( HMEVENT.beforeGenerate, {
|
||||
fmt: targInfo.fmt.outFormat,
|
||||
file: PATH.relative(process.cwd(), f)
|
||||
});
|
||||
|
||||
// If targInfo.fmt.files exists, this format is backed by a document.
|
||||
// Fluent/FRESH themes are handled here.
|
||||
if( targInfo.fmt.files && targInfo.fmt.files.length ) {
|
||||
theFormat = _fmts.filter(
|
||||
function(fmt) { return fmt.name === targInfo.fmt.outFormat; })[0];
|
||||
MKDIRP.sync( PATH.dirname( f ) ); // Ensure dest folder exists;
|
||||
_opts.targets = finished;
|
||||
ret = theFormat.gen.generate( _rezObj, f, _opts );
|
||||
}
|
||||
//Otherwise this is an ad-hoc format (JSON, YML, or PNG) that every theme
|
||||
// gets "for free".
|
||||
else {
|
||||
theFormat = _fmts.filter( function(fmt) {
|
||||
return fmt.name === targInfo.fmt.outFormat;
|
||||
})[0];
|
||||
var outFolder = PATH.dirname( f );
|
||||
MKDIRP.sync( outFolder ); // Ensure dest folder exists;
|
||||
ret = theFormat.gen.generate( _rezObj, f, _opts );
|
||||
}
|
||||
}
|
||||
catch( e ) {
|
||||
// Catch any errors caused by generating this file and don't let them
|
||||
// propagate -- typically we want to continue processing other formats
|
||||
// even if this format failed.
|
||||
ex = e;
|
||||
// Load the theme...
|
||||
let theme = null;
|
||||
this.stat(HMEVENT.beforeTheme, { theme: _opts.theme });
|
||||
try {
|
||||
const tFolder = _verifyTheme.call(this, _opts.theme);
|
||||
if (tFolder.fluenterror) {
|
||||
tFolder.quit = true;
|
||||
this.err(tFolder.fluenterror, tFolder);
|
||||
return;
|
||||
}
|
||||
theme = (_opts.themeObj = _loadTheme(tFolder));
|
||||
_addFreebieFormats(theme);
|
||||
} catch (error) {
|
||||
err = error;
|
||||
const newEx = {
|
||||
fluenterror: HMSTATUS.themeLoad,
|
||||
inner: err,
|
||||
attempted: _opts.theme,
|
||||
quit: true
|
||||
};
|
||||
this.err(HMSTATUS.themeLoad, newEx);
|
||||
return null;
|
||||
}
|
||||
|
||||
this.stat( HMEVENT.afterGenerate, {
|
||||
this.stat(HMEVENT.afterTheme, {theme});
|
||||
|
||||
// Check for invalid outputs...
|
||||
const inv = _verifyOutputs.call(this, dst, theme);
|
||||
if (inv && inv.length) {
|
||||
this.err(HMSTATUS.invalidFormat, {data: inv, theme, quit: true});
|
||||
return null;
|
||||
}
|
||||
|
||||
//# Merge input resumes, yielding a single source resume...
|
||||
let rez = null;
|
||||
if (sheets.length > 1) {
|
||||
const isFRESH = !sheets[0].basics;
|
||||
const mixed = _.any(sheets, function(s) { if (isFRESH) { return s.basics; } else { return !s.basics; } });
|
||||
this.stat(HMEVENT.beforeMerge, { f: _.clone(sheetObjects), mixed });
|
||||
if (mixed) {
|
||||
this.err(HMSTATUS.mixedMerge);
|
||||
}
|
||||
rez = _.reduceRight(sheets, ( a, b ) => extend( true, b, a ));
|
||||
this.stat(HMEVENT.afterMerge, { r: rez });
|
||||
} else {
|
||||
rez = sheets[0];
|
||||
}
|
||||
|
||||
// Convert the merged source resume to the theme's format, if necessary..
|
||||
const orgFormat = rez.basics ? 'JRS' : 'FRESH';
|
||||
const toFormat = theme.render ? 'JRS' : 'FRESH';
|
||||
if (toFormat !== orgFormat) {
|
||||
this.stat(HMEVENT.beforeInlineConvert);
|
||||
rez = RConverter[ `to${toFormat}` ]( rez );
|
||||
this.stat(HMEVENT.afterInlineConvert, { file: sheetObjects[0].file, fmt: toFormat });
|
||||
}
|
||||
|
||||
// Announce the theme
|
||||
this.stat(HMEVENT.applyTheme, {r: rez, theme});
|
||||
|
||||
// Load the resume into a FRESHResume or JRSResume object
|
||||
_rezObj = new (RTYPES[ toFormat ])().parseJSON( rez, {private: _opts.private} );
|
||||
|
||||
// Expand output resumes...
|
||||
const targets = _expand(dst, theme);
|
||||
|
||||
// Run the transformation!
|
||||
_.each(targets, function(t) {
|
||||
if (this.hasError() && opts.assert) { return { }; }
|
||||
t.final = _single.call(this, t, theme, targets);
|
||||
if (t.final != null ? t.final.fluenterror : undefined) {
|
||||
t.final.quit = opts.assert;
|
||||
this.err(t.final.fluenterror, t.final);
|
||||
}
|
||||
}
|
||||
, this);
|
||||
|
||||
const results = {
|
||||
sheet: _rezObj,
|
||||
targets,
|
||||
processed: targets
|
||||
};
|
||||
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(results);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Prepare for a BUILD run.
|
||||
*/
|
||||
var _prep = function( src, dst, opts ) {
|
||||
// Cherry-pick options //_opts = extend( true, _opts, opts );
|
||||
_opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern';
|
||||
_opts.prettify = opts.prettify === true;
|
||||
_opts.private = opts.private === true;
|
||||
_opts.noescape = opts.noescape === true;
|
||||
_opts.css = opts.css;
|
||||
_opts.pdf = opts.pdf;
|
||||
_opts.wrap = opts.wrap || 60;
|
||||
_opts.stitles = opts.sectionTitles;
|
||||
_opts.tips = opts.tips;
|
||||
_opts.errHandler = opts.errHandler;
|
||||
_opts.noTips = opts.noTips;
|
||||
_opts.debug = opts.debug;
|
||||
_opts.sort = opts.sort;
|
||||
_opts.wkhtmltopdf = opts.wkhtmltopdf;
|
||||
const that = this;
|
||||
|
||||
// Set up callbacks for internal generators
|
||||
_opts.onTransform = function(info) {
|
||||
that.stat(HMEVENT.afterTransform, info);
|
||||
};
|
||||
_opts.beforeWrite = function(info) {
|
||||
that.stat(HMEVENT.beforeWrite, info);
|
||||
};
|
||||
_opts.afterWrite = function(info) {
|
||||
that.stat(HMEVENT.afterWrite, info);
|
||||
};
|
||||
|
||||
|
||||
// If two or more files are passed to the GENERATE command and the TO
|
||||
// keyword is omitted, the last file specifies the output file.
|
||||
( (src.length > 1) && ( !dst || !dst.length ) ) && dst.push( src.pop() );
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Generate a single target resume such as "out/rez.html" or "out/rez.doc".
|
||||
TODO: Refactor.
|
||||
@param targInfo Information for the target resume.
|
||||
@param theme A FRESHTheme or JRSTheme object.
|
||||
*/
|
||||
var _single = function( targInfo, theme, finished ) {
|
||||
|
||||
let ret = null;
|
||||
let ex = null;
|
||||
const f = targInfo.file;
|
||||
|
||||
try {
|
||||
|
||||
if (!targInfo.fmt) {
|
||||
return { };
|
||||
}
|
||||
let theFormat = null;
|
||||
|
||||
this.stat(HMEVENT.beforeGenerate, {
|
||||
fmt: targInfo.fmt.outFormat,
|
||||
file: PATH.relative( process.cwd(), f ),
|
||||
error: ex
|
||||
});
|
||||
|
||||
if( ex ) {
|
||||
if( ex.fluenterror )
|
||||
this.err( ex.fluenterror, ex );
|
||||
else
|
||||
this.err( HMSTATUS.generateError, { inner: ex } );
|
||||
file: PATH.relative(process.cwd(), f)
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Ensure that user-specified outputs/targets are valid.
|
||||
*/
|
||||
function verifyOutputs( targets, theme ) {
|
||||
|
||||
this.stat(HMEVENT.verifyOutputs, { targets: targets, theme: theme });
|
||||
|
||||
return _.reject(
|
||||
targets.map( function( t ) {
|
||||
var pathInfo = parsePath( t );
|
||||
return {
|
||||
format: pathInfo.extname.substr(1)
|
||||
};
|
||||
}),
|
||||
function(t) {
|
||||
return t.format === 'all' || theme.hasFormat( t.format );
|
||||
}
|
||||
);
|
||||
|
||||
_opts.targets = finished;
|
||||
|
||||
// If targInfo.fmt.files exists, this format is backed by a document.
|
||||
// Fluent/FRESH themes are handled here.
|
||||
if (targInfo.fmt.files && targInfo.fmt.files.length) {
|
||||
theFormat = _fmts.filter( fmt => fmt.name === targInfo.fmt.outFormat)[0];
|
||||
MKDIRP.sync(PATH.dirname( f ));
|
||||
ret = theFormat.gen.generate(_rezObj, f, _opts);
|
||||
|
||||
// Otherwise this is an ad-hoc format (JSON, YML, or PNG) that every theme
|
||||
// gets "for free".
|
||||
} else {
|
||||
theFormat = _fmts.filter( fmt => fmt.name === targInfo.fmt.outFormat)[0];
|
||||
const outFolder = PATH.dirname(f);
|
||||
MKDIRP.sync(outFolder); // Ensure dest folder exists;
|
||||
ret = theFormat.gen.generate(_rezObj, f, _opts);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
ex = e;
|
||||
}
|
||||
|
||||
this.stat(HMEVENT.afterGenerate, {
|
||||
fmt: targInfo.fmt.outFormat,
|
||||
file: PATH.relative(process.cwd(), f),
|
||||
error: ex
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Reinforce the chosen theme with "freebie" formats provided by HackMyResume.
|
||||
A "freebie" format is an output format such as JSON, YML, or PNG that can be
|
||||
generated directly from the resume model or from one of the theme's declared
|
||||
output formats. For example, the PNG format can be generated for any theme
|
||||
that declares an HTML format; the theme doesn't have to provide an explicit
|
||||
PNG template.
|
||||
@param theTheme A FRESHTheme or JRSTheme object.
|
||||
*/
|
||||
function addFreebieFormats( theTheme ) {
|
||||
// Add freebie formats (JSON, YAML, PNG) every theme gets...
|
||||
// Add HTML-driven PNG only if the theme has an HTML format.
|
||||
theTheme.formats.json = theTheme.formats.json || {
|
||||
freebie: true, title: 'json', outFormat: 'json', pre: 'json',
|
||||
ext: 'json', path: null, data: null
|
||||
};
|
||||
theTheme.formats.yml = theTheme.formats.yml || {
|
||||
freebie: true, title: 'yaml', outFormat: 'yml', pre: 'yml',
|
||||
ext: 'yml', path: null, data: null
|
||||
};
|
||||
if( theTheme.formats.html && !theTheme.formats.png ) {
|
||||
theTheme.formats.png = {
|
||||
freebie: true, title: 'png', outFormat: 'png',
|
||||
ext: 'yml', path: null, data: null
|
||||
};
|
||||
if (ex) {
|
||||
if (ex.fluenterror) {
|
||||
ret = ex;
|
||||
} else {
|
||||
ret = {fluenterror: HMSTATUS.generateError, inner: ex};
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Expand output files. For example, "foo.all" should be expanded to
|
||||
["foo.html", "foo.doc", "foo.pdf", "etc"].
|
||||
@param dst An array of output files as specified by the user.
|
||||
@param theTheme A FRESHTheme or JRSTheme object.
|
||||
*/
|
||||
function expand( dst, theTheme ) {
|
||||
|
||||
// Set up the destination collection. It's either the array of files passed
|
||||
// by the user or 'out/resume.all' if no targets were specified.
|
||||
var destColl = (dst && dst.length && dst) ||
|
||||
[PATH.normalize('out/resume.all')];
|
||||
|
||||
// Assemble an array of expanded target files... (can't use map() here)
|
||||
var targets = [];
|
||||
destColl.forEach( function(t) {
|
||||
|
||||
var to = PATH.resolve(t), pa = parsePath(to),fmat = pa.extname || '.all';
|
||||
/** Ensure that user-specified outputs/targets are valid. */
|
||||
var _verifyOutputs = function( targets, theme ) {
|
||||
this.stat(HMEVENT.verifyOutputs, {targets, theme});
|
||||
return _.reject(targets.map( function( t ) {
|
||||
const pathInfo = parsePath(t);
|
||||
return {format: pathInfo.extname.substr(1)}; }),
|
||||
t => (t.format === 'all') || theme.hasFormat( t.format ));
|
||||
};
|
||||
|
||||
|
||||
targets.push.apply(
|
||||
targets, fmat === '.all' ?
|
||||
Object.keys( theTheme.formats ).map( function( k ) {
|
||||
var z = theTheme.formats[k];
|
||||
return { file: to.replace( /all$/g, z.outFormat ), fmt: z };
|
||||
}) :
|
||||
[{ file: to, fmt: theTheme.getFormat( fmat.slice(1) ) }]);
|
||||
|
||||
// targets.push.apply(
|
||||
// targets, fmat === '.all' ?
|
||||
// Object.keys( explicitFormats ).map( function( k ) {
|
||||
// var z = theTheme.formats[k];
|
||||
// return { file: to.replace( /all$/g, z.outFormat ), fmt: z };
|
||||
// }) :
|
||||
// [{ file: to, fmt: theTheme.getFormat( fmat.slice(1) ) }]);
|
||||
|
||||
});
|
||||
|
||||
return targets;
|
||||
/**
|
||||
Reinforce the chosen theme with "freebie" formats provided by HackMyResume.
|
||||
A "freebie" format is an output format such as JSON, YML, or PNG that can be
|
||||
generated directly from the resume model or from one of the theme's declared
|
||||
output formats. For example, the PNG format can be generated for any theme
|
||||
that declares an HTML format; the theme doesn't have to provide an explicit
|
||||
PNG template.
|
||||
@param theTheme A FRESHTheme or JRSTheme object.
|
||||
*/
|
||||
var _addFreebieFormats = function( theTheme ) {
|
||||
// Add freebie formats (JSON, YAML, PNG) every theme gets...
|
||||
// Add HTML-driven PNG only if the theme has an HTML format.
|
||||
theTheme.formats.json = theTheme.formats.json || {
|
||||
freebie: true, title: 'json', outFormat: 'json', pre: 'json',
|
||||
ext: 'json', path: null, data: null
|
||||
};
|
||||
theTheme.formats.yml = theTheme.formats.yml || {
|
||||
freebie: true, title: 'yaml', outFormat: 'yml', pre: 'yml',
|
||||
ext: 'yml', path: null, data: null
|
||||
};
|
||||
if (theTheme.formats.html && !theTheme.formats.png) {
|
||||
theTheme.formats.png = {
|
||||
freebie: true, title: 'png', outFormat: 'png',
|
||||
ext: 'yml', path: null, data: null
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Verify the specified theme name/path.
|
||||
*/
|
||||
function verifyTheme( themeNameOrPath ) {
|
||||
var tFolder = PATH.join(
|
||||
parsePath ( require.resolve('fresh-themes') ).dirname,
|
||||
/**
|
||||
Expand output files. For example, "foo.all" should be expanded to
|
||||
["foo.html", "foo.doc", "foo.pdf", "etc"].
|
||||
@param dst An array of output files as specified by the user.
|
||||
@param theTheme A FRESHTheme or JRSTheme object.
|
||||
*/
|
||||
var _expand = function( dst, theTheme ) {
|
||||
|
||||
// Set up the destination collection. It's either the array of files passed
|
||||
// by the user or 'out/resume.all' if no targets were specified.
|
||||
const destColl = (dst && dst.length && dst) || [PATH.normalize('out/resume.all')];
|
||||
|
||||
// Assemble an array of expanded target files... (can't use map() here)
|
||||
const targets = [];
|
||||
destColl.forEach(function(t) {
|
||||
const to = PATH.resolve(t);
|
||||
const pa = parsePath(to);
|
||||
const fmat = pa.extname || '.all';
|
||||
return targets.push.apply( targets,
|
||||
fmat === '.all'
|
||||
? Object.keys( theTheme.formats ).map( function( k ) {
|
||||
const z = theTheme.formats[k];
|
||||
return { file: to.replace( /all$/g, z.outFormat ), fmt: z };
|
||||
})
|
||||
: [{ file: to, fmt: theTheme.getFormat( fmat.slice(1) ) }]
|
||||
);
|
||||
});
|
||||
return targets;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Verify the specified theme name/path.
|
||||
*/
|
||||
var _verifyTheme = function( themeNameOrPath ) {
|
||||
|
||||
// First, see if this is one of the predefined FRESH themes. There are only a
|
||||
// handful of these, but they may change over time, so we need to query
|
||||
// the official source of truth: the fresh-themes repository, which mounts the
|
||||
// themes conveniently by name to the module object, and which is embedded
|
||||
// locally inside the HackMyResume installation.
|
||||
let tFolder;
|
||||
const themesObj = require('fresh-themes');
|
||||
if (_.has(themesObj.themes, themeNameOrPath)) {
|
||||
tFolder = PATH.join(
|
||||
parsePath( require.resolve('fresh-themes') ).dirname,
|
||||
'/themes/',
|
||||
themeNameOrPath
|
||||
);
|
||||
var exists = require('path-exists').sync;
|
||||
if( !exists( tFolder ) ) {
|
||||
tFolder = PATH.resolve( themeNameOrPath );
|
||||
if( !exists( tFolder ) ) {
|
||||
this.err( HMSTATUS.themeNotFound, { data: _opts.theme } );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Otherwsie it's a path to an arbitrary FRESH or JRS theme sitting somewhere
|
||||
// on the user's system (or, in the future, at a URI).
|
||||
tFolder = PATH.resolve(themeNameOrPath);
|
||||
}
|
||||
|
||||
// In either case, make sure the theme folder exists
|
||||
const exists = require('path-exists').sync;
|
||||
if (exists(tFolder)) {
|
||||
return tFolder;
|
||||
} else {
|
||||
return {fluenterror: HMSTATUS.themeNotFound, data: _opts.theme};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Load the specified theme, which could be either a FRESH theme or a JSON Resume
|
||||
theme.
|
||||
*/
|
||||
function loadTheme( tFolder ) {
|
||||
/**
|
||||
Load the specified theme, which could be either a FRESH theme or a JSON Resume
|
||||
theme (or both).
|
||||
*/
|
||||
var _loadTheme = function( tFolder ) {
|
||||
|
||||
// Create a FRESH or JRS theme object
|
||||
var theTheme = _opts.theme.indexOf('jsonresume-theme-') > -1 ?
|
||||
new JRSTheme().open(tFolder) : new FRESHTheme().open( tFolder );
|
||||
const themeJsonPath = PATH.join(tFolder, 'theme.json'); // [^1]
|
||||
const exists = require('path-exists').sync;
|
||||
|
||||
// Cache the theme object
|
||||
_opts.themeObj = theTheme;
|
||||
// Create a FRESH or JRS theme object
|
||||
const theTheme =
|
||||
exists(themeJsonPath)
|
||||
? new FRESHTheme().open(tFolder)
|
||||
: new JRSTheme().open(tFolder);
|
||||
|
||||
return theTheme;
|
||||
}
|
||||
// Cache the theme object
|
||||
_opts.themeObj = theTheme;
|
||||
return theTheme;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}());
|
||||
// FOOTNOTES
|
||||
// ------------------------------------------------------------------------------
|
||||
// [^1] We don't know ahead of time whether this is a FRESH or JRS theme.
|
||||
// However, all FRESH themes have a theme.json file, so we'll use that as a
|
||||
// canary for now, as an interim solution.
|
||||
//
|
||||
// Unfortunately, with the exception of FRESH's theme.json, both FRESH and
|
||||
// JRS themes are free-form and don't have a ton of reliable distinguishing
|
||||
// marks, which makes a simple task like ad hoc theme detection harder than
|
||||
// it should be to do cleanly.
|
||||
//
|
||||
// Another complicating factor is that it's possible for a theme to be BOTH.
|
||||
// That is, a single set of theme files can serve as a FRESH theme -and- a
|
||||
// JRS theme.
|
||||
//
|
||||
// TODO: The most robust way to deal with all these issues is with a strong
|
||||
// theme validator. If a theme structure validates as a particular theme
|
||||
// type, then for all intents and purposes, it IS a theme of that type.
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Implementation of the 'convert' verb for HackMyResume.
|
||||
@module verbs/convert
|
||||
@ -6,84 +11,161 @@ Implementation of the 'convert' verb for HackMyResume.
|
||||
|
||||
|
||||
|
||||
(function(){
|
||||
const ResumeFactory = require('../core/resume-factory');
|
||||
const Verb = require('../verbs/verb');
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const _ = require('underscore');
|
||||
const HMEVENT = require('../core/event-codes');
|
||||
|
||||
|
||||
|
||||
var ResumeFactory = require('../core/resume-factory')
|
||||
, chalk = require('chalk')
|
||||
, Verb = require('../verbs/verb')
|
||||
, HMSTATUS = require('../core/status-codes')
|
||||
, _ = require('underscore')
|
||||
, HMEVENT = require('../core/event-codes');
|
||||
class ConvertVerb extends Verb {
|
||||
constructor() { super('convert', _convert); }
|
||||
}
|
||||
|
||||
|
||||
var ConvertVerb = module.exports = Verb.extend({
|
||||
|
||||
init: function() {
|
||||
this._super('convert');
|
||||
},
|
||||
|
||||
invoke: function() {
|
||||
this.stat( HMEVENT.begin, { cmd: 'convert' });
|
||||
convert.apply( this, arguments );
|
||||
this.stat( HMEVENT.end );
|
||||
}
|
||||
|
||||
});
|
||||
module.exports = ConvertVerb;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Convert between FRESH and JRS formats.
|
||||
*/
|
||||
function convert( srcs, dst, opts ) {
|
||||
/** Private workhorse method. Convert 0..N resumes between FRESH and JRS
|
||||
formats. */
|
||||
|
||||
// Housekeeping
|
||||
if( !srcs || !srcs.length ) { throw { fluenterror: 6, quit: true }; }
|
||||
if( !dst || !dst.length ) {
|
||||
if( srcs.length === 1 ) {
|
||||
throw { fluenterror: HMSTATUS.inputOutputParity, quit: true };
|
||||
}
|
||||
else if( srcs.length === 2 ) {
|
||||
dst = dst || []; dst.push( srcs.pop() );
|
||||
}
|
||||
else {
|
||||
throw { fluenterror: HMSTATUS.inputOutputParity, quit: true };
|
||||
}
|
||||
}
|
||||
if(srcs && dst && srcs.length && dst.length && srcs.length !== dst.length){
|
||||
throw { fluenterror: HMSTATUS.inputOutputParity, quit: true };
|
||||
}
|
||||
|
||||
// Load source resumes
|
||||
_.each(srcs, function( src, idx ) {
|
||||
|
||||
// Load the resume
|
||||
var rinfo = ResumeFactory.loadOne( src, {
|
||||
format: null, objectify: true, throw: false
|
||||
});
|
||||
|
||||
// If a load error occurs, report it and move on to the next file (if any)
|
||||
if( rinfo.fluenterror ) {
|
||||
this.err( rinfo.fluenterror, rinfo );
|
||||
return;
|
||||
}
|
||||
|
||||
var 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 });
|
||||
|
||||
// Save it to the destination format
|
||||
s.saveAs( dst[idx], targetFormat );
|
||||
|
||||
}, this);
|
||||
var _convert = function( srcs, dst, opts ) {
|
||||
|
||||
// If no source resumes are specified, error out
|
||||
let fmtUp;
|
||||
if (!srcs || !srcs.length) {
|
||||
this.err(HMSTATUS.resumeNotFound, { quit: true });
|
||||
return null;
|
||||
}
|
||||
|
||||
// If no destination resumes are specified, error out except for the special
|
||||
// case of two resumes:
|
||||
// hackmyresume CONVERT r1.json r2.json
|
||||
if (!dst || !dst.length) {
|
||||
if (srcs.length === 1) {
|
||||
this.err(HMSTATUS.inputOutputParity, { quit: true });
|
||||
} else if (srcs.length === 2) {
|
||||
dst = dst || []; dst.push( srcs.pop() );
|
||||
} else {
|
||||
this.err(HMSTATUS.inputOutputParity, { quit: true });
|
||||
}
|
||||
}
|
||||
|
||||
// Different number of source and dest resumes? Error out.
|
||||
if (srcs && dst && srcs.length && dst.length && (srcs.length !== dst.length)) {
|
||||
this.err(HMSTATUS.inputOutputParity, { quit: true });
|
||||
}
|
||||
|
||||
// Validate the destination format (if specified)
|
||||
//const targetVer = null;
|
||||
if (opts.format) {
|
||||
fmtUp = opts.format.trim().toUpperCase();
|
||||
if (!_.contains(['FRESH','FRESCA','JRS','JRS@1','JRS@edge'], fmtUp)) {
|
||||
this.err(HMSTATUS.invalidSchemaVersion, {data: opts.format.trim(), quit: true});
|
||||
}
|
||||
}
|
||||
// freshVerRegex = require '../utils/fresh-version-regex'
|
||||
// matches = fmtUp.match freshVerRegex()
|
||||
// # null
|
||||
// # [ 'JRS@1.0', 'JRS', '1.0', index: 0, input: 'FRESH' ]
|
||||
// # [ 'FRESH', 'FRESH', undefined, index: 0, input: 'FRESH' ]
|
||||
// if not matches
|
||||
// @err HMSTATUS.invalidSchemaVersion, data: opts.format.trim(), quit: true
|
||||
// targetSchema = matches[1]
|
||||
// targetVer = matches[2] || '1'
|
||||
|
||||
// If any errors have occurred this early, we're done.
|
||||
if (this.hasError()) {
|
||||
this.reject(this.errorCode);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Map each source resume to the converted destination resume
|
||||
const results = _.map(srcs, function( src, idx ) {
|
||||
|
||||
// Convert each resume in turn
|
||||
const r = _convertOne.call(this, src, dst, idx, fmtUp);
|
||||
|
||||
// Handle conversion errors
|
||||
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. */
|
||||
var _convertOne = function(src, dst, idx, targetSchema) {
|
||||
|
||||
// Load the resume
|
||||
const rinfo = ResumeFactory.loadOne(src, {
|
||||
format: null,
|
||||
objectify: true,
|
||||
inner: {
|
||||
privatize: false
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// If a load error occurs, report it and move on to the next file (if any)
|
||||
if (rinfo.fluenterror) {
|
||||
this.stat(HMEVENT.beforeConvert, {
|
||||
srcFile: src, //rinfo.file
|
||||
srcFmt: '???',
|
||||
dstFile: dst[idx],
|
||||
dstFmt: '???',
|
||||
error: true
|
||||
}
|
||||
);
|
||||
//@err rinfo.fluenterror, rinfo
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
// Determine the resume's SOURCE format
|
||||
// TODO: replace with detector component
|
||||
const { rez } = rinfo;
|
||||
let srcFmt = '';
|
||||
if (rez.meta && rez.meta.format) { //&& rez.meta.format.substr(0, 5).toUpperCase() == 'FRESH'
|
||||
srcFmt = 'FRESH';
|
||||
} else if (rez.basics) {
|
||||
srcFmt = 'JRS';
|
||||
} else {
|
||||
rinfo.fluenterror = HMSTATUS.unknownSchema;
|
||||
return rinfo;
|
||||
}
|
||||
|
||||
// Determine the TARGET format for the conversion
|
||||
const targetFormat = targetSchema || (srcFmt === 'JRS' ? 'FRESH' : 'JRS');
|
||||
|
||||
// Fire the beforeConvert event
|
||||
this.stat(HMEVENT.beforeConvert, {
|
||||
srcFile: rinfo.file,
|
||||
srcFmt,
|
||||
dstFile: dst[idx],
|
||||
dstFmt: targetFormat
|
||||
}
|
||||
);
|
||||
|
||||
// Save it to the destination format
|
||||
try {
|
||||
rez.saveAs(dst[idx], targetFormat);
|
||||
} catch (err) {
|
||||
if (err.badVer) {
|
||||
return {fluenterror: HMSTATUS.invalidSchemaVersion, quit: true, data: err.badVer};
|
||||
}
|
||||
}
|
||||
return rez;
|
||||
};
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Implementation of the 'create' verb for HackMyResume.
|
||||
@module verbs/create
|
||||
@ -6,55 +11,74 @@ Implementation of the 'create' verb for HackMyResume.
|
||||
|
||||
|
||||
|
||||
(function(){
|
||||
const MKDIRP = require('mkdirp');
|
||||
const PATH = require('path');
|
||||
const Verb = require('../verbs/verb');
|
||||
const _ = require('underscore');
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const HMEVENT = require('../core/event-codes');
|
||||
|
||||
|
||||
|
||||
var MKDIRP = require('mkdirp')
|
||||
, PATH = require('path')
|
||||
, chalk = require('chalk')
|
||||
, Verb = require('../verbs/verb')
|
||||
, _ = require('underscore')
|
||||
, HMSTATUS = require('../core/status-codes')
|
||||
, HMEVENT = require('../core/event-codes');
|
||||
class CreateVerb extends Verb {
|
||||
|
||||
constructor() { super('new', _create); }
|
||||
}
|
||||
|
||||
|
||||
module.exports = CreateVerb;
|
||||
|
||||
|
||||
|
||||
var CreateVerb = module.exports = Verb.extend({
|
||||
|
||||
init: function() {
|
||||
this._super('new');
|
||||
},
|
||||
|
||||
invoke: function() {
|
||||
this.stat( HMEVENT.begin, { cmd: 'create' });
|
||||
create.apply( this, arguments );
|
||||
this.stat( HMEVENT.begin, { cmd: 'convert' });
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Create a new empty resume in either FRESH or JRS format.
|
||||
*/
|
||||
function create( src, dst, opts ) {
|
||||
|
||||
if( !src || !src.length )
|
||||
throw { fluenterror: HMSTATUS.createNameMissing, quit: true };
|
||||
|
||||
_.each( src, function( t ) {
|
||||
var safeFmt = opts.format.toUpperCase();
|
||||
this.stat( HMEVENT.beforeCreate, { fmt: safeFmt, file: t } );
|
||||
MKDIRP.sync( PATH.dirname( t ) ); // Ensure dest folder exists;
|
||||
var RezClass = require('../core/' + safeFmt.toLowerCase() + '-resume' );
|
||||
RezClass.default().save(t);
|
||||
this.stat( HMEVENT.afterCreate, { fmt: safeFmt, file: t } );
|
||||
}, this);
|
||||
/** Create a new empty resume in either FRESH or JRS format. */
|
||||
var _create = function( src, dst, opts ) {
|
||||
|
||||
if (!src || !src.length) {
|
||||
this.err(HMSTATUS.createNameMissing, { quit: true });
|
||||
return null;
|
||||
}
|
||||
|
||||
const results = _.map(src, function( t ) {
|
||||
if (opts.assert && this.hasError()) { return { }; }
|
||||
const 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(this.errorCode);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
}());
|
||||
|
||||
/** Create a single new resume */
|
||||
var _createOne = function( t, opts ) {
|
||||
let ret, safeFmt;
|
||||
try {
|
||||
ret = null;
|
||||
safeFmt = opts.format.toUpperCase();
|
||||
this.stat(HMEVENT.beforeCreate, { fmt: safeFmt, file: t });
|
||||
MKDIRP.sync(PATH.dirname( t )); // Ensure dest folder exists;
|
||||
const RezClass = require(`../core/${safeFmt.toLowerCase()}-resume`);
|
||||
const newRez = RezClass.default();
|
||||
newRez.save(t);
|
||||
ret = newRez;
|
||||
} catch (err) {
|
||||
ret = {
|
||||
fluenterror: HMSTATUS.createError,
|
||||
inner: err
|
||||
};
|
||||
}
|
||||
finally {
|
||||
this.stat(HMEVENT.afterCreate, { fmt: safeFmt, file: t, isError: ret.fluenterror });
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Implementation of the 'peek' verb for HackMyResume.
|
||||
@module verbs/peek
|
||||
@ -6,78 +11,93 @@ Implementation of the 'peek' verb for HackMyResume.
|
||||
|
||||
|
||||
|
||||
(function(){
|
||||
const Verb = require('../verbs/verb');
|
||||
const _ = require('underscore');
|
||||
const __ = require('lodash');
|
||||
const safeLoadJSON = require('../utils/safe-json-loader');
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const HMEVENT = require('../core/event-codes');
|
||||
|
||||
|
||||
|
||||
var Verb = require('../verbs/verb')
|
||||
, _ = require('underscore')
|
||||
, __ = require('lodash')
|
||||
, safeLoadJSON = require('../utils/safe-json-loader')
|
||||
, HMSTATUS = require('../core/status-codes')
|
||||
, HMEVENT = require('../core/event-codes');
|
||||
class PeekVerb extends Verb {
|
||||
|
||||
constructor() { super('peek', _peek); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = PeekVerb;
|
||||
|
||||
var PeekVerb = module.exports = Verb.extend({
|
||||
|
||||
init: function() {
|
||||
this._super('peek');
|
||||
},
|
||||
|
||||
invoke: function() {
|
||||
this.stat( HMEVENT.begin, { cmd: 'peek' } );
|
||||
peek.apply( this, arguments );
|
||||
this.stat( HMEVENT.end );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Peek at a resume, resume section, or resume field.
|
||||
*/
|
||||
function peek( src, dst, opts ) {
|
||||
|
||||
if(!src || !src.length) throw {fluenterror: HMSTATUS.resumeNotFound};
|
||||
|
||||
var objPath = (dst && dst[0]) || '';
|
||||
|
||||
_.each( src, function( t ) {
|
||||
|
||||
// Fire the 'beforePeek' event 2nd, so we have error/warning/success
|
||||
this.stat( HMEVENT.beforePeek, { file: t, target: objPath } );
|
||||
|
||||
// Load the input file JSON 1st
|
||||
var obj = safeLoadJSON( t );
|
||||
|
||||
// Fetch the requested object path (or the entire file)
|
||||
var tgt;
|
||||
if( !obj.ex )
|
||||
tgt = objPath ? __.get( obj.json, objPath ) : obj.json;
|
||||
|
||||
// Fire the 'afterPeek' event with collected info
|
||||
this.stat( HMEVENT.afterPeek, {
|
||||
file: t,
|
||||
requested: objPath,
|
||||
target: tgt,
|
||||
error: obj.ex
|
||||
});
|
||||
|
||||
// safeLoadJSON can only return a READ error or a PARSE error
|
||||
if( obj.ex ) {
|
||||
var 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 );
|
||||
}
|
||||
|
||||
}, this);
|
||||
/** Peek at a resume, resume section, or resume field. */
|
||||
var _peek = function( src, dst, opts ) {
|
||||
|
||||
if (!src || !src.length) {
|
||||
this.err(HMSTATUS.resumeNotFound, { quit: true });
|
||||
return null;
|
||||
}
|
||||
|
||||
const objPath = (dst && dst[0]) || '';
|
||||
|
||||
const results = _.map(src, function( t ) {
|
||||
|
||||
if (opts.assert && this.hasError()) { return { }; }
|
||||
|
||||
const tgt = _peekOne.call(this, t, objPath);
|
||||
if (tgt.error) {
|
||||
this.setError(tgt.error.fluenterror, tgt.error);
|
||||
}
|
||||
//tgt.error.quit = opts.assert
|
||||
//@err tgt.error.fluenterror, tgt.error
|
||||
return 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. */
|
||||
var _peekOne = function( t, objPath ) {
|
||||
|
||||
this.stat(HMEVENT.beforePeek, { file: t, target: objPath });
|
||||
|
||||
// Load the input file JSON 1st
|
||||
const obj = safeLoadJSON(t);
|
||||
|
||||
// Fetch the requested object path (or the entire file)
|
||||
let tgt = null;
|
||||
if (!obj.ex) {
|
||||
tgt = objPath ? __.get(obj.json, objPath) : obj.json;
|
||||
}
|
||||
|
||||
//# safeLoadJSON can only return a READ error or a PARSE error
|
||||
let pkgError = null;
|
||||
if (obj.ex) {
|
||||
const errCode = obj.ex.op === 'parse' ? HMSTATUS.parseError : HMSTATUS.readError;
|
||||
if (errCode === HMSTATUS.readError) {
|
||||
obj.ex.quiet = true;
|
||||
}
|
||||
pkgError = {fluenterror: errCode, inner: obj.ex};
|
||||
}
|
||||
|
||||
// Fire the 'afterPeek' event with collected info
|
||||
this.stat(HMEVENT.afterPeek, {
|
||||
file: t,
|
||||
requested: objPath,
|
||||
target: obj.ex ? undefined : tgt,
|
||||
error: pkgError
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
val: obj.ex ? undefined : tgt,
|
||||
error: pkgError
|
||||
};
|
||||
};
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Implementation of the 'validate' verb for HackMyResume.
|
||||
@module verbs/validate
|
||||
@ -6,98 +11,103 @@ Implementation of the 'validate' verb for HackMyResume.
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
const Verb = require('../verbs/verb');
|
||||
const HMSTATUS = require('../core/status-codes');
|
||||
const HMEVENT = require('../core/event-codes');
|
||||
const _ = require('underscore');
|
||||
const safeLoadJSON = require('../utils/safe-json-loader');
|
||||
|
||||
|
||||
|
||||
var FS = require('fs');
|
||||
var ResumeFactory = require('../core/resume-factory');
|
||||
var SyntaxErrorEx = require('../utils/syntax-error-ex');
|
||||
var chalk = require('chalk');
|
||||
var Verb = require('../verbs/verb');
|
||||
var HMSTATUS = require('../core/status-codes');
|
||||
var HMEVENT = require('../core/event-codes');
|
||||
var _ = require('underscore');
|
||||
/** An invokable resume validation command. */
|
||||
class ValidateVerb extends Verb {
|
||||
constructor() { super('validate', _validate); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** An invokable resume validation command. */
|
||||
var ValidateVerb = module.exports = Verb.extend({
|
||||
|
||||
init: function() {
|
||||
this._super('validate');
|
||||
},
|
||||
|
||||
invoke: function() {
|
||||
this.stat( HMEVENT.begin, { cmd: 'validate' } );
|
||||
validate.apply( this, arguments );
|
||||
this.stat( HMEVENT.end );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
/** Validate 1 to N resumes in FRESH or JSON Resume format. */
|
||||
function validate( sources, unused, opts ) {
|
||||
|
||||
if( !sources || !sources.length )
|
||||
throw { fluenterror: HMSTATUS.resumeNotFoundAlt, quit: true };
|
||||
|
||||
var validator = require('is-my-json-valid');
|
||||
var schemas = {
|
||||
fresh: require('fresca'),
|
||||
jars: require('../core/resume.json')
|
||||
};
|
||||
|
||||
var resumes = ResumeFactory.load( sources, {
|
||||
format: null,
|
||||
objectify: false
|
||||
}, this );
|
||||
|
||||
// Validate input resumes. Return a { file: <f>, isValid: <v>} object for
|
||||
// each resume (valid, invalid, or broken).
|
||||
return resumes.map( function( src ) {
|
||||
|
||||
var ret = { file: src, isValid: false };
|
||||
|
||||
// If there was an error reading the resume
|
||||
if( src.fluenterror ) {
|
||||
if( opts.assert ) throw src;
|
||||
this.setError( src.fluenterror, src );
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Successfully read the resume. Now parse it as JSON.
|
||||
var json = src.json, fmt = json.basics ? 'jrs' : 'fresh', errors = [];
|
||||
try {
|
||||
var validate = validator( schemas[ fmt ], { // Note [1]
|
||||
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( exc ) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
this.stat( HMEVENT.afterValidate, { file: src.file, isValid: ret.isValid,
|
||||
fmt: fmt.replace( 'jars', 'JSON Resume' ), errors: errors });
|
||||
|
||||
if( opts.assert && !ret.isValid ) {
|
||||
throw { fluenterror: HMSTATUS.invalid, shouldExit: true };
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}, this);
|
||||
// Validate 1 to N resumes in FRESH or JSON Resume format.
|
||||
var _validate = function(sources, unused, opts) {
|
||||
|
||||
if (!sources || !sources.length) {
|
||||
this.err(HMSTATUS.resumeNotFoundAlt, {quit: true});
|
||||
return null;
|
||||
}
|
||||
|
||||
}());
|
||||
const validator = require('is-my-json-valid');
|
||||
const schemas = {
|
||||
fresh: require('fresh-resume-schema'),
|
||||
jars: require('../core/resume.json')
|
||||
};
|
||||
|
||||
const results = _.map(sources, function(t) {
|
||||
const r = _validateOne.call(this, t, validator, schemas, opts);
|
||||
if (r.error) { this.err(r.error.fluenterror, r.error); }
|
||||
return r;
|
||||
}
|
||||
, this);
|
||||
|
||||
if (this.hasError() && !opts.assert) {
|
||||
this.reject(this.errorCode);
|
||||
} else if (!this.hasError()) {
|
||||
this.resolve(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
module.exports = ValidateVerb;
|
||||
|
||||
/**
|
||||
Validate a single resume.
|
||||
@returns {
|
||||
file: <fileName>,
|
||||
isValid: <validFlag>,
|
||||
status: <validationStatus>,
|
||||
violations: <validationErrors>,
|
||||
schema: <schemaType>,
|
||||
error: <errorObject>
|
||||
}
|
||||
*/
|
||||
var _validateOne = function(t, validator, schemas) {
|
||||
|
||||
const ret = {file: t, isValid: false, status: 'unknown', schema: '-----'};
|
||||
|
||||
try {
|
||||
|
||||
// Read and parse the resume JSON. Won't throw.
|
||||
const obj = safeLoadJSON(t);
|
||||
|
||||
// If success, validate the resume against the schema
|
||||
if (!obj.ex) {
|
||||
if (obj.json.basics) { ret.schema = 'jars'; } else { ret.schema = 'fresh'; }
|
||||
const validate = validator(schemas[ ret.schema ], // Note [1]
|
||||
{formats: { date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/ }});
|
||||
ret.isValid = validate(obj.json);
|
||||
ret.status = ret.isValid ? 'valid' : 'invalid';
|
||||
if (!ret.isValid) { ret.violations = validate.errors; }
|
||||
|
||||
// If failure, package JSON read/parse errors
|
||||
} else {
|
||||
let errCode;
|
||||
if (obj.ex.op === 'parse') {
|
||||
errCode = HMSTATUS.parseError;
|
||||
ret.status = 'broken';
|
||||
} else {
|
||||
errCode = HMSTATUS.readError;
|
||||
ret.status = 'missing';
|
||||
}
|
||||
ret.error = {
|
||||
fluenterror: errCode,
|
||||
inner: obj.ex.inner,
|
||||
quiet: errCode === HMSTATUS.readError
|
||||
};
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
// Package any unexpected exceptions
|
||||
ret.error = {fluenterror: HMSTATUS.validateError, inner: err};
|
||||
}
|
||||
|
||||
this.stat(HMEVENT.afterValidate, ret);
|
||||
return ret;
|
||||
};
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
/**
|
||||
Definition of the Verb class.
|
||||
@module verbs/verb
|
||||
@ -6,91 +11,105 @@ Definition of the Verb class.
|
||||
|
||||
|
||||
|
||||
(function(){
|
||||
const EVENTS = require('events');
|
||||
const HMEVENT = require('../core/event-codes');
|
||||
const Promise = require('pinkie-promise');
|
||||
|
||||
|
||||
|
||||
// Use J. Resig's nifty class implementation
|
||||
var Class = require( '../utils/class' )
|
||||
, EVENTS = require('events');
|
||||
/**
|
||||
An abstract invokable verb.
|
||||
Provides base class functionality for verbs. Provide common services such as
|
||||
error handling, event management, and promise support.
|
||||
@class Verb
|
||||
*/
|
||||
|
||||
class Verb {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
An instantiation of a HackMyResume command.
|
||||
@class Verb
|
||||
*/
|
||||
var Verb = module.exports = Class.extend({
|
||||
/** Constructor. Automatically called at creation. */
|
||||
constructor( moniker, workhorse ) {
|
||||
this.moniker = moniker;
|
||||
this.workhorse = workhorse;
|
||||
this.emitter = new EVENTS.EventEmitter();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Constructor. Automatically called at creation.
|
||||
*/
|
||||
init: function( moniker ) {
|
||||
this.moniker = moniker;
|
||||
this.emitter = new EVENTS.EventEmitter();
|
||||
},
|
||||
/** Invoke the command. */
|
||||
invoke() {
|
||||
|
||||
// Sent the 'begin' notification for this verb
|
||||
this.stat(HMEVENT.begin, {cmd: this.moniker});
|
||||
|
||||
// Prepare command arguments
|
||||
const argsArray = Array.prototype.slice.call(arguments);
|
||||
|
||||
// Create a promise for this verb instance
|
||||
const 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.
|
||||
*/
|
||||
on: function() {
|
||||
this.emitter.on.apply( this.emitter, arguments );
|
||||
},
|
||||
/** Forward subscriptions to the event emitter. */
|
||||
on() { return this.emitter.on.apply(this.emitter, arguments); }
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Fire an arbitrary event, scoped to "hmr:".
|
||||
*/
|
||||
fire: function(evtName, payload) {
|
||||
payload = payload || { };
|
||||
payload.cmd = this.moniker;
|
||||
this.emitter.emit( 'hmr:' + evtName, payload );
|
||||
return true;
|
||||
},
|
||||
/** Fire an arbitrary event, scoped to "hmr:". */
|
||||
fire(evtName, payload) {
|
||||
payload = payload || { };
|
||||
payload.cmd = this.moniker;
|
||||
this.emitter.emit(`hmr:${evtName}`, payload);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Handle an error condition.
|
||||
*/
|
||||
err: function( errorCode, payload, hot ) {
|
||||
payload = payload || { };
|
||||
payload.sub = payload.fluenterror = errorCode;
|
||||
payload.throw = hot;
|
||||
this.fire( 'error', payload );
|
||||
if( hot ) throw payload;
|
||||
return true;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Fire the 'hmr:status' error event.
|
||||
*/
|
||||
stat: function( subEvent, payload ) {
|
||||
payload = payload || { };
|
||||
payload.sub = subEvent;
|
||||
this.fire('status', payload);
|
||||
return true;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
Associate error info with the invocation.
|
||||
*/
|
||||
setError: function( code, obj ) {
|
||||
this.errorCode = code;
|
||||
this.errorObj = obj;
|
||||
/** Handle an error condition. */
|
||||
err( errorCode, payload, hot ) {
|
||||
payload = payload || { };
|
||||
payload.sub = (payload.fluenterror = errorCode);
|
||||
payload.throw = hot;
|
||||
this.setError(errorCode, payload);
|
||||
if (payload.quit) {
|
||||
this.reject(errorCode);
|
||||
}
|
||||
this.fire('error', payload);
|
||||
if (hot) {
|
||||
throw payload;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
/** Fire the 'hmr:status' error event. */
|
||||
stat( subEvent, payload ) {
|
||||
payload = payload || { };
|
||||
payload.sub = subEvent;
|
||||
this.fire('status', payload);
|
||||
return true;
|
||||
}
|
||||
|
||||
}());
|
||||
|
||||
|
||||
/** Has an error occurred during this verb invocation? */
|
||||
hasError() { return this.errorCode || this.errorObj; }
|
||||
|
||||
|
||||
|
||||
/** Associate error info with the invocation. */
|
||||
setError( code, obj ) {
|
||||
this.errorCode = code;
|
||||
this.errorObj = obj;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Verb;
|
||||
|
12
test/all.js
Normal file
12
test/all.js
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
var MKDIRP = require('mkdirp');
|
||||
var PATH = require('path');
|
||||
MKDIRP( PATH.join( __dirname, '/sandbox' ) );
|
||||
|
||||
require('./scripts/test-cli');
|
||||
require('./scripts/test-fresh-sheet');
|
||||
require('./scripts/test-jrs-sheet');
|
||||
require('./scripts/test-themes');
|
||||
require('./scripts/test-verbs');
|
||||
require('./scripts/test-output');
|
||||
require('./scripts/test-dates');
|
204
test/expected/modern/modern-html.css
Normal file
204
test/expected/modern/modern-html.css
Normal file
@ -0,0 +1,204 @@
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
main {
|
||||
display: block;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Helvetica Neue', 'Helvetica', 'Segoe UI', 'Calibri', 'sans-serif';
|
||||
font-size: 15px;
|
||||
color: #333;
|
||||
line-height: 1.42857143;
|
||||
background-color: #F0F0F0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Typical page borders are awkward when rendered to PDF. */
|
||||
body.pdf {
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* Adobe or wkhtmltopdf has issues with the <main> tag, so we use <div> for
|
||||
the PDF case, <main> for the HTML case, and style both via an ID. */
|
||||
#main {
|
||||
background-color: #FFF;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
border: 1px solid #E6E6E6;
|
||||
}
|
||||
|
||||
body.pdf > #main {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#container > header {
|
||||
padding-top: 6em;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
body.pdf #container > header {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#main > #container > section {
|
||||
margin-left: 5em;
|
||||
position: relative;
|
||||
display: block;
|
||||
}
|
||||
|
||||
span.fa
|
||||
{
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: -50px;
|
||||
font-size: 30px;
|
||||
color: #BFC1C3;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
border: 0;
|
||||
border-top: 1px solid #EEE;
|
||||
}
|
||||
|
||||
.tenure, .keywords {
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 46px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
color: #BFC1C3;
|
||||
text-transform: uppercase;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-bottom: 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: #428BCA;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.defunct {
|
||||
color: #989898;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#summary > p > strong {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
|
||||
.label-keyword {
|
||||
display: inline-block;
|
||||
background: #7eb0db;
|
||||
color: white;
|
||||
font-size: 0.9em;
|
||||
padding: 5px;
|
||||
border: 1px solid #357ebd;
|
||||
border-radius: 5px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.card-skills {
|
||||
position: relative;
|
||||
}
|
||||
.card-nested {
|
||||
min-height: 0;
|
||||
margin-bottom: 10px;
|
||||
border-width: 1px 0 0 0;
|
||||
}
|
||||
.card {
|
||||
background: #FFF;
|
||||
border-radius: 3px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.skill-level {
|
||||
border-radius: 3px;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
bottom: 10px;
|
||||
left: 0;
|
||||
width: 10px;
|
||||
box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.skill-level .skill-progress {
|
||||
position: absolute;
|
||||
border-radius: 3px;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
-webkit-transition: height 1s ease;
|
||||
}
|
||||
.skill-level .skill-progress.beginner {
|
||||
height: 50%;
|
||||
background: #e74c3c;
|
||||
}
|
||||
.skill-level .skill-progress.intermediate {
|
||||
height: 70%;
|
||||
background: #f1c40f;
|
||||
}
|
||||
.skill-level .skill-progress.advanced {
|
||||
height: 80%;
|
||||
background: #428bca;
|
||||
}
|
||||
.skill-level .skill-progress.master {
|
||||
height: 95%;
|
||||
background: #5cb85c;
|
||||
}
|
||||
.skill-info {
|
||||
margin-left: 10px;
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.skill-info {
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.list-unstyled {
|
||||
padding-left: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.card-skills {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.space-top {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#elevator-pitch {
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
color: #BFC1C3;
|
||||
text-transform: uppercase;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.res-label {
|
||||
font-style: italic;
|
||||
}
|
203
test/expected/modern/modern-pdf.css
Normal file
203
test/expected/modern/modern-pdf.css
Normal file
@ -0,0 +1,203 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
main {
|
||||
display: block;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Helvetica Neue', 'Helvetica', 'Segoe UI', 'Calibri', 'sans-serif';
|
||||
font-size: 15px;
|
||||
color: #333;
|
||||
line-height: 1.42857143;
|
||||
background-color: #F0F0F0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Typical page borders are awkward when rendered to PDF. */
|
||||
body {
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* Adobe or wkhtmltopdf has issues with the <main> tag, so we use <div> for
|
||||
the PDF case, <main> for the HTML case, and style both via an ID. */
|
||||
#main {
|
||||
background-color: #FFF;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
border: 1px solid #E6E6E6;
|
||||
}
|
||||
|
||||
body > #main {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#container > header {
|
||||
padding-top: 6em;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
body.pdf #container > header {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#main > #container > section {
|
||||
margin-left: 5em;
|
||||
position: relative;
|
||||
display: block;
|
||||
}
|
||||
|
||||
span.fa
|
||||
{
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: -50px;
|
||||
font-size: 30px;
|
||||
color: #BFC1C3;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
border: 0;
|
||||
border-top: 1px solid #EEE;
|
||||
}
|
||||
|
||||
.tenure, .keywords {
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 46px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
color: #BFC1C3;
|
||||
text-transform: uppercase;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-bottom: 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: #428BCA;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.defunct {
|
||||
color: #989898;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#summary > p > strong {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
|
||||
.label-keyword {
|
||||
display: inline-block;
|
||||
background: #7eb0db;
|
||||
color: white;
|
||||
font-size: 0.9em;
|
||||
padding: 5px;
|
||||
border: 1px solid #357ebd;
|
||||
border-radius: 5px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.card-skills {
|
||||
position: relative;
|
||||
}
|
||||
.card-nested {
|
||||
min-height: 0;
|
||||
margin-bottom: 10px;
|
||||
border-width: 1px 0 0 0;
|
||||
}
|
||||
.card {
|
||||
background: #FFF;
|
||||
border-radius: 3px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.skill-level {
|
||||
border-radius: 3px;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
bottom: 10px;
|
||||
left: 0;
|
||||
width: 10px;
|
||||
box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.skill-level .skill-progress {
|
||||
position: absolute;
|
||||
border-radius: 3px;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
-webkit-transition: height 1s ease;
|
||||
}
|
||||
.skill-level .skill-progress.beginner {
|
||||
height: 50%;
|
||||
background: #e74c3c;
|
||||
}
|
||||
.skill-level .skill-progress.intermediate {
|
||||
height: 70%;
|
||||
background: #f1c40f;
|
||||
}
|
||||
.skill-level .skill-progress.advanced {
|
||||
height: 80%;
|
||||
background: #428bca;
|
||||
}
|
||||
.skill-level .skill-progress.master {
|
||||
height: 95%;
|
||||
background: #5cb85c;
|
||||
}
|
||||
.skill-info {
|
||||
margin-left: 10px;
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.skill-info {
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.list-unstyled {
|
||||
padding-left: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.card-skills {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.space-top {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#elevator-pitch {
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
color: #BFC1C3;
|
||||
text-transform: uppercase;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.res-label {
|
||||
font-style: italic;
|
||||
}
|
2586
test/expected/modern/resume.doc
Normal file
2586
test/expected/modern/resume.doc
Normal file
File diff suppressed because it is too large
Load Diff
709
test/expected/modern/resume.html
Normal file
709
test/expected/modern/resume.html
Normal file
@ -0,0 +1,709 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Jane Q. Fullstacker</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic'
|
||||
rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
main {
|
||||
display: block;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Helvetica Neue', 'Helvetica', 'Segoe UI', 'Calibri', 'sans-serif';
|
||||
font-size: 15px;
|
||||
color: #333;
|
||||
line-height: 1.42857143;
|
||||
background-color: #F0F0F0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Typical page borders are awkward when rendered to PDF. */
|
||||
body.pdf {
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* Adobe or wkhtmltopdf has issues with the <main> tag, so we use <div> for
|
||||
the PDF case, <main> for the HTML case, and style both via an ID. */
|
||||
#main {
|
||||
background-color: #FFF;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
border: 1px solid #E6E6E6;
|
||||
}
|
||||
|
||||
body.pdf > #main {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#container > header {
|
||||
padding-top: 6em;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
body.pdf #container > header {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#main > #container > section {
|
||||
margin-left: 5em;
|
||||
position: relative;
|
||||
display: block;
|
||||
}
|
||||
|
||||
span.fa
|
||||
{
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
left: -50px;
|
||||
font-size: 30px;
|
||||
color: #BFC1C3;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
border: 0;
|
||||
border-top: 1px solid #EEE;
|
||||
}
|
||||
|
||||
.tenure, .keywords {
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 46px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
color: #BFC1C3;
|
||||
text-transform: uppercase;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-bottom: 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: #428BCA;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.defunct {
|
||||
color: #989898;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#summary > p > strong {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
|
||||
.label-keyword {
|
||||
display: inline-block;
|
||||
background: #7eb0db;
|
||||
color: white;
|
||||
font-size: 0.9em;
|
||||
padding: 5px;
|
||||
border: 1px solid #357ebd;
|
||||
border-radius: 5px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.card-skills {
|
||||
position: relative;
|
||||
}
|
||||
.card-nested {
|
||||
min-height: 0;
|
||||
margin-bottom: 10px;
|
||||
border-width: 1px 0 0 0;
|
||||
}
|
||||
.card {
|
||||
background: #FFF;
|
||||
border-radius: 3px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.skill-level {
|
||||
border-radius: 3px;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
bottom: 10px;
|
||||
left: 0;
|
||||
width: 10px;
|
||||
box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.skill-level .skill-progress {
|
||||
position: absolute;
|
||||
border-radius: 3px;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
-webkit-transition: height 1s ease;
|
||||
}
|
||||
.skill-level .skill-progress.beginner {
|
||||
height: 50%;
|
||||
background: #e74c3c;
|
||||
}
|
||||
.skill-level .skill-progress.intermediate {
|
||||
height: 70%;
|
||||
background: #f1c40f;
|
||||
}
|
||||
.skill-level .skill-progress.advanced {
|
||||
height: 80%;
|
||||
background: #428bca;
|
||||
}
|
||||
.skill-level .skill-progress.master {
|
||||
height: 95%;
|
||||
background: #5cb85c;
|
||||
}
|
||||
.skill-info {
|
||||
margin-left: 10px;
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.skill-info {
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.list-unstyled {
|
||||
padding-left: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.card-skills {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.space-top {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#elevator-pitch {
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
color: #BFC1C3;
|
||||
text-transform: uppercase;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.res-label {
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main id="main">
|
||||
<div id="container">
|
||||
<header>
|
||||
<h1>Jane Q. Fullstacker</h1>
|
||||
<div id="contact"></div>
|
||||
</header>
|
||||
<hr>
|
||||
<section id="summary">
|
||||
<header> <span class="fa fa-lg fa-info"></span>
|
||||
<h2>info</h2>
|
||||
|
||||
</header> <strong>Imaginary full-stack software developer with 6+ years industry experience</strong> specializing
|
||||
in cloud-driven web applications and middleware. A native of southern CA,
|
||||
Jane enjoys hiking, mystery novels, and the company of Rufus, her two year
|
||||
old beagle.</section>
|
||||
<hr>
|
||||
<section id="skills">
|
||||
<header>
|
||||
<h2>Skills</h2>
|
||||
</header> <span class="fa fa-lg fa-code"></span>
|
||||
<ul class="list-unstyled">
|
||||
<li class="card card-nested card-skills">
|
||||
<div class="skill-level" rel="tooltip" title="advanced" data-placement="left">
|
||||
<div class="skill-progress advanced"></div>
|
||||
</div>
|
||||
<div class="skill-info"> <strong>Web</strong>
|
||||
<div class="space-top labels"> <span class="label label-keyword">JavaScript</span>
|
||||
<span class="label label-keyword">HTML 5</span>
|
||||
<span
|
||||
class="label label-keyword">CSS</span> <span class="label label-keyword">LAMP</span>
|
||||
<span class="label label-keyword">MVC</span>
|
||||
<span
|
||||
class="label label-keyword">REST</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="card card-nested card-skills">
|
||||
<div class="skill-level" rel="tooltip" title="master" data-placement="left">
|
||||
<div class="skill-progress master"></div>
|
||||
</div>
|
||||
<div class="skill-info"> <strong>JavaScript</strong>
|
||||
<div class="space-top labels"> <span class="label label-keyword">Node.js</span>
|
||||
<span class="label label-keyword">Angular.js</span>
|
||||
<span
|
||||
class="label label-keyword">jQuery</span> <span class="label label-keyword">Bootstrap</span>
|
||||
<span class="label label-keyword">React.js</span>
|
||||
<span
|
||||
class="label label-keyword">Backbone.js</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="card card-nested card-skills">
|
||||
<div class="skill-level" rel="tooltip" title="intermediate" data-placement="left">
|
||||
<div class="skill-progress intermediate"></div>
|
||||
</div>
|
||||
<div class="skill-info"> <strong>Database</strong>
|
||||
<div class="space-top labels"> <span class="label label-keyword">MySQL</span>
|
||||
<span class="label label-keyword">PostgreSQL</span>
|
||||
<span
|
||||
class="label label-keyword">NoSQL</span> <span class="label label-keyword">ORM</span>
|
||||
<span class="label label-keyword">Hibernate</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="card card-nested card-skills">
|
||||
<div class="skill-level" rel="tooltip" title="intermediate" data-placement="left">
|
||||
<div class="skill-progress intermediate"></div>
|
||||
</div>
|
||||
<div class="skill-info"> <strong>Cloud</strong>
|
||||
<div class="space-top labels"> <span class="label label-keyword">AWS</span>
|
||||
<span class="label label-keyword">EC2</span>
|
||||
<span
|
||||
class="label label-keyword">RDS</span> <span class="label label-keyword">S3</span>
|
||||
<span class="label label-keyword">Azure</span>
|
||||
<span
|
||||
class="label label-keyword">Dropbox</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="card card-nested card-skills">
|
||||
<div class="skill-level" rel="tooltip" title="beginner" data-placement="left">
|
||||
<div class="skill-progress beginner"></div>
|
||||
</div>
|
||||
<div class="skill-info"> <strong>Project</strong>
|
||||
<div class="space-top labels"> <span class="label label-keyword">Agile</span>
|
||||
<span class="label label-keyword">TFS</span>
|
||||
<span
|
||||
class="label label-keyword">JIRA</span> <span class="label label-keyword">GitHub</span>
|
||||
<span class="label label-keyword">Unified Process</span>
|
||||
<span
|
||||
class="label label-keyword">MS Project</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="employment">
|
||||
<header> <span class="fa fa-lg fa-building"></span>
|
||||
<h2>employment</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3><em>Head Code Ninja</em>,
|
||||
|
||||
<a href="https://area52.io/does-not-exist">Area 52</a>
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2013-09 — Present</span>
|
||||
| <span class="keywords">Agile PM C C++ R OpenGL Boost MySQL PostgreSQL JIRA </span>
|
||||
<p>
|
||||
<p>Development team manager for <a href="https://en.wikipedia.org/wiki/Vaporware"><strong>Quantum Diorama</strong></a>,
|
||||
a distributed molecular modeling and analysis suite for Linux and OS X.</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>Managed a 5-person development team</li>
|
||||
<li>Accomplishment 2</li>
|
||||
<li>Etc.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em>Principal Developer</em>,
|
||||
|
||||
<a href="https://en.wikipedia.org/wiki/Better_Off_Ted#Plot">Veridian Dynamics</a>
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2011-07 — 2013-08</span>
|
||||
| <span class="keywords">C++ C Linux R Clojure </span>
|
||||
<p>
|
||||
<p>Developer on numerous projects culminating in technical lead role for
|
||||
the <a href="http://betteroffted.wikia.com/wiki/Jabberwocky">Jabberwocky project</a> and
|
||||
promotion to principal developer.</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>Managed a 5-person development team</li>
|
||||
<li>Accomplishment 2</li>
|
||||
<li>Etc.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em>IT Administrator</em>,
|
||||
|
||||
Stark Industries
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2008-10 — 2011-06</span>
|
||||
| <span class="keywords">Novell Active Directory Linux Windows </span>
|
||||
<p>
|
||||
<p>Junior programmer with heavy code responsibilities. Promoted to intermediate
|
||||
role after 6 months.</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>Promoted to intermediate developer after 6 months</li>
|
||||
<li>Accomplishment 2</li>
|
||||
<li>Etc.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em>Intern</em>,
|
||||
|
||||
Dunder Mifflin
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2008-06 — 2008-09</span>
|
||||
| <span class="keywords">Novell Active Directory Linux Windows </span>
|
||||
<p>
|
||||
<p>Performed IT administration and deployments for Dunder Mifflin.</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>Supervised roll-out of Dunder Mifflin Infinity website.</li>
|
||||
<li>Performed mission-critical system backups and</li>
|
||||
<li>Etc.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="projects">
|
||||
<header> <span class="fa fa-lg fa-star"></span>
|
||||
<h2>projects</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
|
||||
<h3><em>Contributor</em>,
|
||||
|
||||
<a href="https://fluentdesk.com/hackmyresume">HackMyResume</a>
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2015-09 — Present</span>
|
||||
| <span class="keywords">JavaScript Node.js cross-platform JSON </span>
|
||||
<p>Exemplar user for HackMyResume and FluentCV!</p>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<h3><em>Co-creator</em>,
|
||||
|
||||
<a href="http://project.website.com">Augmented Android</a>
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2012-02 — 2014-01</span>
|
||||
| <span class="keywords">Android Java Xamarin </span>
|
||||
<p>Performed flagship product conceptualization and development.</p>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<h3><em>Creator</em>,
|
||||
|
||||
<a href="http://myblog.jane.com/blog">Blog</a>
|
||||
|
||||
</h3>
|
||||
<span class="keywords">Jekyll Ruby HTML 5 JavaScript HTTP LAMP </span>
|
||||
<p>Conceptualization, design, development, and deployment.</p>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="education">
|
||||
<header> <span class="fa fa-lg fa-mortar-board"></span>
|
||||
<h2>education</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
|
||||
<h3><em>BSCS</em>,
|
||||
|
||||
<a href="https://www.cornell.edu/">Cornell University</a>
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2005-09 — 2008-05</span>
|
||||
| <span class="keywords">Course 1 Course 2 Course 2 </span>
|
||||
<p>A multiline summary of the education.</p>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<h3>
|
||||
|
||||
<a href="https://en.wikipedia.org/wiki/Medfield_College">Medfield College</a>
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2003-09 — 2005-06</span>
|
||||
| <span class="keywords">Course 1 Course 2 Course 2 </span>
|
||||
<p>A multiline summary of the education.</p>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="governance">
|
||||
<header> <span class="fa fa-lg fa-balance-scale"></span>
|
||||
<h2>governance</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
|
||||
<h3><em>Member</em>,
|
||||
|
||||
<a href="http://themommiesnetwork.org">The Mommies Network</a>
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2008-02 — 2010-01</span>
|
||||
<p>Since 2008 I've been a full-time member of the board of directors
|
||||
for TMN.</p>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
<h3><em>Academic Contributor</em>,
|
||||
|
||||
<a href="https://www.khronos.org">Khronos Group</a>
|
||||
|
||||
</h3>
|
||||
<span class="tenure">2015-01 — Present</span>
|
||||
<ul>
|
||||
<li>Participated in GORFF standardization process (Draft 2).</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="service">
|
||||
<header> <span class="fa fa-lg fa-child"></span>
|
||||
<h2>service</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3><em>Technical Consultant</em>,
|
||||
<a href="http://technology-for-tots.org">Technology for Tots</a>
|
||||
</h3>
|
||||
<span class="tenure">2003-11 — 2005-06</span>
|
||||
|
||||
<p>
|
||||
<p>Summary of this volunteer stint.</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>Accomplishment 1</li>
|
||||
<li>Accomplishment 2</li>
|
||||
<li>etc</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em>NCO</em>,
|
||||
<a href="http://www.usar.army.mil/">US Army Reserves</a>
|
||||
</h3>
|
||||
<span class="tenure">1999-11 — 2003-06</span>
|
||||
|
||||
<p>
|
||||
<p>Summary of this military stint.</p>
|
||||
</p>
|
||||
<ul>
|
||||
<li>Accomplishment 1</li>
|
||||
<li>Accomplishment 2</li>
|
||||
<li>etc</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="affiliation">
|
||||
<header> <span class="fa fa-lg fa-share-alt"></span>
|
||||
<h2>affiliation</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3><em>Member</em>,
|
||||
<a href="https://www.ieee.org/index.html">IEEE</a>
|
||||
</h3>
|
||||
<span class="tenure">2013-06 — Present</span>
|
||||
|
||||
<p>Member in good standing since 2013-06.</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em>Member</em>,
|
||||
<a href="https://developer.apple.com/">Apple Developer Network</a>
|
||||
</h3>
|
||||
<span class="tenure">??? — Present</span>
|
||||
|
||||
<p>Member of the <a href="https://developer.apple.com/">Apple Developer program</a> since
|
||||
2008.</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em>Subscriber</em>,
|
||||
<a href="https://msdn.microsoft.com">MSDN</a>
|
||||
</h3>
|
||||
<span class="tenure">2010-01 — Present</span>
|
||||
|
||||
<p>Super-Ultra-gold level Ultimate Access MSDN subscriber package with subscription
|
||||
toaster and XBox ping pong racket.</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em>Coordinator</em>,
|
||||
Campus Coder's Meetup
|
||||
</h3>
|
||||
<span class="tenure">2003-02 — 2004-04</span>
|
||||
|
||||
<p>Host of a monthly <strong>campus-wide meetup for CS students</strong>.
|
||||
Code, coffee, and crullers!</p>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="samples">
|
||||
<header> <span class="fa fa-lg fa-share"></span>
|
||||
<h2>samples</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3>
|
||||
<a href="http://janef.me/asteroids">Asteroids</a>
|
||||
</h3>
|
||||
<span class="tenure">2014-09</span>
|
||||
|
||||
<p>A browser-based space shooter built on Three.js.</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3>
|
||||
<a href="https://rememberpedia.com">Rememberpedia</a>
|
||||
</h3>
|
||||
<span class="tenure">2015-07</span>
|
||||
|
||||
<p>A website to help you remember things.</p>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="writing">
|
||||
<header> <span class="fa fa-lg fa-pencil"></span>
|
||||
<h2>writing</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3><em><a href="http://codeproject.com/build-ui-electron-atom.aspx">Building User Interfaces with Electron and Atom</a></em>,
|
||||
Code Project</h3>
|
||||
<span class="tenure">2011</span>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<h3><em><a href="http://janef.me">Jane Fullstacker's Blog</a></em>,
|
||||
self</h3>
|
||||
<span class="tenure">2011</span>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<h3><em><a href="http://url.to.publication.com/blah">Teach Yourself GORFF in 21 Days</a></em>,
|
||||
Amazon</h3>
|
||||
<span class="tenure">2008</span>
|
||||
|
||||
<p>A primer on the programming language of GORFF, whose for loops are coterminous
|
||||
with all of time and space.</p>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="reading">
|
||||
<header> <span class="fa fa-lg fa-book"></span>
|
||||
<h2>reading</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3><em><a href="https://www.reddit.com/r/programming/">r/programming</a></em></h3>
|
||||
<span class="tenure">Current</span>
|
||||
|
||||
<p>Daily reader and longtime lurker.</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em><a href="https://news.ycombinator.com/">Hacker News / YCombinator</a></em></h3>
|
||||
<span class="tenure">Current</span>
|
||||
|
||||
<p>Daily reader and longtime lurker.</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em><a href="http://www.codinghorror.com">Coding Horror</a></em>, Jeff Atwood</h3>
|
||||
<span class="tenure">Current</span>
|
||||
|
||||
<p>Reader since 2007; member of the StackOverflow Beta.</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em><a href="http://www.cc2e.com/Default.aspx">Code Complete</a></em>, Steve McConnell</h3>
|
||||
<span class="tenure">2014</span>
|
||||
|
||||
<p>My 'desert-island' software construction manual.</p>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="recognition">
|
||||
<header> <span class="fa fa-lg fa-trophy"></span>
|
||||
<h2>recognition</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3><em>Honorable Mention</em>, Google</h3>
|
||||
<span class="tenure">2012</span>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<h3><em>Summa cum laude</em>, Cornell University</h3>
|
||||
<span class="tenure">2012</span>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="speaking">
|
||||
<header> <span class="fa fa-lg fa-users"></span>
|
||||
<h2>speaking</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3><em>Data Warehousing Evolved: DARMA 2.0</em>, OPENSTART 2013 Developer's Conference</h3>
|
||||
<span class="tenure">2012</span>
|
||||
|
||||
<ul>
|
||||
<li>Won 'Best Presentation on an Emerging Technical Field' prize.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="testimonials">
|
||||
<header> <span class="fa fa-lg fa-quote-left"></span>
|
||||
<h2>testimonials</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3><em>John Davidson</em></h3>
|
||||
|
||||
<p>Jane is awesome! I'd hire her again in a heartbeat.</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><em>Dana Nevins</em></h3>
|
||||
|
||||
<p>I've known Jane personally and professionally for almost ten years.
|
||||
She is one in a million.</p>
|
||||
</div>
|
||||
</section>
|
||||
<hr>
|
||||
<section id="interests">
|
||||
<header> <span class="fa fa-lg fa-bicycle"></span>
|
||||
<h2>interests</h2>
|
||||
|
||||
</header>
|
||||
<div>
|
||||
<h3><em>reading</em></h3>
|
||||
<span class="tenure">Current</span>
|
@ -2,7 +2,7 @@
|
||||
"basics": {
|
||||
"name": "Jane Q. Fullstacker",
|
||||
"label": "Senior Developer",
|
||||
"summary": "**Full-stack software developer with 6+ years industry experience** specializing in scalable cloud architectures for this, that, and the other. A native of southern CA, Jane enjoys hiking, mystery novels, and the company of Rufus, her two-year-old beagle.",
|
||||
"summary": "**Imaginary full-stack software developer with 6+ years industry experience** specializing in cloud-driven web applications and middleware. A native of southern CA, Jane enjoys hiking, mystery novels, and the company of Rufus, her two year old beagle.",
|
||||
"website": "http://janef.me/blog",
|
||||
"phone": "1-650-999-7777",
|
||||
"email": "jdoe@onecoolstartup.io",
|
||||
@ -29,11 +29,11 @@
|
||||
},
|
||||
"work": [
|
||||
{
|
||||
"company": "One Cool Startup",
|
||||
"website": "https://onecool.io/does-not-exist",
|
||||
"company": "Area 52",
|
||||
"website": "https://area52.io/does-not-exist",
|
||||
"position": "Head Code Ninja",
|
||||
"startDate": "2013-09",
|
||||
"summary": "Development team manager for OneCoolApp and OneCoolWebsite, a free social network tiddlywink generator and lifestyle portal with over 200,000 users.",
|
||||
"summary": "Development team manager for [**Quantum Diorama**](https://en.wikipedia.org/wiki/Vaporware), a distributed molecular modeling and analysis suite for Linux and OS X.",
|
||||
"highlights": [
|
||||
"Managed a 5-person development team",
|
||||
"Accomplishment 2",
|
||||
@ -104,7 +104,8 @@
|
||||
],
|
||||
"skills": [
|
||||
{
|
||||
"name": "Web Dev",
|
||||
"name": "Web",
|
||||
"level": "advanced",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
"HTML 5",
|
||||
@ -116,6 +117,7 @@
|
||||
},
|
||||
{
|
||||
"name": "JavaScript",
|
||||
"level": "master",
|
||||
"keywords": [
|
||||
"Node.js",
|
||||
"Angular.js",
|
||||
@ -127,6 +129,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Database",
|
||||
"level": "intermediate",
|
||||
"keywords": [
|
||||
"MySQL",
|
||||
"PostgreSQL",
|
||||
@ -137,6 +140,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Cloud",
|
||||
"level": "intermediate",
|
||||
"keywords": [
|
||||
"AWS",
|
||||
"EC2",
|
||||
@ -148,9 +152,12 @@
|
||||
},
|
||||
{
|
||||
"name": "Project",
|
||||
"level": "beginner",
|
||||
"keywords": [
|
||||
"Agile",
|
||||
"TFS",
|
||||
"JIRA",
|
||||
"GitHub",
|
||||
"Unified Process",
|
||||
"MS Project"
|
||||
]
|
||||
@ -158,6 +165,7 @@
|
||||
],
|
||||
"volunteer": [
|
||||
{
|
||||
"flavor": "volunteer",
|
||||
"organization": "Technology for Tots",
|
||||
"position": "Technical Consultant",
|
||||
"startDate": "2003-11",
|
||||
@ -171,6 +179,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"flavor": "military",
|
||||
"organization": "US Army Reserves",
|
||||
"position": "NCO",
|
||||
"startDate": "1999-11",
|
||||
@ -186,11 +195,13 @@
|
||||
],
|
||||
"awards": [
|
||||
{
|
||||
"flavor": "award",
|
||||
"title": "Honorable Mention",
|
||||
"date": "2012",
|
||||
"awarder": "Google"
|
||||
},
|
||||
{
|
||||
"flavor": "honor",
|
||||
"title": "Summa cum laude",
|
||||
"date": "2012",
|
||||
"awarder": "Cornell University"
|
||||
@ -240,10 +251,6 @@
|
||||
"name": "John Davidson",
|
||||
"reference": "Jane is awesome! I'd hire her again in a heartbeat."
|
||||
},
|
||||
{
|
||||
"name": "Elias Fullstacker",
|
||||
"reference": "I worked with Jane on Jabberwocky and can vouch for her awesome technical capabilities and attention to detail. Insta-hire."
|
||||
},
|
||||
{
|
||||
"name": "Dana Nevins",
|
||||
"reference": "I've known Jane personally and professionally for almost ten years. She is one in a million."
|
||||
@ -259,5 +266,53 @@
|
||||
"level": "Moderate",
|
||||
"years": 10
|
||||
}
|
||||
],
|
||||
"projects": [
|
||||
{
|
||||
"name": "HackMyResume",
|
||||
"description": "A resume authoring and analysis tool for OS X, Linux, and Windows.",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
"Node.js",
|
||||
"cross-platform",
|
||||
"JSON"
|
||||
],
|
||||
"startDate": "2015-09",
|
||||
"url": "https://fluentdesk.com/hackmyresume",
|
||||
"roles": [
|
||||
"contributor"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Augmented Android",
|
||||
"description": "An augmented reality app for Android.",
|
||||
"keywords": [
|
||||
"Android",
|
||||
"Java",
|
||||
"Xamarin"
|
||||
],
|
||||
"startDate": "2012-02",
|
||||
"endDate": "2014-01",
|
||||
"url": "http://project.website.com",
|
||||
"roles": [
|
||||
"co-creator"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Blog",
|
||||
"description": "My programming blog. Powered by Jekyll.",
|
||||
"keywords": [
|
||||
"Jekyll",
|
||||
"Ruby",
|
||||
"HTML 5",
|
||||
"JavaScript",
|
||||
"HTTP",
|
||||
"LAMP"
|
||||
],
|
||||
"url": "http://myblog.jane.com/blog",
|
||||
"roles": [
|
||||
"creator"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
194
test/expected/modern/resume.md
Normal file
194
test/expected/modern/resume.md
Normal file
@ -0,0 +1,194 @@
|
||||
Jane Q. Fullstacker
|
||||
============
|
||||
Email: jdoe@onecoolstartup.io
|
||||
Tel: 1-650-999-7777
|
||||
Web: http://janef.me/blog
|
||||
|
||||
**Imaginary full-stack software developer with 6+ years industry experience** specializing in cloud-driven web applications and middleware. A native of southern CA, Jane enjoys hiking, mystery novels, and the company of Rufus, her two year old beagle.
|
||||
|
||||
## SKILLS
|
||||
|
||||
- Web: JavaScript HTML 5 CSS LAMP MVC REST
|
||||
- JavaScript: Node.js Angular.js jQuery Bootstrap React.js Backbone.js
|
||||
- Database: MySQL PostgreSQL NoSQL ORM Hibernate
|
||||
- Cloud: AWS EC2 RDS S3 Azure Dropbox
|
||||
- Project: Agile TFS JIRA GitHub Unified Process MS Project
|
||||
|
||||
## EMPLOYMENT
|
||||
|
||||
### *Head Code Ninja*, [Area 52](https://area52.io/does-not-exist) (2013-09 — Present)
|
||||
|
||||
Development team manager for [**Quantum Diorama**](https://en.wikipedia.org/wiki/Vaporware), a distributed molecular modeling and analysis suite for Linux and OS X.
|
||||
- Managed a 5-person development team
|
||||
- Accomplishment 2
|
||||
- Etc.
|
||||
|
||||
### *Principal Developer*, [Veridian Dynamics](https://en.wikipedia.org/wiki/Better_Off_Ted#Plot) (2011-07 — 2013-08)
|
||||
|
||||
Developer on numerous projects culminating in technical lead role for the [Jabberwocky project](http://betteroffted.wikia.com/wiki/Jabberwocky) and promotion to principal developer.
|
||||
- Managed a 5-person development team
|
||||
- Accomplishment 2
|
||||
- Etc.
|
||||
|
||||
### *IT Administrator*, Stark Industries (2008-10 — 2011-06)
|
||||
|
||||
Junior programmer with heavy code responsibilities. Promoted to intermediate role after 6 months.
|
||||
- Promoted to intermediate developer after 6 months
|
||||
- Accomplishment 2
|
||||
- Etc.
|
||||
|
||||
### *Intern*, Dunder Mifflin (2008-06 — 2008-09)
|
||||
|
||||
Performed IT administration and deployments for Dunder Mifflin.
|
||||
- Supervised roll-out of Dunder Mifflin Infinity website.
|
||||
- Performed mission-critical system backups and
|
||||
- Etc.
|
||||
|
||||
|
||||
## PROJECTS
|
||||
|
||||
### *Contributor*, [HackMyResume](https://fluentdesk.com/hackmyresume) (2015-09 — Present)
|
||||
|
||||
A resume authoring and analysis tool for OS X, Linux, and Windows.
|
||||
Exemplar user for HackMyResume and FluentCV!
|
||||
|
||||
### *Co-creator*, [Augmented Android](http://project.website.com) (2012-02 — 2014-01)
|
||||
|
||||
An augmented reality app for Android.
|
||||
Performed flagship product conceptualization and development.
|
||||
|
||||
### *Creator*, [Blog](http://myblog.jane.com/blog) (??? — Present)
|
||||
|
||||
My programming blog. Powered by Jekyll.
|
||||
Conceptualization, design, development, and deployment.
|
||||
|
||||
|
||||
## GOVERNANCE
|
||||
|
||||
### *Member*, [The Mommies Network](http://themommiesnetwork.org)
|
||||
|
||||
Since 2008 I've been a full-time member of the board of directors for TMN.
|
||||
|
||||
### *Academic Contributor*, [Khronos Group](https://www.khronos.org)
|
||||
|
||||
- Participated in GORFF standardization process (Draft 2).
|
||||
|
||||
|
||||
|
||||
## EDUCATION
|
||||
|
||||
### [Cornell University](https://www.cornell.edu/) (2005-09 — 2008-05)
|
||||
|
||||
A multiline summary of the education.
|
||||
|
||||
|
||||
### [Medfield College](https://en.wikipedia.org/wiki/Medfield_College) (2003-09 — 2005-06)
|
||||
|
||||
A multiline summary of the education.
|
||||
|
||||
|
||||
|
||||
## AFFILIATION
|
||||
|
||||
### *Member*, [IEEE](https://www.ieee.org/index.html) (2013-06 — Present)
|
||||
|
||||
Member in good standing since 2013-06.
|
||||
|
||||
### *Member*, [Apple Developer Network](https://developer.apple.com/) (??? — Present)
|
||||
|
||||
Member of the [Apple Developer program](https://developer.apple.com/) since 2008.
|
||||
|
||||
### *Subscriber*, [MSDN](https://msdn.microsoft.com) (2010-01 — Present)
|
||||
|
||||
Super-Ultra-gold level Ultimate Access MSDN subscriber package with subscription toaster and XBox ping pong racket.
|
||||
|
||||
### *Coordinator*, Campus Coder's Meetup (2003-02 — 2004-04)
|
||||
|
||||
Host of a monthly **campus-wide meetup for CS students**. Code, coffee, and crullers!
|
||||
|
||||
|
||||
## SAMPLES
|
||||
|
||||
### [Asteroids](http://janef.me/asteroids) (2014-09)
|
||||
|
||||
A browser-based space shooter built on Three.js.
|
||||
|
||||
### [Rememberpedia](https://rememberpedia.com) (2015-07)
|
||||
|
||||
A website to help you remember things.
|
||||
|
||||
|
||||
## WRITING
|
||||
|
||||
### [Building User Interfaces with Electron and Atom](http://codeproject.com/build-ui-electron-atom.aspx) (2011-01)
|
||||
|
||||
|
||||
|
||||
### [Jane Fullstacker's Blog](http://janef.me) (2011-01)
|
||||
|
||||
|
||||
|
||||
### [Teach Yourself GORFF in 21 Days](http://url.to.publication.com/blah) (2008-01)
|
||||
|
||||
A primer on the programming language of GORFF, whose for loops are coterminous with all of time and space.
|
||||
|
||||
|
||||
## READING
|
||||
|
||||
### [*r/programming*](https://www.reddit.com/r/programming/)
|
||||
Daily reader and longtime lurker.
|
||||
|
||||
### [*Hacker News / YCombinator*](https://news.ycombinator.com/)
|
||||
Daily reader and longtime lurker.
|
||||
|
||||
### [*Coding Horror*](http://www.codinghorror.com), Jeff Atwood
|
||||
Reader since 2007; member of the StackOverflow Beta.
|
||||
|
||||
### [*Code Complete*](http://www.cc2e.com/Default.aspx), Steve McConnell
|
||||
My 'desert-island' software construction manual.
|
||||
|
||||
|
||||
## SERVICE
|
||||
|
||||
### *Technical Consultant*, [Technology for Tots](http://technology-for-tots.org) (2003-11 — 2005-06)
|
||||
|
||||
Summary of this volunteer stint.
|
||||
- Accomplishment 1
|
||||
- Accomplishment 2
|
||||
- etc
|
||||
|
||||
### *NCO*, [US Army Reserves](http://www.usar.army.mil/) (1999-11 — 2003-06)
|
||||
|
||||
Summary of this military stint.
|
||||
- Accomplishment 1
|
||||
- Accomplishment 2
|
||||
- etc
|
||||
|
||||
|
||||
## RECOGNITION
|
||||
|
||||
### Honorable Mention, Google (Jan 2012)
|
||||
|
||||
### Summa cum laude, Cornell University (Jan 2012)
|
||||
|
||||
|
||||
## SPEAKING
|
||||
|
||||
### *Data Warehousing Evolved: DARMA 2.0*, OPENSTART 2013 Developer's Conference (2012)
|
||||
|
||||
|
||||
- Won 'Best Presentation on an Emerging Technical Field' prize.
|
||||
|
||||
|
||||
|
||||
## INTERESTS
|
||||
|
||||
- READING: mystery Agatha Christie John Grisham
|
||||
Jane is a fan of mystery novels and courtroom dramas including Agatha Christie and John Grisham.
|
||||
|
||||
- HIKING
|
||||
Jane enjoys hiking, light mountain climbing, and has four summits under her belt!
|
||||
|
||||
- YOGA
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user