From 3430a2944f1f86d5db8c6ab345c524d9d3058bf2 Mon Sep 17 00:00:00 2001
From: Preffet
Date: Tue, 19 Jul 2022 20:03:58 +0100
Subject: [PATCH 01/36] Fixed a small grammatical mistake / typo (#1874)
does not passes -> does not pass
---
scripts/preview-theme.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/preview-theme.js b/scripts/preview-theme.js
index ca9effae79cc0..e4422ecd0350a 100644
--- a/scripts/preview-theme.js
+++ b/scripts/preview-theme.js
@@ -156,7 +156,7 @@ async function run() {
if (!ccc.isLevelAA(`#${color1}`, `#${color2}`)) {
const permalink = getWebAimLink(color1, color2);
warnings.push(
- `\`${key}\` does not passes [AA contrast ratio](${permalink})`,
+ `\`${key}\` does not pass [AA contrast ratio](${permalink})`,
);
}
});
From fd80b67e089736efb1d4fb6023b900bac059388a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fidel=20Alejandro=20Fern=C3=A1ndez=20Arias?=
<47539231+ale94lko@users.noreply.github.com>
Date: Tue, 26 Jul 2022 03:04:24 -0400
Subject: [PATCH 02/36] Fixed misspelling (#1885)
---
src/translations.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/translations.js b/src/translations.js
index 38e53f37adeee..31b2d218d5486 100644
--- a/src/translations.js
+++ b/src/translations.js
@@ -201,7 +201,7 @@ const repoCardLocales = {
cs: "Šablona",
de: "Vorlage",
en: "Template",
- es: "Planitlla",
+ es: "Plantilla",
fr: "Modèle",
hu: "Sablon",
it: "Template",
From cffb0843b172ca114a0164b6258dc35947e99bd3 Mon Sep 17 00:00:00 2001
From: tmt <101849050+tinnamchoi@users.noreply.github.com>
Date: Wed, 27 Jul 2022 15:17:55 +0930
Subject: [PATCH 03/36] docs: incorrect cache documentation (#1889)
---
readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index d1aa23a36b438..146739055f0fb 100644
--- a/readme.md
+++ b/readme.md
@@ -167,7 +167,7 @@ You can customize the appearance of your `Stats Card` or `Repo Card` however you
- `bg_color` - Card's background color _(hex color)_ **or** a gradient in the form of _angle,start,end_
- `hide_border` - Hides the card's border _(boolean)_
- `theme` - name of the theme, choose from [all available themes](./themes/README.md)
-- `cache_seconds` - set the cache header manually _(min: 1800, max: 86400)_
+- `cache_seconds` - set the cache header manually _(min: 7200, max: 86400)_
- `locale` - set the language in the card _(e.g. cn, de, es, etc.)_
- `border_radius` - Corner rounding on the card_
From 678fa1141676fc8fb75e2a322e4297323900e330 Mon Sep 17 00:00:00 2001
From: tmt <101849050+tinnamchoi@users.noreply.github.com>
Date: Wed, 27 Jul 2022 15:18:20 +0930
Subject: [PATCH 04/36] docs: note for temporary cache inc (#1890)
---
readme.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/readme.md b/readme.md
index 146739055f0fb..ec31fdfc128ce 100644
--- a/readme.md
+++ b/readme.md
@@ -171,6 +171,8 @@ You can customize the appearance of your `Stats Card` or `Repo Card` however you
- `locale` - set the language in the card _(e.g. cn, de, es, etc.)_
- `border_radius` - Corner rounding on the card_
+> Note: The minimum of cache_seconds is currently 4 hours as a temporary fix for PATs exhaustion.
+
##### Gradient in bg_color
You can provide multiple comma-separated values in the bg_color option to render a gradient, with the following format:
From 86f0ea071595df748a8db294db38d9cb18bd1a47 Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Fri, 29 Jul 2022 10:42:47 +0200
Subject: [PATCH 05/36] build: pin node version to >=13 (#1900) (#1901)
This commit pins the node version to >=13 since node 12 is now end of
life (see https://vercel.com/changelog/node-js-12-is-being-deprecated).
---
package.json | 3 +++
1 file changed, 3 insertions(+)
diff --git a/package.json b/package.json
index ed7a9ae2fa489..e2f13552e80ad 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,9 @@
},
"author": "Anurag Hazra",
"license": "MIT",
+ "engines": {
+ "node": ">=13"
+ },
"devDependencies": {
"@actions/core": "^1.2.4",
"@actions/github": "^4.0.0",
From 74fc4a3cc3a051f5792a08d94deda1bd9a752dc3 Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Sun, 31 Jul 2022 12:10:10 +0200
Subject: [PATCH 06/36] refactor: improve issues template
Move FAQ notice to the top of the issues template to increase the change of users reading it.
---
.github/ISSUE_TEMPLATE/bug_report.md | 41 ++++++++++++++--------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 9375a5e172ab1..44704fb4fa60c 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,23 +1,3 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: ""
-labels: ""
-assignees: ""
----
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**Expected behaviour**
-A clear and concise description of what you expected to happen.
-
-**Screenshots / Live demo link (paste the github-readme-stats link as markdown image)**
-If applicable, add screenshots to help explain your problem.
-
-**Additional context**
-Add any other context about the problem here.
-
+
+---
+name: Bug report
+about: Create a report to help us improve
+title: ""
+labels: ""
+assignees: ""
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**Expected behaviour**
+A clear and concise description of what you expected to happen.
+
+**Screenshots / Live demo link (paste the github-readme-stats link as markdown image)**
+If applicable, add screenshots to help explain your problem.
+
+**Additional context**
+Add any other context about the problem here.
From 689e1f4052203b89043af7fdd2e4571e7a6c46d8 Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Sun, 31 Jul 2022 12:11:18 +0200
Subject: [PATCH 07/36] refactor: fix bug in issues template
---
.github/ISSUE_TEMPLATE/bug_report.md | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 44704fb4fa60c..b96168187e7c9 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,3 +1,10 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ""
+labels: ""
+assignees: ""
+---
----
-name: Bug report
-about: Create a report to help us improve
-title: ""
-labels: ""
-assignees: ""
----
-
**Describe the bug**
A clear and concise description of what the bug is.
From e547eaf563d3ae0444b1ecea82dddc2e351a2e7d Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Sun, 31 Jul 2022 12:16:46 +0200
Subject: [PATCH 08/36] refactor: improve issues template
Move part of the FAQ notice to the bottom so that it doesn't clutter the issues window.
---
.github/ISSUE_TEMPLATE/bug_report.md | 29 ++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index b96168187e7c9..5ed7d3c969ff8 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -5,9 +5,22 @@ title: ""
labels: ""
assignees: ""
---
-
-PLEASE FIRST READ THE FAQ (#1770) AND COMMON ERROR CODES (#1772)!!!
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**Expected behaviour**
+A clear and concise description of what you expected to happen.
+
+**Screenshots / Live demo link (paste the github-readme-stats link as markdown image)**
+If applicable, add screenshots to help explain your problem.
+
+**Additional context**
+Add any other context about the problem here.
+
+
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**Expected behaviour**
-A clear and concise description of what you expected to happen.
-
-**Screenshots / Live demo link (paste the github-readme-stats link as markdown image)**
-If applicable, add screenshots to help explain your problem.
-
-**Additional context**
-Add any other context about the problem here.
From 7ceec9245507288bc8d1f1f065a78d3a495cea10 Mon Sep 17 00:00:00 2001
From: Cong
Date: Mon, 1 Aug 2022 18:13:59 +1000
Subject: [PATCH 09/36] refactor: fix typo in comment (#1912)
---
src/cards/top-languages-card.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cards/top-languages-card.js b/src/cards/top-languages-card.js
index 4e079ff2738a4..836af05b6b2a7 100644
--- a/src/cards/top-languages-card.js
+++ b/src/cards/top-languages-card.js
@@ -214,7 +214,7 @@ const useLanguages = (topLangs, hide, langs_count) => {
});
}
- // filter out langauges to be hidden
+ // filter out languages to be hidden
langs = langs
.sort((a, b) => b.size - a.size)
.filter((lang) => {
From b6d75b2e65ee3c28db064af5cb19478968dbac4c Mon Sep 17 00:00:00 2001
From: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com>
Date: Tue, 2 Aug 2022 19:26:07 +0900
Subject: [PATCH 10/36] refactor: remove arrow function body braces (#1917)
---
src/fetchers/top-languages-fetcher.js | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/fetchers/top-languages-fetcher.js b/src/fetchers/top-languages-fetcher.js
index 9dd109e22ee2b..7c4c8785c87f9 100644
--- a/src/fetchers/top-languages-fetcher.js
+++ b/src/fetchers/top-languages-fetcher.js
@@ -68,14 +68,10 @@ async function fetchTopLanguages(username, exclude_repo = []) {
// filter out repositories to be hidden
repoNodes = repoNodes
.sort((a, b) => b.size - a.size)
- .filter((name) => {
- return !repoToHide[name.name];
- });
+ .filter((name) => !repoToHide[name.name]);
repoNodes = repoNodes
- .filter((node) => {
- return node.languages.edges.length > 0;
- })
+ .filter((node) => node.languages.edges.length > 0)
// flatten the list of language nodes
.reduce((acc, curr) => curr.languages.edges.concat(acc), [])
.reduce((acc, prev) => {
From e5222902c3f390733fa93e94ba61cd21412389cc Mon Sep 17 00:00:00 2001
From: Daniel
Date: Sat, 13 Aug 2022 01:26:05 -0700
Subject: [PATCH 11/36] refactor: update license year (#1735)
* Updated Year
* Update LICENSE / Revert to 2020
The MIT license [year] field should indicate the year the copyright was applied
Co-authored-by: Rick Staa
Co-authored-by: Rick Staa
---
LICENSE | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/LICENSE b/LICENSE
index 83b114d1e2ed6..14d9ba34bcbdc 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2021 Anurag Hazra
+Copyright (c) 2020 Anurag Hazra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
From 4b6f4650b21a892b8ee1f57593b38efffed74155 Mon Sep 17 00:00:00 2001
From: akmhmgc <38002468+akmhmgc@users.noreply.github.com>
Date: Sun, 14 Aug 2022 03:24:44 +0900
Subject: [PATCH 12/36] refactor: improve level calculator (#1946)
---
src/calculateRank.js | 30 +++++++-----------------------
1 file changed, 7 insertions(+), 23 deletions(-)
diff --git a/src/calculateRank.js b/src/calculateRank.js
index 76909d09547cd..0c401d9a2784a 100644
--- a/src/calculateRank.js
+++ b/src/calculateRank.js
@@ -63,29 +63,13 @@ function calculateRank({
const normalizedScore = normalcdf(score, TOTAL_VALUES, ALL_OFFSETS) * 100;
- let level = "";
-
- if (normalizedScore < RANK_S_VALUE) {
- level = "S+";
- }
- if (
- normalizedScore >= RANK_S_VALUE &&
- normalizedScore < RANK_DOUBLE_A_VALUE
- ) {
- level = "S";
- }
- if (
- normalizedScore >= RANK_DOUBLE_A_VALUE &&
- normalizedScore < RANK_A2_VALUE
- ) {
- level = "A++";
- }
- if (normalizedScore >= RANK_A2_VALUE && normalizedScore < RANK_A3_VALUE) {
- level = "A+";
- }
- if (normalizedScore >= RANK_A3_VALUE && normalizedScore < RANK_B_VALUE) {
- level = "B+";
- }
+ const level = (() => {
+ if (normalizedScore < RANK_S_VALUE) return "S+";
+ if (normalizedScore >= RANK_S_VALUE && normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
+ if (normalizedScore >= RANK_DOUBLE_A_VALUE && normalizedScore < RANK_A2_VALUE) return "A++";
+ if (normalizedScore >= RANK_A2_VALUE && normalizedScore < RANK_A3_VALUE) return "A+"
+ if (normalizedScore >= RANK_A3_VALUE && normalizedScore < RANK_B_VALUE) return "B+"
+ })()
return { level, score: normalizedScore };
}
From 8d5f2da3f317dc8977ba887b36030d9195e41c96 Mon Sep 17 00:00:00 2001
From: Qi Mo Lin <60514926+qimolin@users.noreply.github.com>
Date: Wed, 17 Aug 2022 23:22:52 +0200
Subject: [PATCH 13/36] test: fix gradient test by using more specific
querySelector (#1954)
---
tests/card.test.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/card.test.js b/tests/card.test.js
index 002d278ae7b4d..2ef779459e279 100644
--- a/tests/card.test.js
+++ b/tests/card.test.js
@@ -168,18 +168,18 @@ describe("Card", () => {
"fill",
"url(#gradient)",
);
- expect(document.querySelector("defs linearGradient")).toHaveAttribute(
+ expect(document.querySelector("defs #gradient")).toHaveAttribute(
"gradientTransform",
"rotate(90)",
);
expect(
- document.querySelector("defs linearGradient stop:nth-child(1)"),
+ document.querySelector("defs #gradient stop:nth-child(1)"),
).toHaveAttribute("stop-color", "#fff");
expect(
- document.querySelector("defs linearGradient stop:nth-child(2)"),
+ document.querySelector("defs #gradient stop:nth-child(2)"),
).toHaveAttribute("stop-color", "#000");
expect(
- document.querySelector("defs linearGradient stop:nth-child(3)"),
+ document.querySelector("defs #gradient stop:nth-child(3)"),
).toHaveAttribute("stop-color", "#f00");
});
});
From dd5a41d696c3f6a6ad84253317d1b70bd0e1a66f Mon Sep 17 00:00:00 2001
From: Qi Mo Lin <60514926+qimolin@users.noreply.github.com>
Date: Thu, 18 Aug 2022 10:32:03 +0200
Subject: [PATCH 14/36] feat: add min width languages card (#1953)
* Add min width to languages card
* Add test for min width languages card
* feat: increase lang card min width
Co-authored-by: Rick Staa
---
src/cards/top-languages-card.js | 20 +++++++++++++-------
tests/renderTopLanguages.test.js | 15 +++++++++++++++
2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/src/cards/top-languages-card.js b/src/cards/top-languages-card.js
index 836af05b6b2a7..b2f5c362dd47f 100644
--- a/src/cards/top-languages-card.js
+++ b/src/cards/top-languages-card.js
@@ -13,6 +13,7 @@ const {
} = require("../common/utils");
const DEFAULT_CARD_WIDTH = 300;
+const MIN_CARD_WIDTH = 230;
const DEFAULT_LANGS_COUNT = 5;
const DEFAULT_LANG_COLOR = "#858585";
const CARD_PADDING = 25;
@@ -24,12 +25,12 @@ const CARD_PADDING = 25;
/**
* @param {Lang[]} arr
*/
- const getLongestLang = (arr) =>
- arr.reduce(
- (savedLang, lang) =>
- lang.name.length > savedLang.name.length ? lang : savedLang,
- { name: "", size: null, color: "" },
- );
+const getLongestLang = (arr) =>
+ arr.reduce(
+ (savedLang, lang) =>
+ lang.name.length > savedLang.name.length ? lang : savedLang,
+ { name: "", size: null, color: "" },
+ );
/**
* @param {{
@@ -261,7 +262,11 @@ const renderTopLanguages = (topLangs, options = {}) => {
String(langs_count),
);
- let width = isNaN(card_width) ? DEFAULT_CARD_WIDTH : card_width;
+ let width = isNaN(card_width)
+ ? DEFAULT_CARD_WIDTH
+ : card_width < MIN_CARD_WIDTH
+ ? MIN_CARD_WIDTH
+ : card_width;
let height = calculateNormalLayoutHeight(langs.length);
let finalLayout = "";
@@ -307,3 +312,4 @@ const renderTopLanguages = (topLangs, options = {}) => {
};
module.exports = renderTopLanguages;
+module.exports.MIN_CARD_WIDTH = MIN_CARD_WIDTH;
diff --git a/tests/renderTopLanguages.test.js b/tests/renderTopLanguages.test.js
index 36dbf03f9507d..b2ff70f68e7d5 100644
--- a/tests/renderTopLanguages.test.js
+++ b/tests/renderTopLanguages.test.js
@@ -103,6 +103,21 @@ describe("Test renderTopLanguages", () => {
expect(document.querySelector("svg")).toHaveAttribute("width", "400");
});
+ it("should render with min width", () => {
+ document.body.innerHTML = renderTopLanguages(langs, { card_width: 190 });
+
+ expect(document.querySelector("svg")).toHaveAttribute(
+ "width",
+ renderTopLanguages.MIN_CARD_WIDTH.toString(),
+ );
+
+ document.body.innerHTML = renderTopLanguages(langs, { card_width: 100 });
+ expect(document.querySelector("svg")).toHaveAttribute(
+ "width",
+ renderTopLanguages.MIN_CARD_WIDTH.toString(),
+ );
+ });
+
it("should render default colors properly", () => {
document.body.innerHTML = renderTopLanguages(langs);
From 663fbae49acd7daccbf20ccbfd18d0d5a10b1005 Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Thu, 18 Aug 2022 11:31:45 +0200
Subject: [PATCH 15/36] ci: add top-issues-dashboard action
This commit adds the top issues dashboard action which creates a issue displaying the top issues of the week.
---
.github/workflows/top-issues-dashboard.yml | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 .github/workflows/top-issues-dashboard.yml
diff --git a/.github/workflows/top-issues-dashboard.yml b/.github/workflows/top-issues-dashboard.yml
new file mode 100644
index 0000000000000..19ebe41886971
--- /dev/null
+++ b/.github/workflows/top-issues-dashboard.yml
@@ -0,0 +1,20 @@
+name: Update top issues dashboard.
+on:
+ schedule:
+ - cron: "0 0 */7 * *"
+
+jobs:
+ showAndLabelTopIssues:
+ name: Update top issues Dashboard.
+ runs-on: ubuntu-latest
+ steps:
+ - name: Run top issues action
+ uses: rickstaa/top-issues-action@v1
+ env:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ label: false
+ dashboard: true
+ top_issues: true
+ top_bugs: true
+ top_features: true
+ top_pull_requests: true
From e9c55d90ad8c9663a480ffaa56484f979ce86fad Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Thu, 18 Aug 2022 11:32:57 +0200
Subject: [PATCH 16/36] ci: fix title of top-issues action
---
.github/workflows/top-issues-dashboard.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/top-issues-dashboard.yml b/.github/workflows/top-issues-dashboard.yml
index 19ebe41886971..3639408112b7f 100644
--- a/.github/workflows/top-issues-dashboard.yml
+++ b/.github/workflows/top-issues-dashboard.yml
@@ -1,4 +1,4 @@
-name: Update top issues dashboard.
+name: Update top issues dashboard
on:
schedule:
- cron: "0 0 */7 * *"
From c2c07ea02238177495eb693c6c1cecb77662ad0b Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Thu, 25 Aug 2022 19:45:11 +0200
Subject: [PATCH 17/36] ci: fix top-issues-action syntax (#1978)
---
.github/workflows/top-issues-dashboard.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/top-issues-dashboard.yml b/.github/workflows/top-issues-dashboard.yml
index 3639408112b7f..a8b2bf300d596 100644
--- a/.github/workflows/top-issues-dashboard.yml
+++ b/.github/workflows/top-issues-dashboard.yml
@@ -12,6 +12,7 @@ jobs:
uses: rickstaa/top-issues-action@v1
env:
github_token: ${{ secrets.GITHUB_TOKEN }}
+ with:
label: false
dashboard: true
top_issues: true
From 84610521a2b56a165f631e9f0e1272d48caafeee Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Thu, 25 Aug 2022 20:06:45 +0200
Subject: [PATCH 18/36] ci: add top-issues-action argument
---
.github/workflows/top-issues-dashboard.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/top-issues-dashboard.yml b/.github/workflows/top-issues-dashboard.yml
index 3639408112b7f..db9abfe71b874 100644
--- a/.github/workflows/top-issues-dashboard.yml
+++ b/.github/workflows/top-issues-dashboard.yml
@@ -14,6 +14,7 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
label: false
dashboard: true
+ dashboard_show_total_reactions: true
top_issues: true
top_bugs: true
top_features: true
From a481021dab695e1d8259e218d8e159e8a2110b1e Mon Sep 17 00:00:00 2001
From: Adil Hanney
Date: Fri, 26 Aug 2022 21:28:48 +0100
Subject: [PATCH 19/36] Fix NaN and undefined for empty profiles (#1965)
* totalCommits: don't return NaN
* rank: B+ should cover everyone
Empty profile used to show "undefined" as the rank. Now empty profile shows "A+"... is B+ possible?
---
src/calculateRank.js | 8 ++++----
src/fetchers/stats-fetcher.js | 9 +++++----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/calculateRank.js b/src/calculateRank.js
index 0c401d9a2784a..9a8a55d589f2f 100644
--- a/src/calculateRank.js
+++ b/src/calculateRank.js
@@ -65,10 +65,10 @@ function calculateRank({
const level = (() => {
if (normalizedScore < RANK_S_VALUE) return "S+";
- if (normalizedScore >= RANK_S_VALUE && normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
- if (normalizedScore >= RANK_DOUBLE_A_VALUE && normalizedScore < RANK_A2_VALUE) return "A++";
- if (normalizedScore >= RANK_A2_VALUE && normalizedScore < RANK_A3_VALUE) return "A+"
- if (normalizedScore >= RANK_A3_VALUE && normalizedScore < RANK_B_VALUE) return "B+"
+ if (normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
+ if (normalizedScore < RANK_A2_VALUE) return "A++";
+ if (normalizedScore < RANK_A3_VALUE) return "A+"
+ return "B+";
})()
return { level, score: normalizedScore };
diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js
index 04b4b3e58e928..2617137a40752 100644
--- a/src/fetchers/stats-fetcher.js
+++ b/src/fetchers/stats-fetcher.js
@@ -86,15 +86,16 @@ const totalCommitsFetcher = async (username) => {
try {
let res = await retryer(fetchTotalCommits, { login: username });
- if (res.data.total_count) {
+ let total_count = res.data.total_count;
+ if (!!total_count && !isNaN(total_count)) {
return res.data.total_count;
}
} catch (err) {
logger.log(err);
- // just return 0 if there is something wrong so that
- // we don't break the whole app
- return 0;
}
+ // just return 0 if there is something wrong so that
+ // we don't break the whole app
+ return 0;
};
/**
From d5c94b6f57d4592b8fafe3fb56f5c8d254cdc51a Mon Sep 17 00:00:00 2001
From: John Sweeney
Date: Tue, 6 Sep 2022 07:50:39 +0100
Subject: [PATCH 20/36] Remove unneeded underscore from Readme (#2003)
---
readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index ec31fdfc128ce..f657871201d15 100644
--- a/readme.md
+++ b/readme.md
@@ -169,7 +169,7 @@ You can customize the appearance of your `Stats Card` or `Repo Card` however you
- `theme` - name of the theme, choose from [all available themes](./themes/README.md)
- `cache_seconds` - set the cache header manually _(min: 7200, max: 86400)_
- `locale` - set the language in the card _(e.g. cn, de, es, etc.)_
-- `border_radius` - Corner rounding on the card_
+- `border_radius` - Corner rounding on the card
> Note: The minimum of cache_seconds is currently 4 hours as a temporary fix for PATs exhaustion.
From 4c2307ab4b30c02123e072f91b1675b876299a72 Mon Sep 17 00:00:00 2001
From: Steven
Date: Tue, 6 Sep 2022 03:09:45 -0400
Subject: [PATCH 21/36] Add prettier check to CI (#1999)
* Add prettier check to CI
* Run prettier:format
---
.github/workflows/test.yml | 4 ++++
package.json | 4 +++-
scripts/generate-langs-json.js | 40 ++++++++++++++++++--------------
src/calculateRank.js | 4 ++--
src/cards/repo-card.js | 12 +++++-----
src/fetchers/wakatime-fetcher.js | 2 +-
tests/fetchTopLanguages.test.js | 5 +++-
tests/fetchWakatime.test.js | 2 +-
tests/renderWakatimeCard.test.js | 17 +++++++++-----
themes/index.js | 4 ++--
10 files changed, 56 insertions(+), 38 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 89df34e6006e6..d26607d352929 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -25,5 +25,9 @@ jobs:
npm install
npm run test
+ - name: Run Prettier
+ run: |
+ npm run prettier:check:ci
+
- name: Code Coverage
uses: codecov/codecov-action@v1
diff --git a/package.json b/package.json
index e2f13552e80ad..110a4e801eee7 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,9 @@
"test:watch": "jest --watch",
"theme-readme-gen": "node scripts/generate-theme-doc",
"preview-theme": "node scripts/preview-theme",
- "generate-langs-json": "node scripts/generate-langs-json"
+ "generate-langs-json": "node scripts/generate-langs-json",
+ "prettier:check:ci": "./node_modules/.bin/prettier --check .",
+ "prettier:format": "./node_modules/.bin/prettier --write ."
},
"author": "Anurag Hazra",
"license": "MIT",
diff --git a/scripts/generate-langs-json.js b/scripts/generate-langs-json.js
index 0705080d9c47d..bd210a3c53fe9 100644
--- a/scripts/generate-langs-json.js
+++ b/scripts/generate-langs-json.js
@@ -1,26 +1,30 @@
-const fs = require('fs');
-const jsYaml = require('js-yaml');
-const axios = require('axios');
+const fs = require("fs");
+const jsYaml = require("js-yaml");
+const axios = require("axios");
-const LANGS_FILEPATH = "./src/common/languageColors.json"
+const LANGS_FILEPATH = "./src/common/languageColors.json";
//Retrieve languages from github linguist repository yaml file
//@ts-ignore
-axios.get("https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml")
-.then((response) => {
+axios
+ .get(
+ "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml",
+ )
+ .then((response) => {
+ //and convert them to a JS Object
+ const languages = jsYaml.load(response.data);
- //and convert them to a JS Object
- const languages = jsYaml.load(response.data);
+ const languageColors = {};
- const languageColors = {};
+ //Filter only language colors from the whole file
+ Object.keys(languages).forEach((lang) => {
+ languageColors[lang] = languages[lang].color;
+ });
- //Filter only language colors from the whole file
- Object.keys(languages).forEach((lang) => {
- languageColors[lang] = languages[lang].color;
+ //Debug Print
+ //console.dir(languageColors);
+ fs.writeFileSync(
+ LANGS_FILEPATH,
+ JSON.stringify(languageColors, null, " "),
+ );
});
-
- //Debug Print
- //console.dir(languageColors);
- fs.writeFileSync(LANGS_FILEPATH, JSON.stringify(languageColors, null, ' '));
-
-});
diff --git a/src/calculateRank.js b/src/calculateRank.js
index 9a8a55d589f2f..742b9ab17509d 100644
--- a/src/calculateRank.js
+++ b/src/calculateRank.js
@@ -67,9 +67,9 @@ function calculateRank({
if (normalizedScore < RANK_S_VALUE) return "S+";
if (normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
if (normalizedScore < RANK_A2_VALUE) return "A++";
- if (normalizedScore < RANK_A3_VALUE) return "A+"
+ if (normalizedScore < RANK_A3_VALUE) return "A+";
return "B+";
- })()
+ })();
return { level, score: normalizedScore };
}
diff --git a/src/cards/repo-card.js b/src/cards/repo-card.js
index bb5c178affbdf..034ee1f6cdf79 100644
--- a/src/cards/repo-card.js
+++ b/src/cards/repo-card.js
@@ -67,8 +67,8 @@ const iconWithLabel = (icon, label, testid) => {
};
/**
- * @param {import('../fetchers/types').RepositoryData} repo
- * @param {Partial} options
+ * @param {import('../fetchers/types').RepositoryData} repo
+ * @param {Partial} options
* @returns {string}
*/
const renderRepoCard = (repo, options = {}) => {
@@ -167,11 +167,11 @@ const renderRepoCard = (repo, options = {}) => {
return card.render(`
${
isTemplate
- // @ts-ignore
- ? getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
+ ? // @ts-ignore
+ getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
: isArchived
- // @ts-ignore
- ? getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
+ ? // @ts-ignore
+ getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
: ""
}
diff --git a/src/fetchers/wakatime-fetcher.js b/src/fetchers/wakatime-fetcher.js
index e9779d600429a..fe06c6385e7df 100644
--- a/src/fetchers/wakatime-fetcher.js
+++ b/src/fetchers/wakatime-fetcher.js
@@ -7,7 +7,7 @@ const { MissingParamError } = require("../common/utils");
*/
const fetchWakatimeStats = async ({ username, api_domain, range }) => {
if (!username) throw new MissingParamError(["username"]);
-
+
try {
const { data } = await axios.get(
`https://${
diff --git a/tests/fetchTopLanguages.test.js b/tests/fetchTopLanguages.test.js
index 54238df179e25..0792f28ded452 100644
--- a/tests/fetchTopLanguages.test.js
+++ b/tests/fetchTopLanguages.test.js
@@ -81,7 +81,10 @@ describe("FetchTopLanguages", () => {
it("should fetch correct language data while excluding the 'test-repo-1' repository", async () => {
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);
- let repo = await fetchTopLanguages("anuraghazra", exclude_repo=["test-repo-1"]);
+ let repo = await fetchTopLanguages(
+ "anuraghazra",
+ (exclude_repo = ["test-repo-1"]),
+ );
expect(repo).toStrictEqual({
HTML: {
color: "#0f0",
diff --git a/tests/fetchWakatime.test.js b/tests/fetchWakatime.test.js
index 6255890c0a5ed..ef8c64c38229f 100644
--- a/tests/fetchWakatime.test.js
+++ b/tests/fetchWakatime.test.js
@@ -207,7 +207,7 @@ describe("Wakatime fetcher", () => {
mock.onGet(/\/https:\/\/wakatime\.com\/api/).reply(404, wakaTimeData);
await expect(fetchWakatimeStats("noone")).rejects.toThrow(
- "Missing params \"username\" make sure you pass the parameters in URL",
+ 'Missing params "username" make sure you pass the parameters in URL',
);
});
});
diff --git a/tests/renderWakatimeCard.test.js b/tests/renderWakatimeCard.test.js
index 51d63e6cf14c1..a6d7c85f30975 100644
--- a/tests/renderWakatimeCard.test.js
+++ b/tests/renderWakatimeCard.test.js
@@ -48,10 +48,15 @@ describe("Test Render Wakatime Card", () => {
});
it('should show "no coding activitiy this week" message when there hasn not been activity', () => {
- document.body.innerHTML = renderWakatimeCard({
- ...wakaTimeData.data,
- languages: undefined
- }, {});
- expect(document.querySelector(".stat").textContent).toBe("No coding activity this week")
- })
+ document.body.innerHTML = renderWakatimeCard(
+ {
+ ...wakaTimeData.data,
+ languages: undefined,
+ },
+ {},
+ );
+ expect(document.querySelector(".stat").textContent).toBe(
+ "No coding activity this week",
+ );
+ });
});
diff --git a/themes/index.js b/themes/index.js
index 2508c9d2f538c..4312496ac6f86 100644
--- a/themes/index.js
+++ b/themes/index.js
@@ -355,12 +355,12 @@ const themes = {
bg_color: "09131B",
border_color: "0c1a25",
},
- "rose_pine":{
+ rose_pine: {
title_color: "9ccfd8",
icon_color: "ebbcba",
text_color: "e0def4",
bg_color: "191724",
- }
+ },
};
module.exports = themes;
From 192170c1111333a2a6a65015c81ab1cdb4b86a6a Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Tue, 6 Sep 2022 10:00:21 +0200
Subject: [PATCH 22/36] ci: add empty issues closer action (#2004)
Co-authored-by: Prashubh Atri
Co-authored-by: Prashubh Atri
---
.github/workflows/empty-issues-closer.yaml | 30 ++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 .github/workflows/empty-issues-closer.yaml
diff --git a/.github/workflows/empty-issues-closer.yaml b/.github/workflows/empty-issues-closer.yaml
new file mode 100644
index 0000000000000..5f050fe067abc
--- /dev/null
+++ b/.github/workflows/empty-issues-closer.yaml
@@ -0,0 +1,30 @@
+name: Close empty issues and templates
+on:
+ issues:
+ types:
+ - reopened
+ - opened
+ - edited
+
+jobs:
+ closeEmptyIssuesAndTemplates:
+ name: Close empty issues
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3 # NOTE: Retrieve issue templates.
+ - name: Run empty issues closer action
+ uses: rickstaa/empty-issues-closer-action@v1
+ env:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ close_comment:
+ Closing this issue because it appears to be empty. Please update the
+ issue for it to be reopened.
+ open_comment:
+ Reopening this issue because the author provided more information.
+ check_templates: true
+ template_close_comment:
+ Closing this issue since the issue template was not filled in.
+ Please provide us with more information to have this issue reopened.
+ template_open_comment:
+ Reopening this issue because the author provided more information.
From b0bb994ad36d7c187e2f934e36e34978e9de5e21 Mon Sep 17 00:00:00 2001
From: Artem Kostiuk
Date: Fri, 16 Sep 2022 06:50:30 -0400
Subject: [PATCH 23/36] Fix #1170: Allow customizable width for GitHub Stats
Card (#1334)
* Change default stats card width with hide rank
* Add tests for stats card with card_width
* Add card_width Stats Card description to readme
* fix: add icon width to stats-card min width calculation
* fix: fixes rank circle padding problem
This commit fixes a padding problem that was introduced in
f9c0e0bff64f325235ccbf936c9d5f7a918ac790. In the new code, the padding
around the rank circle will be 50 when the stats card is bigger than
450. When it is smaller than 450 the left and right padding will shrink
equally.
* style: run prettier
* tests: add extra stats 'card_width' tests
This commit makes sure we also test the stats card width for the case that the 'show_icons'
option is enabled.
* style: run prettier
Co-authored-by: rickstaa
---
api/index.js | 2 +
readme.md | 1 +
src/cards/stats-card.js | 91 +++++++++++++++++++++++------------
tests/renderStatsCard.test.js | 46 ++++++++++++++++++
4 files changed, 108 insertions(+), 32 deletions(-)
diff --git a/api/index.js b/api/index.js
index 6563dbcc8f9e1..b07464d0ff9a0 100644
--- a/api/index.js
+++ b/api/index.js
@@ -17,6 +17,7 @@ module.exports = async (req, res) => {
hide,
hide_title,
hide_border,
+ card_width,
hide_rank,
show_icons,
count_private,
@@ -65,6 +66,7 @@ module.exports = async (req, res) => {
show_icons: parseBoolean(show_icons),
hide_title: parseBoolean(hide_title),
hide_border: parseBoolean(hide_border),
+ card_width: parseInt(card_width, 10),
hide_rank: parseBoolean(hide_rank),
include_all_commits: parseBoolean(include_all_commits),
line_height,
diff --git a/readme.md b/readme.md
index f657871201d15..d8e4c7d4e41e8 100644
--- a/readme.md
+++ b/readme.md
@@ -187,6 +187,7 @@ You can provide multiple comma-separated values in the bg_color option to render
- `hide` - Hides the [specified items](#hiding-individual-stats) from stats _(Comma-separated values)_
- `hide_title` - _(boolean)_
+- `card_width` - Set the card's width manually _(number)_
- `hide_rank` - _(boolean)_ hides the rank and automatically resizes the card width
- `show_icons` - _(boolean)_
- `include_all_commits` - Count total commits instead of just the current year commits _(boolean)_
diff --git a/src/cards/stats-card.js b/src/cards/stats-card.js
index 9db456236a7fe..bbc48cfc1a7ea 100644
--- a/src/cards/stats-card.js
+++ b/src/cards/stats-card.js
@@ -36,10 +36,10 @@ const createTextNode = ({
${iconSvg}
${label}:
- ${kValue}
@@ -66,6 +66,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
show_icons = false,
hide_title = false,
hide_border = false,
+ card_width,
hide_rank = false,
include_all_commits = false,
line_height = 25,
@@ -174,26 +175,6 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
hide_rank ? 0 : 150,
);
- // Conditionally rendered elements
- const rankCircle = hide_rank
- ? ""
- : `
-
-
-
-
- ${rank.level}
-
-
- `;
-
// the better user's score the the rank will be closer to zero so
// subtracting 100 to get the progress in 100%
const progress = 100 - rank.score;
@@ -209,13 +190,20 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
return measureText(custom_title ? custom_title : i18n.t("statcard.title"));
};
- const width = hide_rank
- ? clampValue(
- 50 /* padding */ + calculateTextWidth() * 2,
- 270 /* min */,
- Infinity,
- )
- : 495;
+ /*
+ When hide_rank=true, the minimum card width is 270 px + the title length and padding.
+ When hide_rank=false, the minimum card_width is 340 px + the icon width (if show_icons=true).
+ Numbers are picked by looking at existing dimensions on production.
+ */
+ const iconWidth = show_icons ? 16 : 0;
+ const minCardWidth = hide_rank
+ ? clampValue(50 /* padding */ + calculateTextWidth() * 2, 270, Infinity)
+ : 340 + iconWidth;
+ const defaultCardWidth = hide_rank ? 270 : 495;
+ let width = isNaN(card_width) ? defaultCardWidth : card_width;
+ if (width < minCardWidth) {
+ width = minCardWidth;
+ }
const card = new Card({
customTitle: custom_title,
@@ -238,6 +226,45 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
if (disable_animations) card.disableAnimations();
+ /**
+ * Calculates the right rank circle translation values such that the rank circle
+ * keeps respecting the padding.
+ *
+ * width > 450: The default left padding of 50 px will be used.
+ * width < 450: The left and right padding will shrink equally.
+ *
+ * @returns {number} - Rank circle translation value.
+ */
+ const calculateRankXTranslation = () => {
+ if (width < 450) {
+ return width - 95 + (45 * (450 - 340)) / 110;
+ } else {
+ return width - 95;
+ }
+ };
+
+ // Conditionally rendered elements
+ const rankCircle = hide_rank
+ ? ""
+ : `
+
+
+
+
+ ${rank.level}
+
+
+ `;
+
// Accessibility Labels
const labels = Object.keys(STATS)
.filter((key) => !hide.includes(key))
@@ -264,7 +291,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
gap: lheight,
direction: "column",
}).join("")}
-
+
`);
};
diff --git a/tests/renderStatsCard.test.js b/tests/renderStatsCard.test.js
index aabf2f6b75b5f..09bd9b044eef4 100644
--- a/tests/renderStatsCard.test.js
+++ b/tests/renderStatsCard.test.js
@@ -75,6 +75,52 @@ describe("Test renderStatsCard", () => {
expect(queryByTestId(document.body, "rank-circle")).not.toBeInTheDocument();
});
+ it("should render with custom width set", () => {
+ document.body.innerHTML = renderStatsCard(stats);
+ expect(document.querySelector("svg")).toHaveAttribute("width", "495");
+
+ document.body.innerHTML = renderStatsCard(stats, { card_width: 400 });
+ expect(document.querySelector("svg")).toHaveAttribute("width", "400");
+ });
+
+ it("should render with custom width set and limit minimum width", () => {
+ document.body.innerHTML = renderStatsCard(stats, { card_width: 1 });
+ expect(document.querySelector("svg")).toHaveAttribute("width", "340");
+
+ document.body.innerHTML = renderStatsCard(stats, {
+ card_width: 1,
+ hide_rank: true,
+ });
+ expect(document.querySelector("svg")).toHaveAttribute(
+ "width",
+ "305.81250000000006",
+ );
+
+ document.body.innerHTML = renderStatsCard(stats, {
+ card_width: 1,
+ hide_rank: true,
+ show_icons: true,
+ });
+ expect(document.querySelector("svg")).toHaveAttribute(
+ "width",
+ "305.81250000000006",
+ );
+
+ document.body.innerHTML = renderStatsCard(stats, {
+ card_width: 1,
+ hide_rank: false,
+ show_icons: true,
+ });
+ expect(document.querySelector("svg")).toHaveAttribute("width", "356");
+
+ document.body.innerHTML = renderStatsCard(stats, {
+ card_width: 1,
+ hide_rank: false,
+ show_icons: false,
+ });
+ expect(document.querySelector("svg")).toHaveAttribute("width", "340");
+ });
+
it("should render default colors properly", () => {
document.body.innerHTML = renderStatsCard(stats);
From dc8852dd6ba0b5f86de0e4a13a031c30dcbd20fc Mon Sep 17 00:00:00 2001
From: rickstaa
Date: Fri, 16 Sep 2022 12:55:35 +0200
Subject: [PATCH 24/36] refactor: change formatting command
---
.github/workflows/test.yml | 2 +-
package.json | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index d26607d352929..0911168f33754 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -27,7 +27,7 @@ jobs:
- name: Run Prettier
run: |
- npm run prettier:check:ci
+ npm run format:check
- name: Code Coverage
uses: codecov/codecov-action@v1
diff --git a/package.json b/package.json
index 110a4e801eee7..be9e43541aae0 100644
--- a/package.json
+++ b/package.json
@@ -9,8 +9,8 @@
"theme-readme-gen": "node scripts/generate-theme-doc",
"preview-theme": "node scripts/preview-theme",
"generate-langs-json": "node scripts/generate-langs-json",
- "prettier:check:ci": "./node_modules/.bin/prettier --check .",
- "prettier:format": "./node_modules/.bin/prettier --write ."
+ "format": "./node_modules/.bin/prettier --write .",
+ "format:check": "./node_modules/.bin/prettier --check ."
},
"author": "Anurag Hazra",
"license": "MIT",
From c1324b31bfc6da38c0f3c529b1562c80ec6ecd76 Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Fri, 16 Sep 2022 13:09:19 +0200
Subject: [PATCH 25/36] feat: add 'exclude_repo' option to stats card (#1450)
This commit allows users to exclude repositories for the stats card
using the `exclude_repo` option.
---
api/index.js | 2 ++
readme.md | 11 +++++----
src/fetchers/stats-fetcher.js | 22 +++++++++++++++---
tests/fetchStats.test.js | 43 +++++++++++++++++++++++++++++++----
4 files changed, 65 insertions(+), 13 deletions(-)
diff --git a/api/index.js b/api/index.js
index b07464d0ff9a0..207500597f8dd 100644
--- a/api/index.js
+++ b/api/index.js
@@ -29,6 +29,7 @@ module.exports = async (req, res) => {
bg_color,
theme,
cache_seconds,
+ exclude_repo,
custom_title,
locale,
disable_animations,
@@ -50,6 +51,7 @@ module.exports = async (req, res) => {
username,
parseBoolean(count_private),
parseBoolean(include_all_commits),
+ parseArray(exclude_repo),
);
const cacheSeconds = clampValue(
diff --git a/readme.md b/readme.md
index d8e4c7d4e41e8..a4034ee237d63 100644
--- a/readme.md
+++ b/readme.md
@@ -67,12 +67,12 @@
-Are you considering supporting the project by donating? Please DON'T!!
+Are you considering supporting the project by donating? Please DON'T!!
-Instead, Help India fight the 2nd deadly wave of COVID-19.
-Thousands of people are dying in India because of a lack of Oxygen & also COVID-related infrastructure.
+Instead, Help India fight the 2nd deadly wave of COVID-19.
+Thousands of people are dying in India because of a lack of Oxygen & also COVID-related infrastructure.
-Visit [https://indiafightscorona.giveindia.org](https://indiafightscorona.giveindia.org) and make a small donation to help us fight COVID and overcome this crisis.
+Visit [https://indiafightscorona.giveindia.org](https://indiafightscorona.giveindia.org) and make a small donation to help us fight COVID and overcome this crisis.
A small donation goes a long way. :heart:
@@ -171,7 +171,7 @@ You can customize the appearance of your `Stats Card` or `Repo Card` however you
- `locale` - set the language in the card _(e.g. cn, de, es, etc.)_
- `border_radius` - Corner rounding on the card
-> Note: The minimum of cache_seconds is currently 4 hours as a temporary fix for PATs exhaustion.
+> Note: The minimum of cache_seconds is currently 4 hours as a temporary fix for PATs exhaustion.
##### Gradient in bg_color
@@ -193,6 +193,7 @@ You can provide multiple comma-separated values in the bg_color option to render
- `include_all_commits` - Count total commits instead of just the current year commits _(boolean)_
- `count_private` - Count private commits _(boolean)_
- `line_height` - Sets the line-height between text _(number)_
+- `exclude_repo` - Exclude stars from specified repositories _(Comma-separated values)_
- `custom_title` - Sets a custom title for the card
- `disable_animations` - Disables all animations in the card _(boolean)_
diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js
index 2617137a40752..dc9be5bb4f89c 100644
--- a/src/fetchers/stats-fetcher.js
+++ b/src/fetchers/stats-fetcher.js
@@ -47,6 +47,7 @@ const fetcher = (variables, token) => {
repositories(first: 100, ownerAffiliations: OWNER, orderBy: {direction: DESC, field: STARGAZERS}) {
totalCount
nodes {
+ name
stargazers {
totalCount
}
@@ -108,6 +109,7 @@ async function fetchStats(
username,
count_private = false,
include_all_commits = false,
+ exclude_repo = [],
) {
if (!username) throw new MissingParamError(["username"]);
@@ -133,6 +135,15 @@ async function fetchStats(
const user = res.data.data.user;
+ // populate repoToHide map for quick lookup
+ // while filtering out
+ let repoToHide = {};
+ if (exclude_repo) {
+ exclude_repo.forEach((repoName) => {
+ repoToHide[repoName] = true;
+ });
+ }
+
stats.name = user.name || user.login;
stats.totalIssues = user.openIssues.totalCount + user.closedIssues.totalCount;
@@ -154,9 +165,14 @@ async function fetchStats(
stats.totalPRs = user.pullRequests.totalCount;
stats.contributedTo = user.repositoriesContributedTo.totalCount;
- stats.totalStars = user.repositories.nodes.reduce((prev, curr) => {
- return prev + curr.stargazers.totalCount;
- }, 0);
+ // Retrieve stars while filtering out repositories to be hidden
+ stats.totalStars = user.repositories.nodes
+ .filter((data) => {
+ return !repoToHide[data.name];
+ })
+ .reduce((prev, curr) => {
+ return prev + curr.stargazers.totalCount;
+ }, 0);
stats.rank = calculateRank({
totalCommits: stats.totalCommits,
diff --git a/tests/fetchStats.test.js b/tests/fetchStats.test.js
index f732182f8fe5a..fe2fd4d7fd4fc 100644
--- a/tests/fetchStats.test.js
+++ b/tests/fetchStats.test.js
@@ -20,11 +20,11 @@ const data = {
repositories: {
totalCount: 5,
nodes: [
- { stargazers: { totalCount: 100 } },
- { stargazers: { totalCount: 100 } },
- { stargazers: { totalCount: 100 } },
- { stargazers: { totalCount: 50 } },
- { stargazers: { totalCount: 50 } },
+ { name: "test-repo-1", stargazers: { totalCount: 100 } },
+ { name: "test-repo-2", stargazers: { totalCount: 100 } },
+ { name: "test-repo-3", stargazers: { totalCount: 100 } },
+ { name: "test-repo-4", stargazers: { totalCount: 50 } },
+ { name: "test-repo-5", stargazers: { totalCount: 50 } },
],
},
},
@@ -134,4 +134,37 @@ describe("Test fetchStats", () => {
rank,
});
});
+
+ it("should exclude stars of the `test-repo-1` repository", async () => {
+ mock.onPost("https://api.github.com/graphql").reply(200, data);
+ mock
+ .onGet("https://api.github.com/search/commits?q=author:anuraghazra")
+ .reply(200, { total_count: 1000 });
+
+ let stats = await fetchStats(
+ "anuraghazra",
+ true,
+ true,
+ (exclude_repo = ["test-repo-1"]),
+ );
+ const rank = calculateRank({
+ totalCommits: 1050,
+ totalRepos: 5,
+ followers: 100,
+ contributions: 61,
+ stargazers: 300,
+ prs: 300,
+ issues: 200,
+ });
+
+ expect(stats).toStrictEqual({
+ contributedTo: 61,
+ name: "Anurag Hazra",
+ totalCommits: 1050,
+ totalIssues: 200,
+ totalPRs: 300,
+ totalStars: 300,
+ rank,
+ });
+ });
});
From eacc3cd29cecde23d488023ff8dc2326bc69c25d Mon Sep 17 00:00:00 2001
From: rickstaa
Date: Sat, 17 Sep 2022 11:28:50 +0200
Subject: [PATCH 26/36] fix: add missing StatsCard types
---
src/cards/types.d.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/cards/types.d.ts b/src/cards/types.d.ts
index 4580a2eaa2083..46bf6659c07d0 100644
--- a/src/cards/types.d.ts
+++ b/src/cards/types.d.ts
@@ -16,6 +16,7 @@ export type StatCardOptions = CommonOptions & {
show_icons: boolean;
hide_title: boolean;
hide_border: boolean;
+ card_width: number;
hide_rank: boolean;
include_all_commits: boolean;
line_height: number | string;
From f9b9015ec2566b0a2afa930d97d9637019cd967f Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Sat, 17 Sep 2022 13:32:40 +0200
Subject: [PATCH 27/36] feat(stats): add 'not_bold' option to stats card
(#1468)
---
api/index.js | 2 ++
readme.md | 2 ++
src/cards/stats-card.js | 9 +++++++--
src/getStyles.js | 1 +
tests/__snapshots__/renderWakatimeCard.test.js.snap | 2 ++
5 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/api/index.js b/api/index.js
index 207500597f8dd..2315dddaa302d 100644
--- a/api/index.js
+++ b/api/index.js
@@ -26,6 +26,7 @@ module.exports = async (req, res) => {
title_color,
icon_color,
text_color,
+ text_bold,
bg_color,
theme,
cache_seconds,
@@ -75,6 +76,7 @@ module.exports = async (req, res) => {
title_color,
icon_color,
text_color,
+ text_bold: parseBoolean(text_bold),
bg_color,
theme,
custom_title,
diff --git a/readme.md b/readme.md
index a4034ee237d63..3ef407248312e 100644
--- a/readme.md
+++ b/readme.md
@@ -195,6 +195,7 @@ You can provide multiple comma-separated values in the bg_color option to render
- `line_height` - Sets the line-height between text _(number)_
- `exclude_repo` - Exclude stars from specified repositories _(Comma-separated values)_
- `custom_title` - Sets a custom title for the card
+- `text_bold` - Use bold text _(boolean)_
- `disable_animations` - Disables all animations in the card _(boolean)_
#### Repo Card Exclusive Options:
@@ -453,3 +454,4 @@ Thanks! :heart:
Contributions are welcome! <3
Made with :heart: and JavaScript.
+
diff --git a/src/cards/stats-card.js b/src/cards/stats-card.js
index bbc48cfc1a7ea..30056b8526af6 100644
--- a/src/cards/stats-card.js
+++ b/src/cards/stats-card.js
@@ -20,6 +20,7 @@ const createTextNode = ({
index,
showIcons,
shiftValuePos,
+ bold,
}) => {
const kValue = kFormatter(value);
const staggerDelay = (index + 3) * 150;
@@ -35,9 +36,11 @@ const createTextNode = ({
return `
${iconSvg}
- ${label}:
+ ${label}:
{
title_color,
icon_color,
text_color,
+ text_bold = true,
bg_color,
theme = "default",
custom_title,
@@ -165,6 +169,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
showIcons: show_icons,
shiftValuePos:
(!include_all_commits ? 50 : 35) + (isLongLocale ? 50 : 0),
+ bold: text_bold,
}),
);
diff --git a/src/getStyles.js b/src/getStyles.js
index e5013e567f732..e76b51f4f4de8 100644
--- a/src/getStyles.js
+++ b/src/getStyles.js
@@ -85,6 +85,7 @@ const getStyles = ({
animation: scaleInAnimation 0.3s ease-in-out forwards;
}
+ .not_bold { font-weight: 400 }
.bold { font-weight: 700 }
.icon {
fill: ${iconColor};
diff --git a/tests/__snapshots__/renderWakatimeCard.test.js.snap b/tests/__snapshots__/renderWakatimeCard.test.js.snap
index aa5641a0aa56f..bd62580224b3d 100644
--- a/tests/__snapshots__/renderWakatimeCard.test.js.snap
+++ b/tests/__snapshots__/renderWakatimeCard.test.js.snap
@@ -41,6 +41,7 @@ exports[`Test Render Wakatime Card should render correctly 1`] = `
animation: scaleInAnimation 0.3s ease-in-out forwards;
}
+ .not_bold { font-weight: 400 }
.bold { font-weight: 700 }
.icon {
fill: #4c71f2;
@@ -202,6 +203,7 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1
animation: scaleInAnimation 0.3s ease-in-out forwards;
}
+ .not_bold { font-weight: 400 }
.bold { font-weight: 700 }
.icon {
fill: #4c71f2;
From 40735124ed33b7759b3f25928519f6da5e369d7f Mon Sep 17 00:00:00 2001
From: Rick Staa
Date: Sat, 17 Sep 2022 13:42:16 +0200
Subject: [PATCH 28/36] ci: change theme-preview action run condition (#1903)
This commit makes sure that the theme-preview action only runs when a
theme was added or changed.
---
.github/workflows/preview-theme.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/preview-theme.yml b/.github/workflows/preview-theme.yml
index f102b59c07eba..db7e291daad8a 100644
--- a/.github/workflows/preview-theme.yml
+++ b/.github/workflows/preview-theme.yml
@@ -5,8 +5,10 @@ on:
types: [opened, synchronize, reopened]
branches:
- master
- - theme-preview-script
+ - theme_preview_script
+ paths:
- "themes/index.js"
+ - "scripts/preview-theme.js"
jobs:
build:
From 107f7ca52c3431bf989e7c3624ad130e98cb4f5a Mon Sep 17 00:00:00 2001
From: rsk2
Date: Sat, 24 Sep 2022 13:50:54 +0530
Subject: [PATCH 29/36] Feature/grs 1955 change commonjs imports (#1995)
* GRS-1955: Using ES6 import/export in src files
* GRS-1955: Using ES6 import/export in test files
* GRS-1955: Using ES6 import/export in themes index.js
* GRS-1955: Readding blank line at end of top-languages-card.js
* feat: fix test es6 import errors
This commit makes sure jest is set-up to support es6. It also fixes
several test errors and sorts the imports.
* test: update test node version
This commit makes sure node 16 is used in the github actions.
* refactor: run prettier
Co-authored-by: rickstaa
---
.github/workflows/generate-theme-doc.yml | 2 +-
.github/workflows/test.yml | 2 +-
api/index.js | 18 +-
api/pin.js | 15 +-
api/top-langs.js | 18 +-
api/wakatime.js | 16 +-
jest.config.js | 4 +-
package.json | 14 +-
scripts/generate-langs-json.js | 6 +-
scripts/generate-theme-doc.js | 8 +-
scripts/preview-theme.js | 29 +-
scripts/push-theme-readme.sh | 2 +-
src/calculateRank.js | 7 +-
src/cards/repo-card.js | 21 +-
src/cards/stats-card.js | 23 +-
src/cards/top-languages-card.js | 19 +-
src/cards/wakatime-card.js | 22 +-
src/common/Card.js | 7 +-
src/common/I18n.js | 3 +-
src/common/blacklist.js | 3 +-
src/common/createProgressNode.js | 7 +-
src/common/icons.js | 3 +-
src/common/languageColors.json | 2 +-
src/common/retryer.js | 5 +-
src/common/utils.js | 10 +-
src/fetchers/repo-fetcher.js | 7 +-
src/fetchers/stats-fetcher.js | 23 +-
src/fetchers/top-languages-fetcher.js | 11 +-
src/fetchers/wakatime-fetcher.js | 9 +-
src/getStyles.js | 6 +-
src/translations.js | 4 +-
.../renderWakatimeCard.test.js.snap | 268 ++++--------------
tests/api.test.js | 14 +-
tests/calculateRank.test.js | 4 +-
tests/card.test.js | 12 +-
tests/fetchRepo.test.js | 8 +-
tests/fetchStats.test.js | 17 +-
tests/fetchTopLanguages.test.js | 13 +-
tests/fetchWakatime.test.js | 32 +--
tests/flexLayout.test.js | 2 +-
tests/pin.test.js | 13 +-
tests/renderRepoCard.test.js | 10 +-
tests/renderStatsCard.test.js | 17 +-
tests/renderTopLanguages.test.js | 22 +-
tests/renderWakatimeCard.test.js | 13 +-
tests/retryer.test.js | 7 +-
tests/top-langs.test.js | 13 +-
tests/utils.test.js | 18 +-
themes/index.js | 4 +-
49 files changed, 338 insertions(+), 475 deletions(-)
diff --git a/.github/workflows/generate-theme-doc.yml b/.github/workflows/generate-theme-doc.yml
index 9028044d97e27..75fcb89bb8064 100644
--- a/.github/workflows/generate-theme-doc.yml
+++ b/.github/workflows/generate-theme-doc.yml
@@ -16,7 +16,7 @@ jobs:
- name: setup node
uses: actions/setup-node@v1
with:
- node-version: "12.x"
+ node-version: "16.x"
- name: npm install, generate readme
run: |
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0911168f33754..f5eec3514d8c0 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -18,7 +18,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v1
with:
- node-version: "12.x"
+ node-version: "16.x"
- name: Install & Test
run: |
diff --git a/api/index.js b/api/index.js
index 2315dddaa302d..64231a5975908 100644
--- a/api/index.js
+++ b/api/index.js
@@ -1,17 +1,19 @@
-require("dotenv").config();
-const {
+import {
renderError,
parseBoolean,
parseArray,
clampValue,
CONSTANTS,
-} = require("../src/common/utils");
-const fetchStats = require("../src/fetchers/stats-fetcher");
-const renderStatsCard = require("../src/cards/stats-card");
-const blacklist = require("../src/common/blacklist");
-const { isLocaleAvailable } = require("../src/translations");
+} from "../src/common/utils";
+import fetchStats from "../src/fetchers/stats-fetcher";
+import renderStatsCard from "../src/cards/stats-card";
+import blacklist from "../src/common/blacklist";
+import { isLocaleAvailable } from "../src/translations";
+import * as dotenv from "dotenv";
-module.exports = async (req, res) => {
+dotenv.config();
+
+export default async (req, res) => {
const {
username,
hide,
diff --git a/api/pin.js b/api/pin.js
index f2761cb64d9dd..190238851f7cd 100644
--- a/api/pin.js
+++ b/api/pin.js
@@ -1,16 +1,15 @@
-require("dotenv").config();
-const {
+import {
renderError,
parseBoolean,
clampValue,
CONSTANTS,
-} = require("../src/common/utils");
-const fetchRepo = require("../src/fetchers/repo-fetcher");
-const renderRepoCard = require("../src/cards/repo-card");
-const blacklist = require("../src/common/blacklist");
-const { isLocaleAvailable } = require("../src/translations");
+} from "../src/common/utils";
+import fetchRepo from "../src/fetchers/repo-fetcher";
+import renderRepoCard from "../src/cards/repo-card";
+import blacklist from "../src/common/blacklist";
+import { isLocaleAvailable } from "../src/translations";
-module.exports = async (req, res) => {
+export default async (req, res) => {
const {
username,
repo,
diff --git a/api/top-langs.js b/api/top-langs.js
index 808020743a930..d83d9d6a9ba75 100644
--- a/api/top-langs.js
+++ b/api/top-langs.js
@@ -1,17 +1,19 @@
-require("dotenv").config();
-const {
+import {
renderError,
clampValue,
parseBoolean,
parseArray,
CONSTANTS,
-} = require("../src/common/utils");
-const fetchTopLanguages = require("../src/fetchers/top-languages-fetcher");
-const renderTopLanguages = require("../src/cards/top-languages-card");
-const blacklist = require("../src/common/blacklist");
-const { isLocaleAvailable } = require("../src/translations");
+} from "../src/common/utils";
+import fetchTopLanguages from "../src/fetchers/top-languages-fetcher";
+import { renderTopLanguages } from "../src/cards/top-languages-card";
+import blacklist from "../src/common/blacklist";
+import { isLocaleAvailable } from "../src/translations";
+import * as dotenv from "dotenv";
-module.exports = async (req, res) => {
+dotenv.config();
+
+export default async (req, res) => {
const {
username,
hide,
diff --git a/api/wakatime.js b/api/wakatime.js
index 18b521895f90f..8e27e2f273ee6 100644
--- a/api/wakatime.js
+++ b/api/wakatime.js
@@ -1,16 +1,18 @@
-require("dotenv").config();
-const {
+import {
renderError,
parseBoolean,
clampValue,
parseArray,
CONSTANTS,
-} = require("../src/common/utils");
-const { isLocaleAvailable } = require("../src/translations");
-const { fetchWakatimeStats } = require("../src/fetchers/wakatime-fetcher");
-const wakatimeCard = require("../src/cards/wakatime-card");
+} from "../src/common/utils";
+import { isLocaleAvailable } from "../src/translations";
+import fetchWakatimeStats from "../src/fetchers/wakatime-fetcher";
+import wakatimeCard from "../src/cards/wakatime-card";
+import * as dotenv from "dotenv";
-module.exports = async (req, res) => {
+dotenv.config();
+
+export default async (req, res) => {
const {
username,
title_color,
diff --git a/jest.config.js b/jest.config.js
index 0d51c47ddad31..7fbe69b687566 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -1,3 +1,5 @@
-module.exports = {
+export default {
clearMocks: true,
+ transform: {},
+ testEnvironment: "jsdom",
};
diff --git a/package.json b/package.json
index be9e43541aae0..4cfcd074bdc64 100644
--- a/package.json
+++ b/package.json
@@ -3,9 +3,11 @@
"version": "1.0.0",
"description": "Dynamically generate stats for your github readmes",
"main": "index.js",
+ "type": "module",
"scripts": {
- "test": "jest --coverage",
- "test:watch": "jest --watch",
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
+ "test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
+ "test:update:snapshot": "node --experimental-vm-modules node_modules/jest/bin/jest.js -u",
"theme-readme-gen": "node scripts/generate-theme-doc",
"preview-theme": "node scripts/preview-theme",
"generate-langs-json": "node scripts/generate-langs-json",
@@ -20,14 +22,15 @@
"devDependencies": {
"@actions/core": "^1.2.4",
"@actions/github": "^4.0.0",
- "@testing-library/dom": "^7.20.0",
- "@testing-library/jest-dom": "^5.11.0",
+ "@testing-library/dom": "^8.17.1",
+ "@testing-library/jest-dom": "^5.16.5",
+ "jest-environment-jsdom": "^29.0.3",
+ "jest": "^29.0.3",
"@uppercod/css-to-object": "^1.1.1",
"axios-mock-adapter": "^1.18.1",
"color-contrast-checker": "^2.1.0",
"hjson": "^3.2.2",
"husky": "^4.2.5",
- "jest": "^26.1.0",
"js-yaml": "^4.1.0",
"lodash.snakecase": "^4.1.1",
"parse-diff": "^0.7.0",
@@ -38,6 +41,7 @@
"dotenv": "^8.2.0",
"emoji-name-map": "^1.2.8",
"github-username-regex": "^1.0.0",
+ "upgrade": "^1.1.0",
"word-wrap": "^1.2.3"
},
"husky": {
diff --git a/scripts/generate-langs-json.js b/scripts/generate-langs-json.js
index bd210a3c53fe9..803d60b19321f 100644
--- a/scripts/generate-langs-json.js
+++ b/scripts/generate-langs-json.js
@@ -1,6 +1,6 @@
-const fs = require("fs");
-const jsYaml = require("js-yaml");
-const axios = require("axios");
+import axios from "axios";
+import fs from "fs";
+import jsYaml from "js-yaml";
const LANGS_FILEPATH = "./src/common/languageColors.json";
diff --git a/scripts/generate-theme-doc.js b/scripts/generate-theme-doc.js
index fcb3c5eee705c..e8b83ad2b3f20 100644
--- a/scripts/generate-theme-doc.js
+++ b/scripts/generate-theme-doc.js
@@ -1,5 +1,5 @@
-const theme = require("../themes/index");
-const fs = require("fs");
+import fs from "fs";
+import { themes } from "../themes/index";
const TARGET_FILE = "./themes/README.md";
const REPO_CARD_LINKS_FLAG = "";
@@ -54,7 +54,7 @@ const createStatMdLink = (theme) => {
};
const generateLinks = (fn) => {
- return Object.keys(theme)
+ return Object.keys(themes)
.map((name) => fn(name))
.join("");
};
@@ -65,7 +65,7 @@ const createTableItem = ({ link, label, isRepoCard }) => {
};
const generateTable = ({ isRepoCard }) => {
const rows = [];
- const themes = Object.keys(theme).filter(
+ const themes = Object.keys(themes).filter(
(name) => name !== (!isRepoCard ? "default_repocard" : "default"),
);
diff --git a/scripts/preview-theme.js b/scripts/preview-theme.js
index e4422ecd0350a..33ee96bc2f01a 100644
--- a/scripts/preview-theme.js
+++ b/scripts/preview-theme.js
@@ -1,11 +1,12 @@
-const core = require("@actions/core");
-const github = require("@actions/github");
-const parse = require("parse-diff");
-const Hjson = require("hjson");
-const snakeCase = require("lodash.snakecase");
-const ColorContrastChecker = require("color-contrast-checker");
+import core from "@actions/core";
+import github from "@actions/github";
+import ColorContrastChecker from "color-contrast-checker";
+import * as dotenv from "dotenv";
+import Hjson from "hjson";
+import snakeCase from "lodash.snakecase";
+import parse from "parse-diff";
-require("dotenv").config();
+dotenv.config();
const OWNER = "anuraghazra";
const REPO = "github-readme-stats";
@@ -76,10 +77,10 @@ function getGrsLink(colors) {
}
const themeContribGuidelines = `
- \rHi, thanks for the theme contribution, please read our theme [contribution guidelines](https://github.com/anuraghazra/github-readme-stats/blob/master/CONTRIBUTING.md#themes-contribution).
+ \rHi, thanks for the theme contribution, please read our theme [contribution guidelines](https://github.com/anuraghazra/github-readme-stats/blob/master/CONTRIBUTING.md#themes-contribution).
\rWe are currently only accepting color combinations from any VSCode theme or themes which have good color combination to minimize bloating the themes collection.
- \r> Also note that if this theme is exclusively for your personal use, then instead of adding it to our theme collection you can use card [customization options](https://github.com/anuraghazra/github-readme-stats#customization)
+ \r> Also note that if this theme is exclusively for your personal use, then instead of adding it to our theme collection you can use card [customization options](https://github.com/anuraghazra/github-readme-stats#customization)
`;
async function run() {
@@ -128,7 +129,7 @@ async function run() {
issue_number: pullRequestId,
body: `
\r**${COMMENT_TITLE}**
-
+
\rCannot create theme preview
${themeContribGuidelines}
@@ -167,16 +168,16 @@ async function run() {
owner: OWNER,
repo: REPO,
body: `
- \r**${COMMENT_TITLE}**
-
+ \r**${COMMENT_TITLE}**
+
\r${warnings.map((warning) => `- :warning: ${warning}\n`).join("")}
\ntitle_color: #${titleColor}
| icon_color: #${iconColor}
| text_color: #${textColor}
| bg_color: #${bgColor}
-
+
\r[Preview Link](${url})
\r[](${url})
-
+
${themeContribGuidelines}
`,
});
diff --git a/scripts/push-theme-readme.sh b/scripts/push-theme-readme.sh
index 5223dd111ee55..946096bd4d592 100755
--- a/scripts/push-theme-readme.sh
+++ b/scripts/push-theme-readme.sh
@@ -11,4 +11,4 @@ git checkout -b $BRANCH_NAME
git add --all
git commit --message "docs(theme): Auto update theme readme" || exit 0
git remote add origin-$BRANCH_NAME https://${PERSONAL_TOKEN}@github.com/${GH_REPO}.git
-git push --force --quiet --set-upstream origin-$BRANCH_NAME $BRANCH_NAME
\ No newline at end of file
+git push --force --quiet --set-upstream origin-$BRANCH_NAME $BRANCH_NAME
diff --git a/src/calculateRank.js b/src/calculateRank.js
index 742b9ab17509d..bbfece157c2c8 100644
--- a/src/calculateRank.js
+++ b/src/calculateRank.js
@@ -57,8 +57,8 @@ function calculateRank({
issues * ISSUES_OFFSET +
stargazers * STARS_OFFSET +
prs * PRS_OFFSET +
- followers * FOLLOWERS_OFFSET +
- totalRepos * REPO_OFFSET
+ followers * FOLLOWERS_OFFSET +
+ totalRepos * REPO_OFFSET
) / 100;
const normalizedScore = normalcdf(score, TOTAL_VALUES, ALL_OFFSETS) * 100;
@@ -74,4 +74,5 @@ function calculateRank({
return { level, score: normalizedScore };
}
-module.exports = calculateRank;
+export { calculateRank };
+export default calculateRank;
diff --git a/src/cards/repo-card.js b/src/cards/repo-card.js
index 034ee1f6cdf79..61073beefd345 100644
--- a/src/cards/repo-card.js
+++ b/src/cards/repo-card.js
@@ -1,17 +1,17 @@
// @ts-check
-const {
- kFormatter,
+import { Card } from "../common/Card";
+import { I18n } from "../common/I18n";
+import { icons } from "../common/icons";
+import {
encodeHTML,
- getCardColors,
flexLayout,
- wrapTextMultiline,
+ getCardColors,
+ kFormatter,
measureText,
parseEmojis,
-} = require("../common/utils");
-const I18n = require("../common/I18n");
-const Card = require("../common/Card");
-const icons = require("../common/icons");
-const { repoCardLocales } = require("../translations");
+ wrapTextMultiline,
+} from "../common/utils";
+import { repoCardLocales } from "../translations";
/**
* @param {string} label
@@ -185,4 +185,5 @@ const renderRepoCard = (repo, options = {}) => {
`);
};
-module.exports = renderRepoCard;
+export { renderRepoCard };
+export default renderRepoCard;
diff --git a/src/cards/stats-card.js b/src/cards/stats-card.js
index 30056b8526af6..962c1e4fbb813 100644
--- a/src/cards/stats-card.js
+++ b/src/cards/stats-card.js
@@ -1,16 +1,16 @@
// @ts-check
-const I18n = require("../common/I18n");
-const Card = require("../common/Card");
-const icons = require("../common/icons");
-const { getStyles } = require("../getStyles");
-const { statCardLocales } = require("../translations");
-const {
- kFormatter,
- flexLayout,
+import { Card } from "../common/Card";
+import { I18n } from "../common/I18n";
+import { icons } from "../common/icons";
+import {
clampValue,
- measureText,
+ flexLayout,
getCardColors,
-} = require("../common/utils");
+ kFormatter,
+ measureText,
+} from "../common/utils";
+import { getStyles } from "../getStyles";
+import { statCardLocales } from "../translations";
const createTextNode = ({
icon,
@@ -300,4 +300,5 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
`);
};
-module.exports = renderStatsCard;
+export { renderStatsCard };
+export default renderStatsCard;
diff --git a/src/cards/top-languages-card.js b/src/cards/top-languages-card.js
index b2f5c362dd47f..d8c182531f16a 100644
--- a/src/cards/top-languages-card.js
+++ b/src/cards/top-languages-card.js
@@ -1,16 +1,16 @@
// @ts-check
-const Card = require("../common/Card");
-const I18n = require("../common/I18n");
-const { langCardLocales } = require("../translations");
-const { createProgressNode } = require("../common/createProgressNode");
-const {
+import { Card } from "../common/Card";
+import { createProgressNode } from "../common/createProgressNode";
+import { I18n } from "../common/I18n";
+import {
+ chunkArray,
clampValue,
- getCardColors,
flexLayout,
+ getCardColors,
lowercaseTrim,
measureText,
- chunkArray,
-} = require("../common/utils");
+} from "../common/utils";
+import { langCardLocales } from "../translations";
const DEFAULT_CARD_WIDTH = 300;
const MIN_CARD_WIDTH = 230;
@@ -311,5 +311,4 @@ const renderTopLanguages = (topLangs, options = {}) => {
`);
};
-module.exports = renderTopLanguages;
-module.exports.MIN_CARD_WIDTH = MIN_CARD_WIDTH;
+export { renderTopLanguages, MIN_CARD_WIDTH };
diff --git a/src/cards/wakatime-card.js b/src/cards/wakatime-card.js
index 5ab2f29d890a9..2f30b941a93ae 100644
--- a/src/cards/wakatime-card.js
+++ b/src/cards/wakatime-card.js
@@ -1,16 +1,16 @@
// @ts-check
-const Card = require("../common/Card");
-const I18n = require("../common/I18n");
-const { getStyles } = require("../getStyles");
-const { wakatimeCardLocales } = require("../translations");
-const languageColors = require("../common/languageColors.json");
-const { createProgressNode } = require("../common/createProgressNode");
-const {
+import { Card } from "../common/Card";
+import { createProgressNode } from "../common/createProgressNode";
+import { I18n } from "../common/I18n";
+import languageColors from "../common/languageColors.json";
+import {
clampValue,
- getCardColors,
flexLayout,
+ getCardColors,
lowercaseTrim,
-} = require("../common/utils");
+} from "../common/utils";
+import { getStyles } from "../getStyles";
+import { wakatimeCardLocales } from "../translations";
/**
* @param {{color: string, text: string}} param0
@@ -314,5 +314,5 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
`);
};
-module.exports = renderWakatimeCard;
-exports.createProgressNode = createProgressNode;
+export { renderWakatimeCard };
+export default renderWakatimeCard;
diff --git a/src/common/Card.js b/src/common/Card.js
index 2cc845533a604..24ec4430e3863 100644
--- a/src/common/Card.js
+++ b/src/common/Card.js
@@ -1,5 +1,5 @@
-const { getAnimations } = require("../getStyles");
-const { flexLayout, encodeHTML } = require("../common/utils");
+import { encodeHTML, flexLayout } from "../common/utils";
+import { getAnimations } from "../getStyles";
class Card {
/**
@@ -216,4 +216,5 @@ class Card {
}
}
-module.exports = Card;
+export { Card };
+export default Card;
diff --git a/src/common/I18n.js b/src/common/I18n.js
index e28f605058c0d..7f607cd962f0d 100644
--- a/src/common/I18n.js
+++ b/src/common/I18n.js
@@ -18,4 +18,5 @@ class I18n {
}
}
-module.exports = I18n;
+export { I18n };
+export default I18n;
diff --git a/src/common/blacklist.js b/src/common/blacklist.js
index 3ef635c4bb81f..752ef943fa0f9 100644
--- a/src/common/blacklist.js
+++ b/src/common/blacklist.js
@@ -1,3 +1,4 @@
const blacklist = ["renovate-bot", "technote-space", "sw-yx"];
-module.exports = blacklist;
+export { blacklist };
+export default blacklist;
diff --git a/src/common/createProgressNode.js b/src/common/createProgressNode.js
index 0f15264548842..80abc8ffd44f9 100644
--- a/src/common/createProgressNode.js
+++ b/src/common/createProgressNode.js
@@ -1,4 +1,4 @@
-const { clampValue } = require("../common/utils");
+import { clampValue } from "../common/utils";
const createProgressNode = ({
x,
@@ -16,7 +16,7 @@ const createProgressNode = ({
@@ -25,4 +25,5 @@ const createProgressNode = ({
`;
};
-exports.createProgressNode = createProgressNode;
+export { createProgressNode };
+export default createProgressNode;
diff --git a/src/common/icons.js b/src/common/icons.js
index 7b7e5075c0f18..5282a93ec8725 100644
--- a/src/common/icons.js
+++ b/src/common/icons.js
@@ -8,4 +8,5 @@ const icons = {
fork: ``,
};
-module.exports = icons;
+export { icons };
+export default icons;
diff --git a/src/common/languageColors.json b/src/common/languageColors.json
index 12c85bd52f1ad..3c1370f761fc2 100644
--- a/src/common/languageColors.json
+++ b/src/common/languageColors.json
@@ -499,4 +499,4 @@
"wdl": "#42f1f4",
"wisp": "#7582D1",
"xBase": "#403a40"
-}
\ No newline at end of file
+}
diff --git a/src/common/retryer.js b/src/common/retryer.js
index b06d3e29afab3..f37aaa40a3906 100644
--- a/src/common/retryer.js
+++ b/src/common/retryer.js
@@ -1,4 +1,4 @@
-const { logger, CustomError } = require("../common/utils");
+import { CustomError, logger } from "../common/utils";
const retryer = async (fetcher, variables, retries = 0) => {
if (retries > 7) {
@@ -40,4 +40,5 @@ const retryer = async (fetcher, variables, retries = 0) => {
}
};
-module.exports = retryer;
+export { retryer };
+export default retryer;
diff --git a/src/common/utils.js b/src/common/utils.js
index 2ad18dddbc62a..042b6358faf8a 100644
--- a/src/common/utils.js
+++ b/src/common/utils.js
@@ -1,8 +1,8 @@
// @ts-check
-const axios = require("axios");
-const wrap = require("word-wrap");
-const themes = require("../../themes");
-const toEmoji = require("emoji-name-map");
+import axios from "axios";
+import toEmoji from "emoji-name-map";
+import wrap from "word-wrap";
+import { themes } from "../../themes";
/**
* @param {string} message
@@ -370,7 +370,7 @@ function parseEmojis(str) {
});
}
-module.exports = {
+export {
renderError,
kFormatter,
encodeHTML,
diff --git a/src/fetchers/repo-fetcher.js b/src/fetchers/repo-fetcher.js
index 0bad5f2bd08fd..c55c3d7175e1d 100644
--- a/src/fetchers/repo-fetcher.js
+++ b/src/fetchers/repo-fetcher.js
@@ -1,6 +1,6 @@
// @ts-check
-const retryer = require("../common/retryer");
-const { request, MissingParamError } = require("../common/utils");
+import { retryer } from "../common/retryer";
+import { MissingParamError, request } from "../common/utils";
/**
* @param {import('Axios').AxiosRequestHeaders} variables
@@ -97,4 +97,5 @@ async function fetchRepo(username, reponame) {
}
}
-module.exports = fetchRepo;
+export { fetchRepo };
+export default fetchRepo;
diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js
index dc9be5bb4f89c..cb13255b6d907 100644
--- a/src/fetchers/stats-fetcher.js
+++ b/src/fetchers/stats-fetcher.js
@@ -1,17 +1,17 @@
// @ts-check
-const axios = require("axios").default;
-const githubUsernameRegex = require("github-username-regex");
-
-const retryer = require("../common/retryer");
-const calculateRank = require("../calculateRank");
-const {
- request,
- logger,
+import axios from "axios";
+import * as dotenv from "dotenv";
+import githubUsernameRegex from "github-username-regex";
+import { calculateRank } from "../calculateRank";
+import { retryer } from "../common/retryer";
+import {
CustomError,
+ logger,
MissingParamError,
-} = require("../common/utils");
+ request,
+} from "../common/utils";
-require("dotenv").config();
+dotenv.config();
/**
* @param {import('axios').AxiosRequestHeaders} variables
@@ -187,4 +187,5 @@ async function fetchStats(
return stats;
}
-module.exports = fetchStats;
+export { fetchStats };
+export default fetchStats;
diff --git a/src/fetchers/top-languages-fetcher.js b/src/fetchers/top-languages-fetcher.js
index 7c4c8785c87f9..555fb0632af17 100644
--- a/src/fetchers/top-languages-fetcher.js
+++ b/src/fetchers/top-languages-fetcher.js
@@ -1,7 +1,9 @@
// @ts-check
-const { request, logger, MissingParamError } = require("../common/utils");
-const retryer = require("../common/retryer");
-require("dotenv").config();
+import * as dotenv from "dotenv";
+import { retryer } from "../common/retryer";
+import { logger, MissingParamError, request } from "../common/utils";
+
+dotenv.config();
/**
* @param {import('Axios').AxiosRequestHeaders} variables
@@ -104,4 +106,5 @@ async function fetchTopLanguages(username, exclude_repo = []) {
return topLangs;
}
-module.exports = fetchTopLanguages;
+export { fetchTopLanguages };
+export default fetchTopLanguages;
diff --git a/src/fetchers/wakatime-fetcher.js b/src/fetchers/wakatime-fetcher.js
index fe06c6385e7df..8c40deb4028c5 100644
--- a/src/fetchers/wakatime-fetcher.js
+++ b/src/fetchers/wakatime-fetcher.js
@@ -1,5 +1,5 @@
-const axios = require("axios");
-const { MissingParamError } = require("../common/utils");
+import axios from "axios";
+import { MissingParamError } from "../common/utils";
/**
* @param {{username: string, api_domain: string, range: string}} props
@@ -26,6 +26,5 @@ const fetchWakatimeStats = async ({ username, api_domain, range }) => {
}
};
-module.exports = {
- fetchWakatimeStats,
-};
+export { fetchWakatimeStats };
+export default fetchWakatimeStats;
diff --git a/src/getStyles.js b/src/getStyles.js
index e76b51f4f4de8..3c77787e7e655 100644
--- a/src/getStyles.js
+++ b/src/getStyles.js
@@ -81,7 +81,7 @@ const getStyles = ({
animation: fadeInAnimation 0.3s ease-in-out forwards;
}
.rank-text {
- font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor};
+ font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor};
animation: scaleInAnimation 0.3s ease-in-out forwards;
}
@@ -91,7 +91,7 @@ const getStyles = ({
fill: ${iconColor};
display: ${!!show_icons ? "block" : "none"};
}
-
+
.rank-circle-rim {
stroke: ${titleColor};
fill: none;
@@ -113,4 +113,4 @@ const getStyles = ({
`;
};
-module.exports = { getStyles, getAnimations };
+export { getStyles, getAnimations };
diff --git a/src/translations.js b/src/translations.js
index 31b2d218d5486..c91dcb5e7dd41 100644
--- a/src/translations.js
+++ b/src/translations.js
@@ -1,4 +1,4 @@
-const { encodeHTML } = require("./common/utils");
+import { encodeHTML } from "./common/utils";
const statCardLocales = ({ name, apostrophe }) => {
const encodedName = encodeHTML(name);
@@ -358,7 +358,7 @@ function isLocaleAvailable(locale) {
return availableLocales.includes(locale.toLowerCase());
}
-module.exports = {
+export {
isLocaleAvailable,
availableLocales,
statCardLocales,
diff --git a/tests/__snapshots__/renderWakatimeCard.test.js.snap b/tests/__snapshots__/renderWakatimeCard.test.js.snap
index bd62580224b3d..69e22e4ab575f 100644
--- a/tests/__snapshots__/renderWakatimeCard.test.js.snap
+++ b/tests/__snapshots__/renderWakatimeCard.test.js.snap
@@ -1,180 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Test Render Wakatime Card should render correctly 1`] = `
-"
-
- "
-`;
+exports[`Test Render Wakatime Card should render correctly 1`] = `[Function]`;
exports[`Test Render Wakatime Card should render correctly with compact layout 1`] = `
"
-
-
+
+