@tobi-or-not/docpress 0.7.3 → 0.7.5

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,22 +1,22 @@
1
- import { createOption as m, createCommand as J, Command as ke } from "commander";
2
- import { readFileSync as C, existsSync as O, mkdirSync as Pe, readdirSync as ue, statSync as z, appendFileSync as le, cpSync as B, rmSync as Z, writeFileSync as $, renameSync as Ee } from "node:fs";
3
- import { resolve as u, basename as y, join as Fe, dirname as A, parse as _ } from "node:path";
1
+ import { createOption as m, createCommand as J, Command as Pe } from "commander";
2
+ import { readFileSync as C, existsSync as O, mkdirSync as ke, writeFileSync as v, readdirSync as ue, statSync as z, appendFileSync as le, cpSync as B, rmSync as Z, renameSync as Ee } from "node:fs";
3
+ import { resolve as u, basename as y, join as Fe, dirname as _, parse as R } from "node:path";
4
4
  import Te from "axios";
5
5
  import { rimrafSync as Oe } from "rimraf";
6
6
  import ee from "chalk";
7
- import { fromError as _e } from "zod-validation-error";
7
+ import { fromError as Re } from "zod-validation-error";
8
8
  import { z as l } from "zod";
9
9
  import { Octokit as de } from "@octokit/rest";
10
- import { simpleGit as Ae } from "simple-git";
11
- import { build as Re } from "vitepress";
10
+ import { simpleGit as _e } from "simple-git";
11
+ import { build as Ae } from "vitepress";
12
12
  import { readFile as Ie } from "node:fs/promises";
13
13
  import q from "yaml";
14
- const je = "0.7.3", Le = {
14
+ const je = "0.7.5", Le = {
15
15
  version: je
16
16
  }, S = u(process.cwd(), "docpress");
17
17
  u(process.cwd(), "docpress/repositories.json");
18
18
  u(process.cwd(), "docpress/owner.json");
19
- const pe = u(process.cwd(), "docpress/docs"), M = u(process.cwd(), "docpress/docs/index.md"), Ve = u(process.cwd(), "docpress/docs/forks.md"), E = u(process.cwd(), "docpress/.vitepress/config.ts"), Ne = u(process.cwd(), "docpress/.vitepress/theme"), De = u(process.cwd(), "docpress/.vitepress/theme/extras"), te = process.env.NODE_ENV === "development" ? u(import.meta.dirname, "../../public/templates/theme") : u(import.meta.dirname, "./templates/theme");
19
+ const pe = u(process.cwd(), "docpress/docs"), M = u(process.cwd(), "docpress/docs/index.md"), Ve = u(process.cwd(), "docpress/docs/forks.md"), E = u(process.cwd(), "docpress/.vitepress/config.ts"), Ne = u(process.cwd(), "docpress/.vitepress/theme"), De = u(process.cwd(), "docpress/.vitepress/theme/extras"), te = process.env.NODE_ENV === "development" ? u(import.meta.dirname, "../../public/templates/theme") : u(import.meta.dirname, "./templates/theme"), Ge = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, He = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, Me = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, Ue = /^\d{2}-/;
20
20
  async function G(e) {
21
21
  try {
22
22
  return (await Te.head(e)).status;
@@ -26,42 +26,42 @@ async function G(e) {
26
26
  }
27
27
  function f(e, t) {
28
28
  let r = "";
29
- return t?.removeDot && (e.startsWith(".") ? r = e.slice(1) : r = e, r = r.replaceAll(".", "-")), t?.removeIdx && (r = (r || e).replace(/^\d{2}-/, "")), t?.removeExt && (r = (r || e).split(".")[0]), t?.replaceDash && (r = (r || e).replaceAll("-", " ")), t?.mode === "capitalize" ? r = (r || e).slice(0, 1).toUpperCase() + (r || e).slice(1).toLowerCase() : t?.mode === "lowercase" ? r = (r || e).toLowerCase() : t?.mode === "uppercase" && (r = (r || e).toUpperCase()), r || e;
29
+ return t?.removeDot && (e.startsWith(".") ? r = e.slice(1) : r = e, r = r.replaceAll(".", "-")), t?.removeIdx && (r = (r || e).replace(Ue, "")), t?.removeExt && (r = (r || e).split(".")[0]), t?.replaceDash && (r = (r || e).replaceAll("-", " ")), t?.mode === "capitalize" ? r = (r || e).slice(0, 1).toUpperCase() + (r || e).slice(1).toLowerCase() : t?.mode === "lowercase" ? r = (r || e).toLowerCase() : t?.mode === "uppercase" && (r = (r || e).toUpperCase()), r || e;
30
30
  }
31
31
  function F(e, { clean: t } = { clean: !1 }) {
32
32
  try {
33
- t && O(e) && Oe(`${e}/*`, { glob: !0 }), O(e) || Pe(e, { recursive: !0 });
33
+ t && O(e) && Oe(`${e}/*`, { glob: !0 }), O(e) || ke(e, { recursive: !0 });
34
34
  } catch (r) {
35
35
  console.error(r);
36
36
  }
37
37
  }
38
- function Ge(e) {
38
+ function We(e) {
39
39
  try {
40
40
  return z(e).isDirectory();
41
41
  } catch {
42
42
  return !1;
43
43
  }
44
44
  }
45
- function He(e) {
45
+ function Je(e) {
46
46
  try {
47
47
  return z(e).isFile();
48
48
  } catch {
49
49
  return !1;
50
50
  }
51
51
  }
52
- function R(e) {
53
- return (Array.isArray(e) ? e : [e]).flatMap((t) => He(t) ? [t] : Ge(t) ? ue(t).flatMap((r) => R(Fe(t, r))) : []);
52
+ function A(e) {
53
+ return (Array.isArray(e) ? e : [e]).flatMap((t) => Je(t) ? [t] : We(t) ? ue(t).flatMap((r) => A(Fe(t, r))) : []);
54
54
  }
55
55
  function fe(e) {
56
- return R(e).filter((t) => y(t).endsWith(".md"));
56
+ return A(e).filter((t) => y(t).endsWith(".md"));
57
57
  }
58
- function Me(e) {
58
+ function ze(e) {
59
59
  return e.reduce((t, r, o, s) => o ? o === s.length - 1 ? `${t} or "${r}"` : `${t}, "${r}"` : `"${r}"`, "");
60
60
  }
61
- function Ue(e) {
61
+ function Be(e) {
62
62
  return JSON.parse(C(`${S}/user-${e}.json`).toString());
63
63
  }
64
- function We(e) {
64
+ function qe(e) {
65
65
  return JSON.parse(C(`${S}/repos-${e}.json`).toString());
66
66
  }
67
67
  function U(...e) {
@@ -83,10 +83,18 @@ function W(e) {
83
83
  return {};
84
84
  }
85
85
  }
86
- function P(e) {
86
+ function k(e) {
87
87
  return e.split(",");
88
88
  }
89
- function Je() {
89
+ function Ke(e, t) {
90
+ const o = C(e, "utf8").replace(Ge, (s, i, n) => `[${i}](${t}/${n})`);
91
+ v(e, o, "utf8");
92
+ }
93
+ function Xe(e, t) {
94
+ const o = C(e, "utf8").replace(He, (s, i, n, c) => `[${i}](${t}/${c})`).replace(Me, (s, i, n, c) => `[${i}](${c})`);
95
+ v(e, o, "utf8");
96
+ }
97
+ function Ye() {
90
98
  return typeof Number(process.env.LOG_LEVEL) == "number" && !Number.isNaN(Number(process.env.LOG_LEVEL)) ? Number(process.env.LOG_LEVEL) : 30;
91
99
  }
92
100
  const oe = {
@@ -99,14 +107,14 @@ const oe = {
99
107
  };
100
108
  function a(e, t = "info", r) {
101
109
  const o = r ? ee[r](e) : ee[oe[t].color](e), s = t === "success" ? "info" : t;
102
- Je() >= oe[t].level && console[s](o);
110
+ Ye() >= oe[t].level && console[s](o);
103
111
  }
104
112
  const se = ["github"], d = l.object({
105
113
  // Global
106
114
  usernames: l.string().array().describe("List of comma separated Git provider usernames used to collect data."),
107
115
  // Fetch
108
116
  branch: l.string().describe("Branch used to collect Git provider data.").default("main"),
109
- gitProvider: l.enum(se).describe(`Git provider used to retrieve data. Values should be ${Me(se)}.`).default("github"),
117
+ gitProvider: l.enum(se).describe(`Git provider used to retrieve data. Values should be ${ze(se)}.`).default("github"),
110
118
  reposFilter: l.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
111
119
  // Prepare
112
120
  extraHeaderPages: l.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
@@ -128,26 +136,26 @@ const se = ["github"], d = l.object({
128
136
  }), I = d.partial().extend({
129
137
  config: l.string().describe("Path to the docpress configuration file.").optional(),
130
138
  token: l.string().describe("Git provider token used to collect data.").optional(),
131
- usernames: l.string().describe(d.shape.usernames.description || "").transform(P).optional(),
132
- reposFilter: l.string().describe(d.shape.reposFilter.description || "").transform(P).optional(),
133
- extraHeaderPages: l.string().describe(d.shape.extraHeaderPages.description || "").transform(P).optional(),
134
- extraPublicContent: l.string().describe(d.shape.extraPublicContent.description || "").transform(P).optional(),
135
- extraTheme: l.string().describe(d.shape.extraTheme.description || "").transform(P).optional(),
139
+ usernames: l.string().describe(d.shape.usernames.description || "").transform(k).optional(),
140
+ reposFilter: l.string().describe(d.shape.reposFilter.description || "").transform(k).optional(),
141
+ extraHeaderPages: l.string().describe(d.shape.extraHeaderPages.description || "").transform(k).optional(),
142
+ extraPublicContent: l.string().describe(d.shape.extraPublicContent.description || "").transform(k).optional(),
143
+ extraTheme: l.string().describe(d.shape.extraTheme.description || "").transform(k).optional(),
136
144
  vitepressConfig: l.string().describe(d.shape.vitepressConfig.description || "").optional()
137
145
  });
138
- function ze(e) {
146
+ function Qe(e) {
139
147
  return e ? (e.usernames && typeof e.usernames == "string" && (e.usernames = [e.usernames]), e.reposFilter && typeof e.reposFilter == "string" && (e.reposFilter = [e.reposFilter]), e.extraHeaderPages && typeof e.extraHeaderPages == "string" && (e.extraHeaderPages = [e.extraHeaderPages]), e.extraPublicContent && typeof e.extraPublicContent == "string" && (e.extraPublicContent = [e.extraPublicContent]), e.extraTheme && typeof e.extraTheme == "string" && (e.extraTheme = [e.extraTheme]), e) : {};
140
148
  }
141
- function Be(e) {
149
+ function Ze(e) {
142
150
  if (!e.usernames?.length)
143
151
  throw new Error("The usernames field is required");
144
152
  return e;
145
153
  }
146
- const qe = I.partial().transform((e) => {
154
+ const et = I.partial().transform((e) => {
147
155
  try {
148
156
  const { config: t, vitepressConfig: r, token: o, ...s } = e;
149
157
  a(`Debug: Schema transform input: ${JSON.stringify(e)}`, "debug");
150
- const i = W(t), n = ze(i), c = {
158
+ const i = W(t), n = Qe(i), c = {
151
159
  forks: !1,
152
160
  ...n,
153
161
  ...s,
@@ -158,18 +166,18 @@ const qe = I.partial().transform((e) => {
158
166
  }
159
167
  } : {}
160
168
  };
161
- return a(`Debug: Final merged config: ${JSON.stringify(c)}`, "debug"), Be({ ...c, token: o });
169
+ return a(`Debug: Final merged config: ${JSON.stringify(c)}`, "debug"), Ze({ ...c, token: o });
162
170
  } catch (t) {
163
171
  a(" An error occurred while checking configuration.", "error"), t instanceof Error ? a(` ${t.message}`, "error") : a(` ${JSON.stringify(t, null, 2)}`, "error"), process.exit(1);
164
172
  }
165
- }), Ke = I.pick({}), Xe = I.pick({
173
+ }), tt = I.pick({}), rt = I.pick({
166
174
  branch: !0,
167
175
  config: !0,
168
176
  gitProvider: !0,
169
177
  reposFilter: !0,
170
178
  token: !0,
171
179
  usernames: !0
172
- }), Ye = I.pick({
180
+ }), ot = I.pick({
173
181
  extraHeaderPages: !0,
174
182
  extraPublicContent: !0,
175
183
  extraTheme: !0,
@@ -179,13 +187,13 @@ const qe = I.partial().transform((e) => {
179
187
  token: !0,
180
188
  usernames: !0,
181
189
  vitepressConfig: !0
182
- }), Qe = {
183
- build: Ke,
184
- fetch: Xe,
185
- prepare: Ye,
186
- global: qe
190
+ }), st = {
191
+ build: tt,
192
+ fetch: rt,
193
+ prepare: ot,
194
+ global: et
187
195
  };
188
- function Ze(e, t) {
196
+ function nt(e, t) {
189
197
  const r = W(e);
190
198
  if (!r) return null;
191
199
  const o = d.partial().safeParse(r);
@@ -201,17 +209,17 @@ function K(e, t) {
201
209
  -> Checking for required environment settings and configurations.`, "info"), a(` Debug info - opts: ${JSON.stringify(t)}`, "debug"), a(` Debug info - options[cmd]: ${e}`, "debug");
202
210
  try {
203
211
  if (e === "global" && typeof t.config == "string") {
204
- const o = Ze(
212
+ const o = nt(
205
213
  t.config,
206
214
  typeof t.token == "string" ? t.token : void 0
207
215
  );
208
216
  if (o)
209
217
  return o;
210
218
  }
211
- const r = Qe[e].safeParse(t);
219
+ const r = st[e].safeParse(t);
212
220
  if (!r.success) {
213
221
  try {
214
- const o = _e(r.error).toString();
222
+ const o = Re(r.error).toString();
215
223
  a(` An error occurred while checking configuration.
216
224
  ${o}`, "error");
217
225
  } catch {
@@ -230,7 +238,7 @@ function j(e, t) {
230
238
  e.addOption(r);
231
239
  return e;
232
240
  }
233
- async function et({ username: e, token: t, branch: r }) {
241
+ async function it({ username: e, token: t, branch: r }) {
234
242
  a(` Get infos for username '${e}'.`, "info");
235
243
  const o = new de({ auth: t });
236
244
  a(" Get user infos.", "debug");
@@ -239,7 +247,7 @@ async function et({ username: e, token: t, branch: r }) {
239
247
  const { data: i } = await o.rest.repos.listForUser({ username: e, sort: "full_name", per_page: 500 });
240
248
  return { user: s, repos: i, branch: r };
241
249
  }
242
- async function tt({
250
+ async function at({
243
251
  repository: e,
244
252
  token: t
245
253
  }) {
@@ -283,10 +291,10 @@ async function tt({
283
291
  }
284
292
  return { source: o.source, contributors: s };
285
293
  }
286
- async function rt(e, t, r, o, s) {
294
+ async function ct(e, t, r, o, s) {
287
295
  F(r, { clean: !0 });
288
296
  try {
289
- const i = Ae({ baseDir: r });
297
+ const i = _e({ baseDir: r });
290
298
  await i.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
291
299
  for (const n of s)
292
300
  a(` Add '${n}' to '${e}' sparse-checkout file.`, "debug"), le(u(r, ".git/info/sparse-checkout"), `${n}
@@ -296,7 +304,7 @@ async function rt(e, t, r, o, s) {
296
304
  a(` Error when cloning repository: ${i}.`, "error");
297
305
  }
298
306
  }
299
- async function ot(e, t, r) {
307
+ async function ut(e, t, r) {
300
308
  const o = `https://github.com/${e}/${t}/tree/${r}/README.md`, s = `https://github.com/${e}/${t}/tree/${r}/docs`, i = `https://github.com/${e}/${t}/tree/${r}/docs/01-readme.md`, n = await G(o), c = await G(s), p = await G(i);
301
309
  return {
302
310
  rootReadmeStatus: n,
@@ -304,16 +312,16 @@ async function ot(e, t, r) {
304
312
  docsReadmeStatus: p
305
313
  };
306
314
  }
307
- async function st({ username: e, branch: t, reposFilter: r, token: o }) {
308
- await et({ username: e, token: o, branch: t }).then(async ({ user: s, repos: i, branch: n }) => at(s, i, n, r)).then(async ({ repos: s }) => ct(s, r));
315
+ async function lt({ username: e, branch: t, reposFilter: r, token: o }) {
316
+ await it({ username: e, token: o, branch: t }).then(async ({ user: s, repos: i, branch: n }) => ft(s, i, n, r)).then(async ({ repos: s }) => mt(s, r));
309
317
  }
310
- async function nt(e, t, r) {
318
+ async function dt(e, t, r) {
311
319
  const o = [];
312
320
  return await Promise.all(
313
321
  e.map(async (s) => {
314
322
  const i = t ?? s.default_branch ?? "main", n = u(pe, f(s.name, { removeDot: !0 })), c = me(s, r);
315
323
  let p = [];
316
- !s.fork && !s.private && !c && (p = await it(s, i)), o.push({
324
+ !s.fork && !s.private && !c && (p = await pt(s, i)), o.push({
317
325
  ...s,
318
326
  docpress: {
319
327
  filtered: c,
@@ -327,23 +335,23 @@ async function nt(e, t, r) {
327
335
  })
328
336
  ), o;
329
337
  }
330
- async function it(e, t) {
331
- const r = await ot(e.owner.login, e.name, t), o = [];
338
+ async function pt(e, t) {
339
+ const r = await ut(e.owner.login, e.name, t), o = [];
332
340
  return Object.values(r).every((s) => s === 404) || !e.size ? [] : (r.docsFolderStatus !== 404 && o.push("docs/*"), (r.docsFolderStatus === 404 || r.docsReadmeStatus === 404) && o.push("README.md", "!*/**/README.md"), o);
333
341
  }
334
- async function at(e, t, r, o) {
335
- $(`${S}/user-${e.login}.json`, JSON.stringify(e, null, 2));
336
- const s = await nt(t, r, o);
337
- return $(`${S}/repos-${e.login}.json`, JSON.stringify(s, null, 2)), { user: e, repos: s };
342
+ async function ft(e, t, r, o) {
343
+ v(`${S}/user-${e.login}.json`, JSON.stringify(e, null, 2));
344
+ const s = await dt(t, r, o);
345
+ return v(`${S}/repos-${e.login}.json`, JSON.stringify(s, null, 2)), { user: e, repos: s };
338
346
  }
339
- async function ct(e, t) {
347
+ async function mt(e, t) {
340
348
  if (!e) {
341
349
  a(" No repository respect docpress rules.", "warn");
342
350
  return;
343
351
  }
344
352
  await Promise.all(
345
353
  e.filter((r) => !me(r, t)).map(async (r) => {
346
- await rt(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
354
+ await ct(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
347
355
  })
348
356
  );
349
357
  }
@@ -359,7 +367,7 @@ const L = [
359
367
  m("-b, --branch <string>", d.shape.branch.description).default(d.shape.branch.default),
360
368
  m("-g, --git-provider <string>", d.shape.gitProvider.description).default(d.shape.gitProvider.default),
361
369
  m("-r, --repos-filter <string>", d.shape.reposFilter.description)
362
- ], ut = j(J(ne), [...ge, ...L]).description("Fetch docs with the given username(s) and git provider.").action(async (e) => {
370
+ ], gt = j(J(ne), [...ge, ...L]).description("Fetch docs with the given username(s) and git provider.").action(async (e) => {
363
371
  const t = K(ne, e);
364
372
  await he(t);
365
373
  });
@@ -369,10 +377,10 @@ async function he(e) {
369
377
  -> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"), F(S, { clean: !0 });
370
378
  for (const n of t) {
371
379
  const c = t.length > 1 ? r?.filter((p) => p.startsWith(`${n}/`)).map((p) => p.replace(`${n}/`, "")) : r;
372
- await st({ username: n, branch: s, reposFilter: c, token: o });
380
+ await lt({ username: n, branch: s, reposFilter: c, token: o });
373
381
  }
374
382
  }
375
- async function lt(e) {
383
+ async function ht(e) {
376
384
  const t = console.warn;
377
385
  console.warn = function(...r) {
378
386
  r.length > 0 && typeof r[0] == "string" && (r[0].includes("[Vue warn]: Invalid watch source:") || r[0].includes("{ open: false }")) || t.apply(console, r);
@@ -383,7 +391,7 @@ async function lt(e) {
383
391
  console.warn = t;
384
392
  }
385
393
  }
386
- const dt = "build", pt = j(J(dt), L).description("Build vitepress website.").action(async (e) => {
394
+ const bt = "build", wt = j(J(bt), L).description("Build vitepress website.").action(async (e) => {
387
395
  await be();
388
396
  });
389
397
  async function be() {
@@ -392,28 +400,20 @@ async function be() {
392
400
 
393
401
  `, "info");
394
402
  try {
395
- await lt(async () => {
396
- await Re(S);
403
+ await ht(async () => {
404
+ await Ae(S);
397
405
  }), a(`
398
406
 
399
407
  Docpress build succedeed.`, "success");
400
408
  } catch (e) {
401
409
  a(`
402
410
 
403
- Docpress build failed : ${e}`, "error");
411
+ Docpress build failed : ${e}`, "error"), process.exit(1);
404
412
  }
405
413
  }
406
- function ft(e, t) {
414
+ function yt(e, t) {
407
415
  const r = C(e, { encoding: "utf8" });
408
- F(A(t)), $(t, r);
409
- }
410
- function mt(e, t) {
411
- const o = C(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (s, i, n) => `[${i}](${t}/${n})`);
412
- $(e, o, "utf8");
413
- }
414
- function gt(e, t) {
415
- const o = C(e, "utf8").replace(/\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.?\/)?([^/][^)]+)\)/g, (s, i, n, c) => `[${i}](${t}/${c})`).replace(/\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, (s, i, n, c) => `[${i}](${c})`);
416
- $(e, o, "utf8");
416
+ F(_(t)), v(t, r);
417
417
  }
418
418
  const ie = {
419
419
  base: "/",
@@ -452,45 +452,45 @@ const ie = {
452
452
  }
453
453
  }
454
454
  };
455
- function ht(e, t, r) {
455
+ function vt(e, t, r) {
456
456
  return r ? U(ie, r, { themeConfig: { sidebar: e, nav: t } }) : U(ie, { themeConfig: { sidebar: e, nav: t } });
457
457
  }
458
- async function bt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: r, vitepressConfig: o, forks: s, token: i, username: n, websiteTitle: c, websiteTagline: p }) {
459
- const h = Ue(n), b = We(n).reduce(({ internals: w, forks: v }, x) => {
460
- const { clone_url: k, private: Ce, fork: Y, docpress: Q } = x;
461
- if (k && !Ce && !Q.filtered) {
458
+ async function $t({ extraHeaderPages: e, extraPublicContent: t, extraTheme: r, vitepressConfig: o, forks: s, token: i, username: n, websiteTitle: c, websiteTagline: p }) {
459
+ const h = Be(n), b = qe(n).reduce(({ internals: w, forks: $ }, x) => {
460
+ const { clone_url: P, private: Ce, fork: Y, docpress: Q } = x;
461
+ if (P && !Ce && !Q.filtered) {
462
462
  if (!Y && Q.includes.length)
463
- return { internals: [...w, x], forks: v };
463
+ return { internals: [...w, x], forks: $ };
464
464
  if (Y)
465
- return { internals: w, forks: [...v, x] };
465
+ return { internals: w, forks: [...$, x] };
466
466
  }
467
- return { internals: w, forks: v };
468
- }, { internals: [], forks: [] }), g = { title: c, tagline: p }, { index: V, sidebar: X } = St(b.internals, h, g);
467
+ return { internals: w, forks: $ };
468
+ }, { internals: [], forks: [] }), g = { title: c, tagline: p }, { index: V, sidebar: X } = Et(b.internals, h, g);
469
469
  let N, D;
470
470
  if (O(M) && O(E)) {
471
- const w = await Et(E), v = await Ft(M);
471
+ const w = await Rt(E), $ = await _t(M);
472
472
  N = [
473
473
  ...w.themeConfig?.sidebar ?? [],
474
474
  ...X
475
- ].sort((x, k) => x.text.localeCompare(k.text)), D = {
475
+ ].sort((x, P) => x.text.localeCompare(P.text)), D = {
476
476
  ...V,
477
477
  features: [
478
- ...v.features,
478
+ ...$.features,
479
479
  ...V.features
480
- ].sort((x, k) => x.title.localeCompare(k.title))
480
+ ].sort((x, P) => x.title.localeCompare(P.title))
481
481
  };
482
482
  } else
483
483
  N = X, D = V;
484
484
  const T = [];
485
485
  if (e) {
486
- const w = Ct(e);
487
- s ? T.push(...w.filter((v) => v.link !== "/forks")) : T.push(...w);
486
+ const w = Ft(e);
487
+ s ? T.push(...w.filter(($) => $.link !== "/forks")) : T.push(...w);
488
488
  }
489
- t && (a(" Add extras Vitepress public folder content.", "info"), ae(t, u(S, "public"))), r && (a(" Add extras Vitepress theme files.", "info"), ae(r, u(De))), s && n.length && (a(" Add fork page to display external contributions.", "info"), await Pt(b.forks, n, i), T.push({ text: "Forks", link: "/forks" }));
490
- const Se = ht(N, T, o);
491
- Tt(Se, D);
489
+ t && (a(" Add extras Vitepress public folder content.", "info"), ae(t, u(S, "public"))), r && (a(" Add extras Vitepress theme files.", "info"), ae(r, u(De))), s && n.length && (a(" Add fork page to display external contributions.", "info"), await Ot(b.forks, n, i), T.push({ text: "Forks", link: "/forks" }));
490
+ const Se = vt(N, T, o);
491
+ At(Se, D);
492
492
  }
493
- function wt(e, t) {
493
+ function xt(e, t) {
494
494
  const r = y(t), s = `${f(r, { mode: "lowercase", removeIdx: !0 }) === "readme.md" ? `
495
495
  ## Sources` : "# Sources"}
496
496
 
@@ -498,7 +498,7 @@ Take a look at the [project sources](${e}).
498
498
  `;
499
499
  le(t, s, "utf8");
500
500
  }
501
- function yt(e, t, r) {
501
+ function St(e, t, r) {
502
502
  const { name: o, login: s, bio: i } = t, { title: n, tagline: c } = r;
503
503
  return {
504
504
  layout: "home",
@@ -506,7 +506,7 @@ function yt(e, t, r) {
506
506
  features: e
507
507
  };
508
508
  }
509
- function $t(e, t, r) {
509
+ function Ct(e, t, r) {
510
510
  const o = {
511
511
  title: f(e, { mode: "capitalize", replaceDash: !0 }),
512
512
  details: t,
@@ -514,7 +514,7 @@ function $t(e, t, r) {
514
514
  };
515
515
  return r ? [...r, o] : [o];
516
516
  }
517
- function vt(e, t) {
517
+ function Pt(e, t) {
518
518
  return {
519
519
  text: f(e, { mode: "capitalize", replaceDash: !0 }),
520
520
  collapsed: !0,
@@ -525,9 +525,9 @@ function we(e, t) {
525
525
  return Object.entries(t).flatMap(([r, o]) => r === "$" ? Array.isArray(o) ? o.map((s) => {
526
526
  const i = u(e.docpress.projectPath, s);
527
527
  let n = f(y(i), { mode: "lowercase", removeIdx: !0 });
528
- return n === "readme.md" && (n = "introduction.md"), n !== y(i) && Ee(i, u(A(i), n)), {
529
- text: _(n).name === "introduction" ? "Introduction" : f(n, { mode: "capitalize", replaceDash: !0, removeExt: !0 }),
530
- link: `/${f(e.name, { removeDot: !0 })}/${_(n).name}`
528
+ return n === "readme.md" && (n = "introduction.md"), n !== y(i) && Ee(i, u(_(i), n)), {
529
+ text: R(n).name === "introduction" ? "Introduction" : f(n, { mode: "capitalize", replaceDash: !0, removeExt: !0 }),
530
+ link: `/${f(e.name, { removeDot: !0 })}/${R(n).name}`
531
531
  };
532
532
  }) : [] : typeof o == "object" ? [{
533
533
  text: f(r, { mode: "capitalize", replaceDash: !0 }),
@@ -539,15 +539,15 @@ function ye(e) {
539
539
  return e.reduce((t, r) => {
540
540
  const [o, ...s] = r.split("/");
541
541
  return s.length ? t[o] = ye([
542
- ...t[o] ? $e(t[o], "") : [],
542
+ ...t[o] ? ve(t[o], "") : [],
543
543
  s.join("/")
544
544
  ]) : t.$ = [...t.$ || [], o], t;
545
545
  }, {});
546
546
  }
547
- function $e(e, t = "") {
548
- return Object.entries(e).flatMap(([r, o]) => r === "$" ? Array.isArray(o) ? o.map((s) => t ? `${t}/${s}` : s) : [] : $e(o, t ? `${t}/${r}` : r));
547
+ function ve(e, t = "") {
548
+ return Object.entries(e).flatMap(([r, o]) => r === "$" ? Array.isArray(o) ? o.map((s) => t ? `${t}/${s}` : s) : [] : ve(o, t ? `${t}/${r}` : r));
549
549
  }
550
- function xt(e) {
550
+ function kt(e) {
551
551
  if (!Array.isArray(e))
552
552
  return e;
553
553
  const t = e.findIndex((o) => o.text === "Sources");
@@ -556,42 +556,42 @@ function xt(e) {
556
556
  const [r] = e.splice(t, 1);
557
557
  return e.push(r), e;
558
558
  }
559
- function St(e, t, r) {
559
+ function Et(e, t, r) {
560
560
  const o = [], s = [];
561
561
  for (const n of e) {
562
562
  a(` Replace urls for repository '${n.name}'.`, "info"), fe([n.docpress.projectPath]).forEach((g) => {
563
- a(` Processing file '${y(g)}' for repository '${n.name}'.`, "debug"), mt(g, `https://github.com/${n.owner.login}/${n.name}/tree/${n.docpress.branch}`), y(g).toLowerCase() === "readme.md" && gt(g, `https://github.com/${n.owner.login}/${n.name}/tree/${n.docpress.branch}`);
563
+ a(` Processing file '${y(g)}' for repository '${n.name}'.`, "debug"), Ke(g, `https://github.com/${n.owner.login}/${n.name}/tree/${n.docpress.branch}`), y(g).toLowerCase() === "readme.md" && Xe(g, `https://github.com/${n.owner.login}/${n.name}/tree/${n.docpress.branch}`);
564
564
  }), a(` Generate sidebar for repository '${n.name}'.`, "info");
565
565
  const c = ue(n.docpress.projectPath, { recursive: !0 }).filter((g) => z(u(n.docpress.projectPath, g.toString())).isFile() && y(u(n.docpress.projectPath, g.toString())).endsWith(".md"));
566
566
  a(` Add sources for repository '${n.name}'.`, "info");
567
567
  let p;
568
- c.length > 1 ? (p = u(n.docpress.projectPath, "sources.md"), c.push("sources.md")) : p = u(n.docpress.projectPath, c[0]), wt(n.html_url, p);
569
- const h = ye(c), b = xt(we(n, h));
570
- s.push(vt(f(n.name, { removeDot: !0 }), b)), o.push(...$t(f(n.name, { removeDot: !0 }), n.description || ""));
568
+ c.length > 1 ? (p = u(n.docpress.projectPath, "sources.md"), c.push("sources.md")) : p = u(n.docpress.projectPath, c[0]), xt(n.html_url, p);
569
+ const h = ye(c), b = kt(we(n, h));
570
+ s.push(Pt(f(n.name, { removeDot: !0 }), b)), o.push(...Ct(f(n.name, { removeDot: !0 }), n.description || ""));
571
571
  }
572
572
  a(" Generate index content.", "info");
573
- const i = yt(o.toSorted((n, c) => n.title.localeCompare(c.title)), t, r);
573
+ const i = St(o.toSorted((n, c) => n.title.localeCompare(c.title)), t, r);
574
574
  return {
575
575
  sidebar: s.toSorted((n, c) => n.text.localeCompare(c.text)),
576
576
  index: i
577
577
  };
578
578
  }
579
- function Ct(e) {
579
+ function Ft(e) {
580
580
  const t = fe(e), r = [];
581
581
  a(" Add extras Vitepress headers pages.", "info");
582
582
  for (const o of t) {
583
583
  a(` Processing file '${o}'.`, "debug");
584
584
  const s = u(process.cwd(), o), i = u(pe, f(y(o), { mode: "lowercase", removeIdx: !0 }));
585
585
  B(s, i), r.push({
586
- text: f(_(s).name, { replaceDash: !0, removeIdx: !0 }),
587
- link: `/${f(_(s).name, { removeIdx: !0, mode: "lowercase" })}`
586
+ text: f(R(s).name, { replaceDash: !0, removeIdx: !0 }),
587
+ link: `/${f(R(s).name, { removeIdx: !0, mode: "lowercase" })}`
588
588
  });
589
589
  }
590
590
  return r;
591
591
  }
592
592
  function ae(e, t, r) {
593
593
  for (const o of Array.isArray(e) ? e : [e]) {
594
- const s = u(process.cwd(), o), i = R(s);
594
+ const s = u(process.cwd(), o), i = A(s);
595
595
  for (const n of i) {
596
596
  const c = n.replace(s, ".");
597
597
  a(` Processing file '${c}' for entry '${o}'.`, "debug");
@@ -600,7 +600,7 @@ function ae(e, t, r) {
600
600
  }
601
601
  }
602
602
  }
603
- function kt(e) {
603
+ function Tt(e) {
604
604
  const t = `---
605
605
  `, r = `layout: fork-page
606
606
  repoList:
@@ -616,40 +616,40 @@ This page serves as both a portfolio of past work and a resource for revisiting
616
616
  const { name: c, owner: p, html_url: h, description: b, stargazers_count: g } = i;
617
617
  return { name: c, owner: p.login, html_url: h, description: b, stargazers_count: g, contributions: n };
618
618
  });
619
- a(" Generate forks page.", "info"), $(Ve, t.concat(r, q.stringify(s), t, o));
619
+ a(" Generate forks page.", "info"), v(Ve, t + r + q.stringify(s) + t + o);
620
620
  }
621
- async function Pt(e, t, r) {
621
+ async function Ot(e, t, r) {
622
622
  const o = await Promise.all(
623
623
  e.map(async (s) => {
624
- const { source: i, contributors: n } = await tt({ repository: s, token: r });
624
+ const { source: i, contributors: n } = await at({ repository: s, token: r });
625
625
  return {
626
626
  contributions: n?.find((c) => c.login === t)?.contributions ?? 0,
627
627
  repository: i
628
628
  };
629
629
  })
630
630
  ).then((s) => s.filter(({ repository: i, contributions: n }) => !!i && n));
631
- kt(o);
631
+ Tt(o);
632
632
  }
633
- async function Et(e) {
633
+ async function Rt(e) {
634
634
  const { config: t } = await import(u(process.cwd(), e)).catch((r) => r);
635
635
  return t;
636
636
  }
637
- async function Ft(e) {
637
+ async function _t(e) {
638
638
  const t = (await Ie(u(process.cwd(), e))).toString();
639
639
  return q.parse(t);
640
640
  }
641
- function Tt(e, t) {
641
+ function At(e, t) {
642
642
  const r = `---
643
643
  `;
644
- return F(A(E)), a(" Generate Vitepress config.", "info"), $(E, `export const config = ${JSON.stringify(e, null, 2)}
644
+ return F(_(E)), a(" Generate Vitepress config.", "info"), v(E, `export const config = ${JSON.stringify(e, null, 2)}
645
645
 
646
646
  export default config
647
- `), a(" Generate index file.", "info"), $(M, r.concat(q.stringify(t))), a(" Add Docpress theme files.", "info"), R(te).forEach((o) => {
647
+ `), a(" Generate index file.", "info"), v(M, r + q.stringify(t)), a(" Add Docpress theme files.", "info"), A(te).forEach((o) => {
648
648
  const s = o.replace(`${te}/`, "");
649
- ft(o, u(Ne, s));
649
+ yt(o, u(Ne, s));
650
650
  });
651
651
  }
652
- const ce = "prepare", ve = [
652
+ const ce = "prepare", $e = [
653
653
  m("-c, --extra-public-content <string>", d.shape.extraPublicContent.description),
654
654
  m("-f, --forks", d.shape.forks.description),
655
655
  m("-p, --extra-header-pages <string>", d.shape.extraHeaderPages.description),
@@ -657,40 +657,40 @@ const ce = "prepare", ve = [
657
657
  m("-v, --vitepress-config <string>", d.shape.vitepressConfig.description),
658
658
  m("--website-title <string>", d.shape.websiteTitle.description),
659
659
  m("--website-tagline <string>", d.shape.websiteTagline.description)
660
- ], Ot = j(J(ce), [...ve, ...L]).description("Transform doc to the target vitepress format.").action(async (e) => {
660
+ ], It = j(J(ce), [...$e, ...L]).description("Transform doc to the target vitepress format.").action(async (e) => {
661
661
  const t = K(ce, e);
662
662
  await xe(t);
663
663
  });
664
664
  async function xe(e) {
665
665
  const { extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: s, forks: i, token: n, usernames: c, websiteTitle: p, websiteTagline: h } = e;
666
666
  a(`
667
- -> Start transform files to prepare Vitepress build.`, "info"), F(A(E), { clean: !0 });
667
+ -> Start transform files to prepare Vitepress build.`, "info"), F(_(E), { clean: !0 });
668
668
  for (const b of c)
669
- await bt({ extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: s, forks: i, token: n, username: b, websiteTitle: p, websiteTagline: h });
669
+ await $t({ extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: s, forks: i, token: n, username: b, websiteTitle: p, websiteTagline: h });
670
670
  }
671
- function _t(e) {
671
+ function jt(e) {
672
672
  return {
673
673
  ...e,
674
674
  branch: "main",
675
675
  gitProvider: "github"
676
676
  };
677
677
  }
678
- function At() {
679
- const e = new ke().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${Le.version}`).action(async (t, r) => {
680
- const o = _t(t), s = K("global", o);
678
+ function Lt() {
679
+ const e = new Pe().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${Le.version}`).action(async (t, r) => {
680
+ const o = jt(t), s = K("global", o);
681
681
  await he(s), await xe(s), await be();
682
682
  }).configureHelp({
683
683
  sortSubcommands: !0,
684
684
  sortOptions: !0,
685
685
  showGlobalOptions: !0
686
- }).enablePositionalOptions().passThroughOptions().addCommand(ut).addCommand(Ot).addCommand(pt);
687
- return j(e, [...ge, ...ve, ...L]), e;
686
+ }).enablePositionalOptions().passThroughOptions().addCommand(gt).addCommand(It).addCommand(wt);
687
+ return j(e, [...ge, ...$e, ...L]), e;
688
688
  }
689
- function zt() {
690
- At().parseAsync(process.argv);
689
+ function Xt() {
690
+ Lt().parseAsync(process.argv);
691
691
  }
692
692
  export {
693
- At as getProgram,
694
- zt as main
693
+ Lt as getProgram,
694
+ Xt as main
695
695
  };
696
696
  //# sourceMappingURL=cli.js.map