@shivasankaran18/stackd 1.7.0 → 2.0.1
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.
- package/apps/cli/src/cli.ts +28 -2
- package/apps/cli/src/commands/create.ts +30 -0
- package/apps/cli/src/scripts/ui/shadcn.ts +4 -10
- package/apps/cli/src/scripts/ui/tailwind.ts +39 -0
- package/apps/web/app/scaffold/page.tsx +1 -1
- package/apps/web/package.json +1 -1
- package/apps/web/tsconfig.json +108 -20
- package/package.json +19 -21
- package/stackd.ts +0 -0
- package/dist/apps/cli/src/cli.js +0 -217
- package/dist/apps/cli/src/commands/create.js +0 -148
- package/dist/apps/cli/src/scripts/Auth/jwt.js +0 -78
- package/dist/apps/cli/src/scripts/Auth/nextAuth.js +0 -131
- package/dist/apps/cli/src/scripts/Auth/passport.js +0 -218
- package/dist/apps/cli/src/scripts/backend/django.js +0 -20
- package/dist/apps/cli/src/scripts/backend/expressjs.js +0 -58
- package/dist/apps/cli/src/scripts/backend/expressts.js +0 -83
- package/dist/apps/cli/src/scripts/frontend/angularjs.js +0 -1
- package/dist/apps/cli/src/scripts/frontend/angularts.js +0 -22
- package/dist/apps/cli/src/scripts/frontend/nextjs.js +0 -62
- package/dist/apps/cli/src/scripts/frontend/reactjs.js +0 -31
- package/dist/apps/cli/src/scripts/frontend/reactts.js +0 -30
- package/dist/apps/cli/src/scripts/frontend/vuejs.js +0 -37
- package/dist/apps/cli/src/scripts/frontend/vuets.js +0 -43
- package/dist/apps/cli/src/scripts/orms/drizzleSetup.js +0 -85
- package/dist/apps/cli/src/scripts/orms/mongoSetup.js +0 -53
- package/dist/apps/cli/src/scripts/orms/prismaSetup.js +0 -12
- package/dist/apps/cli/src/scripts/ui/shadcn.js +0 -207
- package/dist/apps/cli/src/scripts/ui/tailwindcss.js +0 -102
- package/dist/apps/web/app/api/auth/[...nextauth]/route.js +0 -5
- package/dist/apps/web/app/api/scaffold/route.js +0 -251
- package/dist/apps/web/app/home/page.js +0 -19
- package/dist/apps/web/app/layout.js +0 -19
- package/dist/apps/web/app/page.js +0 -1
- package/dist/apps/web/app/providers.js +0 -7
- package/dist/apps/web/app/scaffold/page.js +0 -326
- package/dist/apps/web/components/Sidebar.js +0 -54
- package/dist/apps/web/components/theme-provider.js +0 -6
- package/dist/apps/web/components/ui/button.js +0 -32
- package/dist/apps/web/components/ui/card.js +0 -15
- package/dist/apps/web/components/ui/dropdown-menu.js +0 -54
- package/dist/apps/web/components/ui/input.js +0 -7
- package/dist/apps/web/components/ui/label.js +0 -9
- package/dist/apps/web/components/ui/scroll-area.js +0 -19
- package/dist/apps/web/components/ui/sonner.js +0 -15
- package/dist/apps/web/components/ui/steps.js +0 -14
- package/dist/apps/web/components/ui/switch.js +0 -9
- package/dist/apps/web/lib/auth.js +0 -32
- package/dist/apps/web/lib/redis.js +0 -9
- package/dist/apps/web/lib/utils.js +0 -5
- package/dist/packages/scripts/Auth/jwt.js +0 -78
- package/dist/packages/scripts/Auth/nextAuth.js +0 -131
- package/dist/packages/scripts/Auth/passport.js +0 -218
- package/dist/packages/scripts/backend/django.js +0 -20
- package/dist/packages/scripts/backend/expressjs.js +0 -58
- package/dist/packages/scripts/backend/expressts.js +0 -83
- package/dist/packages/scripts/frontend/angularjs.js +0 -1
- package/dist/packages/scripts/frontend/angularts.js +0 -22
- package/dist/packages/scripts/frontend/nextjs.js +0 -62
- package/dist/packages/scripts/frontend/reactjs.js +0 -31
- package/dist/packages/scripts/frontend/reactts.js +0 -30
- package/dist/packages/scripts/frontend/vuejs.js +0 -37
- package/dist/packages/scripts/frontend/vuets.js +0 -43
- package/dist/packages/scripts/orms/drizzleSetup.js +0 -85
- package/dist/packages/scripts/orms/mongoSetup.js +0 -53
- package/dist/packages/scripts/orms/prismaSetup.js +0 -12
- package/dist/packages/scripts/ui/shadcn.js +0 -207
- package/dist/packages/scripts/ui/tailwindcss.js +0 -102
- package/dist/stackd.js +0 -114
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/packages/typescript-config/base.json +0 -19
- package/packages/typescript-config/nextjs.json +0 -12
- package/packages/typescript-config/package.json +0 -9
- package/packages/typescript-config/react-library.json +0 -7
@@ -1,78 +0,0 @@
|
|
1
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
2
|
-
import { join } from 'node:path';
|
3
|
-
import fs from 'fs';
|
4
|
-
export async function jwtAuthts(config, projectDir, emitLog) {
|
5
|
-
emitLog('Installing jsonwebtoken...');
|
6
|
-
const packageJsonPath = join(projectDir, 'backend', 'package.json');
|
7
|
-
const jsonData = await JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
8
|
-
emitLog('Updating package.json...');
|
9
|
-
jsonData.dependencies = jsonData.dependencies || {};
|
10
|
-
jsonData.dependencies["jsonwebtoken"] = "^9.0.2";
|
11
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(jsonData, null, 2), 'utf8');
|
12
|
-
emitLog('Writing jwt.ts...');
|
13
|
-
const jwtAuthFile = `
|
14
|
-
const jwt = require('jsonwebtoken');
|
15
|
-
export const authenticateToken = (req:any, res:any, next:any) => {
|
16
|
-
const token = req.header('Authorization')?.split(' ')[1];
|
17
|
-
if (!token) return res.status(401).json({ error: 'Access Denied' });
|
18
|
-
|
19
|
-
jwt.verify(token, process.env.JWT_SECRET, (err:any, user:any) => {
|
20
|
-
if (err) return res.status(403).json({ error: 'Invalid Token' });
|
21
|
-
req.user = user;
|
22
|
-
next();
|
23
|
-
});
|
24
|
-
};
|
25
|
-
`;
|
26
|
-
emitLog('Writing middleware.ts...');
|
27
|
-
const middlewareDir = join(projectDir, 'backend', 'src', 'middleware');
|
28
|
-
await mkdir(middlewareDir, { recursive: true });
|
29
|
-
emitLog('Writing middleware.ts...');
|
30
|
-
await writeFile(join(middlewareDir, 'middleware.ts'), jwtAuthFile, 'utf8');
|
31
|
-
emitLog('✅ JWT authentication setup completed successfully!');
|
32
|
-
}
|
33
|
-
export async function jwtAuthdjango(config, projectDir, emitLog) {
|
34
|
-
emitLog('Installing jsonwebtoken...');
|
35
|
-
const settingsPath = join(projectDir, 'backend', 'core', 'settings.py');
|
36
|
-
emitLog('Updating settings.py...');
|
37
|
-
try {
|
38
|
-
let settingsContent = fs.readFileSync(settingsPath, 'utf8');
|
39
|
-
const restFrameworkSettings = `
|
40
|
-
|
41
|
-
REST_FRAMEWORK = {
|
42
|
-
'DEFAULT_AUTHENTICATION_CLASSES': [
|
43
|
-
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
44
|
-
],
|
45
|
-
}
|
46
|
-
`;
|
47
|
-
const installedAppsIndex = settingsContent.indexOf('INSTALLED_APPS');
|
48
|
-
const insertPosition = settingsContent.indexOf(']', installedAppsIndex) + 1;
|
49
|
-
settingsContent =
|
50
|
-
settingsContent.slice(0, insertPosition) +
|
51
|
-
restFrameworkSettings +
|
52
|
-
settingsContent.slice(insertPosition);
|
53
|
-
fs.writeFileSync(settingsPath, settingsContent, 'utf8');
|
54
|
-
emitLog('Writing urls.py...');
|
55
|
-
let urlsContent = fs.readFileSync(`${projectDir}/backend/core/urls.py`, 'utf8');
|
56
|
-
const newUrlsContent = `from django.contrib import admin
|
57
|
-
from django.urls import path, include
|
58
|
-
from rest_framework_simplejwt import views as jwt_views
|
59
|
-
|
60
|
-
urlpatterns = [
|
61
|
-
path('admin/', admin.site.urls),
|
62
|
-
path('api/token/',
|
63
|
-
jwt_views.TokenObtainPairView.as_view(),
|
64
|
-
name='token_obtain_pair'),
|
65
|
-
path('api/token/refresh/',
|
66
|
-
jwt_views.TokenRefreshView.as_view(),
|
67
|
-
name='token_refresh'),
|
68
|
-
path('', include('main.urls')),
|
69
|
-
]
|
70
|
-
`;
|
71
|
-
fs.writeFileSync(`${projectDir}/backend/core/urls.py`, newUrlsContent, 'utf8');
|
72
|
-
emitLog('✅ JWT authentication setup completed successfully!');
|
73
|
-
}
|
74
|
-
catch (error) {
|
75
|
-
console.error('Error configuring Django settings:', error);
|
76
|
-
throw error;
|
77
|
-
}
|
78
|
-
}
|
@@ -1,131 +0,0 @@
|
|
1
|
-
import { join } from 'node:path';
|
2
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
3
|
-
import 'dotenv/config';
|
4
|
-
export async function setupNextAuth(config, projectDir, emitLog) {
|
5
|
-
try {
|
6
|
-
const authDir = join(projectDir, 'frontend', 'src', 'app', 'api', 'auth');
|
7
|
-
await mkdir(authDir, { recursive: true });
|
8
|
-
emitLog('Creating auth directory...');
|
9
|
-
const routeCode = `
|
10
|
-
import NextAuth from "next-auth";
|
11
|
-
import { AuthOptions } from "next-auth";
|
12
|
-
import GithubProvider from "next-auth/providers/github";
|
13
|
-
import GoogleProvider from "next-auth/providers/google";
|
14
|
-
import CredentialsProvider from "next-auth/providers/credentials";
|
15
|
-
export const authOptions: AuthOptions = {
|
16
|
-
providers: [
|
17
|
-
GithubProvider({
|
18
|
-
clientId: process.env.GITHUB_ID!,
|
19
|
-
clientSecret: process.env.GITHUB_SECRET!,
|
20
|
-
}),
|
21
|
-
GoogleProvider({
|
22
|
-
clientId: process.env.GOOGLE_CLIENT_ID!,
|
23
|
-
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
24
|
-
}),
|
25
|
-
CredentialsProvider({
|
26
|
-
name: 'Credentials',
|
27
|
-
credentials: {
|
28
|
-
email: { label: "Email", type: "email" },
|
29
|
-
password: { label: "Password", type: "password" }
|
30
|
-
},
|
31
|
-
async authorize(credentials) {
|
32
|
-
// Add your credentials logic here
|
33
|
-
if (!credentials?.email || !credentials?.password) return null;
|
34
|
-
|
35
|
-
try {
|
36
|
-
// Example user verification
|
37
|
-
const user = { id: "1", email: credentials.email, name: "User" };
|
38
|
-
return user;
|
39
|
-
} catch (error) {
|
40
|
-
return null;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}),
|
44
|
-
],
|
45
|
-
pages: {
|
46
|
-
signIn: '/auth/signin',
|
47
|
-
signOut: '/auth/signout',
|
48
|
-
error: '/auth/error',
|
49
|
-
},
|
50
|
-
callbacks: {
|
51
|
-
async jwt({ token, user }) {
|
52
|
-
if (user) {
|
53
|
-
token.id = user.id;
|
54
|
-
}
|
55
|
-
return token;
|
56
|
-
},
|
57
|
-
async session({ session, token }) {
|
58
|
-
if (session.user) {
|
59
|
-
(session.user as any).id = token.id;
|
60
|
-
}
|
61
|
-
return session;
|
62
|
-
},
|
63
|
-
},
|
64
|
-
session: {
|
65
|
-
strategy: "jwt",
|
66
|
-
},
|
67
|
-
secret: process.env.NEXTAUTH_SECRET,
|
68
|
-
};
|
69
|
-
|
70
|
-
const handler = NextAuth(authOptions);
|
71
|
-
export { handler as GET, handler as POST };
|
72
|
-
`;
|
73
|
-
await writeFile(join(authDir, 'route.ts'), routeCode.trim() + '\n');
|
74
|
-
const utilsDir = join(projectDir, 'frontend', 'src', 'utils');
|
75
|
-
await mkdir(utilsDir, { recursive: true });
|
76
|
-
emitLog('Creating utils directory...');
|
77
|
-
const utilsCode = `
|
78
|
-
import { getServerSession } from "next-auth/next";
|
79
|
-
import { authOptions } from "@/app/api/auth/route";
|
80
|
-
|
81
|
-
export async function getSession() {
|
82
|
-
return await getServerSession(authOptions);
|
83
|
-
}
|
84
|
-
|
85
|
-
export async function getCurrentUser() {
|
86
|
-
const session = await getSession();
|
87
|
-
return session?.user;
|
88
|
-
}
|
89
|
-
|
90
|
-
export async function isAuthenticated() {
|
91
|
-
const session = await getSession();
|
92
|
-
return !!session;
|
93
|
-
}
|
94
|
-
`;
|
95
|
-
emitLog('Writing utils.ts...');
|
96
|
-
await writeFile(join(utilsDir, 'auth.ts'), utilsCode.trim() + '\n');
|
97
|
-
const envContent = `
|
98
|
-
# NextAuth Configuration
|
99
|
-
NEXTAUTH_SECRET=your-secret-key-here
|
100
|
-
NEXTAUTH_URL=http://localhost:${config.frontendPort}
|
101
|
-
|
102
|
-
# OAuth Providers
|
103
|
-
GITHUB_ID=your-github-id
|
104
|
-
GITHUB_SECRET=your-github-secret
|
105
|
-
|
106
|
-
GOOGLE_CLIENT_ID=your-google-client-id
|
107
|
-
GOOGLE_CLIENT_SECRET=your-google-client-secret
|
108
|
-
`;
|
109
|
-
emitLog('Writing .env file...');
|
110
|
-
await writeFile(join(projectDir, 'frontend', '.env'), envContent.trim() + '\n');
|
111
|
-
emitLog('Writing AuthProvider.tsx...');
|
112
|
-
const providerCode = `
|
113
|
-
'use client';
|
114
|
-
|
115
|
-
import { SessionProvider } from "next-auth/react";
|
116
|
-
|
117
|
-
export function AuthProvider({ children }: { children: React.ReactNode }) {
|
118
|
-
return <SessionProvider>{children}</SessionProvider>;
|
119
|
-
}
|
120
|
-
`;
|
121
|
-
emitLog('Creating components directory...');
|
122
|
-
const providersDir = join(projectDir, 'frontend', 'src', 'components', 'auth');
|
123
|
-
await mkdir(providersDir, { recursive: true });
|
124
|
-
await writeFile(join(providersDir, 'AuthProvider.tsx'), providerCode.trim() + '\n');
|
125
|
-
emitLog('✅ NextAuth setup completed successfully!');
|
126
|
-
}
|
127
|
-
catch (error) {
|
128
|
-
emitLog(`❌ Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
129
|
-
throw error;
|
130
|
-
}
|
131
|
-
}
|
@@ -1,218 +0,0 @@
|
|
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
|
-
}
|
@@ -1,20 +0,0 @@
|
|
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;
|
@@ -1,58 +0,0 @@
|
|
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
|
-
}
|
@@ -1,83 +0,0 @@
|
|
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
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,22 +0,0 @@
|
|
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
|
-
}
|
@@ -1,62 +0,0 @@
|
|
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
|
-
// }
|