alina sireneva
05077aa640
Some checks failed
Build and deploy typedoc / build (push) Waiting to run
Build and deploy docs / build (push) Successful in 1m56s
Tests / test-deno (push) Successful in 1m56s
Tests / test-bun (push) Successful in 2m5s
Tests / test-node (node22) (push) Successful in 2m14s
Tests / test-node (node20) (push) Successful in 2m21s
Tests / test-node (node18) (push) Successful in 2m29s
Tests / test-web (chromium) (push) Successful in 2m21s
Tests / test-web (firefox) (push) Successful in 1m33s
Tests / lint (push) Failing after 7m0s
Tests / e2e (push) Has been skipped
Tests / e2e-deno (push) Has been skipped
Co-authored-by: Kamilla 'ova <me@kamillaova.dev> Co-authored-by: Alina Chebakova <chebakov05@gmail.com> Co-authored-by: Kravets <57632712+kravetsone@users.noreply.github.com> Co-authored-by: starkow <hello@starkow.dev> Co-authored-by: sireneva <150665887+sireneva@users.noreply.github.com>
90 lines
3.3 KiB
JavaScript
90 lines
3.3 KiB
JavaScript
import { writeFile } from 'node:fs/promises'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { exec } from '@fuman/build'
|
|
import { asNonNull } from '@fuman/utils'
|
|
|
|
/** @type {import('@fuman/build').RootConfig} */
|
|
export default {
|
|
jsr: {
|
|
exclude: ['**/*.{test,bench,test-utils}.ts', '**/__fixtures__/**'],
|
|
sourceDir: 'src',
|
|
transformCode: (path, code) => {
|
|
if (!path.endsWith('.ts')) return code
|
|
if (!code.match('<deno-(insert|remove|tsignore)>')) return code
|
|
|
|
// deno is missing some types, so we have to add them manually
|
|
// i dont want to manually write types for them, so we just declare them as `any` in a comment
|
|
// and un-comment them when building for deno
|
|
//
|
|
// this way we can still have proper types in the code, while also being able to build for deno
|
|
// very much a crutch, but welp, deno sucks
|
|
|
|
let insertContent = code.match(/<deno-insert>(.*?)<\/deno-insert>/s)
|
|
while (insertContent) {
|
|
code = code.slice(0, insertContent.index)
|
|
+ insertContent[1].replace(/\/\/\s*/g, '')
|
|
+ code.slice(insertContent.index + insertContent[0].length)
|
|
|
|
insertContent = code.match(/<deno-insert>(.*?)<\/deno-insert>/s)
|
|
}
|
|
|
|
let removeContent = code.match(/<deno-remove>(.*?)<\/deno-remove>/s)
|
|
while (removeContent) {
|
|
code = code.slice(0, removeContent.index) + code.slice(removeContent.index + removeContent[0].length)
|
|
|
|
removeContent = code.match(/<deno-remove>(.*?)<\/deno-remove>/s)
|
|
}
|
|
|
|
let tsIgnoreContent = code.match(/\/\/\s*<deno-tsignore>/)
|
|
while (tsIgnoreContent) {
|
|
code = `${code.slice(0, tsIgnoreContent.index)}/* @ts-ignore */${code.slice(tsIgnoreContent.index + tsIgnoreContent[0].length)}`
|
|
|
|
tsIgnoreContent = code.match(/\/\/\s*<deno-tsignore>/)
|
|
}
|
|
|
|
return code
|
|
},
|
|
},
|
|
versioning: {
|
|
exclude: [
|
|
'**/*.test.ts',
|
|
'**/*.test-utils.ts',
|
|
'**/__fixtures__/**',
|
|
'**/*.md',
|
|
'typedoc.cjs',
|
|
'{scripts,dist,tests,private}/**',
|
|
],
|
|
beforeReleaseCommit: async (packages) => {
|
|
const OUT_FILE = fileURLToPath(new URL('./scripts/latest-versions.json', import.meta.url))
|
|
|
|
const versions = {}
|
|
|
|
for (const { json, root } of packages) {
|
|
if (root) continue
|
|
versions[asNonNull(json.name)] = asNonNull(json.version)
|
|
}
|
|
|
|
await writeFile(OUT_FILE, JSON.stringify(versions, null, 4))
|
|
await exec(['git', 'add', 'scripts/latest-versions.json'])
|
|
},
|
|
},
|
|
typedoc: {
|
|
out: 'dist/typedoc',
|
|
excludePackages: [
|
|
'@mtcute/tl',
|
|
'@mtcute/create-bot',
|
|
],
|
|
validation: {
|
|
notExported: true,
|
|
invalidLink: false,
|
|
notDocumented: false,
|
|
},
|
|
plugin: [
|
|
'./.config/typedoc/plugin-external-links.js',
|
|
'./.config/typedoc/plugin-umami.js',
|
|
'./.config/typedoc/plugin-fix-cfpages.js',
|
|
],
|
|
gitRemote: 'https://github.com/mtcute/mtcute',
|
|
},
|
|
viteConfig: '.config/vite.build.ts',
|
|
}
|