Skip to content

Commit ada4ab2

Browse files
committed
build: create npm package
This commit makes sure that the common modules of the GRS package can be imported as an npm package.
1 parent 15620a1 commit ada4ab2

20 files changed

+63
-19
lines changed

.github/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
themes: themes/index.js
22
doc-translation: docs/*
3-
card-i18n: src/translations.js
3+
card-i18n: src/assets/translations.js

api/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
renderError,
1010
} from "../src/common/utils.js";
1111
import { fetchStats } from "../src/fetchers/stats-fetcher.js";
12-
import { isLocaleAvailable } from "../src/translations.js";
12+
import { isLocaleAvailable } from "../src/assets/translations.js";
1313

1414
dotenv.config();
1515

api/pin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
renderError,
88
} from "../src/common/utils.js";
99
import { fetchRepo } from "../src/fetchers/repo-fetcher.js";
10-
import { isLocaleAvailable } from "../src/translations.js";
10+
import { isLocaleAvailable } from "../src/assets/translations.js";
1111

1212
export default async (req, res) => {
1313
const {

api/top-langs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
renderError,
1010
} from "../src/common/utils.js";
1111
import { fetchTopLanguages } from "../src/fetchers/top-languages-fetcher.js";
12-
import { isLocaleAvailable } from "../src/translations.js";
12+
import { isLocaleAvailable } from "../src/assets/translations.js";
1313

1414
dotenv.config();
1515

api/wakatime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
renderError,
99
} from "../src/common/utils.js";
1010
import { fetchWakatimeStats } from "../src/fetchers/wakatime-fetcher.js";
11-
import { isLocaleAvailable } from "../src/translations.js";
11+
import { isLocaleAvailable } from "../src/assets/translations.js";
1212

1313
dotenv.config();
1414

package.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
{
22
"name": "github-readme-stats",
33
"version": "1.0.0",
4-
"description": "Dynamically generate stats for your github readmes",
5-
"main": "index.js",
4+
"description": "Dynamically generate stats for your GitHub readme",
5+
"keywords": [
6+
"github-readme-stats",
7+
"readme-stats",
8+
"cards",
9+
"card-generator"
10+
],
11+
"main": "src/index.js",
612
"type": "module",
13+
"homepage": "https://github.com/anuraghazra/github-readme-stats",
14+
"bugs": {
15+
"url": "https://github.com/anuraghazra/github-readme-stats/issues"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "https://github.com/anuraghazra/github-readme-stats.git"
20+
},
721
"scripts": {
822
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
923
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",

src/translations.js renamed to src/assets/translations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { encodeHTML } from "./common/utils.js";
1+
import { encodeHTML } from "../common/utils.js";
22

33
const statCardLocales = ({ name, apostrophe }) => {
44
const encodedName = encodeHTML(name);

src/cards/repo-card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
parseEmojis,
1212
wrapTextMultiline,
1313
} from "../common/utils.js";
14-
import { repoCardLocales } from "../translations.js";
14+
import { repoCardLocales } from "../assets/translations.js";
1515

1616
/**
1717
* @param {string} label

src/cards/stats-card.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99
kFormatter,
1010
measureText,
1111
} from "../common/utils.js";
12-
import { getStyles } from "../getStyles.js";
13-
import { statCardLocales } from "../translations.js";
12+
import { getStyles } from "../common/getStyles.js";
13+
import { statCardLocales } from "../assets/translations.js";
1414

1515
/**
1616
* Create a stats card text item.

src/cards/top-languages-card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
lowercaseTrim,
1111
measureText,
1212
} from "../common/utils.js";
13-
import { langCardLocales } from "../translations.js";
13+
import { langCardLocales } from "../assets/translations.js";
1414

1515
const DEFAULT_CARD_WIDTH = 300;
1616
const MIN_CARD_WIDTH = 230;

src/cards/wakatime-card.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
getCardColors,
99
lowercaseTrim,
1010
} from "../common/utils.js";
11-
import { getStyles } from "../getStyles.js";
12-
import { wakatimeCardLocales } from "../translations.js";
11+
import { getStyles } from "../common/getStyles.js";
12+
import { wakatimeCardLocales } from "../assets/translations.js";
1313

1414
/** Import language colors.
1515
*

src/common/Card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getAnimations } from "../getStyles.js";
1+
import { getAnimations } from "./getStyles.js";
22
import { encodeHTML, flexLayout } from "./utils.js";
33

44
class Card {
File renamed without changes.

src/common/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export { blacklist } from "./blacklist.js";
2+
export { Card } from "./Card.js";
3+
export { createProgressNode } from "./createProgressNode.js";
4+
export { getStyles, getAnimations } from "./getStyles.js";
5+
export { i18n } from "./i18n.js";
6+
export { icons } from "./icons.js";
7+
export { retryer } from "./retryer.js";
8+
export {
9+
renderError,
10+
kFormatter,
11+
encodeHTML,
12+
isValidHexColor,
13+
request,
14+
parseArray,
15+
parseBoolean,
16+
fallbackColor,
17+
flexLayout,
18+
getCardColors,
19+
clampValue,
20+
wrapTextMultiline,
21+
measureText,
22+
logger,
23+
CONSTANTS,
24+
CustomError,
25+
MissingParamError,
26+
lowercaseTrim,
27+
chunkArray,
28+
parseEmojis,
29+
} from "./utils.js";
File renamed without changes.

src/fetchers/stats-fetcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import axios from "axios";
33
import * as dotenv from "dotenv";
44
import githubUsernameRegex from "github-username-regex";
5-
import { calculateRank } from "../calculateRank.js";
5+
import { calculateRank } from "./helpers/calculateRank.js";
66
import { retryer } from "../common/retryer.js";
77
import {
88
CustomError,

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./common/index.js";

tests/api.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { jest } from "@jest/globals";
22
import axios from "axios";
33
import MockAdapter from "axios-mock-adapter";
44
import api from "../api/index.js";
5-
import { calculateRank } from "../src/calculateRank.js";
5+
import { calculateRank } from "../src/fetchers/helpers/calculateRank.js";
66
import { renderStatsCard } from "../src/cards/stats-card.js";
77
import { CONSTANTS, renderError } from "../src/common/utils.js";
88

tests/calculateRank.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "@testing-library/jest-dom";
2-
import { calculateRank } from "../src/calculateRank.js";
2+
import { calculateRank } from "../src/fetchers/helpers/calculateRank.js";
33

44
describe("Test calculateRank", () => {
55
it("should calculate rank correctly", () => {

tests/fetchStats.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "@testing-library/jest-dom";
22
import axios from "axios";
33
import MockAdapter from "axios-mock-adapter";
4-
import { calculateRank } from "../src/calculateRank.js";
4+
import { calculateRank } from "../src/fetchers/helpers/calculateRank.js";
55
import { fetchStats } from "../src/fetchers/stats-fetcher.js";
66

77
const data = {

0 commit comments

Comments
 (0)