mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-04-09 05:10:54 +01:00
refactor(wally-compat): improve manifest parsing
This commit is contained in:
parent
5a8907c335
commit
344416da3d
2 changed files with 15 additions and 6 deletions
|
@ -258,11 +258,11 @@ impl WallyPackageRef {
|
|||
#[derive(Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub(crate) struct WallyPackage {
|
||||
pub(crate) name: String,
|
||||
pub(crate) name: WallyPackageName,
|
||||
pub(crate) version: Version,
|
||||
pub(crate) registry: Url,
|
||||
#[serde(default)]
|
||||
pub(crate) realm: Option<String>,
|
||||
pub(crate) realm: Option<Realm>,
|
||||
#[serde(default)]
|
||||
pub(crate) description: Option<String>,
|
||||
#[serde(default)]
|
||||
|
@ -356,10 +356,7 @@ impl TryFrom<WallyManifest> for IndexFileEntry {
|
|||
|
||||
Ok(IndexFileEntry {
|
||||
version: value.package.version,
|
||||
realm: value
|
||||
.package
|
||||
.realm
|
||||
.map(|r| r.parse().unwrap_or(Realm::Shared)),
|
||||
realm: value.package.realm,
|
||||
published_at: Default::default(),
|
||||
description: value.package.description,
|
||||
dependencies,
|
||||
|
|
|
@ -318,6 +318,18 @@ impl From<WallyPackageName> for PackageName {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "wally")]
|
||||
impl From<WallyPackageName> for StandardPackageName {
|
||||
fn from(name: WallyPackageName) -> Self {
|
||||
let (scope, name) = name.parts();
|
||||
|
||||
StandardPackageName(
|
||||
scope[..scope.len().min(24)].replace('-', "_"),
|
||||
name[..name.len().min(24)].replace('-', "_"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
name_impl!(
|
||||
StandardPackageName,
|
||||
StandardPackageNameValidationError,
|
||||
|
|
Loading…
Add table
Reference in a new issue