stack-analyze 1.1.8 → 1.1.9
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 +24 -2
- package/about.js +97 -45
- package/cli.js +127 -18
- package/demo.js +20 -0
- package/functions/animeInfo.js +3 -6
- package/functions/bitly.js +1 -1
- package/functions/cryptoList.js +9 -8
- package/functions/gitUser.js +1 -1
- package/functions/hardware.js +195 -243
- package/functions/moviesInfo.js +3 -7
- package/functions/multipleStack.js +13 -8
- package/functions/pageSpeed.js +1 -1
- package/functions/scraping.js +153 -0
- package/functions/singleStack.js +14 -9
- package/functions/twitch.js +3 -4
- package/index.cjs +141 -114
- package/index.mjs +141 -119
- package/package.json +9 -8
- package/readme.md +11 -3
- package/utils.js +15 -0
- package/.vscode/settings.json +0 -4
- package/hash/aboutOpts.js +0 -53
- package/hash/hardwareTools.js +0 -47
- package/models/aboutTables.js +0 -40
- package/models/animeTable.js +0 -33
- package/models/cryptoTables.js +0 -32
- package/models/hardwareTables.js +0 -87
- package/models/movieTables.js +0 -33
- package/models/stackTables.js +0 -23
- package/models/twitchTables.js +0 -28
package/functions/singleStack.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import Wappalyzer from "wappalyzer";
|
|
3
3
|
import figlet from "figlet";
|
|
4
4
|
import colors from "colors";
|
|
5
|
-
import
|
|
5
|
+
import { printTable } from "console-table-printer";
|
|
6
|
+
|
|
7
|
+
// list format
|
|
8
|
+
import { listFormat } from "../utils.js";
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
*
|
|
@@ -23,17 +26,19 @@ export default async function singleStack(url) {
|
|
|
23
26
|
name,
|
|
24
27
|
website,
|
|
25
28
|
categories
|
|
26
|
-
}) =>
|
|
27
|
-
|
|
28
|
-
techWebsite: website,
|
|
29
|
-
techCategories: categories.map(({ name }) => name).join(", ")
|
|
30
|
-
}));
|
|
29
|
+
}) => {
|
|
30
|
+
const stackCategories = categories.map(({ name }) => name);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
return {
|
|
33
|
+
techName: name,
|
|
34
|
+
techWebsite: website,
|
|
35
|
+
techCategories: listFormat.format(stackCategories)
|
|
36
|
+
};
|
|
37
|
+
});
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
console.info(colors.green(figlet.textSync(url)));
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
printTable(stackResult);
|
|
37
42
|
} catch (err) {
|
|
38
43
|
console.error(colors.red(err.message));
|
|
39
44
|
}
|
package/functions/twitch.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// modules
|
|
2
|
-
import axios from "axios";
|
|
2
|
+
import { default as axios } from "axios";
|
|
3
3
|
import { format } from "timeago.js";
|
|
4
4
|
import colors from "colors";
|
|
5
5
|
|
|
6
6
|
// table
|
|
7
|
-
import
|
|
7
|
+
import { printTable } from "console-table-printer";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -35,8 +35,7 @@ const twitchInfo = async (twitchUser, twitchClient, apiToken) => {
|
|
|
35
35
|
createdTime: format(created_at)
|
|
36
36
|
}));
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
twitchTable.printTable();
|
|
38
|
+
printTable(result);
|
|
40
39
|
} catch (err) {
|
|
41
40
|
console.error(colors.red(err));
|
|
42
41
|
}
|
package/index.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// modules
|
|
2
2
|
const axios = require("axios").default;
|
|
3
|
-
const CoinGecko = require("coingecko-api");
|
|
4
3
|
const {
|
|
5
4
|
cpu,
|
|
6
5
|
mem,
|
|
@@ -10,48 +9,8 @@ const {
|
|
|
10
9
|
bios
|
|
11
10
|
} = require("systeminformation");
|
|
12
11
|
const Wappalyzer = require("wappalyzer");
|
|
12
|
+
const { load } = require("cheerio");
|
|
13
13
|
|
|
14
|
-
// init coingecko api
|
|
15
|
-
const CoinGeckoClient = new CoinGecko();
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @typedef {Object} anime
|
|
19
|
-
* @property {string} anime.query
|
|
20
|
-
* @property {function(data): void} anime.results
|
|
21
|
-
*
|
|
22
|
-
* @typedef {Object} bitly
|
|
23
|
-
* @property {string} bitly.link
|
|
24
|
-
* @property {string} bitly.token
|
|
25
|
-
* @property {function(data): void} bitly.results
|
|
26
|
-
*
|
|
27
|
-
* @typedef {Object} github
|
|
28
|
-
* @property {string} github.user
|
|
29
|
-
* @property {string} github.results
|
|
30
|
-
*
|
|
31
|
-
* @typedef {Object} movie
|
|
32
|
-
* @property {string} movie.api_key
|
|
33
|
-
* @property {string} movie.query
|
|
34
|
-
* @property {function(data): void} movie.results
|
|
35
|
-
*
|
|
36
|
-
* @typedef {Object} multiple
|
|
37
|
-
* @property {string[]} multiple.urls
|
|
38
|
-
* @property {function(data): void} multiple.results
|
|
39
|
-
*
|
|
40
|
-
* @typedef {Object} stack
|
|
41
|
-
* @property {string} stack.urls
|
|
42
|
-
* @property {function(data): void} stack.results
|
|
43
|
-
*
|
|
44
|
-
* @typedef {Object} twitch
|
|
45
|
-
* @property {string} twitch.query
|
|
46
|
-
* @property {string} twitch.token
|
|
47
|
-
* @property {string} twitch.clientID
|
|
48
|
-
* @property {function(data): void} twitch.results
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @param {anime} {query, results}
|
|
53
|
-
* @returns {Promise<void>}
|
|
54
|
-
*/
|
|
55
14
|
const animeSearch = async ({ query, results }) => {
|
|
56
15
|
/* error manager */
|
|
57
16
|
try {
|
|
@@ -68,10 +27,6 @@ const animeSearch = async ({ query, results }) => {
|
|
|
68
27
|
} catch (err) { results(err); }
|
|
69
28
|
};
|
|
70
29
|
|
|
71
|
-
/**
|
|
72
|
-
* @param {bitly} {link, token, results}
|
|
73
|
-
* @returns {Promise<void>}
|
|
74
|
-
*/
|
|
75
30
|
const bitlyInfo = async ({ link, token, results }) => {
|
|
76
31
|
try {
|
|
77
32
|
const { data } = await axios.post(
|
|
@@ -94,26 +49,26 @@ const bitlyInfo = async ({ link, token, results }) => {
|
|
|
94
49
|
/**
|
|
95
50
|
*
|
|
96
51
|
* @descripiton call the crypto market list
|
|
97
|
-
* @param {function(
|
|
52
|
+
* @param {function(any): void} callback
|
|
98
53
|
* @returns { Promise<void> } - return results search
|
|
99
54
|
*/
|
|
100
55
|
const cryptoMarket = async (callback) => {
|
|
101
56
|
try {
|
|
102
57
|
// start crypto
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
58
|
+
const { data } = await axios.get(
|
|
59
|
+
"https://api.coingecko.com/api/v3/coins/markets", {
|
|
60
|
+
params: {
|
|
61
|
+
vs_currency: "usd",
|
|
62
|
+
per_page: 10
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
106
66
|
|
|
107
67
|
// map coinData
|
|
108
|
-
callback(
|
|
68
|
+
callback(data);
|
|
109
69
|
} catch (err) { callback(err); }
|
|
110
70
|
};
|
|
111
71
|
|
|
112
|
-
/**
|
|
113
|
-
*
|
|
114
|
-
* @param {github} {user, results}
|
|
115
|
-
* @returns {Promise<void>}
|
|
116
|
-
*/
|
|
117
72
|
async function githubInfo({ user, results }) {
|
|
118
73
|
try {
|
|
119
74
|
const { data } = await axios.get(`https://api.github.com/users/${user}`);
|
|
@@ -122,11 +77,6 @@ async function githubInfo({ user, results }) {
|
|
|
122
77
|
} catch (err) { results(err); }
|
|
123
78
|
}
|
|
124
79
|
|
|
125
|
-
/**
|
|
126
|
-
*
|
|
127
|
-
* @param {function(data): void} callback
|
|
128
|
-
* @returns {Promise<void>}
|
|
129
|
-
*/
|
|
130
80
|
async function cpuInfo(callback) {
|
|
131
81
|
try {
|
|
132
82
|
const {
|
|
@@ -156,11 +106,6 @@ async function cpuInfo(callback) {
|
|
|
156
106
|
} catch (err) { callback(err); }
|
|
157
107
|
}
|
|
158
108
|
|
|
159
|
-
/**
|
|
160
|
-
*
|
|
161
|
-
* @param {function(data): void} callback
|
|
162
|
-
* @returns {Promise<void>}
|
|
163
|
-
*/
|
|
164
109
|
async function ramMemInfo(callback) {
|
|
165
110
|
try {
|
|
166
111
|
const {
|
|
@@ -182,11 +127,6 @@ async function ramMemInfo(callback) {
|
|
|
182
127
|
} catch (err) { callback(err); }
|
|
183
128
|
}
|
|
184
129
|
|
|
185
|
-
/**
|
|
186
|
-
*
|
|
187
|
-
* @param {function(data): void} callback
|
|
188
|
-
* @returns {Promise<void>}
|
|
189
|
-
*/
|
|
190
130
|
async function osDetail(callback) {
|
|
191
131
|
try {
|
|
192
132
|
const {
|
|
@@ -214,11 +154,6 @@ async function osDetail(callback) {
|
|
|
214
154
|
} catch (err) { callback(err); }
|
|
215
155
|
}
|
|
216
156
|
|
|
217
|
-
/**
|
|
218
|
-
*
|
|
219
|
-
* @param {function(data): void} callback
|
|
220
|
-
* @returns {Promise<void>}
|
|
221
|
-
*/
|
|
222
157
|
async function diskInfo(callback) {
|
|
223
158
|
try {
|
|
224
159
|
const disks = await diskLayout();
|
|
@@ -242,11 +177,6 @@ async function diskInfo(callback) {
|
|
|
242
177
|
} catch (err) { callback(err); }
|
|
243
178
|
}
|
|
244
179
|
|
|
245
|
-
/**
|
|
246
|
-
*
|
|
247
|
-
* @param {function(data): void} callback
|
|
248
|
-
* @returns {Promise<void>}
|
|
249
|
-
*/
|
|
250
180
|
async function controllerInfo(callback) {
|
|
251
181
|
try {
|
|
252
182
|
const { controllers } = await graphics();
|
|
@@ -267,11 +197,6 @@ async function controllerInfo(callback) {
|
|
|
267
197
|
} catch (err) { callback(err); }
|
|
268
198
|
}
|
|
269
199
|
|
|
270
|
-
/**
|
|
271
|
-
*
|
|
272
|
-
* @param {function(data): void} callback
|
|
273
|
-
* @returns {Promise<void>}
|
|
274
|
-
*/
|
|
275
200
|
async function displayInfo(callback) {
|
|
276
201
|
try {
|
|
277
202
|
const { displays } = await graphics();
|
|
@@ -294,11 +219,6 @@ async function displayInfo(callback) {
|
|
|
294
219
|
} catch (err) { callback(err); }
|
|
295
220
|
}
|
|
296
221
|
|
|
297
|
-
/**
|
|
298
|
-
*
|
|
299
|
-
* @param {function(data): void} callback
|
|
300
|
-
* @returns {Promise<void>}
|
|
301
|
-
*/
|
|
302
222
|
async function biosInfo(callback) {
|
|
303
223
|
try {
|
|
304
224
|
const {
|
|
@@ -312,10 +232,6 @@ async function biosInfo(callback) {
|
|
|
312
232
|
} catch (err) { callback(err); }
|
|
313
233
|
}
|
|
314
234
|
|
|
315
|
-
/**
|
|
316
|
-
* @param {movie} {api_key, query, results}
|
|
317
|
-
* @returns {Promise<void>} void results
|
|
318
|
-
*/
|
|
319
235
|
const movieDB = async ({ api_key, query, results }) => {
|
|
320
236
|
try {
|
|
321
237
|
const { data } = await axios.get("https://api.themoviedb.org/3/search/movie", {
|
|
@@ -353,10 +269,6 @@ const movieDB = async ({ api_key, query, results }) => {
|
|
|
353
269
|
} catch (err) { results(err); }
|
|
354
270
|
};
|
|
355
271
|
|
|
356
|
-
/**
|
|
357
|
-
* @param {multiple} {urls, results}
|
|
358
|
-
* @returns {Promise<void>}
|
|
359
|
-
*/
|
|
360
272
|
async function multipleStack({ urls, results }) {
|
|
361
273
|
let result;
|
|
362
274
|
const wappalyzer = new Wappalyzer();
|
|
@@ -376,10 +288,6 @@ async function multipleStack({ urls, results }) {
|
|
|
376
288
|
results(result);
|
|
377
289
|
}
|
|
378
290
|
|
|
379
|
-
/**
|
|
380
|
-
* @param {stack} {url, results}
|
|
381
|
-
* @returns {Promise<void>}
|
|
382
|
-
*/
|
|
383
291
|
const pageSpeed = async ({ url, results }) => {
|
|
384
292
|
try {
|
|
385
293
|
const resMobile = await axios.get("https://www.googleapis.com/pagespeedonline/v5/runPagespeed", {
|
|
@@ -406,10 +314,6 @@ const pageSpeed = async ({ url, results }) => {
|
|
|
406
314
|
} catch (err) { results(err); }
|
|
407
315
|
};
|
|
408
316
|
|
|
409
|
-
/**
|
|
410
|
-
* @param {stack} {url, results}
|
|
411
|
-
* @returns {Promise<void>}
|
|
412
|
-
*/
|
|
413
317
|
async function singleStack({ url, results }) {
|
|
414
318
|
const wappalyzer = await new Wappalyzer;
|
|
415
319
|
|
|
@@ -434,11 +338,6 @@ async function singleStack({ url, results }) {
|
|
|
434
338
|
results(result);
|
|
435
339
|
}
|
|
436
340
|
|
|
437
|
-
/**
|
|
438
|
-
*
|
|
439
|
-
* @param {twitch} { query, token, clientID, results }
|
|
440
|
-
* @returns {Promise<void>}
|
|
441
|
-
*/
|
|
442
341
|
async function twitchInfo({ query, token, clientID, results }) {
|
|
443
342
|
try {
|
|
444
343
|
const { data: twitchData } = await axios.get(`https://api.twitch.tv/helix/users?login=${query}`,
|
|
@@ -453,6 +352,133 @@ async function twitchInfo({ query, token, clientID, results }) {
|
|
|
453
352
|
} catch (err) { results(err); }
|
|
454
353
|
}
|
|
455
354
|
|
|
355
|
+
function scrape(url) {
|
|
356
|
+
let $;
|
|
357
|
+
|
|
358
|
+
const scraping = axios.create({
|
|
359
|
+
baseURL: url
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const title = async (callback) => {
|
|
363
|
+
try {
|
|
364
|
+
const { data } = await scraping.get("");
|
|
365
|
+
$ = load(data);
|
|
366
|
+
|
|
367
|
+
callback($("title").text());
|
|
368
|
+
} catch (err) { console.error(colors.red(err.message)); }
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
const images = async (callback) => {
|
|
372
|
+
try {
|
|
373
|
+
const { data } = await scraping.get("");
|
|
374
|
+
$ = load(data);
|
|
375
|
+
|
|
376
|
+
const imgs = $("img").map((i, el) => ({
|
|
377
|
+
imagePath: $(el).attr("src"),
|
|
378
|
+
imageTitle: $(el).attr("alt")
|
|
379
|
+
})).toArray();
|
|
380
|
+
|
|
381
|
+
callback(imgs);
|
|
382
|
+
} catch (err) { console.error(colors.red(err.message)); }
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const metadata = async (callback) => {
|
|
386
|
+
try {
|
|
387
|
+
const { data } = await scraping.get("");
|
|
388
|
+
$ = load(data);
|
|
389
|
+
|
|
390
|
+
const metadataList = $("meta").map((i, el) => ({
|
|
391
|
+
metaInfo: $(el).attr("name"),
|
|
392
|
+
metaContent: $(el).attr("content")
|
|
393
|
+
})).toArray()
|
|
394
|
+
.filter(({ metaInfo }) => metaInfo !== undefined);
|
|
395
|
+
|
|
396
|
+
callback(metadataList);
|
|
397
|
+
} catch (err) { console.error(colors.red(err.message)); }
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
const headings = async (callback) => {
|
|
401
|
+
try {
|
|
402
|
+
const { data } = await scraping.get("");
|
|
403
|
+
$ = load(data);
|
|
404
|
+
|
|
405
|
+
const headingList = $("h1, h2, h3, h4, h5, h6").map((i, el) => ({
|
|
406
|
+
headingTag: $(el).prop("tagName"),
|
|
407
|
+
headingText: $(el).text()
|
|
408
|
+
})).toArray();
|
|
409
|
+
|
|
410
|
+
callback(headingList);
|
|
411
|
+
} catch (err) { console.error(colors.red(err.message)); }
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const table_heading = async (callback) => {
|
|
415
|
+
try {
|
|
416
|
+
const { data } = await scraping.get("");
|
|
417
|
+
$ = load(data);
|
|
418
|
+
|
|
419
|
+
const tableHeadList = $("th").map((i, el) => ({
|
|
420
|
+
headingRow: i,
|
|
421
|
+
text: $(el).text()
|
|
422
|
+
})).toArray();
|
|
423
|
+
|
|
424
|
+
callback(tableHeadList);
|
|
425
|
+
} catch (err) { console.error(colors.red(err.message)); }
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const table_data = async (callback) => {
|
|
429
|
+
try {
|
|
430
|
+
const { data } = await scraping.get("");
|
|
431
|
+
$ = load(data);
|
|
432
|
+
|
|
433
|
+
const tableColumnList = $("td").map((i, el) => $(el).text()).toArray();
|
|
434
|
+
|
|
435
|
+
callback(tableColumnList);
|
|
436
|
+
} catch (err) { console.error(colors.red(err.message)); }
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
const links = async (callback) => {
|
|
441
|
+
try {
|
|
442
|
+
const { data } = await scraping.get("");
|
|
443
|
+
$ = load(data);
|
|
444
|
+
|
|
445
|
+
const linkList = $("a").map((i, el) => ({
|
|
446
|
+
url: $(el).attr("href"),
|
|
447
|
+
text: $(el).text()
|
|
448
|
+
})).toArray()
|
|
449
|
+
.filter(({ url }) => url.indexOf("#") !== 0);
|
|
450
|
+
|
|
451
|
+
callback(linkList);
|
|
452
|
+
} catch (err) { console.error(colors.red(err.message)); }
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
const cites = async (callback) => {
|
|
456
|
+
try {
|
|
457
|
+
const { data } = await scraping.get("");
|
|
458
|
+
$ = load(data);
|
|
459
|
+
|
|
460
|
+
const citeList = $("q, blockquote").map((i, el) => ({
|
|
461
|
+
citeTag: $(el).prop("tagName"),
|
|
462
|
+
citeLink: $(el).attr("cite"),
|
|
463
|
+
citeText: $(el).text()
|
|
464
|
+
})).toArray();
|
|
465
|
+
|
|
466
|
+
callback(citeList);
|
|
467
|
+
} catch (err) { console.error(colors.red(err.message)); }
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
return {
|
|
471
|
+
title,
|
|
472
|
+
images,
|
|
473
|
+
metadata,
|
|
474
|
+
headings,
|
|
475
|
+
table_heading,
|
|
476
|
+
table_data,
|
|
477
|
+
links,
|
|
478
|
+
cites
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
|
|
456
482
|
// exports
|
|
457
483
|
module.exports = {
|
|
458
484
|
animeSearch,
|
|
@@ -470,5 +496,6 @@ module.exports = {
|
|
|
470
496
|
multipleStack,
|
|
471
497
|
pageSpeed,
|
|
472
498
|
singleStack,
|
|
473
|
-
twitchInfo
|
|
474
|
-
|
|
499
|
+
twitchInfo,
|
|
500
|
+
scrape
|
|
501
|
+
};
|