@tobi-or-not/docpress 0.12.3 → 0.13.1
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 +1 -0
- package/dist/cli.js +378 -354
- package/dist/cli.js.map +1 -1
- package/dist/templates/theme/mermaid.css +9 -0
- package/package.json +23 -21
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Command as e, createCommand as t, createOption as n } from "commander";
|
|
2
2
|
import { appendFileSync as r, cpSync as i, existsSync as a, mkdirSync as o, readFileSync as s, readdirSync as c, renameSync as l, rmSync as u, statSync as d, writeFileSync as f } from "node:fs";
|
|
3
|
-
import { basename as p, dirname as m, join as h, parse as g, relative as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { z as
|
|
7
|
-
import { Octokit as
|
|
8
|
-
import { simpleGit as
|
|
9
|
-
import { build as
|
|
10
|
-
import { withMermaid as
|
|
11
|
-
import { readFile as
|
|
12
|
-
var
|
|
3
|
+
import { basename as p, dirname as m, join as h, parse as g, relative as _, resolve as v } from "node:path";
|
|
4
|
+
import y from "yaml";
|
|
5
|
+
import b from "picocolors";
|
|
6
|
+
import { z as x } from "zod";
|
|
7
|
+
import { Octokit as S } from "@octokit/rest";
|
|
8
|
+
import { simpleGit as C } from "simple-git";
|
|
9
|
+
import { build as w } from "vitepress";
|
|
10
|
+
import { withMermaid as ee } from "vitepress-plugin-mermaid";
|
|
11
|
+
import { readFile as te } from "node:fs/promises";
|
|
12
|
+
var ne = {
|
|
13
13
|
name: "@tobi-or-not/docpress",
|
|
14
14
|
type: "module",
|
|
15
|
-
version: "0.
|
|
16
|
-
packageManager: "bun@1.4.
|
|
15
|
+
version: "0.13.1",
|
|
16
|
+
packageManager: "bun@1.4.2",
|
|
17
17
|
homepage: "https://this-is-tobi.com/docpress/introduction",
|
|
18
18
|
repository: {
|
|
19
19
|
type: "git",
|
|
@@ -41,6 +41,7 @@ var ie = {
|
|
|
41
41
|
"stop:docker": "docker rm --force docpress",
|
|
42
42
|
test: "vitest run",
|
|
43
43
|
"test:cov": "vitest run --coverage",
|
|
44
|
+
typecheck: "tsc -p tsconfig.spec.json",
|
|
44
45
|
"vp:build": "vitepress build ./docpress",
|
|
45
46
|
"vp:build:docker": "docker build --tag tobi-or-not/docs --target prod .",
|
|
46
47
|
"vp:dev": "vitepress dev ./docpress --port 8080",
|
|
@@ -50,29 +51,29 @@ var ie = {
|
|
|
50
51
|
dependencies: {
|
|
51
52
|
"@octokit/rest": "^22.0.1",
|
|
52
53
|
commander: "^15.0.0",
|
|
53
|
-
mermaid: "^
|
|
54
|
+
mermaid: "^12.0.0",
|
|
54
55
|
picocolors: "^1.1.1",
|
|
55
|
-
"simple-git": "^
|
|
56
|
+
"simple-git": "^4.0.2",
|
|
56
57
|
vitepress: "^1.6.4",
|
|
57
58
|
"vitepress-plugin-mermaid": "^2.0.17",
|
|
58
|
-
yaml: "^2.9.
|
|
59
|
-
zod: "^4.5
|
|
59
|
+
yaml: "^2.9.1",
|
|
60
|
+
zod: "^4.6.5"
|
|
60
61
|
},
|
|
61
62
|
devDependencies: {
|
|
62
63
|
"@antfu/eslint-config": "^9.5.1",
|
|
63
|
-
"@commitlint/cli": "^21.2.
|
|
64
|
-
"@commitlint/config-conventional": "^21.2.
|
|
64
|
+
"@commitlint/cli": "^21.2.3",
|
|
65
|
+
"@commitlint/config-conventional": "^21.2.3",
|
|
65
66
|
"@octokit/types": "^18.0.0",
|
|
66
|
-
"@types/node": "^26.
|
|
67
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
68
|
-
"@vitest/coverage-v8": "^
|
|
69
|
-
eslint: "^10.
|
|
67
|
+
"@types/node": "^26.6.3",
|
|
68
|
+
"@vitejs/plugin-vue": "^6.0.9",
|
|
69
|
+
"@vitest/coverage-v8": "^5.0.2",
|
|
70
|
+
eslint: "^10.11.0",
|
|
70
71
|
husky: "^9.1.7",
|
|
71
72
|
"nano-staged": "^1.0.2",
|
|
72
73
|
typescript: "^6.0.3",
|
|
73
|
-
vite: "^8.
|
|
74
|
-
vitest: "^
|
|
75
|
-
vue: "^3.5.
|
|
74
|
+
vite: "^8.3.1",
|
|
75
|
+
vitest: "^5.0.2",
|
|
76
|
+
vue: "^3.5.43"
|
|
76
77
|
},
|
|
77
78
|
publishConfig: {
|
|
78
79
|
registry: "https://registry.npmjs.org/",
|
|
@@ -80,25 +81,26 @@ var ie = {
|
|
|
80
81
|
tag: "latest"
|
|
81
82
|
},
|
|
82
83
|
overrides: {
|
|
83
|
-
"brace-expansion": "^5.0.
|
|
84
|
-
dompurify: "^3.4.
|
|
85
|
-
"fast-uri": "^3.1.
|
|
86
|
-
"js-yaml": "^4.3.
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
"brace-expansion": "^5.0.12",
|
|
85
|
+
dompurify: "^3.4.16",
|
|
86
|
+
"fast-uri": "^3.1.8",
|
|
87
|
+
"js-yaml": "^4.3.2",
|
|
88
|
+
"lodash-es": "^4.18.1",
|
|
89
|
+
nanoid: "^3.3.19",
|
|
90
|
+
postcss: "^8.5.28"
|
|
89
91
|
}
|
|
90
|
-
},
|
|
91
|
-
red:
|
|
92
|
-
yellow:
|
|
93
|
-
white:
|
|
94
|
-
green:
|
|
95
|
-
blue:
|
|
92
|
+
}, T = v(process.cwd(), "docpress"), re = v(process.cwd(), "docpress/docs"), E = v(process.cwd(), "docpress/docs/index.md"), ie = v(process.cwd(), "docpress/docs/forks.md"), D = v(process.cwd(), "docpress/.vitepress/config.ts"), ae = v(process.cwd(), "docpress/.vitepress/theme"), oe = v(process.cwd(), "docpress/.vitepress/theme/extras"), O = process.env.NODE_ENV === "development" ? v(import.meta.dirname, "../../public/templates/theme") : v(import.meta.dirname, "./templates/theme"), se = {
|
|
93
|
+
red: b.red,
|
|
94
|
+
yellow: b.yellow,
|
|
95
|
+
white: b.white,
|
|
96
|
+
green: b.green,
|
|
97
|
+
blue: b.blue
|
|
96
98
|
};
|
|
97
|
-
function
|
|
99
|
+
function ce() {
|
|
98
100
|
let e = Number(process.env.LOG_LEVEL);
|
|
99
101
|
return Number.isNaN(e) ? 30 : e;
|
|
100
102
|
}
|
|
101
|
-
var
|
|
103
|
+
var k = {
|
|
102
104
|
error: {
|
|
103
105
|
color: "red",
|
|
104
106
|
level: 10
|
|
@@ -123,61 +125,65 @@ var D = {
|
|
|
123
125
|
color: "blue",
|
|
124
126
|
level: 50
|
|
125
127
|
}
|
|
126
|
-
},
|
|
128
|
+
}, A = [
|
|
127
129
|
"error",
|
|
128
130
|
"warn",
|
|
129
131
|
"info",
|
|
130
132
|
"trace",
|
|
131
133
|
"debug"
|
|
132
134
|
];
|
|
133
|
-
function
|
|
134
|
-
return
|
|
135
|
+
function le(e) {
|
|
136
|
+
return k[e].level;
|
|
135
137
|
}
|
|
136
|
-
function
|
|
137
|
-
let r = n ?
|
|
138
|
-
|
|
138
|
+
function j(e, t = "info", n) {
|
|
139
|
+
let r = n ? se[n](e) : se[k[t].color](e), i = t === "success" ? "info" : t;
|
|
140
|
+
ce() >= k[t].level && console[i](r);
|
|
139
141
|
}
|
|
140
142
|
//#endregion
|
|
141
143
|
//#region src/utils/regex.ts
|
|
142
|
-
var
|
|
144
|
+
var ue = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, de = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, fe = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, pe = /^\d{2}-/, me = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/, he = /\[([^\]]+)\]\((?!https?:|\/|#|mailto:)([^)#]*\/)?([^)#/]+\.md)(#[^)]*)?\)/g;
|
|
143
145
|
//#endregion
|
|
144
146
|
//#region src/utils/functions.ts
|
|
145
|
-
async function
|
|
147
|
+
async function M(e) {
|
|
146
148
|
try {
|
|
147
149
|
return (await fetch(e, {
|
|
148
150
|
method: "HEAD",
|
|
149
151
|
redirect: "manual"
|
|
150
152
|
})).status;
|
|
151
153
|
} catch (t) {
|
|
152
|
-
return
|
|
154
|
+
return j(` Network error while checking '${e}': ${P(t)}`, "debug"), 500;
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
|
-
function
|
|
157
|
+
function N(e) {
|
|
156
158
|
return (e.split(/[/\\]/).pop() ?? "").replace(/[^\w.-]/g, "_").replace(/^\.+/, "") || "_";
|
|
157
159
|
}
|
|
158
|
-
function
|
|
159
|
-
return !
|
|
160
|
+
function ge(e) {
|
|
161
|
+
return !H(e) || !("token" in e) ? e : {
|
|
160
162
|
...e,
|
|
161
163
|
token: e.token ? "***" : e.token
|
|
162
164
|
};
|
|
163
165
|
}
|
|
164
|
-
function
|
|
166
|
+
function P(e) {
|
|
165
167
|
return e instanceof Error ? e.message : String(e);
|
|
166
168
|
}
|
|
167
|
-
function
|
|
169
|
+
function F(e) {
|
|
168
170
|
if (e < 1e3) return `${Math.round(e)}ms`;
|
|
169
171
|
let t = e / 1e3;
|
|
170
172
|
if (t < 60) return `${t.toFixed(1)}s`;
|
|
171
173
|
let n = Math.floor(t / 60), r = Math.round(t % 60);
|
|
172
174
|
return `${n}m ${String(r).padStart(2, "0")}s`;
|
|
173
175
|
}
|
|
174
|
-
function
|
|
176
|
+
function _e(e, t) {
|
|
177
|
+
let n = new Map(t.map((e) => [e.toLowerCase(), e]));
|
|
178
|
+
return e.split(" ").map((e) => n.get(e.toLowerCase()) ?? e).join(" ");
|
|
179
|
+
}
|
|
180
|
+
function I(e, t) {
|
|
175
181
|
let n = "";
|
|
176
|
-
return t?.removeDot && (n = e.startsWith(".") ? e.slice(1) : e, n = n.replaceAll(".", "-")), t?.removeIdx && (n = (n || e).replace(
|
|
182
|
+
return t?.removeDot && (n = e.startsWith(".") ? e.slice(1) : e, n = n.replaceAll(".", "-")), t?.removeIdx && (n = (n || e).replace(pe, "")), t?.removeExt && (n = (n || e).split(".")[0]), t?.replaceDash && (n = (n || e).replaceAll("-", " ")), t?.mode === "capitalize" ? n = (n || e).slice(0, 1).toUpperCase() + (n || e).slice(1).toLowerCase() : t?.mode === "lowercase" ? n = (n || e).toLowerCase() : t?.mode === "uppercase" && (n = (n || e).toUpperCase()), t?.acronyms?.length && (n = _e(n || e, t.acronyms)), n || e;
|
|
177
183
|
}
|
|
178
|
-
function
|
|
184
|
+
function L(e, { clean: t } = { clean: !1 }) {
|
|
179
185
|
try {
|
|
180
|
-
if (t && a(e)) for (let t of c(e)) u(
|
|
186
|
+
if (t && a(e)) for (let t of c(e)) u(v(e, t), {
|
|
181
187
|
recursive: !0,
|
|
182
188
|
force: !0
|
|
183
189
|
});
|
|
@@ -200,39 +206,39 @@ function ye(e) {
|
|
|
200
206
|
return !1;
|
|
201
207
|
}
|
|
202
208
|
}
|
|
203
|
-
function L(e) {
|
|
204
|
-
return (Array.isArray(e) ? e : [e]).flatMap((e) => ye(e) ? [e] : ve(e) ? c(e).filter((e) => e !== ".git").sort().flatMap((t) => L(h(e, t))) : []);
|
|
205
|
-
}
|
|
206
209
|
function R(e) {
|
|
207
|
-
return
|
|
210
|
+
return (Array.isArray(e) ? e : [e]).flatMap((e) => ye(e) ? [e] : ve(e) ? c(e).filter((e) => e !== ".git").sort().flatMap((t) => R(h(e, t))) : []);
|
|
208
211
|
}
|
|
209
212
|
function z(e) {
|
|
213
|
+
return R(e).filter((e) => p(e).endsWith(".md"));
|
|
214
|
+
}
|
|
215
|
+
function B(e) {
|
|
210
216
|
return e.reduce((e, t, n, r) => n ? n === r.length - 1 ? `${e} or "${t}"` : `${e}, "${t}"` : `"${t}"`, "");
|
|
211
217
|
}
|
|
212
218
|
function be(e) {
|
|
213
|
-
return JSON.parse(s(`${
|
|
219
|
+
return JSON.parse(s(`${T}/user-${N(e)}.json`).toString());
|
|
214
220
|
}
|
|
215
221
|
function xe(e) {
|
|
216
|
-
return JSON.parse(s(`${
|
|
222
|
+
return JSON.parse(s(`${T}/repos-${N(e)}.json`).toString());
|
|
217
223
|
}
|
|
218
224
|
var Se = /* @__PURE__ */ new Set([
|
|
219
225
|
"__proto__",
|
|
220
226
|
"constructor",
|
|
221
227
|
"prototype"
|
|
222
228
|
]);
|
|
223
|
-
function
|
|
229
|
+
function V(...e) {
|
|
224
230
|
return e.reduce((e, t) => (t === null || Object.keys(t).forEach((n) => {
|
|
225
231
|
if (Se.has(n)) return;
|
|
226
232
|
let r = e ? e[n] : null, i = t[n];
|
|
227
|
-
e[n] =
|
|
233
|
+
e[n] = H(r) && H(i) ? V(r, i) : H(i) ? V({}, i) : i;
|
|
228
234
|
}), e), {});
|
|
229
235
|
}
|
|
230
|
-
function
|
|
236
|
+
function H(e) {
|
|
231
237
|
return e && typeof e == "object" && !Array.isArray(e);
|
|
232
238
|
}
|
|
233
239
|
function Ce(e) {
|
|
234
240
|
if (!e) return {};
|
|
235
|
-
let t =
|
|
241
|
+
let t = v(process.cwd(), e), n;
|
|
236
242
|
try {
|
|
237
243
|
n = s(t, "utf8");
|
|
238
244
|
} catch {
|
|
@@ -244,26 +250,26 @@ function Ce(e) {
|
|
|
244
250
|
throw Error(`Invalid JSON in config file '${e}'.`);
|
|
245
251
|
}
|
|
246
252
|
}
|
|
247
|
-
function
|
|
253
|
+
function U(e) {
|
|
248
254
|
return e.split(",");
|
|
249
255
|
}
|
|
250
256
|
function we(e, t) {
|
|
251
|
-
let n = s(e, "utf8").replace(
|
|
257
|
+
let n = s(e, "utf8").replace(ue, (e, n, r) => `[${n}](${t}/${r})`);
|
|
252
258
|
f(e, n, "utf8");
|
|
253
259
|
}
|
|
254
260
|
function Te(e, t) {
|
|
255
|
-
let n = s(e, "utf8"), r = n.match(
|
|
261
|
+
let n = s(e, "utf8"), r = n.match(me);
|
|
256
262
|
if (r) {
|
|
257
|
-
let i =
|
|
258
|
-
i.lastUpdated = t, f(e, n.replace(
|
|
263
|
+
let i = y.parse(r[1]) ?? {};
|
|
264
|
+
i.lastUpdated = t, f(e, n.replace(me, `---\n${y.stringify(i)}---\n`), "utf8");
|
|
259
265
|
} else f(e, `---\nlastUpdated: ${t}\n---\n\n${n}`, "utf8");
|
|
260
266
|
}
|
|
261
267
|
function Ee(e) {
|
|
262
|
-
return e ? e.split("/").map((e) => e === "" || e === "." || e === ".." ? e :
|
|
268
|
+
return e ? e.split("/").map((e) => e === "" || e === "." || e === ".." ? e : I(e, { removeIdx: !0 })).join("/") : "";
|
|
263
269
|
}
|
|
264
270
|
function De(e) {
|
|
265
|
-
let t = s(e, "utf8").replace(
|
|
266
|
-
let a =
|
|
271
|
+
let t = s(e, "utf8").replace(he, (e, t, n, r, i) => {
|
|
272
|
+
let a = I(r, {
|
|
267
273
|
mode: "lowercase",
|
|
268
274
|
removeIdx: !0
|
|
269
275
|
});
|
|
@@ -272,49 +278,51 @@ function De(e) {
|
|
|
272
278
|
f(e, t, "utf8");
|
|
273
279
|
}
|
|
274
280
|
function Oe(e, t) {
|
|
275
|
-
let n = s(e, "utf8").replace(
|
|
281
|
+
let n = s(e, "utf8").replace(de, (e, n, r, i) => `[${n}](${t}/${i})`).replace(fe, (e, t, n, r) => `[${t}](${r})`);
|
|
276
282
|
f(e, n, "utf8");
|
|
277
283
|
}
|
|
278
284
|
//#endregion
|
|
279
285
|
//#region src/schemas/global.ts
|
|
280
|
-
var
|
|
286
|
+
var W = ["github", "gitlab"], G = ["single", "multi"], ke = [
|
|
281
287
|
"true",
|
|
282
288
|
"false",
|
|
283
289
|
"null"
|
|
284
|
-
],
|
|
285
|
-
usernames:
|
|
286
|
-
logLevel:
|
|
287
|
-
branch:
|
|
288
|
-
gitProvider:
|
|
289
|
-
reposFilter:
|
|
290
|
-
extraHeaderPages:
|
|
291
|
-
extraPublicContent:
|
|
292
|
-
extraTheme:
|
|
293
|
-
forks:
|
|
294
|
-
lastUpdated:
|
|
295
|
-
sidebarMode:
|
|
296
|
-
sidebarCollapsed:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
290
|
+
], Ae = /^\w[\w./-]*$/, je = "Branch name must start with a letter, digit or underscore and only contain letters, digits, \".\", \"-\", \"_\" or \"/\".", K = x.object({
|
|
291
|
+
usernames: x.string().array().describe("List of comma separated Git provider usernames used to collect data."),
|
|
292
|
+
logLevel: x.enum(A).optional().describe(`Verbosity of the CLI output. Values should be ${B(A)}. Defaults to "info", or to the LOG_LEVEL environment variable when set.`),
|
|
293
|
+
branch: x.string().regex(Ae, je).optional().describe("Branch used to collect Git provider data. Defaults to each repository's own default branch when not set."),
|
|
294
|
+
gitProvider: x.enum(W).default("github").describe(`Git provider used to retrieve data. Values should be ${B(W)}.`),
|
|
295
|
+
reposFilter: x.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
|
|
296
|
+
extraHeaderPages: x.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
297
|
+
extraPublicContent: x.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
|
|
298
|
+
extraTheme: x.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
|
|
299
|
+
forks: x.boolean().default(!1).describe("Whether or not to create the dedicated fork page that aggregate external contributions."),
|
|
300
|
+
lastUpdated: x.boolean().default(!1).describe("Whether or not to inject each page's last Git commit date as Vitepress \"lastUpdated\" frontmatter."),
|
|
301
|
+
sidebarMode: x.enum(G).default("single").describe(`Shape of the generated sidebar. Values should be ${B(G)}. "single" lists every repository in one sidebar, "multi" gives each repository its own sidebar.`),
|
|
302
|
+
sidebarCollapsed: x.union([x.boolean(), x.null()]).default(!0).describe("Collapse behaviour of generated sidebar groups. \"true\" collapses them by default, \"false\" expands them, \"null\" makes them non-collapsible."),
|
|
303
|
+
acronyms: x.string().regex(/^[^\s-]+$/, "Each acronym must be a single word, with no space or dash, as it is matched against one word of a label.").array().describe("List of comma separated words kept exactly as written in generated sidebar labels and home page titles, such as \"CLI\" or \"API\", matched whole and ignoring case."),
|
|
304
|
+
vitepressConfig: x.any().optional().describe("Path to the vitepress configuration file."),
|
|
305
|
+
websiteTitle: x.string().describe("Website title."),
|
|
306
|
+
websiteTagline: x.string().describe("Website tagline.")
|
|
300
307
|
}), q = K.partial().extend({
|
|
301
|
-
branch:
|
|
302
|
-
gitProvider:
|
|
303
|
-
logLevel:
|
|
304
|
-
forks:
|
|
305
|
-
lastUpdated:
|
|
306
|
-
config:
|
|
307
|
-
token:
|
|
308
|
-
usernames:
|
|
309
|
-
reposFilter:
|
|
310
|
-
extraHeaderPages:
|
|
311
|
-
extraPublicContent:
|
|
312
|
-
extraTheme:
|
|
313
|
-
vitepressConfig:
|
|
314
|
-
sidebarMode:
|
|
315
|
-
sidebarCollapsed:
|
|
308
|
+
branch: x.string().regex(Ae, je).optional().describe(K.shape.branch.description || ""),
|
|
309
|
+
gitProvider: x.enum(W).optional().describe(K.shape.gitProvider.description || ""),
|
|
310
|
+
logLevel: x.enum(A).optional().describe(K.shape.logLevel.description || ""),
|
|
311
|
+
forks: x.boolean().optional().describe(K.shape.forks.description || ""),
|
|
312
|
+
lastUpdated: x.boolean().optional().describe(K.shape.lastUpdated.description || ""),
|
|
313
|
+
config: x.string().optional().describe("Path to the docpress configuration file."),
|
|
314
|
+
token: x.string().optional().describe("Git provider token used to collect data."),
|
|
315
|
+
usernames: x.string().transform(U).optional().describe(K.shape.usernames.description || ""),
|
|
316
|
+
reposFilter: x.string().transform(U).optional().describe(K.shape.reposFilter.description || ""),
|
|
317
|
+
extraHeaderPages: x.string().transform(U).optional().describe(K.shape.extraHeaderPages.description || ""),
|
|
318
|
+
extraPublicContent: x.string().transform(U).optional().describe(K.shape.extraPublicContent.description || ""),
|
|
319
|
+
extraTheme: x.string().transform(U).optional().describe(K.shape.extraTheme.description || ""),
|
|
320
|
+
vitepressConfig: x.string().optional().describe(K.shape.vitepressConfig.description || ""),
|
|
321
|
+
sidebarMode: x.enum(G).optional().describe(K.shape.sidebarMode.description || ""),
|
|
322
|
+
sidebarCollapsed: x.enum(ke).transform((e) => e === "null" ? null : e === "true").optional().describe(`${K.shape.sidebarCollapsed.description} Values should be ${B(ke)}.`),
|
|
323
|
+
acronyms: x.string().transform(U).pipe(K.shape.acronyms).optional().describe(K.shape.acronyms.description || "")
|
|
316
324
|
});
|
|
317
|
-
function
|
|
325
|
+
function Me(e) {
|
|
318
326
|
if (!e) return {};
|
|
319
327
|
let t = { ...e };
|
|
320
328
|
for (let e of [
|
|
@@ -322,30 +330,31 @@ function je(e) {
|
|
|
322
330
|
"reposFilter",
|
|
323
331
|
"extraHeaderPages",
|
|
324
332
|
"extraPublicContent",
|
|
325
|
-
"extraTheme"
|
|
333
|
+
"extraTheme",
|
|
334
|
+
"acronyms"
|
|
326
335
|
]) typeof t[e] == "string" && (t[e] = [t[e]]);
|
|
327
336
|
return t;
|
|
328
337
|
}
|
|
329
|
-
function
|
|
338
|
+
function Ne(e) {
|
|
330
339
|
let t = K.partial().safeParse(e);
|
|
331
|
-
if (!t.success) throw
|
|
340
|
+
if (!t.success) throw t.error;
|
|
332
341
|
return t.data;
|
|
333
342
|
}
|
|
334
|
-
function
|
|
343
|
+
function Pe(e) {
|
|
335
344
|
if (!e.usernames?.length) throw Error("The usernames field is required");
|
|
336
345
|
return e;
|
|
337
346
|
}
|
|
338
|
-
function
|
|
347
|
+
function Fe(e, t) {
|
|
339
348
|
if (e) return e;
|
|
340
349
|
let n = t === "gitlab" ? process.env.GITLAB_TOKEN : process.env.GITHUB_TOKEN;
|
|
341
350
|
return process.env.DOCPRESS_TOKEN || n || void 0;
|
|
342
351
|
}
|
|
343
|
-
function
|
|
344
|
-
e && (process.env.LOG_LEVEL = String(
|
|
352
|
+
function Ie(e) {
|
|
353
|
+
e && (process.env.LOG_LEVEL = String(le(e)));
|
|
345
354
|
}
|
|
346
|
-
var
|
|
355
|
+
var Le = q.partial().transform((e, t) => {
|
|
347
356
|
try {
|
|
348
|
-
let { config: t, vitepressConfig: n, token: r, ...i } = e, a = Me(
|
|
357
|
+
let { config: t, vitepressConfig: n, token: r, ...i } = e, a = Ne(Me(Ce(t))), o = {
|
|
349
358
|
gitProvider: "github",
|
|
350
359
|
forks: !1,
|
|
351
360
|
lastUpdated: !1,
|
|
@@ -358,23 +367,31 @@ var Ie = q.partial().transform((e, t) => {
|
|
|
358
367
|
...Ce(n) || {}
|
|
359
368
|
} } : {}
|
|
360
369
|
};
|
|
361
|
-
return
|
|
370
|
+
return Ie(o.logLevel), Pe({
|
|
362
371
|
...o,
|
|
363
|
-
token:
|
|
372
|
+
token: Fe(r, o.gitProvider)
|
|
364
373
|
});
|
|
365
374
|
} catch (e) {
|
|
375
|
+
if (e instanceof x.ZodError) {
|
|
376
|
+
for (let n of e.issues) t.addIssue({
|
|
377
|
+
code: "custom",
|
|
378
|
+
message: n.message,
|
|
379
|
+
path: n.path
|
|
380
|
+
});
|
|
381
|
+
return x.NEVER;
|
|
382
|
+
}
|
|
366
383
|
return t.addIssue({
|
|
367
384
|
code: "custom",
|
|
368
385
|
message: e instanceof Error ? e.message : JSON.stringify(e, null, 2)
|
|
369
|
-
}),
|
|
386
|
+
}), x.NEVER;
|
|
370
387
|
}
|
|
371
388
|
});
|
|
372
389
|
//#endregion
|
|
373
390
|
//#region src/utils/commands.ts
|
|
374
391
|
function J(e, t) {
|
|
375
|
-
|
|
376
|
-
let n =
|
|
377
|
-
return n.success || (
|
|
392
|
+
j("Initializing Docpress...", "info", "blue"), j("\n\n-> Checking for required environment settings and configurations.", "info"), j(` Debug info - cmd: ${e}`, "debug");
|
|
393
|
+
let n = Le.safeParse(t);
|
|
394
|
+
return n.success || (j(` An error occurred while checking configuration.\n ${x.prettifyError(n.error)}`, "error"), process.exit(1)), j(` Debug info - resolved options: ${JSON.stringify(ge(n.data))}`, "debug"), j(" Setup complete! Ready to process your documentation.", "info"), n.data;
|
|
378
395
|
}
|
|
379
396
|
function Y(e, t) {
|
|
380
397
|
return Object.fromEntries(Object.entries(t).filter(([t]) => e.getOptionValueSource(t) !== "default"));
|
|
@@ -385,27 +402,27 @@ function X(e, t) {
|
|
|
385
402
|
}
|
|
386
403
|
//#endregion
|
|
387
404
|
//#region src/lib/git.ts
|
|
388
|
-
var
|
|
405
|
+
var Re = {
|
|
389
406
|
debug: () => {},
|
|
390
407
|
info: () => {},
|
|
391
408
|
warn: (e) => {
|
|
392
|
-
e.includes("404") ||
|
|
409
|
+
e.includes("404") || j(e, "warn");
|
|
393
410
|
},
|
|
394
411
|
error: (e) => {
|
|
395
|
-
e.includes("404") ||
|
|
412
|
+
e.includes("404") || j(e, "error");
|
|
396
413
|
}
|
|
397
414
|
};
|
|
398
|
-
async function
|
|
399
|
-
|
|
400
|
-
let r = new
|
|
415
|
+
async function ze({ username: e, token: t, branch: n }) {
|
|
416
|
+
j(` Get infos for username '${e}'.`, "info");
|
|
417
|
+
let r = new S({
|
|
401
418
|
auth: t,
|
|
402
|
-
log:
|
|
419
|
+
log: Re
|
|
403
420
|
});
|
|
404
|
-
|
|
421
|
+
j(" Get user infos.", "debug");
|
|
405
422
|
let { data: i } = await r.rest.users.getByUsername({ username: e }).catch((t) => {
|
|
406
423
|
throw t.status === 404 ? /* @__PURE__ */ Error(`No GitHub user found for '${e}'.`) : t;
|
|
407
424
|
});
|
|
408
|
-
return
|
|
425
|
+
return j(" Get repositories infos.", "debug"), {
|
|
409
426
|
user: i,
|
|
410
427
|
repos: await r.paginate(r.rest.repos.listForUser, {
|
|
411
428
|
username: e,
|
|
@@ -415,11 +432,11 @@ async function Re({ username: e, token: t, branch: n }) {
|
|
|
415
432
|
branch: n
|
|
416
433
|
};
|
|
417
434
|
}
|
|
418
|
-
async function
|
|
419
|
-
|
|
420
|
-
let n = new
|
|
435
|
+
async function Be({ repository: e, token: t }) {
|
|
436
|
+
j(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
437
|
+
let n = new S({
|
|
421
438
|
auth: t,
|
|
422
|
-
log:
|
|
439
|
+
log: Re
|
|
423
440
|
}), r;
|
|
424
441
|
try {
|
|
425
442
|
r = (await n.rest.repos.get({
|
|
@@ -427,7 +444,7 @@ async function ze({ repository: e, token: t }) {
|
|
|
427
444
|
repo: e.name
|
|
428
445
|
})).data;
|
|
429
446
|
} catch (t) {
|
|
430
|
-
return
|
|
447
|
+
return j(` Failed to get repository infos for '${e.name}'. Error : ${P(t)}`, "warn"), {
|
|
431
448
|
source: void 0,
|
|
432
449
|
contributors: []
|
|
433
450
|
};
|
|
@@ -444,7 +461,7 @@ async function ze({ repository: e, token: t }) {
|
|
|
444
461
|
per_page: 100
|
|
445
462
|
})) i.push(...e);
|
|
446
463
|
} catch (t) {
|
|
447
|
-
return
|
|
464
|
+
return j(` Failed to get contributors infos for repository '${e.name}'. Error : ${P(t)}`, "warn"), {
|
|
448
465
|
source: r.source,
|
|
449
466
|
contributors: []
|
|
450
467
|
};
|
|
@@ -454,7 +471,7 @@ async function ze({ repository: e, token: t }) {
|
|
|
454
471
|
contributors: i
|
|
455
472
|
};
|
|
456
473
|
}
|
|
457
|
-
function
|
|
474
|
+
function Ve(e) {
|
|
458
475
|
let t = /* @__PURE__ */ new Map(), n = null;
|
|
459
476
|
for (let r of e.split("\n")) {
|
|
460
477
|
let e = r.trim();
|
|
@@ -468,12 +485,12 @@ function Be(e) {
|
|
|
468
485
|
}
|
|
469
486
|
return t;
|
|
470
487
|
}
|
|
471
|
-
async function
|
|
472
|
-
let r =
|
|
488
|
+
async function He(e, t, n) {
|
|
489
|
+
let r = z([t]);
|
|
473
490
|
if (!r.length) return;
|
|
474
491
|
let i;
|
|
475
492
|
try {
|
|
476
|
-
i =
|
|
493
|
+
i = Ve(await e.raw([
|
|
477
494
|
"-c",
|
|
478
495
|
"core.quotePath=false",
|
|
479
496
|
"log",
|
|
@@ -481,19 +498,19 @@ async function Ve(e, t, n) {
|
|
|
481
498
|
"--name-only"
|
|
482
499
|
]));
|
|
483
500
|
} catch (e) {
|
|
484
|
-
|
|
501
|
+
j(` Unable to read commit history for repository '${n}'. Error : ${P(e)}`, "warn");
|
|
485
502
|
return;
|
|
486
503
|
}
|
|
487
504
|
for (let e of r) {
|
|
488
|
-
let n = i.get(
|
|
505
|
+
let n = i.get(_(t, e));
|
|
489
506
|
n && Te(e, n);
|
|
490
507
|
}
|
|
491
508
|
}
|
|
492
|
-
async function
|
|
493
|
-
if (t.startsWith("-") || a.startsWith("-")) return
|
|
494
|
-
|
|
509
|
+
async function Ue(e, t, n, a, o, s) {
|
|
510
|
+
if (t.startsWith("-") || a.startsWith("-")) return j(` Refusing to clone '${e}': unsafe repository URL or branch name.`, "error"), !1;
|
|
511
|
+
L(n, { clean: !0 });
|
|
495
512
|
try {
|
|
496
|
-
let c =
|
|
513
|
+
let c = C({
|
|
497
514
|
baseDir: n,
|
|
498
515
|
config: [
|
|
499
516
|
"maintenance.auto=false",
|
|
@@ -502,24 +519,24 @@ async function He(e, t, n, a, o, s) {
|
|
|
502
519
|
]
|
|
503
520
|
});
|
|
504
521
|
await c.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
|
|
505
|
-
for (let t of o)
|
|
506
|
-
return
|
|
522
|
+
for (let t of o) j(` Add '${t}' to '${e}' sparse-checkout file.`, "debug"), r(v(n, ".git/info/sparse-checkout"), `${t}\n`, "utf8");
|
|
523
|
+
return j(` Clone repository '${e}'.`, "info"), await c.pull("origin", a), s && await He(c, n, e), o.some((e) => e.includes("docs")) && (i(v(n, "docs"), n, { recursive: !0 }), u(v(n, "docs"), { recursive: !0 })), u(v(n, ".git"), { recursive: !0 }), !0;
|
|
507
524
|
} catch (t) {
|
|
508
|
-
return
|
|
525
|
+
return j(` Error when cloning repository '${e}': ${P(t)}.`, "error"), !1;
|
|
509
526
|
}
|
|
510
527
|
}
|
|
511
528
|
//#endregion
|
|
512
529
|
//#region src/lib/gitlab.ts
|
|
513
|
-
var
|
|
530
|
+
var We = "https://gitlab.com/api/v4";
|
|
514
531
|
async function Z(e, t) {
|
|
515
|
-
let n = await fetch(`${
|
|
532
|
+
let n = await fetch(`${We}${e}`, { headers: t ? { "PRIVATE-TOKEN": t } : {} });
|
|
516
533
|
if (!n.ok) throw Error(`GitLab API request failed for '${e}' (status: ${n.status}).`);
|
|
517
534
|
return {
|
|
518
535
|
data: await n.json(),
|
|
519
536
|
headers: n.headers
|
|
520
537
|
};
|
|
521
538
|
}
|
|
522
|
-
async function
|
|
539
|
+
async function Ge(e, t) {
|
|
523
540
|
let n = e.includes("?") ? "&" : "?", r = [], i = "1";
|
|
524
541
|
for (; i;) {
|
|
525
542
|
let a = await Z(`${e}${n}per_page=100&page=${i}`, t);
|
|
@@ -527,7 +544,7 @@ async function We(e, t) {
|
|
|
527
544
|
}
|
|
528
545
|
return r;
|
|
529
546
|
}
|
|
530
|
-
function
|
|
547
|
+
function Ke(e) {
|
|
531
548
|
return {
|
|
532
549
|
login: e.username ?? e.path,
|
|
533
550
|
name: e.name,
|
|
@@ -536,7 +553,7 @@ function Ge(e) {
|
|
|
536
553
|
html_url: e.web_url
|
|
537
554
|
};
|
|
538
555
|
}
|
|
539
|
-
function
|
|
556
|
+
function qe(e, t) {
|
|
540
557
|
return {
|
|
541
558
|
name: e.path,
|
|
542
559
|
owner: { login: t },
|
|
@@ -550,32 +567,32 @@ function Ke(e, t) {
|
|
|
550
567
|
stargazers_count: e.star_count
|
|
551
568
|
};
|
|
552
569
|
}
|
|
553
|
-
async function
|
|
554
|
-
|
|
570
|
+
async function Je({ username: e, token: t, branch: n }) {
|
|
571
|
+
j(` Get infos for username '${e}'.`, "info");
|
|
555
572
|
let { data: r } = await Z(`/users?username=${encodeURIComponent(e)}`, t);
|
|
556
573
|
if (r.length) {
|
|
557
574
|
let i = r[0];
|
|
558
|
-
t && (i = await Z(`/users/${r[0].id}`, t).then((e) => e.data).catch(() => r[0])),
|
|
559
|
-
let a = await
|
|
575
|
+
t && (i = await Z(`/users/${r[0].id}`, t).then((e) => e.data).catch(() => r[0])), j(" Get repositories infos.", "debug");
|
|
576
|
+
let a = await Ge(`/users/${r[0].id}/projects`, t);
|
|
560
577
|
return {
|
|
561
|
-
user:
|
|
562
|
-
repos: a.map((t) =>
|
|
578
|
+
user: Ke(i),
|
|
579
|
+
repos: a.map((t) => qe(t, i.username ?? e)),
|
|
563
580
|
branch: n
|
|
564
581
|
};
|
|
565
582
|
}
|
|
566
|
-
|
|
583
|
+
j(` No GitLab user '${e}' found, trying groups.`, "debug");
|
|
567
584
|
let i = await Z(`/groups/${encodeURIComponent(e)}?with_projects=false`, t).then((e) => e.data).catch(() => {
|
|
568
585
|
throw Error(`No GitLab user or group found for '${e}'.`);
|
|
569
|
-
}), a = await
|
|
586
|
+
}), a = await Ge(`/groups/${encodeURIComponent(e)}/projects`, t);
|
|
570
587
|
return {
|
|
571
|
-
user:
|
|
572
|
-
repos: a.map((t) =>
|
|
588
|
+
user: Ke(i),
|
|
589
|
+
repos: a.map((t) => qe(t, i.path ?? e)),
|
|
573
590
|
branch: n
|
|
574
591
|
};
|
|
575
592
|
}
|
|
576
593
|
//#endregion
|
|
577
594
|
//#region src/lib/fetch.ts
|
|
578
|
-
function
|
|
595
|
+
function Ye(e, t, n) {
|
|
579
596
|
if (n === "gitlab") {
|
|
580
597
|
let n = e.html_url ?? `https://gitlab.com/${e.owner.login}/${e.name}`;
|
|
581
598
|
return {
|
|
@@ -591,11 +608,11 @@ function Je(e, t, n) {
|
|
|
591
608
|
raw_url: `https://raw.githubusercontent.com/${e.owner.login}/${e.name}/${t}`
|
|
592
609
|
};
|
|
593
610
|
}
|
|
594
|
-
async function
|
|
611
|
+
async function Xe(e) {
|
|
595
612
|
let [t, n, r] = await Promise.all([
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
613
|
+
M(`${e.blob_url}/README.md`),
|
|
614
|
+
M(`${e.tree_url}/docs`),
|
|
615
|
+
M(`${e.blob_url}/docs/01-readme.md`)
|
|
599
616
|
]);
|
|
600
617
|
return {
|
|
601
618
|
rootReadmeStatus: t,
|
|
@@ -603,19 +620,19 @@ async function Ye(e) {
|
|
|
603
620
|
docsReadmeStatus: r
|
|
604
621
|
};
|
|
605
622
|
}
|
|
606
|
-
async function
|
|
607
|
-
let { user: s, repos: c, branch: l } = await (r === "gitlab" ?
|
|
623
|
+
async function Ze({ username: e, branch: t, reposFilter: n, gitProvider: r, token: i, lastUpdated: a, multiUser: o }) {
|
|
624
|
+
let { user: s, repos: c, branch: l } = await (r === "gitlab" ? Je : ze)({
|
|
608
625
|
username: e,
|
|
609
626
|
token: i,
|
|
610
627
|
branch: t
|
|
611
|
-
}), { repos: u } = await
|
|
612
|
-
await
|
|
628
|
+
}), { repos: u } = await et(s, c, l, n, r, o ? `${N(e)}/` : "");
|
|
629
|
+
await tt(u, n, a);
|
|
613
630
|
}
|
|
614
|
-
async function
|
|
631
|
+
async function Qe(e, t, n, r, i = "") {
|
|
615
632
|
let a = [];
|
|
616
633
|
return await Promise.all(e.map(async (e) => {
|
|
617
|
-
let o = t ?? e.default_branch ?? "main", s =
|
|
618
|
-
!e.fork && !e.private && !c && (u = await
|
|
634
|
+
let o = t ?? e.default_branch ?? "main", s = v(re, `${i}${I(N(e.name), { removeDot: !0 })}`), c = nt(e, n), l = Ye(e, o, r), u = [];
|
|
635
|
+
!e.fork && !e.private && !c && (u = await $e(e, o, r, l)), a.push({
|
|
619
636
|
...e,
|
|
620
637
|
docpress: {
|
|
621
638
|
filtered: c,
|
|
@@ -629,38 +646,38 @@ async function Ze(e, t, n, r, i = "") {
|
|
|
629
646
|
});
|
|
630
647
|
})), a;
|
|
631
648
|
}
|
|
632
|
-
async function
|
|
633
|
-
let i = await
|
|
649
|
+
async function $e(e, t, n, r) {
|
|
650
|
+
let i = await Xe(r ?? Ye(e, t, n)), a = [];
|
|
634
651
|
return Object.values(i).every((e) => e !== 200) || !e.size ? [] : (i.docsFolderStatus === 200 && a.push("docs/*"), (i.docsFolderStatus !== 200 || i.docsReadmeStatus !== 200) && a.push("README.md", "!*/**/README.md"), a);
|
|
635
652
|
}
|
|
636
|
-
async function
|
|
637
|
-
f(`${
|
|
638
|
-
let o = await
|
|
639
|
-
return f(`${
|
|
653
|
+
async function et(e, t, n, r, i, a = "") {
|
|
654
|
+
f(`${T}/user-${N(e.login)}.json`, JSON.stringify(e, null, 2));
|
|
655
|
+
let o = await Qe(t, n, r, i, a);
|
|
656
|
+
return f(`${T}/repos-${N(e.login)}.json`, JSON.stringify(o, null, 2)), {
|
|
640
657
|
user: e,
|
|
641
658
|
repos: o
|
|
642
659
|
};
|
|
643
660
|
}
|
|
644
|
-
async function
|
|
661
|
+
async function tt(e, t, n) {
|
|
645
662
|
if (!e) {
|
|
646
|
-
|
|
663
|
+
j(" No repositories to process.", "warn");
|
|
647
664
|
return;
|
|
648
665
|
}
|
|
649
|
-
let r = await Promise.all(e.filter((e) => !
|
|
650
|
-
let t = await
|
|
666
|
+
let r = await Promise.all(e.filter((e) => !nt(e, t)).map(async (e) => {
|
|
667
|
+
let t = await Ue(e.name, e.clone_url, e.docpress.projectPath, e.docpress.branch, e.docpress.includes, n);
|
|
651
668
|
return {
|
|
652
669
|
name: e.name,
|
|
653
670
|
success: t
|
|
654
671
|
};
|
|
655
672
|
}));
|
|
656
673
|
if (!r.length) {
|
|
657
|
-
|
|
674
|
+
j(" No repository matched the current filters.", "warn");
|
|
658
675
|
return;
|
|
659
676
|
}
|
|
660
677
|
let i = r.filter(({ success: e }) => !e).map(({ name: e }) => e), a = r.length - i.length;
|
|
661
|
-
i.length ?
|
|
678
|
+
i.length ? j(` Cloned ${a}/${r.length} repository(ies), ${i.length} failed: ${i.join(", ")}.`, "warn") : j(` Cloned ${a}/${r.length} repository(ies).`, "success");
|
|
662
679
|
}
|
|
663
|
-
function
|
|
680
|
+
function nt(e, t) {
|
|
664
681
|
if ("docpress" in e && !e.docpress.includes.length) return !0;
|
|
665
682
|
let n = t?.filter((e) => !e.startsWith("!")) ?? [], r = t?.every((e) => e.startsWith("!")), i = t?.filter((e) => e.startsWith("!")).some((t) => e.name === t.substring(1)), a = !t || n.includes(e.name) || e.fork && !i || r && !i, o = i || !a;
|
|
666
683
|
return !(e.clone_url && !e.private && !o);
|
|
@@ -672,24 +689,24 @@ var Q = [
|
|
|
672
689
|
n("--log-level <string>", q.shape.logLevel.description),
|
|
673
690
|
n("-T, --token <string>", q.shape.token.description),
|
|
674
691
|
n("-U, --usernames <string>", q.shape.usernames.description)
|
|
675
|
-
],
|
|
692
|
+
], rt = "fetch", it = [
|
|
676
693
|
n("-b, --branch <string>", K.shape.branch.description),
|
|
677
694
|
n("-g, --git-provider <string>", K.shape.gitProvider.description).default(K.shape.gitProvider.def.defaultValue),
|
|
678
695
|
n("-l, --last-updated", K.shape.lastUpdated.description),
|
|
679
696
|
n("-r, --repos-filter <string>", K.shape.reposFilter.description)
|
|
680
|
-
],
|
|
681
|
-
await
|
|
697
|
+
], at = X(t(rt), [...it, ...Q]).description("Fetch docs with the given username(s) and git provider.").action(async (e, t) => {
|
|
698
|
+
await ot(J(rt, Y(t, e)));
|
|
682
699
|
});
|
|
683
|
-
async function
|
|
700
|
+
async function ot(e) {
|
|
684
701
|
let { usernames: t, reposFilter: n, token: r, branch: i, gitProvider: a, lastUpdated: o } = e;
|
|
685
|
-
|
|
702
|
+
j("\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.", "info");
|
|
686
703
|
let s = Date.now();
|
|
687
|
-
|
|
704
|
+
L(T, { clean: !0 });
|
|
688
705
|
let c = [];
|
|
689
706
|
for (let e of t) {
|
|
690
707
|
let s = t.length > 1 ? n?.filter((t) => t.replace(/^!/, "").startsWith(`${e}/`)).map((t) => t.replace(`${e}/`, "")) : n;
|
|
691
708
|
try {
|
|
692
|
-
await
|
|
709
|
+
await Ze({
|
|
693
710
|
username: e,
|
|
694
711
|
branch: i,
|
|
695
712
|
reposFilter: s,
|
|
@@ -699,15 +716,15 @@ async function at(e) {
|
|
|
699
716
|
multiUser: t.length > 1
|
|
700
717
|
});
|
|
701
718
|
} catch (t) {
|
|
702
|
-
c.push(e),
|
|
719
|
+
c.push(e), j(` Failed to fetch documentation for '${e}': ${P(t)}`, "error");
|
|
703
720
|
}
|
|
704
721
|
}
|
|
705
722
|
if (c.length === t.length) throw Error(`Failed to fetch documentation for all requested username(s): ${c.join(", ")}.`);
|
|
706
|
-
|
|
723
|
+
j(` Fetched documentation for ${t.length - c.length}/${t.length} username(s) in ${F(Date.now() - s)}.`, c.length ? "warn" : "success");
|
|
707
724
|
}
|
|
708
725
|
//#endregion
|
|
709
726
|
//#region src/commands/build.ts
|
|
710
|
-
async function
|
|
727
|
+
async function st(e) {
|
|
711
728
|
let t = console.warn;
|
|
712
729
|
console.warn = function(...e) {
|
|
713
730
|
e.length > 0 && typeof e[0] == "string" && (e[0].includes("[Vue warn]: Invalid watch source:") || e[0].includes("{ open: false }")) || t.apply(console, e);
|
|
@@ -718,32 +735,32 @@ async function ot(e) {
|
|
|
718
735
|
console.warn = t;
|
|
719
736
|
}
|
|
720
737
|
}
|
|
721
|
-
var
|
|
722
|
-
await
|
|
738
|
+
var ct = X(t("build"), Q).description("Build vitepress website.").action(async (e) => {
|
|
739
|
+
await lt();
|
|
723
740
|
});
|
|
724
|
-
async function
|
|
725
|
-
|
|
741
|
+
async function lt() {
|
|
742
|
+
j("\n-> Start building Vitepress website.\n\n", "info");
|
|
726
743
|
let e = Date.now();
|
|
727
744
|
try {
|
|
728
|
-
await
|
|
729
|
-
await
|
|
730
|
-
|
|
745
|
+
await st(async () => {
|
|
746
|
+
await w(T, { onAfterConfigResolve(e) {
|
|
747
|
+
ee(e);
|
|
731
748
|
} });
|
|
732
749
|
});
|
|
733
750
|
} catch (e) {
|
|
734
|
-
throw Error(`Docpress build failed: ${
|
|
751
|
+
throw Error(`Docpress build failed: ${P(e)}`);
|
|
735
752
|
}
|
|
736
|
-
|
|
753
|
+
j(`\n\nDocpress build succeeded in ${F(Date.now() - e)}.`, "success");
|
|
737
754
|
}
|
|
738
755
|
//#endregion
|
|
739
756
|
//#region src/utils/templates.ts
|
|
740
|
-
function
|
|
757
|
+
function ut(e, t) {
|
|
741
758
|
let n = s(e, { encoding: "utf8" });
|
|
742
|
-
|
|
759
|
+
L(m(t)), f(t, n);
|
|
743
760
|
}
|
|
744
761
|
//#endregion
|
|
745
762
|
//#region src/lib/vitepress.ts
|
|
746
|
-
var
|
|
763
|
+
var dt = {
|
|
747
764
|
base: "/",
|
|
748
765
|
lang: "en-US",
|
|
749
766
|
vite: { publicDir: "../public" },
|
|
@@ -776,24 +793,24 @@ var ut = {
|
|
|
776
793
|
}
|
|
777
794
|
}
|
|
778
795
|
};
|
|
779
|
-
function
|
|
780
|
-
return n ?
|
|
796
|
+
function ft(e, t, n) {
|
|
797
|
+
return n ? V(dt, n, { themeConfig: {
|
|
781
798
|
sidebar: e,
|
|
782
799
|
nav: t
|
|
783
|
-
} }) :
|
|
800
|
+
} }) : V(dt, { themeConfig: {
|
|
784
801
|
sidebar: e,
|
|
785
802
|
nav: t
|
|
786
803
|
} });
|
|
787
804
|
}
|
|
788
805
|
//#endregion
|
|
789
806
|
//#region src/lib/prepare.ts
|
|
790
|
-
function
|
|
807
|
+
function pt(e) {
|
|
791
808
|
return e === null ? {} : { collapsed: e };
|
|
792
809
|
}
|
|
793
|
-
async function
|
|
794
|
-
let
|
|
795
|
-
i && !
|
|
796
|
-
let
|
|
810
|
+
async function mt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, vitepressConfig: r, forks: i, gitProvider: o, lastUpdated: s, sidebarMode: c, sidebarCollapsed: l, acronyms: u, token: d, username: f, websiteTitle: p, websiteTagline: m }) {
|
|
811
|
+
let h = i && o !== "gitlab";
|
|
812
|
+
i && !h && j(" The forks page is not supported with the 'gitlab' provider, skipping.", "warn");
|
|
813
|
+
let g = be(f), _ = xe(f).reduce(({ internals: e, forks: t }, n) => {
|
|
797
814
|
let { clone_url: r, private: i, fork: a, docpress: o } = n;
|
|
798
815
|
if (r && !i && !o.filtered) {
|
|
799
816
|
if (!a && o.includes.length) return {
|
|
@@ -812,43 +829,44 @@ async function pt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, v
|
|
|
812
829
|
}, {
|
|
813
830
|
internals: [],
|
|
814
831
|
forks: []
|
|
815
|
-
}),
|
|
816
|
-
title:
|
|
817
|
-
tagline:
|
|
818
|
-
}, { index:
|
|
832
|
+
}), y = {
|
|
833
|
+
title: p,
|
|
834
|
+
tagline: m
|
|
835
|
+
}, { index: b, sidebar: x } = Et(_.internals, g, y, {
|
|
819
836
|
mode: c,
|
|
820
|
-
collapsed: l
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
837
|
+
collapsed: l,
|
|
838
|
+
acronyms: u
|
|
839
|
+
}), S, C;
|
|
840
|
+
if (a(E) && a(D)) {
|
|
841
|
+
let e = await jt(D), t = await Mt(E);
|
|
842
|
+
S = Tt(e.themeConfig?.sidebar, x), C = {
|
|
843
|
+
...b,
|
|
844
|
+
features: [...t.features, ...b.features].sort((e, t) => e.title.localeCompare(t.title))
|
|
827
845
|
};
|
|
828
|
-
} else
|
|
829
|
-
let
|
|
846
|
+
} else S = x, C = b;
|
|
847
|
+
let w = [];
|
|
830
848
|
if (e) {
|
|
831
|
-
let t =
|
|
832
|
-
|
|
849
|
+
let t = Dt(e);
|
|
850
|
+
h ? w.push(...t.filter((e) => e.link !== "/forks")) : w.push(...t);
|
|
833
851
|
}
|
|
834
|
-
t && (
|
|
852
|
+
t && (j(" Add extras Vitepress public folder content.", "info"), Ot(t, v(T, "public"))), n && (j(" Add extras Vitepress theme files.", "info"), Ot(n, v(oe))), h && f.length && (j(" Add fork page to display external contributions.", "info"), await At(_.forks, f, d), w.push({
|
|
835
853
|
text: "Forks",
|
|
836
854
|
link: "/forks"
|
|
837
855
|
}));
|
|
838
|
-
let
|
|
856
|
+
let ee = s ? {
|
|
839
857
|
lastUpdated: !0,
|
|
840
858
|
...r
|
|
841
859
|
} : r;
|
|
842
|
-
|
|
860
|
+
Pt(ft(S, w, ee), C);
|
|
843
861
|
}
|
|
844
|
-
function
|
|
845
|
-
let n = `${
|
|
862
|
+
function ht(e, t) {
|
|
863
|
+
let n = `${I(p(t), {
|
|
846
864
|
mode: "lowercase",
|
|
847
865
|
removeIdx: !0
|
|
848
866
|
}) === "readme.md" ? "\n## Sources" : "# Sources"}\n\nTake a look at the [project sources](${e}).\n`;
|
|
849
867
|
r(t, n, "utf8");
|
|
850
868
|
}
|
|
851
|
-
function
|
|
869
|
+
function gt(e, t, n) {
|
|
852
870
|
let { name: r, login: i, bio: a } = t, { title: o, tagline: s } = n;
|
|
853
871
|
return {
|
|
854
872
|
layout: "home",
|
|
@@ -862,138 +880,142 @@ function ht(e, t, n) {
|
|
|
862
880
|
features: e
|
|
863
881
|
};
|
|
864
882
|
}
|
|
865
|
-
function
|
|
866
|
-
let
|
|
867
|
-
title:
|
|
883
|
+
function _t(e, t, n, r = "", i = []) {
|
|
884
|
+
let a = {
|
|
885
|
+
title: I(e, {
|
|
868
886
|
mode: "capitalize",
|
|
869
|
-
replaceDash: !0
|
|
887
|
+
replaceDash: !0,
|
|
888
|
+
acronyms: i
|
|
870
889
|
}),
|
|
871
890
|
details: t,
|
|
872
|
-
link: `/${r}${
|
|
891
|
+
link: `/${r}${I(e, { removeDot: !0 })}/introduction`
|
|
873
892
|
};
|
|
874
|
-
return n ? [...n,
|
|
893
|
+
return n ? [...n, a] : [a];
|
|
875
894
|
}
|
|
876
|
-
function
|
|
895
|
+
function vt(e, t, n = !0, r = []) {
|
|
877
896
|
return {
|
|
878
|
-
text:
|
|
897
|
+
text: I(e, {
|
|
879
898
|
mode: "capitalize",
|
|
880
|
-
replaceDash: !0
|
|
899
|
+
replaceDash: !0,
|
|
900
|
+
acronyms: r
|
|
881
901
|
}),
|
|
882
|
-
...
|
|
902
|
+
...pt(n),
|
|
883
903
|
items: t
|
|
884
904
|
};
|
|
885
905
|
}
|
|
886
|
-
function
|
|
887
|
-
return Object.entries(t).flatMap(([t,
|
|
888
|
-
if (t === "$") return Array.isArray(
|
|
889
|
-
let n =
|
|
906
|
+
function yt(e, t, n = !0, r = []) {
|
|
907
|
+
return Object.entries(t).flatMap(([t, i]) => {
|
|
908
|
+
if (t === "$") return Array.isArray(i) ? i.map((t) => {
|
|
909
|
+
let n = v(e.docpress.projectPath, t), i = I(p(n), {
|
|
890
910
|
mode: "lowercase",
|
|
891
911
|
removeIdx: !0
|
|
892
912
|
});
|
|
893
|
-
return
|
|
894
|
-
text: g(
|
|
913
|
+
return i === "readme.md" && (i = "introduction.md"), i !== p(n) && l(n, v(m(n), i)), {
|
|
914
|
+
text: g(i).name === "introduction" ? "Introduction" : I(i, {
|
|
895
915
|
mode: "capitalize",
|
|
896
916
|
replaceDash: !0,
|
|
897
|
-
removeExt: !0
|
|
917
|
+
removeExt: !0,
|
|
918
|
+
acronyms: r
|
|
898
919
|
}),
|
|
899
|
-
link: `/${e.docpress.routePrefix ?? ""}${
|
|
920
|
+
link: `/${e.docpress.routePrefix ?? ""}${I(e.name, { removeDot: !0 })}/${g(i).name}`
|
|
900
921
|
};
|
|
901
922
|
}) : [];
|
|
902
|
-
if (typeof
|
|
903
|
-
let
|
|
904
|
-
return
|
|
905
|
-
text:
|
|
923
|
+
if (typeof i == "object") {
|
|
924
|
+
let a = I(t, { removeIdx: !0 }), o = v(e.docpress.projectPath, t), s = v(e.docpress.projectPath, a);
|
|
925
|
+
return a !== t && l(o, s), [{
|
|
926
|
+
text: I(a, {
|
|
906
927
|
mode: "capitalize",
|
|
907
|
-
replaceDash: !0
|
|
928
|
+
replaceDash: !0,
|
|
929
|
+
acronyms: r
|
|
908
930
|
}),
|
|
909
|
-
...
|
|
910
|
-
items:
|
|
931
|
+
...pt(n),
|
|
932
|
+
items: yt({
|
|
911
933
|
...e,
|
|
912
|
-
name: `${e.name}/${
|
|
934
|
+
name: `${e.name}/${a}`,
|
|
913
935
|
docpress: {
|
|
914
936
|
...e.docpress,
|
|
915
|
-
projectPath:
|
|
937
|
+
projectPath: s
|
|
916
938
|
}
|
|
917
|
-
},
|
|
939
|
+
}, i, n, r)
|
|
918
940
|
}];
|
|
919
941
|
}
|
|
920
942
|
return [];
|
|
921
943
|
});
|
|
922
944
|
}
|
|
923
|
-
function
|
|
945
|
+
function bt(e) {
|
|
924
946
|
return e.reduce((e, t) => {
|
|
925
947
|
let [n, ...r] = t.split("/");
|
|
926
|
-
return r.length ? e[n] =
|
|
948
|
+
return r.length ? e[n] = bt([...e[n] ? xt(e[n], "") : [], r.join("/")]) : e.$ = [...e.$ || [], n], e;
|
|
927
949
|
}, {});
|
|
928
950
|
}
|
|
929
|
-
function
|
|
930
|
-
return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] :
|
|
951
|
+
function xt(e, t = "") {
|
|
952
|
+
return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] : xt(n, t ? `${t}/${e}` : e));
|
|
931
953
|
}
|
|
932
|
-
function
|
|
954
|
+
function St(e) {
|
|
933
955
|
if (!Array.isArray(e)) return e;
|
|
934
956
|
let t = e.findIndex((e) => e.text === "Sources");
|
|
935
957
|
if (t === -1) return e;
|
|
936
958
|
let [n] = e.splice(t, 1);
|
|
937
959
|
return e.push(n), e;
|
|
938
960
|
}
|
|
939
|
-
var
|
|
940
|
-
function
|
|
961
|
+
var Ct = 5;
|
|
962
|
+
function wt(e, t, n = []) {
|
|
941
963
|
return e.flatMap((e) => {
|
|
942
964
|
if (!("items" in e) || !e.items?.length) return [];
|
|
943
965
|
let r = [...n, e.text];
|
|
944
|
-
return t >=
|
|
966
|
+
return t >= Ct ? [r.join("/")] : wt(e.items, t + 1, r);
|
|
945
967
|
});
|
|
946
968
|
}
|
|
947
|
-
function
|
|
969
|
+
function Tt(e, t) {
|
|
948
970
|
if (!e) return t;
|
|
949
971
|
if (Array.isArray(e) && Array.isArray(t)) return [...e, ...t].toSorted((e, t) => (e.text ?? "").localeCompare(t.text ?? ""));
|
|
950
972
|
let n = (e) => Array.isArray(e) ? { "/": e } : e;
|
|
951
|
-
return
|
|
973
|
+
return $({
|
|
952
974
|
...n(e),
|
|
953
975
|
...n(t)
|
|
954
976
|
});
|
|
955
977
|
}
|
|
956
|
-
function
|
|
978
|
+
function $(e) {
|
|
957
979
|
return Object.fromEntries(Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)));
|
|
958
980
|
}
|
|
959
|
-
function
|
|
960
|
-
let { mode: i = "single", collapsed: a = !0 } = r,
|
|
981
|
+
function Et(e, t, n, r = {}) {
|
|
982
|
+
let { mode: i = "single", collapsed: a = !0, acronyms: o = [] } = r, s = [], l = [], u = {};
|
|
961
983
|
for (let t of e) {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
}),
|
|
984
|
+
j(` Replace urls for repository '${t.name}'.`, "info"), z([t.docpress.projectPath]).forEach((e) => {
|
|
985
|
+
j(` Processing file '${p(e)}' for repository '${t.name}'.`, "debug"), we(e, t.docpress.replace_url), p(e).toLowerCase() === "readme.md" && Oe(e, t.docpress.replace_url), De(e);
|
|
986
|
+
}), j(` Generate sidebar for repository '${t.name}'.`, "info");
|
|
965
987
|
let e = c(t.docpress.projectPath, { recursive: !0 }).filter((e) => {
|
|
966
|
-
let n =
|
|
988
|
+
let n = v(t.docpress.projectPath, e.toString());
|
|
967
989
|
return p(n).endsWith(".md") && ye(n);
|
|
968
990
|
}).sort();
|
|
969
|
-
|
|
991
|
+
j(` Add sources for repository '${t.name}'.`, "info");
|
|
970
992
|
let n;
|
|
971
|
-
e.length > 1 ? (n =
|
|
972
|
-
let r =
|
|
973
|
-
|
|
993
|
+
e.length > 1 ? (n = v(t.docpress.projectPath, "sources.md"), e.push("sources.md")) : e.length === 1 && (n = v(t.docpress.projectPath, e[0])), n ? ht(t.html_url, n) : j(` No markdown files found for repository '${t.name}', skipping sources.`, "warn");
|
|
994
|
+
let r = St(yt(t, bt(e), a, o)), d = wt(r, i === "multi" ? 0 : 1);
|
|
995
|
+
d.length && j(` Sidebar for repository '${t.name}' nests deeper than Vitepress renders, pages under ${d.map((e) => `'${e}'`).join(", ")} will not appear in the sidebar.`, "warn"), i === "multi" ? u[`/${t.docpress.routePrefix ?? ""}${I(t.name, { removeDot: !0 })}/`] = r : l.push(vt(I(t.name, { removeDot: !0 }), r, a, o)), s.push(..._t(I(t.name, { removeDot: !0 }), t.description || "", void 0, t.docpress.routePrefix ?? "", o));
|
|
974
996
|
}
|
|
975
|
-
|
|
976
|
-
let
|
|
997
|
+
j(" Generate index content.", "info");
|
|
998
|
+
let d = gt(s.toSorted((e, t) => e.title.localeCompare(t.title)), t, n);
|
|
977
999
|
return {
|
|
978
|
-
sidebar: i === "multi" ?
|
|
979
|
-
index:
|
|
1000
|
+
sidebar: i === "multi" ? $(u) : l.toSorted((e, t) => e.text.localeCompare(t.text)),
|
|
1001
|
+
index: d
|
|
980
1002
|
};
|
|
981
1003
|
}
|
|
982
|
-
function
|
|
983
|
-
let t =
|
|
984
|
-
|
|
1004
|
+
function Dt(e) {
|
|
1005
|
+
let t = z(e), n = [];
|
|
1006
|
+
j(" Add extras Vitepress headers pages.", "info");
|
|
985
1007
|
for (let e of t) {
|
|
986
|
-
|
|
987
|
-
let t =
|
|
1008
|
+
j(` Processing file '${e}'.`, "debug");
|
|
1009
|
+
let t = v(process.cwd(), e), r = v(re, I(p(e), {
|
|
988
1010
|
mode: "lowercase",
|
|
989
1011
|
removeIdx: !0
|
|
990
1012
|
}));
|
|
991
1013
|
i(t, r), n.push({
|
|
992
|
-
text:
|
|
1014
|
+
text: I(g(t).name, {
|
|
993
1015
|
replaceDash: !0,
|
|
994
1016
|
removeIdx: !0
|
|
995
1017
|
}),
|
|
996
|
-
link: `/${
|
|
1018
|
+
link: `/${I(g(t).name, {
|
|
997
1019
|
removeIdx: !0,
|
|
998
1020
|
mode: "lowercase"
|
|
999
1021
|
})}`
|
|
@@ -1001,18 +1023,18 @@ function Et(e) {
|
|
|
1001
1023
|
}
|
|
1002
1024
|
return n;
|
|
1003
1025
|
}
|
|
1004
|
-
function
|
|
1026
|
+
function Ot(e, t, n) {
|
|
1005
1027
|
for (let r of Array.isArray(e) ? e : [e]) {
|
|
1006
|
-
let e =
|
|
1028
|
+
let e = v(process.cwd(), r), a = R(e);
|
|
1007
1029
|
for (let o of a) {
|
|
1008
1030
|
let a = o.replace(e, ".");
|
|
1009
|
-
|
|
1010
|
-
let s =
|
|
1031
|
+
j(` Processing file '${a}' for entry '${r}'.`, "debug");
|
|
1032
|
+
let s = v(process.cwd(), o), c = v(t, a);
|
|
1011
1033
|
n && n(), i(s, c);
|
|
1012
1034
|
}
|
|
1013
1035
|
}
|
|
1014
1036
|
}
|
|
1015
|
-
function
|
|
1037
|
+
function kt(e) {
|
|
1016
1038
|
let t = e.map(({ repository: e, contributions: t }) => {
|
|
1017
1039
|
let { name: n, owner: r, html_url: i, description: a, stargazers_count: o } = e;
|
|
1018
1040
|
return {
|
|
@@ -1024,11 +1046,11 @@ function Ot(e) {
|
|
|
1024
1046
|
contributions: t
|
|
1025
1047
|
};
|
|
1026
1048
|
});
|
|
1027
|
-
|
|
1049
|
+
j(" Generate forks page.", "info"), f(ie, "---\nlayout: fork-page\nrepoList:\n" + y.stringify(t) + "---\n\n# External contributions\n\nThis gallery is a visual representation of the collaborative work done across a variety of open-source projects, each driven by a shared passion for innovation and community growth.\n\nEvery tile below represents a unique project where contributions have been made-ranging from code enhancements to documentation improvements. Each project includes a summary of its goals, features, and links to GitHub for direct access.\n\nThis page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.\n");
|
|
1028
1050
|
}
|
|
1029
|
-
async function
|
|
1030
|
-
|
|
1031
|
-
let { source: r, contributors: i } = await
|
|
1051
|
+
async function At(e, t, n) {
|
|
1052
|
+
kt(await Promise.all(e.map(async (e) => {
|
|
1053
|
+
let { source: r, contributors: i } = await Be({
|
|
1032
1054
|
repository: e,
|
|
1033
1055
|
token: n
|
|
1034
1056
|
});
|
|
@@ -1038,31 +1060,32 @@ async function kt(e, t, n) {
|
|
|
1038
1060
|
};
|
|
1039
1061
|
})).then((e) => e.filter(({ repository: e, contributions: t }) => !!e && t)));
|
|
1040
1062
|
}
|
|
1041
|
-
async function
|
|
1063
|
+
async function jt(e) {
|
|
1042
1064
|
try {
|
|
1043
|
-
let { config: t } = await import(
|
|
1065
|
+
let { config: t } = await import(v(process.cwd(), e));
|
|
1044
1066
|
return t ?? {};
|
|
1045
1067
|
} catch (t) {
|
|
1046
|
-
return
|
|
1068
|
+
return j(` Unable to load existing Vitepress config '${e}', starting from an empty config. ${P(t)}`, "warn"), {};
|
|
1047
1069
|
}
|
|
1048
1070
|
}
|
|
1049
|
-
async function
|
|
1050
|
-
let t = (await
|
|
1051
|
-
return
|
|
1052
|
-
}
|
|
1053
|
-
var
|
|
1054
|
-
function
|
|
1055
|
-
|
|
1056
|
-
let n =
|
|
1057
|
-
if (!n.length) throw Error(`No template theme files found at '${
|
|
1058
|
-
|
|
1059
|
-
let t = e.replace(`${
|
|
1060
|
-
|
|
1071
|
+
async function Mt(e) {
|
|
1072
|
+
let t = (await te(v(process.cwd(), e))).toString();
|
|
1073
|
+
return y.parse(t);
|
|
1074
|
+
}
|
|
1075
|
+
var Nt = "\nfunction escapeInlineCode(md) {\n const render = md.renderer.rules.code_inline\n md.renderer.rules.code_inline = (tokens, idx, options, env, self) => {\n tokens[idx].attrSet('v-pre', '')\n return render(tokens, idx, options, env, self)\n }\n}\n\nexport default { ...config, markdown: { ...config.markdown, config: escapeInlineCode } }\n";
|
|
1076
|
+
function Pt(e, t) {
|
|
1077
|
+
L(m(D)), j(" Generate Vitepress config.", "info"), f(D, `export const config = ${JSON.stringify(e, null, 2)}\n${Nt}`), j(" Generate index file.", "info"), f(E, "---\n" + y.stringify(t));
|
|
1078
|
+
let n = R(O);
|
|
1079
|
+
if (!n.length) throw Error(`No template theme files found at '${O}'. The Vitepress build cannot succeed without them.`);
|
|
1080
|
+
j(" Add Docpress theme files.", "info"), n.forEach((e) => {
|
|
1081
|
+
let t = e.replace(`${O}/`, "");
|
|
1082
|
+
ut(e, v(ae, t));
|
|
1061
1083
|
});
|
|
1062
1084
|
}
|
|
1063
1085
|
//#endregion
|
|
1064
1086
|
//#region src/commands/prepare.ts
|
|
1065
|
-
var
|
|
1087
|
+
var Ft = "prepare", It = [
|
|
1088
|
+
n("--acronyms <string>", K.shape.acronyms.description),
|
|
1066
1089
|
n("-c, --extra-public-content <string>", K.shape.extraPublicContent.description),
|
|
1067
1090
|
n("-f, --forks", K.shape.forks.description),
|
|
1068
1091
|
n("-p, --extra-header-pages <string>", K.shape.extraHeaderPages.description),
|
|
@@ -1072,17 +1095,17 @@ var Pt = "prepare", Ft = [
|
|
|
1072
1095
|
n("-v, --vitepress-config <string>", K.shape.vitepressConfig.description),
|
|
1073
1096
|
n("--website-title <string>", K.shape.websiteTitle.description),
|
|
1074
1097
|
n("--website-tagline <string>", K.shape.websiteTagline.description)
|
|
1075
|
-
],
|
|
1076
|
-
await
|
|
1098
|
+
], Lt = X(t(Ft), [...It, ...Q]).description("Transform doc to the target vitepress format.").action(async (e, t) => {
|
|
1099
|
+
await Rt(J(Ft, Y(t, e)));
|
|
1077
1100
|
});
|
|
1078
|
-
async function
|
|
1079
|
-
let { extraHeaderPages: t, extraPublicContent: n, extraTheme: r, vitepressConfig: i, forks: a, gitProvider: o, lastUpdated: s, sidebarMode: c, sidebarCollapsed: l,
|
|
1080
|
-
|
|
1081
|
-
let
|
|
1082
|
-
|
|
1083
|
-
let
|
|
1084
|
-
for (let e of
|
|
1085
|
-
await
|
|
1101
|
+
async function Rt(e) {
|
|
1102
|
+
let { extraHeaderPages: t, extraPublicContent: n, extraTheme: r, vitepressConfig: i, forks: a, gitProvider: o, lastUpdated: s, sidebarMode: c, sidebarCollapsed: l, acronyms: u, token: d, usernames: f, websiteTitle: p, websiteTagline: h } = e;
|
|
1103
|
+
j("\n-> Start transform files to prepare Vitepress build.", "info");
|
|
1104
|
+
let g = Date.now();
|
|
1105
|
+
L(m(D), { clean: !0 });
|
|
1106
|
+
let _ = [];
|
|
1107
|
+
for (let e of f) try {
|
|
1108
|
+
await mt({
|
|
1086
1109
|
extraHeaderPages: t,
|
|
1087
1110
|
extraPublicContent: n,
|
|
1088
1111
|
extraTheme: r,
|
|
@@ -1092,40 +1115,41 @@ async function Lt(e) {
|
|
|
1092
1115
|
lastUpdated: s,
|
|
1093
1116
|
sidebarMode: c,
|
|
1094
1117
|
sidebarCollapsed: l,
|
|
1095
|
-
|
|
1118
|
+
acronyms: u,
|
|
1119
|
+
token: d,
|
|
1096
1120
|
username: e,
|
|
1097
|
-
websiteTitle:
|
|
1098
|
-
websiteTagline:
|
|
1121
|
+
websiteTitle: p,
|
|
1122
|
+
websiteTagline: h
|
|
1099
1123
|
});
|
|
1100
1124
|
} catch (t) {
|
|
1101
|
-
|
|
1125
|
+
_.push(e), j(` Failed to prepare documentation for '${e}': ${P(t)}`, "error");
|
|
1102
1126
|
}
|
|
1103
|
-
if (
|
|
1104
|
-
|
|
1127
|
+
if (_.length === f.length) throw Error(`Failed to prepare documentation for all requested username(s): ${_.join(", ")}.`);
|
|
1128
|
+
j(` Prepared documentation for ${f.length - _.length}/${f.length} username(s) in ${F(Date.now() - g)}.`, _.length ? "warn" : "success");
|
|
1105
1129
|
}
|
|
1106
1130
|
//#endregion
|
|
1107
1131
|
//#region src/cli.ts
|
|
1108
|
-
function
|
|
1109
|
-
let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${
|
|
1132
|
+
function zt() {
|
|
1133
|
+
let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${ne.version}`).action(async (e, t) => {
|
|
1110
1134
|
let n = J("global", Y(t, e));
|
|
1111
|
-
await
|
|
1135
|
+
await ot(n), await Rt(n), await lt();
|
|
1112
1136
|
}).configureHelp({
|
|
1113
1137
|
sortSubcommands: !0,
|
|
1114
1138
|
sortOptions: !0,
|
|
1115
1139
|
showGlobalOptions: !0
|
|
1116
|
-
}).enablePositionalOptions().passThroughOptions().addCommand(
|
|
1140
|
+
}).enablePositionalOptions().passThroughOptions().addCommand(at).addCommand(Lt).addCommand(ct);
|
|
1117
1141
|
return X(t, [
|
|
1118
|
-
...
|
|
1119
|
-
...
|
|
1142
|
+
...it,
|
|
1143
|
+
...It,
|
|
1120
1144
|
...Q
|
|
1121
1145
|
]), t;
|
|
1122
1146
|
}
|
|
1123
|
-
function
|
|
1124
|
-
|
|
1125
|
-
|
|
1147
|
+
function Bt() {
|
|
1148
|
+
zt().parseAsync(process.argv).catch((e) => {
|
|
1149
|
+
j(`\n${P(e)}`, "error"), process.exit(1);
|
|
1126
1150
|
});
|
|
1127
1151
|
}
|
|
1128
1152
|
//#endregion
|
|
1129
|
-
export {
|
|
1153
|
+
export { zt as getProgram, Bt as main };
|
|
1130
1154
|
|
|
1131
1155
|
//# sourceMappingURL=cli.js.map
|