@tobi-or-not/docpress 0.8.0 → 0.8.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/dist/cli.js +117 -114
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOption as m, createCommand as J, Command as Pe } from "commander";
|
|
2
|
-
import { readFileSync as
|
|
2
|
+
import { readFileSync as S, existsSync as O, mkdirSync as ke, writeFileSync as v, readdirSync as ue, statSync as z, appendFileSync as le, cpSync as B, rmSync as Z, renameSync as Ee } from "node:fs";
|
|
3
3
|
import { resolve as u, basename as y, join as Fe, dirname as _, parse as R } from "node:path";
|
|
4
4
|
import Te from "axios";
|
|
5
5
|
import { rimrafSync as Oe } from "rimraf";
|
|
@@ -9,14 +9,15 @@ import { z as l } from "zod";
|
|
|
9
9
|
import { Octokit as de } from "@octokit/rest";
|
|
10
10
|
import { simpleGit as _e } from "simple-git";
|
|
11
11
|
import { build as Ae } from "vitepress";
|
|
12
|
-
import {
|
|
12
|
+
import { withMermaid as Ie } from "vitepress-plugin-mermaid";
|
|
13
|
+
import { readFile as je } from "node:fs/promises";
|
|
13
14
|
import q from "yaml";
|
|
14
|
-
const
|
|
15
|
-
version:
|
|
16
|
-
},
|
|
15
|
+
const Le = "0.8.1", Ve = {
|
|
16
|
+
version: Le
|
|
17
|
+
}, C = u(process.cwd(), "docpress");
|
|
17
18
|
u(process.cwd(), "docpress/repositories.json");
|
|
18
19
|
u(process.cwd(), "docpress/owner.json");
|
|
19
|
-
const pe = u(process.cwd(), "docpress/docs"),
|
|
20
|
+
const pe = u(process.cwd(), "docpress/docs"), M = u(process.cwd(), "docpress/docs/index.md"), Ne = u(process.cwd(), "docpress/docs/forks.md"), E = u(process.cwd(), "docpress/.vitepress/config.ts"), De = u(process.cwd(), "docpress/.vitepress/theme"), Ge = u(process.cwd(), "docpress/.vitepress/theme/extras"), te = process.env.NODE_ENV === "development" ? u(import.meta.dirname, "../../public/templates/theme") : u(import.meta.dirname, "./templates/theme"), He = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, Me = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, Ue = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, We = /^\d{2}-/;
|
|
20
21
|
async function G(e) {
|
|
21
22
|
try {
|
|
22
23
|
return (await Te.head(e)).status;
|
|
@@ -26,7 +27,7 @@ async function G(e) {
|
|
|
26
27
|
}
|
|
27
28
|
function f(e, t) {
|
|
28
29
|
let r = "";
|
|
29
|
-
return t?.removeDot && (e.startsWith(".") ? r = e.slice(1) : r = e, r = r.replaceAll(".", "-")), t?.removeIdx && (r = (r || e).replace(
|
|
30
|
+
return t?.removeDot && (e.startsWith(".") ? r = e.slice(1) : r = e, r = r.replaceAll(".", "-")), t?.removeIdx && (r = (r || e).replace(We, "")), t?.removeExt && (r = (r || e).split(".")[0]), t?.replaceDash && (r = (r || e).replaceAll("-", " ")), t?.mode === "capitalize" ? r = (r || e).slice(0, 1).toUpperCase() + (r || e).slice(1).toLowerCase() : t?.mode === "lowercase" ? r = (r || e).toLowerCase() : t?.mode === "uppercase" && (r = (r || e).toUpperCase()), r || e;
|
|
30
31
|
}
|
|
31
32
|
function F(e, { clean: t } = { clean: !1 }) {
|
|
32
33
|
try {
|
|
@@ -35,14 +36,14 @@ function F(e, { clean: t } = { clean: !1 }) {
|
|
|
35
36
|
console.error(r);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function Je(e) {
|
|
39
40
|
try {
|
|
40
41
|
return z(e).isDirectory();
|
|
41
42
|
} catch {
|
|
42
43
|
return !1;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function ze(e) {
|
|
46
47
|
try {
|
|
47
48
|
return z(e).isFile();
|
|
48
49
|
} catch {
|
|
@@ -50,19 +51,19 @@ function Je(e) {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
function A(e) {
|
|
53
|
-
return (Array.isArray(e) ? e : [e]).flatMap((t) =>
|
|
54
|
+
return (Array.isArray(e) ? e : [e]).flatMap((t) => ze(t) ? [t] : Je(t) ? ue(t).flatMap((r) => A(Fe(t, r))) : []);
|
|
54
55
|
}
|
|
55
56
|
function fe(e) {
|
|
56
57
|
return A(e).filter((t) => y(t).endsWith(".md"));
|
|
57
58
|
}
|
|
58
|
-
function ze(e) {
|
|
59
|
-
return e.reduce((t, r, o, s) => o ? o === s.length - 1 ? `${t} or "${r}"` : `${t}, "${r}"` : `"${r}"`, "");
|
|
60
|
-
}
|
|
61
59
|
function Be(e) {
|
|
62
|
-
return
|
|
60
|
+
return e.reduce((t, r, o, s) => o ? o === s.length - 1 ? `${t} or "${r}"` : `${t}, "${r}"` : `"${r}"`, "");
|
|
63
61
|
}
|
|
64
62
|
function qe(e) {
|
|
65
|
-
return JSON.parse(
|
|
63
|
+
return JSON.parse(S(`${C}/user-${e}.json`).toString());
|
|
64
|
+
}
|
|
65
|
+
function Ke(e) {
|
|
66
|
+
return JSON.parse(S(`${C}/repos-${e}.json`).toString());
|
|
66
67
|
}
|
|
67
68
|
function U(...e) {
|
|
68
69
|
return e.reduce((t, r) => (r === null || Object.keys(r).forEach((o) => {
|
|
@@ -77,7 +78,7 @@ function W(e) {
|
|
|
77
78
|
if (!e)
|
|
78
79
|
return {};
|
|
79
80
|
try {
|
|
80
|
-
const t = u(process.cwd(), e), r =
|
|
81
|
+
const t = u(process.cwd(), e), r = S(t, "utf8");
|
|
81
82
|
return JSON.parse(r);
|
|
82
83
|
} catch {
|
|
83
84
|
return {};
|
|
@@ -86,15 +87,15 @@ function W(e) {
|
|
|
86
87
|
function k(e) {
|
|
87
88
|
return e.split(",");
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
-
const o =
|
|
90
|
+
function Xe(e, t) {
|
|
91
|
+
const o = S(e, "utf8").replace(He, (s, i, n) => `[${i}](${t}/${n})`);
|
|
91
92
|
v(e, o, "utf8");
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
-
const o =
|
|
94
|
+
function Ye(e, t) {
|
|
95
|
+
const o = S(e, "utf8").replace(Me, (s, i, n, c) => `[${i}](${t}/${c})`).replace(Ue, (s, i, n, c) => `[${i}](${c})`);
|
|
95
96
|
v(e, o, "utf8");
|
|
96
97
|
}
|
|
97
|
-
function
|
|
98
|
+
function Qe() {
|
|
98
99
|
return typeof Number(process.env.LOG_LEVEL) == "number" && !Number.isNaN(Number(process.env.LOG_LEVEL)) ? Number(process.env.LOG_LEVEL) : 30;
|
|
99
100
|
}
|
|
100
101
|
const oe = {
|
|
@@ -107,14 +108,14 @@ const oe = {
|
|
|
107
108
|
};
|
|
108
109
|
function a(e, t = "info", r) {
|
|
109
110
|
const o = r ? ee[r](e) : ee[oe[t].color](e), s = t === "success" ? "info" : t;
|
|
110
|
-
|
|
111
|
+
Qe() >= oe[t].level && console[s](o);
|
|
111
112
|
}
|
|
112
113
|
const se = ["github"], d = l.object({
|
|
113
114
|
// Global
|
|
114
115
|
usernames: l.string().array().describe("List of comma separated Git provider usernames used to collect data."),
|
|
115
116
|
// Fetch
|
|
116
117
|
branch: l.string().describe("Branch used to collect Git provider data.").default("main"),
|
|
117
|
-
gitProvider: l.enum(se).describe(`Git provider used to retrieve data. Values should be ${
|
|
118
|
+
gitProvider: l.enum(se).describe(`Git provider used to retrieve data. Values should be ${Be(se)}.`).default("github"),
|
|
118
119
|
reposFilter: l.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
|
|
119
120
|
// Prepare
|
|
120
121
|
extraHeaderPages: l.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
@@ -124,7 +125,7 @@ const se = ["github"], d = l.object({
|
|
|
124
125
|
vitepressConfig: l.any().describe("Path to the vitepress configuration file."),
|
|
125
126
|
websiteTitle: l.string().describe("Website title."),
|
|
126
127
|
websiteTagline: l.string().describe("Website tagline.")
|
|
127
|
-
}),
|
|
128
|
+
}), H = d.partial().extend({
|
|
128
129
|
config: l.string().describe("Path to the docpress configuration file.").optional(),
|
|
129
130
|
token: l.string().describe("Git provider token used to collect data.").optional(),
|
|
130
131
|
usernames: l.string().describe(d.shape.usernames.description || "").optional(),
|
|
@@ -143,19 +144,19 @@ const se = ["github"], d = l.object({
|
|
|
143
144
|
extraTheme: l.string().describe(d.shape.extraTheme.description || "").transform(k).optional(),
|
|
144
145
|
vitepressConfig: l.string().describe(d.shape.vitepressConfig.description || "").optional()
|
|
145
146
|
});
|
|
146
|
-
function
|
|
147
|
+
function Ze(e) {
|
|
147
148
|
return e ? (e.usernames && typeof e.usernames == "string" && (e.usernames = [e.usernames]), e.reposFilter && typeof e.reposFilter == "string" && (e.reposFilter = [e.reposFilter]), e.extraHeaderPages && typeof e.extraHeaderPages == "string" && (e.extraHeaderPages = [e.extraHeaderPages]), e.extraPublicContent && typeof e.extraPublicContent == "string" && (e.extraPublicContent = [e.extraPublicContent]), e.extraTheme && typeof e.extraTheme == "string" && (e.extraTheme = [e.extraTheme]), e) : {};
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function et(e) {
|
|
150
151
|
if (!e.usernames?.length)
|
|
151
152
|
throw new Error("The usernames field is required");
|
|
152
153
|
return e;
|
|
153
154
|
}
|
|
154
|
-
const
|
|
155
|
+
const tt = I.partial().transform((e) => {
|
|
155
156
|
try {
|
|
156
157
|
const { config: t, vitepressConfig: r, token: o, ...s } = e;
|
|
157
158
|
a(`Debug: Schema transform input: ${JSON.stringify(e)}`, "debug");
|
|
158
|
-
const i = W(t), n =
|
|
159
|
+
const i = W(t), n = Ze(i), c = {
|
|
159
160
|
forks: !1,
|
|
160
161
|
...n,
|
|
161
162
|
...s,
|
|
@@ -166,18 +167,18 @@ const et = I.partial().transform((e) => {
|
|
|
166
167
|
}
|
|
167
168
|
} : {}
|
|
168
169
|
};
|
|
169
|
-
return a(`Debug: Final merged config: ${JSON.stringify(c)}`, "debug"),
|
|
170
|
+
return a(`Debug: Final merged config: ${JSON.stringify(c)}`, "debug"), et({ ...c, token: o });
|
|
170
171
|
} catch (t) {
|
|
171
172
|
a(" An error occurred while checking configuration.", "error"), t instanceof Error ? a(` ${t.message}`, "error") : a(` ${JSON.stringify(t, null, 2)}`, "error"), process.exit(1);
|
|
172
173
|
}
|
|
173
|
-
}),
|
|
174
|
+
}), rt = I.pick({}), ot = I.pick({
|
|
174
175
|
branch: !0,
|
|
175
176
|
config: !0,
|
|
176
177
|
gitProvider: !0,
|
|
177
178
|
reposFilter: !0,
|
|
178
179
|
token: !0,
|
|
179
180
|
usernames: !0
|
|
180
|
-
}),
|
|
181
|
+
}), st = I.pick({
|
|
181
182
|
extraHeaderPages: !0,
|
|
182
183
|
extraPublicContent: !0,
|
|
183
184
|
extraTheme: !0,
|
|
@@ -187,13 +188,13 @@ const et = I.partial().transform((e) => {
|
|
|
187
188
|
token: !0,
|
|
188
189
|
usernames: !0,
|
|
189
190
|
vitepressConfig: !0
|
|
190
|
-
}),
|
|
191
|
-
build:
|
|
192
|
-
fetch:
|
|
193
|
-
prepare:
|
|
194
|
-
global:
|
|
191
|
+
}), nt = {
|
|
192
|
+
build: rt,
|
|
193
|
+
fetch: ot,
|
|
194
|
+
prepare: st,
|
|
195
|
+
global: tt
|
|
195
196
|
};
|
|
196
|
-
function
|
|
197
|
+
function it(e, t) {
|
|
197
198
|
const r = W(e);
|
|
198
199
|
if (!r) return null;
|
|
199
200
|
const o = d.partial().safeParse(r);
|
|
@@ -209,14 +210,14 @@ function K(e, t) {
|
|
|
209
210
|
-> Checking for required environment settings and configurations.`, "info"), a(` Debug info - opts: ${JSON.stringify(t)}`, "debug"), a(` Debug info - options[cmd]: ${e}`, "debug");
|
|
210
211
|
try {
|
|
211
212
|
if (e === "global" && typeof t.config == "string") {
|
|
212
|
-
const o =
|
|
213
|
+
const o = it(
|
|
213
214
|
t.config,
|
|
214
215
|
typeof t.token == "string" ? t.token : void 0
|
|
215
216
|
);
|
|
216
217
|
if (o)
|
|
217
218
|
return o;
|
|
218
219
|
}
|
|
219
|
-
const r =
|
|
220
|
+
const r = nt[e].safeParse(t);
|
|
220
221
|
if (!r.success) {
|
|
221
222
|
try {
|
|
222
223
|
const o = Re(r.error).toString();
|
|
@@ -238,7 +239,7 @@ function j(e, t) {
|
|
|
238
239
|
e.addOption(r);
|
|
239
240
|
return e;
|
|
240
241
|
}
|
|
241
|
-
async function
|
|
242
|
+
async function at({ username: e, token: t, branch: r }) {
|
|
242
243
|
a(` Get infos for username '${e}'.`, "info");
|
|
243
244
|
const o = new de({ auth: t });
|
|
244
245
|
a(" Get user infos.", "debug");
|
|
@@ -247,7 +248,7 @@ async function it({ username: e, token: t, branch: r }) {
|
|
|
247
248
|
const { data: i } = await o.rest.repos.listForUser({ username: e, sort: "full_name", per_page: 500 });
|
|
248
249
|
return { user: s, repos: i, branch: r };
|
|
249
250
|
}
|
|
250
|
-
async function
|
|
251
|
+
async function ct({
|
|
251
252
|
repository: e,
|
|
252
253
|
token: t
|
|
253
254
|
}) {
|
|
@@ -291,7 +292,7 @@ async function at({
|
|
|
291
292
|
}
|
|
292
293
|
return { source: o.source, contributors: s };
|
|
293
294
|
}
|
|
294
|
-
async function
|
|
295
|
+
async function ut(e, t, r, o, s) {
|
|
295
296
|
F(r, { clean: !0 });
|
|
296
297
|
try {
|
|
297
298
|
const i = _e({ baseDir: r });
|
|
@@ -304,7 +305,7 @@ async function ct(e, t, r, o, s) {
|
|
|
304
305
|
a(` Error when cloning repository: ${i}.`, "error");
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
|
-
async function
|
|
308
|
+
async function lt(e, t, r) {
|
|
308
309
|
const o = `https://github.com/${e}/${t}/tree/${r}/README.md`, s = `https://github.com/${e}/${t}/tree/${r}/docs`, i = `https://github.com/${e}/${t}/tree/${r}/docs/01-readme.md`, n = await G(o), c = await G(s), p = await G(i);
|
|
309
310
|
return {
|
|
310
311
|
rootReadmeStatus: n,
|
|
@@ -312,16 +313,16 @@ async function ut(e, t, r) {
|
|
|
312
313
|
docsReadmeStatus: p
|
|
313
314
|
};
|
|
314
315
|
}
|
|
315
|
-
async function
|
|
316
|
-
await
|
|
316
|
+
async function dt({ username: e, branch: t, reposFilter: r, token: o }) {
|
|
317
|
+
await at({ username: e, token: o, branch: t }).then(async ({ user: s, repos: i, branch: n }) => mt(s, i, n, r)).then(async ({ repos: s }) => gt(s, r));
|
|
317
318
|
}
|
|
318
|
-
async function
|
|
319
|
+
async function pt(e, t, r) {
|
|
319
320
|
const o = [];
|
|
320
321
|
return await Promise.all(
|
|
321
322
|
e.map(async (s) => {
|
|
322
323
|
const i = t ?? s.default_branch ?? "main", n = u(pe, f(s.name, { removeDot: !0 })), c = me(s, r);
|
|
323
324
|
let p = [];
|
|
324
|
-
!s.fork && !s.private && !c && (p = await
|
|
325
|
+
!s.fork && !s.private && !c && (p = await ft(s, i)), o.push({
|
|
325
326
|
...s,
|
|
326
327
|
docpress: {
|
|
327
328
|
filtered: c,
|
|
@@ -335,23 +336,23 @@ async function dt(e, t, r) {
|
|
|
335
336
|
})
|
|
336
337
|
), o;
|
|
337
338
|
}
|
|
338
|
-
async function
|
|
339
|
-
const r = await
|
|
339
|
+
async function ft(e, t) {
|
|
340
|
+
const r = await lt(e.owner.login, e.name, t), o = [];
|
|
340
341
|
return Object.values(r).every((s) => s === 404) || !e.size ? [] : (r.docsFolderStatus !== 404 && o.push("docs/*"), (r.docsFolderStatus === 404 || r.docsReadmeStatus === 404) && o.push("README.md", "!*/**/README.md"), o);
|
|
341
342
|
}
|
|
342
|
-
async function
|
|
343
|
-
v(`${
|
|
344
|
-
const s = await
|
|
345
|
-
return v(`${
|
|
343
|
+
async function mt(e, t, r, o) {
|
|
344
|
+
v(`${C}/user-${e.login}.json`, JSON.stringify(e, null, 2));
|
|
345
|
+
const s = await pt(t, r, o);
|
|
346
|
+
return v(`${C}/repos-${e.login}.json`, JSON.stringify(s, null, 2)), { user: e, repos: s };
|
|
346
347
|
}
|
|
347
|
-
async function
|
|
348
|
+
async function gt(e, t) {
|
|
348
349
|
if (!e) {
|
|
349
350
|
a(" No repository respect docpress rules.", "warn");
|
|
350
351
|
return;
|
|
351
352
|
}
|
|
352
353
|
await Promise.all(
|
|
353
354
|
e.filter((r) => !me(r, t)).map(async (r) => {
|
|
354
|
-
await
|
|
355
|
+
await ut(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
|
|
355
356
|
})
|
|
356
357
|
);
|
|
357
358
|
}
|
|
@@ -360,27 +361,27 @@ function me(e, t) {
|
|
|
360
361
|
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !i);
|
|
361
362
|
}
|
|
362
363
|
const L = [
|
|
363
|
-
m("-C, --config <string>",
|
|
364
|
-
m("-T, --token <string>",
|
|
365
|
-
m("-U, --usernames <string>",
|
|
364
|
+
m("-C, --config <string>", H.shape.config.description),
|
|
365
|
+
m("-T, --token <string>", H.shape.token.description),
|
|
366
|
+
m("-U, --usernames <string>", H.shape.usernames.description)
|
|
366
367
|
], ne = "fetch", ge = [
|
|
367
368
|
m("-b, --branch <string>", d.shape.branch.description).default(d.shape.branch.default),
|
|
368
369
|
m("-g, --git-provider <string>", d.shape.gitProvider.description).default(d.shape.gitProvider.default),
|
|
369
370
|
m("-r, --repos-filter <string>", d.shape.reposFilter.description)
|
|
370
|
-
],
|
|
371
|
+
], ht = j(J(ne), [...ge, ...L]).description("Fetch docs with the given username(s) and git provider.").action(async (e) => {
|
|
371
372
|
const t = K(ne, e);
|
|
372
373
|
await he(t);
|
|
373
374
|
});
|
|
374
375
|
async function he(e) {
|
|
375
376
|
const { usernames: t, reposFilter: r, token: o, branch: s, gitProvider: i } = e;
|
|
376
377
|
a(`
|
|
377
|
-
-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"), F(
|
|
378
|
+
-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"), F(C, { clean: !0 });
|
|
378
379
|
for (const n of t) {
|
|
379
380
|
const c = t.length > 1 ? r?.filter((p) => p.startsWith(`${n}/`)).map((p) => p.replace(`${n}/`, "")) : r;
|
|
380
|
-
await
|
|
381
|
+
await dt({ username: n, branch: s, reposFilter: c, token: o });
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
|
-
async function
|
|
384
|
+
async function bt(e) {
|
|
384
385
|
const t = console.warn;
|
|
385
386
|
console.warn = function(...r) {
|
|
386
387
|
r.length > 0 && typeof r[0] == "string" && (r[0].includes("[Vue warn]: Invalid watch source:") || r[0].includes("{ open: false }")) || t.apply(console, r);
|
|
@@ -391,7 +392,7 @@ async function ht(e) {
|
|
|
391
392
|
console.warn = t;
|
|
392
393
|
}
|
|
393
394
|
}
|
|
394
|
-
const
|
|
395
|
+
const wt = "build", yt = j(J(wt), L).description("Build vitepress website.").action(async (e) => {
|
|
395
396
|
await be();
|
|
396
397
|
});
|
|
397
398
|
async function be() {
|
|
@@ -400,8 +401,12 @@ async function be() {
|
|
|
400
401
|
|
|
401
402
|
`, "info");
|
|
402
403
|
try {
|
|
403
|
-
await
|
|
404
|
-
await Ae(
|
|
404
|
+
await bt(async () => {
|
|
405
|
+
await Ae(C, {
|
|
406
|
+
onAfterConfigResolve(e) {
|
|
407
|
+
Ie(e);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
405
410
|
}), a(`
|
|
406
411
|
|
|
407
412
|
Docpress build succedeed.`, "success");
|
|
@@ -411,8 +416,8 @@ Docpress build succedeed.`, "success");
|
|
|
411
416
|
Docpress build failed : ${e}`, "error"), process.exit(1);
|
|
412
417
|
}
|
|
413
418
|
}
|
|
414
|
-
function
|
|
415
|
-
const r =
|
|
419
|
+
function vt(e, t) {
|
|
420
|
+
const r = S(e, { encoding: "utf8" });
|
|
416
421
|
F(_(t)), v(t, r);
|
|
417
422
|
}
|
|
418
423
|
const ie = {
|
|
@@ -452,23 +457,23 @@ const ie = {
|
|
|
452
457
|
}
|
|
453
458
|
}
|
|
454
459
|
};
|
|
455
|
-
function
|
|
460
|
+
function $t(e, t, r) {
|
|
456
461
|
return r ? U(ie, r, { themeConfig: { sidebar: e, nav: t } }) : U(ie, { themeConfig: { sidebar: e, nav: t } });
|
|
457
462
|
}
|
|
458
|
-
async function
|
|
459
|
-
const h =
|
|
460
|
-
const { clone_url: P, private:
|
|
461
|
-
if (P && !
|
|
463
|
+
async function xt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: r, vitepressConfig: o, forks: s, token: i, username: n, websiteTitle: c, websiteTagline: p }) {
|
|
464
|
+
const h = qe(n), b = Ke(n).reduce(({ internals: w, forks: $ }, x) => {
|
|
465
|
+
const { clone_url: P, private: Se, fork: Y, docpress: Q } = x;
|
|
466
|
+
if (P && !Se && !Q.filtered) {
|
|
462
467
|
if (!Y && Q.includes.length)
|
|
463
468
|
return { internals: [...w, x], forks: $ };
|
|
464
469
|
if (Y)
|
|
465
470
|
return { internals: w, forks: [...$, x] };
|
|
466
471
|
}
|
|
467
472
|
return { internals: w, forks: $ };
|
|
468
|
-
}, { internals: [], forks: [] }), g = { title: c, tagline: p }, { index: V, sidebar: X } =
|
|
473
|
+
}, { internals: [], forks: [] }), g = { title: c, tagline: p }, { index: V, sidebar: X } = Ft(b.internals, h, g);
|
|
469
474
|
let N, D;
|
|
470
|
-
if (O(
|
|
471
|
-
const w = await
|
|
475
|
+
if (O(M) && O(E)) {
|
|
476
|
+
const w = await _t(E), $ = await At(M);
|
|
472
477
|
N = [
|
|
473
478
|
...w.themeConfig?.sidebar ?? [],
|
|
474
479
|
...X
|
|
@@ -483,14 +488,14 @@ async function $t({ extraHeaderPages: e, extraPublicContent: t, extraTheme: r, v
|
|
|
483
488
|
N = X, D = V;
|
|
484
489
|
const T = [];
|
|
485
490
|
if (e) {
|
|
486
|
-
const w =
|
|
491
|
+
const w = Tt(e);
|
|
487
492
|
s ? T.push(...w.filter(($) => $.link !== "/forks")) : T.push(...w);
|
|
488
493
|
}
|
|
489
|
-
t && (a(" Add extras Vitepress public folder content.", "info"), ae(t, u(
|
|
490
|
-
const
|
|
491
|
-
|
|
494
|
+
t && (a(" Add extras Vitepress public folder content.", "info"), ae(t, u(C, "public"))), r && (a(" Add extras Vitepress theme files.", "info"), ae(r, u(Ge))), s && n.length && (a(" Add fork page to display external contributions.", "info"), await Rt(b.forks, n, i), T.push({ text: "Forks", link: "/forks" }));
|
|
495
|
+
const Ce = $t(N, T, o);
|
|
496
|
+
It(Ce, D);
|
|
492
497
|
}
|
|
493
|
-
function
|
|
498
|
+
function Ct(e, t) {
|
|
494
499
|
const r = y(t), s = `${f(r, { mode: "lowercase", removeIdx: !0 }) === "readme.md" ? `
|
|
495
500
|
## Sources` : "# Sources"}
|
|
496
501
|
|
|
@@ -506,7 +511,7 @@ function St(e, t, r) {
|
|
|
506
511
|
features: e
|
|
507
512
|
};
|
|
508
513
|
}
|
|
509
|
-
function
|
|
514
|
+
function Pt(e, t, r) {
|
|
510
515
|
const o = {
|
|
511
516
|
title: f(e, { mode: "capitalize", replaceDash: !0 }),
|
|
512
517
|
details: t,
|
|
@@ -514,7 +519,7 @@ function Ct(e, t, r) {
|
|
|
514
519
|
};
|
|
515
520
|
return r ? [...r, o] : [o];
|
|
516
521
|
}
|
|
517
|
-
function
|
|
522
|
+
function kt(e, t) {
|
|
518
523
|
return {
|
|
519
524
|
text: f(e, { mode: "capitalize", replaceDash: !0 }),
|
|
520
525
|
collapsed: !0,
|
|
@@ -547,7 +552,7 @@ function ye(e) {
|
|
|
547
552
|
function ve(e, t = "") {
|
|
548
553
|
return Object.entries(e).flatMap(([r, o]) => r === "$" ? Array.isArray(o) ? o.map((s) => t ? `${t}/${s}` : s) : [] : ve(o, t ? `${t}/${r}` : r));
|
|
549
554
|
}
|
|
550
|
-
function
|
|
555
|
+
function Et(e) {
|
|
551
556
|
if (!Array.isArray(e))
|
|
552
557
|
return e;
|
|
553
558
|
const t = e.findIndex((o) => o.text === "Sources");
|
|
@@ -556,18 +561,18 @@ function kt(e) {
|
|
|
556
561
|
const [r] = e.splice(t, 1);
|
|
557
562
|
return e.push(r), e;
|
|
558
563
|
}
|
|
559
|
-
function
|
|
564
|
+
function Ft(e, t, r) {
|
|
560
565
|
const o = [], s = [];
|
|
561
566
|
for (const n of e) {
|
|
562
567
|
a(` Replace urls for repository '${n.name}'.`, "info"), fe([n.docpress.projectPath]).forEach((g) => {
|
|
563
|
-
a(` Processing file '${y(g)}' for repository '${n.name}'.`, "debug"),
|
|
568
|
+
a(` Processing file '${y(g)}' for repository '${n.name}'.`, "debug"), Xe(g, `https://github.com/${n.owner.login}/${n.name}/tree/${n.docpress.branch}`), y(g).toLowerCase() === "readme.md" && Ye(g, `https://github.com/${n.owner.login}/${n.name}/tree/${n.docpress.branch}`);
|
|
564
569
|
}), a(` Generate sidebar for repository '${n.name}'.`, "info");
|
|
565
570
|
const c = ue(n.docpress.projectPath, { recursive: !0 }).filter((g) => z(u(n.docpress.projectPath, g.toString())).isFile() && y(u(n.docpress.projectPath, g.toString())).endsWith(".md"));
|
|
566
571
|
a(` Add sources for repository '${n.name}'.`, "info");
|
|
567
572
|
let p;
|
|
568
|
-
c.length > 1 ? (p = u(n.docpress.projectPath, "sources.md"), c.push("sources.md")) : p = u(n.docpress.projectPath, c[0]),
|
|
569
|
-
const h = ye(c), b =
|
|
570
|
-
s.push(
|
|
573
|
+
c.length > 1 ? (p = u(n.docpress.projectPath, "sources.md"), c.push("sources.md")) : p = u(n.docpress.projectPath, c[0]), Ct(n.html_url, p);
|
|
574
|
+
const h = ye(c), b = Et(we(n, h));
|
|
575
|
+
s.push(kt(f(n.name, { removeDot: !0 }), b)), o.push(...Pt(f(n.name, { removeDot: !0 }), n.description || ""));
|
|
571
576
|
}
|
|
572
577
|
a(" Generate index content.", "info");
|
|
573
578
|
const i = St(o.toSorted((n, c) => n.title.localeCompare(c.title)), t, r);
|
|
@@ -576,7 +581,7 @@ function Et(e, t, r) {
|
|
|
576
581
|
index: i
|
|
577
582
|
};
|
|
578
583
|
}
|
|
579
|
-
function
|
|
584
|
+
function Tt(e) {
|
|
580
585
|
const t = fe(e), r = [];
|
|
581
586
|
a(" Add extras Vitepress headers pages.", "info");
|
|
582
587
|
for (const o of t) {
|
|
@@ -600,7 +605,7 @@ function ae(e, t, r) {
|
|
|
600
605
|
}
|
|
601
606
|
}
|
|
602
607
|
}
|
|
603
|
-
function
|
|
608
|
+
function Ot(e) {
|
|
604
609
|
const t = `---
|
|
605
610
|
`, r = `layout: fork-page
|
|
606
611
|
repoList:
|
|
@@ -616,39 +621,37 @@ This page serves as both a portfolio of past work and a resource for revisiting
|
|
|
616
621
|
const { name: c, owner: p, html_url: h, description: b, stargazers_count: g } = i;
|
|
617
622
|
return { name: c, owner: p.login, html_url: h, description: b, stargazers_count: g, contributions: n };
|
|
618
623
|
});
|
|
619
|
-
a(" Generate forks page.", "info"), v(
|
|
624
|
+
a(" Generate forks page.", "info"), v(Ne, t + r + q.stringify(s) + t + o);
|
|
620
625
|
}
|
|
621
|
-
async function
|
|
626
|
+
async function Rt(e, t, r) {
|
|
622
627
|
const o = await Promise.all(
|
|
623
628
|
e.map(async (s) => {
|
|
624
|
-
const { source: i, contributors: n } = await
|
|
629
|
+
const { source: i, contributors: n } = await ct({ repository: s, token: r });
|
|
625
630
|
return {
|
|
626
631
|
contributions: n?.find((c) => c.login === t)?.contributions ?? 0,
|
|
627
632
|
repository: i
|
|
628
633
|
};
|
|
629
634
|
})
|
|
630
635
|
).then((s) => s.filter(({ repository: i, contributions: n }) => !!i && n));
|
|
631
|
-
|
|
636
|
+
Ot(o);
|
|
632
637
|
}
|
|
633
|
-
async function
|
|
638
|
+
async function _t(e) {
|
|
634
639
|
const { config: t } = await import(u(process.cwd(), e)).catch((r) => r);
|
|
635
640
|
return t;
|
|
636
641
|
}
|
|
637
|
-
async function
|
|
638
|
-
const t = (await
|
|
642
|
+
async function At(e) {
|
|
643
|
+
const t = (await je(u(process.cwd(), e))).toString();
|
|
639
644
|
return q.parse(t);
|
|
640
645
|
}
|
|
641
|
-
function
|
|
646
|
+
function It(e, t) {
|
|
642
647
|
const r = `---
|
|
643
648
|
`;
|
|
644
|
-
return F(_(E)), a(" Generate Vitepress config.", "info"), v(E, `
|
|
645
|
-
|
|
646
|
-
export const config = withMermaid(${JSON.stringify(e, null, 2)})
|
|
649
|
+
return F(_(E)), a(" Generate Vitepress config.", "info"), v(E, `export const config = ${JSON.stringify(e, null, 2)}
|
|
647
650
|
|
|
648
651
|
export default config
|
|
649
|
-
`), a(" Generate index file.", "info"), v(
|
|
652
|
+
`), a(" Generate index file.", "info"), v(M, r + q.stringify(t)), a(" Add Docpress theme files.", "info"), A(te).forEach((o) => {
|
|
650
653
|
const s = o.replace(`${te}/`, "");
|
|
651
|
-
|
|
654
|
+
vt(o, u(De, s));
|
|
652
655
|
});
|
|
653
656
|
}
|
|
654
657
|
const ce = "prepare", $e = [
|
|
@@ -659,7 +662,7 @@ const ce = "prepare", $e = [
|
|
|
659
662
|
m("-v, --vitepress-config <string>", d.shape.vitepressConfig.description),
|
|
660
663
|
m("--website-title <string>", d.shape.websiteTitle.description),
|
|
661
664
|
m("--website-tagline <string>", d.shape.websiteTagline.description)
|
|
662
|
-
],
|
|
665
|
+
], jt = j(J(ce), [...$e, ...L]).description("Transform doc to the target vitepress format.").action(async (e) => {
|
|
663
666
|
const t = K(ce, e);
|
|
664
667
|
await xe(t);
|
|
665
668
|
});
|
|
@@ -668,31 +671,31 @@ async function xe(e) {
|
|
|
668
671
|
a(`
|
|
669
672
|
-> Start transform files to prepare Vitepress build.`, "info"), F(_(E), { clean: !0 });
|
|
670
673
|
for (const b of c)
|
|
671
|
-
await
|
|
674
|
+
await xt({ extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: s, forks: i, token: n, username: b, websiteTitle: p, websiteTagline: h });
|
|
672
675
|
}
|
|
673
|
-
function
|
|
676
|
+
function Lt(e) {
|
|
674
677
|
return {
|
|
675
678
|
...e,
|
|
676
679
|
branch: "main",
|
|
677
680
|
gitProvider: "github"
|
|
678
681
|
};
|
|
679
682
|
}
|
|
680
|
-
function
|
|
681
|
-
const e = new Pe().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${
|
|
682
|
-
const o =
|
|
683
|
+
function Vt() {
|
|
684
|
+
const e = new Pe().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${Ve.version}`).action(async (t, r) => {
|
|
685
|
+
const o = Lt(t), s = K("global", o);
|
|
683
686
|
await he(s), await xe(s), await be();
|
|
684
687
|
}).configureHelp({
|
|
685
688
|
sortSubcommands: !0,
|
|
686
689
|
sortOptions: !0,
|
|
687
690
|
showGlobalOptions: !0
|
|
688
|
-
}).enablePositionalOptions().passThroughOptions().addCommand(
|
|
691
|
+
}).enablePositionalOptions().passThroughOptions().addCommand(ht).addCommand(jt).addCommand(yt);
|
|
689
692
|
return j(e, [...ge, ...$e, ...L]), e;
|
|
690
693
|
}
|
|
691
|
-
function
|
|
692
|
-
|
|
694
|
+
function Qt() {
|
|
695
|
+
Vt().parseAsync(process.argv);
|
|
693
696
|
}
|
|
694
697
|
export {
|
|
695
|
-
|
|
696
|
-
|
|
698
|
+
Vt as getProgram,
|
|
699
|
+
Qt as main
|
|
697
700
|
};
|
|
698
701
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../src/utils/const.ts","../src/utils/regex.ts","../src/utils/functions.ts","../src/utils/logger.ts","../src/schemas/global.ts","../src/schemas/build.ts","../src/schemas/fetch.ts","../src/schemas/prepare.ts","../src/utils/commands.ts","../src/lib/git.ts","../src/lib/fetch.ts","../src/commands/global.ts","../src/commands/fetch.ts","../src/commands/build.ts","../src/utils/templates.ts","../src/lib/vitepress.ts","../src/lib/prepare.ts","../src/commands/prepare.ts","../src/cli.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\n/**\n * Main directory for DocPress files\n */\nexport const DOCPRESS_DIR = resolve(process.cwd(), 'docpress')\n\n/**\n * Path to repositories information JSON file\n */\nexport const USER_REPOS_INFOS = resolve(process.cwd(), 'docpress/repositories.json')\n\n/**\n * Path to user information JSON file\n */\nexport const USER_INFOS = resolve(process.cwd(), 'docpress/owner.json')\n\n/**\n * Directory for documentation files\n */\nexport const DOCS_DIR = resolve(process.cwd(), 'docpress/docs')\n\n/**\n * Path to the main index file\n */\nexport const INDEX_FILE = resolve(process.cwd(), 'docpress/docs/index.md')\n\n/**\n * Path to the forks documentation file\n */\nexport const FORKS_FILE = resolve(process.cwd(), 'docpress/docs/forks.md')\n\n/**\n * Path to VitePress configuration file\n */\nexport const VITEPRESS_CONFIG = resolve(process.cwd(), 'docpress/.vitepress/config.ts')\n\n/**\n * Directory for VitePress theme\n */\nexport const VITEPRESS_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme')\n\n/**\n * Directory for user custom theme files\n */\nexport const VITEPRESS_USER_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme/extras')\n\n/**\n * Path to template theme files\n */\n// eslint-disable-next-line dot-notation\nexport const TEMPLATE_THEME = process.env['NODE_ENV'] === 'development'\n ? resolve(import.meta.dirname, '../../public/templates/theme')\n : resolve(import.meta.dirname, './templates/theme')\n","export const relativePathRegex = /\\[([^\\]]+)\\]\\(\\.\\.\\/([^)]+)\\)/g\nexport const readmePathRegex = /\\[([^\\]]+)\\]\\((?!\\.?\\/docs\\/|docs\\/|http|#)(\\.\\/)?([^/][^)]+)\\)/g\nexport const readmeDocsPathRegex = /\\[([^\\]]+)\\]\\((\\.?\\/docs\\/|docs\\/)([^)]*)\\)/g\nexport const removeIdxRegex = /^\\d{2}-/\n","import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'\nimport { basename, join, resolve } from 'node:path'\nimport axios from 'axios'\nimport { rimrafSync } from 'rimraf'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport type { getInfos } from '../lib/git.js'\nimport { DOCPRESS_DIR } from './const.js'\nimport { readmeDocsPathRegex, readmePathRegex, relativePathRegex, removeIdxRegex } from './regex.js'\n\n/**\n * Checks the HTTP status code of a URL\n *\n * @param url - URL to check\n * @returns HTTP status code (404 if not found, 500 for errors)\n */\nexport async function checkHttpStatus(url: string): Promise<number> {\n try {\n const response = await axios.head(url)\n return response.status\n } catch (error) {\n return error.response?.status || error.status || 500\n }\n}\n\n/**\n * Options for prettifying strings\n */\ninterface PrettifyOpts {\n mode?: 'capitalize' | 'uppercase' | 'lowercase'\n replaceDash?: boolean\n removeIdx?: boolean\n removeDot?: boolean\n removeExt?: boolean\n}\n\n/**\n * Formats a string based on specified options\n *\n * @param s - Input string to format\n * @param opts - Formatting options\n * @returns Formatted string\n */\nexport function prettify(s: string, opts: PrettifyOpts) {\n let u: string = ''\n\n if (opts?.removeDot) {\n if (s.startsWith('.')) {\n u = s.slice(1)\n } else {\n u = s\n }\n // Replace all remaining dots with dashes to ensure consistency\n u = u.replaceAll('.', '-')\n }\n\n if (opts?.removeIdx) {\n u = (u || s).replace(removeIdxRegex, '')\n }\n\n if (opts?.removeExt) {\n u = (u || s).split('.')[0]\n }\n\n if (opts?.replaceDash) {\n u = (u || s).replaceAll('-', ' ')\n }\n\n if (opts?.mode === 'capitalize') {\n u = (u || s).slice(0, 1).toUpperCase() + (u || s).slice(1).toLowerCase()\n } else if (opts?.mode === 'lowercase') {\n u = (u || s).toLowerCase()\n } else if (opts?.mode === 'uppercase') {\n u = (u || s).toUpperCase()\n }\n\n return u || s\n}\n\n/**\n * Creates a directory, optionally cleaning it first\n *\n * @param directory - Path to the directory to create\n * @param options - Options object\n * @param options.clean - Whether to clean the directory before creating it\n */\nexport function createDir(directory: string, { clean }: { clean?: boolean } = { clean: false }) {\n try {\n if (clean && existsSync(directory)) {\n rimrafSync(`${directory}/*`, { glob: true })\n }\n if (!existsSync(directory)) {\n mkdirSync(directory, { recursive: true })\n }\n } catch (err) {\n console.error(err)\n }\n}\n\n/**\n * Checks if a path is a directory\n *\n * @param path - Path to check\n * @returns True if path is a directory, false otherwise\n */\nexport function isDir(path: string) {\n try {\n return statSync(path).isDirectory()\n } catch (_error) {\n return false\n }\n}\n\n/**\n * Checks if a path is a file\n *\n * @param path - Path to check\n * @returns True if path is a file, false otherwise\n */\nexport function isFile(path: string) {\n try {\n return statSync(path).isFile()\n } catch (_error) {\n return false\n }\n}\n\n/**\n * Extracts a list of file paths from directories and files\n *\n * @param paths - Path or array of paths to extract files from\n * @returns Array of file paths\n */\nexport function extractFiles(paths: string[] | string): string[] {\n return (Array.isArray(paths) ? paths : [paths]).flatMap((path) => {\n if (isFile(path)) {\n return [path]\n }\n if (isDir(path)) {\n return readdirSync(path).flatMap(file => extractFiles(join(path, file)))\n }\n return []\n })\n}\n\n/**\n * Gets all markdown files from specified paths\n *\n * @param path - Array of paths to search for markdown files\n * @returns Array of markdown file paths\n */\nexport function getMdFiles(path: string[]) {\n return extractFiles(path).filter(file => basename(file).endsWith('.md'))\n}\n\n/**\n * Formats an array of strings into a readable comma-separated list\n *\n * @param arr - Array of strings to format\n * @returns Formatted string (e.g., \"a\", \"b\" or \"c\")\n */\nexport function prettifyEnum(arr: readonly string[]) {\n return arr.reduce((acc, cur, idx, arr) => {\n if (!idx) {\n return `\"${cur}\"`\n } else if (idx === arr.length - 1) {\n return `${acc} or \"${cur}\"`\n } else {\n return `${acc}, \"${cur}\"`\n }\n }, '')\n}\n\n/**\n * Gets user information from cached JSON file\n *\n * @param username - GitHub username\n * @returns User information object\n */\nexport function getUserInfos(username: GlobalOpts['usernames'][number]) {\n return JSON.parse(readFileSync(`${DOCPRESS_DIR}/user-${username}.json`).toString()) as Awaited<ReturnType<typeof getInfos>>['user']\n}\n\n/**\n * Gets repository information from cached JSON file\n *\n * @param username - GitHub username\n * @returns Array of enhanced repository objects\n */\nexport function getUserRepos(username: GlobalOpts['usernames'][number]) {\n return JSON.parse(readFileSync(`${DOCPRESS_DIR}/repos-${username}.json`).toString()) as EnhancedRepository[]\n}\n\n/**\n * Deep merges multiple objects\n *\n * @param objects - Objects to merge\n * @returns Merged object\n */\nexport function deepMerge<T extends Record<string, any> | null>(...objects: T[]): T {\n return objects.reduce((acc, obj) => {\n if (obj === null) {\n return acc\n }\n\n Object.keys(obj).forEach((key) => {\n const accValue = acc ? acc[key] : null\n const objValue = obj[key]\n\n if (isObject(accValue) && isObject(objValue)) {\n (acc as Record<string, any>)[key] = deepMerge(accValue, objValue)\n } else {\n (acc as Record<string, any>)[key] = objValue\n }\n })\n return acc\n }, {} as T)\n}\n\n/**\n * Checks if a value is an object (not an array or null)\n *\n * @param val - Value to check\n * @returns True if value is an object, false otherwise\n */\nexport function isObject(val: any): val is object {\n return val && typeof val === 'object' && !Array.isArray(val)\n}\n\n/**\n * Loads and parses a JSON configuration file\n *\n * @param configPath - Path to the configuration file\n * @returns Parsed configuration object or empty object if file doesn't exist\n */\nexport function loadConfigFile(configPath?: string) {\n if (!configPath) {\n return {}\n }\n try {\n const fullPath = resolve(process.cwd(), configPath)\n const fileContents = readFileSync(fullPath, 'utf8')\n return JSON.parse(fileContents)\n } catch (_error) {\n return {}\n }\n}\n\n/**\n * Splits a comma-separated string into an array of strings\n *\n * @param s - Comma-separated string\n * @returns Array of strings\n */\nexport function splitByComma(s: string) {\n return s.split(',')\n}\n\n/**\n * Replaces relative paths in markdown links with absolute URLs\n *\n * @param file - Path to the markdown file to process\n * @param url - Base URL to use for absolute links\n */\nexport function replaceRelativePath(file: string, url: string) {\n const fileContent = readFileSync(file, 'utf8')\n const updatedContent = fileContent.replace(relativePathRegex, (_match, p1, p2) => {\n return `[${p1}](${url}/${p2})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n\n/**\n * Processes README files to fix various link formats\n *\n * @param file - Path to the README file to process\n * @param url - Base URL to use for absolute links\n */\nexport function replaceReadmePath(file: string, url: string) {\n const readmeContent = readFileSync(file, 'utf8')\n const updatedContent = readmeContent\n .replace(readmePathRegex, (_match, p1, _p2, p3) => {\n return `[${p1}](${url}/${p3})`\n })\n .replace(readmeDocsPathRegex, (_match, p1, _p2, p3) => {\n return `[${p1}](${p3})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n","/* eslint-disable dot-notation */\nimport type { ColorName } from 'chalk'\nimport chalk from 'chalk'\n\n/**\n * Log message types\n */\ntype LogType = keyof Pick<Console, 'info' | 'warn' | 'error' | 'debug' | 'trace'> | 'success'\n\n/**\n * Mapping of log types to colors and levels\n */\ntype ColorMap = {\n [K in LogType]: {\n color: ColorName\n level: number\n }\n}\n\n/**\n * Gets the current log level from environment variables\n *\n * @returns Log level number (default: 30)\n */\nfunction getLogLevel() {\n return typeof Number(process.env['LOG_LEVEL']) === 'number' && !Number.isNaN(Number(process.env['LOG_LEVEL']))\n ? Number(process.env['LOG_LEVEL'])\n : 30\n}\n\n/**\n * Color mapping configuration for different log types\n */\nconst colorMap: ColorMap = {\n error: { color: 'red', level: 10 },\n warn: { color: 'yellow', level: 20 },\n info: { color: 'white', level: 30 },\n success: { color: 'green', level: 30 },\n trace: { color: 'white', level: 40 },\n debug: { color: 'blue', level: 50 },\n}\n\n/**\n * Logs a message with color formatting based on type and level\n *\n * @param msg - Message to log\n * @param type - Type of log message (info, warn, error, debug, trace, success)\n * @param color - Optional specific color to use instead of the default for the type\n */\nexport function log(msg: string, type: LogType = 'info', color?: ColorName) {\n const computedMsg = color ? chalk[color](msg) : chalk[colorMap[type].color](msg)\n const computedType = type === 'success' ? 'info' : type\n\n if (getLogLevel() >= colorMap[type].level) {\n console[computedType](computedMsg)\n }\n}\n","import { z } from 'zod'\nimport { loadConfigFile, prettifyEnum, splitByComma } from '../utils/functions.js'\nimport { log } from '../utils/logger.js'\n\n/**\n * List of supported Git providers\n */\nconst providers = ['github'] as const\n\n/**\n * Schema for the DocPress configuration file\n * Defines the structure and validation rules for the configuration\n */\nexport const configSchema = z.object({\n // Global\n usernames: z.string()\n .array()\n .describe('List of comma separated Git provider usernames used to collect data.'),\n // Fetch\n branch: z.string()\n .describe('Branch used to collect Git provider data.')\n .default('main'),\n gitProvider: z.enum(providers)\n .describe(`Git provider used to retrieve data. Values should be ${prettifyEnum(providers)}.`)\n .default('github'),\n reposFilter: z.string()\n .array()\n .describe('List of comma separated repositories to retrieve from Git provider. Default to all user\\'s public repositories.'),\n // Prepare\n extraHeaderPages: z.string()\n .array()\n .describe('List of comma separated additional files or directories to process Vitepress header pages.'),\n extraPublicContent: z.string()\n .array()\n .describe('List of comma separated additional files or directories to process Vitepress public folder.'),\n extraTheme: z.string()\n .array()\n .describe('List of comma separated additional files or directories to use as Vitepress theme.'),\n forks: z.boolean()\n .describe('Whether or not to create the dedicated fork page that aggregate external contributions.')\n .default(false),\n vitepressConfig: z.any()\n .describe('Path to the vitepress configuration file.'),\n websiteTitle: z.string()\n .describe('Website title.'),\n websiteTagline: z.string()\n .describe('Website tagline.'),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\n/**\n * Base CLI schema for parsing command line arguments\n * All fields are optional in this schema\n */\nexport const baseCliSchema = configSchema.partial().extend({\n config: z.string()\n .describe('Path to the docpress configuration file.')\n .optional(),\n token: z.string()\n .describe('Git provider token used to collect data.')\n .optional(),\n usernames: z.string()\n .describe(configSchema.shape.usernames.description || '')\n .optional(),\n reposFilter: z.string()\n .describe(configSchema.shape.reposFilter.description || '')\n .optional(),\n extraHeaderPages: z.string()\n .describe(configSchema.shape.extraHeaderPages.description || '')\n .optional(),\n extraPublicContent: z.string()\n .describe(configSchema.shape.extraPublicContent.description || '')\n .optional(),\n extraTheme: z.string()\n .describe(configSchema.shape.extraTheme.description || '')\n .optional(),\n vitepressConfig: z.string()\n .describe(configSchema.shape.vitepressConfig.description || '')\n .optional(),\n})\n\nexport type RawCli = z.infer<typeof baseCliSchema>\n\n/**\n * CLI schema with transformations applied to handle string-to-array conversions\n */\nexport const cliSchema = configSchema\n .partial()\n .extend({\n config: z.string()\n .describe('Path to the docpress configuration file.')\n .optional(),\n token: z.string()\n .describe('Git provider token used to collect data.')\n .optional(),\n usernames: z.string()\n .describe(configSchema.shape.usernames.description || '')\n .transform(splitByComma)\n .optional(),\n reposFilter: z.string()\n .describe(configSchema.shape.reposFilter.description || '')\n .transform(splitByComma)\n .optional(),\n extraHeaderPages: z.string()\n .describe(configSchema.shape.extraHeaderPages.description || '')\n .transform(splitByComma)\n .optional(),\n extraPublicContent: z.string()\n .describe(configSchema.shape.extraPublicContent.description || '')\n .transform(splitByComma)\n .optional(),\n extraTheme: z.string()\n .describe(configSchema.shape.extraTheme.description || '')\n .transform(splitByComma)\n .optional(),\n vitepressConfig: z.string()\n .describe(configSchema.shape.vitepressConfig.description || '')\n .optional(),\n })\n\nexport type Cli = z.infer<typeof cliSchema>\n\n// Helper functions to reduce complexity\n/**\n * Prepares configuration data by converting string values to arrays when needed\n *\n * @param configData - Raw configuration data to process\n * @returns Processed configuration data with proper array types\n */\nfunction prepareConfigData(configData: any) {\n if (!configData) return {}\n\n // Convert arrays that might be strings\n if (configData.usernames && typeof configData.usernames === 'string') {\n configData.usernames = [configData.usernames]\n }\n if (configData.reposFilter && typeof configData.reposFilter === 'string') {\n configData.reposFilter = [configData.reposFilter]\n }\n if (configData.extraHeaderPages && typeof configData.extraHeaderPages === 'string') {\n configData.extraHeaderPages = [configData.extraHeaderPages]\n }\n if (configData.extraPublicContent && typeof configData.extraPublicContent === 'string') {\n configData.extraPublicContent = [configData.extraPublicContent]\n }\n if (configData.extraTheme && typeof configData.extraTheme === 'string') {\n configData.extraTheme = [configData.extraTheme]\n }\n\n return configData\n}\n\n/**\n * Validates the final merged configuration to ensure required fields are present\n *\n * @param mergedConfig - The merged configuration to validate\n * @returns The validated configuration if it passes validation\n * @throws Error if required fields are missing\n */\nfunction validateFinalConfig(mergedConfig: any) {\n // Ensure usernames exists\n if (!mergedConfig.usernames?.length) {\n throw new Error('The usernames field is required')\n }\n\n return mergedConfig\n}\n\n/**\n * Schema for global options that combines CLI arguments and configuration files\n * Applies transformations to merge different config sources and validate the result\n */\nexport const globalOptsSchema = cliSchema\n .partial()\n .transform((data) => {\n try {\n const { config, vitepressConfig, token, ...rest } = data\n\n log(`Debug: Schema transform input: ${JSON.stringify(data)}`, 'debug')\n\n // Load configuration from file\n const configData = loadConfigFile(config)\n const preparedConfigData = prepareConfigData(configData)\n\n // Create final config\n const mergedConfig = {\n forks: false,\n ...preparedConfigData,\n ...rest,\n ...(vitepressConfig\n ? {\n vitepressConfig: {\n ...(loadConfigFile(vitepressConfig) || {}),\n ...(preparedConfigData.vitepressConfig || {}),\n },\n }\n : {}),\n }\n\n log(`Debug: Final merged config: ${JSON.stringify(mergedConfig)}`, 'debug')\n\n return validateFinalConfig({ ...mergedConfig, token })\n } catch (error) {\n // Handle errors gracefully\n log(` An error occurred while checking configuration.`, 'error')\n if (error instanceof Error) {\n log(` ${error.message}`, 'error')\n } else {\n log(` ${JSON.stringify(error, null, 2)}`, 'error')\n }\n process.exit(1)\n }\n })\n\nexport type GlobalOpts = Required<Pick<z.infer<typeof globalOptsSchema>, 'branch' | 'gitProvider'>>\n & Omit<z.infer<typeof globalOptsSchema>, 'branch' | 'gitProvider'>\n","import type { z } from 'zod'\nimport { cliSchema } from './global.js'\n\n/**\n * Schema for build command options\n * Currently empty as build doesn't require specific options\n */\nexport const buildOptsSchema = cliSchema\n .pick({})\n\nexport type BuildOpts = z.infer<typeof buildOptsSchema>\n","import { cliSchema } from './global.js'\nimport type { GlobalOpts } from './global.js'\n\n/**\n * Schema for fetch command options\n * Includes options related to Git repository fetching\n */\nexport const fetchOptsSchema = cliSchema\n .pick({\n branch: true,\n config: true,\n gitProvider: true,\n reposFilter: true,\n token: true,\n usernames: true,\n })\n\n/**\n * Type for fetch options\n */\nexport type FetchOpts = GlobalOpts\n\n/**\n * Type for fetch options with username instead of usernames array\n */\nexport type FetchOptsUser = Omit<FetchOpts, 'usernames'> & { username: FetchOpts['usernames'][number] }\n","import { cliSchema } from './global.js'\nimport type { GlobalOpts } from './global.js'\n\n/**\n * Schema for prepare command options\n * Includes options related to documentation preparation and customization\n */\nexport const prepareOptsSchema = cliSchema\n .pick({\n extraHeaderPages: true,\n extraPublicContent: true,\n extraTheme: true,\n config: true,\n gitProvider: true,\n reposFilter: true,\n token: true,\n usernames: true,\n vitepressConfig: true,\n })\n\n/**\n * Type for prepare options\n */\nexport type PrepareOpts = GlobalOpts\n","/* eslint-disable dot-notation */\nimport type { Command, Option } from 'commander'\nimport { fromError } from 'zod-validation-error'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport { configSchema, globalOptsSchema } from '../schemas/global.js'\nimport type { BuildOpts } from '../schemas/build.js'\nimport { buildOptsSchema } from '../schemas/build.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { fetchOptsSchema } from '../schemas/fetch.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { prepareOptsSchema } from '../schemas/prepare.js'\nimport { loadConfigFile } from './functions.js'\nimport { log } from './logger.js'\n\n/**\n * Type definition for command names\n */\ntype Cmd = 'fetch' | 'build' | 'prepare' | 'global'\n\n/**\n * Interface mapping command names to their option types\n */\ninterface Options {\n build: BuildOpts\n fetch: FetchOpts\n prepare: PrepareOpts\n global: GlobalOpts\n}\n\n/**\n * Mapping of command names to their schema validators\n */\nexport const options = {\n build: buildOptsSchema,\n fetch: fetchOptsSchema,\n prepare: prepareOptsSchema,\n global: globalOptsSchema,\n}\n\n/**\n * Handles loading and parsing of the configuration file\n *\n * @param configPath - Path to the configuration file\n * @param token - Optional GitHub token\n * @returns Parsed configuration data or null if loading/parsing failed\n */\nfunction handleConfigFile(configPath: string, token?: string) {\n const configData = loadConfigFile(configPath)\n if (!configData) return null\n\n // No need for a try/catch here since we're handling errors at a higher level\n const parsedConfig = configSchema.partial().safeParse(configData)\n if (parsedConfig.success) {\n return {\n ...parsedConfig.data,\n config: configPath,\n token: token || undefined,\n }\n }\n\n return null\n}\n\n/**\n * Parses and validates command options based on the command type\n *\n * @param cmd - The command name ('fetch', 'build', 'prepare', or 'global')\n * @param opts - Raw options from the command line\n * @returns Validated and processed options for the specified command\n */\nexport function parseOptions<T extends Cmd>(cmd: T, opts: Record<string, unknown>): Options[T] {\n log(`Initializing Docpress...`, 'info', 'blue')\n log(`\\n\\n-> Checking for required environment settings and configurations.`, 'info')\n log(` Debug info - opts: ${JSON.stringify(opts)}`, 'debug')\n log(` Debug info - options[cmd]: ${cmd}`, 'debug')\n\n try {\n // Special handling for config file\n if (cmd === 'global' && typeof opts['config'] === 'string') {\n const configResult = handleConfigFile(\n opts['config'],\n typeof opts['token'] === 'string' ? opts['token'] : undefined,\n )\n if (configResult) {\n // Force type assertion since we know the structure will match\n return configResult as unknown as Options[T]\n }\n }\n\n const res = options[cmd].safeParse(opts)\n if (!res.success) {\n try {\n const errorMessage = fromError(res.error).toString()\n log(` An error occurred while checking configuration.\\n ${errorMessage}`, 'error')\n } catch {\n // Fallback for incompatibility between zod-validation-error and Zod v4\n log(` An error occurred while checking configuration.\\n ${JSON.stringify(res.error, null, 2)}`, 'error')\n }\n process.exit(1)\n }\n log(' Setup complete! Ready to process your documentation.', 'info')\n return res.data as Options[T]\n } catch (error) {\n log(` An error occurred while processing options.`, 'error')\n if (error instanceof Error) {\n log(` ${error.message}`, 'error')\n } else {\n log(` ${JSON.stringify(error, null, 2)}`, 'error')\n }\n process.exit(1)\n }\n}\n\n/**\n * Adds option definitions to a Command instance\n *\n * @param cmd - The Commander Command instance\n * @param opts - Array of option definitions to add\n * @returns The Command instance with options added\n */\nexport function addOptions(cmd: Command, opts: Option[]) {\n for (const opt of opts) {\n cmd.addOption(opt)\n }\n return cmd\n}\n","import { appendFileSync, cpSync, rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { Octokit } from '@octokit/rest'\nimport { simpleGit } from 'simple-git'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { createDir } from '../utils/functions.js'\nimport { log } from '../utils/logger.js'\nimport type { EnhancedRepository } from './fetch.js'\n\n/**\n * Fetches user and repository information from GitHub\n *\n * @param options - Options for retrieving GitHub data\n * @param options.username - GitHub username\n * @param options.token - GitHub API token\n * @param options.branch - Branch to use for documentation\n * @returns Object containing user information, repositories, and branch\n */\nexport async function getInfos({ username, token, branch }: Pick<FetchOpts, 'branch'> & Pick<GlobalOpts, 'token'> & { username: GlobalOpts['usernames'][number] }) {\n log(` Get infos for username '${username}'.`, 'info')\n const octokit = new Octokit({ auth: token })\n log(` Get user infos.`, 'debug')\n const { data: user } = await octokit.rest.users.getByUsername({ username })\n log(` Get repositories infos.`, 'debug')\n const { data: repos } = await octokit.rest.repos.listForUser({ username, sort: 'full_name', per_page: 500 })\n\n return { user, repos, branch }\n}\n\n/**\n * Gets contributors for a repository\n *\n * @param options - Options for retrieving contributors\n * @param options.repository - Repository information\n * @param options.token - GitHub API token\n * @returns Object with source repository and contributors list\n */\nexport async function getContributors({\n repository,\n token,\n}: {\n repository: EnhancedRepository\n token: GlobalOpts['token']\n}) {\n log(` Get contributors infos for repository '${repository.name}'.`, 'info')\n const octokit = new Octokit({\n auth: token,\n log: {\n debug: () => {},\n info: () => {},\n warn: (message) => {\n if (!message.includes('404')) console.warn(message)\n },\n error: (message) => {\n if (!message.includes('404')) console.error(message)\n },\n },\n })\n const { data: repo } = await octokit.rest.repos.get({\n owner: repository.owner.login,\n repo: repository.name,\n })\n if (!repo.source?.owner?.login) {\n return { source: repo.source, contributors: [] }\n }\n const contributors: Array<any> = []\n try {\n for await (const { data } of octokit.paginate.iterator(\n octokit.rest.repos.listContributors,\n {\n owner: repo.source.owner.login,\n repo: repo.parent?.name ?? repo.name,\n per_page: 500,\n },\n )) {\n contributors.push(...data)\n }\n } catch (error) {\n log(\n ` Failed to get contributors infos for repository '${repository.name}'. Error : ${error.message}`,\n 'warn',\n )\n return { source: repo.source, contributors: [] }\n }\n\n return { source: repo.source, contributors }\n}\n\n/**\n * Clones a repository with sparse checkout\n *\n * @param name - Repository name\n * @param url - Repository URL\n * @param projectDir - Directory to clone into\n * @param branch - Branch to clone\n * @param includes - Patterns to include in sparse checkout\n */\nexport async function cloneRepo(name: string, url: string, projectDir: string, branch: string, includes: string[]) {\n createDir(projectDir, { clean: true })\n\n try {\n const git = simpleGit({ baseDir: projectDir })\n await git.init()\n .addConfig('core.sparseCheckout', 'true', true, 'local')\n .addRemote('origin', url)\n\n for (const item of includes) {\n log(` Add '${item}' to '${name}' sparse-checkout file.`, 'debug')\n appendFileSync(resolve(projectDir, '.git/info/sparse-checkout'), `${item}\\n`, 'utf8')\n }\n\n log(` Clone repository '${name}'.`, 'info')\n await git.pull('origin', branch)\n\n if (includes.some(item => item.includes('docs'))) {\n cpSync(resolve(projectDir, 'docs'), projectDir, { recursive: true })\n rmSync(resolve(projectDir, 'docs'), { recursive: true })\n }\n rmSync(resolve(projectDir, '.git'), { recursive: true })\n } catch (error) {\n log(` Error when cloning repository: ${error}.`, 'error')\n }\n}\n","import { resolve } from 'node:path'\nimport { writeFileSync } from 'node:fs'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport type { FetchOpts, FetchOptsUser } from '../schemas/fetch.js'\nimport { checkHttpStatus, prettify } from '../utils/functions.js'\nimport { DOCPRESS_DIR, DOCS_DIR } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport { cloneRepo, getInfos } from './git.js'\n\n/**\n * Enhanced repository type with DocPress-specific metadata\n */\nexport type EnhancedRepository = Awaited<ReturnType<typeof getInfos>>['repos'][number] & {\n docpress: {\n branch: string\n filtered: boolean\n includes: string[]\n projectPath: string\n raw_url: string\n replace_url: string\n }\n}\n\n/**\n * Checks for the existence of documentation files in a repository\n *\n * @param repoOwner - Owner of the repository (username)\n * @param repoName - Name of the repository\n * @param branch - Branch to check for documentation\n * @returns Object containing HTTP status codes for different documentation paths\n */\nexport async function checkDoc(repoOwner: GlobalOpts['usernames'][number], repoName: string, branch: FetchOpts['branch']) {\n const rootReadmeUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/README.md`\n const docsFolderUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/docs`\n const docsReadmeUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/docs/01-readme.md`\n\n const rootReadmeStatus = await checkHttpStatus(rootReadmeUrl)\n const docsFolderStatus = await checkHttpStatus(docsFolderUrl)\n const docsReadmeStatus = await checkHttpStatus(docsReadmeUrl)\n\n return {\n rootReadmeStatus,\n docsFolderStatus,\n docsReadmeStatus,\n }\n}\n\n/**\n * Fetches documentation from a user's repositories\n *\n * @param options - Options for fetching documentation\n * @param options.username - GitHub username\n * @param options.branch - Branch to use for documentation\n * @param options.reposFilter - Optional filter for repositories\n * @param options.token - GitHub API token\n */\nexport async function fetchDoc({ username, branch, reposFilter, token }: FetchOptsUser) {\n await getInfos({ username, token, branch })\n .then(async ({ user, repos, branch }) => generateInfos(user, repos, branch, reposFilter))\n .then(async ({ repos }) => getDoc(repos, reposFilter))\n}\n\n/**\n * Enhances repository information with DocPress metadata\n *\n * @param repos - List of repositories from Git provider\n * @param branch - Branch to use for documentation\n * @param reposFilter - Optional filter for repositories\n * @returns Array of enhanced repositories with DocPress metadata\n */\nexport async function enhanceRepositories(repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n const enhancedRepos: EnhancedRepository[] = []\n\n await Promise.all(\n repos.map(async (repo) => {\n const computedBranch = branch ?? repo.default_branch ?? 'main'\n const projectPath = resolve(DOCS_DIR, prettify(repo.name, { removeDot: true }))\n const filtered = isRepoFiltered(repo, reposFilter)\n let includes: string[] = []\n\n if (!repo.fork && !repo.private && !filtered) {\n includes = await getSparseCheckout(repo, computedBranch)\n }\n\n enhancedRepos.push({\n ...repo,\n docpress: {\n filtered,\n branch: computedBranch,\n includes,\n projectPath,\n raw_url: `https://raw.githubusercontent.com/${repo.owner.login}/${repo.name}/${computedBranch}`,\n replace_url: `https://github.com/${repo.owner.login}/${repo.name}/tree/${computedBranch}`,\n },\n })\n }),\n )\n\n return enhancedRepos\n}\n\n/**\n * Determines which files to include in the sparse checkout based on repository structure\n *\n * @param repo - Repository information\n * @param branch - Branch to check for documentation\n * @returns Array of file patterns to include in sparse checkout\n */\nexport async function getSparseCheckout(repo: Awaited<ReturnType<typeof getInfos>>['repos'][number], branch: FetchOpts['branch']) {\n const docsStatus = await checkDoc(repo.owner.login, repo.name, branch)\n\n const includes: string[] = []\n if (Object.values(docsStatus).every(status => status === 404) || !repo.size) {\n return []\n }\n if (docsStatus.docsFolderStatus !== 404) {\n includes.push('docs/*')\n }\n if (docsStatus.docsFolderStatus === 404 || docsStatus.docsReadmeStatus === 404) {\n includes.push('README.md', '!*/**/README.md')\n }\n return includes\n}\n\n/**\n * Generates and saves user and repository information\n *\n * @param user - User information from Git provider\n * @param repos - List of repositories from Git provider\n * @param branch - Branch to use for documentation\n * @param reposFilter - Optional filter for repositories\n * @returns Object containing user and enhanced repository information\n */\nexport async function generateInfos(user: Awaited<ReturnType<typeof getInfos>>['user'], repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n writeFileSync(`${DOCPRESS_DIR}/user-${user.login}.json`, JSON.stringify(user, null, 2))\n\n const enhancedRepos = await enhanceRepositories(repos, branch, reposFilter)\n writeFileSync(`${DOCPRESS_DIR}/repos-${user.login}.json`, JSON.stringify(enhancedRepos, null, 2))\n\n return { user, repos: enhancedRepos }\n}\n\n/**\n * Fetches documentation from repositories\n *\n * @param repos - List of enhanced repositories\n * @param reposFilter - Optional filter for repositories\n */\nexport async function getDoc(repos?: EnhancedRepository[], reposFilter?: FetchOpts['reposFilter']) {\n if (!repos) {\n log(` No repository respect docpress rules.`, 'warn')\n return\n }\n\n await Promise.all(\n repos\n .filter(repo => !isRepoFiltered(repo, reposFilter))\n .map(async (repo) => {\n await cloneRepo(repo.name, repo.clone_url as string, repo.docpress.projectPath, repo.docpress.branch, repo.docpress.includes)\n }),\n )\n}\n\n/**\n * Determines if a repository should be filtered out based on filter rules\n *\n * @param repo - Repository information\n * @param reposFilter - Optional filter for repositories\n * @returns True if the repository should be filtered out, false otherwise\n */\nexport function isRepoFiltered(repo: EnhancedRepository | Awaited<ReturnType<typeof getInfos>>['repos'][number], reposFilter?: FetchOpts['reposFilter']) {\n const hasOnlyExclusions = reposFilter?.every((filter: string) => filter.startsWith('!'))\n const isExcluded = reposFilter?.filter((filter: string) => filter.startsWith('!'))\n .some((filter: string) => repo.name === filter.substring(1))\n const isIncluded = !reposFilter\n || reposFilter?.filter((filter: string) => !filter.startsWith('!')).includes(repo.name)\n || (repo.fork && !isExcluded)\n || (hasOnlyExclusions && !isExcluded)\n\n const isFiltered = isExcluded || !isIncluded\n\n if ('docpress' in repo && !repo.docpress.includes.length) {\n return true\n }\n\n if (!!repo.clone_url && !repo.private && !isFiltered) {\n return false\n }\n return true\n}\n","import { createOption } from 'commander'\nimport { baseCliSchema } from '../schemas/global.js'\n\n/**\n * Global command line options shared across all commands\n */\nexport const globalOpts = [\n createOption('-C, --config <string>', baseCliSchema.shape.config.description),\n createOption('-T, --token <string>', baseCliSchema.shape.token.description),\n createOption('-U, --usernames <string>', baseCliSchema.shape.usernames.description),\n]\n","import { createCommand, createOption } from 'commander'\nimport { createDir } from '../utils/functions.js'\nimport { DOCPRESS_DIR } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { fetchDoc } from '../lib/fetch.js'\nimport { configSchema } from '../schemas/global.js'\nimport { globalOpts } from './global.js'\n\n/**\n * Command name for the fetch operation\n */\nconst cmdName = 'fetch'\n\n/**\n * Command line options specific to the fetch command\n */\nexport const fetchOpts = [\n createOption('-b, --branch <string>', configSchema.shape.branch.description)\n .default(configSchema.shape.branch.default),\n createOption('-g, --git-provider <string>', configSchema.shape.gitProvider.description)\n .default(configSchema.shape.gitProvider.default),\n createOption('-r, --repos-filter <string>', configSchema.shape.reposFilter.description),\n]\n\n/**\n * The fetch command definition for Commander\n */\nexport const fetchCmd = addOptions(createCommand(cmdName), [...fetchOpts, ...globalOpts])\n .description('Fetch docs with the given username(s) and git provider.')\n .action(async (opts) => {\n const parsedOpts = parseOptions(cmdName, opts)\n await main(parsedOpts)\n })\n\n/**\n * Main function to execute the fetch command\n *\n * @param opts - Validated fetch options\n */\nexport async function main(opts: FetchOpts) {\n const { usernames, reposFilter, token, branch, gitProvider } = opts\n log(`\\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, 'info')\n\n createDir(DOCPRESS_DIR, { clean: true })\n for (const username of usernames) {\n const finalRF = usernames.length > 1\n ? reposFilter?.filter((rf: string) => rf.startsWith(`${username}/`)).map((rf: string) => rf.replace(`${username}/`, ''))\n : reposFilter\n await fetchDoc({ username, branch, reposFilter: finalRF, gitProvider, token })\n }\n}\n","import { build as vitepressBuild } from 'vitepress'\nimport { createCommand } from 'commander'\nimport { addOptions } from '../utils/commands.js'\nimport { DOCPRESS_DIR } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport { globalOpts } from './global.js'\n\n/**\n * Suppress specific Vue warnings during the build process\n *\n * @param callback - Function to execute while warnings are suppressed\n * @returns The result of the callback function\n */\nexport async function suppressVueWarnings<T>(callback: () => Promise<T>): Promise<T> {\n // Store the original console.warn\n const originalWarn = console.warn\n\n // Override console.warn to suppress specific Vue warnings\n console.warn = function (...args) {\n if (\n args.length > 0\n && typeof args[0] === 'string'\n && (args[0].includes('[Vue warn]: Invalid watch source:')\n || args[0].includes('{ open: false }'))\n ) {\n // Skip this warning\n return\n }\n // Pass other warnings to the original console.warn\n originalWarn.apply(console, args)\n }\n\n try {\n // Execute the callback with warnings suppressed\n return await callback()\n } finally {\n // Restore the original console.warn\n console.warn = originalWarn\n }\n}\n\n/**\n * Command name for the build operation\n */\nconst cmdName = 'build'\n\n/**\n * Command line options specific to the build command (none currently)\n */\nexport const buildOpts = []\n\n/**\n * The build command definition for Commander\n */\nexport const buildCmd = addOptions(createCommand(cmdName), globalOpts)\n .description('Build vitepress website.')\n .action(async (_opts) => {\n await main()\n })\n\n/**\n * Main function to execute the build command\n * Builds the VitePress static site\n */\nexport async function main() {\n log(`\\n-> Start building Vitepress website.\\n\\n`, 'info')\n\n try {\n // Build VitePress with Vue warnings suppressed\n await suppressVueWarnings(async () => {\n await vitepressBuild(DOCPRESS_DIR)\n })\n\n log(`\\n\\nDocpress build succedeed.`, 'success')\n } catch (error) {\n log(`\\n\\nDocpress build failed : ${error}`, 'error')\n process.exit(1)\n }\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { createDir } from './functions.js'\n\n/**\n * Generates a file by copying content from source to destination\n *\n * @param src - Path to the source file\n * @param dest - Path to the destination file\n */\nexport function generateFile(src: string, dest: string) {\n const content = readFileSync(src, { encoding: 'utf8' })\n createDir(dirname(dest))\n writeFileSync(dest, content)\n}\n","import type { defineConfig } from 'vitepress'\nimport { deepMerge } from '../utils/functions.js'\nimport type { Page, SidebarProject } from './prepare.js'\n\n/**\n * Default VitePress configuration\n */\nconst defaultVitepressConfig: ReturnType<typeof defineConfig> = {\n base: '/',\n lang: 'en-US',\n vite: {\n publicDir: '../public',\n },\n title: 'Home',\n description: 'Docpress',\n srcDir: './docs',\n cleanUrls: false,\n ignoreDeadLinks: 'localhostLinks',\n themeConfig: {\n outline: [2, 3],\n search: {\n provider: 'local',\n options: {\n translations: {\n button: {\n buttonText: 'Search...',\n buttonAriaLabel: 'Search',\n },\n modal: {\n backButtonTitle: 'erase search',\n displayDetails: 'show details',\n noResultsText: 'No results for : ',\n resetButtonTitle: 'cancel search',\n footer: {\n selectText: 'go to',\n navigateText: 'navigate in results',\n closeText: 'close',\n },\n },\n },\n },\n },\n },\n}\n\n/**\n * Generates VitePress configuration by merging default and custom configs\n *\n * @param sidebar - Sidebar configuration\n * @param nav - Navigation configuration\n * @param vitepressConfig - Optional custom VitePress configuration\n * @returns Merged VitePress configuration\n */\nexport function getVitepressConfig(sidebar: SidebarProject[], nav: Page[], vitepressConfig?: ReturnType<typeof defineConfig>): Partial<ReturnType<typeof defineConfig>> {\n const config = vitepressConfig\n ? deepMerge(defaultVitepressConfig, vitepressConfig, { themeConfig: { sidebar, nav } })\n : deepMerge(defaultVitepressConfig, { themeConfig: { sidebar, nav } })\n return config\n}\n","import { basename, dirname, parse, resolve } from 'node:path'\nimport { appendFileSync, cpSync, existsSync, readdirSync, renameSync, statSync, writeFileSync } from 'node:fs'\nimport { readFile } from 'node:fs/promises'\nimport YAML from 'yaml'\nimport type { defineConfig } from 'vitepress'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { generateFile } from '../utils/templates.js'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport { createDir, extractFiles, getMdFiles, getUserInfos, getUserRepos, prettify, replaceReadmePath, replaceRelativePath } from '../utils/functions.js'\nimport { DOCPRESS_DIR, DOCS_DIR, FORKS_FILE, INDEX_FILE, TEMPLATE_THEME, VITEPRESS_CONFIG, VITEPRESS_THEME, VITEPRESS_USER_THEME } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport type { EnhancedRepository } from './fetch.js'\nimport type { getInfos } from './git.js'\nimport { getContributors } from './git.js'\nimport { getVitepressConfig } from './vitepress.js'\n\n/**\n * Represents a navigation page item with text and link\n */\nexport interface Page {\n text: string\n link: string\n}\n\n/**\n * Represents a sidebar project with nested items\n */\nexport interface SidebarProject {\n text: string\n collapsed: boolean\n items: (Page | SidebarProject)[]\n}\n\n/**\n * Represents a feature to display on the index page\n */\nexport interface Feature {\n title: string\n details: string\n link: string\n}\n\n/**\n * Represents the structure of the VitePress index page\n */\nexport interface Index {\n layout: string\n hero: {\n name: string\n tagline?: string\n }\n /** List of features to display */\n features: Feature[]\n}\n\n/**\n * Prepares the documentation structure for a user's repositories\n *\n * @param options - Options for documentation preparation\n * @param options.extraHeaderPages - Array of paths to additional header pages\n * @param options.extraPublicContent - Array of paths to additional public content\n * @param options.extraTheme - Array of paths to additional theme files\n * @param options.vitepressConfig - Path to the VitePress configuration file\n * @param options.forks - Flag to include forked repositories\n * @param options.token - GitHub token for API access\n * @param options.username - GitHub username to fetch repositories for\n * @param options.websiteTitle - Custom title for the documentation website\n * @param options.websiteTagline - Custom tagline for the documentation website\n */\nexport async function prepareDoc({ extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig, forks, token, username, websiteTitle, websiteTagline }: Omit<PrepareOpts, 'usernames' | 'branch' | 'gitProvider' | 'reposFilter'> & { username: PrepareOpts['usernames'][number] }) {\n const user = getUserInfos(username)\n const repositories = getUserRepos(username)\n .reduce(({ internals, forks }: { internals: EnhancedRepository[], forks: EnhancedRepository[] }, cur) => {\n const { clone_url, private: privateRepo, fork, docpress } = cur\n if (clone_url && !privateRepo && !docpress.filtered) {\n if (!fork && docpress.includes.length) {\n return { internals: [...internals, cur], forks }\n } else if (fork) {\n return { internals, forks: [...forks, cur] }\n }\n }\n return { internals, forks }\n }, { internals: [], forks: [] })\n\n const websiteInfos = { title: websiteTitle, tagline: websiteTagline }\n const { index, sidebar } = transformDoc(repositories.internals, user, websiteInfos)\n\n let finalSB\n let finalIndex\n if (existsSync(INDEX_FILE) && existsSync(VITEPRESS_CONFIG)) {\n const actualConfig = await parseVitepressConfig(VITEPRESS_CONFIG)\n const actualIndex = await parseVitepressIndex(INDEX_FILE)\n finalSB = [\n ...(actualConfig.themeConfig?.sidebar as SidebarProject[] ?? []),\n ...sidebar,\n ].sort((a, b) => a.text.localeCompare(b.text))\n finalIndex = {\n ...index,\n features: [\n ...actualIndex.features,\n ...index.features,\n ].sort((a, b) => a.title.localeCompare(b.title)),\n }\n } else {\n finalSB = sidebar\n finalIndex = index\n }\n const nav: Page[] = []\n\n if (extraHeaderPages) {\n const pages = addExtraPages(extraHeaderPages)\n if (forks) {\n nav.push(...pages.filter(p => p.link !== '/forks'))\n } else {\n nav.push(...pages)\n }\n }\n if (extraPublicContent) {\n log(` Add extras Vitepress public folder content.`, 'info')\n addContent(extraPublicContent, resolve(DOCPRESS_DIR, 'public'))\n }\n if (extraTheme) {\n log(` Add extras Vitepress theme files.`, 'info')\n addContent(extraTheme, resolve(VITEPRESS_USER_THEME))\n }\n if (forks && username.length) {\n log(` Add fork page to display external contributions.`, 'info')\n await processForks(repositories.forks, username, token)\n nav.push({ text: 'Forks', link: '/forks' })\n }\n\n const config = getVitepressConfig(finalSB, nav, vitepressConfig)\n\n generateVitepressFiles(config, finalIndex)\n}\n\n/**\n * Adds a source reference section to a markdown file\n *\n * @param repoUrl - URL of the GitHub repository\n * @param outputPath - Path to the markdown file where sources will be added\n */\nexport function addSources(repoUrl: string, outputPath: string) {\n const fileName = basename(outputPath)\n const title = prettify(fileName, { mode: 'lowercase', removeIdx: true }) === 'readme.md' ? '\\n## Sources' : '# Sources'\n\n const sourcesContent = `${title}\\n\\nTake a look at the [project sources](${repoUrl}).\\n`\n\n appendFileSync(outputPath, sourcesContent, 'utf8')\n}\n\n/**\n * Information about website title and tagline\n */\nexport interface WebsiteInfos {\n title?: string\n tagline?: string\n}\n\n/**\n * Generates the index page content for the documentation site\n *\n * @param features - Array of features to display on the homepage\n * @param user - User information retrieved from GitHub\n * @param websiteInfos - Custom title and tagline information\n * @returns An object with index page configuration\n */\nexport function generateIndex(features: Feature[], user: ReturnType<typeof getUserInfos>, websiteInfos: WebsiteInfos) {\n const { name, login, bio } = user\n const { title, tagline } = websiteInfos\n\n const hero = title\n ? { name: title, tagline }\n : { name: name ? `${name}'s projects` : `${login}'s projects`, tagline: bio ?? 'Robots are everywhere 🤖' }\n\n return {\n layout: 'home',\n hero,\n features,\n }\n}\n\n/**\n * Generates feature cards for the homepage\n *\n * @param repoName - Name of the repository\n * @param description - Description of the repository\n * @param features - Optional existing features to append to\n * @returns Array of feature objects for the homepage\n */\nexport function generateFeatures(repoName: string, description: string, features?: Feature[]) {\n const content = {\n title: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n details: description,\n link: `/${prettify(repoName, { removeDot: true })}/introduction`,\n }\n\n return features ? [...features, content] : [content]\n}\n\n/**\n * Generates a sidebar project entry for the documentation navigation\n *\n * @param repoName - Name of the repository\n * @param sidebarPages - Array of sidebar pages to include in this project\n * @returns A sidebar project configuration object\n */\nexport function generateSidebarProject(repoName: string, sidebarPages: (SidebarProject | Page)[]) {\n return {\n text: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n collapsed: true,\n items: sidebarPages,\n }\n}\n\n/**\n * Generates sidebar page entries for the documentation navigation\n *\n * @param repoName - Name of the repository\n * @param fileName - Name of the file\n * @param sidebarPages - Optional existing sidebar pages to append to\n * @returns Array of page objects for the sidebar\n */\nexport function generateSidebarPages(repoName: string, fileName: string, sidebarPages?: Page[]) {\n const content = {\n text: fileName === 'introduction' ? 'Introduction' : prettify(fileName, { mode: 'capitalize', replaceDash: true }),\n link: `/${prettify(repoName, { removeDot: true })}/${fileName}`,\n }\n\n return sidebarPages ? [...sidebarPages, content] : [content]\n}\n\n/**\n * Generates sidebar items from a repository's file structure\n *\n * @param repository - Repository information\n * @param obj - Object representing the file tree structure\n * @returns Array of sidebar items (projects and pages)\n */\nexport function generateSidebarItems(repository: EnhancedRepository, obj: any): (SidebarProject | Page)[] {\n return Object.entries(obj).flatMap(([key, value]): (SidebarProject | Page)[] => {\n if (key === '$') {\n if (Array.isArray(value)) {\n return value.map((element) => {\n const file = resolve(repository.docpress.projectPath, element)\n let filename = prettify(basename(file), { mode: 'lowercase', removeIdx: true })\n if (filename === 'readme.md') {\n filename = 'introduction.md'\n }\n if (filename !== basename(file)) {\n renameSync(file, resolve(dirname(file), filename))\n }\n\n return {\n text: parse(filename).name === 'introduction'\n ? 'Introduction'\n : prettify(filename, { mode: 'capitalize', replaceDash: true, removeExt: true }),\n link: `/${prettify(repository.name, { removeDot: true })}/${parse(filename).name}`,\n } as Page\n })\n }\n return []\n } else if (typeof value === 'object') {\n return [{\n text: prettify(key, { mode: 'capitalize', replaceDash: true }),\n collapsed: true,\n items: generateSidebarItems({ ...repository, name: `${repository.name}/${key}` }, value),\n } as SidebarProject]\n }\n\n return []\n })\n}\n\n/**\n * Builds a tree structure from an array of file paths\n *\n * @param files - Array of file paths to be organized into a tree\n * @returns A nested object representing the directory structure\n */\nexport function buildTree(files: string[]): any {\n return files.reduce((tree, file) => {\n const [first, ...rest] = file.split('/')\n if (!rest.length) {\n // eslint-disable-next-line dot-notation\n tree['$'] = [...(tree['$'] || []), first]\n } else {\n tree[first] = buildTree([\n ...(tree[first] ? flattenTree(tree[first], '') : []),\n rest.join('/'),\n ])\n }\n return tree\n }, {} as Record<string, any>)\n}\n\n/**\n * Flattens a nested tree structure into an array of file paths\n *\n * @param subtree - The tree object to flatten\n * @param prefix - Optional path prefix to prepend to each result\n * @returns An array of file paths\n */\nexport function flattenTree(subtree: any, prefix = ''): string[] {\n return Object.entries(subtree).flatMap(([key, value]) => {\n if (key === '$') {\n if (Array.isArray(value)) {\n return value.map((v: string) => (prefix ? `${prefix}/${v}` : v))\n } else {\n return []\n }\n }\n return flattenTree(value, prefix ? `${prefix}/${key}` : key)\n })\n}\n\n/**\n * Reorders sidebar items to ensure 'Sources' appears last\n *\n * @param arr - Array of sidebar items to reorder\n * @returns Reordered array with 'Sources' as the last item\n */\nfunction moveSourcesLast(arr: (SidebarProject | Page)[]) {\n if (!Array.isArray(arr)) {\n return arr\n }\n const sourcesIdx = arr.findIndex(item => item.text === 'Sources')\n if (sourcesIdx === -1) {\n return arr\n }\n const [sources] = arr.splice(sourcesIdx, 1)\n arr.push(sources)\n return arr\n}\n\n/**\n * Transforms repository data into documentation structure\n *\n * @param repositories - Array of enhanced repositories\n * @param user - User information retrieved from GitHub\n * @param websiteInfos - Custom title and tagline information\n * @returns Object containing sidebar and index page configurations\n */\nexport function transformDoc(repositories: EnhancedRepository[], user: ReturnType<typeof getUserInfos>, websiteInfos: WebsiteInfos) {\n const features: Feature[] = []\n const sidebar: SidebarProject[] = []\n\n for (const repository of repositories) {\n log(` Replace urls for repository '${repository.name}'.`, 'info')\n getMdFiles([repository.docpress.projectPath]).forEach((file) => {\n log(` Processing file '${basename(file)}' for repository '${repository.name}'.`, 'debug')\n replaceRelativePath(file, `https://github.com/${repository.owner.login}/${repository.name}/tree/${repository.docpress.branch}`)\n\n if (basename(file).toLowerCase() === 'readme.md') {\n replaceReadmePath(file, `https://github.com/${repository.owner.login}/${repository.name}/tree/${repository.docpress.branch}`)\n }\n })\n\n log(` Generate sidebar for repository '${repository.name}'.`, 'info')\n const projectFiles = readdirSync(repository.docpress.projectPath, { recursive: true })\n .filter((file) => {\n return statSync(resolve(repository.docpress.projectPath, file.toString())).isFile()\n && basename(resolve(repository.docpress.projectPath, file.toString())).endsWith('.md')\n }) as string[]\n\n log(` Add sources for repository '${repository.name}'.`, 'info')\n let sourceFile\n if (projectFiles.length > 1) {\n sourceFile = resolve(repository.docpress.projectPath, 'sources.md')\n projectFiles.push('sources.md')\n } else {\n sourceFile = resolve(repository.docpress.projectPath, projectFiles[0])\n }\n addSources(repository.html_url, sourceFile)\n\n const projectTree = buildTree(projectFiles)\n const sidebarItems = moveSourcesLast(generateSidebarItems(repository, projectTree))\n\n sidebar.push(generateSidebarProject(prettify(repository.name, { removeDot: true }), sidebarItems))\n features.push(...generateFeatures(prettify(repository.name, { removeDot: true }), repository.description || ''))\n }\n\n log(` Generate index content.`, 'info')\n const index = generateIndex(features.toSorted((a, b) => a.title.localeCompare(b.title)), user, websiteInfos)\n return {\n sidebar: sidebar.toSorted((a, b) => a.text.localeCompare(b.text)),\n index,\n }\n}\n\n/**\n * Adds extra pages to the documentation from specified paths\n *\n * @param paths - Array of paths to markdown files\n * @returns Array of navigation page objects\n */\nexport function addExtraPages(paths: string[]) {\n const files = getMdFiles(paths)\n const nav: Page[] = []\n\n log(` Add extras Vitepress headers pages.`, 'info')\n for (const file of files) {\n log(` Processing file '${file}'.`, 'debug')\n const src = resolve(process.cwd(), file)\n const dest = resolve(DOCS_DIR, prettify(basename(file), { mode: 'lowercase', removeIdx: true }))\n cpSync(src, dest)\n nav.push({\n text: prettify(parse(src).name, { replaceDash: true, removeIdx: true }),\n link: `/${prettify(parse(src).name, { removeIdx: true, mode: 'lowercase' })}`,\n })\n }\n return nav\n}\n\n/**\n * Adds content from specified paths to a target directory\n *\n * @param paths - String or array of paths to content\n * @param dir - Target directory to copy content to\n * @param fn - Optional callback function to execute for each file\n */\nexport function addContent(paths: string | string[], dir: string, fn?: () => void) {\n for (const path of Array.isArray(paths) ? paths : [paths]) {\n const absolutePath = resolve(process.cwd(), path)\n const files = extractFiles(absolutePath)\n\n for (const file of files) {\n const formattedFile = file.replace(absolutePath, '.')\n log(` Processing file '${formattedFile}' for entry '${path}'.`, 'debug')\n const src = resolve(process.cwd(), file)\n const dest = resolve(dir, formattedFile)\n if (fn) {\n fn()\n }\n cpSync(src, dest)\n }\n }\n}\n\n/**\n * Creates a fork page to display external contributions\n *\n * @param forks - Array of repositories and contribution counts\n */\nexport function addForkPage(forks: { repository: Awaited<ReturnType<typeof getInfos>>['repos'][number], contributions: number }[]) {\n const separator = '---\\n'\n const header = 'layout: fork-page\\nrepoList:\\n'\n const text = '\\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'\n const frontmatter = forks.map(({ repository, contributions }) => {\n const { name, owner, html_url, description, stargazers_count } = repository\n return { name, owner: owner.login, html_url, description, stargazers_count, contributions }\n })\n log(` Generate forks page.`, 'info')\n writeFileSync(FORKS_FILE, separator + header + YAML.stringify(frontmatter) + separator + text)\n}\n\ntype Source = Required<Awaited<ReturnType<typeof getContributors>>['source']>\n\ntype AdaptedLicense = Omit<NonNullable<Source>['license'], 'spdx_id'> & { spdx_id?: string }\n\ntype AdaptedRepository = Omit<NonNullable<Source>, 'license'> & { license: AdaptedLicense }\n\n/**\n * Processes forked repositories to generate contribution information\n *\n * @param repositories - Array of enhanced repositories\n * @param username - GitHub username\n * @param token - Optional GitHub API token\n */\nexport async function processForks(repositories: EnhancedRepository[], username: GlobalOpts['usernames'][number], token?: GlobalOpts['token']) {\n const forks = await Promise.all(\n repositories.map(async (repository) => {\n const { source, contributors } = await getContributors({ repository, token })\n return {\n contributions: contributors?.find(contributor => contributor.login === username)?.contributions ?? 0,\n repository: source as AdaptedRepository,\n }\n }),\n ).then(f => f.filter(({ repository, contributions }) => !!repository && contributions))\n\n addForkPage(forks)\n}\n\n/**\n * Parses a VitePress configuration file\n *\n * @param path - Path to the VitePress config file\n * @returns The parsed configuration object\n */\nexport async function parseVitepressConfig(path: string): Promise<Partial<ReturnType<typeof defineConfig>>> {\n const { config } = await import(resolve(process.cwd(), path)).catch(e => e)\n return config\n}\n\n/**\n * Parses a VitePress index file\n *\n * @param path - Path to the index file\n * @returns The parsed index object\n */\nexport async function parseVitepressIndex(path: string): Promise<Index> {\n const index = (await readFile(resolve(process.cwd(), path))).toString()\n return YAML.parse(index)\n}\n\n/**\n * Generates VitePress configuration and index files\n *\n * @param vitepressConfig - VitePress configuration object\n * @param index - Index page configuration\n * @returns The list of theme files that were generated\n */\nexport function generateVitepressFiles(vitepressConfig: Partial<ReturnType<typeof defineConfig>>, index: Index) {\n const separator = '---\\n'\n createDir(dirname(VITEPRESS_CONFIG))\n\n log(` Generate Vitepress config.`, 'info')\n writeFileSync(VITEPRESS_CONFIG, `import { withMermaid } from 'vitepress-plugin-mermaid'\\n\\nexport const config = withMermaid(${JSON.stringify(vitepressConfig, null, 2)})\\n\\nexport default config\\n`)\n log(` Generate index file.`, 'info')\n writeFileSync(INDEX_FILE, separator + YAML.stringify(index))\n log(` Add Docpress theme files.`, 'info')\n return extractFiles(TEMPLATE_THEME).forEach((path) => {\n const relativePath = path.replace(`${TEMPLATE_THEME}/`, '')\n generateFile(path, resolve(VITEPRESS_THEME, relativePath))\n })\n}\n","import { dirname } from 'node:path'\nimport { createCommand, createOption } from 'commander'\nimport { configSchema } from '../schemas/global.js'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport { prepareDoc } from '../lib/prepare.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { log } from '../utils/logger.js'\nimport { createDir } from '../utils/functions.js'\nimport { VITEPRESS_CONFIG } from '../utils/const.js'\nimport { globalOpts } from './global.js'\n\n/**\n * Command name for the prepare operation\n */\nconst cmdName = 'prepare'\n\n/**\n * Command line options specific to the prepare command\n */\nexport const prepareOpts = [\n createOption('-c, --extra-public-content <string>', configSchema.shape.extraPublicContent.description),\n createOption('-f, --forks', configSchema.shape.forks.description),\n createOption('-p, --extra-header-pages <string>', configSchema.shape.extraHeaderPages.description),\n createOption('-t, --extra-theme <string>', configSchema.shape.extraTheme.description),\n createOption('-v, --vitepress-config <string>', configSchema.shape.vitepressConfig.description),\n createOption('--website-title <string>', configSchema.shape.websiteTitle.description),\n createOption('--website-tagline <string>', configSchema.shape.websiteTagline.description),\n]\n\n/**\n * The prepare command definition for Commander\n */\nexport const prepareCmd = addOptions(createCommand(cmdName), [...prepareOpts, ...globalOpts])\n .description('Transform doc to the target vitepress format.')\n .action(async (opts) => {\n const parsedOpts = parseOptions(cmdName, opts)\n await main(parsedOpts)\n })\n\n/**\n * Main function to execute the prepare command\n *\n * @param opts - Validated prepare options\n */\nexport async function main(opts: PrepareOpts) {\n const { extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig, forks, token, usernames, websiteTitle, websiteTagline } = opts\n log(`\\n-> Start transform files to prepare Vitepress build.`, 'info')\n\n createDir(dirname(VITEPRESS_CONFIG), { clean: true })\n for (const username of usernames) {\n await prepareDoc({ extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig, forks, token, username, websiteTitle, websiteTagline })\n }\n}\n","import { Command } from 'commander'\nimport pkg from '../package.json' with { type: 'json' }\nimport { fetchCmd, main as fetchFn, fetchOpts } from './commands/fetch.js'\nimport { buildCmd, main as buildFn } from './commands/build.js'\nimport { prepareCmd, main as prepareFn, prepareOpts } from './commands/prepare.js'\nimport { addOptions, parseOptions } from './utils/commands.js'\nimport { globalOpts } from './commands/global.js'\n\n/**\n * Adds explicit defaults to options object for branch and gitProvider\n *\n * @param opts - Options object from Commander\n * @returns Options with defaults explicitly set\n */\nfunction addDefaults(opts: Record<string, unknown>): Record<string, unknown> {\n // Create a new object with explicit defaults\n return {\n ...opts,\n branch: 'main',\n gitProvider: 'github',\n }\n}\n\n/**\n * Creates and configures the Command Line Interface for DocPress\n *\n * @returns A configured Commander program instance\n */\nexport function getProgram() {\n const pm = new Command()\n .name('docpress')\n .description('Build your doc website faster than light ⚡️⚡️⚡️')\n .version(`${pkg.version}`)\n .action(async (opts, _cmd) => {\n const optsWithDefaults = addDefaults(opts)\n const parsedOpts = parseOptions('global', optsWithDefaults)\n await fetchFn(parsedOpts)\n await prepareFn(parsedOpts)\n await buildFn()\n })\n .configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n showGlobalOptions: true,\n })\n .enablePositionalOptions()\n .passThroughOptions()\n .addCommand(fetchCmd)\n .addCommand(prepareCmd)\n .addCommand(buildCmd)\n\n addOptions(pm, [...fetchOpts, ...prepareOpts, ...globalOpts])\n\n return pm\n}\n\n/**\n * Entry point for the DocPress CLI\n * Initializes and runs the command parser\n */\nexport function main() {\n const pm = getProgram()\n pm.parseAsync(process.argv)\n}\n"],"names":["DOCPRESS_DIR","resolve","DOCS_DIR","INDEX_FILE","FORKS_FILE","VITEPRESS_CONFIG","VITEPRESS_THEME","VITEPRESS_USER_THEME","TEMPLATE_THEME","relativePathRegex","readmePathRegex","readmeDocsPathRegex","removeIdxRegex","checkHttpStatus","url","axios","error","prettify","s","opts","u","createDir","directory","clean","existsSync","rimrafSync","mkdirSync","err","isDir","path","statSync","isFile","extractFiles","paths","readdirSync","file","join","getMdFiles","basename","prettifyEnum","arr","acc","cur","idx","getUserInfos","username","readFileSync","getUserRepos","deepMerge","objects","obj","key","accValue","objValue","isObject","val","loadConfigFile","configPath","fullPath","fileContents","splitByComma","replaceRelativePath","updatedContent","_match","p1","p2","writeFileSync","replaceReadmePath","_p2","p3","getLogLevel","colorMap","log","msg","type","color","computedMsg","chalk","computedType","providers","configSchema","z","baseCliSchema","cliSchema","prepareConfigData","configData","validateFinalConfig","mergedConfig","globalOptsSchema","data","config","vitepressConfig","token","rest","preparedConfigData","buildOptsSchema","fetchOptsSchema","prepareOptsSchema","options","handleConfigFile","parsedConfig","parseOptions","cmd","configResult","res","errorMessage","fromError","addOptions","opt","getInfos","branch","octokit","Octokit","user","repos","getContributors","repository","message","repo","contributors","cloneRepo","name","projectDir","includes","git","simpleGit","item","appendFileSync","cpSync","rmSync","checkDoc","repoOwner","repoName","rootReadmeUrl","docsFolderUrl","docsReadmeUrl","rootReadmeStatus","docsFolderStatus","docsReadmeStatus","fetchDoc","reposFilter","generateInfos","getDoc","enhanceRepositories","enhancedRepos","computedBranch","projectPath","filtered","isRepoFiltered","getSparseCheckout","docsStatus","status","hasOnlyExclusions","filter","isExcluded","isIncluded","isFiltered","globalOpts","createOption","cmdName","fetchOpts","fetchCmd","createCommand","parsedOpts","main","usernames","gitProvider","finalRF","rf","suppressVueWarnings","callback","originalWarn","args","buildCmd","_opts","vitepressBuild","generateFile","src","dest","content","dirname","defaultVitepressConfig","getVitepressConfig","sidebar","nav","prepareDoc","extraHeaderPages","extraPublicContent","extraTheme","forks","websiteTitle","websiteTagline","repositories","internals","clone_url","privateRepo","fork","docpress","websiteInfos","index","transformDoc","finalSB","finalIndex","actualConfig","parseVitepressConfig","actualIndex","parseVitepressIndex","a","b","pages","addExtraPages","p","addContent","processForks","generateVitepressFiles","addSources","repoUrl","outputPath","fileName","sourcesContent","generateIndex","features","login","bio","title","tagline","generateFeatures","description","generateSidebarProject","sidebarPages","generateSidebarItems","value","element","filename","renameSync","parse","buildTree","files","tree","first","flattenTree","subtree","prefix","v","moveSourcesLast","sourcesIdx","sources","projectFiles","sourceFile","projectTree","sidebarItems","dir","fn","absolutePath","formattedFile","addForkPage","separator","header","text","frontmatter","contributions","owner","html_url","stargazers_count","YAML","source","contributor","f","e","readFile","relativePath","prepareOpts","prepareCmd","addDefaults","getProgram","pm","Command","pkg","_cmd","optsWithDefaults","fetchFn","prepareFn","buildFn"],"mappings":";;;;;;;;;;;;;;;GAKaA,IAAeC,EAAQ,QAAQ,IAAA,GAAO,UAAU;AAK7BA,EAAQ,QAAQ,IAAA,GAAO,4BAA4B;AAKzDA,EAAQ,QAAQ,IAAA,GAAO,qBAAqB;AAK/D,MAAMC,KAAWD,EAAQ,QAAQ,IAAA,GAAO,eAAe,GAKjDE,IAAaF,EAAQ,QAAQ,IAAA,GAAO,wBAAwB,GAK5DG,KAAaH,EAAQ,QAAQ,IAAA,GAAO,wBAAwB,GAK5DI,IAAmBJ,EAAQ,QAAQ,IAAA,GAAO,+BAA+B,GAKzEK,KAAkBL,EAAQ,QAAQ,IAAA,GAAO,2BAA2B,GAKpEM,KAAuBN,EAAQ,QAAQ,IAAA,GAAO,kCAAkC,GAMhFO,KAAiB,QAAQ,IAAI,aAAgB,gBACtDP,EAAQ,YAAY,SAAS,8BAA8B,IAC3DA,EAAQ,YAAY,SAAS,mBAAmB,GCrDvCQ,KAAoB,kCACpBC,KAAkB,oEAClBC,KAAsB,gDACtBC,KAAiB;ACa9B,eAAsBC,EAAgBC,GAA8B;AAClE,MAAI;AAEF,YADiB,MAAMC,GAAM,KAAKD,CAAG,GACrB;AAAA,EAClB,SAASE,GAAO;AACd,WAAOA,EAAM,UAAU,UAAUA,EAAM,UAAU;AAAA,EACnD;AACF;AAoBO,SAASC,EAASC,GAAWC,GAAoB;AACtD,MAAIC,IAAY;AAEhB,SAAID,GAAM,cACJD,EAAE,WAAW,GAAG,IAClBE,IAAIF,EAAE,MAAM,CAAC,IAEbE,IAAIF,GAGNE,IAAIA,EAAE,WAAW,KAAK,GAAG,IAGvBD,GAA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|
1
|
+
{"version":3,"file":"cli.js","sources":["../src/utils/const.ts","../src/utils/regex.ts","../src/utils/functions.ts","../src/utils/logger.ts","../src/schemas/global.ts","../src/schemas/build.ts","../src/schemas/fetch.ts","../src/schemas/prepare.ts","../src/utils/commands.ts","../src/lib/git.ts","../src/lib/fetch.ts","../src/commands/global.ts","../src/commands/fetch.ts","../src/commands/build.ts","../src/utils/templates.ts","../src/lib/vitepress.ts","../src/lib/prepare.ts","../src/commands/prepare.ts","../src/cli.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\n/**\n * Main directory for DocPress files\n */\nexport const DOCPRESS_DIR = resolve(process.cwd(), 'docpress')\n\n/**\n * Path to repositories information JSON file\n */\nexport const USER_REPOS_INFOS = resolve(process.cwd(), 'docpress/repositories.json')\n\n/**\n * Path to user information JSON file\n */\nexport const USER_INFOS = resolve(process.cwd(), 'docpress/owner.json')\n\n/**\n * Directory for documentation files\n */\nexport const DOCS_DIR = resolve(process.cwd(), 'docpress/docs')\n\n/**\n * Path to the main index file\n */\nexport const INDEX_FILE = resolve(process.cwd(), 'docpress/docs/index.md')\n\n/**\n * Path to the forks documentation file\n */\nexport const FORKS_FILE = resolve(process.cwd(), 'docpress/docs/forks.md')\n\n/**\n * Path to VitePress configuration file\n */\nexport const VITEPRESS_CONFIG = resolve(process.cwd(), 'docpress/.vitepress/config.ts')\n\n/**\n * Directory for VitePress theme\n */\nexport const VITEPRESS_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme')\n\n/**\n * Directory for user custom theme files\n */\nexport const VITEPRESS_USER_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme/extras')\n\n/**\n * Path to template theme files\n */\n// eslint-disable-next-line dot-notation\nexport const TEMPLATE_THEME = process.env['NODE_ENV'] === 'development'\n ? resolve(import.meta.dirname, '../../public/templates/theme')\n : resolve(import.meta.dirname, './templates/theme')\n","export const relativePathRegex = /\\[([^\\]]+)\\]\\(\\.\\.\\/([^)]+)\\)/g\nexport const readmePathRegex = /\\[([^\\]]+)\\]\\((?!\\.?\\/docs\\/|docs\\/|http|#)(\\.\\/)?([^/][^)]+)\\)/g\nexport const readmeDocsPathRegex = /\\[([^\\]]+)\\]\\((\\.?\\/docs\\/|docs\\/)([^)]*)\\)/g\nexport const removeIdxRegex = /^\\d{2}-/\n","import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'\nimport { basename, join, resolve } from 'node:path'\nimport axios from 'axios'\nimport { rimrafSync } from 'rimraf'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport type { getInfos } from '../lib/git.js'\nimport { DOCPRESS_DIR } from './const.js'\nimport { readmeDocsPathRegex, readmePathRegex, relativePathRegex, removeIdxRegex } from './regex.js'\n\n/**\n * Checks the HTTP status code of a URL\n *\n * @param url - URL to check\n * @returns HTTP status code (404 if not found, 500 for errors)\n */\nexport async function checkHttpStatus(url: string): Promise<number> {\n try {\n const response = await axios.head(url)\n return response.status\n } catch (error) {\n return error.response?.status || error.status || 500\n }\n}\n\n/**\n * Options for prettifying strings\n */\ninterface PrettifyOpts {\n mode?: 'capitalize' | 'uppercase' | 'lowercase'\n replaceDash?: boolean\n removeIdx?: boolean\n removeDot?: boolean\n removeExt?: boolean\n}\n\n/**\n * Formats a string based on specified options\n *\n * @param s - Input string to format\n * @param opts - Formatting options\n * @returns Formatted string\n */\nexport function prettify(s: string, opts: PrettifyOpts) {\n let u: string = ''\n\n if (opts?.removeDot) {\n if (s.startsWith('.')) {\n u = s.slice(1)\n } else {\n u = s\n }\n // Replace all remaining dots with dashes to ensure consistency\n u = u.replaceAll('.', '-')\n }\n\n if (opts?.removeIdx) {\n u = (u || s).replace(removeIdxRegex, '')\n }\n\n if (opts?.removeExt) {\n u = (u || s).split('.')[0]\n }\n\n if (opts?.replaceDash) {\n u = (u || s).replaceAll('-', ' ')\n }\n\n if (opts?.mode === 'capitalize') {\n u = (u || s).slice(0, 1).toUpperCase() + (u || s).slice(1).toLowerCase()\n } else if (opts?.mode === 'lowercase') {\n u = (u || s).toLowerCase()\n } else if (opts?.mode === 'uppercase') {\n u = (u || s).toUpperCase()\n }\n\n return u || s\n}\n\n/**\n * Creates a directory, optionally cleaning it first\n *\n * @param directory - Path to the directory to create\n * @param options - Options object\n * @param options.clean - Whether to clean the directory before creating it\n */\nexport function createDir(directory: string, { clean }: { clean?: boolean } = { clean: false }) {\n try {\n if (clean && existsSync(directory)) {\n rimrafSync(`${directory}/*`, { glob: true })\n }\n if (!existsSync(directory)) {\n mkdirSync(directory, { recursive: true })\n }\n } catch (err) {\n console.error(err)\n }\n}\n\n/**\n * Checks if a path is a directory\n *\n * @param path - Path to check\n * @returns True if path is a directory, false otherwise\n */\nexport function isDir(path: string) {\n try {\n return statSync(path).isDirectory()\n } catch (_error) {\n return false\n }\n}\n\n/**\n * Checks if a path is a file\n *\n * @param path - Path to check\n * @returns True if path is a file, false otherwise\n */\nexport function isFile(path: string) {\n try {\n return statSync(path).isFile()\n } catch (_error) {\n return false\n }\n}\n\n/**\n * Extracts a list of file paths from directories and files\n *\n * @param paths - Path or array of paths to extract files from\n * @returns Array of file paths\n */\nexport function extractFiles(paths: string[] | string): string[] {\n return (Array.isArray(paths) ? paths : [paths]).flatMap((path) => {\n if (isFile(path)) {\n return [path]\n }\n if (isDir(path)) {\n return readdirSync(path).flatMap(file => extractFiles(join(path, file)))\n }\n return []\n })\n}\n\n/**\n * Gets all markdown files from specified paths\n *\n * @param path - Array of paths to search for markdown files\n * @returns Array of markdown file paths\n */\nexport function getMdFiles(path: string[]) {\n return extractFiles(path).filter(file => basename(file).endsWith('.md'))\n}\n\n/**\n * Formats an array of strings into a readable comma-separated list\n *\n * @param arr - Array of strings to format\n * @returns Formatted string (e.g., \"a\", \"b\" or \"c\")\n */\nexport function prettifyEnum(arr: readonly string[]) {\n return arr.reduce((acc, cur, idx, arr) => {\n if (!idx) {\n return `\"${cur}\"`\n } else if (idx === arr.length - 1) {\n return `${acc} or \"${cur}\"`\n } else {\n return `${acc}, \"${cur}\"`\n }\n }, '')\n}\n\n/**\n * Gets user information from cached JSON file\n *\n * @param username - GitHub username\n * @returns User information object\n */\nexport function getUserInfos(username: GlobalOpts['usernames'][number]) {\n return JSON.parse(readFileSync(`${DOCPRESS_DIR}/user-${username}.json`).toString()) as Awaited<ReturnType<typeof getInfos>>['user']\n}\n\n/**\n * Gets repository information from cached JSON file\n *\n * @param username - GitHub username\n * @returns Array of enhanced repository objects\n */\nexport function getUserRepos(username: GlobalOpts['usernames'][number]) {\n return JSON.parse(readFileSync(`${DOCPRESS_DIR}/repos-${username}.json`).toString()) as EnhancedRepository[]\n}\n\n/**\n * Deep merges multiple objects\n *\n * @param objects - Objects to merge\n * @returns Merged object\n */\nexport function deepMerge<T extends Record<string, any> | null>(...objects: T[]): T {\n return objects.reduce((acc, obj) => {\n if (obj === null) {\n return acc\n }\n\n Object.keys(obj).forEach((key) => {\n const accValue = acc ? acc[key] : null\n const objValue = obj[key]\n\n if (isObject(accValue) && isObject(objValue)) {\n (acc as Record<string, any>)[key] = deepMerge(accValue, objValue)\n } else {\n (acc as Record<string, any>)[key] = objValue\n }\n })\n return acc\n }, {} as T)\n}\n\n/**\n * Checks if a value is an object (not an array or null)\n *\n * @param val - Value to check\n * @returns True if value is an object, false otherwise\n */\nexport function isObject(val: any): val is object {\n return val && typeof val === 'object' && !Array.isArray(val)\n}\n\n/**\n * Loads and parses a JSON configuration file\n *\n * @param configPath - Path to the configuration file\n * @returns Parsed configuration object or empty object if file doesn't exist\n */\nexport function loadConfigFile(configPath?: string) {\n if (!configPath) {\n return {}\n }\n try {\n const fullPath = resolve(process.cwd(), configPath)\n const fileContents = readFileSync(fullPath, 'utf8')\n return JSON.parse(fileContents)\n } catch (_error) {\n return {}\n }\n}\n\n/**\n * Splits a comma-separated string into an array of strings\n *\n * @param s - Comma-separated string\n * @returns Array of strings\n */\nexport function splitByComma(s: string) {\n return s.split(',')\n}\n\n/**\n * Replaces relative paths in markdown links with absolute URLs\n *\n * @param file - Path to the markdown file to process\n * @param url - Base URL to use for absolute links\n */\nexport function replaceRelativePath(file: string, url: string) {\n const fileContent = readFileSync(file, 'utf8')\n const updatedContent = fileContent.replace(relativePathRegex, (_match, p1, p2) => {\n return `[${p1}](${url}/${p2})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n\n/**\n * Processes README files to fix various link formats\n *\n * @param file - Path to the README file to process\n * @param url - Base URL to use for absolute links\n */\nexport function replaceReadmePath(file: string, url: string) {\n const readmeContent = readFileSync(file, 'utf8')\n const updatedContent = readmeContent\n .replace(readmePathRegex, (_match, p1, _p2, p3) => {\n return `[${p1}](${url}/${p3})`\n })\n .replace(readmeDocsPathRegex, (_match, p1, _p2, p3) => {\n return `[${p1}](${p3})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n","/* eslint-disable dot-notation */\nimport type { ColorName } from 'chalk'\nimport chalk from 'chalk'\n\n/**\n * Log message types\n */\ntype LogType = keyof Pick<Console, 'info' | 'warn' | 'error' | 'debug' | 'trace'> | 'success'\n\n/**\n * Mapping of log types to colors and levels\n */\ntype ColorMap = {\n [K in LogType]: {\n color: ColorName\n level: number\n }\n}\n\n/**\n * Gets the current log level from environment variables\n *\n * @returns Log level number (default: 30)\n */\nfunction getLogLevel() {\n return typeof Number(process.env['LOG_LEVEL']) === 'number' && !Number.isNaN(Number(process.env['LOG_LEVEL']))\n ? Number(process.env['LOG_LEVEL'])\n : 30\n}\n\n/**\n * Color mapping configuration for different log types\n */\nconst colorMap: ColorMap = {\n error: { color: 'red', level: 10 },\n warn: { color: 'yellow', level: 20 },\n info: { color: 'white', level: 30 },\n success: { color: 'green', level: 30 },\n trace: { color: 'white', level: 40 },\n debug: { color: 'blue', level: 50 },\n}\n\n/**\n * Logs a message with color formatting based on type and level\n *\n * @param msg - Message to log\n * @param type - Type of log message (info, warn, error, debug, trace, success)\n * @param color - Optional specific color to use instead of the default for the type\n */\nexport function log(msg: string, type: LogType = 'info', color?: ColorName) {\n const computedMsg = color ? chalk[color](msg) : chalk[colorMap[type].color](msg)\n const computedType = type === 'success' ? 'info' : type\n\n if (getLogLevel() >= colorMap[type].level) {\n console[computedType](computedMsg)\n }\n}\n","import { z } from 'zod'\nimport { loadConfigFile, prettifyEnum, splitByComma } from '../utils/functions.js'\nimport { log } from '../utils/logger.js'\n\n/**\n * List of supported Git providers\n */\nconst providers = ['github'] as const\n\n/**\n * Schema for the DocPress configuration file\n * Defines the structure and validation rules for the configuration\n */\nexport const configSchema = z.object({\n // Global\n usernames: z.string()\n .array()\n .describe('List of comma separated Git provider usernames used to collect data.'),\n // Fetch\n branch: z.string()\n .describe('Branch used to collect Git provider data.')\n .default('main'),\n gitProvider: z.enum(providers)\n .describe(`Git provider used to retrieve data. Values should be ${prettifyEnum(providers)}.`)\n .default('github'),\n reposFilter: z.string()\n .array()\n .describe('List of comma separated repositories to retrieve from Git provider. Default to all user\\'s public repositories.'),\n // Prepare\n extraHeaderPages: z.string()\n .array()\n .describe('List of comma separated additional files or directories to process Vitepress header pages.'),\n extraPublicContent: z.string()\n .array()\n .describe('List of comma separated additional files or directories to process Vitepress public folder.'),\n extraTheme: z.string()\n .array()\n .describe('List of comma separated additional files or directories to use as Vitepress theme.'),\n forks: z.boolean()\n .describe('Whether or not to create the dedicated fork page that aggregate external contributions.')\n .default(false),\n vitepressConfig: z.any()\n .describe('Path to the vitepress configuration file.'),\n websiteTitle: z.string()\n .describe('Website title.'),\n websiteTagline: z.string()\n .describe('Website tagline.'),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\n/**\n * Base CLI schema for parsing command line arguments\n * All fields are optional in this schema\n */\nexport const baseCliSchema = configSchema.partial().extend({\n config: z.string()\n .describe('Path to the docpress configuration file.')\n .optional(),\n token: z.string()\n .describe('Git provider token used to collect data.')\n .optional(),\n usernames: z.string()\n .describe(configSchema.shape.usernames.description || '')\n .optional(),\n reposFilter: z.string()\n .describe(configSchema.shape.reposFilter.description || '')\n .optional(),\n extraHeaderPages: z.string()\n .describe(configSchema.shape.extraHeaderPages.description || '')\n .optional(),\n extraPublicContent: z.string()\n .describe(configSchema.shape.extraPublicContent.description || '')\n .optional(),\n extraTheme: z.string()\n .describe(configSchema.shape.extraTheme.description || '')\n .optional(),\n vitepressConfig: z.string()\n .describe(configSchema.shape.vitepressConfig.description || '')\n .optional(),\n})\n\nexport type RawCli = z.infer<typeof baseCliSchema>\n\n/**\n * CLI schema with transformations applied to handle string-to-array conversions\n */\nexport const cliSchema = configSchema\n .partial()\n .extend({\n config: z.string()\n .describe('Path to the docpress configuration file.')\n .optional(),\n token: z.string()\n .describe('Git provider token used to collect data.')\n .optional(),\n usernames: z.string()\n .describe(configSchema.shape.usernames.description || '')\n .transform(splitByComma)\n .optional(),\n reposFilter: z.string()\n .describe(configSchema.shape.reposFilter.description || '')\n .transform(splitByComma)\n .optional(),\n extraHeaderPages: z.string()\n .describe(configSchema.shape.extraHeaderPages.description || '')\n .transform(splitByComma)\n .optional(),\n extraPublicContent: z.string()\n .describe(configSchema.shape.extraPublicContent.description || '')\n .transform(splitByComma)\n .optional(),\n extraTheme: z.string()\n .describe(configSchema.shape.extraTheme.description || '')\n .transform(splitByComma)\n .optional(),\n vitepressConfig: z.string()\n .describe(configSchema.shape.vitepressConfig.description || '')\n .optional(),\n })\n\nexport type Cli = z.infer<typeof cliSchema>\n\n// Helper functions to reduce complexity\n/**\n * Prepares configuration data by converting string values to arrays when needed\n *\n * @param configData - Raw configuration data to process\n * @returns Processed configuration data with proper array types\n */\nfunction prepareConfigData(configData: any) {\n if (!configData) return {}\n\n // Convert arrays that might be strings\n if (configData.usernames && typeof configData.usernames === 'string') {\n configData.usernames = [configData.usernames]\n }\n if (configData.reposFilter && typeof configData.reposFilter === 'string') {\n configData.reposFilter = [configData.reposFilter]\n }\n if (configData.extraHeaderPages && typeof configData.extraHeaderPages === 'string') {\n configData.extraHeaderPages = [configData.extraHeaderPages]\n }\n if (configData.extraPublicContent && typeof configData.extraPublicContent === 'string') {\n configData.extraPublicContent = [configData.extraPublicContent]\n }\n if (configData.extraTheme && typeof configData.extraTheme === 'string') {\n configData.extraTheme = [configData.extraTheme]\n }\n\n return configData\n}\n\n/**\n * Validates the final merged configuration to ensure required fields are present\n *\n * @param mergedConfig - The merged configuration to validate\n * @returns The validated configuration if it passes validation\n * @throws Error if required fields are missing\n */\nfunction validateFinalConfig(mergedConfig: any) {\n // Ensure usernames exists\n if (!mergedConfig.usernames?.length) {\n throw new Error('The usernames field is required')\n }\n\n return mergedConfig\n}\n\n/**\n * Schema for global options that combines CLI arguments and configuration files\n * Applies transformations to merge different config sources and validate the result\n */\nexport const globalOptsSchema = cliSchema\n .partial()\n .transform((data) => {\n try {\n const { config, vitepressConfig, token, ...rest } = data\n\n log(`Debug: Schema transform input: ${JSON.stringify(data)}`, 'debug')\n\n // Load configuration from file\n const configData = loadConfigFile(config)\n const preparedConfigData = prepareConfigData(configData)\n\n // Create final config\n const mergedConfig = {\n forks: false,\n ...preparedConfigData,\n ...rest,\n ...(vitepressConfig\n ? {\n vitepressConfig: {\n ...(loadConfigFile(vitepressConfig) || {}),\n ...(preparedConfigData.vitepressConfig || {}),\n },\n }\n : {}),\n }\n\n log(`Debug: Final merged config: ${JSON.stringify(mergedConfig)}`, 'debug')\n\n return validateFinalConfig({ ...mergedConfig, token })\n } catch (error) {\n // Handle errors gracefully\n log(` An error occurred while checking configuration.`, 'error')\n if (error instanceof Error) {\n log(` ${error.message}`, 'error')\n } else {\n log(` ${JSON.stringify(error, null, 2)}`, 'error')\n }\n process.exit(1)\n }\n })\n\nexport type GlobalOpts = Required<Pick<z.infer<typeof globalOptsSchema>, 'branch' | 'gitProvider'>>\n & Omit<z.infer<typeof globalOptsSchema>, 'branch' | 'gitProvider'>\n","import type { z } from 'zod'\nimport { cliSchema } from './global.js'\n\n/**\n * Schema for build command options\n * Currently empty as build doesn't require specific options\n */\nexport const buildOptsSchema = cliSchema\n .pick({})\n\nexport type BuildOpts = z.infer<typeof buildOptsSchema>\n","import { cliSchema } from './global.js'\nimport type { GlobalOpts } from './global.js'\n\n/**\n * Schema for fetch command options\n * Includes options related to Git repository fetching\n */\nexport const fetchOptsSchema = cliSchema\n .pick({\n branch: true,\n config: true,\n gitProvider: true,\n reposFilter: true,\n token: true,\n usernames: true,\n })\n\n/**\n * Type for fetch options\n */\nexport type FetchOpts = GlobalOpts\n\n/**\n * Type for fetch options with username instead of usernames array\n */\nexport type FetchOptsUser = Omit<FetchOpts, 'usernames'> & { username: FetchOpts['usernames'][number] }\n","import { cliSchema } from './global.js'\nimport type { GlobalOpts } from './global.js'\n\n/**\n * Schema for prepare command options\n * Includes options related to documentation preparation and customization\n */\nexport const prepareOptsSchema = cliSchema\n .pick({\n extraHeaderPages: true,\n extraPublicContent: true,\n extraTheme: true,\n config: true,\n gitProvider: true,\n reposFilter: true,\n token: true,\n usernames: true,\n vitepressConfig: true,\n })\n\n/**\n * Type for prepare options\n */\nexport type PrepareOpts = GlobalOpts\n","/* eslint-disable dot-notation */\nimport type { Command, Option } from 'commander'\nimport { fromError } from 'zod-validation-error'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport { configSchema, globalOptsSchema } from '../schemas/global.js'\nimport type { BuildOpts } from '../schemas/build.js'\nimport { buildOptsSchema } from '../schemas/build.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { fetchOptsSchema } from '../schemas/fetch.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { prepareOptsSchema } from '../schemas/prepare.js'\nimport { loadConfigFile } from './functions.js'\nimport { log } from './logger.js'\n\n/**\n * Type definition for command names\n */\ntype Cmd = 'fetch' | 'build' | 'prepare' | 'global'\n\n/**\n * Interface mapping command names to their option types\n */\ninterface Options {\n build: BuildOpts\n fetch: FetchOpts\n prepare: PrepareOpts\n global: GlobalOpts\n}\n\n/**\n * Mapping of command names to their schema validators\n */\nexport const options = {\n build: buildOptsSchema,\n fetch: fetchOptsSchema,\n prepare: prepareOptsSchema,\n global: globalOptsSchema,\n}\n\n/**\n * Handles loading and parsing of the configuration file\n *\n * @param configPath - Path to the configuration file\n * @param token - Optional GitHub token\n * @returns Parsed configuration data or null if loading/parsing failed\n */\nfunction handleConfigFile(configPath: string, token?: string) {\n const configData = loadConfigFile(configPath)\n if (!configData) return null\n\n // No need for a try/catch here since we're handling errors at a higher level\n const parsedConfig = configSchema.partial().safeParse(configData)\n if (parsedConfig.success) {\n return {\n ...parsedConfig.data,\n config: configPath,\n token: token || undefined,\n }\n }\n\n return null\n}\n\n/**\n * Parses and validates command options based on the command type\n *\n * @param cmd - The command name ('fetch', 'build', 'prepare', or 'global')\n * @param opts - Raw options from the command line\n * @returns Validated and processed options for the specified command\n */\nexport function parseOptions<T extends Cmd>(cmd: T, opts: Record<string, unknown>): Options[T] {\n log(`Initializing Docpress...`, 'info', 'blue')\n log(`\\n\\n-> Checking for required environment settings and configurations.`, 'info')\n log(` Debug info - opts: ${JSON.stringify(opts)}`, 'debug')\n log(` Debug info - options[cmd]: ${cmd}`, 'debug')\n\n try {\n // Special handling for config file\n if (cmd === 'global' && typeof opts['config'] === 'string') {\n const configResult = handleConfigFile(\n opts['config'],\n typeof opts['token'] === 'string' ? opts['token'] : undefined,\n )\n if (configResult) {\n // Force type assertion since we know the structure will match\n return configResult as unknown as Options[T]\n }\n }\n\n const res = options[cmd].safeParse(opts)\n if (!res.success) {\n try {\n const errorMessage = fromError(res.error).toString()\n log(` An error occurred while checking configuration.\\n ${errorMessage}`, 'error')\n } catch {\n // Fallback for incompatibility between zod-validation-error and Zod v4\n log(` An error occurred while checking configuration.\\n ${JSON.stringify(res.error, null, 2)}`, 'error')\n }\n process.exit(1)\n }\n log(' Setup complete! Ready to process your documentation.', 'info')\n return res.data as Options[T]\n } catch (error) {\n log(` An error occurred while processing options.`, 'error')\n if (error instanceof Error) {\n log(` ${error.message}`, 'error')\n } else {\n log(` ${JSON.stringify(error, null, 2)}`, 'error')\n }\n process.exit(1)\n }\n}\n\n/**\n * Adds option definitions to a Command instance\n *\n * @param cmd - The Commander Command instance\n * @param opts - Array of option definitions to add\n * @returns The Command instance with options added\n */\nexport function addOptions(cmd: Command, opts: Option[]) {\n for (const opt of opts) {\n cmd.addOption(opt)\n }\n return cmd\n}\n","import { appendFileSync, cpSync, rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { Octokit } from '@octokit/rest'\nimport { simpleGit } from 'simple-git'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { createDir } from '../utils/functions.js'\nimport { log } from '../utils/logger.js'\nimport type { EnhancedRepository } from './fetch.js'\n\n/**\n * Fetches user and repository information from GitHub\n *\n * @param options - Options for retrieving GitHub data\n * @param options.username - GitHub username\n * @param options.token - GitHub API token\n * @param options.branch - Branch to use for documentation\n * @returns Object containing user information, repositories, and branch\n */\nexport async function getInfos({ username, token, branch }: Pick<FetchOpts, 'branch'> & Pick<GlobalOpts, 'token'> & { username: GlobalOpts['usernames'][number] }) {\n log(` Get infos for username '${username}'.`, 'info')\n const octokit = new Octokit({ auth: token })\n log(` Get user infos.`, 'debug')\n const { data: user } = await octokit.rest.users.getByUsername({ username })\n log(` Get repositories infos.`, 'debug')\n const { data: repos } = await octokit.rest.repos.listForUser({ username, sort: 'full_name', per_page: 500 })\n\n return { user, repos, branch }\n}\n\n/**\n * Gets contributors for a repository\n *\n * @param options - Options for retrieving contributors\n * @param options.repository - Repository information\n * @param options.token - GitHub API token\n * @returns Object with source repository and contributors list\n */\nexport async function getContributors({\n repository,\n token,\n}: {\n repository: EnhancedRepository\n token: GlobalOpts['token']\n}) {\n log(` Get contributors infos for repository '${repository.name}'.`, 'info')\n const octokit = new Octokit({\n auth: token,\n log: {\n debug: () => {},\n info: () => {},\n warn: (message) => {\n if (!message.includes('404')) console.warn(message)\n },\n error: (message) => {\n if (!message.includes('404')) console.error(message)\n },\n },\n })\n const { data: repo } = await octokit.rest.repos.get({\n owner: repository.owner.login,\n repo: repository.name,\n })\n if (!repo.source?.owner?.login) {\n return { source: repo.source, contributors: [] }\n }\n const contributors: Array<any> = []\n try {\n for await (const { data } of octokit.paginate.iterator(\n octokit.rest.repos.listContributors,\n {\n owner: repo.source.owner.login,\n repo: repo.parent?.name ?? repo.name,\n per_page: 500,\n },\n )) {\n contributors.push(...data)\n }\n } catch (error) {\n log(\n ` Failed to get contributors infos for repository '${repository.name}'. Error : ${error.message}`,\n 'warn',\n )\n return { source: repo.source, contributors: [] }\n }\n\n return { source: repo.source, contributors }\n}\n\n/**\n * Clones a repository with sparse checkout\n *\n * @param name - Repository name\n * @param url - Repository URL\n * @param projectDir - Directory to clone into\n * @param branch - Branch to clone\n * @param includes - Patterns to include in sparse checkout\n */\nexport async function cloneRepo(name: string, url: string, projectDir: string, branch: string, includes: string[]) {\n createDir(projectDir, { clean: true })\n\n try {\n const git = simpleGit({ baseDir: projectDir })\n await git.init()\n .addConfig('core.sparseCheckout', 'true', true, 'local')\n .addRemote('origin', url)\n\n for (const item of includes) {\n log(` Add '${item}' to '${name}' sparse-checkout file.`, 'debug')\n appendFileSync(resolve(projectDir, '.git/info/sparse-checkout'), `${item}\\n`, 'utf8')\n }\n\n log(` Clone repository '${name}'.`, 'info')\n await git.pull('origin', branch)\n\n if (includes.some(item => item.includes('docs'))) {\n cpSync(resolve(projectDir, 'docs'), projectDir, { recursive: true })\n rmSync(resolve(projectDir, 'docs'), { recursive: true })\n }\n rmSync(resolve(projectDir, '.git'), { recursive: true })\n } catch (error) {\n log(` Error when cloning repository: ${error}.`, 'error')\n }\n}\n","import { resolve } from 'node:path'\nimport { writeFileSync } from 'node:fs'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport type { FetchOpts, FetchOptsUser } from '../schemas/fetch.js'\nimport { checkHttpStatus, prettify } from '../utils/functions.js'\nimport { DOCPRESS_DIR, DOCS_DIR } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport { cloneRepo, getInfos } from './git.js'\n\n/**\n * Enhanced repository type with DocPress-specific metadata\n */\nexport type EnhancedRepository = Awaited<ReturnType<typeof getInfos>>['repos'][number] & {\n docpress: {\n branch: string\n filtered: boolean\n includes: string[]\n projectPath: string\n raw_url: string\n replace_url: string\n }\n}\n\n/**\n * Checks for the existence of documentation files in a repository\n *\n * @param repoOwner - Owner of the repository (username)\n * @param repoName - Name of the repository\n * @param branch - Branch to check for documentation\n * @returns Object containing HTTP status codes for different documentation paths\n */\nexport async function checkDoc(repoOwner: GlobalOpts['usernames'][number], repoName: string, branch: FetchOpts['branch']) {\n const rootReadmeUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/README.md`\n const docsFolderUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/docs`\n const docsReadmeUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/docs/01-readme.md`\n\n const rootReadmeStatus = await checkHttpStatus(rootReadmeUrl)\n const docsFolderStatus = await checkHttpStatus(docsFolderUrl)\n const docsReadmeStatus = await checkHttpStatus(docsReadmeUrl)\n\n return {\n rootReadmeStatus,\n docsFolderStatus,\n docsReadmeStatus,\n }\n}\n\n/**\n * Fetches documentation from a user's repositories\n *\n * @param options - Options for fetching documentation\n * @param options.username - GitHub username\n * @param options.branch - Branch to use for documentation\n * @param options.reposFilter - Optional filter for repositories\n * @param options.token - GitHub API token\n */\nexport async function fetchDoc({ username, branch, reposFilter, token }: FetchOptsUser) {\n await getInfos({ username, token, branch })\n .then(async ({ user, repos, branch }) => generateInfos(user, repos, branch, reposFilter))\n .then(async ({ repos }) => getDoc(repos, reposFilter))\n}\n\n/**\n * Enhances repository information with DocPress metadata\n *\n * @param repos - List of repositories from Git provider\n * @param branch - Branch to use for documentation\n * @param reposFilter - Optional filter for repositories\n * @returns Array of enhanced repositories with DocPress metadata\n */\nexport async function enhanceRepositories(repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n const enhancedRepos: EnhancedRepository[] = []\n\n await Promise.all(\n repos.map(async (repo) => {\n const computedBranch = branch ?? repo.default_branch ?? 'main'\n const projectPath = resolve(DOCS_DIR, prettify(repo.name, { removeDot: true }))\n const filtered = isRepoFiltered(repo, reposFilter)\n let includes: string[] = []\n\n if (!repo.fork && !repo.private && !filtered) {\n includes = await getSparseCheckout(repo, computedBranch)\n }\n\n enhancedRepos.push({\n ...repo,\n docpress: {\n filtered,\n branch: computedBranch,\n includes,\n projectPath,\n raw_url: `https://raw.githubusercontent.com/${repo.owner.login}/${repo.name}/${computedBranch}`,\n replace_url: `https://github.com/${repo.owner.login}/${repo.name}/tree/${computedBranch}`,\n },\n })\n }),\n )\n\n return enhancedRepos\n}\n\n/**\n * Determines which files to include in the sparse checkout based on repository structure\n *\n * @param repo - Repository information\n * @param branch - Branch to check for documentation\n * @returns Array of file patterns to include in sparse checkout\n */\nexport async function getSparseCheckout(repo: Awaited<ReturnType<typeof getInfos>>['repos'][number], branch: FetchOpts['branch']) {\n const docsStatus = await checkDoc(repo.owner.login, repo.name, branch)\n\n const includes: string[] = []\n if (Object.values(docsStatus).every(status => status === 404) || !repo.size) {\n return []\n }\n if (docsStatus.docsFolderStatus !== 404) {\n includes.push('docs/*')\n }\n if (docsStatus.docsFolderStatus === 404 || docsStatus.docsReadmeStatus === 404) {\n includes.push('README.md', '!*/**/README.md')\n }\n return includes\n}\n\n/**\n * Generates and saves user and repository information\n *\n * @param user - User information from Git provider\n * @param repos - List of repositories from Git provider\n * @param branch - Branch to use for documentation\n * @param reposFilter - Optional filter for repositories\n * @returns Object containing user and enhanced repository information\n */\nexport async function generateInfos(user: Awaited<ReturnType<typeof getInfos>>['user'], repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n writeFileSync(`${DOCPRESS_DIR}/user-${user.login}.json`, JSON.stringify(user, null, 2))\n\n const enhancedRepos = await enhanceRepositories(repos, branch, reposFilter)\n writeFileSync(`${DOCPRESS_DIR}/repos-${user.login}.json`, JSON.stringify(enhancedRepos, null, 2))\n\n return { user, repos: enhancedRepos }\n}\n\n/**\n * Fetches documentation from repositories\n *\n * @param repos - List of enhanced repositories\n * @param reposFilter - Optional filter for repositories\n */\nexport async function getDoc(repos?: EnhancedRepository[], reposFilter?: FetchOpts['reposFilter']) {\n if (!repos) {\n log(` No repository respect docpress rules.`, 'warn')\n return\n }\n\n await Promise.all(\n repos\n .filter(repo => !isRepoFiltered(repo, reposFilter))\n .map(async (repo) => {\n await cloneRepo(repo.name, repo.clone_url as string, repo.docpress.projectPath, repo.docpress.branch, repo.docpress.includes)\n }),\n )\n}\n\n/**\n * Determines if a repository should be filtered out based on filter rules\n *\n * @param repo - Repository information\n * @param reposFilter - Optional filter for repositories\n * @returns True if the repository should be filtered out, false otherwise\n */\nexport function isRepoFiltered(repo: EnhancedRepository | Awaited<ReturnType<typeof getInfos>>['repos'][number], reposFilter?: FetchOpts['reposFilter']) {\n const hasOnlyExclusions = reposFilter?.every((filter: string) => filter.startsWith('!'))\n const isExcluded = reposFilter?.filter((filter: string) => filter.startsWith('!'))\n .some((filter: string) => repo.name === filter.substring(1))\n const isIncluded = !reposFilter\n || reposFilter?.filter((filter: string) => !filter.startsWith('!')).includes(repo.name)\n || (repo.fork && !isExcluded)\n || (hasOnlyExclusions && !isExcluded)\n\n const isFiltered = isExcluded || !isIncluded\n\n if ('docpress' in repo && !repo.docpress.includes.length) {\n return true\n }\n\n if (!!repo.clone_url && !repo.private && !isFiltered) {\n return false\n }\n return true\n}\n","import { createOption } from 'commander'\nimport { baseCliSchema } from '../schemas/global.js'\n\n/**\n * Global command line options shared across all commands\n */\nexport const globalOpts = [\n createOption('-C, --config <string>', baseCliSchema.shape.config.description),\n createOption('-T, --token <string>', baseCliSchema.shape.token.description),\n createOption('-U, --usernames <string>', baseCliSchema.shape.usernames.description),\n]\n","import { createCommand, createOption } from 'commander'\nimport { createDir } from '../utils/functions.js'\nimport { DOCPRESS_DIR } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { fetchDoc } from '../lib/fetch.js'\nimport { configSchema } from '../schemas/global.js'\nimport { globalOpts } from './global.js'\n\n/**\n * Command name for the fetch operation\n */\nconst cmdName = 'fetch'\n\n/**\n * Command line options specific to the fetch command\n */\nexport const fetchOpts = [\n createOption('-b, --branch <string>', configSchema.shape.branch.description)\n .default(configSchema.shape.branch.default),\n createOption('-g, --git-provider <string>', configSchema.shape.gitProvider.description)\n .default(configSchema.shape.gitProvider.default),\n createOption('-r, --repos-filter <string>', configSchema.shape.reposFilter.description),\n]\n\n/**\n * The fetch command definition for Commander\n */\nexport const fetchCmd = addOptions(createCommand(cmdName), [...fetchOpts, ...globalOpts])\n .description('Fetch docs with the given username(s) and git provider.')\n .action(async (opts) => {\n const parsedOpts = parseOptions(cmdName, opts)\n await main(parsedOpts)\n })\n\n/**\n * Main function to execute the fetch command\n *\n * @param opts - Validated fetch options\n */\nexport async function main(opts: FetchOpts) {\n const { usernames, reposFilter, token, branch, gitProvider } = opts\n log(`\\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, 'info')\n\n createDir(DOCPRESS_DIR, { clean: true })\n for (const username of usernames) {\n const finalRF = usernames.length > 1\n ? reposFilter?.filter((rf: string) => rf.startsWith(`${username}/`)).map((rf: string) => rf.replace(`${username}/`, ''))\n : reposFilter\n await fetchDoc({ username, branch, reposFilter: finalRF, gitProvider, token })\n }\n}\n","import { build as vitepressBuild } from 'vitepress'\nimport type { UserConfig } from 'vitepress'\nimport { withMermaid } from 'vitepress-plugin-mermaid'\nimport { createCommand } from 'commander'\nimport { addOptions } from '../utils/commands.js'\nimport { DOCPRESS_DIR } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport { globalOpts } from './global.js'\n\n/**\n * Suppress specific Vue warnings during the build process\n *\n * @param callback - Function to execute while warnings are suppressed\n * @returns The result of the callback function\n */\nexport async function suppressVueWarnings<T>(callback: () => Promise<T>): Promise<T> {\n // Store the original console.warn\n const originalWarn = console.warn\n\n // Override console.warn to suppress specific Vue warnings\n console.warn = function (...args) {\n if (\n args.length > 0\n && typeof args[0] === 'string'\n && (args[0].includes('[Vue warn]: Invalid watch source:')\n || args[0].includes('{ open: false }'))\n ) {\n // Skip this warning\n return\n }\n // Pass other warnings to the original console.warn\n originalWarn.apply(console, args)\n }\n\n try {\n // Execute the callback with warnings suppressed\n return await callback()\n } finally {\n // Restore the original console.warn\n console.warn = originalWarn\n }\n}\n\n/**\n * Command name for the build operation\n */\nconst cmdName = 'build'\n\n/**\n * Command line options specific to the build command (none currently)\n */\nexport const buildOpts = []\n\n/**\n * The build command definition for Commander\n */\nexport const buildCmd = addOptions(createCommand(cmdName), globalOpts)\n .description('Build vitepress website.')\n .action(async (_opts) => {\n await main()\n })\n\n/**\n * Main function to execute the build command\n * Builds the VitePress static site\n */\nexport async function main() {\n log(`\\n-> Start building Vitepress website.\\n\\n`, 'info')\n\n try {\n // Build VitePress with Vue warnings suppressed\n await suppressVueWarnings(async () => {\n await vitepressBuild(DOCPRESS_DIR, {\n onAfterConfigResolve(siteConfig) {\n withMermaid(siteConfig as unknown as UserConfig)\n },\n })\n })\n\n log(`\\n\\nDocpress build succedeed.`, 'success')\n } catch (error) {\n log(`\\n\\nDocpress build failed : ${error}`, 'error')\n process.exit(1)\n }\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { createDir } from './functions.js'\n\n/**\n * Generates a file by copying content from source to destination\n *\n * @param src - Path to the source file\n * @param dest - Path to the destination file\n */\nexport function generateFile(src: string, dest: string) {\n const content = readFileSync(src, { encoding: 'utf8' })\n createDir(dirname(dest))\n writeFileSync(dest, content)\n}\n","import type { defineConfig } from 'vitepress'\nimport { deepMerge } from '../utils/functions.js'\nimport type { Page, SidebarProject } from './prepare.js'\n\n/**\n * Default VitePress configuration\n */\nconst defaultVitepressConfig: ReturnType<typeof defineConfig> = {\n base: '/',\n lang: 'en-US',\n vite: {\n publicDir: '../public',\n },\n title: 'Home',\n description: 'Docpress',\n srcDir: './docs',\n cleanUrls: false,\n ignoreDeadLinks: 'localhostLinks',\n themeConfig: {\n outline: [2, 3],\n search: {\n provider: 'local',\n options: {\n translations: {\n button: {\n buttonText: 'Search...',\n buttonAriaLabel: 'Search',\n },\n modal: {\n backButtonTitle: 'erase search',\n displayDetails: 'show details',\n noResultsText: 'No results for : ',\n resetButtonTitle: 'cancel search',\n footer: {\n selectText: 'go to',\n navigateText: 'navigate in results',\n closeText: 'close',\n },\n },\n },\n },\n },\n },\n}\n\n/**\n * Generates VitePress configuration by merging default and custom configs\n *\n * @param sidebar - Sidebar configuration\n * @param nav - Navigation configuration\n * @param vitepressConfig - Optional custom VitePress configuration\n * @returns Merged VitePress configuration\n */\nexport function getVitepressConfig(sidebar: SidebarProject[], nav: Page[], vitepressConfig?: ReturnType<typeof defineConfig>): Partial<ReturnType<typeof defineConfig>> {\n const config = vitepressConfig\n ? deepMerge(defaultVitepressConfig, vitepressConfig, { themeConfig: { sidebar, nav } })\n : deepMerge(defaultVitepressConfig, { themeConfig: { sidebar, nav } })\n return config\n}\n","import { basename, dirname, parse, resolve } from 'node:path'\nimport { appendFileSync, cpSync, existsSync, readdirSync, renameSync, statSync, writeFileSync } from 'node:fs'\nimport { readFile } from 'node:fs/promises'\nimport YAML from 'yaml'\nimport type { defineConfig } from 'vitepress'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { generateFile } from '../utils/templates.js'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport { createDir, extractFiles, getMdFiles, getUserInfos, getUserRepos, prettify, replaceReadmePath, replaceRelativePath } from '../utils/functions.js'\nimport { DOCPRESS_DIR, DOCS_DIR, FORKS_FILE, INDEX_FILE, TEMPLATE_THEME, VITEPRESS_CONFIG, VITEPRESS_THEME, VITEPRESS_USER_THEME } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport type { EnhancedRepository } from './fetch.js'\nimport type { getInfos } from './git.js'\nimport { getContributors } from './git.js'\nimport { getVitepressConfig } from './vitepress.js'\n\n/**\n * Represents a navigation page item with text and link\n */\nexport interface Page {\n text: string\n link: string\n}\n\n/**\n * Represents a sidebar project with nested items\n */\nexport interface SidebarProject {\n text: string\n collapsed: boolean\n items: (Page | SidebarProject)[]\n}\n\n/**\n * Represents a feature to display on the index page\n */\nexport interface Feature {\n title: string\n details: string\n link: string\n}\n\n/**\n * Represents the structure of the VitePress index page\n */\nexport interface Index {\n layout: string\n hero: {\n name: string\n tagline?: string\n }\n /** List of features to display */\n features: Feature[]\n}\n\n/**\n * Prepares the documentation structure for a user's repositories\n *\n * @param options - Options for documentation preparation\n * @param options.extraHeaderPages - Array of paths to additional header pages\n * @param options.extraPublicContent - Array of paths to additional public content\n * @param options.extraTheme - Array of paths to additional theme files\n * @param options.vitepressConfig - Path to the VitePress configuration file\n * @param options.forks - Flag to include forked repositories\n * @param options.token - GitHub token for API access\n * @param options.username - GitHub username to fetch repositories for\n * @param options.websiteTitle - Custom title for the documentation website\n * @param options.websiteTagline - Custom tagline for the documentation website\n */\nexport async function prepareDoc({ extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig, forks, token, username, websiteTitle, websiteTagline }: Omit<PrepareOpts, 'usernames' | 'branch' | 'gitProvider' | 'reposFilter'> & { username: PrepareOpts['usernames'][number] }) {\n const user = getUserInfos(username)\n const repositories = getUserRepos(username)\n .reduce(({ internals, forks }: { internals: EnhancedRepository[], forks: EnhancedRepository[] }, cur) => {\n const { clone_url, private: privateRepo, fork, docpress } = cur\n if (clone_url && !privateRepo && !docpress.filtered) {\n if (!fork && docpress.includes.length) {\n return { internals: [...internals, cur], forks }\n } else if (fork) {\n return { internals, forks: [...forks, cur] }\n }\n }\n return { internals, forks }\n }, { internals: [], forks: [] })\n\n const websiteInfos = { title: websiteTitle, tagline: websiteTagline }\n const { index, sidebar } = transformDoc(repositories.internals, user, websiteInfos)\n\n let finalSB\n let finalIndex\n if (existsSync(INDEX_FILE) && existsSync(VITEPRESS_CONFIG)) {\n const actualConfig = await parseVitepressConfig(VITEPRESS_CONFIG)\n const actualIndex = await parseVitepressIndex(INDEX_FILE)\n finalSB = [\n ...(actualConfig.themeConfig?.sidebar as SidebarProject[] ?? []),\n ...sidebar,\n ].sort((a, b) => a.text.localeCompare(b.text))\n finalIndex = {\n ...index,\n features: [\n ...actualIndex.features,\n ...index.features,\n ].sort((a, b) => a.title.localeCompare(b.title)),\n }\n } else {\n finalSB = sidebar\n finalIndex = index\n }\n const nav: Page[] = []\n\n if (extraHeaderPages) {\n const pages = addExtraPages(extraHeaderPages)\n if (forks) {\n nav.push(...pages.filter(p => p.link !== '/forks'))\n } else {\n nav.push(...pages)\n }\n }\n if (extraPublicContent) {\n log(` Add extras Vitepress public folder content.`, 'info')\n addContent(extraPublicContent, resolve(DOCPRESS_DIR, 'public'))\n }\n if (extraTheme) {\n log(` Add extras Vitepress theme files.`, 'info')\n addContent(extraTheme, resolve(VITEPRESS_USER_THEME))\n }\n if (forks && username.length) {\n log(` Add fork page to display external contributions.`, 'info')\n await processForks(repositories.forks, username, token)\n nav.push({ text: 'Forks', link: '/forks' })\n }\n\n const config = getVitepressConfig(finalSB, nav, vitepressConfig)\n\n generateVitepressFiles(config, finalIndex)\n}\n\n/**\n * Adds a source reference section to a markdown file\n *\n * @param repoUrl - URL of the GitHub repository\n * @param outputPath - Path to the markdown file where sources will be added\n */\nexport function addSources(repoUrl: string, outputPath: string) {\n const fileName = basename(outputPath)\n const title = prettify(fileName, { mode: 'lowercase', removeIdx: true }) === 'readme.md' ? '\\n## Sources' : '# Sources'\n\n const sourcesContent = `${title}\\n\\nTake a look at the [project sources](${repoUrl}).\\n`\n\n appendFileSync(outputPath, sourcesContent, 'utf8')\n}\n\n/**\n * Information about website title and tagline\n */\nexport interface WebsiteInfos {\n title?: string\n tagline?: string\n}\n\n/**\n * Generates the index page content for the documentation site\n *\n * @param features - Array of features to display on the homepage\n * @param user - User information retrieved from GitHub\n * @param websiteInfos - Custom title and tagline information\n * @returns An object with index page configuration\n */\nexport function generateIndex(features: Feature[], user: ReturnType<typeof getUserInfos>, websiteInfos: WebsiteInfos) {\n const { name, login, bio } = user\n const { title, tagline } = websiteInfos\n\n const hero = title\n ? { name: title, tagline }\n : { name: name ? `${name}'s projects` : `${login}'s projects`, tagline: bio ?? 'Robots are everywhere 🤖' }\n\n return {\n layout: 'home',\n hero,\n features,\n }\n}\n\n/**\n * Generates feature cards for the homepage\n *\n * @param repoName - Name of the repository\n * @param description - Description of the repository\n * @param features - Optional existing features to append to\n * @returns Array of feature objects for the homepage\n */\nexport function generateFeatures(repoName: string, description: string, features?: Feature[]) {\n const content = {\n title: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n details: description,\n link: `/${prettify(repoName, { removeDot: true })}/introduction`,\n }\n\n return features ? [...features, content] : [content]\n}\n\n/**\n * Generates a sidebar project entry for the documentation navigation\n *\n * @param repoName - Name of the repository\n * @param sidebarPages - Array of sidebar pages to include in this project\n * @returns A sidebar project configuration object\n */\nexport function generateSidebarProject(repoName: string, sidebarPages: (SidebarProject | Page)[]) {\n return {\n text: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n collapsed: true,\n items: sidebarPages,\n }\n}\n\n/**\n * Generates sidebar page entries for the documentation navigation\n *\n * @param repoName - Name of the repository\n * @param fileName - Name of the file\n * @param sidebarPages - Optional existing sidebar pages to append to\n * @returns Array of page objects for the sidebar\n */\nexport function generateSidebarPages(repoName: string, fileName: string, sidebarPages?: Page[]) {\n const content = {\n text: fileName === 'introduction' ? 'Introduction' : prettify(fileName, { mode: 'capitalize', replaceDash: true }),\n link: `/${prettify(repoName, { removeDot: true })}/${fileName}`,\n }\n\n return sidebarPages ? [...sidebarPages, content] : [content]\n}\n\n/**\n * Generates sidebar items from a repository's file structure\n *\n * @param repository - Repository information\n * @param obj - Object representing the file tree structure\n * @returns Array of sidebar items (projects and pages)\n */\nexport function generateSidebarItems(repository: EnhancedRepository, obj: any): (SidebarProject | Page)[] {\n return Object.entries(obj).flatMap(([key, value]): (SidebarProject | Page)[] => {\n if (key === '$') {\n if (Array.isArray(value)) {\n return value.map((element) => {\n const file = resolve(repository.docpress.projectPath, element)\n let filename = prettify(basename(file), { mode: 'lowercase', removeIdx: true })\n if (filename === 'readme.md') {\n filename = 'introduction.md'\n }\n if (filename !== basename(file)) {\n renameSync(file, resolve(dirname(file), filename))\n }\n\n return {\n text: parse(filename).name === 'introduction'\n ? 'Introduction'\n : prettify(filename, { mode: 'capitalize', replaceDash: true, removeExt: true }),\n link: `/${prettify(repository.name, { removeDot: true })}/${parse(filename).name}`,\n } as Page\n })\n }\n return []\n } else if (typeof value === 'object') {\n return [{\n text: prettify(key, { mode: 'capitalize', replaceDash: true }),\n collapsed: true,\n items: generateSidebarItems({ ...repository, name: `${repository.name}/${key}` }, value),\n } as SidebarProject]\n }\n\n return []\n })\n}\n\n/**\n * Builds a tree structure from an array of file paths\n *\n * @param files - Array of file paths to be organized into a tree\n * @returns A nested object representing the directory structure\n */\nexport function buildTree(files: string[]): any {\n return files.reduce((tree, file) => {\n const [first, ...rest] = file.split('/')\n if (!rest.length) {\n // eslint-disable-next-line dot-notation\n tree['$'] = [...(tree['$'] || []), first]\n } else {\n tree[first] = buildTree([\n ...(tree[first] ? flattenTree(tree[first], '') : []),\n rest.join('/'),\n ])\n }\n return tree\n }, {} as Record<string, any>)\n}\n\n/**\n * Flattens a nested tree structure into an array of file paths\n *\n * @param subtree - The tree object to flatten\n * @param prefix - Optional path prefix to prepend to each result\n * @returns An array of file paths\n */\nexport function flattenTree(subtree: any, prefix = ''): string[] {\n return Object.entries(subtree).flatMap(([key, value]) => {\n if (key === '$') {\n if (Array.isArray(value)) {\n return value.map((v: string) => (prefix ? `${prefix}/${v}` : v))\n } else {\n return []\n }\n }\n return flattenTree(value, prefix ? `${prefix}/${key}` : key)\n })\n}\n\n/**\n * Reorders sidebar items to ensure 'Sources' appears last\n *\n * @param arr - Array of sidebar items to reorder\n * @returns Reordered array with 'Sources' as the last item\n */\nfunction moveSourcesLast(arr: (SidebarProject | Page)[]) {\n if (!Array.isArray(arr)) {\n return arr\n }\n const sourcesIdx = arr.findIndex(item => item.text === 'Sources')\n if (sourcesIdx === -1) {\n return arr\n }\n const [sources] = arr.splice(sourcesIdx, 1)\n arr.push(sources)\n return arr\n}\n\n/**\n * Transforms repository data into documentation structure\n *\n * @param repositories - Array of enhanced repositories\n * @param user - User information retrieved from GitHub\n * @param websiteInfos - Custom title and tagline information\n * @returns Object containing sidebar and index page configurations\n */\nexport function transformDoc(repositories: EnhancedRepository[], user: ReturnType<typeof getUserInfos>, websiteInfos: WebsiteInfos) {\n const features: Feature[] = []\n const sidebar: SidebarProject[] = []\n\n for (const repository of repositories) {\n log(` Replace urls for repository '${repository.name}'.`, 'info')\n getMdFiles([repository.docpress.projectPath]).forEach((file) => {\n log(` Processing file '${basename(file)}' for repository '${repository.name}'.`, 'debug')\n replaceRelativePath(file, `https://github.com/${repository.owner.login}/${repository.name}/tree/${repository.docpress.branch}`)\n\n if (basename(file).toLowerCase() === 'readme.md') {\n replaceReadmePath(file, `https://github.com/${repository.owner.login}/${repository.name}/tree/${repository.docpress.branch}`)\n }\n })\n\n log(` Generate sidebar for repository '${repository.name}'.`, 'info')\n const projectFiles = readdirSync(repository.docpress.projectPath, { recursive: true })\n .filter((file) => {\n return statSync(resolve(repository.docpress.projectPath, file.toString())).isFile()\n && basename(resolve(repository.docpress.projectPath, file.toString())).endsWith('.md')\n }) as string[]\n\n log(` Add sources for repository '${repository.name}'.`, 'info')\n let sourceFile\n if (projectFiles.length > 1) {\n sourceFile = resolve(repository.docpress.projectPath, 'sources.md')\n projectFiles.push('sources.md')\n } else {\n sourceFile = resolve(repository.docpress.projectPath, projectFiles[0])\n }\n addSources(repository.html_url, sourceFile)\n\n const projectTree = buildTree(projectFiles)\n const sidebarItems = moveSourcesLast(generateSidebarItems(repository, projectTree))\n\n sidebar.push(generateSidebarProject(prettify(repository.name, { removeDot: true }), sidebarItems))\n features.push(...generateFeatures(prettify(repository.name, { removeDot: true }), repository.description || ''))\n }\n\n log(` Generate index content.`, 'info')\n const index = generateIndex(features.toSorted((a, b) => a.title.localeCompare(b.title)), user, websiteInfos)\n return {\n sidebar: sidebar.toSorted((a, b) => a.text.localeCompare(b.text)),\n index,\n }\n}\n\n/**\n * Adds extra pages to the documentation from specified paths\n *\n * @param paths - Array of paths to markdown files\n * @returns Array of navigation page objects\n */\nexport function addExtraPages(paths: string[]) {\n const files = getMdFiles(paths)\n const nav: Page[] = []\n\n log(` Add extras Vitepress headers pages.`, 'info')\n for (const file of files) {\n log(` Processing file '${file}'.`, 'debug')\n const src = resolve(process.cwd(), file)\n const dest = resolve(DOCS_DIR, prettify(basename(file), { mode: 'lowercase', removeIdx: true }))\n cpSync(src, dest)\n nav.push({\n text: prettify(parse(src).name, { replaceDash: true, removeIdx: true }),\n link: `/${prettify(parse(src).name, { removeIdx: true, mode: 'lowercase' })}`,\n })\n }\n return nav\n}\n\n/**\n * Adds content from specified paths to a target directory\n *\n * @param paths - String or array of paths to content\n * @param dir - Target directory to copy content to\n * @param fn - Optional callback function to execute for each file\n */\nexport function addContent(paths: string | string[], dir: string, fn?: () => void) {\n for (const path of Array.isArray(paths) ? paths : [paths]) {\n const absolutePath = resolve(process.cwd(), path)\n const files = extractFiles(absolutePath)\n\n for (const file of files) {\n const formattedFile = file.replace(absolutePath, '.')\n log(` Processing file '${formattedFile}' for entry '${path}'.`, 'debug')\n const src = resolve(process.cwd(), file)\n const dest = resolve(dir, formattedFile)\n if (fn) {\n fn()\n }\n cpSync(src, dest)\n }\n }\n}\n\n/**\n * Creates a fork page to display external contributions\n *\n * @param forks - Array of repositories and contribution counts\n */\nexport function addForkPage(forks: { repository: Awaited<ReturnType<typeof getInfos>>['repos'][number], contributions: number }[]) {\n const separator = '---\\n'\n const header = 'layout: fork-page\\nrepoList:\\n'\n const text = '\\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'\n const frontmatter = forks.map(({ repository, contributions }) => {\n const { name, owner, html_url, description, stargazers_count } = repository\n return { name, owner: owner.login, html_url, description, stargazers_count, contributions }\n })\n log(` Generate forks page.`, 'info')\n writeFileSync(FORKS_FILE, separator + header + YAML.stringify(frontmatter) + separator + text)\n}\n\ntype Source = Required<Awaited<ReturnType<typeof getContributors>>['source']>\n\ntype AdaptedLicense = Omit<NonNullable<Source>['license'], 'spdx_id'> & { spdx_id?: string }\n\ntype AdaptedRepository = Omit<NonNullable<Source>, 'license'> & { license: AdaptedLicense }\n\n/**\n * Processes forked repositories to generate contribution information\n *\n * @param repositories - Array of enhanced repositories\n * @param username - GitHub username\n * @param token - Optional GitHub API token\n */\nexport async function processForks(repositories: EnhancedRepository[], username: GlobalOpts['usernames'][number], token?: GlobalOpts['token']) {\n const forks = await Promise.all(\n repositories.map(async (repository) => {\n const { source, contributors } = await getContributors({ repository, token })\n return {\n contributions: contributors?.find(contributor => contributor.login === username)?.contributions ?? 0,\n repository: source as AdaptedRepository,\n }\n }),\n ).then(f => f.filter(({ repository, contributions }) => !!repository && contributions))\n\n addForkPage(forks)\n}\n\n/**\n * Parses a VitePress configuration file\n *\n * @param path - Path to the VitePress config file\n * @returns The parsed configuration object\n */\nexport async function parseVitepressConfig(path: string): Promise<Partial<ReturnType<typeof defineConfig>>> {\n const { config } = await import(resolve(process.cwd(), path)).catch(e => e)\n return config\n}\n\n/**\n * Parses a VitePress index file\n *\n * @param path - Path to the index file\n * @returns The parsed index object\n */\nexport async function parseVitepressIndex(path: string): Promise<Index> {\n const index = (await readFile(resolve(process.cwd(), path))).toString()\n return YAML.parse(index)\n}\n\n/**\n * Generates VitePress configuration and index files\n *\n * @param vitepressConfig - VitePress configuration object\n * @param index - Index page configuration\n * @returns The list of theme files that were generated\n */\nexport function generateVitepressFiles(vitepressConfig: Partial<ReturnType<typeof defineConfig>>, index: Index) {\n const separator = '---\\n'\n createDir(dirname(VITEPRESS_CONFIG))\n\n log(` Generate Vitepress config.`, 'info')\n writeFileSync(VITEPRESS_CONFIG, `export const config = ${JSON.stringify(vitepressConfig, null, 2)}\\n\\nexport default config\\n`)\n log(` Generate index file.`, 'info')\n writeFileSync(INDEX_FILE, separator + YAML.stringify(index))\n log(` Add Docpress theme files.`, 'info')\n return extractFiles(TEMPLATE_THEME).forEach((path) => {\n const relativePath = path.replace(`${TEMPLATE_THEME}/`, '')\n generateFile(path, resolve(VITEPRESS_THEME, relativePath))\n })\n}\n","import { dirname } from 'node:path'\nimport { createCommand, createOption } from 'commander'\nimport { configSchema } from '../schemas/global.js'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport { prepareDoc } from '../lib/prepare.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { log } from '../utils/logger.js'\nimport { createDir } from '../utils/functions.js'\nimport { VITEPRESS_CONFIG } from '../utils/const.js'\nimport { globalOpts } from './global.js'\n\n/**\n * Command name for the prepare operation\n */\nconst cmdName = 'prepare'\n\n/**\n * Command line options specific to the prepare command\n */\nexport const prepareOpts = [\n createOption('-c, --extra-public-content <string>', configSchema.shape.extraPublicContent.description),\n createOption('-f, --forks', configSchema.shape.forks.description),\n createOption('-p, --extra-header-pages <string>', configSchema.shape.extraHeaderPages.description),\n createOption('-t, --extra-theme <string>', configSchema.shape.extraTheme.description),\n createOption('-v, --vitepress-config <string>', configSchema.shape.vitepressConfig.description),\n createOption('--website-title <string>', configSchema.shape.websiteTitle.description),\n createOption('--website-tagline <string>', configSchema.shape.websiteTagline.description),\n]\n\n/**\n * The prepare command definition for Commander\n */\nexport const prepareCmd = addOptions(createCommand(cmdName), [...prepareOpts, ...globalOpts])\n .description('Transform doc to the target vitepress format.')\n .action(async (opts) => {\n const parsedOpts = parseOptions(cmdName, opts)\n await main(parsedOpts)\n })\n\n/**\n * Main function to execute the prepare command\n *\n * @param opts - Validated prepare options\n */\nexport async function main(opts: PrepareOpts) {\n const { extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig, forks, token, usernames, websiteTitle, websiteTagline } = opts\n log(`\\n-> Start transform files to prepare Vitepress build.`, 'info')\n\n createDir(dirname(VITEPRESS_CONFIG), { clean: true })\n for (const username of usernames) {\n await prepareDoc({ extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig, forks, token, username, websiteTitle, websiteTagline })\n }\n}\n","import { Command } from 'commander'\nimport pkg from '../package.json' with { type: 'json' }\nimport { fetchCmd, main as fetchFn, fetchOpts } from './commands/fetch.js'\nimport { buildCmd, main as buildFn } from './commands/build.js'\nimport { prepareCmd, main as prepareFn, prepareOpts } from './commands/prepare.js'\nimport { addOptions, parseOptions } from './utils/commands.js'\nimport { globalOpts } from './commands/global.js'\n\n/**\n * Adds explicit defaults to options object for branch and gitProvider\n *\n * @param opts - Options object from Commander\n * @returns Options with defaults explicitly set\n */\nfunction addDefaults(opts: Record<string, unknown>): Record<string, unknown> {\n // Create a new object with explicit defaults\n return {\n ...opts,\n branch: 'main',\n gitProvider: 'github',\n }\n}\n\n/**\n * Creates and configures the Command Line Interface for DocPress\n *\n * @returns A configured Commander program instance\n */\nexport function getProgram() {\n const pm = new Command()\n .name('docpress')\n .description('Build your doc website faster than light ⚡️⚡️⚡️')\n .version(`${pkg.version}`)\n .action(async (opts, _cmd) => {\n const optsWithDefaults = addDefaults(opts)\n const parsedOpts = parseOptions('global', optsWithDefaults)\n await fetchFn(parsedOpts)\n await prepareFn(parsedOpts)\n await buildFn()\n })\n .configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n showGlobalOptions: true,\n })\n .enablePositionalOptions()\n .passThroughOptions()\n .addCommand(fetchCmd)\n .addCommand(prepareCmd)\n .addCommand(buildCmd)\n\n addOptions(pm, [...fetchOpts, ...prepareOpts, ...globalOpts])\n\n return pm\n}\n\n/**\n * Entry point for the DocPress CLI\n * Initializes and runs the command parser\n */\nexport function main() {\n const pm = getProgram()\n pm.parseAsync(process.argv)\n}\n"],"names":["DOCPRESS_DIR","resolve","DOCS_DIR","INDEX_FILE","FORKS_FILE","VITEPRESS_CONFIG","VITEPRESS_THEME","VITEPRESS_USER_THEME","TEMPLATE_THEME","relativePathRegex","readmePathRegex","readmeDocsPathRegex","removeIdxRegex","checkHttpStatus","url","axios","error","prettify","s","opts","u","createDir","directory","clean","existsSync","rimrafSync","mkdirSync","err","isDir","path","statSync","isFile","extractFiles","paths","readdirSync","file","join","getMdFiles","basename","prettifyEnum","arr","acc","cur","idx","getUserInfos","username","readFileSync","getUserRepos","deepMerge","objects","obj","key","accValue","objValue","isObject","val","loadConfigFile","configPath","fullPath","fileContents","splitByComma","replaceRelativePath","updatedContent","_match","p1","p2","writeFileSync","replaceReadmePath","_p2","p3","getLogLevel","colorMap","log","msg","type","color","computedMsg","chalk","computedType","providers","configSchema","z","baseCliSchema","cliSchema","prepareConfigData","configData","validateFinalConfig","mergedConfig","globalOptsSchema","data","config","vitepressConfig","token","rest","preparedConfigData","buildOptsSchema","fetchOptsSchema","prepareOptsSchema","options","handleConfigFile","parsedConfig","parseOptions","cmd","configResult","res","errorMessage","fromError","addOptions","opt","getInfos","branch","octokit","Octokit","user","repos","getContributors","repository","message","repo","contributors","cloneRepo","name","projectDir","includes","git","simpleGit","item","appendFileSync","cpSync","rmSync","checkDoc","repoOwner","repoName","rootReadmeUrl","docsFolderUrl","docsReadmeUrl","rootReadmeStatus","docsFolderStatus","docsReadmeStatus","fetchDoc","reposFilter","generateInfos","getDoc","enhanceRepositories","enhancedRepos","computedBranch","projectPath","filtered","isRepoFiltered","getSparseCheckout","docsStatus","status","hasOnlyExclusions","filter","isExcluded","isIncluded","isFiltered","globalOpts","createOption","cmdName","fetchOpts","fetchCmd","createCommand","parsedOpts","main","usernames","gitProvider","finalRF","rf","suppressVueWarnings","callback","originalWarn","args","buildCmd","_opts","vitepressBuild","siteConfig","withMermaid","generateFile","src","dest","content","dirname","defaultVitepressConfig","getVitepressConfig","sidebar","nav","prepareDoc","extraHeaderPages","extraPublicContent","extraTheme","forks","websiteTitle","websiteTagline","repositories","internals","clone_url","privateRepo","fork","docpress","websiteInfos","index","transformDoc","finalSB","finalIndex","actualConfig","parseVitepressConfig","actualIndex","parseVitepressIndex","a","b","pages","addExtraPages","p","addContent","processForks","generateVitepressFiles","addSources","repoUrl","outputPath","fileName","sourcesContent","generateIndex","features","login","bio","title","tagline","generateFeatures","description","generateSidebarProject","sidebarPages","generateSidebarItems","value","element","filename","renameSync","parse","buildTree","files","tree","first","flattenTree","subtree","prefix","v","moveSourcesLast","sourcesIdx","sources","projectFiles","sourceFile","projectTree","sidebarItems","dir","fn","absolutePath","formattedFile","addForkPage","separator","header","text","frontmatter","contributions","owner","html_url","stargazers_count","YAML","source","contributor","f","e","readFile","relativePath","prepareOpts","prepareCmd","addDefaults","getProgram","pm","Command","pkg","_cmd","optsWithDefaults","fetchFn","prepareFn","buildFn"],"mappings":";;;;;;;;;;;;;;;;GAKaA,IAAeC,EAAQ,QAAQ,IAAA,GAAO,UAAU;AAK7BA,EAAQ,QAAQ,IAAA,GAAO,4BAA4B;AAKzDA,EAAQ,QAAQ,IAAA,GAAO,qBAAqB;AAK/D,MAAMC,KAAWD,EAAQ,QAAQ,IAAA,GAAO,eAAe,GAKjDE,IAAaF,EAAQ,QAAQ,IAAA,GAAO,wBAAwB,GAK5DG,KAAaH,EAAQ,QAAQ,IAAA,GAAO,wBAAwB,GAK5DI,IAAmBJ,EAAQ,QAAQ,IAAA,GAAO,+BAA+B,GAKzEK,KAAkBL,EAAQ,QAAQ,IAAA,GAAO,2BAA2B,GAKpEM,KAAuBN,EAAQ,QAAQ,IAAA,GAAO,kCAAkC,GAMhFO,KAAiB,QAAQ,IAAI,aAAgB,gBACtDP,EAAQ,YAAY,SAAS,8BAA8B,IAC3DA,EAAQ,YAAY,SAAS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