Skip to content

Commit 7981abd

Browse files
committed
fix: fix release error
- Migrate from Node.js to Bun - Removed Node.js related scripts and dependencies, including check_nodejs.py and test_check_nodejs.py. - Introduced check-bun-node.ts for managing Bun versions. - Updated .gitignore to exclude node_modules. - Added CLAUDE.md for Bun usage guidelines. - Updated package.json for Bun dependencies. - Adjusted CI workflows to utilize Bun instead of Node.js. - Added new Dockerfiles and entrypoint scripts for Bun-based images. This commit transitions the project to use Bun as the primary runtime, aligning with the new development standards.
1 parent f53dbe3 commit 7981abd

29 files changed

+975
-1220
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../CLAUDE.md

.github/workflows/ci.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,14 @@ jobs:
2525
# - name: Set up bashcov
2626
# uses: infertux/bashcov/.github/actions/set-up-bashcov@master
2727

28-
- name: Set up Python
29-
uses: actions/setup-python@v5
30-
with:
31-
python-version: "3.x"
32-
cache: "pipenv"
33-
3428
- name: Install lcov
3529
run: sudo apt-get update && sudo apt-get install -y lcov
3630

37-
- name: Install dependencies
38-
run: |
39-
pip install pipenv
40-
pipenv install --dev
41-
42-
- name: Run tests with coverage
43-
run: |
44-
pipenv run pytest --cov --cov-report=lcov
45-
# bashcov ./commit_changes_test.sh
46-
# ./merge_lcov.sh src merged.lcov
31+
# - name: Run tests with coverage
32+
# run: |
33+
# pipenv run pytest --cov --cov-report=lcov
34+
# # bashcov ./commit_changes_test.sh
35+
# # ./merge_lcov.sh src merged.lcov
4736

4837
- name: Coverage Badge
4938
uses: ImBIOS/lcov-coverage-badge@v1

.github/workflows/release.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626
env:
2727
REGISTRY: imbios
2828
PLATFORMS: linux/amd64,linux/arm64
29-
NODE_MAJOR_VERSIONS_TO_CHECK: 20,22,24
29+
NODE_MAJOR_VERSIONS_TO_CHECK: 20,22,24,25
3030
NODE_VERSIONS_TO_BUILD: ""
3131
BUN_TAGS_TO_CHECK: canary,latest
3232
BUN_VERSIONS_TO_BUILD: ""
@@ -42,28 +42,15 @@ jobs:
4242
- name: Checkout code
4343
uses: actions/checkout@v4
4444

45-
- name: Install jq
46-
run: sudo apt install jq
47-
48-
- name: Set up Python
49-
uses: actions/setup-python@v5
50-
with:
51-
python-version: "3.12"
52-
cache: "pipenv"
53-
54-
- name: Install pipenv
55-
run: pip install pipenv
56-
57-
- name: Install dependencies using pipenv
58-
run: |
59-
pipenv install --dev
45+
- uses: oven-sh/setup-bun@v2
46+
- run: bun install
6047

6148
- name: Check for new releases of nodejs and bun
6249
if: ${{ inputs.nodejs-version == '' && inputs.bun-versions == '' && inputs.distros == '' }}
6350
run: |
6451
set -e
65-
echo "NODE_VERSIONS_TO_BUILD=$(pipenv run python check_nodejs.py ${{ env.NODE_MAJOR_VERSIONS_TO_CHECK }})" >> $GITHUB_ENV
66-
echo "BUN_VERSIONS_TO_BUILD=$(pipenv run python check_bun.py ${{ env.BUN_TAGS_TO_CHECK }})" >> $GITHUB_ENV
52+
echo "NODE_VERSIONS_TO_BUILD=$(bun run check-bun-node.ts --node ${{ env.NODE_MAJOR_VERSIONS_TO_CHECK }})" >> $GITHUB_ENV
53+
echo "BUN_VERSIONS_TO_BUILD=$(bun run check-bun-node.ts --bun ${{ env.BUN_TAGS_TO_CHECK }})" >> $GITHUB_ENV
6754
6855
- name: Setup Docker Buildx
6956
uses: docker/setup-buildx-action@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
*.lcov
66
coverage.info
77
coverage/
8+
node_modules/

CLAUDE.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
description: Use Bun instead of Node.js, npm, pnpm, or vite.
3+
globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
4+
alwaysApply: false
5+
---
6+
7+
Default to using Bun instead of Node.js.
8+
9+
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
10+
- Use `bun test` instead of `jest` or `vitest`
11+
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
12+
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
13+
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
14+
- Bun automatically loads .env, so don't use dotenv.
15+
16+
## APIs
17+
18+
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
19+
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
20+
- `Bun.redis` for Redis. Don't use `ioredis`.
21+
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
22+
- `WebSocket` is built-in. Don't use `ws`.
23+
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
24+
- Bun.$`ls` instead of execa.
25+
26+
## Testing
27+
28+
Use `bun test` to run tests.
29+
30+
```ts#index.test.ts
31+
import { test, expect } from "bun:test";
32+
33+
test("hello world", () => {
34+
expect(1).toBe(1);
35+
});
36+
```
37+
38+
## Frontend
39+
40+
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
41+
42+
Server:
43+
44+
```ts#index.ts
45+
import index from "./index.html"
46+
47+
Bun.serve({
48+
routes: {
49+
"/": index,
50+
"/api/users/:id": {
51+
GET: (req) => {
52+
return new Response(JSON.stringify({ id: req.params.id }));
53+
},
54+
},
55+
},
56+
// optional websocket support
57+
websocket: {
58+
open: (ws) => {
59+
ws.send("Hello, world!");
60+
},
61+
message: (ws, message) => {
62+
ws.send(message);
63+
},
64+
close: (ws) => {
65+
// handle close
66+
}
67+
},
68+
development: {
69+
hmr: true,
70+
console: true,
71+
}
72+
})
73+
```
74+
75+
HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
76+
77+
```html#index.html
78+
<html>
79+
<body>
80+
<h1>Hello, world!</h1>
81+
<script type="module" src="./frontend.tsx"></script>
82+
</body>
83+
</html>
84+
```
85+
86+
With the following `frontend.tsx`:
87+
88+
```tsx#frontend.tsx
89+
import React from "react";
90+
91+
// import .css files directly and it works
92+
import './index.css';
93+
94+
import { createRoot } from "react-dom/client";
95+
96+
const root = createRoot(document.body);
97+
98+
export default function Frontend() {
99+
return <h1>Hello, world!</h1>;
100+
}
101+
102+
root.render(<Frontend />);
103+
```
104+
105+
Then, run index.ts
106+
107+
```sh
108+
bun --hot ./index.ts
109+
```
110+
111+
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.

Pipfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)