From 54029124912163c351cf1c45ac728e7d66fb254a Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Wed, 6 May 2026 14:28:05 +0900 Subject: [PATCH 01/21] chore: use VITEST_API_TOKEN for ui dev --- packages/ui/CONTRIBUTING.md | 4 ++-- packages/ui/vite.config.ts | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/ui/CONTRIBUTING.md b/packages/ui/CONTRIBUTING.md index 847f71a03306..07dc1c71d9c2 100644 --- a/packages/ui/CONTRIBUTING.md +++ b/packages/ui/CONTRIBUTING.md @@ -5,7 +5,7 @@ nr ui:dev ``` ```bash -nr test --api +nr test --ui ---open=false ``` As the last command, you can use any of the available tests suites instead. Make sure that they run at 51204 port or specify a custom port with `VITE_PORT` environmental variable when running the first command. For example, @@ -15,7 +15,7 @@ VITE_PORT=3200 nr ui:dev ``` ```bash -nr test --api=3200 +nr test --ui --open=false --api=3200 ``` Open the browser at the URL printed by the first command. For example, `http://localhost:5173/`. If you see a connection error, it means the port is specified incorrectly. diff --git a/packages/ui/vite.config.ts b/packages/ui/vite.config.ts index 586e772c6ac2..5ad7c00a733f 100644 --- a/packages/ui/vite.config.ts +++ b/packages/ui/vite.config.ts @@ -1,3 +1,4 @@ +import assert from 'node:assert' import Vue from '@vitejs/plugin-vue' import { resolve } from 'pathe' import { presetAttributify, presetIcons, presetUno, transformerDirectives } from 'unocss' @@ -63,6 +64,27 @@ export default defineConfig({ // }, // }, + { + name: 'proxy-api-token', + apply: 'serve', + async transformIndexHtml() { + const apiOrigin = `http://localhost:${process.env.VITE_PORT || '51204'}` + const apiTokenPattern = /`) // }, // }, - - { - name: 'dev-ui-script', - apply(_config, env) { - return env.command === 'serve' && env.mode !== 'test' - }, - async transformIndexHtml() { - if (process.env.BROWSER_DEV) { - const browserOrigin = `http://localhost:${process.env.BROWSER_DEV_PORT || '63315'}` - const response = await fetch(new URL('/__vitest_test__/', browserOrigin)) - assert(response.ok, `Failed to fetch browser runner HTML from ${browserOrigin}/__vitest_test__/`) - const browserHtml = await response.text() - const browserScript = browserHtml.match(/