Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

Commit 0226c6c

Browse files
committed
Replace nwg with azul
1 parent 8708eb1 commit 0226c6c

File tree

11 files changed

+2069
-719
lines changed

11 files changed

+2069
-719
lines changed

Cargo.lock

Lines changed: 1861 additions & 496 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "lore-seeker"
3-
version = "0.0.2"
3+
version = "0.0.3"
44
authors = ["Fenhl <fenhl@fenhl.net>"]
5+
edition = "2018"
56

67
[lib]
78
name = "lore_seeker_desktop"
@@ -10,31 +11,27 @@ path = "src/lib.rs"
1011
[[bin]]
1112
name = "install-cockatrice"
1213
path = "src/bin/install-cockatrice.rs"
13-
doc = false
1414
test = false
1515
bench = false
1616

1717
[[bin]]
18-
name = "lore-seeker-windows"
18+
name = "lore-seeker-desktop"
1919
path = "src/main.rs"
20-
doc = false
2120
test = false
2221
bench = false
2322

2423
[[bin]]
2524
name = "lore-seeker-release"
2625
path = "src/bin/release.rs"
27-
doc = false
2826
test = false
2927
bench = false
3028

31-
[build-dependencies]
29+
[target.'cfg(windows)'.build-dependencies]
3230
winres = "0.1"
3331

3432
[dependencies]
3533
cargo_metadata = "*"
3634
itertools = "*"
37-
native-windows-gui = "0.2.0"
3835
open = "*"
3936
reqwest = "*"
4037
semver = "*"
@@ -44,3 +41,6 @@ serde_json = "1.0"
4441
tempfile = "*"
4542
urlencoding = "*"
4643
wrapped_enum = "*"
44+
45+
[dependencies.azul]
46+
git = "https://github.com/maps4print/azul"

build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate winres;
2-
31
use std::{
42
fs::File,
53
io::{
@@ -8,6 +6,7 @@ use std::{
86
},
97
process::Command
108
};
9+
#[cfg(windows)]
1110
use winres::WindowsResource;
1211

1312
/// Modified from <https://stackoverflow.com/questions/43753491/include-git-commit-hash-as-string-into-rust-program>

src/bin/install-cockatrice.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#![deny(unused, unused_qualifications)]
33
#![forbid(unused_import_braces)]
44

5-
extern crate lore_seeker_desktop;
6-
75
use lore_seeker_desktop::trice;
86

97
fn main() -> Result<(), trice::Error> {

src/bin/release.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
#![deny(unused, unused_qualifications)]
33
#![forbid(unused_import_braces)]
44

5-
extern crate cargo_metadata;
6-
extern crate lore_seeker_desktop;
7-
extern crate reqwest;
8-
extern crate semver;
9-
extern crate tempfile;
105
#[macro_use] extern crate wrapped_enum;
116

127
use std::{
@@ -23,10 +18,7 @@ use semver::{
2318
Version
2419
};
2520
use lore_seeker_desktop::{
26-
github::{
27-
self,
28-
Repo
29-
},
21+
github::Repo,
3022
util
3123
};
3224

@@ -42,7 +34,6 @@ wrapped_enum! {
4234
#[derive(Debug)]
4335
enum Error {
4436
Cargo(cargo_metadata::Error),
45-
GitHub(github::Error),
4637
Io(io::Error),
4738
Other(OtherError),
4839
ReleaseClient(util::ReleaseClientError),
@@ -55,15 +46,16 @@ fn main() -> Result<(), Error> {
5546
//TODO make sure working dir is clean and on master and up to date with remote and remote is up to date. Alternatively, make sure we're on gitdir master and up to date
5647
let repo = Repo::new("fenhl", "lore-seeker-desktop");
5748
let client = util::release_client()?;
58-
let local_version = cargo_metadata::metadata(None)?.packages.first().ok_or(OtherError::MissingPackage)?.version.parse::<Version>()?;
49+
let metadata = cargo_metadata::MetadataCommand::default().exec()?;
50+
let local_version = &metadata.packages.first().ok_or(OtherError::MissingPackage)?.version;
5951
let remote_version = repo.latest_release(&client)?.tag_name[1..].parse::<Version>()?;
6052
match local_version.cmp(&remote_version) {
6153
Less => { return Err(OtherError::VersionRegression.into()); }
6254
Equal => { return Err(OtherError::SameVersion.into()); }
63-
Greater => ()
55+
Greater => {}
6456
}
65-
if !Command::new("cargo").arg("build").arg("--bin=lore-seeker-windows").arg("--release").status()?.success() { return Err(OtherError::Command.into()); }
66-
if !Command::new("cargo").arg("+stable-i686-pc-windows-msvc").arg("build").arg("--bin=lore-seeker-windows").arg("--release").arg("--target-dir=target-x86").status()?.success() { return Err(OtherError::Command.into()); }
57+
if !Command::new("cargo").arg("build").arg("--bin=lore-seeker-desktop").arg("--release").status()?.success() { return Err(OtherError::Command.into()); }
58+
if !Command::new("cargo").arg("+stable-i686-pc-windows-msvc").arg("build").arg("--bin=lore-seeker-desktop").arg("--release").arg("--target-dir=target-x86").status()?.success() { return Err(OtherError::Command.into()); }
6759
let release_notes = {
6860
let mut release_notes_file = tempfile::Builder::new()
6961
.prefix("lore-seeker-desktop-release-notes")
@@ -75,8 +67,8 @@ fn main() -> Result<(), Error> {
7567
buf
7668
};
7769
let release = repo.create_release(&client, format!("Lore Seeker Desktop {}", local_version), format!("v{}", local_version), release_notes)?;
78-
repo.release_attach(&client, &release, "lore-seeker-windows-64bit.exe", "application/vnd.microsoft.portable-executable", File::open("target/release/lore-seeker-windows.exe")?)?;
79-
repo.release_attach(&client, &release, "lore-seeker-windows-32bit.exe", "application/vnd.microsoft.portable-executable", File::open("target-x86/release/lore-seeker-windows.exe")?)?;
70+
repo.release_attach(&client, &release, "lore-seeker-windows-64bit.exe", "application/vnd.microsoft.portable-executable", File::open("target/release/lore-seeker-desktop.exe")?)?;
71+
repo.release_attach(&client, &release, "lore-seeker-windows-32bit.exe", "application/vnd.microsoft.portable-executable", File::open("target-x86/release/lore-seeker-desktop.exe")?)?;
8072
repo.publish_release(&client, release)?;
8173
Ok(())
8274
}

src/github.rs

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,8 @@
22
33
#![allow(missing_docs)] //TODO
44

5-
use std::fmt;
6-
use reqwest;
7-
8-
/// An error that can occur in the GitHub API.
9-
#[derive(Debug)]
10-
pub enum Error {
11-
/// An error occurred in the `reqwest` crate.
12-
Reqwest(reqwest::Error),
13-
/// The latest release's tag name is not listed in the repo's tags.
14-
TagNotFound
15-
}
16-
17-
impl From<reqwest::Error> for Error {
18-
fn from(e: reqwest::Error) -> Error {
19-
Error::Reqwest(e)
20-
}
21-
}
22-
23-
impl fmt::Display for Error {
24-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
25-
match *self {
26-
Error::Reqwest(ref e) => e.fmt(f),
27-
Error::TagNotFound => write!(f, "Release tag not found.")
28-
}
29-
}
30-
}
5+
use serde_derive::Deserialize;
6+
use serde_json::json;
317

328
#[derive(Deserialize)]
339
pub struct Release {
@@ -72,7 +48,7 @@ impl Repo {
7248
}
7349
}
7450

75-
pub fn latest_release(&self, client: &reqwest::Client) -> Result<Release, Error> {
51+
pub fn latest_release(&self, client: &reqwest::Client) -> Result<Release, reqwest::Error> {
7652
Ok(
7753
client.get(&format!("https://api.github.com/repos/{}/{}/releases/latest", self.user, self.name))
7854
.send()?
@@ -82,7 +58,7 @@ impl Repo {
8258
}
8359

8460
/// Creates a draft release, which can be published using `Repo::publish_release`.
85-
pub fn create_release(&self, client: &reqwest::Client, name: String, tag_name: String, body: String) -> Result<Release, Error> {
61+
pub fn create_release(&self, client: &reqwest::Client, name: String, tag_name: String, body: String) -> Result<Release, reqwest::Error> {
8662
Ok(
8763
client.post(&format!("https://api.github.com/repos/{}/{}/releases", self.user, self.name))
8864
.json(&json!({
@@ -97,7 +73,7 @@ impl Repo {
9773
)
9874
}
9975

100-
pub fn publish_release(&self, client: &reqwest::Client, release: Release) -> Result<Release, Error> {
76+
pub fn publish_release(&self, client: &reqwest::Client, release: Release) -> Result<Release, reqwest::Error> {
10177
Ok(
10278
client.patch(&format!("https://api.github.com/repos/{}/{}/releases/{}", self.user, self.name, release.id))
10379
.json(&json!({"draft": false}))
@@ -107,7 +83,7 @@ impl Repo {
10783
)
10884
}
10985

110-
pub fn release_attach(&self, client: &reqwest::Client, release: &Release, name: &str, content_type: &'static str, body: impl Into<reqwest::Body>) -> Result<ReleaseAsset, Error> {
86+
pub fn release_attach(&self, client: &reqwest::Client, release: &Release, name: &str, content_type: &'static str, body: impl Into<reqwest::Body>) -> Result<ReleaseAsset, reqwest::Error> {
11187
let mut headers = reqwest::header::HeaderMap::new();
11288
headers.insert(reqwest::header::CONTENT_TYPE, reqwest::header::HeaderValue::from_static(content_type));
11389
Ok(
@@ -121,7 +97,7 @@ impl Repo {
12197
)
12298
}
12399

124-
pub fn tags(&self, client: &reqwest::Client) -> Result<Vec<Tag>, Error> {
100+
pub fn tags(&self, client: &reqwest::Client) -> Result<Vec<Tag>, reqwest::Error> {
125101
Ok(
126102
client.get(&format!("https://api.github.com/repos/{}/{}/tags", self.user, self.name))
127103
.send()?

src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
#![deny(missing_docs, unused, unused_qualifications)]
66
#![forbid(unused_import_braces)]
77

8-
extern crate itertools;
9-
#[cfg(windows)] extern crate native_windows_gui as nwg;
10-
extern crate reqwest;
11-
#[macro_use] extern crate serde_derive;
12-
#[macro_use] extern crate serde_json;
13-
extern crate tempfile;
14-
#[macro_use] extern crate wrapped_enum;
15-
168
pub mod github;
179
pub mod trice;
1810
pub mod update;

0 commit comments

Comments
 (0)