Skip to content

Commit d318923

Browse files
committed
Add extensive debug logging to trace composer update issue
1 parent 6ccd5fe commit d318923

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/buddy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,14 @@ export class Buddy {
477477
if (composerUpdates.length > 0) {
478478
try {
479479
const { generateComposerUpdates } = await import('./utils/composer-parser')
480+
// Debug logging to see what composer updates are being passed
481+
console.log(`🐛 DEBUG: Passing ${composerUpdates.length} composer updates to parser:`)
482+
composerUpdates.forEach(update => {
483+
console.log(`🐛 - ${update.name}: ${update.currentVersion} -> ${update.newVersion}`)
484+
})
480485
// Pass only the composer updates for this specific group to prevent cross-contamination
481486
const compUpdates = await generateComposerUpdates(composerUpdates)
487+
console.log(`🐛 DEBUG: Composer parser returned ${compUpdates.length} file updates`)
482488
fileUpdates.push(...compUpdates)
483489
}
484490
catch (error) {

src/utils/composer-parser.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ export async function generateComposerUpdates(updates: Array<{ name: string, new
183183
const fileUpdates: Array<{ path: string, content: string, type: 'update' }> = []
184184
const composerUpdates = updates.filter(update => update.file.endsWith('composer.json'))
185185

186+
console.log(`🐛 COMPOSER PARSER DEBUG: Received ${updates.length} total updates, ${composerUpdates.length} composer updates`)
187+
composerUpdates.forEach(update => {
188+
console.log(`🐛 - Processing: ${update.name} -> ${update.newVersion}`)
189+
})
190+
186191
if (composerUpdates.length === 0) {
187192
return fileUpdates
188193
}
@@ -200,23 +205,31 @@ export async function generateComposerUpdates(updates: Array<{ name: string, new
200205
})
201206
}
202207

208+
console.log(`🐛 COMPOSER PARSER DEBUG: Processing ${updatesByFile.size} file(s)`)
209+
203210
// Process each composer.json file
204211
for (const [filePath, fileUpdates_] of updatesByFile) {
205212
try {
213+
console.log(`🐛 COMPOSER PARSER DEBUG: Processing file ${filePath} with ${fileUpdates_.length} updates`)
214+
206215
// Read current composer.json content
207216
const fs = await import('node:fs')
208217
let composerContent = fs.readFileSync(filePath, 'utf-8')
209218

219+
console.log(`🐛 COMPOSER PARSER DEBUG: Original composer.json content length: ${composerContent.length}`)
220+
210221
// Parse to understand structure
211222
const composerData: ComposerPackage = JSON.parse(composerContent)
212223

213224
// Apply updates using string replacement to preserve formatting
214225
for (const update of fileUpdates_) {
226+
console.log(`🐛 COMPOSER PARSER DEBUG: Applying update for ${update.name} -> ${update.newVersion}`)
215227
let packageFound = false
216228

217229
// Check in require section
218230
if (composerData.require && composerData.require[update.name]) {
219231
const currentVersionInFile = composerData.require[update.name]
232+
console.log(`🐛 Found ${update.name} in require: ${currentVersionInFile}`)
220233

221234
// For complex constraints like ">=6.0,<7.0", preserve the constraint format
222235
// and just update the version numbers
@@ -235,6 +248,8 @@ export async function generateComposerUpdates(updates: Array<{ name: string, new
235248
newVersion = `${originalPrefix}${update.newVersion}`
236249
}
237250

251+
console.log(`🐛 Updating ${update.name}: ${currentVersionInFile} -> ${newVersion}`)
252+
238253
// Create regex to find the exact line with this package and version
239254
const packageRegex = new RegExp(
240255
`("${update.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}"\\s*:\\s*")([^"]+)(")`,
@@ -248,6 +263,7 @@ export async function generateComposerUpdates(updates: Array<{ name: string, new
248263
// Check in require-dev section
249264
if (!packageFound && composerData['require-dev'] && composerData['require-dev'][update.name]) {
250265
const currentVersionInFile = composerData['require-dev'][update.name]
266+
console.log(`🐛 Found ${update.name} in require-dev: ${currentVersionInFile}`)
251267

252268
// For complex constraints like ">=6.0,<7.0", preserve the constraint format
253269
// and just update the version numbers
@@ -266,6 +282,8 @@ export async function generateComposerUpdates(updates: Array<{ name: string, new
266282
newVersion = `${originalPrefix}${update.newVersion}`
267283
}
268284

285+
console.log(`🐛 Updating ${update.name}: ${currentVersionInFile} -> ${newVersion}`)
286+
269287
const packageRegex = new RegExp(
270288
`("${update.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}"\\s*:\\s*")([^"]+)(")`,
271289
'g',
@@ -280,6 +298,8 @@ export async function generateComposerUpdates(updates: Array<{ name: string, new
280298
}
281299
}
282300

301+
console.log(`🐛 COMPOSER PARSER DEBUG: Final composer.json content length: ${composerContent.length}`)
302+
283303
fileUpdates.push({
284304
path: filePath,
285305
content: composerContent,
@@ -291,5 +311,6 @@ export async function generateComposerUpdates(updates: Array<{ name: string, new
291311
}
292312
}
293313

314+
console.log(`🐛 COMPOSER PARSER DEBUG: Returning ${fileUpdates.length} file updates`)
294315
return fileUpdates
295316
}

0 commit comments

Comments
 (0)