mirror of
https://github.com/github/awesome-copilot.git
synced 2026-05-04 14:15:55 +00:00
Enforce canonical plugin manifest ordering (#1601)
* Enforce canonical plugin manifest ordering Sort existing plugin manifest spec arrays so plugin:clean no longer creates noisy diffs from out-of-order entries. Add validation to require alphabetical ordering and teach plugin:clean to normalize manifest arrays when cleaning materialized plugin content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -42,6 +42,14 @@ export function restoreManifestFromMaterializedFiles(pluginPath) {
|
||||
|
||||
let changed = false;
|
||||
for (const [field, spec] of Object.entries(MATERIALIZED_SPECS)) {
|
||||
if (Array.isArray(plugin[field])) {
|
||||
const sortedEntries = sortPluginEntries(plugin[field]);
|
||||
if (!arraysEqual(plugin[field], sortedEntries)) {
|
||||
plugin[field] = sortedEntries;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
const materializedPath = path.join(pluginPath, spec.path);
|
||||
if (!fs.existsSync(materializedPath) || !fs.statSync(materializedPath).isDirectory()) {
|
||||
continue;
|
||||
@@ -132,6 +140,10 @@ function arraysEqual(left, right) {
|
||||
return left.every((value, index) => value === right[index]);
|
||||
}
|
||||
|
||||
function sortPluginEntries(entries) {
|
||||
return [...entries].sort((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
function toPosixPath(filePath) {
|
||||
return filePath.split(path.sep).join("/");
|
||||
}
|
||||
@@ -165,7 +177,7 @@ function main() {
|
||||
} else {
|
||||
console.log(`✅ Removed ${total} materialized file(s) from plugins.`);
|
||||
if (manifestsUpdated > 0) {
|
||||
console.log(`✅ Updated ${manifestsUpdated} plugin manifest(s) with folder trailing slashes.`);
|
||||
console.log(`✅ Updated ${manifestsUpdated} plugin manifest(s) to restore and normalize spec entries.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user