Compare commits

...

7 Commits

Author SHA1 Message Date
严浩
e82b8575d1 ci: 更新项目依赖并优化测试工作流 2025-09-12 12:14:33 +08:00
严浩
3b76e57df5 build(deps): 使用 rolldown-vite 包 2025-09-11 16:18:49 +08:00
严浩
eb600d0b6b chore(package): 更新依赖包版本 2025-09-11 16:18:05 +08:00
严浩
87e701042f ci: 优化 GitHub Actions 工作流并添加单元测试 2025-09-09 23:22:35 +08:00
严浩
306ed9a527 ci: 更新 Playwright 配置以使用预览服务器
- 将 baseURL 固定为 http://localhost:4173,不再根据环境变量区分 CI 和本地环境
- 修改启动命令为先构建再启动预览服务器
- 设置 reuseExistingServer 为 true,优化服务器重用逻辑

(cherry picked from commit df6ffb99c8)
2025-09-09 23:11:00 +08:00
严浩
56d8a3aa49 test(e2e): 添加 AppLayout 组件的测试用例 2025-09-09 22:50:57 +08:00
严浩
394294904d build(deps): 更新依赖并添加 .npmrc 配置 2025-09-09 22:48:04 +08:00
10 changed files with 400 additions and 323 deletions

2
.env
View File

@@ -1,2 +1,4 @@
VITE_BASE=/
VITE_BUILD_SOURCE_MAP=true
VITE_BUILD_COMMIT= VITE_BUILD_COMMIT=
VITE_BUILD_TIME= VITE_BUILD_TIME=

View File

@@ -28,6 +28,9 @@ jobs:
env: env:
VITE_BUILD_COMMIT: ${{ github.sha }} VITE_BUILD_COMMIT: ${{ github.sha }}
- name: 🧪 单元测试
run: pnpm run test:unit
- name: 📊 计算构建大小 - name: 📊 计算构建大小
run: | run: |
echo "📊 构建大小统计:" echo "📊 构建大小统计:"

View File

@@ -18,6 +18,8 @@ jobs:
uses: yanhao98/composite-actions/setup-node-environment@25eb4dc0c134cc9df2b7c569aa54140a366b45a8 uses: yanhao98/composite-actions/setup-node-environment@25eb4dc0c134cc9df2b7c569aa54140a366b45a8
# - name: 📥 安装 Playwright 浏览器 # - name: 📥 安装 Playwright 浏览器
# run: pnpm exec playwright install --with-deps # run: pnpm exec playwright install --with-deps
- name: 🔄 更新依赖
run: pnpm update --latest
- name: 📦 构建项目 - name: 📦 构建项目
run: pnpm run build-only run: pnpm run build-only
- name: ▶️ 运行 Playwright 测试 - name: ▶️ 运行 Playwright 测试

9
.npmrc Normal file
View File

@@ -0,0 +1,9 @@
registry=https://registry.npmmirror.com/
# https://pnpm.io/zh/npmrc#node-mirrorltreleasedir
use-node-version=24.7.0
node-mirror:release=https://npmmirror.com/mirrors/node/ # pnpm config set node-mirror:release=https://npmmirror.com/mirrors/node/
node-mirror:rc=https://npmmirror.com/mirrors/node-rc/
node-mirror:nightly=https://npmmirror.com/mirrors/node-nightly/
# shamefully-hoist=true

View File

@@ -50,4 +50,11 @@ test.describe('Vue App', () => {
await expect(button).toHaveText('Name from API is: Unknown') await expect(button).toHaveText('Name from API is: Unknown')
}) })
test('app-layout is present', async ({ page }) => {
await page.goto('/')
const appLayout = page.locator('.app-layout')
await expect(appLayout).toBeVisible()
await expect(appLayout).toContainText('AppLayout')
})
}) })

View File

@@ -49,13 +49,15 @@
] ]
}, },
"pnpm": { "pnpm": {
"overrides": {} "overrides": {
"vite": "$vite"
}
}, },
"dependencies": { "dependencies": {
"@commitlint/cli": "^19.8.1", "@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1", "@commitlint/config-conventional": "^19.8.1",
"@formkit/auto-animate": "^0.9.0", "@formkit/auto-animate": "^0.9.0",
"@pinia/colada": "^0.17.3", "@pinia/colada": "^0.17.4",
"@primeuix/themes": "^1.2.3", "@primeuix/themes": "^1.2.3",
"@unhead/vue": "^2.0.14", "@unhead/vue": "^2.0.14",
"@vueuse/core": "^13.9.0", "@vueuse/core": "^13.9.0",
@@ -69,12 +71,13 @@
"vue-router": "^4.5.1" "vue-router": "^4.5.1"
}, },
"devDependencies": { "devDependencies": {
"@cloudflare/vite-plugin": "^1.12.3", "@cloudflare/vite-plugin": "^1.12.4",
"@commitlint/types": "^19.8.1", "@commitlint/types": "^19.8.1",
"@intlify/unplugin-vue-i18n": "^11.0.0", "@intlify/unplugin-vue-i18n": "^11.0.0",
"@playwright/test": "^1.55.0", "@playwright/test": "^1.55.0",
"@prettier/plugin-oxc": "^0.0.4", "@prettier/plugin-oxc": "^0.0.4",
"@primevue/auto-import-resolver": "^4.3.9", "@primevue/auto-import-resolver": "^4.3.9",
"@primevue/metadata": "^4.3.9",
"@tsconfig/node22": "^22.0.2", "@tsconfig/node22": "^22.0.2",
"@types/jsdom": "^21.1.7", "@types/jsdom": "^21.1.7",
"@types/node": "^22.18.1", "@types/node": "^22.18.1",
@@ -98,7 +101,6 @@
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"oxlint": "~1.14.0", "oxlint": "~1.14.0",
"prettier": "3.6.2", "prettier": "3.6.2",
"rolldown": "1.0.0-beta.36",
"typescript": "~5.9.2", "typescript": "~5.9.2",
"unocss": "^66.5.1", "unocss": "^66.5.1",
"unocss-preset-animations": "^1.2.1", "unocss-preset-animations": "^1.2.1",
@@ -107,7 +109,7 @@
"unplugin-vue-components": "^29.0.0", "unplugin-vue-components": "^29.0.0",
"unplugin-vue-markdown": "^29.1.0", "unplugin-vue-markdown": "^29.1.0",
"unplugin-vue-router": "^0.15.0", "unplugin-vue-router": "^0.15.0",
"vite": "^7.1.5", "vite": "npm:rolldown-vite@^7.1.9",
"vite-plugin-checker": "^0.10.3", "vite-plugin-checker": "^0.10.3",
"vite-plugin-fake-server": "^2.2.0", "vite-plugin-fake-server": "^2.2.0",
"vite-plugin-image-optimizer": "^2.0.2", "vite-plugin-image-optimizer": "^2.0.2",
@@ -117,6 +119,6 @@
"vitest": "^3.2.4", "vitest": "^3.2.4",
"vue-macros": "3.0.0-beta.23", "vue-macros": "3.0.0-beta.23",
"vue-tsc": "^3.0.6", "vue-tsc": "^3.0.6",
"wrangler": "^4.34.0" "wrangler": "^4.35.0"
} }
} }

View File

@@ -2,7 +2,7 @@ import { defineConfig, devices } from '@playwright/test'
import process from 'node:process' import process from 'node:process'
// const runningInVSCode = process.env.TERM_PROGRAM === 'vscode' // const runningInVSCode = process.env.TERM_PROGRAM === 'vscode'
const baseURL = process.env.CI ? 'http://localhost:4173' : 'http://localhost:4730' const baseURL = 'http://localhost:4173'
/** /**
* Read environment variables from file. * Read environment variables from file.
@@ -106,8 +106,8 @@ export default defineConfig({
* Use the preview server on CI for more realistic testing. * Use the preview server on CI for more realistic testing.
* Playwright will re-use the local server if there is already a dev-server running. * Playwright will re-use the local server if there is already a dev-server running.
*/ */
command: process.env.CI ? 'pnpm run preview' : 'pnpm run dev', command: 'pnpm run build-only; pnpm run preview',
port: Number(new URL(baseURL).port), port: Number(new URL(baseURL).port),
reuseExistingServer: !process.env.CI, reuseExistingServer: true /* !process.env.CI */,
}, },
}) })

655
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
<script setup lang="ts"></script> <script setup lang="ts"></script>
<template> <template>
<div> <div class="app-layout">
<div>AppLayout</div> <div>AppLayout</div>
<router-view /> <router-view />
</div> </div>

View File

@@ -1,18 +1,19 @@
import { fileURLToPath, URL } from 'node:url' import { fileURLToPath, URL } from 'node:url'
import { createViteProxy } from 'utils4u/vite' import { createViteProxy } from 'utils4u/vite'
import { defineConfig, type DepOptimizationOptions } from 'vite' import { defineConfig, loadEnv, type DepOptimizationOptions } from 'vite'
import { Plugins } from './vite.config.plugins' import { Plugins } from './vite.config.plugins'
// import { createRolldownSplitChunks } from './vite.config.rolldown.split-chunks'
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig(({ command /* mode */ }) => { export default defineConfig(({ command, mode }) => {
const isBuild = command === 'build' const isBuild = command === 'build'
// const env = loadEnv(mode, process.cwd()) const env = loadEnv(mode, process.cwd())
return { return {
// build: createRolldownSplitChunks(), base: env.VITE_BASE,
// base: env.VITE_BASE, build: {
sourcemap: env.VITE_BUILD_SOURCE_MAP === 'true',
},
plugins: Plugins(), plugins: Plugins(),
resolve: { resolve: {
alias: { alias: {
@@ -30,14 +31,14 @@ export default defineConfig(({ command /* mode */ }) => {
} }
}) })
// const primevuecomponents = await (async () => { const primevuecomponents = await (async () => {
// const { components } = await import('@primevue/metadata') const { components } = await import('@primevue/metadata')
// return components.map((c) => c.from).filter((c) => c !== undefined) return components.map((c) => c.from).filter((c) => c !== undefined)
// })() })()
function optimizeDeps(): DepOptimizationOptions { function optimizeDeps(): DepOptimizationOptions {
return { return {
include: [ include: [
// ...primevuecomponents, ...primevuecomponents,
'@primeuix/themes', '@primeuix/themes',
'@primeuix/themes/lara', '@primeuix/themes/lara',
'class-variance-authority', 'class-variance-authority',