@shivasankaran18/stackd 1.1.0 → 1.2.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 (67) hide show
  1. package/dist/apps/cli/src/cli.js +217 -0
  2. package/dist/apps/cli/src/commands/create.js +148 -0
  3. package/dist/apps/cli/src/scripts/Auth/jwt.js +78 -0
  4. package/dist/apps/cli/src/scripts/Auth/nextAuth.js +131 -0
  5. package/dist/apps/cli/src/scripts/Auth/passport.js +218 -0
  6. package/dist/apps/cli/src/scripts/backend/django.js +20 -0
  7. package/dist/apps/cli/src/scripts/backend/expressjs.js +58 -0
  8. package/dist/apps/cli/src/scripts/backend/expressts.js +83 -0
  9. package/dist/apps/cli/src/scripts/frontend/angularjs.js +1 -0
  10. package/dist/apps/cli/src/scripts/frontend/angularts.js +22 -0
  11. package/dist/apps/cli/src/scripts/frontend/nextjs.js +62 -0
  12. package/dist/apps/cli/src/scripts/frontend/reactjs.js +31 -0
  13. package/dist/apps/cli/src/scripts/frontend/reactts.js +30 -0
  14. package/dist/apps/cli/src/scripts/frontend/vuejs.js +37 -0
  15. package/dist/apps/cli/src/scripts/frontend/vuets.js +43 -0
  16. package/dist/apps/cli/src/scripts/orms/drizzleSetup.js +85 -0
  17. package/dist/apps/cli/src/scripts/orms/mongoSetup.js +53 -0
  18. package/dist/apps/cli/src/scripts/orms/prismaSetup.js +12 -0
  19. package/dist/apps/cli/src/scripts/ui/shadcn.js +207 -0
  20. package/dist/apps/cli/src/scripts/ui/tailwindcss.js +102 -0
  21. package/dist/apps/web/app/api/auth/[...nextauth]/route.js +5 -0
  22. package/dist/apps/web/app/api/scaffold/route.js +251 -0
  23. package/dist/apps/web/app/home/page.js +19 -0
  24. package/dist/apps/web/app/layout.js +19 -0
  25. package/dist/apps/web/app/page.js +1 -0
  26. package/dist/apps/web/app/providers.js +7 -0
  27. package/dist/apps/web/app/scaffold/page.js +326 -0
  28. package/dist/apps/web/components/Sidebar.js +54 -0
  29. package/dist/apps/web/components/theme-provider.js +6 -0
  30. package/dist/apps/web/components/ui/button.js +32 -0
  31. package/dist/apps/web/components/ui/card.js +15 -0
  32. package/dist/apps/web/components/ui/dropdown-menu.js +54 -0
  33. package/dist/apps/web/components/ui/input.js +7 -0
  34. package/dist/apps/web/components/ui/label.js +9 -0
  35. package/dist/apps/web/components/ui/scroll-area.js +19 -0
  36. package/dist/apps/web/components/ui/sonner.js +15 -0
  37. package/dist/apps/web/components/ui/steps.js +14 -0
  38. package/dist/apps/web/components/ui/switch.js +9 -0
  39. package/dist/apps/web/lib/auth.js +32 -0
  40. package/dist/apps/web/lib/redis.js +9 -0
  41. package/dist/apps/web/lib/utils.js +5 -0
  42. package/dist/packages/scripts/Auth/jwt.js +78 -0
  43. package/dist/packages/scripts/Auth/nextAuth.js +131 -0
  44. package/dist/packages/scripts/Auth/passport.js +218 -0
  45. package/dist/packages/scripts/backend/django.js +20 -0
  46. package/dist/packages/scripts/backend/expressjs.js +58 -0
  47. package/dist/packages/scripts/backend/expressts.js +83 -0
  48. package/dist/packages/scripts/frontend/angularjs.js +1 -0
  49. package/dist/packages/scripts/frontend/angularts.js +22 -0
  50. package/dist/packages/scripts/frontend/nextjs.js +62 -0
  51. package/dist/packages/scripts/frontend/reactjs.js +31 -0
  52. package/dist/packages/scripts/frontend/reactts.js +30 -0
  53. package/dist/packages/scripts/frontend/vuejs.js +37 -0
  54. package/dist/packages/scripts/frontend/vuets.js +43 -0
  55. package/dist/packages/scripts/orms/drizzleSetup.js +85 -0
  56. package/dist/packages/scripts/orms/mongoSetup.js +53 -0
  57. package/dist/packages/scripts/orms/prismaSetup.js +12 -0
  58. package/dist/packages/scripts/ui/shadcn.js +207 -0
  59. package/dist/packages/scripts/ui/tailwindcss.js +102 -0
  60. package/dist/packages/ui/src/button.js +10 -0
  61. package/dist/packages/ui/src/card.js +11 -0
  62. package/dist/packages/ui/src/code.js +6 -0
  63. package/dist/packages/ui/turbo/generators/config.js +30 -0
  64. package/dist/stackd.js +114 -0
  65. package/dist/tsconfig.tsbuildinfo +1 -0
  66. package/package.json +3 -3
  67. package/stackd.ts +0 -0
@@ -0,0 +1,218 @@
1
+ import { join } from 'node:path';
2
+ import { mkdir, writeFile } from 'node:fs/promises';
3
+ export async function setupPassport(config, projectDir, emitLog) {
4
+ emitLog('Setting up Passport...');
5
+ try {
6
+ const backendDir = join(projectDir, 'backend');
7
+ const authDir = join(backendDir, 'src', 'auth');
8
+ const configDir = join(backendDir, 'src', 'config');
9
+ emitLog('Creating auth and config directories...');
10
+ await mkdir(authDir, { recursive: true });
11
+ await mkdir(configDir, { recursive: true });
12
+ const passportConfigCode = `
13
+ import passport from 'passport';
14
+ import { Strategy as LocalStrategy } from 'passport-local';
15
+ import { Strategy as JwtStrategy, ExtractJwt } from 'passport-jwt';
16
+ import { Strategy as GoogleStrategy } from 'passport-google-oauth20';
17
+ import { User } from '../models/user.model';
18
+ import { config } from '../config';
19
+
20
+ // Local Strategy
21
+ passport.use(new LocalStrategy(
22
+ { usernameField: 'email' },
23
+ async (email, password, done) => {
24
+ try {
25
+ const user = await User.findOne({ email });
26
+ if (!user) {
27
+ return done(null, false, { message: 'Incorrect email.' });
28
+ }
29
+
30
+ const isValid = await user.comparePassword(password);
31
+ if (!isValid) {
32
+ return done(null, false, { message: 'Incorrect password.' });
33
+ }
34
+
35
+ return done(null, user);
36
+ } catch (error) {
37
+ return done(error);
38
+ }
39
+ }
40
+ ));
41
+
42
+ // JWT Strategy
43
+ passport.use(new JwtStrategy(
44
+ {
45
+ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
46
+ secretOrKey: config.jwt.secret,
47
+ },
48
+ async (payload, done) => {
49
+ try {
50
+ const user = await User.findById(payload.sub);
51
+ if (!user) {
52
+ return done(null, false);
53
+ }
54
+ return done(null, user);
55
+ } catch (error) {
56
+ return done(error, false);
57
+ }
58
+ }
59
+ ));
60
+
61
+ // Google OAuth Strategy
62
+ passport.use(new GoogleStrategy(
63
+ {
64
+ clientID: config.google.clientId,
65
+ clientSecret: config.google.clientSecret,
66
+ callbackURL: '/auth/google/callback',
67
+ },
68
+ async (accessToken, refreshToken, profile, done) => {
69
+ try {
70
+ let user = await User.findOne({ googleId: profile.id });
71
+
72
+ if (!user) {
73
+ user = await User.create({
74
+ googleId: profile.id,
75
+ email: profile.emails?.[0]?.value,
76
+ name: profile.displayName,
77
+ });
78
+ }
79
+
80
+ return done(null, user);
81
+ } catch (error) {
82
+ return done(error, false);
83
+ }
84
+ }
85
+ ));
86
+
87
+ // Serialization
88
+ passport.serializeUser((user: any, done) => {
89
+ done(null, user.id);
90
+ });
91
+
92
+ passport.deserializeUser(async (id: string, done) => {
93
+ try {
94
+ const user = await User.findById(id);
95
+ done(null, user);
96
+ } catch (error) {
97
+ done(error);
98
+ }
99
+ });
100
+
101
+ export default passport;
102
+ `;
103
+ emitLog('Writing passport.config.ts...');
104
+ await writeFile(join(authDir, 'passport.config.ts'), passportConfigCode.trim() + '\n');
105
+ emitLog('Creating authentication middleware...');
106
+ const authMiddlewareCode = `
107
+ import { Request, Response, NextFunction } from 'express';
108
+ import passport from 'passport';
109
+ import jwt from 'jsonwebtoken';
110
+ import { config } from '../config';
111
+
112
+ export const authenticateJWT = passport.authenticate('jwt', { session: false });
113
+
114
+ export const authenticateLocal = (req: Request, res: Response, next: NextFunction) => {
115
+ passport.authenticate('local', { session: false }, (err, user, info) => {
116
+ if (err) {
117
+ return next(err);
118
+ }
119
+ if (!user) {
120
+ return res.status(401).json({ message: info?.message || 'Authentication failed' });
121
+ }
122
+
123
+ const token = jwt.sign({ sub: user.id }, config.jwt.secret, {
124
+ expiresIn: config.jwt.expiresIn,
125
+ });
126
+
127
+ req.user = user;
128
+ res.locals.token = token;
129
+ next();
130
+ })(req, res, next);
131
+ };
132
+
133
+ export const isAuthenticated = (req: Request, res: Response, next: NextFunction) => {
134
+ if (req.isAuthenticated()) {
135
+ return next();
136
+ }
137
+ res.status(401).json({ message: 'Unauthorized' });
138
+ };
139
+ `;
140
+ emitLog('Writing middleware.ts...');
141
+ await writeFile(join(authDir, 'middleware.ts'), authMiddlewareCode.trim() + '\n');
142
+ emitLog('Creating authentication routes...');
143
+ const authRoutesCode = `
144
+ import { Router } from 'express';
145
+ import passport from 'passport';
146
+ import { authenticateLocal } from './middleware';
147
+
148
+ const router = Router();
149
+
150
+ router.post('/login', authenticateLocal, (req, res) => {
151
+ res.json({
152
+ user: req.user,
153
+ token: res.locals.token,
154
+ });
155
+ });
156
+
157
+ router.post('/register', async (req, res) => {
158
+ // Add your registration logic here
159
+ });
160
+
161
+ router.get('/google',
162
+ passport.authenticate('google', { scope: ['profile', 'email'] })
163
+ );
164
+
165
+ router.get('/google/callback',
166
+ passport.authenticate('google', { session: false }),
167
+ (req, res) => {
168
+ // Handle successful authentication
169
+ res.redirect('/');
170
+ }
171
+ );
172
+
173
+ router.post('/logout', (req, res) => {
174
+ req.logout();
175
+ res.json({ message: 'Logged out successfully' });
176
+ });
177
+
178
+ export default router;
179
+ `;
180
+ emitLog('Writing routes.ts...');
181
+ await writeFile(join(authDir, 'routes.ts'), authRoutesCode.trim() + '\n');
182
+ emitLog('Creating configuration file...');
183
+ const configCode = `
184
+ export const config = {
185
+ jwt: {
186
+ secret: process.env.JWT_SECRET || 'your-secret-key',
187
+ expiresIn: '1d',
188
+ },
189
+ google: {
190
+ clientId: process.env.GOOGLE_CLIENT_ID,
191
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET,
192
+ },
193
+ session: {
194
+ secret: process.env.SESSION_SECRET || 'session-secret',
195
+ },
196
+ };
197
+ `;
198
+ emitLog('Writing index.ts...');
199
+ await writeFile(join(configDir, 'index.ts'), configCode.trim() + '\n');
200
+ emitLog('Adding environment variables...');
201
+ const envContent = `
202
+ # Authentication
203
+ JWT_SECRET=your-jwt-secret-key
204
+ SESSION_SECRET=your-session-secret
205
+
206
+ # Google OAuth
207
+ GOOGLE_CLIENT_ID=your-google-client-id
208
+ GOOGLE_CLIENT_SECRET=your-google-client-secret
209
+ `;
210
+ emitLog('Writing .env file...');
211
+ await writeFile(join(backendDir, '.env'), envContent.trim() + '\n');
212
+ emitLog('✅ Passport.js setup completed successfully!');
213
+ }
214
+ catch (error) {
215
+ emitLog(`❌ Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
216
+ throw error;
217
+ }
218
+ }
@@ -0,0 +1,20 @@
1
+ import { exec } from 'child_process';
2
+ import { mkdirSync } from 'fs';
3
+ import util from 'util';
4
+ const execAsync = util.promisify(exec);
5
+ export async function installDjangoDependencies(projectPath) {
6
+ try {
7
+ mkdirSync(`${projectPath}/backend`, { recursive: true });
8
+ await execAsync('python -m venv venv', { cwd: `${projectPath}/backend` });
9
+ const pythonCmd = process.platform === 'win32' ? 'venv\\Scripts\\python.exe' : 'venv/bin/python';
10
+ await execAsync(`${pythonCmd} -m pip install django djangorestframework django-cors-headers djangorestframework_simplejwt`, { cwd: `${projectPath}/backend` });
11
+ await execAsync(`${pythonCmd} -m django startproject core .`, { cwd: `${projectPath}/backend` });
12
+ await execAsync(`${pythonCmd} manage.py startapp main`, { cwd: `${projectPath}/backend` });
13
+ console.log("Django project setup completed!");
14
+ }
15
+ catch (error) {
16
+ console.error('Error installing Django dependencies:', error);
17
+ throw error;
18
+ }
19
+ }
20
+ export default installDjangoDependencies;
@@ -0,0 +1,58 @@
1
+ import { execSync } from 'node:child_process';
2
+ import { mkdir, writeFile } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ export async function createExpressJS(config, projectDir, emitLog) {
5
+ emitLog('Creating ExpressJS project...');
6
+ await mkdir(join(projectDir, 'backend'));
7
+ const backendPackageJson = {
8
+ name: "backend",
9
+ version: "1.0.0",
10
+ scripts: {
11
+ "dev": "nodemon src/index.js",
12
+ "start": "node src/index.js"
13
+ },
14
+ dependencies: {
15
+ "express": "^4.18.2",
16
+ "cors": "^2.8.5",
17
+ "dotenv": "^16.3.1"
18
+ },
19
+ devDependencies: {
20
+ "nodemon": "^2.0.22"
21
+ }
22
+ };
23
+ emitLog('Writing package.json...');
24
+ await writeFile(join(projectDir, 'backend', 'package.json'), JSON.stringify(backendPackageJson, null, 2));
25
+ emitLog('Creating src directory...');
26
+ await mkdir(join(projectDir, 'backend', 'src'));
27
+ const backendIndex = `
28
+ const express = require('express');
29
+ const cors = require('cors');
30
+ const dotenv = require('dotenv');
31
+
32
+ dotenv.config();
33
+
34
+ const app = express();
35
+ const port = process.env.PORT || ${config.backendPort};
36
+
37
+ app.use(cors());
38
+ app.use(express.json());
39
+
40
+ // Test route
41
+ app.get('/api/test', (req, res) => {
42
+ res.json({ message: 'Hello from Express!' });
43
+ });
44
+
45
+ // Health check route
46
+ app.get('/api/health', (req, res) => {
47
+ res.json({ status: 'ok', timestamp: new Date() });
48
+ });
49
+
50
+ app.listen(port, () => {
51
+ console.log(\`Server running on port \${port}\`);
52
+ });`;
53
+ emitLog('Writing index.js...');
54
+ await writeFile(join(projectDir, 'backend', 'src', 'index.js'), backendIndex.trim());
55
+ emitLog('Installing dependencies...');
56
+ await execSync("npm install", { cwd: projectDir + '/backend', stdio: "inherit" });
57
+ emitLog('✅ ExpressJS project created successfully!');
58
+ }
@@ -0,0 +1,83 @@
1
+ import { execSync } from 'node:child_process';
2
+ import { mkdir, writeFile } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ export async function createExpressTS(config, projectDir, emitLog) {
5
+ emitLog('Creating ExpressTS project...');
6
+ await mkdir(join(projectDir, 'backend'));
7
+ emitLog('Writing package.json...');
8
+ const backendPackageJson = {
9
+ name: "backend",
10
+ version: "1.0.0",
11
+ scripts: {
12
+ "dev": "ts-node-dev --respawn --transpile-only src/index.ts",
13
+ "build": "tsc",
14
+ "start": "node dist/index.js"
15
+ },
16
+ dependencies: {
17
+ "express": "^4.18.2",
18
+ "cors": "^2.8.5",
19
+ "dotenv": "^16.3.1"
20
+ },
21
+ devDependencies: {
22
+ "@types/express": "^4.17.17",
23
+ "@types/cors": "^2.8.13",
24
+ "@types/node": "^20.4.5",
25
+ "typescript": "^5.1.6",
26
+ "ts-node-dev": "^2.0.0"
27
+ }
28
+ };
29
+ await writeFile(join(projectDir, 'backend', 'package.json'), JSON.stringify(backendPackageJson, null, 2));
30
+ emitLog('Writing tsconfig.json...');
31
+ const tsConfig = {
32
+ compilerOptions: {
33
+ "target": "ES2020",
34
+ "module": "CommonJS",
35
+ "lib": ["ES2020"],
36
+ "moduleResolution": "node",
37
+ "outDir": "./dist",
38
+ "rootDir": "./src",
39
+ "strict": true,
40
+ "esModuleInterop": true,
41
+ "skipLibCheck": true,
42
+ "forceConsistentCasingInFileNames": true,
43
+ "resolveJsonModule": true
44
+ },
45
+ include: ["src/**/*"],
46
+ exclude: ["node_modules"]
47
+ };
48
+ await writeFile(join(projectDir, 'backend', 'tsconfig.json'), JSON.stringify(tsConfig, null, 2));
49
+ emitLog('Creating src directory...');
50
+ await mkdir(join(projectDir, 'backend', 'src'));
51
+ emitLog('Writing index.ts...');
52
+ const backendIndex = `
53
+ import express from 'express';
54
+ import cors from 'cors';
55
+ import dotenv from 'dotenv';
56
+
57
+ dotenv.config();
58
+
59
+ const app = express();
60
+ const port = process.env.PORT || ${config.backendPort};
61
+
62
+ app.use(cors());
63
+ app.use(express.json());
64
+
65
+ // Test route
66
+ app.get('/api/test', (req, res) => {
67
+ res.json({ message: 'Hello from Express!' });
68
+ });
69
+
70
+ // Health check route
71
+ app.get('/api/health', (req, res) => {
72
+ res.json({ status: 'ok', timestamp: new Date() });
73
+ });
74
+
75
+ app.listen(port, () => {
76
+ console.log(\`Server running on port \${port}\`);
77
+ });`;
78
+ emitLog('Writing index.ts...');
79
+ await writeFile(join(projectDir, 'backend', 'src', 'index.ts'), backendIndex.trim());
80
+ emitLog('Installing dependencies...');
81
+ await execSync("npm install", { cwd: projectDir + '/backend', stdio: "inherit" });
82
+ emitLog('✅ ExpressTS project created successfully!');
83
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { execSync } from "child_process";
2
+ import path from "path";
3
+ export default async function createAngularTS(config, projectDir) {
4
+ try {
5
+ const projectFullPath = path.join(projectDir, 'frontend');
6
+ console.log('Installing Angular CLI...');
7
+ await execSync(`npx @angular/cli@latest new frontend --skip-git --style=scss --routing=true --strict`, {
8
+ cwd: projectDir,
9
+ stdio: 'inherit'
10
+ });
11
+ console.log('Installing dependencies...');
12
+ await execSync('npm install', {
13
+ cwd: projectFullPath,
14
+ stdio: 'inherit'
15
+ });
16
+ console.log('Angular project created successfully!');
17
+ }
18
+ catch (error) {
19
+ console.error('Error creating Angular project:', error);
20
+ throw error;
21
+ }
22
+ }
@@ -0,0 +1,62 @@
1
+ // import { join } from 'node:path'
2
+ // import { execSync, ExecSyncOptions } from 'child_process'
3
+ // import { writeFile, mkdir } from 'node:fs/promises'
4
+ // import { existsSync } from 'fs'
5
+ export {};
6
+ // export async function createNextJS(config: any, projectDir: string, emitLog: (log: string) => void) {
7
+ // try {
8
+ // const frontendDir = join(projectDir, 'frontend');
9
+ // if (!existsSync(frontendDir)) {
10
+ // emitLog('Creating frontend directory...');
11
+ // await mkdir(frontendDir, { recursive: true });
12
+ // }
13
+ // emitLog('Creating Next.js project...');
14
+ // const execOptions: ExecSyncOptions = {
15
+ // cwd: frontendDir,
16
+ // stdio: 'inherit',
17
+ // encoding: 'utf-8'
18
+ // };
19
+ // execSync('npx create-next-app@latest . --typescript --tailwind --eslint --app --src-dir --import-alias "@/*" --no-git', execOptions);
20
+ // emitLog('Updating package.json...');
21
+ // const packageJsonPath = join(frontendDir, 'package.json');
22
+ // const packageJson = require(packageJsonPath);
23
+ // packageJson.scripts.dev = `next dev -p ${config.frontendPort}`;
24
+ // await writeFile(
25
+ // packageJsonPath,
26
+ // JSON.stringify(packageJson, null, 2)
27
+ // );
28
+ // emitLog('Creating environment file...');
29
+ // const envContent = `
30
+ // NEXT_PUBLIC_API_URL=http://localhost:${config.backendPort}
31
+ // NEXTAUTH_URL=http://localhost:${config.frontendPort}
32
+ // NEXTAUTH_SECRET=your-secret-key-here
33
+ // `;
34
+ // await writeFile(
35
+ // join(frontendDir, '.env'),
36
+ // envContent.trim() + '\n'
37
+ // );
38
+ // emitLog('Setting up API proxy...');
39
+ // const nextConfigContent = `
40
+ // /** @type {import('next').NextConfig} */
41
+ // const nextConfig = {
42
+ // async rewrites() {
43
+ // return [
44
+ // {
45
+ // source: '/api/:path*',
46
+ // destination: 'http://localhost:${config.backendPort}/api/:path*'
47
+ // }
48
+ // ]
49
+ // }
50
+ // }
51
+ // module.exports = nextConfig
52
+ // `;
53
+ // await writeFile(
54
+ // join(frontendDir, 'next.config.js'),
55
+ // nextConfigContent.trim() + '\n'
56
+ // );
57
+ // emitLog('✅ Next.js setup completed successfully!');
58
+ // } catch (error) {
59
+ // emitLog(`❌ Error setting up Next.js: ${error instanceof Error ? error.message : 'Unknown error'}`);
60
+ // throw error;
61
+ // }
62
+ // }
@@ -0,0 +1,31 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
+ export async function createReactJS(config, projectDir, emitLog) {
5
+ emitLog('Creating ReactJS project...');
6
+ await execSync(`npm create vite@latest frontend -- --template react`, {
7
+ cwd: projectDir,
8
+ stdio: 'inherit'
9
+ });
10
+ emitLog('Installing the dependencies for the frontend...');
11
+ await execSync("npm install", { cwd: projectDir + "/frontend", stdio: "inherit" });
12
+ emitLog('Writing Vite configuration...');
13
+ const viteConfig = `
14
+ import { defineConfig } from 'vite'
15
+ import react from '@vitejs/plugin-react'
16
+
17
+ export default defineConfig({
18
+ plugins: [react()],
19
+ server: {
20
+ port: ${config.frontendPort},
21
+ proxy: {
22
+ '/api': {
23
+ target: 'http://localhost:${config.backendPort}',
24
+ changeOrigin: true
25
+ }
26
+ }
27
+ }
28
+ })`;
29
+ await writeFile(join(projectDir, 'frontend', 'vite.config.js'), viteConfig.trim());
30
+ emitLog('✅ ReactJS project created successfully!');
31
+ }
@@ -0,0 +1,30 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
+ export async function createReactTS(config, projectDir, emitLog) {
5
+ emitLog('Creating ReactTS project...');
6
+ await execSync(`npm create vite@latest frontend -- --template react-ts`, {
7
+ cwd: projectDir,
8
+ stdio: 'inherit'
9
+ });
10
+ emitLog('Installing the dependencies...');
11
+ await execSync('npm install', { cwd: projectDir + '/frontend', stdio: 'inherit' });
12
+ emitLog('Writing Vite configuration...');
13
+ const viteConfig = `
14
+ import { defineConfig } from 'vite'
15
+ import react from '@vitejs/plugin-react'
16
+ export default defineConfig({
17
+ plugins: [react()],
18
+ server: {
19
+ port: ${config.frontendPort},
20
+ proxy: {
21
+ '/api': {
22
+ target: 'http://localhost:${config.backendPort}',
23
+ changeOrigin: true
24
+ }
25
+ }
26
+ }
27
+ })`;
28
+ await writeFile(join(projectDir, 'frontend', 'vite.config.ts'), viteConfig.trim());
29
+ emitLog('✅ ReactTS project created successfully!');
30
+ }
@@ -0,0 +1,37 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
+ export async function createVueJS(config, projectDir, emitLog) {
5
+ emitLog('Creating VueJS project...');
6
+ await execSync(`npm create vite@latest frontend -- --template vue`, {
7
+ cwd: projectDir,
8
+ stdio: 'inherit'
9
+ });
10
+ emitLog('Installing Vite...');
11
+ console.log(projectDir);
12
+ console.log(config);
13
+ const viteConfig = `
14
+ import { defineConfig } from 'vite'
15
+ import vue from '@vitejs/plugin-vue'
16
+
17
+ export default defineConfig({
18
+ plugins: [vue()],
19
+ server: {
20
+ port: ${config.frontendPort},
21
+ proxy: {
22
+ '/api': {
23
+ target: 'http://localhost:${config.backendPort}',
24
+ changeOrigin: true
25
+ }
26
+ }
27
+ }
28
+ })`;
29
+ emitLog('Writing Vite configuration...');
30
+ await writeFile(join(projectDir, 'frontend', `vite.config.js`), viteConfig.trim());
31
+ emitLog('Installing Vue Router and Pinia...');
32
+ await execSync('npm install vue-router@4 pinia@2', {
33
+ cwd: join(projectDir, 'frontend'),
34
+ stdio: 'inherit'
35
+ });
36
+ emitLog('✅ VueJS project created successfully!');
37
+ }
@@ -0,0 +1,43 @@
1
+ import { writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
+ export async function createVueTS(config, projectDir, emitLog) {
5
+ emitLog('Creating VueTS project...');
6
+ emitLog('Installing Vite...');
7
+ await execSync(`npm create vite@latest frontend -- --template vue-ts`, {
8
+ cwd: projectDir,
9
+ stdio: 'inherit'
10
+ });
11
+ emitLog('Configuring Vite...');
12
+ const viteConfig = `
13
+ import { defineConfig } from 'vite'
14
+ import vue from '@vitejs/plugin-vue'
15
+
16
+ export default defineConfig({
17
+ plugins: [vue()],
18
+ server: {
19
+ port: ${config.frontendPort},
20
+ proxy: {
21
+ '/api': {
22
+ target: 'http://localhost:${config.backendPort}',
23
+ changeOrigin: true
24
+ }
25
+ }
26
+ }
27
+ })`;
28
+ emitLog('Writing Vite configuration...');
29
+ await writeFile(join(projectDir, 'frontend', `vite.config.ts`), viteConfig.trim());
30
+ emitLog('Installing Vue Router and Pinia...');
31
+ await execSync('npm install vue-router@4 pinia@2', {
32
+ cwd: join(projectDir, 'frontend'),
33
+ stdio: 'inherit'
34
+ });
35
+ emitLog('Installing TypeScript and other dependencies...');
36
+ if (config.frontend === 'vue-ts') {
37
+ await execSync('npm install -D @types/node', {
38
+ cwd: join(projectDir, 'frontend'),
39
+ stdio: 'inherit'
40
+ });
41
+ }
42
+ emitLog('✅ VueTS project created successfully!');
43
+ }