forked from davidje13/Refacto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.mjs
executable file
·61 lines (55 loc) · 1.59 KB
/
start.mjs
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
#!/usr/bin/env node
import { join } from 'node:path';
import { basedir, log } from './helpers/io.mjs';
import { runMultipleTasks } from './helpers/proc.mjs';
const forceMockSSO = process.argv.slice(2).includes('--mock-sso');
const apiPort = Number.parseInt(process.env['PORT'] ?? '5000');
const appPort = apiPort + 1;
const frontendEnv = {
...process.env,
PORT: String(appPort),
};
const backendEnv = {
...process.env,
PORT: String(apiPort),
FORWARD_HOST: `http://localhost:${appPort}`,
SERVER_BIND_ADDRESS: 'localhost',
};
if (
forceMockSSO ||
(!process.env['SSO_GOOGLE_CLIENT_ID'] &&
!process.env['SSO_GITHUB_CLIENT_ID'] &&
!process.env['SSO_GITLAB_CLIENT_ID'])
) {
log('Using mock authentication provider');
const mockSSOPort = apiPort + 2;
const mockSSOHost = `http://localhost:${mockSSOPort}`;
backendEnv['MOCK_SSO_PORT'] = mockSSOPort;
backendEnv['SSO_GOOGLE_CLIENT_ID'] = 'mock-client-id';
backendEnv['SSO_GOOGLE_AUTH_URL'] = `${mockSSOHost}/auth`;
backendEnv['SSO_GOOGLE_TOKEN_INFO_URL'] = `${mockSSOHost}/tokeninfo`;
}
log('Starting application...');
await runMultipleTasks(
[
{
command: 'npm',
args: ['start', '--quiet'],
cwd: join(basedir, 'frontend'),
env: frontendEnv,
failureMessage: 'Failed to run frontend',
outputPrefix: 'frontend',
prefixFormat: '35',
},
{
command: 'npm',
args: ['start', '--quiet'],
cwd: join(basedir, 'backend'),
env: backendEnv,
failureMessage: 'Failed to run backend',
outputPrefix: 'backend',
prefixFormat: '36',
},
],
{ parallel: true },
);