mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 22:25:24 +00:00
feat: add category and icon fields to plugin manifest schema
This commit is contained in:
1 parent
5a76d30637
commit
7f1beddccc
8 files changed
+72
No files matched your search
@@ -27,6 +27,10 @@ function knownPermissions(schema) {
|
||||
return schema.properties.permissions.items.enum;
|
||||
}
|
||||
|
||||
function knownCategories(schema) {
|
||||
return schema.properties.category.enum;
|
||||
}
|
||||
|
||||
function validateManifest(manifest, schema) {
|
||||
const errors = [];
|
||||
|
||||
@@ -56,6 +60,21 @@ function validateManifest(manifest, schema) {
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof manifest.category === "string") {
|
||||
const categories = knownCategories(schema);
|
||||
if (!categories.includes(manifest.category)) {
|
||||
errors.push(
|
||||
`Field "category" must be one of: ${categories.join(", ")}, got: "${manifest.category}"`,
|
||||
);
|
||||
}
|
||||
} else if ("category" in manifest) {
|
||||
errors.push('Field "category" must be a string');
|
||||
}
|
||||
|
||||
if ("icon" in manifest && typeof manifest.icon !== "string") {
|
||||
errors.push('Field "icon" must be a string');
|
||||
}
|
||||
|
||||
if (manifest.engine && typeof manifest.engine === "object") {
|
||||
if (!manifest.engine.termix) {
|
||||
errors.push('Field "engine.termix" is required');
|
||||
|
||||
Reference in new issue
Block a user