From 0209f63210e5b547b5c6b73367bb80ea86c255ec Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 8 Aug 2026 03:52:33 +0900 Subject: feat(composer): bake the dev build warning deadline in at build time Composer defines COMPOSER_DEV_WARNING_TIME from its phar stub when the compiled version is a commit hash rather than a tag, so the value exists only in the build artifact. It was a todo!() in the PHP shim, leaving the warning branch in Application::do_run unreachable. A build script now derives it the way Compiler does, from git describe and the HEAD commit date, and composer::COMPOSER_DEV_WARNING_TIME holds the result as a Rust constant instead of a runtime-defined one. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/composer.rs | 10 ++++++++++ crates/shirabe/src/console/application.rs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'crates/shirabe/src') diff --git a/crates/shirabe/src/composer.rs b/crates/shirabe/src/composer.rs index 356aefc1..fca19539 100644 --- a/crates/shirabe/src/composer.rs +++ b/crates/shirabe/src/composer.rs @@ -21,6 +21,16 @@ pub const RELEASE_DATE: &str = "2026-04-14 13:31:52"; pub const SOURCE_VERSION: &str = ""; pub const RUNTIME_API_VERSION: &str = "2.2.2"; +/// The deadline after which a development build reports itself as outdated, or `None` for a build +/// made from a tagged revision. Baked in by `build.rs`. +/// +/// Composer declares this as the global constant COMPOSER_DEV_WARNING_TIME from its phar stub, so +/// a plugin can read it back with `defined()`/`constant()`. Here it is a Rust constant, and +/// plugins cannot observe it. Technically speaking, it is incompatible with Composer, but trivial +/// enough. +pub const COMPOSER_DEV_WARNING_TIME: Option = + include!(concat!(env!("OUT_DIR"), "/dev_warning_time.rs")); + pub fn get_version() -> String { if VERSION == "@package_version@" { return SOURCE_VERSION.to_string(); diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 36151563..96f80d9b 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -2301,10 +2301,10 @@ impl ApplicationHandle { io.write_error("Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug"); } - if defined("COMPOSER_DEV_WARNING_TIME") + if let Some(dev_warning_time) = composer::COMPOSER_DEV_WARNING_TIME && command_name.as_deref() != Some("self-update") && command_name.as_deref() != Some("selfupdate") - && time() > shirabe_php_shim::composer_dev_warning_time() + && time() > dev_warning_time { io.write_error(&format!( "Warning: This development build of Composer is over 60 days old. It is recommended to update it by running \"{} self-update\" to get the latest version.", -- cgit v1.3.1-4-g156e