stack-analyze 1.1.4

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.
@@ -0,0 +1,241 @@
1
+ // modules
2
+ const {
3
+ cpu,
4
+ mem,
5
+ osInfo,
6
+ diskLayout,
7
+ graphics,
8
+ bios
9
+ } = require("systeminformation");
10
+ const { printTable } = require("console-table-printer");
11
+ const { red } = require("colors");
12
+
13
+
14
+ /**
15
+ *
16
+ * @description call the async function cpuinfo
17
+ * @return { Promise<void> } - return cpu results
18
+ *
19
+ */
20
+ async function cpuInfo() {
21
+ try {
22
+ const {
23
+ manufacturer,
24
+ brand,
25
+ speed,
26
+ cores,
27
+ physicalCores,
28
+ processors,
29
+ vendor,
30
+ family,
31
+ model
32
+ } = await cpu();
33
+
34
+ // show results
35
+ console.table({
36
+ manufacturer,
37
+ brand,
38
+ speed,
39
+ cores,
40
+ physicalCores,
41
+ processors,
42
+ vendor,
43
+ family,
44
+ model
45
+ });
46
+ } catch (err) {
47
+ console.error(red(err.message));
48
+ }
49
+ }
50
+
51
+ /**
52
+ *
53
+ * @description call the async function ram memory
54
+ * @return { Promise<void> } - return ram memory results
55
+ *
56
+ */
57
+ async function ramMemInfo() {
58
+ try {
59
+ const {
60
+ total,
61
+ free,
62
+ used,
63
+ active,
64
+ available
65
+ } = await mem();
66
+
67
+ // show results
68
+ console.table({
69
+ total_mem: `${(total / 1073741824).toFixed(2)} GB`,
70
+ free_mem: `${(free / 1073741824).toFixed(2)} GB`,
71
+ used_mem: `${(used / 1073741824).toFixed(2)} GB`,
72
+ active_mem: `${(active / 1073741824).toFixed(2)} GB`,
73
+ available_mem: `${(available / 1073741824).toFixed(2)} GB`
74
+ });
75
+ } catch (err) {
76
+ console.error(red(err.message));
77
+ }
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @description call the async function osinfo
83
+ * @return { Promise<void> } - return os results results
84
+ *
85
+ */
86
+ async function osDetail() {
87
+ try {
88
+ const {
89
+ hostname,
90
+ platform,
91
+ distro,
92
+ release,
93
+ kernel,
94
+ arch,
95
+ serial,
96
+ uefi
97
+ } = await osInfo();
98
+
99
+ // show results
100
+ console.table({
101
+ hostname,
102
+ platform,
103
+ distro,
104
+ release,
105
+ kernel,
106
+ arch,
107
+ serial,
108
+ uefi
109
+ });
110
+ } catch (err) {
111
+ console.error(red(err.message));
112
+ }
113
+ }
114
+
115
+ /**
116
+ *
117
+ * @description call the async function diskinfo
118
+ * @return { Promise<void> } - return disks results
119
+ *
120
+ */
121
+ async function diskInfo() {
122
+ try {
123
+ const disks = await diskLayout();
124
+
125
+ const disksList = disks.map(({
126
+ type,
127
+ name,
128
+ vendor,
129
+ size,
130
+ interfaceType
131
+ }) => ({
132
+ type,
133
+ name,
134
+ vendor,
135
+ diskSize: `${(size / 1073741824).toFixed(2)} GB`,
136
+ interfaceType
137
+ }));
138
+
139
+ printTable(disksList);
140
+
141
+ } catch (err) {
142
+ console.error(red(err.message));
143
+ }
144
+ }
145
+
146
+ /**
147
+ *
148
+ * @description call the async function graphic card
149
+ * @return { Promise<void> } - return graphic controller results
150
+ *
151
+ */
152
+ async function controllerInfo() {
153
+ try {
154
+ const { controllers } = await graphics();
155
+
156
+ const controllersList = controllers.map(({
157
+ model,
158
+ vendor,
159
+ vram
160
+ }) => ({
161
+ model,
162
+ vendor,
163
+ vramSize: vram < 1024
164
+ ? `${vram} MB`
165
+ : `${(vram / 1024).toFixed(2)} GB`
166
+ }));
167
+
168
+ // show results
169
+ printTable(controllersList);
170
+ } catch (err) {
171
+ console.error(red(err.message));
172
+ }
173
+ }
174
+
175
+ /**
176
+ *
177
+ * @description call the async function display info
178
+ * @return { Promise<void> } - return display results
179
+ *
180
+ */
181
+ async function displayInfo() {
182
+ try {
183
+ const { displays } = await graphics();
184
+
185
+ const displayList = displays.map(({
186
+ model,
187
+ main,
188
+ connection,
189
+ resolutionX,
190
+ resolutionY
191
+ }) => ({
192
+ model,
193
+ main,
194
+ connection,
195
+ resolutionX,
196
+ resolutionY
197
+ }));
198
+
199
+ // show results
200
+ printTable(displayList);
201
+ } catch (err) {
202
+ console.error(red(err.message));
203
+ }
204
+ }
205
+
206
+ /**
207
+ *
208
+ * @description call the async function biosinfo
209
+ * @return { Promise<void> } - return bios info results
210
+ *
211
+ */
212
+ async function biosInfo() {
213
+ try {
214
+ const {
215
+ releaseDate,
216
+ vendor,
217
+ revision,
218
+ version
219
+ } = await bios();
220
+
221
+ console.table({
222
+ releaseDate,
223
+ vendor,
224
+ bios_revision: revision === "" ? "no info": revision,
225
+ version
226
+ });
227
+ } catch (err) {
228
+ console.error(red(err.message));
229
+ }
230
+ }
231
+
232
+ // exports modules
233
+ module.exports = {
234
+ cpuInfo,
235
+ ramMemInfo,
236
+ osDetail,
237
+ diskInfo,
238
+ controllerInfo,
239
+ displayInfo,
240
+ biosInfo
241
+ };
@@ -0,0 +1,77 @@
1
+ // modules
2
+ const { textSync } = require("figlet");
3
+ const Wappalyzer = require("wappalyzer");
4
+ const { red, green } = require("colors");
5
+ const { Table } = require("console-table-printer");
6
+
7
+ /**
8
+ *
9
+ * @description call multiple websites tech stack analyze
10
+ * @param { string[] } urls - tech analyze in multiples websites
11
+ * @returns { Promise<void> } - async results in multiples websites
12
+ *
13
+ */
14
+ const multipleStack = async (urls) => {
15
+ const wappalyzer = await new Wappalyzer();
16
+
17
+ const p = new Table({
18
+ columns: [
19
+ {
20
+ name: "techName",
21
+ alignment: "left",
22
+ color: "cyan"
23
+ },
24
+ {
25
+ name: "techWebsite",
26
+ alignment: "left",
27
+ color: "green"
28
+ },
29
+ {
30
+ name: "techCategories",
31
+ alignment: "left",
32
+ color: "cyan"
33
+ }
34
+ ]
35
+ });
36
+
37
+ try {
38
+ await wappalyzer.init();
39
+
40
+ const results = await Promise.all(
41
+ urls.map(async (url) => {
42
+ const { technologies } = await wappalyzer.open(url).analyze();
43
+
44
+ return {
45
+ url,
46
+ technologies
47
+ };
48
+ }));
49
+
50
+ console.info("multiple websites tech stack \n");
51
+ console.group();
52
+ // loop web site tech stack
53
+ results.forEach(({url, technologies}) => {
54
+ const stackResult = technologies.map(({
55
+ name,
56
+ website,
57
+ categories
58
+ }) => ({
59
+ techName: name,
60
+ techWebsite: website,
61
+ techCategories: categories.map(({ name }) => name).join(", ")
62
+ }));
63
+
64
+ console.info(green(textSync(url, "Small")));
65
+ console.group();
66
+ p.addRows(stackResult);
67
+ p.printTable();
68
+ console.groupEnd();
69
+ });
70
+ } catch (err) {
71
+ console.error(red(err.message));
72
+ }
73
+
74
+ await wappalyzer.destroy();
75
+ };
76
+
77
+ module.exports = multipleStack;
@@ -0,0 +1,104 @@
1
+ // modules
2
+ const axios = require("axios").default;
3
+ const cliProgress = require("cli-progress");
4
+ const colors = require("colors");
5
+
6
+ /**
7
+ * @description get color bar
8
+ * @param { number } valueOne - get value data desktop
9
+ * @param { number } valueTwo - get value data mobile
10
+ * @param { any } bar - using bar
11
+ * @returns { void }
12
+ */
13
+ const barColor = (valueOne, valueTwo, bar) => {
14
+ switch (true) {
15
+ case (valueOne === 1 || valueOne <= 49):
16
+ case (valueTwo === 1 || valueTwo <= 49):
17
+ colors.red(bar);
18
+ break;
19
+ case (valueOne === 50 || valueOne <= 89):
20
+ case (valueTwo === 50 || valueTwo <= 89):
21
+ colors.yellow(bar);
22
+ break;
23
+ case (valueOne >= 90 || valueOne === 100):
24
+ case (valueTwo >= 90 || valueTwo === 100):
25
+ colors.green(bar);
26
+ break;
27
+ default:
28
+ colors.bgMagenta(bar);
29
+ break;
30
+ }
31
+ };
32
+
33
+ /**
34
+ * @description async function mobile website pagespeed
35
+ * @param { string } url - website from pagespeed mobile results
36
+ * @returns { Promise<void> } - return async mobile results
37
+ */
38
+ const pageSpeed = async (url) => {
39
+ const resMobile = await axios.get("https://www.googleapis.com/pagespeedonline/v5/runPagespeed", {
40
+ params: {
41
+ url,
42
+ key: "AIzaSyBEDaW4FxSZ2s1vz5CdD5Ai6PGZGdAzij0",
43
+ strategy: "mobile"
44
+ }
45
+ });
46
+
47
+ const resDesktop = await axios.get("https://www.googleapis.com/pagespeedonline/v5/runPagespeed", {
48
+ params: {
49
+ url,
50
+ key: "AIzaSyBEDaW4FxSZ2s1vz5CdD5Ai6PGZGdAzij0",
51
+ strategy: "desktop"
52
+ }
53
+ });
54
+
55
+ // extract results
56
+ const movil = Math.round(resMobile.data.lighthouseResult.categories.performance.score * 100);
57
+ const desktop = Math.round(resDesktop.data.lighthouseResult.categories.performance.score * 100);
58
+
59
+ // result pagespeed bar color
60
+ const multibar = new cliProgress.MultiBar({
61
+ format: " {bar} | {text} | {value}/{total}",
62
+ clearOnComplete: false,
63
+ hideCursor: true,
64
+ barCompleteChar: "\u2588",
65
+ barIncompleteChar: "\u2591",
66
+ }, cliProgress.Presets.rect);
67
+
68
+ // add bars
69
+ const b1 = multibar.create(100, 0);
70
+ const b2 = multibar.create(100, 0);
71
+
72
+ try {
73
+
74
+ // valid results
75
+ switch (true) {
76
+ case (movil === 1 || movil <= 49):
77
+ case (desktop === 1 || desktop <= 49):
78
+ b1.update(movil, { text: "mobile result".red });
79
+ b2.update(desktop, { text: "desktop result".red });
80
+ break;
81
+ case (movil === 50 || movil <= 89):
82
+ case (desktop === 50 || desktop <= 89):
83
+ b1.update(movil, { text: "mobile result".yellow });
84
+ b2.update(desktop, { text: "desktop result".yellow });
85
+ break;
86
+ case (movil >= 90 || movil === 100):
87
+ case (desktop >= 90 || desktop === 100):
88
+ b1.update(movil, { text: "mobile result".green });
89
+ b2.update(desktop, { text: "desktop result".green });
90
+ break;
91
+ default:
92
+ b1.update(movil, { text: "mobile result" });
93
+ b2.update(desktop, { text: "desktop result" });
94
+ break;
95
+ }
96
+
97
+ // stop all bars
98
+ multibar.stop();
99
+ } catch (err) {
100
+ console.error(err.message.red);
101
+ }
102
+ };
103
+
104
+ module.exports = pageSpeed;
@@ -0,0 +1,65 @@
1
+ // module
2
+ const Wappalyzer = require("wappalyzer");
3
+ const { textSync } = require("figlet");
4
+ const { red, green } = require("colors");
5
+ const { Table } = require("console-table-printer");
6
+
7
+ /**
8
+ *
9
+ * @description call single website tech stack analyze
10
+ * @param { string } url - analyze single website stack
11
+ * @returns { Promise<void> } - return async results single web
12
+ *
13
+ */
14
+ async function singleStack(url) {
15
+ const wappalyzer = await new Wappalyzer;
16
+
17
+ const p = new Table({
18
+ columns: [
19
+ {
20
+ name: "techName",
21
+ alignment: "left",
22
+ color: "cyan"
23
+ },
24
+ {
25
+ name: "techWebsite",
26
+ alignment: "left",
27
+ color: "green"
28
+ },
29
+ {
30
+ name: "techCategories",
31
+ alignment: "left",
32
+ color: "cyan"
33
+ }
34
+ ]
35
+
36
+ });
37
+
38
+ try {
39
+ await wappalyzer.init();
40
+
41
+ const { technologies } = await wappalyzer.open(url).analyze();
42
+
43
+ const stackResult = technologies.map(({
44
+ name,
45
+ website,
46
+ categories
47
+ }) => ({
48
+ techName: name,
49
+ techWebsite: website,
50
+ techCategories: categories.map(({ name }) => name).join(", ")
51
+ }));
52
+
53
+ console.info(green(textSync(url)));
54
+
55
+ p.addRows(stackResult);
56
+
57
+ p.printTable();
58
+ } catch (err) {
59
+ console.error(red(err.message));
60
+ }
61
+
62
+ await wappalyzer.destroy();
63
+ }
64
+
65
+ module.exports = singleStack;