Compare commits

..
Author SHA1 Message Date
anuraghazra f2936add74 docs: added contributing.md
Test / build (push) Canceled after 0s
2020-07-25 20:24:48 +05:30
anuraghazra b5c4cc71f5 Merge branch 'patch-1' of https://github.com/vasugamdha/github-readme-stats into vasugamdha-patch-1 2020-07-25 20:01:53 +05:30
Yash 64d1fb46c3 style(theme): Add Night-Owl Theme (#186)
* Added Night-Owl Theme

* corrected quotes

* minor changes
2020-07-25 19:44:42 +05:30
SagarandAnurag Hazra 753f0b9fec feat(themes): Added shades of purple theme (#185)
* 📦 NEW: shade of purple theme

* style(theme): icons color update

* chore: change theme name

Co-authored-by: Anurag Hazra <hazru.anurag@gmail.com>
2020-07-25 18:26:15 +05:30
Anurag Hazra f50938c908 Merge pull request #182 from anuraghazra/show-statcard-org-error
chore: added secondary warning message in renderError
2020-07-25 13:50:18 +05:30
anuraghazra 6d5a828542 chore: added secondary warning message in renderError 2020-07-25 13:29:32 +05:30
Anurag Hazra e32ab3f973 Merge pull request #178 from anuraghazra/fix-unicode
fix: weird unicode char
2020-07-24 23:46:38 +05:30
anuraghazra 2812ce0fd3 fix: weird unicode char 2020-07-24 23:35:20 +05:30
Feng L.HandAnurag Hazra f9b14c9442 style(theme): Added Vue theme (#143)
Add Vue style.

Co-authored-by: Anurag Hazra <hazru.anurag@gmail.com>
2020-07-24 22:06:19 +05:30
Naufal Yudhistira 7b509d3128 style(theme): Add monokai theme (#124)
* style(theme): Add new theme

* style(theme): Change monokai style

* style(theme): Change monokai style

* feat(theme): Add theme randomizer

* fix(theme): Make randomizer asynchronous

* feat(theme): Add theme randomizer

* fix(theme): Fix everything back ._.

* fix(theme): Change theme based on review
2020-07-24 21:58:23 +05:30
leavesster f355f48bb4 doc(translation): add Hide individual languages in readme_cn (#173) 2020-07-24 20:09:35 +05:30
Fábio Rosadoandanuraghazra 4c0518616f feat: Add count_private flag to count private contributions (#148)
* Add private contributions count

* Remove unused var and add tests

* Update readme

* fix: tests & minor code formating

* docs: updated docs

Co-authored-by: anuraghazra <hazru.anurag@gmail.com>
2020-07-24 19:34:38 +05:30
Mario Lubenkaandanuraghazra 3a9ded0a09 feat(repocard): parse emojis in description (#67)
* feat: add remove_emojis option

Removes emojis in repo card description

* feat: parse emojis

* feat: rename remove_emojis to show_emojis option for consistency

* docs: update docs

Co-authored-by: anuraghazra <hazru.anurag@gmail.com>
2020-07-24 18:56:26 +05:30
obsidian 7973805cf7 doc(translation): fixed typo and retranslated some titles. (#172) 2020-07-24 18:23:50 +05:30
Joydip Roy a7d56c3a04 docs: changed bugs and feature link (#137)
* docs: changed bugs and feature link

* link change as per suggestion
2020-07-24 18:15:20 +05:30
obsidian 13d9da68ff docs: Added content about "Top Langs" in readme_cn.md (#144)
* doc: supplement readme_cn.md.

* rm -rf .idea
2020-07-24 17:46:45 +05:30
Liamandanuraghazra 9624cf6acd fix: stats hide_border bug (#151)
* fix: stats hide border bug

* fix white border on dark mode issue

* chore: refactor code & tests

Co-authored-by: anuraghazra <hazru.anurag@gmail.com>
2020-07-24 13:07:09 +05:30
Anurag Hazra 7a8510641c Merge pull request #166 from terror/typo-fix-top-lang
docs: fix typo in top lang section
2020-07-24 12:47:41 +05:30
Liam bd13399e7f docs: fix typo in top lang section 2020-07-23 23:25:25 -04:00
Anurag Hazra aa44bd7615 fix: hide parameter array implementation (#162)
* fix: hide paramter array implementation

* chore: parseArray str check

* docs: updated readme

* chore: add codecov threshold

* docs: update docs
2020-07-23 21:01:23 +05:30
Arjun Mahishiandanuraghazra c2adcfd6fe feat: hide specific languages in "Top languages" card (#150)
* add new query param to hide specific languages in top languages card

* [top-langs] add function to clean out the provided lang name

* [top-langs] rename 'hide_lang' => 'hide', refactor logic for parsing the list of provided languages to hide

* [top-langs] take list of languages to hide, as a json array

* chore: minor changes

* docs: added docs for hide lang

Co-authored-by: anuraghazra <hazru.anurag@gmail.com>
2020-07-23 19:47:04 +05:30
Anurag Hazra 17c33cd322 chore: added buymeacoffee link 2020-07-23 14:18:50 +05:30
Anurag Hazra 1c4cb84916 Merge pull request #156 from anuraghazra/fix-repo-lang-fallback
fix: languages color fallback & hide lang if not present
2020-07-23 13:52:17 +05:30
anuraghazra d394add560 fix: languages color fallback & hide lang if not present 2020-07-23 13:41:37 +05:30
Joydip Royandanuraghazra 5ed75e11be feat: added isTemplate badge & refactored console.logs (#146)
* feat: template option added husky added for same commit disable console in test \
logger utils added env checked for log modified git ignore

* changed are done as per the suggesstion

* changed style and font

* text color dynamic

* fix border and using .bagde class as common

* simplified the badge svg code through a common method

* chore: updated css & fixed tests

Co-authored-by: anuraghazra <hazru.anurag@gmail.com>
2020-07-23 13:05:50 +05:30
Anurag Hazra 03f55e809e infra: added Codecov yml (#149)
* chore: test codecov

* fix: workflow file

* fix: workflow file

* chore: added coverage in vercelignore

* docs: added codecov badge

* chore: add codecov.yml
2020-07-22 23:46:10 +05:30
Anurag Hazra 63ba6e6601 infra: Added codecov test coverage (#147)
* chore: test codecov

* fix: workflow file

* fix: workflow file

* chore: added coverage in vercelignore

* docs: added codecov badge
2020-07-22 23:26:10 +05:30
Anurag Hazra dc3e9a59f2 Merge pull request #133 from anuraghazra/add-redirect
chore: add redirect to gh repo
2020-07-21 21:26:46 +05:30
anuraghazra 8284be105d chore: add redirect to gh repo 2020-07-21 21:24:39 +05:30
Anurag Hazra 6c16020c53 Merge pull request #131 from anuraghazra/fix-sort-langcard
fix: fixed sorting of languages by percentage
2020-07-21 20:00:56 +05:30
anuraghazra 8a8ff5b390 fix: fixed sorting of languages by percentage 2020-07-21 19:58:13 +05:30
Anurag Hazra 4b01b4187c Merge pull request #129 from nombrekeff/patch-2
docs: Added "prussian" theme to themes/README preview
2020-07-21 19:53:14 +05:30
Manolo Edge c3de4675c5 Added "prussian" theme to themes/README preview 2020-07-21 16:10:44 +02:00
Anurag Hazra ad87824f3c Merge pull request #128 from anuraghazra/top-langs
feat: added Top languages card
2020-07-21 18:59:02 +05:30
Vasu Gamdha 8372346626 Create CONTRIBUTING.md 2020-07-21 01:01:08 +05:30
32 changed files with 572 additions and 124 deletions
+1 -1
View File
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["https://www.paypal.me/anuraghazra"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ["https://www.paypal.me/anuraghazra", "https://www.buymeacoffee.com/anuraghazra"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+3
View File
@@ -34,3 +34,6 @@ jobs:
run: |
npm install
npm run test
- name: Code Coverage
uses: codecov/codecov-action@v1
+3
View File
@@ -2,3 +2,6 @@
.env
node_modules
package-lock.json
*.lock
.vscode/
coverage
+2 -1
View File
@@ -1,2 +1,3 @@
.env
package-lock.json
package-lock.json
coverage
+75
View File
@@ -0,0 +1,75 @@
# Contributing to [github-readme-stats](https://github.com/anuraghazra/github-readme-stats)
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
- Reporting a issue
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer
## All Changes Happen Through Pull Requests
Pull requests are the best way to propose changes. We actively welcome your pull requests:
1. Fork the repo and create your branch from `master`.
1. If you've added code that should be tested, add some tests' example.
1. If you've changed APIs, update the documentation.
1. Issue that pull request!
## Local Development
To run & test github-readme-stats you need to follow few simple steps :-
_(make sure you already have a [vercel](https://vercel.com/) account)_
1. Install [Vercel CLI](https://vercel.com/download)
1. Fork the repository and clone the code to your local machine
1. Run the command "vercel" in the root and follow the steps there
1. Create a `.env` file in the root of the directory
1. In the .env file add a new variable named "PAT" with your [github Personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)
1. Run the command "vercel dev" to start a development server at https://localhost:3000
## Themes Contribution
Github readme stats supports custom theming and you can also contribute new themes!
All you need to do is edit [themes/index.js](./themes/index.js) file and add your theme at the end of the file.
While creating the Pull request to add a new theme **don't forget to add a screenshot of how your theme looks**, you can also test how it looks using custom url parameters like `title_color`, `icon_color`, `bg_color`, `text_color`
> NOTE: If you are contributing your theme just because you are using it personally, then you can [customize the looks](./readme.md#customization) of your card with URL params instead.
## Any contributions you make will be under the MIT Software License
In short, when you submit changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
## Report issues/bugs using Github's [issues](https://github.com/anuraghazra/github-readme-stats/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/anuraghazra/github-readme-stats/issues/new/choose); it's that easy!
### Bug Reports
**Great Bug Reports** tend to have:
- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Share the snapshot, if possible.
- Github Readme Stats' live link
- What actually happens
- What you expected would happen
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
People _love_ thorough bug reports. I'm not even kidding.
### Feature Request
**Great Feature Requests** tend to have:
- A quick idea summary
- What & why you wanted to add the specific feature
- Additional Context like images, links to resources to implement the feature etc etc.
## License
By contributing, you agree that your contributions will be licensed under its [MIT License](./LICENSE).
+10 -3
View File
@@ -2,6 +2,7 @@ require("dotenv").config();
const {
renderError,
parseBoolean,
parseArray,
clampValue,
CONSTANTS,
} = require("../src/utils");
@@ -16,6 +17,7 @@ module.exports = async (req, res) => {
hide_border,
hide_rank,
show_icons,
count_private,
line_height,
title_color,
icon_color,
@@ -29,9 +31,14 @@ module.exports = async (req, res) => {
res.setHeader("Content-Type", "image/svg+xml");
try {
stats = await fetchStats(username);
stats = await fetchStats(username, parseBoolean(count_private));
} catch (err) {
return res.send(renderError(err.message));
return res.send(
renderError(
err.message,
"Make sure the provided username is not an organization"
)
);
}
const cacheSeconds = clampValue(
@@ -44,7 +51,7 @@ module.exports = async (req, res) => {
res.send(
renderStatsCard(stats, {
hide: JSON.parse(hide || "[]"),
hide: parseArray(hide),
show_icons: parseBoolean(show_icons),
hide_title: parseBoolean(hide_title),
hide_border: parseBoolean(hide_border),
+2 -1
View File
@@ -4,6 +4,7 @@ const {
parseBoolean,
clampValue,
CONSTANTS,
logger,
} = require("../src/utils");
const fetchRepo = require("../src/fetchRepo");
const renderRepoCard = require("../src/renderRepoCard");
@@ -28,7 +29,7 @@ module.exports = async (req, res) => {
try {
repoData = await fetchRepo(username, repo);
} catch (err) {
console.log(err);
logger.error(err);
return res.send(renderError(err.message));
}
+3 -2
View File
@@ -3,6 +3,7 @@ const {
renderError,
clampValue,
parseBoolean,
parseArray,
CONSTANTS,
} = require("../src/utils");
const fetchTopLanguages = require("../src/fetchTopLanguages");
@@ -11,7 +12,7 @@ const renderTopLanguages = require("../src/renderTopLanguages");
module.exports = async (req, res) => {
const {
username,
hide_langs_below,
hide,
hide_title,
card_width,
title_color,
@@ -43,7 +44,7 @@ module.exports = async (req, res) => {
theme,
hide_title: parseBoolean(hide_title),
card_width: parseInt(card_width, 10),
hide_langs_below: parseFloat(hide_langs_below, 10),
hide: parseArray(hide),
title_color,
text_color,
bg_color,
+13
View File
@@ -0,0 +1,13 @@
codecov:
require_ci_to_pass: yes
coverage:
precision: 2
round: down
range: "70...100"
status:
project:
default:
threshold: 5
patch: false
+9 -2
View File
@@ -4,7 +4,7 @@
"description": "Dynamically generate stats for your github readmes",
"main": "index.js",
"scripts": {
"test": "jest",
"test": "jest --coverage",
"test:watch": "jest --watch"
},
"author": "Anurag Hazra",
@@ -15,9 +15,16 @@
"axios": "^0.19.2",
"axios-mock-adapter": "^1.18.1",
"css-to-object": "^1.1.0",
"husky": "^4.2.5",
"jest": "^26.1.0"
},
"dependencies": {
"dotenv": "^8.2.0"
"dotenv": "^8.2.0",
"emoji-name-map": "^1.2.8"
},
"husky": {
"hooks": {
"pre-commit": "npm test"
}
}
}
+43 -26
View File
@@ -1,5 +1,5 @@
<p align="center">
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="Github Readme Stats" />
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="Github Readme Stats" />
<h2 align="center">GitHub Readme Stats</h2>
<p align="center">Get dynamically generated GitHub stats on your readmes!</p>
</p>
@@ -8,6 +8,9 @@
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
</a>
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
</a>
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
</a>
@@ -19,9 +22,9 @@
<p align="center">
<a href="#demo">View Demo</a>
·
<a href="https://github.com/anuraghazra/github-readme-stats/issues">Report Bug</a>
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Report Bug</a>
·
<a href="https://github.com/anuraghazra/github-readme-stats/issues">Request Feature</a>
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Request Feature</a>
</p>
<p align="center">
<a href="readme_cn.md">简体中文</a>
@@ -54,12 +57,24 @@ _Note: Ranks are calculated based on user's stats, see [src/calculateRank.js](./
### Hiding individual stats
To hide any specific stats, you can pass a query parameter `?hide=` with an array of items you wanna hide.
To hide any specific stats, you can pass a query parameter `?hide=` with comma seperated values.
> Options: `&hide=["stars","commits","prs","issues","contribs"]`
> Options: `&hide=stars,commits,prs,issues,contribs`
```md
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=["contribs","prs"])
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=contribs,prs])
```
### Adding private contributions count to total commits count
You can add the count of all your private contributions to the total commits count by using the query parameter `?count_private=true`.
_Note: If you are deploying this project yourself, the private contributions will be counted by default otherwise you need to chose to share your private contribution counts._
> Options: `&count_private=true`
```md
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&count_private=true)
```
### Showing icons
@@ -94,21 +109,22 @@ You can customize the appearance of your `Stats Card` or `Repo Card` however you
Customization Options:
| Option | type | description | Stats Card (default) | Repo Card (default) | Top Lang Card (default) |
| ---------------- | --------- | ---------------------------------------------- | -------------------- | ------------------- | ----------------------- |
| title_color | hex color | title color | 2f80ed | 2f80ed | 2f80ed |
| text_color | hex color | body color | 333 | 333 | 333 |
| icon_color | hex color | icon color | 4c71f2 | 586069 | 586069 |
| bg_color | hex color | card bg color | FFFEFE | FFFEFE | FFFEFE |
| line_height | number | control the line-height between text | 30 | N/A | N/A |
| hide_rank | boolean | hides the ranking | false | N/A | N/A |
| hide_title | boolean | hides the stats title | false | N/A | false |
| hide_border | boolean | hides the stats card border | false | N/A | N/A |
| show_owner | boolean | shows owner name in repo card | N/A | false | N/A |
| show_icons | boolean | shows icons | false | N/A | N/A |
| theme | string | sets inbuilt theme | 'default' | 'default_repocard' | 'default |
| cache_seconds | number | manually set custom cache control | 1800 | 1800 | '1800' |
| hide_langs_below | number | hide langs below certain threshold (lang card) | N/A | N/A | undefined |
| Option | type | description | Stats Card (default) | Repo Card (default) | Top Lang Card (default) |
| ------------- | --------- | ------------------------------------------- | -------------------- | ------------------- | ----------------------- |
| title_color | hex color | title color | 2f80ed | 2f80ed | 2f80ed |
| text_color | hex color | body color | 333 | 333 | 333 |
| icon_color | hex color | icon color | 4c71f2 | 586069 | 586069 |
| bg_color | hex color | card bg color | FFFEFE | FFFEFE | FFFEFE |
| line_height | number | control the line-height between text | 30 | N/A | N/A |
| hide | CSV | hides the items specified | undefined | N/A | undefined |
| hide_rank | boolean | hides the ranking | false | N/A | N/A |
| hide_title | boolean | hides the stats title | false | N/A | false |
| hide_border | boolean | hides the stats card border | false | N/A | N/A |
| show_owner | boolean | shows owner name in repo card | N/A | false | N/A |
| show_icons | boolean | shows icons | false | N/A | N/A |
| theme | string | sets inbuilt theme | 'default' | 'default_repocard' | 'default |
| cache_seconds | number | manually set custom cache control | 1800 | 1800 | '1800' |
| count_private | boolean | counts private contributions too if enabled | false | N/A | N/A |
> Note on cache: Repo cards have default cache of 30mins (1800 seconds) if the fork count & star count is less than 1k otherwise it's 2hours (7200). Also note that cache is clamped to minimum of 30min and maximum of 24hours
@@ -152,12 +168,12 @@ Endpoint: `api/top-langs?username=anuraghazra`
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra)](https://github.com/anuraghazra/github-readme-stats)
```
### Hide languages below certain threshold
### Hide individual languages
You can use `?hide_langs_below=NUMBER` parameter to hide languages below a specified threshold percentage.
You can use `?hide=language1,language2` parameter to hide individual languages.
```md
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&hide_langs_below=1)](https://github.com/anuraghazra/github-readme-stats)
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&hide=javascript,html)](https://github.com/anuraghazra/github-readme-stats)
```
### Demo
@@ -174,11 +190,11 @@ You can use `?hide_langs_below=NUMBER` parameter to hide languages below a speci
- Hiding specific stats
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=["contribs","issues"])
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=contribs,issues])
- Showing icons
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=["issues"]&show_icons=true)
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=issues&show_icons=true)
- Themes
@@ -239,6 +255,7 @@ NOTE: Since [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) we
1. Select root and keep everything as is, just add your environment variable named PAT_1 (as shown), which will contain a personal access token (PAT), which you can easily create [here](https://github.com/settings/tokens/new) (leave everything as is, just name it something, it can be anything you want)
![](https://files.catbox.moe/0ez4g7.png)
1. Click deploy, and you're good to go. See your domains to use the API!
</details>
## :sparkling_heart: Support the project
+72 -5
View File
@@ -19,9 +19,9 @@
<p align="center">
<a href="#demo">查看 Demo</a>
·
<a href="https://github.com/anuraghazra/github-readme-stats/issues">报告 bug</a>
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">报告 bug</a>
·
<a href="https://github.com/anuraghazra/github-readme-stats/issues">请求增加功能</a>
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">请求增加功能</a>
</p>
</p>
<p align="center">喜欢这个项目?请考虑<a href="https://www.paypal.me/anuraghazra">捐赠</a>来帮助它完善!
@@ -30,6 +30,7 @@
- [GitHub 统计卡片](#GitHub-统计卡片)
- [GitHub 更多置顶](#GitHub-更多置顶)
- [热门语言卡片](#热门语言卡片)
- [主题](#主题)
- [自定义](#自定义)
- [自己部署](#自己部署)
@@ -64,6 +65,7 @@ _Note: 排名基于用户的统计信息计算得出,详见 [src/calculateRank
```
### 主题
你可以通过现有的主题进行卡片个性化,省去[手动自定义](#自定义)的麻烦。
调用 `?theme=THEME_NAME` 参数,如下:
@@ -72,7 +74,7 @@ _Note: 排名基于用户的统计信息计算得出,详见 [src/calculateRank
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=radical)
```
#### 所有现有主题:
#### 所有现有主题
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
@@ -122,11 +124,11 @@ dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontr
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=radical)
- 自定义添加卡片
- 自定义统计卡片
![Anurag's github stats](https://github-readme-stats.vercel.app/api/?username=anuraghazra&show_icons=true&title_color=fff&icon_color=79ff97&text_color=9f9f9f&bg_color=151515)
- 自定义 Repo 卡片
- 自定义代码库卡片
![Customized Card](https://github-readme-stats.vercel.app/api/pin?username=anuraghazra&repo=github-readme-stats&title_color=fff&icon_color=f9f9f9&text_color=9f9f9f&bg_color=151515)
@@ -156,6 +158,70 @@ Endpoint: `api/pin?username=anuraghazra&repo=github-readme-stats`
[![ReadMe Card](https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&show_owner=true)](https://github.com/anuraghazra/github-readme-stats)
# 热门语言卡片
热门语言卡片显示了Github用户常用的编程语言。
*注意:热门语言并不表示我的技能水平或类似的水平,它是用户在Github上拥有最多代码的一项指标,它是github-readme-stats的新功能*
### 使用细则
将此代码复制粘贴到您的`README.md`文件中,并改变链接。
Endpoint: `api/top-langs?username=anuraghazra`
```md
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra)](https://github.com/anuraghazra/github-readme-stats)
```
### 隐藏特定语言
可以使用`?hide=语言1,语言2`参数来隐藏指定的语言。
```md
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&hide=语言1,语言2)](https://github.com/anuraghazra/github-readme-stats)
```
### Demo
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra)](https://github.com/anuraghazra/github-readme-stats)
---
### 全部Demo
- 默认
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra)
- 隐藏特定数据
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=["contribs","issues"])
- 显示图标
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&hide=["issues"]&show_icons=true)
- 主题
从 [默认主题](#主题) 中进行选择
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=radical)
- 自定义统计卡片
![Anurag's github stats](https://github-readme-stats.vercel.app/api/?username=anuraghazra&show_icons=true&title_color=fff&icon_color=79ff97&text_color=9f9f9f&bg_color=151515)
- 自定义代码库卡片
![Customized Card](https://github-readme-stats.vercel.app/api/pin?username=anuraghazra&repo=github-readme-stats&title_color=fff&icon_color=f9f9f9&text_color=9f9f9f&bg_color=151515)
- 热门语言
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra)](https://github.com/anuraghazra/github-readme-stats)
---
### 提示 (对齐 Repo 卡片)
你通常无法将图片靠边显示。为此,您可以使用以下方法:
@@ -196,6 +262,7 @@ Endpoint: `api/pin?username=anuraghazra&repo=github-readme-stats`
1. 选择 root 并将所有内容保持不变,并且只需添加名为 PAT_1 的环境变量(如图所示),其中将包含一个个人访问令牌(PAT),你可以在[这里](https://github.com/settings/tokens/new)轻松创建(保留默认,并且只需要命名下,名字随便)
![](https://files.catbox.moe/caem5b.png)
1. 点击 deploy,这就完成了,查看你的域名就可使用 API 了!
</details>
## :sparkling_heart: 支持这个项目
+5 -4
View File
@@ -1,5 +1,5 @@
<p align="center">
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="Github Readme Stats" />
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="Github Readme Stats" />
<h2 align="center">GitHub Readme Stats</h2>
<p align="center">¡Obtén tus estadísticas de GitHub generadas dinámicamente en tu README!</p>
</p>
@@ -19,9 +19,9 @@
<p align="center">
<a href="#ejemplo">Ve un ejemplo</a>
·
<a href="https://github.com/anuraghazra/github-readme-stats/issues">Reporta un bug</a>
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Reporta un bug</a>
·
<a href="https://github.com/anuraghazra/github-readme-stats/issues">Solicita una mejora</a>
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Solicita una mejora</a>
</p>
</p>
<p align="center">¿Te gusta este proyecto? ¡Por favor considera <a href="https://www.paypal.me/anuraghazra">donar</a> para ayudar a mejorarlo!
@@ -74,7 +74,7 @@ Utiliza el parámetro `?theme=THEME_NAME`, de esta manera:
![Anurag's github stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=radical)
```
#### Todos los temas incorporados:
#### Todos los temas incorporados
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
@@ -197,6 +197,7 @@ Nota: debido a esto [#58](https://github.com/anuraghazra/github-readme-stats/pul
1. Selecciona "root" y matén todo como está, simplemente añade tu variable de entorno llamada PAT_1 (como se muestra), la cual contendrá un token de acceso personal (PAT), el cual puedes crear fácilmente [aquí](https://github.com/settings/tokens/new) (mantén todo como está, simplemente asígnale un nombre, puede ser cualquiera que desees)
![](https://files.catbox.moe/caem5b.png)
1. Clickea "Deploy" y ya está listo. ¡Ve tus dominios para usar la API!
</details>
## :sparkling_heart: Apoya al proyecto
+1
View File
@@ -10,6 +10,7 @@ const fetcher = (variables, token) => {
nameWithOwner
isPrivate
isArchived
isTemplate
stargazers {
totalCount
}
+13 -4
View File
@@ -1,4 +1,4 @@
const { request } = require("./utils");
const { request, logger } = require("./utils");
const retryer = require("./retryer");
const calculateRank = require("./calculateRank");
require("dotenv").config();
@@ -13,6 +13,7 @@ const fetcher = (variables, token) => {
login
contributionsCollection {
totalCommitContributions
restrictedContributionsCount
}
repositoriesContributedTo(first: 1, contributionTypes: [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY]) {
totalCount
@@ -45,7 +46,7 @@ const fetcher = (variables, token) => {
);
};
async function fetchStats(username) {
async function fetchStats(username, count_private = false) {
if (!username) throw Error("Invalid username");
const stats = {
@@ -61,15 +62,23 @@ async function fetchStats(username) {
let res = await retryer(fetcher, { login: username });
if (res.data.errors) {
console.log(res.data.errors);
logger.error(res.data.errors);
throw Error(res.data.errors[0].message || "Could not fetch user");
}
const user = res.data.data.user;
const contributionCount = user.contributionsCollection;
stats.name = user.name || user.login;
stats.totalIssues = user.issues.totalCount;
stats.totalCommits = user.contributionsCollection.totalCommitContributions;
stats.totalCommits = contributionCount.totalCommitContributions;
if (count_private) {
stats.totalCommits =
contributionCount.totalCommitContributions +
contributionCount.restrictedContributionsCount;
}
stats.totalPRs = user.pullRequests.totalCount;
stats.contributedTo = user.repositoriesContributedTo.totalCount;
+2 -2
View File
@@ -1,4 +1,4 @@
const { request } = require("./utils");
const { request, logger } = require("./utils");
const retryer = require("./retryer");
require("dotenv").config();
@@ -38,7 +38,7 @@ async function fetchTopLanguages(username) {
let res = await retryer(fetcher, { login: username });
if (res.data.errors) {
console.log(res.data.errors);
logger.error(res.data.errors);
throw Error(res.data.errors[0].message || "Could not fetch user");
}
+43 -19
View File
@@ -5,6 +5,7 @@ const {
FlexLayout,
} = require("../src/utils");
const icons = require("./icons");
const toEmoji = require("emoji-name-map");
const renderRepoCard = (repo, options = {}) => {
const {
@@ -14,6 +15,7 @@ const renderRepoCard = (repo, options = {}) => {
primaryLanguage,
stargazers,
isArchived,
isTemplate,
forkCount,
} = repo;
const {
@@ -26,15 +28,21 @@ const renderRepoCard = (repo, options = {}) => {
} = options;
const header = show_owner ? nameWithOwner : name;
const langName = primaryLanguage ? primaryLanguage.name : "Unspecified";
const langColor = primaryLanguage ? primaryLanguage.color : "#333";
const langName = (primaryLanguage && primaryLanguage.name) || "Unspecified";
const langColor = (primaryLanguage && primaryLanguage.color) || "#333";
const height = 120;
const shiftText = langName.length > 15 ? 0 : 30;
let desc = description || "No description provided";
// parse emojis to unicode
desc = desc.replace(/:\w+:/gm, (emoji) => {
return toEmoji.get(emoji) || "";
});
if (desc.length > 55) {
desc = `${description.slice(0, 55)}..`;
desc = `${desc.slice(0, 55)}..`;
}
// returns theme based colors with proper overrides and defaults
@@ -49,22 +57,30 @@ const renderRepoCard = (repo, options = {}) => {
const totalStars = kFormatter(stargazers.totalCount);
const totalForks = kFormatter(forkCount);
const archiveBadge = isArchived
? `
<g data-testid="archive-badge" class="archive-badge" transform="translate(320, 38)">
const getBadgeSVG = (label) => `
<g data-testid="badge" class="badge" transform="translate(320, 38)">
<rect stroke="${textColor}" stroke-width="1" width="70" height="20" x="-12" y="-14" ry="10" rx="10"></rect>
<text fill="${textColor}">Archived</text>
<text
x="23" y="-5"
alignment-baseline="central"
dominant-baseline="central"
text-anchor="middle"
fill="${textColor}"
>
${label}
</text>
</g>
`;
const svgLanguage = primaryLanguage
? `
<g data-testid="primary-lang" transform="translate(30, 100)">
<circle data-testid="lang-color" cx="0" cy="-5" r="6" fill="${langColor}" />
<text data-testid="lang-name" class="gray" x="15">${langName}</text>
</g>
`
: "";
const svgLanguage = `
<g transform="translate(30, 100)">
<circle data-testid="lang-color" cx="0" cy="-5" r="6" fill="${langColor}" />
<text data-testid="lang" class="gray" x="15">${langName}</text>
</g>
`;
const svgStars =
stargazers.totalCount > 0 &&
`
@@ -90,22 +106,30 @@ const renderRepoCard = (repo, options = {}) => {
.description { font: 400 13px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
.gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
.icon { fill: ${iconColor} }
.archive-badge { font: 600 12px 'Segoe UI', Ubuntu, Sans-Serif; }
.archive-badge rect { opacity: 0.2 }
.badge { font: 600 11px 'Segoe UI', Ubuntu, Sans-Serif; }
.badge rect { opacity: 0.2 }
</style>
<rect data-testid="card-bg" x="0.5" y="0.5" width="399" height="99%" rx="4.5" fill="${bgColor}" stroke="#E4E2E2"/>
<svg class="icon" x="25" y="25" viewBox="0 0 16 16" version="1.1" width="16" height="16">
${icons.contribs}
</svg>
${archiveBadge}
<text x="50" y="38" class="header">${header}</text>
${
isTemplate
? getBadgeSVG("Template")
: isArchived
? getBadgeSVG("Archived")
: ""
}
<text class="description" x="25" y="70">${encodeHTML(desc)}</text>
${svgLanguage}
<g transform="translate(${155 - shiftText}, 100)">
<g transform="translate(${primaryLanguage ? 155 - shiftText : 25}, 100)">
${FlexLayout({ items: [svgStars, svgForks], gap: 65 }).join("")}
</g>
+9 -5
View File
@@ -1,4 +1,9 @@
const { kFormatter, getCardColors, FlexLayout } = require("../src/utils");
const {
kFormatter,
getCardColors,
FlexLayout,
encodeHTML,
} = require("../src/utils");
const getStyles = require("./getStyles");
const icons = require("./icons");
@@ -128,11 +133,9 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
const apostrophe = ["x", "s"].includes(name.slice(-1)) ? "" : "s";
const title = hide_title
? ""
: `<text x="25" y="35" class="header">${name}'${apostrophe} GitHub Stats</text>`;
: `<text x="25" y="35" class="header">${encodeHTML(name)}'${apostrophe} GitHub Stats</text>`;
const border = hide_border
? ""
: `
const border = `
<rect
data-testid="card-bg"
x="0.5"
@@ -142,6 +145,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
rx="4.5"
fill="${bgColor}"
stroke="#E4E2E2"
stroke-opacity="${hide_border ? 0 : 1}"
/>
`;
+19 -7
View File
@@ -23,6 +23,8 @@ const createProgressNode = ({ width, color, name, progress }) => {
`;
};
const lowercaseTrim = (name) => name.toLowerCase().trim();
const renderTopLanguages = (topLangs, options = {}) => {
const {
hide_title,
@@ -30,22 +32,32 @@ const renderTopLanguages = (topLangs, options = {}) => {
title_color,
text_color,
bg_color,
hide_langs_below,
hide,
theme,
} = options;
let langs = Object.values(topLangs);
let langsToHide = {};
// populate langsToHide map for quick lookup
// while filtering out
if (hide) {
hide.forEach((langName) => {
langsToHide[lowercaseTrim(langName)] = true;
});
}
// filter out langauges to be hidden
langs = langs
.sort((a, b) => b.size - a.size)
.filter((lang) => {
return !langsToHide[lowercaseTrim(lang.name)];
});
const totalSize = langs.reduce((acc, curr) => {
return acc + curr.size;
}, 0);
// hide langs
langs = langs.filter((lang) => {
if (!hide_langs_below) return true;
return (lang.size / totalSize) * 100 > hide_langs_below;
});
// returns theme based colors with proper overrides and defaults
const { titleColor, textColor, bgColor } = getCardColors({
title_color,
+5 -3
View File
@@ -1,9 +1,11 @@
const { logger } = require("./utils");
const retryer = async (fetcher, variables, retries = 0) => {
if (retries > 7) {
throw new Error("Maximum retries exceeded");
}
try {
console.log(`Trying PAT_${retries + 1}`);
logger.log(`Trying PAT_${retries + 1}`);
// try to fetch with the first token since RETRIES is 0 index i'm adding +1
let response = await fetcher(
@@ -18,7 +20,7 @@ const retryer = async (fetcher, variables, retries = 0) => {
// if rate limit is hit increase the RETRIES and recursively call the retryer
// with username, and current RETRIES
if (isRateExceeded) {
console.log(`PAT_${retries + 1} Failed`);
logger.log(`PAT_${retries + 1} Failed`);
retries++;
// directly return from the function
return retryer(fetcher, variables, retries);
@@ -32,7 +34,7 @@ const retryer = async (fetcher, variables, retries = 0) => {
const isBadCredential = err.response.data && err.response.data.message === "Bad credentials";
if (isBadCredential) {
console.log(`PAT_${retries + 1} Failed`);
logger.log(`PAT_${retries + 1} Failed`);
retries++;
// directly return from the function
return retryer(fetcher, variables, retries);
+24 -6
View File
@@ -1,25 +1,31 @@
const axios = require("axios");
const themes = require("../themes");
const renderError = (message) => {
const renderError = (message, secondaryMessage = "") => {
return `
<svg width="495" height="100" viewBox="0 0 495 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg width="495" height="120" viewBox="0 0 495 120" fill="none" xmlns="http://www.w3.org/2000/svg">
<style>
.text { font: 600 16px 'Segoe UI', Ubuntu, Sans-Serif; fill: #2F80ED }
.small { font: 600 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: #252525 }
.gray { fill: #858585 }
</style>
<rect x="0.5" y="0.5" width="494" height="99%" rx="4.5" fill="#FFFEFE" stroke="#E4E2E2"/>
<text x="25" y="45" class="text">Something went wrong! file an issue at https://git.io/JJmN9</text>
<text id="message" x="25" y="65" class="text small">${message}</text>
<text data-testid="message" x="25" y="55" class="text small">
<tspan x="25" dy="18">${message}</tspan>
<tspan x="25" dy="18" class="gray">${secondaryMessage}</tspan>
</text>
</svg>
`;
};
// https://stackoverflow.com/a/48073476/10629172
function encodeHTML(str) {
return str.replace(/[\u00A0-\u9999<>&](?!#)/gim, function (i) {
return "&#" + i.charCodeAt(0) + ";";
});
return str
.replace(/[\u00A0-\u9999<>&](?!#)/gim, (i) => {
return "&#" + i.charCodeAt(0) + ";";
})
.replace(/\u0008/gim, "");
}
function kFormatter(num) {
@@ -44,6 +50,11 @@ function parseBoolean(value) {
}
}
function parseArray(str) {
if (!str) return [];
return str.split(",");
}
function clampValue(number, min, max) {
return Math.max(min, Math.min(number, max));
}
@@ -116,6 +127,11 @@ function getCardColors({
return { titleColor, iconColor, textColor, bgColor };
}
const fn = () => {};
// return console instance based on the environment
const logger =
process.env.NODE_ENV !== "test" ? console : { log: fn, error: fn };
const CONSTANTS = {
THIRTY_MINUTES: 1800,
TWO_HOURS: 7200,
@@ -128,10 +144,12 @@ module.exports = {
encodeHTML,
isValidHexColor,
request,
parseArray,
parseBoolean,
fallbackColor,
FlexLayout,
getCardColors,
clampValue,
logger,
CONSTANTS,
};
+43 -3
View File
@@ -30,7 +30,10 @@ const data = {
user: {
name: stats.name,
repositoriesContributedTo: { totalCount: stats.contributedTo },
contributionsCollection: { totalCommitContributions: stats.totalCommits },
contributionsCollection: {
totalCommitContributions: stats.totalCommits,
restrictedContributionsCount: 100,
},
pullRequests: { totalCount: stats.totalPRs },
issues: { totalCount: stats.totalIssues },
followers: { totalCount: 0 },
@@ -91,14 +94,19 @@ describe("Test /api/", () => {
await api(req, res);
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(renderError(error.errors[0].message));
expect(res.send).toBeCalledWith(
renderError(
error.errors[0].message,
"Make sure the provided username is not an organization"
)
);
});
it("should get the query options", async () => {
const { req, res } = faker(
{
username: "anuraghazra",
hide: `["issues","prs","contribs"]`,
hide: "issues,prs,contribs",
show_icons: true,
hide_border: true,
line_height: 100,
@@ -181,4 +189,36 @@ describe("Test /api/", () => {
]);
}
});
it("should add private contributions", async () => {
const { req, res } = faker(
{
username: "anuraghazra",
count_private: true,
},
data
);
await api(req, res);
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
expect(res.send).toBeCalledWith(
renderStatsCard(
{
...stats,
totalCommits: stats.totalCommits + 100,
rank: calculateRank({
totalCommits: stats.totalCommits + 100,
totalRepos: 1,
followers: 0,
contributions: stats.contributedTo,
stargazers: stats.totalStars,
prs: stats.totalPRs,
issues: stats.totalIssues,
}),
},
{}
)
);
});
});
+27 -2
View File
@@ -9,7 +9,7 @@ const data = {
user: {
name: "Anurag Hazra",
repositoriesContributedTo: { totalCount: 61 },
contributionsCollection: { totalCommitContributions: 100 },
contributionsCollection: { totalCommitContributions: 100, restrictedContributionsCount: 50 },
pullRequests: { totalCount: 300 },
issues: { totalCount: 200 },
followers: { totalCount: 100 },
@@ -77,4 +77,29 @@ describe("Test fetchStats", () => {
"Could not resolve to a User with the login of 'noname'."
);
});
});
it("should fetch and add private contributions", async () => {
mock.onPost("https://api.github.com/graphql").reply(200, data);
let stats = await fetchStats("anuraghazra", true);
const rank = calculateRank({
totalCommits: 150,
totalRepos: 5,
followers: 100,
contributions: 61,
stargazers: 400,
prs: 300,
issues: 200,
});
expect(stats).toStrictEqual({
contributedTo: 61,
name: "Anurag Hazra",
totalCommits: 150,
totalIssues: 200,
totalPRs: 300,
totalStars: 400,
rank,
});
});
});
+1
View File
@@ -17,6 +17,7 @@ const data_repo = {
name: "TypeScript",
},
forkCount: 100,
isTemplate: false
},
};
+62 -14
View File
@@ -33,7 +33,7 @@ describe("Test renderRepoCard", () => {
);
expect(queryByTestId(document.body, "stargazers")).toHaveTextContent("38k");
expect(queryByTestId(document.body, "forkcount")).toHaveTextContent("100");
expect(queryByTestId(document.body, "lang")).toHaveTextContent(
expect(queryByTestId(document.body, "lang-name")).toHaveTextContent(
"TypeScript"
);
expect(queryByTestId(document.body, "lang-color")).toHaveAttribute(
@@ -73,6 +73,18 @@ describe("Test renderRepoCard", () => {
);
});
it("should render emojis", () => {
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
description: "This is a text with a :poop: poo emoji",
});
// poop emoji may not show in all editors but it's there between "a" and "poo"
expect(document.getElementsByClassName("description")[0]).toHaveTextContent(
"This is a text with a 💩 poo emoji"
);
});
it("should shift the text position depending on language length", () => {
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
@@ -82,6 +94,7 @@ describe("Test renderRepoCard", () => {
},
});
expect(queryByTestId(document.body, "primary-lang")).toBeInTheDocument();
expect(document.getElementsByTagName("g")[1]).toHaveAttribute(
"transform",
"translate(155, 100)"
@@ -102,6 +115,30 @@ describe("Test renderRepoCard", () => {
);
});
it("should hide language if primaryLanguage is null & fallback to correct values", () => {
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
primaryLanguage: null,
});
expect(queryByTestId(document.body, "primary-lang")).toBeNull();
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
primaryLanguage: { color: null, name: null },
});
expect(queryByTestId(document.body, "primary-lang")).toBeInTheDocument();
expect(queryByTestId(document.body, "lang-color")).toHaveAttribute(
"fill",
"#333"
);
expect(queryByTestId(document.body, "lang-name")).toHaveTextContent(
"Unspecified"
);
});
it("should render default colors properly", () => {
document.body.innerHTML = renderRepoCard(data_repo.repository);
@@ -217,17 +254,6 @@ describe("Test renderRepoCard", () => {
);
});
it("should render archive badge if repo is archived", () => {
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
isArchived: true,
});
expect(queryByTestId(document.body, "archive-badge")).toHaveTextContent(
"Archived"
);
});
it("should not render star count or fork count if either of the are zero", () => {
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
@@ -235,7 +261,7 @@ describe("Test renderRepoCard", () => {
});
expect(queryByTestId(document.body, "stargazers")).toBeNull();
expect(queryByTestId(document.body, "forkcount")).toBeDefined();
expect(queryByTestId(document.body, "forkcount")).toBeInTheDocument();
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
@@ -243,7 +269,7 @@ describe("Test renderRepoCard", () => {
forkCount: 0,
});
expect(queryByTestId(document.body, "stargazers")).toBeDefined();
expect(queryByTestId(document.body, "stargazers")).toBeInTheDocument();
expect(queryByTestId(document.body, "forkcount")).toBeNull();
document.body.innerHTML = renderRepoCard({
@@ -255,4 +281,26 @@ describe("Test renderRepoCard", () => {
expect(queryByTestId(document.body, "stargazers")).toBeNull();
expect(queryByTestId(document.body, "forkcount")).toBeNull();
});
it("should render badges", () => {
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
isArchived: true,
});
expect(queryByTestId(document.body, "badge")).toHaveTextContent("Archived");
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
isTemplate: true,
});
expect(queryByTestId(document.body, "badge")).toHaveTextContent("Template");
});
it("should not render template", () => {
document.body.innerHTML = renderRepoCard({
...data_repo.repository,
});
expect(queryByTestId(document.body, "badge")).toBeNull();
});
});
+10 -2
View File
@@ -55,7 +55,7 @@ describe("Test renderStatsCard", () => {
it("should hide individual stats", () => {
document.body.innerHTML = renderStatsCard(stats, {
hide: "['issues', 'prs', 'contribs']",
hide: ["issues", "prs", "contribs"],
});
expect(
@@ -71,8 +71,16 @@ describe("Test renderStatsCard", () => {
it("should hide_border", () => {
document.body.innerHTML = renderStatsCard(stats, { hide_border: true });
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"stroke-opacity",
"0"
);
expect(queryByTestId(document.body, "card-bg")).not.toBeInTheDocument();
document.body.innerHTML = renderStatsCard(stats, { hide_border: false });
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
"stroke-opacity",
"1"
);
});
it("should hide_rank", () => {
+14 -6
View File
@@ -58,18 +58,26 @@ describe("Test renderTopLanguages", () => {
);
});
it("should hide_langs_below", () => {
it("should hide languages when hide is passed", () => {
document.body.innerHTML = renderTopLanguages(langs, {
hide_langs_below: 34,
hide: ["HTML"],
});
expect(queryAllByTestId(document.body, "lang-name")[0]).toBeInTheDocument(
"HTML"
);
expect(queryAllByTestId(document.body, "lang-name")[1]).toBeInTheDocument(
"javascript"
);
expect(queryAllByTestId(document.body, "lang-name")[1]).toBeInTheDocument(
"css"
);
expect(queryAllByTestId(document.body, "lang-name")[2]).not.toBeDefined();
// multiple languages passed
document.body.innerHTML = renderTopLanguages(langs, {
hide: ["HTML","css"],
});
expect(queryAllByTestId(document.body, "lang-name")[0]).toBeInTheDocument(
"javascript"
);
expect(queryAllByTestId(document.body, "lang-name")[1]).not.toBeDefined();
});
it("should resize the height correctly depending on langs", () => {
+2 -1
View File
@@ -1,8 +1,9 @@
require("@testing-library/jest-dom");
const retryer = require("../src/retryer");
const { logger } = require("../src/utils");
const fetcher = jest.fn((variables, token) => {
console.log(variables, token);
logger.log(variables, token);
return new Promise((res, rej) => res({ data: "ok" }));
});
+16 -3
View File
@@ -1,3 +1,4 @@
require("@testing-library/jest-dom");
const {
kFormatter,
encodeHTML,
@@ -6,6 +7,8 @@ const {
getCardColors,
} = require("../src/utils");
const { queryByTestId } = require("@testing-library/dom");
describe("Test utils.js", () => {
it("should test kFormatter", () => {
expect(kFormatter(1)).toBe(1);
@@ -25,9 +28,19 @@ describe("Test utils.js", () => {
it("should test renderError", () => {
document.body.innerHTML = renderError("Something went wrong");
expect(document.getElementById("message").textContent).toBe(
"Something went wrong"
expect(
queryByTestId(document.body, "message").children[0]
).toHaveTextContent(/Something went wrong/gim);
expect(queryByTestId(document.body, "message").children[1]).toBeEmpty(2);
// Secondary message
document.body.innerHTML = renderError(
"Something went wrong",
"Secondary Message"
);
expect(
queryByTestId(document.body, "message").children[1]
).toHaveTextContent(/Secondary Message/gim);
});
it("should test FlexLayout", () => {
@@ -82,7 +95,7 @@ describe("Test utils.js", () => {
bgColor: "#fff",
});
});
it("getCardColors: should fallback to specified theme colors if is not defined", () => {
let colors = getCardColors({
theme: "dark",
+8 -2
View File
@@ -17,7 +17,8 @@ Use `?theme=THEME_NAME` parameter like so :-
| `default` ![default][default] | `radical` ![radical][radical] | `merko` ![merko][merko] |
| `gruvbox` ![gruvbox][gruvbox] | `tokyonight` ![tokyonight][tokyonight] | `onedark` ![onedark][onedark] |
| `cobalt` ![cobalt][cobalt] | `synthwave` ![synthwave][synthwave] | `highcontrast` ![highcontrast][highcontrast] |
| `dracula` ![dracula][dracula] | `dark` ![dark][dark] | [Add your theme][add-theme] |
| `dracula` ![dracula][dracula] | `dark` ![dark][dark] | `prussian` ![prussian][prussian] |
| [Add your theme][add-theme] |||
## Repo Card
@@ -28,7 +29,9 @@ Use `?theme=THEME_NAME` parameter like so :-
| `default_repocard` ![default_repocard][default_repocard] | `radical` ![radical][radical_repocard] | `merko` ![merko][merko_repocard] |
| `gruvbox` ![gruvbox][gruvbox_repocard] | `tokyonight` ![tokyonight][tokyonight_repocard] | `onedark` ![onedark][onedark_repocard] |
| `cobalt` ![cobalt][cobalt_repocard] | `synthwave` ![synthwave][synthwave_repocard] | `highcontrast` ![highcontrast][highcontrast_repocard] |
| `dracula` ![dracula][dracula_repocard] | `dark` ![dark_repocard][dark_repocard] | [Add your theme][add-theme] |
| `dracula` ![dracula][dracula_repocard] | `dark` ![dark_repocard][dark_repocard] | `prussian` ![prussian_repocard][prussian_repocard] |
| [Add your theme][add-theme] |||
<!-- Repo Card Theme previews -->
@@ -44,6 +47,7 @@ Use `?theme=THEME_NAME` parameter like so :-
[synthwave_repocard]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=synthwave
[onedark_repocard]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=onedark
[highcontrast_repocard]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=highcontrast
[prussian_repocard]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=prussian
<!-- Stats Theme previews -->
@@ -58,5 +62,7 @@ Use `?theme=THEME_NAME` parameter like so :-
[synthwave]: https://github-readme-stats.vercel.app/api?username=anuraghazra&theme=synthwave&hide=["contribs","prs"]&cache_seconds=86400
[highcontrast]: https://github-readme-stats.vercel.app/api?username=anuraghazra&theme=highcontrast&hide=["contribs","prs"]&cache_seconds=86400
[dracula]: https://github-readme-stats.vercel.app/api?username=anuraghazra&theme=dracula&hide=["contribs","prs"]&cache_seconds=86400
[prussian]: https://github-readme-stats.vercel.app/api?username=anuraghazra&theme=prussian&hide=["contribs","prs"]&cache_seconds=86400
[add-theme]: https://github.com/anuraghazra/github-readme-stats/edit/master/themes/index.js
+24
View File
@@ -77,6 +77,30 @@ const themes = {
text_color: "6e93b5",
bg_color: "172f45",
},
monokai: {
title_color: "eb1f6a",
icon_color: "e28905",
text_color: "f1f1eb",
bg_color: "272822",
},
vue: {
title_color: "41b883",
icon_color: "41b883",
text_color: "273849",
bg_color: "FFFEFE",
},
"shades-of-purple": {
title_color: "FAD000",
icon_color: "FB94FF",
text_color: "A599E9",
bg_color: "2D2B55",
},
nightowl: {
title_color: "C792EA",
icon_color: "FFEB95",
text_color: "7FDBCA",
bg_color: "011627",
},
};
module.exports = themes;
+8
View File
@@ -0,0 +1,8 @@
{
"redirects": [
{
"source": "/",
"destination": "https://github.com/anuraghazra/github-readme-stats"
}
]
}