From f4d28ce4a4b6e79168a08a33376af0f80a143077 Mon Sep 17 00:00:00 2001 From: Gili Tzabari Date: Wed, 4 Sep 2024 12:50:26 -0400 Subject: [PATCH] * Node needs "exports" in package.json for ESM-only libraries. * Do not include the diff legend for context that does not include a diff. --- docs/Changelog.md | 2 +- package.json | 13 +- pnpm-lock.yaml | 244 +++++++++--------- src/DefaultJavascriptValidators.mts | 26 +- .../message/diff/ContextGenerator.mts | 24 +- .../message/section/MessageBuilder.mts | 1 - src/internal/util/AssertionError.mts | 5 - src/internal/validator/AbstractValidators.mts | 7 +- .../validator/JavascriptValidatorsImpl.mts | 19 +- src/internal/validator/Objects.mts | 30 ++- test/ArrayTest.mts | 1 - test/NumberTest.mts | 1 + test/SetTest.mts | 1 + test/SizeTest.mts | 1 + test/StringTest.mts | 5 +- test/ValidationFailureTest.mts | 1 + 16 files changed, 217 insertions(+), 164 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 00a9e76..40ead19 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,7 +1,7 @@ Minor updates involving cosmetic changes have been omitted from this list. See https://github.com/cowwoc/requirements.java/commits/master for a full list. -## Version 4.0 - ? +## Version 4.0.0 - ? * Breaking changes: * Replaced `validateThat()` with `checkIf()`. diff --git a/package.json b/package.json index 66658c2..7b2230c 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,11 @@ "browser": "browser/index.js", "module": "node/index.mjs", "types": "node/index.d.mts", + "exports": { + ".": { + "import": "./node/index.mjs" + } + }, "sideEffects": false, "dependencies": { "chalk": "^5.3.0", @@ -38,15 +43,15 @@ "@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-typescript": "^11.1.6", - "@types/chai": "^4.3.18", - "@types/diff": "^5.2.1", + "@types/chai": "^4.3.19", + "@types/diff": "^5.2.2", "@types/eslint": "^9.6.1", "@types/lodash": "^4.17.7", "@types/lodash.debounce": "^4.0.9", "@types/lodash.isequal": "^4.5.8", "@types/minimist": "^1.2.5", "@types/mocha": "^10.0.7", - "@types/node": "^22.5.0", + "@types/node": "^22.5.1", "@types/rollup-plugin-node-globals": "^1.4.4", "@types/tmp": "^0.2.6", "@typescript-eslint/eslint-plugin": "^8.3.0", @@ -66,7 +71,7 @@ "pnpm": "^9.9.0", "react": "^18.3.1", "react-dom": "^18.3.1", - "rollup": "^4.21.1", + "rollup": "^4.21.2", "rollup-plugin-node-globals": "^1.4.0", "source-map-support": "^0.5.21", "strip-ansi": "^7.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ed1320a..43bfce7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,19 +23,19 @@ importers: version: 9.9.1 '@rollup/plugin-commonjs': specifier: ^26.0.1 - version: 26.0.1(rollup@4.21.1) + version: 26.0.1(rollup@4.21.2) '@rollup/plugin-node-resolve': specifier: ^15.2.3 - version: 15.2.3(rollup@4.21.1) + version: 15.2.3(rollup@4.21.2) '@rollup/plugin-typescript': specifier: ^11.1.6 - version: 11.1.6(rollup@4.21.1)(tslib@2.7.0)(typescript@5.5.4) + version: 11.1.6(rollup@4.21.2)(tslib@2.7.0)(typescript@5.5.4) '@types/chai': - specifier: ^4.3.18 - version: 4.3.18 + specifier: ^4.3.19 + version: 4.3.19 '@types/diff': - specifier: ^5.2.1 - version: 5.2.1 + specifier: ^5.2.2 + version: 5.2.2 '@types/eslint': specifier: ^9.6.1 version: 9.6.1 @@ -55,8 +55,8 @@ importers: specifier: ^10.0.7 version: 10.0.7 '@types/node': - specifier: ^22.5.0 - version: 22.5.0 + specifier: ^22.5.1 + version: 22.5.1 '@types/rollup-plugin-node-globals': specifier: ^1.4.4 version: 1.4.4 @@ -115,8 +115,8 @@ importers: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) rollup: - specifier: ^4.21.1 - version: 4.21.1 + specifier: ^4.21.2 + version: 4.21.2 rollup-plugin-node-globals: specifier: ^1.4.0 version: 1.4.0 @@ -137,7 +137,7 @@ importers: version: 0.2.3 ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@22.5.0)(typescript@5.5.4) + version: 10.9.2(@types/node@22.5.1)(typescript@5.5.4) tslib: specifier: ^2.7.0 version: 2.7.0 @@ -448,88 +448,88 @@ packages: rollup: optional: true - '@rollup/rollup-android-arm-eabi@4.21.1': - resolution: {integrity: sha512-2thheikVEuU7ZxFXubPDOtspKn1x0yqaYQwvALVtEcvFhMifPADBrgRPyHV0TF3b+9BgvgjgagVyvA/UqPZHmg==} + '@rollup/rollup-android-arm-eabi@4.21.2': + resolution: {integrity: sha512-fSuPrt0ZO8uXeS+xP3b+yYTCBUd05MoSp2N/MFOgjhhUhMmchXlpTQrTpI8T+YAwAQuK7MafsCOxW7VrPMrJcg==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.21.1': - resolution: {integrity: sha512-t1lLYn4V9WgnIFHXy1d2Di/7gyzBWS8G5pQSXdZqfrdCGTwi1VasRMSS81DTYb+avDs/Zz4A6dzERki5oRYz1g==} + '@rollup/rollup-android-arm64@4.21.2': + resolution: {integrity: sha512-xGU5ZQmPlsjQS6tzTTGwMsnKUtu0WVbl0hYpTPauvbRAnmIvpInhJtgjj3mcuJpEiuUw4v1s4BimkdfDWlh7gA==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.21.1': - resolution: {integrity: sha512-AH/wNWSEEHvs6t4iJ3RANxW5ZCK3fUnmf0gyMxWCesY1AlUj8jY7GC+rQE4wd3gwmZ9XDOpL0kcFnCjtN7FXlA==} + '@rollup/rollup-darwin-arm64@4.21.2': + resolution: {integrity: sha512-99AhQ3/ZMxU7jw34Sq8brzXqWH/bMnf7ZVhvLk9QU2cOepbQSVTns6qoErJmSiAvU3InRqC2RRZ5ovh1KN0d0Q==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.21.1': - resolution: {integrity: sha512-dO0BIz/+5ZdkLZrVgQrDdW7m2RkrLwYTh2YMFG9IpBtlC1x1NPNSXkfczhZieOlOLEqgXOFH3wYHB7PmBtf+Bg==} + '@rollup/rollup-darwin-x64@4.21.2': + resolution: {integrity: sha512-ZbRaUvw2iN/y37x6dY50D8m2BnDbBjlnMPotDi/qITMJ4sIxNY33HArjikDyakhSv0+ybdUxhWxE6kTI4oX26w==} cpu: [x64] os: [darwin] - '@rollup/rollup-linux-arm-gnueabihf@4.21.1': - resolution: {integrity: sha512-sWWgdQ1fq+XKrlda8PsMCfut8caFwZBmhYeoehJ05FdI0YZXk6ZyUjWLrIgbR/VgiGycrFKMMgp7eJ69HOF2pQ==} + '@rollup/rollup-linux-arm-gnueabihf@4.21.2': + resolution: {integrity: sha512-ztRJJMiE8nnU1YFcdbd9BcH6bGWG1z+jP+IPW2oDUAPxPjo9dverIOyXz76m6IPA6udEL12reYeLojzW2cYL7w==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.21.1': - resolution: {integrity: sha512-9OIiSuj5EsYQlmwhmFRA0LRO0dRRjdCVZA3hnmZe1rEwRk11Jy3ECGGq3a7RrVEZ0/pCsYWx8jG3IvcrJ6RCew==} + '@rollup/rollup-linux-arm-musleabihf@4.21.2': + resolution: {integrity: sha512-flOcGHDZajGKYpLV0JNc0VFH361M7rnV1ee+NTeC/BQQ1/0pllYcFmxpagltANYt8FYf9+kL6RSk80Ziwyhr7w==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.21.1': - resolution: {integrity: sha512-0kuAkRK4MeIUbzQYu63NrJmfoUVicajoRAL1bpwdYIYRcs57iyIV9NLcuyDyDXE2GiZCL4uhKSYAnyWpjZkWow==} + '@rollup/rollup-linux-arm64-gnu@4.21.2': + resolution: {integrity: sha512-69CF19Kp3TdMopyteO/LJbWufOzqqXzkrv4L2sP8kfMaAQ6iwky7NoXTp7bD6/irKgknDKM0P9E/1l5XxVQAhw==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.21.1': - resolution: {integrity: sha512-/6dYC9fZtfEY0vozpc5bx1RP4VrtEOhNQGb0HwvYNwXD1BBbwQ5cKIbUVVU7G2d5WRE90NfB922elN8ASXAJEA==} + '@rollup/rollup-linux-arm64-musl@4.21.2': + resolution: {integrity: sha512-48pD/fJkTiHAZTnZwR0VzHrao70/4MlzJrq0ZsILjLW/Ab/1XlVUStYyGt7tdyIiVSlGZbnliqmult/QGA2O2w==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.21.1': - resolution: {integrity: sha512-ltUWy+sHeAh3YZ91NUsV4Xg3uBXAlscQe8ZOXRCVAKLsivGuJsrkawYPUEyCV3DYa9urgJugMLn8Z3Z/6CeyRQ==} + '@rollup/rollup-linux-powerpc64le-gnu@4.21.2': + resolution: {integrity: sha512-cZdyuInj0ofc7mAQpKcPR2a2iu4YM4FQfuUzCVA2u4HI95lCwzjoPtdWjdpDKyHxI0UO82bLDoOaLfpZ/wviyQ==} cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.21.1': - resolution: {integrity: sha512-BggMndzI7Tlv4/abrgLwa/dxNEMn2gC61DCLrTzw8LkpSKel4o+O+gtjbnkevZ18SKkeN3ihRGPuBxjaetWzWg==} + '@rollup/rollup-linux-riscv64-gnu@4.21.2': + resolution: {integrity: sha512-RL56JMT6NwQ0lXIQmMIWr1SW28z4E4pOhRRNqwWZeXpRlykRIlEpSWdsgNWJbYBEWD84eocjSGDu/XxbYeCmwg==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.21.1': - resolution: {integrity: sha512-z/9rtlGd/OMv+gb1mNSjElasMf9yXusAxnRDrBaYB+eS1shFm6/4/xDH1SAISO5729fFKUkJ88TkGPRUh8WSAA==} + '@rollup/rollup-linux-s390x-gnu@4.21.2': + resolution: {integrity: sha512-PMxkrWS9z38bCr3rWvDFVGD6sFeZJw4iQlhrup7ReGmfn7Oukrr/zweLhYX6v2/8J6Cep9IEA/SmjXjCmSbrMQ==} cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.21.1': - resolution: {integrity: sha512-kXQVcWqDcDKw0S2E0TmhlTLlUgAmMVqPrJZR+KpH/1ZaZhLSl23GZpQVmawBQGVhyP5WXIsIQ/zqbDBBYmxm5w==} + '@rollup/rollup-linux-x64-gnu@4.21.2': + resolution: {integrity: sha512-B90tYAUoLhU22olrafY3JQCFLnT3NglazdwkHyxNDYF/zAxJt5fJUB/yBoWFoIQ7SQj+KLe3iL4BhOMa9fzgpw==} cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.21.1': - resolution: {integrity: sha512-CbFv/WMQsSdl+bpX6rVbzR4kAjSSBuDgCqb1l4J68UYsQNalz5wOqLGYj4ZI0thGpyX5kc+LLZ9CL+kpqDovZA==} + '@rollup/rollup-linux-x64-musl@4.21.2': + resolution: {integrity: sha512-7twFizNXudESmC9oneLGIUmoHiiLppz/Xs5uJQ4ShvE6234K0VB1/aJYU3f/4g7PhssLGKBVCC37uRkkOi8wjg==} cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.21.1': - resolution: {integrity: sha512-3Q3brDgA86gHXWHklrwdREKIrIbxC0ZgU8lwpj0eEKGBQH+31uPqr0P2v11pn0tSIxHvcdOWxa4j+YvLNx1i6g==} + '@rollup/rollup-win32-arm64-msvc@4.21.2': + resolution: {integrity: sha512-9rRero0E7qTeYf6+rFh3AErTNU1VCQg2mn7CQcI44vNUWM9Ze7MSRS/9RFuSsox+vstRt97+x3sOhEey024FRQ==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.21.1': - resolution: {integrity: sha512-tNg+jJcKR3Uwe4L0/wY3Ro0H+u3nrb04+tcq1GSYzBEmKLeOQF2emk1whxlzNqb6MMrQ2JOcQEpuuiPLyRcSIw==} + '@rollup/rollup-win32-ia32-msvc@4.21.2': + resolution: {integrity: sha512-5rA4vjlqgrpbFVVHX3qkrCo/fZTj1q0Xxpg+Z7yIo3J2AilW7t2+n6Q8Jrx+4MrYpAnjttTYF8rr7bP46BPzRw==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.21.1': - resolution: {integrity: sha512-xGiIH95H1zU7naUyTKEyOA/I0aexNMUdO9qRv0bLKN3qu25bBdrxZHqA3PTJ24YNN/GdMzG4xkDcd/GvjuhfLg==} + '@rollup/rollup-win32-x64-msvc@4.21.2': + resolution: {integrity: sha512-6UUxd0+SKomjdzuAcp+HAmxw1FlGBnl1v2yEPSabtx4lBfdXHDVsW7+lQkgz9cNFJGY3AWR7+V8P5BqkD9L9nA==} cpu: [x64] os: [win32] - '@shikijs/core@1.14.1': - resolution: {integrity: sha512-KyHIIpKNaT20FtFPFjCQB5WVSTpLR/n+jQXhWHWVUMm9MaOaG9BGOG0MSyt7yA4+Lm+4c9rTc03tt3nYzeYSfw==} + '@shikijs/core@1.15.2': + resolution: {integrity: sha512-hi6XZuwHYn6bU4wtXZxST8ynM55aiU2+rVU9aPIrSxqKmEKl4d65puwGsggwcZWTET+7zGXKe7AUj46iQ8Aq8w==} '@socket.io/component-emitter@3.1.2': resolution: {integrity: sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==} @@ -546,8 +546,8 @@ packages: '@tsconfig/node16@1.0.4': resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} - '@types/chai@4.3.18': - resolution: {integrity: sha512-2UfJzigyNa8kYTKn7o4hNMPphkxtu4WTJyobK3m4FBpyj7EK5xgtPcOtxLm7Dznk/Qxr0QXn+gQbkg7mCZKdfg==} + '@types/chai@4.3.19': + resolution: {integrity: sha512-2hHHvQBVE2FiSK4eN0Br6snX9MtolHaTo/batnLjlGRhoQzlCL61iVpxoqO7SfFyOw+P/pwv+0zNHzKoGWz9Cw==} '@types/cookie@0.4.1': resolution: {integrity: sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==} @@ -555,8 +555,8 @@ packages: '@types/cors@2.8.17': resolution: {integrity: sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==} - '@types/diff@5.2.1': - resolution: {integrity: sha512-uxpcuwWJGhe2AR1g8hD9F5OYGCqjqWnBUQFD8gMZsDbv8oPHzxJF6iMO6n8Tk0AdzlxoaaoQhOYlIg/PukVU8g==} + '@types/diff@5.2.2': + resolution: {integrity: sha512-qVqLpd49rmJA2nZzLVsmfS/aiiBpfVE95dHhPVwG0NmSBAt+riPxnj53wq2oBq5m4Q2RF1IWFEUpnZTgrQZfEQ==} '@types/eslint@9.6.1': resolution: {integrity: sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==} @@ -591,8 +591,8 @@ packages: '@types/mocha@10.0.7': resolution: {integrity: sha512-GN8yJ1mNTcFcah/wKEFIJckJx9iJLoMSzWcfRRuxz/Jk+U6KQNnml+etbtxFK8lPjzOw3zp4Ha/kjSst9fsHYw==} - '@types/node@22.5.0': - resolution: {integrity: sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==} + '@types/node@22.5.1': + resolution: {integrity: sha512-KkHsxej0j9IW1KKOOAA/XBA0z08UFSrRQHErzEfA3Vgq57eXIMYboIlHJuYIfd+lwCQjtKqUu3UnmKbtUc9yRw==} '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -1008,8 +1008,8 @@ packages: engines: {node: '>=18'} hasBin: true - escalade@3.1.2: - resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} + escalade@3.2.0: + resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} escape-html@1.0.3: @@ -1171,8 +1171,8 @@ packages: get-func-name@2.0.2: resolution: {integrity: sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==} - get-tsconfig@4.7.6: - resolution: {integrity: sha512-ZAqrLlu18NbDdRaHq+AKXzAmqIUPswPWKUchfytdAjiRFnCe5ojG2bstg6mRiZabkKfCoL/e98pbBELIV/YCeA==} + get-tsconfig@4.8.0: + resolution: {integrity: sha512-Pgba6TExTZ0FJAn1qkJAjIeKoDJ3CsI2ChuLohJnZl/tTU8MVrq3b+2t5UOPfRa4RMsorClBjJALkJUMjG1PAw==} glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} @@ -1687,8 +1687,8 @@ packages: resolution: {integrity: sha512-dFf8LpUNzIj3oE0vCvobX6rqOzHzLBoblyFp+3znPbjiSmSvOoK2kMKx+Fv9jYduG1rvcCfCveSgEaQHjWRF6g==} hasBin: true - rollup@4.21.1: - resolution: {integrity: sha512-ZnYyKvscThhgd3M5+Qt3pmhO4jIRR5RGzaSovB6Q7rGNrK5cUncrtLmcTTJVSdcKXyZjW8X8MB0JMSuH9bcAJg==} + rollup@4.21.2: + resolution: {integrity: sha512-e3TapAgYf9xjdLvKQCkQTnbTKd4a6jwlpQSJJFokHGaX2IVjoEqkIIhiQfqsi0cdwlOD+tQGuOd5AJkc5RngBw==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -1748,8 +1748,8 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - shiki@1.14.1: - resolution: {integrity: sha512-FujAN40NEejeXdzPt+3sZ3F2dx1U24BY2XTY01+MG8mbxCiA2XukXdcbyMyLAHJ/1AUUnQd1tZlvIjefWWEJeA==} + shiki@1.15.2: + resolution: {integrity: sha512-M+7QZQZiZw/cZeizrC/yryG3eeG8pTUhu7ZaHxVyzPNFIRIlN46YBciquoNPCiXiwLnx6JB62f3lSuSYQrus1w==} signal-exit@4.1.0: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} @@ -2239,94 +2239,94 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true - '@rollup/plugin-commonjs@26.0.1(rollup@4.21.1)': + '@rollup/plugin-commonjs@26.0.1(rollup@4.21.2)': dependencies: - '@rollup/pluginutils': 5.1.0(rollup@4.21.1) + '@rollup/pluginutils': 5.1.0(rollup@4.21.2) commondir: 1.0.1 estree-walker: 2.0.2 glob: 10.4.5 is-reference: 1.2.1 magic-string: 0.30.11 optionalDependencies: - rollup: 4.21.1 + rollup: 4.21.2 - '@rollup/plugin-node-resolve@15.2.3(rollup@4.21.1)': + '@rollup/plugin-node-resolve@15.2.3(rollup@4.21.2)': dependencies: - '@rollup/pluginutils': 5.1.0(rollup@4.21.1) + '@rollup/pluginutils': 5.1.0(rollup@4.21.2) '@types/resolve': 1.20.2 deepmerge: 4.3.1 is-builtin-module: 3.2.1 is-module: 1.0.0 resolve: 1.22.8 optionalDependencies: - rollup: 4.21.1 + rollup: 4.21.2 - '@rollup/plugin-typescript@11.1.6(rollup@4.21.1)(tslib@2.7.0)(typescript@5.5.4)': + '@rollup/plugin-typescript@11.1.6(rollup@4.21.2)(tslib@2.7.0)(typescript@5.5.4)': dependencies: - '@rollup/pluginutils': 5.1.0(rollup@4.21.1) + '@rollup/pluginutils': 5.1.0(rollup@4.21.2) resolve: 1.22.8 typescript: 5.5.4 optionalDependencies: - rollup: 4.21.1 + rollup: 4.21.2 tslib: 2.7.0 - '@rollup/pluginutils@5.1.0(rollup@4.21.1)': + '@rollup/pluginutils@5.1.0(rollup@4.21.2)': dependencies: '@types/estree': 1.0.5 estree-walker: 2.0.2 picomatch: 2.3.1 optionalDependencies: - rollup: 4.21.1 + rollup: 4.21.2 - '@rollup/rollup-android-arm-eabi@4.21.1': + '@rollup/rollup-android-arm-eabi@4.21.2': optional: true - '@rollup/rollup-android-arm64@4.21.1': + '@rollup/rollup-android-arm64@4.21.2': optional: true - '@rollup/rollup-darwin-arm64@4.21.1': + '@rollup/rollup-darwin-arm64@4.21.2': optional: true - '@rollup/rollup-darwin-x64@4.21.1': + '@rollup/rollup-darwin-x64@4.21.2': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.21.1': + '@rollup/rollup-linux-arm-gnueabihf@4.21.2': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.21.1': + '@rollup/rollup-linux-arm-musleabihf@4.21.2': optional: true - '@rollup/rollup-linux-arm64-gnu@4.21.1': + '@rollup/rollup-linux-arm64-gnu@4.21.2': optional: true - '@rollup/rollup-linux-arm64-musl@4.21.1': + '@rollup/rollup-linux-arm64-musl@4.21.2': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.21.1': + '@rollup/rollup-linux-powerpc64le-gnu@4.21.2': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.21.1': + '@rollup/rollup-linux-riscv64-gnu@4.21.2': optional: true - '@rollup/rollup-linux-s390x-gnu@4.21.1': + '@rollup/rollup-linux-s390x-gnu@4.21.2': optional: true - '@rollup/rollup-linux-x64-gnu@4.21.1': + '@rollup/rollup-linux-x64-gnu@4.21.2': optional: true - '@rollup/rollup-linux-x64-musl@4.21.1': + '@rollup/rollup-linux-x64-musl@4.21.2': optional: true - '@rollup/rollup-win32-arm64-msvc@4.21.1': + '@rollup/rollup-win32-arm64-msvc@4.21.2': optional: true - '@rollup/rollup-win32-ia32-msvc@4.21.1': + '@rollup/rollup-win32-ia32-msvc@4.21.2': optional: true - '@rollup/rollup-win32-x64-msvc@4.21.1': + '@rollup/rollup-win32-x64-msvc@4.21.2': optional: true - '@shikijs/core@1.14.1': + '@shikijs/core@1.15.2': dependencies: '@types/hast': 3.0.4 @@ -2340,15 +2340,15 @@ snapshots: '@tsconfig/node16@1.0.4': {} - '@types/chai@4.3.18': {} + '@types/chai@4.3.19': {} '@types/cookie@0.4.1': {} '@types/cors@2.8.17': dependencies: - '@types/node': 22.5.0 + '@types/node': 22.5.1 - '@types/diff@5.2.1': {} + '@types/diff@5.2.2': {} '@types/eslint@9.6.1': dependencies: @@ -2381,7 +2381,7 @@ snapshots: '@types/mocha@10.0.7': {} - '@types/node@22.5.0': + '@types/node@22.5.1': dependencies: undici-types: 6.19.8 @@ -2389,7 +2389,7 @@ snapshots: '@types/rollup-plugin-node-globals@1.4.4': dependencies: - '@types/node': 22.5.0 + '@types/node': 22.5.1 rollup: 0.63.5 '@types/tmp@0.2.6': {} @@ -2822,7 +2822,7 @@ snapshots: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.17 - '@types/node': 22.5.0 + '@types/node': 22.5.1 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.4.2 @@ -2864,7 +2864,7 @@ snapshots: '@esbuild/win32-ia32': 0.23.1 '@esbuild/win32-x64': 0.23.1 - escalade@3.1.2: {} + escalade@3.2.0: {} escape-html@1.0.3: {} @@ -3037,7 +3037,7 @@ snapshots: get-func-name@2.0.2: {} - get-tsconfig@4.7.6: + get-tsconfig@4.8.0: dependencies: resolve-pkg-maps: 1.0.0 @@ -3541,28 +3541,28 @@ snapshots: rollup@0.63.5: dependencies: '@types/estree': 0.0.39 - '@types/node': 22.5.0 + '@types/node': 22.5.1 - rollup@4.21.1: + rollup@4.21.2: dependencies: '@types/estree': 1.0.5 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.21.1 - '@rollup/rollup-android-arm64': 4.21.1 - '@rollup/rollup-darwin-arm64': 4.21.1 - '@rollup/rollup-darwin-x64': 4.21.1 - '@rollup/rollup-linux-arm-gnueabihf': 4.21.1 - '@rollup/rollup-linux-arm-musleabihf': 4.21.1 - '@rollup/rollup-linux-arm64-gnu': 4.21.1 - '@rollup/rollup-linux-arm64-musl': 4.21.1 - '@rollup/rollup-linux-powerpc64le-gnu': 4.21.1 - '@rollup/rollup-linux-riscv64-gnu': 4.21.1 - '@rollup/rollup-linux-s390x-gnu': 4.21.1 - '@rollup/rollup-linux-x64-gnu': 4.21.1 - '@rollup/rollup-linux-x64-musl': 4.21.1 - '@rollup/rollup-win32-arm64-msvc': 4.21.1 - '@rollup/rollup-win32-ia32-msvc': 4.21.1 - '@rollup/rollup-win32-x64-msvc': 4.21.1 + '@rollup/rollup-android-arm-eabi': 4.21.2 + '@rollup/rollup-android-arm64': 4.21.2 + '@rollup/rollup-darwin-arm64': 4.21.2 + '@rollup/rollup-darwin-x64': 4.21.2 + '@rollup/rollup-linux-arm-gnueabihf': 4.21.2 + '@rollup/rollup-linux-arm-musleabihf': 4.21.2 + '@rollup/rollup-linux-arm64-gnu': 4.21.2 + '@rollup/rollup-linux-arm64-musl': 4.21.2 + '@rollup/rollup-linux-powerpc64le-gnu': 4.21.2 + '@rollup/rollup-linux-riscv64-gnu': 4.21.2 + '@rollup/rollup-linux-s390x-gnu': 4.21.2 + '@rollup/rollup-linux-x64-gnu': 4.21.2 + '@rollup/rollup-linux-x64-musl': 4.21.2 + '@rollup/rollup-win32-arm64-msvc': 4.21.2 + '@rollup/rollup-win32-ia32-msvc': 4.21.2 + '@rollup/rollup-win32-x64-msvc': 4.21.2 fsevents: 2.3.3 run-parallel@1.2.0: @@ -3638,9 +3638,9 @@ snapshots: shebang-regex@3.0.0: {} - shiki@1.14.1: + shiki@1.15.2: dependencies: - '@shikijs/core': 1.14.1 + '@shikijs/core': 1.15.2 '@types/hast': 3.0.4 signal-exit@4.1.0: {} @@ -3779,14 +3779,14 @@ snapshots: dependencies: typescript: 5.5.4 - ts-node@10.9.2(@types/node@22.5.0)(typescript@5.5.4): + ts-node@10.9.2(@types/node@22.5.1)(typescript@5.5.4): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 22.5.0 + '@types/node': 22.5.1 acorn: 8.12.1 acorn-walk: 8.3.3 arg: 4.1.3 @@ -3802,7 +3802,7 @@ snapshots: tsx@4.19.0: dependencies: esbuild: 0.23.1 - get-tsconfig: 4.7.6 + get-tsconfig: 4.8.0 optionalDependencies: fsevents: 2.3.3 @@ -3819,7 +3819,7 @@ snapshots: lunr: 2.3.9 markdown-it: 14.1.0 minimatch: 9.0.5 - shiki: 1.14.1 + shiki: 1.15.2 typescript: 5.5.4 yaml: 2.5.0 @@ -3930,7 +3930,7 @@ snapshots: yargs@16.2.0: dependencies: cliui: 7.0.4 - escalade: 3.1.2 + escalade: 3.2.0 get-caller-file: 2.0.5 require-directory: 2.1.1 string-width: 4.2.3 @@ -3940,7 +3940,7 @@ snapshots: yargs@17.7.2: dependencies: cliui: 8.0.1 - escalade: 3.1.2 + escalade: 3.2.0 get-caller-file: 2.0.5 require-directory: 2.1.1 string-width: 4.2.3 diff --git a/src/DefaultJavascriptValidators.mts b/src/DefaultJavascriptValidators.mts index c1ef561..579a40a 100644 --- a/src/DefaultJavascriptValidators.mts +++ b/src/DefaultJavascriptValidators.mts @@ -11,11 +11,12 @@ import { MainApplicationScope, type ConfigurationUpdater, type ValidatorComponent, - JavascriptValidators + JavascriptValidators, + AssertionError } from "./internal/internal.mjs"; -const typedocWorkaround: null | ValidatorComponent | - JavascriptValidators = null; +const typedocWorkaround: null | ValidatorComponent | JavascriptValidators | + AssertionError = null; // noinspection PointlessBooleanExpressionJS if (typedocWorkaround !== null) console.log("WORKAROUND: https://github.com/microsoft/tsdoc/issues/348"); @@ -64,7 +65,8 @@ function requireThat(value: T, name: string): NumberValidator | Bool /** * Validates the state of a value. *

- * The returned validator throws an error immediately if a validation fails. + * The returned validator throws an exception immediately if a validation fails. This exception is then + * converted into an {@link AssertionError}. Exceptions unrelated to validation failures are not converted. * * @typeParam T - the type the value * @typeParam E - the type elements in the array or set @@ -76,14 +78,14 @@ function requireThat(value: T, name: string): NumberValidator | Bool * @throws TypeError if `name` is `undefined` or `null` * @throws RangeError if `name` is empty */ -function assertThat(value: number, name: string): NumberValidator; -function assertThat(value: boolean, name: string): BooleanValidator; -function assertThat(value: E[], name: string): ArrayValidator; -function assertThat(value: Set, name: string): SetValidator; -function assertThat(value: Map, name: string): MapValidator; -function assertThat(value: string, name: string): StringValidator; -function assertThat(value: T, name: string): ObjectValidator; -function assertThat(value: T, name: string): NumberValidator | BooleanValidator | +function assertThat(value: number, name?: string): NumberValidator; +function assertThat(value: boolean, name?: string): BooleanValidator; +function assertThat(value: E[], name?: string): ArrayValidator; +function assertThat(value: Set, name?: string): SetValidator; +function assertThat(value: Map, name?: string): MapValidator; +function assertThat(value: string, name?: string): StringValidator; +function assertThat(value: T, name?: string): ObjectValidator; +function assertThat(value: T, name?: string): NumberValidator | BooleanValidator | ArrayValidator | SetValidator | MapValidator | StringValidator | ObjectValidator { return DELEGATE.assertThat(value, name); diff --git a/src/internal/message/diff/ContextGenerator.mts b/src/internal/message/diff/ContextGenerator.mts index 9fc3433..3ac6677 100644 --- a/src/internal/message/diff/ContextGenerator.mts +++ b/src/internal/message/diff/ContextGenerator.mts @@ -14,7 +14,8 @@ import { isApplicationScope, assertThatInstanceOf, ValidationTarget, - AssertionError + AssertionError, + MessageBuilder } from "../../internal.mjs"; import isEqual from "lodash.isequal"; @@ -46,6 +47,10 @@ class ContextGenerator * `true` if error messages may include a diff that compares actual and expected values. */ private _allowDiff: boolean; + /** + * `true` if the output may include an explanation of the diff format. + */ + private _allowLegend = false; /** * Creates a ContextGenerator. @@ -117,6 +122,18 @@ expectedName: ${expectedName}`); return this; } + /** + * Determines if the output may include a legend of the diff format. + * + * @param allowLegend - `true` if the output may include an explanation of the diff format + * return this + */ + public allowLegend(allowLegend: boolean) + { + this._allowLegend = allowLegend; + return this; + } + /** * @returns the diff to append to the error message */ @@ -210,7 +227,8 @@ expectedName: ${expectedName}`); } const elementGenerator = new ContextGenerator(this.scope, this.configuration, - actualNameLine, expectedNameLine); + actualNameLine, expectedNameLine). + allowLegend(false); actualValueLine.ifValid(value => elementGenerator.actualValue(value)); expectedValueLine.ifValid(value => elementGenerator.expectedValue(value)); @@ -338,6 +356,8 @@ expectedName: ${expectedName}`); context.push(elementGenerator.getDiffSection(actualNameLine, actualValueLine, diffLine, expectedNameLine, expectedValueLine)); } + if (diffLinesExist && this._allowLegend) + context.push(new StringSection(MessageBuilder.DIFF_LEGEND)); return context; } diff --git a/src/internal/message/section/MessageBuilder.mts b/src/internal/message/section/MessageBuilder.mts index 47ec56b..a921248 100644 --- a/src/internal/message/section/MessageBuilder.mts +++ b/src/internal/message/section/MessageBuilder.mts @@ -88,7 +88,6 @@ Legend actualValue(actualValue). expectedValue(expectedValue); this.diff.push(...contextGenerator.build()); - this.diff.push(new StringSection(MessageBuilder.DIFF_LEGEND)); return this; } diff --git a/src/internal/util/AssertionError.mts b/src/internal/util/AssertionError.mts index 454a636..2089539 100644 --- a/src/internal/util/AssertionError.mts +++ b/src/internal/util/AssertionError.mts @@ -13,11 +13,6 @@ class AssertionError extends Error { super(message, options); this.name = this.constructor.name; - if (options !== undefined && options.cause !== undefined) - { - const originalError = options.cause; - this.stack = originalError.stack?.replace(originalError.name, this.name); - } } } diff --git a/src/internal/validator/AbstractValidators.mts b/src/internal/validator/AbstractValidators.mts index ff1c30a..f69a7d3 100644 --- a/src/internal/validator/AbstractValidators.mts +++ b/src/internal/validator/AbstractValidators.mts @@ -136,7 +136,12 @@ abstract class AbstractValidators implements Validators * A function that converts the thrown error to `AssertionError`. */ private static readonly CONVERT_TO_ASSERTION_ERROR: (error: Error) => Error = - error => new AssertionError(error.message, {cause: error}); + e => + { + const assertionError = new AssertionError(e.message); + assertionError.stack = e.stack?.replace(e.name, assertionError.name); + throw assertionError; + }; protected readonly scope: ApplicationScope; private requireThatConfiguration: Configuration; private assertThatConfiguration: Configuration; diff --git a/src/internal/validator/JavascriptValidatorsImpl.mts b/src/internal/validator/JavascriptValidatorsImpl.mts index 832845a..068e354 100644 --- a/src/internal/validator/JavascriptValidatorsImpl.mts +++ b/src/internal/validator/JavascriptValidatorsImpl.mts @@ -24,10 +24,11 @@ import { Type, requireThatType, ValidationTarget, - Pluralizer + Pluralizer, + AssertionError } from "../internal.mjs"; -const typedocWorkaround: null | ConfigurationUpdater = null; +const typedocWorkaround: null | ConfigurationUpdater | AssertionError = null; // noinspection PointlessBooleanExpressionJS if (typedocWorkaround !== null) console.log("WORKAROUND: https://github.com/microsoft/tsdoc/issues/348"); @@ -86,7 +87,9 @@ class JavascriptValidatorsImpl extends AbstractValidators } /** - * Validates the state of a value, throwing errors immediately on validation failure. + * Validates the state of a value. + *

+ * The returned validator throws an error immediately if a validation fails. * * @typeParam T - the type the value * @typeParam E - the type elements in the array or set @@ -113,7 +116,10 @@ class JavascriptValidatorsImpl extends AbstractValidators } /** - * Validates the state of a value, throwing `AssertionError` immediately on validation failure. + * Validates the state of a value. + *

+ * The returned validator throws an exception immediately if a validation fails. This exception is then + * converted into an {@link AssertionError}. Exceptions unrelated to validation failures are not converted. * * @typeParam T - the type the value * @typeParam E - the type elements in the array or set @@ -139,8 +145,9 @@ class JavascriptValidatorsImpl extends AbstractValidators } /** - * Validates the state of a value, capturing errors on validation failure rather than throwing them - * immediately. + * Validates the state of a value. + *

+ * The returned validator throws an error immediately if a validation fails. * * @typeParam T - the type the value * @typeParam E - the type elements in the array or set diff --git a/src/internal/validator/Objects.mts b/src/internal/validator/Objects.mts index ec57671..869c006 100644 --- a/src/internal/validator/Objects.mts +++ b/src/internal/validator/Objects.mts @@ -120,7 +120,11 @@ function assertThatValueIsNotNull(value: unknown, name: string): void catch (e) { if (e instanceof Error) - throw new AssertionError(e.message, {cause: e}); + { + const assertionError = new AssertionError(e.message); + assertionError.stack = e.stack?.replace(e.name, assertionError.name); + throw assertionError; + } throw e; } } @@ -179,7 +183,11 @@ function assertThatType(value: unknown, name: string, type: Type): void catch (e) { if (e instanceof Error) - throw new AssertionError(e.message, {cause: e}); + { + const assertionError = new AssertionError(e.message); + assertionError.stack = e.stack?.replace(e.name, assertionError.name); + throw assertionError; + } throw e; } } @@ -243,7 +251,11 @@ function assertThatTypeCategory(value: unknown, name: string, category: TypeCate catch (e) { if (e instanceof Error) - throw new AssertionError(e.message, {cause: e}); + { + const assertionError = new AssertionError(e.message); + assertionError.stack = e.stack?.replace(e.name, assertionError.name); + throw assertionError; + } throw e; } @@ -324,7 +336,11 @@ function assertThatInstanceOf(value: T, name: string, type: ClassConstructor< catch (e) { if (e instanceof Error) - throw new AssertionError(e.message, {cause: e}); + { + const assertionError = new AssertionError(e.message); + assertionError.stack = e.stack?.replace(e.name, assertionError.name); + throw assertionError; + } throw e; } } @@ -369,7 +385,11 @@ function assertThatStringIsNotEmpty(value: string, name: string): void catch (e) { if (e instanceof Error) - throw new AssertionError(e.message, {cause: e}); + { + const assertionError = new AssertionError(e.message); + assertionError.stack = e.stack?.replace(e.name, assertionError.name); + throw assertionError; + } throw e; } } diff --git a/test/ArrayTest.mts b/test/ArrayTest.mts index 238b898..db42a4e 100644 --- a/test/ArrayTest.mts +++ b/test/ArrayTest.mts @@ -10,7 +10,6 @@ import { } from "../src/index.mjs"; import {JavascriptValidatorsImpl} from "../src/internal/validator/JavascriptValidatorsImpl.mjs"; import {TestApplicationScope} from "./TestApplicationScope.mjs"; -import {map} from "lodash"; const validators = new JavascriptValidatorsImpl(new TestApplicationScope(TerminalEncoding.NONE), diff --git a/test/NumberTest.mts b/test/NumberTest.mts index b11075e..629de65 100644 --- a/test/NumberTest.mts +++ b/test/NumberTest.mts @@ -13,6 +13,7 @@ import { } from "../src/internal/internal.mjs"; import {TestApplicationScope} from "./TestApplicationScope.mjs"; + const validators = new JavascriptValidatorsImpl(new TestApplicationScope(TerminalEncoding.NONE), Configuration.DEFAULT); diff --git a/test/SetTest.mts b/test/SetTest.mts index 97f6579..f9a3c2e 100644 --- a/test/SetTest.mts +++ b/test/SetTest.mts @@ -10,6 +10,7 @@ import {assert} from "chai"; import {JavascriptValidatorsImpl} from "../src/internal/internal.mjs"; import {TestApplicationScope} from "./TestApplicationScope.mjs"; + const validators = new JavascriptValidatorsImpl(new TestApplicationScope(TerminalEncoding.NONE), Configuration.DEFAULT); diff --git a/test/SizeTest.mts b/test/SizeTest.mts index a68298b..a0640a2 100644 --- a/test/SizeTest.mts +++ b/test/SizeTest.mts @@ -13,6 +13,7 @@ import {mode} from "../build/mode.mjs"; import {JavascriptValidatorsImpl} from "../src/internal/internal.mjs"; import {TestApplicationScope} from "./TestApplicationScope.mjs"; + const validators = new JavascriptValidatorsImpl(new TestApplicationScope(TerminalEncoding.NONE), Configuration.DEFAULT); diff --git a/test/StringTest.mts b/test/StringTest.mts index 27525c7..5dcce38 100644 --- a/test/StringTest.mts +++ b/test/StringTest.mts @@ -4,10 +4,6 @@ import { } from "mocha"; import {assert} from "chai"; import { - TextOnly, - EOS_MARKER, - DIFF_DELETE, - DIFF_INSERT, JavascriptValidatorsImpl, Type } from "../src/internal/internal.mjs"; @@ -17,6 +13,7 @@ import { } from "../src/index.mjs"; import {TestApplicationScope} from "./TestApplicationScope.mjs"; + const validators = new JavascriptValidatorsImpl(new TestApplicationScope(TerminalEncoding.NONE), Configuration.DEFAULT); diff --git a/test/ValidationFailureTest.mts b/test/ValidationFailureTest.mts index 4a0daf9..b70556b 100644 --- a/test/ValidationFailureTest.mts +++ b/test/ValidationFailureTest.mts @@ -18,6 +18,7 @@ import { } from "../src/internal/internal.mjs"; import {TestApplicationScope} from "./TestApplicationScope.mjs"; + suite("ValidationFailureTest", () => { test("configurationIsUndefined", () =>