diff options
Diffstat (limited to 'crates/shirabe')
52 files changed, 437 insertions, 343 deletions
diff --git a/crates/shirabe/src/advisory/auditor.rs b/crates/shirabe/src/advisory/auditor.rs index 37c86d9..e2fb965 100644 --- a/crates/shirabe/src/advisory/auditor.rs +++ b/crates/shirabe/src/advisory/auditor.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Advisory/Auditor.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -178,7 +179,7 @@ impl Auditor { JsonFile::INDENT_DEFAULT, )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(audit_bitmask); @@ -225,7 +226,7 @@ impl Auditor { ], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.output_advisories(io, advisories_to_output, format)?; } @@ -237,7 +238,7 @@ impl Auditor { "Run \"composer audit\" for a full list of advisories.".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } else { @@ -246,7 +247,7 @@ impl Auditor { "<info>No security vulnerability advisories found.</info>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -256,13 +257,13 @@ impl Auditor { "<warning>The following repositories were unreachable:</warning>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); for repo in &unreachable_repos { io.write_error( PhpMixed::String(format!(" - {}", repo)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } @@ -603,7 +604,7 @@ impl Auditor { .collect(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -628,7 +629,7 @@ impl Auditor { ], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if format == Self::FORMAT_PLAIN { @@ -647,7 +648,7 @@ impl Auditor { ], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } diff --git a/crates/shirabe/src/cache.rs b/crates/shirabe/src/cache.rs index fb05ce2..5bca3b1 100644 --- a/crates/shirabe/src/cache.rs +++ b/crates/shirabe/src/cache.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Cache.php +use crate::io::io_interface; use std::sync::Mutex; use anyhow::Result; @@ -89,7 +90,7 @@ impl Cache { self.root, )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.enabled = Some(false); } @@ -111,7 +112,7 @@ impl Cache { self.io.write_error( PhpMixed::String(format!("Reading {} from cache", full_path)), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); return file_get_contents(&full_path); @@ -130,7 +131,7 @@ impl Cache { self.io.write_error( PhpMixed::String(format!("Writing {}{} into cache", self.root, file)), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); let temp_file_name = format!("{}{}{}.tmp", self.root, file, bin2hex(&random_bytes(5)),); @@ -161,7 +162,7 @@ impl Cache { e, )), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); let message_match = Preg::is_match_with_indexed_captures( r"{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}", @@ -192,7 +193,7 @@ impl Cache { ); self.io - .write_error(PhpMixed::String(message), true, IOInterface::NORMAL); + .write_error(PhpMixed::String(message), true, io_interface::NORMAL); return Ok(false); } @@ -220,13 +221,13 @@ impl Cache { source, )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else if self.io.is_debug() { self.io.write_error( PhpMixed::String(format!("Writing {} into cache from {}", full_path, source,)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -262,7 +263,7 @@ impl Cache { self.io.write_error( PhpMixed::String(format!("Reading {} from cache", full_path)), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); return Ok(self.filesystem.copy(&full_path, target)); diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs index 0382246..d608a4c 100644 --- a/crates/shirabe/src/command/bump_command.rs +++ b/crates/shirabe/src/command/bump_command.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Command/BumpCommand.php +use crate::io::io_interface; use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::symfony::component::console::command::command::Command; @@ -109,7 +110,7 @@ impl BumpCommand { composer_json_path )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(Self::ERROR_GENERIC); } @@ -124,7 +125,7 @@ impl BumpCommand { composer_json_path )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(Self::ERROR_GENERIC); } @@ -144,7 +145,7 @@ impl BumpCommand { composer_json_path )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(Self::ERROR_GENERIC); } @@ -161,7 +162,7 @@ impl BumpCommand { "<error>The lock file is not up to date with the latest changes in composer.json. Run the appropriate `update` to fix that before you use the `bump` command.</error>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(Self::ERROR_LOCK_OUTDATED); } @@ -176,7 +177,7 @@ impl BumpCommand { "<warning>Warning: Bumping dependency constraints is not recommended for libraries as it will narrow down your dependencies and may cause problems for your users.</warning>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let contents_data = composer_json.read()?; @@ -186,7 +187,7 @@ impl BumpCommand { "If your package is not a library, you can explicitly specify the \"type\" by using \"composer config type project\".".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); io.write_error( PhpMixed::String(format!( @@ -194,7 +195,7 @@ impl BumpCommand { dev_only_flag_hint )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } @@ -286,7 +287,7 @@ impl BumpCommand { composer_json_path )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); for (require_type, packages) in &updates { for (package, version) in packages { @@ -296,7 +297,7 @@ impl BumpCommand { require_type, package, version )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } @@ -307,7 +308,7 @@ impl BumpCommand { composer_json_path, change_count )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } else { @@ -317,7 +318,7 @@ impl BumpCommand { composer_json_path )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } diff --git a/crates/shirabe/src/command/completion_trait.rs b/crates/shirabe/src/command/completion_trait.rs index 8278603..ea2db2b 100644 --- a/crates/shirabe/src/command/completion_trait.rs +++ b/crates/shirabe/src/command/completion_trait.rs @@ -6,7 +6,7 @@ use crate::package::package_interface::PackageInterface; use crate::repository::composite_repository::CompositeRepository; use crate::repository::installed_repository::InstalledRepository; use crate::repository::platform_repository::PlatformRepository; -use crate::repository::repository_interface::RepositoryInterface; +use crate::repository::repository_interface::{self, RepositoryInterface}; use crate::repository::root_package_repository::RootPackageRepository; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::symfony::component::console::completion::completion_input::CompletionInput; @@ -179,7 +179,7 @@ pub trait CompletionTrait { if !input.get_completion_value().contains('/') { let search_results = repos.search( format!("^{}", preg_quote(input.get_completion_value(), None)), - RepositoryInterface::SEARCH_VENDOR, + repository_interface::SEARCH_VENDOR, None, ); results = search_results.iter().map(|r| r.name.clone()).collect(); @@ -192,7 +192,7 @@ pub trait CompletionTrait { if results.len() <= 1 { let search_results = repos.search( format!("^{}", preg_quote(input.get_completion_value(), None)), - RepositoryInterface::SEARCH_NAME, + repository_interface::SEARCH_NAME, None, ); results = search_results.iter().map(|r| r.name.clone()).collect(); diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index 62e630a..a539d69 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Command/ConfigCommand.php +use crate::io::io_interface; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -483,7 +484,7 @@ impl ConfigCommand { self.inner.inner.get_io().write( &format!("{}{}", value_str, source_of_config_value), true, - IOInterface::QUIET, + io_interface::QUIET, ); return Ok(0); @@ -1364,7 +1365,7 @@ impl ConfigCommand { source ), true, - IOInterface::QUIET, + io_interface::QUIET, ); } else { io.write( @@ -1377,7 +1378,7 @@ impl ConfigCommand { source ), true, - IOInterface::QUIET, + io_interface::QUIET, ); } } diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index d8f0113..b43fdea 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Command/InitCommand.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -271,7 +272,7 @@ impl InitCommand { Box::new(PhpMixed::String(String::new())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if !io.ask_confirmation( "Do you confirm generation [<comment>yes</comment>]? ".to_string(), @@ -280,7 +281,7 @@ impl InitCommand { io.write_error( PhpMixed::String("<error>Command aborted</error>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(1); @@ -289,7 +290,7 @@ impl InitCommand { io.write_error( PhpMixed::String(format!("Writing {}", file_obj.get_path())), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -303,7 +304,7 @@ impl InitCommand { "<error>Schema validation error, aborting</error>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let errors = format!( " - {}", @@ -312,7 +313,7 @@ impl InitCommand { io.write_error( PhpMixed::String(format!("{}:{}{}", json_err.message, PHP_EOL, errors)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); Silencer::call( "unlink", @@ -376,7 +377,7 @@ impl InitCommand { autoload_path.as_deref().unwrap_or("") )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); io.write_error( PhpMixed::String( @@ -384,7 +385,7 @@ impl InitCommand { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -493,7 +494,7 @@ impl InitCommand { Box::new(PhpMixed::String(String::new())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); // namespace @@ -507,7 +508,7 @@ impl InitCommand { Box::new(PhpMixed::String(String::new())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut name = input @@ -709,7 +710,7 @@ impl InitCommand { Box::new(PhpMixed::String(String::new())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); // prepare to resolve dependencies @@ -1024,7 +1025,7 @@ impl InitCommand { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } @@ -1040,7 +1041,7 @@ impl InitCommand { self.inner.get_io().write_error( PhpMixed::String("Could not run dump-autoload.".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs index 8fcf2c8..164cc53 100644 --- a/crates/shirabe/src/command/package_discovery_trait.rs +++ b/crates/shirabe/src/command/package_discovery_trait.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Command/PackageDiscoveryTrait.php +use crate::io::io_interface; use std::any::Any; use anyhow::Result; @@ -167,7 +168,7 @@ pub trait PackageDiscoveryTrait { requirement.get("name").map(|s| s.as_str()).unwrap_or(""), )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -198,7 +199,7 @@ pub trait PackageDiscoveryTrait { ], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else { requirement.insert("version".to_string(), "guess".to_string()); @@ -331,7 +332,7 @@ pub trait PackageDiscoveryTrait { Box::new(PhpMixed::String(String::new())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); io.write_error( @@ -342,9 +343,9 @@ pub trait PackageDiscoveryTrait { .collect(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); - io.write_error(PhpMixed::String(String::new()), true, IOInterface::NORMAL); + io.write_error(PhpMixed::String(String::new()), true, io_interface::NORMAL); let matches_clone = matches.clone(); let version_parser_clone = version_parser.clone(); @@ -440,7 +441,7 @@ pub trait PackageDiscoveryTrait { ], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); c diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index 24dda7e..70c3651 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Command/RequireCommand.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -136,7 +137,7 @@ impl RequireCommand { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -148,7 +149,7 @@ impl RequireCommand { self.file )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(1); @@ -157,7 +158,7 @@ impl RequireCommand { io.write_error( PhpMixed::String(format!("<error>{} is not readable.</error>", self.file)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(1); @@ -186,7 +187,7 @@ impl RequireCommand { SignalHandler::SIGHUP, ], Box::new(move |signal: String, handler: &SignalHandler| { - // TODO(phase-b): self.get_io().write_error('Received '.$signal.', aborting', true, IOInterface::DEBUG); + // TODO(phase-b): self.get_io().write_error('Received '.$signal.', aborting', true, io_interface::DEBUG); // TODO(phase-b): self.revert_composer_file(); let _ = signal; handler.exit_with_last_signal(); @@ -209,7 +210,7 @@ impl RequireCommand { io.write_error( PhpMixed::String(format!("<error>{} is not writable.</error>", self.file)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(1); @@ -236,7 +237,7 @@ impl RequireCommand { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if !config.contains_key("type") { @@ -246,7 +247,7 @@ impl RequireCommand { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -425,7 +426,7 @@ impl RequireCommand { &[PhpMixed::String(package.clone())], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(1); @@ -544,7 +545,7 @@ impl RequireCommand { } )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if input.get_option("no-update").as_bool().unwrap_or(false) { @@ -817,7 +818,7 @@ impl RequireCommand { flags, )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let command_event = CommandEvent::new(PluginEvents::COMMAND, "require", input, output); @@ -888,7 +889,7 @@ impl RequireCommand { req.get("name").cloned().unwrap_or_default(), )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); break; } @@ -955,7 +956,7 @@ impl RequireCommand { ], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if Preg::is_match( @@ -1107,7 +1108,7 @@ impl RequireCommand { self.file )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); unlink(self.json.as_ref().unwrap().get_path()); if file_exists(&self.lock) { @@ -1125,7 +1126,7 @@ impl RequireCommand { self.file, msg )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); file_put_contents( self.json.as_ref().unwrap().get_path(), diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs index 28f4fd1..3b0d52e 100644 --- a/crates/shirabe/src/command/search_command.rs +++ b/crates/shirabe/src/command/search_command.rs @@ -8,7 +8,7 @@ use crate::plugin::command_event::CommandEvent; use crate::plugin::plugin_events::PluginEvents; use crate::repository::composite_repository::CompositeRepository; use crate::repository::platform_repository::PlatformRepository; -use crate::repository::repository_interface::RepositoryInterface; +use crate::repository::repository_interface::{self, RepositoryInterface}; use crate::{command::base_command::BaseCommand, composer::Composer}; use anyhow::Result; use indexmap::IndexMap; @@ -98,7 +98,7 @@ impl SearchCommand { .get_event_dispatcher() .dispatch(command_event.get_name(), &command_event); - let mut mode: i64 = RepositoryInterface::SEARCH_FULLTEXT; + let mut mode: i64 = repository_interface::SEARCH_FULLTEXT; if input.get_option("only-name").as_bool().unwrap_or(false) { if input.get_option("only-vendor").as_bool().unwrap_or(false) { return Err(InvalidArgumentException { @@ -107,9 +107,9 @@ impl SearchCommand { } .into()); } - mode = RepositoryInterface::SEARCH_NAME; + mode = repository_interface::SEARCH_NAME; } else if input.get_option("only-vendor").as_bool().unwrap_or(false) { - mode = RepositoryInterface::SEARCH_VENDOR; + mode = repository_interface::SEARCH_VENDOR; } let r#type = input @@ -127,7 +127,7 @@ impl SearchCommand { }) .unwrap_or_default(); let mut query = implode(" ", &token_strings); - if mode != RepositoryInterface::SEARCH_FULLTEXT { + if mode != repository_interface::SEARCH_FULLTEXT { query = preg_quote(&query, None); } diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs index b1b0c06..5f80516 100644 --- a/crates/shirabe/src/command/self_update_command.rs +++ b/crates/shirabe/src/command/self_update_command.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Command/SelfUpdateCommand.php +use crate::io::io_interface; use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::symfony::component::console::command::command::Command; @@ -89,21 +90,21 @@ impl SelfUpdateCommand { "<error>This instance of Composer does not have the self-update command.</error>" .to_string(), ), - IOInterface::NORMAL, + io_interface::NORMAL, ); output.writeln( PhpMixed::String(format!( "<comment>You are running Composer installed as a package in your current project (\"{}\").</comment>", proj_dir )), - IOInterface::NORMAL, + io_interface::NORMAL, ); output.writeln( PhpMixed::String( "<comment>To update Composer, download a composer.phar from https://getcomposer.org and then run `composer.phar update composer/composer` in your project.</comment>" .to_string(), ), - IOInterface::NORMAL, + io_interface::NORMAL, ); } else { output.writeln( @@ -111,14 +112,14 @@ impl SelfUpdateCommand { "<error>This instance of Composer does not have the self-update command.</error>" .to_string(), ), - IOInterface::NORMAL, + io_interface::NORMAL, ); output.writeln( PhpMixed::String( "<comment>This could be due to a number of reasons, such as Composer being installed as a system package on your OS, or Composer being installed as a package in the current project.</comment>" .to_string(), ), - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -245,7 +246,7 @@ impl SelfUpdateCommand { composer_user_name, home, home_owner_name )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } @@ -312,7 +313,7 @@ impl SelfUpdateCommand { skipped_version, update_major_version, update_major_version )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else if version_compare(¤t_major_version, &preview_major_version, "<") { // promote next major version if available in preview @@ -322,7 +323,7 @@ impl SelfUpdateCommand { latest_preview.get("version").and_then(|v| v.as_string()).unwrap_or("") )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } @@ -348,7 +349,7 @@ impl SelfUpdateCommand { latest_stable.get("version").and_then(|v| v.as_string()).unwrap_or("") )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } if latest.contains_key("eol") { @@ -359,7 +360,7 @@ impl SelfUpdateCommand { latest_stable.get("version").and_then(|v| v.as_string()).unwrap_or("") )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -372,7 +373,7 @@ impl SelfUpdateCommand { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(1); @@ -393,7 +394,7 @@ impl SelfUpdateCommand { ], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); // remove all backups except for the most recent, if any @@ -437,7 +438,7 @@ impl SelfUpdateCommand { ], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let remote_filename = format!( "{}{}", @@ -467,10 +468,10 @@ impl SelfUpdateCommand { io.write_error( PhpMixed::String(" ".to_string()), false, - IOInterface::NORMAL, + io_interface::NORMAL, ); http_downloader.copy(&remote_filename, &temp_filename)?; - io.write_error(PhpMixed::String(String::new()), true, IOInterface::NORMAL); + io.write_error(PhpMixed::String(String::new()), true, io_interface::NORMAL); if !file_exists(&temp_filename) || signature.is_none() || signature.as_deref() == Some("") { io.write_error( @@ -479,7 +480,7 @@ impl SelfUpdateCommand { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(1); @@ -494,7 +495,7 @@ impl SelfUpdateCommand { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else { if !extension_loaded("openssl") { @@ -644,7 +645,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ &[PhpMixed::String(Composer::VERSION.to_string())], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else { io.write_error( @@ -653,7 +654,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ backup_file )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -676,7 +677,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); // TODO(phase-b): closure captures none; PHP throws inside the closure on bad input @@ -741,7 +742,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ Keys::fingerprint(&key_path)? )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut tags_key = String::new(); @@ -788,7 +789,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ Keys::fingerprint(&key_path)? )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); io.write( @@ -797,7 +798,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ config.get("home").as_string().unwrap_or("") )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); Ok(()) @@ -862,7 +863,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ &[PhpMixed::String(rollback_version.clone())], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if !self.set_local_phar(local_filename, &old_file, None)? { return Ok(1); @@ -899,7 +900,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ error.unwrap_or_default() )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if backup_target.is_some() { @@ -909,7 +910,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -981,7 +982,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ io.write_error( PhpMixed::String(format!("<info>Removing: {}</info>", file_str)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); fs.remove(&file_str); } @@ -1077,7 +1078,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ local_filename )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let help_message = "Please run the self-update command as an Administrator."; let question = @@ -1090,7 +1091,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ help_message )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return false; @@ -1103,7 +1104,7 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ io.write_error( PhpMixed::String(format!("<error>Operation failed. {}</error>", help_message)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return false; @@ -1168,13 +1169,13 @@ RGv89BPD+2DLnJysngsvVaUCAwEAAQ==\n\ io.write_error( PhpMixed::String("<info>Operation succeeded.</info>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else { io.write_error( PhpMixed::String(format!("<error>Operation failed. {}</error>", help_message)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index aeeb7ba..dca0d07 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Command/UpdateCommand.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -119,7 +120,7 @@ impl UpdateCommand { "<warning>You are using the deprecated option \"--dev\". It has no effect and will break in Composer 3.</warning>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } if input.get_option("no-suggest").as_bool().unwrap_or(false) { @@ -128,7 +129,7 @@ impl UpdateCommand { "<warning>You are using the deprecated option \"--no-suggest\". It has no effect and will break in Composer 3.</warning>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -140,7 +141,7 @@ impl UpdateCommand { "<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -228,7 +229,7 @@ impl UpdateCommand { todo!("root_requirements[package].get_pretty_constraint()"), )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); io.write( PhpMixed::String(format!( @@ -236,7 +237,7 @@ impl UpdateCommand { package, package, constraint, )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(BaseCommand::FAILURE); @@ -339,7 +340,7 @@ impl UpdateCommand { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(-1); @@ -449,7 +450,7 @@ impl UpdateCommand { io.write_error( PhpMixed::String("<info>Bumping dependencies</info>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut bump_command = BumpCommand::new(); bump_command.set_composer(composer.clone()); @@ -511,7 +512,7 @@ impl UpdateCommand { io.write_error( PhpMixed::String("<info>Loading packages that can be updated...</info>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut autocompleter_values: IndexMap<String, String> = IndexMap::new(); let installed_packages = if composer.get_locker().is_locked() { diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs index 12755b0..f2e784a 100644 --- a/crates/shirabe/src/config.rs +++ b/crates/shirabe/src/config.rs @@ -3,6 +3,7 @@ pub mod config_source_interface; pub mod json_config_source; +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -1170,7 +1171,7 @@ impl Config { scheme.as_deref().unwrap_or("") )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } self.warned_hosts.insert(hostname.clone(), true); @@ -1212,7 +1213,7 @@ impl Config { hostname, w )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.ssl_verify_warned_hosts.insert(hostname.clone(), true); } diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 8fb84dc..dec25ce 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Console/Application.php +use crate::io::io_interface; use indexmap::IndexMap; use shirabe_external_packages::composer::xdebug_handler::xdebug_handler::XdebugHandler; @@ -210,7 +211,7 @@ impl Application { ErrorHandler::register(Some(io)); if input.has_parameter_option("--no-cache", false) { - io.write_error("Disabling cache usage", true, IOInterface::DEBUG); + io.write_error("Disabling cache usage", true, io_interface::DEBUG); Platform::put_env( "COMPOSER_CACHE_DIR", if Platform::is_windows() { @@ -239,7 +240,7 @@ impl Application { } ), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); } @@ -478,7 +479,7 @@ impl Application { ], ), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); if PHP_VERSION_ID < 70205 { @@ -724,11 +725,11 @@ impl Application { && self.is_running_as_root() && !self.io.is_interactive() { - io.write_error("<error>Plugins have been disabled automatically as you are running as root, this may be the cause of the script failure.</error>", true, IOInterface::QUIET); + io.write_error("<error>Plugins have been disabled automatically as you are running as root, this may be the cause of the script failure.</error>", true, io_interface::QUIET); io.write_error( "<error>See also https://getcomposer.org/root</error>", true, - IOInterface::QUIET, + io_interface::QUIET, ); } @@ -834,7 +835,7 @@ impl Application { hit = df.map(|d| d < min_space_free).unwrap_or(false); } if hit { - io.write_error(&format!("<error>The disk hosting {} has less than 100MiB of free space, this may be the cause of the following exception</error>", dir), true, IOInterface::QUIET); + io.write_error(&format!("<error>The disk hosting {} has less than 100MiB of free space, this may be the cause of the following exception</error>", dir), true, io_interface::QUIET); } } Ok(()) @@ -848,9 +849,9 @@ impl Application { io.write_error( "<error>The following exception indicates your proxy is misconfigured</error>", true, - IOInterface::QUIET, + io_interface::QUIET, ); - io.write_error("<error>Check https://getcomposer.org/doc/faqs/how-to-use-composer-behind-a-proxy.md for details</error>", true, IOInterface::QUIET); + io.write_error("<error>Check https://getcomposer.org/doc/faqs/how-to-use-composer-behind-a-proxy.md for details</error>", true, io_interface::QUIET); } if Platform::is_windows() @@ -865,18 +866,18 @@ impl Application { .collect(), )) && count(&avast_detect) != 0 { - io.write_error("<error>The following exception indicates a possible issue with the Avast Firewall</error>", true, IOInterface::QUIET); + io.write_error("<error>The following exception indicates a possible issue with the Avast Firewall</error>", true, io_interface::QUIET); io.write_error( "<error>Check https://getcomposer.org/local-issuer for details</error>", true, - IOInterface::QUIET, + io_interface::QUIET, ); } else { - io.write_error("<error>The following exception indicates a possible issue with a Firewall/Antivirus</error>", true, IOInterface::QUIET); + io.write_error("<error>The following exception indicates a possible issue with a Firewall/Antivirus</error>", true, io_interface::QUIET); io.write_error( "<error>Check https://getcomposer.org/local-issuer for details</error>", true, - IOInterface::QUIET, + io_interface::QUIET, ); } } @@ -884,13 +885,13 @@ impl Application { if Platform::is_windows() && strpos(&message, "The system cannot find the path specified").is_some() { - io.write_error("<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>", true, IOInterface::QUIET); - io.write_error("<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>", true, IOInterface::QUIET); + io.write_error("<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>", true, io_interface::QUIET); + io.write_error("<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>", true, io_interface::QUIET); } if strpos(&message, "fork failed - Cannot allocate memory").is_some() { - io.write_error("<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>", true, IOInterface::QUIET); - io.write_error("<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>", true, IOInterface::QUIET); + io.write_error("<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>", true, io_interface::QUIET); + io.write_error("<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>", true, io_interface::QUIET); } if exception @@ -900,28 +901,28 @@ impl Application { io.write_error( "<error>The following exception is caused by a process timeout</error>", true, - IOInterface::QUIET, + io_interface::QUIET, ); - io.write_error("<error>Check https://getcomposer.org/doc/06-config.md#process-timeout for details</error>", true, IOInterface::QUIET); + io.write_error("<error>Check https://getcomposer.org/doc/06-config.md#process-timeout for details</error>", true, io_interface::QUIET); } if self.get_disable_plugins_by_default() && self.is_running_as_root() && !self.io.is_interactive() { - io.write_error("<error>Plugins have been disabled automatically as you are running as root, this may be the cause of the following exception. See also https://getcomposer.org/root</error>", true, IOInterface::QUIET); + io.write_error("<error>Plugins have been disabled automatically as you are running as root, this may be the cause of the following exception. See also https://getcomposer.org/root</error>", true, io_interface::QUIET); } else if exception .downcast_ref::<CommandNotFoundException>() .is_some() && self.get_disable_plugins_by_default() { - io.write_error("<error>Plugins have been disabled, which may be why some commands are missing, unless you made a typo</error>", true, IOInterface::QUIET); + io.write_error("<error>Plugins have been disabled, which may be why some commands are missing, unless you made a typo</error>", true, io_interface::QUIET); } let hints = HttpDownloader::get_exception_hints_from_error(exception); if !hints.is_empty() && count(&hints) > 0 { for hint in &hints { - io.write_error(hint, true, IOInterface::QUIET); + io.write_error(hint, true, io_interface::QUIET); } } } diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs index f518545..de5bacf 100644 --- a/crates/shirabe/src/dependency_resolver/pool_builder.rs +++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/DependencyResolver/PoolBuilder.php +use crate::io::io_interface; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -1042,7 +1043,7 @@ impl PoolBuilder { &[(microtime(true) - before).into()], ), true, - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, ); self.io.write_with_verbosity( &sprintf( @@ -1054,7 +1055,7 @@ impl PoolBuilder { ], ), true, - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, ); pool @@ -1093,7 +1094,7 @@ impl PoolBuilder { &[(microtime(true) - before).into()], ), true, - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, ); self.io.write_with_verbosity( &sprintf( @@ -1105,7 +1106,7 @@ impl PoolBuilder { ], ), true, - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, ); pool diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs index 83ba219..c03f704 100644 --- a/crates/shirabe/src/downloader/download_manager.rs +++ b/crates/shirabe/src/downloader/download_manager.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Downloader/DownloadManager.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -222,7 +223,7 @@ impl DownloadManager { source, )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } // TODO(phase-b): &mut on shared package — PHP mutates by reference @@ -257,7 +258,7 @@ impl DownloadManager { e, )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); retry_state = true; @@ -364,7 +365,7 @@ impl DownloadManager { self.io.write_error( PhpMixed::String(format!("<error> Update failed ({})</error>", e,)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if !self.io.ask_confirmation( " Would you like to try reinstalling the package instead [<comment>yes</comment>]? ".to_string(), diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs index c9c9392..e6b471f 100644 --- a/crates/shirabe/src/downloader/file_downloader.rs +++ b/crates/shirabe/src/downloader/file_downloader.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Downloader/FileDownloader.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use std::sync::{LazyLock, Mutex}; @@ -102,7 +103,7 @@ impl FileDownloader { }; if this.cache.is_some() && this.cache.as_ref().unwrap().gc_is_necessary() { - // PHP: writeError('Running cache garbage collection', true, IOInterface::VERY_VERBOSE) + // PHP: writeError('Running cache garbage collection', true, io_interface::VERY_VERBOSE) this.io.write_error("Running cache garbage collection"); this.cache.as_mut().unwrap().gc( this.config.get("cache-files-ttl").as_int().unwrap_or(0), diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs index 1bc0ff1..45849cb 100644 --- a/crates/shirabe/src/downloader/git_downloader.rs +++ b/crates/shirabe/src/downloader/git_downloader.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Downloader/GitDownloader.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -89,7 +90,7 @@ impl GitDownloader { package.get_full_pretty_version(), )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.inner.io.write_error( PhpMixed::String(sprintf( @@ -97,7 +98,7 @@ impl GitDownloader { &[PhpMixed::String(cache_path.clone())], )), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); let r#ref = package.get_source_reference(); if self.git_util.fetch_ref_or_sync_mirror( @@ -251,7 +252,7 @@ impl GitDownloader { self.inner .io - .write_error(PhpMixed::String(msg), true, IOInterface::NORMAL); + .write_error(PhpMixed::String(msg), true, io_interface::NORMAL); self.git_util.run_commands(commands, url, &path, true); @@ -335,7 +336,7 @@ impl GitDownloader { self.inner .io - .write_error(PhpMixed::String(msg), true, IOInterface::NORMAL); + .write_error(PhpMixed::String(msg), true, io_interface::NORMAL); let mut output = String::new(); if self.inner.process.execute( @@ -694,7 +695,7 @@ impl GitDownloader { package.get_pretty_name() )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let slice_end = 10_usize.min(changes.len()); self.inner.io.write_error( @@ -705,7 +706,7 @@ impl GitDownloader { .collect(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if (changes.len() as i64) > 10 { self.inner.io.write_error( @@ -714,7 +715,7 @@ impl GitDownloader { changes.len() as i64 - 10 )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -762,7 +763,7 @@ impl GitDownloader { .collect(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } Some("d") => { @@ -792,7 +793,7 @@ impl GitDownloader { )), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if update { self.inner.io.write_error( @@ -801,13 +802,13 @@ impl GitDownloader { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } self.inner.io.write_error( PhpMixed::String(" ? - print help".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } @@ -827,7 +828,7 @@ impl GitDownloader { self.inner.io.write_error( PhpMixed::String(" <info>Re-applying stashed changes</info>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut output = String::new(); if self.inner.process.execute( @@ -1058,7 +1059,7 @@ impl GitDownloader { reference )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); exception_extra = format!( "\nIt looks like the commit hash is not available in the repository, maybe {}? Run \"composer update {}\" to resolve this.", @@ -1249,7 +1250,7 @@ impl GitDownloader { self.inner .io - .write_error(PhpMixed::String(output), true, IOInterface::NORMAL); + .write_error(PhpMixed::String(output), true, io_interface::NORMAL); } pub(crate) fn normalize_path(&self, path: &str) -> String { diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs index 33e3b45..c50d390 100644 --- a/crates/shirabe/src/downloader/path_downloader.rs +++ b/crates/shirabe/src/downloader/path_downloader.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Downloader/PathDownloader.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::react::promise::promise_interface::PromiseInterface; @@ -123,7 +124,7 @@ impl PathDownloader { appendix )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -149,7 +150,7 @@ impl PathDownloader { InstallOperation::format(package, false) )), false, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -162,7 +163,7 @@ impl PathDownloader { self.inner.io.write_error( PhpMixed::String(format!("Junctioning from {}", url)), false, - IOInterface::NORMAL, + io_interface::NORMAL, ); } Ok(self.inner.filesystem.junction(&real_url, &path)) @@ -172,7 +173,7 @@ impl PathDownloader { self.inner.io.write_error( PhpMixed::String(format!("Symlinking from {}", url)), false, - IOInterface::NORMAL, + io_interface::NORMAL, ); } if transport_options @@ -211,7 +212,7 @@ impl PathDownloader { self.inner.io.write_error( PhpMixed::String("".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.inner.io.write_error( PhpMixed::String( @@ -219,7 +220,7 @@ impl PathDownloader { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } current_strategy = Self::STRATEGY_MIRROR; @@ -250,7 +251,7 @@ impl PathDownloader { url )), false, - IOInterface::NORMAL, + io_interface::NORMAL, ); } let iterator = ArchivableFilesFinder::new(&real_url, vec![]); @@ -260,7 +261,7 @@ impl PathDownloader { if output { self.inner .io - .write_error(PhpMixed::String("".to_string()), true, IOInterface::NORMAL); + .write_error(PhpMixed::String("".to_string()), true, io_interface::NORMAL); } Ok(shirabe_external_packages::react::promise::resolve(None)) @@ -290,7 +291,7 @@ impl PathDownloader { path )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } if !self.inner.filesystem.remove_junction(&path) { @@ -300,7 +301,7 @@ impl PathDownloader { path )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Err(RuntimeException { message: format!( @@ -347,7 +348,7 @@ impl PathDownloader { path )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs index ef006f3..eb4de65 100644 --- a/crates/shirabe/src/downloader/svn_downloader.rs +++ b/crates/shirabe/src/downloader/svn_downloader.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Downloader/SvnDownloader.php +use crate::io::io_interface; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::react::promise; use shirabe_external_packages::react::promise::promise_interface::PromiseInterface; @@ -70,7 +71,7 @@ impl SvnDownloader { self.inner.io.write_error( PhpMixed::String(format!(" Checking out {}", package.get_source_reference())), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.execute( package, @@ -119,7 +120,7 @@ impl SvnDownloader { self.inner.io.write_error( PhpMixed::String(format!(" Checking out {}", r#ref)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut command = vec!["svn".to_string(), "switch".to_string()]; command.extend(flags); @@ -214,7 +215,7 @@ impl SvnDownloader { if count_changes == 1 { "" } else { "s" } )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let slice_end = 10_usize.min(changes.len()); self.inner.io.write_error( @@ -225,7 +226,7 @@ impl SvnDownloader { .collect(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if count_changes > 10 { let remaining_changes = count_changes - 10; @@ -236,7 +237,7 @@ impl SvnDownloader { if remaining_changes == 1 { "" } else { "s" } )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -270,7 +271,7 @@ impl SvnDownloader { .collect(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } _ => { @@ -288,7 +289,7 @@ impl SvnDownloader { Box::new(PhpMixed::String(" ? - print help".to_string())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } diff --git a/crates/shirabe/src/downloader/vcs_downloader.rs b/crates/shirabe/src/downloader/vcs_downloader.rs index 9ec86ff..05593e5 100644 --- a/crates/shirabe/src/downloader/vcs_downloader.rs +++ b/crates/shirabe/src/downloader/vcs_downloader.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Downloader/VcsDownloader.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::react::promise::promise_interface::PromiseInterface; @@ -138,7 +139,7 @@ pub trait VcsDownloader: self.io_mut().write_error( PhpMixed::String(format!("Failed: [{}] {}", get_class(&e), e,)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else if count(&PhpMixed::List( urls.iter() @@ -149,7 +150,7 @@ pub trait VcsDownloader: self.io_mut().write_error( PhpMixed::String(" Failed, trying the next URL".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } if count(&PhpMixed::List( @@ -232,7 +233,7 @@ pub trait VcsDownloader: InstallOperation::format(package, false) )), false, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut urls = self.prepare_urls(package.get_source_urls()); @@ -252,7 +253,7 @@ pub trait VcsDownloader: self.io_mut().write_error( PhpMixed::String(format!("Failed: [{}] {}", get_class(&e), e,)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else if count(&PhpMixed::List( urls.iter() @@ -263,7 +264,7 @@ pub trait VcsDownloader: self.io_mut().write_error( PhpMixed::String(" Failed, trying the next URL".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } if count(&PhpMixed::List( @@ -304,7 +305,7 @@ pub trait VcsDownloader: UpdateOperation::format(initial, target, false), )), false, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut urls = self.prepare_urls(target.get_source_urls()); @@ -330,7 +331,7 @@ pub trait VcsDownloader: self.io_mut().write_error( PhpMixed::String(format!("Failed: [{}] {}", get_class(&e), e,)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else if count(&PhpMixed::List( urls.iter() @@ -341,7 +342,7 @@ pub trait VcsDownloader: self.io_mut().write_error( PhpMixed::String(" Failed, trying the next URL".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } exception = Some(e); @@ -381,10 +382,10 @@ pub trait VcsDownloader: self.io_mut().write_error( PhpMixed::String(format!(" {}", message)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io_mut() - .write_error(PhpMixed::String(logs), true, IOInterface::NORMAL); + .write_error(PhpMixed::String(logs), true, io_interface::NORMAL); } } @@ -408,7 +409,7 @@ pub trait VcsDownloader: UninstallOperation::format(package, false) )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let promise = self.filesystem_mut().remove_directory_async(path); diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs index 3f6180f..0aeb52b 100644 --- a/crates/shirabe/src/installer.rs +++ b/crates/shirabe/src/installer.rs @@ -15,6 +15,7 @@ pub mod plugin_installer; pub mod project_installer; pub mod suggested_packages_reporter; +use crate::io::io_interface; use indexmap::IndexMap; use shirabe_external_packages::seld::json_lint::parsing_exception::ParsingException; @@ -542,7 +543,7 @@ impl Installer { } ), true, - IOInterface::QUIET, + io_interface::QUIET, ); return Ok(Self::ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE); @@ -618,14 +619,14 @@ impl Installer { self.io.write_error( &format!("<error>{}</error>", err), true, - IOInterface::QUIET, + io_interface::QUIET, ); self.io.write_error(&pretty_problem); if !self.dev_mode { self.io.write_error( "<warning>Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.</warning>", true, - IOInterface::QUIET, + io_interface::QUIET, ); } @@ -645,12 +646,12 @@ impl Installer { count(&pool.as_ref().unwrap()) ), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); self.io.write_error( &format!("Analyzed {} rules to resolve dependencies", rule_set_size), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); pool = None; @@ -735,21 +736,21 @@ impl Installer { self.io.write_error( &format!("Installs: {}", implode(", ", &install_names)), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } if !update_names.is_empty() { self.io.write_error( &format!("Updates: {}", implode(", ", &update_names)), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } if !uninstalls.is_empty() { self.io.write_error( &format!("Removals: {}", implode(", ", &uninstall_names)), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } } @@ -890,7 +891,7 @@ impl Installer { self.io.write_error( &format!("<error>{}</error>", err), true, - IOInterface::QUIET, + io_interface::QUIET, ); self.io.write_error("Your requirements can be resolved successfully when require-dev packages are present."); self.io.write_error("You may need to move packages from require-dev or some of their dependencies to require."); @@ -960,7 +961,7 @@ impl Installer { self.io.write_error( "<warning>Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.</warning>", true, - IOInterface::QUIET, + io_interface::QUIET, ); } @@ -1028,7 +1029,7 @@ impl Installer { self.io.write_error( "<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>", true, - IOInterface::QUIET, + io_interface::QUIET, ); return Ok(Self::ERROR_LOCK_FILE_INVALID); @@ -1048,7 +1049,7 @@ impl Installer { self.io.write_error( &format!("<error>{}</error>", err), true, - IOInterface::QUIET, + io_interface::QUIET, ); self.io.write_error(&pretty_problem); @@ -1111,21 +1112,21 @@ impl Installer { self.io.write_error( &format!("Installs: {}", implode(", ", &installs)), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } if !updates.is_empty() { self.io.write_error( &format!("Updates: {}", implode(", ", &updates)), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } if !uninstalls.is_empty() { self.io.write_error( &format!("Removals: {}", implode(", ", &uninstalls)), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } } @@ -1489,7 +1490,7 @@ impl Installer { self.io.write( "Pool Optimizer was disabled for debugging purposes.", true, - IOInterface::DEBUG, + io_interface::DEBUG, ); return None; diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs index 0e5b3d9..243dde0 100644 --- a/crates/shirabe/src/installer/binary_installer.rs +++ b/crates/shirabe/src/installer/binary_installer.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Installer/BinaryInstaller.php +use crate::io::io_interface; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_php_shim::{ PhpMixed, basename, basename_with_suffix, chmod, dirname, fclose, fgets, file_exists, @@ -65,7 +66,7 @@ impl BinaryInstaller { package.get_name(), )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); continue; } @@ -77,7 +78,7 @@ impl BinaryInstaller { package.get_name(), )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); continue; } @@ -100,7 +101,7 @@ impl BinaryInstaller { package.get_name(), )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } continue; @@ -200,7 +201,7 @@ impl BinaryInstaller { package.get_name(), )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs index 3362d86..798ea00 100644 --- a/crates/shirabe/src/installer/installation_manager.rs +++ b/crates/shirabe/src/installer/installation_manager.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Installer/InstallationManager.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::react::promise; @@ -414,7 +415,7 @@ impl InstallationManager { self.io.write_error( PhpMixed::String(format!(" - {}", operation.show(false))), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } // PHP: $this->{$opType}($repo, $operation); @@ -532,7 +533,7 @@ impl InstallationManager { // ProgressBar in non-decorated output does not output a final line-break and clear() does nothing if !self.io.is_decorated() { self.io - .write_error(PhpMixed::String(String::new()), true, IOInterface::NORMAL); + .write_error(PhpMixed::String(String::new()), true, io_interface::NORMAL); } } } diff --git a/crates/shirabe/src/installer/metapackage_installer.rs b/crates/shirabe/src/installer/metapackage_installer.rs index 0a5f872..3a47f70 100644 --- a/crates/shirabe/src/installer/metapackage_installer.rs +++ b/crates/shirabe/src/installer/metapackage_installer.rs @@ -4,6 +4,7 @@ use crate::dependency_resolver::operation::install_operation::InstallOperation; use crate::dependency_resolver::operation::uninstall_operation::UninstallOperation; use crate::dependency_resolver::operation::update_operation::UpdateOperation; use crate::installer::installer_interface::InstallerInterface; +use crate::io::io_interface; use crate::io::io_interface::IOInterface; use crate::package::package_interface::PackageInterface; use crate::repository::installed_repository_interface::InstalledRepositoryInterface; @@ -75,7 +76,7 @@ impl InstallerInterface for MetapackageInstaller { self.io.write_error( &format!(" - {}", InstallOperation::format(package, false)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); repo.add_package(package.clone_box()); @@ -102,7 +103,7 @@ impl InstallerInterface for MetapackageInstaller { self.io.write_error( &format!(" - {}", UpdateOperation::format(initial, target, false)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); repo.remove_package(initial); @@ -129,7 +130,7 @@ impl InstallerInterface for MetapackageInstaller { self.io.write_error( &format!(" - {}", UninstallOperation::format(package, false)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); repo.remove_package(package); diff --git a/crates/shirabe/src/io/base_io.rs b/crates/shirabe/src/io/base_io.rs index ddccd98..aa81d7b 100644 --- a/crates/shirabe/src/io/base_io.rs +++ b/crates/shirabe/src/io/base_io.rs @@ -1,6 +1,8 @@ //! ref: composer/src/Composer/IO/BaseIO.php use crate::config::Config; +use crate::io::io_interface; +use crate::io::io_interface; use crate::io::io_interface::IOInterface; use crate::util::process_executor::ProcessExecutor; use crate::util::silencer::Silencer; @@ -80,7 +82,7 @@ pub trait BaseIO: IOInterface { repository_name )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } self.set_authentication(repository_name, username, password); @@ -363,7 +365,7 @@ pub trait BaseIO: IOInterface { domain )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); continue; } @@ -483,28 +485,28 @@ pub trait BaseIO: IOInterface { self.write_error( PhpMixed::String(format!("<error>{}</error>", message_str)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else if level_str == LogLevel::WARNING { self.write_error( PhpMixed::String(format!("<warning>{}</warning>", message_str)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else if level_str == LogLevel::NOTICE { self.write_error( PhpMixed::String(format!("<info>{}</info>", message_str)), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } else if level_str == LogLevel::INFO { self.write_error( PhpMixed::String(format!("<info>{}</info>", message_str)), true, - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, ); } else { - self.write_error(PhpMixed::String(message_str), true, IOInterface::DEBUG); + self.write_error(PhpMixed::String(message_str), true, io_interface::DEBUG); } } } diff --git a/crates/shirabe/src/io/console_io.rs b/crates/shirabe/src/io/console_io.rs index f2c09ac..6a2edc7 100644 --- a/crates/shirabe/src/io/console_io.rs +++ b/crates/shirabe/src/io/console_io.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/IO/ConsoleIO.php +use crate::io::io_interface; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::symfony::component::console::helper::helper_set::HelperSet; @@ -50,14 +51,14 @@ impl ConsoleIO { helper_set: HelperSet, ) -> Self { let mut verbosity_map = IndexMap::new(); - verbosity_map.insert(IOInterface::QUIET, OutputInterface::VERBOSITY_QUIET); - verbosity_map.insert(IOInterface::NORMAL, OutputInterface::VERBOSITY_NORMAL); - verbosity_map.insert(IOInterface::VERBOSE, OutputInterface::VERBOSITY_VERBOSE); + verbosity_map.insert(io_interface::QUIET, OutputInterface::VERBOSITY_QUIET); + verbosity_map.insert(io_interface::NORMAL, OutputInterface::VERBOSITY_NORMAL); + verbosity_map.insert(io_interface::VERBOSE, OutputInterface::VERBOSITY_VERBOSE); verbosity_map.insert( - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, OutputInterface::VERBOSITY_VERY_VERBOSE, ); - verbosity_map.insert(IOInterface::DEBUG, OutputInterface::VERBOSITY_DEBUG); + verbosity_map.insert(io_interface::DEBUG, OutputInterface::VERBOSITY_DEBUG); Self { inner: BaseIO { authentications: IndexMap::new(), diff --git a/crates/shirabe/src/io/io_interface.rs b/crates/shirabe/src/io/io_interface.rs index 446f47c..d66552d 100644 --- a/crates/shirabe/src/io/io_interface.rs +++ b/crates/shirabe/src/io/io_interface.rs @@ -5,13 +5,13 @@ use indexmap::IndexMap; use shirabe_external_packages::psr::log::logger_interface::LoggerInterface; use shirabe_php_shim::PhpMixed; -pub trait IOInterface: LoggerInterface { - const QUIET: i64 = 1; - const NORMAL: i64 = 2; - const VERBOSE: i64 = 4; - const VERY_VERBOSE: i64 = 8; - const DEBUG: i64 = 16; +pub const QUIET: i64 = 1; +pub const NORMAL: i64 = 2; +pub const VERBOSE: i64 = 4; +pub const VERY_VERBOSE: i64 = 8; +pub const DEBUG: i64 = 16; +pub trait IOInterface: LoggerInterface { fn is_interactive(&self) -> bool; fn is_verbose(&self) -> bool; @@ -65,11 +65,11 @@ pub trait IOInterface: LoggerInterface { fn get_authentication(&self, repository_name: &str) -> IndexMap<String, Option<String>>; fn set_authentication( - &self, + &mut self, repository_name: String, username: String, password: Option<String>, ); - fn load_configuration(&self, config: &Config); + fn load_configuration(&mut self, config: &Config); } diff --git a/crates/shirabe/src/io/null_io.rs b/crates/shirabe/src/io/null_io.rs index af0296d..66f7123 100644 --- a/crates/shirabe/src/io/null_io.rs +++ b/crates/shirabe/src/io/null_io.rs @@ -78,6 +78,44 @@ impl IOInterface for NullIO { ) -> PhpMixed { default } + + fn write_raw(&self, messages: PhpMixed, newline: bool, verbosity: i64) { + <Self as BaseIO>::write_raw(self, messages, newline, verbosity) + } + + fn write_error_raw(&self, messages: PhpMixed, newline: bool, verbosity: i64) { + <Self as BaseIO>::write_error_raw(self, messages, newline, verbosity) + } + + fn get_authentications( + &self, + ) -> indexmap::IndexMap<String, indexmap::IndexMap<String, Option<String>>> { + <Self as BaseIO>::get_authentications(self) + } + + fn has_authentication(&self, repository_name: &str) -> bool { + <Self as BaseIO>::has_authentication(self, repository_name) + } + + fn get_authentication( + &self, + repository_name: &str, + ) -> indexmap::IndexMap<String, Option<String>> { + <Self as BaseIO>::get_authentication(self, repository_name) + } + + fn set_authentication( + &mut self, + repository_name: String, + username: String, + password: Option<String>, + ) { + <Self as BaseIO>::set_authentication(self, repository_name, username, password) + } + + fn load_configuration(&mut self, config: &crate::config::Config) { + <Self as BaseIO>::load_configuration(self, config) + } } impl BaseIO for NullIO { diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs index 89cfbb1..c1fa495 100644 --- a/crates/shirabe/src/json/json_file.rs +++ b/crates/shirabe/src/json/json_file.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Json/JsonFile.php +use crate::io::io_interface; use crate::util::silencer::Silencer; use anyhow::Result; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -122,7 +123,7 @@ impl JsonFile { io.write_error( PhpMixed::String(format!("Reading {}{}", self.path, realpath_info)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs index b813bbb..e370339 100644 --- a/crates/shirabe/src/package/locker.rs +++ b/crates/shirabe/src/package/locker.rs @@ -24,7 +24,7 @@ use crate::package::loader::array_loader::ArrayLoader; use crate::package::package_interface::PackageInterface; use crate::package::root_package_interface::RootPackageInterface; use crate::package::version::version_parser::VersionParser; -use crate::plugin::plugin_interface::PluginInterface; +use crate::plugin::plugin_interface::{self, PluginInterface}; use crate::repository::installed_repository::InstalledRepository; use crate::repository::lock_array_repository::LockArrayRepository; use crate::repository::platform_repository::PlatformRepository; @@ -584,7 +584,7 @@ impl Locker { } lock.insert( "plugin-api-version".to_string(), - PhpMixed::String(PluginInterface::PLUGIN_API_VERSION.to_string()), + PhpMixed::String(plugin_interface::PLUGIN_API_VERSION.to_string()), ); let lock = self.fixup_json_data_type(lock); diff --git a/crates/shirabe/src/package/version/version_selector.rs b/crates/shirabe/src/package/version/version_selector.rs index f665320..5cbc052 100644 --- a/crates/shirabe/src/package/version/version_selector.rs +++ b/crates/shirabe/src/package/version/version_selector.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Package/Version/VersionSelector.php +use crate::io::io_interface; use std::any::Any; use indexmap::IndexMap; @@ -190,9 +191,9 @@ impl VersionSelector { )), true, if is_first_warning { - IOInterface::NORMAL + io_interface::NORMAL } else { - IOInterface::VERBOSE + io_interface::VERBOSE }, ); } diff --git a/crates/shirabe/src/plugin/plugin_interface.rs b/crates/shirabe/src/plugin/plugin_interface.rs index ae64034..d536380 100644 --- a/crates/shirabe/src/plugin/plugin_interface.rs +++ b/crates/shirabe/src/plugin/plugin_interface.rs @@ -3,9 +3,9 @@ use crate::composer::Composer; use crate::io::io_interface::IOInterface; -pub trait PluginInterface { - const PLUGIN_API_VERSION: &'static str = "2.9.0"; +pub const PLUGIN_API_VERSION: &'static str = "2.9.0"; +pub trait PluginInterface { fn activate(&mut self, composer: &Composer, io: &dyn IOInterface); fn deactivate(&mut self, composer: &Composer, io: &dyn IOInterface); diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs index 430b0a4..4ebe48b 100644 --- a/crates/shirabe/src/plugin/plugin_manager.rs +++ b/crates/shirabe/src/plugin/plugin_manager.rs @@ -30,7 +30,7 @@ use crate::partial_composer::PartialComposer; use crate::plugin::capability::capability::Capability; use crate::plugin::capable::Capable; use crate::plugin::plugin_blocked_exception::PluginBlockedException; -use crate::plugin::plugin_interface::PluginInterface; +use crate::plugin::plugin_interface::{self, PluginInterface}; use crate::repository::installed_repository::InstalledRepository; use crate::repository::repository_interface::RepositoryInterface; use crate::repository::repository_utils::RepositoryUtils; @@ -347,7 +347,7 @@ impl PluginManager { /// Returns the version of the internal composer-plugin-api package. pub(crate) fn get_plugin_api_version(&self) -> String { - PluginInterface::PLUGIN_API_VERSION.to_string() + plugin_interface::PLUGIN_API_VERSION.to_string() } /// Adds a plugin, activates it and registers it with the event dispatcher diff --git a/crates/shirabe/src/repository/artifact_repository.rs b/crates/shirabe/src/repository/artifact_repository.rs index a9832a1..d869156 100644 --- a/crates/shirabe/src/repository/artifact_repository.rs +++ b/crates/shirabe/src/repository/artifact_repository.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Repository/ArtifactRepository.php +use crate::io::io_interface; use std::path::Path; use indexmap::IndexMap; @@ -111,7 +112,7 @@ impl ArtifactRepository { basename ), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } Some(package) => { @@ -123,7 +124,7 @@ impl ArtifactRepository { basename, ), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); self.inner.add_package(package); } @@ -168,7 +169,7 @@ impl ArtifactRepository { self.io.write( &format!("Failed loading package {}: {}", pathname, exception), false, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); } } diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs index 5c6bec7..cda3401 100644 --- a/crates/shirabe/src/repository/platform_repository.rs +++ b/crates/shirabe/src/repository/platform_repository.rs @@ -160,7 +160,7 @@ impl PlatformRepository { composer.set_description("Composer package".to_string()); self.add_package(Box::new(composer))?; - pretty_version = <dyn PluginInterface>::PLUGIN_API_VERSION.to_string(); + pretty_version = plugin_interface::PLUGIN_API_VERSION.to_string(); version = self .version_parser .as_ref() diff --git a/crates/shirabe/src/repository/repository_interface.rs b/crates/shirabe/src/repository/repository_interface.rs index 15c85f0..777d3f6 100644 --- a/crates/shirabe/src/repository/repository_interface.rs +++ b/crates/shirabe/src/repository/repository_interface.rs @@ -35,11 +35,11 @@ pub struct ProviderInfo { pub r#type: String, } -pub trait RepositoryInterface: Countable { - const SEARCH_FULLTEXT: i64 = 0; - const SEARCH_NAME: i64 = 1; - const SEARCH_VENDOR: i64 = 2; +pub const SEARCH_FULLTEXT: i64 = 0; +pub const SEARCH_NAME: i64 = 1; +pub const SEARCH_VENDOR: i64 = 2; +pub trait RepositoryInterface: Countable { fn has_package(&self, package: &dyn PackageInterface) -> bool; fn find_package( diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs index c03f217..2efbfb7 100644 --- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs +++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Repository/Vcs/ForgejoDriver.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -489,7 +490,7 @@ impl ForgejoDriver { url )), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); return false; @@ -655,7 +656,7 @@ impl ForgejoDriver { ssh_url )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); Err(e) } diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs index f1e6a89..cd3ae3a 100644 --- a/crates/shirabe/src/repository/vcs/fossil_driver.rs +++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Repository/Vcs/FossilDriver.php +use crate::io::io_interface; use chrono::{DateTime, Utc}; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -133,7 +134,7 @@ impl FossilDriver { self.inner.process.get_error_output() )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } else { diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index 0e16ced..fb667b7 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Repository/Vcs/GitBitbucketDriver.php +use crate::io::io_interface; use anyhow::Result; use chrono::{DateTime, Utc}; use indexmap::IndexMap; @@ -843,8 +844,8 @@ impl GitBitbucketDriver { url ), ); - // PHP: writeError(..., true, IOInterface::VERBOSE) - // TODO(phase-b): IOInterface::VERBOSE verbosity argument + // PHP: writeError(..., true, io_interface::VERBOSE) + // TODO(phase-b): io_interface::VERBOSE verbosity argument return false; } diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs index 48aa4c1..40ad179 100644 --- a/crates/shirabe/src/repository/vcs/git_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_driver.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Repository/Vcs/GitDriver.php +use crate::io::io_interface; use chrono::TimeZone; use chrono::{DateTime, Utc}; use indexmap::IndexMap; @@ -117,7 +118,7 @@ impl GitDriver { self.inner.url )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs index 233e3ea..7bf15bf 100644 --- a/crates/shirabe/src/repository/vcs/github_driver.rs +++ b/crates/shirabe/src/repository/vcs/github_driver.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Repository/Vcs/GitHubDriver.php +use crate::io::io_interface; use anyhow::Result; use chrono::{DateTime, Utc}; use indexmap::IndexMap; @@ -628,7 +629,7 @@ impl GitHubDriver { item_url )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); keys_to_remove.push(key_idx); } @@ -901,7 +902,7 @@ impl GitHubDriver { url )), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); return false; @@ -1062,7 +1063,7 @@ impl GitHubDriver { self.inner.url )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Err(e); } @@ -1091,7 +1092,7 @@ impl GitHubDriver { ], )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -1211,7 +1212,7 @@ impl GitHubDriver { self.generate_ssh_url() )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); Err(setup_err) } diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index 583f221..dea1bf6 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Repository/Vcs/GitLabDriver.php +use crate::io::io_interface; use anyhow::Result; use chrono::{DateTime, Utc}; use indexmap::IndexMap; @@ -684,7 +685,7 @@ impl GitLabDriver { url )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); Err(e) } @@ -785,7 +786,7 @@ impl GitLabDriver { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.attempt_clone_fallback() @@ -887,7 +888,7 @@ impl GitLabDriver { self.namespace, self.repository, e.message )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); git_lab_util.authorize_oauth_interactively( &self.scheme, @@ -969,7 +970,7 @@ impl GitLabDriver { url )), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); return false; diff --git a/crates/shirabe/src/repository/vcs/hg_driver.rs b/crates/shirabe/src/repository/vcs/hg_driver.rs index a8fc70a..3f27d7a 100644 --- a/crates/shirabe/src/repository/vcs/hg_driver.rs +++ b/crates/shirabe/src/repository/vcs/hg_driver.rs @@ -2,6 +2,7 @@ use crate::cache::Cache; use crate::config::Config; +use crate::io::io_interface; use crate::io::io_interface::IOInterface; use crate::repository::vcs::vcs_driver::VcsDriverBase; use crate::util::filesystem::Filesystem; @@ -79,7 +80,7 @@ impl HgDriver { self.inner.io.write_error( format!("<error>Failed to update {}, package information from this repository may be outdated ({})</error>", self.inner.url, self.inner.process.get_error_output()).into(), true, - crate::io::io_interface::IOInterface::NORMAL, + crate::io::io_interface::io_interface::NORMAL, ); } } else { diff --git a/crates/shirabe/src/repository/vcs_repository.rs b/crates/shirabe/src/repository/vcs_repository.rs index 57e44a5..961ea55 100644 --- a/crates/shirabe/src/repository/vcs_repository.rs +++ b/crates/shirabe/src/repository/vcs_repository.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Repository/VcsRepository.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -397,7 +398,7 @@ impl VcsRepository { PhpMixed::String(msg.clone()), false, None, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -556,7 +557,7 @@ impl VcsRepository { PhpMixed::String(String::new()), false, None, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -592,7 +593,7 @@ impl VcsRepository { PhpMixed::String(msg.clone()), false, None, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -738,7 +739,7 @@ impl VcsRepository { PhpMixed::String(String::new()), false, None, - IOInterface::NORMAL, + io_interface::NORMAL, ); } @@ -910,7 +911,7 @@ impl VcsRepository { PhpMixed::String(msg.clone()), false, None, - IOInterface::NORMAL, + io_interface::NORMAL, ); } diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs index 98c2471..33d0b54 100644 --- a/crates/shirabe/src/util/auth_helper.rs +++ b/crates/shirabe/src/util/auth_helper.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Util/AuthHelper.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; @@ -157,7 +158,7 @@ impl AuthHelper { sso_url, ); self.io - .write_error(PhpMixed::String(message), true, IOInterface::NORMAL); + .write_error(PhpMixed::String(message), true, io_interface::NORMAL); if !self.io.is_interactive() { return Err(TransportException::new( format!("Could not authenticate against {}", origin), @@ -448,7 +449,7 @@ impl AuthHelper { origin, )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let username = self.io.ask(" Username: ".to_string(), PhpMixed::Null); let password = self.io.ask_and_hide_answer(" Password: ".to_string()); @@ -671,7 +672,7 @@ impl AuthHelper { self.io.write_error( PhpMixed::String(display_message.clone()), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); self.displayed_origin_authentications .insert(origin.to_string(), display_message.clone()); diff --git a/crates/shirabe/src/util/bitbucket.rs b/crates/shirabe/src/util/bitbucket.rs index fd7aafc..c6aa874 100644 --- a/crates/shirabe/src/util/bitbucket.rs +++ b/crates/shirabe/src/util/bitbucket.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Util/Bitbucket.php +use crate::io::io_interface; use indexmap::IndexMap; use shirabe_php_shim::{LogicException, PhpMixed, time}; @@ -117,33 +118,33 @@ impl Bitbucket { "<error>Invalid OAuth consumer provided.</error>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String("This can have three reasons:".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "1. You are authenticating with a bitbucket username/password combination".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "2. You are using an OAuth consumer, but didn't configure a (dummy) callback url".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "3. You are using an OAuth consumer, but didn't configure it as private consumer".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(false); } @@ -153,14 +154,14 @@ impl Bitbucket { "<error>Invalid OAuth consumer provided.</error>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "You can also add it manually later by using \"composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>\"".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(false); } @@ -203,8 +204,11 @@ impl Bitbucket { message: Option<&str>, ) -> anyhow::Result<bool> { if let Some(msg) = message { - self.io - .write_error(PhpMixed::String(msg.to_string()), true, IOInterface::NORMAL); + self.io.write_error( + PhpMixed::String(msg.to_string()), + true, + io_interface::NORMAL, + ); } let local_auth_config = self.config.get_local_auth_config_source(); @@ -213,10 +217,13 @@ impl Bitbucket { self.io.write_error( PhpMixed::String("Follow the instructions here:".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, + ); + self.io.write_error( + PhpMixed::String(url.to_string()), + true, + io_interface::NORMAL, ); - self.io - .write_error(PhpMixed::String(url.to_string()), true, IOInterface::NORMAL); let auth_config_source_name = self.config.get_auth_config_source().get_name(); let local_name_prefix = local_auth_config .as_ref() @@ -228,14 +235,14 @@ impl Bitbucket { local_name_prefix + &auth_config_source_name )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "Ensure you enter a \"Callback URL\" (http://example.com is fine) or it will not be possible to create an Access Token (this callback url will not be used by composer)".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut store_in_local_auth_config = false; @@ -258,14 +265,14 @@ impl Bitbucket { self.io.write_error( PhpMixed::String("<warning>No consumer key given, aborting.</warning>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "You can also add it manually later by using \"composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>\"".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(false); } @@ -283,14 +290,14 @@ impl Bitbucket { "<warning>No consumer secret given, aborting.</warning>".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "You can also add it manually later by using \"composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>\"".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(false); } @@ -332,7 +339,7 @@ impl Bitbucket { self.io.write_error( PhpMixed::String("<info>Consumer stored successfully.</info>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); Ok(true) diff --git a/crates/shirabe/src/util/forgejo.rs b/crates/shirabe/src/util/forgejo.rs index 7f62fb9..15081fc 100644 --- a/crates/shirabe/src/util/forgejo.rs +++ b/crates/shirabe/src/util/forgejo.rs @@ -2,6 +2,7 @@ use crate::config::Config; use crate::downloader::transport_exception::TransportException; +use crate::io::io_interface; use crate::io::io_interface::IOInterface; use crate::util::http_downloader::HttpDownloader; @@ -28,16 +29,16 @@ impl Forgejo { message: Option<&str>, ) -> anyhow::Result<Result<bool, TransportException>> { if let Some(message) = message { - self.io.write_error(message, true, IOInterface::NORMAL); + self.io.write_error(message, true, io_interface::NORMAL); } let url = format!("https://{}/user/settings/applications", origin_url); self.io.write_error( "Setup a personal access token with repository:read permissions on:", true, - IOInterface::NORMAL, + io_interface::NORMAL, ); - self.io.write_error(&url, true, IOInterface::NORMAL); + self.io.write_error(&url, true, io_interface::NORMAL); let local_auth_config = self.config.get_local_auth_config_source(); self.io.write_error( &format!( @@ -49,12 +50,12 @@ impl Forgejo { + self.config.get_auth_config_source().get_name() ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( "For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#forgejo-token", true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut store_in_local_auth_config = false; @@ -80,10 +81,10 @@ impl Forgejo { self.io.write_error( "<warning>No username/token given, aborting.</warning>", true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io - .write_error(&add_token_manually, true, IOInterface::NORMAL); + .write_error(&add_token_manually, true, io_interface::NORMAL); return Ok(Ok(false)); } @@ -103,10 +104,10 @@ impl Forgejo { self.io.write_error( "<error>Invalid access token provided.</error>", true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io - .write_error(&add_token_manually, true, IOInterface::NORMAL); + .write_error(&add_token_manually, true, io_interface::NORMAL); return Ok(Ok(false)); } @@ -138,7 +139,7 @@ impl Forgejo { self.io.write_error( "<info>Token stored successfully.</info>", true, - IOInterface::NORMAL, + io_interface::NORMAL, ); Ok(Ok(true)) diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs index 62d1e0e..8fe66a4 100644 --- a/crates/shirabe/src/util/git.rs +++ b/crates/shirabe/src/util/git.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Util/Git.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use std::sync::Mutex; @@ -75,7 +76,7 @@ impl Git { io.write_error( PhpMixed::String(format!("<warning>{}</warning>", msg)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } @@ -540,7 +541,7 @@ impl Git { .to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); if run_commands_inline( &ssh_url, @@ -679,12 +680,12 @@ impl Git { m2 )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String(format!("<warning>{}</warning>", trim(&error_msg, None))), true, - IOInterface::VERBOSE, + io_interface::VERBOSE, ); let mut auth_map: IndexMap<String, Option<String>> = IndexMap::new(); auth_map.insert( @@ -792,7 +793,7 @@ impl Git { url )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(false); @@ -857,7 +858,7 @@ impl Git { self.io.write_error( PhpMixed::String(format!("<error>Sync mirror failed: {}</error>", e)), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); return Ok(false); @@ -1173,7 +1174,7 @@ impl Git { e )), true, - IOInterface::DEBUG, + io_interface::DEBUG, ); None } diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs index 9911084..c04873f 100644 --- a/crates/shirabe/src/util/github.rs +++ b/crates/shirabe/src/util/github.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Util/GitHub.php +use crate::io::io_interface; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_php_shim::{PhpMixed, date, stripos, strtolower}; @@ -80,8 +81,11 @@ impl GitHub { message: Option<&str>, ) -> anyhow::Result<bool> { if let Some(msg) = message { - self.io - .write_error(PhpMixed::String(msg.to_string()), true, IOInterface::NORMAL); + self.io.write_error( + PhpMixed::String(msg.to_string()), + true, + io_interface::NORMAL, + ); } let mut note = "Composer".to_string(); @@ -127,7 +131,7 @@ impl GitHub { Box::new(PhpMixed::String(String::new())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let encoded_note = shirabe_php_shim::rawurlencode(¬e).replace("%20", "+"); @@ -149,7 +153,7 @@ impl GitHub { Box::new(PhpMixed::String(String::new())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( @@ -170,7 +174,7 @@ impl GitHub { Box::new(PhpMixed::String(String::new())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( @@ -194,7 +198,7 @@ impl GitHub { Box::new(PhpMixed::String(String::new())), ]), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( @@ -202,7 +206,7 @@ impl GitHub { "For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut store_in_local_auth_config = false; @@ -225,14 +229,14 @@ impl GitHub { self.io.write_error( PhpMixed::String("<warning>No token given, aborting.</warning>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "You can also add it manually later by using \"composer config --global --auth github-oauth.github.com <token>\"".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(false); } @@ -266,14 +270,14 @@ impl GitHub { self.io.write_error( PhpMixed::String("<error>Invalid token provided.</error>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "You can also add it manually later by using \"composer config --global --auth github-oauth.github.com <token>\"".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(false); } @@ -307,7 +311,7 @@ impl GitHub { self.io.write_error( PhpMixed::String("<info>Token stored successfully.</info>".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); Ok(true) diff --git a/crates/shirabe/src/util/gitlab.rs b/crates/shirabe/src/util/gitlab.rs index 054dc9a..7788ed8 100644 --- a/crates/shirabe/src/util/gitlab.rs +++ b/crates/shirabe/src/util/gitlab.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Util/GitLab.php +use crate::io::io_interface; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_php_shim::{PhpMixed, RuntimeException, http_build_query, json_decode, time}; @@ -167,8 +168,11 @@ impl GitLab { message: Option<&str>, ) -> anyhow::Result<bool> { if let Some(msg) = message { - self.io - .write_error(PhpMixed::String(msg.to_string()), true, IOInterface::NORMAL); + self.io.write_error( + PhpMixed::String(msg.to_string()), + true, + io_interface::NORMAL, + ); } let local_auth_config = self.config.get_local_auth_config_source(); @@ -187,44 +191,44 @@ impl GitLab { + &self.config.get_auth_config_source().get_name() )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String("To revoke access to this token you can visit:".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String(revoke_link.clone()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String( "Alternatively you can setup an personal access token on:".to_string(), ), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String(personal_access_token_link.clone()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String("and store it under \"gitlab-token\" see https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token for more details.".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String("https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String("for more details.".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); let mut store_in_local_auth_config = false; @@ -260,32 +264,32 @@ impl GitLab { self.io.write_error( PhpMixed::String("Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else { self.io.write_error( PhpMixed::String("Bad credentials.".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } else { self.io.write_error( PhpMixed::String("Maximum number of login attempts exceeded. Please try again later.".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); } self.io.write_error( PhpMixed::String("You can also manually create a personal access token enabling the \"read_api\" scope at:".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String(personal_access_token_link.clone()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.io.write_error( PhpMixed::String(format!( @@ -293,7 +297,7 @@ impl GitLab { origin_url )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); continue; @@ -374,7 +378,7 @@ impl GitLab { self.io.write_error( PhpMixed::String(format!("Couldn't refresh access token: {}", te.message)), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); return Ok(false); } @@ -459,7 +463,7 @@ impl GitLab { self.io.write_error( PhpMixed::String("Token successfully created".to_string()), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); Ok(token) @@ -548,7 +552,7 @@ impl GitLab { self.io.write_error( PhpMixed::String("GitLab token successfully refreshed".to_string()), true, - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, ); self.io.write_error( PhpMixed::String(format!( @@ -556,7 +560,7 @@ impl GitLab { scheme, origin_url )), true, - IOInterface::VERY_VERBOSE, + io_interface::VERY_VERBOSE, ); Ok(token) diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs index 2d97322..6351a73 100644 --- a/crates/shirabe/src/util/process_executor.rs +++ b/crates/shirabe/src/util/process_executor.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Util/ProcessExecutor.php +use crate::io::io_interface; use anyhow::Result; use indexmap::IndexMap; use std::sync::{LazyLock, Mutex}; @@ -361,13 +362,13 @@ impl ProcessExecutor { self.io.as_ref().unwrap().write_error_raw( PhpMixed::String(buffer.to_string()), false, - IOInterface::NORMAL, + io_interface::NORMAL, ); } else { self.io.as_ref().unwrap().write_raw( PhpMixed::String(buffer.to_string()), false, - IOInterface::NORMAL, + io_interface::NORMAL, ); } } diff --git a/crates/shirabe/src/util/svn.rs b/crates/shirabe/src/util/svn.rs index f1a900c..b312ec3 100644 --- a/crates/shirabe/src/util/svn.rs +++ b/crates/shirabe/src/util/svn.rs @@ -1,5 +1,6 @@ //! ref: composer/src/Composer/Util/Svn.php +use crate::io::io_interface; use std::sync::Mutex; use anyhow::Result; @@ -142,7 +143,7 @@ impl Svn { // PHP: $output .= $buffer; output.get_or_insert_with(String::new).push_str(buffer); if verbose { - // self.io.write_error(PhpMixed::String(buffer.to_string()), false, IOInterface::NORMAL); + // self.io.write_error(PhpMixed::String(buffer.to_string()), false, io_interface::NORMAL); } None }; @@ -216,7 +217,7 @@ impl Svn { self.url, )), true, - IOInterface::NORMAL, + io_interface::NORMAL, ); self.has_auth = Some(true); |
