mirror of
https://github.com/github/awesome-copilot.git
synced 2026-03-12 04:05:12 +00:00
fix: rewrite plugin.json paths to folders during publish
During the staged→main publish, after materializing files into plugin directories, rewrite each plugin.json to replace individual file paths with folder references so consumers on main get directory-level entries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -145,6 +145,30 @@ function materializePlugins() {
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite plugin.json to use folder paths instead of individual file paths.
|
||||
// On staged, paths like ./agents/foo.md point to individual source files.
|
||||
// On main, after materialization, we only need the containing directory.
|
||||
const rewritten = { ...metadata };
|
||||
let changed = false;
|
||||
|
||||
for (const field of ["agents", "commands"]) {
|
||||
if (Array.isArray(rewritten[field]) && rewritten[field].length > 0) {
|
||||
const dirs = [...new Set(rewritten[field].map(p => path.dirname(p)))];
|
||||
rewritten[field] = dirs;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(rewritten.skills) && rewritten.skills.length > 0) {
|
||||
// Skills are already folder refs (./skills/name/); strip trailing slash
|
||||
rewritten.skills = rewritten.skills.map(p => p.replace(/\/$/, ""));
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
fs.writeFileSync(pluginJsonPath, JSON.stringify(rewritten, null, 2) + "\n", "utf8");
|
||||
}
|
||||
|
||||
const counts = [];
|
||||
if (metadata.agents?.length) counts.push(`${metadata.agents.length} agents`);
|
||||
if (metadata.commands?.length) counts.push(`${metadata.commands.length} commands`);
|
||||
|
||||
Reference in New Issue
Block a user