@tobi-or-not/docpress 0.10.1 → 0.10.2
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 +407 -342
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Command as e, createCommand as t, createOption as n } from "commander";
|
|
2
2
|
import { appendFileSync as r, cpSync as i, existsSync as a, mkdirSync as o, readFileSync as s, readdirSync as c, renameSync as l, rmSync as u, statSync as d, writeFileSync as f } from "node:fs";
|
|
3
|
-
import { basename as p, dirname as m, join as
|
|
4
|
-
import { rimrafSync as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { z as
|
|
8
|
-
import { Octokit as
|
|
9
|
-
import { simpleGit as
|
|
10
|
-
import { build as
|
|
11
|
-
import { withMermaid as
|
|
12
|
-
import { readFile as
|
|
13
|
-
var
|
|
3
|
+
import { basename as p, dirname as m, join as h, parse as g, relative as _, resolve as v } from "node:path";
|
|
4
|
+
import { rimrafSync as y } from "rimraf";
|
|
5
|
+
import b from "yaml";
|
|
6
|
+
import x from "chalk";
|
|
7
|
+
import { z as S } from "zod";
|
|
8
|
+
import { Octokit as C } from "@octokit/rest";
|
|
9
|
+
import { simpleGit as ee } from "simple-git";
|
|
10
|
+
import { build as te } from "vitepress";
|
|
11
|
+
import { withMermaid as ne } from "vitepress-plugin-mermaid";
|
|
12
|
+
import { readFile as re } from "node:fs/promises";
|
|
13
|
+
var ie = {
|
|
14
14
|
name: "@tobi-or-not/docpress",
|
|
15
15
|
type: "module",
|
|
16
|
-
version: "0.10.
|
|
16
|
+
version: "0.10.2",
|
|
17
17
|
packageManager: "bun@1.3.14",
|
|
18
18
|
homepage: "https://this-is-tobi.com/docpress/introduction",
|
|
19
19
|
repository: {
|
|
@@ -77,71 +77,125 @@ var ae = {
|
|
|
77
77
|
access: "public",
|
|
78
78
|
tag: "latest"
|
|
79
79
|
}
|
|
80
|
-
},
|
|
80
|
+
}, w = v(process.cwd(), "docpress"), T = v(process.cwd(), "docpress/docs"), E = v(process.cwd(), "docpress/docs/index.md"), ae = v(process.cwd(), "docpress/docs/forks.md"), D = v(process.cwd(), "docpress/.vitepress/config.ts"), oe = v(process.cwd(), "docpress/.vitepress/theme"), se = v(process.cwd(), "docpress/.vitepress/theme/extras"), O = process.env.NODE_ENV === "development" ? v(import.meta.dirname, "../../public/templates/theme") : v(import.meta.dirname, "./templates/theme");
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/utils/logger.ts
|
|
83
|
+
function ce() {
|
|
84
|
+
let e = Number(process.env.LOG_LEVEL);
|
|
85
|
+
return Number.isNaN(e) ? 30 : e;
|
|
86
|
+
}
|
|
87
|
+
var k = {
|
|
88
|
+
error: {
|
|
89
|
+
color: "red",
|
|
90
|
+
level: 10
|
|
91
|
+
},
|
|
92
|
+
warn: {
|
|
93
|
+
color: "yellow",
|
|
94
|
+
level: 20
|
|
95
|
+
},
|
|
96
|
+
info: {
|
|
97
|
+
color: "white",
|
|
98
|
+
level: 30
|
|
99
|
+
},
|
|
100
|
+
success: {
|
|
101
|
+
color: "green",
|
|
102
|
+
level: 30
|
|
103
|
+
},
|
|
104
|
+
trace: {
|
|
105
|
+
color: "white",
|
|
106
|
+
level: 40
|
|
107
|
+
},
|
|
108
|
+
debug: {
|
|
109
|
+
color: "blue",
|
|
110
|
+
level: 50
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
function A(e, t = "info", n) {
|
|
114
|
+
let r = n ? x[n](e) : x[k[t].color](e), i = t === "success" ? "info" : t;
|
|
115
|
+
ce() >= k[t].level && console[i](r);
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/utils/regex.ts
|
|
119
|
+
var le = /\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, ue = /\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http|#)(\.\/)?([^/][^)]+)\)/g, de = /\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, fe = /^\d{2}-/, pe = /^---\r?\n([\s\S]*?)\r?\n---\r?\n/, me = /\[([^\]]+)\]\((?!https?:|\/|#|mailto:)([^)#]*\/)?([^)#/]+\.md)(#[^)]*)?\)/g;
|
|
81
120
|
//#endregion
|
|
82
121
|
//#region src/utils/functions.ts
|
|
83
|
-
async function
|
|
122
|
+
async function j(e) {
|
|
84
123
|
try {
|
|
85
124
|
return (await fetch(e, {
|
|
86
125
|
method: "HEAD",
|
|
87
126
|
redirect: "manual"
|
|
88
127
|
})).status;
|
|
89
|
-
} catch {
|
|
90
|
-
return 500;
|
|
128
|
+
} catch (t) {
|
|
129
|
+
return A(` Network error while checking '${e}': ${t instanceof Error ? t.message : String(t)}`, "debug"), 500;
|
|
91
130
|
}
|
|
92
131
|
}
|
|
93
|
-
function
|
|
132
|
+
function M(e) {
|
|
133
|
+
return (e.split(/[/\\]/).pop() ?? "").replace(/[^\w.-]/g, "_").replace(/^\.+/, "");
|
|
134
|
+
}
|
|
135
|
+
function N(e) {
|
|
136
|
+
return !z(e) || !("token" in e) ? e : {
|
|
137
|
+
...e,
|
|
138
|
+
token: e.token ? "***" : e.token
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function P(e, t) {
|
|
94
142
|
let n = "";
|
|
95
143
|
return t?.removeDot && (n = e.startsWith(".") ? e.slice(1) : e, n = n.replaceAll(".", "-")), t?.removeIdx && (n = (n || e).replace(fe, "")), t?.removeExt && (n = (n || e).split(".")[0]), t?.replaceDash && (n = (n || e).replaceAll("-", " ")), t?.mode === "capitalize" ? n = (n || e).slice(0, 1).toUpperCase() + (n || e).slice(1).toLowerCase() : t?.mode === "lowercase" ? n = (n || e).toLowerCase() : t?.mode === "uppercase" && (n = (n || e).toUpperCase()), n || e;
|
|
96
144
|
}
|
|
97
|
-
function
|
|
145
|
+
function F(e, { clean: t } = { clean: !1 }) {
|
|
98
146
|
try {
|
|
99
|
-
t && a(e) &&
|
|
100
|
-
} catch (
|
|
101
|
-
|
|
147
|
+
t && a(e) && y(`${e}/*`, { glob: !0 }), a(e) || o(e, { recursive: !0 });
|
|
148
|
+
} catch (t) {
|
|
149
|
+
throw Error(`Unable to create directory '${e}': ${t instanceof Error ? t.message : String(t)}`);
|
|
102
150
|
}
|
|
103
151
|
}
|
|
104
|
-
function
|
|
152
|
+
function he(e) {
|
|
105
153
|
try {
|
|
106
154
|
return d(e).isDirectory();
|
|
107
155
|
} catch {
|
|
108
156
|
return !1;
|
|
109
157
|
}
|
|
110
158
|
}
|
|
111
|
-
function
|
|
159
|
+
function ge(e) {
|
|
112
160
|
try {
|
|
113
161
|
return d(e).isFile();
|
|
114
162
|
} catch {
|
|
115
163
|
return !1;
|
|
116
164
|
}
|
|
117
165
|
}
|
|
118
|
-
function
|
|
119
|
-
return (Array.isArray(e) ? e : [e]).flatMap((e) =>
|
|
120
|
-
}
|
|
121
|
-
function N(e) {
|
|
122
|
-
return M(e).filter((e) => p(e).endsWith(".md"));
|
|
166
|
+
function I(e) {
|
|
167
|
+
return (Array.isArray(e) ? e : [e]).flatMap((e) => ge(e) ? [e] : he(e) ? c(e).filter((e) => e !== ".git").sort().flatMap((t) => I(h(e, t))) : []);
|
|
123
168
|
}
|
|
124
|
-
function
|
|
125
|
-
return e.
|
|
169
|
+
function L(e) {
|
|
170
|
+
return I(e).filter((e) => p(e).endsWith(".md"));
|
|
126
171
|
}
|
|
127
172
|
function _e(e) {
|
|
128
|
-
return
|
|
173
|
+
return e.reduce((e, t, n, r) => n ? n === r.length - 1 ? `${e} or "${t}"` : `${e}, "${t}"` : `"${t}"`, "");
|
|
129
174
|
}
|
|
130
175
|
function ve(e) {
|
|
131
|
-
return JSON.parse(s(`${
|
|
176
|
+
return JSON.parse(s(`${w}/user-${M(e)}.json`).toString());
|
|
177
|
+
}
|
|
178
|
+
function ye(e) {
|
|
179
|
+
return JSON.parse(s(`${w}/repos-${M(e)}.json`).toString());
|
|
132
180
|
}
|
|
133
|
-
|
|
181
|
+
var be = /* @__PURE__ */ new Set([
|
|
182
|
+
"__proto__",
|
|
183
|
+
"constructor",
|
|
184
|
+
"prototype"
|
|
185
|
+
]);
|
|
186
|
+
function R(...e) {
|
|
134
187
|
return e.reduce((e, t) => (t === null || Object.keys(t).forEach((n) => {
|
|
188
|
+
if (be.has(n)) return;
|
|
135
189
|
let r = e ? e[n] : null, i = t[n];
|
|
136
|
-
|
|
190
|
+
z(r) && z(i) ? e[n] = R(r, i) : z(i) ? e[n] = R({}, i) : e[n] = i;
|
|
137
191
|
}), e), {});
|
|
138
192
|
}
|
|
139
|
-
function
|
|
193
|
+
function z(e) {
|
|
140
194
|
return e && typeof e == "object" && !Array.isArray(e);
|
|
141
195
|
}
|
|
142
|
-
function
|
|
196
|
+
function B(e) {
|
|
143
197
|
if (!e) return {};
|
|
144
|
-
let t =
|
|
198
|
+
let t = v(process.cwd(), e), n;
|
|
145
199
|
try {
|
|
146
200
|
n = s(t, "utf8");
|
|
147
201
|
} catch {
|
|
@@ -153,121 +207,91 @@ function I(e) {
|
|
|
153
207
|
throw Error(`Invalid JSON in config file '${e}'.`);
|
|
154
208
|
}
|
|
155
209
|
}
|
|
156
|
-
function
|
|
210
|
+
function V(e) {
|
|
157
211
|
return e.split(",");
|
|
158
212
|
}
|
|
159
|
-
function
|
|
213
|
+
function xe(e, t) {
|
|
160
214
|
f(e, s(e, "utf8").replace(le, (e, n, r) => `[${n}](${t}/${r})`), "utf8");
|
|
161
215
|
}
|
|
162
|
-
function
|
|
163
|
-
let n = s(e, "utf8"), r = n.match(
|
|
216
|
+
function Se(e, t) {
|
|
217
|
+
let n = s(e, "utf8"), r = n.match(pe);
|
|
164
218
|
if (r) {
|
|
165
|
-
let i =
|
|
166
|
-
i.lastUpdated = t, f(e, n.replace(
|
|
219
|
+
let i = b.parse(r[1]) ?? {};
|
|
220
|
+
i.lastUpdated = t, f(e, n.replace(pe, `---\n${b.stringify(i)}---\n`), "utf8");
|
|
167
221
|
} else f(e, `---\nlastUpdated: ${t}\n---\n\n${n}`, "utf8");
|
|
168
222
|
}
|
|
169
|
-
function
|
|
170
|
-
f(e, s(e, "utf8").replace(
|
|
171
|
-
let a =
|
|
223
|
+
function Ce(e) {
|
|
224
|
+
f(e, s(e, "utf8").replace(me, (e, t, n, r, i) => {
|
|
225
|
+
let a = P(r, {
|
|
172
226
|
mode: "lowercase",
|
|
173
227
|
removeIdx: !0
|
|
174
228
|
});
|
|
175
229
|
return a === "readme.md" && (a = "introduction.md"), `[${t}](${n ?? ""}${a}${i ?? ""})`;
|
|
176
230
|
}), "utf8");
|
|
177
231
|
}
|
|
178
|
-
function
|
|
232
|
+
function we(e, t) {
|
|
179
233
|
f(e, s(e, "utf8").replace(ue, (e, n, r, i) => `[${n}](${t}/${i})`).replace(de, (e, t, n, r) => `[${t}](${r})`), "utf8");
|
|
180
234
|
}
|
|
181
235
|
//#endregion
|
|
182
|
-
//#region src/utils/logger.ts
|
|
183
|
-
function Ce() {
|
|
184
|
-
let e = Number(process.env.LOG_LEVEL);
|
|
185
|
-
return Number.isNaN(e) ? 30 : e;
|
|
186
|
-
}
|
|
187
|
-
var we = {
|
|
188
|
-
error: {
|
|
189
|
-
color: "red",
|
|
190
|
-
level: 10
|
|
191
|
-
},
|
|
192
|
-
warn: {
|
|
193
|
-
color: "yellow",
|
|
194
|
-
level: 20
|
|
195
|
-
},
|
|
196
|
-
info: {
|
|
197
|
-
color: "white",
|
|
198
|
-
level: 30
|
|
199
|
-
},
|
|
200
|
-
success: {
|
|
201
|
-
color: "green",
|
|
202
|
-
level: 30
|
|
203
|
-
},
|
|
204
|
-
trace: {
|
|
205
|
-
color: "white",
|
|
206
|
-
level: 40
|
|
207
|
-
},
|
|
208
|
-
debug: {
|
|
209
|
-
color: "blue",
|
|
210
|
-
level: 50
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
function R(e, t = "info", n) {
|
|
214
|
-
let r = n ? b[n](e) : b[we[t].color](e), i = t === "success" ? "info" : t;
|
|
215
|
-
Ce() >= we[t].level && console[i](r);
|
|
216
|
-
}
|
|
217
|
-
//#endregion
|
|
218
236
|
//#region src/schemas/global.ts
|
|
219
|
-
var
|
|
220
|
-
usernames:
|
|
221
|
-
branch:
|
|
222
|
-
gitProvider:
|
|
223
|
-
reposFilter:
|
|
224
|
-
extraHeaderPages:
|
|
225
|
-
extraPublicContent:
|
|
226
|
-
extraTheme:
|
|
227
|
-
forks:
|
|
228
|
-
lastUpdated:
|
|
229
|
-
vitepressConfig:
|
|
230
|
-
websiteTitle:
|
|
231
|
-
websiteTagline:
|
|
232
|
-
}),
|
|
233
|
-
branch:
|
|
234
|
-
gitProvider:
|
|
235
|
-
forks:
|
|
236
|
-
lastUpdated:
|
|
237
|
-
config:
|
|
238
|
-
token:
|
|
239
|
-
usernames:
|
|
240
|
-
reposFilter:
|
|
241
|
-
extraHeaderPages:
|
|
242
|
-
extraPublicContent:
|
|
243
|
-
extraTheme:
|
|
244
|
-
vitepressConfig:
|
|
237
|
+
var H = ["github", "gitlab"], U = /^\w[\w./-]*$/, W = "Branch name must start with a letter, digit or underscore and only contain letters, digits, \".\", \"-\", \"_\" or \"/\".", G = S.object({
|
|
238
|
+
usernames: S.string().array().describe("List of comma separated Git provider usernames used to collect data."),
|
|
239
|
+
branch: S.string().regex(U, W).default("main").describe("Branch used to collect Git provider data."),
|
|
240
|
+
gitProvider: S.enum(H).default("github").describe(`Git provider used to retrieve data. Values should be ${_e(H)}.`),
|
|
241
|
+
reposFilter: S.string().array().describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories."),
|
|
242
|
+
extraHeaderPages: S.string().array().describe("List of comma separated additional files or directories to process Vitepress header pages."),
|
|
243
|
+
extraPublicContent: S.string().array().describe("List of comma separated additional files or directories to process Vitepress public folder."),
|
|
244
|
+
extraTheme: S.string().array().describe("List of comma separated additional files or directories to use as Vitepress theme."),
|
|
245
|
+
forks: S.boolean().default(!1).describe("Whether or not to create the dedicated fork page that aggregate external contributions."),
|
|
246
|
+
lastUpdated: S.boolean().default(!1).describe("Whether or not to inject each page's last Git commit date as Vitepress \"lastUpdated\" frontmatter."),
|
|
247
|
+
vitepressConfig: S.any().optional().describe("Path to the vitepress configuration file."),
|
|
248
|
+
websiteTitle: S.string().describe("Website title."),
|
|
249
|
+
websiteTagline: S.string().describe("Website tagline.")
|
|
250
|
+
}), K = G.partial().extend({
|
|
251
|
+
branch: S.string().regex(U, W).optional().describe(G.shape.branch.description || ""),
|
|
252
|
+
gitProvider: S.enum(H).optional().describe(G.shape.gitProvider.description || ""),
|
|
253
|
+
forks: S.boolean().optional().describe(G.shape.forks.description || ""),
|
|
254
|
+
lastUpdated: S.boolean().optional().describe(G.shape.lastUpdated.description || ""),
|
|
255
|
+
config: S.string().optional().describe("Path to the docpress configuration file."),
|
|
256
|
+
token: S.string().optional().describe("Git provider token used to collect data."),
|
|
257
|
+
usernames: S.string().transform(V).optional().describe(G.shape.usernames.description || ""),
|
|
258
|
+
reposFilter: S.string().transform(V).optional().describe(G.shape.reposFilter.description || ""),
|
|
259
|
+
extraHeaderPages: S.string().transform(V).optional().describe(G.shape.extraHeaderPages.description || ""),
|
|
260
|
+
extraPublicContent: S.string().transform(V).optional().describe(G.shape.extraPublicContent.description || ""),
|
|
261
|
+
extraTheme: S.string().transform(V).optional().describe(G.shape.extraTheme.description || ""),
|
|
262
|
+
vitepressConfig: S.string().optional().describe(G.shape.vitepressConfig.description || "")
|
|
245
263
|
});
|
|
246
264
|
function Te(e) {
|
|
247
265
|
if (!e) return {};
|
|
248
|
-
|
|
266
|
+
let t = { ...e };
|
|
267
|
+
for (let e of [
|
|
249
268
|
"usernames",
|
|
250
269
|
"reposFilter",
|
|
251
270
|
"extraHeaderPages",
|
|
252
271
|
"extraPublicContent",
|
|
253
272
|
"extraTheme"
|
|
254
|
-
])
|
|
255
|
-
return
|
|
273
|
+
]) typeof t[e] == "string" && (t[e] = [t[e]]);
|
|
274
|
+
return t;
|
|
256
275
|
}
|
|
257
276
|
function Ee(e) {
|
|
258
|
-
let t =
|
|
259
|
-
if (!t.success) throw Error(
|
|
277
|
+
let t = G.partial().safeParse(e);
|
|
278
|
+
if (!t.success) throw Error(S.prettifyError(t.error));
|
|
260
279
|
return t.data;
|
|
261
280
|
}
|
|
262
281
|
function De(e) {
|
|
263
282
|
if (!e.usernames?.length) throw Error("The usernames field is required");
|
|
264
283
|
return e;
|
|
265
284
|
}
|
|
266
|
-
|
|
285
|
+
function Oe(e, t) {
|
|
286
|
+
if (e) return e;
|
|
287
|
+
let n = t === "gitlab" ? process.env.GITLAB_TOKEN : process.env.GITHUB_TOKEN;
|
|
288
|
+
return process.env.DOCPRESS_TOKEN ?? n;
|
|
289
|
+
}
|
|
290
|
+
var ke = K.partial().transform((e) => {
|
|
267
291
|
try {
|
|
268
292
|
let { config: t, vitepressConfig: n, token: r, ...i } = e;
|
|
269
|
-
|
|
270
|
-
let a = Ee(Te(
|
|
293
|
+
A(`Debug: Schema transform input: ${JSON.stringify(N(e))}`, "debug");
|
|
294
|
+
let a = Ee(Te(B(t))), o = {
|
|
271
295
|
branch: "main",
|
|
272
296
|
gitProvider: "github",
|
|
273
297
|
forks: !1,
|
|
@@ -276,34 +300,34 @@ var Oe = V.partial().transform((e) => {
|
|
|
276
300
|
...i,
|
|
277
301
|
...n ? { vitepressConfig: {
|
|
278
302
|
...a.vitepressConfig || {},
|
|
279
|
-
...
|
|
303
|
+
...B(n) || {}
|
|
280
304
|
} } : {}
|
|
281
305
|
};
|
|
282
|
-
return
|
|
306
|
+
return A(`Debug: Final merged config: ${JSON.stringify(o)}`, "debug"), De({
|
|
283
307
|
...o,
|
|
284
|
-
token: r
|
|
308
|
+
token: Oe(r, o.gitProvider)
|
|
285
309
|
});
|
|
286
310
|
} catch (e) {
|
|
287
|
-
|
|
311
|
+
A(" An error occurred while checking configuration.", "error"), e instanceof Error ? A(` ${e.message}`, "error") : A(` ${JSON.stringify(e, null, 2)}`, "error"), process.exit(1);
|
|
288
312
|
}
|
|
289
313
|
});
|
|
290
314
|
//#endregion
|
|
291
315
|
//#region src/utils/commands.ts
|
|
292
|
-
function
|
|
293
|
-
|
|
294
|
-
let n =
|
|
295
|
-
return n.success || (
|
|
316
|
+
function q(e, t) {
|
|
317
|
+
A("Initializing Docpress...", "info", "blue"), A("\n\n-> Checking for required environment settings and configurations.", "info"), A(` Debug info - opts: ${JSON.stringify(N(t))}`, "debug"), A(` Debug info - cmd: ${e}`, "debug");
|
|
318
|
+
let n = ke.safeParse(t);
|
|
319
|
+
return n.success || (A(` An error occurred while checking configuration.\n ${S.prettifyError(n.error)}`, "error"), process.exit(1)), A(" Setup complete! Ready to process your documentation.", "info"), n.data;
|
|
296
320
|
}
|
|
297
|
-
function
|
|
321
|
+
function J(e, t) {
|
|
298
322
|
return Object.fromEntries(Object.entries(t).filter(([t]) => e.getOptionValueSource(t) !== "default"));
|
|
299
323
|
}
|
|
300
|
-
function
|
|
324
|
+
function Y(e, t) {
|
|
301
325
|
for (let n of t) e.addOption(n);
|
|
302
326
|
return e;
|
|
303
327
|
}
|
|
304
328
|
//#endregion
|
|
305
329
|
//#region src/lib/git.ts
|
|
306
|
-
var
|
|
330
|
+
var X = {
|
|
307
331
|
debug: () => {},
|
|
308
332
|
info: () => {},
|
|
309
333
|
warn: (e) => {
|
|
@@ -313,17 +337,17 @@ var G = {
|
|
|
313
337
|
e.includes("404") || console.error(e);
|
|
314
338
|
}
|
|
315
339
|
};
|
|
316
|
-
async function
|
|
317
|
-
|
|
318
|
-
let r = new
|
|
340
|
+
async function Ae({ username: e, token: t, branch: n }) {
|
|
341
|
+
A(` Get infos for username '${e}'.`, "info");
|
|
342
|
+
let r = new C({
|
|
319
343
|
auth: t,
|
|
320
|
-
log:
|
|
344
|
+
log: X
|
|
321
345
|
});
|
|
322
|
-
|
|
346
|
+
A(" Get user infos.", "debug");
|
|
323
347
|
let { data: i } = await r.rest.users.getByUsername({ username: e }).catch((t) => {
|
|
324
348
|
throw t.status === 404 ? /* @__PURE__ */ Error(`No GitHub user found for '${e}'.`) : t;
|
|
325
349
|
});
|
|
326
|
-
return
|
|
350
|
+
return A(" Get repositories infos.", "debug"), {
|
|
327
351
|
user: i,
|
|
328
352
|
repos: await r.paginate(r.rest.repos.listForUser, {
|
|
329
353
|
username: e,
|
|
@@ -333,11 +357,11 @@ async function ke({ username: e, token: t, branch: n }) {
|
|
|
333
357
|
branch: n
|
|
334
358
|
};
|
|
335
359
|
}
|
|
336
|
-
async function
|
|
337
|
-
|
|
338
|
-
let n = new
|
|
360
|
+
async function je({ repository: e, token: t }) {
|
|
361
|
+
A(` Get contributors infos for repository '${e.name}'.`, "info");
|
|
362
|
+
let n = new C({
|
|
339
363
|
auth: t,
|
|
340
|
-
log:
|
|
364
|
+
log: X
|
|
341
365
|
}), { data: r } = await n.rest.repos.get({
|
|
342
366
|
owner: e.owner.login,
|
|
343
367
|
repo: e.name
|
|
@@ -354,7 +378,7 @@ async function Ae({ repository: e, token: t }) {
|
|
|
354
378
|
per_page: 100
|
|
355
379
|
})) i.push(...e);
|
|
356
380
|
} catch (t) {
|
|
357
|
-
return
|
|
381
|
+
return A(` Failed to get contributors infos for repository '${e.name}'. Error : ${t instanceof Error ? t.message : String(t)}`, "warn"), {
|
|
358
382
|
source: r.source,
|
|
359
383
|
contributors: []
|
|
360
384
|
};
|
|
@@ -364,24 +388,44 @@ async function Ae({ repository: e, token: t }) {
|
|
|
364
388
|
contributors: i
|
|
365
389
|
};
|
|
366
390
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
R(` Unable to get last commit date for '${i}' in repository '${n}'. Error : ${e}`, "warn");
|
|
391
|
+
function Me(e) {
|
|
392
|
+
let t = /* @__PURE__ */ new Map(), n = null;
|
|
393
|
+
for (let r of e.split("\n")) {
|
|
394
|
+
let e = r.trim();
|
|
395
|
+
if (e) {
|
|
396
|
+
if (/^\d{4}-\d{2}-\d{2}T/.test(e)) {
|
|
397
|
+
n = e;
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
n && !t.has(e) && t.set(e, n);
|
|
378
401
|
}
|
|
379
402
|
}
|
|
403
|
+
return t;
|
|
380
404
|
}
|
|
381
|
-
async function
|
|
382
|
-
|
|
405
|
+
async function Ne(e, t, n) {
|
|
406
|
+
let r = L([t]);
|
|
407
|
+
if (!r.length) return;
|
|
408
|
+
let i;
|
|
383
409
|
try {
|
|
384
|
-
|
|
410
|
+
i = Me(await e.raw([
|
|
411
|
+
"log",
|
|
412
|
+
"--format=%cI",
|
|
413
|
+
"--name-only"
|
|
414
|
+
]));
|
|
415
|
+
} catch (e) {
|
|
416
|
+
A(` Unable to read commit history for repository '${n}'. Error : ${e instanceof Error ? e.message : String(e)}`, "warn");
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
for (let e of r) {
|
|
420
|
+
let n = i.get(_(t, e));
|
|
421
|
+
n && Se(e, n);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
async function Pe(e, t, n, a, o, s) {
|
|
425
|
+
if (t.startsWith("-") || a.startsWith("-")) return A(` Refusing to clone '${e}': unsafe repository URL or branch name.`, "error"), !1;
|
|
426
|
+
F(n, { clean: !0 });
|
|
427
|
+
try {
|
|
428
|
+
let c = ee({
|
|
385
429
|
baseDir: n,
|
|
386
430
|
config: [
|
|
387
431
|
"maintenance.auto=false",
|
|
@@ -390,32 +434,32 @@ async function Me(e, t, n, a, o, s) {
|
|
|
390
434
|
]
|
|
391
435
|
});
|
|
392
436
|
await c.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", t);
|
|
393
|
-
for (let t of o)
|
|
394
|
-
|
|
395
|
-
} catch (
|
|
396
|
-
|
|
437
|
+
for (let t of o) A(` Add '${t}' to '${e}' sparse-checkout file.`, "debug"), r(v(n, ".git/info/sparse-checkout"), `${t}\n`, "utf8");
|
|
438
|
+
return A(` Clone repository '${e}'.`, "info"), await c.pull("origin", a), s && await Ne(c, n, e), o.some((e) => e.includes("docs")) && (i(v(n, "docs"), n, { recursive: !0 }), u(v(n, "docs"), { recursive: !0 })), u(v(n, ".git"), { recursive: !0 }), !0;
|
|
439
|
+
} catch (t) {
|
|
440
|
+
return A(` Error when cloning repository '${e}': ${t instanceof Error ? t.message : String(t)}.`, "error"), !1;
|
|
397
441
|
}
|
|
398
442
|
}
|
|
399
443
|
//#endregion
|
|
400
444
|
//#region src/lib/gitlab.ts
|
|
401
|
-
var
|
|
402
|
-
async function
|
|
403
|
-
let n = await fetch(`${
|
|
445
|
+
var Fe = "https://gitlab.com/api/v4";
|
|
446
|
+
async function Z(e, t) {
|
|
447
|
+
let n = await fetch(`${Fe}${e}`, { headers: t ? { "PRIVATE-TOKEN": t } : {} });
|
|
404
448
|
if (!n.ok) throw Error(`GitLab API request failed for '${e}' (status: ${n.status}).`);
|
|
405
449
|
return {
|
|
406
450
|
data: await n.json(),
|
|
407
451
|
headers: n.headers
|
|
408
452
|
};
|
|
409
453
|
}
|
|
410
|
-
async function
|
|
454
|
+
async function Q(e, t) {
|
|
411
455
|
let n = e.includes("?") ? "&" : "?", r = [], i = "1";
|
|
412
456
|
for (; i;) {
|
|
413
|
-
let
|
|
414
|
-
r.push(...a), i =
|
|
457
|
+
let a = await Z(`${e}${n}per_page=100&page=${i}`, t);
|
|
458
|
+
r.push(...a.data), i = a.headers.get("x-next-page") || null;
|
|
415
459
|
}
|
|
416
460
|
return r;
|
|
417
461
|
}
|
|
418
|
-
function
|
|
462
|
+
function Ie(e) {
|
|
419
463
|
return {
|
|
420
464
|
login: e.username ?? e.path,
|
|
421
465
|
name: e.name,
|
|
@@ -424,7 +468,7 @@ function J(e) {
|
|
|
424
468
|
html_url: e.web_url
|
|
425
469
|
};
|
|
426
470
|
}
|
|
427
|
-
function
|
|
471
|
+
function Le(e, t) {
|
|
428
472
|
return {
|
|
429
473
|
name: e.path,
|
|
430
474
|
owner: { login: t },
|
|
@@ -438,32 +482,32 @@ function Y(e, t) {
|
|
|
438
482
|
stargazers_count: e.star_count
|
|
439
483
|
};
|
|
440
484
|
}
|
|
441
|
-
async function
|
|
442
|
-
|
|
443
|
-
let { data: r } = await
|
|
485
|
+
async function Re({ username: e, token: t, branch: n }) {
|
|
486
|
+
A(` Get infos for username '${e}'.`, "info");
|
|
487
|
+
let { data: r } = await Z(`/users?username=${encodeURIComponent(e)}`, t);
|
|
444
488
|
if (r.length) {
|
|
445
|
-
let
|
|
446
|
-
t && (
|
|
447
|
-
let
|
|
489
|
+
let i = r[0];
|
|
490
|
+
t && (i = await Z(`/users/${r[0].id}`, t).then((e) => e.data).catch(() => r[0])), A(" Get repositories infos.", "debug");
|
|
491
|
+
let a = await Q(`/users/${r[0].id}/projects`, t);
|
|
448
492
|
return {
|
|
449
|
-
user:
|
|
450
|
-
repos:
|
|
493
|
+
user: Ie(i),
|
|
494
|
+
repos: a.map((t) => Le(t, i.username ?? e)),
|
|
451
495
|
branch: n
|
|
452
496
|
};
|
|
453
497
|
}
|
|
454
|
-
|
|
455
|
-
let i = await
|
|
498
|
+
A(` No GitLab user '${e}' found, trying groups.`, "debug");
|
|
499
|
+
let i = await Z(`/groups/${encodeURIComponent(e)}?with_projects=false`, t).then((e) => e.data).catch(() => {
|
|
456
500
|
throw Error(`No GitLab user or group found for '${e}'.`);
|
|
457
|
-
}), a = await
|
|
501
|
+
}), a = await Q(`/groups/${encodeURIComponent(e)}/projects`, t);
|
|
458
502
|
return {
|
|
459
|
-
user:
|
|
460
|
-
repos: a.map((
|
|
503
|
+
user: Ie(i),
|
|
504
|
+
repos: a.map((t) => Le(t, i.path ?? e)),
|
|
461
505
|
branch: n
|
|
462
506
|
};
|
|
463
507
|
}
|
|
464
508
|
//#endregion
|
|
465
509
|
//#region src/lib/fetch.ts
|
|
466
|
-
function
|
|
510
|
+
function ze(e, t, n) {
|
|
467
511
|
if (n === "gitlab") {
|
|
468
512
|
let n = e.html_url ?? `https://gitlab.com/${e.owner.login}/${e.name}`;
|
|
469
513
|
return {
|
|
@@ -479,25 +523,31 @@ function X(e, t, n) {
|
|
|
479
523
|
raw_url: `https://raw.githubusercontent.com/${e.owner.login}/${e.name}/${t}`
|
|
480
524
|
};
|
|
481
525
|
}
|
|
482
|
-
async function
|
|
526
|
+
async function Be(e) {
|
|
527
|
+
let [t, n, r] = await Promise.all([
|
|
528
|
+
j(`${e.blob_url}/README.md`),
|
|
529
|
+
j(`${e.tree_url}/docs`),
|
|
530
|
+
j(`${e.blob_url}/docs/01-readme.md`)
|
|
531
|
+
]);
|
|
483
532
|
return {
|
|
484
|
-
rootReadmeStatus:
|
|
485
|
-
docsFolderStatus:
|
|
486
|
-
docsReadmeStatus:
|
|
533
|
+
rootReadmeStatus: t,
|
|
534
|
+
docsFolderStatus: n,
|
|
535
|
+
docsReadmeStatus: r
|
|
487
536
|
};
|
|
488
537
|
}
|
|
489
|
-
async function
|
|
490
|
-
await (r === "gitlab" ?
|
|
538
|
+
async function Ve({ username: e, branch: t, reposFilter: n, gitProvider: r, token: i, lastUpdated: a }) {
|
|
539
|
+
let { user: o, repos: s, branch: c } = await (r === "gitlab" ? Re : Ae)({
|
|
491
540
|
username: e,
|
|
492
541
|
token: i,
|
|
493
542
|
branch: t
|
|
494
|
-
})
|
|
543
|
+
}), { repos: l } = await We(o, s, c, n, r);
|
|
544
|
+
await Ge(l, n, a);
|
|
495
545
|
}
|
|
496
|
-
async function
|
|
546
|
+
async function He(e, t, n, r) {
|
|
497
547
|
let i = [];
|
|
498
548
|
return await Promise.all(e.map(async (e) => {
|
|
499
|
-
let a = t ?? e.default_branch ?? "main", o =
|
|
500
|
-
!e.fork && !e.private && !s && (l = await
|
|
549
|
+
let a = t ?? e.default_branch ?? "main", o = v(T, P(M(e.name), { removeDot: !0 })), s = Ke(e, n), c = ze(e, a, r), l = [];
|
|
550
|
+
!e.fork && !e.private && !s && (l = await Ue(e, a, r, c)), i.push({
|
|
501
551
|
...e,
|
|
502
552
|
docpress: {
|
|
503
553
|
filtered: s,
|
|
@@ -510,60 +560,75 @@ async function Le(e, t, n, r) {
|
|
|
510
560
|
});
|
|
511
561
|
})), i;
|
|
512
562
|
}
|
|
513
|
-
async function
|
|
514
|
-
let
|
|
515
|
-
return Object.values(
|
|
563
|
+
async function Ue(e, t, n, r) {
|
|
564
|
+
let i = await Be(r ?? ze(e, t, n)), a = [];
|
|
565
|
+
return Object.values(i).every((e) => e !== 200) || !e.size ? [] : (i.docsFolderStatus === 200 && a.push("docs/*"), (i.docsFolderStatus !== 200 || i.docsReadmeStatus !== 200) && a.push("README.md", "!*/**/README.md"), a);
|
|
516
566
|
}
|
|
517
|
-
async function
|
|
518
|
-
f(`${
|
|
519
|
-
let a = await
|
|
520
|
-
return f(`${
|
|
567
|
+
async function We(e, t, n, r, i) {
|
|
568
|
+
f(`${w}/user-${M(e.login)}.json`, JSON.stringify(e, null, 2));
|
|
569
|
+
let a = await He(t, n, r, i);
|
|
570
|
+
return f(`${w}/repos-${M(e.login)}.json`, JSON.stringify(a, null, 2)), {
|
|
521
571
|
user: e,
|
|
522
572
|
repos: a
|
|
523
573
|
};
|
|
524
574
|
}
|
|
525
|
-
async function
|
|
575
|
+
async function Ge(e, t, n) {
|
|
526
576
|
if (!e) {
|
|
527
|
-
|
|
577
|
+
A(" No repository respect docpress rules.", "warn");
|
|
528
578
|
return;
|
|
529
579
|
}
|
|
530
|
-
await Promise.all(e.filter((e) => !
|
|
531
|
-
await
|
|
532
|
-
|
|
580
|
+
let r = (await Promise.all(e.filter((e) => !Ke(e, t)).map(async (e) => {
|
|
581
|
+
let t = await Pe(e.name, e.clone_url, e.docpress.projectPath, e.docpress.branch, e.docpress.includes, n);
|
|
582
|
+
return {
|
|
583
|
+
name: e.name,
|
|
584
|
+
success: t
|
|
585
|
+
};
|
|
586
|
+
}))).filter(({ success: e }) => !e).map(({ name: e }) => e);
|
|
587
|
+
r.length && A(` ${r.length} repository(ies) failed to clone: ${r.join(", ")}.`, "warn");
|
|
533
588
|
}
|
|
534
|
-
function
|
|
535
|
-
|
|
536
|
-
|
|
589
|
+
function Ke(e, t) {
|
|
590
|
+
if ("docpress" in e && !e.docpress.includes.length) return !0;
|
|
591
|
+
let n = t?.filter((e) => !e.startsWith("!")) ?? [], r = t?.every((e) => e.startsWith("!")), i = t?.filter((e) => e.startsWith("!")).some((t) => e.name === t.substring(1)), a = !t || n.includes(e.name) || e.fork && !i || r && !i, o = i || !a;
|
|
592
|
+
return !(e.clone_url && !e.private && !o);
|
|
537
593
|
}
|
|
538
594
|
//#endregion
|
|
539
595
|
//#region src/commands/global.ts
|
|
540
|
-
var
|
|
541
|
-
n("-C, --config <string>",
|
|
542
|
-
n("-T, --token <string>",
|
|
543
|
-
n("-U, --usernames <string>",
|
|
544
|
-
],
|
|
545
|
-
n("-b, --branch <string>",
|
|
546
|
-
n("-g, --git-provider <string>",
|
|
547
|
-
n("-l, --last-updated",
|
|
548
|
-
n("-r, --repos-filter <string>",
|
|
549
|
-
],
|
|
550
|
-
await
|
|
596
|
+
var $ = [
|
|
597
|
+
n("-C, --config <string>", K.shape.config.description),
|
|
598
|
+
n("-T, --token <string>", K.shape.token.description),
|
|
599
|
+
n("-U, --usernames <string>", K.shape.usernames.description)
|
|
600
|
+
], qe = "fetch", Je = [
|
|
601
|
+
n("-b, --branch <string>", G.shape.branch.description).default(G.shape.branch.def.defaultValue),
|
|
602
|
+
n("-g, --git-provider <string>", G.shape.gitProvider.description).default(G.shape.gitProvider.def.defaultValue),
|
|
603
|
+
n("-l, --last-updated", G.shape.lastUpdated.description),
|
|
604
|
+
n("-r, --repos-filter <string>", G.shape.reposFilter.description)
|
|
605
|
+
], Ye = Y(t(qe), [...Je, ...$]).description("Fetch docs with the given username(s) and git provider.").action(async (e, t) => {
|
|
606
|
+
await Xe(q(qe, J(t, e)));
|
|
551
607
|
});
|
|
552
|
-
async function
|
|
608
|
+
async function Xe(e) {
|
|
553
609
|
let { usernames: t, reposFilter: n, token: r, branch: i, gitProvider: a, lastUpdated: o } = e;
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
610
|
+
A("\n-> Start fetching documentation files. This may take a moment, especially for larger repositories.", "info"), F(w, { clean: !0 });
|
|
611
|
+
let s = [];
|
|
612
|
+
for (let e of t) {
|
|
613
|
+
let c = t.length > 1 ? n?.filter((t) => t.replace(/^!/, "").startsWith(`${e}/`)).map((t) => t.replace(`${e}/`, "")) : n;
|
|
614
|
+
try {
|
|
615
|
+
await Ve({
|
|
616
|
+
username: e,
|
|
617
|
+
branch: i,
|
|
618
|
+
reposFilter: c,
|
|
619
|
+
gitProvider: a,
|
|
620
|
+
token: r,
|
|
621
|
+
lastUpdated: o
|
|
622
|
+
});
|
|
623
|
+
} catch (t) {
|
|
624
|
+
s.push(e), A(` Failed to fetch documentation for '${e}': ${t instanceof Error ? t.message : String(t)}`, "error");
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (s.length === t.length) throw Error(`Failed to fetch documentation for all requested username(s): ${s.join(", ")}.`);
|
|
563
628
|
}
|
|
564
629
|
//#endregion
|
|
565
630
|
//#region src/commands/build.ts
|
|
566
|
-
async function
|
|
631
|
+
async function Ze(e) {
|
|
567
632
|
let t = console.warn;
|
|
568
633
|
console.warn = function(...e) {
|
|
569
634
|
e.length > 0 && typeof e[0] == "string" && (e[0].includes("[Vue warn]: Invalid watch source:") || e[0].includes("{ open: false }")) || t.apply(console, e);
|
|
@@ -574,30 +639,30 @@ async function Ge(e) {
|
|
|
574
639
|
console.warn = t;
|
|
575
640
|
}
|
|
576
641
|
}
|
|
577
|
-
var
|
|
578
|
-
await
|
|
642
|
+
var Qe = Y(t("build"), $).description("Build vitepress website.").action(async (e) => {
|
|
643
|
+
await $e();
|
|
579
644
|
});
|
|
580
|
-
async function
|
|
581
|
-
|
|
645
|
+
async function $e() {
|
|
646
|
+
A("\n-> Start building Vitepress website.\n\n", "info");
|
|
582
647
|
try {
|
|
583
|
-
await
|
|
584
|
-
await
|
|
585
|
-
|
|
648
|
+
await Ze(async () => {
|
|
649
|
+
await te(w, { onAfterConfigResolve(e) {
|
|
650
|
+
ne(e);
|
|
586
651
|
} });
|
|
587
|
-
}),
|
|
652
|
+
}), A("\n\nDocpress build succeeded.", "success");
|
|
588
653
|
} catch (e) {
|
|
589
|
-
|
|
654
|
+
A(`\n\nDocpress build failed : ${e}`, "error"), process.exit(1);
|
|
590
655
|
}
|
|
591
656
|
}
|
|
592
657
|
//#endregion
|
|
593
658
|
//#region src/utils/templates.ts
|
|
594
|
-
function
|
|
659
|
+
function et(e, t) {
|
|
595
660
|
let n = s(e, { encoding: "utf8" });
|
|
596
|
-
|
|
661
|
+
F(m(t)), f(t, n);
|
|
597
662
|
}
|
|
598
663
|
//#endregion
|
|
599
664
|
//#region src/lib/vitepress.ts
|
|
600
|
-
var
|
|
665
|
+
var tt = {
|
|
601
666
|
base: "/",
|
|
602
667
|
lang: "en-US",
|
|
603
668
|
vite: { publicDir: "../public" },
|
|
@@ -630,21 +695,21 @@ var Ye = {
|
|
|
630
695
|
}
|
|
631
696
|
}
|
|
632
697
|
};
|
|
633
|
-
function
|
|
634
|
-
return n ?
|
|
698
|
+
function nt(e, t, n) {
|
|
699
|
+
return n ? R(tt, n, { themeConfig: {
|
|
635
700
|
sidebar: e,
|
|
636
701
|
nav: t
|
|
637
|
-
} }) :
|
|
702
|
+
} }) : R(tt, { themeConfig: {
|
|
638
703
|
sidebar: e,
|
|
639
704
|
nav: t
|
|
640
705
|
} });
|
|
641
706
|
}
|
|
642
707
|
//#endregion
|
|
643
708
|
//#region src/lib/prepare.ts
|
|
644
|
-
async function
|
|
709
|
+
async function rt({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, vitepressConfig: r, forks: i, gitProvider: o, lastUpdated: s, token: c, username: l, websiteTitle: u, websiteTagline: d }) {
|
|
645
710
|
let f = i && o !== "gitlab";
|
|
646
|
-
i && !f &&
|
|
647
|
-
let p =
|
|
711
|
+
i && !f && A(" The forks page is not supported with the 'gitlab' provider, skipping.", "warn");
|
|
712
|
+
let p = ve(l), m = ye(l).reduce(({ internals: e, forks: t }, n) => {
|
|
648
713
|
let { clone_url: r, private: i, fork: a, docpress: o } = n;
|
|
649
714
|
if (r && !i && !o.filtered) {
|
|
650
715
|
if (!a && o.includes.length) return {
|
|
@@ -663,39 +728,39 @@ async function Ze({ extraHeaderPages: e, extraPublicContent: t, extraTheme: n, v
|
|
|
663
728
|
}, {
|
|
664
729
|
internals: [],
|
|
665
730
|
forks: []
|
|
666
|
-
}),
|
|
731
|
+
}), h = {
|
|
667
732
|
title: u,
|
|
668
733
|
tagline: d
|
|
669
|
-
}, { index:
|
|
670
|
-
if (a(
|
|
671
|
-
let e = await
|
|
672
|
-
|
|
673
|
-
...
|
|
674
|
-
features: [...t.features, ...
|
|
734
|
+
}, { index: g, sidebar: _ } = ft(m.internals, p, h), y, b;
|
|
735
|
+
if (a(E) && a(D)) {
|
|
736
|
+
let e = await _t(D), t = await vt(E);
|
|
737
|
+
y = [...e.themeConfig?.sidebar ?? [], ..._].sort((e, t) => e.text.localeCompare(t.text)), b = {
|
|
738
|
+
...g,
|
|
739
|
+
features: [...t.features, ...g.features].sort((e, t) => e.title.localeCompare(t.title))
|
|
675
740
|
};
|
|
676
|
-
} else
|
|
677
|
-
let
|
|
741
|
+
} else y = _, b = g;
|
|
742
|
+
let x = [];
|
|
678
743
|
if (e) {
|
|
679
|
-
let t =
|
|
680
|
-
f ?
|
|
744
|
+
let t = pt(e);
|
|
745
|
+
f ? x.push(...t.filter((e) => e.link !== "/forks")) : x.push(...t);
|
|
681
746
|
}
|
|
682
|
-
t && (
|
|
747
|
+
t && (A(" Add extras Vitepress public folder content.", "info"), mt(t, v(w, "public"))), n && (A(" Add extras Vitepress theme files.", "info"), mt(n, v(se))), f && l.length && (A(" Add fork page to display external contributions.", "info"), await gt(m.forks, l, c), x.push({
|
|
683
748
|
text: "Forks",
|
|
684
749
|
link: "/forks"
|
|
685
750
|
}));
|
|
686
|
-
let
|
|
751
|
+
let S = s ? {
|
|
687
752
|
lastUpdated: !0,
|
|
688
753
|
...r
|
|
689
754
|
} : r;
|
|
690
|
-
|
|
755
|
+
yt(nt(y, x, S), b);
|
|
691
756
|
}
|
|
692
|
-
function
|
|
693
|
-
r(t, `${
|
|
757
|
+
function it(e, t) {
|
|
758
|
+
r(t, `${P(p(t), {
|
|
694
759
|
mode: "lowercase",
|
|
695
760
|
removeIdx: !0
|
|
696
761
|
}) === "readme.md" ? "\n## Sources" : "# Sources"}\n\nTake a look at the [project sources](${e}).\n`, "utf8");
|
|
697
762
|
}
|
|
698
|
-
function
|
|
763
|
+
function at(e, t, n) {
|
|
699
764
|
let { name: r, login: i, bio: a } = t, { title: o, tagline: s } = n;
|
|
700
765
|
return {
|
|
701
766
|
layout: "home",
|
|
@@ -709,20 +774,20 @@ function $e(e, t, n) {
|
|
|
709
774
|
features: e
|
|
710
775
|
};
|
|
711
776
|
}
|
|
712
|
-
function
|
|
777
|
+
function ot(e, t, n) {
|
|
713
778
|
let r = {
|
|
714
|
-
title:
|
|
779
|
+
title: P(e, {
|
|
715
780
|
mode: "capitalize",
|
|
716
781
|
replaceDash: !0
|
|
717
782
|
}),
|
|
718
783
|
details: t,
|
|
719
|
-
link: `/${
|
|
784
|
+
link: `/${P(e, { removeDot: !0 })}/introduction`
|
|
720
785
|
};
|
|
721
786
|
return n ? [...n, r] : [r];
|
|
722
787
|
}
|
|
723
|
-
function
|
|
788
|
+
function st(e, t) {
|
|
724
789
|
return {
|
|
725
|
-
text:
|
|
790
|
+
text: P(e, {
|
|
726
791
|
mode: "capitalize",
|
|
727
792
|
replaceDash: !0
|
|
728
793
|
}),
|
|
@@ -730,86 +795,86 @@ function tt(e, t) {
|
|
|
730
795
|
items: t
|
|
731
796
|
};
|
|
732
797
|
}
|
|
733
|
-
function
|
|
798
|
+
function ct(e, t) {
|
|
734
799
|
return Object.entries(t).flatMap(([t, n]) => t === "$" ? Array.isArray(n) ? n.map((t) => {
|
|
735
|
-
let n =
|
|
800
|
+
let n = v(e.docpress.projectPath, t), r = P(p(n), {
|
|
736
801
|
mode: "lowercase",
|
|
737
802
|
removeIdx: !0
|
|
738
803
|
});
|
|
739
|
-
return r === "readme.md" && (r = "introduction.md"), r !== p(n) && l(n,
|
|
740
|
-
text:
|
|
804
|
+
return r === "readme.md" && (r = "introduction.md"), r !== p(n) && l(n, v(m(n), r)), {
|
|
805
|
+
text: g(r).name === "introduction" ? "Introduction" : P(r, {
|
|
741
806
|
mode: "capitalize",
|
|
742
807
|
replaceDash: !0,
|
|
743
808
|
removeExt: !0
|
|
744
809
|
}),
|
|
745
|
-
link: `/${
|
|
810
|
+
link: `/${P(e.name, { removeDot: !0 })}/${g(r).name}`
|
|
746
811
|
};
|
|
747
812
|
}) : [] : typeof n == "object" ? [{
|
|
748
|
-
text:
|
|
813
|
+
text: P(t, {
|
|
749
814
|
mode: "capitalize",
|
|
750
815
|
replaceDash: !0
|
|
751
816
|
}),
|
|
752
817
|
collapsed: !0,
|
|
753
|
-
items:
|
|
818
|
+
items: ct({
|
|
754
819
|
...e,
|
|
755
820
|
name: `${e.name}/${t}`
|
|
756
821
|
}, n)
|
|
757
822
|
}] : []);
|
|
758
823
|
}
|
|
759
|
-
function
|
|
824
|
+
function lt(e) {
|
|
760
825
|
return e.reduce((e, t) => {
|
|
761
826
|
let [n, ...r] = t.split("/");
|
|
762
|
-
return r.length ? e[n] =
|
|
827
|
+
return r.length ? e[n] = lt([...e[n] ? ut(e[n], "") : [], r.join("/")]) : e.$ = [...e.$ || [], n], e;
|
|
763
828
|
}, {});
|
|
764
829
|
}
|
|
765
|
-
function
|
|
766
|
-
return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] :
|
|
830
|
+
function ut(e, t = "") {
|
|
831
|
+
return Object.entries(e).flatMap(([e, n]) => e === "$" ? Array.isArray(n) ? n.map((e) => t ? `${t}/${e}` : e) : [] : ut(n, t ? `${t}/${e}` : e));
|
|
767
832
|
}
|
|
768
|
-
function
|
|
833
|
+
function dt(e) {
|
|
769
834
|
if (!Array.isArray(e)) return e;
|
|
770
835
|
let t = e.findIndex((e) => e.text === "Sources");
|
|
771
836
|
if (t === -1) return e;
|
|
772
837
|
let [n] = e.splice(t, 1);
|
|
773
838
|
return e.push(n), e;
|
|
774
839
|
}
|
|
775
|
-
function
|
|
840
|
+
function ft(e, t, n) {
|
|
776
841
|
let r = [], i = [];
|
|
777
842
|
for (let t of e) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
}),
|
|
843
|
+
A(` Replace urls for repository '${t.name}'.`, "info"), L([t.docpress.projectPath]).forEach((e) => {
|
|
844
|
+
A(` Processing file '${p(e)}' for repository '${t.name}'.`, "debug"), xe(e, t.docpress.replace_url), p(e).toLowerCase() === "readme.md" && we(e, t.docpress.replace_url), Ce(e);
|
|
845
|
+
}), A(` Generate sidebar for repository '${t.name}'.`, "info");
|
|
781
846
|
let e = c(t.docpress.projectPath, { recursive: !0 }).filter((e) => {
|
|
782
|
-
let n =
|
|
783
|
-
return p(n).endsWith(".md") &&
|
|
847
|
+
let n = v(t.docpress.projectPath, e.toString());
|
|
848
|
+
return p(n).endsWith(".md") && ge(n);
|
|
784
849
|
}).sort();
|
|
785
|
-
|
|
850
|
+
A(` Add sources for repository '${t.name}'.`, "info");
|
|
786
851
|
let n;
|
|
787
|
-
e.length > 1 ? (n =
|
|
788
|
-
let a =
|
|
789
|
-
i.push(
|
|
852
|
+
e.length > 1 ? (n = v(t.docpress.projectPath, "sources.md"), e.push("sources.md")) : e.length === 1 && (n = v(t.docpress.projectPath, e[0])), n ? it(t.html_url, n) : A(` No markdown files found for repository '${t.name}', skipping sources.`, "warn");
|
|
853
|
+
let a = dt(ct(t, lt(e)));
|
|
854
|
+
i.push(st(P(t.name, { removeDot: !0 }), a)), r.push(...ot(P(t.name, { removeDot: !0 }), t.description || ""));
|
|
790
855
|
}
|
|
791
|
-
|
|
792
|
-
let a =
|
|
856
|
+
A(" Generate index content.", "info");
|
|
857
|
+
let a = at(r.toSorted((e, t) => e.title.localeCompare(t.title)), t, n);
|
|
793
858
|
return {
|
|
794
859
|
sidebar: i.toSorted((e, t) => e.text.localeCompare(t.text)),
|
|
795
860
|
index: a
|
|
796
861
|
};
|
|
797
862
|
}
|
|
798
|
-
function
|
|
799
|
-
let t =
|
|
800
|
-
|
|
863
|
+
function pt(e) {
|
|
864
|
+
let t = L(e), n = [];
|
|
865
|
+
A(" Add extras Vitepress headers pages.", "info");
|
|
801
866
|
for (let e of t) {
|
|
802
|
-
|
|
803
|
-
let t =
|
|
804
|
-
i(t,
|
|
867
|
+
A(` Processing file '${e}'.`, "debug");
|
|
868
|
+
let t = v(process.cwd(), e);
|
|
869
|
+
i(t, v(T, P(p(e), {
|
|
805
870
|
mode: "lowercase",
|
|
806
871
|
removeIdx: !0
|
|
807
872
|
}))), n.push({
|
|
808
|
-
text:
|
|
873
|
+
text: P(g(t).name, {
|
|
809
874
|
replaceDash: !0,
|
|
810
875
|
removeIdx: !0
|
|
811
876
|
}),
|
|
812
|
-
link: `/${
|
|
877
|
+
link: `/${P(g(t).name, {
|
|
813
878
|
removeIdx: !0,
|
|
814
879
|
mode: "lowercase"
|
|
815
880
|
})}`
|
|
@@ -817,18 +882,18 @@ function ot(e) {
|
|
|
817
882
|
}
|
|
818
883
|
return n;
|
|
819
884
|
}
|
|
820
|
-
function
|
|
885
|
+
function mt(e, t, n) {
|
|
821
886
|
for (let r of Array.isArray(e) ? e : [e]) {
|
|
822
|
-
let e =
|
|
887
|
+
let e = v(process.cwd(), r), a = I(e);
|
|
823
888
|
for (let o of a) {
|
|
824
889
|
let a = o.replace(e, ".");
|
|
825
|
-
|
|
826
|
-
let s =
|
|
890
|
+
A(` Processing file '${a}' for entry '${r}'.`, "debug");
|
|
891
|
+
let s = v(process.cwd(), o), c = v(t, a);
|
|
827
892
|
n && n(), i(s, c);
|
|
828
893
|
}
|
|
829
894
|
}
|
|
830
895
|
}
|
|
831
|
-
function
|
|
896
|
+
function ht(e) {
|
|
832
897
|
let t = e.map(({ repository: e, contributions: t }) => {
|
|
833
898
|
let { name: n, owner: r, html_url: i, description: a, stargazers_count: o } = e;
|
|
834
899
|
return {
|
|
@@ -840,11 +905,11 @@ function ct(e) {
|
|
|
840
905
|
contributions: t
|
|
841
906
|
};
|
|
842
907
|
});
|
|
843
|
-
|
|
908
|
+
A(" Generate forks page.", "info"), f(ae, "---\nlayout: fork-page\nrepoList:\n" + b.stringify(t) + "---\n\n# External contributions\n\nThis gallery is a visual representation of the collaborative work done across a variety of open-source projects, each driven by a shared passion for innovation and community growth.\n\nEvery tile below represents a unique project where contributions have been made-ranging from code enhancements to documentation improvements. Each project includes a summary of its goals, features, and links to GitHub for direct access.\n\nThis page serves as both a portfolio of past work and a resource for revisiting projects that have made a meaningful impact.\n");
|
|
844
909
|
}
|
|
845
|
-
async function
|
|
846
|
-
|
|
847
|
-
let { source: r, contributors: i } = await
|
|
910
|
+
async function gt(e, t, n) {
|
|
911
|
+
ht(await Promise.all(e.map(async (e) => {
|
|
912
|
+
let { source: r, contributors: i } = await je({
|
|
848
913
|
repository: e,
|
|
849
914
|
token: n
|
|
850
915
|
});
|
|
@@ -854,40 +919,40 @@ async function lt(e, t, n) {
|
|
|
854
919
|
};
|
|
855
920
|
})).then((e) => e.filter(({ repository: e, contributions: t }) => !!e && t)));
|
|
856
921
|
}
|
|
857
|
-
async function
|
|
922
|
+
async function _t(e) {
|
|
858
923
|
try {
|
|
859
|
-
let { config: t } = await import(
|
|
924
|
+
let { config: t } = await import(v(process.cwd(), e));
|
|
860
925
|
return t ?? {};
|
|
861
926
|
} catch (t) {
|
|
862
|
-
return
|
|
927
|
+
return A(` Unable to load existing Vitepress config '${e}', starting from an empty config. ${t instanceof Error ? t.message : ""}`, "warn"), {};
|
|
863
928
|
}
|
|
864
929
|
}
|
|
865
|
-
async function
|
|
866
|
-
let t = (await
|
|
867
|
-
return
|
|
930
|
+
async function vt(e) {
|
|
931
|
+
let t = (await re(v(process.cwd(), e))).toString();
|
|
932
|
+
return b.parse(t);
|
|
868
933
|
}
|
|
869
|
-
function
|
|
870
|
-
return
|
|
871
|
-
|
|
934
|
+
function yt(e, t) {
|
|
935
|
+
return F(m(D)), A(" Generate Vitepress config.", "info"), f(D, `export const config = ${JSON.stringify(e, null, 2)}\n\nexport default config\n`), A(" Generate index file.", "info"), f(E, "---\n" + b.stringify(t)), A(" Add Docpress theme files.", "info"), I(O).forEach((e) => {
|
|
936
|
+
et(e, v(oe, e.replace(`${O}/`, "")));
|
|
872
937
|
});
|
|
873
938
|
}
|
|
874
939
|
//#endregion
|
|
875
940
|
//#region src/commands/prepare.ts
|
|
876
|
-
var
|
|
877
|
-
n("-c, --extra-public-content <string>",
|
|
878
|
-
n("-f, --forks",
|
|
879
|
-
n("-p, --extra-header-pages <string>",
|
|
880
|
-
n("-t, --extra-theme <string>",
|
|
881
|
-
n("-v, --vitepress-config <string>",
|
|
882
|
-
n("--website-title <string>",
|
|
883
|
-
n("--website-tagline <string>",
|
|
884
|
-
],
|
|
885
|
-
await
|
|
941
|
+
var bt = "prepare", xt = [
|
|
942
|
+
n("-c, --extra-public-content <string>", G.shape.extraPublicContent.description),
|
|
943
|
+
n("-f, --forks", G.shape.forks.description),
|
|
944
|
+
n("-p, --extra-header-pages <string>", G.shape.extraHeaderPages.description),
|
|
945
|
+
n("-t, --extra-theme <string>", G.shape.extraTheme.description),
|
|
946
|
+
n("-v, --vitepress-config <string>", G.shape.vitepressConfig.description),
|
|
947
|
+
n("--website-title <string>", G.shape.websiteTitle.description),
|
|
948
|
+
n("--website-tagline <string>", G.shape.websiteTagline.description)
|
|
949
|
+
], St = Y(t(bt), [...xt, ...$]).description("Transform doc to the target vitepress format.").action(async (e, t) => {
|
|
950
|
+
await Ct(q(bt, J(t, e)));
|
|
886
951
|
});
|
|
887
|
-
async function
|
|
952
|
+
async function Ct(e) {
|
|
888
953
|
let { extraHeaderPages: t, extraPublicContent: n, extraTheme: r, vitepressConfig: i, forks: a, gitProvider: o, lastUpdated: s, token: c, usernames: l, websiteTitle: u, websiteTagline: d } = e;
|
|
889
|
-
|
|
890
|
-
for (let e of l) await
|
|
954
|
+
A("\n-> Start transform files to prepare Vitepress build.", "info"), F(m(D), { clean: !0 });
|
|
955
|
+
for (let e of l) await rt({
|
|
891
956
|
extraHeaderPages: t,
|
|
892
957
|
extraPublicContent: n,
|
|
893
958
|
extraTheme: r,
|
|
@@ -903,27 +968,27 @@ async function gt(e) {
|
|
|
903
968
|
}
|
|
904
969
|
//#endregion
|
|
905
970
|
//#region src/cli.ts
|
|
906
|
-
function
|
|
907
|
-
let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${
|
|
908
|
-
let n =
|
|
909
|
-
await
|
|
971
|
+
function wt() {
|
|
972
|
+
let t = new e().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${ie.version}`).action(async (e, t) => {
|
|
973
|
+
let n = q("global", J(t, e));
|
|
974
|
+
await Xe(n), await Ct(n), await $e();
|
|
910
975
|
}).configureHelp({
|
|
911
976
|
sortSubcommands: !0,
|
|
912
977
|
sortOptions: !0,
|
|
913
978
|
showGlobalOptions: !0
|
|
914
|
-
}).enablePositionalOptions().passThroughOptions().addCommand(
|
|
915
|
-
return
|
|
916
|
-
...
|
|
917
|
-
...
|
|
918
|
-
|
|
979
|
+
}).enablePositionalOptions().passThroughOptions().addCommand(Ye).addCommand(St).addCommand(Qe);
|
|
980
|
+
return Y(t, [
|
|
981
|
+
...Je,
|
|
982
|
+
...xt,
|
|
983
|
+
...$
|
|
919
984
|
]), t;
|
|
920
985
|
}
|
|
921
|
-
function
|
|
922
|
-
|
|
923
|
-
|
|
986
|
+
function Tt() {
|
|
987
|
+
wt().parseAsync(process.argv).catch((e) => {
|
|
988
|
+
A(`\n${e instanceof Error ? e.message : String(e)}`, "error"), process.exit(1);
|
|
924
989
|
});
|
|
925
990
|
}
|
|
926
991
|
//#endregion
|
|
927
|
-
export {
|
|
992
|
+
export { wt as getProgram, Tt as main };
|
|
928
993
|
|
|
929
994
|
//# sourceMappingURL=cli.js.map
|