1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use log::info;
use flowcore::model::lib_manifest::DEFAULT_LIB_JSON_MANIFEST_FILENAME;
use flowcore::model::lib_manifest::LibraryManifest;
use crate::errors::*;
pub fn write(lib_manifest: &LibraryManifest, json_manifest_filename: &Path) -> Result<()> {
let mut manifest_file = File::create(&json_manifest_filename)?;
manifest_file.write_all(
serde_json::to_string_pretty(lib_manifest)
.chain_err(|| "Could not pretty format the library manifest JSON contents")?
.as_bytes(),
)?;
info!(
"Generated library JSON manifest at '{}'",
json_manifest_filename.display()
);
Ok(())
}
pub fn manifest_filename(base_dir: &Path) -> PathBuf {
let mut filename = base_dir.to_path_buf();
filename.push(DEFAULT_LIB_JSON_MANIFEST_FILENAME);
filename.set_extension("json");
filename
}