From 61466d0af47a1876595ac4228247445ac4ef8e8c Mon Sep 17 00:00:00 2001 From: luojiyin Date: Sat, 25 Jul 2026 09:48:06 +0800 Subject: [PATCH 1/2] fix: unify Deno imports with JSR --- deno.json | 8 +++++++- deps.ts | 22 +++++----------------- main.ts | 2 +- render_svg.ts | 11 +++++------ vercel.json | 24 ++++++++++++------------ 5 files changed, 30 insertions(+), 37 deletions(-) diff --git a/deno.json b/deno.json index 2424e78a..2095767d 100644 --- a/deno.json +++ b/deno.json @@ -7,6 +7,12 @@ "test": "ENV_TYPE=test deno test --allow-env" }, "imports": { - "@std/dotenv": "jsr:@std/dotenv@^0.224.0" + "@std/assert": "jsr:@std/assert@^1.0.19", + "@std/dotenv": "jsr:@std/dotenv@^0.225.7", + "@std/http": "jsr:@std/http@^1.1.2", + "@std/testing": "jsr:@std/testing@^1.0.19", + "@redis": "https://deno.land/x/redis@v0.31.0/mod.ts", + "@soxa": "https://deno.land/x/soxa@1.4/src/core/Soxa.ts", + "@soxa/defaults": "https://deno.land/x/soxa@1.4/src/defaults.ts" } } diff --git a/deps.ts b/deps.ts index 646eaf28..c1a5999c 100644 --- a/deps.ts +++ b/deps.ts @@ -1,21 +1,9 @@ -import { Soxa as ServiceProvider } from "https://deno.land/x/soxa@1.4/src/core/Soxa.ts"; -import { defaults } from "https://deno.land/x/soxa@1.4/src/defaults.ts"; -import { - assertEquals, - assertRejects, -} from "https://deno.land/std@0.203.0/assert/mod.ts"; -import { - assertSpyCalls, - returnsNext, - spy, - stub, -} from "https://deno.land/std@0.203.0/testing/mock.ts"; +import { Soxa as ServiceProvider } from "@soxa"; +import { defaults } from "@soxa/defaults"; +import { assertEquals, assertRejects } from "@std/assert"; +import { assertSpyCalls, returnsNext, spy, stub } from "@std/testing/mock"; -export { - type Bulk, - connect, - type Redis, -} from "https://deno.land/x/redis@v0.31.0/mod.ts"; +export { type Bulk, connect, type Redis } from "@redis"; import { CONSTANTS } from "./src/utils.ts"; diff --git a/main.ts b/main.ts index 01634881..20277c86 100644 --- a/main.ts +++ b/main.ts @@ -1,4 +1,4 @@ -import { serve } from "https://deno.land/std@0.224.0/http/server.ts"; +import { serve } from "@std/http/server"; import requestHandler from "./api/index.ts"; serve(requestHandler, { port: Number(Deno.env.get("PORT")) || 8080 }); diff --git a/render_svg.ts b/render_svg.ts index f870eee8..893fefcf 100644 --- a/render_svg.ts +++ b/render_svg.ts @@ -1,4 +1,4 @@ -import "https://deno.land/x/dotenv@v0.5.0/load.ts"; +import "@std/dotenv/load"; const username = Deno.args[0]; const outputPath = Deno.args[1] ?? "./assets/trophy.svg"; @@ -14,6 +14,7 @@ if (!username) { import { GithubApiService } from "./src/Services/GithubApiService.ts"; import { Card } from "./src/card.ts"; import { COLORS } from "./src/theme.ts"; +import { UserInfo } from "./src/user_info.ts"; async function main() { console.log("Starting trophy render..."); @@ -25,16 +26,14 @@ async function main() { const userInfoOrError = await svc.requestUserInfo(username); - if ( - !(userInfoOrError && (userInfoOrError as any).totalCommits !== undefined) - ) { + if (!(userInfoOrError instanceof UserInfo)) { console.error( "Failed to fetch user info. Check token, username and rate limits.", ); Deno.exit(2); } - const userInfo = userInfoOrError as any; + const userInfo = userInfoOrError; const panelSize = 115; const maxRow = 10; @@ -55,7 +54,7 @@ async function main() { noBackground, noFrame, ); - const theme = (COLORS as any)[themeName] ?? (COLORS as any).default; + const theme = COLORS[themeName] ?? COLORS.default; const svg = card.render(userInfo, theme); try { diff --git a/vercel.json b/vercel.json index 254f68dc..9d04af20 100644 --- a/vercel.json +++ b/vercel.json @@ -1,14 +1,14 @@ { - "functions": { - "api/**/*.[jt]s": { - "runtime": "vercel-deno@3.1.1", - "maxDuration": 5 - } - }, - "rewrites": [ - { - "source": "/(.*)", - "destination": "/api/$1" - } - ] + "functions": { + "api/**/*.[jt]s": { + "runtime": "vercel-deno@3.1.1", + "maxDuration": 5 + } + }, + "rewrites": [ + { + "source": "/(.*)", + "destination": "/api/$1" + } + ] } From e971da3df0ecb9648e0b32984475de9e3de579c5 Mon Sep 17 00:00:00 2001 From: luojiyin Date: Sat, 25 Jul 2026 10:26:41 +0800 Subject: [PATCH 2/2] ci: test Deno 1 and 2 --- .github/workflows/testing.yml | 8 ++++---- deno.json | 3 +++ vercel.json | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 459aaa51..6028324d 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - deno-version: ["1.44.4"] + deno-version: ["1.44.4", "2.x"] steps: # Step 1: Checkout repository @@ -24,7 +24,7 @@ jobs: # Step 2: Setup Deno - name: Setup Deno - uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@v2 with: deno-version: ${{ matrix.deno-version }} @@ -37,9 +37,9 @@ jobs: - name: Deno format check run: deno fmt --check - # Step 5: Lint check (won't fail workflow) + # Step 5: Lint check - name: Deno lint check - run: deno lint || true + run: deno lint # Step 6: Run tests - name: Test Deno Module diff --git a/deno.json b/deno.json index 2095767d..d7bd9424 100644 --- a/deno.json +++ b/deno.json @@ -6,6 +6,9 @@ "lint": "deno lint", "test": "ENV_TYPE=test deno test --allow-env" }, + "fmt": { + "indentWidth": 2 + }, "imports": { "@std/assert": "jsr:@std/assert@^1.0.19", "@std/dotenv": "jsr:@std/dotenv@^0.225.7", diff --git a/vercel.json b/vercel.json index 9d04af20..254f68dc 100644 --- a/vercel.json +++ b/vercel.json @@ -1,14 +1,14 @@ { - "functions": { - "api/**/*.[jt]s": { - "runtime": "vercel-deno@3.1.1", - "maxDuration": 5 - } - }, - "rewrites": [ - { - "source": "/(.*)", - "destination": "/api/$1" - } - ] + "functions": { + "api/**/*.[jt]s": { + "runtime": "vercel-deno@3.1.1", + "maxDuration": 5 + } + }, + "rewrites": [ + { + "source": "/(.*)", + "destination": "/api/$1" + } + ] }