import os from "os" ; import fs from "fs-extra" ; import ciInfo from "ci-info" ; type EnvironmentData = { systemPlatform : NodeJS . Platform ; systemRelease : string ; systemArchitecture : string ; cpuCount : number ; cpuModel : string | null ; cpuSpeed : number | null ; memoryInMb : number ; isCI : boolean ; ciName : string | null ; sstVersion : string ; } ; let data ; export function getEnvironmentData ( ) { if ( data ) { return data ; } const cpus = os . cpus ( ) || [ ] ; const isSeed = ! ! process . env . SEED_APP_NAME ; data = { systemPlatform : os . platform ( ) , systemRelease : os . release ( ) , systemArchitecture : os . arch ( ) , cpuCount : cpus . length , cpuModel : cpus . length ? cpus [ 0 ] . model : null , cpuSpeed : cpus . length ? cpus [ 0 ] . speed : null , memoryInMb : Math . trunc ( os . totalmem ( ) / Math . pow ( 1024 , 2 ) ) , isCI : ciInfo . isCI || isSeed , ciName : ( isSeed ? "Seed" : ciInfo . name ) || null , sstVersion : getSSTVersion ( ) , } ; return data ; } function getSSTVersion ( ) { const module = "@serverless-stack/core/package.json" ; const packageJson = fs . readJsonSync ( require . resolve ( module ) ) ; return packageJson . version ; }