-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfactory.ts
More file actions
39 lines (37 loc) · 1.5 KB
/
Copy pathfactory.ts
File metadata and controls
39 lines (37 loc) · 1.5 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
import type { Config, Registry } from "../config/schema.ts";
import { createLinearTracker } from "./linear/adapter.ts";
import { createPlaneTracker, verifyPlaneConfig } from "./plane/adapter.ts";
import type { Tracker } from "./tracker.ts";
export function createTracker(config: Config, registry: Registry, env: NodeJS.ProcessEnv = process.env): Tracker {
switch (config.tracker) {
case "plane":
return createPlaneTracker(config, registry, env);
case "linear":
return createLinearTracker(config, registry, env);
default: {
const exhaustive: never = config.tracker;
throw new Error(`unknown tracker "${String(exhaustive)}"`);
}
}
}
// Static, network-free validation of the active tracker's config block. Throws a
// clear, actionable error when the block is present but not yet usable. Operates
// on config alone — no instance, no API key, no network — so doctor can run it
// even when the key is unset or the tracker cannot be constructed.
export function verifyTrackerConfig(config: Config): void {
switch (config.tracker) {
case "plane": {
const plane = config.trackers.plane;
if (plane !== undefined) {
verifyPlaneConfig(plane);
}
return;
}
case "linear":
return;
default: {
const exhaustive: never = config.tracker;
throw new Error(`unknown tracker "${String(exhaustive)}"`);
}
}
}