import { createHash } from 'crypto' ; import { hashElement } from 'folder-hash' ; const rootDir = `${ __dirname }/../../../..` ; export const getBaseHash = async ( ) : Promise < string > => { const hash = createHash ( 'sha1' ) ; const { hash : unchainedHash } = await hashElement ( rootDir , { folders : { exclude : [ '.*' , '*' ] } , files : { include : [ 'package.json' , 'lerna.json' ] } , } ) ; hash . update ( unchainedHash ) ; const { hash : packagesHash } = await hashElement ( `${ rootDir }/packages` , { folders : { include : [ '**' ] , exclude : [ '.*' , 'dist' , 'node_modules' , 'pulumi' ] } , files : { include : [ '*.ts' , '*.json' , 'Dockerfile' ] } , } ) ; hash . update ( packagesHash ) ; const { hash : commonHash } = await hashElement ( `${ rootDir }/coinstacks/common` , { folders : { include : [ '**' ] , exclude : [ '.*' , 'dist' , 'node_modules' , 'pulumi' ] } , files : { include : [ '*.ts' , '*.json' , 'Dockerfile' ] } , } ) ; hash . update ( commonHash ) ; const { hash : dependenciesHash } = await hashElement ( `${ rootDir }/coinstacks` , { folders : { include : [ '**' ] , exclude : [ '.*' , 'common' , 'dist' , 'node_modules' , 'pulumi' ] } , files : { include : [ 'package.json' ] } , } ) ; hash . update ( dependenciesHash ) ; return hash . digest ( 'hex' ) ; } ;