pub struct PackageJson {Show 21 fields
pub name: Option<String>,
pub private: Option<bool>,
pub main: Option<String>,
pub module: Option<String>,
pub types: Option<String>,
pub typings: Option<String>,
pub source: Option<String>,
pub files: Vec<String>,
pub browser: Option<Value>,
pub bin: Option<Value>,
pub exports: Option<Value>,
pub imports: Option<Value>,
pub dependencies: Option<HashMap<String, String>>,
pub dev_dependencies: Option<HashMap<String, String>>,
pub peer_dependencies: Option<HashMap<String, String>>,
pub peer_dependencies_meta: Option<HashMap<String, PeerDependencyMeta>>,
pub optional_dependencies: Option<HashMap<String, String>>,
pub scripts: Option<HashMap<String, String>>,
pub napi: Option<NapiConfig>,
pub workspaces: Option<Value>,
pub package_manager: Option<String>,
}Expand description
Parsed package.json with fields relevant to fallow.
Fields§
§name: Option<String>The name field: the package’s npm name, used to identify workspace
packages and match public_packages config entries.
private: Option<bool>The private field. Non-boolean values become None rather than
failing manifest parsing.
main: Option<String>The main field: CommonJS entry-point path, seeded as an entry point.
module: Option<String>The module field: ESM entry-point path, seeded as an entry point.
types: Option<String>The types field: type-declaration entry-point path.
typings: Option<String>The typings field: legacy spelling of types.
source: Option<String>The source field: unbundled source entry point used by bundler-based
packages (Parcel convention).
files: Vec<String>The files field: publish allowlist patterns. Non-array values become
empty rather than failing manifest parsing.
browser: Option<Value>The browser field, kept raw because it is either a string entry point
or a path-remap object.
bin: Option<Value>The bin field, kept raw because it is either a string path or a
name-to-path object; every referenced file is an entry point.
exports: Option<Value>The exports field, kept raw because of its many shapes (string,
conditions object, subpath map); referenced files are entry points and
the map drives subpath resolution.
imports: Option<Value>The imports field (#-prefixed internal subpath map), kept raw and
consumed by the module resolver.
dependencies: Option<HashMap<String, String>>The dependencies map (package name to version range), the base set
for unused/unlisted-dependency accounting.
dev_dependencies: Option<HashMap<String, String>>The devDependencies map, checked by unused-dev-dependencies and
dev-dependency-in-production.
peer_dependencies: Option<HashMap<String, String>>The peerDependencies map. Peers are provided by the consumer, so
they are exempt from unused-dependency reporting.
peer_dependencies_meta: Option<HashMap<String, PeerDependencyMeta>>The peerDependenciesMeta map, marking which peers are optional.
optional_dependencies: Option<HashMap<String, String>>The optionalDependencies map, checked by
unused-optional-dependencies.
scripts: Option<HashMap<String, String>>The scripts map, scanned so packages invoked from scripts count as
used tooling dependencies.
napi: Option<NapiConfig>The NAPI-RS napi block; see NapiConfig. Non-object values become
None rather than failing manifest parsing.
workspaces: Option<Value>The workspaces field, kept raw because it is either a pattern array
or an object with a packages array; drives workspace discovery.
package_manager: Option<String>The packageManager field (e.g. "pnpm@9.1.0"), used to determine
the canonical package manager for the project.
Implementations§
Source§impl PackageJson
impl PackageJson
Sourcepub fn load(path: &Path) -> Result<Self, String>
pub fn load(path: &Path) -> Result<Self, String>
Load from a package.json file.
§Errors
Returns an error string when the file cannot be read or parsed as JSON.
Sourcepub fn all_dependency_names(&self) -> Vec<String>
pub fn all_dependency_names(&self) -> Vec<String>
Get all dependency names (production + dev + peer + optional).
Sourcepub fn production_dependency_names(&self) -> Vec<String>
pub fn production_dependency_names(&self) -> Vec<String>
Get production dependency names only.
Sourcepub fn dev_dependency_names(&self) -> Vec<String>
pub fn dev_dependency_names(&self) -> Vec<String>
Get dev dependency names only.
Sourcepub fn optional_dependency_names(&self) -> Vec<String>
pub fn optional_dependency_names(&self) -> Vec<String>
Get optional dependency names only.
Sourcepub fn required_peer_dependency_names(&self) -> Vec<String>
pub fn required_peer_dependency_names(&self) -> Vec<String>
Get required peer dependency names only.
Sourcepub fn entry_points(&self) -> Vec<String>
pub fn entry_points(&self) -> Vec<String>
Extract entry points from package.json fields.
Sourcepub fn exports_subdirectories(&self) -> Vec<String>
pub fn exports_subdirectories(&self) -> Vec<String>
Extract unique subdirectory names referenced by the exports field keys.
For exports like "./compat": { ... }, "./hooks/client": { ... },
this returns ["compat", "hooks"]. Used to discover sub-packages in
projects that define their internal package structure via the exports map
(e.g., preact with compat/, hooks/, debug/ sub-packages).
Sourcepub fn workspace_patterns(&self) -> Vec<String>
pub fn workspace_patterns(&self) -> Vec<String>
Extract workspace patterns from package.json.
Trait Implementations§
Source§impl Clone for PackageJson
impl Clone for PackageJson
Source§fn clone(&self) -> PackageJson
fn clone(&self) -> PackageJson
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PackageJson
impl Debug for PackageJson
Source§impl Default for PackageJson
impl Default for PackageJson
Source§fn default() -> PackageJson
fn default() -> PackageJson
Source§impl<'de> Deserialize<'de> for PackageJson
impl<'de> Deserialize<'de> for PackageJson
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PackageJson
impl RefUnwindSafe for PackageJson
impl Send for PackageJson
impl Sync for PackageJson
impl Unpin for PackageJson
impl UnsafeUnpin for PackageJson
impl UnwindSafe for PackageJson
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§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<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more