Skip to content

Commit b453454

Browse files
authored
chore: upgrade vite (#429)
1 parent 2680609 commit b453454

File tree

12 files changed

+472
-570
lines changed

12 files changed

+472
-570
lines changed

.github/workflows/build-preview-docker-image.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ jobs:
2727

2828
steps:
2929
- name: Checkout code (commit from CI run)
30-
uses: actions/checkout@v4
30+
uses: actions/checkout@v5
3131
with:
3232
ref: ${{ github.event.workflow_run.head_sha }}
3333

3434
- name: Set up QEMU
35-
uses: docker/setup-qemu-action@v3
35+
uses: docker/setup-qemu-action@v4
3636

3737
- name: Set up Docker Buildx
38-
uses: docker/setup-buildx-action@v3
38+
uses: docker/setup-buildx-action@v4
3939

4040
- name: Login to GitHub Container Registry
41-
uses: docker/login-action@v3
41+
uses: docker/login-action@v4
4242
with:
4343
registry: ghcr.io
4444
username: ${{ github.repository_owner }}
@@ -49,14 +49,14 @@ jobs:
4949
version: 10
5050

5151
- name: Setup Node.js
52-
uses: actions/setup-node@v4
52+
uses: actions/setup-node@v6
5353
with:
5454
node-version: ${{ env.NODE_VERSION }}
5555
cache: "pnpm"
5656
cache-dependency-path: ui/pnpm-lock.yaml
5757

5858
- name: Setup Go
59-
uses: actions/setup-go@v5
59+
uses: actions/setup-go@v6
6060
with:
6161
go-version: ${{ env.GO_VERSION }}
6262
cache: true
@@ -75,7 +75,7 @@ jobs:
7575
run: make cross-compile
7676

7777
- name: Build and push Docker image
78-
uses: docker/build-push-action@v6
78+
uses: docker/build-push-action@v7
7979
with:
8080
context: .
8181
file: ./Dockerfile.binary

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ jobs:
5050

5151
steps:
5252
- name: Checkout code
53-
uses: actions/checkout@v4
53+
uses: actions/checkout@v5
5454

5555
- uses: pnpm/action-setup@v4
5656
with:
5757
version: 10
5858
- name: Setup Node.js
59-
uses: actions/setup-node@v4
59+
uses: actions/setup-node@v6
6060
with:
6161
node-version: ${{ env.NODE_VERSION }}
6262
cache: "pnpm"
6363
cache-dependency-path: ui/pnpm-lock.yaml
6464

6565
- name: Setup Go
66-
uses: actions/setup-go@v5
66+
uses: actions/setup-go@v6
6767
with:
6868
go-version: ${{ env.GO_VERSION }}
6969
cache: true

.github/workflows/docs-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v4
18+
uses: actions/checkout@v5
1919
with:
2020
fetch-depth: 0
2121
- uses: pnpm/action-setup@v3

.github/workflows/release.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,36 @@ jobs:
2424

2525
steps:
2626
- name: Checkout code
27-
uses: actions/checkout@v4
27+
uses: actions/checkout@v5
2828
- name: Login to GitHub Container Registry
29-
uses: docker/login-action@v3
29+
uses: docker/login-action@v4
3030
with:
3131
registry: ghcr.io
3232
username: ${{ github.actor }}
3333
password: ${{ secrets.GITHUB_TOKEN }}
3434
- name: Login to Docker hub Registry
35-
uses: docker/login-action@v3
35+
uses: docker/login-action@v4
3636
with:
3737
username: ${{ secrets.DOCKER_USERNAME }}
3838
password: ${{ secrets.DOCKER_PASSWORD }}
3939

4040
- name: Set up QEMU
41-
uses: docker/setup-qemu-action@v3
41+
uses: docker/setup-qemu-action@v4
4242
- name: Set up Docker Buildx
43-
uses: docker/setup-buildx-action@v3
43+
uses: docker/setup-buildx-action@v4
4444

4545
- uses: pnpm/action-setup@v4
4646
with:
4747
version: 10
4848
- name: Setup Node.js
49-
uses: actions/setup-node@v4
49+
uses: actions/setup-node@v6
5050
with:
5151
node-version: ${{ env.NODE_VERSION }}
5252
cache: "pnpm"
5353
cache-dependency-path: ui/pnpm-lock.yaml
5454

5555
- name: Setup Go
56-
uses: actions/setup-go@v5
56+
uses: actions/setup-go@v6
5757
with:
5858
go-version: ${{ env.GO_VERSION }}
5959
cache: true
@@ -75,7 +75,7 @@ jobs:
7575
run: make package-binaries
7676

7777
- name: Build and push image
78-
uses: docker/build-push-action@v6
78+
uses: docker/build-push-action@v7
7979
with:
8080
context: .
8181
file: ./Dockerfile.binary
@@ -117,7 +117,7 @@ jobs:
117117
contents: write
118118
steps:
119119
- name: Checkout gh-pages
120-
uses: actions/checkout@v4
120+
uses: actions/checkout@v5
121121
with:
122122
ref: gh-pages
123123
fetch-depth: 0

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20-alpine AS frontend-builder
1+
FROM node:24-alpine AS frontend-builder
22

33
WORKDIR /app/ui
44

pkg/utils/utils.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ package utils
22

33
import (
44
"fmt"
5+
"html"
56
"regexp"
67
"strings"
78

89
"k8s.io/apimachinery/pkg/util/rand"
910
)
1011

12+
const kiteBasePlaceholder = "__KITE_BASE__"
13+
1114
func InjectAnalytics(htmlContent string) string {
1215
analyticsScript := `<script defer src="https://cloud.umami.is/script.js" data-website-id="c3d8a914-abbc-4eed-9699-a9192c4bef9e" data-exclude-search="true" data-exclude-hash="true" data-do-not-track="true"></script>`
1316

@@ -16,7 +19,14 @@ func InjectAnalytics(htmlContent string) string {
1619
}
1720

1821
func InjectKiteBase(htmlContent string, base string) string {
19-
baseScript := fmt.Sprintf(`<script>window.__dynamic_base__='%s';</script>`, base)
22+
assetBase := base
23+
if assetBase == "/" {
24+
assetBase = ""
25+
}
26+
27+
htmlContent = strings.ReplaceAll(htmlContent, kiteBasePlaceholder, html.EscapeString(assetBase))
28+
29+
baseScript := fmt.Sprintf(`<script>window.__dynamic_base__=%q;</script>`, assetBase)
2030
re := regexp.MustCompile(`<head>`)
2131
return re.ReplaceAllString(htmlContent, "<head>\n "+baseScript)
2232
}

pkg/utils/utils_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,64 @@
11
package utils
22

33
import (
4+
"strings"
45
"testing"
56

67
"k8s.io/apimachinery/pkg/util/validation"
78
)
89

10+
func TestInjectKiteBase(t *testing.T) {
11+
html := `<html><head><link rel="modulepreload" href="__KITE_BASE__/assets/index.js"><script type="module" src="__KITE_BASE__/assets/main.js"></script></head></html>`
12+
13+
t.Run("subpath", func(t *testing.T) {
14+
got := InjectKiteBase(html, "/kite")
15+
16+
if strings.Contains(got, "__KITE_BASE__") {
17+
t.Fatalf("placeholder should be replaced: %s", got)
18+
}
19+
if strings.Contains(got, "<base ") {
20+
t.Fatalf("base tag should not be injected anymore: %s", got)
21+
}
22+
if !strings.Contains(got, `href="/kite/assets/index.js"`) {
23+
t.Fatalf("expected asset href to include subpath: %s", got)
24+
}
25+
if !strings.Contains(got, `src="/kite/assets/main.js"`) {
26+
t.Fatalf("expected asset src to include subpath: %s", got)
27+
}
28+
if !strings.Contains(got, `<script>window.__dynamic_base__="/kite";</script>`) {
29+
t.Fatalf("expected runtime base script: %s", got)
30+
}
31+
})
32+
33+
t.Run("root", func(t *testing.T) {
34+
got := InjectKiteBase(html, "")
35+
36+
if !strings.Contains(got, `href="/assets/index.js"`) {
37+
t.Fatalf("expected root asset href: %s", got)
38+
}
39+
if !strings.Contains(got, `src="/assets/main.js"`) {
40+
t.Fatalf("expected root asset src: %s", got)
41+
}
42+
if !strings.Contains(got, `<script>window.__dynamic_base__="";</script>`) {
43+
t.Fatalf("expected empty runtime base script: %s", got)
44+
}
45+
})
46+
47+
t.Run("escapes html attribute injection", func(t *testing.T) {
48+
got := InjectKiteBase(html, `/ki"te`)
49+
50+
if strings.Contains(got, `href="/ki"te/assets/index.js"`) {
51+
t.Fatalf("expected asset href to be escaped: %s", got)
52+
}
53+
if !strings.Contains(got, `href="/ki&#34;te/assets/index.js"`) {
54+
t.Fatalf("expected escaped quote in asset href: %s", got)
55+
}
56+
if !strings.Contains(got, `<script>window.__dynamic_base__="/ki\"te";</script>`) {
57+
t.Fatalf("expected runtime base script to remain safely quoted: %s", got)
58+
}
59+
})
60+
}
61+
962
func TestGetImageRegistryAndRepo(t *testing.T) {
1063
testcase := []struct {
1164
image string

ui/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",
6+
"engines": {
7+
"node": "^20.19.0 || >=22.12.0"
8+
},
69
"scripts": {
710
"dev": "vite",
811
"build": "tsc -b && vite build",
@@ -29,7 +32,7 @@
2932
"@radix-ui/react-toggle-group": "^1.1.11",
3033
"@radix-ui/react-tooltip": "^1.2.8",
3134
"@tabler/icons-react": "^3.40.0",
32-
"@tailwindcss/vite": "^4.2.1",
35+
"@tailwindcss/vite": "^4.2.2",
3336
"@tanstack/react-query": "^5.90.21",
3437
"@tanstack/react-table": "^8.21.3",
3538
"@xterm/addon-fit": "^0.11.0",
@@ -57,7 +60,7 @@
5760
"remark-gfm": "^4.0.1",
5861
"sonner": "^2.0.7",
5962
"tailwind-merge": "^3.5.0",
60-
"tailwindcss": "^4.2.1"
63+
"tailwindcss": "^4.2.2"
6164
},
6265
"devDependencies": {
6366
"@eslint/js": "^9.39.4",
@@ -78,7 +81,6 @@
7881
"tw-animate-css": "^1.4.0",
7982
"typescript": "~5.9.3",
8083
"typescript-eslint": "^8.57.1",
81-
"vite": "^7.3.1",
82-
"vite-plugin-dynamic-base": "^1.3.0"
84+
"vite": "^8.0.1"
8385
}
8486
}

0 commit comments

Comments
 (0)