resume-cli 3.1.0 → 3.1.2
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/build/builder.js +2 -2
- package/build/main.js +1 -1
- package/build/render-html.js +4 -2
- package/build/render-html.test.js +14 -5
- package/build/serve.js +6 -0
- package/package.json +2 -1
package/build/builder.js
CHANGED
|
@@ -4,7 +4,7 @@ const themeServer = process.env.THEME_SERVER || 'https://themes.jsonresume.org/t
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const request = require('superagent');
|
|
6
6
|
const chalk = require('chalk');
|
|
7
|
-
const renderHtml = require('./render-html');
|
|
7
|
+
const renderHtml = require('./render-html').default;
|
|
8
8
|
const denormalizeTheme = value => {
|
|
9
9
|
return value.match(/jsonresume-theme-(.*)/)[1];
|
|
10
10
|
};
|
|
@@ -28,7 +28,7 @@ module.exports = function resumeBuilder(theme, dir, resumeFilename, cb) {
|
|
|
28
28
|
if (err) {
|
|
29
29
|
console.log(chalk.yellow('Could not find:'), resumeFilename);
|
|
30
30
|
console.log(chalk.cyan('Using example resume.json from resume-schema instead...'));
|
|
31
|
-
resumeJson = require('resume-schema')
|
|
31
|
+
resumeJson = require('resume-schema/sample.resume.json');
|
|
32
32
|
} else {
|
|
33
33
|
try {
|
|
34
34
|
// todo: test resume schema
|
package/build/main.js
CHANGED
|
@@ -22,7 +22,7 @@ const normalizeTheme = (value, defaultValue) => {
|
|
|
22
22
|
return theme.match('jsonresume-theme-.*') ? theme : `jsonresume-theme-${theme}`;
|
|
23
23
|
};
|
|
24
24
|
(async () => {
|
|
25
|
-
program.name('resume').usage('[command] [options]').version(pkg.version).option('-F, --force', 'Used by `publish` and `export` - bypasses schema testing.').option('-t, --theme <theme name>', 'Specify theme used by `export` and `serve` or specify a path starting with . (use . for current directory or ../some/other/dir)', normalizeTheme, 'jsonresume-theme-
|
|
25
|
+
program.name('resume').usage('[command] [options]').version(pkg.version).option('-F, --force', 'Used by `publish` and `export` - bypasses schema testing.').option('-t, --theme <theme name>', 'Specify theme used by `export` and `serve` or specify a path starting with . (use . for current directory or ../some/other/dir)', normalizeTheme, 'jsonresume-theme-elegant').option('-f, --format <file type extension>', 'Used by `export`.').option('-r, --resume <resume filename>', "path to the resume in json format. Use '-' to read from stdin", 'resume.json').option('-p, --port <port>', 'Used by `serve` (default: 4000)', 4000).option('-s, --silent', 'Used by `serve` to tell it if open browser auto or not.', false).option('-d, --dir <path>', 'Used by `serve` to indicate a public directory path.', 'public').option('--schema <relativePath>', 'Used by `validate` to validate against a custom schema.');
|
|
26
26
|
program.command('init').description('Initialize a resume.json file').action(async () => {
|
|
27
27
|
await (0, _init.default)({
|
|
28
28
|
resumePath: program.resume
|
package/build/render-html.js
CHANGED
|
@@ -18,10 +18,12 @@ var _default = async ({
|
|
|
18
18
|
const cwd = process.cwd();
|
|
19
19
|
let path;
|
|
20
20
|
if (themePath[0] === '.') {
|
|
21
|
-
path = tryResolve(path.join(cwd, themePath), {
|
|
21
|
+
path = tryResolve(require('path').join(cwd, themePath), {
|
|
22
22
|
paths: [cwd]
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
if (!path) {
|
|
25
|
+
throw new Error(`Theme ${themePath} could not be resolved relative to ${cwd}`);
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
if (!path) {
|
|
27
29
|
path = tryResolve(themePath, {
|
|
@@ -7,9 +7,6 @@ describe('renderHTML', () => {
|
|
|
7
7
|
const originalRequireResolve = require.resolve;
|
|
8
8
|
const mockThemePath = 'mock/path/to/jsonresume-theme-even';
|
|
9
9
|
require.resolve = (...args) => {
|
|
10
|
-
if (args[0] === 'jsonresume-theme-even') {
|
|
11
|
-
return mockThemePath;
|
|
12
|
-
}
|
|
13
10
|
if (args[0] === 'jsonresume-theme-even') {
|
|
14
11
|
return mockThemePath;
|
|
15
12
|
}
|
|
@@ -26,13 +23,13 @@ describe('renderHTML', () => {
|
|
|
26
23
|
email: 'test4@test.com'
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
|
-
it('should reject when theme is not
|
|
26
|
+
it('should reject when theme is not available', async () => {
|
|
30
27
|
await expect((0, _renderHtml.default)({
|
|
31
28
|
resume,
|
|
32
29
|
themePath: 'unknown'
|
|
33
30
|
})).rejects.toBeTruthy();
|
|
34
31
|
});
|
|
35
|
-
describe('should render html when theme is
|
|
32
|
+
describe('should render html when theme is available', () => {
|
|
36
33
|
it('with long theme name', async () => {
|
|
37
34
|
expect(await (0, _renderHtml.default)({
|
|
38
35
|
resume,
|
|
@@ -45,5 +42,17 @@ describe('renderHTML', () => {
|
|
|
45
42
|
themePath: 'even'
|
|
46
43
|
})).toStartWith('<!doctype html>');
|
|
47
44
|
});
|
|
45
|
+
it('should reject theme with invalid path', async () => {
|
|
46
|
+
await expect((0, _renderHtml.default)({
|
|
47
|
+
resume,
|
|
48
|
+
themePath: './unknown'
|
|
49
|
+
})).rejects.toBeTruthy();
|
|
50
|
+
});
|
|
51
|
+
it('with local theme path', async () => {
|
|
52
|
+
expect(await (0, _renderHtml.default)({
|
|
53
|
+
resume,
|
|
54
|
+
themePath: './node_modules/jsonresume-theme-even'
|
|
55
|
+
})).toStartWith('<!doctype html>');
|
|
56
|
+
});
|
|
48
57
|
});
|
|
49
58
|
});
|
package/build/serve.js
CHANGED
|
@@ -6,6 +6,12 @@ const readline = require('readline');
|
|
|
6
6
|
const bs = require('browser-sync').create();
|
|
7
7
|
const builder = require('./builder');
|
|
8
8
|
const reBuildResume = (theme, dir, resumeFilename, cb) => {
|
|
9
|
+
console.log({
|
|
10
|
+
theme,
|
|
11
|
+
dir,
|
|
12
|
+
resumeFilename,
|
|
13
|
+
cb
|
|
14
|
+
});
|
|
9
15
|
builder(theme, dir, resumeFilename, (err, html) => {
|
|
10
16
|
if (err) {
|
|
11
17
|
readline.cursorTo(process.stdout, 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resume-cli",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "The JSON Resume command line interface",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"dotenv": "^8.2.0",
|
|
38
38
|
"file-exists": "^5.0.1",
|
|
39
39
|
"jest-extended": "^0.11.5",
|
|
40
|
+
"jsonresume-theme-elegant": "^1.16.1",
|
|
40
41
|
"jsonresume-theme-even": "^0.6.0",
|
|
41
42
|
"mime-types": "^2.1.27",
|
|
42
43
|
"object-path-immutable": "^4.1.1",
|