stack-analyze 1.3.6 → 1.3.8

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
@@ -4,6 +4,15 @@ stack-analyze all version and notable changes, fixed, remove and new additions i
4
4
 
5
5
  ## generation 4 (ver. 1.3.0 - )
6
6
 
7
+ ### version 1.3.7
8
+
9
+ #### Added
10
+ - quotes new tool
11
+
12
+ #### Changed
13
+ - some files using new types jsdocs via import
14
+ - cpuinfo using separetd of cache
15
+
7
16
  ### version 1.3.6 (5th aniversary)
8
17
 
9
18
  #### Added
package/about.js CHANGED
@@ -1,14 +1,11 @@
1
1
  // print table
2
2
  import { printTable } from "console-table-printer";
3
+ import { returnMainOpts } from "./utils.js";
3
4
 
4
5
  // package.json
5
- const { default: { license, version}} = await import("./package.json", {with: {type: "json" }});
6
-
7
- const timeout = 1e3;
6
+ const { default: { license, version } } = await import("./package.json", { with: { type: "json" } });
8
7
 
9
8
  /**
10
- * types for about tools
11
- *
12
9
  * @typedef {Object} Info
13
10
  * @property {string} Info.mainDeveloper
14
11
  * @property {string} Info.version
@@ -29,8 +26,21 @@ const timeout = 1e3;
29
26
  * @typedef {Object} Project
30
27
  * @property {string} Project.name
31
28
  * @property {string} Project.desc
29
+ *
30
+ * select types
31
+ * @typedef {({
32
+ * [x: string]: (
33
+ * refreshCallback: () => Promise<void>,
34
+ * alternativeCallback?: () => Promise<void>
35
+ * ) => Promise<void> | void
36
+ * })} Select
32
37
  */
33
38
 
39
+
40
+ /** @type {number} */
41
+ const timeout = 1e3;
42
+
43
+ /** @type {Select}*/
34
44
  const aboutTool = {
35
45
  mainInfo(refreshCallback) {
36
46
  /** @type {Info} */
@@ -42,12 +52,12 @@ const aboutTool = {
42
52
 
43
53
  console.clear();
44
54
  console.table(aboutApp);
45
-
55
+
46
56
  setTimeout(refreshCallback, timeout);
47
57
  },
48
58
  async lineup(refreshCallback) {
49
59
  const { listFormat } = await import("./utils.js");
50
-
60
+
51
61
  /** @type {DeveloperList[]} */
52
62
  const developers = [
53
63
  {
@@ -75,7 +85,7 @@ const aboutTool = {
75
85
  printTable(youtubeDev);
76
86
  setTimeout(refreshCallback, timeout);
77
87
  },
78
- twitchRecomendation(refreshCallback) {
88
+ twitchRecomendation(refreshCallback) {
79
89
  /** @type {Twitch[]} */
80
90
  const twitchUsers = [
81
91
  {
@@ -107,8 +117,8 @@ const aboutTool = {
107
117
  desc: "promos albums and community"
108
118
  },
109
119
  {
110
- name: "slithering black records",
111
- desc: "record label & community"
120
+ name: "slithering black records",
121
+ desc: "record label & community"
112
122
  }
113
123
  ];
114
124
 
@@ -118,4 +128,6 @@ const aboutTool = {
118
128
  }
119
129
  };
120
130
 
121
- export default aboutTool;
131
+ const menuAboutOpts = [...Object.keys(aboutTool), returnMainOpts];
132
+
133
+ export { aboutTool, menuAboutOpts };
package/cli.js CHANGED
@@ -1,43 +1,36 @@
1
1
  #!/usr/bin/env node
2
- import Gauge from "gauge";
2
+ import ora from "ora";
3
3
  import colors from "colors";
4
4
  import { confirm } from "@inquirer/prompts";
5
5
  import figlet from "figlet";
6
6
 
7
7
  import { stackMenu } from "./menu.js";
8
8
 
9
- import webTools from "./hash/webTools.js";
10
- import queryTools from "./hash/queryTools.js";
11
- import infoTools from "./hash/infoTools.js";
12
- import utilityTools from "./hash/utilityTools.js";
13
- import wallpaperSelect from "./hash/wallpaperSelect.js";
14
- import aboutTool from "./about.js";
15
-
16
- import {
17
- menuOpts,
18
- menuQueryOpts,
19
- menuWebOpts,
20
- menuAboutOpts,
21
- menuInfoOpts,
22
- menuWallpaperOpts,
23
- menuUtilityOpts
24
- } from "./utils.js";
25
-
26
- const [gauge, totalTime, pageSize] = [new Gauge(), 1e4, 9];
9
+ import {menuWebOpts, webTools} from "./hash/webTools.js";
10
+ import {menuQueryOpts, queryTools} from "./hash/queryTools.js";
11
+ import {infoTools, menuInfoOpts} from "./hash/infoTools.js";
12
+ import {menuUtilityOpts, utilityTools} from "./hash/utilityTools.js";
13
+ import {menuWallpaperOpts, wallpaperSelect} from "./hash/wallpaperSelect.js";
14
+ import {aboutTool, menuAboutOpts} from "./about.js";
15
+
16
+ import { exitMsg } from "./utils.js";
17
+ import { quoteSelect, menuQuoteOpts } from "./hash/quotesSelect.js";
18
+
19
+ const [spinner, totalTime, pageSize] = [
20
+ ora({spinner: "dots11", color: "white" }),
21
+ 1e4, 9
22
+ ];
27
23
 
28
24
  /** @returns {void} */
29
25
  const exitCli = () => {
30
26
  console.clear();
31
- console.info("thanks for use stack-analyze".green);
27
+ console.info(exitMsg);
32
28
  };
33
29
 
34
- /**
35
- * @async
36
- * @returns {Promise<void>}
37
- */
30
+ /** @returns {Promise<void>} */
38
31
  async function webOpts() {
39
32
  console.info(colors.yellow(figlet.textSync("web options")));
40
-
33
+
41
34
  const web = await stackMenu({
42
35
  pageSize,
43
36
  message: "enter a web tool option",
@@ -49,13 +42,10 @@ async function webOpts() {
49
42
  : mainMenu();
50
43
  }
51
44
 
52
- /**
53
- * @async
54
- * @returns {Promise<void>}
55
- */
45
+ /** @returns {Promise<void>} */
56
46
  async function infoOpts() {
57
47
  console.info(colors.yellow(figlet.textSync("info options")));
58
-
48
+
59
49
  const info = await stackMenu({
60
50
  pageSize,
61
51
  message: "enter a info tool option",
@@ -67,13 +57,10 @@ async function infoOpts() {
67
57
  : infoTools[info](returnMain);
68
58
  }
69
59
 
70
- /**
71
- * @async
72
- * @returns {Promise<void>}
73
- */
60
+ /** @returns {Promise<void>} */
74
61
  async function queryOpts() {
75
62
  console.info(colors.yellow(figlet.textSync("query options")));
76
-
63
+
77
64
  const query = await stackMenu({
78
65
  pageSize,
79
66
  message: "enter a query tool option",
@@ -85,31 +72,40 @@ async function queryOpts() {
85
72
  : queryTools[query](returnMain);
86
73
  }
87
74
 
88
- /**
89
- * @async
90
- * @returns {Promise<void>}
91
- */
75
+ /** @returns {Promise<void>} */
92
76
  async function wallpapersOpts() {
93
77
  console.info(colors.yellow(figlet.textSync("wallpapers")));
94
-
78
+
95
79
  const wallpaper = await stackMenu({
96
80
  pageSize,
97
81
  message: "enter a wallpaper selector",
98
82
  choices: menuWallpaperOpts
99
83
  });
100
-
84
+
101
85
  wallpaper === "return main menu"
102
86
  ? mainMenu()
103
87
  : wallpaperSelect[wallpaper](returnMain, wallpapersOpts);
104
88
  }
105
89
 
106
- /**
107
- * @async
108
- * @returns {Promise<void>}
109
- */
90
+ /** @returns {Promise<void>} */
91
+ async function quotesOpts() {
92
+ console.info(colors.yellow(figlet.textSync("quotes")));
93
+
94
+ const quotes = await stackMenu({
95
+ pageSize,
96
+ choices: menuQuoteOpts,
97
+ message: "enter a quote option"
98
+ });
99
+
100
+ quotes === "return main menu"
101
+ ? mainMenu()
102
+ : quoteSelect[quotes](returnMain);
103
+ }
104
+
105
+ /** @returns {Promise<void>} */
110
106
  async function utilityOpts() {
111
107
  console.info(colors.yellow(figlet.textSync("utility options")));
112
-
108
+
113
109
  const utility = await stackMenu({
114
110
  pageSize,
115
111
  message: "enter a utility tool option",
@@ -121,13 +117,10 @@ async function utilityOpts() {
121
117
  : utilityTools[utility](returnMain);
122
118
  }
123
119
 
124
- /**
125
- * @async
126
- * @returns {Promise<void>}
127
- */
120
+ /** @returns {Promise<void>} */
128
121
  async function aboutOpts() {
129
122
  console.info(colors.yellow(figlet.textSync("About Menu")));
130
-
123
+
131
124
  const about = await stackMenu({
132
125
  pageSize,
133
126
  message: "select about option info",
@@ -139,19 +132,11 @@ async function aboutOpts() {
139
132
  : mainMenu();
140
133
  }
141
134
 
142
- /**
143
- * @async
144
- * @returns {Promise<void>}
145
- */
135
+ /** @returns {Promise<void>} */
146
136
  async function mainMenu() {
147
137
  console.clear();
148
138
  console.info(colors.yellow(figlet.textSync("stack-analyze")));
149
139
 
150
- const option = await stackMenu({
151
- message: "what option do you want to analyze stack",
152
- choices: menuOpts
153
- });
154
-
155
140
  const menuList = {
156
141
  web() {
157
142
  console.clear();
@@ -173,24 +158,31 @@ async function mainMenu() {
173
158
  console.clear();
174
159
  wallpapersOpts();
175
160
  },
161
+ quotes() {
162
+ console.clear();
163
+ quotesOpts();
164
+ },
176
165
  about() {
177
166
  console.clear();
178
167
  aboutOpts();
179
168
  }
180
169
  };
181
170
 
171
+ const option = await stackMenu({
172
+ message: "what option do you want to analyze stack",
173
+ choices: [...Object.keys(menuList), "exit"],
174
+ pageSize: 10
175
+ });
176
+
182
177
  option !== "exit" ? menuList[option]() : exitCli();
183
178
  }
184
179
 
185
- /**
186
- * @async
187
- * @returns {Promise<void>}
188
- */
180
+ /** @returns {Promise<void>} */
189
181
  async function returnMain() {
190
182
  try {
191
183
  const returnMain = await confirm({
192
184
  message: "do you want go to the main menu?",
193
- });
185
+ }).catch();
194
186
 
195
187
  returnMain ? mainMenu() : exitCli();
196
188
  } catch (err) {
@@ -199,15 +191,17 @@ async function returnMain() {
199
191
  }
200
192
 
201
193
  for (let i = 50; i < totalTime; i += 50) {
202
- const percentage = i / totalTime;
194
+ const percentage = i / totalTime * 100;
203
195
 
204
196
  setTimeout(() => {
205
- gauge.pulse();
206
- gauge.show(`Loading app... ${percentage * 100}%`.random, percentage);
197
+ /* gauge.pulse();
198
+ gauge.show(`Loading app... ${percentage * 100}%`.random, percentage); */
199
+ spinner.text = `Loading app... ${Math.ceil(percentage)}%`.random;
200
+ spinner.start();
207
201
  }, i);
208
202
  }
209
203
 
210
204
  setTimeout(() => {
211
- gauge.hide();
205
+ spinner.stop();
212
206
  mainMenu();
213
207
  }, totalTime);
@@ -9,7 +9,7 @@ import { stackSave } from "../utils.js";
9
9
 
10
10
  /**
11
11
  *
12
- * @description call the anime serach info
12
+ * @description call the anime serach info.
13
13
  * @async
14
14
  * @param { string } q - get query results
15
15
  * @returns { Promise<void> } - return results serach
@@ -7,7 +7,7 @@ import { stackSave } from "../utils.js";
7
7
 
8
8
  /**
9
9
  * @async
10
- * @params { string } query
10
+ * @param {string} q
11
11
  * @returns {Promise<void>}
12
12
  */
13
13
  export default async function deezer(q) {
@@ -20,9 +20,8 @@ export default async function deezer(q) {
20
20
  id, title, record_type,
21
21
  explicit_lyrics, artist, nb_tracks
22
22
  }) => ({
23
- id,
23
+ id, title,
24
24
  artist: artist.name,
25
- title,
26
25
  type: record_type,
27
26
  num_tracks: nb_tracks,
28
27
  lyrics_content: explicit_lyrics ? "explicit" : "clean"
@@ -37,15 +37,15 @@ export default async function hardware() {
37
37
  hardwareinfo.write(csvData(biosInfo, "\n\n"));
38
38
 
39
39
  // cpu info
40
- const cpuInfo = await cpu();
41
-
42
- cpuInfo.cache = Object.entries(cpuInfo.cache)
43
- .map(([key, value]) => `${key}: ${value}`)
44
- .join(" ");
40
+ const { cache: cpuCache, ...cpuInfo } = await cpu();
45
41
 
46
42
  hardwareinfo.write(csvHeader(cpuInfo));
47
43
  hardwareinfo.write(csvData(cpuInfo, "\n\n"));
48
44
 
45
+ hardwareinfo.write("cpu cache\n");
46
+ hardwareinfo.write(csvHeader(cpuCache));
47
+ hardwareinfo.write(csvData(cpuCache, "\n\n"));
48
+
49
49
  // os info
50
50
  const os = await osInfo();
51
51
 
@@ -25,16 +25,12 @@ export default async function movieDB(query, token) {
25
25
 
26
26
  const movieData = data.results
27
27
  .map(({
28
- title,
29
- original_language,
30
- popularity,
31
- vote_average,
28
+ title, original_language,
29
+ popularity, vote_average,
32
30
  release_date
33
31
  }) => ({
34
- title,
35
- original_language,
36
- popularity,
37
- vote_average,
32
+ title, original_language,
33
+ popularity, vote_average,
38
34
  release_date
39
35
  }))
40
36
  .sort((x, y) => {
@@ -6,6 +6,7 @@ import CliProgress from "cli-progress";
6
6
  // utils
7
7
  import { listFormat, stackSave } from "../utils.js";
8
8
 
9
+ /** @type {Object<string, number>} */
9
10
  const pokeStats = {
10
11
  hp: 255,
11
12
  attack: 194,
@@ -17,7 +18,7 @@ const pokeStats = {
17
18
  };
18
19
 
19
20
  /**
20
- * @param {string}
21
+ * @param {string} stat
21
22
  * @returns {string}
22
23
  */
23
24
  const barColor = stat => {
@@ -27,7 +28,7 @@ const barColor = stat => {
27
28
  case "attack":
28
29
  return "{bar}".yellow;
29
30
  case "defense":
30
- return "{bar}".brightYellow;
31
+ return "{bar}".white;
31
32
  case "special-attack":
32
33
  return "{bar}".blue;
33
34
  case "special-defense":
@@ -61,22 +62,13 @@ export default async function pokemonInfo(pokemon) {
61
62
  ).json();
62
63
 
63
64
  const {
64
- id,
65
- name,
66
- height,
67
- base_experience,
68
- weight,
69
- stats,
70
- types
65
+ id, name, height, base_experience, weight,
66
+ stats, types
71
67
  } = data;
72
68
 
73
69
  const info = {
74
- id,
75
- name,
76
- height,
77
- base_experience,
78
- weight,
79
- types: listFormat.format(types.map(({ type }) => type.name)),
70
+ id, name, height, base_experience,
71
+ weight, types: listFormat.format(types.map(({ type }) => type.name)),
80
72
  };
81
73
 
82
74
  const PokeInfo = boxen(info.types, {title: `${id} - ${name}`});
@@ -6,7 +6,7 @@ import { stackSave } from "../utils.js";
6
6
 
7
7
  /**
8
8
  * @typedef {"go-fish"|"gin-rummy"|"blackjack"|"slapjack"|"basics-of-poker"|"texas-holdem-poker"} Options
9
- * @params {Options} game
9
+ * @param {Options} game
10
10
  * @returns {Promise<void>}
11
11
  */
12
12
  export default async function pokerGame(game) {
@@ -0,0 +1,19 @@
1
+ import axios from "axios";
2
+ import colors from "colors";
3
+
4
+ /**
5
+ * @async
6
+ * @returns {Promise<void>}
7
+ */
8
+ async function getSwiftQuotes() {
9
+ try {
10
+ const { data } = await axios.get("https://taylorswiftapi.onrender.com/get");
11
+
12
+ console.info(`"${data.quote}" \n album: ${data.album} song: ${data.song}`);
13
+
14
+ } catch (err) {
15
+ console.error(colors.red(err.message));
16
+ }
17
+ }
18
+
19
+ export { getSwiftQuotes };
package/hash/infoTools.js CHANGED
@@ -6,37 +6,48 @@ import bitlyInfo from "../functions/bitly.js";
6
6
  import cryptoMarket from "../functions/cryptoList.js";
7
7
  import githubInfo from "../functions/gitUser.js";
8
8
  import bundlephobia from "../functions/bundlephobia.js";
9
+ import { returnMainOpts } from "../utils.js";
9
10
 
10
11
  // bitly regexp
11
12
  const bitlyRegexp = /bit\.ly\//g;
12
13
 
14
+ /**
15
+ * select types
16
+ * @typedef {({
17
+ * [x: string]: (
18
+ * refreshCallback: () => Promise<void>,
19
+ * alternativeCallback?: () => Promise<void>
20
+ * ) => Promise<void> | void
21
+ * })} Select
22
+ * /
23
+
24
+ /** @type {Select}*/
13
25
  const infoTools = {
14
26
  async github_info(refreshCallback) {
15
27
  console.clear();
16
-
28
+
17
29
  const gitUser = await input({
18
- message: "enter a github user for search",
19
- required: true
30
+ message: "enter a github user for search",
31
+ required: true
20
32
  });
21
-
33
+
22
34
  githubInfo(gitUser);
23
35
  setTimeout(refreshCallback, 2e3);
24
36
  },
25
37
  async bitly_info(refreshCallback) {
26
38
  console.clear();
27
-
39
+
28
40
  const { bitlyLink, token } = {
29
- bitlyLink: await input({
30
- message: "enter a short link:",
31
- validate: input => bitlyRegexp.test(input) || "only bitly link".yellow
32
- }),
33
- token: await password({
34
- message: "enter a bitly token",
35
- required: true,
36
- mask: true
37
- })
41
+ bitlyLink: await input({
42
+ message: "enter a short link:",
43
+ validate: input => bitlyRegexp.test(input) || "only bitly link".yellow
44
+ }),
45
+ token: await password({
46
+ message: "enter a bitly token",
47
+ mask: true
48
+ })
38
49
  };
39
-
50
+
40
51
  bitlyInfo(bitlyLink, token);
41
52
  setTimeout(refreshCallback, 2e3);
42
53
  },
@@ -47,15 +58,17 @@ const infoTools = {
47
58
  },
48
59
  async bundlephobia_info(refreshCallback) {
49
60
  console.clear();
50
-
61
+
51
62
  const pkgName = await input({
52
- message: "enter a npm package name for search info size"
63
+ message: "enter a npm package name for search info size"
53
64
  });
54
-
65
+
55
66
  console.info(pkgName);
56
67
  bundlephobia(pkgName);
57
68
  setTimeout(refreshCallback, 5e3);
58
69
  },
59
70
  };
60
71
 
61
- export default infoTools;
72
+ const menuInfoOpts = [...Object.keys(infoTools), returnMainOpts];
73
+
74
+ export { infoTools, menuInfoOpts };
@@ -8,8 +8,19 @@ import pokemonInfo from "../functions/pokemon.js";
8
8
  import twitchInfo from "../functions/twitch.js";
9
9
  import deezer from "../functions/deezer.js";
10
10
  import potterSearch from "../functions/potterSearch.js";
11
+ import { returnMainOpts } from "../utils.js";
11
12
 
12
- /** query tools */
13
+ /**
14
+ * select types
15
+ * @typedef {({
16
+ * [x: string]: (
17
+ * refreshCallback: () => Promise<void>,
18
+ * alternativeCallback?: () => Promise<void>
19
+ * ) => Promise<void> | void
20
+ * })} Select
21
+ * /
22
+
23
+ /** @type {Select}*/
13
24
  const queryTools = {
14
25
  async anime_Search(refreshCallback) {
15
26
  console.clear();
@@ -32,7 +43,6 @@ const queryTools = {
32
43
  }),
33
44
  token: await password({
34
45
  message: "enter a token key",
35
- required: true,
36
46
  mask: true
37
47
  })
38
48
  };
@@ -76,12 +86,10 @@ const queryTools = {
76
86
  }),
77
87
  twitchClient: await password({
78
88
  message: "enter a twitch client ID:",
79
- required: true,
80
89
  mask: true
81
90
  }),
82
91
  twitchToken: await password({
83
92
  message: "enter a twitch token:",
84
- required: true,
85
93
  mask: true
86
94
  })
87
95
  };
@@ -113,4 +121,6 @@ const queryTools = {
113
121
  }
114
122
  };
115
123
 
116
- export default queryTools;
124
+ const menuQueryOpts = [...Object.keys(queryTools), returnMainOpts];
125
+
126
+ export {queryTools, menuQueryOpts};
@@ -0,0 +1,25 @@
1
+ // import { input } from "@inquirer/prompts";
2
+ import { getSwiftQuotes } from "../functions/quotes.js";
3
+ import { returnMainOpts } from "../utils.js";
4
+ /**
5
+ * select types
6
+ * @typedef {({
7
+ * [x: string]: (
8
+ * refreshCallback: () => Promise<void>,
9
+ * alternativeCallback?: () => Promise<void>
10
+ * ) => Promise<void> | void
11
+ * })} Select
12
+ * /
13
+
14
+ /** @type {Select}*/
15
+ const quoteSelect = {
16
+
17
+ swiftQuotes: (refreshCallback) => {
18
+ getSwiftQuotes();
19
+ setTimeout(refreshCallback, 5000);
20
+ }
21
+ };
22
+
23
+ const menuQuoteOpts = [...Object.keys(quoteSelect), returnMainOpts];
24
+
25
+ export {quoteSelect, menuQuoteOpts };
@@ -1,12 +1,23 @@
1
1
  // menu
2
2
  import { stackMenu } from "../menu.js";
3
- import { pokerGameOpts } from "../utils.js";
3
+ import { pokerGameOpts, returnMainOpts } from "../utils.js";
4
4
 
5
5
  // functions
6
6
  import genPassword from "../functions/password.js";
7
7
  import hardware from "../functions/hardware.js";
8
8
  import pokerGame from "../functions/poker.js";
9
9
 
10
+ /**
11
+ * select types
12
+ * @typedef {({
13
+ * [x: string]: (
14
+ * refreshCallback: () => Promise<void>,
15
+ * alternativeCallback?: () => Promise<void>
16
+ * ) => Promise<void> | void
17
+ * })} Select
18
+ * /
19
+
20
+ /** @type {Select}*/
10
21
  const utilityTools = {
11
22
  password(refreshCallback) {
12
23
  console.clear();
@@ -16,17 +27,19 @@ const utilityTools = {
16
27
  async hardware(refreshCallback) {
17
28
  console.clear();
18
29
  hardware();
19
- setTimeout(refreshCallback, 3e3);
30
+ setTimeout(refreshCallback, 12e3);
20
31
  },
21
32
  async poker_game(refreshCallback) {
22
- const pokeOpt = await stackMenu({
23
- message: "select a poker game for view instructions:",
24
- choices: pokerGameOpts
25
- });
26
-
27
- pokerGame(pokeOpt);
28
- setTimeout(refreshCallback, 5e3);
33
+ const pokeOpt = await stackMenu({
34
+ message: "select a poker game for view instructions:",
35
+ choices: pokerGameOpts
36
+ });
37
+
38
+ pokerGame(pokeOpt);
39
+ setTimeout(refreshCallback, 5e3);
29
40
  }
30
41
  };
31
42
 
32
- export default utilityTools;
43
+ const menuUtilityOpts = [...Object.keys(utilityTools), returnMainOpts];
44
+
45
+ export { utilityTools, menuUtilityOpts };
@@ -2,12 +2,24 @@
2
2
  import { select } from "@inquirer/prompts";
3
3
 
4
4
  import { wallpaperDownload } from "../functions/download.js";
5
+ import { returnMainOpts } from "../utils.js";
5
6
 
6
7
  const message = "select a wallpaper for download:";
7
8
  const backMenu = "back to menu";
8
9
 
10
+ /**
11
+ * select types
12
+ * @typedef {({
13
+ * [x: string]: (
14
+ * refreshCallback: () => Promise<void>,
15
+ * alternativeCallback?: () => Promise<void>
16
+ * ) => Promise<void> | void
17
+ * })} Select
18
+ * /
19
+
20
+ /** @type {Select}*/
9
21
  const wallpaperSelect = {
10
- async solMoon(refreshCallback, alternativeCallback) {
22
+ solMoon: async (refreshCallback, alternativeCallback) => {
11
23
  const solMoonWallpapers = [...Array(20).keys()]
12
24
  .map(i => `sol-moon${i + 1}.jpeg`);
13
25
 
@@ -23,7 +35,7 @@ const wallpaperSelect = {
23
35
  setTimeout(refreshCallback, 5000);
24
36
  }
25
37
  },
26
- async dimensions(refreshCallback, alternativeCallback) {
38
+ dimensions: async (refreshCallback, alternativeCallback) => {
27
39
  const dimensionsWallpapers = [...Array(12).keys()]
28
40
  .map(i => `dimensions-${i + 1}.jpeg`);
29
41
 
@@ -39,7 +51,7 @@ const wallpaperSelect = {
39
51
  setTimeout(refreshCallback, 5000);
40
52
  }
41
53
  },
42
- async seyyahi2(refreshCallback, alternativeCallback) {
54
+ seyyahi2: async (refreshCallback, alternativeCallback) => {
43
55
  const seyyahiWallpapers = [...Array(14).keys()]
44
56
  .map(i => `seyyahi2-wallpaper${i + 1}.jpg`);
45
57
 
@@ -54,7 +66,7 @@ const wallpaperSelect = {
54
66
  setTimeout(refreshCallback, 5000);
55
67
  }
56
68
  },
57
- async ancientMistery(refreshCallback, alternativeCallback) {
69
+ ancientMistery: async (refreshCallback, alternativeCallback) => {
58
70
  const ancientMisteryWallpapers = [...Array(6).keys()]
59
71
  .map(i => `ancient-mistery${i + 1}.jpeg`);
60
72
 
@@ -69,7 +81,7 @@ const wallpaperSelect = {
69
81
  setTimeout(refreshCallback, 5000);
70
82
  }
71
83
  },
72
- async tsukyNoEmily(refreshCallback, alternativeCallback) {
84
+ tsukyNoEmily: async (refreshCallback, alternativeCallback) => {
73
85
  const tsukyNoEmilyWallpapers = [...Array(6).keys()]
74
86
  .map(i => `tsuky-no-emily${i + 1}.jpeg`);
75
87
 
@@ -86,4 +98,6 @@ const wallpaperSelect = {
86
98
  },
87
99
  };
88
100
 
89
- export default wallpaperSelect;
101
+ const menuWallpaperOpts = [...Object.keys(wallpaperSelect), returnMainOpts];
102
+
103
+ export {wallpaperSelect, menuWallpaperOpts};
package/hash/webTools.js CHANGED
@@ -12,11 +12,22 @@ import scrape from "../functions/scraping.js";
12
12
  import cssValidate from "../functions/cssValidator.js";
13
13
 
14
14
  import { stackMenu } from "../menu.js";
15
- import { scrapingOpts } from "../utils.js";
15
+ import { returnMainOpts, scrapingOpts } from "../utils.js";
16
16
 
17
17
  // regex
18
18
  const webRegex = /https?:\/\//g;
19
19
 
20
+ /**
21
+ * select types
22
+ * @typedef {({
23
+ * [x: string]: (
24
+ * refreshCallback: () => Promise<void>,
25
+ * alternativeCallback?: () => Promise<void>
26
+ * ) => Promise<void> | void
27
+ * })} Select
28
+ * /
29
+
30
+ /** @type {Select}*/
20
31
  const webTools = {
21
32
  async single(refreshCallback) {
22
33
  console.clear();
@@ -89,4 +100,6 @@ const webTools = {
89
100
  }
90
101
  };
91
102
 
92
- export default webTools;
103
+ const menuWebOpts = [...Object.keys(webTools), returnMainOpts];
104
+
105
+ export {webTools, menuWebOpts};
package/menu.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import { select } from "@inquirer/prompts";
2
+ import { forceExit } from "./utils.js";
2
3
 
3
4
  /**
4
5
  * @typedef {Object} Menu
5
6
  * @property {string} message
6
7
  * @property {string[]} choices
7
8
  * @property {number} [pageSize]
8
- * @param {Menu}
9
+ *
10
+ * @param {Menu} menu
11
+ * @async
9
12
  * @returns {Promise<any>}
10
13
  */
11
14
  export const stackMenu = async ({message, choices, pageSize}) => await select({
12
15
  message, choices, pageSize
13
- });
16
+ }).catch(forceExit);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stack-analyze",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "type": "module",
5
5
  "description": "cli tech stack analyze and pagespeed with node.js using the wappalyzer module. with google pagespeed api, hardware and crypto market",
6
6
  "main": "cli.js",
@@ -8,25 +8,25 @@
8
8
  "stack-analyze": "cli.js"
9
9
  },
10
10
  "dependencies": {
11
- "@inquirer/prompts": "^7.3.2",
12
- "axios": "^1.7.7",
11
+ "@inquirer/prompts": "^7.6.0",
12
+ "axios": "^1.10.0",
13
13
  "boxen": "^8.0.1",
14
- "cheerio": "^1.0.0",
14
+ "cheerio": "^1.1.0",
15
15
  "cli-progress": "^3.12.0",
16
16
  "colors": "^1.4.0",
17
- "console-table-printer": "^2.12.1",
18
- "figlet": "^1.8.0",
19
- "gauge": "^5.0.2",
20
- "inquirer": "^12.0.1",
21
- "systeminformation": "^5.23.5",
17
+ "console-table-printer": "^2.14.6",
18
+ "figlet": "^1.8.1",
19
+ "inquirer": "^12.7.0",
20
+ "ora": "^8.2.0",
21
+ "systeminformation": "^5.27.7",
22
22
  "timeago.js": "^4.0.2",
23
- "w3c-css-validator": "^1.3.2",
23
+ "w3c-css-validator": "^1.4.0",
24
24
  "wapalyzer": "^6.10.65"
25
25
  },
26
26
  "devDependencies": {
27
- "@eslint/js": "^9.14.0",
28
- "eslint": "^9.14.0",
29
- "globals": "^15.12.0",
27
+ "@eslint/js": "^9.30.1",
28
+ "eslint": "^9.30.1",
29
+ "globals": "^16.3.0",
30
30
  "jsdoc": "^4.0.4"
31
31
  },
32
32
  "scripts": {
package/utils.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { writeFile } from "node:fs/promises";
2
+ import colors from "colors";
2
3
 
3
4
  const listFormat = new Intl.ListFormat("en", {
4
5
  style: "short",
@@ -9,46 +10,9 @@ const currency = new Intl.NumberFormat("en-us", {
9
10
  style: "currency", currency: "USD"
10
11
  });
11
12
 
13
+ /** @type {string} */
12
14
  const returnMainOpts = "return main menu";
13
15
 
14
- const menuOpts = [
15
- "web", "info", "query", "utility", "wallpapers",
16
- "about", "exit"
17
- ];
18
-
19
- const menuWebOpts = [
20
- "single", "multiple", "pagespeed", "scraping", "css_validate",
21
- returnMainOpts
22
- ];
23
-
24
- const menuInfoOpts = [
25
- "github_info", "crypto_market", "bitly_info", "bundlephobia_info", returnMainOpts
26
- ];
27
-
28
- const menuQueryOpts = [
29
- "anime_Search", "movie_info", "pokemon_info",
30
- "twitch_info", "deezer", "potter_search", returnMainOpts
31
- ];
32
-
33
- const menuUtilityOpts = [
34
- "hardware", "password", "poker_game", returnMainOpts
35
- ];
36
-
37
- const menuWallpaperOpts = [
38
- "solMoon", "dimensions", "seyyahi2", "ancientMistery",
39
- "tsukyNoEmily", returnMainOpts
40
- ];
41
-
42
- const menuHardwareOpts = [
43
- "cpuInfo", "ramMemInfo", "osDetail", "diskInfo",
44
- "controllerInfo", "displayInfo", "biosInfo", returnMainOpts
45
- ];
46
-
47
- const menuAboutOpts = [
48
- "mainInfo", "lineup", "youtubeRecomendation",
49
- "twitchRecomendation", "projectsRecomendation", returnMainOpts
50
- ];
51
-
52
16
  const scrapingOpts = [
53
17
  "title", "images", "metadata", "headings",
54
18
  "tableHead", "tableData", "links", "cites"
@@ -60,7 +24,6 @@ const pokerGameOpts = [
60
24
  ];
61
25
 
62
26
  /**
63
- *
64
27
  * @param {string} filename
65
28
  * @param {any} data
66
29
  * @returns {Promise<void>}
@@ -76,29 +39,27 @@ const stackSave = async (filename, data) => {
76
39
  return;
77
40
  }
78
41
 
79
- try {
80
- await writeFile(filename, data);
42
+ try { await writeFile(filename, data);
81
43
  } catch (err) {
82
- console.info(err.message);
44
+ console.info(colors.red(err.message));
83
45
  }
84
46
  };
85
47
 
86
- const exitCli = "thanks for use stack-analyze";
48
+ const exitMsg = "thanks for use stack-analyze".green;
49
+
50
+ /**
51
+ * @param {Error} err
52
+ * @returns {void}
53
+ */
54
+ const forceExit = (err) => {
55
+ if(err.name === "ExitPromptError") {
56
+ console.info("👋 until next time!".green);
57
+ process.exit(1);
58
+ }
59
+ };
87
60
 
88
61
  export {
89
- listFormat,
90
- currency,
91
- menuOpts,
92
- menuWebOpts,
93
- menuInfoOpts,
94
- menuQueryOpts,
95
- menuUtilityOpts,
96
- menuHardwareOpts,
97
- menuWallpaperOpts,
98
- menuAboutOpts,
99
- scrapingOpts,
100
- stackSave,
101
- pokerGameOpts,
102
- exitCli
62
+ listFormat, currency, scrapingOpts, forceExit,
63
+ stackSave, pokerGameOpts, exitMsg, returnMainOpts
103
64
  };
104
65
 
@@ -29,9 +29,4 @@ const promptKey = (name, message) => ({
29
29
  validate: input => input !== "" || "token field is required".yellow
30
30
  });
31
31
 
32
- export {
33
- bitlyQuery,
34
- promptParams,
35
- promptKey
36
- };
37
-
32
+ export { bitlyQuery, promptParams, promptKey };
@@ -26,8 +26,4 @@ const webScrapingQuery = {
26
26
  choices: scrapingOpts
27
27
  };
28
28
 
29
- export {
30
- singleWebQuery,
31
- multipleWebQuery,
32
- webScrapingQuery
33
- };
29
+ export { singleWebQuery, multipleWebQuery, webScrapingQuery };