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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // modules
2
- import axios from "axios";
2
+ import {default as axios} from "axios";
3
3
  import CoinGecko from "coingecko-api";
4
4
  import {
5
5
  cpu,
@@ -11,48 +11,7 @@ import {
11
11
  } from "systeminformation";
12
12
  import Wappalyzer from "wappalyzer";
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 }) => {
56
15
  /* error manager */
57
16
  try {
58
17
  // call api
@@ -68,10 +27,6 @@ const CoinGeckoClient = new CoinGecko();
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(
@@ -91,29 +46,23 @@ const bitlyInfo = async ({ link, token, results }) => {
91
46
  } catch (err) { results(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
49
  const cryptoMarket = async (callback) => {
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);
62
+ callback(data);
109
63
  } catch (err) { callback(err); }
110
64
  };
111
65
 
112
- /**
113
- *
114
- * @param {github} {user, results}
115
- * @returns {Promise<void>}
116
- */
117
66
  async function githubInfo({ user, results }) {
118
67
  try {
119
68
  const { data } = await axios.get(`https://api.github.com/users/${user}`);
@@ -122,11 +71,6 @@ async function githubInfo({ user, results }) {
122
71
  } catch (err) { results(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,10 +226,6 @@ 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
229
  const movieDB = async ({ api_key, query, results }) => {
320
230
  try {
321
231
  const { data } = await axios.get("https://api.themoviedb.org/3/search/movie", {
@@ -353,10 +263,6 @@ const movieDB = async ({ api_key, query, results }) => {
353
263
  } catch (err) { results(err); }
354
264
  };
355
265
 
356
- /**
357
- * @param {multiple} {urls, results}
358
- * @returns {Promise<void>}
359
- */
360
266
  async function multipleStack({ urls, results }) {
361
267
  let result;
362
268
  const wappalyzer = new Wappalyzer();
@@ -376,10 +282,6 @@ async function multipleStack({ urls, results }) {
376
282
  results(result);
377
283
  }
378
284
 
379
- /**
380
- * @param {stack} {url, results}
381
- * @returns {Promise<void>}
382
- */
383
285
  const pageSpeed = async ({ url, results }) => {
384
286
  try {
385
287
  const resMobile = await axios.get("https://www.googleapis.com/pagespeedonline/v5/runPagespeed", {
@@ -406,10 +308,6 @@ const pageSpeed = async ({ url, results }) => {
406
308
  } catch (err) { results(err); }
407
309
  };
408
310
 
409
- /**
410
- * @param {stack} {url, results}
411
- * @returns {Promise<void>}
412
- */
413
311
  async function singleStack({ url, results }) {
414
312
  const wappalyzer = await new Wappalyzer;
415
313
 
@@ -434,11 +332,6 @@ async function singleStack({ url, results }) {
434
332
  results(result);
435
333
  }
436
334
 
437
- /**
438
- *
439
- * @param {twitch} { query, token, clientID, results }
440
- * @returns {Promise<void>}
441
- */
442
335
  async function twitchInfo({ query, token, clientID, results }) {
443
336
  try {
444
337
  const { data: twitchData } = await axios.get(`https://api.twitch.tv/helix/users?login=${query}`,
@@ -453,6 +346,134 @@ async function twitchInfo({ query, token, clientID, results }) {
453
346
  } catch (err) { results(err); }
454
347
  }
455
348
 
349
+ function scrape(url) {
350
+ let $;
351
+
352
+ const scraping = axios.create({
353
+ baseURL: url
354
+ });
355
+
356
+ const title = async (callback) => {
357
+ try {
358
+ const { data } = await scraping.get("");
359
+ $ = load(data);
360
+
361
+ callback($("title").text());
362
+ } catch (err) { console.error(colors.red(err.message)); }
363
+ };
364
+
365
+ const images = async (callback) => {
366
+ try {
367
+ const { data } = await scraping.get("");
368
+ $ = load(data);
369
+
370
+ const imgs = $("img").map((i, el) => ({
371
+ imagePath: $(el).attr("src"),
372
+ imageTitle: $(el).attr("alt")
373
+ })).toArray();
374
+
375
+ callback(imgs);
376
+ } catch (err) { console.error(colors.red(err.message)); }
377
+ };
378
+
379
+ const metadata = async (callback) => {
380
+ try {
381
+ const { data } = await scraping.get("");
382
+ $ = 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
+ callback(metadataList);
391
+ } catch (err) { console.error(colors.red(err.message)); }
392
+ };
393
+
394
+ const headings = async (callback) => {
395
+ try {
396
+ const { data } = await scraping.get("");
397
+ $ = 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
+ callback(headingList);
405
+ } catch (err) { console.error(colors.red(err.message)); }
406
+ };
407
+
408
+ const table_heading = async (callback) => {
409
+ try {
410
+ const { data } = await scraping.get("");
411
+ $ = load(data);
412
+
413
+ const tableHeadList = $("th").map((i, el) => ({
414
+ headingRow: i,
415
+ text: $(el).text()
416
+ })).toArray();
417
+
418
+ callback(tableHeadList);
419
+ } catch (err) { console.error(colors.red(err.message)); }
420
+ };
421
+
422
+ const table_data = async (callback) => {
423
+ try {
424
+ const { data } = await scraping.get("");
425
+ $ = load(data);
426
+
427
+ const tableColumnList = $("td").map((i, el) => $(el).text()).toArray();
428
+
429
+ callback(tableColumnList);
430
+ } catch (err) { console.error(colors.red(err.message)); }
431
+ };
432
+
433
+
434
+ const links = async (callback) => {
435
+ try {
436
+ const { data } = await scraping.get("");
437
+ $ = 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
+ callback(linkList);
446
+ } catch (err) { console.error(colors.red(err.message)); }
447
+ };
448
+
449
+ const cites = async (callback) => {
450
+ try {
451
+ const { data } = await scraping.get("");
452
+ $ = 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
+ callback(citeList);
461
+ } catch (err) { console.error(colors.red(err.message)); }
462
+ };
463
+
464
+ return {
465
+ title,
466
+ images,
467
+ metadata,
468
+ headings,
469
+ table_heading,
470
+ table_data,
471
+ links,
472
+ cites
473
+ };
474
+ }
475
+
476
+
456
477
  // exports
457
478
  export {
458
479
  animeSearch,
@@ -470,5 +491,6 @@ export {
470
491
  multipleStack,
471
492
  pageSpeed,
472
493
  singleStack,
473
- twitchInfo
494
+ twitchInfo,
495
+ scrape
474
496
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stack-analyze",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
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",
@@ -15,19 +15,20 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "axios": "^0.27.2",
18
- "cli-progress": "^3.11.0",
18
+ "cheerio": "^1.0.0-rc.12",
19
+ "cli-progress": "^3.11.2",
19
20
  "colors": "^1.4.0",
20
21
  "console-table-printer": "^2.11.0",
21
22
  "figlet": "^1.5.2",
22
- "inquirer": "^8.2.4",
23
- "systeminformation": "^5.11.14",
23
+ "inquirer": "^9.0.0",
24
+ "systeminformation": "^5.11.22",
24
25
  "timeago.js": "^4.0.2",
25
- "wappalyzer": "^6.10.26"
26
+ "wappalyzer": "^6.10.37"
26
27
  },
27
28
  "devDependencies": {
28
- "eslint": "^8.15.0",
29
- "gh-pages": "^3.2.3",
30
- "jest": "^28.1.0",
29
+ "eslint": "^8.18.0",
30
+ "gh-pages": "^4.0.0",
31
+ "jest": "^28.1.2",
31
32
  "jsdoc": "^3.6.10",
32
33
  "minami": "^1.2.3"
33
34
  },
package/readme.md CHANGED
@@ -15,8 +15,16 @@ cli tech stack analyze with **node.js** using the wappalyzer and google pagespee
15
15
  use the cli program install
16
16
 
17
17
  ## example module
18
- >npx stack-analyze "using external without install"<br>
19
- >npm i -g stack-analyze "global install"<br>
18
+ ``` sh
19
+ # global old npm versions
20
+ npm i -g stack-analyze
21
+
22
+ # global new module
23
+ npm i --location=global
24
+
25
+ # portable
26
+ npx stack-analyze
27
+ ```
20
28
  >note: if global install fail using npx
21
29
 
22
30
  [github repo](https://github.com/stack-analyze/stack-analyze.git)
@@ -29,4 +37,4 @@ use the cli program install
29
37
  - [changelog module](/CHANGELOG.md)
30
38
  ## author this project Julian David Cordoba Torres as omega5300
31
39
 
32
- **Intermachine Developers LICENSE MIT**
40
+ **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
+
@@ -1,4 +0,0 @@
1
- {
2
- "docwriter.progress.trackFunctions": true,
3
- "docwriter.progress.trackMethods": false
4
- }
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;
@@ -1,47 +0,0 @@
1
- // hardware modules
2
- import {
3
- cpuInfo,
4
- ramMemInfo,
5
- osDetail,
6
- diskInfo,
7
- controllerInfo,
8
- displayInfo,
9
- biosInfo
10
- } from "../functions/hardware.js";
11
-
12
- /**
13
- * @type {{ cpu(): void, ram_memory(): void, os(): void, disk(): void, controller(): void, display(): void, bios(): void }}
14
- */
15
- const hardwareTools = {
16
- cpu() {
17
- console.clear();
18
- cpuInfo();
19
- },
20
- ram_memory() {
21
- console.clear();
22
- ramMemInfo();
23
- },
24
- os() {
25
- console.clear();
26
- osDetail();
27
- },
28
- disk() {
29
- console.clear();
30
- diskInfo();
31
- },
32
- controller() {
33
- console.clear();
34
- controllerInfo();
35
- },
36
- display() {
37
- console.clear();
38
- displayInfo();
39
- },
40
- bios() {
41
- console.clear();
42
- biosInfo();
43
- }
44
- };
45
-
46
- // exports
47
- export default hardwareTools;
@@ -1,40 +0,0 @@
1
- // table model module
2
- import { Table } from "console-table-printer";
3
-
4
- // youtube model
5
- const youtubeDevTable = new Table({
6
- columns: [
7
- {
8
- name: "youtubeChannel",
9
- alignment: "left",
10
- color: "green"
11
- },
12
- {
13
- name: "recomendation",
14
- alignment: "left",
15
- color: "cyan"
16
- }
17
- ]
18
- });
19
-
20
- // ideas model
21
- const ideasTable = new Table({
22
- columns: [
23
- {
24
- name: "author",
25
- alignment: "left",
26
- color: "green"
27
- },
28
- {
29
- name: "tool",
30
- alignment: "left",
31
- color: "green"
32
- }
33
- ]
34
- });
35
-
36
- // exports tables
37
- export {
38
- youtubeDevTable,
39
- ideasTable
40
- };
@@ -1,33 +0,0 @@
1
- import { Table } from "console-table-printer";
2
-
3
- const animeList = new Table({
4
- columns: [
5
- {
6
- name: "title",
7
- alignment: "left",
8
- color: "green"
9
- },
10
- {
11
- name: "type",
12
- alignment: "left",
13
- color: "magenta"
14
- },
15
- {
16
- name: "episodes",
17
- alignment: "left",
18
- color: "magenta"
19
- },
20
- {
21
- name: "debutDate",
22
- alignment: "left",
23
- color: "magenta"
24
- },
25
- {
26
- name: "finalDate",
27
- alignment: "left",
28
- color: "green"
29
- }
30
- ]
31
- });
32
-
33
- export default animeList;
@@ -1,32 +0,0 @@
1
- import { Table } from "console-table-printer";
2
-
3
- const coinTable = new Table({
4
- columns: [
5
- {
6
- name: "symbol",
7
- alignment: "left",
8
- color: "green"
9
- },
10
- {
11
- name: "name",
12
- alignment: "left",
13
- color: "white_bold"
14
- },
15
- {
16
- name: "price",
17
- alignment: "left",
18
- color: "yellow"
19
- },
20
- {
21
- name: "priceChanged",
22
- alignment: "left"
23
- },
24
- {
25
- name: "lastUpdated",
26
- alignment: "left",
27
- color: "magenta"
28
- }
29
- ]
30
- });
31
-
32
- export default coinTable;