From 09c69e23cdf6c69c51f83635482fff89ab2574e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Apr 2023 09:56:04 -0700 Subject: [PATCH 1/3] chore: bump @npmcli/template-oss from 4.13.0 to 4.14.1 (#555) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: npm CLI robot Co-authored-by: nlf --- .github/workflows/release.yml | 3 ++- package.json | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de63a6de..eb79eb20 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -322,6 +322,7 @@ jobs: shell: bash permissions: deployments: write + id-token: write steps: - name: Checkout uses: actions/checkout@v3 @@ -338,7 +339,7 @@ jobs: - name: Publish env: PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} - run: npm publish + run: npm publish --provenance post-release-integration: needs: [ release, release-integration ] diff --git a/package.json b/package.json index 0a6095b8..c4fca044 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ }, "devDependencies": { "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.13.0", + "@npmcli/template-oss": "4.14.1", "tap": "^16.0.0" }, "license": "ISC", @@ -53,7 +53,7 @@ "author": "GitHub Inc.", "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.13.0", + "version": "4.14.1", "engines": ">=10", "ciVersions": [ "10.0.0", From d30d25a5c1fb963c3cc9178cb1769fe45e4a3cab Mon Sep 17 00:00:00 2001 From: Tom Jenkinson Date: Fri, 12 May 2023 16:50:08 +0100 Subject: [PATCH 2/3] fix: show type on invalid semver error (#559) Add linting rules to prevent regression in using node internals. --- .eslintrc.local.js | 18 +++++++++++++++++ classes/semver.js | 2 +- test/classes/semver.js | 44 ++++++++++++++++++++++++----------------- test/functions/parse.js | 2 +- test/map.js | 1 + 5 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 .eslintrc.local.js diff --git a/.eslintrc.local.js b/.eslintrc.local.js new file mode 100644 index 00000000..5b7c98ea --- /dev/null +++ b/.eslintrc.local.js @@ -0,0 +1,18 @@ +'use strict' + +module.exports = { + overrides: [ + { + files: ['bin/**', 'classes/**', 'functions/**', 'internal/**', 'ranges/**'], + rules: { + 'import/no-extraneous-dependencies': [ + 'error', + { + devDependencies: false, + }, + ], + 'import/no-nodejs-modules': ['error'], + }, + }, + ], +} diff --git a/classes/semver.js b/classes/semver.js index 25ee889d..99dbe82d 100644 --- a/classes/semver.js +++ b/classes/semver.js @@ -16,7 +16,7 @@ class SemVer { version = version.version } } else if (typeof version !== 'string') { - throw new TypeError(`Invalid Version: ${require('util').inspect(version)}`) + throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`) } if (version.length > MAX_LENGTH) { diff --git a/test/classes/semver.js b/test/classes/semver.js index 4556434c..6be0ac8f 100644 --- a/test/classes/semver.js +++ b/test/classes/semver.js @@ -62,15 +62,19 @@ test('really big numeric prerelease value', (t) => { }) test('invalid version numbers', (t) => { - ['1.2.3.4', - 'NOT VALID', - 1.2, - null, - 'Infinity.NaN.Infinity', - ].forEach((v) => { - t.throws(() => { - new SemVer(v) // eslint-disable-line no-new - }, { name: 'TypeError', message: `Invalid Version: ${v}` }) + ['1.2.3.4', 'NOT VALID', 1.2, null, 'Infinity.NaN.Infinity'].forEach((v) => { + t.throws( + () => { + new SemVer(v) // eslint-disable-line no-new + }, + { + name: 'TypeError', + message: + typeof v === 'string' + ? `Invalid Version: ${v}` + : `Invalid version. Must be a string. Got type "${typeof v}".`, + } + ) }) t.end() @@ -113,15 +117,19 @@ test('compare main vs pre', (t) => { }) test('invalid version numbers', (t) => { - ['1.2.3.4', - 'NOT VALID', - 1.2, - null, - 'Infinity.NaN.Infinity', - ].forEach((v) => { - t.throws(() => { - new SemVer(v) // eslint-disable-line no-new - }, { name: 'TypeError', message: `Invalid Version: ${v}` }) + ['1.2.3.4', 'NOT VALID', 1.2, null, 'Infinity.NaN.Infinity'].forEach((v) => { + t.throws( + () => { + new SemVer(v) // eslint-disable-line no-new + }, + { + name: 'TypeError', + message: + typeof v === 'string' + ? `Invalid Version: ${v}` + : `Invalid version. Must be a string. Got type "${typeof v}".`, + } + ) }) t.end() diff --git a/test/functions/parse.js b/test/functions/parse.js index f3ca4cd8..dd091e94 100644 --- a/test/functions/parse.js +++ b/test/functions/parse.js @@ -20,7 +20,7 @@ t.test('throw errors if asked to', t => { parse([], null, true) }, { name: 'TypeError', - message: 'Invalid Version: []', + message: 'Invalid version. Must be a string. Got type "object".', }) t.end() }) diff --git a/test/map.js b/test/map.js index aded2454..8179e71e 100644 --- a/test/map.js +++ b/test/map.js @@ -6,6 +6,7 @@ const ignore = [ '.github', '.commitlintrc.js', '.eslintrc.js', + '.eslintrc.local.js', 'node_modules', 'coverage', 'tap-snapshots', From aa016a67162c195938f7873ea29a73dac47ff9ba Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 12 May 2023 15:51:17 +0000 Subject: [PATCH 3/3] chore: release 7.5.1 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 6 ++++++ package.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index cd52c1e8..fbde66cb 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.5.0" + ".": "7.5.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index fed01d9b..99f8e567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [7.5.1](https://github.com/npm/node-semver/compare/v7.5.0...v7.5.1) (2023-05-12) + +### Bug Fixes + +* [`d30d25a`](https://github.com/npm/node-semver/commit/d30d25a5c1fb963c3cc9178cb1769fe45e4a3cab) [#559](https://github.com/npm/node-semver/pull/559) show type on invalid semver error (#559) (@tjenkinson) + ## [7.5.0](https://github.com/npm/node-semver/compare/v7.4.0...v7.5.0) (2023-04-17) ### Features diff --git a/package.json b/package.json index c4fca044..592404a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.5.0", + "version": "7.5.1", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": {