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