From 63e42b9b52f165911f9118d1b673802c09246b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Tue, 11 Jun 2024 11:23:36 +0200 Subject: [PATCH] ci(editor): Enforce type-safety in @n8n/chat builds as well (no-changelog) (#9685) --- packages/@n8n/chat/package.json | 6 ++-- .../chat/{vite.config.ts => vite.config.mts} | 6 ++-- packages/@n8n/chat/vitest.config.mts | 30 +++++++++++++++++++ packages/@n8n/chat/vitest.config.ts | 20 ------------- 4 files changed, 35 insertions(+), 27 deletions(-) rename packages/@n8n/chat/{vite.config.ts => vite.config.mts} (88%) create mode 100644 packages/@n8n/chat/vitest.config.mts delete mode 100644 packages/@n8n/chat/vitest.config.ts diff --git a/packages/@n8n/chat/package.json b/packages/@n8n/chat/package.json index a6c5360c4978a..98de7613c33f8 100644 --- a/packages/@n8n/chat/package.json +++ b/packages/@n8n/chat/package.json @@ -3,8 +3,8 @@ "version": "0.16.0", "scripts": { "dev": "pnpm run storybook", - "build": "pnpm type-check && pnpm build:vite && pnpm run build:individual && npm run build:prepare", - "build:full": "pnpm type-check && pnpm build:vite && pnpm build:vite:full && pnpm run build:individual && npm run build:prepare", + "build": "pnpm build:vite && pnpm run build:individual && npm run build:prepare", + "build:full": "pnpm build:vite && pnpm build:vite:full && pnpm run build:individual && npm run build:prepare", "build:vite": "vite build", "build:vite:full": "INCLUDE_VUE=true vite build", "build:individual": "unbuild", @@ -13,7 +13,7 @@ "preview": "vite preview", "test:dev": "vitest", "test": "vitest run --coverage", - "type-check": "vue-tsc --noEmit -p tsconfig.json --composite false", + "typecheck": "vue-tsc --noEmit", "lint": "eslint . --ext .js,.ts,.vue --quiet", "lintfix": "eslint . --ext .js,.ts,.vue --fix", "format": "prettier --write src/", diff --git a/packages/@n8n/chat/vite.config.ts b/packages/@n8n/chat/vite.config.mts similarity index 88% rename from packages/@n8n/chat/vite.config.ts rename to packages/@n8n/chat/vite.config.mts index 847a22430338e..44f987e5e1fe5 100644 --- a/packages/@n8n/chat/vite.config.ts +++ b/packages/@n8n/chat/vite.config.mts @@ -1,5 +1,3 @@ -import { fileURLToPath, URL } from 'node:url'; - import { defineConfig } from 'vite'; import checker from 'vite-plugin-checker'; import { resolve } from 'path'; @@ -8,7 +6,7 @@ import icons from 'unplugin-icons/vite'; import dts from 'vite-plugin-dts'; const includeVue = process.env.INCLUDE_VUE === 'true'; -const srcPath = fileURLToPath(new URL('./src', import.meta.url)); +const srcPath = resolve(__dirname, 'src'); const plugins = [ vue(), @@ -18,7 +16,7 @@ const plugins = [ }), dts(), ]; -if (process.env.ENABLE_TYPE_CHECKING === 'true') { +if (!process.env.VITEST) { plugins.push(checker({ vueTsc: true })); } diff --git a/packages/@n8n/chat/vitest.config.mts b/packages/@n8n/chat/vitest.config.mts new file mode 100644 index 0000000000000..a14986457cccc --- /dev/null +++ b/packages/@n8n/chat/vitest.config.mts @@ -0,0 +1,30 @@ +import { resolve } from 'path'; +import { mergeConfig } from 'vite'; +import { type UserConfig } from 'vitest'; +import { defineConfig } from 'vitest/config'; +import viteConfig from './vite.config.mts'; + +const srcPath = resolve(__dirname, 'src'); +const vitestConfig = defineConfig({ + test: { + globals: true, + environment: 'jsdom', + root: srcPath, + setupFiles: ['./src/__tests__/setup.ts'], + ...(process.env.COVERAGE_ENABLED === 'true' + ? { + coverage: { + enabled: true, + provider: 'v8', + reporter: process.env.CI === 'true' ? 'cobertura' : 'text-summary', + all: true, + }, + } + : {}), + }, +}) as UserConfig; + +export default mergeConfig( + viteConfig, + vitestConfig, +); diff --git a/packages/@n8n/chat/vitest.config.ts b/packages/@n8n/chat/vitest.config.ts deleted file mode 100644 index cda2fb78678f8..0000000000000 --- a/packages/@n8n/chat/vitest.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { fileURLToPath } from 'node:url'; -import { mergeConfig, defineConfig } from 'vite'; -import { configDefaults } from 'vitest/config'; -import viteConfig from './vite.config'; - -export default mergeConfig( - viteConfig, - defineConfig({ - test: { - globals: true, - environment: 'jsdom', - exclude: [...configDefaults.exclude, 'e2e/*'], - root: fileURLToPath(new URL('./', import.meta.url)), - setupFiles: ['./src/__tests__/setup.ts'], - transformMode: { - web: [/\.[jt]sx$/], - }, - }, - }), -);