@shivasankaran18/stackd 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/.github/workflows/ci.yml +30 -0
  2. package/LICENSE +21 -0
  3. package/README.md +115 -0
  4. package/apps/cli/package.json +32 -0
  5. package/apps/cli/src/cli.ts +271 -0
  6. package/apps/cli/src/commands/create.ts +162 -0
  7. package/apps/cli/src/scripts/Auth/jwt.ts +83 -0
  8. package/apps/cli/src/scripts/Auth/nextAuth.ts +146 -0
  9. package/apps/cli/src/scripts/Auth/passport.ts +234 -0
  10. package/apps/cli/src/scripts/backend/django.ts +30 -0
  11. package/apps/cli/src/scripts/backend/expressjs.ts +72 -0
  12. package/apps/cli/src/scripts/backend/expressts.ts +95 -0
  13. package/apps/cli/src/scripts/frontend/angularjs.ts +0 -0
  14. package/apps/cli/src/scripts/frontend/angularts.ts +29 -0
  15. package/apps/cli/src/scripts/frontend/nextjs.ts +72 -0
  16. package/apps/cli/src/scripts/frontend/reactjs.ts +36 -0
  17. package/apps/cli/src/scripts/frontend/reactts.ts +34 -0
  18. package/apps/cli/src/scripts/frontend/vuejs.ts +43 -0
  19. package/apps/cli/src/scripts/frontend/vuets.ts +53 -0
  20. package/apps/cli/src/scripts/orms/drizzleSetup.ts +102 -0
  21. package/apps/cli/src/scripts/orms/mongoSetup.ts +68 -0
  22. package/apps/cli/src/scripts/orms/prismaSetup.ts +14 -0
  23. package/apps/cli/src/scripts/ui/shadcn.ts +228 -0
  24. package/apps/cli/src/scripts/ui/tailwindcss.ts +126 -0
  25. package/apps/cli/tsconfig.json +111 -0
  26. package/apps/web/app/api/auth/[...nextauth]/route.ts +7 -0
  27. package/apps/web/app/api/scaffold/route.ts +274 -0
  28. package/apps/web/app/favicon.ico +0 -0
  29. package/apps/web/app/fonts/GeistMonoVF.woff +0 -0
  30. package/apps/web/app/fonts/GeistVF.woff +0 -0
  31. package/apps/web/app/globals.css +158 -0
  32. package/apps/web/app/home/page.tsx +22 -0
  33. package/apps/web/app/layout.tsx +35 -0
  34. package/apps/web/app/page.module.css +188 -0
  35. package/apps/web/app/page.tsx +1 -0
  36. package/apps/web/app/providers.tsx +9 -0
  37. package/apps/web/app/scaffold/page.tsx +472 -0
  38. package/apps/web/components/Sidebar.tsx +108 -0
  39. package/apps/web/components/theme-provider.tsx +9 -0
  40. package/apps/web/components/ui/button.tsx +57 -0
  41. package/apps/web/components/ui/card.tsx +76 -0
  42. package/apps/web/components/ui/dropdown-menu.tsx +200 -0
  43. package/apps/web/components/ui/input.tsx +22 -0
  44. package/apps/web/components/ui/label.tsx +26 -0
  45. package/apps/web/components/ui/scroll-area.tsx +48 -0
  46. package/apps/web/components/ui/sonner.tsx +31 -0
  47. package/apps/web/components/ui/steps.tsx +36 -0
  48. package/apps/web/components/ui/switch.tsx +29 -0
  49. package/apps/web/components.json +21 -0
  50. package/apps/web/eslint.config.js +4 -0
  51. package/apps/web/lib/auth.ts +35 -0
  52. package/apps/web/lib/redis.ts +13 -0
  53. package/apps/web/lib/utils.ts +8 -0
  54. package/apps/web/next-env.d.ts +5 -0
  55. package/apps/web/next.config.js +4 -0
  56. package/apps/web/package.json +52 -0
  57. package/apps/web/postcss.config.js +6 -0
  58. package/apps/web/public/file-text.svg +3 -0
  59. package/apps/web/public/globe.svg +10 -0
  60. package/apps/web/public/next.svg +1 -0
  61. package/apps/web/public/turborepo-dark.svg +19 -0
  62. package/apps/web/public/turborepo-light.svg +19 -0
  63. package/apps/web/public/vercel.svg +10 -0
  64. package/apps/web/public/window.svg +3 -0
  65. package/apps/web/tailwind.config.js +65 -0
  66. package/apps/web/tsconfig.json +23 -0
  67. package/apps/web/types/global.d.ts +4 -0
  68. package/docker-compose.yml +14 -0
  69. package/package.json +55 -0
  70. package/packages/eslint-config/README.md +3 -0
  71. package/packages/eslint-config/base.js +32 -0
  72. package/packages/eslint-config/next.js +49 -0
  73. package/packages/eslint-config/package.json +24 -0
  74. package/packages/eslint-config/react-internal.js +39 -0
  75. package/packages/scripts/Auth/jwt.ts +83 -0
  76. package/packages/scripts/Auth/nextAuth.ts +146 -0
  77. package/packages/scripts/Auth/passport.ts +234 -0
  78. package/packages/scripts/backend/django.ts +30 -0
  79. package/packages/scripts/backend/expressjs.ts +72 -0
  80. package/packages/scripts/backend/expressts.ts +95 -0
  81. package/packages/scripts/frontend/angularjs.ts +0 -0
  82. package/packages/scripts/frontend/angularts.ts +29 -0
  83. package/packages/scripts/frontend/nextjs.ts +72 -0
  84. package/packages/scripts/frontend/reactjs.ts +36 -0
  85. package/packages/scripts/frontend/reactts.ts +34 -0
  86. package/packages/scripts/frontend/vuejs.ts +43 -0
  87. package/packages/scripts/frontend/vuets.ts +53 -0
  88. package/packages/scripts/orms/drizzleSetup.ts +102 -0
  89. package/packages/scripts/orms/mongoSetup.ts +68 -0
  90. package/packages/scripts/orms/prismaSetup.ts +14 -0
  91. package/packages/scripts/ui/shadcn.ts +228 -0
  92. package/packages/scripts/ui/tailwindcss.ts +126 -0
  93. package/packages/typescript-config/base.json +19 -0
  94. package/packages/typescript-config/nextjs.json +12 -0
  95. package/packages/typescript-config/package.json +9 -0
  96. package/packages/typescript-config/react-library.json +7 -0
  97. package/packages/ui/eslint.config.mjs +4 -0
  98. package/packages/ui/package.json +27 -0
  99. package/packages/ui/src/button.tsx +20 -0
  100. package/packages/ui/src/card.tsx +27 -0
  101. package/packages/ui/src/code.tsx +11 -0
  102. package/packages/ui/tsconfig.json +8 -0
  103. package/packages/ui/turbo/generators/config.ts +30 -0
  104. package/packages/ui/turbo/generators/templates/component.hbs +8 -0
  105. package/stackd.ts +134 -0
  106. package/start-web.sh +5 -0
  107. package/tsconfig.json +111 -0
  108. package/tsconfig.tsbuildinfo +1 -0
  109. package/turbo.json +21 -0
@@ -0,0 +1,53 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises'
2
+ import { join } from 'node:path'
3
+ import { execSync } from 'node:child_process'
4
+
5
+ export async function createVueTS(config: any, projectDir: string,emitLog: (log: string) => void) {
6
+ emitLog('Creating VueTS project...');
7
+
8
+ emitLog('Installing Vite...');
9
+ await execSync(`npm create vite@latest frontend -- --template vue-ts`, {
10
+ cwd: projectDir,
11
+ stdio: 'inherit'
12
+ })
13
+
14
+ emitLog('Configuring Vite...');
15
+ const viteConfig = `
16
+ import { defineConfig } from 'vite'
17
+ import vue from '@vitejs/plugin-vue'
18
+
19
+ export default defineConfig({
20
+ plugins: [vue()],
21
+ server: {
22
+ port: ${config.frontendPort},
23
+ proxy: {
24
+ '/api': {
25
+ target: 'http://localhost:${config.backendPort}',
26
+ changeOrigin: true
27
+ }
28
+ }
29
+ }
30
+ })`
31
+
32
+ emitLog('Writing Vite configuration...');
33
+ await writeFile(
34
+ join(projectDir, 'frontend', `vite.config.ts`),
35
+ viteConfig.trim()
36
+ )
37
+
38
+ emitLog('Installing Vue Router and Pinia...');
39
+ await execSync('npm install vue-router@4 pinia@2', {
40
+ cwd: join(projectDir, 'frontend'),
41
+ stdio: 'inherit'
42
+ })
43
+
44
+ emitLog('Installing TypeScript and other dependencies...');
45
+ if (config.frontend === 'vue-ts') {
46
+ await execSync('npm install -D @types/node', {
47
+ cwd: join(projectDir, 'frontend'),
48
+ stdio: 'inherit'
49
+ })
50
+ }
51
+
52
+ emitLog('✅ VueTS project created successfully!');
53
+ }
@@ -0,0 +1,102 @@
1
+ import { join } from 'node:path'
2
+ import { mkdir, writeFile } from 'node:fs/promises'
3
+ import 'dotenv/config'
4
+
5
+ export async function setupDrizzle(config: any, projectDir: string, emitLog: (log: string) => void) {
6
+ try {
7
+ emitLog('Starting Drizzle ORM setup...');
8
+ const backendDir = join(projectDir, 'backend');
9
+ const dbDir = join(backendDir, 'src', 'db');
10
+ const schemasDir = join(dbDir, 'schema');
11
+ emitLog('Creating directory structure...');
12
+ await mkdir(schemasDir, { recursive: true });
13
+ emitLog('✅ Directory structure created');
14
+
15
+ emitLog('Generating environment configuration...');
16
+ const envContent = `
17
+ # Database Configuration
18
+ ${config.env?.DATABASE_URL_ENV || 'DATABASE_URL'}=postgres://user:password@localhost:5432/${config.databaseName || 'myapp'}
19
+ # Add other environment variables here
20
+ NODE_ENV=development
21
+ PORT=3000
22
+ `;
23
+ await writeFile(
24
+ join(backendDir, '.env'),
25
+ envContent.trim() + '\n'
26
+ );
27
+ emitLog('✅ Environment configuration created');
28
+
29
+ emitLog('Setting up database connection...');
30
+ const dbCode = `
31
+ import { drizzle } from 'drizzle-orm/node-postgres';
32
+ import { Pool } from 'pg';
33
+ import 'dotenv/config';
34
+
35
+ const pool = new Pool({
36
+ connectionString: process.env.${config.env?.DATABASE_URL_ENV || 'DATABASE_URL'},
37
+ });
38
+
39
+ export const db = drizzle(pool);
40
+
41
+ export async function connectDB() {
42
+ try {
43
+ await pool.connect();
44
+ console.log('Connected to PostgreSQL database');
45
+ } catch (error) {
46
+ console.error('Database connection error:', error);
47
+ process.exit(1);
48
+ }
49
+ }
50
+
51
+ export async function disconnectDB() {
52
+ await pool.end();
53
+ console.log('Disconnected from PostgreSQL database');
54
+ }
55
+ `;
56
+ await writeFile(
57
+ join(dbDir, 'index.ts'),
58
+ dbCode
59
+ );
60
+ emitLog('✅ Database connection setup complete');
61
+
62
+ emitLog('Creating example schema...');
63
+ const exampleSchemaCode = `
64
+ import { pgTable, serial, varchar, timestamp } from 'drizzle-orm/pg-core';
65
+
66
+ export const examples = pgTable('examples', {
67
+ id: serial('id').primaryKey(),
68
+ name: varchar('name', { length: 256 }).notNull(),
69
+ createdAt: timestamp('created_at').defaultNow(),
70
+ });
71
+ `;
72
+ await writeFile(
73
+ join(schemasDir, 'example.ts'),
74
+ exampleSchemaCode
75
+ );
76
+ emitLog('✅ Example schema created');
77
+
78
+ emitLog('Configuring Drizzle migrations...');
79
+ const drizzleConfigCode = `
80
+ import type { Config } from 'drizzle-kit';
81
+
82
+ export default {
83
+ schema: './src/db/schema/*',
84
+ out: './src/db/migrations',
85
+ driver: 'pg',
86
+ dbCredentials: {
87
+ connectionString: process.env.${config.env?.DATABASE_URL_ENV || 'DATABASE_URL'}!,
88
+ },
89
+ } satisfies Config;
90
+ `;
91
+ await writeFile(
92
+ join(backendDir, 'drizzle.config.ts'),
93
+ drizzleConfigCode
94
+ );
95
+ emitLog('✅ Drizzle configuration complete');
96
+
97
+ emitLog('✅ Drizzle ORM setup completed successfully!');
98
+ } catch (error) {
99
+ emitLog(`❌ Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
100
+ throw error;
101
+ }
102
+ }
@@ -0,0 +1,68 @@
1
+ import { join } from 'node:path'
2
+ import { mkdir, writeFile } from 'node:fs/promises'
3
+ import 'dotenv/config'
4
+
5
+ export async function setupMongoose(config: any, projectDir: string,emitLog: (log: string) => void) {
6
+ const backendDir = join(projectDir, 'backend');
7
+ const modelsDir = join(backendDir, 'src', 'models');
8
+ await mkdir(modelsDir, { recursive: true });
9
+
10
+ emitLog('Generating environment configuration...');
11
+ const envContent = `
12
+ # MongoDB Configuration
13
+ ${config.env?.MONGODB_URI_ENV || 'MONGODB_URI'}=mongodb://localhost:27017/${config.databaseName || 'myapp'}
14
+
15
+ # Add other environment variables here
16
+ NODE_ENV=development
17
+ PORT=3000
18
+ `;
19
+
20
+ await writeFile(
21
+ join(backendDir, '.env'),
22
+ envContent.trim() + '\n'
23
+ );
24
+ emitLog('✅ Environment configuration created');
25
+
26
+ emitLog('Setting up database connection...');
27
+ const dbCode = `
28
+ import mongoose from 'mongoose';
29
+
30
+ const MONGODB_URI = process.env.${config.env?.MONGODB_URI_ENV || 'MONGODB_URI'} || 'mongodb://localhost:27017/${config.databaseName || 'myapp'}';
31
+
32
+ export async function connectDB() {
33
+ try {
34
+ await mongoose.connect(MONGODB_URI);
35
+ console.log('Connected to MongoDB');
36
+ } catch (error) {
37
+ console.error('MongoDB connection error:', error);
38
+ process.exit(1);
39
+ }
40
+ }
41
+
42
+ export async function disconnectDB() {
43
+ await mongoose.disconnect();
44
+ console.log('Disconnected from MongoDB');
45
+ }
46
+ `;
47
+ emitLog('✅ Database connection setup complete');
48
+ await writeFile(
49
+ join(backendDir, 'db.ts'),
50
+ dbCode
51
+ );
52
+
53
+ const exampleModelCode = `
54
+ import mongoose from 'mongoose';
55
+
56
+ const exampleSchema = new mongoose.Schema({
57
+ name: { type: String, required: true },
58
+ createdAt: { type: Date, default: Date.now },
59
+ });
60
+
61
+ export const Example = mongoose.model('Example', exampleSchema);
62
+ `;
63
+
64
+ await writeFile(
65
+ join(modelsDir, 'example.ts'),
66
+ exampleModelCode
67
+ );
68
+ }
@@ -0,0 +1,14 @@
1
+ import { join } from 'node:path'
2
+ import { execSync } from 'node:child_process'
3
+ import { writeFileSync } from 'node:fs';
4
+
5
+
6
+ export async function setupPrisma(config: any, projectDir: string,emitLog: (log: string) => void) {
7
+ emitLog('Setting up Prisma...');
8
+ const backendDir = join(projectDir, 'backend');
9
+ const envContent = `DATABASE_URL=${config.dbUrl}\n`;
10
+ writeFileSync(join(projectDir, 'backend', '.env'), envContent);
11
+ await execSync('npm install prisma', { cwd: backendDir });
12
+ await execSync('npx prisma init', { cwd: backendDir });
13
+ emitLog('✅ Prisma setup complete');
14
+ }
@@ -0,0 +1,228 @@
1
+ import { writeFile, mkdir } from 'fs/promises';
2
+ import { join } from 'path';
3
+ import { execSync } from 'child_process';
4
+ import { existsSync } from 'fs';
5
+
6
+ export async function setupShadcn(
7
+ config: any,
8
+ projectDir: string,
9
+ emitLog: (log: string) => void
10
+ ) {
11
+ try {
12
+ const frontendDir = join(projectDir, 'frontend');
13
+ emitLog('📦 Setting up shadcn/ui...');
14
+
15
+ // Make sure Tailwind is set up first
16
+ emitLog('Ensuring Tailwind CSS is set up...');
17
+
18
+ // Install shadcn/ui dependencies
19
+ emitLog('Installing shadcn/ui dependencies...');
20
+ execSync('npm install @shadcn/ui class-variance-authority clsx tailwind-merge lucide-react', {
21
+ cwd: frontendDir,
22
+ stdio: 'inherit'
23
+ });
24
+
25
+ // Create components.json configuration
26
+ const componentsConfig = {
27
+ $schema: "https://ui.shadcn.com/schema.json",
28
+ style: "default",
29
+ rsc: false,
30
+ tailwind: {
31
+ config: "tailwind.config.js",
32
+ css: "src/index.css",
33
+ baseColor: "slate",
34
+ cssVariables: true,
35
+ },
36
+ aliases: {
37
+ components: "@/components",
38
+ utils: "@/lib/utils"
39
+ }
40
+ };
41
+
42
+ await writeFile(
43
+ join(frontendDir, 'components.json'),
44
+ JSON.stringify(componentsConfig, null, 2)
45
+ );
46
+
47
+ // Create utils file
48
+ const utilsDir = join(frontendDir, 'src', 'lib');
49
+ if (!existsSync(utilsDir)) {
50
+ await mkdir(utilsDir, { recursive: true });
51
+ }
52
+
53
+ const utilsContent = `
54
+ import { type ClassValue, clsx } from "clsx"
55
+ import { twMerge } from "tailwind-merge"
56
+
57
+ export function cn(...inputs: ClassValue[]) {
58
+ return twMerge(clsx(inputs))
59
+ }
60
+ `;
61
+
62
+ await writeFile(
63
+ join(utilsDir, 'utils.ts'),
64
+ utilsContent.trim() + '\n'
65
+ );
66
+
67
+ emitLog('✅ shadcn/ui setup completed successfully!');
68
+ } catch (error) {
69
+ emitLog(`❌ Error setting up shadcn/ui: ${error instanceof Error ? error.message : 'Unknown error'}`);
70
+ throw error;
71
+ }
72
+ }
73
+
74
+ function generateShadcnTailwindConfig(frontend: string): string {
75
+ const baseConfig = {
76
+ darkMode: ["class"],
77
+ content: frontend === 'django'
78
+ ? ["./templates/**/*.html", "./static/**/*.{js,ts}"]
79
+ : ["./index.html", "./src/**/*.{js,ts,jsx,tsx,vue}"],
80
+ theme: {
81
+ container: {
82
+ center: true,
83
+ padding: "2rem",
84
+ screens: {
85
+ "2xl": "1400px",
86
+ },
87
+ },
88
+ extend: {
89
+ colors: {
90
+ border: "hsl(var(--border))",
91
+ input: "hsl(var(--input))",
92
+ ring: "hsl(var(--ring))",
93
+ background: "hsl(var(--background))",
94
+ foreground: "hsl(var(--foreground))",
95
+ primary: {
96
+ DEFAULT: "hsl(var(--primary))",
97
+ foreground: "hsl(var(--primary-foreground))",
98
+ },
99
+ secondary: {
100
+ DEFAULT: "hsl(var(--secondary))",
101
+ foreground: "hsl(var(--secondary-foreground))",
102
+ },
103
+ destructive: {
104
+ DEFAULT: "hsl(var(--destructive))",
105
+ foreground: "hsl(var(--destructive-foreground))",
106
+ },
107
+ muted: {
108
+ DEFAULT: "hsl(var(--muted))",
109
+ foreground: "hsl(var(--muted-foreground))",
110
+ },
111
+ accent: {
112
+ DEFAULT: "hsl(var(--accent))",
113
+ foreground: "hsl(var(--accent-foreground))",
114
+ },
115
+ popover: {
116
+ DEFAULT: "hsl(var(--popover))",
117
+ foreground: "hsl(var(--popover-foreground))",
118
+ },
119
+ card: {
120
+ DEFAULT: "hsl(var(--card))",
121
+ foreground: "hsl(var(--card-foreground))",
122
+ },
123
+ },
124
+ borderRadius: {
125
+ lg: "var(--radius)",
126
+ md: "calc(var(--radius) - 2px)",
127
+ sm: "calc(var(--radius) - 4px)",
128
+ },
129
+ keyframes: {
130
+ "accordion-down": {
131
+ from: { height: "0" },
132
+ to: { height: "var(--radix-accordion-content-height)" },
133
+ },
134
+ "accordion-up": {
135
+ from: { height: "var(--radix-accordion-content-height)" },
136
+ to: { height: "0" },
137
+ },
138
+ },
139
+ animation: {
140
+ "accordion-down": "accordion-down 0.2s ease-out",
141
+ "accordion-up": "accordion-up 0.2s ease-out",
142
+ },
143
+ },
144
+ },
145
+ plugins: ["require('tailwindcss-animate')"],
146
+ };
147
+
148
+ return `/** @type {import('tailwindcss').Config} */
149
+ export default ${JSON.stringify(baseConfig, null, 2)}`;
150
+ }
151
+
152
+ function generateShadcnStyles(frontend: string): string {
153
+ return `@tailwind base;
154
+ @tailwind components;
155
+ @tailwind utilities;
156
+ @layer base {
157
+ :root {
158
+ --background: 0 0% 100%;
159
+ --foreground: 222.2 84% 4.9%;
160
+
161
+ --card: 0 0% 100%;
162
+ --card-foreground: 222.2 84% 4.9%;
163
+
164
+ --popover: 0 0% 100%;
165
+ --popover-foreground: 222.2 84% 4.9%;
166
+
167
+ --primary: 222.2 47.4% 11.2%;
168
+ --primary-foreground: 210 40% 98%;
169
+
170
+ --secondary: 210 40% 96.1%;
171
+ --secondary-foreground: 222.2 47.4% 11.2%;
172
+
173
+ --muted: 210 40% 96.1%;
174
+ --muted-foreground: 215.4 16.3% 46.9%;
175
+
176
+ --accent: 210 40% 96.1%;
177
+ --accent-foreground: 222.2 47.4% 11.2%;
178
+
179
+ --destructive: 0 84.2% 60.2%;
180
+ --destructive-foreground: 210 40% 98%;
181
+
182
+ --border: 214.3 31.8% 91.4%;
183
+ --input: 214.3 31.8% 91.4%;
184
+ --ring: 222.2 84% 4.9%;
185
+
186
+ --radius: 0.5rem;
187
+ }
188
+
189
+ .dark {
190
+ --background: 222.2 84% 4.9%;
191
+ --foreground: 210 40% 98%;
192
+
193
+ --card: 222.2 84% 4.9%;
194
+ --card-foreground: 210 40% 98%;
195
+
196
+ --popover: 222.2 84% 4.9%;
197
+ --popover-foreground: 210 40% 98%;
198
+
199
+ --primary: 210 40% 98%;
200
+ --primary-foreground: 222.2 47.4% 11.2%;
201
+
202
+ --secondary: 217.2 32.6% 17.5%;
203
+ --secondary-foreground: 210 40% 98%;
204
+
205
+ --muted: 217.2 32.6% 17.5%;
206
+ --muted-foreground: 215 20.2% 65.1%;
207
+
208
+ --accent: 217.2 32.6% 17.5%;
209
+ --accent-foreground: 210 40% 98%;
210
+
211
+ --destructive: 0 62.8% 30.6%;
212
+ --destructive-foreground: 210 40% 98%;
213
+
214
+ --border: 217.2 32.6% 17.5%;
215
+ --input: 217.2 32.6% 17.5%;
216
+ --ring: 212.7 26.8% 83.9%;
217
+ }
218
+ }
219
+
220
+ @layer base {
221
+ * {
222
+ @apply border-border;
223
+ }
224
+ body {
225
+ @apply bg-background text-foreground;
226
+ }
227
+ }`;
228
+ }
@@ -0,0 +1,126 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { execSync } from 'child_process';
4
+ import { existsSync } from 'fs';
5
+ import { mkdir } from 'fs/promises';
6
+
7
+ export async function setupTailwindCSS(
8
+ config: any,
9
+ projectDir: string,
10
+ emitLog: (log: string) => void
11
+ ) {
12
+ try {
13
+ const frontendDir = join(projectDir, 'frontend');
14
+ const srcDir = join(frontendDir, 'src');
15
+
16
+ // Ensure directories exist
17
+ if (!existsSync(frontendDir)) {
18
+ emitLog('Creating frontend directory...');
19
+ await mkdir(frontendDir, { recursive: true });
20
+ }
21
+
22
+ if (!existsSync(srcDir)) {
23
+ emitLog('Creating src directory...');
24
+ await mkdir(srcDir, { recursive: true });
25
+ }
26
+
27
+ // Initialize package.json if it doesn't exist
28
+ if (!existsSync(join(frontendDir, 'package.json'))) {
29
+ emitLog('Initializing package.json...');
30
+ execSync('npm init -y', {
31
+ cwd: frontendDir,
32
+ stdio: 'inherit'
33
+ });
34
+ }
35
+
36
+ // Install dependencies using npm directly
37
+ emitLog('Installing Tailwind CSS dependencies...');
38
+ execSync('npm install tailwindcss@latest postcss@latest autoprefixer@latest --save-dev', {
39
+ cwd: frontendDir,
40
+ stdio: 'inherit'
41
+ });
42
+
43
+ // Create tailwind.config.js manually instead of using npx
44
+ emitLog('Creating Tailwind configuration...');
45
+ const tailwindConfig = generateTailwindConfig(config.frontend);
46
+ await writeFile(
47
+ join(frontendDir, 'tailwind.config.js'),
48
+ tailwindConfig
49
+ );
50
+
51
+ // Create postcss.config.js
52
+ emitLog('Creating PostCSS configuration...');
53
+ const postcssConfig = `
54
+ module.exports = {
55
+ plugins: {
56
+ tailwindcss: {},
57
+ autoprefixer: {},
58
+ },
59
+ }`;
60
+ await writeFile(
61
+ join(frontendDir, 'postcss.config.js'),
62
+ postcssConfig
63
+ );
64
+
65
+ // Add Tailwind directives to CSS
66
+ emitLog('Creating CSS file with Tailwind directives...');
67
+ const tailwindDirectives = `
68
+ @tailwind base;
69
+ @tailwind components;
70
+ @tailwind utilities;
71
+ `;
72
+ await writeFile(
73
+ join(srcDir, 'index.css'),
74
+ tailwindDirectives
75
+ );
76
+
77
+ emitLog('✅ Tailwind CSS setup completed successfully!');
78
+ } catch (error) {
79
+ emitLog(`❌ Error setting up Tailwind CSS: ${error instanceof Error ? error.message : 'Unknown error'}`);
80
+ throw error;
81
+ }
82
+ }
83
+
84
+ function generateTailwindConfig(framework: string): string {
85
+ const baseConfig = {
86
+ content: [
87
+ "./index.html",
88
+ "./src/**/*.{js,ts,jsx,tsx}",
89
+ ],
90
+ theme: {
91
+ extend: {
92
+ colors: {
93
+ background: 'hsl(var(--background))',
94
+ foreground: 'hsl(var(--foreground))',
95
+ },
96
+ },
97
+ },
98
+ plugins: [],
99
+ };
100
+
101
+ switch (framework) {
102
+ case 'react-ts':
103
+ case 'react':
104
+ baseConfig.content = [
105
+ "./index.html",
106
+ "./src/**/*.{js,ts,jsx,tsx}",
107
+ ];
108
+ break;
109
+ case 'vue-ts':
110
+ case 'vue':
111
+ baseConfig.content = [
112
+ "./index.html",
113
+ "./src/**/*.{vue,js,ts,jsx,tsx}",
114
+ ];
115
+ break;
116
+ case 'django':
117
+ baseConfig.content = [
118
+ "./templates/**/*.html",
119
+ "./static/**/*.{js,ts}",
120
+ ];
121
+ break;
122
+ }
123
+
124
+ return `/** @type {import('tailwindcss').Config} */
125
+ module.exports = ${JSON.stringify(baseConfig, null, 2)}`;
126
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationMap": true,
6
+ "esModuleInterop": true,
7
+ "incremental": false,
8
+ "isolatedModules": true,
9
+ "lib": ["es2022", "DOM", "DOM.Iterable"],
10
+ "module": "NodeNext",
11
+ "moduleDetection": "force",
12
+ "moduleResolution": "NodeNext",
13
+ "noUncheckedIndexedAccess": true,
14
+ "resolveJsonModule": true,
15
+ "skipLibCheck": true,
16
+ "strict": true,
17
+ "target": "ES2022"
18
+ }
19
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "plugins": [{ "name": "next" }],
6
+ "module": "ESNext",
7
+ "moduleResolution": "Bundler",
8
+ "allowJs": true,
9
+ "jsx": "preserve",
10
+ "noEmit": true
11
+ }
12
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@repo/typescript-config",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ }
9
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "jsx": "react-jsx"
6
+ }
7
+ }
@@ -0,0 +1,4 @@
1
+ import { config } from "@repo/eslint-config/react-internal";
2
+
3
+ /** @type {import("eslint").Linter.Config} */
4
+ export default config;
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@repo/ui",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "exports": {
6
+ "./*": "./src/*.tsx"
7
+ },
8
+ "scripts": {
9
+ "lint": "eslint . --max-warnings 0",
10
+ "generate:component": "turbo gen react-component",
11
+ "check-types": "tsc --noEmit"
12
+ },
13
+ "devDependencies": {
14
+ "@repo/eslint-config": "*",
15
+ "@repo/typescript-config": "*",
16
+ "@turbo/gen": "^2.4.0",
17
+ "@types/node": "^22.13.0",
18
+ "@types/react": "19.0.8",
19
+ "@types/react-dom": "19.0.3",
20
+ "eslint": "^9.20.0",
21
+ "typescript": "5.7.3"
22
+ },
23
+ "dependencies": {
24
+ "react": "^19.0.0",
25
+ "react-dom": "^19.0.0"
26
+ }
27
+ }