Skip to content

Commit 65240d5

Browse files
committed
fix: remove overly restrictive Composer constraint filtering
The previous approach was filtering out ALL updates that didn't match version constraints, including major updates that users want to see as individual PRs. Now including all available Composer updates and letting the grouping logic handle separation of major vs non-major updates naturally: - Major updates → Individual PRs (even if beyond constraints) - Minor/patch updates → Grouped PR (naturally respect constraints) This matches user expectations and fixes the issue where 0 Composer packages were being found due to overly strict constraint filtering.
1 parent 49dd91a commit 65240d5

File tree

1 file changed

+3
-60
lines changed

1 file changed

+3
-60
lines changed

src/registry/registry-client.ts

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,8 @@ export class RegistryClient {
568568

569569
try {
570570
// Use composer outdated to get all available updates, then filter based on version constraints
571-
this.logger.info('Running composer outdated command...')
572571
const output = await this.runCommand('composer', ['outdated', '--format=json', '--direct'])
573-
this.logger.info(`Composer outdated raw output: ${output}`)
574572
const composerData = JSON.parse(output)
575-
this.logger.info(`Parsed composer data:`, composerData)
576573

577574
const updates: PackageUpdate[] = []
578575

@@ -582,84 +579,30 @@ export class RegistryClient {
582579
const fs = await import('node:fs')
583580
const path = await import('node:path')
584581
const composerJsonPath = path.join(this.projectPath, 'composer.json')
585-
this.logger.info(`Looking for composer.json at: ${composerJsonPath}`)
586582
if (fs.existsSync(composerJsonPath)) {
587583
const composerContent = fs.readFileSync(composerJsonPath, 'utf-8')
588584
composerJsonData = JSON.parse(composerContent)
589-
this.logger.info(`Found composer.json with packages:`, Object.keys(composerJsonData.require || {}), Object.keys(composerJsonData['require-dev'] || {}))
590-
} else {
591-
this.logger.warn(`composer.json not found at ${composerJsonPath}`)
592585
}
593586
}
594587
catch (error) {
595588
this.logger.warn('Failed to read composer.json for dependency type detection:', error)
596589
}
597590

598-
// Parse composer outdated output and filter based on version constraints
591+
// Parse composer outdated output and filter based on version constraints
599592
if (composerData.installed) {
600-
this.logger.info(`Processing ${composerData.installed.length} outdated Composer packages`)
601-
602593
for (const pkg of composerData.installed) {
603594
if (pkg.name && pkg.version && pkg.latest) {
604-
this.logger.info(`Checking ${pkg.name}: ${pkg.version}${pkg.latest}`)
605-
606595
// Get the version constraint from composer.json
607596
const requireConstraint = composerJsonData.require?.[pkg.name]
608597
const requireDevConstraint = composerJsonData['require-dev']?.[pkg.name]
609598
const constraint = requireConstraint || requireDevConstraint
610-
611-
this.logger.info(`Constraint for ${pkg.name}: ${constraint}`)
612-
599+
613600
if (!constraint) {
614-
this.logger.info(`Skipping ${pkg.name}: not found in composer.json`)
615601
continue // Skip packages not found in composer.json
616602
}
617603

618-
// Check if the latest version respects the version constraint
604+
// Include all available updates - let grouping and strategy handle filtering
619605
let newVersion = pkg.latest
620-
const currentMajor = this.getMajorVersion(pkg.version)
621-
const latestMajor = this.getMajorVersion(pkg.latest)
622-
623-
this.logger.info(`Version analysis for ${pkg.name}: current major=${currentMajor}, latest major=${latestMajor}`)
624-
625-
// For caret constraints (^), only allow updates within the same major version
626-
if (constraint.startsWith('^')) {
627-
if (currentMajor !== latestMajor) {
628-
this.logger.info(`Skipping ${pkg.name}: major version change not allowed by ^ constraint`)
629-
continue // Skip major version updates for caret constraints
630-
}
631-
}
632-
633-
// For tilde constraints (~), handle according to the constraint level
634-
if (constraint.startsWith('~')) {
635-
const currentMinor = this.getMinorVersion(pkg.version)
636-
const latestMinor = this.getMinorVersion(pkg.latest)
637-
638-
// ~1.2.3 allows patch updates within 1.2.x
639-
// ~1.2 allows minor and patch updates within 1.x.x
640-
const constraintParts = constraint.replace('~', '').split('.')
641-
if (constraintParts.length >= 3) {
642-
// ~1.2.3 - only allow patches in same minor version
643-
if (currentMajor !== latestMajor || currentMinor !== latestMinor) {
644-
this.logger.info(`Skipping ${pkg.name}: version change not allowed by ~x.y.z constraint`)
645-
continue
646-
}
647-
} else if (constraintParts.length >= 2) {
648-
// ~1.2 - allow minor/patch in same major version
649-
if (currentMajor !== latestMajor) {
650-
this.logger.info(`Skipping ${pkg.name}: major version change not allowed by ~x.y constraint`)
651-
continue
652-
}
653-
} else {
654-
// ~1 - allow minor/patch in same major version
655-
if (currentMajor !== latestMajor) {
656-
this.logger.info(`Skipping ${pkg.name}: major version change not allowed by ~x constraint`)
657-
continue
658-
}
659-
}
660-
}
661-
662-
this.logger.info(`Accepted ${pkg.name}: ${pkg.version}${newVersion}`)
663606

664607
const updateType = getUpdateType(pkg.version, newVersion)
665608

0 commit comments

Comments
 (0)