Files
punimtag/e2e/env-defaults.ts
T
ilia 26faf33a95
CI / skip-ci-check (pull_request) Successful in 29s
CI / docker-ci (pull_request) Successful in 32s
CI / python-lint (pull_request) Successful in 32s
CI / secret-scan (pull_request) Successful in 37s
CI / viewer-unit (pull_request) Successful in 1m53s
CI / admin-unit (pull_request) Successful in 2m39s
CI / e2e (pull_request) Failing after 3m19s
Sprint D: hardening e2e, /search redirect, scroll restore fix.
Admin review smoke tests, CWV budgets, unified gallery at /, and explicit
body unlock when closing the photo modal so scroll position restores.
2026-08-04 22:17:43 -04:00

51 lines
1.8 KiB
TypeScript

/**
* Canonical punimtag DEV targets — single source of truth for fixtures,
* playwright.config.ts, and the Gitea Actions `e2e` job defaults.
*
* Values live in env-defaults.json so CI bash can read them without
* compiling TypeScript (see `.gitea/workflows/ci.yml`).
*
* env-defaults.json ships placeholder host values (this is a public repo).
* Real targets come from env vars (PLAYKIT_BASE_URL / PLAYKIT_API_BASE_URL —
* set as Gitea Actions secrets in CI) or from a gitignored
* `env-defaults.local.json` next to this file for local runs.
*/
import * as fs from 'node:fs';
import * as path from 'node:path';
import checkedInDefaults from './env-defaults.json' with { type: 'json' };
function loadLocalOverrides(): Partial<typeof checkedInDefaults> {
try {
const raw = fs.readFileSync(
path.join(__dirname, 'env-defaults.local.json'),
'utf8',
);
return JSON.parse(raw);
} catch {
return {};
}
}
const defaults = { ...checkedInDefaults, ...loadLocalOverrides() };
export const DEFAULT_BASE_URL = defaults.DEFAULT_BASE_URL;
export const DEFAULT_ADMIN_BASE_URL = defaults.DEFAULT_ADMIN_BASE_URL;
export const DEFAULT_API_BASE_URL = defaults.DEFAULT_API_BASE_URL;
export const DEFAULT_PROJECT = defaults.DEFAULT_PROJECT;
export const DEFAULT_ENV = defaults.DEFAULT_ENV;
/** Env bag for createPlaykitRuntime — fills gaps only, never overrides set vars. */
export function playkitEnvFromProcess(
env: NodeJS.ProcessEnv = process.env,
): NodeJS.ProcessEnv {
return {
...env,
PLAYKIT_PROJECT: env.PLAYKIT_PROJECT || env.CI_PROJECT || DEFAULT_PROJECT,
PLAYKIT_ENV: env.PLAYKIT_ENV || env.APP_ENV || DEFAULT_ENV,
PLAYKIT_BASE_URL: env.PLAYKIT_BASE_URL || env.BASE_URL || DEFAULT_BASE_URL,
PLAYKIT_API_BASE_URL:
env.PLAYKIT_API_BASE_URL || env.API_BASE_URL || DEFAULT_API_BASE_URL,
};
}