Skip to content

Commit 4581965

Browse files
authored
refactor: use Bun, Biome.js, Lefthook; upgrade packages (#151)
* refactor: use Bun, Biome.js; upgrade packages * feat: rename Countries JS workflow * chore: update version to 3.2.0; use lefthook; adjust lock file references * fix: update biome schema path and improve test assertions * build: 3.2.0 * feat: rename GitHub Actions workflow for build and test * fix: update AGENTS.md * feat: rename packages/test-node to packages/test-js
1 parent cc382a4 commit 4581965

Some content is hidden

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

56 files changed

+1023
-6811
lines changed

.eslintrc.json

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

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- unit tests are passing
77
- separate changes with commits where necessary
88
- when data needs to be changed, only files within `/data/` were modified
9-
- when there is an update for `package.json`, please also push `package-lock.json` changes
9+
- when there is an update for `package.json`, please also push `bun.lock` changes
1010
- no `/dist/` file changes accepted (they are built with every version bump)
1111
1212
-->

.github/workflows/nodejs.yml renamed to .github/workflows/build-test.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,21 @@ on:
1515
- '!**README*'
1616

1717
jobs:
18-
nodejs:
18+
build-test:
1919
runs-on: ubuntu-latest
2020

21-
strategy:
22-
matrix:
23-
node-version: [20, 18]
24-
2521
steps:
2622
- uses: actions/checkout@v3
2723

28-
- name: Use Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v3
24+
- name: Setup Bun
25+
uses: oven-sh/setup-bun@v1
3026
with:
31-
cache: 'npm'
32-
node-version: ${{ matrix.node-version }}
27+
bun-version: 1.3.0
3328

34-
- name: NPM install
35-
run: npm install --prefer-offline --no-audit
36-
env:
37-
CI: true
29+
- name: Install dependencies
30+
run: bun install --frozen-lockfile
3831

3932
- name: Build & Test
40-
# Runs lint, build & tests
41-
run: npm run ci
33+
run: bun run ci
4234
env:
4335
CI: true

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
# IDE
55
.idea
6-
*.lock
76

87
coverage
9-
.eslintcache
108
.phpunit.cache
119
.turbo
1210

.husky/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/_/pre-commit

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/sh
2+
3+
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
4+
set -x
5+
fi
6+
7+
if [ "$LEFTHOOK" = "0" ]; then
8+
exit 0
9+
fi
10+
11+
call_lefthook()
12+
{
13+
if test -n "$LEFTHOOK_BIN"
14+
then
15+
"$LEFTHOOK_BIN" "$@"
16+
elif lefthook -h >/dev/null 2>&1
17+
then
18+
lefthook "$@"
19+
else
20+
dir="$(git rev-parse --show-toplevel)"
21+
osArch=$(uname | tr '[:upper:]' '[:lower:]')
22+
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
23+
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook"
24+
then
25+
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@"
26+
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook"
27+
then
28+
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@"
29+
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook"
30+
then
31+
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@"
32+
elif test -f "$dir/node_modules/lefthook/bin/index.js"
33+
then
34+
"$dir/node_modules/lefthook/bin/index.js" "$@"
35+
36+
elif go tool lefthook -h >/dev/null 2>&1
37+
then
38+
go tool lefthook "$@"
39+
elif bundle exec lefthook -h >/dev/null 2>&1
40+
then
41+
bundle exec lefthook "$@"
42+
elif yarn lefthook -h >/dev/null 2>&1
43+
then
44+
yarn lefthook "$@"
45+
elif pnpm lefthook -h >/dev/null 2>&1
46+
then
47+
pnpm lefthook "$@"
48+
elif swift package lefthook >/dev/null 2>&1
49+
then
50+
swift package --build-path .build/lefthook --disable-sandbox lefthook "$@"
51+
elif command -v mint >/dev/null 2>&1
52+
then
53+
mint run csjones/lefthook-plugin "$@"
54+
elif uv run lefthook -h >/dev/null 2>&1
55+
then
56+
uv run lefthook "$@"
57+
elif mise exec -- lefthook -h >/dev/null 2>&1
58+
then
59+
mise exec -- lefthook "$@"
60+
elif devbox run lefthook -h >/dev/null 2>&1
61+
then
62+
devbox run lefthook "$@"
63+
else
64+
echo "Can't find lefthook in PATH"
65+
fi
66+
fi
67+
}
68+
69+
call_lefthook run "pre-commit" "$@"

.husky/_/prepare-commit-msg

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/sh
2+
3+
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
4+
set -x
5+
fi
6+
7+
if [ "$LEFTHOOK" = "0" ]; then
8+
exit 0
9+
fi
10+
11+
call_lefthook()
12+
{
13+
if test -n "$LEFTHOOK_BIN"
14+
then
15+
"$LEFTHOOK_BIN" "$@"
16+
elif lefthook -h >/dev/null 2>&1
17+
then
18+
lefthook "$@"
19+
else
20+
dir="$(git rev-parse --show-toplevel)"
21+
osArch=$(uname | tr '[:upper:]' '[:lower:]')
22+
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
23+
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook"
24+
then
25+
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@"
26+
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook"
27+
then
28+
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@"
29+
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook"
30+
then
31+
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@"
32+
elif test -f "$dir/node_modules/lefthook/bin/index.js"
33+
then
34+
"$dir/node_modules/lefthook/bin/index.js" "$@"
35+
36+
elif go tool lefthook -h >/dev/null 2>&1
37+
then
38+
go tool lefthook "$@"
39+
elif bundle exec lefthook -h >/dev/null 2>&1
40+
then
41+
bundle exec lefthook "$@"
42+
elif yarn lefthook -h >/dev/null 2>&1
43+
then
44+
yarn lefthook "$@"
45+
elif pnpm lefthook -h >/dev/null 2>&1
46+
then
47+
pnpm lefthook "$@"
48+
elif swift package lefthook >/dev/null 2>&1
49+
then
50+
swift package --build-path .build/lefthook --disable-sandbox lefthook "$@"
51+
elif command -v mint >/dev/null 2>&1
52+
then
53+
mint run csjones/lefthook-plugin "$@"
54+
elif uv run lefthook -h >/dev/null 2>&1
55+
then
56+
uv run lefthook "$@"
57+
elif mise exec -- lefthook -h >/dev/null 2>&1
58+
then
59+
mise exec -- lefthook "$@"
60+
elif devbox run lefthook -h >/dev/null 2>&1
61+
then
62+
devbox run lefthook "$@"
63+
else
64+
echo "Can't find lefthook in PATH"
65+
fi
66+
fi
67+
}
68+
69+
call_lefthook run "prepare-commit-msg" "$@"

.husky/pre-commit

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npx lint-staged
4+
bunx lefthook run pre-commit

.prettierrc.json

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

AGENTS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Agent Instructions
2+
3+
## Commands
4+
5+
- Build: `bun run build` (builds all packages via turbo)
6+
- Lint: `bun run lint` (runs biome check)
7+
- Lint fix: `bun run lint:fix` (runs biome check --write)
8+
- Format: `bun run format` (runs biome format --write)
9+
- Test: `bun run test` (runs all tests)
10+
- Single test: `cd packages/test-js && bun test <test-file.test.ts>` (Bun test runner)
11+
- CI: `bun run ci` (lint + build + test)
12+
13+
## Code Style
14+
15+
- Use Biome for linting and formatting: 100 char width, single quotes, no semicolons, 2 spaces, trailing commas (ES5)
16+
- TypeScript: Avoid `any` (warn level), use explicit types for exports
17+
- Imports: Use `.ts` extensions in import paths (e.g., `from './types.ts'`)
18+
- Naming: camelCase for functions/variables, PascalCase for types/interfaces (prefix `I` for interfaces, `T` for type aliases)
19+
- Error handling: TypeScript strict mode, no explicit any unless necessary
20+
- Exports: Named exports only (no default exports)
21+
- Files: One primary export per file matching filename (e.g., `getCountryData.ts` exports `getCountryData`)
22+
- Format: Run `bun run format` before committing (enforced by husky pre-commit hook)
23+
- Code should be clear and self-explanatory as much as possible
24+
- Do not write any documentation unless it was asked for
25+
- Do not write unnecessary comments in code, unless: code is not obvious, URLs should be linked to the issue, docs etc

0 commit comments

Comments
 (0)