jsfetch-term 1.0.4 → 1.0.5
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 +24 -0
- package/bin/app.js +105 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,3 +12,27 @@ To install globally on your machine through npm use the command
|
|
|
12
12
|
```JavaScript
|
|
13
13
|
npm i -g jsfetch-term
|
|
14
14
|
```
|
|
15
|
+
|
|
16
|
+
### Usage
|
|
17
|
+
|
|
18
|
+
To see an output of your system run
|
|
19
|
+
|
|
20
|
+
```Shell
|
|
21
|
+
jsfetch
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
To see output in all one color provide a color as an argument
|
|
25
|
+
|
|
26
|
+
```Shell
|
|
27
|
+
jsfetch color
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
supported colors are red, green, yellow, blue, magenta, cyan, white, gray, black and rainbow!
|
|
31
|
+
|
|
32
|
+
### Development
|
|
33
|
+
|
|
34
|
+
To work on jsfetch after cloning the project directory run
|
|
35
|
+
|
|
36
|
+
```JavaScript
|
|
37
|
+
npm install
|
|
38
|
+
```
|
package/bin/app.js
CHANGED
|
@@ -9,17 +9,19 @@ import {
|
|
|
9
9
|
uptime,
|
|
10
10
|
release,
|
|
11
11
|
version,
|
|
12
|
+
totalmem,
|
|
12
13
|
} from 'node:os';
|
|
13
14
|
import chalk from 'chalk';
|
|
14
15
|
import * as logos from './os-logos.js';
|
|
16
|
+
import { argv } from 'node:process';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* returns a number of the currently installed packages on a system.
|
|
18
|
-
* @param {string}
|
|
20
|
+
* @param {string} OS - devices platform.
|
|
19
21
|
*/
|
|
20
|
-
function packages(
|
|
22
|
+
function packages(OS) {
|
|
21
23
|
// if mac os
|
|
22
|
-
if (
|
|
24
|
+
if (OS === 'darwin') {
|
|
23
25
|
const directory = spawnSync('brew', ['--cellar'], { encoding: 'utf8' });
|
|
24
26
|
const myVar = directory.output[1];
|
|
25
27
|
const fullText = `${myVar} | wc -l`;
|
|
@@ -29,9 +31,24 @@ function packages(platform) {
|
|
|
29
31
|
encoding: 'utf8',
|
|
30
32
|
}).output[1].trim();
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
// Pass on my VM running Xubuntu
|
|
36
|
+
if (OS === 'linux') {
|
|
37
|
+
try {
|
|
38
|
+
const aptList = spawnSync('apt', ['list', '--installed'], {
|
|
39
|
+
encoding: 'utf8',
|
|
40
|
+
});
|
|
41
|
+
return aptList.output[1].match(/\n/g).length - 1;
|
|
42
|
+
} catch (err) {
|
|
43
|
+
return 'distribution not supported ';
|
|
44
|
+
}
|
|
34
45
|
}
|
|
46
|
+
|
|
47
|
+
if (OS === 'win32') {
|
|
48
|
+
// return 'not supported';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return 'not supported';
|
|
35
52
|
}
|
|
36
53
|
|
|
37
54
|
/**
|
|
@@ -133,40 +150,94 @@ function getGPU(platform) {
|
|
|
133
150
|
}
|
|
134
151
|
|
|
135
152
|
/**
|
|
136
|
-
* returns a
|
|
137
|
-
* @param {
|
|
153
|
+
* returns a rounded number of the users total installed memory in GB
|
|
154
|
+
* @param {number} memoryInt - total memory of system in bytes.
|
|
138
155
|
*/
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
const fullText = 'SPHardwareDataType |grep Memory';
|
|
142
|
-
return spawnSync('system_profiler', [`${fullText}`], {
|
|
143
|
-
shell: true,
|
|
144
|
-
encoding: 'utf8',
|
|
145
|
-
}).output[1].trim();
|
|
146
|
-
}
|
|
147
|
-
// if (platform === 'win32') {//TODO: return windows memory
|
|
148
|
-
// }
|
|
156
|
+
function displayMemory(memoryInt) {
|
|
157
|
+
return Math.floor(Math.floor(memoryInt / 1000000) / 1024);
|
|
149
158
|
}
|
|
150
159
|
|
|
160
|
+
/**
|
|
161
|
+
* returns a system logo
|
|
162
|
+
* @param {string} OS - devices platform.
|
|
163
|
+
*/
|
|
151
164
|
function displayLogo(OS) {
|
|
152
165
|
return logos[OS] || ':::OS LOGO:::';
|
|
153
166
|
}
|
|
154
167
|
|
|
155
168
|
const name = platform();
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
console.log(chalk.
|
|
169
|
+
const colors = [
|
|
170
|
+
'red',
|
|
171
|
+
'green',
|
|
172
|
+
'yellow',
|
|
173
|
+
'blue',
|
|
174
|
+
'magenta',
|
|
175
|
+
'cyan',
|
|
176
|
+
'white',
|
|
177
|
+
'gray',
|
|
178
|
+
'black',
|
|
179
|
+
'rainbow',
|
|
180
|
+
];
|
|
181
|
+
const choice = argv[2];
|
|
182
|
+
|
|
183
|
+
if (colors.includes(choice) === true) {
|
|
184
|
+
if (choice === 'rainbow') {
|
|
185
|
+
console.log(chalk.red(`${displayLogo(name)}`));
|
|
186
|
+
// TODO: separate logo from rest of information
|
|
187
|
+
console.log(chalk.red(`${userInfo().username}@${hostname()}`));
|
|
188
|
+
console.log('-----------------');
|
|
189
|
+
console.log(chalk.rgb(255, 87, 51)(`OS: ${name} ${release()} ${arch()}`));
|
|
190
|
+
console.log(chalk.rgb(255, 87, 51)(`Kernel: ${version()}`));
|
|
191
|
+
console.log(chalk.yellow(`Uptime: ${timeConvert(uptime())}`));
|
|
192
|
+
console.log(chalk.yellow(`packages: ${packages(name)}`));
|
|
193
|
+
console.log(chalk.green(`shell: ${shellCheck(name)}`));
|
|
194
|
+
console.log(chalk.green(`${getResolution(name)}`));
|
|
195
|
+
// TODO:desktop environment
|
|
196
|
+
// TODO:window manager
|
|
197
|
+
// TODO:terminal
|
|
198
|
+
// TODO:terminal font
|
|
199
|
+
console.log(chalk.blue(`CPU: ${getCPU(name)}`));
|
|
200
|
+
console.log(chalk.blue(`GPU: ${getGPU(name)}`));
|
|
201
|
+
console.log(
|
|
202
|
+
chalk.rgb(143, 0, 255)(`Memory: ${displayMemory(totalmem())}GB`)
|
|
203
|
+
);
|
|
204
|
+
} else {
|
|
205
|
+
console.log(chalk[choice](`${displayLogo(name)}`));
|
|
206
|
+
// TODO: separate logo from rest of information
|
|
207
|
+
console.log(chalk[choice](`${userInfo().username}@${hostname()}`));
|
|
208
|
+
console.log('-----------------');
|
|
209
|
+
console.log(chalk[choice](`OS: ${name} ${release()} ${arch()}`));
|
|
210
|
+
console.log(chalk[choice](`Kernel: ${version()}`));
|
|
211
|
+
console.log(chalk[choice](`Uptime: ${timeConvert(uptime())}`));
|
|
212
|
+
console.log(chalk[choice](`packages: ${packages(name)}`));
|
|
213
|
+
console.log(chalk[choice](`shell: ${shellCheck(name)}`));
|
|
214
|
+
console.log(chalk[choice](`${getResolution(name)}`));
|
|
215
|
+
// TODO:desktop environment
|
|
216
|
+
// TODO:window manager
|
|
217
|
+
// TODO:terminal
|
|
218
|
+
// TODO:terminal font
|
|
219
|
+
console.log(chalk[choice](`CPU: ${getCPU(name)}`));
|
|
220
|
+
console.log(chalk[choice](`GPU: ${getGPU(name)}`));
|
|
221
|
+
console.log(chalk[choice](`Memory: ${displayMemory(totalmem())}GB`));
|
|
222
|
+
}
|
|
223
|
+
} else if (choice === undefined) {
|
|
224
|
+
console.log(chalk.cyan(`${displayLogo(name)}`));
|
|
225
|
+
// TODO: separate logo from rest of information
|
|
226
|
+
console.log(chalk.yellow(`${userInfo().username}@${hostname()}`));
|
|
227
|
+
console.log('-----------------');
|
|
228
|
+
console.log(chalk.blue(`OS: ${name} ${release()} ${arch()}`));
|
|
229
|
+
console.log(chalk.red(`Kernel: ${version()}`));
|
|
230
|
+
console.log(chalk.red(`Uptime: ${timeConvert(uptime())}`));
|
|
231
|
+
console.log(chalk.yellow(`packages: ${packages(name)}`));
|
|
232
|
+
console.log(chalk.yellow(`shell: ${shellCheck(name)}`));
|
|
233
|
+
console.log(chalk.yellow(`${getResolution(name)}`));
|
|
234
|
+
// TODO:desktop environment
|
|
235
|
+
// TODO:window manager
|
|
236
|
+
// TODO:terminal
|
|
237
|
+
// TODO:terminal font
|
|
238
|
+
console.log(chalk.yellow(`CPU: ${getCPU(name)}`));
|
|
239
|
+
console.log(chalk.yellow(`GPU: ${getGPU(name)}`));
|
|
240
|
+
console.log(chalk.yellow(`Memory: ${displayMemory(totalmem())}GB`));
|
|
241
|
+
} else {
|
|
242
|
+
console.log('color not supported', choice);
|
|
243
|
+
}
|