From a55ad1cc44c12836eca5652d231902968e04eea1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 5 May 2026 12:20:32 +0900 Subject: refactor(core): centralize version constant in mozart-core --- crates/mozart/src/commands/about.rs | 6 ++++-- crates/mozart/src/commands/diagnose.rs | 4 ++-- crates/mozart/src/commands/self_update.rs | 9 ++------- 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'crates/mozart/src/commands') 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!("Mozart - Dependency Manager for PHP - version {version}"), + &console_format!( + "Mozart - Dependency Manager for PHP - version {MOZART_VERSION}", + ), 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 { .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 -- cgit v1.3.1