import { readFileSync } from 'fs' ; import { join } from 'path' ; import Compiler from './compiler' ; import validateRestSpec from './steps/validate-rest-spec' ; import addInfo from './steps/add-info' ; import addDescription from './steps/add-description' ; import validateModel from './steps/validate-model' ; import addContentType from './steps/add-content-type' ; import readDefinitionValidation from './steps/read-definition-validation' ; const nvmrc = readFileSync ( join ( __dirname , '..' , '..' , '.nvmrc' ) , 'utf8' ) ; const nodejsMajor = process . version . split ( '.' ) . shift ( ) ?. slice ( 1 ) ?? '' ; const nvmMajor = nvmrc . trim ( ) . split ( '.' ) . shift ( ) ?? '' ; if ( nodejsMajor !== nvmMajor ) { console . error ( `Bad nodejs major version, you are using ${ nodejsMajor }, while ${ nvmMajor } should be used. Run 'nvm install' to fix this.` ) ; process . exit ( 1 ) ; } const compiler = new Compiler ( ) ; compiler . generateModel ( ) . step ( addInfo ) . step ( addContentType ) . step ( readDefinitionValidation ) . step ( validateRestSpec ) . step ( addDescription ) . step ( validateModel ) . write ( ) . then ( ( ) => { console . log ( 'Done' ) ; } ) . catch ( err => { console . error ( err ) ; process . exit ( 1 ) ; } ) ;