diff --git a/.github/labeler.yml b/.github/labeler.yml index be97765f07e42..5b2a4b9c72171 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,3 +1,3 @@ themes: themes/index.js doc-translation: docs/* -card-i18n: src/translations.js +card-i18n: src/assets/translations.js diff --git a/api/index.js b/api/index.js index 10dd48478ec6b..2839a0e2ffbbc 100644 --- a/api/index.js +++ b/api/index.js @@ -9,7 +9,7 @@ import { renderError, } from "../src/common/utils.js"; import { fetchStats } from "../src/fetchers/stats-fetcher.js"; -import { isLocaleAvailable } from "../src/translations.js"; +import { isLocaleAvailable } from "../src/assets/translations.js"; dotenv.config(); diff --git a/api/pin.js b/api/pin.js index e83750a5f7ce4..346f34daa17e6 100644 --- a/api/pin.js +++ b/api/pin.js @@ -7,7 +7,7 @@ import { renderError, } from "../src/common/utils.js"; import { fetchRepo } from "../src/fetchers/repo-fetcher.js"; -import { isLocaleAvailable } from "../src/translations.js"; +import { isLocaleAvailable } from "../src/assets/translations.js"; export default async (req, res) => { const { diff --git a/api/top-langs.js b/api/top-langs.js index aa29b23472dd2..ab3193fab5aa3 100644 --- a/api/top-langs.js +++ b/api/top-langs.js @@ -9,7 +9,7 @@ import { renderError, } from "../src/common/utils.js"; import { fetchTopLanguages } from "../src/fetchers/top-languages-fetcher.js"; -import { isLocaleAvailable } from "../src/translations.js"; +import { isLocaleAvailable } from "../src/assets/translations.js"; dotenv.config(); diff --git a/api/wakatime.js b/api/wakatime.js index bbfb2f2ec5dde..482bd33f862d8 100644 --- a/api/wakatime.js +++ b/api/wakatime.js @@ -8,7 +8,7 @@ import { renderError, } from "../src/common/utils.js"; import { fetchWakatimeStats } from "../src/fetchers/wakatime-fetcher.js"; -import { isLocaleAvailable } from "../src/translations.js"; +import { isLocaleAvailable } from "../src/assets/translations.js"; dotenv.config(); diff --git a/package.json b/package.json index 5fc4492764901..95b1a11dad93f 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,23 @@ { "name": "github-readme-stats", "version": "1.0.0", - "description": "Dynamically generate stats for your github readmes", - "main": "index.js", + "description": "Dynamically generate stats for your GitHub readme", + "keywords": [ + "github-readme-stats", + "readme-stats", + "cards", + "card-generator" + ], + "main": "src/index.js", "type": "module", + "homepage": "https://github.com/anuraghazra/github-readme-stats", + "bugs": { + "url": "https://github.com/anuraghazra/github-readme-stats/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/anuraghazra/github-readme-stats.git" + }, "scripts": { "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage", "test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch", diff --git a/src/translations.js b/src/assets/translations.js similarity index 99% rename from src/translations.js rename to src/assets/translations.js index 3f931bc8ee585..aaa0e44a7fc94 100644 --- a/src/translations.js +++ b/src/assets/translations.js @@ -1,4 +1,4 @@ -import { encodeHTML } from "./common/utils.js"; +import { encodeHTML } from "../common/utils.js"; const statCardLocales = ({ name, apostrophe }) => { const encodedName = encodeHTML(name); diff --git a/src/cards/repo-card.js b/src/cards/repo-card.js index 5730ea4ff0e60..baa50c76f9978 100644 --- a/src/cards/repo-card.js +++ b/src/cards/repo-card.js @@ -11,7 +11,7 @@ import { parseEmojis, wrapTextMultiline, } from "../common/utils.js"; -import { repoCardLocales } from "../translations.js"; +import { repoCardLocales } from "../assets/translations.js"; /** * @param {string} label diff --git a/src/cards/stats-card.js b/src/cards/stats-card.js index f880560e93a1b..8855d07bf0726 100644 --- a/src/cards/stats-card.js +++ b/src/cards/stats-card.js @@ -9,8 +9,8 @@ import { kFormatter, measureText, } from "../common/utils.js"; -import { getStyles } from "../getStyles.js"; -import { statCardLocales } from "../translations.js"; +import { getStyles } from "../common/getStyles.js"; +import { statCardLocales } from "../assets/translations.js"; /** * Create a stats card text item. diff --git a/src/cards/top-languages-card.js b/src/cards/top-languages-card.js index b837b3587a513..cc3f2f6e0f7ee 100644 --- a/src/cards/top-languages-card.js +++ b/src/cards/top-languages-card.js @@ -10,7 +10,7 @@ import { lowercaseTrim, measureText, } from "../common/utils.js"; -import { langCardLocales } from "../translations.js"; +import { langCardLocales } from "../assets/translations.js"; const DEFAULT_CARD_WIDTH = 300; const MIN_CARD_WIDTH = 230; diff --git a/src/cards/wakatime-card.js b/src/cards/wakatime-card.js index 24571e7fffe82..3b1bc7ec778f2 100644 --- a/src/cards/wakatime-card.js +++ b/src/cards/wakatime-card.js @@ -8,8 +8,8 @@ import { getCardColors, lowercaseTrim, } from "../common/utils.js"; -import { getStyles } from "../getStyles.js"; -import { wakatimeCardLocales } from "../translations.js"; +import { getStyles } from "../common/getStyles.js"; +import { wakatimeCardLocales } from "../assets/translations.js"; /** Import language colors. * diff --git a/src/common/Card.js b/src/common/Card.js index 5fd4b9f372c7c..8ee75ab5d2335 100644 --- a/src/common/Card.js +++ b/src/common/Card.js @@ -1,4 +1,4 @@ -import { getAnimations } from "../getStyles.js"; +import { getAnimations } from "./getStyles.js"; import { encodeHTML, flexLayout } from "./utils.js"; class Card { diff --git a/src/getStyles.js b/src/common/getStyles.js similarity index 100% rename from src/getStyles.js rename to src/common/getStyles.js diff --git a/src/common/index.js b/src/common/index.js new file mode 100644 index 0000000000000..ffae69be3af23 --- /dev/null +++ b/src/common/index.js @@ -0,0 +1,29 @@ +export { blacklist } from "./blacklist.js"; +export { Card } from "./Card.js"; +export { createProgressNode } from "./createProgressNode.js"; +export { getStyles, getAnimations } from "./getStyles.js"; +export { i18n } from "./i18n.js"; +export { icons } from "./icons.js"; +export { retryer } from "./retryer.js"; +export { + renderError, + kFormatter, + encodeHTML, + isValidHexColor, + request, + parseArray, + parseBoolean, + fallbackColor, + flexLayout, + getCardColors, + clampValue, + wrapTextMultiline, + measureText, + logger, + CONSTANTS, + CustomError, + MissingParamError, + lowercaseTrim, + chunkArray, + parseEmojis, +} from "./utils.js"; diff --git a/src/calculateRank.js b/src/fetchers/helpers/calculateRank.js similarity index 100% rename from src/calculateRank.js rename to src/fetchers/helpers/calculateRank.js diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js index 941c7e145a14f..17beb5648af37 100644 --- a/src/fetchers/stats-fetcher.js +++ b/src/fetchers/stats-fetcher.js @@ -2,7 +2,7 @@ import axios from "axios"; import * as dotenv from "dotenv"; import githubUsernameRegex from "github-username-regex"; -import { calculateRank } from "../calculateRank.js"; +import { calculateRank } from "./helpers/calculateRank.js"; import { retryer } from "../common/retryer.js"; import { CustomError, diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000000000..027f648c0c241 --- /dev/null +++ b/src/index.js @@ -0,0 +1 @@ +export * from "./common/index.js"; diff --git a/tests/api.test.js b/tests/api.test.js index a6bb0920449e4..2ae7207bb9103 100644 --- a/tests/api.test.js +++ b/tests/api.test.js @@ -2,7 +2,7 @@ import { jest } from "@jest/globals"; import axios from "axios"; import MockAdapter from "axios-mock-adapter"; import api from "../api/index.js"; -import { calculateRank } from "../src/calculateRank.js"; +import { calculateRank } from "../src/fetchers/helpers/calculateRank.js"; import { renderStatsCard } from "../src/cards/stats-card.js"; import { CONSTANTS, renderError } from "../src/common/utils.js"; diff --git a/tests/calculateRank.test.js b/tests/calculateRank.test.js index 5cc19a02aa73b..e7ed020c9f75a 100644 --- a/tests/calculateRank.test.js +++ b/tests/calculateRank.test.js @@ -1,5 +1,5 @@ import "@testing-library/jest-dom"; -import { calculateRank } from "../src/calculateRank.js"; +import { calculateRank } from "../src/fetchers/helpers/calculateRank.js"; describe("Test calculateRank", () => { it("should calculate rank correctly", () => { diff --git a/tests/fetchStats.test.js b/tests/fetchStats.test.js index 192146ea5fbe0..801934be324c6 100644 --- a/tests/fetchStats.test.js +++ b/tests/fetchStats.test.js @@ -1,7 +1,7 @@ import "@testing-library/jest-dom"; import axios from "axios"; import MockAdapter from "axios-mock-adapter"; -import { calculateRank } from "../src/calculateRank.js"; +import { calculateRank } from "../src/fetchers/helpers/calculateRank.js"; import { fetchStats } from "../src/fetchers/stats-fetcher.js"; const data = {