Create index.js
Browse files
index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const { spawnSync } = require('child_process')
|
| 2 |
+
const { existsSync, writeFileSync } = require('fs')
|
| 3 |
+
|
| 4 |
+
const SESSION_ID = 'levanter_177e8a2538e2a94654a118869b3d60927d' // Edit this line only, don't remove ' <- this symbol
|
| 5 |
+
|
| 6 |
+
if (!existsSync('levanter')) {
|
| 7 |
+
console.log('Cloning the repository...')
|
| 8 |
+
const cloneResult = spawnSync(
|
| 9 |
+
'git',
|
| 10 |
+
['clone', 'https://github.com/lyfe00011/levanter.git', 'levanter'],
|
| 11 |
+
{
|
| 12 |
+
stdio: 'inherit',
|
| 13 |
+
}
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
if (cloneResult.error) {
|
| 17 |
+
throw new Error(`Failed to clone the repository: ${cloneResult.error.message}`)
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
const configPath = 'levanter/config.env'
|
| 21 |
+
try {
|
| 22 |
+
console.log('Writing to config.env...')
|
| 23 |
+
writeFileSync(configPath, `VPS=true\nSESSION_ID=${SESSION_ID}`)
|
| 24 |
+
} catch (err) {
|
| 25 |
+
throw new Error(`Failed to write to config.env: ${err.message}`)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
console.log('Installing dependencies...')
|
| 29 |
+
const installResult = spawnSync('yarn', ['install', '--network-concurrency', '3'], {
|
| 30 |
+
cwd: 'levanter',
|
| 31 |
+
stdio: 'inherit',
|
| 32 |
+
})
|
| 33 |
+
|
| 34 |
+
if (installResult.error) {
|
| 35 |
+
throw new Error(`Failed to install dependencies: ${installResult.error.message}`)
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
spawnSync('node', ['.'], { cwd: 'levanter', stdio: 'inherit' })
|