jsfetch-term 1.0.2 → 1.0.3

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,19 @@
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
+ },
19
+ };
@@ -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/bin/app.js CHANGED
@@ -1,5 +1,15 @@
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';
4
14
 
5
15
  /**
@@ -7,61 +17,80 @@ import chalk from 'chalk';
7
17
  * @param {string} platform - devices platform.
8
18
  */
9
19
  function packages(platform) {
10
-
11
- //if mac os
20
+ // if mac os
12
21
  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"
22
+ const directory = spawnSync('brew', ['--cellar'], { encoding: 'utf8' });
23
+ const myVar = directory.output[1];
24
+ const fullText = `${myVar} | wc -l`;
25
+ const replaced = fullText.replace(/\n|\r/g, '');
26
+ return spawnSync('ls', [replaced], {
27
+ shell: true,
28
+ encoding: 'utf8',
29
+ }).output[1].trim();
30
+ }
31
+ if (platform === 'win32') {
32
+ return 'not supported';
22
33
  }
23
34
  }
24
35
 
25
36
  /**
26
- * converts time to a formmated string.
37
+ * converts time to a formatted string.
27
38
  * @param {number} time - computers uptime in seconds.
28
39
  */
29
40
  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)} `;
41
+ const min = time / 60;
42
+ const hour = time / 3600;
43
+ const day = time / 86400;
44
+ return `time is minuet's: ${Math.floor(min)}, hour's: ${Math.floor(
45
+ hour
46
+ )}, day's: ${Math.floor(day)} `;
34
47
  }
35
48
 
36
49
  /**
37
50
  * returns the users shell.
38
51
  */
39
52
  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'})
53
+ if (platform === 'darwin') {
54
+ return spawnSync(`echo`, ['"$SHELL"'], {
55
+ shell: true,
56
+ encoding: 'utf8',
57
+ }).output[1].trim();
58
+ }
59
+ if (platform === 'win32') {
60
+ const shell = spawnSync('$host.Name', { encoding: 'utf8' });
44
61
  if (shell.output === null) {
45
- return "CMD"
46
- } else if (shell.output[1].trim() === "ConsoleHost") {
47
- return "Powershell"
62
+ return 'CMD';
63
+ }
64
+ if (shell.output[1].trim() === 'ConsoleHost') {
65
+ return 'Powershell';
48
66
  }
49
67
  }
50
68
  }
51
69
 
52
-
53
- //resoltion
70
+ // resolution
54
71
  function getResolution(platform) {
55
- //based on platform issue command that gets screen resolution and then
72
+ // based on platform issue command that gets screen resolution and then
56
73
  if (platform === 'darwin') {
57
74
  const fullText = 'SPDisplaysDataType |grep Resolution';
58
- return spawnSync('system_profiler', [`${fullText}`], {shell: true, encoding: 'utf8'}).output[1].trim();
75
+ return spawnSync('system_profiler', [`${fullText}`], {
76
+ shell: true,
77
+ encoding: 'utf8',
78
+ }).output[1].trim();
59
79
  }
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, ''));
80
+ if (platform === 'win32') {
81
+ const height = spawnSync(
82
+ 'wmic',
83
+ ['desktopmonitor', 'get', 'screenheight'],
84
+ {
85
+ encoding: 'utf8',
86
+ }
87
+ );
88
+ const width = spawnSync('wmic', ['desktopmonitor', 'get', 'screenwidth'], {
89
+ encoding: 'utf8',
90
+ });
91
+ return `${String(width.output[1].trim().replace(/^\D+/g, ''))}x${String(
92
+ height.output[1].trim().replace(/^\D+/g, '')
93
+ )}`;
65
94
  }
66
95
  }
67
96
 
@@ -70,8 +99,14 @@ function getResolution(platform) {
70
99
  * @param {string} platform - devices platform.
71
100
  */
72
101
  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
102
+ if (platform === 'darwin') {
103
+ return spawnSync('sysctl', ['-n machdep.cpu.brand_string'], {
104
+ shell: true,
105
+ encoding: 'utf8',
106
+ }).output[1].trim();
107
+ }
108
+ if (platform === 'win32') {
109
+ // TODO: return cpu
75
110
  }
76
111
  }
77
112
 
@@ -79,15 +114,22 @@ function getCPU(platform) {
79
114
  * returns a string of the systems GPU.
80
115
  * @param {string} platform - devices platform.
81
116
  */
82
- function getGPU(platform) {
117
+ function getGPU(platform) {
83
118
  if (platform === 'darwin') {
84
119
  const fullText = 'SPDisplaysDataType |grep Chipset';
85
- return spawnSync('system_profiler', [`${fullText}`], {shell: true, encoding: 'utf8'}).output[1].trim();
120
+ return spawnSync('system_profiler', [`${fullText}`], {
121
+ shell: true,
122
+ encoding: 'utf8',
123
+ }).output[1].trim();
86
124
  }
87
125
  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);
126
+ const gpu = spawnSync(
127
+ 'wmic',
128
+ ['path', 'win32_videoController', 'get', 'name'],
129
+ { encoding: 'utf8' }
130
+ ).output[1].split('\n');
131
+ gpu.splice(0, 1);
132
+ gpu.splice(1, 2);
91
133
  return gpu.join('\n').trim();
92
134
  }
93
135
  }
@@ -96,10 +138,13 @@ function getCPU(platform) {
96
138
  * returns a string of the systems memory.
97
139
  * @param {string} platform - devices platform.
98
140
  */
99
- function getMemory(platform) {
141
+ function getMemory(platform) {
100
142
  if (platform === 'darwin') {
101
143
  const fullText = 'SPHardwareDataType |grep Memory';
102
- return spawnSync('system_profiler', [`${fullText}`], {shell: true, encoding: 'utf8'}).output[1].trim();
144
+ return spawnSync('system_profiler', [`${fullText}`], {
145
+ shell: true,
146
+ encoding: 'utf8',
147
+ }).output[1].trim();
103
148
  }
104
149
  // if (platform === 'win32') {//TODO: return windows memory
105
150
  // }
@@ -107,7 +152,7 @@ function getCPU(platform) {
107
152
 
108
153
  function displayLogo(platform) {
109
154
  if (platform === 'darwin') {
110
- let logo = ` 'c.
155
+ const logo = ` 'c.
111
156
  ,xNMM.
112
157
  .OMMMMo
113
158
  OMMM0,
@@ -123,14 +168,14 @@ function displayLogo(platform) {
123
168
  .XMMMMMMMMMMMMMMMMMMMMMMMMK.
124
169
  kMMMMMMMMMMMMMMMMMMMMMMd
125
170
  ;KMMMMMMMWXXWMMMMMMMk.
126
- .cooc,. .,coo:.`
127
- return logo;
171
+ .cooc,. .,coo:.`;
172
+ return logo;
128
173
  }
129
174
  }
130
175
 
131
- let name = platform()
176
+ const name = platform();
132
177
  console.log(chalk.cyan(`${displayLogo(name)}`));
133
- //TODO: seperate logo from rest of information
178
+ // TODO: separate logo from rest of information
134
179
  console.log(chalk.yellow(`${userInfo().username}@${hostname()}`));
135
180
  console.log('-----------------');
136
181
  console.log(chalk.blue(`OS: ${name} ${release()} ${arch()}`));
@@ -139,10 +184,10 @@ console.log(chalk.red(`Uptime: ${timeConvert(uptime())}`));
139
184
  console.log(chalk.yellow(`packages: ${packages(name)}`));
140
185
  console.log(chalk.yellow(`shell: ${shellCheck(name)}`));
141
186
  console.log(chalk.yellow(`${getResolution(name)}`));
142
- //TODO:desktop enviornment
143
- //TODO:window manager
144
- //TODO:terminal
145
- //TODO:terminal font
187
+ // TODO:desktop environment
188
+ // TODO:window manager
189
+ // TODO:terminal
190
+ // TODO:terminal font
146
191
  console.log(chalk.yellow(`CPU: ${getCPU(name)}`));
147
192
  console.log(chalk.yellow(`GPU: ${getGPU(name)}`));
148
- console.log(chalk.yellow(`Memory: ${getMemory(name)}`));
193
+ console.log(chalk.yellow(`Memory: ${getMemory(name)}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsfetch-term",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
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
  }