diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-05 12:20:32 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-05 12:55:09 +0900 |
| commit | a55ad1cc44c12836eca5652d231902968e04eea1 (patch) | |
| tree | 3e24d859a464dd716ecb92cc40c729bf281863f4 /crates/mozart | |
| parent | 14d3eb2b2f537140bf626b3d109e01834704e5bf (diff) | |
| download | php-mozart-a55ad1cc44c12836eca5652d231902968e04eea1.tar.gz php-mozart-a55ad1cc44c12836eca5652d231902968e04eea1.tar.zst php-mozart-a55ad1cc44c12836eca5652d231902968e04eea1.zip | |
refactor(core): centralize version constant in mozart-core
Diffstat (limited to 'crates/mozart')
| -rw-r--r-- | crates/mozart/src/commands/about.rs | 6 | ||||
| -rw-r--r-- | crates/mozart/src/commands/diagnose.rs | 4 | ||||
| -rw-r--r-- | crates/mozart/src/commands/self_update.rs | 9 | ||||
| -rw-r--r-- | crates/mozart/src/main.rs | 3 |
4 files changed, 10 insertions, 12 deletions
diff --git a/crates/mozart/src/commands/about.rs b/crates/mozart/src/commands/about.rs index 9c58db3..a8566d1 100644 --- a/crates/mozart/src/commands/about.rs +++ b/crates/mozart/src/commands/about.rs @@ -1,4 +1,5 @@ use clap::Args; +use mozart_core::MOZART_VERSION; use mozart_core::console; use mozart_core::console_format; @@ -10,9 +11,10 @@ pub async fn execute( _cli: &super::Cli, console: &console::Console, ) -> anyhow::Result<()> { - let version = env!("CARGO_PKG_VERSION"); console.write_stdout( - &console_format!("<info>Mozart - Dependency Manager for PHP - version {version}</info>"), + &console_format!( + "<info>Mozart - Dependency Manager for PHP - version {MOZART_VERSION}</info>", + ), console::Verbosity::Normal, ); console.write_stdout( diff --git a/crates/mozart/src/commands/diagnose.rs b/crates/mozart/src/commands/diagnose.rs index 2320ddc..54296ce 100644 --- a/crates/mozart/src/commands/diagnose.rs +++ b/crates/mozart/src/commands/diagnose.rs @@ -1,5 +1,6 @@ use clap::Args; use colored::Colorize; +use mozart_core::MOZART_VERSION; use mozart_core::console::{Console, Verbosity}; use std::path::{Path, PathBuf}; @@ -80,8 +81,7 @@ fn print_info_line(result: &CheckResult, console: &Console) { /// Check 1: Mozart version info (informational). fn check_version() -> CheckResult { - let version = env!("CARGO_PKG_VERSION"); - CheckResult::Info(format!("Mozart version {version}")) + CheckResult::Info(format!("Mozart version {MOZART_VERSION}")) } /// Check 2 & 3: HTTP/HTTPS connectivity to Packagist. diff --git a/crates/mozart/src/commands/self_update.rs b/crates/mozart/src/commands/self_update.rs index 2c7c59b..401d15a 100644 --- a/crates/mozart/src/commands/self_update.rs +++ b/crates/mozart/src/commands/self_update.rs @@ -1,4 +1,5 @@ use clap::Args; +use mozart_core::MOZART_VERSION; use mozart_core::console::Verbosity; use mozart_core::console_format; use std::io::Write; @@ -91,12 +92,6 @@ fn get_data_dir() -> anyhow::Result<PathBuf> { .join("mozart")) } -// ─── Version helpers ────────────────────────────────────────────────────────── - -fn get_current_version() -> &'static str { - env!("CARGO_PKG_VERSION") -} - /// Returns the platform-specific binary asset name for the current build target. /// /// Examples: `mozart-linux-x86_64`, `mozart-macos-aarch64`, `mozart-windows-x86_64.exe` @@ -286,7 +281,7 @@ async fn update( data_dir: &Path, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { - let current_version = get_current_version(); + let current_version = MOZART_VERSION; let channel = effective_channel(args.preview); // Fetch releases diff --git a/crates/mozart/src/main.rs b/crates/mozart/src/main.rs index 8201d87..35f8485 100644 --- a/crates/mozart/src/main.rs +++ b/crates/mozart/src/main.rs @@ -1,5 +1,6 @@ use clap::Parser; use mozart::commands; +use mozart_core::MOZART_VERSION; use mozart_core::exit_code; use tracing_subscriber::{EnvFilter, fmt, prelude::*}; @@ -48,7 +49,7 @@ async fn main() { "{}", mozart_core::console_format!( "<info>Mozart</info> version <comment>{}</comment> {}", - env!("CARGO_PKG_VERSION"), + MOZART_VERSION, build_date ) ); |
