also looking at this
fix(ci): land the lock-file repair instead of describing it
#1408
6 files
+193
-15
| @@ -1374,8 +1374,10 @@ cli | ||
| 1374 | 1374 | baseBranch: config.repository?.baseBranch ?? 'main', |
| 1375 | 1375 | ai: createAiClient(config, logger), |
| 1376 | 1376 | logger, |
| 1377 | dryRun: Boolean(options.dryRun), | |
| 1377 | 1378 | regenerateLockfile: async () => { |
| 1378 | const { regenerateLockFile, detectRequiredPackageManagers } = await import('../src/utils/lock-file') | |
| 1379 | const { regenerateLockFile, detectRequiredPackageManagers, getAllLockFilePaths } = await import('../src/utils/lock-file') | |
| 1380 | const { commitAndPush } = await import('../src/utils/git') | |
| 1379 | 1381 | |
| 1380 | 1382 | // Detection keys off the manifests a lockfile is derived from, so a |
| 1381 | 1383 | // repository with several ecosystems regenerates each of them. |
| @@ -1390,7 +1392,24 @@ cli | ||
| 1390 | 1392 | logger.warn(`⚠️ ${result.message}`) |
| 1391 | 1393 | } |
| 1392 | 1394 | |
| 1393 | return regenerated | |
| 1395 | if (!regenerated) | |
| 1396 | return { regenerated: false, pushed: false } | |
| 1397 | ||
| 1398 | // Rewriting the file in a workspace that is about to be thrown away | |
| 1399 | // repairs nothing. The job checked this branch out with credentials, | |
| 1400 | // so the commit is a local one rather than a branch recreation. | |
| 1401 | try { | |
| 1402 | const pushed = await commitAndPush( | |
| 1403 | getAllLockFilePaths(), | |
| 1404 | 'fix(deps): regenerate the lock file\n\nThe lock file had drifted from the manifest, which failed CI.', | |
| 1405 | process.cwd(), | |
| 1406 | ) | |
| 1407 | return { regenerated: true, pushed } | |
| 1408 | } | |
| 1409 | catch (error) { | |
| 1410 | logger.warn(`⚠️ Could not push the regenerated lock file: ${error instanceof Error ? error.message : String(error)}`) | |
| 1411 | return { regenerated: true, pushed: false } | |
| 1412 | } | |
| 1394 | 1413 | }, |
| 1395 | 1414 | }) |
| 1396 | 1415 | |