From d06c8fdf49920cf4d8ba0487c20f5bdc851c36de Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 14 Jul 2026 16:33:01 -0400 Subject: [PATCH] Name change (#3) Reviewed-on: http://git.kundeng.us/phoenix/sienvy/pulls/3 --- .env | 4 +-- .env.sample | 4 +-- .gitea/workflows/tag_release.yml | 2 +- .gitea/workflows/workflow.yaml | 12 ++++----- Cargo.lock | 16 ++++++------ Cargo.toml | 2 +- LICENSE.md | 22 +++++++++++++++++ README.md | 1 + src/environment.rs | 8 +++--- src/keys.rs | 19 ++++++++------- tests/test.rs | 42 ++++++++++++++++---------------- 11 files changed, 78 insertions(+), 54 deletions(-) create mode 100644 LICENSE.md diff --git a/.env b/.env index e7a9a26..e7eae77 100644 --- a/.env +++ b/.env @@ -9,8 +9,8 @@ POSTGRES_MAIN_PASSWORD=password POSTGRES_MAIN_DB=my_db POSTGRES_MAIN_HOST=localhost DATABASE_URL=postgres://${POSTGRES_MAIN_USER}:${POSTGRES_MAIN_PASSWORD}@${POSTGRES_MAIN_HOST}:5432/${POSTGRES_MAIN_DB} -ICARUS_BASE_API_URL=https://icarus.com -ICARUS_AUTH_BASE_API_URL=https://auth.icarus.com +SOARICARUS_BASE_API_URL=https://soaricarus.com +SOARICARUS_AUTH_BASE_API_URL=https://auth.soaricarus.com APP_ENV=development BACKEND_PORT=8001 FRONTEND_URL=http://localhost:4200 diff --git a/.env.sample b/.env.sample index e7a9a26..e7eae77 100644 --- a/.env.sample +++ b/.env.sample @@ -9,8 +9,8 @@ POSTGRES_MAIN_PASSWORD=password POSTGRES_MAIN_DB=my_db POSTGRES_MAIN_HOST=localhost DATABASE_URL=postgres://${POSTGRES_MAIN_USER}:${POSTGRES_MAIN_PASSWORD}@${POSTGRES_MAIN_HOST}:5432/${POSTGRES_MAIN_DB} -ICARUS_BASE_API_URL=https://icarus.com -ICARUS_AUTH_BASE_API_URL=https://auth.icarus.com +SOARICARUS_BASE_API_URL=https://soaricarus.com +SOARICARUS_AUTH_BASE_API_URL=https://auth.soaricarus.com APP_ENV=development BACKEND_PORT=8001 FRONTEND_URL=http://localhost:4200 diff --git a/.gitea/workflows/tag_release.yml b/.gitea/workflows/tag_release.yml index 5e7779d..7b7e06f 100644 --- a/.gitea/workflows/tag_release.yml +++ b/.gitea/workflows/tag_release.yml @@ -20,7 +20,7 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.96.1 + toolchain: 1.97 components: cargo - uses: Swatinem/rust-cache@v2 diff --git a/.gitea/workflows/workflow.yaml b/.gitea/workflows/workflow.yaml index a768767..a44dcbe 100644 --- a/.gitea/workflows/workflow.yaml +++ b/.gitea/workflows/workflow.yaml @@ -1,4 +1,4 @@ -name: Rust Build +name: sienvy Build on: push: @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.96.1 + toolchain: 1.97 - uses: Swatinem/rust-cache@v2 - run: cargo check @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.96.1 + toolchain: 1.97 - uses: Swatinem/rust-cache@v2 - run: cargo test @@ -38,7 +38,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.96.1 + toolchain: 1.97 - run: rustup component add rustfmt - uses: Swatinem/rust-cache@v2 - run: cargo fmt --all -- --check @@ -50,7 +50,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.96.1 + toolchain: 1.97 - run: rustup component add clippy - uses: Swatinem/rust-cache@v2 - run: cargo clippy -- -D warnings @@ -62,6 +62,6 @@ jobs: - uses: actions/checkout@v6 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: 1.96.1 + toolchain: 1.97 - uses: Swatinem/rust-cache@v2 - run: cargo build diff --git a/Cargo.lock b/Cargo.lock index b3921ae..fa5c4b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,14 +29,6 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" -[[package]] -name = "icarus_envy" -version = "0.8.0" -dependencies = [ - "const_format", - "dotenvy", -] - [[package]] name = "konst" version = "0.2.20" @@ -70,6 +62,14 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "sienvy" +version = "0.8.0" +dependencies = [ + "const_format", + "dotenvy", +] + [[package]] name = "unicode-ident" version = "1.0.24" diff --git a/Cargo.toml b/Cargo.toml index 046b565..b8ca601 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "icarus_envy" +name = "sienvy" version = "0.8.0" edition = "2024" rust-version = "1.95" diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..1ba694a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +Copyright (c) 2026 Kun Deng. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 1312bd2..1788545 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +# sienvy This is a library used to retrieve environment variables associated with various icarus projects. Rather than having the various icarus projects such as icarus, icarus_auth, songparser, and others, have environment code, it would be more diff --git a/src/environment.rs b/src/environment.rs index 5d26dcb..341cc68 100644 --- a/src/environment.rs +++ b/src/environment.rs @@ -38,17 +38,17 @@ pub fn get_root_directory() -> crate::EnvVar { crate::init_envvar(key, &value) } -pub fn get_icarus_base_api_url() -> crate::EnvVar { +pub fn get_soaricarus_base_api_url() -> crate::EnvVar { dotenvy::dotenv().ok(); - let key = crate::keys::ICARUS_BASE_API_URL; + let key = crate::keys::SOARICARUS_BASE_API_URL; let value = std::env::var(key).expect(key); crate::init_envvar(key, &value) } -pub fn get_icarus_auth_base_api_url() -> crate::EnvVar { +pub fn get_soaricarus_auth_base_api_url() -> crate::EnvVar { dotenvy::dotenv().ok(); - let key = crate::keys::ICARUS_AUTH_BASE_API_URL; + let key = crate::keys::SOARICARUS_AUTH_BASE_API_URL; let value = std::env::var(key).expect(key); crate::init_envvar(key, &value) diff --git a/src/keys.rs b/src/keys.rs index e396db0..efa70ac 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -2,7 +2,7 @@ pub const DB_URL: &str = "DATABASE_URL"; /// Environment key for secret main key -/// Used for the icarus app +/// Used for the soaricarus app pub const SECRET_MAIN_KEY: &str = "SECRET_MAIN_KEY"; /// Environment key for service logins @@ -12,14 +12,14 @@ pub const SERVICE_PASSPHRASE: &str = "SERVICE_PASSPHRASE"; /// Generic use of secret key that could be found in various apps pub const SECRET_KEY: &str = "SECRET_KEY"; -/// Environment key for root directory for the icarus app +/// Environment key for root directory for the soaricarus app pub const ROOT_DIRECTORY: &str = "ROOT_DIRECTORY"; -/// Environment key for icarus api url -pub const ICARUS_BASE_API_URL: &str = "ICARUS_BASE_API_URL"; +/// Environment key for soaricarus api url +pub const SOARICARUS_BASE_API_URL: &str = "SOARICARUS_BASE_API_URL"; -/// Environment key for icarus auth api url -pub const ICARUS_AUTH_BASE_API_URL: &str = "ICARUS_AUTH_BASE_API_URL"; +/// Environment key for soaricarus auth api url +pub const SOARICARUS_AUTH_BASE_API_URL: &str = "SOARICARUS_AUTH_BASE_API_URL"; /// Environment key for App status pub const APP_ENV: &str = "APP_ENV"; @@ -41,9 +41,10 @@ pub mod error { pub const SERVICE_LOGIN: &str = concatcp!(super::SERVICE_PASSPHRASE, " ", GENERAL_ERROR); pub const SECRET_KEY: &str = concatcp!(super::SECRET_KEY, " ", GENERAL_ERROR); pub const ROOT_DIRECTORY: &str = concatcp!(super::ROOT_DIRECTORY, " ", GENERAL_ERROR); - pub const ICARUS_BASE_API_URL: &str = concatcp!(super::ICARUS_BASE_API_URL, " ", GENERAL_ERROR); - pub const ICARUS_AUTH_BASE_API_URL: &str = - concatcp!(super::ICARUS_AUTH_BASE_API_URL, " ", GENERAL_ERROR); + pub const SOARICARUS_BASE_API_URL: &str = + concatcp!(super::SOARICARUS_BASE_API_URL, " ", GENERAL_ERROR); + pub const SOARICARUS_AUTH_BASE_API_URL: &str = + concatcp!(super::SOARICARUS_AUTH_BASE_API_URL, " ", GENERAL_ERROR); pub const APP_ENV: &str = concatcp!(super::APP_ENV, " ", GENERAL_ERROR); pub const BACKEND_PORT: &str = concatcp!(super::BACKEND_PORT, " ", GENERAL_ERROR); pub const FRONTEND_URL: &str = concatcp!(super::FRONTEND_URL, " ", GENERAL_ERROR); diff --git a/tests/test.rs b/tests/test.rs index 0def6ce..5dd3552 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -2,7 +2,7 @@ mod tests { #[test] fn test_dburl() { - let result = icarus_envy::environment::get_db_url(); + let result = sienvy::environment::get_db_url(); assert_eq!( result.value, "postgres://myuser:password@localhost:5432/my_db", "DATABASE_URL does not match {:?}", @@ -12,7 +12,7 @@ mod tests { #[test] fn test_get_secret_main_key() { - let result = icarus_envy::environment::get_secret_main_key(); + let result = sienvy::environment::get_secret_main_key(); assert_eq!( result.value, "Somesupersecretpassword!!!45345435", "SECRET_MAIN_KEY does not match {:?}", @@ -22,7 +22,7 @@ mod tests { #[test] fn test_get_service_passphrase() { - let result = icarus_envy::environment::get_service_passphrase(); + let result = sienvy::environment::get_service_passphrase(); assert_eq!( result.value, "T5OCHDHadAtuOWIqRAS7u8XHDDkzKT1Uvvw7mGMkNzKjVdlHA8xGdILf2adDHspO", "SERVICE_PASSPHRASE does not match {:?}", @@ -32,7 +32,7 @@ mod tests { #[test] fn test_get_secret_key() { - let result = icarus_envy::environment::get_secret_key(); + let result = sienvy::environment::get_secret_key(); assert_eq!( result.value, "AmIGoodEnoughForYou?", "SECRET_KEY does not match {:?}", @@ -42,7 +42,7 @@ mod tests { #[test] fn test_get_root_directory() { - let result = icarus_envy::environment::get_root_directory(); + let result = sienvy::environment::get_root_directory(); assert_eq!( result.value, "/path/to/root", "ROOT_DIRECTORY does not match {:?}", @@ -51,68 +51,68 @@ mod tests { } #[test] - fn test_get_icarus_base_api_url() { - let result = icarus_envy::environment::get_icarus_base_api_url(); + fn test_get_soaricarus_base_api_url() { + let result = sienvy::environment::get_soaricarus_base_api_url(); assert_eq!( - result.value, "https://icarus.com", - "ICARUS_BASE_API_URL does not match {:?}", + result.value, "https://soaricarus.com", + "SOARICARUS_BASE_API_URL does not match {:?}", result ) } #[test] fn test_get_app_env() { - let result = icarus_envy::environment::get_app_env(); + let result = sienvy::environment::get_app_env(); assert_eq!( result.value, "development", "{} does not match {:?}", - icarus_envy::keys::APP_ENV, + sienvy::keys::APP_ENV, result ) } #[test] fn test_get_backend_port() { - let result = icarus_envy::environment::get_backend_port(); + let result = sienvy::environment::get_backend_port(); assert_eq!( result.value, "8001", "{} does not match {:?}", - icarus_envy::keys::BACKEND_PORT, + sienvy::keys::BACKEND_PORT, result ) } #[test] fn test_get_frontend_url() { - let result = icarus_envy::environment::get_frontend_url(); + let result = sienvy::environment::get_frontend_url(); assert_eq!( result.value, "http://localhost:4200", "{} does not match {:?}", - icarus_envy::keys::FRONTEND_URL, + sienvy::keys::FRONTEND_URL, result ) } #[test] fn test_get_rust_log() { - let result = icarus_envy::environment::get_rust_log(); + let result = sienvy::environment::get_rust_log(); assert_eq!( result.value, "debug", "{} does not match {:?}", - icarus_envy::keys::RUST_LOG, + sienvy::keys::RUST_LOG, result ) } #[test] fn test_get_allowed_origins() { - let result = icarus_envy::environment::get_allowed_origins(); + let result = sienvy::environment::get_allowed_origins(); assert_eq!( result.value, "https://soaricarus.com,https://www.soaricarus.com", "{} does not match {:?}", - icarus_envy::keys::ALLOWED_ORIGINS, + sienvy::keys::ALLOWED_ORIGINS, result ); @@ -122,7 +122,7 @@ mod tests { result.key ); - match icarus_envy::utility::delimitize(&result) { + match sienvy::utility::delimitize(&result) { Ok(allowed_origins) => { assert_eq!( allowed_origins.len(), @@ -152,7 +152,7 @@ mod tests { ]; for (key, value) in keys.iter() { - let result = icarus_envy::environment::get_env(key); + let result = sienvy::environment::get_env(key); assert_eq!( result.value, *value, "{:?} does not match {:?}",