Skip to content

Commit 572adab

Browse files
authored
Merge pull request #1 from JustAGhosT/tembo/refactor-utility-packages-distribution
Refactor Utility Packages
2 parents 39a868c + f4d3030 commit 572adab

6 files changed

Lines changed: 107 additions & 13 deletions

File tree

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
"private": true,
44
"version": "0.1.0",
55
"type": "module",
6+
"workspaces": [
7+
"packages/*"
8+
],
69
"scripts": {
710
"dev": "vite",
8-
"build": "tsc && vite build",
11+
"build": "npm run build:packages && tsc && vite build",
12+
"build:packages": "npm run build --workspace=@codeflow/utils",
913
"preview": "vite preview",
1014
"tauri": "tauri"
1115
},
@@ -17,6 +21,7 @@
1721
"@tauri-apps/api": "^2",
1822
"@tauri-apps/plugin-opener": "^2",
1923
"class-variance-authority": "^0.7.0",
24+
"@codeflow/utils": "workspace:*",
2025
"clsx": "^2.1.1",
2126
"js-yaml": "^4.1.1",
2227
"lucide-react": "^0.554.0",

packages/utils/package.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "@codeflow/utils",
3+
"version": "0.1.0",
4+
"description": "Shared utility functions for CodeFlow applications",
5+
"type": "module",
6+
"main": "./dist/index.js",
7+
"module": "./dist/index.js",
8+
"types": "./dist/index.d.ts",
9+
"exports": {
10+
".": {
11+
"import": "./dist/index.js",
12+
"types": "./dist/index.d.ts"
13+
},
14+
"./tailwind": {
15+
"import": "./dist/tailwind.js",
16+
"types": "./dist/tailwind.d.ts"
17+
}
18+
},
19+
"files": [
20+
"dist"
21+
],
22+
"scripts": {
23+
"build": "tsc",
24+
"dev": "tsc --watch",
25+
"clean": "rm -rf dist"
26+
},
27+
"dependencies": {
28+
"clsx": "^2.1.1",
29+
"tailwind-merge": "^2.5.4"
30+
},
31+
"devDependencies": {
32+
"typescript": "~5.9.3"
33+
},
34+
"peerDependencies": {
35+
"clsx": "^2.0.0",
36+
"tailwind-merge": "^2.0.0"
37+
},
38+
"peerDependenciesMeta": {
39+
"clsx": {
40+
"optional": true
41+
},
42+
"tailwind-merge": {
43+
"optional": true
44+
}
45+
},
46+
"keywords": [
47+
"codeflow",
48+
"utils",
49+
"utilities",
50+
"tailwind"
51+
],
52+
"license": "MIT",
53+
"repository": {
54+
"type": "git",
55+
"url": "https://github.com/JustAGhosT/codeflow-desktop.git",
56+
"directory": "packages/utils"
57+
}
58+
}

packages/utils/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @codeflow/utils - Shared utility functions for CodeFlow applications
3+
*/
4+
5+
// Re-export tailwind utilities
6+
export { cn, type ClassValue } from "./tailwind";

packages/utils/src/tailwind.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { type ClassValue, clsx } from "clsx";
2+
import { twMerge } from "tailwind-merge";
3+
4+
/**
5+
* Utility function for merging Tailwind CSS classes with proper precedence.
6+
* Combines clsx for conditional classes and tailwind-merge for deduplication.
7+
*
8+
* @example
9+
* cn("px-4 py-2", "px-6") // => "py-2 px-6"
10+
* cn("bg-red-500", isActive && "bg-blue-500") // => "bg-blue-500" if isActive
11+
*/
12+
export function cn(...inputs: ClassValue[]) {
13+
return twMerge(clsx(inputs));
14+
}
15+
16+
export type { ClassValue };

packages/utils/tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"lib": ["ES2022", "DOM"],
7+
"strict": true,
8+
"skipLibCheck": true,
9+
"esModuleInterop": true,
10+
"declaration": true,
11+
"declarationMap": true,
12+
"sourceMap": true,
13+
"outDir": "./dist",
14+
"rootDir": "./src"
15+
},
16+
"include": ["src/**/*"],
17+
"exclude": ["node_modules", "dist"]
18+
}

src/lib/utils.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
import { type ClassValue, clsx } from "clsx";
2-
import { twMerge } from "tailwind-merge";
3-
41
/**
5-
* Utility function for merging Tailwind CSS classes with proper precedence.
6-
* Combines clsx for conditional classes and tailwind-merge for deduplication.
7-
*
8-
* @example
9-
* cn("px-4 py-2", "px-6") // => "py-2 px-6"
10-
* cn("bg-red-500", isActive && "bg-blue-500") // => "bg-blue-500" if isActive
2+
* Re-export utilities from @codeflow/utils package.
3+
* This file exists for backwards compatibility with existing imports.
114
*/
12-
export function cn(...inputs: ClassValue[]) {
13-
return twMerge(clsx(inputs));
14-
}
5+
export { cn, type ClassValue } from "@codeflow/utils";

0 commit comments

Comments
 (0)