@tobi-or-not/docpress 0.13.5 → 0.13.6
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 +237 -234
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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 h, parse as g,
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { z as
|
|
7
|
-
import { Octokit as
|
|
8
|
-
import { simpleGit as
|
|
9
|
-
import { build as
|
|
10
|
-
import { withMermaid as
|
|
11
|
-
import { readFile as
|
|
12
|
-
var
|
|
3
|
+
import { basename as p, dirname as m, join as h, parse as g, posix as _, relative as v, resolve as y, sep as b } from "node:path";
|
|
4
|
+
import x from "yaml";
|
|
5
|
+
import S from "picocolors";
|
|
6
|
+
import { z as C } from "zod";
|
|
7
|
+
import { Octokit as w } from "@octokit/rest";
|
|
8
|
+
import { simpleGit as ee } from "simple-git";
|
|
9
|
+
import { build as te } from "vitepress";
|
|
10
|
+
import { withMermaid as ne } from "vitepress-plugin-mermaid";
|
|
11
|
+
import { readFile as re } from "node:fs/promises";
|
|
12
|
+
var ie = {
|
|
13
13
|
name: "@tobi-or-not/docpress",
|
|
14
14
|
type: "module",
|
|
15
|
-
version: "0.13.
|
|
15
|
+
version: "0.13.6",
|
|
16
16
|
packageManager: "bun@1.4.4",
|
|
17
17
|
homepage: "https://this-is-tobi.com/docpress/introduction",
|
|
18
18
|
repository: {
|
|
@@ -89,14 +89,14 @@ var ne = {
|
|
|
89
89
|
nanoid: "^3.3.19",
|
|
90
90
|
postcss: "^8.5.28"
|
|
91
91
|
}
|
|
92
|
-
}, T =
|
|
93
|
-
red:
|
|
94
|
-
yellow:
|
|
95
|
-
white:
|
|
96
|
-
green:
|
|
97
|
-
blue:
|
|
92
|
+
}, T = y(process.cwd(), "docpress"), ae = y(process.cwd(), "docpress/docs"), E = y(process.cwd(), "docpress/docs/index.md"), oe = y(process.cwd(), "docpress/docs/forks.md"), D = y(process.cwd(), "docpress/.vitepress/config.ts"), se = y(process.cwd(), "docpress/.vitepress/theme"), ce = y(process.cwd(), "docpress/.vitepress/theme/extras"), O = process.env.NODE_ENV === "development" ? y(import.meta.dirname, "../../public/templates/theme") : y(import.meta.dirname, "./templates/theme"), le = {
|
|
93
|
+
red: S.red,
|
|
94
|
+
yellow: S.yellow,
|
|
95
|
+
white: S.white,
|
|
96
|
+
green: S.green,
|
|
97
|
+
blue: S.blue
|
|
98
98
|
};
|
|
99
|
-
function
|
|
99
|
+
function ue() {
|
|
100
100
|
let e = Number(process.env.LOG_LEVEL);
|
|
101
101
|
return Number.isNaN(e) ? 30 : e;
|
|
102
102
|
}
|
|
@@ -132,16 +132,16 @@ var k = {
|
|
|
132
132
|
"trace",
|
|
133
133
|
"debug"
|
|
134
134
|
];
|
|
135
|
-
function
|
|
135
|
+
function de(e) {
|
|
136
136
|
return k[e].level;
|
|
137
137
|
}
|
|
138
138
|
function j(e, t = "info", n) {
|
|
139
|
-
let r = n ?
|
|
140
|
-
|
|
139
|
+
let r = n ? le[n](e) : le[k[t].color](e), i = t === "success" ? "info" : t;
|
|
140
|
+
ue() >= k[t].level && console[i](r);
|
|
141
141
|
}
|
|
142
142
|
//#endregion
|
|
143
143
|
//#region src/utils/regex.ts
|
|
144
|
-
var
|
|
144
|
+
var fe = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, pe = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, me = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, he = /^\d{2}-/, ge = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/, _e = /\[([^\]]+)\]\((?!https?:|\/|#|mailto:)([^)#]*\/)?([^)#/]+\.md)(#[^)]*)?\)/g;
|
|
145
145
|
//#endregion
|
|
146
146
|
//#region src/utils/functions.ts
|
|
147
147
|
async function M(e) {
|
|
@@ -157,7 +157,7 @@ async function M(e) {
|
|
|
157
157
|
function N(e) {
|
|
158
158
|
return (e.split(/[/\\]/).pop() ?? "").replace(/[^\w.-]/g, "_").replace(/^\.+/, "") || "_";
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function ve(e) {
|
|
161
161
|
return !H(e) || !("token" in e) ? e : {
|
|
162
162
|
...e,
|
|
163
163
|
token: e.token ? "***" : e.token
|
|
@@ -173,17 +173,17 @@ function F(e) {
|
|
|
173
173
|
let n = Math.floor(t / 60), r = Math.round(t % 60);
|
|
174
174
|
return `${n}m ${String(r).padStart(2, "0")}s`;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function ye(e, t) {
|
|
177
177
|
let n = new Map(t.map((e) => [e.toLowerCase(), e]));
|
|
178
178
|
return e.split(" ").map((e) => n.get(e.toLowerCase()) ?? e).join(" ");
|
|
179
179
|
}
|
|
180
180
|
function I(e, t) {
|
|
181
181
|
let n = "";
|
|
182
|
-
return t?.removeDot && (n = e.startsWith(".") ? e.slice(1) : e, n = n.replaceAll(".", "-")), t?.removeIdx && (n = (n || e).replace(
|
|
182
|
+
return t?.removeDot && (n = e.startsWith(".") ? e.slice(1) : e, n = n.replaceAll(".", "-")), t?.removeIdx && (n = (n || e).replace(he, "")), 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()), t?.acronyms?.length && (n = ye(n || e, t.acronyms)), n || e;
|
|
183
183
|
}
|
|
184
184
|
function L(e, { clean: t } = { clean: !1 }) {
|
|
185
185
|
try {
|
|
186
|
-
if (t && a(e)) for (let t of c(e)) u(
|
|
186
|
+
if (t && a(e)) for (let t of c(e)) u(y(e, t), {
|
|
187
187
|
recursive: !0,
|
|
188
188
|
force: !0
|
|
189
189
|
});
|
|
@@ -192,14 +192,14 @@ function L(e, { clean: t } = { clean: !1 }) {
|
|
|
192
192
|
throw Error(`Unable to create directory '${e}': ${t instanceof Error ? t.message : String(t)}`);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function be(e) {
|
|
196
196
|
try {
|
|
197
197
|
return d(e).isDirectory();
|
|
198
198
|
} catch {
|
|
199
199
|
return !1;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function xe(e) {
|
|
203
203
|
try {
|
|
204
204
|
return d(e).isFile();
|
|
205
205
|
} catch {
|
|
@@ -207,7 +207,7 @@ function ye(e) {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
function R(e) {
|
|
210
|
-
return (Array.isArray(e) ? e : [e]).flatMap((e) =>
|
|
210
|
+
return (Array.isArray(e) ? e : [e]).flatMap((e) => xe(e) ? [e] : be(e) ? c(e).filter((e) => e !== ".git").sort().flatMap((t) => R(h(e, t))) : []);
|
|
211
211
|
}
|
|
212
212
|
function z(e) {
|
|
213
213
|
return R(e).filter((e) => p(e).endsWith(".md"));
|
|
@@ -215,20 +215,20 @@ function z(e) {
|
|
|
215
215
|
function B(e) {
|
|
216
216
|
return e.reduce((e, t, n, r) => n ? n === r.length - 1 ? `${e} or "${t}"` : `${e}, "${t}"` : `"${t}"`, "");
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function Se(e) {
|
|
219
219
|
return JSON.parse(s(`${T}/user-${N(e)}.json`).toString());
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function Ce(e) {
|
|
222
222
|
return JSON.parse(s(`${T}/repos-${N(e)}.json`).toString());
|
|
223
223
|
}
|
|
224
|
-
var
|
|
224
|
+
var we = /* @__PURE__ */ new Set([
|
|
225
225
|
"__proto__",
|
|
226
226
|
"constructor",
|
|
227
227
|
"prototype"
|
|
228
228
|
]);
|
|
229
229
|
function V(...e) {
|
|
230
230
|
return e.reduce((e, t) => (t === null || Object.keys(t).forEach((n) => {
|
|
231
|
-
if (
|
|
231
|
+
if (we.has(n)) return;
|
|
232
232
|
let r = e ? e[n] : null, i = t[n];
|
|
233
233
|
e[n] = H(r) && H(i) ? V(r, i) : H(i) ? V({}, i) : i;
|
|
234
234
|
}), e), {});
|
|
@@ -236,9 +236,9 @@ function V(...e) {
|
|
|
236
236
|
function H(e) {
|
|
237
237
|
return e && typeof e == "object" && !Array.isArray(e);
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function Te(e) {
|
|
240
240
|
if (!e) return {};
|
|
241
|
-
let t =
|
|
241
|
+
let t = y(process.cwd(), e), n;
|
|
242
242
|
try {
|
|
243
243
|
n = s(t, "utf8");
|
|
244
244
|
} catch {
|
|
@@ -253,76 +253,79 @@ function Ce(e) {
|
|
|
253
253
|
function U(e) {
|
|
254
254
|
return e.split(",");
|
|
255
255
|
}
|
|
256
|
-
function
|
|
257
|
-
let n = s(e, "utf8").replace(
|
|
258
|
-
|
|
256
|
+
function Ee(e, t, n = m(e)) {
|
|
257
|
+
let r = _.join("docs", v(n, m(e)).split(b).join("/")), i = s(e, "utf8").replace(fe, (e, n, i) => {
|
|
258
|
+
let a = _.join(r, "..", i);
|
|
259
|
+
return a.startsWith("docs/") ? `[${n}](${_.relative(r, a)})` : `[${n}](${t}/${a})`;
|
|
260
|
+
});
|
|
261
|
+
f(e, i, "utf8");
|
|
259
262
|
}
|
|
260
|
-
function
|
|
261
|
-
let n = s(e, "utf8"), r = n.match(
|
|
263
|
+
function De(e, t) {
|
|
264
|
+
let n = s(e, "utf8"), r = n.match(ge);
|
|
262
265
|
if (r) {
|
|
263
|
-
let i =
|
|
264
|
-
i.lastUpdated = t, f(e, n.replace(
|
|
266
|
+
let i = x.parse(r[1]) ?? {};
|
|
267
|
+
i.lastUpdated = t, f(e, n.replace(ge, `---\n${x.stringify(i)}---\n`), "utf8");
|
|
265
268
|
} else f(e, `---\nlastUpdated: ${t}\n---\n\n${n}`, "utf8");
|
|
266
269
|
}
|
|
267
|
-
function
|
|
270
|
+
function Oe(e) {
|
|
268
271
|
return e ? e.split("/").map((e) => e === "" || e === "." || e === ".." ? e : I(e, { removeIdx: !0 })).join("/") : "";
|
|
269
272
|
}
|
|
270
|
-
function
|
|
271
|
-
let t = s(e, "utf8").replace(
|
|
273
|
+
function ke(e) {
|
|
274
|
+
let t = s(e, "utf8").replace(_e, (e, t, n, r, i) => {
|
|
272
275
|
let a = I(r, {
|
|
273
276
|
mode: "lowercase",
|
|
274
277
|
removeIdx: !0
|
|
275
278
|
});
|
|
276
|
-
return a === "readme.md" && (a = "introduction.md"), `[${t}](${
|
|
279
|
+
return a === "readme.md" && (a = "introduction.md"), `[${t}](${Oe(n)}${a}${i ?? ""})`;
|
|
277
280
|
});
|
|
278
281
|
f(e, t, "utf8");
|
|
279
282
|
}
|
|
280
|
-
function
|
|
281
|
-
let n = s(e, "utf8").replace(
|
|
283
|
+
function Ae(e, t) {
|
|
284
|
+
let n = s(e, "utf8").replace(pe, (e, n, r, i) => `[${n}](${t}/${i})`).replace(me, (e, t, n, r) => `[${t}](${r})`);
|
|
282
285
|
f(e, n, "utf8");
|
|
283
286
|
}
|
|
284
287
|
//#endregion
|
|
285
288
|
//#region src/schemas/global.ts
|
|
286
|
-
var W = ["github", "gitlab"], G = ["single", "multi"],
|
|
289
|
+
var W = ["github", "gitlab"], G = ["single", "multi"], je = [
|
|
287
290
|
"true",
|
|
288
291
|
"false",
|
|
289
292
|
"null"
|
|
290
|
-
],
|
|
291
|
-
usernames:
|
|
292
|
-
logLevel:
|
|
293
|
-
branch:
|
|
294
|
-
gitProvider:
|
|
295
|
-
reposFilter:
|
|
296
|
-
extraHeaderPages:
|
|
297
|
-
extraPublicContent:
|
|
298
|
-
extraTheme:
|
|
299
|
-
forks:
|
|
300
|
-
lastUpdated:
|
|
301
|
-
sidebarMode:
|
|
302
|
-
sidebarCollapsed:
|
|
303
|
-
acronyms:
|
|
304
|
-
vitepressConfig:
|
|
305
|
-
websiteTitle:
|
|
306
|
-
websiteTagline:
|
|
293
|
+
], Me = /^\w[\w./-]*$/, Ne = "Branch name must start with a letter, digit or underscore and only contain letters, digits, \".\", \"-\", \"_\" or \"/\".", K = C.object({
|
|
294
|
+
usernames: C.string().array().describe("List of comma separated Git provider usernames used to collect data."),
|
|
295
|
+
logLevel: C.enum(A).optional().describe(`Verbosity of the CLI output. Values should be ${B(A)}. Defaults to "info", or to the LOG_LEVEL environment variable when set.`),
|
|
296
|
+
branch: C.string().regex(Me, Ne).optional().describe("Branch used to collect Git provider data. Defaults to each repository's own default branch when not set."),
|
|
297
|
+
gitProvider: C.enum(W).default("github").describe(`Git provider used to retrieve data. Values should be ${B(W)}.`),
|
|
298
|
+
reposFilter: C.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
|
|
299
|
+
extraHeaderPages: C.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
300
|
+
extraPublicContent: C.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
|
|
301
|
+
extraTheme: C.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
|
|
302
|
+
forks: C.boolean().default(!1).describe("Whether or not to create the dedicated fork page that aggregate external contributions."),
|
|
303
|
+
lastUpdated: C.boolean().default(!1).describe("Whether or not to inject each page's last Git commit date as Vitepress \"lastUpdated\" frontmatter."),
|
|
304
|
+
sidebarMode: C.enum(G).default("single").describe(`Shape of the generated sidebar. Values should be ${B(G)}. "single" lists every repository in one sidebar, "multi" gives each repository its own sidebar.`),
|
|
305
|
+
sidebarCollapsed: C.union([C.boolean(), C.null()]).default(!0).describe("Collapse behaviour of generated sidebar groups. \"true\" collapses them by default, \"false\" expands them, \"null\" makes them non-collapsible."),
|
|
306
|
+
acronyms: C.string().regex(/^[^\s-]+$/, "Each acronym must be a single word, with no space or dash, as it is matched against one word of a label.").array().describe("List of comma separated words kept exactly as written in generated sidebar labels and home page titles, such as \"CLI\" or \"API\", matched whole and ignoring case."),
|
|
307
|
+
vitepressConfig: C.any().optional().describe("Path to the vitepress configuration file."),
|
|
308
|
+
websiteTitle: C.string().describe("Website title."),
|
|
309
|
+
websiteTagline: C.string().describe("Website tagline.")
|
|
307
310
|
}), q = K.partial().extend({
|
|
308
|
-
branch:
|
|
309
|
-
gitProvider:
|
|
310
|
-
logLevel:
|
|
311
|
-
forks:
|
|
312
|
-
lastUpdated:
|
|
313
|
-
config:
|
|
314
|
-
token:
|
|
315
|
-
usernames:
|
|
316
|
-
reposFilter:
|
|
317
|
-
extraHeaderPages:
|
|
318
|
-
extraPublicContent:
|
|
319
|
-
extraTheme:
|
|
320
|
-
vitepressConfig:
|
|
321
|
-
sidebarMode:
|
|
322
|
-
sidebarCollapsed:
|
|
323
|
-
acronyms:
|
|
311
|
+
branch: C.string().regex(Me, Ne).optional().describe(K.shape.branch.description || ""),
|
|
312
|
+
gitProvider: C.enum(W).optional().describe(K.shape.gitProvider.description || ""),
|
|
313
|
+
logLevel: C.enum(A).optional().describe(K.shape.logLevel.description || ""),
|
|
314
|
+
forks: C.boolean().optional().describe(K.shape.forks.description || ""),
|
|
315
|
+
lastUpdated: C.boolean().optional().describe(K.shape.lastUpdated.description || ""),
|
|
316
|
+
config: C.string().optional().describe("Path to the docpress configuration file."),
|
|
317
|
+
token: C.string().optional().describe("Git provider token used to collect data."),
|
|
318
|
+
usernames: C.string().transform(U).optional().describe(K.shape.usernames.description || ""),
|
|
319
|
+
reposFilter: C.string().transform(U).optional().describe(K.shape.reposFilter.description || ""),
|
|
320
|
+
extraHeaderPages: C.string().transform(U).optional().describe(K.shape.extraHeaderPages.description || ""),
|
|
321
|
+
extraPublicContent: C.string().transform(U).optional().describe(K.shape.extraPublicContent.description || ""),
|
|
322
|
+
extraTheme: C.string().transform(U).optional().describe(K.shape.extraTheme.description || ""),
|
|
323
|
+
vitepressConfig: C.string().optional().describe(K.shape.vitepressConfig.description || ""),
|
|
324
|
+
sidebarMode: C.enum(G).optional().describe(K.shape.sidebarMode.description || ""),
|
|
325
|
+
sidebarCollapsed: C.enum(je).transform((e) => e === "null" ? null : e === "true").optional().describe(`${K.shape.sidebarCollapsed.description} Values should be ${B(je)}.`),
|
|
326
|
+
acronyms: C.string().transform(U).pipe(K.shape.acronyms).optional().describe(K.shape.acronyms.description || "")
|
|
324
327
|
});
|
|
325
|
-
function
|
|
328
|
+
function Pe(e) {
|
|
326
329
|
if (!e) return {};
|
|
327
330
|
let t = { ...e };
|
|
328
331
|
for (let e of [
|
|
@@ -335,26 +338,26 @@ function Me(e) {
|
|
|
335
338
|
]) typeof t[e] == "string" && (t[e] = [t[e]]);
|
|
336
339
|
return t;
|
|
337
340
|
}
|
|
338
|
-
function
|
|
341
|
+
function Fe(e) {
|
|
339
342
|
let t = K.partial().safeParse(e);
|
|
340
343
|
if (!t.success) throw t.error;
|
|
341
344
|
return t.data;
|
|
342
345
|
}
|
|
343
|
-
function
|
|
346
|
+
function Ie(e) {
|
|
344
347
|
if (!e.usernames?.length) throw Error("The usernames field is required");
|
|
345
348
|
return e;
|
|
346
349
|
}
|
|
347
|
-
function
|
|
350
|
+
function Le(e, t) {
|
|
348
351
|
if (e) return e;
|
|
349
352
|
let n = t === "gitlab" ? process.env.GITLAB_TOKEN : process.env.GITHUB_TOKEN;
|
|
350
353
|
return process.env.DOCPRESS_TOKEN || n || void 0;
|
|
351
354
|
}
|
|
352
|
-
function
|
|
353
|
-
e && (process.env.LOG_LEVEL = String(
|
|
355
|
+
function Re(e) {
|
|
356
|
+
e && (process.env.LOG_LEVEL = String(de(e)));
|
|
354
357
|
}
|
|
355
|
-
var
|
|
358
|
+
var ze = q.partial().transform((e, t) => {
|
|
356
359
|
try {
|
|
357
|
-
let { config: t, vitepressConfig: n, token: r, ...i } = e, a =
|
|
360
|
+
let { config: t, vitepressConfig: n, token: r, ...i } = e, a = Fe(Pe(Te(t))), o = {
|
|
358
361
|
gitProvider: "github",
|
|
359
362
|
forks: !1,
|
|
360
363
|
lastUpdated: !1,
|
|
@@ -364,34 +367,34 @@ var Le = q.partial().transform((e, t) => {
|
|
|
364
367
|
...i,
|
|
365
368
|
...n ? { vitepressConfig: {
|
|
366
369
|
...a.vitepressConfig || {},
|
|
367
|
-
...
|
|
370
|
+
...Te(n) || {}
|
|
368
371
|
} } : {}
|
|
369
372
|
};
|
|
370
|
-
return
|
|
373
|
+
return Re(o.logLevel), Ie({
|
|
371
374
|
...o,
|
|
372
|
-
token:
|
|
375
|
+
token: Le(r, o.gitProvider)
|
|
373
376
|
});
|
|
374
377
|
} catch (e) {
|
|
375
|
-
if (e instanceof
|
|
378
|
+
if (e instanceof C.ZodError) {
|
|
376
379
|
for (let n of e.issues) t.addIssue({
|
|
377
380
|
code: "custom",
|
|
378
381
|
message: n.message,
|
|
379
382
|
path: n.path
|
|
380
383
|
});
|
|
381
|
-
return
|
|
384
|
+
return C.NEVER;
|
|
382
385
|
}
|
|
383
386
|
return t.addIssue({
|
|
384
387
|
code: "custom",
|
|
385
388
|
message: e instanceof Error ? e.message : JSON.stringify(e, null, 2)
|
|
386
|
-
}),
|
|
389
|
+
}), C.NEVER;
|
|
387
390
|
}
|
|
388
391
|
});
|
|
389
392
|
//#endregion
|
|
390
393
|
//#region src/utils/commands.ts
|
|
391
394
|
function J(e, t) {
|
|
392
395
|
j("Initializing Docpress...", "info", "blue"), j("\n\n-> Checking for required environment settings and configurations.", "info"), j(` Debug info - cmd: ${e}`, "debug");
|
|
393
|
-
let n =
|
|
394
|
-
return n.success || (j(` An error occurred while checking configuration.\n ${
|
|
396
|
+
let n = ze.safeParse(t);
|
|
397
|
+
return n.success || (j(` An error occurred while checking configuration.\n ${C.prettifyError(n.error)}`, "error"), process.exit(1)), j(` Debug info - resolved options: ${JSON.stringify(ve(n.data))}`, "debug"), j(" Setup complete! Ready to process your documentation.", "info"), n.data;
|
|
395
398
|
}
|
|
396
399
|
function Y(e, t) {
|
|
397
400
|
return Object.fromEntries(Object.entries(t).filter(([t]) => e.getOptionValueSource(t) !== "default"));
|
|
@@ -402,7 +405,7 @@ function X(e, t) {
|
|
|
402
405
|
}
|
|
403
406
|
//#endregion
|
|
404
407
|
//#region src/lib/git.ts
|
|
405
|
-
var
|
|
408
|
+
var Be = {
|
|
406
409
|
debug: () => {},
|
|
407
410
|
info: () => {},
|
|
408
411
|
warn: (e) => {
|
|
@@ -412,11 +415,11 @@ var Re = {
|
|
|
412
415
|
e.includes("404") || j(e, "error");
|
|
413
416
|
}
|
|
414
417
|
};
|
|
415
|
-
async function
|
|
418
|
+
async function Ve({ username: e, token: t, branch: n }) {
|
|
416
419
|
j(` Get infos for username '${e}'.`, "info");
|
|
417
|
-
let r = new
|
|
420
|
+
let r = new w({
|
|
418
421
|
auth: t,
|
|
419
|
-
log:
|
|
422
|
+
log: Be
|
|
420
423
|
});
|
|
421
424
|
j(" Get user infos.", "debug");
|
|
422
425
|
let { data: i } = await r.rest.users.getByUsername({ username: e }).catch((t) => {
|
|
@@ -432,11 +435,11 @@ async function ze({ username: e, token: t, branch: n }) {
|
|
|
432
435
|
branch: n
|
|
433
436
|
};
|
|
434
437
|
}
|
|
435
|
-
async function
|
|
438
|
+
async function He({ repository: e, token: t }) {
|
|
436
439
|
j(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
437
|
-
let n = new
|
|
440
|
+
let n = new w({
|
|
438
441
|
auth: t,
|
|
439
|
-
log:
|
|
442
|
+
log: Be
|
|
440
443
|
}), r;
|
|
441
444
|
try {
|
|
442
445
|
r = (await n.rest.repos.get({
|
|
@@ -471,7 +474,7 @@ async function Be({ repository: e, token: t }) {
|
|
|
471
474
|
contributors: i
|
|
472
475
|
};
|
|
473
476
|
}
|
|
474
|
-
function
|
|
477
|
+
function Ue(e) {
|
|
475
478
|
let t = /* @__PURE__ */ new Map(), n = null;
|
|
476
479
|
for (let r of e.split("\n")) {
|
|
477
480
|
let e = r.trim();
|
|
@@ -485,12 +488,12 @@ function Ve(e) {
|
|
|
485
488
|
}
|
|
486
489
|
return t;
|
|
487
490
|
}
|
|
488
|
-
async function
|
|
491
|
+
async function We(e, t, n) {
|
|
489
492
|
let r = z([t]);
|
|
490
493
|
if (!r.length) return;
|
|
491
494
|
let i;
|
|
492
495
|
try {
|
|
493
|
-
i =
|
|
496
|
+
i = Ue(await e.raw([
|
|
494
497
|
"-c",
|
|
495
498
|
"core.quotePath=false",
|
|
496
499
|
"log",
|
|
@@ -502,15 +505,15 @@ async function He(e, t, n) {
|
|
|
502
505
|
return;
|
|
503
506
|
}
|
|
504
507
|
for (let e of r) {
|
|
505
|
-
let n = i.get(
|
|
506
|
-
n &&
|
|
508
|
+
let n = i.get(v(t, e));
|
|
509
|
+
n && De(e, n);
|
|
507
510
|
}
|
|
508
511
|
}
|
|
509
|
-
async function
|
|
512
|
+
async function Ge(e, t, n, a, o, s) {
|
|
510
513
|
if (t.startsWith("-") || a.startsWith("-")) return j(` Refusing to clone '${e}': unsafe repository URL or branch name.`, "error"), !1;
|
|
511
514
|
L(n, { clean: !0 });
|
|
512
515
|
try {
|
|
513
|
-
let c =
|
|
516
|
+
let c = ee({
|
|
514
517
|
baseDir: n,
|
|
515
518
|
config: [
|
|
516
519
|
"maintenance.auto=false",
|
|
@@ -519,24 +522,24 @@ async function Ue(e, t, n, a, o, s) {
|
|
|
519
522
|
]
|
|
520
523
|
});
|
|
521
524
|
await c.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
|
|
522
|
-
for (let t of o) j(` Add '${t}' to '${e}' sparse-checkout file.`, "debug"), r(
|
|
523
|
-
return j(` Clone repository '${e}'.`, "info"), await c.pull("origin", a), s && await
|
|
525
|
+
for (let t of o) j(` Add '${t}' to '${e}' sparse-checkout file.`, "debug"), r(y(n, ".git/info/sparse-checkout"), `${t}\n`, "utf8");
|
|
526
|
+
return j(` Clone repository '${e}'.`, "info"), await c.pull("origin", a), s && await We(c, n, e), o.some((e) => e.includes("docs")) && (i(y(n, "docs"), n, { recursive: !0 }), u(y(n, "docs"), { recursive: !0 })), u(y(n, ".git"), { recursive: !0 }), !0;
|
|
524
527
|
} catch (t) {
|
|
525
528
|
return j(` Error when cloning repository '${e}': ${P(t)}.`, "error"), !1;
|
|
526
529
|
}
|
|
527
530
|
}
|
|
528
531
|
//#endregion
|
|
529
532
|
//#region src/lib/gitlab.ts
|
|
530
|
-
var
|
|
533
|
+
var Ke = "https://gitlab.com/api/v4";
|
|
531
534
|
async function Z(e, t) {
|
|
532
|
-
let n = await fetch(`${
|
|
535
|
+
let n = await fetch(`${Ke}${e}`, { headers: t ? { "PRIVATE-TOKEN": t } : {} });
|
|
533
536
|
if (!n.ok) throw Error(`GitLab API request failed for '${e}' (status: ${n.status}).`);
|
|
534
537
|
return {
|
|
535
538
|
data: await n.json(),
|
|
536
539
|
headers: n.headers
|
|
537
540
|
};
|
|
538
541
|
}
|
|
539
|
-
async function
|
|
542
|
+
async function qe(e, t) {
|
|
540
543
|
let n = e.includes("?") ? "&" : "?", r = [], i = "1";
|
|
541
544
|
for (; i;) {
|
|
542
545
|
let a = await Z(`${e}${n}per_page=100&page=${i}`, t);
|
|
@@ -544,7 +547,7 @@ async function Ge(e, t) {
|
|
|
544
547
|
}
|
|
545
548
|
return r;
|
|
546
549
|
}
|
|
547
|
-
function
|
|
550
|
+
function Je(e) {
|
|
548
551
|
return {
|
|
549
552
|
login: e.username ?? e.path,
|
|
550
553
|
name: e.name,
|
|
@@ -553,7 +556,7 @@ function Ke(e) {
|
|
|
553
556
|
html_url: e.web_url
|
|
554
557
|
};
|
|
555
558
|
}
|
|
556
|
-
function
|
|
559
|
+
function Ye(e, t) {
|
|
557
560
|
return {
|
|
558
561
|
name: e.path,
|
|
559
562
|
owner: { login: t },
|
|
@@ -567,32 +570,32 @@ function qe(e, t) {
|
|
|
567
570
|
stargazers_count: e.star_count
|
|
568
571
|
};
|
|
569
572
|
}
|
|
570
|
-
async function
|
|
573
|
+
async function Xe({ username: e, token: t, branch: n }) {
|
|
571
574
|
j(` Get infos for username '${e}'.`, "info");
|
|
572
575
|
let { data: r } = await Z(`/users?username=${encodeURIComponent(e)}`, t);
|
|
573
576
|
if (r.length) {
|
|
574
577
|
let i = r[0];
|
|
575
578
|
t && (i = await Z(`/users/${r[0].id}`, t).then((e) => e.data).catch(() => r[0])), j(" Get repositories infos.", "debug");
|
|
576
|
-
let a = await
|
|
579
|
+
let a = await qe(`/users/${r[0].id}/projects`, t);
|
|
577
580
|
return {
|
|
578
|
-
user:
|
|
579
|
-
repos: a.map((t) =>
|
|
581
|
+
user: Je(i),
|
|
582
|
+
repos: a.map((t) => Ye(t, i.username ?? e)),
|
|
580
583
|
branch: n
|
|
581
584
|
};
|
|
582
585
|
}
|
|
583
586
|
j(` No GitLab user '${e}' found, trying groups.`, "debug");
|
|
584
587
|
let i = await Z(`/groups/${encodeURIComponent(e)}?with_projects=false`, t).then((e) => e.data).catch(() => {
|
|
585
588
|
throw Error(`No GitLab user or group found for '${e}'.`);
|
|
586
|
-
}), a = await
|
|
589
|
+
}), a = await qe(`/groups/${encodeURIComponent(e)}/projects`, t);
|
|
587
590
|
return {
|
|
588
|
-
user:
|
|
589
|
-
repos: a.map((t) =>
|
|
591
|
+
user: Je(i),
|
|
592
|
+
repos: a.map((t) => Ye(t, i.path ?? e)),
|
|
590
593
|
branch: n
|
|
591
594
|
};
|
|
592
595
|
}
|
|
593
596
|
//#endregion
|
|
594
597
|
//#region src/lib/fetch.ts
|
|
595
|
-
function
|
|
598
|
+
function Ze(e, t, n) {
|
|
596
599
|
if (n === "gitlab") {
|
|
597
600
|
let n = e.html_url ?? `https://gitlab.com/${e.owner.login}/${e.name}`;
|
|
598
601
|
return {
|
|
@@ -608,7 +611,7 @@ function Ye(e, t, n) {
|
|
|
608
611
|
raw_url: `https://raw.githubusercontent.com/${e.owner.login}/${e.name}/${t}`
|
|
609
612
|
};
|
|
610
613
|
}
|
|
611
|
-
async function
|
|
614
|
+
async function Qe(e) {
|
|
612
615
|
let [t, n, r] = await Promise.all([
|
|
613
616
|
M(`${e.blob_url}/README.md`),
|
|
614
617
|
M(`${e.tree_url}/docs`),
|
|
@@ -620,19 +623,19 @@ async function Xe(e) {
|
|
|
620
623
|
docsReadmeStatus: r
|
|
621
624
|
};
|
|
622
625
|
}
|
|
623
|
-
async function
|
|
624
|
-
let { user: s, repos: c, branch: l } = await (r === "gitlab" ?
|
|
626
|
+
async function $e({ username: e, branch: t, reposFilter: n, gitProvider: r, token: i, lastUpdated: a, multiUser: o }) {
|
|
627
|
+
let { user: s, repos: c, branch: l } = await (r === "gitlab" ? Xe : Ve)({
|
|
625
628
|
username: e,
|
|
626
629
|
token: i,
|
|
627
630
|
branch: t
|
|
628
|
-
}), { repos: u } = await
|
|
629
|
-
await
|
|
631
|
+
}), { repos: u } = await nt(s, c, l, n, r, o ? `${N(e)}/` : "");
|
|
632
|
+
await rt(u, n, a);
|
|
630
633
|
}
|
|
631
|
-
async function
|
|
634
|
+
async function et(e, t, n, r, i = "") {
|
|
632
635
|
let a = [];
|
|
633
636
|
return await Promise.all(e.map(async (e) => {
|
|
634
|
-
let o = t ?? e.default_branch ?? "main", s =
|
|
635
|
-
!e.fork && !e.private && !c && (u = await
|
|
637
|
+
let o = t ?? e.default_branch ?? "main", s = y(ae, `${i}${I(N(e.name), { removeDot: !0 })}`), c = it(e, n), l = Ze(e, o, r), u = [];
|
|
638
|
+
!e.fork && !e.private && !c && (u = await tt(e, o, r, l)), a.push({
|
|
636
639
|
...e,
|
|
637
640
|
docpress: {
|
|
638
641
|
filtered: c,
|
|
@@ -646,25 +649,25 @@ async function Qe(e, t, n, r, i = "") {
|
|
|
646
649
|
});
|
|
647
650
|
})), a;
|
|
648
651
|
}
|
|
649
|
-
async function
|
|
650
|
-
let i = await
|
|
652
|
+
async function tt(e, t, n, r) {
|
|
653
|
+
let i = await Qe(r ?? Ze(e, t, n)), a = [];
|
|
651
654
|
return Object.values(i).every((e) => e !== 200) || !e.size ? [] : (i.docsFolderStatus === 200 && a.push("docs/*"), (i.docsFolderStatus !== 200 || i.docsReadmeStatus !== 200) && a.push("README.md", "!*/**/README.md"), a);
|
|
652
655
|
}
|
|
653
|
-
async function
|
|
656
|
+
async function nt(e, t, n, r, i, a = "") {
|
|
654
657
|
f(`${T}/user-${N(e.login)}.json`, JSON.stringify(e, null, 2));
|
|
655
|
-
let o = await
|
|
658
|
+
let o = await et(t, n, r, i, a);
|
|
656
659
|
return f(`${T}/repos-${N(e.login)}.json`, JSON.stringify(o, null, 2)), {
|
|
657
660
|
user: e,
|
|
658
661
|
repos: o
|
|
659
662
|
};
|
|
660
663
|
}
|
|
661
|
-
async function
|
|
664
|
+
async function rt(e, t, n) {
|
|
662
665
|
if (!e) {
|
|
663
666
|
j(" No repositories to process.", "warn");
|
|
664
667
|
return;
|
|
665
668
|
}
|
|
666
|
-
let r = await Promise.all(e.filter((e) => !
|
|
667
|
-
let t = await
|
|
669
|
+
let r = await Promise.all(e.filter((e) => !it(e, t)).map(async (e) => {
|
|
670
|
+
let t = await Ge(e.name, e.clone_url, e.docpress.projectPath, e.docpress.branch, e.docpress.includes, n);
|
|
668
671
|
return {
|
|
669
672
|
name: e.name,
|
|
670
673
|
success: t
|
|
@@ -677,7 +680,7 @@ async function tt(e, t, n) {
|
|
|
677
680
|
let i = r.filter(({ success: e }) => !e).map(({ name: e }) => e), a = r.length - i.length;
|
|
678
681
|
i.length ? j(` Cloned ${a}/${r.length} repository(ies), ${i.length} failed: ${i.join(", ")}.`, "warn") : j(` Cloned ${a}/${r.length} repository(ies).`, "success");
|
|
679
682
|
}
|
|
680
|
-
function
|
|
683
|
+
function it(e, t) {
|
|
681
684
|
if ("docpress" in e && !e.docpress.includes.length) return !0;
|
|
682
685
|
let n = t?.filter((e) => !e.startsWith("!")) ?? [], r = t?.every((e) => e.startsWith("!")), i = t?.filter((e) => e.startsWith("!")).some((t) => e.name === t.substring(1)), a = !t || n.includes(e.name) || e.fork && !i || r && !i, o = i || !a;
|
|
683
686
|
return !(e.clone_url && !e.private && !o);
|
|
@@ -689,15 +692,15 @@ var Q = [
|
|
|
689
692
|
n("--log-level <string>", q.shape.logLevel.description),
|
|
690
693
|
n("-T, --token <string>", q.shape.token.description),
|
|
691
694
|
n("-U, --usernames <string>", q.shape.usernames.description)
|
|
692
|
-
],
|
|
695
|
+
], at = "fetch", ot = [
|
|
693
696
|
n("-b, --branch <string>", K.shape.branch.description),
|
|
694
697
|
n("-g, --git-provider <string>", K.shape.gitProvider.description).default(K.shape.gitProvider.def.defaultValue),
|
|
695
698
|
n("-l, --last-updated", K.shape.lastUpdated.description),
|
|
696
699
|
n("-r, --repos-filter <string>", K.shape.reposFilter.description)
|
|
697
|
-
],
|
|
698
|
-
await
|
|
700
|
+
], st = X(t(at), [...ot, ...Q]).description("Fetch docs with the given username(s) and git provider.").action(async (e, t) => {
|
|
701
|
+
await ct(J(at, Y(t, e)));
|
|
699
702
|
});
|
|
700
|
-
async function
|
|
703
|
+
async function ct(e) {
|
|
701
704
|
let { usernames: t, reposFilter: n, token: r, branch: i, gitProvider: a, lastUpdated: o } = e;
|
|
702
705
|
j("\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.", "info");
|
|
703
706
|
let s = Date.now();
|
|
@@ -706,7 +709,7 @@ async function ot(e) {
|
|
|
706
709
|
for (let e of t) {
|
|
707
710
|
let s = t.length > 1 ? n?.filter((t) => t.replace(/^!/, "").startsWith(`${e}/`)).map((t) => t.replace(`${e}/`, "")) : n;
|
|
708
711
|
try {
|
|
709
|
-
await
|
|
712
|
+
await $e({
|
|
710
713
|
username: e,
|
|
711
714
|
branch: i,
|
|
712
715
|
reposFilter: s,
|
|
@@ -724,7 +727,7 @@ async function ot(e) {
|
|
|
724
727
|
}
|
|
725
728
|
//#endregion
|
|
726
729
|
//#region src/commands/build.ts
|
|
727
|
-
async function
|
|
730
|
+
async function lt(e) {
|
|
728
731
|
let t = console.warn;
|
|
729
732
|
console.warn = function(...e) {
|
|
730
733
|
e.length > 0 && typeof e[0] == "string" && (e[0].includes("[Vue warn]: Invalid watch source:") || e[0].includes("{ open: false }")) || t.apply(console, e);
|
|
@@ -735,16 +738,16 @@ async function st(e) {
|
|
|
735
738
|
console.warn = t;
|
|
736
739
|
}
|
|
737
740
|
}
|
|
738
|
-
var
|
|
739
|
-
await
|
|
741
|
+
var ut = X(t("build"), Q).description("Build vitepress website.").action(async (e) => {
|
|
742
|
+
await dt();
|
|
740
743
|
});
|
|
741
|
-
async function
|
|
744
|
+
async function dt() {
|
|
742
745
|
j("\n-> Start building Vitepress website.\n\n", "info");
|
|
743
746
|
let e = Date.now();
|
|
744
747
|
try {
|
|
745
|
-
await
|
|
746
|
-
await
|
|
747
|
-
|
|
748
|
+
await lt(async () => {
|
|
749
|
+
await te(T, { onAfterConfigResolve(e) {
|
|
750
|
+
ne(e);
|
|
748
751
|
} });
|
|
749
752
|
});
|
|
750
753
|
} catch (e) {
|
|
@@ -754,13 +757,13 @@ async function lt() {
|
|
|
754
757
|
}
|
|
755
758
|
//#endregion
|
|
756
759
|
//#region src/utils/templates.ts
|
|
757
|
-
function
|
|
760
|
+
function ft(e, t) {
|
|
758
761
|
let n = s(e, { encoding: "utf8" });
|
|
759
762
|
L(m(t)), f(t, n);
|
|
760
763
|
}
|
|
761
764
|
//#endregion
|
|
762
765
|
//#region src/lib/vitepress.ts
|
|
763
|
-
var
|
|
766
|
+
var pt = {
|
|
764
767
|
base: "/",
|
|
765
768
|
lang: "en-US",
|
|
766
769
|
vite: { publicDir: "../public" },
|
|
@@ -793,24 +796,24 @@ var dt = {
|
|
|
793
796
|
}
|
|
794
797
|
}
|
|
795
798
|
};
|
|
796
|
-
function
|
|
797
|
-
return n ? V(
|
|
799
|
+
function mt(e, t, n) {
|
|
800
|
+
return n ? V(pt, n, { themeConfig: {
|
|
798
801
|
sidebar: e,
|
|
799
802
|
nav: t
|
|
800
|
-
} }) : V(
|
|
803
|
+
} }) : V(pt, { themeConfig: {
|
|
801
804
|
sidebar: e,
|
|
802
805
|
nav: t
|
|
803
806
|
} });
|
|
804
807
|
}
|
|
805
808
|
//#endregion
|
|
806
809
|
//#region src/lib/prepare.ts
|
|
807
|
-
function
|
|
810
|
+
function ht(e) {
|
|
808
811
|
return e === null ? {} : { collapsed: e };
|
|
809
812
|
}
|
|
810
|
-
async function
|
|
813
|
+
async function gt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, vitepressConfig: r, forks: i, gitProvider: o, lastUpdated: s, sidebarMode: c, sidebarCollapsed: l, acronyms: u, token: d, username: f, websiteTitle: p, websiteTagline: m }) {
|
|
811
814
|
let h = i && o !== "gitlab";
|
|
812
815
|
i && !h && j(" The forks page is not supported with the 'gitlab' provider, skipping.", "warn");
|
|
813
|
-
let g =
|
|
816
|
+
let g = Se(f), _ = Ce(f).reduce(({ internals: e, forks: t }, n) => {
|
|
814
817
|
let { clone_url: r, private: i, fork: a, docpress: o } = n;
|
|
815
818
|
if (r && !i && !o.filtered) {
|
|
816
819
|
if (!a && o.includes.length) return {
|
|
@@ -829,27 +832,27 @@ async function mt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, v
|
|
|
829
832
|
}, {
|
|
830
833
|
internals: [],
|
|
831
834
|
forks: []
|
|
832
|
-
}),
|
|
835
|
+
}), v = {
|
|
833
836
|
title: p,
|
|
834
837
|
tagline: m
|
|
835
|
-
}, { index: b, sidebar: x } =
|
|
838
|
+
}, { index: b, sidebar: x } = Ot(_.internals, g, v, {
|
|
836
839
|
mode: c,
|
|
837
840
|
collapsed: l,
|
|
838
841
|
acronyms: u
|
|
839
842
|
}), S, C;
|
|
840
843
|
if (a(E) && a(D)) {
|
|
841
|
-
let e = await
|
|
842
|
-
S =
|
|
844
|
+
let e = await Nt(D), t = await Pt(E);
|
|
845
|
+
S = Et(e.themeConfig?.sidebar, x), C = {
|
|
843
846
|
...b,
|
|
844
847
|
features: [...t.features, ...b.features].sort((e, t) => e.title.localeCompare(t.title))
|
|
845
848
|
};
|
|
846
849
|
} else S = x, C = b;
|
|
847
850
|
let w = [];
|
|
848
851
|
if (e) {
|
|
849
|
-
let t =
|
|
852
|
+
let t = kt(e);
|
|
850
853
|
h ? w.push(...t.filter((e) => e.link !== "/forks")) : w.push(...t);
|
|
851
854
|
}
|
|
852
|
-
t && (j(" Add extras Vitepress public folder content.", "info"),
|
|
855
|
+
t && (j(" Add extras Vitepress public folder content.", "info"), At(t, y(T, "public"))), n && (j(" Add extras Vitepress theme files.", "info"), At(n, y(ce))), h && f.length && (j(" Add fork page to display external contributions.", "info"), await Mt(_.forks, f, d), w.push({
|
|
853
856
|
text: "Forks",
|
|
854
857
|
link: "/forks"
|
|
855
858
|
}));
|
|
@@ -857,16 +860,16 @@ async function mt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, v
|
|
|
857
860
|
lastUpdated: !0,
|
|
858
861
|
...r
|
|
859
862
|
} : r;
|
|
860
|
-
|
|
863
|
+
It(mt(S, w, ee), C);
|
|
861
864
|
}
|
|
862
|
-
function
|
|
865
|
+
function _t(e, t) {
|
|
863
866
|
let n = `${I(p(t), {
|
|
864
867
|
mode: "lowercase",
|
|
865
868
|
removeIdx: !0
|
|
866
869
|
}) === "readme.md" ? "\n## Sources" : "# Sources"}\n\nTake a look at the [project sources](${e}).\n`;
|
|
867
870
|
r(t, n, "utf8");
|
|
868
871
|
}
|
|
869
|
-
function
|
|
872
|
+
function vt(e, t, n) {
|
|
870
873
|
let { name: r, login: i, bio: a } = t, { title: o, tagline: s } = n;
|
|
871
874
|
return {
|
|
872
875
|
layout: "home",
|
|
@@ -880,7 +883,7 @@ function gt(e, t, n) {
|
|
|
880
883
|
features: e
|
|
881
884
|
};
|
|
882
885
|
}
|
|
883
|
-
function
|
|
886
|
+
function yt(e, t, n, r = "", i = []) {
|
|
884
887
|
let a = {
|
|
885
888
|
title: I(e, {
|
|
886
889
|
mode: "capitalize",
|
|
@@ -892,25 +895,25 @@ function _t(e, t, n, r = "", i = []) {
|
|
|
892
895
|
};
|
|
893
896
|
return n ? [...n, a] : [a];
|
|
894
897
|
}
|
|
895
|
-
function
|
|
898
|
+
function bt(e, t, n = !0, r = []) {
|
|
896
899
|
return {
|
|
897
900
|
text: I(e, {
|
|
898
901
|
mode: "capitalize",
|
|
899
902
|
replaceDash: !0,
|
|
900
903
|
acronyms: r
|
|
901
904
|
}),
|
|
902
|
-
...
|
|
905
|
+
...ht(n),
|
|
903
906
|
items: t
|
|
904
907
|
};
|
|
905
908
|
}
|
|
906
|
-
function
|
|
909
|
+
function xt(e, t, n = !0, r = []) {
|
|
907
910
|
return Object.entries(t).flatMap(([t, i]) => {
|
|
908
911
|
if (t === "$") return Array.isArray(i) ? i.map((t) => {
|
|
909
|
-
let n =
|
|
912
|
+
let n = y(e.docpress.projectPath, t), i = I(p(n), {
|
|
910
913
|
mode: "lowercase",
|
|
911
914
|
removeIdx: !0
|
|
912
915
|
});
|
|
913
|
-
return i === "readme.md" && (i = "introduction.md"), i !== p(n) && l(n,
|
|
916
|
+
return i === "readme.md" && (i = "introduction.md"), i !== p(n) && l(n, y(m(n), i)), {
|
|
914
917
|
text: g(i).name === "introduction" ? "Introduction" : I(i, {
|
|
915
918
|
mode: "capitalize",
|
|
916
919
|
replaceDash: !0,
|
|
@@ -921,15 +924,15 @@ function yt(e, t, n = !0, r = []) {
|
|
|
921
924
|
};
|
|
922
925
|
}) : [];
|
|
923
926
|
if (typeof i == "object") {
|
|
924
|
-
let a = I(t, { removeIdx: !0 }), o =
|
|
927
|
+
let a = I(t, { removeIdx: !0 }), o = y(e.docpress.projectPath, t), s = y(e.docpress.projectPath, a);
|
|
925
928
|
return a !== t && l(o, s), [{
|
|
926
929
|
text: I(a, {
|
|
927
930
|
mode: "capitalize",
|
|
928
931
|
replaceDash: !0,
|
|
929
932
|
acronyms: r
|
|
930
933
|
}),
|
|
931
|
-
...
|
|
932
|
-
items:
|
|
934
|
+
...ht(n),
|
|
935
|
+
items: xt({
|
|
933
936
|
...e,
|
|
934
937
|
name: `${e.name}/${a}`,
|
|
935
938
|
docpress: {
|
|
@@ -942,71 +945,71 @@ function yt(e, t, n = !0, r = []) {
|
|
|
942
945
|
return [];
|
|
943
946
|
});
|
|
944
947
|
}
|
|
945
|
-
function
|
|
948
|
+
function St(e) {
|
|
946
949
|
return e.reduce((e, t) => {
|
|
947
950
|
let [n, ...r] = t.split("/");
|
|
948
|
-
return r.length ? e[n] =
|
|
951
|
+
return r.length ? e[n] = St([...e[n] ? Ct(e[n], "") : [], r.join("/")]) : e.$ = [...e.$ || [], n], e;
|
|
949
952
|
}, {});
|
|
950
953
|
}
|
|
951
|
-
function
|
|
952
|
-
return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] :
|
|
954
|
+
function Ct(e, t = "") {
|
|
955
|
+
return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] : Ct(n, t ? `${t}/${e}` : e));
|
|
953
956
|
}
|
|
954
|
-
function
|
|
957
|
+
function wt(e) {
|
|
955
958
|
if (!Array.isArray(e)) return e;
|
|
956
959
|
let t = e.findIndex((e) => e.text === "Sources");
|
|
957
960
|
if (t === -1) return e;
|
|
958
961
|
let [n] = e.splice(t, 1);
|
|
959
962
|
return e.push(n), e;
|
|
960
963
|
}
|
|
961
|
-
var
|
|
962
|
-
function
|
|
964
|
+
var Tt = 5;
|
|
965
|
+
function $(e, t, n = []) {
|
|
963
966
|
return e.flatMap((e) => {
|
|
964
967
|
if (!("items" in e) || !e.items?.length) return [];
|
|
965
968
|
let r = [...n, e.text];
|
|
966
|
-
return t >=
|
|
969
|
+
return t >= Tt ? [r.join("/")] : $(e.items, t + 1, r);
|
|
967
970
|
});
|
|
968
971
|
}
|
|
969
|
-
function
|
|
972
|
+
function Et(e, t) {
|
|
970
973
|
if (!e) return t;
|
|
971
974
|
if (Array.isArray(e) && Array.isArray(t)) return [...e, ...t].toSorted((e, t) => (e.text ?? "").localeCompare(t.text ?? ""));
|
|
972
975
|
let n = (e) => Array.isArray(e) ? { "/": e } : e;
|
|
973
|
-
return
|
|
976
|
+
return Dt({
|
|
974
977
|
...n(e),
|
|
975
978
|
...n(t)
|
|
976
979
|
});
|
|
977
980
|
}
|
|
978
|
-
function
|
|
981
|
+
function Dt(e) {
|
|
979
982
|
return Object.fromEntries(Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)));
|
|
980
983
|
}
|
|
981
|
-
function
|
|
984
|
+
function Ot(e, t, n, r = {}) {
|
|
982
985
|
let { mode: i = "single", collapsed: a = !0, acronyms: o = [] } = r, s = [], l = [], u = {};
|
|
983
986
|
for (let t of e) {
|
|
984
987
|
j(` Replace urls for repository '${t.name}'.`, "info"), z([t.docpress.projectPath]).forEach((e) => {
|
|
985
|
-
j(` Processing file '${p(e)}' for repository '${t.name}'.`, "debug"),
|
|
988
|
+
j(` Processing file '${p(e)}' for repository '${t.name}'.`, "debug"), Ee(e, t.docpress.replace_url, t.docpress.projectPath), p(e).toLowerCase() === "readme.md" && Ae(e, t.docpress.replace_url), ke(e);
|
|
986
989
|
}), j(` Generate sidebar for repository '${t.name}'.`, "info");
|
|
987
990
|
let e = c(t.docpress.projectPath, { recursive: !0 }).filter((e) => {
|
|
988
|
-
let n =
|
|
989
|
-
return p(n).endsWith(".md") &&
|
|
991
|
+
let n = y(t.docpress.projectPath, e.toString());
|
|
992
|
+
return p(n).endsWith(".md") && xe(n);
|
|
990
993
|
}).sort();
|
|
991
994
|
j(` Add sources for repository '${t.name}'.`, "info");
|
|
992
995
|
let n;
|
|
993
|
-
e.length > 1 ? (n =
|
|
994
|
-
let r =
|
|
995
|
-
d.length && j(` Sidebar for repository '${t.name}' nests deeper than Vitepress renders, pages under ${d.map((e) => `'${e}'`).join(", ")} will not appear in the sidebar.`, "warn"), i === "multi" ? u[`/${t.docpress.routePrefix ?? ""}${I(t.name, { removeDot: !0 })}/`] = r : l.push(
|
|
996
|
+
e.length > 1 ? (n = y(t.docpress.projectPath, "sources.md"), e.push("sources.md")) : e.length === 1 && (n = y(t.docpress.projectPath, e[0])), n ? _t(t.html_url, n) : j(` No markdown files found for repository '${t.name}', skipping sources.`, "warn");
|
|
997
|
+
let r = wt(xt(t, St(e), a, o)), d = $(r, i === "multi" ? 0 : 1);
|
|
998
|
+
d.length && j(` Sidebar for repository '${t.name}' nests deeper than Vitepress renders, pages under ${d.map((e) => `'${e}'`).join(", ")} will not appear in the sidebar.`, "warn"), i === "multi" ? u[`/${t.docpress.routePrefix ?? ""}${I(t.name, { removeDot: !0 })}/`] = r : l.push(bt(I(t.name, { removeDot: !0 }), r, a, o)), s.push(...yt(I(t.name, { removeDot: !0 }), t.description || "", void 0, t.docpress.routePrefix ?? "", o));
|
|
996
999
|
}
|
|
997
1000
|
j(" Generate index content.", "info");
|
|
998
|
-
let d =
|
|
1001
|
+
let d = vt(s.toSorted((e, t) => e.title.localeCompare(t.title)), t, n);
|
|
999
1002
|
return {
|
|
1000
|
-
sidebar: i === "multi" ?
|
|
1003
|
+
sidebar: i === "multi" ? Dt(u) : l.toSorted((e, t) => e.text.localeCompare(t.text)),
|
|
1001
1004
|
index: d
|
|
1002
1005
|
};
|
|
1003
1006
|
}
|
|
1004
|
-
function
|
|
1007
|
+
function kt(e) {
|
|
1005
1008
|
let t = z(e), n = [];
|
|
1006
1009
|
j(" Add extras Vitepress headers pages.", "info");
|
|
1007
1010
|
for (let e of t) {
|
|
1008
1011
|
j(` Processing file '${e}'.`, "debug");
|
|
1009
|
-
let t =
|
|
1012
|
+
let t = y(process.cwd(), e), r = y(ae, I(p(e), {
|
|
1010
1013
|
mode: "lowercase",
|
|
1011
1014
|
removeIdx: !0
|
|
1012
1015
|
}));
|
|
@@ -1023,18 +1026,18 @@ function Dt(e) {
|
|
|
1023
1026
|
}
|
|
1024
1027
|
return n;
|
|
1025
1028
|
}
|
|
1026
|
-
function
|
|
1029
|
+
function At(e, t, n) {
|
|
1027
1030
|
for (let r of Array.isArray(e) ? e : [e]) {
|
|
1028
|
-
let e =
|
|
1031
|
+
let e = y(process.cwd(), r), a = R(e);
|
|
1029
1032
|
for (let o of a) {
|
|
1030
1033
|
let a = o.replace(e, ".");
|
|
1031
1034
|
j(` Processing file '${a}' for entry '${r}'.`, "debug");
|
|
1032
|
-
let s =
|
|
1035
|
+
let s = y(process.cwd(), o), c = y(t, a);
|
|
1033
1036
|
n && n(), i(s, c);
|
|
1034
1037
|
}
|
|
1035
1038
|
}
|
|
1036
1039
|
}
|
|
1037
|
-
function
|
|
1040
|
+
function jt(e) {
|
|
1038
1041
|
let t = e.map(({ repository: e, contributions: t }) => {
|
|
1039
1042
|
let { name: n, owner: r, html_url: i, description: a, stargazers_count: o } = e;
|
|
1040
1043
|
return {
|
|
@@ -1046,11 +1049,11 @@ function kt(e) {
|
|
|
1046
1049
|
contributions: t
|
|
1047
1050
|
};
|
|
1048
1051
|
});
|
|
1049
|
-
j(" Generate forks page.", "info"), f(
|
|
1052
|
+
j(" Generate forks page.", "info"), f(oe, "---\nlayout: fork-page\nrepoList:\n" + x.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");
|
|
1050
1053
|
}
|
|
1051
|
-
async function
|
|
1052
|
-
|
|
1053
|
-
let { source: r, contributors: i } = await
|
|
1054
|
+
async function Mt(e, t, n) {
|
|
1055
|
+
jt(await Promise.all(e.map(async (e) => {
|
|
1056
|
+
let { source: r, contributors: i } = await He({
|
|
1054
1057
|
repository: e,
|
|
1055
1058
|
token: n
|
|
1056
1059
|
});
|
|
@@ -1060,31 +1063,31 @@ async function At(e, t, n) {
|
|
|
1060
1063
|
};
|
|
1061
1064
|
})).then((e) => e.filter(({ repository: e, contributions: t }) => !!e && t)));
|
|
1062
1065
|
}
|
|
1063
|
-
async function
|
|
1066
|
+
async function Nt(e) {
|
|
1064
1067
|
try {
|
|
1065
|
-
let { config: t } = await import(
|
|
1068
|
+
let { config: t } = await import(y(process.cwd(), e));
|
|
1066
1069
|
return t ?? {};
|
|
1067
1070
|
} catch (t) {
|
|
1068
1071
|
return j(` Unable to load existing Vitepress config '${e}', starting from an empty config. ${P(t)}`, "warn"), {};
|
|
1069
1072
|
}
|
|
1070
1073
|
}
|
|
1071
|
-
async function
|
|
1072
|
-
let t = (await
|
|
1073
|
-
return
|
|
1074
|
+
async function Pt(e) {
|
|
1075
|
+
let t = (await re(y(process.cwd(), e))).toString();
|
|
1076
|
+
return x.parse(t);
|
|
1074
1077
|
}
|
|
1075
|
-
var
|
|
1076
|
-
function
|
|
1077
|
-
L(m(D)), j(" Generate Vitepress config.", "info"), f(D, `export const config = ${JSON.stringify(e, null, 2)}\n${
|
|
1078
|
+
var Ft = "\nfunction escapeInlineCode(md) {\n const render = md.renderer.rules.code_inline\n md.renderer.rules.code_inline = (tokens, idx, options, env, self) => {\n tokens[idx].attrSet('v-pre', '')\n return render(tokens, idx, options, env, self)\n }\n}\n\nexport default { ...config, markdown: { ...config.markdown, config: escapeInlineCode } }\n";
|
|
1079
|
+
function It(e, t) {
|
|
1080
|
+
L(m(D)), j(" Generate Vitepress config.", "info"), f(D, `export const config = ${JSON.stringify(e, null, 2)}\n${Ft}`), j(" Generate index file.", "info"), f(E, "---\n" + x.stringify(t));
|
|
1078
1081
|
let n = R(O);
|
|
1079
1082
|
if (!n.length) throw Error(`No template theme files found at '${O}'. The Vitepress build cannot succeed without them.`);
|
|
1080
1083
|
j(" Add Docpress theme files.", "info"), n.forEach((e) => {
|
|
1081
1084
|
let t = e.replace(`${O}/`, "");
|
|
1082
|
-
|
|
1085
|
+
ft(e, y(se, t));
|
|
1083
1086
|
});
|
|
1084
1087
|
}
|
|
1085
1088
|
//#endregion
|
|
1086
1089
|
//#region src/commands/prepare.ts
|
|
1087
|
-
var
|
|
1090
|
+
var Lt = "prepare", Rt = [
|
|
1088
1091
|
n("--acronyms <string>", K.shape.acronyms.description),
|
|
1089
1092
|
n("-c, --extra-public-content <string>", K.shape.extraPublicContent.description),
|
|
1090
1093
|
n("-f, --forks", K.shape.forks.description),
|
|
@@ -1095,17 +1098,17 @@ var Ft = "prepare", It = [
|
|
|
1095
1098
|
n("-v, --vitepress-config <string>", K.shape.vitepressConfig.description),
|
|
1096
1099
|
n("--website-title <string>", K.shape.websiteTitle.description),
|
|
1097
1100
|
n("--website-tagline <string>", K.shape.websiteTagline.description)
|
|
1098
|
-
],
|
|
1099
|
-
await
|
|
1101
|
+
], zt = X(t(Lt), [...Rt, ...Q]).description("Transform doc to the target vitepress format.").action(async (e, t) => {
|
|
1102
|
+
await Bt(J(Lt, Y(t, e)));
|
|
1100
1103
|
});
|
|
1101
|
-
async function
|
|
1104
|
+
async function Bt(e) {
|
|
1102
1105
|
let { extraHeaderPages: t, extraPublicContent: n, extraTheme: r, vitepressConfig: i, forks: a, gitProvider: o, lastUpdated: s, sidebarMode: c, sidebarCollapsed: l, acronyms: u, token: d, usernames: f, websiteTitle: p, websiteTagline: h } = e;
|
|
1103
1106
|
j("\n-> Start transform files to prepare Vitepress build.", "info");
|
|
1104
1107
|
let g = Date.now();
|
|
1105
1108
|
L(m(D), { clean: !0 });
|
|
1106
1109
|
let _ = [];
|
|
1107
1110
|
for (let e of f) try {
|
|
1108
|
-
await
|
|
1111
|
+
await gt({
|
|
1109
1112
|
extraHeaderPages: t,
|
|
1110
1113
|
extraPublicContent: n,
|
|
1111
1114
|
extraTheme: r,
|
|
@@ -1129,27 +1132,27 @@ async function Rt(e) {
|
|
|
1129
1132
|
}
|
|
1130
1133
|
//#endregion
|
|
1131
1134
|
//#region src/cli.ts
|
|
1132
|
-
function
|
|
1133
|
-
let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${
|
|
1135
|
+
function Vt() {
|
|
1136
|
+
let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${ie.version}`).action(async (e, t) => {
|
|
1134
1137
|
let n = J("global", Y(t, e));
|
|
1135
|
-
await
|
|
1138
|
+
await ct(n), await Bt(n), await dt();
|
|
1136
1139
|
}).configureHelp({
|
|
1137
1140
|
sortSubcommands: !0,
|
|
1138
1141
|
sortOptions: !0,
|
|
1139
1142
|
showGlobalOptions: !0
|
|
1140
|
-
}).enablePositionalOptions().passThroughOptions().addCommand(
|
|
1143
|
+
}).enablePositionalOptions().passThroughOptions().addCommand(st).addCommand(zt).addCommand(ut);
|
|
1141
1144
|
return X(t, [
|
|
1142
|
-
...
|
|
1143
|
-
...
|
|
1145
|
+
...ot,
|
|
1146
|
+
...Rt,
|
|
1144
1147
|
...Q
|
|
1145
1148
|
]), t;
|
|
1146
1149
|
}
|
|
1147
|
-
function
|
|
1148
|
-
|
|
1150
|
+
function Ht() {
|
|
1151
|
+
Vt().parseAsync(process.argv).catch((e) => {
|
|
1149
1152
|
j(`\n${P(e)}`, "error"), process.exit(1);
|
|
1150
1153
|
});
|
|
1151
1154
|
}
|
|
1152
1155
|
//#endregion
|
|
1153
|
-
export {
|
|
1156
|
+
export { Vt as getProgram, Ht as main };
|
|
1154
1157
|
|
|
1155
1158
|
//# sourceMappingURL=cli.js.map
|