pub struct PackageManager { /* private fields */ }Expand description
Manages installation, removal, and listing of packages
Implementations§
Source§impl PackageManager
impl PackageManager
Sourcepub fn with_dir(packages_dir: PathBuf) -> Result<Self>
pub fn with_dir(packages_dir: PathBuf) -> Result<Self>
Create a PackageManager with a custom packages directory (for testing)
Sourcepub fn set_project_dir(&mut self, dir: PathBuf)
pub fn set_project_dir(&mut self, dir: PathBuf)
Set the project directory for project-scoped packages
Sourcepub fn set_progress_callback(
&mut self,
callback: Box<dyn Fn(ProgressEvent) + Send + Sync>,
)
pub fn set_progress_callback( &mut self, callback: Box<dyn Fn(ProgressEvent) + Send + Sync>, )
Set a progress callback
Sourcepub fn packages_dir(&self) -> &Path
pub fn packages_dir(&self) -> &Path
Get the packages directory path
Sourcepub fn install(&mut self, source: &str) -> Result<PackageManifest>
pub fn install(&mut self, source: &str) -> Result<PackageManifest>
Install a package from a local directory path
Sourcepub fn install_from_source(
&mut self,
source: &str,
scope: SourceScope,
) -> Result<PackageManifest>
pub fn install_from_source( &mut self, source: &str, scope: SourceScope, ) -> Result<PackageManifest>
Install from any source
Sourcepub fn install_npm(&mut self, name: &str) -> Result<PackageManifest>
pub fn install_npm(&mut self, name: &str) -> Result<PackageManifest>
Install from npm using npm pack (legacy sync method)
Sourcepub fn uninstall_from_source(
&mut self,
source: &str,
scope: SourceScope,
) -> Result<()>
pub fn uninstall_from_source( &mut self, source: &str, scope: SourceScope, ) -> Result<()>
Uninstall a package from a specific source
Sourcepub fn update(&mut self, name: &str) -> Result<PackageManifest>
pub fn update(&mut self, name: &str) -> Result<PackageManifest>
Update a package (re-install from the same source).
For npm packages, re-runs npm pack to get the latest version.
For local packages, re-copies from the source path (if available).
For git packages, does a git pull.
Sourcepub fn update_all(&mut self) -> Vec<(String, Result<PackageManifest>)>
pub fn update_all(&mut self) -> Vec<(String, Result<PackageManifest>)>
Update all installed packages
Sourcepub async fn check_for_updates(&self) -> Vec<PackageUpdateInfo>
pub async fn check_for_updates(&self) -> Vec<PackageUpdateInfo>
Check for available updates across all packages
Sourcepub fn list(&self) -> Vec<&PackageManifest>
pub fn list(&self) -> Vec<&PackageManifest>
List all installed packages
Sourcepub fn list_configured(&self) -> Vec<ConfiguredPackage>
pub fn list_configured(&self) -> Vec<ConfiguredPackage>
List configured packages with metadata
Sourcepub fn is_installed(&self, name: &str) -> bool
pub fn is_installed(&self, name: &str) -> bool
Check whether a package is installed
Sourcepub fn get_install_dir(&self, name: &str) -> Option<PathBuf>
pub fn get_install_dir(&self, name: &str) -> Option<PathBuf>
Get the install directory for a package (if it exists on disk)
Sourcepub fn get_installed_path_for_source(
&self,
source: &str,
scope: SourceScope,
) -> Option<PathBuf>
pub fn get_installed_path_for_source( &self, source: &str, scope: SourceScope, ) -> Option<PathBuf>
Get the installed path for a source at a given scope
Sourcepub fn discover_resources(&self, name: &str) -> Result<Vec<DiscoveredResource>>
pub fn discover_resources(&self, name: &str) -> Result<Vec<DiscoveredResource>>
Discover all resources from an installed package.
Sourcepub fn resource_counts(&self, name: &str) -> Result<ResourceCounts>
pub fn resource_counts(&self, name: &str) -> Result<ResourceCounts>
Get resource counts for a package
Sourcepub fn resolve(&self) -> ResolvedPaths
pub fn resolve(&self) -> ResolvedPaths
Resolve all resources from all installed packages, producing ResolvedPaths
Sourcepub fn resolve_dependencies(&self) -> Vec<(String, Vec<String>)>
pub fn resolve_dependencies(&self) -> Vec<(String, Vec<String>)>
Resolve dependencies for all installed packages. Returns a list of (package, missing_dependencies) tuples.
Sourcepub fn get_installed_version(&self, name: &str) -> Option<&str>
pub fn get_installed_version(&self, name: &str) -> Option<&str>
Get installed version of a package
Sourcepub fn version_satisfies(&self, name: &str, requirement: &str) -> bool
pub fn version_satisfies(&self, name: &str, requirement: &str) -> bool
Check if an installed version satisfies a semver requirement
Auto Trait Implementations§
impl Freeze for PackageManager
impl !RefUnwindSafe for PackageManager
impl Send for PackageManager
impl Sync for PackageManager
impl Unpin for PackageManager
impl UnsafeUnpin for PackageManager
impl !UnwindSafe for PackageManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more