Skip to content

Commit 547be2a

Browse files
committed
feat!: migrate to Bun, publish ESM-only exports, add framework integrations (#30)
- Tooling: switch scripts/CI to Bun - Packaging: ESM-only build, modern exports map + wildcard subpath exports for integrations (permask/<integration>) - Integrations: express, fastify, h3, nitro, nestjs, hono, koa, itty-router, elysia (thin adapters) - Core: add PermaskError, base64 helpers, portable packBitmasks/unpackBitmasks, add formatBitmask BREAKING CHANGE: package is ESM-only (CJS/UMD entry points removed) BREAKING CHANGE: unpackBitmasks now throws PermaskError on invalid input BREAKING CHANGE: createPermask().create now throws PermaskError for unknown groups
1 parent 985d5c8 commit 547be2a

Some content is hidden

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

52 files changed

+4516
-6640
lines changed

.github/workflows/release.yml

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ on:
55
- main
66

77
permissions:
8-
contents: write # to be able to publish a GitHub release
9-
issues: write # to be able to comment on released issues
10-
pull-requests: write # to be able to comment on released pull requests
11-
id-token: write # to enable use of OIDC for npm provenance
12-
pages: write # to deploy to Pages
13-
actions: read # to read workflow artifacts
14-
8+
contents: read
159

1610
concurrency:
1711
group: ${{ github.workflow }}-${{ github.ref }}
@@ -21,57 +15,80 @@ jobs:
2115
release:
2216
name: Release
2317
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
issues: write
21+
pull-requests: write
22+
id-token: write
2423
steps:
2524
- uses: actions/checkout@v4
2625
with:
2726
fetch-depth: 0
28-
- name: Install pnpm
29-
uses: pnpm/action-setup@v4
27+
- name: Setup Bun
28+
uses: oven-sh/setup-bun@v2
3029
with:
31-
version: 10
30+
bun-version: "1.3.1"
3231
- name: Use Node.js
3332
uses: actions/setup-node@v4
3433
with:
3534
node-version: 22
36-
cache: 'pnpm'
35+
36+
- name: Use cache
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.bun/install/cache
41+
node_modules
42+
*/*/node_modules
43+
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
44+
restore-keys: |
45+
bun-${{ runner.os }}-
46+
3747
- name: Install dependencies
38-
run: pnpm install
48+
run: bun install --frozen-lockfile
3949
- name: Build
40-
run: pnpm build
50+
run: bun run build
4151
- name: Release
4252
env:
4353
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4454
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45-
run: pnpm dlx semantic-release
55+
run: npx semantic-release
4656

4757
playground:
4858
name: Playground
4959
runs-on: ubuntu-latest
60+
permissions:
61+
contents: read
62+
pages: write
63+
id-token: write
5064
needs: release
5165
if: github.ref == 'refs/heads/main'
5266

5367
steps:
5468
- uses: actions/checkout@v4
55-
- name: Install pnpm
56-
uses: pnpm/action-setup@v4
69+
- name: Setup Bun
70+
uses: oven-sh/setup-bun@v2
5771
with:
58-
version: 10
59-
- name: Use Node.js
60-
uses: actions/setup-node@v4
72+
bun-version: "1.3.1"
73+
74+
- name: Use cache
75+
uses: actions/cache@v4
6176
with:
62-
node-version: 22
63-
cache: 'pnpm'
77+
path: |
78+
~/.bun/install/cache
79+
node_modules
80+
*/*/node_modules
81+
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
82+
restore-keys: |
83+
bun-${{ runner.os }}-
84+
6485
- name: Install dependencies
65-
run: |
66-
cd playground/vue
67-
pnpm install
86+
run: bun install --frozen-lockfile
6887
- name: Build playground
69-
run: |
70-
cd playground/vue
71-
pnpm build
88+
working-directory: playground/vue
89+
run: bun run build
7290
- name: Deploy to GitHub Pages
7391
uses: peaceiris/actions-gh-pages@v4
7492
with:
7593
github_token: ${{ secrets.GITHUB_TOKEN }}
7694
publish_dir: ./playground/vue/dist
77-

.github/workflows/test.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Test
2+
23
on:
4+
push:
5+
branches:
6+
- main
37
pull_request:
48
branches:
59
- main
@@ -8,9 +12,6 @@ jobs:
812
test:
913
name: Test
1014
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
node-version: [ 22 ]
1415

1516
permissions:
1617
# Required to checkout the code
@@ -20,19 +21,27 @@ jobs:
2021

2122
steps:
2223
- uses: actions/checkout@v4
23-
- name: Install pnpm
24-
uses: pnpm/action-setup@v4
24+
- name: Setup Bun
25+
uses: oven-sh/setup-bun@v2
2526
with:
26-
version: 10
27-
- name: Use Node.js ${{ matrix.node-version }}
28-
uses: actions/setup-node@v4
27+
bun-version: "1.3.1"
28+
29+
- name: Use cache
30+
uses: actions/cache@v4
2931
with:
30-
node-version: ${{ matrix.node-version }}
31-
cache: 'pnpm'
32+
path: |
33+
~/.bun/install/cache
34+
node_modules
35+
*/*/node_modules
36+
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
37+
restore-keys: |
38+
bun-${{ runner.os }}-
39+
3240
- name: Install dependencies
33-
run: pnpm install
41+
run: bun install --frozen-lockfile
42+
3443
- name: 'Test'
35-
run: pnpm test:coverage
44+
run: bun run test:coverage
3645
- name: 'Report Coverage'
3746
if: always() # Also generate the report if tests are failing
3847
uses: davelosert/vitest-coverage-report-action@v2

AGENTS.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Repository Guidelines
2+
3+
## Project Structure
4+
5+
- `src/`: main TypeScript source (utilities, constants, integrations).
6+
- `src/**/*.test.ts`: Vitest unit tests colocated with code.
7+
- `playground/vue/`: Vue playground for interactive/manual validation.
8+
- `dist/`: build output (generated; don’t edit by hand).
9+
- `.github/workflows/`: CI and release pipelines (Bun-based).
10+
11+
## Build, Test, and Development Commands
12+
13+
This repo uses **Bun** as the package manager and runtime.
14+
Use the version pinned in `package.json#packageManager` (CI matches it).
15+
16+
```bash
17+
bun install # install deps (uses bun.lock)
18+
bun run build # build library bundles + types into dist/
19+
bun run test # run vitest (watch/default mode)
20+
bun run test:coverage # run tests + V8 coverage summary
21+
bun run lint # biome check for formatting + lint
22+
bun run lint:fix # apply biome fixes where safe
23+
```
24+
25+
Playground (from repo root):
26+
27+
```bash
28+
bun --cwd=playground/vue run dev
29+
bun --cwd=playground/vue run build
30+
```
31+
32+
## Coding Style & Naming Conventions
33+
34+
- Language: TypeScript (ESM, `strict`).
35+
- Formatting/linting: **Biome** (`bunx biome check .`).
36+
- Indentation: 2 spaces; line width: 120.
37+
- File naming: `kebab-case.ts` for modules; tests as `*.test.ts`.
38+
39+
## Testing Guidelines
40+
41+
- Framework: **Vitest**.
42+
- Keep tests close to the code they validate (`src/**`).
43+
- Add/extend tests for new behavior and bug fixes; prefer deterministic tests.
44+
- Run locally before pushing: `bun run test:coverage`.
45+
46+
## Commit & Pull Request Guidelines
47+
48+
- This repo’s public changelog is generated by **semantic-release**, so commit messages must follow **Conventional Commits** (enforced by commitlint).
49+
- Prefer small, focused commits (one logical change per commit), because release notes are derived from them.
50+
- Use scopes to keep the changelog readable: `core`, `integrations`, `docs`, `playground`, `ci`, `build`.
51+
- Examples: `feat(core): add formatBitmask utility`, `feat(integrations): add elysia adapter`, `fix(pack): throw on invalid base64`, `chore(ci): switch workflows to bun`.
52+
- Breaking changes: use `feat!:` / `fix!:` or add a `BREAKING CHANGE:` footer.
53+
- PRs should include: a short description, rationale, and any relevant usage notes.
54+
- Requirements: `bun run lint`, `bun run test:coverage`, and `bun run build` must pass; avoid committing generated `dist/` output.

0 commit comments

Comments
 (0)