pub struct PackageManager { /* private fields */ }Expand description
Installs, removes and resolves packages for a working directory.
Implementations§
Source§impl PackageManager
impl PackageManager
Sourcepub fn new(
cwd: PathBuf,
agent_dir: PathBuf,
settings: SettingsManager,
npm_config: HashMap<String, String>,
) -> PackageManager
pub fn new( cwd: PathBuf, agent_dir: PathBuf, settings: SettingsManager, npm_config: HashMap<String, String>, ) -> PackageManager
A manager for cwd, reading and writing settings, with npm’s
configuration npm_config, as npm::config reads it.
Sourcepub fn project_only(&mut self, keep: ProjectOnly)
pub fn project_only(&mut self, keep: ProjectOnly)
Makes PackageManager::install_missing install only the user’s
packages that keep, a project-only run’s keep list, could need.
Sourcepub fn on_progress(&mut self, progress: impl Fn(&str) + Send + Sync + 'static)
pub fn on_progress(&mut self, progress: impl Fn(&str) + Send + Sync + 'static)
Reports the start of each install, removal and update.
Sourcepub fn settings(&self) -> &SettingsManager
pub fn settings(&self) -> &SettingsManager
The settings it reads and writes.
Sourcepub fn installed_path(&self, source: &str, scope: Scope) -> Option<PathBuf>
pub fn installed_path(&self, source: &str, scope: Scope) -> Option<PathBuf>
Where source, as written in scope’s settings, is installed.
Sourcepub async fn install(
&mut self,
source: &str,
local: bool,
) -> Result<(), PackageError>
pub async fn install( &mut self, source: &str, local: bool, ) -> Result<(), PackageError>
pi’s installAndPersist: installs source into the user’s (or with
local, the project’s) packages and lists it in their settings.
Sourcepub async fn remove(
&mut self,
source: &str,
local: bool,
) -> Result<bool, PackageError>
pub async fn remove( &mut self, source: &str, local: bool, ) -> Result<bool, PackageError>
pi’s removeAndPersist: uninstalls source from the scope and drops
its settings entries. Returns false when settings did not list it.
Sourcepub fn list(&self) -> Vec<Configured>
pub fn list(&self) -> Vec<Configured>
The packages settings list: the user’s, then the project’s.
Sourcepub async fn update(&mut self, source: Option<&str>) -> Result<(), PackageError>
pub async fn update(&mut self, source: Option<&str>) -> Result<(), PackageError>
pi’s update: reinstalls unpinned npm packages with newer matching
versions and fast-forwards git packages, for every configured package
or the one source names.
Sourcepub async fn available_updates(&self) -> Vec<String>
pub async fn available_updates(&self) -> Vec<String>
pi’s checkForAvailableUpdates: the installed npm and git packages
that settings list which have a later version than the one installed,
by name: the npm package’s, or <host>/<path> for git. Local and
pinned sources are skipped, and so is a package whose check fails.
Sourcepub async fn install_temporary(
&mut self,
source: &str,
offline: bool,
) -> Result<Option<PathBuf>, PackageError>
pub async fn install_temporary( &mut self, source: &str, offline: bool, ) -> Result<Option<PathBuf>, PackageError>
pi’s temporary package for -e: where source is for this run. npm
and git sources live under <agent>/tmp/extensions and are not added
to settings. A missing package is installed, an npm package whose
installed version is outside the source’s range is reinstalled, and an
unpinned git checkout is refreshed, kept as it is when that fails.
offline skips all three, and a missing package is then None.
Sourcepub async fn install_missing<B>(
&mut self,
on_error: impl FnMut(&str, String) -> ControlFlow<B>,
) -> ControlFlow<B>
pub async fn install_missing<B>( &mut self, on_error: impl FnMut(&str, String) -> ControlFlow<B>, ) -> ControlFlow<B>
The installs of pi’s resolve: the configured npm and git packages
that are missing, and the npm packages whose installed version is
outside the configured range, in the order and at the places of
resolve::locate_packages. on_error receives each failure, with
its source, and its Break ends the install and is returned.