Skip to content
This repository was archived by the owner on Mar 29, 2025. It is now read-only.

Commit 5215bd1

Browse files
committed
ci,build: add lint and format jobs
1 parent df20460 commit 5215bd1

File tree

5 files changed

+77
-9
lines changed

5 files changed

+77
-9
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ on:
1010
workflow_dispatch:
1111

1212
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
- name: Setup node
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: lts/hydrogen # 18
22+
cache: 'npm'
23+
- run: npm clean-install
24+
- run: npm run format-check
25+
26+
test-types:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v3
31+
- name: Setup node
32+
uses: actions/setup-node@v3
33+
with:
34+
node-version: lts/hydrogen # 18
35+
cache: 'npm'
36+
- run: npm clean-install
37+
- run: npm run test-types
38+
1339
test:
1440
runs-on: ubuntu-latest
1541
strategy:
@@ -27,4 +53,3 @@ jobs:
2753
check-latest: true
2854
- run: npm clean-install
2955
- run: npm run test
30-
- run: npm run test-types

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"types/index.d.ts"
2929
],
3030
"scripts": {
31+
"_format": "find lib types test -type f -name '*.ts' -o -name '*.mjs' -name '*.cjs' | xargs prettier",
32+
"format": "npm run _format -- --write",
33+
"format-check": "npm run _format -- --check",
3134
"test": "ava",
3235
"test-types": "tsd",
3336
"watch": "ava --watch"
@@ -40,6 +43,7 @@
4043
"devDependencies": {
4144
"@types/node": "^16.4.0",
4245
"ava": "^5.0.1",
46+
"prettier": "^2.8.8",
4347
"sinon": "^11.1.2",
4448
"tsd": "^0.28.1",
4549
"typescript": "^3.6.0"

types/index.d.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,15 @@ export namespace V1 {
114114
options?: Omit<ConsumeOptionsBuffer<true>, 'assertion'>,
115115
): Promise<CompleteResultBuffer>
116116
function generateKey(purpose: 'local' | 'public'): Promise<KeyObject>
117-
function generateKey(purpose: 'local' | 'public', options: { format: 'keyobject' }): Promise<KeyObject>
117+
function generateKey(
118+
purpose: 'local' | 'public',
119+
options: { format: 'keyobject' },
120+
): Promise<KeyObject>
118121
function generateKey(purpose: 'local', options: { format: 'paserk' }): Promise<string>
119-
function generateKey(purpose: 'public', options: { format: 'paserk' }): Promise<{ secretKey: string, publicKey: string }>
122+
function generateKey(
123+
purpose: 'public',
124+
options: { format: 'paserk' },
125+
): Promise<{ secretKey: string; publicKey: string }>
120126
}
121127
export namespace V2 {
122128
function sign(
@@ -146,7 +152,10 @@ export namespace V2 {
146152
): Promise<CompleteResultBuffer>
147153
function generateKey(purpose: 'public'): Promise<KeyObject>
148154
function generateKey(purpose: 'public', options: { format: 'keyobject' }): Promise<KeyObject>
149-
function generateKey(purpose: 'public', options: { format: 'paserk' }): Promise<{ secretKey: string, publicKey: string }>
155+
function generateKey(
156+
purpose: 'public',
157+
options: { format: 'paserk' },
158+
): Promise<{ secretKey: string; publicKey: string }>
150159
function bytesToKeyObject(bytes: Buffer): KeyObject
151160
function keyObjectToBytes(keyObject: KeyObject): Buffer
152161
}
@@ -202,9 +211,15 @@ export namespace V3 {
202211
options?: ConsumeOptionsBuffer<true>,
203212
): Promise<CompleteResultBuffer>
204213
function generateKey(purpose: 'local' | 'public'): Promise<KeyObject>
205-
function generateKey(purpose: 'local' | 'public', options: { format: 'keyobject' }): Promise<KeyObject>
214+
function generateKey(
215+
purpose: 'local' | 'public',
216+
options: { format: 'keyobject' },
217+
): Promise<KeyObject>
206218
function generateKey(purpose: 'local', options: { format: 'paserk' }): Promise<string>
207-
function generateKey(purpose: 'public', options: { format: 'paserk' }): Promise<{ secretKey: string, publicKey: string }>
219+
function generateKey(
220+
purpose: 'public',
221+
options: { format: 'paserk' },
222+
): Promise<{ secretKey: string; publicKey: string }>
208223
function bytesToKeyObject(bytes: Buffer): KeyObject
209224
function keyObjectToBytes(keyObject: KeyObject): Buffer
210225
}
@@ -236,7 +251,10 @@ export namespace V4 {
236251
): Promise<CompleteResultBuffer>
237252
function generateKey(purpose: 'public'): Promise<KeyObject>
238253
function generateKey(purpose: 'public', options: { format: 'keyobject' }): Promise<KeyObject>
239-
function generateKey(purpose: 'public', options: { format: 'paserk' }): Promise<{ secretKey: string, publicKey: string }>
254+
function generateKey(
255+
purpose: 'public',
256+
options: { format: 'paserk' },
257+
): Promise<{ secretKey: string; publicKey: string }>
240258
function bytesToKeyObject(bytes: Buffer): KeyObject
241259
function keyObjectToBytes(keyObject: KeyObject): Buffer
242260
}

types/index.test-d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as paseto from '.'
2-
import {expectType} from 'tsd';
3-
2+
import { expectType } from 'tsd'
43
;(async () => {
54
{
65
const key = await paseto.V2.generateKey('public')

0 commit comments

Comments
 (0)