mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-09 20:38:46 +03:00
fix bug in detecting recursive dependencies
This commit is contained in:
parent
1ebd4fb741
commit
77192723d0
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1326,6 +1326,7 @@ version = "1.5.2"
|
||||
name = "leo-package"
|
||||
version = "1.5.2"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"serde",
|
||||
"thiserror",
|
||||
|
@ -25,8 +25,7 @@ use leo_package::root::{
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use indexmap::set::IndexSet;
|
||||
use std::collections::HashMap;
|
||||
use indexmap::{set::IndexSet, IndexMap};
|
||||
use structopt::StructOpt;
|
||||
use tracing::span::Span;
|
||||
|
||||
@ -85,7 +84,7 @@ impl Fetch {
|
||||
context: Context,
|
||||
mut tree: IndexSet<String>,
|
||||
lock_file: &mut LockFile,
|
||||
dependencies: HashMap<String, Dependency>,
|
||||
dependencies: IndexMap<String, Dependency>,
|
||||
) -> Result<()> {
|
||||
// Go through each dependency in Leo.toml and add it to the imports.
|
||||
// While adding, pull dependencies of this package as well and check for recursion.
|
||||
|
@ -17,6 +17,9 @@ include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ]
|
||||
license = "GPL-3.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies.indexmap]
|
||||
version = "1.7"
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
features = [ "derive" ]
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
use crate::{errors::LockFileError, root::Dependency};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
@ -43,8 +44,8 @@ pub struct Package {
|
||||
pub version: String,
|
||||
pub author: String,
|
||||
pub import_name: Option<String>,
|
||||
#[serde(skip_serializing_if = "HashMap::is_empty", default)]
|
||||
pub dependencies: HashMap<String, String>,
|
||||
#[serde(skip_serializing_if = "IndexMap::is_empty", default)]
|
||||
pub dependencies: IndexMap<String, String>,
|
||||
}
|
||||
|
||||
impl LockFile {
|
||||
@ -125,7 +126,7 @@ impl TryFrom<&Path> for LockFile {
|
||||
|
||||
impl Package {
|
||||
/// Fill dependencies from Leo Manifest data.
|
||||
pub fn add_dependencies(&mut self, dependencies: &HashMap<String, Dependency>) {
|
||||
pub fn add_dependencies(&mut self, dependencies: &IndexMap<String, Dependency>) {
|
||||
for (import_name, dependency) in dependencies.iter() {
|
||||
self.dependencies
|
||||
.insert(import_name.clone(), Package::from(dependency).to_string());
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
use crate::{errors::ManifestError, package::Package};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
@ -45,7 +46,7 @@ pub struct Dependency {
|
||||
pub struct Manifest {
|
||||
pub project: Package,
|
||||
pub remote: Option<Remote>,
|
||||
pub dependencies: Option<HashMap<String, Dependency>>,
|
||||
pub dependencies: Option<IndexMap<String, Dependency>>,
|
||||
}
|
||||
|
||||
impl Manifest {
|
||||
@ -53,7 +54,7 @@ impl Manifest {
|
||||
Ok(Self {
|
||||
project: Package::new(package_name)?,
|
||||
remote: author.map(|author| Remote { author }),
|
||||
dependencies: Some(HashMap::<String, Dependency>::new()),
|
||||
dependencies: Some(IndexMap::<String, Dependency>::new()),
|
||||
})
|
||||
}
|
||||
|
||||
@ -81,7 +82,7 @@ impl Manifest {
|
||||
self.project.description.clone()
|
||||
}
|
||||
|
||||
pub fn get_package_dependencies(&self) -> Option<HashMap<String, Dependency>> {
|
||||
pub fn get_package_dependencies(&self) -> Option<IndexMap<String, Dependency>> {
|
||||
self.dependencies.clone()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user