From 4a6f0eed4917cd3610188282e8dd309c90462e36 Mon Sep 17 00:00:00 2001 From: pwnwriter Date: Tue, 21 Nov 2023 21:33:17 +0545 Subject: [PATCH] refactor(core): Fixed ascii // app name over the app --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 6 +++--- src/commands/install.rs | 4 ++-- src/commands/mod.rs | 2 +- src/commands/search.rs | 2 +- src/commands/uninstall.rs | 8 ++++---- src/engine/dirs.rs | 24 ++++++++++++------------ src/engine/essentials.rs | 2 +- src/engine/interface.rs | 11 ++++++----- src/engine/parser.rs | 4 ++-- 10 files changed, 48 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83ec1cc..41fa5b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -421,6 +421,22 @@ dependencies = [ "tokio-rustls", ] +[[package]] +name = "hysp" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "colored", + "columns", + "lazy_static", + "reqwest", + "serde", + "spinoff", + "tokio", + "toml", +] + [[package]] name = "idna" version = "0.4.0" @@ -816,22 +832,6 @@ dependencies = [ "serde", ] -[[package]] -name = "seren" -version = "0.1.0" -dependencies = [ - "anyhow", - "clap", - "colored", - "columns", - "lazy_static", - "reqwest", - "serde", - "spinoff", - "tokio", - "toml", -] - [[package]] name = "signal-hook-registry" version = "1.4.1" diff --git a/Cargo.toml b/Cargo.toml index 55122de..4bb94fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "seren" +name = "hysp" version = "0.1.0" edition = "2021" authors = [ "PwnWriter < hey@pwnwriter.xyz >" ] description = "📦 An independent package manager for the nix" readme = "README.md" -repository = "https://github.com/pwnwriter/seren" -homepage = "https://github.com/pwnwriter/seren.git" +repository = "https://github.com/pwnwriter/hysp" +homepage = "https://github.com/pwnwriter/hysp.git" license = "MIT" keywords = ["package-manager", "ctf-tool-download", "pentesting", "pkgs"] categories = ["accessibility", "web-programming", "command-line" ] diff --git a/src/commands/install.rs b/src/commands/install.rs index 03bd040..3ebad54 100644 --- a/src/commands/install.rs +++ b/src/commands/install.rs @@ -1,4 +1,4 @@ -use super::seren_helpers::RESET; +use super::hysp_helpers::RESET; use crate::engine::parser::fetch_package_info; use crate::engine::{check_conflicts, check_dependencies, InstallArgs}; use crate::engine::{dirs::*, print_package_info}; @@ -64,7 +64,7 @@ async fn download_binary(binary_url: String) -> Result<(), anyhow::Error> { .and_then(|segments| segments.last()) .unwrap_or_default(); - let file_path = SEREN_BIN_DIR.join(fname); + let file_path = HYSP_BIN_DIR.join(fname); let mut dest = File::create(&file_path)?; let content = response.bytes().await?; diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 0c52428..bc1bb97 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -2,7 +2,7 @@ pub mod install; pub mod search; pub mod uninstall; -pub mod seren_helpers { +pub mod hysp_helpers { use tokio::fs::File; use tokio::io::AsyncReadExt; diff --git a/src/commands/search.rs b/src/commands/search.rs index 2edc9a0..7d5c0d7 100644 --- a/src/commands/search.rs +++ b/src/commands/search.rs @@ -1,4 +1,4 @@ -use crate::commands::seren_helpers::{ASCII, BAR}; +use crate::commands::hysp_helpers::{ASCII, BAR}; use crate::engine::pkg_info::available_packages::Available; use crate::engine::{parser::build_package_toml_url, SearchArgs}; use anyhow::anyhow; diff --git a/src/commands/uninstall.rs b/src/commands/uninstall.rs index 47ba353..035d855 100644 --- a/src/commands/uninstall.rs +++ b/src/commands/uninstall.rs @@ -1,4 +1,4 @@ -use crate::commands::seren_helpers::read_local_file; +use crate::commands::hysp_helpers::read_local_file; use crate::engine::dirs::*; use crate::engine::essentials::print_package_info; use crate::engine::pkg_info::PackageInfo; @@ -21,7 +21,7 @@ pub async fn remove_pkgs(uninstall_pkgs: RemoveArgs) -> Result<(), anyhow::Error } pub async fn get_local_toml(pkgname: &str) -> Result { - let package_file = format!("{}/{}.toml", SEREN_DATA_DIR.to_string_lossy(), pkgname); + let package_file = format!("{}/{}.toml", HYSP_DATA_DIR.to_string_lossy(), pkgname); let toml_text = read_local_file(&package_file) .await .with_context(|| format!("Failed to read TOML file: {}", package_file))?; @@ -36,8 +36,8 @@ fn remove_binary_file(binary_name: &str) -> Result<(), anyhow::Error> { Color::Yellow, Streams::Stderr, ); - let bin_file_path = format!("{}/{}", SEREN_BIN_DIR.to_string_lossy(), binary_name); - let bin_data_file_path = format!("{}/{}.toml", SEREN_DATA_DIR.to_string_lossy(), binary_name); + let bin_file_path = format!("{}/{}", HYSP_BIN_DIR.to_string_lossy(), binary_name); + let bin_data_file_path = format!("{}/{}.toml", HYSP_DATA_DIR.to_string_lossy(), binary_name); fs::remove_file(&bin_file_path) .with_context(|| format!("Failed to remove binary file: {}", bin_file_path))?; diff --git a/src/engine/dirs.rs b/src/engine/dirs.rs index b0fd4cd..7ad4727 100644 --- a/src/engine/dirs.rs +++ b/src/engine/dirs.rs @@ -15,9 +15,9 @@ pub fn get_xdg_path(key: &str, default: &str) -> PathBuf { } lazy_static! { - pub static ref SEREN_HOME_DIR: PathBuf = get_xdg_path("SEREN_HOME_DIR", "seren"); - pub static ref SEREN_BIN_DIR: PathBuf = get_xdg_path("SEREN_BIN_DIR", "seren/bin"); - pub static ref SEREN_DATA_DIR: PathBuf = get_xdg_path("SEREN_DATA_DIR", "seren/data"); + pub static ref HYSP_HOME_DIR: PathBuf = get_xdg_path("HYSP_HOME_DIR", "hysp"); + pub static ref HYSP_BIN_DIR: PathBuf = get_xdg_path(" HYSP_BIN_DIR", "hysp/bin"); + pub static ref HYSP_DATA_DIR: PathBuf = get_xdg_path("HYSP_DATA_DIR", "hysp/data"); } #[cfg(test)] @@ -37,26 +37,26 @@ mod tests { } #[test] - fn test_seren_home_dir() { + fn test_hysp_home_dir() { assert!( - check_path(&SEREN_HOME_DIR).is_ok(), - "SEREN_HOME_DIR does not exist or is not an absolute path" + check_path(&HYSP_HOME_DIR).is_ok(), + "HYSP_HOME_DIR does not exist or is not an absolute path" ); } #[test] - fn test_seren_bin_dir() { + fn test_hysp_bin_dir() { assert!( - check_path(&SEREN_BIN_DIR).is_ok(), - "SEREN_BIN_DIR does not exist or is not an absolute path" + check_path(&HYSP_BIN_DIR).is_ok(), + "HYSP_BIN_DIR does not exist or is not an absolute path" ); } #[test] - fn test_seren_data_dir() { + fn test_hysp_data_dir() { assert!( - check_path(&SEREN_DATA_DIR).is_ok(), - "SEREN_DATA_DIR does not exist or is not an absolute path" + check_path(&HYSP_DATA_DIR).is_ok(), + "HYSP_DATA_DIR does not exist or is not an absolute path" ); } } diff --git a/src/engine/essentials.rs b/src/engine/essentials.rs index 0a4d597..f1d3f2f 100644 --- a/src/engine/essentials.rs +++ b/src/engine/essentials.rs @@ -1,6 +1,6 @@ use crate::engine::InstallArgs; use crate::{ - commands::seren_helpers::{ASCII, BAR}, + commands::hysp_helpers::{ASCII, BAR}, engine::parser::fetch_package_info, }; use anyhow::Result; diff --git a/src/engine/interface.rs b/src/engine/interface.rs index 2ccff23..ba6ec92 100644 --- a/src/engine/interface.rs +++ b/src/engine/interface.rs @@ -5,6 +5,7 @@ use colored::Colorize; pub static SPLASHES: &[&str] = &[ "There are reasons to use rust. - PwnWriter", "whatsoever a man soweth, that shall he also reap. - Dylanaraps", + "Harmonizing Your System", ]; fn generate_random_number() -> usize { @@ -23,16 +24,16 @@ pub fn show_splashes() -> String { let logo = format!( r#" + ✮ ┓┏ ✮ + ┣┫┓┏┏┏┓ + ┛┗┗┫┛┣┛ + ┛ ┛ v{} - ✮ ┏┓┏┓┳┓┏┓┳┓ ✮ - ┗┓┣ ┣┫┣ ┃┃ - ┗┛┗┛┛┗┗┛┛┗ v{} - "#, app_version, ) .bold() .purple(); - let splash = SPLASHES[rng].italic(); + let splash = SPLASHES[rng].italic().white(); format!("{logo} {splash}") } diff --git a/src/engine/parser.rs b/src/engine/parser.rs index b6e7aca..b1d4746 100644 --- a/src/engine/parser.rs +++ b/src/engine/parser.rs @@ -9,7 +9,7 @@ use std::io::prelude::*; pub fn build_package_toml_url(pkg_name: Option<&str>) -> String { let repo_url = - std::env::var("SEREN_REPO_URL").unwrap_or_else(|_| "metis-os/seren-pkgs".to_string()); + std::env::var("SEREN_REPO_URL").unwrap_or_else(|_| "metis-os/hysp-pkgs".to_string()); let available_url = format!( "https://raw.githubusercontent.com/{}/main/available.toml", @@ -48,7 +48,7 @@ pub async fn fetch_package_info(pkg_name: &str) -> Result { let parsed_toml: PackageInfo = toml::from_str(&toml_text)?; // dbg!("{}", &parsed_toml); let file_name = format!("{}.toml", pkg_name); - let data_dir = &*SEREN_DATA_DIR; + let data_dir = &*HYSP_DATA_DIR; let file_path = data_dir.join(file_name); let mut file = File::create(file_path)?;