Skip to content

Commit

Permalink
fix: move schema generation to a separate crate
Browse files Browse the repository at this point in the history
  • Loading branch information
amr-crabnebula committed Oct 4, 2023
1 parent 95e8e68 commit 6bb7c65
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 54 deletions.
1 change: 0 additions & 1 deletion .changes/inital-release.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
"cargo-packager": "patch"
"cargo-packager-config": "minor"
---

Initial Release
12 changes: 10 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions crates/config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[package]
name = "cargo-packager-config"
version = "0.0.0"
version = "0.1.0"
description = "Config types for cargo-packager."
authors = [
"CrabNebula Ltd.",
"Tauri Programme within The Commons Conservancy",
"George Burton <[email protected]>",
"CrabNebula Ltd.",
"Tauri Programme within The Commons Conservancy",
"George Burton <[email protected]>"
]
edition = "2021"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/crabnebula-dev/cargo-packager"

[features]
clap = ["dep:clap"]
clap = [ "dep:clap" ]

[dependencies]
serde.workspace = true
schemars.workspace = true
serde = { workspace = true }
schemars = { workspace = true }
clap = { workspace = true, optional = true }
strsim = "0.10"
2 changes: 1 addition & 1 deletion crates/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
}
},
"desktopTemplate": {
"description": "Path to a custom desktop file Handlebars template.\n\nAvailable variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.\n\nDefault file contents: ```text ```",
"description": "Path to a custom desktop file Handlebars template.\n\nAvailable variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.\n\nDefault file contents: ```text [Desktop Entry] Categories={{categories}} {{#if comment}} Comment={{comment}} {{/if}} Exec={{exec}} Icon={{icon}} Name={{name}} Terminal=false Type=Application {{#if mime_type}} MimeType={{mime_type}} {{/if}} ```",
"type": [
"string",
"null"
Expand Down
14 changes: 13 additions & 1 deletion crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,19 @@ pub struct DebianConfig {
///
/// Default file contents:
/// ```text
#[doc = include_str!("../../packager/src/package/deb/main.desktop")]
/// [Desktop Entry]
/// Categories={{categories}}
/// {{#if comment}}
/// Comment={{comment}}
/// {{/if}}
/// Exec={{exec}}
/// Icon={{icon}}
/// Name={{name}}
/// Terminal=false
/// Type=Application
/// {{#if mime_type}}
/// MimeType={{mime_type}}
/// {{/if}}
/// ```
#[serde(alias = "desktop-template", alias = "desktop_template")]
pub desktop_template: Option<PathBuf>,
Expand Down
12 changes: 12 additions & 0 deletions crates/config_schema_generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "cargo-packager-config-schema-generator"
version = "0.0.0"
publish = false
edition = "2021"
authors = ["CrabNebula Ltd."]
license = "Apache-2.0 OR MIT"

[build-dependencies]
cargo-packager-config = { path = "../config", version = "0.1.0" }
serde_json = { workspace = true }
schemars = { workspace = true }
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
let schema = schemars::schema_for!(cargo_packager_config::Config);
let schema_str = serde_json::to_string_pretty(&schema).unwrap();
let crate_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
for file in ["schema.json", "../config/schema.json"] {
for file in ["../packager/schema.json", "../config/schema.json"] {
let mut schema_file = BufWriter::new(File::create(crate_dir.join(file))?);
write!(schema_file, "{schema_str}")?;
}
Expand Down
5 changes: 5 additions & 0 deletions crates/config_schema_generator/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2023-2023 CrabNebula Ltd.
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

fn main() {}
81 changes: 41 additions & 40 deletions crates/packager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,60 @@ name = "cargo-packager"
version = "0.1.0"
description = "Rust executable packager and bundler CLI and library."
authors = [
"CrabNebula Ltd.",
"Tauri Programme within The Commons Conservancy",
"George Burton <[email protected]>",
"CrabNebula Ltd.",
"Tauri Programme within The Commons Conservancy",
"George Burton <[email protected]>"
]
edition = "2021"
license = "Apache-2.0 OR MIT"
keywords = ["bundle", "package", "cargo"]
keywords = [ "bundle", "package", "cargo" ]
categories = [
"command-line-interface",
"command-line-utilities",
"development-tools::cargo-plugins",
"development-tools::build-utils",
"os",
"command-line-interface",
"command-line-utilities",
"development-tools::cargo-plugins",
"development-tools::build-utils",
"os"
]
repository = "https://github.com/crabnebula-dev/cargo-packager"

[features]
default = ["cli"]
cli = ["clap", "cargo-packager-config/clap", "tracing", "tracing-subscriber"]
tracing = ["dep:tracing"]

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "doc_cfg"]
rustdoc-args = [ "--cfg", "doc_cfg" ]
default-target = "x86_64-unknown-linux-gnu"
targets = [
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin"
]

[build-dependencies]
cargo-packager-config = { path = "../config", version = "0.0.0" }
serde_json.workspace = true
schemars.workspace = true
[features]
default = [ "cli" ]
cli = [
"clap",
"cargo-packager-config/clap",
"tracing",
"tracing-subscriber"
]
tracing = [ "dep:tracing" ]

[dependencies]
cargo-packager-config = { path = "../config", version = "0.0.0" }
thiserror.workspace = true
serde.workspace = true
serde_json.workspace = true
dunce.workspace = true
dirs.workspace = true
semver.workspace = true
base64.workspace = true
clap = { workspace = true, optional = true, features = ["env"] }
cargo-packager-config = { path = "../config", version = "0.1.0" }
thiserror = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
dunce = { workspace = true }
dirs = { workspace = true }
semver = { workspace = true }
base64 = { workspace = true }
clap = { workspace = true, optional = true, features = [ "env" ] }
tracing = { workspace = true, optional = true }
tracing-subscriber = { version = "0.3", optional = true, features = [
"env-filter",
] }
tracing-subscriber = { version = "0.3", optional = true, features = [ "env-filter" ] }
toml = "0.8"
cargo_metadata = "0.18"
ureq = "2.8"
hex = "0.4"
sha1 = "0.10"
sha2 = "0.10"
zip = { version = "0.6", default-features = false, features = ["deflate"] }
zip = { version = "0.6", default-features = false, features = [ "deflate" ] }
handlebars = "4.4"
glob = "0.3"
relative-path = "1.9"
Expand All @@ -71,12 +69,15 @@ libflate = "2.0"
[target."cfg(target_os = \"windows\")".dependencies]
winreg = "0.51"
once_cell = "1.18"
uuid = { version = "1", features = ["v4", "v5"] }
uuid = { version = "1", features = [ "v4", "v5" ] }
regex = "1.9"

[target."cfg(target_os = \"windows\")".dependencies.windows-sys]
version = "0.48"
features = ["Win32_System_SystemInformation", "Win32_System_Diagnostics_Debug"]
[target."cfg(target_os = \"windows\")".dependencies.windows-sys]
version = "0.48"
features = [
"Win32_System_SystemInformation",
"Win32_System_Diagnostics_Debug"
]

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"netbsd\", target_os = \"openbsd\"))".dependencies]
image = "0.24"
Expand All @@ -86,7 +87,7 @@ ar = "0.9"

[target."cfg(target_os = \"macos\")".dependencies]
icns = { package = "tauri-icns", version = "0.1" }
time = { version = "0.3", features = ["formatting"] }
time = { version = "0.3", features = [ "formatting" ] }
plist = "1"
image = "0.24"
tempfile = "3"
2 changes: 1 addition & 1 deletion crates/packager/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
}
},
"desktopTemplate": {
"description": "Path to a custom desktop file Handlebars template.\n\nAvailable variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.\n\nDefault file contents: ```text ```",
"description": "Path to a custom desktop file Handlebars template.\n\nAvailable variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.\n\nDefault file contents: ```text [Desktop Entry] Categories={{categories}} {{#if comment}} Comment={{comment}} {{/if}} Exec={{exec}} Icon={{icon}} Name={{name}} Terminal=false Type=Application {{#if mime_type}} MimeType={{mime_type}} {{/if}} ```",
"type": [
"string",
"null"
Expand Down

0 comments on commit 6bb7c65

Please sign in to comment.