diff options
Diffstat (limited to 'crates/shirabe/src')
179 files changed, 973 insertions, 1176 deletions
diff --git a/crates/shirabe/src/advisory/mod.rs b/crates/shirabe/src/advisory.rs index dbb90bd..dbb90bd 100644 --- a/crates/shirabe/src/advisory/mod.rs +++ b/crates/shirabe/src/advisory.rs diff --git a/crates/shirabe/src/advisory/audit_config.rs b/crates/shirabe/src/advisory/audit_config.rs index 28e5e68..458ebef 100644 --- a/crates/shirabe/src/advisory/audit_config.rs +++ b/crates/shirabe/src/advisory/audit_config.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Advisory/AuditConfig.php -use indexmap::IndexMap; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed}; - use crate::advisory::Auditor; use crate::config::Config; +use indexmap::IndexMap; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed}; #[derive(Debug, Clone)] pub struct AuditConfig { diff --git a/crates/shirabe/src/advisory/auditor.rs b/crates/shirabe/src/advisory/auditor.rs index 4331b7b..be78f4b 100644 --- a/crates/shirabe/src/advisory/auditor.rs +++ b/crates/shirabe/src/advisory/auditor.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Advisory/Auditor.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_php_shim::{ - DATE_ATOM, InvalidArgumentException, PhpMixed, array_all, array_any, array_key_exists, - array_keys, array_reduce, get_class, sprintf, str_starts_with, -}; - use crate::advisory::AnySecurityAdvisory; use crate::advisory::SecurityAdvisory; use crate::io::ConsoleIO; @@ -19,6 +10,14 @@ use crate::package::PackageInterfaceHandle; use crate::package::base_package; use crate::repository::RepositorySet; use crate::util::PackageInfo; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_php_shim::{ + DATE_ATOM, InvalidArgumentException, PhpMixed, array_all, array_any, array_key_exists, + array_keys, array_reduce, get_class, sprintf, str_starts_with, +}; /// Shape of the `--format=json` audit output. #[derive(serde::Serialize)] diff --git a/crates/shirabe/src/advisory/security_advisory.rs b/crates/shirabe/src/advisory/security_advisory.rs index 78a2562..298a9e6 100644 --- a/crates/shirabe/src/advisory/security_advisory.rs +++ b/crates/shirabe/src/advisory/security_advisory.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Advisory/SecurityAdvisory.php +use crate::advisory::IgnoredSecurityAdvisory; +use crate::advisory::PartialSecurityAdvisory; use chrono::{DateTime, Utc}; use indexmap::IndexMap; use shirabe_php_shim::DATE_RFC3339; use shirabe_semver::constraint::AnyConstraint; -use crate::advisory::IgnoredSecurityAdvisory; -use crate::advisory::PartialSecurityAdvisory; - fn serialize_date_rfc3339<S: serde::Serializer>( dt: &DateTime<Utc>, serializer: S, diff --git a/crates/shirabe/src/autoload/mod.rs b/crates/shirabe/src/autoload.rs index d5758b2..d5758b2 100644 --- a/crates/shirabe/src/autoload/mod.rs +++ b/crates/shirabe/src/autoload.rs diff --git a/crates/shirabe/src/autoload/autoload_generator.rs b/crates/shirabe/src/autoload/autoload_generator.rs index 133348c..e7acb0a 100644 --- a/crates/shirabe/src/autoload/autoload_generator.rs +++ b/crates/shirabe/src/autoload/autoload_generator.rs @@ -1,20 +1,5 @@ //! ref: composer/src/Composer/Autoload/AutoloadGenerator.php -use indexmap::IndexMap; - -use shirabe_class_map_generator::class_map::ClassMap; -use shirabe_class_map_generator::class_map_generator::ClassMapGenerator; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, array_keys, array_map, array_merge_map, - array_merge_recursive, array_shift, array_slice_strs, array_unique, bin2hex, explode, - file_exists, file_get_contents, hash, implode, is_array, ksort, ltrim, preg_quote, - random_bytes, realpath, str_contains, str_replace, str_starts_with, strlen, strpos, strtr, - substr, substr_count, trim, unlink, var_export, -}; -use shirabe_semver::constraint::Bound; - use crate::autoload::ClassLoader; use crate::config::Config; use crate::event_dispatcher::EventDispatcher; @@ -34,6 +19,19 @@ use crate::script::ScriptEvents; use crate::util::Filesystem; use crate::util::PackageSorter; use crate::util::Platform; +use indexmap::IndexMap; +use shirabe_class_map_generator::class_map::ClassMap; +use shirabe_class_map_generator::class_map_generator::ClassMapGenerator; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, array_keys, array_map, array_merge_map, + array_merge_recursive, array_shift, array_slice_strs, array_unique, bin2hex, explode, + file_exists, file_get_contents, hash, implode, is_array, ksort, ltrim, preg_quote, + random_bytes, realpath, str_contains, str_replace, str_starts_with, strlen, strpos, strtr, + substr, substr_count, trim, unlink, var_export, +}; +use shirabe_semver::constraint::Bound; #[derive(Debug)] pub struct AutoloadGenerator { diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs index 3889ca0..3ebb7a7 100644 --- a/crates/shirabe/src/autoload/class_loader.rs +++ b/crates/shirabe/src/autoload/class_loader.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Autoload/ClassLoader.php use indexmap::IndexMap; -use std::sync::{LazyLock, Mutex}; - use shirabe_php_shim::{ DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, defined, file_exists, include_file, spl_autoload_register, spl_autoload_unregister, stream_resolve_include_path, strlen, strpos, strrpos, strtr, substr, }; +use std::sync::{LazyLock, Mutex}; /// @var array<string, self> static REGISTERED_LOADERS: LazyLock<Mutex<IndexMap<String, ClassLoader>>> = diff --git a/crates/shirabe/src/cache.rs b/crates/shirabe/src/cache.rs index 20197cd..b2e2f3f 100644 --- a/crates/shirabe/src/cache.rs +++ b/crates/shirabe/src/cache.rs @@ -1,7 +1,10 @@ //! ref: composer/src/Composer/Cache.php -use std::sync::Mutex; - +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; +use crate::util::Filesystem; +use crate::util::Platform; +use crate::util::Silencer; use anyhow::Result; use chrono::Utc; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; @@ -11,12 +14,7 @@ use shirabe_php_shim::{ file_exists, file_get_contents, file_put_contents, filemtime, function_exists, hash_file, is_dir, is_writable, mkdir, random_bytes, random_int, rename, time, unlink, }; - -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::Filesystem; -use crate::util::Platform; -use crate::util::Silencer; +use std::sync::Mutex; /// Reads/writes to a filesystem cache #[derive(Debug)] diff --git a/crates/shirabe/src/command/mod.rs b/crates/shirabe/src/command.rs index 614fff7..614fff7 100644 --- a/crates/shirabe/src/command/mod.rs +++ b/crates/shirabe/src/command.rs diff --git a/crates/shirabe/src/command/about_command.rs b/crates/shirabe/src/command/about_command.rs index 6aae55d..94c877a 100644 --- a/crates/shirabe/src/command/about_command.rs +++ b/crates/shirabe/src/command/about_command.rs @@ -1,5 +1,9 @@ //! ref: composer/src/Composer/Command/AboutCommand.php +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::composer; use anyhow::Result; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; @@ -7,11 +11,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::composer; - #[derive(Debug)] pub struct AboutCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/archive_command.rs b/crates/shirabe/src/command/archive_command.rs index d593912..91e8036 100644 --- a/crates/shirabe/src/command/archive_command.rs +++ b/crates/shirabe/src/command/archive_command.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Command/ArchiveCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{LogicException, get_debug_type}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::composer::PartialComposerHandle; @@ -32,6 +22,15 @@ use crate::util::Filesystem; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::r#loop::Loop; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{LogicException, get_debug_type}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ArchiveCommand { diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs index 0cf64a3..59d11a6 100644 --- a/crates/shirabe/src/command/audit_command.rs +++ b/crates/shirabe/src/command/audit_command.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Command/AuditCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, UnexpectedValueException, implode, in_array, -}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::AuditConfig; use crate::advisory::Auditor; use crate::command::BaseCommand; @@ -21,6 +11,15 @@ use crate::io::IOInterfaceImmutable; use crate::repository::CanonicalPackagesTrait; use crate::repository::RepositorySet; use crate::repository::RepositoryUtils; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, UnexpectedValueException, implode, in_array, +}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct AuditCommand { diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs index 149dc09..46ee5f7 100644 --- a/crates/shirabe/src/command/base_command.rs +++ b/crates/shirabe/src/command/base_command.rs @@ -1,23 +1,6 @@ //! ref: composer/src/Composer/Command/BaseCommand.php //! ref: composer/vendor/symfony/console/Command/Command.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::Terminal; -use shirabe_external_packages::symfony::console::command::command::{ - Command, CommandData, SetDefinitionArg, -}; -use shirabe_external_packages::symfony::console::helper::Table; -use shirabe_external_packages::symfony::console::helper::TableSeparator; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, RuntimeException, UnexpectedValueException, - count, explode, in_array, is_string, -}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::AuditConfig; use crate::advisory::Auditor; use crate::composer::PartialComposerHandle; @@ -34,6 +17,22 @@ use crate::package::version::VersionParser; use crate::plugin::PluginEvents; use crate::plugin::PreCommandRunEvent; use crate::util::Platform; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::Terminal; +use shirabe_external_packages::symfony::console::command::command::{ + Command, CommandData, SetDefinitionArg, +}; +use shirabe_external_packages::symfony::console::helper::Table; +use shirabe_external_packages::symfony::console::helper::TableSeparator; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, RuntimeException, UnexpectedValueException, + count, explode, in_array, is_string, +}; +use std::cell::RefCell; +use std::rc::Rc; pub const SUCCESS: i64 = 0; pub const FAILURE: i64 = 1; diff --git a/crates/shirabe/src/command/base_dependency_command.rs b/crates/shirabe/src/command/base_dependency_command.rs index 1c48a06..8b4fb14 100644 --- a/crates/shirabe/src/command/base_dependency_command.rs +++ b/crates/shirabe/src/command/base_dependency_command.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Command/BaseDependencyCommand.php -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, UnexpectedValueException}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::Bound; - use crate::command::BaseCommand; use crate::io::IOInterfaceImmutable; use crate::package::Package; @@ -22,6 +13,14 @@ use crate::repository::RootPackageRepository; use crate::repository::{DependentsEntry, InstalledRepository, NeedleInput}; use crate::repository::{FindPackageConstraint, RepositoryInterface}; use crate::util::PackageInfo; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, UnexpectedValueException}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::Bound; pub const ARGUMENT_PACKAGE: &str = "package"; pub const ARGUMENT_CONSTRAINT: &str = "version"; diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs index 3964300..79fedfb 100644 --- a/crates/shirabe/src/command/bump_command.rs +++ b/crates/shirabe/src/command/bump_command.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/Command/BumpCommand.php -use crate::io::io_interface; -use crate::package::base_package; -use anyhow::Result; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{PhpMixed, file_get_contents, file_put_contents, is_writable, strtolower}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::console::input::InputArgument; @@ -18,12 +7,22 @@ use crate::console::input::InputOption; use crate::factory::Factory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonFile; use crate::json::JsonManipulator; +use crate::package::base_package; use crate::package::version::VersionBumper; use crate::repository::PlatformRepository; use crate::util::Filesystem; use crate::util::Silencer; +use anyhow::Result; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{PhpMixed, file_get_contents, file_put_contents, is_writable, strtolower}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct BumpCommand { @@ -180,7 +179,7 @@ impl BumpCommand { let unique_lower: Vec<String> = packages_filter .iter() .map(|s| strtolower(s)) - .collect::<std::collections::HashSet<_>>() + .collect::<indexmap::IndexSet<_>>() .into_iter() .collect(); let pattern = base_package::package_names_to_regexp(&unique_lower, "{^(?:%s)$}iD"); diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs index ee98aa8..4b4e043 100644 --- a/crates/shirabe/src/command/check_platform_reqs_command.rs +++ b/crates/shirabe/src/command/check_platform_reqs_command.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/Command/CheckPlatformReqsCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{PhpMixed, array_merge_map, strip_tags}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::SimpleConstraint; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::console::input::InputOption; @@ -21,6 +10,16 @@ use crate::repository::InstalledRepository; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterface; use crate::repository::RootPackageRepository; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{PhpMixed, array_merge_map, strip_tags}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; +use std::cell::RefCell; +use std::rc::Rc; struct CheckResult { platform_package: String, diff --git a/crates/shirabe/src/command/clear_cache_command.rs b/crates/shirabe/src/command/clear_cache_command.rs index abe72ec..696b1dc 100644 --- a/crates/shirabe/src/command/clear_cache_command.rs +++ b/crates/shirabe/src/command/clear_cache_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/ClearCacheCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::realpath; -use std::cell::RefCell; -use std::rc::Rc; - use crate::cache::Cache; use crate::command::BaseCommand; use crate::command::BaseCommandData; @@ -16,6 +8,13 @@ use crate::config::Config; use crate::console::input::InputOption; use crate::factory::Factory; use crate::io::IOInterfaceImmutable; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::realpath; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ClearCacheCommand { diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index 7bf7d1b..e1ebf1a 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -1,21 +1,5 @@ //! ref: composer/src/Composer/Command/ConfigCommand.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; - -use crate::console::input::InputOption; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge, - escapeshellcmd, exec, explode, file_exists, file_get_contents, implode, in_array, is_array, - is_bool, is_dir, is_numeric, is_object, is_string, json_encode, str_replace, strpos, - strtolower, system, touch, var_export, -}; - use crate::advisory::Auditor; use crate::command::BaseConfigCommand; use crate::command::{BaseCommand, BaseCommandData}; @@ -23,13 +7,27 @@ use crate::config::Config; use crate::config::ConfigSourceInterface; use crate::config::JsonConfigSource; use crate::console::input::InputArgument; +use crate::console::input::InputOption; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::package::base_package::{self}; use crate::util::Filesystem; use crate::util::Platform; use crate::util::Silencer; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge, + escapeshellcmd, exec, explode, file_exists, file_get_contents, implode, in_array, is_array, + is_bool, is_dir, is_numeric, is_object, is_string, json_encode, str_replace, strpos, + strtolower, system, touch, var_export, +}; use shirabe_semver::VersionParser; #[derive(Debug)] diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index abbf37a..8f01f98 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -1,22 +1,5 @@ //! ref: composer/src/Composer/Command/CreateProjectCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::seld::signal::SignalHandler; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_external_packages::symfony::finder::Finder; -use shirabe_php_shim::{ - DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, RuntimeException, - UnexpectedValueException, array_pop, chdir, explode_with_limit, file_exists, getcwd, implode, - is_dir, is_file, mkdir, realpath, rtrim, strtolower, unlink, -}; -use std::cell::RefCell; -use std::path::PathBuf; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; @@ -49,6 +32,22 @@ use crate::script::ScriptEvents; use crate::util::Filesystem; use crate::util::Platform; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::seld::signal::SignalHandler; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_external_packages::symfony::finder::Finder; +use shirabe_php_shim::{ + DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, RuntimeException, + UnexpectedValueException, array_pop, chdir, explode_with_limit, file_exists, getcwd, implode, + is_dir, is_file, mkdir, realpath, rtrim, strtolower, unlink, +}; +use std::cell::RefCell; +use std::path::PathBuf; +use std::rc::Rc; /// Install a package as new project into new directory. #[derive(Debug)] diff --git a/crates/shirabe/src/command/depends_command.rs b/crates/shirabe/src/command/depends_command.rs index fa60a42..39e916a 100644 --- a/crates/shirabe/src/command/depends_command.rs +++ b/crates/shirabe/src/command/depends_command.rs @@ -1,18 +1,17 @@ //! ref: composer/src/Composer/Command/DependsCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::BaseDependencyCommand; use crate::command::base_command::base_command_initialize; use crate::console::input::InputArgument; use crate::console::input::InputOption; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct DependsCommand { diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs index 0bdf8ef..656f730 100644 --- a/crates/shirabe/src/command/diagnose_command.rs +++ b/crates/shirabe/src/command/diagnose_command.rs @@ -1,25 +1,5 @@ //! ref: composer/src/Composer/Command/DiagnoseCommand.php -use anyhow::Result; -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_external_packages::symfony::process::ExecutableFinder; -use shirabe_php_shim::{ - INFO_GENERAL, InvalidArgumentException, OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT, - PHP_BINARY, PHP_EOL, PHP_VERSION, PHP_VERSION_ID, PHP_WINDOWS_VERSION_BUILD, PhpMixed, defined, - disk_free_space, extension_loaded, file_exists, filter_var_boolean, function_exists, - get_class_err, hash, implode, ini_get, ioncube_loader_iversion, ioncube_loader_version, - is_array, is_string, ob_get_clean, ob_start, phpinfo, rtrim, str_contains, str_replace, - str_starts_with, strpos, strstr, strtolower, trim, version_compare, -}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; @@ -52,6 +32,24 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::http::ProxyManager; use crate::util::http::RequestProxy; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_external_packages::symfony::process::ExecutableFinder; +use shirabe_php_shim::{ + INFO_GENERAL, InvalidArgumentException, OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT, + PHP_BINARY, PHP_EOL, PHP_VERSION, PHP_VERSION_ID, PHP_WINDOWS_VERSION_BUILD, PhpMixed, defined, + disk_free_space, extension_loaded, file_exists, filter_var_boolean, function_exists, + get_class_err, hash, implode, ini_get, ioncube_loader_iversion, ioncube_loader_version, + is_array, is_string, ob_get_clean, ob_start, phpinfo, rtrim, str_contains, str_replace, + str_starts_with, strpos, strstr, strtolower, trim, version_compare, +}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct DiagnoseCommand { diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs index b0bb755..baae79d 100644 --- a/crates/shirabe/src/command/dump_autoload_command.rs +++ b/crates/shirabe/src/command/dump_autoload_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/DumpAutoloadCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, file_exists}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -15,6 +7,13 @@ use crate::console::input::InputOption; use crate::io::IOInterfaceImmutable; use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, file_exists}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct DumpAutoloadCommand { diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs index 8f3a0b5..8b7d5f7 100644 --- a/crates/shirabe/src/command/exec_command.rs +++ b/crates/shirabe/src/command/exec_command.rs @@ -1,5 +1,11 @@ //! ref: composer/src/Composer/Command/ExecCommand.php +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; +use crate::io::IOInterfaceImmutable; use anyhow::Result; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; @@ -8,13 +14,6 @@ use shirabe_php_shim::{PhpMixed, RuntimeException, basename, chdir, getcwd, glob use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; -use crate::io::IOInterfaceImmutable; - #[derive(Debug)] pub struct ExecCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/fund_command.rs b/crates/shirabe/src/command/fund_command.rs index 7e3bf65..ad4f94f 100644 --- a/crates/shirabe/src/command/fund_command.rs +++ b/crates/shirabe/src/command/fund_command.rs @@ -1,5 +1,13 @@ //! ref: composer/src/Composer/Command/FundCommand.php +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::console::input::InputOption; +use crate::io::IOInterfaceImmutable; +use crate::json::JsonFile; +use crate::package::base_package::{self}; +use crate::repository::CompositeRepository; +use crate::repository::RepositoryInterface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -13,15 +21,6 @@ use shirabe_semver::constraint::MatchAllConstraint; use std::cell::RefCell; use std::rc::Rc; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::console::input::InputOption; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonFile; -use crate::package::base_package::{self}; -use crate::repository::CompositeRepository; -use crate::repository::RepositoryInterface; - #[derive(Debug)] pub struct FundCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs index d0d8a31..04c2409 100644 --- a/crates/shirabe/src/command/global_command.rs +++ b/crates/shirabe/src/command/global_command.rs @@ -1,7 +1,12 @@ //! ref: composer/src/Composer/Command/GlobalCommand.php -use std::path::Path; - +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::console::input::InputArgument; +use crate::factory::Factory; +use crate::util::Filesystem; +use crate::util::Platform; use anyhow::Result; use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::console::command::command::Command; @@ -12,16 +17,9 @@ use shirabe_external_packages::symfony::console::input::StringInput; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{LogicException, RuntimeException, chdir}; use std::cell::RefCell; +use std::path::Path; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::console::input::InputArgument; -use crate::factory::Factory; -use crate::util::Filesystem; -use crate::util::Platform; - #[derive(Debug)] pub struct GlobalCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/home_command.rs b/crates/shirabe/src/command/home_command.rs index bde9fc2..682cb6a 100644 --- a/crates/shirabe/src/command/home_command.rs +++ b/crates/shirabe/src/command/home_command.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Command/HomeCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::PhpMixed; -use shirabe_php_shim::filter_var_url; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -20,6 +11,14 @@ use crate::repository::RepositoryFactory; use crate::repository::RootPackageRepository; use crate::util::Platform; use crate::util::ProcessExecutor; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::PhpMixed; +use shirabe_php_shim::filter_var_url; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct HomeCommand { diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index 88a2934..dc91069 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -1,6 +1,22 @@ //! ref: composer/src/Composer/Command/InitCommand.php +use crate::command::PackageDiscoveryTrait; +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::console::input::InputOption; +use crate::factory::Factory; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::json::JsonFile; +use crate::json::JsonValidationException; +use crate::package::base_package::{self}; +use crate::repository::CompositeRepository; +use crate::repository::PlatformRepository; +use crate::repository::PlatformRepositoryHandle; +use crate::repository::RepositoryFactory; +use crate::util::Filesystem; +use crate::util::ProcessExecutor; +use crate::util::Silencer; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; @@ -19,23 +35,6 @@ use shirabe_spdx_licenses::SpdxLicenses; use std::cell::RefCell; use std::rc::Rc; -use crate::command::PackageDiscoveryTrait; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::console::input::InputOption; -use crate::factory::Factory; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonFile; -use crate::json::JsonValidationException; -use crate::package::base_package::{self}; -use crate::repository::CompositeRepository; -use crate::repository::PlatformRepository; -use crate::repository::PlatformRepositoryHandle; -use crate::repository::RepositoryFactory; -use crate::util::Filesystem; -use crate::util::ProcessExecutor; -use crate::util::Silencer; - #[derive(Debug)] pub struct InitCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/install_command.rs b/crates/shirabe/src/command/install_command.rs index de0f400..2f782cc 100644 --- a/crates/shirabe/src/command/install_command.rs +++ b/crates/shirabe/src/command/install_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/InstallCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::BaseCommand; use crate::command::BaseCommandData; @@ -19,6 +11,13 @@ use crate::io::IOInterfaceImmutable; use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; use crate::util::HttpDownloader; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct InstallCommand { diff --git a/crates/shirabe/src/command/licenses_command.rs b/crates/shirabe/src/command/licenses_command.rs index cae79e4..c5cdf2a 100644 --- a/crates/shirabe/src/command/licenses_command.rs +++ b/crates/shirabe/src/command/licenses_command.rs @@ -1,5 +1,16 @@ //! ref: composer/src/Composer/Command/LicensesCommand.php +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::console::input::InputOption; +use crate::io::IOInterfaceImmutable; +use crate::json::JsonFile; +use crate::plugin::CommandEvent; +use crate::plugin::PluginEvents; +use crate::repository::RepositoryInterface; +use crate::repository::RepositoryUtils; +use crate::util::PackageInfo; +use crate::util::PackageSorter; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::symfony::console::command::command::Command; @@ -13,18 +24,6 @@ use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException}; use std::cell::RefCell; use std::rc::Rc; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::console::input::InputOption; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonFile; -use crate::plugin::CommandEvent; -use crate::plugin::PluginEvents; -use crate::repository::RepositoryInterface; -use crate::repository::RepositoryUtils; -use crate::util::PackageInfo; -use crate::util::PackageSorter; - #[derive(Debug)] pub struct LicensesCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/outdated_command.rs b/crates/shirabe/src/command/outdated_command.rs index 90c0f3d..be921e1 100644 --- a/crates/shirabe/src/command/outdated_command.rs +++ b/crates/shirabe/src/command/outdated_command.rs @@ -1,5 +1,10 @@ //! ref: composer/src/Composer/Command/OutdatedCommand.php +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::symfony::console::command::command::Command; @@ -10,12 +15,6 @@ use shirabe_php_shim::PhpMixed; use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; - #[derive(Debug)] pub struct OutdatedCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs index 4a5c65b..c3f744c 100644 --- a/crates/shirabe/src/command/package_discovery_trait.rs +++ b/crates/shirabe/src/command/package_discovery_trait.rs @@ -1,24 +1,12 @@ //! ref: composer/src/Composer/Command/PackageDiscoveryTrait.php -use crate::io::io_interface; - -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - Exception, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, array_keys, - array_slice, asort, explode, file_get_contents, implode, in_array, is_array, is_file, - is_numeric, json_decode, levenshtein, strlen, strpos, trim, -}; - use crate::command::BaseCommand; use crate::factory::Factory; use crate::filter::platform_requirement_filter::IgnoreAllPlatformRequirementFilter; use crate::filter::platform_requirement_filter::PlatformRequirementFilterFactory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::version::VersionParser; use crate::package::version::VersionSelector; @@ -29,6 +17,16 @@ use crate::repository::RepositoryFactory; use crate::repository::RepositorySet; use crate::repository::{RepositoryInterface, SearchResult}; use crate::util::Filesystem; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + Exception, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, array_keys, + array_slice, asort, explode, file_get_contents, implode, in_array, is_array, is_file, + is_numeric, json_decode, levenshtein, strlen, strpos, trim, +}; /// @internal pub trait PackageDiscoveryTrait: BaseCommand { diff --git a/crates/shirabe/src/command/prohibits_command.rs b/crates/shirabe/src/command/prohibits_command.rs index 7c034aa..2423dc7 100644 --- a/crates/shirabe/src/command/prohibits_command.rs +++ b/crates/shirabe/src/command/prohibits_command.rs @@ -1,5 +1,10 @@ //! ref: composer/src/Composer/Command/ProhibitsCommand.php +use crate::command::BaseDependencyCommand; +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; use anyhow::Result; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; @@ -7,12 +12,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseDependencyCommand; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; - #[derive(Debug)] pub struct ProhibitsCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs index b1d74cc..2cafbc3 100644 --- a/crates/shirabe/src/command/reinstall_command.rs +++ b/crates/shirabe/src/command/reinstall_command.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Command/ReinstallCommand.php -use anyhow::Result; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::InvalidArgumentException; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -23,6 +14,14 @@ use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; use crate::script::ScriptEvents; use crate::util::Platform; +use anyhow::Result; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::InvalidArgumentException; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ReinstallCommand { diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs index f864ebe..7422151 100644 --- a/crates/shirabe/src/command/remove_command.rs +++ b/crates/shirabe/src/command/remove_command.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/Command/RemoveCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::exception::InvalidArgumentException; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{PhpMixed, UnexpectedValueException, strtolower}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; @@ -25,6 +14,16 @@ use crate::io::IOInterfaceImmutable; use crate::json::JsonFile; use crate::package::base_package; use crate::repository::RepositoryInterface; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::exception::InvalidArgumentException; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{PhpMixed, UnexpectedValueException, strtolower}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RemoveCommand { diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs index 19dfb6b..ba0778c 100644 --- a/crates/shirabe/src/command/repository_command.rs +++ b/crates/shirabe/src/command/repository_command.rs @@ -1,5 +1,14 @@ //! ref: composer/src/Composer/Command/RepositoryCommand.php +use crate::command::BaseConfigCommand; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::config::Config; +use crate::config::ConfigSourceInterface; +use crate::config::JsonConfigSource; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; +use crate::io::IOInterfaceImmutable; +use crate::json::JsonFile; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -12,16 +21,6 @@ use shirabe_php_shim::{ use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseConfigCommand; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::config::Config; -use crate::config::ConfigSourceInterface; -use crate::config::JsonConfigSource; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonFile; - #[derive(Debug)] pub struct RepositoryCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index 4f50e71..ebd090a 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -1,21 +1,5 @@ //! 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; -use shirabe_external_packages::seld::signal::SignalHandler; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, array_fill_keys, array_intersect, array_keys, array_map, - array_merge, array_unique, empty, file_exists, file_get_contents, file_put_contents, filesize, - implode, is_writable, strtolower, unlink, -}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::PackageDiscoveryTrait; use crate::command::base_command::base_command_initialize; @@ -28,6 +12,7 @@ use crate::installer::Installer; use crate::installer::InstallerEvents; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonFile; use crate::json::JsonManipulator; use crate::package::base_package; @@ -44,6 +29,20 @@ use crate::repository::RepositorySet; use crate::util::Filesystem; use crate::util::PackageSorter; use crate::util::Silencer; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::seld::signal::SignalHandler; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, array_fill_keys, array_intersect, array_keys, array_map, + array_merge, array_unique, empty, file_exists, file_get_contents, file_put_contents, filesize, + implode, is_writable, strtolower, unlink, +}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RequireCommand { diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs index a85bb4e..869d97b 100644 --- a/crates/shirabe/src/command/run_script_command.rs +++ b/crates/shirabe/src/command/run_script_command.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Command/RunScriptCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::PhpMixed; -use shirabe_php_shim::{InvalidArgumentException, RuntimeException}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -20,6 +10,15 @@ use crate::script::Event as ScriptEvent; use crate::script::ScriptEvents; use crate::util::Platform; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::PhpMixed; +use shirabe_php_shim::{InvalidArgumentException, RuntimeException}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RunScriptCommand { diff --git a/crates/shirabe/src/command/script_alias_command.rs b/crates/shirabe/src/command/script_alias_command.rs index 9f55b03..20e2901 100644 --- a/crates/shirabe/src/command/script_alias_command.rs +++ b/crates/shirabe/src/command/script_alias_command.rs @@ -1,5 +1,11 @@ //! ref: composer/src/Composer/Command/ScriptAliasCommand.php +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; +use crate::util::Platform; use anyhow::Result; use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::console::command::command::Command; @@ -9,13 +15,6 @@ use shirabe_php_shim::{InvalidArgumentException, LogicException, PhpMixed, is_st use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; -use crate::util::Platform; - #[derive(Debug)] pub struct ScriptAliasCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs index f902eb8..6f3f4ce 100644 --- a/crates/shirabe/src/command/search_command.rs +++ b/crates/shirabe/src/command/search_command.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Command/SearchCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, implode, in_array, preg_quote}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::console::input::InputArgument; @@ -22,6 +12,15 @@ use crate::repository::CompositeRepository; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterfaceHandle; use crate::repository::repository_interface::{self, RepositoryInterface}; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, implode, in_array, preg_quote}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct SearchCommand { diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs index 5b94058..ca567ce 100644 --- a/crates/shirabe/src/command/self_update_command.rs +++ b/crates/shirabe/src/command/self_update_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/SelfUpdateCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -15,6 +7,13 @@ use crate::console::input::InputArgument; use crate::console::input::InputOption; use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct SelfUpdateCommand { diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index c52e0bf..6e777a1 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -1,25 +1,5 @@ //! ref: composer/src/Composer/Command/ShowCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - DATE_ATOM, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, - array_search, date, date_format_to_strftime, extension_loaded, in_array, realpath, strtolower, - version_compare, -}; -use shirabe_semver::Semver; -use shirabe_spdx_licenses::SpdxLicenses; -use std::cell::RefCell; -use std::rc::Rc; - -use shirabe_semver::constraint::AnyConstraint; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::composer::PartialComposerHandle; @@ -52,6 +32,24 @@ use crate::repository::RepositorySet; use crate::repository::RepositoryUtils; use crate::repository::RootPackageRepository; use crate::util::PackageInfo; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + DATE_ATOM, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, + array_search, date, date_format_to_strftime, extension_loaded, in_array, realpath, strtolower, + version_compare, +}; +use shirabe_semver::Semver; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_spdx_licenses::SpdxLicenses; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ShowCommand { diff --git a/crates/shirabe/src/command/status_command.rs b/crates/shirabe/src/command/status_command.rs index 74a85b4..bec6868 100644 --- a/crates/shirabe/src/command/status_command.rs +++ b/crates/shirabe/src/command/status_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/StatusCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -20,6 +12,13 @@ use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; use crate::script::ScriptEvents; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct StatusCommand { diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index e602cc2..cce4829 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -1,10 +1,28 @@ //! ref: composer/src/Composer/Command/UpdateCommand.php use crate::advisory::Auditor; +use crate::command::BumpCommand; +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::composer::PartialComposerHandle; use crate::console::input::InputArgument; use crate::console::input::InputOption; +use crate::dependency_resolver::request::UpdateAllowTransitiveDeps; +use crate::installer::Installer; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; use crate::package::base_package; +use crate::package::loader::RootPackageLoader; +use crate::package::version::VersionParser; +use crate::package::version::VersionSelector; +use crate::plugin::CommandEvent; +use crate::plugin::PluginEvents; +use crate::repository::CanonicalPackagesTrait; +use crate::repository::CompositeRepository; +use crate::repository::PlatformRepository; +use crate::repository::RepositorySet; +use crate::util::HttpDownloader; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -21,25 +39,6 @@ use shirabe_semver::constraint::MultiConstraint; use std::cell::RefCell; use std::rc::Rc; -use crate::command::BumpCommand; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::composer::PartialComposerHandle; -use crate::dependency_resolver::request::UpdateAllowTransitiveDeps; -use crate::installer::Installer; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::package::loader::RootPackageLoader; -use crate::package::version::VersionParser; -use crate::package::version::VersionSelector; -use crate::plugin::CommandEvent; -use crate::plugin::PluginEvents; -use crate::repository::CanonicalPackagesTrait; -use crate::repository::CompositeRepository; -use crate::repository::PlatformRepository; -use crate::repository::RepositorySet; -use crate::util::HttpDownloader; - #[derive(Debug)] pub struct UpdateCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/validate_command.rs b/crates/shirabe/src/command/validate_command.rs index fc9a7df..ab88398 100644 --- a/crates/shirabe/src/command/validate_command.rs +++ b/crates/shirabe/src/command/validate_command.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Command/ValidateCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -20,6 +13,12 @@ use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; use crate::util::ConfigValidator; use crate::util::Filesystem; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ValidateCommand { diff --git a/crates/shirabe/src/composer.rs b/crates/shirabe/src/composer.rs index d6c41e2..e28fb00 100644 --- a/crates/shirabe/src/composer.rs +++ b/crates/shirabe/src/composer.rs @@ -1,8 +1,6 @@ //! ref: composer/src/Composer/Composer.php //! ref: composer/src/Composer/PartialComposer.php -use shirabe_external_packages::composer::pcre::Preg; - use crate::autoload::AutoloadGeneratorInterface; use crate::config::Config; use crate::downloader::DownloadManagerInterface; @@ -13,6 +11,7 @@ use crate::package::{LockerInterface, RootPackageInterfaceHandle}; use crate::plugin::PluginManager; use crate::repository::RepositoryManagerInterface; use crate::util::r#loop::Loop; +use shirabe_external_packages::composer::pcre::Preg; // TODO: change this information to Shirabe version. pub const VERSION: &str = "2.9.7"; diff --git a/crates/shirabe/src/config/json_config_source.rs b/crates/shirabe/src/config/json_config_source.rs index 1ce51ad..1b09e54 100644 --- a/crates/shirabe/src/config/json_config_source.rs +++ b/crates/shirabe/src/config/json_config_source.rs @@ -1,5 +1,10 @@ //! ref: composer/src/Composer/Config/JsonConfigSource.php +use crate::config::ConfigSourceInterface; +use crate::json::JsonFile; +use crate::json::JsonManipulator; +use crate::json::JsonValidationException; +use crate::util::Filesystem; use crate::util::Silencer; use anyhow::Result; use indexmap::IndexMap; @@ -8,12 +13,6 @@ use shirabe_php_shim::{ implode, is_writable, }; -use crate::config::ConfigSourceInterface; -use crate::json::JsonFile; -use crate::json::JsonManipulator; -use crate::json::JsonValidationException; -use crate::util::Filesystem; - /// JSON Configuration Source #[derive(Debug)] pub struct JsonConfigSource { diff --git a/crates/shirabe/src/console/mod.rs b/crates/shirabe/src/console.rs index 9289d7e..9289d7e 100644 --- a/crates/shirabe/src/console/mod.rs +++ b/crates/shirabe/src/console.rs diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 3e197a2..077ea0a 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -1,58 +1,6 @@ //! ref: composer/src/Composer/Console/Application.php //! ref: composer/vendor/symfony/console/Application.php -use crate::io::io_interface; -use indexmap::IndexMap; - -use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; -use shirabe_external_packages::seld::json_lint::ParsingException; -use shirabe_external_packages::symfony::console::application::Application as BaseApplication; -use shirabe_external_packages::symfony::console::command::Command as SymfonyCommand; -use shirabe_external_packages::symfony::console::command::help_command::HelpCommand; -use shirabe_external_packages::symfony::console::command::signalable_command_interface::SignalableCommandInterface; -use shirabe_external_packages::symfony::console::command_loader::command_loader_interface::CommandLoaderInterface; -use shirabe_external_packages::symfony::console::completion::completion_input::CompletionInput; -use shirabe_external_packages::symfony::console::completion::completion_suggestions::CompletionSuggestions; -use shirabe_external_packages::symfony::console::exception::CommandNotFoundException; -use shirabe_external_packages::symfony::console::exception::invalid_argument_exception::InvalidArgumentException as ConsoleInvalidArgumentException; -use shirabe_external_packages::symfony::console::exception::invalid_option_exception::InvalidOptionException; -use shirabe_external_packages::symfony::console::exception::logic_exception::LogicException as ConsoleLogicException; -use shirabe_external_packages::symfony::console::exception::missing_input_exception::MissingInputException; -use shirabe_external_packages::symfony::console::exception::namespace_not_found_exception::NamespaceNotFoundException; -use shirabe_external_packages::symfony::console::exception::runtime_exception::RuntimeException as ConsoleRuntimeException; -use shirabe_external_packages::symfony::console::formatter::output_formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::helper::HelperSet; -use shirabe_external_packages::symfony::console::helper::QuestionHelper; -use shirabe_external_packages::symfony::console::helper::formatter_helper::{ - FormatBlockMessages, FormatterHelper, -}; -use shirabe_external_packages::symfony::console::helper::helper::Helper; -use shirabe_external_packages::symfony::console::input::InputDefinition; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::input::InputOption; -use shirabe_external_packages::symfony::console::input::argv_input::ArgvInput; -use shirabe_external_packages::symfony::console::input::array_input::ArrayInput; -use shirabe_external_packages::symfony::console::input::input_argument::InputArgument; -use shirabe_external_packages::symfony::console::output::console_output::ConsoleOutput; -use shirabe_external_packages::symfony::console::output::output_interface::{ - self as output_interface, OutputInterface, -}; -use shirabe_external_packages::symfony::console::signal_registry::signal_registry::SignalRegistry; -use shirabe_external_packages::symfony::console::style::style_interface::StyleInterface; -use shirabe_external_packages::symfony::console::style::symfony_style::SymfonyStyle; -use shirabe_external_packages::symfony::console::terminal::Terminal; -use shirabe_external_packages::symfony::process::exception::ProcessTimedOutException; -use shirabe_php_shim::{ - LogicException as ShimLogicException, PHP_BINARY, PHP_VERSION, PHP_VERSION_ID, PhpMixed, - RuntimeException, bin2hex, chdir, date_default_timezone_get, date_default_timezone_set, - defined, dirname, disk_free_space, extension_loaded, file_exists, file_get_contents, - file_put_contents, function_exists, getcwd, getmypid, glob, in_array, ini_set, is_array, - is_dir, is_file, is_string, is_subclass_of, json_decode, memory_get_peak_usage, - memory_get_usage, microtime, php_uname, posix_getuid, random_bytes, realpath, - restore_error_handler, round, str_contains, str_replace, strpos, strtoupper, sys_get_temp_dir, - time, unlink, -}; - use crate::command::AboutCommand; use crate::command::ArchiveCommand; use crate::command::AuditCommand; @@ -98,12 +46,62 @@ use crate::io::ConsoleIO; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; use crate::io::NullIO; +use crate::io::io_interface; use crate::json::JsonValidationException; use crate::util::ErrorHandler; use crate::util::Filesystem; use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::Silencer; +use indexmap::IndexMap; +use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; +use shirabe_external_packages::seld::json_lint::ParsingException; +use shirabe_external_packages::symfony::console::application::Application as BaseApplication; +use shirabe_external_packages::symfony::console::command::Command as SymfonyCommand; +use shirabe_external_packages::symfony::console::command::help_command::HelpCommand; +use shirabe_external_packages::symfony::console::command::signalable_command_interface::SignalableCommandInterface; +use shirabe_external_packages::symfony::console::command_loader::command_loader_interface::CommandLoaderInterface; +use shirabe_external_packages::symfony::console::completion::completion_input::CompletionInput; +use shirabe_external_packages::symfony::console::completion::completion_suggestions::CompletionSuggestions; +use shirabe_external_packages::symfony::console::exception::CommandNotFoundException; +use shirabe_external_packages::symfony::console::exception::invalid_argument_exception::InvalidArgumentException as ConsoleInvalidArgumentException; +use shirabe_external_packages::symfony::console::exception::invalid_option_exception::InvalidOptionException; +use shirabe_external_packages::symfony::console::exception::logic_exception::LogicException as ConsoleLogicException; +use shirabe_external_packages::symfony::console::exception::missing_input_exception::MissingInputException; +use shirabe_external_packages::symfony::console::exception::namespace_not_found_exception::NamespaceNotFoundException; +use shirabe_external_packages::symfony::console::exception::runtime_exception::RuntimeException as ConsoleRuntimeException; +use shirabe_external_packages::symfony::console::formatter::output_formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::helper::HelperSet; +use shirabe_external_packages::symfony::console::helper::QuestionHelper; +use shirabe_external_packages::symfony::console::helper::formatter_helper::{ + FormatBlockMessages, FormatterHelper, +}; +use shirabe_external_packages::symfony::console::helper::helper::Helper; +use shirabe_external_packages::symfony::console::input::InputDefinition; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::input::InputOption; +use shirabe_external_packages::symfony::console::input::argv_input::ArgvInput; +use shirabe_external_packages::symfony::console::input::array_input::ArrayInput; +use shirabe_external_packages::symfony::console::input::input_argument::InputArgument; +use shirabe_external_packages::symfony::console::output::console_output::ConsoleOutput; +use shirabe_external_packages::symfony::console::output::output_interface::{ + self, OutputInterface, +}; +use shirabe_external_packages::symfony::console::signal_registry::signal_registry::SignalRegistry; +use shirabe_external_packages::symfony::console::style::style_interface::StyleInterface; +use shirabe_external_packages::symfony::console::style::symfony_style::SymfonyStyle; +use shirabe_external_packages::symfony::console::terminal::Terminal; +use shirabe_external_packages::symfony::process::exception::ProcessTimedOutException; +use shirabe_php_shim::{ + LogicException as ShimLogicException, PHP_BINARY, PHP_VERSION, PHP_VERSION_ID, PhpMixed, + RuntimeException, bin2hex, chdir, date_default_timezone_get, date_default_timezone_set, + defined, dirname, disk_free_space, extension_loaded, file_exists, file_get_contents, + file_put_contents, function_exists, getcwd, getmypid, glob, in_array, ini_set, is_array, + is_dir, is_file, is_string, is_subclass_of, json_decode, memory_get_peak_usage, + memory_get_usage, microtime, php_uname, posix_getuid, random_bytes, realpath, + restore_error_handler, round, str_contains, str_replace, strpos, strtoupper, sys_get_temp_dir, + time, unlink, +}; /// The PHP `Composer\Console\Application` and `Symfony\Component\Console\Application` are /// flattened into a single struct. Methods that are overridden by subclass and called via @@ -867,7 +865,7 @@ impl Application { merged.extend(ns); } let merged: Vec<String> = merged.into_iter().filter(|s| !s.is_empty()).collect(); - let mut seen = std::collections::HashSet::new(); + let mut seen = indexmap::IndexSet::new(); let unique: Vec<String> = merged .into_iter() .filter(|s| seen.insert(s.clone())) @@ -1044,7 +1042,7 @@ impl Application { let commands_clone = commands.clone(); let mut new_commands: Vec<String> = Vec::new(); - let mut seen = std::collections::HashSet::new(); + let mut seen = indexmap::IndexSet::new(); for name_or_alias in commands { if !command_list.contains_key(&name_or_alias) { let loaded = self.command_loader.as_ref().unwrap().get(&name_or_alias); diff --git a/crates/shirabe/src/console/input/mod.rs b/crates/shirabe/src/console/input.rs index 9141f0c..9141f0c 100644 --- a/crates/shirabe/src/console/input/mod.rs +++ b/crates/shirabe/src/console/input.rs diff --git a/crates/shirabe/src/dependency_resolver/mod.rs b/crates/shirabe/src/dependency_resolver.rs index bcde18b..bcde18b 100644 --- a/crates/shirabe/src/dependency_resolver/mod.rs +++ b/crates/shirabe/src/dependency_resolver.rs diff --git a/crates/shirabe/src/dependency_resolver/default_policy.rs b/crates/shirabe/src/dependency_resolver/default_policy.rs index 5b0981d..d56a96c 100644 --- a/crates/shirabe/src/dependency_resolver/default_policy.rs +++ b/crates/shirabe/src/dependency_resolver/default_policy.rs @@ -1,16 +1,14 @@ //! ref: composer/src/Composer/DependencyResolver/DefaultPolicy.php -use std::cell::RefCell; - -use indexmap::IndexMap; -use shirabe_semver::CompilingMatcher; -use shirabe_semver::constraint::SimpleConstraint; - use crate::dependency_resolver::PolicyInterface; use crate::dependency_resolver::Pool; use crate::package::BasePackageHandle; use crate::package::STABILITIES; use crate::util::Platform; +use indexmap::IndexMap; +use shirabe_semver::CompilingMatcher; +use shirabe_semver::constraint::SimpleConstraint; +use std::cell::RefCell; #[derive(Debug)] pub struct DefaultPolicy { diff --git a/crates/shirabe/src/dependency_resolver/generic_rule.rs b/crates/shirabe/src/dependency_resolver/generic_rule.rs index 9098e93..afab376 100644 --- a/crates/shirabe/src/dependency_resolver/generic_rule.rs +++ b/crates/shirabe/src/dependency_resolver/generic_rule.rs @@ -1,11 +1,10 @@ //! ref: composer/src/Composer/DependencyResolver/GenericRule.php +use super::rule::ReasonData; use crate::dependency_resolver::{Rule, RuleBase}; use anyhow::Result; use shirabe_php_shim::{PHP_VERSION_ID, RuntimeException, hash_raw, unpack}; -use super::rule::ReasonData; - #[derive(Debug)] pub struct GenericRule { inner: RuleBase, diff --git a/crates/shirabe/src/dependency_resolver/lock_transaction.rs b/crates/shirabe/src/dependency_resolver/lock_transaction.rs index 3cabdcd..fb34562 100644 --- a/crates/shirabe/src/dependency_resolver/lock_transaction.rs +++ b/crates/shirabe/src/dependency_resolver/lock_transaction.rs @@ -1,12 +1,11 @@ //! ref: composer/src/Composer/DependencyResolver/LockTransaction.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; - use crate::dependency_resolver::Decisions; use crate::dependency_resolver::Pool; use crate::dependency_resolver::Transaction; use crate::package::PackageInterfaceHandle; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; #[derive(Debug)] pub struct LockTransaction { diff --git a/crates/shirabe/src/dependency_resolver/operation/mod.rs b/crates/shirabe/src/dependency_resolver/operation.rs index 720c5a0..720c5a0 100644 --- a/crates/shirabe/src/dependency_resolver/operation/mod.rs +++ b/crates/shirabe/src/dependency_resolver/operation.rs diff --git a/crates/shirabe/src/dependency_resolver/pool.rs b/crates/shirabe/src/dependency_resolver/pool.rs index 43d959b..1b072b4 100644 --- a/crates/shirabe/src/dependency_resolver/pool.rs +++ b/crates/shirabe/src/dependency_resolver/pool.rs @@ -1,16 +1,14 @@ //! ref: composer/src/Composer/DependencyResolver/Pool.php -use std::fmt; - +use crate::advisory::AnySecurityAdvisory; +use crate::package::BasePackageHandle; +use crate::package::version::VersionParser; use indexmap::IndexMap; use shirabe_php_shim::{STR_PAD_LEFT, str_pad}; use shirabe_semver::CompilingMatcher; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; - -use crate::advisory::AnySecurityAdvisory; -use crate::package::BasePackageHandle; -use crate::package::version::VersionParser; +use std::fmt; /// A package pool contains all packages for dependency resolution #[derive(Debug)] diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs index 986cbdf..5cfaa33 100644 --- a/crates/shirabe/src/dependency_resolver/pool_builder.rs +++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs @@ -1,20 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/PoolBuilder.php -use crate::io::io_interface; -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - LogicException, PhpMixed, array_flip_strings, array_map, in_array, microtime, number_format, - round, strpos, -}; -use shirabe_semver::CompilingMatcher; -use shirabe_semver::Intervals; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::MatchAllConstraint; -use shirabe_semver::constraint::MultiConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::dependency_resolver::Pool; use crate::dependency_resolver::PoolOptimizer; use crate::dependency_resolver::Request; @@ -22,6 +7,7 @@ use crate::dependency_resolver::SecurityAdvisoryPoolFilter; use crate::event_dispatcher::EventDispatcherInterface; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::AliasPackageHandle; use crate::package::BasePackageHandle; use crate::package::CompleteAliasPackageHandle; @@ -32,6 +18,18 @@ use crate::repository::CanonicalPackagesTrait; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterfaceHandle; use crate::repository::RootPackageRepository; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + LogicException, PhpMixed, array_flip_strings, array_map, in_array, microtime, number_format, + round, strpos, +}; +use shirabe_semver::CompilingMatcher; +use shirabe_semver::Intervals; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::MatchAllConstraint; +use shirabe_semver::constraint::MultiConstraint; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug)] pub struct PoolBuilder { diff --git a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs index 3cc5551..6238ddb 100644 --- a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs +++ b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs @@ -1,7 +1,10 @@ //! ref: composer/src/Composer/DependencyResolver/PoolOptimizer.php -use std::rc::Rc; - +use crate::dependency_resolver::PolicyInterface; +use crate::dependency_resolver::Pool; +use crate::dependency_resolver::Request; +use crate::package::BasePackageHandle; +use crate::package::version::VersionParser; use indexmap::IndexMap; use shirabe_php_shim::{implode, ksort}; use shirabe_semver::CompilingMatcher; @@ -9,12 +12,7 @@ use shirabe_semver::Intervals; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MultiConstraint; use shirabe_semver::constraint::SimpleConstraint; - -use crate::dependency_resolver::PolicyInterface; -use crate::dependency_resolver::Pool; -use crate::dependency_resolver::Request; -use crate::package::BasePackageHandle; -use crate::package::version::VersionParser; +use std::rc::Rc; /// Optimizes a given pool #[derive(Debug)] diff --git a/crates/shirabe/src/dependency_resolver/problem.rs b/crates/shirabe/src/dependency_resolver/problem.rs index 230ebc3..ac05033 100644 --- a/crates/shirabe/src/dependency_resolver/problem.rs +++ b/crates/shirabe/src/dependency_resolver/problem.rs @@ -1,7 +1,15 @@ //! ref: composer/src/Composer/DependencyResolver/Problem.php +use crate::dependency_resolver::Pool; +use crate::dependency_resolver::Request; +use crate::dependency_resolver::rule::{self, Rule}; +use crate::package::BasePackageHandle; +use crate::package::Link; +use crate::package::version::VersionParser; +use crate::repository::LockArrayRepository; +use crate::repository::PlatformRepository; +use crate::repository::RepositorySet; use indexmap::IndexMap; - use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::symfony::console::formatter::OutputFormatter; use shirabe_php_shim::{ @@ -13,16 +21,6 @@ use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MultiConstraint; use shirabe_semver::constraint::SimpleConstraint; -use crate::dependency_resolver::Pool; -use crate::dependency_resolver::Request; -use crate::dependency_resolver::rule::{self, Rule}; -use crate::package::BasePackageHandle; -use crate::package::Link; -use crate::package::version::VersionParser; -use crate::repository::LockArrayRepository; -use crate::repository::PlatformRepository; -use crate::repository::RepositorySet; - /// Represents a problem detected while solving dependencies #[derive(Debug)] pub struct Problem { diff --git a/crates/shirabe/src/dependency_resolver/request.rs b/crates/shirabe/src/dependency_resolver/request.rs index d3bcdfc..0a05f3e 100644 --- a/crates/shirabe/src/dependency_resolver/request.rs +++ b/crates/shirabe/src/dependency_resolver/request.rs @@ -1,14 +1,13 @@ //! ref: composer/src/Composer/DependencyResolver/Request.php +use crate::package::BasePackageHandle; +use crate::repository::LockArrayRepositoryHandle; +use crate::repository::RepositoryInterface; use indexmap::IndexMap; use shirabe_php_shim::{LogicException, strtolower}; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MatchAllConstraint; -use crate::package::BasePackageHandle; -use crate::repository::LockArrayRepositoryHandle; -use crate::repository::RepositoryInterface; - /// Identifies a partial update for listed packages only, all dependencies will remain at locked versions pub const UPDATE_ONLY_LISTED: i64 = 0; diff --git a/crates/shirabe/src/dependency_resolver/rule.rs b/crates/shirabe/src/dependency_resolver/rule.rs index 306f633..958af5a 100644 --- a/crates/shirabe/src/dependency_resolver/rule.rs +++ b/crates/shirabe/src/dependency_resolver/rule.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/Rule.php -use std::cell::RefCell; -use std::rc::Rc; - -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_php_shim::{ - LogicException, PhpMixed, RuntimeException, array_keys, array_shift, implode, -}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::dependency_resolver::GenericRule; use crate::dependency_resolver::MultiConflictRule; use crate::dependency_resolver::Pool; @@ -23,6 +12,15 @@ use crate::package::version::VersionParser; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterface; use crate::repository::RepositorySet; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_php_shim::{ + LogicException, PhpMixed, RuntimeException, array_keys, array_shift, implode, +}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub enum ReasonData { diff --git a/crates/shirabe/src/dependency_resolver/rule_set.rs b/crates/shirabe/src/dependency_resolver/rule_set.rs index d88f346..cde4ebc 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set.rs @@ -1,16 +1,14 @@ //! ref: composer/src/Composer/DependencyResolver/RuleSet.php -use std::cell::RefCell; -use std::rc::Rc; - -use indexmap::IndexMap; -use shirabe_php_shim::OutOfBoundsException; - use crate::dependency_resolver::Pool; use crate::dependency_resolver::Request; use crate::dependency_resolver::Rule; use crate::dependency_resolver::RuleSetIterator; use crate::repository::RepositorySet; +use indexmap::IndexMap; +use shirabe_php_shim::OutOfBoundsException; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RuleSet { diff --git a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs index 1d9d0c4..6c2824e 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs @@ -1,11 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/RuleSetGenerator.php -use std::cell::RefCell; -use std::collections::VecDeque; -use std::rc::Rc; - -use indexmap::IndexMap; - use crate::dependency_resolver::GenericRule; use crate::dependency_resolver::MultiConflictRule; use crate::dependency_resolver::PolicyInterface; @@ -18,6 +12,10 @@ use crate::filter::platform_requirement_filter::IgnoreListPlatformRequirementFil use crate::filter::platform_requirement_filter::PlatformRequirementFilterFactory; use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; use crate::package::PackageInterfaceHandle; +use indexmap::IndexMap; +use std::cell::RefCell; +use std::collections::VecDeque; +use std::rc::Rc; #[derive(Debug)] pub struct RuleSetGenerator { diff --git a/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs b/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs index 91cfff2..2c4b9a4 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/DependencyResolver/RuleSetIterator.php -use std::cell::RefCell; -use std::rc::Rc; - use crate::dependency_resolver::Rule; use indexmap::IndexMap; +use std::cell::RefCell; +use std::rc::Rc; /// Implements PHP \Iterator over a grouped rule set. #[derive(Debug)] diff --git a/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs b/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs index 370d553..b746f50 100644 --- a/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs +++ b/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs @@ -1,14 +1,12 @@ //! ref: composer/src/Composer/DependencyResolver/RuleWatchGraph.php -use std::cell::RefCell; -use std::rc::Rc; - -use indexmap::IndexMap; - use crate::dependency_resolver::Decisions; use crate::dependency_resolver::Rule; use crate::dependency_resolver::RuleWatchChain; use crate::dependency_resolver::RuleWatchNode; +use indexmap::IndexMap; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RuleWatchGraph { diff --git a/crates/shirabe/src/dependency_resolver/rule_watch_node.rs b/crates/shirabe/src/dependency_resolver/rule_watch_node.rs index 7292ae0..92faae7 100644 --- a/crates/shirabe/src/dependency_resolver/rule_watch_node.rs +++ b/crates/shirabe/src/dependency_resolver/rule_watch_node.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/DependencyResolver/RuleWatchNode.php -use std::cell::RefCell; -use std::rc::Rc; - use crate::dependency_resolver::Decisions; use crate::dependency_resolver::Rule; +use std::cell::RefCell; +use std::rc::Rc; pub struct RuleWatchNode { pub watch1: i64, diff --git a/crates/shirabe/src/dependency_resolver/solver.rs b/crates/shirabe/src/dependency_resolver/solver.rs index 53a26ac..933f79f 100644 --- a/crates/shirabe/src/dependency_resolver/solver.rs +++ b/crates/shirabe/src/dependency_resolver/solver.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/Solver.php -use std::cell::RefCell; -use std::rc::Rc; - -use indexmap::IndexMap; - -use shirabe_php_shim::{array_shift, array_unshift, microtime, spl_object_hash}; -use shirabe_semver::constraint::AnyConstraint; - use crate::dependency_resolver::Decisions; use crate::dependency_resolver::GenericRule; use crate::dependency_resolver::LockTransaction; @@ -28,6 +20,11 @@ use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterfa use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; use crate::package::BasePackageHandle; +use indexmap::IndexMap; +use shirabe_php_shim::{array_shift, array_unshift, microtime, spl_object_hash}; +use shirabe_semver::constraint::AnyConstraint; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct Solver { diff --git a/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs b/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs index d5f5560..b0016d0 100644 --- a/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs +++ b/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs @@ -1,16 +1,14 @@ //! ref: composer/src/Composer/DependencyResolver/SolverProblemsException.php -use std::cell::RefCell; -use std::rc::Rc; - -use shirabe_php_shim::RuntimeException; - use crate::dependency_resolver::Pool; use crate::dependency_resolver::Problem; use crate::dependency_resolver::Request; use crate::dependency_resolver::Rule; use crate::repository::RepositorySet; use crate::util::IniHelper; +use shirabe_php_shim::RuntimeException; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct SolverProblemsException { diff --git a/crates/shirabe/src/dependency_resolver/transaction.rs b/crates/shirabe/src/dependency_resolver/transaction.rs index 9e0a709..07564ed 100644 --- a/crates/shirabe/src/dependency_resolver/transaction.rs +++ b/crates/shirabe/src/dependency_resolver/transaction.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/Transaction.php -use indexmap::IndexMap; -use indexmap::IndexSet; -use shirabe_php_shim::{ - PhpMixed, array_filter, array_intersect, array_keys, array_pop, array_unshift, strcmp, uasort, - uasort_map, -}; - use crate::dependency_resolver::operation::InstallOperation; use crate::dependency_resolver::operation::MarkAliasInstalledOperation; use crate::dependency_resolver::operation::MarkAliasUninstalledOperation; @@ -17,6 +10,12 @@ use crate::package::AliasPackageHandle; use crate::package::Link; use crate::package::PackageInterfaceHandle; use crate::repository::PlatformRepository; +use indexmap::IndexMap; +use indexmap::IndexSet; +use shirabe_php_shim::{ + PhpMixed, array_filter, array_intersect, array_keys, array_pop, array_unshift, strcmp, uasort, + uasort_map, +}; /// @internal #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/downloader/mod.rs b/crates/shirabe/src/downloader.rs index 4f7641b..4f7641b 100644 --- a/crates/shirabe/src/downloader/mod.rs +++ b/crates/shirabe/src/downloader.rs diff --git a/crates/shirabe/src/downloader/archive_downloader.rs b/crates/shirabe/src/downloader/archive_downloader.rs index b1bdee7..4744bc2 100644 --- a/crates/shirabe/src/downloader/archive_downloader.rs +++ b/crates/shirabe/src/downloader/archive_downloader.rs @@ -1,5 +1,12 @@ //! ref: composer/src/Composer/Downloader/ArchiveDownloader.php +use crate::dependency_resolver::operation::InstallOperation; +use crate::downloader::DownloaderInterface; +use crate::downloader::FileDownloader; +use crate::io::IOInterfaceImmutable; +use crate::package::PackageInterfaceHandle; +use crate::util::Filesystem; +use crate::util::Platform; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::symfony::finder::Finder; @@ -9,14 +16,6 @@ use shirabe_php_shim::{ }; use std::path::{Path, PathBuf}; -use crate::dependency_resolver::operation::InstallOperation; -use crate::downloader::DownloaderInterface; -use crate::downloader::FileDownloader; -use crate::io::IOInterfaceImmutable; -use crate::package::PackageInterfaceHandle; -use crate::util::Filesystem; -use crate::util::Platform; - pub trait ArchiveDownloader { fn inner(&self) -> &FileDownloader; fn inner_mut(&mut self) -> &mut FileDownloader; diff --git a/crates/shirabe/src/downloader/change_report_interface.rs b/crates/shirabe/src/downloader/change_report_interface.rs index 718b2c1..ca2a113 100644 --- a/crates/shirabe/src/downloader/change_report_interface.rs +++ b/crates/shirabe/src/downloader/change_report_interface.rs @@ -1,8 +1,7 @@ //! ref: composer/src/Composer/Downloader/ChangeReportInterface.php -use anyhow::Result; - use crate::package::PackageInterfaceHandle; +use anyhow::Result; pub trait ChangeReportInterface { fn get_local_changes( diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs index b978368..82bf4bb 100644 --- a/crates/shirabe/src/downloader/download_manager.rs +++ b/crates/shirabe/src/downloader/download_manager.rs @@ -1,6 +1,12 @@ //! ref: composer/src/Composer/Downloader/DownloadManager.php +use crate::downloader::DownloaderInterface; +use crate::exception::IrrecoverableDownloadException; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::package::PackageInterfaceHandle; +use crate::util::Filesystem; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -10,13 +16,6 @@ use shirabe_php_shim::{ strtolower, usort, }; -use crate::downloader::DownloaderInterface; -use crate::exception::IrrecoverableDownloadException; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::package::PackageInterfaceHandle; -use crate::util::Filesystem; - /// Downloaders manager. #[derive(Debug)] pub struct DownloadManager { diff --git a/crates/shirabe/src/downloader/dvcs_downloader_interface.rs b/crates/shirabe/src/downloader/dvcs_downloader_interface.rs index 59f5774..e33aa46 100644 --- a/crates/shirabe/src/downloader/dvcs_downloader_interface.rs +++ b/crates/shirabe/src/downloader/dvcs_downloader_interface.rs @@ -1,8 +1,7 @@ //! ref: composer/src/Composer/Downloader/DvcsDownloaderInterface.php -use anyhow::Result; - use crate::package::PackageInterfaceHandle; +use anyhow::Result; pub trait DvcsDownloaderInterface { fn get_unpushed_changes( diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs index 66f3390..d3e1f6c 100644 --- a/crates/shirabe/src/downloader/file_downloader.rs +++ b/crates/shirabe/src/downloader/file_downloader.rs @@ -1,18 +1,5 @@ //! ref: composer/src/Composer/Downloader/FileDownloader.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use std::sync::{LazyLock, Mutex}; - -use crate::util::Silencer; -use shirabe_php_shim::{ - DIRECTORY_SEPARATOR, InvalidArgumentException, PATHINFO_BASENAME, PATHINFO_EXTENSION, - PHP_URL_PATH, PhpMixed, RuntimeException, UnexpectedValueException, array_search, file_exists, - filesize, get_class, hash, hash_file, in_array, is_dir, is_executable, parse_url, pathinfo, - realpath, rtrim, spl_object_hash, strlen, strpos, strtr, trim, umask, usleep, -}; - use crate::cache::Cache; use crate::config::Config; use crate::dependency_resolver::operation::InstallOperation; @@ -27,13 +14,24 @@ use crate::exception::IrrecoverableDownloadException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; use crate::io::NullIO; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::comparer::Comparer; use crate::util::Filesystem; use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; +use crate::util::Silencer; use crate::util::Url as UrlUtil; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_php_shim::{ + DIRECTORY_SEPARATOR, InvalidArgumentException, PATHINFO_BASENAME, PATHINFO_EXTENSION, + PHP_URL_PATH, PhpMixed, RuntimeException, UnexpectedValueException, array_search, file_exists, + filesize, get_class, hash, hash_file, in_array, is_dir, is_executable, parse_url, pathinfo, + realpath, rtrim, spl_object_hash, strlen, strpos, strtr, trim, umask, usleep, +}; +use std::sync::{LazyLock, Mutex}; /// @var array<string, int|string> /// @private diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs index fd044f8..dc27e0c 100644 --- a/crates/shirabe/src/downloader/git_downloader.rs +++ b/crates/shirabe/src/downloader/git_downloader.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Downloader/GitDownloader.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, array_map, basename, dirname, implode, in_array, is_dir, - preg_quote, realpath, rtrim, strlen, strpos, substr, trim, version_compare, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::ChangeReportInterface; @@ -18,12 +9,20 @@ use crate::downloader::VcsDownloader; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::util::Filesystem; use crate::util::Git as GitUtil; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Url; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, array_map, basename, dirname, implode, in_array, is_dir, + preg_quote, realpath, rtrim, strlen, strpos, substr, trim, version_compare, +}; #[derive(Debug)] pub struct GitDownloader { diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs index 694f758..cfd4889 100644 --- a/crates/shirabe/src/downloader/path_downloader.rs +++ b/crates/shirabe/src/downloader/path_downloader.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Downloader/PathDownloader.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::filesystem::Filesystem as SymfonyFilesystem; -use shirabe_php_shim::{ - DIRECTORY_SEPARATOR, PHP_WINDOWS_VERSION_MAJOR, PHP_WINDOWS_VERSION_MINOR, PhpMixed, - RuntimeException, file_exists, function_exists, is_dir, realpath, -}; - use crate::cache::Cache; use crate::config::Config; use crate::dependency_resolver::operation::InstallOperation; @@ -19,6 +10,7 @@ use crate::downloader::VcsCapableDownloaderInterface; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::archiver::ArchivableFilesFinder; use crate::package::dumper::ArrayDumper; @@ -28,6 +20,13 @@ use crate::util::Filesystem; use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::filesystem::Filesystem as SymfonyFilesystem; +use shirabe_php_shim::{ + DIRECTORY_SEPARATOR, PHP_WINDOWS_VERSION_MAJOR, PHP_WINDOWS_VERSION_MINOR, PhpMixed, + RuntimeException, file_exists, function_exists, is_dir, realpath, +}; #[derive(Debug)] pub struct PathDownloader { diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs index 8c13a05..cd48dae 100644 --- a/crates/shirabe/src/downloader/svn_downloader.rs +++ b/crates/shirabe/src/downloader/svn_downloader.rs @@ -1,10 +1,5 @@ //! ref: composer/src/Composer/Downloader/SvnDownloader.php -use crate::io::io_interface; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{PhpMixed, RuntimeException, is_dir, version_compare}; - use crate::config::Config; use crate::downloader::ChangeReportInterface; use crate::downloader::DownloaderInterface; @@ -13,11 +8,15 @@ use crate::downloader::VcsDownloader; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::repository::VcsRepository; use crate::util::Filesystem; use crate::util::ProcessExecutor; use crate::util::Svn as SvnUtil; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{PhpMixed, RuntimeException, is_dir, version_compare}; #[derive(Debug)] pub struct SvnDownloader { diff --git a/crates/shirabe/src/downloader/vcs_downloader.rs b/crates/shirabe/src/downloader/vcs_downloader.rs index 8084c37..1c89571 100644 --- a/crates/shirabe/src/downloader/vcs_downloader.rs +++ b/crates/shirabe/src/downloader/vcs_downloader.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Downloader/VcsDownloader.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, RuntimeException, array_map, array_shift, explode, - get_class_err, implode, rawurldecode, realpath, str_replace, strlen, strpos, substr, trim, -}; - use crate::config::Config; use crate::dependency_resolver::operation::InstallOperation; use crate::dependency_resolver::operation::UninstallOperation; @@ -17,12 +9,19 @@ use crate::downloader::DownloaderInterface; use crate::downloader::VcsCapableDownloaderInterface; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::dumper::ArrayDumper; use crate::package::version::VersionGuesser; use crate::package::version::VersionParser; use crate::util::Filesystem; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, RuntimeException, array_map, array_shift, explode, + get_class_err, implode, rawurldecode, realpath, str_replace, strlen, strpos, substr, trim, +}; #[derive(Debug)] pub struct VcsDownloaderBase { diff --git a/crates/shirabe/src/event_dispatcher/mod.rs b/crates/shirabe/src/event_dispatcher.rs index a50fa4d..a50fa4d 100644 --- a/crates/shirabe/src/event_dispatcher/mod.rs +++ b/crates/shirabe/src/event_dispatcher.rs diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs index 091160e..87552a9 100644 --- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs +++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs @@ -1,19 +1,5 @@ //! ref: composer/src/Composer/EventDispatcher/EventDispatcher.php -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::process::ExecutableFinder; -use shirabe_external_packages::symfony::process::PhpExecutableFinder; -use shirabe_php_shim::{ - InvalidArgumentException, PATH_SEPARATOR, PhpMixed, RuntimeException, array_pop, array_push, - array_search_in_vec, array_splice, class_exists, defined, file_exists, get_class, hash, - implode, ini_get, is_a, is_array, is_callable, is_object, is_string, krsort, preg_quote, - realpath, spl_autoload_functions, spl_autoload_register, spl_autoload_unregister, - spl_object_hash, str_contains, str_ends_with, str_replace, str_starts_with, strlen, strpos, - strtoupper, substr, trim, -}; - use crate::autoload::ClassLoader; use crate::composer::PartialComposerHandle; use crate::composer::PartialComposerWeakHandle; @@ -32,6 +18,18 @@ use crate::repository::RepositoryInterface; use crate::script::Event as ScriptEvent; use crate::util::Platform; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::process::ExecutableFinder; +use shirabe_external_packages::symfony::process::PhpExecutableFinder; +use shirabe_php_shim::{ + InvalidArgumentException, PATH_SEPARATOR, PhpMixed, RuntimeException, array_pop, array_push, + array_search_in_vec, array_splice, class_exists, defined, file_exists, get_class, hash, + implode, ini_get, is_a, is_array, is_callable, is_object, is_string, krsort, preg_quote, + realpath, spl_autoload_functions, spl_autoload_register, spl_autoload_unregister, + spl_object_hash, str_contains, str_ends_with, str_replace, str_starts_with, strlen, strpos, + strtoupper, substr, trim, +}; /// Represents a callable listener. PHP's `callable` may be a string (command, script, or /// "Class::method"), a `[object|string, method]` pair, or a `\Closure`. @@ -858,7 +856,7 @@ impl EventDispatcher { ) -> anyhow::Result<PhpMixed> { if self.io.is_verbose() { self.io.write_error3( - &format!("> {}: {}::{}", event.get_name(), class_name, method_name,), + &format!("> {}: {}::{}", event.get_name(), class_name, method_name), true, crate::io::NORMAL, ); @@ -1218,8 +1216,6 @@ impl EventDispatcher { Ok(()) } - // ---- helpers ---- - fn io_clone(&self) -> std::rc::Rc<std::cell::RefCell<dyn IOInterface>> { self.io.clone() } diff --git a/crates/shirabe/src/exception/mod.rs b/crates/shirabe/src/exception.rs index 0355e35..0355e35 100644 --- a/crates/shirabe/src/exception/mod.rs +++ b/crates/shirabe/src/exception.rs diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs index 6d1729b..b3d478c 100644 --- a/crates/shirabe/src/factory.rs +++ b/crates/shirabe/src/factory.rs @@ -1,18 +1,5 @@ //! ref: composer/src/Composer/Factory.php -use indexmap::IndexMap; - -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; -use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyleInterface; -use shirabe_external_packages::symfony::console::output::ConsoleOutput; -use shirabe_php_shim::{ - InvalidArgumentException, PATHINFO_EXTENSION, PHP_EOL, PHP_OS, PhpMixed, RuntimeException, - UnexpectedValueException, array_replace_recursive, class_exists, dirname, extension_loaded, - file_exists, file_get_contents, file_put_contents, implode, is_dir, is_file, json_decode, - mkdir, pathinfo, realpath, rename, rtrim, strpos, strtr, substr, trim, -}; - use crate::autoload::AutoloadGenerator; use crate::cache::Cache; use crate::composer::{ComposerHandle, ComposerWeakHandle, PartialOrFullComposer}; @@ -64,6 +51,17 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Silencer; use crate::util::r#loop::Loop; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyleInterface; +use shirabe_external_packages::symfony::console::output::ConsoleOutput; +use shirabe_php_shim::{ + InvalidArgumentException, PATHINFO_EXTENSION, PHP_EOL, PHP_OS, PhpMixed, RuntimeException, + UnexpectedValueException, array_replace_recursive, class_exists, dirname, extension_loaded, + file_exists, file_get_contents, file_put_contents, implode, is_dir, is_file, json_decode, + mkdir, pathinfo, realpath, rename, rtrim, strpos, strtr, substr, trim, +}; /// Either a configuration array or a filename to read from. PHP's `$localConfig` accepts both. pub enum LocalConfigInput { diff --git a/crates/shirabe/src/filter/mod.rs b/crates/shirabe/src/filter.rs index a5f35c5..a5f35c5 100644 --- a/crates/shirabe/src/filter/mod.rs +++ b/crates/shirabe/src/filter.rs diff --git a/crates/shirabe/src/filter/platform_requirement_filter/mod.rs b/crates/shirabe/src/filter/platform_requirement_filter.rs index 0a6556f..0a6556f 100644 --- a/crates/shirabe/src/filter/platform_requirement_filter/mod.rs +++ b/crates/shirabe/src/filter/platform_requirement_filter.rs diff --git a/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs b/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs index 854a4f6..709fdfc 100644 --- a/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs +++ b/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs @@ -1,5 +1,8 @@ //! ref: composer/src/Composer/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilter.php +use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; +use crate::package::base_package::{self}; +use crate::repository::PlatformRepository; use shirabe_external_packages::composer::pcre::Preg; use shirabe_semver::Interval; use shirabe_semver::Intervals; @@ -8,10 +11,6 @@ use shirabe_semver::constraint::MatchAllConstraint; use shirabe_semver::constraint::MultiConstraint; use shirabe_semver::constraint::SimpleConstraint; -use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; -use crate::package::base_package::{self}; -use crate::repository::PlatformRepository; - #[derive(Debug)] pub struct IgnoreListPlatformRequirementFilter { ignore_regex: String, diff --git a/crates/shirabe/src/installed_versions.rs b/crates/shirabe/src/installed_versions.rs index 0e22e06..8b287f1 100644 --- a/crates/shirabe/src/installed_versions.rs +++ b/crates/shirabe/src/installed_versions.rs @@ -1,7 +1,6 @@ //! ref: composer/src/Composer/InstalledVersions.php -use std::sync::Mutex; - +use crate::autoload::ClassLoader; use anyhow::Result; use indexmap::IndexMap; use shirabe_php_shim::{ @@ -9,8 +8,7 @@ use shirabe_php_shim::{ implode, is_file, method_exists, php_dir, require_php_file, strtr_array, substr, }; use shirabe_semver::VersionParser; - -use crate::autoload::ClassLoader; +use std::sync::Mutex; /// This class is copied in every Composer installed project and available to all /// diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs index ea73f6f..31e2e7b 100644 --- a/crates/shirabe/src/installer/binary_installer.rs +++ b/crates/shirabe/src/installer/binary_installer.rs @@ -1,6 +1,13 @@ //! ref: composer/src/Composer/Installer/BinaryInstaller.php +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::package::PackageInterfaceHandle; +use crate::util::Filesystem; +use crate::util::Platform; +use crate::util::ProcessExecutor; +use crate::util::Silencer; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ @@ -9,14 +16,6 @@ use shirabe_php_shim::{ substr, trim, umask, }; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::package::PackageInterfaceHandle; -use crate::util::Filesystem; -use crate::util::Platform; -use crate::util::ProcessExecutor; -use crate::util::Silencer; - /// Seam over the BinaryInstaller methods reached through LibraryInstaller, so tests can inject a /// recording double. Composer has no PHP `BinaryInstallerInterface`; this exists only to allow the /// `LibraryInstaller` collaborator to be mocked the way PHPUnit mocks the concrete class. diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs index bee14cc..3ce8076 100644 --- a/crates/shirabe/src/installer/installation_manager.rs +++ b/crates/shirabe/src/installer/installation_manager.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Installer/InstallationManager.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::seld::signal::SignalHandler; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, array_splice, array_unshift, http_build_query, json_encode, - str_contains, str_replace, strpos, strtolower, -}; - use crate::dependency_resolver::operation::InstallOperation; use crate::dependency_resolver::operation::MarkAliasInstalledOperation; use crate::dependency_resolver::operation::MarkAliasUninstalledOperation; @@ -21,10 +12,18 @@ use crate::installer::InstallerInterface; use crate::installer::PackageEvents; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::repository::InstalledRepositoryInterface; use crate::util::Platform; use crate::util::r#loop::Loop; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::seld::signal::SignalHandler; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, array_splice, array_unshift, http_build_query, json_encode, + str_contains, str_replace, strpos, strtolower, +}; /// Package operation manager. #[derive(Debug)] diff --git a/crates/shirabe/src/installer/installer_event.rs b/crates/shirabe/src/installer/installer_event.rs index ca0be22..5171b6d 100644 --- a/crates/shirabe/src/installer/installer_event.rs +++ b/crates/shirabe/src/installer/installer_event.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Installer/InstallerEvent.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::composer::ComposerWeakHandle; use crate::dependency_resolver::Transaction; use crate::event_dispatcher::Event; use crate::event_dispatcher::EventInterface; use crate::io::IOInterface; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct InstallerEvent { diff --git a/crates/shirabe/src/installer/library_installer.rs b/crates/shirabe/src/installer/library_installer.rs index 26fbf0e..133ba7c 100644 --- a/crates/shirabe/src/installer/library_installer.rs +++ b/crates/shirabe/src/installer/library_installer.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Installer/LibraryInstaller.php -use anyhow::Result; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, dirname, is_dir, is_link, preg_quote, - realpath, rmdir, rtrim, strpos, -}; - use crate::composer::PartialComposerWeakHandle; use crate::downloader::DownloadManagerInterface; use crate::installer::BinaryInstaller; @@ -19,6 +12,12 @@ use crate::repository::InstalledRepositoryInterface; use crate::util::Filesystem; use crate::util::Platform; use crate::util::Silencer; +use anyhow::Result; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, dirname, is_dir, is_link, preg_quote, + realpath, rmdir, rtrim, strpos, +}; /// Package installation manager. #[derive(Debug)] diff --git a/crates/shirabe/src/io/mod.rs b/crates/shirabe/src/io.rs index f7c8ad1..f7c8ad1 100644 --- a/crates/shirabe/src/io/mod.rs +++ b/crates/shirabe/src/io.rs diff --git a/crates/shirabe/src/io/console_io.rs b/crates/shirabe/src/io/console_io.rs index d14d730..210dbdc 100644 --- a/crates/shirabe/src/io/console_io.rs +++ b/crates/shirabe/src/io/console_io.rs @@ -1,7 +1,13 @@ //! ref: composer/src/Composer/IO/ConsoleIO.php use crate::config::Config; +use crate::io::BaseIO; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; +use crate::io::IOInterfaceMutable; use crate::io::io_interface; +use crate::question::StrictConfirmationQuestion; +use crate::util::Silencer; use indexmap::IndexMap; use indexmap::indexmap; use shirabe_external_packages::composer::pcre::Preg; @@ -12,7 +18,7 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::ConsoleOutput; use shirabe_external_packages::symfony::console::output::ConsoleOutputInterface; use shirabe_external_packages::symfony::console::output::output_interface::{ - self as output_interface, OutputInterface, + self, OutputInterface, }; use shirabe_external_packages::symfony::console::question::ChoiceQuestion; use shirabe_external_packages::symfony::console::question::Question; @@ -23,13 +29,6 @@ use shirabe_php_shim::{ }; use std::cell::RefCell; -use crate::io::BaseIO; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::io::IOInterfaceMutable; -use crate::question::StrictConfirmationQuestion; -use crate::util::Silencer; - /// The Input/Output helper. #[derive(Debug)] pub struct ConsoleIO { diff --git a/crates/shirabe/src/json/mod.rs b/crates/shirabe/src/json.rs index e5c3406..e5c3406 100644 --- a/crates/shirabe/src/json/mod.rs +++ b/crates/shirabe/src/json.rs diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs index b38de1e..c0b8816 100644 --- a/crates/shirabe/src/json/json_file.rs +++ b/crates/shirabe/src/json/json_file.rs @@ -1,6 +1,12 @@ //! ref: composer/src/Composer/Json/JsonFile.php +use crate::downloader::TransportException; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::json::JsonValidationException; +use crate::util::Filesystem; +use crate::util::HttpDownloader; use crate::util::Silencer; use anyhow::Result; use indexmap::IndexMap; @@ -14,13 +20,6 @@ use shirabe_php_shim::{ str_ends_with, str_repeat, strlen, strpos, usleep, }; -use crate::downloader::TransportException; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonValidationException; -use crate::util::Filesystem; -use crate::util::HttpDownloader; - #[derive(Debug, Clone)] pub struct JsonEncodeOptions { pub unescaped_slashes: bool, diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs index c62e31e..043534d 100644 --- a/crates/shirabe/src/json/json_manipulator.rs +++ b/crates/shirabe/src/json/json_manipulator.rs @@ -1,7 +1,9 @@ //! ref: composer/src/Composer/Json/JsonManipulator.php +use crate::json::JsonFile; +use crate::json::json_grammar::{self, ValueKind}; +use crate::repository::PlatformRepository; use indexmap::IndexMap; - use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, addcslashes, array_key_exists, array_keys, @@ -10,10 +12,6 @@ use shirabe_php_shim::{ trim, uksort, }; -use crate::json::JsonFile; -use crate::json::json_grammar::{self, ValueKind}; -use crate::repository::PlatformRepository; - #[derive(Debug)] pub struct JsonManipulator { contents: String, diff --git a/crates/shirabe/src/package/mod.rs b/crates/shirabe/src/package.rs index 912ac17..912ac17 100644 --- a/crates/shirabe/src/package/mod.rs +++ b/crates/shirabe/src/package.rs diff --git a/crates/shirabe/src/package/alias_package.rs b/crates/shirabe/src/package/alias_package.rs index 5af61b2..79204df 100644 --- a/crates/shirabe/src/package/alias_package.rs +++ b/crates/shirabe/src/package/alias_package.rs @@ -1,10 +1,5 @@ //! ref: composer/src/Composer/Package/AliasPackage.php -use chrono::{DateTime, Utc}; -use indexmap::IndexMap; -use shirabe_php_shim::{PhpMixed, in_array}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::package::BasePackage; use crate::package::Link; use crate::package::Mirror; @@ -12,6 +7,10 @@ use crate::package::PackageHandle; use crate::package::PackageInterface; use crate::package::version::VersionParser; use crate::repository::RepositoryInterfaceHandle; +use chrono::{DateTime, Utc}; +use indexmap::IndexMap; +use shirabe_php_shim::{PhpMixed, in_array}; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug, Clone)] pub struct AliasPackage { diff --git a/crates/shirabe/src/package/archiver/mod.rs b/crates/shirabe/src/package/archiver.rs index b4df5b0..b4df5b0 100644 --- a/crates/shirabe/src/package/archiver/mod.rs +++ b/crates/shirabe/src/package/archiver.rs diff --git a/crates/shirabe/src/package/archiver/archive_manager.rs b/crates/shirabe/src/package/archiver/archive_manager.rs index be911d6..eaeab9c 100644 --- a/crates/shirabe/src/package/archiver/archive_manager.rs +++ b/crates/shirabe/src/package/archiver/archive_manager.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Package/Archiver/ArchiveManager.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - InvalidArgumentException, RuntimeException, bin2hex, file_exists, random_bytes, realpath, - sys_get_temp_dir, -}; - use crate::downloader::DownloadManager; use crate::json::JsonFile; use crate::package::CompletePackageInterfaceHandle; @@ -16,6 +9,12 @@ use crate::package::archiver::ZipArchiver; use crate::util::Filesystem; use crate::util::SyncHelper; use crate::util::r#loop::Loop; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + InvalidArgumentException, RuntimeException, bin2hex, file_exists, random_bytes, realpath, + sys_get_temp_dir, +}; pub struct ArchiveManager { pub(crate) download_manager: std::rc::Rc<std::cell::RefCell<DownloadManager>>, diff --git a/crates/shirabe/src/package/archiver/phar_archiver.rs b/crates/shirabe/src/package/archiver/phar_archiver.rs index c25b90b..1bac060 100644 --- a/crates/shirabe/src/package/archiver/phar_archiver.rs +++ b/crates/shirabe/src/package/archiver/phar_archiver.rs @@ -1,15 +1,14 @@ //! ref: composer/src/Composer/Package/Archiver/PharArchiver.php +use crate::package::archiver::ArchivableFilesFilter; +use crate::package::archiver::ArchivableFilesFinder; +use crate::package::archiver::ArchiverInterface; use indexmap::IndexMap; use shirabe_php_shim::{ FilesystemIterator, Phar, PharData, PhpMixed, RuntimeException, bzcompress, file_exists, file_put_contents, function_exists, gzcompress, pack, str_repeat, strrpos, unlink, }; -use crate::package::archiver::ArchivableFilesFilter; -use crate::package::archiver::ArchivableFilesFinder; -use crate::package::archiver::ArchiverInterface; - fn formats() -> IndexMap<&'static str, i64> { let mut m = IndexMap::new(); m.insert("zip", Phar::ZIP); diff --git a/crates/shirabe/src/package/base_package.rs b/crates/shirabe/src/package/base_package.rs index 60211d2..04b4ea0 100644 --- a/crates/shirabe/src/package/base_package.rs +++ b/crates/shirabe/src/package/base_package.rs @@ -1,15 +1,13 @@ //! ref: composer/src/Composer/Package/BasePackage.php -use std::sync::LazyLock; - -use indexmap::IndexMap; -use shirabe_php_shim::preg_quote; - use crate::package::DisplayMode; use crate::package::Link; use crate::package::PackageInterface; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterfaceHandle; +use indexmap::IndexMap; +use shirabe_php_shim::preg_quote; +use std::sync::LazyLock; pub struct SupportedLinkType { pub description: &'static str, diff --git a/crates/shirabe/src/package/comparer/mod.rs b/crates/shirabe/src/package/comparer.rs index 878d7e0..878d7e0 100644 --- a/crates/shirabe/src/package/comparer/mod.rs +++ b/crates/shirabe/src/package/comparer.rs diff --git a/crates/shirabe/src/package/comparer/comparer.rs b/crates/shirabe/src/package/comparer/comparer.rs index 3139295..b0e01bd 100644 --- a/crates/shirabe/src/package/comparer/comparer.rs +++ b/crates/shirabe/src/package/comparer/comparer.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Package/Comparer/Comparer.php +use crate::util::Platform; use indexmap::IndexMap; use std::path::Path; -use crate::util::Platform; - #[derive(Debug)] pub struct Comparer { source: String, diff --git a/crates/shirabe/src/package/complete_alias_package.rs b/crates/shirabe/src/package/complete_alias_package.rs index 2fff592..2172157 100644 --- a/crates/shirabe/src/package/complete_alias_package.rs +++ b/crates/shirabe/src/package/complete_alias_package.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Package/CompleteAliasPackage.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::package::AliasPackage; use crate::package::CompletePackageHandle; use crate::package::CompletePackageInterface; use crate::package::PackageHandle; use crate::package::handle::delegate_package_interface_to_inner; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug, Clone)] pub struct CompleteAliasPackage { diff --git a/crates/shirabe/src/package/complete_package_interface.rs b/crates/shirabe/src/package/complete_package_interface.rs index 42b35ef..948c5e6 100644 --- a/crates/shirabe/src/package/complete_package_interface.rs +++ b/crates/shirabe/src/package/complete_package_interface.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Package/CompletePackageInterface.php +use crate::package::PackageInterface; use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; -use crate::package::PackageInterface; - pub trait CompletePackageInterface: PackageInterface { fn get_scripts(&self) -> IndexMap<String, Vec<String>>; diff --git a/crates/shirabe/src/package/dumper/mod.rs b/crates/shirabe/src/package/dumper.rs index c501aec..c501aec 100644 --- a/crates/shirabe/src/package/dumper/mod.rs +++ b/crates/shirabe/src/package/dumper.rs diff --git a/crates/shirabe/src/package/dumper/array_dumper.rs b/crates/shirabe/src/package/dumper/array_dumper.rs index ec33340..6688ad5 100644 --- a/crates/shirabe/src/package/dumper/array_dumper.rs +++ b/crates/shirabe/src/package/dumper/array_dumper.rs @@ -1,11 +1,10 @@ //! ref: composer/src/Composer/Package/Dumper/ArrayDumper.php -use indexmap::IndexMap; -use shirabe_php_shim::{DATE_RFC3339, PhpMixed}; - use crate::package::Mirror; use crate::package::PackageInterfaceHandle; use crate::package::SUPPORTED_LINK_TYPES; +use indexmap::IndexMap; +use shirabe_php_shim::{DATE_RFC3339, PhpMixed}; /// Serializes a Mirror back into the PHP array shape `{url, preferred}`. fn mirror_to_php(mirror: Mirror) -> PhpMixed { diff --git a/crates/shirabe/src/package/handle.rs b/crates/shirabe/src/package/handle.rs index 39121fa..28b1dbe 100644 --- a/crates/shirabe/src/package/handle.rs +++ b/crates/shirabe/src/package/handle.rs @@ -3,13 +3,12 @@ //! No weak handles are provided: an alias package never aliases another alias package, so the //! `alias_of` references are acyclic. -use std::cell::RefCell; -use std::rc::Rc; - use crate::package::{ AliasPackage, CompleteAliasPackage, CompletePackage, CompletePackageInterface, Package, PackageInterface, RootAliasPackage, RootPackage, RootPackageInterface, }; +use std::cell::RefCell; +use std::rc::Rc; /// Any package type. #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/package/loader/mod.rs b/crates/shirabe/src/package/loader.rs index 1073172..1073172 100644 --- a/crates/shirabe/src/package/loader/mod.rs +++ b/crates/shirabe/src/package/loader.rs diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs index b86f1de..07ad11f 100644 --- a/crates/shirabe/src/package/loader/array_loader.rs +++ b/crates/shirabe/src/package/loader/array_loader.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Package/Loader/ArrayLoader.php -use anyhow::Result; -use chrono::Utc; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - E_USER_DEPRECATED, PhpMixed, UnexpectedValueException, is_scalar, is_string, json_encode, - ltrim, stripos, strpos, strtolower, strval, substr, trigger_error, trim, -}; - use crate::package::CompleteAliasPackageHandle; use crate::package::CompletePackage; use crate::package::CompletePackageHandle; @@ -24,6 +15,14 @@ use crate::package::RootPackageHandle; use crate::package::SUPPORTED_LINK_TYPES; use crate::package::loader::LoaderInterface; use crate::package::version::VersionParser; +use anyhow::Result; +use chrono::Utc; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + E_USER_DEPRECATED, PhpMixed, UnexpectedValueException, is_scalar, is_string, json_encode, + ltrim, stripos, strpos, strtolower, strval, substr, trigger_error, trim, +}; #[derive(Debug)] pub struct ArrayLoader { diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs index c0101ac..83cda30 100644 --- a/crates/shirabe/src/package/loader/root_package_loader.rs +++ b/crates/shirabe/src/package/loader/root_package_loader.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Package/Loader/RootPackageLoader.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException, strtolower}; - use crate::config::Config; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; @@ -18,6 +14,9 @@ use crate::repository::RepositoryFactory; use crate::repository::RepositoryManager; use crate::util::Platform; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException, strtolower}; #[derive(Debug)] pub struct RootPackageLoader { diff --git a/crates/shirabe/src/package/loader/validating_array_loader.rs b/crates/shirabe/src/package/loader/validating_array_loader.rs index 14500a6..56e4157 100644 --- a/crates/shirabe/src/package/loader/validating_array_loader.rs +++ b/crates/shirabe/src/package/loader/validating_array_loader.rs @@ -1,7 +1,11 @@ //! ref: composer/src/Composer/Package/Loader/ValidatingArrayLoader.php +use crate::package::loader::InvalidPackageException; +use crate::package::loader::LoaderInterface; +use crate::package::version::VersionParser; +use crate::package::{STABILITIES, SUPPORTED_LINK_TYPES}; +use crate::repository::PlatformRepository; use indexmap::IndexMap; - use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{ E_USER_DEPRECATED, PHP_EOL, PhpMixed, array_intersect_key, array_values, filter_var_email, @@ -14,12 +18,6 @@ use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; use shirabe_spdx_licenses::SpdxLicenses; -use crate::package::loader::InvalidPackageException; -use crate::package::loader::LoaderInterface; -use crate::package::version::VersionParser; -use crate::package::{STABILITIES, SUPPORTED_LINK_TYPES}; -use crate::repository::PlatformRepository; - #[derive(Debug)] pub struct ValidatingArrayLoader { loader: Box<dyn LoaderInterface>, diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs index 1f123f1..09c2def 100644 --- a/crates/shirabe/src/package/locker.rs +++ b/crates/shirabe/src/package/locker.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/Package/Locker.php -use anyhow::Result; -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::seld::json_lint::ParsingException; -use shirabe_php_shim::{ - DATE_RFC3339, LogicException, PhpMixed, RuntimeException, array_intersect, array_keys, - array_map, array_merge, file_get_contents, filemtime, function_exists, hash, in_array, is_int, - ksort, realpath, strcmp, strtolower, touch2, trim, usort, -}; - use crate::installer::InstallationManager; use crate::io::IOInterface; use crate::json::JsonEncodeOptions; @@ -34,6 +23,15 @@ use crate::repository::RepositoryInterfaceHandle; use crate::repository::RootPackageRepository; use crate::util::Git as GitUtil; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::seld::json_lint::ParsingException; +use shirabe_php_shim::{ + DATE_RFC3339, LogicException, PhpMixed, RuntimeException, array_intersect, array_keys, + array_map, array_merge, file_get_contents, filemtime, function_exists, hash, in_array, is_int, + ksort, realpath, strcmp, strtolower, touch2, trim, usort, +}; /// Reads/writes project lockfile (composer.lock). #[derive(Debug)] diff --git a/crates/shirabe/src/package/package.rs b/crates/shirabe/src/package/package.rs index 7fa9452..6eaf348 100644 --- a/crates/shirabe/src/package/package.rs +++ b/crates/shirabe/src/package/package.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Package/Package.php -use std::rc::Rc; - -use chrono::{DateTime, Utc}; -use indexmap::{IndexMap, IndexSet}; - -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{E_USER_DEPRECATED, LogicException, PhpMixed, strpos, trigger_error}; - use crate::package::BasePackage; use crate::package::DisplayMode; use crate::package::Link; @@ -16,6 +8,11 @@ use crate::package::version::VersionParser; use crate::repository::RepositoryInterfaceHandle; use crate::repository::RepositoryInterfaceWeakHandle; use crate::util::ComposerMirror; +use chrono::{DateTime, Utc}; +use indexmap::{IndexMap, IndexSet}; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{E_USER_DEPRECATED, LogicException, PhpMixed, strpos, trigger_error}; +use std::rc::Rc; /// Mirror entry, e.g. `['url' => 'https://...', 'preferred' => true]`. #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/package/package_interface.rs b/crates/shirabe/src/package/package_interface.rs index 42a2ca2..8c9213c 100644 --- a/crates/shirabe/src/package/package_interface.rs +++ b/crates/shirabe/src/package/package_interface.rs @@ -1,12 +1,11 @@ //! ref: composer/src/Composer/Package/PackageInterface.php -use chrono::{DateTime, Utc}; -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::package::Link; use crate::package::Mirror; use crate::repository::RepositoryInterfaceHandle; +use chrono::{DateTime, Utc}; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; /// Selects how `get_full_pretty_version` renders the reference. /// diff --git a/crates/shirabe/src/package/root_alias_package.rs b/crates/shirabe/src/package/root_alias_package.rs index 687ee59..41b30a9 100644 --- a/crates/shirabe/src/package/root_alias_package.rs +++ b/crates/shirabe/src/package/root_alias_package.rs @@ -1,8 +1,5 @@ //! ref: composer/src/Composer/Package/RootAliasPackage.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::package::CompleteAliasPackage; use crate::package::CompletePackageHandle; use crate::package::CompletePackageInterface; @@ -10,6 +7,8 @@ use crate::package::Link; use crate::package::RootPackageHandle; use crate::package::RootPackageInterface; use crate::package::handle::delegate_package_interface_to_inner; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug, Clone)] pub struct RootAliasPackage { diff --git a/crates/shirabe/src/package/root_package.rs b/crates/shirabe/src/package/root_package.rs index 3ec7cbd..d764f9e 100644 --- a/crates/shirabe/src/package/root_package.rs +++ b/crates/shirabe/src/package/root_package.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Package/RootPackage.php -use chrono::{DateTime, Utc}; -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::package::CompletePackage; use crate::package::CompletePackageInterface; use crate::package::DisplayMode; @@ -12,6 +8,9 @@ use crate::package::Mirror; use crate::package::PackageInterface; use crate::package::RootPackageInterface; use crate::repository::RepositoryInterfaceHandle; +use chrono::{DateTime, Utc}; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug, Clone)] pub struct RootPackage { diff --git a/crates/shirabe/src/package/root_package_interface.rs b/crates/shirabe/src/package/root_package_interface.rs index d597555..85e5f9a 100644 --- a/crates/shirabe/src/package/root_package_interface.rs +++ b/crates/shirabe/src/package/root_package_interface.rs @@ -1,12 +1,10 @@ //! ref: composer/src/Composer/Package/RootPackageInterface.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - -use crate::package::PackageInterface; - use crate::package::CompletePackageInterface; use crate::package::Link; +use crate::package::PackageInterface; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; pub trait RootPackageInterface: CompletePackageInterface { fn get_aliases(&self) -> &[IndexMap<String, String>]; diff --git a/crates/shirabe/src/package/version/mod.rs b/crates/shirabe/src/package/version.rs index b2f32a2..b2f32a2 100644 --- a/crates/shirabe/src/package/version/mod.rs +++ b/crates/shirabe/src/package/version.rs diff --git a/crates/shirabe/src/package/version/version_guesser.rs b/crates/shirabe/src/package/version/version_guesser.rs index 6642201..f18f363 100644 --- a/crates/shirabe/src/package/version/version_guesser.rs +++ b/crates/shirabe/src/package/version/version_guesser.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Package/Version/VersionGuesser.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PHP_INT_MAX, PhpMixed, RuntimeException, array_keys, array_map, array_merge, empty, - function_exists, implode, is_string, json_encode, preg_quote, str_replace, strlen, - strnatcasecmp, strpos, substr, trim, usort, -}; - use crate::config::Config; use crate::io::IOInterface; use crate::io::NullIO; @@ -19,6 +10,14 @@ use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Svn as SvnUtil; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PHP_INT_MAX, PhpMixed, RuntimeException, array_keys, array_map, array_merge, empty, + function_exists, implode, is_string, json_encode, preg_quote, str_replace, strlen, + strnatcasecmp, strpos, substr, trim, usort, +}; /// Seam over the parts of [`VersionGuesser`] that consumers depend on, so they can be exercised /// with a test double. PHP has no such interface; this exists only to allow mocking the concrete diff --git a/crates/shirabe/src/package/version/version_parser.rs b/crates/shirabe/src/package/version/version_parser.rs index d412d47..3527722 100644 --- a/crates/shirabe/src/package/version/version_parser.rs +++ b/crates/shirabe/src/package/version/version_parser.rs @@ -1,14 +1,12 @@ //! ref: composer/src/Composer/Package/Version/VersionParser.php +use crate::repository::PlatformRepository; use indexmap::IndexMap; -use std::sync::{LazyLock, Mutex}; - use shirabe_external_packages::composer::pcre::Preg; use shirabe_semver::Semver; use shirabe_semver::VersionParser as SemverVersionParser; use shirabe_semver::constraint::AnyConstraint; - -use crate::repository::PlatformRepository; +use std::sync::{LazyLock, Mutex}; static CONSTRAINTS: LazyLock<Mutex<IndexMap<String, AnyConstraint>>> = LazyLock::new(|| Mutex::new(IndexMap::new())); diff --git a/crates/shirabe/src/package/version/version_selector.rs b/crates/shirabe/src/package/version/version_selector.rs index 8a0d037..48b045e 100644 --- a/crates/shirabe/src/package/version/version_selector.rs +++ b/crates/shirabe/src/package/version/version_selector.rs @@ -1,21 +1,12 @@ //! ref: composer/src/Composer/Package/Version/VersionSelector.php -use crate::io::io_interface; - -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, strtolower, version_compare, -}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::filter::platform_requirement_filter::IgnoreAllPlatformRequirementFilter; use crate::filter::platform_requirement_filter::IgnoreListPlatformRequirementFilter; use crate::filter::platform_requirement_filter::PlatformRequirementFilterFactory; use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::base_package; use crate::package::dumper::ArrayDumper; @@ -24,6 +15,13 @@ use crate::package::version::VersionParser; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterface; use crate::repository::RepositorySetInterface; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, strtolower, version_compare, +}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug)] pub struct VersionSelector { diff --git a/crates/shirabe/src/phpstan/mod.rs b/crates/shirabe/src/phpstan.rs index 5c48ac7..5c48ac7 100644 --- a/crates/shirabe/src/phpstan/mod.rs +++ b/crates/shirabe/src/phpstan.rs diff --git a/crates/shirabe/src/platform/mod.rs b/crates/shirabe/src/platform.rs index 6abbb76..6abbb76 100644 --- a/crates/shirabe/src/platform/mod.rs +++ b/crates/shirabe/src/platform.rs diff --git a/crates/shirabe/src/plugin/mod.rs b/crates/shirabe/src/plugin.rs index a26e117..a26e117 100644 --- a/crates/shirabe/src/plugin/mod.rs +++ b/crates/shirabe/src/plugin.rs diff --git a/crates/shirabe/src/plugin/capability/mod.rs b/crates/shirabe/src/plugin/capability.rs index 5b7dcea..5b7dcea 100644 --- a/crates/shirabe/src/plugin/capability/mod.rs +++ b/crates/shirabe/src/plugin/capability.rs diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs index a949c03..dd68d1e 100644 --- a/crates/shirabe/src/plugin/plugin_manager.rs +++ b/crates/shirabe/src/plugin/plugin_manager.rs @@ -4,15 +4,6 @@ //! and is not implemented in Phase A. The structure is mirrored verbatim so //! future plugin support can fill in the runtime hooks. -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - E_USER_DEPRECATED, PhpMixed, RuntimeException, UnexpectedValueException, array_key_exists, - get_class_obj, implode, ksort, trigger_error, trim, var_export_str, version_compare, -}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::composer::PartialComposerHandle; use crate::composer::{ComposerHandle, ComposerWeakHandle}; use crate::factory::DisablePlugins; @@ -31,6 +22,13 @@ use crate::repository::InstalledRepository; use crate::repository::RepositoryInterface; use crate::repository::RepositoryUtils; use crate::util::PackageSorter; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + E_USER_DEPRECATED, PhpMixed, RuntimeException, UnexpectedValueException, array_key_exists, + get_class_obj, implode, ksort, trigger_error, trim, var_export_str, version_compare, +}; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug)] pub struct PluginManager { diff --git a/crates/shirabe/src/plugin/post_file_download_event.rs b/crates/shirabe/src/plugin/post_file_download_event.rs index 9ba946e..88fc181 100644 --- a/crates/shirabe/src/plugin/post_file_download_event.rs +++ b/crates/shirabe/src/plugin/post_file_download_event.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Plugin/PostFileDownloadEvent.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::event_dispatcher::Event; use crate::event_dispatcher::EventInterface; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct PostFileDownloadEvent { diff --git a/crates/shirabe/src/plugin/pre_file_download_event.rs b/crates/shirabe/src/plugin/pre_file_download_event.rs index 0cd14d7..9ec74a0 100644 --- a/crates/shirabe/src/plugin/pre_file_download_event.rs +++ b/crates/shirabe/src/plugin/pre_file_download_event.rs @@ -1,11 +1,10 @@ //! ref: composer/src/Composer/Plugin/PreFileDownloadEvent.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::event_dispatcher::Event; use crate::event_dispatcher::EventInterface; use crate::util::HttpDownloader; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct PreFileDownloadEvent { diff --git a/crates/shirabe/src/plugin/pre_pool_create_event.rs b/crates/shirabe/src/plugin/pre_pool_create_event.rs index 303159a..0ffde94 100644 --- a/crates/shirabe/src/plugin/pre_pool_create_event.rs +++ b/crates/shirabe/src/plugin/pre_pool_create_event.rs @@ -1,14 +1,12 @@ //! ref: composer/src/Composer/Plugin/PrePoolCreateEvent.php -use indexmap::IndexMap; - -use shirabe_php_shim::PhpMixed; - use crate::dependency_resolver::Request; use crate::event_dispatcher::Event; use crate::event_dispatcher::EventInterface; use crate::package::BasePackageHandle; use crate::repository::RepositoryInterface; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct PrePoolCreateEvent { diff --git a/crates/shirabe/src/question/mod.rs b/crates/shirabe/src/question.rs index 4fedd84..4fedd84 100644 --- a/crates/shirabe/src/question/mod.rs +++ b/crates/shirabe/src/question.rs diff --git a/crates/shirabe/src/repository/mod.rs b/crates/shirabe/src/repository.rs index 478eedd..478eedd 100644 --- a/crates/shirabe/src/repository/mod.rs +++ b/crates/shirabe/src/repository.rs diff --git a/crates/shirabe/src/repository/array_repository.rs b/crates/shirabe/src/repository/array_repository.rs index afe2cc5..eec49f2 100644 --- a/crates/shirabe/src/repository/array_repository.rs +++ b/crates/shirabe/src/repository/array_repository.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Repository/ArrayRepository.php -use std::cell::RefCell; -use std::rc::Weak; - -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{implode, preg_quote, strtolower}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::package::AliasPackageHandle; use crate::package::BasePackageHandle; use crate::package::CompleteAliasPackageHandle; @@ -21,6 +11,14 @@ use crate::repository::{ AbandonedInfo, FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, RepositoryInterfaceHandle, RepositoryInterfaceWeakHandle, SearchResult, }; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{implode, preg_quote, strtolower}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; +use std::cell::RefCell; +use std::rc::Weak; /// A repository implementation that simply stores packages in an array #[derive(Debug)] diff --git a/crates/shirabe/src/repository/artifact_repository.rs b/crates/shirabe/src/repository/artifact_repository.rs index ac83e6b..7d9c02b 100644 --- a/crates/shirabe/src/repository/artifact_repository.rs +++ b/crates/shirabe/src/repository/artifact_repository.rs @@ -1,15 +1,8 @@ //! ref: composer/src/Composer/Repository/ArtifactRepository.php -use crate::io::io_interface; -use std::path::Path; - -use indexmap::IndexMap; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, UnexpectedValueException, extension_loaded, hash_file, -}; - use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonFile; use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; @@ -24,7 +17,12 @@ use crate::repository::{ use crate::util::Platform; use crate::util::Tar; use crate::util::Zip; +use indexmap::IndexMap; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, UnexpectedValueException, extension_loaded, hash_file, +}; use shirabe_semver::constraint::AnyConstraint; +use std::path::Path; pub struct ArtifactRepository { inner: ArrayRepository, diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index 4042a9b..e3a5711 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -1,19 +1,5 @@ //! ref: composer/src/Composer/Repository/ComposerRepository.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_metadata_minifier::MetadataMinifier; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, RuntimeException, - UnexpectedValueException, extension_loaded, hash, http_build_query, in_array, json_decode, - parse_url_all, realpath, strtolower, strtr, urlencode, var_export, -}; - -use shirabe_semver::CompilingMatcher; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::MatchAllConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::advisory::{AnySecurityAdvisory, PartialSecurityAdvisory}; use crate::cache::Cache; use crate::config::Config; @@ -46,6 +32,18 @@ use crate::util::HttpDownloader; use crate::util::Url; use crate::util::http::Response; use crate::util::r#loop::Loop; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_metadata_minifier::MetadataMinifier; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, RuntimeException, + UnexpectedValueException, extension_loaded, hash, http_build_query, in_array, json_decode, + parse_url_all, realpath, strtolower, strtr, urlencode, var_export, +}; +use shirabe_semver::CompilingMatcher; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::MatchAllConstraint; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug)] pub enum RootData { diff --git a/crates/shirabe/src/repository/composite_repository.rs b/crates/shirabe/src/repository/composite_repository.rs index d1456b1..9e5c975 100644 --- a/crates/shirabe/src/repository/composite_repository.rs +++ b/crates/shirabe/src/repository/composite_repository.rs @@ -1,14 +1,13 @@ //! ref: composer/src/Composer/Repository/CompositeRepository.php -use indexmap::IndexMap; -use shirabe_semver::constraint::AnyConstraint; - use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; use crate::repository::{ FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, RepositoryInterfaceHandle, SearchResult, }; +use indexmap::IndexMap; +use shirabe_semver::constraint::AnyConstraint; #[derive(Debug)] pub struct CompositeRepository { @@ -147,7 +146,7 @@ impl RepositoryInterface for CompositeRepository { all_names_found.extend(result.names_found); } - let mut seen = std::collections::HashSet::new(); + let mut seen = indexmap::IndexSet::new(); let unique_names: Vec<String> = all_names_found .into_iter() .filter(|s| seen.insert(s.clone())) diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs index 14365f2..ebe7600 100644 --- a/crates/shirabe/src/repository/filesystem_repository.rs +++ b/crates/shirabe/src/repository/filesystem_repository.rs @@ -1,17 +1,5 @@ //! ref: composer/src/Composer/Repository/FilesystemRepository.php -use std::any::Any; - -use crate::util::Silencer; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - Exception, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, - array_flip, dirname, r#eval, file_get_contents, get_class_err, get_debug_type, in_array, - is_array, is_null, is_string, ksort, realpath, str_repeat, trim, usort, var_export, -}; - use crate::config::is_php_integer_key; use crate::installed_versions::InstalledVersions; use crate::installer::InstallationManagerInterface; @@ -29,7 +17,17 @@ use crate::repository::WritableArrayRepository; use crate::repository::{FindPackageConstraint, LoadPackagesResult, ProviderInfo, SearchResult}; use crate::util::Filesystem; use crate::util::Platform; +use crate::util::Silencer; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + Exception, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, + array_flip, dirname, r#eval, file_get_contents, get_class_err, get_debug_type, in_array, + is_array, is_null, is_string, ksort, realpath, str_repeat, trim, usort, var_export, +}; use shirabe_semver::constraint::AnyConstraint; +use std::any::Any; /// Filesystem repository. #[derive(Debug)] diff --git a/crates/shirabe/src/repository/handle.rs b/crates/shirabe/src/repository/handle.rs index d0ad774..64cb5b7 100644 --- a/crates/shirabe/src/repository/handle.rs +++ b/crates/shirabe/src/repository/handle.rs @@ -1,17 +1,15 @@ //! Shared handle over `RepositoryInterface`. -use std::cell::{Ref, RefCell, RefMut}; -use std::rc::{Rc, Weak}; - -use indexmap::IndexMap; -use shirabe_semver::constraint::AnyConstraint; - use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; use crate::repository::{ FindPackageConstraint, LoadPackagesResult, LockArrayRepository, PlatformRepository, ProviderInfo, RepositoryInterface, SearchResult, }; +use indexmap::IndexMap; +use shirabe_semver::constraint::AnyConstraint; +use std::cell::{Ref, RefCell, RefMut}; +use std::rc::{Rc, Weak}; /// Shared reference to a repository. Corresponds to PHP `RepositoryInterface`. #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/repository/installed_array_repository.rs b/crates/shirabe/src/repository/installed_array_repository.rs index 6eff28f..ae0843d 100644 --- a/crates/shirabe/src/repository/installed_array_repository.rs +++ b/crates/shirabe/src/repository/installed_array_repository.rs @@ -1,8 +1,5 @@ //! ref: composer/src/Composer/Repository/InstalledArrayRepository.php -use indexmap::IndexMap; -use shirabe_semver::constraint::AnyConstraint; - use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; use crate::repository::AdvisoryProviderInterface; @@ -12,6 +9,8 @@ use crate::repository::WritableRepositoryInterface; use crate::repository::{ FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, SearchResult, }; +use indexmap::IndexMap; +use shirabe_semver::constraint::AnyConstraint; #[derive(Debug)] pub struct InstalledArrayRepository { diff --git a/crates/shirabe/src/repository/installed_filesystem_repository.rs b/crates/shirabe/src/repository/installed_filesystem_repository.rs index fc92aff..3cd21eb 100644 --- a/crates/shirabe/src/repository/installed_filesystem_repository.rs +++ b/crates/shirabe/src/repository/installed_filesystem_repository.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Repository/InstalledFilesystemRepository.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_semver::constraint::AnyConstraint; - use crate::json::JsonFile; use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; @@ -16,6 +12,9 @@ use crate::repository::{ FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, SearchResult, }; use crate::util::Filesystem; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_semver::constraint::AnyConstraint; #[derive(Debug)] pub struct InstalledFilesystemRepository { diff --git a/crates/shirabe/src/repository/installed_repository.rs b/crates/shirabe/src/repository/installed_repository.rs index b17fb27..9ed8d4e 100644 --- a/crates/shirabe/src/repository/installed_repository.rs +++ b/crates/shirabe/src/repository/installed_repository.rs @@ -1,11 +1,5 @@ //! ref: composer/src/Composer/Repository/InstalledRepository.php -use indexmap::IndexMap; -use shirabe_php_shim::array_merge_map; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::MatchAllConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::package::BasePackageHandle; use crate::package::Link; use crate::package::PackageInterfaceHandle; @@ -18,6 +12,11 @@ use crate::repository::{ FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, RepositoryInterfaceHandle, SearchResult, }; +use indexmap::IndexMap; +use shirabe_php_shim::array_merge_map; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::MatchAllConstraint; +use shirabe_semver::constraint::SimpleConstraint; pub enum NeedleInput { Single(String), diff --git a/crates/shirabe/src/repository/path_repository.rs b/crates/shirabe/src/repository/path_repository.rs index f573ee9..8249bb9 100644 --- a/crates/shirabe/src/repository/path_repository.rs +++ b/crates/shirabe/src/repository/path_repository.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Repository/PathRepository.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - DIRECTORY_SEPARATOR, GLOB_BRACE, GLOB_MARK, GLOB_ONLYDIR, PhpMixed, RuntimeException, defined, - file_exists, file_get_contents, glob_with_flags, hash, realpath, serialize, -}; - use crate::config::Config; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; @@ -29,6 +22,12 @@ use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Url; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + DIRECTORY_SEPARATOR, GLOB_BRACE, GLOB_MARK, GLOB_ONLYDIR, PhpMixed, RuntimeException, defined, + file_exists, file_get_contents, glob_with_flags, hash, realpath, serialize, +}; #[derive(Debug)] pub struct PathRepository { diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs index ee1d26e..0fa5638 100644 --- a/crates/shirabe/src/repository/platform_repository.rs +++ b/crates/shirabe/src/repository/platform_repository.rs @@ -1,18 +1,5 @@ //! ref: composer/src/Composer/Repository/PlatformRepository.php -use std::sync::{LazyLock, Mutex}; - -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, UnexpectedValueException, array_map_str_fn, - array_slice_strs, explode, get_class, implode, in_array, is_string, str_replace, - str_starts_with, strpos, strtolower, var_export, -}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::composer; use crate::package::CompletePackage; use crate::package::CompletePackageHandle; @@ -31,6 +18,16 @@ use crate::plugin::plugin_interface::{self}; use crate::repository::ArrayRepository; use crate::repository::RepositoryInterface; use crate::util::Silencer; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, UnexpectedValueException, array_map_str_fn, + array_slice_strs, explode, get_class, implode, in_array, is_string, str_replace, + str_starts_with, strpos, strtolower, var_export, +}; +use shirabe_semver::constraint::SimpleConstraint; +use std::sync::{LazyLock, Mutex}; static LAST_SEEN_PLATFORM_PHP: LazyLock<Mutex<Option<String>>> = LazyLock::new(|| Mutex::new(None)); @@ -1810,8 +1807,6 @@ impl PlatformRepository { self.inner.search(query, mode, r#type) } - // ---- helpers ---- - fn is_complete_package(package: PackageInterfaceHandle) -> bool { package.as_complete().is_some() } diff --git a/crates/shirabe/src/repository/repository_factory.rs b/crates/shirabe/src/repository/repository_factory.rs index bc08589..23766bf 100644 --- a/crates/shirabe/src/repository/repository_factory.rs +++ b/crates/shirabe/src/repository/repository_factory.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Repository/RepositoryFactory.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, UnexpectedValueException, get_debug_type, json_encode, - php_to_string, -}; - use crate::config::Config; use crate::event_dispatcher::EventDispatcher; use crate::factory::Factory; @@ -18,6 +11,12 @@ use crate::repository::RepositoryManager; use crate::repository::RepositoryManagerInterface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, UnexpectedValueException, get_debug_type, json_encode, + php_to_string, +}; pub struct RepositoryFactory; diff --git a/crates/shirabe/src/repository/repository_manager.rs b/crates/shirabe/src/repository/repository_manager.rs index 41f4e7d..eb755dc 100644 --- a/crates/shirabe/src/repository/repository_manager.rs +++ b/crates/shirabe/src/repository/repository_manager.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Repository/RepositoryManager.php -use indexmap::IndexMap; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, json_encode}; -use shirabe_semver::constraint::AnyConstraint; - use crate::config::Config; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; @@ -13,6 +9,9 @@ use crate::repository::FilterRepository; use crate::repository::RepositoryInterfaceHandle; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, json_encode}; +use shirabe_semver::constraint::AnyConstraint; #[derive(Debug)] pub struct RepositoryManager { diff --git a/crates/shirabe/src/repository/repository_set.rs b/crates/shirabe/src/repository/repository_set.rs index f8514cb..c19f61a 100644 --- a/crates/shirabe/src/repository/repository_set.rs +++ b/crates/shirabe/src/repository/repository_set.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Repository/RepositorySet.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_php_shim::{LogicException, RuntimeException, ksort, strtolower}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::MatchAllConstraint; -use shirabe_semver::constraint::MultiConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::advisory::AnySecurityAdvisory; use crate::dependency_resolver::Pool; use crate::dependency_resolver::PoolBuilder; @@ -28,6 +20,13 @@ use crate::repository::InstalledRepository; use crate::repository::LockArrayRepositoryHandle; use crate::repository::PlatformRepository; use crate::repository::{FindPackageConstraint, RepositoryInterfaceHandle}; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_php_shim::{LogicException, RuntimeException, ksort, strtolower}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::MatchAllConstraint; +use shirabe_semver::constraint::MultiConstraint; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug, Clone)] pub struct RootAliasEntry { diff --git a/crates/shirabe/src/repository/vcs/mod.rs b/crates/shirabe/src/repository/vcs.rs index 5c60e0a..5c60e0a 100644 --- a/crates/shirabe/src/repository/vcs/mod.rs +++ b/crates/shirabe/src/repository/vcs.rs diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs index 4d66f37..9557847 100644 --- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs +++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs @@ -1,18 +1,11 @@ //! 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::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; @@ -21,6 +14,12 @@ use crate::util::Forgejo; use crate::util::ForgejoRepositoryData; use crate::util::ForgejoUrl; use crate::util::http::Response; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode, +}; #[derive(Debug)] pub struct ForgejoDriver { diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs index be3beff..840a2ae 100644 --- a/crates/shirabe/src/repository/vcs/fossil_driver.rs +++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs @@ -1,19 +1,18 @@ //! ref: composer/src/Composer/Repository/Vcs/FossilDriver.php -use crate::io::io_interface; -use chrono::{DateTime, FixedOffset, Utc}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::repository::vcs::VcsDriverBase; use crate::util::Filesystem; use crate::util::ProcessExecutor; +use chrono::{DateTime, FixedOffset, Utc}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable}; #[derive(Debug)] pub struct FossilDriver { diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index 7a570bc..f28a005 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -1,21 +1,11 @@ //! ref: composer/src/Composer/Repository/Vcs/GitBitbucketDriver.php -use crate::io::io_interface; -use anyhow::Result; -use chrono::{DateTime, FixedOffset}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists, - array_search_mixed, extension_loaded, http_build_query_mixed, implode, in_array, is_array, - strpos, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; @@ -23,6 +13,15 @@ use crate::repository::vcs::VcsDriverBase; use crate::repository::vcs::VcsDriverInterface; use crate::util::Bitbucket; use crate::util::http::Response; +use anyhow::Result; +use chrono::{DateTime, FixedOffset}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists, + array_search_mixed, extension_loaded, http_build_query_mixed, implode, in_array, is_array, + strpos, +}; #[derive(Debug)] pub struct GitBitbucketDriver { diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs index cd08117..1455383 100644 --- a/crates/shirabe/src/repository/vcs/git_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_driver.rs @@ -1,26 +1,25 @@ //! ref: composer/src/Composer/Repository/Vcs/GitDriver.php -use crate::io::io_interface; -use chrono::TimeZone; -use chrono::{DateTime, FixedOffset, Utc}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, realpath, - sys_get_temp_dir, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::repository::vcs::VcsDriverBase; use crate::util::Filesystem; use crate::util::Git as GitUtil; use crate::util::ProcessExecutor; use crate::util::Url; +use chrono::TimeZone; +use chrono::{DateTime, FixedOffset, Utc}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::PhpMixed; +use shirabe_php_shim::{ + InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, realpath, + sys_get_temp_dir, +}; #[derive(Debug)] pub struct GitDriver { diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs index e45096d..e8e67ea 100644 --- a/crates/shirabe/src/repository/vcs/github_driver.rs +++ b/crates/shirabe/src/repository/vcs/github_driver.rs @@ -1,27 +1,26 @@ //! ref: composer/src/Composer/Repository/Vcs/GitHubDriver.php -use crate::io::io_interface; -use anyhow::Result; -use chrono::{DateTime, FixedOffset}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_key_exists, array_map, - array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array, - parse_url_all, strpos, strtolower, substr, trim, urlencode, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; use crate::repository::vcs::VcsDriverBase; use crate::util::GitHub; use crate::util::http::Response; +use anyhow::Result; +use chrono::{DateTime, FixedOffset}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_key_exists, array_map, + array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array, + parse_url_all, strpos, strtolower, substr, trim, urlencode, +}; #[derive(Debug)] pub struct GitHubDriver { diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index a9a2fdb..136d0d6 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -1,21 +1,11 @@ //! ref: composer/src/Composer/Repository/Vcs/GitLabDriver.php -use crate::io::io_interface; -use anyhow::Result; -use chrono::{DateTime, FixedOffset}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed, - array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array, is_array, - is_string, ord, strpos, strtolower, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; @@ -23,6 +13,15 @@ use crate::repository::vcs::VcsDriverBase; use crate::util::GitLab; use crate::util::HttpDownloader; use crate::util::http::Response; +use anyhow::Result; +use chrono::{DateTime, FixedOffset}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed, + array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array, is_array, + is_string, ord, strpos, strtolower, +}; /// Driver for GitLab API, use the Git driver for local checkouts. #[derive(Debug)] diff --git a/crates/shirabe/src/repository/vcs/perforce_driver.rs b/crates/shirabe/src/repository/vcs/perforce_driver.rs index cb280e5..55a8eae 100644 --- a/crates/shirabe/src/repository/vcs/perforce_driver.rs +++ b/crates/shirabe/src/repository/vcs/perforce_driver.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Repository/Vcs/PerforceDriver.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{BadMethodCallException, PhpMixed, RuntimeException}; - use crate::cache::Cache; use crate::config::Config; use crate::io::IOInterface; @@ -12,6 +8,9 @@ use crate::util::Perforce; use crate::util::PerforceInterface; use crate::util::ProcessExecutor; use crate::util::http::Response; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{BadMethodCallException, PhpMixed, RuntimeException}; #[derive(Debug)] pub struct PerforceDriver { diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index 087ed9d..cb4ff87 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Repository/Vcs/SvnDriver.php -use anyhow::Result; -use chrono::{DateTime, FixedOffset, Utc}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, array_key_exists, stripos, strrpos, strtr, substr, trim, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; @@ -19,6 +11,13 @@ use crate::util::Filesystem; use crate::util::ProcessExecutor; use crate::util::Svn as SvnUtil; use crate::util::Url; +use anyhow::Result; +use chrono::{DateTime, FixedOffset, Utc}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, array_key_exists, stripos, strrpos, strtr, substr, trim, +}; #[derive(Debug)] pub struct SvnDriver { diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs index 5e0715c..1dce856 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs @@ -1,10 +1,5 @@ //! ref: composer/src/Composer/Repository/Vcs/VcsDriver.php -use chrono::{DateTime, FixedOffset}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{DATE_RFC3339, PhpMixed, extension_loaded}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; @@ -15,6 +10,10 @@ use crate::repository::vcs::VcsDriverInterface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; use crate::util::http::Response; +use chrono::{DateTime, FixedOffset}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{DATE_RFC3339, PhpMixed, extension_loaded}; #[derive(Debug)] pub struct VcsDriverBase { diff --git a/crates/shirabe/src/repository/vcs_repository.rs b/crates/shirabe/src/repository/vcs_repository.rs index 901276a..d799532 100644 --- a/crates/shirabe/src/repository/vcs_repository.rs +++ b/crates/shirabe/src/repository/vcs_repository.rs @@ -1,17 +1,11 @@ //! 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; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, in_array, str_replace, strpos}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::config::Config; use crate::downloader::TransportException; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; use crate::package::loader::ArrayLoader; @@ -32,6 +26,11 @@ use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Url; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, in_array, str_replace, strpos}; +use shirabe_semver::constraint::SimpleConstraint; // TODO(phase-c): the driver registration should be refactored later. #[derive(Debug)] diff --git a/crates/shirabe/src/script/mod.rs b/crates/shirabe/src/script.rs index e8b657f..e8b657f 100644 --- a/crates/shirabe/src/script/mod.rs +++ b/crates/shirabe/src/script.rs diff --git a/crates/shirabe/src/self_update/mod.rs b/crates/shirabe/src/self_update.rs index 5594811..5594811 100644 --- a/crates/shirabe/src/self_update/mod.rs +++ b/crates/shirabe/src/self_update.rs diff --git a/crates/shirabe/src/util/mod.rs b/crates/shirabe/src/util.rs index bd51b66..bd51b66 100644 --- a/crates/shirabe/src/util/mod.rs +++ b/crates/shirabe/src/util.rs diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs index 584ce69..8a89842 100644 --- a/crates/shirabe/src/util/auth_helper.rs +++ b/crates/shirabe/src/util/auth_helper.rs @@ -1,6 +1,13 @@ //! ref: composer/src/Composer/Util/AuthHelper.php +use crate::config::Config; +use crate::downloader::TransportException; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::util::Bitbucket; +use crate::util::GitHub; +use crate::util::GitLab; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -10,14 +17,6 @@ use shirabe_php_shim::{ trim, }; -use crate::config::Config; -use crate::downloader::TransportException; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::Bitbucket; -use crate::util::GitHub; -use crate::util::GitLab; - #[derive(Debug)] pub struct AuthHelper { pub(crate) io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, diff --git a/crates/shirabe/src/util/bitbucket.rs b/crates/shirabe/src/util/bitbucket.rs index 8a1127a..bba16e8 100644 --- a/crates/shirabe/src/util/bitbucket.rs +++ b/crates/shirabe/src/util/bitbucket.rs @@ -1,16 +1,15 @@ //! ref: composer/src/Composer/Util/Bitbucket.php -use crate::io::io_interface; -use indexmap::IndexMap; -use shirabe_php_shim::{LogicException, PhpMixed, time}; - use crate::config::Config; use crate::downloader::TransportException; use crate::factory::Factory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_php_shim::{LogicException, PhpMixed, time}; fn transport_error_code(err: &anyhow::Error) -> Option<i64> { err.downcast_ref::<TransportException>().map(|te| te.code) diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs index b224767..d21a0e7 100644 --- a/crates/shirabe/src/util/filesystem.rs +++ b/crates/shirabe/src/util/filesystem.rs @@ -1,5 +1,8 @@ //! ref: composer/src/Composer/Util/Filesystem.php +use crate::util::Platform; +use crate::util::ProcessExecutor; +use crate::util::Silencer; use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::filesystem::exception::IOException; use shirabe_external_packages::symfony::finder::Finder; @@ -12,13 +15,8 @@ use shirabe_php_shim::{ str_starts_with, strlen, strpos, strtoupper, strtr, substr, substr_count, symlink, touch, unlink, usleep, var_export, }; - use std::path::Path; -use crate::util::Platform; -use crate::util::ProcessExecutor; -use crate::util::Silencer; - #[derive(Debug)] pub struct Filesystem { process_executor: Option<std::rc::Rc<std::cell::RefCell<ProcessExecutor>>>, diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs index f30f9f7..ee9f9e6 100644 --- a/crates/shirabe/src/util/git.rs +++ b/crates/shirabe/src/util/git.rs @@ -1,20 +1,9 @@ //! ref: composer/src/Composer/Util/Git.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use std::sync::Mutex; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, PHP_EOL, PhpMixed, RuntimeException, array_map, clearstatcache, - explode, implode, in_array, is_callable, is_dir, preg_quote, rawurldecode, rawurlencode, - str_contains, str_ends_with, str_replace_array, strlen, strpos, substr, trim, version_compare, -}; - use crate::config::Config; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::util::Bitbucket; use crate::util::Filesystem; use crate::util::GitHub; @@ -24,6 +13,15 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Url; use crate::util::{AuthHelper, StoreAuth}; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, PHP_EOL, PhpMixed, RuntimeException, array_map, clearstatcache, + explode, implode, in_array, is_callable, is_dir, preg_quote, rawurldecode, rawurlencode, + str_contains, str_ends_with, str_replace_array, strlen, strpos, substr, trim, version_compare, +}; +use std::sync::Mutex; #[derive(Debug)] pub struct Git { diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs index 285052e..905026a 100644 --- a/crates/shirabe/src/util/github.rs +++ b/crates/shirabe/src/util/github.rs @@ -1,16 +1,15 @@ //! ref: composer/src/Composer/Util/GitHub.php -use crate::io::io_interface; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{PhpMixed, date, stripos, strtolower}; - use crate::config::Config; use crate::factory::Factory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{PhpMixed, date, stripos, strtolower}; #[derive(Debug)] pub struct GitHub { diff --git a/crates/shirabe/src/util/gitlab.rs b/crates/shirabe/src/util/gitlab.rs index a71c231..eae26f0 100644 --- a/crates/shirabe/src/util/gitlab.rs +++ b/crates/shirabe/src/util/gitlab.rs @@ -1,17 +1,16 @@ //! ref: composer/src/Composer/Util/GitLab.php -use crate::io::io_interface; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{PhpMixed, RuntimeException, http_build_query, json_decode, time}; - use crate::config::Config; use crate::downloader::TransportException; use crate::factory::Factory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{PhpMixed, RuntimeException, http_build_query, json_decode, time}; #[derive(Debug)] pub struct GitLab { diff --git a/crates/shirabe/src/util/http/mod.rs b/crates/shirabe/src/util/http.rs index 19e5a86..19e5a86 100644 --- a/crates/shirabe/src/util/http/mod.rs +++ b/crates/shirabe/src/util/http.rs diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs index 66ca326..019a5ab 100644 --- a/crates/shirabe/src/util/http/curl_downloader.rs +++ b/crates/shirabe/src/util/http/curl_downloader.rs @@ -10,15 +10,6 @@ //! is preserved. Per-request TLS/proxy/IP-resolve settings that reqwest only exposes per-Client //! are simplified to a single default Client; see the TODOs below. -use std::sync::atomic::{AtomicBool, Ordering}; - -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - PhpMixed, in_array, parse_url, preg_quote, rename, strpos, substr, unlink_silent, -}; - use crate::config::Config; use crate::downloader::MaxFileSizeExceededException; use crate::downloader::TransportException; @@ -31,6 +22,12 @@ use crate::util::http::CurlResponse; use crate::util::http::ProxyManager; use crate::util::http::Response; use crate::util::{AuthHelper, PromptAuthResult, StoreAuth}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + PhpMixed, in_array, parse_url, preg_quote, rename, strpos, substr, unlink_silent, +}; +use std::sync::atomic::{AtomicBool, Ordering}; /// resolve callback supplied by `HttpDownloader`. Receives the final `Response` on success. pub type ResolveCallback = Box<dyn Fn(Response) + Send + Sync>; diff --git a/crates/shirabe/src/util/http/curl_response.rs b/crates/shirabe/src/util/http/curl_response.rs index cc3d21b..579bba8 100644 --- a/crates/shirabe/src/util/http/curl_response.rs +++ b/crates/shirabe/src/util/http/curl_response.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Util/Http/CurlResponse.php +use super::Response; use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; -use super::Response; - #[derive(Debug)] pub struct CurlResponse { pub(crate) inner: Response, diff --git a/crates/shirabe/src/util/http/proxy_manager.rs b/crates/shirabe/src/util/http/proxy_manager.rs index d0ff9d9..3bc0888 100644 --- a/crates/shirabe/src/util/http/proxy_manager.rs +++ b/crates/shirabe/src/util/http/proxy_manager.rs @@ -1,12 +1,11 @@ //! ref: composer/src/Composer/Util/Http/ProxyManager.php -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Mutex, OnceLock}; - use crate::downloader::TransportException; use crate::util::NoProxyPattern; use crate::util::http::ProxyItem; use crate::util::http::RequestProxy; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::{Mutex, OnceLock}; static INSTANCE: OnceLock<Mutex<Option<ProxyManager>>> = OnceLock::new(); diff --git a/crates/shirabe/src/util/http/request_proxy.rs b/crates/shirabe/src/util/http/request_proxy.rs index 49aa885..1262622 100644 --- a/crates/shirabe/src/util/http/request_proxy.rs +++ b/crates/shirabe/src/util/http/request_proxy.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Util/Http/RequestProxy.php +use crate::downloader::TransportException; use indexmap::IndexMap; use shirabe_php_shim::{ CURLAUTH_BASIC, CURLOPT_NOPROXY, CURLOPT_PROXY, CURLOPT_PROXY_CAINFO, CURLOPT_PROXY_CAPATH, CURLOPT_PROXYAUTH, CURLOPT_PROXYUSERPWD, InvalidArgumentException, PhpMixed, }; -use crate::downloader::TransportException; - // contextOptions = array{http: array{proxy: string, header?: string, request_fulluri?: bool}} type ContextOptions = IndexMap<String, IndexMap<String, PhpMixed>>; diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs index a6b62d7..18e320c 100644 --- a/crates/shirabe/src/util/http_downloader.rs +++ b/crates/shirabe/src/util/http_downloader.rs @@ -1,17 +1,5 @@ //! ref: composer/src/Composer/Util/HttpDownloader.php -use anyhow::Result; -use indexmap::IndexMap; - -use crate::util::Silencer; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, chr, - extension_loaded, file_get_contents, function_exists, implode, is_numeric, rawurldecode, - stream_context_create, stripos, strpos, substr, ucfirst, -}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::composer; use crate::config::Config; use crate::downloader::TransportException; @@ -21,10 +9,20 @@ use crate::package::version::VersionParser; use crate::util::GetResult; use crate::util::Platform; use crate::util::RemoteFilesystem; +use crate::util::Silencer; use crate::util::StreamContextFactory; use crate::util::Url; use crate::util::http::CurlDownloader; use crate::util::http::Response; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, chr, + extension_loaded, file_get_contents, function_exists, implode, is_numeric, rawurldecode, + stream_context_create, stripos, strpos, substr, ucfirst, +}; +use shirabe_semver::constraint::SimpleConstraint; /// @phpstan-type Request array{url: non-empty-string, options: mixed[], copyTo: string|null} /// @phpstan-type Job array{id: int, status: int, request: Request, sync: bool, origin: string, resolve?: callable, reject?: callable, curl_id?: int, response?: Response, exception?: \Throwable} diff --git a/crates/shirabe/src/util/package_sorter.rs b/crates/shirabe/src/util/package_sorter.rs index 6e0af01..4b76c2f 100644 --- a/crates/shirabe/src/util/package_sorter.rs +++ b/crates/shirabe/src/util/package_sorter.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Util/PackageSorter.php -use indexmap::IndexMap; -use shirabe_php_shim::{strnatcasecmp, version_compare}; - use crate::package::Link; use crate::package::PackageInterfaceHandle; +use indexmap::IndexMap; +use shirabe_php_shim::{strnatcasecmp, version_compare}; pub struct PackageSorter; diff --git a/crates/shirabe/src/util/perforce.rs b/crates/shirabe/src/util/perforce.rs index d8cd39d..bd8e9e6 100644 --- a/crates/shirabe/src/util/perforce.rs +++ b/crates/shirabe/src/util/perforce.rs @@ -1,5 +1,10 @@ //! ref: composer/src/Composer/Util/Perforce.php +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; +use crate::util::Filesystem; +use crate::util::Platform; +use crate::util::ProcessExecutor; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -11,12 +16,6 @@ use shirabe_php_shim::{ strpos, strrpos, substr, time, trim, }; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::Filesystem; -use crate::util::Platform; -use crate::util::ProcessExecutor; - /// @phpstan-type RepoConfig array{unique_perforce_client_name?: string, depot?: string, branch?: string, p4user?: string, p4password?: string} #[derive(Debug)] pub struct Perforce { diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs index 889da6e..b3b7e2b 100644 --- a/crates/shirabe/src/util/platform.rs +++ b/crates/shirabe/src/util/platform.rs @@ -1,7 +1,7 @@ //! ref: composer/src/Composer/Util/Platform.php -use std::sync::Mutex; - +use crate::util::ProcessExecutor; +use crate::util::Silencer; use anyhow::Result; use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{ @@ -11,9 +11,7 @@ use shirabe_php_shim::{ posix_isatty, putenv, putenv_clear, realpath, stream_isatty, stripos, strlen, strtoupper, substr, usleep, }; - -use crate::util::ProcessExecutor; -use crate::util::Silencer; +use std::sync::Mutex; /// Platform helper for uniform platform-specific tests. pub struct Platform; diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs index 98c3186..230695a 100644 --- a/crates/shirabe/src/util/process_executor.rs +++ b/crates/shirabe/src/util/process_executor.rs @@ -1,10 +1,12 @@ //! ref: composer/src/Composer/Util/ProcessExecutor.php +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::util::GitHub; +use crate::util::Platform; use anyhow::Result; use indexmap::IndexMap; -use std::sync::{LazyLock, Mutex}; - use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::seld::signal::SignalHandler; use shirabe_external_packages::symfony::process::ExecutableFinder; @@ -16,11 +18,7 @@ use shirabe_php_shim::{ explode, implode, in_array, is_array, is_dir, is_numeric, is_string, rtrim, sprintf, str_replace, strcspn, strlen, strpbrk, strtolower, strtr_array, substr_replace, trim, usleep, }; - -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::GitHub; -use crate::util::Platform; +use std::sync::{LazyLock, Mutex}; static EXECUTABLES: LazyLock<Mutex<IndexMap<String, String>>> = LazyLock::new(|| Mutex::new(IndexMap::new())); diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs index ca818fc..aa42f6b 100644 --- a/crates/shirabe/src/util/remote_filesystem.rs +++ b/crates/shirabe/src/util/remote_filesystem.rs @@ -1,17 +1,5 @@ //! ref: composer/src/Composer/Util/RemoteFilesystem.php -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PHP_URL_HOST, PHP_URL_PATH, PHP_URL_SCHEME, PHP_VERSION_ID, PhpMixed, RuntimeException, - STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_PROGRESS, - array_replace_recursive, base64_encode, explode, extension_loaded, file_put_contents, - filter_var_boolean, gethostbyname, http_clear_last_response_headers, - http_get_last_response_headers, ini_get, json_decode, parse_url, preg_quote, strpos, - strtolower, strtr, substr, trim, zlib_decode, -}; - use crate::config::Config; use crate::downloader::MaxFileSizeExceededException; use crate::downloader::TransportException; @@ -24,6 +12,16 @@ use crate::util::StreamContextFactory; use crate::util::Url; use crate::util::http::ProxyManager; use crate::util::http::Response; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PHP_URL_HOST, PHP_URL_PATH, PHP_URL_SCHEME, PHP_VERSION_ID, PhpMixed, RuntimeException, + STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_PROGRESS, + array_replace_recursive, base64_encode, explode, extension_loaded, file_put_contents, + filter_var_boolean, gethostbyname, http_clear_last_response_headers, + http_get_last_response_headers, ini_get, json_decode, parse_url, preg_quote, strpos, + strtolower, strtr, substr, trim, zlib_decode, +}; /// Result of `RemoteFilesystem::get` — string content, `true` (for copy), or `false`. #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/util/stream_context_factory.rs b/crates/shirabe/src/util/stream_context_factory.rs index 0b259d7..6a40cd0 100644 --- a/crates/shirabe/src/util/stream_context_factory.rs +++ b/crates/shirabe/src/util/stream_context_factory.rs @@ -1,5 +1,11 @@ //! ref: composer/src/Composer/Util/StreamContextFactory.php +use crate::composer; +use crate::downloader::TransportException; +use crate::repository::PlatformRepository; +use crate::util::Filesystem; +use crate::util::Platform; +use crate::util::http::ProxyManager; use indexmap::IndexMap; use shirabe_external_packages::composer::ca_bundle::CaBundle; use shirabe_php_shim::{ @@ -8,13 +14,6 @@ use shirabe_php_shim::{ stripos, uasort, }; -use crate::composer; -use crate::downloader::TransportException; -use crate::repository::PlatformRepository; -use crate::util::Filesystem; -use crate::util::Platform; -use crate::util::http::ProxyManager; - pub struct StreamContextFactory; impl StreamContextFactory { diff --git a/crates/shirabe/src/util/svn.rs b/crates/shirabe/src/util/svn.rs index 096d8c3..5eed44d 100644 --- a/crates/shirabe/src/util/svn.rs +++ b/crates/shirabe/src/util/svn.rs @@ -1,8 +1,11 @@ //! ref: composer/src/Composer/Util/Svn.php +use crate::config::Config; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; -use std::sync::Mutex; - +use crate::util::Platform; +use crate::util::ProcessExecutor; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; @@ -10,12 +13,7 @@ use shirabe_php_shim::{ LogicException, PHP_URL_HOST, PhpMixed, RuntimeException, empty, implode, parse_url, parse_url_all, stripos, strpos, trim, }; - -use crate::config::Config; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::Platform; -use crate::util::ProcessExecutor; +use std::sync::Mutex; #[derive(Debug, Clone)] pub struct SvnCredentials { |
