Skip to content

Commit

Permalink
Add schemas for: LinUtil (#4080)
Browse files Browse the repository at this point in the history
* feat(schema): support LinUtil configs

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix(schema): use `id` instead of `$id`

* feat(test): add positive tests

* feat(test): add negative tests

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
EmilyGraceSeville7cf and pre-commit-ci[bot] committed Sep 17, 2024
1 parent 3bce93d commit 3eadf78
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/api/json/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -6884,6 +6884,18 @@
"description": "Preset list for a WinUtil",
"fileMatch": ["**/*winutil*/config/preset.json"],
"url": "https://raw.githubusercontent.com/winutil-preset.json"
},
{
"name": "Tab list for a LinUtil",
"description": "Tab list for a LinUtil",
"fileMatch": ["**/*linutil*/**/tabs.toml"],
"url": "https://raw.githubusercontent.com/linutil-tabs.json"
},
{
"name": "Tab data for a LinUtil",
"description": "Tab data for a LinUtil",
"fileMatch": ["**/*linutil*/**/tab_data.toml"],
"url": "https://raw.githubusercontent.com/linutil-tab-data.json"
}
]
}
26 changes: 26 additions & 0 deletions src/negative_test/linutil-tab-data/invalid-properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"data": [
{
"name": "",
"script": ""
},
{
"entries": [
{
"name": "",
"script": ""
}
],
"name": "",
"preconditions": [
{
"data": {
"environment": ""
},
"values": [""]
}
]
}
],
"name": ""
}
3 changes: 3 additions & 0 deletions src/negative_test/linutil-tabs/invalid-items.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directories": [""]
}
123 changes: 123 additions & 0 deletions src/schemas/json/linutil-tab-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://raw.githubusercontent.com/linutil-tab-data.json",
"definitions": {
"string-property": {
"type": "string",
"minLength": 1,
"pattern": "[^ ]"
}
},
"title": "tab data",
"description": "Tab data",
"type": "object",
"required": ["name", "data"],
"properties": {
"name": {
"$ref": "#/definitions/string-property",
"title": "name",
"description": "The name of a tab"
},
"data": {
"title": "data",
"description": "The data of a tab",
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"title": "data entry",
"description": "The data entry of a tab",
"type": "object",
"properties": {
"name": {
"$ref": "#/definitions/string-property",
"title": "name",
"description": "The name of a tab entry"
},
"script": {
"$ref": "#/definitions/string-property",
"title": "script",
"description": "The script run of a tab entry"
},
"preconditions": {
"title": "preconditions",
"description": "Preconditions of a tab entry",
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"title": "precondition entry",
"description": "The precondition entry of a tab entry",
"type": "object",
"properties": {
"matches": {
"title": "matches",
"description": "Whether to require the condition to match or not for a precondition entry",
"type": "boolean"
},
"data": {
"title": "data",
"description": "The data of a tab precondition entry",
"type": "object",
"properties": {
"environment": {
"$ref": "#/definitions/string-property",
"title": "environment",
"description": "The environment variable of a data"
}
},
"additionalProperties": false
},
"values": {
"title": "values",
"description": "The values of a tab precondition entry",
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"title": "entry",
"description": "The entry of values",
"type": "string"
}
}
},
"additionalProperties": false
}
},
"entries": {
"title": "entries",
"description": "The entries of a tab entry",
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"title": "entry",
"description": "The entry",
"type": "object",
"properties": {
"name": {
"$ref": "#/definitions/string-property",
"title": "name",
"description": "The name of a tab entry"
},
"script": {
"$ref": "#/definitions/string-property",
"title": "script",
"description": "The script run of a tab entry"
},
"matches": {
"title": "matches",
"description": "Whether to require the condition to match or not for an entry",
"type": "boolean"
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
25 changes: 25 additions & 0 deletions src/schemas/json/linutil-tabs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://raw.githubusercontent.com/linutil-tabs.json",
"title": "tab data",
"description": "Tab data",
"type": "object",
"required": ["directories"],
"properties": {
"directories": {
"title": "directories",
"description": "The directories of tabs",
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"title": "directory entry",
"description": "The directory entry of a tab",
"type": "string",
"minLength": 1,
"pattern": "[^ ]"
}
}
},
"additionalProperties": false
}
71 changes: 71 additions & 0 deletions src/test/linutil-tab-data/one-tab.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"data": [
{
"name": "WiFi Manager",
"script": "wifi-control.sh"
},
{
"entries": [
{
"name": "Duplicate Displays",
"script": "monitor-control/duplicate_displays.sh"
},
{
"name": "Extend Displays",
"script": "monitor-control/extend_displays.sh"
},
{
"name": "Auto Detect Displays",
"script": "monitor-control/auto_detect_displays.sh"
},
{
"name": "Enable Monitor",
"script": "monitor-control/enable_monitor.sh"
},
{
"name": "Disable Monitor",
"script": "monitor-control/disable_monitor.sh"
},
{
"name": "Set Primary Monitor",
"script": "monitor-control/set_primary_monitor.sh"
},
{
"name": "Change Orientation",
"script": "monitor-control/change_orientation.sh"
},
{
"name": "Manage Arrangement",
"script": "monitor-control/manage_arrangement.sh"
},
{
"name": "Scale Monitors",
"script": "monitor-control/scale_monitor.sh"
},
{
"matches": true,
"name": "Reset Scaling",
"script": "monitor-control/reset_scaling.sh"
}
],
"name": "Monitor Control",
"preconditions": [
{
"data": {
"environment": "XDG_SESSION_TYPE"
},
"matches": true,
"values": ["x11", "X11", "xorg", "Xorg", "tty"]
},
{
"data": {
"environment": "DISPLAY"
},
"matches": true,
"values": [":0", ":1", ":2", ":3", ":4", ":5", ":6", ":7", ":8", ":9"]
}
]
}
],
"name": "Utilities"
}
9 changes: 9 additions & 0 deletions src/test/linutil-tabs/top-level-directories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"directories": [
"applications-setup",
"gaming",
"security",
"system-setup",
"utils"
]
}

0 comments on commit 3eadf78

Please sign in to comment.