@tobi-or-not/docpress 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +74 -0
  2. package/bin/docpress.js +5 -0
  3. package/dist/commands/build.js +16 -0
  4. package/dist/commands/build.js.map +1 -0
  5. package/dist/commands/fetch.js +25 -0
  6. package/dist/commands/fetch.js.map +1 -0
  7. package/dist/commands/global.js +6 -0
  8. package/dist/commands/global.js.map +1 -0
  9. package/dist/commands/prepare.js +46 -0
  10. package/dist/commands/prepare.js.map +1 -0
  11. package/dist/index.js +31 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/lib/fetch.js +92 -0
  14. package/dist/lib/fetch.js.map +1 -0
  15. package/dist/lib/git.js +33 -0
  16. package/dist/lib/git.js.map +1 -0
  17. package/dist/lib/prepare.js +128 -0
  18. package/dist/lib/prepare.js.map +1 -0
  19. package/dist/lib/vitepress.js +50 -0
  20. package/dist/lib/vitepress.js.map +1 -0
  21. package/dist/schemas/build.js +3 -0
  22. package/dist/schemas/build.js.map +1 -0
  23. package/dist/schemas/fetch.js +24 -0
  24. package/dist/schemas/fetch.js.map +1 -0
  25. package/dist/schemas/global.js +16 -0
  26. package/dist/schemas/global.js.map +1 -0
  27. package/dist/schemas/prepare.js +22 -0
  28. package/dist/schemas/prepare.js.map +1 -0
  29. package/dist/utils/commands.js +21 -0
  30. package/dist/utils/commands.js.map +1 -0
  31. package/dist/utils/const.js +8 -0
  32. package/dist/utils/const.js.map +1 -0
  33. package/dist/utils/functions.js +107 -0
  34. package/dist/utils/functions.js.map +1 -0
  35. package/dist/utils/regex.js +20 -0
  36. package/dist/utils/regex.js.map +1 -0
  37. package/package.json +62 -0
  38. package/types/commands/build.d.ts +3 -0
  39. package/types/commands/fetch.d.ts +4 -0
  40. package/types/commands/global.d.ts +1 -0
  41. package/types/commands/prepare.d.ts +4 -0
  42. package/types/index.d.ts +1 -0
  43. package/types/lib/fetch.d.ts +19 -0
  44. package/types/lib/git.d.ts +241 -0
  45. package/types/lib/prepare.d.ts +55 -0
  46. package/types/lib/vitepress.d.ts +3 -0
  47. package/types/schemas/build.d.ts +3 -0
  48. package/types/schemas/fetch.d.ts +21 -0
  49. package/types/schemas/global.d.ts +64 -0
  50. package/types/schemas/prepare.d.ts +18 -0
  51. package/types/utils/commands.d.ts +82 -0
  52. package/types/utils/const.d.ts +6 -0
  53. package/types/utils/functions.d.ts +21 -0
  54. package/types/utils/regex.d.ts +2 -0
@@ -0,0 +1,22 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ import { z } from 'zod';
4
+ export const prepareOptsSchema = z.object({
5
+ extraHeaderPages: z.string()
6
+ .describe('List of comma separated additional files or directories to process Vitepress header pages.')
7
+ .transform(paths => paths.split(','))
8
+ .optional(),
9
+ extraPublicContent: z.string()
10
+ .describe('List of comma separated additional files or directories to process Vitepress public folder.')
11
+ .transform(paths => paths.split(','))
12
+ .optional(),
13
+ extraTheme: z.string()
14
+ .describe('List of comma separated additional files or directories to use as Vitepress theme.')
15
+ .transform(paths => paths.split(','))
16
+ .optional(),
17
+ vitepressConfig: z.string()
18
+ .describe('Path to the vitepress configuration file.')
19
+ .transform(path => JSON.parse(readFileSync(resolve(process.cwd(), path)).toString()))
20
+ .optional(),
21
+ });
22
+ //# sourceMappingURL=prepare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/schemas/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;SACzB,QAAQ,CAAC,4FAA4F,CAAC;SACtG,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpC,QAAQ,EAAE;IACb,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE;SAC3B,QAAQ,CAAC,6FAA6F,CAAC;SACvG,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpC,QAAQ,EAAE;IACb,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;SACnB,QAAQ,CAAC,oFAAoF,CAAC;SAC9F,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpC,QAAQ,EAAE;IACb,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;SACxB,QAAQ,CAAC,2CAA2C,CAAC;SACrD,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAoC,CAAC;SACvH,QAAQ,EAAE;CACd,CAAC,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { globalOptsSchema } from '../schemas/global.js';
2
+ import { buildOptsSchema } from '../schemas/build.js';
3
+ import { fetchOptsSchema } from '../schemas/fetch.js';
4
+ import { prepareOptsSchema } from '../schemas/prepare.js';
5
+ export const options = {
6
+ build: buildOptsSchema,
7
+ fetch: fetchOptsSchema,
8
+ prepare: prepareOptsSchema,
9
+ global: globalOptsSchema,
10
+ };
11
+ export function parseOptions(cmd, opts) {
12
+ return options[cmd].parse({
13
+ ...globalOptsSchema.parse(opts).config,
14
+ ...opts,
15
+ });
16
+ }
17
+ export function addOptions(cmd, opts) {
18
+ opts.forEach(opt => cmd.addOption(opt));
19
+ return cmd;
20
+ }
21
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/utils/commands.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAWzD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,iBAAiB;IAC1B,MAAM,EAAE,gBAAgB;CACzB,CAAA;AAED,MAAM,UAAU,YAAY,CAAgB,GAAM,EAAE,IAAgB;IAClE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;QACxB,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM;QACtC,GAAG,IAAI;KACR,CAAe,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAY,EAAE,IAAc;IACrD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;IACvC,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { resolve } from 'node:path';
2
+ export const DOCPRESS_DIR = resolve(process.cwd(), 'docpress');
3
+ export const USER_REPOS_INFOS = resolve(process.cwd(), 'docpress/repositories.json');
4
+ export const USER_INFOS = resolve(process.cwd(), 'docpress/owner.json');
5
+ export const DOCS_DIR = resolve(process.cwd(), 'docpress/docs');
6
+ export const INDEX_FILE = resolve(process.cwd(), 'docpress/docs/index.md');
7
+ export const VITEPRESS_CONFIG = resolve(process.cwd(), 'docpress/.vitepress/config.ts');
8
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/utils/const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAA;AAE9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,4BAA4B,CAAC,CAAA;AAEpF,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,qBAAqB,CAAC,CAAA;AAEvE,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAA;AAE/D,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,wBAAwB,CAAC,CAAA;AAE1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,+BAA+B,CAAC,CAAA"}
@@ -0,0 +1,107 @@
1
+ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync } from 'node:fs';
2
+ import { basename, join } from 'node:path';
3
+ import axios from 'axios';
4
+ import { rimrafSync } from 'rimraf';
5
+ import { USER_INFOS, USER_REPOS_INFOS } from './const.js';
6
+ export async function checkHttpStatus(url) {
7
+ try {
8
+ const response = await axios.head(url);
9
+ return response.status;
10
+ }
11
+ catch (error) {
12
+ if (axios.isAxiosError(error) && error.response) {
13
+ return error.response.status;
14
+ }
15
+ return 500;
16
+ }
17
+ }
18
+ export function prettify(s, opts) {
19
+ let u = '';
20
+ if (opts?.removeIdx) {
21
+ u = s.replace(/^\d{2}-/, '');
22
+ }
23
+ if (opts?.replaceDash) {
24
+ u = (u || s).replaceAll('-', ' ');
25
+ }
26
+ if (opts?.mode === 'capitalize') {
27
+ u = (u || s).slice(0, 1).toUpperCase() + (u || s).slice(1).toLowerCase();
28
+ }
29
+ else if (opts?.mode === 'lowercase') {
30
+ u = (u || s).toLowerCase();
31
+ }
32
+ else if (opts?.mode === 'uppercase') {
33
+ u = (u || s).toUpperCase();
34
+ }
35
+ return u;
36
+ }
37
+ export function createDir(directory, { clean } = { clean: false }) {
38
+ try {
39
+ if (clean && existsSync(directory)) {
40
+ rimrafSync(`${directory}/*`, { glob: true });
41
+ }
42
+ if (!existsSync(directory)) {
43
+ mkdirSync(directory, { recursive: true });
44
+ }
45
+ }
46
+ catch (err) {
47
+ console.error(err);
48
+ }
49
+ }
50
+ export function isDir(path) {
51
+ return statSync(path).isDirectory();
52
+ }
53
+ export function isFile(path) {
54
+ return statSync(path).isFile();
55
+ }
56
+ export function extractFiles(paths) {
57
+ return (Array.isArray(paths) ? paths : [paths]).flatMap((path) => {
58
+ if (isFile(path)) {
59
+ return [path];
60
+ }
61
+ if (isDir(path)) {
62
+ return readdirSync(path).flatMap(file => extractFiles(join(path, file)));
63
+ }
64
+ return [];
65
+ });
66
+ }
67
+ export function getMdFiles(path) {
68
+ return extractFiles(path).filter(file => basename(file).endsWith('.md'));
69
+ }
70
+ export function prettifyEnum(arr) {
71
+ return arr.reduce((acc, cur, idx, arr) => {
72
+ if (!idx) {
73
+ return cur;
74
+ }
75
+ else if (idx === arr.length - 1) {
76
+ return `${JSON.stringify(acc)} or ${JSON.stringify(cur)}`;
77
+ }
78
+ else {
79
+ return `${JSON.stringify(acc)}, ${JSON.stringify(cur)}`;
80
+ }
81
+ }, '');
82
+ }
83
+ export function getUserInfos() {
84
+ return JSON.parse(readFileSync(USER_INFOS).toString());
85
+ }
86
+ export function getUserRepos() {
87
+ return JSON.parse(readFileSync(USER_REPOS_INFOS).toString());
88
+ }
89
+ export function deepMerge(...objects) {
90
+ return objects.reduce((acc, obj) => {
91
+ Object.keys(obj).forEach((key) => {
92
+ const accValue = acc[key];
93
+ const objValue = obj[key];
94
+ if (isObject(accValue) && isObject(objValue)) {
95
+ acc[key] = deepMerge(accValue, objValue);
96
+ }
97
+ else {
98
+ acc[key] = objValue;
99
+ }
100
+ });
101
+ return acc;
102
+ }, {});
103
+ }
104
+ function isObject(val) {
105
+ return val && typeof val === 'object' && !Array.isArray(val);
106
+ }
107
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/utils/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACpF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAGnC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEzD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC/C,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACtC,OAAO,QAAQ,CAAC,MAAM,CAAA;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YAChD,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAA;QAC9B,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;AACH,CAAC;AAQD,MAAM,UAAU,QAAQ,CAAC,CAAS,EAAE,IAAkB;IACpD,IAAI,CAAC,GAAW,EAAE,CAAA;IAElB,IAAI,IAAI,EAAE,SAAS,EAAE,CAAC;QACpB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAC9B,CAAC;IAED,IAAI,IAAI,EAAE,WAA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C,GAAQ;IACxB,OAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AAC9D,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
+ export function replaceRelativePath(file, url) {
3
+ const fileContent = readFileSync(file, 'utf8');
4
+ const updatedContent = fileContent.replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (_match, p1, p2) => {
5
+ return `[${p1}](${url}/${p2})`;
6
+ });
7
+ writeFileSync(file, updatedContent, 'utf8');
8
+ }
9
+ export function replaceReadmePath(file, url) {
10
+ const readmeContent = readFileSync(file, 'utf8');
11
+ const updatedContent = readmeContent
12
+ .replace(/\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http)(\.?\/)?([^/][^)]+)\)/g, (_match, p1, _p2, p3) => {
13
+ return `[${p1}](${url}/${p3})`;
14
+ })
15
+ .replace(/\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, (_match, p1, _p2, p3) => {
16
+ return `[${p1}](${p3})`;
17
+ });
18
+ writeFileSync(file, updatedContent, 'utf8');
19
+ }
20
+ //# sourceMappingURL=regex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regex.js","sourceRoot":"","sources":["../../src/utils/regex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAErD,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,GAAW;IAC3D,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC9C,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC,gCAAgC,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;QAC9F,OAAO,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,CAAA;IAChC,CAAC,CAAC,CAAA;IACF,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,CAAA;AAC7C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,GAAW;IACzD,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAChD,MAAM,cAAc,GAAG,aAAa;SACjC,OAAO,CAAC,iEAAiE,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE;QAClG,OAAO,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,CAAA;IAChC,CAAC,CAAC;SACD,OAAO,CAAC,8CAA8C,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE;QAC/E,OAAO,IAAI,EAAE,KAAK,EAAE,GAAG,CAAA;IACzB,CAAC,CAAC,CAAA;IACJ,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,CAAA;AAC7C,CAAC"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@tobi-or-not/docpress",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "main": "bin/index.js",
6
+ "types": "types/index.d.ts",
7
+ "bin": {
8
+ "docpress": "bin/docpress.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "dist",
13
+ "types"
14
+ ],
15
+ "engines": {
16
+ "node": ">=20"
17
+ },
18
+ "dependencies": {
19
+ "axios": "^1.7.7",
20
+ "commander": "^12.1.0",
21
+ "octokit": "^4.0.2",
22
+ "rimraf": "^6.0.1",
23
+ "simple-git": "^3.27.0",
24
+ "vitepress": "^1.4.1",
25
+ "yaml": "^2.6.0",
26
+ "zod": "^3.23.8"
27
+ },
28
+ "devDependencies": {
29
+ "@antfu/eslint-config": "^3.8.0",
30
+ "@commitlint/cli": "^19.5.0",
31
+ "@commitlint/config-conventional": "^19.5.0",
32
+ "@types/node": "^22.7.7",
33
+ "eslint": "^9.13.0",
34
+ "husky": "^9.1.6",
35
+ "lint-staged": "^15.2.10",
36
+ "typescript": "^5.6.3",
37
+ "vite": "^5.4.9",
38
+ "vite-node": "^2.1.3"
39
+ },
40
+ "publishConfig": {
41
+ "registry": "https://registry.npmjs.org/",
42
+ "access": "public",
43
+ "tag": "latest"
44
+ },
45
+ "scripts": {
46
+ "build": "tsc",
47
+ "build:clean": "rimraf ./dist ./types ./tsconfig.tsbuildinfo",
48
+ "build:docker": "docker build --tag robots/docpress --target prod .",
49
+ "dev": "vite-node ./dev/index.ts",
50
+ "format": "eslint . --fix",
51
+ "lint": "eslint .",
52
+ "start": "./bin/docpress.js",
53
+ "start:docker": "docker run --publish 8080:8080 --name docpress --rm -v $(pwd)/docpress:/app/docpress:rw robots/docpress",
54
+ "stop:docker": "docker rm --force docpress",
55
+ "test": "echo 'wip'",
56
+ "vp:build": "vitepress build ./docpress",
57
+ "vp:build:docker": "docker build --tag robots/docs --target prod .",
58
+ "vp:dev": "vitepress dev ./docpress --port 8080",
59
+ "vp:dev:docker": "docker run --publish 8080:8080 --rm robots/docs",
60
+ "vp:preview": "vitepress preview ./docpress --port 8080"
61
+ }
62
+ }
@@ -0,0 +1,3 @@
1
+ export declare const buildOpts: never[];
2
+ export declare const buildCmd: import("commander").Command;
3
+ export declare function main(): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import type { Config } from '../schemas/global.js';
2
+ export declare const fetchOpts: import("commander").Option[];
3
+ export declare const fetchCmd: import("commander").Command;
4
+ export declare function main(opts: Config): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare const globalOpts: import("commander").Option[];
@@ -0,0 +1,4 @@
1
+ import type { PrepareOpts } from '../schemas/prepare.js';
2
+ export declare const prepareOpts: import("commander").Option[];
3
+ export declare const prepareCmd: import("commander").Command;
4
+ export declare function main(opts: PrepareOpts): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function main(): void;
@@ -0,0 +1,19 @@
1
+ import type { FetchOpts } from '../schemas/fetch.js';
2
+ import { getInfos } from './git.js';
3
+ export type EnhancedRepository = Awaited<ReturnType<typeof getInfos>>['repos'][number] & {
4
+ docpress: {
5
+ branch: string;
6
+ filtered: boolean;
7
+ includes: string[];
8
+ projectPath: string;
9
+ raw_url: string;
10
+ replace_url: string;
11
+ };
12
+ };
13
+ export declare function checkDoc(repoOwner: FetchOpts['username'], repoName: string, branch: FetchOpts['branch']): Promise<{
14
+ rootReadmeStatus: number;
15
+ docsFolderStatus: number;
16
+ docsReadmeStatus: number;
17
+ }>;
18
+ export declare function fetchDoc({ username, branch, reposFilter, token }: FetchOpts): Promise<void>;
19
+ export declare function isRepoFiltered(repo: EnhancedRepository | Awaited<ReturnType<typeof getInfos>>['repos'][number], reposFilter?: FetchOpts['reposFilter']): boolean;
@@ -0,0 +1,241 @@
1
+ import type { FetchOpts } from '../schemas/fetch.js';
2
+ export declare function getInfos({ username, token, branch }: Pick<FetchOpts, 'username' | 'branch' | 'token'>): Promise<{
3
+ user: {
4
+ login: string;
5
+ id: number;
6
+ node_id: string;
7
+ avatar_url: string;
8
+ gravatar_id: string | null;
9
+ url: string;
10
+ html_url: string;
11
+ followers_url: string;
12
+ following_url: string;
13
+ gists_url: string;
14
+ starred_url: string;
15
+ subscriptions_url: string;
16
+ organizations_url: string;
17
+ repos_url: string;
18
+ events_url: string;
19
+ received_events_url: string;
20
+ type: string;
21
+ site_admin: boolean;
22
+ name: string | null;
23
+ company: string | null;
24
+ blog: string | null;
25
+ location: string | null;
26
+ email: string | null;
27
+ hireable: boolean | null;
28
+ bio: string | null;
29
+ twitter_username?: string | null;
30
+ public_repos: number;
31
+ public_gists: number;
32
+ followers: number;
33
+ following: number;
34
+ created_at: string;
35
+ updated_at: string;
36
+ private_gists: number;
37
+ total_private_repos: number;
38
+ owned_private_repos: number;
39
+ disk_usage: number;
40
+ collaborators: number;
41
+ two_factor_authentication: boolean;
42
+ plan?: {
43
+ collaborators: number;
44
+ name: string;
45
+ space: number;
46
+ private_repos: number;
47
+ };
48
+ suspended_at?: string | null;
49
+ business_plus?: boolean;
50
+ ldap_dn?: string;
51
+ } | {
52
+ login: string;
53
+ id: number;
54
+ node_id: string;
55
+ avatar_url: string;
56
+ gravatar_id: string | null;
57
+ url: string;
58
+ html_url: string;
59
+ followers_url: string;
60
+ following_url: string;
61
+ gists_url: string;
62
+ starred_url: string;
63
+ subscriptions_url: string;
64
+ organizations_url: string;
65
+ repos_url: string;
66
+ events_url: string;
67
+ received_events_url: string;
68
+ type: string;
69
+ site_admin: boolean;
70
+ name: string | null;
71
+ company: string | null;
72
+ blog: string | null;
73
+ location: string | null;
74
+ email: string | null;
75
+ hireable: boolean | null;
76
+ bio: string | null;
77
+ twitter_username?: string | null;
78
+ public_repos: number;
79
+ public_gists: number;
80
+ followers: number;
81
+ following: number;
82
+ created_at: string;
83
+ updated_at: string;
84
+ plan?: {
85
+ collaborators: number;
86
+ name: string;
87
+ space: number;
88
+ private_repos: number;
89
+ };
90
+ suspended_at?: string | null;
91
+ private_gists?: number;
92
+ total_private_repos?: number;
93
+ owned_private_repos?: number;
94
+ disk_usage?: number;
95
+ collaborators?: number;
96
+ };
97
+ repos: {
98
+ id: number;
99
+ node_id: string;
100
+ name: string;
101
+ full_name: string;
102
+ owner: {
103
+ name?: string | null;
104
+ email?: string | null;
105
+ login: string;
106
+ id: number;
107
+ node_id: string;
108
+ avatar_url: string;
109
+ gravatar_id: string | null;
110
+ url: string;
111
+ html_url: string;
112
+ followers_url: string;
113
+ following_url: string;
114
+ gists_url: string;
115
+ starred_url: string;
116
+ subscriptions_url: string;
117
+ organizations_url: string;
118
+ repos_url: string;
119
+ events_url: string;
120
+ received_events_url: string;
121
+ type: string;
122
+ site_admin: boolean;
123
+ starred_at?: string;
124
+ };
125
+ private: boolean;
126
+ html_url: string;
127
+ description: string | null;
128
+ fork: boolean;
129
+ url: string;
130
+ archive_url: string;
131
+ assignees_url: string;
132
+ blobs_url: string;
133
+ branches_url: string;
134
+ collaborators_url: string;
135
+ comments_url: string;
136
+ commits_url: string;
137
+ compare_url: string;
138
+ contents_url: string;
139
+ contributors_url: string;
140
+ deployments_url: string;
141
+ downloads_url: string;
142
+ events_url: string;
143
+ forks_url: string;
144
+ git_commits_url: string;
145
+ git_refs_url: string;
146
+ git_tags_url: string;
147
+ git_url?: string;
148
+ issue_comment_url: string;
149
+ issue_events_url: string;
150
+ issues_url: string;
151
+ keys_url: string;
152
+ labels_url: string;
153
+ languages_url: string;
154
+ merges_url: string;
155
+ milestones_url: string;
156
+ notifications_url: string;
157
+ pulls_url: string;
158
+ releases_url: string;
159
+ ssh_url?: string;
160
+ stargazers_url: string;
161
+ statuses_url: string;
162
+ subscribers_url: string;
163
+ subscription_url: string;
164
+ tags_url: string;
165
+ teams_url: string;
166
+ trees_url: string;
167
+ clone_url?: string;
168
+ mirror_url?: string | null;
169
+ hooks_url: string;
170
+ svn_url?: string;
171
+ homepage?: string | null;
172
+ language?: string | null;
173
+ forks_count?: number;
174
+ stargazers_count?: number;
175
+ watchers_count?: number;
176
+ size?: number;
177
+ default_branch?: string;
178
+ open_issues_count?: number;
179
+ is_template?: boolean;
180
+ topics?: string[];
181
+ has_issues?: boolean;
182
+ has_projects?: boolean;
183
+ has_wiki?: boolean;
184
+ has_pages?: boolean;
185
+ has_downloads?: boolean;
186
+ has_discussions?: boolean;
187
+ archived?: boolean;
188
+ disabled?: boolean;
189
+ visibility?: string;
190
+ pushed_at?: string | null;
191
+ created_at?: string | null;
192
+ updated_at?: string | null;
193
+ permissions?: {
194
+ admin?: boolean;
195
+ maintain?: boolean;
196
+ push?: boolean;
197
+ triage?: boolean;
198
+ pull?: boolean;
199
+ };
200
+ role_name?: string;
201
+ temp_clone_token?: string;
202
+ delete_branch_on_merge?: boolean;
203
+ subscribers_count?: number;
204
+ network_count?: number;
205
+ code_of_conduct?: {
206
+ key: string;
207
+ name: string;
208
+ url: string;
209
+ body?: string;
210
+ html_url: string | null;
211
+ };
212
+ license?: {
213
+ key?: string;
214
+ name?: string;
215
+ spdx_id?: string;
216
+ url?: string;
217
+ node_id?: string;
218
+ } | null;
219
+ forks?: number;
220
+ open_issues?: number;
221
+ watchers?: number;
222
+ allow_forking?: boolean;
223
+ web_commit_signoff_required?: boolean;
224
+ security_and_analysis?: {
225
+ advanced_security?: {
226
+ status?: "enabled" | "disabled";
227
+ };
228
+ dependabot_security_updates?: {
229
+ status?: "enabled" | "disabled";
230
+ };
231
+ secret_scanning?: {
232
+ status?: "enabled" | "disabled";
233
+ };
234
+ secret_scanning_push_protection?: {
235
+ status?: "enabled" | "disabled";
236
+ };
237
+ } | null;
238
+ }[];
239
+ branch: string;
240
+ }>;
241
+ export declare function cloneRepo(url: string, projectDir: string, branch: string, includes: string[]): Promise<void>;
@@ -0,0 +1,55 @@
1
+ import type { defineConfig } from 'vitepress';
2
+ import type { getUserInfos } from '../utils/functions.js';
3
+ import type { EnhancedRepository } from './fetch.js';
4
+ export interface Page {
5
+ text: string;
6
+ link: string;
7
+ }
8
+ export interface SidebarProject {
9
+ text: string;
10
+ collapsed: boolean;
11
+ items: Page[];
12
+ }
13
+ export interface Feature {
14
+ title: string;
15
+ details: string;
16
+ link: string;
17
+ }
18
+ export interface Index {
19
+ layout: string;
20
+ hero: {
21
+ name: string;
22
+ tagline: string;
23
+ };
24
+ features: Feature[];
25
+ }
26
+ export declare function generateIndex(features: Feature[], user: ReturnType<typeof getUserInfos>): {
27
+ layout: string;
28
+ hero: {
29
+ name: string;
30
+ tagline: string;
31
+ };
32
+ features: Feature[];
33
+ };
34
+ export declare function generateFeatures(repoName: string, description: string, features?: Feature[]): Feature[];
35
+ export declare function generateSidebarProject(repoName: string, sidebarPages: Page[]): {
36
+ text: string;
37
+ collapsed: boolean;
38
+ items: Page[];
39
+ };
40
+ export declare function generateSidebarPages(repoName: string, fileName: string, sidebarPages?: Page[]): Page[];
41
+ export declare function transformDoc(repositories: EnhancedRepository[], user: ReturnType<typeof getUserInfos>): {
42
+ sidebar: SidebarProject[];
43
+ index: {
44
+ layout: string;
45
+ hero: {
46
+ name: string;
47
+ tagline: string;
48
+ };
49
+ features: Feature[];
50
+ };
51
+ };
52
+ export declare function addExtraPages(paths: string[]): Page[];
53
+ export declare function addContent(path: string | string[], dir: string, fn?: () => void): void;
54
+ export declare function parseVitepressConfig(path: string): any;
55
+ export declare function generateVitepressFiles(vitepressConfig: Partial<ReturnType<typeof defineConfig>>, index: Index): void;
@@ -0,0 +1,3 @@
1
+ import type { defineConfig } from 'vitepress';
2
+ import type { Page, SidebarProject } from './prepare.js';
3
+ export declare function getVitepressConfig(sidebar: SidebarProject[], nav: Page[], vitepressConfig?: ReturnType<typeof defineConfig>): Partial<ReturnType<typeof defineConfig>>;
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ export declare const buildOptsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
3
+ export type BuildOpts = Zod.infer<typeof buildOptsSchema>;
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export declare const fetchOptsSchema: z.ZodObject<{
3
+ branch: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4
+ gitProvider: z.ZodDefault<z.ZodOptional<z.ZodEnum<["github", "gitlab"]>>>;
5
+ reposFilter: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodString, string[], string>, z.ZodArray<z.ZodString, "many">]>>;
6
+ token: z.ZodOptional<z.ZodString>;
7
+ username: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ branch: string;
10
+ gitProvider: "github" | "gitlab";
11
+ username: string;
12
+ reposFilter?: string[] | undefined;
13
+ token?: string | undefined;
14
+ }, {
15
+ username: string;
16
+ branch?: string | undefined;
17
+ gitProvider?: "github" | "gitlab" | undefined;
18
+ reposFilter?: string | string[] | undefined;
19
+ token?: string | undefined;
20
+ }>;
21
+ export type FetchOpts = Zod.infer<typeof fetchOptsSchema>;