Skip to content

Commit 5c8a5d6

Browse files
EhespSalakar
andauthored
feat: docs.page 2024 refresh (#359)
Co-authored-by: Mike Diarmid <[email protected]>
1 parent f6466a0 commit 5c8a5d6

File tree

294 files changed

+11498
-26995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

294 files changed

+11498
-26995
lines changed

.eslintignore

-9
This file was deleted.

.eslintrc

-40
This file was deleted.

.github/workflows/pull_request.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Code quality
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
quality:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
- name: Setup Biome
13+
uses: biomejs/setup-biome@v2
14+
with:
15+
version: latest
16+
- name: Run Biome
17+
run: biome ci .

.github/workflows/website.yaml

-22
This file was deleted.

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

3+
# We ignore this since we're using Bun for workspace management, and some environments
4+
# will detect this file and use npm instead of bun.
5+
package-lock.json
6+
37
# dependencies
48
node_modules
59
/.pnp

.prettierignore

-8
This file was deleted.

.prettierrc.json

-10
This file was deleted.

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

CONTRIBUTING.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Contributing
2+
3+
This repository uses [Bun](https://bun.sh/) for workspace and dependency management. To get started, run the following commands:
4+
5+
```bash
6+
bun install
7+
```
8+
9+
The repository is structured as follows:
10+
11+
- `api`: The API server which is served via `https://api.docs.page`. This is an express application which handles tasks such as fetching content from GitHub and markdown parsing.
12+
- `og`: A Next.js application which serves the Open Graph images for documentation pages.
13+
- `website`: A Remix application which serves the main `https://docs.page` website, and the documentation rendering for each repository.
14+
- `packages/cli`: A CLI for running various commands and scripts for initialization, checking etc. Used locally and on CI environments.
15+
16+
## Running docs.page
17+
18+
Generally, you'll want to interface with the website and api. To run these concurrently, you can use the following command:
19+
20+
```bash
21+
bun dev
22+
```
23+
24+
This will start the website on `http://localhost:5173` and the api on `http://localhost:8080`.
25+
26+
> The API requires a `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY` to be set in your environment. These are used to authenticate with the GitHub API. You can create a GitHub App in your GitHub account settings.

api/Dockerfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
FROM oven/bun:1.0.29
16+
FROM oven/bun:1.1.22
1717

1818
ARG BUILD_SHA=default_value
1919
ENV __BUILD_SHA=$BUILD_SHA
2020

2121
WORKDIR /opt/app
22-
COPY . /opt/app
23-
RUN cd /opt/app && bun install --frozen-lockfile --production
22+
COPY . .
23+
RUN bun install --frozen-lockfile --production
24+
25+
WORKDIR /opt/app/api
2426

25-
WORKDIR /opt/app
2627
CMD ["bun","run","start"]

api/bun.lockb

-267 KB
Binary file not shown.

api/package.json

+12-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
"license": "MIT",
99
"dependencies": {
1010
"@code-hike/mdx": "0.7.2",
11+
"@docs.page/cli": "workspace:*",
1112
"@mdx-js/mdx": "2.2.1",
1213
"@octokit/graphql": "5.0.0",
13-
"@types/cors": "^2.8.12",
14+
"@octokit/webhooks": "^13.2.7",
15+
"@shikijs/transformers": "1.12.1",
16+
"@shikijs/twoslash": "^1.12.1",
1417
"@types/express": "^4.17.13",
1518
"@types/morgan": "^1.9.3",
1619
"@types/node": "^18.0.0",
1720
"a2a": "^0.2.0",
1821
"camelcase": "7.0.0",
19-
"cors": "2.8.5",
2022
"dotenv": "16.0.1",
2123
"esbuild": "0.14.47",
2224
"express": "4.18.1",
@@ -26,21 +28,23 @@
2628
"hast-util-parse-selector": "3.1.0",
2729
"is-badge": "^2.1.0",
2830
"js-yaml": "4.1.0",
31+
"jszip": "^3.10.1",
32+
"lodash.get": "^4.4.2",
2933
"mdx-bundler": "9.0.1",
3034
"morgan": "1.10.0",
3135
"node-fetch": "3.2.6",
32-
"pm2": "5.3.0",
33-
"probot": "12.2.8",
36+
"octokit": "^4.0.2",
3437
"rehype-accessible-emojis": "0.3.2",
3538
"rehype-katex": "6.0.2",
3639
"rehype-slug": "5.0.1",
3740
"remark-comment": "1.0.0",
3841
"remark-gfm": "3.0.1",
3942
"remark-math": "5.1.1",
4043
"remark-parse": "10.0.1",
41-
"shiki": "1.1.7",
44+
"shiki": "1.12.1",
4245
"unist-util-visit": "4.1.0",
4346
"zod": "3.22.4",
47+
"zod-to-json-schema": "^3.23.1",
4448
"zod-validation-error": "0.2.2"
4549
},
4650
"scripts": {
@@ -49,9 +53,11 @@
4953
},
5054
"devDependencies": {
5155
"@octokit/webhooks-types": "^6.2.4",
56+
"@types/bun": "^1.1.6",
5257
"@types/js-yaml": "^4.0.5",
58+
"@types/lodash.get": "^4.4.9",
5359
"rollup": "3.9.1",
5460
"ts-node": "^10.8.1",
55-
"typescript": "4.7.4"
61+
"typescript": "5.5.3"
5662
}
5763
}

api/src/app.ts

+16-19
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
1-
import express, { Router, text } from 'express';
2-
import morgan from 'morgan';
3-
import cors from 'cors';
4-
import { config } from 'dotenv';
1+
import express, { Router, text } from "express";
2+
import morgan from "morgan";
53

6-
import bundle from './routes/bundle';
7-
import preview from './routes/preview';
8-
import mdx from './routes/mdx';
9-
import probot from './probot';
10-
import { notFound } from './res';
4+
import { notFound } from "./res";
5+
import bundle from "./routes/bundle";
6+
import preview from "./routes/preview";
7+
import schema from "./routes/schema";
8+
import githubWebhook from "./routes/webhooks.github";
119

12-
config();
10+
import { ENV } from "./env";
1311

14-
const PORT = process.env.PORT || 8080;
12+
const PORT = ENV.PORT;
1513
const app = express();
1614
app.use(text());
17-
app.use(cors());
18-
app.use(morgan('dev'));
15+
app.use(morgan("dev"));
1916
app.use(express.json());
2017
app.use(
2118
express.urlencoded({
2219
extended: true,
2320
}),
2421
);
25-
app.use(probot);
2622

2723
const router = Router();
28-
router.get('/status', (_, res) => res.status(200).send('OK'));
29-
router.post('/preview', preview);
30-
router.get('/bundle', bundle);
31-
router.post('/mdx', mdx);
32-
router.all('*', (_, res) => notFound(res));
24+
router.get("/status", (_, res) => res.status(200).send("OK"));
25+
router.get("/schema.json", schema);
26+
router.post("/preview", preview);
27+
router.get("/bundle", bundle);
28+
router.post("/webhooks/github", githubWebhook);
29+
router.all("*", (_, res) => notFound(res));
3330
app.use(router);
3431

3532
app.listen(PORT, () => {

api/src/bundler/error.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export class BundlerError extends Error {
2+
code: number;
3+
name: string;
4+
source?: string;
5+
6+
constructor({
7+
code,
8+
name,
9+
message,
10+
source,
11+
}: {
12+
code: number;
13+
name: string;
14+
message: string;
15+
source?: string;
16+
}) {
17+
super(message);
18+
this.code = code;
19+
this.name = name;
20+
this.message = message;
21+
this.source = source;
22+
}
23+
}

0 commit comments

Comments
 (0)