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