forked from mirrored/github-readme-stats
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e09a753df4 | ||
|
|
1d3fc7b5ab | ||
|
|
b027857a1f |
+13
-12
@@ -48,8 +48,8 @@
|
||||
// "dot-notation": "warn",
|
||||
// "eqeqeq": [ "error", "smart" ],
|
||||
// "guard-for-in": "warn",
|
||||
"no-alert": "error",
|
||||
"no-caller": "error",
|
||||
// "no-alert": "error",
|
||||
// "no-caller": "error",
|
||||
// "no-case-declarations": "warn",
|
||||
// "no-div-regex": "warn",
|
||||
// "no-else-return": "warn",
|
||||
@@ -99,7 +99,7 @@
|
||||
"location": "start"
|
||||
}],
|
||||
"no-with": "warn",
|
||||
"radix": "warn",
|
||||
// "radix": "warn",
|
||||
// "vars-on-top": "error",
|
||||
|
||||
// Enforces the style of wrapped functions
|
||||
@@ -113,7 +113,7 @@
|
||||
|
||||
// "init-declarations": [ "error", "always" ],
|
||||
// "no-catch-shadow": "warn",
|
||||
"no-delete-var": "error",
|
||||
// "no-delete-var": "error",
|
||||
// "no-label-var": "error",
|
||||
// "no-shadow-restricted-names": "error",
|
||||
// "no-shadow": "warn",
|
||||
@@ -150,12 +150,12 @@
|
||||
// "arrow-body-style": [ "error", "always" ],
|
||||
// "arrow-parens": [ "error", "always" ],
|
||||
// "arrow-spacing": [ "error", { "before": true, "after": true }],
|
||||
"constructor-super": "error",
|
||||
// "constructor-super": "error",
|
||||
// "generator-star-spacing": [ "error", "before" ],
|
||||
// "no-arrow-condition": "error",
|
||||
"no-class-assign": "error",
|
||||
"no-const-assign": "error",
|
||||
"no-dupe-class-members": "error",
|
||||
// "no-class-assign": "error",
|
||||
// "no-const-assign": "error",
|
||||
// "no-dupe-class-members": "error",
|
||||
"no-this-before-super": "error",
|
||||
// "no-var": "warn",
|
||||
"object-shorthand": [ "warn" ],
|
||||
@@ -193,9 +193,9 @@
|
||||
// "no-continue": "off",
|
||||
// "no-inline-comments": "off",
|
||||
// "no-lonely-if": "warn",
|
||||
"no-mixed-spaces-and-tabs": "warn",
|
||||
// "no-mixed-spaces-and-tabs": "warn",
|
||||
"no-multiple-empty-lines": "warn",
|
||||
"no-negated-condition": "warn",
|
||||
// "no-negated-condition": "off",
|
||||
// "no-nested-ternary": "warn",
|
||||
// "no-new-object": "warn",
|
||||
// "no-plusplus": "off",
|
||||
@@ -217,13 +217,14 @@
|
||||
"MethodDefinition": true,
|
||||
"ClassDeclaration": false
|
||||
}
|
||||
}],
|
||||
}]
|
||||
// "semi-spacing": [ "warn", { "before": false, "after": true }],
|
||||
// "semi": [ "error", "always" ],
|
||||
// "sort-vars": "off",
|
||||
"keyword-spacing": ["error", { "before": true, "after": true }]
|
||||
// "space-after-keywords": [ "warn", "always" ],
|
||||
// "space-before-blocks": [ "warn", "always" ],
|
||||
// "space-before-function-paren": [ "warn", "never" ],
|
||||
// "space-before-keywords": [ "warn", "always" ],
|
||||
// "space-in-parens": [ "warn", "never" ],
|
||||
// "space-infix-ops": [ "warn", { "int32Hint": true } ],
|
||||
// "space-return-throw-case": "error",
|
||||
|
||||
@@ -6,11 +6,6 @@ updates:
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 10
|
||||
commit-message:
|
||||
prefix: "build(deps)"
|
||||
prefix-development: "build(deps-dev)"
|
||||
reviewers:
|
||||
- "qwerty541"
|
||||
|
||||
# Maintain dependencies for GitHub Actions
|
||||
- package-ecosystem: github-actions
|
||||
@@ -18,8 +13,3 @@ updates:
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 10
|
||||
commit-message:
|
||||
prefix: "build(deps)"
|
||||
prefix-development: "build(deps-dev)"
|
||||
reviewers:
|
||||
- "qwerty541"
|
||||
|
||||
@@ -38,7 +38,6 @@ wakatime-card:
|
||||
- src/fetchers/wakatime-fetcher.js
|
||||
- tests/fetchWakatime.test.js
|
||||
- tests/renderWakatimeCard.test.js
|
||||
- tests/wakatime.test.js
|
||||
gist-card:
|
||||
- api/gist.js
|
||||
- src/cards/gist-card.js
|
||||
|
||||
@@ -2,11 +2,9 @@ name: "Static code analysis workflow (CodeQL)"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
@@ -29,7 +27,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
|
||||
@@ -10,7 +10,7 @@ jobs:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
- name: Deployment Prep
|
||||
run: python ./.github/workflows/deploy-prep.py
|
||||
- uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d # v5.0.0
|
||||
|
||||
@@ -17,10 +17,10 @@ jobs:
|
||||
node-version: [18.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
|
||||
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
@@ -27,10 +27,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# NOTE: Retrieve issue templates.
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
|
||||
- name: Run empty issues closer action
|
||||
uses: rickstaa/empty-issues-closer-action@e0fb1033c83cf13e0c98c2c9d0419d3040a6a1d0 # v1.1.50
|
||||
uses: rickstaa/empty-issues-closer-action@e9e79c66b85961ebc9dc11493b65b6e4bb355ed0 # v1.1.28
|
||||
env:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
||||
@@ -29,10 +29,10 @@ jobs:
|
||||
node-version: [18.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
|
||||
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
@@ -21,12 +21,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
|
||||
uses: ossf/scorecard-action@483ef80eb98fb506c348f7d62e28055e49fe2398 # v2.3.0
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
|
||||
@@ -30,15 +30,15 @@ jobs:
|
||||
node-version: [18.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
|
||||
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
- uses: bahmutov/npm-install@2509f13e8485d88340a789a3f7ca11aaac47c9fc # v1.8.36
|
||||
- uses: bahmutov/npm-install@c46e3830503dcb831cf4aee3f26b4e6bce8cc9d2 # v1.8.35
|
||||
with:
|
||||
useLockFile: false
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
|
||||
@@ -36,15 +36,15 @@ jobs:
|
||||
node-version: [18.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
|
||||
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
- uses: bahmutov/npm-install@2509f13e8485d88340a789a3f7ca11aaac47c9fc # v1.8.36
|
||||
- uses: bahmutov/npm-install@c46e3830503dcb831cf4aee3f26b4e6bce8cc9d2 # v1.8.35
|
||||
with:
|
||||
useLockFile: false
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ jobs:
|
||||
node-version: [18.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
|
||||
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
@@ -35,10 +35,6 @@ jobs:
|
||||
run: |
|
||||
npm run lint
|
||||
|
||||
- name: Run bench tests
|
||||
run: |
|
||||
npm run bench
|
||||
|
||||
- name: Run Prettier
|
||||
run: |
|
||||
npm run format:check
|
||||
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Run top issues action
|
||||
uses: rickstaa/top-issues-action@04028f4fc0f1c217e571be72102b6ea4827b8468 # v1.3.75
|
||||
uses: rickstaa/top-issues-action@a2f94d3653b3c2490e0d997c8ec4a5e7beba4c7d # v1.3.54
|
||||
env:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
@@ -47,3 +47,7 @@ jobs:
|
||||
top_bugs: true
|
||||
top_features: true
|
||||
top_pull_requests: true
|
||||
custom_pull_requests_label: themes
|
||||
top_custom_pull_requests_label: ":star: top themes"
|
||||
top_custom_pull_requests_label_description: Top themes
|
||||
top_custom_pull_requests_label_colour: "#A23599"
|
||||
|
||||
@@ -15,7 +15,7 @@ on:
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: write
|
||||
contents: read
|
||||
deployments: read
|
||||
issues: read
|
||||
discussions: read
|
||||
@@ -36,10 +36,10 @@ jobs:
|
||||
node-version: [18.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
|
||||
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
@@ -4,7 +4,6 @@ node_modules
|
||||
*.lock
|
||||
.idea/
|
||||
coverage
|
||||
benchmarks
|
||||
vercel_token
|
||||
|
||||
# IDE
|
||||
|
||||
+13
-8
@@ -34,28 +34,33 @@ _(make sure you already have a [Vercel](https://vercel.com/) account)_
|
||||
2. Fork the repository and clone the code to your local machine.
|
||||
3. Run `npm install` in the repository root.
|
||||
4. Run the command `vercel` in the root and follow the steps there.
|
||||
5. Run the command `vercel dev` to start a development server at <http://localhost:3000>.
|
||||
6. The cards will then be available from this local endpoint (i.e. `http://localhost:3000/api?username=anuraghazra`).
|
||||
5. Open `vercel.json` and set the maxDuration to 10.
|
||||
6. Create a `.env` file in the root of the directory.
|
||||
7. In the .env file add a new variable named `PAT_1` with your [GitHub Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token).
|
||||
8. Run the command `vercel dev` to start a development server at <https://localhost:3000>.
|
||||
9. The cards will then be available from this local endpoint (i.e. `https://localhost:3000/api?username=anuraghazra`).
|
||||
|
||||
> [!NOTE]\
|
||||
> You can debug the package code in [Vscode](https://code.visualstudio.com/) by using the [Node.js: Attach to process](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_setting-up-an-attach-configuration) debug option. You can also debug any tests using the [VSCode Jest extension](https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest). For more information, see https://github.com/jest-community/vscode-jest/issues/912.
|
||||
|
||||
## Themes Contribution
|
||||
|
||||
We're currently paused addition of new themes to decrease maintenance efforts. All pull requests related to new themes will be closed.
|
||||
GitHub Readme Stats supports custom theming, and you can also contribute new themes!
|
||||
|
||||
> [!NOTE]\
|
||||
> If you are considering contributing your theme just because you are using it personally, then instead of adding it to our theme collection, you can use card [customization options](./readme.md#customization).
|
||||
> 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.
|
||||
|
||||
## Translations Contribution
|
||||
> [!NOTE]\
|
||||
> Keep in mind that we already have a vast collection of different themes. To keep their number manageable, we began to add only themes supported by the community. Your pull request with theme addition will be merged once we get enough positive feedback from the community in the form of thumbs up :+1: emojis (see [#1935](https://github.com/anuraghazra/github-readme-stats/issues/1935#top-themes-prs)). We expect to see at least 10-15 thumbs up before making a decision to merge your pull request into the master branch. Remember that you can also support themes of other contributors that you liked to speed up their merge.
|
||||
|
||||
GitHub Readme Stats supports multiple languages, if we are missing your language, you can contribute it! You can check the currently supported languages [here](./readme.md#available-locales).
|
||||
> [!NOTE]\
|
||||
> Before submitting pull request, please make sure that your theme pass WCAG 2.0 level AA contrast ration test. You can use [this tool](https://webaim.org/resources/contrastchecker/) to check it.
|
||||
|
||||
To contribute your language you need to edit the [src/translations.js](./src/translations.js) file and add new property to each object where the key is the language code in [ISO 639-1 standard](https://www.andiamo.co.uk/resources/iso-language-codes/) and the value is the translated string.
|
||||
To contribute your theme you need to edit the [themes/index.js](./themes/index.js) file and add it at the end of the file.
|
||||
|
||||
## 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](https://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
|
||||
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)
|
||||
|
||||
|
||||
+2
-18
@@ -27,15 +27,7 @@ export default async (req, res) => {
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(
|
||||
renderError("Something went wrong", "Language not found", {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError("Something went wrong", "Language not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -91,14 +83,6 @@ export default async (req, res) => {
|
||||
CONSTANTS.ERROR_CACHE_SECONDS
|
||||
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
); // Use lower cache period for errors.
|
||||
return res.send(
|
||||
renderError(err.message, err.secondaryMessage, {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError(err.message, err.secondaryMessage));
|
||||
}
|
||||
};
|
||||
|
||||
+8
-56
@@ -8,36 +8,7 @@ import {
|
||||
renderError,
|
||||
} from "../src/common/utils.js";
|
||||
import { fetchStats } from "../src/fetchers/stats-fetcher.js";
|
||||
import { validateQueryStringParams } from "../src/common/validate.js";
|
||||
|
||||
const QUERYSTRING_PARAMS_DATA_TYPE_MAP = new Map([
|
||||
["username", "string"],
|
||||
["hide", "enum-array"],
|
||||
["hide_title", "boolean"],
|
||||
["hide_border", "boolean"],
|
||||
["card_width", "number"],
|
||||
["hide_rank", "boolean"],
|
||||
["show_icons", "boolean"],
|
||||
["include_all_commits", "boolean"],
|
||||
["line_height", "number"],
|
||||
["title_color", "string"],
|
||||
["ring_color", "string"],
|
||||
["icon_color", "string"],
|
||||
["text_color", "string"],
|
||||
["text_bold", "boolean"],
|
||||
["bg_color", "string"],
|
||||
["theme", "enum"],
|
||||
["cache_seconds", "number"],
|
||||
["exclude_repo", "array"],
|
||||
["custom_title", "string"],
|
||||
["locale", "enum"],
|
||||
["disable_animations", "boolean"],
|
||||
["border_radius", "number"],
|
||||
["border_color", "string"],
|
||||
["number_format", "enum"],
|
||||
["rank_icon", "enum"],
|
||||
["show", "enum-array"],
|
||||
]);
|
||||
import { isLocaleAvailable } from "../src/translations.js";
|
||||
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
@@ -71,29 +42,18 @@ export default async (req, res) => {
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (blacklist.includes(username)) {
|
||||
return res.send(
|
||||
renderError("Something went wrong", "This username is blacklisted", {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError("Something went wrong"));
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(renderError("Something went wrong", "Language not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
validateQueryStringParams(req.query, QUERYSTRING_PARAMS_DATA_TYPE_MAP);
|
||||
|
||||
const showStats = parseArray(show);
|
||||
const stats = await fetchStats(
|
||||
username,
|
||||
parseBoolean(include_all_commits),
|
||||
parseArray(exclude_repo),
|
||||
showStats.includes("prs_merged") ||
|
||||
showStats.includes("prs_merged_percentage"),
|
||||
showStats.includes("discussions_started"),
|
||||
showStats.includes("discussions_answered"),
|
||||
);
|
||||
|
||||
let cacheSeconds = clampValue(
|
||||
@@ -136,7 +96,7 @@ export default async (req, res) => {
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
disable_animations: parseBoolean(disable_animations),
|
||||
rank_icon,
|
||||
show: showStats,
|
||||
show: parseArray(show),
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
@@ -146,14 +106,6 @@ export default async (req, res) => {
|
||||
CONSTANTS.ERROR_CACHE_SECONDS
|
||||
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
); // Use lower cache period for errors.
|
||||
return res.send(
|
||||
renderError(err.message, err.secondaryMessage, {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError(err.message, err.secondaryMessage));
|
||||
}
|
||||
};
|
||||
|
||||
+3
-29
@@ -24,33 +24,16 @@ export default async (req, res) => {
|
||||
locale,
|
||||
border_radius,
|
||||
border_color,
|
||||
description_lines_count,
|
||||
} = req.query;
|
||||
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (blacklist.includes(username)) {
|
||||
return res.send(
|
||||
renderError("Something went wrong", "This username is blacklisted", {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError("Something went wrong"));
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(
|
||||
renderError("Something went wrong", "Language not found", {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError("Something went wrong", "Language not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -97,7 +80,6 @@ export default async (req, res) => {
|
||||
border_color,
|
||||
show_owner: parseBoolean(show_owner),
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
description_lines_count,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
@@ -107,14 +89,6 @@ export default async (req, res) => {
|
||||
CONSTANTS.ERROR_CACHE_SECONDS
|
||||
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
); // Use lower cache period for errors.
|
||||
return res.send(
|
||||
renderError(err.message, err.secondaryMessage, {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError(err.message, err.secondaryMessage));
|
||||
}
|
||||
};
|
||||
|
||||
+2
-18
@@ -37,15 +37,7 @@ export default async (req, res) => {
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (blacklist.includes(username)) {
|
||||
return res.send(
|
||||
renderError("Something went wrong", "This username is blacklisted", {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError("Something went wrong"));
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
@@ -113,14 +105,6 @@ export default async (req, res) => {
|
||||
CONSTANTS.ERROR_CACHE_SECONDS
|
||||
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
); // Use lower cache period for errors.
|
||||
return res.send(
|
||||
renderError(err.message, err.secondaryMessage, {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError(err.message, err.secondaryMessage));
|
||||
}
|
||||
};
|
||||
|
||||
+2
-22
@@ -30,22 +30,12 @@ export default async (req, res) => {
|
||||
api_domain,
|
||||
border_radius,
|
||||
border_color,
|
||||
display_format,
|
||||
disable_animations,
|
||||
} = req.query;
|
||||
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(
|
||||
renderError("Something went wrong", "Language not found", {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError("Something went wrong", "Language not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -85,8 +75,6 @@ export default async (req, res) => {
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
layout,
|
||||
langs_count,
|
||||
display_format,
|
||||
disable_animations: parseBoolean(disable_animations),
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
@@ -96,14 +84,6 @@ export default async (req, res) => {
|
||||
CONSTANTS.ERROR_CACHE_SECONDS
|
||||
}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
|
||||
); // Use lower cache period for errors.
|
||||
return res.send(
|
||||
renderError(err.message, err.secondaryMessage, {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
}),
|
||||
);
|
||||
return res.send(renderError(err.message, err.secondaryMessage));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
||||
+14
-8
@@ -25,6 +25,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -75,7 +81,7 @@
|
||||
- [Verbirg einzelne Sprachen](#verbirg-einzelne-sprachen)
|
||||
- [Kompaktes Sprachen-Karte Layout](#kompaktes-sprachen-karte-layout)
|
||||
- [Beispiel](#beispiel)
|
||||
- [WakaTime Wochen-Statistik](#wakatime-wochen-statistik)
|
||||
- [Wakatime Wochen-Statistik](#wakatime-wochen-statistik)
|
||||
- [Beispiel](#beispiel-1)
|
||||
- [Alle Beispiele](#alle-beispiele)
|
||||
- [Kleiner Tipp (Ausrichten der Repo-Karte)](#kleiner-tipp-ausrichten-der-repo-karte)
|
||||
@@ -189,7 +195,7 @@ Du kannst mehrere, mit Kommas separierte, Werte in der bg_color Option angeben,
|
||||
- `layout` - Wechselt zwischen zwei verschiedenen Layouts: `default` & `compact`
|
||||
- `langs_count` - Begrenzt die Anzahl der angezeigten Sprachen auf der Karte
|
||||
- `api_domain` - Legt eine benutzerdefinierte API Domain fest, z.B. für [Hakatime](https://github.com/mujx/hakatime) oder [Wakapi](https://github.com/muety/wakapi)
|
||||
- `range` – Fragt eine andere Zeitspanne an, als jene, welche standardmäßig in WakaTime hinterlegt ist. Zum Beispiel `last_7_days`. Siehe [WakaTime API Dokumentation](https://wakatime.com/developers#stats).
|
||||
- `range` – Fragt eine andere Zeitspanne an, als jene, welche standardmäßig in Wakatime hinterlegt ist. Zum Beispiel `last_7_days`. Siehe [WakaTime API Dokumentation](https://wakatime.com/developers#stats).
|
||||
|
||||
---
|
||||
|
||||
@@ -260,23 +266,23 @@ Du kannst die `&layout=compact` Option nutzen, um das Kartendesign zu ändern.
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# WakaTime Wochen-Statistik
|
||||
# Wakatime Wochen-Statistik
|
||||
|
||||
Ändere `?username=` in den eigenen [WakaTime](https://wakatime.com)-Benutzernamen.
|
||||
Ändere `?username=` in den eigenen [Wakatime](https://wakatime.com)-Benutzernamen.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Beispiel
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Kompaktes Layout
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
|
||||
+16
-10
@@ -25,6 +25,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Apoyado%20por-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Apoyado%20por-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -78,7 +84,7 @@
|
||||
- [Mostrar más lenguajes](#mostrar-más-lenguajes)
|
||||
- [Diseño Compacto de Tarjeta de Lenguaje](#diseño-compacto-de-tarjeta-de-lenguaje)
|
||||
- [Ejemplo](#ejemplo-1)
|
||||
- [Estadísticas de la semana de WakaTime](#estadísticas-de-la-semana-de-wakatime)
|
||||
- [Estadísticas de la semana de Wakatime](#estadísticas-de-la-semana-de-wakatime)
|
||||
- [Ejemplo](#ejemplo-2)
|
||||
- [Todos los ejemplos](#todos-los-ejemplos)
|
||||
- [Consejo rápido (para alinear las tarjetas de repositorio)](#consejo-rápido-para-alinear-las-tarjetas-de-repositorio)
|
||||
@@ -200,7 +206,7 @@ Puedes pasar mútliples valores separados por coma en la opción `bg_color` para
|
||||
> Los nombres de los lenguajes deben estar codificados para URLs, como se especifica en [Código porciento](https://es.wikipedia.org/wiki/C%C3%B3digo_porciento)
|
||||
> (es decir: `c++` debería convertirse en `c%2B%2B`,`jupyter notebook` debería convertirse en `jupyter%20notebook`, etc.)
|
||||
|
||||
#### Opciones exclusivas de la Tarjeta de WakaTime:
|
||||
#### Opciones exclusivas de la Tarjeta de Wakatime:
|
||||
|
||||
- `hide_title` - _(booleano)_
|
||||
- `line_height` - Establece el alto de línea entre texto _(número)_
|
||||
@@ -292,23 +298,23 @@ Puedes usar la opción `& layout = compact` para cambiar el diseño de la tarjet
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Estadísticas de la semana de WakaTime
|
||||
# Estadísticas de la semana de Wakatime
|
||||
|
||||
cambia el valor del parámetro `?username=` a tu username en [WakaTime](https://wakatime.com).
|
||||
cambia el valor del parámetro `?username=` a tu username en [Wakatime](https://wakatime.com).
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Ejemplo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Diseño compacto
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
@@ -356,9 +362,9 @@ Escoja cualquiera de los [temas por defecto](#themes)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Tarjeta de WakaTime
|
||||
- Tarjeta de Wakatime
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supporté%20par-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supporté%20par-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supportato%20da-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supportato%20da-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
||||
+13
-7
@@ -24,6 +24,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -77,7 +83,7 @@
|
||||
- [표시할 언어 수 지정하기](#표시할-언어-수-지정하기)
|
||||
- [컴택트한 카드 레이아웃 설정하기](#컴택트한-카드-레이아웃-설정하기)
|
||||
- [미리보기](#미리보기-1)
|
||||
- [WakaTime 주간 통계](#wakatime-주간-통계)
|
||||
- [Wakatime 주간 통계](#wakatime-주간-통계)
|
||||
- [미리보기](#미리보기-2)
|
||||
- [전체 미리보기](#전체-미리보기)
|
||||
- [꿀팁 (저장소 핀 정렬하기)](#꿀팁-저장소-핀-정렬하기)
|
||||
@@ -216,7 +222,7 @@ dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontr
|
||||
> ( 예를 들면, `c++` 는 `c%2B%2B`, `jupyter notebook` 는 `jupyter%20notebook`, 등등. )
|
||||
> [urlencoder.org](https://www.urlencoder.org/) < 서비스를 이용하면 자동으로 생성할 수 있습니다.
|
||||
|
||||
#### WakaTime 카드의 표시 제한 옵션:
|
||||
#### Wakatime 카드의 표시 제한 옵션:
|
||||
|
||||
- `hide_title` - 타이틀 제외 _(boolean)_
|
||||
- `line_height` - 텍스트 간 줄 높이 설정(자간) _(number)_
|
||||
@@ -308,12 +314,12 @@ _참고:
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# WakaTime 주간 통계
|
||||
# Wakatime 주간 통계
|
||||
|
||||
`?username=` 속성의 값을 [WakaTime](https://wakatime.com) 계정의 사용자 명(닉네임)으로 바꿔주세요.
|
||||
`?username=` 속성의 값을 [Wakatime](https://wakatime.com) 계정의 사용자 명(닉네임)으로 바꿔주세요.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 미리보기
|
||||
@@ -372,9 +378,9 @@ _참고:
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- WakaTime 카드
|
||||
- Wakatime 카드
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
|
||||
+15
-9
@@ -24,6 +24,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -77,7 +83,7 @@
|
||||
- [Laat meer programmeertalen zien](#laat-meer-programmeertalen-zien)
|
||||
- [Compacte Talen Kaart opmaak](#compacte-talen-kaart-opmaak)
|
||||
- [Demo](#demo-1)
|
||||
- [Wekelijkse WakaTime Statistieken](#wekelijkse-wakatime-statistieken)
|
||||
- [Wekelijkse Wakatime Statistieken](#wekelijkse-wakatime-statistieken)
|
||||
- [Demo](#demo-2)
|
||||
- [Alle demos](#alle-demos)
|
||||
- [Kleine tip (Verstel de repo kaart z'n positie)](#kleine-tip-verstel-de-repo-kaart-zn-positie)
|
||||
@@ -202,7 +208,7 @@ Je kan meerdere komma verdeelde waarden in de bg_color optie geven om een kleure
|
||||
> (Oftewel: `c++` moet `c%2B%2B` worden, `jupyter notebook` moet `jupyter%20notebook` worden, enzovoort...)
|
||||
> Zie [urlencoder.org](https://www.urlencoder.org/) om dit automatisch te doen.
|
||||
|
||||
#### Exclusieve opties voor WakaTime Kaart:
|
||||
#### Exclusieve opties voor Wakatime Kaart:
|
||||
|
||||
- `hide_title` - _(boolean)_
|
||||
- `line_height` - Verandert de lijn hoogte tussen tekst _(nummer)_
|
||||
@@ -293,19 +299,19 @@ Je kan de `&layout=compact` optie gebruiken om het kaart ontwerp aan te passen.
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Wekelijkse WakaTime Statistieken
|
||||
# Wekelijkse Wakatime Statistieken
|
||||
|
||||
Verander de `?username=` waarde naar je [WakaTime](https://wakatime.com) gebruikersnaam.
|
||||
Verander de `?username=` waarde naar je [Wakatime](https://wakatime.com) gebruikersnaam.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
@@ -353,9 +359,9 @@ Kies uit de [standaard thema\'s](#themes)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- WakaTime kaart
|
||||
- Wakatime kaart
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
|
||||
+11
-5
@@ -24,6 +24,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -291,17 +297,17 @@ You can use the `&langs_count=` option to increase or decrease the number of lan
|
||||
|
||||
# वाका समय वीक स्तट्स
|
||||
|
||||
Change the `?username=` value to your [WakaTime](https://wakatime.com) username.
|
||||
Change the `?username=` value to your [Wakatime](https://wakatime.com) username.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### डेमो
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
@@ -351,7 +357,7 @@ Change the `?username=` value to your [WakaTime](https://wakatime.com) username.
|
||||
|
||||
- वक समय कार्ड
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
|
||||
+12
-6
@@ -24,6 +24,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Apoiado%20por-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Apoiado%20por-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -75,7 +81,7 @@
|
||||
- [Ocultar linguagens individualmente](#ocultar-linguagens-individualmente)
|
||||
- [Layout de cartão de linguagens compacto](#layout-de-cartão-de-linguagens-compacto)
|
||||
- [Demonstração](#demonstração-1)
|
||||
- [Estatística semanal WakaTime](#estatística-semanal-wakatime)
|
||||
- [Estatística semanal Wakatime](#estatística-semanal-wakatime)
|
||||
- [Demonstração](#demonstração-2)
|
||||
- [Todas as demonstrações](#todas-as-demonstrações)
|
||||
- [Dica (Alinhandos os cartões de repositório)](#dica-alinhandos-os-cartões-de-repositório)
|
||||
@@ -250,19 +256,19 @@ Utilize a opção `&layout=compact` para mudar o layout do cartão.
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Estatística semanal WakaTime
|
||||
# Estatística semanal Wakatime
|
||||
|
||||
Altere o valor de `?username=` para o seu username do WakaTime.
|
||||
Altere o valor de `?username=` para o seu username do Wakatime.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demonstração
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
|
||||
+16
-10
@@ -24,6 +24,12 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -77,7 +83,7 @@
|
||||
- [Daha Fazla Dil Gösterin](#daha-fazla-dil-gösterin)
|
||||
- [Kompakt Dil Kartı Düzeni](#kompakt-dil-kartı-düzeni)
|
||||
- [Demo](#demo-1)
|
||||
- [WakaTime Haftalık İstatistikler](#wakatime-haftalık-i̇statistikler)
|
||||
- [Wakatime Haftalık İstatistikler](#wakatime-haftalık-i̇statistikler)
|
||||
- [Demo](#demo-2)
|
||||
- [Tüm Demolar](#tüm-demolar)
|
||||
- [Hızlı İpucu (Repo Kartları Hizlayın)](#hızlı-i̇pucu-repo-kartları-hizlayın)
|
||||
@@ -202,7 +208,7 @@ bg_color içerisinde birden fazla rengi gradient olarak göstermek için virgül
|
||||
> (ör: `c++` yerine `c%2B%2B`, `jupyter notebook` yerine `jupyter%20notebook`, vb.)
|
||||
> [urlencoder.org](https://www.urlencoder.org/) adresini kullanarak otomatik olarak değerleri bu şekle çevirebilirsiniz.
|
||||
|
||||
#### WakaTime Kart Exclusive Özellikler:
|
||||
#### Wakatime Kart Exclusive Özellikler:
|
||||
|
||||
- `hide_title` - _(boolean)_
|
||||
- `line_height` - Satır aralığı yüksekliği _(number)_
|
||||
@@ -292,23 +298,23 @@ Endpoint: `api/top-langs?username=mustafacagri`
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# WakaTime Haftalık İstatistikler
|
||||
# Wakatime Haftalık İstatistikler
|
||||
|
||||
`?username=` değerini [WakaTime](https://wakatime.com)'daki kullanıcı adınızla değiştirin.
|
||||
`?username=` değerini [Wakatime](https://wakatime.com)'daki kullanıcı adınızla değiştirin.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Kompakt Düzen
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
@@ -356,9 +362,9 @@ Endpoint: `api/top-langs?username=mustafacagri`
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- WakaTime kart
|
||||
- Wakatime kart
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
|
||||
+2
-1
@@ -1,11 +1,12 @@
|
||||
import "dotenv/config";
|
||||
import statsCard from "./api/index.js";
|
||||
import repoCard from "./api/pin.js";
|
||||
import langCard from "./api/top-langs.js";
|
||||
import wakatimeCard from "./api/wakatime.js";
|
||||
import gistCard from "./api/gist.js";
|
||||
import express from "express";
|
||||
import dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
const app = express();
|
||||
app.listen(process.env.port || 9000);
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
export default {
|
||||
// Jest-bench need its own test environment to function
|
||||
testEnvironment: "jest-bench/environment",
|
||||
testEnvironmentOptions: {
|
||||
// still Jest-bench environment will run your environment if you specify it here
|
||||
testEnvironment: "jest-environment-node",
|
||||
testEnvironmentOptions: {
|
||||
// specify any option for your environment
|
||||
},
|
||||
},
|
||||
// always include "default" reporter along with Jest-bench reporter
|
||||
// for error reporting
|
||||
reporters: ["default", "jest-bench/reporter"],
|
||||
// will pick up "*.bench.js" file.
|
||||
testRegex: "(\\.bench)\\.(ts|tsx|js)$",
|
||||
};
|
||||
Generated
+426
-816
File diff suppressed because it is too large
Load Diff
+7
-9
@@ -30,34 +30,32 @@
|
||||
"format": "prettier --write .",
|
||||
"format:check": "prettier --check .",
|
||||
"prepare": "husky install",
|
||||
"lint": "npx eslint --max-warnings 0 \"./src/**/*.js\" \"./scripts/**/*.js\" \"./tests/**/*.js\" \"./api/**/*.js\" \"./themes/**/*.js\"",
|
||||
"bench": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.bench.config.js"
|
||||
"lint": "npx eslint --max-warnings 0 \"./src/**/*.js\" \"./scripts/**/*.js\" \"./tests/**/*.js\" \"./api/**/*.js\" \"./themes/**/*.js\""
|
||||
},
|
||||
"author": "Anurag Hazra",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@actions/core": "^1.10.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@actions/github": "^5.1.1",
|
||||
"@testing-library/dom": "^9.3.3",
|
||||
"@testing-library/jest-dom": "^6.1.4",
|
||||
"@testing-library/jest-dom": "^6.1.3",
|
||||
"@uppercod/css-to-object": "^1.1.1",
|
||||
"axios-mock-adapter": "^1.22.0",
|
||||
"color-contrast-checker": "^2.1.0",
|
||||
"eslint": "^8.54.0",
|
||||
"eslint": "^8.51.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"hjson": "^3.2.2",
|
||||
"husky": "^8.0.3",
|
||||
"jest": "^29.7.0",
|
||||
"jest-bench": "^29.4.1",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"lint-staged": "^15.1.0",
|
||||
"lint-staged": "^14.0.1",
|
||||
"lodash.snakecase": "^4.1.1",
|
||||
"parse-diff": "^0.11.1",
|
||||
"prettier": "^3.1.0"
|
||||
"prettier": "^3.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.6.2",
|
||||
"axios": "^1.5.1",
|
||||
"dotenv": "^16.3.1",
|
||||
"emoji-name-map": "^1.2.8",
|
||||
"github-username-regex": "^1.0.0",
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://vercel.com?utm\_source=github\_readme\_stats\_team\&utm\_campaign=oss">
|
||||
<img src="./powered-by-vercel.svg"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -65,7 +62,7 @@
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p align="center">Please note that documentation translations may be outdated; try to use English documentation if possible.</p>
|
||||
<p align="center">Please note that documentation translations may be outdated, try to use english documentation if possible.</p>
|
||||
|
||||
<p align="center">Love the project? Please consider <a href="https://www.paypal.me/anuraghazra">donating</a> to help it improve!</p>
|
||||
|
||||
@@ -73,11 +70,11 @@
|
||||
<img src="https://cfstatic.give.do/logo.png" alt="Give india logo" width="200" />
|
||||
</a>
|
||||
|
||||
Are you considering supporting the project by donating to me? Please DO NOT!!!
|
||||
Are you considering supporting the project by donating to me? Please DO NOT!!
|
||||
|
||||
<img src="https://cfstatic.give.do/910ede2a-7892-43fe-8c8a-dea45e96d950.webp" alt="Picture of Coromandel Express train tragedy" width="35%">
|
||||
|
||||
India has recently suffered one of the most devastating train accidents, and your help will be immensely valuable for the people who were affected by this tragedy.
|
||||
India just suffered one of the most devastating train accident and your help will be immensely valuable for the people who were affected by this tragedy.
|
||||
|
||||
Please visit [this link](https://give.do/fundraisers/stand-beside-the-victims-of-the-coromandel-express-train-tragedy-in-odisha-donate-now) and make a small donation to help the people in need. A small donation goes a long way. :heart:
|
||||
|
||||
@@ -109,7 +106,7 @@ Please visit [this link](https://give.do/fundraisers/stand-beside-the-victims-of
|
||||
- [Pie Chart Language Card Layout](#pie-chart-language-card-layout)
|
||||
- [Hide Progress Bars](#hide-progress-bars)
|
||||
- [Demo](#demo-2)
|
||||
- [WakaTime Stats Card](#wakatime-stats-card)
|
||||
- [Wakatime Stats Card](#wakatime-stats-card)
|
||||
- [Demo](#demo-3)
|
||||
- [All Demos](#all-demos)
|
||||
- [Quick Tip (Align The Cards)](#quick-tip-align-the-cards)
|
||||
@@ -121,19 +118,14 @@ Please visit [this link](https://give.do/fundraisers/stand-beside-the-victims-of
|
||||
- [Keep your fork up to date](#keep-your-fork-up-to-date)
|
||||
- [:sparkling\_heart: Support the project](#sparkling_heart-support-the-project)
|
||||
|
||||
# Important Notices <!-- omit in toc -->
|
||||
# Important Notice <!-- omit in toc -->
|
||||
|
||||
> [!IMPORTANT]\
|
||||
> Since the GitHub API only [allows 5k requests per hour per user account](https://docs.github.com/en/graphql/overview/resource-limitations), the public Vercel instance hosted on `https://github-readme-stats.vercel.app/api` could possibly hit the rate limiter (see [#1471](https://github.com/anuraghazra/github-readme-stats/issues/1471)). We use caching to prevent this from happening (see https://github.com/anuraghazra/github-readme-stats#common-options). You can turn off these rate limit protections by deploying [your own Vercel instance](#disable-rate-limit-protections).
|
||||
|
||||
<img alt="Uptime Badge" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fgithub-readme-stats-git-monitoring-github-readme-stats-team.vercel.app%2Fapi%2Fstatus%2Fup%3Ftype%3Dshields">
|
||||
|
||||
> [!IMPORTANT]\
|
||||
> We're a small team, and to prioritize, we rely on upvotes :+1:. We use the Top Issues dashboard for tracking community demand (see [#1935](https://github.com/anuraghazra/github-readme-stats/issues/1935)). Do not hesitate to upvote the issues and pull requests you are interested in. We will work on the most upvoted first.
|
||||
|
||||
# GitHub Stats Card
|
||||
|
||||
Copy and paste this into your markdown, and that's it. Simple!
|
||||
Copy-paste this into your markdown content, and that is it. Simple!
|
||||
|
||||
Change the `?username=` value to your GitHub username.
|
||||
|
||||
@@ -142,10 +134,10 @@ Change the `?username=` value to your GitHub username.
|
||||
```
|
||||
|
||||
> [!WARNING]\
|
||||
> By default, the stats card only shows statistics like stars, commits, and pull requests from public repositories. To show private statistics on the stats card, you should [deploy your own instance](#deploy-on-your-own) using your own GitHub API token.
|
||||
> By default, the stats card only shows statistics like stars, commits and pull requests from public repositories. To show private statistics on the stats card, you should [deploy your own instance](#deploy-on-your-own) using your own GitHub API token.
|
||||
|
||||
> [!NOTE]\
|
||||
> Available ranks are S (top 1%), A+ (12.5%), A (25%), A- (37.5%), B+ (50%), B (62.5%), B- (75%), C+ (87.5%) and C (everyone). This ranking scheme is based on the [Japanese academic grading](https://wikipedia.org/wiki/Academic_grading_in_Japan) system. The global percentile is calculated as a weighted sum of percentiles for each statistic (number of commits, pull requests, reviews, issues, stars, and followers), based on the cumulative distribution function of the [exponential](https://wikipedia.org/wiki/exponential_distribution) and the [log-normal](https://wikipedia.org/wiki/Log-normal_distribution) distributions. The implementation can be investigated at [src/calculateRank.js](https://github.com/anuraghazra/github-readme-stats/blob/master/src/calculateRank.js). The circle around the rank shows 100 minus the global percentile.
|
||||
> Available ranks are S (top 1%), A+ (12.5%), A (25%), A- (37.5%), B+ (50%), B (62.5%), B- (75%), C+ (87.5%) and C (everyone). This ranking scheme is based on the [Japanese academic grading](https://wikipedia.org/wiki/Academic_grading_in_Japan) system. The global percentile is calculated as a weighted sum of percentiles for each statistic (number of commits, pull requests, reviews, issues, stars and followers), based on the cumulative distribution function of the [exponential](https://wikipedia.org/wiki/exponential_distribution) and the [log-normal](https://wikipedia.org/wiki/Log-normal_distribution) distributions. The implementation can be investigated at [src/calculateRank.js](/src/calculateRank.js). The circle around the rank shows 100 minus the global percentile.
|
||||
|
||||
### Hiding individual stats
|
||||
|
||||
@@ -191,7 +183,7 @@ GitHub Readme Stats comes with several built-in themes (e.g. `dark`, `radical`,
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stats Themes" width="600px"/>
|
||||
|
||||
You can look at a preview for [all available themes](themes/README.md) or checkout the [theme config file](themes/index.js). Please note that we paused the addition of new themes to decrease maintenance efforts; all pull requests related to new themes will be closed.
|
||||
You can look at a preview for [all available themes](themes/README.md) or checkout the [theme config file](themes/index.js). You can also contribute new themes if you like, contributing guidelines can be found [here](CONTRIBUTING.md#themes-contribution).
|
||||
|
||||
#### Responsive Card Theme
|
||||
|
||||
@@ -288,18 +280,16 @@ You can customize the appearance of all your cards however you wish with URL par
|
||||
|
||||
#### Common Options
|
||||
|
||||
| Name | Description | Type | Default value |
|
||||
| --- | --- | --- | --- |
|
||||
| `title_color` | Card's title color. | string (hex color) | `2f80ed` |
|
||||
| `text_color` | Body text color. | string (hex color) | `434d58` |
|
||||
| `icon_color` | Icons color if available. | string (hex color) | `4c71f2` |
|
||||
| `border_color` | Card's border color. Does not apply when `hide_border` is enabled. | string (hex color) | `e4e2e2` |
|
||||
| `bg_color` | Card's background color. | string (hex color or a gradient in the form of *angle,start,end*) | `fffefe` |
|
||||
| `hide_border` | Hides the card's border. | boolean | `false` |
|
||||
| `theme` | Name of the theme, choose from [all available themes](themes/README.md). | enum | `default` |
|
||||
| `cache_seconds` | Sets the cache header manually (min: 21600, max: 86400). | integer | `1800` |
|
||||
| `locale` | Sets the language in the card, you can check full list of available locales [here](#available-locales). | enum | `en` |
|
||||
| `border_radius` | Corner rounding on the card. | number | `4.5` |
|
||||
* `title_color` - Card's title color *(hex color)*. Default: `2f80ed`.
|
||||
* `text_color` - Body text color *(hex color)*. Default: `434d58`.
|
||||
* `icon_color` - Icons color if available *(hex color)*. Default: `4c71f2`.
|
||||
* `border_color` - Card's border color *(hex color)*. Default: `e4e2e2` (Does not apply when `hide_border` is enabled).
|
||||
* `bg_color` - Card's background color *(hex color)* **or** a gradient in the form of *angle,start,end*. Default: `fffefe`
|
||||
* `hide_border` - Hides the card's border *(boolean)*. Default: `false`
|
||||
* `theme` - Name of the theme, choose from [all available themes](themes/README.md). Default: `default` theme.
|
||||
* `cache_seconds` - Sets the cache header manually *(min: 21600, max: 86400)*. Default: `21600 seconds (6 hours)`.
|
||||
* `locale` - Sets the language in the card, you can check full list of available locales [here](#available-locales). Default: `en`.
|
||||
* `border_radius` - Corner rounding on the card. Default: `4.5`.
|
||||
|
||||
> [!WARNING]\
|
||||
> We use caching to decrease the load on our servers (see <https://github.com/anuraghazra/github-readme-stats/issues/1471#issuecomment-1271551425>). Our cards have a default cache of 6 hours (21600 seconds). Also, note that the cache is clamped to a minimum of 6 hours and a maximum of 24 hours. If you want the data on your statistics card to be updated more often you can [deploy your own instance](#deploy-on-your-own) and set [environment variable](#disable-rate-limit-protections) `CACHE_SECONDS` to a value of your choosing.
|
||||
@@ -362,79 +352,66 @@ Here is a list of all available locales:
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
If we don't support your language, please consider contributing! You can find more information about how to do it in our [contributing guidelines](CONTRIBUTING.md#translations-contribution).
|
||||
If we don't support your language, please consider contributing!
|
||||
|
||||
#### Stats Card Exclusive Options
|
||||
|
||||
| Name | Description | Type | Default value |
|
||||
| --- | --- | --- | --- |
|
||||
| `hide` | Hides the [specified items](#hiding-individual-stats) from stats. | string (comma-separated values) | `null` |
|
||||
| `hide_title` | Hides the title of your stats card. | boolean | `false` |
|
||||
| `card_width` | Sets the card's width manually. | number | `500px (approx.)` |
|
||||
| `hide_rank` | Hides the rank and automatically resizes the card width. | boolean | `false` |
|
||||
| `rank_icon` | Shows alternative rank icon (i.e. `github`, `percentile` or `default`). | enum | `default` |
|
||||
| `show_icons` | Shows icons near all stats. | boolean | `false` |
|
||||
| `include_all_commits` | Count total commits instead of just the current year commits. | boolean | `false` |
|
||||
| `line_height` | Sets the line height between text. | integer | `25` |
|
||||
| `exclude_repo` | Excludes specified repositories. | string (comma-separated values) | `null` |
|
||||
| `custom_title` | Sets a custom title for the card. | string | `<username> GitHub Stats` |
|
||||
| `text_bold` | Uses bold text. | boolean | `true` |
|
||||
| `disable_animations` | Disables all animations in the card. | boolean | `false` |
|
||||
| `ring_color` | Color of the rank circle. | string (hex color) | `2f80ed` |
|
||||
| `number_format` | Switches between two available formats for displaying the card values `short` (i.e. `6.6k`) and `long` (i.e. `6626`). | enum | `short` |
|
||||
| `show` | Shows [additional items](#showing-additional-individual-stats) on stats card (i.e. `reviews`, `discussions_started`, `discussions_answered`, `prs_merged` or `prs_merged_percentage`). | string (comma-separated values) | `null` |
|
||||
* `hide` - Hides the [specified items](#hiding-individual-stats) from stats *(Comma-separated values)*. Default: `[] (blank array)`.
|
||||
* `hide_title` - *(boolean)*. Default: `false`.
|
||||
* `card_width` - Sets the card's width manually *(number)*. Default: `500px (approx.)`.
|
||||
* `hide_rank` - *(boolean)* hides the rank and automatically resizes the card width. Default: `false`.
|
||||
* `rank_icon` - Shows alternative rank icon (i.e. `github`, `percentile` or `default`). Default: `default`.
|
||||
* `show_icons` - *(boolean)*. Default: `false`.
|
||||
* `include_all_commits` - Counts total commits instead of just the current year commits *(boolean)*. Default: `false`.
|
||||
* `line_height` - Sets the line height between text *(number)*. Default: `25`.
|
||||
* `exclude_repo` - Excludes stars from specified repositories *(Comma-separated values)*. Default: `[] (blank array)`.
|
||||
* `custom_title` - Sets a custom title for the card. Default: `<username> GitHub Stats`.
|
||||
* `text_bold` - Uses bold text *(boolean)*. Default: `true`.
|
||||
* `disable_animations` - Disables all animations in the card *(boolean)*. Default: `false`.
|
||||
* `ring_color` - Color of the rank circle *(hex color)*. Defaults to the theme ring color if it exists and otherwise the title color.
|
||||
* `number_format` - Switches between two available formats for displaying the card values `short` (i.e. `6.6k`) and `long` (i.e. `6626`). Default: `short`.
|
||||
* `show` - Shows [additional items](#showing-additional-individual-stats) on stats card (i.e. `reviews`, `discussions_started`, `discussions_answered`, `prs_merged` or `prs_merged_percentage`) *(Comma-separated values)*. Default: `[] (blank array)`.
|
||||
|
||||
> [!NOTE]\
|
||||
> When hide\_rank=`true`, the minimum card width is 270 px + the title length and padding.
|
||||
|
||||
#### Repo Card Exclusive Options
|
||||
|
||||
| Name | Description | Type | Default value |
|
||||
| --- | --- | --- | --- |
|
||||
| `show_owner` | Shows the repo's owner name. | boolean | `false` |
|
||||
| `description_lines_count` | Manually set the number of lines for the description. Specified value will be clamped between 1 and 3. If this parameter is not specified, the number of lines will be automatically adjusted according to the actual length of the description. | number | `null` |
|
||||
* `show_owner` - Shows the repo's owner name *(boolean)*. Default: `false`.
|
||||
|
||||
#### Gist Card Exclusive Options
|
||||
|
||||
| Name | Description | Type | Default value |
|
||||
| --- | --- | --- | --- |
|
||||
| `show_owner` | Shows the gist's owner name. | boolean | `false` |
|
||||
* `show_owner` - Shows the gist's owner name *(boolean)*. Default: `false`.
|
||||
|
||||
#### Language Card Exclusive Options
|
||||
|
||||
| Name | Description | Type | Default value |
|
||||
| --- | --- | --- | --- |
|
||||
| `hide` | Hides the [specified languages](#hide-individual-languages) from card. | string (comma-separated values) | `null` |
|
||||
| `hide_title` | Hides the title of your card. | boolean | `false` |
|
||||
| `layout` | Switches between five available layouts `normal` & `compact` & `donut` & `donut-vertical` & `pie`. | enum | `normal` |
|
||||
| `card_width` | Sets the card's width manually. | number | `300` |
|
||||
| `langs_count` | Shows more languages on the card, between 1-20. | integer | `5` for `normal` and `donut`, `6` for other layouts |
|
||||
| `exclude_repo` | Excludes specified repositories. | string (comma-separated values) | `null` |
|
||||
| `custom_title` | Sets a custom title for the card. | string | `Most Used Languages` |
|
||||
| `disable_animations` | Disables all animations in the card. | boolean | `false` |
|
||||
| `hide_progress` | Uses the compact layout option, hides percentages, and removes the bars. | boolean | `false` |
|
||||
| `size_weight` | Configures language stats algorithm (see [Language stats algorithm](#language-stats-algorithm)). | integer | `1` |
|
||||
| `count_weight` | Configures language stats algorithm (see [Language stats algorithm](#language-stats-algorithm)). | integer | `0` |
|
||||
* `hide` - Hides the languages specified from the card *(Comma-separated values)*. Default: `[] (blank array)`.
|
||||
* `hide_title` - *(boolean)*. Default: `false`.
|
||||
* `layout` - Switches between five available layouts `normal` & `compact` & `donut` & `donut-vertical` & `pie`. Default: `normal`.
|
||||
* `card_width` - Sets the card's width manually *(number)*. Default `300`.
|
||||
* `langs_count` - Shows more languages on the card, between 1-20 *(number)*. Default: `5` for `normal` and `donut`, `6` for other layouts.
|
||||
* `exclude_repo` - Excludes specified repositories *(Comma-separated values)*. Default: `[] (blank array)`.
|
||||
* `custom_title` - Sets a custom title for the card *(string)*. Default `Most Used Languages`.
|
||||
* `disable_animations` - Disables all animations in the card *(boolean)*. Default: `false`.
|
||||
* `hide_progress` - Uses the compact layout option, hides percentages, and removes the bars. Default: `false`.
|
||||
* `size_weight` - Configures language stats algorithm *(number)* (see [Language stats algorithm](#Language-stats-algorithm)), defaults to 1.
|
||||
* `count_weight` - Configures language stats algorithm *(number)* (see [Language stats algorithm](#Language-stats-algorithm)), defaults to 0.
|
||||
|
||||
> [!WARNING]\
|
||||
> Language names should be URI-escaped, as specified in [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding)
|
||||
> (i.e: `c++` should become `c%2B%2B`, `jupyter notebook` should become `jupyter%20notebook`, etc.) You can use
|
||||
> [urlencoder.org](https://www.urlencoder.org/) to help you do this automatically.
|
||||
|
||||
#### WakaTime Card Exclusive Options
|
||||
#### Wakatime Card Exclusive Options
|
||||
|
||||
| Name | Description | Type | Default value |
|
||||
| --- | --- | --- | --- |
|
||||
| `hide` | Hides the languages specified from the card. | string (comma-separated values) | `null` |
|
||||
| `hide_title` | Hides the title of your card. | boolean | `false` |
|
||||
| `line_height` | Sets the line height between text. | integer | `25` |
|
||||
| `hide_progress` | Hides the progress bar and percentage. | boolean | `false` |
|
||||
| `custom_title` | Sets a custom title for the card. | string | `WakaTime Stats` |
|
||||
| `layout` | Switches between two available layouts `default` & `compact`. | enum | `default` |
|
||||
| `langs_count` | Limits the number of languages on the card, defaults to all reported languages. | integer | `null` |
|
||||
| `api_domain` | Sets a custom API domain for the card, e.g. to use services like [Hakatime](https://github.com/mujx/hakatime) or [Wakapi](https://github.com/muety/wakapi) | string | `Waka API` |
|
||||
| `display_format` | Sets the WakaTime stats display format. Choose `time` to display time-based stats or `percent` to show percentages. | enum | `time` |
|
||||
| `disable_animations` | Disables all animations in the card. | boolean | `false` |
|
||||
* `hide` - Hides the languages specified from the card *(Comma-separated values)*. Default: `[] (blank array)`.
|
||||
* `hide_title` - *(boolean)*. Default `false`.
|
||||
* `line_height` - Sets the line height between text *(number)*. Default `25`.
|
||||
* `hide_progress` - Hides the progress bar and percentage *(boolean)*. Default `false`.
|
||||
* `custom_title` - Sets a custom title for the card *(string)*. Default `Wakatime Stats`.
|
||||
* `layout` - Switches between two available layouts `default` & `compact`. Default `default`.
|
||||
* `langs_count` - Limits the number of languages on the card, defaults to all reported languages *(number)*.
|
||||
* `api_domain` - Sets a custom API domain for the card, e.g. to use services like [Hakatime](https://github.com/mujx/hakatime) or [Wakapi](https://github.com/muety/wakapi) *(string)*. Default `Waka API`.
|
||||
|
||||
***
|
||||
|
||||
@@ -495,10 +472,10 @@ The top languages card shows a GitHub user's most frequently used languages.
|
||||
> Top Languages does not indicate the user's skill level or anything like that; it's a GitHub metric to determine which languages have the most code on GitHub. It is a new feature of github-readme-stats.
|
||||
|
||||
> [!WARNING]\
|
||||
> This card shows language usage only inside your own non-forked repositories, not depending on who the author of the commits is. It does not include your contributions into another users/organizations repositories. Currently there are no way to get this data from GitHub API. If you want this behavior to be improved you can support [this feature request](https://github.com/orgs/community/discussions/18230) created by [@rickstaa](https://github.com/rickstaa) inside GitHub Community.
|
||||
> This card shows languages usage only inside your own non-forked repositories, not depending from who is the author of the commits. It does not include your contributions into another users/organizations repositories. Currently there are no way to get this data from GitHub API. If you want this behavior to be improved you can support [this feature request](https://github.com/orgs/community/discussions/18230) created by [@rickstaa](https://github.com/rickstaa) inside GitHub Community.
|
||||
|
||||
> [!WARNING]\
|
||||
> Currently this card shows data only about first 100 repositories. This is because GitHub API limitations which cause downtimes of public instances (see [#1471](https://github.com/anuraghazra/github-readme-stats/issues/1471)). In future this behavior will be improved by releasing GitHub action or providing environment variables for user's own instances.
|
||||
> Currently this card shows data only about first 100 repositories. This is because GitHub API limitations which cause downtimes of public instance (see [#1471](https://github.com/anuraghazra/github-readme-stats/issues/1471)). In future this behavior will be improved by releasing GitHub action or providing environment variable for user's own instances.
|
||||
|
||||
### Usage
|
||||
|
||||
@@ -616,26 +593,26 @@ You can use the `&hide_progress=true` option to hide the percentages and the pro
|
||||
|
||||

|
||||
|
||||
# WakaTime Stats Card
|
||||
# Wakatime Stats Card
|
||||
|
||||
> [!WARNING]\
|
||||
> Please be aware that we currently only show data from WakaTime profiles that are public. You therefore have to make sure that **BOTH** `Display code time publicly` and `Display languages, editors, os, categories publicly` are enabled.
|
||||
> Please be aware that we currently only show data from Wakatime profiles that are public. You therefore have to make sure that **BOTH** `Display code time publicly` and `Display languages, editors, os, categories publicly` are enabled.
|
||||
|
||||
Change the `?username=` value to your [WakaTime](https://wakatime.com) username.
|
||||
Change the `?username=` value to your [Wakatime](https://wakatime.com) username.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
* Compact layout
|
||||
|
||||

|
||||

|
||||
|
||||
***
|
||||
|
||||
@@ -709,7 +686,7 @@ Choose from any of the [default themes](#themes)
|
||||
|
||||
* WakaTime card
|
||||
|
||||

|
||||

|
||||
|
||||
***
|
||||
|
||||
@@ -768,7 +745,7 @@ Since the GitHub API only allows 5k requests per hour, my `https://github-readme
|
||||
> Since [#58](https://github.com/anuraghazra/github-readme-stats/pull/58), we should be able to handle more than 5k requests and have fewer issues with downtime :grin:.
|
||||
|
||||
> [!NOTE]\
|
||||
> If you are on the [Pro (i.e. paid)](https://vercel.com/pricing) Vercel plan, the [maxDuration](https://vercel.com/docs/concepts/projects/project-configuration#value-definition) value found in the [vercel.json](https://github.com/anuraghazra/github-readme-stats/blob/master/vercel.json) can be increased when your Vercel instance frequently times out during the card request. You are advised to keep this value lower than `30` seconds to prevent high memory usage.
|
||||
> If you are on the [Pro (i.e. paid)](https://vercel.com/pricing) Vercel plan, the [maxDuration](https://vercel.com/docs/concepts/projects/project-configuration#value-definition) value found in the [Vercel.json](/vercel.json) can be increased when your Vercel instance frequently times out during the card request. You are advised to keep this value lower than `30` seconds to prevent high memory usage.
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
@@ -815,7 +792,7 @@ Since the GitHub API only allows 5k requests per hour, my `https://github-readme
|
||||
|
||||
Github Readme Stats contains several Vercel environment variables that can be used to remove the rate limit protections:
|
||||
|
||||
* `CACHE_SECONDS`: This environment variable takes precedence over our cache minimum and maximum values and can circumvent these values for self-hosted Vercel instances.
|
||||
* `CACHE_SECONDS`: This environment variable takes precedence over our cache minimum and maximum values and can circumvent these values for self Hosted Vercel instances.
|
||||
|
||||
See [the Vercel documentation](https://vercel.com/docs/concepts/projects/environment-variables) on adding these environment variables to your Vercel instance.
|
||||
|
||||
@@ -830,9 +807,9 @@ this takes time. You can use this service for free.
|
||||
|
||||
However, if you are using this project and are happy with it or just want to encourage me to continue creating stuff, there are a few ways you can do it:
|
||||
|
||||
* Giving proper credit when you use github-readme-stats on your readme, linking back to it. :D
|
||||
* Starring and sharing the project. :rocket:
|
||||
* [](https://www.paypal.me/anuraghazra) - You can make a one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
|
||||
* Giving proper credit when you use github-readme-stats on your readme, linking back to it :D
|
||||
* Starring and sharing the project :rocket:
|
||||
* [](https://www.paypal.me/anuraghazra) - You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
|
||||
|
||||
Thanks! :heart:
|
||||
|
||||
|
||||
@@ -155,9 +155,7 @@ const run = async () => {
|
||||
// Loop through all stale invalid theme pull requests and close them.
|
||||
for (const prNumber of staleThemePRsNumbers) {
|
||||
debug(`Closing #${prNumber} because it is stale...`);
|
||||
if (dryRun) {
|
||||
debug("Dry run enabled, skipping...");
|
||||
} else {
|
||||
if (!dryRun) {
|
||||
await octokit.rest.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
@@ -170,6 +168,8 @@ const run = async () => {
|
||||
pull_number: prNumber,
|
||||
state: "closed",
|
||||
});
|
||||
} else {
|
||||
debug("Dry run enabled, skipping...");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -14,7 +14,7 @@ const THEME_TEMPLATE = `## Available Themes
|
||||
|
||||
With inbuilt themes, you can customize the look of the card without doing any manual customization.
|
||||
|
||||
Use \`?theme=THEME_NAME\` parameter like so:
|
||||
Use \`?theme=THEME_NAME\` parameter like so :-
|
||||
|
||||
\`\`\`md
|
||||

|
||||
@@ -22,7 +22,7 @@ Use \`?theme=THEME_NAME\` parameter like so:
|
||||
|
||||
## Stats
|
||||
|
||||
> These themes works with all five our cards: Stats Card, Repo Card, Gist Card, Top languages Card and WakaTime Card.
|
||||
> These themes work both for the Stats Card and Repo Card.
|
||||
|
||||
| | | |
|
||||
| :--: | :--: | :--: |
|
||||
@@ -30,7 +30,7 @@ ${STAT_CARD_TABLE_FLAG}
|
||||
|
||||
## Repo Card
|
||||
|
||||
> These themes works with all five our cards: Stats Card, Repo Card, Gist Card, Top languages Card and WakaTime Card.
|
||||
> These themes work both for the Stats Card and Repo Card.
|
||||
|
||||
| | | |
|
||||
| :--: | :--: | :--: |
|
||||
@@ -69,7 +69,7 @@ const createTableItem = ({ link, label, isRepoCard }) => {
|
||||
const generateTable = ({ isRepoCard }) => {
|
||||
const rows = [];
|
||||
const themesFiltered = Object.keys(themes).filter(
|
||||
(name) => name !== (isRepoCard ? "default" : "default_repocard"),
|
||||
(name) => name !== (!isRepoCard ? "default_repocard" : "default"),
|
||||
);
|
||||
|
||||
for (let i = 0; i < themesFiltered.length; i += 3) {
|
||||
|
||||
+31
-42
@@ -12,7 +12,7 @@ import Hjson from "hjson";
|
||||
import snakeCase from "lodash.snakecase";
|
||||
import parse from "parse-diff";
|
||||
import { inspect } from "util";
|
||||
import { isValidHexColor, isValidGradient } from "../src/common/utils.js";
|
||||
import { isValidHexColor } from "../src/common/utils.js";
|
||||
import { themes } from "../themes/index.js";
|
||||
import { getGithubToken, getRepoInfo } from "./helpers.js";
|
||||
|
||||
@@ -32,9 +32,6 @@ const THEME_CONTRIB_GUIDELINES = `
|
||||
\r> [!WARNING]\
|
||||
\r> Keep in mind that we already have a vast collection of different themes. To keep their number manageable, we began to add only themes supported by the community. Your pull request with theme addition will be merged once we get enough positive feedback from the community in the form of thumbs up :+1: emojis (see [#1935](https://github.com/anuraghazra/github-readme-stats/issues/1935#top-themes-prs)). We expect to see at least 10-15 thumbs up before making a decision to merge your pull request into the master branch. Remember that you can also support themes of other contributors that you liked to speed up their merge.
|
||||
|
||||
\r> [!WARNING]\
|
||||
\r> Please do not submit a pull request with a batch of themes, since it will be hard to judge how the community will react to each of them. We will only merge one theme per pull request. If you have several themes, please submit a separate pull request for each of them. Situations when you have several versions of the same theme (e.g. light and dark) are an exception to this rule.
|
||||
|
||||
\r> [!NOTE]\
|
||||
\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).
|
||||
`;
|
||||
@@ -42,7 +39,7 @@ const COLOR_PROPS = {
|
||||
title_color: 6,
|
||||
icon_color: 6,
|
||||
text_color: 6,
|
||||
bg_color: 23,
|
||||
bg_color: 8,
|
||||
border_color: 6,
|
||||
};
|
||||
const ACCEPTED_COLOR_PROPS = Object.keys(COLOR_PROPS);
|
||||
@@ -175,20 +172,20 @@ const upsertComment = async (
|
||||
body,
|
||||
) => {
|
||||
let resp;
|
||||
if (commentId === undefined) {
|
||||
resp = await octokit.rest.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
body,
|
||||
});
|
||||
} else {
|
||||
if (commentId !== undefined) {
|
||||
resp = await octokit.rest.issues.updateComment({
|
||||
owner,
|
||||
repo,
|
||||
comment_id: commentId,
|
||||
body,
|
||||
});
|
||||
} else {
|
||||
resp = await octokit.rest.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
body,
|
||||
});
|
||||
}
|
||||
return resp.data.html_url;
|
||||
};
|
||||
@@ -344,10 +341,10 @@ const parseJSON = (json) => {
|
||||
.filter((x) => typeof x !== "string" || !!x.trim()); // Split json into array of strings and objects.
|
||||
if (splitJson[0].replace(/\s+/g, "") === "},") {
|
||||
splitJson[0] = "},";
|
||||
if (/\s*}\s*,?\s*$/.test(splitJson[1])) {
|
||||
splitJson.shift();
|
||||
} else {
|
||||
if (!/\s*}\s*,?\s*$/.test(splitJson[1])) {
|
||||
splitJson.push(splitJson.shift());
|
||||
} else {
|
||||
splitJson.shift();
|
||||
}
|
||||
parsedJson = splitJson.join("");
|
||||
}
|
||||
@@ -469,7 +466,10 @@ export const run = async () => {
|
||||
// Check if the theme colors are valid.
|
||||
debug("Theme preview body: Check if the theme colors are valid...");
|
||||
let invalidColors = false;
|
||||
if (colors) {
|
||||
if (!colors) {
|
||||
warnings.push("Theme colors are missing");
|
||||
invalidColors = true;
|
||||
} else {
|
||||
const missingKeys = REQUIRED_COLOR_PROPS.filter(
|
||||
(x) => !Object.keys(colors).includes(x),
|
||||
);
|
||||
@@ -499,21 +499,14 @@ export const run = async () => {
|
||||
`Theme color property \`${colorKey}\` can not be longer than \`${COLOR_PROPS[colorKey]}\` characters`,
|
||||
);
|
||||
invalidColors = true;
|
||||
} else if (
|
||||
!(colorKey === "bg_color" && colorValue.split(",").length > 1
|
||||
? isValidGradient(colorValue.split(","))
|
||||
: isValidHexColor(colorValue))
|
||||
) {
|
||||
} else if (!isValidHexColor(colorValue)) {
|
||||
errors.push(
|
||||
`Theme color property \`${colorKey}\` is not a valid hex color: <code>${colorValue}</code>`,
|
||||
`Theme color property \`${colorKey}\` is not a valid hex color: <code>#${colorValue}</code>`,
|
||||
);
|
||||
invalidColors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
warnings.push("Theme colors are missing");
|
||||
invalidColors = true;
|
||||
}
|
||||
if (invalidColors) {
|
||||
themeValid[theme] = false;
|
||||
@@ -546,10 +539,6 @@ export const run = async () => {
|
||||
Object.keys(colorPairs).forEach((item) => {
|
||||
let color1 = colorPairs[item][0];
|
||||
let color2 = colorPairs[item][1];
|
||||
const isGradientColor = color2.split(",").length > 1;
|
||||
if (isGradientColor) {
|
||||
return;
|
||||
}
|
||||
color1 = color1.length === 4 ? color1.slice(0, 3) : color1.slice(0, 6);
|
||||
color2 = color2.length === 4 ? color2.slice(0, 3) : color2.slice(0, 6);
|
||||
if (!ccc.isLevelAA(`#${color1}`, `#${color2}`)) {
|
||||
@@ -608,10 +597,7 @@ export const run = async () => {
|
||||
// Create or update theme-preview comment.
|
||||
debug("Create or update theme-preview comment...");
|
||||
let comment_url;
|
||||
if (DRY_RUN) {
|
||||
info(`DRY_RUN: Comment body: ${commentBody}`);
|
||||
comment_url = "";
|
||||
} else {
|
||||
if (!DRY_RUN) {
|
||||
comment_url = await upsertComment(
|
||||
OCTOKIT,
|
||||
PULL_REQUEST_ID,
|
||||
@@ -620,6 +606,9 @@ export const run = async () => {
|
||||
comment?.id,
|
||||
commentBody,
|
||||
);
|
||||
} else {
|
||||
info(`DRY_RUN: Comment body: ${commentBody}`);
|
||||
comment_url = "";
|
||||
}
|
||||
|
||||
// Change review state and add/remove `invalid` label based on theme PR validity.
|
||||
@@ -631,10 +620,7 @@ export const run = async () => {
|
||||
const reviewReason = themesValid
|
||||
? undefined
|
||||
: INVALID_REVIEW_COMMENT(comment_url);
|
||||
if (DRY_RUN) {
|
||||
info(`DRY_RUN: Review state: ${reviewState}`);
|
||||
info(`DRY_RUN: Review reason: ${reviewReason}`);
|
||||
} else {
|
||||
if (!DRY_RUN) {
|
||||
await addReview(
|
||||
OCTOKIT,
|
||||
PULL_REQUEST_ID,
|
||||
@@ -651,13 +637,13 @@ export const run = async () => {
|
||||
"invalid",
|
||||
!themesValid,
|
||||
);
|
||||
} else {
|
||||
info(`DRY_RUN: Review state: ${reviewState}`);
|
||||
info(`DRY_RUN: Review reason: ${reviewReason}`);
|
||||
}
|
||||
} catch (error) {
|
||||
debug("Set review state to `REQUEST_CHANGES` and add `invalid` label...");
|
||||
if (DRY_RUN) {
|
||||
info(`DRY_RUN: Review state: REQUEST_CHANGES`);
|
||||
info(`DRY_RUN: Review reason: ${error.message}`);
|
||||
} else {
|
||||
if (!DRY_RUN) {
|
||||
await addReview(
|
||||
OCTOKIT,
|
||||
PULL_REQUEST_ID,
|
||||
@@ -676,6 +662,9 @@ export const run = async () => {
|
||||
"invalid",
|
||||
true,
|
||||
);
|
||||
} else {
|
||||
info(`DRY_RUN: Review state: REQUEST_CHANGES`);
|
||||
info(`DRY_RUN: Review reason: ${error.message}`);
|
||||
}
|
||||
setFailed(error.message);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ git config --global --add safe.directory ${GITHUB_WORKSPACE}
|
||||
git branch -d $BRANCH_NAME || true
|
||||
git checkout -b $BRANCH_NAME
|
||||
git add --all
|
||||
git commit --no-verify --message "docs(theme): auto update theme readme"
|
||||
git commit --no-verify --message "docs(theme): Auto update theme readme"
|
||||
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
|
||||
|
||||
+6
-21
@@ -12,13 +12,10 @@ import {
|
||||
wrapTextMultiline,
|
||||
iconWithLabel,
|
||||
createLanguageNode,
|
||||
clampValue,
|
||||
} from "../common/utils.js";
|
||||
import { repoCardLocales } from "../translations.js";
|
||||
|
||||
const ICON_SIZE = 16;
|
||||
const DESCRIPTION_LINE_WIDTH = 59;
|
||||
const DESCRIPTION_MAX_LINES = 3;
|
||||
|
||||
/**
|
||||
* Retrieves the repository description and wraps it to fit the card width.
|
||||
@@ -76,34 +73,22 @@ const renderRepoCard = (repo, options = {}) => {
|
||||
border_radius,
|
||||
border_color,
|
||||
locale,
|
||||
description_lines_count,
|
||||
} = options;
|
||||
|
||||
const lineHeight = 10;
|
||||
const header = show_owner ? nameWithOwner : name;
|
||||
const langName = (primaryLanguage && primaryLanguage.name) || "Unspecified";
|
||||
const langColor = (primaryLanguage && primaryLanguage.color) || "#333";
|
||||
const descriptionMaxLines = description_lines_count
|
||||
? clampValue(description_lines_count, 1, DESCRIPTION_MAX_LINES)
|
||||
: DESCRIPTION_MAX_LINES;
|
||||
|
||||
const desc = parseEmojis(description || "No description provided");
|
||||
const multiLineDescription = wrapTextMultiline(
|
||||
desc,
|
||||
DESCRIPTION_LINE_WIDTH,
|
||||
descriptionMaxLines,
|
||||
);
|
||||
const descriptionLinesCount = description_lines_count
|
||||
? clampValue(description_lines_count, 1, DESCRIPTION_MAX_LINES)
|
||||
: multiLineDescription.length;
|
||||
|
||||
const multiLineDescription = wrapTextMultiline(desc);
|
||||
const descriptionLines = multiLineDescription.length;
|
||||
const descriptionSvg = multiLineDescription
|
||||
.map((line) => `<tspan dy="1.2em" x="25">${encodeHTML(line)}</tspan>`)
|
||||
.join("");
|
||||
|
||||
const height =
|
||||
(descriptionLinesCount > 1 ? 120 : 110) +
|
||||
descriptionLinesCount * lineHeight;
|
||||
(descriptionLines > 1 ? 120 : 110) + descriptionLines * lineHeight;
|
||||
|
||||
const i18n = new I18n({
|
||||
locale,
|
||||
@@ -175,9 +160,9 @@ const renderRepoCard = (repo, options = {}) => {
|
||||
? // @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)
|
||||
: ""
|
||||
}
|
||||
|
||||
<text class="description" x="25" y="-5">
|
||||
|
||||
+7
-118
@@ -10,6 +10,7 @@ import {
|
||||
kFormatter,
|
||||
measureText,
|
||||
} from "../common/utils.js";
|
||||
import { getStyles } from "../getStyles.js";
|
||||
import { statCardLocales } from "../translations.js";
|
||||
|
||||
const CARD_MIN_WIDTH = 287;
|
||||
@@ -75,118 +76,6 @@ const createTextNode = ({
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates progress along the boundary of the circle, i.e. its circumference.
|
||||
*
|
||||
* @param {number} value The rank value to calculate progress for.
|
||||
* @returns {number} Progress value.
|
||||
*/
|
||||
const calculateCircleProgress = (value) => {
|
||||
const radius = 40;
|
||||
const c = Math.PI * (radius * 2);
|
||||
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
if (value > 100) {
|
||||
value = 100;
|
||||
}
|
||||
|
||||
return ((100 - value) / 100) * c;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the animation to display progress along the circumference of circle
|
||||
* from the beginning to the given value in a clockwise direction.
|
||||
*
|
||||
* @param {{progress: number}} progress The progress value to animate to.
|
||||
* @returns {string} Progress animation css.
|
||||
*/
|
||||
const getProgressAnimation = ({ progress }) => {
|
||||
return `
|
||||
@keyframes rankAnimation {
|
||||
from {
|
||||
stroke-dashoffset: ${calculateCircleProgress(0)};
|
||||
}
|
||||
to {
|
||||
stroke-dashoffset: ${calculateCircleProgress(progress)};
|
||||
}
|
||||
}
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves CSS styles for a card.
|
||||
*
|
||||
* @param {Object} colors The colors to use for the card.
|
||||
* @param {string} colors.titleColor The title color.
|
||||
* @param {string} colors.textColor The text color.
|
||||
* @param {string} colors.iconColor The icon color.
|
||||
* @param {string} colors.ringColor The ring color.
|
||||
* @param {boolean} colors.show_icons Whether to show icons.
|
||||
* @param {number} colors.progress The progress value to animate to.
|
||||
* @returns {string} Card CSS styles.
|
||||
*/
|
||||
const getStyles = ({
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
ringColor,
|
||||
show_icons,
|
||||
progress,
|
||||
}) => {
|
||||
return `
|
||||
.stat {
|
||||
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: ${textColor};
|
||||
}
|
||||
@supports(-moz-appearance: auto) {
|
||||
/* Selector detects Firefox */
|
||||
.stat { font-size:12px; }
|
||||
}
|
||||
.stagger {
|
||||
opacity: 0;
|
||||
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-text {
|
||||
font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor};
|
||||
animation: scaleInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-percentile-header {
|
||||
font-size: 14px;
|
||||
}
|
||||
.rank-percentile-text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.not_bold { font-weight: 400 }
|
||||
.bold { font-weight: 700 }
|
||||
.icon {
|
||||
fill: ${iconColor};
|
||||
display: ${show_icons ? "block" : "none"};
|
||||
}
|
||||
|
||||
.rank-circle-rim {
|
||||
stroke: ${ringColor};
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
opacity: 0.2;
|
||||
}
|
||||
.rank-circle {
|
||||
stroke: ${ringColor};
|
||||
stroke-dasharray: 250;
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
stroke-linecap: round;
|
||||
opacity: 0.8;
|
||||
transform-origin: -10px 8px;
|
||||
transform: rotate(-90deg);
|
||||
animation: rankAnimation 1s forwards ease-in-out;
|
||||
}
|
||||
${process.env.NODE_ENV === "test" ? "" : getProgressAnimation({ progress })}
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import('../fetchers/types').StatsData} StatsData
|
||||
* @typedef {import('./types').StatCardOptions} StatCardOptions
|
||||
@@ -412,8 +301,8 @@ const renderStatsCard = (stats, options = {}) => {
|
||||
custom_title
|
||||
? custom_title
|
||||
: statItems.length
|
||||
? i18n.t("statcard.title")
|
||||
: i18n.t("statcard.ranktitle"),
|
||||
? i18n.t("statcard.title")
|
||||
: i18n.t("statcard.ranktitle"),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -431,14 +320,14 @@ const renderStatsCard = (stats, options = {}) => {
|
||||
Infinity,
|
||||
)
|
||||
: statItems.length
|
||||
? RANK_CARD_MIN_WIDTH
|
||||
: RANK_ONLY_CARD_MIN_WIDTH) + iconWidth;
|
||||
? RANK_CARD_MIN_WIDTH
|
||||
: RANK_ONLY_CARD_MIN_WIDTH) + iconWidth;
|
||||
const defaultCardWidth =
|
||||
(hide_rank
|
||||
? CARD_DEFAULT_WIDTH
|
||||
: statItems.length
|
||||
? RANK_CARD_DEFAULT_WIDTH
|
||||
: RANK_ONLY_CARD_DEFAULT_WIDTH) + iconWidth;
|
||||
? RANK_CARD_DEFAULT_WIDTH
|
||||
: RANK_ONLY_CARD_DEFAULT_WIDTH) + iconWidth;
|
||||
let width = card_width
|
||||
? isNaN(card_width)
|
||||
? defaultCardWidth
|
||||
|
||||
@@ -383,14 +383,14 @@ const renderCompactLayout = (langs, width, totalLanguageSize, hideProgress) => {
|
||||
|
||||
return `
|
||||
${
|
||||
hideProgress
|
||||
? ""
|
||||
: `
|
||||
<mask id="rect-mask">
|
||||
<rect x="0" y="0" width="${offsetWidth}" height="8" fill="white" rx="5"/>
|
||||
</mask>
|
||||
${compactProgressBar}
|
||||
`
|
||||
!hideProgress
|
||||
? `
|
||||
<mask id="rect-mask">
|
||||
<rect x="0" y="0" width="${offsetWidth}" height="8" fill="white" rx="5"/>
|
||||
</mask>
|
||||
${compactProgressBar}
|
||||
`
|
||||
: ""
|
||||
}
|
||||
<g transform="translate(0, ${hideProgress ? "0" : "25"})">
|
||||
${createLanguageTextNode({
|
||||
@@ -755,8 +755,8 @@ const renderTopLanguages = (topLangs, options = {}) => {
|
||||
? isNaN(card_width)
|
||||
? DEFAULT_CARD_WIDTH
|
||||
: card_width < MIN_CARD_WIDTH
|
||||
? MIN_CARD_WIDTH
|
||||
: card_width
|
||||
? MIN_CARD_WIDTH
|
||||
: card_width
|
||||
: DEFAULT_CARD_WIDTH;
|
||||
let height = calculateNormalLayoutHeight(langs.length);
|
||||
|
||||
|
||||
Vendored
-3
@@ -32,7 +32,6 @@ export type StatCardOptions = CommonOptions & {
|
||||
|
||||
export type RepoCardOptions = CommonOptions & {
|
||||
show_owner: boolean;
|
||||
description_lines_count: number;
|
||||
};
|
||||
|
||||
export type TopLangOptions = CommonOptions & {
|
||||
@@ -54,8 +53,6 @@ type WakaTimeOptions = CommonOptions & {
|
||||
custom_title: string;
|
||||
layout: "compact" | "normal";
|
||||
langs_count: number;
|
||||
display_format: "time" | "percent";
|
||||
disable_animations: boolean;
|
||||
};
|
||||
|
||||
export type GistCardOptions = CommonOptions & {
|
||||
|
||||
+16
-62
@@ -8,6 +8,7 @@ import {
|
||||
getCardColors,
|
||||
lowercaseTrim,
|
||||
} from "../common/utils.js";
|
||||
import { getStyles } from "../getStyles.js";
|
||||
import { wakatimeCardLocales } from "../translations.js";
|
||||
|
||||
/** Import language colors.
|
||||
@@ -46,21 +47,16 @@ const noCodingActivityNode = ({ color, text }) => {
|
||||
* @param {WakaTimeLang} args.lang The languages array.
|
||||
* @param {number} args.x The x position of the language node.
|
||||
* @param {number} args.y The y position of the language node.
|
||||
* @param {"time" | "percent"} args.display_format The display format of the language node.
|
||||
* @returns {string} The compact layout language SVG node.
|
||||
*/
|
||||
const createCompactLangNode = ({ lang, x, y, display_format }) => {
|
||||
const createCompactLangNode = ({ lang, x, y }) => {
|
||||
const color = languageColors[lang.name] || "#858585";
|
||||
const value =
|
||||
display_format === "percent"
|
||||
? `${lang.percent.toFixed(2).toString()} %`
|
||||
: lang.text;
|
||||
|
||||
return `
|
||||
<g transform="translate(${x}, ${y})">
|
||||
<circle cx="5" cy="6" r="5" fill="${color}" />
|
||||
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
|
||||
${lang.name} - ${value}
|
||||
${lang.name} - ${lang.text}
|
||||
</text>
|
||||
</g>
|
||||
`;
|
||||
@@ -72,24 +68,21 @@ const createCompactLangNode = ({ lang, x, y, display_format }) => {
|
||||
* @param {Object} args The function arguments.
|
||||
* @param {WakaTimeLang[]} args.langs The language objects.
|
||||
* @param {number} args.y The y position of the language node.
|
||||
* @param {"time" | "percent"} args.display_format The display format of the language node.
|
||||
* @returns {string[]} The language text node items.
|
||||
*/
|
||||
const createLanguageTextNode = ({ langs, y, display_format }) => {
|
||||
const createLanguageTextNode = ({ langs, y }) => {
|
||||
return langs.map((lang, index) => {
|
||||
if (index % 2 === 0) {
|
||||
return createCompactLangNode({
|
||||
lang,
|
||||
x: 25,
|
||||
y: 12.5 * index + y,
|
||||
display_format,
|
||||
});
|
||||
}
|
||||
return createCompactLangNode({
|
||||
lang,
|
||||
x: 230,
|
||||
y: 12.5 + 12.5 * index,
|
||||
display_format,
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -165,36 +158,6 @@ const recalculatePercentages = (languages) => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves CSS styles for a card.
|
||||
*
|
||||
* @param {Object} colors The colors to use for the card.
|
||||
* @param {string} colors.titleColor The title color.
|
||||
* @param {string} colors.textColor The text color.
|
||||
* @returns {string} Card CSS styles.
|
||||
*/
|
||||
const getStyles = ({
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
titleColor,
|
||||
textColor,
|
||||
}) => {
|
||||
return `
|
||||
.stat {
|
||||
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: ${textColor};
|
||||
}
|
||||
@supports(-moz-appearance: auto) {
|
||||
/* Selector detects Firefox */
|
||||
.stat { font-size:12px; }
|
||||
}
|
||||
.stagger {
|
||||
opacity: 0;
|
||||
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.not_bold { font-weight: 400 }
|
||||
.bold { font-weight: 700 }
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import('../fetchers/types').WakaTimeData} WakaTimeData
|
||||
* @typedef {import('./types').WakaTimeOptions} WakaTimeOptions
|
||||
@@ -226,8 +189,6 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
||||
langs_count = languages.length,
|
||||
border_radius,
|
||||
border_color,
|
||||
display_format = "time",
|
||||
disable_animations,
|
||||
} = options;
|
||||
|
||||
const shouldHideLangs = Array.isArray(hide) && hide.length > 0;
|
||||
@@ -274,6 +235,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
||||
const cssStyles = getStyles({
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
});
|
||||
|
||||
let finalLayout = "";
|
||||
@@ -321,16 +283,15 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
||||
? createLanguageTextNode({
|
||||
y: 25,
|
||||
langs: filteredLanguages,
|
||||
display_format,
|
||||
}).join("")
|
||||
: noCodingActivityNode({
|
||||
// @ts-ignore
|
||||
color: textColor,
|
||||
text: stats.is_coding_activity_visible
|
||||
? stats.is_other_usage_visible
|
||||
? i18n.t("wakatimecard.nocodingactivity")
|
||||
: i18n.t("wakatimecard.nocodedetails")
|
||||
: i18n.t("wakatimecard.notpublic"),
|
||||
text: !stats.is_coding_activity_visible
|
||||
? i18n.t("wakatimecard.notpublic")
|
||||
: stats.is_other_usage_visible
|
||||
? i18n.t("wakatimecard.nocodingactivity")
|
||||
: i18n.t("wakatimecard.nocodedetails"),
|
||||
})
|
||||
}
|
||||
`;
|
||||
@@ -341,10 +302,7 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
||||
return createTextNode({
|
||||
id: language.name,
|
||||
label: language.name,
|
||||
value:
|
||||
display_format === "percent"
|
||||
? `${language.percent.toFixed(2).toString()} %`
|
||||
: language.text,
|
||||
value: language.text,
|
||||
index,
|
||||
percent: language.percent,
|
||||
// @ts-ignore
|
||||
@@ -358,11 +316,11 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
||||
noCodingActivityNode({
|
||||
// @ts-ignore
|
||||
color: textColor,
|
||||
text: stats.is_coding_activity_visible
|
||||
? stats.is_other_usage_visible
|
||||
? i18n.t("wakatimecard.nocodingactivity")
|
||||
: i18n.t("wakatimecard.nocodedetails")
|
||||
: i18n.t("wakatimecard.notpublic"),
|
||||
text: !stats.is_coding_activity_visible
|
||||
? i18n.t("wakatimecard.notpublic")
|
||||
: stats.is_other_usage_visible
|
||||
? i18n.t("wakatimecard.nocodingactivity")
|
||||
: i18n.t("wakatimecard.nocodedetails"),
|
||||
}),
|
||||
],
|
||||
gap: lheight,
|
||||
@@ -396,10 +354,6 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
||||
},
|
||||
});
|
||||
|
||||
if (disable_animations) {
|
||||
card.disableAnimations();
|
||||
}
|
||||
|
||||
card.setHideBorder(hide_border);
|
||||
card.setHideTitle(hide_title);
|
||||
card.setCSS(
|
||||
|
||||
+5
-31
@@ -1,3 +1,4 @@
|
||||
import { getAnimations } from "../getStyles.js";
|
||||
import { encodeHTML, flexLayout } from "./utils.js";
|
||||
|
||||
class Card {
|
||||
@@ -39,9 +40,9 @@ class Card {
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
this.colors = colors;
|
||||
this.title =
|
||||
customTitle === undefined
|
||||
? encodeHTML(defaultTitle)
|
||||
: encodeHTML(customTitle);
|
||||
customTitle !== undefined
|
||||
? encodeHTML(customTitle)
|
||||
: encodeHTML(defaultTitle);
|
||||
|
||||
this.css = "";
|
||||
|
||||
@@ -172,33 +173,6 @@ class Card {
|
||||
: "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves css animations for a card.
|
||||
*
|
||||
* @returns {string} Animation css.
|
||||
*/
|
||||
getAnimations = () => {
|
||||
return `
|
||||
/* Animations */
|
||||
@keyframes scaleInAnimation {
|
||||
from {
|
||||
transform: translate(-5px, 5px) scale(0);
|
||||
}
|
||||
to {
|
||||
transform: translate(-5px, 5px) scale(1);
|
||||
}
|
||||
}
|
||||
@keyframes fadeInAnimation {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} body The inner body of the card.
|
||||
* @returns {string} The rendered card.
|
||||
@@ -228,7 +202,7 @@ class Card {
|
||||
}
|
||||
${this.css}
|
||||
|
||||
${process.env.NODE_ENV === "test" ? "" : this.getAnimations()}
|
||||
${process.env.NODE_ENV === "test" ? "" : getAnimations()}
|
||||
${
|
||||
this.animations === false
|
||||
? `* { animation-duration: 0s !important; animation-delay: 0s !important; }`
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
"BlitzBasic": "#00FFAE",
|
||||
"BlitzMax": "#cd6400",
|
||||
"Bluespec": "#12223c",
|
||||
"Bluespec BH": "#12223c",
|
||||
"Boo": "#d4bec1",
|
||||
"Boogie": "#c80fa0",
|
||||
"Brainfuck": "#2F2530",
|
||||
@@ -193,7 +192,6 @@
|
||||
"Gosu": "#82937f",
|
||||
"Grace": "#615f8b",
|
||||
"Gradle": "#02303a",
|
||||
"Gradle Kotlin DSL": "#02303a",
|
||||
"Grammatical Framework": "#ff0000",
|
||||
"GraphQL": "#e10098",
|
||||
"Graphviz (DOT)": "#2596be",
|
||||
@@ -424,7 +422,6 @@
|
||||
"Red": "#f50000",
|
||||
"Regular Expression": "#009a00",
|
||||
"Ren'Py": "#ff7f7f",
|
||||
"Rez": "#FFDAB3",
|
||||
"Ring": "#2D54CB",
|
||||
"Riot": "#A71E49",
|
||||
"RobotFramework": "#00c0b5",
|
||||
@@ -479,7 +476,6 @@
|
||||
"SuperCollider": "#46390b",
|
||||
"Svelte": "#ff3e00",
|
||||
"Sway": "#dea584",
|
||||
"Sweave": "#198ce7",
|
||||
"Swift": "#F05138",
|
||||
"SystemVerilog": "#DAE1C2",
|
||||
"TI Program": "#A0AA87",
|
||||
@@ -500,7 +496,6 @@
|
||||
"Turing": "#cf142b",
|
||||
"Twig": "#c1d026",
|
||||
"TypeScript": "#3178c6",
|
||||
"Typst": "#239dad",
|
||||
"Unified Parallel C": "#4e3617",
|
||||
"Unity3D Asset": "#222c37",
|
||||
"Uno": "#9933cc",
|
||||
|
||||
+78
-110
@@ -4,40 +4,51 @@ import toEmoji from "emoji-name-map";
|
||||
import wrap from "word-wrap";
|
||||
import { themes } from "../../themes/index.js";
|
||||
|
||||
const TRY_AGAIN_LATER = "Please try again later";
|
||||
// Script parameters.
|
||||
const ERROR_CARD_LENGTH = 576.5;
|
||||
|
||||
const SECONDARY_ERROR_MESSAGES = {
|
||||
MAX_RETRY:
|
||||
"You can deploy own instance or wait until public will be no longer limited",
|
||||
NO_TOKENS:
|
||||
"Please add an env variable called PAT_1 with your GitHub API token in vercel",
|
||||
USER_NOT_FOUND: "Make sure the provided username is not an organization",
|
||||
GRAPHQL_ERROR: TRY_AGAIN_LATER,
|
||||
GITHUB_REST_API_ERROR: TRY_AGAIN_LATER,
|
||||
WAKATIME_USER_NOT_FOUND: "Make sure you have a public WakaTime profile",
|
||||
/**
|
||||
* Encode string as HTML.
|
||||
*
|
||||
* @see https://stackoverflow.com/a/48073476/10629172
|
||||
*
|
||||
* @param {string} str String to encode.
|
||||
* @returns {string} Encoded string.
|
||||
*/
|
||||
const encodeHTML = (str) => {
|
||||
return str
|
||||
.replace(/[\u00A0-\u9999<>&](?!#)/gim, (i) => {
|
||||
return "&#" + i.charCodeAt(0) + ";";
|
||||
})
|
||||
.replace(/\u0008/gim, "");
|
||||
};
|
||||
|
||||
/**
|
||||
* Custom error class to handle custom GRS errors.
|
||||
* Renders error message on the card.
|
||||
*
|
||||
* @param {string} message Main error message.
|
||||
* @param {string} secondaryMessage The secondary error message.
|
||||
* @returns {string} The SVG markup.
|
||||
*/
|
||||
class CustomError extends Error {
|
||||
/**
|
||||
* @param {string} message Error message.
|
||||
* @param {string} type Error type.
|
||||
*/
|
||||
constructor(message, type) {
|
||||
super(message);
|
||||
this.type = type;
|
||||
this.secondaryMessage = SECONDARY_ERROR_MESSAGES[type] || type;
|
||||
}
|
||||
|
||||
static MAX_RETRY = "MAX_RETRY";
|
||||
static NO_TOKENS = "NO_TOKENS";
|
||||
static USER_NOT_FOUND = "USER_NOT_FOUND";
|
||||
static GRAPHQL_ERROR = "GRAPHQL_ERROR";
|
||||
static GITHUB_REST_API_ERROR = "GITHUB_REST_API_ERROR";
|
||||
static WAKATIME_ERROR = "WAKATIME_ERROR";
|
||||
}
|
||||
const renderError = (message, secondaryMessage = "") => {
|
||||
return `
|
||||
<svg width="${ERROR_CARD_LENGTH}" height="120" viewBox="0 0 ${ERROR_CARD_LENGTH} 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="${
|
||||
ERROR_CARD_LENGTH - 1
|
||||
}" height="99%" rx="4.5" fill="#FFFEFE" stroke="#E4E2E2"/>
|
||||
<text x="25" y="45" class="text">Something went wrong! file an issue at https://tiny.one/readme-stats</text>
|
||||
<text data-testid="message" x="25" y="55" class="text small">
|
||||
<tspan x="25" dy="18">${encodeHTML(message)}</tspan>
|
||||
<tspan x="25" dy="18" class="gray">${secondaryMessage}</tspan>
|
||||
</text>
|
||||
</svg>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Auto layout utility, allows us to layout things vertically or horizontally with
|
||||
@@ -177,7 +188,7 @@ const parseArray = (str) => {
|
||||
*/
|
||||
const clampValue = (number, min, max) => {
|
||||
// @ts-ignore
|
||||
if (Number.isNaN(parseInt(number, 10))) {
|
||||
if (Number.isNaN(parseInt(number))) {
|
||||
return min;
|
||||
}
|
||||
return Math.max(min, Math.min(number, max));
|
||||
@@ -190,10 +201,7 @@ const clampValue = (number, min, max) => {
|
||||
* @returns {boolean} True if the given string is a valid gradient.
|
||||
*/
|
||||
const isValidGradient = (colors) => {
|
||||
return (
|
||||
colors.length > 2 &&
|
||||
colors.slice(1).every((color) => isValidHexColor(color))
|
||||
);
|
||||
return isValidHexColor(colors[1]) && isValidHexColor(colors[2]);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -325,81 +333,6 @@ const getCardColors = ({
|
||||
return { titleColor, iconColor, textColor, bgColor, borderColor, ringColor };
|
||||
};
|
||||
|
||||
// Script parameters.
|
||||
const ERROR_CARD_LENGTH = 576.5;
|
||||
|
||||
/**
|
||||
* Encode string as HTML.
|
||||
*
|
||||
* @see https://stackoverflow.com/a/48073476/10629172
|
||||
*
|
||||
* @param {string} str String to encode.
|
||||
* @returns {string} Encoded string.
|
||||
*/
|
||||
const encodeHTML = (str) => {
|
||||
return str
|
||||
.replace(/[\u00A0-\u9999<>&](?!#)/gim, (i) => {
|
||||
return "&#" + i.charCodeAt(0) + ";";
|
||||
})
|
||||
.replace(/\u0008/gim, "");
|
||||
};
|
||||
|
||||
const UPSTREAM_API_ERRORS = [
|
||||
TRY_AGAIN_LATER,
|
||||
SECONDARY_ERROR_MESSAGES.MAX_RETRY,
|
||||
];
|
||||
|
||||
/**
|
||||
* Renders error message on the card.
|
||||
*
|
||||
* @param {string} message Main error message.
|
||||
* @param {string} secondaryMessage The secondary error message.
|
||||
* @param {object} options Function options.
|
||||
* @returns {string} The SVG markup.
|
||||
*/
|
||||
const renderError = (message, secondaryMessage = "", options = {}) => {
|
||||
const {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme = "default",
|
||||
} = options;
|
||||
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
const { titleColor, textColor, bgColor, borderColor } = getCardColors({
|
||||
title_color,
|
||||
text_color,
|
||||
icon_color: "",
|
||||
bg_color,
|
||||
border_color,
|
||||
ring_color: "",
|
||||
theme,
|
||||
});
|
||||
|
||||
return `
|
||||
<svg width="${ERROR_CARD_LENGTH}" height="120" viewBox="0 0 ${ERROR_CARD_LENGTH} 120" fill="${bgColor}" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.text { font: 600 16px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${titleColor} }
|
||||
.small { font: 600 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
|
||||
.gray { fill: #858585 }
|
||||
</style>
|
||||
<rect x="0.5" y="0.5" width="${
|
||||
ERROR_CARD_LENGTH - 1
|
||||
}" height="99%" rx="4.5" fill="${bgColor}" stroke="${borderColor}"/>
|
||||
<text x="25" y="45" class="text">Something went wrong!${
|
||||
UPSTREAM_API_ERRORS.includes(secondaryMessage)
|
||||
? ""
|
||||
: " file an issue at https://tiny.one/readme-stats"
|
||||
}</text>
|
||||
<text data-testid="message" x="25" y="55" class="text small">
|
||||
<tspan x="25" dy="18">${encodeHTML(message)}</tspan>
|
||||
<tspan x="25" dy="18" class="gray">${secondaryMessage}</tspan>
|
||||
</text>
|
||||
</svg>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Split text over multiple lines based on the card width.
|
||||
*
|
||||
@@ -438,7 +371,7 @@ const wrapTextMultiline = (text, width = 59, maxLines = 3) => {
|
||||
const noop = () => {};
|
||||
// return console instance based on the environment
|
||||
const logger =
|
||||
process.env.NODE_ENV === "test" ? { log: noop, error: noop } : console;
|
||||
process.env.NODE_ENV !== "test" ? console : { log: noop, error: noop };
|
||||
|
||||
const ONE_MINUTE = 60;
|
||||
const FIVE_MINUTES = 300;
|
||||
@@ -466,6 +399,41 @@ const CONSTANTS = {
|
||||
ERROR_CACHE_SECONDS: TEN_MINUTES,
|
||||
};
|
||||
|
||||
const TRY_AGAIN_LATER = "Please try again later";
|
||||
|
||||
const SECONDARY_ERROR_MESSAGES = {
|
||||
MAX_RETRY:
|
||||
"You can deploy own instance or wait until public will be no longer limited",
|
||||
NO_TOKENS:
|
||||
"Please add an env variable called PAT_1 with your GitHub API token in vercel",
|
||||
USER_NOT_FOUND: "Make sure the provided username is not an organization",
|
||||
GRAPHQL_ERROR: TRY_AGAIN_LATER,
|
||||
GITHUB_REST_API_ERROR: TRY_AGAIN_LATER,
|
||||
WAKATIME_USER_NOT_FOUND: "Make sure you have a public WakaTime profile",
|
||||
};
|
||||
|
||||
/**
|
||||
* Custom error class to handle custom GRS errors.
|
||||
*/
|
||||
class CustomError extends Error {
|
||||
/**
|
||||
* @param {string} message Error message.
|
||||
* @param {string} type Error type.
|
||||
*/
|
||||
constructor(message, type) {
|
||||
super(message);
|
||||
this.type = type;
|
||||
this.secondaryMessage = SECONDARY_ERROR_MESSAGES[type] || type;
|
||||
}
|
||||
|
||||
static MAX_RETRY = "MAX_RETRY";
|
||||
static NO_TOKENS = "NO_TOKENS";
|
||||
static USER_NOT_FOUND = "USER_NOT_FOUND";
|
||||
static GRAPHQL_ERROR = "GRAPHQL_ERROR";
|
||||
static GITHUB_REST_API_ERROR = "GITHUB_REST_API_ERROR";
|
||||
static WAKATIME_ERROR = "WAKATIME_ERROR";
|
||||
}
|
||||
|
||||
/**
|
||||
* Missing query parameter class.
|
||||
*/
|
||||
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
export type DataTypes =
|
||||
| "enum"
|
||||
| "enum-array"
|
||||
| "array"
|
||||
| "string"
|
||||
| "boolean"
|
||||
| "number";
|
||||
|
||||
export function validateQueryStringParam(
|
||||
expectedDataType: DateTypes,
|
||||
param: string,
|
||||
value: string,
|
||||
): boolean;
|
||||
|
||||
export function validateQueryStringParams(
|
||||
queryStringParams: object,
|
||||
queryStringParamsDataTypeMap: Map<string, DataTypes>,
|
||||
): void;
|
||||
|
||||
export class InvalidQueryStringParamsError extends Error {
|
||||
constructor(message: string, secondaryMessage: string);
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { availableLocales } from "../translations.js";
|
||||
import { themes } from "../../themes/index.js";
|
||||
import { parseArray } from "./utils.js";
|
||||
|
||||
/**
|
||||
* Class for handling invalid query string param errors.
|
||||
*/
|
||||
export class InvalidQueryStringParamsError extends Error {
|
||||
/**
|
||||
* Constructor for InvalidQueryStringParamsError.
|
||||
*
|
||||
* @param {string} message - The error message.
|
||||
* @param {string} secondaryMessage - The secondary error message.
|
||||
*/
|
||||
constructor(message, secondaryMessage) {
|
||||
super(message);
|
||||
this.secondaryMessage = secondaryMessage;
|
||||
}
|
||||
}
|
||||
|
||||
const QUERYSTRING_PARAMS_ENUM_VALUES = {
|
||||
hide: ["stars", "commits", "prs", "issues", "contribs"],
|
||||
theme: Object.keys(themes),
|
||||
locale: availableLocales,
|
||||
number_format: ["short", "long"],
|
||||
rank_icon: ["github", "percentile", "default"],
|
||||
show: [
|
||||
"reviews",
|
||||
"discussions_started",
|
||||
"discussions_answered",
|
||||
"prs_merged",
|
||||
"prs_merged_percentage",
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import("./validate").DataTypes} DataTypes The data types.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the secondary error message for an invalid query string param.
|
||||
*
|
||||
* @param {string} param - The invalid query string param.
|
||||
* @param {Map<string, DataTypes>} queryStringParamsDataTypeMap - The query string params data type map.
|
||||
* @returns {string} The secondary error message.
|
||||
*/
|
||||
const getInvalidQueryStringParamsErrorSecondaryMessage = (
|
||||
param,
|
||||
queryStringParamsDataTypeMap,
|
||||
) => {
|
||||
const expectedDataType = queryStringParamsDataTypeMap.get(param);
|
||||
if (expectedDataType === "enum" || expectedDataType === "enum-array") {
|
||||
return `Expected: ${QUERYSTRING_PARAMS_ENUM_VALUES[param].join(", ")}`;
|
||||
} else if (expectedDataType === "number") {
|
||||
return "Expected: a number";
|
||||
} else if (expectedDataType === "boolean") {
|
||||
return "Expected: true or false";
|
||||
} else if (expectedDataType === "array") {
|
||||
return "Expected: an array";
|
||||
} else if (expectedDataType === "string") {
|
||||
return "Expected: a string";
|
||||
} else {
|
||||
throw new Error("Unexpected behavior");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates a query string param.
|
||||
*
|
||||
* @param {DataTypes} expectedDataType - The expected data type of the query string param.
|
||||
* @param {string} param - The query string param.
|
||||
* @param {string} value - The query string param value.
|
||||
* @returns {boolean} Whether the query string param is valid.
|
||||
*/
|
||||
export const validateQueryStringParam = (expectedDataType, param, value) => {
|
||||
if (expectedDataType === "enum") {
|
||||
return QUERYSTRING_PARAMS_ENUM_VALUES[param].includes(value);
|
||||
} else if (expectedDataType === "enum-array") {
|
||||
return parseArray(value).every((value) =>
|
||||
QUERYSTRING_PARAMS_ENUM_VALUES[param].includes(value),
|
||||
);
|
||||
} else if (expectedDataType === "number") {
|
||||
return !isNaN(parseFloat(value));
|
||||
} else if (expectedDataType === "boolean") {
|
||||
return value === "true" || value === "false";
|
||||
} else if (expectedDataType === "array") {
|
||||
return Array.isArray(parseArray(value));
|
||||
} else if (expectedDataType === "string") {
|
||||
return typeof value === "string";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Validates the query string params.
|
||||
* Throws an error if a query string param is invalid.
|
||||
* Does not return anything.
|
||||
*
|
||||
* @param {object} queryStringParams - The query string params.
|
||||
* @param {Map<string, DataTypes>} queryStringParamsDataTypeMap - The query string params data type map.
|
||||
* @returns {void}
|
||||
*/
|
||||
export const validateQueryStringParams = (
|
||||
queryStringParams,
|
||||
queryStringParamsDataTypeMap,
|
||||
) => {
|
||||
for (const [param, value] of Object.entries(queryStringParams)) {
|
||||
const expectedDataType = queryStringParamsDataTypeMap.get(param);
|
||||
if (!expectedDataType) {
|
||||
// Absence of data type means that the query string param is not supported.
|
||||
// Currently we allow addition of extra query string params.
|
||||
continue;
|
||||
}
|
||||
if (validateQueryStringParam(expectedDataType, param, value)) {
|
||||
continue;
|
||||
}
|
||||
throw new InvalidQueryStringParamsError(
|
||||
`Invalid query string param \`${param}\` value: ${value}`,
|
||||
getInvalidQueryStringParamsErrorSecondaryMessage(
|
||||
param,
|
||||
queryStringParamsDataTypeMap,
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -40,7 +40,7 @@ const GRAPHQL_REPOS_QUERY = `
|
||||
`;
|
||||
|
||||
const GRAPHQL_STATS_QUERY = `
|
||||
query userInfo($login: String!, $after: String, $includeMergedPullRequests: Boolean!, $includeDiscussions: Boolean!, $includeDiscussionsAnswers: Boolean!) {
|
||||
query userInfo($login: String!, $after: String) {
|
||||
user(login: $login) {
|
||||
name
|
||||
login
|
||||
@@ -54,7 +54,7 @@ const GRAPHQL_STATS_QUERY = `
|
||||
pullRequests(first: 1) {
|
||||
totalCount
|
||||
}
|
||||
mergedPullRequests: pullRequests(states: MERGED) @include(if: $includeMergedPullRequests) {
|
||||
mergedPullRequests: pullRequests(states: MERGED) {
|
||||
totalCount
|
||||
}
|
||||
openIssues: issues(states: OPEN) {
|
||||
@@ -66,10 +66,10 @@ const GRAPHQL_STATS_QUERY = `
|
||||
followers {
|
||||
totalCount
|
||||
}
|
||||
repositoryDiscussions @include(if: $includeDiscussions) {
|
||||
repositoryDiscussions {
|
||||
totalCount
|
||||
}
|
||||
repositoryDiscussionComments(onlyAnswers: true) @include(if: $includeDiscussionsAnswers) {
|
||||
repositoryDiscussionComments(onlyAnswers: true) {
|
||||
totalCount
|
||||
}
|
||||
${GRAPHQL_REPOS_FIELD}
|
||||
@@ -89,7 +89,7 @@ const GRAPHQL_STATS_QUERY = `
|
||||
* @returns {Promise<AxiosResponse>} Axios response.
|
||||
*/
|
||||
const fetcher = (variables, token) => {
|
||||
const query = variables.after ? GRAPHQL_REPOS_QUERY : GRAPHQL_STATS_QUERY;
|
||||
const query = !variables.after ? GRAPHQL_STATS_QUERY : GRAPHQL_REPOS_QUERY;
|
||||
return request(
|
||||
{
|
||||
query,
|
||||
@@ -104,33 +104,17 @@ const fetcher = (variables, token) => {
|
||||
/**
|
||||
* Fetch stats information for a given username.
|
||||
*
|
||||
* @param {object} variables Fetcher variables.
|
||||
* @param {string} variables.username Github username.
|
||||
* @param {boolean} variables.includeMergedPullRequests Include merged pull requests.
|
||||
* @param {boolean} variables.includeDiscussions Include discussions.
|
||||
* @param {boolean} variables.includeDiscussionsAnswers Include discussions answers.
|
||||
* @param {string} username Github username.
|
||||
* @returns {Promise<AxiosResponse>} Axios response.
|
||||
*
|
||||
* @description This function supports multi-page fetching if the 'FETCH_MULTI_PAGE_STARS' environment variable is set to true.
|
||||
*/
|
||||
const statsFetcher = async ({
|
||||
username,
|
||||
includeMergedPullRequests,
|
||||
includeDiscussions,
|
||||
includeDiscussionsAnswers,
|
||||
}) => {
|
||||
const statsFetcher = async (username) => {
|
||||
let stats;
|
||||
let hasNextPage = true;
|
||||
let endCursor = null;
|
||||
while (hasNextPage) {
|
||||
const variables = {
|
||||
login: username,
|
||||
first: 100,
|
||||
after: endCursor,
|
||||
includeMergedPullRequests,
|
||||
includeDiscussions,
|
||||
includeDiscussionsAnswers,
|
||||
};
|
||||
const variables = { login: username, first: 100, after: endCursor };
|
||||
let res = await retryer(fetcher, variables);
|
||||
if (res.data.errors) {
|
||||
return res;
|
||||
@@ -138,10 +122,10 @@ const statsFetcher = async ({
|
||||
|
||||
// Store stats data.
|
||||
const repoNodes = res.data.data.user.repositories.nodes;
|
||||
if (stats) {
|
||||
stats.data.data.user.repositories.nodes.push(...repoNodes);
|
||||
} else {
|
||||
if (!stats) {
|
||||
stats = res;
|
||||
} else {
|
||||
stats.data.data.user.repositories.nodes.push(...repoNodes);
|
||||
}
|
||||
|
||||
// Disable multi page fetching on public Vercel instance due to rate limits.
|
||||
@@ -214,18 +198,12 @@ const totalCommitsFetcher = async (username) => {
|
||||
* @param {string} username GitHub username.
|
||||
* @param {boolean} include_all_commits Include all commits.
|
||||
* @param {string[]} exclude_repo Repositories to exclude.
|
||||
* @param {boolean} include_merged_pull_requests Include merged pull requests.
|
||||
* @param {boolean} include_discussions Include discussions.
|
||||
* @param {boolean} include_discussions_answers Include discussions answers.
|
||||
* @returns {Promise<StatsData>} Stats data.
|
||||
*/
|
||||
const fetchStats = async (
|
||||
username,
|
||||
include_all_commits = false,
|
||||
exclude_repo = [],
|
||||
include_merged_pull_requests = false,
|
||||
include_discussions = false,
|
||||
include_discussions_answers = false,
|
||||
) => {
|
||||
if (!username) {
|
||||
throw new MissingParamError(["username"]);
|
||||
@@ -246,12 +224,7 @@ const fetchStats = async (
|
||||
rank: { level: "C", percentile: 100 },
|
||||
};
|
||||
|
||||
let res = await statsFetcher({
|
||||
username,
|
||||
includeMergedPullRequests: include_merged_pull_requests,
|
||||
includeDiscussions: include_discussions,
|
||||
includeDiscussionsAnswers: include_discussions_answers,
|
||||
});
|
||||
let res = await statsFetcher(username);
|
||||
|
||||
// Catch GraphQL errors.
|
||||
if (res.data.errors) {
|
||||
@@ -286,21 +259,14 @@ const fetchStats = async (
|
||||
}
|
||||
|
||||
stats.totalPRs = user.pullRequests.totalCount;
|
||||
if (include_merged_pull_requests) {
|
||||
stats.totalPRsMerged = user.mergedPullRequests.totalCount;
|
||||
stats.mergedPRsPercentage =
|
||||
(user.mergedPullRequests.totalCount / user.pullRequests.totalCount) * 100;
|
||||
}
|
||||
stats.totalPRsMerged = user.mergedPullRequests.totalCount;
|
||||
stats.mergedPRsPercentage =
|
||||
(user.mergedPullRequests.totalCount / user.pullRequests.totalCount) * 100;
|
||||
stats.totalReviews =
|
||||
user.contributionsCollection.totalPullRequestReviewContributions;
|
||||
stats.totalIssues = user.openIssues.totalCount + user.closedIssues.totalCount;
|
||||
if (include_discussions) {
|
||||
stats.totalDiscussionsStarted = user.repositoryDiscussions.totalCount;
|
||||
}
|
||||
if (include_discussions_answers) {
|
||||
stats.totalDiscussionsAnswered =
|
||||
user.repositoryDiscussionComments.totalCount;
|
||||
}
|
||||
stats.totalDiscussionsStarted = user.repositoryDiscussions.totalCount;
|
||||
stats.totalDiscussionsAnswered = user.repositoryDiscussionComments.totalCount;
|
||||
stats.contributedTo = user.repositoriesContributedTo.totalCount;
|
||||
|
||||
// Retrieve stars while filtering out repositories to be hidden.
|
||||
|
||||
@@ -92,7 +92,7 @@ const fetchTopLanguages = async (
|
||||
);
|
||||
}
|
||||
throw new CustomError(
|
||||
"Something went wrong while trying to retrieve the language data using the GraphQL API.",
|
||||
"Something went while trying to retrieve the language data using the GraphQL API.",
|
||||
CustomError.GRAPHQL_ERROR,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* Calculates progress along the boundary of the circle i.e it's circumference.
|
||||
*
|
||||
* @param {number} value The rank value to calculate progress for.
|
||||
* @returns {number} Progress value.
|
||||
*/
|
||||
const calculateCircleProgress = (value) => {
|
||||
const radius = 40;
|
||||
const c = Math.PI * (radius * 2);
|
||||
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
if (value > 100) {
|
||||
value = 100;
|
||||
}
|
||||
|
||||
return ((100 - value) / 100) * c;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the animation to display progress along the circumference of circle
|
||||
* from the beginning to the given value in a clockwise direction.
|
||||
*
|
||||
* @param {{progress: number}} progress The progress value to animate to.
|
||||
* @returns {string} Progress animation css.
|
||||
*/
|
||||
const getProgressAnimation = ({ progress }) => {
|
||||
return `
|
||||
@keyframes rankAnimation {
|
||||
from {
|
||||
stroke-dashoffset: ${calculateCircleProgress(0)};
|
||||
}
|
||||
to {
|
||||
stroke-dashoffset: ${calculateCircleProgress(progress)};
|
||||
}
|
||||
}
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves css animations for a card.
|
||||
*
|
||||
* @returns {string} Animation css.
|
||||
*/
|
||||
const getAnimations = () => {
|
||||
return `
|
||||
/* Animations */
|
||||
@keyframes scaleInAnimation {
|
||||
from {
|
||||
transform: translate(-5px, 5px) scale(0);
|
||||
}
|
||||
to {
|
||||
transform: translate(-5px, 5px) scale(1);
|
||||
}
|
||||
}
|
||||
@keyframes fadeInAnimation {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves CSS styles for a card.
|
||||
*
|
||||
* @param {Object} colors The colors to use for the card.
|
||||
* @param {string} colors.titleColor The title color.
|
||||
* @param {string} colors.textColor The text color.
|
||||
* @param {string} colors.iconColor The icon color.
|
||||
* @param {string} colors.ringColor The ring color.
|
||||
* @param {boolean} colors.show_icons Whether to show icons.
|
||||
* @param {number} colors.progress The progress value to animate to.
|
||||
* @returns {string} Card CSS styles.
|
||||
*/
|
||||
const getStyles = ({
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
ringColor,
|
||||
show_icons,
|
||||
progress,
|
||||
}) => {
|
||||
return `
|
||||
.stat {
|
||||
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: ${textColor};
|
||||
}
|
||||
@supports(-moz-appearance: auto) {
|
||||
/* Selector detects Firefox */
|
||||
.stat { font-size:12px; }
|
||||
}
|
||||
.stagger {
|
||||
opacity: 0;
|
||||
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-text {
|
||||
font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor};
|
||||
animation: scaleInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-percentile-header {
|
||||
font-size: 14px;
|
||||
}
|
||||
.rank-percentile-text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.not_bold { font-weight: 400 }
|
||||
.bold { font-weight: 700 }
|
||||
.icon {
|
||||
fill: ${iconColor};
|
||||
display: ${!!show_icons ? "block" : "none"};
|
||||
}
|
||||
|
||||
.rank-circle-rim {
|
||||
stroke: ${ringColor};
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
opacity: 0.2;
|
||||
}
|
||||
.rank-circle {
|
||||
stroke: ${ringColor};
|
||||
stroke-dasharray: 250;
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
stroke-linecap: round;
|
||||
opacity: 0.8;
|
||||
transform-origin: -10px 8px;
|
||||
transform: rotate(-90deg);
|
||||
animation: rankAnimation 1s forwards ease-in-out;
|
||||
}
|
||||
${process.env.NODE_ENV === "test" ? "" : getProgressAnimation({ progress })}
|
||||
`;
|
||||
};
|
||||
|
||||
export { getAnimations, getStyles };
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./common/index.js";
|
||||
export * from "./cards/index.js";
|
||||
export { getStyles, getAnimations } from "./getStyles.js";
|
||||
|
||||
+57
-57
@@ -128,7 +128,7 @@ const statCardLocales = ({ name, apostrophe }) => {
|
||||
np: "कुल Commits",
|
||||
el: "Σύνολο Commits",
|
||||
ru: "Всего коммитов",
|
||||
"uk-ua": "Всього комітів",
|
||||
"uk-ua": "Всього коммітов",
|
||||
id: "Total Komitmen",
|
||||
ml: "ആകെ കമ്മിറ്റുകൾ",
|
||||
my: "Jumlah Komitmen",
|
||||
@@ -440,7 +440,7 @@ const repoCardLocales = {
|
||||
np: "अभिलेख राखियो",
|
||||
el: "Αρχειοθετημένα",
|
||||
ru: "Архивирован",
|
||||
"uk-ua": "Архивований",
|
||||
"uk-ua": "Архивирован",
|
||||
id: "Arsip",
|
||||
ml: "ശേഖരിച്ചത്",
|
||||
my: "Arkib",
|
||||
@@ -521,34 +521,34 @@ const langCardLocales = {
|
||||
const wakatimeCardLocales = {
|
||||
"wakatimecard.title": {
|
||||
ar: "إحصائيات واكا تايم",
|
||||
cn: "WakaTime 周统计",
|
||||
"zh-tw": "WakaTime 周統計",
|
||||
cs: "Statistiky WakaTime",
|
||||
de: "WakaTime Status",
|
||||
en: "WakaTime Stats",
|
||||
bn: "WakaTime স্ট্যাটাস",
|
||||
es: "Estadísticas de WakaTime",
|
||||
fr: "Statistiques de WakaTime",
|
||||
hu: "WakaTime statisztika",
|
||||
it: "Statistiche WakaTime",
|
||||
ja: "WakaTime ワカタイム統計",
|
||||
kr: "WakaTime 주간 통계",
|
||||
nl: "WakaTime-statistieken",
|
||||
"pt-pt": "Estatísticas WakaTime",
|
||||
"pt-br": "Estatísticas WakaTime",
|
||||
np: "WakaTime तथ्या .्क",
|
||||
el: "Στατιστικά WakaTime",
|
||||
ru: "Статистика WakaTime",
|
||||
"uk-ua": "Статистика WakaTime",
|
||||
id: "Status WakaTime",
|
||||
cn: "Wakatime 周统计",
|
||||
"zh-tw": "Wakatime 周統計",
|
||||
cs: "Statistiky Wakatime",
|
||||
de: "Wakatime Status",
|
||||
en: "Wakatime Stats",
|
||||
bn: "Wakatime স্ট্যাটাস",
|
||||
es: "Estadísticas de Wakatime",
|
||||
fr: "Statistiques de Wakatime",
|
||||
hu: "Wakatime statisztika",
|
||||
it: "Statistiche Wakatime",
|
||||
ja: "Wakatime ワカタイム統計",
|
||||
kr: "Wakatime 주간 통계",
|
||||
nl: "Wakatime-statistieken",
|
||||
"pt-pt": "Estatísticas Wakatime",
|
||||
"pt-br": "Estatísticas Wakatime",
|
||||
np: "Wakatime तथ्या .्क",
|
||||
el: "Στατιστικά Wakatime",
|
||||
ru: "Статистика Wakatime",
|
||||
"uk-ua": "Статистика Wakatime",
|
||||
id: "Status Wakatime",
|
||||
ml: "വേക്ക് ടൈം സ്ഥിതിവിവരക്കണക്കുകൾ",
|
||||
my: "Statistik WakaTime",
|
||||
sk: "WakaTime štatistika",
|
||||
tr: "WakaTime İstatistikler",
|
||||
pl: "Statystyki WakaTime",
|
||||
uz: "WakaTime statistikasi",
|
||||
vi: "Thống Kê WakaTime",
|
||||
se: "WakaTime statistik",
|
||||
my: "Statistik Wakatime",
|
||||
sk: "Wakatime štatistika",
|
||||
tr: "Waketime İstatistikler",
|
||||
pl: "Statystyki Wakatime",
|
||||
uz: "Wakatime statistikasi",
|
||||
vi: "Thống Kê Wakatime",
|
||||
se: "Wakatime statistik",
|
||||
},
|
||||
"wakatimecard.lastyear": {
|
||||
ar: "العام الماضي",
|
||||
@@ -614,34 +614,34 @@ const wakatimeCardLocales = {
|
||||
},
|
||||
"wakatimecard.notpublic": {
|
||||
ar: "ملف المستخدم غير عام",
|
||||
cn: "WakaTime 用户个人资料未公开",
|
||||
"zh-tw": "WakaTime 使用者個人資料未公開",
|
||||
cs: "Profil uživatele WakaTime není veřejný",
|
||||
de: "WakaTime-Benutzerprofil nicht öffentlich",
|
||||
en: "WakaTime user profile not public",
|
||||
bn: "WakaTime ব্যবহারকারীর প্রোফাইল প্রকাশ্য নয়",
|
||||
es: "Perfil de usuario de WakaTime no público",
|
||||
fr: "Profil utilisateur WakaTime non public",
|
||||
hu: "A WakaTime felhasználói profilja nem nyilvános",
|
||||
it: "Profilo utente WakaTime non pubblico",
|
||||
ja: "WakaTime ユーザープロファイルは公開されていません",
|
||||
kr: "WakaTime 사용자 프로필이 공개되지 않았습니다",
|
||||
nl: "WakaTime gebruikersprofiel niet openbaar",
|
||||
"pt-pt": "Perfil de usuário WakaTime não público",
|
||||
"pt-br": "Perfil de usuário WakaTime não público",
|
||||
np: "WakaTime प्रयोगकर्ता प्रोफाइल सार्वजनिक छैन",
|
||||
el: "Το προφίλ χρήστη WakaTime δεν είναι δημόσιο",
|
||||
ru: "Профиль пользователя WakaTime не является общедоступным",
|
||||
"uk-ua": "Профіль користувача WakaTime не є публічним",
|
||||
id: "Profil pengguna WakaTime tidak publik",
|
||||
ml: "WakaTime ഉപയോക്തൃ പ്രൊഫൈൽ പൊതുവായി പ്രസിദ്ധീകരിക്കപ്പെടാത്തതാണ്",
|
||||
my: "Profil pengguna WakaTime tidak awam",
|
||||
sk: "Profil používateľa WakaTime nie je verejný",
|
||||
tr: "WakaTime kullanıcı profili herkese açık değil",
|
||||
pl: "Profil użytkownika WakaTime nie jest publiczny",
|
||||
uz: "WakaTime foydalanuvchi profili ochiq emas",
|
||||
vi: "Hồ sơ người dùng WakaTime không công khai",
|
||||
se: "WakaTime användarprofil inte offentlig",
|
||||
cn: "Wakatime 用户个人资料未公开",
|
||||
"zh-tw": "Wakatime 使用者個人資料未公開",
|
||||
cs: "Profil uživatele Wakatime není veřejný",
|
||||
de: "Wakatime-Benutzerprofil nicht öffentlich",
|
||||
en: "Wakatime user profile not public",
|
||||
bn: "Wakatime ব্যবহারকারীর প্রোফাইল প্রকাশ্য নয়",
|
||||
es: "Perfil de usuario de Wakatime no público",
|
||||
fr: "Profil utilisateur Wakatime non public",
|
||||
hu: "A Wakatime felhasználói profilja nem nyilvános",
|
||||
it: "Profilo utente Wakatime non pubblico",
|
||||
ja: "Wakatime ユーザープロファイルは公開されていません",
|
||||
kr: "Wakatime 사용자 프로필이 공개되지 않았습니다",
|
||||
nl: "Wakatime gebruikersprofiel niet openbaar",
|
||||
"pt-pt": "Perfil de usuário Wakatime não público",
|
||||
"pt-br": "Perfil de usuário Wakatime não público",
|
||||
np: "Wakatime प्रयोगकर्ता प्रोफाइल सार्वजनिक छैन",
|
||||
el: "Το προφίλ χρήστη Wakatime δεν είναι δημόσιο",
|
||||
ru: "Профиль пользователя Wakatime не является общедоступным",
|
||||
"uk-ua": "Профіль користувача Wakatime не є публічним",
|
||||
id: "Profil pengguna Wakatime tidak publik",
|
||||
ml: "Wakatime ഉപയോക്തൃ പ്രൊഫൈൽ പൊതുവായി പ്രസിദ്ധീകരിക്കപ്പെടാത്തതാണ്",
|
||||
my: "Profil pengguna Wakatime tidak awam",
|
||||
sk: "Profil používateľa Wakatime nie je verejný",
|
||||
tr: "Wakatime kullanıcı profili herkese açık değil",
|
||||
pl: "Profil użytkownika Wakatime nie jest publiczny",
|
||||
uz: "Wakatime foydalanuvchi profili ochiq emas",
|
||||
vi: "Hồ sơ người dùng Wakatime không công khai",
|
||||
se: "Wakatime användarprofil inte offentlig",
|
||||
},
|
||||
"wakatimecard.nocodedetails": {
|
||||
ar: "المستخدم لا يشارك معلومات تفصيلية عن البرمجة",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Test Render WakaTime Card should render correctly 1`] = `[Function]`;
|
||||
exports[`Test Render Wakatime Card should render correctly 1`] = `[Function]`;
|
||||
|
||||
exports[`Test Render WakaTime Card should render correctly with compact layout 1`] = `
|
||||
exports[`Test Render Wakatime Card should render correctly with compact layout 1`] = `
|
||||
"
|
||||
<svg
|
||||
width="495"
|
||||
@@ -38,8 +38,42 @@ exports[`Test Render WakaTime Card should render correctly with compact layout 1
|
||||
opacity: 0;
|
||||
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-text {
|
||||
font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58;
|
||||
animation: scaleInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-percentile-header {
|
||||
font-size: 14px;
|
||||
}
|
||||
.rank-percentile-text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.not_bold { font-weight: 400 }
|
||||
.bold { font-weight: 700 }
|
||||
.icon {
|
||||
fill: #4c71f2;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rank-circle-rim {
|
||||
stroke: undefined;
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
opacity: 0.2;
|
||||
}
|
||||
.rank-circle {
|
||||
stroke: undefined;
|
||||
stroke-dasharray: 250;
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
stroke-linecap: round;
|
||||
opacity: 0.8;
|
||||
transform-origin: -10px 8px;
|
||||
transform: rotate(-90deg);
|
||||
animation: rankAnimation 1s forwards ease-in-out;
|
||||
}
|
||||
|
||||
|
||||
@keyframes slideInAnimation {
|
||||
from {
|
||||
@@ -95,7 +129,7 @@ exports[`Test Render WakaTime Card should render correctly with compact layout 1
|
||||
y="0"
|
||||
class="header"
|
||||
data-testid="header"
|
||||
>WakaTime Stats (last 7 days)</text>
|
||||
>Wakatime Stats (last 7 days)</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
@@ -154,7 +188,7 @@ exports[`Test Render WakaTime Card should render correctly with compact layout 1
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`Test Render WakaTime Card should render correctly with compact layout when langs_count is set 1`] = `
|
||||
exports[`Test Render Wakatime Card should render correctly with compact layout when langs_count is set 1`] = `
|
||||
"
|
||||
<svg
|
||||
width="495"
|
||||
@@ -190,8 +224,42 @@ exports[`Test Render WakaTime Card should render correctly with compact layout w
|
||||
opacity: 0;
|
||||
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-text {
|
||||
font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58;
|
||||
animation: scaleInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-percentile-header {
|
||||
font-size: 14px;
|
||||
}
|
||||
.rank-percentile-text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.not_bold { font-weight: 400 }
|
||||
.bold { font-weight: 700 }
|
||||
.icon {
|
||||
fill: #4c71f2;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rank-circle-rim {
|
||||
stroke: undefined;
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
opacity: 0.2;
|
||||
}
|
||||
.rank-circle {
|
||||
stroke: undefined;
|
||||
stroke-dasharray: 250;
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
stroke-linecap: round;
|
||||
opacity: 0.8;
|
||||
transform-origin: -10px 8px;
|
||||
transform: rotate(-90deg);
|
||||
animation: rankAnimation 1s forwards ease-in-out;
|
||||
}
|
||||
|
||||
|
||||
@keyframes slideInAnimation {
|
||||
from {
|
||||
@@ -247,7 +315,7 @@ exports[`Test Render WakaTime Card should render correctly with compact layout w
|
||||
y="0"
|
||||
class="header"
|
||||
data-testid="header"
|
||||
>WakaTime Stats (last 7 days)</text>
|
||||
>Wakatime Stats (last 7 days)</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
|
||||
+7
-32
@@ -6,7 +6,6 @@ import { calculateRank } from "../src/calculateRank.js";
|
||||
import { renderStatsCard } from "../src/cards/stats-card.js";
|
||||
import { CONSTANTS, renderError } from "../src/common/utils.js";
|
||||
import { expect, it, describe, afterEach } from "@jest/globals";
|
||||
import { availableLocales } from "../src/translations.js";
|
||||
|
||||
const stats = {
|
||||
name: "Anurag Hazra",
|
||||
@@ -121,28 +120,13 @@ describe("Test /api/", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("should render error card in same theme as requested card", async () => {
|
||||
const { req, res } = faker({ theme: "merko" }, error);
|
||||
|
||||
await api(req, res);
|
||||
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.send).toBeCalledWith(
|
||||
renderError(
|
||||
error.errors[0].message,
|
||||
"Make sure the provided username is not an organization",
|
||||
{ theme: "merko" },
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it("should get the query options", async () => {
|
||||
const { req, res } = faker(
|
||||
{
|
||||
username: "anuraghazra",
|
||||
hide: "issues,prs,contribs",
|
||||
show_icons: "true",
|
||||
hide_border: "true",
|
||||
show_icons: true,
|
||||
hide_border: true,
|
||||
line_height: 100,
|
||||
title_color: "fff",
|
||||
icon_color: "fff",
|
||||
@@ -271,8 +255,8 @@ describe("Test /api/", () => {
|
||||
{
|
||||
username: "anuraghazra",
|
||||
hide: "issues,prs,contribs",
|
||||
show_icons: "true",
|
||||
hide_border: "true",
|
||||
show_icons: true,
|
||||
hide_border: true,
|
||||
line_height: 100,
|
||||
title_color: "fff",
|
||||
ring_color: "0000ff",
|
||||
@@ -307,9 +291,7 @@ describe("Test /api/", () => {
|
||||
await api(req, res);
|
||||
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.send).toBeCalledWith(
|
||||
renderError("Something went wrong", "This username is blacklisted"),
|
||||
);
|
||||
expect(res.send).toBeCalledWith(renderError("Something went wrong"));
|
||||
});
|
||||
|
||||
it("should render error card when wrong locale is provided", async () => {
|
||||
@@ -319,10 +301,7 @@ describe("Test /api/", () => {
|
||||
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.send).toBeCalledWith(
|
||||
renderError(
|
||||
"Invalid query string param `locale` value: asdf",
|
||||
`Expected: ${availableLocales.join(", ")}`,
|
||||
),
|
||||
renderError("Something went wrong", "Language not found"),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -332,7 +311,7 @@ describe("Test /api/", () => {
|
||||
.reply(200, { error: "Some test error message" });
|
||||
|
||||
const { req, res } = faker(
|
||||
{ username: "anuraghazra", include_all_commits: "true" },
|
||||
{ username: "anuraghazra", include_all_commits: true },
|
||||
data_stats,
|
||||
);
|
||||
|
||||
@@ -342,9 +321,5 @@ describe("Test /api/", () => {
|
||||
expect(res.send).toBeCalledWith(
|
||||
renderError("Could not fetch total commits.", "Please try again later"),
|
||||
);
|
||||
// Received SVG output should not contain string "https://tiny.one/readme-stats"
|
||||
expect(res.send.mock.calls[0][0]).not.toContain(
|
||||
"https://tiny.one/readme-stats",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
import { benchmarkSuite } from "jest-bench";
|
||||
import api from "../../api/index.js";
|
||||
import axios from "axios";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import { jest } from "@jest/globals";
|
||||
|
||||
const stats = {
|
||||
name: "Anurag Hazra",
|
||||
totalStars: 100,
|
||||
totalCommits: 200,
|
||||
totalIssues: 300,
|
||||
totalPRs: 400,
|
||||
totalPRsMerged: 320,
|
||||
mergedPRsPercentage: 80,
|
||||
totalReviews: 50,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
contributedTo: 50,
|
||||
rank: null,
|
||||
};
|
||||
|
||||
const data_stats = {
|
||||
data: {
|
||||
user: {
|
||||
name: stats.name,
|
||||
repositoriesContributedTo: { totalCount: stats.contributedTo },
|
||||
contributionsCollection: {
|
||||
totalCommitContributions: stats.totalCommits,
|
||||
totalPullRequestReviewContributions: stats.totalReviews,
|
||||
},
|
||||
pullRequests: { totalCount: stats.totalPRs },
|
||||
mergedPullRequests: { totalCount: stats.totalPRsMerged },
|
||||
openIssues: { totalCount: stats.totalIssues },
|
||||
closedIssues: { totalCount: 0 },
|
||||
followers: { totalCount: 0 },
|
||||
repositoryDiscussions: { totalCount: stats.totalDiscussionsStarted },
|
||||
repositoryDiscussionComments: {
|
||||
totalCount: stats.totalDiscussionsAnswered,
|
||||
},
|
||||
repositories: {
|
||||
totalCount: 1,
|
||||
nodes: [{ stargazers: { totalCount: 100 } }],
|
||||
pageInfo: {
|
||||
hasNextPage: false,
|
||||
endCursor: "cursor",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const mock = new MockAdapter(axios);
|
||||
|
||||
const faker = (query, data) => {
|
||||
const req = {
|
||||
query: {
|
||||
username: "anuraghazra",
|
||||
...query,
|
||||
},
|
||||
};
|
||||
const res = {
|
||||
setHeader: jest.fn(),
|
||||
send: jest.fn(),
|
||||
};
|
||||
mock.onPost("https://api.github.com/graphql").replyOnce(200, data);
|
||||
|
||||
return { req, res };
|
||||
};
|
||||
|
||||
benchmarkSuite("test /api", {
|
||||
["simple request"]: async () => {
|
||||
const { req, res } = faker({}, data_stats);
|
||||
|
||||
await api(req, res);
|
||||
},
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
import { benchmarkSuite } from "jest-bench";
|
||||
import { calculateRank } from "../../src/calculateRank.js";
|
||||
|
||||
benchmarkSuite("calculateRank", {
|
||||
["calculateRank"]: () => {
|
||||
calculateRank({
|
||||
all_commits: false,
|
||||
commits: 1300,
|
||||
prs: 1500,
|
||||
issues: 4500,
|
||||
reviews: 1000,
|
||||
repos: 0,
|
||||
stars: 600000,
|
||||
followers: 50000,
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
import { benchmarkSuite } from "jest-bench";
|
||||
import gist from "../../api/gist.js";
|
||||
import axios from "axios";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import { jest } from "@jest/globals";
|
||||
|
||||
const gist_data = {
|
||||
data: {
|
||||
viewer: {
|
||||
gist: {
|
||||
description:
|
||||
"List of countries and territories in English and Spanish: name, continent, capital, dial code, country codes, TLD, and area in sq km. Lista de países y territorios en Inglés y Español: nombre, continente, capital, código de teléfono, códigos de país, dominio y área en km cuadrados. Updated 2023",
|
||||
owner: {
|
||||
login: "Yizack",
|
||||
},
|
||||
stargazerCount: 33,
|
||||
forks: {
|
||||
totalCount: 11,
|
||||
},
|
||||
files: [
|
||||
{
|
||||
name: "countries.json",
|
||||
language: {
|
||||
name: "JSON",
|
||||
},
|
||||
size: 85858,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const mock = new MockAdapter(axios);
|
||||
mock.onPost("https://api.github.com/graphql").reply(200, gist_data);
|
||||
|
||||
benchmarkSuite("test /api/gist", {
|
||||
["simple request"]: async () => {
|
||||
const req = {
|
||||
query: {
|
||||
id: "bbfce31e0217a3689c8d961a356cb10d",
|
||||
},
|
||||
};
|
||||
const res = {
|
||||
setHeader: jest.fn(),
|
||||
send: jest.fn(),
|
||||
};
|
||||
|
||||
await gist(req, res);
|
||||
},
|
||||
});
|
||||
@@ -1,50 +0,0 @@
|
||||
import { benchmarkSuite } from "jest-bench";
|
||||
import pin from "../../api/pin.js";
|
||||
import axios from "axios";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import { jest } from "@jest/globals";
|
||||
|
||||
const data_repo = {
|
||||
repository: {
|
||||
username: "anuraghazra",
|
||||
name: "convoychat",
|
||||
stargazers: {
|
||||
totalCount: 38000,
|
||||
},
|
||||
description: "Help us take over the world! React + TS + GraphQL Chat App",
|
||||
primaryLanguage: {
|
||||
color: "#2b7489",
|
||||
id: "MDg6TGFuZ3VhZ2UyODc=",
|
||||
name: "TypeScript",
|
||||
},
|
||||
forkCount: 100,
|
||||
isTemplate: false,
|
||||
},
|
||||
};
|
||||
|
||||
const data_user = {
|
||||
data: {
|
||||
user: { repository: data_repo.repository },
|
||||
organization: null,
|
||||
},
|
||||
};
|
||||
|
||||
const mock = new MockAdapter(axios);
|
||||
mock.onPost("https://api.github.com/graphql").reply(200, data_user);
|
||||
|
||||
benchmarkSuite("test /api/pin", {
|
||||
["simple request"]: async () => {
|
||||
const req = {
|
||||
query: {
|
||||
username: "anuraghazra",
|
||||
repo: "convoychat",
|
||||
},
|
||||
};
|
||||
const res = {
|
||||
setHeader: jest.fn(),
|
||||
send: jest.fn(),
|
||||
};
|
||||
|
||||
await pin(req, res);
|
||||
},
|
||||
});
|
||||
+1
-1
@@ -89,7 +89,7 @@ describe("Card", () => {
|
||||
"200",
|
||||
);
|
||||
expect(document.getElementsByTagName("svg")[0]).toHaveAttribute(
|
||||
"width",
|
||||
"height",
|
||||
"200",
|
||||
);
|
||||
});
|
||||
|
||||
+24
-82
@@ -122,12 +122,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -158,12 +158,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -200,12 +200,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 1000,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -249,12 +249,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 1000,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalReviews: 50,
|
||||
totalStars: 200,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -280,12 +280,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalReviews: 50,
|
||||
totalStars: 400,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -311,12 +311,12 @@ describe("Test fetchStats", () => {
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalPRsMerged: 240,
|
||||
mergedPRsPercentage: 80,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
totalDiscussionsStarted: 10,
|
||||
totalDiscussionsAnswered: 40,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
@@ -336,64 +336,6 @@ describe("Test fetchStats", () => {
|
||||
followers: 100,
|
||||
});
|
||||
|
||||
expect(stats).toStrictEqual({
|
||||
contributedTo: 61,
|
||||
name: "Anurag Hazra",
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
|
||||
it("should not fetch additional stats data when it not requested", async () => {
|
||||
let stats = await fetchStats("anuraghazra");
|
||||
const rank = calculateRank({
|
||||
all_commits: false,
|
||||
commits: 100,
|
||||
prs: 300,
|
||||
reviews: 50,
|
||||
issues: 200,
|
||||
repos: 5,
|
||||
stars: 300,
|
||||
followers: 100,
|
||||
});
|
||||
|
||||
expect(stats).toStrictEqual({
|
||||
contributedTo: 61,
|
||||
name: "Anurag Hazra",
|
||||
totalCommits: 100,
|
||||
totalIssues: 200,
|
||||
totalPRs: 300,
|
||||
totalPRsMerged: 0,
|
||||
mergedPRsPercentage: 0,
|
||||
totalReviews: 50,
|
||||
totalStars: 300,
|
||||
totalDiscussionsStarted: 0,
|
||||
totalDiscussionsAnswered: 0,
|
||||
rank,
|
||||
});
|
||||
});
|
||||
|
||||
it("should fetch additional stats when it requested", async () => {
|
||||
let stats = await fetchStats("anuraghazra", false, [], true, true, true);
|
||||
const rank = calculateRank({
|
||||
all_commits: false,
|
||||
commits: 100,
|
||||
prs: 300,
|
||||
reviews: 50,
|
||||
issues: 200,
|
||||
repos: 5,
|
||||
stars: 300,
|
||||
followers: 100,
|
||||
});
|
||||
|
||||
expect(stats).toStrictEqual({
|
||||
contributedTo: 61,
|
||||
name: "Anurag Hazra",
|
||||
|
||||
@@ -165,7 +165,7 @@ describe("FetchTopLanguages", () => {
|
||||
});
|
||||
|
||||
await expect(fetchTopLanguages("anuraghazra")).rejects.toThrow(
|
||||
"Something went wrong while trying to retrieve the language data using the GraphQL API.",
|
||||
"Something went while trying to retrieve the language data using the GraphQL API.",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -102,8 +102,8 @@ const wakaTimeData = {
|
||||
},
|
||||
};
|
||||
|
||||
describe("WakaTime fetcher", () => {
|
||||
it("should fetch correct WakaTime data", async () => {
|
||||
describe("Wakatime fetcher", () => {
|
||||
it("should fetch correct wakatime data", async () => {
|
||||
const username = "anuraghazra";
|
||||
mock
|
||||
.onGet(
|
||||
|
||||
+1
-3
@@ -155,9 +155,7 @@ describe("Test /api/pin", () => {
|
||||
await pin(req, res);
|
||||
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.send).toBeCalledWith(
|
||||
renderError("Something went wrong", "This username is blacklisted"),
|
||||
);
|
||||
expect(res.send).toBeCalledWith(renderError("Something went wrong"));
|
||||
});
|
||||
|
||||
it("should render error card if wrong locale provided", async () => {
|
||||
|
||||
@@ -135,10 +135,9 @@ describe("test renderGistCard", () => {
|
||||
);
|
||||
expect(descClassStyles.fill.trim()).toBe(`#${themes[name].text_color}`);
|
||||
expect(iconClassStyles.fill.trim()).toBe(`#${themes[name].icon_color}`);
|
||||
const backgroundElement = queryByTestId(document.body, "card-bg");
|
||||
const backgroundElementFill = backgroundElement.getAttribute("fill");
|
||||
expect([`#${themes[name].bg_color}`, "url(#gradient)"]).toContain(
|
||||
backgroundElementFill,
|
||||
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
|
||||
"fill",
|
||||
`#${themes[name].bg_color}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -190,10 +190,9 @@ describe("Test renderRepoCard", () => {
|
||||
);
|
||||
expect(descClassStyles.fill.trim()).toBe(`#${themes[name].text_color}`);
|
||||
expect(iconClassStyles.fill.trim()).toBe(`#${themes[name].icon_color}`);
|
||||
const backgroundElement = queryByTestId(document.body, "card-bg");
|
||||
const backgroundElementFill = backgroundElement.getAttribute("fill");
|
||||
expect([`#${themes[name].bg_color}`, "url(#gradient)"]).toContain(
|
||||
backgroundElementFill,
|
||||
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
|
||||
"fill",
|
||||
`#${themes[name].bg_color}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -339,34 +338,4 @@ describe("Test renderRepoCard", () => {
|
||||
"No description provided",
|
||||
);
|
||||
});
|
||||
|
||||
it("should have correct height with specified `description_lines_count` parameter", () => {
|
||||
// Testing short description
|
||||
document.body.innerHTML = renderRepoCard(data_repo.repository, {
|
||||
description_lines_count: 1,
|
||||
});
|
||||
expect(document.querySelector("svg")).toHaveAttribute("height", "120");
|
||||
document.body.innerHTML = renderRepoCard(data_repo.repository, {
|
||||
description_lines_count: 3,
|
||||
});
|
||||
expect(document.querySelector("svg")).toHaveAttribute("height", "150");
|
||||
|
||||
// Testing long description
|
||||
const longDescription =
|
||||
"A tool that will make a lot of iPhone/iPad developers' life easier. It shares your app over-the-air in a WiFi network. Bonjour is used and no configuration is needed.";
|
||||
document.body.innerHTML = renderRepoCard(
|
||||
{ ...data_repo.repository, description: longDescription },
|
||||
{
|
||||
description_lines_count: 3,
|
||||
},
|
||||
);
|
||||
expect(document.querySelector("svg")).toHaveAttribute("height", "150");
|
||||
document.body.innerHTML = renderRepoCard(
|
||||
{ ...data_repo.repository, description: longDescription },
|
||||
{
|
||||
description_lines_count: 1,
|
||||
},
|
||||
);
|
||||
expect(document.querySelector("svg")).toHaveAttribute("height", "120");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -264,10 +264,9 @@ describe("Test renderStatsCard", () => {
|
||||
);
|
||||
expect(statClassStyles.fill.trim()).toBe(`#${themes[name].text_color}`);
|
||||
expect(iconClassStyles.fill.trim()).toBe(`#${themes[name].icon_color}`);
|
||||
const backgroundElement = queryByTestId(document.body, "card-bg");
|
||||
const backgroundElementFill = backgroundElement.getAttribute("fill");
|
||||
expect([`#${themes[name].bg_color}`, "url(#gradient)"]).toContain(
|
||||
backgroundElementFill,
|
||||
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
|
||||
"fill",
|
||||
`#${themes[name].bg_color}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -524,10 +524,9 @@ describe("Test renderTopLanguages", () => {
|
||||
|
||||
expect(headerStyles.fill.trim()).toBe(`#${themes[name].title_color}`);
|
||||
expect(langNameStyles.fill.trim()).toBe(`#${themes[name].text_color}`);
|
||||
const backgroundElement = queryByTestId(document.body, "card-bg");
|
||||
const backgroundElementFill = backgroundElement.getAttribute("fill");
|
||||
expect([`#${themes[name].bg_color}`, "url(#gradient)"]).toContain(
|
||||
backgroundElementFill,
|
||||
expect(queryByTestId(document.body, "card-bg")).toHaveAttribute(
|
||||
"fill",
|
||||
`#${themes[name].bg_color}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ import { getCardColors } from "../src/common/utils.js";
|
||||
import { wakaTimeData } from "./fetchWakatime.test.js";
|
||||
import { expect, it, describe } from "@jest/globals";
|
||||
|
||||
describe("Test Render WakaTime Card", () => {
|
||||
describe("Test Render Wakatime Card", () => {
|
||||
it("should render correctly", () => {
|
||||
// const card = renderWakatimeCard(wakaTimeData.data);
|
||||
expect(getCardColors).toMatchSnapshot();
|
||||
@@ -39,12 +39,12 @@ describe("Test Render WakaTime Card", () => {
|
||||
it("should render translations", () => {
|
||||
document.body.innerHTML = renderWakatimeCard({}, { locale: "cn" });
|
||||
expect(document.getElementsByClassName("header")[0].textContent).toBe(
|
||||
"WakaTime 周统计",
|
||||
"Wakatime 周统计",
|
||||
);
|
||||
expect(
|
||||
document.querySelector('g[transform="translate(0, 0)"]>text.stat.bold')
|
||||
.textContent,
|
||||
).toBe("WakaTime 用户个人资料未公开");
|
||||
).toBe("Wakatime 用户个人资料未公开");
|
||||
});
|
||||
|
||||
it("should render without rounding", () => {
|
||||
|
||||
@@ -183,9 +183,7 @@ describe("Test /api/top-langs", () => {
|
||||
await topLangs(req, res);
|
||||
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.send).toBeCalledWith(
|
||||
renderError("Something went wrong", "This username is blacklisted"),
|
||||
);
|
||||
expect(res.send).toBeCalledWith(renderError("Something went wrong"));
|
||||
});
|
||||
|
||||
it("should render error card if wrong locale provided", async () => {
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { expect, it, describe } from "@jest/globals";
|
||||
import {
|
||||
validateQueryStringParam,
|
||||
validateQueryStringParams,
|
||||
InvalidQueryStringParamsError,
|
||||
} from "../src/common/validate";
|
||||
import { themes } from "../themes/index.js";
|
||||
|
||||
/**
|
||||
* @typedef {import("../src/common/validate").DataTypes} DataTypes The data types.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {Map<string, DataTypes>} The query string params data type map.
|
||||
*/
|
||||
const QUERYSTRING_PARAMS_DATA_TYPE_MAP = new Map([
|
||||
["username", "string"],
|
||||
["hide", "enum-array"],
|
||||
["hide_title", "boolean"],
|
||||
["hide_border", "boolean"],
|
||||
["card_width", "number"],
|
||||
["hide_rank", "boolean"],
|
||||
["show_icons", "boolean"],
|
||||
["include_all_commits", "boolean"],
|
||||
["line_height", "number"],
|
||||
["title_color", "string"],
|
||||
["ring_color", "string"],
|
||||
["icon_color", "string"],
|
||||
["text_color", "string"],
|
||||
["text_bold", "boolean"],
|
||||
["bg_color", "string"],
|
||||
["theme", "enum"],
|
||||
["cache_seconds", "number"],
|
||||
["exclude_repo", "array"],
|
||||
["custom_title", "string"],
|
||||
["locale", "enum"],
|
||||
["disable_animations", "boolean"],
|
||||
["border_radius", "number"],
|
||||
["border_color", "string"],
|
||||
["number_format", "enum"],
|
||||
["rank_icon", "enum"],
|
||||
["show", "enum-array"],
|
||||
]);
|
||||
|
||||
describe("test query string param validation", () => {
|
||||
// Tests for `validateQueryStringParam` function.
|
||||
it("should validate a string", () => {
|
||||
expect(validateQueryStringParam("string", "username", "anuraghazra")).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
it("should validate a boolean", () => {
|
||||
expect(validateQueryStringParam("boolean", "hide_title", "true")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(validateQueryStringParam("boolean", "hide_title", "false")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(validateQueryStringParam("boolean", "hide_title", "invalid")).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
it("should validate a number", () => {
|
||||
expect(validateQueryStringParam("number", "card_width", "300")).toBe(true);
|
||||
expect(validateQueryStringParam("number", "card_width", "300.000")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(validateQueryStringParam("number", "card_width", "invalid")).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
it("should validate an enum", () => {
|
||||
expect(validateQueryStringParam("enum", "theme", "dark")).toBe(true);
|
||||
expect(validateQueryStringParam("enum", "theme", "merko")).toBe(true);
|
||||
expect(validateQueryStringParam("enum", "theme", "invalid")).toBe(false);
|
||||
|
||||
expect(validateQueryStringParam("enum", "locale", "en")).toBe(true);
|
||||
expect(validateQueryStringParam("enum", "locale", "invalid")).toBe(false);
|
||||
|
||||
expect(validateQueryStringParam("enum", "number_format", "short")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(validateQueryStringParam("enum", "number_format", "invalid")).toBe(
|
||||
false,
|
||||
);
|
||||
|
||||
expect(validateQueryStringParam("enum", "rank_icon", "github")).toBe(true);
|
||||
expect(validateQueryStringParam("enum", "rank_icon", "invalid")).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
it("should validate an enum-array", () => {
|
||||
expect(
|
||||
validateQueryStringParam("enum-array", "hide", "stars,commits,prs"),
|
||||
).toBe(true);
|
||||
expect(
|
||||
validateQueryStringParam(
|
||||
"enum-array",
|
||||
"show",
|
||||
"reviews,discussions_started",
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
validateQueryStringParam(
|
||||
"enum-array",
|
||||
"hide",
|
||||
"stars,commits,prs,invalid",
|
||||
),
|
||||
).toBe(false);
|
||||
expect(validateQueryStringParam("enum-array", "hide", "invalid")).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
it("should validate an array", () => {
|
||||
expect(
|
||||
validateQueryStringParam("array", "exclude_repo", "repo1,repo2"),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
// Tests for `validateQueryStringParams` function.
|
||||
it("should validate query string params", () => {
|
||||
expect(
|
||||
validateQueryStringParams(
|
||||
{
|
||||
username: "anuraghazra",
|
||||
hide: "stars,commits,prs",
|
||||
hide_title: "true",
|
||||
hide_border: "true",
|
||||
card_width: "300",
|
||||
hide_rank: "true",
|
||||
show_icons: "true",
|
||||
include_all_commits: "true",
|
||||
line_height: "25",
|
||||
title_color: "fff",
|
||||
ring_color: "fff",
|
||||
icon_color: "fff",
|
||||
text_color: "fff",
|
||||
text_bold: "true",
|
||||
bg_color: "fff",
|
||||
theme: "dark",
|
||||
cache_seconds: "300",
|
||||
exclude_repo: "repo1,repo2",
|
||||
custom_title: "My Custom Title",
|
||||
locale: "en",
|
||||
disable_animations: "true",
|
||||
border_radius: "0",
|
||||
number_format: "long",
|
||||
border_color: "fff",
|
||||
rank_icon: "github",
|
||||
show: "reviews,discussions_started",
|
||||
},
|
||||
QUERYSTRING_PARAMS_DATA_TYPE_MAP,
|
||||
),
|
||||
// This function returns void on successful run and throws an error on invalid query string params.
|
||||
).toBe(undefined);
|
||||
});
|
||||
it("should validate query string params with extra params", () => {
|
||||
expect(
|
||||
validateQueryStringParams(
|
||||
{
|
||||
username: "anuraghazra",
|
||||
hide: "stars,commits,prs",
|
||||
hide_title: "true",
|
||||
hide_border: "true",
|
||||
card_width: "300",
|
||||
hide_rank: "true",
|
||||
show_icons: "true",
|
||||
include_all_commits: "true",
|
||||
line_height: "25",
|
||||
title_color: "fff",
|
||||
ring_color: "fff",
|
||||
icon_color: "fff",
|
||||
text_color: "fff",
|
||||
text_bold: "true",
|
||||
bg_color: "fff",
|
||||
theme: "dark",
|
||||
cache_seconds: "300",
|
||||
exclude_repo: "repo1,repo2",
|
||||
custom_title: "My Custom Title",
|
||||
locale: "en",
|
||||
disable_animations: "true",
|
||||
border_radius: "0",
|
||||
number_format: "long",
|
||||
border_color: "fff",
|
||||
rank_icon: "github",
|
||||
show: "reviews,discussions_started",
|
||||
invalid: "invalid",
|
||||
},
|
||||
QUERYSTRING_PARAMS_DATA_TYPE_MAP,
|
||||
),
|
||||
// This function returns void on successful run and throws an error on invalid query string params.
|
||||
).toBe(undefined);
|
||||
});
|
||||
it("should throw correct error on invalid boolean param", () => {
|
||||
expect(() =>
|
||||
validateQueryStringParams(
|
||||
{
|
||||
hide_title: "invalid",
|
||||
},
|
||||
QUERYSTRING_PARAMS_DATA_TYPE_MAP,
|
||||
),
|
||||
).toThrow(
|
||||
new InvalidQueryStringParamsError(
|
||||
"Invalid query string param `hide_title` value: invalid",
|
||||
"Expected: true or false",
|
||||
),
|
||||
);
|
||||
});
|
||||
it("should throw correct error on invalid number param", () => {
|
||||
expect(() =>
|
||||
validateQueryStringParams(
|
||||
{
|
||||
card_width: "invalid",
|
||||
},
|
||||
QUERYSTRING_PARAMS_DATA_TYPE_MAP,
|
||||
),
|
||||
).toThrow(
|
||||
new InvalidQueryStringParamsError(
|
||||
"Invalid query string param `card_width` value: invalid",
|
||||
"Expected: a number",
|
||||
),
|
||||
);
|
||||
});
|
||||
it("should throw correct error on invalid enum param", () => {
|
||||
expect(() =>
|
||||
validateQueryStringParams(
|
||||
{
|
||||
theme: "invalid",
|
||||
},
|
||||
QUERYSTRING_PARAMS_DATA_TYPE_MAP,
|
||||
),
|
||||
).toThrow(
|
||||
new InvalidQueryStringParamsError(
|
||||
"Invalid query string param `theme` value: invalid",
|
||||
`Expected: ${Object.keys(themes).join(", ")}`,
|
||||
),
|
||||
);
|
||||
});
|
||||
it("should throw correct error on invalid enum-array param", () => {
|
||||
expect(() =>
|
||||
validateQueryStringParams(
|
||||
{
|
||||
hide: "commits,prs,invalid",
|
||||
},
|
||||
QUERYSTRING_PARAMS_DATA_TYPE_MAP,
|
||||
),
|
||||
).toThrow(
|
||||
new InvalidQueryStringParamsError(
|
||||
"Invalid query string param `hide` value: commits,prs,invalid",
|
||||
"Expected: stars, commits, prs, issues, contribs",
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,123 +0,0 @@
|
||||
import { jest } from "@jest/globals";
|
||||
import "@testing-library/jest-dom";
|
||||
import axios from "axios";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import wakatime from "../api/wakatime.js";
|
||||
import { renderWakatimeCard } from "../src/cards/wakatime-card.js";
|
||||
import { expect, it, describe, afterEach } from "@jest/globals";
|
||||
|
||||
const wakaTimeData = {
|
||||
data: {
|
||||
categories: [
|
||||
{
|
||||
digital: "22:40",
|
||||
hours: 22,
|
||||
minutes: 40,
|
||||
name: "Coding",
|
||||
percent: 100,
|
||||
text: "22 hrs 40 mins",
|
||||
total_seconds: 81643.570077,
|
||||
},
|
||||
],
|
||||
daily_average: 16095,
|
||||
daily_average_including_other_language: 16329,
|
||||
days_including_holidays: 7,
|
||||
days_minus_holidays: 5,
|
||||
editors: [
|
||||
{
|
||||
digital: "22:40",
|
||||
hours: 22,
|
||||
minutes: 40,
|
||||
name: "VS Code",
|
||||
percent: 100,
|
||||
text: "22 hrs 40 mins",
|
||||
total_seconds: 81643.570077,
|
||||
},
|
||||
],
|
||||
holidays: 2,
|
||||
human_readable_daily_average: "4 hrs 28 mins",
|
||||
human_readable_daily_average_including_other_language: "4 hrs 32 mins",
|
||||
human_readable_total: "22 hrs 21 mins",
|
||||
human_readable_total_including_other_language: "22 hrs 40 mins",
|
||||
id: "random hash",
|
||||
is_already_updating: false,
|
||||
is_coding_activity_visible: true,
|
||||
is_including_today: false,
|
||||
is_other_usage_visible: true,
|
||||
is_stuck: false,
|
||||
is_up_to_date: true,
|
||||
languages: [
|
||||
{
|
||||
digital: "0:19",
|
||||
hours: 0,
|
||||
minutes: 19,
|
||||
name: "Other",
|
||||
percent: 1.43,
|
||||
text: "19 mins",
|
||||
total_seconds: 1170.434361,
|
||||
},
|
||||
{
|
||||
digital: "0:01",
|
||||
hours: 0,
|
||||
minutes: 1,
|
||||
name: "TypeScript",
|
||||
percent: 0.1,
|
||||
text: "1 min",
|
||||
total_seconds: 83.293809,
|
||||
},
|
||||
{
|
||||
digital: "0:00",
|
||||
hours: 0,
|
||||
minutes: 0,
|
||||
name: "YAML",
|
||||
percent: 0.07,
|
||||
text: "0 secs",
|
||||
total_seconds: 54.975151,
|
||||
},
|
||||
],
|
||||
operating_systems: [
|
||||
{
|
||||
digital: "22:40",
|
||||
hours: 22,
|
||||
minutes: 40,
|
||||
name: "Mac",
|
||||
percent: 100,
|
||||
text: "22 hrs 40 mins",
|
||||
total_seconds: 81643.570077,
|
||||
},
|
||||
],
|
||||
percent_calculated: 100,
|
||||
range: "last_7_days",
|
||||
status: "ok",
|
||||
timeout: 15,
|
||||
total_seconds: 80473.135716,
|
||||
total_seconds_including_other_language: 81643.570077,
|
||||
user_id: "random hash",
|
||||
username: "anuraghazra",
|
||||
writes_only: false,
|
||||
},
|
||||
};
|
||||
|
||||
const mock = new MockAdapter(axios);
|
||||
|
||||
afterEach(() => {
|
||||
mock.reset();
|
||||
});
|
||||
|
||||
describe("Test /api/wakatime", () => {
|
||||
it("should test the request", async () => {
|
||||
const username = "anuraghazra";
|
||||
const req = { query: { username } };
|
||||
const res = { setHeader: jest.fn(), send: jest.fn() };
|
||||
mock
|
||||
.onGet(
|
||||
`https://wakatime.com/api/v1/users/${username}/stats?is_including_today=true`,
|
||||
)
|
||||
.reply(200, wakaTimeData);
|
||||
|
||||
await wakatime(req, res);
|
||||
|
||||
expect(res.setHeader).toBeCalledWith("Content-Type", "image/svg+xml");
|
||||
expect(res.send).toBeCalledWith(renderWakatimeCard(wakaTimeData.data, {}));
|
||||
});
|
||||
});
|
||||
+9
-17
@@ -4,7 +4,7 @@
|
||||
|
||||
With inbuilt themes, you can customize the look of the card without doing any manual customization.
|
||||
|
||||
Use `?theme=THEME_NAME` parameter like so:
|
||||
Use `?theme=THEME_NAME` parameter like so :-
|
||||
|
||||
```md
|
||||

|
||||
@@ -12,7 +12,7 @@ Use `?theme=THEME_NAME` parameter like so:
|
||||
|
||||
## Stats
|
||||
|
||||
> These themes works with all five our cards: Stats Card, Repo Card, Gist Card, Top languages Card and WakaTime Card.
|
||||
> These themes work both for the Stats Card and Repo Card.
|
||||
|
||||
| | | |
|
||||
| :--: | :--: | :--: |
|
||||
@@ -37,14 +37,13 @@ Use `?theme=THEME_NAME` parameter like so:
|
||||
| `aura_dark` ![aura_dark][aura_dark] | `panda` ![panda][panda] | `noctis_minimus` ![noctis_minimus][noctis_minimus] |
|
||||
| `cobalt2` ![cobalt2][cobalt2] | `swift` ![swift][swift] | `aura` ![aura][aura] |
|
||||
| `apprentice` ![apprentice][apprentice] | `moltack` ![moltack][moltack] | `codeSTACKr` ![codeSTACKr][codeSTACKr] |
|
||||
| `rose_pine` ![rose_pine][rose_pine] | `catppuccin_latte` ![catppuccin_latte][catppuccin_latte] | `catppuccin_mocha` ![catppuccin_mocha][catppuccin_mocha] |
|
||||
| `date_night` ![date_night][date_night] | `one_dark_pro` ![one_dark_pro][one_dark_pro] | `rose` ![rose][rose] |
|
||||
| `holi` ![holi][holi] | `neon` ![neon][neon] | `blue_navy` ![blue_navy][blue_navy] |
|
||||
| `calm_pink` ![calm_pink][calm_pink] | `ambient_gradient` ![ambient_gradient][ambient_gradient] | [Add your theme][add-theme] |
|
||||
| `rose_pine` ![rose_pine][rose_pine] | `date_night` ![date_night][date_night] | `one_dark_pro` ![one_dark_pro][one_dark_pro] |
|
||||
| `rose` ![rose][rose] | `holi` ![holi][holi] | `neon` ![neon][neon] |
|
||||
| `blue_navy` ![blue_navy][blue_navy] | `calm_pink` ![calm_pink][calm_pink] | [Add your theme][add-theme] |
|
||||
|
||||
## Repo Card
|
||||
|
||||
> These themes works with all five our cards: Stats Card, Repo Card, Gist Card, Top languages Card and WakaTime Card.
|
||||
> These themes work both for the Stats Card and Repo Card.
|
||||
|
||||
| | | |
|
||||
| :--: | :--: | :--: |
|
||||
@@ -69,10 +68,9 @@ Use `?theme=THEME_NAME` parameter like so:
|
||||
| `aura_dark` ![aura_dark][aura_dark_repo] | `panda` ![panda][panda_repo] | `noctis_minimus` ![noctis_minimus][noctis_minimus_repo] |
|
||||
| `cobalt2` ![cobalt2][cobalt2_repo] | `swift` ![swift][swift_repo] | `aura` ![aura][aura_repo] |
|
||||
| `apprentice` ![apprentice][apprentice_repo] | `moltack` ![moltack][moltack_repo] | `codeSTACKr` ![codeSTACKr][codeSTACKr_repo] |
|
||||
| `rose_pine` ![rose_pine][rose_pine_repo] | `catppuccin_latte` ![catppuccin_latte][catppuccin_latte_repo] | `catppuccin_mocha` ![catppuccin_mocha][catppuccin_mocha_repo] |
|
||||
| `date_night` ![date_night][date_night_repo] | `one_dark_pro` ![one_dark_pro][one_dark_pro_repo] | `rose` ![rose][rose_repo] |
|
||||
| `holi` ![holi][holi_repo] | `neon` ![neon][neon_repo] | `blue_navy` ![blue_navy][blue_navy_repo] |
|
||||
| `calm_pink` ![calm_pink][calm_pink_repo] | `ambient_gradient` ![ambient_gradient][ambient_gradient_repo] | [Add your theme][add-theme] |
|
||||
| `rose_pine` ![rose_pine][rose_pine_repo] | `date_night` ![date_night][date_night_repo] | `one_dark_pro` ![one_dark_pro][one_dark_pro_repo] |
|
||||
| `rose` ![rose][rose_repo] | `holi` ![holi][holi_repo] | `neon` ![neon][neon_repo] |
|
||||
| `blue_navy` ![blue_navy][blue_navy_repo] | `calm_pink` ![calm_pink][calm_pink_repo] | [Add your theme][add-theme] |
|
||||
|
||||
|
||||
[default]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=default
|
||||
@@ -140,8 +138,6 @@ Use `?theme=THEME_NAME` parameter like so:
|
||||
[moltack]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=moltack
|
||||
[codeSTACKr]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=codeSTACKr
|
||||
[rose_pine]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=rose_pine
|
||||
[catppuccin_latte]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=catppuccin_latte
|
||||
[catppuccin_mocha]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=catppuccin_mocha
|
||||
[date_night]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=date_night
|
||||
[one_dark_pro]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=one_dark_pro
|
||||
[rose]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=rose
|
||||
@@ -149,7 +145,6 @@ Use `?theme=THEME_NAME` parameter like so:
|
||||
[neon]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=neon
|
||||
[blue_navy]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=blue_navy
|
||||
[calm_pink]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=calm_pink
|
||||
[ambient_gradient]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=ambient_gradient
|
||||
|
||||
|
||||
[default_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=default
|
||||
@@ -217,8 +212,6 @@ Use `?theme=THEME_NAME` parameter like so:
|
||||
[moltack_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=moltack
|
||||
[codeSTACKr_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=codeSTACKr
|
||||
[rose_pine_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=rose_pine
|
||||
[catppuccin_latte_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=catppuccin_latte
|
||||
[catppuccin_mocha_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=catppuccin_mocha
|
||||
[date_night_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=date_night
|
||||
[one_dark_pro_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=one_dark_pro
|
||||
[rose_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=rose
|
||||
@@ -226,7 +219,6 @@ Use `?theme=THEME_NAME` parameter like so:
|
||||
[neon_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=neon
|
||||
[blue_navy_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=blue_navy
|
||||
[calm_pink_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=calm_pink
|
||||
[ambient_gradient_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=ambient_gradient
|
||||
|
||||
|
||||
[add-theme]: https://github.com/anuraghazra/github-readme-stats/edit/master/themes/index.js
|
||||
|
||||
@@ -395,18 +395,6 @@ export const themes = {
|
||||
text_color: "e0def4",
|
||||
bg_color: "191724",
|
||||
},
|
||||
catppuccin_latte: {
|
||||
title_color: "137980",
|
||||
icon_color: "8839ef",
|
||||
text_color: "4c4f69",
|
||||
bg_color: "eff1f5",
|
||||
},
|
||||
catppuccin_mocha: {
|
||||
title_color: "94e2d5",
|
||||
icon_color: "cba6f7",
|
||||
text_color: "cdd6f4",
|
||||
bg_color: "1e1e2e",
|
||||
},
|
||||
date_night: {
|
||||
title_color: "DA7885",
|
||||
text_color: "E1B2A2",
|
||||
@@ -456,12 +444,6 @@ export const themes = {
|
||||
border_color: "e1bc29",
|
||||
bg_color: "2b2d40",
|
||||
},
|
||||
ambient_gradient: {
|
||||
title_color: "ffffff",
|
||||
text_color: "ffffff",
|
||||
icon_color: "ffffff",
|
||||
bg_color: "35,4158d0,c850c0,ffcc70",
|
||||
},
|
||||
};
|
||||
|
||||
export default themes;
|
||||
|
||||
Reference in New Issue
Block a user