@t8/docsgen 0.1.36 → 0.1.37
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/dist/bin.js +77 -44
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -24,57 +24,90 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// node_modules/args-json/dist/index.js
|
|
27
|
-
function
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
27
|
+
function toCamelCase(x) {
|
|
28
|
+
let s = x.replace(/^[-_.\s~+]|[-_.\s~+]$/g, "");
|
|
29
|
+
if (!/[-_.\s~+]/.test(s)) return s.slice(0, 1).toLowerCase() + s.slice(1);
|
|
30
|
+
return s.toLowerCase().replace(/[-_.\s~+](\S)/g, (_, match) => match.toUpperCase());
|
|
31
|
+
}
|
|
32
|
+
function toKey(x) {
|
|
33
|
+
if (x) {
|
|
34
|
+
if (x.startsWith("--") && x.length > 2) return toCamelCase(x.slice(2));
|
|
35
|
+
if (x.startsWith("-") && x.length === 2) return toCamelCase(x.slice(1));
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
function split(x) {
|
|
39
|
+
let words = [], word = "";
|
|
40
|
+
let hasOpenSingleQuote = false;
|
|
41
|
+
let hasOpenDoubleQuote = false;
|
|
42
|
+
for (let i = 0; i < x.length; i++) {
|
|
43
|
+
let c = x[i];
|
|
44
|
+
if (/^\s/.test(c) && !hasOpenSingleQuote && !hasOpenDoubleQuote) {
|
|
45
|
+
if (word) words.push(word);
|
|
46
|
+
word = "";
|
|
43
47
|
continue;
|
|
44
48
|
}
|
|
45
|
-
|
|
49
|
+
if (c === "'" && x[i - 1] !== "\\")
|
|
50
|
+
hasOpenSingleQuote = !hasOpenSingleQuote;
|
|
51
|
+
if (c === '"' && x[i - 1] !== "\\")
|
|
52
|
+
hasOpenDoubleQuote = !hasOpenDoubleQuote;
|
|
53
|
+
word += c;
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
if (word) words.push(word);
|
|
56
|
+
return words;
|
|
57
|
+
}
|
|
58
|
+
function getDefaultInput() {
|
|
59
|
+
return typeof process === "undefined" ? [] : process.argv;
|
|
60
|
+
}
|
|
61
|
+
function parseArgs(input, map) {
|
|
62
|
+
let normalizedInput;
|
|
63
|
+
let normalizedMap;
|
|
64
|
+
if (input === void 0) normalizedInput = getDefaultInput();
|
|
65
|
+
else if (typeof input === "string") normalizedInput = split(input);
|
|
66
|
+
else if (Array.isArray(input)) normalizedInput = input.map((x) => String(x));
|
|
67
|
+
else if (input !== null && typeof input === "object") {
|
|
68
|
+
normalizedInput = getDefaultInput();
|
|
69
|
+
normalizedMap = input;
|
|
70
|
+
} else normalizedInput = [];
|
|
71
|
+
normalizedInput = normalizedInput.flatMap((item) => {
|
|
72
|
+
let normalizedItem = item.trim();
|
|
73
|
+
let k = normalizedItem.indexOf("=");
|
|
74
|
+
if (k === -1) return normalizedItem;
|
|
75
|
+
return [normalizedItem.slice(0, k), normalizedItem.slice(k + 1)];
|
|
76
|
+
});
|
|
77
|
+
if (map) normalizedMap = map;
|
|
78
|
+
let key = "";
|
|
79
|
+
let parsedArgs = {};
|
|
80
|
+
for (let rawValue of normalizedInput) {
|
|
81
|
+
rawValue = rawValue.trim();
|
|
82
|
+
if (rawValue.startsWith('"') && rawValue.endsWith('"'))
|
|
83
|
+
rawValue = rawValue.slice(1, -1);
|
|
84
|
+
else if (rawValue.startsWith("'") && rawValue.endsWith("'"))
|
|
85
|
+
rawValue = rawValue.slice(1, -1);
|
|
86
|
+
let parsedKey = toKey(rawValue);
|
|
87
|
+
if (parsedKey !== void 0) {
|
|
88
|
+
let nextKey = normalizedMap?.[parsedKey] ?? parsedKey;
|
|
89
|
+
if (key && nextKey !== key && parsedArgs[key] === void 0)
|
|
90
|
+
parsedArgs[key] = true;
|
|
91
|
+
key = nextKey;
|
|
65
92
|
continue;
|
|
66
93
|
}
|
|
67
|
-
let
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
let parsedValue;
|
|
95
|
+
if (rawValue) {
|
|
96
|
+
try {
|
|
97
|
+
parsedValue = JSON.parse(rawValue);
|
|
98
|
+
} catch {
|
|
99
|
+
parsedValue = rawValue;
|
|
100
|
+
}
|
|
101
|
+
} else parsedValue = true;
|
|
102
|
+
let prevValue = parsedArgs[key];
|
|
103
|
+
let value;
|
|
104
|
+
if (prevValue === void 0) value = parsedValue;
|
|
105
|
+
else if (Array.isArray(prevValue)) value = [...prevValue, parsedValue];
|
|
106
|
+
else value = [prevValue, parsedValue];
|
|
107
|
+
parsedArgs[key] = value;
|
|
76
108
|
}
|
|
77
|
-
|
|
109
|
+
if (key && parsedArgs[key] === void 0) parsedArgs[key] = true;
|
|
110
|
+
return parsedArgs;
|
|
78
111
|
}
|
|
79
112
|
|
|
80
113
|
// src/bin/fetchText.ts
|
|
@@ -188,7 +221,7 @@ async function getConfig() {
|
|
|
188
221
|
root: "/",
|
|
189
222
|
contentDir: "x",
|
|
190
223
|
...localConfig,
|
|
191
|
-
...
|
|
224
|
+
...parseArgs(args)
|
|
192
225
|
};
|
|
193
226
|
if (config.entries)
|
|
194
227
|
config.entries = await Promise.all(config.entries.map(reviseConfig));
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t8/docsgen",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/bin.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"docsgen": "dist/bin.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "npx npm-run-all clean build-bin
|
|
10
|
+
"build": "npx npm-run-all clean build-bin build-css",
|
|
11
11
|
"build-bin": "npx esbuild ./src/bin/run.ts --bundle --outfile=dist/bin.js --platform=node --external:jsdom --external:markdown-it",
|
|
12
12
|
"build-css": "node -e \"require('node:fs').cpSync('src/css', 'dist/css', { force: true, recursive: true });\"",
|
|
13
13
|
"build-schema": "npx ts-json-schema-generator -p src/types/Config.ts -t Config -o schema.json --minify",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"typescript": "^5.9.3"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"args-json": "^1.2.
|
|
33
|
+
"args-json": "^1.2.5",
|
|
34
34
|
"jsdom": "^27.0.0",
|
|
35
35
|
"markdown-it": "^14.1.0"
|
|
36
36
|
}
|