@shivasankaran18/stackd 2.0.2 → 13.0.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 (45) hide show
  1. package/README.md +12 -7
  2. package/apps/cli/src/cli.ts +2 -28
  3. package/apps/cli/src/commands/create.ts +0 -30
  4. package/apps/cli/src/generators/auth/jwt.js +83 -0
  5. package/apps/cli/src/generators/auth/nextAuth.js +146 -0
  6. package/apps/cli/src/generators/auth/passport.js +234 -0
  7. package/apps/cli/src/generators/backend/django.js +30 -0
  8. package/apps/cli/src/generators/backend/expressjs.js +72 -0
  9. package/apps/cli/src/generators/backend/expressts.js +95 -0
  10. package/apps/cli/src/generators/frontend/angularts.js +29 -0
  11. package/apps/cli/src/generators/frontend/reactjs.js +42 -0
  12. package/apps/cli/src/generators/frontend/reactts.d.ts +13 -0
  13. package/apps/cli/src/generators/frontend/reactts.js +40 -0
  14. package/apps/cli/src/generators/frontend/vuejs.js +43 -0
  15. package/apps/cli/src/generators/frontend/vuets.js +53 -0
  16. package/apps/cli/src/generators/orm/drizzleSetup.js +102 -0
  17. package/apps/cli/src/generators/orm/mongoSetup.js +68 -0
  18. package/apps/cli/src/generators/orm/prismaSetup.js +14 -0
  19. package/apps/cli/src/generators/ui/shadcn.js +228 -0
  20. package/apps/cli/src/generators/ui/tailwindcss.js +126 -0
  21. package/apps/cli/src/scripts/backend/expressts.ts +1 -1
  22. package/apps/cli/src/scripts/frontend/angularts.ts +4 -2
  23. package/apps/cli/src/scripts/frontend/reactjs.ts +3 -2
  24. package/apps/cli/src/scripts/frontend/reactts.ts +3 -2
  25. package/apps/cli/src/scripts/orms/prismaSetup.ts +2 -2
  26. package/apps/cli/src/scripts/ui/shadcn.ts +10 -4
  27. package/apps/web/app/api/scaffold/route.ts +7 -7
  28. package/apps/web/app/scaffold/page.tsx +1 -1
  29. package/apps/web/package.json +2 -1
  30. package/apps/web/tsconfig.json +23 -125
  31. package/package.json +3 -33
  32. package/packages/typescript-config/base.json +19 -0
  33. package/packages/typescript-config/nextjs.json +12 -0
  34. package/packages/typescript-config/package.json +9 -0
  35. package/packages/typescript-config/react-library.json +7 -0
  36. package/packages/ui/eslint.config.mjs +4 -0
  37. package/packages/ui/package.json +27 -0
  38. package/packages/ui/src/button.tsx +20 -0
  39. package/packages/ui/src/card.tsx +27 -0
  40. package/packages/ui/src/code.tsx +11 -0
  41. package/packages/ui/tsconfig.json +8 -0
  42. package/packages/ui/turbo/generators/config.ts +30 -0
  43. package/packages/ui/turbo/generators/templates/component.hbs +8 -0
  44. package/stackd.ts +16 -6
  45. package/apps/cli/src/scripts/ui/tailwind.ts +0 -39
@@ -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,
8
+ projectDir,
9
+ emitLog
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) {
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) {
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,
9
+ projectDir,
10
+ emitLog
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) {
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
+ }
@@ -90,6 +90,6 @@ app.listen(port, () => {
90
90
  backendIndex.trim()
91
91
  )
92
92
  emitLog('Installing dependencies...');
93
- await execSync("npm install",{cwd : projectDir + '/backend',stdio : "inherit"});
93
+ await execSync("npm install",{cwd : projectDir + '/backend',stdio : "inherit",shell: process.platform === "win32" ? "powershell.exe" : "/bin/sh",});
94
94
  emitLog('✅ ExpressTS project created successfully!');
95
95
  }
@@ -9,14 +9,16 @@ export default async function createAngularTS(config: any, projectDir: any) {
9
9
  console.log('Installing Angular CLI...');
10
10
  await execSync(`npx @angular/cli@latest new frontend --skip-git --style=scss --routing=true --strict`, {
11
11
  cwd: projectDir,
12
- stdio: 'inherit'
12
+ stdio: 'inherit',
13
+ shell: process.platform === "win32" ? "cmd.exe" : "/bin/sh",
13
14
  });
14
15
 
15
16
 
16
17
  console.log('Installing dependencies...');
17
18
  await execSync('npm install', {
18
19
  cwd: projectFullPath,
19
- stdio: 'inherit'
20
+ stdio: 'inherit',
21
+ shell: process.platform === "win32" ? "cmd.exe" : "/bin/sh",
20
22
  });
21
23
 
22
24
  console.log('Angular project created successfully!');
@@ -6,10 +6,11 @@ export async function createReactJS(config: any, projectDir: string,emitLog: (lo
6
6
  emitLog('Creating ReactJS project...');
7
7
  await execSync(`npm create vite@latest frontend -- --template react`, {
8
8
  cwd: projectDir,
9
- stdio: 'inherit'
9
+ stdio: 'inherit',
10
+ shell: process.platform === "win32" ? "cmd.exe" : "/bin/sh",
10
11
  })
11
12
  emitLog('Installing the dependencies for the frontend...');
12
- await execSync("npm install",{cwd:projectDir + "/frontend",stdio:"inherit"});
13
+ await execSync("npm install",{cwd:projectDir + "/frontend",stdio:"inherit",shell: process.platform === "win32" ? "cmd.exe" : "/bin/sh",});
13
14
  emitLog('Writing Vite configuration...');
14
15
  const viteConfig = `
15
16
  import { defineConfig } from 'vite'
@@ -6,10 +6,11 @@ export async function createReactTS(config: any, projectDir: string,emitLog: (lo
6
6
  emitLog('Creating ReactTS project...');
7
7
  await execSync(`npm create vite@latest frontend -- --template react-ts`, {
8
8
  cwd: projectDir,
9
- stdio: 'inherit'
9
+ stdio: 'inherit',
10
+ shell: process.platform === "win32" ? "powershell.exe" : "/bin/sh",
10
11
  });
11
12
  emitLog('Installing the dependencies...');
12
- await execSync('npm install',{cwd : projectDir + '/frontend',stdio : 'inherit'});
13
+ await execSync('npm install',{cwd : projectDir + '/frontend',stdio : 'inherit',shell: process.platform === "win32" ? "powershell.exe" : "/bin/sh",});
13
14
  emitLog('Writing Vite configuration...');
14
15
  const viteConfig = `
15
16
  import { defineConfig } from 'vite'
@@ -8,7 +8,7 @@ export async function setupPrisma(config: any, projectDir: string,emitLog: (log:
8
8
  const backendDir = join(projectDir, 'backend');
9
9
  const envContent = `DATABASE_URL=${config.dbUrl}\n`;
10
10
  writeFileSync(join(projectDir, 'backend', '.env'), envContent);
11
- await execSync('npm install prisma', { cwd: backendDir });
12
- await execSync('npx prisma init', { cwd: backendDir });
11
+ await execSync('npm install prisma', { cwd: backendDir,shell: process.platform === "win32" ? "powershell.exe" : "/bin/sh", });
12
+ await execSync('npx prisma init', { cwd: backendDir,shell: process.platform === "win32" ? "powershell.exe" : "/bin/sh", });
13
13
  emitLog('✅ Prisma setup complete');
14
14
  }
@@ -2,9 +2,12 @@ import { writeFile, mkdir } from 'fs/promises';
2
2
  import { join } from 'path';
3
3
  import { execSync } from 'child_process';
4
4
  import { existsSync } from 'fs';
5
- import { ProjectConfig } from '../../cli.js';
6
5
 
7
- export async function setupShadcn(config: ProjectConfig, projectDir: string, emitLog: (message: string) => void) {
6
+ export async function setupShadcn(
7
+ config: any,
8
+ projectDir: string,
9
+ emitLog: (log: string) => void
10
+ ) {
8
11
  try {
9
12
  const frontendDir = join(projectDir, 'frontend');
10
13
  emitLog('📦 Setting up shadcn/ui...');
@@ -14,7 +17,10 @@ export async function setupShadcn(config: ProjectConfig, projectDir: string, emi
14
17
 
15
18
  // Install shadcn/ui dependencies
16
19
  emitLog('Installing shadcn/ui dependencies...');
17
- execSync('npm install @shadcn/ui', { cwd: projectDir });
20
+ execSync('npm install @shadcn/ui class-variance-authority clsx tailwind-merge lucide-react', {
21
+ cwd: frontendDir,
22
+ stdio: 'inherit'
23
+ });
18
24
 
19
25
  // Create components.json configuration
20
26
  const componentsConfig = {
@@ -60,7 +66,7 @@ export function cn(...inputs: ClassValue[]) {
60
66
 
61
67
  emitLog('✅ shadcn/ui setup completed successfully!');
62
68
  } catch (error) {
63
- emitLog('Failed to setup shadcn/ui');
69
+ emitLog(`❌ Error setting up shadcn/ui: ${error instanceof Error ? error.message : 'Unknown error'}`);
64
70
  throw error;
65
71
  }
66
72
  }
@@ -55,9 +55,9 @@ export async function POST(req: NextRequest) {
55
55
  case 'react':
56
56
  await createReactJS(config, projectDir,emitLog)
57
57
  break
58
- // case 'nextjs':
59
- // await createNextJS(config, projectDir, emitLog);
60
- // break;
58
+ case 'nextjs':
59
+ await createNextJS(config, projectDir, emitLog);
60
+ break;
61
61
  case 'django':
62
62
  await installDjangoDependencies(projectDir);
63
63
  break;
@@ -71,7 +71,7 @@ export async function POST(req: NextRequest) {
71
71
  await createAngularTS(config, projectDir)
72
72
  break
73
73
  default:
74
- throw new Error(`Unsupported frontend`)
74
+ throw new Error(`Unsupported frontend: ${config.frontend}`)
75
75
  }
76
76
 
77
77
  switch(config.backend) {
@@ -89,7 +89,7 @@ export async function POST(req: NextRequest) {
89
89
  // await createNextJS(config, projectDir, emitLog);
90
90
  // break;
91
91
  default:
92
- throw new Error(`Unsupported backend`)
92
+ throw new Error(`Unsupported backend: ${config.backend}`)
93
93
  }
94
94
 
95
95
  switch(config.auth) {
@@ -103,7 +103,7 @@ export async function POST(req: NextRequest) {
103
103
  await setupPassport(config, projectDir,emitLog);
104
104
  break
105
105
  default:
106
- throw new Error(`Unsupported auth`)
106
+ throw new Error(`Unsupported auth: ${config.authentication}`)
107
107
  }
108
108
  switch(config.orm) {
109
109
  case 'drizzle':
@@ -116,7 +116,7 @@ export async function POST(req: NextRequest) {
116
116
  await setupMongoose(config, projectDir,emitLog);
117
117
  break
118
118
  default:
119
- throw new Error(`Unsupported orm`)
119
+ throw new Error(`Unsupported orm: ${config.orm}`)
120
120
  }
121
121
  const gitignore = `
122
122
  # Dependencies
@@ -49,7 +49,7 @@ const Navbar = () => (
49
49
  </div>
50
50
 
51
51
  <a
52
- href="https://github.com/shivasankaran18/STACKD"
52
+ href="https://github.com/ShyamSunder06/STACKD"
53
53
  target="_blank"
54
54
  rel="noopener noreferrer"
55
55
  className="absolute right-8 text-muted-foreground hover:text-foreground"
@@ -16,6 +16,7 @@
16
16
  "@radix-ui/react-scroll-area": "^1.2.3",
17
17
  "@radix-ui/react-slot": "^1.1.2",
18
18
  "@radix-ui/react-switch": "^1.1.3",
19
+ "@repo/ui": "*",
19
20
  "axios": "^1.7.9",
20
21
  "class-variance-authority": "^0.7.1",
21
22
  "clsx": "^2.1.1",
@@ -37,7 +38,7 @@
37
38
  },
38
39
  "devDependencies": {
39
40
  "@repo/eslint-config": "*",
40
-
41
+ "@repo/typescript-config": "*",
41
42
  "@types/d3": "^7.4.3",
42
43
  "@types/node": "^20.0.0",
43
44
  "@types/react": "19.0.8",