Struct axoproject::PackageInfo

source ·
pub struct PackageInfo {
Show 21 fields pub manifest_path: Utf8PathBuf, pub package_root: Utf8PathBuf, pub name: String, pub version: Option<Version>, pub description: Option<String>, pub authors: Vec<String>, pub license: Option<String>, pub publish: bool, pub keywords: Option<Vec<String>>, pub repository_url: Option<String>, pub homepage_url: Option<String>, pub documentation_url: Option<String>, pub readme_file: Option<Utf8PathBuf>, pub license_files: Vec<Utf8PathBuf>, pub changelog_file: Option<Utf8PathBuf>, pub binaries: Vec<String>, pub cstaticlibs: Vec<String>, pub cdylibs: Vec<String>, pub cargo_metadata_table: Option<Value>, pub cargo_package_id: Option<PackageId>, pub build_command: Option<Vec<String>>,
}
Expand description

Computed info about a package

This notably includes finding readmes and licenses even if the user didn’t specify their location – something Cargo does but Guppy (and cargo-metadata) don’t.

Fields§

§manifest_path: Utf8PathBuf

Path to the manifest for this package

§package_root: Utf8PathBuf

Path to the root dir for this package

§name: String

Name of the package

This can actually be missing for JS packages, but in that case it’s basically the same thing as a “virtual manifest” in Cargo. PackageInfo is only for concrete packages so we don’t need to allow for that.

§version: Option<Version>

Version of the package

Both cargo and npm use SemVer but they disagree slightly on what that means:

Cargo requires this field at all times, npm only requires it to publish. Probably we could get away with making it non-optional but allowing this theoretically lets npm users “kick the tires” even when they’re not ready to publish.

§description: Option<String>

A brief description of the package

§authors: Vec<String>

Authors of the package (may be empty)

§license: Option<String>

The license the package is provided under

§publish: bool

False if they set publish=false, true otherwise

Currently always true for npm packages.

§keywords: Option<Vec<String>>

Package keywords AND/OR categories.

Specifically, Cargo has both the notion of a “package keyword” (free-form text) and a “package category” (one of circa 70 predefined categories accepted by crates.io). We don’t really care about validating these, though, and just squash them together with the keywords.

§repository_url: Option<String>

URL to the repository for this package

This URL can be used by various CI/Installer helpers. In the future we might also use it for auto-detecting “hey you’re using github, here’s the recommended github setup”.

i.e. cargo dist init --installer=shell uses this as the base URL for fetching from a Github Release™️.

§homepage_url: Option<String>

URL to the homepage for this package.

Currently this isn’t terribly important or useful?

§documentation_url: Option<String>

URL to the documentation for this package.

This will default to docs.rs if not specified, which is the default crates.io behaviour.

Currently this isn’t terribly important or useful?

§readme_file: Option<Utf8PathBuf>

Path to the README file for this package.

If the user specifies where this is, we’ll respect it. Otherwise we’ll try to find this in the workspace using AutoIncludes.

§license_files: Vec<Utf8PathBuf>

Paths to the LICENSE files for this package.

By default these should be copied into a zip containing this package’s binary.

If the user specifies where this is, we’ll respect it. Otherwise we’ll try to find this in the workspace using AutoIncludes.

Cargo only lets you specify one such path, but that’s because its license-path key primarily exists as an escape hatch for someone’s whacky-wild custom license. Ultimately Cargo’s license-path is inadequate for Normal Licenses because it can’t handle the standard pattern of dual licensing MIT/Apache and having two license files. AutoIncludes properly handles dual licensing.

§changelog_file: Option<Utf8PathBuf>

Paths to the CHANGELOG or RELEASES file for this package

By default this should be copied into a zip containing this package’s binary.

We will try to parse this

§binaries: Vec<String>

Names of binaries this package defines

For Cargo this is currently properly computed in all its complexity. For JS I think this is computed in its full complexity but Tests Needed and also there’s so many ways to define things who can ever be sure.

§cstaticlibs: Vec<String>

Names of C-style staticlibs (.a) this library defines.

For Cargo this is currently properly computed in all its complexity. For JS we don’t compute this at all.

§cdylibs: Vec<String>

Names of C-style dylibs (.dll, .so, …) this package defines

For Cargo this is currently properly computed in all its complexity. For JS we don’t compute this at all.

§cargo_metadata_table: Option<Value>

Raw cargo [package.metadata] table

§cargo_package_id: Option<PackageId>

A unique id used by Cargo to refer to the package

§build_command: Option<Vec<String>>

Command to run to build this package

Implementations§

source§

impl PackageInfo

source

pub fn changelog_for_version( &self, version: &Version, ) -> Result<Option<ChangelogInfo>>

Get the changelog for a given version from a package’s changelog

source§

impl PackageInfo

source

pub fn github_repo(&self) -> Result<Option<GithubRepo>>

Returns a struct which contains the repository’s owner and name.

source

pub fn web_url(&self) -> Result<Option<String>>

Returns a web version of the repository URL, converted from SSH if necessary, with .git suffix trimmed.

Trait Implementations§

source§

impl Debug for PackageInfo

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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