Skip to content

Commit

Permalink
Merge pull request #34 from curveball/prep-v1
Browse files Browse the repository at this point in the history
Dropping CommonJS and releasing 1.0
  • Loading branch information
evert authored Jan 15, 2024
2 parents 31a58a2 + df13679 commit d7263e8
Show file tree
Hide file tree
Showing 14 changed files with 816 additions and 3,774 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"env": {
"browser": true,
"node": true,
"es6": true
"es6": true,
"mocha": true
},
"extends": [
"eslint:recommended",
Expand Down Expand Up @@ -61,7 +62,6 @@
"args": "none"
}],
"@typescript-eslint/prefer-for-of": ["error"],
"@typescript-eslint/prefer-optional-chain": ["error"],
"@typescript-eslint/prefer-ts-expect-error": ["error"]
}
}
16 changes: 1 addition & 15 deletions .github/workflows/bun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Bun
uses: antongolub/action-setup-bun@v1
- run: bun install
- run: bun run build
- run: bun run mocha

lint:
name: Lint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x
- run: npm ci
- run: npm run lint
33 changes: 6 additions & 27 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,35 @@ on:

jobs:
node-test:
name: Node.js tests (ESM)
name: Node.js tests

runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [18.x, 20.x, 21.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test

cjs-test:
name: Node.js tests (CommonJS)

runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
matrix:
node-version: [16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }} (CommonJS)
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: make test-cjs

lint:
name: Lint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 18.x
- run: npm ci
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- run: npm ci
- run: npm test

Expand All @@ -23,9 +23,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
Expand All @@ -37,13 +37,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- run: npm ci
- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: '@curveball'
- run: npm publish
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/node_modules

# typescript output
/esm
/cjs
/dist

# Directory used for running tests in CommonJS mode
/cjs-test
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2023 Evert Pot
Copyright (c) 2018-2024 Evert Pot

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 5 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ SOURCE_FILES:=$(shell find src/ -type f -name '*.ts')
all: build

.PHONY:build
build: cjs/build esm/build
build: dist/build

.PHONY:test
test:
npx nyc mocha

.PHONY:test-cjs
test-cjs:
mkdir -p cjs-test
cd test; npx tsc --module commonjs --outdir ../cjs-test
echo '{"type": "commonjs"}' > cjs-test/package.json
cd cjs-test; npx mocha --no-package

.PHONY:lint
lint:
npx eslint --quiet 'src/**/*.ts' 'test/**/*.ts'
Expand All @@ -37,17 +30,8 @@ start: build

.PHONY:clean
clean:
rm -rf dist esm cjs cjs-test

cjs/build: $(SOURCE_FILES)
npx tsc --module commonjs --outDir cjs/
echo '{"type": "commonjs"}' > cjs/package.json
@# Creating a small file to keep track of the last build time
touch cjs/build

rm -rf dist

esm/build: $(SOURCE_FILES)
npx tsc --module es2022 --outDir esm/
echo '{"type": "module"}' > esm/package.json
@# Creating a small file to keep track of the last build time
touch esm/build
dist/build: $(SOURCE_FILES)
npx tsc
touch dist/build
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ try {
```

Lastly, it the package has an interface that makes it easier to work with the
`application/problem+json` format, as defined in [RFC7807][3]. The interface
`application/problem+json` format, as defined in [RFC9457][3]. The interface
has `type`, `title`, `detail` and `instance` properties, which makes it easier
to write a generic interface that emits this JSON error format.

Expand Down Expand Up @@ -180,7 +180,7 @@ export class Gone extends HttpErrorBase {}
export class LengthRequired extends HttpErrorBase {}
export class PreconditionFailed extends HttpErrorBase {}

export class PayloadTooLarge extends HttpErrorBase {
export class ContentTooLarge extends HttpErrorBase {
retryAfter: number | null;
constructor(detail: string|null = null, retryAfter: number|null = null) {}
}
Expand All @@ -190,7 +190,7 @@ export class UnsupportedMediaType extends HttpErrorBase {}
export class RangeNotSatisfiable extends HttpErrorBase {}
export class ExpectationFailed extends HttpErrorBase {}
export class MisdirectedRequest extends HttpErrorBase {}
export class UnprocessableEntity extends HttpErrorBase {}
export class UnprocessableContent extends HttpErrorBase {}
export class Locked extends HttpErrorBase {}
export class FailedDependency extends HttpErrorBase {}
export class TooEarly extends HttpErrorBase {}
Expand Down Expand Up @@ -218,12 +218,11 @@ export class HttpVersionNotSupported extends HttpErrorBase {}
export class VariantAlsoNegotiates extends HttpErrorBase {}
export class UnsufficientStorage extends HttpErrorBase {}
export class LoopDetected extends HttpErrorBase {}
export class NotExtended extends HttpErrorBase {}
export class NetworkAuthenticationRequired extends HttpErrorBase {}
```

...

[1]: https://github.com/curveball/
[2]: http://koajs.com/
[3]: https://tools.ietf.org/html/rfc7807
[3]: https://tools.ietf.org/html/rfc9457
15 changes: 15 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Changelog
=========

1.0.0 (2024-01-15)
------------------

* Finally! Curveball v1. Only took 6 years.
* CommonJS support has been dropped. The previous version of this library
supported both CommonJS and ESM. The effort of this no longer feels worth it.
ESM is the future, so we're dropping CommonJS.
* Now requires Node 18.
* Upgraded to Typescript 5.3.
* To match RFC9110, `UnprocessableEntity` is now `UnprocessableContent`, and
`PayloadToolarge` is now `ContentTooLarge`. The old classes still exist and
have been marked as deprecated.
* Updated references from RFC7807 to RFC9457.


0.5.0 (2023-02-14)
------------------

Expand Down
Loading

0 comments on commit d7263e8

Please sign in to comment.