hdoc-tools 0.34.0 → 0.34.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-create.js CHANGED
@@ -1,108 +1,108 @@
1
- (() => {
2
- const fs = require("fs-extra");
3
- const path = require("node:path");
4
- const hdoc = require(path.join(__dirname, "hdoc-module.js"));
5
-
6
- let doc_id;
7
- let file_count = 0;
8
- let folder_count = 0;
9
-
10
- const processed_links = {};
11
-
12
- exports.run = async (source_path) => {
13
- console.log("Hornbill HDocBook Create", "\n");
14
- console.log("Path:", source_path, "\n");
15
-
16
- // Load the hdocbook-project.json file to get the docId
17
- // use the docId to get the book config
18
- const hdocbook_project_config_path = path.join(
19
- source_path,
20
- "hdocbook-project.json",
21
- );
22
- let hdocbook_project = {};
23
- try {
24
- hdocbook_project = require(hdocbook_project_config_path);
25
- } catch (e) {
26
- console.error(`File not found: ${hdocbook_project_config_path}\n`);
27
- console.error(
28
- "hdoc create needs to be run in the root of a HDoc Book.\n",
29
- );
30
- process.exit(1);
31
- }
32
- doc_id = hdocbook_project.docId;
33
-
34
- const book_path = path.join(source_path, doc_id);
35
- const hdocbook_path = path.join(book_path, "hdocbook.json");
36
-
37
- let hdocbook = {};
38
- try {
39
- hdocbook = require(hdocbook_path);
40
- } catch (e) {
41
- console.error(`File not found: ${hdocbook_path}\n`);
42
- console.error(
43
- "hdoc create needs to be run in the root of a HDoc Book.\n",
44
- );
45
- process.exit(1);
46
- }
47
-
48
- // Get paths from breadcrumb builder
49
- const nav_paths = hdoc.build_breadcrumbs(hdocbook.navigation.items);
50
- for (const key in nav_paths) {
51
- if (Object.hasOwn(nav_paths, key)) {
52
- for (const navkey in nav_paths[key]) {
53
- if (Object.hasOwn(nav_paths[key], navkey)) {
54
- for (let i = 0; i < nav_paths[key][navkey].length; i++) {
55
- if (
56
- nav_paths[key][navkey][i].link &&
57
- !processed_links[nav_paths[key][navkey][i].link]
58
- ) {
59
- nav_paths[key][navkey][i].path = path.join(
60
- source_path,
61
- nav_paths[key][navkey][i].link,
62
- );
63
- await add_doc(nav_paths[key][navkey][i]);
64
- }
65
- }
66
- }
67
- }
68
- }
69
- }
70
- console.log("\n-----------------------");
71
- console.log(" Docs Creation Summary");
72
- console.log("-----------------------\n");
73
- console.log(` Files Created: ${file_count}`);
74
- console.log(`Folders Created: ${folder_count}\n`);
75
- };
76
-
77
- const add_doc = async (doc_info) => {
78
- // Does folder exist? Create if not
79
- const folder = path.dirname(doc_info.path);
80
- if (!fs.existsSync(folder)) {
81
- try {
82
- fs.mkdirSync(folder, true);
83
- console.log("Folder created:", folder);
84
- folder_count++;
85
- } catch {
86
- console.error("\nError creating folder", folder, ":", e);
87
- return;
88
- }
89
- }
90
-
91
- // Does file exist? Create if not
92
- if (
93
- !fs.existsSync(`${doc_info.path}.md`) &&
94
- !fs.existsSync(`${doc_info.path}.htm`) &&
95
- !fs.existsSync(`${doc_info.path}.html`)
96
- ) {
97
- try {
98
- const file_path = `${doc_info.path}.md`;
99
- fs.writeFileSync(file_path, `# ${doc_info.text}\n`);
100
- console.log(" File created:", file_path);
101
- processed_links[doc_info.link] = true;
102
- file_count++;
103
- } catch (e) {
104
- console.error("\nError creating file", doc_info.path, ":", e);
105
- }
106
- }
107
- };
108
- })();
1
+ (() => {
2
+ const fs = require("fs-extra");
3
+ const path = require("node:path");
4
+ const hdoc = require(path.join(__dirname, "hdoc-module.js"));
5
+
6
+ let doc_id;
7
+ let file_count = 0;
8
+ let folder_count = 0;
9
+
10
+ const processed_links = {};
11
+
12
+ exports.run = async (source_path) => {
13
+ console.log("Hornbill HDocBook Create", "\n");
14
+ console.log("Path:", source_path, "\n");
15
+
16
+ // Load the hdocbook-project.json file to get the docId
17
+ // use the docId to get the book config
18
+ const hdocbook_project_config_path = path.join(
19
+ source_path,
20
+ "hdocbook-project.json",
21
+ );
22
+ let hdocbook_project = {};
23
+ try {
24
+ hdocbook_project = require(hdocbook_project_config_path);
25
+ } catch (e) {
26
+ console.error(`File not found: ${hdocbook_project_config_path}\n`);
27
+ console.error(
28
+ "hdoc create needs to be run in the root of a HDoc Book.\n",
29
+ );
30
+ process.exit(1);
31
+ }
32
+ doc_id = hdocbook_project.docId;
33
+
34
+ const book_path = path.join(source_path, doc_id);
35
+ const hdocbook_path = path.join(book_path, "hdocbook.json");
36
+
37
+ let hdocbook = {};
38
+ try {
39
+ hdocbook = require(hdocbook_path);
40
+ } catch (e) {
41
+ console.error(`File not found: ${hdocbook_path}\n`);
42
+ console.error(
43
+ "hdoc create needs to be run in the root of a HDoc Book.\n",
44
+ );
45
+ process.exit(1);
46
+ }
47
+
48
+ // Get paths from breadcrumb builder
49
+ const nav_paths = hdoc.build_breadcrumbs(hdocbook.navigation.items);
50
+ for (const key in nav_paths) {
51
+ if (Object.hasOwn(nav_paths, key)) {
52
+ for (const navkey in nav_paths[key]) {
53
+ if (Object.hasOwn(nav_paths[key], navkey)) {
54
+ for (let i = 0; i < nav_paths[key][navkey].length; i++) {
55
+ if (
56
+ nav_paths[key][navkey][i].link &&
57
+ !processed_links[nav_paths[key][navkey][i].link]
58
+ ) {
59
+ nav_paths[key][navkey][i].path = path.join(
60
+ source_path,
61
+ nav_paths[key][navkey][i].link,
62
+ );
63
+ await add_doc(nav_paths[key][navkey][i]);
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ console.log("\n-----------------------");
71
+ console.log(" Docs Creation Summary");
72
+ console.log("-----------------------\n");
73
+ console.log(` Files Created: ${file_count}`);
74
+ console.log(`Folders Created: ${folder_count}\n`);
75
+ };
76
+
77
+ const add_doc = async (doc_info) => {
78
+ // Does folder exist? Create if not
79
+ const folder = path.dirname(doc_info.path);
80
+ if (!fs.existsSync(folder)) {
81
+ try {
82
+ fs.mkdirSync(folder, { recursive: true });
83
+ console.log("Folder created:", folder);
84
+ folder_count++;
85
+ } catch (e) {
86
+ console.error("\nError creating folder", folder, ":", e);
87
+ return;
88
+ }
89
+ }
90
+
91
+ // Does file exist? Create if not
92
+ if (
93
+ !fs.existsSync(`${doc_info.path}.md`) &&
94
+ !fs.existsSync(`${doc_info.path}.htm`) &&
95
+ !fs.existsSync(`${doc_info.path}.html`)
96
+ ) {
97
+ try {
98
+ const file_path = `${doc_info.path}.md`;
99
+ fs.writeFileSync(file_path, `# ${doc_info.text}\n`);
100
+ console.log(" File created:", file_path);
101
+ processed_links[doc_info.link] = true;
102
+ file_count++;
103
+ } catch (e) {
104
+ console.error("\nError creating file", doc_info.path, ":", e);
105
+ }
106
+ }
107
+ };
108
+ })();
package/hdoc-validate.js CHANGED
@@ -561,7 +561,7 @@ const e = require("express");
561
561
  await axios({
562
562
  url: links[i],
563
563
  method: 'get',
564
- timeout: 10000,
564
+ timeout: 30000,
565
565
  maxRedirects: 5,
566
566
  validateStatus: (status) =>
567
567
  status >= 200 && status < 400,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.34.0",
3
+ "version": "0.34.2",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {