stack-analyze 1.3.7 → 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/about.js CHANGED
@@ -1,16 +1,49 @@
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
+ const { default: { license, version } } = await import("./package.json", { with: { type: "json" } });
7
+
8
+ /**
9
+ * @typedef {Object} Info
10
+ * @property {string} Info.mainDeveloper
11
+ * @property {string} Info.version
12
+ * @property {string} Info.license
13
+ *
14
+ * @typedef {Object} DeveloperList
15
+ * @property {string} DeveloperList.name
16
+ * @property {string} DeveloperList.roles
17
+ *
18
+ * @typedef {Object} Youtube
19
+ * @property {string} Youtube.youtubeChannel
20
+ * @property {string} Youtube.recomendation
21
+ *
22
+ * @typedef {Object} Twitch
23
+ * @property {string} Twitch.user
24
+ * @property {string} [Twitch.details]
25
+ *
26
+ * @typedef {Object} Project
27
+ * @property {string} Project.name
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
37
+ */
38
+
6
39
 
7
40
  /** @type {number} */
8
41
  const timeout = 1e3;
9
42
 
10
- /** @type {import("./types.js").Select}*/
43
+ /** @type {Select}*/
11
44
  const aboutTool = {
12
45
  mainInfo(refreshCallback) {
13
- /** @type {import("./types.js").Info} */
46
+ /** @type {Info} */
14
47
  const aboutApp = {
15
48
  mainDeveloper: "omega5300",
16
49
  license,
@@ -19,13 +52,13 @@ const aboutTool = {
19
52
 
20
53
  console.clear();
21
54
  console.table(aboutApp);
22
-
55
+
23
56
  setTimeout(refreshCallback, timeout);
24
57
  },
25
58
  async lineup(refreshCallback) {
26
59
  const { listFormat } = await import("./utils.js");
27
-
28
- /** @type {import("./types.js").DeveloperList[]} */
60
+
61
+ /** @type {DeveloperList[]} */
29
62
  const developers = [
30
63
  {
31
64
  name: "omega5300",
@@ -38,7 +71,7 @@ const aboutTool = {
38
71
  setTimeout(refreshCallback, timeout);
39
72
  },
40
73
  youtubeRecomendation(refreshCallback) {
41
- /** @type {import("./types.js").Youtube[]} */
74
+ /** @type {Youtube[]} */
42
75
  const youtubeDev = [
43
76
  { youtubeChannel: "fazt", recomendation: "recommend" },
44
77
  { youtubeChannel: "doriandesings", recomendation: "recommend" },
@@ -52,8 +85,8 @@ const aboutTool = {
52
85
  printTable(youtubeDev);
53
86
  setTimeout(refreshCallback, timeout);
54
87
  },
55
- twitchRecomendation(refreshCallback) {
56
- /** @type {import("./types.js").Twitch[]} */
88
+ twitchRecomendation(refreshCallback) {
89
+ /** @type {Twitch[]} */
57
90
  const twitchUsers = [
58
91
  {
59
92
  user: "DannyAgii",
@@ -73,7 +106,7 @@ const aboutTool = {
73
106
  setTimeout(refreshCallback, timeout);
74
107
  },
75
108
  projectsRecomendation(refreshCallback) {
76
- /** @type {import("./types.js").Project[]} */
109
+ /** @type {Project[]} */
77
110
  const projects = [
78
111
  {
79
112
  name: "black metal promotion",
@@ -84,8 +117,8 @@ const aboutTool = {
84
117
  desc: "promos albums and community"
85
118
  },
86
119
  {
87
- name: "slithering black records",
88
- desc: "record label & community"
120
+ name: "slithering black records",
121
+ desc: "record label & community"
89
122
  }
90
123
  ];
91
124
 
@@ -95,4 +128,6 @@ const aboutTool = {
95
128
  }
96
129
  };
97
130
 
98
- export default aboutTool;
131
+ const menuAboutOpts = [...Object.keys(aboutTool), returnMainOpts];
132
+
133
+ export { aboutTool, menuAboutOpts };
package/cli.js CHANGED
@@ -1,33 +1,34 @@
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";
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
15
 
16
- import {
17
- menuOpts, menuQueryOpts, menuWebOpts, menuAboutOpts,
18
- menuInfoOpts, menuWallpaperOpts, menuUtilityOpts, menuQuoteOpts
19
- } from "./utils.js";
20
- import quoteSelect from "./hash/quotesSelect.js";
16
+ import { exitMsg } from "./utils.js";
17
+ import { quoteSelect, menuQuoteOpts } from "./hash/quotesSelect.js";
21
18
 
22
- const [gauge, totalTime, pageSize] = [new Gauge(), 1e4, 9];
19
+ const [spinner, totalTime, pageSize] = [
20
+ ora({spinner: "dots11", color: "white" }),
21
+ 1e4, 9
22
+ ];
23
23
 
24
24
  /** @returns {void} */
25
25
  const exitCli = () => {
26
26
  console.clear();
27
- console.info("thanks for use stack-analyze".green);
27
+ console.info(exitMsg);
28
28
  };
29
29
 
30
- /** @type {import('./types.js').Menu} */async function webOpts() {
30
+ /** @returns {Promise<void>} */
31
+ async function webOpts() {
31
32
  console.info(colors.yellow(figlet.textSync("web options")));
32
33
 
33
34
  const web = await stackMenu({
@@ -41,7 +42,7 @@ const exitCli = () => {
41
42
  : mainMenu();
42
43
  }
43
44
 
44
- /** @type {import('./types.js').Menu} */
45
+ /** @returns {Promise<void>} */
45
46
  async function infoOpts() {
46
47
  console.info(colors.yellow(figlet.textSync("info options")));
47
48
 
@@ -56,7 +57,7 @@ async function infoOpts() {
56
57
  : infoTools[info](returnMain);
57
58
  }
58
59
 
59
- /** @type {import('./types.js').Menu} */
60
+ /** @returns {Promise<void>} */
60
61
  async function queryOpts() {
61
62
  console.info(colors.yellow(figlet.textSync("query options")));
62
63
 
@@ -71,7 +72,7 @@ async function queryOpts() {
71
72
  : queryTools[query](returnMain);
72
73
  }
73
74
 
74
- /** @type {import('./types.js').Menu} */
75
+ /** @returns {Promise<void>} */
75
76
  async function wallpapersOpts() {
76
77
  console.info(colors.yellow(figlet.textSync("wallpapers")));
77
78
 
@@ -86,9 +87,9 @@ async function wallpapersOpts() {
86
87
  : wallpaperSelect[wallpaper](returnMain, wallpapersOpts);
87
88
  }
88
89
 
89
- /** @type {import('./types.js').Menu} */
90
+ /** @returns {Promise<void>} */
90
91
  async function quotesOpts() {
91
- console.info(colors.yellow(figlet.textSync("")));
92
+ console.info(colors.yellow(figlet.textSync("quotes")));
92
93
 
93
94
  const quotes = await stackMenu({
94
95
  pageSize,
@@ -101,7 +102,7 @@ async function quotesOpts() {
101
102
  : quoteSelect[quotes](returnMain);
102
103
  }
103
104
 
104
- /** @type {import('./types.js').Menu} */
105
+ /** @returns {Promise<void>} */
105
106
  async function utilityOpts() {
106
107
  console.info(colors.yellow(figlet.textSync("utility options")));
107
108
 
@@ -116,7 +117,7 @@ async function utilityOpts() {
116
117
  : utilityTools[utility](returnMain);
117
118
  }
118
119
 
119
- /** @type {import('./types.js').Menu} */
120
+ /** @returns {Promise<void>} */
120
121
  async function aboutOpts() {
121
122
  console.info(colors.yellow(figlet.textSync("About Menu")));
122
123
 
@@ -131,17 +132,11 @@ async function aboutOpts() {
131
132
  : mainMenu();
132
133
  }
133
134
 
134
- /** @type {import('./types.js').Menu} */
135
+ /** @returns {Promise<void>} */
135
136
  async function mainMenu() {
136
137
  console.clear();
137
138
  console.info(colors.yellow(figlet.textSync("stack-analyze")));
138
139
 
139
- const option = await stackMenu({
140
- message: "what option do you want to analyze stack",
141
- choices: menuOpts,
142
- pageSize: 10
143
- });
144
-
145
140
  const menuList = {
146
141
  web() {
147
142
  console.clear();
@@ -173,15 +168,21 @@ async function mainMenu() {
173
168
  }
174
169
  };
175
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
+
176
177
  option !== "exit" ? menuList[option]() : exitCli();
177
178
  }
178
179
 
179
- /** @type {import('./types.js').Menu} */
180
+ /** @returns {Promise<void>} */
180
181
  async function returnMain() {
181
182
  try {
182
183
  const returnMain = await confirm({
183
184
  message: "do you want go to the main menu?",
184
- });
185
+ }).catch();
185
186
 
186
187
  returnMain ? mainMenu() : exitCli();
187
188
  } catch (err) {
@@ -190,15 +191,17 @@ async function returnMain() {
190
191
  }
191
192
 
192
193
  for (let i = 50; i < totalTime; i += 50) {
193
- const percentage = i / totalTime;
194
+ const percentage = i / totalTime * 100;
194
195
 
195
196
  setTimeout(() => {
196
- gauge.pulse();
197
- 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();
198
201
  }, i);
199
202
  }
200
203
 
201
204
  setTimeout(() => {
202
- gauge.hide();
205
+ spinner.stop();
203
206
  mainMenu();
204
207
  }, totalTime);
@@ -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"
@@ -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) {
@@ -2,32 +2,18 @@ import axios from "axios";
2
2
  import colors from "colors";
3
3
 
4
4
  /**
5
- * @description get random quote from anime characters.
6
5
  * @async
7
- * @param {string} anime
8
6
  * @returns {Promise<void>}
9
7
  */
10
- async function getAnimeQuote(anime) {
8
+ async function getSwiftQuotes() {
11
9
  try {
12
- /** @type {import('axios').AxiosResponse<import('../types.js').AnimeQuoute>} */
13
- const { data } = await axios.get("https://api.animechan.io/v1/quotes/random", {
14
- params: { anime }
15
- });
10
+ const { data } = await axios.get("https://taylorswiftapi.onrender.com/get");
16
11
 
17
- const {
18
- content,
19
- anime: { altName: animeAltName, name: animeName },
20
- character: { name: characterName }
21
- } = data.data;
12
+ console.info(`"${data.quote}" \n album: ${data.album} song: ${data.song}`);
22
13
 
23
- console.info({
24
- content, animeAltName, animeName, characterName
25
- });
26
14
  } catch (err) {
27
- console.error(colors.red(/** @type {import('axios').AxiosError} */(err).message));
15
+ console.error(colors.red(err.message));
28
16
  }
29
17
  }
30
18
 
31
- export {
32
- getAnimeQuote
33
- };
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
 
13
- /** @type {import("../types.js").Select}*/
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}*/
14
25
  const infoTools = {
15
26
  async github_info(refreshCallback) {
16
27
  console.clear();
17
-
28
+
18
29
  const gitUser = await input({
19
- message: "enter a github user for search",
20
- required: true
30
+ message: "enter a github user for search",
31
+ required: true
21
32
  });
22
-
33
+
23
34
  githubInfo(gitUser);
24
35
  setTimeout(refreshCallback, 2e3);
25
36
  },
26
37
  async bitly_info(refreshCallback) {
27
38
  console.clear();
28
-
39
+
29
40
  const { bitlyLink, token } = {
30
- bitlyLink: await input({
31
- message: "enter a short link:",
32
- validate: input => bitlyRegexp.test(input) || "only bitly link".yellow
33
- }),
34
- token: await password({
35
- message: "enter a bitly token",
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
- /** @type {import("../types.js").Select}*/
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();
@@ -110,4 +121,6 @@ const queryTools = {
110
121
  }
111
122
  };
112
123
 
113
- export default queryTools;
124
+ const menuQueryOpts = [...Object.keys(queryTools), returnMainOpts];
125
+
126
+ export {queryTools, menuQueryOpts};
@@ -1,16 +1,25 @@
1
- import { input } from "@inquirer/prompts";
2
- import { getAnimeQuote } from "../functions/quotes.js";
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
+ * /
3
13
 
4
- /** @type {import("../types.js").Select}*/
14
+ /** @type {Select}*/
5
15
  const quoteSelect = {
6
- animeQuote: async (refreshCallback) => {
7
- const quote = await input({
8
- message: "enter a anime for get random quote: \u0022if press enter key get random\u0022:".yellow,
9
- });
10
-
11
- getAnimeQuote(quote);
16
+
17
+ swiftQuotes: (refreshCallback) => {
18
+ getSwiftQuotes();
12
19
  setTimeout(refreshCallback, 5000);
13
- },
20
+ }
14
21
  };
15
22
 
16
- export default quoteSelect;
23
+ const menuQuoteOpts = [...Object.keys(quoteSelect), returnMainOpts];
24
+
25
+ export {quoteSelect, menuQuoteOpts };
@@ -1,13 +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
- /** @type {import("../types.js").Select}*/
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}*/
11
21
  const utilityTools = {
12
22
  password(refreshCallback) {
13
23
  console.clear();
@@ -20,14 +30,16 @@ const utilityTools = {
20
30
  setTimeout(refreshCallback, 12e3);
21
31
  },
22
32
  async poker_game(refreshCallback) {
23
- const pokeOpt = await stackMenu({
24
- message: "select a poker game for view instructions:",
25
- choices: pokerGameOpts
26
- });
27
-
28
- pokerGame(pokeOpt);
29
- 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);
30
40
  }
31
41
  };
32
42
 
33
- export default utilityTools;
43
+ const menuUtilityOpts = [...Object.keys(utilityTools), returnMainOpts];
44
+
45
+ export { utilityTools, menuUtilityOpts };
@@ -2,11 +2,22 @@
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
 
9
- /** @type {import("../types.js").Select}*/
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 wallpaperSelect = {
11
22
  solMoon: async (refreshCallback, alternativeCallback) => {
12
23
  const solMoonWallpapers = [...Array(20).keys()]
@@ -87,4 +98,6 @@ const wallpaperSelect = {
87
98
  },
88
99
  };
89
100
 
90
- export default wallpaperSelect;
101
+ const menuWallpaperOpts = [...Object.keys(wallpaperSelect), returnMainOpts];
102
+
103
+ export {wallpaperSelect, menuWallpaperOpts};
package/hash/webTools.js CHANGED
@@ -12,12 +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
- /** @type {import("../types.js").Select}*/
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}*/
21
31
  const webTools = {
22
32
  async single(refreshCallback) {
23
33
  console.clear();
@@ -90,4 +100,6 @@ const webTools = {
90
100
  }
91
101
  };
92
102
 
93
- 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.7",
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",
@@ -16,8 +16,8 @@
16
16
  "colors": "^1.4.0",
17
17
  "console-table-printer": "^2.14.6",
18
18
  "figlet": "^1.8.1",
19
- "gauge": "^5.0.2",
20
19
  "inquirer": "^12.7.0",
20
+ "ora": "^8.2.0",
21
21
  "systeminformation": "^5.27.7",
22
22
  "timeago.js": "^4.0.2",
23
23
  "w3c-css-validator": "^1.4.0",
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,48 +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", "quotes",
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 menuQuoteOpts = ["animeQuote", returnMainOpts];
43
-
44
- const menuHardwareOpts = [
45
- "cpuInfo", "ramMemInfo", "osDetail", "diskInfo",
46
- "controllerInfo", "displayInfo", "biosInfo", returnMainOpts
47
- ];
48
-
49
- const menuAboutOpts = [
50
- "mainInfo", "lineup", "youtubeRecomendation",
51
- "twitchRecomendation", "projectsRecomendation", returnMainOpts
52
- ];
53
-
54
16
  const scrapingOpts = [
55
17
  "title", "images", "metadata", "headings",
56
18
  "tableHead", "tableData", "links", "cites"
@@ -62,7 +24,6 @@ const pokerGameOpts = [
62
24
  ];
63
25
 
64
26
  /**
65
- *
66
27
  * @param {string} filename
67
28
  * @param {any} data
68
29
  * @returns {Promise<void>}
@@ -78,19 +39,27 @@ const stackSave = async (filename, data) => {
78
39
  return;
79
40
  }
80
41
 
81
- try {
82
- await writeFile(filename, data);
42
+ try { await writeFile(filename, data);
83
43
  } catch (err) {
84
- console.info(err.message);
44
+ console.info(colors.red(err.message));
85
45
  }
86
46
  };
87
47
 
88
- 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
+ };
89
60
 
90
61
  export {
91
- listFormat, currency, menuOpts, menuWebOpts,
92
- menuInfoOpts, menuQueryOpts, menuUtilityOpts, menuHardwareOpts,
93
- menuWallpaperOpts, menuAboutOpts, scrapingOpts, menuQuoteOpts,
94
- stackSave, pokerGameOpts, exitCli
62
+ listFormat, currency, scrapingOpts, forceExit,
63
+ stackSave, pokerGameOpts, exitMsg, returnMainOpts
95
64
  };
96
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 };
package/types.js DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * general functions
3
- * @typedef {() => Promise<void>} Menu
4
- *
5
- * types for about tools
6
- *
7
- * @typedef {Object} Info
8
- * @property {string} Info.mainDeveloper
9
- * @property {string} Info.version
10
- * @property {string} Info.license
11
- *
12
- * @typedef {Object} DeveloperList
13
- * @property {string} DeveloperList.name
14
- * @property {string} DeveloperList.roles
15
- *
16
- * @typedef {Object} Youtube
17
- * @property {string} Youtube.youtubeChannel
18
- * @property {string} Youtube.recomendation
19
- *
20
- * @typedef {Object} Twitch
21
- * @property {string} Twitch.user
22
- * @property {string} [Twitch.details]
23
- *
24
- * @typedef {Object} Project
25
- * @property {string} Project.name
26
- * @property {string} Project.desc
27
- *
28
- * anime quote types
29
- * @typedef {Object} Anime
30
- * @property {number} id
31
- * @property {string} name
32
- * @property {string} altName
33
- *
34
- * @typedef {Object} Data
35
- * @property {string} content
36
- * @property {Anime} anime
37
- * @property {Omit<Anime, 'altName'>} character
38
- *
39
- * @typedef {Object} AnimeQuoute
40
- * @property {string} status
41
- * @property {Data} data
42
- *
43
- * select types
44
- * @typedef {({
45
- * [x: string]: (
46
- * refreshCallback: () => Promise<void>,
47
- * alternativeCallback?: () => Promise<void>
48
- * ) => Promise<void> | void
49
- * })} Select
50
- *
51
- */