@tobi-or-not/docpress 0.2.3 → 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 +35 -196
- package/dist/cli.js +419 -268
- package/dist/cli.js.map +1 -1
- package/package.json +17 -14
- package/types/commands/fetch.d.ts +2 -2
- package/types/lib/fetch.d.ts +2 -1
- package/types/lib/git.d.ts +277 -3
- package/types/lib/prepare.d.ts +7 -0
- package/types/schemas/build.d.ts +19 -2
- package/types/schemas/fetch.d.ts +43 -12
- package/types/schemas/global.d.ts +128 -42
- package/types/schemas/prepare.d.ts +51 -8
- package/types/templates/index.d.ts +1 -0
- package/types/templates/theme/index.d.ts +8 -0
- package/types/utils/commands.d.ts +166 -42
- package/types/utils/const.d.ts +4 -0
- package/types/utils/functions.d.ts +3 -0
package/dist/cli.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { createOption as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { rimrafSync as
|
|
9
|
-
import { Octokit as
|
|
10
|
-
import { simpleGit as
|
|
11
|
-
import { build as
|
|
12
|
-
import
|
|
13
|
-
const
|
|
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
|
+
import { z as u } from "zod";
|
|
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 .",
|
|
25
25
|
"build:types": "tsc",
|
|
26
26
|
"build:vite": "vite build",
|
|
27
|
-
dev: "
|
|
27
|
+
dev: "vite-node ./dev/docpress.ts",
|
|
28
|
+
"dev:clean": "rimraf ./docpress && pnpm run dev",
|
|
28
29
|
format: "eslint . --fix",
|
|
29
30
|
lint: "eslint .",
|
|
30
31
|
prepare: "husky",
|
|
@@ -38,53 +39,55 @@ const Se = "@tobi-or-not/docpress", $e = "module", xe = "0.2.3", Ce = "pnpm@9.12
|
|
|
38
39
|
"vp:dev": "vitepress dev ./docpress --port 8080",
|
|
39
40
|
"vp:dev:docker": "docker run --publish 8080:8080 --name docpress-vp --rm tobi-or-not/docs",
|
|
40
41
|
"vp:preview": "vitepress preview ./docpress --port 8080"
|
|
41
|
-
},
|
|
42
|
+
}, Ue = {
|
|
43
|
+
"@octokit/rest": "^21.0.2",
|
|
42
44
|
axios: "^1.7.7",
|
|
43
45
|
chalk: "^5.3.0",
|
|
44
46
|
commander: "^12.1.0",
|
|
45
47
|
octokit: "^4.0.2",
|
|
46
48
|
rimraf: "^6.0.1",
|
|
47
49
|
"simple-git": "^3.27.0",
|
|
48
|
-
vitepress: "^1.
|
|
49
|
-
yaml: "^2.6.
|
|
50
|
+
vitepress: "^1.5.0",
|
|
51
|
+
yaml: "^2.6.1",
|
|
50
52
|
zod: "^3.23.8",
|
|
51
53
|
"zod-validation-error": "^3.4.0"
|
|
52
|
-
},
|
|
53
|
-
"@antfu/eslint-config": "^3.
|
|
54
|
-
"@commitlint/cli": "^19.
|
|
55
|
-
"@commitlint/config-conventional": "^19.
|
|
56
|
-
"@types
|
|
57
|
-
"@
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
}, He = {
|
|
55
|
+
"@antfu/eslint-config": "^3.9.2",
|
|
56
|
+
"@commitlint/cli": "^19.6.0",
|
|
57
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
58
|
+
"@octokit/types": "^13.6.1",
|
|
59
|
+
"@types/node": "^22.9.1",
|
|
60
|
+
"@vitest/coverage-v8": "^2.1.5",
|
|
61
|
+
eslint: "^9.15.0",
|
|
62
|
+
husky: "^9.1.7",
|
|
60
63
|
"lint-staged": "^15.2.10",
|
|
61
64
|
typescript: "^5.6.3",
|
|
62
|
-
vite: "^5.4.
|
|
63
|
-
"vite-node": "^2.1.
|
|
64
|
-
vitest: "^2.1.
|
|
65
|
-
},
|
|
65
|
+
vite: "^5.4.11",
|
|
66
|
+
"vite-node": "^2.1.5",
|
|
67
|
+
vitest: "^2.1.5"
|
|
68
|
+
}, ze = {
|
|
66
69
|
registry: "https://registry.npmjs.org/",
|
|
67
70
|
access: "public",
|
|
68
71
|
tag: "latest"
|
|
69
|
-
},
|
|
70
|
-
name:
|
|
71
|
-
type:
|
|
72
|
-
version:
|
|
73
|
-
packageManager:
|
|
74
|
-
module:
|
|
75
|
-
types:
|
|
76
|
-
bin:
|
|
77
|
-
files:
|
|
78
|
-
engines:
|
|
79
|
-
scripts:
|
|
80
|
-
dependencies:
|
|
81
|
-
devDependencies:
|
|
82
|
-
publishConfig:
|
|
72
|
+
}, Be = {
|
|
73
|
+
name: Te,
|
|
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
|
|
83
86
|
};
|
|
84
|
-
function
|
|
87
|
+
function Je() {
|
|
85
88
|
return typeof Number(process.env.LOG_LEVEL) == "number" && !Number.isNaN(Number(process.env.LOG_LEVEL)) ? Number(process.env.LOG_LEVEL) : 30;
|
|
86
89
|
}
|
|
87
|
-
const
|
|
90
|
+
const X = {
|
|
88
91
|
info: { color: "white", level: 30 },
|
|
89
92
|
warn: { color: "yellow", level: 20 },
|
|
90
93
|
error: { color: "red", level: 10 },
|
|
@@ -92,219 +95,311 @@ const M = {
|
|
|
92
95
|
trace: { color: "white", level: 40 },
|
|
93
96
|
success: { color: "green", level: 30 }
|
|
94
97
|
};
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
+
function c(e, t = "info", r) {
|
|
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);
|
|
98
101
|
}
|
|
99
|
-
const
|
|
100
|
-
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) {
|
|
101
104
|
try {
|
|
102
|
-
return (await
|
|
105
|
+
return (await Ee.head(e)).status;
|
|
103
106
|
} catch (t) {
|
|
104
107
|
return t.response?.status || t.status || 500;
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
|
-
function
|
|
110
|
+
function k(e, t) {
|
|
108
111
|
let r = "";
|
|
109
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;
|
|
110
113
|
}
|
|
111
|
-
function
|
|
114
|
+
function E(e, { clean: t } = { clean: !1 }) {
|
|
112
115
|
try {
|
|
113
|
-
t &&
|
|
116
|
+
t && q(e) && Oe(`${e}/*`, { glob: !0 }), q(e) || xe(e, { recursive: !0 });
|
|
114
117
|
} catch (r) {
|
|
115
118
|
console.error(r);
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
|
-
function
|
|
121
|
+
function Xe(e) {
|
|
119
122
|
try {
|
|
120
|
-
return
|
|
123
|
+
return G(e).isDirectory();
|
|
121
124
|
} catch {
|
|
122
125
|
return !1;
|
|
123
126
|
}
|
|
124
127
|
}
|
|
125
|
-
function
|
|
128
|
+
function Ye(e) {
|
|
126
129
|
try {
|
|
127
|
-
return
|
|
130
|
+
return G(e).isFile();
|
|
128
131
|
} catch {
|
|
129
132
|
return !1;
|
|
130
133
|
}
|
|
131
134
|
}
|
|
132
|
-
function
|
|
133
|
-
return (Array.isArray(e) ? e : [e]).flatMap((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))) : []);
|
|
134
137
|
}
|
|
135
|
-
function
|
|
136
|
-
return
|
|
138
|
+
function ge(e) {
|
|
139
|
+
return O(e).filter((t) => b(t).endsWith(".md"));
|
|
137
140
|
}
|
|
138
|
-
function
|
|
139
|
-
return e.reduce((t, r,
|
|
141
|
+
function Ze(e) {
|
|
142
|
+
return e.reduce((t, r, s, n) => s ? s === n.length - 1 ? `${t} or "${r}"` : `${t}, "${r}"` : `"${r}"`, "");
|
|
140
143
|
}
|
|
141
|
-
function
|
|
142
|
-
return JSON.parse(
|
|
144
|
+
function Qe() {
|
|
145
|
+
return JSON.parse(C(fe).toString());
|
|
143
146
|
}
|
|
144
|
-
function
|
|
145
|
-
return JSON.parse(
|
|
147
|
+
function et() {
|
|
148
|
+
return JSON.parse(C(le).toString());
|
|
146
149
|
}
|
|
147
|
-
function
|
|
148
|
-
return e.reduce((t, r) => (r === null || Object.keys(r).forEach((
|
|
149
|
-
const n = t ? t[
|
|
150
|
-
|
|
150
|
+
function j(...e) {
|
|
151
|
+
return e.reduce((t, r) => (r === null || Object.keys(r).forEach((s) => {
|
|
152
|
+
const n = t ? t[s] : null, o = r[s];
|
|
153
|
+
Q(n) && Q(o) ? t[s] = j(n, o) : t[s] = o;
|
|
151
154
|
}), t), {});
|
|
152
155
|
}
|
|
153
|
-
function
|
|
156
|
+
function Q(e) {
|
|
154
157
|
return e && typeof e == "object" && !Array.isArray(e);
|
|
155
158
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
function ee(e) {
|
|
160
|
+
if (!e)
|
|
161
|
+
return {};
|
|
162
|
+
try {
|
|
163
|
+
const t = d(process.cwd(), e), r = C(t, "utf8");
|
|
164
|
+
return JSON.parse(r);
|
|
165
|
+
} catch {
|
|
166
|
+
return {};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function P(e) {
|
|
170
|
+
return e.split(",");
|
|
171
|
+
}
|
|
172
|
+
const te = ["github"], p = u.object({
|
|
173
|
+
// Global
|
|
174
|
+
username: u.string().describe("Git provider username used to collect data."),
|
|
175
|
+
// Fetch
|
|
176
|
+
branch: u.string().describe("Branch used to collect Git provider data.").default("main"),
|
|
177
|
+
gitProvider: u.enum(te).describe(`Git provider used to retrieve data. Values should be ${Ze(te)}.`).default("github"),
|
|
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
|
+
// Prepare
|
|
180
|
+
extraHeaderPages: u.array(u.string()).describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
181
|
+
extraPublicContent: u.array(u.string()).describe("List of comma separated additional files or directories to process Vitepress public folder."),
|
|
182
|
+
extraTheme: u.array(u.string()).describe("List of comma separated additional files or directories to use as Vitepress theme."),
|
|
183
|
+
forks: u.boolean().describe("Whether or not to create the dedicated fork page that aggregate external contributions.").default(!1),
|
|
184
|
+
vitepressConfig: u.any().describe("Path to the vitepress configuration file.")
|
|
169
185
|
});
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
function H(e) {
|
|
187
|
+
const { config: t, vitepressConfig: r, token: s, ...n } = e;
|
|
188
|
+
try {
|
|
189
|
+
const o = p.partial().parse(ee(t)), i = ee(r), a = p.partial().required({ branch: !0, gitProvider: !0 }).parse({}), l = {
|
|
190
|
+
...i,
|
|
191
|
+
...o.vitepressConfig
|
|
192
|
+
}, g = {
|
|
193
|
+
...o,
|
|
194
|
+
...a,
|
|
195
|
+
...n,
|
|
196
|
+
...Object.keys(l).length && { vitepressConfig: l }
|
|
197
|
+
};
|
|
198
|
+
return { ...p.partial().required({ username: !0 }).parse(g), token: s };
|
|
199
|
+
} catch (o) {
|
|
200
|
+
c(` An error occurred while checking configuration.
|
|
201
|
+
${ce(o).toString()}`, "error"), process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const F = p.partial().extend({
|
|
205
|
+
config: u.string().describe("Path to the docpress configuration file.").optional(),
|
|
206
|
+
token: u.string().describe("Git provider token used to collect data.").optional(),
|
|
207
|
+
reposFilter: u.string().describe(p.shape.reposFilter.description || "").transform(P).optional(),
|
|
208
|
+
extraHeaderPages: u.string().describe(p.shape.extraHeaderPages.description || "").transform(P).optional(),
|
|
209
|
+
extraPublicContent: u.string().describe(p.shape.extraPublicContent.description || "").transform(P).optional(),
|
|
210
|
+
extraTheme: u.string().describe(p.shape.extraTheme.description || "").transform(P).optional(),
|
|
211
|
+
vitepressConfig: u.string().describe(p.shape.vitepressConfig.description || "").optional()
|
|
212
|
+
}), _ = F.partial().transform(H), tt = F.pick({}), rt = F.pick({
|
|
213
|
+
branch: !0,
|
|
214
|
+
config: !0,
|
|
215
|
+
gitProvider: !0,
|
|
216
|
+
reposFilter: !0,
|
|
217
|
+
token: !0,
|
|
218
|
+
username: !0
|
|
219
|
+
}).transform(H), ot = F.pick({
|
|
220
|
+
extraHeaderPages: !0,
|
|
221
|
+
extraPublicContent: !0,
|
|
222
|
+
extraTheme: !0,
|
|
223
|
+
config: !0,
|
|
224
|
+
gitProvider: !0,
|
|
225
|
+
reposFilter: !0,
|
|
226
|
+
token: !0,
|
|
227
|
+
username: !0,
|
|
228
|
+
vitepressConfig: !0
|
|
229
|
+
}).transform(H), st = {
|
|
230
|
+
build: tt,
|
|
231
|
+
fetch: rt,
|
|
232
|
+
prepare: ot,
|
|
233
|
+
global: _
|
|
176
234
|
};
|
|
177
|
-
function
|
|
178
|
-
|
|
235
|
+
function z(e, t) {
|
|
236
|
+
c("Initializing Docpress...", "info", "blue"), c(`
|
|
179
237
|
|
|
180
238
|
-> Checking for required environment settings and configurations.`, "info");
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
...s
|
|
185
|
-
});
|
|
186
|
-
if (i.success)
|
|
187
|
-
return i.data;
|
|
188
|
-
d(` An error occurred while checking configuration: ${pe(i.error).toString()}`, "error"), process.exit(0);
|
|
189
|
-
}
|
|
190
|
-
const o = e.reduce((n, s) => {
|
|
191
|
-
const i = r(s, t);
|
|
192
|
-
return Object.assign(n, i);
|
|
193
|
-
}, {});
|
|
194
|
-
return d(" Setup complete! Ready to process your documentation.", "info"), o;
|
|
239
|
+
const r = st[e].safeParse(t);
|
|
240
|
+
return r.error && (c(` An error occurred while checking configuration.
|
|
241
|
+
${ce(r.error).toString()}`, "error"), process.exit(1)), c(" Setup complete! Ready to process your documentation.", "info"), r.data;
|
|
195
242
|
}
|
|
196
|
-
function
|
|
243
|
+
function R(e, t) {
|
|
197
244
|
return t.forEach((r) => e.addOption(r)), e;
|
|
198
245
|
}
|
|
199
|
-
async function
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
246
|
+
async function nt({ username: e, token: t, branch: r }) {
|
|
247
|
+
c(` Get infos for username '${e}'.`, "info");
|
|
248
|
+
const s = new ue({ auth: t });
|
|
249
|
+
c(" Get user infos.", "debug");
|
|
250
|
+
const { data: n } = await s.rest.users.getByUsername({ username: e });
|
|
251
|
+
c(" Get repositories infos.", "debug");
|
|
252
|
+
const { data: o } = await s.rest.repos.listForUser({ username: e, sort: "full_name" });
|
|
253
|
+
return { user: n, repos: o, branch: r };
|
|
254
|
+
}
|
|
255
|
+
async function it({
|
|
256
|
+
repository: e,
|
|
257
|
+
token: t
|
|
258
|
+
}) {
|
|
259
|
+
c(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
260
|
+
const r = new ue({
|
|
261
|
+
auth: t,
|
|
262
|
+
log: {
|
|
263
|
+
debug: () => {
|
|
264
|
+
},
|
|
265
|
+
info: () => {
|
|
266
|
+
},
|
|
267
|
+
warn: (o) => {
|
|
268
|
+
o.includes("404") || console.warn(o);
|
|
269
|
+
},
|
|
270
|
+
error: (o) => {
|
|
271
|
+
o.includes("404") || console.error(o);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}), { data: s } = await r.rest.repos.get({
|
|
275
|
+
owner: e.owner.login,
|
|
276
|
+
repo: e.name
|
|
277
|
+
});
|
|
278
|
+
if (!s.source?.owner?.login)
|
|
279
|
+
return { source: s.source, contributors: [] };
|
|
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
|
+
}
|
|
297
|
+
return { source: s.source, contributors: n };
|
|
203
298
|
}
|
|
204
|
-
async function
|
|
205
|
-
|
|
299
|
+
async function ct(e, t, r, s, n) {
|
|
300
|
+
E(r, { clean: !0 });
|
|
206
301
|
try {
|
|
207
|
-
const
|
|
208
|
-
await
|
|
209
|
-
for (const
|
|
210
|
-
|
|
302
|
+
const o = Fe({ baseDir: r });
|
|
303
|
+
await o.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
|
|
304
|
+
for (const i of n)
|
|
305
|
+
c(` Add '${i}' to '${e}' sparse-checkout file.`, "debug"), de(d(r, ".git/info/sparse-checkout"), `${i}
|
|
211
306
|
`, "utf8");
|
|
212
|
-
await
|
|
213
|
-
} catch (
|
|
214
|
-
|
|
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 });
|
|
308
|
+
} catch (o) {
|
|
309
|
+
c(` Error when cloning repository: ${o}.`, "error");
|
|
215
310
|
}
|
|
216
311
|
}
|
|
217
|
-
async function
|
|
218
|
-
const
|
|
312
|
+
async function at(e, t, r) {
|
|
313
|
+
const s = `https://github.com/${e}/${t}/tree/${r}/README.md`, n = `https://github.com/${e}/${t}/tree/${r}/docs`, o = `https://github.com/${e}/${t}/tree/${r}/docs/01-readme.md`, i = await I(s), a = await I(n), l = await I(o);
|
|
219
314
|
return {
|
|
220
315
|
rootReadmeStatus: i,
|
|
221
316
|
docsFolderStatus: a,
|
|
222
|
-
docsReadmeStatus:
|
|
317
|
+
docsReadmeStatus: l
|
|
223
318
|
};
|
|
224
319
|
}
|
|
225
|
-
async function
|
|
226
|
-
|
|
320
|
+
async function dt({ username: e, branch: t, reposFilter: r, token: s }) {
|
|
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));
|
|
227
322
|
}
|
|
228
|
-
async function
|
|
229
|
-
const
|
|
323
|
+
async function ut(e, t, r) {
|
|
324
|
+
const s = [];
|
|
230
325
|
return await Promise.all(
|
|
231
326
|
e.map(async (n) => {
|
|
232
|
-
const
|
|
233
|
-
let
|
|
234
|
-
!n.fork && !n.private && !a && (
|
|
327
|
+
const o = t ?? n.default_branch ?? "main", i = d(me, n.name), a = he(n, r);
|
|
328
|
+
let l = [];
|
|
329
|
+
!n.fork && !n.private && !a && (l = await pt(n, o)), s.push({
|
|
235
330
|
...n,
|
|
236
331
|
docpress: {
|
|
237
332
|
filtered: a,
|
|
238
|
-
branch:
|
|
239
|
-
includes:
|
|
333
|
+
branch: o,
|
|
334
|
+
includes: l,
|
|
240
335
|
projectPath: i,
|
|
241
|
-
raw_url: `https://raw.githubusercontent.com/${n.owner.login}/${n.name}/${
|
|
242
|
-
replace_url: `https://github.com/${n.owner.login}/${n.name}/tree/${
|
|
336
|
+
raw_url: `https://raw.githubusercontent.com/${n.owner.login}/${n.name}/${o}`,
|
|
337
|
+
replace_url: `https://github.com/${n.owner.login}/${n.name}/tree/${o}`
|
|
243
338
|
}
|
|
244
339
|
});
|
|
245
340
|
})
|
|
246
|
-
),
|
|
341
|
+
), s;
|
|
247
342
|
}
|
|
248
|
-
async function
|
|
249
|
-
const r = await
|
|
250
|
-
return Object.values(r).every((n) => n === 404) || !e.size ? [] : (r.docsFolderStatus !== 404 &&
|
|
343
|
+
async function pt(e, t) {
|
|
344
|
+
const r = await at(e.owner.login, e.name, t), s = [];
|
|
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);
|
|
251
346
|
}
|
|
252
|
-
async function
|
|
253
|
-
|
|
254
|
-
const n = await
|
|
255
|
-
return
|
|
347
|
+
async function lt(e, t, r, s) {
|
|
348
|
+
v(fe, JSON.stringify(e, null, 2));
|
|
349
|
+
const n = await ut(t, r, s);
|
|
350
|
+
return v(le, JSON.stringify(n, null, 2)), { user: e, repos: n };
|
|
256
351
|
}
|
|
257
|
-
async function
|
|
352
|
+
async function ft(e, t) {
|
|
258
353
|
if (!e) {
|
|
259
|
-
|
|
354
|
+
c(" No repository respect docpress rules.", "warn");
|
|
260
355
|
return;
|
|
261
356
|
}
|
|
262
357
|
await Promise.all(
|
|
263
|
-
e.filter((r) => !
|
|
264
|
-
|
|
358
|
+
e.filter((r) => !he(r, t)).map(async (r) => {
|
|
359
|
+
await ct(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
|
|
265
360
|
})
|
|
266
361
|
);
|
|
267
362
|
}
|
|
268
|
-
function
|
|
269
|
-
const r = t?.every((i) => i.startsWith("!")),
|
|
270
|
-
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.
|
|
271
|
-
}
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
],
|
|
281
|
-
const t =
|
|
282
|
-
await
|
|
363
|
+
function he(e, t) {
|
|
364
|
+
const r = t?.every((i) => i.startsWith("!")), s = t?.filter((i) => i.startsWith("!")).some((i) => e.name === i.substring(1)), n = !t || t?.filter((i) => !i.startsWith("!")).includes(e.name) || e.fork && !s || r && !s, o = s || !n;
|
|
365
|
+
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !o);
|
|
366
|
+
}
|
|
367
|
+
const T = [
|
|
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 = [
|
|
372
|
+
m("-b, --branch <string>", p.shape.branch._def.description).default(p.shape.branch._def.defaultValue()),
|
|
373
|
+
m("-g, --git-provider <string>", p.shape.gitProvider._def.description).default(p.shape.gitProvider._def.defaultValue()),
|
|
374
|
+
m("-r, --repos-filter <string>", p.shape.reposFilter._def.description)
|
|
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);
|
|
283
378
|
});
|
|
284
|
-
async function
|
|
285
|
-
const { username: t, reposFilter: r, token:
|
|
286
|
-
|
|
287
|
-
-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"), await
|
|
379
|
+
async function ve(e) {
|
|
380
|
+
const { username: t, reposFilter: r, token: s, branch: n, gitProvider: o } = e;
|
|
381
|
+
c(`
|
|
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 });
|
|
288
383
|
}
|
|
289
|
-
const
|
|
290
|
-
await
|
|
384
|
+
const gt = "build", ht = R(A(gt), T).description("Build vitepress website.").action(async (e) => {
|
|
385
|
+
await ye();
|
|
291
386
|
});
|
|
292
|
-
async function
|
|
293
|
-
|
|
387
|
+
async function ye() {
|
|
388
|
+
c(`
|
|
294
389
|
-> Start building Vitepress website.
|
|
295
390
|
|
|
296
391
|
`, "info");
|
|
297
392
|
try {
|
|
298
|
-
await
|
|
393
|
+
await Re(U), c(`
|
|
299
394
|
|
|
300
395
|
Docpress build succedeed.`, "success");
|
|
301
396
|
} catch (e) {
|
|
302
|
-
|
|
397
|
+
c(`
|
|
303
398
|
|
|
304
399
|
Docpress build failed : ${e}`, "error");
|
|
305
400
|
}
|
|
306
401
|
}
|
|
307
|
-
const
|
|
402
|
+
const oe = {
|
|
308
403
|
base: "/",
|
|
309
404
|
lang: "en-US",
|
|
310
405
|
vite: {
|
|
@@ -341,150 +436,206 @@ const H = {
|
|
|
341
436
|
}
|
|
342
437
|
}
|
|
343
438
|
};
|
|
344
|
-
function
|
|
345
|
-
return r ?
|
|
439
|
+
function bt(e, t, r) {
|
|
440
|
+
return r ? j(oe, r, { themeConfig: { sidebar: e, nav: t } }) : j(oe, { themeConfig: { sidebar: e, nav: t } });
|
|
346
441
|
}
|
|
347
|
-
function
|
|
348
|
-
const
|
|
349
|
-
|
|
442
|
+
function vt(e, t) {
|
|
443
|
+
const r = C(e, { encoding: "utf8" });
|
|
444
|
+
E(M(t)), v(t, r);
|
|
350
445
|
}
|
|
351
|
-
function
|
|
352
|
-
const
|
|
353
|
-
|
|
446
|
+
function yt(e, t) {
|
|
447
|
+
const s = C(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (n, o, i) => `[${o}](${t}/${i})`);
|
|
448
|
+
v(e, s, "utf8");
|
|
354
449
|
}
|
|
355
|
-
function
|
|
356
|
-
const
|
|
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");
|
|
453
|
+
}
|
|
454
|
+
function se(e, t) {
|
|
455
|
+
const n = `${b(t) === "introduction.md" ? `
|
|
357
456
|
## Sources` : "# Sources"}
|
|
358
457
|
|
|
359
458
|
Take a look at the [project sources](${e}).
|
|
360
459
|
`;
|
|
361
|
-
|
|
460
|
+
de(t, n, "utf8");
|
|
362
461
|
}
|
|
363
|
-
function
|
|
364
|
-
const { name: r, login:
|
|
462
|
+
function kt(e, t) {
|
|
463
|
+
const { name: r, login: s, bio: n } = t;
|
|
365
464
|
return {
|
|
366
465
|
layout: "home",
|
|
367
466
|
hero: {
|
|
368
|
-
name: r ? `${r}'s projects` : `${
|
|
467
|
+
name: r ? `${r}'s projects` : `${s}'s projects`,
|
|
369
468
|
tagline: n ?? "Robots are everywhere 🤖"
|
|
370
469
|
// \U0001F916
|
|
371
470
|
},
|
|
372
471
|
features: e
|
|
373
472
|
};
|
|
374
473
|
}
|
|
375
|
-
function
|
|
376
|
-
const
|
|
377
|
-
title:
|
|
474
|
+
function $t(e, t, r) {
|
|
475
|
+
const s = {
|
|
476
|
+
title: k(e, { mode: "capitalize", replaceDash: !0 }),
|
|
378
477
|
details: t,
|
|
379
478
|
link: `/${e}/introduction`
|
|
380
479
|
};
|
|
381
|
-
return r ? [...r,
|
|
480
|
+
return r ? [...r, s] : [s];
|
|
382
481
|
}
|
|
383
|
-
function
|
|
482
|
+
function Ct(e, t) {
|
|
384
483
|
return {
|
|
385
|
-
text:
|
|
484
|
+
text: k(e, { mode: "capitalize", replaceDash: !0 }),
|
|
386
485
|
collapsed: !0,
|
|
387
486
|
items: t
|
|
388
487
|
};
|
|
389
488
|
}
|
|
390
|
-
function
|
|
391
|
-
const
|
|
392
|
-
text: t === "introduction" ? "Introduction" :
|
|
489
|
+
function V(e, t, r) {
|
|
490
|
+
const s = {
|
|
491
|
+
text: t === "introduction" ? "Introduction" : k(t, { mode: "capitalize", replaceDash: !0 }),
|
|
393
492
|
link: `/${e}/${t}`
|
|
394
493
|
};
|
|
395
|
-
return r ? [...r,
|
|
396
|
-
}
|
|
397
|
-
function
|
|
398
|
-
const r = [],
|
|
399
|
-
for (const
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}),
|
|
403
|
-
const i =
|
|
404
|
-
const
|
|
405
|
-
let
|
|
406
|
-
if (
|
|
407
|
-
let
|
|
408
|
-
if (
|
|
409
|
-
return
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
494
|
+
return r ? [...r, s] : [s];
|
|
495
|
+
}
|
|
496
|
+
function St(e, t) {
|
|
497
|
+
const r = [], s = [];
|
|
498
|
+
for (const o of e) {
|
|
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}`);
|
|
501
|
+
}), c(` Generate sidebar for repository '${o.name}'.`, "info");
|
|
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) => {
|
|
503
|
+
const h = d(o.docpress.projectPath, l);
|
|
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(
|
|
509
|
+
o.name,
|
|
510
|
+
x(w).name,
|
|
511
|
+
V(o.name, x(f).name, a)
|
|
413
512
|
);
|
|
414
|
-
|
|
513
|
+
w = d(o.docpress.projectPath, f), se(o.html_url, w);
|
|
415
514
|
}
|
|
416
|
-
return
|
|
515
|
+
return V(o.name, x(f).name, a);
|
|
417
516
|
}, []);
|
|
418
|
-
|
|
517
|
+
s.push(Ct(o.name, i)), r.push(...$t(o.name, o.description || ""));
|
|
419
518
|
}
|
|
420
|
-
|
|
421
|
-
const n =
|
|
519
|
+
c(" Generate index content.", "info");
|
|
520
|
+
const n = kt(r.sort((o, i) => o.title.localeCompare(i.title)), t);
|
|
422
521
|
return {
|
|
423
|
-
sidebar:
|
|
522
|
+
sidebar: s.sort((o, i) => o.text.localeCompare(i.text)),
|
|
424
523
|
index: n
|
|
425
524
|
};
|
|
426
525
|
}
|
|
427
|
-
function
|
|
428
|
-
const t =
|
|
429
|
-
|
|
430
|
-
for (const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
526
|
+
function xt(e) {
|
|
527
|
+
const t = ge(e), r = [];
|
|
528
|
+
c(" Add extras Vitepress headers pages.", "info");
|
|
529
|
+
for (const s of t) {
|
|
530
|
+
c(` Processing file '${s}'.`, "debug");
|
|
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" })}`
|
|
435
535
|
});
|
|
436
536
|
}
|
|
437
537
|
return r;
|
|
438
538
|
}
|
|
439
|
-
function
|
|
440
|
-
for (const
|
|
441
|
-
const n =
|
|
442
|
-
for (const i of
|
|
443
|
-
const a =
|
|
444
|
-
|
|
539
|
+
function ne(e, t, r) {
|
|
540
|
+
for (const s of Array.isArray(e) ? e : [e]) {
|
|
541
|
+
const n = d(process.cwd(), s), o = O(n);
|
|
542
|
+
for (const i of o) {
|
|
543
|
+
const a = i.replace(n, ".");
|
|
544
|
+
c(` Processing file '${a}' for entry '${s}'.`, "debug");
|
|
545
|
+
const l = d(process.cwd(), i), g = d(t, a);
|
|
546
|
+
N(l, g);
|
|
445
547
|
}
|
|
446
548
|
}
|
|
447
549
|
}
|
|
448
|
-
function
|
|
550
|
+
function Pt(e) {
|
|
551
|
+
const t = `---
|
|
552
|
+
`, r = `layout: fork-page
|
|
553
|
+
repoList:
|
|
554
|
+
`, s = `
|
|
555
|
+
# External contributions
|
|
556
|
+
|
|
557
|
+
This 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.
|
|
558
|
+
|
|
559
|
+
Every 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.
|
|
560
|
+
|
|
561
|
+
This page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.
|
|
562
|
+
`, n = e.map(({ repository: o, contributions: i }) => {
|
|
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 };
|
|
565
|
+
});
|
|
566
|
+
c(" Generate forks page.", "info"), v(qe, t.concat(r, pe.stringify(n), t, s));
|
|
567
|
+
}
|
|
568
|
+
async function _t(e, t, r) {
|
|
569
|
+
const s = await Promise.all(
|
|
570
|
+
e.map(async (n) => {
|
|
571
|
+
const { source: o, contributors: i } = await it({ repository: n, token: r });
|
|
572
|
+
return {
|
|
573
|
+
contributions: i?.find((a) => a.login === t)?.contributions ?? 0,
|
|
574
|
+
repository: o
|
|
575
|
+
};
|
|
576
|
+
})
|
|
577
|
+
).then((n) => n.filter(({ repository: o, contributions: i }) => !!o && i));
|
|
578
|
+
Pt(s);
|
|
579
|
+
}
|
|
580
|
+
function Et(e, t) {
|
|
449
581
|
const r = `---
|
|
450
582
|
`;
|
|
451
|
-
|
|
452
|
-
`),
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
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
|
+
}
|
|
590
|
+
}
|
|
591
|
+
const ie = "prepare", we = [
|
|
592
|
+
m("-c, --extra-public-content <string>", p.shape.extraPublicContent._def.description),
|
|
593
|
+
m("-f, --forks", p.shape.forks._def.description),
|
|
594
|
+
m("-p, --extra-header-pages <string>", p.shape.extraHeaderPages._def.description),
|
|
595
|
+
m("-t, --extra-theme <string>", p.shape.extraTheme._def.description),
|
|
596
|
+
m("-v, --vitepress-config <string>", p.shape.vitepressConfig._def.description)
|
|
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);
|
|
462
600
|
});
|
|
463
|
-
async function
|
|
464
|
-
const { extraHeaderPages: t, extraPublicContent: r, extraTheme:
|
|
465
|
-
|
|
601
|
+
async function ke(e) {
|
|
602
|
+
const { extraHeaderPages: t, extraPublicContent: r, extraTheme: s, vitepressConfig: n, forks: o, token: i, username: a } = e;
|
|
603
|
+
c(`
|
|
466
604
|
-> Start transform files to prepare Vitepress build.`, "info");
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
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] };
|
|
612
|
+
}
|
|
613
|
+
return { internals: $, forks: S };
|
|
614
|
+
}, { internals: [], forks: [] }), { sidebar: y, index: h } = St(g.internals, l), f = [];
|
|
615
|
+
if (t) {
|
|
616
|
+
const $ = xt(t);
|
|
617
|
+
o ? f.push(...$.filter((S) => S.link !== "/forks")) : f.push(...$);
|
|
618
|
+
}
|
|
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();
|
|
476
627
|
}).configureHelp({
|
|
477
628
|
sortSubcommands: !0,
|
|
478
629
|
sortOptions: !0,
|
|
479
630
|
showGlobalOptions: !0
|
|
480
|
-
}).enablePositionalOptions().passThroughOptions();
|
|
481
|
-
return
|
|
631
|
+
}).enablePositionalOptions().passThroughOptions().addCommand(mt).addCommand(Ot).addCommand(ht);
|
|
632
|
+
return R(e, [...be, ...we, ...T]), e;
|
|
482
633
|
}
|
|
483
|
-
function
|
|
484
|
-
|
|
634
|
+
function Ht() {
|
|
635
|
+
Ft().parseAsync(process.argv);
|
|
485
636
|
}
|
|
486
637
|
export {
|
|
487
|
-
|
|
488
|
-
|
|
638
|
+
Ft as getProgram,
|
|
639
|
+
Ht as main
|
|
489
640
|
};
|
|
490
641
|
//# sourceMappingURL=cli.js.map
|