-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
36 lines (28 loc) Β· 1.46 KB
/
setup.js
File metadata and controls
36 lines (28 loc) Β· 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { execSync } from 'node:child_process';
import { existsSync, copyFileSync } from 'node:fs';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const backendDir = resolve(__dirname, 'backend');
function run(cmd, cwd = __dirname) {
console.log(`\n> ${cmd}`);
execSync(cmd, { cwd, stdio: 'inherit' });
}
// ββ Backend ββββββββββββββββββββββββββββββββββ
console.log('\nπ¦ Installing backend dependencies...');
run('npm install', backendDir);
if (!existsSync(resolve(backendDir, '.env'))) {
console.log('\nπ Creating backend/.env from .env.example...');
copyFileSync(resolve(backendDir, '.env.example'), resolve(backendDir, '.env'));
}
console.log('\nπ§ Generating Prisma client...');
run('npx prisma generate', backendDir);
console.log('\nποΈ Creating database...');
run('npx prisma db push', backendDir);
// ββ Frontend βββββββββββββββββββββββββββββββββ
console.log('\nπ¦ Installing frontend dependencies...');
run('npm install', __dirname);
// ββ Done βββββββββββββββββββββββββββββββββββββ
console.log('\nβ
Setup complete!');
console.log(' Run "npm start" to launch the app.');
console.log(' Open http://localhost:5173 in your browser.\n');