@tobi-or-not/docpress 0.10.1 → 0.10.2

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