@@ -19,6 +19,8 @@ import { parseArgs } from 'node:util'
1919import { promisify } from 'node:util'
2020import { exec as execCallback } from 'node:child_process'
2121
22+ import { checkVersionConsistency } from './check-version-consistency.mjs'
23+
2224const exec = promisify ( execCallback )
2325
2426const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
@@ -389,6 +391,10 @@ async function main() {
389391 type : 'boolean' ,
390392 default : false ,
391393 } ,
394+ 'skip-consistency-check' : {
395+ type : 'boolean' ,
396+ default : false ,
397+ } ,
392398 'skip-build' : {
393399 type : 'boolean' ,
394400 default : false ,
@@ -422,6 +428,7 @@ Options:
422428 --platform=PLATFORM Specific platform(s) to build (can specify multiple)
423429 --version=VERSION Version to publish (default: from package.json)
424430 --dry-run Perform dry-run without publishing
431+ --skip-consistency-check Skip package version consistency validation (NOT RECOMMENDED)
425432 --skip-build Skip building binaries (use existing)
426433 --skip-optional Skip optional platforms (armv7, alpine)
427434 --otp=CODE npm OTP for publishing
@@ -474,6 +481,31 @@ Notes:
474481 const version = values . version || await getVersion ( )
475482 console . log ( `Publishing version: ${ version } \n` )
476483
484+ // Check version consistency across all packages.
485+ if ( ! values [ 'skip-consistency-check' ] ) {
486+ console . log ( '📋 Package Version Consistency Check' )
487+ console . log ( '─' . repeat ( 60 ) )
488+ const isConsistent = await checkVersionConsistency ( version )
489+ console . log ( '─' . repeat ( 60 ) )
490+
491+ if ( ! isConsistent ) {
492+ console . log ( '\n❌ Version consistency check failed!' )
493+ console . log ( 'This is CRITICAL: All @socketbin packages must have the same version.' )
494+ console . log ( 'Fix the version mismatches before publishing.' )
495+
496+ if ( ! values [ 'dry-run' ] ) {
497+ console . log ( '\nAborting publish to prevent version inconsistency.' )
498+ console . log ( 'Use --skip-consistency-check to bypass this check (NOT RECOMMENDED).\n' )
499+ process . exitCode = 1
500+ return
501+ } else {
502+ console . log ( '\n⚠️ Continuing with dry-run despite version mismatch...\n' )
503+ }
504+ } else {
505+ console . log ( )
506+ }
507+ }
508+
477509 // Determine which platforms to build
478510 let platformsToBuild = values . platform || [ ]
479511
0 commit comments