diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e9b7e73..db203ad 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,11 +12,11 @@ jobs: matrix: include: - target: x86_64-pc-windows-gnu - name: oxup.exe + name: oxate.exe - target: x86_64-unknown-linux-musl - name: oxup + name: oxate - target: x86_64-apple-darwin - name: oxup-darwin + name: oxate-darwin steps: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 diff --git a/.version b/.version deleted file mode 100644 index bd4053b..0000000 --- a/.version +++ /dev/null @@ -1 +0,0 @@ -2.6.3 \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 768ed0f..4f759d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -237,7 +237,7 @@ dependencies = [ "http", "indexmap", "slab", - "tokio 0.2.25", + "tokio", "tokio-util", "tracing", "tracing-futures", @@ -315,7 +315,7 @@ dependencies = [ "itoa 0.4.8", "pin-project", "socket2", - "tokio 0.2.25", + "tokio", "tower-service", "tracing", "want", @@ -330,7 +330,7 @@ dependencies = [ "bytes 0.5.6", "hyper", "native-tls", - "tokio 0.2.25", + "tokio", "tokio-tls", ] @@ -570,14 +570,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" [[package]] -name = "oxup" -version = "2.6.3" +name = "oxate" +version = "2.7.0" dependencies = [ "clap", "reqwest", "serde", "serde_json", - "tokio 1.18.5", + "tokio", ] [[package]] @@ -717,7 +717,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "tokio 0.2.25", + "tokio", "tokio-tls", "url", "wasm-bindgen", @@ -898,23 +898,14 @@ dependencies = [ "mio", "pin-project-lite 0.1.12", "slab", -] - -[[package]] -name = "tokio" -version = "1.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e050c618355082ae5a89ec63bbf897225d5ffe84c7c4e036874e4d185a5044e" -dependencies = [ - "pin-project-lite 0.2.9", "tokio-macros", ] [[package]] name = "tokio-macros" -version = "1.8.2" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" dependencies = [ "proc-macro2", "quote", @@ -928,7 +919,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" dependencies = [ "native-tls", - "tokio 0.2.25", + "tokio", ] [[package]] @@ -942,7 +933,7 @@ dependencies = [ "futures-sink", "log", "pin-project-lite 0.1.12", - "tokio 0.2.25", + "tokio", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3d9e515..ee0a6f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "oxup" -version = "2.6.3" +name = "oxate" +version = "2.7.0" edition = "2021" [profile.release] @@ -13,4 +13,4 @@ clap = { version = "4.0.9", features = ["derive"] } reqwest = { version = "0.10", features = ["json"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -tokio = { version = "1.18", features = ["macros"] } +tokio = { version = "0.2.25", features = ["macros"] } diff --git a/README.md b/README.md index 1afd25a..4738e76 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Oxup +# Oxate -Oxup is a tool for managing installations and packages of oxido. +Oxate is a tool for managing installations and packages of oxido. ## Installation @@ -13,7 +13,7 @@ Then you can restart your shell and install oxido. ## Usage ```bash -oxup [OPTIONS] +oxate [OPTIONS] ``` | Command | Description | diff --git a/install.sh b/install.sh index e67e42c..8bde025 100755 --- a/install.sh +++ b/install.sh @@ -1,25 +1,20 @@ BLUE='\033[0;34m' NONE='\033[0m' PREFIX="${BLUE}=>${NONE} " -echo -e "${PREFIX}Downloading oxup" +echo -e "${PREFIX}Downloading oxate" if [[ "$OSTYPE" == "linux-gnu"* ]]; then - curl -LO https://github.com/oxidic/oxup/releases/latest/download/oxup - chmod +x oxup - ./oxup setup -n + curl -LO https://github.com/oxidic/oxate/releases/latest/download/oxate + chmod +x oxate + ./oxate setup elif [[ "$OSTYPE" == "darwin"* ]]; then - curl -LO https://github.com/oxidic/oxup/releases/latest/download/oxup-darwin - chmod +x oxup-darwin - ./oxup-darwin setup -n + curl -LO https://github.com/oxidic/oxate/releases/latest/download/oxate-darwin + chmod +x oxate-darwin + ./oxate-darwin setup else - curl -LO https://github.com/oxidic/oxup/releases/latest/download/oxup.exe - ./oxup.exe setup -n + curl -LO https://github.com/oxidic/oxate/releases/latest/download/oxate.exe + ./oxate.exe setup fi -if [[ $SHELL == *bash ]]; then - echo '. "$HOME/.oxido/env"' >> $HOME/.bashrc -elif [[ $SHELL == *zsh ]]; then - echo '. "$HOME/.oxido/env"' >> $HOME/.zshrc -else - echo -e "${PREFIX}Add the following lines to your shell configuration to add oxup to PATH: \`. \"$HOME/.oxido/env\"\`" -fi +echo -e "${PREFIX}Add the following lines to your shell configuration to add oxate to PATH: \`. \"$HOME/.oxido/env\"\`" + diff --git a/src/init.rs b/src/init.rs index 7aa3c8d..d6fd87c 100644 --- a/src/init.rs +++ b/src/init.rs @@ -3,20 +3,17 @@ use std::fs::{create_dir_all, write}; use crate::success; pub fn init(name: String) { - let default_function = "fn main() { - print(\"Hello world!\"); -} -"; + let default_function = "println(\"Hello world!\");"; let metadata = format!( "[package] -name = {name} -version = 0.1.0 +name = \"{name}\" +version = \"0.1.0\" " ); create_dir_all(format!("{name}/src")).unwrap(); - write(format!("{name}/src/main.ox"), default_function).unwrap(); - write(format!("{name}/Oxup.toml"), metadata).unwrap(); + write(format!("{name}/src/main.oxi"), default_function).unwrap(); + write(format!("{name}/Oxate.toml"), metadata).unwrap(); success![format!("Successfully initialised {name}!")] } diff --git a/src/install.rs b/src/install.rs index 4be7b1f..d39c816 100644 --- a/src/install.rs +++ b/src/install.rs @@ -1,5 +1,4 @@ -use std::os::unix::prelude::PermissionsExt; - +use std::{os::unix::prelude::PermissionsExt, env::var, fs::{write, set_permissions, Permissions}}; use crate::{info, success}; use reqwest::{ header::{HeaderMap, USER_AGENT}, @@ -19,12 +18,12 @@ pub struct ReleaseData { assets: Vec, } -pub async fn install(os: OS, oxup: bool) -> Result<(), Box> { +pub async fn install(os: OS, oxate: bool) -> Result<(), Box> { let mut headers = HeaderMap::new(); headers.insert(USER_AGENT, "megatank58".parse().unwrap()); - let target = if oxup { - "https://api.github.com/repos/oxidic/oxup/releases/latest" + let target = if oxate { + "https://api.github.com/repos/oxidic/oxate/releases/latest" } else { "https://api.github.com/repositories/500013933/releases/latest" }; @@ -32,8 +31,8 @@ pub async fn install(os: OS, oxup: bool) -> Result<(), Box bin.to_owned() + "darwin", @@ -55,7 +54,7 @@ pub async fn install(os: OS, oxup: bool) -> Result<(), Box format!(r"C:\bin\{bin}.exe"), _ => { @@ -66,9 +65,9 @@ pub async fn install(os: OS, oxup: bool) -> Result<(), Box Result<(), Box> { - let args = Oxup::parse(); + let args = Oxate::parse(); - let mut os = OS::from(); - if args.linux { - os = OS::Linux; - } else if args.macos { - os = OS::Mac; - } else if args.windows { - os = OS::Windows; - } + let os = OS::from(); match args.command { Commands::Install => { install::install(os, false).await?; } - Commands::Init { file } => init::init(file), + Commands::Init { name } => init::init(name), Commands::Uninstall => { uninstall::uninstall(os); } @@ -86,17 +62,6 @@ async fn main() -> Result<(), Box> { Commands::Update { update } => update::update(update, os).await?, } - let current_version = env!("CARGO_PKG_VERSION"); - - let new_version = reqwest::get("https://raw.githubusercontent.com/oxidic/oxup/main/.version") - .await? - .text() - .await?; - - if !args.no_update && current_version != new_version { - info![format!("Oxup v{new_version} is avaliable for download.")]; - } - Ok(()) } @@ -113,6 +78,7 @@ mod macros { macro_rules! error { ($message:expr) => { println!("{} {}", "\x1b[1m\x1b[31merror:\x1b[0m", $message) + std::process::exit(1); }; } diff --git a/src/setup.rs b/src/setup.rs index c501a50..4d474f1 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -1,6 +1,10 @@ use crate::{info, os::OS, success}; -use std::fs::{copy, create_dir_all, metadata, remove_file, write}; +use std::{ + env::var, + fs::{copy, create_dir_all, metadata, remove_file, set_permissions, write, Permissions}, + os::unix::prelude::PermissionsExt, +}; pub fn setup(os: OS) { match os { @@ -10,19 +14,20 @@ pub fn setup(os: OS) { info!["Created directory C:\\bin\\oxido"]; } - copy("oxup.exe", "C:\\bin\\oxido\\oxup.exe").unwrap(); - remove_file("oxup.exe").unwrap(); + copy("oxate.exe", "C:\\bin\\oxido\\oxate.exe").unwrap(); + remove_file("oxate.exe").unwrap(); } OS::Mac | OS::Linux => { - if metadata(format!("{}/.oxido", std::env::var("HOME").unwrap())).is_err() { - create_dir_all(format!("{}/.oxido/bin", std::env::var("HOME").unwrap())).unwrap(); + let home = var("HOME").unwrap(); + if metadata(format!("{home}/.oxido")).is_err() { + create_dir_all(format!("{home}/.oxido/bin")).unwrap(); } write( - format!("{}/.oxido/env", std::env::var("HOME").unwrap()), + format!("{home}/.oxido/env"), " #!/bin/sh - # oxup shell setup + # oxate shell setup # affix colons on either side of $PATH to simplify matching case \":${PATH}:\" in *:\"$HOME/.oxido/bin\":*) @@ -36,16 +41,13 @@ pub fn setup(os: OS) { ) .unwrap(); - if metadata("./oxup").is_ok() { - copy( - "oxup", - format!("{}/.oxido/bin/oxup", std::env::var("HOME").unwrap()), - ) - .unwrap(); - remove_file("oxup").unwrap(); + if metadata("./oxate").is_ok() { + set_permissions("./oxate", Permissions::from_mode(0o770)).unwrap(); + copy("oxate", format!("{home}/.oxido/bin/oxate")).unwrap(); + remove_file("oxate").unwrap(); } - success![format!("Created {}/.oxido", std::env::var("HOME").unwrap())]; + success![format!("Created {home}/.oxido")]; } } } diff --git a/src/uninstall.rs b/src/uninstall.rs index 6cd2698..5d2ca44 100644 --- a/src/uninstall.rs +++ b/src/uninstall.rs @@ -1,16 +1,16 @@ use crate::{os::OS, success}; +use std::{ + env::var, + fs::{remove_dir_all, remove_file}, +}; pub fn uninstall(os: OS) { match os { OS::Linux | OS::Mac => { - std::fs::remove_dir_all(format!( - "{}/.oxido/bin/oxido", - std::env::var("HOME").unwrap() - )) - .unwrap(); + remove_dir_all(format!("{}/.oxido/bin/oxido", var("HOME").unwrap())).unwrap(); } OS::Windows => { - std::fs::remove_file(r"C:\bin\oxido").unwrap(); + remove_file(r"C:\bin\oxido").unwrap(); } } diff --git a/src/update.rs b/src/update.rs index 77ae99a..333c1f3 100644 --- a/src/update.rs +++ b/src/update.rs @@ -1,19 +1,20 @@ use crate::{install::install, Updateable, OS}; +use std::{env::var, error::Error, fs::remove_file}; -pub async fn update(update: Updateable, os: OS) -> Result<(), Box> { - let (bin, oxup) = match update { +pub async fn update(update: Updateable, os: OS) -> Result<(), Box> { + let (bin, oxate) = match update { Updateable::Oxido => ("oxido", false), - Updateable::Oxup => ("oxup", true), + Updateable::Oxate => ("oxate", true), }; - std::fs::remove_file(match os { + remove_file(match os { OS::Windows => format!(r"C:\bin\{bin}.exe"), _ => { - format!("{}/.oxido/bin/{bin}", std::env::var("HOME").unwrap()) + format!("{}/.oxido/bin/{bin}", var("HOME").unwrap()) } })?; - install(os, oxup).await?; + install(os, oxate).await?; Ok(()) }