mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-01-05 23:59:09 +00:00
feat: keep dev dependencies in manifest file
This commit is contained in:
parent
159d0bafc1
commit
cc85135a8e
2 changed files with 56 additions and 51 deletions
|
@ -11,8 +11,16 @@ use git2::{Remote, Repository, Signature};
|
||||||
use rusty_s3::{actions::PutObject, S3Action};
|
use rusty_s3::{actions::PutObject, S3Action};
|
||||||
use tar::Archive;
|
use tar::Archive;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
auth::UserId,
|
||||||
|
benv,
|
||||||
|
error::{Error, ErrorResponse},
|
||||||
|
package::{s3_name, S3_SIGN_DURATION},
|
||||||
|
search::update_version,
|
||||||
|
AppState,
|
||||||
|
};
|
||||||
use pesde::{
|
use pesde::{
|
||||||
manifest::Manifest,
|
manifest::{DependencyType, Manifest},
|
||||||
source::{
|
source::{
|
||||||
git_index::GitBasedSource,
|
git_index::GitBasedSource,
|
||||||
pesde::{IndexFile, IndexFileEntry, ScopeInfo, SCOPE_INFO_FILE},
|
pesde::{IndexFile, IndexFileEntry, ScopeInfo, SCOPE_INFO_FILE},
|
||||||
|
@ -23,15 +31,6 @@ use pesde::{
|
||||||
MANIFEST_FILE_NAME,
|
MANIFEST_FILE_NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
|
||||||
auth::UserId,
|
|
||||||
benv,
|
|
||||||
error::{Error, ErrorResponse},
|
|
||||||
package::{s3_name, S3_SIGN_DURATION},
|
|
||||||
search::update_version,
|
|
||||||
AppState,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn signature<'a>() -> Signature<'a> {
|
fn signature<'a>() -> Signature<'a> {
|
||||||
Signature::now(
|
Signature::now(
|
||||||
&benv!(required "COMMITTER_GIT_NAME"),
|
&benv!(required "COMMITTER_GIT_NAME"),
|
||||||
|
@ -122,53 +121,59 @@ pub async fn publish_package(
|
||||||
|
|
||||||
let dependencies = manifest
|
let dependencies = manifest
|
||||||
.all_dependencies()
|
.all_dependencies()
|
||||||
.map_err(|_| Error::InvalidArchive)?;
|
.map_err(|_| Error::InvalidArchive)?
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|(alias, (specifier, ty))| {
|
||||||
|
match &specifier {
|
||||||
|
DependencySpecifiers::Pesde(specifier) => {
|
||||||
|
if specifier
|
||||||
|
.index
|
||||||
|
.as_ref()
|
||||||
|
.filter(|index| match index.parse::<url::Url>() {
|
||||||
|
Ok(_) if config.other_registries_allowed => true,
|
||||||
|
Ok(url) => url == env!("CARGO_PKG_REPOSITORY").parse().unwrap(),
|
||||||
|
Err(_) => false,
|
||||||
|
})
|
||||||
|
.is_none()
|
||||||
|
{
|
||||||
|
return Some(Err(Error::InvalidArchive));
|
||||||
|
}
|
||||||
|
|
||||||
for (specifier, _) in dependencies.values() {
|
let (dep_scope, dep_name) = specifier.name.as_str();
|
||||||
match specifier {
|
match source.read_file([dep_scope, dep_name], &app_state.project, None) {
|
||||||
DependencySpecifiers::Pesde(specifier) => {
|
Ok(Some(_)) => {}
|
||||||
if specifier
|
Ok(None) => return Some(Err(Error::InvalidArchive)),
|
||||||
.index
|
Err(e) => return Some(Err(e.into())),
|
||||||
.as_ref()
|
}
|
||||||
.filter(|index| match index.parse::<url::Url>() {
|
|
||||||
Ok(_) if config.other_registries_allowed => true,
|
|
||||||
Ok(url) => url == env!("CARGO_PKG_REPOSITORY").parse().unwrap(),
|
|
||||||
Err(_) => false,
|
|
||||||
})
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
return Err(Error::InvalidArchive);
|
|
||||||
}
|
}
|
||||||
|
DependencySpecifiers::Wally(specifier) => {
|
||||||
|
if !config.wally_allowed {
|
||||||
|
return Some(Err(Error::InvalidArchive));
|
||||||
|
}
|
||||||
|
|
||||||
let (dep_scope, dep_name) = specifier.name.as_str();
|
if specifier
|
||||||
if source
|
.index
|
||||||
.read_file([dep_scope, dep_name], &app_state.project, None)?
|
.as_ref()
|
||||||
.is_none()
|
.filter(|index| index.parse::<url::Url>().is_ok())
|
||||||
{
|
.is_none()
|
||||||
return Err(Error::InvalidArchive);
|
{
|
||||||
|
return Some(Err(Error::InvalidArchive));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
DependencySpecifiers::Git(_) => {
|
||||||
DependencySpecifiers::Wally(specifier) => {
|
if !config.git_allowed {
|
||||||
if !config.wally_allowed {
|
return Some(Err(Error::InvalidArchive));
|
||||||
return Err(Error::InvalidArchive);
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if specifier
|
if ty == DependencyType::Dev {
|
||||||
.index
|
return None;
|
||||||
.as_ref()
|
|
||||||
.filter(|index| index.parse::<url::Url>().is_ok())
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
return Err(Error::InvalidArchive);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
DependencySpecifiers::Git(_) => {
|
|
||||||
if !config.git_allowed {
|
Some(Ok((alias, (specifier, ty))))
|
||||||
return Err(Error::InvalidArchive);
|
})
|
||||||
}
|
.collect::<Result<_, Error>>()?;
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let repo = source.repo_git2(&app_state.project)?;
|
let repo = source.repo_git2(&app_state.project)?;
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ pub struct Manifest {
|
||||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
pub peer_dependencies: BTreeMap<String, DependencySpecifiers>,
|
pub peer_dependencies: BTreeMap<String, DependencySpecifiers>,
|
||||||
/// The dev dependencies of the package
|
/// The dev dependencies of the package
|
||||||
#[serde(default, skip_serializing)]
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
pub dev_dependencies: BTreeMap<String, DependencySpecifiers>,
|
pub dev_dependencies: BTreeMap<String, DependencySpecifiers>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue