Skip to content

Commit 7407fc9

Browse files
authored
Merge pull request #43 from Cleboost/chore/knip
chore: Add Knip for unused code analysis
2 parents 7f222d6 + 301607d commit 7407fc9

File tree

8 files changed

+147
-44
lines changed

8 files changed

+147
-44
lines changed

.github/workflows/pr.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,8 @@ jobs:
5050
- name: Install Bun Packages
5151
run: bun install
5252

53+
- name: Run Knip
54+
run: bun run knip
55+
5356
- name: Build project
5457
run: bun run tauri build --no-bundle

bun.lock

Lines changed: 67 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

knip.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@5/schema.json",
3+
"entry": ["src/main.ts"],
4+
"project": ["src/**/*.{ts,vue}"],
5+
"ignore": ["src/**/*.d.ts", "src/components/ui/**/*"],
6+
"ignoreDependencies": [
7+
"@tanstack/vue-table",
8+
"@unovis/ts",
9+
"@unovis/vue",
10+
"@vee-validate/zod",
11+
"embla-carousel-vue",
12+
"tailwindcss",
13+
"tw-animate-css",
14+
"vaul-vue",
15+
"vee-validate",
16+
"vue-sonner",
17+
"zod"
18+
]
19+
}

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
"dev": "vite",
88
"build": "vite build",
99
"preview": "vite preview",
10-
"tauri": "tauri"
10+
"tauri": "tauri",
11+
"lint" : "vue-tsc --noEmit",
12+
"knip": "knip"
1113
},
1214
"dependencies": {
1315
"@iconify/vue": "^5.0.0",
1416
"@tailwindcss/vite": "^4.1.13",
1517
"@tanstack/vue-table": "^8.21.3",
1618
"@tauri-apps/api": "^2",
1719
"@tauri-apps/plugin-fs": "^2.4.2",
18-
"@tauri-apps/plugin-opener": "^2",
1920
"@tauri-apps/plugin-shell": "^2.3.1",
2021
"@tauri-apps/plugin-store": "^2.4.0",
2122
"@unovis/ts": "^1.6.1",
@@ -41,7 +42,9 @@
4142
"devDependencies": {
4243
"@tauri-apps/cli": "^2",
4344
"@types/bun": "^1.2.22",
45+
"@types/node": "^24.5.2",
4446
"@vitejs/plugin-vue": "^6.0.0",
47+
"knip": "^5.64.0",
4548
"typescript": "~5.9.0",
4649
"vite": "^7.0.0",
4750
"vue-tsc": "^3.0.0"

src/class/Server.ts

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,20 @@ export class ServerConsole {
127127
}
128128

129129
async execute(command: string): Promise<string> {
130-
const child = Command.create("ssh", ["-tt", "-o", "StrictHostKeyChecking=accept-new", "-i", await this.server.config().getKey().getPath(), `root@${this.server.config().getIP()}`, command]);
131-
130+
const child = Command.create("ssh", [
131+
"-tt",
132+
"-o",
133+
"StrictHostKeyChecking=accept-new",
134+
"-i",
135+
await this.server.config().getKey().getPath(),
136+
`root@${this.server.config().getIP()}`,
137+
command,
138+
]);
139+
132140
return new Promise((resolve, reject) => {
133141
let stdout = "";
134142
let stderr = "";
135-
143+
136144
child.on("close", (data) => {
137145
if (data.code === 0) {
138146
resolve(stdout);
@@ -144,25 +152,31 @@ export class ServerConsole {
144152
} else if (stderr.includes("Permission denied")) {
145153
reject(new Error("Cannot connect to server: Permission denied"));
146154
} else if (stderr.includes("Host key verification failed")) {
147-
reject(new Error("Cannot connect to server: Host key verification failed"));
155+
reject(
156+
new Error(
157+
"Cannot connect to server: Host key verification failed",
158+
),
159+
);
148160
} else {
149-
reject(new Error(`Command failed with code ${data.code}: ${stderr}`));
161+
reject(
162+
new Error(`Command failed with code ${data.code}: ${stderr}`),
163+
);
150164
}
151165
}
152166
});
153-
167+
154168
child.on("error", (error) => {
155169
reject(new Error(`Error executing command: ${error}`));
156170
});
157-
171+
158172
child.stdout.on("data", (data) => {
159173
stdout += data;
160174
});
161-
175+
162176
child.stderr.on("data", (data) => {
163177
stderr += data;
164178
});
165-
179+
166180
child.spawn();
167181
});
168182
}
@@ -174,11 +188,11 @@ class Docker {
174188
constructor(server: Server) {
175189
this.server = server;
176190
}
177-
191+
178192
async getVersion(): Promise<string> {
179193
try {
180194
const output = await this.server.console.execute("docker version");
181-
const lines = output.split('\n');
195+
const lines = output.split("\n");
182196
let foundCommunity = false;
183197
let version = null;
184198

@@ -224,47 +238,47 @@ class Docker {
224238
}> {
225239
try {
226240
const command = `echo "===CONTAINERS===" && docker ps -a --format "{{.Status}}" && echo "===IMAGES===" && docker images --format "{{.Repository}}" && echo "===DANGLING===" && docker images -f dangling=true --format "{{.Repository}}" && echo "===SIZE===" && docker system df`;
227-
241+
228242
const output = await this.server.console.execute(command);
229243
console.log("Docker command output:", output); // Debug log
230-
231-
const lines = output.split('\n');
232-
let currentSection = '';
244+
245+
const lines = output.split("\n");
246+
let currentSection = "";
233247
const containers: string[] = [];
234248
const images: string[] = [];
235249
const dangling: string[] = [];
236250
let size = "0B";
237-
251+
238252
for (const line of lines) {
239253
const trimmedLine = line.trim();
240-
241-
if (trimmedLine === '===CONTAINERS===') {
242-
currentSection = 'containers';
254+
255+
if (trimmedLine === "===CONTAINERS===") {
256+
currentSection = "containers";
243257
continue;
244-
} else if (trimmedLine === '===IMAGES===') {
245-
currentSection = 'images';
258+
} else if (trimmedLine === "===IMAGES===") {
259+
currentSection = "images";
246260
continue;
247-
} else if (trimmedLine === '===DANGLING===') {
248-
currentSection = 'dangling';
261+
} else if (trimmedLine === "===DANGLING===") {
262+
currentSection = "dangling";
249263
continue;
250-
} else if (trimmedLine === '===SIZE===') {
251-
currentSection = 'size';
264+
} else if (trimmedLine === "===SIZE===") {
265+
currentSection = "size";
252266
continue;
253267
}
254-
255-
if (trimmedLine && !trimmedLine.includes('REPOSITORY')) {
268+
269+
if (trimmedLine && !trimmedLine.includes("REPOSITORY")) {
256270
switch (currentSection) {
257-
case 'containers':
271+
case "containers":
258272
containers.push(trimmedLine);
259273
break;
260-
case 'images':
274+
case "images":
261275
images.push(trimmedLine);
262276
break;
263-
case 'dangling':
277+
case "dangling":
264278
dangling.push(trimmedLine);
265279
break;
266-
case 'size':
267-
if (trimmedLine.includes('Images')) {
280+
case "size":
281+
if (trimmedLine.includes("Images")) {
268282
const sizeMatch = trimmedLine.match(/(\d+\.?\d*[GMK]?B)/);
269283
if (sizeMatch) {
270284
size = sizeMatch[1];
@@ -274,11 +288,11 @@ class Docker {
274288
}
275289
}
276290
}
277-
291+
278292
let running = 0;
279293
let stopped = 0;
280294
for (const container of containers) {
281-
if (container.includes('Up')) {
295+
if (container.includes("Up")) {
282296
running++;
283297
} else {
284298
stopped++;
@@ -289,22 +303,20 @@ class Docker {
289303
containers: {
290304
running,
291305
stopped,
292-
total: running + stopped
306+
total: running + stopped,
293307
},
294308
images: {
295309
local: images.length,
296310
size,
297-
dangling: dangling.length
298-
}
311+
dangling: dangling.length,
312+
},
299313
};
300314
} catch (error) {
301315
console.error("Error retrieving Docker data:", error);
302316
return {
303317
containers: { running: 0, stopped: 0, total: 0 },
304-
images: { local: 0, size: "0B", dangling: 0 }
318+
images: { local: 0, size: "0B", dangling: 0 },
305319
};
306320
}
307321
}
308322
}
309-
310-
export type { ConfigServer, Docker };

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"@/*": ["./src/*"]
2525
}
2626
},
27-
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
27+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue"],
2828
"references": [{ "path": "./tsconfig.node.json" }]
2929
}

0 commit comments

Comments
 (0)