diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-19 00:10:22 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-19 00:11:03 +0900 |
| commit | c839244d8d09f3036ebfee8eef7eb6b147e593ab (patch) | |
| tree | fe48c94f2c2e62468beef5ff1a8f3cff6adeef4f /crates/shirabe/src/installer | |
| parent | 48839250146b217e2756ed3c0e624fd341b54d6c (diff) | |
| download | php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.gz php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.tar.zst php-shirabe-c839244d8d09f3036ebfee8eef7eb6b147e593ab.zip | |
fix(compile): fix various compile errors
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer')
| -rw-r--r-- | crates/shirabe/src/installer/binary_installer.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/installation_manager.rs | 23 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/installer_event.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/installer_interface.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/library_installer.rs | 28 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/metapackage_installer.rs | 16 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/noop_installer.rs | 10 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/package_event.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/plugin_installer.rs | 19 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/project_installer.rs | 26 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/suggested_packages_reporter.rs | 1 |
11 files changed, 87 insertions, 54 deletions
diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs index 243dde0..e6677ed 100644 --- a/crates/shirabe/src/installer/binary_installer.rs +++ b/crates/shirabe/src/installer/binary_installer.rs @@ -33,7 +33,7 @@ impl BinaryInstaller { filesystem: Option<Filesystem>, vendor_dir: Option<String>, ) -> Self { - let filesystem = filesystem.unwrap_or_else(Filesystem::new); + let filesystem = filesystem.unwrap_or_else(|| Filesystem::new(None)); Self { bin_dir, bin_compat, diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs index 798ea00..59e029a 100644 --- a/crates/shirabe/src/installer/installation_manager.rs +++ b/crates/shirabe/src/installer/installation_manager.rs @@ -40,7 +40,7 @@ pub struct InstallationManager { cache: IndexMap<String, Box<dyn InstallerInterface>>, /// @var array<string, array<PackageInterface>> notifiable_packages: IndexMap<String, Vec<Box<dyn PackageInterface>>>, - loop_: Loop, + loop_: std::rc::Rc<std::cell::RefCell<Loop>>, io: Box<dyn IOInterface>, event_dispatcher: Option<EventDispatcher>, output_progress: bool, @@ -48,7 +48,7 @@ pub struct InstallationManager { impl InstallationManager { pub fn new( - loop_: Loop, + loop_: std::rc::Rc<std::cell::RefCell<Loop>>, io: Box<dyn IOInterface>, event_dispatcher: Option<EventDispatcher>, ) -> Self { @@ -527,13 +527,12 @@ impl InstallationManager { // TODO(phase-b): progress = self.io.get_progress_bar(); progress = Some(()); } - self.loop_.wait(promises, progress); + let _ = self.loop_.borrow_mut().wait(promises, progress); if progress.is_some() { // progress.clear(); // ProgressBar in non-decorated output does not output a final line-break and clear() does nothing if !self.io.is_decorated() { - self.io - .write_error(PhpMixed::String(String::new()), true, io_interface::NORMAL); + self.io.write_error3("", true, io_interface::NORMAL); } } } @@ -628,7 +627,7 @@ impl InstallationManager { let package = operation.get_package(); if !repo.has_package(package) { - repo.add_package(package.clone_box()); + repo.add_package(package.clone_package_box()); } } @@ -697,7 +696,7 @@ impl InstallationManager { ), ); - promises.push(self.loop_.get_http_downloader().add( + promises.push(self.loop_.borrow().get_http_downloader().add( &url, &PhpMixed::Array( opts.into_iter().map(|(k, v)| (k, Box::new(v))).collect(), @@ -768,13 +767,13 @@ impl InstallationManager { PhpMixed::Array(http.into_iter().map(|(k, v)| (k, Box::new(v))).collect()), ); - promises.push(self.loop_.get_http_downloader().add( + promises.push(self.loop_.borrow().get_http_downloader().add( repo_url, &PhpMixed::Array(opts.into_iter().map(|(k, v)| (k, Box::new(v))).collect()), )); } - self.loop_.wait(promises, None); + let _ = self.loop_.borrow_mut().wait(promises, None); Ok(()) })(); @@ -789,7 +788,7 @@ impl InstallationManager { self.notifiable_packages .entry(notification_url.to_string()) .or_insert_with(Vec::new) - .push(package.clone_box()); + .push(package.clone_package_box()); } } @@ -800,7 +799,7 @@ impl InstallationManager { ) { let mut promises: Vec<Box<dyn PromiseInterface>> = vec![]; - self.loop_.abort_jobs(); + self.loop_.borrow().abort_jobs(); for (_, cleanup) in cleanup_promises { // TODO(phase-b): React\Promise\Promise constructor with executor; emulate by wrapping cleanup() @@ -813,7 +812,7 @@ impl InstallationManager { } if (promises.len() as i64) > 0 { - self.loop_.wait(promises, None); + let _ = self.loop_.borrow_mut().wait(promises, None); } } } diff --git a/crates/shirabe/src/installer/installer_event.rs b/crates/shirabe/src/installer/installer_event.rs index 456a4bd..20a8b27 100644 --- a/crates/shirabe/src/installer/installer_event.rs +++ b/crates/shirabe/src/installer/installer_event.rs @@ -24,7 +24,7 @@ impl InstallerEvent { execute_operations: bool, transaction: Transaction, ) -> Self { - let inner = Event::new(event_name, vec![], vec![]); + let inner = Event::new(event_name, vec![], indexmap::IndexMap::new()); Self { inner, composer, diff --git a/crates/shirabe/src/installer/installer_interface.rs b/crates/shirabe/src/installer/installer_interface.rs index 16cf10c..cf700be 100644 --- a/crates/shirabe/src/installer/installer_interface.rs +++ b/crates/shirabe/src/installer/installer_interface.rs @@ -27,20 +27,20 @@ pub trait InstallerInterface { ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>; fn install( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>; fn update( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, initial: &dyn PackageInterface, target: &dyn PackageInterface, ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>; fn uninstall( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>; @@ -53,4 +53,8 @@ pub trait InstallerInterface { ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>; fn get_install_path(&self, package: &dyn PackageInterface) -> Option<String>; + + fn clone_box(&self) -> Box<dyn InstallerInterface> { + todo!() + } } diff --git a/crates/shirabe/src/installer/library_installer.rs b/crates/shirabe/src/installer/library_installer.rs index af11ef6..17404e2 100644 --- a/crates/shirabe/src/installer/library_installer.rs +++ b/crates/shirabe/src/installer/library_installer.rs @@ -27,7 +27,7 @@ use crate::util::silencer::Silencer; pub struct LibraryInstaller { pub(crate) composer: PartialComposer, pub(crate) vendor_dir: String, - pub(crate) download_manager: Option<DownloadManager>, + pub(crate) download_manager: Option<std::rc::Rc<std::cell::RefCell<DownloadManager>>>, pub(crate) io: Box<dyn IOInterface>, pub(crate) r#type: Option<String>, pub(crate) filesystem: Filesystem, @@ -53,7 +53,7 @@ impl LibraryInstaller { None }; - let filesystem = filesystem.unwrap_or_else(Filesystem::new); + let filesystem = filesystem.unwrap_or_else(|| Filesystem::new(None)); let vendor_dir = rtrim( // TODO(phase-b): composer.get_config().get("vendor-dir") returns a PhpMixed/String &composer.get_config().get("vendor-dir"), @@ -123,7 +123,9 @@ impl LibraryInstaller { ) -> Result<Option<Box<dyn PromiseInterface>>> { let download_path = self.get_install_path(package).unwrap(); - self.get_download_manager().install(package, &download_path) + self.get_download_manager() + .borrow() + .install(package, &download_path) } /// @return PromiseInterface|null @@ -165,6 +167,7 @@ impl LibraryInstaller { } self.get_download_manager() + .borrow() .update(initial, target, &target_download_path) } @@ -176,7 +179,9 @@ impl LibraryInstaller { ) -> Result<Option<Box<dyn PromiseInterface>>> { let download_path = self.get_package_base_path(package); - self.get_download_manager().remove(package, &download_path) + self.get_download_manager() + .borrow() + .remove(package, &download_path) } pub(crate) fn initialize_vendor_dir(&mut self) { @@ -185,7 +190,7 @@ impl LibraryInstaller { self.vendor_dir = realpath(&self.vendor_dir).unwrap(); } - pub(crate) fn get_download_manager(&self) -> &DownloadManager { + pub(crate) fn get_download_manager(&self) -> &std::rc::Rc<std::cell::RefCell<DownloadManager>> { // PHP: assert($this->downloadManager instanceof DownloadManager, new \LogicException(...)) assert!( self.download_manager.is_some(), @@ -252,6 +257,7 @@ impl InstallerInterface for LibraryInstaller { let download_path = self.get_install_path(package).unwrap(); self.get_download_manager() + .borrow() .download(package, &download_path, prev_package) } @@ -266,6 +272,7 @@ impl InstallerInterface for LibraryInstaller { let download_path = self.get_install_path(package).unwrap(); self.get_download_manager() + .borrow() .prepare(r#type, package, &download_path, prev_package) } @@ -280,11 +287,12 @@ impl InstallerInterface for LibraryInstaller { let download_path = self.get_install_path(package).unwrap(); self.get_download_manager() + .borrow() .cleanup(r#type, package, &download_path, prev_package) } fn install( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> Result<Option<Box<dyn PromiseInterface>>> { @@ -310,14 +318,14 @@ impl InstallerInterface for LibraryInstaller { Ok(Some(promise.then(Box::new(move || -> Result<()> { binary_installer.install_binaries(package, &install_path, true); if !repo.has_package(package) { - repo.add_package(package.clone_box())?; + repo.add_package(package.clone_package_box())?; } Ok(()) })))) } fn update( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, initial: &dyn PackageInterface, target: &dyn PackageInterface, @@ -348,14 +356,14 @@ impl InstallerInterface for LibraryInstaller { binary_installer.install_binaries(target, &install_path, true); repo.remove_package(initial)?; if !repo.has_package(target) { - repo.add_package(target.clone_box())?; + repo.add_package(target.clone_package_box())?; } Ok(()) })))) } fn uninstall( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> Result<Option<Box<dyn PromiseInterface>>> { diff --git a/crates/shirabe/src/installer/metapackage_installer.rs b/crates/shirabe/src/installer/metapackage_installer.rs index 3a47f70..e30ef85 100644 --- a/crates/shirabe/src/installer/metapackage_installer.rs +++ b/crates/shirabe/src/installer/metapackage_installer.rs @@ -69,17 +69,17 @@ impl InstallerInterface for MetapackageInstaller { } fn install( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> Result<Option<Box<dyn PromiseInterface>>> { - self.io.write_error( + self.io.write_error3( &format!(" - {}", InstallOperation::format(package, false)), true, io_interface::NORMAL, ); - repo.add_package(package.clone_box()); + repo.add_package(package.clone_package_box()); Ok(Some(shirabe_external_packages::react::promise::resolve( None, @@ -87,7 +87,7 @@ impl InstallerInterface for MetapackageInstaller { } fn update( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, initial: &dyn PackageInterface, target: &dyn PackageInterface, @@ -100,14 +100,14 @@ impl InstallerInterface for MetapackageInstaller { .into()); } - self.io.write_error( + self.io.write_error3( &format!(" - {}", UpdateOperation::format(initial, target, false)), true, io_interface::NORMAL, ); repo.remove_package(initial); - repo.add_package(target.clone_box()); + repo.add_package(target.clone_package_box()); Ok(Some(shirabe_external_packages::react::promise::resolve( None, @@ -115,7 +115,7 @@ impl InstallerInterface for MetapackageInstaller { } fn uninstall( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> Result<Option<Box<dyn PromiseInterface>>> { @@ -127,7 +127,7 @@ impl InstallerInterface for MetapackageInstaller { .into()); } - self.io.write_error( + self.io.write_error3( &format!(" - {}", UninstallOperation::format(package, false)), true, io_interface::NORMAL, diff --git a/crates/shirabe/src/installer/noop_installer.rs b/crates/shirabe/src/installer/noop_installer.rs index 09e6afd..8180402 100644 --- a/crates/shirabe/src/installer/noop_installer.rs +++ b/crates/shirabe/src/installer/noop_installer.rs @@ -55,12 +55,12 @@ impl InstallerInterface for NoopInstaller { } fn install( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> { if !repo.has_package(package) { - repo.add_package(package.clone_box()); + repo.add_package(package.clone_package_box()); } Ok(Some(shirabe_external_packages::react::promise::resolve( @@ -69,7 +69,7 @@ impl InstallerInterface for NoopInstaller { } fn update( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, initial: &dyn PackageInterface, target: &dyn PackageInterface, @@ -84,7 +84,7 @@ impl InstallerInterface for NoopInstaller { repo.remove_package(initial); if !repo.has_package(target) { - repo.add_package(target.clone_box()); + repo.add_package(target.clone_package_box()); } Ok(Some(shirabe_external_packages::react::promise::resolve( @@ -93,7 +93,7 @@ impl InstallerInterface for NoopInstaller { } fn uninstall( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> { diff --git a/crates/shirabe/src/installer/package_event.rs b/crates/shirabe/src/installer/package_event.rs index 2bf1c6b..8b6fbbe 100644 --- a/crates/shirabe/src/installer/package_event.rs +++ b/crates/shirabe/src/installer/package_event.rs @@ -39,6 +39,10 @@ impl PackageEvent { } } + pub fn get_name(&self) -> &str { + self.inner.get_name() + } + pub fn get_composer(&self) -> &Composer { &self.composer } diff --git a/crates/shirabe/src/installer/plugin_installer.rs b/crates/shirabe/src/installer/plugin_installer.rs index 1fd2334..77bd669 100644 --- a/crates/shirabe/src/installer/plugin_installer.rs +++ b/crates/shirabe/src/installer/plugin_installer.rs @@ -37,13 +37,13 @@ impl PluginInstaller { } } - pub fn disable_plugins(&self) { + pub fn disable_plugins(&mut self) { // TODO(plugin): disable plugins via plugin manager - self.get_plugin_manager().disable_plugins(); + self.get_plugin_manager_mut().disable_plugins(); } fn rollback_install( - &self, + &mut self, e: anyhow::Error, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, @@ -71,6 +71,11 @@ impl PluginInstaller { // TODO(plugin): return plugin manager from composer self.inner.composer.get_plugin_manager() } + + fn get_plugin_manager_mut(&mut self) -> &mut PluginManager { + // TODO(plugin): return mutable plugin manager from composer + todo!() + } } impl InstallerInterface for PluginInstaller { @@ -129,7 +134,7 @@ impl InstallerInterface for PluginInstaller { } fn install( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> Result<Option<Box<dyn PromiseInterface>>> { @@ -149,7 +154,7 @@ impl InstallerInterface for PluginInstaller { } fn update( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, initial: &dyn PackageInterface, target: &dyn PackageInterface, @@ -171,12 +176,12 @@ impl InstallerInterface for PluginInstaller { } fn uninstall( - &self, + &mut self, repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> Result<Option<Box<dyn PromiseInterface>>> { // TODO(plugin): uninstall package from plugin manager - self.get_plugin_manager().uninstall_package(package); + self.get_plugin_manager_mut().uninstall_package(package); self.inner.uninstall(repo, package) } diff --git a/crates/shirabe/src/installer/project_installer.rs b/crates/shirabe/src/installer/project_installer.rs index 1a097b0..f8b0bba 100644 --- a/crates/shirabe/src/installer/project_installer.rs +++ b/crates/shirabe/src/installer/project_installer.rs @@ -11,13 +11,17 @@ use shirabe_php_shim::InvalidArgumentException; #[derive(Debug)] pub struct ProjectInstaller { install_path: String, - download_manager: DownloadManager, + download_manager: std::rc::Rc<std::cell::RefCell<DownloadManager>>, filesystem: Filesystem, } impl ProjectInstaller { - pub fn new(install_path: &str, dm: DownloadManager, fs: Filesystem) -> Self { - let install_path = format!("{}/", install_path.replace('\\', '/').trim_end_matches('/')); + pub fn new( + install_path: &str, + dm: std::rc::Rc<std::cell::RefCell<DownloadManager>>, + fs: Filesystem, + ) -> Self { + let install_path = format!("{}/", install_path.replace('\\', "/").trim_end_matches('/')); Self { install_path, download_manager: dm, @@ -59,7 +63,9 @@ impl InstallerInterface for ProjectInstaller { } self.download_manager + .borrow() .download(package, install_path, prev_package) + .map(Some) } fn prepare( @@ -69,7 +75,9 @@ impl InstallerInterface for ProjectInstaller { prev_package: Option<&dyn PackageInterface>, ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> { self.download_manager + .borrow() .prepare(r#type, package, &self.install_path, prev_package) + .map(Some) } fn cleanup( @@ -79,19 +87,23 @@ impl InstallerInterface for ProjectInstaller { prev_package: Option<&dyn PackageInterface>, ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> { self.download_manager + .borrow() .cleanup(r#type, package, &self.install_path, prev_package) + .map(Some) } fn install( - &self, + &mut self, _repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface, ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> { - self.download_manager.install(package, &self.install_path) + self.download_manager + .borrow() + .install(package, &self.install_path) } fn update( - &self, + &mut self, _repo: &mut dyn InstalledRepositoryInterface, _initial: &dyn PackageInterface, _target: &dyn PackageInterface, @@ -104,7 +116,7 @@ impl InstallerInterface for ProjectInstaller { } fn uninstall( - &self, + &mut self, _repo: &mut dyn InstalledRepositoryInterface, _package: &dyn PackageInterface, ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> { diff --git a/crates/shirabe/src/installer/suggested_packages_reporter.rs b/crates/shirabe/src/installer/suggested_packages_reporter.rs index cfee20b..31a34d8 100644 --- a/crates/shirabe/src/installer/suggested_packages_reporter.rs +++ b/crates/shirabe/src/installer/suggested_packages_reporter.rs @@ -3,6 +3,7 @@ use crate::io::io_interface::IOInterface; use crate::package::package_interface::PackageInterface; use crate::repository::installed_repository::InstalledRepository; +use crate::repository::repository_interface::RepositoryInterface; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_external_packages::symfony::component::console::formatter::output_formatter::OutputFormatter; |
