mirror of
https://github.com/anuraghazra/github-readme-stats.git
synced 2024-12-15 06:04:17 +08:00
Add prettier check to CI (#1999)
* Add prettier check to CI * Run prettier:format
This commit is contained in:
parent
d5c94b6f57
commit
4c2307ab4b
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -25,5 +25,9 @@ jobs:
|
||||
npm install
|
||||
npm run test
|
||||
|
||||
- name: Run Prettier
|
||||
run: |
|
||||
npm run prettier:check:ci
|
||||
|
||||
- name: Code Coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
|
@ -8,7 +8,9 @@
|
||||
"test:watch": "jest --watch",
|
||||
"theme-readme-gen": "node scripts/generate-theme-doc",
|
||||
"preview-theme": "node scripts/preview-theme",
|
||||
"generate-langs-json": "node scripts/generate-langs-json"
|
||||
"generate-langs-json": "node scripts/generate-langs-json",
|
||||
"prettier:check:ci": "./node_modules/.bin/prettier --check .",
|
||||
"prettier:format": "./node_modules/.bin/prettier --write ."
|
||||
},
|
||||
"author": "Anurag Hazra",
|
||||
"license": "MIT",
|
||||
|
@ -1,26 +1,30 @@
|
||||
const fs = require('fs');
|
||||
const jsYaml = require('js-yaml');
|
||||
const axios = require('axios');
|
||||
const fs = require("fs");
|
||||
const jsYaml = require("js-yaml");
|
||||
const axios = require("axios");
|
||||
|
||||
const LANGS_FILEPATH = "./src/common/languageColors.json"
|
||||
const LANGS_FILEPATH = "./src/common/languageColors.json";
|
||||
|
||||
//Retrieve languages from github linguist repository yaml file
|
||||
//@ts-ignore
|
||||
axios.get("https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml")
|
||||
.then((response) => {
|
||||
axios
|
||||
.get(
|
||||
"https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml",
|
||||
)
|
||||
.then((response) => {
|
||||
//and convert them to a JS Object
|
||||
const languages = jsYaml.load(response.data);
|
||||
|
||||
//and convert them to a JS Object
|
||||
const languages = jsYaml.load(response.data);
|
||||
const languageColors = {};
|
||||
|
||||
const languageColors = {};
|
||||
//Filter only language colors from the whole file
|
||||
Object.keys(languages).forEach((lang) => {
|
||||
languageColors[lang] = languages[lang].color;
|
||||
});
|
||||
|
||||
//Filter only language colors from the whole file
|
||||
Object.keys(languages).forEach((lang) => {
|
||||
languageColors[lang] = languages[lang].color;
|
||||
//Debug Print
|
||||
//console.dir(languageColors);
|
||||
fs.writeFileSync(
|
||||
LANGS_FILEPATH,
|
||||
JSON.stringify(languageColors, null, " "),
|
||||
);
|
||||
});
|
||||
|
||||
//Debug Print
|
||||
//console.dir(languageColors);
|
||||
fs.writeFileSync(LANGS_FILEPATH, JSON.stringify(languageColors, null, ' '));
|
||||
|
||||
});
|
||||
|
@ -67,9 +67,9 @@ function calculateRank({
|
||||
if (normalizedScore < RANK_S_VALUE) return "S+";
|
||||
if (normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
|
||||
if (normalizedScore < RANK_A2_VALUE) return "A++";
|
||||
if (normalizedScore < RANK_A3_VALUE) return "A+"
|
||||
if (normalizedScore < RANK_A3_VALUE) return "A+";
|
||||
return "B+";
|
||||
})()
|
||||
})();
|
||||
|
||||
return { level, score: normalizedScore };
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ const iconWithLabel = (icon, label, testid) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import('../fetchers/types').RepositoryData} repo
|
||||
* @param {Partial<import("./types").RepoCardOptions>} options
|
||||
* @param {import('../fetchers/types').RepositoryData} repo
|
||||
* @param {Partial<import("./types").RepoCardOptions>} options
|
||||
* @returns {string}
|
||||
*/
|
||||
const renderRepoCard = (repo, options = {}) => {
|
||||
@ -167,11 +167,11 @@ const renderRepoCard = (repo, options = {}) => {
|
||||
return card.render(`
|
||||
${
|
||||
isTemplate
|
||||
// @ts-ignore
|
||||
? getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
|
||||
? // @ts-ignore
|
||||
getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
|
||||
: isArchived
|
||||
// @ts-ignore
|
||||
? getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
|
||||
? // @ts-ignore
|
||||
getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
|
||||
: ""
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ const { MissingParamError } = require("../common/utils");
|
||||
*/
|
||||
const fetchWakatimeStats = async ({ username, api_domain, range }) => {
|
||||
if (!username) throw new MissingParamError(["username"]);
|
||||
|
||||
|
||||
try {
|
||||
const { data } = await axios.get(
|
||||
`https://${
|
||||
|
@ -81,7 +81,10 @@ describe("FetchTopLanguages", () => {
|
||||
it("should fetch correct language data while excluding the 'test-repo-1' repository", async () => {
|
||||
mock.onPost("https://api.github.com/graphql").reply(200, data_langs);
|
||||
|
||||
let repo = await fetchTopLanguages("anuraghazra", exclude_repo=["test-repo-1"]);
|
||||
let repo = await fetchTopLanguages(
|
||||
"anuraghazra",
|
||||
(exclude_repo = ["test-repo-1"]),
|
||||
);
|
||||
expect(repo).toStrictEqual({
|
||||
HTML: {
|
||||
color: "#0f0",
|
||||
|
@ -207,7 +207,7 @@ describe("Wakatime fetcher", () => {
|
||||
mock.onGet(/\/https:\/\/wakatime\.com\/api/).reply(404, wakaTimeData);
|
||||
|
||||
await expect(fetchWakatimeStats("noone")).rejects.toThrow(
|
||||
"Missing params \"username\" make sure you pass the parameters in URL",
|
||||
'Missing params "username" make sure you pass the parameters in URL',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -48,10 +48,15 @@ describe("Test Render Wakatime Card", () => {
|
||||
});
|
||||
|
||||
it('should show "no coding activitiy this week" message when there hasn not been activity', () => {
|
||||
document.body.innerHTML = renderWakatimeCard({
|
||||
...wakaTimeData.data,
|
||||
languages: undefined
|
||||
}, {});
|
||||
expect(document.querySelector(".stat").textContent).toBe("No coding activity this week")
|
||||
})
|
||||
document.body.innerHTML = renderWakatimeCard(
|
||||
{
|
||||
...wakaTimeData.data,
|
||||
languages: undefined,
|
||||
},
|
||||
{},
|
||||
);
|
||||
expect(document.querySelector(".stat").textContent).toBe(
|
||||
"No coding activity this week",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -355,12 +355,12 @@ const themes = {
|
||||
bg_color: "09131B",
|
||||
border_color: "0c1a25",
|
||||
},
|
||||
"rose_pine":{
|
||||
rose_pine: {
|
||||
title_color: "9ccfd8",
|
||||
icon_color: "ebbcba",
|
||||
text_color: "e0def4",
|
||||
bg_color: "191724",
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = themes;
|
||||
|
Loading…
Reference in New Issue
Block a user