@tobi-or-not/docpress 0.1.6 → 0.1.7
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/README.md +222 -27
- package/dist/cli.js +206 -204
- package/dist/cli.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -4,37 +4,56 @@ This project aims to automate the construction of documentation website based on
|
|
|
4
4
|
|
|
5
5
|
## Explanation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
After downloading all project documentation files, it will build a static website using [vitepress](https://vitepress.dev/).
|
|
7
|
+
Docpress automates the process of downloading documentation files from specified GitHub repositories. Here's how it works:
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
1. __Repository Documentation Retrieval__:
|
|
10
|
+
- The program checks if a `docs/` folder is present at the root level of each specified repository.
|
|
11
|
+
- If the `docs/` folder exists, the entire folder will be downloaded, including all its contents.
|
|
12
|
+
- If the `docs/` folder is not found, only the `README.md` file will be downloaded.
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
2. __Static Website Generation__:
|
|
15
|
+
- After retrieving the documentation files, Docpress generates a static website using [VitePress](https://vitepress.dev/). This framework allows for the creation of fast and customizable documentation sites.
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
- Only the `docs/` root folder in the repository will be parsed to import advanced documentation (multi pages documentation, embed images or files, etc...).
|
|
16
|
-
- The `README.md` root file will only be imported if there is no `./docs/01-readme.md` file (this allows you to manage differences between the readme file and the advanced documentation introduction page, for example using a table of contents in the readme file that makes no sense in the documentation website).
|
|
17
|
-
- Any inline link in the `./README.md` root file that does not point to `./docs/**` will be replaced by the appropriate Github link.
|
|
18
|
-
- Any inline link in the `./docs/*.md` files that does not point to `./docs/**` will be replaced by the appropriate Github link.
|
|
19
|
-
- Each project description on the home page is extracted from the Github repository description.
|
|
17
|
+
For optimal use of Docpress, please check the [rules section](#rules) to understand the conventions and guidelines that will ensure that everything works correctly. By following these rules, you can maximize the effectiveness of the documentation process.
|
|
20
18
|
|
|
21
19
|
## Quickstart
|
|
22
20
|
|
|
23
21
|
Generate website using the Docpress docker image :
|
|
24
22
|
|
|
25
23
|
```sh
|
|
26
|
-
docker run \
|
|
27
|
-
|
|
28
|
-
--name docpress \
|
|
29
|
-
--rm \
|
|
30
|
-
-v $(pwd)/docpress:/app/docpress:rw ghcr.io/this-is-tobi/docpress \
|
|
31
|
-
-u <github_username>
|
|
24
|
+
docker run --name docpress --rm -v $(pwd)/docpress:/app/docpress:rw \
|
|
25
|
+
ghcr.io/this-is-tobi/docpress -u <github_username>
|
|
32
26
|
```
|
|
33
27
|
|
|
34
28
|
The dist folder is available at `./docpress/.vitepress/dist`, ready to be delivered with a web server like Nginx, Apache, etc...
|
|
35
29
|
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
To ensure that the program functions correctly, please follow these conventions:
|
|
33
|
+
|
|
34
|
+
1. __Documentation folder structure__:
|
|
35
|
+
- The script will only parse the `docs/` folder located at the root level of the repository. This folder is used to import advanced documentation features, such as multi-page documentation, embedded images, and files.
|
|
36
|
+
|
|
37
|
+
2. __File naming and sorting__:
|
|
38
|
+
- If a `docs/` folder is present, all files within it will be sorted and renamed by removing any prefix numbers. This ensures that files appear cleanly in the generated website. For example, `docs/01-get-started.md` will be renamed to `get-started.md`.
|
|
39
|
+
|
|
40
|
+
3. __Handling the root readme file__:
|
|
41
|
+
- The `README.md` file located at the root of the repository will only be imported if there is no `./docs/01-readme.md` file present. This allows you to differentiate between the general README and the advanced documentation introduction page.
|
|
42
|
+
- For instance, you might use the README file for a table of contents that is not relevant in the context of the documentation website.
|
|
43
|
+
|
|
44
|
+
4. __Link management__:
|
|
45
|
+
- Any inline link in the `./README.md` file that does not point to `./docs/**` will be replaced with the corresponding GitHub link.
|
|
46
|
+
- Similarly, any inline link in the `./docs/*.md` files that does not reference `./docs/**` will also be replaced with the appropriate GitHub link.
|
|
47
|
+
|
|
48
|
+
5. __Project descriptions__:
|
|
49
|
+
- The project description displayed on the home page of the generated website is extracted from the GitHub repository's description.
|
|
50
|
+
|
|
51
|
+
By adhering to these rules, you can ensure that your documentation is processed correctly and that it aligns with the intended structure and functionality of the generated site.
|
|
52
|
+
|
|
36
53
|
## Advanced usage
|
|
37
54
|
|
|
55
|
+
All CLI options are available with the helper flag `docker run ghcr.io/this-is-tobi/docpress -h` :
|
|
56
|
+
|
|
38
57
|
```txt
|
|
39
58
|
Usage: docpress [options] [command]
|
|
40
59
|
|
|
@@ -44,7 +63,7 @@ Options:
|
|
|
44
63
|
-b, --branch <string> Branch used to collect Git provider data. (default: "main")
|
|
45
64
|
-c, --extra-public-content <string> List of comma separated additional files or directories to process Vitepress public folder.
|
|
46
65
|
-C, --config <string> Path to the docpress configuration file.
|
|
47
|
-
-g, --git-provider <string> Git provider used to retrieve data. Values should be
|
|
66
|
+
-g, --git-provider <string> Git provider used to retrieve data. Values should be "github". (default: "github")
|
|
48
67
|
-h, --help display help for command
|
|
49
68
|
-p, --extra-header-pages <string> List of comma separated additional files or directories to process Vitepress header pages.
|
|
50
69
|
-r, --repos-filter <string> List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories.
|
|
@@ -60,30 +79,206 @@ Commands:
|
|
|
60
79
|
prepare [options] Transform doc to the target vitepress format.
|
|
61
80
|
```
|
|
62
81
|
|
|
82
|
+
### Usage methods
|
|
83
|
+
|
|
84
|
+
Docpress is available through both [npm](https://www.npmjs.com/package/@tobi-or-not/docpress) and [Docker](https://github.com/this-is-tobi/docpress/pkgs/container/docpress), so you can choose the installation method that best suits your environment.
|
|
85
|
+
|
|
86
|
+
#### Using npm (or other package managers)
|
|
87
|
+
|
|
88
|
+
If you prefer Node.js package managers like npm, pnpm, or bun, you can easily install and run Docpress without additional setup.
|
|
89
|
+
|
|
90
|
+
To run Docpress using npm:
|
|
91
|
+
```sh
|
|
92
|
+
npx @tobi-or-not/docpress -u <github_username>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
> [!TIP]
|
|
96
|
+
> If you’re using a package manager like pnpm or bun, simply replace npx with the corresponding command (pnpx or bunx) to execute Docpress.
|
|
97
|
+
|
|
98
|
+
#### Using Docker
|
|
99
|
+
|
|
100
|
+
Docpress also provides a Docker image, which is especially useful if you want to avoid installing dependencies directly on your system or if you’re working in a containerized environment. Using Docker ensures a consistent runtime environment.
|
|
101
|
+
|
|
102
|
+
To run Docpress with Docker:
|
|
103
|
+
```sh
|
|
104
|
+
docker run --rm -v $(pwd)/docpress:/app/docpress:rw ghcr.io/this-is-tobi/docpress -u <github_username>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
In this command:
|
|
108
|
+
- `--rm` removes the container after it stops, keeping your environment clean.
|
|
109
|
+
- `-v $(pwd)/docpress:/app/docpress:rw` mounts the `docpress` directory in your current path to the container’s `/app/docpress` folder, allowing Docpress to store generated files locally.
|
|
110
|
+
|
|
111
|
+
> Ensure Docker is installed and running on your system before using this method.
|
|
112
|
+
|
|
113
|
+
Both methods provide the same functionality, so you can choose the one that fits your setup or use case.
|
|
114
|
+
|
|
115
|
+
### Filter repositories
|
|
116
|
+
|
|
117
|
+
The `-r` or `--repos-filter` option allows you to specify which repositories to include or exclude when generating documentation. This option accepts a comma-separated list of repository names and can include exclusions by prefixing a repository name with `!`.
|
|
118
|
+
|
|
119
|
+
- __Including specific repositories__: To generate documentation for specific repositories, provide their names separated by commas. For example, `-r 'repo1,repo2'` will retrieve documentation only for `repo1` and `repo2`.
|
|
120
|
+
- __Excluding repositories__: To exclude certain repositories, prefix their names with `!`. For instance, `-r '!repo1,!repo2'` will retrieve all public repositories except `repo1` and `repo2`.
|
|
121
|
+
|
|
122
|
+
> Only public, non-fork repositories are fetched.
|
|
123
|
+
|
|
124
|
+
### Docpress configuration
|
|
125
|
+
|
|
126
|
+
Docpress can be configured with an external configuration file specified by the `-C` or `--config` option. This file, which should be in JSON or YAML format, allows you to set Docpress parameters to automate and customize the documentation fetching and generation process. Key options that can be configured include:
|
|
127
|
+
|
|
128
|
+
- `username`: Git provider username (usually GitHub) to fetch repositories (equivalent to the `-u` CLI option).
|
|
129
|
+
- `reposFilter`: List of repositories to include or exclude (equivalent to the `-r` CLI option).
|
|
130
|
+
- `branch`: Default branch from which documentation will be fetched.
|
|
131
|
+
- `extraHeaderPages`: Additional pages to include in the website header (equivalent to `-p`).
|
|
132
|
+
- `extraPublicContent`: Additional content for the Vitepress public folder (equivalent to `-c`).
|
|
133
|
+
- `extraTheme`: Files or folders to customize the Vitepress theme (equivalent to `-t`).
|
|
134
|
+
|
|
135
|
+
Example JSON configuration:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"username": "my-github-username",
|
|
140
|
+
"reposFilter": ["!repo1", "!repo2"],
|
|
141
|
+
"branch": "main",
|
|
142
|
+
"extraHeaderPages": ["header1.md", "header2.md"],
|
|
143
|
+
"extraPublicContent": ["favicon.ico", "logo.png"],
|
|
144
|
+
"extraTheme": ["custom-theme.css"]
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Vitepress configuration
|
|
149
|
+
|
|
150
|
+
Vitepress configuration can be customized via a vitepress.config.js file, specified with the `-v` or `--vitepress-config` option. This file lets you adjust Vitepress options like the site title, navigation structure, footer, and plugins.
|
|
151
|
+
|
|
152
|
+
Key configurable options include:
|
|
153
|
+
|
|
154
|
+
- `title`: The title of the generated site.
|
|
155
|
+
- `description`: A description of the site (used for SEO).
|
|
156
|
+
- `themeConfig`: The theme configuration, including navigation and header links.
|
|
157
|
+
- `markdown`: Options to customize Markdown rendering.
|
|
158
|
+
|
|
159
|
+
Basic Vitepress configuration example:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"title": "My Project Documentation",
|
|
164
|
+
"description": "A site generated by Docpress",
|
|
165
|
+
"themeConfig": {
|
|
166
|
+
"socialLinks": [
|
|
167
|
+
{ "icon": "github", "link": "https://github.com/this-is-tobi" }
|
|
168
|
+
],
|
|
169
|
+
"outline": [2, 4]
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Vitepress theme
|
|
175
|
+
|
|
176
|
+
Docpress allows you to customize the Vitepress theme by adding files or directories specified with the `-t` or `--extra-theme` option. This flexibility enables you to adjust the look and feel of your documentation site by adding custom CSS, modifying components, or even creating an entirely custom theme.
|
|
177
|
+
|
|
178
|
+
You can approach theme customization in two main ways:
|
|
179
|
+
|
|
180
|
+
1. __Extending the Default Theme__:
|
|
181
|
+
Vitepress offers options to extend its built-in default theme, which includes configuration for the layout, sidebar, and header. Extending the default theme is a good choice if you want to make minor tweaks to colors, fonts, or layout without changing the overall structure. To do this, you can:
|
|
182
|
+
- Add custom CSS or SCSS files for style adjustments.
|
|
183
|
+
- Override default theme components to change the behavior of certain sections (like headers or footers).
|
|
184
|
+
- Introduce new Vue components if needed.
|
|
185
|
+
|
|
186
|
+
For more details on extending the default theme, visit the [Vitepress guide on extending the default theme](https://vitepress.dev/guide/extending-default-theme).
|
|
187
|
+
|
|
188
|
+
2. __Creating a Custom Theme__:
|
|
189
|
+
If your project requires a unique design or a complete overhaul of the site layout, you can create a fully custom theme. Vitepress allows you to replace its default theme entirely by creating a custom theme directory structure. With this approach, you gain full control over every part of the site, from page structure to individual components.
|
|
190
|
+
|
|
191
|
+
To implement a custom theme:
|
|
192
|
+
- Create a `theme/index.js` file where you export custom components.
|
|
193
|
+
- Organize components like headers, footers, and layout in the theme directory.
|
|
194
|
+
- Add global styles to `theme/style.css` or other preferred CSS files.
|
|
195
|
+
|
|
196
|
+
For a comprehensive guide on creating a custom theme, refer to the [Vitepress documentation on using a custom theme](https://vitepress.dev/guide/custom-theme#using-a-custom-theme).
|
|
197
|
+
|
|
198
|
+
> For either method, keep in mind that customizations should be tested across different pages to ensure they integrate smoothly with your content.
|
|
199
|
+
|
|
200
|
+
With these approaches, you can create a distinct look and feel for your documentation site while keeping it aligned with your project’s branding and user experience requirements.
|
|
201
|
+
|
|
202
|
+
### Extra header pages
|
|
203
|
+
|
|
204
|
+
With the `-p` or `--extra-header-pages` option, you can add additional pages to the Vitepress website header, such as privacy policies, advanced user guides, or links to external resources.
|
|
205
|
+
|
|
206
|
+
This option accepts a comma-separated list of Markdown files or directories containing Markdown files. These pages will be included as-is in the final website and automatically added to the navigation bar at the top of each page on the generated site.
|
|
207
|
+
|
|
208
|
+
> All specified extra-header-pages must be in Markdown format and can include any Vitepress-compatible content, such as links, images, and other documentation elements.
|
|
209
|
+
|
|
210
|
+
### Extra public content
|
|
211
|
+
|
|
212
|
+
The `-c` or `--extra-public-content` option allows you to include additional static assets in the Vitepress `public` folder. This is useful for adding content that needs to be accessible across all pages of the documentation, such as custom icons, logos, or other assets.
|
|
213
|
+
|
|
214
|
+
These files or directories will be copied directly into the `public` folder and will be available as static resources on the final website.
|
|
215
|
+
|
|
216
|
+
Common use cases for `extra-public-content` include:
|
|
217
|
+
- __Adding branding assets__: For example, including a custom favicon (`favicon.ico`) or logo (`logo.png`) that will display on every page.
|
|
218
|
+
- __Providing downloadable files__: Such as PDF guides, policy documents, or downloadable images that users may need quick access to.
|
|
219
|
+
- __Supplementing media files__: Including additional images, icons, or background files that you may want to reference across different parts of your documentation.
|
|
220
|
+
|
|
221
|
+
This option accepts a comma-separated list of file or directory paths.
|
|
222
|
+
|
|
223
|
+
> Ensure that any files you add are optimized for the web, as large or uncompressed files may impact site performance.
|
|
224
|
+
|
|
225
|
+
> All files and directories specified with extra-public-content are directly accessible at the root of the final site, making it easy to link to them within your Markdown files (e.g., using /logo.png in an img tag).
|
|
226
|
+
|
|
227
|
+
### GitHub Token Option
|
|
228
|
+
|
|
229
|
+
When using the Docpress tool to fetch data from GitHub, you have the option to provide a personal access token using the `-T` flag. This token is important as it allows you to authenticate your requests, which can help increase your request limits on the GitHub API.
|
|
230
|
+
|
|
231
|
+
Utilizing a personal access token not only helps you avoid rate limiting issues but also enhances the reliability of data retrieval for your documentation projects.
|
|
232
|
+
|
|
233
|
+
For further details on how authentication affects rate limits and other considerations, please refer to the official GitHub documentation on [Rate limits for the REST API](https://docs.github.com/en/rest/overview/rate-limits-for-the-rest-api).
|
|
234
|
+
|
|
63
235
|
## Development
|
|
64
236
|
|
|
65
237
|
### Prerequisites
|
|
66
238
|
|
|
67
|
-
To run the application in development mode, install :
|
|
68
|
-
|
|
69
|
-
- [
|
|
239
|
+
To successfully run the Docpress application in development mode, you'll need to install the following prerequisites:
|
|
240
|
+
|
|
241
|
+
- __[Node.js](https://nodejs.org/)__: A JavaScript runtime that allows you to execute JavaScript code server-side. Make sure you install a version that is compatible with the project requirements.
|
|
242
|
+
- __[pnpm](https://pnpm.io/)__: A fast, disk space-efficient package manager for Node.js that is used to manage the project's dependencies.
|
|
70
243
|
|
|
71
|
-
###
|
|
244
|
+
### Setting Up the Development Environment
|
|
72
245
|
|
|
73
|
-
|
|
246
|
+
Follow these steps to set up the development environment and start working with Docpress:
|
|
247
|
+
|
|
248
|
+
1. __Clone the repository__
|
|
249
|
+
Start by cloning the Docpress repository to your local machine using Git:
|
|
250
|
+
```sh
|
|
251
|
+
git clone https://github.com/this-is-tobi/docpress.git
|
|
252
|
+
cd docpress
|
|
253
|
+
```
|
|
254
|
+
2. __Install project dependencies__
|
|
255
|
+
Use pnpm to install all necessary Node.js dependencies:
|
|
74
256
|
```sh
|
|
75
257
|
pnpm install
|
|
76
258
|
```
|
|
77
|
-
|
|
259
|
+
3. __Fetch and build the website__
|
|
260
|
+
Run the following command to fetch documentation from the specified GitHub username and build the static website:
|
|
78
261
|
```sh
|
|
79
|
-
pnpm run dev -u <
|
|
262
|
+
pnpm run dev -u <github_username>
|
|
80
263
|
```
|
|
81
|
-
|
|
264
|
+
4. __Preview the website__
|
|
265
|
+
Launch a local development server to preview your website:
|
|
82
266
|
```sh
|
|
83
267
|
pnpm run vp:dev
|
|
84
268
|
```
|
|
85
|
-
|
|
86
|
-
Preview website is available at <http://localhost:8080>.
|
|
269
|
+
You can access the preview by navigating to [http://localhost:8080](http://localhost:8080) in your web browser.
|
|
87
270
|
|
|
88
271
|
> [!TIP]
|
|
89
272
|
> Use command `pnpm run dev -h` to print options.
|
|
273
|
+
|
|
274
|
+
## Contributions
|
|
275
|
+
|
|
276
|
+
All contributions to my repositories are welcome and must be made via Github with a pull request following the rules below.
|
|
277
|
+
|
|
278
|
+
### Conventions
|
|
279
|
+
|
|
280
|
+
Commits must follow the specification of [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), it is possible to add the [VSCode extension](https://github.com/vivaxy/vscode-conventional-commits) to facilitate the creation of commits.
|
|
281
|
+
|
|
282
|
+
A PR must be made with an updated branch with the `main` branch in rebase (and without merge) before requesting a merge, and the merge must be requested in `main`.
|
|
283
|
+
|
|
284
|
+
Check whether the repository has linting rules or tests to keep them clean and ensure that CI workflows pass (new features in repositories with tests should be accompanied by new tests to ensure that the new feature works properly).
|
package/dist/cli.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { createOption as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { createOption as u, createCommand as D, Command as ce } from "commander";
|
|
2
|
+
import { fromError as ae } from "zod-validation-error";
|
|
3
|
+
import { readFileSync as y, existsSync as N, mkdirSync as de, readdirSync as J, statSync as E, appendFileSync as B, cpSync as F, rmSync as L, writeFileSync as v, renameSync as pe } from "node:fs";
|
|
4
|
+
import { resolve as i, join as le, basename as m, dirname as H, parse as S } from "node:path";
|
|
4
5
|
import { z as d } from "zod";
|
|
5
|
-
import
|
|
6
|
-
import { rimrafSync as
|
|
7
|
-
import { Octokit as
|
|
8
|
-
import { simpleGit as
|
|
9
|
-
import { build as
|
|
10
|
-
import
|
|
11
|
-
const
|
|
6
|
+
import ue from "axios";
|
|
7
|
+
import { rimrafSync as fe } from "rimraf";
|
|
8
|
+
import { Octokit as me } from "octokit";
|
|
9
|
+
import { simpleGit as ge } from "simple-git";
|
|
10
|
+
import { build as he } from "vitepress";
|
|
11
|
+
import be from "yaml";
|
|
12
|
+
const ve = "@tobi-or-not/docpress", ye = "module", we = "0.1.7", Se = "pnpm@9.12.3", $e = "dist/docpress.js", Ce = "types/index.d.ts", xe = {
|
|
12
13
|
docpress: "bin/docpress.js"
|
|
13
|
-
},
|
|
14
|
+
}, ke = [
|
|
14
15
|
"bin",
|
|
15
16
|
"dist",
|
|
16
17
|
"types"
|
|
17
|
-
],
|
|
18
|
+
], _e = {
|
|
18
19
|
node: ">=20"
|
|
19
|
-
},
|
|
20
|
+
}, Pe = {
|
|
20
21
|
build: "pnpm run build:types && pnpm run build:vite",
|
|
21
22
|
"build:clean": "rimraf ./dist ./types ./tsconfig.tsbuildinfo",
|
|
22
23
|
"build:docker": "docker build --tag tobi-or-not/docpress --target prod .",
|
|
23
24
|
"build:types": "tsc",
|
|
24
25
|
"build:vite": "vite build",
|
|
25
|
-
dev: "vite-node ./dev/docpress.ts",
|
|
26
|
+
dev: "rimraf ./docpress && vite-node ./dev/docpress.ts",
|
|
26
27
|
format: "eslint . --fix",
|
|
27
28
|
lint: "eslint .",
|
|
28
29
|
prepare: "husky",
|
|
@@ -36,7 +37,7 @@ const he = "@tobi-or-not/docpress", be = "module", ve = "0.1.6", ye = "pnpm@9.12
|
|
|
36
37
|
"vp:dev": "vitepress dev ./docpress --port 8080",
|
|
37
38
|
"vp:dev:docker": "docker run --publish 8080:8080 --name docpress-vp --rm tobi-or-not/docs",
|
|
38
39
|
"vp:preview": "vitepress preview ./docpress --port 8080"
|
|
39
|
-
},
|
|
40
|
+
}, Oe = {
|
|
40
41
|
axios: "^1.7.7",
|
|
41
42
|
commander: "^12.1.0",
|
|
42
43
|
octokit: "^4.0.2",
|
|
@@ -44,8 +45,9 @@ const he = "@tobi-or-not/docpress", be = "module", ve = "0.1.6", ye = "pnpm@9.12
|
|
|
44
45
|
"simple-git": "^3.27.0",
|
|
45
46
|
vitepress: "^1.4.1",
|
|
46
47
|
yaml: "^2.6.0",
|
|
47
|
-
zod: "^3.23.8"
|
|
48
|
-
|
|
48
|
+
zod: "^3.23.8",
|
|
49
|
+
"zod-validation-error": "^3.4.0"
|
|
50
|
+
}, Re = {
|
|
49
51
|
"@antfu/eslint-config": "^3.8.0",
|
|
50
52
|
"@commitlint/cli": "^19.5.0",
|
|
51
53
|
"@commitlint/config-conventional": "^19.5.0",
|
|
@@ -58,28 +60,28 @@ const he = "@tobi-or-not/docpress", be = "module", ve = "0.1.6", ye = "pnpm@9.12
|
|
|
58
60
|
vite: "^5.4.9",
|
|
59
61
|
"vite-node": "^2.1.3",
|
|
60
62
|
vitest: "^2.1.3"
|
|
61
|
-
},
|
|
63
|
+
}, De = {
|
|
62
64
|
registry: "https://registry.npmjs.org/",
|
|
63
65
|
access: "public",
|
|
64
66
|
tag: "latest"
|
|
65
|
-
},
|
|
66
|
-
name:
|
|
67
|
-
type:
|
|
68
|
-
version:
|
|
69
|
-
packageManager:
|
|
70
|
-
module:
|
|
71
|
-
types:
|
|
72
|
-
bin:
|
|
73
|
-
files:
|
|
74
|
-
engines:
|
|
75
|
-
scripts:
|
|
76
|
-
dependencies:
|
|
77
|
-
devDependencies:
|
|
78
|
-
publishConfig:
|
|
79
|
-
},
|
|
67
|
+
}, Ee = {
|
|
68
|
+
name: ve,
|
|
69
|
+
type: ye,
|
|
70
|
+
version: we,
|
|
71
|
+
packageManager: Se,
|
|
72
|
+
module: $e,
|
|
73
|
+
types: Ce,
|
|
74
|
+
bin: xe,
|
|
75
|
+
files: ke,
|
|
76
|
+
engines: _e,
|
|
77
|
+
scripts: Pe,
|
|
78
|
+
dependencies: Oe,
|
|
79
|
+
devDependencies: Re,
|
|
80
|
+
publishConfig: De
|
|
81
|
+
}, W = d.object({}), x = i(process.cwd(), "docpress"), q = i(process.cwd(), "docpress/repositories.json"), X = i(process.cwd(), "docpress/owner.json"), Y = i(process.cwd(), "docpress/docs"), Fe = i(process.cwd(), "docpress/docs/index.md"), V = i(process.cwd(), "docpress/.vitepress/config.ts");
|
|
80
82
|
async function P(e) {
|
|
81
83
|
try {
|
|
82
|
-
return (await
|
|
84
|
+
return (await ue.head(e)).status;
|
|
83
85
|
} catch (t) {
|
|
84
86
|
return t.response?.status || t.status || 500;
|
|
85
87
|
}
|
|
@@ -88,46 +90,54 @@ function h(e, t) {
|
|
|
88
90
|
let s = "";
|
|
89
91
|
return t?.removeIdx && (s = e.replace(/^\d{2}-/, "")), t?.replaceDash && (s = (s || e).replaceAll("-", " ")), t?.mode === "capitalize" ? s = (s || e).slice(0, 1).toUpperCase() + (s || e).slice(1).toLowerCase() : t?.mode === "lowercase" ? s = (s || e).toLowerCase() : t?.mode === "uppercase" && (s = (s || e).toUpperCase()), s || e;
|
|
90
92
|
}
|
|
91
|
-
function
|
|
93
|
+
function j(e, { clean: t } = { clean: !1 }) {
|
|
92
94
|
try {
|
|
93
|
-
t &&
|
|
95
|
+
t && N(e) && fe(`${e}/*`, { glob: !0 }), N(e) || de(e, { recursive: !0 });
|
|
94
96
|
} catch (s) {
|
|
95
97
|
console.error(s);
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
+
function je(e) {
|
|
101
|
+
try {
|
|
102
|
+
return E(e).isDirectory();
|
|
103
|
+
} catch {
|
|
104
|
+
return !1;
|
|
105
|
+
}
|
|
100
106
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
107
|
+
function Ie(e) {
|
|
108
|
+
try {
|
|
109
|
+
return E(e).isFile();
|
|
110
|
+
} catch {
|
|
111
|
+
return !1;
|
|
112
|
+
}
|
|
103
113
|
}
|
|
104
|
-
function
|
|
105
|
-
return (Array.isArray(e) ? e : [e]).flatMap((t) =>
|
|
114
|
+
function I(e) {
|
|
115
|
+
return (Array.isArray(e) ? e : [e]).flatMap((t) => Ie(t) ? [t] : je(t) ? J(t).flatMap((s) => I(le(t, s))) : []);
|
|
106
116
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
117
|
+
function K(e) {
|
|
118
|
+
return I(e).filter((t) => m(t).endsWith(".md"));
|
|
109
119
|
}
|
|
110
|
-
function
|
|
111
|
-
return e.reduce((t, s,
|
|
120
|
+
function Te(e) {
|
|
121
|
+
return e.reduce((t, s, n, o) => n ? n === o.length - 1 ? `${t} or "${s}"` : `${t}, "${s}"` : `"${s}"`, "");
|
|
112
122
|
}
|
|
113
|
-
function
|
|
114
|
-
return JSON.parse(y(
|
|
123
|
+
function Ne() {
|
|
124
|
+
return JSON.parse(y(X).toString());
|
|
115
125
|
}
|
|
116
|
-
function
|
|
117
|
-
return JSON.parse(y(
|
|
126
|
+
function Le() {
|
|
127
|
+
return JSON.parse(y(q).toString());
|
|
118
128
|
}
|
|
119
|
-
function
|
|
120
|
-
return e.reduce((t, s) => (s === null || Object.keys(s).forEach((
|
|
121
|
-
const
|
|
122
|
-
|
|
129
|
+
function R(...e) {
|
|
130
|
+
return e.reduce((t, s) => (s === null || Object.keys(s).forEach((n) => {
|
|
131
|
+
const o = t ? t[n] : null, r = s[n];
|
|
132
|
+
A(o) && A(r) ? t[n] = R(o, r) : t[n] = r;
|
|
123
133
|
}), t), {});
|
|
124
134
|
}
|
|
125
|
-
function
|
|
135
|
+
function A(e) {
|
|
126
136
|
return e && typeof e == "object" && !Array.isArray(e);
|
|
127
137
|
}
|
|
128
|
-
const
|
|
138
|
+
const U = ["github"], f = d.object({
|
|
129
139
|
branch: d.string().describe("Branch used to collect Git provider data.").optional().default("main"),
|
|
130
|
-
gitProvider: d.enum(
|
|
140
|
+
gitProvider: d.enum(U).describe(`Git provider used to retrieve data. Values should be ${Te(U)}.`).optional().default("github"),
|
|
131
141
|
reposFilter: d.string().transform((e) => e.split(",")).or(d.string().array()).describe("List of comma separated repositories to retrieve from Git provider. Default to all user's public repositories.").optional(),
|
|
132
142
|
token: d.string().describe("Git provider token used to collect data.").optional(),
|
|
133
143
|
username: d.string().describe("Git provider username used to collect data.")
|
|
@@ -136,120 +146,120 @@ const A = ["github"], f = d.object({
|
|
|
136
146
|
extraPublicContent: d.string().describe("List of comma separated additional files or directories to process Vitepress public folder.").transform((e) => e.split(",")).optional(),
|
|
137
147
|
extraTheme: d.string().describe("List of comma separated additional files or directories to use as Vitepress theme.").transform((e) => e.split(",")).optional(),
|
|
138
148
|
vitepressConfig: d.string().describe("Path to the vitepress configuration file.").transform((e) => JSON.parse(y(i(process.cwd(), e)).toString())).optional()
|
|
139
|
-
}),
|
|
149
|
+
}), T = d.object({
|
|
140
150
|
config: d.string().describe("Path to the docpress configuration file.").transform((e) => JSON.parse(y(i(process.cwd(), e)).toString())).optional()
|
|
141
151
|
});
|
|
142
|
-
f.merge(b).merge(
|
|
143
|
-
const
|
|
144
|
-
build:
|
|
152
|
+
f.merge(b).merge(W);
|
|
153
|
+
const Ve = {
|
|
154
|
+
build: W,
|
|
145
155
|
fetch: f,
|
|
146
156
|
prepare: b,
|
|
147
|
-
global:
|
|
157
|
+
global: T
|
|
148
158
|
};
|
|
149
|
-
function
|
|
150
|
-
const s =
|
|
151
|
-
...
|
|
159
|
+
function Q(e, t) {
|
|
160
|
+
const s = Ve[e].safeParse({
|
|
161
|
+
...T.parse(t).config,
|
|
152
162
|
...t
|
|
153
163
|
});
|
|
154
164
|
if (s.success)
|
|
155
165
|
return s.data;
|
|
156
|
-
|
|
166
|
+
console.error(ae(s.error).toString()), process.exit(0);
|
|
157
167
|
}
|
|
158
168
|
function k(e, t) {
|
|
159
169
|
return t.forEach((s) => e.addOption(s)), e;
|
|
160
170
|
}
|
|
161
|
-
async function
|
|
162
|
-
const
|
|
163
|
-
return { user:
|
|
171
|
+
async function Ae({ username: e, token: t, branch: s }) {
|
|
172
|
+
const n = new me({ auth: t }), { data: o } = await n.request("GET /users/{username}", { username: e }), { data: r } = await n.request("GET /users/{username}/repos", { username: e, sort: "full_name" });
|
|
173
|
+
return { user: o, repos: r, branch: s };
|
|
164
174
|
}
|
|
165
|
-
async function
|
|
166
|
-
|
|
175
|
+
async function Ue(e, t, s, n) {
|
|
176
|
+
j(t, { clean: !0 });
|
|
167
177
|
try {
|
|
168
|
-
const
|
|
169
|
-
await
|
|
170
|
-
for (const r of
|
|
171
|
-
|
|
178
|
+
const o = ge({ baseDir: t });
|
|
179
|
+
await o.init().addConfig("core.sparseCheckout", "true", !0, "local").addRemote("origin", e);
|
|
180
|
+
for (const r of n)
|
|
181
|
+
B(i(t, ".git/info/sparse-checkout"), `${r}
|
|
172
182
|
`, "utf8");
|
|
173
|
-
await
|
|
174
|
-
} catch (
|
|
175
|
-
console.error(
|
|
183
|
+
await o.pull("origin", s), n.some((r) => r.includes("docs")) && (F(i(t, "docs"), t, { recursive: !0 }), L(i(t, "docs"), { recursive: !0 })), L(i(t, ".git"), { recursive: !0 });
|
|
184
|
+
} catch (o) {
|
|
185
|
+
console.error(o);
|
|
176
186
|
}
|
|
177
187
|
}
|
|
178
|
-
async function
|
|
179
|
-
const
|
|
188
|
+
async function Ge(e, t, s) {
|
|
189
|
+
const n = `https://github.com/${e}/${t}/tree/${s}/README.md`, o = `https://github.com/${e}/${t}/tree/${s}/docs`, r = `https://github.com/${e}/${t}/tree/${s}/docs/01-readme.md`, a = await P(n), c = await P(o), l = await P(r);
|
|
180
190
|
return {
|
|
181
191
|
rootReadmeStatus: a,
|
|
182
192
|
docsFolderStatus: c,
|
|
183
|
-
docsReadmeStatus:
|
|
193
|
+
docsReadmeStatus: l
|
|
184
194
|
};
|
|
185
195
|
}
|
|
186
|
-
async function
|
|
187
|
-
|
|
196
|
+
async function Me({ username: e, branch: t, reposFilter: s, token: n }) {
|
|
197
|
+
j(x, { clean: !0 }), await Ae({ username: e, token: n, branch: t }).then(async ({ user: o, repos: r, branch: a }) => Be(o, r, a, s)).then(async ({ repos: o }) => He(o, s));
|
|
188
198
|
}
|
|
189
|
-
async function
|
|
190
|
-
const
|
|
199
|
+
async function ze(e, t, s) {
|
|
200
|
+
const n = [];
|
|
191
201
|
return await Promise.all(
|
|
192
|
-
e.map(async (
|
|
193
|
-
const r = t ??
|
|
194
|
-
let
|
|
195
|
-
!
|
|
196
|
-
...
|
|
202
|
+
e.map(async (o) => {
|
|
203
|
+
const r = t ?? o.default_branch ?? "main", a = i(Y, o.name), c = Z(o, s);
|
|
204
|
+
let l = [];
|
|
205
|
+
!o.fork && !o.private && !c && (l = await Je(o, r)), n.push({
|
|
206
|
+
...o,
|
|
197
207
|
docpress: {
|
|
198
208
|
filtered: c,
|
|
199
209
|
branch: r,
|
|
200
|
-
includes:
|
|
210
|
+
includes: l,
|
|
201
211
|
projectPath: a,
|
|
202
|
-
raw_url: `https://raw.githubusercontent.com/${
|
|
203
|
-
replace_url: `https://github.com/${
|
|
212
|
+
raw_url: `https://raw.githubusercontent.com/${o.owner.login}/${o.name}/${r}`,
|
|
213
|
+
replace_url: `https://github.com/${o.owner.login}/${o.name}/tree/${r}`
|
|
204
214
|
}
|
|
205
215
|
});
|
|
206
216
|
})
|
|
207
|
-
),
|
|
217
|
+
), n;
|
|
208
218
|
}
|
|
209
|
-
async function
|
|
210
|
-
const s = await
|
|
211
|
-
return Object.values(s).every((
|
|
219
|
+
async function Je(e, t) {
|
|
220
|
+
const s = await Ge(e.owner.login, e.name, t), n = [];
|
|
221
|
+
return Object.values(s).every((o) => o === 404) || !e.size ? [] : (s.docsFolderStatus !== 404 && n.push("docs/*"), (s.docsFolderStatus === 404 || s.docsReadmeStatus === 404) && n.push("README.md", "!*/**/README.md"), n);
|
|
212
222
|
}
|
|
213
|
-
async function
|
|
214
|
-
v(
|
|
215
|
-
const
|
|
216
|
-
return v(
|
|
223
|
+
async function Be(e, t, s, n) {
|
|
224
|
+
v(X, JSON.stringify(e, null, 2));
|
|
225
|
+
const o = await ze(t, s, n);
|
|
226
|
+
return v(q, JSON.stringify(o, null, 2)), { user: e, repos: o };
|
|
217
227
|
}
|
|
218
|
-
async function
|
|
228
|
+
async function He(e, t) {
|
|
219
229
|
if (!e) {
|
|
220
230
|
console.warn("No repository respect docpress rules.");
|
|
221
231
|
return;
|
|
222
232
|
}
|
|
223
233
|
await Promise.all(
|
|
224
|
-
e.filter((s) => !
|
|
234
|
+
e.filter((s) => !Z(s, t)).map(async (s) => Ue(s.clone_url, s.docpress.projectPath, s.docpress.branch, s.docpress.includes))
|
|
225
235
|
);
|
|
226
236
|
}
|
|
227
|
-
function
|
|
228
|
-
const s = t?.filter((r) => r.startsWith("!")).some((r) => e.name === r.substring(1)),
|
|
229
|
-
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.fork && !e.private && !
|
|
237
|
+
function Z(e, t) {
|
|
238
|
+
const s = t?.filter((r) => r.startsWith("!")).some((r) => e.name === r.substring(1)), n = !t || t?.filter((r) => !r.startsWith("!")).includes(e.name), o = s || !n;
|
|
239
|
+
return "docpress" in e && !e.docpress.includes.length ? !0 : !(e.clone_url && !e.fork && !e.private && !o);
|
|
230
240
|
}
|
|
231
241
|
const _ = [
|
|
232
|
-
|
|
233
|
-
],
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
],
|
|
240
|
-
await
|
|
242
|
+
u("-C, --config <string>", T.shape.config._def.description)
|
|
243
|
+
], ee = "fetch", te = [
|
|
244
|
+
u("-b, --branch <string>", f.shape.branch._def.description).default(f.shape.branch._def.defaultValue()),
|
|
245
|
+
u("-g, --git-provider <string>", f.shape.gitProvider._def.description).default(f.shape.gitProvider._def.defaultValue()),
|
|
246
|
+
u("-r, --repos-filter <string>", f.shape.reposFilter._def.description),
|
|
247
|
+
u("-T, --token <string>", f.shape.token._def.description),
|
|
248
|
+
u("-u, --username <string>", f.shape.username._def.description)
|
|
249
|
+
], We = k(D(ee), [...te, ..._]).description("Fetch docs with the given username and git provider.").action(async (e) => {
|
|
250
|
+
await se(e);
|
|
241
251
|
});
|
|
242
|
-
async function
|
|
243
|
-
const { username: t, reposFilter: s, token:
|
|
244
|
-
await
|
|
252
|
+
async function se(e) {
|
|
253
|
+
const { username: t, reposFilter: s, token: n, branch: o, gitProvider: r } = Q(ee, e);
|
|
254
|
+
await Me({ username: t, branch: o, reposFilter: s, gitProvider: r, token: n });
|
|
245
255
|
}
|
|
246
|
-
const
|
|
247
|
-
await
|
|
256
|
+
const qe = "build", Xe = k(D(qe), _).description("Build vitepress website.").action(async (e) => {
|
|
257
|
+
await re();
|
|
248
258
|
});
|
|
249
|
-
async function
|
|
250
|
-
await
|
|
259
|
+
async function re() {
|
|
260
|
+
await he(x);
|
|
251
261
|
}
|
|
252
|
-
const
|
|
262
|
+
const G = {
|
|
253
263
|
base: "/",
|
|
254
264
|
lang: "en-US",
|
|
255
265
|
vite: {
|
|
@@ -258,7 +268,7 @@ const qe = {
|
|
|
258
268
|
title: "Home",
|
|
259
269
|
description: "Docpress",
|
|
260
270
|
srcDir: "./docs",
|
|
261
|
-
cleanUrls: !
|
|
271
|
+
cleanUrls: !1,
|
|
262
272
|
ignoreDeadLinks: "localhostLinks",
|
|
263
273
|
themeConfig: {
|
|
264
274
|
outline: [2, 3],
|
|
@@ -286,54 +296,46 @@ const qe = {
|
|
|
286
296
|
}
|
|
287
297
|
}
|
|
288
298
|
};
|
|
289
|
-
function
|
|
290
|
-
|
|
291
|
-
return {
|
|
292
|
-
...o,
|
|
293
|
-
themeConfig: {
|
|
294
|
-
...o.themeConfig,
|
|
295
|
-
sidebar: e,
|
|
296
|
-
nav: t
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
function Ye(e, t) {
|
|
301
|
-
const o = y(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (n, r, a) => `[${r}](${t}/${a})`);
|
|
302
|
-
v(e, o, "utf8");
|
|
299
|
+
function Ye(e, t, s) {
|
|
300
|
+
return s ? R(G, s, { themeConfig: { sidebar: e, nav: t } }) : R(G, { themeConfig: { sidebar: e, nav: t } });
|
|
303
301
|
}
|
|
304
302
|
function Ke(e, t) {
|
|
305
|
-
const
|
|
306
|
-
v(e,
|
|
303
|
+
const n = y(e, "utf8").replace(/\[([^\]]+)\]\(\.\.\/([^)]+)\)/g, (o, r, a) => `[${r}](${t}/${a})`);
|
|
304
|
+
v(e, n, "utf8");
|
|
305
|
+
}
|
|
306
|
+
function Qe(e, t) {
|
|
307
|
+
const n = y(e, "utf8").replace(/\[([^\]]+)\]\((?!\.?\/docs\/|docs\/|http)(\.?\/)?([^/][^)]+)\)/g, (o, r, a, c) => `[${r}](${t}/${c})`).replace(/\[([^\]]+)\]\((\.?\/docs\/|docs\/)([^)]*)\)/g, (o, r, a, c) => `[${r}](${c})`);
|
|
308
|
+
v(e, n, "utf8");
|
|
307
309
|
}
|
|
308
|
-
function
|
|
309
|
-
const
|
|
310
|
+
function M(e, t) {
|
|
311
|
+
const o = `${m(t) === "readme.md" ? `
|
|
310
312
|
## Sources` : "# Sources"}
|
|
311
313
|
|
|
312
314
|
Take a look at the [project sources](${e}).
|
|
313
315
|
`;
|
|
314
|
-
|
|
316
|
+
B(t, o, "utf8");
|
|
315
317
|
}
|
|
316
|
-
function
|
|
317
|
-
const { name: s, login:
|
|
318
|
+
function Ze(e, t) {
|
|
319
|
+
const { name: s, login: n, bio: o } = t;
|
|
318
320
|
return {
|
|
319
321
|
layout: "home",
|
|
320
322
|
hero: {
|
|
321
|
-
name: s ? `${s}'s projects` : `${
|
|
322
|
-
tagline:
|
|
323
|
+
name: s ? `${s}'s projects` : `${n}'s projects`,
|
|
324
|
+
tagline: o ?? "Robots are everywhere 🤖"
|
|
323
325
|
// \U0001F916
|
|
324
326
|
},
|
|
325
327
|
features: e
|
|
326
328
|
};
|
|
327
329
|
}
|
|
328
|
-
function
|
|
329
|
-
const
|
|
330
|
+
function et(e, t, s) {
|
|
331
|
+
const n = {
|
|
330
332
|
title: h(e, { mode: "capitalize", replaceDash: !0 }),
|
|
331
333
|
details: t,
|
|
332
334
|
link: `/${e}/readme`
|
|
333
335
|
};
|
|
334
|
-
return s ? [...s,
|
|
336
|
+
return s ? [...s, n] : [n];
|
|
335
337
|
}
|
|
336
|
-
function
|
|
338
|
+
function tt(e, t) {
|
|
337
339
|
return {
|
|
338
340
|
text: h(e, { mode: "capitalize", replaceDash: !0 }),
|
|
339
341
|
collapsed: !0,
|
|
@@ -341,92 +343,92 @@ function et(e, t) {
|
|
|
341
343
|
};
|
|
342
344
|
}
|
|
343
345
|
function O(e, t, s) {
|
|
344
|
-
const
|
|
346
|
+
const n = {
|
|
345
347
|
text: t === "readme" ? "Introduction" : h(t, { mode: "capitalize", replaceDash: !0 }),
|
|
346
348
|
link: `/${e}/${t}`
|
|
347
349
|
};
|
|
348
|
-
return s ? [...s,
|
|
350
|
+
return s ? [...s, n] : [n];
|
|
349
351
|
}
|
|
350
|
-
function
|
|
351
|
-
const s = [],
|
|
352
|
+
function st(e, t) {
|
|
353
|
+
const s = [], n = [];
|
|
352
354
|
for (const r of e) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
+
K([r.docpress.projectPath]).forEach((c) => {
|
|
356
|
+
Ke(c, `https://github.com/${r.owner.login}/${r.name}/tree/${r.docpress.branch}`), m(c).toLowerCase() === "readme.md" && Qe(c, `https://github.com/${r.owner.login}/${r.name}/tree/${r.docpress.branch}`);
|
|
355
357
|
});
|
|
356
|
-
const a =
|
|
357
|
-
const g = i(r.docpress.projectPath,
|
|
358
|
-
if (p !== m(g) &&
|
|
358
|
+
const a = J(r.docpress.projectPath).filter((c) => E(i(r.docpress.projectPath, c)).isFile() && m(i(r.docpress.projectPath, c)).endsWith(".md")).sort((c, l) => c.localeCompare(l)).reduce((c, l, $, C) => {
|
|
359
|
+
const g = i(r.docpress.projectPath, l), p = h(m(g), { mode: "lowercase", removeIdx: !0 });
|
|
360
|
+
if (p !== m(g) && pe(g, i(H(g), p)), $ === C.length - 1) {
|
|
359
361
|
let w;
|
|
360
362
|
if (C.length > 1)
|
|
361
|
-
return w = i(r.docpress.projectPath, "sources.md"),
|
|
363
|
+
return w = i(r.docpress.projectPath, "sources.md"), M(r.html_url, w), O(
|
|
362
364
|
r.name,
|
|
363
365
|
S(w).name,
|
|
364
366
|
O(r.name, S(p).name, c)
|
|
365
367
|
);
|
|
366
|
-
w = i(r.docpress.projectPath, "readme.md"),
|
|
368
|
+
w = i(r.docpress.projectPath, "readme.md"), M(r.html_url, w);
|
|
367
369
|
}
|
|
368
370
|
return O(r.name, S(p).name, c);
|
|
369
371
|
}, []);
|
|
370
|
-
|
|
372
|
+
n.push(tt(r.name, a)), s.push(...et(r.name, r.description || ""));
|
|
371
373
|
}
|
|
372
|
-
const
|
|
374
|
+
const o = Ze(s.sort((r, a) => r.title.localeCompare(a.title)), t);
|
|
373
375
|
return {
|
|
374
|
-
sidebar:
|
|
375
|
-
index:
|
|
376
|
+
sidebar: n.sort((r, a) => r.text.localeCompare(a.text)),
|
|
377
|
+
index: o
|
|
376
378
|
};
|
|
377
379
|
}
|
|
378
|
-
function
|
|
379
|
-
const t =
|
|
380
|
-
for (const
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
text: h(S(
|
|
384
|
-
link: `/${h(S(
|
|
380
|
+
function rt(e) {
|
|
381
|
+
const t = K(e), s = [];
|
|
382
|
+
for (const n of t) {
|
|
383
|
+
const o = i(process.cwd(), n), r = i(Y, h(m(n), { mode: "lowercase", removeIdx: !0 }));
|
|
384
|
+
F(o, r), s.push({
|
|
385
|
+
text: h(S(o).name, { replaceDash: !0, removeIdx: !0 }),
|
|
386
|
+
link: `/${h(S(o).name, { removeIdx: !0, mode: "lowercase" })}`
|
|
385
387
|
});
|
|
386
388
|
}
|
|
387
389
|
return s;
|
|
388
390
|
}
|
|
389
|
-
function
|
|
390
|
-
const
|
|
391
|
-
for (const
|
|
392
|
-
const r = i(process.cwd(),
|
|
393
|
-
|
|
391
|
+
function z(e, t, s) {
|
|
392
|
+
const n = I(e);
|
|
393
|
+
for (const o of n) {
|
|
394
|
+
const r = i(process.cwd(), o), a = i(t, m(o));
|
|
395
|
+
F(r, a);
|
|
394
396
|
}
|
|
395
397
|
}
|
|
396
|
-
function
|
|
397
|
-
|
|
398
|
-
`), v(
|
|
399
|
-
`.concat(
|
|
400
|
-
}
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
],
|
|
407
|
-
await
|
|
398
|
+
function ot(e, t) {
|
|
399
|
+
j(H(V)), v(V, `export default ${JSON.stringify(e, null, 2)}
|
|
400
|
+
`), v(Fe, `---
|
|
401
|
+
`.concat(be.stringify(t)));
|
|
402
|
+
}
|
|
403
|
+
const oe = "prepare", ne = [
|
|
404
|
+
u("-c, --extra-public-content <string>", b.shape.extraPublicContent._def.description),
|
|
405
|
+
u("-p, --extra-header-pages <string>", b.shape.extraHeaderPages._def.description),
|
|
406
|
+
u("-t, --extra-theme <string>", b.shape.extraTheme._def.description),
|
|
407
|
+
u("-v, --vitepress-config <string>", b.shape.vitepressConfig._def.description)
|
|
408
|
+
], nt = k(D(oe), [...ne, ..._]).description("Transform doc to the target vitepress format.").action(async (e) => {
|
|
409
|
+
await ie(e);
|
|
408
410
|
});
|
|
409
|
-
async function
|
|
410
|
-
const { extraHeaderPages: t, extraPublicContent: s, extraTheme:
|
|
411
|
-
t && $.push(...
|
|
412
|
-
const C =
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
function
|
|
416
|
-
const e = new
|
|
417
|
-
await
|
|
411
|
+
async function ie(e) {
|
|
412
|
+
const { extraHeaderPages: t, extraPublicContent: s, extraTheme: n, vitepressConfig: o } = Q(oe, e), r = Ne(), a = Le().reduce((g, p) => p.clone_url && !p.fork && !p.private && p.docpress.includes.length && !p.docpress.filtered ? [...g, p] : g, []), { sidebar: c, index: l } = st(a, r), $ = [];
|
|
413
|
+
t && $.push(...rt(t)), s && z(s, i(x, "public")), n && z(n, i(x, ".vitepress/theme"));
|
|
414
|
+
const C = Ye(c, $, o);
|
|
415
|
+
ot(C, l);
|
|
416
|
+
}
|
|
417
|
+
function it() {
|
|
418
|
+
const e = new ce().name("docpress").description("Build your doc website faster than light ⚡️⚡️⚡️").version(`${Ee.version}`).addCommand(We).addCommand(nt).addCommand(Xe).action(async (t, s) => {
|
|
419
|
+
await se(t), await ie(t), await re();
|
|
418
420
|
}).configureHelp({
|
|
419
421
|
sortSubcommands: !0,
|
|
420
422
|
sortOptions: !0,
|
|
421
423
|
showGlobalOptions: !0
|
|
422
424
|
}).enablePositionalOptions().passThroughOptions();
|
|
423
|
-
return k(e, [...
|
|
425
|
+
return k(e, [...te, ...ne, ..._]), e;
|
|
424
426
|
}
|
|
425
|
-
function
|
|
426
|
-
|
|
427
|
+
function vt() {
|
|
428
|
+
it().parseAsync();
|
|
427
429
|
}
|
|
428
430
|
export {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
+
it as getProgram,
|
|
432
|
+
vt as main
|
|
431
433
|
};
|
|
432
434
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../src/schemas/build.ts","../src/utils/const.ts","../src/utils/functions.ts","../src/schemas/fetch.ts","../src/schemas/prepare.ts","../src/schemas/global.ts","../src/utils/commands.ts","../src/lib/git.ts","../src/lib/fetch.ts","../src/commands/global.ts","../src/commands/fetch.ts","../src/commands/build.ts","../src/lib/vitepress.ts","../src/utils/regex.ts","../src/lib/prepare.ts","../src/commands/prepare.ts","../src/cli.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const buildOptsSchema = z.object({})\n\nexport type BuildOpts = Zod.infer<typeof buildOptsSchema>\n","import { resolve } from 'node:path'\n\nexport const DOCPRESS_DIR = resolve(process.cwd(), 'docpress')\n\nexport const USER_REPOS_INFOS = resolve(process.cwd(), 'docpress/repositories.json')\n\nexport const USER_INFOS = resolve(process.cwd(), 'docpress/owner.json')\n\nexport const DOCS_DIR = resolve(process.cwd(), 'docpress/docs')\n\nexport const INDEX_FILE = resolve(process.cwd(), 'docpress/docs/index.md')\n\nexport const VITEPRESS_CONFIG = resolve(process.cwd(), 'docpress/.vitepress/config.ts')\n","import { existsSync, mkdirSync, readdirSync, readFileSync, statSync } from 'node:fs'\nimport { basename, join } from 'node:path'\nimport axios from 'axios'\nimport { rimrafSync } from 'rimraf'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport type { getInfos } from '../lib/git.js'\nimport { USER_INFOS, USER_REPOS_INFOS } from './const.js'\n\nexport async function checkHttpStatus(url: string): Promise<number> {\n try {\n const response = await axios.head(url)\n return response.status\n } catch (error) {\n return error.response?.status || error.status || 500\n }\n}\n\ninterface PrettifyOpts {\n mode?: 'capitalize' | 'uppercase' | 'lowercase'\n replaceDash?: boolean\n removeIdx?: boolean\n}\n\nexport function prettify(s: string, opts: PrettifyOpts) {\n let u: string = ''\n\n if (opts?.removeIdx) {\n u = s.replace(/^\\d{2}-/, '')\n }\n\n if (opts?.replaceDash) {\n u = (u || s).replaceAll('-', ' ')\n }\n\n if (opts?.mode === 'capitalize') {\n u = (u || s).slice(0, 1).toUpperCase() + (u || s).slice(1).toLowerCase()\n } else if (opts?.mode === 'lowercase') {\n u = (u || s).toLowerCase()\n } else if (opts?.mode === 'uppercase') {\n u = (u || s).toUpperCase()\n }\n\n return u || s\n}\n\nexport function createDir(directory: string, { clean }: { clean?: boolean } = { clean: false }) {\n try {\n if (clean && existsSync(directory)) {\n rimrafSync(`${directory}/*`, { glob: true })\n }\n if (!existsSync(directory)) {\n mkdirSync(directory, { recursive: true })\n }\n } catch (err) {\n console.error(err)\n }\n}\n\nexport function isDir(path: string) {\n return statSync(path).isDirectory()\n}\n\nexport function isFile(path: string) {\n return statSync(path).isFile()\n}\n\nexport function extractFiles(paths: string[] | string): string[] {\n return (Array.isArray(paths) ? paths : [paths]).flatMap((path) => {\n if (isFile(path)) {\n return [path]\n }\n if (isDir(path)) {\n return readdirSync(path).flatMap(file => extractFiles(join(path, file)))\n }\n return []\n })\n}\n\nexport function getMdFiles(path: string[]) {\n return extractFiles(path).filter(file => basename(file).endsWith('.md'))\n}\n\nexport function prettifyEnum(arr: readonly string[]) {\n return arr.reduce((acc, cur, idx, arr) => {\n if (!idx) {\n return `\"${cur}\"`\n } else if (idx === arr.length - 1) {\n return `${acc} or \"${cur}\"`\n } else {\n return `${acc}, \"${cur}\"`\n }\n }, '')\n}\n\nexport function getUserInfos() {\n return JSON.parse(readFileSync(USER_INFOS).toString()) as Awaited<ReturnType<typeof getInfos>>['user']\n}\n\nexport function getUserRepos() {\n return JSON.parse(readFileSync(USER_REPOS_INFOS).toString()) as EnhancedRepository[]\n}\n\nexport function deepMerge<T extends Record<string, any> | null>(...objects: T[]): T {\n return objects.reduce((acc, obj) => {\n if (obj === null) {\n return acc\n }\n\n Object.keys(obj).forEach((key) => {\n const accValue = acc ? acc[key] : null\n const objValue = obj[key]\n\n if (isObject(accValue) && isObject(objValue)) {\n (acc as Record<string, any>)[key] = deepMerge(accValue, objValue)\n } else {\n (acc as Record<string, any>)[key] = objValue\n }\n })\n return acc\n }, {} as T)\n}\n\nfunction isObject(val: any): val is object {\n return val && typeof val === 'object' && !Array.isArray(val)\n}\n","import { z } from 'zod'\nimport { prettifyEnum } from '../utils/functions.js'\n\nconst providers = ['github'] as const\n\nexport const fetchOptsSchema = z.object({\n branch: z.string()\n .describe('Branch used to collect Git provider data.')\n .optional()\n .default('main'),\n gitProvider: z.enum(providers)\n .describe(`Git provider used to retrieve data. Values should be one of ${prettifyEnum(providers)}.`)\n .optional()\n .default('github'),\n reposFilter: z.string()\n .transform(repos => repos.split(','))\n .or(z.string().array())\n .describe('List of comma separated repositories to retrieve from Git provider. Default to all user\\'s public repositories.')\n .optional(),\n token: z.string()\n .describe('Git provider token used to collect data.')\n .optional(),\n username: z.string()\n .describe('Git provider username used to collect data.'),\n})\n\nexport type FetchOpts = Zod.infer<typeof fetchOptsSchema>\n","import { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport type { defineConfig } from 'vitepress'\nimport { z } from 'zod'\n\nexport const prepareOptsSchema = z.object({\n extraHeaderPages: z.string()\n .describe('List of comma separated additional files or directories to process Vitepress header pages.')\n .transform(paths => paths.split(','))\n .optional(),\n extraPublicContent: z.string()\n .describe('List of comma separated additional files or directories to process Vitepress public folder.')\n .transform(paths => paths.split(','))\n .optional(),\n extraTheme: z.string()\n .describe('List of comma separated additional files or directories to use as Vitepress theme.')\n .transform(paths => paths.split(','))\n .optional(),\n vitepressConfig: z.string()\n .describe('Path to the vitepress configuration file.')\n .transform(path => JSON.parse(readFileSync(resolve(process.cwd(), path)).toString()) as ReturnType<typeof defineConfig>)\n .optional(),\n})\n\nexport type PrepareOpts = Zod.infer<typeof prepareOptsSchema>\n","import { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { z } from 'zod'\nimport { buildOptsSchema } from './build.js'\nimport type { FetchOpts } from './fetch.js'\nimport { fetchOptsSchema } from './fetch.js'\nimport type { PrepareOpts } from './prepare.js'\nimport { prepareOptsSchema } from './prepare.js'\n\nexport const globalOptsSchema = z.object({\n config: z.string()\n .describe('Path to the docpress configuration file.')\n .transform(path => JSON.parse(readFileSync(resolve(process.cwd(), path)).toString()) as FetchOpts & PrepareOpts)\n .optional(),\n})\n\nexport type GlobalOpts = Zod.infer<typeof globalOptsSchema>\n\nexport const configSchema = fetchOptsSchema\n .merge(prepareOptsSchema)\n .merge(buildOptsSchema)\n\nexport type Config = Zod.infer<typeof configSchema>\n","import type { Command, Option } from 'commander'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport { globalOptsSchema } from '../schemas/global.js'\nimport type { BuildOpts } from '../schemas/build.js'\nimport { buildOptsSchema } from '../schemas/build.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { fetchOptsSchema } from '../schemas/fetch.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { prepareOptsSchema } from '../schemas/prepare.js'\n\ntype Cmd = 'fetch' | 'build' | 'prepare' | 'global'\n\ninterface Options {\n build: BuildOpts\n fetch: FetchOpts\n prepare: PrepareOpts\n global: GlobalOpts\n}\n\nexport const options = {\n build: buildOptsSchema,\n fetch: fetchOptsSchema,\n prepare: prepareOptsSchema,\n global: globalOptsSchema,\n}\n\nexport function parseOptions<T extends Cmd>(cmd: T, opts: Options[T]) {\n const res = options[cmd].safeParse({\n ...globalOptsSchema.parse(opts).config,\n ...opts,\n })\n\n if (res.success) {\n return res.data as Options[T]\n }\n throw new Error(`Invalid options: ${res.error}`)\n}\n\nexport function addOptions(cmd: Command, opts: Option[]) {\n opts.forEach(opt => cmd.addOption(opt))\n return cmd\n}\n","import { appendFileSync, cpSync, rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { Octokit } from 'octokit'\nimport { simpleGit } from 'simple-git'\nimport { createDir } from '../utils/functions.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\n\nexport async function getInfos({ username, token, branch }: Pick<FetchOpts, 'username' | 'branch' | 'token'>) {\n const octokit = new Octokit({ auth: token })\n const { data: user } = await octokit.request('GET /users/{username}', { username })\n const { data: repos } = await octokit.request('GET /users/{username}/repos', { username, sort: 'full_name' })\n\n return { user, repos, branch }\n}\n\nexport async function cloneRepo(url: string, projectDir: string, branch: string, includes: string[]) {\n createDir(projectDir, { clean: true })\n\n try {\n const git = simpleGit({ baseDir: projectDir })\n await git.init()\n .addConfig('core.sparseCheckout', 'true', true, 'local')\n .addRemote('origin', url)\n\n for (const item of includes) {\n appendFileSync(resolve(projectDir, '.git/info/sparse-checkout'), `${item}\\n`, 'utf8')\n }\n\n await git.pull('origin', branch)\n\n if (includes.some(item => item.includes('docs'))) {\n cpSync(resolve(projectDir, 'docs'), projectDir, { recursive: true })\n rmSync(resolve(projectDir, 'docs'), { recursive: true })\n }\n rmSync(resolve(projectDir, '.git'), { recursive: true })\n } catch (e) {\n console.error(e)\n }\n}\n","import { resolve } from 'node:path'\nimport { writeFileSync } from 'node:fs'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { checkHttpStatus, createDir } from '../utils/functions.js'\nimport { DOCPRESS_DIR, DOCS_DIR, USER_INFOS, USER_REPOS_INFOS } from '../utils/const.js'\nimport { cloneRepo, getInfos } from './git.js'\n\nexport type EnhancedRepository = Awaited<ReturnType<typeof getInfos>>['repos'][number] & {\n docpress: {\n branch: string\n filtered: boolean\n includes: string[]\n projectPath: string\n raw_url: string\n replace_url: string\n }\n}\n\nexport async function checkDoc(repoOwner: FetchOpts['username'], repoName: string, branch: FetchOpts['branch']) {\n const rootReadmeUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/README.md`\n const docsFolderUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/docs`\n const docsReadmeUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/docs/01-readme.md`\n\n const rootReadmeStatus = await checkHttpStatus(rootReadmeUrl)\n const docsFolderStatus = await checkHttpStatus(docsFolderUrl)\n const docsReadmeStatus = await checkHttpStatus(docsReadmeUrl)\n\n return {\n rootReadmeStatus,\n docsFolderStatus,\n docsReadmeStatus,\n }\n}\n\nexport async function fetchDoc({ username, branch, reposFilter, token }: FetchOpts) {\n createDir(DOCPRESS_DIR, { clean: true })\n\n await getInfos({ username, token, branch })\n .then(async ({ user, repos, branch }) => generateInfos(user, repos, branch, reposFilter))\n .then(async ({ repos }) => getDoc(repos, reposFilter))\n}\n\nexport async function enhanceRepositories(repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n const enhancedRepos: EnhancedRepository[] = []\n\n await Promise.all(\n repos.map(async (repo) => {\n const computedBranch = branch ?? repo.default_branch ?? 'main'\n const projectPath = resolve(DOCS_DIR, repo.name)\n const filtered = isRepoFiltered(repo, reposFilter)\n let includes: string[] = []\n\n if (!repo.fork && !repo.private && !filtered) {\n includes = await getSparseCheckout(repo, computedBranch)\n }\n\n enhancedRepos.push({\n ...repo,\n docpress: {\n filtered,\n branch: computedBranch,\n includes,\n projectPath,\n raw_url: `https://raw.githubusercontent.com/${repo.owner.login}/${repo.name}/${computedBranch}`,\n replace_url: `https://github.com/${repo.owner.login}/${repo.name}/tree/${computedBranch}`,\n },\n })\n }),\n )\n\n return enhancedRepos\n}\n\nexport async function getSparseCheckout(repo: Awaited<ReturnType<typeof getInfos>>['repos'][number], branch: FetchOpts['branch']) {\n const docsStatus = await checkDoc(repo.owner.login, repo.name, branch)\n\n const includes: string[] = []\n if (Object.values(docsStatus).every(status => status === 404) || !repo.size) {\n return []\n }\n if (docsStatus.docsFolderStatus !== 404) {\n includes.push('docs/*')\n }\n if (docsStatus.docsFolderStatus === 404 || docsStatus.docsReadmeStatus === 404) {\n includes.push('README.md', '!*/**/README.md')\n }\n return includes\n}\n\nexport async function generateInfos(user: Awaited<ReturnType<typeof getInfos>>['user'], repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n writeFileSync(USER_INFOS, JSON.stringify(user, null, 2))\n\n const enhancedRepos = await enhanceRepositories(repos, branch, reposFilter)\n writeFileSync(USER_REPOS_INFOS, JSON.stringify(enhancedRepos, null, 2))\n\n return { user, repos: enhancedRepos }\n}\n\nexport async function getDoc(repos?: EnhancedRepository[], reposFilter?: FetchOpts['reposFilter']) {\n if (!repos) {\n console.warn('No repository respect docpress rules.')\n return\n }\n\n await Promise.all(\n repos\n .filter(repo => !isRepoFiltered(repo, reposFilter))\n .map(async repo => cloneRepo(repo.clone_url as string, repo.docpress.projectPath, repo.docpress.branch, repo.docpress.includes)),\n )\n}\n\nexport function isRepoFiltered(repo: EnhancedRepository | Awaited<ReturnType<typeof getInfos>>['repos'][number], reposFilter?: FetchOpts['reposFilter']) {\n const isExcluded = reposFilter?.filter(filter => filter.startsWith('!'))\n .some(filter => repo.name === filter.substring(1))\n const isIncluded = !reposFilter || reposFilter?.filter(filter => !filter.startsWith('!'))\n .includes(repo.name)\n\n const isFiltered = isExcluded || !isIncluded\n\n if ('docpress' in repo && !repo.docpress.includes.length) {\n return true\n }\n\n if (!!repo.clone_url && !repo.fork && !repo.private && !isFiltered) {\n return false\n }\n return true\n}\n","import { createOption } from 'commander'\nimport { globalOptsSchema } from '../schemas/global.js'\n\nexport const globalOpts = [\n createOption('-C, --config <string>', globalOptsSchema.shape.config._def.description),\n]\n","import { createCommand, createOption } from 'commander'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport { fetchOptsSchema } from '../schemas/fetch.js'\nimport { fetchDoc } from '../lib/fetch.js'\nimport type { Config } from '../schemas/global.js'\nimport { globalOpts } from './global.js'\n\nconst cmdName = 'fetch'\n\nexport const fetchOpts = [\n createOption('-b, --branch <string>', fetchOptsSchema.shape.branch._def.description)\n .default(fetchOptsSchema.shape.branch._def.defaultValue()),\n createOption('-g, --git-provider <string>', fetchOptsSchema.shape.gitProvider._def.description)\n .default(fetchOptsSchema.shape.gitProvider._def.defaultValue()),\n createOption('-r, --repos-filter <string>', fetchOptsSchema.shape.reposFilter._def.description),\n createOption('-T, --token <string>', fetchOptsSchema.shape.token._def.description),\n createOption('-u, --username <string>', fetchOptsSchema.shape.username._def.description),\n]\n\nexport const fetchCmd = addOptions(createCommand(cmdName), [...fetchOpts, ...globalOpts])\n .description('Fetch docs with the given username and git provider.')\n .action(async (opts) => {\n await main(opts)\n })\n\nexport async function main(opts: Config) {\n const { username, reposFilter, token, branch, gitProvider } = parseOptions(cmdName, opts)\n\n await fetchDoc({ username, branch, reposFilter, gitProvider, token })\n}\n","import { build as vitepressBuild } from 'vitepress'\nimport { createCommand } from 'commander'\nimport { addOptions } from '../utils/commands.js'\nimport { DOCPRESS_DIR } from '../utils/const.js'\nimport { globalOpts } from './global.js'\n\nconst cmdName = 'build'\n\nexport const buildOpts = []\n\nexport const buildCmd = addOptions(createCommand(cmdName), globalOpts)\n .description('Build vitepress website.')\n .action(async (_opts) => {\n await main()\n })\n\nexport async function main() {\n await vitepressBuild(DOCPRESS_DIR)\n}\n","import type { defineConfig } from 'vitepress'\nimport { deepMerge } from '../utils/functions.js'\nimport type { Page, SidebarProject } from './prepare.js'\n\nconst defaultVitepressConfig: ReturnType<typeof defineConfig> = {\n base: '/',\n lang: 'en-US',\n vite: {\n publicDir: '../public',\n },\n title: 'Home',\n description: 'Docpress',\n srcDir: './docs',\n cleanUrls: true,\n ignoreDeadLinks: 'localhostLinks',\n themeConfig: {\n outline: [2, 3],\n search: {\n provider: 'local',\n options: {\n translations: {\n button: {\n buttonText: 'Search...',\n buttonAriaLabel: 'Search',\n },\n modal: {\n backButtonTitle: 'erase search',\n displayDetails: 'show details',\n noResultsText: 'No results for : ',\n resetButtonTitle: 'cancel search',\n footer: {\n selectText: 'go to',\n navigateText: 'navigate in results',\n closeText: 'close',\n },\n },\n },\n },\n },\n },\n}\n\nexport function getVitepressConfig(sidebar: SidebarProject[], nav: Page[], vitepressConfig?: ReturnType<typeof defineConfig>): Partial<ReturnType<typeof defineConfig>> {\n const mergedConfig = deepMerge(defaultVitepressConfig, vitepressConfig ?? {})\n\n return {\n ...mergedConfig,\n themeConfig: {\n ...mergedConfig.themeConfig,\n sidebar,\n nav,\n },\n }\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\n\nexport function replaceRelativePath(file: string, url: string) {\n const fileContent = readFileSync(file, 'utf8')\n const updatedContent = fileContent.replace(/\\[([^\\]]+)\\]\\(\\.\\.\\/([^)]+)\\)/g, (_match, p1, p2) => {\n return `[${p1}](${url}/${p2})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n\nexport function replaceReadmePath(file: string, url: string) {\n const readmeContent = readFileSync(file, 'utf8')\n const updatedContent = readmeContent\n .replace(/\\[([^\\]]+)\\]\\((?!\\.?\\/docs\\/|docs\\/|http)(\\.?\\/)?([^/][^)]+)\\)/g, (_match, p1, _p2, p3) => {\n return `[${p1}](${url}/${p3})`\n })\n .replace(/\\[([^\\]]+)\\]\\((\\.?\\/docs\\/|docs\\/)([^)]*)\\)/g, (_match, p1, _p2, p3) => {\n return `[${p1}](${p3})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n","import { basename, dirname, parse, resolve } from 'node:path'\nimport { appendFileSync, cpSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs'\nimport YAML from 'yaml'\nimport type { defineConfig } from 'vitepress'\nimport type { getUserInfos } from '../utils/functions.js'\nimport { createDir, extractFiles, getMdFiles, prettify } from '../utils/functions.js'\nimport { DOCS_DIR, INDEX_FILE, VITEPRESS_CONFIG } from '../utils/const.js'\nimport { replaceReadmePath, replaceRelativePath } from '../utils/regex.js'\nimport type { EnhancedRepository } from './fetch.js'\n\nexport interface Page {\n text: string\n link: string\n}\n\nexport interface SidebarProject {\n text: string\n collapsed: boolean\n items: Page[]\n}\n\nexport interface Feature {\n title: string\n details: string\n link: string\n}\n\nexport interface Index {\n layout: string\n hero: {\n name: string\n tagline: string\n }\n features: Feature[]\n}\n\nfunction addSources(repoUrl: string, outputPath: string) {\n const fileName = basename(outputPath)\n const title = fileName === 'readme.md' ? '\\n## Sources' : '# Sources'\n\n const sourcesContent = `${title}\\n\\nTake a look at the [project sources](${repoUrl}).\\n`\n\n appendFileSync(outputPath, sourcesContent, 'utf8')\n}\n\n// export function addContribution(outputPath: string) {\n// const sourcesContent = `\n// If you'd like to improve or fix the code, check out the [contribution guidelines](/contribute).\n// `\n\n// appendFileSync(outputPath, sourcesContent, 'utf8')\n// }\n\nexport function generateIndex(features: Feature[], user: ReturnType<typeof getUserInfos>) {\n const { name, login, bio } = user\n return {\n layout: 'home',\n hero: {\n name: name ? `${name}'s projects` : `${login}'s projects`,\n tagline: bio ?? 'Robots are everywhere 🤖', // \\U0001F916\n },\n features,\n }\n}\n\nexport function generateFeatures(repoName: string, description: string, features?: Feature[]) {\n const content = {\n title: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n details: description,\n link: `/${repoName}/readme`,\n }\n\n return features ? [...features, content] : [content]\n}\n\nexport function generateSidebarProject(repoName: string, sidebarPages: Page[]) {\n return {\n text: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n collapsed: true,\n items: sidebarPages,\n }\n}\n\nexport function generateSidebarPages(repoName: string, fileName: string, sidebarPages?: Page[]) {\n const content = {\n text: fileName === 'readme' ? 'Introduction' : prettify(fileName, { mode: 'capitalize', replaceDash: true }),\n link: `/${repoName}/${fileName}`,\n }\n\n return sidebarPages ? [...sidebarPages, content] : [content]\n}\n\nexport function transformDoc(repositories: EnhancedRepository[], user: ReturnType<typeof getUserInfos>) {\n const features: Feature[] = []\n const sidebar: SidebarProject[] = []\n\n for (const repository of repositories) {\n getMdFiles([repository.docpress.projectPath]).forEach((file) => {\n replaceRelativePath(file, `https://github.com/${repository.owner.login}/${repository.name}/tree/${repository.docpress.branch}`)\n\n if (basename(file).toLowerCase() === 'readme.md') {\n replaceReadmePath(file, `https://github.com/${repository.owner.login}/${repository.name}/tree/${repository.docpress.branch}`)\n }\n })\n\n const sidebarItems = readdirSync(repository.docpress.projectPath)\n .filter((file) => {\n return statSync(resolve(repository.docpress.projectPath, file)).isFile()\n && basename(resolve(repository.docpress.projectPath, file)).endsWith('.md')\n })\n .sort((a, b) => a.localeCompare(b))\n .reduce((acc: Page[], cur, idx, arr) => {\n const file = resolve(repository.docpress.projectPath, cur)\n const filename = prettify(basename(file), { mode: 'lowercase', removeIdx: true })\n\n if (filename !== basename(file)) {\n renameSync(file, resolve(dirname(file), filename))\n }\n\n if (idx === arr.length - 1) {\n let sourceFile\n if (arr.length > 1) {\n sourceFile = resolve(repository.docpress.projectPath, 'sources.md')\n addSources(repository.html_url, sourceFile)\n\n return generateSidebarPages(\n repository.name,\n parse(sourceFile).name,\n generateSidebarPages(repository.name, parse(filename).name, acc),\n )\n }\n sourceFile = resolve(repository.docpress.projectPath, 'readme.md')\n addSources(repository.html_url, sourceFile)\n }\n\n return generateSidebarPages(repository.name, parse(filename).name, acc)\n }, [])\n\n sidebar.push(generateSidebarProject(repository.name, sidebarItems))\n features.push(...generateFeatures(repository.name, repository.description || ''))\n }\n\n const index = generateIndex(features.sort((a, b) => a.title.localeCompare(b.title)), user)\n return {\n sidebar: sidebar.sort((a, b) => a.text.localeCompare(b.text)),\n index,\n }\n}\n\nexport function addExtraPages(paths: string[]) {\n const files = getMdFiles(paths)\n const nav: Page[] = []\n\n for (const file of files) {\n const src = resolve(process.cwd(), file)\n const dest = resolve(DOCS_DIR, prettify(basename(file), { mode: 'lowercase', removeIdx: true }))\n cpSync(src, dest)\n nav.push({\n text: prettify(parse(src).name, { replaceDash: true, removeIdx: true }),\n link: `/${prettify(parse(src).name, { removeIdx: true, mode: 'lowercase' })}`,\n })\n }\n return nav\n}\n\nexport function addContent(path: string | string[], dir: string, fn?: () => void) {\n const files = extractFiles(path)\n\n for (const file of files) {\n const src = resolve(process.cwd(), file)\n const dest = resolve(dir, basename(file))\n if (fn) {\n fn()\n }\n cpSync(src, dest)\n }\n}\n\nexport function parseVitepressConfig(path: string) {\n return JSON.parse(readFileSync(resolve(process.cwd(), path)).toString())\n}\n\nexport function generateVitepressFiles(vitepressConfig: Partial<ReturnType<typeof defineConfig>>, index: Index) {\n createDir(dirname(VITEPRESS_CONFIG))\n\n writeFileSync(VITEPRESS_CONFIG, `export default ${JSON.stringify(vitepressConfig, null, 2)}\\n`)\n writeFileSync(INDEX_FILE, '---\\n'.concat(YAML.stringify(index)))\n}\n","import { resolve } from 'node:path'\nimport { createCommand, createOption } from 'commander'\nimport { DOCPRESS_DIR } from '../utils/const.js'\nimport { getUserInfos, getUserRepos } from '../utils/functions.js'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport { getVitepressConfig } from '../lib/vitepress.js'\nimport { addContent, addExtraPages, generateVitepressFiles, transformDoc } from '../lib/prepare.js'\nimport { prepareOptsSchema } from '../schemas/prepare.js'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport type { Page } from '../lib/prepare.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { globalOpts } from './global.js'\n\nconst cmdName = 'prepare'\n\nexport const prepareOpts = [\n createOption('-c, --extra-public-content <string>', prepareOptsSchema.shape.extraPublicContent._def.description),\n createOption('-p, --extra-header-pages <string>', prepareOptsSchema.shape.extraHeaderPages._def.description),\n createOption('-t, --extra-theme <string>', prepareOptsSchema.shape.extraTheme._def.description),\n createOption('-v, --vitepress-config <string>', prepareOptsSchema.shape.vitepressConfig._def.description),\n]\n\nexport const prepareCmd = addOptions(createCommand(cmdName), [...prepareOpts, ...globalOpts])\n .description('Transform doc to the target vitepress format.')\n .action(async (opts) => {\n await main(opts)\n })\n\nexport async function main(opts: PrepareOpts) {\n const { extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig } = parseOptions(cmdName, opts)\n\n const user = getUserInfos()\n const repositories = getUserRepos()\n .reduce((acc: EnhancedRepository[], cur) => {\n if (cur.clone_url && !cur.fork && !cur.private && cur.docpress.includes.length && !cur.docpress.filtered) {\n return [...acc, cur]\n }\n return acc\n }, [])\n\n const { sidebar, index } = transformDoc(repositories, user)\n const nav: Page[] = []\n\n if (extraHeaderPages) {\n nav.push(...addExtraPages(extraHeaderPages))\n }\n if (extraPublicContent) {\n addContent(extraPublicContent, resolve(DOCPRESS_DIR, 'public'))\n }\n if (extraTheme) {\n addContent(extraTheme, resolve(DOCPRESS_DIR, '.vitepress/theme'))\n }\n\n const config = getVitepressConfig(sidebar, nav, vitepressConfig)\n\n generateVitepressFiles(config, index)\n}\n","import { Command } from 'commander'\nimport pkg from '../package.json' with { type: 'json' }\nimport { fetchCmd, main as fetchFn, fetchOpts } from './commands/fetch.js'\nimport { buildCmd, main as buildFn } from './commands/build.js'\nimport { prepareCmd, main as prepareFn, prepareOpts } from './commands/prepare.js'\nimport { addOptions } from './utils/commands.js'\nimport { globalOpts } from './commands/global.js'\n\nexport function getProgram() {\n const pm = new Command()\n .name('docpress')\n .description('Build your doc website faster than light ⚡️⚡️⚡️')\n .version(`${pkg.version}`)\n .addCommand((fetchCmd))\n .addCommand(prepareCmd)\n .addCommand(buildCmd)\n .action(async (opts, _cmd) => {\n await fetchFn(opts)\n await prepareFn(opts)\n await buildFn()\n })\n .configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n showGlobalOptions: true,\n })\n .enablePositionalOptions()\n .passThroughOptions()\n\n addOptions(pm, [...fetchOpts, ...prepareOpts, ...globalOpts])\n\n return pm\n}\n\nexport function main() {\n const pm = getProgram()\n pm.parseAsync()\n}\n"],"names":["buildOptsSchema","z","DOCPRESS_DIR","resolve","USER_REPOS_INFOS","USER_INFOS","DOCS_DIR","INDEX_FILE","VITEPRESS_CONFIG","checkHttpStatus","url","axios","error","prettify","s","opts","u","createDir","directory","clean","existsSync","rimrafSync","mkdirSync","err","isDir","path","statSync","isFile","extractFiles","paths","readdirSync","file","join","getMdFiles","basename","prettifyEnum","arr","acc","cur","idx","getUserInfos","readFileSync","getUserRepos","deepMerge","objects","obj","key","accValue","objValue","isObject","val","providers","fetchOptsSchema","repos","prepareOptsSchema","globalOptsSchema","options","parseOptions","cmd","res","addOptions","opt","getInfos","username","token","branch","octokit","Octokit","user","cloneRepo","projectDir","includes","git","simpleGit","item","appendFileSync","cpSync","rmSync","e","checkDoc","repoOwner","repoName","rootReadmeUrl","docsFolderUrl","docsReadmeUrl","rootReadmeStatus","docsFolderStatus","docsReadmeStatus","fetchDoc","reposFilter","generateInfos","getDoc","enhanceRepositories","enhancedRepos","repo","computedBranch","projectPath","filtered","isRepoFiltered","getSparseCheckout","docsStatus","status","writeFileSync","isExcluded","filter","isIncluded","isFiltered","globalOpts","createOption","cmdName","fetchOpts","fetchCmd","createCommand","main","gitProvider","buildCmd","_opts","vitepressBuild","defaultVitepressConfig","getVitepressConfig","sidebar","nav","vitepressConfig","mergedConfig","replaceRelativePath","updatedContent","_match","p1","p2","replaceReadmePath","_p2","p3","addSources","repoUrl","outputPath","sourcesContent","generateIndex","features","name","login","bio","generateFeatures","description","content","generateSidebarProject","sidebarPages","generateSidebarPages","fileName","transformDoc","repositories","repository","sidebarItems","a","b","filename","renameSync","dirname","sourceFile","parse","index","addExtraPages","files","src","dest","addContent","dir","fn","generateVitepressFiles","YAML","prepareOpts","prepareCmd","extraHeaderPages","extraPublicContent","extraTheme","config","getProgram","pm","Command","pkg","_cmd","fetchFn","prepareFn","buildFn"],"mappings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ts","../src/utils/const.ts","../src/utils/functions.ts","../src/schemas/fetch.ts","../src/schemas/prepare.ts","../src/schemas/global.ts","../src/utils/commands.ts","../src/lib/git.ts","../src/lib/fetch.ts","../src/commands/global.ts","../src/commands/fetch.ts","../src/commands/build.ts","../src/lib/vitepress.ts","../src/utils/regex.ts","../src/lib/prepare.ts","../src/commands/prepare.ts","../src/cli.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const buildOptsSchema = z.object({})\n\nexport type BuildOpts = Zod.infer<typeof buildOptsSchema>\n","import { resolve } from 'node:path'\n\nexport const DOCPRESS_DIR = resolve(process.cwd(), 'docpress')\n\nexport const USER_REPOS_INFOS = resolve(process.cwd(), 'docpress/repositories.json')\n\nexport const USER_INFOS = resolve(process.cwd(), 'docpress/owner.json')\n\nexport const DOCS_DIR = resolve(process.cwd(), 'docpress/docs')\n\nexport const INDEX_FILE = resolve(process.cwd(), 'docpress/docs/index.md')\n\nexport const VITEPRESS_CONFIG = resolve(process.cwd(), 'docpress/.vitepress/config.ts')\n","import { existsSync, mkdirSync, readdirSync, readFileSync, statSync } from 'node:fs'\nimport { basename, join } from 'node:path'\nimport axios from 'axios'\nimport { rimrafSync } from 'rimraf'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport type { getInfos } from '../lib/git.js'\nimport { USER_INFOS, USER_REPOS_INFOS } from './const.js'\n\nexport async function checkHttpStatus(url: string): Promise<number> {\n try {\n const response = await axios.head(url)\n return response.status\n } catch (error) {\n return error.response?.status || error.status || 500\n }\n}\n\ninterface PrettifyOpts {\n mode?: 'capitalize' | 'uppercase' | 'lowercase'\n replaceDash?: boolean\n removeIdx?: boolean\n}\n\nexport function prettify(s: string, opts: PrettifyOpts) {\n let u: string = ''\n\n if (opts?.removeIdx) {\n u = s.replace(/^\\d{2}-/, '')\n }\n\n if (opts?.replaceDash) {\n u = (u || s).replaceAll('-', ' ')\n }\n\n if (opts?.mode === 'capitalize') {\n u = (u || s).slice(0, 1).toUpperCase() + (u || s).slice(1).toLowerCase()\n } else if (opts?.mode === 'lowercase') {\n u = (u || s).toLowerCase()\n } else if (opts?.mode === 'uppercase') {\n u = (u || s).toUpperCase()\n }\n\n return u || s\n}\n\nexport function createDir(directory: string, { clean }: { clean?: boolean } = { clean: false }) {\n try {\n if (clean && existsSync(directory)) {\n rimrafSync(`${directory}/*`, { glob: true })\n }\n if (!existsSync(directory)) {\n mkdirSync(directory, { recursive: true })\n }\n } catch (err) {\n console.error(err)\n }\n}\n\nexport function isDir(path: string) {\n try {\n return statSync(path).isDirectory()\n } catch (_error) {\n return false\n }\n}\n\nexport function isFile(path: string) {\n try {\n return statSync(path).isFile()\n } catch (_error) {\n return false\n }\n}\n\nexport function extractFiles(paths: string[] | string): string[] {\n return (Array.isArray(paths) ? paths : [paths]).flatMap((path) => {\n if (isFile(path)) {\n return [path]\n }\n if (isDir(path)) {\n return readdirSync(path).flatMap(file => extractFiles(join(path, file)))\n }\n return []\n })\n}\n\nexport function getMdFiles(path: string[]) {\n return extractFiles(path).filter(file => basename(file).endsWith('.md'))\n}\n\nexport function prettifyEnum(arr: readonly string[]) {\n return arr.reduce((acc, cur, idx, arr) => {\n if (!idx) {\n return `\"${cur}\"`\n } else if (idx === arr.length - 1) {\n return `${acc} or \"${cur}\"`\n } else {\n return `${acc}, \"${cur}\"`\n }\n }, '')\n}\n\nexport function getUserInfos() {\n return JSON.parse(readFileSync(USER_INFOS).toString()) as Awaited<ReturnType<typeof getInfos>>['user']\n}\n\nexport function getUserRepos() {\n return JSON.parse(readFileSync(USER_REPOS_INFOS).toString()) as EnhancedRepository[]\n}\n\nexport function deepMerge<T extends Record<string, any> | null>(...objects: T[]): T {\n return objects.reduce((acc, obj) => {\n if (obj === null) {\n return acc\n }\n\n Object.keys(obj).forEach((key) => {\n const accValue = acc ? acc[key] : null\n const objValue = obj[key]\n\n if (isObject(accValue) && isObject(objValue)) {\n (acc as Record<string, any>)[key] = deepMerge(accValue, objValue)\n } else {\n (acc as Record<string, any>)[key] = objValue\n }\n })\n return acc\n }, {} as T)\n}\n\nfunction isObject(val: any): val is object {\n return val && typeof val === 'object' && !Array.isArray(val)\n}\n","import { z } from 'zod'\nimport { prettifyEnum } from '../utils/functions.js'\n\nconst providers = ['github'] as const\n\nexport const fetchOptsSchema = z.object({\n branch: z.string()\n .describe('Branch used to collect Git provider data.')\n .optional()\n .default('main'),\n gitProvider: z.enum(providers)\n .describe(`Git provider used to retrieve data. Values should be ${prettifyEnum(providers)}.`)\n .optional()\n .default('github'),\n reposFilter: z.string()\n .transform(repos => repos.split(','))\n .or(z.string().array())\n .describe('List of comma separated repositories to retrieve from Git provider. Default to all user\\'s public repositories.')\n .optional(),\n token: z.string()\n .describe('Git provider token used to collect data.')\n .optional(),\n username: z.string()\n .describe('Git provider username used to collect data.'),\n})\n\nexport type FetchOpts = Zod.infer<typeof fetchOptsSchema>\n","import { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport type { defineConfig } from 'vitepress'\nimport { z } from 'zod'\n\nexport const prepareOptsSchema = z.object({\n extraHeaderPages: z.string()\n .describe('List of comma separated additional files or directories to process Vitepress header pages.')\n .transform(paths => paths.split(','))\n .optional(),\n extraPublicContent: z.string()\n .describe('List of comma separated additional files or directories to process Vitepress public folder.')\n .transform(paths => paths.split(','))\n .optional(),\n extraTheme: z.string()\n .describe('List of comma separated additional files or directories to use as Vitepress theme.')\n .transform(paths => paths.split(','))\n .optional(),\n vitepressConfig: z.string()\n .describe('Path to the vitepress configuration file.')\n .transform(path => JSON.parse(readFileSync(resolve(process.cwd(), path)).toString()) as ReturnType<typeof defineConfig>)\n .optional(),\n})\n\nexport type PrepareOpts = Zod.infer<typeof prepareOptsSchema>\n","import { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { z } from 'zod'\nimport { buildOptsSchema } from './build.js'\nimport type { FetchOpts } from './fetch.js'\nimport { fetchOptsSchema } from './fetch.js'\nimport type { PrepareOpts } from './prepare.js'\nimport { prepareOptsSchema } from './prepare.js'\n\nexport const globalOptsSchema = z.object({\n config: z.string()\n .describe('Path to the docpress configuration file.')\n .transform(path => JSON.parse(readFileSync(resolve(process.cwd(), path)).toString()) as FetchOpts & PrepareOpts)\n .optional(),\n})\n\nexport type GlobalOpts = Zod.infer<typeof globalOptsSchema>\n\nexport const configSchema = fetchOptsSchema\n .merge(prepareOptsSchema)\n .merge(buildOptsSchema)\n\nexport type Config = Zod.infer<typeof configSchema>\n","import type { Command, Option } from 'commander'\nimport { fromError } from 'zod-validation-error'\nimport type { GlobalOpts } from '../schemas/global.js'\nimport { globalOptsSchema } from '../schemas/global.js'\nimport type { BuildOpts } from '../schemas/build.js'\nimport { buildOptsSchema } from '../schemas/build.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { fetchOptsSchema } from '../schemas/fetch.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { prepareOptsSchema } from '../schemas/prepare.js'\n\ntype Cmd = 'fetch' | 'build' | 'prepare' | 'global'\n\ninterface Options {\n build: BuildOpts\n fetch: FetchOpts\n prepare: PrepareOpts\n global: GlobalOpts\n}\n\nexport const options = {\n build: buildOptsSchema,\n fetch: fetchOptsSchema,\n prepare: prepareOptsSchema,\n global: globalOptsSchema,\n}\n\nexport function parseOptions<T extends Cmd>(cmd: T, opts: Options[T]) {\n const res = options[cmd].safeParse({\n ...globalOptsSchema.parse(opts).config,\n ...opts,\n })\n\n if (res.success) {\n return res.data as Options[T]\n }\n console.error(fromError(res.error).toString())\n process.exit(0)\n}\n\nexport function addOptions(cmd: Command, opts: Option[]) {\n opts.forEach(opt => cmd.addOption(opt))\n return cmd\n}\n","import { appendFileSync, cpSync, rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { Octokit } from 'octokit'\nimport { simpleGit } from 'simple-git'\nimport { createDir } from '../utils/functions.js'\nimport type { FetchOpts } from '../schemas/fetch.js'\n\nexport async function getInfos({ username, token, branch }: Pick<FetchOpts, 'username' | 'branch' | 'token'>) {\n const octokit = new Octokit({ auth: token })\n const { data: user } = await octokit.request('GET /users/{username}', { username })\n const { data: repos } = await octokit.request('GET /users/{username}/repos', { username, sort: 'full_name' })\n\n return { user, repos, branch }\n}\n\nexport async function cloneRepo(url: string, projectDir: string, branch: string, includes: string[]) {\n createDir(projectDir, { clean: true })\n\n try {\n const git = simpleGit({ baseDir: projectDir })\n await git.init()\n .addConfig('core.sparseCheckout', 'true', true, 'local')\n .addRemote('origin', url)\n\n for (const item of includes) {\n appendFileSync(resolve(projectDir, '.git/info/sparse-checkout'), `${item}\\n`, 'utf8')\n }\n\n await git.pull('origin', branch)\n\n if (includes.some(item => item.includes('docs'))) {\n cpSync(resolve(projectDir, 'docs'), projectDir, { recursive: true })\n rmSync(resolve(projectDir, 'docs'), { recursive: true })\n }\n rmSync(resolve(projectDir, '.git'), { recursive: true })\n } catch (e) {\n console.error(e)\n }\n}\n","import { resolve } from 'node:path'\nimport { writeFileSync } from 'node:fs'\nimport type { FetchOpts } from '../schemas/fetch.js'\nimport { checkHttpStatus, createDir } from '../utils/functions.js'\nimport { DOCPRESS_DIR, DOCS_DIR, USER_INFOS, USER_REPOS_INFOS } from '../utils/const.js'\nimport { cloneRepo, getInfos } from './git.js'\n\nexport type EnhancedRepository = Awaited<ReturnType<typeof getInfos>>['repos'][number] & {\n docpress: {\n branch: string\n filtered: boolean\n includes: string[]\n projectPath: string\n raw_url: string\n replace_url: string\n }\n}\n\nexport async function checkDoc(repoOwner: FetchOpts['username'], repoName: string, branch: FetchOpts['branch']) {\n const rootReadmeUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/README.md`\n const docsFolderUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/docs`\n const docsReadmeUrl = `https://github.com/${repoOwner}/${repoName}/tree/${branch}/docs/01-readme.md`\n\n const rootReadmeStatus = await checkHttpStatus(rootReadmeUrl)\n const docsFolderStatus = await checkHttpStatus(docsFolderUrl)\n const docsReadmeStatus = await checkHttpStatus(docsReadmeUrl)\n\n return {\n rootReadmeStatus,\n docsFolderStatus,\n docsReadmeStatus,\n }\n}\n\nexport async function fetchDoc({ username, branch, reposFilter, token }: FetchOpts) {\n createDir(DOCPRESS_DIR, { clean: true })\n\n await getInfos({ username, token, branch })\n .then(async ({ user, repos, branch }) => generateInfos(user, repos, branch, reposFilter))\n .then(async ({ repos }) => getDoc(repos, reposFilter))\n}\n\nexport async function enhanceRepositories(repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n const enhancedRepos: EnhancedRepository[] = []\n\n await Promise.all(\n repos.map(async (repo) => {\n const computedBranch = branch ?? repo.default_branch ?? 'main'\n const projectPath = resolve(DOCS_DIR, repo.name)\n const filtered = isRepoFiltered(repo, reposFilter)\n let includes: string[] = []\n\n if (!repo.fork && !repo.private && !filtered) {\n includes = await getSparseCheckout(repo, computedBranch)\n }\n\n enhancedRepos.push({\n ...repo,\n docpress: {\n filtered,\n branch: computedBranch,\n includes,\n projectPath,\n raw_url: `https://raw.githubusercontent.com/${repo.owner.login}/${repo.name}/${computedBranch}`,\n replace_url: `https://github.com/${repo.owner.login}/${repo.name}/tree/${computedBranch}`,\n },\n })\n }),\n )\n\n return enhancedRepos\n}\n\nexport async function getSparseCheckout(repo: Awaited<ReturnType<typeof getInfos>>['repos'][number], branch: FetchOpts['branch']) {\n const docsStatus = await checkDoc(repo.owner.login, repo.name, branch)\n\n const includes: string[] = []\n if (Object.values(docsStatus).every(status => status === 404) || !repo.size) {\n return []\n }\n if (docsStatus.docsFolderStatus !== 404) {\n includes.push('docs/*')\n }\n if (docsStatus.docsFolderStatus === 404 || docsStatus.docsReadmeStatus === 404) {\n includes.push('README.md', '!*/**/README.md')\n }\n return includes\n}\n\nexport async function generateInfos(user: Awaited<ReturnType<typeof getInfos>>['user'], repos: Awaited<ReturnType<typeof getInfos>>['repos'], branch?: FetchOpts['branch'], reposFilter?: FetchOpts['reposFilter']) {\n writeFileSync(USER_INFOS, JSON.stringify(user, null, 2))\n\n const enhancedRepos = await enhanceRepositories(repos, branch, reposFilter)\n writeFileSync(USER_REPOS_INFOS, JSON.stringify(enhancedRepos, null, 2))\n\n return { user, repos: enhancedRepos }\n}\n\nexport async function getDoc(repos?: EnhancedRepository[], reposFilter?: FetchOpts['reposFilter']) {\n if (!repos) {\n console.warn('No repository respect docpress rules.')\n return\n }\n\n await Promise.all(\n repos\n .filter(repo => !isRepoFiltered(repo, reposFilter))\n .map(async repo => cloneRepo(repo.clone_url as string, repo.docpress.projectPath, repo.docpress.branch, repo.docpress.includes)),\n )\n}\n\nexport function isRepoFiltered(repo: EnhancedRepository | Awaited<ReturnType<typeof getInfos>>['repos'][number], reposFilter?: FetchOpts['reposFilter']) {\n const isExcluded = reposFilter?.filter(filter => filter.startsWith('!'))\n .some(filter => repo.name === filter.substring(1))\n const isIncluded = !reposFilter || reposFilter?.filter(filter => !filter.startsWith('!'))\n .includes(repo.name)\n\n const isFiltered = isExcluded || !isIncluded\n\n if ('docpress' in repo && !repo.docpress.includes.length) {\n return true\n }\n\n if (!!repo.clone_url && !repo.fork && !repo.private && !isFiltered) {\n return false\n }\n return true\n}\n","import { createOption } from 'commander'\nimport { globalOptsSchema } from '../schemas/global.js'\n\nexport const globalOpts = [\n createOption('-C, --config <string>', globalOptsSchema.shape.config._def.description),\n]\n","import { createCommand, createOption } from 'commander'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport { fetchOptsSchema } from '../schemas/fetch.js'\nimport { fetchDoc } from '../lib/fetch.js'\nimport type { Config } from '../schemas/global.js'\nimport { globalOpts } from './global.js'\n\nconst cmdName = 'fetch'\n\nexport const fetchOpts = [\n createOption('-b, --branch <string>', fetchOptsSchema.shape.branch._def.description)\n .default(fetchOptsSchema.shape.branch._def.defaultValue()),\n createOption('-g, --git-provider <string>', fetchOptsSchema.shape.gitProvider._def.description)\n .default(fetchOptsSchema.shape.gitProvider._def.defaultValue()),\n createOption('-r, --repos-filter <string>', fetchOptsSchema.shape.reposFilter._def.description),\n createOption('-T, --token <string>', fetchOptsSchema.shape.token._def.description),\n createOption('-u, --username <string>', fetchOptsSchema.shape.username._def.description),\n]\n\nexport const fetchCmd = addOptions(createCommand(cmdName), [...fetchOpts, ...globalOpts])\n .description('Fetch docs with the given username and git provider.')\n .action(async (opts) => {\n await main(opts)\n })\n\nexport async function main(opts: Config) {\n const { username, reposFilter, token, branch, gitProvider } = parseOptions(cmdName, opts)\n\n await fetchDoc({ username, branch, reposFilter, gitProvider, token })\n}\n","import { build as vitepressBuild } from 'vitepress'\nimport { createCommand } from 'commander'\nimport { addOptions } from '../utils/commands.js'\nimport { DOCPRESS_DIR } from '../utils/const.js'\nimport { globalOpts } from './global.js'\n\nconst cmdName = 'build'\n\nexport const buildOpts = []\n\nexport const buildCmd = addOptions(createCommand(cmdName), globalOpts)\n .description('Build vitepress website.')\n .action(async (_opts) => {\n await main()\n })\n\nexport async function main() {\n await vitepressBuild(DOCPRESS_DIR)\n}\n","import type { defineConfig } from 'vitepress'\nimport { deepMerge } from '../utils/functions.js'\nimport type { Page, SidebarProject } from './prepare.js'\n\nconst defaultVitepressConfig: ReturnType<typeof defineConfig> = {\n base: '/',\n lang: 'en-US',\n vite: {\n publicDir: '../public',\n },\n title: 'Home',\n description: 'Docpress',\n srcDir: './docs',\n cleanUrls: false,\n ignoreDeadLinks: 'localhostLinks',\n themeConfig: {\n outline: [2, 3],\n search: {\n provider: 'local',\n options: {\n translations: {\n button: {\n buttonText: 'Search...',\n buttonAriaLabel: 'Search',\n },\n modal: {\n backButtonTitle: 'erase search',\n displayDetails: 'show details',\n noResultsText: 'No results for : ',\n resetButtonTitle: 'cancel search',\n footer: {\n selectText: 'go to',\n navigateText: 'navigate in results',\n closeText: 'close',\n },\n },\n },\n },\n },\n },\n}\n\nexport function getVitepressConfig(sidebar: SidebarProject[], nav: Page[], vitepressConfig?: ReturnType<typeof defineConfig>): Partial<ReturnType<typeof defineConfig>> {\n return vitepressConfig\n ? deepMerge(defaultVitepressConfig, vitepressConfig, { themeConfig: { sidebar, nav } })\n : deepMerge(defaultVitepressConfig, { themeConfig: { sidebar, nav } })\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\n\nexport function replaceRelativePath(file: string, url: string) {\n const fileContent = readFileSync(file, 'utf8')\n const updatedContent = fileContent.replace(/\\[([^\\]]+)\\]\\(\\.\\.\\/([^)]+)\\)/g, (_match, p1, p2) => {\n return `[${p1}](${url}/${p2})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n\nexport function replaceReadmePath(file: string, url: string) {\n const readmeContent = readFileSync(file, 'utf8')\n const updatedContent = readmeContent\n .replace(/\\[([^\\]]+)\\]\\((?!\\.?\\/docs\\/|docs\\/|http)(\\.?\\/)?([^/][^)]+)\\)/g, (_match, p1, _p2, p3) => {\n return `[${p1}](${url}/${p3})`\n })\n .replace(/\\[([^\\]]+)\\]\\((\\.?\\/docs\\/|docs\\/)([^)]*)\\)/g, (_match, p1, _p2, p3) => {\n return `[${p1}](${p3})`\n })\n writeFileSync(file, updatedContent, 'utf8')\n}\n","import { basename, dirname, parse, resolve } from 'node:path'\nimport { appendFileSync, cpSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs'\nimport YAML from 'yaml'\nimport type { defineConfig } from 'vitepress'\nimport type { getUserInfos } from '../utils/functions.js'\nimport { createDir, extractFiles, getMdFiles, prettify } from '../utils/functions.js'\nimport { DOCS_DIR, INDEX_FILE, VITEPRESS_CONFIG } from '../utils/const.js'\nimport { replaceReadmePath, replaceRelativePath } from '../utils/regex.js'\nimport type { EnhancedRepository } from './fetch.js'\n\nexport interface Page {\n text: string\n link: string\n}\n\nexport interface SidebarProject {\n text: string\n collapsed: boolean\n items: Page[]\n}\n\nexport interface Feature {\n title: string\n details: string\n link: string\n}\n\nexport interface Index {\n layout: string\n hero: {\n name: string\n tagline: string\n }\n features: Feature[]\n}\n\nfunction addSources(repoUrl: string, outputPath: string) {\n const fileName = basename(outputPath)\n const title = fileName === 'readme.md' ? '\\n## Sources' : '# Sources'\n\n const sourcesContent = `${title}\\n\\nTake a look at the [project sources](${repoUrl}).\\n`\n\n appendFileSync(outputPath, sourcesContent, 'utf8')\n}\n\n// export function addContribution(outputPath: string) {\n// const sourcesContent = `\n// If you'd like to improve or fix the code, check out the [contribution guidelines](/contribute).\n// `\n\n// appendFileSync(outputPath, sourcesContent, 'utf8')\n// }\n\nexport function generateIndex(features: Feature[], user: ReturnType<typeof getUserInfos>) {\n const { name, login, bio } = user\n return {\n layout: 'home',\n hero: {\n name: name ? `${name}'s projects` : `${login}'s projects`,\n tagline: bio ?? 'Robots are everywhere 🤖', // \\U0001F916\n },\n features,\n }\n}\n\nexport function generateFeatures(repoName: string, description: string, features?: Feature[]) {\n const content = {\n title: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n details: description,\n link: `/${repoName}/readme`,\n }\n\n return features ? [...features, content] : [content]\n}\n\nexport function generateSidebarProject(repoName: string, sidebarPages: Page[]) {\n return {\n text: prettify(repoName, { mode: 'capitalize', replaceDash: true }),\n collapsed: true,\n items: sidebarPages,\n }\n}\n\nexport function generateSidebarPages(repoName: string, fileName: string, sidebarPages?: Page[]) {\n const content = {\n text: fileName === 'readme' ? 'Introduction' : prettify(fileName, { mode: 'capitalize', replaceDash: true }),\n link: `/${repoName}/${fileName}`,\n }\n\n return sidebarPages ? [...sidebarPages, content] : [content]\n}\n\nexport function transformDoc(repositories: EnhancedRepository[], user: ReturnType<typeof getUserInfos>) {\n const features: Feature[] = []\n const sidebar: SidebarProject[] = []\n\n for (const repository of repositories) {\n getMdFiles([repository.docpress.projectPath]).forEach((file) => {\n replaceRelativePath(file, `https://github.com/${repository.owner.login}/${repository.name}/tree/${repository.docpress.branch}`)\n\n if (basename(file).toLowerCase() === 'readme.md') {\n replaceReadmePath(file, `https://github.com/${repository.owner.login}/${repository.name}/tree/${repository.docpress.branch}`)\n }\n })\n\n const sidebarItems = readdirSync(repository.docpress.projectPath)\n .filter((file) => {\n return statSync(resolve(repository.docpress.projectPath, file)).isFile()\n && basename(resolve(repository.docpress.projectPath, file)).endsWith('.md')\n })\n .sort((a, b) => a.localeCompare(b))\n .reduce((acc: Page[], cur, idx, arr) => {\n const file = resolve(repository.docpress.projectPath, cur)\n const filename = prettify(basename(file), { mode: 'lowercase', removeIdx: true })\n\n if (filename !== basename(file)) {\n renameSync(file, resolve(dirname(file), filename))\n }\n\n if (idx === arr.length - 1) {\n let sourceFile\n if (arr.length > 1) {\n sourceFile = resolve(repository.docpress.projectPath, 'sources.md')\n addSources(repository.html_url, sourceFile)\n\n return generateSidebarPages(\n repository.name,\n parse(sourceFile).name,\n generateSidebarPages(repository.name, parse(filename).name, acc),\n )\n }\n sourceFile = resolve(repository.docpress.projectPath, 'readme.md')\n addSources(repository.html_url, sourceFile)\n }\n\n return generateSidebarPages(repository.name, parse(filename).name, acc)\n }, [])\n\n sidebar.push(generateSidebarProject(repository.name, sidebarItems))\n features.push(...generateFeatures(repository.name, repository.description || ''))\n }\n\n const index = generateIndex(features.sort((a, b) => a.title.localeCompare(b.title)), user)\n return {\n sidebar: sidebar.sort((a, b) => a.text.localeCompare(b.text)),\n index,\n }\n}\n\nexport function addExtraPages(paths: string[]) {\n const files = getMdFiles(paths)\n const nav: Page[] = []\n\n for (const file of files) {\n const src = resolve(process.cwd(), file)\n const dest = resolve(DOCS_DIR, prettify(basename(file), { mode: 'lowercase', removeIdx: true }))\n cpSync(src, dest)\n nav.push({\n text: prettify(parse(src).name, { replaceDash: true, removeIdx: true }),\n link: `/${prettify(parse(src).name, { removeIdx: true, mode: 'lowercase' })}`,\n })\n }\n return nav\n}\n\nexport function addContent(path: string | string[], dir: string, fn?: () => void) {\n const files = extractFiles(path)\n\n for (const file of files) {\n const src = resolve(process.cwd(), file)\n const dest = resolve(dir, basename(file))\n if (fn) {\n fn()\n }\n cpSync(src, dest)\n }\n}\n\nexport function parseVitepressConfig(path: string) {\n return JSON.parse(readFileSync(resolve(process.cwd(), path)).toString())\n}\n\nexport function generateVitepressFiles(vitepressConfig: Partial<ReturnType<typeof defineConfig>>, index: Index) {\n createDir(dirname(VITEPRESS_CONFIG))\n\n writeFileSync(VITEPRESS_CONFIG, `export default ${JSON.stringify(vitepressConfig, null, 2)}\\n`)\n writeFileSync(INDEX_FILE, '---\\n'.concat(YAML.stringify(index)))\n}\n","import { resolve } from 'node:path'\nimport { createCommand, createOption } from 'commander'\nimport { DOCPRESS_DIR } from '../utils/const.js'\nimport { getUserInfos, getUserRepos } from '../utils/functions.js'\nimport { addOptions, parseOptions } from '../utils/commands.js'\nimport { getVitepressConfig } from '../lib/vitepress.js'\nimport { addContent, addExtraPages, generateVitepressFiles, transformDoc } from '../lib/prepare.js'\nimport { prepareOptsSchema } from '../schemas/prepare.js'\nimport type { EnhancedRepository } from '../lib/fetch.js'\nimport type { Page } from '../lib/prepare.js'\nimport type { PrepareOpts } from '../schemas/prepare.js'\nimport { globalOpts } from './global.js'\n\nconst cmdName = 'prepare'\n\nexport const prepareOpts = [\n createOption('-c, --extra-public-content <string>', prepareOptsSchema.shape.extraPublicContent._def.description),\n createOption('-p, --extra-header-pages <string>', prepareOptsSchema.shape.extraHeaderPages._def.description),\n createOption('-t, --extra-theme <string>', prepareOptsSchema.shape.extraTheme._def.description),\n createOption('-v, --vitepress-config <string>', prepareOptsSchema.shape.vitepressConfig._def.description),\n]\n\nexport const prepareCmd = addOptions(createCommand(cmdName), [...prepareOpts, ...globalOpts])\n .description('Transform doc to the target vitepress format.')\n .action(async (opts) => {\n await main(opts)\n })\n\nexport async function main(opts: PrepareOpts) {\n const { extraHeaderPages, extraPublicContent, extraTheme, vitepressConfig } = parseOptions(cmdName, opts)\n\n const user = getUserInfos()\n const repositories = getUserRepos()\n .reduce((acc: EnhancedRepository[], cur) => {\n if (cur.clone_url && !cur.fork && !cur.private && cur.docpress.includes.length && !cur.docpress.filtered) {\n return [...acc, cur]\n }\n return acc\n }, [])\n\n const { sidebar, index } = transformDoc(repositories, user)\n const nav: Page[] = []\n\n if (extraHeaderPages) {\n nav.push(...addExtraPages(extraHeaderPages))\n }\n if (extraPublicContent) {\n addContent(extraPublicContent, resolve(DOCPRESS_DIR, 'public'))\n }\n if (extraTheme) {\n addContent(extraTheme, resolve(DOCPRESS_DIR, '.vitepress/theme'))\n }\n\n const config = getVitepressConfig(sidebar, nav, vitepressConfig)\n\n generateVitepressFiles(config, index)\n}\n","import { Command } from 'commander'\nimport pkg from '../package.json' with { type: 'json' }\nimport { fetchCmd, main as fetchFn, fetchOpts } from './commands/fetch.js'\nimport { buildCmd, main as buildFn } from './commands/build.js'\nimport { prepareCmd, main as prepareFn, prepareOpts } from './commands/prepare.js'\nimport { addOptions } from './utils/commands.js'\nimport { globalOpts } from './commands/global.js'\n\nexport function getProgram() {\n const pm = new Command()\n .name('docpress')\n .description('Build your doc website faster than light ⚡️⚡️⚡️')\n .version(`${pkg.version}`)\n .addCommand((fetchCmd))\n .addCommand(prepareCmd)\n .addCommand(buildCmd)\n .action(async (opts, _cmd) => {\n await fetchFn(opts)\n await prepareFn(opts)\n await buildFn()\n })\n .configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n showGlobalOptions: true,\n })\n .enablePositionalOptions()\n .passThroughOptions()\n\n addOptions(pm, [...fetchOpts, ...prepareOpts, ...globalOpts])\n\n return pm\n}\n\nexport function main() {\n const pm = getProgram()\n pm.parseAsync()\n}\n"],"names":["buildOptsSchema","z","DOCPRESS_DIR","resolve","USER_REPOS_INFOS","USER_INFOS","DOCS_DIR","INDEX_FILE","VITEPRESS_CONFIG","checkHttpStatus","url","axios","error","prettify","s","opts","u","createDir","directory","clean","existsSync","rimrafSync","mkdirSync","err","isDir","path","statSync","isFile","extractFiles","paths","readdirSync","file","join","getMdFiles","basename","prettifyEnum","arr","acc","cur","idx","getUserInfos","readFileSync","getUserRepos","deepMerge","objects","obj","key","accValue","objValue","isObject","val","providers","fetchOptsSchema","repos","prepareOptsSchema","globalOptsSchema","options","parseOptions","cmd","res","fromError","addOptions","opt","getInfos","username","token","branch","octokit","Octokit","user","cloneRepo","projectDir","includes","git","simpleGit","item","appendFileSync","cpSync","rmSync","e","checkDoc","repoOwner","repoName","rootReadmeUrl","docsFolderUrl","docsReadmeUrl","rootReadmeStatus","docsFolderStatus","docsReadmeStatus","fetchDoc","reposFilter","generateInfos","getDoc","enhanceRepositories","enhancedRepos","repo","computedBranch","projectPath","filtered","isRepoFiltered","getSparseCheckout","docsStatus","status","writeFileSync","isExcluded","filter","isIncluded","isFiltered","globalOpts","createOption","cmdName","fetchOpts","fetchCmd","createCommand","main","gitProvider","buildCmd","_opts","vitepressBuild","defaultVitepressConfig","getVitepressConfig","sidebar","nav","vitepressConfig","replaceRelativePath","updatedContent","_match","p1","p2","replaceReadmePath","_p2","p3","addSources","repoUrl","outputPath","sourcesContent","generateIndex","features","name","login","bio","generateFeatures","description","content","generateSidebarProject","sidebarPages","generateSidebarPages","fileName","transformDoc","repositories","repository","sidebarItems","a","b","filename","renameSync","dirname","sourceFile","parse","index","addExtraPages","files","src","dest","addContent","dir","fn","generateVitepressFiles","YAML","prepareOpts","prepareCmd","extraHeaderPages","extraPublicContent","extraTheme","config","getProgram","pm","Command","pkg","_cmd","fetchFn","prepareFn","buildFn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAEaA,IAAkBC,EAAE,OAAO,EAAE,GCA7BC,IAAeC,EAAQ,QAAQ,OAAO,UAAU,GAEhDC,IAAmBD,EAAQ,QAAQ,OAAO,4BAA4B,GAEtEE,IAAaF,EAAQ,QAAQ,OAAO,qBAAqB,GAEzDG,IAAWH,EAAQ,QAAQ,OAAO,eAAe,GAEjDI,KAAaJ,EAAQ,QAAQ,OAAO,wBAAwB,GAE5DK,IAAmBL,EAAQ,QAAQ,IAAA,GAAO,+BAA+B;ACJtF,eAAsBM,EAAgBC,GAA8B;AAC9D,MAAA;AAEF,YADiB,MAAMC,GAAM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GAAcW,CAAgB,CAAC,GAEzCC,KACFR,EAAWQ,GAAoBzK,EAAQD,GAAc,QAAQ,CAAC,GAE5D2K,KACFT,EAAWS,GAAY1K,EAAQD,GAAc,kBAAkB,CAAC;AAGlE,QAAM4K,IAAStD,GAAmBC,GAASC,GAAKC,CAAe;AAE/D,EAAA4C,GAAuBO,GAAQf,CAAK;AACtC;AChDO,SAASgB,KAAa;AAC3B,QAAMC,IAAK,IAAIC,GAAQ,EACpB,KAAK,UAAU,EACf,YAAY,iDAAiD,EAC7D,QAAQ,GAAGC,GAAI,OAAO,EAAE,EACxB,WAAYlE,EAAS,EACrB,WAAW0D,EAAU,EACrB,WAAWtD,EAAQ,EACnB,OAAO,OAAOrG,GAAMoK,MAAS;AAC5B,UAAMC,GAAQrK,CAAI,GAClB,MAAMsK,GAAUtK,CAAI,GACpB,MAAMuK,GAAQ;AAAA,EACf,CAAA,EACA,cAAc;AAAA,IACb,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,mBAAmB;AAAA,EAAA,CACpB,EACA,0BACA;AAEQ,SAAAzH,EAAAmH,GAAI,CAAC,GAAGjE,IAAW,GAAG0D,IAAa,GAAG7D,CAAU,CAAC,GAErDoE;AACT;AAEO,SAAS9D,KAAO;AAErB,EADW6D,KACR,WAAW;AAChB;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tobi-or-not/docpress",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"module": "dist/docpress.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"bin": {
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"simple-git": "^3.27.0",
|
|
24
24
|
"vitepress": "^1.4.1",
|
|
25
25
|
"yaml": "^2.6.0",
|
|
26
|
-
"zod": "^3.23.8"
|
|
26
|
+
"zod": "^3.23.8",
|
|
27
|
+
"zod-validation-error": "^3.4.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@antfu/eslint-config": "^3.8.0",
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
"build:docker": "docker build --tag tobi-or-not/docpress --target prod .",
|
|
51
52
|
"build:types": "tsc",
|
|
52
53
|
"build:vite": "vite build",
|
|
53
|
-
"dev": "vite-node ./dev/docpress.ts",
|
|
54
|
+
"dev": "rimraf ./docpress && vite-node ./dev/docpress.ts",
|
|
54
55
|
"format": "eslint . --fix",
|
|
55
56
|
"lint": "eslint .",
|
|
56
57
|
"start": "./bin/docpress.js",
|