From 5e8735163cb9a12127becb895acfda6dc957a027 Mon Sep 17 00:00:00 2001 From: Dervex Date: Sun, 5 May 2024 17:03:48 +0200 Subject: [PATCH] Remove unused deps, improve build script, update auth token name --- .github/workflows/ci.yml | 3 + .github/workflows/release.yml | 3 +- Cargo.lock | 150 ---------------------------------- Cargo.toml | 14 +--- build.rs | 19 ++++- src/cli/exec.rs | 4 +- src/server/stop.rs | 8 +- src/stats.rs | 4 +- 8 files changed, 30 insertions(+), 175 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e7231f..5320d1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,9 @@ on: branches: - main +env: + RUSTFLAGS: "-D warnings" + jobs: build-test: name: Build and Test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff0ee24..bcf7c77 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -113,7 +113,8 @@ jobs: - name: Build run: cargo build --all-features --release --verbose --target ${{ matrix.target }} env: - AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }} + ARGON_TOKEN: ${{ secrets.ARGON_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Archive shell: bash diff --git a/Cargo.lock b/Cargo.lock index 047139a..3da338f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -366,7 +366,6 @@ dependencies = [ "self_update", "serde", "serde_json", - "tokio", "toml", "toml2lua", "trash", @@ -1343,19 +1342,6 @@ dependencies = [ "tokio-rustls", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes 1.5.0", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "iana-time-zone" version = "0.1.60" @@ -1741,24 +1727,6 @@ dependencies = [ "serde", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nix" version = "0.10.0" @@ -1831,16 +1799,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "number_prefix" version = "0.4.0" @@ -1882,50 +1840,6 @@ dependencies = [ "pathdiff", ] -[[package]] -name = "openssl" -version = "0.10.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" -dependencies = [ - "bitflags 2.5.0", - "cfg-if 1.0.0", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.101" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "optfield" version = "0.3.0" @@ -2351,12 +2265,10 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", - "hyper-tls", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -2368,7 +2280,6 @@ dependencies = [ "sync_wrapper", "system-configuration", "tokio", - "tokio-native-tls", "tokio-rustls", "tower-service", "url", @@ -2513,15 +2424,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -2538,29 +2440,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "security-framework" -version = "2.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" -dependencies = [ - "bitflags 1.3.2", - "core-foundation 0.9.4", - "core-foundation-sys 0.8.6", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" -dependencies = [ - "core-foundation-sys 0.8.6", - "libc", -] - [[package]] name = "self-replace" version = "1.3.7" @@ -2911,36 +2790,13 @@ dependencies = [ "bytes 1.5.0", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", - "tokio-macros", "windows-sys 0.48.0", ] -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.24.1" @@ -3143,12 +2999,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 58898a7..5c4181c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,12 +27,11 @@ rbx_reflection_database = "0.2.10" config-derive = { version = "*", path = "crates/config-derive" } profiling = { version = "*", path = "crates/profiling/profiling" } -clap = { version = "4.4.1", features = ["derive", "cargo"] } serde = { version = "1.0.189", features = ["derive"] } -tokio = { version = "1.32.0", features = ["full"] } -reqwest = { version = "0.11.23", features = ["blocking", "rustls-tls"] } rmpv = {version = "1.3.0", features = ["with-serde"] } -self_update = { version = "0.39.0", features = [ +clap = { version = "4.4.1", features = ["derive", "cargo"] } +reqwest = { version = "0.11.23", default-features = false, features = ["blocking", "rustls-tls"] } +self_update = { version = "0.39.0", default-features = false, features = [ "compression-zip-deflate", "rustls", ] } @@ -85,15 +84,10 @@ winsafe = { version = "0.0.20", features = ["user"] } [build-dependencies] anyhow = "1.0.79" -self_update = { version = "0.39.0", features = [ - "compression-zip-deflate", - "rustls", -] } - +self_update = { version = "0.39.0", default-features = false, features = ["rustls"]} [patch.crates-io] notify-debouncer-full = { path = "crates/notify-debouncer-full" } self_update = { path = "crates/self_update" } - # Temporary until `InstanceBuilder::with_referent` is released rbx_dom_weak = { path = "crates/rbx_dom_weak" } diff --git a/build.rs b/build.rs index 14b4507..240cde6 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,4 @@ -use anyhow::Result; +use anyhow::{Context, Result}; use self_update::backends::github::Update; use std::{env, fs::File, path::PathBuf}; @@ -10,14 +10,25 @@ fn main() -> Result<()> { return Ok(()); } - Update::configure() + let mut builder = Update::configure(); + + if let Ok(token) = env::var("GITHUB_TOKEN") { + builder.auth_token(&token); + } else { + println!("cargo:warning=GITHUB_TOKEN not set, rate limits may apply!") + } + + builder .repo_owner("argon-rbx") .repo_name("argon-roblox") .bin_name("Argon.rbxm") .bin_install_path(out_path) - .target("") + .target(""); + + builder .build()? - .download()?; + .download() + .context("Failed to download Argon plugin from GitHub!")?; Ok(()) } diff --git a/src/cli/exec.rs b/src/cli/exec.rs index 68eb62f..686fb2f 100644 --- a/src/cli/exec.rs +++ b/src/cli/exec.rs @@ -4,7 +4,7 @@ use reqwest::{blocking::Client, header::CONTENT_TYPE}; use serde::Serialize; use std::{fs, path::MAIN_SEPARATOR}; -use crate::{argon_error, argon_info, sessions, studio}; +use crate::{argon_error, argon_info, sessions}; /// Execute Luau code in Roblox Studio (requires running session) #[derive(Parser)] @@ -71,7 +71,7 @@ impl Exec { #[cfg(target_os = "windows")] if self.focus { - studio::focus(None)?; + crate::studio::focus(None)?; } } else { argon_error!("Code execution failed: running session does not have an address"); diff --git a/src/server/stop.rs b/src/server/stop.rs index b02f012..240790b 100644 --- a/src/server/stop.rs +++ b/src/server/stop.rs @@ -4,14 +4,10 @@ use std::process; use crate::util; -async fn stop() { +#[post("/stop")] +async fn main() -> impl Responder { trace!("Stopping Argon!"); - // We need to kill all child processes as well util::kill_process(process::id()); -} -#[post("/stop")] -async fn main() -> impl Responder { - tokio::spawn(stop()); HttpResponse::Ok().body("Argon stopped successfully") } diff --git a/src/stats.rs b/src/stats.rs index ab2269e..e0c7d6e 100644 --- a/src/stats.rs +++ b/src/stats.rs @@ -113,7 +113,7 @@ pub fn track() -> Result<()> { let mut tracker = get_tracker()?; if tracker.last_synced.elapsed()?.as_secs() > 3600 && tracker.stats.total() > 10 { - if let Some(token) = option_env!("AUTH_TOKEN") { + if let Some(token) = option_env!("ARGON_TOKEN") { let stats = tracker.stats; let remainder = stats.minutes_used % 60; @@ -138,7 +138,7 @@ pub fn track() -> Result<()> { set_tracker(&tracker)?; } else { - warn!("This Argon build has no `AUTH_TOKEN` set, stats will not be uploaded") + warn!("This Argon build has no `ARGON_TOKEN` set, stats will not be uploaded") } } else { debug!("Stats already synced within the last hour or too few stats to sync");