stack-analyze 1.3.4 → 1.3.6

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/cli.js CHANGED
@@ -1,227 +1,213 @@
1
- #!/usr/bin/env node
2
- import Gauge from "gauge";
3
- import colors from "colors";
4
- import inquirer from "inquirer";
5
- import figlet from "figlet";
6
-
7
- import webTools from "./hash/webTools.js";
8
- import queryTools from "./hash/queryTools.js";
9
- import infoTools from "./hash/infoTools.js";
10
- import utilityTools from "./hash/utilityTools.js";
11
- import wallpaperSelect from "./hash/wallpaperSelect.js";
12
- import aboutTool from "./about.cjs";
13
-
14
- import {
15
- menuOpts,
16
- menuQueryOpts,
17
- menuWebOpts,
18
- menuAboutOpts,
19
- menuInfoOpts,
20
- menuWallpaperOpts,
21
- menuUtilityOpts
22
- } from "./utils.js";
23
-
24
- const [gauge, totalTime, pageSize] = [new Gauge(), 1e4, 9];
25
-
26
- /** @returns {void} */
27
- const exitCli = () => {
28
- console.clear();
29
- console.info("thanks for use stack-analyze".green);
30
- };
31
-
32
- /**
33
- * @async
34
- * @returns {Promise<void>}
35
- */
36
- async function webOpts() {
37
- console.info(colors.yellow(figlet.textSync("web options")));
38
-
39
- const { web } = await inquirer.prompt({
40
- type: "list",
41
- pageSize,
42
- name: "web",
43
- message: "enter a web tool option",
44
- choices: menuWebOpts
45
- });
46
-
47
- web !== "return main menu"
48
- ? webTools[web](returnMain)
49
- : mainMenu();
50
- }
51
-
52
- /**
53
- * @async
54
- * @returns {Promise<void>}
55
- */
56
- async function infoOpts() {
57
- console.info(colors.yellow(figlet.textSync("info options")));
58
-
59
- const { info } = await inquirer.prompt({
60
- type: "list",
61
- pageSize,
62
- name: "info",
63
- message: "enter a info tool option",
64
- choices: menuInfoOpts
65
- });
66
-
67
- info === "return main menu"
68
- ? mainMenu()
69
- : infoTools[info](returnMain);
70
- }
71
-
72
- /**
73
- * @async
74
- * @returns {Promise<void>}
75
- */
76
- async function queryOpts() {
77
- console.info(colors.yellow(figlet.textSync("query options")));
78
-
79
- const { query } = await inquirer.prompt({
80
- type: "list",
81
- pageSize,
82
- name: "query",
83
- message: "enter a query tool option",
84
- choices: menuQueryOpts
85
- });
86
-
87
- query === "return main menu"
88
- ? mainMenu()
89
- : queryTools[query](returnMain);
90
- }
91
-
92
- /**
93
- * @async
94
- * @returns {void}
95
- */
96
- async function wallpapersOpts() {
97
- console.info(colors.yellow(figlet.textSync("wallpapers")));
98
-
99
- const { wallpaper } = await inquirer.prompt({
100
- type: "list",
101
- pageSize,
102
- name: "wallpaper",
103
- message: "enter a wallpaper selector",
104
- choices: menuWallpaperOpts
105
- });
106
-
107
- wallpaper === "return main menu"
108
- ? mainMenu()
109
- : wallpaperSelect[wallpaper](returnMain, wallpapersOpts);
110
- }
111
-
112
- /**
113
- * @async
114
- * @returns {Promise<void>}
115
- */
116
- async function utilityOpts() {
117
- console.info(colors.yellow(figlet.textSync("utility options")));
118
-
119
- const { utility } = await inquirer.prompt({
120
- type: "list",
121
- pageSize,
122
- name: "utility",
123
- message: "enter a utility tool option",
124
- choices: menuUtilityOpts
125
- });
126
-
127
- utility === "return main menu"
128
- ? mainMenu()
129
- : utilityTools[utility](returnMain);
130
- }
131
-
132
- /**
133
- * @async
134
- * @returns {Promise<void>}
135
- */
136
- async function aboutOpts() {
137
- console.info(colors.yellow(figlet.textSync("About Menu")));
138
-
139
- const { about } = await inquirer.prompt({
140
- type: "list",
141
- pageSize,
142
- name: "about",
143
- message: "select about option info",
144
- choices: menuAboutOpts
145
- });
146
-
147
- about !== "return main menu"
148
- ? aboutTool[about](aboutOpts)
149
- : mainMenu();
150
- }
151
-
152
- /**
153
- * @async
154
- * @returns {Promise<void>}
155
- */
156
- async function mainMenu() {
157
- console.clear();
158
- console.info(colors.yellow(figlet.textSync("stack-analyze")));
159
-
160
- const { option } = await inquirer.prompt({
161
- type: "list",
162
- name: "option",
163
- message: "what option do you want to analyze stack",
164
- choices: menuOpts
165
- });
166
-
167
- const menuList = {
168
- web() {
169
- console.clear();
170
- webOpts();
171
- },
172
- info() {
173
- console.clear();
174
- infoOpts();
175
- },
176
- query() {
177
- console.clear();
178
- queryOpts();
179
- },
180
- utility() {
181
- console.clear();
182
- utilityOpts();
183
- },
184
- wallpapers() {
185
- console.clear();
186
- wallpapersOpts();
187
- },
188
- about() {
189
- console.clear();
190
- aboutOpts();
191
- }
192
- };
193
-
194
- option !== "exit" ? menuList[option]() : exitCli();
195
- }
196
-
197
- /**
198
- * @async
199
- * @returns {Promise<void>}
200
- */
201
- async function returnMain() {
202
- try {
203
- const { returnMain } = await inquirer.prompt({
204
- type: "confirm",
205
- name: "returnMain",
206
- message: "do you want go to the main menu?",
207
- });
208
-
209
- returnMain ? mainMenu() : exitCli();
210
- } catch (err) {
211
- console.error(colors.bgRed(err.message));
212
- }
213
- }
214
-
215
- for (let i = 50; i < totalTime; i += 50) {
216
- const percentage = i / totalTime;
217
-
218
- setTimeout(() => {
219
- gauge.pulse();
220
- gauge.show(`Loading app... ${percentage * 100}%`.random, percentage);
221
- }, i);
222
- }
223
-
224
- setTimeout(() => {
225
- gauge.hide();
226
- mainMenu();
227
- }, totalTime);
1
+ #!/usr/bin/env node
2
+ import Gauge from "gauge";
3
+ import colors from "colors";
4
+ import { confirm } from "@inquirer/prompts";
5
+ import figlet from "figlet";
6
+
7
+ import { stackMenu } from "./menu.js";
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];
27
+
28
+ /** @returns {void} */
29
+ const exitCli = () => {
30
+ console.clear();
31
+ console.info("thanks for use stack-analyze".green);
32
+ };
33
+
34
+ /**
35
+ * @async
36
+ * @returns {Promise<void>}
37
+ */
38
+ async function webOpts() {
39
+ console.info(colors.yellow(figlet.textSync("web options")));
40
+
41
+ const web = await stackMenu({
42
+ pageSize,
43
+ message: "enter a web tool option",
44
+ choices: menuWebOpts
45
+ });
46
+
47
+ web !== "return main menu"
48
+ ? webTools[web](returnMain)
49
+ : mainMenu();
50
+ }
51
+
52
+ /**
53
+ * @async
54
+ * @returns {Promise<void>}
55
+ */
56
+ async function infoOpts() {
57
+ console.info(colors.yellow(figlet.textSync("info options")));
58
+
59
+ const info = await stackMenu({
60
+ pageSize,
61
+ message: "enter a info tool option",
62
+ choices: menuInfoOpts
63
+ });
64
+
65
+ info === "return main menu"
66
+ ? mainMenu()
67
+ : infoTools[info](returnMain);
68
+ }
69
+
70
+ /**
71
+ * @async
72
+ * @returns {Promise<void>}
73
+ */
74
+ async function queryOpts() {
75
+ console.info(colors.yellow(figlet.textSync("query options")));
76
+
77
+ const query = await stackMenu({
78
+ pageSize,
79
+ message: "enter a query tool option",
80
+ choices: menuQueryOpts
81
+ });
82
+
83
+ query === "return main menu"
84
+ ? mainMenu()
85
+ : queryTools[query](returnMain);
86
+ }
87
+
88
+ /**
89
+ * @async
90
+ * @returns {Promise<void>}
91
+ */
92
+ async function wallpapersOpts() {
93
+ console.info(colors.yellow(figlet.textSync("wallpapers")));
94
+
95
+ const wallpaper = await stackMenu({
96
+ pageSize,
97
+ message: "enter a wallpaper selector",
98
+ choices: menuWallpaperOpts
99
+ });
100
+
101
+ wallpaper === "return main menu"
102
+ ? mainMenu()
103
+ : wallpaperSelect[wallpaper](returnMain, wallpapersOpts);
104
+ }
105
+
106
+ /**
107
+ * @async
108
+ * @returns {Promise<void>}
109
+ */
110
+ async function utilityOpts() {
111
+ console.info(colors.yellow(figlet.textSync("utility options")));
112
+
113
+ const utility = await stackMenu({
114
+ pageSize,
115
+ message: "enter a utility tool option",
116
+ choices: menuUtilityOpts
117
+ });
118
+
119
+ utility === "return main menu"
120
+ ? mainMenu()
121
+ : utilityTools[utility](returnMain);
122
+ }
123
+
124
+ /**
125
+ * @async
126
+ * @returns {Promise<void>}
127
+ */
128
+ async function aboutOpts() {
129
+ console.info(colors.yellow(figlet.textSync("About Menu")));
130
+
131
+ const about = await stackMenu({
132
+ pageSize,
133
+ message: "select about option info",
134
+ choices: menuAboutOpts
135
+ });
136
+
137
+ about !== "return main menu"
138
+ ? aboutTool[about](aboutOpts)
139
+ : mainMenu();
140
+ }
141
+
142
+ /**
143
+ * @async
144
+ * @returns {Promise<void>}
145
+ */
146
+ async function mainMenu() {
147
+ console.clear();
148
+ console.info(colors.yellow(figlet.textSync("stack-analyze")));
149
+
150
+ const option = await stackMenu({
151
+ message: "what option do you want to analyze stack",
152
+ choices: menuOpts
153
+ });
154
+
155
+ const menuList = {
156
+ web() {
157
+ console.clear();
158
+ webOpts();
159
+ },
160
+ info() {
161
+ console.clear();
162
+ infoOpts();
163
+ },
164
+ query() {
165
+ console.clear();
166
+ queryOpts();
167
+ },
168
+ utility() {
169
+ console.clear();
170
+ utilityOpts();
171
+ },
172
+ wallpapers() {
173
+ console.clear();
174
+ wallpapersOpts();
175
+ },
176
+ about() {
177
+ console.clear();
178
+ aboutOpts();
179
+ }
180
+ };
181
+
182
+ option !== "exit" ? menuList[option]() : exitCli();
183
+ }
184
+
185
+ /**
186
+ * @async
187
+ * @returns {Promise<void>}
188
+ */
189
+ async function returnMain() {
190
+ try {
191
+ const returnMain = await confirm({
192
+ message: "do you want go to the main menu?",
193
+ });
194
+
195
+ returnMain ? mainMenu() : exitCli();
196
+ } catch (err) {
197
+ console.error(colors.bgRed(err.message));
198
+ }
199
+ }
200
+
201
+ for (let i = 50; i < totalTime; i += 50) {
202
+ const percentage = i / totalTime;
203
+
204
+ setTimeout(() => {
205
+ gauge.pulse();
206
+ gauge.show(`Loading app... ${percentage * 100}%`.random, percentage);
207
+ }, i);
208
+ }
209
+
210
+ setTimeout(() => {
211
+ gauge.hide();
212
+ mainMenu();
213
+ }, totalTime);
package/eslint.config.js CHANGED
@@ -1,44 +1,44 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import globals from "globals";
4
- import js from "@eslint/js";
5
- import { FlatCompat } from "@eslint/eslintrc";
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
- const compat = new FlatCompat({
10
- baseDirectory: __dirname,
11
- recommendedConfig: js.configs.recommended,
12
- allConfig: js.configs.all
13
- });
14
-
15
- export default [{
16
- ignores: ["node_modules", "test", "docs", "eslint.config.js"],
17
- }, ...compat.extends("eslint:recommended"), {
18
- languageOptions: {
19
- globals: {
20
- ...globals.commonjs,
21
- ...globals.node,
22
- },
23
- ecmaVersion: "latest",
24
- sourceType: "module",
25
- },
26
-
27
- rules: {
28
- "no-var": "error",
29
- eqeqeq: "warn",
30
- "default-case": "error",
31
- "eol-last": "error",
32
- "spaced-comment": "error",
33
- "comma-spacing": "error",
34
- quotes: "error",
35
- "block-spacing": "error",
36
- "prefer-const": "error",
37
-
38
- indent: ["error", 2, {
39
- SwitchCase: 1,
40
- }],
41
-
42
- semi: "error",
43
- },
44
- }];
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import globals from "globals";
4
+ import js from "@eslint/js";
5
+ import { FlatCompat } from "@eslint/eslintrc";
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+ const compat = new FlatCompat({
10
+ baseDirectory: __dirname,
11
+ recommendedConfig: js.configs.recommended,
12
+ allConfig: js.configs.all
13
+ });
14
+
15
+ export default [{
16
+ ignores: ["node_modules", "test", "docs", "eslint.config.js"],
17
+ }, ...compat.extends("eslint:recommended"), {
18
+ languageOptions: {
19
+ globals: {
20
+ ...globals.commonjs,
21
+ ...globals.node,
22
+ },
23
+ ecmaVersion: "latest",
24
+ sourceType: "module",
25
+ },
26
+
27
+ rules: {
28
+ "no-var": "error",
29
+ eqeqeq: "warn",
30
+ "default-case": "error",
31
+ "eol-last": "error",
32
+ "spaced-comment": "error",
33
+ "comma-spacing": "error",
34
+ quotes: "error",
35
+ "block-spacing": "error",
36
+ "prefer-const": "error",
37
+
38
+ indent: ["error", 2, {
39
+ SwitchCase: 1,
40
+ }],
41
+
42
+ semi: "error",
43
+ },
44
+ }];
@@ -1,45 +1,45 @@
1
- // modules
2
- import axios from "axios";
3
- import { format } from "timeago.js";
4
- import colors from "colors";
5
- import { printTable } from "console-table-printer";
6
-
7
- // save anime
8
- import { stackSave } from "../utils.js";
9
-
10
- /**
11
- *
12
- * @description call the anime serach info
13
- * @async
14
- * @param { string } q - get query results
15
- * @returns { Promise<void> } - return results serach
16
- *
17
- */
18
- export default async function animeSearch(q) {
19
- try {
20
- // call api
21
- const { data } = await axios.get("https://api.jikan.moe/v4/anime", {
22
- params: { q }
23
- });
24
-
25
- const animeData = data.data.map(({
26
- title,
27
- episodes,
28
- aired,
29
- status,
30
- type }) => ({
31
- title,
32
- type,
33
- totalEpisodes: episodes || "current",
34
- debutDate: format(aired.from),
35
- finalDate: aired?.to
36
- ? format(aired.to)
37
- : status
38
- }));
39
-
40
-
41
- printTable(animeData.slice(0, 10));
42
-
43
- stackSave(`${q}-results.json`, JSON.stringify(animeData, null, 2));
44
- } catch (err) { console.error(colors.red(err.message)); }
45
- }
1
+ // modules
2
+ import axios from "axios";
3
+ import { format } from "timeago.js";
4
+ import colors from "colors";
5
+ import { printTable } from "console-table-printer";
6
+
7
+ // save anime
8
+ import { stackSave } from "../utils.js";
9
+
10
+ /**
11
+ *
12
+ * @description call the anime serach info
13
+ * @async
14
+ * @param { string } q - get query results
15
+ * @returns { Promise<void> } - return results serach
16
+ *
17
+ */
18
+ export default async function animeSearch(q) {
19
+ try {
20
+ // call api
21
+ const { data } = await axios.get("https://api.jikan.moe/v4/anime", {
22
+ params: { q }
23
+ });
24
+
25
+ const animeData = data.data.map(({
26
+ title,
27
+ episodes,
28
+ aired,
29
+ status,
30
+ type }) => ({
31
+ title,
32
+ type,
33
+ totalEpisodes: episodes || "current",
34
+ debutDate: format(aired.from),
35
+ finalDate: aired?.to
36
+ ? format(aired.to)
37
+ : status
38
+ }));
39
+
40
+
41
+ printTable(animeData.slice(0, 10));
42
+
43
+ stackSave(`${q}-results.json`, JSON.stringify(animeData, null, 2));
44
+ } catch (err) { console.error(colors.red(err.message)); }
45
+ }