import { padStart } from 'lodash' ; export function getTemplateVersion ( versionStr ) { const splitted = versionStr . split ( '.' ) ; const minorStr = splitted [ 2 ] || '' ; const padded = splitted . map ( ( v ) => { const vMatches = v . match ( /\d+/ ) ; if ( vMatches ) { return padStart ( vMatches [ 0 ] , 2 , '0' ) ; } return '00' ; } ) ; const [ majorV , minorV , patchV ] = padded ; let buildV ; if ( minorStr . match ( 'alpha' ) ) { const matches = minorStr . match ( /alpha(?<alpha>\d+)/ ) ; if ( matches != null && matches . groups != null ) { const alphaVerInt = parseInt ( matches . groups . alpha , 10 ) ; buildV = padStart ( `${ alphaVerInt }` , 2 , '0' ) ; } } else if ( minorStr . match ( 'beta' ) ) { const matches = minorStr . match ( /beta(?<beta>\d+)/ ) ; if ( matches != null && matches . groups != null ) { const alphaVerInt = parseInt ( matches . groups . beta , 10 ) + 25 ; buildV = padStart ( `${ alphaVerInt }` , 2 , '0' ) ; } } else { buildV = '99' ; } const joinedParts = [ majorV , minorV , patchV , buildV ] . join ( '' ) ; return parseInt ( joinedParts , 10 ) ; }