diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c4d651..e22b432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## NEXT PATCH RELEASE + +### Bug fixes + +* Fixes version check does not support composer version ranges. + ## 4.0.0 ### Breaking changes diff --git a/lib/commands/compatibility.js b/lib/commands/compatibility.js index bccc3cd..b48c721 100755 --- a/lib/commands/compatibility.js +++ b/lib/commands/compatibility.js @@ -2,7 +2,7 @@ const Chalk = require('chalk'); const Program = require('commander'); -const semver = require('semver'); +const { compareVersions, compareVersionsWithComperator } = require('composer-version-constraint-evaluator'); const { promisify } = require('util'); const ShopwareStoreCommander = require('../shopwareStoreCommander'); @@ -65,7 +65,7 @@ async function main() { let minCompatibleVersion; if (binary.compatibleSoftwareVersions.length > 0) { binary.compatibleSoftwareVersions.sort( - (lhs, rhs) => semver.compare(lhs.name, rhs.name), + (lhs, rhs) => compareVersions(lhs.name, rhs.name), ); minCompatibleVersion = binary.compatibleSoftwareVersions[0].name; } else { @@ -74,19 +74,19 @@ async function main() { ).shift().name; } - if (semver.lt(Program.opts().minVersion, minCompatibleVersion)) { + if (compareVersionsWithComperator(Program.opts().minVersion, minCompatibleVersion, '<')) { // Add new version compatibility entries to lower the minimum compatibility console.log(`Lowering minimum compatible Shopware version of binary ${binary.version} to ${Program.opts().minVersion}...`); binary.compatibleSoftwareVersions = binary.compatibleSoftwareVersions.concat(shopwareVersions.filter( version => version.selectable - && semver.gte(version.name, Program.opts().minVersion) - && semver.lt(version.name, minCompatibleVersion), + && compareVersionsWithComperator(version.name, Program.opts().minVersion, '>=') + && compareVersionsWithComperator(version.name, minCompatibleVersion, '<'), )); - } else if (semver.gt(Program.opts().minVersion, minCompatibleVersion)) { + } else if (compareVersionsWithComperator(Program.opts().minVersion, minCompatibleVersion, '>')) { // Remove some version compatibilities to raise the minimum compatibility console.log(`Raising minimum compatible Shopware version of binary ${binary.version} to ${Program.opts().minVersion}...`); binary.compatibleSoftwareVersions = binary.compatibleSoftwareVersions.filter( - version => version.selectable && semver.gte(version.name, Program.opts().minVersion), + version => version.selectable && compareVersionsWithComperator(version.name, Program.opts().minVersion, '>='), ); } else { console.log(`Minimum compatible Shopware version of binary ${binary.version} already matches ${Program.opts().minVersion}`); @@ -97,7 +97,7 @@ async function main() { if (binary.compatibleSoftwareVersions.length === 0) { // Add at least the minimum compatible shopware version binary.compatibleSoftwareVersions = [ - shopwareVersions.find(version => version.selectable && semver.eq(version.name, Program.opts().minVersion)), + shopwareVersions.find(version => version.selectable && compareVersionsWithComperator(version.name, Program.opts().minVersion, '=')), ]; } diff --git a/lib/commands/list.js b/lib/commands/list.js index d3a2fba..840948f 100755 --- a/lib/commands/list.js +++ b/lib/commands/list.js @@ -2,7 +2,7 @@ const Chalk = require('chalk'); const Program = require('commander'); -const semver = require('semver'); +const { compareVersions } = require('composer-version-constraint-evaluator'); const Table = require('cli-table'); const ShopwareStoreCommander = require('../shopwareStoreCommander'); const programVersion = require('../version'); @@ -16,7 +16,7 @@ const getShopwareCompatibility = (plugin, reverse) => { const sortedVersions = plugin.latestBinary.compatibleSoftwareVersions .map(shopwareVersion => shopwareVersion.name) - .sort(semver.compare); + .sort(compareVersions); return (reverse) ? sortedVersions.pop() : sortedVersions.shift(); }; @@ -27,7 +27,7 @@ const pluginComparators = { const vA = (a.latestBinary) ? a.latestBinary.version : '0.0.0'; const vB = (b.latestBinary) ? b.latestBinary.version : '0.0.0'; - return semver.compare(vA, vB); + return compareVersions(vA, vB); }, active: (a, b) => a.activationStatus.name.localeCompare(b.activationStatus.name), reviewStatus: (a, b) => { @@ -46,13 +46,13 @@ const pluginComparators = { const vA = getShopwareCompatibility(a, false) || '10000.0.0'; const vB = getShopwareCompatibility(b, false) || '10000.0.0'; - return semver.compare(vA, vB); + return compareVersions(vA, vB); }, maxShopwareCompatibility: (a, b) => { const vA = getShopwareCompatibility(a, true) || '10000.0.0'; const vB = getShopwareCompatibility(b, true) || '10000.0.0'; - return semver.compare(vA, vB); + return compareVersions(vA, vB); }, }; diff --git a/lib/commands/upload.js b/lib/commands/upload.js index 957428c..c400aeb 100755 --- a/lib/commands/upload.js +++ b/lib/commands/upload.js @@ -3,7 +3,7 @@ const Chalk = require('chalk'); const path = require('path'); const Program = require('commander'); -const semver = require('semver'); +const { compareVersionsReverse } = require('composer-version-constraint-evaluator'); const ShopwareStoreCommander = require('../shopwareStoreCommander'); const publishPluginReleaseEvent = require('../publishPluginReleaseEvent'); const util = require('../util'); @@ -22,9 +22,8 @@ function parseOnOffAutoOption(suppliedValue) { return suppliedValue; default: console.error(Chalk.white.bgRed.bold(`Invalid value '${suppliedValue}' for option --license-check-required.`)); - process.exit(-1); - return undefined; + return process.exit(-1); } } @@ -99,7 +98,7 @@ async function main() { return newBinary; }).sort( // Sort by version (semver) and release date (from new to old) - (lhs, rhs) => semver.rcompare(lhs.version, rhs.version) || (-1 * lhs.creationDate.localeCompare(rhs.creationDate)), + (lhs, rhs) => compareVersionsReverse(lhs.version, rhs.version) || (-1 * lhs.creationDate.localeCompare(rhs.creationDate)), ); const latestReleasedBinary = (releasedBinaries.length > 0) ? releasedBinaries[0] : null; diff --git a/lib/plugin.js b/lib/plugin.js index 5e99634..a37738e 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -1,7 +1,7 @@ const fs = require('mz/fs'); const JSZip = require('jszip'); const path = require('path'); -const semver = require('semver'); +const { versionSatisfiesConstraint } = require('composer-version-constraint-evaluator'); const { parseChangelogMarkdown } = require('./changelogMarkdownParser'); function readInfoFromComposerJson(composerJsonString) { @@ -82,7 +82,7 @@ module.exports = class Plugin { const shopwareVersion = this.getShopware6Semver(shopwareMarketingVersion); const pluginShopwareCompatibility = this.getShopware6Semver(this.shopwareCompatibility); - return semver.satisfies(shopwareVersion, pluginShopwareCompatibility); + return versionSatisfiesConstraint(shopwareVersion, pluginShopwareCompatibility); } if (this.shopwareMajorVersion === 5) { @@ -90,7 +90,7 @@ module.exports = class Plugin { return false; } - return semver.satisfies(shopwareMarketingVersion, this.shopwareCompatibility); + return versionSatisfiesConstraint(shopwareMarketingVersion, this.shopwareCompatibility); } throw new Error( diff --git a/package-lock.json b/package-lock.json index 6d2b5e0..673351a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,8 +24,7 @@ "jszip": "^3.6.0", "marked": "^2.0.3", "mz": "^2.4.0", - "node-notifier": "^9.0.1", - "semver": "^7.3.5" + "node-notifier": "^9.0.1" }, "bin": { "scs-commander": "index.js", diff --git a/package.json b/package.json index 368fb1d..94d1bbf 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "marked": "^2.0.3", "mz": "^2.4.0", "node-notifier": "^9.0.1", - "semver": "^7.3.5" + "composer-version-constraint-evaluator": "^1.0.0" }, "devDependencies": { "cspell": "^5.4.0", @@ -59,4 +59,4 @@ "node": ">=18.0.0" }, "preferGlobal": true -} +} \ No newline at end of file