mirror of
https://github.com/AleoHQ/leo.git
synced 2025-01-07 02:19:52 +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"
|
name = "leo-package"
|
||||||
version = "1.5.2"
|
version = "1.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"indexmap",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@ -25,8 +25,7 @@ use leo_package::root::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use indexmap::set::IndexSet;
|
use indexmap::{set::IndexSet, IndexMap};
|
||||||
use std::collections::HashMap;
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use tracing::span::Span;
|
use tracing::span::Span;
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ impl Fetch {
|
|||||||
context: Context,
|
context: Context,
|
||||||
mut tree: IndexSet<String>,
|
mut tree: IndexSet<String>,
|
||||||
lock_file: &mut LockFile,
|
lock_file: &mut LockFile,
|
||||||
dependencies: HashMap<String, Dependency>,
|
dependencies: IndexMap<String, Dependency>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// Go through each dependency in Leo.toml and add it to the imports.
|
// 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.
|
// 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"
|
license = "GPL-3.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies.indexmap]
|
||||||
|
version = "1.7"
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
features = [ "derive" ]
|
features = [ "derive" ]
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
use crate::{errors::LockFileError, root::Dependency};
|
use crate::{errors::LockFileError, root::Dependency};
|
||||||
|
|
||||||
|
use indexmap::IndexMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
@ -43,8 +44,8 @@ pub struct Package {
|
|||||||
pub version: String,
|
pub version: String,
|
||||||
pub author: String,
|
pub author: String,
|
||||||
pub import_name: Option<String>,
|
pub import_name: Option<String>,
|
||||||
#[serde(skip_serializing_if = "HashMap::is_empty", default)]
|
#[serde(skip_serializing_if = "IndexMap::is_empty", default)]
|
||||||
pub dependencies: HashMap<String, String>,
|
pub dependencies: IndexMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LockFile {
|
impl LockFile {
|
||||||
@ -125,7 +126,7 @@ impl TryFrom<&Path> for LockFile {
|
|||||||
|
|
||||||
impl Package {
|
impl Package {
|
||||||
/// Fill dependencies from Leo Manifest data.
|
/// 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() {
|
for (import_name, dependency) in dependencies.iter() {
|
||||||
self.dependencies
|
self.dependencies
|
||||||
.insert(import_name.clone(), Package::from(dependency).to_string());
|
.insert(import_name.clone(), Package::from(dependency).to_string());
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
use crate::{errors::ManifestError, package::Package};
|
use crate::{errors::ManifestError, package::Package};
|
||||||
|
|
||||||
|
use indexmap::IndexMap;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
@ -45,7 +46,7 @@ pub struct Dependency {
|
|||||||
pub struct Manifest {
|
pub struct Manifest {
|
||||||
pub project: Package,
|
pub project: Package,
|
||||||
pub remote: Option<Remote>,
|
pub remote: Option<Remote>,
|
||||||
pub dependencies: Option<HashMap<String, Dependency>>,
|
pub dependencies: Option<IndexMap<String, Dependency>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manifest {
|
impl Manifest {
|
||||||
@ -53,7 +54,7 @@ impl Manifest {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
project: Package::new(package_name)?,
|
project: Package::new(package_name)?,
|
||||||
remote: author.map(|author| Remote { author }),
|
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()
|
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()
|
self.dependencies.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user