From 1cde630864b8e5e5eec822fdbee66f536b5ff299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E6=9C=94?= <565183519@qq.com> Date: Wed, 12 Aug 2026 07:32:17 +0800 Subject: [PATCH] build(hololake): use runner config loading --- product-source/hololake-platform/package.json | 12 ++++++------ .../scripts/local-native-candidate.test.mjs | 2 ++ .../scripts/run-vitest-coverage.mjs | 4 ++-- product-source/hololake-platform/vite.config.ts | 9 ++++++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/product-source/hololake-platform/package.json b/product-source/hololake-platform/package.json index 5a4f400..5fc11c5 100644 --- a/product-source/hololake-platform/package.json +++ b/product-source/hololake-platform/package.json @@ -8,9 +8,9 @@ "predev": "pnpm test:native-authority", "dev": "vite", "prebuild": "pnpm test:native-authority && pnpm test:native-core", - "build": "tsc -b && vite build", - "build:team-foundation": "VITE_HOLOLAKE_DISTRIBUTION=team-foundation tsc -b && VITE_HOLOLAKE_DISTRIBUTION=team-foundation vite build && node scripts/finalize-team-foundation-build.mjs", - "build:education": "tsc -b && vite build --base=/jd/education/", + "build": "tsc -b && vite build --configLoader runner", + "build:team-foundation": "VITE_HOLOLAKE_DISTRIBUTION=team-foundation tsc -b && VITE_HOLOLAKE_DISTRIBUTION=team-foundation vite build --configLoader runner && node scripts/finalize-team-foundation-build.mjs", + "build:education": "tsc -b && vite build --configLoader runner --base=/jd/education/", "agent-docs": "node scripts/build-agent-docs.mjs", "bundle-mcp": "node scripts/bundle-mcp-server.mjs", "docs:dev": "vitepress dev site --host 127.0.0.1", @@ -25,8 +25,8 @@ "preview": "vite preview", "tauri": "tauri", "pretest": "pnpm test:native-authority", - "test": "vitest run", - "test:watch": "vitest", + "test": "vitest run --configLoader runner", + "test:watch": "vitest --configLoader runner", "test:e2e": "playwright test", "playwright:smoke": "playwright test --config playwright.smoke.config.ts tests/smoke/autosave-low-end-typing.spec.ts tests/smoke/create-note-backing-file.spec.ts tests/smoke/delete-note-nonblocking.spec.ts tests/smoke/example.spec.ts tests/smoke/fix-crash-create-note.spec.ts tests/smoke/quick-open-create-note.spec.ts tests/smoke/save-before-note-switch.spec.ts tests/smoke/h1-untitled-auto-rename.spec.ts tests/smoke/keyboard-command-routing.spec.ts tests/smoke/missing-string-metadata-open-note.spec.ts tests/smoke/multibyte-search-snippet.spec.ts tests/smoke/pull-refresh-open-note.spec.ts tests/smoke/wikilink-path-fix.spec.ts", "playwright:regression": "playwright test tests/smoke/", @@ -37,7 +37,7 @@ "guard:deployment-source": "node scripts/deployment-source-guard.mjs", "test:deployment-source": "node --test scripts/deployment-source-guard.test.mjs", "test:native-authority": "bash scripts/test-guanghu-native-authority.sh && node scripts/validate-guanghu-native-profile.mjs", - "test:native-core": "vitest run --config vitest.guanghu-native.config.ts --coverage", + "test:native-core": "vitest run --config vitest.guanghu-native.config.ts --coverage --configLoader runner", "package:internal:macos": "HOLOLAKE_DISTRIBUTION=personal HOLOLAKE_SOURCE_REPOSITORY_ID=REPO-008 HOLOLAKE_SOURCE_CHANNEL_ID=HLP-CHANNEL-0001 pnpm guard:deployment-source && ./scripts/build-internal-release.sh macos", "package:local-candidate:macos": "HOLOLAKE_DISTRIBUTION=local-candidate HOLOLAKE_TAURI_CONFIG=src-tauri/tauri.local-candidate.conf.json HOLOLAKE_APP_NAME='HoloLake Era · 本地方向候选 0.4.6' HOLOLAKE_INSTALLER_BASENAME='HoloLake-Era-{version}-Local-Direction-Candidate-Mac-aarch64' ./scripts/build-internal-release.sh macos", "package:internal:windows": "HOLOLAKE_DISTRIBUTION=personal HOLOLAKE_SOURCE_REPOSITORY_ID=REPO-008 HOLOLAKE_SOURCE_CHANNEL_ID=HLP-CHANNEL-0001 pnpm guard:deployment-source && ./scripts/build-internal-release.sh windows", diff --git a/product-source/hololake-platform/scripts/local-native-candidate.test.mjs b/product-source/hololake-platform/scripts/local-native-candidate.test.mjs index 5b26324..a744745 100644 --- a/product-source/hololake-platform/scripts/local-native-candidate.test.mjs +++ b/product-source/hololake-platform/scripts/local-native-candidate.test.mjs @@ -20,4 +20,6 @@ test('local native candidate has an isolated macOS package identity', async () = packageJson.scripts['package:local-candidate:macos'], /tauri\.local-candidate\.conf\.json/, ) + assert.match(packageJson.scripts.build, /--configLoader runner/) + assert.match(packageJson.scripts['test:native-core'], /--configLoader runner/) }) diff --git a/product-source/hololake-platform/scripts/run-vitest-coverage.mjs b/product-source/hololake-platform/scripts/run-vitest-coverage.mjs index f67231f..89b3a92 100644 --- a/product-source/hololake-platform/scripts/run-vitest-coverage.mjs +++ b/product-source/hololake-platform/scripts/run-vitest-coverage.mjs @@ -33,8 +33,8 @@ const packageManagerExec = process.env.npm_execpath const isJsExecpath = packageManagerExec && /\.[mc]?js$/i.test(packageManagerExec) const command = isJsExecpath ? process.execPath : 'pnpm' const baseCommandArgs = isJsExecpath - ? [packageManagerExec, 'exec', 'vitest', 'run', '--coverage'] - : ['exec', 'vitest', 'run', '--coverage'] + ? [packageManagerExec, 'exec', 'vitest', 'run', '--coverage', '--configLoader', 'runner'] + : ['exec', 'vitest', 'run', '--coverage', '--configLoader', 'runner'] const clearCacheCommandArgs = isJsExecpath ? [packageManagerExec, 'exec', 'vitest', '--clearCache'] : ['exec', 'vitest', '--clearCache'] diff --git a/product-source/hololake-platform/vite.config.ts b/product-source/hololake-platform/vite.config.ts index 950a30e..7b24d6b 100644 --- a/product-source/hololake-platform/vite.config.ts +++ b/product-source/hololake-platform/vite.config.ts @@ -14,11 +14,14 @@ import { type Dirent, } from 'fs' import os from 'os' +import { fileURLToPath } from 'node:url' import { defineConfig, type Plugin } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' import matter from 'gray-matter' +const configDirectory = path.dirname(fileURLToPath(import.meta.url)) + // --- Vault API middleware (dev only) --- interface VaultEntry { @@ -962,7 +965,7 @@ export default defineConfig({ resolve: { alias: { - '@': path.resolve(__dirname, './src'), + '@': path.resolve(configDirectory, './src'), }, }, @@ -972,7 +975,7 @@ export default defineConfig({ define: { ...(process.env.CI || (process.env.TAURI_PLATFORM && !process.env.TAURI_DEBUG) ? {} - : { __DEMO_VAULT_PATH__: JSON.stringify(path.resolve(__dirname, 'demo-vault-v2')) }), + : { __DEMO_VAULT_PATH__: JSON.stringify(path.resolve(configDirectory, 'demo-vault-v2')) }), }, // Prevent vite from obscuring Rust errors @@ -993,7 +996,7 @@ export default defineConfig({ build: { rollupOptions: process.env.VITE_HOLOLAKE_DISTRIBUTION === 'team-foundation' - ? { input: path.resolve(__dirname, 'team-foundation.html') } + ? { input: path.resolve(configDirectory, 'team-foundation.html') } : undefined, // Tauri uses Chromium on Windows and WebKit on macOS/Linux target: process.env.TAURI_PLATFORM === 'windows' ? 'chrome105' : 'safari13',