From 4f9c0e27ca25042a97acebc9f3282e4f941706fe Mon Sep 17 00:00:00 2001 From: Jan Allersma Date: Jan 10 2019 15:46:34 +0000 Subject: Rename project to 'Ambassade'. --- diff --git a/.gitignore b/.gitignore index 8741fe0..cec1169 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /target **/*.rs.bk -*beheer.json +*ambassade.json diff --git a/Cargo.lock b/Cargo.lock index 0aa7ce0..072f7aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,7 +43,7 @@ dependencies = [ ] [[package]] -name = "beheer" +name = "ambassade" version = "0.1.0" dependencies = [ "git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 47d2e5c..ef6b9ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "beheer" +name = "ambassade" version = "0.1.0" authors = ["Jan Allersma "] diff --git a/README.md b/README.md index c04e7ca..e1dd235 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Beheer +# Ambassade ## Notes diff --git a/doc/use_cases.md b/doc/use_cases.md new file mode 100644 index 0000000..bf16fcd --- /dev/null +++ b/doc/use_cases.md @@ -0,0 +1,76 @@ +# Migrate your software. + +Saying goodbye to a reliable old framework can be scary. +You need to make sure that every piece of software has been migrated and +working correctly when it gets in production. +With Ambassade it is easy to set up dependencies and pieces of your code in a +hybrid way, making your migrations smoother. +Once you have migrated a part of your code, Ambassade checks for remaining +dependencies in your configuration before you remove your old code. + +# Control over heterogenous packages. + +In some cases, you want to make use of libraries/packages that take some effort +to be compatible with your project. Take the OPC-UA protocol for example. The +protocol has limited implementations because of a 400+ pages counting +specification. There are some useful C libraries available that support the +OPC-UA protocol. If you want to combine the library with Node.js, you have some +solutions, for example: + +* Create an NPM package that interfaces with the C implementation using Node's +Native API. + +* Seperate your project in a server-side part, using [Oat++](https://oatpp.io) +to create an executable for the server, containing the back-end code. The +client-side part will consist of front-end code. + +* Compile the library to WebAssembly and "glue" the compiled binary to your +Node.js code. + +Without having a central package manager that organizes all the different parts +of the code in different languages, keeping control over your software will be +difficult. There are some package managers and git features (like submodules +and mergetrees) that can help you with managing your packages. However, most +of them will not provide a satisfying solution. Ambassade is dedicated to manage +heterogenous packages, and does not even require special configuration files in +the dependencies themselves. + +# Make your software more modular. + +Because Ambassade takes care of dependencies, it gives you as developer more +freedom to make your projects more modular. You could split your project in +more repositories. The advantage of modulating your project is that you can +re-use code more easily. If a deprecated feature should not be implemented +in your project anymore, you can rebuild your project without having to delete +files. Maybe that code could be useful later for future projects. + +If you already have certain features implemented in project A, you can import +that feature in project B with one command, so you only have to focus on +calling the feature from your project. + +# Keep the structure of non-trivial projects simple. + +Once a successful project grows, and grows, it's structure will be less obvious. +The developers that developed the project from the start, know exactly the +relationships between dependencies. New developers that join the development +team will have a harder time figuring the project's structure out. An +easy-to-read configuration file and a flat dependency structure would be a +solution. + +## What is a 'flat dependency structure'? + +NPM version 2 uses a nested dependency structure. This basically means that a +dependency resides in a dependency, which resides in another dependency and so +on. + +A flat dependency structure has all dependencies at the same level. Ambassade +puts all dependencies in one directory, the `dep` directory. This makes finding +dependencies easier and keeps directory paths relatively small. + +# Backup all of your code with one command. + +Having to checkout and backup all of your code manually, could take a lot of +time and joy. Automating checkouts and backups of your code takes a lot of time +as well and isn't that enjoyable. Initializing a Ambassade project with all your +code as dependencies saves a lot of time. This way you can use Ambassade as a +system to backup all important files. diff --git a/src/backend/build.rs b/src/backend/build.rs index 2db696b..be084c6 100644 --- a/src/backend/build.rs +++ b/src/backend/build.rs @@ -60,7 +60,7 @@ fn build_module(config: serde_json::Value) -> Result { let build_cmd = &config["build"]["linux"]; if !build_cmd.is_string() { - return Err(String::from("beheer.json: 'build->linux' should be a string.")); + return Err(String::from("ambassade.json: 'build->linux' should be a string.")); } super::fetch::build(env::current_dir().unwrap(), String::from(build_cmd.as_str().unwrap())) @@ -73,7 +73,7 @@ fn build_module(config: serde_json::Value) -> Result { let build_cmd = &config["build"]["os-x"]; if !build_cmd.is_string() { - return Err(String::from("beheer.json: 'build->os-x' should be a string.")); + return Err(String::from("ambassade.json: 'build->os-x' should be a string.")); } super::fetch::fetch(env::get_current_dir().unwrap(), String::from(build_cmd.as_str().unwrap())) @@ -86,7 +86,7 @@ fn build_module(config: serde_json::Value) -> Result { let build_cmd = &config["build"]["windows"]; if !build_cmd.is_string() { - return Err(String::from("beheer.json: 'build->windows' should be a string.")); + return Err(String::from("ambassade.json: 'build->windows' should be a string.")); } super::fetch::fetch(env::get_current_dir().unwrap(), String::from(build_cmd.as_str().unwrap())) diff --git a/src/backend/config.rs b/src/backend/config.rs index 4ece9c9..98b1644 100644 --- a/src/backend/config.rs +++ b/src/backend/config.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; use std::result::Result; pub fn create(mut path: PathBuf) -> Result<(), Error> { - path.push("beheer.json"); + path.push("ambassade.json"); init(&path) } @@ -26,7 +26,7 @@ fn init(path: &PathBuf) -> Result<(), Error> { }); match File::open(path.to_str().unwrap()) { - Ok(_) => return Err(Error::new(ErrorKind::AlreadyExists, "Already found a 'beheer.json' file.")), + Ok(_) => return Err(Error::new(ErrorKind::AlreadyExists, "Already found a 'ambassade.json' file.")), Err(_) => { match File::create(path) { Ok(mut file) => { @@ -41,7 +41,7 @@ fn init(path: &PathBuf) -> Result<(), Error> { } pub fn update(mut path: PathBuf, value: serde_json::Value) -> Result<(), String> { - path.push("beheer.json"); + path.push("ambassade.json"); match File::create(path) { Ok(mut file) => { @@ -57,7 +57,7 @@ pub fn update(mut path: PathBuf, value: serde_json::Value) -> Result<(), String> fn read(path: &mut PathBuf) -> Result { let mut config = String::new(); - path.push("beheer.json"); + path.push("ambassade.json"); check(&path); match File::open(path.to_str().unwrap()) { diff --git a/src/backend/dep.rs b/src/backend/dep.rs index 6f7d34b..530863b 100644 --- a/src/backend/dep.rs +++ b/src/backend/dep.rs @@ -21,15 +21,15 @@ pub fn json(config: String) -> Result { return Err(error); }, serde_json::error::Category::Syntax => { - error.push_str("Syntax error in 'beheer.json'"); + error.push_str("Syntax error in 'ambassade.json'"); return Err(error); }, serde_json::error::Category::Data => { - error.push_str("Semantic error in 'beheer.json'"); + error.push_str("Semantic error in 'ambassade.json'"); return Err(error); }, serde_json::error::Category::Eof => { - error.push_str("Unexpected end-of-file in 'beheer.json'"); + error.push_str("Unexpected end-of-file in 'ambassade.json'"); return Err(error); } } @@ -73,12 +73,12 @@ pub fn dep(config: serde_json::Value, os: &OS) -> Result, Some(object) => { for dep in object.iter() { if !dep.1.is_string() { - return Err(String::from("beheer.json: all deps should be strings!")) + return Err(String::from("ambassade.json: all deps should be strings!")) } output.push((dep.0.to_string(), String::from(dep.1.as_str().unwrap()))); } }, - None => return Err(String::from("beheer.json: 'deps->linux' should be an object.")) + None => return Err(String::from("ambassade.json: 'deps->linux' should be an object.")) } } }, @@ -89,12 +89,12 @@ pub fn dep(config: serde_json::Value, os: &OS) -> Result, Some(object) => { for dep in object.iter() { if !dep.1.is_string() { - return Err(String::from("beheer.json: all deps should be strings!")) + return Err(String::from("ambassade.json: all deps should be strings!")) } output.push((dep.0.to_string(), String::from(dep.1.as_str().unwrap()))); } }, - None => return Err(String::from("beheer.json: 'deps->os-x' should be an object.")) + None => return Err(String::from("ambassade.json: 'deps->os-x' should be an object.")) } } }, @@ -105,12 +105,12 @@ pub fn dep(config: serde_json::Value, os: &OS) -> Result, Some(object) => { for dep in object.iter() { if !dep.1.is_string() { - return Err(String::from("beheer.json: all deps should be strings!")) + return Err(String::from("ambassade.json: all deps should be strings!")) } output.push((dep.0.to_string(), String::from(dep.1.as_str().unwrap()))); } }, - None => return Err(String::from("beheer.json: 'deps->windows' should be an object.")) + None => return Err(String::from("ambassade.json: 'deps->windows' should be an object.")) } } } diff --git a/src/backend/fetch.rs b/src/backend/fetch.rs index e98a1f3..2ddfbe7 100644 --- a/src/backend/fetch.rs +++ b/src/backend/fetch.rs @@ -44,7 +44,7 @@ fn fetch(dep: PathBuf, command: String) -> Result { }, Err(e) => { let mut config_file = dep.clone(); - config_file.push("beheer.json"); + config_file.push("ambassade.json"); let mut error = String::from("Fetching failed: command '"); error.push_str(command); @@ -54,7 +54,7 @@ fn fetch(dep: PathBuf, command: String) -> Result { match config_file.to_str() { Some(path) => error.push_str(path), - None => error.push_str("beheer.json") + None => error.push_str("ambassade.json") } error.push_str("' file."); diff --git a/src/backend/filesystem.rs b/src/backend/filesystem.rs index 3a5e3b9..3467053 100644 --- a/src/backend/filesystem.rs +++ b/src/backend/filesystem.rs @@ -4,7 +4,7 @@ use std::io::{Result, Error, ErrorKind}; fn get_root(mut path: path::PathBuf) -> Option { loop { let mut config = path.clone(); - config.push("beheer.json"); + config.push("ambassade.json"); if config.as_path().is_file() { return Some(path); diff --git a/src/backend/project.rs b/src/backend/project.rs index 7540211..d4affa5 100644 --- a/src/backend/project.rs +++ b/src/backend/project.rs @@ -46,19 +46,19 @@ pub fn exe(args: &mut I) -> Result where I: Iterator args = String::from(string), - None => return Err(String::from("beheer.json: 'run->linux' should be a string.")) + None => return Err(String::from("ambassade.json: 'run->linux' should be a string.")) } } if cfg!(target_os = "macos") { match config["run"]["os-x"].as_str() { Some(string) => args = String::from(string), - None => return Err(String::from("beheer.json: 'run->os-x' should be a string.")) + None => return Err(String::from("ambassade.json: 'run->os-x' should be a string.")) } } if cfg!(target_os = "windows") { match config["run"]["windows"].as_str() { Some(string) => args = String::from(string), - None => return Err(String::from("beheer.json: 'run->windows' should be a string.")) + None => return Err(String::from("ambassade.json: 'run->windows' should be a string.")) } } }, @@ -130,7 +130,7 @@ pub fn ignore(args: &Vec) -> Result<(), String> { match super::filesystem::get_current_dep_root() { Ok(mut dir) => { dir.push(&entry); - super::git::ignore::add(&mut dir, &mut entry) // entry moet "beheer.json" worden. + super::git::ignore::add(&mut dir, &mut entry) // entry moet "ambassade.json" worden. }, Err(e) => Err(e.to_string()) } @@ -154,7 +154,7 @@ pub fn dep_tree(args: &mut I) -> Result where I: Itera pub fn help() { println!("Syntax:"); - println!("$ beheer [FLAG] [COMMAND [ARGUMENTS]]"); + println!("$ ambassade [FLAG] [COMMAND [ARGUMENTS]]"); println!(""); println!("--help -h\t\t\t\tShow this message");