mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-21 02:40:08 +00:00
chore(website): Cleanup docusaurus setup (#3355)
* Update docusaurus typescript setup for v3 And fix lint-staged and eslint * Enable automatic JSX runtime * Remove babel config and dependencies * update yarn.lock * add typecheck to site workflow * update typedoc config * downgrade docusaurus packages * Update site.yml * Type context and options in webpack-docusaurus-plugin.ts --------- Co-authored-by: Matt Hatcher <3768988+MatthewSH@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
||||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
// these two paths may vary depending on where you place this script, and your project structure including where typedoc generates its output files.
|
||||
const typedocOutPath = await import('../typedoc.json', {
|
||||
assert: { type: 'json' },
|
||||
}).then((module) => module.default.out)
|
||||
const typedocOutPath = await import('../typedoc.json', { assert: { type: 'json' } }).then((module) => module.default.out)
|
||||
|
||||
async function* walk(dir) {
|
||||
for await (const d of await fs.promises.opendir(dir)) {
|
||||
@@ -18,13 +19,33 @@ for await (let filepath of walk(typedocOutPath)) {
|
||||
if (filepath.endsWith('.json')) continue
|
||||
let file = fs.readFileSync(filepath, 'utf-8')
|
||||
|
||||
if (filepath.endsWith('generated/README.md')) {
|
||||
if (filepath.endsWith(`generated${path.sep}README.md`)) {
|
||||
file = [
|
||||
'discordeno-monorepo / [Modules](modules.md)',
|
||||
'',
|
||||
'# Discordeno',
|
||||
'',
|
||||
'Thank you for using Discordeno. These docs are generated automatically. If you see any issues please contact us on [Discord](https://discord.gg/ddeno)',
|
||||
'',
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
if (filepath.endsWith(`generated${path.sep}modules.md`)) {
|
||||
file = [
|
||||
'[discordeno-monorepo](README.md) / Modules',
|
||||
'',
|
||||
'# discordeno-monorepo',
|
||||
'',
|
||||
'## Table of contents',
|
||||
'',
|
||||
'### Modules',
|
||||
'',
|
||||
'- [@discordeno/bot](modules/Bot)',
|
||||
'- [@discordeno/gateway](modules/Gateway)',
|
||||
'- [@discordeno/rest](modules/Rest)',
|
||||
'- [@discordeno/types](modules/Types)',
|
||||
'- [@discordeno/utils](modules/Utils)',
|
||||
'',
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
@@ -53,10 +74,9 @@ for await (let filepath of walk(typedocOutPath)) {
|
||||
|
||||
for (const form of cleanForms) {
|
||||
// Clean the file of the ugly forms
|
||||
file = file.replace(new RegExp(form.ugly, 'gi'), form.clean || '')
|
||||
const lastIndex = filepath.lastIndexOf('/')
|
||||
file = file.replace(new RegExp(form.ugly, 'gi'), form.clean ?? '')
|
||||
// Clean the file name of the ugly forms
|
||||
if (!filepath.endsWith(`${form.ugly}md`)) filepath = filepath.replace(new RegExp(form.ugly, 'gi'), form.clean || '')
|
||||
if (!filepath.endsWith(`${form.ugly}md`)) filepath = filepath.replace(new RegExp(form.ugly, 'gi'), form.clean ?? '')
|
||||
}
|
||||
|
||||
file = file.replace(/(?<!\\)(<|>|,|=|\{|\})/gi, `\\$1`)
|
||||
@@ -68,13 +88,10 @@ for await (let filepath of walk(typedocOutPath)) {
|
||||
filepath = filepath.replace('/md', '/README.md')
|
||||
}
|
||||
|
||||
// if (filepath.includes('/generated/classes')) console.log('file in classes 2', filepath)
|
||||
if (filepath.includes('/generated/modules/discordeno_')) {
|
||||
const mod = filepath.substring(filepath.lastIndexOf('_') + 1)
|
||||
filepath = filepath.substring(0, filepath.lastIndexOf('/')) + `/${mod[0].toUpperCase()}${mod.substring(1)}`
|
||||
}
|
||||
|
||||
fs.writeFileSync(filepath, file, function (err, result) {
|
||||
if (err) throw err
|
||||
})
|
||||
fs.writeFileSync(filepath, file)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user