about-system 0.0.18 → 0.0.19
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/README.md +128 -67
- package/dist/about-system-cli.js +113 -205
- package/dist/about-system-cli.js.map +1 -1
- package/dist/index.d.ts +3 -9
- package/dist/index.js +4 -4
- package/dist/system-info-api-Bc0iSNdN.js +837 -0
- package/dist/system-info-api-Bc0iSNdN.js.map +1 -0
- package/dist/system-info-api.d.ts +313 -194
- package/dist/system-info-api.js +9 -791
- package/dist/system-info-api.js.map +1 -1
- package/package.json +4 -4
- package/src/about-system-cli.ts +124 -221
- package/src/cache/cache-config.ts +68 -0
- package/src/cache/cache.ts +95 -0
- package/src/info/hardware.ts +173 -0
- package/src/info/memory.ts +215 -0
- package/src/info/network.ts +213 -0
- package/src/info/platform.ts +145 -0
- package/src/info/process.ts +72 -0
- package/src/info/settings.ts +209 -0
- package/src/info/software.ts +192 -0
- package/src/info/system-status.ts +152 -0
- package/src/system-info-api.ts +78 -1117
- package/src/types/internal-types.ts +21 -0
- package/src/utils/command.ts +47 -0
- package/src/utils/network.ts +58 -0
- package/src/utils/platform.ts +13 -0
package/src/about-system-cli.ts
CHANGED
|
@@ -1,179 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import os from
|
|
3
|
-
import fs from
|
|
4
|
-
import path from
|
|
5
|
-
import { fileURLToPath } from
|
|
6
|
-
import { getSystemInfo } from
|
|
7
|
-
import type { SystemInfo, SystemInfoOptions } from
|
|
2
|
+
import os from "os";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { getSystemInfo } from "./system-info-api";
|
|
7
|
+
import type { SystemInfo, SystemInfoOptions } from "./systeminfo-types";
|
|
8
8
|
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
['ip', 'iplocal', 'city', 'domain', 'isp'],
|
|
21
|
-
['shell', 'pacman', 'services_running', 'containers'],
|
|
22
|
-
],
|
|
23
|
-
colors: {
|
|
24
|
-
user: 'red',
|
|
25
|
-
hostname: 'orange',
|
|
26
|
-
disk_used: 'purple',
|
|
27
|
-
ram_used: 'yellow',
|
|
28
|
-
top_process: 'magenta',
|
|
29
|
-
uptime: 'cyan',
|
|
30
|
-
ip: 'green',
|
|
31
|
-
iplocal: 'yellow',
|
|
32
|
-
city: 'green',
|
|
33
|
-
domain: 'gray',
|
|
34
|
-
isp: 'lightblue',
|
|
35
|
-
os: 'gray',
|
|
36
|
-
cpu: 'orange',
|
|
37
|
-
gpu: 'yellow',
|
|
38
|
-
device: 'yellow',
|
|
39
|
-
kernel: 'green',
|
|
40
|
-
shell: 'orange',
|
|
41
|
-
pacman: 'multicolor',
|
|
42
|
-
ports: 'multicolor',
|
|
43
|
-
containers: 'green',
|
|
44
|
-
memory_available: 'blue',
|
|
45
|
-
swap_used: 'purple',
|
|
46
|
-
load_average: 'red',
|
|
47
|
-
users_logged_in: 'cyan',
|
|
48
|
-
network_interfaces: 'yellow',
|
|
49
|
-
mount_points: 'gray',
|
|
50
|
-
services_running: 'green',
|
|
51
|
-
temperature: 'red',
|
|
52
|
-
battery: 'green',
|
|
53
|
-
screen_resolution: 'blue',
|
|
54
|
-
},
|
|
55
|
-
display: {
|
|
56
|
-
show_emojis: true,
|
|
57
|
-
single_line: false,
|
|
58
|
-
line_wrap_length: process?.stdout?.columns || 100,
|
|
59
|
-
},
|
|
60
|
-
network: {
|
|
61
|
-
show_offline_message: true,
|
|
62
|
-
},
|
|
63
|
-
advanced: {
|
|
64
|
-
debug: false,
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// Color codes
|
|
69
|
-
const colors = {
|
|
70
|
-
reset: '\x1b[0m',
|
|
71
|
-
red: '\x1b[38;5;196m',
|
|
72
|
-
orange: '\x1b[38;5;208m',
|
|
73
|
-
yellow: '\x1b[38;5;226m',
|
|
74
|
-
green: '\x1b[38;5;46m',
|
|
75
|
-
blue: '\x1b[38;5;39m',
|
|
76
|
-
cyan: '\x1b[38;5;51m',
|
|
77
|
-
purple: '\x1b[38;5;171m',
|
|
78
|
-
magenta: '\x1b[38;5;213m',
|
|
79
|
-
gray: '\x1b[38;5;250m',
|
|
80
|
-
lightblue: '\x1b[38;5;220m',
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// Emoji mappings
|
|
84
|
-
const emojis: Record<string, string> = {
|
|
85
|
-
user: '👤 ',
|
|
86
|
-
hostname: '🏠 ',
|
|
87
|
-
ip: '🌎 ',
|
|
88
|
-
iplocal: '🌐 ',
|
|
89
|
-
city: '📍 ',
|
|
90
|
-
domain: '🔗 ',
|
|
91
|
-
isp: '👮 ',
|
|
92
|
-
os: '⚡ ',
|
|
93
|
-
cpu: '📈 ',
|
|
94
|
-
gpu: '🎮 ',
|
|
95
|
-
device: '💻 ',
|
|
96
|
-
kernel: '🔧 ',
|
|
97
|
-
shell: '🐚 ',
|
|
98
|
-
pacman: '🚀 ',
|
|
99
|
-
disk_used: '📁 ',
|
|
100
|
-
ram_used: '💾 ',
|
|
101
|
-
top_process: '🔝 ',
|
|
102
|
-
uptime: '⏱️ ',
|
|
103
|
-
ports: '🔌 ',
|
|
104
|
-
containers: '📦',
|
|
105
|
-
memory_available: '🧠 ',
|
|
106
|
-
swap_used: '🔄 ',
|
|
107
|
-
load_average: '⚖️ ',
|
|
108
|
-
users_logged_in: '👥 ',
|
|
109
|
-
network_interfaces: '🌐 ',
|
|
110
|
-
mount_points: '📂 ',
|
|
111
|
-
services_running: '⚙️ ',
|
|
112
|
-
temperature: '🌡️ ',
|
|
113
|
-
battery_charging: '🔌 ',
|
|
114
|
-
battery: '🔋 ',
|
|
115
|
-
screen_resolution: '🖥️ ',
|
|
116
|
-
};
|
|
11
|
+
import {
|
|
12
|
+
Settings,
|
|
13
|
+
DEFAULT_SETTINGS,
|
|
14
|
+
colors,
|
|
15
|
+
SETTINGS_FILE,
|
|
16
|
+
CACHE_FILE,
|
|
17
|
+
loadSettings,
|
|
18
|
+
saveSettings,
|
|
19
|
+
} from "./info/settings";
|
|
117
20
|
|
|
118
21
|
// Platform detection
|
|
119
|
-
const IS_WINDOWS = os.platform() ===
|
|
120
|
-
|
|
121
|
-
interface Settings {
|
|
122
|
-
display_order: string[][];
|
|
123
|
-
colors: Record<string, string>;
|
|
124
|
-
display: {
|
|
125
|
-
show_emojis: boolean;
|
|
126
|
-
single_line: boolean;
|
|
127
|
-
line_wrap_length: number;
|
|
128
|
-
};
|
|
129
|
-
network: {
|
|
130
|
-
show_offline_message: boolean;
|
|
131
|
-
};
|
|
132
|
-
advanced: {
|
|
133
|
-
debug: boolean;
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function loadSettings(): Settings {
|
|
138
|
-
try {
|
|
139
|
-
if (fs.existsSync(SETTINGS_FILE)) {
|
|
140
|
-
const settings = JSON.parse(fs.readFileSync(SETTINGS_FILE, 'utf8'));
|
|
141
|
-
return { ...DEFAULT_SETTINGS, ...settings };
|
|
142
|
-
}
|
|
143
|
-
} catch {}
|
|
144
|
-
return DEFAULT_SETTINGS;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function saveSettings(settings: Settings): boolean {
|
|
148
|
-
try {
|
|
149
|
-
const configDir = path.dirname(SETTINGS_FILE);
|
|
150
|
-
if (!fs.existsSync(configDir)) {
|
|
151
|
-
fs.mkdirSync(configDir, { recursive: true });
|
|
152
|
-
}
|
|
153
|
-
fs.writeFileSync(SETTINGS_FILE, JSON.stringify(settings, null, 2));
|
|
154
|
-
return true;
|
|
155
|
-
} catch {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
22
|
+
const IS_WINDOWS = os.platform() === "win32";
|
|
159
23
|
|
|
160
24
|
function formatValue(key: string, value: string, settings: Settings): string {
|
|
161
|
-
if (!value || value.trim() ===
|
|
25
|
+
if (!value || value.trim() === "") return "";
|
|
162
26
|
|
|
163
|
-
const color =
|
|
164
|
-
|
|
27
|
+
const color =
|
|
28
|
+
colors[settings.colors[key] as keyof typeof colors] || colors.reset;
|
|
29
|
+
const emoji = settings.display.show_emojis ? settings.emojis[key] || "" : "";
|
|
165
30
|
|
|
166
31
|
// Special handling for battery emoji
|
|
167
|
-
if (key ===
|
|
168
|
-
const batteryEmoji = value.includes(
|
|
32
|
+
if (key === "battery" && settings.display.show_emojis) {
|
|
33
|
+
const batteryEmoji = value.includes("+")
|
|
34
|
+
? settings.emojis.battery_charging
|
|
35
|
+
: settings.emojis.battery;
|
|
169
36
|
return `${color}${batteryEmoji}${value}`;
|
|
170
37
|
}
|
|
171
38
|
|
|
172
39
|
// Multicolor handling for ports
|
|
173
|
-
if (key ===
|
|
174
|
-
const emoji = settings.display.show_emojis ? emojis.ports :
|
|
40
|
+
if (key === "ports" && settings.colors[key] === "multicolor" && value) {
|
|
41
|
+
const emoji = settings.display.show_emojis ? settings.emojis.ports : "";
|
|
175
42
|
let output = ` ${emoji}`;
|
|
176
|
-
const ports = value.split(
|
|
43
|
+
const ports = value.split(" ");
|
|
177
44
|
const colorCodes = [31, 32, 33, 34, 35, 36];
|
|
178
45
|
ports.forEach((port, index) => {
|
|
179
46
|
const colorCode = colorCodes[index % colorCodes.length];
|
|
@@ -183,8 +50,8 @@ function formatValue(key: string, value: string, settings: Settings): string {
|
|
|
183
50
|
}
|
|
184
51
|
|
|
185
52
|
// Multicolor handling for pacman
|
|
186
|
-
if (key ===
|
|
187
|
-
const emoji = settings.display.show_emojis ? emojis.pacman :
|
|
53
|
+
if (key === "pacman" && settings.colors[key] === "multicolor" && value) {
|
|
54
|
+
const emoji = settings.display.show_emojis ? settings.emojis.pacman : "";
|
|
188
55
|
return `${color}${emoji}${value}`;
|
|
189
56
|
}
|
|
190
57
|
|
|
@@ -192,10 +59,12 @@ function formatValue(key: string, value: string, settings: Settings): string {
|
|
|
192
59
|
}
|
|
193
60
|
|
|
194
61
|
function removeAnsiCodes(str: string): string {
|
|
195
|
-
return str.replace(/\x1b\[[0-9;]*m/g,
|
|
62
|
+
return str.replace(/\x1b\[[0-9;]*m/g, "");
|
|
196
63
|
}
|
|
197
64
|
|
|
198
|
-
async function displaySystemInfo(
|
|
65
|
+
async function displaySystemInfo(
|
|
66
|
+
customDisplayOrder: string[][] | null = null
|
|
67
|
+
): Promise<void> {
|
|
199
68
|
const settings = loadSettings();
|
|
200
69
|
const displayOrder = customDisplayOrder || settings.display_order;
|
|
201
70
|
|
|
@@ -217,14 +86,14 @@ async function displaySystemInfo(customDisplayOrder: string[][] | null = null):
|
|
|
217
86
|
}
|
|
218
87
|
|
|
219
88
|
if (allItems.length > 0) {
|
|
220
|
-
console.log(allItems.join(
|
|
89
|
+
console.log(allItems.join(" ") + colors.reset);
|
|
221
90
|
}
|
|
222
91
|
return;
|
|
223
92
|
}
|
|
224
93
|
|
|
225
94
|
// Multi-line mode with intelligent wrapping
|
|
226
95
|
const lines: string[] = [];
|
|
227
|
-
let currentLine =
|
|
96
|
+
let currentLine = "";
|
|
228
97
|
const maxLineLength = settings.display.line_wrap_length;
|
|
229
98
|
|
|
230
99
|
for (const group of displayOrder) {
|
|
@@ -236,7 +105,10 @@ async function displaySystemInfo(customDisplayOrder: string[][] | null = null):
|
|
|
236
105
|
const formattedLength = removeAnsiCodes(formatted).length;
|
|
237
106
|
const currentLineLength = removeAnsiCodes(currentLine).length;
|
|
238
107
|
|
|
239
|
-
if (
|
|
108
|
+
if (
|
|
109
|
+
currentLine &&
|
|
110
|
+
currentLineLength + formattedLength + 1 > maxLineLength
|
|
111
|
+
) {
|
|
240
112
|
lines.push(currentLine);
|
|
241
113
|
currentLine = formatted;
|
|
242
114
|
} else {
|
|
@@ -256,58 +128,61 @@ async function displaySystemInfo(customDisplayOrder: string[][] | null = null):
|
|
|
256
128
|
console.log(line + colors.reset);
|
|
257
129
|
});
|
|
258
130
|
} else if (settings.advanced.debug) {
|
|
259
|
-
console.log(
|
|
131
|
+
console.log("No system information could be displayed");
|
|
260
132
|
}
|
|
261
133
|
}
|
|
262
134
|
|
|
263
135
|
function handleSettingsCommand(args: string[]): boolean {
|
|
264
136
|
const settings = loadSettings();
|
|
265
137
|
|
|
266
|
-
if (args.includes(
|
|
138
|
+
if (args.includes("--settings-init")) {
|
|
267
139
|
if (saveSettings(DEFAULT_SETTINGS)) {
|
|
268
|
-
console.log(
|
|
140
|
+
console.log("Settings initialized with defaults");
|
|
269
141
|
} else {
|
|
270
|
-
console.log(
|
|
142
|
+
console.log("Failed to initialize settings");
|
|
271
143
|
}
|
|
272
144
|
return true;
|
|
273
145
|
}
|
|
274
146
|
|
|
275
|
-
if (args.includes(
|
|
276
|
-
console.log(
|
|
147
|
+
if (args.includes("--settings-show")) {
|
|
148
|
+
console.log("Current settings:");
|
|
277
149
|
console.log(JSON.stringify(settings, null, 2));
|
|
278
150
|
return true;
|
|
279
151
|
}
|
|
280
152
|
|
|
281
|
-
if (args.includes(
|
|
153
|
+
if (args.includes("--settings-reset")) {
|
|
282
154
|
if (saveSettings(DEFAULT_SETTINGS)) {
|
|
283
|
-
console.log(
|
|
155
|
+
console.log("Settings reset to defaults");
|
|
284
156
|
} else {
|
|
285
|
-
console.log(
|
|
157
|
+
console.log("Failed to reset settings");
|
|
286
158
|
}
|
|
287
159
|
return true;
|
|
288
160
|
}
|
|
289
161
|
|
|
290
|
-
if (args.includes(
|
|
162
|
+
if (args.includes("--refresh")) {
|
|
291
163
|
try {
|
|
292
164
|
if (fs.existsSync(CACHE_FILE)) {
|
|
293
165
|
fs.unlinkSync(CACHE_FILE);
|
|
294
|
-
console.log(
|
|
166
|
+
console.log("Cache cleared");
|
|
295
167
|
}
|
|
296
168
|
} catch (error) {
|
|
297
|
-
console.error(
|
|
169
|
+
console.error("Error clearing cache:", (error as Error).message);
|
|
298
170
|
}
|
|
299
171
|
return true;
|
|
300
172
|
}
|
|
301
173
|
|
|
302
|
-
const setIndex = args.indexOf(
|
|
174
|
+
const setIndex = args.indexOf("--set");
|
|
303
175
|
if (setIndex !== -1 && args[setIndex + 1] && args[setIndex + 2]) {
|
|
304
176
|
const key = args[setIndex + 1];
|
|
305
177
|
const value = args[setIndex + 2];
|
|
306
178
|
|
|
307
179
|
try {
|
|
308
|
-
const parsedValue =
|
|
180
|
+
const parsedValue =
|
|
181
|
+
value.startsWith("{") || value.startsWith("[")
|
|
182
|
+
? JSON.parse(value)
|
|
183
|
+
: value;
|
|
309
184
|
|
|
310
|
-
const keys = key.split(
|
|
185
|
+
const keys = key.split(".");
|
|
311
186
|
let current: any = settings;
|
|
312
187
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
313
188
|
if (!current[keys[i]]) current[keys[i]] = {};
|
|
@@ -318,10 +193,10 @@ function handleSettingsCommand(args: string[]): boolean {
|
|
|
318
193
|
if (saveSettings(settings)) {
|
|
319
194
|
console.log(`Setting ${key} = ${value}`);
|
|
320
195
|
} else {
|
|
321
|
-
console.log(
|
|
196
|
+
console.log("Failed to save settings");
|
|
322
197
|
}
|
|
323
198
|
} catch (error) {
|
|
324
|
-
console.error(
|
|
199
|
+
console.error("Error setting value:", (error as Error).message);
|
|
325
200
|
}
|
|
326
201
|
return true;
|
|
327
202
|
}
|
|
@@ -334,11 +209,11 @@ function installShellGreeting(): void {
|
|
|
334
209
|
|
|
335
210
|
let configDir: string, scriptPath: string;
|
|
336
211
|
if (IS_WINDOWS) {
|
|
337
|
-
configDir = path.join(homeDir,
|
|
338
|
-
scriptPath = path.join(configDir,
|
|
212
|
+
configDir = path.join(homeDir, "AppData", "Local");
|
|
213
|
+
scriptPath = path.join(configDir, "systeminfo");
|
|
339
214
|
} else {
|
|
340
|
-
configDir = path.join(homeDir,
|
|
341
|
-
scriptPath = path.join(configDir,
|
|
215
|
+
configDir = path.join(homeDir, ".config");
|
|
216
|
+
scriptPath = path.join(configDir, "systeminfo");
|
|
342
217
|
}
|
|
343
218
|
|
|
344
219
|
const currentScript = path.resolve(__filename);
|
|
@@ -350,81 +225,99 @@ function installShellGreeting(): void {
|
|
|
350
225
|
|
|
351
226
|
fs.copyFileSync(currentScript, scriptPath);
|
|
352
227
|
if (!IS_WINDOWS) {
|
|
353
|
-
fs.chmodSync(scriptPath,
|
|
228
|
+
fs.chmodSync(scriptPath, "755");
|
|
354
229
|
}
|
|
355
230
|
|
|
356
231
|
if (IS_WINDOWS) {
|
|
357
|
-
console.log(
|
|
358
|
-
console.log(
|
|
359
|
-
console.log(
|
|
232
|
+
console.log("Windows installation:");
|
|
233
|
+
console.log("1. Script copied to:", scriptPath);
|
|
234
|
+
console.log("2. To add to PowerShell profile, run:");
|
|
360
235
|
console.log(` Add-Content $PROFILE "node '${scriptPath}'"`);
|
|
361
|
-
console.log(
|
|
236
|
+
console.log(
|
|
237
|
+
"3. To add to Command Prompt, create a batch file in your startup folder"
|
|
238
|
+
);
|
|
362
239
|
|
|
363
|
-
const startupBat = path.join(configDir,
|
|
240
|
+
const startupBat = path.join(configDir, "systeminfo-startup.bat");
|
|
364
241
|
fs.writeFileSync(startupBat, `@echo off\nnode "${scriptPath}"\n`);
|
|
365
|
-
console.log(
|
|
242
|
+
console.log("4. Batch file created:", startupBat);
|
|
366
243
|
} else {
|
|
367
244
|
try {
|
|
368
|
-
const hushLoginPath = path.join(homeDir,
|
|
369
|
-
fs.writeFileSync(hushLoginPath,
|
|
245
|
+
const hushLoginPath = path.join(homeDir, ".hushlogin");
|
|
246
|
+
fs.writeFileSync(hushLoginPath, "");
|
|
370
247
|
} catch {}
|
|
371
248
|
|
|
372
|
-
const bashrcPath = path.join(homeDir,
|
|
249
|
+
const bashrcPath = path.join(homeDir, ".bashrc");
|
|
373
250
|
const bashLine = `node ${scriptPath}`;
|
|
374
251
|
|
|
375
252
|
if (fs.existsSync(bashrcPath)) {
|
|
376
|
-
const bashrc = fs.readFileSync(bashrcPath,
|
|
377
|
-
if (!bashrc.includes(
|
|
253
|
+
const bashrc = fs.readFileSync(bashrcPath, "utf8");
|
|
254
|
+
if (!bashrc.includes("systeminfo")) {
|
|
378
255
|
fs.appendFileSync(bashrcPath, `\n${bashLine}\n`);
|
|
379
256
|
}
|
|
380
257
|
} else {
|
|
381
258
|
fs.writeFileSync(bashrcPath, `${bashLine}\n`);
|
|
382
259
|
}
|
|
383
260
|
|
|
384
|
-
const zshrcPath = path.join(homeDir,
|
|
261
|
+
const zshrcPath = path.join(homeDir, ".zshrc");
|
|
385
262
|
if (fs.existsSync(zshrcPath)) {
|
|
386
|
-
const zshrc = fs.readFileSync(zshrcPath,
|
|
387
|
-
if (!zshrc.includes(
|
|
263
|
+
const zshrc = fs.readFileSync(zshrcPath, "utf8");
|
|
264
|
+
if (!zshrc.includes("systeminfo")) {
|
|
388
265
|
fs.appendFileSync(zshrcPath, `\n${bashLine}\n`);
|
|
389
266
|
}
|
|
390
267
|
}
|
|
391
268
|
|
|
392
|
-
const fishConfigPath = path.join(
|
|
269
|
+
const fishConfigPath = path.join(
|
|
270
|
+
homeDir,
|
|
271
|
+
".config",
|
|
272
|
+
"fish",
|
|
273
|
+
"config.fish"
|
|
274
|
+
);
|
|
393
275
|
if (fs.existsSync(fishConfigPath)) {
|
|
394
|
-
const fishConfig = fs.readFileSync(fishConfigPath,
|
|
395
|
-
if (!fishConfig.includes(
|
|
396
|
-
fs.appendFileSync(
|
|
276
|
+
const fishConfig = fs.readFileSync(fishConfigPath, "utf8");
|
|
277
|
+
if (!fishConfig.includes("systeminfo")) {
|
|
278
|
+
fs.appendFileSync(
|
|
279
|
+
fishConfigPath,
|
|
280
|
+
`\nset -U fish_greeting ""\n${bashLine}\n`
|
|
281
|
+
);
|
|
397
282
|
}
|
|
398
283
|
}
|
|
399
284
|
|
|
400
|
-
const nushellConfigPath = path.join(
|
|
285
|
+
const nushellConfigPath = path.join(
|
|
286
|
+
homeDir,
|
|
287
|
+
".config",
|
|
288
|
+
"nushell",
|
|
289
|
+
"config.nu"
|
|
290
|
+
);
|
|
401
291
|
if (fs.existsSync(nushellConfigPath)) {
|
|
402
|
-
const nushellConfig = fs.readFileSync(nushellConfigPath,
|
|
403
|
-
if (!nushellConfig.includes(
|
|
404
|
-
fs.appendFileSync(
|
|
292
|
+
const nushellConfig = fs.readFileSync(nushellConfigPath, "utf8");
|
|
293
|
+
if (!nushellConfig.includes("systeminfo")) {
|
|
294
|
+
fs.appendFileSync(
|
|
295
|
+
nushellConfigPath,
|
|
296
|
+
`\n$env.config.show_banner = false\n${bashLine}\n`
|
|
297
|
+
);
|
|
405
298
|
}
|
|
406
299
|
}
|
|
407
300
|
}
|
|
408
301
|
|
|
409
|
-
console.log(
|
|
302
|
+
console.log("Shell greeting installation completed!");
|
|
410
303
|
} catch (error) {
|
|
411
|
-
console.error(
|
|
304
|
+
console.error("Error installing shell greeting:", (error as Error).message);
|
|
412
305
|
process.exit(1);
|
|
413
306
|
}
|
|
414
307
|
}
|
|
415
308
|
|
|
416
309
|
function parseCLIMode(args: string[]): string[] | null {
|
|
417
310
|
for (const arg of args) {
|
|
418
|
-
if (!arg.startsWith(
|
|
311
|
+
if (!arg.startsWith("--") && arg.includes(",")) {
|
|
419
312
|
return arg
|
|
420
|
-
.split(
|
|
313
|
+
.split(",")
|
|
421
314
|
.map((part) => part.trim())
|
|
422
315
|
.filter((part) => part.length > 0);
|
|
423
316
|
}
|
|
424
317
|
}
|
|
425
318
|
|
|
426
319
|
for (const arg of args) {
|
|
427
|
-
if (!arg.startsWith(
|
|
320
|
+
if (!arg.startsWith("--") && !arg.includes("=") && arg.length > 0) {
|
|
428
321
|
return [arg.trim()];
|
|
429
322
|
}
|
|
430
323
|
}
|
|
@@ -458,12 +351,22 @@ Examples:
|
|
|
458
351
|
about-system --install
|
|
459
352
|
about-system --set display.show_emojis false
|
|
460
353
|
about-system --set colors.user blue
|
|
354
|
+
about-system --set emojis.cpu "🚀 "
|
|
355
|
+
about-system --set labels.cpu "Processor"
|
|
461
356
|
about-system --json
|
|
462
357
|
|
|
463
358
|
Settings file: ${SETTINGS_FILE}
|
|
464
359
|
Cache file: ${CACHE_FILE}
|
|
465
360
|
|
|
466
|
-
Platform: ${
|
|
361
|
+
Platform: ${
|
|
362
|
+
IS_WINDOWS
|
|
363
|
+
? "Windows"
|
|
364
|
+
: os.platform() === "darwin"
|
|
365
|
+
? "macOS"
|
|
366
|
+
: os.platform() === "linux"
|
|
367
|
+
? "Linux"
|
|
368
|
+
: "Unknown"
|
|
369
|
+
}
|
|
467
370
|
|
|
468
371
|
Available display blocks:
|
|
469
372
|
Basic: user, hostname, uptime, shell, os, kernel, device
|
|
@@ -482,17 +385,17 @@ async function main(): Promise<void> {
|
|
|
482
385
|
return;
|
|
483
386
|
}
|
|
484
387
|
|
|
485
|
-
if (args.includes(
|
|
388
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
486
389
|
await showHelp();
|
|
487
390
|
return;
|
|
488
391
|
}
|
|
489
392
|
|
|
490
|
-
if (args.includes(
|
|
393
|
+
if (args.includes("--install")) {
|
|
491
394
|
installShellGreeting();
|
|
492
395
|
return;
|
|
493
396
|
}
|
|
494
397
|
|
|
495
|
-
if (args.includes(
|
|
398
|
+
if (args.includes("--json")) {
|
|
496
399
|
const info = await getSystemInfo();
|
|
497
400
|
console.log(JSON.stringify(info, null, 2));
|
|
498
401
|
return;
|
|
@@ -509,7 +412,7 @@ async function main(): Promise<void> {
|
|
|
509
412
|
}
|
|
510
413
|
|
|
511
414
|
main().catch((error) => {
|
|
512
|
-
console.error(
|
|
415
|
+
console.error("Error:", error.message);
|
|
513
416
|
process.exit(1);
|
|
514
417
|
});
|
|
515
418
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache configuration and constants
|
|
3
|
+
* @module cache-config
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import os from "os";
|
|
7
|
+
import path from "path";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Cache file location in system's temporary directory
|
|
11
|
+
* @constant
|
|
12
|
+
*/
|
|
13
|
+
export const CACHE_FILE = path.join(os.tmpdir(), "systeminfo-cache.json");
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cache duration configuration for different system information types
|
|
17
|
+
* Values are in milliseconds
|
|
18
|
+
*
|
|
19
|
+
* @constant
|
|
20
|
+
* @property {number} ip - IP information cache (5 minutes)
|
|
21
|
+
* @property {number} cpu - CPU information cache (24 hours)
|
|
22
|
+
* @property {number} gpu - GPU information cache (24 hours)
|
|
23
|
+
* @property {number} os - OS information cache (24 hours)
|
|
24
|
+
* @property {number} device - Device information cache (24 hours)
|
|
25
|
+
* @property {number} kernel - Kernel information cache (1 hour)
|
|
26
|
+
* @property {number} pacman - Package managers cache (10 minutes)
|
|
27
|
+
* @property {number} ports - Open ports cache (5 minutes)
|
|
28
|
+
* @property {number} containers - Docker containers cache (5 minutes)
|
|
29
|
+
* @property {number} top_process - Top process cache (5 seconds)
|
|
30
|
+
* @property {number} disk_used - Disk usage cache (1 minute)
|
|
31
|
+
* @property {number} ram_used - RAM usage cache (10 seconds)
|
|
32
|
+
* @property {number} services_running - Services cache (5 minutes)
|
|
33
|
+
* @property {number} temperature - Temperature cache (30 seconds)
|
|
34
|
+
* @property {number} battery - Battery status cache (1 minute)
|
|
35
|
+
* @property {number} network_interfaces - Network interfaces cache (5 minutes)
|
|
36
|
+
* @property {number} mount_points - Mount points cache (10 minutes)
|
|
37
|
+
*/
|
|
38
|
+
export const CACHE_DURATION = {
|
|
39
|
+
ip: 5 * 60 * 1000,
|
|
40
|
+
cpu: 24 * 60 * 60 * 1000,
|
|
41
|
+
gpu: 24 * 60 * 60 * 1000,
|
|
42
|
+
os: 24 * 60 * 60 * 1000,
|
|
43
|
+
device: 24 * 60 * 60 * 1000,
|
|
44
|
+
kernel: 60 * 60 * 1000,
|
|
45
|
+
pacman: 10 * 60 * 1000,
|
|
46
|
+
ports: 5 * 60 * 1000,
|
|
47
|
+
containers: 5 * 60 * 1000,
|
|
48
|
+
top_process: 5 * 1000,
|
|
49
|
+
disk_used: 60 * 1000,
|
|
50
|
+
ram_used: 10 * 1000,
|
|
51
|
+
services_running: 5 * 60 * 1000,
|
|
52
|
+
temperature: 30 * 1000,
|
|
53
|
+
battery: 60 * 1000,
|
|
54
|
+
network_interfaces: 5 * 60 * 1000,
|
|
55
|
+
mount_points: 10 * 60 * 1000,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Default IPInfo.io API token for geolocation
|
|
60
|
+
* @constant
|
|
61
|
+
*/
|
|
62
|
+
export const DEFAULT_IPINFO_TOKEN = "da2d6cc4baa5d1";
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Default network request timeout in milliseconds
|
|
66
|
+
* @constant
|
|
67
|
+
*/
|
|
68
|
+
export const DEFAULT_NETWORK_TIMEOUT = 5000;
|