@tobi-or-not/docpress 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -204
- package/dist/cli.js +389 -269
- 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 +299 -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/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 I, Command as $e } from "commander";
|
|
2
|
+
import B from "chalk";
|
|
3
|
+
import { fromZodError as se } from "zod-validation-error";
|
|
4
|
+
import { z as u } from "zod";
|
|
5
|
+
import { readFileSync as x, existsSync as J, mkdirSync as Ce, readdirSync as ne, statSync as V, appendFileSync as ie, cpSync as j, rmSync as W, writeFileSync as k, renameSync as Se } from "node:fs";
|
|
6
|
+
import { resolve as d, join as xe, basename as b, dirname as ce, parse as S } from "node:path";
|
|
7
|
+
import Pe from "axios";
|
|
8
|
+
import { rimrafSync as Ee } from "rimraf";
|
|
9
|
+
import { Octokit as ae } from "@octokit/rest";
|
|
10
|
+
import { simpleGit as _e } from "simple-git";
|
|
11
|
+
import { build as Oe } from "vitepress";
|
|
12
|
+
import de from "yaml";
|
|
13
|
+
const Te = "@tobi-or-not/docpress", Fe = "module", Re = "0.3.0", De = "pnpm@9.12.3", Ge = "dist/docpress.js", Le = "types/index.d.ts", Ie = {
|
|
14
14
|
docpress: "bin/docpress.js"
|
|
15
|
-
},
|
|
15
|
+
}, Ve = [
|
|
16
16
|
"bin",
|
|
17
17
|
"dist",
|
|
18
18
|
"types"
|
|
19
|
-
],
|
|
19
|
+
], je = {
|
|
20
20
|
node: ">=20"
|
|
21
|
-
},
|
|
21
|
+
}, Ae = {
|
|
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
|
+
}, Ne = {
|
|
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
|
+
}, Me = {
|
|
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
|
+
}, He = {
|
|
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
|
+
}, Ue = {
|
|
73
|
+
name: Te,
|
|
74
|
+
type: Fe,
|
|
75
|
+
version: Re,
|
|
76
|
+
packageManager: De,
|
|
77
|
+
module: Ge,
|
|
78
|
+
types: Le,
|
|
79
|
+
bin: Ie,
|
|
80
|
+
files: Ve,
|
|
81
|
+
engines: je,
|
|
82
|
+
scripts: Ae,
|
|
83
|
+
dependencies: Ne,
|
|
84
|
+
devDependencies: Me,
|
|
85
|
+
publishConfig: He
|
|
83
86
|
};
|
|
84
|
-
function
|
|
87
|
+
function ze() {
|
|
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 K = {
|
|
88
91
|
info: { color: "white", level: 30 },
|
|
89
92
|
warn: { color: "yellow", level: 20 },
|
|
90
93
|
error: { color: "red", level: 10 },
|
|
@@ -92,219 +95,289 @@ 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 ? B[r](e) : B[K[t].color](e), n = t === "success" ? "info" : t;
|
|
100
|
+
ze() >= K[t].level && console[n](s);
|
|
98
101
|
}
|
|
99
|
-
const
|
|
100
|
-
async function
|
|
102
|
+
const A = d(process.cwd(), "docpress"), ue = d(process.cwd(), "docpress/repositories.json"), pe = d(process.cwd(), "docpress/owner.json"), le = d(process.cwd(), "docpress/docs"), qe = d(process.cwd(), "docpress/docs/index.md"), Be = d(process.cwd(), "docpress/docs/forks.md"), X = d(process.cwd(), "docpress/.vitepress/config.ts"), Je = d(process.cwd(), "docpress/.vitepress/theme"), We = d(process.cwd(), "docpress/.vitepress/theme/extras"), Ke = d(import.meta.dirname, "../templates/theme");
|
|
103
|
+
async function R(e) {
|
|
101
104
|
try {
|
|
102
|
-
return (await
|
|
105
|
+
return (await Pe.head(e)).status;
|
|
103
106
|
} catch (t) {
|
|
104
107
|
return t.response?.status || t.status || 500;
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
|
-
function
|
|
110
|
+
function w(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 N(e, { clean: t } = { clean: !1 }) {
|
|
112
115
|
try {
|
|
113
|
-
t &&
|
|
116
|
+
t && J(e) && Ee(`${e}/*`, { glob: !0 }), J(e) || Ce(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 V(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 V(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 M(e) {
|
|
136
|
+
return (Array.isArray(e) ? e : [e]).flatMap((t) => Ye(t) ? [t] : Xe(t) ? ne(t).flatMap((r) => M(xe(t, r))) : []);
|
|
134
137
|
}
|
|
135
|
-
function
|
|
136
|
-
return
|
|
138
|
+
function fe(e) {
|
|
139
|
+
return M(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(x(pe).toString());
|
|
143
146
|
}
|
|
144
|
-
function
|
|
145
|
-
return JSON.parse(
|
|
147
|
+
function et() {
|
|
148
|
+
return JSON.parse(x(ue).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 L(...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
|
+
Y(n) && Y(o) ? t[s] = L(n, o) : t[s] = o;
|
|
151
154
|
}), t), {});
|
|
152
155
|
}
|
|
153
|
-
function
|
|
156
|
+
function Y(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 Z(e) {
|
|
160
|
+
if (!e)
|
|
161
|
+
return {};
|
|
162
|
+
try {
|
|
163
|
+
const t = d(process.cwd(), e), r = x(t, "utf8");
|
|
164
|
+
return JSON.parse(r);
|
|
165
|
+
} catch {
|
|
166
|
+
return {};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function P(e) {
|
|
170
|
+
return e.split(",");
|
|
171
|
+
}
|
|
172
|
+
const Q = ["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(Q).describe(`Git provider used to retrieve data. Values should be ${Ze(Q)}.`).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(Z(t)), i = Z(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
|
+
${se(o).toString()}`, "error"), process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const _ = 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
|
+
}), E = _.partial().transform(H), tt = _.pick({}), rt = _.pick({
|
|
213
|
+
branch: !0,
|
|
214
|
+
config: !0,
|
|
215
|
+
gitProvider: !0,
|
|
216
|
+
reposFilter: !0,
|
|
217
|
+
token: !0,
|
|
218
|
+
username: !0
|
|
219
|
+
}).transform(H), ot = _.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: E
|
|
176
234
|
};
|
|
177
|
-
function
|
|
178
|
-
|
|
235
|
+
function U(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
|
+
${se(r.error).toString()}`, "error"), process.exit(1)), c(" Setup complete! Ready to process your documentation.", "info"), r.data;
|
|
195
242
|
}
|
|
196
|
-
function
|
|
243
|
+
function O(e, t) {
|
|
197
244
|
return t.forEach((r) => e.addOption(r)), e;
|
|
198
245
|
}
|
|
199
|
-
async function
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
246
|
+
async function nt({ username: e, token: t, branch: r }) {
|
|
247
|
+
c(` Get infos for username '${e}'.`, "info");
|
|
248
|
+
const s = new ae({ auth: t });
|
|
249
|
+
c(" Get user infos.", "debug");
|
|
250
|
+
const { data: n } = await s.request("GET /users/{username}", { username: e });
|
|
251
|
+
c(" Get repositories infos.", "debug");
|
|
252
|
+
const { data: o } = await s.request("GET /users/{username}/repos", { username: e, sort: "full_name" });
|
|
253
|
+
return { user: n, repos: o, branch: r };
|
|
254
|
+
}
|
|
255
|
+
async function it({ repository: e, token: t }) {
|
|
256
|
+
c(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
257
|
+
const r = new ae({
|
|
258
|
+
auth: t,
|
|
259
|
+
log: {
|
|
260
|
+
debug: () => {
|
|
261
|
+
},
|
|
262
|
+
info: () => {
|
|
263
|
+
},
|
|
264
|
+
warn: (o) => {
|
|
265
|
+
o.includes("404") || console.warn(o);
|
|
266
|
+
},
|
|
267
|
+
error: (o) => {
|
|
268
|
+
o.includes("404") || console.error(o);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}), { data: s } = await r.request("GET /repos/{owner}/{repo}", { owner: e.owner.login, repo: e.name });
|
|
272
|
+
if (!s.source?.owner.login)
|
|
273
|
+
return { source: s.source, contributors: [] };
|
|
274
|
+
const { data: n } = await r.request("GET /repos/{owner}/{repo}/contributors", { owner: s.source.owner.login, repo: s.name }).catch((o) => (c(` Failed to get contributors infos for repository '${e.name}'.`, "warn"), { data: [] }));
|
|
275
|
+
return { source: s.source, contributors: n };
|
|
276
|
+
}
|
|
277
|
+
async function ct(e, t, r, s, n) {
|
|
278
|
+
N(r, { clean: !0 });
|
|
206
279
|
try {
|
|
207
|
-
const
|
|
208
|
-
await
|
|
209
|
-
for (const
|
|
210
|
-
|
|
280
|
+
const o = _e({ baseDir: r });
|
|
281
|
+
await o.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
|
|
282
|
+
for (const i of n)
|
|
283
|
+
c(` Add '${i}' to '${e}' sparse-checkout file.`, "debug"), ie(d(r, ".git/info/sparse-checkout"), `${i}
|
|
211
284
|
`, "utf8");
|
|
212
|
-
await
|
|
213
|
-
} catch (
|
|
214
|
-
|
|
285
|
+
c(` Clone repository '${e}'.`, "info"), await o.pull("origin", s), n.some((i) => i.includes("docs")) && (j(d(r, "docs"), r, { recursive: !0 }), W(d(r, "docs"), { recursive: !0 })), W(d(r, ".git"), { recursive: !0 });
|
|
286
|
+
} catch (o) {
|
|
287
|
+
c(` Error when cloning repository: ${o}.`, "error");
|
|
215
288
|
}
|
|
216
289
|
}
|
|
217
|
-
async function
|
|
218
|
-
const
|
|
290
|
+
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 R(s), a = await R(n), l = await R(o);
|
|
219
292
|
return {
|
|
220
293
|
rootReadmeStatus: i,
|
|
221
294
|
docsFolderStatus: a,
|
|
222
|
-
docsReadmeStatus:
|
|
295
|
+
docsReadmeStatus: l
|
|
223
296
|
};
|
|
224
297
|
}
|
|
225
|
-
async function
|
|
226
|
-
|
|
298
|
+
async function dt({ username: e, branch: t, reposFilter: r, token: s }) {
|
|
299
|
+
N(A, { 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
300
|
}
|
|
228
|
-
async function
|
|
229
|
-
const
|
|
301
|
+
async function ut(e, t, r) {
|
|
302
|
+
const s = [];
|
|
230
303
|
return await Promise.all(
|
|
231
304
|
e.map(async (n) => {
|
|
232
|
-
const
|
|
233
|
-
let
|
|
234
|
-
!n.fork && !n.private && !a && (
|
|
305
|
+
const o = t ?? n.default_branch ?? "main", i = d(le, n.name), a = me(n, r);
|
|
306
|
+
let l = [];
|
|
307
|
+
!n.fork && !n.private && !a && (l = await pt(n, o)), s.push({
|
|
235
308
|
...n,
|
|
236
309
|
docpress: {
|
|
237
310
|
filtered: a,
|
|
238
|
-
branch:
|
|
239
|
-
includes:
|
|
311
|
+
branch: o,
|
|
312
|
+
includes: l,
|
|
240
313
|
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/${
|
|
314
|
+
raw_url: `https://raw.githubusercontent.com/${n.owner.login}/${n.name}/${o}`,
|
|
315
|
+
replace_url: `https://github.com/${n.owner.login}/${n.name}/tree/${o}`
|
|
243
316
|
}
|
|
244
317
|
});
|
|
245
318
|
})
|
|
246
|
-
),
|
|
319
|
+
), s;
|
|
247
320
|
}
|
|
248
|
-
async function
|
|
249
|
-
const r = await
|
|
250
|
-
return Object.values(r).every((n) => n === 404) || !e.size ? [] : (r.docsFolderStatus !== 404 &&
|
|
321
|
+
async function pt(e, t) {
|
|
322
|
+
const r = await at(e.owner.login, e.name, t), s = [];
|
|
323
|
+
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
324
|
}
|
|
252
|
-
async function
|
|
253
|
-
|
|
254
|
-
const n = await
|
|
255
|
-
return
|
|
325
|
+
async function lt(e, t, r, s) {
|
|
326
|
+
k(pe, JSON.stringify(e, null, 2));
|
|
327
|
+
const n = await ut(t, r, s);
|
|
328
|
+
return k(ue, JSON.stringify(n, null, 2)), { user: e, repos: n };
|
|
256
329
|
}
|
|
257
|
-
async function
|
|
330
|
+
async function ft(e, t) {
|
|
258
331
|
if (!e) {
|
|
259
|
-
|
|
332
|
+
c(" No repository respect docpress rules.", "warn");
|
|
260
333
|
return;
|
|
261
334
|
}
|
|
262
335
|
await Promise.all(
|
|
263
|
-
e.filter((r) => !
|
|
264
|
-
|
|
336
|
+
e.filter((r) => !me(r, t)).map(async (r) => {
|
|
337
|
+
await ct(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
|
|
265
338
|
})
|
|
266
339
|
);
|
|
267
340
|
}
|
|
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
|
|
341
|
+
function me(e, t) {
|
|
342
|
+
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
|
+
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !o);
|
|
344
|
+
}
|
|
345
|
+
const T = [
|
|
346
|
+
m("-C, --config <string>", E.innerType().shape.config._def.description),
|
|
347
|
+
m("-T, --token <string>", E.innerType().shape.token._def.description),
|
|
348
|
+
m("-U, --username <string>", E.innerType().shape.username._def.description)
|
|
349
|
+
], ee = "fetch", ge = [
|
|
350
|
+
m("-b, --branch <string>", p.shape.branch._def.description).default(p.shape.branch._def.defaultValue()),
|
|
351
|
+
m("-g, --git-provider <string>", p.shape.gitProvider._def.description).default(p.shape.gitProvider._def.defaultValue()),
|
|
352
|
+
m("-r, --repos-filter <string>", p.shape.reposFilter._def.description)
|
|
353
|
+
], mt = O(I(ee), [...ge, ...T]).description("Fetch docs with the given username and git provider.").action(async (e) => {
|
|
354
|
+
const t = U(ee, e);
|
|
355
|
+
await he(t);
|
|
283
356
|
});
|
|
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
|
|
357
|
+
async function he(e) {
|
|
358
|
+
const { username: t, reposFilter: r, token: s, branch: n, gitProvider: o } = e;
|
|
359
|
+
c(`
|
|
360
|
+
-> 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
361
|
}
|
|
289
|
-
const
|
|
290
|
-
await
|
|
362
|
+
const gt = "build", ht = O(I(gt), T).description("Build vitepress website.").action(async (e) => {
|
|
363
|
+
await be();
|
|
291
364
|
});
|
|
292
|
-
async function
|
|
293
|
-
|
|
365
|
+
async function be() {
|
|
366
|
+
c(`
|
|
294
367
|
-> Start building Vitepress website.
|
|
295
368
|
|
|
296
369
|
`, "info");
|
|
297
370
|
try {
|
|
298
|
-
await
|
|
371
|
+
await Oe(A), c(`
|
|
299
372
|
|
|
300
373
|
Docpress build succedeed.`, "success");
|
|
301
374
|
} catch (e) {
|
|
302
|
-
|
|
375
|
+
c(`
|
|
303
376
|
|
|
304
377
|
Docpress build failed : ${e}`, "error");
|
|
305
378
|
}
|
|
306
379
|
}
|
|
307
|
-
const
|
|
380
|
+
const te = {
|
|
308
381
|
base: "/",
|
|
309
382
|
lang: "en-US",
|
|
310
383
|
vite: {
|
|
@@ -341,150 +414,197 @@ const H = {
|
|
|
341
414
|
}
|
|
342
415
|
}
|
|
343
416
|
};
|
|
344
|
-
function
|
|
345
|
-
return r ?
|
|
417
|
+
function bt(e, t, r) {
|
|
418
|
+
return r ? L(te, r, { themeConfig: { sidebar: e, nav: t } }) : L(te, { themeConfig: { sidebar: e, nav: t } });
|
|
346
419
|
}
|
|
347
|
-
function
|
|
348
|
-
const
|
|
349
|
-
|
|
420
|
+
function vt(e, t) {
|
|
421
|
+
const s = x(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (n, o, i) => `[${o}](${t}/${i})`);
|
|
422
|
+
k(e, s, "utf8");
|
|
350
423
|
}
|
|
351
|
-
function
|
|
352
|
-
const
|
|
353
|
-
|
|
424
|
+
function yt(e, t) {
|
|
425
|
+
const s = x(e, "utf8").replace(/\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.?\/)?([^/][^)]+)\)/g, (n, o, i, a) => `[${o}](${t}/${a})`).replace(/\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, (n, o, i, a) => `[${o}](${a})`);
|
|
426
|
+
k(e, s, "utf8");
|
|
354
427
|
}
|
|
355
|
-
function
|
|
356
|
-
const n = `${
|
|
428
|
+
function re(e, t) {
|
|
429
|
+
const n = `${b(t) === "introduction.md" ? `
|
|
357
430
|
## Sources` : "# Sources"}
|
|
358
431
|
|
|
359
432
|
Take a look at the [project sources](${e}).
|
|
360
433
|
`;
|
|
361
|
-
|
|
434
|
+
ie(t, n, "utf8");
|
|
362
435
|
}
|
|
363
|
-
function
|
|
364
|
-
const { name: r, login:
|
|
436
|
+
function wt(e, t) {
|
|
437
|
+
const { name: r, login: s, bio: n } = t;
|
|
365
438
|
return {
|
|
366
439
|
layout: "home",
|
|
367
440
|
hero: {
|
|
368
|
-
name: r ? `${r}'s projects` : `${
|
|
441
|
+
name: r ? `${r}'s projects` : `${s}'s projects`,
|
|
369
442
|
tagline: n ?? "Robots are everywhere 🤖"
|
|
370
443
|
// \U0001F916
|
|
371
444
|
},
|
|
372
445
|
features: e
|
|
373
446
|
};
|
|
374
447
|
}
|
|
375
|
-
function
|
|
376
|
-
const
|
|
377
|
-
title:
|
|
448
|
+
function kt(e, t, r) {
|
|
449
|
+
const s = {
|
|
450
|
+
title: w(e, { mode: "capitalize", replaceDash: !0 }),
|
|
378
451
|
details: t,
|
|
379
452
|
link: `/${e}/introduction`
|
|
380
453
|
};
|
|
381
|
-
return r ? [...r,
|
|
454
|
+
return r ? [...r, s] : [s];
|
|
382
455
|
}
|
|
383
|
-
function
|
|
456
|
+
function $t(e, t) {
|
|
384
457
|
return {
|
|
385
|
-
text:
|
|
458
|
+
text: w(e, { mode: "capitalize", replaceDash: !0 }),
|
|
386
459
|
collapsed: !0,
|
|
387
460
|
items: t
|
|
388
461
|
};
|
|
389
462
|
}
|
|
390
|
-
function
|
|
391
|
-
const
|
|
392
|
-
text: t === "introduction" ? "Introduction" :
|
|
463
|
+
function D(e, t, r) {
|
|
464
|
+
const s = {
|
|
465
|
+
text: t === "introduction" ? "Introduction" : w(t, { mode: "capitalize", replaceDash: !0 }),
|
|
393
466
|
link: `/${e}/${t}`
|
|
394
467
|
};
|
|
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
|
-
|
|
468
|
+
return r ? [...r, s] : [s];
|
|
469
|
+
}
|
|
470
|
+
function Ct(e, t) {
|
|
471
|
+
const r = [], s = [];
|
|
472
|
+
for (const o of e) {
|
|
473
|
+
c(` Replace urls for repository '${o.name}'.`, "info"), fe([o.docpress.projectPath]).forEach((a) => {
|
|
474
|
+
c(` Processing file '${b(a)}' for repository '${o.name}'.`, "debug"), vt(a, `https://github.com/${o.owner.login}/${o.name}/tree/${o.docpress.branch}`), b(a).toLowerCase() === "readme.md" && yt(a, `https://github.com/${o.owner.login}/${o.name}/tree/${o.docpress.branch}`);
|
|
475
|
+
}), c(` Generate sidebar for repository '${o.name}'.`, "info");
|
|
476
|
+
const i = ne(o.docpress.projectPath).filter((a) => V(d(o.docpress.projectPath, a)).isFile() && b(d(o.docpress.projectPath, a)).endsWith(".md")).sort((a, l) => a.localeCompare(l)).reduce((a, l, g, v) => {
|
|
477
|
+
const h = d(o.docpress.projectPath, l);
|
|
478
|
+
let f = w(b(h), { mode: "lowercase", removeIdx: !0 });
|
|
479
|
+
if (f === "readme.md" && (f = "introduction.md"), f !== b(h) && Se(h, d(ce(h), f)), g === v.length - 1) {
|
|
480
|
+
let y;
|
|
481
|
+
if (v.length > 1)
|
|
482
|
+
return y = d(o.docpress.projectPath, "sources.md"), c(` Add sources for repository '${o.name}'.`, "info"), re(o.html_url, y), D(
|
|
483
|
+
o.name,
|
|
484
|
+
S(y).name,
|
|
485
|
+
D(o.name, S(f).name, a)
|
|
413
486
|
);
|
|
414
|
-
|
|
487
|
+
y = d(o.docpress.projectPath, f), re(o.html_url, y);
|
|
415
488
|
}
|
|
416
|
-
return
|
|
489
|
+
return D(o.name, S(f).name, a);
|
|
417
490
|
}, []);
|
|
418
|
-
|
|
491
|
+
s.push($t(o.name, i)), r.push(...kt(o.name, o.description || ""));
|
|
419
492
|
}
|
|
420
|
-
|
|
421
|
-
const n =
|
|
493
|
+
c(" Generate index content.", "info");
|
|
494
|
+
const n = wt(r.sort((o, i) => o.title.localeCompare(i.title)), t);
|
|
422
495
|
return {
|
|
423
|
-
sidebar:
|
|
496
|
+
sidebar: s.sort((o, i) => o.text.localeCompare(i.text)),
|
|
424
497
|
index: n
|
|
425
498
|
};
|
|
426
499
|
}
|
|
427
|
-
function
|
|
428
|
-
const t =
|
|
429
|
-
|
|
430
|
-
for (const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
500
|
+
function St(e) {
|
|
501
|
+
const t = fe(e), r = [];
|
|
502
|
+
c(" Add extras Vitepress headers pages.", "info");
|
|
503
|
+
for (const s of t) {
|
|
504
|
+
c(` Processing file '${s}'.`, "debug");
|
|
505
|
+
const n = d(process.cwd(), s), o = d(le, w(b(s), { mode: "lowercase", removeIdx: !0 }));
|
|
506
|
+
j(n, o), r.push({
|
|
507
|
+
text: w(S(n).name, { replaceDash: !0, removeIdx: !0 }),
|
|
508
|
+
link: `/${w(S(n).name, { removeIdx: !0, mode: "lowercase" })}`
|
|
435
509
|
});
|
|
436
510
|
}
|
|
437
511
|
return r;
|
|
438
512
|
}
|
|
439
|
-
function
|
|
440
|
-
for (const
|
|
441
|
-
const n =
|
|
442
|
-
for (const i of
|
|
443
|
-
const a =
|
|
444
|
-
|
|
513
|
+
function G(e, t, r) {
|
|
514
|
+
for (const s of Array.isArray(e) ? e : [e]) {
|
|
515
|
+
const n = d(process.cwd(), s), o = M(n);
|
|
516
|
+
for (const i of o) {
|
|
517
|
+
const a = i.replace(n, ".");
|
|
518
|
+
c(` Processing file '${a}' for entry '${s}'.`, "debug");
|
|
519
|
+
const l = d(process.cwd(), i), g = d(t, a);
|
|
520
|
+
j(l, g);
|
|
445
521
|
}
|
|
446
522
|
}
|
|
447
523
|
}
|
|
448
|
-
function
|
|
524
|
+
function xt(e) {
|
|
525
|
+
const t = `---
|
|
526
|
+
`, r = `layout: fork-page
|
|
527
|
+
repoList:
|
|
528
|
+
`, s = `
|
|
529
|
+
# External contributions
|
|
530
|
+
|
|
531
|
+
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.
|
|
532
|
+
|
|
533
|
+
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.
|
|
534
|
+
|
|
535
|
+
This page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.
|
|
536
|
+
`, n = e.map(({ repository: o, contributions: i }) => {
|
|
537
|
+
const { name: a, owner: l, html_url: g, description: v, stargazers_count: h } = o;
|
|
538
|
+
return { name: a, owner: l.login, html_url: g, description: v, stargazers_count: h, contributions: i };
|
|
539
|
+
});
|
|
540
|
+
c(" Generate forks page.", "info"), k(Be, t.concat(r, de.stringify(n), t, s));
|
|
541
|
+
}
|
|
542
|
+
async function Pt(e, t, r) {
|
|
543
|
+
const s = await Promise.all(
|
|
544
|
+
e.map(async (n) => {
|
|
545
|
+
const { source: o, contributors: i } = await it({ repository: n, token: r });
|
|
546
|
+
return {
|
|
547
|
+
contributions: i?.find((a) => a.login === t)?.contributions ?? 0,
|
|
548
|
+
repository: o
|
|
549
|
+
};
|
|
550
|
+
})
|
|
551
|
+
).then((n) => n.filter(({ repository: o, contributions: i }) => !!o && i));
|
|
552
|
+
xt(s);
|
|
553
|
+
}
|
|
554
|
+
function Et(e, t) {
|
|
449
555
|
const r = `---
|
|
450
556
|
`;
|
|
451
|
-
|
|
452
|
-
`),
|
|
453
|
-
}
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
557
|
+
N(ce(X)), c(" Generate Vitepress config.", "info"), k(X, `export default ${JSON.stringify(e, null, 2)}
|
|
558
|
+
`), c(" Generate index file.", "info"), k(qe, r.concat(de.stringify(t), r));
|
|
559
|
+
}
|
|
560
|
+
const oe = "prepare", ve = [
|
|
561
|
+
m("-c, --extra-public-content <string>", p.shape.extraPublicContent._def.description),
|
|
562
|
+
m("-f, --forks", p.shape.forks._def.description),
|
|
563
|
+
m("-p, --extra-header-pages <string>", p.shape.extraHeaderPages._def.description),
|
|
564
|
+
m("-t, --extra-theme <string>", p.shape.extraTheme._def.description),
|
|
565
|
+
m("-v, --vitepress-config <string>", p.shape.vitepressConfig._def.description)
|
|
566
|
+
], _t = O(I(oe), [...ve, ...T]).description("Transform doc to the target vitepress format.").action(async (e) => {
|
|
567
|
+
const t = U(oe, e);
|
|
568
|
+
await ye(t);
|
|
462
569
|
});
|
|
463
|
-
async function
|
|
464
|
-
const { extraHeaderPages: t, extraPublicContent: r, extraTheme:
|
|
465
|
-
|
|
570
|
+
async function ye(e) {
|
|
571
|
+
const { extraHeaderPages: t, extraPublicContent: r, extraTheme: s, vitepressConfig: n, forks: o, token: i, username: a } = e;
|
|
572
|
+
c(`
|
|
466
573
|
-> Start transform files to prepare Vitepress build.`, "info");
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
574
|
+
const l = Qe(), g = et().reduce(({ internals: $, forks: C }, F) => {
|
|
575
|
+
const { clone_url: we, private: ke, fork: z, docpress: q } = F;
|
|
576
|
+
if (we && !ke && !q.filtered) {
|
|
577
|
+
if (!z && q.includes.length)
|
|
578
|
+
return { internals: [...$, F], forks: C };
|
|
579
|
+
if (z)
|
|
580
|
+
return { internals: $, forks: [...C, F] };
|
|
581
|
+
}
|
|
582
|
+
return { internals: $, forks: C };
|
|
583
|
+
}, { internals: [], forks: [] }), { sidebar: v, index: h } = Ct(g.internals, l), f = [];
|
|
584
|
+
if (t) {
|
|
585
|
+
const $ = St(t);
|
|
586
|
+
o ? f.push(...$.filter((C) => C.link !== "/forks")) : f.push(...$);
|
|
587
|
+
}
|
|
588
|
+
r && (c(" Add extras Vitepress public folder content.", "info"), G(r, d(A, "public"))), c(" Add Docpress theme files.", "info"), G(Ke, d(Je)), s && (c(" Add extras Vitepress theme files.", "info"), G(s, d(We))), o && a && (c(" Add fork page to display external contributions.", "info"), await Pt(g.forks, a, i), f.push({ text: "Forks", link: "/forks" }));
|
|
589
|
+
const y = bt(v, f, n);
|
|
590
|
+
Et(y, h);
|
|
591
|
+
}
|
|
592
|
+
function Ot() {
|
|
593
|
+
const e = new $e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${Ue.version}`).action(async (t, r) => {
|
|
594
|
+
const s = U("global", t);
|
|
595
|
+
await he(s), await ye(s), await be();
|
|
476
596
|
}).configureHelp({
|
|
477
597
|
sortSubcommands: !0,
|
|
478
598
|
sortOptions: !0,
|
|
479
599
|
showGlobalOptions: !0
|
|
480
|
-
}).enablePositionalOptions().passThroughOptions();
|
|
481
|
-
return
|
|
600
|
+
}).enablePositionalOptions().passThroughOptions().addCommand(mt).addCommand(_t).addCommand(ht);
|
|
601
|
+
return O(e, [...ge, ...ve, ...T]), e;
|
|
482
602
|
}
|
|
483
|
-
function
|
|
484
|
-
|
|
603
|
+
function Ht() {
|
|
604
|
+
Ot().parseAsync(process.argv);
|
|
485
605
|
}
|
|
486
606
|
export {
|
|
487
|
-
|
|
488
|
-
|
|
607
|
+
Ot as getProgram,
|
|
608
|
+
Ht as main
|
|
489
609
|
};
|
|
490
610
|
//# sourceMappingURL=cli.js.map
|