hdoc-tools 0.57.0 → 0.57.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/hdoc-bump.js CHANGED
@@ -1,123 +1,123 @@
1
- (() => {
2
- const fs = require("node:fs");
3
- const path = require("node:path");
4
-
5
- exports.run = (source_path, bump_type) => {
6
- if (
7
- bump_type !== "patch" &&
8
- bump_type !== "minor" &&
9
- bump_type !== "major"
10
- ) {
11
- console.error(`Unsupported bump type: ${bump_type}`);
12
- process.exit(1);
13
- }
14
- console.log(`Bumping ${bump_type} book version...\n`);
15
-
16
- // Get document ID
17
- const hdocbook_project_config_path = path.join(
18
- source_path,
19
- "hdocbook-project.json",
20
- );
21
- let hdocbook_project;
22
- try {
23
- hdocbook_project = require(hdocbook_project_config_path);
24
- } catch (e) {
25
- console.error("File not found: hdocbook-project.json:");
26
- console.error(e, "\n");
27
- console.error("hdoc bump needs to be run in the root of a HDoc Book.\n");
28
- process.exit(1);
29
- }
30
- const doc_id = hdocbook_project.docId;
31
-
32
- const book_path = path.join(source_path, doc_id);
33
- const hdocbook_path = path.join(book_path, "hdocbook.json");
34
-
35
- let hdocbook_config;
36
- try {
37
- hdocbook_config = require(hdocbook_path);
38
- } catch (e) {
39
- console.error("File not found: hdocbook.json");
40
- console.error(e, "\n");
41
- console.error("hdoc bump needs to be run in the root of a HDoc Book.\n");
42
- process.exit(1);
43
- }
44
- const initial_version = hdocbook_config.version;
45
- const hdocbook_version = hdocbook_config.version.split(".");
46
- if (hdocbook_version.length !== 3) {
47
- console.error(
48
- `Book version does not appear to be in a semantic versioning format: ${initial_version}`,
49
- );
50
- process.exit(1);
51
- }
52
-
53
- if (Number.isNaN(hdocbook_version[0])) {
54
- console.error(
55
- `Existing major version is not a number: ${hdocbook_version[0]}`,
56
- );
57
- process.exit(1);
58
- }
59
- if (Number.isNaN(hdocbook_version[1])) {
60
- console.error(
61
- `Existing minor version is not a number: ${hdocbook_version[1]}`,
62
- );
63
- process.exit(1);
64
- }
65
- if (Number.isNaN(hdocbook_version[2])) {
66
- console.error(
67
- `Existing patch version is not a number: ${hdocbook_version[2]}`,
68
- );
69
- process.exit(1);
70
- }
71
-
72
- switch (bump_type) {
73
- case "major":
74
- try {
75
- hdocbook_version[0] = Number.parseInt(hdocbook_version[0], 10) + 1;
76
- hdocbook_version[1] = 0;
77
- hdocbook_version[2] = 0;
78
- } catch (e) {
79
- console.error("Failed to update major version:");
80
- console.error(e);
81
- process.exit(1);
82
- }
83
- break;
84
- case "minor":
85
- try {
86
- hdocbook_version[0] = Number.parseInt(hdocbook_version[0], 10);
87
- hdocbook_version[1] = Number.parseInt(hdocbook_version[1], 10) + 1;
88
- hdocbook_version[2] = 0;
89
- } catch (e) {
90
- console.error("Failed to update minor version:");
91
- console.error(e);
92
- process.exit(1);
93
- }
94
- break;
95
- default:
96
- //case "patch" catered for with this default
97
- try {
98
- hdocbook_version[0] = Number.parseInt(hdocbook_version[0], 10);
99
- hdocbook_version[1] = Number.parseInt(hdocbook_version[1], 10);
100
- hdocbook_version[2] = Number.parseInt(hdocbook_version[2], 10) + 1;
101
- } catch (e) {
102
- console.error("Failed to update patch version:");
103
- console.error(e);
104
- process.exit(1);
105
- }
106
- break;
107
- }
108
-
109
- hdocbook_config.version = hdocbook_version.join(".");
110
-
111
- try {
112
- fs.writeFileSync(hdocbook_path, JSON.stringify(hdocbook_config, null, 2));
113
- } catch (e) {
114
- console.error("Error writing bumped version to book config:", e);
115
- process.exit(1);
116
- }
117
-
118
- console.log(
119
- `Book version updated from ${initial_version} to ${hdocbook_config.version}\n`,
120
- );
121
- return true;
122
- };
123
- })();
1
+ (() => {
2
+ const fs = require("node:fs");
3
+ const path = require("node:path");
4
+
5
+ exports.run = (source_path, bump_type) => {
6
+ if (
7
+ bump_type !== "patch" &&
8
+ bump_type !== "minor" &&
9
+ bump_type !== "major"
10
+ ) {
11
+ console.error(`Unsupported bump type: ${bump_type}`);
12
+ process.exit(1);
13
+ }
14
+ console.log(`Bumping ${bump_type} book version...\n`);
15
+
16
+ // Get document ID
17
+ const hdocbook_project_config_path = path.join(
18
+ source_path,
19
+ "hdocbook-project.json",
20
+ );
21
+ let hdocbook_project;
22
+ try {
23
+ hdocbook_project = require(hdocbook_project_config_path);
24
+ } catch (e) {
25
+ console.error("File not found: hdocbook-project.json:");
26
+ console.error(e, "\n");
27
+ console.error("hdoc bump needs to be run in the root of a HDoc Book.\n");
28
+ process.exit(1);
29
+ }
30
+ const doc_id = hdocbook_project.docId;
31
+
32
+ const book_path = path.join(source_path, doc_id);
33
+ const hdocbook_path = path.join(book_path, "hdocbook.json");
34
+
35
+ let hdocbook_config;
36
+ try {
37
+ hdocbook_config = require(hdocbook_path);
38
+ } catch (e) {
39
+ console.error("File not found: hdocbook.json");
40
+ console.error(e, "\n");
41
+ console.error("hdoc bump needs to be run in the root of a HDoc Book.\n");
42
+ process.exit(1);
43
+ }
44
+ const initial_version = hdocbook_config.version;
45
+ const hdocbook_version = hdocbook_config.version.split(".");
46
+ if (hdocbook_version.length !== 3) {
47
+ console.error(
48
+ `Book version does not appear to be in a semantic versioning format: ${initial_version}`,
49
+ );
50
+ process.exit(1);
51
+ }
52
+
53
+ if (Number.isNaN(hdocbook_version[0])) {
54
+ console.error(
55
+ `Existing major version is not a number: ${hdocbook_version[0]}`,
56
+ );
57
+ process.exit(1);
58
+ }
59
+ if (Number.isNaN(hdocbook_version[1])) {
60
+ console.error(
61
+ `Existing minor version is not a number: ${hdocbook_version[1]}`,
62
+ );
63
+ process.exit(1);
64
+ }
65
+ if (Number.isNaN(hdocbook_version[2])) {
66
+ console.error(
67
+ `Existing patch version is not a number: ${hdocbook_version[2]}`,
68
+ );
69
+ process.exit(1);
70
+ }
71
+
72
+ switch (bump_type) {
73
+ case "major":
74
+ try {
75
+ hdocbook_version[0] = Number.parseInt(hdocbook_version[0], 10) + 1;
76
+ hdocbook_version[1] = 0;
77
+ hdocbook_version[2] = 0;
78
+ } catch (e) {
79
+ console.error("Failed to update major version:");
80
+ console.error(e);
81
+ process.exit(1);
82
+ }
83
+ break;
84
+ case "minor":
85
+ try {
86
+ hdocbook_version[0] = Number.parseInt(hdocbook_version[0], 10);
87
+ hdocbook_version[1] = Number.parseInt(hdocbook_version[1], 10) + 1;
88
+ hdocbook_version[2] = 0;
89
+ } catch (e) {
90
+ console.error("Failed to update minor version:");
91
+ console.error(e);
92
+ process.exit(1);
93
+ }
94
+ break;
95
+ default:
96
+ //case "patch" catered for with this default
97
+ try {
98
+ hdocbook_version[0] = Number.parseInt(hdocbook_version[0], 10);
99
+ hdocbook_version[1] = Number.parseInt(hdocbook_version[1], 10);
100
+ hdocbook_version[2] = Number.parseInt(hdocbook_version[2], 10) + 1;
101
+ } catch (e) {
102
+ console.error("Failed to update patch version:");
103
+ console.error(e);
104
+ process.exit(1);
105
+ }
106
+ break;
107
+ }
108
+
109
+ hdocbook_config.version = hdocbook_version.join(".");
110
+
111
+ try {
112
+ fs.writeFileSync(hdocbook_path, JSON.stringify(hdocbook_config, null, 2));
113
+ } catch (e) {
114
+ console.error("Error writing bumped version to book config:", e);
115
+ process.exit(1);
116
+ }
117
+
118
+ console.log(
119
+ `Book version updated from ${initial_version} to ${hdocbook_config.version}\n`,
120
+ );
121
+ return true;
122
+ };
123
+ })();
package/hdoc-edit.js CHANGED
@@ -31,7 +31,7 @@
31
31
  const { TocModel } = require(path.join(__dirname, "hdoc-toc.js"));
32
32
  const { dialect_findings } = require(path.join(__dirname, "hdoc-spell.js"));
33
33
 
34
- let port = 3000;
34
+ let port = 3001;
35
35
 
36
36
  // editor_path is the directory containing the editor SPA. For the stub this
37
37
  // is editor/ (a hand-written placeholder index.html). Once the React app is
package/hdoc-help.js CHANGED
@@ -18,7 +18,8 @@ Commands
18
18
  Creates folder structure and markdown documents as defined in the HDocBook navigation item links
19
19
 
20
20
  - edit
21
- Starts the local structure/content editor on port 3000 (bound to 127.0.0.1), serving the editor UI alongside a live preview of the content. Supports a -port N to use a different port.
21
+ Starts the local structure/content editor on port 3001 (bound to 127.0.0.1), serving the editor UI alongside a live preview of the content. Supports a -port N to use a different port.
22
+ NOTE: This feature is experimental and not really for general use yet. GS
22
23
 
23
24
  - help
24
25
  Outputs available arguments and switches
@@ -28,10 +28,13 @@
28
28
  errors.push(`hdocbook.json: "${path}" must be an object`);
29
29
  return;
30
30
  }
31
- check_extra_keys(item, ['text', 'link', 'expand', 'draft', 'items'], path, 'hdocbook.json', errors);
31
+ check_extra_keys(item, ['text', 'link', 'expand', 'draft', 'items', 'id'], path, 'hdocbook.json', errors);
32
32
  if (!item.text || typeof item.text !== 'string') {
33
33
  errors.push(`hdocbook.json: "${path}.text" is required and must be a non-empty string`);
34
34
  }
35
+ if (item.id !== undefined && typeof item.id !== 'string') {
36
+ errors.push(`hdocbook.json: "${path}.id" must be a string`);
37
+ }
35
38
  if (item.link !== undefined && typeof item.link !== 'string') {
36
39
  errors.push(`hdocbook.json: "${path}.link" must be a string`);
37
40
  }
package/hdoc-ver.js CHANGED
@@ -1,43 +1,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
- })();
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
+ })();
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.53.0",
3
+ "version": "0.57.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "hdoc-tools",
9
- "version": "0.53.0",
9
+ "version": "0.57.2",
10
10
  "hasInstallScript": true,
11
11
  "license": "ISC",
12
12
  "dependencies": {
@@ -15,7 +15,7 @@
15
15
  "archiver": "8.0.0",
16
16
  "better-sqlite3": "12.11.1",
17
17
  "cheerio": "1.2.0",
18
- "compression": "^1.8.1",
18
+ "compression": "1.8.1",
19
19
  "express": "5.2.1",
20
20
  "markdown-it": "14.2.0",
21
21
  "markdown-it-container": "4.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.57.0",
3
+ "version": "0.57.2",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {
@@ -1,17 +1,17 @@
1
- (() => {
2
- const vers = process.versions;
3
- const supportedVersion = 20;
4
- if (vers?.node) {
5
- if (Number.parseInt(vers.node, 10) < supportedVersion) {
6
- console.log("\r\nHornbill HDocBook Tools\r\n");
7
- console.error(
8
- `\x1b[31mThis tool requires Node.js version >= ${supportedVersion}.x.\x1b[0m\r\n`,
9
- );
10
- process.exit(1);
11
- }
12
- } else {
13
- console.log(
14
- "\x1b[33mCould not read version of Node.js, continuing...\x1b[0m",
15
- );
16
- }
17
- })();
1
+ (() => {
2
+ const vers = process.versions;
3
+ const supportedVersion = 20;
4
+ if (vers?.node) {
5
+ if (Number.parseInt(vers.node, 10) < supportedVersion) {
6
+ console.log("\r\nHornbill HDocBook Tools\r\n");
7
+ console.error(
8
+ `\x1b[31mThis tool requires Node.js version >= ${supportedVersion}.x.\x1b[0m\r\n`,
9
+ );
10
+ process.exit(1);
11
+ }
12
+ } else {
13
+ console.log(
14
+ "\x1b[33mCould not read version of Node.js, continuing...\x1b[0m",
15
+ );
16
+ }
17
+ })();
package/LICENSE DELETED
@@ -1,21 +0,0 @@
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.