Skip to content

Commit d5d1f0f

Browse files
authored
Merge pull request #68 from anuraghazra/master
[pull] master from anuraghazra:master
2 parents a6247c3 + d5fbfb4 commit d5d1f0f

File tree

11 files changed

+127
-16
lines changed

11 files changed

+127
-16
lines changed

.github/labeler.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
themes: themes/index.js
22
doc-translation: docs/*
33
card-i18n: src/translations.js
4+
documentation: readme.md

.github/workflows/generate-theme-doc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
node-version: ${{ matrix.node-version }}
2424
cache: npm
2525

26+
# Fix the unsafe repo error which was introduced by the CVE-2022-24765 git patches.
27+
- name: Fix unsafe repo error
28+
run: git config --global --add safe.directory ${{ github.workspace }}
29+
2630
- name: npm install, generate readme
2731
run: |
2832
npm ci

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ vercel_token
1010
# IDE
1111
.vscode
1212
*.code-workspace
13+
14+
.vercel

express.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import statsCard from './api/index.js'
2+
import repoCard from './api/pin.js'
3+
import langCard from './api/top-langs.js'
4+
import wakatimeCard from './api/wakatime.js'
5+
import express from 'express'
6+
import dotenv from 'dotenv'
7+
8+
dotenv.config()
9+
const app = express()
10+
app.listen(process.env.port || 9000)
11+
12+
app.get('/', statsCard)
13+
app.get('/pin', repoCard)
14+
app.get('/top-langs', langCard)
15+
app.get('/wakatime', wakatimeCard)

readme.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ Visit <https://indiafightscorona.giveindia.org> and make a small donation to hel
9292
- [Repo Card Exclusive Options](#repo-card-exclusive-options)
9393
- [Language Card Exclusive Options](#language-card-exclusive-options)
9494
- [Wakatime Card Exclusive Option](#wakatime-card-exclusive-options)
95-
- [Deploy Yourself](#deploy-on-your-own-vercel-instance)
95+
- [Deploy Yourself](#deploy-on-your-own)
96+
- [On Vercel](#on-vercel)
97+
- [On other platforms](#on-other-platforms)
9698
- [Keep your fork up to date](#keep-your-fork-up-to-date)
9799

98100
# GitHub Stats Card
@@ -133,7 +135,7 @@ You can add the count of all your private contributions to the total commits cou
133135

134136
### Showing icons
135137

136-
To enable icons, you can pass `show_icons=true` in the query param, like so:
138+
To enable icons, you can pass `&show_icons=true` in the query param, like so:
137139

138140
```md
139141
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true)
@@ -509,7 +511,9 @@ By default, GitHub does not lay out the cards side by side. To do that, you can
509511
</a>
510512
```
511513

512-
## Deploy on your own Vercel instance
514+
## Deploy on your own
515+
516+
### On Vercel
513517

514518
#### :film_projector: [Check Out Step By Step Video Tutorial By @codeSTACKr](https://youtu.be/n6d4KHSKqGk?t=107)
515519

@@ -546,6 +550,23 @@ Since the GitHub API only allows 5k requests per hour, my `https://github-readme
546550

547551
</details>
548552

553+
### On other platforms
554+
555+
> **Warning**
556+
> This way of using GRS is not officially supported and was added to cater to some particular use cases where Vercel could not be used (e.g. #2341). The support for this method, therefore, is limited.
557+
558+
<details>
559+
<summary><b>:hammer_and_wrench: Step-by-step guide for deploying on other platforms</b></summary>
560+
561+
1. Fork or clone this repo as per your needs
562+
2. Add `express` to the dependencies section of `package.json`
563+
https://github.com/anuraghazra/github-readme-stats/blob/ba7c2f8b55eac8452e479c8bd38b044d204d0424/package.json#L54-L61
564+
3. Run `npm i` if needed (initial setup)
565+
4. Run `node express.js` to start the server, or set the entry point to `express.js` in `package.json` if you're deploying on a managed service
566+
https://github.com/anuraghazra/github-readme-stats/blob/ba7c2f8b55eac8452e479c8bd38b044d204d0424/package.json#L11
567+
5. You're done 🎉
568+
</details>
569+
549570
### Keep your fork up to date
550571

551572
You can keep your fork, and thus your private Vercel instance up to date with the upstream using GitHubs' [Sync Fork button](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork). You can also use the [pull](https://github.com/wei/pull) package created by [@wei](https://github.com/wei) to automate this process.

scripts/preview-theme.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,13 @@ const themeNameAlreadyExists = (name) => {
298298
return themes[name] !== undefined;
299299
};
300300

301+
const DRY_RUN = process.env.DRY_RUN === "true" || false;
302+
301303
/**
302304
* Main function.
303305
*/
304306
export const run = async (prNumber) => {
305307
try {
306-
const dryRun = process.env.DRY_RUN === "true" || false;
307308
debug("Retrieve action information from context...");
308309
debug(`Context: ${inspect(github.context)}`);
309310
let commentBody = `
@@ -513,7 +514,7 @@ export const run = async (prNumber) => {
513514
// Create or update theme-preview comment.
514515
debug("Create or update theme-preview comment...");
515516
let comment_url;
516-
if (!dryRun) {
517+
if (!DRY_RUN) {
517518
comment_url = await upsertComment(octokit, {
518519
comment_id: comment?.id,
519520
issue_number: pullRequestId,
@@ -535,7 +536,7 @@ export const run = async (prNumber) => {
535536
const reviewReason = themesValid
536537
? undefined
537538
: INVALID_REVIEW_COMMENT(comment_url);
538-
if (!dryRun) {
539+
if (!DRY_RUN) {
539540
await addReview(
540541
octokit,
541542
pullRequestId,
@@ -558,7 +559,7 @@ export const run = async (prNumber) => {
558559
}
559560
} catch (error) {
560561
debug("Set review state to `REQUEST_CHANGES` and add `invalid` label...");
561-
if (!dryRun) {
562+
if (!DRY_RUN) {
562563
await addReview(
563564
octokit,
564565
pullRequestId,

src/cards/top-languages-card.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { langCardLocales } from "../translations.js";
1414

1515
const DEFAULT_CARD_WIDTH = 300;
16-
const MIN_CARD_WIDTH = 230;
16+
const MIN_CARD_WIDTH = 280;
1717
const DEFAULT_LANGS_COUNT = 5;
1818
const DEFAULT_LANG_COLOR = "#858585";
1919
const CARD_PADDING = 25;
@@ -317,7 +317,6 @@ const renderTopLanguages = (topLangs, options = {}) => {
317317

318318
let finalLayout = "";
319319
if (layout === "compact" || hide_progress == true) {
320-
width = width + 50; // padding
321320
height =
322321
calculateCompactLayoutHeight(langs.length) + (hide_progress ? -25 : 0);
323322

src/cards/wakatime-card.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const createTextNode = ({
118118
// @ts-ignore
119119
name: label,
120120
progressBarBackgroundColor,
121+
delay: staggerDelay + 300,
121122
});
122123

123124
return `
@@ -276,11 +277,12 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
276277
} else {
277278
finalLayout = flexLayout({
278279
items: filteredLanguages.length
279-
? filteredLanguages.map((language) => {
280+
? filteredLanguages.map((language, index) => {
280281
return createTextNode({
281282
id: language.name,
282283
label: language.name,
283284
value: language.text,
285+
index: index,
284286
percent: language.percent,
285287
// @ts-ignore
286288
progressBarColor: titleColor,
@@ -321,7 +323,29 @@ const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
321323
card.setCSS(
322324
`
323325
${cssStyles}
326+
@keyframes slideInAnimation {
327+
from {
328+
width: 0;
329+
}
330+
to {
331+
width: calc(100%-100px);
332+
}
333+
}
334+
@keyframes growWidthAnimation {
335+
from {
336+
width: 0;
337+
}
338+
to {
339+
width: 100%;
340+
}
341+
}
324342
.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
343+
#rect-mask rect{
344+
animation: slideInAnimation 1s ease-in-out forwards;
345+
}
346+
.lang-progress{
347+
animation: growWidthAnimation 0.6s ease-in-out forwards;
348+
}
325349
`,
326350
);
327351

tests/__snapshots__/renderWakatimeCard.test.js.snap

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,29 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1
6969
}
7070
7171
72+
@keyframes slideInAnimation {
73+
from {
74+
width: 0;
75+
}
76+
to {
77+
width: calc(100%-100px);
78+
}
79+
}
80+
@keyframes growWidthAnimation {
81+
from {
82+
width: 0;
83+
}
84+
to {
85+
width: 100%;
86+
}
87+
}
7288
.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58 }
89+
#rect-mask rect{
90+
animation: slideInAnimation 1s ease-in-out forwards;
91+
}
92+
.lang-progress{
93+
animation: growWidthAnimation 0.6s ease-in-out forwards;
94+
}
7395
7496
7597
@@ -227,7 +249,29 @@ exports[`Test Render Wakatime Card should render correctly with compact layout w
227249
}
228250
229251
252+
@keyframes slideInAnimation {
253+
from {
254+
width: 0;
255+
}
256+
to {
257+
width: calc(100%-100px);
258+
}
259+
}
260+
@keyframes growWidthAnimation {
261+
from {
262+
width: 0;
263+
}
264+
to {
265+
width: 100%;
266+
}
267+
}
230268
.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58 }
269+
#rect-mask rect{
270+
animation: slideInAnimation 1s ease-in-out forwards;
271+
}
272+
.lang-progress{
273+
animation: growWidthAnimation 0.6s ease-in-out forwards;
274+
}
231275
232276
233277

tests/e2e/e2e.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ const REPO = "curly-fiesta";
1515
const USER = "catelinemnemosyne";
1616
const STATS_DATA = {
1717
name: "Cateline Mnemosyne",
18-
totalPRs: 1,
19-
totalCommits: 7,
18+
totalPRs: 2,
19+
totalCommits: 8,
2020
totalIssues: 1,
2121
totalStars: 1,
2222
contributedTo: 1,
2323
rank: {
2424
level: "A+",
25-
score: 50.893750297869225,
25+
score: 50.88831151384285,
2626
},
2727
};
2828

tests/renderTopLanguages.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,23 @@ describe("Test renderTopLanguages", () => {
216216
);
217217
expect(queryAllByTestId(document.body, "lang-progress")[0]).toHaveAttribute(
218218
"width",
219-
"120",
219+
"100",
220220
);
221221

222222
expect(queryAllByTestId(document.body, "lang-name")[1]).toHaveTextContent(
223223
"javascript 40.00%",
224224
);
225225
expect(queryAllByTestId(document.body, "lang-progress")[1]).toHaveAttribute(
226226
"width",
227-
"120",
227+
"100",
228228
);
229229

230230
expect(queryAllByTestId(document.body, "lang-name")[2]).toHaveTextContent(
231231
"css 20.00%",
232232
);
233233
expect(queryAllByTestId(document.body, "lang-progress")[2]).toHaveAttribute(
234234
"width",
235-
"60",
235+
"50",
236236
);
237237
});
238238

0 commit comments

Comments
 (0)