Skip to content

Commit

Permalink
chore: use Bun as a package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe committed Jan 28, 2024
1 parent a96f5ec commit 2e3400c
Show file tree
Hide file tree
Showing 17 changed files with 2,754 additions and 2,856 deletions.
71 changes: 32 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: oven-sh/setup-bun@v1
with:
node-version: 20.x
- run: yarn install --frozen-lockfile
- run: npm run format
- run: npm run lint
- run: npm run build
- run: NODE_OPTIONS="--no-warnings" npm test
bun-version: '1.0.25'
- run: bun install
- run: bun run format
- run: bun run lint
- run: bun run build
- run: bun run test

denoify:
name: "Checking if you've done denoify"
Expand All @@ -29,11 +29,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
node-version: '18.x'
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: |
npm run denoify
bun run denoify
if [[ `git status --porcelain` ]]; then
exit 1
fi
Expand All @@ -57,20 +57,18 @@ jobs:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: '1.0.18'
bun-version: '1.0.25'
- run: bun run test:bun

fastly:
name: 'Fastly Compute'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:fastly
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run test:fastly

node:
name: 'Node.js v${{ matrix.node }}'
Expand All @@ -83,42 +81,37 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:node
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run test:node

wrangler:
name: 'Cloudflare Workers'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:wrangler
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run test:wrangler

lambda:
name: 'AWS Lambda'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:lambda
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run test:lambda

lambda-edge:
name: 'Lambda@Edge'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
- run: yarn install --frozen-lockfile
- run: npm run build
- run: npm run test:lambda-edge
- uses: oven-sh/setup-bun@v1
- run: bun install --frozen-lockfile
- run: bun run build
- run: bun run test:lambda-edge
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ sandbox
worker
.wrangler

# Bun
bun.lockb

# Logs
logs
*.log
Expand Down
Binary file added benchmarks/query-param/bun.lockb
Binary file not shown.
Binary file added bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[install.lockfile]
print = "yarn"
2 changes: 1 addition & 1 deletion deno_dist/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Hono } from '../hono.ts'
import type { Schema } from '../types.ts'
import type { HasRequiredKeys } from '../utils/types.ts'

type HonoRequest = typeof Hono.prototype['request']
type HonoRequest = (typeof Hono.prototype)['request']

export type ClientRequestOptions<T = unknown> = keyof T extends never
? {
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/hono-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { getPath, getPathNoStrict, getQueryStrings, mergePath } from './utils/ur

export const COMPOSED_HANDLER = Symbol('composedHandler')

type Methods = typeof METHODS[number] | typeof METHOD_NAME_ALL_LOWERCASE
type Methods = (typeof METHODS)[number] | typeof METHOD_NAME_ALL_LOWERCASE

function defineDynamicClass(): {
new <E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'>(): {
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/middleware/compress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { MiddlewareHandler } from '../../types.ts'
const ENCODING_TYPES = ['gzip', 'deflate'] as const

interface CompressionOptions {
encoding?: typeof ENCODING_TYPES[number]
encoding?: (typeof ENCODING_TYPES)[number]
}

export const compress = (options?: CompressionOptions): MiddlewareHandler => {
Expand Down
4 changes: 2 additions & 2 deletions deno_dist/utils/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const HtmlEscapedCallbackPhase = {
} as const
type HtmlEscapedCallbackOpts = {
buffer?: [string]
phase: typeof HtmlEscapedCallbackPhase[keyof typeof HtmlEscapedCallbackPhase]
phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase]
context: object // An object unique to each JSX tree. This object is used as the WeakMap key.
}
export type HtmlEscapedCallback = (opts: HtmlEscapedCallbackOpts) => Promise<string> | undefined
Expand Down Expand Up @@ -112,7 +112,7 @@ export const escapeToBuffer = (str: string, buffer: StringBuffer): void => {

export const resolveCallback = async (
str: string | HtmlEscapedString,
phase: typeof HtmlEscapedCallbackPhase[keyof typeof HtmlEscapedCallbackPhase],
phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase],
preserveCallbacks: boolean,
context: object,
buffer?: [string]
Expand Down
23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
"test:wrangler": "vitest --run --config ./runtime_tests/wrangler/vitest.config.ts",
"test:lambda": "vitest --run --config ./runtime_tests/lambda/vitest.config.ts",
"test:lambda-edge": "vitest --run --config ./runtime_tests/lambda-edge/vitest.config.ts",
"test:all": "yarn test && yarn test:deno && yarn test:bun && yarn test:fastly && yarn test:node && yarn test:wrangler && yarn test:lambda && yarn test:lambda-edge",
"test:all": "bun run test && bun test:deno && bun test:bun && bun test:fastly && bun test:node && bun test:wrangler && bun test:lambda && bun test:lambda-edge",
"lint": "eslint --ext js,ts,tsx src runtime_tests",
"lint:fix": "eslint --ext js,ts,tsx src runtime_tests --fix",
"format": "prettier --check \"src/**/*.{js,ts,tsx}\" \"runtime_tests/**/*.{js,ts,tsx}\"",
"format:fix": "prettier --write \"src/**/*.{js,ts,tsx}\" \"runtime_tests/**/*.{js,ts,tsx}\"",
"denoify": "rimraf deno_dist && denoify && rimraf \"deno_dist/**/*.test.{ts,tsx}\"",
"copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json ",
"build": "rimraf dist && tsx ./build.ts && yarn copy:package.cjs.json",
"build": "rimraf dist && tsx ./build.ts && bun run copy:package.cjs.json",
"postbuild": "publint",
"watch": "rimraf dist && tsx ./build.ts --watch && yarn copy:package.cjs.json",
"watch": "rimraf dist && tsx ./build.ts --watch && bun run copy:package.cjs.json",
"coverage": "vitest --run --coverage",
"prerelease": "yarn denoify && yarn test:deno && yarn build",
"prerelease": "bun denoify && bun test:deno && bun run build",
"release": "np"
},
"exports": {
Expand Down Expand Up @@ -512,32 +512,29 @@
"@types/crypto-js": "^4.1.1",
"@types/glob": "^8.0.0",
"@types/jsdom": "^21.1.4",
"@types/node": "^20.8.2",
"@types/node-fetch": "^2.6.2",
"@types/node": "20.11.4",
"@types/supertest": "^2.0.12",
"@vitest/coverage-v8": "^1.1.0",
"arg": "^5.0.2",
"crypto-js": "^4.1.1",
"denoify": "^1.6.6",
"esbuild": "^0.15.12",
"eslint": "^8.55.0",
"form-data": "^4.0.0",
"jsdom": "^22.1.0",
"msw": "^1.0.0",
"node-fetch": "2",
"np": "^7.7.0",
"msw": "1.3.2",
"np": "^9.2.0",
"prettier": "^2.6.2",
"publint": "^0.1.8",
"rimraf": "^3.0.2",
"supertest": "^6.3.3",
"tsx": "^3.11.0",
"tsx": "^4.7.0",
"typescript": "^5.3.3",
"vite-plugin-fastly-js-compute": "^0.4.2",
"vitest": "^1.1.0",
"vitest": "^1.2.2",
"wrangler": "3.17.1",
"zod": "^3.20.2"
},
"engines": {
"node": ">=16.0.0"
}
}
}
10 changes: 0 additions & 10 deletions src/client/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/ban-ts-comment */
import FormData from 'form-data'
import { rest } from 'msw'
import { setupServer } from 'msw/node'
import _fetch, { Request as NodeFetchRequest } from 'node-fetch'
import { vi, expectTypeOf } from 'vitest'
import { Hono } from '../hono'
import { parse } from '../utils/cookie'
Expand All @@ -13,13 +10,6 @@ import { validator } from '../validator'
import { hc } from './client'
import type { InferRequestType, InferResponseType } from './types'

// @ts-ignore
global.fetch = _fetch
// @ts-ignore
global.Request = NodeFetchRequest
// @ts-ignore
global.FormData = FormData

describe('Basic - JSON', () => {
const app = new Hono()

Expand Down
2 changes: 1 addition & 1 deletion src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Hono } from '../hono'
import type { Schema } from '../types'
import type { HasRequiredKeys } from '../utils/types'

type HonoRequest = typeof Hono.prototype['request']
type HonoRequest = (typeof Hono.prototype)['request']

export type ClientRequestOptions<T = unknown> = keyof T extends never
? {
Expand Down
9 changes: 9 additions & 0 deletions src/helper/adapter/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { getRuntimeKey } from '.'

describe('getRuntimeKey', () => {
it('Should return the current runtime key', () => {
// Now, using the `bun run test` command.
// But `vitest` depending Node.js will run this test so the RuntimeKey will be `node`.
expect(getRuntimeKey()).toBe('node')
})
})
2 changes: 1 addition & 1 deletion src/hono-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { getPath, getPathNoStrict, getQueryStrings, mergePath } from './utils/ur

export const COMPOSED_HANDLER = Symbol('composedHandler')

type Methods = typeof METHODS[number] | typeof METHOD_NAME_ALL_LOWERCASE
type Methods = (typeof METHODS)[number] | typeof METHOD_NAME_ALL_LOWERCASE

function defineDynamicClass(): {
new <E extends Env = Env, S extends Schema = {}, BasePath extends string = '/'>(): {
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/compress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { MiddlewareHandler } from '../../types'
const ENCODING_TYPES = ['gzip', 'deflate'] as const

interface CompressionOptions {
encoding?: typeof ENCODING_TYPES[number]
encoding?: (typeof ENCODING_TYPES)[number]
}

export const compress = (options?: CompressionOptions): MiddlewareHandler => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const HtmlEscapedCallbackPhase = {
} as const
type HtmlEscapedCallbackOpts = {
buffer?: [string]
phase: typeof HtmlEscapedCallbackPhase[keyof typeof HtmlEscapedCallbackPhase]
phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase]
context: object // An object unique to each JSX tree. This object is used as the WeakMap key.
}
export type HtmlEscapedCallback = (opts: HtmlEscapedCallbackOpts) => Promise<string> | undefined
Expand Down Expand Up @@ -112,7 +112,7 @@ export const escapeToBuffer = (str: string, buffer: StringBuffer): void => {

export const resolveCallback = async (
str: string | HtmlEscapedString,
phase: typeof HtmlEscapedCallbackPhase[keyof typeof HtmlEscapedCallbackPhase],
phase: (typeof HtmlEscapedCallbackPhase)[keyof typeof HtmlEscapedCallbackPhase],
preserveCallbacks: boolean,
context: object,
buffer?: [string]
Expand Down
Loading

0 comments on commit 2e3400c

Please sign in to comment.