Skip to content

Commit bc6eb55

Browse files
committed
add prebuild script to collect peerdeps
1 parent 6e88393 commit bc6eb55

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

config/collect-peerdeps.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import fs from 'node:fs/promises';
2+
import { join } from 'node:path';
3+
4+
const packageJsons = await Promise.all(
5+
(await fs.readdir('./')).map((p) =>
6+
fs
7+
.readFile(join(p, 'package.json'))
8+
.then(JSON.parse)
9+
.catch((e) => {}),
10+
),
11+
);
12+
13+
const peerDependencies = Object.fromEntries(
14+
packageJsons
15+
.filter((pj) => pj && pj.peerDependencies)
16+
.flatMap((pj) => Object.entries(pj.peerDependencies)),
17+
);
18+
19+
const packageJson = {
20+
...JSON.parse(await fs.readFile('package.json')),
21+
peerDependencies,
22+
};
23+
24+
await fs.writeFile(
25+
'package.json',
26+
JSON.stringify(packageJson, null, 2) + '\n', // newline at EOF
27+
);

lefthook.yml

+4
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ pre-commit:
2222
typescript:
2323
glob: '*.{ts,tsx}'
2424
run: bun tsc --noEmit
25+
collect-peerdeps:
26+
glob: '**/package.json'
27+
run: node ./config/collect-peerdeps.js
28+
stage_fixed: true

package.json

+22-1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@
221221
"build:vine": "microbundle --cwd vine --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@vinejs/vine=vine",
222222
"build:fluentvalidation-ts": "microbundle --cwd fluentvalidation-ts --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
223223
"build:standard-schema": "microbundle --cwd standard-schema --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@standard-schema/spec=standardSchema",
224+
"prebuild": "node ./config/collect-peerdeps.js",
224225
"postbuild": "node ./config/node-13-exports.js && check-export-map",
225226
"lint": "bunx @biomejs/biome check --write --vcs-use-ignore-file=true .",
226227
"lint:types": "tsc",
@@ -317,7 +318,27 @@
317318
"zod": "^3.24.2"
318319
},
319320
"peerDependencies": {
320-
"react-hook-form": "^7.55.0"
321+
"react-hook-form": "^7.55.0",
322+
"@hookform/resolvers": "^2.0.0",
323+
"ajv": "^8.12.0",
324+
"ajv-errors": "^3.0.0",
325+
"arktype": "^2.0.0",
326+
"class-transformer": "^0.4.0",
327+
"class-validator": "^0.12.0",
328+
"effect": "^3.10.3",
329+
"fluentvalidation-ts": "^3.0.0",
330+
"io-ts": "^2.0.0",
331+
"fp-ts": "^2.7.0",
332+
"nope-validator": "^0.12.0",
333+
"@standard-schema/spec": "^1.0.0",
334+
"@standard-schema/utils": "^0.3.0",
335+
"superstruct": ">=0.12.0",
336+
"typanion": "^3.3.2",
337+
"@sinclair/typebox": "^0.25.24",
338+
"@typeschema/main": "^0.13.7",
339+
"valibot": "^1.0.0 || ^1.0.0-beta.4 || ^1.0.0-rc",
340+
"vest": ">=3.0.0",
341+
"@vinejs/vine": "^2.0.0"
321342
},
322343
"dependencies": {
323344
"@standard-schema/utils": "^0.3.0"

0 commit comments

Comments
 (0)