mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-08 22:15:14 +02:00
feat(cli): generate json schemas locally
This commit updates the various komorebic json schema generation commands to generate the schemas locally, without requiring a running instance of komorebi to communicate with over IPC.
This commit is contained in:
Generated
+1
@@ -2766,6 +2766,7 @@ dependencies = [
|
|||||||
"paste",
|
"paste",
|
||||||
"powershell_script",
|
"powershell_script",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json_lenient",
|
"serde_json_lenient",
|
||||||
"serde_yaml 0.9.34+deprecated",
|
"serde_yaml 0.9.34+deprecated",
|
||||||
|
|||||||
@@ -45,4 +45,6 @@ docgen:
|
|||||||
|
|
||||||
schemagen:
|
schemagen:
|
||||||
komorebic static-config-schema > schema.json
|
komorebic static-config-schema > schema.json
|
||||||
|
komorebic application-specific-configuration-schema > schema.asc.json
|
||||||
|
komorebi-bar --schema > schema.bar.json
|
||||||
generate-schema-doc .\schema.json --config template_name=js_offline --config minify=false .\static-config-docs\
|
generate-schema-doc .\schema.json --config template_name=js_offline --config minify=false .\static-config-docs\
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
pub use komorebi::colour::Colour;
|
pub use komorebi::colour::Colour;
|
||||||
pub use komorebi::colour::Rgb;
|
pub use komorebi::colour::Rgb;
|
||||||
|
pub use komorebi::config_generation::ApplicationConfiguration;
|
||||||
pub use komorebi::container::Container;
|
pub use komorebi::container::Container;
|
||||||
pub use komorebi::core::config_generation::ApplicationConfigurationGenerator;
|
pub use komorebi::core::config_generation::ApplicationConfigurationGenerator;
|
||||||
pub use komorebi::core::resolve_home_path;
|
pub use komorebi::core::resolve_home_path;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ which = "6"
|
|||||||
win32-display-data = { workspace = true }
|
win32-display-data = { workspace = true }
|
||||||
windows = { workspace = true }
|
windows = { workspace = true }
|
||||||
shadow-rs = { workspace = true }
|
shadow-rs = { workspace = true }
|
||||||
|
schemars = { workspace = true }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
reqwest = { version = "0.12", features = ["blocking"] }
|
reqwest = { version = "0.12", features = ["blocking"] }
|
||||||
|
|||||||
+23
-4
@@ -25,12 +25,16 @@ use fs_tail::TailedFile;
|
|||||||
use komorebi_client::resolve_home_path;
|
use komorebi_client::resolve_home_path;
|
||||||
use komorebi_client::send_message;
|
use komorebi_client::send_message;
|
||||||
use komorebi_client::send_query;
|
use komorebi_client::send_query;
|
||||||
|
use komorebi_client::ApplicationConfiguration;
|
||||||
|
use komorebi_client::Notification;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use miette::NamedSource;
|
use miette::NamedSource;
|
||||||
use miette::Report;
|
use miette::Report;
|
||||||
use miette::SourceOffset;
|
use miette::SourceOffset;
|
||||||
use miette::SourceSpan;
|
use miette::SourceSpan;
|
||||||
use paste::paste;
|
use paste::paste;
|
||||||
|
use schemars::gen::SchemaSettings;
|
||||||
|
use schemars::schema_for;
|
||||||
use which::which;
|
use which::which;
|
||||||
use windows::Win32::Foundation::HWND;
|
use windows::Win32::Foundation::HWND;
|
||||||
use windows::Win32::UI::WindowsAndMessaging::ShowWindow;
|
use windows::Win32::UI::WindowsAndMessaging::ShowWindow;
|
||||||
@@ -2539,16 +2543,31 @@ Stop-Process -Name:komorebi -ErrorAction SilentlyContinue
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
SubCommand::ApplicationSpecificConfigurationSchema => {
|
SubCommand::ApplicationSpecificConfigurationSchema => {
|
||||||
print_query(&SocketMessage::ApplicationSpecificConfigurationSchema);
|
let asc = schema_for!(Vec<ApplicationConfiguration>);
|
||||||
|
let schema = serde_json::to_string_pretty(&asc)?;
|
||||||
|
println!("{schema}");
|
||||||
}
|
}
|
||||||
SubCommand::NotificationSchema => {
|
SubCommand::NotificationSchema => {
|
||||||
print_query(&SocketMessage::NotificationSchema);
|
let notification = schema_for!(Notification);
|
||||||
|
let schema = serde_json::to_string_pretty(¬ification)?;
|
||||||
|
println!("{schema}");
|
||||||
}
|
}
|
||||||
SubCommand::SocketSchema => {
|
SubCommand::SocketSchema => {
|
||||||
print_query(&SocketMessage::SocketSchema);
|
let socket_message = schema_for!(SocketMessage);
|
||||||
|
let schema = serde_json::to_string_pretty(&socket_message)?;
|
||||||
|
println!("{schema}");
|
||||||
}
|
}
|
||||||
SubCommand::StaticConfigSchema => {
|
SubCommand::StaticConfigSchema => {
|
||||||
print_query(&SocketMessage::StaticConfigSchema);
|
let settings = SchemaSettings::default().with(|s| {
|
||||||
|
s.option_nullable = false;
|
||||||
|
s.option_add_null_type = false;
|
||||||
|
s.inline_subschemas = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let gen = settings.into_generator();
|
||||||
|
let socket_message = gen.into_root_schema_for::<StaticConfig>();
|
||||||
|
let schema = serde_json::to_string_pretty(&socket_message)?;
|
||||||
|
println!("{schema}");
|
||||||
}
|
}
|
||||||
SubCommand::GenerateStaticConfig => {
|
SubCommand::GenerateStaticConfig => {
|
||||||
print_query(&SocketMessage::GenerateStaticConfig);
|
print_query(&SocketMessage::GenerateStaticConfig);
|
||||||
|
|||||||
+18
-32
@@ -19,7 +19,7 @@
|
|||||||
"null"
|
"null"
|
||||||
],
|
],
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/IdWithIdentifierAndComment"
|
"$ref": "#/definitions/MatchingRule"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"identifier": {
|
"identifier": {
|
||||||
@@ -53,9 +53,9 @@
|
|||||||
"enum": [
|
"enum": [
|
||||||
"object_name_change",
|
"object_name_change",
|
||||||
"layered",
|
"layered",
|
||||||
"border_overflow",
|
|
||||||
"tray_and_multi_window",
|
"tray_and_multi_window",
|
||||||
"force"
|
"force",
|
||||||
|
"border_overflow"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"IdWithIdentifier": {
|
"IdWithIdentifier": {
|
||||||
@@ -83,36 +83,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"IdWithIdentifierAndComment": {
|
"MatchingRule": {
|
||||||
"type": "object",
|
"anyOf": [
|
||||||
"required": [
|
{
|
||||||
"id",
|
"$ref": "#/definitions/IdWithIdentifier"
|
||||||
"kind"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"comment": {
|
|
||||||
"type": [
|
|
||||||
"string",
|
|
||||||
"null"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"id": {
|
{
|
||||||
"type": "string"
|
"type": "array",
|
||||||
},
|
"items": {
|
||||||
"kind": {
|
"$ref": "#/definitions/IdWithIdentifier"
|
||||||
"$ref": "#/definitions/ApplicationIdentifier"
|
}
|
||||||
},
|
|
||||||
"matching_strategy": {
|
|
||||||
"anyOf": [
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/MatchingStrategy"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "null"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"MatchingStrategy": {
|
"MatchingStrategy": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -122,7 +104,11 @@
|
|||||||
"StartsWith",
|
"StartsWith",
|
||||||
"EndsWith",
|
"EndsWith",
|
||||||
"Contains",
|
"Contains",
|
||||||
"Regex"
|
"Regex",
|
||||||
|
"DoesNotEndWith",
|
||||||
|
"DoesNotStartWith",
|
||||||
|
"DoesNotEqual",
|
||||||
|
"DoesNotContain"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user