jsfetch-term 1.0.3 → 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/.eslintrc.cjs CHANGED
@@ -15,5 +15,6 @@ module.exports = {
15
15
  },
16
16
  rules: {
17
17
  'no-console': 'off',
18
+ 'import/extensions': ['warn', 'always'],
18
19
  },
19
20
  };
package/README.md CHANGED
@@ -1,9 +1,38 @@
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
- # Installation
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
+ ```
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,16 +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';
15
+ import * as logos from './os-logos.js';
16
+ import { argv } from 'node:process';
14
17
 
15
18
  /**
16
19
  * returns a number of the currently installed packages on a system.
17
- * @param {string} platform - devices platform.
20
+ * @param {string} OS - devices platform.
18
21
  */
19
- function packages(platform) {
22
+ function packages(OS) {
20
23
  // if mac os
21
- if (platform === 'darwin') {
24
+ if (OS === 'darwin') {
22
25
  const directory = spawnSync('brew', ['--cellar'], { encoding: 'utf8' });
23
26
  const myVar = directory.output[1];
24
27
  const fullText = `${myVar} | wc -l`;
@@ -28,9 +31,24 @@ function packages(platform) {
28
31
  encoding: 'utf8',
29
32
  }).output[1].trim();
30
33
  }
31
- if (platform === 'win32') {
32
- return 'not supported';
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
+ }
45
+ }
46
+
47
+ if (OS === 'win32') {
48
+ // return 'not supported';
33
49
  }
50
+
51
+ return 'not supported';
34
52
  }
35
53
 
36
54
  /**
@@ -50,11 +68,8 @@ function timeConvert(time) {
50
68
  * returns the users shell.
51
69
  */
52
70
  function shellCheck(platform) {
53
- if (platform === 'darwin') {
54
- return spawnSync(`echo`, ['"$SHELL"'], {
55
- shell: true,
56
- encoding: 'utf8',
57
- }).output[1].trim();
71
+ if (platform === 'darwin' || platform === 'linux') {
72
+ return userInfo(['utf8']).shell;
58
73
  }
59
74
  if (platform === 'win32') {
60
75
  const shell = spawnSync('$host.Name', { encoding: 'utf8' });
@@ -135,59 +150,94 @@ function getGPU(platform) {
135
150
  }
136
151
 
137
152
  /**
138
- * returns a string of the systems memory.
139
- * @param {string} platform - devices platform.
153
+ * returns a rounded number of the users total installed memory in GB
154
+ * @param {number} memoryInt - total memory of system in bytes.
140
155
  */
141
- function getMemory(platform) {
142
- if (platform === 'darwin') {
143
- const fullText = 'SPHardwareDataType |grep Memory';
144
- return spawnSync('system_profiler', [`${fullText}`], {
145
- shell: true,
146
- encoding: 'utf8',
147
- }).output[1].trim();
148
- }
149
- // if (platform === 'win32') {//TODO: return windows memory
150
- // }
156
+ function displayMemory(memoryInt) {
157
+ return Math.floor(Math.floor(memoryInt / 1000000) / 1024);
151
158
  }
152
159
 
153
- function displayLogo(platform) {
154
- if (platform === 'darwin') {
155
- const logo = ` 'c.
156
- ,xNMM.
157
- .OMMMMo
158
- OMMM0,
159
- .;loddo:. .olloddol;.
160
- cKMMMMMMMMMMNWMMMMMMMMMM0:
161
- .KMMMMMMMMMMMMMMMMMMMMMMMWd.
162
- XMMMMMMMMMMMMMMMMMMMMMMMX.
163
- ;MMMMMMMMMMMMMMMMMMMMMMMM:
164
- :MMMMMMMMMMMMMMMMMMMMMMMM:
165
- .MMMMMMMMMMMMMMMMMMMMMMMMX.
166
- kMMMMMMMMMMMMMMMMMMMMMMMMWd.
167
- .XMMMMMMMMMMMMMMMMMMMMMMMMMMk
168
- .XMMMMMMMMMMMMMMMMMMMMMMMMK.
169
- kMMMMMMMMMMMMMMMMMMMMMMd
170
- ;KMMMMMMMWXXWMMMMMMMk.
171
- .cooc,. .,coo:.`;
172
- return logo;
173
- }
160
+ /**
161
+ * returns a system logo
162
+ * @param {string} OS - devices platform.
163
+ */
164
+ function displayLogo(OS) {
165
+ return logos[OS] || ':::OS LOGO:::';
174
166
  }
175
167
 
176
168
  const name = platform();
177
- console.log(chalk.cyan(`${displayLogo(name)}`));
178
- // TODO: separate logo from rest of information
179
- console.log(chalk.yellow(`${userInfo().username}@${hostname()}`));
180
- console.log('-----------------');
181
- console.log(chalk.blue(`OS: ${name} ${release()} ${arch()}`));
182
- console.log(chalk.red(`Kernel: ${version()}`));
183
- console.log(chalk.red(`Uptime: ${timeConvert(uptime())}`));
184
- console.log(chalk.yellow(`packages: ${packages(name)}`));
185
- console.log(chalk.yellow(`shell: ${shellCheck(name)}`));
186
- console.log(chalk.yellow(`${getResolution(name)}`));
187
- // TODO:desktop environment
188
- // TODO:window manager
189
- // TODO:terminal
190
- // TODO:terminal font
191
- console.log(chalk.yellow(`CPU: ${getCPU(name)}`));
192
- console.log(chalk.yellow(`GPU: ${getGPU(name)}`));
193
- console.log(chalk.yellow(`Memory: ${getMemory(name)}`));
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
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Generated by https://ascii-generator.site/
3
+ * With columns of size: 50
4
+ */
5
+
6
+ const darwin = `
7
+ -+#%@-
8
+ -#@@@@@@.
9
+ :%@@@@@@@#
10
+ =@@@@@@@@%
11
+ =@@@@@@@@*
12
+ @@@@@@@*:
13
+ :@@@%*=.
14
+ :-====-:. . .:==+++==:.
15
+ :+%@@@@@@@@@@@#+-:.:-+#@@@@@@@@@@@@@#=
16
+ =%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*.
17
+ -%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#.
18
+ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*.
19
+ =@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:
20
+ .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.
21
+ *@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
22
+ %@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
23
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%
24
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
25
+ #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+
26
+ =@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
27
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*
28
+ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+.
29
+ %@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%+
30
+ .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
31
+ :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+
32
+ :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+
33
+ .%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-
34
+ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%.
35
+ :#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=
36
+ -%@@@@@@@@@@#*+===+*%@@@@@@@@@@+
37
+ `;
38
+
39
+ const linux = `
40
+ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
41
+ ░░▒▓█▓▒░░░░░░░▓▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
42
+ ░░░▒█▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
43
+ ░░░▒█▒░░░░░░░▒▓▒░░▒▓▓░▒▓▓▓░░░▒▓▒░░▒▓▓░░▒▓▓▒░░▒▓▒░░
44
+ ░░░▒█▒░░░░░░░░█▓░░░▓█▒░░░█▓░░░█▓░░░▓█░░░░▓█▒▒▓░░░░
45
+ ░░░▒█▒░░░░░░░░█▓░░░▓█░░░░█▓░░░█▓░░░▓█░░░░░▒█▓░░░░░
46
+ ░░░▒█▒░░░░▓▒░░█▓░░░▓█░░░░█▓░░░█▓░░░▓█░░░░▒▓░▓█░░░░
47
+ ░░▒▓▓▓▒▒▒▓▓░░▒▓▓▒░▒▓▓▒░░▒▓▓▒░░▒▓▓▒▒▒▓▒░▒▓▓░░░▓▓▒░░`;
48
+
49
+ const win32 = `
50
+ .....
51
+ .....@@@@@@@@@@
52
+ ....@@@@@@@@@@@@@@@@@@@@@
53
+ .... @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
54
+ ...@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
55
+ @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
56
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
57
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
58
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
59
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
60
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
61
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
62
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
63
+
64
+ @@@@@@@@@@@@@@@@@@ @@@@@@@@.....................
65
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
66
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
67
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
68
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
69
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
70
+ @@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
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",
3
+ "version": "1.0.5",
4
4
  "description": "neofetch clone in javascript",
5
5
  "main": "app.js",
6
6
  "type": "module",