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 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
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "trailingComma": "es5",
3
+ "printWidth": 80,
4
+ "singleQuote": true,
5
+ "semi": true,
6
+ "tabWidth": 2,
7
+ "useTabs": true,
8
+ "arrowParens": "always"
9
+ }
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
- # 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
+ ```
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 { platform, userInfo, hostname, arch, uptime, release, version } from 'node:os';
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
- let directory = spawnSync('brew', ['--cellar'], { encoding : 'utf8' });
14
- let myVar = directory.output[1];
15
- let fullText = `${myVar} | wc -l`;
16
- let replaced = fullText.replace(/\n|\r/g, "");
17
- return spawnSync('ls', [replaced], {shell: true, encoding: 'utf8'}).output[1].trim();
18
- }
19
-
20
- else if (platform === "win32") {
21
- return "not supported"
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 formmated string.
38
+ * converts time to a formatted string.
27
39
  * @param {number} time - computers uptime in seconds.
28
40
  */
29
41
  function timeConvert(time) {
30
- let min = time / 60;
31
- let hour = time / 3600;
32
- let day = time / 86400;
33
- return `time is minuet's: ${Math.floor(min)}, hour's: ${Math.floor(hour)}, day's: ${Math.floor(day)} `;
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'){return spawnSync(`echo`,['"$SHELL"'], {shell: true, encoding : 'utf8' }).output[1].trim();}
41
-
42
- else if (platform ==='win32') {
43
- let shell = spawnSync('$host.Name', {encoding : 'utf8'})
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 "CMD"
46
- } else if (shell.output[1].trim() === "ConsoleHost") {
47
- return "Powershell"
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}`], {shell: true, encoding: 'utf8'}).output[1].trim();
73
+ return spawnSync('system_profiler', [`${fullText}`], {
74
+ shell: true,
75
+ encoding: 'utf8',
76
+ }).output[1].trim();
59
77
  }
60
-
61
- else if (platform === 'win32') {
62
- let height = spawnSync('wmic', ['desktopmonitor', 'get', 'screenheight'], {encoding : 'utf8'});
63
- let width = spawnSync('wmic', ['desktopmonitor', 'get', 'screenwidth'], {encoding : 'utf8'});
64
- return String(width.output[1].trim().replace( /^\D+/g, '')) + "x"+ String(height.output[1].trim().replace( /^\D+/g, ''));
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') {return spawnSync('sysctl', ['-n machdep.cpu.brand_string'], {shell: true, encoding: 'utf8'}).output[1].trim()};
74
- if (platform === 'win32') {//TODO: return cpu
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
- function getGPU(platform) {
115
+ function getGPU(platform) {
83
116
  if (platform === 'darwin') {
84
117
  const fullText = 'SPDisplaysDataType |grep Chipset';
85
- return spawnSync('system_profiler', [`${fullText}`], {shell: true, encoding: 'utf8'}).output[1].trim();
118
+ return spawnSync('system_profiler', [`${fullText}`], {
119
+ shell: true,
120
+ encoding: 'utf8',
121
+ }).output[1].trim();
86
122
  }
87
123
  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);
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
- function getMemory(platform) {
139
+ function getMemory(platform) {
100
140
  if (platform === 'darwin') {
101
141
  const fullText = 'SPHardwareDataType |grep Memory';
102
- return spawnSync('system_profiler', [`${fullText}`], {shell: true, encoding: 'utf8'}).output[1].trim();
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(platform) {
109
- if (platform === 'darwin') {
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
- let name = platform()
155
+ const name = platform();
132
156
  console.log(chalk.cyan(`${displayLogo(name)}`));
133
- //TODO: seperate logo from rest of information
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 enviornment
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)}`));
@@ -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
+ 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@@@@@@@@@
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.2",
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
  }