-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a11c63b
commit 357179e
Showing
12 changed files
with
4,403 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Test, Build, and Publish | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
|
||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/*' | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Run tests | ||
run: npm test | ||
build: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/*' | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Audit signatures | ||
run: npm audit signatures | ||
- name: Build library | ||
run: npm run build | ||
- name: Prepare artifact | ||
run: | | ||
mkdir -p ./lib/lib && | ||
find ./lib -mindepth 1 -maxdepth 1 ! -name "lib" -exec mv {} ./lib/lib/ \; | ||
cp package.json README.md LICENSE ./lib | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: lib | ||
path: ./lib | ||
publish: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/*' | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: lib | ||
- name: Publish library | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: | | ||
cd ./lib && | ||
npx semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
lib/ | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v20.18.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# `Symbol.metadata` Polyfill | ||
|
||
`@tsmetadata/polyfill` provides the necessary polyfill for legacy runtimes to properly use decorator metadata in TypeScript 5.2+. | ||
|
||
In addition, the library provides the necessary global type declaration for `Symbol.metadata`. | ||
|
||
- [🌱 Install](#-install) | ||
- [⚙️ Usage](#️-usage) | ||
- [🙏 Thanks](#-thanks) | ||
|
||
## 🌱 Install | ||
```bash | ||
# `@tsmetadata/polyfill` is intended to be installed as a dev dependency. | ||
npm install -D @tsmetadata/polyfill | ||
``` | ||
|
||
## ⚙️ Usage | ||
As early as possible, import the polyfill. | ||
```typescript | ||
import '@tsmetadata/polyfill'; | ||
``` | ||
|
||
After doing so, `Symbol.metadata` will be defined. | ||
|
||
## 🙏 Thanks | ||
|
||
Special thanks to Oleksandr Tarasiuk for implementing decorator metadata and to Andrew Branch for releasing an early version of this polyfill. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import '../src'; | ||
|
||
describe('polyfill', () => { | ||
describe('`Symbol.metadata`', () => { | ||
it('should be defined', () => { | ||
expect(Object.hasOwn(Symbol, 'metadata')).toBe(true); | ||
}); | ||
|
||
it('should be of type symbol', () => { | ||
expect(typeof Symbol.metadata).toBe('symbol'); | ||
}); | ||
|
||
it("should be named 'Symbol.metadata'", () => { | ||
expect(Symbol.metadata.toString()).toBe('Symbol(Symbol.metadata)'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"formatter": { | ||
"enabled": true, | ||
"indentStyle": "space", | ||
"indentWidth": 2, | ||
"lineWidth": 80, | ||
"lineEnding": "lf" | ||
}, | ||
"javascript": { | ||
"formatter": { | ||
"arrowParentheses": "always", | ||
"bracketSameLine": true, | ||
"bracketSpacing": true, | ||
"quoteStyle": "single", | ||
"quoteProperties": "asNeeded", | ||
"semicolons": "always", | ||
"trailingCommas": "all" | ||
} | ||
}, | ||
"json": { | ||
"formatter": { | ||
"trailingCommas": "none" | ||
} | ||
}, | ||
"files": { | ||
"ignore": ["./coverage"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Config } from 'jest'; | ||
|
||
const config: Config = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
coverageThreshold: { | ||
global: { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 100, | ||
}, | ||
}, | ||
transform: { | ||
'^.+\\.ts?$': [ | ||
'ts-jest', | ||
{ | ||
diagnostics: false, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.