hdoc-tools 0.19.8 → 0.21.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/custom_modules/tips.js +88 -86
- package/hdoc-build-db.js +260 -198
- package/hdoc-build-pdf.js +219 -173
- package/hdoc-build.js +1498 -1505
- package/hdoc-bump.js +123 -109
- package/hdoc-create.js +108 -95
- package/hdoc-db.js +97 -125
- package/hdoc-help.js +48 -51
- package/hdoc-init.js +181 -147
- package/hdoc-module.js +727 -722
- package/hdoc-serve.js +390 -361
- package/hdoc-stats.js +187 -184
- package/hdoc-validate.js +958 -717
- package/hdoc-ver.js +43 -43
- package/hdoc.js +142 -124
- package/package.json +60 -60
- package/templates/init/_hdocbook/hdocbook.json +23 -23
- package/templates/init/hdocbook-project.json +10 -10
- package/templates/init/package.json +8 -10
- package/ui/js/doc.hornbill.js +708 -659
- package/validateNodeVer.js +17 -14
package/hdoc-ver.js
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
(
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
})();
|
1
|
+
(() => {
|
2
|
+
const fs = require("node:fs");
|
3
|
+
const path = require("node:path");
|
4
|
+
|
5
|
+
exports.run = (source_path) => {
|
6
|
+
console.log("Retrieving book version...\n");
|
7
|
+
|
8
|
+
// Get document ID
|
9
|
+
const hdocbook_project_config_path = path.join(
|
10
|
+
source_path,
|
11
|
+
"hdocbook-project.json",
|
12
|
+
);
|
13
|
+
let hdocbook_project;
|
14
|
+
try {
|
15
|
+
hdocbook_project = require(hdocbook_project_config_path);
|
16
|
+
} catch (e) {
|
17
|
+
console.error("File not found: hdocbook-project.json:");
|
18
|
+
console.log(e, "\n");
|
19
|
+
console.error("hdoc ver needs to be run in the root of a HDoc Book.\n");
|
20
|
+
process.exit(1);
|
21
|
+
}
|
22
|
+
const doc_id = hdocbook_project.docId;
|
23
|
+
|
24
|
+
const book_path = path.join(source_path, doc_id);
|
25
|
+
const hdocbook_path = path.join(book_path, "hdocbook.json");
|
26
|
+
|
27
|
+
let hdocbook_config;
|
28
|
+
try {
|
29
|
+
hdocbook_config = require(hdocbook_path);
|
30
|
+
} catch (e) {
|
31
|
+
console.error("File not found: hdocbook.json");
|
32
|
+
console.log(e, "\n");
|
33
|
+
console.error("hdoc ver needs to be run in the root of a HDoc Book.\n");
|
34
|
+
process.exit(1);
|
35
|
+
}
|
36
|
+
if (hdocbook_config.version && hdocbook_config.version !== "") {
|
37
|
+
console.log(`Book version: ${hdocbook_config.version}\n`);
|
38
|
+
} else {
|
39
|
+
console.error("Error - this book has no version defined.\n");
|
40
|
+
process.exit(1);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
})();
|
package/hdoc.js
CHANGED
@@ -1,125 +1,143 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
(async
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
2
|
+
(async () => {
|
3
|
+
const preRun = require("./validateNodeVer.js");
|
4
|
+
const fs = require("node:fs");
|
5
|
+
const path = require("node:path");
|
6
|
+
const { trueCasePathSync } = require("true-case-path");
|
7
|
+
|
8
|
+
const packageFile = path.join(__dirname, "package.json");
|
9
|
+
|
10
|
+
const { info, error } = console;
|
11
|
+
console.info = (arg) => {
|
12
|
+
info.call(console, `\x1b[33m${arg}\x1b[0m`);
|
13
|
+
};
|
14
|
+
console.error = (arg) => {
|
15
|
+
error.call(console, `\x1b[31m${arg}\x1b[0m`);
|
16
|
+
};
|
17
|
+
|
18
|
+
const getHdocPackageVersion = (packagePath) => {
|
19
|
+
if (fs.existsSync(packagePath)) {
|
20
|
+
try {
|
21
|
+
return JSON.parse(fs.readFileSync(packagePath, "utf8")).version;
|
22
|
+
} catch (e) {
|
23
|
+
console.error(
|
24
|
+
"Could not parse package file: ",
|
25
|
+
packagePath,
|
26
|
+
" - ",
|
27
|
+
JSON.stringify(e),
|
28
|
+
);
|
29
|
+
process.exit(1);
|
30
|
+
}
|
31
|
+
} else {
|
32
|
+
console.error("Package file not found: ", packagePath);
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
36
|
+
// Default source path to working directory
|
37
|
+
let source_path = process.cwd();
|
38
|
+
let ui_path = path.join(__dirname, "ui");
|
39
|
+
let git_token = "";
|
40
|
+
let command = ""; // Our command to run
|
41
|
+
let build_version = "";
|
42
|
+
let verbose = false;
|
43
|
+
let gen_exclude = false;
|
44
|
+
let bump_type = "patch"; // To generate spellcheck exclusions for all files
|
45
|
+
|
46
|
+
// Get options from command args
|
47
|
+
for (let x = 0; x < process.argv.length; x++) {
|
48
|
+
// First two arguments are command, and script
|
49
|
+
if (x === 0 || x === 1) continue;
|
50
|
+
// Third argument is command
|
51
|
+
if (x === 2) {
|
52
|
+
command = process.argv[x];
|
53
|
+
|
54
|
+
if (command === "bump") {
|
55
|
+
x++;
|
56
|
+
if (x < process.argv.length) {
|
57
|
+
bump_type = process.argv[x];
|
58
|
+
}
|
59
|
+
}
|
60
|
+
continue;
|
61
|
+
}
|
62
|
+
|
63
|
+
if (process.argv[x] === "-v") {
|
64
|
+
verbose = true;
|
65
|
+
} else if (process.argv[x].toLowerCase() === "-path") {
|
66
|
+
x++;
|
67
|
+
if (x < process.argv.length) {
|
68
|
+
source_path = process.argv[x];
|
69
|
+
}
|
70
|
+
} else if (process.argv[x].toLowerCase() === "-ui-path") {
|
71
|
+
x++;
|
72
|
+
if (x < process.argv.length) {
|
73
|
+
ui_path = process.argv[x];
|
74
|
+
}
|
75
|
+
} else if (process.argv[x].toLowerCase() === "--git-token") {
|
76
|
+
x++;
|
77
|
+
if (x < process.argv.length) {
|
78
|
+
git_token = process.argv[x];
|
79
|
+
}
|
80
|
+
} else if (process.argv[x].toLowerCase() === "--set-version") {
|
81
|
+
x++;
|
82
|
+
if (x < process.argv.length) {
|
83
|
+
build_version = process.argv[x];
|
84
|
+
}
|
85
|
+
} else if (process.argv[x].toLowerCase() === "-e") {
|
86
|
+
gen_exclude = true;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
source_path = trueCasePathSync(source_path);
|
90
|
+
|
91
|
+
console.log(
|
92
|
+
`Hornbill HDocBook Tools v${getHdocPackageVersion(packageFile)}`,
|
93
|
+
"\r\n",
|
94
|
+
);
|
95
|
+
console.log(" Server Path:", __dirname);
|
96
|
+
console.log(" Document Path:", source_path, "\r\n");
|
97
|
+
|
98
|
+
if (command.toLowerCase() === "serve") {
|
99
|
+
const server = require(path.join(__dirname, "hdoc-serve.js"));
|
100
|
+
server.run(ui_path, source_path);
|
101
|
+
} else if (command.toLowerCase() === "build") {
|
102
|
+
const builder = require(path.join(__dirname, "hdoc-build.js"));
|
103
|
+
await builder.run(
|
104
|
+
source_path,
|
105
|
+
verbose,
|
106
|
+
git_token,
|
107
|
+
false,
|
108
|
+
gen_exclude,
|
109
|
+
build_version,
|
110
|
+
);
|
111
|
+
} else if (command.toLowerCase() === "createdocs") {
|
112
|
+
const creator = require(path.join(__dirname, "hdoc-create.js"));
|
113
|
+
await creator.run(source_path);
|
114
|
+
} else if (command.toLowerCase() === "validate") {
|
115
|
+
const builder = require(path.join(__dirname, "hdoc-build.js"));
|
116
|
+
await builder.run(
|
117
|
+
source_path,
|
118
|
+
verbose,
|
119
|
+
git_token,
|
120
|
+
true,
|
121
|
+
gen_exclude,
|
122
|
+
build_version,
|
123
|
+
);
|
124
|
+
} else if (command.toLowerCase() === "stats") {
|
125
|
+
const stats = require(path.join(__dirname, "hdoc-stats.js"));
|
126
|
+
stats.run(ui_path, source_path, verbose);
|
127
|
+
} else if (command.toLowerCase() === "init") {
|
128
|
+
const init = require(path.join(__dirname, "hdoc-init.js"));
|
129
|
+
init.run(__dirname, source_path);
|
130
|
+
} else if (command.toLowerCase() === "help") {
|
131
|
+
const help = require(path.join(__dirname, "hdoc-help.js"));
|
132
|
+
help.run();
|
133
|
+
} else if (command.toLowerCase() === "bump") {
|
134
|
+
const bump = require(path.join(__dirname, "hdoc-bump.js"));
|
135
|
+
bump.run(source_path, bump_type);
|
136
|
+
} else if (command.toLowerCase() === "ver") {
|
137
|
+
const ver = require(path.join(__dirname, "hdoc-ver.js"));
|
138
|
+
ver.run(source_path);
|
139
|
+
} else {
|
140
|
+
console.error("Unknown command:", command, "\r\n");
|
141
|
+
console.log("Run hdoc help for information regarding this tool.\r\n");
|
142
|
+
}
|
143
|
+
})();
|
package/package.json
CHANGED
@@ -1,62 +1,62 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
2
|
+
"name": "hdoc-tools",
|
3
|
+
"version": "0.21.0",
|
4
|
+
"description": "Hornbill HDocBook Development Support Tool",
|
5
|
+
"main": "hdoc.js",
|
6
|
+
"bin": {
|
7
|
+
"hdoc": "./hdoc.js"
|
8
|
+
},
|
9
|
+
"files": [
|
10
|
+
"hdoc.js",
|
11
|
+
"hdoc-db.js",
|
12
|
+
"hdoc-build.js",
|
13
|
+
"hdoc-build-db.js",
|
14
|
+
"hdoc-build-pdf.js",
|
15
|
+
"hdoc-bump.js",
|
16
|
+
"hdoc-create.js",
|
17
|
+
"hdoc-help.js",
|
18
|
+
"hdoc-init.js",
|
19
|
+
"hdoc-module.js",
|
20
|
+
"hdoc-serve.js",
|
21
|
+
"hdoc-stats.js",
|
22
|
+
"hdoc-validate.js",
|
23
|
+
"hdoc-ver.js",
|
24
|
+
"validateNodeVer.js",
|
25
|
+
"ui",
|
26
|
+
"custom_modules",
|
27
|
+
"templates",
|
28
|
+
"templates/init/.npmignore",
|
29
|
+
"templates/init/gitignore"
|
30
|
+
],
|
31
|
+
"scripts": {
|
32
|
+
"preinstall": "node validateNodeVer",
|
33
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
34
|
+
},
|
35
|
+
"author": "Hornbill Technologies Ltd",
|
36
|
+
"license": "ISC",
|
37
|
+
"dependencies": {
|
38
|
+
"american-british-english-translator": "^0.2.1",
|
39
|
+
"archiver": "7.0.1",
|
40
|
+
"axios": "^1.7.2",
|
41
|
+
"axios-retry": "^4.4.1",
|
42
|
+
"better-sqlite3": "^11.1.2",
|
43
|
+
"cheerio": "^1.0.0-rc.12",
|
44
|
+
"dree": "^5.0.7",
|
45
|
+
"express": "^4.19.2",
|
46
|
+
"fs-extra": "^11.2.0",
|
47
|
+
"html-entities": "^2.5.2",
|
48
|
+
"html-to-text": "^9.0.5",
|
49
|
+
"js-yaml": "^4.1.0",
|
50
|
+
"jsdom": "^24.1.0",
|
51
|
+
"markdown-it": "14.1.0",
|
52
|
+
"markdown-it-container": "^4.0.0",
|
53
|
+
"markdown-it-front-matter": "^0.2.4",
|
54
|
+
"mime-types": "^2.1.35",
|
55
|
+
"prompt": "^1.3.0",
|
56
|
+
"puppeteer": "^22.12.1",
|
57
|
+
"stream": "0.0.3",
|
58
|
+
"true-case-path": "^2.2.1",
|
59
|
+
"words-count": "^2.0.2",
|
60
|
+
"xml-formatter": "^3.6.2"
|
61
|
+
}
|
62
62
|
}
|
@@ -1,23 +1,23 @@
|
|
1
|
-
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}
|
1
|
+
{
|
2
|
+
"docId": "--docId--",
|
3
|
+
"title": "--title--",
|
4
|
+
"description": "--description--",
|
5
|
+
"publicSource": "--publicSource--",
|
6
|
+
"productFamily": "hdocs",
|
7
|
+
"version": "0.0.1",
|
8
|
+
"audience": [
|
9
|
+
"public"
|
10
|
+
],
|
11
|
+
"languages": [
|
12
|
+
"en"
|
13
|
+
],
|
14
|
+
"navigation": {
|
15
|
+
"items": [
|
16
|
+
{
|
17
|
+
"text": "Introduction",
|
18
|
+
"expand": true
|
19
|
+
}
|
20
|
+
]
|
21
|
+
},
|
22
|
+
"tags": []
|
23
|
+
}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
}
|
1
|
+
{
|
2
|
+
"docId": "hdoc-guide",
|
3
|
+
"pdfGeneration": {
|
4
|
+
"enable": true,
|
5
|
+
"exclude_paths": []
|
6
|
+
},
|
7
|
+
"validation": {
|
8
|
+
"exclude_links": []
|
9
|
+
}
|
10
|
+
}
|
@@ -1,12 +1,10 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
"dependencies": {
|
11
|
-
}
|
2
|
+
"name": "hdoc-guide",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "",
|
5
|
+
"main": "hdocbook.js",
|
6
|
+
"author": "",
|
7
|
+
"license": "ISC",
|
8
|
+
"devDependencies": {},
|
9
|
+
"dependencies": {}
|
12
10
|
}
|