mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-04-17 18:33:49 +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)]
|
#[derive(Deserialize, Clone, Debug)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub(crate) struct WallyPackage {
|
pub(crate) struct WallyPackage {
|
||||||
pub(crate) name: String,
|
pub(crate) name: WallyPackageName,
|
||||||
pub(crate) version: Version,
|
pub(crate) version: Version,
|
||||||
pub(crate) registry: Url,
|
pub(crate) registry: Url,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) realm: Option<String>,
|
pub(crate) realm: Option<Realm>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub(crate) description: Option<String>,
|
pub(crate) description: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
@ -356,10 +356,7 @@ impl TryFrom<WallyManifest> for IndexFileEntry {
|
||||||
|
|
||||||
Ok(IndexFileEntry {
|
Ok(IndexFileEntry {
|
||||||
version: value.package.version,
|
version: value.package.version,
|
||||||
realm: value
|
realm: value.package.realm,
|
||||||
.package
|
|
||||||
.realm
|
|
||||||
.map(|r| r.parse().unwrap_or(Realm::Shared)),
|
|
||||||
published_at: Default::default(),
|
published_at: Default::default(),
|
||||||
description: value.package.description,
|
description: value.package.description,
|
||||||
dependencies,
|
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!(
|
name_impl!(
|
||||||
StandardPackageName,
|
StandardPackageName,
|
||||||
StandardPackageNameValidationError,
|
StandardPackageNameValidationError,
|
||||||
|
|
Loading…
Add table
Reference in a new issue