@tobi-or-not/docpress 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/cli.js +202 -171
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/types/lib/git.d.ts +2 -24
- package/types/templates/index.d.ts +1 -0
package/README.md
CHANGED
|
@@ -104,3 +104,26 @@ In this command:
|
|
|
104
104
|
> Ensure Docker is installed and running on your system before using this method.
|
|
105
105
|
|
|
106
106
|
Both methods provide the same functionality, so you can choose the one that fits your setup or use case.
|
|
107
|
+
|
|
108
|
+
## Rules
|
|
109
|
+
|
|
110
|
+
To ensure that the program functions correctly, please follow these conventions:
|
|
111
|
+
|
|
112
|
+
1. __Documentation folder structure__:
|
|
113
|
+
- The script will only parse the `docs/` folder located at the root level of the repository. This folder is used to import advanced documentation features, such as multi-page documentation, embedded images, and files.
|
|
114
|
+
|
|
115
|
+
2. __File naming and sorting__:
|
|
116
|
+
- If a `docs/` folder is present, all files within it will be sorted and renamed by removing any prefix numbers. This ensures that files appear cleanly in the generated website. For example, `docs/01-get-started.md` will be renamed to `get-started.md`.
|
|
117
|
+
|
|
118
|
+
3. __Handling the root readme file__:
|
|
119
|
+
- The `README.md` file located at the root of the repository will only be imported if there is no `./docs/01-readme.md` file present. This allows you to differentiate between the general README and the advanced documentation introduction page.
|
|
120
|
+
- For instance, you might use the README file for a table of contents that is not relevant in the context of the documentation website.
|
|
121
|
+
|
|
122
|
+
4. __Link management__:
|
|
123
|
+
- Any inline link in the `./README.md` file that does not point to `./docs/**` will be replaced with the corresponding GitHub link.
|
|
124
|
+
- Similarly, any inline link in the `./docs/*.md` files that does not reference `./docs/**` will also be replaced with the appropriate GitHub link.
|
|
125
|
+
|
|
126
|
+
5. __Project descriptions__:
|
|
127
|
+
- The project description displayed on the home page of the generated website is extracted from the GitHub repository's description.
|
|
128
|
+
|
|
129
|
+
By adhering to these rules, you can ensure that your documentation is processed correctly and that it aligns with the intended structure and functionality of the generated site.
|
package/dist/cli.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { createOption as m, createCommand as
|
|
2
|
-
import
|
|
3
|
-
import { fromZodError as
|
|
1
|
+
import { createOption as m, createCommand as A, Command as Se } from "commander";
|
|
2
|
+
import W from "chalk";
|
|
3
|
+
import { fromZodError as ce } from "zod-validation-error";
|
|
4
4
|
import { z as u } from "zod";
|
|
5
|
-
import { readFileSync as
|
|
6
|
-
import { resolve as d, join as
|
|
7
|
-
import
|
|
8
|
-
import { rimrafSync as
|
|
9
|
-
import { Octokit as
|
|
10
|
-
import { simpleGit as
|
|
11
|
-
import { build as
|
|
12
|
-
import
|
|
13
|
-
const Te = "@tobi-or-not/docpress",
|
|
5
|
+
import { readFileSync as C, existsSync as q, mkdirSync as xe, readdirSync as ae, statSync as G, appendFileSync as de, cpSync as N, rmSync as K, writeFileSync as v, renameSync as Pe } from "node:fs";
|
|
6
|
+
import { resolve as d, join as _e, basename as b, dirname as M, parse as x } from "node:path";
|
|
7
|
+
import Ee from "axios";
|
|
8
|
+
import { rimrafSync as Oe } from "rimraf";
|
|
9
|
+
import { Octokit as ue } from "@octokit/rest";
|
|
10
|
+
import { simpleGit as Fe } from "simple-git";
|
|
11
|
+
import { build as Re } from "vitepress";
|
|
12
|
+
import pe from "yaml";
|
|
13
|
+
const Te = "@tobi-or-not/docpress", De = "module", Le = "0.3.1", Ie = "pnpm@9.12.3", Ve = "dist/docpress.js", je = "types/index.d.ts", Ae = {
|
|
14
14
|
docpress: "bin/docpress.js"
|
|
15
|
-
},
|
|
15
|
+
}, Ge = [
|
|
16
16
|
"bin",
|
|
17
17
|
"dist",
|
|
18
18
|
"types"
|
|
19
|
-
],
|
|
19
|
+
], Ne = {
|
|
20
20
|
node: ">=20"
|
|
21
|
-
},
|
|
21
|
+
}, Me = {
|
|
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", Fe = "module", Re = "0.3.0", De = "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
|
+
}, Ue = {
|
|
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", Fe = "module", Re = "0.3.0", De = "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
|
+
}, He = {
|
|
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", Fe = "module", Re = "0.3.0", De = "pnpm@9.12
|
|
|
65
65
|
vite: "^5.4.11",
|
|
66
66
|
"vite-node": "^2.1.5",
|
|
67
67
|
vitest: "^2.1.5"
|
|
68
|
-
},
|
|
68
|
+
}, ze = {
|
|
69
69
|
registry: "https://registry.npmjs.org/",
|
|
70
70
|
access: "public",
|
|
71
71
|
tag: "latest"
|
|
72
|
-
},
|
|
72
|
+
}, Be = {
|
|
73
73
|
name: Te,
|
|
74
|
-
type:
|
|
75
|
-
version:
|
|
76
|
-
packageManager:
|
|
77
|
-
module:
|
|
78
|
-
types:
|
|
79
|
-
bin:
|
|
80
|
-
files:
|
|
81
|
-
engines:
|
|
82
|
-
scripts:
|
|
83
|
-
dependencies:
|
|
84
|
-
devDependencies:
|
|
85
|
-
publishConfig:
|
|
74
|
+
type: De,
|
|
75
|
+
version: Le,
|
|
76
|
+
packageManager: Ie,
|
|
77
|
+
module: Ve,
|
|
78
|
+
types: je,
|
|
79
|
+
bin: Ae,
|
|
80
|
+
files: Ge,
|
|
81
|
+
engines: Ne,
|
|
82
|
+
scripts: Me,
|
|
83
|
+
dependencies: Ue,
|
|
84
|
+
devDependencies: He,
|
|
85
|
+
publishConfig: ze
|
|
86
86
|
};
|
|
87
|
-
function
|
|
87
|
+
function Je() {
|
|
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 X = {
|
|
91
91
|
info: { color: "white", level: 30 },
|
|
92
92
|
warn: { color: "yellow", level: 20 },
|
|
93
93
|
error: { color: "red", level: 10 },
|
|
@@ -96,71 +96,71 @@ const K = {
|
|
|
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 ? W[r](e) : W[X[t].color](e), n = t === "success" ? "info" : t;
|
|
100
|
+
Je() >= X[t].level && console[n](s);
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
async function
|
|
102
|
+
const U = d(process.cwd(), "docpress"), le = d(process.cwd(), "docpress/repositories.json"), fe = d(process.cwd(), "docpress/owner.json"), me = d(process.cwd(), "docpress/docs"), We = d(process.cwd(), "docpress/docs/index.md"), qe = d(process.cwd(), "docpress/docs/forks.md"), Y = d(process.cwd(), "docpress/.vitepress/config.ts"), Z = d(process.cwd(), "docpress/.vitepress/theme"), Ke = d(process.cwd(), "docpress/.vitepress/theme/extras"), L = d(import.meta.dirname, "../templates/theme");
|
|
103
|
+
async function I(e) {
|
|
104
104
|
try {
|
|
105
|
-
return (await
|
|
105
|
+
return (await Ee.head(e)).status;
|
|
106
106
|
} catch (t) {
|
|
107
107
|
return t.response?.status || t.status || 500;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function k(e, t) {
|
|
111
111
|
let r = "";
|
|
112
112
|
return t?.removeIdx && (r = e.replace(/^\d{2}-/, "")), t?.replaceDash && (r = (r || e).replaceAll("-", " ")), t?.mode === "capitalize" ? r = (r || e).slice(0, 1).toUpperCase() + (r || e).slice(1).toLowerCase() : t?.mode === "lowercase" ? r = (r || e).toLowerCase() : t?.mode === "uppercase" && (r = (r || e).toUpperCase()), r || e;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function E(e, { clean: t } = { clean: !1 }) {
|
|
115
115
|
try {
|
|
116
|
-
t &&
|
|
116
|
+
t && q(e) && Oe(`${e}/*`, { glob: !0 }), q(e) || xe(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 G(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 G(e).isFile();
|
|
131
131
|
} catch {
|
|
132
132
|
return !1;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
return (Array.isArray(e) ? e : [e]).flatMap((t) => Ye(t) ? [t] : Xe(t) ?
|
|
135
|
+
function O(e) {
|
|
136
|
+
return (Array.isArray(e) ? e : [e]).flatMap((t) => Ye(t) ? [t] : Xe(t) ? ae(t).flatMap((r) => O(_e(t, r))) : []);
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
return
|
|
138
|
+
function ge(e) {
|
|
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(
|
|
145
|
+
return JSON.parse(C(fe).toString());
|
|
146
146
|
}
|
|
147
147
|
function et() {
|
|
148
|
-
return JSON.parse(
|
|
148
|
+
return JSON.parse(C(le).toString());
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function j(...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
|
+
Q(n) && Q(o) ? t[s] = j(n, o) : t[s] = o;
|
|
154
154
|
}), t), {});
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function Q(e) {
|
|
157
157
|
return e && typeof e == "object" && !Array.isArray(e);
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function ee(e) {
|
|
160
160
|
if (!e)
|
|
161
161
|
return {};
|
|
162
162
|
try {
|
|
163
|
-
const t = d(process.cwd(), e), r =
|
|
163
|
+
const t = d(process.cwd(), e), r = C(t, "utf8");
|
|
164
164
|
return JSON.parse(r);
|
|
165
165
|
} catch {
|
|
166
166
|
return {};
|
|
@@ -169,12 +169,12 @@ function Z(e) {
|
|
|
169
169
|
function P(e) {
|
|
170
170
|
return e.split(",");
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const te = ["github"], p = u.object({
|
|
173
173
|
// Global
|
|
174
174
|
username: u.string().describe("Git provider username used to collect data."),
|
|
175
175
|
// Fetch
|
|
176
176
|
branch: u.string().describe("Branch used to collect Git provider data.").default("main"),
|
|
177
|
-
gitProvider: u.enum(
|
|
177
|
+
gitProvider: u.enum(te).describe(`Git provider used to retrieve data. Values should be ${Ze(te)}.`).default("github"),
|
|
178
178
|
reposFilter: u.array(u.string()).describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
|
|
179
179
|
// Prepare
|
|
180
180
|
extraHeaderPages: u.array(u.string()).describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
@@ -186,7 +186,7 @@ const Q = ["github"], p = u.object({
|
|
|
186
186
|
function H(e) {
|
|
187
187
|
const { config: t, vitepressConfig: r, token: s, ...n } = e;
|
|
188
188
|
try {
|
|
189
|
-
const o = p.partial().parse(
|
|
189
|
+
const o = p.partial().parse(ee(t)), i = ee(r), a = p.partial().required({ branch: !0, gitProvider: !0 }).parse({}), l = {
|
|
190
190
|
...i,
|
|
191
191
|
...o.vitepressConfig
|
|
192
192
|
}, g = {
|
|
@@ -198,10 +198,10 @@ function H(e) {
|
|
|
198
198
|
return { ...p.partial().required({ username: !0 }).parse(g), token: s };
|
|
199
199
|
} catch (o) {
|
|
200
200
|
c(` An error occurred while checking configuration.
|
|
201
|
-
${
|
|
201
|
+
${ce(o).toString()}`, "error"), process.exit(1);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
const
|
|
204
|
+
const F = p.partial().extend({
|
|
205
205
|
config: u.string().describe("Path to the docpress configuration file.").optional(),
|
|
206
206
|
token: u.string().describe("Git provider token used to collect data.").optional(),
|
|
207
207
|
reposFilter: u.string().describe(p.shape.reposFilter.description || "").transform(P).optional(),
|
|
@@ -209,14 +209,14 @@ const _ = p.partial().extend({
|
|
|
209
209
|
extraPublicContent: u.string().describe(p.shape.extraPublicContent.description || "").transform(P).optional(),
|
|
210
210
|
extraTheme: u.string().describe(p.shape.extraTheme.description || "").transform(P).optional(),
|
|
211
211
|
vitepressConfig: u.string().describe(p.shape.vitepressConfig.description || "").optional()
|
|
212
|
-
}),
|
|
212
|
+
}), _ = F.partial().transform(H), 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(H), ot =
|
|
219
|
+
}).transform(H), ot = F.pick({
|
|
220
220
|
extraHeaderPages: !0,
|
|
221
221
|
extraPublicContent: !0,
|
|
222
222
|
extraTheme: !0,
|
|
@@ -230,31 +230,34 @@ const _ = p.partial().extend({
|
|
|
230
230
|
build: tt,
|
|
231
231
|
fetch: rt,
|
|
232
232
|
prepare: ot,
|
|
233
|
-
global:
|
|
233
|
+
global: _
|
|
234
234
|
};
|
|
235
|
-
function
|
|
235
|
+
function z(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
|
+
${ce(r.error).toString()}`, "error"), process.exit(1)), c(" Setup complete! Ready to process your documentation.", "info"), r.data;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
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 ue({ auth: t });
|
|
249
249
|
c(" Get user infos.", "debug");
|
|
250
|
-
const { data: n } = await s.
|
|
250
|
+
const { data: n } = await s.rest.users.getByUsername({ username: e });
|
|
251
251
|
c(" Get repositories infos.", "debug");
|
|
252
|
-
const { data: o } = await s.
|
|
252
|
+
const { data: o } = await s.rest.repos.listForUser({ username: e, sort: "full_name" });
|
|
253
253
|
return { user: n, repos: o, branch: r };
|
|
254
254
|
}
|
|
255
|
-
async function it({
|
|
255
|
+
async function it({
|
|
256
|
+
repository: e,
|
|
257
|
+
token: t
|
|
258
|
+
}) {
|
|
256
259
|
c(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
257
|
-
const r = new
|
|
260
|
+
const r = new ue({
|
|
258
261
|
auth: t,
|
|
259
262
|
log: {
|
|
260
263
|
debug: () => {
|
|
@@ -268,27 +271,46 @@ async function it({ repository: e, token: t }) {
|
|
|
268
271
|
o.includes("404") || console.error(o);
|
|
269
272
|
}
|
|
270
273
|
}
|
|
271
|
-
}), { data: s } = await r.
|
|
272
|
-
|
|
274
|
+
}), { data: s } = await r.rest.repos.get({
|
|
275
|
+
owner: e.owner.login,
|
|
276
|
+
repo: e.name
|
|
277
|
+
});
|
|
278
|
+
if (!s.source?.owner?.login)
|
|
273
279
|
return { source: s.source, contributors: [] };
|
|
274
|
-
const
|
|
280
|
+
const n = [];
|
|
281
|
+
try {
|
|
282
|
+
for await (const { data: o } of r.paginate.iterator(
|
|
283
|
+
r.rest.repos.listContributors,
|
|
284
|
+
{
|
|
285
|
+
owner: s.source.owner.login,
|
|
286
|
+
repo: s.name,
|
|
287
|
+
per_page: 500
|
|
288
|
+
}
|
|
289
|
+
))
|
|
290
|
+
n.push(...o);
|
|
291
|
+
} catch {
|
|
292
|
+
return c(
|
|
293
|
+
` Failed to get contributors infos for repository '${e.name}'.`,
|
|
294
|
+
"warn"
|
|
295
|
+
), { source: s.source, contributors: [] };
|
|
296
|
+
}
|
|
275
297
|
return { source: s.source, contributors: n };
|
|
276
298
|
}
|
|
277
299
|
async function ct(e, t, r, s, n) {
|
|
278
|
-
|
|
300
|
+
E(r, { clean: !0 });
|
|
279
301
|
try {
|
|
280
|
-
const o =
|
|
302
|
+
const o = Fe({ baseDir: r });
|
|
281
303
|
await o.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
|
|
282
304
|
for (const i of n)
|
|
283
|
-
c(` Add '${i}' to '${e}' sparse-checkout file.`, "debug"),
|
|
305
|
+
c(` Add '${i}' to '${e}' sparse-checkout file.`, "debug"), de(d(r, ".git/info/sparse-checkout"), `${i}
|
|
284
306
|
`, "utf8");
|
|
285
|
-
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")) && (N(d(r, "docs"), r, { recursive: !0 }), K(d(r, "docs"), { recursive: !0 })), K(d(r, ".git"), { recursive: !0 });
|
|
286
308
|
} catch (o) {
|
|
287
309
|
c(` Error when cloning repository: ${o}.`, "error");
|
|
288
310
|
}
|
|
289
311
|
}
|
|
290
312
|
async function at(e, t, r) {
|
|
291
|
-
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 I(s), a = await I(n), l = await I(o);
|
|
292
314
|
return {
|
|
293
315
|
rootReadmeStatus: i,
|
|
294
316
|
docsFolderStatus: a,
|
|
@@ -296,13 +318,13 @@ async function at(e, t, r) {
|
|
|
296
318
|
};
|
|
297
319
|
}
|
|
298
320
|
async function dt({ username: e, branch: t, reposFilter: r, token: s }) {
|
|
299
|
-
|
|
321
|
+
E(U, { 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));
|
|
300
322
|
}
|
|
301
323
|
async function ut(e, t, r) {
|
|
302
324
|
const s = [];
|
|
303
325
|
return await Promise.all(
|
|
304
326
|
e.map(async (n) => {
|
|
305
|
-
const o = t ?? n.default_branch ?? "main", i = d(
|
|
327
|
+
const o = t ?? n.default_branch ?? "main", i = d(me, n.name), a = he(n, r);
|
|
306
328
|
let l = [];
|
|
307
329
|
!n.fork && !n.private && !a && (l = await pt(n, o)), s.push({
|
|
308
330
|
...n,
|
|
@@ -323,9 +345,9 @@ async function pt(e, t) {
|
|
|
323
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);
|
|
324
346
|
}
|
|
325
347
|
async function lt(e, t, r, s) {
|
|
326
|
-
|
|
348
|
+
v(fe, JSON.stringify(e, null, 2));
|
|
327
349
|
const n = await ut(t, r, s);
|
|
328
|
-
return
|
|
350
|
+
return v(le, JSON.stringify(n, null, 2)), { user: e, repos: n };
|
|
329
351
|
}
|
|
330
352
|
async function ft(e, t) {
|
|
331
353
|
if (!e) {
|
|
@@ -333,42 +355,42 @@ async function ft(e, t) {
|
|
|
333
355
|
return;
|
|
334
356
|
}
|
|
335
357
|
await Promise.all(
|
|
336
|
-
e.filter((r) => !
|
|
358
|
+
e.filter((r) => !he(r, t)).map(async (r) => {
|
|
337
359
|
await ct(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
|
|
338
360
|
})
|
|
339
361
|
);
|
|
340
362
|
}
|
|
341
|
-
function
|
|
363
|
+
function he(e, t) {
|
|
342
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;
|
|
343
365
|
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !o);
|
|
344
366
|
}
|
|
345
367
|
const T = [
|
|
346
|
-
m("-C, --config <string>",
|
|
347
|
-
m("-T, --token <string>",
|
|
348
|
-
m("-U, --username <string>",
|
|
349
|
-
],
|
|
368
|
+
m("-C, --config <string>", _.innerType().shape.config._def.description),
|
|
369
|
+
m("-T, --token <string>", _.innerType().shape.token._def.description),
|
|
370
|
+
m("-U, --username <string>", _.innerType().shape.username._def.description)
|
|
371
|
+
], re = "fetch", be = [
|
|
350
372
|
m("-b, --branch <string>", p.shape.branch._def.description).default(p.shape.branch._def.defaultValue()),
|
|
351
373
|
m("-g, --git-provider <string>", p.shape.gitProvider._def.description).default(p.shape.gitProvider._def.defaultValue()),
|
|
352
374
|
m("-r, --repos-filter <string>", p.shape.reposFilter._def.description)
|
|
353
|
-
], mt =
|
|
354
|
-
const t =
|
|
355
|
-
await
|
|
375
|
+
], mt = R(A(re), [...be, ...T]).description("Fetch docs with the given username and git provider.").action(async (e) => {
|
|
376
|
+
const t = z(re, e);
|
|
377
|
+
await ve(t);
|
|
356
378
|
});
|
|
357
|
-
async function
|
|
379
|
+
async function ve(e) {
|
|
358
380
|
const { username: t, reposFilter: r, token: s, branch: n, gitProvider: o } = e;
|
|
359
381
|
c(`
|
|
360
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 });
|
|
361
383
|
}
|
|
362
|
-
const gt = "build", ht =
|
|
363
|
-
await
|
|
384
|
+
const gt = "build", ht = R(A(gt), T).description("Build vitepress website.").action(async (e) => {
|
|
385
|
+
await ye();
|
|
364
386
|
});
|
|
365
|
-
async function
|
|
387
|
+
async function ye() {
|
|
366
388
|
c(`
|
|
367
389
|
-> Start building Vitepress website.
|
|
368
390
|
|
|
369
391
|
`, "info");
|
|
370
392
|
try {
|
|
371
|
-
await
|
|
393
|
+
await Re(U), c(`
|
|
372
394
|
|
|
373
395
|
Docpress build succedeed.`, "success");
|
|
374
396
|
} catch (e) {
|
|
@@ -377,7 +399,7 @@ Docpress build succedeed.`, "success");
|
|
|
377
399
|
Docpress build failed : ${e}`, "error");
|
|
378
400
|
}
|
|
379
401
|
}
|
|
380
|
-
const
|
|
402
|
+
const oe = {
|
|
381
403
|
base: "/",
|
|
382
404
|
lang: "en-US",
|
|
383
405
|
vite: {
|
|
@@ -415,25 +437,29 @@ const te = {
|
|
|
415
437
|
}
|
|
416
438
|
};
|
|
417
439
|
function bt(e, t, r) {
|
|
418
|
-
return r ?
|
|
440
|
+
return r ? j(oe, r, { themeConfig: { sidebar: e, nav: t } }) : j(oe, { themeConfig: { sidebar: e, nav: t } });
|
|
419
441
|
}
|
|
420
442
|
function vt(e, t) {
|
|
421
|
-
const
|
|
422
|
-
|
|
443
|
+
const r = C(e, { encoding: "utf8" });
|
|
444
|
+
E(M(t)), v(t, r);
|
|
423
445
|
}
|
|
424
446
|
function yt(e, t) {
|
|
425
|
-
const s =
|
|
426
|
-
|
|
447
|
+
const s = C(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (n, o, i) => `[${o}](${t}/${i})`);
|
|
448
|
+
v(e, s, "utf8");
|
|
449
|
+
}
|
|
450
|
+
function wt(e, t) {
|
|
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
|
+
v(e, s, "utf8");
|
|
427
453
|
}
|
|
428
|
-
function
|
|
454
|
+
function se(e, t) {
|
|
429
455
|
const n = `${b(t) === "introduction.md" ? `
|
|
430
456
|
## Sources` : "# Sources"}
|
|
431
457
|
|
|
432
458
|
Take a look at the [project sources](${e}).
|
|
433
459
|
`;
|
|
434
|
-
|
|
460
|
+
de(t, n, "utf8");
|
|
435
461
|
}
|
|
436
|
-
function
|
|
462
|
+
function kt(e, t) {
|
|
437
463
|
const { name: r, login: s, bio: n } = t;
|
|
438
464
|
return {
|
|
439
465
|
layout: "home",
|
|
@@ -445,83 +471,83 @@ function wt(e, t) {
|
|
|
445
471
|
features: e
|
|
446
472
|
};
|
|
447
473
|
}
|
|
448
|
-
function
|
|
474
|
+
function $t(e, t, r) {
|
|
449
475
|
const s = {
|
|
450
|
-
title:
|
|
476
|
+
title: k(e, { mode: "capitalize", replaceDash: !0 }),
|
|
451
477
|
details: t,
|
|
452
478
|
link: `/${e}/introduction`
|
|
453
479
|
};
|
|
454
480
|
return r ? [...r, s] : [s];
|
|
455
481
|
}
|
|
456
|
-
function
|
|
482
|
+
function Ct(e, t) {
|
|
457
483
|
return {
|
|
458
|
-
text:
|
|
484
|
+
text: k(e, { mode: "capitalize", replaceDash: !0 }),
|
|
459
485
|
collapsed: !0,
|
|
460
486
|
items: t
|
|
461
487
|
};
|
|
462
488
|
}
|
|
463
|
-
function
|
|
489
|
+
function V(e, t, r) {
|
|
464
490
|
const s = {
|
|
465
|
-
text: t === "introduction" ? "Introduction" :
|
|
491
|
+
text: t === "introduction" ? "Introduction" : k(t, { mode: "capitalize", replaceDash: !0 }),
|
|
466
492
|
link: `/${e}/${t}`
|
|
467
493
|
};
|
|
468
494
|
return r ? [...r, s] : [s];
|
|
469
495
|
}
|
|
470
|
-
function
|
|
496
|
+
function St(e, t) {
|
|
471
497
|
const r = [], s = [];
|
|
472
498
|
for (const o of e) {
|
|
473
|
-
c(` Replace urls for repository '${o.name}'.`, "info"),
|
|
474
|
-
c(` Processing file '${b(a)}' for repository '${o.name}'.`, "debug"),
|
|
499
|
+
c(` Replace urls for repository '${o.name}'.`, "info"), ge([o.docpress.projectPath]).forEach((a) => {
|
|
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}`);
|
|
475
501
|
}), c(` Generate sidebar for repository '${o.name}'.`, "info");
|
|
476
|
-
const i =
|
|
502
|
+
const i = ae(o.docpress.projectPath).filter((a) => G(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) => {
|
|
477
503
|
const h = d(o.docpress.projectPath, l);
|
|
478
|
-
let f =
|
|
479
|
-
if (f === "readme.md" && (f = "introduction.md"), f !== b(h) &&
|
|
480
|
-
let
|
|
481
|
-
if (
|
|
482
|
-
return
|
|
504
|
+
let f = k(b(h), { mode: "lowercase", removeIdx: !0 });
|
|
505
|
+
if (f === "readme.md" && (f = "introduction.md"), f !== b(h) && Pe(h, d(M(h), f)), g === y.length - 1) {
|
|
506
|
+
let w;
|
|
507
|
+
if (y.length > 1)
|
|
508
|
+
return w = d(o.docpress.projectPath, "sources.md"), c(` Add sources for repository '${o.name}'.`, "info"), se(o.html_url, w), V(
|
|
483
509
|
o.name,
|
|
484
|
-
|
|
485
|
-
|
|
510
|
+
x(w).name,
|
|
511
|
+
V(o.name, x(f).name, a)
|
|
486
512
|
);
|
|
487
|
-
|
|
513
|
+
w = d(o.docpress.projectPath, f), se(o.html_url, w);
|
|
488
514
|
}
|
|
489
|
-
return
|
|
515
|
+
return V(o.name, x(f).name, a);
|
|
490
516
|
}, []);
|
|
491
|
-
s.push(
|
|
517
|
+
s.push(Ct(o.name, i)), r.push(...$t(o.name, o.description || ""));
|
|
492
518
|
}
|
|
493
519
|
c(" Generate index content.", "info");
|
|
494
|
-
const n =
|
|
520
|
+
const n = kt(r.sort((o, i) => o.title.localeCompare(i.title)), t);
|
|
495
521
|
return {
|
|
496
522
|
sidebar: s.sort((o, i) => o.text.localeCompare(i.text)),
|
|
497
523
|
index: n
|
|
498
524
|
};
|
|
499
525
|
}
|
|
500
|
-
function
|
|
501
|
-
const t =
|
|
526
|
+
function xt(e) {
|
|
527
|
+
const t = ge(e), r = [];
|
|
502
528
|
c(" Add extras Vitepress headers pages.", "info");
|
|
503
529
|
for (const s of t) {
|
|
504
530
|
c(` Processing file '${s}'.`, "debug");
|
|
505
|
-
const n = d(process.cwd(), s), o = d(
|
|
506
|
-
|
|
507
|
-
text:
|
|
508
|
-
link: `/${
|
|
531
|
+
const n = d(process.cwd(), s), o = d(me, k(b(s), { mode: "lowercase", removeIdx: !0 }));
|
|
532
|
+
N(n, o), r.push({
|
|
533
|
+
text: k(x(n).name, { replaceDash: !0, removeIdx: !0 }),
|
|
534
|
+
link: `/${k(x(n).name, { removeIdx: !0, mode: "lowercase" })}`
|
|
509
535
|
});
|
|
510
536
|
}
|
|
511
537
|
return r;
|
|
512
538
|
}
|
|
513
|
-
function
|
|
539
|
+
function ne(e, t, r) {
|
|
514
540
|
for (const s of Array.isArray(e) ? e : [e]) {
|
|
515
|
-
const n = d(process.cwd(), s), o =
|
|
541
|
+
const n = d(process.cwd(), s), o = O(n);
|
|
516
542
|
for (const i of o) {
|
|
517
543
|
const a = i.replace(n, ".");
|
|
518
544
|
c(` Processing file '${a}' for entry '${s}'.`, "debug");
|
|
519
545
|
const l = d(process.cwd(), i), g = d(t, a);
|
|
520
|
-
|
|
546
|
+
N(l, g);
|
|
521
547
|
}
|
|
522
548
|
}
|
|
523
549
|
}
|
|
524
|
-
function
|
|
550
|
+
function Pt(e) {
|
|
525
551
|
const t = `---
|
|
526
552
|
`, r = `layout: fork-page
|
|
527
553
|
repoList:
|
|
@@ -534,12 +560,12 @@ Every tile below represents a unique project where contributions have been made-
|
|
|
534
560
|
|
|
535
561
|
This page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.
|
|
536
562
|
`, n = e.map(({ repository: o, contributions: i }) => {
|
|
537
|
-
const { name: a, owner: l, html_url: g, description:
|
|
538
|
-
return { name: a, owner: l.login, html_url: g, description:
|
|
563
|
+
const { name: a, owner: l, html_url: g, description: y, stargazers_count: h } = o;
|
|
564
|
+
return { name: a, owner: l.login, html_url: g, description: y, stargazers_count: h, contributions: i };
|
|
539
565
|
});
|
|
540
|
-
c(" Generate forks page.", "info"),
|
|
566
|
+
c(" Generate forks page.", "info"), v(qe, t.concat(r, pe.stringify(n), t, s));
|
|
541
567
|
}
|
|
542
|
-
async function
|
|
568
|
+
async function _t(e, t, r) {
|
|
543
569
|
const s = await Promise.all(
|
|
544
570
|
e.map(async (n) => {
|
|
545
571
|
const { source: o, contributors: i } = await it({ repository: n, token: r });
|
|
@@ -549,62 +575,67 @@ async function Pt(e, t, r) {
|
|
|
549
575
|
};
|
|
550
576
|
})
|
|
551
577
|
).then((n) => n.filter(({ repository: o, contributions: i }) => !!o && i));
|
|
552
|
-
|
|
578
|
+
Pt(s);
|
|
553
579
|
}
|
|
554
580
|
function Et(e, t) {
|
|
555
581
|
const r = `---
|
|
556
582
|
`;
|
|
557
|
-
|
|
558
|
-
`), c(" Generate index file.", "info"),
|
|
583
|
+
E(M(Y)), c(" Generate Vitepress config.", "info"), v(Y, `export default ${JSON.stringify(e, null, 2)}
|
|
584
|
+
`), c(" Generate index file.", "info"), v(We, r.concat(pe.stringify(t), r)), c(" Add Docpress theme files.", "info");
|
|
585
|
+
const s = O(L);
|
|
586
|
+
for (const n of s) {
|
|
587
|
+
const o = n.replace(`${L}/`, "");
|
|
588
|
+
c(` Processing file '${d(Z, o)}'.`, "debug"), vt(d(L, n), d(Z, o));
|
|
589
|
+
}
|
|
559
590
|
}
|
|
560
|
-
const
|
|
591
|
+
const ie = "prepare", we = [
|
|
561
592
|
m("-c, --extra-public-content <string>", p.shape.extraPublicContent._def.description),
|
|
562
593
|
m("-f, --forks", p.shape.forks._def.description),
|
|
563
594
|
m("-p, --extra-header-pages <string>", p.shape.extraHeaderPages._def.description),
|
|
564
595
|
m("-t, --extra-theme <string>", p.shape.extraTheme._def.description),
|
|
565
596
|
m("-v, --vitepress-config <string>", p.shape.vitepressConfig._def.description)
|
|
566
|
-
],
|
|
567
|
-
const t =
|
|
568
|
-
await
|
|
597
|
+
], Ot = R(A(ie), [...we, ...T]).description("Transform doc to the target vitepress format.").action(async (e) => {
|
|
598
|
+
const t = z(ie, e);
|
|
599
|
+
await ke(t);
|
|
569
600
|
});
|
|
570
|
-
async function
|
|
601
|
+
async function ke(e) {
|
|
571
602
|
const { extraHeaderPages: t, extraPublicContent: r, extraTheme: s, vitepressConfig: n, forks: o, token: i, username: a } = e;
|
|
572
603
|
c(`
|
|
573
604
|
-> Start transform files to prepare Vitepress build.`, "info");
|
|
574
|
-
const l = Qe(), g = et().reduce(({ internals: $, forks:
|
|
575
|
-
const { clone_url:
|
|
576
|
-
if (
|
|
577
|
-
if (!
|
|
578
|
-
return { internals: [...$,
|
|
579
|
-
if (
|
|
580
|
-
return { internals: $, forks: [...
|
|
605
|
+
const l = Qe(), g = et().reduce(({ internals: $, forks: S }, D) => {
|
|
606
|
+
const { clone_url: $e, private: Ce, fork: B, docpress: J } = D;
|
|
607
|
+
if ($e && !Ce && !J.filtered) {
|
|
608
|
+
if (!B && J.includes.length)
|
|
609
|
+
return { internals: [...$, D], forks: S };
|
|
610
|
+
if (B)
|
|
611
|
+
return { internals: $, forks: [...S, D] };
|
|
581
612
|
}
|
|
582
|
-
return { internals: $, forks:
|
|
583
|
-
}, { internals: [], forks: [] }), { sidebar:
|
|
613
|
+
return { internals: $, forks: S };
|
|
614
|
+
}, { internals: [], forks: [] }), { sidebar: y, index: h } = St(g.internals, l), f = [];
|
|
584
615
|
if (t) {
|
|
585
|
-
const $ =
|
|
586
|
-
o ? f.push(...$.filter((
|
|
616
|
+
const $ = xt(t);
|
|
617
|
+
o ? f.push(...$.filter((S) => S.link !== "/forks")) : f.push(...$);
|
|
587
618
|
}
|
|
588
|
-
r && (c(" Add extras Vitepress public folder content.", "info"),
|
|
589
|
-
const
|
|
590
|
-
Et(
|
|
591
|
-
}
|
|
592
|
-
function
|
|
593
|
-
const e = new
|
|
594
|
-
const s =
|
|
595
|
-
await
|
|
619
|
+
r && (c(" Add extras Vitepress public folder content.", "info"), ne(r, d(U, "public"))), s && (c(" Add extras Vitepress theme files.", "info"), ne(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
|
+
const w = bt(y, f, n);
|
|
621
|
+
Et(w, h);
|
|
622
|
+
}
|
|
623
|
+
function Ft() {
|
|
624
|
+
const e = new Se().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${Be.version}`).action(async (t, r) => {
|
|
625
|
+
const s = z("global", t);
|
|
626
|
+
await ve(s), await ke(s), await ye();
|
|
596
627
|
}).configureHelp({
|
|
597
628
|
sortSubcommands: !0,
|
|
598
629
|
sortOptions: !0,
|
|
599
630
|
showGlobalOptions: !0
|
|
600
|
-
}).enablePositionalOptions().passThroughOptions().addCommand(mt).addCommand(
|
|
601
|
-
return
|
|
631
|
+
}).enablePositionalOptions().passThroughOptions().addCommand(mt).addCommand(Ot).addCommand(ht);
|
|
632
|
+
return R(e, [...be, ...we, ...T]), e;
|
|
602
633
|
}
|
|
603
634
|
function Ht() {
|
|
604
|
-
|
|
635
|
+
Ft().parseAsync(process.argv);
|
|
605
636
|
}
|
|
606
637
|
export {
|
|
607
|
-
|
|
638
|
+
Ft as getProgram,
|
|
608
639
|
Ht as main
|
|
609
640
|
};
|
|
610
641
|
//# sourceMappingURL=cli.js.map
|
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/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 { GetResponseTypeFromEndpointMethod } from '@octokit/types'\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.request('GET /users/{username}', { username })\n log(` Get repositories infos.`, 'debug')\n const { data: repos } = await octokit.request('GET /users/{username}/repos', { username, sort: 'full_name' })\n\n return { user, repos, branch }\n}\n\nexport async function getContributors({ repository, token }: { repository: EnhancedRepository, token: GlobalOpts['token'] }) {\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.request('GET /repos/{owner}/{repo}', { owner: repository.owner.login, repo: repository.name })\n if (!repo.source?.owner.login) {\n return { source: repo.source, contributors: [] }\n }\n const { data: contributors } = await octokit.request('GET /repos/{owner}/{repo}/contributors', { owner: repo.source.owner.login, repo: repo.name }).catch((_error) => {\n log(` Failed to get contributors infos for repository '${repository.name}'.`, 'warn')\n return { data: [] } as unknown as GetResponseTypeFromEndpointMethod<typeof octokit.repos.listContributors>\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'\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 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, VITEPRESS_CONFIG } 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}\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, TEMPLATE_THEME, VITEPRESS_THEME, 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 log(` Add Docpress theme files.`, 'info')\n addContent(TEMPLATE_THEME, resolve(VITEPRESS_THEME))\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","_error","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","replaceRelativePath","updatedContent","_match","p1","p2","replaceReadmePath","_p2","p3","addSources","repoUrl","outputPath","sourcesContent","generateIndex","features","login","bio","generateFeatures","description","content","generateSidebarProject","sidebarPages","generateSidebarPages","fileName","transformDoc","repositories","sidebarItems","b","filename","renameSync","dirname","sourceFile","parse","index","a","addExtraPages","files","src","dest","addContent","dir","fn","absolutePath","formattedFile","addForkPage","forks","separator","header","text","frontmatter","contributions","owner","html_url","stargazers_count","YAML","processForks","source","contributor","f","generateVitepressFiles","prepareOpts","prepareCmd","extraHeaderPages","extraPublicContent","extraTheme","internals","clone_url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/BoM,EAAAnL,IAAgBT,EAAQO,EAAe,CAAC,GAC/C8M,MACF7N,EAAI,wCAAwC,MAAM,GACvCoM,EAAAyB,GAAYrN,EAAQQ,EAAoB,CAAC,IAElD0L,KAAS9G,MACX5F,EAAI,uDAAuD,MAAM,GACjE,MAAMoN,GAAa9B,EAAa,OAAO1F,GAAUpB,CAAK,GACtDqF,EAAI,KAAK,EAAE,MAAM,SAAS,MAAM,UAAU;AAG5C,QAAMvF,IAASqF,GAAmBC,GAASC,GAAKtF,CAAe;AAE/D,EAAAiJ,GAAuBlJ,GAAQwH,CAAK;AACtC;AC7DO,SAASuC,KAAa;AAC3B,QAAMC,IAAK,IAAIC,KACZ,KAAK,UAAU,EACf,YAAY,iDAAiD,EAC7D,QAAQ,GAAGC,GAAI,OAAO,EAAE,EACxB,OAAO,OAAOhN,GAAMiN,MAAS;AACtB,UAAArF,IAAa9D,EAAa,UAAU9D,CAAI;AAC9C,UAAMkN,GAAQtF,CAAU,GACxB,MAAMuF,GAAUvF,CAAU,GAC1B,MAAMwF,GAAQ;AAAA,EACf,CAAA,EACA,cAAc;AAAA,IACb,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,mBAAmB;AAAA,EACpB,CAAA,EACA,wBAAwB,EACxB,mBAAmB,EACnB,WAAW1F,EAAQ,EACnB,WAAWwE,EAAU,EACrB,WAAWnE,EAAQ;AAEX,SAAA9D,EAAA6I,GAAI,CAAC,GAAGrF,IAAW,GAAGwE,IAAa,GAAG3E,CAAU,CAAC,GAErDwF;AACT;AAEO,SAASjF,KAAO;AAElB,EADQgF,KACR,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/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,EA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nB,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;"}
|
package/package.json
CHANGED
package/types/lib/git.d.ts
CHANGED
|
@@ -240,7 +240,7 @@ export declare function getInfos({ username, token, branch }: Pick<FetchOpts, 'b
|
|
|
240
240
|
}[];
|
|
241
241
|
branch: string | undefined;
|
|
242
242
|
}>;
|
|
243
|
-
export declare function getContributors({ repository, token }: {
|
|
243
|
+
export declare function getContributors({ repository, token, }: {
|
|
244
244
|
repository: EnhancedRepository;
|
|
245
245
|
token: GlobalOpts['token'];
|
|
246
246
|
}): Promise<{
|
|
@@ -510,28 +510,6 @@ export declare function getContributors({ repository, token }: {
|
|
|
510
510
|
starred_at?: string;
|
|
511
511
|
anonymous_access_enabled?: boolean;
|
|
512
512
|
};
|
|
513
|
-
contributors:
|
|
514
|
-
login?: string;
|
|
515
|
-
id?: number;
|
|
516
|
-
node_id?: string;
|
|
517
|
-
avatar_url?: string;
|
|
518
|
-
gravatar_id?: string | null;
|
|
519
|
-
url?: string;
|
|
520
|
-
html_url?: string;
|
|
521
|
-
followers_url?: string;
|
|
522
|
-
following_url?: string;
|
|
523
|
-
gists_url?: string;
|
|
524
|
-
starred_url?: string;
|
|
525
|
-
subscriptions_url?: string;
|
|
526
|
-
organizations_url?: string;
|
|
527
|
-
repos_url?: string;
|
|
528
|
-
events_url?: string;
|
|
529
|
-
received_events_url?: string;
|
|
530
|
-
type: string;
|
|
531
|
-
site_admin?: boolean;
|
|
532
|
-
contributions: number;
|
|
533
|
-
email?: string;
|
|
534
|
-
name?: string;
|
|
535
|
-
}[];
|
|
513
|
+
contributors: any[];
|
|
536
514
|
}>;
|
|
537
515
|
export declare function cloneRepo(name: string, url: string, projectDir: string, branch: string, includes: string[]): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateFile(src: string, dest: string): void;
|