stack-analyze 1.1.4 → 1.1.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,53 @@
2
2
 
3
3
  stack-analyze all version and notable changes, fixed, remove and new additions in code.
4
4
 
5
+ ## version 1.1.7
6
+ ### Added
7
+ - twitch info tool
8
+ - remove one js module for module to cjs and esm
9
+ ### fixed
10
+ - change write token to process.env varaibles own (not avalible values in github and gitlab)
11
+ - migrate cjs to esm
12
+ - rewrite module
13
+ ### change
14
+ - except some hardware tools and github using models from console-table-printer
15
+ - now using esm now about is js file not folder about with index.js
16
+ - rewrite all tests functions
17
+
18
+ ## version 1.1.6
19
+ ### Added
20
+ - module stack-analyze mode
21
+ ### fixed
22
+ - rewrite code
23
+ - renove nonolive recommends
24
+ ### changed
25
+ - menu renove
26
+ - renove jsdocs in some function or variables
27
+ - remove nonolive recommends soon in versions desktop 7 and pwa 1.5.0
28
+
29
+ ## version 1.1.5
30
+ ### Added
31
+ - add new tool: movie info
32
+ - add new test
33
+ - renove menu
34
+ ### fixed
35
+ - rewrite in some functions and about
36
+ - remove some dependencies not using project
37
+ ### changed
38
+ - change multibar to 2 single bars
39
+ - change switch in all tools for hash functions tables
40
+ - renove nonolive recommends
41
+
42
+ ## version 1.1.4
43
+ ### Added
44
+ - add new tool: bitly info
45
+ - add new test
46
+ ### fixed
47
+ - rewrite some functions
48
+ - update npm modules via manual
49
+ ### changed
50
+ - no changed
51
+
5
52
  ## version 1.1.3
6
53
  ### Added
7
54
  - add new module: coingecko-api
package/about.js ADDED
@@ -0,0 +1,58 @@
1
+ // package.json
2
+ import { createRequire } from "module";
3
+ const require = createRequire(import.meta.url);
4
+ const { license, version } = require("./package.json");
5
+
6
+ /**
7
+ * @type {{ mainDeveloper: string, version: string, license: string }}
8
+ */
9
+ const aboutApp = {
10
+ mainDeveloper: "omega5300",
11
+ license,
12
+ version
13
+ };
14
+
15
+ /**
16
+ * @typedef {Object} ideas
17
+ * @property {string} ideas.author
18
+ * @property {string} ideas.tool
19
+ */
20
+
21
+ /** @type {ideas[]} */
22
+ const ideas = [
23
+ { author: "verguiskarime", tool: "bitly info" }
24
+ ];
25
+
26
+ /** @type { string[] } */
27
+ const developers = [ "omega5300" ];
28
+
29
+ /**
30
+ * @typedef {Object} youtubeDev
31
+ * @property {string} youtubeDev.youtubeChannel
32
+ * @property {string} youtubeDev.recomendation
33
+ */
34
+
35
+ /** @type {youtubeDev[]} */
36
+ const youtubeDev = [
37
+ { youtubeChannel: "fazt", recomendation: "recommend" },
38
+ { youtubeChannel: "doriandesings", recomendation: "recommend" },
39
+ { youtubeChannel: "bluuweb", recomendation: "recommend" },
40
+ { youtubeChannel: "leonidas esteban", recomendation: "neutral recommend" },
41
+ { youtubeChannel: "fernando herrera", recomendation: "recommend" },
42
+ { youtubeChannel: "soy dalto", recomendation: "neutral recommend" },
43
+ ];
44
+
45
+ /** @type { string[] } */
46
+ const twitch = [ "dannyaegyo", "Lunanny" ];
47
+
48
+ /** @type { string[] } */
49
+ const projects = [ "Doofy's Projects" ];
50
+
51
+ export {
52
+ aboutApp,
53
+ developers,
54
+ youtubeDev,
55
+ twitch,
56
+ projects,
57
+ ideas
58
+ };
package/cli.js ADDED
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env node
2
+
3
+ // modules
4
+ import { performance } from "perf_hooks";
5
+ import inquirer from "inquirer";
6
+ import figlet from "figlet";
7
+ import colors from "colors";
8
+
9
+ // hash tables
10
+ import mainTools from "./hash/mainTools.js";
11
+ import hardwareTools from "./hash/hardwareTools.js";
12
+ import aboutTool from "./hash/aboutOpts.js";
13
+ import infoTools from "./hash/infoTools.js";
14
+
15
+ /**
16
+ * @description about menu
17
+ * @return { Promise<void> } about option sections answer
18
+ */
19
+ async function aboutOpts() {
20
+ const { about } = await inquirer.prompt({
21
+ type: "list",
22
+ pageSize: 9,
23
+ name: "about",
24
+ message: "select about option info",
25
+ choices: [
26
+ "main_info",
27
+ "lineup",
28
+ "youtube_recomendation",
29
+ "twitch_recomendation",
30
+ "projects_recomendation",
31
+ "tools_ideas",
32
+ "return to main menu"
33
+ ]
34
+ });
35
+
36
+ if (about !== "return to main menu") {
37
+ aboutTool[about]();
38
+ setTimeout(aboutOpts, 1000);
39
+ } else {
40
+ question();
41
+ }
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @description call the async function return list to question list
47
+ * @return { Promise<void> } - return in boolean a result question list
48
+ *
49
+ */
50
+ async function returnWebQuestion() {
51
+ try {
52
+ const anw = await inquirer.prompt([
53
+ {
54
+ type: "confirm",
55
+ name: "return",
56
+ message: "do you want go to the tools menu?",
57
+ }
58
+ ]);
59
+
60
+ if (anw.return) {
61
+ console.clear();
62
+ mainOptions();
63
+ } else {
64
+ question();
65
+ }
66
+ } catch (err) {
67
+ console.error(colors.red(err.message));
68
+ }
69
+ }
70
+
71
+ /**
72
+ *
73
+ * @description call the async function return list to question list
74
+ * @return { Promise<void> } - return in boolean a result question list
75
+ *
76
+ */
77
+ async function returnInfoQuestion() {
78
+ try {
79
+ const anw = await inquirer.prompt([
80
+ {
81
+ type: "confirm",
82
+ name: "return",
83
+ message: "do you want go to the tools menu?",
84
+ }
85
+ ]);
86
+
87
+ if (anw.return) {
88
+ console.clear();
89
+ infoOpts();
90
+ } else {
91
+ question();
92
+ }
93
+ } catch (err) {
94
+ console.error(colors.red(err.message));
95
+ }
96
+ }
97
+
98
+ /**
99
+ * @description call hardware information options
100
+ * @returns { Promise<void> } hardware options tool
101
+ */
102
+ async function hardwareOpts() {
103
+ const { hardware } = await inquirer.prompt({
104
+ type: "list",
105
+ name: "hardware",
106
+ pageSize: 9,
107
+ message: "select a hardware-information option:",
108
+ choices: [
109
+ "cpu",
110
+ "ram_memory",
111
+ "os",
112
+ "disk",
113
+ "controller",
114
+ "display",
115
+ "bios",
116
+ "exit to main menu"
117
+ ]
118
+ });
119
+
120
+ if(hardware !== "exit to main menu") {
121
+ hardwareTools[hardware]();
122
+ setTimeout(hardwareOpts, 1000);
123
+ } else {
124
+ question();
125
+ }
126
+ }
127
+
128
+ /**
129
+ *
130
+ * @description call the function question web tools options
131
+ * @returns { Promise<void> } return main tools options
132
+ *
133
+ */
134
+ async function mainOptions() {
135
+ const { main } = await inquirer.prompt({
136
+ type: "list",
137
+ pageSize: 9,
138
+ name: "main",
139
+ message: "",
140
+ choices: [
141
+ "single",
142
+ "multiple",
143
+ "pagespeed",
144
+ "return main menu"
145
+ ]
146
+ });
147
+
148
+ if (main !== "return main menu") {
149
+ mainTools[main]();
150
+ const timeEnd = performance.now();
151
+ setTimeout(returnWebQuestion, timeEnd);
152
+ } else {
153
+ question();
154
+ }
155
+ }
156
+
157
+ /**
158
+ *
159
+ * @description call the function question info tools options
160
+ * @returns { Promise<void> } return main tools options
161
+ *
162
+ */
163
+ async function infoOpts() {
164
+ const { info } = await inquirer.prompt({
165
+ type: "list",
166
+ pageSize: 9,
167
+ name: "info",
168
+ message: "enter a info tools option",
169
+ choices: [
170
+ "github_info",
171
+ "anime_search",
172
+ "crypto_market",
173
+ "bitly_info",
174
+ "movie_info",
175
+ "twitch_info",
176
+ "return main menu"
177
+ ]
178
+ });
179
+
180
+ if (info !== "return main menu") {
181
+ infoTools[info]();
182
+ const timeEnd = performance.now();
183
+ setTimeout(returnInfoQuestion, timeEnd);
184
+ } else {
185
+ question();
186
+ }
187
+ }
188
+
189
+
190
+ /**
191
+ *
192
+ * @description call the function question raw list options
193
+ * @returns { Promise<void> } return exit question
194
+ *
195
+ */
196
+ async function question() {
197
+ console.clear();
198
+ console.info(colors.yellow(figlet.textSync("stack-analyze")));
199
+ const { analyze } = await inquirer.prompt({
200
+ type: "list",
201
+ name: "analyze",
202
+ message: "what option do you want to analyze stack",
203
+ choices: ["web tools", "info tools", "hardware tools", "about", "exit"]
204
+ });
205
+
206
+ switch (analyze) {
207
+ case "web tools":
208
+ mainOptions();
209
+ break;
210
+ case "info tools":
211
+ infoOpts();
212
+ break;
213
+ case "hardware tools":
214
+ hardwareOpts();
215
+ break;
216
+ case "about":
217
+ aboutOpts();
218
+ break;
219
+ default:
220
+ console.clear();
221
+ console.info("thanks for use stack-analyze".green);
222
+ break;
223
+ }
224
+ }
225
+
226
+ // call the message title and question list
227
+ question();
228
+
@@ -0,0 +1 @@
1
+ process.env.BITLY_TOKEN = "efeac58916c768e4ae6ad22fe31b601361f71886";
@@ -0,0 +1 @@
1
+ process.env.MOVIE_CODE= "6bd534c04a4246666a68080da99bb105";
@@ -0,0 +1 @@
1
+ process.env.CLIENT_ID = "am096eog80r416605ka34uzq8b5614";
@@ -1,8 +1,8 @@
1
1
  // modules
2
- const axios = require("axios").default;
3
- const { format } = require("timeago.js");
4
- const { red } = require("colors");
5
- const { Table } = require("console-table-printer");
2
+ import axios from "axios";
3
+ import { format } from "timeago.js";
4
+ import colors from "colors";
5
+ import animeList from "../models/animeTable.js";
6
6
 
7
7
  /**
8
8
  *
@@ -22,36 +22,6 @@ const animeSearch = async (query) => {
22
22
  }
23
23
  });
24
24
 
25
- const animeList = new Table({
26
- columns: [
27
- {
28
- name: "title",
29
- alignment: "left",
30
- color: "green"
31
- },
32
- {
33
- name: "type",
34
- alignment: "left",
35
- color: "magenta"
36
- },
37
- {
38
- name: "episodes",
39
- alignment: "left",
40
- color: "magenta"
41
- },
42
- {
43
- name: "debutDate",
44
- alignment: "left",
45
- color: "magenta"
46
- },
47
- {
48
- name: "finalDate",
49
- alignment: "left",
50
- color: "green"
51
- }
52
- ]
53
- });
54
-
55
25
  const animeData = data.results.map(({
56
26
  title,
57
27
  episodes,
@@ -62,18 +32,18 @@ const animeSearch = async (query) => {
62
32
  type,
63
33
  episodes,
64
34
  debutDate: format(start_date),
65
- finalDate: end_date !== null
66
- ? format(end_date)
35
+ finalDate: end_date !== null
36
+ ? format(end_date)
67
37
  : "current date"
68
38
  }));
69
-
39
+
70
40
 
71
41
  animeList.addRows(animeData);
72
42
 
73
43
  animeList.printTable();
74
44
 
75
- } catch (err) { console.error(red(err.message)); }
45
+ } catch (err) { console.error(colors.red(err.message)); }
76
46
  };
77
47
 
78
48
  // exports module
79
- module.exports = animeSearch;
49
+ export default animeSearch;
@@ -1,17 +1,17 @@
1
1
  // modules
2
- const axios = require("axios").default;
3
- const { format } = require("timeago.js");
4
- const { red } = require("colors");
2
+ import "../env/bitly.env.js";
3
+ import axios from "axios";
4
+ import { format } from "timeago.js";
5
+ import colors from "colors";
5
6
 
6
7
  /**
7
8
  *
8
9
  * @description call the bitly info data
9
10
  * @param { string } link - link for search info
10
- * @param { string } token - token for using tool
11
11
  * @returns { Promise<void> } - return results serach
12
12
  *
13
13
  */
14
- const bitlyInfo = async (link, token) => {
14
+ const bitlyInfo = async (link) => {
15
15
  try {
16
16
  const { data, status } = await axios.post(
17
17
  "https://api-ssl.bitly.com/v4/expand",
@@ -20,7 +20,7 @@ const bitlyInfo = async (link, token) => {
20
20
  },
21
21
  {
22
22
  headers: {
23
- Authorization: `Bearer ${token}`,
23
+ Authorization: `Bearer ${process.env.BITLY_TOKEN}`,
24
24
  "Content-Type": "application/json"
25
25
  }
26
26
  }
@@ -34,10 +34,9 @@ const bitlyInfo = async (link, token) => {
34
34
  link: data.long_url
35
35
  });
36
36
  } catch (err) {
37
- console.error(red(err.message));
37
+ console.error(colors.red(err.message));
38
38
  }
39
39
  };
40
40
 
41
41
  // export
42
- module.exports = bitlyInfo;
43
-
42
+ export default bitlyInfo;
@@ -1,8 +1,9 @@
1
1
  // modules
2
- const CoinGecko = require("coingecko-api");
3
- const { format } = require("timeago.js");
4
- const { red, green } = require("colors");
5
- const { Table } = require("console-table-printer");
2
+ import CoinGecko from "coingecko-api";
3
+ import { format } from "timeago.js";
4
+ import colors from "colors";
5
+
6
+ import coinTable from "../models/cryptoTables.js";
6
7
 
7
8
  // init coingecko api
8
9
  const CoinGeckoClient = new CoinGecko();
@@ -32,49 +33,19 @@ const cryptoMarket = async () => {
32
33
  name,
33
34
  price: current_price,
34
35
  priceChanged: price_change_percentage_24h > 0
35
- ? green(price_change_percentage_24h)
36
- : red(price_change_percentage_24h),
36
+ ? colors.green(price_change_percentage_24h)
37
+ : colors.red(price_change_percentage_24h),
37
38
  lastUpdated: format(last_updated)
38
39
  }));
39
40
 
40
- // init table
41
- const coinTable = new Table({
42
- columns: [
43
- {
44
- name: "symbol",
45
- alignment: "left",
46
- color: "green"
47
- },
48
- {
49
- name: "name",
50
- alignment: "left",
51
- color: "white_bold"
52
- },
53
- {
54
- name: "price",
55
- alignment: "left",
56
- color: "yellow"
57
- },
58
- {
59
- name: "priceChanged",
60
- alignment: "left"
61
- },
62
- {
63
- name: "lastUpdated",
64
- alignment: "left",
65
- color: "magenta"
66
- }
67
- ]
68
- });
69
-
70
41
  coinTable.addRows(coinList);
71
42
 
72
43
  // print table
73
44
  coinTable.printTable();
74
45
  } catch (err) {
75
46
  // print err message
76
- console.error(red(err.message));
47
+ console.error(colors.red(err.message));
77
48
  }
78
49
  };
79
50
 
80
- module.exports = cryptoMarket;
51
+ export default cryptoMarket;
@@ -1,7 +1,7 @@
1
1
  // modules
2
- const axios = require("axios").default;
3
- const { format } = require("timeago.js");
4
- const { red, yellow } = require("colors");
2
+ import axios from "axios";
3
+ import { format } from "timeago.js";
4
+ import colors from "colors";
5
5
 
6
6
  /**
7
7
  *
@@ -10,7 +10,7 @@ const { red, yellow } = require("colors");
10
10
  * @returns { Promise<void> } - return results info
11
11
  *
12
12
  */
13
- async function githubInfo(user) {
13
+ export default async function githubInfo(user) {
14
14
  try {
15
15
  const res = await axios.get(`https://api.github.com/users/${user}`);
16
16
 
@@ -30,12 +30,9 @@ async function githubInfo(user) {
30
30
 
31
31
  console.table(info);
32
32
  } else {
33
- console.info(yellow(res.status.toString()));
33
+ console.info(colors.yellow(res.status.toString()));
34
34
  }
35
35
  } catch(err) {
36
- console.error(red(err.message));
36
+ console.error(colors.red(err.message));
37
37
  }
38
38
  }
39
-
40
- module.exports = githubInfo;
41
-
@@ -1,14 +1,18 @@
1
1
  // modules
2
- const {
3
- cpu,
4
- mem,
5
- osInfo,
6
- diskLayout,
7
- graphics,
8
- bios
9
- } = require("systeminformation");
10
- const { printTable } = require("console-table-printer");
11
- const { red } = require("colors");
2
+ import {
3
+ cpu,
4
+ mem,
5
+ osInfo,
6
+ diskLayout,
7
+ graphics,
8
+ bios
9
+ } from "systeminformation";
10
+ import colors from "colors";
11
+ import {
12
+ controllersTable,
13
+ diskTables,
14
+ displayTables
15
+ } from "../models/hardwareTables.js";
12
16
 
13
17
 
14
18
  /**
@@ -44,7 +48,7 @@ async function cpuInfo() {
44
48
  model
45
49
  });
46
50
  } catch (err) {
47
- console.error(red(err.message));
51
+ console.error(colors.red(err.message));
48
52
  }
49
53
  }
50
54
 
@@ -73,7 +77,7 @@ async function ramMemInfo() {
73
77
  available_mem: `${(available / 1073741824).toFixed(2)} GB`
74
78
  });
75
79
  } catch (err) {
76
- console.error(red(err.message));
80
+ console.error(colors.red(err.message));
77
81
  }
78
82
  }
79
83
 
@@ -108,7 +112,7 @@ async function osDetail() {
108
112
  uefi
109
113
  });
110
114
  } catch (err) {
111
- console.error(red(err.message));
115
+ console.error(colors.red(err.message));
112
116
  }
113
117
  }
114
118
 
@@ -135,11 +139,13 @@ async function diskInfo() {
135
139
  diskSize: `${(size / 1073741824).toFixed(2)} GB`,
136
140
  interfaceType
137
141
  }));
138
-
139
- printTable(disksList);
142
+
143
+ diskTables.addRows(disksList);
144
+
145
+ diskTables.printTable();
140
146
 
141
147
  } catch (err) {
142
- console.error(red(err.message));
148
+ console.error(colors.red(err.message));
143
149
  }
144
150
  }
145
151
 
@@ -160,15 +166,16 @@ async function controllerInfo() {
160
166
  }) => ({
161
167
  model,
162
168
  vendor,
163
- vramSize: vram < 1024
169
+ vramSize: vram < 1024
164
170
  ? `${vram} MB`
165
171
  : `${(vram / 1024).toFixed(2)} GB`
166
172
  }));
167
173
 
168
174
  // show results
169
- printTable(controllersList);
175
+ controllersTable.addRows(controllersList);
176
+ controllersTable.printTable();
170
177
  } catch (err) {
171
- console.error(red(err.message));
178
+ console.error(colors.red(err.message));
172
179
  }
173
180
  }
174
181
 
@@ -197,9 +204,10 @@ async function displayInfo() {
197
204
  }));
198
205
 
199
206
  // show results
200
- printTable(displayList);
207
+ displayTables.addRows(displayList);
208
+ displayTables.printTable();
201
209
  } catch (err) {
202
- console.error(red(err.message));
210
+ console.error(colors.red(err.message));
203
211
  }
204
212
  }
205
213
 
@@ -221,16 +229,16 @@ async function biosInfo() {
221
229
  console.table({
222
230
  releaseDate,
223
231
  vendor,
224
- bios_revision: revision === "" ? "no info": revision,
232
+ bios_revision: revision === "" ? "no info" : revision,
225
233
  version
226
234
  });
227
235
  } catch (err) {
228
- console.error(red(err.message));
236
+ console.error(colors.red(err.message));
229
237
  }
230
238
  }
231
239
 
232
240
  // exports modules
233
- module.exports = {
241
+ export {
234
242
  cpuInfo,
235
243
  ramMemInfo,
236
244
  osDetail,