Skip to main content

PackageManager

Struct PackageManager 

Source
pub struct PackageManager { /* private fields */ }
Expand description

Installs, removes and resolves packages for a working directory.

Implementations§

Source§

impl PackageManager

Source

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.

Source

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.

Source

pub fn on_progress(&mut self, progress: impl Fn(&str) + Send + Sync + 'static)

Reports the start of each install, removal and update.

Source

pub fn settings(&self) -> &SettingsManager

The settings it reads and writes.

Source

pub fn installed_path(&self, source: &str, scope: Scope) -> Option<PathBuf>

Where source, as written in scope’s settings, is installed.

Source

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.

Source

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.

Source

pub fn list(&self) -> Vec<Configured>

The packages settings list: the user’s, then the project’s.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for PackageManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more