-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender-setup.js
More file actions
158 lines (130 loc) Β· 5.17 KB
/
Copy pathrender-setup.js
File metadata and controls
158 lines (130 loc) Β· 5.17 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { execSync } from 'child_process';
// Get the directory paths
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log('π¨ Starting Render build setup...');
console.log(`Current directory: ${process.cwd()}`);
try {
// Print out directory listing for debugging
console.log('\nπ Contents of current directory:');
console.log(execSync('ls -la').toString());
console.log('\nπ¦ Node.js and npm versions:');
console.log(execSync('node -v && npm -v').toString());
// Copy environment file for Render
console.log('\nπ Setting up environment file...');
const envRenderPath = path.join(__dirname, '.env.render');
const envPath = path.join(__dirname, '.env');
if (fs.existsSync(envRenderPath)) {
fs.copyFileSync(envRenderPath, envPath);
console.log('β
Copied .env.render to .env');
} else {
console.log('β οΈ No .env.render file found, creating .env file...');
// Create a basic .env file if .env.render doesn't exist
const basicEnvContent = `
# Server Configuration
NODE_ENV=production
PORT=10000
# Supabase Configuration
SUPABASE_URL=https://qqmagqwumjipdqvxbiqu.supabase.co
SUPABASE_ANON_KEY=your-supabase-anon-key
# JWT Authentication
JWT_SECRET=e4f8a2b5c9d3f7e1a0b5c8d2e6f3a9b7d1e0f5a2c4b8e3d7f9a1c5b0e2d4f8
JWT_EXPIRE=30d
# Frontend Configuration
VITE_APP_NAME="JetSet App"
VITE_API_URL=/api
`;
fs.writeFileSync(envPath, basicEnvContent);
console.log('β
Created new .env file');
}
// Create Pages directory and subdirectories
const resourcesDir = path.join(__dirname, 'resources', 'js');
console.log(`\nπ Checking resources directory: ${resourcesDir}`);
if (fs.existsSync(resourcesDir)) {
console.log('β
Resources directory exists');
} else {
console.log('β Resources directory not found');
process.exit(1);
}
// Log contents
console.log('\nπ Contents of resources/js directory:');
console.log(fs.readdirSync(resourcesDir));
const pagesDir = path.join(resourcesDir, 'Pages');
const pagesAuthDir = path.join(pagesDir, 'Auth');
// Create directories if they don't exist
if (!fs.existsSync(pagesDir)) {
console.log('π Creating Pages directory...');
fs.mkdirSync(pagesDir, { recursive: true });
}
if (!fs.existsSync(pagesAuthDir)) {
console.log('π Creating Auth directory...');
fs.mkdirSync(pagesAuthDir, { recursive: true });
}
// Copy files from lowercase pages to uppercase Pages
const lowerPagesDir = path.join(resourcesDir, 'pages');
if (fs.existsSync(lowerPagesDir)) {
console.log('π Copying files from pages to Pages...');
console.log('π Contents of pages directory:');
console.log(fs.readdirSync(lowerPagesDir));
// Copy function
const copyDirRecursively = (src, dest) => {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
const entries = fs.readdirSync(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
try {
if (entry.isDirectory()) {
copyDirRecursively(srcPath, destPath);
console.log(`π Copied directory: ${entry.name}`);
} else {
fs.copyFileSync(srcPath, destPath);
console.log(`β
Copied file: ${srcPath} to ${destPath}`);
}
} catch (err) {
console.error(`β Error copying ${srcPath}: ${err.message}`);
}
}
};
copyDirRecursively(lowerPagesDir, pagesDir);
} else {
console.log('β οΈ Lowercase pages directory not found');
}
console.log('\nπ After copying, Contents of Pages directory:');
if (fs.existsSync(pagesDir)) {
console.log(fs.readdirSync(pagesDir));
} else {
console.log('β Pages directory still not found');
}
// Check and update app.jsx imports
const appPath = path.join(resourcesDir, 'app.jsx');
if (fs.existsSync(appPath)) {
console.log('\nπ Updating app.jsx...');
let appContent = fs.readFileSync(appPath, 'utf8');
appContent = appContent.replace(/from\s+['"]\.\/pages\//g, 'from \'./Pages/');
fs.writeFileSync(appPath, appContent);
console.log('β
Updated app.jsx imports');
} else {
console.log('β app.jsx not found');
}
console.log('\nπ¨ Installing dependencies...');
// First try to install the required packages directly (most reliable)
console.log('π¦ Explicitly installing vite and plugin-react first...');
execSync('npm install @vitejs/plugin-react vite --no-save', { stdio: 'inherit' });
// Then install all packages
console.log('π¦ Installing all dependencies...');
execSync('npm install', { stdio: 'inherit' });
// Use our simplified Vite config
console.log('\nπ§ Using simplified vite config...');
console.log('\nποΈ Building application...');
execSync('npx vite build --config simple-vite.config.js', { stdio: 'inherit' });
console.log('\nβ
Build completed successfully!');
} catch (error) {
console.error('\nβ Build failed:', error);
process.exit(1);
}