diff --git a/scripts/update-export-versions.cjs b/scripts/update-export-versions.cjs index ba272a32..67860b4d 100644 --- a/scripts/update-export-versions.cjs +++ b/scripts/update-export-versions.cjs @@ -77,13 +77,15 @@ const updateVersionsFile = () => { if (versionsUpdated) { fs.writeFileSync(versionsFilePath, fileContent, 'utf8'); console.log('\n🎉 Successfully synchronized versions.ts!'); + + // Only update snapshots when versions actually changed + // This requires packages to be built, so we only do it when necessary + console.log('\n📸 Updating snapshots to match new versions...'); + updateSnapshots(); } else { console.log('\n✅ All versions in versions.ts are already up to date.'); + console.log(' Skipping snapshot update (no version changes detected).'); } - - // Always update snapshots to ensure they match current versions - console.log('\n📸 Ensuring snapshots match current versions...'); - updateSnapshots(); }; const updateSnapshots = () => { @@ -99,9 +101,14 @@ const updateSnapshots = () => { console.log('✅ Snapshots updated successfully!'); } catch (error) { console.error('❌ Failed to update snapshots:', error.message); - console.log( - '⚠️ Please run "pnpm --filter @openzeppelin/ui-builder-app test src/export/__tests__/ -- -u" manually' + console.error( + '⚠️ Snapshot update failed. This will cause CI failures if versions.ts is committed without matching snapshots.' + ); + console.error( + ' To fix manually, run: pnpm --filter @openzeppelin/ui-builder-app test src/export/__tests__/ -- -u' ); + // Exit with error code to prevent committing mismatched versions + process.exit(1); } };