Skip to content

Commit

Permalink
improve manifest error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nick1udwig committed Jul 10, 2024
1 parent 9f17645 commit ea44eec
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kit"
version = "0.6.5"
version = "0.6.6"
edition = "2021"

[build-dependencies]
Expand Down
11 changes: 6 additions & 5 deletions src/run_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::process::Command;
use std::path::{Path, PathBuf};
use std::sync::Arc;

use color_eyre::{eyre::{eyre, WrapErr}, Result};
use color_eyre::{eyre::eyre, Result, Section};
use dirs::home_dir;
use fs_err as fs;
use tokio::sync::Mutex;
Expand Down Expand Up @@ -187,10 +187,11 @@ async fn load_caps(test_package_paths: &Vec<PathBuf>, port: u16) -> Result<()> {
let mut caps = std::collections::HashMap::new();
for test_package_path in test_package_paths {
let manifest_path = test_package_path.join("pkg").join("manifest.json");
let manifest: Vec<PackageManifestEntry> =
serde_json::from_reader(fs::File::open(manifest_path)
.wrap_err_with(|| "Missing required manifest.json file. See discussion at https://book.kinode.org/my_first_app/chapter_1.html?highlight=manifest.json#pkgmanifestjson")?
)?;

let manifest = fs::File::open(manifest_path)
.with_suggestion(|| "Missing required manifest.json file. See discussion at https://book.kinode.org/my_first_app/chapter_1.html?highlight=manifest.json#pkgmanifestjson")?;
let manifest: Vec<PackageManifestEntry> = serde_json::from_reader(manifest)
.with_suggestion(|| "Failed to parse required manifest.json file. See discussion at https://book.kinode.org/my_first_app/chapter_1.html?highlight=manifest.json#pkgmanifestjson")?;
if manifest.len() != 1 {
return Err(eyre!(""));
}
Expand Down
13 changes: 5 additions & 8 deletions src/start_package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use sha2::{Digest, Sha256};
use std::io::{Read, Write};
use std::path::Path;

use color_eyre::{
eyre::{eyre, WrapErr},
Result, Section,
};
use color_eyre::{eyre::eyre, Result, Section};
use fs_err as fs;
use serde_json::json;
use tracing::{info, instrument};
Expand Down Expand Up @@ -131,10 +128,10 @@ pub async fn execute(package_dir: &Path, url: &str) -> Result<()> {
let publisher = metadata.properties.publisher.as_str();
let pkg_publisher = format!("{}:{}", package_name, publisher);

let manifest: Vec<PackageManifestEntry> =
serde_json::from_reader(fs::File::open(pkg_dir.join("manifest.json"))
.wrap_err_with(|| "Missing required manifest.json file. See discussion at https://book.kinode.org/my_first_app/chapter_1.html?highlight=manifest.json#pkgmanifestjson")?
)?;
let manifest = fs::File::open(pkg_dir.join("manifest.json"))
.with_suggestion(|| "Missing required manifest.json file. See discussion at https://book.kinode.org/my_first_app/chapter_1.html?highlight=manifest.json#pkgmanifestjson")?;
let manifest: Vec<PackageManifestEntry> = serde_json::from_reader(manifest)
.with_suggestion(|| "Failed to parse required manifest.json file. See discussion at https://book.kinode.org/my_first_app/chapter_1.html?highlight=manifest.json#pkgmanifestjson")?;
let has_all_entries = manifest.iter().fold(true, |has_all_entries, entry| {
let file_path = entry
.process_wasm_path
Expand Down

0 comments on commit ea44eec

Please sign in to comment.