about-system 0.0.51 → 0.0.66
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 +63 -0
- package/dist/about-system-cli.js +117 -99
- package/dist/about-system-cli.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/system-info-api-C_y-O4VW.js +2409 -0
- package/dist/system-info-api-C_y-O4VW.js.map +1 -0
- package/dist/system-info-api.js +1 -1
- package/package.json +17 -6
- package/src/about-system-cli.ts +31 -6
- package/src/cache/cache.test.ts +235 -0
- package/src/info/platform.test.ts +190 -0
- package/src/info/settings.ts +38 -10
- package/src/utils/utils.test.ts +218 -0
- package/dist/system-info-api-CChFyamn.js +0 -2396
- package/dist/system-info-api-CChFyamn.js.map +0 -1
package/README.md
CHANGED
|
@@ -28,6 +28,52 @@ about-system
|
|
|
28
28
|
bun x about-system
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
### Desktop app
|
|
32
|
+
|
|
33
|
+
The same 30+ metrics as a window you can leave open, built natively for every desktop OS. The CLI
|
|
34
|
+
is compiled into the app as a [Tauri sidecar](https://v2.tauri.app/develop/sidecar/), so an
|
|
35
|
+
installer runs on a machine with no Node, no Bun, and no package manager on it.
|
|
36
|
+
|
|
37
|
+
#### Download an installer
|
|
38
|
+
|
|
39
|
+
Every tagged release attaches a native build for each desktop system
|
|
40
|
+
([Releases](https://github.com/OpenSourceAGI/dev-tools-starter-agent/releases?q=about-system-desktop)):
|
|
41
|
+
|
|
42
|
+
| System | Architecture | Installer |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| Windows 10 1803+ / 11 | x86_64 | `About System_<version>_x64_en-US.msi`, `About System_<version>_x64-setup.exe` |
|
|
45
|
+
| macOS 10.15+ | Apple Silicon + Intel (universal) | `About System_<version>_universal.dmg` |
|
|
46
|
+
| Linux (Debian/Ubuntu) | x86_64, aarch64 | `About System_<version>_amd64.deb`, `About System_<version>_arm64.deb` |
|
|
47
|
+
| Linux (Fedora/RHEL) | x86_64, aarch64 | `About System-<version>-1.x86_64.rpm`, `About System-<version>-1.aarch64.rpm` |
|
|
48
|
+
| Linux (any distro) | x86_64, aarch64 | `About System_<version>_amd64.AppImage`, `About System_<version>_aarch64.AppImage` |
|
|
49
|
+
|
|
50
|
+
Installers are unsigned by default, so macOS shows an "unidentified developer" warning and Windows
|
|
51
|
+
shows a SmartScreen prompt on first launch.
|
|
52
|
+
|
|
53
|
+
#### Build it yourself
|
|
54
|
+
|
|
55
|
+
Needs [Rust](https://rustup.rs) 1.77.2+, Node 18+, [Bun](https://bun.sh), and your platform's
|
|
56
|
+
[Tauri prerequisites](https://v2.tauri.app/start/prerequisites/):
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
bun install # the CLI's dependencies — the sidecar is compiled from its source
|
|
60
|
+
cd native
|
|
61
|
+
npm install
|
|
62
|
+
npm run build:desktop # regenerates config, compiles the sidecar, builds the installers
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Artifacts land in `native/src-tauri/target/release/bundle/`. **Each installer must be built on its
|
|
66
|
+
own OS and architecture** — neither Tauri nor the `bun build --compile` sidecar cross-compiles,
|
|
67
|
+
which is why `.github/workflows/about-system-desktop.yml` runs the same two commands on a Windows,
|
|
68
|
+
a macOS, an x86_64 Linux, and an aarch64 Linux runner and attaches every artifact to one release.
|
|
69
|
+
|
|
70
|
+
The app is scaffolded from [`packages/native-app-wrapper`](../native-app-wrapper/) — a Tauri shell
|
|
71
|
+
that turns one JSON profile into a native app — and owns its whole identity (name, bundle id,
|
|
72
|
+
version, window, sidecar command) in `native/profiles/about-system.json`. See
|
|
73
|
+
[`native/README.md`](native/README.md) for the development loop, the universal-macOS build, and the
|
|
74
|
+
known limitations (no Windows-on-ARM build, since Bun has no `windows-arm64` compile target; and no
|
|
75
|
+
mobile build, since Android and iOS don't let an app spawn a bundled executable).
|
|
76
|
+
|
|
31
77
|
## Examples
|
|
32
78
|
|
|
33
79
|

|
|
@@ -210,6 +256,7 @@ about-system --cache-clear
|
|
|
210
256
|
},
|
|
211
257
|
"display": {
|
|
212
258
|
"show_emojis": true,
|
|
259
|
+
"show_backgrounds": true,
|
|
213
260
|
"single_line": true,
|
|
214
261
|
"line_wrap_length": 100
|
|
215
262
|
},
|
|
@@ -231,11 +278,21 @@ Available color options for each info block:
|
|
|
231
278
|
- `red`, `orange`, `yellow`, `green`, `blue`, `cyan`, `purple`, `magenta`, `gray`, `lightblue`
|
|
232
279
|
- Use `multicolor` for ports to get a rainbow effect
|
|
233
280
|
|
|
281
|
+
All colors use darker, more saturated shades so they stay readable on both light and dark terminal backgrounds.
|
|
282
|
+
|
|
234
283
|
```bash
|
|
235
284
|
about-system --set colors.user blue
|
|
236
285
|
about-system --set colors.hostname green
|
|
237
286
|
```
|
|
238
287
|
|
|
288
|
+
#### Backgrounds
|
|
289
|
+
|
|
290
|
+
By default, every info block is rendered as a colored background badge with a contrasting text color, so it stays legible no matter what background color your terminal uses. Disable it to fall back to plain colored text:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
about-system --set display.show_backgrounds false
|
|
294
|
+
```
|
|
295
|
+
|
|
239
296
|
#### Emojis
|
|
240
297
|
|
|
241
298
|
Customize the emoji displayed for each info block. Emojis can be toggled on/off globally with `display.show_emojis` or individually customized:
|
|
@@ -357,3 +414,9 @@ import type {
|
|
|
357
414
|
|
|
358
415
|
- [Repository](https://github.com/OpenSourceAGI/StarterDOCS/tree/master/packages/about-system-info)
|
|
359
416
|
- [Issues](https://github.com/OpenSourceAGI/StarterDOCS/issues)
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
[](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)
|
|
421
|
+
|
|
422
|
+
Please star this repo for updates! 🌟
|
package/dist/about-system-cli.js
CHANGED
|
@@ -1,84 +1,101 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import y from "os";
|
|
3
3
|
import r from "fs";
|
|
4
|
-
import
|
|
5
|
-
import { fileURLToPath as
|
|
6
|
-
import { g as
|
|
7
|
-
const
|
|
4
|
+
import d from "path";
|
|
5
|
+
import { fileURLToPath as P } from "url";
|
|
6
|
+
import { g as F, a as I, b as S, C as b, S as k, c as p, d as v, D as $ } from "./system-info-api-C_y-O4VW.js";
|
|
7
|
+
const x = P(import.meta.url), g = y.platform() === "win32", T = {
|
|
8
|
+
31: [41, 97],
|
|
9
|
+
// red
|
|
10
|
+
32: [42, 30],
|
|
11
|
+
// green
|
|
12
|
+
33: [43, 30],
|
|
13
|
+
// yellow
|
|
14
|
+
34: [44, 97],
|
|
15
|
+
// blue
|
|
16
|
+
35: [45, 97],
|
|
17
|
+
// magenta
|
|
18
|
+
36: [46, 30]
|
|
19
|
+
// cyan
|
|
20
|
+
};
|
|
8
21
|
function j(e, s, o) {
|
|
9
22
|
if (!s || s.trim() === "") return "";
|
|
10
|
-
const l =
|
|
23
|
+
const l = o.display.show_backgrounds !== !1, n = o.colors[e], f = v[n], t = l && f || p[n] || p.reset, i = l ? p.reset : "", c = o.display.show_emojis && o.emojis[e] || "";
|
|
11
24
|
if (e === "battery" && o.display.show_emojis) {
|
|
12
|
-
const
|
|
13
|
-
return `${
|
|
25
|
+
const a = s.includes("+") ? o.emojis.battery_charging : o.emojis.battery;
|
|
26
|
+
return `${t}${a}${s}${i}`;
|
|
14
27
|
}
|
|
15
28
|
if (e === "ports" && o.colors[e] === "multicolor" && s) {
|
|
16
|
-
let
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
let u = ` ${o.display.show_emojis ? o.emojis.ports : ""}`;
|
|
30
|
+
const m = s.split(" "), h = [31, 32, 33, 34, 35, 36];
|
|
31
|
+
return m.forEach((w, O) => {
|
|
32
|
+
const _ = h[O % h.length];
|
|
33
|
+
if (l) {
|
|
34
|
+
const [E, L] = T[_];
|
|
35
|
+
u += `\x1B[${E}m\x1B[${L}m${w}\x1B[0m `;
|
|
36
|
+
} else
|
|
37
|
+
u += `\x1B[${_}m${w}\x1B[0m `;
|
|
38
|
+
}), u.trim();
|
|
22
39
|
}
|
|
23
40
|
if (e === "pacman" && o.colors[e] === "multicolor" && s) {
|
|
24
|
-
const
|
|
25
|
-
return `${
|
|
41
|
+
const a = o.display.show_emojis ? o.emojis.pacman : "";
|
|
42
|
+
return `${t}${a}${s}${i}`;
|
|
26
43
|
}
|
|
27
|
-
return `${
|
|
44
|
+
return `${t}${c}${s}${i}`;
|
|
28
45
|
}
|
|
29
|
-
function
|
|
46
|
+
function B(e, s) {
|
|
30
47
|
if (s <= 0) return e ? [e] : [];
|
|
31
48
|
const o = [];
|
|
32
|
-
let l = "",
|
|
49
|
+
let l = "", n = 0, f = "";
|
|
33
50
|
for (let t = 0; t < e.length; t++) {
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
let
|
|
37
|
-
for (;
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
const i = e[t];
|
|
52
|
+
if (i === "\x1B" && e[t + 1] === "[") {
|
|
53
|
+
let m = i, h = t + 1;
|
|
54
|
+
for (; h < e.length && e[h] !== "m"; )
|
|
55
|
+
m += e[h], h++;
|
|
56
|
+
h < e.length && (m += e[h]), l += m, f = /\x1b\[0m/.test(m) ? "" : m, t = h;
|
|
40
57
|
continue;
|
|
41
58
|
}
|
|
42
|
-
let
|
|
43
|
-
const
|
|
44
|
-
|
|
59
|
+
let c = i, a = 1;
|
|
60
|
+
const u = e.charCodeAt(t);
|
|
61
|
+
u >= 55296 && u <= 56319 && t + 1 < e.length && (c = i + e[t + 1], a = 2, t++), n >= s && (o.push(l), l = f, n = 0), l += c, n += a;
|
|
45
62
|
}
|
|
46
63
|
return l && o.push(l), o;
|
|
47
64
|
}
|
|
48
|
-
async function
|
|
49
|
-
const s =
|
|
65
|
+
async function C(e = null) {
|
|
66
|
+
const s = I(), o = e || s.display_order, l = await F();
|
|
50
67
|
if (s.display.single_line) {
|
|
51
|
-
const
|
|
52
|
-
for (const
|
|
53
|
-
for (const
|
|
54
|
-
const
|
|
55
|
-
|
|
68
|
+
const i = [];
|
|
69
|
+
for (const c of o)
|
|
70
|
+
for (const a of c) {
|
|
71
|
+
const u = l[a], m = j(a, u, s);
|
|
72
|
+
m && m.trim() && i.push(m);
|
|
56
73
|
}
|
|
57
|
-
|
|
74
|
+
i.length > 0 && console.log(i.join(" ") + p.reset);
|
|
58
75
|
return;
|
|
59
76
|
}
|
|
60
|
-
const
|
|
61
|
-
for (const
|
|
62
|
-
for (const
|
|
63
|
-
const
|
|
64
|
-
|
|
77
|
+
const n = s.display.line_wrap_length, f = [];
|
|
78
|
+
for (const i of o)
|
|
79
|
+
for (const c of i) {
|
|
80
|
+
const a = l[c], u = j(c, a, s);
|
|
81
|
+
u && u.trim() && f.push(u);
|
|
65
82
|
}
|
|
66
|
-
const t =
|
|
67
|
-
t.length > 0 ? t.forEach((
|
|
68
|
-
console.log(
|
|
83
|
+
const t = B(f.join(" "), n);
|
|
84
|
+
t.length > 0 ? t.forEach((i) => {
|
|
85
|
+
console.log(i + p.reset);
|
|
69
86
|
}) : s.advanced.debug && console.log("No system information could be displayed");
|
|
70
87
|
}
|
|
71
|
-
function
|
|
72
|
-
const s =
|
|
88
|
+
function N(e) {
|
|
89
|
+
const s = I();
|
|
73
90
|
if (e.includes("--settings-init"))
|
|
74
|
-
return S(
|
|
91
|
+
return S($) ? console.log("Settings initialized with defaults") : console.log("Failed to initialize settings"), !0;
|
|
75
92
|
if (e.includes("--settings-show"))
|
|
76
93
|
return console.log("Current settings:"), console.log(JSON.stringify(s, null, 2)), !0;
|
|
77
94
|
if (e.includes("--settings-reset"))
|
|
78
|
-
return S(
|
|
95
|
+
return S($) ? console.log("Settings reset to defaults") : console.log("Failed to reset settings"), !0;
|
|
79
96
|
if (e.includes("--refresh")) {
|
|
80
97
|
try {
|
|
81
|
-
r.existsSync(
|
|
98
|
+
r.existsSync(b) && (r.unlinkSync(b), console.log("Cache cleared"));
|
|
82
99
|
} catch (l) {
|
|
83
100
|
console.error("Error clearing cache:", l.message);
|
|
84
101
|
}
|
|
@@ -86,82 +103,82 @@ function O(e) {
|
|
|
86
103
|
}
|
|
87
104
|
const o = e.indexOf("--set");
|
|
88
105
|
if (o !== -1 && e[o + 1] && e[o + 2]) {
|
|
89
|
-
const l = e[o + 1],
|
|
106
|
+
const l = e[o + 1], n = e[o + 2];
|
|
90
107
|
try {
|
|
91
|
-
const
|
|
92
|
-
let
|
|
93
|
-
for (let
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
} catch (
|
|
97
|
-
console.error("Error setting value:",
|
|
108
|
+
const f = n.startsWith("{") || n.startsWith("[") ? JSON.parse(n) : n === "true" ? !0 : n === "false" ? !1 : n, t = l.split(".");
|
|
109
|
+
let i = s;
|
|
110
|
+
for (let c = 0; c < t.length - 1; c++)
|
|
111
|
+
i[t[c]] || (i[t[c]] = {}), i = i[t[c]];
|
|
112
|
+
i[t[t.length - 1]] = f, S(s) ? console.log(`Setting ${l} = ${n}`) : console.log("Failed to save settings");
|
|
113
|
+
} catch (f) {
|
|
114
|
+
console.error("Error setting value:", f.message);
|
|
98
115
|
}
|
|
99
116
|
return !0;
|
|
100
117
|
}
|
|
101
118
|
return !1;
|
|
102
119
|
}
|
|
103
|
-
function
|
|
104
|
-
const e =
|
|
120
|
+
function D() {
|
|
121
|
+
const e = y.homedir();
|
|
105
122
|
let s, o;
|
|
106
|
-
|
|
107
|
-
const l =
|
|
123
|
+
g ? (s = d.join(e, "AppData", "Local"), o = d.join(s, "systeminfo")) : (s = d.join(e, ".config"), o = d.join(s, "systeminfo"));
|
|
124
|
+
const l = d.resolve(x);
|
|
108
125
|
try {
|
|
109
|
-
if (r.existsSync(s) || r.mkdirSync(s, { recursive: !0 }), r.copyFileSync(l, o),
|
|
126
|
+
if (r.existsSync(s) || r.mkdirSync(s, { recursive: !0 }), r.copyFileSync(l, o), g || r.chmodSync(o, "755"), g) {
|
|
110
127
|
console.log("Windows installation:"), console.log("1. Script copied to:", o), console.log("2. To add to PowerShell profile, run:"), console.log(` Add-Content $PROFILE "node '${o}'"`), console.log(
|
|
111
128
|
"3. To add to Command Prompt, create a batch file in your startup folder"
|
|
112
129
|
);
|
|
113
|
-
const
|
|
114
|
-
r.writeFileSync(
|
|
130
|
+
const n = d.join(s, "systeminfo-startup.bat");
|
|
131
|
+
r.writeFileSync(n, `@echo off
|
|
115
132
|
node "${o}"
|
|
116
|
-
`), console.log("4. Batch file created:",
|
|
133
|
+
`), console.log("4. Batch file created:", n);
|
|
117
134
|
} else {
|
|
118
135
|
try {
|
|
119
|
-
const
|
|
120
|
-
r.writeFileSync(
|
|
136
|
+
const a = d.join(e, ".hushlogin");
|
|
137
|
+
r.writeFileSync(a, "");
|
|
121
138
|
} catch {
|
|
122
139
|
}
|
|
123
|
-
const
|
|
124
|
-
r.existsSync(
|
|
125
|
-
${
|
|
126
|
-
`) : r.writeFileSync(
|
|
140
|
+
const n = d.join(e, ".bashrc"), f = `node ${o}`;
|
|
141
|
+
r.existsSync(n) ? r.readFileSync(n, "utf8").includes("systeminfo") || r.appendFileSync(n, `
|
|
142
|
+
${f}
|
|
143
|
+
`) : r.writeFileSync(n, `${f}
|
|
127
144
|
`);
|
|
128
|
-
const t =
|
|
145
|
+
const t = d.join(e, ".zshrc");
|
|
129
146
|
r.existsSync(t) && (r.readFileSync(t, "utf8").includes("systeminfo") || r.appendFileSync(t, `
|
|
130
|
-
${
|
|
147
|
+
${f}
|
|
131
148
|
`));
|
|
132
|
-
const
|
|
149
|
+
const i = d.join(
|
|
133
150
|
e,
|
|
134
151
|
".config",
|
|
135
152
|
"fish",
|
|
136
153
|
"config.fish"
|
|
137
154
|
);
|
|
138
|
-
r.existsSync(
|
|
139
|
-
|
|
155
|
+
r.existsSync(i) && (r.readFileSync(i, "utf8").includes("systeminfo") || r.appendFileSync(
|
|
156
|
+
i,
|
|
140
157
|
`
|
|
141
158
|
set -U fish_greeting ""
|
|
142
|
-
${
|
|
159
|
+
${f}
|
|
143
160
|
`
|
|
144
161
|
));
|
|
145
|
-
const
|
|
162
|
+
const c = d.join(
|
|
146
163
|
e,
|
|
147
164
|
".config",
|
|
148
165
|
"nushell",
|
|
149
166
|
"config.nu"
|
|
150
167
|
);
|
|
151
|
-
r.existsSync(
|
|
152
|
-
|
|
168
|
+
r.existsSync(c) && (r.readFileSync(c, "utf8").includes("systeminfo") || r.appendFileSync(
|
|
169
|
+
c,
|
|
153
170
|
`
|
|
154
171
|
$env.config.show_banner = false
|
|
155
|
-
${
|
|
172
|
+
${f}
|
|
156
173
|
`
|
|
157
174
|
));
|
|
158
175
|
}
|
|
159
176
|
console.log("Shell greeting installation completed!");
|
|
160
|
-
} catch (
|
|
161
|
-
console.error("Error installing shell greeting:",
|
|
177
|
+
} catch (n) {
|
|
178
|
+
console.error("Error installing shell greeting:", n.message), process.exit(1);
|
|
162
179
|
}
|
|
163
180
|
}
|
|
164
|
-
function
|
|
181
|
+
function A(e) {
|
|
165
182
|
for (const s of e)
|
|
166
183
|
if (!s.startsWith("--") && s.includes(","))
|
|
167
184
|
return s.split(",").map((o) => o.trim()).filter((o) => o.length > 0);
|
|
@@ -170,7 +187,7 @@ function L(e) {
|
|
|
170
187
|
return [s.trim()];
|
|
171
188
|
return null;
|
|
172
189
|
}
|
|
173
|
-
async function
|
|
190
|
+
async function W() {
|
|
174
191
|
console.log(`
|
|
175
192
|
System Info Script - TypeScript Version
|
|
176
193
|
|
|
@@ -195,15 +212,16 @@ Examples:
|
|
|
195
212
|
about-system disk_used # Show only disk usage
|
|
196
213
|
about-system --install
|
|
197
214
|
about-system --set display.show_emojis false
|
|
215
|
+
about-system --set display.show_backgrounds false
|
|
198
216
|
about-system --set colors.user blue
|
|
199
217
|
about-system --set emojis.cpu "🚀 "
|
|
200
218
|
about-system --set labels.cpu "Processor"
|
|
201
219
|
about-system --json
|
|
202
220
|
|
|
203
|
-
Settings file: ${
|
|
204
|
-
Cache file: ${
|
|
221
|
+
Settings file: ${k}
|
|
222
|
+
Cache file: ${b}
|
|
205
223
|
|
|
206
|
-
Platform: ${
|
|
224
|
+
Platform: ${g ? "Windows" : y.platform() === "darwin" ? "macOS" : y.platform() === "linux" ? "Linux" : "Unknown"}
|
|
207
225
|
|
|
208
226
|
Available display blocks:
|
|
209
227
|
Basic: user, hostname, uptime, shell, os, kernel, device
|
|
@@ -214,35 +232,35 @@ Available display blocks:
|
|
|
214
232
|
Tools: pacman, ports, containers
|
|
215
233
|
`);
|
|
216
234
|
}
|
|
217
|
-
async function
|
|
235
|
+
async function z() {
|
|
218
236
|
const e = process.argv.slice(2);
|
|
219
|
-
if (
|
|
237
|
+
if (N(e))
|
|
220
238
|
return;
|
|
221
239
|
if (e.includes("--help") || e.includes("-h")) {
|
|
222
|
-
await
|
|
240
|
+
await W();
|
|
223
241
|
return;
|
|
224
242
|
}
|
|
225
243
|
if (e.includes("--install")) {
|
|
226
|
-
|
|
244
|
+
D();
|
|
227
245
|
return;
|
|
228
246
|
}
|
|
229
247
|
if (e.includes("--json")) {
|
|
230
|
-
const o = await
|
|
248
|
+
const o = await F();
|
|
231
249
|
console.log(JSON.stringify(o, null, 2));
|
|
232
250
|
return;
|
|
233
251
|
}
|
|
234
|
-
const s =
|
|
252
|
+
const s = A(e);
|
|
235
253
|
if (s) {
|
|
236
|
-
await
|
|
254
|
+
await C([s]);
|
|
237
255
|
return;
|
|
238
256
|
}
|
|
239
|
-
await
|
|
257
|
+
await C();
|
|
240
258
|
}
|
|
241
|
-
|
|
259
|
+
z().catch((e) => {
|
|
242
260
|
console.error("Error:", e.message), process.exit(1);
|
|
243
261
|
});
|
|
244
262
|
export {
|
|
245
|
-
|
|
246
|
-
|
|
263
|
+
C as displaySystemInfo,
|
|
264
|
+
D as installShellGreeting
|
|
247
265
|
};
|
|
248
266
|
//# sourceMappingURL=about-system-cli.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"about-system-cli.js","sources":["../src/about-system-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport os from \"os\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { getSystemInfo } from \"./system-info-api\";\nimport type { SystemInfo, SystemInfoOptions } from \"./systeminfo-types\";\n\nconst __filename = fileURLToPath(import.meta.url);\n\nimport {\n Settings,\n DEFAULT_SETTINGS,\n colors,\n SETTINGS_FILE,\n CACHE_FILE,\n loadSettings,\n saveSettings,\n} from \"./info/settings\";\n\n// Platform detection\nconst IS_WINDOWS = os.platform() === \"win32\";\n\nfunction formatValue(key: string, value: string, settings: Settings): string {\n if (!value || value.trim() === \"\") return \"\";\n\n const color =\n colors[settings.colors[key] as keyof typeof colors] || colors.reset;\n const emoji = settings.display.show_emojis ? settings.emojis[key] || \"\" : \"\";\n\n // Special handling for battery emoji\n if (key === \"battery\" && settings.display.show_emojis) {\n const batteryEmoji = value.includes(\"+\")\n ? settings.emojis.battery_charging\n : settings.emojis.battery;\n return `${color}${batteryEmoji}${value}`;\n }\n\n // Multicolor handling for ports\n if (key === \"ports\" && settings.colors[key] === \"multicolor\" && value) {\n const emoji = settings.display.show_emojis ? settings.emojis.ports : \"\";\n let output = ` ${emoji}`;\n const ports = value.split(\" \");\n const colorCodes = [31, 32, 33, 34, 35, 36];\n ports.forEach((port, index) => {\n const colorCode = colorCodes[index % colorCodes.length];\n output += `\\x1b[${colorCode}m${port}\\x1b[0m `;\n });\n return output.trim();\n }\n\n // Multicolor handling for pacman\n if (key === \"pacman\" && settings.colors[key] === \"multicolor\" && value) {\n const emoji = settings.display.show_emojis ? settings.emojis.pacman : \"\";\n return `${color}${emoji}${value}`;\n }\n\n return `${color}${emoji}${value}`;\n}\n\n/**\n * Wraps text to a maximum visible width, filling each line completely with\n * characters before moving on. Unlike block-boundary wrapping, this breaks in\n * the middle of an info block when it doesn't fit, so no visible space is left\n * unused at the end of a line.\n *\n * ANSI color codes are copied verbatim and never counted toward the width, and\n * the active color is re-applied at the start of each wrapped line so colors\n * survive a mid-block break. Emoji surrogate pairs are kept intact.\n *\n * @param text - The text to wrap (may contain ANSI escape sequences)\n * @param maxLength - Maximum visible characters per line\n * @returns Array of wrapped lines\n */\nfunction wrapAnsiText(text: string, maxLength: number): string[] {\n if (maxLength <= 0) return text ? [text] : [];\n\n const lines: string[] = [];\n let currentLine = \"\";\n let visibleCount = 0;\n let activeAnsi = \"\";\n\n for (let i = 0; i < text.length; i++) {\n const char = text[i];\n\n // Copy ANSI escape sequences verbatim without counting them.\n if (char === \"\\x1b\" && text[i + 1] === \"[\") {\n let seq = char;\n let j = i + 1;\n while (j < text.length && text[j] !== \"m\") {\n seq += text[j];\n j++;\n }\n if (j < text.length) seq += text[j]; // include the trailing \"m\"\n currentLine += seq;\n // Track the active color so wrapped lines keep it; a reset clears it.\n activeAnsi = /\\x1b\\[0m/.test(seq) ? \"\" : seq;\n i = j;\n continue;\n }\n\n // Keep an emoji (surrogate pair) together and count it as width 2.\n let unit = char;\n let width = 1;\n const code = text.charCodeAt(i);\n if (code >= 0xd800 && code <= 0xdbff && i + 1 < text.length) {\n unit = char + text[i + 1];\n width = 2;\n i++;\n }\n\n // Line is full: break here, even in the middle of an info block.\n if (visibleCount >= maxLength) {\n lines.push(currentLine);\n currentLine = activeAnsi;\n visibleCount = 0;\n }\n\n currentLine += unit;\n visibleCount += width;\n }\n\n if (currentLine) lines.push(currentLine);\n\n return lines;\n}\n\nasync function displaySystemInfo(\n customDisplayOrder: string[][] | null = null\n): Promise<void> {\n const settings = loadSettings();\n const displayOrder = customDisplayOrder || settings.display_order;\n\n // Get system info\n const info = await getSystemInfo();\n\n // Single line mode\n if (settings.display.single_line) {\n const allItems: string[] = [];\n\n for (const group of displayOrder) {\n for (const key of group) {\n const value = info[key as keyof SystemInfo] as string;\n const formatted = formatValue(key, value, settings);\n if (formatted && formatted.trim()) {\n allItems.push(formatted);\n }\n }\n }\n\n if (allItems.length > 0) {\n console.log(allItems.join(\" \") + colors.reset);\n }\n return;\n }\n\n // Multi-line mode: fill each line completely with characters, wrapping in\n // the middle of an info block when it no longer fits.\n const maxLineLength = settings.display.line_wrap_length;\n const allItems: string[] = [];\n\n for (const group of displayOrder) {\n for (const key of group) {\n const value = info[key as keyof SystemInfo] as string;\n const formatted = formatValue(key, value, settings);\n\n if (formatted && formatted.trim()) {\n allItems.push(formatted);\n }\n }\n }\n\n const lines = wrapAnsiText(allItems.join(\" \"), maxLineLength);\n\n // Output\n if (lines.length > 0) {\n lines.forEach((line) => {\n console.log(line + colors.reset);\n });\n } else if (settings.advanced.debug) {\n console.log(\"No system information could be displayed\");\n }\n}\n\nfunction handleSettingsCommand(args: string[]): boolean {\n const settings = loadSettings();\n\n if (args.includes(\"--settings-init\")) {\n if (saveSettings(DEFAULT_SETTINGS)) {\n console.log(\"Settings initialized with defaults\");\n } else {\n console.log(\"Failed to initialize settings\");\n }\n return true;\n }\n\n if (args.includes(\"--settings-show\")) {\n console.log(\"Current settings:\");\n console.log(JSON.stringify(settings, null, 2));\n return true;\n }\n\n if (args.includes(\"--settings-reset\")) {\n if (saveSettings(DEFAULT_SETTINGS)) {\n console.log(\"Settings reset to defaults\");\n } else {\n console.log(\"Failed to reset settings\");\n }\n return true;\n }\n\n if (args.includes(\"--refresh\")) {\n try {\n if (fs.existsSync(CACHE_FILE)) {\n fs.unlinkSync(CACHE_FILE);\n console.log(\"Cache cleared\");\n }\n } catch (error) {\n console.error(\"Error clearing cache:\", (error as Error).message);\n }\n return true;\n }\n\n const setIndex = args.indexOf(\"--set\");\n if (setIndex !== -1 && args[setIndex + 1] && args[setIndex + 2]) {\n const key = args[setIndex + 1];\n const value = args[setIndex + 2];\n\n try {\n const parsedValue =\n value.startsWith(\"{\") || value.startsWith(\"[\")\n ? JSON.parse(value)\n : value;\n\n const keys = key.split(\".\");\n let current: any = settings;\n for (let i = 0; i < keys.length - 1; i++) {\n if (!current[keys[i]]) current[keys[i]] = {};\n current = current[keys[i]];\n }\n current[keys[keys.length - 1]] = parsedValue;\n\n if (saveSettings(settings)) {\n console.log(`Setting ${key} = ${value}`);\n } else {\n console.log(\"Failed to save settings\");\n }\n } catch (error) {\n console.error(\"Error setting value:\", (error as Error).message);\n }\n return true;\n }\n\n return false;\n}\n\nfunction installShellGreeting(): void {\n const homeDir = os.homedir();\n\n let configDir: string, scriptPath: string;\n if (IS_WINDOWS) {\n configDir = path.join(homeDir, \"AppData\", \"Local\");\n scriptPath = path.join(configDir, \"systeminfo\");\n } else {\n configDir = path.join(homeDir, \".config\");\n scriptPath = path.join(configDir, \"systeminfo\");\n }\n\n const currentScript = path.resolve(__filename);\n\n try {\n if (!fs.existsSync(configDir)) {\n fs.mkdirSync(configDir, { recursive: true });\n }\n\n fs.copyFileSync(currentScript, scriptPath);\n if (!IS_WINDOWS) {\n fs.chmodSync(scriptPath, \"755\");\n }\n\n if (IS_WINDOWS) {\n console.log(\"Windows installation:\");\n console.log(\"1. Script copied to:\", scriptPath);\n console.log(\"2. To add to PowerShell profile, run:\");\n console.log(` Add-Content $PROFILE \"node '${scriptPath}'\"`);\n console.log(\n \"3. To add to Command Prompt, create a batch file in your startup folder\"\n );\n\n const startupBat = path.join(configDir, \"systeminfo-startup.bat\");\n fs.writeFileSync(startupBat, `@echo off\\nnode \"${scriptPath}\"\\n`);\n console.log(\"4. Batch file created:\", startupBat);\n } else {\n try {\n const hushLoginPath = path.join(homeDir, \".hushlogin\");\n fs.writeFileSync(hushLoginPath, \"\");\n } catch {}\n\n const bashrcPath = path.join(homeDir, \".bashrc\");\n const bashLine = `node ${scriptPath}`;\n\n if (fs.existsSync(bashrcPath)) {\n const bashrc = fs.readFileSync(bashrcPath, \"utf8\");\n if (!bashrc.includes(\"systeminfo\")) {\n fs.appendFileSync(bashrcPath, `\\n${bashLine}\\n`);\n }\n } else {\n fs.writeFileSync(bashrcPath, `${bashLine}\\n`);\n }\n\n const zshrcPath = path.join(homeDir, \".zshrc\");\n if (fs.existsSync(zshrcPath)) {\n const zshrc = fs.readFileSync(zshrcPath, \"utf8\");\n if (!zshrc.includes(\"systeminfo\")) {\n fs.appendFileSync(zshrcPath, `\\n${bashLine}\\n`);\n }\n }\n\n const fishConfigPath = path.join(\n homeDir,\n \".config\",\n \"fish\",\n \"config.fish\"\n );\n if (fs.existsSync(fishConfigPath)) {\n const fishConfig = fs.readFileSync(fishConfigPath, \"utf8\");\n if (!fishConfig.includes(\"systeminfo\")) {\n fs.appendFileSync(\n fishConfigPath,\n `\\nset -U fish_greeting \"\"\\n${bashLine}\\n`\n );\n }\n }\n\n const nushellConfigPath = path.join(\n homeDir,\n \".config\",\n \"nushell\",\n \"config.nu\"\n );\n if (fs.existsSync(nushellConfigPath)) {\n const nushellConfig = fs.readFileSync(nushellConfigPath, \"utf8\");\n if (!nushellConfig.includes(\"systeminfo\")) {\n fs.appendFileSync(\n nushellConfigPath,\n `\\n$env.config.show_banner = false\\n${bashLine}\\n`\n );\n }\n }\n }\n\n console.log(\"Shell greeting installation completed!\");\n } catch (error) {\n console.error(\"Error installing shell greeting:\", (error as Error).message);\n process.exit(1);\n }\n}\n\nfunction parseCLIMode(args: string[]): string[] | null {\n for (const arg of args) {\n if (!arg.startsWith(\"--\") && arg.includes(\",\")) {\n return arg\n .split(\",\")\n .map((part) => part.trim())\n .filter((part) => part.length > 0);\n }\n }\n\n for (const arg of args) {\n if (!arg.startsWith(\"--\") && !arg.includes(\"=\") && arg.length > 0) {\n return [arg.trim()];\n }\n }\n\n return null;\n}\n\nasync function showHelp(): Promise<void> {\n console.log(`\nSystem Info Script - TypeScript Version\n\nUsage:\n about-system [options]\n about-system <part1,part2,...> # CLI mode: show specific parts only\n\nOptions:\n --help, -h Show this help message\n --install Install as shell greeting\n --settings-init Initialize settings file with defaults\n --settings-show Display current settings\n --settings-reset Reset settings to defaults\n --refresh Clear the cache file\n --set <key> <value> Set a configuration value (use dot notation)\n --json Output as JSON\n\nExamples:\n about-system # Show all info (default)\n about-system cpu,os # Show only CPU and OS info\n about-system user,hostname,ip # Show user, hostname, and IP\n about-system disk_used # Show only disk usage\n about-system --install\n about-system --set display.show_emojis false\n about-system --set colors.user blue\n about-system --set emojis.cpu \"🚀 \"\n about-system --set labels.cpu \"Processor\"\n about-system --json\n\nSettings file: ${SETTINGS_FILE}\nCache file: ${CACHE_FILE}\n\nPlatform: ${\n IS_WINDOWS\n ? \"Windows\"\n : os.platform() === \"darwin\"\n ? \"macOS\"\n : os.platform() === \"linux\"\n ? \"Linux\"\n : \"Unknown\"\n }\n\nAvailable display blocks:\n Basic: user, hostname, uptime, shell, os, kernel, device\n Resources: disk_used, ram_used, memory_available, swap_used, top_process\n Network: ip, iplocal, city, domain, isp, network_interfaces\n Hardware: cpu, gpu, temperature, battery, screen_resolution\n System: load_average, users_logged_in, mount_points, services_running\n Tools: pacman, ports, containers\n`);\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n\n if (handleSettingsCommand(args)) {\n return;\n }\n\n if (args.includes(\"--help\") || args.includes(\"-h\")) {\n await showHelp();\n return;\n }\n\n if (args.includes(\"--install\")) {\n installShellGreeting();\n return;\n }\n\n if (args.includes(\"--json\")) {\n const info = await getSystemInfo();\n console.log(JSON.stringify(info, null, 2));\n return;\n }\n\n const cliParts = parseCLIMode(args);\n if (cliParts) {\n const customDisplayOrder = [cliParts];\n await displaySystemInfo(customDisplayOrder);\n return;\n }\n\n await displaySystemInfo();\n}\n\nmain().catch((error) => {\n console.error(\"Error:\", error.message);\n process.exit(1);\n});\n\nexport { displaySystemInfo, installShellGreeting };\n"],"names":["__filename","fileURLToPath","IS_WINDOWS","os","formatValue","key","value","settings","color","colors","emoji","batteryEmoji","output","ports","colorCodes","port","index","colorCode","wrapAnsiText","text","maxLength","lines","currentLine","visibleCount","activeAnsi","i","char","seq","j","unit","width","code","displaySystemInfo","customDisplayOrder","loadSettings","displayOrder","info","getSystemInfo","allItems","group","formatted","maxLineLength","line","handleSettingsCommand","args","saveSettings","DEFAULT_SETTINGS","fs","CACHE_FILE","error","setIndex","parsedValue","keys","current","installShellGreeting","homeDir","configDir","scriptPath","path","currentScript","startupBat","hushLoginPath","bashrcPath","bashLine","zshrcPath","fishConfigPath","nushellConfigPath","parseCLIMode","arg","part","showHelp","SETTINGS_FILE","main","cliParts"],"mappings":";;;;;;AAQA,MAAMA,IAAaC,EAAc,YAAY,GAAG,GAa1CC,IAAaC,EAAG,SAAA,MAAe;AAErC,SAASC,EAAYC,GAAaC,GAAeC,GAA4B;AAC3E,MAAI,CAACD,KAASA,EAAM,KAAA,MAAW,GAAI,QAAO;AAE1C,QAAME,IACJC,EAAOF,EAAS,OAAOF,CAAG,CAAwB,KAAKI,EAAO,OAC1DC,IAAQH,EAAS,QAAQ,eAAcA,EAAS,OAAOF,CAAG,KAAK;AAGrE,MAAIA,MAAQ,aAAaE,EAAS,QAAQ,aAAa;AACrD,UAAMI,IAAeL,EAAM,SAAS,GAAG,IACnCC,EAAS,OAAO,mBAChBA,EAAS,OAAO;AACpB,WAAO,GAAGC,CAAK,GAAGG,CAAY,GAAGL,CAAK;AAAA,EACxC;AAGA,MAAID,MAAQ,WAAWE,EAAS,OAAOF,CAAG,MAAM,gBAAgBC,GAAO;AAErE,QAAIM,IAAS,IADCL,EAAS,QAAQ,cAAcA,EAAS,OAAO,QAAQ,EAC/C;AACtB,UAAMM,IAAQP,EAAM,MAAM,GAAG,GACvBQ,IAAa,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AAC1C,WAAAD,EAAM,QAAQ,CAACE,GAAMC,MAAU;AAC7B,YAAMC,IAAYH,EAAWE,IAAQF,EAAW,MAAM;AACtD,MAAAF,KAAU,QAAQK,CAAS,IAAIF,CAAI;AAAA,IACrC,CAAC,GACMH,EAAO,KAAA;AAAA,EAChB;AAGA,MAAIP,MAAQ,YAAYE,EAAS,OAAOF,CAAG,MAAM,gBAAgBC,GAAO;AACtE,UAAMI,IAAQH,EAAS,QAAQ,cAAcA,EAAS,OAAO,SAAS;AAC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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBA6BGC,CAAa;AAAA,cAChBvB,CAAU;AAAA;AAAA,YAGpB9C,IACI,YACAC,EAAG,SAAA,MAAe,WAClB,UACAA,EAAG,SAAA,MAAe,UAClB,UACA,SACN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CASD;AACD;AAEA,eAAeqE,IAAsB;AACnC,QAAM5B,IAAO,QAAQ,KAAK,MAAM,CAAC;AAEjC,MAAID,EAAsBC,CAAI;AAC5B;AAGF,MAAIA,EAAK,SAAS,QAAQ,KAAKA,EAAK,SAAS,IAAI,GAAG;AAClD,UAAM0B,EAAA;AACN;AAAA,EACF;AAEA,MAAI1B,EAAK,SAAS,WAAW,GAAG;AAC9B,IAAAU,EAAA;AACA;AAAA,EACF;AAEA,MAAIV,EAAK,SAAS,QAAQ,GAAG;AAC3B,UAAMR,IAAO,MAAMC,EAAA;AACnB,YAAQ,IAAI,KAAK,UAAUD,GAAM,MAAM,CAAC,CAAC;AACzC;AAAA,EACF;AAEA,QAAMqC,IAAWN,EAAavB,CAAI;AAClC,MAAI6B,GAAU;AAEZ,UAAMzC,EADqB,CAACyC,CAAQ,CACM;AAC1C;AAAA,EACF;AAEA,QAAMzC,EAAA;AACR;AAEAwC,IAAO,MAAM,CAACvB,MAAU;AACtB,UAAQ,MAAM,UAAUA,EAAM,OAAO,GACrC,QAAQ,KAAK,CAAC;AAChB,CAAC;"}
|
|
1
|
+
{"version":3,"file":"about-system-cli.js","sources":["../src/about-system-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport os from \"os\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { getSystemInfo } from \"./system-info-api\";\nimport type { SystemInfo, SystemInfoOptions } from \"./systeminfo-types\";\n\nconst __filename = fileURLToPath(import.meta.url);\n\nimport {\n Settings,\n DEFAULT_SETTINGS,\n colors,\n backgrounds,\n SETTINGS_FILE,\n CACHE_FILE,\n loadSettings,\n saveSettings,\n} from \"./info/settings\";\n\n// Platform detection\nconst IS_WINDOWS = os.platform() === \"win32\";\n\n// Foreground code -> [background code, contrasting text code] for the\n// legacy 8-color multicolor rotation (ports/pacman rainbow mode).\nconst MULTICOLOR_BG: Record<number, [number, number]> = {\n 31: [41, 97], // red\n 32: [42, 30], // green\n 33: [43, 30], // yellow\n 34: [44, 97], // blue\n 35: [45, 97], // magenta\n 36: [46, 30], // cyan\n};\n\nfunction formatValue(key: string, value: string, settings: Settings): string {\n if (!value || value.trim() === \"\") return \"\";\n\n const showBackgrounds = settings.display.show_backgrounds !== false;\n const colorName = settings.colors[key] as keyof typeof colors;\n const bg = backgrounds[colorName as keyof typeof backgrounds];\n const style = (showBackgrounds && bg) || colors[colorName] || colors.reset;\n const suffix = showBackgrounds ? colors.reset : \"\";\n const emoji = settings.display.show_emojis ? settings.emojis[key] || \"\" : \"\";\n\n // Special handling for battery emoji\n if (key === \"battery\" && settings.display.show_emojis) {\n const batteryEmoji = value.includes(\"+\")\n ? settings.emojis.battery_charging\n : settings.emojis.battery;\n return `${style}${batteryEmoji}${value}${suffix}`;\n }\n\n // Multicolor handling for ports\n if (key === \"ports\" && settings.colors[key] === \"multicolor\" && value) {\n const emoji = settings.display.show_emojis ? settings.emojis.ports : \"\";\n let output = ` ${emoji}`;\n const ports = value.split(\" \");\n const colorCodes = [31, 32, 33, 34, 35, 36];\n ports.forEach((port, index) => {\n const colorCode = colorCodes[index % colorCodes.length];\n if (showBackgrounds) {\n const [bgCode, textCode] = MULTICOLOR_BG[colorCode];\n output += `\\x1b[${bgCode}m\\x1b[${textCode}m${port}\\x1b[0m `;\n } else {\n output += `\\x1b[${colorCode}m${port}\\x1b[0m `;\n }\n });\n return output.trim();\n }\n\n // Multicolor handling for pacman\n if (key === \"pacman\" && settings.colors[key] === \"multicolor\" && value) {\n const emoji = settings.display.show_emojis ? settings.emojis.pacman : \"\";\n return `${style}${emoji}${value}${suffix}`;\n }\n\n return `${style}${emoji}${value}${suffix}`;\n}\n\n/**\n * Wraps text to a maximum visible width, filling each line completely with\n * characters before moving on. Unlike block-boundary wrapping, this breaks in\n * the middle of an info block when it doesn't fit, so no visible space is left\n * unused at the end of a line.\n *\n * ANSI color codes are copied verbatim and never counted toward the width, and\n * the active color is re-applied at the start of each wrapped line so colors\n * survive a mid-block break. Emoji surrogate pairs are kept intact.\n *\n * @param text - The text to wrap (may contain ANSI escape sequences)\n * @param maxLength - Maximum visible characters per line\n * @returns Array of wrapped lines\n */\nfunction wrapAnsiText(text: string, maxLength: number): string[] {\n if (maxLength <= 0) return text ? [text] : [];\n\n const lines: string[] = [];\n let currentLine = \"\";\n let visibleCount = 0;\n let activeAnsi = \"\";\n\n for (let i = 0; i < text.length; i++) {\n const char = text[i];\n\n // Copy ANSI escape sequences verbatim without counting them.\n if (char === \"\\x1b\" && text[i + 1] === \"[\") {\n let seq = char;\n let j = i + 1;\n while (j < text.length && text[j] !== \"m\") {\n seq += text[j];\n j++;\n }\n if (j < text.length) seq += text[j]; // include the trailing \"m\"\n currentLine += seq;\n // Track the active color so wrapped lines keep it; a reset clears it.\n activeAnsi = /\\x1b\\[0m/.test(seq) ? \"\" : seq;\n i = j;\n continue;\n }\n\n // Keep an emoji (surrogate pair) together and count it as width 2.\n let unit = char;\n let width = 1;\n const code = text.charCodeAt(i);\n if (code >= 0xd800 && code <= 0xdbff && i + 1 < text.length) {\n unit = char + text[i + 1];\n width = 2;\n i++;\n }\n\n // Line is full: break here, even in the middle of an info block.\n if (visibleCount >= maxLength) {\n lines.push(currentLine);\n currentLine = activeAnsi;\n visibleCount = 0;\n }\n\n currentLine += unit;\n visibleCount += width;\n }\n\n if (currentLine) lines.push(currentLine);\n\n return lines;\n}\n\nasync function displaySystemInfo(\n customDisplayOrder: string[][] | null = null\n): Promise<void> {\n const settings = loadSettings();\n const displayOrder = customDisplayOrder || settings.display_order;\n\n // Get system info\n const info = await getSystemInfo();\n\n // Single line mode\n if (settings.display.single_line) {\n const allItems: string[] = [];\n\n for (const group of displayOrder) {\n for (const key of group) {\n const value = info[key as keyof SystemInfo] as string;\n const formatted = formatValue(key, value, settings);\n if (formatted && formatted.trim()) {\n allItems.push(formatted);\n }\n }\n }\n\n if (allItems.length > 0) {\n console.log(allItems.join(\" \") + colors.reset);\n }\n return;\n }\n\n // Multi-line mode: fill each line completely with characters, wrapping in\n // the middle of an info block when it no longer fits.\n const maxLineLength = settings.display.line_wrap_length;\n const allItems: string[] = [];\n\n for (const group of displayOrder) {\n for (const key of group) {\n const value = info[key as keyof SystemInfo] as string;\n const formatted = formatValue(key, value, settings);\n\n if (formatted && formatted.trim()) {\n allItems.push(formatted);\n }\n }\n }\n\n const lines = wrapAnsiText(allItems.join(\" \"), maxLineLength);\n\n // Output\n if (lines.length > 0) {\n lines.forEach((line) => {\n console.log(line + colors.reset);\n });\n } else if (settings.advanced.debug) {\n console.log(\"No system information could be displayed\");\n }\n}\n\nfunction handleSettingsCommand(args: string[]): boolean {\n const settings = loadSettings();\n\n if (args.includes(\"--settings-init\")) {\n if (saveSettings(DEFAULT_SETTINGS)) {\n console.log(\"Settings initialized with defaults\");\n } else {\n console.log(\"Failed to initialize settings\");\n }\n return true;\n }\n\n if (args.includes(\"--settings-show\")) {\n console.log(\"Current settings:\");\n console.log(JSON.stringify(settings, null, 2));\n return true;\n }\n\n if (args.includes(\"--settings-reset\")) {\n if (saveSettings(DEFAULT_SETTINGS)) {\n console.log(\"Settings reset to defaults\");\n } else {\n console.log(\"Failed to reset settings\");\n }\n return true;\n }\n\n if (args.includes(\"--refresh\")) {\n try {\n if (fs.existsSync(CACHE_FILE)) {\n fs.unlinkSync(CACHE_FILE);\n console.log(\"Cache cleared\");\n }\n } catch (error) {\n console.error(\"Error clearing cache:\", (error as Error).message);\n }\n return true;\n }\n\n const setIndex = args.indexOf(\"--set\");\n if (setIndex !== -1 && args[setIndex + 1] && args[setIndex + 2]) {\n const key = args[setIndex + 1];\n const value = args[setIndex + 2];\n\n try {\n const parsedValue =\n value.startsWith(\"{\") || value.startsWith(\"[\")\n ? JSON.parse(value)\n : value === \"true\"\n ? true\n : value === \"false\"\n ? false\n : value;\n\n const keys = key.split(\".\");\n let current: any = settings;\n for (let i = 0; i < keys.length - 1; i++) {\n if (!current[keys[i]]) current[keys[i]] = {};\n current = current[keys[i]];\n }\n current[keys[keys.length - 1]] = parsedValue;\n\n if (saveSettings(settings)) {\n console.log(`Setting ${key} = ${value}`);\n } else {\n console.log(\"Failed to save settings\");\n }\n } catch (error) {\n console.error(\"Error setting value:\", (error as Error).message);\n }\n return true;\n }\n\n return false;\n}\n\nfunction installShellGreeting(): void {\n const homeDir = os.homedir();\n\n let configDir: string, scriptPath: string;\n if (IS_WINDOWS) {\n configDir = path.join(homeDir, \"AppData\", \"Local\");\n scriptPath = path.join(configDir, \"systeminfo\");\n } else {\n configDir = path.join(homeDir, \".config\");\n scriptPath = path.join(configDir, \"systeminfo\");\n }\n\n const currentScript = path.resolve(__filename);\n\n try {\n if (!fs.existsSync(configDir)) {\n fs.mkdirSync(configDir, { recursive: true });\n }\n\n fs.copyFileSync(currentScript, scriptPath);\n if (!IS_WINDOWS) {\n fs.chmodSync(scriptPath, \"755\");\n }\n\n if (IS_WINDOWS) {\n console.log(\"Windows installation:\");\n console.log(\"1. Script copied to:\", scriptPath);\n console.log(\"2. To add to PowerShell profile, run:\");\n console.log(` Add-Content $PROFILE \"node '${scriptPath}'\"`);\n console.log(\n \"3. To add to Command Prompt, create a batch file in your startup folder\"\n );\n\n const startupBat = path.join(configDir, \"systeminfo-startup.bat\");\n fs.writeFileSync(startupBat, `@echo off\\nnode \"${scriptPath}\"\\n`);\n console.log(\"4. Batch file created:\", startupBat);\n } else {\n try {\n const hushLoginPath = path.join(homeDir, \".hushlogin\");\n fs.writeFileSync(hushLoginPath, \"\");\n } catch {}\n\n const bashrcPath = path.join(homeDir, \".bashrc\");\n const bashLine = `node ${scriptPath}`;\n\n if (fs.existsSync(bashrcPath)) {\n const bashrc = fs.readFileSync(bashrcPath, \"utf8\");\n if (!bashrc.includes(\"systeminfo\")) {\n fs.appendFileSync(bashrcPath, `\\n${bashLine}\\n`);\n }\n } else {\n fs.writeFileSync(bashrcPath, `${bashLine}\\n`);\n }\n\n const zshrcPath = path.join(homeDir, \".zshrc\");\n if (fs.existsSync(zshrcPath)) {\n const zshrc = fs.readFileSync(zshrcPath, \"utf8\");\n if (!zshrc.includes(\"systeminfo\")) {\n fs.appendFileSync(zshrcPath, `\\n${bashLine}\\n`);\n }\n }\n\n const fishConfigPath = path.join(\n homeDir,\n \".config\",\n \"fish\",\n \"config.fish\"\n );\n if (fs.existsSync(fishConfigPath)) {\n const fishConfig = fs.readFileSync(fishConfigPath, \"utf8\");\n if (!fishConfig.includes(\"systeminfo\")) {\n fs.appendFileSync(\n fishConfigPath,\n `\\nset -U fish_greeting \"\"\\n${bashLine}\\n`\n );\n }\n }\n\n const nushellConfigPath = path.join(\n homeDir,\n \".config\",\n \"nushell\",\n \"config.nu\"\n );\n if (fs.existsSync(nushellConfigPath)) {\n const nushellConfig = fs.readFileSync(nushellConfigPath, \"utf8\");\n if (!nushellConfig.includes(\"systeminfo\")) {\n fs.appendFileSync(\n nushellConfigPath,\n `\\n$env.config.show_banner = false\\n${bashLine}\\n`\n );\n }\n }\n }\n\n console.log(\"Shell greeting installation completed!\");\n } catch (error) {\n console.error(\"Error installing shell greeting:\", (error as Error).message);\n process.exit(1);\n }\n}\n\nfunction parseCLIMode(args: string[]): string[] | null {\n for (const arg of args) {\n if (!arg.startsWith(\"--\") && arg.includes(\",\")) {\n return arg\n .split(\",\")\n .map((part) => part.trim())\n .filter((part) => part.length > 0);\n }\n }\n\n for (const arg of args) {\n if (!arg.startsWith(\"--\") && !arg.includes(\"=\") && arg.length > 0) {\n return [arg.trim()];\n }\n }\n\n return null;\n}\n\nasync function showHelp(): Promise<void> {\n console.log(`\nSystem Info Script - TypeScript Version\n\nUsage:\n about-system [options]\n about-system <part1,part2,...> # CLI mode: show specific parts only\n\nOptions:\n --help, -h Show this help message\n --install Install as shell greeting\n --settings-init Initialize settings file with defaults\n --settings-show Display current settings\n --settings-reset Reset settings to defaults\n --refresh Clear the cache file\n --set <key> <value> Set a configuration value (use dot notation)\n --json Output as JSON\n\nExamples:\n about-system # Show all info (default)\n about-system cpu,os # Show only CPU and OS info\n about-system user,hostname,ip # Show user, hostname, and IP\n about-system disk_used # Show only disk usage\n about-system --install\n about-system --set display.show_emojis false\n about-system --set display.show_backgrounds false\n about-system --set colors.user blue\n about-system --set emojis.cpu \"🚀 \"\n about-system --set labels.cpu \"Processor\"\n about-system --json\n\nSettings file: ${SETTINGS_FILE}\nCache file: ${CACHE_FILE}\n\nPlatform: ${\n IS_WINDOWS\n ? \"Windows\"\n : os.platform() === \"darwin\"\n ? \"macOS\"\n : os.platform() === \"linux\"\n ? \"Linux\"\n : \"Unknown\"\n }\n\nAvailable display blocks:\n Basic: user, hostname, uptime, shell, os, kernel, device\n Resources: disk_used, ram_used, memory_available, swap_used, top_process\n Network: ip, iplocal, city, domain, isp, network_interfaces\n Hardware: cpu, gpu, temperature, battery, screen_resolution\n System: load_average, users_logged_in, mount_points, services_running\n Tools: pacman, ports, containers\n`);\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n\n if (handleSettingsCommand(args)) {\n return;\n }\n\n if (args.includes(\"--help\") || args.includes(\"-h\")) {\n await showHelp();\n return;\n }\n\n if (args.includes(\"--install\")) {\n installShellGreeting();\n return;\n }\n\n if (args.includes(\"--json\")) {\n const info = await getSystemInfo();\n console.log(JSON.stringify(info, null, 2));\n return;\n }\n\n const cliParts = parseCLIMode(args);\n if (cliParts) {\n const customDisplayOrder = [cliParts];\n await displaySystemInfo(customDisplayOrder);\n return;\n }\n\n await displaySystemInfo();\n}\n\nmain().catch((error) => {\n console.error(\"Error:\", error.message);\n process.exit(1);\n});\n\nexport { displaySystemInfo, installShellGreeting };\n"],"names":["__filename","fileURLToPath","IS_WINDOWS","os","MULTICOLOR_BG","formatValue","key","value","settings","showBackgrounds","colorName","bg","backgrounds","style","colors","suffix","emoji","batteryEmoji","output","ports","colorCodes","port","index","colorCode","bgCode","textCode","wrapAnsiText","text","maxLength","lines","currentLine","visibleCount","activeAnsi","i","char","seq","j","unit","width","code","displaySystemInfo","customDisplayOrder","loadSettings","displayOrder","info","getSystemInfo","allItems","group","formatted","maxLineLength","line","handleSettingsCommand","args","saveSettings","DEFAULT_SETTINGS","fs","CACHE_FILE","error","setIndex","parsedValue","keys","current","installShellGreeting","homeDir","configDir","scriptPath","path","currentScript","startupBat","hushLoginPath","bashrcPath","bashLine","zshrcPath","fishConfigPath","nushellConfigPath","parseCLIMode","arg","part","showHelp","SETTINGS_FILE","main","cliParts"],"mappings":";;;;;;AAQA,MAAMA,IAAaC,EAAc,YAAY,GAAG,GAc1CC,IAAaC,EAAG,SAAA,MAAe,SAI/BC,IAAkD;AAAA,EACtD,IAAI,CAAC,IAAI,EAAE;AAAA;AAAA,EACX,IAAI,CAAC,IAAI,EAAE;AAAA;AAAA,EACX,IAAI,CAAC,IAAI,EAAE;AAAA;AAAA,EACX,IAAI,CAAC,IAAI,EAAE;AAAA;AAAA,EACX,IAAI,CAAC,IAAI,EAAE;AAAA;AAAA,EACX,IAAI,CAAC,IAAI,EAAE;AAAA;AACb;AAEA,SAASC,EAAYC,GAAaC,GAAeC,GAA4B;AAC3E,MAAI,CAACD,KAASA,EAAM,KAAA,MAAW,GAAI,QAAO;AAE1C,QAAME,IAAkBD,EAAS,QAAQ,qBAAqB,IACxDE,IAAYF,EAAS,OAAOF,CAAG,GAC/BK,IAAKC,EAAYF,CAAqC,GACtDG,IAASJ,KAAmBE,KAAOG,EAAOJ,CAAS,KAAKI,EAAO,OAC/DC,IAASN,IAAkBK,EAAO,QAAQ,IAC1CE,IAAQR,EAAS,QAAQ,eAAcA,EAAS,OAAOF,CAAG,KAAK;AAGrE,MAAIA,M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