mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-24 04:15:14 +00:00
Adds eng/clean-materialized-plugins.mjs which removes agents/, commands/, and skills/ subdirectories from plugin folders. These are generated by CI via eng/materialize-plugins.mjs during publish and should not be tracked on the staged branch. Runnable via: npm run plugin:clean Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import fs from "fs";
|
|
import path from "path";
|
|
import { ROOT_FOLDER } from "./constants.mjs";
|
|
|
|
const PLUGINS_DIR = path.join(ROOT_FOLDER, "plugins");
|
|
const MATERIALIZED_DIRS = ["agents", "commands", "skills"];
|
|
|
|
function cleanPlugin(pluginPath) {
|
|
let removed = 0;
|
|
for (const subdir of MATERIALIZED_DIRS) {
|
|
const target = path.join(pluginPath, subdir);
|
|
if (fs.existsSync(target) && fs.statSync(target).isDirectory()) {
|
|
const count = countFiles(target);
|
|
fs.rmSync(target, { recursive: true, force: true });
|
|
removed += count;
|
|
console.log(` Removed ${path.basename(pluginPath)}/${subdir}/ (${count} files)`);
|
|
}
|
|
}
|
|
return removed;
|
|
}
|
|
|
|
function countFiles(dir) {
|
|
let count = 0;
|
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
if (entry.isDirectory()) {
|
|
count += countFiles(path.join(dir, entry.name));
|
|
} else {
|
|
count++;
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
|
|
function main() {
|
|
console.log("Cleaning materialized files from plugins...\n");
|
|
|
|
if (!fs.existsSync(PLUGINS_DIR)) {
|
|
console.error(`Error: plugins directory not found at ${PLUGINS_DIR}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const pluginDirs = fs.readdirSync(PLUGINS_DIR, { withFileTypes: true })
|
|
.filter(entry => entry.isDirectory())
|
|
.map(entry => entry.name)
|
|
.sort();
|
|
|
|
let total = 0;
|
|
for (const dirName of pluginDirs) {
|
|
total += cleanPlugin(path.join(PLUGINS_DIR, dirName));
|
|
}
|
|
|
|
console.log();
|
|
if (total === 0) {
|
|
console.log("✅ No materialized files found. Plugins are already clean.");
|
|
} else {
|
|
console.log(`✅ Removed ${total} materialized file(s) from plugins.`);
|
|
}
|
|
}
|
|
|
|
main();
|