-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapply-plugin-fixes.ts
More file actions
83 lines (69 loc) · 2.33 KB
/
apply-plugin-fixes.ts
File metadata and controls
83 lines (69 loc) · 2.33 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
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bun
import { readFileSync, writeFileSync } from "fs";
interface Plugin {
name: string;
description: string;
tags: string[];
source: string;
installSteps: string[];
}
interface Suggestion {
name: string;
issues: string[];
suggestions: {
sourceUrl?: string;
additionalTags?: string[];
descriptionTip?: string;
};
}
interface Report {
suggestions: Suggestion[];
}
async function main() {
console.log("🔧 Applying Plugin Quality Fixes");
console.log("================================\n");
// Load suggestions and plugins
const report: Report = JSON.parse(readFileSync("plugin-quality-report.json", "utf-8"));
const plugins: Plugin[] = JSON.parse(readFileSync("marketing/plugins-dump.json", "utf-8"));
const pluginMap = new Map(plugins.map(p => [p.name, p]));
let fixed = 0;
let sourceUrlsAdded = 0;
let tagsAdded = 0;
for (const suggestion of report.suggestions) {
const plugin = pluginMap.get(suggestion.name);
if (!plugin) continue;
// Apply source URL fix
if (suggestion.suggestions.sourceUrl && (!plugin.source || plugin.source === "https://github.com")) {
plugin.source = suggestion.suggestions.sourceUrl;
sourceUrlsAdded++;
console.log(`✓ ${plugin.name}: Source URL added`);
}
// Apply tag suggestions
if (suggestion.suggestions.additionalTags) {
const before = plugin.tags.length;
suggestion.suggestions.additionalTags.forEach(tag => {
if (!plugin.tags.includes(tag)) {
plugin.tags.push(tag);
}
});
if (plugin.tags.length > before) {
tagsAdded += plugin.tags.length - before;
console.log(`✓ ${plugin.name}: Added ${plugin.tags.length - before} tags`);
}
}
fixed++;
}
// Re-sort plugin array
const updatedPlugins = Array.from(pluginMap.values()).sort((a, b) =>
a.name.localeCompare(b.name)
);
// Save updated dump
writeFileSync("marketing/plugins-dump.json", JSON.stringify(updatedPlugins, null, 2));
console.log(`\n✅ Quality Fixes Applied`);
console.log(`========================`);
console.log(`Plugins fixed: ${fixed}`);
console.log(`Source URLs added: ${sourceUrlsAdded}`);
console.log(`Tags added: ${tagsAdded}`);
console.log(`\n✓ Updated plugins-dump.json with ${updatedPlugins.length} plugins`);
}
main().catch(console.error);