Skip to main content

PackageManager

Struct PackageManager 

Source
pub struct PackageManager<R: Runner = SystemRunner> { /* private fields */ }
Expand description

Extension package manager: install, remove, update, list, resolve.

Generic over a Runner so tests can inject command execution. Production code uses PackageManager (which defaults to SystemRunner).

Implementations§

Source§

impl PackageManager<SystemRunner>

Source

pub fn new(options: PackageManagerOptions) -> Self

Create a manager backed by the real subprocess runner.

Source§

impl<R: Runner> PackageManager<R>

Source

pub fn with_runner(options: PackageManagerOptions, runner: R) -> Self

Create a manager with an injected runner.

Source

pub fn with_offline(self, offline: bool) -> Self

Force offline mode (Some(true)) or online (Some(false)), overriding PI_OFFLINE. None (the default) reads the env on each call.

Source

pub fn set_progress_callback(&mut self, callback: Option<ProgressCallback>)

Install a progress callback (replaces any previous one).

Source

pub fn get_installed_path( &self, settings: &SettingsManager, source: &str, scope: Scope, ) -> Result<Option<PathBuf>, PackageManagerError>

Absolute install path for source in scope, or None when absent.

§Errors

Returns PackageManagerError::ProjectNotTrusted for project scope while untrusted, or PackageManagerError::Resolve on path escape.

Source

pub fn install( &self, settings: &SettingsManager, source: &str, scope: Scope, ) -> Result<(), PackageManagerError>

Install source into scope without recording it in settings.

Local sources only verify the path exists; npm and git run the package manager / git clone under NETWORK_TIMEOUT_MS.

§Errors

Returns PackageManagerError::ProjectNotTrusted for untrusted project scope, PackageManagerError::PathNotFound for a missing local path, or PackageManagerError::Runner on subprocess failure.

Source

pub fn install_and_persist( &self, settings: &mut SettingsManager, source: &str, scope: Scope, ) -> Result<(), PackageManagerError>

Install then persist the source into the scope’s packages[].

§Errors

See Self::install and Self::add_source_to_settings.

Source

pub fn remove( &self, settings: &SettingsManager, source: &str, scope: Scope, ) -> Result<(), PackageManagerError>

Remove source from scope (disk only; settings untouched).

Local sources are a no-op; npm uninstalls and git removes the clone.

§Errors

Returns PackageManagerError::ProjectNotTrusted for untrusted project scope or PackageManagerError::Runner on subprocess failure.

Source

pub fn remove_and_persist( &self, settings: &mut SettingsManager, source: &str, scope: Scope, ) -> Result<bool, PackageManagerError>

Remove from disk then drop the source from packages[].

Returns whether the settings array actually changed.

§Errors

See Self::remove and Self::remove_source_from_settings.

Source

pub fn update_extensions( &self, settings: &SettingsManager, source: Option<&str>, ) -> Result<(), PackageManagerError>

Update one package (Some) or every configured package (None).

Pinned npm versions are skipped (they are fixed). Pinned git refs are reconciled against the configured ref. Offline mode or an empty match set is a no-op. A filter that matches nothing is an error.

§Errors

Returns PackageManagerError::NoMatchingPackage (with a suggestion when one exists) for an unmatched filter, or PackageManagerError variants from the underlying install/clone operations.

Source

pub fn list_configured_packages( &self, settings: &SettingsManager, ) -> Result<Vec<ConfiguredPackage>, PackageManagerError>

List every configured package across both scopes with its install path.

§Errors

Returns PackageManagerError only when an install-path lookup hits a trust or path-escape failure.

Source

pub fn resolve( &self, settings: &SettingsManager, ) -> Result<ResolvedPaths, PackageManagerError>

Resolve all configured packages and local resources to concrete paths.

Delegates to PackagePathResolver::resolve so this surface and the resolve-side discovery never disagree on managed install locations. Missing installs are skipped (no network install here).

§Errors

Propagates PackageResolveError as PackageManagerError::Resolve.

Source

pub fn add_source_to_settings( &self, settings: &mut SettingsManager, source: &str, scope: Scope, ) -> Result<bool, PackageManagerError>

Add (or normalize) source in scope’s packages[].

Returns whether the settings array changed. Adding the same source is idempotent (returns false); a re-normalized local path returns true.

§Errors

Returns PackageManagerError::ProjectNotTrusted (via the settings setter) for untrusted project scope.

Source

pub fn remove_source_from_settings( &self, settings: &mut SettingsManager, source: &str, scope: Scope, ) -> Result<bool, PackageManagerError>

Remove source from scope’s packages[].

Returns whether the array changed.

§Errors

Returns PackageManagerError::ProjectNotTrusted for untrusted project scope.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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