()
| 181 | |
| 182 | // Main validation function |
| 183 | function validatePlugins() { |
| 184 | if (!fs.existsSync(PLUGINS_DIR)) { |
| 185 | console.log("No plugins directory found - validation skipped"); |
| 186 | return true; |
| 187 | } |
| 188 | |
| 189 | const pluginDirs = fs |
| 190 | .readdirSync(PLUGINS_DIR, { withFileTypes: true }) |
| 191 | .filter((d) => d.isDirectory()) |
| 192 | .map((d) => d.name); |
| 193 | |
| 194 | if (pluginDirs.length === 0) { |
| 195 | console.log("No plugin directories found - validation skipped"); |
| 196 | return true; |
| 197 | } |
| 198 | |
| 199 | console.log(`Validating ${pluginDirs.length} plugins...\n`); |
| 200 | |
| 201 | let hasErrors = false; |
| 202 | const seenNames = new Set(); |
| 203 | |
| 204 | for (const dir of pluginDirs) { |
| 205 | console.log(`Validating ${dir}...`); |
| 206 | |
| 207 | const errors = validatePlugin(dir); |
| 208 | |
| 209 | if (errors.length > 0) { |
| 210 | console.error(`❌ ${dir}:`); |
| 211 | errors.forEach((e) => console.error(` - ${e}`)); |
| 212 | hasErrors = true; |
| 213 | } else { |
| 214 | console.log(`✅ ${dir} is valid`); |
| 215 | } |
| 216 | |
| 217 | // Rule 10: duplicate names |
| 218 | if (seenNames.has(dir)) { |
| 219 | console.error(`❌ Duplicate plugin name "${dir}"`); |
| 220 | hasErrors = true; |
| 221 | } else { |
| 222 | seenNames.add(dir); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | console.log("\nValidating external plugin catalog..."); |
| 227 | const { plugins: externalPlugins, errors: externalErrors, warnings: externalWarnings } = readExternalPlugins({ |
| 228 | localPluginNames: pluginDirs, |
| 229 | policy: "marketplace", |
| 230 | }); |
| 231 | |
| 232 | externalWarnings.forEach((warning) => console.warn(`⚠️ ${warning}`)); |
| 233 | |
| 234 | if (externalErrors.length > 0) { |
| 235 | console.error("❌ external.json:"); |
| 236 | externalErrors.forEach((error) => console.error(` - ${error}`)); |
| 237 | hasErrors = true; |
| 238 | } else { |
| 239 | console.log(`✅ external.json is valid (${externalPlugins.length} external plugins)`); |
| 240 | } |
no test coverage detected