Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit ec0c79a

Browse files
committed
Fix: Linter fix
1 parent 3a9a3dc commit ec0c79a

File tree

11 files changed

+1918
-1919
lines changed

11 files changed

+1918
-1919
lines changed

src/core/database/stacks.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,62 +5,62 @@ import { db } from "./database";
55
import { executeDbOperation } from "./helper";
66

77
const stmt = {
8-
insert: db.prepare(`
8+
insert: db.prepare(`
99
INSERT INTO stacks_config (
1010
name, version, custom, source, compose_spec
1111
) VALUES (?, ?, ?, ?, ?)
1212
`),
13-
selectAll: db.prepare(`
13+
selectAll: db.prepare(`
1414
SELECT id, name, version, custom, source, compose_spec
1515
FROM stacks_config
1616
ORDER BY name DESC
1717
`),
18-
update: db.prepare(`
18+
update: db.prepare(`
1919
UPDATE stacks_config
2020
SET name = ?, custom = ?, source = ?, compose_spec = ?
2121
WHERE name = ?
2222
`),
23-
delete: db.prepare("DELETE FROM stacks_config WHERE id = ?"),
23+
delete: db.prepare("DELETE FROM stacks_config WHERE id = ?"),
2424
};
2525

2626
export function addStack(stack: stacks_config) {
27-
executeDbOperation("Add Stack", () =>
28-
stmt.insert.run(
29-
stack.name,
30-
stack.version,
31-
stack.custom,
32-
stack.source,
33-
stack.compose_spec
34-
)
35-
);
27+
executeDbOperation("Add Stack", () =>
28+
stmt.insert.run(
29+
stack.name,
30+
stack.version,
31+
stack.custom,
32+
stack.source,
33+
stack.compose_spec,
34+
),
35+
);
3636

37-
return findObjectByKey(getStacks(), "name", stack.name)?.id;
37+
return findObjectByKey(getStacks(), "name", stack.name)?.id;
3838
}
3939

4040
export function getStacks() {
41-
return executeDbOperation("Get Stacks", () =>
42-
stmt.selectAll.all()
43-
) as Stack[];
41+
return executeDbOperation("Get Stacks", () =>
42+
stmt.selectAll.all(),
43+
) as Stack[];
4444
}
4545

4646
export function deleteStack(id: number) {
47-
return executeDbOperation(
48-
"Delete Stack",
49-
() => stmt.delete.run(id),
50-
() => {
51-
if (typeof id !== "number") throw new TypeError("Invalid stack ID");
52-
}
53-
);
47+
return executeDbOperation(
48+
"Delete Stack",
49+
() => stmt.delete.run(id),
50+
() => {
51+
if (typeof id !== "number") throw new TypeError("Invalid stack ID");
52+
},
53+
);
5454
}
5555

5656
export function updateStack(stack: stacks_config) {
57-
return executeDbOperation("Update Stack", () =>
58-
stmt.update.run(
59-
stack.version,
60-
stack.custom,
61-
stack.source,
62-
stack.name,
63-
stack.compose_spec
64-
)
65-
);
57+
return executeDbOperation("Update Stack", () =>
58+
stmt.update.run(
59+
stack.version,
60+
stack.custom,
61+
stack.source,
62+
stack.name,
63+
stack.compose_spec,
64+
),
65+
);
6666
}

src/core/plugins/plugin-manager.ts

Lines changed: 137 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,145 @@
11
import { EventEmitter } from "node:events";
22
import type { ContainerInfo } from "~/typings/docker";
3-
import type { Plugin, Hooks, PluginInfo } from "~/typings/plugin";
3+
import type { Hooks, Plugin, PluginInfo } from "~/typings/plugin";
44
import { logger } from "../utils/logger";
55

66
class PluginManager extends EventEmitter {
7-
private plugins: Map<string, Plugin> = new Map();
8-
9-
register(plugin: Plugin) {
10-
try {
11-
this.plugins.set(plugin.name, plugin);
12-
logger.debug(`Registered plugin: ${plugin.name}`);
13-
} catch (error) {
14-
logger.error(
15-
`Registering plugin ${plugin.name} failed: ${error as string}`
16-
);
17-
}
18-
}
19-
20-
unregister(name: string) {
21-
this.plugins.delete(name);
22-
}
23-
24-
getLoadedPlugins(): PluginInfo[] {
25-
return Array.from(this.plugins.values()).map((plugin) => {
26-
const hooks: Hooks = {
27-
onContainerStart: !!plugin.onContainerStart,
28-
onContainerStop: !!plugin.onContainerStop,
29-
onContainerExit: !!plugin.onContainerExit,
30-
onContainerCreate: !!plugin.onContainerCreate,
31-
onContainerKill: !!plugin.onContainerKill,
32-
handleContainerDie: !!plugin.handleContainerDie,
33-
onContainerDestroy: !!plugin.onContainerDestroy,
34-
onContainerPause: !!plugin.onContainerPause,
35-
onContainerUnpause: !!plugin.onContainerUnpause,
36-
onContainerRestart: !!plugin.onContainerRestart,
37-
onContainerUpdate: !!plugin.onContainerUpdate,
38-
onContainerRename: !!plugin.onContainerRename,
39-
onContainerHealthStatus: !!plugin.onContainerHealthStatus,
40-
onHostUnreachable: !!plugin.onHostUnreachable,
41-
onHostReachableAgain: !!plugin.onHostReachableAgain,
42-
};
43-
44-
return {
45-
name: plugin.name,
46-
version: plugin.version,
47-
status: "active",
48-
usedHooks: hooks,
49-
};
50-
});
51-
}
52-
53-
// Trigger plugin flows:
54-
handleContainerStop(containerInfo: ContainerInfo) {
55-
for (const [, plugin] of this.plugins) {
56-
plugin.onContainerStop?.(containerInfo);
57-
}
58-
}
59-
60-
handleContainerStart(containerInfo: ContainerInfo) {
61-
for (const [, plugin] of this.plugins) {
62-
plugin.onContainerStart?.(containerInfo);
63-
}
64-
}
65-
66-
handleContainerExit(containerInfo: ContainerInfo) {
67-
for (const [, plugin] of this.plugins) {
68-
plugin.onContainerExit?.(containerInfo);
69-
}
70-
}
71-
72-
handleContainerCreate(containerInfo: ContainerInfo) {
73-
for (const [, plugin] of this.plugins) {
74-
plugin.onContainerCreate?.(containerInfo);
75-
}
76-
}
77-
78-
handleContainerDestroy(containerInfo: ContainerInfo) {
79-
for (const [, plugin] of this.plugins) {
80-
plugin.onContainerDestroy?.(containerInfo);
81-
}
82-
}
83-
84-
handleContainerPause(containerInfo: ContainerInfo) {
85-
for (const [, plugin] of this.plugins) {
86-
plugin.onContainerPause?.(containerInfo);
87-
}
88-
}
89-
90-
handleContainerUnpause(containerInfo: ContainerInfo) {
91-
for (const [, plugin] of this.plugins) {
92-
plugin.onContainerUnpause?.(containerInfo);
93-
}
94-
}
95-
96-
handleContainerRestart(containerInfo: ContainerInfo) {
97-
for (const [, plugin] of this.plugins) {
98-
plugin.onContainerRestart?.(containerInfo);
99-
}
100-
}
101-
102-
handleContainerUpdate(containerInfo: ContainerInfo) {
103-
for (const [, plugin] of this.plugins) {
104-
plugin.onContainerUpdate?.(containerInfo);
105-
}
106-
}
107-
108-
handleContainerRename(containerInfo: ContainerInfo) {
109-
for (const [, plugin] of this.plugins) {
110-
plugin.onContainerRename?.(containerInfo);
111-
}
112-
}
113-
114-
handleContainerHealthStatus(containerInfo: ContainerInfo) {
115-
for (const [, plugin] of this.plugins) {
116-
plugin.onContainerHealthStatus?.(containerInfo);
117-
}
118-
}
119-
120-
handleHostUnreachable(host: string, err: string) {
121-
for (const [, plugin] of this.plugins) {
122-
plugin.onHostUnreachable?.(host, err);
123-
}
124-
}
125-
126-
handleHostReachableAgain(host: string) {
127-
for (const [, plugin] of this.plugins) {
128-
plugin.onHostReachableAgain?.(host);
129-
}
130-
}
131-
132-
handleContainerKill(containerInfo: ContainerInfo) {
133-
for (const [, plugin] of this.plugins) {
134-
plugin.onContainerKill?.(containerInfo);
135-
}
136-
}
137-
138-
handleContainerDie(containerInfo: ContainerInfo) {
139-
for (const [, plugin] of this.plugins) {
140-
plugin.handleContainerDie?.(containerInfo);
141-
}
142-
}
7+
private plugins: Map<string, Plugin> = new Map();
8+
9+
register(plugin: Plugin) {
10+
try {
11+
this.plugins.set(plugin.name, plugin);
12+
logger.debug(`Registered plugin: ${plugin.name}`);
13+
} catch (error) {
14+
logger.error(
15+
`Registering plugin ${plugin.name} failed: ${error as string}`,
16+
);
17+
}
18+
}
19+
20+
unregister(name: string) {
21+
this.plugins.delete(name);
22+
}
23+
24+
getLoadedPlugins(): PluginInfo[] {
25+
return Array.from(this.plugins.values()).map((plugin) => {
26+
const hooks: Hooks = {
27+
onContainerStart: !!plugin.onContainerStart,
28+
onContainerStop: !!plugin.onContainerStop,
29+
onContainerExit: !!plugin.onContainerExit,
30+
onContainerCreate: !!plugin.onContainerCreate,
31+
onContainerKill: !!plugin.onContainerKill,
32+
handleContainerDie: !!plugin.handleContainerDie,
33+
onContainerDestroy: !!plugin.onContainerDestroy,
34+
onContainerPause: !!plugin.onContainerPause,
35+
onContainerUnpause: !!plugin.onContainerUnpause,
36+
onContainerRestart: !!plugin.onContainerRestart,
37+
onContainerUpdate: !!plugin.onContainerUpdate,
38+
onContainerRename: !!plugin.onContainerRename,
39+
onContainerHealthStatus: !!plugin.onContainerHealthStatus,
40+
onHostUnreachable: !!plugin.onHostUnreachable,
41+
onHostReachableAgain: !!plugin.onHostReachableAgain,
42+
};
43+
44+
return {
45+
name: plugin.name,
46+
version: plugin.version,
47+
status: "active",
48+
usedHooks: hooks,
49+
};
50+
});
51+
}
52+
53+
// Trigger plugin flows:
54+
handleContainerStop(containerInfo: ContainerInfo) {
55+
for (const [, plugin] of this.plugins) {
56+
plugin.onContainerStop?.(containerInfo);
57+
}
58+
}
59+
60+
handleContainerStart(containerInfo: ContainerInfo) {
61+
for (const [, plugin] of this.plugins) {
62+
plugin.onContainerStart?.(containerInfo);
63+
}
64+
}
65+
66+
handleContainerExit(containerInfo: ContainerInfo) {
67+
for (const [, plugin] of this.plugins) {
68+
plugin.onContainerExit?.(containerInfo);
69+
}
70+
}
71+
72+
handleContainerCreate(containerInfo: ContainerInfo) {
73+
for (const [, plugin] of this.plugins) {
74+
plugin.onContainerCreate?.(containerInfo);
75+
}
76+
}
77+
78+
handleContainerDestroy(containerInfo: ContainerInfo) {
79+
for (const [, plugin] of this.plugins) {
80+
plugin.onContainerDestroy?.(containerInfo);
81+
}
82+
}
83+
84+
handleContainerPause(containerInfo: ContainerInfo) {
85+
for (const [, plugin] of this.plugins) {
86+
plugin.onContainerPause?.(containerInfo);
87+
}
88+
}
89+
90+
handleContainerUnpause(containerInfo: ContainerInfo) {
91+
for (const [, plugin] of this.plugins) {
92+
plugin.onContainerUnpause?.(containerInfo);
93+
}
94+
}
95+
96+
handleContainerRestart(containerInfo: ContainerInfo) {
97+
for (const [, plugin] of this.plugins) {
98+
plugin.onContainerRestart?.(containerInfo);
99+
}
100+
}
101+
102+
handleContainerUpdate(containerInfo: ContainerInfo) {
103+
for (const [, plugin] of this.plugins) {
104+
plugin.onContainerUpdate?.(containerInfo);
105+
}
106+
}
107+
108+
handleContainerRename(containerInfo: ContainerInfo) {
109+
for (const [, plugin] of this.plugins) {
110+
plugin.onContainerRename?.(containerInfo);
111+
}
112+
}
113+
114+
handleContainerHealthStatus(containerInfo: ContainerInfo) {
115+
for (const [, plugin] of this.plugins) {
116+
plugin.onContainerHealthStatus?.(containerInfo);
117+
}
118+
}
119+
120+
handleHostUnreachable(host: string, err: string) {
121+
for (const [, plugin] of this.plugins) {
122+
plugin.onHostUnreachable?.(host, err);
123+
}
124+
}
125+
126+
handleHostReachableAgain(host: string) {
127+
for (const [, plugin] of this.plugins) {
128+
plugin.onHostReachableAgain?.(host);
129+
}
130+
}
131+
132+
handleContainerKill(containerInfo: ContainerInfo) {
133+
for (const [, plugin] of this.plugins) {
134+
plugin.onContainerKill?.(containerInfo);
135+
}
136+
}
137+
138+
handleContainerDie(containerInfo: ContainerInfo) {
139+
for (const [, plugin] of this.plugins) {
140+
plugin.handleContainerDie?.(containerInfo);
141+
}
142+
}
143143
}
144144

145145
export const pluginManager = new PluginManager();

0 commit comments

Comments
 (0)