about-system 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/about-system.js +13 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "about-system",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "A Node.js script to display key system information with emojis. Cross-platform support for Windows, macOS, and Linux with customizable output and caching.",
|
|
5
5
|
"main": "src/about-system.js",
|
|
6
6
|
"bin": {
|
package/src/about-system.js
CHANGED
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
* @license: MIT
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
import os from 'os';
|
|
23
|
+
import fs from 'fs';
|
|
24
|
+
import path from 'path';
|
|
25
|
+
import { execSync } from 'child_process';
|
|
26
|
+
import https from 'https';
|
|
27
27
|
|
|
28
28
|
// Cache configuration
|
|
29
29
|
const CACHE_FILE = path.join(os.tmpdir(), 'systeminfo-cache.json');
|
|
@@ -336,9 +336,9 @@ const infoFunctions = {
|
|
|
336
336
|
const addresses = [];
|
|
337
337
|
|
|
338
338
|
for (const name of Object.keys(interfaces)) {
|
|
339
|
-
for (const
|
|
340
|
-
if (
|
|
341
|
-
addresses.push(
|
|
339
|
+
for (const device of interfaces[name]) {
|
|
340
|
+
if (device.family === 'IPv4' && !device.internal) {
|
|
341
|
+
addresses.push(device.address);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
}
|
|
@@ -697,45 +697,8 @@ const infoFunctions = {
|
|
|
697
697
|
top_process(settings) {
|
|
698
698
|
const cached = getCachedValue(this.cache, 'top_process', settings);
|
|
699
699
|
if (cached) return cached;
|
|
700
|
-
|
|
701
|
-
if (
|
|
702
|
-
try {
|
|
703
|
-
// Get top process using PowerShell performance counters
|
|
704
|
-
const ps = execCommand('powershell.exe -Command "Get-Counter \'\\Process(*)\\% Processor Time\' | Select-Object -ExpandProperty CounterSamples | Where-Object {$_.InstanceName -notin @(\'_Total\', \'Idle\')} | Sort-Object CookedValue -Descending | Select-Object -First 1 | Select-Object InstanceName, @{Name=\'CPU%\'; Expression={[math]::Round($_.CookedValue, 1)}}"');
|
|
705
|
-
const lines = ps.split('\n').filter(line => line.trim());
|
|
706
|
-
if (lines.length > 0) {
|
|
707
|
-
const parts = lines[0].trim().split(/\s+/);
|
|
708
|
-
if (parts.length >= 2) {
|
|
709
|
-
const processName = parts[0];
|
|
710
|
-
const cpuPercent = parts[1];
|
|
711
|
-
const color = colors[settings.colors.top_process] || colors.magenta;
|
|
712
|
-
const emoji = settings.display.show_emojis ? '🔝 ' : '';
|
|
713
|
-
const result = `${color}${emoji}${cpuPercent}% ${processName}`;
|
|
714
|
-
setCachedValue(this.cache, 'top_process', result);
|
|
715
|
-
return result;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
} catch {}
|
|
719
|
-
|
|
720
|
-
// Fallback using tasklist
|
|
721
|
-
try {
|
|
722
|
-
const tasklist = execCommand('tasklist /fo csv | findstr /v "Image Name" | sort /r /+5');
|
|
723
|
-
const lines = tasklist.split('\n').filter(line => line.trim());
|
|
724
|
-
if (lines.length > 0) {
|
|
725
|
-
const line = lines[0];
|
|
726
|
-
const parts = line.split(',');
|
|
727
|
-
if (parts.length >= 5) {
|
|
728
|
-
const processName = parts[0].replace(/"/g, '').split('.')[0];
|
|
729
|
-
const memoryUsage = parts[4].replace(/"/g, '').replace(/[,\s]/g, '');
|
|
730
|
-
const color = colors[settings.colors.top_process] || colors.magenta;
|
|
731
|
-
const emoji = settings.display.show_emojis ? '🔝 ' : '';
|
|
732
|
-
const result = `${color}${emoji}${memoryUsage}KB ${processName}`;
|
|
733
|
-
setCachedValue(this.cache, 'top_process', result);
|
|
734
|
-
return result;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
} catch {}
|
|
738
|
-
} else if (IS_LINUX) {
|
|
700
|
+
|
|
701
|
+
if (IS_LINUX) {
|
|
739
702
|
try {
|
|
740
703
|
const ps = execCommand('ps -eo pcpu,comm --sort=-%cpu --no-headers');
|
|
741
704
|
const lines = ps.split('\n');
|
|
@@ -1634,11 +1597,11 @@ Linux-specific features:
|
|
|
1634
1597
|
}
|
|
1635
1598
|
|
|
1636
1599
|
// Run the script
|
|
1637
|
-
if (
|
|
1600
|
+
// if (import.meta.url === `file://${process.argv[1]}`) {
|
|
1638
1601
|
main().catch(error => {
|
|
1639
1602
|
console.error('Error:', error.message);
|
|
1640
1603
|
process.exit(1);
|
|
1641
1604
|
});
|
|
1642
|
-
}
|
|
1605
|
+
// }
|
|
1643
1606
|
|
|
1644
|
-
|
|
1607
|
+
export { displaySystemInfo, installShellGreeting };
|