Skip to main content

NpmCommand

Struct NpmCommand 

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

A validated package-manager executable plus its fixed argument prefix.

Implementations§

Source§

impl NpmCommand

Source

pub fn resolve(cwd: &Path, project_trusted: bool) -> Result<Self, String>

Resolve the effective command using .rpi, .pi, global, then npm. Project settings are considered only after the project trust gate has passed because npmCommand can name an arbitrary executable.

Source

pub fn from_argv(argv: Option<&[String]>) -> Result<Self, String>

Build a command from Pi’s optional argv setting. A missing or empty array selects the platform npm launcher. A blank executable is invalid and never falls back to another command.

Source

pub fn program(&self) -> &str

Executable launched as an argv command. Windows .cmd/.bat shims use the standard library’s hardened batch argument encoding.

Source

pub fn prefix_args(&self) -> &[String]

Fixed arguments configured before each package-manager operation.

Source

pub fn is_configured(&self) -> bool

Whether the effective command came from an explicit npmCommand.

Source

pub fn manager_kind(&self) -> NpmManagerKind

Package-manager family used for manager-specific install flags.

Source

pub fn combined_args(&self, operation_args: &[String]) -> Vec<String>

Prepend the fixed configured argv to one operation’s arguments.

Source

pub fn view_args(&self, source_spec: &str) -> Result<Vec<String>, String>

Construct the complete argv for native Pi’s registry version lookup.

Source

pub fn install_args(&self, specs: &[String], install_root: &Path) -> Vec<String>

Construct manager-specific operation args for a managed npm root. These match native Pi’s getNpmInstallArgs ordering exactly.

Source

pub fn uninstall_args( &self, package_name: &str, install_root: &Path, ) -> Vec<String>

Construct manager-specific arguments for removing one package from a managed npm root. The ordering and flags match native Pi’s uninstallNpm implementation.

Source

pub fn global_package_roots(&self) -> Result<Vec<PathBuf>, String>

Resolve the package-manager’s legacy global install root(s).

Native Pi uses the configured npmCommand for this lookup. The result is intentionally read-only metadata: callers may use it to discover a package that predates Pi’s managed store, but must not use it as an rpi-owned install or removal root. Every returned path is absolute, canonical, an existing directory, and ends in node_modules.

Source

pub fn global_package_paths( &self, package_names: &[String], ) -> Result<HashMap<String, PathBuf>, String>

Locate packages in a legacy global install with one package-manager query for the whole batch.

npm/bun use <global root>/<package name>. pnpm reports the concrete virtual-store path through list -g --depth 0 --json, so that output is parsed instead of guessing a symlink layout. Returned paths are canonical read-only discovery paths; package updates must migrate into the rpi/native managed root before writing anything.

Source

pub fn global_package_path( &self, package_name: &str, ) -> Result<Option<PathBuf>, String>

Locate one package using the same validation and bounded lookup as the batch API.

Source

pub fn validate_global_package_path( root: &Path, package_name: &str, ) -> Option<PathBuf>

Validate a command output path without executing a package manager. This is useful to callers that cache global-root discovery and to tests; it does not grant write or delete authority.

Trait Implementations§

Source§

impl Clone for NpmCommand

Source§

fn clone(&self) -> NpmCommand

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NpmCommand

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for NpmCommand

Source§

impl PartialEq for NpmCommand

Source§

fn eq(&self, other: &NpmCommand) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NpmCommand

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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