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.
@@ -1,41 +1,41 @@
1
- // modules
2
- import axios from "axios";
3
- import { format } from "timeago.js";
4
- import colors from "colors";
5
-
6
- // save bitly
7
- import { stackSave } from "../utils.js";
8
-
9
- /**
10
- *
11
- * @description call the bitly info data
12
- * @async
13
- * @param { string } link - link for search info
14
- * @param { string } token - bitly api token is required
15
- * @returns { Promise<void> } - return results serach
16
- *
17
- */
18
- export default async function bitlyInfo(link, token) {
19
- try {
20
- const { data } = await axios.post(
21
- "https://api-ssl.bitly.com/v4/expand",
22
- { bitlink_id: link },
23
- {
24
- headers: {
25
- Authorization: `Bearer ${token}`,
26
- "Content-Type": "application/json"
27
- }
28
- }
29
- );
30
-
31
- console.table({
32
- created_link: format(data.created_at),
33
- bitly_link: data.link,
34
- link: data.long_url
35
- });
36
-
37
- stackSave("bitly.json", JSON.stringify(data, null, 2));
38
- } catch (err) {
39
- console.error(colors.red(err.message));
40
- }
41
- }
1
+ // modules
2
+ import axios from "axios";
3
+ import { format } from "timeago.js";
4
+ import colors from "colors";
5
+
6
+ // save bitly
7
+ import { stackSave } from "../utils.js";
8
+
9
+ /**
10
+ *
11
+ * @description call the bitly info data
12
+ * @async
13
+ * @param { string } link - link for search info
14
+ * @param { string } token - bitly api token is required
15
+ * @returns { Promise<void> } - return results serach
16
+ *
17
+ */
18
+ export default async function bitlyInfo(link, token) {
19
+ try {
20
+ const { data } = await axios.post(
21
+ "https://api-ssl.bitly.com/v4/expand",
22
+ { bitlink_id: link },
23
+ {
24
+ headers: {
25
+ Authorization: `Bearer ${token}`,
26
+ "Content-Type": "application/json"
27
+ }
28
+ }
29
+ );
30
+
31
+ console.table({
32
+ created_link: format(data.created_at),
33
+ bitly_link: data.link,
34
+ link: data.long_url
35
+ });
36
+
37
+ stackSave("bitly.json", JSON.stringify(data, null, 2));
38
+ } catch (err) {
39
+ console.error(colors.red(err.message));
40
+ }
41
+ }
@@ -1,36 +1,36 @@
1
- import axios from "axios";
2
- import colors from "colors";
3
- import { stackSave } from "../utils.js";
4
-
5
- /**
6
- * @description kilobyte convert for bundlephobia pkg info
7
- * @param {number} size - pkg sixe
8
- * @returns {string} - result converter
9
- */
10
- const kilobyteConvert = (size) => (size < 1024 ? `${size} B` : `${size / 1024} KB`);
11
-
12
- /**
13
- * @description get info of npm package
14
- * @param {string} pkg
15
- * @async
16
- * @returns { Promise<void> } - return result bundlephobia info
17
- */
18
- export default async function bundlephobia (pkg) {
19
- try {
20
- const { data } = await axios.get("https://bundlephobia.com/api/size", {
21
- params: { package: pkg }
22
- });
23
-
24
- console.table({
25
- module_name: data.name,
26
- module_version: data.version,
27
- module_repo: data.repository,
28
- module_size: kilobyteConvert(data.size),
29
- module_gzip: kilobyteConvert(data.gzip),
30
- });
31
-
32
- stackSave(`${pkg}-pkg-info.json`, JSON.stringify(data, null, 2));
33
- } catch (err) {
34
- console.error(colors.red(err.message));
35
- }
36
- }
1
+ import axios from "axios";
2
+ import colors from "colors";
3
+ import { stackSave } from "../utils.js";
4
+
5
+ /**
6
+ * @description kilobyte convert for bundlephobia pkg info
7
+ * @param {number} size - pkg sixe
8
+ * @returns {string} - result converter
9
+ */
10
+ const kilobyteConvert = (size) => (size < 1024 ? `${size} B` : `${size / 1024} KB`);
11
+
12
+ /**
13
+ * @description get info of npm package
14
+ * @param {string} pkg
15
+ * @async
16
+ * @returns { Promise<void> } - return result bundlephobia info
17
+ */
18
+ export default async function bundlephobia (pkg) {
19
+ try {
20
+ const { data } = await axios.get("https://bundlephobia.com/api/size", {
21
+ params: { package: pkg }
22
+ });
23
+
24
+ console.table({
25
+ module_name: data.name,
26
+ module_version: data.version,
27
+ module_repo: data.repository,
28
+ module_size: kilobyteConvert(data.size),
29
+ module_gzip: kilobyteConvert(data.gzip),
30
+ });
31
+
32
+ stackSave(`${pkg}-pkg-info.json`, JSON.stringify(data, null, 2));
33
+ } catch (err) {
34
+ console.error(colors.red(err.message));
35
+ }
36
+ }
@@ -1,48 +1,48 @@
1
- // modules
2
- import axios from "axios";
3
- import { format } from "timeago.js";
4
- import colors from "colors";
5
-
6
- import { printTable } from "console-table-printer";
7
-
8
- // currency format
9
- import { currency, stackSave } from "../utils.js";
10
-
11
- /**
12
- * @descripiton call the crypto market list
13
- * @async
14
- * @returns { Promise<void> } - return results search
15
- */
16
- export default async function cryptoMarket() {
17
- try {
18
- // start crypto
19
- const { data } = await axios.get(
20
- "https://api.coingecko.com/api/v3/coins/markets", {
21
- params: { vs_currency: "usd" }
22
- }
23
- );
24
-
25
- // map coinData
26
- const coinList = data.map(({
27
- symbol,
28
- name,
29
- current_price,
30
- price_change_percentage_24h,
31
- last_updated
32
- }) => ({
33
- symbol,
34
- name,
35
- price: currency.format(current_price),
36
- priceChanged: `${price_change_percentage_24h.toFixed(2)} %`,
37
- lastUpdated: format(last_updated)
38
- }));
39
-
40
- // print table
41
- printTable(coinList.slice(0, 10));
42
-
43
- stackSave("crypto-list.json", JSON.stringify(coinList, null, 2));
44
- } catch (err) {
45
- // print err message
46
- console.error(colors.red(err.message));
47
- }
48
- }
1
+ // modules
2
+ import axios from "axios";
3
+ import { format } from "timeago.js";
4
+ import colors from "colors";
5
+
6
+ import { printTable } from "console-table-printer";
7
+
8
+ // currency format
9
+ import { currency, stackSave } from "../utils.js";
10
+
11
+ /**
12
+ * @descripiton call the crypto market list
13
+ * @async
14
+ * @returns { Promise<void> } - return results search
15
+ */
16
+ export default async function cryptoMarket() {
17
+ try {
18
+ // start crypto
19
+ const { data } = await axios.get(
20
+ "https://api.coingecko.com/api/v3/coins/markets", {
21
+ params: { vs_currency: "usd" }
22
+ }
23
+ );
24
+
25
+ // map coinData
26
+ const coinList = data.map(({
27
+ symbol,
28
+ name,
29
+ current_price,
30
+ price_change_percentage_24h,
31
+ last_updated
32
+ }) => ({
33
+ symbol,
34
+ name,
35
+ price: currency.format(current_price),
36
+ priceChanged: `${price_change_percentage_24h.toFixed(2)} %`,
37
+ lastUpdated: format(last_updated)
38
+ }));
39
+
40
+ // print table
41
+ printTable(coinList.slice(0, 10));
42
+
43
+ stackSave("crypto-list.json", JSON.stringify(coinList, null, 2));
44
+ } catch (err) {
45
+ // print err message
46
+ console.error(colors.red(err.message));
47
+ }
48
+ }
@@ -1,25 +1,25 @@
1
- // modules
2
- import colors from "colors";
3
- import cssValidator from "w3c-css-validator";
4
- import { stackSave } from "../utils.js";
5
-
6
- /**
7
- * @description css validator tool from w3c service
8
- * @param {string} url - url analyze all stylesheets
9
- * @async
10
- * @returns {Promise<void>}
11
- */
12
- export default async function cssValidate(url) {
13
- try {
14
- const cssResults = await cssValidator.validateURL(url, {
15
- warningLevel: 1
16
- });
17
-
18
- stackSave("cssErrors.json", JSON.stringify(cssResults.errors, null, 2));
19
- stackSave("cssWarnings.json", JSON.stringify(cssResults.warnings, null, 2));
20
-
21
- console.info("finish css results printers".green);
22
- } catch(err) {
23
- console.error(colors.red(err.message));
24
- }
25
- }
1
+ // modules
2
+ import colors from "colors";
3
+ import cssValidator from "w3c-css-validator";
4
+ import { stackSave } from "../utils.js";
5
+
6
+ /**
7
+ * @description css validator tool from w3c service
8
+ * @param {string} url - url analyze all stylesheets
9
+ * @async
10
+ * @returns {Promise<void>}
11
+ */
12
+ export default async function cssValidate(url) {
13
+ try {
14
+ const cssResults = await cssValidator.validateURL(url, {
15
+ warningLevel: 1
16
+ });
17
+
18
+ stackSave("cssErrors.json", JSON.stringify(cssResults.errors, null, 2));
19
+ stackSave("cssWarnings.json", JSON.stringify(cssResults.warnings, null, 2));
20
+
21
+ console.info("finish css results printers".green);
22
+ } catch(err) {
23
+ console.error(colors.red(err.message));
24
+ }
25
+ }
@@ -1,37 +1,37 @@
1
- import axios from "axios";
2
- import { printTable } from "console-table-printer";
3
- import colors from "colors";
4
-
5
- // save data search
6
- import { stackSave } from "../utils.js";
7
-
8
- /**
9
- * @async
10
- * @params { string } query
11
- * @returns {Promise<void>}
12
- */
13
- export default async function deezer(q) {
14
- try {
15
- const { data } = await axios.get("https://api.deezer.com/search/album", {
16
- params: { q }
17
- });
18
-
19
- const results = data.data.map(({
20
- id, title, record_type,
21
- explicit_lyrics, artist, nb_tracks
22
- }) => ({
23
- id,
24
- artist: artist.name,
25
- title,
26
- type: record_type,
27
- num_tracks: nb_tracks,
28
- lyrics_content: explicit_lyrics ? "explicit" : "clean"
29
- }));
30
-
31
- printTable(results.slice(0, 15));
32
-
33
- stackSave("album-search.json", JSON.stringify(data.data, null, 2));
34
- } catch(err) {
35
- console.error(colors.red(err.message));
36
- }
37
- }
1
+ import axios from "axios";
2
+ import { printTable } from "console-table-printer";
3
+ import colors from "colors";
4
+
5
+ // save data search
6
+ import { stackSave } from "../utils.js";
7
+
8
+ /**
9
+ * @async
10
+ * @params { string } query
11
+ * @returns {Promise<void>}
12
+ */
13
+ export default async function deezer(q) {
14
+ try {
15
+ const { data } = await axios.get("https://api.deezer.com/search/album", {
16
+ params: { q }
17
+ });
18
+
19
+ const results = data.data.map(({
20
+ id, title, record_type,
21
+ explicit_lyrics, artist, nb_tracks
22
+ }) => ({
23
+ id,
24
+ artist: artist.name,
25
+ title,
26
+ type: record_type,
27
+ num_tracks: nb_tracks,
28
+ lyrics_content: explicit_lyrics ? "explicit" : "clean"
29
+ }));
30
+
31
+ printTable(results.slice(0, 15));
32
+
33
+ stackSave("album-search.json", JSON.stringify(data.data, null, 2));
34
+ } catch(err) {
35
+ console.error(colors.red(err.message));
36
+ }
37
+ }
@@ -1,24 +1,25 @@
1
- // colors module
2
- import colors from "colors";
3
-
4
- // url api
5
- import { wallpapersURL } from "../api/wallpapersURL.js";
6
-
7
- // save file
8
- import { stackSave } from "../utils.js";
9
-
10
- /**
11
- * sol, moon wallpapers downloader
12
- * @async
13
- * @param {"sol-moon" | "dimensions" | "seyyahi"} opt
14
- * @param {string} filename
15
- * @returns {Promise<void>}
16
- */
17
- export const wallpaperDownload = async (opt, filename) => {
18
- try {
19
- const { data } = await wallpapersURL.get(`/${opt}/download/${filename}`);
20
- stackSave(filename, data);
21
- } catch(err) {
22
- console.error(colors.red(err.message));
23
- }
24
- };
1
+ // core modules
2
+ import { writeFile } from "node:fs/promises";
3
+
4
+ // colors module
5
+ import colors from "colors";
6
+
7
+ // url api
8
+ import { wallpapersURL } from "../api/wallpapersURL.js";
9
+
10
+ /**
11
+ * sol, moon wallpapers downloader
12
+ * @async
13
+ * @param {"sol-moon" | "dimensions" | "seyyahi2" | "ancient-mistery" | "tsuky-no-emily"} opt
14
+ * @param {string} filename
15
+ * @returns {Promise<void>}
16
+ */
17
+ export const wallpaperDownload = async (opt, filename) => {
18
+ try {
19
+ const { data } = await wallpapersURL.get(`/${opt}/download/${filename}`);
20
+
21
+ writeFile(filename, data, {encoding: "base64"});
22
+ } catch (err) {
23
+ console.error(colors.red(err.message));
24
+ }
25
+ };
@@ -1,37 +1,37 @@
1
- // modules
2
- import { format } from "timeago.js";
3
- import colors from "colors";
4
-
5
- // save git user
6
- import { stackSave } from "../utils.js";
7
-
8
- /**
9
- *
10
- * @description call github info user
11
- * @async
12
- * @param { string } user - get github user info
13
- * @returns { Promise<void> } - return results info
14
- *
15
- */
16
- export default async function githubInfo(user) {
17
- try {
18
- const data = await (await fetch(`https://api.github.com/users/${user}`)).json();
19
-
20
- const info = {
21
- username: data.login,
22
- fullName: data?.name ?? "no info",
23
- userFollowers: data.followers,
24
- userFollowing: data.following,
25
- accountAge: format(data.created_at),
26
- twitter: data?.twitter_username ?? "no info",
27
- repos: data.public_repos,
28
- gists: data.public_gists
29
- };
30
-
31
- console.table(info);
32
-
33
- stackSave(`${user}-info.json`, JSON.stringify(info, null, 2));
34
- } catch(err) {
35
- console.error(colors.red(err.message));
36
- }
37
- }
1
+ // modules
2
+ import { format } from "timeago.js";
3
+ import colors from "colors";
4
+
5
+ // save git user
6
+ import { stackSave } from "../utils.js";
7
+
8
+ /**
9
+ *
10
+ * @description call github info user
11
+ * @async
12
+ * @param { string } user - get github user info
13
+ * @returns { Promise<void> } - return results info
14
+ *
15
+ */
16
+ export default async function githubInfo(user) {
17
+ try {
18
+ const data = await (await fetch(`https://api.github.com/users/${user}`)).json();
19
+
20
+ const info = {
21
+ username: data.login,
22
+ fullName: data?.name ?? "no info",
23
+ userFollowers: data.followers,
24
+ userFollowing: data.following,
25
+ accountAge: format(data.created_at),
26
+ twitter: data?.twitter_username ?? "no info",
27
+ repos: data.public_repos,
28
+ gists: data.public_gists
29
+ };
30
+
31
+ console.table(info);
32
+
33
+ stackSave(`${user}-info.json`, JSON.stringify(info, null, 2));
34
+ } catch(err) {
35
+ console.error(colors.red(err.message));
36
+ }
37
+ }