@tobi-or-not/docpress 0.13.5 → 0.13.6

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