diff options
31 files changed, 151 insertions, 90 deletions
diff --git a/crates/shirabe/build.rs b/crates/shirabe/build.rs index 22c8be58..e11b1a06 100644 --- a/crates/shirabe/build.rs +++ b/crates/shirabe/build.rs @@ -1,11 +1,13 @@ //! ref: composer/src/Composer/Compiler.php //! -//! Generates a constant value of `composer::COMPOSER_DEV_WARNING_TIME`. +//! Generates the constant values of `composer::SHIRABE_RELEASE_DATE` and +//! `composer::COMPOSER_DEV_WARNING_TIME` from the HEAD commit. fn git(repo_root: &std::path::Path, args: &[&str]) -> Option<String> { let output = std::process::Command::new("git") .args(args) .current_dir(repo_root) + .env("TZ", "UTC") .output() .ok()?; if !output.status.success() { @@ -26,26 +28,49 @@ fn main() { if let Some(git_dir) = git(repo_root, &["rev-parse", "--git-dir"]) { let git_dir = repo_root.join(git_dir); - for path in ["HEAD", "packed-refs", "refs/tags"] { - let path = git_dir.join(path); + // Committing on the current branch moves the branch ref, not HEAD. + let branch_ref = git(repo_root, &["symbolic-ref", "-q", "HEAD"]); + for path in ["HEAD", "packed-refs", "refs/tags"] + .iter() + .map(|name| git_dir.join(name)) + .chain(branch_ref.map(|name| git_dir.join(name))) + { if path.exists() { println!("cargo::rerun-if-changed={}", path.display()); } } } + // Both constants describe the HEAD commit, so a checkout git cannot read leaves the build + // unable to date itself. Falling back would ship a build that claims a release date it does + // not have and that never reports itself as outdated. + let expect_git = "the release date comes from the HEAD commit: build from a git checkout"; + let release_date = git( + repo_root, + &[ + "log", + "-n1", + "--date=format-local:%Y-%m-%d %H:%M:%S", + "--pretty=%cd", + "HEAD", + ], + ) + .expect(expect_git); + let commit_time = git(repo_root, &["log", "-n1", "--pretty=%ct", "HEAD"]) + .and_then(|date| date.parse::<i64>().ok()) + .expect(expect_git); + let dev_warning_time = if git(repo_root, &["describe", "--tags", "--exact-match", "HEAD"]).is_some() { None } else { - git(repo_root, &["log", "-n1", "--pretty=%ct", "HEAD"]) - .and_then(|date| date.parse::<i64>().ok()) - .map(|date| date + 60 * 86400) + Some(commit_time + 60 * 86400) }; - let out_dir = std::env::var("OUT_DIR").unwrap(); + let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()); + std::fs::write(out_dir.join("release_date.rs"), format!("{release_date:?}")).unwrap(); std::fs::write( - std::path::Path::new(&out_dir).join("dev_warning_time.rs"), + out_dir.join("dev_warning_time.rs"), match dev_warning_time { Some(time) => format!("Some({time})"), None => "None".to_string(), diff --git a/crates/shirabe/src/command/about_command.rs b/crates/shirabe/src/command/about_command.rs index 3a72ac3a..73c466c6 100644 --- a/crates/shirabe/src/command/about_command.rs +++ b/crates/shirabe/src/command/about_command.rs @@ -47,12 +47,13 @@ impl Command for AboutCommand { input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> anyhow::Result<i64> { - let composer_version = composer::get_version(); + let shirabe_version = composer::SHIRABE_VERSION; + let composer_version = composer::VERSION; let _ = (input, output); self.get_io().borrow().write(&format!( - "<info>Composer - Dependency Manager for PHP - version {composer_version}</info>\n\ - <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.\n\ + "<info>Shirabe - Dependency Manager for PHP - version {shirabe_version} (based on Composer {composer_version})</info>\n\ + <comment>Shirabe is a dependency manager tracking local dependencies of your projects and libraries.\n\ See https://getcomposer.org/ for more information.</comment>" )); diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index df47d934..3d92de4b 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -120,7 +120,7 @@ impl ConfigCommand { .unwrap_or(false) { self.get_io().write_error( - "<info>You are now running Composer with SSL/TLS protection enabled.</info>", + "<info>You are now running Shirabe with SSL/TLS protection enabled.</info>", ); } else if normalized_value.as_bool().unwrap_or(false) && !config @@ -129,7 +129,7 @@ impl ConfigCommand { .as_bool() .unwrap_or(false) { - self.get_io().write_error("<warning>You are now running Composer with SSL/TLS protection disabled.</warning>"); + self.get_io().write_error("<warning>You are now running Shirabe with SSL/TLS protection disabled.</warning>"); } } @@ -907,7 +907,7 @@ impl Command for ConfigCommand { .unwrap_or(false) { self.get_io().write_error( - "<info>You are now running Composer with SSL/TLS protection enabled.</info>", + "<info>You are now running Shirabe with SSL/TLS protection enabled.</info>", ); } diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs index da043a4f..451b051c 100644 --- a/crates/shirabe/src/command/diagnose_command.rs +++ b/crates/shirabe/src/command/diagnose_command.rs @@ -177,7 +177,7 @@ impl DiagnoseCommand { let mut result_list: Vec<PhpMixed> = vec![]; let mut tls_warning: Option<String> = None; if proto == "https" && config.borrow().get("disable-tls").as_bool() == Some(true) { - tls_warning = Some("<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>".to_string()); + tls_warning = Some("<warning>Shirabe is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>".to_string()); } match self @@ -236,7 +236,7 @@ impl DiagnoseCommand { let mut tls_warning: Option<String> = None; if url.starts_with("https://") && config.borrow().get("disable-tls").as_bool() == Some(true) { - tls_warning = Some("<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>".to_string()); + tls_warning = Some("<warning>Shirabe is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>".to_string()); } match self @@ -964,7 +964,7 @@ impl DiagnoseCommand { ), other => { return Err(InvalidArgumentException::new(format!( - "DiagnoseCommand: Unknown error type \"{}\". Please report at https://github.com/composer/composer/issues/new.", + "DiagnoseCommand: Unknown error type \"{}\". Please report at https://github.com/nsfisis/php-shirabe/issues/new.", other, )) .into()); @@ -989,7 +989,7 @@ impl DiagnoseCommand { "zlib" => { display_ini_message = true; format!( - "The zlib extension is not loaded, this can slow down Composer a lot.{}If possible, enable it or recompile php with --with-zlib{}", + "The zlib extension is not loaded, this can slow down Shirabe a lot.{}If possible, enable it or recompile php with --with-zlib{}", PHP_EOL, PHP_EOL ) } @@ -1021,29 +1021,29 @@ impl DiagnoseCommand { ) } "xdebug_loaded" => format!( - "The xdebug extension is loaded, this can slow down Composer a little.{} Disabling it when using Composer is recommended.", + "The xdebug extension is loaded, this can slow down Shirabe a little.{} Disabling it when using Shirabe is recommended.", PHP_EOL ), "xdebug_profile" => { display_ini_message = true; format!( - "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.{}Add the following to the end of your `php.ini` to disable it:{} xdebug.profiler_enabled = 0", + "The xdebug.profiler_enabled setting is enabled, this can slow down Shirabe a lot.{}Add the following to the end of your `php.ini` to disable it:{} xdebug.profiler_enabled = 0", PHP_EOL, PHP_EOL ) } "onedrive" => format!( - "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.{}Upgrade your PHP ({}) to use this location with Composer.{}", + "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.{}Upgrade your PHP ({}) to use this location with Shirabe.{}", PHP_EOL, current.as_string().unwrap_or(""), PHP_EOL ), "uopz" => format!( - "The uopz extension ignores exit calls and may not work with all Composer commands.{}Disabling it when using Composer is recommended.", + "The uopz extension ignores exit calls and may not work with all Shirabe commands.{}Disabling it when using Shirabe is recommended.", PHP_EOL ), other => { return Err(InvalidArgumentException::new(format!( - "DiagnoseCommand: Unknown warning type \"{}\". Please report at https://github.com/composer/composer/issues/new.", + "DiagnoseCommand: Unknown warning type \"{}\". Please report at https://github.com/nsfisis/php-shirabe/issues/new.", other, )) .into()); @@ -1197,17 +1197,18 @@ impl Command for DiagnoseCommand { let r = self.check_pub_keys(&config.borrow())?; self.output_result(r); - io.write_no_newline("Checking Composer version: "); + io.write_no_newline("Checking Shirabe version: "); let r = self.check_version(&config)?; self.output_result(r); } io.write(&format!( - "Composer version: <comment>{}</comment>", - composer::get_version() + "Shirabe version: <comment>{}</comment> (based on Composer <comment>{}</comment>)", + composer::SHIRABE_VERSION, + composer::VERSION )); - io.write_no_newline("Checking Composer and its dependencies for vulnerabilities: "); + io.write_no_newline("Checking Shirabe and its dependencies for vulnerabilities: "); let r = self.check_composer_audit(&config)?; self.output_result(r); diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index e76f5a94..7e6021a9 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -878,7 +878,7 @@ impl Command for InitCommand { "\n{}\n", formatter.borrow().format_block( FormatBlockMessages::String( - "Welcome to the Composer config generator".to_string(), + "Welcome to the Shirabe config generator".to_string(), ), "bg=blue;fg=white", true, diff --git a/crates/shirabe/src/command/install_command.rs b/crates/shirabe/src/command/install_command.rs index 6a5ce8de..f1a6df35 100644 --- a/crates/shirabe/src/command/install_command.rs +++ b/crates/shirabe/src/command/install_command.rs @@ -134,7 +134,7 @@ impl Command for InstallCommand { let composer = crate::composer::composer_full(&composer_handle); if !composer.get_locker().borrow_mut().is_locked() && !HttpDownloader::is_curl_enabled() { - io.write_error("<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>"); + io.write_error("<warning>Shirabe is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>"); } // TODO(plugin): dispatch CommandEvent diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index b961b3a0..38a79e30 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -345,7 +345,7 @@ impl Command for UpdateCommand { if !HttpDownloader::is_curl_enabled() { io.write_error3( - "<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>", + "<warning>Shirabe is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>", true, io_interface::NORMAL, ); diff --git a/crates/shirabe/src/composer.rs b/crates/shirabe/src/composer.rs index e714f85d..1c6bbaed 100644 --- a/crates/shirabe/src/composer.rs +++ b/crates/shirabe/src/composer.rs @@ -14,13 +14,21 @@ use crate::util::r#loop::Loop; use shirabe_pcre::Preg; use shirabe_php_shim::php_regex; -// TODO(distribution): change this information to Shirabe version. +/// The Composer version this port tracks. Kept as-is so `Composer::VERSION`, the `composer` +/// platform package and the HTTP User-Agent keep reporting a value plugins and servers can +/// interpret. What Shirabe calls itself is `SHIRABE_VERSION`. pub const VERSION: &str = "2.9.7"; pub const BRANCH_ALIAS_VERSION: &str = ""; 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"; +pub const SHIRABE_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// The UTC date of the commit this build was made from. Baked in by `build.rs`, the way Composer's +/// Compiler stamps `RELEASE_DATE` when it builds the phar. +pub const SHIRABE_RELEASE_DATE: &str = include!(concat!(env!("OUT_DIR"), "/release_date.rs")); + /// 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`. /// diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 9bb810f7..3e4a746b 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -141,17 +141,16 @@ pub struct Application { } impl Application { - const LOGO: &'static str = r#" ______ - / ____/___ ____ ___ ____ ____ ________ _____ - / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ -/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / -\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ - /_/ + const LOGO: &'static str = r#" _____ __ _ __ + / ___// /_ (_)________ _/ /_ ___ + \__ \/ __ \/ / ___/ __ `/ __ \/ _ \ + ___/ / / / / / / / /_/ / /_/ / __/ +/____/_/ /_/_/_/ \__,_/_.___/\___/ "#; pub fn new(name: String, mut version: String) -> Self { if version.is_empty() { - version = composer::get_version(); + version = composer::SHIRABE_VERSION.to_string(); } if function_exists("ini_set") && extension_loaded("xdebug") { ini_set("xdebug.show_exception_trace", "0"); @@ -525,11 +524,12 @@ impl Application { } format!( - "<info>{}</info> version <comment>{}{}</comment> {}", + "<info>{}</info> version <comment>{}{}</comment> (based on Composer {}) {}", self.get_name(), self.get_version(), branch_alias_string, - composer::RELEASE_DATE, + composer::VERSION, + composer::SHIRABE_RELEASE_DATE, ) } @@ -2176,7 +2176,7 @@ impl ApplicationHandle { // at this point plugins are needed, so if we are running as root and it is not allowed we need to prompt // if interactive, and abort otherwise if is_non_allowed_root { - io.write_error("<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>"); + io.write_error("<warning>Do not run Shirabe as root/super user! See https://getcomposer.org/root for details</warning>"); if io.is_interactive() && io.ask_confirmation( @@ -2200,7 +2200,7 @@ impl ApplicationHandle { let cmd_name = command.borrow().get_name().unwrap_or_default(); if application.borrow_mut().has(&cmd_name) { let cls = command.borrow().php_class_name(); - io.write_error(&format!("<warning>Plugin command {} ({}) would override a Composer command and has been skipped</warning>", cmd_name, cls)); + io.write_error(&format!("<warning>Plugin command {} ({}) would override a Shirabe command and has been skipped</warning>", cmd_name, cls)); } else { self.add(command)?; } @@ -2259,9 +2259,10 @@ impl ApplicationHandle { if !is_proxy_command { io.write_error3( &format!( - "Running {} ({}) with PHP {} on {}", - composer::get_version(), - composer::RELEASE_DATE, + "Running Shirabe {} ({}, based on Composer {}) with PHP {} on {}", + composer::SHIRABE_VERSION, + composer::SHIRABE_RELEASE_DATE, + composer::VERSION, shirabe_php_rpc::get_php_version().version, (if function_exists("php_uname") { format!("{} / {}", php_uname("s"), php_uname("r")) @@ -2274,13 +2275,13 @@ impl ApplicationHandle { ); if shirabe_php_rpc::get_php_version().version_id < 70205 { - io.write_error(&format!("<warning>Composer supports PHP 7.2.5 and above, you will most likely encounter problems with your PHP {}. Upgrading is strongly recommended but you can use Composer 2.2.x LTS as a fallback.</warning>", shirabe_php_rpc::get_php_version().version)); + io.write_error(&format!("<warning>Shirabe supports PHP 7.2.5 and above, you will most likely encounter problems with your PHP {}. Upgrading is strongly recommended but you can use Composer 2.2.x LTS as a fallback.</warning>", shirabe_php_rpc::get_php_version().version)); } if shirabe_php_rpc::xdebug::is_xdebug_active() && Platform::get_env("COMPOSER_DISABLE_XDEBUG_WARN").is_none() { - io.write_error("<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>"); + io.write_error("<warning>Shirabe is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>"); } let dev_warning_time = application.borrow().dev_warning_time; @@ -2290,7 +2291,7 @@ impl ApplicationHandle { && time() > dev_warning_time { io.write_error(&format!( - "<warning>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.</warning>", + "<warning>Warning: This development build of Shirabe is over 60 days old. It is recommended to update it by running \"{} self-update\" to get the latest version.</warning>", shirabe_php_shim::PHP_SERVER .lock() .unwrap() @@ -2305,7 +2306,7 @@ impl ApplicationHandle { && command_name.as_deref() != Some("selfupdate") && command_name.as_deref() != Some("_complete") { - io.write_error("<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>"); + io.write_error("<warning>Do not run Shirabe as root/super user! See https://getcomposer.org/root for details</warning>"); if io.is_interactive() && !io.ask_confirmation( @@ -2336,7 +2337,7 @@ impl ApplicationHandle { && unlink(&tempfile).is_ok() && !file_exists(&tempfile)) { - return Ok(Some(format!("<error>PHP temp directory ({}) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini</error>", sys_get_temp_dir()))); + return Ok(Some(format!("<error>PHP temp directory ({}) does not exist or is not writable to Shirabe. Set sys_temp_dir in your php.ini</error>", sys_get_temp_dir()))); } Ok(None) }) @@ -2362,7 +2363,7 @@ impl ApplicationHandle { ); if !defined(&script_event_const) { if application.borrow_mut().has(script) { - io.write_error(&format!("<warning>A script named {} would override a Composer command and has been skipped</warning>", script)); + io.write_error(&format!("<warning>A script named {} would override a Shirabe command and has been skipped</warning>", script)); } else { let mut description = format!( "Runs the {} script as defined in composer.json", diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs index 27ae409b..7dd40c4b 100644 --- a/crates/shirabe/src/dependency_resolver/pool_builder.rs +++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs @@ -829,7 +829,7 @@ impl PoolBuilder { } if matched_platform_package { self.io.write_error(&format!( - "<warning>Pattern \"{}\" listed for update matches platform packages, but these cannot be updated by Composer.</warning>", + "<warning>Pattern \"{}\" listed for update matches platform packages, but these cannot be updated by Shirabe.</warning>", pattern )); } else if strpos(pattern, "*").is_some() { diff --git a/crates/shirabe/src/dependency_resolver/solver_bug_exception.rs b/crates/shirabe/src/dependency_resolver/solver_bug_exception.rs index 9c47d99b..5234108f 100644 --- a/crates/shirabe/src/dependency_resolver/solver_bug_exception.rs +++ b/crates/shirabe/src/dependency_resolver/solver_bug_exception.rs @@ -9,7 +9,7 @@ impl SolverBugException { pub fn new(message: String) -> Self { let full_message = format!( "{}\nThis exception was most likely caused by a bug in Composer.\n\ - Please report the command you ran, the exact error you received, and your composer.json on https://github.com/composer/composer/issues - thank you!\n", + Please report the command you ran, the exact error you received, and your composer.json on https://github.com/nsfisis/php-shirabe/issues - thank you!\n", message ); SolverBugException(RuntimeException::new(full_message)) diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs index 8586de3d..44940fef 100644 --- a/crates/shirabe/src/downloader/path_downloader.rs +++ b/crates/shirabe/src/downloader/path_downloader.rs @@ -153,7 +153,7 @@ impl PathDownloader { && !self.safe_junctions() { if !allowed_strategies.contains(&Self::STRATEGY_MIRROR) { - return Err(RuntimeException::new("You are on an old Windows / old PHP combo which does not allow Composer to use junctions/symlinks and this path repository has symlink:true in its options so copying is not allowed".to_string()) + return Err(RuntimeException::new("You are on an old Windows / old PHP combo which does not allow Shirabe to use junctions/symlinks and this path repository has symlink:true in its options so copying is not allowed".to_string()) .into()); } current_strategy = Self::STRATEGY_MIRROR; @@ -166,7 +166,7 @@ impl PathDownloader { && !function_exists("symlink") { if !allowed_strategies.contains(&Self::STRATEGY_MIRROR) { - return Err(RuntimeException::new("Your PHP has the symlink() function disabled which does not allow Composer to use symlinks and this path repository has symlink:true in its options so copying is not allowed".to_string()) + return Err(RuntimeException::new("Your PHP has the symlink() function disabled which does not allow Shirabe to use symlinks and this path repository has symlink:true in its options so copying is not allowed".to_string()) .into()); } current_strategy = Self::STRATEGY_MIRROR; diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs index 4fe248c5..fe5a0ec8 100644 --- a/crates/shirabe/src/factory.rs +++ b/crates/shirabe/src/factory.rs @@ -450,9 +450,9 @@ impl Factory { if !file.exists() { let message = if path == "./composer.json" || path == "composer.json" { - format!("Composer could not find a composer.json file in {}", cwd) + format!("Shirabe could not find a composer.json file in {}", cwd) } else { - format!("Composer could not find the config file: {}", path) + format!("Shirabe could not find the config file: {}", path) }; let instructions = if full_load { "To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage" @@ -1445,7 +1445,7 @@ impl Factory { { if !unsafe { WARNED } { io.write_error3( - "<warning>You are running Composer with SSL/TLS protection disabled.</warning>", + "<warning>You are running Shirabe with SSL/TLS protection disabled.</warning>", true, crate::io::NORMAL, ); diff --git a/crates/shirabe/src/filter/platform_requirement_filter/platform_requirement_filter_factory.rs b/crates/shirabe/src/filter/platform_requirement_filter/platform_requirement_filter_factory.rs index 7f08e8dd..f71afb1b 100644 --- a/crates/shirabe/src/filter/platform_requirement_filter/platform_requirement_filter_factory.rs +++ b/crates/shirabe/src/filter/platform_requirement_filter/platform_requirement_filter_factory.rs @@ -39,7 +39,7 @@ impl PlatformRequirementFilterFactory { )?)) } other => Err(InvalidArgumentException::new(format!( - "PlatformRequirementFilter: Unknown $boolOrList parameter {}. Please report at https://github.com/composer/composer/issues/new.", + "PlatformRequirementFilter: Unknown $boolOrList parameter {}. Please report at https://github.com/nsfisis/php-shirabe/issues/new.", shirabe_php_shim::get_debug_type(&other) )).into()), } diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs index bbd032e7..2fa4fe8f 100644 --- a/crates/shirabe/src/json/json_manipulator.rs +++ b/crates/shirabe/src/json/json_manipulator.rs @@ -939,7 +939,7 @@ impl JsonManipulator { children_clean = Some(children.clone()); } - let children_clean = children_clean.ok_or_else(|| InvalidArgumentException::new("JsonManipulator: $childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.".to_string()))?; + let children_clean = children_clean.ok_or_else(|| InvalidArgumentException::new("JsonManipulator: $childrenClean is not defined. Please report at https://github.com/nsfisis/php-shirabe/issues/new.".to_string()))?; // no child data left, $name was the only key in let mut empty_match: IndexMap<String, String> = IndexMap::new(); diff --git a/crates/shirabe/src/lib.rs b/crates/shirabe/src/lib.rs index 009db5a0..9daf2188 100644 --- a/crates/shirabe/src/lib.rs +++ b/crates/shirabe/src/lib.rs @@ -43,7 +43,7 @@ pub fn run(argv: Vec<String>) -> anyhow::Result<i32> { .unwrap_or_default(), ); - let application = ApplicationHandle::new("Composer".to_string(), String::new())?; + let application = ApplicationHandle::new("Shirabe".to_string(), String::new())?; let input = std::rc::Rc::new(std::cell::RefCell::new(ArgvInput::new(Some(argv), None)?)); application.run(Some(input), None) } diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs index 5f35843e..0ee355f0 100644 --- a/crates/shirabe/src/package/loader/root_package_loader.rs +++ b/crates/shirabe/src/package/loader/root_package_loader.rs @@ -112,7 +112,7 @@ impl RootPackageLoader { let package_type = config.get("type").and_then(|v| v.as_string()).unwrap_or(""); if name != "__root__" && package_type != "project" { io.warning(&format!( - "Composer could not detect the root package ({}) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version", + "Shirabe could not detect the root package ({}) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version", name ), &[]); } diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs index 75852348..9f569af7 100644 --- a/crates/shirabe/src/plugin/plugin_manager.rs +++ b/crates/shirabe/src/plugin/plugin_manager.rs @@ -250,7 +250,7 @@ impl PluginManager { if requires_composer.get_pretty_string() == self.get_plugin_api_version() { self.io.write_error(&format!("<warning>The \"{}\" plugin requires composer-plugin-api {}, this *WILL* break in the future and it should be fixed ASAP (require ^{} instead for example).</warning>", package.get_name(), self.get_plugin_api_version(), self.get_plugin_api_version())); } else if !requires_composer.matches(¤t_plugin_api_constraint.into()) { - self.io.write_error(&format!("<warning>The \"{}\" plugin {}was skipped because it requires a Plugin API version (\"{}\") that does not match your Composer installation (\"{}\"). You may need to run composer update with the \"--no-plugins\" option.</warning>", + self.io.write_error(&format!("<warning>The \"{}\" plugin {}was skipped because it requires a Plugin API version (\"{}\") that does not match your Shirabe installation (\"{}\"). You may need to run shirabe update with the \"--no-plugins\" option.</warning>", package.get_name(), if is_global_plugin || self.running_in_global_dir { "(installed globally) " } else { "" }, requires_composer.get_pretty_string(), @@ -1347,7 +1347,7 @@ impl PluginManager { } Err(PluginBlockedException::new(format!( - "{}{} contains a Composer plugin which is blocked by your allow-plugins config. You may add it to the list if you consider it safe.\nYou can run \"composer {}config --no-plugins allow-plugins.{} [true|false]\" to enable it (true) or disable it explicitly and suppress this exception (false)\nSee https://getcomposer.org/allow-plugins", + "{}{} contains a Composer plugin which is blocked by your allow-plugins config. You may add it to the list if you consider it safe.\nYou can run \"shirabe {}config --no-plugins allow-plugins.{} [true|false]\" to enable it (true) or disable it explicitly and suppress this exception (false)\nSee https://getcomposer.org/allow-plugins", package, if is_global_plugin || self.running_in_global_dir { " (installed globally)" } else { "" }, if is_global_plugin || self.running_in_global_dir { "global " } else { "" }, diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index fe8faf48..33944c8f 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -2915,7 +2915,7 @@ impl ComposerRepository { match data { Some(d) => Ok(d), - None => Err(LogicException::new("ComposerRepository: Undefined $data. Please report at https://github.com/composer/composer/issues/new.".to_string()).into()), + None => Err(LogicException::new("ComposerRepository: Undefined $data. Please report at https://github.com/nsfisis/php-shirabe/issues/new.".to_string()).into()), } } diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs index 10a30159..26756ed0 100644 --- a/crates/shirabe/src/util/github.rs +++ b/crates/shirabe/src/util/github.rs @@ -88,7 +88,7 @@ impl GitHub { self.io.write_error3(msg, true, io_interface::NORMAL); } - let mut note = "Composer".to_string(); + let mut note = "Shirabe".to_string(); let expose_hostname = self .config .borrow_mut() diff --git a/crates/shirabe/tests/application_test.rs b/crates/shirabe/tests/application_test.rs index 1c93b790..23bc909a 100644 --- a/crates/shirabe/tests/application_test.rs +++ b/crates/shirabe/tests/application_test.rs @@ -40,7 +40,7 @@ fn test_dev_warning() { let _tear_down = TearDown; set_up(); - let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + let application = ApplicationHandle::new("Shirabe".to_string(), "".to_string()).unwrap(); application.__set_dev_warning_time(Some(time() - 1)); @@ -59,7 +59,7 @@ fn test_dev_warning() { application.do_run(input, output_trait).unwrap(); let expected_output = format!( - "<warning>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.</warning>{}", + "<warning>Warning: This development build of Shirabe is over 60 days old. It is recommended to update it by running \"{} self-update\" to get the latest version.</warning>{}", PHP_SERVER .lock() .unwrap() @@ -82,7 +82,7 @@ fn test_dev_warning_suppressed_for_self_update() { return; } - let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + let application = ApplicationHandle::new("Shirabe".to_string(), "".to_string()).unwrap(); let command: std::rc::Rc<std::cell::RefCell<dyn Command>> = std::rc::Rc::new(std::cell::RefCell::new(SelfUpdateCommand::new())); application.add(command).unwrap(); @@ -113,7 +113,7 @@ fn test_process_isolation_works_multiple_times() { let _tear_down = TearDown; set_up(); - let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + let application = ApplicationHandle::new("Shirabe".to_string(), "".to_string()).unwrap(); let command: std::rc::Rc<std::cell::RefCell<dyn Command>> = std::rc::Rc::new(std::cell::RefCell::new(AboutCommand::new())); application.add(command).unwrap(); @@ -166,7 +166,7 @@ fn test_no_plugins_disables_plugins_when_script_commands_exist() { true, ); - let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + let application = ApplicationHandle::new("Shirabe".to_string(), "".to_string()).unwrap(); application.set_catch_exceptions(false); // Run list command with --no-plugins, this triggers script command registration which previously @@ -231,7 +231,7 @@ fn test_script_command_takes_priority_over_abbreviated_builtin_command() { true, ); - let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + let application = ApplicationHandle::new("Shirabe".to_string(), "".to_string()).unwrap(); application.set_catch_exceptions(false); let app_output = std::rc::Rc::new(std::cell::RefCell::new(BufferedOutput::new( diff --git a/crates/shirabe/tests/command/about_command_test.rs b/crates/shirabe/tests/command/about_command_test.rs index bb726cf8..52e42a1d 100644 --- a/crates/shirabe/tests/command/about_command_test.rs +++ b/crates/shirabe/tests/command/about_command_test.rs @@ -8,7 +8,8 @@ use shirabe_php_shim::PhpMixed; #[test] #[serial] fn test_about() { - let composer_version = composer::get_version(); + let shirabe_version = composer::SHIRABE_VERSION; + let composer_version = composer::VERSION; let mut app_tester = get_application_tester(); let status_code = app_tester .run( @@ -19,11 +20,11 @@ fn test_about() { assert_eq!(0, status_code); assert!(app_tester.get_display().contains(&format!( - "Composer - Dependency Manager for PHP - version {composer_version}" + "Shirabe - Dependency Manager for PHP - version {shirabe_version} (based on Composer {composer_version})" ))); assert!(app_tester.get_display().contains( - "Composer is a dependency manager tracking local dependencies of your projects and libraries." + "Shirabe is a dependency manager tracking local dependencies of your projects and libraries." )); assert!( app_tester diff --git a/crates/shirabe/tests/command/validate_command_test.rs b/crates/shirabe/tests/command/validate_command_test.rs index 8e78dfe7..67370df0 100644 --- a/crates/shirabe/tests/command/validate_command_test.rs +++ b/crates/shirabe/tests/command/validate_command_test.rs @@ -69,7 +69,7 @@ fn provide_validate_tests() -> Vec<ValidateCase> { name: "validation passing", composer_json: minimal_valid_configuration(), command: vec![], - expected: "<warning>Composer could not detect the root package (test/suite) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version</warning>\n<warning>Composer could not detect the root package (test/suite) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version</warning>\n./composer.json is valid", + expected: "<warning>Shirabe could not detect the root package (test/suite) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version</warning>\n<warning>Shirabe could not detect the root package (test/suite) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version</warning>\n./composer.json is valid", }, ValidateCase { // WORDING NOTE: upstream asserts justinrainbow's property-prefixed strings @@ -142,7 +142,7 @@ fn test_with_composer_lock() { .run(validate_input(vec![]), RunOptions::default()) .unwrap(); - let expected = "<warning>Composer could not detect the root package (test/suite) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version</warning>\n<warning>Composer could not detect the root package (test/suite) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version</warning>\n./composer.json is valid but your composer.lock has some errors\n# Lock file errors\n- Required package \"root/req\" is not present in the lock file.\nThis usually happens when composer files are incorrectly merged or the composer.json file is manually edited.\nRead more about correctly resolving merge conflicts https://getcomposer.org/doc/articles/resolving-merge-conflicts.md\nand prefer using the \"require\" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require-r"; + let expected = "<warning>Shirabe could not detect the root package (test/suite) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version</warning>\n<warning>Shirabe could not detect the root package (test/suite) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version</warning>\n./composer.json is valid but your composer.lock has some errors\n# Lock file errors\n- Required package \"root/req\" is not present in the lock file.\nThis usually happens when composer files are incorrectly merged or the composer.json file is manually edited.\nRead more about correctly resolving merge conflicts https://getcomposer.org/doc/articles/resolving-merge-conflicts.md\nand prefer using the \"require\" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require-r"; assert_eq!(expected.trim(), app_tester.get_display().trim()); diff --git a/crates/shirabe/tests/common/test_case.rs b/crates/shirabe/tests/common/test_case.rs index 9de7d905..3be2df24 100644 --- a/crates/shirabe/tests/common/test_case.rs +++ b/crates/shirabe/tests/common/test_case.rs @@ -302,7 +302,7 @@ pub fn create_composer_lock( pub fn get_application_tester() -> ApplicationTester { crate::bootstrap::bootstrap(); - let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + let application = ApplicationHandle::new("Shirabe".to_string(), "".to_string()).unwrap(); application.set_catch_exceptions(false); ApplicationTester::new(application) } diff --git a/crates/shirabe/tests/completion_functional_test.rs b/crates/shirabe/tests/completion_functional_test.rs index 6bbe955a..1193b5d1 100644 --- a/crates/shirabe/tests/completion_functional_test.rs +++ b/crates/shirabe/tests/completion_functional_test.rs @@ -44,7 +44,7 @@ fn assert_complete(input: &str, expected_suggestions: Option<&[&str]>) { let mut input: Vec<&str> = input.split(' ').collect(); let command_name = input.remove(0); // PHP: $this->getApplication()->get($commandName) - let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + let application = ApplicationHandle::new("Shirabe".to_string(), "".to_string()).unwrap(); let base = application.__base_application(); let command = { let mut app_ref = base.borrow_mut(); diff --git a/crates/shirabe/tests/documentation_test.rs b/crates/shirabe/tests/documentation_test.rs index 33e5ec3f..a8da3d08 100644 --- a/crates/shirabe/tests/documentation_test.rs +++ b/crates/shirabe/tests/documentation_test.rs @@ -14,7 +14,7 @@ fn get_command_name(command: &std::rc::Rc<std::cell::RefCell<dyn Command>>) -> S } fn provide_command_cases() -> Vec<std::rc::Rc<std::cell::RefCell<dyn Command>>> { - let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + let application = ApplicationHandle::new("Shirabe".to_string(), "".to_string()).unwrap(); application.set_catch_exceptions(false); let mut description = diff --git a/crates/shirabe/tests/factory_test.rs b/crates/shirabe/tests/factory_test.rs index 3e70a7d9..4a446f43 100644 --- a/crates/shirabe/tests/factory_test.rs +++ b/crates/shirabe/tests/factory_test.rs @@ -38,7 +38,7 @@ fn test_default_values_are_as_expected() { .borrow_mut() .expects( vec![Expectation::text( - "<warning>You are running Composer with SSL/TLS protection disabled.</warning>", + "<warning>You are running Shirabe with SSL/TLS protection disabled.</warning>", )], false, ) diff --git a/crates/shirabe/tests/filter/platform_requirement_filter/platform_requirement_filter_factory_test.rs b/crates/shirabe/tests/filter/platform_requirement_filter/platform_requirement_filter_factory_test.rs index 10012e78..4c69068f 100644 --- a/crates/shirabe/tests/filter/platform_requirement_filter/platform_requirement_filter_factory_test.rs +++ b/crates/shirabe/tests/filter/platform_requirement_filter/platform_requirement_filter_factory_test.rs @@ -46,7 +46,7 @@ fn test_from_bool_throws_exception_if_type_is_unknown() { let result = PlatformRequirementFilterFactory::from_bool_or_list(PhpMixed::Null); let err = result.unwrap_err(); assert_eq!( - "PlatformRequirementFilter: Unknown $boolOrList parameter null. Please report at https://github.com/composer/composer/issues/new.", + "PlatformRequirementFilter: Unknown $boolOrList parameter null. Please report at https://github.com/nsfisis/php-shirabe/issues/new.", err.to_string() ); } diff --git a/crates/shirabe/tests/installer_test.rs b/crates/shirabe/tests/installer_test.rs index 5c835aff..a4c04c00 100644 --- a/crates/shirabe/tests/installer_test.rs +++ b/crates/shirabe/tests/installer_test.rs @@ -960,7 +960,7 @@ fn do_test_integration(case: &IntegrationCase, expect_output: Option<&str>) { ))); // Application with inline install/update commands (setCode closures). - let application = ApplicationHandle::new("Composer".to_string(), "".to_string()).unwrap(); + let application = ApplicationHandle::new("Shirabe".to_string(), "".to_string()).unwrap(); application.set_catch_exceptions(false); let run_result: std::rc::Rc<std::cell::RefCell<Option<anyhow::Result<i64>>>> = diff --git a/crates/shirabe/tests/plugin/e2e_script_command_test.rs b/crates/shirabe/tests/plugin/e2e_script_command_test.rs index 019c830d..d730fbff 100644 --- a/crates/shirabe/tests/plugin/e2e_script_command_test.rs +++ b/crates/shirabe/tests/plugin/e2e_script_command_test.rs @@ -42,6 +42,15 @@ fn run_command(work: &Path, program: &str, prefix_args: &[&str], args: &[&str]) } } +/// `list` opens with the application banner (logo and version line), which Shirabe owns and +/// upstream Composer cannot match. Everything from the `Usage:` section down still has to. +fn list_body(text: &str) -> &str { + let usage = text + .find("\nUsage:") + .expect("list output has a Usage section"); + &text[usage + 1..] +} + fn lines_starting_with<'a>(text: &'a str, prefix: &str) -> Vec<&'a str> { text.lines() .map(str::trim_end) @@ -149,7 +158,11 @@ fn test_script_command_class_import_matches_upstream_composer() { // them, next to the plain shell script that stays a ScriptAliasCommand. assert_eq!(0, u_list.exit_code); assert_eq!(u_list.exit_code, s_list.exit_code); - assert_eq!(u_list.stdout, s_list.stdout, "list output differs"); + assert_eq!( + list_body(&u_list.stdout), + list_body(&s_list.stdout), + "list output differs" + ); assert_eq!( vec![" greet Greets someone from a script-provided command."], lines_starting_with(&s_list.stdout, "greet") diff --git a/docs/known-incompatibilities.md b/docs/known-incompatibilities.md index e8e6a038..79ead94c 100644 --- a/docs/known-incompatibilities.md +++ b/docs/known-incompatibilities.md @@ -3,12 +3,6 @@ NOTE: This is not an exhaustive list. Shirabe is in early development and there are still a number of significant incompatibilities with Composer that are not documented here yet. -## Error Messages - -Error messages, in particular those from PHP built-in functions, are not intended to be mapped exactly. -Plugins or external tools that rely on error messages may break. - - ## Default Home/Cache/Data Directories To avoid conflicting with an existing Composer installation, Shirabe's default system directories @@ -32,6 +26,23 @@ The following are intentionally left unchanged for ecosystem compatibility: TODO: a CLI flag or an environment variable to force Shirabe to use compatible paths. +## Error Messages + +Error messages, in particular those from PHP built-in functions, are not +intended to be mapped exactly. Plugins or external tools that rely on error +messages may break. + + +## Version Reporting + +Shirabe has its own version, separate from the Composer version it is ported +from. `shirabe --version`, `shirabe about` and `shirabe diagnose` report the +Shirabe version and show the Composer version alongside it. + +The pseudo-package `composer` and `composer-runtime-api` keep the original +Composer version in order not to break the version resolution. + + ## Xdebug Composer disables Xdebug on startup. Shirabe emulates it, but the exact |
