@tobi-or-not/docpress 0.10.3 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import { Command as e, createCommand as t, createOption as n } from "commander";
2
2
  import { appendFileSync as r, cpSync as i, existsSync as a, mkdirSync as o, readFileSync as s, readdirSync as c, renameSync as l, rmSync as u, statSync as d, writeFileSync as f } from "node:fs";
3
- import { basename as p, dirname as m, join as h, parse as g, relative as _, resolve as v } from "node:path";
4
- import y from "yaml";
5
- import b from "picocolors";
6
- import { z as x } from "zod";
7
- import { Octokit as S } from "@octokit/rest";
8
- import { simpleGit as ee } from "simple-git";
3
+ import { basename as p, dirname as m, join as h, parse as g, relative as ee, resolve as _ } from "node:path";
4
+ import v from "yaml";
5
+ import y from "picocolors";
6
+ import { z as b } from "zod";
7
+ import { Octokit as x } from "@octokit/rest";
8
+ import { simpleGit as S } from "simple-git";
9
9
  import { build as te } from "vitepress";
10
10
  import { withMermaid as ne } from "vitepress-plugin-mermaid";
11
11
  import { readFile as re } from "node:fs/promises";
12
12
  var ie = {
13
13
  name: "@tobi-or-not/docpress",
14
14
  type: "module",
15
- version: "0.10.3",
16
- packageManager: "bun@1.3.14",
15
+ version: "0.12.0",
16
+ packageManager: "bun@1.4.0",
17
17
  homepage: "https://this-is-tobi.com/docpress/introduction",
18
18
  repository: {
19
19
  type: "git",
@@ -31,7 +31,7 @@ var ie = {
31
31
  "build:docker": "docker build --tag tobi-or-not/docpress --target prod .",
32
32
  "build:types": "tsc",
33
33
  "build:vite": "vite build",
34
- dev: "bun ./dev/docpress.ts",
34
+ dev: "NODE_ENV=development bun ./dev/docpress.ts",
35
35
  "dev:clean": "node -e \"require('node:fs').rmSync('./docpress',{recursive:true,force:true})\" && bun run dev",
36
36
  format: "eslint . --fix",
37
37
  lint: "eslint .",
@@ -50,40 +50,49 @@ var ie = {
50
50
  dependencies: {
51
51
  "@octokit/rest": "^22.0.1",
52
52
  commander: "^15.0.0",
53
+ mermaid: "^11.17.2",
53
54
  picocolors: "^1.1.1",
54
55
  "simple-git": "^3.36.0",
55
56
  vitepress: "^1.6.4",
56
57
  "vitepress-plugin-mermaid": "^2.0.17",
57
58
  yaml: "^2.9.0",
58
- zod: "^4.4.3"
59
+ zod: "^4.5.4"
59
60
  },
60
61
  devDependencies: {
61
- "@antfu/eslint-config": "^9.1.0",
62
- "@commitlint/cli": "^21.2.1",
63
- "@commitlint/config-conventional": "^21.2.0",
64
- "@octokit/types": "^16.0.0",
65
- "@types/node": "^26.1.1",
62
+ "@antfu/eslint-config": "^9.5.1",
63
+ "@commitlint/cli": "^21.2.2",
64
+ "@commitlint/config-conventional": "^21.2.2",
65
+ "@octokit/types": "^18.0.0",
66
+ "@types/node": "^26.4.1",
66
67
  "@vitejs/plugin-vue": "^6.0.8",
67
- "@vitest/coverage-v8": "^4.1.10",
68
- eslint: "^10.7.0",
68
+ "@vitest/coverage-v8": "^4.1.11",
69
+ eslint: "^10.9.1",
69
70
  husky: "^9.1.7",
70
71
  "nano-staged": "^1.0.2",
71
72
  typescript: "^6.0.3",
72
- vite: "^8.1.5",
73
- vitest: "^4.1.10",
74
- vue: "^3.5.40"
73
+ vite: "^8.2.2",
74
+ vitest: "^4.1.11",
75
+ vue: "^3.5.42"
75
76
  },
76
77
  publishConfig: {
77
78
  registry: "https://registry.npmjs.org/",
78
79
  access: "public",
79
80
  tag: "latest"
81
+ },
82
+ overrides: {
83
+ "brace-expansion": "^5.0.8",
84
+ dompurify: "^3.4.14",
85
+ "fast-uri": "^3.1.6",
86
+ "js-yaml": "^4.3.1",
87
+ nanoid: "^3.3.16",
88
+ postcss: "^8.5.26"
80
89
  }
81
- }, C = v(process.cwd(), "docpress"), ae = v(process.cwd(), "docpress/docs"), w = v(process.cwd(), "docpress/docs/index.md"), oe = v(process.cwd(), "docpress/docs/forks.md"), T = v(process.cwd(), "docpress/.vitepress/config.ts"), se = v(process.cwd(), "docpress/.vitepress/theme"), ce = v(process.cwd(), "docpress/.vitepress/theme/extras"), le = process.env.NODE_ENV === "development" ? v(import.meta.dirname, "../../public/templates/theme") : v(import.meta.dirname, "./templates/theme"), E = {
82
- red: b.red,
83
- yellow: b.yellow,
84
- white: b.white,
85
- green: b.green,
86
- blue: b.blue
90
+ }, C = _(process.cwd(), "docpress"), ae = _(process.cwd(), "docpress/docs"), w = _(process.cwd(), "docpress/docs/index.md"), oe = _(process.cwd(), "docpress/docs/forks.md"), T = _(process.cwd(), "docpress/.vitepress/config.ts"), se = _(process.cwd(), "docpress/.vitepress/theme"), ce = _(process.cwd(), "docpress/.vitepress/theme/extras"), E = process.env.NODE_ENV === "development" ? _(import.meta.dirname, "../../public/templates/theme") : _(import.meta.dirname, "./templates/theme"), le = {
91
+ red: y.red,
92
+ yellow: y.yellow,
93
+ white: y.white,
94
+ green: y.green,
95
+ blue: y.blue
87
96
  };
88
97
  function ue() {
89
98
  let e = Number(process.env.LOG_LEVEL);
@@ -114,42 +123,61 @@ var D = {
114
123
  color: "blue",
115
124
  level: 50
116
125
  }
117
- };
118
- function O(e, t = "info", n) {
119
- let r = n ? E[n](e) : E[D[t].color](e), i = t === "success" ? "info" : t;
126
+ }, O = [
127
+ "error",
128
+ "warn",
129
+ "info",
130
+ "trace",
131
+ "debug"
132
+ ];
133
+ function de(e) {
134
+ return D[e].level;
135
+ }
136
+ function k(e, t = "info", n) {
137
+ let r = n ? le[n](e) : le[D[t].color](e), i = t === "success" ? "info" : t;
120
138
  ue() >= D[t].level && console[i](r);
121
139
  }
122
140
  //#endregion
123
141
  //#region src/utils/regex.ts
124
- var de = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, fe = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, pe = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, me = /^\d{2}-/, k = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/, he = /\[([^\]]+)\]\((?!https?:|\/|#|mailto:)([^)#]*\/)?([^)#/]+\.md)(#[^)]*)?\)/g;
142
+ var fe = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, pe = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, me = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, he = /^\d{2}-/, A = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/, ge = /\[([^\]]+)\]\((?!https?:|\/|#|mailto:)([^)#]*\/)?([^)#/]+\.md)(#[^)]*)?\)/g;
125
143
  //#endregion
126
144
  //#region src/utils/functions.ts
127
- async function A(e) {
145
+ async function j(e) {
128
146
  try {
129
147
  return (await fetch(e, {
130
148
  method: "HEAD",
131
149
  redirect: "manual"
132
150
  })).status;
133
151
  } catch (t) {
134
- return O(` Network error while checking '${e}': ${t instanceof Error ? t.message : String(t)}`, "debug"), 500;
152
+ return k(` Network error while checking '${e}': ${N(t)}`, "debug"), 500;
135
153
  }
136
154
  }
137
- function j(e) {
155
+ function M(e) {
138
156
  return (e.split(/[/\\]/).pop() ?? "").replace(/[^\w.-]/g, "_").replace(/^\.+/, "") || "_";
139
157
  }
140
- function M(e) {
141
- return !z(e) || !("token" in e) ? e : {
158
+ function _e(e) {
159
+ return !V(e) || !("token" in e) ? e : {
142
160
  ...e,
143
161
  token: e.token ? "***" : e.token
144
162
  };
145
163
  }
146
- function N(e, t) {
164
+ function N(e) {
165
+ return e instanceof Error ? e.message : String(e);
166
+ }
167
+ function P(e) {
168
+ if (e < 1e3) return `${Math.round(e)}ms`;
169
+ let t = e / 1e3;
170
+ if (t < 60) return `${t.toFixed(1)}s`;
171
+ let n = Math.floor(t / 60), r = Math.round(t % 60);
172
+ return `${n}m ${String(r).padStart(2, "0")}s`;
173
+ }
174
+ function F(e, t) {
147
175
  let n = "";
148
- return t?.removeDot && (n = e.startsWith(".") ? e.slice(1) : e, n = n.replaceAll(".", "-")), t?.removeIdx && (n = (n || e).replace(me, "")), t?.removeExt && (n = (n || e).split(".")[0]), t?.replaceDash && (n = (n || e).replaceAll("-", " ")), t?.mode === "capitalize" ? n = (n || e).slice(0, 1).toUpperCase() + (n || e).slice(1).toLowerCase() : t?.mode === "lowercase" ? n = (n || e).toLowerCase() : t?.mode === "uppercase" && (n = (n || e).toUpperCase()), n || e;
176
+ 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()), n || e;
149
177
  }
150
- function P(e, { clean: t } = { clean: !1 }) {
178
+ function I(e, { clean: t } = { clean: !1 }) {
151
179
  try {
152
- if (t && a(e)) for (let t of c(e)) u(v(e, t), {
180
+ if (t && a(e)) for (let t of c(e)) u(_(e, t), {
153
181
  recursive: !0,
154
182
  force: !0
155
183
  });
@@ -158,53 +186,53 @@ function P(e, { clean: t } = { clean: !1 }) {
158
186
  throw Error(`Unable to create directory '${e}': ${t instanceof Error ? t.message : String(t)}`);
159
187
  }
160
188
  }
161
- function ge(e) {
189
+ function ve(e) {
162
190
  try {
163
191
  return d(e).isDirectory();
164
192
  } catch {
165
193
  return !1;
166
194
  }
167
195
  }
168
- function F(e) {
196
+ function ye(e) {
169
197
  try {
170
198
  return d(e).isFile();
171
199
  } catch {
172
200
  return !1;
173
201
  }
174
202
  }
175
- function I(e) {
176
- return (Array.isArray(e) ? e : [e]).flatMap((e) => F(e) ? [e] : ge(e) ? c(e).filter((e) => e !== ".git").sort().flatMap((t) => I(h(e, t))) : []);
177
- }
178
203
  function L(e) {
179
- return I(e).filter((e) => p(e).endsWith(".md"));
204
+ return (Array.isArray(e) ? e : [e]).flatMap((e) => ye(e) ? [e] : ve(e) ? c(e).filter((e) => e !== ".git").sort().flatMap((t) => L(h(e, t))) : []);
180
205
  }
181
- function _e(e) {
206
+ function R(e) {
207
+ return L(e).filter((e) => p(e).endsWith(".md"));
208
+ }
209
+ function z(e) {
182
210
  return e.reduce((e, t, n, r) => n ? n === r.length - 1 ? `${e} or "${t}"` : `${e}, "${t}"` : `"${t}"`, "");
183
211
  }
184
- function ve(e) {
185
- return JSON.parse(s(`${C}/user-${j(e)}.json`).toString());
212
+ function be(e) {
213
+ return JSON.parse(s(`${C}/user-${M(e)}.json`).toString());
186
214
  }
187
- function ye(e) {
188
- return JSON.parse(s(`${C}/repos-${j(e)}.json`).toString());
215
+ function xe(e) {
216
+ return JSON.parse(s(`${C}/repos-${M(e)}.json`).toString());
189
217
  }
190
- var be = /* @__PURE__ */ new Set([
218
+ var Se = /* @__PURE__ */ new Set([
191
219
  "__proto__",
192
220
  "constructor",
193
221
  "prototype"
194
222
  ]);
195
- function R(...e) {
223
+ function B(...e) {
196
224
  return e.reduce((e, t) => (t === null || Object.keys(t).forEach((n) => {
197
- if (be.has(n)) return;
225
+ if (Se.has(n)) return;
198
226
  let r = e ? e[n] : null, i = t[n];
199
- z(r) && z(i) ? e[n] = R(r, i) : z(i) ? e[n] = R({}, i) : e[n] = i;
227
+ e[n] = V(r) && V(i) ? B(r, i) : V(i) ? B({}, i) : i;
200
228
  }), e), {});
201
229
  }
202
- function z(e) {
230
+ function V(e) {
203
231
  return e && typeof e == "object" && !Array.isArray(e);
204
232
  }
205
- function B(e) {
233
+ function Ce(e) {
206
234
  if (!e) return {};
207
- let t = v(process.cwd(), e), n;
235
+ let t = _(process.cwd(), e), n;
208
236
  try {
209
237
  n = s(t, "utf8");
210
238
  } catch {
@@ -216,61 +244,74 @@ function B(e) {
216
244
  throw Error(`Invalid JSON in config file '${e}'.`);
217
245
  }
218
246
  }
219
- function V(e) {
247
+ function H(e) {
220
248
  return e.split(",");
221
249
  }
222
- function xe(e, t) {
223
- f(e, s(e, "utf8").replace(de, (e, n, r) => `[${n}](${t}/${r})`), "utf8");
250
+ function we(e, t) {
251
+ let n = s(e, "utf8").replace(fe, (e, n, r) => `[${n}](${t}/${r})`);
252
+ f(e, n, "utf8");
224
253
  }
225
- function Se(e, t) {
226
- let n = s(e, "utf8"), r = n.match(k);
254
+ function Te(e, t) {
255
+ let n = s(e, "utf8"), r = n.match(A);
227
256
  if (r) {
228
- let i = y.parse(r[1]) ?? {};
229
- i.lastUpdated = t, f(e, n.replace(k, `---\n${y.stringify(i)}---\n`), "utf8");
257
+ let i = v.parse(r[1]) ?? {};
258
+ i.lastUpdated = t, f(e, n.replace(A, `---\n${v.stringify(i)}---\n`), "utf8");
230
259
  } else f(e, `---\nlastUpdated: ${t}\n---\n\n${n}`, "utf8");
231
260
  }
232
- function Ce(e) {
233
- f(e, s(e, "utf8").replace(he, (e, t, n, r, i) => {
234
- let a = N(r, {
261
+ function Ee(e) {
262
+ let t = s(e, "utf8").replace(ge, (e, t, n, r, i) => {
263
+ let a = F(r, {
235
264
  mode: "lowercase",
236
265
  removeIdx: !0
237
266
  });
238
267
  return a === "readme.md" && (a = "introduction.md"), `[${t}](${n ?? ""}${a}${i ?? ""})`;
239
- }), "utf8");
268
+ });
269
+ f(e, t, "utf8");
240
270
  }
241
- function we(e, t) {
242
- f(e, s(e, "utf8").replace(fe, (e, n, r, i) => `[${n}](${t}/${i})`).replace(pe, (e, t, n, r) => `[${t}](${r})`), "utf8");
271
+ function De(e, t) {
272
+ let n = s(e, "utf8").replace(pe, (e, n, r, i) => `[${n}](${t}/${i})`).replace(me, (e, t, n, r) => `[${t}](${r})`);
273
+ f(e, n, "utf8");
243
274
  }
244
275
  //#endregion
245
276
  //#region src/schemas/global.ts
246
- var H = ["github", "gitlab"], U = /^\w[\w./-]*$/, W = "Branch name must start with a letter, digit or underscore and only contain letters, digits, \".\", \"-\", \"_\" or \"/\".", G = x.object({
247
- usernames: x.string().array().describe("List of comma separated Git provider usernames used to collect data."),
248
- branch: x.string().regex(U, W).optional().describe("Branch used to collect Git provider data. Defaults to each repository's own default branch when not set."),
249
- gitProvider: x.enum(H).default("github").describe(`Git provider used to retrieve data. Values should be ${_e(H)}.`),
250
- reposFilter: x.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
251
- extraHeaderPages: x.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
252
- extraPublicContent: x.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
253
- extraTheme: x.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
254
- forks: x.boolean().default(!1).describe("Whether or not to create the dedicated fork page that aggregate external contributions."),
255
- lastUpdated: x.boolean().default(!1).describe("Whether or not to inject each page's last Git commit date as Vitepress \"lastUpdated\" frontmatter."),
256
- vitepressConfig: x.any().optional().describe("Path to the vitepress configuration file."),
257
- websiteTitle: x.string().describe("Website title."),
258
- websiteTagline: x.string().describe("Website tagline.")
259
- }), K = G.partial().extend({
260
- branch: x.string().regex(U, W).optional().describe(G.shape.branch.description || ""),
261
- gitProvider: x.enum(H).optional().describe(G.shape.gitProvider.description || ""),
262
- forks: x.boolean().optional().describe(G.shape.forks.description || ""),
263
- lastUpdated: x.boolean().optional().describe(G.shape.lastUpdated.description || ""),
264
- config: x.string().optional().describe("Path to the docpress configuration file."),
265
- token: x.string().optional().describe("Git provider token used to collect data."),
266
- usernames: x.string().transform(V).optional().describe(G.shape.usernames.description || ""),
267
- reposFilter: x.string().transform(V).optional().describe(G.shape.reposFilter.description || ""),
268
- extraHeaderPages: x.string().transform(V).optional().describe(G.shape.extraHeaderPages.description || ""),
269
- extraPublicContent: x.string().transform(V).optional().describe(G.shape.extraPublicContent.description || ""),
270
- extraTheme: x.string().transform(V).optional().describe(G.shape.extraTheme.description || ""),
271
- vitepressConfig: x.string().optional().describe(G.shape.vitepressConfig.description || "")
277
+ var U = ["github", "gitlab"], W = ["single", "multi"], Oe = [
278
+ "true",
279
+ "false",
280
+ "null"
281
+ ], G = /^\w[\w./-]*$/, ke = "Branch name must start with a letter, digit or underscore and only contain letters, digits, \".\", \"-\", \"_\" or \"/\".", K = b.object({
282
+ usernames: b.string().array().describe("List of comma separated Git provider usernames used to collect data."),
283
+ logLevel: b.enum(O).optional().describe(`Verbosity of the CLI output. Values should be ${z(O)}. Defaults to "info", or to the LOG_LEVEL environment variable when set.`),
284
+ branch: b.string().regex(G, ke).optional().describe("Branch used to collect Git provider data. Defaults to each repository's own default branch when not set."),
285
+ gitProvider: b.enum(U).default("github").describe(`Git provider used to retrieve data. Values should be ${z(U)}.`),
286
+ reposFilter: b.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
287
+ extraHeaderPages: b.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
288
+ extraPublicContent: b.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
289
+ extraTheme: b.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
290
+ forks: b.boolean().default(!1).describe("Whether or not to create the dedicated fork page that aggregate external contributions."),
291
+ lastUpdated: b.boolean().default(!1).describe("Whether or not to inject each page's last Git commit date as Vitepress \"lastUpdated\" frontmatter."),
292
+ sidebarMode: b.enum(W).default("single").describe(`Shape of the generated sidebar. Values should be ${z(W)}. "single" lists every repository in one sidebar, "multi" gives each repository its own sidebar.`),
293
+ sidebarCollapsed: b.union([b.boolean(), b.null()]).default(!0).describe("Collapse behaviour of generated sidebar groups. \"true\" collapses them by default, \"false\" expands them, \"null\" makes them non-collapsible."),
294
+ vitepressConfig: b.any().optional().describe("Path to the vitepress configuration file."),
295
+ websiteTitle: b.string().describe("Website title."),
296
+ websiteTagline: b.string().describe("Website tagline.")
297
+ }), q = K.partial().extend({
298
+ branch: b.string().regex(G, ke).optional().describe(K.shape.branch.description || ""),
299
+ gitProvider: b.enum(U).optional().describe(K.shape.gitProvider.description || ""),
300
+ logLevel: b.enum(O).optional().describe(K.shape.logLevel.description || ""),
301
+ forks: b.boolean().optional().describe(K.shape.forks.description || ""),
302
+ lastUpdated: b.boolean().optional().describe(K.shape.lastUpdated.description || ""),
303
+ config: b.string().optional().describe("Path to the docpress configuration file."),
304
+ token: b.string().optional().describe("Git provider token used to collect data."),
305
+ usernames: b.string().transform(H).optional().describe(K.shape.usernames.description || ""),
306
+ reposFilter: b.string().transform(H).optional().describe(K.shape.reposFilter.description || ""),
307
+ extraHeaderPages: b.string().transform(H).optional().describe(K.shape.extraHeaderPages.description || ""),
308
+ extraPublicContent: b.string().transform(H).optional().describe(K.shape.extraPublicContent.description || ""),
309
+ extraTheme: b.string().transform(H).optional().describe(K.shape.extraTheme.description || ""),
310
+ vitepressConfig: b.string().optional().describe(K.shape.vitepressConfig.description || ""),
311
+ sidebarMode: b.enum(W).optional().describe(K.shape.sidebarMode.description || ""),
312
+ sidebarCollapsed: b.enum(Oe).transform((e) => e === "null" ? null : e === "true").optional().describe(`${K.shape.sidebarCollapsed.description} Values should be ${z(Oe)}.`)
272
313
  });
273
- function Te(e) {
314
+ function Ae(e) {
274
315
  if (!e) return {};
275
316
  let t = { ...e };
276
317
  for (let e of [
@@ -282,83 +323,86 @@ function Te(e) {
282
323
  ]) typeof t[e] == "string" && (t[e] = [t[e]]);
283
324
  return t;
284
325
  }
285
- function Ee(e) {
286
- let t = G.partial().safeParse(e);
287
- if (!t.success) throw Error(x.prettifyError(t.error));
326
+ function je(e) {
327
+ let t = K.partial().safeParse(e);
328
+ if (!t.success) throw Error(b.prettifyError(t.error));
288
329
  return t.data;
289
330
  }
290
- function De(e) {
331
+ function Me(e) {
291
332
  if (!e.usernames?.length) throw Error("The usernames field is required");
292
333
  return e;
293
334
  }
294
- function Oe(e, t) {
335
+ function Ne(e, t) {
295
336
  if (e) return e;
296
337
  let n = t === "gitlab" ? process.env.GITLAB_TOKEN : process.env.GITHUB_TOKEN;
297
- return process.env.DOCPRESS_TOKEN ?? n;
338
+ return process.env.DOCPRESS_TOKEN || n || void 0;
339
+ }
340
+ function Pe(e) {
341
+ e && (process.env.LOG_LEVEL = String(de(e)));
298
342
  }
299
- var ke = K.partial().transform((e, t) => {
343
+ var Fe = q.partial().transform((e, t) => {
300
344
  try {
301
- let { config: t, vitepressConfig: n, token: r, ...i } = e;
302
- O(`Debug: Schema transform input: ${JSON.stringify(M(e))}`, "debug");
303
- let a = Ee(Te(B(t))), o = {
345
+ let { config: t, vitepressConfig: n, token: r, ...i } = e, a = je(Ae(Ce(t))), o = {
304
346
  gitProvider: "github",
305
347
  forks: !1,
306
348
  lastUpdated: !1,
349
+ sidebarMode: "single",
350
+ sidebarCollapsed: !0,
307
351
  ...a,
308
352
  ...i,
309
353
  ...n ? { vitepressConfig: {
310
354
  ...a.vitepressConfig || {},
311
- ...B(n) || {}
355
+ ...Ce(n) || {}
312
356
  } } : {}
313
357
  };
314
- return O(`Debug: Final merged config: ${JSON.stringify(o)}`, "debug"), De({
358
+ return Pe(o.logLevel), Me({
315
359
  ...o,
316
- token: Oe(r, o.gitProvider)
360
+ token: Ne(r, o.gitProvider)
317
361
  });
318
362
  } catch (e) {
319
363
  return t.addIssue({
320
364
  code: "custom",
321
365
  message: e instanceof Error ? e.message : JSON.stringify(e, null, 2)
322
- }), x.NEVER;
366
+ }), b.NEVER;
323
367
  }
324
368
  });
325
369
  //#endregion
326
370
  //#region src/utils/commands.ts
327
- function q(e, t) {
328
- O("Initializing Docpress...", "info", "blue"), O("\n\n-> Checking for required environment settings and configurations.", "info"), O(` Debug info - opts: ${JSON.stringify(M(t))}`, "debug"), O(` Debug info - cmd: ${e}`, "debug");
329
- let n = ke.safeParse(t);
330
- return n.success || (O(` An error occurred while checking configuration.\n ${x.prettifyError(n.error)}`, "error"), process.exit(1)), O(" Setup complete! Ready to process your documentation.", "info"), n.data;
331
- }
332
371
  function J(e, t) {
333
- return Object.fromEntries(Object.entries(t).filter(([t]) => e.getOptionValueSource(t) !== "default"));
372
+ k("Initializing Docpress...", "info", "blue"), k("\n\n-> Checking for required environment settings and configurations.", "info"), k(` Debug info - cmd: ${e}`, "debug");
373
+ let n = Fe.safeParse(t);
374
+ return n.success || (k(` An error occurred while checking configuration.\n ${b.prettifyError(n.error)}`, "error"), process.exit(1)), k(` Debug info - resolved options: ${JSON.stringify(_e(n.data))}`, "debug"), k(" Setup complete! Ready to process your documentation.", "info"), n.data;
334
375
  }
335
376
  function Y(e, t) {
377
+ return Object.fromEntries(Object.entries(t).filter(([t]) => e.getOptionValueSource(t) !== "default"));
378
+ }
379
+ function X(e, t) {
336
380
  for (let n of t) e.addOption(n);
337
381
  return e;
338
382
  }
339
383
  //#endregion
340
384
  //#region src/lib/git.ts
341
- var X = {
385
+ var Ie = {
342
386
  debug: () => {},
343
387
  info: () => {},
344
388
  warn: (e) => {
345
- e.includes("404") || console.warn(e);
389
+ e.includes("404") || k(e, "warn");
346
390
  },
347
391
  error: (e) => {
348
- e.includes("404") || console.error(e);
392
+ e.includes("404") || k(e, "error");
349
393
  }
350
394
  };
351
- async function Ae({ username: e, token: t, branch: n }) {
352
- O(` Get infos for username '${e}'.`, "info");
353
- let r = new S({
395
+ async function Le({ username: e, token: t, branch: n }) {
396
+ k(` Get infos for username '${e}'.`, "info");
397
+ let r = new x({
354
398
  auth: t,
355
- log: X
399
+ log: Ie
356
400
  });
357
- O(" Get user infos.", "debug");
401
+ k(" Get user infos.", "debug");
358
402
  let { data: i } = await r.rest.users.getByUsername({ username: e }).catch((t) => {
359
403
  throw t.status === 404 ? /* @__PURE__ */ Error(`No GitHub user found for '${e}'.`) : t;
360
404
  });
361
- return O(" Get repositories infos.", "debug"), {
405
+ return k(" Get repositories infos.", "debug"), {
362
406
  user: i,
363
407
  repos: await r.paginate(r.rest.repos.listForUser, {
364
408
  username: e,
@@ -368,11 +412,11 @@ async function Ae({ username: e, token: t, branch: n }) {
368
412
  branch: n
369
413
  };
370
414
  }
371
- async function je({ repository: e, token: t }) {
372
- O(` Get contributors infos for repository '${e.name}'.`, "info");
373
- let n = new S({
415
+ async function Re({ repository: e, token: t }) {
416
+ k(` Get contributors infos for repository '${e.name}'.`, "info");
417
+ let n = new x({
374
418
  auth: t,
375
- log: X
419
+ log: Ie
376
420
  }), r;
377
421
  try {
378
422
  r = (await n.rest.repos.get({
@@ -380,7 +424,7 @@ async function je({ repository: e, token: t }) {
380
424
  repo: e.name
381
425
  })).data;
382
426
  } catch (t) {
383
- return O(` Failed to get repository infos for '${e.name}'. Error : ${t instanceof Error ? t.message : String(t)}`, "warn"), {
427
+ return k(` Failed to get repository infos for '${e.name}'. Error : ${N(t)}`, "warn"), {
384
428
  source: void 0,
385
429
  contributors: []
386
430
  };
@@ -397,7 +441,7 @@ async function je({ repository: e, token: t }) {
397
441
  per_page: 100
398
442
  })) i.push(...e);
399
443
  } catch (t) {
400
- return O(` Failed to get contributors infos for repository '${e.name}'. Error : ${t instanceof Error ? t.message : String(t)}`, "warn"), {
444
+ return k(` Failed to get contributors infos for repository '${e.name}'. Error : ${N(t)}`, "warn"), {
401
445
  source: r.source,
402
446
  contributors: []
403
447
  };
@@ -407,7 +451,7 @@ async function je({ repository: e, token: t }) {
407
451
  contributors: i
408
452
  };
409
453
  }
410
- function Me(e) {
454
+ function ze(e) {
411
455
  let t = /* @__PURE__ */ new Map(), n = null;
412
456
  for (let r of e.split("\n")) {
413
457
  let e = r.trim();
@@ -421,12 +465,12 @@ function Me(e) {
421
465
  }
422
466
  return t;
423
467
  }
424
- async function Ne(e, t, n) {
425
- let r = L([t]);
468
+ async function Be(e, t, n) {
469
+ let r = R([t]);
426
470
  if (!r.length) return;
427
471
  let i;
428
472
  try {
429
- i = Me(await e.raw([
473
+ i = ze(await e.raw([
430
474
  "-c",
431
475
  "core.quotePath=false",
432
476
  "log",
@@ -434,19 +478,19 @@ async function Ne(e, t, n) {
434
478
  "--name-only"
435
479
  ]));
436
480
  } catch (e) {
437
- O(` Unable to read commit history for repository '${n}'. Error : ${e instanceof Error ? e.message : String(e)}`, "warn");
481
+ k(` Unable to read commit history for repository '${n}'. Error : ${N(e)}`, "warn");
438
482
  return;
439
483
  }
440
484
  for (let e of r) {
441
- let n = i.get(_(t, e));
442
- n && Se(e, n);
485
+ let n = i.get(ee(t, e));
486
+ n && Te(e, n);
443
487
  }
444
488
  }
445
- async function Pe(e, t, n, a, o, s) {
446
- if (t.startsWith("-") || a.startsWith("-")) return O(` Refusing to clone '${e}': unsafe repository URL or branch name.`, "error"), !1;
447
- P(n, { clean: !0 });
489
+ async function Ve(e, t, n, a, o, s) {
490
+ if (t.startsWith("-") || a.startsWith("-")) return k(` Refusing to clone '${e}': unsafe repository URL or branch name.`, "error"), !1;
491
+ I(n, { clean: !0 });
448
492
  try {
449
- let c = ee({
493
+ let c = S({
450
494
  baseDir: n,
451
495
  config: [
452
496
  "maintenance.auto=false",
@@ -455,24 +499,24 @@ async function Pe(e, t, n, a, o, s) {
455
499
  ]
456
500
  });
457
501
  await c.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
458
- for (let t of o) O(` Add '${t}' to '${e}' sparse-checkout file.`, "debug"), r(v(n, ".git/info/sparse-checkout"), `${t}\n`, "utf8");
459
- return O(` Clone repository '${e}'.`, "info"), await c.pull("origin", a), s && await Ne(c, n, e), o.some((e) => e.includes("docs")) && (i(v(n, "docs"), n, { recursive: !0 }), u(v(n, "docs"), { recursive: !0 })), u(v(n, ".git"), { recursive: !0 }), !0;
502
+ for (let t of o) k(` Add '${t}' to '${e}' sparse-checkout file.`, "debug"), r(_(n, ".git/info/sparse-checkout"), `${t}\n`, "utf8");
503
+ return k(` Clone repository '${e}'.`, "info"), await c.pull("origin", a), s && await Be(c, n, e), o.some((e) => e.includes("docs")) && (i(_(n, "docs"), n, { recursive: !0 }), u(_(n, "docs"), { recursive: !0 })), u(_(n, ".git"), { recursive: !0 }), !0;
460
504
  } catch (t) {
461
- return O(` Error when cloning repository '${e}': ${t instanceof Error ? t.message : String(t)}.`, "error"), !1;
505
+ return k(` Error when cloning repository '${e}': ${N(t)}.`, "error"), !1;
462
506
  }
463
507
  }
464
508
  //#endregion
465
509
  //#region src/lib/gitlab.ts
466
- var Fe = "https://gitlab.com/api/v4";
510
+ var He = "https://gitlab.com/api/v4";
467
511
  async function Z(e, t) {
468
- let n = await fetch(`${Fe}${e}`, { headers: t ? { "PRIVATE-TOKEN": t } : {} });
512
+ let n = await fetch(`${He}${e}`, { headers: t ? { "PRIVATE-TOKEN": t } : {} });
469
513
  if (!n.ok) throw Error(`GitLab API request failed for '${e}' (status: ${n.status}).`);
470
514
  return {
471
515
  data: await n.json(),
472
516
  headers: n.headers
473
517
  };
474
518
  }
475
- async function Q(e, t) {
519
+ async function Ue(e, t) {
476
520
  let n = e.includes("?") ? "&" : "?", r = [], i = "1";
477
521
  for (; i;) {
478
522
  let a = await Z(`${e}${n}per_page=100&page=${i}`, t);
@@ -480,7 +524,7 @@ async function Q(e, t) {
480
524
  }
481
525
  return r;
482
526
  }
483
- function Ie(e) {
527
+ function We(e) {
484
528
  return {
485
529
  login: e.username ?? e.path,
486
530
  name: e.name,
@@ -489,7 +533,7 @@ function Ie(e) {
489
533
  html_url: e.web_url
490
534
  };
491
535
  }
492
- function Le(e, t) {
536
+ function Ge(e, t) {
493
537
  return {
494
538
  name: e.path,
495
539
  owner: { login: t },
@@ -503,32 +547,32 @@ function Le(e, t) {
503
547
  stargazers_count: e.star_count
504
548
  };
505
549
  }
506
- async function Re({ username: e, token: t, branch: n }) {
507
- O(` Get infos for username '${e}'.`, "info");
550
+ async function Ke({ username: e, token: t, branch: n }) {
551
+ k(` Get infos for username '${e}'.`, "info");
508
552
  let { data: r } = await Z(`/users?username=${encodeURIComponent(e)}`, t);
509
553
  if (r.length) {
510
554
  let i = r[0];
511
- t && (i = await Z(`/users/${r[0].id}`, t).then((e) => e.data).catch(() => r[0])), O(" Get repositories infos.", "debug");
512
- let a = await Q(`/users/${r[0].id}/projects`, t);
555
+ t && (i = await Z(`/users/${r[0].id}`, t).then((e) => e.data).catch(() => r[0])), k(" Get repositories infos.", "debug");
556
+ let a = await Ue(`/users/${r[0].id}/projects`, t);
513
557
  return {
514
- user: Ie(i),
515
- repos: a.map((t) => Le(t, i.username ?? e)),
558
+ user: We(i),
559
+ repos: a.map((t) => Ge(t, i.username ?? e)),
516
560
  branch: n
517
561
  };
518
562
  }
519
- O(` No GitLab user '${e}' found, trying groups.`, "debug");
563
+ k(` No GitLab user '${e}' found, trying groups.`, "debug");
520
564
  let i = await Z(`/groups/${encodeURIComponent(e)}?with_projects=false`, t).then((e) => e.data).catch(() => {
521
565
  throw Error(`No GitLab user or group found for '${e}'.`);
522
- }), a = await Q(`/groups/${encodeURIComponent(e)}/projects`, t);
566
+ }), a = await Ue(`/groups/${encodeURIComponent(e)}/projects`, t);
523
567
  return {
524
- user: Ie(i),
525
- repos: a.map((t) => Le(t, i.path ?? e)),
568
+ user: We(i),
569
+ repos: a.map((t) => Ge(t, i.path ?? e)),
526
570
  branch: n
527
571
  };
528
572
  }
529
573
  //#endregion
530
574
  //#region src/lib/fetch.ts
531
- function ze(e, t, n) {
575
+ function qe(e, t, n) {
532
576
  if (n === "gitlab") {
533
577
  let n = e.html_url ?? `https://gitlab.com/${e.owner.login}/${e.name}`;
534
578
  return {
@@ -544,11 +588,11 @@ function ze(e, t, n) {
544
588
  raw_url: `https://raw.githubusercontent.com/${e.owner.login}/${e.name}/${t}`
545
589
  };
546
590
  }
547
- async function Be(e) {
591
+ async function Je(e) {
548
592
  let [t, n, r] = await Promise.all([
549
- A(`${e.blob_url}/README.md`),
550
- A(`${e.tree_url}/docs`),
551
- A(`${e.blob_url}/docs/01-readme.md`)
593
+ j(`${e.blob_url}/README.md`),
594
+ j(`${e.tree_url}/docs`),
595
+ j(`${e.blob_url}/docs/01-readme.md`)
552
596
  ]);
553
597
  return {
554
598
  rootReadmeStatus: t,
@@ -556,19 +600,19 @@ async function Be(e) {
556
600
  docsReadmeStatus: r
557
601
  };
558
602
  }
559
- async function Ve({ username: e, branch: t, reposFilter: n, gitProvider: r, token: i, lastUpdated: a, multiUser: o }) {
560
- let { user: s, repos: c, branch: l } = await (r === "gitlab" ? Re : Ae)({
603
+ async function Ye({ username: e, branch: t, reposFilter: n, gitProvider: r, token: i, lastUpdated: a, multiUser: o }) {
604
+ let { user: s, repos: c, branch: l } = await (r === "gitlab" ? Ke : Le)({
561
605
  username: e,
562
606
  token: i,
563
607
  branch: t
564
- }), { repos: u } = await We(s, c, l, n, r, o ? `${j(e)}/` : "");
565
- await Ge(u, n, a);
608
+ }), { repos: u } = await Qe(s, c, l, n, r, o ? `${M(e)}/` : "");
609
+ await $e(u, n, a);
566
610
  }
567
- async function He(e, t, n, r, i = "") {
611
+ async function Xe(e, t, n, r, i = "") {
568
612
  let a = [];
569
613
  return await Promise.all(e.map(async (e) => {
570
- let o = t ?? e.default_branch ?? "main", s = v(ae, `${i}${N(j(e.name), { removeDot: !0 })}`), c = Ke(e, n), l = ze(e, o, r), u = [];
571
- !e.fork && !e.private && !c && (u = await Ue(e, o, r, l)), a.push({
614
+ let o = t ?? e.default_branch ?? "main", s = _(ae, `${i}${F(M(e.name), { removeDot: !0 })}`), c = et(e, n), l = qe(e, o, r), u = [];
615
+ !e.fork && !e.private && !c && (u = await Ze(e, o, r, l)), a.push({
572
616
  ...e,
573
617
  docpress: {
574
618
  filtered: c,
@@ -582,76 +626,85 @@ async function He(e, t, n, r, i = "") {
582
626
  });
583
627
  })), a;
584
628
  }
585
- async function Ue(e, t, n, r) {
586
- let i = await Be(r ?? ze(e, t, n)), a = [];
629
+ async function Ze(e, t, n, r) {
630
+ let i = await Je(r ?? qe(e, t, n)), a = [];
587
631
  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);
588
632
  }
589
- async function We(e, t, n, r, i, a = "") {
590
- f(`${C}/user-${j(e.login)}.json`, JSON.stringify(e, null, 2));
591
- let o = await He(t, n, r, i, a);
592
- return f(`${C}/repos-${j(e.login)}.json`, JSON.stringify(o, null, 2)), {
633
+ async function Qe(e, t, n, r, i, a = "") {
634
+ f(`${C}/user-${M(e.login)}.json`, JSON.stringify(e, null, 2));
635
+ let o = await Xe(t, n, r, i, a);
636
+ return f(`${C}/repos-${M(e.login)}.json`, JSON.stringify(o, null, 2)), {
593
637
  user: e,
594
638
  repos: o
595
639
  };
596
640
  }
597
- async function Ge(e, t, n) {
641
+ async function $e(e, t, n) {
598
642
  if (!e) {
599
- O(" No repository respect docpress rules.", "warn");
643
+ k(" No repositories to process.", "warn");
600
644
  return;
601
645
  }
602
- let r = (await Promise.all(e.filter((e) => !Ke(e, t)).map(async (e) => {
603
- let t = await Pe(e.name, e.clone_url, e.docpress.projectPath, e.docpress.branch, e.docpress.includes, n);
646
+ let r = await Promise.all(e.filter((e) => !et(e, t)).map(async (e) => {
647
+ let t = await Ve(e.name, e.clone_url, e.docpress.projectPath, e.docpress.branch, e.docpress.includes, n);
604
648
  return {
605
649
  name: e.name,
606
650
  success: t
607
651
  };
608
- }))).filter(({ success: e }) => !e).map(({ name: e }) => e);
609
- r.length && O(` ${r.length} repository(ies) failed to clone: ${r.join(", ")}.`, "warn");
652
+ }));
653
+ if (!r.length) {
654
+ k(" No repository matched the current filters.", "warn");
655
+ return;
656
+ }
657
+ let i = r.filter(({ success: e }) => !e).map(({ name: e }) => e), a = r.length - i.length;
658
+ i.length ? k(` Cloned ${a}/${r.length} repository(ies), ${i.length} failed: ${i.join(", ")}.`, "warn") : k(` Cloned ${a}/${r.length} repository(ies).`, "success");
610
659
  }
611
- function Ke(e, t) {
660
+ function et(e, t) {
612
661
  if ("docpress" in e && !e.docpress.includes.length) return !0;
613
662
  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;
614
663
  return !(e.clone_url && !e.private && !o);
615
664
  }
616
665
  //#endregion
617
666
  //#region src/commands/global.ts
618
- var $ = [
619
- n("-C, --config <string>", K.shape.config.description),
620
- n("-T, --token <string>", K.shape.token.description),
621
- n("-U, --usernames <string>", K.shape.usernames.description)
622
- ], qe = "fetch", Je = [
623
- n("-b, --branch <string>", G.shape.branch.description),
624
- n("-g, --git-provider <string>", G.shape.gitProvider.description).default(G.shape.gitProvider.def.defaultValue),
625
- n("-l, --last-updated", G.shape.lastUpdated.description),
626
- n("-r, --repos-filter <string>", G.shape.reposFilter.description)
627
- ], Ye = Y(t(qe), [...Je, ...$]).description("Fetch docs with the given username(s) and git provider.").action(async (e, t) => {
628
- await Xe(q(qe, J(t, e)));
667
+ var Q = [
668
+ n("-C, --config <string>", q.shape.config.description),
669
+ n("--log-level <string>", q.shape.logLevel.description),
670
+ n("-T, --token <string>", q.shape.token.description),
671
+ n("-U, --usernames <string>", q.shape.usernames.description)
672
+ ], tt = "fetch", nt = [
673
+ n("-b, --branch <string>", K.shape.branch.description),
674
+ n("-g, --git-provider <string>", K.shape.gitProvider.description).default(K.shape.gitProvider.def.defaultValue),
675
+ n("-l, --last-updated", K.shape.lastUpdated.description),
676
+ n("-r, --repos-filter <string>", K.shape.reposFilter.description)
677
+ ], rt = X(t(tt), [...nt, ...Q]).description("Fetch docs with the given username(s) and git provider.").action(async (e, t) => {
678
+ await it(J(tt, Y(t, e)));
629
679
  });
630
- async function Xe(e) {
680
+ async function it(e) {
631
681
  let { usernames: t, reposFilter: n, token: r, branch: i, gitProvider: a, lastUpdated: o } = e;
632
- O("\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.", "info"), P(C, { clean: !0 });
633
- let s = [];
682
+ k("\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.", "info");
683
+ let s = Date.now();
684
+ I(C, { clean: !0 });
685
+ let c = [];
634
686
  for (let e of t) {
635
- let c = t.length > 1 ? n?.filter((t) => t.replace(/^!/, "").startsWith(`${e}/`)).map((t) => t.replace(`${e}/`, "")) : n;
687
+ let s = t.length > 1 ? n?.filter((t) => t.replace(/^!/, "").startsWith(`${e}/`)).map((t) => t.replace(`${e}/`, "")) : n;
636
688
  try {
637
- await Ve({
689
+ await Ye({
638
690
  username: e,
639
691
  branch: i,
640
- reposFilter: c,
692
+ reposFilter: s,
641
693
  gitProvider: a,
642
694
  token: r,
643
695
  lastUpdated: o,
644
696
  multiUser: t.length > 1
645
697
  });
646
698
  } catch (t) {
647
- s.push(e), O(` Failed to fetch documentation for '${e}': ${t instanceof Error ? t.message : String(t)}`, "error");
699
+ c.push(e), k(` Failed to fetch documentation for '${e}': ${N(t)}`, "error");
648
700
  }
649
701
  }
650
- if (s.length === t.length) throw Error(`Failed to fetch documentation for all requested username(s): ${s.join(", ")}.`);
702
+ if (c.length === t.length) throw Error(`Failed to fetch documentation for all requested username(s): ${c.join(", ")}.`);
703
+ k(` Fetched documentation for ${t.length - c.length}/${t.length} username(s) in ${P(Date.now() - s)}.`, c.length ? "warn" : "success");
651
704
  }
652
705
  //#endregion
653
706
  //#region src/commands/build.ts
654
- async function Ze(e) {
707
+ async function at(e) {
655
708
  let t = console.warn;
656
709
  console.warn = function(...e) {
657
710
  e.length > 0 && typeof e[0] == "string" && (e[0].includes("[Vue warn]: Invalid watch source:") || e[0].includes("{ open: false }")) || t.apply(console, e);
@@ -662,30 +715,32 @@ async function Ze(e) {
662
715
  console.warn = t;
663
716
  }
664
717
  }
665
- var Qe = Y(t("build"), $).description("Build vitepress website.").action(async (e) => {
666
- await $e();
718
+ var ot = X(t("build"), Q).description("Build vitepress website.").action(async (e) => {
719
+ await st();
667
720
  });
668
- async function $e() {
669
- O("\n-> Start building Vitepress website.\n\n", "info");
721
+ async function st() {
722
+ k("\n-> Start building Vitepress website.\n\n", "info");
723
+ let e = Date.now();
670
724
  try {
671
- await Ze(async () => {
725
+ await at(async () => {
672
726
  await te(C, { onAfterConfigResolve(e) {
673
727
  ne(e);
674
728
  } });
675
- }), O("\n\nDocpress build succeeded.", "success");
729
+ });
676
730
  } catch (e) {
677
- O(`\n\nDocpress build failed : ${e}`, "error"), process.exit(1);
731
+ throw Error(`Docpress build failed: ${N(e)}`);
678
732
  }
733
+ k(`\n\nDocpress build succeeded in ${P(Date.now() - e)}.`, "success");
679
734
  }
680
735
  //#endregion
681
736
  //#region src/utils/templates.ts
682
- function et(e, t) {
737
+ function ct(e, t) {
683
738
  let n = s(e, { encoding: "utf8" });
684
- P(m(t)), f(t, n);
739
+ I(m(t)), f(t, n);
685
740
  }
686
741
  //#endregion
687
742
  //#region src/lib/vitepress.ts
688
- var tt = {
743
+ var lt = {
689
744
  base: "/",
690
745
  lang: "en-US",
691
746
  vite: { publicDir: "../public" },
@@ -718,21 +773,24 @@ var tt = {
718
773
  }
719
774
  }
720
775
  };
721
- function nt(e, t, n) {
722
- return n ? R(tt, n, { themeConfig: {
776
+ function ut(e, t, n) {
777
+ return n ? B(lt, n, { themeConfig: {
723
778
  sidebar: e,
724
779
  nav: t
725
- } }) : R(tt, { themeConfig: {
780
+ } }) : B(lt, { themeConfig: {
726
781
  sidebar: e,
727
782
  nav: t
728
783
  } });
729
784
  }
730
785
  //#endregion
731
786
  //#region src/lib/prepare.ts
732
- async function rt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, vitepressConfig: r, forks: i, gitProvider: o, lastUpdated: s, token: c, username: l, websiteTitle: u, websiteTagline: d }) {
733
- let f = i && o !== "gitlab";
734
- i && !f && O(" The forks page is not supported with the 'gitlab' provider, skipping.", "warn");
735
- let p = ve(l), m = ye(l).reduce(({ internals: e, forks: t }, n) => {
787
+ function dt(e) {
788
+ return e === null ? {} : { collapsed: e };
789
+ }
790
+ async function ft({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, vitepressConfig: r, forks: i, gitProvider: o, lastUpdated: s, sidebarMode: c, sidebarCollapsed: l, token: u, username: d, websiteTitle: f, websiteTagline: p }) {
791
+ let m = i && o !== "gitlab";
792
+ i && !m && k(" The forks page is not supported with the 'gitlab' provider, skipping.", "warn");
793
+ let h = be(d), g = xe(d).reduce(({ internals: e, forks: t }, n) => {
736
794
  let { clone_url: r, private: i, fork: a, docpress: o } = n;
737
795
  if (r && !i && !o.filtered) {
738
796
  if (!a && o.includes.length) return {
@@ -751,39 +809,43 @@ async function rt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, v
751
809
  }, {
752
810
  internals: [],
753
811
  forks: []
754
- }), h = {
755
- title: u,
756
- tagline: d
757
- }, { index: g, sidebar: _ } = ft(m.internals, p, h), y, b;
812
+ }), ee = {
813
+ title: f,
814
+ tagline: p
815
+ }, { index: v, sidebar: y } = wt(g.internals, h, ee, {
816
+ mode: c,
817
+ collapsed: l
818
+ }), b, x;
758
819
  if (a(w) && a(T)) {
759
- let e = await _t(T), t = await vt(w);
760
- y = [...e.themeConfig?.sidebar ?? [], ..._].sort((e, t) => e.text.localeCompare(t.text)), b = {
761
- ...g,
762
- features: [...t.features, ...g.features].sort((e, t) => e.title.localeCompare(t.title))
820
+ let e = await kt(T), t = await At(w);
821
+ b = St(e.themeConfig?.sidebar, y), x = {
822
+ ...v,
823
+ features: [...t.features, ...v.features].sort((e, t) => e.title.localeCompare(t.title))
763
824
  };
764
- } else y = _, b = g;
765
- let x = [];
825
+ } else b = y, x = v;
826
+ let S = [];
766
827
  if (e) {
767
- let t = pt(e);
768
- f ? x.push(...t.filter((e) => e.link !== "/forks")) : x.push(...t);
828
+ let t = Tt(e);
829
+ m ? S.push(...t.filter((e) => e.link !== "/forks")) : S.push(...t);
769
830
  }
770
- t && (O(" Add extras Vitepress public folder content.", "info"), mt(t, v(C, "public"))), n && (O(" Add extras Vitepress theme files.", "info"), mt(n, v(ce))), f && l.length && (O(" Add fork page to display external contributions.", "info"), await gt(m.forks, l, c), x.push({
831
+ t && (k(" Add extras Vitepress public folder content.", "info"), Et(t, _(C, "public"))), n && (k(" Add extras Vitepress theme files.", "info"), Et(n, _(ce))), m && d.length && (k(" Add fork page to display external contributions.", "info"), await Ot(g.forks, d, u), S.push({
771
832
  text: "Forks",
772
833
  link: "/forks"
773
834
  }));
774
- let S = s ? {
835
+ let te = s ? {
775
836
  lastUpdated: !0,
776
837
  ...r
777
838
  } : r;
778
- yt(nt(y, x, S), b);
839
+ jt(ut(b, S, te), x);
779
840
  }
780
- function it(e, t) {
781
- r(t, `${N(p(t), {
841
+ function pt(e, t) {
842
+ let n = `${F(p(t), {
782
843
  mode: "lowercase",
783
844
  removeIdx: !0
784
- }) === "readme.md" ? "\n## Sources" : "# Sources"}\n\nTake a look at the [project sources](${e}).\n`, "utf8");
845
+ }) === "readme.md" ? "\n## Sources" : "# Sources"}\n\nTake a look at the [project sources](${e}).\n`;
846
+ r(t, n, "utf8");
785
847
  }
786
- function at(e, t, n) {
848
+ function mt(e, t, n) {
787
849
  let { name: r, login: i, bio: a } = t, { title: o, tagline: s } = n;
788
850
  return {
789
851
  layout: "home",
@@ -797,107 +859,131 @@ function at(e, t, n) {
797
859
  features: e
798
860
  };
799
861
  }
800
- function ot(e, t, n, r = "") {
862
+ function ht(e, t, n, r = "") {
801
863
  let i = {
802
- title: N(e, {
864
+ title: F(e, {
803
865
  mode: "capitalize",
804
866
  replaceDash: !0
805
867
  }),
806
868
  details: t,
807
- link: `/${r}${N(e, { removeDot: !0 })}/introduction`
869
+ link: `/${r}${F(e, { removeDot: !0 })}/introduction`
808
870
  };
809
871
  return n ? [...n, i] : [i];
810
872
  }
811
- function st(e, t) {
873
+ function gt(e, t, n = !0) {
812
874
  return {
813
- text: N(e, {
875
+ text: F(e, {
814
876
  mode: "capitalize",
815
877
  replaceDash: !0
816
878
  }),
817
- collapsed: !0,
879
+ ...dt(n),
818
880
  items: t
819
881
  };
820
882
  }
821
- function ct(e, t) {
822
- return Object.entries(t).flatMap(([t, n]) => t === "$" ? Array.isArray(n) ? n.map((t) => {
823
- let n = v(e.docpress.projectPath, t), r = N(p(n), {
883
+ function _t(e, t, n = !0) {
884
+ return Object.entries(t).flatMap(([t, r]) => t === "$" ? Array.isArray(r) ? r.map((t) => {
885
+ let n = _(e.docpress.projectPath, t), r = F(p(n), {
824
886
  mode: "lowercase",
825
887
  removeIdx: !0
826
888
  });
827
- return r === "readme.md" && (r = "introduction.md"), r !== p(n) && l(n, v(m(n), r)), {
828
- text: g(r).name === "introduction" ? "Introduction" : N(r, {
889
+ return r === "readme.md" && (r = "introduction.md"), r !== p(n) && l(n, _(m(n), r)), {
890
+ text: g(r).name === "introduction" ? "Introduction" : F(r, {
829
891
  mode: "capitalize",
830
892
  replaceDash: !0,
831
893
  removeExt: !0
832
894
  }),
833
- link: `/${e.docpress.routePrefix ?? ""}${N(e.name, { removeDot: !0 })}/${g(r).name}`
895
+ link: `/${e.docpress.routePrefix ?? ""}${F(e.name, { removeDot: !0 })}/${g(r).name}`
834
896
  };
835
- }) : [] : typeof n == "object" ? [{
836
- text: N(t, {
897
+ }) : [] : typeof r == "object" ? [{
898
+ text: F(t, {
837
899
  mode: "capitalize",
838
900
  replaceDash: !0
839
901
  }),
840
- collapsed: !0,
841
- items: ct({
902
+ ...dt(n),
903
+ items: _t({
842
904
  ...e,
843
- name: `${e.name}/${t}`
844
- }, n)
905
+ name: `${e.name}/${t}`,
906
+ docpress: {
907
+ ...e.docpress,
908
+ projectPath: _(e.docpress.projectPath, t)
909
+ }
910
+ }, r, n)
845
911
  }] : []);
846
912
  }
847
- function lt(e) {
913
+ function vt(e) {
848
914
  return e.reduce((e, t) => {
849
915
  let [n, ...r] = t.split("/");
850
- return r.length ? e[n] = lt([...e[n] ? ut(e[n], "") : [], r.join("/")]) : e.$ = [...e.$ || [], n], e;
916
+ return r.length ? e[n] = vt([...e[n] ? $(e[n], "") : [], r.join("/")]) : e.$ = [...e.$ || [], n], e;
851
917
  }, {});
852
918
  }
853
- function ut(e, t = "") {
854
- return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] : ut(n, t ? `${t}/${e}` : e));
919
+ function $(e, t = "") {
920
+ return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] : $(n, t ? `${t}/${e}` : e));
855
921
  }
856
- function dt(e) {
922
+ function yt(e) {
857
923
  if (!Array.isArray(e)) return e;
858
924
  let t = e.findIndex((e) => e.text === "Sources");
859
925
  if (t === -1) return e;
860
926
  let [n] = e.splice(t, 1);
861
927
  return e.push(n), e;
862
928
  }
863
- function ft(e, t, n) {
864
- let r = [], i = [];
929
+ var bt = 5;
930
+ function xt(e, t, n = []) {
931
+ return e.flatMap((e) => {
932
+ if (!("items" in e) || !e.items?.length) return [];
933
+ let r = [...n, e.text];
934
+ return t >= bt ? [r.join("/")] : xt(e.items, t + 1, r);
935
+ });
936
+ }
937
+ function St(e, t) {
938
+ if (!e) return t;
939
+ if (Array.isArray(e) && Array.isArray(t)) return [...e, ...t].toSorted((e, t) => (e.text ?? "").localeCompare(t.text ?? ""));
940
+ let n = (e) => Array.isArray(e) ? { "/": e } : e;
941
+ return Ct({
942
+ ...n(e),
943
+ ...n(t)
944
+ });
945
+ }
946
+ function Ct(e) {
947
+ return Object.fromEntries(Object.entries(e).toSorted(([e], [t]) => e.localeCompare(t)));
948
+ }
949
+ function wt(e, t, n, r = {}) {
950
+ let { mode: i = "single", collapsed: a = !0 } = r, o = [], s = [], l = {};
865
951
  for (let t of e) {
866
- O(` Replace urls for repository '${t.name}'.`, "info"), L([t.docpress.projectPath]).forEach((e) => {
867
- O(` Processing file '${p(e)}' for repository '${t.name}'.`, "debug"), xe(e, t.docpress.replace_url), p(e).toLowerCase() === "readme.md" && we(e, t.docpress.replace_url), Ce(e);
868
- }), O(` Generate sidebar for repository '${t.name}'.`, "info");
952
+ k(` Replace urls for repository '${t.name}'.`, "info"), R([t.docpress.projectPath]).forEach((e) => {
953
+ k(` Processing file '${p(e)}' for repository '${t.name}'.`, "debug"), we(e, t.docpress.replace_url), p(e).toLowerCase() === "readme.md" && De(e, t.docpress.replace_url), Ee(e);
954
+ }), k(` Generate sidebar for repository '${t.name}'.`, "info");
869
955
  let e = c(t.docpress.projectPath, { recursive: !0 }).filter((e) => {
870
- let n = v(t.docpress.projectPath, e.toString());
871
- return p(n).endsWith(".md") && F(n);
956
+ let n = _(t.docpress.projectPath, e.toString());
957
+ return p(n).endsWith(".md") && ye(n);
872
958
  }).sort();
873
- O(` Add sources for repository '${t.name}'.`, "info");
959
+ k(` Add sources for repository '${t.name}'.`, "info");
874
960
  let n;
875
- e.length > 1 ? (n = v(t.docpress.projectPath, "sources.md"), e.push("sources.md")) : e.length === 1 && (n = v(t.docpress.projectPath, e[0])), n ? it(t.html_url, n) : O(` No markdown files found for repository '${t.name}', skipping sources.`, "warn");
876
- let a = dt(ct(t, lt(e)));
877
- i.push(st(N(t.name, { removeDot: !0 }), a)), r.push(...ot(N(t.name, { removeDot: !0 }), t.description || "", void 0, t.docpress.routePrefix ?? ""));
961
+ e.length > 1 ? (n = _(t.docpress.projectPath, "sources.md"), e.push("sources.md")) : e.length === 1 && (n = _(t.docpress.projectPath, e[0])), n ? pt(t.html_url, n) : k(` No markdown files found for repository '${t.name}', skipping sources.`, "warn");
962
+ let r = yt(_t(t, vt(e), a)), u = xt(r, i === "multi" ? 0 : 1);
963
+ u.length && k(` Sidebar for repository '${t.name}' nests deeper than Vitepress renders, pages under ${u.map((e) => `'${e}'`).join(", ")} will not appear in the sidebar.`, "warn"), i === "multi" ? l[`/${t.docpress.routePrefix ?? ""}${F(t.name, { removeDot: !0 })}/`] = r : s.push(gt(F(t.name, { removeDot: !0 }), r, a)), o.push(...ht(F(t.name, { removeDot: !0 }), t.description || "", void 0, t.docpress.routePrefix ?? ""));
878
964
  }
879
- O(" Generate index content.", "info");
880
- let a = at(r.toSorted((e, t) => e.title.localeCompare(t.title)), t, n);
965
+ k(" Generate index content.", "info");
966
+ let u = mt(o.toSorted((e, t) => e.title.localeCompare(t.title)), t, n);
881
967
  return {
882
- sidebar: i.toSorted((e, t) => e.text.localeCompare(t.text)),
883
- index: a
968
+ sidebar: i === "multi" ? Ct(l) : s.toSorted((e, t) => e.text.localeCompare(t.text)),
969
+ index: u
884
970
  };
885
971
  }
886
- function pt(e) {
887
- let t = L(e), n = [];
888
- O(" Add extras Vitepress headers pages.", "info");
972
+ function Tt(e) {
973
+ let t = R(e), n = [];
974
+ k(" Add extras Vitepress headers pages.", "info");
889
975
  for (let e of t) {
890
- O(` Processing file '${e}'.`, "debug");
891
- let t = v(process.cwd(), e);
892
- i(t, v(ae, N(p(e), {
976
+ k(` Processing file '${e}'.`, "debug");
977
+ let t = _(process.cwd(), e), r = _(ae, F(p(e), {
893
978
  mode: "lowercase",
894
979
  removeIdx: !0
895
- }))), n.push({
896
- text: N(g(t).name, {
980
+ }));
981
+ i(t, r), n.push({
982
+ text: F(g(t).name, {
897
983
  replaceDash: !0,
898
984
  removeIdx: !0
899
985
  }),
900
- link: `/${N(g(t).name, {
986
+ link: `/${F(g(t).name, {
901
987
  removeIdx: !0,
902
988
  mode: "lowercase"
903
989
  })}`
@@ -905,18 +991,18 @@ function pt(e) {
905
991
  }
906
992
  return n;
907
993
  }
908
- function mt(e, t, n) {
994
+ function Et(e, t, n) {
909
995
  for (let r of Array.isArray(e) ? e : [e]) {
910
- let e = v(process.cwd(), r), a = I(e);
996
+ let e = _(process.cwd(), r), a = L(e);
911
997
  for (let o of a) {
912
998
  let a = o.replace(e, ".");
913
- O(` Processing file '${a}' for entry '${r}'.`, "debug");
914
- let s = v(process.cwd(), o), c = v(t, a);
999
+ k(` Processing file '${a}' for entry '${r}'.`, "debug");
1000
+ let s = _(process.cwd(), o), c = _(t, a);
915
1001
  n && n(), i(s, c);
916
1002
  }
917
1003
  }
918
1004
  }
919
- function ht(e) {
1005
+ function Dt(e) {
920
1006
  let t = e.map(({ repository: e, contributions: t }) => {
921
1007
  let { name: n, owner: r, html_url: i, description: a, stargazers_count: o } = e;
922
1008
  return {
@@ -928,11 +1014,11 @@ function ht(e) {
928
1014
  contributions: t
929
1015
  };
930
1016
  });
931
- O(" Generate forks page.", "info"), f(oe, "---\nlayout: fork-page\nrepoList:\n" + y.stringify(t) + "---\n\n# External contributions\n\nThis gallery is a visual representation of the collaborative work done across a variety of open-source projects, each driven by a shared passion for innovation and community growth.\n\nEvery tile below represents a unique project where contributions have been made-ranging from code enhancements to documentation improvements. Each project includes a summary of its goals, features, and links to GitHub for direct access.\n\nThis page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.\n");
1017
+ k(" Generate forks page.", "info"), f(oe, "---\nlayout: fork-page\nrepoList:\n" + v.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");
932
1018
  }
933
- async function gt(e, t, n) {
934
- ht(await Promise.all(e.map(async (e) => {
935
- let { source: r, contributors: i } = await je({
1019
+ async function Ot(e, t, n) {
1020
+ Dt(await Promise.all(e.map(async (e) => {
1021
+ let { source: r, contributors: i } = await Re({
936
1022
  repository: e,
937
1023
  token: n
938
1024
  });
@@ -942,76 +1028,93 @@ async function gt(e, t, n) {
942
1028
  };
943
1029
  })).then((e) => e.filter(({ repository: e, contributions: t }) => !!e && t)));
944
1030
  }
945
- async function _t(e) {
1031
+ async function kt(e) {
946
1032
  try {
947
- let { config: t } = await import(v(process.cwd(), e));
1033
+ let { config: t } = await import(_(process.cwd(), e));
948
1034
  return t ?? {};
949
1035
  } catch (t) {
950
- return O(` Unable to load existing Vitepress config '${e}', starting from an empty config. ${t instanceof Error ? t.message : ""}`, "warn"), {};
1036
+ return k(` Unable to load existing Vitepress config '${e}', starting from an empty config. ${N(t)}`, "warn"), {};
951
1037
  }
952
1038
  }
953
- async function vt(e) {
954
- let t = (await re(v(process.cwd(), e))).toString();
955
- return y.parse(t);
956
- }
957
- function yt(e, t) {
958
- return P(m(T)), O(" Generate Vitepress config.", "info"), f(T, `export const config = ${JSON.stringify(e, null, 2)}\n\nexport default config\n`), O(" Generate index file.", "info"), f(w, "---\n" + y.stringify(t)), O(" Add Docpress theme files.", "info"), I(le).forEach((e) => {
959
- et(e, v(se, e.replace(`${le}/`, "")));
1039
+ async function At(e) {
1040
+ let t = (await re(_(process.cwd(), e))).toString();
1041
+ return v.parse(t);
1042
+ }
1043
+ function jt(e, t) {
1044
+ I(m(T)), k(" Generate Vitepress config.", "info"), f(T, `export const config = ${JSON.stringify(e, null, 2)}\n\nexport default config\n`), k(" Generate index file.", "info"), f(w, "---\n" + v.stringify(t));
1045
+ let n = L(E);
1046
+ if (!n.length) throw Error(`No template theme files found at '${E}'. The Vitepress build cannot succeed without them.`);
1047
+ k(" Add Docpress theme files.", "info"), n.forEach((e) => {
1048
+ let t = e.replace(`${E}/`, "");
1049
+ ct(e, _(se, t));
960
1050
  });
961
1051
  }
962
1052
  //#endregion
963
1053
  //#region src/commands/prepare.ts
964
- var bt = "prepare", xt = [
965
- n("-c, --extra-public-content <string>", G.shape.extraPublicContent.description),
966
- n("-f, --forks", G.shape.forks.description),
967
- n("-p, --extra-header-pages <string>", G.shape.extraHeaderPages.description),
968
- n("-t, --extra-theme <string>", G.shape.extraTheme.description),
969
- n("-v, --vitepress-config <string>", G.shape.vitepressConfig.description),
970
- n("--website-title <string>", G.shape.websiteTitle.description),
971
- n("--website-tagline <string>", G.shape.websiteTagline.description)
972
- ], St = Y(t(bt), [...xt, ...$]).description("Transform doc to the target vitepress format.").action(async (e, t) => {
973
- await Ct(q(bt, J(t, e)));
1054
+ var Mt = "prepare", Nt = [
1055
+ n("-c, --extra-public-content <string>", K.shape.extraPublicContent.description),
1056
+ n("-f, --forks", K.shape.forks.description),
1057
+ n("-p, --extra-header-pages <string>", K.shape.extraHeaderPages.description),
1058
+ n("-t, --extra-theme <string>", K.shape.extraTheme.description),
1059
+ n("--sidebar-mode <string>", K.shape.sidebarMode.description),
1060
+ n("--sidebar-collapsed <string>", K.shape.sidebarCollapsed.description),
1061
+ n("-v, --vitepress-config <string>", K.shape.vitepressConfig.description),
1062
+ n("--website-title <string>", K.shape.websiteTitle.description),
1063
+ n("--website-tagline <string>", K.shape.websiteTagline.description)
1064
+ ], Pt = X(t(Mt), [...Nt, ...Q]).description("Transform doc to the target vitepress format.").action(async (e, t) => {
1065
+ await Ft(J(Mt, Y(t, e)));
974
1066
  });
975
- async function Ct(e) {
976
- let { extraHeaderPages: t, extraPublicContent: n, extraTheme: r, vitepressConfig: i, forks: a, gitProvider: o, lastUpdated: s, token: c, usernames: l, websiteTitle: u, websiteTagline: d } = e;
977
- O("\n-> Start transform files to prepare Vitepress build.", "info"), P(m(T), { clean: !0 });
978
- for (let e of l) await rt({
979
- extraHeaderPages: t,
980
- extraPublicContent: n,
981
- extraTheme: r,
982
- vitepressConfig: i,
983
- forks: a,
984
- gitProvider: o,
985
- lastUpdated: s,
986
- token: c,
987
- username: e,
988
- websiteTitle: u,
989
- websiteTagline: d
990
- });
1067
+ async function Ft(e) {
1068
+ let { extraHeaderPages: t, extraPublicContent: n, extraTheme: r, vitepressConfig: i, forks: a, gitProvider: o, lastUpdated: s, sidebarMode: c, sidebarCollapsed: l, token: u, usernames: d, websiteTitle: f, websiteTagline: p } = e;
1069
+ k("\n-> Start transform files to prepare Vitepress build.", "info");
1070
+ let h = Date.now();
1071
+ I(m(T), { clean: !0 });
1072
+ let g = [];
1073
+ for (let e of d) try {
1074
+ await ft({
1075
+ extraHeaderPages: t,
1076
+ extraPublicContent: n,
1077
+ extraTheme: r,
1078
+ vitepressConfig: i,
1079
+ forks: a,
1080
+ gitProvider: o,
1081
+ lastUpdated: s,
1082
+ sidebarMode: c,
1083
+ sidebarCollapsed: l,
1084
+ token: u,
1085
+ username: e,
1086
+ websiteTitle: f,
1087
+ websiteTagline: p
1088
+ });
1089
+ } catch (t) {
1090
+ g.push(e), k(` Failed to prepare documentation for '${e}': ${N(t)}`, "error");
1091
+ }
1092
+ if (g.length === d.length) throw Error(`Failed to prepare documentation for all requested username(s): ${g.join(", ")}.`);
1093
+ k(` Prepared documentation for ${d.length - g.length}/${d.length} username(s) in ${P(Date.now() - h)}.`, g.length ? "warn" : "success");
991
1094
  }
992
1095
  //#endregion
993
1096
  //#region src/cli.ts
994
- function wt() {
1097
+ function It() {
995
1098
  let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${ie.version}`).action(async (e, t) => {
996
- let n = q("global", J(t, e));
997
- await Xe(n), await Ct(n), await $e();
1099
+ let n = J("global", Y(t, e));
1100
+ await it(n), await Ft(n), await st();
998
1101
  }).configureHelp({
999
1102
  sortSubcommands: !0,
1000
1103
  sortOptions: !0,
1001
1104
  showGlobalOptions: !0
1002
- }).enablePositionalOptions().passThroughOptions().addCommand(Ye).addCommand(St).addCommand(Qe);
1003
- return Y(t, [
1004
- ...Je,
1005
- ...xt,
1006
- ...$
1105
+ }).enablePositionalOptions().passThroughOptions().addCommand(rt).addCommand(Pt).addCommand(ot);
1106
+ return X(t, [
1107
+ ...nt,
1108
+ ...Nt,
1109
+ ...Q
1007
1110
  ]), t;
1008
1111
  }
1009
- function Tt() {
1010
- wt().parseAsync(process.argv).catch((e) => {
1011
- O(`\n${e instanceof Error ? e.message : String(e)}`, "error"), process.exit(1);
1112
+ function Lt() {
1113
+ It().parseAsync(process.argv).catch((e) => {
1114
+ k(`\n${N(e)}`, "error"), process.exit(1);
1012
1115
  });
1013
1116
  }
1014
1117
  //#endregion
1015
- export { wt as getProgram, Tt as main };
1118
+ export { It as getProgram, Lt as main };
1016
1119
 
1017
1120
  //# sourceMappingURL=cli.js.map