From 22ae54d66c2dec8200947066dbb9c33bb729b8a8 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 8 Apr 2022 08:37:00 -0700 Subject: [PATCH 1/9] deps: revert to lru-cache@6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b04e0d32..16e344ce 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "node": "^10.0.0 || ^12.0.0 || ^14.0.0 || >=16.0.0" }, "dependencies": { - "lru-cache": "^7.4.0" + "lru-cache": "^6.0.0" }, "author": "GitHub Inc.", "templateOSS": { From 85b269a90806713d2a41e8e990b0ea6bc274b171 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 8 Apr 2022 08:38:56 -0700 Subject: [PATCH 2/9] fix: allow node >=10 --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 16e344ce..670181a9 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "coverage-map": "map.js" }, "engines": { - "node": "^10.0.0 || ^12.0.0 || ^14.0.0 || >=16.0.0" + "node": ">=10" }, "dependencies": { "lru-cache": "^6.0.0" @@ -53,6 +53,7 @@ "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", "version": "3.2.2", + "engines": ">=10", "ciVersions": [ "10.0.0", "10.x", From a683bf9224c2ff86de298fa2402116aabbd06305 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Apr 2022 06:34:45 +0000 Subject: [PATCH 3/9] chore: bump @npmcli/template-oss from 3.2.2 to 3.3.2 Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 3.2.2 to 3.3.2. - [Release notes](https://github.com/npm/template-oss/releases) - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/template-oss/compare/v3.2.2...v3.3.2) --- updated-dependencies: - dependency-name: "@npmcli/template-oss" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 670181a9..116ce179 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "devDependencies": { "@npmcli/eslint-config": "^3.0.1", - "@npmcli/template-oss": "3.2.2", + "@npmcli/template-oss": "3.3.2", "tap": "^16.0.0" }, "license": "ISC", From e7c3973ce5a065f46d55322806278f327d42c4f8 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 9 Apr 2022 13:36:15 -0700 Subject: [PATCH 4/9] chore: postinstall for dependabot template-oss PR --- .github/workflows/audit.yml | 2 +- .github/workflows/ci.yml | 4 ++-- .github/workflows/post-dependabot.yml | 7 +++---- package.json | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 549243ae..03dcd937 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -23,5 +23,5 @@ jobs: - name: Update npm to latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - run: npm -v - - run: npm i --ignore-scripts --package-lock + - run: npm i --ignore-scripts --no-audit --no-fund --package-lock - run: npm audit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c5c5df3..538e46a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: - name: Update npm to latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - run: npm -v - - run: npm i --ignore-scripts + - run: npm i --ignore-scripts --no-audit --no-fund - run: npm run lint test: @@ -81,5 +81,5 @@ jobs: if: ${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - run: npm -v - - run: npm i --ignore-scripts + - run: npm i --ignore-scripts --no-audit --no-fund - run: npm test --ignore-scripts diff --git a/.github/workflows/post-dependabot.yml b/.github/workflows/post-dependabot.yml index dde84863..0372a7a9 100644 --- a/.github/workflows/post-dependabot.yml +++ b/.github/workflows/post-dependabot.yml @@ -4,13 +4,12 @@ name: Post Dependabot Actions on: pull_request -# https://docs.github.com/en/rest/overview/permissions-required-for-github-apps +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions permissions: - actions: write contents: write jobs: - Install: + template-oss-apply: runs-on: ubuntu-latest if: github.actor == 'dependabot[bot]' steps: @@ -36,7 +35,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh pr checkout ${{ github.event.pull_request.number }} - npm install --ignore-scripts + npm install --ignore-scripts --no-audit --no-fund npm run template-oss-apply git add . git commit -am "chore: postinstall for dependabot template-oss PR" diff --git a/package.json b/package.json index 116ce179..c2194511 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "author": "GitHub Inc.", "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "3.2.2", + "version": "3.3.2", "engines": ">=10", "ciVersions": [ "10.0.0", From 4ceca76729c577166395f19172854cbbcce3cec1 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 9 Apr 2022 19:48:49 -0700 Subject: [PATCH 5/9] fix(bin): get correct value from arg separated by equals (#449) Fixes #431 --- bin/semver.js | 3 ++- tap-snapshots/test/bin/semver.js.test.cjs | 2 +- test/bin/semver.js | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/bin/semver.js b/bin/semver.js index 779b8b0c..8d1b5572 100755 --- a/bin/semver.js +++ b/bin/semver.js @@ -37,8 +37,9 @@ const main = () => { let a = argv.shift() const indexOfEqualSign = a.indexOf('=') if (indexOfEqualSign !== -1) { + const value = a.slice(indexOfEqualSign + 1) a = a.slice(0, indexOfEqualSign) - argv.unshift(a.slice(indexOfEqualSign + 1)) + argv.unshift(value) } switch (a) { case '-rv': case '-rev': case '--rev': case '--reverse': diff --git a/tap-snapshots/test/bin/semver.js.test.cjs b/tap-snapshots/test/bin/semver.js.test.cjs index 0e11ff06..4093fdab 100644 --- a/tap-snapshots/test/bin/semver.js.test.cjs +++ b/tap-snapshots/test/bin/semver.js.test.cjs @@ -305,7 +305,7 @@ exports[`test/bin/semver.js TAP inc tests > -i premajor 1.0.0 --preid=beta 1`] = Object { "code": 0, "err": "", - "out": "2.0.0-0\\n", + "out": "2.0.0-beta.0\\n", "signal": null, } ` diff --git a/test/bin/semver.js b/test/bin/semver.js index 56ca6a1c..04333fd5 100644 --- a/test/bin/semver.js +++ b/test/bin/semver.js @@ -60,3 +60,21 @@ t.test('coercing', t => Promise.all([ ['not a version', '1.2.3', '-c'], ['not a version', '-c'], ].map(args => t.resolveMatchSnapshot(run(args), args.join(' '))))) + +t.test('args with equals', t => Promise.all([ + [['--version', '1.2.3'], '1.2.3'], + [['--range', '1'], ['1.2.3'], ['2.3.4'], '1.2.3'], + [['--increment', 'major'], ['1.0.0'], '2.0.0'], + [['--increment', 'premajor'], ['--preid', 'beta'], ['1.0.0'], '2.0.0-beta.0'], +].map(async (args) => { + const expected = args.pop() + const equals = args.map((a) => a.join('=')) + const spaces = args.reduce((acc, a) => acc.concat(a), []) + const res1 = await run(equals) + const res2 = await run(spaces) + t.equal(res1.signal, null) + t.equal(res1.code, 0) + t.equal(res1.err, '') + t.equal(res1.out.trim(), expected) + t.strictSame(res1, res2, args.join(' ')) +}))) From 802e16174fe2a704dba16e97891ce36dc4f2ad76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 9 Apr 2022 20:06:20 -0700 Subject: [PATCH 6/9] fix: inc prerelease with numeric preid (#380) --- classes/semver.js | 2 +- test/fixtures/increments.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/classes/semver.js b/classes/semver.js index ed81a7ec..af629551 100644 --- a/classes/semver.js +++ b/classes/semver.js @@ -265,7 +265,7 @@ class SemVer { if (identifier) { // 1.2.0-beta.1 bumps to 1.2.0-beta.2, // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 - if (this.prerelease[0] === identifier) { + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (isNaN(this.prerelease[1])) { this.prerelease = [identifier, 0] } diff --git a/test/fixtures/increments.js b/test/fixtures/increments.js index e214f2ed..6a998b5f 100644 --- a/test/fixtures/increments.js +++ b/test/fixtures/increments.js @@ -82,4 +82,9 @@ module.exports = [ ['1.2.0-1', 'minor', '1.2.0', false, 'dev'], ['1.0.0-1', 'major', '1.0.0', 'dev'], ['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev'], + + ['1.2.3-0', 'prerelease', '1.2.3-1.0', false, '1'], + ['1.2.3-1.0', 'prerelease', '1.2.3-1.1', false, '1'], + ['1.2.3-1.1', 'prerelease', '1.2.3-1.2', false, '1'], + ['1.2.3-1.1', 'prerelease', '1.2.3-2.0', false, '2'], ] From 4571a1a05ab527e81c162857c8ed6c37210e90ab Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Sat, 9 Apr 2022 23:53:49 -0700 Subject: [PATCH 7/9] chore(test): add test for max safe integers in ranges (#450) Closes #393 --- test/fixtures/range-parse.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/fixtures/range-parse.js b/test/fixtures/range-parse.js index 8779f9a7..83adaff8 100644 --- a/test/fixtures/range-parse.js +++ b/test/fixtures/range-parse.js @@ -2,6 +2,7 @@ // null result means it's not a valid range // '*' is the return value from functions.validRange(), but // new Range().range will be '' in those cases +const { MAX_SAFE_INTEGER } = require('../../internal/constants') module.exports = [ ['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'], ['1.0.0 - 2.0.0', '>=1.0.0-0 <2.0.1-0', { includePrerelease: true }], @@ -93,4 +94,7 @@ module.exports = [ ['>=09090', '>=9090.0.0', true], ['>=09090-0', null, { includePrerelease: true }], ['>=09090-0', null, { loose: true, includePrerelease: true }], + [`^${MAX_SAFE_INTEGER}.0.0`, null], + [`=${MAX_SAFE_INTEGER}.0.0`, `${MAX_SAFE_INTEGER}.0.0`], + [`^${MAX_SAFE_INTEGER - 1}.0.0`, `>=${MAX_SAFE_INTEGER - 1}.0.0 <${MAX_SAFE_INTEGER}.0.0-0`], ] From f070dde0cc22894ac254e281cb36a79ab790272d Mon Sep 17 00:00:00 2001 From: Louis Bompart Date: Sun, 10 Apr 2022 23:08:05 -0400 Subject: [PATCH 8/9] fix: ensure SemVer instance passed to inc are not modified (#427) --- functions/inc.js | 5 ++++- test/functions/inc.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/functions/inc.js b/functions/inc.js index aa4d83ab..62d1da2c 100644 --- a/functions/inc.js +++ b/functions/inc.js @@ -7,7 +7,10 @@ const inc = (version, release, options, identifier) => { } try { - return new SemVer(version, options).inc(release, identifier).version + return new SemVer( + version instanceof SemVer ? version.version : version, + options + ).inc(release, identifier).version } catch (er) { return null } diff --git a/test/functions/inc.js b/test/functions/inc.js index c91f6ebc..909debdf 100644 --- a/test/functions/inc.js +++ b/test/functions/inc.js @@ -10,10 +10,20 @@ test('increment versions test', (t) => { t.equal(found, wanted, `${cmd} === ${wanted}`) const parsed = parse(pre, options) + const parsedAsInput = parse(pre, options) if (wanted) { parsed.inc(what, id) t.equal(parsed.version, wanted, `${cmd} object version updated`) t.equal(parsed.raw, wanted, `${cmd} object raw field updated`) + + const preIncObject = JSON.stringify(parsedAsInput) + inc(parsedAsInput, what, options, id) + const postIncObject = JSON.stringify(parsedAsInput) + t.equal( + postIncObject, + preIncObject, + `${cmd} didn't modify its input` + ) } else if (parsed) { t.throws(() => { parsed.inc(what, id) From 7a2d69c294571bb71c53ccf8104edb3937bc28b2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 12 Apr 2022 09:20:06 -0700 Subject: [PATCH 9/9] chore(main): release 7.3.7 (#451) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 15 +++++++++++++++ package.json | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4214af72..04ad0067 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +### [7.3.7](https://github.com/npm/node-semver/compare/v7.3.6...v7.3.7) (2022-04-11) + + +### Bug Fixes + +* allow node >=10 ([85b269a](https://github.com/npm/node-semver/commit/85b269a90806713d2a41e8e990b0ea6bc274b171)) +* **bin:** get correct value from arg separated by equals ([#449](https://github.com/npm/node-semver/issues/449)) ([4ceca76](https://github.com/npm/node-semver/commit/4ceca76729c577166395f19172854cbbcce3cec1)), closes [#431](https://github.com/npm/node-semver/issues/431) +* ensure SemVer instance passed to inc are not modified ([#427](https://github.com/npm/node-semver/issues/427)) ([f070dde](https://github.com/npm/node-semver/commit/f070dde0cc22894ac254e281cb36a79ab790272d)) +* inc prerelease with numeric preid ([#380](https://github.com/npm/node-semver/issues/380)) ([802e161](https://github.com/npm/node-semver/commit/802e16174fe2a704dba16e97891ce36dc4f2ad76)) + + +### Dependencies + +* revert to lru-cache@6 ([22ae54d](https://github.com/npm/node-semver/commit/22ae54d66c2dec8200947066dbb9c33bb729b8a8)) + ### [7.3.6](https://github.com/npm/node-semver/compare/v7.3.5...v7.3.6) (2022-04-05) diff --git a/package.json b/package.json index c2194511..7898f590 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "7.3.6", + "version": "7.3.7", "description": "The semantic version parser used by npm.", "main": "index.js", "scripts": {