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