From 3068d374d4a8a2b37eedf75d1d9ae5c858fe83bb Mon Sep 17 00:00:00 2001 From: Antoine POPINEAU Date: Fri, 22 Mar 2019 23:19:07 +0100 Subject: [PATCH] Renamed crates and publish to crates.io. --- Cargo.lock | 38 ++++++++++++------- Cargo.toml | 2 +- README.md | 24 ++++++------ knox-bin/Cargo.toml | 31 --------------- knox-bin/src/util/mod.rs | 22 ----------- knox-testing/Cargo.toml | 2 +- knox/Cargo.toml | 26 ++++++++----- {knox-bin => knox}/src/cli.yml | 0 {knox-bin => knox}/src/commands/delete.rs | 4 +- {knox-bin => knox}/src/commands/display.rs | 2 +- {knox-bin => knox}/src/commands/identities.rs | 2 +- {knox-bin => knox}/src/commands/info.rs | 2 +- {knox-bin => knox}/src/commands/init.rs | 4 +- {knox-bin => knox}/src/commands/mod.rs | 0 {knox-bin => knox}/src/commands/pwned.rs | 2 +- {knox-bin => knox}/src/commands/write.rs | 4 +- {knox-bin => knox}/src/main.rs | 0 knox/src/spec.rs | 4 +- {knox-bin => knox}/src/util/attributes.rs | 2 +- {knox-bin => knox}/src/util/display.rs | 2 +- {knox-bin => knox}/src/util/hierarchy.rs | 4 +- knox/src/util/mod.rs | 25 ++++++++++-- libknox/Cargo.toml | 25 ++++++++++++ {knox => libknox}/build.rs | 0 {knox => libknox}/protobufs/pb.proto | 0 {knox => libknox}/src/gpg.rs | 0 {knox => libknox}/src/lib.rs | 0 {knox => libknox}/src/pb.rs | 0 {knox => libknox}/src/prelude/attribute.rs | 0 {knox => libknox}/src/prelude/entry.rs | 0 {knox => libknox}/src/prelude/mod.rs | 0 {knox => libknox}/src/prelude/pack.rs | 0 {knox => libknox}/src/prelude/vault.rs | 0 {knox-bin => libknox}/src/spec.rs | 4 +- {knox => libknox}/src/util/error.rs | 0 libknox/src/util/mod.rs | 5 +++ {knox => libknox}/src/util/path.rs | 0 scripts/publish.sh | 23 +++++++++++ 38 files changed, 147 insertions(+), 112 deletions(-) delete mode 100644 knox-bin/Cargo.toml delete mode 100644 knox-bin/src/util/mod.rs rename {knox-bin => knox}/src/cli.yml (100%) rename {knox-bin => knox}/src/commands/delete.rs (96%) rename {knox-bin => knox}/src/commands/display.rs (99%) rename {knox-bin => knox}/src/commands/identities.rs (98%) rename {knox-bin => knox}/src/commands/info.rs (95%) rename {knox-bin => knox}/src/commands/init.rs (95%) rename {knox-bin => knox}/src/commands/mod.rs (100%) rename {knox-bin => knox}/src/commands/pwned.rs (99%) rename {knox-bin => knox}/src/commands/write.rs (99%) rename {knox-bin => knox}/src/main.rs (100%) rename {knox-bin => knox}/src/util/attributes.rs (98%) rename {knox-bin => knox}/src/util/display.rs (98%) rename {knox-bin => knox}/src/util/hierarchy.rs (98%) create mode 100644 libknox/Cargo.toml rename {knox => libknox}/build.rs (100%) rename {knox => libknox}/protobufs/pb.proto (100%) rename {knox => libknox}/src/gpg.rs (100%) rename {knox => libknox}/src/lib.rs (100%) rename {knox => libknox}/src/pb.rs (100%) rename {knox => libknox}/src/prelude/attribute.rs (100%) rename {knox => libknox}/src/prelude/entry.rs (100%) rename {knox => libknox}/src/prelude/mod.rs (100%) rename {knox => libknox}/src/prelude/pack.rs (100%) rename {knox => libknox}/src/prelude/vault.rs (100%) rename {knox-bin => libknox}/src/spec.rs (88%) rename {knox => libknox}/src/util/error.rs (100%) create mode 100644 libknox/src/util/mod.rs rename {knox => libknox}/src/util/path.rs (100%) create mode 100755 scripts/publish.sh diff --git a/Cargo.lock b/Cargo.lock index ef30b99..28e33c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -629,25 +629,14 @@ dependencies = [ [[package]] name = "knox" version = "0.1.0" -dependencies = [ - "gpgme 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "knox_testing 0.1.0", - "protobuf 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc-rust 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "knox-bin" -version = "0.1.0" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "colored 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "knox 0.1.0", "knox_testing 0.1.0", + "libknox 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_env_logger 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -661,7 +650,7 @@ name = "knox_testing" version = "0.1.0" dependencies = [ "gpgme 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "knox 0.1.0", + "libknox 0.1.0", "protobuf 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -700,6 +689,28 @@ dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "libknox" +version = "0.1.0" +dependencies = [ + "gpgme 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "knox_testing 0.1.0", + "protobuf 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc-rust 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libknox" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gpgme 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc-rust 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "lock_api" version = "0.1.5" @@ -1856,6 +1867,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)" = "023a4cd09b2ff695f9734c1934145a315594b7986398496841c7031a5a1bbdbd" "checksum libflate 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "bff3ac7d6f23730d3b533c35ed75eef638167634476a499feef16c428d74b57b" "checksum libgpg-error-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f382cb49e4f37c592f65c5c568646a4afd43396a9da522984cc82d28f3d2c0b" +"checksum libknox 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4f87b8397c99eaebe7ce87a6afc8d1c99db900ec374aa37effd8637d8dcf7ec" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" diff --git a/Cargo.toml b/Cargo.toml index 41aa6d4..ca4ee2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] members = [ + "libknox", "knox", - "knox-bin", "knox-testing" ] diff --git a/README.md b/README.md index 030f14b..2049ee1 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ The following command creates an empty vault and takes the GPG identity for whic ``` $ knox init myidentity@example.com - INFO knox::commands::init > vault initialized successfully + INFO libknox::commands::init > vault initialized successfully ``` By default, the vault will be created in ```$HOME/.knox```. You can change this path by setting the ```KNOX_PATH``` environment variable. @@ -57,7 +57,7 @@ By default, the vault will be created in ```$HOME/.knox```. You can change this ``` $ knox add dir/subdir/website.com username=apognu password=Str0ngP@ss - INFO knox::commands::write > entry personal/website was successfully added to the vault + INFO libknox::commands::write > entry personal/website was successfully added to the vault ``` ```vault``` is attribute-agnostic, there is no special handling of, for instance, the ```password``` attribute. You can add any number of attributes to an entry. @@ -69,7 +69,7 @@ One special kind of attribute is _confidential_ attributes. They only differ in ``` $ knox add website.com username=apognu password= Enter value for 'password': - INFO knox::commands::write > entry personal/website was successfully added to the vault + INFO libknox::commands::write > entry personal/website was successfully added to the vault ``` ### Generated passwords @@ -90,7 +90,7 @@ An entire file can be embedded into an attribute with the syntax ```attr=@/path/ ``` $ knox add personal/ssh pubkey=@/home/apognu/.ssh/id_rsa.pub privkey=@/home/apognu/.ssh/id_rsa -INFO knox::commands::write > entry personal/ssh was successfully added to the vault +INFO libknox::commands::write > entry personal/ssh was successfully added to the vault $ knox show personal/ssh Store » ssh » keys privkey = @@ -175,7 +175,7 @@ The syntax for modifying an existing secret is exactly the same as the one used ``` $ knox edit website.com -d url username=newlogin password= - INFO knox::commands::write > entry website.com was successfully edited + INFO libknox::commands::write > entry website.com was successfully edited ``` This command will delete thre ```url``` attribute from the secret, change the ```username``` attribute to ```newlogin``` and prompt for the value of the redacted attribute ```password``` @@ -186,14 +186,14 @@ A secret can be renamed through the ```rename``` command: ``` $ knox rename my/first/secret new/location/secret - INFO knox::commands::write > entry my/first/secret was successfully renamed to new/location/secret + INFO libknox::commands::write > entry my/first/secret was successfully renamed to new/location/secret ``` ## Delete a secret ``` $ knox delete dir/subdir/website.com - INFO knox::commands::delete > entry 'dir/subdir/website.com' was successfully deleted from the vault + INFO libknox::commands::delete > entry 'dir/subdir/website.com' was successfully deleted from the vault ``` ## Check if you've been pwned @@ -202,7 +202,7 @@ Vault integrates Troy Hunt's [Have I Been Pwned](https://haveibeenpwned.com/) to ``` $ knox pwned my/super/password -INFO knox::commands::pwned > Pwnage status for attributes at pwned/test +INFO libknox::commands::pwned > Pwnage status for attributes at pwned/test ⚠ password -> PWNED ✓ secure -> CLEAR ⚠ apikey -> PWNED @@ -213,7 +213,7 @@ The check is also performed for confidential attributes when adding or editing a You may also omit the ```PATH``` paramter to initiate a vault-wide check against the data breaches. This may take some time, but will check all confidential attributes in your vault: ``` -INFO knox::commands::pwned > checking for pwned secret across your vault +INFO libknox::commands::pwned > checking for pwned secret across your vault ⚠ test/insecure/test1/password -> PWNED ⚠ test/insecure/test1/apikey -> PWNED ⚠ test/insecure/test2/password -> PWNED @@ -232,10 +232,10 @@ When you add or remove an identity to or from the vault, all entries (including ``` $ knox init myown@identity.com - INFO knox::commands::init > vault initialized successfully at /vault + INFO libknox::commands::init > vault initialized successfully at /vault [...] $ knox identities add myfriend@identity.com -INFO knox::commands::identities > Writing metadata file... +INFO libknox::commands::identities > Writing metadata file... re-encrypting entry company/secret1 re-encrypting entry personal/secret2 re-encrypting entry company/secret2 @@ -256,7 +256,7 @@ The library contained in ```knox``` can be used by your program to access and ma # # main.rs -use knox::prelude::*; +use libknox::prelude::*; fn main() -> Result<(), Box> { let context = VaultContext::open("/home/user/.knox")?; diff --git a/knox-bin/Cargo.toml b/knox-bin/Cargo.toml deleted file mode 100644 index 330e5d5..0000000 --- a/knox-bin/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "knox-bin" -version = "0.1.0" -description = "structured secret vault encrypted through GPG" -authors = ["Antoine POPINEAU "] -repository = "https://github.com/apognu/knox" -license = "MIT" - -edition = "2018" -workspace = "../" - -[[bin]] -name = "knox" -path = "src/main.rs" - -[dev-dependencies] -knox_testing = { path = "../knox-testing" } - -[dependencies] -knox = { path = "../knox" } -log = "^0.4" -pretty_env_logger = "^0.2" -clap = { version = "^2.0", features = ["yaml"] } -rand = "^0.6" -rpassword = "2.1.0" -colored = "1.6" -clipboard = "^0.5" -dirs = "1.0.4" -reqwest = "^0.9.0" -sha-1 = "^0.8.0" -indicatif = "^0.11.0" \ No newline at end of file diff --git a/knox-bin/src/util/mod.rs b/knox-bin/src/util/mod.rs deleted file mode 100644 index cff4f4b..0000000 --- a/knox-bin/src/util/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -pub(crate) mod attributes; -pub(crate) mod display; -pub(crate) mod hierarchy; - -use std::env; -use std::error::Error; - -use knox::prelude::*; - -pub(crate) fn vault_path() -> Result> { - let path = env::var("KNOX_PATH"); - - match path { - Ok(path) => Ok(path), - Err(_) => match dirs::home_dir() { - Some(home) => Ok(format!("{}/.knox", home.display())), - None => Err(VaultError::throw( - "could not get your home directory, please set KNOX_PATH", - )), - }, - } -} diff --git a/knox-testing/Cargo.toml b/knox-testing/Cargo.toml index 2b709bf..669bed2 100644 --- a/knox-testing/Cargo.toml +++ b/knox-testing/Cargo.toml @@ -10,7 +10,7 @@ publish = false edition = "2018" [dependencies] -knox = { path = "../knox" } +libknox = { path = "../libknox" } tempfile = "^3.0" protobuf = "^2.2" gpgme = "^0.8" diff --git a/knox/Cargo.toml b/knox/Cargo.toml index 09875b8..0c91689 100644 --- a/knox/Cargo.toml +++ b/knox/Cargo.toml @@ -1,25 +1,31 @@ [package] name = "knox" version = "0.1.0" -description = "secret vault encrypted with GPG" +description = "structured secret vault encrypted through GPG" authors = ["Antoine POPINEAU "] repository = "https://github.com/apognu/knox" license = "MIT" edition = "2018" workspace = "../" -build = "build.rs" -[build-dependencies] -protoc-rust = "2.0" +[[bin]] +name = "knox" +path = "src/main.rs" [dev-dependencies] knox_testing = { path = "../knox-testing" } [dependencies] -protobuf = "^2.2" -gpgme = "^0.8" -uuid = { version = "^0.7", features = ["v4"] } - -[features] -protobufs = [] +libknox = "^0.1" +log = "^0.4" +pretty_env_logger = "^0.2" +clap = { version = "^2.0", features = ["yaml"] } +rand = "^0.6" +rpassword = "2.1.0" +colored = "1.6" +clipboard = "^0.5" +dirs = "1.0.4" +reqwest = "^0.9.0" +sha-1 = "^0.8.0" +indicatif = "^0.11.0" \ No newline at end of file diff --git a/knox-bin/src/cli.yml b/knox/src/cli.yml similarity index 100% rename from knox-bin/src/cli.yml rename to knox/src/cli.yml diff --git a/knox-bin/src/commands/delete.rs b/knox/src/commands/delete.rs similarity index 96% rename from knox-bin/src/commands/delete.rs rename to knox/src/commands/delete.rs index 597f91b..2f579a1 100644 --- a/knox-bin/src/commands/delete.rs +++ b/knox/src/commands/delete.rs @@ -3,7 +3,7 @@ use std::error::Error; use colored::*; use log::*; -use knox::prelude::*; +use libknox::prelude::*; use crate::util::vault_path; @@ -26,7 +26,7 @@ pub(crate) fn delete(args: &clap::ArgMatches) -> Result<(), Box> { mod tests { use clap::App; - use knox::prelude::*; + use libknox::prelude::*; use knox_testing::spec; #[test] diff --git a/knox-bin/src/commands/display.rs b/knox/src/commands/display.rs similarity index 99% rename from knox-bin/src/commands/display.rs rename to knox/src/commands/display.rs index 955f894..972d514 100644 --- a/knox-bin/src/commands/display.rs +++ b/knox/src/commands/display.rs @@ -7,7 +7,7 @@ use colored::*; use log::*; use crate::util::{display, hierarchy, vault_path}; -use knox::prelude::*; +use libknox::prelude::*; pub(crate) fn list(args: &clap::ArgMatches) -> Result<(), Box> { let path = args.value_of("path"); diff --git a/knox-bin/src/commands/identities.rs b/knox/src/commands/identities.rs similarity index 98% rename from knox-bin/src/commands/identities.rs rename to knox/src/commands/identities.rs index 31cbea6..e003bfb 100644 --- a/knox-bin/src/commands/identities.rs +++ b/knox/src/commands/identities.rs @@ -2,7 +2,7 @@ use std::error::Error; use colored::*; use indicatif::ProgressBar; -use knox::prelude::*; +use libknox::prelude::*; use log::*; use crate::util::vault_path; diff --git a/knox-bin/src/commands/info.rs b/knox/src/commands/info.rs similarity index 95% rename from knox-bin/src/commands/info.rs rename to knox/src/commands/info.rs index f801f28..ce8571e 100644 --- a/knox-bin/src/commands/info.rs +++ b/knox/src/commands/info.rs @@ -1,7 +1,7 @@ use std::error::Error; use colored::*; -use knox::prelude::*; +use libknox::prelude::*; use crate::util::vault_path; diff --git a/knox-bin/src/commands/init.rs b/knox/src/commands/init.rs similarity index 95% rename from knox-bin/src/commands/init.rs rename to knox/src/commands/init.rs index 55f63d0..d145b9d 100644 --- a/knox-bin/src/commands/init.rs +++ b/knox/src/commands/init.rs @@ -3,7 +3,7 @@ use std::error::Error; use colored::*; use log::*; -use knox::prelude::*; +use libknox::prelude::*; use crate::util::vault_path; @@ -26,7 +26,7 @@ pub(crate) fn init(args: &clap::ArgMatches) -> Result<(), Box> { mod tests { use clap::App; - use knox::prelude::*; + use libknox::prelude::*; use knox_testing::spec; #[test] diff --git a/knox-bin/src/commands/mod.rs b/knox/src/commands/mod.rs similarity index 100% rename from knox-bin/src/commands/mod.rs rename to knox/src/commands/mod.rs diff --git a/knox-bin/src/commands/pwned.rs b/knox/src/commands/pwned.rs similarity index 99% rename from knox-bin/src/commands/pwned.rs rename to knox/src/commands/pwned.rs index c5e2bf7..6a3ceb2 100644 --- a/knox-bin/src/commands/pwned.rs +++ b/knox/src/commands/pwned.rs @@ -3,7 +3,7 @@ use std::error::Error; use colored::*; use indicatif::ProgressBar; -use knox::prelude::*; +use libknox::prelude::*; use log::*; use sha1::{Digest, Sha1}; diff --git a/knox-bin/src/commands/write.rs b/knox/src/commands/write.rs similarity index 99% rename from knox-bin/src/commands/write.rs rename to knox/src/commands/write.rs index bc695a9..5848720 100644 --- a/knox-bin/src/commands/write.rs +++ b/knox/src/commands/write.rs @@ -1,7 +1,7 @@ use std::error::Error; use colored::*; -use knox::prelude::*; +use libknox::prelude::*; use log::*; use crate::commands::pwned::{self, PwnedResult}; @@ -122,7 +122,7 @@ pub(crate) fn rename(args: &clap::ArgMatches) -> Result<(), Box> { mod tests { use clap::App; - use knox::prelude::*; + use libknox::prelude::*; use knox_testing::spec; #[test] diff --git a/knox-bin/src/main.rs b/knox/src/main.rs similarity index 100% rename from knox-bin/src/main.rs rename to knox/src/main.rs diff --git a/knox/src/spec.rs b/knox/src/spec.rs index 2fd8c04..bdbcf87 100644 --- a/knox/src/spec.rs +++ b/knox/src/spec.rs @@ -1,10 +1,10 @@ -#[cfg(test)] +// #[cfg(test)] use std::error::Error; use std::path::Path; use knox_testing::spec; -use crate::prelude::*; +use libknox::prelude::*; pub(crate) fn get_test_vault

(path: P) -> Result> where diff --git a/knox-bin/src/util/attributes.rs b/knox/src/util/attributes.rs similarity index 98% rename from knox-bin/src/util/attributes.rs rename to knox/src/util/attributes.rs index 43cad9e..8715043 100644 --- a/knox-bin/src/util/attributes.rs +++ b/knox/src/util/attributes.rs @@ -3,7 +3,7 @@ use std::error::Error; use std::fs::OpenOptions; use std::io::Read; -use knox::prelude::*; +use libknox::prelude::*; use rand::{distributions::Alphanumeric, seq::SliceRandom, Rng}; pub(crate) fn build(args: &clap::ArgMatches) -> Result, Box> { diff --git a/knox-bin/src/util/display.rs b/knox/src/util/display.rs similarity index 98% rename from knox-bin/src/util/display.rs rename to knox/src/util/display.rs index 4a4c15f..30798a5 100644 --- a/knox-bin/src/util/display.rs +++ b/knox/src/util/display.rs @@ -5,7 +5,7 @@ use std::fs::{self, OpenOptions}; use std::io::Write; use std::path::Path; -use knox::prelude::*; +use libknox::prelude::*; pub(crate) fn entry(path: &str, entry: &Entry, print: bool) { use colored::*; diff --git a/knox-bin/src/util/hierarchy.rs b/knox/src/util/hierarchy.rs similarity index 98% rename from knox-bin/src/util/hierarchy.rs rename to knox/src/util/hierarchy.rs index 2303e12..87e3d3e 100644 --- a/knox-bin/src/util/hierarchy.rs +++ b/knox/src/util/hierarchy.rs @@ -3,7 +3,7 @@ use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; -use knox::prelude::*; +use libknox::prelude::*; #[derive(Debug, PartialEq)] pub(crate) enum Item { @@ -116,7 +116,7 @@ mod tests { use std::rc::Rc; use super::Item; - use knox::prelude::*; + use libknox::prelude::*; #[test] fn build() { diff --git a/knox/src/util/mod.rs b/knox/src/util/mod.rs index 91e2821..5aed862 100644 --- a/knox/src/util/mod.rs +++ b/knox/src/util/mod.rs @@ -1,5 +1,22 @@ -mod error; -mod path; +pub(crate) mod attributes; +pub(crate) mod display; +pub(crate) mod hierarchy; -pub use self::error::*; -pub(crate) use self::path::*; +use std::env; +use std::error::Error; + +use libknox::prelude::*; + +pub(crate) fn vault_path() -> Result> { + let path = env::var("KNOX_PATH"); + + match path { + Ok(path) => Ok(path), + Err(_) => match dirs::home_dir() { + Some(home) => Ok(format!("{}/.knox", home.display())), + None => Err(VaultError::throw( + "could not get your home directory, please set KNOX_PATH", + )), + }, + } +} diff --git a/libknox/Cargo.toml b/libknox/Cargo.toml new file mode 100644 index 0000000..7147b65 --- /dev/null +++ b/libknox/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "libknox" +version = "0.1.0" +description = "secret vault encrypted with GPG" +authors = ["Antoine POPINEAU "] +repository = "https://github.com/apognu/knox" +license = "MIT" + +edition = "2018" +workspace = "../" +build = "build.rs" + +[build-dependencies] +protoc-rust = "2.0" + +[dev-dependencies] +knox_testing = { path = "../knox-testing", version = "0.1.0" } + +[dependencies] +protobuf = "^2.2" +gpgme = "^0.8" +uuid = { version = "^0.7", features = ["v4"] } + +[features] +protobufs = [] diff --git a/knox/build.rs b/libknox/build.rs similarity index 100% rename from knox/build.rs rename to libknox/build.rs diff --git a/knox/protobufs/pb.proto b/libknox/protobufs/pb.proto similarity index 100% rename from knox/protobufs/pb.proto rename to libknox/protobufs/pb.proto diff --git a/knox/src/gpg.rs b/libknox/src/gpg.rs similarity index 100% rename from knox/src/gpg.rs rename to libknox/src/gpg.rs diff --git a/knox/src/lib.rs b/libknox/src/lib.rs similarity index 100% rename from knox/src/lib.rs rename to libknox/src/lib.rs diff --git a/knox/src/pb.rs b/libknox/src/pb.rs similarity index 100% rename from knox/src/pb.rs rename to libknox/src/pb.rs diff --git a/knox/src/prelude/attribute.rs b/libknox/src/prelude/attribute.rs similarity index 100% rename from knox/src/prelude/attribute.rs rename to libknox/src/prelude/attribute.rs diff --git a/knox/src/prelude/entry.rs b/libknox/src/prelude/entry.rs similarity index 100% rename from knox/src/prelude/entry.rs rename to libknox/src/prelude/entry.rs diff --git a/knox/src/prelude/mod.rs b/libknox/src/prelude/mod.rs similarity index 100% rename from knox/src/prelude/mod.rs rename to libknox/src/prelude/mod.rs diff --git a/knox/src/prelude/pack.rs b/libknox/src/prelude/pack.rs similarity index 100% rename from knox/src/prelude/pack.rs rename to libknox/src/prelude/pack.rs diff --git a/knox/src/prelude/vault.rs b/libknox/src/prelude/vault.rs similarity index 100% rename from knox/src/prelude/vault.rs rename to libknox/src/prelude/vault.rs diff --git a/knox-bin/src/spec.rs b/libknox/src/spec.rs similarity index 88% rename from knox-bin/src/spec.rs rename to libknox/src/spec.rs index a1a2529..2fd8c04 100644 --- a/knox-bin/src/spec.rs +++ b/libknox/src/spec.rs @@ -1,10 +1,10 @@ -// #[cfg(test)] +#[cfg(test)] use std::error::Error; use std::path::Path; use knox_testing::spec; -use knox::prelude::*; +use crate::prelude::*; pub(crate) fn get_test_vault

(path: P) -> Result> where diff --git a/knox/src/util/error.rs b/libknox/src/util/error.rs similarity index 100% rename from knox/src/util/error.rs rename to libknox/src/util/error.rs diff --git a/libknox/src/util/mod.rs b/libknox/src/util/mod.rs new file mode 100644 index 0000000..91e2821 --- /dev/null +++ b/libknox/src/util/mod.rs @@ -0,0 +1,5 @@ +mod error; +mod path; + +pub use self::error::*; +pub(crate) use self::path::*; diff --git a/knox/src/util/path.rs b/libknox/src/util/path.rs similarity index 100% rename from knox/src/util/path.rs rename to libknox/src/util/path.rs diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000..24f9078 --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +CRATES=(libknox knox) + +cargo test -- --test-threads=1 + +for CRATE in ${CRATES[@]}; do + cd $CRATE + + cp Cargo.toml Cargo.toml.bak + sed -i 's/build =.*/build = false/' Cargo.toml + sed -i '/^\[dev-dependencies\]/,/^$/d' Cargo.toml + + cargo package --allow-dirty --no-verify + cargo publish --allow-dirty + + mv Cargo.toml.bak Cargo.toml + + cd .. + +done \ No newline at end of file