@tobi-or-not/docpress 0.3.1 → 0.4.0
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 +108 -169
- package/dist/cli.js.map +1 -1
- package/dist/templates/theme/index.ts +22 -0
- package/dist/templates/theme/layouts/ForkPage.vue +130 -0
- package/package.json +13 -13
- /package/types/{templates → public/templates}/theme/index.d.ts +0 -0
- /package/types/{cli.d.ts → src/cli.d.ts} +0 -0
- /package/types/{commands → src/commands}/build.d.ts +0 -0
- /package/types/{commands → src/commands}/fetch.d.ts +0 -0
- /package/types/{commands → src/commands}/global.d.ts +0 -0
- /package/types/{commands → src/commands}/prepare.d.ts +0 -0
- /package/types/{lib → src/lib}/fetch.d.ts +0 -0
- /package/types/{lib → src/lib}/git.d.ts +0 -0
- /package/types/{lib → src/lib}/prepare.d.ts +0 -0
- /package/types/{lib → src/lib}/vitepress.d.ts +0 -0
- /package/types/{schemas → src/schemas}/build.d.ts +0 -0
- /package/types/{schemas → src/schemas}/fetch.d.ts +0 -0
- /package/types/{schemas → src/schemas}/global.d.ts +0 -0
- /package/types/{schemas → src/schemas}/prepare.d.ts +0 -0
- /package/types/{utils → src/utils}/commands.d.ts +0 -0
- /package/types/{utils → src/utils}/const.d.ts +0 -0
- /package/types/{utils → src/utils}/functions.d.ts +0 -0
- /package/types/{utils → src/utils}/logger.d.ts +0 -0
- /package/types/{utils → src/utils}/regex.d.ts +0 -0
- /package/types/{templates/index.d.ts → src/utils/templates.d.ts} +0 -0
package/dist/cli.js
CHANGED
|
@@ -1,93 +1,34 @@
|
|
|
1
|
-
import { createOption as m, createCommand as
|
|
2
|
-
import
|
|
3
|
-
import { fromZodError as
|
|
1
|
+
import { createOption as m, createCommand as j, Command as Ce } from "commander";
|
|
2
|
+
import J from "chalk";
|
|
3
|
+
import { fromZodError as ie } from "zod-validation-error";
|
|
4
4
|
import { z as u } from "zod";
|
|
5
|
-
import { readFileSync as C, existsSync as
|
|
6
|
-
import { resolve as d, join as
|
|
7
|
-
import
|
|
8
|
-
import { rimrafSync as
|
|
9
|
-
import { Octokit as
|
|
10
|
-
import { simpleGit as
|
|
11
|
-
import { build as
|
|
12
|
-
import
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"types"
|
|
19
|
-
], Ne = {
|
|
20
|
-
node: ">=20"
|
|
21
|
-
}, Me = {
|
|
22
|
-
build: "pnpm run build:types && pnpm run build:vite",
|
|
23
|
-
"build:clean": "rimraf ./dist ./types ./tsconfig.tsbuildinfo",
|
|
24
|
-
"build:docker": "docker build --tag tobi-or-not/docpress --target prod .",
|
|
25
|
-
"build:types": "tsc",
|
|
26
|
-
"build:vite": "vite build",
|
|
27
|
-
dev: "vite-node ./dev/docpress.ts",
|
|
28
|
-
"dev:clean": "rimraf ./docpress && pnpm run dev",
|
|
29
|
-
format: "eslint . --fix",
|
|
30
|
-
lint: "eslint .",
|
|
31
|
-
prepare: "husky",
|
|
32
|
-
start: "./bin/docpress.js",
|
|
33
|
-
"start:docker": "docker run --name docpress --rm -v $(pwd)/docpress:/app/docpress:rw tobi-or-not/docpress",
|
|
34
|
-
"stop:docker": "docker rm --force docpress",
|
|
35
|
-
test: "vitest run",
|
|
36
|
-
"test:cov": "vitest run --coverage",
|
|
37
|
-
"vp:build": "vitepress build ./docpress",
|
|
38
|
-
"vp:build:docker": "docker build --tag tobi-or-not/docs --target prod .",
|
|
39
|
-
"vp:dev": "vitepress dev ./docpress --port 8080",
|
|
40
|
-
"vp:dev:docker": "docker run --publish 8080:8080 --name docpress-vp --rm tobi-or-not/docs",
|
|
41
|
-
"vp:preview": "vitepress preview ./docpress --port 8080"
|
|
42
|
-
}, Ue = {
|
|
43
|
-
"@octokit/rest": "^21.0.2",
|
|
44
|
-
axios: "^1.7.7",
|
|
45
|
-
chalk: "^5.3.0",
|
|
46
|
-
commander: "^12.1.0",
|
|
47
|
-
octokit: "^4.0.2",
|
|
48
|
-
rimraf: "^6.0.1",
|
|
49
|
-
"simple-git": "^3.27.0",
|
|
50
|
-
vitepress: "^1.5.0",
|
|
51
|
-
yaml: "^2.6.1",
|
|
52
|
-
zod: "^3.23.8",
|
|
53
|
-
"zod-validation-error": "^3.4.0"
|
|
54
|
-
}, He = {
|
|
55
|
-
"@antfu/eslint-config": "^3.9.2",
|
|
56
|
-
"@commitlint/cli": "^19.6.0",
|
|
57
|
-
"@commitlint/config-conventional": "^19.6.0",
|
|
58
|
-
"@octokit/types": "^13.6.1",
|
|
59
|
-
"@types/node": "^22.9.1",
|
|
60
|
-
"@vitest/coverage-v8": "^2.1.5",
|
|
61
|
-
eslint: "^9.15.0",
|
|
62
|
-
husky: "^9.1.7",
|
|
63
|
-
"lint-staged": "^15.2.10",
|
|
64
|
-
typescript: "^5.6.3",
|
|
65
|
-
vite: "^5.4.11",
|
|
66
|
-
"vite-node": "^2.1.5",
|
|
67
|
-
vitest: "^2.1.5"
|
|
68
|
-
}, ze = {
|
|
69
|
-
registry: "https://registry.npmjs.org/",
|
|
70
|
-
access: "public",
|
|
71
|
-
tag: "latest"
|
|
72
|
-
}, Be = {
|
|
73
|
-
name: Te,
|
|
74
|
-
type: De,
|
|
75
|
-
version: Le,
|
|
76
|
-
packageManager: Ie,
|
|
5
|
+
import { readFileSync as C, existsSync as W, mkdirSync as Se, readdirSync as ce, statSync as A, appendFileSync as ae, cpSync as G, rmSync as q, writeFileSync as v, renameSync as xe } from "node:fs";
|
|
6
|
+
import { resolve as d, join as Pe, basename as b, dirname as N, parse as x } from "node:path";
|
|
7
|
+
import _e from "axios";
|
|
8
|
+
import { rimrafSync as Ee } from "rimraf";
|
|
9
|
+
import { Octokit as de } from "@octokit/rest";
|
|
10
|
+
import { simpleGit as Oe } from "simple-git";
|
|
11
|
+
import { build as Fe } from "vitepress";
|
|
12
|
+
import ue from "yaml";
|
|
13
|
+
const Re = "@tobi-or-not/docpress", Te = "module", De = "0.4.0", Le = "pnpm@9.15.0", Ve = "dist/docpress.js", Ie = "types/index.d.ts", je = { docpress: "bin/docpress.js" }, Ae = ["bin", "dist", "types"], Ge = { node: ">=20" }, Ne = { build: "pnpm run build:types && pnpm run build:vite", "build:clean": "rimraf ./dist ./types ./tsconfig.tsbuildinfo", "build:docker": "docker build --tag tobi-or-not/docpress --target prod .", "build:types": "tsc", "build:vite": "vite build", dev: "vite-node ./dev/docpress.ts", "dev:clean": "rimraf ./docpress && pnpm run dev", format: "eslint . --fix", lint: "eslint .", prepare: "husky", start: "./bin/docpress.js", "start:docker": "docker run --name docpress --rm -v $(pwd)/docpress:/app/docpress:rw tobi-or-not/docpress", "stop:docker": "docker rm --force docpress", test: "vitest run", "test:cov": "vitest run --coverage", "vp:build": "vitepress build ./docpress", "vp:build:docker": "docker build --tag tobi-or-not/docs --target prod .", "vp:dev": "vitepress dev ./docpress --port 8080", "vp:dev:docker": "docker run --publish 8080:8080 --name docpress-vp --rm tobi-or-not/docs", "vp:preview": "vitepress preview ./docpress --port 8080" }, Me = { "@octokit/rest": "^21.0.2", axios: "^1.7.9", chalk: "^5.3.0", commander: "^12.1.0", octokit: "^4.0.2", rimraf: "^6.0.1", "simple-git": "^3.27.0", vitepress: "^1.5.0", yaml: "^2.6.1", zod: "^3.24.1", "zod-validation-error": "^3.4.0" }, Ue = { "@antfu/eslint-config": "^3.11.2", "@commitlint/cli": "^19.6.0", "@commitlint/config-conventional": "^19.6.0", "@octokit/types": "^13.6.2", "@types/node": "^22.10.2", "@vitest/coverage-v8": "^2.1.8", eslint: "^9.16.0", husky: "^9.1.7", "lint-staged": "^15.2.11", typescript: "^5.7.2", vite: "^6.0.3", "vite-node": "^2.1.8", vitest: "^2.1.8" }, He = { registry: "https://registry.npmjs.org/", access: "public", tag: "latest" }, ze = {
|
|
14
|
+
name: Re,
|
|
15
|
+
type: Te,
|
|
16
|
+
version: De,
|
|
17
|
+
packageManager: Le,
|
|
77
18
|
module: Ve,
|
|
78
|
-
types:
|
|
79
|
-
bin:
|
|
80
|
-
files:
|
|
81
|
-
engines:
|
|
82
|
-
scripts:
|
|
83
|
-
dependencies:
|
|
84
|
-
devDependencies:
|
|
85
|
-
publishConfig:
|
|
19
|
+
types: Ie,
|
|
20
|
+
bin: je,
|
|
21
|
+
files: Ae,
|
|
22
|
+
engines: Ge,
|
|
23
|
+
scripts: Ne,
|
|
24
|
+
dependencies: Me,
|
|
25
|
+
devDependencies: Ue,
|
|
26
|
+
publishConfig: He
|
|
86
27
|
};
|
|
87
|
-
function
|
|
28
|
+
function Be() {
|
|
88
29
|
return typeof Number(process.env.LOG_LEVEL) == "number" && !Number.isNaN(Number(process.env.LOG_LEVEL)) ? Number(process.env.LOG_LEVEL) : 30;
|
|
89
30
|
}
|
|
90
|
-
const
|
|
31
|
+
const K = {
|
|
91
32
|
info: { color: "white", level: 30 },
|
|
92
33
|
warn: { color: "yellow", level: 20 },
|
|
93
34
|
error: { color: "red", level: 10 },
|
|
@@ -96,13 +37,13 @@ const X = {
|
|
|
96
37
|
success: { color: "green", level: 30 }
|
|
97
38
|
};
|
|
98
39
|
function c(e, t = "info", r) {
|
|
99
|
-
const s = r ?
|
|
100
|
-
|
|
40
|
+
const s = r ? J[r](e) : J[K[t].color](e), n = t === "success" ? "info" : t;
|
|
41
|
+
Be() >= K[t].level && console[n](s);
|
|
101
42
|
}
|
|
102
|
-
const
|
|
103
|
-
async function
|
|
43
|
+
const M = d(process.cwd(), "docpress"), pe = d(process.cwd(), "docpress/repositories.json"), le = d(process.cwd(), "docpress/owner.json"), fe = d(process.cwd(), "docpress/docs"), Je = d(process.cwd(), "docpress/docs/index.md"), We = d(process.cwd(), "docpress/docs/forks.md"), X = d(process.cwd(), "docpress/.vitepress/config.ts"), qe = d(process.cwd(), "docpress/.vitepress/theme"), Ke = d(process.cwd(), "docpress/.vitepress/theme/extras"), Y = process.env.NODE_ENV === "development" ? d(import.meta.dirname, "../../public/templates/theme") : d(import.meta.dirname, "./templates/theme");
|
|
44
|
+
async function L(e) {
|
|
104
45
|
try {
|
|
105
|
-
return (await
|
|
46
|
+
return (await _e.head(e)).status;
|
|
106
47
|
} catch (t) {
|
|
107
48
|
return t.response?.status || t.status || 500;
|
|
108
49
|
}
|
|
@@ -113,50 +54,50 @@ function k(e, t) {
|
|
|
113
54
|
}
|
|
114
55
|
function E(e, { clean: t } = { clean: !1 }) {
|
|
115
56
|
try {
|
|
116
|
-
t &&
|
|
57
|
+
t && W(e) && Ee(`${e}/*`, { glob: !0 }), W(e) || Se(e, { recursive: !0 });
|
|
117
58
|
} catch (r) {
|
|
118
59
|
console.error(r);
|
|
119
60
|
}
|
|
120
61
|
}
|
|
121
62
|
function Xe(e) {
|
|
122
63
|
try {
|
|
123
|
-
return
|
|
64
|
+
return A(e).isDirectory();
|
|
124
65
|
} catch {
|
|
125
66
|
return !1;
|
|
126
67
|
}
|
|
127
68
|
}
|
|
128
69
|
function Ye(e) {
|
|
129
70
|
try {
|
|
130
|
-
return
|
|
71
|
+
return A(e).isFile();
|
|
131
72
|
} catch {
|
|
132
73
|
return !1;
|
|
133
74
|
}
|
|
134
75
|
}
|
|
135
76
|
function O(e) {
|
|
136
|
-
return (Array.isArray(e) ? e : [e]).flatMap((t) => Ye(t) ? [t] : Xe(t) ?
|
|
77
|
+
return (Array.isArray(e) ? e : [e]).flatMap((t) => Ye(t) ? [t] : Xe(t) ? ce(t).flatMap((r) => O(Pe(t, r))) : []);
|
|
137
78
|
}
|
|
138
|
-
function
|
|
79
|
+
function me(e) {
|
|
139
80
|
return O(e).filter((t) => b(t).endsWith(".md"));
|
|
140
81
|
}
|
|
141
82
|
function Ze(e) {
|
|
142
83
|
return e.reduce((t, r, s, n) => s ? s === n.length - 1 ? `${t} or "${r}"` : `${t}, "${r}"` : `"${r}"`, "");
|
|
143
84
|
}
|
|
144
85
|
function Qe() {
|
|
145
|
-
return JSON.parse(C(
|
|
86
|
+
return JSON.parse(C(le).toString());
|
|
146
87
|
}
|
|
147
88
|
function et() {
|
|
148
|
-
return JSON.parse(C(
|
|
89
|
+
return JSON.parse(C(pe).toString());
|
|
149
90
|
}
|
|
150
|
-
function
|
|
91
|
+
function I(...e) {
|
|
151
92
|
return e.reduce((t, r) => (r === null || Object.keys(r).forEach((s) => {
|
|
152
93
|
const n = t ? t[s] : null, o = r[s];
|
|
153
|
-
|
|
94
|
+
Z(n) && Z(o) ? t[s] = I(n, o) : t[s] = o;
|
|
154
95
|
}), t), {});
|
|
155
96
|
}
|
|
156
|
-
function
|
|
97
|
+
function Z(e) {
|
|
157
98
|
return e && typeof e == "object" && !Array.isArray(e);
|
|
158
99
|
}
|
|
159
|
-
function
|
|
100
|
+
function Q(e) {
|
|
160
101
|
if (!e)
|
|
161
102
|
return {};
|
|
162
103
|
try {
|
|
@@ -169,12 +110,12 @@ function ee(e) {
|
|
|
169
110
|
function P(e) {
|
|
170
111
|
return e.split(",");
|
|
171
112
|
}
|
|
172
|
-
const
|
|
113
|
+
const ee = ["github"], p = u.object({
|
|
173
114
|
// Global
|
|
174
115
|
username: u.string().describe("Git provider username used to collect data."),
|
|
175
116
|
// Fetch
|
|
176
117
|
branch: u.string().describe("Branch used to collect Git provider data.").default("main"),
|
|
177
|
-
gitProvider: u.enum(
|
|
118
|
+
gitProvider: u.enum(ee).describe(`Git provider used to retrieve data. Values should be ${Ze(ee)}.`).default("github"),
|
|
178
119
|
reposFilter: u.array(u.string()).describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
|
|
179
120
|
// Prepare
|
|
180
121
|
extraHeaderPages: u.array(u.string()).describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
@@ -183,10 +124,10 @@ const te = ["github"], p = u.object({
|
|
|
183
124
|
forks: u.boolean().describe("Whether or not to create the dedicated fork page that aggregate external contributions.").default(!1),
|
|
184
125
|
vitepressConfig: u.any().describe("Path to the vitepress configuration file.")
|
|
185
126
|
});
|
|
186
|
-
function
|
|
127
|
+
function U(e) {
|
|
187
128
|
const { config: t, vitepressConfig: r, token: s, ...n } = e;
|
|
188
129
|
try {
|
|
189
|
-
const o = p.partial().parse(
|
|
130
|
+
const o = p.partial().parse(Q(t)), i = Q(r), a = p.partial().required({ branch: !0, gitProvider: !0 }).parse({}), l = {
|
|
190
131
|
...i,
|
|
191
132
|
...o.vitepressConfig
|
|
192
133
|
}, g = {
|
|
@@ -198,7 +139,7 @@ function H(e) {
|
|
|
198
139
|
return { ...p.partial().required({ username: !0 }).parse(g), token: s };
|
|
199
140
|
} catch (o) {
|
|
200
141
|
c(` An error occurred while checking configuration.
|
|
201
|
-
${
|
|
142
|
+
${ie(o).toString()}`, "error"), process.exit(1);
|
|
202
143
|
}
|
|
203
144
|
}
|
|
204
145
|
const F = p.partial().extend({
|
|
@@ -209,14 +150,14 @@ const F = p.partial().extend({
|
|
|
209
150
|
extraPublicContent: u.string().describe(p.shape.extraPublicContent.description || "").transform(P).optional(),
|
|
210
151
|
extraTheme: u.string().describe(p.shape.extraTheme.description || "").transform(P).optional(),
|
|
211
152
|
vitepressConfig: u.string().describe(p.shape.vitepressConfig.description || "").optional()
|
|
212
|
-
}), _ = F.partial().transform(
|
|
153
|
+
}), _ = F.partial().transform(U), tt = F.pick({}), rt = F.pick({
|
|
213
154
|
branch: !0,
|
|
214
155
|
config: !0,
|
|
215
156
|
gitProvider: !0,
|
|
216
157
|
reposFilter: !0,
|
|
217
158
|
token: !0,
|
|
218
159
|
username: !0
|
|
219
|
-
}).transform(
|
|
160
|
+
}).transform(U), ot = F.pick({
|
|
220
161
|
extraHeaderPages: !0,
|
|
221
162
|
extraPublicContent: !0,
|
|
222
163
|
extraTheme: !0,
|
|
@@ -226,26 +167,26 @@ const F = p.partial().extend({
|
|
|
226
167
|
token: !0,
|
|
227
168
|
username: !0,
|
|
228
169
|
vitepressConfig: !0
|
|
229
|
-
}).transform(
|
|
170
|
+
}).transform(U), st = {
|
|
230
171
|
build: tt,
|
|
231
172
|
fetch: rt,
|
|
232
173
|
prepare: ot,
|
|
233
174
|
global: _
|
|
234
175
|
};
|
|
235
|
-
function
|
|
176
|
+
function H(e, t) {
|
|
236
177
|
c("Initializing Docpress...", "info", "blue"), c(`
|
|
237
178
|
|
|
238
179
|
-> Checking for required environment settings and configurations.`, "info");
|
|
239
180
|
const r = st[e].safeParse(t);
|
|
240
181
|
return r.error && (c(` An error occurred while checking configuration.
|
|
241
|
-
${
|
|
182
|
+
${ie(r.error).toString()}`, "error"), process.exit(1)), c(" Setup complete! Ready to process your documentation.", "info"), r.data;
|
|
242
183
|
}
|
|
243
184
|
function R(e, t) {
|
|
244
185
|
return t.forEach((r) => e.addOption(r)), e;
|
|
245
186
|
}
|
|
246
187
|
async function nt({ username: e, token: t, branch: r }) {
|
|
247
188
|
c(` Get infos for username '${e}'.`, "info");
|
|
248
|
-
const s = new
|
|
189
|
+
const s = new de({ auth: t });
|
|
249
190
|
c(" Get user infos.", "debug");
|
|
250
191
|
const { data: n } = await s.rest.users.getByUsername({ username: e });
|
|
251
192
|
c(" Get repositories infos.", "debug");
|
|
@@ -257,7 +198,7 @@ async function it({
|
|
|
257
198
|
token: t
|
|
258
199
|
}) {
|
|
259
200
|
c(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
260
|
-
const r = new
|
|
201
|
+
const r = new de({
|
|
261
202
|
auth: t,
|
|
262
203
|
log: {
|
|
263
204
|
debug: () => {
|
|
@@ -299,18 +240,18 @@ async function it({
|
|
|
299
240
|
async function ct(e, t, r, s, n) {
|
|
300
241
|
E(r, { clean: !0 });
|
|
301
242
|
try {
|
|
302
|
-
const o =
|
|
243
|
+
const o = Oe({ baseDir: r });
|
|
303
244
|
await o.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
|
|
304
245
|
for (const i of n)
|
|
305
|
-
c(` Add '${i}' to '${e}' sparse-checkout file.`, "debug"),
|
|
246
|
+
c(` Add '${i}' to '${e}' sparse-checkout file.`, "debug"), ae(d(r, ".git/info/sparse-checkout"), `${i}
|
|
306
247
|
`, "utf8");
|
|
307
|
-
c(` Clone repository '${e}'.`, "info"), await o.pull("origin", s), n.some((i) => i.includes("docs")) && (
|
|
248
|
+
c(` Clone repository '${e}'.`, "info"), await o.pull("origin", s), n.some((i) => i.includes("docs")) && (G(d(r, "docs"), r, { recursive: !0 }), q(d(r, "docs"), { recursive: !0 })), q(d(r, ".git"), { recursive: !0 });
|
|
308
249
|
} catch (o) {
|
|
309
250
|
c(` Error when cloning repository: ${o}.`, "error");
|
|
310
251
|
}
|
|
311
252
|
}
|
|
312
253
|
async function at(e, t, r) {
|
|
313
|
-
const s = `https://github.com/${e}/${t}/tree/${r}/README.md`, n = `https://github.com/${e}/${t}/tree/${r}/docs`, o = `https://github.com/${e}/${t}/tree/${r}/docs/01-readme.md`, i = await
|
|
254
|
+
const s = `https://github.com/${e}/${t}/tree/${r}/README.md`, n = `https://github.com/${e}/${t}/tree/${r}/docs`, o = `https://github.com/${e}/${t}/tree/${r}/docs/01-readme.md`, i = await L(s), a = await L(n), l = await L(o);
|
|
314
255
|
return {
|
|
315
256
|
rootReadmeStatus: i,
|
|
316
257
|
docsFolderStatus: a,
|
|
@@ -318,13 +259,13 @@ async function at(e, t, r) {
|
|
|
318
259
|
};
|
|
319
260
|
}
|
|
320
261
|
async function dt({ username: e, branch: t, reposFilter: r, token: s }) {
|
|
321
|
-
E(
|
|
262
|
+
E(M, { clean: !0 }), await nt({ username: e, token: s, branch: t }).then(async ({ user: n, repos: o, branch: i }) => lt(n, o, i, r)).then(async ({ repos: n }) => ft(n, r));
|
|
322
263
|
}
|
|
323
264
|
async function ut(e, t, r) {
|
|
324
265
|
const s = [];
|
|
325
266
|
return await Promise.all(
|
|
326
267
|
e.map(async (n) => {
|
|
327
|
-
const o = t ?? n.default_branch ?? "main", i = d(
|
|
268
|
+
const o = t ?? n.default_branch ?? "main", i = d(fe, n.name), a = ge(n, r);
|
|
328
269
|
let l = [];
|
|
329
270
|
!n.fork && !n.private && !a && (l = await pt(n, o)), s.push({
|
|
330
271
|
...n,
|
|
@@ -345,9 +286,9 @@ async function pt(e, t) {
|
|
|
345
286
|
return Object.values(r).every((n) => n === 404) || !e.size ? [] : (r.docsFolderStatus !== 404 && s.push("docs/*"), (r.docsFolderStatus === 404 || r.docsReadmeStatus === 404) && s.push("README.md", "!*/**/README.md"), s);
|
|
346
287
|
}
|
|
347
288
|
async function lt(e, t, r, s) {
|
|
348
|
-
v(
|
|
289
|
+
v(le, JSON.stringify(e, null, 2));
|
|
349
290
|
const n = await ut(t, r, s);
|
|
350
|
-
return v(
|
|
291
|
+
return v(pe, JSON.stringify(n, null, 2)), { user: e, repos: n };
|
|
351
292
|
}
|
|
352
293
|
async function ft(e, t) {
|
|
353
294
|
if (!e) {
|
|
@@ -355,12 +296,12 @@ async function ft(e, t) {
|
|
|
355
296
|
return;
|
|
356
297
|
}
|
|
357
298
|
await Promise.all(
|
|
358
|
-
e.filter((r) => !
|
|
299
|
+
e.filter((r) => !ge(r, t)).map(async (r) => {
|
|
359
300
|
await ct(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
|
|
360
301
|
})
|
|
361
302
|
);
|
|
362
303
|
}
|
|
363
|
-
function
|
|
304
|
+
function ge(e, t) {
|
|
364
305
|
const r = t?.every((i) => i.startsWith("!")), s = t?.filter((i) => i.startsWith("!")).some((i) => e.name === i.substring(1)), n = !t || t?.filter((i) => !i.startsWith("!")).includes(e.name) || e.fork && !s || r && !s, o = s || !n;
|
|
365
306
|
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !o);
|
|
366
307
|
}
|
|
@@ -368,29 +309,29 @@ const T = [
|
|
|
368
309
|
m("-C, --config <string>", _.innerType().shape.config._def.description),
|
|
369
310
|
m("-T, --token <string>", _.innerType().shape.token._def.description),
|
|
370
311
|
m("-U, --username <string>", _.innerType().shape.username._def.description)
|
|
371
|
-
],
|
|
312
|
+
], te = "fetch", he = [
|
|
372
313
|
m("-b, --branch <string>", p.shape.branch._def.description).default(p.shape.branch._def.defaultValue()),
|
|
373
314
|
m("-g, --git-provider <string>", p.shape.gitProvider._def.description).default(p.shape.gitProvider._def.defaultValue()),
|
|
374
315
|
m("-r, --repos-filter <string>", p.shape.reposFilter._def.description)
|
|
375
|
-
], mt = R(
|
|
376
|
-
const t =
|
|
377
|
-
await
|
|
316
|
+
], mt = R(j(te), [...he, ...T]).description("Fetch docs with the given username and git provider.").action(async (e) => {
|
|
317
|
+
const t = H(te, e);
|
|
318
|
+
await be(t);
|
|
378
319
|
});
|
|
379
|
-
async function
|
|
320
|
+
async function be(e) {
|
|
380
321
|
const { username: t, reposFilter: r, token: s, branch: n, gitProvider: o } = e;
|
|
381
322
|
c(`
|
|
382
323
|
-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"), await dt({ username: t, branch: n, reposFilter: r, gitProvider: o, token: s });
|
|
383
324
|
}
|
|
384
|
-
const gt = "build", ht = R(
|
|
385
|
-
await
|
|
325
|
+
const gt = "build", ht = R(j(gt), T).description("Build vitepress website.").action(async (e) => {
|
|
326
|
+
await ve();
|
|
386
327
|
});
|
|
387
|
-
async function
|
|
328
|
+
async function ve() {
|
|
388
329
|
c(`
|
|
389
330
|
-> Start building Vitepress website.
|
|
390
331
|
|
|
391
332
|
`, "info");
|
|
392
333
|
try {
|
|
393
|
-
await
|
|
334
|
+
await Fe(M), c(`
|
|
394
335
|
|
|
395
336
|
Docpress build succedeed.`, "success");
|
|
396
337
|
} catch (e) {
|
|
@@ -399,7 +340,7 @@ Docpress build succedeed.`, "success");
|
|
|
399
340
|
Docpress build failed : ${e}`, "error");
|
|
400
341
|
}
|
|
401
342
|
}
|
|
402
|
-
const
|
|
343
|
+
const re = {
|
|
403
344
|
base: "/",
|
|
404
345
|
lang: "en-US",
|
|
405
346
|
vite: {
|
|
@@ -437,11 +378,11 @@ const oe = {
|
|
|
437
378
|
}
|
|
438
379
|
};
|
|
439
380
|
function bt(e, t, r) {
|
|
440
|
-
return r ?
|
|
381
|
+
return r ? I(re, r, { themeConfig: { sidebar: e, nav: t } }) : I(re, { themeConfig: { sidebar: e, nav: t } });
|
|
441
382
|
}
|
|
442
383
|
function vt(e, t) {
|
|
443
384
|
const r = C(e, { encoding: "utf8" });
|
|
444
|
-
E(
|
|
385
|
+
E(N(t)), v(t, r);
|
|
445
386
|
}
|
|
446
387
|
function yt(e, t) {
|
|
447
388
|
const s = C(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (n, o, i) => `[${o}](${t}/${i})`);
|
|
@@ -451,13 +392,13 @@ function wt(e, t) {
|
|
|
451
392
|
const s = C(e, "utf8").replace(/\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.?\/)?([^/][^)]+)\)/g, (n, o, i, a) => `[${o}](${t}/${a})`).replace(/\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, (n, o, i, a) => `[${o}](${a})`);
|
|
452
393
|
v(e, s, "utf8");
|
|
453
394
|
}
|
|
454
|
-
function
|
|
395
|
+
function oe(e, t) {
|
|
455
396
|
const n = `${b(t) === "introduction.md" ? `
|
|
456
397
|
## Sources` : "# Sources"}
|
|
457
398
|
|
|
458
399
|
Take a look at the [project sources](${e}).
|
|
459
400
|
`;
|
|
460
|
-
|
|
401
|
+
ae(t, n, "utf8");
|
|
461
402
|
}
|
|
462
403
|
function kt(e, t) {
|
|
463
404
|
const { name: r, login: s, bio: n } = t;
|
|
@@ -496,21 +437,21 @@ function V(e, t, r) {
|
|
|
496
437
|
function St(e, t) {
|
|
497
438
|
const r = [], s = [];
|
|
498
439
|
for (const o of e) {
|
|
499
|
-
c(` Replace urls for repository '${o.name}'.`, "info"),
|
|
440
|
+
c(` Replace urls for repository '${o.name}'.`, "info"), me([o.docpress.projectPath]).forEach((a) => {
|
|
500
441
|
c(` Processing file '${b(a)}' for repository '${o.name}'.`, "debug"), yt(a, `https://github.com/${o.owner.login}/${o.name}/tree/${o.docpress.branch}`), b(a).toLowerCase() === "readme.md" && wt(a, `https://github.com/${o.owner.login}/${o.name}/tree/${o.docpress.branch}`);
|
|
501
442
|
}), c(` Generate sidebar for repository '${o.name}'.`, "info");
|
|
502
|
-
const i =
|
|
443
|
+
const i = ce(o.docpress.projectPath).filter((a) => A(d(o.docpress.projectPath, a)).isFile() && b(d(o.docpress.projectPath, a)).endsWith(".md")).sort((a, l) => a.localeCompare(l)).reduce((a, l, g, y) => {
|
|
503
444
|
const h = d(o.docpress.projectPath, l);
|
|
504
445
|
let f = k(b(h), { mode: "lowercase", removeIdx: !0 });
|
|
505
|
-
if (f === "readme.md" && (f = "introduction.md"), f !== b(h) &&
|
|
446
|
+
if (f === "readme.md" && (f = "introduction.md"), f !== b(h) && xe(h, d(N(h), f)), g === y.length - 1) {
|
|
506
447
|
let w;
|
|
507
448
|
if (y.length > 1)
|
|
508
|
-
return w = d(o.docpress.projectPath, "sources.md"), c(` Add sources for repository '${o.name}'.`, "info"),
|
|
449
|
+
return w = d(o.docpress.projectPath, "sources.md"), c(` Add sources for repository '${o.name}'.`, "info"), oe(o.html_url, w), V(
|
|
509
450
|
o.name,
|
|
510
451
|
x(w).name,
|
|
511
452
|
V(o.name, x(f).name, a)
|
|
512
453
|
);
|
|
513
|
-
w = d(o.docpress.projectPath, f),
|
|
454
|
+
w = d(o.docpress.projectPath, f), oe(o.html_url, w);
|
|
514
455
|
}
|
|
515
456
|
return V(o.name, x(f).name, a);
|
|
516
457
|
}, []);
|
|
@@ -524,26 +465,26 @@ function St(e, t) {
|
|
|
524
465
|
};
|
|
525
466
|
}
|
|
526
467
|
function xt(e) {
|
|
527
|
-
const t =
|
|
468
|
+
const t = me(e), r = [];
|
|
528
469
|
c(" Add extras Vitepress headers pages.", "info");
|
|
529
470
|
for (const s of t) {
|
|
530
471
|
c(` Processing file '${s}'.`, "debug");
|
|
531
|
-
const n = d(process.cwd(), s), o = d(
|
|
532
|
-
|
|
472
|
+
const n = d(process.cwd(), s), o = d(fe, k(b(s), { mode: "lowercase", removeIdx: !0 }));
|
|
473
|
+
G(n, o), r.push({
|
|
533
474
|
text: k(x(n).name, { replaceDash: !0, removeIdx: !0 }),
|
|
534
475
|
link: `/${k(x(n).name, { removeIdx: !0, mode: "lowercase" })}`
|
|
535
476
|
});
|
|
536
477
|
}
|
|
537
478
|
return r;
|
|
538
479
|
}
|
|
539
|
-
function
|
|
480
|
+
function se(e, t, r) {
|
|
540
481
|
for (const s of Array.isArray(e) ? e : [e]) {
|
|
541
482
|
const n = d(process.cwd(), s), o = O(n);
|
|
542
483
|
for (const i of o) {
|
|
543
484
|
const a = i.replace(n, ".");
|
|
544
485
|
c(` Processing file '${a}' for entry '${s}'.`, "debug");
|
|
545
486
|
const l = d(process.cwd(), i), g = d(t, a);
|
|
546
|
-
|
|
487
|
+
G(l, g);
|
|
547
488
|
}
|
|
548
489
|
}
|
|
549
490
|
}
|
|
@@ -563,7 +504,7 @@ This page serves as both a portfolio of past work and a resource for revisiting
|
|
|
563
504
|
const { name: a, owner: l, html_url: g, description: y, stargazers_count: h } = o;
|
|
564
505
|
return { name: a, owner: l.login, html_url: g, description: y, stargazers_count: h, contributions: i };
|
|
565
506
|
});
|
|
566
|
-
c(" Generate forks page.", "info"), v(
|
|
507
|
+
c(" Generate forks page.", "info"), v(We, t.concat(r, ue.stringify(n), t, s));
|
|
567
508
|
}
|
|
568
509
|
async function _t(e, t, r) {
|
|
569
510
|
const s = await Promise.all(
|
|
@@ -580,34 +521,32 @@ async function _t(e, t, r) {
|
|
|
580
521
|
function Et(e, t) {
|
|
581
522
|
const r = `---
|
|
582
523
|
`;
|
|
583
|
-
E(
|
|
584
|
-
`), c(" Generate index file.", "info"), v(
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
c(` Processing file '${d(Z, o)}'.`, "debug"), vt(d(L, n), d(Z, o));
|
|
589
|
-
}
|
|
524
|
+
return E(N(X)), c(" Generate Vitepress config.", "info"), v(X, `export default ${JSON.stringify(e, null, 2)}
|
|
525
|
+
`), c(" Generate index file.", "info"), v(Je, r.concat(ue.stringify(t), r)), c(" Add Docpress theme files.", "info"), O(Y).forEach((s) => {
|
|
526
|
+
const n = s.replace(`${Y}/`, "");
|
|
527
|
+
vt(s, d(qe, n));
|
|
528
|
+
});
|
|
590
529
|
}
|
|
591
|
-
const
|
|
530
|
+
const ne = "prepare", ye = [
|
|
592
531
|
m("-c, --extra-public-content <string>", p.shape.extraPublicContent._def.description),
|
|
593
532
|
m("-f, --forks", p.shape.forks._def.description),
|
|
594
533
|
m("-p, --extra-header-pages <string>", p.shape.extraHeaderPages._def.description),
|
|
595
534
|
m("-t, --extra-theme <string>", p.shape.extraTheme._def.description),
|
|
596
535
|
m("-v, --vitepress-config <string>", p.shape.vitepressConfig._def.description)
|
|
597
|
-
], Ot = R(
|
|
598
|
-
const t =
|
|
599
|
-
await
|
|
536
|
+
], Ot = R(j(ne), [...ye, ...T]).description("Transform doc to the target vitepress format.").action(async (e) => {
|
|
537
|
+
const t = H(ne, e);
|
|
538
|
+
await we(t);
|
|
600
539
|
});
|
|
601
|
-
async function
|
|
540
|
+
async function we(e) {
|
|
602
541
|
const { extraHeaderPages: t, extraPublicContent: r, extraTheme: s, vitepressConfig: n, forks: o, token: i, username: a } = e;
|
|
603
542
|
c(`
|
|
604
543
|
-> Start transform files to prepare Vitepress build.`, "info");
|
|
605
544
|
const l = Qe(), g = et().reduce(({ internals: $, forks: S }, D) => {
|
|
606
|
-
const { clone_url:
|
|
607
|
-
if (
|
|
608
|
-
if (!
|
|
545
|
+
const { clone_url: ke, private: $e, fork: z, docpress: B } = D;
|
|
546
|
+
if (ke && !$e && !B.filtered) {
|
|
547
|
+
if (!z && B.includes.length)
|
|
609
548
|
return { internals: [...$, D], forks: S };
|
|
610
|
-
if (
|
|
549
|
+
if (z)
|
|
611
550
|
return { internals: $, forks: [...S, D] };
|
|
612
551
|
}
|
|
613
552
|
return { internals: $, forks: S };
|
|
@@ -616,20 +555,20 @@ async function ke(e) {
|
|
|
616
555
|
const $ = xt(t);
|
|
617
556
|
o ? f.push(...$.filter((S) => S.link !== "/forks")) : f.push(...$);
|
|
618
557
|
}
|
|
619
|
-
r && (c(" Add extras Vitepress public folder content.", "info"),
|
|
558
|
+
r && (c(" Add extras Vitepress public folder content.", "info"), se(r, d(M, "public"))), s && (c(" Add extras Vitepress theme files.", "info"), se(s, d(Ke))), o && a && (c(" Add fork page to display external contributions.", "info"), await _t(g.forks, a, i), f.push({ text: "Forks", link: "/forks" }));
|
|
620
559
|
const w = bt(y, f, n);
|
|
621
560
|
Et(w, h);
|
|
622
561
|
}
|
|
623
562
|
function Ft() {
|
|
624
|
-
const e = new
|
|
625
|
-
const s =
|
|
626
|
-
await
|
|
563
|
+
const e = new Ce().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${ze.version}`).action(async (t, r) => {
|
|
564
|
+
const s = H("global", t);
|
|
565
|
+
await be(s), await we(s), await ve();
|
|
627
566
|
}).configureHelp({
|
|
628
567
|
sortSubcommands: !0,
|
|
629
568
|
sortOptions: !0,
|
|
630
569
|
showGlobalOptions: !0
|
|
631
570
|
}).enablePositionalOptions().passThroughOptions().addCommand(mt).addCommand(Ot).addCommand(ht);
|
|
632
|
-
return R(e, [...
|
|
571
|
+
return R(e, [...he, ...ye, ...T]), e;
|
|
633
572
|
}
|
|
634
573
|
function Ht() {
|
|
635
574
|
Ft().parseAsync(process.argv);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../src/utils/logger.ts","../src/utils/const.ts","../src/utils/functions.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/lib/vitepress.ts","../src/templates/index.ts","../src/utils/regex.ts","../src/lib/prepare.ts","../src/commands/prepare.ts","../src/cli.ts"],"sourcesContent":["/* eslint-disable dot-notation */\nimport type { ColorName } from 'chalk'\nimport chalk from 'chalk'\n\ntype LogType = keyof Pick<Console, 'info' | 'warn' | 'error' | 'debug' | 'trace'> | 'success'\n\ntype ColorMap = {\n [K in LogType]: {\n color: ColorName\n level: number\n }\n}\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\nconst colorMap: ColorMap = {\n info: { color: 'white', level: 30 },\n warn: { color: 'yellow', level: 20 },\n error: { color: 'red', level: 10 },\n debug: { color: 'blue', level: 50 },\n trace: { color: 'white', level: 40 },\n success: { color: 'green', level: 30 },\n}\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 { resolve } from 'node:path'\n\nexport const DOCPRESS_DIR = resolve(process.cwd(), 'docpress')\n\nexport const USER_REPOS_INFOS = resolve(process.cwd(), 'docpress/repositories.json')\n\nexport const USER_INFOS = resolve(process.cwd(), 'docpress/owner.json')\n\nexport const DOCS_DIR = resolve(process.cwd(), 'docpress/docs')\n\nexport const INDEX_FILE = resolve(process.cwd(), 'docpress/docs/index.md')\n\nexport const FORKS_FILE = resolve(process.cwd(), 'docpress/docs/forks.md')\n\nexport const VITEPRESS_CONFIG = resolve(process.cwd(), 'docpress/.vitepress/config.ts')\n\nexport const VITEPRESS_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme')\n\nexport const VITEPRESS_USER_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme/extras')\n\nexport const TEMPLATE_THEME = resolve(import.meta.dirname, '../templates/theme')\n","import { existsSync, mkdirSync, readdirSync, readFileSync, statSync } from 'node:fs'\nimport { basename, join, resolve } from 'node:path'\nimport axios from 'axios'\nimport { rimrafSync } from 'rimraf'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport type { getInfos } from '../lib/git.js'\nimport { USER_INFOS, USER_REPOS_INFOS } from './const.js'\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\ninterface PrettifyOpts {\n mode?: 'capitalize' | 'uppercase' | 'lowercase'\n replaceDash?: boolean\n removeIdx?: boolean\n}\n\nexport function prettify(s: string, opts: PrettifyOpts) {\n let u: string = ''\n\n if (opts?.removeIdx) {\n u = s.replace(/^\\d{2}-/, '')\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\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\nexport function isDir(path: string) {\n try {\n return statSync(path).isDirectory()\n } catch (_error) {\n return false\n }\n}\n\nexport function isFile(path: string) {\n try {\n return statSync(path).isFile()\n } catch (_error) {\n return false\n }\n}\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\nexport function getMdFiles(path: string[]) {\n return extractFiles(path).filter(file => basename(file).endsWith('.md'))\n}\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\nexport function getUserInfos() {\n return JSON.parse(readFileSync(USER_INFOS).toString()) as Awaited<ReturnType<typeof getInfos>>['user']\n}\n\nexport function getUserRepos() {\n return JSON.parse(readFileSync(USER_REPOS_INFOS).toString()) as EnhancedRepository[]\n}\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\nexport function isObject(val: any): val is object {\n return val && typeof val === 'object' && !Array.isArray(val)\n}\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\nexport function splitByComma(s: string) {\n return s.split(',')\n}\n","import { z } from 'zod'\nimport { fromZodError } from 'zod-validation-error'\nimport type { UserConfig } from 'vitepress'\nimport { loadConfigFile, prettifyEnum, splitByComma } from '../utils/functions.js'\nimport { log } from '../utils/logger.js'\n\nconst providers = ['github'] as const\n\nexport const configSchema = z.object({\n // Global\n username: z.string()\n .describe('Git provider username 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.array(z.string())\n .describe('List of comma separated repositories to retrieve from Git provider. Default to all user\\'s public repositories.'),\n // Prepare\n extraHeaderPages: z.array(z.string())\n .describe('List of comma separated additional files or directories to process Vitepress header pages.'),\n extraPublicContent: z.array(z.string())\n .describe('List of comma separated additional files or directories to process Vitepress public folder.'),\n extraTheme: z.array(z.string())\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})\n\nexport type Config = Zod.infer<typeof configSchema>\n\nexport function applyGlobalOptsTransform(data: Cli) {\n const { config, vitepressConfig, token, ...rest } = data\n\n try {\n const loadedDPConfig = configSchema.partial().parse(loadConfigFile(config)) as Config\n const loadedVPConfig = loadConfigFile(vitepressConfig) as UserConfig\n const defaultConfig = configSchema.partial().required({ branch: true, gitProvider: true }).parse({})\n const vpConfig = {\n ...loadedVPConfig,\n ...loadedDPConfig.vitepressConfig,\n }\n const mergedConfig = {\n ...loadedDPConfig,\n ...defaultConfig,\n ...rest,\n ...(Object.keys(vpConfig).length && { vitepressConfig: vpConfig }),\n }\n const parsedConfig = configSchema.partial().required({ username: true }).parse(mergedConfig)\n\n return { ...parsedConfig, token }\n } catch (error) {\n log(` An error occurred while checking configuration.\\n ${fromZodError(error).toString()}`, 'error')\n process.exit(1)\n }\n}\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 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 = Zod.infer<typeof cliSchema>\n\nexport const globalOptsSchema = cliSchema\n .partial()\n .transform(applyGlobalOptsTransform)\n\nexport type GlobalOpts = Required<Pick<Zod.infer<typeof globalOptsSchema>, 'branch' | 'gitProvider'>>\n & Omit<Zod.infer<typeof globalOptsSchema>, 'branch' | 'gitProvider'>\n","import { cliSchema } from './global.js'\n\nexport const buildOptsSchema = cliSchema\n .pick({})\n\nexport type BuildOpts = Zod.infer<typeof buildOptsSchema>\n","// import type { GlobalOpts } from './global.js'\nimport { applyGlobalOptsTransform, cliSchema } from './global.js'\n\nexport const fetchOptsSchema = cliSchema\n .pick({\n branch: true,\n config: true,\n gitProvider: true,\n reposFilter: true,\n token: true,\n username: true,\n })\n .transform(applyGlobalOptsTransform)\n\nexport type FetchOpts = Zod.infer<typeof fetchOptsSchema>\n","// import type { GlobalOpts } from './global.js'\nimport { applyGlobalOptsTransform, cliSchema } from './global.js'\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 username: true,\n vitepressConfig: true,\n })\n .transform(applyGlobalOptsTransform)\n\nexport type PrepareOpts = Zod.infer<typeof prepareOptsSchema>\n","import type { Command, Option } from 'commander'\nimport { fromZodError } from 'zod-validation-error'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport { 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 { log } from './logger.js'\n\ntype Cmd = 'fetch' | 'build' | 'prepare' | 'global'\n\ninterface Options {\n build: BuildOpts\n fetch: FetchOpts\n prepare: PrepareOpts\n global: GlobalOpts\n}\n\nexport const options = {\n build: buildOptsSchema,\n fetch: fetchOptsSchema,\n prepare: prepareOptsSchema,\n global: globalOptsSchema,\n}\n\nexport function parseOptions<T extends Cmd>(cmd: T, opts: Options[T]) {\n log(`Initializing Docpress...`, 'info', 'blue')\n log(`\\n\\n-> Checking for required environment settings and configurations.`, 'info')\n\n const res = options[cmd].safeParse(opts)\n if (res.error) {\n log(` An error occurred while checking configuration.\\n ${fromZodError(res.error).toString()}`, 'error')\n process.exit(1)\n }\n log(' Setup complete! Ready to process your documentation.', 'info')\n return res.data as Options[T]\n}\n\nexport function addOptions(cmd: Command, opts: Option[]) {\n opts.forEach(opt => cmd.addOption(opt))\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\nexport async function getInfos({ username, token, branch }: Pick<FetchOpts, 'branch'> & Pick<GlobalOpts, 'token'> & Required<Pick<GlobalOpts, 'username'>>) {\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' })\n\n return { user, repos, branch }\n}\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.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}'.`,\n 'warn',\n )\n return { source: repo.source, contributors: [] }\n }\n\n return { source: repo.source, contributors }\n}\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 } from '../schemas/fetch.js'\nimport { checkHttpStatus, createDir } from '../utils/functions.js'\nimport { DOCPRESS_DIR, DOCS_DIR, USER_INFOS, USER_REPOS_INFOS } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport { cloneRepo, getInfos } from './git.js'\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\nexport async function checkDoc(repoOwner: GlobalOpts['username'], 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\nexport async function fetchDoc({ username, branch, reposFilter, token }: FetchOpts) {\n createDir(DOCPRESS_DIR, { clean: true })\n\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\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, repo.name)\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\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\nexport async function generateInfos(user: Awaited<ReturnType<typeof getInfos>>['user'], repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n writeFileSync(USER_INFOS, JSON.stringify(user, null, 2))\n\n const enhancedRepos = await enhanceRepositories(repos, branch, reposFilter)\n writeFileSync(USER_REPOS_INFOS, JSON.stringify(enhancedRepos, null, 2))\n\n return { user, repos: enhancedRepos }\n}\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\nexport function isRepoFiltered(repo: EnhancedRepository | Awaited<ReturnType<typeof getInfos>>['repos'][number], reposFilter?: FetchOpts['reposFilter']) {\n const hasOnlyExclusions = reposFilter?.every(filter => filter.startsWith('!'))\n const isExcluded = reposFilter?.filter(filter => filter.startsWith('!'))\n .some(filter => repo.name === filter.substring(1))\n const isIncluded = !reposFilter\n || reposFilter?.filter(filter => !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 { globalOptsSchema } from '../schemas/global.js'\n\nexport const globalOpts = [\n createOption('-C, --config <string>', globalOptsSchema.innerType().shape.config._def.description),\n createOption('-T, --token <string>', globalOptsSchema.innerType().shape.token._def.description),\n createOption('-U, --username <string>', globalOptsSchema.innerType().shape.username._def.description),\n]\n","import { createCommand, createOption } from 'commander'\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\nconst cmdName = 'fetch'\n\nexport const fetchOpts = [\n createOption('-b, --branch <string>', configSchema.shape.branch._def.description)\n .default(configSchema.shape.branch._def.defaultValue()),\n createOption('-g, --git-provider <string>', configSchema.shape.gitProvider._def.description)\n .default(configSchema.shape.gitProvider._def.defaultValue()),\n createOption('-r, --repos-filter <string>', configSchema.shape.reposFilter._def.description),\n]\n\nexport const fetchCmd = addOptions(createCommand(cmdName), [...fetchOpts, ...globalOpts])\n .description('Fetch docs with the given username and git provider.')\n .action(async (opts) => {\n const parsedOpts = parseOptions(cmdName, opts)\n await main(parsedOpts)\n })\n\nexport async function main(opts: FetchOpts) {\n const { username, reposFilter, token, branch, gitProvider } = opts\n log(`\\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, 'info')\n\n await fetchDoc({ username, branch, reposFilter, gitProvider, token })\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\nconst cmdName = 'build'\n\nexport const buildOpts = []\n\nexport const buildCmd = addOptions(createCommand(cmdName), globalOpts)\n .description('Build vitepress website.')\n .action(async (_opts) => {\n await main()\n })\n\nexport async function main() {\n log(`\\n-> Start building Vitepress website.\\n\\n`, 'info')\n\n try {\n await vitepressBuild(DOCPRESS_DIR)\n log(`\\n\\nDocpress build succedeed.`, 'success')\n } catch (error) {\n log(`\\n\\nDocpress build failed : ${error}`, 'error')\n }\n}\n","import type { defineConfig } from 'vitepress'\nimport { deepMerge } from '../utils/functions.js'\nimport type { Page, SidebarProject } from './prepare.js'\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\nexport function getVitepressConfig(sidebar: SidebarProject[], nav: Page[], vitepressConfig?: ReturnType<typeof defineConfig>): Partial<ReturnType<typeof defineConfig>> {\n return vitepressConfig\n ? deepMerge(defaultVitepressConfig, vitepressConfig, { themeConfig: { sidebar, nav } })\n : deepMerge(defaultVitepressConfig, { themeConfig: { sidebar, nav } })\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { createDir } from '../utils/functions.js'\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 { readFileSync, writeFileSync } from 'node:fs'\n\nexport function replaceRelativePath(file: string, url: string) {\n const fileContent = readFileSync(file, 'utf8')\n const updatedContent = fileContent.replace(/\\[([^\\]]+)\\]\\(\\.\\.\\/([^)]+)\\)/g, (_match, p1, p2) => {\n return `[${p1}](${url}/${p2})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n\nexport function replaceReadmePath(file: string, url: string) {\n const readmeContent = readFileSync(file, 'utf8')\n const updatedContent = readmeContent\n .replace(/\\[([^\\]]+)\\]\\((?!\\.?\\/docs\\/|docs\\/|http|#)(\\.?\\/)?([^/][^)]+)\\)/g, (_match, p1, _p2, p3) => {\n return `[${p1}](${url}/${p3})`\n })\n .replace(/\\[([^\\]]+)\\]\\((\\.?\\/docs\\/|docs\\/)([^)]*)\\)/g, (_match, p1, _p2, p3) => {\n return `[${p1}](${p3})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n","import { basename, dirname, parse, resolve } from 'node:path'\nimport { appendFileSync, cpSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs'\nimport YAML from 'yaml'\nimport type { defineConfig } from 'vitepress'\nimport { generateFile } from '../templates/index.js'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport type { getUserInfos } from '../utils/functions.js'\nimport { createDir, extractFiles, getMdFiles, prettify } from '../utils/functions.js'\nimport { DOCS_DIR, FORKS_FILE, INDEX_FILE, TEMPLATE_THEME, VITEPRESS_CONFIG, VITEPRESS_THEME } from '../utils/const.js'\nimport { replaceReadmePath, replaceRelativePath } from '../utils/regex.js'\nimport { log } from '../utils/logger.js'\nimport type { EnhancedRepository } from './fetch.js'\nimport type { getInfos } from './git.js'\nimport { getContributors } from './git.js'\n\nexport interface Page {\n text: string\n link: string\n}\n\nexport interface SidebarProject {\n text: string\n collapsed: boolean\n items: Page[]\n}\n\nexport interface Feature {\n title: string\n details: string\n link: string\n}\n\nexport interface Index {\n layout: string\n hero: {\n name: string\n tagline: string\n }\n features: Feature[]\n}\n\nfunction addSources(repoUrl: string, outputPath: string) {\n const fileName = basename(outputPath)\n const title = fileName === 'introduction.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// export function addContribution(outputPath: string) {\n// const sourcesContent = `\n// If you'd like to improve or fix the code, check out the [contribution guidelines](/contribute).\n// `\n\n// appendFileSync(outputPath, sourcesContent, 'utf8')\n// }\n\nexport function generateIndex(features: Feature[], user: ReturnType<typeof getUserInfos>) {\n const { name, login, bio } = user\n return {\n layout: 'home',\n hero: {\n name: name ? `${name}'s projects` : `${login}'s projects`,\n tagline: bio ?? 'Robots are everywhere 🤖', // \\U0001F916\n },\n features,\n }\n}\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: `/${repoName}/introduction`,\n }\n\n return features ? [...features, content] : [content]\n}\n\nexport function generateSidebarProject(repoName: string, sidebarPages: Page[]) {\n return {\n text: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n collapsed: true,\n items: sidebarPages,\n }\n}\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: `/${repoName}/${fileName}`,\n }\n\n return sidebarPages ? [...sidebarPages, content] : [content]\n}\n\nexport function transformDoc(repositories: EnhancedRepository[], user: ReturnType<typeof getUserInfos>) {\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 sidebarItems = readdirSync(repository.docpress.projectPath)\n .filter((file) => {\n return statSync(resolve(repository.docpress.projectPath, file)).isFile()\n && basename(resolve(repository.docpress.projectPath, file)).endsWith('.md')\n })\n .sort((a, b) => a.localeCompare(b))\n .reduce((acc: Page[], cur, idx, arr) => {\n const file = resolve(repository.docpress.projectPath, cur)\n let filename = prettify(basename(file), { mode: 'lowercase', removeIdx: true })\n\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 if (idx === arr.length - 1) {\n let sourceFile\n if (arr.length > 1) {\n sourceFile = resolve(repository.docpress.projectPath, 'sources.md')\n log(` Add sources for repository '${repository.name}'.`, 'info')\n addSources(repository.html_url, sourceFile)\n\n return generateSidebarPages(\n repository.name,\n parse(sourceFile).name,\n generateSidebarPages(repository.name, parse(filename).name, acc),\n )\n }\n sourceFile = resolve(repository.docpress.projectPath, filename)\n addSources(repository.html_url, sourceFile)\n }\n\n return generateSidebarPages(repository.name, parse(filename).name, acc)\n }, [])\n\n sidebar.push(generateSidebarProject(repository.name, sidebarItems))\n features.push(...generateFeatures(repository.name, repository.description || ''))\n }\n\n log(` Generate index content.`, 'info')\n const index = generateIndex(features.sort((a, b) => a.title.localeCompare(b.title)), user)\n return {\n sidebar: sidebar.sort((a, b) => a.text.localeCompare(b.text)),\n index,\n }\n}\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\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\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.concat(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\nexport async function processForks(repositories: EnhancedRepository[], username: GlobalOpts['username'], 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\nexport function parseVitepressConfig(path: string) {\n return JSON.parse(readFileSync(resolve(process.cwd(), path)).toString())\n}\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 default ${JSON.stringify(vitepressConfig, null, 2)}\\n`)\n log(` Generate index file.`, 'info')\n writeFileSync(INDEX_FILE, separator.concat(YAML.stringify(index), separator))\n log(` Add Docpress theme files.`, 'info')\n const templates = extractFiles(TEMPLATE_THEME)\n for (const filePath of templates) {\n const relativePath = filePath.replace(`${TEMPLATE_THEME}/`, '')\n log(` Processing file '${resolve(VITEPRESS_THEME, relativePath)}'.`, 'debug')\n generateFile(resolve(TEMPLATE_THEME, filePath), resolve(VITEPRESS_THEME, relativePath))\n }\n}\n","import { resolve } from 'node:path'\nimport { createCommand, createOption } from 'commander'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport { configSchema } from '../schemas/global.js'\nimport { DOCPRESS_DIR, VITEPRESS_USER_THEME } from '../utils/const.js'\nimport { getUserInfos, getUserRepos } from '../utils/functions.js'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport { getVitepressConfig } from '../lib/vitepress.js'\nimport { addContent, addExtraPages, generateVitepressFiles, processForks, transformDoc } from '../lib/prepare.js'\nimport type { Page } from '../lib/prepare.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { log } from '../utils/logger.js'\nimport { globalOpts } from './global.js'\n\nconst cmdName = 'prepare'\n\nexport const prepareOpts = [\n createOption('-c, --extra-public-content <string>', configSchema.shape.extraPublicContent._def.description),\n createOption('-f, --forks', configSchema.shape.forks._def.description),\n createOption('-p, --extra-header-pages <string>', configSchema.shape.extraHeaderPages._def.description),\n createOption('-t, --extra-theme <string>', configSchema.shape.extraTheme._def.description),\n createOption('-v, --vitepress-config <string>', configSchema.shape.vitepressConfig._def.description),\n]\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\nexport async function main(opts: PrepareOpts) {\n const { extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig, forks, token, username } = opts\n log(`\\n-> Start transform files to prepare Vitepress build.`, 'info')\n\n const user = getUserInfos()\n const repositories = getUserRepos()\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 { sidebar, index } = transformDoc(repositories.internals, user)\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) {\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(sidebar, nav, vitepressConfig)\n\n generateVitepressFiles(config, index)\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// const options = {\n// fetchOpts: [\n// createOption('-b, --branch <string>', configSchema.shape.branch._def.description)\n// .default(configSchema.shape.branch._def.defaultValue()),\n// createOption('-g, --git-provider <string>', configSchema.shape.gitProvider._def.description)\n// .default(configSchema.shape.gitProvider._def.defaultValue()),\n// createOption('-r, --repos-filter <string>', configSchema.shape.reposFilter._def.description),\n// ],\n// }\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 parsedOpts = parseOptions('global', opts)\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\nexport function main() {\n const pm = getProgram()\n pm.parseAsync(process.argv)\n}\n"],"names":["getLogLevel","colorMap","log","msg","type","color","computedMsg","chalk","computedType","DOCPRESS_DIR","resolve","USER_REPOS_INFOS","USER_INFOS","DOCS_DIR","INDEX_FILE","FORKS_FILE","VITEPRESS_CONFIG","VITEPRESS_THEME","VITEPRESS_USER_THEME","TEMPLATE_THEME","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","readFileSync","getUserRepos","deepMerge","objects","obj","key","accValue","objValue","isObject","val","loadConfigFile","configPath","fullPath","fileContents","splitByComma","providers","configSchema","z","applyGlobalOptsTransform","data","config","vitepressConfig","token","rest","loadedDPConfig","loadedVPConfig","defaultConfig","vpConfig","mergedConfig","fromZodError","cliSchema","globalOptsSchema","buildOptsSchema","fetchOptsSchema","prepareOptsSchema","options","parseOptions","cmd","res","addOptions","opt","getInfos","username","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","writeFileSync","hasOnlyExclusions","filter","isExcluded","isIncluded","isFiltered","globalOpts","createOption","cmdName","fetchOpts","fetchCmd","createCommand","parsedOpts","main","gitProvider","buildCmd","_opts","vitepressBuild","defaultVitepressConfig","getVitepressConfig","sidebar","nav","generateFile","src","dest","content","dirname","replaceRelativePath","updatedContent","_match","p1","p2","replaceReadmePath","_p2","p3","addSources","repoUrl","outputPath","sourcesContent","generateIndex","features","login","bio","generateFeatures","description","generateSidebarProject","sidebarPages","generateSidebarPages","fileName","transformDoc","repositories","sidebarItems","b","filename","renameSync","sourceFile","parse","index","a","addExtraPages","files","addContent","dir","fn","absolutePath","formattedFile","addForkPage","forks","separator","header","text","frontmatter","contributions","owner","html_url","stargazers_count","YAML","processForks","source","contributor","f","generateVitepressFiles","templates","filePath","relativePath","prepareOpts","prepareCmd","extraHeaderPages","extraPublicContent","extraTheme","internals","clone_url","privateRepo","fork","docpress","pages","p","getProgram","pm","Command","pkg","_cmd","fetchFn","prepareFn","buildFn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAASA,KAAc;AACd,SAAA,OAAO,OAAO,QAAQ,IAAI,SAAY,KAAM,YAAY,CAAC,OAAO,MAAM,OAAO,QAAQ,IAAI,SAAY,CAAC,IACzG,OAAO,QAAQ,IAAI,SAAY,IAC/B;AACN;AAEA,MAAMC,IAAqB;AAAA,EACzB,MAAM,EAAE,OAAO,SAAS,OAAO,GAAG;AAAA,EAClC,MAAM,EAAE,OAAO,UAAU,OAAO,GAAG;AAAA,EACnC,OAAO,EAAE,OAAO,OAAO,OAAO,GAAG;AAAA,EACjC,OAAO,EAAE,OAAO,QAAQ,OAAO,GAAG;AAAA,EAClC,OAAO,EAAE,OA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KAAO;AAElB,EADQoF,GAAW,EACnB,WAAW,QAAQ,IAAI;AAC5B;"}
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../src/utils/logger.ts","../src/utils/const.ts","../src/utils/functions.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/lib/vitepress.ts","../src/utils/templates.ts","../src/utils/regex.ts","../src/lib/prepare.ts","../src/commands/prepare.ts","../src/cli.ts"],"sourcesContent":["/* eslint-disable dot-notation */\nimport type { ColorName } from 'chalk'\nimport chalk from 'chalk'\n\ntype LogType = keyof Pick<Console, 'info' | 'warn' | 'error' | 'debug' | 'trace'> | 'success'\n\ntype ColorMap = {\n [K in LogType]: {\n color: ColorName\n level: number\n }\n}\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\nconst colorMap: ColorMap = {\n info: { color: 'white', level: 30 },\n warn: { color: 'yellow', level: 20 },\n error: { color: 'red', level: 10 },\n debug: { color: 'blue', level: 50 },\n trace: { color: 'white', level: 40 },\n success: { color: 'green', level: 30 },\n}\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 { resolve } from 'node:path'\n\nexport const DOCPRESS_DIR = resolve(process.cwd(), 'docpress')\n\nexport const USER_REPOS_INFOS = resolve(process.cwd(), 'docpress/repositories.json')\n\nexport const USER_INFOS = resolve(process.cwd(), 'docpress/owner.json')\n\nexport const DOCS_DIR = resolve(process.cwd(), 'docpress/docs')\n\nexport const INDEX_FILE = resolve(process.cwd(), 'docpress/docs/index.md')\n\nexport const FORKS_FILE = resolve(process.cwd(), 'docpress/docs/forks.md')\n\nexport const VITEPRESS_CONFIG = resolve(process.cwd(), 'docpress/.vitepress/config.ts')\n\nexport const VITEPRESS_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme')\n\nexport const VITEPRESS_USER_THEME = resolve(process.cwd(), 'docpress/.vitepress/theme/extras')\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","import { existsSync, mkdirSync, readdirSync, readFileSync, statSync } from 'node:fs'\nimport { basename, join, resolve } from 'node:path'\nimport axios from 'axios'\nimport { rimrafSync } from 'rimraf'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport type { getInfos } from '../lib/git.js'\nimport { USER_INFOS, USER_REPOS_INFOS } from './const.js'\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\ninterface PrettifyOpts {\n mode?: 'capitalize' | 'uppercase' | 'lowercase'\n replaceDash?: boolean\n removeIdx?: boolean\n}\n\nexport function prettify(s: string, opts: PrettifyOpts) {\n let u: string = ''\n\n if (opts?.removeIdx) {\n u = s.replace(/^\\d{2}-/, '')\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\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\nexport function isDir(path: string) {\n try {\n return statSync(path).isDirectory()\n } catch (_error) {\n return false\n }\n}\n\nexport function isFile(path: string) {\n try {\n return statSync(path).isFile()\n } catch (_error) {\n return false\n }\n}\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\nexport function getMdFiles(path: string[]) {\n return extractFiles(path).filter(file => basename(file).endsWith('.md'))\n}\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\nexport function getUserInfos() {\n return JSON.parse(readFileSync(USER_INFOS).toString()) as Awaited<ReturnType<typeof getInfos>>['user']\n}\n\nexport function getUserRepos() {\n return JSON.parse(readFileSync(USER_REPOS_INFOS).toString()) as EnhancedRepository[]\n}\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\nexport function isObject(val: any): val is object {\n return val && typeof val === 'object' && !Array.isArray(val)\n}\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\nexport function splitByComma(s: string) {\n return s.split(',')\n}\n","import { z } from 'zod'\nimport { fromZodError } from 'zod-validation-error'\nimport type { UserConfig } from 'vitepress'\nimport { loadConfigFile, prettifyEnum, splitByComma } from '../utils/functions.js'\nimport { log } from '../utils/logger.js'\n\nconst providers = ['github'] as const\n\nexport const configSchema = z.object({\n // Global\n username: z.string()\n .describe('Git provider username 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.array(z.string())\n .describe('List of comma separated repositories to retrieve from Git provider. Default to all user\\'s public repositories.'),\n // Prepare\n extraHeaderPages: z.array(z.string())\n .describe('List of comma separated additional files or directories to process Vitepress header pages.'),\n extraPublicContent: z.array(z.string())\n .describe('List of comma separated additional files or directories to process Vitepress public folder.'),\n extraTheme: z.array(z.string())\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})\n\nexport type Config = Zod.infer<typeof configSchema>\n\nexport function applyGlobalOptsTransform(data: Cli) {\n const { config, vitepressConfig, token, ...rest } = data\n\n try {\n const loadedDPConfig = configSchema.partial().parse(loadConfigFile(config)) as Config\n const loadedVPConfig = loadConfigFile(vitepressConfig) as UserConfig\n const defaultConfig = configSchema.partial().required({ branch: true, gitProvider: true }).parse({})\n const vpConfig = {\n ...loadedVPConfig,\n ...loadedDPConfig.vitepressConfig,\n }\n const mergedConfig = {\n ...loadedDPConfig,\n ...defaultConfig,\n ...rest,\n ...(Object.keys(vpConfig).length && { vitepressConfig: vpConfig }),\n }\n const parsedConfig = configSchema.partial().required({ username: true }).parse(mergedConfig)\n\n return { ...parsedConfig, token }\n } catch (error) {\n log(` An error occurred while checking configuration.\\n ${fromZodError(error).toString()}`, 'error')\n process.exit(1)\n }\n}\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 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 = Zod.infer<typeof cliSchema>\n\nexport const globalOptsSchema = cliSchema\n .partial()\n .transform(applyGlobalOptsTransform)\n\nexport type GlobalOpts = Required<Pick<Zod.infer<typeof globalOptsSchema>, 'branch' | 'gitProvider'>>\n & Omit<Zod.infer<typeof globalOptsSchema>, 'branch' | 'gitProvider'>\n","import { cliSchema } from './global.js'\n\nexport const buildOptsSchema = cliSchema\n .pick({})\n\nexport type BuildOpts = Zod.infer<typeof buildOptsSchema>\n","// import type { GlobalOpts } from './global.js'\nimport { applyGlobalOptsTransform, cliSchema } from './global.js'\n\nexport const fetchOptsSchema = cliSchema\n .pick({\n branch: true,\n config: true,\n gitProvider: true,\n reposFilter: true,\n token: true,\n username: true,\n })\n .transform(applyGlobalOptsTransform)\n\nexport type FetchOpts = Zod.infer<typeof fetchOptsSchema>\n","// import type { GlobalOpts } from './global.js'\nimport { applyGlobalOptsTransform, cliSchema } from './global.js'\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 username: true,\n vitepressConfig: true,\n })\n .transform(applyGlobalOptsTransform)\n\nexport type PrepareOpts = Zod.infer<typeof prepareOptsSchema>\n","import type { Command, Option } from 'commander'\nimport { fromZodError } from 'zod-validation-error'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport { 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 { log } from './logger.js'\n\ntype Cmd = 'fetch' | 'build' | 'prepare' | 'global'\n\ninterface Options {\n build: BuildOpts\n fetch: FetchOpts\n prepare: PrepareOpts\n global: GlobalOpts\n}\n\nexport const options = {\n build: buildOptsSchema,\n fetch: fetchOptsSchema,\n prepare: prepareOptsSchema,\n global: globalOptsSchema,\n}\n\nexport function parseOptions<T extends Cmd>(cmd: T, opts: Options[T]) {\n log(`Initializing Docpress...`, 'info', 'blue')\n log(`\\n\\n-> Checking for required environment settings and configurations.`, 'info')\n\n const res = options[cmd].safeParse(opts)\n if (res.error) {\n log(` An error occurred while checking configuration.\\n ${fromZodError(res.error).toString()}`, 'error')\n process.exit(1)\n }\n log(' Setup complete! Ready to process your documentation.', 'info')\n return res.data as Options[T]\n}\n\nexport function addOptions(cmd: Command, opts: Option[]) {\n opts.forEach(opt => cmd.addOption(opt))\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\nexport async function getInfos({ username, token, branch }: Pick<FetchOpts, 'branch'> & Pick<GlobalOpts, 'token'> & Required<Pick<GlobalOpts, 'username'>>) {\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' })\n\n return { user, repos, branch }\n}\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.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}'.`,\n 'warn',\n )\n return { source: repo.source, contributors: [] }\n }\n\n return { source: repo.source, contributors }\n}\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 } from '../schemas/fetch.js'\nimport { checkHttpStatus, createDir } from '../utils/functions.js'\nimport { DOCPRESS_DIR, DOCS_DIR, USER_INFOS, USER_REPOS_INFOS } from '../utils/const.js'\nimport { log } from '../utils/logger.js'\nimport { cloneRepo, getInfos } from './git.js'\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\nexport async function checkDoc(repoOwner: GlobalOpts['username'], 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\nexport async function fetchDoc({ username, branch, reposFilter, token }: FetchOpts) {\n createDir(DOCPRESS_DIR, { clean: true })\n\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\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, repo.name)\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\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\nexport async function generateInfos(user: Awaited<ReturnType<typeof getInfos>>['user'], repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n writeFileSync(USER_INFOS, JSON.stringify(user, null, 2))\n\n const enhancedRepos = await enhanceRepositories(repos, branch, reposFilter)\n writeFileSync(USER_REPOS_INFOS, JSON.stringify(enhancedRepos, null, 2))\n\n return { user, repos: enhancedRepos }\n}\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\nexport function isRepoFiltered(repo: EnhancedRepository | Awaited<ReturnType<typeof getInfos>>['repos'][number], reposFilter?: FetchOpts['reposFilter']) {\n const hasOnlyExclusions = reposFilter?.every(filter => filter.startsWith('!'))\n const isExcluded = reposFilter?.filter(filter => filter.startsWith('!'))\n .some(filter => repo.name === filter.substring(1))\n const isIncluded = !reposFilter\n || reposFilter?.filter(filter => !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 { globalOptsSchema } from '../schemas/global.js'\n\nexport const globalOpts = [\n createOption('-C, --config <string>', globalOptsSchema.innerType().shape.config._def.description),\n createOption('-T, --token <string>', globalOptsSchema.innerType().shape.token._def.description),\n createOption('-U, --username <string>', globalOptsSchema.innerType().shape.username._def.description),\n]\n","import { createCommand, createOption } from 'commander'\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\nconst cmdName = 'fetch'\n\nexport const fetchOpts = [\n createOption('-b, --branch <string>', configSchema.shape.branch._def.description)\n .default(configSchema.shape.branch._def.defaultValue()),\n createOption('-g, --git-provider <string>', configSchema.shape.gitProvider._def.description)\n .default(configSchema.shape.gitProvider._def.defaultValue()),\n createOption('-r, --repos-filter <string>', configSchema.shape.reposFilter._def.description),\n]\n\nexport const fetchCmd = addOptions(createCommand(cmdName), [...fetchOpts, ...globalOpts])\n .description('Fetch docs with the given username and git provider.')\n .action(async (opts) => {\n const parsedOpts = parseOptions(cmdName, opts)\n await main(parsedOpts)\n })\n\nexport async function main(opts: FetchOpts) {\n const { username, reposFilter, token, branch, gitProvider } = opts\n log(`\\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, 'info')\n\n await fetchDoc({ username, branch, reposFilter, gitProvider, token })\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\nconst cmdName = 'build'\n\nexport const buildOpts = []\n\nexport const buildCmd = addOptions(createCommand(cmdName), globalOpts)\n .description('Build vitepress website.')\n .action(async (_opts) => {\n await main()\n })\n\nexport async function main() {\n log(`\\n-> Start building Vitepress website.\\n\\n`, 'info')\n\n try {\n await vitepressBuild(DOCPRESS_DIR)\n log(`\\n\\nDocpress build succedeed.`, 'success')\n } catch (error) {\n log(`\\n\\nDocpress build failed : ${error}`, 'error')\n }\n}\n","import type { defineConfig } from 'vitepress'\nimport { deepMerge } from '../utils/functions.js'\nimport type { Page, SidebarProject } from './prepare.js'\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\nexport function getVitepressConfig(sidebar: SidebarProject[], nav: Page[], vitepressConfig?: ReturnType<typeof defineConfig>): Partial<ReturnType<typeof defineConfig>> {\n return vitepressConfig\n ? deepMerge(defaultVitepressConfig, vitepressConfig, { themeConfig: { sidebar, nav } })\n : deepMerge(defaultVitepressConfig, { themeConfig: { sidebar, nav } })\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { createDir } from './functions.js'\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 { readFileSync, writeFileSync } from 'node:fs'\n\nexport function replaceRelativePath(file: string, url: string) {\n const fileContent = readFileSync(file, 'utf8')\n const updatedContent = fileContent.replace(/\\[([^\\]]+)\\]\\(\\.\\.\\/([^)]+)\\)/g, (_match, p1, p2) => {\n return `[${p1}](${url}/${p2})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n\nexport function replaceReadmePath(file: string, url: string) {\n const readmeContent = readFileSync(file, 'utf8')\n const updatedContent = readmeContent\n .replace(/\\[([^\\]]+)\\]\\((?!\\.?\\/docs\\/|docs\\/|http|#)(\\.?\\/)?([^/][^)]+)\\)/g, (_match, p1, _p2, p3) => {\n return `[${p1}](${url}/${p3})`\n })\n .replace(/\\[([^\\]]+)\\]\\((\\.?\\/docs\\/|docs\\/)([^)]*)\\)/g, (_match, p1, _p2, p3) => {\n return `[${p1}](${p3})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n","import { basename, dirname, parse, resolve } from 'node:path'\nimport { appendFileSync, cpSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs'\nimport YAML from 'yaml'\nimport type { defineConfig } from 'vitepress'\nimport { generateFile } from '../utils/templates.js'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport type { getUserInfos } from '../utils/functions.js'\nimport { createDir, extractFiles, getMdFiles, prettify } from '../utils/functions.js'\nimport { DOCS_DIR, FORKS_FILE, INDEX_FILE, TEMPLATE_THEME, VITEPRESS_CONFIG, VITEPRESS_THEME } from '../utils/const.js'\nimport { replaceReadmePath, replaceRelativePath } from '../utils/regex.js'\nimport { log } from '../utils/logger.js'\nimport type { EnhancedRepository } from './fetch.js'\nimport type { getInfos } from './git.js'\nimport { getContributors } from './git.js'\n\nexport interface Page {\n text: string\n link: string\n}\n\nexport interface SidebarProject {\n text: string\n collapsed: boolean\n items: Page[]\n}\n\nexport interface Feature {\n title: string\n details: string\n link: string\n}\n\nexport interface Index {\n layout: string\n hero: {\n name: string\n tagline: string\n }\n features: Feature[]\n}\n\nfunction addSources(repoUrl: string, outputPath: string) {\n const fileName = basename(outputPath)\n const title = fileName === 'introduction.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// export function addContribution(outputPath: string) {\n// const sourcesContent = `\n// If you'd like to improve or fix the code, check out the [contribution guidelines](/contribute).\n// `\n\n// appendFileSync(outputPath, sourcesContent, 'utf8')\n// }\n\nexport function generateIndex(features: Feature[], user: ReturnType<typeof getUserInfos>) {\n const { name, login, bio } = user\n return {\n layout: 'home',\n hero: {\n name: name ? `${name}'s projects` : `${login}'s projects`,\n tagline: bio ?? 'Robots are everywhere 🤖', // \\U0001F916\n },\n features,\n }\n}\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: `/${repoName}/introduction`,\n }\n\n return features ? [...features, content] : [content]\n}\n\nexport function generateSidebarProject(repoName: string, sidebarPages: Page[]) {\n return {\n text: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n collapsed: true,\n items: sidebarPages,\n }\n}\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: `/${repoName}/${fileName}`,\n }\n\n return sidebarPages ? [...sidebarPages, content] : [content]\n}\n\nexport function transformDoc(repositories: EnhancedRepository[], user: ReturnType<typeof getUserInfos>) {\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 sidebarItems = readdirSync(repository.docpress.projectPath)\n .filter((file) => {\n return statSync(resolve(repository.docpress.projectPath, file)).isFile()\n && basename(resolve(repository.docpress.projectPath, file)).endsWith('.md')\n })\n .sort((a, b) => a.localeCompare(b))\n .reduce((acc: Page[], cur, idx, arr) => {\n const file = resolve(repository.docpress.projectPath, cur)\n let filename = prettify(basename(file), { mode: 'lowercase', removeIdx: true })\n\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 if (idx === arr.length - 1) {\n let sourceFile\n if (arr.length > 1) {\n sourceFile = resolve(repository.docpress.projectPath, 'sources.md')\n log(` Add sources for repository '${repository.name}'.`, 'info')\n addSources(repository.html_url, sourceFile)\n\n return generateSidebarPages(\n repository.name,\n parse(sourceFile).name,\n generateSidebarPages(repository.name, parse(filename).name, acc),\n )\n }\n sourceFile = resolve(repository.docpress.projectPath, filename)\n addSources(repository.html_url, sourceFile)\n }\n\n return generateSidebarPages(repository.name, parse(filename).name, acc)\n }, [])\n\n sidebar.push(generateSidebarProject(repository.name, sidebarItems))\n features.push(...generateFeatures(repository.name, repository.description || ''))\n }\n\n log(` Generate index content.`, 'info')\n const index = generateIndex(features.sort((a, b) => a.title.localeCompare(b.title)), user)\n return {\n sidebar: sidebar.sort((a, b) => a.text.localeCompare(b.text)),\n index,\n }\n}\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\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\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.concat(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\nexport async function processForks(repositories: EnhancedRepository[], username: GlobalOpts['username'], 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\nexport function parseVitepressConfig(path: string) {\n return JSON.parse(readFileSync(resolve(process.cwd(), path)).toString())\n}\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 default ${JSON.stringify(vitepressConfig, null, 2)}\\n`)\n log(` Generate index file.`, 'info')\n writeFileSync(INDEX_FILE, separator.concat(YAML.stringify(index), separator))\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 { resolve } from 'node:path'\nimport { createCommand, createOption } from 'commander'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport { configSchema } from '../schemas/global.js'\nimport { DOCPRESS_DIR, VITEPRESS_USER_THEME } from '../utils/const.js'\nimport { getUserInfos, getUserRepos } from '../utils/functions.js'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport { getVitepressConfig } from '../lib/vitepress.js'\nimport { addContent, addExtraPages, generateVitepressFiles, processForks, transformDoc } from '../lib/prepare.js'\nimport type { Page } from '../lib/prepare.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { log } from '../utils/logger.js'\nimport { globalOpts } from './global.js'\n\nconst cmdName = 'prepare'\n\nexport const prepareOpts = [\n createOption('-c, --extra-public-content <string>', configSchema.shape.extraPublicContent._def.description),\n createOption('-f, --forks', configSchema.shape.forks._def.description),\n createOption('-p, --extra-header-pages <string>', configSchema.shape.extraHeaderPages._def.description),\n createOption('-t, --extra-theme <string>', configSchema.shape.extraTheme._def.description),\n createOption('-v, --vitepress-config <string>', configSchema.shape.vitepressConfig._def.description),\n]\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\nexport async function main(opts: PrepareOpts) {\n const { extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig, forks, token, username } = opts\n log(`\\n-> Start transform files to prepare Vitepress build.`, 'info')\n\n const user = getUserInfos()\n const repositories = getUserRepos()\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 { sidebar, index } = transformDoc(repositories.internals, user)\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) {\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(sidebar, nav, vitepressConfig)\n\n generateVitepressFiles(config, index)\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// const options = {\n// fetchOpts: [\n// createOption('-b, --branch <string>', configSchema.shape.branch._def.description)\n// .default(configSchema.shape.branch._def.defaultValue()),\n// createOption('-g, --git-provider <string>', configSchema.shape.gitProvider._def.description)\n// .default(configSchema.shape.gitProvider._def.defaultValue()),\n// createOption('-r, --repos-filter <string>', configSchema.shape.reposFilter._def.description),\n// ],\n// }\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 parsedOpts = parseOptions('global', opts)\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\nexport function main() {\n const pm = getProgram()\n pm.parseAsync(process.argv)\n}\n"],"names":["getLogLevel","colorMap","log","msg","type","color","computedMsg","chalk","computedType","DOCPRESS_DIR","resolve","USER_REPOS_INFOS","USER_INFOS","DOCS_DIR","INDEX_FILE","FORKS_FILE","VITEPRESS_CONFIG","VITEPRESS_THEME","VITEPRESS_USER_THEME","TEMPLATE_THEME","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","readFileSync","getUserRepos","deepMerge","objects","obj","key","accValue","objValue","isObject","val","loadConfigFile","configPath","fullPath","fileContents","splitByComma","providers","configSchema","z","applyGlobalOptsTransform","data","config","vitepressConfig","token","rest","loadedDPConfig","loadedVPConfig","defaultConfig","vpConfig","mergedConfig","fromZodError","cliSchema","globalOptsSchema","buildOptsSchema","fetchOptsSchema","prepareOptsSchema","options","parseOptions","cmd","res","addOptions","opt","getInfos","username","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","writeFileSync","hasOnlyExclusions","filter","isExcluded","isIncluded","isFiltered","globalOpts","createOption","cmdName","fetchOpts","fetchCmd","createCommand","parsedOpts","main","gitProvider","buildCmd","_opts","vitepressBuild","defaultVitepressConfig","getVitepressConfig","sidebar","nav","generateFile","src","dest","content","dirname","replaceRelativePath","updatedContent","_match","p1","p2","replaceReadmePath","_p2","p3","addSources","repoUrl","outputPath","sourcesContent","generateIndex","features","login","bio","generateFeatures","description","generateSidebarProject","sidebarPages","generateSidebarPages","fileName","transformDoc","repositories","sidebarItems","b","filename","renameSync","sourceFile","parse","index","a","addExtraPages","files","addContent","dir","fn","absolutePath","formattedFile","addForkPage","forks","separator","header","text","frontmatter","contributions","owner","html_url","stargazers_count","YAML","processForks","source","contributor","f","generateVitepressFiles","relativePath","prepareOpts","prepareCmd","extraHeaderPages","extraPublicContent","extraTheme","internals","clone_url","privateRepo","fork","docpress","pages","p","getProgram","pm","Command","pkg","_cmd","fetchFn","prepareFn","buildFn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,SAASA,KAAc;AACd,SAAA,OAAO,OAAO,QAAQ,IAAI,SAAY,KA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AA,EACf,CAAA,EACA,cAAc;AAAA,IACb,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,mBAAmB;AAAA,EACpB,CAAA,EACA,wBAAwB,EACxB,mBAAmB,EACnB,WAAW5F,EAAQ,EACnB,WAAW0E,EAAU,EACrB,WAAWrE,EAAQ;AAEX,SAAA7D,EAAA8I,GAAI,CAAC,GAAGvF,IAAW,GAAG0E,IAAa,GAAG7E,CAAU,CAAC,GAErD0F;AACT;AAEO,SAASnF,KAAO;AAElB,EADQkF,GAAW,EACnB,WAAW,QAAQ,IAAI;AAC5B;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Theme } from 'vitepress'
|
|
2
|
+
import DefaultTheme from 'vitepress/theme'
|
|
3
|
+
import ForkPage from './layouts/ForkPage.vue'
|
|
4
|
+
|
|
5
|
+
const userFiles = import.meta.glob('./extras/**/*', { eager: true })
|
|
6
|
+
const processedFiles = new Set<string>()
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
enhanceApp({ app }) {
|
|
10
|
+
Object.entries(userFiles).forEach(([path, file]) => {
|
|
11
|
+
if (!processedFiles.has(path)) {
|
|
12
|
+
processedFiles.add(path)
|
|
13
|
+
if (path.endsWith('.vue')) {
|
|
14
|
+
const componentName = path.replace(/^.*[\\/]/, '').replace('.vue', '')
|
|
15
|
+
app.component(componentName, (file as { default: any }).default)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
app.component('fork-page', ForkPage)
|
|
20
|
+
},
|
|
21
|
+
extends: DefaultTheme,
|
|
22
|
+
} satisfies Theme
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useData } from 'vitepress'
|
|
3
|
+
|
|
4
|
+
const { frontmatter } = useData()
|
|
5
|
+
const repositories = frontmatter.value.repoList || []
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<div class="container">
|
|
10
|
+
<Content class="vp-doc" />
|
|
11
|
+
<div class="github-repo-cards">
|
|
12
|
+
<div class="repo-grid">
|
|
13
|
+
<a
|
|
14
|
+
v-for="repo in repositories"
|
|
15
|
+
:key="repo.name"
|
|
16
|
+
:href="repo.html_url"
|
|
17
|
+
target="_blank"
|
|
18
|
+
rel="noopener noreferrer"
|
|
19
|
+
class="repo-card VPFeature link"
|
|
20
|
+
>
|
|
21
|
+
<div class="repo-content">
|
|
22
|
+
<span class="repo-name">{{ repo.name }}</span>
|
|
23
|
+
<p class="repo-description">{{ repo.description }}</p>
|
|
24
|
+
<div class="repo-stats">
|
|
25
|
+
<span class="repo-stars">
|
|
26
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16" class="repo-star-icon"><path fill-rule="evenodd" d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z" /></svg>
|
|
27
|
+
{{ repo.stargazers_count }}
|
|
28
|
+
</span>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</a>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<style scoped>
|
|
38
|
+
.container {
|
|
39
|
+
padding-left: 110px;
|
|
40
|
+
padding-right: 110px;
|
|
41
|
+
padding-top: 50px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.github-repo-cards {
|
|
45
|
+
margin: 2rem 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.repo-grid {
|
|
49
|
+
display: grid;
|
|
50
|
+
grid-template-columns: 1fr;
|
|
51
|
+
gap: 1rem;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (min-width: 480px) and (max-width: 639px) {
|
|
55
|
+
.repo-grid {
|
|
56
|
+
grid-template-columns: repeat(1, 1fr);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.container {
|
|
60
|
+
padding-left: 5%;
|
|
61
|
+
padding-right: 5%;
|
|
62
|
+
padding-top: 25px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media (min-width: 640px) and (max-width: 959px) {
|
|
67
|
+
.repo-grid {
|
|
68
|
+
grid-template-columns: repeat(2, 1fr);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@media (min-width: 960px) {
|
|
73
|
+
.repo-grid {
|
|
74
|
+
grid-template-columns: repeat(3, 1fr);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.repo-card {
|
|
79
|
+
display: block;
|
|
80
|
+
background-color: var(--vp-c-bg-alt);
|
|
81
|
+
border-radius: 8px;
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
transition: border-color 0.3s ease, background-color 0.3s ease;
|
|
84
|
+
text-decoration: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.repo-content {
|
|
88
|
+
padding: 1rem;
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
height: 100%;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.repo-name {
|
|
95
|
+
font-size: x-large;
|
|
96
|
+
color: var(--vp-c-brand-ligther);
|
|
97
|
+
margin-top: 5px;
|
|
98
|
+
margin-bottom: 15px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.repo-description {
|
|
102
|
+
font-size: 0.875rem;
|
|
103
|
+
color: var(--vp-c-text-1);
|
|
104
|
+
margin-bottom: 0;
|
|
105
|
+
flex-grow: 1;
|
|
106
|
+
line-height: 1.6;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.repo-stats {
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
font-size: 0.875rem;
|
|
113
|
+
color: var(--vp-c-text-1);
|
|
114
|
+
padding-top: 25px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.repo-stars {
|
|
118
|
+
display: flex;
|
|
119
|
+
align-items: center;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.repo-star-icon {
|
|
123
|
+
margin-right: 0.25rem;
|
|
124
|
+
fill: currentColor;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.dark .repo-stats {
|
|
128
|
+
color: var(--vp-c-text-2);
|
|
129
|
+
}
|
|
130
|
+
</style>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tobi-or-not/docpress",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"module": "dist/docpress.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@octokit/rest": "^21.0.2",
|
|
20
|
-
"axios": "^1.7.
|
|
20
|
+
"axios": "^1.7.9",
|
|
21
21
|
"chalk": "^5.3.0",
|
|
22
22
|
"commander": "^12.1.0",
|
|
23
23
|
"octokit": "^4.0.2",
|
|
@@ -25,23 +25,23 @@
|
|
|
25
25
|
"simple-git": "^3.27.0",
|
|
26
26
|
"vitepress": "^1.5.0",
|
|
27
27
|
"yaml": "^2.6.1",
|
|
28
|
-
"zod": "^3.
|
|
28
|
+
"zod": "^3.24.1",
|
|
29
29
|
"zod-validation-error": "^3.4.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@antfu/eslint-config": "^3.
|
|
32
|
+
"@antfu/eslint-config": "^3.11.2",
|
|
33
33
|
"@commitlint/cli": "^19.6.0",
|
|
34
34
|
"@commitlint/config-conventional": "^19.6.0",
|
|
35
|
-
"@octokit/types": "^13.6.
|
|
36
|
-
"@types/node": "^22.
|
|
37
|
-
"@vitest/coverage-v8": "^2.1.
|
|
38
|
-
"eslint": "^9.
|
|
35
|
+
"@octokit/types": "^13.6.2",
|
|
36
|
+
"@types/node": "^22.10.2",
|
|
37
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
38
|
+
"eslint": "^9.16.0",
|
|
39
39
|
"husky": "^9.1.7",
|
|
40
|
-
"lint-staged": "^15.2.
|
|
41
|
-
"typescript": "^5.
|
|
42
|
-
"vite": "^
|
|
43
|
-
"vite-node": "^2.1.
|
|
44
|
-
"vitest": "^2.1.
|
|
40
|
+
"lint-staged": "^15.2.11",
|
|
41
|
+
"typescript": "^5.7.2",
|
|
42
|
+
"vite": "^6.0.3",
|
|
43
|
+
"vite-node": "^2.1.8",
|
|
44
|
+
"vitest": "^2.1.8"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"registry": "https://registry.npmjs.org/",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|