hdoc-tools 0.19.8 → 0.20.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/hdoc-ver.js CHANGED
@@ -1,43 +1,43 @@
1
- (function () {
2
- 'use strict';
3
-
4
- const fs = require('fs'),
5
- path = require('path');
6
-
7
- exports.run = function (source_path) {
8
- console.log(`Retrieving book version...\n`);
9
-
10
- // Get document ID
11
- const hdocbook_project_config_path = path.join(source_path, 'hdocbook-project.json');
12
- let hdocbook_project;
13
- try {
14
- hdocbook_project = require(hdocbook_project_config_path);
15
- } catch (e) {
16
- console.error('File not found: hdocbook-project.json:');
17
- console.log(e, '\n');
18
- console.error('hdoc ver needs to be run in the root of a HDoc Book.\n');
19
- process.exit(1);
20
- }
21
- const doc_id = hdocbook_project.docId;
22
-
23
- const book_path = path.join(source_path, doc_id),
24
- hdocbook_path = path.join(book_path, 'hdocbook.json');
25
-
26
- let hdocbook_config;
27
- try {
28
- hdocbook_config = require(hdocbook_path);
29
- } catch (e) {
30
- console.error('File not found: hdocbook.json');
31
- console.log(e, '\n');
32
- console.error('hdoc ver needs to be run in the root of a HDoc Book.\n');
33
- process.exit(1);
34
- }
35
- if (hdocbook_config.version && hdocbook_config.version !== '') {
36
- console.log(`Book version: ${hdocbook_config.version}\n`);
37
- } else {
38
- console.error(`Error - this book has no version defined.\n`);
39
- process.exit(1);
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 function () {
3
- 'use strict';
4
-
5
- const preRun = require('./validateNodeVer.js'),
6
- fs = require('fs'),
7
- path = require('path'),
8
- { trueCasePathSync } = require('true-case-path');
9
-
10
- const packageFile = path.join(__dirname, 'package.json');
11
-
12
- const { info, error } = console;
13
- console.info = (arg) => {
14
- info.call(console, `\x1b[33m${arg}\x1b[0m`);
15
- };
16
- console.error = (arg) => {
17
- error.call(console, `\x1b[31m${arg}\x1b[0m`);
18
- };
19
-
20
-
21
- const getHdocPackageVersion = function (packagePath) {
22
- if (fs.existsSync(packagePath)) {
23
- try {
24
- return JSON.parse(fs.readFileSync(packagePath, 'utf8')).version;
25
- } catch (e) {
26
- console.error('Could not parse package file: ', packagePath, ' - ', JSON.stringify(e));
27
- process.exit(1);
28
- }
29
- } else {
30
- console.error('Package file not found: ', packagePath);
31
- }
32
- };
33
-
34
- // Default source path to working directory
35
- let source_path = process.cwd();
36
- let ui_path = path.join(__dirname, 'ui');
37
- let git_token = '',
38
- command = '', // Our command to run
39
- build_version = '',
40
- verbose = false,
41
- gen_exclude = false,
42
- bump_type = 'patch'; // To generate spellcheck exclusions for all files
43
-
44
- // Get options from command args
45
- for (let x = 0; x < process.argv.length; x++) {
46
- // First two arguments are command, and script
47
- if (x == 0 || x == 1)
48
- continue;
49
- // Third argument is command
50
- if (x == 2) {
51
- command = process.argv[x];
52
-
53
- if (command === 'bump') {
54
- x++;
55
- if (x < process.argv.length) {
56
- bump_type = process.argv[x];
57
- }
58
- }
59
- continue;
60
- }
61
-
62
- if (process.argv[x] === '-v') {
63
- verbose = true;
64
- } else if (process.argv[x] == '-path') {
65
- x++;
66
- if (x < process.argv.length) {
67
- source_path = process.argv[x];
68
- }
69
- } else if (process.argv[x] == '-ui-path') {
70
- x++;
71
- if (x < process.argv.length) {
72
- ui_path = process.argv[x];
73
- }
74
- } else if (process.argv[x] == '--git-token') {
75
- x++;
76
- if (x < process.argv.length) {
77
- git_token = process.argv[x];
78
- }
79
- } else if (process.argv[x] == '--set-version') {
80
- x++;
81
- if (x < process.argv.length) {
82
- build_version = process.argv[x];
83
- }
84
- } else if (process.argv[x] == '-e') {
85
- gen_exclude = true;
86
- }
87
- }
88
- source_path = trueCasePathSync(source_path);
89
-
90
- console.log('Hornbill HDocBook Tools v' + getHdocPackageVersion(packageFile), '\r\n');
91
- console.log(' Server Path:', __dirname);
92
- console.log(' Document Path:', source_path, '\r\n');
93
-
94
- if (command == 'serve') {
95
- const server = require(path.join(__dirname, 'hdoc-serve.js'));
96
- server.run(ui_path, source_path);
97
- } else if (command == 'build') {
98
- const builder = require(path.join(__dirname, 'hdoc-build.js'));
99
- await builder.run(source_path, verbose, git_token, false, gen_exclude, build_version);
100
- } else if (command == 'createDocs') {
101
- const creator = require(path.join(__dirname, 'hdoc-create.js'));
102
- await creator.run(source_path);
103
- } else if (command == 'validate') {
104
- const builder = require(path.join(__dirname, 'hdoc-build.js'));
105
- await builder.run(source_path, verbose, git_token, true, gen_exclude, build_version);
106
- } else if (command == 'stats') {
107
- const stats = require(path.join(__dirname, 'hdoc-stats.js'));
108
- stats.run(ui_path, source_path, verbose);
109
- } else if (command == 'init') {
110
- const init = require(path.join(__dirname, 'hdoc-init.js'));
111
- init.run(__dirname, source_path);
112
- } else if (command == 'help') {
113
- const help = require(path.join(__dirname, 'hdoc-help.js'));
114
- help.run();
115
- } else if (command == 'bump') {
116
- const bump = require(path.join(__dirname, 'hdoc-bump.js'));
117
- bump.run(source_path, bump_type);
118
- } else if (command == 'ver') {
119
- const ver = require(path.join(__dirname, 'hdoc-ver.js'));
120
- ver.run(source_path);
121
- } else {
122
- console.error('Unknown command:', command, '\r\n');
123
- console.log('Run hdoc help for information regarding this tool.\r\n');
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
- "name": "hdoc-tools",
3
- "version": "0.19.8",
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
- }
2
+ "name": "hdoc-tools",
3
+ "version": "0.20.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
- "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
+ {
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
- "docId": "hdoc-guide",
3
- "pdfGeneration": {
4
- "enable": true,
5
- "exclude_paths": []
6
- },
7
- "validation": {
8
- "exclude_links": []
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
- "name": "hdoc-guide",
3
- "version": "0.1.0",
4
- "description": "",
5
- "main": "hdocbook.js",
6
- "author": "",
7
- "license": "ISC",
8
- "devDependencies": {
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
  }