diff --git a/.gitignore b/.gitignore index 4690b14d1..d46aba4f8 100644 --- a/.gitignore +++ b/.gitignore @@ -137,3 +137,5 @@ dist/ # Conformance test results results/ + +.lefthook-local.yml diff --git a/lefthook-local.example.yml b/lefthook-local.example.yml new file mode 100644 index 000000000..9bbfcc44c --- /dev/null +++ b/lefthook-local.example.yml @@ -0,0 +1,24 @@ +# Optional local lefthook configuration +# To enable this: +# cp lefthook-local.example.yml lefthook-local.yml + +pre-commit: + parallel: true + jobs: + - name: 'Typecheck' + run: pnpm typecheck:all + stage_fixed: true + + - name: 'Lint Fix & Format' + run: pnpm lint:fix:all + stage_fixed: true + +post-checkout: + jobs: + - name: 'Install Dependencies' + run: pnpm install + +post-merge: + jobs: + - name: 'Install Dependencies' + run: pnpm install diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 000000000..016a5b0f8 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,47 @@ +# lefthook.yml +# Configuration reference: https://lefthook.dev/configuration/ + +assert_lefthook_installed: true + +output: + - meta # Print lefthook version + - summary # Print summary block (successful and failed steps) + - empty_summary # Print summary heading when there are no steps to run + - success # Print successful steps + - failure # Print failed steps printing + - execution # Print any execution logs (but prints if the execution failed) + - execution_out # Print execution output (but still prints failed commands output) + - execution_info # Print `EXECUTE > ...` logging + - skips # Print "skip" (i.e. no files matched) + +pre-push: + follow: true + parallel: true + jobs: + - name: 'Typecheck' + run: pnpm run typecheck:all + fail_text: | + 💡 To catch typechecking issues earlier, enable the pre-commit hook: + cp lefthook-local.example.yml lefthook-local.yml + + - name: 'Lint' + run: pnpm run lint:all + fail_text: | + 💡 To catch linting issues earlier, enable the pre-commit hook: + cp lefthook-local.example.yml lefthook-local.yml + + - name: 'Build' + run: pnpm run build:all + fail_text: | + 💡 To catch build issues earlier, enable the pre-commit hook: + cp lefthook-local.example.yml lefthook-local.yml + +post-checkout: + jobs: + - name: 'Install Dependencies' + run: pnpm install + +post-merge: + jobs: + - name: 'Install Dependencies' + run: pnpm install diff --git a/package-lock.json b/package-lock.json index 0129fe803..939b5c9ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,7 +41,12 @@ "@typescript/native-preview": "^7.0.0-dev.20251103.1", "eslint": "^9.8.0", "eslint-config-prettier": "^10.1.8", +<<<<<<< HEAD + "jest": "^29.7.0", + "lefthook": "^1.13.6", +======= "eslint-plugin-n": "^17.23.1", +>>>>>>> 160902eb2e43f02c11181e320ea45d88d5e322b0 "prettier": "3.6.2", "supertest": "^7.0.0", "tsx": "^4.16.5", @@ -3334,6 +3339,190 @@ "json-buffer": "3.0.1" } }, +<<<<<<< HEAD + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/lefthook": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook/-/lefthook-1.13.6.tgz", + "integrity": "sha512-ojj4/4IJ29Xn4drd5emqVgilegAPN3Kf0FQM2p/9+lwSTpU+SZ1v4Ig++NF+9MOa99UKY8bElmVrLhnUUNFh5g==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "lefthook": "bin/index.js" + }, + "optionalDependencies": { + "lefthook-darwin-arm64": "1.13.6", + "lefthook-darwin-x64": "1.13.6", + "lefthook-freebsd-arm64": "1.13.6", + "lefthook-freebsd-x64": "1.13.6", + "lefthook-linux-arm64": "1.13.6", + "lefthook-linux-x64": "1.13.6", + "lefthook-openbsd-arm64": "1.13.6", + "lefthook-openbsd-x64": "1.13.6", + "lefthook-windows-arm64": "1.13.6", + "lefthook-windows-x64": "1.13.6" + } + }, + "node_modules/lefthook-darwin-arm64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-darwin-arm64/-/lefthook-darwin-arm64-1.13.6.tgz", + "integrity": "sha512-m6Lb77VGc84/Qo21Lhq576pEvcgFCnvloEiP02HbAHcIXD0RTLy9u2yAInrixqZeaz13HYtdDaI7OBYAAdVt8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/lefthook-darwin-x64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-darwin-x64/-/lefthook-darwin-x64-1.13.6.tgz", + "integrity": "sha512-CoRpdzanu9RK3oXR1vbEJA5LN7iB+c7hP+sONeQJzoOXuq4PNKVtEaN84Gl1BrVtCNLHWFAvCQaZPPiiXSy8qg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/lefthook-freebsd-arm64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-freebsd-arm64/-/lefthook-freebsd-arm64-1.13.6.tgz", + "integrity": "sha512-X4A7yfvAJ68CoHTqP+XvQzdKbyd935sYy0bQT6Ajz7FL1g7hFiro8dqHSdPdkwei9hs8hXeV7feyTXbYmfjKQQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/lefthook-freebsd-x64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-freebsd-x64/-/lefthook-freebsd-x64-1.13.6.tgz", + "integrity": "sha512-ai2m+Sj2kGdY46USfBrCqLKe9GYhzeq01nuyDYCrdGISePeZ6udOlD1k3lQKJGQCHb0bRz4St0r5nKDSh1x/2A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/lefthook-linux-arm64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-linux-arm64/-/lefthook-linux-arm64-1.13.6.tgz", + "integrity": "sha512-cbo4Wtdq81GTABvikLORJsAWPKAJXE8Q5RXsICFUVznh5PHigS9dFW/4NXywo0+jfFPCT6SYds2zz4tCx6DA0Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/lefthook-linux-x64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-1.13.6.tgz", + "integrity": "sha512-uJl9vjCIIBTBvMZkemxCE+3zrZHlRO7Oc+nZJ+o9Oea3fu+W82jwX7a7clw8jqNfaeBS+8+ZEQgiMHWCloTsGw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/lefthook-openbsd-arm64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-openbsd-arm64/-/lefthook-openbsd-arm64-1.13.6.tgz", + "integrity": "sha512-7r153dxrNRQ9ytRs2PmGKKkYdvZYFPre7My7XToSTiRu5jNCq++++eAKVkoyWPduk97dGIA+YWiEr5Noe0TK2A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/lefthook-openbsd-x64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-openbsd-x64/-/lefthook-openbsd-x64-1.13.6.tgz", + "integrity": "sha512-Z+UhLlcg1xrXOidK3aLLpgH7KrwNyWYE3yb7ITYnzJSEV8qXnePtVu8lvMBHs/myzemjBzeIr/U/+ipjclR06g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/lefthook-windows-arm64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-windows-arm64/-/lefthook-windows-arm64-1.13.6.tgz", + "integrity": "sha512-Uxef6qoDxCmUNQwk8eBvddYJKSBFglfwAY9Y9+NnnmiHpWTjjYiObE9gT2mvGVpEgZRJVAatBXc+Ha5oDD/OgQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/lefthook-windows-x64": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/lefthook-windows-x64/-/lefthook-windows-x64-1.13.6.tgz", + "integrity": "sha512-mOZoM3FQh3o08M8PQ/b3IYuL5oo36D9ehczIw1dAgp1Ly+Tr4fJ96A+4SEJrQuYeRD4mex9bR7Ps56I73sBSZA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, +======= +>>>>>>> 160902eb2e43f02c11181e320ea45d88d5e322b0 "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", diff --git a/package.json b/package.json index ff9a9b350..3b9bfcc80 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "lint:fix:all": "pnpm -r lint:fix", "check:all": "pnpm -r typecheck && pnpm -r lint", "test:all": "pnpm -r test", + "prepare": "npx --no-install lefthook install", "test:conformance:client": "pnpm --filter @modelcontextprotocol/test-conformance run test:conformance:client", "test:conformance:client:all": "pnpm --filter @modelcontextprotocol/test-conformance run test:conformance:client:all", "test:conformance:client:run": "pnpm --filter @modelcontextprotocol/test-conformance run test:conformance:client:run", @@ -42,6 +43,7 @@ "test:conformance:all": "pnpm run test:conformance:client:all && pnpm run test:conformance:server:all" }, "devDependencies": { + "lefthook": "^2.0.16", "@cfworker/json-schema": "catalog:runtimeShared", "@changesets/changelog-github": "^0.5.2", "@changesets/cli": "^2.29.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e51ed15ed..a21a0f706 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -194,6 +194,9 @@ importers: fast-glob: specifier: ^3.3.3 version: 3.3.3 + lefthook: + specifier: ^2.0.16 + version: 2.0.16 prettier: specifier: catalog:devTools version: 3.6.2 @@ -3516,6 +3519,60 @@ packages: resolution: {integrity: sha512-3BeXMoiOhpOwu62CiVpO6lxfq4eS6KMYfQdMsN/2kUCRNuF2YiEr7u0HLHaQU+O4Xu8YXE3bHVkwaQ85i72EuA==} engines: {node: '>=20.0.0'} + lefthook-darwin-arm64@2.0.16: + resolution: {integrity: sha512-kjVHkD7rfPa7M0aKJSx/yatdV9uC6o3cJyzM9zk7cg5HD7alSwchFalgF/P0w6nt7C02rAUx8C05qiWCDWaKeA==} + cpu: [arm64] + os: [darwin] + + lefthook-darwin-x64@2.0.16: + resolution: {integrity: sha512-tbJ0mdT49DNRLqknro0BvWrYNC23TTcqBJFQnQ32pq1/H9B87bTNKvKKAtogp/saxfHUzkIq1i3twZlBZ3G3Xw==} + cpu: [x64] + os: [darwin] + + lefthook-freebsd-arm64@2.0.16: + resolution: {integrity: sha512-wa1KFD5tSUhw3tuetVef/BCSxbbmS7auTDNdoLx3WFeuN5RS15woSN9+E8GPGOOY1g2HCsgdLrhrexEomulfjQ==} + cpu: [arm64] + os: [freebsd] + + lefthook-freebsd-x64@2.0.16: + resolution: {integrity: sha512-UXowfn2e94AwNk9UuoePRK+qiF15jZsssiyA15VK5GTtxpn6Sn+Z2QFciofxJczXXxM4abaf7qgx2OoJBt32VA==} + cpu: [x64] + os: [freebsd] + + lefthook-linux-arm64@2.0.16: + resolution: {integrity: sha512-U355elz4Z0AHSVqxfcglN09TGR86ov/GtYlliDknci2mmz6EWLiD3dTYnqJiwa4dYxqmuCDc/DvAL9rgb3YJiQ==} + cpu: [arm64] + os: [linux] + + lefthook-linux-x64@2.0.16: + resolution: {integrity: sha512-7eAvBeWGAgjOKZ23OQbjJINLPImDIuDeX8dXOfk+aI6IFt2X6KCzRkp+ASUvGQtrPuNZQZT43EhW0/1jZU14ZQ==} + cpu: [x64] + os: [linux] + + lefthook-openbsd-arm64@2.0.16: + resolution: {integrity: sha512-Fcd+E17ZkWGnRSQINb5gf+rNy2So5PYn5mBljiC31dl+TgWM8Wy46mSEGveHo7lKCO3q+DkmHIa50Qm58G03AQ==} + cpu: [arm64] + os: [openbsd] + + lefthook-openbsd-x64@2.0.16: + resolution: {integrity: sha512-uL5nOkz8eBtQHped0/tB5X8clZ5kfnyjQrv1fpKbGAjeFHI2J+GmRqcn6Awq2IeuBbQvkyV6jDjpATyHBp5mCA==} + cpu: [x64] + os: [openbsd] + + lefthook-windows-arm64@2.0.16: + resolution: {integrity: sha512-U61bNWzD6Vd2kjuJ7b4voPfTQ4mlBFOyTpCU3k/h0YjpKDQEFT1T5fDKkDothdnw/JVDSgrclIcfAY7Jyr/UIg==} + cpu: [arm64] + os: [win32] + + lefthook-windows-x64@2.0.16: + resolution: {integrity: sha512-dCHi2+hebhPI0LQUGRNjPMsGRyXhrTN3Y/b8M4HO8KVyGamKB3Yemf67ya81tZopDkxNVy5XUBXLYWKGhnAfLQ==} + cpu: [x64] + os: [win32] + + lefthook@2.0.16: + resolution: {integrity: sha512-ABs3M5V9c4nqxFnZO509HXuQTu8GM8hmqc9ruV0acQ81yKlxEq70MRoYP5Z1dr5le326X8vA5qj3arJA36yE3A==} + hasBin: true + levn@0.4.1: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} @@ -6986,6 +7043,49 @@ snapshots: kysely@0.28.9: {} + lefthook-darwin-arm64@2.0.16: + optional: true + + lefthook-darwin-x64@2.0.16: + optional: true + + lefthook-freebsd-arm64@2.0.16: + optional: true + + lefthook-freebsd-x64@2.0.16: + optional: true + + lefthook-linux-arm64@2.0.16: + optional: true + + lefthook-linux-x64@2.0.16: + optional: true + + lefthook-openbsd-arm64@2.0.16: + optional: true + + lefthook-openbsd-x64@2.0.16: + optional: true + + lefthook-windows-arm64@2.0.16: + optional: true + + lefthook-windows-x64@2.0.16: + optional: true + + lefthook@2.0.16: + optionalDependencies: + lefthook-darwin-arm64: 2.0.16 + lefthook-darwin-x64: 2.0.16 + lefthook-freebsd-arm64: 2.0.16 + lefthook-freebsd-x64: 2.0.16 + lefthook-linux-arm64: 2.0.16 + lefthook-linux-x64: 2.0.16 + lefthook-openbsd-arm64: 2.0.16 + lefthook-openbsd-x64: 2.0.16 + lefthook-windows-arm64: 2.0.16 + lefthook-windows-x64: 2.0.16 + levn@0.4.1: dependencies: prelude-ls: 1.2.1