| const { spawnSync } = require('child_process') |
| const { existsSync, writeFileSync } = require('fs') |
|
|
| const SESSION_ID = 'levanter_177e8a2538e2a94654a118869b3d60927d' |
|
|
| if (!existsSync('levanter')) { |
| console.log('Cloning the repository...') |
| const cloneResult = spawnSync( |
| 'git', |
| ['clone', 'https://github.com/lyfe00011/levanter.git', 'levanter'], |
| { |
| stdio: 'inherit', |
| } |
| ) |
|
|
| if (cloneResult.error) { |
| throw new Error(`Failed to clone the repository: ${cloneResult.error.message}`) |
| } |
|
|
| const configPath = 'levanter/config.env' |
| try { |
| console.log('Writing to config.env...') |
| writeFileSync(configPath, `VPS=true\nSESSION_ID=${SESSION_ID}`) |
| } catch (err) { |
| throw new Error(`Failed to write to config.env: ${err.message}`) |
| } |
|
|
| console.log('Installing dependencies...') |
| const installResult = spawnSync('yarn', ['install', '--network-concurrency', '3'], { |
| cwd: 'levanter', |
| stdio: 'inherit', |
| }) |
|
|
| if (installResult.error) { |
| throw new Error(`Failed to install dependencies: ${installResult.error.message}`) |
| } |
| } |
| spawnSync('node', ['.'], { cwd: 'levanter', stdio: 'inherit' }) |