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