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