From d7089af346cdb8f5cda34ffb9a62d209da82c0a1 Mon Sep 17 00:00:00 2001 From: Rahul Mahesh Date: Sun, 2 Aug 2020 18:48:49 +0530 Subject: [PATCH 1/7] style(theme): Added new theme Bear (#278) Bear is one of the most downloaded color themes on VSCode. So I created a theme based on that. Co-authored-by: Anurag Hazra --- themes/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/themes/index.js b/themes/index.js index 2f0c78ae..1381d7a1 100644 --- a/themes/index.js +++ b/themes/index.js @@ -125,6 +125,12 @@ const themes = { text_color: "ffd95b", bg_color: "000000", }, + "bear": { + title_color: "e03c8a", + icon_color: "00AEFF", + text_color: "bcb28d", + bg_color: "1f2023", + }, "solarized-dark": { title_color: "268bd2", icon_color: "b58900", From 6f7e35468ca78dd8b7c2b42c3bce99e12015dc59 Mon Sep 17 00:00:00 2001 From: Anurag Hazra Date: Sun, 2 Aug 2020 18:52:53 +0530 Subject: [PATCH 2/7] docs(theme): Auto update theme readme (#294) Co-authored-by: Github Readme Stats Bot --- themes/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/themes/README.md b/themes/README.md index 8d110ae7..53c8c13b 100644 --- a/themes/README.md +++ b/themes/README.md @@ -22,8 +22,8 @@ Use `?theme=THEME_NAME` parameter like so :- | `highcontrast` ![highcontrast][highcontrast] | `dracula` ![dracula][dracula] | `prussian` ![prussian][prussian] | | `monokai` ![monokai][monokai] | `vue` ![vue][vue] | `shades-of-purple` ![shades-of-purple][shades-of-purple] | | `nightowl` ![nightowl][nightowl] | `buefy` ![buefy][buefy] | `blue-green` ![blue-green][blue-green] | -| `algolia` ![algolia][algolia] | `great-gatsby` ![great-gatsby][great-gatsby] | `solarized-dark` ![solarized-dark][solarized-dark] | -| `solarized-light` ![solarized-light][solarized-light] | | [Add your theme][add-theme] | +| `algolia` ![algolia][algolia] | `great-gatsby` ![great-gatsby][great-gatsby] | `bear` ![bear][bear] | +| `solarized-dark` ![solarized-dark][solarized-dark] | `solarized-light` ![solarized-light][solarized-light] | [Add your theme][add-theme] | ## Repo Card @@ -37,8 +37,8 @@ Use `?theme=THEME_NAME` parameter like so :- | `highcontrast` ![highcontrast][highcontrast_repo] | `dracula` ![dracula][dracula_repo] | `prussian` ![prussian][prussian_repo] | | `monokai` ![monokai][monokai_repo] | `vue` ![vue][vue_repo] | `shades-of-purple` ![shades-of-purple][shades-of-purple_repo] | | `nightowl` ![nightowl][nightowl_repo] | `buefy` ![buefy][buefy_repo] | `blue-green` ![blue-green][blue-green_repo] | -| `algolia` ![algolia][algolia_repo] | `great-gatsby` ![great-gatsby][great-gatsby_repo] | `solarized-dark` ![solarized-dark][solarized-dark_repo] | -| `solarized-light` ![solarized-light][solarized-light_repo] | | [Add your theme][add-theme] | +| `algolia` ![algolia][algolia_repo] | `great-gatsby` ![great-gatsby][great-gatsby_repo] | `bear` ![bear][bear_repo] | +| `solarized-dark` ![solarized-dark][solarized-dark_repo] | `solarized-light` ![solarized-light][solarized-light_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 @@ -62,6 +62,7 @@ Use `?theme=THEME_NAME` parameter like so :- [blue-green]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=blue-green [algolia]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=algolia [great-gatsby]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=great-gatsby +[bear]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=bear [solarized-dark]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=solarized-dark [solarized-light]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=solarized-light @@ -87,6 +88,7 @@ Use `?theme=THEME_NAME` parameter like so :- [blue-green_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=blue-green [algolia_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=algolia [great-gatsby_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=great-gatsby +[bear_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=bear [solarized-dark_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=solarized-dark [solarized-light_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=solarized-light From 53c49404bf356dfe2c7b15ca613b3dcefba831bb Mon Sep 17 00:00:00 2001 From: Anurag Hazra Date: Sun, 2 Aug 2020 22:47:34 +0530 Subject: [PATCH 3/7] infra: theme preview gh action (#296) * chore: testing theme preview script * fix: workflow * test current pr * comment on pr script * fix: preview theme script * fix: preview theme --- .github/workflows/preview-theme.yml | 29 +++++++++++ package.json | 8 ++- scripts/preview-theme.js | 76 +++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/preview-theme.yml create mode 100644 scripts/preview-theme.js diff --git a/.github/workflows/preview-theme.yml b/.github/workflows/preview-theme.yml new file mode 100644 index 00000000..c0203c33 --- /dev/null +++ b/.github/workflows/preview-theme.yml @@ -0,0 +1,29 @@ +name: Theme preview + +on: + pull_request: + types: [opened, synchronize, reopened] + branches: + - master + - theme-preview-script + paths: + - "themes/index.js" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: setup node + uses: actions/setup-node@v1 + with: + node-version: "12.x" + + - name: npm install, preview theme + run: | + npm install + npm run preview-theme + env: + CI: true + PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }} diff --git a/package.json b/package.json index d167c1b5..af82b595 100644 --- a/package.json +++ b/package.json @@ -6,18 +6,22 @@ "scripts": { "test": "jest --coverage", "test:watch": "jest --watch", - "theme-readme-gen": "node scripts/generate-theme-doc" + "theme-readme-gen": "node scripts/generate-theme-doc", + "preview-theme": "node scripts/preview-theme" }, "author": "Anurag Hazra", "license": "MIT", "devDependencies": { + "@actions/core": "^1.2.4", + "@actions/github": "^4.0.0", "@testing-library/dom": "^7.20.0", "@testing-library/jest-dom": "^5.11.0", "axios": "^0.19.2", "axios-mock-adapter": "^1.18.1", "css-to-object": "^1.1.0", "husky": "^4.2.5", - "jest": "^26.1.0" + "jest": "^26.1.0", + "parse-diff": "^0.7.0" }, "dependencies": { "dotenv": "^8.2.0", diff --git a/scripts/preview-theme.js b/scripts/preview-theme.js new file mode 100644 index 00000000..6a0eaa6e --- /dev/null +++ b/scripts/preview-theme.js @@ -0,0 +1,76 @@ +const core = require("@actions/core"); +const github = require("@actions/github"); +const parse = require("parse-diff"); +require("dotenv").config(); + +const parsePullRequestId = (githubRef) => { + const result = /refs\/pull\/(\d+)\/merge/g.exec(githubRef); + if (!result) { + console.log("Reference not found."); + return 297; + } + const [, pullRequestId] = result; + return pullRequestId; +}; + +async function run() { + try { + const octokit = github.getOctokit(process.env.PERSONAL_TOKEN); + const pullRequestId = parsePullRequestId(process.env.GITHUB_REF); + + let res = await octokit.pulls.get({ + owner: "anuraghazra", + repo: "github-readme-stats", + pull_number: pullRequestId, + mediaType: { + format: "diff", + }, + }); + + let diff = parse(res.data); + let colorStrings = diff + .find((file) => file.to === "themes/index.js") + .chunks[0].changes.filter((c) => c.type === "add") + .map((c) => c.content.replace("+", "")) + .join(""); + + let matches = colorStrings.match(/(title_color:.*bg_color.*\")/); + let colors = matches && matches[0].split(","); + + if (!colors) { + await octokit.issues.createComment({ + owner: "anuraghazra", + repo: "github-readme-stats", + body: ` + \rTheme preview (bot) + Cannot create theme preview + `, + issue_number: pullRequestId, + }); + return; + } + colors = colors.map((color) => + color.replace(/.*\:\s/, "").replace(/\"/g, "") + ); + + let titleColor = colors[0]; + let iconColor = colors[1]; + let textColor = colors[2]; + let bgColor = colors[3]; + const url = `https://github-readme-stats.vercel.app/api?username=anuraghazra&title_color=${titleColor}&icon_color=${iconColor}&text_color=${textColor}&bg_color=${bgColor}&show_icons=true`; + + await octokit.issues.createComment({ + owner: "anuraghazra", + repo: "github-readme-stats", + body: ` + \rTheme preview (bot) + \r![](${url}) + `, + issue_number: pullRequestId, + }); + } catch (error) { + core.setFailed(error.message); + } +} + +run(); From ce8660c8251fb55b71367f57aa1935d298c3bf52 Mon Sep 17 00:00:00 2001 From: Algo-ryth-mix Date: Wed, 5 Aug 2020 10:14:03 +0200 Subject: [PATCH 4/7] style(theme): Add Nord theme (#314) * Add Nordtheme adding a www.nordtheme.com inspired theme using nord0, nord4, nord8 & nord9 * Update index.js --- themes/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/themes/index.js b/themes/index.js index 1381d7a1..56ff9989 100644 --- a/themes/index.js +++ b/themes/index.js @@ -143,6 +143,12 @@ const themes = { text_color: "859900", bg_color: "fdf6e3", }, + nord: { + title_color: "81a1c1", + text_color: "d8dee9", + icon_color: "88c0d0", + bg_color: "2e3440", + }, }; module.exports = themes; From 20463f63657e39d2529abc2350b60a8ef504d674 Mon Sep 17 00:00:00 2001 From: Anurag Hazra Date: Wed, 5 Aug 2020 21:57:11 +0530 Subject: [PATCH 5/7] fix: Theme preview script (#318) * chore: testing theme preview script * fix: workflow * test current pr * comment on pr script * fix: preview theme script * fix: preview theme * fix: token fix * test: theme * fix: conflict --- .github/workflows/preview-theme.yml | 3 ++- scripts/preview-theme.js | 3 ++- themes/index.js | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/preview-theme.yml b/.github/workflows/preview-theme.yml index c0203c33..44782eed 100644 --- a/.github/workflows/preview-theme.yml +++ b/.github/workflows/preview-theme.yml @@ -6,7 +6,6 @@ on: branches: - master - theme-preview-script - paths: - "themes/index.js" jobs: @@ -27,3 +26,5 @@ jobs: env: CI: true PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }} + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/preview-theme.js b/scripts/preview-theme.js index 6a0eaa6e..4935b778 100644 --- a/scripts/preview-theme.js +++ b/scripts/preview-theme.js @@ -15,7 +15,8 @@ const parsePullRequestId = (githubRef) => { async function run() { try { - const octokit = github.getOctokit(process.env.PERSONAL_TOKEN); + const token = core.getInput("token"); + const octokit = github.getOctokit(token || process.env.PERSONAL_TOKEN); const pullRequestId = parsePullRequestId(process.env.GITHUB_REF); let res = await octokit.pulls.get({ diff --git a/themes/index.js b/themes/index.js index 56ff9989..8dda8f81 100644 --- a/themes/index.js +++ b/themes/index.js @@ -113,19 +113,19 @@ const themes = { text_color: "0cf574", bg_color: "040f0f", }, - "algolia": { + algolia: { title_color: "00AEFF", icon_color: "2DDE98", text_color: "FFFFFF", bg_color: "050F2C", }, - "great-gatsby":{ + "great-gatsby": { title_color: "ffa726", icon_color: "ffb74d", text_color: "ffd95b", bg_color: "000000", }, - "bear": { + bear: { title_color: "e03c8a", icon_color: "00AEFF", text_color: "bcb28d", From 8acd429d448c82e9c4946a294209ca70418155af Mon Sep 17 00:00:00 2001 From: IK <36619465+kazukazuinaina@users.noreply.github.com> Date: Thu, 6 Aug 2020 01:35:08 +0900 Subject: [PATCH 6/7] style(theme): Add gotham theme (#317) * [add] gotham-theme * fix gotham colorscheme --- themes/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/themes/index.js b/themes/index.js index 8dda8f81..8e2ba724 100644 --- a/themes/index.js +++ b/themes/index.js @@ -149,6 +149,12 @@ const themes = { icon_color: "88c0d0", bg_color: "2e3440", }, + "gotham": { + title_color: "2aa889", + icon_color: "599cab", + text_color: "99d1ce", + bg_color: "0c1014", + }, }; module.exports = themes; From 719e74c7f539efad97840e1d875238b344e0fcfb Mon Sep 17 00:00:00 2001 From: Anurag Hazra Date: Wed, 5 Aug 2020 22:09:18 +0530 Subject: [PATCH 7/7] docs(theme): Auto update theme readme (#319) Co-authored-by: Github Readme Stats Bot --- themes/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/themes/README.md b/themes/README.md index 53c8c13b..c091b76e 100644 --- a/themes/README.md +++ b/themes/README.md @@ -23,7 +23,8 @@ Use `?theme=THEME_NAME` parameter like so :- | `monokai` ![monokai][monokai] | `vue` ![vue][vue] | `shades-of-purple` ![shades-of-purple][shades-of-purple] | | `nightowl` ![nightowl][nightowl] | `buefy` ![buefy][buefy] | `blue-green` ![blue-green][blue-green] | | `algolia` ![algolia][algolia] | `great-gatsby` ![great-gatsby][great-gatsby] | `bear` ![bear][bear] | -| `solarized-dark` ![solarized-dark][solarized-dark] | `solarized-light` ![solarized-light][solarized-light] | [Add your theme][add-theme] | +| `solarized-dark` ![solarized-dark][solarized-dark] | `solarized-light` ![solarized-light][solarized-light] | `nord` ![nord][nord] | +| `gotham` ![gotham][gotham] | | [Add your theme][add-theme] | ## Repo Card @@ -38,7 +39,8 @@ Use `?theme=THEME_NAME` parameter like so :- | `monokai` ![monokai][monokai_repo] | `vue` ![vue][vue_repo] | `shades-of-purple` ![shades-of-purple][shades-of-purple_repo] | | `nightowl` ![nightowl][nightowl_repo] | `buefy` ![buefy][buefy_repo] | `blue-green` ![blue-green][blue-green_repo] | | `algolia` ![algolia][algolia_repo] | `great-gatsby` ![great-gatsby][great-gatsby_repo] | `bear` ![bear][bear_repo] | -| `solarized-dark` ![solarized-dark][solarized-dark_repo] | `solarized-light` ![solarized-light][solarized-light_repo] | [Add your theme][add-theme] | +| `solarized-dark` ![solarized-dark][solarized-dark_repo] | `solarized-light` ![solarized-light][solarized-light_repo] | `nord` ![nord][nord_repo] | +| `gotham` ![gotham][gotham_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 @@ -65,6 +67,8 @@ Use `?theme=THEME_NAME` parameter like so :- [bear]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=bear [solarized-dark]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=solarized-dark [solarized-light]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=solarized-light +[nord]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=nord +[gotham]: https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide=contribs,prs&cache_seconds=86400&theme=gotham [default_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=default @@ -91,6 +95,8 @@ Use `?theme=THEME_NAME` parameter like so :- [bear_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=bear [solarized-dark_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=solarized-dark [solarized-light_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=solarized-light +[nord_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=nord +[gotham_repo]: https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats&cache_seconds=86400&theme=gotham [add-theme]: https://github.com/anuraghazra/github-readme-stats/edit/master/themes/index.js