@take-out/scripts 0.0.47 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/helpers/get-test-env.ts +22 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@take-out/scripts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/run.ts",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@take-out/helpers": "
|
|
27
|
+
"@take-out/helpers": "workspace:*",
|
|
28
28
|
"glob": "^11.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -4,14 +4,34 @@ import { loadEnv } from './env-load'
|
|
|
4
4
|
import { getDockerHost } from './get-docker-host'
|
|
5
5
|
import { getZeroVersion } from './zero-get-version'
|
|
6
6
|
|
|
7
|
+
// extract the port from a postgres connection string
|
|
8
|
+
function getPortFromConnectionString(url: string | undefined): string | undefined {
|
|
9
|
+
if (!url) return undefined
|
|
10
|
+
try {
|
|
11
|
+
// handle postgresql:// URLs
|
|
12
|
+
const match = url.match(/:(\d+)\//)
|
|
13
|
+
return match?.[1]
|
|
14
|
+
} catch {
|
|
15
|
+
return undefined
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
7
19
|
export async function getTestEnv() {
|
|
8
20
|
const zeroVersion = getZeroVersion()
|
|
9
21
|
const devEnv = await loadEnv('development')
|
|
10
22
|
const dockerHost = getDockerHost()
|
|
11
23
|
const serverEnvFallback = await import(join(process.cwd(), 'src/server/env-server'))
|
|
12
24
|
|
|
13
|
-
//
|
|
14
|
-
|
|
25
|
+
// determine db port from (in order of priority):
|
|
26
|
+
// 1. DOCKER_DB_PORT env var
|
|
27
|
+
// 2. port from ZERO_UPSTREAM_DB in devEnv
|
|
28
|
+
// 3. default 5432
|
|
29
|
+
const dbPort =
|
|
30
|
+
process.env.DOCKER_DB_PORT ||
|
|
31
|
+
getPortFromConnectionString(devEnv.ZERO_UPSTREAM_DB as string) ||
|
|
32
|
+
'5432'
|
|
33
|
+
|
|
34
|
+
const dockerDbBase = `postgresql://user:password@127.0.0.1:${dbPort}`
|
|
15
35
|
|
|
16
36
|
return {
|
|
17
37
|
...serverEnvFallback,
|