Skip to content

Commit a64a2c4

Browse files
authored
Merge pull request #112 from JacobLinCool/upgrade
Upgrade deps and support self-hosting docker image
2 parents 2079265 + 9b4689c commit a64a2c4

34 files changed

+5038
-4637
lines changed

.github/workflows/pr_check.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,10 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v3
15-
16-
- name: Cache PNPM Modules
17-
uses: actions/cache@v3
18-
with:
19-
path: ~/.pnpm-store
20-
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
21-
restore-keys: |
22-
${{ runner.os }}-pnpm-
14+
uses: actions/checkout@v4
2315

2416
- name: Setup PNPM
25-
uses: pnpm/action-setup@v2.2.4
17+
uses: pnpm/action-setup@v3
2618
with:
2719
run_install: true
2820

.github/workflows/publish.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,17 @@ jobs:
1414
name: Deploy
1515
steps:
1616
- name: Checkout Repository
17-
uses: actions/checkout@v3
18-
19-
- name: Cache PNPM Modules
20-
uses: actions/cache@v3
21-
with:
22-
path: ~/.pnpm-store
23-
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
24-
restore-keys: |
25-
${{ runner.os }}-pnpm-
17+
uses: actions/checkout@v4
2618

2719
- name: Setup PNPM
28-
uses: pnpm/action-setup@v2.2.4
20+
uses: pnpm/action-setup@v3
2921
with:
3022
run_install: true
3123

3224
- name: Build Worker
3325
run: pnpm build
3426

3527
- name: Publish to Cloudflare
36-
uses: cloudflare/wrangler-action@1.3.0
28+
uses: cloudflare/wrangler-action@v3
3729
with:
3830
apiToken: ${{ secrets.CF_API_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@ lib/
8080
**/.DS_Store
8181
.wrangler/
8282

83+
worker.capnp
84+
.storage/

.hadolint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ignored:
2+
- DL3007
3+
- DL3045

.husky/pre-commit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pnpm i --frozen-lockfile
2+
pnpm build
3+
pnpm lint-staged

.prettierrc.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,4 @@ overrides:
1010
options:
1111
tabWidth: 2
1212
plugins:
13-
- "./node_modules/@trivago/prettier-plugin-sort-imports/lib/src/index.js"
14-
15-
# sort-imports plugin
16-
importOrder:
17-
- "^node:"
18-
- "^[^@.]"
19-
- "^@"
20-
- "^\\."
21-
importOrderSortSpecifiers: true
13+
- prettier-plugin-organize-imports

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM jacoblincool/workerd:latest
2+
3+
COPY ./worker.capnp ./worker.capnp
4+
5+
CMD ["serve", "--experimental", "--binary", "worker.capnp"]

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ LeetCode and LeetCode CN are both supported.
2222

2323
It also has a [NPM package](https://www.npmjs.com/package/leetcode-card) and a [highly extensible system](./src/core/index.ts), so you can easily customize it to your needs.
2424

25-
CLI tool will be created if I have time.
2625
Want to contribute? Feel free to open a pull request!
2726

27+
## Self-hosting
28+
29+
You can also self-host this service using the [`jacoblincool/leetcode-stats-card`](https://hub.docker.com/r/jacoblincool/leetcode-stats-card) Docker image.
30+
31+
To build the image by yourself, use `pnpm build:image` script.
32+
33+
See [docker-compose.yml](./docker-compose.yml) for an example.
34+
2835
## Usage
2936

3037
Simply copy the code below, paste it into your `README.md`, and change the path to your leetcode username (case-insensitive).

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3.8"
2+
3+
services:
4+
worker:
5+
build: .
6+
image: jacoblincool/leetcode-stats-card
7+
volumes:
8+
- ./.storage/cache:/worker/cache
9+
ports:
10+
- "8080:8080"

eslint.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @ts-check
2+
3+
import eslint from "@eslint/js";
4+
import prettier from "eslint-config-prettier";
5+
import tseslint from "typescript-eslint";
6+
7+
export default tseslint.config(
8+
eslint.configs.recommended,
9+
...tseslint.configs.recommended,
10+
prettier,
11+
{
12+
ignores: ["dist/**.js", "lib/**.js"],
13+
},
14+
);

0 commit comments

Comments
 (0)