-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert start and install to javascript
- Loading branch information
Showing
7 changed files
with
136 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env node | ||
|
||
import { join } from 'node:path'; | ||
import { basedir, deleteDirectory, log, readJSON } from './helpers/io.mjs'; | ||
import { stat } from 'node:fs/promises'; | ||
import { runTask } from './helpers/proc.mjs'; | ||
|
||
const SKIP_E2E_DEPS = (process.env['SKIP_E2E_DEPS'] ?? 'false') === 'true'; | ||
const FORCE = process.argv.slice(2).includes('--force'); | ||
|
||
const packageJson = await readJSON(join(basedir, 'package.json')); | ||
const dependencyKeys = Object.keys(packageJson).filter((k) => | ||
k.toLowerCase().includes('dependencies'), | ||
); | ||
if (dependencyKeys.length > 0) { | ||
log(` | ||
Dependencies should not be installed in root package.json! | ||
- remove ${dependencyKeys.map((v) => `"${v}"`).join(', ')} | ||
- add the dependencies to the desired subproject instead | ||
- re-run install | ||
`); | ||
deleteDirectory(join(basedir, 'node_modules')); | ||
process.exit(1); | ||
} | ||
|
||
async function installPackage(pkg) { | ||
const s = await stat(join(basedir, pkg, 'node_modules')).catch(() => null); | ||
if (s === null || FORCE) { | ||
log(`Installing ${pkg} dependencies...`); | ||
await runTask('npm', ['install', '--quiet'], { | ||
cwd: join(basedir, pkg), | ||
env: { ...process.env, DISABLE_OPENCOLLECTIVE: '1' }, | ||
}); | ||
} | ||
} | ||
|
||
await installPackage('frontend'); | ||
await installPackage('backend'); | ||
if (!SKIP_E2E_DEPS) { | ||
await installPackage('e2e'); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env node | ||
|
||
import { join } from 'node:path'; | ||
import { basedir, log } from './helpers/io.mjs'; | ||
import { runTaskPrefixOutput } 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 Promise.all([ | ||
runTaskPrefixOutput({ | ||
command: 'npm', | ||
args: ['start', '--quiet'], | ||
cwd: join(basedir, 'frontend'), | ||
env: frontendEnv, | ||
outputPrefix: 'frontend', | ||
prefixFormat: '35', | ||
}), | ||
runTaskPrefixOutput({ | ||
command: 'npm', | ||
args: ['start', '--quiet'], | ||
cwd: join(basedir, 'backend'), | ||
env: backendEnv, | ||
outputPrefix: 'backend', | ||
prefixFormat: '36', | ||
}), | ||
]); |
This file was deleted.
Oops, something went wrong.