mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-05-07 03:13:31 +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:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2766,6 +2766,7 @@ dependencies = [
|
||||
"paste",
|
||||
"powershell_script",
|
||||
"reqwest",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json_lenient",
|
||||
"serde_yaml 0.9.34+deprecated",
|
||||
|
||||
2
justfile
2
justfile
@@ -45,4 +45,6 @@ docgen:
|
||||
|
||||
schemagen:
|
||||
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\
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
pub use komorebi::colour::Colour;
|
||||
pub use komorebi::colour::Rgb;
|
||||
pub use komorebi::config_generation::ApplicationConfiguration;
|
||||
pub use komorebi::container::Container;
|
||||
pub use komorebi::core::config_generation::ApplicationConfigurationGenerator;
|
||||
pub use komorebi::core::resolve_home_path;
|
||||
|
||||
@@ -34,6 +34,7 @@ which = "6"
|
||||
win32-display-data = { workspace = true }
|
||||
windows = { workspace = true }
|
||||
shadow-rs = { workspace = true }
|
||||
schemars = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
reqwest = { version = "0.12", features = ["blocking"] }
|
||||
|
||||
@@ -25,12 +25,16 @@ use fs_tail::TailedFile;
|
||||
use komorebi_client::resolve_home_path;
|
||||
use komorebi_client::send_message;
|
||||
use komorebi_client::send_query;
|
||||
use komorebi_client::ApplicationConfiguration;
|
||||
use komorebi_client::Notification;
|
||||
use lazy_static::lazy_static;
|
||||
use miette::NamedSource;
|
||||
use miette::Report;
|
||||
use miette::SourceOffset;
|
||||
use miette::SourceSpan;
|
||||
use paste::paste;
|
||||
use schemars::gen::SchemaSettings;
|
||||
use schemars::schema_for;
|
||||
use which::which;
|
||||
use windows::Win32::Foundation::HWND;
|
||||
use windows::Win32::UI::WindowsAndMessaging::ShowWindow;
|
||||
@@ -2539,16 +2543,31 @@ Stop-Process -Name:komorebi -ErrorAction SilentlyContinue
|
||||
);
|
||||
}
|
||||
SubCommand::ApplicationSpecificConfigurationSchema => {
|
||||
print_query(&SocketMessage::ApplicationSpecificConfigurationSchema);
|
||||
let asc = schema_for!(Vec<ApplicationConfiguration>);
|
||||
let schema = serde_json::to_string_pretty(&asc)?;
|
||||
println!("{schema}");
|
||||
}
|
||||
SubCommand::NotificationSchema => {
|
||||
print_query(&SocketMessage::NotificationSchema);
|
||||
let notification = schema_for!(Notification);
|
||||
let schema = serde_json::to_string_pretty(¬ification)?;
|
||||
println!("{schema}");
|
||||
}
|
||||
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 => {
|
||||
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 => {
|
||||
print_query(&SocketMessage::GenerateStaticConfig);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"null"
|
||||
],
|
||||
"items": {
|
||||
"$ref": "#/definitions/IdWithIdentifierAndComment"
|
||||
"$ref": "#/definitions/MatchingRule"
|
||||
}
|
||||
},
|
||||
"identifier": {
|
||||
@@ -53,9 +53,9 @@
|
||||
"enum": [
|
||||
"object_name_change",
|
||||
"layered",
|
||||
"border_overflow",
|
||||
"tray_and_multi_window",
|
||||
"force"
|
||||
"force",
|
||||
"border_overflow"
|
||||
]
|
||||
},
|
||||
"IdWithIdentifier": {
|
||||
@@ -83,36 +83,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"IdWithIdentifierAndComment": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id",
|
||||
"kind"
|
||||
],
|
||||
"properties": {
|
||||
"comment": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
"MatchingRule": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/IdWithIdentifier"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"$ref": "#/definitions/ApplicationIdentifier"
|
||||
},
|
||||
"matching_strategy": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/MatchingStrategy"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/IdWithIdentifier"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"MatchingStrategy": {
|
||||
"type": "string",
|
||||
@@ -122,7 +104,11 @@
|
||||
"StartsWith",
|
||||
"EndsWith",
|
||||
"Contains",
|
||||
"Regex"
|
||||
"Regex",
|
||||
"DoesNotEndWith",
|
||||
"DoesNotStartWith",
|
||||
"DoesNotEqual",
|
||||
"DoesNotContain"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user