jsfetch-term 1.0.0 → 1.0.2
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 +5 -1
- package/bin/app.js +29 -43
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -2,4 +2,8 @@
|
|
|
2
2
|
jsfetch is a clone of [neofetch](https://github.com/dylanaraps/neofetch) written in JavaScript using NodeJS.
|
|
3
3
|
jsfetch is designed to be a fan project by [@toddmcintire](https://github.com/toddmcintire) to learn more about how JavaScript and NodeJS work. It is not designed to be run in any serious capacity, if you are looking for something more stable please use [neofetch](https://github.com/dylanaraps/neofetch).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# Installation
|
|
6
|
+
To install globally on your machine through npm use the command
|
|
7
|
+
```
|
|
8
|
+
npm i -g jsfetch-term
|
|
9
|
+
```
|
package/bin/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { platform, userInfo, hostname, arch, uptime, release, version } from 'node:os';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -10,11 +10,11 @@ function packages(platform) {
|
|
|
10
10
|
|
|
11
11
|
//if mac os
|
|
12
12
|
if (platform === 'darwin') {
|
|
13
|
-
let directory =
|
|
13
|
+
let directory = spawnSync('brew', ['--cellar'], { encoding : 'utf8' });
|
|
14
14
|
let myVar = directory.output[1];
|
|
15
15
|
let fullText = `${myVar} | wc -l`;
|
|
16
16
|
let replaced = fullText.replace(/\n|\r/g, "");
|
|
17
|
-
return
|
|
17
|
+
return spawnSync('ls', [replaced], {shell: true, encoding: 'utf8'}).output[1].trim();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
else if (platform === "win32") {
|
|
@@ -30,19 +30,17 @@ function timeConvert(time) {
|
|
|
30
30
|
let min = time / 60;
|
|
31
31
|
let hour = time / 3600;
|
|
32
32
|
let day = time / 86400;
|
|
33
|
-
return `time is
|
|
33
|
+
return `time is minuet's: ${Math.floor(min)}, hour's: ${Math.floor(hour)}, day's: ${Math.floor(day)} `;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* returns the users shell.
|
|
38
38
|
*/
|
|
39
39
|
function shellCheck(platform) {
|
|
40
|
-
if (platform === 'darwin'){
|
|
41
|
-
return child.spawnSync(`echo`,['"$SHELL"'], {shell: true, encoding : 'utf8' }).output[1].trim();
|
|
42
|
-
}
|
|
40
|
+
if (platform === 'darwin'){return spawnSync(`echo`,['"$SHELL"'], {shell: true, encoding : 'utf8' }).output[1].trim();}
|
|
43
41
|
|
|
44
42
|
else if (platform ==='win32') {
|
|
45
|
-
let shell =
|
|
43
|
+
let shell = spawnSync('$host.Name', {encoding : 'utf8'})
|
|
46
44
|
if (shell.output === null) {
|
|
47
45
|
return "CMD"
|
|
48
46
|
} else if (shell.output[1].trim() === "ConsoleHost") {
|
|
@@ -57,12 +55,12 @@ function getResolution(platform) {
|
|
|
57
55
|
//based on platform issue command that gets screen resolution and then
|
|
58
56
|
if (platform === 'darwin') {
|
|
59
57
|
const fullText = 'SPDisplaysDataType |grep Resolution';
|
|
60
|
-
return
|
|
58
|
+
return spawnSync('system_profiler', [`${fullText}`], {shell: true, encoding: 'utf8'}).output[1].trim();
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
else if (platform === 'win32') {
|
|
64
|
-
let height =
|
|
65
|
-
let width =
|
|
62
|
+
let height = spawnSync('wmic', ['desktopmonitor', 'get', 'screenheight'], {encoding : 'utf8'});
|
|
63
|
+
let width = spawnSync('wmic', ['desktopmonitor', 'get', 'screenwidth'], {encoding : 'utf8'});
|
|
66
64
|
return String(width.output[1].trim().replace( /^\D+/g, '')) + "x"+ String(height.output[1].trim().replace( /^\D+/g, ''));
|
|
67
65
|
}
|
|
68
66
|
}
|
|
@@ -72,11 +70,8 @@ function getResolution(platform) {
|
|
|
72
70
|
* @param {string} platform - devices platform.
|
|
73
71
|
*/
|
|
74
72
|
function getCPU(platform) {
|
|
75
|
-
if (platform === 'darwin') {return
|
|
76
|
-
|
|
77
|
-
function macCPU() {
|
|
78
|
-
const cpuCommand = child.spawnSync('sysctl', ['-n machdep.cpu.brand_string'], {shell: true, encoding: 'utf8'});
|
|
79
|
-
return cpuCommand.output[1].trim();
|
|
73
|
+
if (platform === 'darwin') {return spawnSync('sysctl', ['-n machdep.cpu.brand_string'], {shell: true, encoding: 'utf8'}).output[1].trim()};
|
|
74
|
+
if (platform === 'win32') {//TODO: return cpu
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
77
|
|
|
@@ -85,20 +80,15 @@ function getCPU(platform) {
|
|
|
85
80
|
* @param {string} platform - devices platform.
|
|
86
81
|
*/
|
|
87
82
|
function getGPU(platform) {
|
|
88
|
-
if (platform === 'darwin') {
|
|
89
|
-
if (platform === 'win32') {return windowsGPU()}
|
|
90
|
-
|
|
91
|
-
function macGPU() {
|
|
83
|
+
if (platform === 'darwin') {
|
|
92
84
|
const fullText = 'SPDisplaysDataType |grep Chipset';
|
|
93
|
-
return
|
|
85
|
+
return spawnSync('system_profiler', [`${fullText}`], {shell: true, encoding: 'utf8'}).output[1].trim();
|
|
94
86
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
lines.splice(1,2);
|
|
101
|
-
return lines.join('\n').trim();
|
|
87
|
+
if (platform === 'win32') {
|
|
88
|
+
let gpu = spawnSync('wmic', ['path', 'win32_videoController', 'get', 'name'], {encoding : 'utf8'}).output[1].split('\n');
|
|
89
|
+
gpu.splice(0,1);
|
|
90
|
+
gpu.splice(1,2);
|
|
91
|
+
return gpu.join('\n').trim();
|
|
102
92
|
}
|
|
103
93
|
}
|
|
104
94
|
|
|
@@ -107,16 +97,12 @@ function getCPU(platform) {
|
|
|
107
97
|
* @param {string} platform - devices platform.
|
|
108
98
|
*/
|
|
109
99
|
function getMemory(platform) {
|
|
110
|
-
if (platform === 'darwin') {
|
|
111
|
-
|
|
112
|
-
function macMemory() {
|
|
100
|
+
if (platform === 'darwin') {
|
|
113
101
|
const fullText = 'SPHardwareDataType |grep Memory';
|
|
114
|
-
return
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function windowsMemory() {
|
|
118
|
-
|
|
102
|
+
return spawnSync('system_profiler', [`${fullText}`], {shell: true, encoding: 'utf8'}).output[1].trim();
|
|
119
103
|
}
|
|
104
|
+
// if (platform === 'win32') {//TODO: return windows memory
|
|
105
|
+
// }
|
|
120
106
|
}
|
|
121
107
|
|
|
122
108
|
function displayLogo(platform) {
|
|
@@ -142,14 +128,14 @@ function displayLogo(platform) {
|
|
|
142
128
|
}
|
|
143
129
|
}
|
|
144
130
|
|
|
145
|
-
let name =
|
|
146
|
-
console.log(chalk.
|
|
131
|
+
let name = platform()
|
|
132
|
+
console.log(chalk.cyan(`${displayLogo(name)}`));
|
|
147
133
|
//TODO: seperate logo from rest of information
|
|
148
|
-
console.log(chalk.yellow(`${
|
|
134
|
+
console.log(chalk.yellow(`${userInfo().username}@${hostname()}`));
|
|
149
135
|
console.log('-----------------');
|
|
150
|
-
console.log(chalk.blue(`OS: ${name} ${
|
|
151
|
-
console.log(chalk.red(`Kernel: ${
|
|
152
|
-
console.log(chalk.red(`Uptime: ${timeConvert(
|
|
136
|
+
console.log(chalk.blue(`OS: ${name} ${release()} ${arch()}`));
|
|
137
|
+
console.log(chalk.red(`Kernel: ${version()}`));
|
|
138
|
+
console.log(chalk.red(`Uptime: ${timeConvert(uptime())}`));
|
|
153
139
|
console.log(chalk.yellow(`packages: ${packages(name)}`));
|
|
154
140
|
console.log(chalk.yellow(`shell: ${shellCheck(name)}`));
|
|
155
141
|
console.log(chalk.yellow(`${getResolution(name)}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfetch-term",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "neofetch clone in javascript",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"type": "module",
|
|
@@ -16,5 +16,9 @@
|
|
|
16
16
|
"license": "GPL-3.0",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"chalk": "^5.0.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"eslint": "^8.28.0",
|
|
22
|
+
"prettier": "^2.7.1"
|
|
19
23
|
}
|
|
20
24
|
}
|