50 lines
1.8 KiB
TypeScript
50 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_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,
|
|
};
|
|
}
|