mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-24 04:15:14 +00:00
Merge branch 'staged' into agentic-workflows-staged
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();
|
||||
@@ -14,12 +14,12 @@ const MARKETPLACE_FILE = path.join(ROOT_FOLDER, ".github/plugin", "marketplace.j
|
||||
*/
|
||||
function readPluginMetadata(pluginDir) {
|
||||
const pluginJsonPath = path.join(pluginDir, ".github/plugin", "plugin.json");
|
||||
|
||||
|
||||
if (!fs.existsSync(pluginJsonPath)) {
|
||||
console.warn(`Warning: No plugin.json found for ${path.basename(pluginDir)}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const content = fs.readFileSync(pluginJsonPath, "utf8");
|
||||
return JSON.parse(content);
|
||||
@@ -34,30 +34,30 @@ function readPluginMetadata(pluginDir) {
|
||||
*/
|
||||
function generateMarketplace() {
|
||||
console.log("Generating marketplace.json...");
|
||||
|
||||
|
||||
if (!fs.existsSync(PLUGINS_DIR)) {
|
||||
console.error(`Error: Plugins directory not found at ${PLUGINS_DIR}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
// Read all plugin directories
|
||||
const pluginDirs = fs.readdirSync(PLUGINS_DIR, { withFileTypes: true })
|
||||
.filter(entry => entry.isDirectory())
|
||||
.map(entry => entry.name)
|
||||
.sort();
|
||||
|
||||
|
||||
console.log(`Found ${pluginDirs.length} plugin directories`);
|
||||
|
||||
|
||||
// Read metadata for each plugin
|
||||
const plugins = [];
|
||||
for (const dirName of pluginDirs) {
|
||||
const pluginPath = path.join(PLUGINS_DIR, dirName);
|
||||
const metadata = readPluginMetadata(pluginPath);
|
||||
|
||||
|
||||
if (metadata) {
|
||||
plugins.push({
|
||||
name: metadata.name,
|
||||
source: `./plugins/${dirName}`,
|
||||
source: dirName,
|
||||
description: metadata.description,
|
||||
version: metadata.version || "1.0.0"
|
||||
});
|
||||
@@ -66,7 +66,7 @@ function generateMarketplace() {
|
||||
console.log(`✗ Skipped: ${dirName} (no valid plugin.json)`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create marketplace.json structure
|
||||
const marketplace = {
|
||||
name: "awesome-copilot",
|
||||
@@ -81,16 +81,16 @@ function generateMarketplace() {
|
||||
},
|
||||
plugins: plugins
|
||||
};
|
||||
|
||||
|
||||
// Ensure directory exists
|
||||
const marketplaceDir = path.dirname(MARKETPLACE_FILE);
|
||||
if (!fs.existsSync(marketplaceDir)) {
|
||||
fs.mkdirSync(marketplaceDir, { recursive: true });
|
||||
}
|
||||
|
||||
|
||||
// Write marketplace.json
|
||||
fs.writeFileSync(MARKETPLACE_FILE, JSON.stringify(marketplace, null, 2) + "\n");
|
||||
|
||||
|
||||
console.log(`\n✓ Successfully generated marketplace.json with ${plugins.length} plugins`);
|
||||
console.log(` Location: ${MARKETPLACE_FILE}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user