jsfch 1.0.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/index.js +49 -0
- package/package.json +23 -0
package/index.js
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
import fs from "node:fs";
|
3
|
+
import os from "node:os";
|
4
|
+
|
5
|
+
const releaseInfo = "/etc/os-release";
|
6
|
+
|
7
|
+
const data = fs.readFileSync(releaseInfo, "utf8");
|
8
|
+
|
9
|
+
// parsing /erc/os-release file
|
10
|
+
const osInfo = {};
|
11
|
+
data.split("\n").forEach((line) => {
|
12
|
+
const [key, value] = line.split("=");
|
13
|
+
if (key && value) {
|
14
|
+
osInfo[key.trim()] = value.replace(/"/g, "").trim();
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
function formatedSeconds(seconds) {
|
19
|
+
const hh = Math.floor(seconds / 3600);
|
20
|
+
const mm = Math.floor((seconds % 3600) / 60);
|
21
|
+
const ss = Math.floor(seconds % 60);
|
22
|
+
|
23
|
+
return `${hh} hours, ${mm} minutes, ${ss} seconds`
|
24
|
+
}
|
25
|
+
|
26
|
+
const getMemory = {
|
27
|
+
usedMemory: Math.floor((os.totalmem / (1024 * 1024)) - (os.freemem / (1024 * 1024))),
|
28
|
+
totalMemory: Math.floor((os.totalmem / (1024 * 1024)))
|
29
|
+
}
|
30
|
+
|
31
|
+
const output = {
|
32
|
+
host: `${process.env.USER}@${os.hostname}`,
|
33
|
+
hr: '--------------------------------------------------------------------',
|
34
|
+
sys: `Distro: ${osInfo["NAME"]} ${os.machine}`,
|
35
|
+
kernel: `Kernel: ${os.release}`,
|
36
|
+
uptime: `Uptime: ${formatedSeconds(os.uptime)}`,
|
37
|
+
shell: `Shell: ${process.env.SHELL}`,
|
38
|
+
// terminal: `Terminal: ${process.env.TERM}`,
|
39
|
+
cpus: `CPU: ${JSON.stringify(os.cpus().at(0).model)}`,
|
40
|
+
memory: `Memory: ${getMemory.usedMemory}MB / ${getMemory.totalMemory}MB`,
|
41
|
+
currentDate: `Date: ${new Date().toDateString()}`,
|
42
|
+
currentTime: `Time: ${new Date().toTimeString()}`,
|
43
|
+
};
|
44
|
+
|
45
|
+
(function () {
|
46
|
+
for(const value in output) {
|
47
|
+
console.log(output[value]);
|
48
|
+
}
|
49
|
+
})();
|
package/package.json
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"name": "jsfch",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"main": "index.js",
|
5
|
+
"scripts": {
|
6
|
+
"dev": "node index.js"
|
7
|
+
},
|
8
|
+
"keywords": [
|
9
|
+
"fetch",
|
10
|
+
"jsfetch",
|
11
|
+
"neofetch"
|
12
|
+
],
|
13
|
+
"author": "vj",
|
14
|
+
"license": "ISC",
|
15
|
+
"type": "module",
|
16
|
+
"description": "Simple JS version of fetch",
|
17
|
+
"bin": {
|
18
|
+
"jsfch": "./index.js"
|
19
|
+
},
|
20
|
+
"dependencies": {
|
21
|
+
"node": "^22.13.0"
|
22
|
+
}
|
23
|
+
}
|