Skip to content

add prebuild script to collect peerdeps #765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions config/collect-peerdeps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import fs from 'node:fs/promises';
import { join } from 'node:path';

const packageJsons = await Promise.all(
(await fs.readdir('./')).map((p) =>
fs
.readFile(join(p, 'package.json'))
.then(JSON.parse)
.catch((e) => {}),
),
);

const peerDependencies = Object.fromEntries(
packageJsons
.filter((pj) => pj && pj.peerDependencies)
.flatMap((pj) => Object.entries(pj.peerDependencies)),
);

const packageJson = {
...JSON.parse(await fs.readFile('package.json')),
peerDependencies,
};

await fs.writeFile(
'package.json',
JSON.stringify(packageJson, null, 2) + '\n', // newline at EOF
);
4 changes: 4 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ pre-commit:
typescript:
glob: '*.{ts,tsx}'
run: bun tsc --noEmit
collect-peerdeps:
glob: '**/package.json'
run: node ./config/collect-peerdeps.js
stage_fixed: true
23 changes: 22 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"build:vine": "microbundle --cwd vine --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@vinejs/vine=vine",
"build:fluentvalidation-ts": "microbundle --cwd fluentvalidation-ts --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
"build:standard-schema": "microbundle --cwd standard-schema --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@standard-schema/spec=standardSchema",
"prebuild": "node ./config/collect-peerdeps.js",
"postbuild": "node ./config/node-13-exports.js && check-export-map",
"lint": "bunx @biomejs/biome check --write --vcs-use-ignore-file=true .",
"lint:types": "tsc",
Expand Down Expand Up @@ -317,7 +318,27 @@
"zod": "^3.24.2"
},
"peerDependencies": {
"react-hook-form": "^7.55.0"
"react-hook-form": "^7.55.0",
"@hookform/resolvers": "^2.0.0",
"ajv": "^8.12.0",
"ajv-errors": "^3.0.0",
"arktype": "^2.0.0",
"class-transformer": "^0.4.0",
"class-validator": "^0.12.0",
"effect": "^3.10.3",
"fluentvalidation-ts": "^3.0.0",
"io-ts": "^2.0.0",
"fp-ts": "^2.7.0",
"nope-validator": "^0.12.0",
"@standard-schema/spec": "^1.0.0",
"@standard-schema/utils": "^0.3.0",
"superstruct": ">=0.12.0",
"typanion": "^3.3.2",
"@sinclair/typebox": "^0.25.24",
"@typeschema/main": "^0.13.7",
"valibot": "^1.0.0 || ^1.0.0-beta.4 || ^1.0.0-rc",
"vest": ">=3.0.0",
"@vinejs/vine": "^2.0.0"
},
"dependencies": {
"@standard-schema/utils": "^0.3.0"
Expand Down