mirror of
https://github.com/Gimanh/taskview-community.git
synced 2026-12-06 19:04:41 +00:00
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { execFileSync } from 'node:child_process'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { E2E_API_URL, E2E_IS_DEV, E2E_WEB_URL } from './e2e-env'
|
|
|
|
async function isUp(url: string): Promise<boolean> {
|
|
try {
|
|
await fetch(url)
|
|
return true
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
function imagesExist(): boolean {
|
|
try {
|
|
execFileSync('docker', ['image', 'inspect', 'taskview-ce-e2e/api:local', 'taskview-ce-e2e/migration:local', 'taskview-ce-e2e/web:local'], { stdio: 'ignore' })
|
|
return true
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
// E2E_REBUILD=1 rebuilds the images from the current source and starts a fresh stack. Without it a running
|
|
// stack is used as it is, and a stopped one is started from the images of the last build.
|
|
export default async function globalSetup() {
|
|
if (E2E_IS_DEV) return
|
|
|
|
const rebuild = process.env.E2E_REBUILD === '1' || !imagesExist()
|
|
if (!rebuild && (await isUp(E2E_API_URL)) && (await isUp(E2E_WEB_URL))) return
|
|
|
|
const setupScript = path.join(path.dirname(fileURLToPath(import.meta.url)), 'docker-setup.sh')
|
|
execFileSync('bash', [setupScript], { stdio: 'inherit', env: { ...process.env, SKIP_BUILD: rebuild ? '0' : '1' } })
|
|
}
|