diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..2b7c7e0 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,36 @@ +on: [push, pull_request] + +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + + - uses: pnpm/action-setup@v2 + with: + version: 8.6.7 + + - name: Retrieve the cached "node_modules" directory (if present) + uses: actions/cache@v2 + id: node-cache + with: + path: node_modules + key: node-modules-${{ runner.os }}-${{ hashFiles('package-lock.json') }} + + - name: Install dependencies (if the cached directory was not found) + if: steps.node-cache.outputs.cache-hit != 'true' + run: pnpm i + + - name: Create the docs directory locally in CI + run: pnpm build:docs + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + branch: gh-pages + folder: docs + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 0090cc7..28bd622 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# TypeDoc generated documentation +/docs + # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore # Logs diff --git a/bun.lockb b/bun.lockb index e07a2c9..1b57678 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 5c66e72..4a28337 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,19 @@ "type": "module", "devDependencies": { "@electron/asar": "^3.2.7", - "bun-types": "latest" + "bun-types": "latest", + "typedoc": "^0.25.2" }, "peerDependencies": { "typescript": "^5.0.0" }, "dependencies": { "@tybys/chromium-pickle-js": "^1.0.0" + }, + "scripts": { + "build": "bun scripts/build.ts", + "build:docs": "typedoc src/index.ts", + "pretest": "bun scripts/cleanup-test-data.ts", + "test": "bun test" } -} \ No newline at end of file +} diff --git a/scripts/build.ts b/scripts/build.ts new file mode 100644 index 0000000..615c896 --- /dev/null +++ b/scripts/build.ts @@ -0,0 +1,14 @@ +import { rm } from "fs/promises"; + +const outdir = "dist"; + +await rm(outdir, { recursive: true, force: true }); + +await Bun.build({ + entrypoints: ["src/index.ts"], + target: "node", + minify: true, + sourcemap: "external", + outdir, + splitting: true, +}); diff --git a/scripts/cleanup-test-data.ts b/scripts/cleanup-test-data.ts new file mode 100755 index 0000000..0f4d3b5 --- /dev/null +++ b/scripts/cleanup-test-data.ts @@ -0,0 +1,13 @@ +import { rm, readdir } from "fs/promises"; +import { join as joinPaths } from "path"; + +// rm -f test/ignore/*.{js,json,txt} +// rm -f test/ignore/app-*.asar + +const ignoreDir = "test/ignore"; + +for (const file of await readdir(ignoreDir)) { + if (/\.(js|json|txt)$|^app-.+\.asar/.test(file)) { + await rm(joinPaths(ignoreDir, file)); + } +} diff --git a/test/cleanupTestData.sh b/test/cleanupTestData.sh deleted file mode 100755 index 8c93fdb..0000000 --- a/test/cleanupTestData.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -rm -f test/ignore/*.{js,json,txt} -rm -f test/ignore/app-*.asar diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 0000000..f80995e --- /dev/null +++ b/typedoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://typedoc.org/schema.json", + "basePath": "src" +}