jsfetch-term 1.0.2 → 1.0.4
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/.eslintrc.cjs +20 -0
- package/.prettierrc.json +9 -0
- package/README.md +8 -3
- package/bin/app.js +94 -70
- package/bin/os-logos.js +78 -0
- package/package.json +8 -1
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
es2021: true,
|
|
4
|
+
node: true,
|
|
5
|
+
},
|
|
6
|
+
extends: [
|
|
7
|
+
//
|
|
8
|
+
'airbnb-base',
|
|
9
|
+
'plugin:prettier/recommended',
|
|
10
|
+
],
|
|
11
|
+
overrides: [],
|
|
12
|
+
parserOptions: {
|
|
13
|
+
ecmaVersion: 'latest',
|
|
14
|
+
sourceType: 'module',
|
|
15
|
+
},
|
|
16
|
+
rules: {
|
|
17
|
+
'no-console': 'off',
|
|
18
|
+
'import/extensions': ['warn', 'always'],
|
|
19
|
+
},
|
|
20
|
+
};
|
package/.prettierrc.json
ADDED
package/README.md
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
# jsfetch
|
|
2
|
+
|
|
2
3
|
jsfetch is a clone of [neofetch](https://github.com/dylanaraps/neofetch) written in JavaScript using NodeJS.
|
|
3
4
|
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
5
|
|
|
5
|
-
|
|
6
|
+
jsfetch currently supports Windows, Mac and Debian based Linux distros.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
6
10
|
To install globally on your machine through npm use the command
|
|
7
|
-
|
|
11
|
+
|
|
12
|
+
```JavaScript
|
|
8
13
|
npm i -g jsfetch-term
|
|
9
|
-
```
|
|
14
|
+
```
|
package/bin/app.js
CHANGED
|
@@ -1,67 +1,94 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
|
|
1
3
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
platform,
|
|
6
|
+
userInfo,
|
|
7
|
+
hostname,
|
|
8
|
+
arch,
|
|
9
|
+
uptime,
|
|
10
|
+
release,
|
|
11
|
+
version,
|
|
12
|
+
} from 'node:os';
|
|
3
13
|
import chalk from 'chalk';
|
|
14
|
+
import * as logos from './os-logos.js';
|
|
4
15
|
|
|
5
16
|
/**
|
|
6
17
|
* returns a number of the currently installed packages on a system.
|
|
7
18
|
* @param {string} platform - devices platform.
|
|
8
19
|
*/
|
|
9
20
|
function packages(platform) {
|
|
10
|
-
|
|
11
|
-
//if mac os
|
|
21
|
+
// if mac os
|
|
12
22
|
if (platform === 'darwin') {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return spawnSync('ls', [replaced], {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
const directory = spawnSync('brew', ['--cellar'], { encoding: 'utf8' });
|
|
24
|
+
const myVar = directory.output[1];
|
|
25
|
+
const fullText = `${myVar} | wc -l`;
|
|
26
|
+
const replaced = fullText.replace(/\n|\r/g, '');
|
|
27
|
+
return spawnSync('ls', [replaced], {
|
|
28
|
+
shell: true,
|
|
29
|
+
encoding: 'utf8',
|
|
30
|
+
}).output[1].trim();
|
|
31
|
+
}
|
|
32
|
+
if (platform === 'win32') {
|
|
33
|
+
return 'not supported';
|
|
22
34
|
}
|
|
23
35
|
}
|
|
24
36
|
|
|
25
37
|
/**
|
|
26
|
-
* converts time to a
|
|
38
|
+
* converts time to a formatted string.
|
|
27
39
|
* @param {number} time - computers uptime in seconds.
|
|
28
40
|
*/
|
|
29
41
|
function timeConvert(time) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return `time is minuet's: ${Math.floor(min)}, hour's: ${Math.floor(
|
|
42
|
+
const min = time / 60;
|
|
43
|
+
const hour = time / 3600;
|
|
44
|
+
const day = time / 86400;
|
|
45
|
+
return `time is minuet's: ${Math.floor(min)}, hour's: ${Math.floor(
|
|
46
|
+
hour
|
|
47
|
+
)}, day's: ${Math.floor(day)} `;
|
|
34
48
|
}
|
|
35
49
|
|
|
36
50
|
/**
|
|
37
51
|
* returns the users shell.
|
|
38
52
|
*/
|
|
39
53
|
function shellCheck(platform) {
|
|
40
|
-
if (platform === 'darwin'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
if (platform === 'darwin' || platform === 'linux') {
|
|
55
|
+
return userInfo(['utf8']).shell;
|
|
56
|
+
}
|
|
57
|
+
if (platform === 'win32') {
|
|
58
|
+
const shell = spawnSync('$host.Name', { encoding: 'utf8' });
|
|
44
59
|
if (shell.output === null) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
60
|
+
return 'CMD';
|
|
61
|
+
}
|
|
62
|
+
if (shell.output[1].trim() === 'ConsoleHost') {
|
|
63
|
+
return 'Powershell';
|
|
48
64
|
}
|
|
49
65
|
}
|
|
50
66
|
}
|
|
51
67
|
|
|
52
|
-
|
|
53
|
-
//resoltion
|
|
68
|
+
// resolution
|
|
54
69
|
function getResolution(platform) {
|
|
55
|
-
//based on platform issue command that gets screen resolution and then
|
|
70
|
+
// based on platform issue command that gets screen resolution and then
|
|
56
71
|
if (platform === 'darwin') {
|
|
57
72
|
const fullText = 'SPDisplaysDataType |grep Resolution';
|
|
58
|
-
return spawnSync('system_profiler', [`${fullText}`], {
|
|
73
|
+
return spawnSync('system_profiler', [`${fullText}`], {
|
|
74
|
+
shell: true,
|
|
75
|
+
encoding: 'utf8',
|
|
76
|
+
}).output[1].trim();
|
|
59
77
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
if (platform === 'win32') {
|
|
79
|
+
const height = spawnSync(
|
|
80
|
+
'wmic',
|
|
81
|
+
['desktopmonitor', 'get', 'screenheight'],
|
|
82
|
+
{
|
|
83
|
+
encoding: 'utf8',
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
const width = spawnSync('wmic', ['desktopmonitor', 'get', 'screenwidth'], {
|
|
87
|
+
encoding: 'utf8',
|
|
88
|
+
});
|
|
89
|
+
return `${String(width.output[1].trim().replace(/^\D+/g, ''))}x${String(
|
|
90
|
+
height.output[1].trim().replace(/^\D+/g, '')
|
|
91
|
+
)}`;
|
|
65
92
|
}
|
|
66
93
|
}
|
|
67
94
|
|
|
@@ -70,8 +97,14 @@ function getResolution(platform) {
|
|
|
70
97
|
* @param {string} platform - devices platform.
|
|
71
98
|
*/
|
|
72
99
|
function getCPU(platform) {
|
|
73
|
-
if (platform === 'darwin') {
|
|
74
|
-
|
|
100
|
+
if (platform === 'darwin') {
|
|
101
|
+
return spawnSync('sysctl', ['-n machdep.cpu.brand_string'], {
|
|
102
|
+
shell: true,
|
|
103
|
+
encoding: 'utf8',
|
|
104
|
+
}).output[1].trim();
|
|
105
|
+
}
|
|
106
|
+
if (platform === 'win32') {
|
|
107
|
+
// TODO: return cpu
|
|
75
108
|
}
|
|
76
109
|
}
|
|
77
110
|
|
|
@@ -79,15 +112,22 @@ function getCPU(platform) {
|
|
|
79
112
|
* returns a string of the systems GPU.
|
|
80
113
|
* @param {string} platform - devices platform.
|
|
81
114
|
*/
|
|
82
|
-
|
|
115
|
+
function getGPU(platform) {
|
|
83
116
|
if (platform === 'darwin') {
|
|
84
117
|
const fullText = 'SPDisplaysDataType |grep Chipset';
|
|
85
|
-
return spawnSync('system_profiler', [`${fullText}`], {
|
|
118
|
+
return spawnSync('system_profiler', [`${fullText}`], {
|
|
119
|
+
shell: true,
|
|
120
|
+
encoding: 'utf8',
|
|
121
|
+
}).output[1].trim();
|
|
86
122
|
}
|
|
87
123
|
if (platform === 'win32') {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
124
|
+
const gpu = spawnSync(
|
|
125
|
+
'wmic',
|
|
126
|
+
['path', 'win32_videoController', 'get', 'name'],
|
|
127
|
+
{ encoding: 'utf8' }
|
|
128
|
+
).output[1].split('\n');
|
|
129
|
+
gpu.splice(0, 1);
|
|
130
|
+
gpu.splice(1, 2);
|
|
91
131
|
return gpu.join('\n').trim();
|
|
92
132
|
}
|
|
93
133
|
}
|
|
@@ -96,41 +136,25 @@ function getCPU(platform) {
|
|
|
96
136
|
* returns a string of the systems memory.
|
|
97
137
|
* @param {string} platform - devices platform.
|
|
98
138
|
*/
|
|
99
|
-
|
|
139
|
+
function getMemory(platform) {
|
|
100
140
|
if (platform === 'darwin') {
|
|
101
141
|
const fullText = 'SPHardwareDataType |grep Memory';
|
|
102
|
-
return spawnSync('system_profiler', [`${fullText}`], {
|
|
142
|
+
return spawnSync('system_profiler', [`${fullText}`], {
|
|
143
|
+
shell: true,
|
|
144
|
+
encoding: 'utf8',
|
|
145
|
+
}).output[1].trim();
|
|
103
146
|
}
|
|
104
147
|
// if (platform === 'win32') {//TODO: return windows memory
|
|
105
148
|
// }
|
|
106
149
|
}
|
|
107
150
|
|
|
108
|
-
function displayLogo(
|
|
109
|
-
|
|
110
|
-
let logo = ` 'c.
|
|
111
|
-
,xNMM.
|
|
112
|
-
.OMMMMo
|
|
113
|
-
OMMM0,
|
|
114
|
-
.;loddo:. .olloddol;.
|
|
115
|
-
cKMMMMMMMMMMNWMMMMMMMMMM0:
|
|
116
|
-
.KMMMMMMMMMMMMMMMMMMMMMMMWd.
|
|
117
|
-
XMMMMMMMMMMMMMMMMMMMMMMMX.
|
|
118
|
-
;MMMMMMMMMMMMMMMMMMMMMMMM:
|
|
119
|
-
:MMMMMMMMMMMMMMMMMMMMMMMM:
|
|
120
|
-
.MMMMMMMMMMMMMMMMMMMMMMMMX.
|
|
121
|
-
kMMMMMMMMMMMMMMMMMMMMMMMMWd.
|
|
122
|
-
.XMMMMMMMMMMMMMMMMMMMMMMMMMMk
|
|
123
|
-
.XMMMMMMMMMMMMMMMMMMMMMMMMK.
|
|
124
|
-
kMMMMMMMMMMMMMMMMMMMMMMd
|
|
125
|
-
;KMMMMMMMWXXWMMMMMMMk.
|
|
126
|
-
.cooc,. .,coo:.`
|
|
127
|
-
return logo;
|
|
128
|
-
}
|
|
151
|
+
function displayLogo(OS) {
|
|
152
|
+
return logos[OS] || ':::OS LOGO:::';
|
|
129
153
|
}
|
|
130
154
|
|
|
131
|
-
|
|
155
|
+
const name = platform();
|
|
132
156
|
console.log(chalk.cyan(`${displayLogo(name)}`));
|
|
133
|
-
//TODO:
|
|
157
|
+
// TODO: separate logo from rest of information
|
|
134
158
|
console.log(chalk.yellow(`${userInfo().username}@${hostname()}`));
|
|
135
159
|
console.log('-----------------');
|
|
136
160
|
console.log(chalk.blue(`OS: ${name} ${release()} ${arch()}`));
|
|
@@ -139,10 +163,10 @@ console.log(chalk.red(`Uptime: ${timeConvert(uptime())}`));
|
|
|
139
163
|
console.log(chalk.yellow(`packages: ${packages(name)}`));
|
|
140
164
|
console.log(chalk.yellow(`shell: ${shellCheck(name)}`));
|
|
141
165
|
console.log(chalk.yellow(`${getResolution(name)}`));
|
|
142
|
-
//TODO:desktop
|
|
143
|
-
//TODO:window manager
|
|
144
|
-
//TODO:terminal
|
|
145
|
-
//TODO:terminal font
|
|
166
|
+
// TODO:desktop environment
|
|
167
|
+
// TODO:window manager
|
|
168
|
+
// TODO:terminal
|
|
169
|
+
// TODO:terminal font
|
|
146
170
|
console.log(chalk.yellow(`CPU: ${getCPU(name)}`));
|
|
147
171
|
console.log(chalk.yellow(`GPU: ${getGPU(name)}`));
|
|
148
|
-
console.log(chalk.yellow(`Memory: ${getMemory(name)}`));
|
|
172
|
+
console.log(chalk.yellow(`Memory: ${getMemory(name)}`));
|
package/bin/os-logos.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by https://ascii-generator.site/
|
|
3
|
+
*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@@@@@@@%+
|
|
30
|
+
.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
|
|
31
|
+
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+
|
|
32
|
+
:@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+
|
|
33
|
+
.%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
|
|
34
|
+
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%.
|
|
35
|
+
:#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=
|
|
36
|
+
-%@@@@@@@@@@#*+===+*%@@@@@@@@@@+
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const linux = `
|
|
40
|
+
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
41
|
+
░░▒▓█▓▒░░░░░░░▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
42
|
+
░░░▒█▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
43
|
+
░░░▒█▒░░░░░░░▒▓▒░░▒▓▓░▒▓▓▓░░░▒▓▒░░▒▓▓░░▒▓▓▒░░▒▓▒░░
|
|
44
|
+
░░░▒█▒░░░░░░░░█▓░░░▓█▒░░░█▓░░░█▓░░░▓█░░░░▓█▒▒▓░░░░
|
|
45
|
+
░░░▒█▒░░░░░░░░█▓░░░▓█░░░░█▓░░░█▓░░░▓█░░░░░▒█▓░░░░░
|
|
46
|
+
░░░▒█▒░░░░▓▒░░█▓░░░▓█░░░░█▓░░░█▓░░░▓█░░░░▒▓░▓█░░░░
|
|
47
|
+
░░▒▓▓▓▒▒▒▓▓░░▒▓▓▒░▒▓▓▒░░▒▓▓▒░░▒▓▓▒▒▒▓▒░▒▓▓░░░▓▓▒░░`;
|
|
48
|
+
|
|
49
|
+
const win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@@@@@@@@@@@@@@@@@@@@@
|
|
71
|
+
@@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
72
|
+
.@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
73
|
+
..@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
74
|
+
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
|
75
|
+
..@@@@@@@@@@@@@@@@@@@
|
|
76
|
+
...@@@@@@@@`
|
|
77
|
+
|
|
78
|
+
export { darwin, linux, win32 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsfetch-term",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "neofetch clone in javascript",
|
|
5
5
|
"main": "app.js",
|
|
6
6
|
"type": "module",
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"build": "node bin/app.js",
|
|
9
9
|
"test": "echo \"No test specified\""
|
|
10
10
|
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"jsfetch": "./bin/app.js"
|
|
13
|
+
},
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
|
13
16
|
"url": "https://github.com/toddmcintire/jsfetch"
|
|
@@ -19,6 +22,10 @@
|
|
|
19
22
|
},
|
|
20
23
|
"devDependencies": {
|
|
21
24
|
"eslint": "^8.28.0",
|
|
25
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
26
|
+
"eslint-config-prettier": "^8.5.0",
|
|
27
|
+
"eslint-plugin-import": "^2.26.0",
|
|
28
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
22
29
|
"prettier": "^2.7.1"
|
|
23
30
|
}
|
|
24
31
|
}
|