os-nerve 1.1.0
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 +20 -0
- package/index.js +89 -0
- package/package.json +32 -0
- package/welcome.js +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# ⚡ OS-NERVE
|
|
2
|
+
|
|
3
|
+
> The command-line nerve center for your system.
|
|
4
|
+
|
|
5
|
+
**OS-Nerve** is a lightweight, professional terminal dashboard that monitors your system vitals in real-time. Built for developers who live in the terminal.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## ✨ Features
|
|
11
|
+
* **📊 System Vitals**: Real-time CPU Load & RAM Usage.
|
|
12
|
+
* **🔋 Battery Status**: Live charging status and percentage.
|
|
13
|
+
* **🌐 Network Speed**: Accurate Download/Upload speeds (1s interval scan).
|
|
14
|
+
* **🎨 Interactive**: Beautiful magenta UI with refresh capabilities.
|
|
15
|
+
|
|
16
|
+
## 📦 Installation
|
|
17
|
+
Install globally via npm:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g os-nerve
|
package/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from 'commander';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import ora from 'ora';
|
|
6
|
+
import si from 'systeminformation';
|
|
7
|
+
|
|
8
|
+
program.name('nerve').version('1.2.0');
|
|
9
|
+
|
|
10
|
+
// Helper to delay for accurate network speed calculation
|
|
11
|
+
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
12
|
+
|
|
13
|
+
async function showDashboard() {
|
|
14
|
+
const spinner = ora('Measuring System Vitals (1s scan)...').start();
|
|
15
|
+
|
|
16
|
+
// 1. Get the default network interface ID (Wi-Fi or Ethernet)
|
|
17
|
+
const defaultIf = await si.networkInterfaceDefault();
|
|
18
|
+
|
|
19
|
+
// 2. First measure (Baseline)
|
|
20
|
+
await si.networkStats(defaultIf);
|
|
21
|
+
|
|
22
|
+
// 3. Wait 1 second to calculate speed (Speed = Change / Time)
|
|
23
|
+
await sleep(1000);
|
|
24
|
+
|
|
25
|
+
// 4. Final measure (The real data)
|
|
26
|
+
const [cpu, mem, battery, netData] = await Promise.all([
|
|
27
|
+
si.currentLoad(),
|
|
28
|
+
si.mem(),
|
|
29
|
+
si.battery(),
|
|
30
|
+
si.networkStats(defaultIf) // Get stats ONLY for the active internet connection
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
spinner.stop();
|
|
34
|
+
console.clear(); // Clean screen for a dashboard feel
|
|
35
|
+
|
|
36
|
+
const net = netData[0]; // The active interface
|
|
37
|
+
|
|
38
|
+
console.log(chalk.magenta.bold('\n--- 🛠️ OS-NERVE SYSTEM DASHBOARD ---'));
|
|
39
|
+
|
|
40
|
+
// CPU & RAM
|
|
41
|
+
console.log(chalk.cyan(' [System]'));
|
|
42
|
+
console.log(` CPU Load: ${chalk.yellow(cpu.currentLoad.toFixed(1) + '%')}`);
|
|
43
|
+
console.log(` RAM: ${chalk.yellow((mem.active / 1024 / 1024 / 1024).toFixed(2))} / ${(mem.total / 1024 / 1024 / 1024).toFixed(2)} GB`);
|
|
44
|
+
|
|
45
|
+
// Battery
|
|
46
|
+
if (battery.hasBattery) {
|
|
47
|
+
console.log(` Battery: ${chalk.green(battery.percent + '%')} (${battery.isCharging ? 'Charging' : 'Discharging'})`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Network (Now accurate!)
|
|
51
|
+
console.log(chalk.cyan('\n [Network]'));
|
|
52
|
+
if (net) {
|
|
53
|
+
console.log(` Download: ${chalk.white((net.rx_sec / 1024).toFixed(2))} KB/s`);
|
|
54
|
+
console.log(` Upload: ${chalk.white((net.tx_sec / 1024).toFixed(2))} KB/s`);
|
|
55
|
+
} else {
|
|
56
|
+
console.log(chalk.gray(' Offline or No Interface Found'));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log(chalk.magenta('--------------------------------\n'));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
program
|
|
63
|
+
.command('dash')
|
|
64
|
+
.description('Launch the dashboard')
|
|
65
|
+
.action(async () => {
|
|
66
|
+
let keepRunning = true;
|
|
67
|
+
|
|
68
|
+
while (keepRunning) {
|
|
69
|
+
// Run the dashboard logic
|
|
70
|
+
await showDashboard();
|
|
71
|
+
|
|
72
|
+
// 'rawlist' fixes the invisible menu bug on Windows!
|
|
73
|
+
const { action } = await inquirer.prompt([{
|
|
74
|
+
type: 'rawlist',
|
|
75
|
+
name: 'action',
|
|
76
|
+
message: 'Next move?',
|
|
77
|
+
choices: ['Refresh', 'Exit']
|
|
78
|
+
}]);
|
|
79
|
+
|
|
80
|
+
if (action === 'Exit') {
|
|
81
|
+
console.log(chalk.yellow('See you later, Captain.'));
|
|
82
|
+
keepRunning = false;
|
|
83
|
+
process.exit();
|
|
84
|
+
}
|
|
85
|
+
// If Refresh, the loop simply runs again!
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "os-nerve",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A terminal dashboard to monitor system vitals and hardware health.",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"nerve": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
+
"postinstall": "node welcome.js"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"cli",
|
|
16
|
+
"system-monitor",
|
|
17
|
+
"dashboard",
|
|
18
|
+
"vitals",
|
|
19
|
+
"hardware"
|
|
20
|
+
],
|
|
21
|
+
"author": "Eyuel Engida",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"chalk": "^5.6.2",
|
|
25
|
+
"commander": "^14.0.3",
|
|
26
|
+
"dotenv": "^17.2.3",
|
|
27
|
+
"inquirer": "^13.2.2",
|
|
28
|
+
"ora": "^9.1.0",
|
|
29
|
+
"systeminformation": "^5.30.7",
|
|
30
|
+
"telegraf": "^4.16.3"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/welcome.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
console.log(`
|
|
4
|
+
${chalk.green.bold('⚡ OS-NERVE INSTALLED')}
|
|
5
|
+
${chalk.gray('The nerve center for your system is now active.')}
|
|
6
|
+
|
|
7
|
+
${chalk.white.bold('🔗 GitHub:')} ${chalk.blue('https://github.com/Eul45/os-nerve')}
|
|
8
|
+
${chalk.white.bold('👤 Author:')} ${chalk.yellow('Eyuel Engida')}
|
|
9
|
+
|
|
10
|
+
Type ${chalk.cyan.bold('nerve dash')} to begin.
|
|
11
|
+
`);
|