Skip to content

Commit

Permalink
Merge branch 'master' into update_themes_preview_run_condition
Browse files Browse the repository at this point in the history
  • Loading branch information
rickstaa committed Sep 17, 2022
2 parents 415ac11 + f9b9015 commit 775e5a6
Show file tree
Hide file tree
Showing 28 changed files with 347 additions and 135 deletions.
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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.
Expand All @@ -18,9 +19,8 @@ If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.

<!--
PLEASE FIRST READ THE FAQ (#1770) AND COMMON ERROR CODES (#1772)!!!
<!-- FAQ
Below are some questions that are found in the FAQ. The full FAQ can be found in #1770.
Q: My card displays an error
Ans: First, check the common error codes (i.e. https://github.com/anuraghazra/github-readme-stats/issues/1772) and existing issues before creating a new one.
Expand All @@ -40,5 +40,4 @@ Ans: Please read all the issues/comments before opening any issues regarding lan
Q: How to count private stats?
Ans: We can only count private commits & we cannot access any other private info of any users, so it's impossible. The only way is to deploy on your own instance & use your own PAT (Personal Access Token)
-->
30 changes: 30 additions & 0 deletions .github/workflows/empty-issues-closer.yaml
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions .github/workflows/preview-theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ on:
branches:
- master
- theme-preview-script
- "themes/index.js"
paths:
- 'themes/**'
- 'themes/index.js'
- 'scripts/preview-theme.js'

jobs:
build:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ jobs:
npm install
npm run test
- name: Run Prettier
run: |
npm run format:check
- name: Code Coverage
uses: codecov/codecov-action@v1
22 changes: 22 additions & 0 deletions .github/workflows/top-issues-dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 }}
with:
label: false
dashboard: true
dashboard_show_total_reactions: true
top_issues: true
top_bugs: true
top_features: true
top_pull_requests: true
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = async (req, res) => {
hide,
hide_title,
hide_border,
card_width,
hide_rank,
show_icons,
count_private,
Expand All @@ -25,9 +26,11 @@ module.exports = async (req, res) => {
title_color,
icon_color,
text_color,
text_bold,
bg_color,
theme,
cache_seconds,
exclude_repo,
custom_title,
locale,
disable_animations,
Expand All @@ -49,6 +52,7 @@ module.exports = async (req, res) => {
username,
parseBoolean(count_private),
parseBoolean(include_all_commits),
parseArray(exclude_repo),
);

const cacheSeconds = clampValue(
Expand All @@ -65,12 +69,14 @@ 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,
title_color,
icon_color,
text_color,
text_bold: parseBoolean(text_bold),
bg_color,
theme,
custom_title,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"format": "./node_modules/.bin/prettier --write .",
"format:check": "./node_modules/.bin/prettier --check ."
},
"author": "Anurag Hazra",
"license": "MIT",
Expand Down
16 changes: 10 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
<img src="https://d2wvdrxmr8p0wf.cloudfront.net/static/giveindia.svg" alt="Give india logo" width="200" />
</a>

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:
</p>

Expand Down Expand Up @@ -169,9 +169,9 @@ 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.
> Note: The minimum of cache_seconds is currently 4 hours as a temporary fix for PATs exhaustion.
##### Gradient in bg_color

Expand All @@ -187,12 +187,15 @@ 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)_
- `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
- `text_bold` - Use bold text _(boolean)_
- `disable_animations` - Disables all animations in the card _(boolean)_

#### Repo Card Exclusive Options:
Expand Down Expand Up @@ -451,3 +454,4 @@ Thanks! :heart:
Contributions are welcome! <3

Made with :heart: and JavaScript.

40 changes: 22 additions & 18 deletions scripts/generate-langs-json.js
Original file line number Diff line number Diff line change
@@ -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, ' '));

});
30 changes: 7 additions & 23 deletions src/calculateRank.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_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 };
}
Expand Down
12 changes: 6 additions & 6 deletions src/cards/repo-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const iconWithLabel = (icon, label, testid) => {
};

/**
* @param {import('../fetchers/types').RepositoryData} repo
* @param {Partial<import("./types").RepoCardOptions>} options
* @param {import('../fetchers/types').RepositoryData} repo
* @param {Partial<import("./types").RepoCardOptions>} options
* @returns {string}
*/
const renderRepoCard = (repo, options = {}) => {
Expand Down Expand Up @@ -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)
: ""
}
Expand Down

0 comments on commit 775e5a6

Please sign in to comment.