@shivasankaran18/stackd 2.0.2 → 12.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 +17 -7
  45. package/apps/cli/src/scripts/ui/tailwind.ts +0 -39
@@ -0,0 +1,72 @@
1
+ import { execSync } from 'node:child_process'
2
+ import { mkdir, writeFile } from 'node:fs/promises'
3
+ import { join } from 'node:path'
4
+ import { writeFileSync } from 'fs'
5
+
6
+ export async function createExpressJS(config, projectDir,emitLog) {
7
+ emitLog('Creating ExpressJS project...');
8
+ await mkdir(join(projectDir, 'backend'))
9
+ const backendPackageJson = {
10
+ name: "backend",
11
+ version: "1.0.0",
12
+ scripts: {
13
+ "dev": "nodemon src/index.js",
14
+ "start": "node src/index.js"
15
+ },
16
+ dependencies: {
17
+ "express": "^4.18.2",
18
+ "cors": "^2.8.5",
19
+ "dotenv": "^16.3.1"
20
+ },
21
+ devDependencies: {
22
+ "nodemon": "^2.0.22"
23
+ }
24
+ }
25
+
26
+ emitLog('Writing package.json...');
27
+ await writeFile(
28
+ join(projectDir, 'backend', 'package.json'),
29
+ JSON.stringify(backendPackageJson, null, 2)
30
+ )
31
+
32
+ emitLog('Creating src directory...');
33
+ await mkdir(join(projectDir, 'backend', 'src'))
34
+
35
+ const backendIndex = `
36
+ const express = require('express');
37
+ const cors = require('cors');
38
+ const dotenv = require('dotenv');
39
+
40
+ dotenv.config();
41
+
42
+ const app = express();
43
+ const port = process.env.PORT || ${config.backendPort};
44
+
45
+ app.use(cors());
46
+ app.use(express.json());
47
+
48
+ // Test route
49
+ app.get('/api/test', (req, res) => {
50
+ res.json({ message: 'Hello from Express!' });
51
+ });
52
+
53
+ // Health check route
54
+ app.get('/api/health', (req, res) => {
55
+ res.json({ status: 'ok', timestamp: new Date() });
56
+ });
57
+
58
+ app.listen(port, () => {
59
+ console.log(\`Server running on port \${port}\`);
60
+ });`
61
+
62
+ emitLog('Writing index.js...');
63
+ await writeFile(
64
+ join(projectDir, 'backend', 'src', 'index.js'),
65
+ backendIndex.trim()
66
+ )
67
+
68
+ emitLog('Installing dependencies...');
69
+ await execSync("npm install",{cwd : projectDir + '/backend',stdio : "inherit"});
70
+
71
+ emitLog('✅ ExpressJS project created successfully!');
72
+ }
@@ -0,0 +1,95 @@
1
+ import { execSync } from 'node:child_process'
2
+ import { mkdir, writeFile } from 'node:fs/promises'
3
+ import { join } from 'node:path'
4
+
5
+ export async function createExpressTS(config, projectDir ,emitLog) {
6
+ emitLog('Creating ExpressTS project...');
7
+ await mkdir(join(projectDir, 'backend'));
8
+ emitLog('Writing package.json...');
9
+ const backendPackageJson = {
10
+ name: "backend",
11
+ version: "1.0.0",
12
+ scripts: {
13
+ "dev": "ts-node-dev --respawn --transpile-only src/index.ts",
14
+ "build": "tsc",
15
+ "start": "node dist/index.js"
16
+ },
17
+ dependencies: {
18
+ "express": "^4.18.2",
19
+ "cors": "^2.8.5",
20
+ "dotenv": "^16.3.1"
21
+ },
22
+ devDependencies: {
23
+ "@types/express": "^4.17.17",
24
+ "@types/cors": "^2.8.13",
25
+ "@types/node": "^20.4.5",
26
+ "typescript": "^5.1.6",
27
+ "ts-node-dev": "^2.0.0"
28
+ }
29
+ }
30
+
31
+ await writeFile(
32
+ join(projectDir, 'backend', 'package.json'),
33
+ JSON.stringify(backendPackageJson, null, 2)
34
+ )
35
+ emitLog('Writing tsconfig.json...');
36
+ const tsConfig = {
37
+ compilerOptions: {
38
+ "target": "ES2020",
39
+ "module": "CommonJS",
40
+ "lib": ["ES2020"],
41
+ "moduleResolution": "node",
42
+ "outDir": "./dist",
43
+ "rootDir": "./src",
44
+ "strict": true,
45
+ "esModuleInterop": true,
46
+ "skipLibCheck": true,
47
+ "forceConsistentCasingInFileNames": true,
48
+ "resolveJsonModule": true
49
+ },
50
+ include: ["src/**/*"],
51
+ exclude: ["node_modules"]
52
+ }
53
+
54
+ await writeFile(
55
+ join(projectDir, 'backend', 'tsconfig.json'),
56
+ JSON.stringify(tsConfig, null, 2)
57
+ )
58
+ emitLog('Creating src directory...');
59
+ await mkdir(join(projectDir, 'backend', 'src'))
60
+ emitLog('Writing index.ts...');
61
+ const backendIndex = `
62
+ import express from 'express';
63
+ import cors from 'cors';
64
+ import dotenv from 'dotenv';
65
+
66
+ dotenv.config();
67
+
68
+ const app = express();
69
+ const port = process.env.PORT || ${config.backendPort};
70
+
71
+ app.use(cors());
72
+ app.use(express.json());
73
+
74
+ // Test route
75
+ app.get('/api/test', (req, res) => {
76
+ res.json({ message: 'Hello from Express!' });
77
+ });
78
+
79
+ // Health check route
80
+ app.get('/api/health', (req, res) => {
81
+ res.json({ status: 'ok', timestamp: new Date() });
82
+ });
83
+
84
+ app.listen(port, () => {
85
+ console.log(\`Server running on port \${port}\`);
86
+ });`
87
+ emitLog('Writing index.ts...');
88
+ await writeFile(
89
+ join(projectDir, 'backend', 'src', 'index.ts'),
90
+ backendIndex.trim()
91
+ )
92
+ emitLog('Installing dependencies...');
93
+ await execSync("npm install",{cwd : projectDir + '/backend',stdio : "inherit"});
94
+ emitLog('✅ ExpressTS project created successfully!');
95
+ }
@@ -0,0 +1,29 @@
1
+ import { execSync } from "child_process";
2
+ import path from "path";
3
+
4
+ export default async function createAngularTS(config, projectDir) {
5
+ try {
6
+
7
+ const projectFullPath = path.join(projectDir, 'frontend');
8
+
9
+ console.log('Installing Angular CLI...');
10
+ await execSync(`npx @angular/cli@latest new frontend --skip-git --style=scss --routing=true --strict`, {
11
+ cwd: projectDir,
12
+ stdio: 'inherit'
13
+ });
14
+
15
+
16
+ console.log('Installing dependencies...');
17
+ await execSync('npm install', {
18
+ cwd: projectFullPath,
19
+ stdio: 'inherit'
20
+ });
21
+
22
+ console.log('Angular project created successfully!');
23
+
24
+ } catch (error) {
25
+ console.error('Error creating Angular project:', error);
26
+ throw error;
27
+ }
28
+ }
29
+
@@ -0,0 +1,42 @@
1
+ import { mkdir, writeFile } from 'fs/promises';
2
+ import { join } from 'path';
3
+ import { execSync } from 'child_process';
4
+
5
+ export async function createReactJS(config, projectDir,emitLog) {
6
+ emitLog("Creating React JavaScript frontend...");
7
+
8
+ await execSync(`npm create vite@latest frontend -- --template react`, {
9
+ cwd: projectDir,
10
+ stdio: 'inherit',
11
+ shell: true
12
+ });
13
+
14
+ emitLog("Installing dependencies...");
15
+ await execSync('npm install', {
16
+ cwd: join(projectDir, 'frontend'),
17
+ stdio: 'inherit',
18
+ shell: true
19
+ });
20
+
21
+ const viteConfig = `
22
+ import { defineConfig } from 'vite'
23
+ import react from '@vitejs/plugin-react'
24
+
25
+ export default defineConfig({
26
+ plugins: [react()],
27
+ server: {
28
+ port: ${config.frontendPort},
29
+ proxy: {
30
+ '/api': {
31
+ target: 'http://localhost:${config.backendPort}',
32
+ changeOrigin: true
33
+ }
34
+ }
35
+ }
36
+ })`;
37
+
38
+ await writeFile(
39
+ join(projectDir, 'frontend', 'vite.config.js'),
40
+ viteConfig.trim()
41
+ );
42
+ }
@@ -0,0 +1,13 @@
1
+ export interface ProjectConfig {
2
+ projectName: string;
3
+ projectPath: string;
4
+ frontendPort: number;
5
+ backendPort: number;
6
+ dbUrl: string;
7
+ }
8
+
9
+ export function createReactTS(
10
+ config: ProjectConfig,
11
+ projectDir: string,
12
+ emitLog: (message: string) => void
13
+ ): Promise<void>;
@@ -0,0 +1,40 @@
1
+ import { writeFile } from 'fs/promises';
2
+ import { join } from 'path';
3
+ import { execSync } from 'child_process';
4
+
5
+ export async function createReactTS(config, projectDir,emitLog) {
6
+ emitLog("Creating React TypeScript frontend...");
7
+
8
+ await execSync(`npm create vite@latest frontend -- --template react-ts`, {
9
+ cwd: projectDir,
10
+ stdio: 'inherit'
11
+ });
12
+
13
+ emitLog("Installing dependencies...");
14
+ await execSync('npm install', {
15
+ cwd: join(projectDir, 'frontend'),
16
+ stdio: 'inherit'
17
+ });
18
+
19
+ const viteConfig = `
20
+ import { defineConfig } from 'vite'
21
+ import react from '@vitejs/plugin-react'
22
+
23
+ export default defineConfig({
24
+ plugins: [react()],
25
+ server: {
26
+ port: ${config.frontendPort},
27
+ proxy: {
28
+ '/api': {
29
+ target: 'http://localhost:${config.backendPort}',
30
+ changeOrigin: true
31
+ }
32
+ }
33
+ }
34
+ })`;
35
+
36
+ await writeFile(
37
+ join(projectDir, 'frontend', 'vite.config.ts'),
38
+ viteConfig.trim()
39
+ );
40
+ }
@@ -0,0 +1,43 @@
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 createVueJS(config, projectDir,emitLog) {
6
+ emitLog('Creating VueJS project...');
7
+ await execSync(`npm create vite@latest frontend -- --template vue`, {
8
+ cwd: projectDir,
9
+ stdio: 'inherit'
10
+ })
11
+
12
+ emitLog('Installing Vite...');
13
+ console.log(projectDir)
14
+ console.log(config)
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.js`),
35
+ viteConfig.trim()
36
+ )
37
+ emitLog('Installing Vue Router and Pinia...');
38
+ await execSync('npm install vue-router@4 pinia@2', {
39
+ cwd: join(projectDir, 'frontend'),
40
+ stdio: 'inherit'
41
+ })
42
+ emitLog('✅ VueJS project created successfully!');
43
+ }
@@ -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, projectDir,emitLog) {
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, projectDir, emitLog) {
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, projectDir,emitLog) {
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, projectDir,emitLog) {
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
+ }