stack-analyze 1.1.7 → 1.2.0

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/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  // modules
2
- import axios from "axios";
3
- import CoinGecko from "coingecko-api";
2
+ import {default as axios} from "axios";
4
3
  import {
5
4
  cpu,
6
5
  mem,
@@ -10,53 +9,13 @@ import {
10
9
  bios
11
10
  } from "systeminformation";
12
11
  import Wappalyzer from "wappalyzer";
12
+ import cheerio from "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
- const animeSearch = async ({ query, results }) => {
14
+ const animeSearch = async ({ query, results, failed }) => {
56
15
  /* error manager */
57
16
  try {
58
17
  // call api
59
- const { data } = await axios.get("https://api.jikan.moe/v3/search/anime", {
18
+ const { data } = await axios.get("https://api.jikan.moe/v/anime", {
60
19
  params: {
61
20
  q: query,
62
21
  limit: 10
@@ -65,14 +24,10 @@ const CoinGeckoClient = new CoinGecko();
65
24
 
66
25
  results(data.results);
67
26
 
68
- } catch (err) { results(err); }
27
+ } catch (err) { failed(err); }
69
28
  };
70
29
 
71
- /**
72
- * @param {bitly} {link, token, results}
73
- * @returns {Promise<void>}
74
- */
75
- const bitlyInfo = async ({ link, token, results }) => {
30
+ const bitlyInfo = async ({ link, token, results, failed }) => {
76
31
  try {
77
32
  const { data } = await axios.post(
78
33
  "https://api-ssl.bitly.com/v4/expand",
@@ -88,45 +43,34 @@ const bitlyInfo = async ({ link, token, results }) => {
88
43
  );
89
44
 
90
45
  results(data);
91
- } catch (err) { results(err); }
46
+ } catch (err) { failed(err); }
92
47
  };
93
48
 
94
- /**
95
- *
96
- * @descripiton call the crypto market list
97
- * @param {function(data): void} callback
98
- * @returns { Promise<void> } - return results search
99
- */
100
- const cryptoMarket = async (callback) => {
49
+ const cryptoMarket = async ({results, failed}) => {
101
50
  try {
102
51
  // start crypto
103
- const coinData = await CoinGeckoClient.coins.markets({
104
- per_page: 10
105
- });
52
+ const { data } = await axios.get(
53
+ "https://api.coingecko.com/api/v3/coins/markets", {
54
+ params: {
55
+ vs_currency: "usd",
56
+ per_page: 10
57
+ }
58
+ }
59
+ );
106
60
 
107
61
  // map coinData
108
- callback(coinData.data);
109
- } catch (err) { callback(err); }
62
+ results(data);
63
+ } catch (err) { failed(err); }
110
64
  };
111
65
 
112
- /**
113
- *
114
- * @param {github} {user, results}
115
- * @returns {Promise<void>}
116
- */
117
- async function githubInfo({ user, results }) {
66
+ async function githubInfo({ user, results, failed }) {
118
67
  try {
119
68
  const { data } = await axios.get(`https://api.github.com/users/${user}`);
120
69
 
121
70
  results(data);
122
- } catch (err) { results(err); }
71
+ } catch (err) { failed(err); }
123
72
  }
124
73
 
125
- /**
126
- *
127
- * @param {function(data): void} callback
128
- * @returns {Promise<void>}
129
- */
130
74
  async function cpuInfo(callback) {
131
75
  try {
132
76
  const {
@@ -156,11 +100,6 @@ async function cpuInfo(callback) {
156
100
  } catch (err) { callback(err); }
157
101
  }
158
102
 
159
- /**
160
- *
161
- * @param {function(data): void} callback
162
- * @returns {Promise<void>}
163
- */
164
103
  async function ramMemInfo(callback) {
165
104
  try {
166
105
  const {
@@ -182,11 +121,6 @@ async function ramMemInfo(callback) {
182
121
  } catch (err) { callback(err); }
183
122
  }
184
123
 
185
- /**
186
- *
187
- * @param {function(data): void} callback
188
- * @returns {Promise<void>}
189
- */
190
124
  async function osDetail(callback) {
191
125
  try {
192
126
  const {
@@ -214,11 +148,6 @@ async function osDetail(callback) {
214
148
  } catch (err) { callback(err); }
215
149
  }
216
150
 
217
- /**
218
- *
219
- * @param {function(data): void} callback
220
- * @returns {Promise<void>}
221
- */
222
151
  async function diskInfo(callback) {
223
152
  try {
224
153
  const disks = await diskLayout();
@@ -242,11 +171,6 @@ async function diskInfo(callback) {
242
171
  } catch (err) { callback(err); }
243
172
  }
244
173
 
245
- /**
246
- *
247
- * @param {function(data): void} callback
248
- * @returns {Promise<void>}
249
- */
250
174
  async function controllerInfo(callback) {
251
175
  try {
252
176
  const { controllers } = await graphics();
@@ -267,11 +191,6 @@ async function controllerInfo(callback) {
267
191
  } catch (err) { callback(err); }
268
192
  }
269
193
 
270
- /**
271
- *
272
- * @param {function(data): void} callback
273
- * @returns {Promise<void>}
274
- */
275
194
  async function displayInfo(callback) {
276
195
  try {
277
196
  const { displays } = await graphics();
@@ -294,11 +213,6 @@ async function displayInfo(callback) {
294
213
  } catch (err) { callback(err); }
295
214
  }
296
215
 
297
- /**
298
- *
299
- * @param {function(data): void} callback
300
- * @returns {Promise<void>}
301
- */
302
216
  async function biosInfo(callback) {
303
217
  try {
304
218
  const {
@@ -312,11 +226,7 @@ async function biosInfo(callback) {
312
226
  } catch (err) { callback(err); }
313
227
  }
314
228
 
315
- /**
316
- * @param {movie} {api_key, query, results}
317
- * @returns {Promise<void>} void results
318
- */
319
- const movieDB = async ({ api_key, query, results }) => {
229
+ const movieDB = async ({ api_key, query, results, failed }) => {
320
230
  try {
321
231
  const { data } = await axios.get("https://api.themoviedb.org/3/search/movie", {
322
232
  params: {
@@ -350,14 +260,10 @@ const movieDB = async ({ api_key, query, results }) => {
350
260
  .filter(({ release_date }) => release_date !== undefined && release_date !== "");
351
261
 
352
262
  results(movieData);
353
- } catch (err) { results(err); }
263
+ } catch (err) { failed(err); }
354
264
  };
355
265
 
356
- /**
357
- * @param {multiple} {urls, results}
358
- * @returns {Promise<void>}
359
- */
360
- async function multipleStack({ urls, results }) {
266
+ async function multipleStack({ urls, results, failed }) {
361
267
  let result;
362
268
  const wappalyzer = new Wappalyzer();
363
269
  try {
@@ -371,16 +277,12 @@ async function multipleStack({ urls, results }) {
371
277
  };
372
278
  })
373
279
  );
374
- } catch (err) { result = err; }
280
+ results(result);
281
+ } catch (err) { failed(err); }
375
282
  await wappalyzer.destroy();
376
- results(result);
377
283
  }
378
284
 
379
- /**
380
- * @param {stack} {url, results}
381
- * @returns {Promise<void>}
382
- */
383
- const pageSpeed = async ({ url, results }) => {
285
+ const pageSpeed = async ({ url, results, failed }) => {
384
286
  try {
385
287
  const resMobile = await axios.get("https://www.googleapis.com/pagespeedonline/v5/runPagespeed", {
386
288
  params: {
@@ -403,14 +305,10 @@ const pageSpeed = async ({ url, results }) => {
403
305
  const desktop = Math.round(resDesktop.data.lighthouseResult.categories.performance.score * 100);
404
306
 
405
307
  results({ mobile, desktop });
406
- } catch (err) { results(err); }
308
+ } catch (err) { failed(err); }
407
309
  };
408
310
 
409
- /**
410
- * @param {stack} {url, results}
411
- * @returns {Promise<void>}
412
- */
413
- async function singleStack({ url, results }) {
311
+ async function singleStack({ url, results, failed }) {
414
312
  const wappalyzer = await new Wappalyzer;
415
313
 
416
314
  let result;
@@ -428,18 +326,13 @@ async function singleStack({ url, results }) {
428
326
  techWebsite: website,
429
327
  techCategories: categories.map(({ name }) => name).join(", ")
430
328
  }));
431
- } catch (err) { results(err); }
329
+ results(result);
330
+ } catch (err) { failed(err); }
432
331
 
433
332
  await wappalyzer.destroy();
434
- results(result);
435
333
  }
436
334
 
437
- /**
438
- *
439
- * @param {twitch} { query, token, clientID, results }
440
- * @returns {Promise<void>}
441
- */
442
- async function twitchInfo({ query, token, clientID, results }) {
335
+ async function twitchInfo({ query, token, clientID, results, failed }) {
443
336
  try {
444
337
  const { data: twitchData } = await axios.get(`https://api.twitch.tv/helix/users?login=${query}`,
445
338
  {
@@ -450,9 +343,153 @@ async function twitchInfo({ query, token, clientID, results }) {
450
343
  });
451
344
 
452
345
  results(twitchData.data);
453
- } catch (err) { results(err); }
346
+ } catch (err) { failed(err); }
347
+ }
348
+
349
+ function scrape(url) {
350
+ let $;
351
+
352
+ const scraping = axios.create({
353
+ baseURL: url
354
+ });
355
+
356
+ const title = async ({results, failed}) => {
357
+ try {
358
+ const { data } = await scraping.get(url);
359
+ $ = cheerio.load(data);
360
+
361
+ results($("title").text());
362
+ } catch (err) { failed(err); }
363
+ };
364
+
365
+ const images = async ({results, failed}) => {
366
+ try {
367
+ const { data } = await scraping.get(url);
368
+ $ = cheerio.load(data);
369
+
370
+ const imgs = $("img").map((i, el) => ({
371
+ imagePath: $(el).attr("src"),
372
+ imageTitle: $(el).attr("alt")
373
+ })).toArray();
374
+
375
+ results(imgs);
376
+ } catch (err) { failed(err); }
377
+ };
378
+
379
+ const metadata = async ({results, failed}) => {
380
+ try {
381
+ const { data } = await scraping.get(url);
382
+ $ = cheerio.load(data);
383
+
384
+ const metadataList = $("meta").map((i, el) => ({
385
+ metaInfo: $(el).attr("name"),
386
+ metaContent: $(el).attr("content")
387
+ })).toArray()
388
+ .filter(({ metaInfo }) => metaInfo !== undefined);
389
+
390
+ results(metadataList);
391
+ } catch (err) { failed(err); }
392
+ };
393
+
394
+ const headings = async ({results, failed}) => {
395
+ try {
396
+ const { data } = await scraping.get(url);
397
+ $ = cheerio.load(data);
398
+
399
+ const headingList = $("h1, h2, h3, h4, h5, h6").map((i, el) => ({
400
+ headingTag: $(el).prop("tagName"),
401
+ headingText: $(el).text()
402
+ })).toArray();
403
+
404
+ results(headingList);
405
+ } catch (err) { failed(err); }
406
+ };
407
+
408
+ const table_heading = async ({results, failed}) => {
409
+ try {
410
+ const { data } = await scraping.get(url);
411
+ $ = cheerio.load(data);
412
+
413
+ const tableHeadList = $("th").map((i, el) => ({
414
+ headingRow: i,
415
+ text: $(el).text()
416
+ })).toArray();
417
+
418
+ results(tableHeadList);
419
+ } catch (err) { failed(err); }
420
+ };
421
+
422
+ const table_data = async ({results, failed}) => {
423
+ try {
424
+ const { data } = await scraping.get(url);
425
+ $ = cheerio.load(data);
426
+
427
+ const tableColumnList = $("td").map((i, el) => $(el).text()).toArray();
428
+
429
+ results(tableColumnList);
430
+ } catch (err) { failed(err); }
431
+ };
432
+
433
+
434
+ const links = async ({results, failed}) => {
435
+ try {
436
+ const { data } = await scraping.get(url);
437
+ $ = cheerio.load(data);
438
+
439
+ const linkList = $("a").map((i, el) => ({
440
+ url: $(el).attr("href"),
441
+ text: $(el).text()
442
+ })).toArray()
443
+ .filter(({ url }) => url.indexOf("#") !== 0);
444
+
445
+ results(linkList);
446
+ } catch (err) { failed(err); }
447
+ };
448
+
449
+ const cites = async ({results, failed}) => {
450
+ try {
451
+ const { data } = await scraping.get(url);
452
+ $ = cheerio.load(data);
453
+
454
+ const citeList = $("q, blockquote").map((i, el) => ({
455
+ citeTag: $(el).prop("tagName"),
456
+ citeLink: $(el).attr("cite"),
457
+ citeText: $(el).text()
458
+ })).toArray();
459
+
460
+ results(citeList);
461
+ } catch (err) { failed(err); }
462
+ };
463
+
464
+ return {
465
+ title,
466
+ images,
467
+ metadata,
468
+ headings,
469
+ table_heading,
470
+ table_data,
471
+ links,
472
+ cites
473
+ };
454
474
  }
455
475
 
476
+ const password = () => {
477
+ const chars = "0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()ABCDEFGHIJKLMNOPQRSTUVWXYZ";
478
+
479
+ // blank password var
480
+ let password = "";
481
+
482
+ // loop generate chars
483
+ for(let i = 0; i < 12; i++) {
484
+ const randomNumber = Math.floor(Math.random() * chars.length);
485
+
486
+ password += chars.substring(randomNumber, randomNumber + 1);
487
+ }
488
+
489
+ // print new passwors
490
+ return password;
491
+ };
492
+
456
493
  // exports
457
494
  export {
458
495
  animeSearch,
@@ -470,5 +507,7 @@ export {
470
507
  multipleStack,
471
508
  pageSpeed,
472
509
  singleStack,
473
- twitchInfo
510
+ twitchInfo,
511
+ scrape,
512
+ password
474
513
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stack-analyze",
3
- "version": "1.1.7",
3
+ "version": "1.2.0",
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": "index.mjs",
@@ -14,35 +14,35 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "axios": "^0.26.0",
18
- "cli-progress": "^3.10.0",
19
- "coingecko-api": "^1.0.10",
17
+ "axios": "^0.27.2",
18
+ "cheerio": "^1.0.0-rc.12",
19
+ "cli-progress": "^3.11.2",
20
20
  "colors": "^1.4.0",
21
- "console-table-printer": "^2.10.0",
21
+ "console-table-printer": "^2.11.1",
22
22
  "figlet": "^1.5.2",
23
- "inquirer": "^8.2.0",
24
- "systeminformation": "^5.11.6",
23
+ "inquirer": "^9.1.1",
24
+ "systeminformation": "^5.12.6",
25
25
  "timeago.js": "^4.0.2",
26
- "wappalyzer": "^6.10.17"
26
+ "wappalyzer": "^6.10.39"
27
27
  },
28
28
  "devDependencies": {
29
- "eslint": "^8.10.0",
30
- "gh-pages": "^3.2.3",
31
- "jest": "^27.5.1",
32
- "jsdoc": "^3.6.10",
29
+ "eslint": "^8.23.0",
30
+ "gh-pages": "^4.0.0",
31
+ "jest": "^29.0.1",
32
+ "jsdoc": "^3.6.11",
33
33
  "minami": "^1.2.3"
34
34
  },
35
35
  "scripts": {
36
36
  "start": "node cli.js",
37
37
  "test": "jest",
38
- "lint:test": "eslint . --ext .js",
39
- "lint:fix": "eslint . --ext .js --fix",
38
+ "lint:test": "eslint . --ext .js,.cjs,.mjs",
39
+ "lint:fix": "eslint . --ext .js,.cjs,.mjs --fix",
40
40
  "docs": "jsdoc -c jsdoc.json",
41
41
  "docs:deploy": "npm run docs && gh-pages -d docs"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",
45
- "url": "git+https://github.com/intermachine-developers/stack-analyze.git"
45
+ "url": "git+https://github.com/stack-analyze/stack-analyze.git"
46
46
  },
47
47
  "keywords": [
48
48
  "cli",
@@ -58,12 +58,12 @@
58
58
  "crypto market info",
59
59
  "movie info"
60
60
  ],
61
- "author": "Intermachine Developers",
61
+ "author": "stack-analyze",
62
62
  "license": "MIT",
63
63
  "bugs": {
64
- "url": "https://github.com/intermachine-developers/stack-analyze/issues"
64
+ "url": "https://github.com/stack-analyze/stack-analyze/issues"
65
65
  },
66
- "homepage": "https://intermachine-developers.github.io/stack-analyze/",
66
+ "homepage": "https://stack-analyze.github.io/stack-analyze/",
67
67
  "directories": {
68
68
  "doc": "docs",
69
69
  "test": "test"
package/readme.md CHANGED
@@ -12,16 +12,47 @@
12
12
 
13
13
  cli tech stack analyze with **node.js** using the wappalyzer and google pagespeed api the module this node external module or install.
14
14
 
15
- use the cli program install
15
+ ## use the cli program install
16
+
17
+ ## cli module
18
+ ``` sh
19
+ # old npm mode
20
+ npm i -g stack-analyze
21
+
22
+ # new npm mode
23
+ npm i --location=global
24
+
25
+ # if using global install
26
+ stack-analyze
27
+
28
+ # portable
29
+ npx stack-analyze
30
+ ```
31
+
32
+ ## module
33
+
34
+ ``` sh
35
+ npm i stack-analyze
36
+ ```
37
+
38
+ ``` js
39
+ // cjs
40
+ const stackAnalyze = require('stack-analyze') // full
41
+ const { password } = require('stack-analyze') // destructuring
42
+
43
+ // esm
44
+ import stackAnalyze from 'stack-analyze' // full
45
+ import { password } from 'stack-analyze' // destructuring
46
+
47
+ // examples
48
+ password()
49
+ ```
16
50
 
17
- ## example module
18
- >npx stack-analyze "using external without install"<br>
19
- >npm i -g stack-analyze "global install"<br>
20
51
  >note: if global install fail using npx
21
52
 
22
- [github repo](https://github.com/intermachine-developers/stack-analyze.git)
53
+ [github repo](https://github.com/stack-analyze/stack-analyze.git)
23
54
 
24
- [docs](https://intermachine-developers.github.io/stack-analyze)
55
+ [docs](https://stack-analyze.github.io/stack-analyze/)
25
56
 
26
57
  [gitlab repo](https://gitlab.com/Intermachine-dev/stack-analyze)
27
58
 
@@ -29,4 +60,4 @@ use the cli program install
29
60
  - [changelog module](/CHANGELOG.md)
30
61
  ## author this project Julian David Cordoba Torres as omega5300
31
62
 
32
- **Intermachine Developers LICENSE MIT**
63
+ **stack-analyze LICENSE MIT**
package/utils.js ADDED
@@ -0,0 +1,15 @@
1
+ const listFormat = new Intl.ListFormat("en", {
2
+ style: "short",
3
+ type: "conjunction"
4
+ });
5
+
6
+ const currency = Intl.NumberFormat("en-us", {
7
+ style: "currency",
8
+ currency: "USD"
9
+ });
10
+
11
+ export {
12
+ listFormat,
13
+ currency
14
+ };
15
+
package/env/bitly.env.js DELETED
@@ -1 +0,0 @@
1
- process.env.BITLY_TOKEN = "efeac58916c768e4ae6ad22fe31b601361f71886";
package/env/movie.env.js DELETED
@@ -1 +0,0 @@
1
- process.env.MOVIE_CODE= "6bd534c04a4246666a68080da99bb105";
@@ -1 +0,0 @@
1
- process.env.CLIENT_ID = "am096eog80r416605ka34uzq8b5614";
package/hash/aboutOpts.js DELETED
@@ -1,53 +0,0 @@
1
- // print table
2
- import { printTable } from "console-table-printer";
3
-
4
- // tables models
5
- import {
6
- youtubeDevTable,
7
- ideasTable
8
- } from "../models/aboutTables.js";
9
-
10
- // about sections
11
- import {
12
- aboutApp,
13
- developers,
14
- twitch,
15
- projects,
16
- ideas,
17
- youtubeDev
18
- } from "../about.js";
19
-
20
- /** @type {{ main_info(): void, lineup(): void, youtube_recomendation(): void, twitch_recomendation(): void, projects_recomendation(): void, tools_ideas(): void }} */
21
- const aboutTool = {
22
- main_info() {
23
- console.clear();
24
- console.table(aboutApp);
25
- },
26
- lineup() {
27
- console.clear();
28
- printTable(developers.map((dev, i) => ({ index: i + 1, dev })));
29
- },
30
- youtube_recomendation() {
31
- console.clear();
32
- youtubeDevTable.addRows(youtubeDev);
33
- youtubeDevTable.printTable();
34
- },
35
- twitch_recomendation() {
36
- console.clear();
37
- const streamers = twitch.map((streamer, i) => ({ index: i + 1, streamer }));
38
- printTable(streamers);
39
- },
40
- projects_recomendation() {
41
- console.clear();
42
- const proyectsReccomend = projects.map((project, i) => ({ index: i + 1, project }));
43
- printTable(proyectsReccomend);
44
- },
45
- tools_ideas() {
46
- console.clear();
47
- ideasTable.addRows(ideas);
48
- ideasTable.printTable();
49
- }
50
- };
51
-
52
- // export hash
53
- export default aboutTool;