Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ use std::path::{Path, PathBuf};
use std::rc::Rc;
use toml_edit::{value, DocumentMut, ImDocument};

fn dep_base(name: &str) -> String {
name.split('@').next().unwrap_or(name).to_string()
}

#[derive(Debug, Serialize, Deserialize)]
struct Package {
name: String,
Expand Down Expand Up @@ -88,7 +92,10 @@ pub async fn update_mops_toml(
if doc["dependencies"].get(&lib).is_some() {
continue;
}
let version = service.get_highest_version(&lib).await?.into_result();
let version = service
.get_highest_version(&dep_base(&lib))
.await?
.into_result();
match version {
Ok(version) => {
println(
Expand Down Expand Up @@ -211,7 +218,7 @@ async fn update_mops_lock(agent: &Agent, env: &Env) -> Result<()> {
continue;
}
let pkg = service
.get_package_details(&name, &version)
.get_package_details(&dep_base(&name), &version)
.await?
.into_result()
.map_err(Error::msg)?;
Expand Down Expand Up @@ -447,7 +454,7 @@ async fn get_latest_package_version(
match pkg.get_type() {
PackageType::Mops { .. } => {
let latest = service
.get_highest_version(&pkg.name)
.get_highest_version(&dep_base(&pkg.name))
.await?
.into_result()
.map_err(Error::msg)?;
Expand Down Expand Up @@ -530,7 +537,7 @@ async fn download_mops_package(
bar: Rc<ProgressBar>,
) -> Result<()> {
let ids = service
.get_file_ids(&lib, &version)
.get_file_ids(&dep_base(&lib), &version)
.await?
.into_result()
.map_err(Error::msg)?;
Expand Down
4 changes: 2 additions & 2 deletions test/main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import DB "mo:candb/CanDB";
//import IC "ic:aaaaa-aa";
import Ledger "ic:ryjl3-tyaaa-aaaaa-aaaba-cai";
import Named "canister:backend";
import Iter "mo:core@1/Iter";

actor {
}
persistent actor {};
2 changes: 1 addition & 1 deletion test/mops.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ prng = "0.0.5"
splay = "https://github.com/chenyan2002/motoko-splay.git"
base_local = "../../motoko-base"
candb = "1.0.8"
"core@1" = "1.0.0"

[[canister]]
name = "backend"
canister_id = "um5iw-rqaaa-aaaaq-qaaba-cai"

[[canister]]
canister_id = "ryjl3-tyaaa-aaaaa-aaaba-cai"