Skip to content

Commit f586e2c

Browse files
authored
chore: move from legacy npm lefthook package and change from pre-commit to pre-push (#93)
1 parent 8fc55ba commit f586e2c

5 files changed

Lines changed: 134 additions & 24 deletions

File tree

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ plugins:
44
- path: .yarn/plugins/@yarnpkg/plugin-postinstall.cjs
55
spec: "https://raw.githubusercontent.com/gravitywelluk/yarn-plugin-postinstall/master/bundles/%40yarnpkg/plugin-postinstall.js"
66

7-
postinstall: npx -c 'lefthook install' && yarn build:library
7+
postinstall: npx -c 'lefthook install' && yarn build:library && yarn build:visualizer
88

99
yarnPath: .yarn/releases/yarn-3.6.1.cjs

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ We use [changesets](https://github.com/changesets/changesets) to make it easier
218218
The `package.json` file contains various scripts for common tasks:
219219

220220
- `yarn build:library`: compile the library code with babel.
221+
- `yarn build:visualizer`: compile the Next.js visualizer code.
221222
- `yarn lint:js`: lint files with ESLint.
222223
- `yarn typescript`: type-check files with TypeScript.
223224
- `yarn lint:android`: lint Kotlin files.

lefthook.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
1-
pre-commit:
1+
pre-push:
22
piped: true
33
commands:
44
lint-js:
55
# Run ESLint for root ESLint config JS/TS files if any of them are staged
6-
files: git diff --name-only --cached
6+
files: git diff --name-only --cached origin/main
77
glob: '*.{js,ts,jsx,tsx}'
88
run: yarn lint:js
99
exclude:
1010
- 'packages/visualizer/**'
1111
lint-js-visualizer:
1212
# Run ESLint for visualizer ESLint config JS/TS files if any of them are staged
13-
files: git diff --name-only --cached
14-
glob: 'packages/visualizer/**/*.{js,ts,jsx,tsx}'
13+
files: git diff --name-only --cached origin/main
14+
glob: 'packages/visualizer/*.{js,ts,jsx,tsx}'
1515
run: yarn workspace @callstack/license-kit-visualizer lint
1616
lint-docs:
1717
# Run biome linter for docs files if any of them are staged
18-
files: git diff --name-only --cached
19-
glob: 'docs/**/*.{md,mdx,js,ts,jsx,tsx}'
18+
files: git diff --name-only --cached origin/main
19+
glob: 'docs/*.{md,mdx,js,ts,jsx,tsx}'
2020
run: yarn lint:docs
2121
typescript:
2222
# Run type-checking for TS files if any of them are staged
23-
files: git diff --name-only --cached
23+
files: git diff --name-only --cached origin/main
2424
glob: '*.{js,ts,jsx,tsx}'
2525
run: yarn typescript
26+
exclude:
27+
- 'packages/visualizer/**'
28+
typescript-visualizer:
29+
# Run type-checking for TS files if any of them are staged
30+
files: git diff --name-only --cached origin/main
31+
glob: 'packages/visualizer/*.{js,ts,jsx,tsx}'
32+
run: yarn workspace @callstack/license-kit-visualizer build
2633
lint-android:
2734
# Run linter for Kotlin files if any of them are staged
28-
files: git diff --name-only --cached
35+
files: git diff --name-only --cached origin/main
2936
glob: '*.{kt,kts}'
3037
run: yarn lint:android
3138
lint-objc:
3239
# Run linter for ObjC files if any of them are staged
33-
files: git diff --name-only --cached
40+
files: git diff --name-only --cached origin/main
3441
glob: '*.{h,m,mm}'
3542
run: yarn lint:objc
3643
lint-swift:
3744
# Run linter for Swift files if any of them are staged
38-
files: git diff --name-only --cached
45+
files: git diff --name-only --cached origin/main
3946
glob: '*.{swift}'
4047
run: yarn lint:swift
4148
commit-msg:

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
]
1111
},
1212
"scripts": {
13-
"build:library": "yarn workspace @callstack/licenses build && yarn workspace react-native-legal build-plugins && yarn workspace license-kit build-library && yarn workspace react-native-legal build-library && yarn workspace @callstack/license-kit-visualizer build",
13+
"build:library": "yarn workspace @callstack/licenses build && yarn workspace react-native-legal build-plugins && yarn workspace license-kit build-library && yarn workspace react-native-legal build-library",
14+
"build:visualizer": "yarn workspace @callstack/license-kit-visualizer build",
1415
"lint:js": "eslint \"**/*.{js,ts,tsx}\"",
1516
"lint:docs": "yarn workspace docs check",
1617
"typescript": "yarn build:library && tsc --noEmit -p examples/bare-example/tsconfig.json && tsc --noEmit -p examples/expo-example/tsconfig.json",
@@ -40,12 +41,12 @@
4041
"@changesets/changelog-github": "^0.5.1",
4142
"@changesets/cli": "^2.28.1",
4243
"@commitlint/config-conventional": "17.6.6",
43-
"@evilmartians/lefthook": "1.12.2",
4444
"commitlint": "17.6.6",
4545
"eslint": "^8.46.0",
4646
"eslint-plugin-flowtype": "^8.0.3",
4747
"eslint-plugin-prettier": "^5.5.3",
4848
"expo": "~52.0.36",
49+
"lefthook": "1.12.2",
4950
"prettier": "^3.6.2",
5051
"typescript": "^5.1.3"
5152
},

yarn.lock

Lines changed: 112 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5172,16 +5172,6 @@ __metadata:
51725172
languageName: node
51735173
linkType: hard
51745174

5175-
"@evilmartians/lefthook@npm:1.12.2":
5176-
version: 1.12.2
5177-
resolution: "@evilmartians/lefthook@npm:1.12.2"
5178-
bin:
5179-
lefthook: bin/index.js
5180-
checksum: 99d29d4c700bb22b75838603589896a5368b0512a813df9cb6d807cf2317301cac7154dd53c2714d5a466ee5d3b74166140736201e84bbec29d05b6006c7030f
5181-
conditions: (os=darwin | os=linux | os=win32) & (cpu=x64 | cpu=arm64 | cpu=ia32)
5182-
languageName: node
5183-
linkType: hard
5184-
51855175
"@expo/bunyan@npm:^4.0.0":
51865176
version: 4.0.0
51875177
resolution: "@expo/bunyan@npm:4.0.0"
@@ -17708,6 +17698,117 @@ __metadata:
1770817698
languageName: node
1770917699
linkType: hard
1771017700

17701+
"lefthook-darwin-arm64@npm:1.12.2":
17702+
version: 1.12.2
17703+
resolution: "lefthook-darwin-arm64@npm:1.12.2"
17704+
conditions: os=darwin & cpu=arm64
17705+
languageName: node
17706+
linkType: hard
17707+
17708+
"lefthook-darwin-x64@npm:1.12.2":
17709+
version: 1.12.2
17710+
resolution: "lefthook-darwin-x64@npm:1.12.2"
17711+
conditions: os=darwin & cpu=x64
17712+
languageName: node
17713+
linkType: hard
17714+
17715+
"lefthook-freebsd-arm64@npm:1.12.2":
17716+
version: 1.12.2
17717+
resolution: "lefthook-freebsd-arm64@npm:1.12.2"
17718+
conditions: os=freebsd & cpu=arm64
17719+
languageName: node
17720+
linkType: hard
17721+
17722+
"lefthook-freebsd-x64@npm:1.12.2":
17723+
version: 1.12.2
17724+
resolution: "lefthook-freebsd-x64@npm:1.12.2"
17725+
conditions: os=freebsd & cpu=x64
17726+
languageName: node
17727+
linkType: hard
17728+
17729+
"lefthook-linux-arm64@npm:1.12.2":
17730+
version: 1.12.2
17731+
resolution: "lefthook-linux-arm64@npm:1.12.2"
17732+
conditions: os=linux & cpu=arm64
17733+
languageName: node
17734+
linkType: hard
17735+
17736+
"lefthook-linux-x64@npm:1.12.2":
17737+
version: 1.12.2
17738+
resolution: "lefthook-linux-x64@npm:1.12.2"
17739+
conditions: os=linux & cpu=x64
17740+
languageName: node
17741+
linkType: hard
17742+
17743+
"lefthook-openbsd-arm64@npm:1.12.2":
17744+
version: 1.12.2
17745+
resolution: "lefthook-openbsd-arm64@npm:1.12.2"
17746+
conditions: os=openbsd & cpu=arm64
17747+
languageName: node
17748+
linkType: hard
17749+
17750+
"lefthook-openbsd-x64@npm:1.12.2":
17751+
version: 1.12.2
17752+
resolution: "lefthook-openbsd-x64@npm:1.12.2"
17753+
conditions: os=openbsd & cpu=x64
17754+
languageName: node
17755+
linkType: hard
17756+
17757+
"lefthook-windows-arm64@npm:1.12.2":
17758+
version: 1.12.2
17759+
resolution: "lefthook-windows-arm64@npm:1.12.2"
17760+
conditions: os=win32 & cpu=arm64
17761+
languageName: node
17762+
linkType: hard
17763+
17764+
"lefthook-windows-x64@npm:1.12.2":
17765+
version: 1.12.2
17766+
resolution: "lefthook-windows-x64@npm:1.12.2"
17767+
conditions: os=win32 & cpu=x64
17768+
languageName: node
17769+
linkType: hard
17770+
17771+
"lefthook@npm:1.12.2":
17772+
version: 1.12.2
17773+
resolution: "lefthook@npm:1.12.2"
17774+
dependencies:
17775+
lefthook-darwin-arm64: 1.12.2
17776+
lefthook-darwin-x64: 1.12.2
17777+
lefthook-freebsd-arm64: 1.12.2
17778+
lefthook-freebsd-x64: 1.12.2
17779+
lefthook-linux-arm64: 1.12.2
17780+
lefthook-linux-x64: 1.12.2
17781+
lefthook-openbsd-arm64: 1.12.2
17782+
lefthook-openbsd-x64: 1.12.2
17783+
lefthook-windows-arm64: 1.12.2
17784+
lefthook-windows-x64: 1.12.2
17785+
dependenciesMeta:
17786+
lefthook-darwin-arm64:
17787+
optional: true
17788+
lefthook-darwin-x64:
17789+
optional: true
17790+
lefthook-freebsd-arm64:
17791+
optional: true
17792+
lefthook-freebsd-x64:
17793+
optional: true
17794+
lefthook-linux-arm64:
17795+
optional: true
17796+
lefthook-linux-x64:
17797+
optional: true
17798+
lefthook-openbsd-arm64:
17799+
optional: true
17800+
lefthook-openbsd-x64:
17801+
optional: true
17802+
lefthook-windows-arm64:
17803+
optional: true
17804+
lefthook-windows-x64:
17805+
optional: true
17806+
bin:
17807+
lefthook: bin/index.js
17808+
checksum: 5a6a5bc5b02aca102acd83f7233f53ea6bce5cb27054d5be5abe5804bfc52c3afe0aa667d2b3a35186979f1b93b1e2f2fe768a0c72deee413f5fc2c5a8620815
17809+
languageName: node
17810+
linkType: hard
17811+
1771117812
"leven@npm:^3.1.0":
1771217813
version: 3.1.0
1771317814
resolution: "leven@npm:3.1.0"
@@ -22237,12 +22338,12 @@ __metadata:
2223722338
"@changesets/changelog-github": ^0.5.1
2223822339
"@changesets/cli": ^2.28.1
2223922340
"@commitlint/config-conventional": 17.6.6
22240-
"@evilmartians/lefthook": 1.12.2
2224122341
commitlint: 17.6.6
2224222342
eslint: ^8.46.0
2224322343
eslint-plugin-flowtype: ^8.0.3
2224422344
eslint-plugin-prettier: ^5.5.3
2224522345
expo: ~52.0.36
22346+
lefthook: 1.12.2
2224622347
prettier: ^3.6.2
2224722348
typescript: ^5.1.3
2224822349
languageName: unknown

0 commit comments

Comments
 (0)