11import { readFileSync } from 'fs' ;
2+ import { detectNonCommutative } from 'src/utils/commutativity' ;
23import type { Dialect } from '../../utils/schemaValidator' ;
34import { prepareOutFolder , validatorForDialect } from '../../utils/utils-node' ;
45import { info } from '../views' ;
5- import { detectNonCommutative } from 'src/utils/commutativity' ;
66
77export const checkHandler = async ( out : string , dialect : Dialect ) => {
88 const { snapshots } = prepareOutFolder ( out ) ;
99 const validator = validatorForDialect ( dialect ) ;
1010
11- const snapshotsData : any [ ] = [ ] ;
11+ // const snapshotsData: PostgresSnapshot [] = [];
1212
1313 for ( const snapshot of snapshots ) {
1414 const raw = JSON . parse ( readFileSync ( `./${ snapshot } ` ) . toString ( ) ) ;
1515
16- snapshotsData . push ( raw ) ;
16+ // snapshotsData.push(raw);
1717
1818 const res = validator ( raw ) ;
1919 if ( res . status === 'unsupported' ) {
@@ -36,18 +36,18 @@ export const checkHandler = async (out: string, dialect: Dialect) => {
3636 }
3737 }
3838
39- // Non-commutative detection for branching
4039 try {
41- const nc = await detectNonCommutative ( snapshotsData , dialect ) ;
42- if ( nc . conflicts . length > 0 ) {
40+ const response = await detectNonCommutative ( snapshots , dialect ) ;
41+ if ( response ! . conflicts . length > 0 ) {
4342 console . log ( '\nNon-commutative migration branches detected:' ) ;
44- for ( const c of nc . conflicts ) {
43+ for ( const c of response ! . conflicts ) {
4544 console . log ( `- Parent ${ c . parentId } ${ c . parentPath ? ` (${ c . parentPath } )` : '' } ` ) ;
4645 console . log ( ` A: ${ c . branchA . headId } (${ c . branchA . path } )` ) ;
4746 console . log ( ` B: ${ c . branchB . headId } (${ c . branchB . path } )` ) ;
4847 // for (const r of c.reasons) console.log(` • ${r}`);
4948 }
5049 }
5150 } catch ( e ) {
51+ console . error ( e ) ;
5252 }
5353} ;
0 commit comments