@take-out/scripts 0.0.91 → 0.0.92

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@take-out/scripts",
3
- "version": "0.0.91",
3
+ "version": "0.0.92",
4
4
  "type": "module",
5
5
  "main": "./src/run.ts",
6
6
  "sideEffects": false,
@@ -1,3 +1,4 @@
1
+ import { existsSync } from 'node:fs'
1
2
  import { join } from 'node:path'
2
3
 
3
4
  import { loadEnv as vxrnLoadEnv } from 'vxrn/loadEnv'
@@ -9,9 +10,9 @@ export async function loadEnv(
9
10
  // loads env into process.env
10
11
  await vxrnLoadEnv(environment)
11
12
 
12
- const Environment = await import(
13
- options?.envPath || join(process.cwd(), 'src/server/env-server.ts')
14
- )
13
+ const envPath = options?.envPath || resolveEnvServerPath()
14
+
15
+ const Environment = await import(envPath)
15
16
 
16
17
  // validate
17
18
  for (const key in Environment) {
@@ -25,3 +26,15 @@ export async function loadEnv(
25
26
 
26
27
  return Environment
27
28
  }
29
+
30
+ function resolveEnvServerPath(): string {
31
+ const candidates = ['src/constants/env-server.ts', 'src/server/env-server.ts']
32
+ for (const candidate of candidates) {
33
+ const full = join(process.cwd(), candidate)
34
+ if (existsSync(full)) {
35
+ return full
36
+ }
37
+ }
38
+ // fall back to first candidate for error message
39
+ return join(process.cwd(), 'src/constants/env-server.ts')
40
+ }
@@ -1,3 +1,4 @@
1
+ import { existsSync } from 'node:fs'
1
2
  import { join } from 'node:path'
2
3
 
3
4
  import { loadEnv } from './env-load'
@@ -8,7 +9,10 @@ export async function getTestEnv() {
8
9
  const zeroVersion = getZeroVersion()
9
10
  const dockerHost = getDockerHost()
10
11
  const devEnv = await loadEnv('development')
11
- const serverEnvFallback = await import(join(process.cwd(), 'src/server/env-server'))
12
+ const envPath = ['src/constants/env-server', 'src/server/env-server']
13
+ .map((p) => join(process.cwd(), p))
14
+ .find((p) => existsSync(p + '.ts')) || join(process.cwd(), 'src/constants/env-server')
15
+ const serverEnvFallback = await import(envPath)
12
16
 
13
17
  // ports come from VITE_PORT_* in .env.development (loaded by loadEnv)
14
18
  const dbPort = process.env.VITE_PORT_POSTGRES || '5433'