50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
const { exec } = require('child_process');
|
|
const path = require('path');
|
|
|
|
// Function to execute shell commands
|
|
const runCommand = (command, cwd) => {
|
|
return new Promise((resolve, reject) => {
|
|
console.log(`Running command: ${command} in ${cwd}`);
|
|
const process = exec(command, { cwd }, (error, stdout, stderr) => {
|
|
if (error) {
|
|
console.error(`Command failed: ${command}`);
|
|
console.error(stderr);
|
|
reject(error);
|
|
return;
|
|
}
|
|
console.log(stdout);
|
|
resolve(stdout);
|
|
});
|
|
|
|
process.stdout.pipe(process.stdout);
|
|
process.stderr.pipe(process.stderr);
|
|
});
|
|
};
|
|
|
|
(async () => {
|
|
try {
|
|
const rootDir = __dirname;
|
|
const backendDir = path.join(rootDir, 'packages', 'backend');
|
|
const frontendDir = path.join(rootDir, 'packages', 'frontend');
|
|
|
|
console.log('Starting application setup...');
|
|
|
|
console.log('Running yarn install...');
|
|
await runCommand('yarn', rootDir);
|
|
|
|
console.log('Running yarn build...');
|
|
await runCommand('yarn build', rootDir);
|
|
|
|
console.log('Starting backend...');
|
|
await runCommand('yarn start', backendDir);
|
|
|
|
console.log('Starting frontend in new terminal...');
|
|
exec(`osascript -e 'tell application "Terminal" to do script "cd ${frontendDir} && yarn dev"'`);
|
|
|
|
console.log('Application started successfully!');
|
|
} catch (error) {
|
|
console.error('Error during setup:', error);
|
|
process.exit(1);
|
|
}
|
|
})();
|