forked from ballerine-io/ballerine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
executable file
·38 lines (30 loc) · 990 Bytes
/
init.js
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
#!/usr/bin/node
const childProcess = require('node:child_process');
const path = require('node:path');
const fs = require('fs');
const rootDir = path.join(__dirname, '..');
const ensureEnvFileIsPresent = projectPath => {
const envFile = path.join(projectPath, '.env');
const envExampleFile = path.join(projectPath, '.env.example');
if (fs.existsSync(envFile)) {
fs.copyFileSync(envFile, `${envFile}-${new Date().toISOString()}.backup`);
}
fs.copyFileSync(envExampleFile, envFile);
};
const run = (cmd, cwd = rootDir) => {
childProcess.execSync(cmd, { cwd, stdio: 'inherit' });
};
// START
console.log('🏗️ preparing project');
run('pnpm run build');
console.log('🍎 preparing environment');
const directories = [
'services/workflows-service',
'services/websocket-service',
'apps/backoffice-v2',
'apps/workflows-dashboard',
];
directories.forEach(directory => {
ensureEnvFileIsPresent(path.join(rootDir, directory));
});
console.log('✅ All done!');