-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate-plugin.ts
More file actions
executable file
·72 lines (63 loc) · 1.92 KB
/
validate-plugin.ts
File metadata and controls
executable file
·72 lines (63 loc) · 1.92 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
66
67
68
69
70
71
72
#!/usr/bin/env bun
import { readFileSync } from "node:fs";
import { $ } from "bun";
const manifest = JSON.parse(readFileSync("manifest.json", "utf-8"));
console.log(`🔍 Validating ${manifest.name || "plugin"}...\n`);
let errors = 0;
// Check manifest.json
if (!manifest.id || !manifest.name || !manifest.version) {
console.error("✗ manifest.json missing required fields");
errors++;
} else {
console.log(`✓ manifest.json — ${manifest.name} v${manifest.version}`);
}
// Check package.json version matches manifest
try {
const pkg = JSON.parse(readFileSync("package.json", "utf-8"));
if (pkg.version !== manifest.version) {
console.error(
`✗ Version mismatch: package.json (${pkg.version}) != manifest.json (${manifest.version})`,
);
errors++;
} else {
console.log("✓ Version numbers match");
}
} catch (error) {
console.error("✗ Version check failed:", error);
errors++;
}
// Run checks
console.log("\n🔧 Checking code quality...");
const checkResult = await $`bun run check`.nothrow();
if (checkResult.exitCode === 0) {
console.log("✓ Code quality checks passed");
} else {
console.error("✗ Code quality checks failed");
errors++;
}
// Build the plugin
console.log("\n📦 Building plugin...");
const buildResult = await $`bun run build.ts`.nothrow();
if (buildResult.exitCode === 0) {
console.log("✓ Build successful");
const mainFile = Bun.file("main.js");
if (await mainFile.exists()) {
const size = mainFile.size / 1024;
console.log(` Output: main.js (${size.toFixed(2)} KB)`);
} else {
console.error("✗ main.js not found after build");
errors++;
}
} else {
console.error("✗ Build failed");
errors++;
}
// Summary
console.log(`\n${"=".repeat(50)}`);
if (errors === 0) {
console.log("✅ All validations passed! Plugin is ready.");
process.exit(0);
} else {
console.log(`❌ Validation failed with ${errors} error(s).`);
process.exit(1);
}