From 59d640b5044e763fe7b7e41daa85f80787d91dc0 Mon Sep 17 00:00:00 2001 From: Arno V Date: Wed, 6 Mar 2024 16:31:30 -0400 Subject: [PATCH 1/2] fix(ui-plugins): adding missing dependencies --- packages/ui-plugins/package.json | 8 ++++++- .../plugins/__tests__/tailwindPlugin.test.ts | 10 ++++++++ .../ui-plugins/src/plugins/tailwindPlugin.ts | 24 ++++++++++--------- packages/ui-plugins/vitest.config.ts | 4 ++-- pnpm-lock.yaml | 13 ++++++++-- 5 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 packages/ui-plugins/src/plugins/__tests__/tailwindPlugin.test.ts diff --git a/packages/ui-plugins/package.json b/packages/ui-plugins/package.json index 3d5edcae..53236fec 100644 --- a/packages/ui-plugins/package.json +++ b/packages/ui-plugins/package.json @@ -28,6 +28,12 @@ "dev": "npm-run-all clean --parallel dev:js dev:types", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix --color", "test:coverage": "echo \"WARNING: no test specified\" && exit 0", - "test": "echo \"WARNING: no test specified\" && exit 0" + "test:watch": "vitest", + "test": "vitest run" + }, + "dependencies": { + "@tailwindcss/typography": "0.5.10", + "culori": "4.0.1", + "tailwindcss": "3.4.1" } } diff --git a/packages/ui-plugins/src/plugins/__tests__/tailwindPlugin.test.ts b/packages/ui-plugins/src/plugins/__tests__/tailwindPlugin.test.ts new file mode 100644 index 00000000..6383c4fb --- /dev/null +++ b/packages/ui-plugins/src/plugins/__tests__/tailwindPlugin.test.ts @@ -0,0 +1,10 @@ +import { describe, expect, it } from "vitest"; + +import { tailwindContentPath } from "../tailwindPlugin"; + +describe("Non-DOM tests", () => { + it("should return an array with ui-system and ui-components", () => { + expect(tailwindContentPath[0]).toContain("ui-system"); + expect(tailwindContentPath[1]).toContain("ui-components"); + }); +}); diff --git a/packages/ui-plugins/src/plugins/tailwindPlugin.ts b/packages/ui-plugins/src/plugins/tailwindPlugin.ts index 02daa09f..c2d56930 100644 --- a/packages/ui-plugins/src/plugins/tailwindPlugin.ts +++ b/packages/ui-plugins/src/plugins/tailwindPlugin.ts @@ -10,6 +10,19 @@ type TailwindConfig = { content: string[]; } & OptionalConfig; +export const isProd = process.env.NODE_ENV === "production"; +export const isDev = !isProd; + +const packagesList = ["ui-system", "ui-components"]; +const distLocation = isDev ? "src" : "dist"; + +export const tailwindContentPath = packagesList.map((pkg) => + `${__dirname}/**/*.{js,ts,jsx,tsx}`.replace( + `ui-plugins/${distLocation}`, + `${pkg}/${distLocation}`, + ), +); + const parse = converter("rgb"); const dynamicColors = () => { @@ -148,17 +161,6 @@ const myComponentLibraryConfig = { }, }; -const tailwindContentPath = [ - (__dirname + "/**/*.{js,ts,jsx,tsx}").replace( - "ui-plugins/dist", - "ui-system/dist", - ), - (__dirname + "/**/*.{js,ts,jsx,tsx}").replace( - "ui-plugins/dist", - "ui-components/dist", - ), -]; - const tailwindPlugins = [ typography, plugin(function ({ addUtilities }) { diff --git a/packages/ui-plugins/vitest.config.ts b/packages/ui-plugins/vitest.config.ts index 10f38968..ab07d97a 100644 --- a/packages/ui-plugins/vitest.config.ts +++ b/packages/ui-plugins/vitest.config.ts @@ -4,9 +4,9 @@ import { defineConfig, mergeConfig } from "vitest/config"; import viteConfig from "./vite.config"; -export default defineConfig((configEnv) => +export default defineConfig(() => mergeConfig( - viteConfig(configEnv), + viteConfig, defineConfig({ test: { globals: true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3ca97b51..b0caa549 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -163,7 +163,17 @@ importers: specifier: workspace:../ui-plugins version: link:../ui-plugins - packages/ui-plugins: {} + packages/ui-plugins: + dependencies: + '@tailwindcss/typography': + specifier: 0.5.10 + version: 0.5.10(tailwindcss@3.4.1) + culori: + specifier: 4.0.1 + version: 4.0.1 + tailwindcss: + specifier: 3.4.1 + version: 3.4.1 packages/ui-private: dependencies: @@ -4005,7 +4015,6 @@ packages: /culori@4.0.1: resolution: {integrity: sha512-LSnjA6HuIUOlkfKVbzi2OlToZE8OjFi667JWN9qNymXVXzGDmvuP60SSgC+e92sd7B7158f7Fy3Mb6rXS5EDPw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: true /dargs@7.0.0: resolution: {integrity: sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==} From 0e540fbe4180b5651c83343ed6064481e35c95e1 Mon Sep 17 00:00:00 2001 From: Arno V Date: Wed, 6 Mar 2024 16:36:51 -0400 Subject: [PATCH 2/2] using test env instead of dev --- packages/ui-plugins/package.json | 2 +- packages/ui-plugins/src/plugins/tailwindPlugin.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/ui-plugins/package.json b/packages/ui-plugins/package.json index 53236fec..12158d5a 100644 --- a/packages/ui-plugins/package.json +++ b/packages/ui-plugins/package.json @@ -29,7 +29,7 @@ "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix --color", "test:coverage": "echo \"WARNING: no test specified\" && exit 0", "test:watch": "vitest", - "test": "vitest run" + "test": "cross-env-shell NODE_ENV=test vitest run" }, "dependencies": { "@tailwindcss/typography": "0.5.10", diff --git a/packages/ui-plugins/src/plugins/tailwindPlugin.ts b/packages/ui-plugins/src/plugins/tailwindPlugin.ts index c2d56930..dc132a36 100644 --- a/packages/ui-plugins/src/plugins/tailwindPlugin.ts +++ b/packages/ui-plugins/src/plugins/tailwindPlugin.ts @@ -10,11 +10,10 @@ type TailwindConfig = { content: string[]; } & OptionalConfig; -export const isProd = process.env.NODE_ENV === "production"; -export const isDev = !isProd; +export const isTest = process.env.NODE_ENV === "test"; const packagesList = ["ui-system", "ui-components"]; -const distLocation = isDev ? "src" : "dist"; +const distLocation = isTest ? "src" : "dist"; export const tailwindContentPath = packagesList.map((pkg) => `${__dirname}/**/*.{js,ts,jsx,tsx}`.replace(