Rather ignore the version comparisons and keep packages as is.

This commit is contained in:
Hein 2025-05-06 09:48:06 +02:00
parent 3013441c12
commit 0d38c77bee

View File

@ -176,8 +176,8 @@ class DependencyChecker {
if (version === "*" || version === "latest") return null; if (version === "*" || version === "latest") return null;
// Handle more version range operators: ^, ~, >=, > // Strip ALL range operators (^, ~, >=, >, <=, <) and any spaces after them
const cleanVersion = version.replace(/^[~^>=]+\s*/, ""); const cleanVersion = version.replace(/^[~^<>=]+\s*/g, "");
try { try {
if (semver.valid(cleanVersion)) return cleanVersion; if (semver.valid(cleanVersion)) return cleanVersion;
@ -590,19 +590,21 @@ class DependencyChecker {
if (appDependencies[dep]) { if (appDependencies[dep]) {
const appVersion = appDependencies[dep]; const appVersion = appDependencies[dep];
if (version !== appVersion) { // Extract just the version numbers for comparison
// Extract the version prefix (>=, >, ^, ~) if any const cleanCurrentVersion = version.replace(/^[~^<>=]+\s*/g, "");
const versionPrefix = version.match(/^([~^>=]+\s*)/)?.[0] || ''; const cleanAppVersion = appVersion.replace(/^[~^<>=]+\s*/g, "");
const newVersion = appVersion.startsWith(versionPrefix) ?
appVersion : if (cleanCurrentVersion !== cleanAppVersion) {
// If the app version doesn't have the same prefix, preserve the original prefix // Extract the version prefix (operators and spaces)
appVersion.match(/^[~^>=]+\s*/) ? const versionPrefix = version.match(/^[~^<>=]+\s*/)?.[0] || '';
appVersion :
`${versionPrefix}${appVersion.replace(/^[~^>=]+\s*/, '')}`; // Create new version string with original prefix but updated version number
const newVersion = versionPrefix + cleanAppVersion;
if (!dryRun) { if (!dryRun) {
packageJson[section]![dep] = newVersion; packageJson[section]![dep] = newVersion;
} }
updates.push({ updates.push({
package: packageJson.name, package: packageJson.name,
dependency: dep, dependency: dep,
@ -610,6 +612,7 @@ class DependencyChecker {
to: newVersion, to: newVersion,
type: section, type: section,
}); });
hasUpdates = true; hasUpdates = true;
} }
} }