Skip to content

Commit

Permalink
Run with Bun instead of Node
Browse files Browse the repository at this point in the history
- Replaces Yarn with Bun
- Replaces Node CI/CD actions with Bun
- Replaces Eslint with Biome & Prettier. Eslint 9 migration still seems far away.
- Removes Striker, as I seem to use it so rarely nowadays.
  • Loading branch information
stscoundrel committed Sep 21, 2024
1 parent daf5b95 commit f1bf6cf
Show file tree
Hide file tree
Showing 23 changed files with 76 additions and 5,788 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

19 changes: 0 additions & 19 deletions .eslintrc.js

This file was deleted.

10 changes: 0 additions & 10 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: monthly
open-pull-requests-limit: 25
groups:
dependencies:
patterns:
- "*" # Match all dependencies to one PR.

- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v4
- name: Build with Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --production=false
- run: yarn build
- name: Build with Bun
uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun run build
env:
CI: true
14 changes: 4 additions & 10 deletions .github/workflows/coverage-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4
- name: Coverage with Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --production=false
- run: yarn test:coverage
- name: Coverage with Bun
uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun test --coverage
env:
CI: true
14 changes: 4 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4
- name: Lint with Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --production=false
- run: yarn lint
- name: Lint with Bun
uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun run lint
env:
CI: true
23 changes: 0 additions & 23 deletions .github/workflows/mutation-test.yml

This file was deleted.

7 changes: 3 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: oven-sh/setup-bun@v2
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn
- run: yarn publish --non-interactive
- run: bun install
- run: bunx npm@latest publish --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
14 changes: 4 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v4
- name: Test with Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --production=false
- run: yarn test:unit
- name: Test with Bun
uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun test
env:
CI: true
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# TypeScript Template

Template repo for generic TypeScript / Node.js library with tests & lint
Template repo for generic TypeScript / Node.js library with tests, lint and CI/CD pipelines.

### Install

`yarn add name-of-the-package`
`npm install name-of-the-package`

##### Usage

Expand Down
6 changes: 0 additions & 6 deletions babel.config.js

This file was deleted.

29 changes: 29 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": []
},
"formatter": {
"enabled": false
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
}
}
Binary file added bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[test]

coverageThreshold = 0.9
13 changes: 0 additions & 13 deletions jest.config.ts

This file was deleted.

41 changes: 14 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typescript-template",
"version": "1.0.0",
"description": "Template repo for generic TypeScript / Node.js library with tests & lint",
"description": "Template repo for generic TypeScript / Node.js library with tests, lint and CI",
"repository": "https://github.com/stscoundrel/typescript-template.git",
"author": "stscoundrel <[email protected]>",
"license": "MIT",
Expand All @@ -15,34 +15,21 @@
"node": ">=12.0.0"
},
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.23.0",
"@babel/preset-env": "^7.22.20",
"@babel/preset-typescript": "^7.23.0",
"@stryker-mutator/core": "^7.1.1",
"@stryker-mutator/jest-runner": "^7.1.1",
"@types/jest": "^29.5.5",
"devDependencies": {
"@biomejs/biome": "1.9.2",
"@types/bun": "latest",
"@types/node": "^20.8.0",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"babel-jest": "^29.7.0",
"eslint": "^8.50.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.4.2",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"prettier": "^3.3.3",
"typescript": "^5.2.2"
},
"scripts": {
"lint": "eslint .",
"fix": "eslint . --fix",
"jest": "jest --verbose --runInBand --passWithNoTests",
"test:unit": "yarn jest",
"test:mutation": "stryker run",
"test:coverage": "jest --coverage --coverageThreshold='{\"global\":{\"statements\":\"90\", \"functions\":\"90\", \"branches\":\"90\", \"lines\":\"90\"}}'",
"build": "tsc",
"prepublishOnly": "yarn build && yarn test:unit"
"prettier:fix": "prettier src tests --write",
"prettier:check": "prettier src tests --check",
"biome:check": "bunx biome lint src tests",
"biome:fix": "bunx biome lint --write src tests",
"lint": "bun run prettier:check && bun run biome:check",
"build": "bun tsc",
"prepublishOnly": "npm run build",
"test:coverage": "bun run test --coverage"
}
}
}
Empty file removed setupTests.ts
Empty file.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const example = (): string => 'test string';
export const example = (): string => "test string";

export default {
example,
Expand Down
15 changes: 0 additions & 15 deletions stryker.conf.js

This file was deleted.

11 changes: 6 additions & 5 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import exampleModule from '../src';
import { describe, test, expect } from "bun:test";
import exampleModule from "../src";

describe('Example tests', () => {
test('Test suite runs', () => {
describe("Example tests", () => {
test("Test suite runs", () => {
expect(true).toBeTruthy();
expect(false).toBeFalsy();
});

test('Example function returns correct string', () => {
test("Example function returns correct string", () => {
const result = exampleModule.example();

expect(result).toBe('test string');
expect(result).toBe("test string");
});
});
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"skipLibCheck": true,
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
Expand Down
Loading

0 comments on commit f1bf6cf

Please sign in to comment.