Compare commits

...
Author SHA1 Message Date
Rick Staa 4ab959d119 docs: update wakatime user
The old example user doesn't have a WakaTime account anymore.
2023-05-06 09:57:10 +00:00
Rongrong 0caa4c5fd8 test: fix mistaken pageInfo.endCursor keys (#2657)
The previous mock logic was too simplistic and has been fixed in the
commit. If the mock logic had been properly implemented, then the
mistaken pageInfo.endCursor keys should have made the test case "should
fetch two pages of stars if 'FETCH_MULTI_PAGE_STARS' env variable is set
to `true`" stuck.
2023-05-06 08:07:03 +00:00
Alexandr Garbuzov 0c2fe4e07b Cover with test changes in #2662 pull request (#2673) 2023-05-06 07:43:37 +00:00
Fabiano CoutoandRick Staa a340900e8a fix(wakatime-fetcher): add default range to prevent user not found error (#2670)
* feat(theme): add github_dark_dimmed theme

* feat(theme): change github_dark_dimmed icon color

* contrast ratio adjustment

contrast ratio adjustment on github_dark_dimmed theme

* feat(theme): readme preview

* feat(theme): github themes next to each other

* github themes next to each other

* feat(RankIcon): add rank icon option

* feat(RankIcon): extract rankIcon to icons file

* feat(RankIcon): update readme

* feat(RankIcon): test coverage

* Update readme.md

Co-authored-by: Rick Staa <rick.staa@outlook.com>

* add wakatime default range

* update wakatime demos in readme with most active user

* update wakatime demo in readme

* remove &range=all_time from wakatime demos in readme

---------

Co-authored-by: Rick Staa <rick.staa@outlook.com>
2023-05-05 23:12:28 +02:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 2619c12638 build(deps): bump yaml from 2.1.3 to 2.2.2 (#2644)
Bumps [yaml](https://github.com/eemeli/yaml) from 2.1.3 to 2.2.2.
- [Release notes](https://github.com/eemeli/yaml/releases)
- [Commits](https://github.com/eemeli/yaml/compare/v2.1.3...v2.2.2)

---
updated-dependencies:
- dependency-name: yaml
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-05 14:10:17 +00:00
Alexandr Garbuzov d306bec73e Add PRs cache cleaning workflow (#2661) 2023-05-05 14:09:23 +00:00
Alexandr Garbuzov c656f3df6b Update codecov action version to resolve github action deprecation warning (#2677) 2023-05-05 14:07:37 +00:00
Alexandr Garbuzov c6dab8b0f2 Fixed docstring for stats card create text node function to resolve type errors (#2689) 2023-05-05 14:07:15 +00:00
Alexandr Garbuzov 311204f4f9 Fixed docstring for several wakatime card gen functions to resolve multiple type errors (#2690) 2023-05-05 14:06:52 +00:00
Alexandr Garbuzov 0dc3531666 Fixed wakatime create text node func docstring to resolve vscode type errors (#2678) 2023-05-04 09:13:47 +02:00
Alexandr Garbuzov a4d6fe104f Fixed card constructor docstring to resolve vscode type errors (#2674) 2023-05-03 07:04:33 +02:00
Alexandr Garbuzov cb99414d3d Show no activity error in compact layout of wakatime card (#2662) 2023-05-01 08:21:29 +02:00
Alexandr Garbuzov 2f4279e738 Fixed vscode type error in get card colors function (#2660) 2023-04-30 08:20:26 +02:00
Rick Staa 3bd6519d39 docs: fix README language card usage order (#2659) 2023-04-29 08:25:37 +05:30
13 changed files with 129 additions and 61 deletions
+33
View File
@@ -0,0 +1,33 @@
name: prs cache clean
on:
pull_request:
types:
- closed
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+1 -1
View File
@@ -34,4 +34,4 @@ jobs:
npm run format:check npm run format:check
- name: Code Coverage - name: Code Coverage
uses: codecov/codecov-action@v1 uses: codecov/codecov-action@v3
+6 -6
View File
@@ -5581,9 +5581,9 @@
"dev": true "dev": true
}, },
"node_modules/yaml": { "node_modules/yaml": {
"version": "2.1.3", "version": "2.2.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.3.tgz", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz",
"integrity": "sha512-AacA8nRULjKMX2DvWvOAdBZMOfQlypSFkjcOcu9FalllIDJ1kvlREzcdIZmidQUqqeMv7jorHjq2HlLv/+c2lg==", "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">= 14" "node": ">= 14"
@@ -9855,9 +9855,9 @@
"dev": true "dev": true
}, },
"yaml": { "yaml": {
"version": "2.1.3", "version": "2.2.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.3.tgz", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz",
"integrity": "sha512-AacA8nRULjKMX2DvWvOAdBZMOfQlypSFkjcOcu9FalllIDJ1kvlREzcdIZmidQUqqeMv7jorHjq2HlLv/+c2lg==", "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==",
"dev": true "dev": true
}, },
"yargs": { "yargs": {
+15 -15
View File
@@ -363,6 +363,16 @@ The top languages card shows a GitHub user's most frequently used top language.
> **Note** > **Note**
> 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. > 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.
### Usage
Copy-paste this code into your readme and change the links.
Endpoint: `api/top-langs?username=anuraghazra`
```md
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra)](https://github.com/anuraghazra/github-readme-stats)
```
### Language stats algorithm ### Language stats algorithm
We use the following algorithm to calculate the languages percentages on the language card: We use the following algorithm to calculate the languages percentages on the language card:
@@ -381,16 +391,6 @@ By default, only the byte count is used for determining the languages percentage
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&size_weight=0.5&count_weight=0.5)](https://github.com/anuraghazra/github-readme-stats) [![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&size_weight=0.5&count_weight=0.5)](https://github.com/anuraghazra/github-readme-stats)
``` ```
### Usage
Copy-paste this code into your readme and change the links.
Endpoint: `api/top-langs?username=anuraghazra`
```md
[![Top Langs](https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra)](https://github.com/anuraghazra/github-readme-stats)
```
### Exclude individual repositories ### Exclude individual repositories
You can use the `&exclude_repo=repo1,repo2` parameter to exclude individual repositories. You can use the `&exclude_repo=repo1,repo2` parameter to exclude individual repositories.
@@ -448,7 +448,7 @@ You can use the `&hide_progress=true` option to hide the percentages and the pro
Change the `?username=` value to your [Wakatime](https://wakatime.com) username. Change the `?username=` value to your [Wakatime](https://wakatime.com) username.
```md ```md
[![willianrod's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=willianrod)](https://github.com/anuraghazra/github-readme-stats) [![Harlok's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=Harlok)](https://github.com/anuraghazra/github-readme-stats)
``` ```
> **Note**: > **Note**:
@@ -456,13 +456,13 @@ Change the `?username=` value to your [Wakatime](https://wakatime.com) username.
### Demo ### Demo
[![willianrod's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=willianrod)](https://github.com/anuraghazra/github-readme-stats) [![Harlok's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=Harlok)](https://github.com/anuraghazra/github-readme-stats)
[![willianrod's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=willianrod&hide_progress=true)](https://github.com/anuraghazra/github-readme-stats) [![Harlok's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=Harlok&hide_progress=true)](https://github.com/anuraghazra/github-readme-stats)
- Compact layout - Compact layout
[![willianrod's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=willianrod&layout=compact)](https://github.com/anuraghazra/github-readme-stats) [![Harlok's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=Harlok&layout=compact)](https://github.com/anuraghazra/github-readme-stats)
* * * * * *
@@ -520,7 +520,7 @@ Choose from any of the [default themes](#themes)
- WakaTime card - WakaTime card
[![willianrod's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=willianrod)](https://github.com/anuraghazra/github-readme-stats) [![Harlok's wakatime stats](https://github-readme-stats.vercel.app/api/wakatime?username=Harlok)](https://github.com/anuraghazra/github-readme-stats)
* * * * * *
+4 -2
View File
@@ -20,14 +20,16 @@ const RANK_CARD_DEFAULT_WIDTH = 450;
/** /**
* Create a stats card text item. * Create a stats card text item.
* *
* @param {object[]} createTextNodeParams Object that contains the createTextNode parameters. * @param {object} createTextNodeParams Object that contains the createTextNode parameters.
* @param {string} createTextNodeParams.icon The icon to display.
* @param {string} createTextNodeParams.label The label to display. * @param {string} createTextNodeParams.label The label to display.
* @param {string} createTextNodeParams.value The value to display. * @param {number} createTextNodeParams.value The value to display.
* @param {string} createTextNodeParams.id The id of the stat. * @param {string} createTextNodeParams.id The id of the stat.
* @param {number} createTextNodeParams.index The index of the stat. * @param {number} createTextNodeParams.index The index of the stat.
* @param {boolean} createTextNodeParams.showIcons Whether to show icons. * @param {boolean} createTextNodeParams.showIcons Whether to show icons.
* @param {number} createTextNodeParams.shiftValuePos Number of pixels the value has to be shifted to the right. * @param {number} createTextNodeParams.shiftValuePos Number of pixels the value has to be shifted to the right.
* @param {boolean} createTextNodeParams.bold Whether to bold the label. * @param {boolean} createTextNodeParams.bold Whether to bold the label.
* @param {string} createTextNodeParams.number_format The format of numbers on card.
* @returns * @returns
*/ */
const createTextNode = ({ const createTextNode = ({
+33 -24
View File
@@ -36,11 +36,11 @@ const noCodingActivityNode = ({ color, text }) => {
/** /**
* Create compact WakaTime layout. * Create compact WakaTime layout.
* *
* @param {Object[]} args The function arguments. * @param {Object} args The function arguments.
* @param {import("../fetchers/types").WakaTimeLang[]} languages The languages array. * @param {import("../fetchers/types").WakaTimeLang} args.lang The languages array.
* @param {number} totalSize The total size of the languages. * @param {number} args.totalSize The total size of the languages.
* @param {number} x The x position of the language node. * @param {number} args.x The x position of the language node.
* @param {number} y The y position of the language node. * @param {number} args.y The y position of the language node.
*/ */
const createCompactLangNode = ({ lang, totalSize, x, y }) => { const createCompactLangNode = ({ lang, totalSize, x, y }) => {
const color = languageColors[lang.name] || "#858585"; const color = languageColors[lang.name] || "#858585";
@@ -58,11 +58,11 @@ const createCompactLangNode = ({ lang, totalSize, x, y }) => {
/** /**
* Create WakaTime language text node item. * Create WakaTime language text node item.
* *
* @param {Object[]} args The function arguments. * @param {Object} args The function arguments.
* @param {import("../fetchers/types").WakaTimeLang} lang The language object. * @param {import("../fetchers/types").WakaTimeLang[]} args.langs The language objects.
* @param {number} totalSize The total size of the languages. * @param {number} args.totalSize The total size of the languages.
* @param {number} x The x position of the language node. * @param {number} args.x The x position of the language node.
* @param {number} y The y position of the language node. * @param {number} args.y The y position of the language node.
*/ */
const createLanguageTextNode = ({ langs, totalSize, x, y }) => { const createLanguageTextNode = ({ langs, totalSize, x, y }) => {
return langs.map((lang, index) => { return langs.map((lang, index) => {
@@ -86,14 +86,15 @@ const createLanguageTextNode = ({ langs, totalSize, x, y }) => {
/** /**
* Create WakaTime text item. * Create WakaTime text item.
* *
* @param {Object[]} args The function arguments. * @param {Object} args The function arguments.
* @param {string} id The id of the text node item. * @param {string} args.id The id of the text node item.
* @param {string} label The label of the text node item. * @param {string} args.label The label of the text node item.
* @param {string} value The value of the text node item. * @param {string} args.value The value of the text node item.
* @param {number} index The index of the text node item. * @param {number} args.index The index of the text node item.
* @param {percent} percent Percentage of the text node item. * @param {string} args.percent Percentage of the text node item.
* @param {boolean} hideProgress Whether to hide the progress bar. * @param {boolean} args.hideProgress Whether to hide the progress bar.
* @param {string} progressBarBackgroundColor The color of the progress bar background. * @param {string} args.progressBarColor The color of the progress bar.
* @param {string} args.progressBarBackgroundColor The color of the progress bar background.
*/ */
const createTextNode = ({ const createTextNode = ({
id, id,
@@ -267,12 +268,20 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
<rect x="25" y="0" width="${width - 50}" height="8" fill="white" rx="5" /> <rect x="25" y="0" width="${width - 50}" height="8" fill="white" rx="5" />
</mask> </mask>
${compactProgressBar} ${compactProgressBar}
${createLanguageTextNode({ ${
x: 0, filteredLanguages.length
y: 25, ? createLanguageTextNode({
langs: filteredLanguages, x: 0,
totalSize: 100, y: 25,
}).join("")} langs: filteredLanguages,
totalSize: 100,
}).join("")
: noCodingActivityNode({
// @ts-ignore
color: textColor,
text: i18n.t("wakatimecard.nocodingactivity"),
})
}
`; `;
} else { } else {
finalLayout = flexLayout({ finalLayout = flexLayout({
+6
View File
@@ -12,6 +12,12 @@ class Card {
* @param {string?=} args.customTitle Card custom title. * @param {string?=} args.customTitle Card custom title.
* @param {string?=} args.defaultTitle Card default title. * @param {string?=} args.defaultTitle Card default title.
* @param {string?=} args.titlePrefixIcon Card title prefix icon. * @param {string?=} args.titlePrefixIcon Card title prefix icon.
* @param {object?=} args.colors Card colors arguments.
* @param {string} args.colors.titleColor Card title color.
* @param {string} args.colors.textColor Card text color.
* @param {string} args.colors.iconColor Card icon color.
* @param {string|Array} args.colors.bgColor Card background color.
* @param {string} args.colors.borderColor Card border color.
* @returns {Card} Card instance. * @returns {Card} Card instance.
*/ */
constructor({ constructor({
+2 -2
View File
@@ -194,15 +194,15 @@ const flexLayout = ({ items, gap, direction, sizes = [] }) => {
/** /**
* Returns theme based colors with proper overrides and defaults. * Returns theme based colors with proper overrides and defaults.
* *
* @param {Object[]} args Function arguments. * @param {Object} args Function arguments.
* @param {string} args.title_color Card title color. * @param {string} args.title_color Card title color.
* @param {string} args.text_color Card text color. * @param {string} args.text_color Card text color.
* @param {string} args.icon_color Card icon color. * @param {string} args.icon_color Card icon color.
* @param {string} args.bg_color Card background color. * @param {string} args.bg_color Card background color.
* @param {string} args.border_color Card border color. * @param {string} args.border_color Card border color.
* @param {string} args.ring_color Card ring color.
* @param {string} args.theme Card theme. * @param {string} args.theme Card theme.
* @param {string} args.fallbackTheme Fallback theme. * @param {string} args.fallbackTheme Fallback theme.
*
*/ */
const getCardColors = ({ const getCardColors = ({
title_color, title_color,
+3 -1
View File
@@ -14,7 +14,9 @@ const fetchWakatimeStats = async ({ username, api_domain, range }) => {
const { data } = await axios.get( const { data } = await axios.get(
`https://${ `https://${
api_domain ? api_domain.replace(/\/$/gi, "") : "wakatime.com" api_domain ? api_domain.replace(/\/$/gi, "") : "wakatime.com"
}/api/v1/users/${username}/stats/${range || ""}?is_including_today=true`, }/api/v1/users/${username}/stats/${
range || "all_time"
}?is_including_today=true`,
); );
return data.data; return data.data;
+1 -1
View File
@@ -43,7 +43,7 @@ const data_stats = {
nodes: [{ stargazers: { totalCount: 100 } }], nodes: [{ stargazers: { totalCount: 100 } }],
pageInfo: { pageInfo: {
hasNextPage: false, hasNextPage: false,
cursor: "cursor", endCursor: "cursor",
}, },
}, },
}, },
+9 -8
View File
@@ -27,7 +27,7 @@ const data_stats = {
], ],
pageInfo: { pageInfo: {
hasNextPage: true, hasNextPage: true,
cursor: "cursor", endCursor: "cursor",
}, },
}, },
}, },
@@ -44,7 +44,7 @@ const data_repo = {
], ],
pageInfo: { pageInfo: {
hasNextPage: false, hasNextPage: false,
cursor: "cursor", endCursor: "cursor",
}, },
}, },
}, },
@@ -64,7 +64,7 @@ const data_repo_zero_stars = {
], ],
pageInfo: { pageInfo: {
hasNextPage: true, hasNextPage: true,
cursor: "cursor", endCursor: "cursor",
}, },
}, },
}, },
@@ -86,11 +86,12 @@ const mock = new MockAdapter(axios);
beforeEach(() => { beforeEach(() => {
process.env.FETCH_MULTI_PAGE_STARS = "false"; // Set to `false` to fetch only one page of stars. process.env.FETCH_MULTI_PAGE_STARS = "false"; // Set to `false` to fetch only one page of stars.
mock mock.onPost("https://api.github.com/graphql").reply((cfg) => {
.onPost("https://api.github.com/graphql") return [
.replyOnce(200, data_stats) 200,
.onPost("https://api.github.com/graphql") cfg.data.includes("contributionsCollection") ? data_stats : data_repo,
.replyOnce(200, data_repo); ];
});
}); });
afterEach(() => { afterEach(() => {
+1 -1
View File
@@ -105,7 +105,7 @@ describe("Wakatime fetcher", () => {
const username = "anuraghazra"; const username = "anuraghazra";
mock mock
.onGet( .onGet(
`https://wakatime.com/api/v1/users/${username}/stats/?is_including_today=true`, `https://wakatime.com/api/v1/users/${username}/stats/all_time?is_including_today=true`,
) )
.reply(200, wakaTimeData); .reply(200, wakaTimeData);
+15
View File
@@ -67,4 +67,19 @@ describe("Test Render Wakatime Card", () => {
"No coding activity this week", "No coding activity this week",
); );
}); });
it('should show "no coding activity this week" message when using compact layout and there has not been activity', () => {
document.body.innerHTML = renderWakatimeCard(
{
...wakaTimeData.data,
languages: undefined,
},
{
layout: "compact",
},
);
expect(document.querySelector(".stat").textContent).toBe(
"No coding activity this week",
);
});
}); });