5etools-utils 0.15.9 → 0.15.10
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/README.md +13 -13
- package/bin/clean-html.js +0 -0
- package/bin/test-edition-sources.js +0 -0
- package/bin/test-file-contents.js +0 -0
- package/bin/test-file-locations.js +0 -0
- package/bin/test-file-names.js +0 -0
- package/bin/test-file-props.js +0 -0
- package/bin/test-img-file-extensions.js +0 -0
- package/bin/test-img-file-sizes.js +0 -0
- package/bin/test-img-source-names-brew.js +0 -0
- package/bin/test-img-source-names-ua.js +0 -0
- package/bin/test-json-brew.js +0 -0
- package/bin/test-json-ua.js +0 -0
- package/lib/BrewCleanerHtml.js +2 -3
- package/lib/TestJson.js +2 -3
- package/lib/WorkerList.js +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# 5etools Utils
|
|
2
|
-
|
|
3
|
-
Available commands:
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
npx clean-html
|
|
7
|
-
npx test-file-names [--name-regex <regex>]
|
|
8
|
-
npx test-file-contents --img-repo-name <repo> --url-prefix-expected <prefix>
|
|
9
|
-
npx test-json-brew [file] [--dir <dir>]
|
|
10
|
-
npx test-json-ua [file] [--dir <dir>]
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
And more; see `bin/`.
|
|
1
|
+
# 5etools Utils
|
|
2
|
+
|
|
3
|
+
Available commands:
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npx clean-html
|
|
7
|
+
npx test-file-names [--name-regex <regex>]
|
|
8
|
+
npx test-file-contents --img-repo-name <repo> --url-prefix-expected <prefix>
|
|
9
|
+
npx test-json-brew [file] [--dir <dir>]
|
|
10
|
+
npx test-json-ua [file] [--dir <dir>]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And more; see `bin/`.
|
package/bin/clean-html.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/bin/test-file-names.js
CHANGED
|
File without changes
|
package/bin/test-file-props.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/bin/test-json-brew.js
CHANGED
|
File without changes
|
package/bin/test-json-ua.js
CHANGED
|
File without changes
|
package/lib/BrewCleanerHtml.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import {Worker} from "node:worker_threads";
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import os from "node:os";
|
|
4
3
|
import he from "he";
|
|
5
4
|
import sanitizeHtml from "sanitize-html";
|
|
6
5
|
import {getCleanJson} from "./UtilClean.js";
|
|
7
6
|
import {ObjectWalker} from "./ObjectWalker.js";
|
|
8
7
|
import * as Uf from "./UtilFs.js";
|
|
9
8
|
import Um from "./UtilMisc.js";
|
|
10
|
-
import {Deferred, WorkerList} from "./WorkerList.js";
|
|
9
|
+
import {Deferred, WorkerList, getCntWorkers} from "./WorkerList.js";
|
|
11
10
|
|
|
12
11
|
export class BrewCleanerHtml {
|
|
13
12
|
static _LOG_TAG = `HTML`;
|
|
@@ -107,7 +106,7 @@ export class BrewCleanerHtml {
|
|
|
107
106
|
static async pGetErrorsOnDirsWorkers ({isFailFast = false} = {}) {
|
|
108
107
|
Um.info(this._LOG_TAG, `Testing for HTML...`);
|
|
109
108
|
|
|
110
|
-
const cntWorkers =
|
|
109
|
+
const cntWorkers = getCntWorkers();
|
|
111
110
|
|
|
112
111
|
const messages = [];
|
|
113
112
|
|
package/lib/TestJson.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as os from "os";
|
|
2
1
|
import * as path from "path";
|
|
3
2
|
import * as url from "url";
|
|
4
3
|
import {Worker} from "worker_threads";
|
|
@@ -7,7 +6,7 @@ import * as jsonSourceMap from "json-source-map";
|
|
|
7
6
|
|
|
8
7
|
import * as Uf from "./UtilFs.js";
|
|
9
8
|
import Um from "./UtilMisc.js";
|
|
10
|
-
import {WorkerList, Deferred} from "./WorkerList.js";
|
|
9
|
+
import {WorkerList, Deferred, getCntWorkers} from "./WorkerList.js";
|
|
11
10
|
import {ObjectWalker} from "./ObjectWalker.js";
|
|
12
11
|
import {UrlUtil} from "./UrlUtil.js";
|
|
13
12
|
import {UtilAjv} from "./UtilAjv.js";
|
|
@@ -211,7 +210,7 @@ class JsonTester {
|
|
|
211
210
|
async pGetErrorsOnDirsWorkers ({isFailFast = false, fileList = null} = {}) {
|
|
212
211
|
Um.info(this._tagLog, `Validating JSON against schemas in dir: ${this._dirSchema}`);
|
|
213
212
|
|
|
214
|
-
const cntWorkers =
|
|
213
|
+
const cntWorkers = getCntWorkers();
|
|
215
214
|
|
|
216
215
|
const errors = [];
|
|
217
216
|
const errorsFull = [];
|
package/lib/WorkerList.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
|
|
3
|
+
export class Deferred {
|
|
2
4
|
constructor () {
|
|
3
5
|
this._resolve = null;
|
|
4
6
|
this._reject = null;
|
|
@@ -13,7 +15,7 @@ class Deferred {
|
|
|
13
15
|
get promise () { return this._promise; }
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
class WorkerList {
|
|
18
|
+
export class WorkerList {
|
|
17
19
|
/**
|
|
18
20
|
* @param {Array} workers
|
|
19
21
|
*/
|
|
@@ -44,4 +46,4 @@ class WorkerList {
|
|
|
44
46
|
get cntAvailableWorkers () { return this._workers.length; }
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
export
|
|
49
|
+
export const getCntWorkers = () => Math.max(1, os.cpus().length - 1);
|