@tobi-or-not/docpress 0.7.0 → 0.7.2
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 +305 -257
- package/dist/cli.js.map +1 -1
- package/dist/templates/theme/index.ts +2 -0
- package/dist/templates/theme/layouts/ForkPage.vue +3 -2
- package/package.json +26 -23
- 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 +139 -0
- 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 +89 -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,39 +1,25 @@
|
|
|
1
|
-
import { createOption as f, createCommand as
|
|
2
|
-
import {
|
|
3
|
-
import { resolve as
|
|
4
|
-
import
|
|
5
|
-
import { rimrafSync as
|
|
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
|
+
import { rimrafSync as Oe } from "rimraf";
|
|
6
6
|
import ee from "chalk";
|
|
7
|
-
import {
|
|
7
|
+
import { fromError as _e } from "zod-validation-error";
|
|
8
8
|
import { z as l } from "zod";
|
|
9
|
-
import { Octokit as
|
|
10
|
-
import { simpleGit as
|
|
11
|
-
import { build as
|
|
9
|
+
import { Octokit as de } from "@octokit/rest";
|
|
10
|
+
import { simpleGit as Re } from "simple-git";
|
|
11
|
+
import { build as Ae } from "vitepress";
|
|
12
12
|
import { readFile as Ie } from "node:fs/promises";
|
|
13
|
-
import
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
d(process.cwd(), "docpress/repositories.json");
|
|
32
|
-
d(process.cwd(), "docpress/owner.json");
|
|
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) {
|
|
13
|
+
import q from "yaml";
|
|
14
|
+
const je = "0.7.2", 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
|
}
|
|
@@ -42,41 +28,41 @@ function m(e, t) {
|
|
|
42
28
|
let r = "";
|
|
43
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 && O(e) &&
|
|
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
|
|
58
|
+
function Me(e) {
|
|
73
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(C(`${
|
|
61
|
+
function Ue(e) {
|
|
62
|
+
return JSON.parse(C(`${S}/user-${e}.json`).toString());
|
|
77
63
|
}
|
|
78
|
-
function
|
|
79
|
-
return JSON.parse(C(`${
|
|
64
|
+
function We(e) {
|
|
65
|
+
return JSON.parse(C(`${S}/repos-${e}.json`).toString());
|
|
80
66
|
}
|
|
81
67
|
function U(...e) {
|
|
82
68
|
return e.reduce((t, r) => (r === null || Object.keys(r).forEach((o) => {
|
|
@@ -87,11 +73,11 @@ function U(...e) {
|
|
|
87
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 {};
|
|
@@ -100,27 +86,27 @@ function oe(e) {
|
|
|
100
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
100
|
function a(e, t = "info", r) {
|
|
115
|
-
const o = r ? ee[r](e) : ee[
|
|
116
|
-
|
|
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
106
|
usernames: l.string().array().describe("List of comma separated Git provider usernames used to collect data."),
|
|
121
107
|
// Fetch
|
|
122
108
|
branch: l.string().describe("Branch used to collect Git provider data.").default("main"),
|
|
123
|
-
gitProvider: l.enum(
|
|
109
|
+
gitProvider: l.enum(se).describe(`Git provider used to retrieve data. Values should be ${Me(se)}.`).default("github"),
|
|
124
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
112
|
extraHeaderPages: l.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
@@ -130,52 +116,60 @@ const ne = ["github"], p = l.object({
|
|
|
130
116
|
vitepressConfig: l.any().describe("Path to the vitepress configuration file."),
|
|
131
117
|
websiteTitle: l.string().describe("Website title."),
|
|
132
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
|
|
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,
|
|
138
152
|
...n,
|
|
139
|
-
...i.vitepressConfig
|
|
140
|
-
}, g = {
|
|
141
|
-
...i,
|
|
142
|
-
...c,
|
|
143
153
|
...s,
|
|
144
|
-
...
|
|
154
|
+
...r ? {
|
|
155
|
+
vitepressConfig: {
|
|
156
|
+
...W(r) || {},
|
|
157
|
+
...n.vitepressConfig || {}
|
|
158
|
+
}
|
|
159
|
+
} : {}
|
|
145
160
|
};
|
|
146
|
-
return
|
|
147
|
-
} catch (
|
|
148
|
-
a(
|
|
149
|
-
${ue(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
|
-
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
|
-
});
|
|
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({
|
|
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 I = p.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
|
};
|
|
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
|
+
}
|
|
194
198
|
function K(e, t) {
|
|
195
199
|
a("Initializing Docpress...", "info", "blue"), a(`
|
|
196
200
|
|
|
197
|
-
-> Checking for required environment settings and configurations.`, "info");
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
+
}
|
|
201
227
|
}
|
|
202
|
-
function
|
|
203
|
-
|
|
228
|
+
function j(e, t) {
|
|
229
|
+
for (const r of t)
|
|
230
|
+
e.addOption(r);
|
|
231
|
+
return e;
|
|
204
232
|
}
|
|
205
|
-
async function
|
|
233
|
+
async function et({ username: e, token: t, branch: r }) {
|
|
206
234
|
a(` Get infos for username '${e}'.`, "info");
|
|
207
|
-
const o = new
|
|
235
|
+
const o = new de({ auth: t });
|
|
208
236
|
a(" Get user infos.", "debug");
|
|
209
237
|
const { data: s } = await o.rest.users.getByUsername({ username: e });
|
|
210
238
|
a(" Get repositories infos.", "debug");
|
|
211
|
-
const { data: i } = await o.rest.repos.listForUser({ username: e, sort: "full_name" });
|
|
239
|
+
const { data: i } = await o.rest.repos.listForUser({ username: e, sort: "full_name", per_page: 500 });
|
|
212
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
246
|
a(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
219
|
-
const r = new
|
|
247
|
+
const r = new de({
|
|
220
248
|
auth: t,
|
|
221
249
|
log: {
|
|
222
250
|
debug: () => {
|
|
@@ -255,42 +283,42 @@ async function ut({
|
|
|
255
283
|
}
|
|
256
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
291
|
for (const n of s)
|
|
264
|
-
a(` Add '${n}' to '${e}' sparse-checkout file.`, "debug"), le(
|
|
292
|
+
a(` Add '${n}' to '${e}' sparse-checkout file.`, "debug"), le(u(r, ".git/info/sparse-checkout"), `${n}
|
|
265
293
|
`, "utf8");
|
|
266
|
-
a(` Clone repository '${e}'.`, "info"), await i.pull("origin", o), s.some((n) => n.includes("docs")) && (B(
|
|
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`, s = `https://github.com/${e}/${t}/tree/${r}/docs`, i = `https://github.com/${e}/${t}/tree/${r}/docs/01-readme.md`, n = await
|
|
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
302
|
rootReadmeStatus: n,
|
|
275
303
|
docsFolderStatus: c,
|
|
276
|
-
docsReadmeStatus:
|
|
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
313
|
e.map(async (s) => {
|
|
286
|
-
const i = t ?? s.default_branch ?? "main", n =
|
|
287
|
-
let
|
|
288
|
-
!s.fork && !s.private && !c && (
|
|
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({
|
|
289
317
|
...s,
|
|
290
318
|
docpress: {
|
|
291
319
|
filtered: c,
|
|
292
320
|
branch: i,
|
|
293
|
-
includes:
|
|
321
|
+
includes: p,
|
|
294
322
|
projectPath: n,
|
|
295
323
|
raw_url: `https://raw.githubusercontent.com/${s.owner.login}/${s.name}/${i}`,
|
|
296
324
|
replace_url: `https://github.com/${s.owner.login}/${s.name}/tree/${i}`
|
|
@@ -299,61 +327,74 @@ async function ht(e, t, r) {
|
|
|
299
327
|
})
|
|
300
328
|
), o;
|
|
301
329
|
}
|
|
302
|
-
async function
|
|
303
|
-
const r = await
|
|
330
|
+
async function it(e, t) {
|
|
331
|
+
const r = await ot(e.owner.login, e.name, t), o = [];
|
|
304
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 s = await
|
|
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
|
|
350
|
+
function me(e, t) {
|
|
323
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
354
|
const L = [
|
|
327
|
-
f("-C, --config <string>",
|
|
328
|
-
f("-T, --token <string>",
|
|
329
|
-
f("-U, --usernames <string>",
|
|
330
|
-
],
|
|
331
|
-
f("-b, --branch <string>",
|
|
332
|
-
f("-g, --git-provider <string>",
|
|
333
|
-
f("-r, --repos-filter <string>",
|
|
334
|
-
],
|
|
335
|
-
const t = K(
|
|
336
|
-
await
|
|
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
|
|
366
|
+
async function he(e) {
|
|
339
367
|
const { usernames: t, reposFilter: r, token: o, branch: s, gitProvider: i } = e;
|
|
340
368
|
a(`
|
|
341
|
-
-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"),
|
|
369
|
+
-> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"), F(S, { clean: !0 });
|
|
342
370
|
for (const n of t) {
|
|
343
|
-
const c = t.length > 1 ? r?.filter((
|
|
344
|
-
await
|
|
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
|
|
389
|
+
async function be() {
|
|
351
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) {
|
|
@@ -362,19 +403,19 @@ Docpress build succedeed.`, "success");
|
|
|
362
403
|
Docpress build failed : ${e}`, "error");
|
|
363
404
|
}
|
|
364
405
|
}
|
|
365
|
-
function
|
|
406
|
+
function ft(e, t) {
|
|
366
407
|
const r = C(e, { encoding: "utf8" });
|
|
367
|
-
|
|
408
|
+
F(R(t)), $(t, r);
|
|
368
409
|
}
|
|
369
|
-
function
|
|
410
|
+
function mt(e, t) {
|
|
370
411
|
const o = C(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (s, i, n) => `[${i}](${t}/${n})`);
|
|
371
|
-
|
|
412
|
+
$(e, o, "utf8");
|
|
372
413
|
}
|
|
373
|
-
function
|
|
414
|
+
function gt(e, t) {
|
|
374
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})`);
|
|
375
|
-
|
|
416
|
+
$(e, o, "utf8");
|
|
376
417
|
}
|
|
377
|
-
const
|
|
418
|
+
const ie = {
|
|
378
419
|
base: "/",
|
|
379
420
|
lang: "en-US",
|
|
380
421
|
vite: {
|
|
@@ -411,45 +452,45 @@ const ce = {
|
|
|
411
452
|
}
|
|
412
453
|
}
|
|
413
454
|
};
|
|
414
|
-
function
|
|
415
|
-
return r ? U(
|
|
416
|
-
}
|
|
417
|
-
async function
|
|
418
|
-
const
|
|
419
|
-
const { clone_url:
|
|
420
|
-
if (
|
|
421
|
-
if (!Y &&
|
|
422
|
-
return { internals: [...
|
|
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 };
|
|
423
464
|
if (Y)
|
|
424
|
-
return { internals:
|
|
465
|
+
return { internals: w, forks: [...v, x] };
|
|
425
466
|
}
|
|
426
|
-
return { internals:
|
|
427
|
-
}, { internals: [], forks: [] }),
|
|
428
|
-
let
|
|
429
|
-
if (O(
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
...
|
|
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 = [
|
|
473
|
+
...w.themeConfig?.sidebar ?? [],
|
|
433
474
|
...X
|
|
434
|
-
].sort((x,
|
|
475
|
+
].sort((x, k) => x.text.localeCompare(k.text)), D = {
|
|
435
476
|
...V,
|
|
436
477
|
features: [
|
|
437
|
-
|
|
478
|
+
...v.features,
|
|
438
479
|
...V.features
|
|
439
|
-
].sort((x,
|
|
480
|
+
].sort((x, k) => x.title.localeCompare(k.title))
|
|
440
481
|
};
|
|
441
482
|
} else
|
|
442
|
-
|
|
483
|
+
N = X, D = V;
|
|
443
484
|
const T = [];
|
|
444
485
|
if (e) {
|
|
445
|
-
const
|
|
446
|
-
s ? T.push(...
|
|
486
|
+
const w = Ct(e);
|
|
487
|
+
s ? T.push(...w.filter((v) => v.link !== "/forks")) : T.push(...w);
|
|
447
488
|
}
|
|
448
|
-
t && (a(" Add extras Vitepress public folder content.", "info"), ae(t,
|
|
449
|
-
const Se =
|
|
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
|
|
493
|
+
function wt(e, t) {
|
|
453
494
|
const r = y(t), s = `${m(r, { mode: "lowercase", removeIdx: !0 }) === "readme.md" ? `
|
|
454
495
|
## Sources` : "# Sources"}
|
|
455
496
|
|
|
@@ -457,7 +498,7 @@ Take a look at the [project sources](${e}).
|
|
|
457
498
|
`;
|
|
458
499
|
le(t, s, "utf8");
|
|
459
500
|
}
|
|
460
|
-
function
|
|
501
|
+
function yt(e, t, r) {
|
|
461
502
|
const { name: o, login: s, bio: i } = t, { title: n, tagline: c } = r;
|
|
462
503
|
return {
|
|
463
504
|
layout: "home",
|
|
@@ -465,7 +506,7 @@ function Tt(e, t, r) {
|
|
|
465
506
|
features: e
|
|
466
507
|
};
|
|
467
508
|
}
|
|
468
|
-
function
|
|
509
|
+
function $t(e, t, r) {
|
|
469
510
|
const o = {
|
|
470
511
|
title: m(e, { mode: "capitalize", replaceDash: !0 }),
|
|
471
512
|
details: t,
|
|
@@ -473,7 +514,7 @@ function Ft(e, t, r) {
|
|
|
473
514
|
};
|
|
474
515
|
return r ? [...r, o] : [o];
|
|
475
516
|
}
|
|
476
|
-
function
|
|
517
|
+
function vt(e, t) {
|
|
477
518
|
return {
|
|
478
519
|
text: m(e, { mode: "capitalize", replaceDash: !0 }),
|
|
479
520
|
collapsed: !0,
|
|
@@ -482,11 +523,11 @@ function Ot(e, t) {
|
|
|
482
523
|
}
|
|
483
524
|
function we(e, t) {
|
|
484
525
|
return Object.entries(t).flatMap(([r, o]) => r === "$" ? Array.isArray(o) ? o.map((s) => {
|
|
485
|
-
const i =
|
|
526
|
+
const i = u(e.docpress.projectPath, s);
|
|
486
527
|
let n = m(y(i), { mode: "lowercase", removeIdx: !0 });
|
|
487
|
-
return n === "readme.md" && (n = "introduction.md"), n !== y(i) &&
|
|
488
|
-
text:
|
|
489
|
-
link: m(`/${e.name}/${
|
|
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 })
|
|
490
531
|
};
|
|
491
532
|
}) : [] : typeof o == "object" ? [{
|
|
492
533
|
text: m(r, { mode: "capitalize", replaceDash: !0 }),
|
|
@@ -494,19 +535,19 @@ function we(e, t) {
|
|
|
494
535
|
items: we({ ...e, name: `${e.name}/${r}` }, o)
|
|
495
536
|
}] : []);
|
|
496
537
|
}
|
|
497
|
-
function
|
|
538
|
+
function ye(e) {
|
|
498
539
|
return e.reduce((t, r) => {
|
|
499
540
|
const [o, ...s] = r.split("/");
|
|
500
|
-
return s.length ? t[o] =
|
|
501
|
-
...t[o] ?
|
|
541
|
+
return s.length ? t[o] = ye([
|
|
542
|
+
...t[o] ? $e(t[o], "") : [],
|
|
502
543
|
s.join("/")
|
|
503
544
|
]) : t.$ = [...t.$ || [], o], t;
|
|
504
545
|
}, {});
|
|
505
546
|
}
|
|
506
|
-
function
|
|
507
|
-
return Object.entries(e).flatMap(([r, o]) => r === "$" ? Array.isArray(o) ? o.map((s) => t ? `${t}/${s}` : s) : [] :
|
|
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));
|
|
508
549
|
}
|
|
509
|
-
function
|
|
550
|
+
function xt(e) {
|
|
510
551
|
if (!Array.isArray(e))
|
|
511
552
|
return e;
|
|
512
553
|
const t = e.findIndex((o) => o.text === "Sources");
|
|
@@ -515,51 +556,51 @@ function Dt(e) {
|
|
|
515
556
|
const [r] = e.splice(t, 1);
|
|
516
557
|
return e.push(r), e;
|
|
517
558
|
}
|
|
518
|
-
function
|
|
559
|
+
function St(e, t, r) {
|
|
519
560
|
const o = [], s = [];
|
|
520
561
|
for (const n of e) {
|
|
521
|
-
a(` Replace urls for repository '${n.name}'.`, "info"),
|
|
522
|
-
a(` Processing file '${y(
|
|
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}`);
|
|
523
564
|
}), a(` Generate sidebar for repository '${n.name}'.`, "info");
|
|
524
|
-
const c =
|
|
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"));
|
|
525
566
|
a(` Add sources for repository '${n.name}'.`, "info");
|
|
526
|
-
let
|
|
527
|
-
c.length > 1 ? (
|
|
528
|
-
const
|
|
529
|
-
s.push(
|
|
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 || ""));
|
|
530
571
|
}
|
|
531
572
|
a(" Generate index content.", "info");
|
|
532
|
-
const i =
|
|
573
|
+
const i = yt(o.toSorted((n, c) => n.title.localeCompare(c.title)), t, r);
|
|
533
574
|
return {
|
|
534
575
|
sidebar: s.toSorted((n, c) => n.text.localeCompare(c.text)),
|
|
535
576
|
index: i
|
|
536
577
|
};
|
|
537
578
|
}
|
|
538
|
-
function
|
|
539
|
-
const t =
|
|
579
|
+
function Ct(e) {
|
|
580
|
+
const t = fe(e), r = [];
|
|
540
581
|
a(" Add extras Vitepress headers pages.", "info");
|
|
541
582
|
for (const o of t) {
|
|
542
583
|
a(` Processing file '${o}'.`, "debug");
|
|
543
|
-
const s =
|
|
584
|
+
const s = u(process.cwd(), o), i = u(pe, m(y(o), { mode: "lowercase", removeIdx: !0 }));
|
|
544
585
|
B(s, i), r.push({
|
|
545
|
-
text: m(
|
|
546
|
-
link: `/${m(
|
|
586
|
+
text: m(_(s).name, { replaceDash: !0, removeIdx: !0 }),
|
|
587
|
+
link: `/${m(_(s).name, { removeIdx: !0, mode: "lowercase" })}`
|
|
547
588
|
});
|
|
548
589
|
}
|
|
549
590
|
return r;
|
|
550
591
|
}
|
|
551
592
|
function ae(e, t, r) {
|
|
552
593
|
for (const o of Array.isArray(e) ? e : [e]) {
|
|
553
|
-
const s =
|
|
594
|
+
const s = u(process.cwd(), o), i = A(s);
|
|
554
595
|
for (const n of i) {
|
|
555
596
|
const c = n.replace(s, ".");
|
|
556
597
|
a(` Processing file '${c}' for entry '${o}'.`, "debug");
|
|
557
|
-
const
|
|
558
|
-
B(
|
|
598
|
+
const p = u(process.cwd(), n), h = u(t, c);
|
|
599
|
+
B(p, h);
|
|
559
600
|
}
|
|
560
601
|
}
|
|
561
602
|
}
|
|
562
|
-
function
|
|
603
|
+
function kt(e) {
|
|
563
604
|
const t = `---
|
|
564
605
|
`, r = `layout: fork-page
|
|
565
606
|
repoList:
|
|
@@ -572,77 +613,84 @@ Every tile below represents a unique project where contributions have been made-
|
|
|
572
613
|
|
|
573
614
|
This page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.
|
|
574
615
|
`, s = e.map(({ repository: i, contributions: n }) => {
|
|
575
|
-
const { name: c, owner:
|
|
576
|
-
return { name: c, owner:
|
|
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 };
|
|
577
618
|
});
|
|
578
|
-
a(" Generate forks page.", "info"),
|
|
619
|
+
a(" Generate forks page.", "info"), $(Ve, t.concat(r, q.stringify(s), t, o));
|
|
579
620
|
}
|
|
580
|
-
async function
|
|
621
|
+
async function Pt(e, t, r) {
|
|
581
622
|
const o = await Promise.all(
|
|
582
623
|
e.map(async (s) => {
|
|
583
|
-
const { source: i, contributors: n } = await
|
|
624
|
+
const { source: i, contributors: n } = await tt({ repository: s, token: r });
|
|
584
625
|
return {
|
|
585
626
|
contributions: n?.find((c) => c.login === t)?.contributions ?? 0,
|
|
586
627
|
repository: i
|
|
587
628
|
};
|
|
588
629
|
})
|
|
589
630
|
).then((s) => s.filter(({ repository: i, contributions: n }) => !!i && n));
|
|
590
|
-
|
|
631
|
+
kt(o);
|
|
591
632
|
}
|
|
592
|
-
async function
|
|
593
|
-
const { config: t } = await import(
|
|
633
|
+
async function Et(e) {
|
|
634
|
+
const { config: t } = await import(u(process.cwd(), e)).catch((r) => r);
|
|
594
635
|
return t;
|
|
595
636
|
}
|
|
596
|
-
async function
|
|
597
|
-
const t = (await Ie(
|
|
598
|
-
return
|
|
637
|
+
async function Ft(e) {
|
|
638
|
+
const t = (await Ie(u(process.cwd(), e))).toString();
|
|
639
|
+
return q.parse(t);
|
|
599
640
|
}
|
|
600
|
-
function
|
|
641
|
+
function Tt(e, t) {
|
|
601
642
|
const r = `---
|
|
602
643
|
`;
|
|
603
|
-
return
|
|
644
|
+
return F(R(E)), a(" Generate Vitepress config.", "info"), $(E, `export const config = ${JSON.stringify(e, null, 2)}
|
|
604
645
|
|
|
605
646
|
export default config
|
|
606
|
-
`), a(" Generate index file.", "info"),
|
|
647
|
+
`), a(" Generate index file.", "info"), $(M, r.concat(q.stringify(t))), a(" Add Docpress theme files.", "info"), A(te).forEach((o) => {
|
|
607
648
|
const s = o.replace(`${te}/`, "");
|
|
608
|
-
|
|
649
|
+
ft(o, u(Ne, s));
|
|
609
650
|
});
|
|
610
651
|
}
|
|
611
|
-
const
|
|
612
|
-
f("-c, --extra-public-content <string>",
|
|
613
|
-
f("-f, --forks",
|
|
614
|
-
f("-p, --extra-header-pages <string>",
|
|
615
|
-
f("-t, --extra-theme <string>",
|
|
616
|
-
f("-v, --vitepress-config <string>",
|
|
617
|
-
f("--website-title <string>",
|
|
618
|
-
f("--website-tagline <string>",
|
|
619
|
-
],
|
|
620
|
-
const t = K(
|
|
621
|
-
await
|
|
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);
|
|
662
|
+
await xe(t);
|
|
622
663
|
});
|
|
623
|
-
async function
|
|
624
|
-
const { extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: s, forks: i, token: n, usernames: c, websiteTitle:
|
|
664
|
+
async function xe(e) {
|
|
665
|
+
const { extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: s, forks: i, token: n, usernames: c, websiteTitle: p, websiteTagline: h } = e;
|
|
625
666
|
a(`
|
|
626
|
-
-> Start transform files to prepare Vitepress build.`, "info"),
|
|
667
|
+
-> Start transform files to prepare Vitepress build.`, "info"), F(R(E), { clean: !0 });
|
|
627
668
|
for (const b of c)
|
|
628
|
-
await
|
|
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
|
+
};
|
|
629
677
|
}
|
|
630
|
-
function
|
|
631
|
-
const e = new
|
|
632
|
-
const o = K("global",
|
|
633
|
-
await
|
|
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();
|
|
634
682
|
}).configureHelp({
|
|
635
683
|
sortSubcommands: !0,
|
|
636
684
|
sortOptions: !0,
|
|
637
685
|
showGlobalOptions: !0
|
|
638
|
-
}).enablePositionalOptions().passThroughOptions().addCommand(
|
|
639
|
-
return
|
|
686
|
+
}).enablePositionalOptions().passThroughOptions().addCommand(ut).addCommand(Ot).addCommand(pt);
|
|
687
|
+
return j(e, [...ge, ...ve, ...L]), e;
|
|
640
688
|
}
|
|
641
|
-
function
|
|
642
|
-
|
|
689
|
+
function zt() {
|
|
690
|
+
Rt().parseAsync(process.argv);
|
|
643
691
|
}
|
|
644
692
|
export {
|
|
645
|
-
|
|
646
|
-
|
|
693
|
+
Rt as getProgram,
|
|
694
|
+
zt as main
|
|
647
695
|
};
|
|
648
696
|
//# sourceMappingURL=cli.js.map
|