hdoc-tools 0.7.10 → 0.7.12
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/LICENSE +21 -0
- package/hdoc-build.js +21 -18
- package/hdoc.js +1 -1
- package/package.json +2 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Hornbill Docs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/hdoc-build.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
const fs = require('fs-extra'),
|
|
5
5
|
path = require('path'),
|
|
6
6
|
dree = require('dree'),
|
|
7
|
-
zipper = require('zip-local')
|
|
7
|
+
zipper = require('zip-local'),
|
|
8
|
+
validate = require(path.join(__dirname, 'hdoc-validate.js'));
|
|
8
9
|
|
|
9
10
|
let conversion_attempted = 0,
|
|
10
11
|
conversion_success = 0,
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
return false;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
// File
|
|
51
|
+
// File callbacks for scans
|
|
51
52
|
const fileCallback = function (element) {
|
|
52
53
|
md_files.push(element.path);
|
|
53
54
|
};
|
|
@@ -58,13 +59,13 @@
|
|
|
58
59
|
extensions: ['md'],
|
|
59
60
|
hash: false,
|
|
60
61
|
normalize: true,
|
|
61
|
-
size:
|
|
62
|
-
sizeInBytes:
|
|
62
|
+
size: false,
|
|
63
|
+
sizeInBytes: false,
|
|
63
64
|
stat: false,
|
|
64
65
|
symbolicLinks: false
|
|
65
66
|
};
|
|
66
67
|
|
|
67
|
-
exports.run = function (source_path, md) {
|
|
68
|
+
exports.run = function (source_path, md, verbose) {
|
|
68
69
|
// GERRY: The purpose of this function is to create a zip file containing the hdocbook content,
|
|
69
70
|
// * Create a _work folder
|
|
70
71
|
// * copy the hdocbook content to the work folder
|
|
@@ -80,14 +81,14 @@
|
|
|
80
81
|
|
|
81
82
|
// Load the hdocbook-project.json file to get the docId
|
|
82
83
|
// use the docId to get the book config
|
|
83
|
-
const
|
|
84
|
-
|
|
84
|
+
const hdocbook_project_config_path = path.join(source_path, 'hdocbook-project.json'),
|
|
85
|
+
hdocbook_project = require(hdocbook_project_config_path);
|
|
85
86
|
|
|
86
87
|
docId = hdocbook_project.docId;
|
|
87
88
|
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const book_path = path.join(source_path, docId),
|
|
90
|
+
hdocbook_path = path.join(book_path, 'hdocbook.json'),
|
|
91
|
+
hdocbook_config = require(hdocbook_path);
|
|
91
92
|
|
|
92
93
|
console.log(`Building: ${docId} v${hdocbook_config.version}...\r\n`);
|
|
93
94
|
|
|
@@ -104,11 +105,7 @@
|
|
|
104
105
|
|
|
105
106
|
// Copy files from book into _work-docId folder
|
|
106
107
|
try {
|
|
107
|
-
fs.copySync(path.join(source_path, docId), path.join(work_path));
|
|
108
|
-
//fs.copyFileSync(path.join(source_path, 'hdocbook-project.json'), path.join(work_path, 'hdocbook-project.json'));
|
|
109
|
-
//fs.copyFileSync(path.join(source_path, 'LICENSE'), path.join(work_path, 'LICENSE'));
|
|
110
|
-
//fs.copyFileSync(path.join(source_path, 'README.md'), path.join(work_path, 'README.md'));
|
|
111
|
-
//fs.copyFileSync(path.join(source_path, 'package.json'), path.join(work_path, 'package.json'));
|
|
108
|
+
fs.copySync(path.join(source_path, docId), path.join(work_path, docId));
|
|
112
109
|
} catch (e) {
|
|
113
110
|
console.error('Error copying from source_path:\r\n', e);
|
|
114
111
|
process.exit(1);
|
|
@@ -116,6 +113,7 @@
|
|
|
116
113
|
|
|
117
114
|
// Get a list of MD files in work_path
|
|
118
115
|
dree.scan(work_path, dreeOptions, fileCallback);
|
|
116
|
+
|
|
119
117
|
// Work through MD files and convert to HTML
|
|
120
118
|
md_files.forEach(function (md_file) {
|
|
121
119
|
transform_markdown_and_save_html(md_file, md);
|
|
@@ -124,11 +122,16 @@
|
|
|
124
122
|
console.log(`Successfully converted to HTML: ${conversion_success}`);
|
|
125
123
|
console.log(` Failed to convert: ${conversion_failed}`);
|
|
126
124
|
|
|
125
|
+
console.log(`\r\nValidating paths in generated HTML files`);
|
|
126
|
+
const validation_success = validate.run(work_path, verbose);
|
|
127
|
+
if (!validation_success) {
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
|
|
127
131
|
const zip_path = path.join(work_path, docId + '.zip');
|
|
128
|
-
zipper.sync.zip(work_path).compress().save(zip_path);
|
|
132
|
+
zipper.sync.zip(path.join(work_path, docId)).compress().save(zip_path);
|
|
129
133
|
|
|
130
|
-
console.log(`
|
|
134
|
+
console.log(`ZIP Creation Success: ${zip_path}\r\n`);
|
|
131
135
|
console.log('Build Complete\r\n');
|
|
132
|
-
|
|
133
136
|
};
|
|
134
137
|
})();
|
package/hdoc.js
CHANGED
|
@@ -94,7 +94,7 @@ const { createCipheriv } = require('crypto');
|
|
|
94
94
|
server.run(ui_path, source_path, md);
|
|
95
95
|
} else if (command == 'build') {
|
|
96
96
|
const builder = require(path.join(__dirname, 'hdoc-build.js'));
|
|
97
|
-
builder.run(source_path, md);
|
|
97
|
+
builder.run(source_path, md, verbose);
|
|
98
98
|
} else if (command == 'stats') {
|
|
99
99
|
const stats = require(path.join(__dirname, 'hdoc-stats.js'));
|
|
100
100
|
stats.run(ui_path, source_path, md, verbose);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hdoc-tools",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.12",
|
|
4
4
|
"description": "Hornbill HDocBook Development Support Tool",
|
|
5
5
|
"main": "hdoc.js",
|
|
6
6
|
"bin": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"body-parser": "^1.20.1",
|
|
29
|
+
"cheerio": "^1.0.0-rc.12",
|
|
29
30
|
"cookie-parser": "^1.4.6",
|
|
30
31
|
"dree": "^3.4.2",
|
|
31
32
|
"express": "^4.18.2",
|