@tobi-or-not/docpress 0.3.1 → 0.3.2
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 +144 -146
- 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 +1 -1
- /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,24 +1,24 @@
|
|
|
1
|
-
import { createOption as m, createCommand as
|
|
2
|
-
import
|
|
3
|
-
import { fromZodError as
|
|
4
|
-
import { z as
|
|
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
|
|
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
|
+
import { z as p } from "zod";
|
|
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
12
|
import pe from "yaml";
|
|
13
|
-
const
|
|
13
|
+
const Re = "@tobi-or-not/docpress", Te = "module", De = "0.3.2", Le = "pnpm@9.12.3", Ve = "dist/docpress.js", Ie = "types/index.d.ts", je = {
|
|
14
14
|
docpress: "bin/docpress.js"
|
|
15
|
-
},
|
|
15
|
+
}, Ae = [
|
|
16
16
|
"bin",
|
|
17
17
|
"dist",
|
|
18
18
|
"types"
|
|
19
|
-
],
|
|
19
|
+
], Ge = {
|
|
20
20
|
node: ">=20"
|
|
21
|
-
},
|
|
21
|
+
}, Ne = {
|
|
22
22
|
build: "pnpm run build:types && pnpm run build:vite",
|
|
23
23
|
"build:clean": "rimraf ./dist ./types ./tsconfig.tsbuildinfo",
|
|
24
24
|
"build:docker": "docker build --tag tobi-or-not/docpress --target prod .",
|
|
@@ -39,7 +39,7 @@ const Te = "@tobi-or-not/docpress", De = "module", Le = "0.3.1", Ie = "pnpm@9.12
|
|
|
39
39
|
"vp:dev": "vitepress dev ./docpress --port 8080",
|
|
40
40
|
"vp:dev:docker": "docker run --publish 8080:8080 --name docpress-vp --rm tobi-or-not/docs",
|
|
41
41
|
"vp:preview": "vitepress preview ./docpress --port 8080"
|
|
42
|
-
},
|
|
42
|
+
}, Me = {
|
|
43
43
|
"@octokit/rest": "^21.0.2",
|
|
44
44
|
axios: "^1.7.7",
|
|
45
45
|
chalk: "^5.3.0",
|
|
@@ -51,7 +51,7 @@ const Te = "@tobi-or-not/docpress", De = "module", Le = "0.3.1", Ie = "pnpm@9.12
|
|
|
51
51
|
yaml: "^2.6.1",
|
|
52
52
|
zod: "^3.23.8",
|
|
53
53
|
"zod-validation-error": "^3.4.0"
|
|
54
|
-
},
|
|
54
|
+
}, Ue = {
|
|
55
55
|
"@antfu/eslint-config": "^3.9.2",
|
|
56
56
|
"@commitlint/cli": "^19.6.0",
|
|
57
57
|
"@commitlint/config-conventional": "^19.6.0",
|
|
@@ -65,29 +65,29 @@ const Te = "@tobi-or-not/docpress", De = "module", Le = "0.3.1", Ie = "pnpm@9.12
|
|
|
65
65
|
vite: "^5.4.11",
|
|
66
66
|
"vite-node": "^2.1.5",
|
|
67
67
|
vitest: "^2.1.5"
|
|
68
|
-
},
|
|
68
|
+
}, He = {
|
|
69
69
|
registry: "https://registry.npmjs.org/",
|
|
70
70
|
access: "public",
|
|
71
71
|
tag: "latest"
|
|
72
|
-
},
|
|
73
|
-
name:
|
|
74
|
-
type:
|
|
75
|
-
version:
|
|
76
|
-
packageManager:
|
|
72
|
+
}, ze = {
|
|
73
|
+
name: Re,
|
|
74
|
+
type: Te,
|
|
75
|
+
version: De,
|
|
76
|
+
packageManager: Le,
|
|
77
77
|
module: Ve,
|
|
78
|
-
types:
|
|
79
|
-
bin:
|
|
80
|
-
files:
|
|
81
|
-
engines:
|
|
82
|
-
scripts:
|
|
83
|
-
dependencies:
|
|
84
|
-
devDependencies:
|
|
85
|
-
publishConfig:
|
|
78
|
+
types: Ie,
|
|
79
|
+
bin: je,
|
|
80
|
+
files: Ae,
|
|
81
|
+
engines: Ge,
|
|
82
|
+
scripts: Ne,
|
|
83
|
+
dependencies: Me,
|
|
84
|
+
devDependencies: Ue,
|
|
85
|
+
publishConfig: He
|
|
86
86
|
};
|
|
87
|
-
function
|
|
87
|
+
function Be() {
|
|
88
88
|
return typeof Number(process.env.LOG_LEVEL) == "number" && !Number.isNaN(Number(process.env.LOG_LEVEL)) ? Number(process.env.LOG_LEVEL) : 30;
|
|
89
89
|
}
|
|
90
|
-
const
|
|
90
|
+
const K = {
|
|
91
91
|
info: { color: "white", level: 30 },
|
|
92
92
|
warn: { color: "yellow", level: 20 },
|
|
93
93
|
error: { color: "red", level: 10 },
|
|
@@ -96,13 +96,13 @@ const X = {
|
|
|
96
96
|
success: { color: "green", level: 30 }
|
|
97
97
|
};
|
|
98
98
|
function c(e, t = "info", r) {
|
|
99
|
-
const s = r ?
|
|
100
|
-
|
|
99
|
+
const s = r ? J[r](e) : J[K[t].color](e), n = t === "success" ? "info" : t;
|
|
100
|
+
Be() >= K[t].level && console[n](s);
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
async function
|
|
102
|
+
const M = d(process.cwd(), "docpress"), ue = 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");
|
|
103
|
+
async function L(e) {
|
|
104
104
|
try {
|
|
105
|
-
return (await
|
|
105
|
+
return (await _e.head(e)).status;
|
|
106
106
|
} catch (t) {
|
|
107
107
|
return t.response?.status || t.status || 500;
|
|
108
108
|
}
|
|
@@ -113,50 +113,50 @@ function k(e, t) {
|
|
|
113
113
|
}
|
|
114
114
|
function E(e, { clean: t } = { clean: !1 }) {
|
|
115
115
|
try {
|
|
116
|
-
t &&
|
|
116
|
+
t && W(e) && Ee(`${e}/*`, { glob: !0 }), W(e) || Se(e, { recursive: !0 });
|
|
117
117
|
} catch (r) {
|
|
118
118
|
console.error(r);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function Xe(e) {
|
|
122
122
|
try {
|
|
123
|
-
return
|
|
123
|
+
return A(e).isDirectory();
|
|
124
124
|
} catch {
|
|
125
125
|
return !1;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
function Ye(e) {
|
|
129
129
|
try {
|
|
130
|
-
return
|
|
130
|
+
return A(e).isFile();
|
|
131
131
|
} catch {
|
|
132
132
|
return !1;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
function O(e) {
|
|
136
|
-
return (Array.isArray(e) ? e : [e]).flatMap((t) => Ye(t) ? [t] : Xe(t) ?
|
|
136
|
+
return (Array.isArray(e) ? e : [e]).flatMap((t) => Ye(t) ? [t] : Xe(t) ? ce(t).flatMap((r) => O(Pe(t, r))) : []);
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function me(e) {
|
|
139
139
|
return O(e).filter((t) => b(t).endsWith(".md"));
|
|
140
140
|
}
|
|
141
141
|
function Ze(e) {
|
|
142
142
|
return e.reduce((t, r, s, n) => s ? s === n.length - 1 ? `${t} or "${r}"` : `${t}, "${r}"` : `"${r}"`, "");
|
|
143
143
|
}
|
|
144
144
|
function Qe() {
|
|
145
|
-
return JSON.parse(C(
|
|
145
|
+
return JSON.parse(C(le).toString());
|
|
146
146
|
}
|
|
147
147
|
function et() {
|
|
148
|
-
return JSON.parse(C(
|
|
148
|
+
return JSON.parse(C(ue).toString());
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function I(...e) {
|
|
151
151
|
return e.reduce((t, r) => (r === null || Object.keys(r).forEach((s) => {
|
|
152
152
|
const n = t ? t[s] : null, o = r[s];
|
|
153
|
-
|
|
153
|
+
Z(n) && Z(o) ? t[s] = I(n, o) : t[s] = o;
|
|
154
154
|
}), t), {});
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function Z(e) {
|
|
157
157
|
return e && typeof e == "object" && !Array.isArray(e);
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function Q(e) {
|
|
160
160
|
if (!e)
|
|
161
161
|
return {};
|
|
162
162
|
try {
|
|
@@ -169,24 +169,24 @@ function ee(e) {
|
|
|
169
169
|
function P(e) {
|
|
170
170
|
return e.split(",");
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const ee = ["github"], u = p.object({
|
|
173
173
|
// Global
|
|
174
|
-
username:
|
|
174
|
+
username: p.string().describe("Git provider username used to collect data."),
|
|
175
175
|
// Fetch
|
|
176
|
-
branch:
|
|
177
|
-
gitProvider:
|
|
178
|
-
reposFilter:
|
|
176
|
+
branch: p.string().describe("Branch used to collect Git provider data.").default("main"),
|
|
177
|
+
gitProvider: p.enum(ee).describe(`Git provider used to retrieve data. Values should be ${Ze(ee)}.`).default("github"),
|
|
178
|
+
reposFilter: p.array(p.string()).describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
|
|
179
179
|
// Prepare
|
|
180
|
-
extraHeaderPages:
|
|
181
|
-
extraPublicContent:
|
|
182
|
-
extraTheme:
|
|
183
|
-
forks:
|
|
184
|
-
vitepressConfig:
|
|
180
|
+
extraHeaderPages: p.array(p.string()).describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
181
|
+
extraPublicContent: p.array(p.string()).describe("List of comma separated additional files or directories to process Vitepress public folder."),
|
|
182
|
+
extraTheme: p.array(p.string()).describe("List of comma separated additional files or directories to use as Vitepress theme."),
|
|
183
|
+
forks: p.boolean().describe("Whether or not to create the dedicated fork page that aggregate external contributions.").default(!1),
|
|
184
|
+
vitepressConfig: p.any().describe("Path to the vitepress configuration file.")
|
|
185
185
|
});
|
|
186
|
-
function
|
|
186
|
+
function U(e) {
|
|
187
187
|
const { config: t, vitepressConfig: r, token: s, ...n } = e;
|
|
188
188
|
try {
|
|
189
|
-
const o =
|
|
189
|
+
const o = u.partial().parse(Q(t)), i = Q(r), a = u.partial().required({ branch: !0, gitProvider: !0 }).parse({}), l = {
|
|
190
190
|
...i,
|
|
191
191
|
...o.vitepressConfig
|
|
192
192
|
}, g = {
|
|
@@ -195,28 +195,28 @@ function H(e) {
|
|
|
195
195
|
...n,
|
|
196
196
|
...Object.keys(l).length && { vitepressConfig: l }
|
|
197
197
|
};
|
|
198
|
-
return { ...
|
|
198
|
+
return { ...u.partial().required({ username: !0 }).parse(g), token: s };
|
|
199
199
|
} catch (o) {
|
|
200
200
|
c(` An error occurred while checking configuration.
|
|
201
|
-
${
|
|
201
|
+
${ie(o).toString()}`, "error"), process.exit(1);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
const F =
|
|
205
|
-
config:
|
|
206
|
-
token:
|
|
207
|
-
reposFilter:
|
|
208
|
-
extraHeaderPages:
|
|
209
|
-
extraPublicContent:
|
|
210
|
-
extraTheme:
|
|
211
|
-
vitepressConfig:
|
|
212
|
-
}), _ = F.partial().transform(
|
|
204
|
+
const F = u.partial().extend({
|
|
205
|
+
config: p.string().describe("Path to the docpress configuration file.").optional(),
|
|
206
|
+
token: p.string().describe("Git provider token used to collect data.").optional(),
|
|
207
|
+
reposFilter: p.string().describe(u.shape.reposFilter.description || "").transform(P).optional(),
|
|
208
|
+
extraHeaderPages: p.string().describe(u.shape.extraHeaderPages.description || "").transform(P).optional(),
|
|
209
|
+
extraPublicContent: p.string().describe(u.shape.extraPublicContent.description || "").transform(P).optional(),
|
|
210
|
+
extraTheme: p.string().describe(u.shape.extraTheme.description || "").transform(P).optional(),
|
|
211
|
+
vitepressConfig: p.string().describe(u.shape.vitepressConfig.description || "").optional()
|
|
212
|
+
}), _ = F.partial().transform(U), tt = F.pick({}), rt = F.pick({
|
|
213
213
|
branch: !0,
|
|
214
214
|
config: !0,
|
|
215
215
|
gitProvider: !0,
|
|
216
216
|
reposFilter: !0,
|
|
217
217
|
token: !0,
|
|
218
218
|
username: !0
|
|
219
|
-
}).transform(
|
|
219
|
+
}).transform(U), ot = F.pick({
|
|
220
220
|
extraHeaderPages: !0,
|
|
221
221
|
extraPublicContent: !0,
|
|
222
222
|
extraTheme: !0,
|
|
@@ -226,26 +226,26 @@ const F = p.partial().extend({
|
|
|
226
226
|
token: !0,
|
|
227
227
|
username: !0,
|
|
228
228
|
vitepressConfig: !0
|
|
229
|
-
}).transform(
|
|
229
|
+
}).transform(U), st = {
|
|
230
230
|
build: tt,
|
|
231
231
|
fetch: rt,
|
|
232
232
|
prepare: ot,
|
|
233
233
|
global: _
|
|
234
234
|
};
|
|
235
|
-
function
|
|
235
|
+
function H(e, t) {
|
|
236
236
|
c("Initializing Docpress...", "info", "blue"), c(`
|
|
237
237
|
|
|
238
238
|
-> Checking for required environment settings and configurations.`, "info");
|
|
239
239
|
const r = st[e].safeParse(t);
|
|
240
240
|
return r.error && (c(` An error occurred while checking configuration.
|
|
241
|
-
${
|
|
241
|
+
${ie(r.error).toString()}`, "error"), process.exit(1)), c(" Setup complete! Ready to process your documentation.", "info"), r.data;
|
|
242
242
|
}
|
|
243
243
|
function R(e, t) {
|
|
244
244
|
return t.forEach((r) => e.addOption(r)), e;
|
|
245
245
|
}
|
|
246
246
|
async function nt({ username: e, token: t, branch: r }) {
|
|
247
247
|
c(` Get infos for username '${e}'.`, "info");
|
|
248
|
-
const s = new
|
|
248
|
+
const s = new de({ auth: t });
|
|
249
249
|
c(" Get user infos.", "debug");
|
|
250
250
|
const { data: n } = await s.rest.users.getByUsername({ username: e });
|
|
251
251
|
c(" Get repositories infos.", "debug");
|
|
@@ -257,7 +257,7 @@ async function it({
|
|
|
257
257
|
token: t
|
|
258
258
|
}) {
|
|
259
259
|
c(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
260
|
-
const r = new
|
|
260
|
+
const r = new de({
|
|
261
261
|
auth: t,
|
|
262
262
|
log: {
|
|
263
263
|
debug: () => {
|
|
@@ -299,18 +299,18 @@ async function it({
|
|
|
299
299
|
async function ct(e, t, r, s, n) {
|
|
300
300
|
E(r, { clean: !0 });
|
|
301
301
|
try {
|
|
302
|
-
const o =
|
|
302
|
+
const o = Oe({ baseDir: r });
|
|
303
303
|
await o.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
|
|
304
304
|
for (const i of n)
|
|
305
|
-
c(` Add '${i}' to '${e}' sparse-checkout file.`, "debug"),
|
|
305
|
+
c(` Add '${i}' to '${e}' sparse-checkout file.`, "debug"), ae(d(r, ".git/info/sparse-checkout"), `${i}
|
|
306
306
|
`, "utf8");
|
|
307
|
-
c(` Clone repository '${e}'.`, "info"), await o.pull("origin", s), n.some((i) => i.includes("docs")) && (
|
|
307
|
+
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
308
|
} catch (o) {
|
|
309
309
|
c(` Error when cloning repository: ${o}.`, "error");
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
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
|
|
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 L(s), a = await L(n), l = await L(o);
|
|
314
314
|
return {
|
|
315
315
|
rootReadmeStatus: i,
|
|
316
316
|
docsFolderStatus: a,
|
|
@@ -318,15 +318,15 @@ async function at(e, t, r) {
|
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
320
|
async function dt({ username: e, branch: t, reposFilter: r, token: s }) {
|
|
321
|
-
E(
|
|
321
|
+
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
322
|
}
|
|
323
|
-
async function
|
|
323
|
+
async function pt(e, t, r) {
|
|
324
324
|
const s = [];
|
|
325
325
|
return await Promise.all(
|
|
326
326
|
e.map(async (n) => {
|
|
327
|
-
const o = t ?? n.default_branch ?? "main", i = d(
|
|
327
|
+
const o = t ?? n.default_branch ?? "main", i = d(fe, n.name), a = ge(n, r);
|
|
328
328
|
let l = [];
|
|
329
|
-
!n.fork && !n.private && !a && (l = await
|
|
329
|
+
!n.fork && !n.private && !a && (l = await ut(n, o)), s.push({
|
|
330
330
|
...n,
|
|
331
331
|
docpress: {
|
|
332
332
|
filtered: a,
|
|
@@ -340,14 +340,14 @@ async function ut(e, t, r) {
|
|
|
340
340
|
})
|
|
341
341
|
), s;
|
|
342
342
|
}
|
|
343
|
-
async function
|
|
343
|
+
async function ut(e, t) {
|
|
344
344
|
const r = await at(e.owner.login, e.name, t), s = [];
|
|
345
345
|
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
346
|
}
|
|
347
347
|
async function lt(e, t, r, s) {
|
|
348
|
-
v(
|
|
349
|
-
const n = await
|
|
350
|
-
return v(
|
|
348
|
+
v(le, JSON.stringify(e, null, 2));
|
|
349
|
+
const n = await pt(t, r, s);
|
|
350
|
+
return v(ue, JSON.stringify(n, null, 2)), { user: e, repos: n };
|
|
351
351
|
}
|
|
352
352
|
async function ft(e, t) {
|
|
353
353
|
if (!e) {
|
|
@@ -355,12 +355,12 @@ async function ft(e, t) {
|
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
357
|
await Promise.all(
|
|
358
|
-
e.filter((r) => !
|
|
358
|
+
e.filter((r) => !ge(r, t)).map(async (r) => {
|
|
359
359
|
await ct(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
|
|
360
360
|
})
|
|
361
361
|
);
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function ge(e, t) {
|
|
364
364
|
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
365
|
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !o);
|
|
366
366
|
}
|
|
@@ -368,29 +368,29 @@ const T = [
|
|
|
368
368
|
m("-C, --config <string>", _.innerType().shape.config._def.description),
|
|
369
369
|
m("-T, --token <string>", _.innerType().shape.token._def.description),
|
|
370
370
|
m("-U, --username <string>", _.innerType().shape.username._def.description)
|
|
371
|
-
],
|
|
372
|
-
m("-b, --branch <string>",
|
|
373
|
-
m("-g, --git-provider <string>",
|
|
374
|
-
m("-r, --repos-filter <string>",
|
|
375
|
-
], mt = R(
|
|
376
|
-
const t =
|
|
377
|
-
await
|
|
371
|
+
], te = "fetch", he = [
|
|
372
|
+
m("-b, --branch <string>", u.shape.branch._def.description).default(u.shape.branch._def.defaultValue()),
|
|
373
|
+
m("-g, --git-provider <string>", u.shape.gitProvider._def.description).default(u.shape.gitProvider._def.defaultValue()),
|
|
374
|
+
m("-r, --repos-filter <string>", u.shape.reposFilter._def.description)
|
|
375
|
+
], mt = R(j(te), [...he, ...T]).description("Fetch docs with the given username and git provider.").action(async (e) => {
|
|
376
|
+
const t = H(te, e);
|
|
377
|
+
await be(t);
|
|
378
378
|
});
|
|
379
|
-
async function
|
|
379
|
+
async function be(e) {
|
|
380
380
|
const { username: t, reposFilter: r, token: s, branch: n, gitProvider: o } = e;
|
|
381
381
|
c(`
|
|
382
382
|
-> 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
383
|
}
|
|
384
|
-
const gt = "build", ht = R(
|
|
385
|
-
await
|
|
384
|
+
const gt = "build", ht = R(j(gt), T).description("Build vitepress website.").action(async (e) => {
|
|
385
|
+
await ve();
|
|
386
386
|
});
|
|
387
|
-
async function
|
|
387
|
+
async function ve() {
|
|
388
388
|
c(`
|
|
389
389
|
-> Start building Vitepress website.
|
|
390
390
|
|
|
391
391
|
`, "info");
|
|
392
392
|
try {
|
|
393
|
-
await
|
|
393
|
+
await Fe(M), c(`
|
|
394
394
|
|
|
395
395
|
Docpress build succedeed.`, "success");
|
|
396
396
|
} catch (e) {
|
|
@@ -399,7 +399,7 @@ Docpress build succedeed.`, "success");
|
|
|
399
399
|
Docpress build failed : ${e}`, "error");
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
|
-
const
|
|
402
|
+
const re = {
|
|
403
403
|
base: "/",
|
|
404
404
|
lang: "en-US",
|
|
405
405
|
vite: {
|
|
@@ -437,11 +437,11 @@ const oe = {
|
|
|
437
437
|
}
|
|
438
438
|
};
|
|
439
439
|
function bt(e, t, r) {
|
|
440
|
-
return r ?
|
|
440
|
+
return r ? I(re, r, { themeConfig: { sidebar: e, nav: t } }) : I(re, { themeConfig: { sidebar: e, nav: t } });
|
|
441
441
|
}
|
|
442
442
|
function vt(e, t) {
|
|
443
443
|
const r = C(e, { encoding: "utf8" });
|
|
444
|
-
E(
|
|
444
|
+
E(N(t)), v(t, r);
|
|
445
445
|
}
|
|
446
446
|
function yt(e, t) {
|
|
447
447
|
const s = C(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (n, o, i) => `[${o}](${t}/${i})`);
|
|
@@ -451,13 +451,13 @@ function wt(e, t) {
|
|
|
451
451
|
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
452
|
v(e, s, "utf8");
|
|
453
453
|
}
|
|
454
|
-
function
|
|
454
|
+
function oe(e, t) {
|
|
455
455
|
const n = `${b(t) === "introduction.md" ? `
|
|
456
456
|
## Sources` : "# Sources"}
|
|
457
457
|
|
|
458
458
|
Take a look at the [project sources](${e}).
|
|
459
459
|
`;
|
|
460
|
-
|
|
460
|
+
ae(t, n, "utf8");
|
|
461
461
|
}
|
|
462
462
|
function kt(e, t) {
|
|
463
463
|
const { name: r, login: s, bio: n } = t;
|
|
@@ -496,21 +496,21 @@ function V(e, t, r) {
|
|
|
496
496
|
function St(e, t) {
|
|
497
497
|
const r = [], s = [];
|
|
498
498
|
for (const o of e) {
|
|
499
|
-
c(` Replace urls for repository '${o.name}'.`, "info"),
|
|
499
|
+
c(` Replace urls for repository '${o.name}'.`, "info"), me([o.docpress.projectPath]).forEach((a) => {
|
|
500
500
|
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
501
|
}), c(` Generate sidebar for repository '${o.name}'.`, "info");
|
|
502
|
-
const i =
|
|
502
|
+
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
503
|
const h = d(o.docpress.projectPath, l);
|
|
504
504
|
let f = k(b(h), { mode: "lowercase", removeIdx: !0 });
|
|
505
|
-
if (f === "readme.md" && (f = "introduction.md"), f !== b(h) &&
|
|
505
|
+
if (f === "readme.md" && (f = "introduction.md"), f !== b(h) && xe(h, d(N(h), f)), g === y.length - 1) {
|
|
506
506
|
let w;
|
|
507
507
|
if (y.length > 1)
|
|
508
|
-
return w = d(o.docpress.projectPath, "sources.md"), c(` Add sources for repository '${o.name}'.`, "info"),
|
|
508
|
+
return w = d(o.docpress.projectPath, "sources.md"), c(` Add sources for repository '${o.name}'.`, "info"), oe(o.html_url, w), V(
|
|
509
509
|
o.name,
|
|
510
510
|
x(w).name,
|
|
511
511
|
V(o.name, x(f).name, a)
|
|
512
512
|
);
|
|
513
|
-
w = d(o.docpress.projectPath, f),
|
|
513
|
+
w = d(o.docpress.projectPath, f), oe(o.html_url, w);
|
|
514
514
|
}
|
|
515
515
|
return V(o.name, x(f).name, a);
|
|
516
516
|
}, []);
|
|
@@ -524,26 +524,26 @@ function St(e, t) {
|
|
|
524
524
|
};
|
|
525
525
|
}
|
|
526
526
|
function xt(e) {
|
|
527
|
-
const t =
|
|
527
|
+
const t = me(e), r = [];
|
|
528
528
|
c(" Add extras Vitepress headers pages.", "info");
|
|
529
529
|
for (const s of t) {
|
|
530
530
|
c(` Processing file '${s}'.`, "debug");
|
|
531
|
-
const n = d(process.cwd(), s), o = d(
|
|
532
|
-
|
|
531
|
+
const n = d(process.cwd(), s), o = d(fe, k(b(s), { mode: "lowercase", removeIdx: !0 }));
|
|
532
|
+
G(n, o), r.push({
|
|
533
533
|
text: k(x(n).name, { replaceDash: !0, removeIdx: !0 }),
|
|
534
534
|
link: `/${k(x(n).name, { removeIdx: !0, mode: "lowercase" })}`
|
|
535
535
|
});
|
|
536
536
|
}
|
|
537
537
|
return r;
|
|
538
538
|
}
|
|
539
|
-
function
|
|
539
|
+
function se(e, t, r) {
|
|
540
540
|
for (const s of Array.isArray(e) ? e : [e]) {
|
|
541
541
|
const n = d(process.cwd(), s), o = O(n);
|
|
542
542
|
for (const i of o) {
|
|
543
543
|
const a = i.replace(n, ".");
|
|
544
544
|
c(` Processing file '${a}' for entry '${s}'.`, "debug");
|
|
545
545
|
const l = d(process.cwd(), i), g = d(t, a);
|
|
546
|
-
|
|
546
|
+
G(l, g);
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
}
|
|
@@ -563,7 +563,7 @@ This page serves as both a portfolio of past work and a resource for revisiting
|
|
|
563
563
|
const { name: a, owner: l, html_url: g, description: y, stargazers_count: h } = o;
|
|
564
564
|
return { name: a, owner: l.login, html_url: g, description: y, stargazers_count: h, contributions: i };
|
|
565
565
|
});
|
|
566
|
-
c(" Generate forks page.", "info"), v(
|
|
566
|
+
c(" Generate forks page.", "info"), v(We, t.concat(r, pe.stringify(n), t, s));
|
|
567
567
|
}
|
|
568
568
|
async function _t(e, t, r) {
|
|
569
569
|
const s = await Promise.all(
|
|
@@ -580,34 +580,32 @@ async function _t(e, t, r) {
|
|
|
580
580
|
function Et(e, t) {
|
|
581
581
|
const r = `---
|
|
582
582
|
`;
|
|
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
|
-
}
|
|
583
|
+
return E(N(X)), c(" Generate Vitepress config.", "info"), v(X, `export default ${JSON.stringify(e, null, 2)}
|
|
584
|
+
`), c(" Generate index file.", "info"), v(Je, r.concat(pe.stringify(t), r)), c(" Add Docpress theme files.", "info"), O(Y).forEach((s) => {
|
|
585
|
+
const n = s.replace(`${Y}/`, "");
|
|
586
|
+
vt(s, d(qe, n));
|
|
587
|
+
});
|
|
590
588
|
}
|
|
591
|
-
const
|
|
592
|
-
m("-c, --extra-public-content <string>",
|
|
593
|
-
m("-f, --forks",
|
|
594
|
-
m("-p, --extra-header-pages <string>",
|
|
595
|
-
m("-t, --extra-theme <string>",
|
|
596
|
-
m("-v, --vitepress-config <string>",
|
|
597
|
-
], Ot = R(
|
|
598
|
-
const t =
|
|
599
|
-
await
|
|
589
|
+
const ne = "prepare", ye = [
|
|
590
|
+
m("-c, --extra-public-content <string>", u.shape.extraPublicContent._def.description),
|
|
591
|
+
m("-f, --forks", u.shape.forks._def.description),
|
|
592
|
+
m("-p, --extra-header-pages <string>", u.shape.extraHeaderPages._def.description),
|
|
593
|
+
m("-t, --extra-theme <string>", u.shape.extraTheme._def.description),
|
|
594
|
+
m("-v, --vitepress-config <string>", u.shape.vitepressConfig._def.description)
|
|
595
|
+
], Ot = R(j(ne), [...ye, ...T]).description("Transform doc to the target vitepress format.").action(async (e) => {
|
|
596
|
+
const t = H(ne, e);
|
|
597
|
+
await we(t);
|
|
600
598
|
});
|
|
601
|
-
async function
|
|
599
|
+
async function we(e) {
|
|
602
600
|
const { extraHeaderPages: t, extraPublicContent: r, extraTheme: s, vitepressConfig: n, forks: o, token: i, username: a } = e;
|
|
603
601
|
c(`
|
|
604
602
|
-> Start transform files to prepare Vitepress build.`, "info");
|
|
605
603
|
const l = Qe(), g = et().reduce(({ internals: $, forks: S }, D) => {
|
|
606
|
-
const { clone_url:
|
|
607
|
-
if (
|
|
608
|
-
if (!
|
|
604
|
+
const { clone_url: ke, private: $e, fork: z, docpress: B } = D;
|
|
605
|
+
if (ke && !$e && !B.filtered) {
|
|
606
|
+
if (!z && B.includes.length)
|
|
609
607
|
return { internals: [...$, D], forks: S };
|
|
610
|
-
if (
|
|
608
|
+
if (z)
|
|
611
609
|
return { internals: $, forks: [...S, D] };
|
|
612
610
|
}
|
|
613
611
|
return { internals: $, forks: S };
|
|
@@ -616,20 +614,20 @@ async function ke(e) {
|
|
|
616
614
|
const $ = xt(t);
|
|
617
615
|
o ? f.push(...$.filter((S) => S.link !== "/forks")) : f.push(...$);
|
|
618
616
|
}
|
|
619
|
-
r && (c(" Add extras Vitepress public folder content.", "info"),
|
|
617
|
+
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
618
|
const w = bt(y, f, n);
|
|
621
619
|
Et(w, h);
|
|
622
620
|
}
|
|
623
621
|
function Ft() {
|
|
624
|
-
const e = new
|
|
625
|
-
const s =
|
|
626
|
-
await
|
|
622
|
+
const e = new Ce().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${ze.version}`).action(async (t, r) => {
|
|
623
|
+
const s = H("global", t);
|
|
624
|
+
await be(s), await we(s), await ve();
|
|
627
625
|
}).configureHelp({
|
|
628
626
|
sortSubcommands: !0,
|
|
629
627
|
sortOptions: !0,
|
|
630
628
|
showGlobalOptions: !0
|
|
631
629
|
}).enablePositionalOptions().passThroughOptions().addCommand(mt).addCommand(Ot).addCommand(ht);
|
|
632
|
-
return R(e, [...
|
|
630
|
+
return R(e, [...he, ...ye, ...T]), e;
|
|
633
631
|
}
|
|
634
632
|
function Ht() {
|
|
635
633
|
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,OAAO,SAAS,OAAO,GAAG;AAAA,EACnC,SAAS,EAAE,OAAO,SAAS,OAAO,GAAG;AACvC;AAEO,SAASC,EAAIC,GAAaC,IAAgB,QAAQC,GAAmB;AAC1E,QAAMC,IAAcD,IAAQE,EAAMF,CAAK,EAAEF,CAAG,IAAII,EAAMN,EAASG,CAAI,EAAE,KAAK,EAAED,CAAG,GACzEK,IAAeJ,MAAS,YAAY,SAASA;AAEnD,EAAIJ,GAAY,KAAKC,EAASG,CAAI,EAAE,SAC1B,QAAAI,CAAY,EAAEF,CAAW;AAErC;ACjCO,MAAMG,IAAeC,EAAQ,QAAQ,IAAA,GAA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ElD0L,KAAS9G,MACX5F,EAAI,uDAAuD,MAAM,GACjE,MAAMoN,GAAa3B,EAAa,OAAO7F,GAAUpB,CAAK,GACtDoF,EAAI,KAAK,EAAE,MAAM,SAAS,MAAM,UAAU;AAG5C,QAAMtF,IAASoF,GAAmBC,GAASC,GAAKrF,CAAe;AAE/D,EAAAiJ,GAAuBlJ,GAAQ0H,CAAK;AACtC;AC3DO,SAASwC,KAAa;AAC3B,QAAMC,IAAK,IAAIC,KACZ,KAAK,UAAU,EACf,YAAY,iDAAiD,EAC7D,QAAQ,GAAGC,GAAI,OAAO,EAAE,EACxB,OAAO,OAAOnN,GAAMoN,MAAS;AACtB,UAAAzF,IAAa7D,EAAa,UAAU9D,CAAI;AAC9C,UAAMqN,GAAQ1F,CAAU,GACxB,MAAM2F,GAAU3F,CAAU,GAC1B,MAAM4F,GAAQ;AAAA,EACf,CAAA,EACA,cAAc;AAAA,IACb,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,mBAAmB;AAAA,EACpB,CAAA,EACA,wBAAwB,EACxB,mBAAmB,EACnB,WAAW9F,EAAQ,EACnB,WAAW4E,EAAU,EACrB,WAAWvE,EAAQ;AAEX,SAAA7D,EAAAgJ,GAAI,CAAC,GAAGzF,IAAW,GAAG4E,IAAa,GAAG/E,CAAU,CAAC,GAErD4F;AACT;AAEO,SAASrF,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,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,E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AW,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
|
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
|