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