@tobi-or-not/docpress 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +11 -9
  2. package/dist/cli.js +878 -691
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +41 -47
  5. package/dist/tsconfig.tsbuildinfo +0 -1
  6. package/types/cli.d.ts +0 -3
  7. package/types/commands/build.d.ts +0 -3
  8. package/types/commands/fetch.d.ts +0 -4
  9. package/types/commands/global.d.ts +0 -1
  10. package/types/commands/prepare.d.ts +0 -4
  11. package/types/lib/fetch.d.ts +0 -120
  12. package/types/lib/git.d.ts +0 -515
  13. package/types/lib/prepare.d.ts +0 -62
  14. package/types/lib/vitepress.d.ts +0 -3
  15. package/types/public/templates/theme/index.d.ts +0 -8
  16. package/types/schemas/build.d.ts +0 -20
  17. package/types/schemas/fetch.d.ts +0 -52
  18. package/types/schemas/global.d.ts +0 -150
  19. package/types/schemas/prepare.d.ts +0 -61
  20. package/types/src/cli.d.ts +0 -12
  21. package/types/src/commands/build.d.ts +0 -20
  22. package/types/src/commands/fetch.d.ts +0 -15
  23. package/types/src/commands/global.d.ts +0 -4
  24. package/types/src/commands/prepare.d.ts +0 -15
  25. package/types/src/lib/fetch.d.ts +0 -179
  26. package/types/src/lib/git.d.ts +0 -568
  27. package/types/src/lib/prepare.d.ts +0 -214
  28. package/types/src/lib/vitepress.d.ts +0 -11
  29. package/types/src/schemas/build.d.ts +0 -7
  30. package/types/src/schemas/fetch.d.ts +0 -25
  31. package/types/src/schemas/global.d.ts +0 -100
  32. package/types/src/schemas/prepare.d.ts +0 -22
  33. package/types/src/templates/index.d.ts +0 -1
  34. package/types/src/templates/theme/index.d.ts +0 -8
  35. package/types/src/utils/commands.d.ts +0 -95
  36. package/types/src/utils/const.d.ts +0 -40
  37. package/types/src/utils/functions.d.ts +0 -130
  38. package/types/src/utils/logger.d.ts +0 -14
  39. package/types/src/utils/regex.d.ts +0 -4
  40. package/types/src/utils/resolver.d.ts +0 -1
  41. package/types/src/utils/templates.d.ts +0 -7
  42. package/types/templates/index.d.ts +0 -5
  43. package/types/templates/theme/index.d.ts +0 -8
  44. package/types/utils/commands.d.ts +0 -207
  45. package/types/utils/const.d.ts +0 -10
  46. package/types/utils/functions.d.ts +0 -24
  47. package/types/utils/logger.d.ts +0 -4
  48. package/types/utils/regex.d.ts +0 -2
package/dist/cli.js CHANGED
@@ -1,701 +1,888 @@
1
- import { createOption as m, createCommand as J, Command as Pe } from "commander";
2
- import { readFileSync as S, 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
- import Te from "axios";
5
- import { rimrafSync as Oe } from "rimraf";
6
- import ee from "chalk";
7
- import { fromError as Re } from "zod-validation-error";
8
- import { z as l } from "zod";
9
- import { Octokit as de } from "@octokit/rest";
10
- import { simpleGit as _e } from "simple-git";
11
- import { build as Ae } from "vitepress";
12
- import { withMermaid as Ie } from "vitepress-plugin-mermaid";
13
- import { readFile as je } from "node:fs/promises";
14
- import q from "yaml";
15
- const Le = "0.8.0", Ve = {
16
- version: Le
17
- }, C = u(process.cwd(), "docpress");
18
- u(process.cwd(), "docpress/repositories.json");
19
- u(process.cwd(), "docpress/owner.json");
20
- const pe = u(process.cwd(), "docpress/docs"), M = u(process.cwd(), "docpress/docs/index.md"), Ne = u(process.cwd(), "docpress/docs/forks.md"), E = u(process.cwd(), "docpress/.vitepress/config.ts"), De = u(process.cwd(), "docpress/.vitepress/theme"), Ge = 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"), He = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, Me = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, Ue = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, We = /^\d{2}-/;
21
- async function G(e) {
22
- try {
23
- return (await Te.head(e)).status;
24
- } catch (t) {
25
- return t.response?.status || t.status || 500;
26
- }
27
- }
28
- function f(e, t) {
29
- let r = "";
30
- return t?.removeDot && (e.startsWith(".") ? r = e.slice(1) : r = e, r = r.replaceAll(".", "-")), t?.removeIdx && (r = (r || e).replace(We, "")), 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;
31
- }
32
- function F(e, { clean: t } = { clean: !1 }) {
33
- try {
34
- t && O(e) && Oe(`${e}/*`, { glob: !0 }), O(e) || ke(e, { recursive: !0 });
35
- } catch (r) {
36
- console.error(r);
37
- }
38
- }
39
- function Je(e) {
40
- try {
41
- return z(e).isDirectory();
42
- } catch {
43
- return !1;
44
- }
45
- }
46
- function ze(e) {
47
- try {
48
- return z(e).isFile();
49
- } catch {
50
- return !1;
51
- }
52
- }
53
- function A(e) {
54
- return (Array.isArray(e) ? e : [e]).flatMap((t) => ze(t) ? [t] : Je(t) ? ue(t).flatMap((r) => A(Fe(t, r))) : []);
1
+ import { Command as e, createCommand as t, createOption as n } from "commander";
2
+ import { appendFileSync as r, cpSync as i, existsSync as a, mkdirSync as o, readFileSync as s, readdirSync as c, renameSync as l, rmSync as u, statSync as d, writeFileSync as f } from "node:fs";
3
+ import { basename as p, dirname as m, join as h, parse as g, resolve as _ } from "node:path";
4
+ import { rimrafSync as v } from "rimraf";
5
+ import y from "chalk";
6
+ import { z as b } from "zod";
7
+ import { Octokit as x } from "@octokit/rest";
8
+ import { simpleGit as ee } from "simple-git";
9
+ import { build as te } from "vitepress";
10
+ import { withMermaid as ne } from "vitepress-plugin-mermaid";
11
+ import { readFile as re } from "node:fs/promises";
12
+ import S from "yaml";
13
+ var ie = {
14
+ name: "@tobi-or-not/docpress",
15
+ type: "module",
16
+ version: "0.9.0",
17
+ packageManager: "bun@1.3.14",
18
+ homepage: "https://this-is-tobi.com/docpress/introduction",
19
+ repository: {
20
+ type: "git",
21
+ url: "https://github.com/this-is-tobi/docpress.git"
22
+ },
23
+ bin: { docpress: "bin/docpress.js" },
24
+ files: ["bin", "dist"],
25
+ engines: { node: ">=22.12.0" },
26
+ scripts: {
27
+ build: "bun run build:clean && bun run build:types && bun run build:vite",
28
+ "build:clean": "rimraf ./dist ./types ./tsconfig.tsbuildinfo",
29
+ "build:docker": "docker build --tag tobi-or-not/docpress --target prod .",
30
+ "build:types": "tsc",
31
+ "build:vite": "vite build",
32
+ dev: "bun ./dev/docpress.ts",
33
+ "dev:clean": "rimraf ./docpress && bun run dev",
34
+ format: "eslint . --fix",
35
+ lint: "eslint .",
36
+ prepare: "husky",
37
+ start: "./bin/docpress.js",
38
+ "start:docker": "docker run --name docpress --rm -v $(pwd)/docpress:/app/docpress:rw tobi-or-not/docpress",
39
+ "stop:docker": "docker rm --force docpress",
40
+ test: "vitest run",
41
+ "test:cov": "vitest run --coverage",
42
+ "vp:build": "vitepress build ./docpress",
43
+ "vp:build:docker": "docker build --tag tobi-or-not/docs --target prod .",
44
+ "vp:dev": "vitepress dev ./docpress --port 8080",
45
+ "vp:dev:docker": "docker run --publish 8080:8080 --name docpress-vp --rm tobi-or-not/docs",
46
+ "vp:preview": "vitepress preview ./docpress --port 8080"
47
+ },
48
+ dependencies: {
49
+ "@octokit/rest": "^22.0.1",
50
+ chalk: "^5.6.2",
51
+ commander: "^15.0.0",
52
+ rimraf: "^6.1.3",
53
+ "simple-git": "^3.36.0",
54
+ vitepress: "^1.6.4",
55
+ "vitepress-plugin-mermaid": "^2.0.17",
56
+ yaml: "^2.9.0",
57
+ zod: "^4.4.3"
58
+ },
59
+ devDependencies: {
60
+ "@antfu/eslint-config": "^9.1.0",
61
+ "@commitlint/cli": "^21.2.0",
62
+ "@commitlint/config-conventional": "^21.2.0",
63
+ "@octokit/types": "^16.0.0",
64
+ "@types/node": "^26.1.0",
65
+ "@vitejs/plugin-vue": "^6.0.7",
66
+ "@vitest/coverage-v8": "^4.1.9",
67
+ eslint: "^10.6.0",
68
+ husky: "^9.1.7",
69
+ "lint-staged": "^17.0.8",
70
+ typescript: "^6.0.3",
71
+ vite: "^8.1.3",
72
+ vitest: "^4.1.9",
73
+ vue: "^3.5.39"
74
+ },
75
+ publishConfig: {
76
+ registry: "https://registry.npmjs.org/",
77
+ access: "public",
78
+ tag: "latest"
79
+ }
80
+ }, C = _(process.cwd(), "docpress"), w = _(process.cwd(), "docpress/docs"), T = _(process.cwd(), "docpress/docs/index.md"), ae = _(process.cwd(), "docpress/docs/forks.md"), E = _(process.cwd(), "docpress/.vitepress/config.ts"), oe = _(process.cwd(), "docpress/.vitepress/theme"), se = _(process.cwd(), "docpress/.vitepress/theme/extras"), D = process.env.NODE_ENV === "development" ? _(import.meta.dirname, "../../public/templates/theme") : _(import.meta.dirname, "./templates/theme"), ce = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, le = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, ue = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, de = /^\d{2}-/;
81
+ //#endregion
82
+ //#region src/utils/functions.ts
83
+ async function O(e) {
84
+ try {
85
+ return (await fetch(e, {
86
+ method: "HEAD",
87
+ redirect: "manual"
88
+ })).status;
89
+ } catch {
90
+ return 500;
91
+ }
92
+ }
93
+ function k(e, t) {
94
+ let n = "";
95
+ return t?.removeDot && (n = e.startsWith(".") ? e.slice(1) : e, n = n.replaceAll(".", "-")), t?.removeIdx && (n = (n || e).replace(de, "")), 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
+ }
97
+ function A(e, { clean: t } = { clean: !1 }) {
98
+ try {
99
+ t && a(e) && v(`${e}/*`, { glob: !0 }), a(e) || o(e, { recursive: !0 });
100
+ } catch (e) {
101
+ console.error(e);
102
+ }
55
103
  }
56
104
  function fe(e) {
57
- return A(e).filter((t) => y(t).endsWith(".md"));
58
- }
59
- function Be(e) {
60
- return e.reduce((t, r, o, s) => o ? o === s.length - 1 ? `${t} or "${r}"` : `${t}, "${r}"` : `"${r}"`, "");
61
- }
62
- function qe(e) {
63
- return JSON.parse(S(`${C}/user-${e}.json`).toString());
64
- }
65
- function Ke(e) {
66
- return JSON.parse(S(`${C}/repos-${e}.json`).toString());
67
- }
68
- function U(...e) {
69
- return e.reduce((t, r) => (r === null || Object.keys(r).forEach((o) => {
70
- const s = t ? t[o] : null, i = r[o];
71
- re(s) && re(i) ? t[o] = U(s, i) : t[o] = i;
72
- }), t), {});
73
- }
74
- function re(e) {
75
- return e && typeof e == "object" && !Array.isArray(e);
76
- }
77
- function W(e) {
78
- if (!e)
79
- return {};
80
- try {
81
- const t = u(process.cwd(), e), r = S(t, "utf8");
82
- return JSON.parse(r);
83
- } catch {
84
- return {};
85
- }
86
- }
87
- function k(e) {
88
- return e.split(",");
89
- }
90
- function Xe(e, t) {
91
- const o = S(e, "utf8").replace(He, (s, i, n) => `[${i}](${t}/${n})`);
92
- v(e, o, "utf8");
93
- }
94
- function Ye(e, t) {
95
- const o = S(e, "utf8").replace(Me, (s, i, n, c) => `[${i}](${t}/${c})`).replace(Ue, (s, i, n, c) => `[${i}](${c})`);
96
- v(e, o, "utf8");
97
- }
98
- function Qe() {
99
- return typeof Number(process.env.LOG_LEVEL) == "number" && !Number.isNaN(Number(process.env.LOG_LEVEL)) ? Number(process.env.LOG_LEVEL) : 30;
100
- }
101
- const oe = {
102
- error: { color: "red", level: 10 },
103
- warn: { color: "yellow", level: 20 },
104
- info: { color: "white", level: 30 },
105
- success: { color: "green", level: 30 },
106
- trace: { color: "white", level: 40 },
107
- debug: { color: "blue", level: 50 }
105
+ try {
106
+ return d(e).isDirectory();
107
+ } catch {
108
+ return !1;
109
+ }
110
+ }
111
+ function j(e) {
112
+ try {
113
+ return d(e).isFile();
114
+ } catch {
115
+ return !1;
116
+ }
117
+ }
118
+ function M(e) {
119
+ return (Array.isArray(e) ? e : [e]).flatMap((e) => j(e) ? [e] : fe(e) ? c(e).sort().flatMap((t) => M(h(e, t))) : []);
120
+ }
121
+ function N(e) {
122
+ return M(e).filter((e) => p(e).endsWith(".md"));
123
+ }
124
+ function pe(e) {
125
+ return e.reduce((e, t, n, r) => n ? n === r.length - 1 ? `${e} or "${t}"` : `${e}, "${t}"` : `"${t}"`, "");
126
+ }
127
+ function me(e) {
128
+ return JSON.parse(s(`${C}/user-${e}.json`).toString());
129
+ }
130
+ function he(e) {
131
+ return JSON.parse(s(`${C}/repos-${e}.json`).toString());
132
+ }
133
+ function P(...e) {
134
+ return e.reduce((e, t) => (t === null || Object.keys(t).forEach((n) => {
135
+ let r = e ? e[n] : null, i = t[n];
136
+ F(r) && F(i) ? e[n] = P(r, i) : e[n] = i;
137
+ }), e), {});
138
+ }
139
+ function F(e) {
140
+ return e && typeof e == "object" && !Array.isArray(e);
141
+ }
142
+ function I(e) {
143
+ if (!e) return {};
144
+ let t = _(process.cwd(), e), n;
145
+ try {
146
+ n = s(t, "utf8");
147
+ } catch {
148
+ throw Error(`Cannot read config file '${e}'.`);
149
+ }
150
+ try {
151
+ return JSON.parse(n);
152
+ } catch {
153
+ throw Error(`Invalid JSON in config file '${e}'.`);
154
+ }
155
+ }
156
+ function L(e) {
157
+ return e.split(",");
158
+ }
159
+ function ge(e, t) {
160
+ f(e, s(e, "utf8").replace(ce, (e, n, r) => `[${n}](${t}/${r})`), "utf8");
161
+ }
162
+ function _e(e, t) {
163
+ f(e, s(e, "utf8").replace(le, (e, n, r, i) => `[${n}](${t}/${i})`).replace(ue, (e, t, n, r) => `[${t}](${r})`), "utf8");
164
+ }
165
+ //#endregion
166
+ //#region src/utils/logger.ts
167
+ function ve() {
168
+ let e = Number(process.env.LOG_LEVEL);
169
+ return Number.isNaN(e) ? 30 : e;
170
+ }
171
+ var R = {
172
+ error: {
173
+ color: "red",
174
+ level: 10
175
+ },
176
+ warn: {
177
+ color: "yellow",
178
+ level: 20
179
+ },
180
+ info: {
181
+ color: "white",
182
+ level: 30
183
+ },
184
+ success: {
185
+ color: "green",
186
+ level: 30
187
+ },
188
+ trace: {
189
+ color: "white",
190
+ level: 40
191
+ },
192
+ debug: {
193
+ color: "blue",
194
+ level: 50
195
+ }
108
196
  };
109
- function a(e, t = "info", r) {
110
- const o = r ? ee[r](e) : ee[oe[t].color](e), s = t === "success" ? "info" : t;
111
- Qe() >= oe[t].level && console[s](o);
112
- }
113
- const se = ["github"], d = l.object({
114
- // Global
115
- usernames: l.string().array().describe("List of comma separated Git provider usernames used to collect data."),
116
- // Fetch
117
- branch: l.string().describe("Branch used to collect Git provider data.").default("main"),
118
- gitProvider: l.enum(se).describe(`Git provider used to retrieve data. Values should be ${Be(se)}.`).default("github"),
119
- reposFilter: l.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
120
- // Prepare
121
- extraHeaderPages: l.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
122
- extraPublicContent: l.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
123
- extraTheme: l.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
124
- forks: l.boolean().describe("Whether or not to create the dedicated fork page that aggregate external contributions.").default(!1),
125
- vitepressConfig: l.any().describe("Path to the vitepress configuration file."),
126
- websiteTitle: l.string().describe("Website title."),
127
- websiteTagline: l.string().describe("Website tagline.")
128
- }), H = 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 || "").optional(),
132
- reposFilter: l.string().describe(d.shape.reposFilter.description || "").optional(),
133
- extraHeaderPages: l.string().describe(d.shape.extraHeaderPages.description || "").optional(),
134
- extraPublicContent: l.string().describe(d.shape.extraPublicContent.description || "").optional(),
135
- extraTheme: l.string().describe(d.shape.extraTheme.description || "").optional(),
136
- vitepressConfig: l.string().describe(d.shape.vitepressConfig.description || "").optional()
137
- }), I = d.partial().extend({
138
- config: l.string().describe("Path to the docpress configuration file.").optional(),
139
- token: l.string().describe("Git provider token used to collect data.").optional(),
140
- usernames: l.string().describe(d.shape.usernames.description || "").transform(k).optional(),
141
- reposFilter: l.string().describe(d.shape.reposFilter.description || "").transform(k).optional(),
142
- extraHeaderPages: l.string().describe(d.shape.extraHeaderPages.description || "").transform(k).optional(),
143
- extraPublicContent: l.string().describe(d.shape.extraPublicContent.description || "").transform(k).optional(),
144
- extraTheme: l.string().describe(d.shape.extraTheme.description || "").transform(k).optional(),
145
- vitepressConfig: l.string().describe(d.shape.vitepressConfig.description || "").optional()
197
+ function z(e, t = "info", n) {
198
+ let r = n ? y[n](e) : y[R[t].color](e), i = t === "success" ? "info" : t;
199
+ ve() >= R[t].level && console[i](r);
200
+ }
201
+ //#endregion
202
+ //#region src/schemas/global.ts
203
+ var B = ["github", "gitlab"], V = b.object({
204
+ usernames: b.string().array().describe("List of comma separated Git provider usernames used to collect data."),
205
+ branch: b.string().default("main").describe("Branch used to collect Git provider data."),
206
+ gitProvider: b.enum(B).default("github").describe(`Git provider used to retrieve data. Values should be ${pe(B)}.`),
207
+ reposFilter: b.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
208
+ extraHeaderPages: b.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
209
+ extraPublicContent: b.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
210
+ extraTheme: b.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
211
+ forks: b.boolean().default(!1).describe("Whether or not to create the dedicated fork page that aggregate external contributions."),
212
+ vitepressConfig: b.any().optional().describe("Path to the vitepress configuration file."),
213
+ websiteTitle: b.string().describe("Website title."),
214
+ websiteTagline: b.string().describe("Website tagline.")
215
+ }), H = V.partial().extend({
216
+ branch: b.string().optional().describe(V.shape.branch.description || ""),
217
+ gitProvider: b.enum(B).optional().describe(V.shape.gitProvider.description || ""),
218
+ forks: b.boolean().optional().describe(V.shape.forks.description || ""),
219
+ config: b.string().optional().describe("Path to the docpress configuration file."),
220
+ token: b.string().optional().describe("Git provider token used to collect data."),
221
+ usernames: b.string().transform(L).optional().describe(V.shape.usernames.description || ""),
222
+ reposFilter: b.string().transform(L).optional().describe(V.shape.reposFilter.description || ""),
223
+ extraHeaderPages: b.string().transform(L).optional().describe(V.shape.extraHeaderPages.description || ""),
224
+ extraPublicContent: b.string().transform(L).optional().describe(V.shape.extraPublicContent.description || ""),
225
+ extraTheme: b.string().transform(L).optional().describe(V.shape.extraTheme.description || ""),
226
+ vitepressConfig: b.string().optional().describe(V.shape.vitepressConfig.description || "")
146
227
  });
147
- function Ze(e) {
148
- 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) : {};
149
- }
150
- function et(e) {
151
- if (!e.usernames?.length)
152
- throw new Error("The usernames field is required");
153
- return e;
154
- }
155
- const tt = I.partial().transform((e) => {
156
- try {
157
- const { config: t, vitepressConfig: r, token: o, ...s } = e;
158
- a(`Debug: Schema transform input: ${JSON.stringify(e)}`, "debug");
159
- const i = W(t), n = Ze(i), c = {
160
- forks: !1,
161
- ...n,
162
- ...s,
163
- ...r ? {
164
- vitepressConfig: {
165
- ...W(r) || {},
166
- ...n.vitepressConfig || {}
167
- }
168
- } : {}
169
- };
170
- return a(`Debug: Final merged config: ${JSON.stringify(c)}`, "debug"), et({ ...c, token: o });
171
- } catch (t) {
172
- 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);
173
- }
174
- }), rt = I.pick({}), ot = I.pick({
175
- branch: !0,
176
- config: !0,
177
- gitProvider: !0,
178
- reposFilter: !0,
179
- token: !0,
180
- usernames: !0
181
- }), st = I.pick({
182
- extraHeaderPages: !0,
183
- extraPublicContent: !0,
184
- extraTheme: !0,
185
- config: !0,
186
- gitProvider: !0,
187
- reposFilter: !0,
188
- token: !0,
189
- usernames: !0,
190
- vitepressConfig: !0
191
- }), nt = {
192
- build: rt,
193
- fetch: ot,
194
- prepare: st,
195
- global: tt
228
+ function ye(e) {
229
+ if (!e) return {};
230
+ for (let t of [
231
+ "usernames",
232
+ "reposFilter",
233
+ "extraHeaderPages",
234
+ "extraPublicContent",
235
+ "extraTheme"
236
+ ]) e[t] && typeof e[t] == "string" && (e[t] = [e[t]]);
237
+ return e;
238
+ }
239
+ function be(e) {
240
+ let t = V.partial().safeParse(e);
241
+ if (!t.success) throw Error(b.prettifyError(t.error));
242
+ return t.data;
243
+ }
244
+ function xe(e) {
245
+ if (!e.usernames?.length) throw Error("The usernames field is required");
246
+ return e;
247
+ }
248
+ var Se = H.partial().transform((e) => {
249
+ try {
250
+ let { config: t, vitepressConfig: n, token: r, ...i } = e;
251
+ z(`Debug: Schema transform input: ${JSON.stringify(e)}`, "debug");
252
+ let a = be(ye(I(t))), o = {
253
+ branch: "main",
254
+ gitProvider: "github",
255
+ forks: !1,
256
+ ...a,
257
+ ...i,
258
+ ...n ? { vitepressConfig: {
259
+ ...a.vitepressConfig || {},
260
+ ...I(n) || {}
261
+ } } : {}
262
+ };
263
+ return z(`Debug: Final merged config: ${JSON.stringify(o)}`, "debug"), xe({
264
+ ...o,
265
+ token: r
266
+ });
267
+ } catch (e) {
268
+ z(" An error occurred while checking configuration.", "error"), e instanceof Error ? z(` ${e.message}`, "error") : z(` ${JSON.stringify(e, null, 2)}`, "error"), process.exit(1);
269
+ }
270
+ });
271
+ //#endregion
272
+ //#region src/utils/commands.ts
273
+ function U(e, t) {
274
+ z("Initializing Docpress...", "info", "blue"), z("\n\n-> Checking for required environment settings and configurations.", "info"), z(` Debug info - opts: ${JSON.stringify(t)}`, "debug"), z(` Debug info - cmd: ${e}`, "debug");
275
+ let n = Se.safeParse(t);
276
+ return n.success || (z(` An error occurred while checking configuration.\n ${b.prettifyError(n.error)}`, "error"), process.exit(1)), z(" Setup complete! Ready to process your documentation.", "info"), n.data;
277
+ }
278
+ function W(e, t) {
279
+ return Object.fromEntries(Object.entries(t).filter(([t]) => e.getOptionValueSource(t) !== "default"));
280
+ }
281
+ function G(e, t) {
282
+ for (let n of t) e.addOption(n);
283
+ return e;
284
+ }
285
+ //#endregion
286
+ //#region src/lib/git.ts
287
+ var K = {
288
+ debug: () => {},
289
+ info: () => {},
290
+ warn: (e) => {
291
+ e.includes("404") || console.warn(e);
292
+ },
293
+ error: (e) => {
294
+ e.includes("404") || console.error(e);
295
+ }
196
296
  };
197
- function it(e, t) {
198
- const r = W(e);
199
- if (!r) return null;
200
- const o = d.partial().safeParse(r);
201
- return o.success ? {
202
- ...o.data,
203
- config: e,
204
- token: t || void 0
205
- } : null;
206
- }
207
- function K(e, t) {
208
- a("Initializing Docpress...", "info", "blue"), a(`
209
-
210
- -> Checking for required environment settings and configurations.`, "info"), a(` Debug info - opts: ${JSON.stringify(t)}`, "debug"), a(` Debug info - options[cmd]: ${e}`, "debug");
211
- try {
212
- if (e === "global" && typeof t.config == "string") {
213
- const o = it(
214
- t.config,
215
- typeof t.token == "string" ? t.token : void 0
216
- );
217
- if (o)
218
- return o;
219
- }
220
- const r = nt[e].safeParse(t);
221
- if (!r.success) {
222
- try {
223
- const o = Re(r.error).toString();
224
- a(` An error occurred while checking configuration.
225
- ${o}`, "error");
226
- } catch {
227
- a(` An error occurred while checking configuration.
228
- ${JSON.stringify(r.error, null, 2)}`, "error");
229
- }
230
- process.exit(1);
231
- }
232
- return a(" Setup complete! Ready to process your documentation.", "info"), r.data;
233
- } catch (r) {
234
- 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);
235
- }
236
- }
237
- function j(e, t) {
238
- for (const r of t)
239
- e.addOption(r);
240
- return e;
241
- }
242
- async function at({ username: e, token: t, branch: r }) {
243
- a(` Get infos for username '${e}'.`, "info");
244
- const o = new de({ auth: t });
245
- a(" Get user infos.", "debug");
246
- const { data: s } = await o.rest.users.getByUsername({ username: e });
247
- a(" Get repositories infos.", "debug");
248
- const { data: i } = await o.rest.repos.listForUser({ username: e, sort: "full_name", per_page: 500 });
249
- return { user: s, repos: i, branch: r };
250
- }
251
- async function ct({
252
- repository: e,
253
- token: t
254
- }) {
255
- a(` Get contributors infos for repository '${e.name}'.`, "info");
256
- const r = new de({
257
- auth: t,
258
- log: {
259
- debug: () => {
260
- },
261
- info: () => {
262
- },
263
- warn: (i) => {
264
- i.includes("404") || console.warn(i);
265
- },
266
- error: (i) => {
267
- i.includes("404") || console.error(i);
268
- }
269
- }
270
- }), { data: o } = await r.rest.repos.get({
271
- owner: e.owner.login,
272
- repo: e.name
273
- });
274
- if (!o.source?.owner?.login)
275
- return { source: o.source, contributors: [] };
276
- const s = [];
277
- try {
278
- for await (const { data: i } of r.paginate.iterator(
279
- r.rest.repos.listContributors,
280
- {
281
- owner: o.source.owner.login,
282
- repo: o.parent?.name ?? o.name,
283
- per_page: 500
284
- }
285
- ))
286
- s.push(...i);
287
- } catch (i) {
288
- return a(
289
- ` Failed to get contributors infos for repository '${e.name}'. Error : ${i.message}`,
290
- "warn"
291
- ), { source: o.source, contributors: [] };
292
- }
293
- return { source: o.source, contributors: s };
294
- }
295
- async function ut(e, t, r, o, s) {
296
- F(r, { clean: !0 });
297
- try {
298
- const i = _e({ baseDir: r });
299
- await i.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
300
- for (const n of s)
301
- a(` Add '${n}' to '${e}' sparse-checkout file.`, "debug"), le(u(r, ".git/info/sparse-checkout"), `${n}
302
- `, "utf8");
303
- 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 });
304
- } catch (i) {
305
- a(` Error when cloning repository: ${i}.`, "error");
306
- }
307
- }
308
- async function lt(e, t, r) {
309
- 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);
310
- return {
311
- rootReadmeStatus: n,
312
- docsFolderStatus: c,
313
- docsReadmeStatus: p
314
- };
315
- }
316
- async function dt({ username: e, branch: t, reposFilter: r, token: o }) {
317
- await at({ username: e, token: o, branch: t }).then(async ({ user: s, repos: i, branch: n }) => mt(s, i, n, r)).then(async ({ repos: s }) => gt(s, r));
318
- }
319
- async function pt(e, t, r) {
320
- const o = [];
321
- return await Promise.all(
322
- e.map(async (s) => {
323
- const i = t ?? s.default_branch ?? "main", n = u(pe, f(s.name, { removeDot: !0 })), c = me(s, r);
324
- let p = [];
325
- !s.fork && !s.private && !c && (p = await ft(s, i)), o.push({
326
- ...s,
327
- docpress: {
328
- filtered: c,
329
- branch: i,
330
- includes: p,
331
- projectPath: n,
332
- raw_url: `https://raw.githubusercontent.com/${s.owner.login}/${s.name}/${i}`,
333
- replace_url: `https://github.com/${s.owner.login}/${s.name}/tree/${i}`
334
- }
335
- });
336
- })
337
- ), o;
338
- }
339
- async function ft(e, t) {
340
- const r = await lt(e.owner.login, e.name, t), o = [];
341
- 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);
342
- }
343
- async function mt(e, t, r, o) {
344
- v(`${C}/user-${e.login}.json`, JSON.stringify(e, null, 2));
345
- const s = await pt(t, r, o);
346
- return v(`${C}/repos-${e.login}.json`, JSON.stringify(s, null, 2)), { user: e, repos: s };
347
- }
348
- async function gt(e, t) {
349
- if (!e) {
350
- a(" No repository respect docpress rules.", "warn");
351
- return;
352
- }
353
- await Promise.all(
354
- e.filter((r) => !me(r, t)).map(async (r) => {
355
- await ut(r.name, r.clone_url, r.docpress.projectPath, r.docpress.branch, r.docpress.includes);
356
- })
357
- );
358
- }
359
- function me(e, t) {
360
- 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;
361
- return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !i);
362
- }
363
- const L = [
364
- m("-C, --config <string>", H.shape.config.description),
365
- m("-T, --token <string>", H.shape.token.description),
366
- m("-U, --usernames <string>", H.shape.usernames.description)
367
- ], ne = "fetch", ge = [
368
- m("-b, --branch <string>", d.shape.branch.description).default(d.shape.branch.default),
369
- m("-g, --git-provider <string>", d.shape.gitProvider.description).default(d.shape.gitProvider.default),
370
- m("-r, --repos-filter <string>", d.shape.reposFilter.description)
371
- ], ht = j(J(ne), [...ge, ...L]).description("Fetch docs with the given username(s) and git provider.").action(async (e) => {
372
- const t = K(ne, e);
373
- await he(t);
297
+ async function Ce({ username: e, token: t, branch: n }) {
298
+ z(` Get infos for username '${e}'.`, "info");
299
+ let r = new x({
300
+ auth: t,
301
+ log: K
302
+ });
303
+ z(" Get user infos.", "debug");
304
+ let { data: i } = await r.rest.users.getByUsername({ username: e }).catch((t) => {
305
+ throw t.status === 404 ? /* @__PURE__ */ Error(`No GitHub user found for '${e}'.`) : t;
306
+ });
307
+ return z(" Get repositories infos.", "debug"), {
308
+ user: i,
309
+ repos: await r.paginate(r.rest.repos.listForUser, {
310
+ username: e,
311
+ sort: "full_name",
312
+ per_page: 100
313
+ }),
314
+ branch: n
315
+ };
316
+ }
317
+ async function we({ repository: e, token: t }) {
318
+ z(` Get contributors infos for repository '${e.name}'.`, "info");
319
+ let n = new x({
320
+ auth: t,
321
+ log: K
322
+ }), { data: r } = await n.rest.repos.get({
323
+ owner: e.owner.login,
324
+ repo: e.name
325
+ });
326
+ if (!r.source?.owner?.login) return {
327
+ source: r.source,
328
+ contributors: []
329
+ };
330
+ let i = [];
331
+ try {
332
+ for await (let { data: e } of n.paginate.iterator(n.rest.repos.listContributors, {
333
+ owner: r.source.owner.login,
334
+ repo: r.parent?.name ?? r.name,
335
+ per_page: 100
336
+ })) i.push(...e);
337
+ } catch (t) {
338
+ return z(` Failed to get contributors infos for repository '${e.name}'. Error : ${t.message}`, "warn"), {
339
+ source: r.source,
340
+ contributors: []
341
+ };
342
+ }
343
+ return {
344
+ source: r.source,
345
+ contributors: i
346
+ };
347
+ }
348
+ async function Te(e, t, n, a, o) {
349
+ A(n, { clean: !0 });
350
+ try {
351
+ let s = ee({
352
+ baseDir: n,
353
+ config: [
354
+ "maintenance.auto=false",
355
+ "gc.auto=0",
356
+ "fetch.writeCommitGraph=false"
357
+ ]
358
+ });
359
+ await s.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
360
+ for (let t of o) z(` Add '${t}' to '${e}' sparse-checkout file.`, "debug"), r(_(n, ".git/info/sparse-checkout"), `${t}\n`, "utf8");
361
+ z(` Clone repository '${e}'.`, "info"), await s.pull("origin", a), o.some((e) => e.includes("docs")) && (i(_(n, "docs"), n, { recursive: !0 }), u(_(n, "docs"), { recursive: !0 })), u(_(n, ".git"), { recursive: !0 });
362
+ } catch (e) {
363
+ z(` Error when cloning repository: ${e}.`, "error");
364
+ }
365
+ }
366
+ //#endregion
367
+ //#region src/lib/gitlab.ts
368
+ var Ee = "https://gitlab.com/api/v4";
369
+ async function q(e, t) {
370
+ let n = await fetch(`${Ee}${e}`, { headers: t ? { "PRIVATE-TOKEN": t } : {} });
371
+ if (!n.ok) throw Error(`GitLab API request failed for '${e}' (status: ${n.status}).`);
372
+ return {
373
+ data: await n.json(),
374
+ headers: n.headers
375
+ };
376
+ }
377
+ async function J(e, t) {
378
+ let n = e.includes("?") ? "&" : "?", r = [], i = "1";
379
+ for (; i;) {
380
+ let { data: a, headers: o } = await q(`${e}${n}per_page=100&page=${i}`, t);
381
+ r.push(...a), i = o.get("x-next-page") || null;
382
+ }
383
+ return r;
384
+ }
385
+ function Y(e) {
386
+ return {
387
+ login: e.username ?? e.path,
388
+ name: e.name,
389
+ bio: e.bio ?? e.description ?? null,
390
+ avatar_url: e.avatar_url,
391
+ html_url: e.web_url
392
+ };
393
+ }
394
+ function X(e, t) {
395
+ return {
396
+ name: e.path,
397
+ owner: { login: t },
398
+ fork: !!e.forked_from_project,
399
+ private: e.visibility !== "public",
400
+ size: +!!e.default_branch,
401
+ default_branch: e.default_branch,
402
+ clone_url: e.http_url_to_repo,
403
+ html_url: e.web_url,
404
+ description: e.description,
405
+ stargazers_count: e.star_count
406
+ };
407
+ }
408
+ async function De({ username: e, token: t, branch: n }) {
409
+ z(` Get infos for username '${e}'.`, "info");
410
+ let { data: r } = await q(`/users?username=${encodeURIComponent(e)}`, t);
411
+ if (r.length) {
412
+ let e = r[0];
413
+ t && (e = await q(`/users/${r[0].id}`, t).then((e) => e.data).catch(() => r[0])), z(" Get repositories infos.", "debug");
414
+ let i = await J(`/users/${r[0].id}/projects`, t);
415
+ return {
416
+ user: Y(e),
417
+ repos: i.map((t) => X(t, e.username)),
418
+ branch: n
419
+ };
420
+ }
421
+ z(` No GitLab user '${e}' found, trying groups.`, "debug");
422
+ let i = await q(`/groups/${encodeURIComponent(e)}?with_projects=false`, t).then((e) => e.data).catch(() => {
423
+ throw Error(`No GitLab user or group found for '${e}'.`);
424
+ }), a = await J(`/groups/${encodeURIComponent(e)}/projects`, t);
425
+ return {
426
+ user: Y(i),
427
+ repos: a.map((e) => X(e, i.path)),
428
+ branch: n
429
+ };
430
+ }
431
+ //#endregion
432
+ //#region src/lib/fetch.ts
433
+ function Z(e, t, n) {
434
+ if (n === "gitlab") {
435
+ let n = e.html_url ?? `https://gitlab.com/${e.owner.login}/${e.name}`;
436
+ return {
437
+ blob_url: `${n}/-/blob/${t}`,
438
+ tree_url: `${n}/-/tree/${t}`,
439
+ raw_url: `${n}/-/raw/${t}`
440
+ };
441
+ }
442
+ let r = e.html_url ?? `https://github.com/${e.owner.login}/${e.name}`;
443
+ return {
444
+ blob_url: `${r}/blob/${t}`,
445
+ tree_url: `${r}/tree/${t}`,
446
+ raw_url: `https://raw.githubusercontent.com/${e.owner.login}/${e.name}/${t}`
447
+ };
448
+ }
449
+ async function Oe(e) {
450
+ return {
451
+ rootReadmeStatus: await O(`${e.blob_url}/README.md`),
452
+ docsFolderStatus: await O(`${e.tree_url}/docs`),
453
+ docsReadmeStatus: await O(`${e.blob_url}/docs/01-readme.md`)
454
+ };
455
+ }
456
+ async function ke({ username: e, branch: t, reposFilter: n, gitProvider: r, token: i }) {
457
+ await (r === "gitlab" ? De : Ce)({
458
+ username: e,
459
+ token: i,
460
+ branch: t
461
+ }).then(async ({ user: e, repos: t, branch: i }) => Me(e, t, i, n, r)).then(async ({ repos: e }) => Ne(e, n));
462
+ }
463
+ async function Ae(e, t, n, r) {
464
+ let i = [];
465
+ return await Promise.all(e.map(async (e) => {
466
+ let a = t ?? e.default_branch ?? "main", o = _(w, k(e.name, { removeDot: !0 })), s = Q(e, n), c = Z(e, a, r), l = [];
467
+ !e.fork && !e.private && !s && (l = await je(e, a, r)), i.push({
468
+ ...e,
469
+ docpress: {
470
+ filtered: s,
471
+ branch: a,
472
+ includes: l,
473
+ projectPath: o,
474
+ raw_url: c.raw_url,
475
+ replace_url: c.tree_url
476
+ }
477
+ });
478
+ })), i;
479
+ }
480
+ async function je(e, t, n) {
481
+ let r = await Oe(Z(e, t, n)), i = [];
482
+ 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);
483
+ }
484
+ async function Me(e, t, n, r, i) {
485
+ f(`${C}/user-${e.login}.json`, JSON.stringify(e, null, 2));
486
+ let a = await Ae(t, n, r, i);
487
+ return f(`${C}/repos-${e.login}.json`, JSON.stringify(a, null, 2)), {
488
+ user: e,
489
+ repos: a
490
+ };
491
+ }
492
+ async function Ne(e, t) {
493
+ if (!e) {
494
+ z(" No repository respect docpress rules.", "warn");
495
+ return;
496
+ }
497
+ await Promise.all(e.filter((e) => !Q(e, t)).map(async (e) => {
498
+ await Te(e.name, e.clone_url, e.docpress.projectPath, e.docpress.branch, e.docpress.includes);
499
+ }));
500
+ }
501
+ function Q(e, t) {
502
+ 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;
503
+ return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.private && !a);
504
+ }
505
+ //#endregion
506
+ //#region src/commands/global.ts
507
+ var $ = [
508
+ n("-C, --config <string>", H.shape.config.description),
509
+ n("-T, --token <string>", H.shape.token.description),
510
+ n("-U, --usernames <string>", H.shape.usernames.description)
511
+ ], Pe = "fetch", Fe = [
512
+ n("-b, --branch <string>", V.shape.branch.description).default(V.shape.branch.def.defaultValue),
513
+ n("-g, --git-provider <string>", V.shape.gitProvider.description).default(V.shape.gitProvider.def.defaultValue),
514
+ n("-r, --repos-filter <string>", V.shape.reposFilter.description)
515
+ ], Ie = G(t(Pe), [...Fe, ...$]).description("Fetch docs with the given username(s) and git provider.").action(async (e, t) => {
516
+ await Le(U(Pe, W(t, e)));
374
517
  });
375
- async function he(e) {
376
- const { usernames: t, reposFilter: r, token: o, branch: s, gitProvider: i } = e;
377
- a(`
378
- -> Start fetching documentation files. This may take a moment, especially for larger repositories.`, "info"), F(C, { clean: !0 });
379
- for (const n of t) {
380
- const c = t.length > 1 ? r?.filter((p) => p.startsWith(`${n}/`)).map((p) => p.replace(`${n}/`, "")) : r;
381
- await dt({ username: n, branch: s, reposFilter: c, token: o });
382
- }
383
- }
384
- async function bt(e) {
385
- const t = console.warn;
386
- console.warn = function(...r) {
387
- r.length > 0 && typeof r[0] == "string" && (r[0].includes("[Vue warn]: Invalid watch source:") || r[0].includes("{ open: false }")) || t.apply(console, r);
388
- };
389
- try {
390
- return await e();
391
- } finally {
392
- console.warn = t;
393
- }
394
- }
395
- const wt = "build", yt = j(J(wt), L).description("Build vitepress website.").action(async (e) => {
396
- await be();
518
+ async function Le(e) {
519
+ let { usernames: t, reposFilter: n, token: r, branch: i, gitProvider: a } = e;
520
+ z("\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.", "info"), A(C, { clean: !0 });
521
+ for (let e of t) await ke({
522
+ username: e,
523
+ branch: i,
524
+ reposFilter: t.length > 1 ? n?.filter((t) => t.replace(/^!/, "").startsWith(`${e}/`)).map((t) => t.replace(`${e}/`, "")) : n,
525
+ gitProvider: a,
526
+ token: r
527
+ });
528
+ }
529
+ //#endregion
530
+ //#region src/commands/build.ts
531
+ async function Re(e) {
532
+ let t = console.warn;
533
+ console.warn = function(...e) {
534
+ e.length > 0 && typeof e[0] == "string" && (e[0].includes("[Vue warn]: Invalid watch source:") || e[0].includes("{ open: false }")) || t.apply(console, e);
535
+ };
536
+ try {
537
+ return await e();
538
+ } finally {
539
+ console.warn = t;
540
+ }
541
+ }
542
+ var ze = G(t("build"), $).description("Build vitepress website.").action(async (e) => {
543
+ await Be();
397
544
  });
398
- async function be() {
399
- a(`
400
- -> Start building Vitepress website.
401
-
402
- `, "info");
403
- try {
404
- await bt(async () => {
405
- await Ae(C, {
406
- onAfterConfigResolve(e) {
407
- Ie(e);
408
- }
409
- });
410
- }), a(`
411
-
412
- Docpress build succedeed.`, "success");
413
- } catch (e) {
414
- a(`
415
-
416
- Docpress build failed : ${e}`, "error"), process.exit(1);
417
- }
418
- }
419
- function vt(e, t) {
420
- const r = S(e, { encoding: "utf8" });
421
- F(_(t)), v(t, r);
422
- }
423
- const ie = {
424
- base: "/",
425
- lang: "en-US",
426
- vite: {
427
- publicDir: "../public"
428
- },
429
- title: "Home",
430
- description: "Docpress",
431
- srcDir: "./docs",
432
- cleanUrls: !1,
433
- ignoreDeadLinks: "localhostLinks",
434
- themeConfig: {
435
- outline: [2, 3],
436
- search: {
437
- provider: "local",
438
- options: {
439
- translations: {
440
- button: {
441
- buttonText: "Search...",
442
- buttonAriaLabel: "Search"
443
- },
444
- modal: {
445
- backButtonTitle: "erase search",
446
- displayDetails: "show details",
447
- noResultsText: "No results for : ",
448
- resetButtonTitle: "cancel search",
449
- footer: {
450
- selectText: "go to",
451
- navigateText: "navigate in results",
452
- closeText: "close"
453
- }
454
- }
455
- }
456
- }
457
- }
458
- }
545
+ async function Be() {
546
+ z("\n-> Start building Vitepress website.\n\n", "info");
547
+ try {
548
+ await Re(async () => {
549
+ await te(C, { onAfterConfigResolve(e) {
550
+ ne(e);
551
+ } });
552
+ }), z("\n\nDocpress build succeeded.", "success");
553
+ } catch (e) {
554
+ z(`\n\nDocpress build failed : ${e}`, "error"), process.exit(1);
555
+ }
556
+ }
557
+ //#endregion
558
+ //#region src/utils/templates.ts
559
+ function Ve(e, t) {
560
+ let n = s(e, { encoding: "utf8" });
561
+ A(m(t)), f(t, n);
562
+ }
563
+ //#endregion
564
+ //#region src/lib/vitepress.ts
565
+ var He = {
566
+ base: "/",
567
+ lang: "en-US",
568
+ vite: { publicDir: "../public" },
569
+ title: "Home",
570
+ description: "Docpress",
571
+ srcDir: "./docs",
572
+ cleanUrls: !1,
573
+ ignoreDeadLinks: "localhostLinks",
574
+ themeConfig: {
575
+ outline: [2, 3],
576
+ search: {
577
+ provider: "local",
578
+ options: { translations: {
579
+ button: {
580
+ buttonText: "Search...",
581
+ buttonAriaLabel: "Search"
582
+ },
583
+ modal: {
584
+ backButtonTitle: "erase search",
585
+ displayDetails: "show details",
586
+ noResultsText: "No results for : ",
587
+ resetButtonTitle: "cancel search",
588
+ footer: {
589
+ selectText: "go to",
590
+ navigateText: "navigate in results",
591
+ closeText: "close"
592
+ }
593
+ }
594
+ } }
595
+ }
596
+ }
459
597
  };
460
- function $t(e, t, r) {
461
- return r ? U(ie, r, { themeConfig: { sidebar: e, nav: t } }) : U(ie, { themeConfig: { sidebar: e, nav: t } });
462
- }
463
- async function xt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: r, vitepressConfig: o, forks: s, token: i, username: n, websiteTitle: c, websiteTagline: p }) {
464
- const h = qe(n), b = Ke(n).reduce(({ internals: w, forks: $ }, x) => {
465
- const { clone_url: P, private: Se, fork: Y, docpress: Q } = x;
466
- if (P && !Se && !Q.filtered) {
467
- if (!Y && Q.includes.length)
468
- return { internals: [...w, x], forks: $ };
469
- if (Y)
470
- return { internals: w, forks: [...$, x] };
471
- }
472
- return { internals: w, forks: $ };
473
- }, { internals: [], forks: [] }), g = { title: c, tagline: p }, { index: V, sidebar: X } = Ft(b.internals, h, g);
474
- let N, D;
475
- if (O(M) && O(E)) {
476
- const w = await _t(E), $ = await At(M);
477
- N = [
478
- ...w.themeConfig?.sidebar ?? [],
479
- ...X
480
- ].sort((x, P) => x.text.localeCompare(P.text)), D = {
481
- ...V,
482
- features: [
483
- ...$.features,
484
- ...V.features
485
- ].sort((x, P) => x.title.localeCompare(P.title))
486
- };
487
- } else
488
- N = X, D = V;
489
- const T = [];
490
- if (e) {
491
- const w = Tt(e);
492
- s ? T.push(...w.filter(($) => $.link !== "/forks")) : T.push(...w);
493
- }
494
- t && (a(" Add extras Vitepress public folder content.", "info"), ae(t, u(C, "public"))), r && (a(" Add extras Vitepress theme files.", "info"), ae(r, u(Ge))), s && n.length && (a(" Add fork page to display external contributions.", "info"), await Rt(b.forks, n, i), T.push({ text: "Forks", link: "/forks" }));
495
- const Ce = $t(N, T, o);
496
- It(Ce, D);
497
- }
498
- function Ct(e, t) {
499
- const r = y(t), s = `${f(r, { mode: "lowercase", removeIdx: !0 }) === "readme.md" ? `
500
- ## Sources` : "# Sources"}
501
-
502
- Take a look at the [project sources](${e}).
503
- `;
504
- le(t, s, "utf8");
505
- }
506
- function St(e, t, r) {
507
- const { name: o, login: s, bio: i } = t, { title: n, tagline: c } = r;
508
- return {
509
- layout: "home",
510
- hero: n ? { name: n, tagline: c } : { name: o ? `${o}'s projects` : `${s}'s projects`, tagline: i ?? "Robots are everywhere 🤖" },
511
- features: e
512
- };
513
- }
514
- function Pt(e, t, r) {
515
- const o = {
516
- title: f(e, { mode: "capitalize", replaceDash: !0 }),
517
- details: t,
518
- link: `/${f(e, { removeDot: !0 })}/introduction`
519
- };
520
- return r ? [...r, o] : [o];
521
- }
522
- function kt(e, t) {
523
- return {
524
- text: f(e, { mode: "capitalize", replaceDash: !0 }),
525
- collapsed: !0,
526
- items: t
527
- };
528
- }
529
- function we(e, t) {
530
- return Object.entries(t).flatMap(([r, o]) => r === "$" ? Array.isArray(o) ? o.map((s) => {
531
- const i = u(e.docpress.projectPath, s);
532
- let n = f(y(i), { mode: "lowercase", removeIdx: !0 });
533
- return n === "readme.md" && (n = "introduction.md"), n !== y(i) && Ee(i, u(_(i), n)), {
534
- text: R(n).name === "introduction" ? "Introduction" : f(n, { mode: "capitalize", replaceDash: !0, removeExt: !0 }),
535
- link: `/${f(e.name, { removeDot: !0 })}/${R(n).name}`
536
- };
537
- }) : [] : typeof o == "object" ? [{
538
- text: f(r, { mode: "capitalize", replaceDash: !0 }),
539
- collapsed: !0,
540
- items: we({ ...e, name: `${e.name}/${r}` }, o)
541
- }] : []);
598
+ function Ue(e, t, n) {
599
+ return n ? P(He, n, { themeConfig: {
600
+ sidebar: e,
601
+ nav: t
602
+ } }) : P(He, { themeConfig: {
603
+ sidebar: e,
604
+ nav: t
605
+ } });
606
+ }
607
+ //#endregion
608
+ //#region src/lib/prepare.ts
609
+ async function We({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, vitepressConfig: r, forks: i, gitProvider: o, token: s, username: c, websiteTitle: l, websiteTagline: u }) {
610
+ let d = i && o !== "gitlab";
611
+ i && !d && z(" The forks page is not supported with the 'gitlab' provider, skipping.", "warn");
612
+ let f = me(c), p = he(c).reduce(({ internals: e, forks: t }, n) => {
613
+ let { clone_url: r, private: i, fork: a, docpress: o } = n;
614
+ if (r && !i && !o.filtered) {
615
+ if (!a && o.includes.length) return {
616
+ internals: [...e, n],
617
+ forks: t
618
+ };
619
+ if (a) return {
620
+ internals: e,
621
+ forks: [...t, n]
622
+ };
623
+ }
624
+ return {
625
+ internals: e,
626
+ forks: t
627
+ };
628
+ }, {
629
+ internals: [],
630
+ forks: []
631
+ }), m = {
632
+ title: l,
633
+ tagline: u
634
+ }, { index: h, sidebar: g } = $e(p.internals, f, m), v, y;
635
+ if (a(T) && a(E)) {
636
+ let e = await it(E), t = await at(T);
637
+ v = [...e.themeConfig?.sidebar ?? [], ...g].sort((e, t) => e.text.localeCompare(t.text)), y = {
638
+ ...h,
639
+ features: [...t.features, ...h.features].sort((e, t) => e.title.localeCompare(t.title))
640
+ };
641
+ } else v = g, y = h;
642
+ let b = [];
643
+ if (e) {
644
+ let t = et(e);
645
+ d ? b.push(...t.filter((e) => e.link !== "/forks")) : b.push(...t);
646
+ }
647
+ t && (z(" Add extras Vitepress public folder content.", "info"), tt(t, _(C, "public"))), n && (z(" Add extras Vitepress theme files.", "info"), tt(n, _(se))), d && c.length && (z(" Add fork page to display external contributions.", "info"), await rt(p.forks, c, s), b.push({
648
+ text: "Forks",
649
+ link: "/forks"
650
+ })), ot(Ue(v, b, r), y);
651
+ }
652
+ function Ge(e, t) {
653
+ r(t, `${k(p(t), {
654
+ mode: "lowercase",
655
+ removeIdx: !0
656
+ }) === "readme.md" ? "\n## Sources" : "# Sources"}\n\nTake a look at the [project sources](${e}).\n`, "utf8");
657
+ }
658
+ function Ke(e, t, n) {
659
+ let { name: r, login: i, bio: a } = t, { title: o, tagline: s } = n;
660
+ return {
661
+ layout: "home",
662
+ hero: o ? {
663
+ name: o,
664
+ tagline: s
665
+ } : {
666
+ name: r ? `${r}'s projects` : `${i}'s projects`,
667
+ tagline: a ?? "Robots are everywhere 🤖"
668
+ },
669
+ features: e
670
+ };
671
+ }
672
+ function qe(e, t, n) {
673
+ let r = {
674
+ title: k(e, {
675
+ mode: "capitalize",
676
+ replaceDash: !0
677
+ }),
678
+ details: t,
679
+ link: `/${k(e, { removeDot: !0 })}/introduction`
680
+ };
681
+ return n ? [...n, r] : [r];
682
+ }
683
+ function Je(e, t) {
684
+ return {
685
+ text: k(e, {
686
+ mode: "capitalize",
687
+ replaceDash: !0
688
+ }),
689
+ collapsed: !0,
690
+ items: t
691
+ };
542
692
  }
543
- function ye(e) {
544
- return e.reduce((t, r) => {
545
- const [o, ...s] = r.split("/");
546
- return s.length ? t[o] = ye([
547
- ...t[o] ? ve(t[o], "") : [],
548
- s.join("/")
549
- ]) : t.$ = [...t.$ || [], o], t;
550
- }, {});
551
- }
552
- function ve(e, t = "") {
553
- return Object.entries(e).flatMap(([r, o]) => r === "$" ? Array.isArray(o) ? o.map((s) => t ? `${t}/${s}` : s) : [] : ve(o, t ? `${t}/${r}` : r));
554
- }
555
- function Et(e) {
556
- if (!Array.isArray(e))
557
- return e;
558
- const t = e.findIndex((o) => o.text === "Sources");
559
- if (t === -1)
560
- return e;
561
- const [r] = e.splice(t, 1);
562
- return e.push(r), e;
563
- }
564
- function Ft(e, t, r) {
565
- const o = [], s = [];
566
- for (const n of e) {
567
- a(` Replace urls for repository '${n.name}'.`, "info"), fe([n.docpress.projectPath]).forEach((g) => {
568
- a(` Processing file '${y(g)}' for repository '${n.name}'.`, "debug"), Xe(g, `https://github.com/${n.owner.login}/${n.name}/tree/${n.docpress.branch}`), y(g).toLowerCase() === "readme.md" && Ye(g, `https://github.com/${n.owner.login}/${n.name}/tree/${n.docpress.branch}`);
569
- }), a(` Generate sidebar for repository '${n.name}'.`, "info");
570
- 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"));
571
- a(` Add sources for repository '${n.name}'.`, "info");
572
- let p;
573
- c.length > 1 ? (p = u(n.docpress.projectPath, "sources.md"), c.push("sources.md")) : p = u(n.docpress.projectPath, c[0]), Ct(n.html_url, p);
574
- const h = ye(c), b = Et(we(n, h));
575
- s.push(kt(f(n.name, { removeDot: !0 }), b)), o.push(...Pt(f(n.name, { removeDot: !0 }), n.description || ""));
576
- }
577
- a(" Generate index content.", "info");
578
- const i = St(o.toSorted((n, c) => n.title.localeCompare(c.title)), t, r);
579
- return {
580
- sidebar: s.toSorted((n, c) => n.text.localeCompare(c.text)),
581
- index: i
582
- };
583
- }
584
- function Tt(e) {
585
- const t = fe(e), r = [];
586
- a(" Add extras Vitepress headers pages.", "info");
587
- for (const o of t) {
588
- a(` Processing file '${o}'.`, "debug");
589
- const s = u(process.cwd(), o), i = u(pe, f(y(o), { mode: "lowercase", removeIdx: !0 }));
590
- B(s, i), r.push({
591
- text: f(R(s).name, { replaceDash: !0, removeIdx: !0 }),
592
- link: `/${f(R(s).name, { removeIdx: !0, mode: "lowercase" })}`
593
- });
594
- }
595
- return r;
596
- }
597
- function ae(e, t, r) {
598
- for (const o of Array.isArray(e) ? e : [e]) {
599
- const s = u(process.cwd(), o), i = A(s);
600
- for (const n of i) {
601
- const c = n.replace(s, ".");
602
- a(` Processing file '${c}' for entry '${o}'.`, "debug");
603
- const p = u(process.cwd(), n), h = u(t, c);
604
- B(p, h);
605
- }
606
- }
607
- }
608
- function Ot(e) {
609
- const t = `---
610
- `, r = `layout: fork-page
611
- repoList:
612
- `, o = `
613
- # External contributions
614
-
615
- This 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.
616
-
617
- 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.
618
-
619
- This page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.
620
- `, s = e.map(({ repository: i, contributions: n }) => {
621
- const { name: c, owner: p, html_url: h, description: b, stargazers_count: g } = i;
622
- return { name: c, owner: p.login, html_url: h, description: b, stargazers_count: g, contributions: n };
623
- });
624
- a(" Generate forks page.", "info"), v(Ne, t + r + q.stringify(s) + t + o);
625
- }
626
- async function Rt(e, t, r) {
627
- const o = await Promise.all(
628
- e.map(async (s) => {
629
- const { source: i, contributors: n } = await ct({ repository: s, token: r });
630
- return {
631
- contributions: n?.find((c) => c.login === t)?.contributions ?? 0,
632
- repository: i
633
- };
634
- })
635
- ).then((s) => s.filter(({ repository: i, contributions: n }) => !!i && n));
636
- Ot(o);
637
- }
638
- async function _t(e) {
639
- const { config: t } = await import(u(process.cwd(), e)).catch((r) => r);
640
- return t;
641
- }
642
- async function At(e) {
643
- const t = (await je(u(process.cwd(), e))).toString();
644
- return q.parse(t);
645
- }
646
- function It(e, t) {
647
- const r = `---
648
- `;
649
- return F(_(E)), a(" Generate Vitepress config.", "info"), v(E, `export const config = ${JSON.stringify(e, null, 2)}
650
-
651
- export default config
652
- `), a(" Generate index file.", "info"), v(M, r + q.stringify(t)), a(" Add Docpress theme files.", "info"), A(te).forEach((o) => {
653
- const s = o.replace(`${te}/`, "");
654
- vt(o, u(De, s));
655
- });
656
- }
657
- const ce = "prepare", $e = [
658
- m("-c, --extra-public-content <string>", d.shape.extraPublicContent.description),
659
- m("-f, --forks", d.shape.forks.description),
660
- m("-p, --extra-header-pages <string>", d.shape.extraHeaderPages.description),
661
- m("-t, --extra-theme <string>", d.shape.extraTheme.description),
662
- m("-v, --vitepress-config <string>", d.shape.vitepressConfig.description),
663
- m("--website-title <string>", d.shape.websiteTitle.description),
664
- m("--website-tagline <string>", d.shape.websiteTagline.description)
665
- ], jt = j(J(ce), [...$e, ...L]).description("Transform doc to the target vitepress format.").action(async (e) => {
666
- const t = K(ce, e);
667
- await xe(t);
693
+ function Ye(e, t) {
694
+ return Object.entries(t).flatMap(([t, n]) => t === "$" ? Array.isArray(n) ? n.map((t) => {
695
+ let n = _(e.docpress.projectPath, t), r = k(p(n), {
696
+ mode: "lowercase",
697
+ removeIdx: !0
698
+ });
699
+ return r === "readme.md" && (r = "introduction.md"), r !== p(n) && l(n, _(m(n), r)), {
700
+ text: g(r).name === "introduction" ? "Introduction" : k(r, {
701
+ mode: "capitalize",
702
+ replaceDash: !0,
703
+ removeExt: !0
704
+ }),
705
+ link: `/${k(e.name, { removeDot: !0 })}/${g(r).name}`
706
+ };
707
+ }) : [] : typeof n == "object" ? [{
708
+ text: k(t, {
709
+ mode: "capitalize",
710
+ replaceDash: !0
711
+ }),
712
+ collapsed: !0,
713
+ items: Ye({
714
+ ...e,
715
+ name: `${e.name}/${t}`
716
+ }, n)
717
+ }] : []);
718
+ }
719
+ function Xe(e) {
720
+ return e.reduce((e, t) => {
721
+ let [n, ...r] = t.split("/");
722
+ return r.length ? e[n] = Xe([...e[n] ? Ze(e[n], "") : [], r.join("/")]) : e.$ = [...e.$ || [], n], e;
723
+ }, {});
724
+ }
725
+ function Ze(e, t = "") {
726
+ return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] : Ze(n, t ? `${t}/${e}` : e));
727
+ }
728
+ function Qe(e) {
729
+ if (!Array.isArray(e)) return e;
730
+ let t = e.findIndex((e) => e.text === "Sources");
731
+ if (t === -1) return e;
732
+ let [n] = e.splice(t, 1);
733
+ return e.push(n), e;
734
+ }
735
+ function $e(e, t, n) {
736
+ let r = [], i = [];
737
+ for (let t of e) {
738
+ z(` Replace urls for repository '${t.name}'.`, "info"), N([t.docpress.projectPath]).forEach((e) => {
739
+ z(` Processing file '${p(e)}' for repository '${t.name}'.`, "debug"), ge(e, t.docpress.replace_url), p(e).toLowerCase() === "readme.md" && _e(e, t.docpress.replace_url);
740
+ }), z(` Generate sidebar for repository '${t.name}'.`, "info");
741
+ let e = c(t.docpress.projectPath, { recursive: !0 }).filter((e) => {
742
+ let n = _(t.docpress.projectPath, e.toString());
743
+ return p(n).endsWith(".md") && j(n);
744
+ }).sort();
745
+ z(` Add sources for repository '${t.name}'.`, "info");
746
+ let n;
747
+ e.length > 1 ? (n = _(t.docpress.projectPath, "sources.md"), e.push("sources.md")) : e.length === 1 && (n = _(t.docpress.projectPath, e[0])), n ? Ge(t.html_url, n) : z(` No markdown files found for repository '${t.name}', skipping sources.`, "warn");
748
+ let a = Qe(Ye(t, Xe(e)));
749
+ i.push(Je(k(t.name, { removeDot: !0 }), a)), r.push(...qe(k(t.name, { removeDot: !0 }), t.description || ""));
750
+ }
751
+ z(" Generate index content.", "info");
752
+ let a = Ke(r.toSorted((e, t) => e.title.localeCompare(t.title)), t, n);
753
+ return {
754
+ sidebar: i.toSorted((e, t) => e.text.localeCompare(t.text)),
755
+ index: a
756
+ };
757
+ }
758
+ function et(e) {
759
+ let t = N(e), n = [];
760
+ z(" Add extras Vitepress headers pages.", "info");
761
+ for (let e of t) {
762
+ z(` Processing file '${e}'.`, "debug");
763
+ let t = _(process.cwd(), e);
764
+ i(t, _(w, k(p(e), {
765
+ mode: "lowercase",
766
+ removeIdx: !0
767
+ }))), n.push({
768
+ text: k(g(t).name, {
769
+ replaceDash: !0,
770
+ removeIdx: !0
771
+ }),
772
+ link: `/${k(g(t).name, {
773
+ removeIdx: !0,
774
+ mode: "lowercase"
775
+ })}`
776
+ });
777
+ }
778
+ return n;
779
+ }
780
+ function tt(e, t, n) {
781
+ for (let r of Array.isArray(e) ? e : [e]) {
782
+ let e = _(process.cwd(), r), a = M(e);
783
+ for (let o of a) {
784
+ let a = o.replace(e, ".");
785
+ z(` Processing file '${a}' for entry '${r}'.`, "debug");
786
+ let s = _(process.cwd(), o), c = _(t, a);
787
+ n && n(), i(s, c);
788
+ }
789
+ }
790
+ }
791
+ function nt(e) {
792
+ let t = e.map(({ repository: e, contributions: t }) => {
793
+ let { name: n, owner: r, html_url: i, description: a, stargazers_count: o } = e;
794
+ return {
795
+ name: n,
796
+ owner: r.login,
797
+ html_url: i,
798
+ description: a,
799
+ stargazers_count: o,
800
+ contributions: t
801
+ };
802
+ });
803
+ z(" Generate forks page.", "info"), f(ae, "---\nlayout: fork-page\nrepoList:\n" + S.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");
804
+ }
805
+ async function rt(e, t, n) {
806
+ nt(await Promise.all(e.map(async (e) => {
807
+ let { source: r, contributors: i } = await we({
808
+ repository: e,
809
+ token: n
810
+ });
811
+ return {
812
+ contributions: i?.find((e) => e.login === t)?.contributions ?? 0,
813
+ repository: r
814
+ };
815
+ })).then((e) => e.filter(({ repository: e, contributions: t }) => !!e && t)));
816
+ }
817
+ async function it(e) {
818
+ try {
819
+ let { config: t } = await import(_(process.cwd(), e));
820
+ return t ?? {};
821
+ } catch (t) {
822
+ return z(` Unable to load existing Vitepress config '${e}', starting from an empty config. ${t instanceof Error ? t.message : ""}`, "warn"), {};
823
+ }
824
+ }
825
+ async function at(e) {
826
+ let t = (await re(_(process.cwd(), e))).toString();
827
+ return S.parse(t);
828
+ }
829
+ function ot(e, t) {
830
+ return A(m(E)), z(" Generate Vitepress config.", "info"), f(E, `export const config = ${JSON.stringify(e, null, 2)}\n\nexport default config\n`), z(" Generate index file.", "info"), f(T, "---\n" + S.stringify(t)), z(" Add Docpress theme files.", "info"), M(D).forEach((e) => {
831
+ Ve(e, _(oe, e.replace(`${D}/`, "")));
832
+ });
833
+ }
834
+ //#endregion
835
+ //#region src/commands/prepare.ts
836
+ var st = "prepare", ct = [
837
+ n("-c, --extra-public-content <string>", V.shape.extraPublicContent.description),
838
+ n("-f, --forks", V.shape.forks.description),
839
+ n("-p, --extra-header-pages <string>", V.shape.extraHeaderPages.description),
840
+ n("-t, --extra-theme <string>", V.shape.extraTheme.description),
841
+ n("-v, --vitepress-config <string>", V.shape.vitepressConfig.description),
842
+ n("--website-title <string>", V.shape.websiteTitle.description),
843
+ n("--website-tagline <string>", V.shape.websiteTagline.description)
844
+ ], lt = G(t(st), [...ct, ...$]).description("Transform doc to the target vitepress format.").action(async (e, t) => {
845
+ await ut(U(st, W(t, e)));
668
846
  });
669
- async function xe(e) {
670
- const { extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: s, forks: i, token: n, usernames: c, websiteTitle: p, websiteTagline: h } = e;
671
- a(`
672
- -> Start transform files to prepare Vitepress build.`, "info"), F(_(E), { clean: !0 });
673
- for (const b of c)
674
- await xt({ extraHeaderPages: t, extraPublicContent: r, extraTheme: o, vitepressConfig: s, forks: i, token: n, username: b, websiteTitle: p, websiteTagline: h });
675
- }
676
- function Lt(e) {
677
- return {
678
- ...e,
679
- branch: "main",
680
- gitProvider: "github"
681
- };
682
- }
683
- function Vt() {
684
- const e = new Pe().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${Ve.version}`).action(async (t, r) => {
685
- const o = Lt(t), s = K("global", o);
686
- await he(s), await xe(s), await be();
687
- }).configureHelp({
688
- sortSubcommands: !0,
689
- sortOptions: !0,
690
- showGlobalOptions: !0
691
- }).enablePositionalOptions().passThroughOptions().addCommand(ht).addCommand(jt).addCommand(yt);
692
- return j(e, [...ge, ...$e, ...L]), e;
693
- }
694
- function Qt() {
695
- Vt().parseAsync(process.argv);
696
- }
697
- export {
698
- Vt as getProgram,
699
- Qt as main
700
- };
701
- //# sourceMappingURL=cli.js.map
847
+ async function ut(e) {
848
+ let { extraHeaderPages: t, extraPublicContent: n, extraTheme: r, vitepressConfig: i, forks: a, gitProvider: o, token: s, usernames: c, websiteTitle: l, websiteTagline: u } = e;
849
+ z("\n-> Start transform files to prepare Vitepress build.", "info"), A(m(E), { clean: !0 });
850
+ for (let e of c) await We({
851
+ extraHeaderPages: t,
852
+ extraPublicContent: n,
853
+ extraTheme: r,
854
+ vitepressConfig: i,
855
+ forks: a,
856
+ gitProvider: o,
857
+ token: s,
858
+ username: e,
859
+ websiteTitle: l,
860
+ websiteTagline: u
861
+ });
862
+ }
863
+ //#endregion
864
+ //#region src/cli.ts
865
+ function dt() {
866
+ let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${ie.version}`).action(async (e, t) => {
867
+ let n = U("global", W(t, e));
868
+ await Le(n), await ut(n), await Be();
869
+ }).configureHelp({
870
+ sortSubcommands: !0,
871
+ sortOptions: !0,
872
+ showGlobalOptions: !0
873
+ }).enablePositionalOptions().passThroughOptions().addCommand(Ie).addCommand(lt).addCommand(ze);
874
+ return G(t, [
875
+ ...Fe,
876
+ ...ct,
877
+ ...$
878
+ ]), t;
879
+ }
880
+ function ft() {
881
+ dt().parseAsync(process.argv).catch((e) => {
882
+ z(`\n${e instanceof Error ? e.message : String(e)}`, "error"), process.exit(1);
883
+ });
884
+ }
885
+ //#endregion
886
+ export { dt as getProgram, ft as main };
887
+
888
+ //# sourceMappingURL=cli.js.map