Skip to content

Commit dad0cc9

Browse files
committed
🐛 CRITICAL FIX: Fix composer update detection
- Fixed bug where composer show versions array was incorrectly parsed as object keys - Now properly detects all available composer package versions - Enhanced detection finds best patch, minor, and major updates per package - Fixes issue where 0 composer updates were found despite packages being available - Clean up debug logging chore: wip
1 parent 793b1d0 commit dad0cc9

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/registry/registry-client.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ export class RegistryClient {
626626
const showOutput = await this.runCommand('composer', ['show', pkg.name, '--available', '--format=json'])
627627
const showData = JSON.parse(showOutput)
628628
if (showData.versions) {
629-
availableVersions = Object.keys(showData.versions)
629+
availableVersions = showData.versions // This is already an array of version strings
630630
}
631631
} catch (error) {
632632
console.warn(`Failed to get available versions for ${pkg.name}, using latest only:`, error)
@@ -680,7 +680,9 @@ export class RegistryClient {
680680

681681
// Parse current version
682682
const currentParts = this.parseVersion(currentVersion)
683-
if (!currentParts) return []
683+
if (!currentParts) {
684+
return []
685+
}
684686

685687
let bestPatch: string | null = null
686688
let bestMinor: string | null = null
@@ -693,10 +695,13 @@ export class RegistryClient {
693695
}
694696

695697
const versionParts = this.parseVersion(version)
696-
if (!versionParts) continue
698+
if (!versionParts) {
699+
continue
700+
}
697701

698702
// Skip versions that are not newer
699-
if (this.compareVersions(version, currentVersion) <= 0) {
703+
const comparison = this.compareVersions(version, currentVersion)
704+
if (comparison <= 0) {
700705
continue
701706
}
702707

@@ -719,9 +724,15 @@ export class RegistryClient {
719724
}
720725

721726
// Add the best candidates
722-
if (bestPatch) candidates.push({ version: bestPatch, type: 'patch' })
723-
if (bestMinor) candidates.push({ version: bestMinor, type: 'minor' })
724-
if (bestMajor) candidates.push({ version: bestMajor, type: 'major' })
727+
if (bestPatch) {
728+
candidates.push({ version: bestPatch, type: 'patch' })
729+
}
730+
if (bestMinor) {
731+
candidates.push({ version: bestMinor, type: 'minor' })
732+
}
733+
if (bestMajor) {
734+
candidates.push({ version: bestMajor, type: 'major' })
735+
}
725736

726737
return candidates
727738
}

0 commit comments

Comments
 (0)