1- const execSync = require ( "node:child_process" ) . execSync ;
21const path = require ( "node:path" ) ;
32
43const rootPath = path . resolve ( `${ __dirname } /../` ) ;
@@ -14,31 +13,34 @@ const discoveredPositionsJSFilename = "js/positions.js";
1413
1514module . exports = {
1615
17- async logSystemInformation ( ) {
16+ async logSystemInformation ( mirrorVersion ) {
1817 try {
19- let installedNodeVersion = execSync ( "node -v" , { encoding : "utf-8" } ) . replace ( "v" , "" ) . replace ( / (?: \r \n | \r | \n ) / g, "" ) ;
18+ const system = await si . system ( ) ;
19+ const osInfo = await si . osInfo ( ) ;
20+ const versions = await si . versions ( ) ;
21+
22+ const usedNodeVersion = process . version . replace ( "v" , "" ) ;
23+ const installedNodeVersion = versions . node ;
24+ const totalRam = ( os . totalmem ( ) / 1024 / 1024 ) . toFixed ( 2 ) ;
25+ const freeRam = ( os . freemem ( ) / 1024 / 1024 ) . toFixed ( 2 ) ;
26+ const usedRam = ( ( os . totalmem ( ) - os . freemem ( ) ) / 1024 / 1024 ) . toFixed ( 2 ) ;
2027
21- const staticData = await si . get ( {
22- system : "manufacturer, model, virtual" ,
23- osInfo : "platform, distro, release, arch" ,
24- versions : "kernel, node, npm, pm2"
25- } ) ;
2628 let systemDataString = [
27- "\n##### System Information # ####" ,
28- `- SYSTEM: manufacturer: ${ staticData . system . manufacturer } ; model: ${ staticData . system . model } ; virtual: ${ staticData . system . virtual } ; timeZone : ${ Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone } ` ,
29- `- OS: platform: ${ staticData . osInfo . platform } ; distro: ${ staticData . osInfo . distro } ; release: ${ staticData . osInfo . release } ; arch: ${ staticData . osInfo . arch } ; kernel: ${ staticData . versions . kernel } ` ,
30- `- VERSIONS: electron: ${ process . versions . electron } ; used node: ${ staticData . versions . node } ; installed node: ${ installedNodeVersion } ; npm: ${ staticData . versions . npm } ; pm2: ${ staticData . versions . pm2 } ` ,
31- `- ENV: XDG_SESSION_TYPE: ${ process . env . XDG_SESSION_TYPE } ; MM_CONFIG_FILE: ${ process . env . MM_CONFIG_FILE } ; ` ,
32- ` WAYLAND_DISPLAY: ${ process . env . WAYLAND_DISPLAY } ; DISPLAY: ${ process . env . DISPLAY } ; ELECTRON_ENABLE_GPU: ${ process . env . ELECTRON_ENABLE_GPU } ` ,
33- `- RAM: total: ${ ( os . totalmem ( ) / 1024 / 1024 ) . toFixed ( 2 ) } MB; free: ${ ( os . freemem ( ) / 1024 / 1024 ) . toFixed ( 2 ) } MB; used: ${ ( ( os . totalmem ( ) - os . freemem ( ) ) / 1024 / 1024 ) . toFixed ( 2 ) } MB` ,
34- `- UPTIME : ${ Math . floor ( os . uptime ( ) / 60 ) } minutes`
29+ "\n#### System Information ####" ,
30+ `- SYSTEM: manufacturer: ${ system . manufacturer } ; model: ${ system . model } ; virtual: ${ system . virtual } ; MM : ${ mirrorVersion } ` ,
31+ `- OS: platform: ${ osInfo . platform } ; distro: ${ osInfo . distro } ; release: ${ osInfo . release } ; arch: ${ osInfo . arch } ; kernel: ${ versions . kernel } ` ,
32+ `- VERSIONS: electron: ${ process . versions . electron } ; used node: ${ usedNodeVersion } ; installed node: ${ installedNodeVersion } ; npm: ${ versions . npm } ; pm2: ${ versions . pm2 } ` ,
33+ `- ENV: XDG_SESSION_TYPE: ${ process . env . XDG_SESSION_TYPE } ; MM_CONFIG_FILE: ${ process . env . MM_CONFIG_FILE } ` ,
34+ ` WAYLAND_DISPLAY: ${ process . env . WAYLAND_DISPLAY } ; DISPLAY: ${ process . env . DISPLAY } ; ELECTRON_ENABLE_GPU: ${ process . env . ELECTRON_ENABLE_GPU } ` ,
35+ `- RAM: total: ${ totalRam } MB; free: ${ freeRam } MB; used: ${ usedRam } MB` ,
36+ `- OTHERS : uptime: ${ Math . floor ( os . uptime ( ) / 60 ) } minutes; timeZone: ${ Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone } `
3537 ] . join ( "\n" ) ;
3638 Log . info ( systemDataString ) ;
3739
3840 // Return is currently only for jest
3941 return systemDataString ;
40- } catch ( e ) {
41- Log . error ( e ) ;
42+ } catch ( error ) {
43+ Log . error ( error ) ;
4244 }
4345 } ,
4446
0 commit comments