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:
@@ -64,6 +64,18 @@ function validateKeywords(keywords) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function arraysEqual(left, right) {
|
||||
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return left.every((value, index) => value === right[index]);
|
||||
}
|
||||
|
||||
function sortPluginEntries(entries) {
|
||||
return [...entries].sort((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
function validateSpecPaths(plugin) {
|
||||
const errors = [];
|
||||
const specs = {
|
||||
@@ -78,6 +90,9 @@ function validateSpecPaths(plugin) {
|
||||
errors.push(`${field} must be an array`);
|
||||
continue;
|
||||
}
|
||||
if (!arraysEqual(arr, sortPluginEntries(arr))) {
|
||||
errors.push(`${field} must be sorted alphabetically`);
|
||||
}
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const p = arr[i];
|
||||
if (typeof p !== "string") {
|
||||
|
||||
Reference in New Issue
Block a user