@tobi-or-not/docpress 0.9.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cli.js +296 -255
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Command as e, createCommand as t, createOption as n } from "commander";
|
|
2
2
|
import { appendFileSync as r, cpSync as i, existsSync as a, mkdirSync as o, readFileSync as s, readdirSync as c, renameSync as l, rmSync as u, statSync as d, writeFileSync as f } from "node:fs";
|
|
3
|
-
import { basename as p, dirname as m, join as
|
|
3
|
+
import { basename as p, dirname as m, join as ee, parse as h, relative as g, resolve as _ } from "node:path";
|
|
4
4
|
import { rimrafSync as v } from "rimraf";
|
|
5
|
-
import y from "
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
var
|
|
5
|
+
import y from "yaml";
|
|
6
|
+
import b from "chalk";
|
|
7
|
+
import { z as x } from "zod";
|
|
8
|
+
import { Octokit as S } from "@octokit/rest";
|
|
9
|
+
import { simpleGit as te } from "simple-git";
|
|
10
|
+
import { build as ne } from "vitepress";
|
|
11
|
+
import { withMermaid as re } from "vitepress-plugin-mermaid";
|
|
12
|
+
import { readFile as ie } from "node:fs/promises";
|
|
13
|
+
var ae = {
|
|
14
14
|
name: "@tobi-or-not/docpress",
|
|
15
15
|
type: "module",
|
|
16
|
-
version: "0.
|
|
16
|
+
version: "0.10.0",
|
|
17
17
|
packageManager: "bun@1.3.14",
|
|
18
18
|
homepage: "https://this-is-tobi.com/docpress/introduction",
|
|
19
19
|
repository: {
|
|
@@ -77,10 +77,10 @@ var ie = {
|
|
|
77
77
|
access: "public",
|
|
78
78
|
tag: "latest"
|
|
79
79
|
}
|
|
80
|
-
}, C = _(process.cwd(), "docpress"), w = _(process.cwd(), "docpress/docs"), T = _(process.cwd(), "docpress/docs/index.md"),
|
|
80
|
+
}, C = _(process.cwd(), "docpress"), w = _(process.cwd(), "docpress/docs"), T = _(process.cwd(), "docpress/docs/index.md"), oe = _(process.cwd(), "docpress/docs/forks.md"), E = _(process.cwd(), "docpress/.vitepress/config.ts"), se = _(process.cwd(), "docpress/.vitepress/theme"), ce = _(process.cwd(), "docpress/.vitepress/theme/extras"), D = process.env.NODE_ENV === "development" ? _(import.meta.dirname, "../../public/templates/theme") : _(import.meta.dirname, "./templates/theme"), le = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, ue = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, de = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, fe = /^\d{2}-/, O = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/, pe = /\[([^\]]+)\]\((?!https?:|\/|#|mailto:)([^)#]*\/)?([^)#/]+\.md)(#[^)]*)?\)/g;
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/utils/functions.ts
|
|
83
|
-
async function
|
|
83
|
+
async function k(e) {
|
|
84
84
|
try {
|
|
85
85
|
return (await fetch(e, {
|
|
86
86
|
method: "HEAD",
|
|
@@ -90,25 +90,25 @@ async function O(e) {
|
|
|
90
90
|
return 500;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function A(e, t) {
|
|
94
94
|
let n = "";
|
|
95
|
-
return t?.removeDot && (n = e.startsWith(".") ? e.slice(1) : e, n = n.replaceAll(".", "-")), t?.removeIdx && (n = (n || e).replace(
|
|
95
|
+
return t?.removeDot && (n = e.startsWith(".") ? e.slice(1) : e, n = n.replaceAll(".", "-")), t?.removeIdx && (n = (n || e).replace(fe, "")), t?.removeExt && (n = (n || e).split(".")[0]), t?.replaceDash && (n = (n || e).replaceAll("-", " ")), t?.mode === "capitalize" ? n = (n || e).slice(0, 1).toUpperCase() + (n || e).slice(1).toLowerCase() : t?.mode === "lowercase" ? n = (n || e).toLowerCase() : t?.mode === "uppercase" && (n = (n || e).toUpperCase()), n || e;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function j(e, { clean: t } = { clean: !1 }) {
|
|
98
98
|
try {
|
|
99
99
|
t && a(e) && v(`${e}/*`, { glob: !0 }), a(e) || o(e, { recursive: !0 });
|
|
100
100
|
} catch (e) {
|
|
101
101
|
console.error(e);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function me(e) {
|
|
105
105
|
try {
|
|
106
106
|
return d(e).isDirectory();
|
|
107
107
|
} catch {
|
|
108
108
|
return !1;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function he(e) {
|
|
112
112
|
try {
|
|
113
113
|
return d(e).isFile();
|
|
114
114
|
} catch {
|
|
@@ -116,18 +116,18 @@ function j(e) {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
function M(e) {
|
|
119
|
-
return (Array.isArray(e) ? e : [e]).flatMap((e) =>
|
|
119
|
+
return (Array.isArray(e) ? e : [e]).flatMap((e) => he(e) ? [e] : me(e) ? c(e).filter((e) => e !== ".git").sort().flatMap((t) => M(ee(e, t))) : []);
|
|
120
120
|
}
|
|
121
121
|
function N(e) {
|
|
122
122
|
return M(e).filter((e) => p(e).endsWith(".md"));
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function ge(e) {
|
|
125
125
|
return e.reduce((e, t, n, r) => n ? n === r.length - 1 ? `${e} or "${t}"` : `${e}, "${t}"` : `"${t}"`, "");
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function _e(e) {
|
|
128
128
|
return JSON.parse(s(`${C}/user-${e}.json`).toString());
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function ve(e) {
|
|
131
131
|
return JSON.parse(s(`${C}/repos-${e}.json`).toString());
|
|
132
132
|
}
|
|
133
133
|
function P(...e) {
|
|
@@ -156,19 +156,35 @@ function I(e) {
|
|
|
156
156
|
function L(e) {
|
|
157
157
|
return e.split(",");
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
f(e, s(e, "utf8").replace(
|
|
159
|
+
function ye(e, t) {
|
|
160
|
+
f(e, s(e, "utf8").replace(le, (e, n, r) => `[${n}](${t}/${r})`), "utf8");
|
|
161
|
+
}
|
|
162
|
+
function be(e, t) {
|
|
163
|
+
let n = s(e, "utf8"), r = n.match(O);
|
|
164
|
+
if (r) {
|
|
165
|
+
let i = y.parse(r[1]) ?? {};
|
|
166
|
+
i.lastUpdated = t, f(e, n.replace(O, `---\n${y.stringify(i)}---\n`), "utf8");
|
|
167
|
+
} else f(e, `---\nlastUpdated: ${t}\n---\n\n${n}`, "utf8");
|
|
168
|
+
}
|
|
169
|
+
function xe(e) {
|
|
170
|
+
f(e, s(e, "utf8").replace(pe, (e, t, n, r, i) => {
|
|
171
|
+
let a = A(r, {
|
|
172
|
+
mode: "lowercase",
|
|
173
|
+
removeIdx: !0
|
|
174
|
+
});
|
|
175
|
+
return a === "readme.md" && (a = "introduction.md"), `[${t}](${n ?? ""}${a}${i ?? ""})`;
|
|
176
|
+
}), "utf8");
|
|
161
177
|
}
|
|
162
|
-
function
|
|
163
|
-
f(e, s(e, "utf8").replace(
|
|
178
|
+
function Se(e, t) {
|
|
179
|
+
f(e, s(e, "utf8").replace(ue, (e, n, r, i) => `[${n}](${t}/${i})`).replace(de, (e, t, n, r) => `[${t}](${r})`), "utf8");
|
|
164
180
|
}
|
|
165
181
|
//#endregion
|
|
166
182
|
//#region src/utils/logger.ts
|
|
167
|
-
function
|
|
183
|
+
function Ce() {
|
|
168
184
|
let e = Number(process.env.LOG_LEVEL);
|
|
169
185
|
return Number.isNaN(e) ? 30 : e;
|
|
170
186
|
}
|
|
171
|
-
var
|
|
187
|
+
var we = {
|
|
172
188
|
error: {
|
|
173
189
|
color: "red",
|
|
174
190
|
level: 10
|
|
@@ -194,38 +210,40 @@ var R = {
|
|
|
194
210
|
level: 50
|
|
195
211
|
}
|
|
196
212
|
};
|
|
197
|
-
function
|
|
198
|
-
let r = n ?
|
|
199
|
-
|
|
213
|
+
function R(e, t = "info", n) {
|
|
214
|
+
let r = n ? b[n](e) : b[we[t].color](e), i = t === "success" ? "info" : t;
|
|
215
|
+
Ce() >= we[t].level && console[i](r);
|
|
200
216
|
}
|
|
201
217
|
//#endregion
|
|
202
218
|
//#region src/schemas/global.ts
|
|
203
|
-
var
|
|
204
|
-
usernames:
|
|
205
|
-
branch:
|
|
206
|
-
gitProvider:
|
|
207
|
-
reposFilter:
|
|
208
|
-
extraHeaderPages:
|
|
209
|
-
extraPublicContent:
|
|
210
|
-
extraTheme:
|
|
211
|
-
forks:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
219
|
+
var z = ["github", "gitlab"], B = x.object({
|
|
220
|
+
usernames: x.string().array().describe("List of comma separated Git provider usernames used to collect data."),
|
|
221
|
+
branch: x.string().default("main").describe("Branch used to collect Git provider data."),
|
|
222
|
+
gitProvider: x.enum(z).default("github").describe(`Git provider used to retrieve data. Values should be ${ge(z)}.`),
|
|
223
|
+
reposFilter: x.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
|
|
224
|
+
extraHeaderPages: x.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
225
|
+
extraPublicContent: x.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
|
|
226
|
+
extraTheme: x.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
|
|
227
|
+
forks: x.boolean().default(!1).describe("Whether or not to create the dedicated fork page that aggregate external contributions."),
|
|
228
|
+
lastUpdated: x.boolean().default(!1).describe("Whether or not to inject each page's last Git commit date as Vitepress \"lastUpdated\" frontmatter."),
|
|
229
|
+
vitepressConfig: x.any().optional().describe("Path to the vitepress configuration file."),
|
|
230
|
+
websiteTitle: x.string().describe("Website title."),
|
|
231
|
+
websiteTagline: x.string().describe("Website tagline.")
|
|
232
|
+
}), V = B.partial().extend({
|
|
233
|
+
branch: x.string().optional().describe(B.shape.branch.description || ""),
|
|
234
|
+
gitProvider: x.enum(z).optional().describe(B.shape.gitProvider.description || ""),
|
|
235
|
+
forks: x.boolean().optional().describe(B.shape.forks.description || ""),
|
|
236
|
+
lastUpdated: x.boolean().optional().describe(B.shape.lastUpdated.description || ""),
|
|
237
|
+
config: x.string().optional().describe("Path to the docpress configuration file."),
|
|
238
|
+
token: x.string().optional().describe("Git provider token used to collect data."),
|
|
239
|
+
usernames: x.string().transform(L).optional().describe(B.shape.usernames.description || ""),
|
|
240
|
+
reposFilter: x.string().transform(L).optional().describe(B.shape.reposFilter.description || ""),
|
|
241
|
+
extraHeaderPages: x.string().transform(L).optional().describe(B.shape.extraHeaderPages.description || ""),
|
|
242
|
+
extraPublicContent: x.string().transform(L).optional().describe(B.shape.extraPublicContent.description || ""),
|
|
243
|
+
extraTheme: x.string().transform(L).optional().describe(B.shape.extraTheme.description || ""),
|
|
244
|
+
vitepressConfig: x.string().optional().describe(B.shape.vitepressConfig.description || "")
|
|
227
245
|
});
|
|
228
|
-
function
|
|
246
|
+
function Te(e) {
|
|
229
247
|
if (!e) return {};
|
|
230
248
|
for (let t of [
|
|
231
249
|
"usernames",
|
|
@@ -236,23 +254,24 @@ function ye(e) {
|
|
|
236
254
|
]) e[t] && typeof e[t] == "string" && (e[t] = [e[t]]);
|
|
237
255
|
return e;
|
|
238
256
|
}
|
|
239
|
-
function
|
|
240
|
-
let t =
|
|
241
|
-
if (!t.success) throw Error(
|
|
257
|
+
function Ee(e) {
|
|
258
|
+
let t = B.partial().safeParse(e);
|
|
259
|
+
if (!t.success) throw Error(x.prettifyError(t.error));
|
|
242
260
|
return t.data;
|
|
243
261
|
}
|
|
244
|
-
function
|
|
262
|
+
function De(e) {
|
|
245
263
|
if (!e.usernames?.length) throw Error("The usernames field is required");
|
|
246
264
|
return e;
|
|
247
265
|
}
|
|
248
|
-
var
|
|
266
|
+
var Oe = V.partial().transform((e) => {
|
|
249
267
|
try {
|
|
250
268
|
let { config: t, vitepressConfig: n, token: r, ...i } = e;
|
|
251
|
-
|
|
252
|
-
let a =
|
|
269
|
+
R(`Debug: Schema transform input: ${JSON.stringify(e)}`, "debug");
|
|
270
|
+
let a = Ee(Te(I(t))), o = {
|
|
253
271
|
branch: "main",
|
|
254
272
|
gitProvider: "github",
|
|
255
273
|
forks: !1,
|
|
274
|
+
lastUpdated: !1,
|
|
256
275
|
...a,
|
|
257
276
|
...i,
|
|
258
277
|
...n ? { vitepressConfig: {
|
|
@@ -260,31 +279,31 @@ var Se = H.partial().transform((e) => {
|
|
|
260
279
|
...I(n) || {}
|
|
261
280
|
} } : {}
|
|
262
281
|
};
|
|
263
|
-
return
|
|
282
|
+
return R(`Debug: Final merged config: ${JSON.stringify(o)}`, "debug"), De({
|
|
264
283
|
...o,
|
|
265
284
|
token: r
|
|
266
285
|
});
|
|
267
286
|
} catch (e) {
|
|
268
|
-
|
|
287
|
+
R(" An error occurred while checking configuration.", "error"), e instanceof Error ? R(` ${e.message}`, "error") : R(` ${JSON.stringify(e, null, 2)}`, "error"), process.exit(1);
|
|
269
288
|
}
|
|
270
289
|
});
|
|
271
290
|
//#endregion
|
|
272
291
|
//#region src/utils/commands.ts
|
|
273
|
-
function
|
|
274
|
-
|
|
275
|
-
let n =
|
|
276
|
-
return n.success || (
|
|
292
|
+
function H(e, t) {
|
|
293
|
+
R("Initializing Docpress...", "info", "blue"), R("\n\n-> Checking for required environment settings and configurations.", "info"), R(` Debug info - opts: ${JSON.stringify(t)}`, "debug"), R(` Debug info - cmd: ${e}`, "debug");
|
|
294
|
+
let n = Oe.safeParse(t);
|
|
295
|
+
return n.success || (R(` An error occurred while checking configuration.\n ${x.prettifyError(n.error)}`, "error"), process.exit(1)), R(" Setup complete! Ready to process your documentation.", "info"), n.data;
|
|
277
296
|
}
|
|
278
|
-
function
|
|
297
|
+
function U(e, t) {
|
|
279
298
|
return Object.fromEntries(Object.entries(t).filter(([t]) => e.getOptionValueSource(t) !== "default"));
|
|
280
299
|
}
|
|
281
|
-
function
|
|
300
|
+
function W(e, t) {
|
|
282
301
|
for (let n of t) e.addOption(n);
|
|
283
302
|
return e;
|
|
284
303
|
}
|
|
285
304
|
//#endregion
|
|
286
305
|
//#region src/lib/git.ts
|
|
287
|
-
var
|
|
306
|
+
var G = {
|
|
288
307
|
debug: () => {},
|
|
289
308
|
info: () => {},
|
|
290
309
|
warn: (e) => {
|
|
@@ -294,17 +313,17 @@ var K = {
|
|
|
294
313
|
e.includes("404") || console.error(e);
|
|
295
314
|
}
|
|
296
315
|
};
|
|
297
|
-
async function
|
|
298
|
-
|
|
299
|
-
let r = new
|
|
316
|
+
async function ke({ username: e, token: t, branch: n }) {
|
|
317
|
+
R(` Get infos for username '${e}'.`, "info");
|
|
318
|
+
let r = new S({
|
|
300
319
|
auth: t,
|
|
301
|
-
log:
|
|
320
|
+
log: G
|
|
302
321
|
});
|
|
303
|
-
|
|
322
|
+
R(" Get user infos.", "debug");
|
|
304
323
|
let { data: i } = await r.rest.users.getByUsername({ username: e }).catch((t) => {
|
|
305
324
|
throw t.status === 404 ? /* @__PURE__ */ Error(`No GitHub user found for '${e}'.`) : t;
|
|
306
325
|
});
|
|
307
|
-
return
|
|
326
|
+
return R(" Get repositories infos.", "debug"), {
|
|
308
327
|
user: i,
|
|
309
328
|
repos: await r.paginate(r.rest.repos.listForUser, {
|
|
310
329
|
username: e,
|
|
@@ -314,11 +333,11 @@ async function Ce({ username: e, token: t, branch: n }) {
|
|
|
314
333
|
branch: n
|
|
315
334
|
};
|
|
316
335
|
}
|
|
317
|
-
async function
|
|
318
|
-
|
|
319
|
-
let n = new
|
|
336
|
+
async function Ae({ repository: e, token: t }) {
|
|
337
|
+
R(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
338
|
+
let n = new S({
|
|
320
339
|
auth: t,
|
|
321
|
-
log:
|
|
340
|
+
log: G
|
|
322
341
|
}), { data: r } = await n.rest.repos.get({
|
|
323
342
|
owner: e.owner.login,
|
|
324
343
|
repo: e.name
|
|
@@ -335,7 +354,7 @@ async function we({ repository: e, token: t }) {
|
|
|
335
354
|
per_page: 100
|
|
336
355
|
})) i.push(...e);
|
|
337
356
|
} catch (t) {
|
|
338
|
-
return
|
|
357
|
+
return R(` Failed to get contributors infos for repository '${e.name}'. Error : ${t.message}`, "warn"), {
|
|
339
358
|
source: r.source,
|
|
340
359
|
contributors: []
|
|
341
360
|
};
|
|
@@ -345,10 +364,24 @@ async function we({ repository: e, token: t }) {
|
|
|
345
364
|
contributors: i
|
|
346
365
|
};
|
|
347
366
|
}
|
|
348
|
-
async function
|
|
349
|
-
|
|
367
|
+
async function je(e, t, n) {
|
|
368
|
+
for (let r of N([t])) {
|
|
369
|
+
let i = g(t, r);
|
|
370
|
+
try {
|
|
371
|
+
let { latest: t } = await e.log({
|
|
372
|
+
file: i,
|
|
373
|
+
maxCount: 1
|
|
374
|
+
});
|
|
375
|
+
t?.date && be(r, t.date);
|
|
376
|
+
} catch (e) {
|
|
377
|
+
R(` Unable to get last commit date for '${i}' in repository '${n}'. Error : ${e}`, "warn");
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
async function Me(e, t, n, a, o, s) {
|
|
382
|
+
j(n, { clean: !0 });
|
|
350
383
|
try {
|
|
351
|
-
let
|
|
384
|
+
let c = te({
|
|
352
385
|
baseDir: n,
|
|
353
386
|
config: [
|
|
354
387
|
"maintenance.auto=false",
|
|
@@ -356,33 +389,33 @@ async function Te(e, t, n, a, o) {
|
|
|
356
389
|
"fetch.writeCommitGraph=false"
|
|
357
390
|
]
|
|
358
391
|
});
|
|
359
|
-
await
|
|
360
|
-
for (let t of o)
|
|
361
|
-
|
|
392
|
+
await c.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
|
|
393
|
+
for (let t of o) R(` Add '${t}' to '${e}' sparse-checkout file.`, "debug"), r(_(n, ".git/info/sparse-checkout"), `${t}\n`, "utf8");
|
|
394
|
+
R(` Clone repository '${e}'.`, "info"), await c.pull("origin", a), s && await je(c, n, e), o.some((e) => e.includes("docs")) && (i(_(n, "docs"), n, { recursive: !0 }), u(_(n, "docs"), { recursive: !0 })), u(_(n, ".git"), { recursive: !0 });
|
|
362
395
|
} catch (e) {
|
|
363
|
-
|
|
396
|
+
R(` Error when cloning repository: ${e}.`, "error");
|
|
364
397
|
}
|
|
365
398
|
}
|
|
366
399
|
//#endregion
|
|
367
400
|
//#region src/lib/gitlab.ts
|
|
368
|
-
var
|
|
369
|
-
async function
|
|
370
|
-
let n = await fetch(`${
|
|
401
|
+
var Ne = "https://gitlab.com/api/v4";
|
|
402
|
+
async function K(e, t) {
|
|
403
|
+
let n = await fetch(`${Ne}${e}`, { headers: t ? { "PRIVATE-TOKEN": t } : {} });
|
|
371
404
|
if (!n.ok) throw Error(`GitLab API request failed for '${e}' (status: ${n.status}).`);
|
|
372
405
|
return {
|
|
373
406
|
data: await n.json(),
|
|
374
407
|
headers: n.headers
|
|
375
408
|
};
|
|
376
409
|
}
|
|
377
|
-
async function
|
|
410
|
+
async function q(e, t) {
|
|
378
411
|
let n = e.includes("?") ? "&" : "?", r = [], i = "1";
|
|
379
412
|
for (; i;) {
|
|
380
|
-
let { data: a, headers: o } = await
|
|
413
|
+
let { data: a, headers: o } = await K(`${e}${n}per_page=100&page=${i}`, t);
|
|
381
414
|
r.push(...a), i = o.get("x-next-page") || null;
|
|
382
415
|
}
|
|
383
416
|
return r;
|
|
384
417
|
}
|
|
385
|
-
function
|
|
418
|
+
function J(e) {
|
|
386
419
|
return {
|
|
387
420
|
login: e.username ?? e.path,
|
|
388
421
|
name: e.name,
|
|
@@ -391,7 +424,7 @@ function Y(e) {
|
|
|
391
424
|
html_url: e.web_url
|
|
392
425
|
};
|
|
393
426
|
}
|
|
394
|
-
function
|
|
427
|
+
function Y(e, t) {
|
|
395
428
|
return {
|
|
396
429
|
name: e.path,
|
|
397
430
|
owner: { login: t },
|
|
@@ -405,32 +438,32 @@ function X(e, t) {
|
|
|
405
438
|
stargazers_count: e.star_count
|
|
406
439
|
};
|
|
407
440
|
}
|
|
408
|
-
async function
|
|
409
|
-
|
|
410
|
-
let { data: r } = await
|
|
441
|
+
async function Pe({ username: e, token: t, branch: n }) {
|
|
442
|
+
R(` Get infos for username '${e}'.`, "info");
|
|
443
|
+
let { data: r } = await K(`/users?username=${encodeURIComponent(e)}`, t);
|
|
411
444
|
if (r.length) {
|
|
412
445
|
let e = r[0];
|
|
413
|
-
t && (e = await
|
|
414
|
-
let i = await
|
|
446
|
+
t && (e = await K(`/users/${r[0].id}`, t).then((e) => e.data).catch(() => r[0])), R(" Get repositories infos.", "debug");
|
|
447
|
+
let i = await q(`/users/${r[0].id}/projects`, t);
|
|
415
448
|
return {
|
|
416
|
-
user:
|
|
417
|
-
repos: i.map((t) =>
|
|
449
|
+
user: J(e),
|
|
450
|
+
repos: i.map((t) => Y(t, e.username)),
|
|
418
451
|
branch: n
|
|
419
452
|
};
|
|
420
453
|
}
|
|
421
|
-
|
|
422
|
-
let i = await
|
|
454
|
+
R(` No GitLab user '${e}' found, trying groups.`, "debug");
|
|
455
|
+
let i = await K(`/groups/${encodeURIComponent(e)}?with_projects=false`, t).then((e) => e.data).catch(() => {
|
|
423
456
|
throw Error(`No GitLab user or group found for '${e}'.`);
|
|
424
|
-
}), a = await
|
|
457
|
+
}), a = await q(`/groups/${encodeURIComponent(e)}/projects`, t);
|
|
425
458
|
return {
|
|
426
|
-
user:
|
|
427
|
-
repos: a.map((e) =>
|
|
459
|
+
user: J(i),
|
|
460
|
+
repos: a.map((e) => Y(e, i.path)),
|
|
428
461
|
branch: n
|
|
429
462
|
};
|
|
430
463
|
}
|
|
431
464
|
//#endregion
|
|
432
465
|
//#region src/lib/fetch.ts
|
|
433
|
-
function
|
|
466
|
+
function X(e, t, n) {
|
|
434
467
|
if (n === "gitlab") {
|
|
435
468
|
let n = e.html_url ?? `https://gitlab.com/${e.owner.login}/${e.name}`;
|
|
436
469
|
return {
|
|
@@ -446,25 +479,25 @@ function Z(e, t, n) {
|
|
|
446
479
|
raw_url: `https://raw.githubusercontent.com/${e.owner.login}/${e.name}/${t}`
|
|
447
480
|
};
|
|
448
481
|
}
|
|
449
|
-
async function
|
|
482
|
+
async function Fe(e) {
|
|
450
483
|
return {
|
|
451
|
-
rootReadmeStatus: await
|
|
452
|
-
docsFolderStatus: await
|
|
453
|
-
docsReadmeStatus: await
|
|
484
|
+
rootReadmeStatus: await k(`${e.blob_url}/README.md`),
|
|
485
|
+
docsFolderStatus: await k(`${e.tree_url}/docs`),
|
|
486
|
+
docsReadmeStatus: await k(`${e.blob_url}/docs/01-readme.md`)
|
|
454
487
|
};
|
|
455
488
|
}
|
|
456
|
-
async function
|
|
457
|
-
await (r === "gitlab" ?
|
|
489
|
+
async function Ie({ username: e, branch: t, reposFilter: n, gitProvider: r, token: i, lastUpdated: a }) {
|
|
490
|
+
await (r === "gitlab" ? Pe : ke)({
|
|
458
491
|
username: e,
|
|
459
492
|
token: i,
|
|
460
493
|
branch: t
|
|
461
|
-
}).then(async ({ user: e, repos: t, branch: i }) =>
|
|
494
|
+
}).then(async ({ user: e, repos: t, branch: i }) => ze(e, t, i, n, r)).then(async ({ repos: e }) => Be(e, n, a));
|
|
462
495
|
}
|
|
463
|
-
async function
|
|
496
|
+
async function Le(e, t, n, r) {
|
|
464
497
|
let i = [];
|
|
465
498
|
return await Promise.all(e.map(async (e) => {
|
|
466
|
-
let a = t ?? e.default_branch ?? "main", o = _(w,
|
|
467
|
-
!e.fork && !e.private && !s && (l = await
|
|
499
|
+
let a = t ?? e.default_branch ?? "main", o = _(w, A(e.name, { removeDot: !0 })), s = Z(e, n), c = X(e, a, r), l = [];
|
|
500
|
+
!e.fork && !e.private && !s && (l = await Re(e, a, r)), i.push({
|
|
468
501
|
...e,
|
|
469
502
|
docpress: {
|
|
470
503
|
filtered: s,
|
|
@@ -477,58 +510,60 @@ async function Ae(e, t, n, r) {
|
|
|
477
510
|
});
|
|
478
511
|
})), i;
|
|
479
512
|
}
|
|
480
|
-
async function
|
|
481
|
-
let r = await
|
|
513
|
+
async function Re(e, t, n) {
|
|
514
|
+
let r = await Fe(X(e, t, n)), i = [];
|
|
482
515
|
return Object.values(r).every((e) => e !== 200) || !e.size ? [] : (r.docsFolderStatus === 200 && i.push("docs/*"), (r.docsFolderStatus !== 200 || r.docsReadmeStatus !== 200) && i.push("README.md", "!*/**/README.md"), i);
|
|
483
516
|
}
|
|
484
|
-
async function
|
|
517
|
+
async function ze(e, t, n, r, i) {
|
|
485
518
|
f(`${C}/user-${e.login}.json`, JSON.stringify(e, null, 2));
|
|
486
|
-
let a = await
|
|
519
|
+
let a = await Le(t, n, r, i);
|
|
487
520
|
return f(`${C}/repos-${e.login}.json`, JSON.stringify(a, null, 2)), {
|
|
488
521
|
user: e,
|
|
489
522
|
repos: a
|
|
490
523
|
};
|
|
491
524
|
}
|
|
492
|
-
async function
|
|
525
|
+
async function Be(e, t, n) {
|
|
493
526
|
if (!e) {
|
|
494
|
-
|
|
527
|
+
R(" No repository respect docpress rules.", "warn");
|
|
495
528
|
return;
|
|
496
529
|
}
|
|
497
|
-
await Promise.all(e.filter((e) => !
|
|
498
|
-
await
|
|
530
|
+
await Promise.all(e.filter((e) => !Z(e, t)).map(async (e) => {
|
|
531
|
+
await Me(e.name, e.clone_url, e.docpress.projectPath, e.docpress.branch, e.docpress.includes, n);
|
|
499
532
|
}));
|
|
500
533
|
}
|
|
501
|
-
function
|
|
534
|
+
function Z(e, t) {
|
|
502
535
|
let n = t?.every((e) => e.startsWith("!")), r = t?.filter((e) => e.startsWith("!")).some((t) => e.name === t.substring(1)), i = !t || t?.filter((e) => !e.startsWith("!")).includes(e.name) || e.fork && !r || n && !r, a = r || !i;
|
|
503
536
|
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !a);
|
|
504
537
|
}
|
|
505
538
|
//#endregion
|
|
506
539
|
//#region src/commands/global.ts
|
|
507
|
-
var
|
|
508
|
-
n("-C, --config <string>",
|
|
509
|
-
n("-T, --token <string>",
|
|
510
|
-
n("-U, --usernames <string>",
|
|
511
|
-
],
|
|
512
|
-
n("-b, --branch <string>",
|
|
513
|
-
n("-g, --git-provider <string>",
|
|
514
|
-
n("-
|
|
515
|
-
|
|
516
|
-
|
|
540
|
+
var Q = [
|
|
541
|
+
n("-C, --config <string>", V.shape.config.description),
|
|
542
|
+
n("-T, --token <string>", V.shape.token.description),
|
|
543
|
+
n("-U, --usernames <string>", V.shape.usernames.description)
|
|
544
|
+
], Ve = "fetch", He = [
|
|
545
|
+
n("-b, --branch <string>", B.shape.branch.description).default(B.shape.branch.def.defaultValue),
|
|
546
|
+
n("-g, --git-provider <string>", B.shape.gitProvider.description).default(B.shape.gitProvider.def.defaultValue),
|
|
547
|
+
n("-l, --last-updated", B.shape.lastUpdated.description),
|
|
548
|
+
n("-r, --repos-filter <string>", B.shape.reposFilter.description)
|
|
549
|
+
], Ue = W(t(Ve), [...He, ...Q]).description("Fetch docs with the given username(s) and git provider.").action(async (e, t) => {
|
|
550
|
+
await We(H(Ve, U(t, e)));
|
|
517
551
|
});
|
|
518
|
-
async function
|
|
519
|
-
let { usernames: t, reposFilter: n, token: r, branch: i, gitProvider: a } = e;
|
|
520
|
-
|
|
521
|
-
for (let e of t) await
|
|
552
|
+
async function We(e) {
|
|
553
|
+
let { usernames: t, reposFilter: n, token: r, branch: i, gitProvider: a, lastUpdated: o } = e;
|
|
554
|
+
R("\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.", "info"), j(C, { clean: !0 });
|
|
555
|
+
for (let e of t) await Ie({
|
|
522
556
|
username: e,
|
|
523
557
|
branch: i,
|
|
524
558
|
reposFilter: t.length > 1 ? n?.filter((t) => t.replace(/^!/, "").startsWith(`${e}/`)).map((t) => t.replace(`${e}/`, "")) : n,
|
|
525
559
|
gitProvider: a,
|
|
526
|
-
token: r
|
|
560
|
+
token: r,
|
|
561
|
+
lastUpdated: o
|
|
527
562
|
});
|
|
528
563
|
}
|
|
529
564
|
//#endregion
|
|
530
565
|
//#region src/commands/build.ts
|
|
531
|
-
async function
|
|
566
|
+
async function Ge(e) {
|
|
532
567
|
let t = console.warn;
|
|
533
568
|
console.warn = function(...e) {
|
|
534
569
|
e.length > 0 && typeof e[0] == "string" && (e[0].includes("[Vue warn]: Invalid watch source:") || e[0].includes("{ open: false }")) || t.apply(console, e);
|
|
@@ -539,30 +574,30 @@ async function Re(e) {
|
|
|
539
574
|
console.warn = t;
|
|
540
575
|
}
|
|
541
576
|
}
|
|
542
|
-
var
|
|
543
|
-
await
|
|
577
|
+
var Ke = W(t("build"), Q).description("Build vitepress website.").action(async (e) => {
|
|
578
|
+
await qe();
|
|
544
579
|
});
|
|
545
|
-
async function
|
|
546
|
-
|
|
580
|
+
async function qe() {
|
|
581
|
+
R("\n-> Start building Vitepress website.\n\n", "info");
|
|
547
582
|
try {
|
|
548
|
-
await
|
|
549
|
-
await
|
|
550
|
-
|
|
583
|
+
await Ge(async () => {
|
|
584
|
+
await ne(C, { onAfterConfigResolve(e) {
|
|
585
|
+
re(e);
|
|
551
586
|
} });
|
|
552
|
-
}),
|
|
587
|
+
}), R("\n\nDocpress build succeeded.", "success");
|
|
553
588
|
} catch (e) {
|
|
554
|
-
|
|
589
|
+
R(`\n\nDocpress build failed : ${e}`, "error"), process.exit(1);
|
|
555
590
|
}
|
|
556
591
|
}
|
|
557
592
|
//#endregion
|
|
558
593
|
//#region src/utils/templates.ts
|
|
559
|
-
function
|
|
594
|
+
function Je(e, t) {
|
|
560
595
|
let n = s(e, { encoding: "utf8" });
|
|
561
|
-
|
|
596
|
+
j(m(t)), f(t, n);
|
|
562
597
|
}
|
|
563
598
|
//#endregion
|
|
564
599
|
//#region src/lib/vitepress.ts
|
|
565
|
-
var
|
|
600
|
+
var Ye = {
|
|
566
601
|
base: "/",
|
|
567
602
|
lang: "en-US",
|
|
568
603
|
vite: { publicDir: "../public" },
|
|
@@ -595,21 +630,21 @@ var He = {
|
|
|
595
630
|
}
|
|
596
631
|
}
|
|
597
632
|
};
|
|
598
|
-
function
|
|
599
|
-
return n ? P(
|
|
633
|
+
function Xe(e, t, n) {
|
|
634
|
+
return n ? P(Ye, n, { themeConfig: {
|
|
600
635
|
sidebar: e,
|
|
601
636
|
nav: t
|
|
602
|
-
} }) : P(
|
|
637
|
+
} }) : P(Ye, { themeConfig: {
|
|
603
638
|
sidebar: e,
|
|
604
639
|
nav: t
|
|
605
640
|
} });
|
|
606
641
|
}
|
|
607
642
|
//#endregion
|
|
608
643
|
//#region src/lib/prepare.ts
|
|
609
|
-
async function
|
|
610
|
-
let
|
|
611
|
-
i && !
|
|
612
|
-
let
|
|
644
|
+
async function Ze({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, vitepressConfig: r, forks: i, gitProvider: o, lastUpdated: s, token: c, username: l, websiteTitle: u, websiteTagline: d }) {
|
|
645
|
+
let f = i && o !== "gitlab";
|
|
646
|
+
i && !f && R(" The forks page is not supported with the 'gitlab' provider, skipping.", "warn");
|
|
647
|
+
let p = _e(l), m = ve(l).reduce(({ internals: e, forks: t }, n) => {
|
|
613
648
|
let { clone_url: r, private: i, fork: a, docpress: o } = n;
|
|
614
649
|
if (r && !i && !o.filtered) {
|
|
615
650
|
if (!a && o.includes.length) return {
|
|
@@ -628,12 +663,12 @@ async function We({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, v
|
|
|
628
663
|
}, {
|
|
629
664
|
internals: [],
|
|
630
665
|
forks: []
|
|
631
|
-
}),
|
|
632
|
-
title:
|
|
633
|
-
tagline:
|
|
634
|
-
}, { index: h, sidebar: g } =
|
|
666
|
+
}), ee = {
|
|
667
|
+
title: u,
|
|
668
|
+
tagline: d
|
|
669
|
+
}, { index: h, sidebar: g } = at(m.internals, p, ee), v, y;
|
|
635
670
|
if (a(T) && a(E)) {
|
|
636
|
-
let e = await
|
|
671
|
+
let e = await ut(E), t = await dt(T);
|
|
637
672
|
v = [...e.themeConfig?.sidebar ?? [], ...g].sort((e, t) => e.text.localeCompare(t.text)), y = {
|
|
638
673
|
...h,
|
|
639
674
|
features: [...t.features, ...h.features].sort((e, t) => e.title.localeCompare(t.title))
|
|
@@ -641,21 +676,26 @@ async function We({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, v
|
|
|
641
676
|
} else v = g, y = h;
|
|
642
677
|
let b = [];
|
|
643
678
|
if (e) {
|
|
644
|
-
let t =
|
|
645
|
-
|
|
679
|
+
let t = ot(e);
|
|
680
|
+
f ? b.push(...t.filter((e) => e.link !== "/forks")) : b.push(...t);
|
|
646
681
|
}
|
|
647
|
-
t && (
|
|
682
|
+
t && (R(" Add extras Vitepress public folder content.", "info"), st(t, _(C, "public"))), n && (R(" Add extras Vitepress theme files.", "info"), st(n, _(ce))), f && l.length && (R(" Add fork page to display external contributions.", "info"), await lt(m.forks, l, c), b.push({
|
|
648
683
|
text: "Forks",
|
|
649
684
|
link: "/forks"
|
|
650
|
-
}))
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
685
|
+
}));
|
|
686
|
+
let x = s ? {
|
|
687
|
+
lastUpdated: !0,
|
|
688
|
+
...r
|
|
689
|
+
} : r;
|
|
690
|
+
ft(Xe(v, b, x), y);
|
|
691
|
+
}
|
|
692
|
+
function Qe(e, t) {
|
|
693
|
+
r(t, `${A(p(t), {
|
|
654
694
|
mode: "lowercase",
|
|
655
695
|
removeIdx: !0
|
|
656
696
|
}) === "readme.md" ? "\n## Sources" : "# Sources"}\n\nTake a look at the [project sources](${e}).\n`, "utf8");
|
|
657
697
|
}
|
|
658
|
-
function
|
|
698
|
+
function $e(e, t, n) {
|
|
659
699
|
let { name: r, login: i, bio: a } = t, { title: o, tagline: s } = n;
|
|
660
700
|
return {
|
|
661
701
|
layout: "home",
|
|
@@ -669,20 +709,20 @@ function Ke(e, t, n) {
|
|
|
669
709
|
features: e
|
|
670
710
|
};
|
|
671
711
|
}
|
|
672
|
-
function
|
|
712
|
+
function et(e, t, n) {
|
|
673
713
|
let r = {
|
|
674
|
-
title:
|
|
714
|
+
title: A(e, {
|
|
675
715
|
mode: "capitalize",
|
|
676
716
|
replaceDash: !0
|
|
677
717
|
}),
|
|
678
718
|
details: t,
|
|
679
|
-
link: `/${
|
|
719
|
+
link: `/${A(e, { removeDot: !0 })}/introduction`
|
|
680
720
|
};
|
|
681
721
|
return n ? [...n, r] : [r];
|
|
682
722
|
}
|
|
683
|
-
function
|
|
723
|
+
function tt(e, t) {
|
|
684
724
|
return {
|
|
685
|
-
text:
|
|
725
|
+
text: A(e, {
|
|
686
726
|
mode: "capitalize",
|
|
687
727
|
replaceDash: !0
|
|
688
728
|
}),
|
|
@@ -690,86 +730,86 @@ function Je(e, t) {
|
|
|
690
730
|
items: t
|
|
691
731
|
};
|
|
692
732
|
}
|
|
693
|
-
function
|
|
733
|
+
function $(e, t) {
|
|
694
734
|
return Object.entries(t).flatMap(([t, n]) => t === "$" ? Array.isArray(n) ? n.map((t) => {
|
|
695
|
-
let n = _(e.docpress.projectPath, t), r =
|
|
735
|
+
let n = _(e.docpress.projectPath, t), r = A(p(n), {
|
|
696
736
|
mode: "lowercase",
|
|
697
737
|
removeIdx: !0
|
|
698
738
|
});
|
|
699
739
|
return r === "readme.md" && (r = "introduction.md"), r !== p(n) && l(n, _(m(n), r)), {
|
|
700
|
-
text:
|
|
740
|
+
text: h(r).name === "introduction" ? "Introduction" : A(r, {
|
|
701
741
|
mode: "capitalize",
|
|
702
742
|
replaceDash: !0,
|
|
703
743
|
removeExt: !0
|
|
704
744
|
}),
|
|
705
|
-
link: `/${
|
|
745
|
+
link: `/${A(e.name, { removeDot: !0 })}/${h(r).name}`
|
|
706
746
|
};
|
|
707
747
|
}) : [] : typeof n == "object" ? [{
|
|
708
|
-
text:
|
|
748
|
+
text: A(t, {
|
|
709
749
|
mode: "capitalize",
|
|
710
750
|
replaceDash: !0
|
|
711
751
|
}),
|
|
712
752
|
collapsed: !0,
|
|
713
|
-
items:
|
|
753
|
+
items: $({
|
|
714
754
|
...e,
|
|
715
755
|
name: `${e.name}/${t}`
|
|
716
756
|
}, n)
|
|
717
757
|
}] : []);
|
|
718
758
|
}
|
|
719
|
-
function
|
|
759
|
+
function nt(e) {
|
|
720
760
|
return e.reduce((e, t) => {
|
|
721
761
|
let [n, ...r] = t.split("/");
|
|
722
|
-
return r.length ? e[n] =
|
|
762
|
+
return r.length ? e[n] = nt([...e[n] ? rt(e[n], "") : [], r.join("/")]) : e.$ = [...e.$ || [], n], e;
|
|
723
763
|
}, {});
|
|
724
764
|
}
|
|
725
|
-
function
|
|
726
|
-
return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] :
|
|
765
|
+
function rt(e, t = "") {
|
|
766
|
+
return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] : rt(n, t ? `${t}/${e}` : e));
|
|
727
767
|
}
|
|
728
|
-
function
|
|
768
|
+
function it(e) {
|
|
729
769
|
if (!Array.isArray(e)) return e;
|
|
730
770
|
let t = e.findIndex((e) => e.text === "Sources");
|
|
731
771
|
if (t === -1) return e;
|
|
732
772
|
let [n] = e.splice(t, 1);
|
|
733
773
|
return e.push(n), e;
|
|
734
774
|
}
|
|
735
|
-
function
|
|
775
|
+
function at(e, t, n) {
|
|
736
776
|
let r = [], i = [];
|
|
737
777
|
for (let t of e) {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}),
|
|
778
|
+
R(` Replace urls for repository '${t.name}'.`, "info"), N([t.docpress.projectPath]).forEach((e) => {
|
|
779
|
+
R(` Processing file '${p(e)}' for repository '${t.name}'.`, "debug"), ye(e, t.docpress.replace_url), p(e).toLowerCase() === "readme.md" && Se(e, t.docpress.replace_url), xe(e);
|
|
780
|
+
}), R(` Generate sidebar for repository '${t.name}'.`, "info");
|
|
741
781
|
let e = c(t.docpress.projectPath, { recursive: !0 }).filter((e) => {
|
|
742
782
|
let n = _(t.docpress.projectPath, e.toString());
|
|
743
|
-
return p(n).endsWith(".md") &&
|
|
783
|
+
return p(n).endsWith(".md") && he(n);
|
|
744
784
|
}).sort();
|
|
745
|
-
|
|
785
|
+
R(` Add sources for repository '${t.name}'.`, "info");
|
|
746
786
|
let n;
|
|
747
|
-
e.length > 1 ? (n = _(t.docpress.projectPath, "sources.md"), e.push("sources.md")) : e.length === 1 && (n = _(t.docpress.projectPath, e[0])), n ?
|
|
748
|
-
let a =
|
|
749
|
-
i.push(
|
|
787
|
+
e.length > 1 ? (n = _(t.docpress.projectPath, "sources.md"), e.push("sources.md")) : e.length === 1 && (n = _(t.docpress.projectPath, e[0])), n ? Qe(t.html_url, n) : R(` No markdown files found for repository '${t.name}', skipping sources.`, "warn");
|
|
788
|
+
let a = it($(t, nt(e)));
|
|
789
|
+
i.push(tt(A(t.name, { removeDot: !0 }), a)), r.push(...et(A(t.name, { removeDot: !0 }), t.description || ""));
|
|
750
790
|
}
|
|
751
|
-
|
|
752
|
-
let a =
|
|
791
|
+
R(" Generate index content.", "info");
|
|
792
|
+
let a = $e(r.toSorted((e, t) => e.title.localeCompare(t.title)), t, n);
|
|
753
793
|
return {
|
|
754
794
|
sidebar: i.toSorted((e, t) => e.text.localeCompare(t.text)),
|
|
755
795
|
index: a
|
|
756
796
|
};
|
|
757
797
|
}
|
|
758
|
-
function
|
|
798
|
+
function ot(e) {
|
|
759
799
|
let t = N(e), n = [];
|
|
760
|
-
|
|
800
|
+
R(" Add extras Vitepress headers pages.", "info");
|
|
761
801
|
for (let e of t) {
|
|
762
|
-
|
|
802
|
+
R(` Processing file '${e}'.`, "debug");
|
|
763
803
|
let t = _(process.cwd(), e);
|
|
764
|
-
i(t, _(w,
|
|
804
|
+
i(t, _(w, A(p(e), {
|
|
765
805
|
mode: "lowercase",
|
|
766
806
|
removeIdx: !0
|
|
767
807
|
}))), n.push({
|
|
768
|
-
text:
|
|
808
|
+
text: A(h(t).name, {
|
|
769
809
|
replaceDash: !0,
|
|
770
810
|
removeIdx: !0
|
|
771
811
|
}),
|
|
772
|
-
link: `/${
|
|
812
|
+
link: `/${A(h(t).name, {
|
|
773
813
|
removeIdx: !0,
|
|
774
814
|
mode: "lowercase"
|
|
775
815
|
})}`
|
|
@@ -777,18 +817,18 @@ function et(e) {
|
|
|
777
817
|
}
|
|
778
818
|
return n;
|
|
779
819
|
}
|
|
780
|
-
function
|
|
820
|
+
function st(e, t, n) {
|
|
781
821
|
for (let r of Array.isArray(e) ? e : [e]) {
|
|
782
822
|
let e = _(process.cwd(), r), a = M(e);
|
|
783
823
|
for (let o of a) {
|
|
784
824
|
let a = o.replace(e, ".");
|
|
785
|
-
|
|
825
|
+
R(` Processing file '${a}' for entry '${r}'.`, "debug");
|
|
786
826
|
let s = _(process.cwd(), o), c = _(t, a);
|
|
787
827
|
n && n(), i(s, c);
|
|
788
828
|
}
|
|
789
829
|
}
|
|
790
830
|
}
|
|
791
|
-
function
|
|
831
|
+
function ct(e) {
|
|
792
832
|
let t = e.map(({ repository: e, contributions: t }) => {
|
|
793
833
|
let { name: n, owner: r, html_url: i, description: a, stargazers_count: o } = e;
|
|
794
834
|
return {
|
|
@@ -800,11 +840,11 @@ function nt(e) {
|
|
|
800
840
|
contributions: t
|
|
801
841
|
};
|
|
802
842
|
});
|
|
803
|
-
|
|
843
|
+
R(" Generate forks page.", "info"), f(oe, "---\nlayout: fork-page\nrepoList:\n" + y.stringify(t) + "---\n\n# External contributions\n\nThis gallery is a visual representation of the collaborative work done across a variety of open-source projects, each driven by a shared passion for innovation and community growth.\n\nEvery 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.\n\nThis page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.\n");
|
|
804
844
|
}
|
|
805
|
-
async function
|
|
806
|
-
|
|
807
|
-
let { source: r, contributors: i } = await
|
|
845
|
+
async function lt(e, t, n) {
|
|
846
|
+
ct(await Promise.all(e.map(async (e) => {
|
|
847
|
+
let { source: r, contributors: i } = await Ae({
|
|
808
848
|
repository: e,
|
|
809
849
|
token: n
|
|
810
850
|
});
|
|
@@ -814,75 +854,76 @@ async function rt(e, t, n) {
|
|
|
814
854
|
};
|
|
815
855
|
})).then((e) => e.filter(({ repository: e, contributions: t }) => !!e && t)));
|
|
816
856
|
}
|
|
817
|
-
async function
|
|
857
|
+
async function ut(e) {
|
|
818
858
|
try {
|
|
819
859
|
let { config: t } = await import(_(process.cwd(), e));
|
|
820
860
|
return t ?? {};
|
|
821
861
|
} catch (t) {
|
|
822
|
-
return
|
|
862
|
+
return R(` Unable to load existing Vitepress config '${e}', starting from an empty config. ${t instanceof Error ? t.message : ""}`, "warn"), {};
|
|
823
863
|
}
|
|
824
864
|
}
|
|
825
|
-
async function
|
|
826
|
-
let t = (await
|
|
827
|
-
return
|
|
865
|
+
async function dt(e) {
|
|
866
|
+
let t = (await ie(_(process.cwd(), e))).toString();
|
|
867
|
+
return y.parse(t);
|
|
828
868
|
}
|
|
829
|
-
function
|
|
830
|
-
return
|
|
831
|
-
|
|
869
|
+
function ft(e, t) {
|
|
870
|
+
return j(m(E)), R(" Generate Vitepress config.", "info"), f(E, `export const config = ${JSON.stringify(e, null, 2)}\n\nexport default config\n`), R(" Generate index file.", "info"), f(T, "---\n" + y.stringify(t)), R(" Add Docpress theme files.", "info"), M(D).forEach((e) => {
|
|
871
|
+
Je(e, _(se, e.replace(`${D}/`, "")));
|
|
832
872
|
});
|
|
833
873
|
}
|
|
834
874
|
//#endregion
|
|
835
875
|
//#region src/commands/prepare.ts
|
|
836
|
-
var
|
|
837
|
-
n("-c, --extra-public-content <string>",
|
|
838
|
-
n("-f, --forks",
|
|
839
|
-
n("-p, --extra-header-pages <string>",
|
|
840
|
-
n("-t, --extra-theme <string>",
|
|
841
|
-
n("-v, --vitepress-config <string>",
|
|
842
|
-
n("--website-title <string>",
|
|
843
|
-
n("--website-tagline <string>",
|
|
844
|
-
],
|
|
845
|
-
await
|
|
876
|
+
var pt = "prepare", mt = [
|
|
877
|
+
n("-c, --extra-public-content <string>", B.shape.extraPublicContent.description),
|
|
878
|
+
n("-f, --forks", B.shape.forks.description),
|
|
879
|
+
n("-p, --extra-header-pages <string>", B.shape.extraHeaderPages.description),
|
|
880
|
+
n("-t, --extra-theme <string>", B.shape.extraTheme.description),
|
|
881
|
+
n("-v, --vitepress-config <string>", B.shape.vitepressConfig.description),
|
|
882
|
+
n("--website-title <string>", B.shape.websiteTitle.description),
|
|
883
|
+
n("--website-tagline <string>", B.shape.websiteTagline.description)
|
|
884
|
+
], ht = W(t(pt), [...mt, ...Q]).description("Transform doc to the target vitepress format.").action(async (e, t) => {
|
|
885
|
+
await gt(H(pt, U(t, e)));
|
|
846
886
|
});
|
|
847
|
-
async function
|
|
848
|
-
let { extraHeaderPages: t, extraPublicContent: n, extraTheme: r, vitepressConfig: i, forks: a, gitProvider: o,
|
|
849
|
-
|
|
850
|
-
for (let e of
|
|
887
|
+
async function gt(e) {
|
|
888
|
+
let { extraHeaderPages: t, extraPublicContent: n, extraTheme: r, vitepressConfig: i, forks: a, gitProvider: o, lastUpdated: s, token: c, usernames: l, websiteTitle: u, websiteTagline: d } = e;
|
|
889
|
+
R("\n-> Start transform files to prepare Vitepress build.", "info"), j(m(E), { clean: !0 });
|
|
890
|
+
for (let e of l) await Ze({
|
|
851
891
|
extraHeaderPages: t,
|
|
852
892
|
extraPublicContent: n,
|
|
853
893
|
extraTheme: r,
|
|
854
894
|
vitepressConfig: i,
|
|
855
895
|
forks: a,
|
|
856
896
|
gitProvider: o,
|
|
857
|
-
|
|
897
|
+
lastUpdated: s,
|
|
898
|
+
token: c,
|
|
858
899
|
username: e,
|
|
859
|
-
websiteTitle:
|
|
860
|
-
websiteTagline:
|
|
900
|
+
websiteTitle: u,
|
|
901
|
+
websiteTagline: d
|
|
861
902
|
});
|
|
862
903
|
}
|
|
863
904
|
//#endregion
|
|
864
905
|
//#region src/cli.ts
|
|
865
|
-
function
|
|
866
|
-
let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${
|
|
867
|
-
let n =
|
|
868
|
-
await
|
|
906
|
+
function _t() {
|
|
907
|
+
let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${ae.version}`).action(async (e, t) => {
|
|
908
|
+
let n = H("global", U(t, e));
|
|
909
|
+
await We(n), await gt(n), await qe();
|
|
869
910
|
}).configureHelp({
|
|
870
911
|
sortSubcommands: !0,
|
|
871
912
|
sortOptions: !0,
|
|
872
913
|
showGlobalOptions: !0
|
|
873
|
-
}).enablePositionalOptions().passThroughOptions().addCommand(
|
|
874
|
-
return
|
|
875
|
-
...
|
|
876
|
-
...
|
|
877
|
-
|
|
914
|
+
}).enablePositionalOptions().passThroughOptions().addCommand(Ue).addCommand(ht).addCommand(Ke);
|
|
915
|
+
return W(t, [
|
|
916
|
+
...He,
|
|
917
|
+
...mt,
|
|
918
|
+
...Q
|
|
878
919
|
]), t;
|
|
879
920
|
}
|
|
880
|
-
function
|
|
881
|
-
|
|
882
|
-
|
|
921
|
+
function vt() {
|
|
922
|
+
_t().parseAsync(process.argv).catch((e) => {
|
|
923
|
+
R(`\n${e instanceof Error ? e.message : String(e)}`, "error"), process.exit(1);
|
|
883
924
|
});
|
|
884
925
|
}
|
|
885
926
|
//#endregion
|
|
886
|
-
export {
|
|
927
|
+
export { _t as getProgram, vt as main };
|
|
887
928
|
|
|
888
929
|
//# sourceMappingURL=cli.js.map
|