forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
65 lines (60 loc) · 2.2 KB
/
Copy pathconfig.ts
File metadata and controls
65 lines (60 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import path from "node:path";
import fs from "node:fs";
import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const SHOWCASE_DIR = path.resolve(__dirname, "../../..");
export interface LocalConfig {
showcaseDir: string;
composeFile: string;
localPorts: Record<string, number>;
pocketbase: {
url: string;
email: string;
password: string;
};
aimockUrl: string;
dashboardUrl: string;
dashboardPort: number;
}
export function loadConfig(): LocalConfig {
// Honor LOCAL_PORTS_FILE env var (set by isolation overlay) so the harness
// reads offset ports from a temp file instead of the checked-in original.
const portsFile =
process.env.LOCAL_PORTS_FILE ||
path.join(SHOWCASE_DIR, "shared/local-ports.json");
const localPorts = JSON.parse(fs.readFileSync(portsFile, "utf-8")) as Record<
string,
number
>;
return {
showcaseDir: SHOWCASE_DIR,
composeFile:
process.env.SHOWCASE_COMPOSE_FILE ||
path.join(SHOWCASE_DIR, "docker-compose.local.yml"),
localPorts,
pocketbase: {
url: process.env.POCKETBASE_URL_LOCAL || "http://localhost:8090",
// PB 0.22+ rejects `admin@localhost` (single-label TLD) as an invalid
// email. Use a valid format that the PB validator accepts. The
// matching admin account is created in the entrypoint / migrations
// path; the docker-compose env vars and `bin/showcase` superuser
// bootstrap must agree on this value.
email: "admin@localhost.dev",
password: "showcase-local-dev",
},
// When --isolate offsets the aimock host port, honor env overrides so the
// harness's host-side references point at the per-project aimock.
aimockUrl: process.env.AIMOCK_URL_LOCAL || "http://localhost:4010",
dashboardUrl: process.env.DASHBOARD_URL_LOCAL || "http://localhost:3200",
dashboardPort: Number(process.env.DASHBOARD_PORT_LOCAL) || 3200,
};
}
export function getPackageUrl(slug: string, config: LocalConfig): string {
const port = config.localPorts[slug];
if (!port) {
throw new Error(
`No local port mapping for slug "${slug}". Check shared/local-ports.json.`,
);
}
return `http://localhost:${port}`;
}