-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsite-config.ts
More file actions
54 lines (47 loc) · 1.18 KB
/
site-config.ts
File metadata and controls
54 lines (47 loc) · 1.18 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
/**
* SiteConfig — all the information a tool handler needs about a site.
* Built from Local.Site data in main.ts, passed through to tool handlers.
*/
export interface SiteConfig {
siteId: string;
sitePath: string;
wpPath: string;
phpBin: string;
phpIniDir: string | null;
wpCliBin: string;
mysqlBin: string;
dbName: string;
dbUser: string;
dbPassword: string;
dbSocket: string | null;
dbPort: number;
dbHost: string;
siteDomain: string;
siteUrl: string;
logPath: string;
}
/**
* In-memory registry of SiteConfigs for all sites that have Agent Tools enabled
* and are currently running (or were running when configs were last built).
*/
export class SiteConfigRegistry {
private configs = new Map<string, SiteConfig>();
register(config: SiteConfig): void {
this.configs.set(config.siteId, config);
}
unregister(siteId: string): void {
this.configs.delete(siteId);
}
get(siteId: string): SiteConfig | undefined {
return this.configs.get(siteId);
}
has(siteId: string): boolean {
return this.configs.has(siteId);
}
getAll(): SiteConfig[] {
return Array.from(this.configs.values());
}
getAllIds(): string[] {
return Array.from(this.configs.keys());
}
}