@tobi-or-not/docpress 0.6.1 → 0.7.1

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,181 +1,175 @@
1
- import { createOption as m, createCommand as B, Command as Pe } from "commander";
2
- import { existsSync as L, mkdirSync as _e, readdirSync as ue, readFileSync as _, statSync as J, appendFileSync as fe, cpSync as q, rmSync as ee, writeFileSync as k, renameSync as Ee } from "node:fs";
3
- import { resolve as d, join as Te, basename as $, dirname as V, parse as F } from "node:path";
4
- import Fe from "axios";
1
+ import { createOption as f, 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 R, parse as _ } from "node:path";
4
+ import Te from "axios";
5
5
  import { rimrafSync as Oe } from "rimraf";
6
- import te from "chalk";
7
- import { fromZodError as me } from "zod-validation-error";
8
- import { z as u } from "zod";
9
- import { Octokit as ge } from "@octokit/rest";
10
- import { simpleGit as De } from "simple-git";
11
- import { build as Re } from "vitepress";
12
- import { readFile as je } from "node:fs/promises";
13
- import K from "yaml";
14
- const Le = "@tobi-or-not/docpress", Ve = "module", Ie = "0.6.1", Ae = "pnpm@9.15.0", Ge = "https://this-is-tobi.com/docpress/introduction", Ne = { type: "git", url: "https://github.com/this-is-tobi/docpress.git" }, Me = "dist/docpress.js", He = "types/index.d.ts", Ue = { docpress: "bin/docpress.js" }, ze = ["bin", "dist", "types"], We = { node: ">=20" }, Be = { build: "pnpm run build:types && pnpm run build:vite", "build:clean": "rimraf ./dist ./types ./tsconfig.tsbuildinfo", "build:docker": "docker build --tag tobi-or-not/docpress --target prod .", "build:types": "tsc", "build:vite": "vite build", dev: "vite-node ./dev/docpress.ts", "dev:clean": "rimraf ./docpress && pnpm run dev", format: "eslint . --fix", lint: "eslint .", prepare: "husky", start: "./bin/docpress.js", "start:docker": "docker run --name docpress --rm -v $(pwd)/docpress:/app/docpress:rw tobi-or-not/docpress", "stop:docker": "docker rm --force docpress", test: "vitest run", "test:cov": "vitest run --coverage", "vp:build": "vitepress build ./docpress", "vp:build:docker": "docker build --tag tobi-or-not/docs --target prod .", "vp:dev": "vitepress dev ./docpress --port 8080", "vp:dev:docker": "docker run --publish 8080:8080 --name docpress-vp --rm tobi-or-not/docs", "vp:preview": "vitepress preview ./docpress --port 8080" }, Je = { "@octokit/rest": "^21.1.0", axios: "^1.7.9", chalk: "^5.4.1", commander: "^13.0.0", octokit: "^4.1.0", rimraf: "^6.0.1", "simple-git": "^3.27.0", vitepress: "^1.5.0", yaml: "^2.7.0", zod: "^3.24.1", "zod-validation-error": "^3.4.0" }, qe = { "@antfu/eslint-config": "^3.14.0", "@commitlint/cli": "^19.6.1", "@commitlint/config-conventional": "^19.6.0", "@octokit/types": "^13.7.0", "@types/node": "^22.10.6", "@vitest/coverage-v8": "^2.1.8", eslint: "^9.18.0", husky: "^9.1.7", "lint-staged": "^15.3.0", typescript: "^5.7.3", vite: "^6.0.7", "vite-node": "^2.1.8", vitest: "^2.1.8" }, Ke = { registry: "https://registry.npmjs.org/", access: "public", tag: "latest" }, Xe = {
15
- name: Le,
16
- type: Ve,
17
- version: Ie,
18
- packageManager: Ae,
19
- homepage: Ge,
20
- repository: Ne,
21
- module: Me,
22
- types: He,
23
- bin: Ue,
24
- files: ze,
25
- engines: We,
26
- scripts: Be,
27
- dependencies: Je,
28
- devDependencies: qe,
29
- publishConfig: Ke
30
- }, S = d(process.cwd(), "docpress");
31
- d(process.cwd(), "docpress/repositories.json");
32
- d(process.cwd(), "docpress/owner.json");
33
- const he = d(process.cwd(), "docpress/docs"), z = d(process.cwd(), "docpress/docs/index.md"), Ye = d(process.cwd(), "docpress/docs/forks.md"), O = d(process.cwd(), "docpress/.vitepress/config.ts"), Ze = d(process.cwd(), "docpress/.vitepress/theme"), Qe = d(process.cwd(), "docpress/.vitepress/theme/extras"), re = process.env.NODE_ENV === "development" ? d(import.meta.dirname, "../../public/templates/theme") : d(import.meta.dirname, "./templates/theme");
34
- async function H(e) {
6
+ import ee from "chalk";
7
+ import { fromError as _e } from "zod-validation-error";
8
+ import { z as l } from "zod";
9
+ import { Octokit as de } from "@octokit/rest";
10
+ import { simpleGit as Re } from "simple-git";
11
+ import { build as Ae } from "vitepress";
12
+ import { readFile as Ie } from "node:fs/promises";
13
+ import q from "yaml";
14
+ const je = "0.7.1", Le = {
15
+ version: je
16
+ }, S = u(process.cwd(), "docpress");
17
+ u(process.cwd(), "docpress/repositories.json");
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");
20
+ async function G(e) {
35
21
  try {
36
- return (await Fe.head(e)).status;
22
+ return (await Te.head(e)).status;
37
23
  } catch (t) {
38
24
  return t.response?.status || t.status || 500;
39
25
  }
40
26
  }
41
- function g(e, t) {
27
+ function m(e, t) {
42
28
  let r = "";
43
- return e.startsWith(".") && t?.removeDot && (r = e.slice(1)), t?.removeIdx && (r = e.replace(/^\d{2}-/, "")), 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 e.startsWith(".") && t?.removeDot && (r = e.slice(1)), t?.removeIdx && (r = e.replace(/^\d{2}-/, "")), t?.removeExt && (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;
44
30
  }
45
- function D(e, { clean: t } = { clean: !1 }) {
31
+ function F(e, { clean: t } = { clean: !1 }) {
46
32
  try {
47
- t && L(e) && Oe(`${e}/*`, { glob: !0 }), L(e) || _e(e, { recursive: !0 });
33
+ t && O(e) && Oe(`${e}/*`, { glob: !0 }), O(e) || Pe(e, { recursive: !0 });
48
34
  } catch (r) {
49
35
  console.error(r);
50
36
  }
51
37
  }
52
- function et(e) {
38
+ function Ge(e) {
53
39
  try {
54
- return J(e).isDirectory();
40
+ return z(e).isDirectory();
55
41
  } catch {
56
42
  return !1;
57
43
  }
58
44
  }
59
- function tt(e) {
45
+ function He(e) {
60
46
  try {
61
- return J(e).isFile();
47
+ return z(e).isFile();
62
48
  } catch {
63
49
  return !1;
64
50
  }
65
51
  }
66
- function I(e) {
67
- return (Array.isArray(e) ? e : [e]).flatMap((t) => tt(t) ? [t] : et(t) ? ue(t).flatMap((r) => I(Te(t, r))) : []);
52
+ function A(e) {
53
+ return (Array.isArray(e) ? e : [e]).flatMap((t) => He(t) ? [t] : Ge(t) ? ue(t).flatMap((r) => A(Fe(t, r))) : []);
68
54
  }
69
- function be(e) {
70
- return I(e).filter((t) => $(t).endsWith(".md"));
55
+ function fe(e) {
56
+ return A(e).filter((t) => y(t).endsWith(".md"));
71
57
  }
72
- function rt(e) {
73
- return e.reduce((t, r, o, n) => o ? o === n.length - 1 ? `${t} or "${r}"` : `${t}, "${r}"` : `"${r}"`, "");
58
+ function Me(e) {
59
+ return e.reduce((t, r, o, s) => o ? o === s.length - 1 ? `${t} or "${r}"` : `${t}, "${r}"` : `"${r}"`, "");
74
60
  }
75
- function ot(e) {
76
- return JSON.parse(_(`${S}/user-${e}.json`).toString());
61
+ function Ue(e) {
62
+ return JSON.parse(C(`${S}/user-${e}.json`).toString());
77
63
  }
78
- function st(e) {
79
- return JSON.parse(_(`${S}/repos-${e}.json`).toString());
64
+ function We(e) {
65
+ return JSON.parse(C(`${S}/repos-${e}.json`).toString());
80
66
  }
81
- function W(...e) {
67
+ function U(...e) {
82
68
  return e.reduce((t, r) => (r === null || Object.keys(r).forEach((o) => {
83
- const n = t ? t[o] : null, i = r[o];
84
- oe(n) && oe(i) ? t[o] = W(n, i) : t[o] = i;
69
+ const s = t ? t[o] : null, i = r[o];
70
+ re(s) && re(i) ? t[o] = U(s, i) : t[o] = i;
85
71
  }), t), {});
86
72
  }
87
- function oe(e) {
73
+ function re(e) {
88
74
  return e && typeof e == "object" && !Array.isArray(e);
89
75
  }
90
- function se(e) {
76
+ function W(e) {
91
77
  if (!e)
92
78
  return {};
93
79
  try {
94
- const t = d(process.cwd(), e), r = _(t, "utf8");
80
+ const t = u(process.cwd(), e), r = C(t, "utf8");
95
81
  return JSON.parse(r);
96
82
  } catch {
97
83
  return {};
98
84
  }
99
85
  }
100
- function T(e) {
86
+ function P(e) {
101
87
  return e.split(",");
102
88
  }
103
- function nt() {
89
+ function Je() {
104
90
  return typeof Number(process.env.LOG_LEVEL) == "number" && !Number.isNaN(Number(process.env.LOG_LEVEL)) ? Number(process.env.LOG_LEVEL) : 30;
105
91
  }
106
- const ne = {
107
- info: { color: "white", level: 30 },
108
- warn: { color: "yellow", level: 20 },
92
+ const oe = {
109
93
  error: { color: "red", level: 10 },
110
- debug: { color: "blue", level: 50 },
94
+ warn: { color: "yellow", level: 20 },
95
+ info: { color: "white", level: 30 },
96
+ success: { color: "green", level: 30 },
111
97
  trace: { color: "white", level: 40 },
112
- success: { color: "green", level: 30 }
98
+ debug: { color: "blue", level: 50 }
113
99
  };
114
- function c(e, t = "info", r) {
115
- const o = r ? te[r](e) : te[ne[t].color](e), n = t === "success" ? "info" : t;
116
- nt() >= ne[t].level && console[n](o);
100
+ function a(e, t = "info", r) {
101
+ const o = r ? ee[r](e) : ee[oe[t].color](e), s = t === "success" ? "info" : t;
102
+ Je() >= oe[t].level && console[s](o);
117
103
  }
118
- const ie = ["github"], l = u.object({
104
+ const se = ["github"], d = l.object({
119
105
  // Global
120
- usernames: u.string().array().describe("List of comma separated Git provider usernames used to collect data."),
106
+ usernames: l.string().array().describe("List of comma separated Git provider usernames used to collect data."),
121
107
  // Fetch
122
- branch: u.string().describe("Branch used to collect Git provider data.").default("main"),
123
- gitProvider: u.enum(ie).describe(`Git provider used to retrieve data. Values should be ${rt(ie)}.`).default("github"),
124
- reposFilter: u.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
108
+ 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"),
110
+ reposFilter: l.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
125
111
  // Prepare
126
- extraHeaderPages: u.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
127
- extraPublicContent: u.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
128
- extraTheme: u.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
129
- forks: u.boolean().describe("Whether or not to create the dedicated fork page that aggregate external contributions.").default(!1),
130
- vitepressConfig: u.any().describe("Path to the vitepress configuration file."),
131
- websiteTitle: u.string().describe("Website title."),
132
- websiteTagline: u.string().describe("Website tagline.")
112
+ extraHeaderPages: l.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
113
+ extraPublicContent: l.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
114
+ extraTheme: l.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
115
+ forks: l.boolean().describe("Whether or not to create the dedicated fork page that aggregate external contributions.").default(!1),
116
+ vitepressConfig: l.any().describe("Path to the vitepress configuration file."),
117
+ websiteTitle: l.string().describe("Website title."),
118
+ websiteTagline: l.string().describe("Website tagline.")
119
+ }), H = d.partial().extend({
120
+ config: l.string().describe("Path to the docpress configuration file.").optional(),
121
+ token: l.string().describe("Git provider token used to collect data.").optional(),
122
+ usernames: l.string().describe(d.shape.usernames.description || "").optional(),
123
+ reposFilter: l.string().describe(d.shape.reposFilter.description || "").optional(),
124
+ extraHeaderPages: l.string().describe(d.shape.extraHeaderPages.description || "").optional(),
125
+ extraPublicContent: l.string().describe(d.shape.extraPublicContent.description || "").optional(),
126
+ extraTheme: l.string().describe(d.shape.extraTheme.description || "").optional(),
127
+ vitepressConfig: l.string().describe(d.shape.vitepressConfig.description || "").optional()
128
+ }), I = d.partial().extend({
129
+ config: l.string().describe("Path to the docpress configuration file.").optional(),
130
+ 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(),
136
+ vitepressConfig: l.string().describe(d.shape.vitepressConfig.description || "").optional()
133
137
  });
134
- function X(e) {
135
- const { config: t, vitepressConfig: r, token: o, ...n } = e;
138
+ function ze(e) {
139
+ 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
+ }
141
+ function Be(e) {
142
+ if (!e.usernames?.length)
143
+ throw new Error("The usernames field is required");
144
+ return e;
145
+ }
146
+ const qe = I.partial().transform((e) => {
136
147
  try {
137
- const i = l.partial().parse(se(t)), s = se(r), p = l.partial().required({ branch: !0, gitProvider: !0 }).parse({}), a = {
138
- ...s,
139
- ...i.vitepressConfig
140
- }, f = {
141
- ...i,
142
- ...p,
148
+ const { config: t, vitepressConfig: r, token: o, ...s } = e;
149
+ a(`Debug: Schema transform input: ${JSON.stringify(e)}`, "debug");
150
+ const i = W(t), n = ze(i), c = {
151
+ forks: !1,
143
152
  ...n,
144
- ...Object.keys(a).length && { vitepressConfig: a }
153
+ ...s,
154
+ ...r ? {
155
+ vitepressConfig: {
156
+ ...W(r) || {},
157
+ ...n.vitepressConfig || {}
158
+ }
159
+ } : {}
145
160
  };
146
- return { ...l.partial().required({ usernames: !0 }).parse(f), token: o };
147
- } catch (i) {
148
- c(` An error occurred while checking configuration.
149
- ${me(i).toString()}`, "error"), process.exit(1);
161
+ return a(`Debug: Final merged config: ${JSON.stringify(c)}`, "debug"), Be({ ...c, token: o });
162
+ } catch (t) {
163
+ 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);
150
164
  }
151
- }
152
- l.partial().extend({
153
- config: u.string().describe("Path to the docpress configuration file.").optional(),
154
- token: u.string().describe("Git provider token used to collect data.").optional(),
155
- usernames: u.string().describe(l.shape.usernames.description || "").optional(),
156
- reposFilter: u.string().describe(l.shape.reposFilter.description || "").optional(),
157
- extraHeaderPages: u.string().describe(l.shape.extraHeaderPages.description || "").optional(),
158
- extraPublicContent: u.string().describe(l.shape.extraPublicContent.description || "").optional(),
159
- extraTheme: u.string().describe(l.shape.extraTheme.description || "").optional(),
160
- vitepressConfig: u.string().describe(l.shape.vitepressConfig.description || "").optional()
161
- });
162
- const A = l.partial().extend({
163
- config: u.string().describe("Path to the docpress configuration file.").optional(),
164
- token: u.string().describe("Git provider token used to collect data.").optional(),
165
- usernames: u.string().describe(l.shape.usernames.description || "").transform(T).optional(),
166
- reposFilter: u.string().describe(l.shape.reposFilter.description || "").transform(T).optional(),
167
- extraHeaderPages: u.string().describe(l.shape.extraHeaderPages.description || "").transform(T).optional(),
168
- extraPublicContent: u.string().describe(l.shape.extraPublicContent.description || "").transform(T).optional(),
169
- extraTheme: u.string().describe(l.shape.extraTheme.description || "").transform(T).optional(),
170
- vitepressConfig: u.string().describe(l.shape.vitepressConfig.description || "").optional()
171
- }), j = A.partial().transform(X), it = A.pick({}), ct = A.pick({
165
+ }), Ke = I.pick({}), Xe = I.pick({
172
166
  branch: !0,
173
167
  config: !0,
174
168
  gitProvider: !0,
175
169
  reposFilter: !0,
176
170
  token: !0,
177
171
  usernames: !0
178
- }).transform(X), at = A.pick({
172
+ }), Ye = I.pick({
179
173
  extraHeaderPages: !0,
180
174
  extraPublicContent: !0,
181
175
  extraTheme: !0,
@@ -185,38 +179,72 @@ const A = l.partial().extend({
185
179
  token: !0,
186
180
  usernames: !0,
187
181
  vitepressConfig: !0
188
- }).transform(X), dt = {
189
- build: it,
190
- fetch: ct,
191
- prepare: at,
192
- global: j
182
+ }), Qe = {
183
+ build: Ke,
184
+ fetch: Xe,
185
+ prepare: Ye,
186
+ global: qe
193
187
  };
194
- function Y(e, t) {
195
- c("Initializing Docpress...", "info", "blue"), c(`
188
+ function Ze(e, t) {
189
+ const r = W(e);
190
+ if (!r) return null;
191
+ const o = d.partial().safeParse(r);
192
+ return o.success ? {
193
+ ...o.data,
194
+ config: e,
195
+ token: t || void 0
196
+ } : null;
197
+ }
198
+ function K(e, t) {
199
+ a("Initializing Docpress...", "info", "blue"), a(`
196
200
 
197
- -> Checking for required environment settings and configurations.`, "info");
198
- const r = dt[e].safeParse(t);
199
- return r.error && (c(` An error occurred while checking configuration.
200
- ${me(r.error).toString()}`, "error"), process.exit(1)), c(" Setup complete! Ready to process your documentation.", "info"), r.data;
201
- }
202
- function G(e, t) {
203
- return t.forEach((r) => e.addOption(r)), e;
204
- }
205
- async function pt({ username: e, token: t, branch: r }) {
206
- c(` Get infos for username '${e}'.`, "info");
207
- const o = new ge({ auth: t });
208
- c(" Get user infos.", "debug");
209
- const { data: n } = await o.rest.users.getByUsername({ username: e });
210
- c(" Get repositories infos.", "debug");
201
+ -> Checking for required environment settings and configurations.`, "info"), a(` Debug info - opts: ${JSON.stringify(t)}`, "debug"), a(` Debug info - options[cmd]: ${e}`, "debug");
202
+ try {
203
+ if (e === "global" && typeof t.config == "string") {
204
+ const o = Ze(
205
+ t.config,
206
+ typeof t.token == "string" ? t.token : void 0
207
+ );
208
+ if (o)
209
+ return o;
210
+ }
211
+ const r = Qe[e].safeParse(t);
212
+ if (!r.success) {
213
+ try {
214
+ const o = _e(r.error).toString();
215
+ a(` An error occurred while checking configuration.
216
+ ${o}`, "error");
217
+ } catch {
218
+ a(` An error occurred while checking configuration.
219
+ ${JSON.stringify(r.error, null, 2)}`, "error");
220
+ }
221
+ process.exit(1);
222
+ }
223
+ return a(" Setup complete! Ready to process your documentation.", "info"), r.data;
224
+ } catch (r) {
225
+ a(" An error occurred while processing options.", "error"), r instanceof Error ? a(` ${r.message}`, "error") : a(` ${JSON.stringify(r, null, 2)}`, "error"), process.exit(1);
226
+ }
227
+ }
228
+ function j(e, t) {
229
+ for (const r of t)
230
+ e.addOption(r);
231
+ return e;
232
+ }
233
+ async function et({ username: e, token: t, branch: r }) {
234
+ a(` Get infos for username '${e}'.`, "info");
235
+ const o = new de({ auth: t });
236
+ a(" Get user infos.", "debug");
237
+ const { data: s } = await o.rest.users.getByUsername({ username: e });
238
+ a(" Get repositories infos.", "debug");
211
239
  const { data: i } = await o.rest.repos.listForUser({ username: e, sort: "full_name" });
212
- return { user: n, repos: i, branch: r };
240
+ return { user: s, repos: i, branch: r };
213
241
  }
214
- async function lt({
242
+ async function tt({
215
243
  repository: e,
216
244
  token: t
217
245
  }) {
218
- c(` Get contributors infos for repository '${e.name}'.`, "info");
219
- const r = new ge({
246
+ a(` Get contributors infos for repository '${e.name}'.`, "info");
247
+ const r = new de({
220
248
  auth: t,
221
249
  log: {
222
250
  debug: () => {
@@ -236,7 +264,7 @@ async function lt({
236
264
  });
237
265
  if (!o.source?.owner?.login)
238
266
  return { source: o.source, contributors: [] };
239
- const n = [];
267
+ const s = [];
240
268
  try {
241
269
  for await (const { data: i } of r.paginate.iterator(
242
270
  r.rest.repos.listContributors,
@@ -246,135 +274,148 @@ async function lt({
246
274
  per_page: 500
247
275
  }
248
276
  ))
249
- n.push(...i);
277
+ s.push(...i);
250
278
  } catch (i) {
251
- return c(
279
+ return a(
252
280
  ` Failed to get contributors infos for repository '${e.name}'. Error : ${i.message}`,
253
281
  "warn"
254
282
  ), { source: o.source, contributors: [] };
255
283
  }
256
- return { source: o.source, contributors: n };
284
+ return { source: o.source, contributors: s };
257
285
  }
258
- async function ut(e, t, r, o, n) {
259
- D(r, { clean: !0 });
286
+ async function rt(e, t, r, o, s) {
287
+ F(r, { clean: !0 });
260
288
  try {
261
- const i = De({ baseDir: r });
289
+ const i = Re({ baseDir: r });
262
290
  await i.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
263
- for (const s of n)
264
- c(` Add '${s}' to '${e}' sparse-checkout file.`, "debug"), fe(d(r, ".git/info/sparse-checkout"), `${s}
291
+ for (const n of s)
292
+ a(` Add '${n}' to '${e}' sparse-checkout file.`, "debug"), le(u(r, ".git/info/sparse-checkout"), `${n}
265
293
  `, "utf8");
266
- c(` Clone repository '${e}'.`, "info"), await i.pull("origin", o), n.some((s) => s.includes("docs")) && (q(d(r, "docs"), r, { recursive: !0 }), ee(d(r, "docs"), { recursive: !0 })), ee(d(r, ".git"), { recursive: !0 });
294
+ a(` Clone repository '${e}'.`, "info"), await i.pull("origin", o), s.some((n) => n.includes("docs")) && (B(u(r, "docs"), r, { recursive: !0 }), Z(u(r, "docs"), { recursive: !0 })), Z(u(r, ".git"), { recursive: !0 });
267
295
  } catch (i) {
268
- c(` Error when cloning repository: ${i}.`, "error");
296
+ a(` Error when cloning repository: ${i}.`, "error");
269
297
  }
270
298
  }
271
- async function ft(e, t, r) {
272
- const o = `https://github.com/${e}/${t}/tree/${r}/README.md`, n = `https://github.com/${e}/${t}/tree/${r}/docs`, i = `https://github.com/${e}/${t}/tree/${r}/docs/01-readme.md`, s = await H(o), p = await H(n), a = await H(i);
299
+ async function ot(e, t, r) {
300
+ 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);
273
301
  return {
274
- rootReadmeStatus: s,
275
- docsFolderStatus: p,
276
- docsReadmeStatus: a
302
+ rootReadmeStatus: n,
303
+ docsFolderStatus: c,
304
+ docsReadmeStatus: p
277
305
  };
278
306
  }
279
- async function mt({ username: e, branch: t, reposFilter: r, token: o }) {
280
- await pt({ username: e, token: o, branch: t }).then(async ({ user: n, repos: i, branch: s }) => bt(n, i, s, r)).then(async ({ repos: n }) => vt(n, r));
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));
281
309
  }
282
- async function gt(e, t, r) {
310
+ async function nt(e, t, r) {
283
311
  const o = [];
284
312
  return await Promise.all(
285
- e.map(async (n) => {
286
- const i = t ?? n.default_branch ?? "main", s = d(he, g(n.name, { removeDot: !0 })), p = ve(n, r);
287
- let a = [];
288
- !n.fork && !n.private && !p && (a = await ht(n, i)), o.push({
289
- ...n,
313
+ e.map(async (s) => {
314
+ const i = t ?? s.default_branch ?? "main", n = u(pe, m(s.name, { removeDot: !0 })), c = me(s, r);
315
+ let p = [];
316
+ !s.fork && !s.private && !c && (p = await it(s, i)), o.push({
317
+ ...s,
290
318
  docpress: {
291
- filtered: p,
319
+ filtered: c,
292
320
  branch: i,
293
- includes: a,
294
- projectPath: s,
295
- raw_url: `https://raw.githubusercontent.com/${n.owner.login}/${n.name}/${i}`,
296
- replace_url: `https://github.com/${n.owner.login}/${n.name}/tree/${i}`
321
+ includes: p,
322
+ projectPath: n,
323
+ raw_url: `https://raw.githubusercontent.com/${s.owner.login}/${s.name}/${i}`,
324
+ replace_url: `https://github.com/${s.owner.login}/${s.name}/tree/${i}`
297
325
  }
298
326
  });
299
327
  })
300
328
  ), o;
301
329
  }
302
- async function ht(e, t) {
303
- const r = await ft(e.owner.login, e.name, t), o = [];
304
- return Object.values(r).every((n) => n === 404) || !e.size ? [] : (r.docsFolderStatus !== 404 && o.push("docs/*"), (r.docsFolderStatus === 404 || r.docsReadmeStatus === 404) && o.push("README.md", "!*/**/README.md"), o);
330
+ async function it(e, t) {
331
+ const r = await ot(e.owner.login, e.name, t), o = [];
332
+ 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);
305
333
  }
306
- async function bt(e, t, r, o) {
307
- k(`${S}/user-${e.login}.json`, JSON.stringify(e, null, 2));
308
- const n = await gt(t, r, o);
309
- return k(`${S}/repos-${e.login}.json`, JSON.stringify(n, null, 2)), { user: e, repos: n };
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 };
310
338
  }
311
- async function vt(e, t) {
339
+ async function ct(e, t) {
312
340
  if (!e) {
313
- c(" No repository respect docpress rules.", "warn");
341
+ a(" No repository respect docpress rules.", "warn");
314
342
  return;
315
343
  }
316
344
  await Promise.all(
317
- e.filter((r) => !ve(r, t)).map(async (r) => {
318
- await ut(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
345
+ 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);
319
347
  })
320
348
  );
321
349
  }
322
- function ve(e, t) {
323
- const r = t?.every((s) => s.startsWith("!")), o = t?.filter((s) => s.startsWith("!")).some((s) => e.name === s.substring(1)), n = !t || t?.filter((s) => !s.startsWith("!")).includes(e.name) || e.fork && !o || r && !o, i = o || !n;
350
+ function me(e, t) {
351
+ const r = t?.every((n) => n.startsWith("!")), o = t?.filter((n) => n.startsWith("!")).some((n) => e.name === n.substring(1)), s = !t || t?.filter((n) => !n.startsWith("!")).includes(e.name) || e.fork && !o || r && !o, i = o || !s;
324
352
  return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !i);
325
353
  }
326
- const N = [
327
- m("-C, --config <string>", j.innerType().shape.config._def.description),
328
- m("-T, --token <string>", j.innerType().shape.token._def.description),
329
- m("-U, --usernames <string>", j.innerType().shape.usernames._def.description)
330
- ], ce = "fetch", ye = [
331
- m("-b, --branch <string>", l.shape.branch._def.description).default(l.shape.branch._def.defaultValue()),
332
- m("-g, --git-provider <string>", l.shape.gitProvider._def.description).default(l.shape.gitProvider._def.defaultValue()),
333
- m("-r, --repos-filter <string>", l.shape.reposFilter._def.description)
334
- ], yt = G(B(ce), [...ye, ...N]).description("Fetch docs with the given username(s) and git provider.").action(async (e) => {
335
- const t = Y(ce, e);
336
- await we(t);
354
+ const L = [
355
+ f("-C, --config <string>", H.shape.config.description),
356
+ f("-T, --token <string>", H.shape.token.description),
357
+ f("-U, --usernames <string>", H.shape.usernames.description)
358
+ ], ne = "fetch", ge = [
359
+ f("-b, --branch <string>", d.shape.branch.description).default(d.shape.branch.default),
360
+ f("-g, --git-provider <string>", d.shape.gitProvider.description).default(d.shape.gitProvider.default),
361
+ f("-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) => {
363
+ const t = K(ne, e);
364
+ await he(t);
337
365
  });
338
- async function we(e) {
339
- const { usernames: t, reposFilter: r, token: o, branch: n, gitProvider: i } = e;
340
- c(`
341
- -> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"), D(S, { clean: !0 });
342
- for (const s of t) {
343
- const p = t.length > 1 ? r?.filter((a) => a.startsWith(s)).map((a) => a.replace(`${s}/`, "")) : r;
344
- await mt({ username: s, branch: n, reposFilter: p, gitProvider: i, token: o });
366
+ async function he(e) {
367
+ const { usernames: t, reposFilter: r, token: o, branch: s, gitProvider: i } = e;
368
+ a(`
369
+ -> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"), F(S, { clean: !0 });
370
+ for (const n of t) {
371
+ 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 });
373
+ }
374
+ }
375
+ async function lt(e) {
376
+ const t = console.warn;
377
+ console.warn = function(...r) {
378
+ r.length > 0 && typeof r[0] == "string" && (r[0].includes("[Vue warn]: Invalid watch source:") || r[0].includes("{ open: false }")) || t.apply(console, r);
379
+ };
380
+ try {
381
+ return await e();
382
+ } finally {
383
+ console.warn = t;
345
384
  }
346
385
  }
347
- const wt = "build", $t = G(B(wt), N).description("Build vitepress website.").action(async (e) => {
348
- await $e();
386
+ const dt = "build", pt = j(J(dt), L).description("Build vitepress website.").action(async (e) => {
387
+ await be();
349
388
  });
350
- async function $e() {
351
- c(`
389
+ async function be() {
390
+ a(`
352
391
  -> Start building Vitepress website.
353
392
 
354
393
  `, "info");
355
394
  try {
356
- await Re(S), c(`
395
+ await lt(async () => {
396
+ await Ae(S);
397
+ }), a(`
357
398
 
358
399
  Docpress build succedeed.`, "success");
359
400
  } catch (e) {
360
- c(`
401
+ a(`
361
402
 
362
403
  Docpress build failed : ${e}`, "error");
363
404
  }
364
405
  }
365
- function kt(e, t) {
366
- const r = _(e, { encoding: "utf8" });
367
- D(V(t)), k(t, r);
406
+ function ft(e, t) {
407
+ const r = C(e, { encoding: "utf8" });
408
+ F(R(t)), $(t, r);
368
409
  }
369
- function xt(e, t) {
370
- const o = _(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (n, i, s) => `[${i}](${t}/${s})`);
371
- k(e, o, "utf8");
410
+ function mt(e, t) {
411
+ const o = C(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (s, i, n) => `[${i}](${t}/${n})`);
412
+ $(e, o, "utf8");
372
413
  }
373
- function Ct(e, t) {
374
- const o = _(e, "utf8").replace(/\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.?\/)?([^/][^)]+)\)/g, (n, i, s, p) => `[${i}](${t}/${p})`).replace(/\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, (n, i, s, p) => `[${i}](${p})`);
375
- k(e, o, "utf8");
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");
376
417
  }
377
- const ae = {
418
+ const ie = {
378
419
  base: "/",
379
420
  lang: "en-US",
380
421
  vite: {
@@ -411,137 +452,155 @@ const ae = {
411
452
  }
412
453
  }
413
454
  };
414
- function St(e, t, r) {
415
- return r ? W(ae, r, { themeConfig: { sidebar: e, nav: t } }) : W(ae, { themeConfig: { sidebar: e, nav: t } });
416
- }
417
- async function Pt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: r, vitepressConfig: o, forks: n, token: i, username: s, websiteTitle: p, websiteTagline: a }) {
418
- const f = ot(s), b = st(s).reduce(({ internals: w, forks: x }, C) => {
419
- const { clone_url: E, private: Se, fork: Z, docpress: Q } = C;
420
- if (E && !Se && !Q.filtered) {
421
- if (!Z && Q.includes.length)
422
- return { internals: [...w, C], forks: x };
423
- if (Z)
424
- return { internals: w, forks: [...x, C] };
455
+ function ht(e, t, r) {
456
+ return r ? U(ie, r, { themeConfig: { sidebar: e, nav: t } }) : U(ie, { themeConfig: { sidebar: e, nav: t } });
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) {
462
+ if (!Y && Q.includes.length)
463
+ return { internals: [...w, x], forks: v };
464
+ if (Y)
465
+ return { internals: w, forks: [...v, x] };
425
466
  }
426
- return { internals: w, forks: x };
427
- }, { internals: [], forks: [] }), P = { title: p, tagline: a }, { index: y, sidebar: h } = Ft(b.internals, f, P);
428
- let v, M;
429
- if (L(z) && L(O)) {
430
- const w = await jt(O), x = await Lt(z);
431
- v = [
467
+ return { internals: w, forks: v };
468
+ }, { internals: [], forks: [] }), g = { title: c, tagline: p }, { index: V, sidebar: X } = St(b.internals, h, g);
469
+ let N, D;
470
+ if (O(M) && O(E)) {
471
+ const w = await Et(E), v = await Ft(M);
472
+ N = [
432
473
  ...w.themeConfig?.sidebar ?? [],
433
- ...h
434
- ].sort((C, E) => C.text.localeCompare(E.text)), M = {
435
- ...y,
474
+ ...X
475
+ ].sort((x, k) => x.text.localeCompare(k.text)), D = {
476
+ ...V,
436
477
  features: [
437
- ...x.features,
438
- ...y.features
439
- ].sort((C, E) => C.title.localeCompare(E.title))
478
+ ...v.features,
479
+ ...V.features
480
+ ].sort((x, k) => x.title.localeCompare(k.title))
440
481
  };
441
482
  } else
442
- v = h, M = y;
443
- const R = [];
483
+ N = X, D = V;
484
+ const T = [];
444
485
  if (e) {
445
- const w = Ot(e);
446
- n ? R.push(...w.filter((x) => x.link !== "/forks")) : R.push(...w);
486
+ const w = Ct(e);
487
+ s ? T.push(...w.filter((v) => v.link !== "/forks")) : T.push(...w);
447
488
  }
448
- t && (c(" Add extras Vitepress public folder content.", "info"), pe(t, d(S, "public"))), r && (c(" Add extras Vitepress theme files.", "info"), pe(r, d(Qe))), n && s.length && (c(" Add fork page to display external contributions.", "info"), await Rt(b.forks, s, i), R.push({ text: "Forks", link: "/forks" }));
449
- const Ce = St(v, R, o);
450
- Vt(Ce, M);
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);
451
492
  }
452
- function de(e, t) {
453
- const n = `${$(t) === "introduction.md" ? `
493
+ function wt(e, t) {
494
+ const r = y(t), s = `${m(r, { mode: "lowercase", removeIdx: !0 }) === "readme.md" ? `
454
495
  ## Sources` : "# Sources"}
455
496
 
456
497
  Take a look at the [project sources](${e}).
457
498
  `;
458
- fe(t, n, "utf8");
499
+ le(t, s, "utf8");
459
500
  }
460
- function _t(e, t, r) {
461
- const { name: o, login: n, bio: i } = t, { title: s, tagline: p } = r;
501
+ function yt(e, t, r) {
502
+ const { name: o, login: s, bio: i } = t, { title: n, tagline: c } = r;
462
503
  return {
463
504
  layout: "home",
464
- hero: s ? { name: s, tagline: p } : { name: o ? `${o}'s projects` : `${n}'s projects`, tagline: i ?? "Robots are everywhere 🤖" },
505
+ hero: n ? { name: n, tagline: c } : { name: o ? `${o}'s projects` : `${s}'s projects`, tagline: i ?? "Robots are everywhere 🤖" },
465
506
  features: e
466
507
  };
467
508
  }
468
- function Et(e, t, r) {
509
+ function $t(e, t, r) {
469
510
  const o = {
470
- title: g(e, { mode: "capitalize", replaceDash: !0 }),
511
+ title: m(e, { mode: "capitalize", replaceDash: !0 }),
471
512
  details: t,
472
513
  link: `/${e}/introduction`
473
514
  };
474
515
  return r ? [...r, o] : [o];
475
516
  }
476
- function Tt(e, t) {
517
+ function vt(e, t) {
477
518
  return {
478
- text: g(e, { mode: "capitalize", replaceDash: !0 }),
519
+ text: m(e, { mode: "capitalize", replaceDash: !0 }),
479
520
  collapsed: !0,
480
521
  items: t
481
522
  };
482
523
  }
483
- function U(e, t, r) {
484
- const o = {
485
- text: t === "introduction" ? "Introduction" : g(t, { mode: "capitalize", replaceDash: !0 }),
486
- link: `/${e}/${t}`
487
- };
488
- return r ? [...r, o] : [o];
524
+ function we(e, t) {
525
+ return Object.entries(t).flatMap(([r, o]) => r === "$" ? Array.isArray(o) ? o.map((s) => {
526
+ const i = u(e.docpress.projectPath, s);
527
+ let n = m(y(i), { mode: "lowercase", removeIdx: !0 });
528
+ return n === "readme.md" && (n = "introduction.md"), n !== y(i) && Ee(i, u(R(i), n)), {
529
+ text: _(n).name === "introduction" ? "Introduction" : m(n, { mode: "capitalize", replaceDash: !0, removeExt: !0 }),
530
+ link: m(`/${e.name}/${_(n).name}`, { removeDot: !0 })
531
+ };
532
+ }) : [] : typeof o == "object" ? [{
533
+ text: m(r, { mode: "capitalize", replaceDash: !0 }),
534
+ collapsed: !0,
535
+ items: we({ ...e, name: `${e.name}/${r}` }, o)
536
+ }] : []);
537
+ }
538
+ function ye(e) {
539
+ return e.reduce((t, r) => {
540
+ const [o, ...s] = r.split("/");
541
+ return s.length ? t[o] = ye([
542
+ ...t[o] ? $e(t[o], "") : [],
543
+ s.join("/")
544
+ ]) : t.$ = [...t.$ || [], o], t;
545
+ }, {});
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));
549
+ }
550
+ function xt(e) {
551
+ if (!Array.isArray(e))
552
+ return e;
553
+ const t = e.findIndex((o) => o.text === "Sources");
554
+ if (t === -1)
555
+ return e;
556
+ const [r] = e.splice(t, 1);
557
+ return e.push(r), e;
489
558
  }
490
- function Ft(e, t, r) {
491
- const o = [], n = [];
492
- for (const s of e) {
493
- c(` Replace urls for repository '${s.name}'.`, "info"), be([s.docpress.projectPath]).forEach((a) => {
494
- c(` Processing file '${$(a)}' for repository '${s.name}'.`, "debug"), xt(a, `https://github.com/${s.owner.login}/${s.name}/tree/${s.docpress.branch}`), $(a).toLowerCase() === "readme.md" && Ct(a, `https://github.com/${s.owner.login}/${s.name}/tree/${s.docpress.branch}`);
495
- }), c(` Generate sidebar for repository '${s.name}'.`, "info");
496
- const p = ue(s.docpress.projectPath).filter((a) => J(d(s.docpress.projectPath, a)).isFile() && $(d(s.docpress.projectPath, a)).endsWith(".md")).sort((a, f) => a.localeCompare(f)).reduce((a, f, b, P) => {
497
- const y = d(s.docpress.projectPath, f);
498
- let h = g($(y), { mode: "lowercase", removeIdx: !0 });
499
- if (h === "readme.md" && (h = "introduction.md"), h !== $(y) && Ee(y, d(V(y), h)), b === P.length - 1) {
500
- let v;
501
- if (P.length > 1)
502
- return v = d(s.docpress.projectPath, "sources.md"), c(` Add sources for repository '${s.name}'.`, "info"), de(s.html_url, v), U(
503
- s.name,
504
- F(v).name,
505
- U(s.name, F(h).name, a)
506
- );
507
- v = d(s.docpress.projectPath, h), de(s.html_url, v);
508
- }
509
- return U(g(s.name, { removeDot: !0 }), F(h).name, a);
510
- }, []);
511
- n.push(Tt(g(s.name, { removeDot: !0 }), p)), o.push(...Et(g(s.name, { removeDot: !0 }), s.description || ""));
559
+ function St(e, t, r) {
560
+ const o = [], s = [];
561
+ for (const n of e) {
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}`);
564
+ }), a(` Generate sidebar for repository '${n.name}'.`, "info");
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
+ a(` Add sources for repository '${n.name}'.`, "info");
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(m(n.name, { removeDot: !0 }), b)), o.push(...$t(m(n.name, { removeDot: !0 }), n.description || ""));
512
571
  }
513
- c(" Generate index content.", "info");
514
- const i = _t(o.toSorted((s, p) => s.title.localeCompare(p.title)), t, r);
572
+ a(" Generate index content.", "info");
573
+ const i = yt(o.toSorted((n, c) => n.title.localeCompare(c.title)), t, r);
515
574
  return {
516
- sidebar: n.toSorted((s, p) => s.text.localeCompare(p.text)),
575
+ sidebar: s.toSorted((n, c) => n.text.localeCompare(c.text)),
517
576
  index: i
518
577
  };
519
578
  }
520
- function Ot(e) {
521
- const t = be(e), r = [];
522
- c(" Add extras Vitepress headers pages.", "info");
579
+ function Ct(e) {
580
+ const t = fe(e), r = [];
581
+ a(" Add extras Vitepress headers pages.", "info");
523
582
  for (const o of t) {
524
- c(` Processing file '${o}'.`, "debug");
525
- const n = d(process.cwd(), o), i = d(he, g($(o), { mode: "lowercase", removeIdx: !0 }));
526
- q(n, i), r.push({
527
- text: g(F(n).name, { replaceDash: !0, removeIdx: !0 }),
528
- link: `/${g(F(n).name, { removeIdx: !0, mode: "lowercase" })}`
583
+ a(` Processing file '${o}'.`, "debug");
584
+ const s = u(process.cwd(), o), i = u(pe, m(y(o), { mode: "lowercase", removeIdx: !0 }));
585
+ B(s, i), r.push({
586
+ text: m(_(s).name, { replaceDash: !0, removeIdx: !0 }),
587
+ link: `/${m(_(s).name, { removeIdx: !0, mode: "lowercase" })}`
529
588
  });
530
589
  }
531
590
  return r;
532
591
  }
533
- function pe(e, t, r) {
592
+ function ae(e, t, r) {
534
593
  for (const o of Array.isArray(e) ? e : [e]) {
535
- const n = d(process.cwd(), o), i = I(n);
536
- for (const s of i) {
537
- const p = s.replace(n, ".");
538
- c(` Processing file '${p}' for entry '${o}'.`, "debug");
539
- const a = d(process.cwd(), s), f = d(t, p);
540
- q(a, f);
594
+ const s = u(process.cwd(), o), i = A(s);
595
+ for (const n of i) {
596
+ const c = n.replace(s, ".");
597
+ a(` Processing file '${c}' for entry '${o}'.`, "debug");
598
+ const p = u(process.cwd(), n), h = u(t, c);
599
+ B(p, h);
541
600
  }
542
601
  }
543
602
  }
544
- function Dt(e) {
603
+ function kt(e) {
545
604
  const t = `---
546
605
  `, r = `layout: fork-page
547
606
  repoList:
@@ -553,78 +612,85 @@ This gallery is a visual representation of the collaborative work done across a
553
612
  Every 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.
554
613
 
555
614
  This page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.
556
- `, n = e.map(({ repository: i, contributions: s }) => {
557
- const { name: p, owner: a, html_url: f, description: b, stargazers_count: P } = i;
558
- return { name: p, owner: a.login, html_url: f, description: b, stargazers_count: P, contributions: s };
615
+ `, s = e.map(({ repository: i, contributions: n }) => {
616
+ const { name: c, owner: p, html_url: h, description: b, stargazers_count: g } = i;
617
+ return { name: c, owner: p.login, html_url: h, description: b, stargazers_count: g, contributions: n };
559
618
  });
560
- c(" Generate forks page.", "info"), k(Ye, t.concat(r, K.stringify(n), t, o));
619
+ a(" Generate forks page.", "info"), $(Ve, t.concat(r, q.stringify(s), t, o));
561
620
  }
562
- async function Rt(e, t, r) {
621
+ async function Pt(e, t, r) {
563
622
  const o = await Promise.all(
564
- e.map(async (n) => {
565
- const { source: i, contributors: s } = await lt({ repository: n, token: r });
623
+ e.map(async (s) => {
624
+ const { source: i, contributors: n } = await tt({ repository: s, token: r });
566
625
  return {
567
- contributions: s?.find((p) => p.login === t)?.contributions ?? 0,
626
+ contributions: n?.find((c) => c.login === t)?.contributions ?? 0,
568
627
  repository: i
569
628
  };
570
629
  })
571
- ).then((n) => n.filter(({ repository: i, contributions: s }) => !!i && s));
572
- Dt(o);
630
+ ).then((s) => s.filter(({ repository: i, contributions: n }) => !!i && n));
631
+ kt(o);
573
632
  }
574
- async function jt(e) {
575
- const { config: t } = await import(d(process.cwd(), e)).catch((r) => r);
633
+ async function Et(e) {
634
+ const { config: t } = await import(u(process.cwd(), e)).catch((r) => r);
576
635
  return t;
577
636
  }
578
- async function Lt(e) {
579
- const t = (await je(d(process.cwd(), e))).toString();
580
- return K.parse(t);
637
+ async function Ft(e) {
638
+ const t = (await Ie(u(process.cwd(), e))).toString();
639
+ return q.parse(t);
581
640
  }
582
- function Vt(e, t) {
641
+ function Tt(e, t) {
583
642
  const r = `---
584
643
  `;
585
- return D(V(O)), c(" Generate Vitepress config.", "info"), k(O, `export const config = ${JSON.stringify(e, null, 2)}
644
+ return F(R(E)), a(" Generate Vitepress config.", "info"), $(E, `export const config = ${JSON.stringify(e, null, 2)}
586
645
 
587
646
  export default config
588
- `), c(" Generate index file.", "info"), k(z, r.concat(K.stringify(t))), c(" Add Docpress theme files.", "info"), I(re).forEach((o) => {
589
- const n = o.replace(`${re}/`, "");
590
- kt(o, d(Ze, n));
647
+ `), a(" Generate index file.", "info"), $(M, r.concat(q.stringify(t))), a(" Add Docpress theme files.", "info"), A(te).forEach((o) => {
648
+ const s = o.replace(`${te}/`, "");
649
+ ft(o, u(Ne, s));
591
650
  });
592
651
  }
593
- const le = "prepare", ke = [
594
- m("-c, --extra-public-content <string>", l.shape.extraPublicContent._def.description),
595
- m("-f, --forks", l.shape.forks._def.description),
596
- m("-p, --extra-header-pages <string>", l.shape.extraHeaderPages._def.description),
597
- m("-t, --extra-theme <string>", l.shape.extraTheme._def.description),
598
- m("-v, --vitepress-config <string>", l.shape.vitepressConfig._def.description),
599
- m("--website-title <string>", l.shape.websiteTitle._def.description),
600
- m("--website-tagline <string>", l.shape.websiteTagline._def.description)
601
- ], It = G(B(le), [...ke, ...N]).description("Transform doc to the target vitepress format.").action(async (e) => {
602
- const t = Y(le, e);
652
+ const ce = "prepare", ve = [
653
+ f("-c, --extra-public-content <string>", d.shape.extraPublicContent.description),
654
+ f("-f, --forks", d.shape.forks.description),
655
+ f("-p, --extra-header-pages <string>", d.shape.extraHeaderPages.description),
656
+ f("-t, --extra-theme <string>", d.shape.extraTheme.description),
657
+ f("-v, --vitepress-config <string>", d.shape.vitepressConfig.description),
658
+ f("--website-title <string>", d.shape.websiteTitle.description),
659
+ f("--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) => {
661
+ const t = K(ce, e);
603
662
  await xe(t);
604
663
  });
605
664
  async function xe(e) {
606
- const { extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: n, forks: i, token: s, usernames: p, websiteTitle: a, websiteTagline: f } = e;
607
- c(`
608
- -> Start transform files to prepare Vitepress build.`, "info"), D(V(O), { clean: !0 });
609
- for (const b of p)
610
- await Pt({ extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: n, forks: i, token: s, username: b, websiteTitle: a, websiteTagline: f });
611
- }
612
- function At() {
613
- const e = new Pe().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${Xe.version}`).action(async (t, r) => {
614
- const o = Y("global", t);
615
- await we(o), await xe(o), await $e();
665
+ const { extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: s, forks: i, token: n, usernames: c, websiteTitle: p, websiteTagline: h } = e;
666
+ a(`
667
+ -> Start transform files to prepare Vitepress build.`, "info"), F(R(E), { clean: !0 });
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 });
670
+ }
671
+ function _t(e) {
672
+ return {
673
+ ...e,
674
+ branch: "main",
675
+ gitProvider: "github"
676
+ };
677
+ }
678
+ function Rt() {
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);
681
+ await he(s), await xe(s), await be();
616
682
  }).configureHelp({
617
683
  sortSubcommands: !0,
618
684
  sortOptions: !0,
619
685
  showGlobalOptions: !0
620
- }).enablePositionalOptions().passThroughOptions().addCommand(yt).addCommand(It).addCommand($t);
621
- return G(e, [...ye, ...ke, ...N]), e;
686
+ }).enablePositionalOptions().passThroughOptions().addCommand(ut).addCommand(Ot).addCommand(pt);
687
+ return j(e, [...ge, ...ve, ...L]), e;
622
688
  }
623
- function Zt() {
624
- At().parseAsync(process.argv);
689
+ function zt() {
690
+ Rt().parseAsync(process.argv);
625
691
  }
626
692
  export {
627
- At as getProgram,
628
- Zt as main
693
+ Rt as getProgram,
694
+ zt as main
629
695
  };
630
696
  //# sourceMappingURL=cli.js.map