@stats-organization/github-readme-stats-core 2.1.4 → 2.1.5
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/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +34 -0
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +18 -0
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +17 -0
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +36 -4
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +34 -0
- package/build/calculateRank.d.ts +12 -11
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +18 -18
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +29 -20
- package/build/cards/stats.d.ts +4 -2
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +21 -8
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +39 -11
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +29 -8
- package/build/common/Card.d.ts +9 -3
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +47 -19
- package/build/common/color.d.ts +42 -8
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +62 -13
- package/build/common/html.js +1 -1
- package/build/common/http.d.ts +13 -4
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +3 -3
- package/build/common/languageColors.json +9 -1
- package/build/common/ops.d.ts +30 -29
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +32 -37
- package/build/common/render.d.ts +115 -111
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +138 -87
- package/build/common/retryer.d.ts +14 -6
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +1 -0
- package/build/fetchers/gist.d.ts +6 -21
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +30 -35
- package/build/fetchers/repo.js +1 -1
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +0 -1
- package/build/fetchers/types.d.ts +126 -0
- package/build/fetchers/types.d.ts.map +1 -0
- package/build/fetchers/types.js +1 -0
- package/package.json +4 -4
- package/src/_emoji-name-map.d.ts +10 -0
- package/src/api/gist.js +36 -0
- package/src/api/index.js +19 -0
- package/src/api/pin.js +18 -0
- package/src/api/top-langs.js +38 -4
- package/src/api/wakatime.js +36 -0
- package/src/{calculateRank.js → calculateRank.ts} +29 -19
- package/src/cards/repo.js +30 -20
- package/src/cards/stats.js +22 -8
- package/src/cards/top-languages.js +49 -11
- package/src/cards/wakatime.js +33 -8
- package/src/common/Card.ts +51 -16
- package/src/common/color.ts +85 -22
- package/src/common/html.ts +1 -1
- package/src/common/http.ts +31 -0
- package/src/common/languageColors.json +9 -1
- package/src/common/{ops.js → ops.ts} +48 -50
- package/src/common/{render.js → render.ts} +208 -96
- package/src/common/retryer.ts +18 -10
- package/src/fetchers/gist.ts +136 -0
- package/src/fetchers/repo.js +1 -1
- package/src/fetchers/stats.js +0 -1
- package/src/common/http.js +0 -19
- package/src/fetchers/gist.js +0 -112
- /package/src/fetchers/{types.d.ts → types.ts} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import type { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
3
|
+
|
|
4
|
+
/** Body of a GraphQL request sent to the GitHub API. */
|
|
5
|
+
interface GraphQLRequest {
|
|
6
|
+
/** The GraphQL query. */
|
|
7
|
+
query: string;
|
|
8
|
+
/** Variables referenced by the query. */
|
|
9
|
+
variables: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Send GraphQL request to GitHub API.
|
|
14
|
+
*
|
|
15
|
+
* @param data Request data.
|
|
16
|
+
* @param headers Request headers.
|
|
17
|
+
* @returns Request response.
|
|
18
|
+
*/
|
|
19
|
+
const request = (
|
|
20
|
+
data: GraphQLRequest,
|
|
21
|
+
headers: NonNullable<AxiosRequestConfig["headers"]>,
|
|
22
|
+
): Promise<AxiosResponse> => {
|
|
23
|
+
return axios({
|
|
24
|
+
url: "https://api.github.com/graphql",
|
|
25
|
+
method: "post",
|
|
26
|
+
headers,
|
|
27
|
+
data,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { request };
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"Awk": "#c30e9b",
|
|
45
45
|
"B (Formal Method)": "#8aa8c5",
|
|
46
46
|
"B4X": "#00e4ff",
|
|
47
|
+
"BAML": "#a855f7",
|
|
47
48
|
"BASIC": "#ff0000",
|
|
48
49
|
"BQN": "#2b7067",
|
|
49
50
|
"Ballerina": "#FF5000",
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
"Blade": "#f7523f",
|
|
59
60
|
"BlitzBasic": "#00FFAE",
|
|
60
61
|
"BlitzMax": "#cd6400",
|
|
62
|
+
"Blueprint": "#3584E4",
|
|
61
63
|
"Bluespec": "#12223c",
|
|
62
64
|
"Bluespec BH": "#12223c",
|
|
63
65
|
"Boo": "#d4bec1",
|
|
@@ -69,7 +71,7 @@
|
|
|
69
71
|
"Bru": "#F4AA41",
|
|
70
72
|
"BuildStream": "#006bff",
|
|
71
73
|
"C": "#555555",
|
|
72
|
-
"C#": "#
|
|
74
|
+
"C#": "#7355dd",
|
|
73
75
|
"C++": "#f34b7d",
|
|
74
76
|
"C3": "#2563eb",
|
|
75
77
|
"CAP CDS": "#0092d1",
|
|
@@ -227,6 +229,7 @@
|
|
|
227
229
|
"Graphviz (DOT)": "#2596be",
|
|
228
230
|
"Groovy": "#4298b8",
|
|
229
231
|
"Groovy Server Pages": "#4298b8",
|
|
232
|
+
"GtkRC": "#7fe719",
|
|
230
233
|
"HAProxy": "#106da9",
|
|
231
234
|
"HCL": "#844FBA",
|
|
232
235
|
"HIP": "#4F3A4F",
|
|
@@ -416,6 +419,7 @@
|
|
|
416
419
|
"OpenSCAD": "#e5cd45",
|
|
417
420
|
"Option List": "#476732",
|
|
418
421
|
"Org": "#77aa99",
|
|
422
|
+
"OverPy": "#78b355",
|
|
419
423
|
"OverpassQL": "#cce2aa",
|
|
420
424
|
"Oxygene": "#cdd0e3",
|
|
421
425
|
"Oz": "#fab738",
|
|
@@ -445,10 +449,12 @@
|
|
|
445
449
|
"Portugol": "#f8bd00",
|
|
446
450
|
"PostCSS": "#dc3a0c",
|
|
447
451
|
"PostScript": "#da291c",
|
|
452
|
+
"Power Query": "#d38e0d",
|
|
448
453
|
"PowerBuilder": "#8f0f8d",
|
|
449
454
|
"PowerShell": "#012456",
|
|
450
455
|
"Praat": "#c8506d",
|
|
451
456
|
"Prisma": "#0c344b",
|
|
457
|
+
"Pro*C": "#bb8368",
|
|
452
458
|
"Processing": "#0096D8",
|
|
453
459
|
"Procfile": "#3B2F63",
|
|
454
460
|
"Prolog": "#74283c",
|
|
@@ -490,6 +496,7 @@
|
|
|
490
496
|
"Rebol": "#358a5b",
|
|
491
497
|
"Record Jar": "#0673ba",
|
|
492
498
|
"Red": "#f50000",
|
|
499
|
+
"Redscript": "#f44336",
|
|
493
500
|
"Regular Expression": "#009a00",
|
|
494
501
|
"Ren'Py": "#ff7f7f",
|
|
495
502
|
"Rez": "#FFDAB3",
|
|
@@ -659,6 +666,7 @@
|
|
|
659
666
|
"nanorc": "#2d004d",
|
|
660
667
|
"nesC": "#94B0C7",
|
|
661
668
|
"ooc": "#b0b77e",
|
|
669
|
+
"pkg-config": "#2b5e82",
|
|
662
670
|
"q": "#0040cd",
|
|
663
671
|
"reStructuredText": "#141414",
|
|
664
672
|
"sed": "#64b970",
|
|
@@ -6,10 +6,10 @@ import { CustomError } from "./error.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* Returns boolean if value is either "true" or "false" else the value as it is.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @returns
|
|
9
|
+
* @param value The value to parse.
|
|
10
|
+
* @returns The parsed value.
|
|
11
11
|
*/
|
|
12
|
-
const parseBoolean = (value) => {
|
|
12
|
+
const parseBoolean = (value: string | boolean): boolean | undefined => {
|
|
13
13
|
if (typeof value === "boolean") {
|
|
14
14
|
return value;
|
|
15
15
|
}
|
|
@@ -27,10 +27,10 @@ const parseBoolean = (value) => {
|
|
|
27
27
|
/**
|
|
28
28
|
* Parse string to array of strings.
|
|
29
29
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @returns
|
|
30
|
+
* @param str The string to parse.
|
|
31
|
+
* @returns The array of strings.
|
|
32
32
|
*/
|
|
33
|
-
const parseArray = (str) => {
|
|
33
|
+
const parseArray = (str: string): Array<string> => {
|
|
34
34
|
if (!str) {
|
|
35
35
|
return [];
|
|
36
36
|
}
|
|
@@ -40,47 +40,44 @@ const parseArray = (str) => {
|
|
|
40
40
|
/**
|
|
41
41
|
* Clamp the given number between the given range.
|
|
42
42
|
*
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @returns
|
|
43
|
+
* @param number The number to clamp.
|
|
44
|
+
* @param min The minimum value.
|
|
45
|
+
* @param max The maximum value.
|
|
46
|
+
* @returns The clamped number.
|
|
47
47
|
*/
|
|
48
|
-
const clampValue = (
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const clampValue = (
|
|
49
|
+
number: string | number,
|
|
50
|
+
min: number,
|
|
51
|
+
max: number,
|
|
52
|
+
): number => {
|
|
53
|
+
if (Number.isNaN(parseInt(String(number), 10))) {
|
|
51
54
|
return min;
|
|
52
55
|
}
|
|
53
|
-
return Math.max(min, Math.min(number, max));
|
|
56
|
+
return Math.max(min, Math.min(Number(number), max));
|
|
54
57
|
};
|
|
55
58
|
|
|
56
59
|
/**
|
|
57
60
|
* Lowercase and trim string.
|
|
58
61
|
*
|
|
59
|
-
* @param
|
|
60
|
-
* @returns
|
|
62
|
+
* @param name String to lowercase and trim.
|
|
63
|
+
* @returns Lowercased and trimmed string.
|
|
61
64
|
*/
|
|
62
|
-
const lowercaseTrim = (name) => name.toLowerCase().trim();
|
|
65
|
+
const lowercaseTrim = (name: string): string => name.toLowerCase().trim();
|
|
63
66
|
|
|
64
67
|
/**
|
|
65
68
|
* Split array of languages in two columns.
|
|
66
69
|
*
|
|
67
70
|
* @template T Language object.
|
|
68
|
-
* @param
|
|
69
|
-
* @param
|
|
70
|
-
* @returns
|
|
71
|
+
* @param arr Array of languages.
|
|
72
|
+
* @param perChunk Number of languages per column.
|
|
73
|
+
* @returns Array of languages split in two columns.
|
|
71
74
|
*/
|
|
72
|
-
const chunkArray = (arr
|
|
73
|
-
return arr.reduce((resultArray, item, index) => {
|
|
75
|
+
const chunkArray = <T>(arr: Array<T>, perChunk: number): Array<Array<T>> => {
|
|
76
|
+
return arr.reduce<Array<Array<T>>>((resultArray, item, index) => {
|
|
74
77
|
const chunkIndex = Math.floor(index / perChunk);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
resultArray[chunkIndex] = []; // start a new chunk
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
resultArray[chunkIndex].push(item);
|
|
83
|
-
|
|
78
|
+
const chunk = resultArray[chunkIndex] ?? [];
|
|
79
|
+
chunk.push(item);
|
|
80
|
+
resultArray[chunkIndex] = chunk;
|
|
84
81
|
return resultArray;
|
|
85
82
|
}, []);
|
|
86
83
|
};
|
|
@@ -88,10 +85,10 @@ const chunkArray = (arr, perChunk) => {
|
|
|
88
85
|
/**
|
|
89
86
|
* Parse emoji from string.
|
|
90
87
|
*
|
|
91
|
-
* @param
|
|
92
|
-
* @returns
|
|
88
|
+
* @param str String to parse emoji from.
|
|
89
|
+
* @returns String with emoji parsed.
|
|
93
90
|
*/
|
|
94
|
-
const parseEmojis = (str) => {
|
|
91
|
+
const parseEmojis = (str: string): string => {
|
|
95
92
|
if (!str) {
|
|
96
93
|
throw new Error("[parseEmoji]: str argument not provided");
|
|
97
94
|
}
|
|
@@ -103,11 +100,11 @@ const parseEmojis = (str) => {
|
|
|
103
100
|
/**
|
|
104
101
|
* Get diff in minutes between two dates.
|
|
105
102
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
108
|
-
* @returns
|
|
103
|
+
* @param d1 First date.
|
|
104
|
+
* @param d2 Second date.
|
|
105
|
+
* @returns Number of minutes between the two dates.
|
|
109
106
|
*/
|
|
110
|
-
const dateDiff = (d1, d2) => {
|
|
107
|
+
const dateDiff = (d1: Date, d2: Date): number => {
|
|
111
108
|
const date1 = new Date(d1);
|
|
112
109
|
const date2 = new Date(d2);
|
|
113
110
|
const diff = date1.getTime() - date2.getTime();
|
|
@@ -117,40 +114,41 @@ const dateDiff = (d1, d2) => {
|
|
|
117
114
|
/**
|
|
118
115
|
* Parse owner affiliations.
|
|
119
116
|
*
|
|
120
|
-
* @param
|
|
121
|
-
* @returns
|
|
117
|
+
* @param affiliations input affiliations to be parsed.
|
|
118
|
+
* @returns Parsed affiliations.
|
|
122
119
|
*
|
|
123
120
|
* @throws {CustomError} If affiliations contains invalid values.
|
|
124
121
|
*/
|
|
125
|
-
const parseOwnerAffiliations = (affiliations) => {
|
|
122
|
+
const parseOwnerAffiliations = (affiliations: Array<string>): Array<string> => {
|
|
126
123
|
// Set default value for ownerAffiliations.
|
|
127
124
|
// NOTE: Done here since parseArray() will always return an empty array even nothing
|
|
128
125
|
//was specified.
|
|
129
|
-
|
|
130
|
-
affiliations
|
|
126
|
+
const normalized =
|
|
127
|
+
affiliations.length > 0
|
|
131
128
|
? affiliations.map((affiliation) => affiliation.toUpperCase())
|
|
132
129
|
: ["OWNER"];
|
|
133
130
|
|
|
134
131
|
// Check if ownerAffiliations contains valid values.
|
|
135
132
|
if (
|
|
136
|
-
|
|
137
|
-
(affiliation) => !OWNER_AFFILIATIONS.includes(affiliation),
|
|
138
|
-
)
|
|
133
|
+
normalized.some((affiliation) => !OWNER_AFFILIATIONS.includes(affiliation))
|
|
139
134
|
) {
|
|
140
135
|
throw new CustomError(
|
|
141
136
|
"Invalid query parameter",
|
|
142
137
|
CustomError.INVALID_AFFILIATION,
|
|
143
138
|
);
|
|
144
139
|
}
|
|
145
|
-
return
|
|
140
|
+
return normalized;
|
|
146
141
|
};
|
|
147
142
|
|
|
148
|
-
const buildSearchFilter = (
|
|
149
|
-
|
|
143
|
+
const buildSearchFilter = (
|
|
144
|
+
repos: Array<string> | string = [],
|
|
145
|
+
owners: Array<string> | string = [],
|
|
146
|
+
): string => {
|
|
147
|
+
const repoFilter =
|
|
150
148
|
Array.isArray(repos) && repos.length > 0
|
|
151
149
|
? repos.map((r) => `repo:${r} `).join("")
|
|
152
150
|
: "";
|
|
153
|
-
|
|
151
|
+
const orgFilter =
|
|
154
152
|
Array.isArray(owners) && owners.length > 0
|
|
155
153
|
? owners.map((o) => `owner:${o} `).join("")
|
|
156
154
|
: "";
|