Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ To set up the project GitHub-Stats-Extended locally, run the following commands:
```bash
./vercel-preparation.sh
pnpm install
pnpm --filter ./apps/frontend/ run build
pnpm run build:packages
pnpm run dev:frontend
```

The easiest way to run and test the project is to deploy it to Vercel as described in the [deployment guide](../docs/deploy.md).
Expand Down
22 changes: 13 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- master
- npm-package
Comment thread
martin-mfg marked this conversation as resolved.

concurrency:
group: "${{ github.workflow }}-${{ github.head_ref }}"
Expand Down Expand Up @@ -43,17 +44,14 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Run backend and core tests
run: pnpm run test
- name: Build packages
run: pnpm run build:packages

- name: Build frontend
run: pnpm --filter ./apps/frontend/ run build
Comment thread
marcalexiei marked this conversation as resolved.
run: pnpm run build:frontend

- name: Run frontend tests
run: pnpm --filter ./apps/frontend/ run test

- name: Run only core tests
run: pnpm --filter ./packages/core/ run test
- name: Run tests
run: pnpm run test --silent

frontend-test-e2e:
name: Frontend E2E test
Expand All @@ -72,14 +70,17 @@ jobs:
- name: Install Dependencies
uses: ./.github/actions/install-dependencies

- name: Build packages
run: pnpm run build:packages

- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps

- name: Run Playwright tests
run: pnpm --filter ./apps/frontend/ run test:e2e

backend-test-e2e:
name: end-to-end backend test
name: Backend E2E test

runs-on: ubuntu-latest

Expand All @@ -95,6 +96,9 @@ jobs:
- name: Install Dependencies
uses: ./.github/actions/install-dependencies

- name: Build packages
run: pnpm run build:packages

- name: Run backend end-to-end tests
run: pnpm --filter ./apps/backend/ run test:e2e

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-theme-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- master
paths:
- "packages/core/themes/index.js"
- "packages/core/src/themes/index.js"
workflow_dispatch:

permissions: {}
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ apps/backend/vercel_token
apps/backend-copy

apps/frontend/.env
apps/frontend/build


.turbo
build
build-ts
tsconfig.tsbuildinfo
*.tsbuildinfo

# IDE
.idea/
Expand Down
5 changes: 3 additions & 2 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
"test": "vitest",
"test:update:snapshot": "vitest -u",
"test:e2e": "vitest --config vitest.config.e2e.ts",
"bench": "vitest bench --run --config vitest.config.bench.ts"
"bench": "vitest bench --run --config vitest.config.bench.ts",
"lint": "eslint",
"typecheck": "tsc -p tsconfig.typecheck.json"
},
"devDependencies": {
"@vitest/coverage-v8": "catalog:default",
"axios-mock-adapter": "2.1.0",
"express": "5.2.1",
"jsdom": "28.1.0",
Expand Down
7 changes: 7 additions & 0 deletions apps/backend/tsconfig.typecheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["./tsconfig.json"],
"compilerOptions": {
"noEmit": true,
"customConditions": []
}
}
2 changes: 1 addition & 1 deletion apps/backend/vercel.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"buildCommand": "cd ../../ && git clean ./apps -fx && pnpm --filter ./apps/backend/ --legacy deploy ./apps/deployment/ && mv ./apps/deployment/node_modules/ ./apps/backend/node_modules/ && ./vercel-preparation.sh",
"buildCommand": "cd ../../ && git clean ./apps -fx && pnpm run build:packages && pnpm --filter ./apps/backend/ --legacy deploy ./apps/deployment/ && mv ./apps/deployment/node_modules/ ./apps/backend/node_modules/ && ./vercel-preparation.sh",
"redirects": [
{
"source": "/",
Expand Down
3 changes: 3 additions & 0 deletions apps/backend/vitest.config.bench.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
resolve: {
conditions: ["@stats/source"],
},
test: {
dir: "./tests/bench",
environment: "jsdom",
Expand Down
3 changes: 3 additions & 0 deletions apps/backend/vitest.config.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
resolve: {
conditions: ["@stats/source"],
},
test: {
environment: "node",
dir: "tests/e2e",
Expand Down
10 changes: 5 additions & 5 deletions apps/backend/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineConfig } from "vitest/config";
import { defineProject } from "vitest/config";

export default defineConfig({
export default defineProject({
resolve: {
conditions: ["@stats/source"],
},
test: {
coverage: {
enabled: true,
},
environment: "jsdom",
include: [
"./tests/*.test.{ts,js}",
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"preview": "vite preview",
"test": "vitest",
"test:e2e": "playwright test",
"typecheck": "tsc --noEmit"
"lint": "eslint",
"typecheck": "tsc -p tsconfig.typecheck.json"
},
"dependencies": {
"@reduxjs/toolkit": "^2.11.2",
Expand Down
20 changes: 3 additions & 17 deletions apps/frontend/src/pages/Home/stages/Theme.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
// @ts-expect-error type info should be added later
import { themes } from "@stats-organization/github-readme-stats-core";
import type { JSX } from "react";

import { Card } from "../../../components/Card/Card";

// to be removed once npm package has been created
type ThemeData = Record<
string,
{
title_color: string;
icon_color: string;
text_color: string;
bg_color: string;
border_color: string;
}
>;

const excludedThemes = [
"merko",
"blue-green",
Expand All @@ -25,10 +12,9 @@ const excludedThemes = [
"holi",
];

const themeList = Object.keys(
/* Needed until themes is typed correctly and retrieved from npm package */
themes as ThemeData,
).filter((myTheme) => !excludedThemes.includes(myTheme));
const themeList = Object.keys(themes).filter(
(myTheme) => !excludedThemes.includes(myTheme),
);

interface ThemeStageProps {
fullSuffix: string;
Expand Down
7 changes: 7 additions & 0 deletions apps/frontend/tsconfig.typecheck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["./tsconfig.json"],
"compilerOptions": {
"noEmit": true,
"customConditions": []
}
}
2 changes: 1 addition & 1 deletion apps/frontend/vercel.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"installCommand": "cd ../../ && git clean ./apps -fx && pnpm install && rm -rf ./apps/frontend/node_modules && pnpm --filter ./apps/frontend/ --legacy deploy ./apps/deployment/ && mv ./apps/deployment/node_modules/ ./apps/frontend/node_modules/",
"installCommand": "cd ../../ && git clean ./apps -fx && pnpm install && pnpm run build:packages && rm -rf ./apps/frontend/node_modules && pnpm --filter ./apps/frontend/ --legacy deploy ./apps/deployment/ && mv ./apps/deployment/node_modules/ ./apps/frontend/node_modules/",
"buildCommand": "pnpm run build",
"outputDirectory": "build"
}
7 changes: 4 additions & 3 deletions apps/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import path from "node:path";

import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vitest/config";
import { defineProject } from "vitest/config";

// https://vitejs.dev/config/
export default defineConfig({
export default defineProject({
base: "/frontend/",
plugins: [react(), tailwindcss()],
build: {
Expand All @@ -16,6 +16,7 @@ export default defineConfig({
chunkSizeWarningLimit: 800,
},
resolve: {
conditions: ["@stats/source"],
alias: [
{
find: "../src/fetchers/wakatime.js",
Expand All @@ -27,7 +28,7 @@ export default defineConfig({
],
},
test: {
dir: "./src",
dir: path.join(import.meta.dirname, "./src"),
exclude: ["**/backend/**"],
},
});
6 changes: 3 additions & 3 deletions docs/advanced_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GitHub Stats Extended comes with several built-in themes (e.g. `dark`, `radical`

<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Stats Extended Themes" width="600px"/>

You can look at a preview for [all available themes](../core/themes/README.md) or checkout the [theme config file](../core/themes/index.js). Please note that we paused the addition of new themes to decrease maintenance efforts; all pull requests related to new themes will be closed.
You can look at a preview for [all available themes](../packages/core/src/themes/README.md) or checkout the [theme config file](../packages/core/src/themes/index.js). Please note that we paused the addition of new themes to decrease maintenance efforts; all pull requests related to new themes will be closed.

#### Responsive Card Theme

Expand All @@ -102,7 +102,7 @@ We have included a `transparent` theme that has a transparent background. This t

##### Add transparent alpha channel to a themes bg\_color

You can use the `bg_color` parameter to make any of [the available themes](../core/themes/README.md) transparent. This is done by setting the `bg_color` to a color with a transparent alpha channel (i.e. `bg_color=00000000`):
You can use the `bg_color` parameter to make any of [the available themes](../packages/core/src/themes/README.md) transparent. This is done by setting the `bg_color` to a color with a transparent alpha channel (i.e. `bg_color=00000000`):

```md
![Anurag's GitHub stats](https://github-stats-extended.vercel.app/api?username=anuraghazra&show_icons=true&bg_color=00000000)
Expand Down Expand Up @@ -181,7 +181,7 @@ You can customize the appearance of all your cards however you wish with URL par
| `border_color` | Card's border color. Does not apply when `hide_border` is enabled. | string (hex color) | `e4e2e2` |
| `bg_color` | Card's background color. | string (hex color or a gradient in the form of *angle,start,end*) | `fffefe` |
| `hide_border` | Hides the card's border. | boolean | `false` |
| `theme` | Name of the theme, choose from [all available themes](../core/themes/README.md). | enum | `default` |
| `theme` | Name of the theme, choose from [all available themes](../packages/core/src/themes/README.md). | enum | `default` |
| `cache_seconds` | Sets the cache header manually (min: 21600, max: 86400). | integer | `21600` |
| `locale` | Sets the language in the card, you can check full list of available locales [here](#available-locales). | enum | `en` |
| `border_radius` | Corner rounding on the card. | number | `4.5` |
Expand Down
20 changes: 20 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fileURLToPath } from "node:url";
import { includeIgnoreFile } from "@eslint/compat";
import js from "@eslint/js";
import { defineConfig } from "eslint/config";
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
import { importX } from "eslint-plugin-import-x";
import { default as jsdoc } from "eslint-plugin-jsdoc";
import react from "eslint-plugin-react";
Expand All @@ -18,6 +19,25 @@ export default defineConfig(

{
extends: [importX.flatConfigs.recommended, importX.flatConfigs.typescript],
settings: {
"import-x/resolver-next": [
createTypeScriptImportResolver({
conditionNames: [
/** Keep in sync with `tsconfig.base.json#customConditions` */
"@stats/source",

"types",
"import",

"require",
"node",
"node-addons",
"browser",
"default",
],
}),
],
},
rules: {
"import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
"import-x/order": [
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,24 @@
"knip": "6.2.0",
"lint-staged": "16.4.0",
"prettier": "3.8.1",
"turbo": "2.9.3",
"typescript": "5.9.3",
"typescript-eslint": "8.58.0",
"vitest": "catalog:default"
},
"scripts": {
"test": "vitest",
"prepare": "husky",
"build:packages": "turbo run build --filter=./packages/*",
"build:frontend": "turbo run build --filter=./apps/frontend",
"dev:frontend": "pnpm run --filter=./apps/frontend dev",
"test": "vitest",
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint": "eslint",
"lint:fix": "eslint --fix",
"lint": "turbo run lint",
"lint:eslint": "eslint",
"lint:eslint:fix": "eslint --fix",
"lint:knip": "knip",
"typecheck": "tsc --build --noEmit"
"typecheck": "turbo run typecheck"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,css,json,jsonc,yaml,yml}": "prettier --write"
Expand Down
15 changes: 12 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,35 @@
"github-stats-extended",
"github-readme-stats-extended"
],
"main": "src/index.js",
"main": "./build/index.js",
"exports": {
".": "./src/index.js"
".": {
"@stats/source": "./src/index.ts",
Comment thread
martin-mfg marked this conversation as resolved.
"default": "./build/index.js"
}
},
"files": [
"build",
"src"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great that you found so quickly what was the problem with the vercel build.
Do I understand correctly that this configuration - where we now basically include the whole code twice - is only a temporary solution until "core" is converted to TS?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The Vercel installCommand runs pnpm --filter ./apps/frontend/ --legacy deploy ./apps/deployment/
  2. pnpm deploy packs workspace packages according to their files field, so packages/core only copies build/ not src/
  3. Vite then runs with conditions: ["@stats/source"], which resolves the core package to ./src/index.ts (per the exports map)
  4. That file doesn't exist in the deployed node_modules so build fails

I've added the conditions to vite.config to allow automatic test rerun.
Later I will fine a way to avoid have both src and build folders

],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"test": "vitest",
"test:update:snapshot": "vitest -u",
"test:e2e": "vitest --config vitest.config.e2e.ts",
"bench": "vitest bench --run --config vitest.config.bench.ts",
"lint": "eslint",
"typecheck": "tsc -p tsconfig.typecheck.json",
"theme-readme-gen": "node scripts/generate-theme-doc",
"generate-langs-json": "node scripts/generate-langs-json"
},
"devDependencies": {
"@testing-library/dom": "10.4.1",
"@testing-library/jest-dom": "6.9.1",
"@uppercod/css-to-object": "1.1.1",
"@vitest/coverage-v8": "catalog:default",
"axios-mock-adapter": "2.1.0",
"js-yaml": "4.1.1",
"jsdom": "28.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/scripts/generate-theme-doc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from "fs";

import { themes } from "../themes/index.js";
import { themes } from "../src/themes/index.js";

const TARGET_FILE = "./themes/README.md";
const TARGET_FILE = "./src/themes/README.md";
const REPO_CARD_LINKS_FLAG = "<!-- REPO_CARD_LINKS -->";
const STAT_CARD_LINKS_FLAG = "<!-- STATS_CARD_LINKS -->";

Expand Down
Loading