diff --git a/.github/labeler.yml b/.github/labeler.yml index 5b2a4b9c..be97765f 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,3 +1,3 @@ themes: themes/index.js doc-translation: docs/* -card-i18n: src/assets/translations.js +card-i18n: src/translations.js diff --git a/api/index.js b/api/index.js index 24f3ee61..b449d43b 100644 --- a/api/index.js +++ b/api/index.js @@ -8,7 +8,7 @@ import { renderError, } from "../src/common/utils.js"; import { fetchStats } from "../src/fetchers/stats-fetcher.js"; -import { isLocaleAvailable } from "../src/assets/translations.js"; +import { isLocaleAvailable } from "../src/translations.js"; export default async (req, res) => { const { diff --git a/api/pin.js b/api/pin.js index 9c336737..4838b0f0 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/assets/translations.js"; +import { isLocaleAvailable } from "../src/translations.js"; export default async (req, res) => { const { diff --git a/api/top-langs.js b/api/top-langs.js index d621a1b1..d183d3b4 100644 --- a/api/top-langs.js +++ b/api/top-langs.js @@ -8,7 +8,7 @@ import { renderError, } from "../src/common/utils.js"; import { fetchTopLanguages } from "../src/fetchers/top-languages-fetcher.js"; -import { isLocaleAvailable } from "../src/assets/translations.js"; +import { isLocaleAvailable } from "../src/translations.js"; export default async (req, res) => { const { diff --git a/api/wakatime.js b/api/wakatime.js index e5dde3f4..d439c5b7 100644 --- a/api/wakatime.js +++ b/api/wakatime.js @@ -7,7 +7,7 @@ import { renderError, } from "../src/common/utils.js"; import { fetchWakatimeStats } from "../src/fetchers/wakatime-fetcher.js"; -import { isLocaleAvailable } from "../src/assets/translations.js"; +import { isLocaleAvailable } from "../src/translations.js"; export default async (req, res) => { const { diff --git a/src/cards/repo-card.js b/src/cards/repo-card.js index 394144de..a306c1d5 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 "../assets/translations.js"; +import { repoCardLocales } from "../translations.js"; /** * Retrieves the repository description and wraps it to fit the card width. diff --git a/src/cards/stats-card.js b/src/cards/stats-card.js index 0a2e6cc4..af40a851 100644 --- a/src/cards/stats-card.js +++ b/src/cards/stats-card.js @@ -10,7 +10,7 @@ import { measureText, } from "../common/utils.js"; import { getStyles } from "../common/getStyles.js"; -import { statCardLocales } from "../assets/translations.js"; +import { statCardLocales } from "../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 7e26c620..602d1b81 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 "../assets/translations.js"; +import { langCardLocales } from "../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 3407f7a5..531885b9 100644 --- a/src/cards/wakatime-card.js +++ b/src/cards/wakatime-card.js @@ -9,7 +9,7 @@ import { lowercaseTrim, } from "../common/utils.js"; import { getStyles } from "../common/getStyles.js"; -import { wakatimeCardLocales } from "../assets/translations.js"; +import { wakatimeCardLocales } from "../translations.js"; /** Import language colors. * diff --git a/src/fetchers/helpers/calculateRank.js b/src/common/calculateRank.js similarity index 100% rename from src/fetchers/helpers/calculateRank.js rename to src/common/calculateRank.js diff --git a/src/common/retryer.js b/src/common/retryer.js index 73833ef8..5351cbe8 100644 --- a/src/common/retryer.js +++ b/src/common/retryer.js @@ -45,7 +45,9 @@ const retryer = async (fetcher, variables, retries = 0) => { // prettier-ignore // also checking for bad credentials if any tokens gets invalidated const isBadCredential = err.response.data && err.response.data.message === "Bad credentials"; - const isAccountSuspended = err.response.data && err.response.data.message === "Sorry. Your account was suspended."; + const isAccountSuspended = + err.response.data && + err.response.data.message === "Sorry. Your account was suspended."; if (isBadCredential || isAccountSuspended) { logger.log(`PAT_${retries + 1} Failed`); diff --git a/src/fetchers/stats-fetcher.js b/src/fetchers/stats-fetcher.js index 252127e0..ec88ce53 100644 --- a/src/fetchers/stats-fetcher.js +++ b/src/fetchers/stats-fetcher.js @@ -1,7 +1,7 @@ // @ts-check import axios from "axios"; import githubUsernameRegex from "github-username-regex"; -import { calculateRank } from "./helpers/calculateRank.js"; +import { calculateRank } from "../common/calculateRank.js"; import { retryer } from "../common/retryer.js"; import { CustomError, diff --git a/src/assets/translations.js b/src/translations.js similarity index 99% rename from src/assets/translations.js rename to src/translations.js index b13bc570..45c8295e 100644 --- a/src/assets/translations.js +++ b/src/translations.js @@ -1,4 +1,4 @@ -import { encodeHTML } from "../common/utils.js"; +import { encodeHTML } from "./common/utils.js"; /** * Retrieves stat card labels in the available locales. diff --git a/tests/api.test.js b/tests/api.test.js index 53c82177..733bebc9 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/fetchers/helpers/calculateRank.js"; +import { calculateRank } from "../src/common/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 89059d3b..fb68dc1f 100644 --- a/tests/calculateRank.test.js +++ b/tests/calculateRank.test.js @@ -1,5 +1,5 @@ import "@testing-library/jest-dom"; -import { calculateRank } from "../src/fetchers/helpers/calculateRank.js"; +import { calculateRank } from "../src/common/calculateRank.js"; describe("Test calculateRank", () => { it("should calculate rank correctly", () => { diff --git a/tests/fetchStats.test.js b/tests/fetchStats.test.js index 801934be..84b8b61f 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/fetchers/helpers/calculateRank.js"; +import { calculateRank } from "../src/common/calculateRank.js"; import { fetchStats } from "../src/fetchers/stats-fetcher.js"; const data = {