diff --git a/CHANGELOG.md b/CHANGELOG.md index bf37fe5..52d722d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @warkypublic/monorepo-dep-checker +## 1.0.3 + +### Patch Changes + +- Fixed ><= version comparisons + ## 1.0.2 ### Patch Changes diff --git a/package.json b/package.json index bb12da8..7589b8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@warkypublic/monorepo-dep-checker", - "version": "1.0.2", + "version": "1.0.3", "description": "A CLI tool to check and manage dependencies across packages in a monorepo", "type": "module", "main": "./dist/index.js", @@ -37,23 +37,23 @@ "author": "Hein (Warkanum) Puth", "license": "MIT", "dependencies": { - "chalk": "^5.3.0", - "semver": "^7.5.4", + "chalk": "^5.4.1", + "semver": "^7.7.1", "yargs": "^17.7.2" }, "devDependencies": { - "@changesets/cli": "^2.27.10", - "@eslint/js": "^9.16.0", - "@types/node": "^22.10.1", - "@types/semver": "~7.5.8", + "@changesets/cli": "^2.29.3", + "@eslint/js": "^9.26.0", + "@types/node": "^22.15.12", + "@types/semver": "~7.7.0", "@types/yargs": "~17.0.33", - "eslint": "^9.16.0", - "globals": "^15.13.0", - "prettier-eslint": "^16.3.0", - "typescript-eslint": "^8.18.0", - "typesync": "^0.14.0", - "vite": "^5.4.11", - "vitest": "^1.6.0" + "eslint": "^9.26.0", + "globals": "^16.0.0", + "prettier-eslint": "^16.4.1", + "typescript-eslint": "^8.32.0", + "typesync": "^0.14.3", + "vite": "^6.3.5", + "vitest": "^3.1.3" }, "engines": { "node": ">=14.16" diff --git a/src/lib.ts b/src/lib.ts index 42664ec..32bbc22 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -173,11 +173,12 @@ class DependencyChecker { if (semver.valid(workspaceVersion)) return workspaceVersion; return null; } - + if (version === "*" || version === "latest") return null; - - const cleanVersion = version.replace(/^[~^]/, ""); - + + // Handle more version range operators: ^, ~, >=, > + const cleanVersion = version.replace(/^[~^>=]+\s*/, ""); + try { if (semver.valid(cleanVersion)) return cleanVersion; return null; @@ -590,14 +591,23 @@ class DependencyChecker { if (appDependencies[dep]) { const appVersion = appDependencies[dep]; if (version !== appVersion) { + // Extract the version prefix (>=, >, ^, ~) if any + const versionPrefix = version.match(/^([~^>=]+\s*)/)?.[0] || ''; + const newVersion = appVersion.startsWith(versionPrefix) ? + appVersion : + // If the app version doesn't have the same prefix, preserve the original prefix + appVersion.match(/^[~^>=]+\s*/) ? + appVersion : + `${versionPrefix}${appVersion.replace(/^[~^>=]+\s*/, '')}`; + if (!dryRun) { - packageJson[section]![dep] = appVersion; + packageJson[section]![dep] = newVersion; } updates.push({ package: packageJson.name, dependency: dep, from: version, - to: appVersion, + to: newVersion, type: section, }); hasUpdates = true;