mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-24 12:25:11 +00:00
Merge pull request #800 from github/chore/clean-materialized-plugins
Add cross-platform script to clean materialized plugin files
This commit is contained in:
62
eng/clean-materialized-plugins.mjs
Normal file
62
eng/clean-materialized-plugins.mjs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#!/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();
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
"plugin:create": "node ./eng/create-plugin.mjs",
|
"plugin:create": "node ./eng/create-plugin.mjs",
|
||||||
"skill:validate": "node ./eng/validate-skills.mjs",
|
"skill:validate": "node ./eng/validate-skills.mjs",
|
||||||
"skill:create": "node ./eng/create-skill.mjs",
|
"skill:create": "node ./eng/create-skill.mjs",
|
||||||
|
"plugin:clean": "node ./eng/clean-materialized-plugins.mjs",
|
||||||
"plugin:generate-marketplace": "node ./eng/generate-marketplace.mjs",
|
"plugin:generate-marketplace": "node ./eng/generate-marketplace.mjs",
|
||||||
"website:data": "node ./eng/generate-website-data.mjs",
|
"website:data": "node ./eng/generate-website-data.mjs",
|
||||||
"website:dev": "npm run website:data && npm run --prefix website dev",
|
"website:dev": "npm run website:data && npm run --prefix website dev",
|
||||||
|
|||||||
Reference in New Issue
Block a user