building docs on the fly is an admittedly terrible idea

This commit is contained in:
MapleLeaf
2022-01-09 02:58:32 -06:00
parent a77185a6a4
commit 7f3b61f19f
5 changed files with 101 additions and 46 deletions

View File

@@ -5,9 +5,12 @@
"scripts": { "scripts": {
"prepare": "node ./scripts/fix-heroicons.js", "prepare": "node ./scripts/fix-heroicons.js",
"serve": "esmo --experimental-import-meta-resolve --experimental-json-modules --no-warnings --enable-source-maps src/main.tsx | pino-colada", "serve": "esmo --experimental-import-meta-resolve --experimental-json-modules --no-warnings --enable-source-maps src/main.tsx | pino-colada",
"dev": "nodemon --inspect --exec \"pnpm serve\" --watch src --ext ts,tsx,md,css", "dev": "npm-run-all --parallel --print-label --race dev-*",
"start": "cross-env NODE_ENV=production pnpm serve", "dev-server": "nodemon --inspect --exec \"pnpm serve\" --watch src --ext ts,tsx,md,css",
"typecheck": "tsc --noEmit" "dev-docs": "typedoc --watch",
"start": "pnpm build-docs && cross-env NODE_ENV=production pnpm serve",
"typecheck": "tsc --noEmit",
"build-docs": "typedoc"
}, },
"dependencies": { "dependencies": {
"@heroicons/react": "^1.0.5", "@heroicons/react": "^1.0.5",
@@ -52,6 +55,7 @@
"browser-sync": "^2.27.7", "browser-sync": "^2.27.7",
"execa": "^6.0.0", "execa": "^6.0.0",
"nodemon": "^2.0.15", "nodemon": "^2.0.15",
"npm-run-all": "^4.1.5",
"rxjs": "^7.5.1", "rxjs": "^7.5.1",
"tsup": "^5.11.10", "tsup": "^5.11.10",
"type-fest": "^2.8.0", "type-fest": "^2.8.0",

View File

@@ -1,29 +0,0 @@
import express, { RequestHandler } from "express"
import PromiseRouter from "express-promise-router"
import * as TypeDoc from "typedoc"
let built = false
const outputDir = "api"
export function serveApiDocs(): RequestHandler {
return PromiseRouter()
.use(async (_, __, next) => {
if (!built) {
const app = new TypeDoc.Application()
app.options.addReader(new TypeDoc.TSConfigReader())
app.options.addReader(new TypeDoc.TypeDocReader())
app.bootstrap()
const project = app.convert()
if (!project) {
throw new Error("Failed to convert project")
}
await app.generateDocs(project, outputDir)
built = true
}
next()
})
.use(express.static(outputDir))
}

View File

@@ -6,7 +6,6 @@ import httpTerminator from "http-terminator"
import pino from "pino" import pino from "pino"
import pinoHttp from "pino-http" import pinoHttp from "pino-http"
import * as React from "react" import * as React from "react"
import { serveApiDocs } from "./api/serve-api-docs"
import { AssetBuilder } from "./asset-builder/asset-builder.js" import { AssetBuilder } from "./asset-builder/asset-builder.js"
import { fromProjectRoot } from "./constants" import { fromProjectRoot } from "./constants"
import { GuidePage } from "./guides/guide-page" import { GuidePage } from "./guides/guide-page"
@@ -25,7 +24,7 @@ const router = PromiseRouter()
.use(pinoHttp({ logger })) .use(pinoHttp({ logger }))
.use(compression()) .use(compression())
.use(builder.middleware()) .use(builder.middleware())
.use("/api", serveApiDocs()) .use("/api", express.static("api"))
.get("/guides/*", async (req: Request<{ 0: string }>, res) => { .get("/guides/*", async (req: Request<{ 0: string }>, res) => {
res res

View File

@@ -1,6 +1,6 @@
{ {
"entryPoints": ["../reacord/library/main.ts"], "entryPoints": ["../reacord/library/main.ts"],
"out": ["public/docs/api"], "out": ["api"],
"tsconfig": "../reacord/tsconfig.json", "tsconfig": "../reacord/tsconfig.json",
"excludeInternal": true, "excludeInternal": true,
"excludePrivate": true, "excludePrivate": true,
@@ -8,5 +8,15 @@
"categorizeByGroup": false, "categorizeByGroup": false,
"preserveWatchOutput": true, "preserveWatchOutput": true,
"githubPages": false, "githubPages": false,
"readme": "none" "readme": "none",
"categoryOrder": [
"Core",
"Embed",
"Button",
"Link",
"Select",
"Action Row",
"Component Event",
"*"
]
} }

91
pnpm-lock.yaml generated
View File

@@ -68,6 +68,7 @@ importers:
markdown-it: ^12.3.0 markdown-it: ^12.3.0
markdown-it-prism: ^2.2.1 markdown-it-prism: ^2.2.1
nodemon: ^2.0.15 nodemon: ^2.0.15
npm-run-all: ^4.1.5
pino: ^7.6.2 pino: ^7.6.2
pino-colada: ^2.2.2 pino-colada: ^2.2.2
pino-http: ^6.5.0 pino-http: ^6.5.0
@@ -110,6 +111,7 @@ importers:
react-dom: 18.0.0-rc.0_react@18.0.0-rc.0 react-dom: 18.0.0-rc.0_react@18.0.0-rc.0
react-ssr-prepass: 1.5.0_react@18.0.0-rc.0 react-ssr-prepass: 1.5.0_react@18.0.0-rc.0
tailwindcss: 3.0.8_cefe482e8d38053bbf3d5815e0c551b3 tailwindcss: 3.0.8_cefe482e8d38053bbf3d5815e0c551b3
typedoc: 0.22.10_typescript@4.5.4
devDependencies: devDependencies:
'@types/browser-sync': 2.26.3 '@types/browser-sync': 2.26.3
'@types/compression': 1.7.2 '@types/compression': 1.7.2
@@ -124,10 +126,10 @@ importers:
browser-sync: 2.27.7 browser-sync: 2.27.7
execa: 6.0.0 execa: 6.0.0
nodemon: 2.0.15 nodemon: 2.0.15
npm-run-all: 4.1.5
rxjs: 7.5.1 rxjs: 7.5.1
tsup: 5.11.10_typescript@4.5.4 tsup: 5.11.10_typescript@4.5.4
type-fest: 2.8.0 type-fest: 2.8.0
typedoc: 0.22.10_typescript@4.5.4
typescript: 4.5.4 typescript: 4.5.4
wait-on: 6.0.0 wait-on: 6.0.0
@@ -5765,6 +5767,10 @@ packages:
resolution: {integrity: sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=} resolution: {integrity: sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=}
dev: true dev: true
/json-parse-better-errors/1.0.2:
resolution: {integrity: sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==}
dev: true
/json-parse-even-better-errors/2.3.1: /json-parse-even-better-errors/2.3.1:
resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}
@@ -5796,7 +5802,7 @@ packages:
/jsonc-parser/3.0.0: /jsonc-parser/3.0.0:
resolution: {integrity: sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==} resolution: {integrity: sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==}
dev: true dev: false
/jsonfile/3.0.1: /jsonfile/3.0.1:
resolution: {integrity: sha1-pezG9l9T9mLEQVx2daAzHQmS7GY=} resolution: {integrity: sha1-pezG9l9T9mLEQVx2daAzHQmS7GY=}
@@ -5903,6 +5909,16 @@ packages:
uc.micro: 1.0.6 uc.micro: 1.0.6
dev: false dev: false
/load-json-file/4.0.0:
resolution: {integrity: sha1-L19Fq5HjMhYjT9U62rZo607AmTs=}
engines: {node: '>=4'}
dependencies:
graceful-fs: 4.2.8
parse-json: 4.0.0
pify: 3.0.0
strip-bom: 3.0.0
dev: true
/localtunnel/2.0.2: /localtunnel/2.0.2:
resolution: {integrity: sha512-n418Cn5ynvJd7m/N1d9WVJISLJF/ellZnfsLnx8WBWGzxv/ntNcFkJ1o6se5quUhCplfLGBNL5tYHiq5WF3Nug==} resolution: {integrity: sha512-n418Cn5ynvJd7m/N1d9WVJISLJF/ellZnfsLnx8WBWGzxv/ntNcFkJ1o6se5quUhCplfLGBNL5tYHiq5WF3Nug==}
engines: {node: '>=8.3.0'} engines: {node: '>=8.3.0'}
@@ -6011,7 +6027,7 @@ packages:
/lunr/2.3.9: /lunr/2.3.9:
resolution: {integrity: sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==} resolution: {integrity: sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==}
dev: true dev: false
/make-dir/3.1.0: /make-dir/3.1.0:
resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
@@ -6057,7 +6073,7 @@ packages:
resolution: {integrity: sha512-0gVrAjo5m0VZSJb4rpL59K1unJAMb/hm8HRXqasD8VeC8m91ytDPMritgFSlKonfdt+rRYYpP/JfLxgIX8yoSw==} resolution: {integrity: sha512-0gVrAjo5m0VZSJb4rpL59K1unJAMb/hm8HRXqasD8VeC8m91ytDPMritgFSlKonfdt+rRYYpP/JfLxgIX8yoSw==}
engines: {node: '>= 12'} engines: {node: '>= 12'}
hasBin: true hasBin: true
dev: true dev: false
/mdn-data/2.0.14: /mdn-data/2.0.14:
resolution: {integrity: sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==} resolution: {integrity: sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==}
@@ -6072,6 +6088,11 @@ packages:
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
dev: false dev: false
/memorystream/0.3.1:
resolution: {integrity: sha1-htcJCzDORV1j+64S3aUaR93K+bI=}
engines: {node: '>= 0.10.0'}
dev: true
/merge-descriptors/1.0.1: /merge-descriptors/1.0.1:
resolution: {integrity: sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=} resolution: {integrity: sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=}
dev: false dev: false
@@ -6308,6 +6329,22 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
dev: false dev: false
/npm-run-all/4.1.5:
resolution: {integrity: sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==}
engines: {node: '>= 4'}
hasBin: true
dependencies:
ansi-styles: 3.2.1
chalk: 2.4.2
cross-spawn: 6.0.5
memorystream: 0.3.1
minimatch: 3.0.4
pidtree: 0.3.1
read-pkg: 3.0.0
shell-quote: 1.7.3
string.prototype.padend: 3.1.3
dev: true
/npm-run-path/2.0.2: /npm-run-path/2.0.2:
resolution: {integrity: sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=} resolution: {integrity: sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=}
engines: {node: '>=4'} engines: {node: '>=4'}
@@ -6645,6 +6682,14 @@ packages:
dependencies: dependencies:
callsites: 3.1.0 callsites: 3.1.0
/parse-json/4.0.0:
resolution: {integrity: sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=}
engines: {node: '>=4'}
dependencies:
error-ex: 1.3.2
json-parse-better-errors: 1.0.2
dev: true
/parse-json/5.2.0: /parse-json/5.2.0:
resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==}
engines: {node: '>=8'} engines: {node: '>=8'}
@@ -6721,7 +6766,6 @@ packages:
engines: {node: '>=4'} engines: {node: '>=4'}
dependencies: dependencies:
pify: 3.0.0 pify: 3.0.0
dev: false
/path-type/4.0.0: /path-type/4.0.0:
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
@@ -6734,10 +6778,15 @@ packages:
resolution: {integrity: sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==} resolution: {integrity: sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==}
engines: {node: '>=8.6'} engines: {node: '>=8.6'}
/pidtree/0.3.1:
resolution: {integrity: sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==}
engines: {node: '>=0.10'}
hasBin: true
dev: true
/pify/3.0.0: /pify/3.0.0:
resolution: {integrity: sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=} resolution: {integrity: sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=}
engines: {node: '>=4'} engines: {node: '>=4'}
dev: false
/pify/4.0.1: /pify/4.0.1:
resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==}
@@ -7398,6 +7447,15 @@ packages:
type-fest: 0.8.1 type-fest: 0.8.1
dev: true dev: true
/read-pkg/3.0.0:
resolution: {integrity: sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=}
engines: {node: '>=4'}
dependencies:
load-json-file: 4.0.0
normalize-package-data: 2.5.0
path-type: 3.0.0
dev: true
/read-pkg/5.2.0: /read-pkg/5.2.0:
resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==}
engines: {node: '>=8'} engines: {node: '>=8'}
@@ -7856,13 +7914,17 @@ packages:
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
engines: {node: '>=8'} engines: {node: '>=8'}
/shell-quote/1.7.3:
resolution: {integrity: sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==}
dev: true
/shiki/0.9.15: /shiki/0.9.15:
resolution: {integrity: sha512-/Y0z9IzhJ8nD9nbceORCqu6NgT9X6I8Fk8c3SICHI5NbZRLdZYFaB233gwct9sU0vvSypyaL/qaKvzyQGJBZSw==} resolution: {integrity: sha512-/Y0z9IzhJ8nD9nbceORCqu6NgT9X6I8Fk8c3SICHI5NbZRLdZYFaB233gwct9sU0vvSypyaL/qaKvzyQGJBZSw==}
dependencies: dependencies:
jsonc-parser: 3.0.0 jsonc-parser: 3.0.0
vscode-oniguruma: 1.6.1 vscode-oniguruma: 1.6.1
vscode-textmate: 5.2.0 vscode-textmate: 5.2.0
dev: true dev: false
/side-channel/1.0.4: /side-channel/1.0.4:
resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==}
@@ -8131,6 +8193,15 @@ packages:
side-channel: 1.0.4 side-channel: 1.0.4
dev: true dev: true
/string.prototype.padend/3.1.3:
resolution: {integrity: sha512-jNIIeokznm8SD/TZISQsZKYu7RJyheFNt84DUPrh482GC8RVp2MKqm2O5oBRdGxbDQoXrhhWtPIWQOiy20svUg==}
engines: {node: '>= 0.4'}
dependencies:
call-bind: 1.0.2
define-properties: 1.1.3
es-abstract: 1.19.1
dev: true
/string.prototype.trimend/1.0.4: /string.prototype.trimend/1.0.4:
resolution: {integrity: sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==} resolution: {integrity: sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==}
dependencies: dependencies:
@@ -8646,7 +8717,7 @@ packages:
minimatch: 3.0.4 minimatch: 3.0.4
shiki: 0.9.15 shiki: 0.9.15
typescript: 4.5.4 typescript: 4.5.4
dev: true dev: false
/typescript/4.5.4: /typescript/4.5.4:
resolution: {integrity: sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==} resolution: {integrity: sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==}
@@ -8782,11 +8853,11 @@ packages:
/vscode-oniguruma/1.6.1: /vscode-oniguruma/1.6.1:
resolution: {integrity: sha512-vc4WhSIaVpgJ0jJIejjYxPvURJavX6QG41vu0mGhqywMkQqulezEqEQ3cO3gc8GvcOpX6ycmKGqRoROEMBNXTQ==} resolution: {integrity: sha512-vc4WhSIaVpgJ0jJIejjYxPvURJavX6QG41vu0mGhqywMkQqulezEqEQ3cO3gc8GvcOpX6ycmKGqRoROEMBNXTQ==}
dev: true dev: false
/vscode-textmate/5.2.0: /vscode-textmate/5.2.0:
resolution: {integrity: sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==} resolution: {integrity: sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==}
dev: true dev: false
/w3c-hr-time/1.0.2: /w3c-hr-time/1.0.2:
resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==}