aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-17 14:33:13 +0900
committernsfisis <nsfisis@gmail.com>2026-05-17 14:38:16 +0900
commit3e21569688cf0c8a1918c73ff96cb1b3aeffe0b3 (patch)
tree712ae7832124da20739f5b389cebe4f44abd7225 /crates/shirabe/src/downloader
parentac59538140a93d9a023da2115148bc9779223978 (diff)
downloadphp-shirabe-3e21569688cf0c8a1918c73ff96cb1b3aeffe0b3.tar.gz
php-shirabe-3e21569688cf0c8a1918c73ff96cb1b3aeffe0b3.tar.zst
php-shirabe-3e21569688cf0c8a1918c73ff96cb1b3aeffe0b3.zip
fix(compile): extract constants from traits to make them dyn-compatible
Diffstat (limited to 'crates/shirabe/src/downloader')
-rw-r--r--crates/shirabe/src/downloader/download_manager.rs7
-rw-r--r--crates/shirabe/src/downloader/file_downloader.rs3
-rw-r--r--crates/shirabe/src/downloader/git_downloader.rs29
-rw-r--r--crates/shirabe/src/downloader/path_downloader.rs23
-rw-r--r--crates/shirabe/src/downloader/svn_downloader.rs15
-rw-r--r--crates/shirabe/src/downloader/vcs_downloader.rs23
6 files changed, 53 insertions, 47 deletions
diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs
index 83ba219..c03f704 100644
--- a/crates/shirabe/src/downloader/download_manager.rs
+++ b/crates/shirabe/src/downloader/download_manager.rs
@@ -1,5 +1,6 @@
//! ref: composer/src/Composer/Downloader/DownloadManager.php
+use crate::io::io_interface;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::preg::Preg;
@@ -222,7 +223,7 @@ impl DownloadManager {
source,
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
// TODO(phase-b): &mut on shared package — PHP mutates by reference
@@ -257,7 +258,7 @@ impl DownloadManager {
e,
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
retry_state = true;
@@ -364,7 +365,7 @@ impl DownloadManager {
self.io.write_error(
PhpMixed::String(format!("<error> Update failed ({})</error>", e,)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
if !self.io.ask_confirmation(
" Would you like to try reinstalling the package instead [<comment>yes</comment>]? ".to_string(),
diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs
index c9c9392..e6b471f 100644
--- a/crates/shirabe/src/downloader/file_downloader.rs
+++ b/crates/shirabe/src/downloader/file_downloader.rs
@@ -1,5 +1,6 @@
//! ref: composer/src/Composer/Downloader/FileDownloader.php
+use crate::io::io_interface;
use anyhow::Result;
use indexmap::IndexMap;
use std::sync::{LazyLock, Mutex};
@@ -102,7 +103,7 @@ impl FileDownloader {
};
if this.cache.is_some() && this.cache.as_ref().unwrap().gc_is_necessary() {
- // PHP: writeError('Running cache garbage collection', true, IOInterface::VERY_VERBOSE)
+ // PHP: writeError('Running cache garbage collection', true, io_interface::VERY_VERBOSE)
this.io.write_error("Running cache garbage collection");
this.cache.as_mut().unwrap().gc(
this.config.get("cache-files-ttl").as_int().unwrap_or(0),
diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs
index 1bc0ff1..45849cb 100644
--- a/crates/shirabe/src/downloader/git_downloader.rs
+++ b/crates/shirabe/src/downloader/git_downloader.rs
@@ -1,5 +1,6 @@
//! ref: composer/src/Composer/Downloader/GitDownloader.php
+use crate::io::io_interface;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::preg::Preg;
@@ -89,7 +90,7 @@ impl GitDownloader {
package.get_full_pretty_version(),
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
self.inner.io.write_error(
PhpMixed::String(sprintf(
@@ -97,7 +98,7 @@ impl GitDownloader {
&[PhpMixed::String(cache_path.clone())],
)),
true,
- IOInterface::DEBUG,
+ io_interface::DEBUG,
);
let r#ref = package.get_source_reference();
if self.git_util.fetch_ref_or_sync_mirror(
@@ -251,7 +252,7 @@ impl GitDownloader {
self.inner
.io
- .write_error(PhpMixed::String(msg), true, IOInterface::NORMAL);
+ .write_error(PhpMixed::String(msg), true, io_interface::NORMAL);
self.git_util.run_commands(commands, url, &path, true);
@@ -335,7 +336,7 @@ impl GitDownloader {
self.inner
.io
- .write_error(PhpMixed::String(msg), true, IOInterface::NORMAL);
+ .write_error(PhpMixed::String(msg), true, io_interface::NORMAL);
let mut output = String::new();
if self.inner.process.execute(
@@ -694,7 +695,7 @@ impl GitDownloader {
package.get_pretty_name()
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
let slice_end = 10_usize.min(changes.len());
self.inner.io.write_error(
@@ -705,7 +706,7 @@ impl GitDownloader {
.collect(),
),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
if (changes.len() as i64) > 10 {
self.inner.io.write_error(
@@ -714,7 +715,7 @@ impl GitDownloader {
changes.len() as i64 - 10
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
@@ -762,7 +763,7 @@ impl GitDownloader {
.collect(),
),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
Some("d") => {
@@ -792,7 +793,7 @@ impl GitDownloader {
)),
]),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
if update {
self.inner.io.write_error(
@@ -801,13 +802,13 @@ impl GitDownloader {
.to_string(),
),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
self.inner.io.write_error(
PhpMixed::String(" ? - print help".to_string()),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
}
@@ -827,7 +828,7 @@ impl GitDownloader {
self.inner.io.write_error(
PhpMixed::String(" <info>Re-applying stashed changes</info>".to_string()),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
let mut output = String::new();
if self.inner.process.execute(
@@ -1058,7 +1059,7 @@ impl GitDownloader {
reference
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
exception_extra = format!(
"\nIt looks like the commit hash is not available in the repository, maybe {}? Run \"composer update {}\" to resolve this.",
@@ -1249,7 +1250,7 @@ impl GitDownloader {
self.inner
.io
- .write_error(PhpMixed::String(output), true, IOInterface::NORMAL);
+ .write_error(PhpMixed::String(output), true, io_interface::NORMAL);
}
pub(crate) fn normalize_path(&self, path: &str) -> String {
diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs
index 33e3b45..c50d390 100644
--- a/crates/shirabe/src/downloader/path_downloader.rs
+++ b/crates/shirabe/src/downloader/path_downloader.rs
@@ -1,5 +1,6 @@
//! ref: composer/src/Composer/Downloader/PathDownloader.php
+use crate::io::io_interface;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::react::promise::promise_interface::PromiseInterface;
@@ -123,7 +124,7 @@ impl PathDownloader {
appendix
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
@@ -149,7 +150,7 @@ impl PathDownloader {
InstallOperation::format(package, false)
)),
false,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
@@ -162,7 +163,7 @@ impl PathDownloader {
self.inner.io.write_error(
PhpMixed::String(format!("Junctioning from {}", url)),
false,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
Ok(self.inner.filesystem.junction(&real_url, &path))
@@ -172,7 +173,7 @@ impl PathDownloader {
self.inner.io.write_error(
PhpMixed::String(format!("Symlinking from {}", url)),
false,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
if transport_options
@@ -211,7 +212,7 @@ impl PathDownloader {
self.inner.io.write_error(
PhpMixed::String("".to_string()),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
self.inner.io.write_error(
PhpMixed::String(
@@ -219,7 +220,7 @@ impl PathDownloader {
.to_string(),
),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
current_strategy = Self::STRATEGY_MIRROR;
@@ -250,7 +251,7 @@ impl PathDownloader {
url
)),
false,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
let iterator = ArchivableFilesFinder::new(&real_url, vec![]);
@@ -260,7 +261,7 @@ impl PathDownloader {
if output {
self.inner
.io
- .write_error(PhpMixed::String("".to_string()), true, IOInterface::NORMAL);
+ .write_error(PhpMixed::String("".to_string()), true, io_interface::NORMAL);
}
Ok(shirabe_external_packages::react::promise::resolve(None))
@@ -290,7 +291,7 @@ impl PathDownloader {
path
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
if !self.inner.filesystem.remove_junction(&path) {
@@ -300,7 +301,7 @@ impl PathDownloader {
path
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
return Err(RuntimeException {
message: format!(
@@ -347,7 +348,7 @@ impl PathDownloader {
path
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs
index ef006f3..eb4de65 100644
--- a/crates/shirabe/src/downloader/svn_downloader.rs
+++ b/crates/shirabe/src/downloader/svn_downloader.rs
@@ -1,5 +1,6 @@
//! ref: composer/src/Composer/Downloader/SvnDownloader.php
+use crate::io::io_interface;
use shirabe_external_packages::composer::pcre::preg::Preg;
use shirabe_external_packages::react::promise;
use shirabe_external_packages::react::promise::promise_interface::PromiseInterface;
@@ -70,7 +71,7 @@ impl SvnDownloader {
self.inner.io.write_error(
PhpMixed::String(format!(" Checking out {}", package.get_source_reference())),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
self.execute(
package,
@@ -119,7 +120,7 @@ impl SvnDownloader {
self.inner.io.write_error(
PhpMixed::String(format!(" Checking out {}", r#ref)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
let mut command = vec!["svn".to_string(), "switch".to_string()];
command.extend(flags);
@@ -214,7 +215,7 @@ impl SvnDownloader {
if count_changes == 1 { "" } else { "s" }
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
let slice_end = 10_usize.min(changes.len());
self.inner.io.write_error(
@@ -225,7 +226,7 @@ impl SvnDownloader {
.collect(),
),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
if count_changes > 10 {
let remaining_changes = count_changes - 10;
@@ -236,7 +237,7 @@ impl SvnDownloader {
if remaining_changes == 1 { "" } else { "s" }
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
@@ -270,7 +271,7 @@ impl SvnDownloader {
.collect(),
),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
_ => {
@@ -288,7 +289,7 @@ impl SvnDownloader {
Box::new(PhpMixed::String(" ? - print help".to_string())),
]),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
}
diff --git a/crates/shirabe/src/downloader/vcs_downloader.rs b/crates/shirabe/src/downloader/vcs_downloader.rs
index 9ec86ff..05593e5 100644
--- a/crates/shirabe/src/downloader/vcs_downloader.rs
+++ b/crates/shirabe/src/downloader/vcs_downloader.rs
@@ -1,5 +1,6 @@
//! ref: composer/src/Composer/Downloader/VcsDownloader.php
+use crate::io::io_interface;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::react::promise::promise_interface::PromiseInterface;
@@ -138,7 +139,7 @@ pub trait VcsDownloader:
self.io_mut().write_error(
PhpMixed::String(format!("Failed: [{}] {}", get_class(&e), e,)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
} else if count(&PhpMixed::List(
urls.iter()
@@ -149,7 +150,7 @@ pub trait VcsDownloader:
self.io_mut().write_error(
PhpMixed::String(" Failed, trying the next URL".to_string()),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
if count(&PhpMixed::List(
@@ -232,7 +233,7 @@ pub trait VcsDownloader:
InstallOperation::format(package, false)
)),
false,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
let mut urls = self.prepare_urls(package.get_source_urls());
@@ -252,7 +253,7 @@ pub trait VcsDownloader:
self.io_mut().write_error(
PhpMixed::String(format!("Failed: [{}] {}", get_class(&e), e,)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
} else if count(&PhpMixed::List(
urls.iter()
@@ -263,7 +264,7 @@ pub trait VcsDownloader:
self.io_mut().write_error(
PhpMixed::String(" Failed, trying the next URL".to_string()),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
if count(&PhpMixed::List(
@@ -304,7 +305,7 @@ pub trait VcsDownloader:
UpdateOperation::format(initial, target, false),
)),
false,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
let mut urls = self.prepare_urls(target.get_source_urls());
@@ -330,7 +331,7 @@ pub trait VcsDownloader:
self.io_mut().write_error(
PhpMixed::String(format!("Failed: [{}] {}", get_class(&e), e,)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
} else if count(&PhpMixed::List(
urls.iter()
@@ -341,7 +342,7 @@ pub trait VcsDownloader:
self.io_mut().write_error(
PhpMixed::String(" Failed, trying the next URL".to_string()),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
}
exception = Some(e);
@@ -381,10 +382,10 @@ pub trait VcsDownloader:
self.io_mut().write_error(
PhpMixed::String(format!(" {}", message)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
self.io_mut()
- .write_error(PhpMixed::String(logs), true, IOInterface::NORMAL);
+ .write_error(PhpMixed::String(logs), true, io_interface::NORMAL);
}
}
@@ -408,7 +409,7 @@ pub trait VcsDownloader:
UninstallOperation::format(package, false)
)),
true,
- IOInterface::NORMAL,
+ io_interface::NORMAL,
);
let promise = self.filesystem_mut().remove_directory_async(path);