resume-cli 3.8.3 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/build/import-resume.js +80 -0
- package/build/import-resume.test.js +100 -0
- package/build/main.js +8 -0
- package/build/main.test.js +4 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ npm install -g resume-cli
|
|
|
23
23
|
| Command | Description |
|
|
24
24
|
|---|---|
|
|
25
25
|
| init | Initialize a `resume.json` file. |
|
|
26
|
+
| import path/to/cv.pdf | Make `resume.json` from a PDF, Word `.docx`, LinkedIn export `.zip` or `.txt`. |
|
|
26
27
|
| validate | Schema validation test your `resume.json`. |
|
|
27
28
|
| export path/to/file.html | Export to `.html`, `.pdf`, `.md` or `.txt`. |
|
|
28
29
|
| audit | Score your resume for ATS (Applicant Tracking System) friendliness. |
|
|
@@ -39,6 +40,10 @@ Creates a new `resume.json` file in your current working directory.
|
|
|
39
40
|
|
|
40
41
|
Complete the `resume.json` with your text editor. Be sure to follow the schema (available at https://jsonresume.org/schema/).
|
|
41
42
|
|
|
43
|
+
### `resume import <file>`
|
|
44
|
+
|
|
45
|
+
Makes `resume.json` from the resume you already have: a PDF, a Word `.docx`, a LinkedIn data export `.zip` or a `.txt` file. The file is read by jsonresume.org's importer (the same one as [jsonresume.org/start](https://jsonresume.org/start)); nothing is saved there and the file is not kept. It lists the fields it was less sure of, so you can check them. It won't replace an existing `resume.json` unless you pass `--force`; `--resume` writes elsewhere.
|
|
46
|
+
|
|
42
47
|
### `resume validate`
|
|
43
48
|
|
|
44
49
|
Validates your `resume.json` against our schema to ensure it complies with the standard.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/* global fetch, FormData, Blob -- built into Node 18+ */
|
|
12
|
+
|
|
13
|
+
const ENDPOINT = process.env.JSONRESUME_IMPORT_URL || 'https://jsonresume.org/api/import';
|
|
14
|
+
const TEXT = new Set(['.txt', '.md', '.text']);
|
|
15
|
+
const MESSAGES = {
|
|
16
|
+
UnsupportedImport: 'That file type is not supported. Use a PDF, a Word .docx, a LinkedIn data export .zip or a .txt file.',
|
|
17
|
+
ImportTooLarge: 'That file is over 5 MB.',
|
|
18
|
+
NothingToImport: 'No text was found in it. A scanned PDF is an image: save the text as a .txt file and import that.',
|
|
19
|
+
ImportFailed: 'The resume could not be read just now. Try again in a minute.',
|
|
20
|
+
TooManyAttempts: 'Too many imports from here in the last hour. Try later.'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `resume import <file>`: turns a PDF, Word document, LinkedIn export or
|
|
25
|
+
* text file into resume.json with jsonresume.org's importer (the same one
|
|
26
|
+
* as jsonresume.org/start). Nothing is saved there; the file is not kept.
|
|
27
|
+
*/
|
|
28
|
+
var _default = async ({
|
|
29
|
+
file,
|
|
30
|
+
resumePath,
|
|
31
|
+
force = false,
|
|
32
|
+
endpoint = ENDPOINT,
|
|
33
|
+
fetchImpl = fetch
|
|
34
|
+
}) => {
|
|
35
|
+
if (!_fs.default.existsSync(file)) {
|
|
36
|
+
console.error(`No file at ${file}.`);
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (_fs.default.existsSync(resumePath) && !force) {
|
|
41
|
+
console.error(`${resumePath} already exists. Pass --force to replace it, or --resume to write elsewhere.`);
|
|
42
|
+
process.exitCode = 1;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const bytes = _fs.default.readFileSync(file);
|
|
46
|
+
const init = TEXT.has(_path.default.extname(file).toLowerCase()) ? {
|
|
47
|
+
headers: {
|
|
48
|
+
'content-type': 'application/json'
|
|
49
|
+
},
|
|
50
|
+
body: JSON.stringify({
|
|
51
|
+
text: bytes.toString('utf8')
|
|
52
|
+
})
|
|
53
|
+
} : (() => {
|
|
54
|
+
const form = new FormData();
|
|
55
|
+
form.append('file', new Blob([bytes]), _path.default.basename(file));
|
|
56
|
+
return {
|
|
57
|
+
body: form
|
|
58
|
+
};
|
|
59
|
+
})();
|
|
60
|
+
console.log(_chalk.default.gray(`Reading ${_path.default.basename(file)}…`));
|
|
61
|
+
const response = await fetchImpl(endpoint, {
|
|
62
|
+
method: 'POST',
|
|
63
|
+
...init
|
|
64
|
+
});
|
|
65
|
+
const body = await response.json().catch(() => ({}));
|
|
66
|
+
if (!response.ok) {
|
|
67
|
+
console.error(_chalk.default.red(MESSAGES[body._tag] || `The import failed (${response.status}).`));
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
_fs.default.writeFileSync(resumePath, `${JSON.stringify(body.resume, null, 2)}\n`);
|
|
72
|
+
const unsure = Object.entries(body.confidence || {}).filter(([, level]) => level !== 'high');
|
|
73
|
+
console.log(_chalk.default.green(`Wrote ${resumePath}: ${body.fields} fields.`));
|
|
74
|
+
if (unsure.length > 0) {
|
|
75
|
+
console.log(_chalk.default.yellow('Check these, the import was less sure of them:'));
|
|
76
|
+
for (const [pointer, level] of unsure) console.log(` ${pointer} (${level === 'low' ? 'a guess' : 'probably right'})`);
|
|
77
|
+
}
|
|
78
|
+
for (const warning of body.warnings || []) console.log(_chalk.default.yellow(` Left out: ${warning}`));
|
|
79
|
+
};
|
|
80
|
+
exports.default = _default;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
4
|
+
var _os = _interopRequireDefault(require("os"));
|
|
5
|
+
var _path = _interopRequireDefault(require("path"));
|
|
6
|
+
var _importResume = _interopRequireDefault(require("./import-resume"));
|
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
/* global FormData -- built into Node 18+ */
|
|
9
|
+
|
|
10
|
+
const reply = (status, body) => async () => ({
|
|
11
|
+
ok: status < 400,
|
|
12
|
+
status,
|
|
13
|
+
json: async () => body
|
|
14
|
+
});
|
|
15
|
+
describe('resume import', () => {
|
|
16
|
+
let dir;
|
|
17
|
+
let log;
|
|
18
|
+
let error;
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
dir = _fs.default.mkdtempSync(_path.default.join(_os.default.tmpdir(), 'resume-cli-import-'));
|
|
21
|
+
log = jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
22
|
+
error = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
23
|
+
process.exitCode = undefined;
|
|
24
|
+
});
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
log.mockRestore();
|
|
27
|
+
error.mockRestore();
|
|
28
|
+
process.exitCode = undefined;
|
|
29
|
+
});
|
|
30
|
+
it('sends text files as text, writes resume.json and lists what to check', async () => {
|
|
31
|
+
const file = _path.default.join(dir, 'cv.txt');
|
|
32
|
+
_fs.default.writeFileSync(file, 'Ada Lovelace\nProgrammer');
|
|
33
|
+
const resumePath = _path.default.join(dir, 'resume.json');
|
|
34
|
+
const calls = [];
|
|
35
|
+
await (0, _importResume.default)({
|
|
36
|
+
file,
|
|
37
|
+
resumePath,
|
|
38
|
+
fetchImpl: async (url, init) => {
|
|
39
|
+
calls.push({
|
|
40
|
+
url,
|
|
41
|
+
init
|
|
42
|
+
});
|
|
43
|
+
return reply(200, {
|
|
44
|
+
resume: {
|
|
45
|
+
basics: {
|
|
46
|
+
name: 'Ada Lovelace'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
confidence: {
|
|
50
|
+
'/basics/name': 'high',
|
|
51
|
+
'/basics/label': 'low'
|
|
52
|
+
},
|
|
53
|
+
warnings: ['Left out work › 0 › endDate'],
|
|
54
|
+
fields: 2
|
|
55
|
+
})();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
expect(JSON.parse(calls[0].init.body)).toEqual({
|
|
59
|
+
text: 'Ada Lovelace\nProgrammer'
|
|
60
|
+
});
|
|
61
|
+
expect(JSON.parse(_fs.default.readFileSync(resumePath, 'utf8'))).toEqual({
|
|
62
|
+
basics: {
|
|
63
|
+
name: 'Ada Lovelace'
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
expect(log).toHaveBeenCalledWith(' /basics/label (a guess)');
|
|
67
|
+
expect(process.exitCode).toBeUndefined();
|
|
68
|
+
});
|
|
69
|
+
it('uploads other files as a form, and says why a refusal happened', async () => {
|
|
70
|
+
const file = _path.default.join(dir, 'scan.pdf');
|
|
71
|
+
_fs.default.writeFileSync(file, '%PDF-1.4');
|
|
72
|
+
let sent;
|
|
73
|
+
await (0, _importResume.default)({
|
|
74
|
+
file,
|
|
75
|
+
resumePath: _path.default.join(dir, 'resume.json'),
|
|
76
|
+
fetchImpl: async (url, init) => {
|
|
77
|
+
sent = init.body;
|
|
78
|
+
return reply(422, {
|
|
79
|
+
_tag: 'NothingToImport'
|
|
80
|
+
})();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
expect(sent).toBeInstanceOf(FormData);
|
|
84
|
+
expect(error).toHaveBeenCalledWith(expect.stringContaining('No text was found'));
|
|
85
|
+
expect(process.exitCode).toBe(1);
|
|
86
|
+
});
|
|
87
|
+
it('never overwrites resume.json without --force', async () => {
|
|
88
|
+
const file = _path.default.join(dir, 'cv.txt');
|
|
89
|
+
_fs.default.writeFileSync(file, 'x');
|
|
90
|
+
const resumePath = _path.default.join(dir, 'resume.json');
|
|
91
|
+
_fs.default.writeFileSync(resumePath, '{"keep":true}');
|
|
92
|
+
await (0, _importResume.default)({
|
|
93
|
+
file,
|
|
94
|
+
resumePath,
|
|
95
|
+
fetchImpl: reply(200, {})
|
|
96
|
+
});
|
|
97
|
+
expect(_fs.default.readFileSync(resumePath, 'utf8')).toBe('{"keep":true}');
|
|
98
|
+
expect(process.exitCode).toBe(1);
|
|
99
|
+
});
|
|
100
|
+
});
|
package/build/main.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
require("dotenv/config");
|
|
5
5
|
var _init = _interopRequireDefault(require("./init"));
|
|
6
|
+
var _importResume = _interopRequireDefault(require("./import-resume"));
|
|
6
7
|
var _loadResume = _interopRequireDefault(require("./load-resume"));
|
|
7
8
|
var _getSchema = _interopRequireDefault(require("./get-schema"));
|
|
8
9
|
var _validate = _interopRequireDefault(require("./validate"));
|
|
@@ -59,6 +60,13 @@ const normalizeTheme = (value, defaultValue) => {
|
|
|
59
60
|
resumePath: program.resume
|
|
60
61
|
});
|
|
61
62
|
});
|
|
63
|
+
program.command('import <file>').description('Make resume.json from a PDF, Word .docx, LinkedIn export .zip or .txt (read by jsonresume.org; nothing is saved there)').option('-f, --force', 'Replace resume.json if it exists').action(async (file, options) => {
|
|
64
|
+
await (0, _importResume.default)({
|
|
65
|
+
file,
|
|
66
|
+
resumePath: program.resume,
|
|
67
|
+
force: Boolean(options.force)
|
|
68
|
+
});
|
|
69
|
+
});
|
|
62
70
|
program.command('validate').description("Validate your resume's schema").action(async () => {
|
|
63
71
|
const resume = await (0, _loadResume.default)(program.resume);
|
|
64
72
|
if (resume === null) {
|
package/build/main.test.js
CHANGED
|
@@ -82,6 +82,10 @@ describe('cli configuration', () => {
|
|
|
82
82
|
|
|
83
83
|
Commands:
|
|
84
84
|
init Initialize a resume.json file
|
|
85
|
+
import [options] <file> Make resume.json from a PDF, Word
|
|
86
|
+
.docx, LinkedIn export .zip or .txt (read
|
|
87
|
+
by jsonresume.org; nothing is saved
|
|
88
|
+
there)
|
|
85
89
|
validate Validate your resume's schema
|
|
86
90
|
export [fileName] Export locally to .html, .pdf, .md
|
|
87
91
|
(markdown) or .txt (text). Supply a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resume-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "The JSON Resume command line interface",
|
|
5
5
|
"main": "build/main.js",
|
|
6
6
|
"engines": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"yaml-js": "^0.2.3",
|
|
44
44
|
"yesno": "^0.3.1",
|
|
45
45
|
"@jsonresume/ats-validator": "0.3.0",
|
|
46
|
-
"@jsonresume/schema": "1.7.
|
|
46
|
+
"@jsonresume/schema": "1.7.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@babel/cli": "^7.25.0",
|