aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/installer/project_installer.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
committernsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
commita1c7e6908a26e10f6e1f23a51721664b5e2d838d (patch)
treec575c76f1b43359ed74913da4c6a2636643f1ba0 /crates/shirabe/src/installer/project_installer.rs
parent7f606f36fef0c0467c3c0db3d0da33af486dae8a (diff)
downloadphp-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.gz
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.zst
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.zip
chore(style): cargo fmt
Diffstat (limited to 'crates/shirabe/src/installer/project_installer.rs')
-rw-r--r--crates/shirabe/src/installer/project_installer.rs71
1 files changed, 55 insertions, 16 deletions
diff --git a/crates/shirabe/src/installer/project_installer.rs b/crates/shirabe/src/installer/project_installer.rs
index 6472472..1a097b0 100644
--- a/crates/shirabe/src/installer/project_installer.rs
+++ b/crates/shirabe/src/installer/project_installer.rs
@@ -1,12 +1,12 @@
//! ref: composer/src/Composer/Installer/ProjectInstaller.php
-use shirabe_external_packages::react::promise::promise_interface::PromiseInterface;
-use shirabe_php_shim::InvalidArgumentException;
use crate::downloader::download_manager::DownloadManager;
use crate::installer::installer_interface::InstallerInterface;
use crate::package::package_interface::PackageInterface;
use crate::repository::installed_repository_interface::InstalledRepositoryInterface;
use crate::util::filesystem::Filesystem;
+use shirabe_external_packages::react::promise::promise_interface::PromiseInterface;
+use shirabe_php_shim::InvalidArgumentException;
#[derive(Debug)]
pub struct ProjectInstaller {
@@ -31,49 +31,88 @@ impl InstallerInterface for ProjectInstaller {
true
}
- fn is_installed(&self, _repo: &dyn InstalledRepositoryInterface, _package: &dyn PackageInterface) -> bool {
+ fn is_installed(
+ &self,
+ _repo: &dyn InstalledRepositoryInterface,
+ _package: &dyn PackageInterface,
+ ) -> bool {
false
}
- fn download(&self, package: &dyn PackageInterface, prev_package: Option<&dyn PackageInterface>) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
+ fn download(
+ &self,
+ package: &dyn PackageInterface,
+ prev_package: Option<&dyn PackageInterface>,
+ ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
let install_path = &self.install_path;
- if std::path::Path::new(install_path).exists() && !self.filesystem.is_dir_empty(install_path) {
+ if std::path::Path::new(install_path).exists()
+ && !self.filesystem.is_dir_empty(install_path)
+ {
return Err(InvalidArgumentException {
message: format!("Project directory {} is not empty.", install_path),
code: 0,
- }.into());
+ }
+ .into());
}
if !std::path::Path::new(install_path).is_dir() {
std::fs::create_dir_all(install_path)?;
}
- self.download_manager.download(package, install_path, prev_package)
+ self.download_manager
+ .download(package, install_path, prev_package)
}
- fn prepare(&self, r#type: &str, package: &dyn PackageInterface, prev_package: Option<&dyn PackageInterface>) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
- self.download_manager.prepare(r#type, package, &self.install_path, prev_package)
+ fn prepare(
+ &self,
+ r#type: &str,
+ package: &dyn PackageInterface,
+ prev_package: Option<&dyn PackageInterface>,
+ ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
+ self.download_manager
+ .prepare(r#type, package, &self.install_path, prev_package)
}
- fn cleanup(&self, r#type: &str, package: &dyn PackageInterface, prev_package: Option<&dyn PackageInterface>) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
- self.download_manager.cleanup(r#type, package, &self.install_path, prev_package)
+ fn cleanup(
+ &self,
+ r#type: &str,
+ package: &dyn PackageInterface,
+ prev_package: Option<&dyn PackageInterface>,
+ ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
+ self.download_manager
+ .cleanup(r#type, package, &self.install_path, prev_package)
}
- fn install(&self, _repo: &mut dyn InstalledRepositoryInterface, package: &dyn PackageInterface) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
+ fn install(
+ &self,
+ _repo: &mut dyn InstalledRepositoryInterface,
+ package: &dyn PackageInterface,
+ ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
self.download_manager.install(package, &self.install_path)
}
- fn update(&self, _repo: &mut dyn InstalledRepositoryInterface, _initial: &dyn PackageInterface, _target: &dyn PackageInterface) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
+ fn update(
+ &self,
+ _repo: &mut dyn InstalledRepositoryInterface,
+ _initial: &dyn PackageInterface,
+ _target: &dyn PackageInterface,
+ ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
Err(InvalidArgumentException {
message: "not supported".to_string(),
code: 0,
- }.into())
+ }
+ .into())
}
- fn uninstall(&self, _repo: &mut dyn InstalledRepositoryInterface, _package: &dyn PackageInterface) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
+ fn uninstall(
+ &self,
+ _repo: &mut dyn InstalledRepositoryInterface,
+ _package: &dyn PackageInterface,
+ ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>> {
Err(InvalidArgumentException {
message: "not supported".to_string(),
code: 0,
- }.into())
+ }
+ .into())
}
fn get_install_path(&self, _package: &dyn PackageInterface) -> Option<String> {