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/CHANGELOG.md +326 -296
- package/LICENSE +21 -21
- package/{about.cjs → about.js} +121 -121
- package/api/pokerApi.js +5 -0
- package/api/wallpapersURL.js +7 -6
- package/api/webApis.js +21 -21
- package/cli.js +213 -227
- package/eslint.config.js +44 -44
- package/functions/animeInfo.js +45 -45
- package/functions/bitly.js +41 -41
- package/functions/bundlephobia.js +36 -36
- package/functions/cryptoList.js +48 -48
- package/functions/cssValidator.js +25 -25
- package/functions/deezer.js +37 -37
- package/functions/download.js +25 -24
- package/functions/gitUser.js +37 -37
- package/functions/hardware.js +109 -109
- package/functions/moviesInfo.js +55 -55
- package/functions/multipleStack.js +53 -53
- package/functions/pageSpeed.js +82 -82
- package/functions/password.js +24 -24
- package/functions/pokemon.js +106 -106
- package/functions/poker.js +40 -0
- package/functions/potterSearch.js +32 -32
- package/functions/scraping.js +132 -132
- package/functions/singleStack.js +48 -48
- package/functions/twitch.js +72 -72
- package/hash/infoTools.js +61 -57
- package/hash/queryTools.js +116 -119
- package/hash/utilityTools.js +32 -19
- package/hash/wallpaperSelect.js +89 -76
- package/hash/webTools.js +92 -68
- package/logo-module.webp +0 -0
- package/menu.js +13 -0
- package/package.json +67 -66
- package/prompts/webPrompts.js +31 -0
- package/readme.md +44 -44
- package/utils.js +104 -94
- package/validations/infoValidations.js +37 -37
- package/validations/webValidations.js +33 -33
package/functions/hardware.js
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
// modules
|
|
2
|
-
import { createWriteStream } from "node:fs";
|
|
3
|
-
import {
|
|
4
|
-
cpu,
|
|
5
|
-
mem,
|
|
6
|
-
osInfo,
|
|
7
|
-
diskLayout,
|
|
8
|
-
graphics,
|
|
9
|
-
bios
|
|
10
|
-
} from "systeminformation";
|
|
11
|
-
import colors from "colors";
|
|
12
|
-
|
|
13
|
-
const csvHeader = (obj) => `${Object.keys(obj).join(";")}\n`;
|
|
14
|
-
const csvData = (obj, spaces) => `${Object.values(obj).join(";")}${spaces}`;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {number} size
|
|
19
|
-
* @param {number} [base = 1073741824]
|
|
20
|
-
* @returns {string}
|
|
21
|
-
*/
|
|
22
|
-
const gigabyteConvert = (size, base = 1073741824) => (size / base).toFixed(2);
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @async
|
|
27
|
-
* @returns {Promise<void>}
|
|
28
|
-
*/
|
|
29
|
-
export default async function hardware() {
|
|
30
|
-
try {
|
|
31
|
-
const hardwareinfo = createWriteStream("hardware.csv");
|
|
32
|
-
|
|
33
|
-
// bios info
|
|
34
|
-
const biosInfo = await bios();
|
|
35
|
-
|
|
36
|
-
hardwareinfo.write(csvHeader(biosInfo));
|
|
37
|
-
hardwareinfo.write(csvData(biosInfo, "\n\n"));
|
|
38
|
-
|
|
39
|
-
// cpu info
|
|
40
|
-
const cpuInfo = await cpu();
|
|
41
|
-
|
|
42
|
-
cpuInfo.cache = Object.entries(cpuInfo.cache)
|
|
43
|
-
.map(([key, value]) => `${key}: ${value}`)
|
|
44
|
-
.join(" ");
|
|
45
|
-
|
|
46
|
-
hardwareinfo.write(csvHeader(cpuInfo));
|
|
47
|
-
hardwareinfo.write(csvData(cpuInfo, "\n\n"));
|
|
48
|
-
|
|
49
|
-
// os info
|
|
50
|
-
const os = await osInfo();
|
|
51
|
-
|
|
52
|
-
hardwareinfo.write(csvHeader(os));
|
|
53
|
-
hardwareinfo.write(csvData(os, "\n\n"));
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// ram memory info
|
|
57
|
-
const ram = await mem();
|
|
58
|
-
|
|
59
|
-
for (const key in ram) {
|
|
60
|
-
ram[key] = `${gigabyteConvert(ram[key])} GB`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
hardwareinfo.write(csvHeader(ram));
|
|
64
|
-
hardwareinfo.write(csvData(ram, "\n\n"));
|
|
65
|
-
|
|
66
|
-
// disks
|
|
67
|
-
const disks = await diskLayout();
|
|
68
|
-
|
|
69
|
-
disks.forEach(disk => {
|
|
70
|
-
for (const key in disk) {
|
|
71
|
-
if (typeof disk[key] === "number") {
|
|
72
|
-
disk[key] = `${gigabyteConvert(disk[key])} GB`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
hardwareinfo.write(csvHeader(disk));
|
|
77
|
-
hardwareinfo.write(csvData(disk, "\n\n"));
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
/* displays & controllers */
|
|
81
|
-
const { displays, controllers } = await graphics();
|
|
82
|
-
|
|
83
|
-
// controllers
|
|
84
|
-
controllers.forEach(controller => {
|
|
85
|
-
for (const key in controller) {
|
|
86
|
-
if (typeof controller[key] === "number") {
|
|
87
|
-
controller[key] = controller[key] < 1024
|
|
88
|
-
? `${controller[key]} MB`
|
|
89
|
-
: `${gigabyteConvert(controller[key])} GB`;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
hardwareinfo.write(csvHeader(controller));
|
|
94
|
-
hardwareinfo.write(csvData(controller, "\n"));
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
hardwareinfo.write("\n");
|
|
98
|
-
|
|
99
|
-
displays.forEach(display => {
|
|
100
|
-
hardwareinfo.write(csvHeader(display));
|
|
101
|
-
hardwareinfo.write(csvData(display, "\n"));
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// finish
|
|
105
|
-
console.info("finish the hardware information file");
|
|
106
|
-
} catch (err) {
|
|
107
|
-
console.error(colors.red(err.message));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
1
|
+
// modules
|
|
2
|
+
import { createWriteStream } from "node:fs";
|
|
3
|
+
import {
|
|
4
|
+
cpu,
|
|
5
|
+
mem,
|
|
6
|
+
osInfo,
|
|
7
|
+
diskLayout,
|
|
8
|
+
graphics,
|
|
9
|
+
bios
|
|
10
|
+
} from "systeminformation";
|
|
11
|
+
import colors from "colors";
|
|
12
|
+
|
|
13
|
+
const csvHeader = (obj) => `${Object.keys(obj).join(";")}\n`;
|
|
14
|
+
const csvData = (obj, spaces) => `${Object.values(obj).join(";")}${spaces}`;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {number} size
|
|
19
|
+
* @param {number} [base = 1073741824]
|
|
20
|
+
* @returns {string}
|
|
21
|
+
*/
|
|
22
|
+
const gigabyteConvert = (size, base = 1073741824) => (size / base).toFixed(2);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @async
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
export default async function hardware() {
|
|
30
|
+
try {
|
|
31
|
+
const hardwareinfo = createWriteStream("hardware.csv");
|
|
32
|
+
|
|
33
|
+
// bios info
|
|
34
|
+
const biosInfo = await bios();
|
|
35
|
+
|
|
36
|
+
hardwareinfo.write(csvHeader(biosInfo));
|
|
37
|
+
hardwareinfo.write(csvData(biosInfo, "\n\n"));
|
|
38
|
+
|
|
39
|
+
// cpu info
|
|
40
|
+
const cpuInfo = await cpu();
|
|
41
|
+
|
|
42
|
+
cpuInfo.cache = Object.entries(cpuInfo.cache)
|
|
43
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
44
|
+
.join(" ");
|
|
45
|
+
|
|
46
|
+
hardwareinfo.write(csvHeader(cpuInfo));
|
|
47
|
+
hardwareinfo.write(csvData(cpuInfo, "\n\n"));
|
|
48
|
+
|
|
49
|
+
// os info
|
|
50
|
+
const os = await osInfo();
|
|
51
|
+
|
|
52
|
+
hardwareinfo.write(csvHeader(os));
|
|
53
|
+
hardwareinfo.write(csvData(os, "\n\n"));
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// ram memory info
|
|
57
|
+
const ram = await mem();
|
|
58
|
+
|
|
59
|
+
for (const key in ram) {
|
|
60
|
+
ram[key] = `${gigabyteConvert(ram[key])} GB`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
hardwareinfo.write(csvHeader(ram));
|
|
64
|
+
hardwareinfo.write(csvData(ram, "\n\n"));
|
|
65
|
+
|
|
66
|
+
// disks
|
|
67
|
+
const disks = await diskLayout();
|
|
68
|
+
|
|
69
|
+
disks.forEach(disk => {
|
|
70
|
+
for (const key in disk) {
|
|
71
|
+
if (typeof disk[key] === "number") {
|
|
72
|
+
disk[key] = `${gigabyteConvert(disk[key])} GB`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
hardwareinfo.write(csvHeader(disk));
|
|
77
|
+
hardwareinfo.write(csvData(disk, "\n\n"));
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/* displays & controllers */
|
|
81
|
+
const { displays, controllers } = await graphics();
|
|
82
|
+
|
|
83
|
+
// controllers
|
|
84
|
+
controllers.forEach(controller => {
|
|
85
|
+
for (const key in controller) {
|
|
86
|
+
if (typeof controller[key] === "number") {
|
|
87
|
+
controller[key] = controller[key] < 1024
|
|
88
|
+
? `${controller[key]} MB`
|
|
89
|
+
: `${gigabyteConvert(controller[key])} GB`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
hardwareinfo.write(csvHeader(controller));
|
|
94
|
+
hardwareinfo.write(csvData(controller, "\n"));
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
hardwareinfo.write("\n");
|
|
98
|
+
|
|
99
|
+
displays.forEach(display => {
|
|
100
|
+
hardwareinfo.write(csvHeader(display));
|
|
101
|
+
hardwareinfo.write(csvData(display, "\n"));
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// finish
|
|
105
|
+
console.info("finish the hardware information file");
|
|
106
|
+
} catch (err) {
|
|
107
|
+
console.error(colors.red(err.message));
|
|
108
|
+
}
|
|
109
|
+
}
|
package/functions/moviesInfo.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
// modules
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import colors from "colors";
|
|
4
|
-
import { printTable } from "console-table-printer";
|
|
5
|
-
|
|
6
|
-
// save movies
|
|
7
|
-
import { stackSave } from "../utils.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @description movie info tool
|
|
11
|
-
* @async
|
|
12
|
-
* @param { string } query - search any movie
|
|
13
|
-
* @param { string } token
|
|
14
|
-
* @returns { Promise<void> } - return movie lisy
|
|
15
|
-
*/
|
|
16
|
-
export default async function movieDB(query, token) {
|
|
17
|
-
try {
|
|
18
|
-
const { data } = await axios.get("https://api.themoviedb.org/3/search/movie", {
|
|
19
|
-
params: {
|
|
20
|
-
api_key: token,
|
|
21
|
-
query,
|
|
22
|
-
page: 1
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const movieData = data.results
|
|
27
|
-
.map(({
|
|
28
|
-
title,
|
|
29
|
-
original_language,
|
|
30
|
-
popularity,
|
|
31
|
-
vote_average,
|
|
32
|
-
release_date
|
|
33
|
-
}) => ({
|
|
34
|
-
title,
|
|
35
|
-
original_language,
|
|
36
|
-
popularity,
|
|
37
|
-
vote_average,
|
|
38
|
-
release_date
|
|
39
|
-
}))
|
|
40
|
-
.sort((x, y) => {
|
|
41
|
-
// date values
|
|
42
|
-
const primaryDate = new Date(x.release_date);
|
|
43
|
-
const secondaryDate = new Date(y.release_date);
|
|
44
|
-
|
|
45
|
-
return primaryDate.getTime() - secondaryDate.getTime();
|
|
46
|
-
})
|
|
47
|
-
.filter((data) => data?.release_date);
|
|
48
|
-
|
|
49
|
-
printTable(movieData);
|
|
50
|
-
|
|
51
|
-
stackSave("movie-list.json", JSON.stringify(movieData, null, 2));
|
|
52
|
-
} catch (err) {
|
|
53
|
-
console.error(colors.red(err.message));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
// modules
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import colors from "colors";
|
|
4
|
+
import { printTable } from "console-table-printer";
|
|
5
|
+
|
|
6
|
+
// save movies
|
|
7
|
+
import { stackSave } from "../utils.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @description movie info tool
|
|
11
|
+
* @async
|
|
12
|
+
* @param { string } query - search any movie
|
|
13
|
+
* @param { string } token
|
|
14
|
+
* @returns { Promise<void> } - return movie lisy
|
|
15
|
+
*/
|
|
16
|
+
export default async function movieDB(query, token) {
|
|
17
|
+
try {
|
|
18
|
+
const { data } = await axios.get("https://api.themoviedb.org/3/search/movie", {
|
|
19
|
+
params: {
|
|
20
|
+
api_key: token,
|
|
21
|
+
query,
|
|
22
|
+
page: 1
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const movieData = data.results
|
|
27
|
+
.map(({
|
|
28
|
+
title,
|
|
29
|
+
original_language,
|
|
30
|
+
popularity,
|
|
31
|
+
vote_average,
|
|
32
|
+
release_date
|
|
33
|
+
}) => ({
|
|
34
|
+
title,
|
|
35
|
+
original_language,
|
|
36
|
+
popularity,
|
|
37
|
+
vote_average,
|
|
38
|
+
release_date
|
|
39
|
+
}))
|
|
40
|
+
.sort((x, y) => {
|
|
41
|
+
// date values
|
|
42
|
+
const primaryDate = new Date(x.release_date);
|
|
43
|
+
const secondaryDate = new Date(y.release_date);
|
|
44
|
+
|
|
45
|
+
return primaryDate.getTime() - secondaryDate.getTime();
|
|
46
|
+
})
|
|
47
|
+
.filter((data) => data?.release_date);
|
|
48
|
+
|
|
49
|
+
printTable(movieData);
|
|
50
|
+
|
|
51
|
+
stackSave("movie-list.json", JSON.stringify(movieData, null, 2));
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error(colors.red(err.message));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
// modules
|
|
2
|
-
import colors from "colors";
|
|
3
|
-
import { printTable } from "console-table-printer";
|
|
4
|
-
import { wappalyzer } from "../api/webApis.js";
|
|
5
|
-
|
|
6
|
-
// list format
|
|
7
|
-
import { listFormat, stackSave } from "../utils.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
* @description call multiple websites tech stack analyze
|
|
12
|
-
* @param { string[] } urlList - tech analyze in multiples websites
|
|
13
|
-
* @returns { Promise<void> } - async results in multiples websites
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export default async function multipleStack(urlList) {
|
|
17
|
-
try {
|
|
18
|
-
await wappalyzer.init();
|
|
19
|
-
|
|
20
|
-
console.info("multiple websites tech stack \n");
|
|
21
|
-
|
|
22
|
-
const stacks = {};
|
|
23
|
-
|
|
24
|
-
for await (const url of urlList) {
|
|
25
|
-
console.info(url.green);
|
|
26
|
-
|
|
27
|
-
const { technologies } = await (await wappalyzer.open(url)).analyze();
|
|
28
|
-
|
|
29
|
-
const stackResult = technologies.map(({
|
|
30
|
-
name,
|
|
31
|
-
website,
|
|
32
|
-
categories
|
|
33
|
-
}) => {
|
|
34
|
-
const stackCategories = categories.map(({ name }) => name);
|
|
35
|
-
return {
|
|
36
|
-
techName: name,
|
|
37
|
-
techWebsite: website,
|
|
38
|
-
techCategories: listFormat.format(stackCategories)
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
printTable(stackResult.slice(0, 10));
|
|
43
|
-
|
|
44
|
-
stacks[url] = stackResult;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
stackSave("multiple-stack.json", JSON.stringify(stacks, null, 2));
|
|
48
|
-
} catch (err) {
|
|
49
|
-
console.error(colors.red(err.message));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
await wappalyzer.destroy();
|
|
53
|
-
}
|
|
1
|
+
// modules
|
|
2
|
+
import colors from "colors";
|
|
3
|
+
import { printTable } from "console-table-printer";
|
|
4
|
+
import { wappalyzer } from "../api/webApis.js";
|
|
5
|
+
|
|
6
|
+
// list format
|
|
7
|
+
import { listFormat, stackSave } from "../utils.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @description call multiple websites tech stack analyze
|
|
12
|
+
* @param { string[] } urlList - tech analyze in multiples websites
|
|
13
|
+
* @returns { Promise<void> } - async results in multiples websites
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export default async function multipleStack(urlList) {
|
|
17
|
+
try {
|
|
18
|
+
await wappalyzer.init();
|
|
19
|
+
|
|
20
|
+
console.info("multiple websites tech stack \n");
|
|
21
|
+
|
|
22
|
+
const stacks = {};
|
|
23
|
+
|
|
24
|
+
for await (const url of urlList) {
|
|
25
|
+
console.info(url.green);
|
|
26
|
+
|
|
27
|
+
const { technologies } = await (await wappalyzer.open(url)).analyze();
|
|
28
|
+
|
|
29
|
+
const stackResult = technologies.map(({
|
|
30
|
+
name,
|
|
31
|
+
website,
|
|
32
|
+
categories
|
|
33
|
+
}) => {
|
|
34
|
+
const stackCategories = categories.map(({ name }) => name);
|
|
35
|
+
return {
|
|
36
|
+
techName: name,
|
|
37
|
+
techWebsite: website,
|
|
38
|
+
techCategories: listFormat.format(stackCategories)
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
printTable(stackResult.slice(0, 10));
|
|
43
|
+
|
|
44
|
+
stacks[url] = stackResult;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
stackSave("multiple-stack.json", JSON.stringify(stacks, null, 2));
|
|
48
|
+
} catch (err) {
|
|
49
|
+
console.error(colors.red(err.message));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await wappalyzer.destroy();
|
|
53
|
+
}
|
package/functions/pageSpeed.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
// modules
|
|
2
|
-
import { MultiBar, Presets } from "cli-progress";
|
|
3
|
-
import figlet from "figlet";
|
|
4
|
-
import colors from "colors";
|
|
5
|
-
|
|
6
|
-
// save file
|
|
7
|
-
import { stackSave } from "../utils.js";
|
|
8
|
-
|
|
9
|
-
// pagespeed api
|
|
10
|
-
import { pagespeedApi } from "../api/webApis.js";
|
|
11
|
-
|
|
12
|
-
const maxScore = 100;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* It takes a score and a bar, and returns a color based on the score
|
|
16
|
-
* @param {number} score - The score of the current test.
|
|
17
|
-
* @returns {string} A function that takes two parameters, score and bar.
|
|
18
|
-
*/
|
|
19
|
-
const barColor = score => {
|
|
20
|
-
const bar = "{bar}";
|
|
21
|
-
|
|
22
|
-
switch (true) {
|
|
23
|
-
case score === 0 || score <= 49:
|
|
24
|
-
return bar.red;
|
|
25
|
-
case score === 50 || score <= 89:
|
|
26
|
-
return bar.yellow;
|
|
27
|
-
default:
|
|
28
|
-
return bar.green;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @description async function mobile website pagespeed
|
|
34
|
-
* @async
|
|
35
|
-
* @param { string } url - website from pagespeed mobile results
|
|
36
|
-
* @returns { Promise<void> } - return async mobile results
|
|
37
|
-
*/
|
|
38
|
-
export default async function pagespeed(url) {
|
|
39
|
-
console.info(url.green);
|
|
40
|
-
|
|
41
|
-
const multibar = new MultiBar({
|
|
42
|
-
format: "{type} | {bar} | {value}/{total}",
|
|
43
|
-
hideCursor: true,
|
|
44
|
-
clearOnComplete: false
|
|
45
|
-
}, Presets.legacy);
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
// start api
|
|
49
|
-
const { data: resMobile } = await pagespeedApi(url, "mobile");
|
|
50
|
-
const { data: resDesktop } = await pagespeedApi(url, "desktop");
|
|
51
|
-
|
|
52
|
-
// extract results
|
|
53
|
-
const mobile = Math.round(resMobile.lighthouseResult.categories.performance.score * 100);
|
|
54
|
-
const desktop = Math.round(resDesktop.lighthouseResult.categories.performance.score * 100);
|
|
55
|
-
|
|
56
|
-
// result pagespeed color bar
|
|
57
|
-
const b1 = multibar.create(maxScore, 0, { type: "mobile" }, {
|
|
58
|
-
format: `{type} | ${barColor(mobile)} | {value}/{total}`
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const b2 = multibar.create(maxScore, 0, { type: "desktop" }, {
|
|
62
|
-
format: `{type} | ${barColor(desktop)} | {value}/{total}`
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// initials bars
|
|
66
|
-
b1.update(mobile);
|
|
67
|
-
b2.update(desktop);
|
|
68
|
-
|
|
69
|
-
// stop multibar
|
|
70
|
-
multibar.stop();
|
|
71
|
-
|
|
72
|
-
const resultTxt = `
|
|
73
|
-
${figlet.textSync(url)} \n
|
|
74
|
-
mobile: ${mobile}/100 \n
|
|
75
|
-
desktop: ${desktop}/100
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
stackSave("pagespeed.txt", resultTxt);
|
|
79
|
-
} catch (err) {
|
|
80
|
-
console.error(colors.red(err.message));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
1
|
+
// modules
|
|
2
|
+
import { MultiBar, Presets } from "cli-progress";
|
|
3
|
+
import figlet from "figlet";
|
|
4
|
+
import colors from "colors";
|
|
5
|
+
|
|
6
|
+
// save file
|
|
7
|
+
import { stackSave } from "../utils.js";
|
|
8
|
+
|
|
9
|
+
// pagespeed api
|
|
10
|
+
import { pagespeedApi } from "../api/webApis.js";
|
|
11
|
+
|
|
12
|
+
const maxScore = 100;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* It takes a score and a bar, and returns a color based on the score
|
|
16
|
+
* @param {number} score - The score of the current test.
|
|
17
|
+
* @returns {string} A function that takes two parameters, score and bar.
|
|
18
|
+
*/
|
|
19
|
+
const barColor = score => {
|
|
20
|
+
const bar = "{bar}";
|
|
21
|
+
|
|
22
|
+
switch (true) {
|
|
23
|
+
case score === 0 || score <= 49:
|
|
24
|
+
return bar.red;
|
|
25
|
+
case score === 50 || score <= 89:
|
|
26
|
+
return bar.yellow;
|
|
27
|
+
default:
|
|
28
|
+
return bar.green;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @description async function mobile website pagespeed
|
|
34
|
+
* @async
|
|
35
|
+
* @param { string } url - website from pagespeed mobile results
|
|
36
|
+
* @returns { Promise<void> } - return async mobile results
|
|
37
|
+
*/
|
|
38
|
+
export default async function pagespeed(url) {
|
|
39
|
+
console.info(url.green);
|
|
40
|
+
|
|
41
|
+
const multibar = new MultiBar({
|
|
42
|
+
format: "{type} | {bar} | {value}/{total}",
|
|
43
|
+
hideCursor: true,
|
|
44
|
+
clearOnComplete: false
|
|
45
|
+
}, Presets.legacy);
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
// start api
|
|
49
|
+
const { data: resMobile } = await pagespeedApi(url, "mobile");
|
|
50
|
+
const { data: resDesktop } = await pagespeedApi(url, "desktop");
|
|
51
|
+
|
|
52
|
+
// extract results
|
|
53
|
+
const mobile = Math.round(resMobile.lighthouseResult.categories.performance.score * 100);
|
|
54
|
+
const desktop = Math.round(resDesktop.lighthouseResult.categories.performance.score * 100);
|
|
55
|
+
|
|
56
|
+
// result pagespeed color bar
|
|
57
|
+
const b1 = multibar.create(maxScore, 0, { type: "mobile" }, {
|
|
58
|
+
format: `{type} | ${barColor(mobile)} | {value}/{total}`
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const b2 = multibar.create(maxScore, 0, { type: "desktop" }, {
|
|
62
|
+
format: `{type} | ${barColor(desktop)} | {value}/{total}`
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// initials bars
|
|
66
|
+
b1.update(mobile);
|
|
67
|
+
b2.update(desktop);
|
|
68
|
+
|
|
69
|
+
// stop multibar
|
|
70
|
+
multibar.stop();
|
|
71
|
+
|
|
72
|
+
const resultTxt = `
|
|
73
|
+
${figlet.textSync(url)} \n
|
|
74
|
+
mobile: ${mobile}/100 \n
|
|
75
|
+
desktop: ${desktop}/100
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
stackSave("pagespeed.txt", resultTxt);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error(colors.red(err.message));
|
|
81
|
+
}
|
|
82
|
+
}
|
package/functions/password.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
// save password
|
|
2
|
-
import { stackSave } from "../utils.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* It generates a random password
|
|
6
|
-
* @returns {void}
|
|
7
|
-
*/
|
|
8
|
-
export default function genPassword() {
|
|
9
|
-
const chars = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
10
|
-
|
|
11
|
-
// blank password var
|
|
12
|
-
let password = "";
|
|
13
|
-
|
|
14
|
-
// loop generate chars
|
|
15
|
-
for(let i = 0; i < 12; i++) {
|
|
16
|
-
const randomNumber = Math.floor(Math.random() * chars.length);
|
|
17
|
-
|
|
18
|
-
password += chars.substring(randomNumber, randomNumber + 1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// print new passwors
|
|
22
|
-
console.info("new password:", password);
|
|
23
|
-
stackSave("password.txt", `new password: ${password}`);
|
|
24
|
-
}
|
|
1
|
+
// save password
|
|
2
|
+
import { stackSave } from "../utils.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* It generates a random password
|
|
6
|
+
* @returns {void}
|
|
7
|
+
*/
|
|
8
|
+
export default function genPassword() {
|
|
9
|
+
const chars = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
10
|
+
|
|
11
|
+
// blank password var
|
|
12
|
+
let password = "";
|
|
13
|
+
|
|
14
|
+
// loop generate chars
|
|
15
|
+
for(let i = 0; i < 12; i++) {
|
|
16
|
+
const randomNumber = Math.floor(Math.random() * chars.length);
|
|
17
|
+
|
|
18
|
+
password += chars.substring(randomNumber, randomNumber + 1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// print new passwors
|
|
22
|
+
console.info("new password:", password);
|
|
23
|
+
stackSave("password.txt", `new password: ${password}`);
|
|
24
|
+
}
|