aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/mozart-core/src')
-rw-r--r--crates/mozart-core/src/downloader.rs47
-rw-r--r--crates/mozart-core/src/downloader/archive_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/change_report_interface.rs1
-rw-r--r--crates/mozart-core/src/downloader/download_manager.rs (renamed from crates/mozart-core/src/repository/download_manager.rs)8
-rw-r--r--crates/mozart-core/src/downloader/downloader_interface.rs1
-rw-r--r--crates/mozart-core/src/downloader/dvcs_downloader_interface.rs1
-rw-r--r--crates/mozart-core/src/downloader/file_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/filesystem_exception.rs1
-rw-r--r--crates/mozart-core/src/downloader/fossil_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/git_downloader.rs (renamed from crates/mozart-core/src/vcs/downloader/git.rs)7
-rw-r--r--crates/mozart-core/src/downloader/gzip_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/hg_downloader.rs (renamed from crates/mozart-core/src/vcs/downloader/hg.rs)4
-rw-r--r--crates/mozart-core/src/downloader/max_file_size_exceeded_exception.rs1
-rw-r--r--crates/mozart-core/src/downloader/path_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/perforce_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/phar_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/rar_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/svn_downloader.rs (renamed from crates/mozart-core/src/vcs/downloader/svn.rs)5
-rw-r--r--crates/mozart-core/src/downloader/tar_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/transport_exception.rs1
-rw-r--r--crates/mozart-core/src/downloader/vcs_capable_downloader_interface.rs1
-rw-r--r--crates/mozart-core/src/downloader/vcs_downloader.rs (renamed from crates/mozart-core/src/vcs/downloader/mod.rs)31
-rw-r--r--crates/mozart-core/src/downloader/xz_downloader.rs1
-rw-r--r--crates/mozart-core/src/downloader/zip_downloader.rs1
-rw-r--r--crates/mozart-core/src/lib.rs1
-rw-r--r--crates/mozart-core/src/repository.rs1
-rw-r--r--crates/mozart-core/src/repository/installer_executor/filesystem.rs18
-rw-r--r--crates/mozart-core/src/vcs.rs1
28 files changed, 101 insertions, 40 deletions
diff --git a/crates/mozart-core/src/downloader.rs b/crates/mozart-core/src/downloader.rs
new file mode 100644
index 0000000..f298085
--- /dev/null
+++ b/crates/mozart-core/src/downloader.rs
@@ -0,0 +1,47 @@
+mod archive_downloader;
+mod change_report_interface;
+mod download_manager;
+mod downloader_interface;
+mod dvcs_downloader_interface;
+mod file_downloader;
+mod filesystem_exception;
+mod fossil_downloader;
+mod git_downloader;
+mod gzip_downloader;
+mod hg_downloader;
+mod max_file_size_exceeded_exception;
+mod path_downloader;
+mod perforce_downloader;
+mod phar_downloader;
+mod rar_downloader;
+mod svn_downloader;
+mod tar_downloader;
+mod transport_exception;
+mod vcs_capable_downloader_interface;
+mod vcs_downloader;
+mod xz_downloader;
+mod zip_downloader;
+
+pub use archive_downloader::*;
+pub use change_report_interface::*;
+pub use download_manager::*;
+pub use downloader_interface::*;
+pub use dvcs_downloader_interface::*;
+pub use file_downloader::*;
+pub use filesystem_exception::*;
+pub use fossil_downloader::*;
+pub use git_downloader::*;
+pub use gzip_downloader::*;
+pub use hg_downloader::*;
+pub use max_file_size_exceeded_exception::*;
+pub use path_downloader::*;
+pub use perforce_downloader::*;
+pub use phar_downloader::*;
+pub use rar_downloader::*;
+pub use svn_downloader::*;
+pub use tar_downloader::*;
+pub use transport_exception::*;
+pub use vcs_capable_downloader_interface::*;
+pub use vcs_downloader::*;
+pub use xz_downloader::*;
+pub use zip_downloader::*;
diff --git a/crates/mozart-core/src/downloader/archive_downloader.rs b/crates/mozart-core/src/downloader/archive_downloader.rs
new file mode 100644
index 0000000..3023609
--- /dev/null
+++ b/crates/mozart-core/src/downloader/archive_downloader.rs
@@ -0,0 +1 @@
+pub struct ArchiveDownloader;
diff --git a/crates/mozart-core/src/downloader/change_report_interface.rs b/crates/mozart-core/src/downloader/change_report_interface.rs
new file mode 100644
index 0000000..3a3b483
--- /dev/null
+++ b/crates/mozart-core/src/downloader/change_report_interface.rs
@@ -0,0 +1 @@
+pub trait ChangeReportInterface {}
diff --git a/crates/mozart-core/src/repository/download_manager.rs b/crates/mozart-core/src/downloader/download_manager.rs
index d422899..c83bc64 100644
--- a/crates/mozart-core/src/repository/download_manager.rs
+++ b/crates/mozart-core/src/downloader/download_manager.rs
@@ -1,17 +1,13 @@
//! `DownloadManager` — pick the right [`VcsDownloader`] for a given
//! [`LocalPackage`]. Mirrors `Composer\Downloader\DownloadManager`.
-use std::path::PathBuf;
-
use crate::composer::{InstallationSource, LocalPackage};
-use crate::vcs::downloader::VcsDownloader;
-use crate::vcs::downloader::git::GitDownloader;
-use crate::vcs::downloader::hg::HgDownloader;
-use crate::vcs::downloader::svn::SvnDownloader;
+use crate::downloader::{GitDownloader, HgDownloader, SvnDownloader, VcsDownloader};
use crate::vcs::process::ProcessExecutor;
use crate::vcs::util::git::GitUtil;
use crate::vcs::util::hg::HgUtil;
use crate::vcs::util::svn::SvnUtil;
+use std::path::PathBuf;
/// Selects a `VcsDownloader` for a package based on its installation source
/// and source type. Mirrors `DownloadManager::getDownloaderForPackage`:
diff --git a/crates/mozart-core/src/downloader/downloader_interface.rs b/crates/mozart-core/src/downloader/downloader_interface.rs
new file mode 100644
index 0000000..9c1b585
--- /dev/null
+++ b/crates/mozart-core/src/downloader/downloader_interface.rs
@@ -0,0 +1 @@
+pub trait DownloaderInterface {}
diff --git a/crates/mozart-core/src/downloader/dvcs_downloader_interface.rs b/crates/mozart-core/src/downloader/dvcs_downloader_interface.rs
new file mode 100644
index 0000000..3f576f5
--- /dev/null
+++ b/crates/mozart-core/src/downloader/dvcs_downloader_interface.rs
@@ -0,0 +1 @@
+pub trait DvcsDownloaderInterface {}
diff --git a/crates/mozart-core/src/downloader/file_downloader.rs b/crates/mozart-core/src/downloader/file_downloader.rs
new file mode 100644
index 0000000..81625c4
--- /dev/null
+++ b/crates/mozart-core/src/downloader/file_downloader.rs
@@ -0,0 +1 @@
+pub struct FileDownloader;
diff --git a/crates/mozart-core/src/downloader/filesystem_exception.rs b/crates/mozart-core/src/downloader/filesystem_exception.rs
new file mode 100644
index 0000000..f978219
--- /dev/null
+++ b/crates/mozart-core/src/downloader/filesystem_exception.rs
@@ -0,0 +1 @@
+pub struct FilesystemException;
diff --git a/crates/mozart-core/src/downloader/fossil_downloader.rs b/crates/mozart-core/src/downloader/fossil_downloader.rs
new file mode 100644
index 0000000..8df300c
--- /dev/null
+++ b/crates/mozart-core/src/downloader/fossil_downloader.rs
@@ -0,0 +1 @@
+pub struct FossilDownloader;
diff --git a/crates/mozart-core/src/vcs/downloader/git.rs b/crates/mozart-core/src/downloader/git_downloader.rs
index eb7a649..d4d8c44 100644
--- a/crates/mozart-core/src/vcs/downloader/git.rs
+++ b/crates/mozart-core/src/downloader/git_downloader.rs
@@ -1,11 +1,12 @@
-use super::super::process::ProcessExecutor;
-use super::super::util::git::GitUtil;
-use super::VcsDownloader;
use anyhow::Result;
use regex::Regex;
use std::path::Path;
use std::sync::LazyLock;
+use crate::downloader::VcsDownloader;
+use crate::vcs::process::ProcessExecutor;
+use crate::vcs::util::git::GitUtil;
+
/// Match `<hex> HEAD` lines in `git show-ref --head -d` output.
static HEAD_REF_RE: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"(?im)^([a-f0-9]+) HEAD$").unwrap());
diff --git a/crates/mozart-core/src/downloader/gzip_downloader.rs b/crates/mozart-core/src/downloader/gzip_downloader.rs
new file mode 100644
index 0000000..c329617
--- /dev/null
+++ b/crates/mozart-core/src/downloader/gzip_downloader.rs
@@ -0,0 +1 @@
+pub struct GzipDownloader;
diff --git a/crates/mozart-core/src/vcs/downloader/hg.rs b/crates/mozart-core/src/downloader/hg_downloader.rs
index 33650f8..9fb918e 100644
--- a/crates/mozart-core/src/vcs/downloader/hg.rs
+++ b/crates/mozart-core/src/downloader/hg_downloader.rs
@@ -1,8 +1,8 @@
-use super::super::util::hg::HgUtil;
-use super::VcsDownloader;
use anyhow::Result;
use std::path::Path;
+use crate::{downloader::VcsDownloader, vcs::util::hg::HgUtil};
+
/// Mercurial downloader using clone/pull/update.
pub struct HgDownloader {
hg_util: HgUtil,
diff --git a/crates/mozart-core/src/downloader/max_file_size_exceeded_exception.rs b/crates/mozart-core/src/downloader/max_file_size_exceeded_exception.rs
new file mode 100644
index 0000000..6a0f90c
--- /dev/null
+++ b/crates/mozart-core/src/downloader/max_file_size_exceeded_exception.rs
@@ -0,0 +1 @@
+pub struct MaxFileSizeExceededException;
diff --git a/crates/mozart-core/src/downloader/path_downloader.rs b/crates/mozart-core/src/downloader/path_downloader.rs
new file mode 100644
index 0000000..e9cb62d
--- /dev/null
+++ b/crates/mozart-core/src/downloader/path_downloader.rs
@@ -0,0 +1 @@
+pub struct PathDownloader;
diff --git a/crates/mozart-core/src/downloader/perforce_downloader.rs b/crates/mozart-core/src/downloader/perforce_downloader.rs
new file mode 100644
index 0000000..688e241
--- /dev/null
+++ b/crates/mozart-core/src/downloader/perforce_downloader.rs
@@ -0,0 +1 @@
+pub struct PerforceDownloader;
diff --git a/crates/mozart-core/src/downloader/phar_downloader.rs b/crates/mozart-core/src/downloader/phar_downloader.rs
new file mode 100644
index 0000000..74aff0f
--- /dev/null
+++ b/crates/mozart-core/src/downloader/phar_downloader.rs
@@ -0,0 +1 @@
+pub struct PharDownloader;
diff --git a/crates/mozart-core/src/downloader/rar_downloader.rs b/crates/mozart-core/src/downloader/rar_downloader.rs
new file mode 100644
index 0000000..6fef0a0
--- /dev/null
+++ b/crates/mozart-core/src/downloader/rar_downloader.rs
@@ -0,0 +1 @@
+pub struct RarDownloader;
diff --git a/crates/mozart-core/src/vcs/downloader/svn.rs b/crates/mozart-core/src/downloader/svn_downloader.rs
index ea885ed..c78f9b7 100644
--- a/crates/mozart-core/src/vcs/downloader/svn.rs
+++ b/crates/mozart-core/src/downloader/svn_downloader.rs
@@ -1,10 +1,11 @@
-use super::super::util::svn::SvnUtil;
-use super::VcsDownloader;
use anyhow::Result;
use regex::Regex;
use std::path::Path;
use std::sync::LazyLock;
+use crate::downloader::VcsDownloader;
+use crate::vcs::util::svn::SvnUtil;
+
/// Match any non-`X` status line (mirror of Composer's
/// `{^ *[^X ] +}m`). Ignores externals (`X` prefix).
static SVN_STATUS_RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?m)^ *[^X ] +").unwrap());
diff --git a/crates/mozart-core/src/downloader/tar_downloader.rs b/crates/mozart-core/src/downloader/tar_downloader.rs
new file mode 100644
index 0000000..82f68d9
--- /dev/null
+++ b/crates/mozart-core/src/downloader/tar_downloader.rs
@@ -0,0 +1 @@
+pub struct TarDownloader;
diff --git a/crates/mozart-core/src/downloader/transport_exception.rs b/crates/mozart-core/src/downloader/transport_exception.rs
new file mode 100644
index 0000000..e6ca721
--- /dev/null
+++ b/crates/mozart-core/src/downloader/transport_exception.rs
@@ -0,0 +1 @@
+pub struct TransportException;
diff --git a/crates/mozart-core/src/downloader/vcs_capable_downloader_interface.rs b/crates/mozart-core/src/downloader/vcs_capable_downloader_interface.rs
new file mode 100644
index 0000000..121b95d
--- /dev/null
+++ b/crates/mozart-core/src/downloader/vcs_capable_downloader_interface.rs
@@ -0,0 +1 @@
+pub trait VcsCapableDownloaderInterface {}
diff --git a/crates/mozart-core/src/vcs/downloader/mod.rs b/crates/mozart-core/src/downloader/vcs_downloader.rs
index 352f330..ce56d41 100644
--- a/crates/mozart-core/src/vcs/downloader/mod.rs
+++ b/crates/mozart-core/src/downloader/vcs_downloader.rs
@@ -1,49 +1,48 @@
-pub mod git;
-pub mod hg;
-pub mod svn;
-
-use std::path::Path;
-
-use anyhow::Result;
-
/// The VCS downloader interface.
///
/// Corresponds to Composer's `VcsDownloader` hierarchy.
pub trait VcsDownloader {
/// Prepare for installation (e.g., sync mirror cache).
- fn download(&self, url: &str, reference: &str, target: &Path) -> Result<()>;
+ fn download(&self, url: &str, reference: &str, target: &std::path::Path) -> anyhow::Result<()>;
/// Install (clone/checkout) the source to the target directory.
- fn install(&self, url: &str, reference: &str, target: &Path) -> Result<()>;
+ fn install(&self, url: &str, reference: &str, target: &std::path::Path) -> anyhow::Result<()>;
/// Update the source at target to a new reference.
- fn update(&self, url: &str, old_ref: &str, new_ref: &str, target: &Path) -> Result<()>;
+ fn update(
+ &self,
+ url: &str,
+ old_ref: &str,
+ new_ref: &str,
+ target: &std::path::Path,
+ ) -> anyhow::Result<()>;
/// Remove the source from the target directory.
- fn remove(&self, target: &Path) -> Result<()>;
+ fn remove(&self, target: &std::path::Path) -> anyhow::Result<()>;
/// Detect local changes in the working copy.
/// Returns `None` if clean, `Some(diff)` if modified.
/// Mirrors `Composer\Downloader\ChangeReportInterface::getLocalChanges`.
- fn get_local_changes(&self, target: &Path) -> Result<Option<String>>;
+ fn get_local_changes(&self, target: &std::path::Path) -> anyhow::Result<Option<String>>;
/// Detect commits present locally but not on the tracking remote.
/// Returns `None` if there are no unpushed commits or the concept does
/// not apply (only `GitDownloader` implements this in Composer's
/// `DvcsDownloaderInterface`).
- fn unpushed_changes(&self, _target: &Path) -> Result<Option<String>> {
+ fn unpushed_changes(&self, _target: &std::path::Path) -> anyhow::Result<Option<String>> {
Ok(None)
}
/// Resolve the working copy's current VCS reference (e.g. commit hash).
/// Returns `None` if no reference can be determined. Mirrors
/// `Composer\Downloader\VcsCapableDownloaderInterface::getVcsReference`.
- fn vcs_reference(&self, _target: &Path) -> Result<Option<String>> {
+ fn vcs_reference(&self, _target: &std::path::Path) -> anyhow::Result<Option<String>> {
Ok(None)
}
/// Get commit log between two references.
- fn commit_logs(&self, from: &str, to: &str, target: &Path) -> Result<String>;
+ fn commit_logs(&self, from: &str, to: &str, target: &std::path::Path)
+ -> anyhow::Result<String>;
/// instanceof ChangeReportInterface
fn is_change_report(&self) -> bool;
diff --git a/crates/mozart-core/src/downloader/xz_downloader.rs b/crates/mozart-core/src/downloader/xz_downloader.rs
new file mode 100644
index 0000000..18de2ce
--- /dev/null
+++ b/crates/mozart-core/src/downloader/xz_downloader.rs
@@ -0,0 +1 @@
+pub struct XzDownloader;
diff --git a/crates/mozart-core/src/downloader/zip_downloader.rs b/crates/mozart-core/src/downloader/zip_downloader.rs
new file mode 100644
index 0000000..401047a
--- /dev/null
+++ b/crates/mozart-core/src/downloader/zip_downloader.rs
@@ -0,0 +1 @@
+pub struct ZipDownloader;
diff --git a/crates/mozart-core/src/lib.rs b/crates/mozart-core/src/lib.rs
index 72f5ae1..adf24a3 100644
--- a/crates/mozart-core/src/lib.rs
+++ b/crates/mozart-core/src/lib.rs
@@ -8,6 +8,7 @@ pub mod config_source;
pub mod config_validator;
pub mod console;
pub mod dependency_resolver;
+pub mod downloader;
pub mod exit_code;
pub mod factory;
pub mod http;
diff --git a/crates/mozart-core/src/repository.rs b/crates/mozart-core/src/repository.rs
index ce6de85..b7527dd 100644
--- a/crates/mozart-core/src/repository.rs
+++ b/crates/mozart-core/src/repository.rs
@@ -2,7 +2,6 @@ pub mod advisory;
pub mod browse_repos;
pub mod cache;
pub mod composer_repo;
-pub mod download_manager;
pub mod downloader;
pub mod inline_package;
pub mod installed;
diff --git a/crates/mozart-core/src/repository/installer_executor/filesystem.rs b/crates/mozart-core/src/repository/installer_executor/filesystem.rs
index 3f982e3..2b34e02 100644
--- a/crates/mozart-core/src/repository/installer_executor/filesystem.rs
+++ b/crates/mozart-core/src/repository/installer_executor/filesystem.rs
@@ -5,9 +5,10 @@
//! [`crate::vcs`], and removes vendor directories. Test code substitutes a
//! recording-only executor instead (added in a later step).
-use super::super::cache::Cache;
-use super::super::downloader;
-use super::{ExecuteContext, InstallerExecutor, PackageOperation};
+use crate::downloader::{GitDownloader, HgDownloader, SvnDownloader};
+use crate::repository::cache::Cache;
+use crate::repository::downloader;
+use crate::repository::installer_executor::{ExecuteContext, InstallerExecutor, PackageOperation};
use std::path::Path;
pub struct FilesystemExecutor {
@@ -135,6 +136,8 @@ fn install_from_source(
vendor_dir: &Path,
package_name: &str,
) -> anyhow::Result<()> {
+ use crate::downloader::VcsDownloader as _;
+
let target = vendor_dir.join(package_name);
if target.exists() {
std::fs::remove_dir_all(&target)?;
@@ -145,23 +148,20 @@ fn install_from_source(
let process = crate::vcs::process::ProcessExecutor::new();
let git_util =
crate::vcs::util::git::GitUtil::new(process, vendor_dir.join(".cache").join("git"));
- let downloader = crate::vcs::downloader::git::GitDownloader::new(git_util);
- use crate::vcs::downloader::VcsDownloader as _;
+ let downloader = GitDownloader::new(git_util);
downloader.download(url, reference, &target)?;
downloader.install(url, reference, &target)?;
}
"svn" => {
let process = crate::vcs::process::ProcessExecutor::new();
let svn_util = crate::vcs::util::svn::SvnUtil::new(process);
- let downloader = crate::vcs::downloader::svn::SvnDownloader::new(svn_util);
- use crate::vcs::downloader::VcsDownloader as _;
+ let downloader = SvnDownloader::new(svn_util);
downloader.install(url, reference, &target)?;
}
"hg" => {
let process = crate::vcs::process::ProcessExecutor::new();
let hg_util = crate::vcs::util::hg::HgUtil::new(process);
- let downloader = crate::vcs::downloader::hg::HgDownloader::new(hg_util);
- use crate::vcs::downloader::VcsDownloader as _;
+ let downloader = HgDownloader::new(hg_util);
downloader.install(url, reference, &target)?;
}
_ => {
diff --git a/crates/mozart-core/src/vcs.rs b/crates/mozart-core/src/vcs.rs
index 137cc5b..534dd0f 100644
--- a/crates/mozart-core/src/vcs.rs
+++ b/crates/mozart-core/src/vcs.rs
@@ -1,4 +1,3 @@
-pub mod downloader;
pub mod process;
pub mod repository;
pub mod util;