Repository navigation
Expand file tree
/
Copy pathsetup.js
More file actions
90 lines (73 loc) · 3.1 KB
/
Copy pathsetup.js
File metadata and controls
90 lines (73 loc) · 3.1 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env node
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
console.log('🥗 NutriPlan Setup Script');
console.log('========================\n');
// Check if Node.js version is compatible
const nodeVersion = process.version;
const majorVersion = parseInt(nodeVersion.slice(1).split('.')[0]);
if (majorVersion < 16) {
console.error('❌ Node.js version 16 or higher is required');
console.error(` Current version: ${nodeVersion}`);
process.exit(1);
}
console.log(`✅ Node.js version: ${nodeVersion}`);
// Install dependencies
console.log('\n📦 Installing dependencies...');
try {
execSync('npm install', { stdio: 'inherit' });
console.log('✅ Root dependencies installed');
process.chdir('server');
execSync('npm install', { stdio: 'inherit' });
console.log('✅ Server dependencies installed');
process.chdir('../client');
execSync('npm install', { stdio: 'inherit' });
console.log('✅ Client dependencies installed');
process.chdir('..');
} catch (error) {
console.error('❌ Failed to install dependencies');
process.exit(1);
}
// Check for environment files
console.log('\n🔧 Checking environment configuration...');
const serverEnvPath = path.join('server', '.env');
const clientEnvPath = path.join('client', '.env');
if (!fs.existsSync(serverEnvPath)) {
console.log('📝 Creating server .env file...');
const serverEnvExample = fs.readFileSync(path.join('server', 'env.example'), 'utf8');
fs.writeFileSync(serverEnvPath, serverEnvExample);
console.log('✅ Server .env file created');
console.log(' Please edit server/.env with your database credentials');
} else {
console.log('✅ Server .env file exists');
}
if (!fs.existsSync(clientEnvPath)) {
console.log('📝 Creating client .env file...');
fs.writeFileSync(clientEnvPath, 'REACT_APP_API_URL=http://localhost:5000/api\n');
console.log('✅ Client .env file created');
} else {
console.log('✅ Client .env file exists');
}
// Database setup instructions
console.log('\n🗄️ Database Setup Instructions:');
console.log('================================');
console.log('1. Install PostgreSQL (if not already installed)');
console.log('2. Create a database:');
console.log(' sudo -u postgres psql');
console.log(' CREATE DATABASE dietician_app;');
console.log('3. Update server/.env with your database credentials');
console.log('4. Run the database schema:');
console.log(' psql -U postgres -d dietician_app -f server/database/schema.sql');
console.log('5. (Optional) Add sample data:');
console.log(' psql -U postgres -d dietician_app -f server/database/seed.sql');
console.log('\n🚀 Quick Start:');
console.log('===============');
console.log('1. Start the development servers:');
console.log(' npm run dev');
console.log('2. Open http://localhost:3000 in your browser');
console.log('3. Register a new account and complete onboarding');
console.log('\n📚 Documentation:');
console.log('=================');
console.log('See README.md for detailed setup instructions and API documentation');
console.log('\n✨ Setup complete! Happy coding!');