diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9456d95..178d1af 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -10,6 +10,7 @@ env:
jobs:
publish:
runs-on: ubuntu-latest
+ permissions: write-all
steps:
- uses: actions/checkout@v3
@@ -39,20 +40,30 @@ jobs:
- name: Run tests with all features
run: cargo test --all-features
+ # - name: publish crates
+ # uses: katyo/publish-crates@v2
+ # with:
+ # # crates.io registry token
+ # registry-token: ${{ secrets.crates_io }}
+
+ - name: publish crates dry run
+ run: |
+ cargo login ${{ secrets.crates_io }}
+ cargo publish -p encrypt_config --dry-run
+ cargo publish -p encrypt_config_derive --dry-run
+
- name: publish crates
- uses: katyo/publish-crates@v2
- with:
- # crates.io registry token
- registry-token: ${{ secrets.crates_io }}
+ run: |
+ cargo publish -p encrypt_config
+ cargo publish -p encrypt_config_derive
- name: Create Tag
uses: actions/github-script@v6
with:
script: |
- const {VERSION} = process.env
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
- ref: `refs/tags/v${VERSION}`,
+ ref: 'refs/tags/v${{ steps.extract-version.outputs.VERSION }}',
sha: context.sha
})
diff --git a/Cargo.toml b/Cargo.toml
index 74a850d..987b840 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,8 @@
-[package]
-name = "encrypt-config"
+[workspace]
+members = ["encrypt-config", "encrypt-config-derive", "tests"]
+resolver = "2"
+
+[workspace.package]
version = "0.0.1-alpha4"
authors = ["Louis <836250617@qq.com>"]
description = "A rust crate to manage, persist and encrypt your configurations."
@@ -7,26 +10,6 @@ license = "MIT"
edition = "2021"
repository = "https://github.com/kingwingfly/encrypt-config"
-[dependencies]
-snafu = { version = "0.7.5" }
-serde = { version = "1", optional = true }
-serde_json = { version = "1", optional = true }
-rsa = { version = "0.9.6", features = ["serde"] }
-keyring = "2.1.0"
-dirs-next = { version = "2.0.0", optional = true }
-rand = "0.8.5"
-encrypt-config-derive = { path = "encrypt-config-derive", version = "0.0.1-alpha4" }
-
-[profile.release]
-lto = true
-opt-level = 3
-codegen-units = 1
-
-[profile.dev]
-opt-level = 3
-
-[features]
-default = ["serde"]
-serde = ["dep:serde", "dep:serde_json"]
-default_config_dir = ["dep:dirs-next", "encrypt-config-derive/default_config_dir"]
-protobuf = []
+[workspace.dependencies]
+encrypt_config = { path = "encrypt-config", version = "^0.0.1-alpha3" }
+encrypt_config_derive = { path = "encrypt-config-derive", version = "^0.0.1-alpha3" }
diff --git a/README.md b/README.md
deleted file mode 100644
index 6ecc500..0000000
--- a/README.md
+++ /dev/null
@@ -1,242 +0,0 @@
-
-
-
-
-[![Contributors][contributors-shield]][contributors-url]
-[![Forks][forks-shield]][forks-url]
-[![Stargazers][stars-shield]][stars-url]
-[![Issues][issues-shield]][issues-url]
-[![MIT License][license-shield]][license-url]
-[![LinkedIn][linkedin-shield]][linkedin-url]
-
-
-
-
-
-
-
-
-
-
-
- Table of Contents
-
- -
- About The Project
-
-
- - Usage
- - Roadmap
- - Contributing
- - License
- - Contact
- - Acknowledgments
-
-
-
-
-
-
-## About The Project
-
-Sometimes, we need to store config in our application that we don't want to expose to the public. For example, the database password, the api key, etc.
-
-One solution is to store them in the OS' secret manager, such as `Keychain` on macOS, `Credential Manager` on Windows, `libsecret` on Linux.
-
-However, they usually have limitation on the secret length. For example, `Keychain` only allows 255 bytes for the secret, `Credential Manager` is even shorter. So we can't store a long secret in it.
-
-Another solution is to store the secret in a file and encrypt it with a rsa public key, and store the private key in the OS' secret manager. This is what this crate does.
-
-In other cases, maybe our secret is not a `String`, but a config `struct`. We can also use this crate to manage it. When invoke `Config::get`, it will deserialize the config from the cache and return it.
-
-This crate provides 3 ways to manage your config:
-- `Source`: A normal source, not persisted or encrypted
-- `PersistSource`: A source that will be persisted to local file, not encrypted
-- `SecretSource`: A source that will be persisted to local file and encrypted
-
-This crate also has some optional features:
-- `default_config_dir`: If enabled, the default config dir will be used.
-- `protobuf`: If enabled, protobuf will be used instead of json for better performance. (Not implemented yet)
-
-(back to top)
-
-
-
-### Built With
-
-* Rust
-* Keyring
-
-(back to top)
-
-
-
-
-## Usage
-_(You may see many `#[cfg(feature = "...")]` in the example below, if you are not familar to Rust, you may not know this attribute is for `Conditinal Compile`, so that I can test it in `cargo test --all-features` automatically to ensure all go right.)_
-
-You can implement the `Source`, `PersistSource` and `SecretSource` yourself.
-```rust no_run
-use encrypt_config::{Config, SecretSource};
-use serde::{Deserialize, Serialize};
-
-#[derive(Serialize, Deserialize, PartialEq, Debug)]
-struct Foo(String);
-
-struct SecretSourceImpl;
-
-// impl `SecectSource` trait for `SecretSourceImpl`
-impl SecretSource for SecretSourceImpl {
- type Value = Foo;
-
- #[cfg(not(feature = "default_config_dir"))]
- fn path(&self) -> std::path::PathBuf {
- std::path::PathBuf::from("tests").join("secret.conf")
- }
-
- #[cfg(feature = "default_config_dir")]
- fn source_name(&self) -> String {
- "secret.conf".to_owned()
- }
-}
-
-let mut config = Config::new("test"); // `test` is the name of rsa private key in OS' secret manager
-config.add_secret_source(SecretSourceImpl).unwrap(); // This will read and decrypt the config from local storage. However, it is empty now.
-
-let new_value = Foo("value".to_owned());
-let patch = SecretSourceImpl.upgrade("key", &new_value); // `upgrade` will return a `Patch`
-patch.apply(&mut config).unwrap(); // No change will happen until the `Patch` is applied
-let v: Foo = config.get("key").unwrap();
-assert_eq!(v, Foo("value".to_owned()));
-```
-
-You can also use the derive macros.
-
-```rust no_run
-// To derive [`Source`]
-use encrypt_config::{PersistSource, SecretSource, Source};
-use serde::{Deserialize, Serialize};
-
-#[derive(Serialize, Deserialize, PartialEq, Debug)]
-struct Foo(String);
-
-#[derive(Source)]
-#[source(value(Foo), default([("key".to_owned(), Foo("value".to_owned()))]))]
-struct SourceFoo;
-
-//To derive [`PersistSource`]
-#[cfg(not(feature = "default_config_dir"))]
-#[derive(PersistSource)]
-#[source(value(Foo), path("tests/persist.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
-struct PersistSourceFoo;
-
-// To derive [`SecretSource`]
-#[cfg(not(feature = "default_config_dir"))]
-#[derive(SecretSource)]
-#[source(value(Foo), path("tests/secret.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
-struct SecretSourceFoo;
-```
-
-_For more examples, please refer to the [Example](examples) or [Documentation](https://docs.rs/encrypt_config)_
-
-(back to top)
-
-
-
-
-## Roadmap
-
-- [ ] Enable protobuf instead of json for better performance
-
-See the [open issues](https://github.com/kingwingfly/encrypt-config/issues) for a full list of proposed features (and known issues).
-
-(back to top)
-
-
-
-
-## Contributing
-
-Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
-
-If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
-Don't forget to give the project a star! Thanks again!
-
-1. Fork the Project
-2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
-3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
-4. Push to the Branch (`git push origin feature/AmazingFeature`)
-5. Open a Pull Request
-
-(back to top)
-
-
-
-
-## License
-
-Distributed under the MIT License. See `LICENSE.txt` for more information.
-
-(back to top)
-
-
-
-
-## Contact
-
-Louis - 836250617@qq.com
-
-Project Link: [https://github.com/kingwingfly/encrypt-config](https://github.com/kingwingfly/encrypt-config)
-
-(back to top)
-
-
-
-
-## Acknowledgments
-
-* None
-* []()
-
-(back to top)
-
-
-
-
-
-[contributors-shield]: https://img.shields.io/github/contributors/kingwingfly/encrypt-config.svg?style=for-the-badge
-[contributors-url]: https://github.com/kingwingfly/encrypt-config/graphs/contributors
-[forks-shield]: https://img.shields.io/github/forks/kingwingfly/encrypt-config.svg?style=for-the-badge
-[forks-url]: https://github.com/kingwingfly/encrypt-config/network/members
-[stars-shield]: https://img.shields.io/github/stars/kingwingfly/encrypt-config.svg?style=for-the-badge
-[stars-url]: https://github.com/kingwingfly/encrypt-config/stargazers
-[issues-shield]: https://img.shields.io/github/issues/kingwingfly/encrypt-config.svg?style=for-the-badge
-[issues-url]: https://github.com/kingwingfly/encrypt-config/issues
-[license-shield]: https://img.shields.io/github/license/kingwingfly/encrypt-config.svg?style=for-the-badge
-[license-url]: https://github.com/kingwingfly/encrypt-config/blob/master/LICENSE.txt
-[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
-[linkedin-url]: https://linkedin.com/in/linkedin_username
-[product-screenshot]: images/screenshot.png
diff --git a/README.md b/README.md
new file mode 120000
index 0000000..88c3776
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+encrypt-config/README.md
\ No newline at end of file
diff --git a/encrypt-config-derive/Cargo.toml b/encrypt-config-derive/Cargo.toml
index cf7ecf0..325bada 100644
--- a/encrypt-config-derive/Cargo.toml
+++ b/encrypt-config-derive/Cargo.toml
@@ -1,18 +1,23 @@
[package]
-name = "encrypt-config-derive"
-version = "0.0.1-alpha4"
-authors = ["Louis <836250617@qq.com>"]
-description = "A rust crate to manage, persist and encrypt your configurations."
-license = "MIT"
-edition = "2021"
-repository = "https://github.com/kingwingfly/encrypt-config"
+name = "encrypt_config_derive"
+version.workspace = true
+authors.workspace = true
+description.workspace = true
+license.workspace = true
+edition.workspace = true
+repository.workspace = true
[dependencies]
syn = { version = "2.0", features = ["full"] }
quote = "1.0"
+[dev-dependencies]
+serde = { version = "1" }
+encrypt_config = { workspace = true }
+
[lib]
proc-macro = true
[features]
-default_config_dir = []
+default = []
+default_config_dir = ["encrypt_config/default_config_dir"]
diff --git a/encrypt-config-derive/README.md b/encrypt-config-derive/README.md
new file mode 120000
index 0000000..88c3776
--- /dev/null
+++ b/encrypt-config-derive/README.md
@@ -0,0 +1 @@
+encrypt-config/README.md
\ No newline at end of file
diff --git a/encrypt-config-derive/src/lib.rs b/encrypt-config-derive/src/lib.rs
index 0a3a2b4..631a310 100644
--- a/encrypt-config-derive/src/lib.rs
+++ b/encrypt-config-derive/src/lib.rs
@@ -5,14 +5,18 @@ use syn::{parenthesized, parse_macro_input, DeriveInput, Expr, Ident, LitStr};
/// A derive macro helping implemente `Source` trait.
/// # Example
/// ```
-/// use encrypt_config::Source;
+/// # use encrypt_config_derive::Source;
+/// # use serde::{Serialize, Deserialize};
/// #[derive(Source)]
/// #[source(default([("key".to_owned(), "value".to_owned())]))]
/// struct SourceArray;
-/// assert_eq!(
-/// SourceArray.collect().unwrap(),
-/// HashMap::from([("key".to_owned(), "value".to_owned())])
-/// );
+///
+/// #[derive(Serialize, Deserialize, PartialEq, Debug)]
+/// struct Foo(String);
+///
+/// #[derive(Source)]
+/// #[source(value(Foo), default([("key".to_owned(), Foo("value".to_owned()))]))]
+/// struct SourceFoo;
/// ```
#[proc_macro_derive(Source, attributes(source))]
pub fn derive_normal_source(input: TokenStream) -> TokenStream {
@@ -87,13 +91,22 @@ pub fn derive_normal_source(input: TokenStream) -> TokenStream {
/// A derive macro helping implemente `PersistSource` trait.
/// # Example
/// ```
-/// use encrypt_config::PersistSource;
+/// # use encrypt_config_derive::PersistSource;
+/// # use serde::{Serialize, Deserialize};
/// #[derive(Serialize, Deserialize, PartialEq, Debug)]
/// struct Foo(String);
///
+/// // If feature `default_config_dir` is off:
+/// # #[cfg(not(feature = "default_config_dir"))]
/// #[derive(PersistSource)]
/// #[source(value(Foo), path("tests/persist.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
/// struct SourceFoo;
+///
+/// // If feature `default_config_dir` is on:
+/// # #[cfg(feature = "default_config_dir")]
+/// #[derive(PersistSource)]
+/// #[source(value(Foo), source_name("secret.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
+/// struct SourceFoo;
/// ```
#[proc_macro_derive(PersistSource, attributes(source))]
pub fn derive_persist_source(input: TokenStream) -> TokenStream {
@@ -185,13 +198,22 @@ pub fn derive_persist_source(input: TokenStream) -> TokenStream {
/// A derive macro helping implemente `SecretSource` trait.
/// # Example
/// ```
-/// use encrypt_config::SecretSource;
+/// # use encrypt_config_derive::SecretSource;
+/// # use serde::{Serialize, Deserialize};
/// #[derive(Serialize, Deserialize, PartialEq, Debug)]
/// struct Foo(String);
///
+/// // If feature `default_config_dir` is off:
+/// # #[cfg(not(feature = "default_config_dir"))]
/// #[derive(SecretSource)]
/// #[source(value(Foo), path("tests/secret.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
/// struct SourceFoo;
+///
+/// // If feature `default_config_dir` is on:
+/// # #[cfg(feature = "default_config_dir")]
+/// #[derive(SecretSource)]
+/// #[source(value(Foo), source_name("secret.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
+/// struct SourceFoo;
/// ```
#[proc_macro_derive(SecretSource, attributes(source))]
pub fn derive_secret_source(input: TokenStream) -> TokenStream {
diff --git a/encrypt-config/Cargo.toml b/encrypt-config/Cargo.toml
new file mode 100644
index 0000000..0744e90
--- /dev/null
+++ b/encrypt-config/Cargo.toml
@@ -0,0 +1,26 @@
+[package]
+name = "encrypt_config"
+version.workspace = true
+authors.workspace = true
+description.workspace = true
+license.workspace = true
+edition.workspace = true
+repository.workspace = true
+
+
+[dependencies]
+snafu = { version = "0.7.5" }
+serde = { version = "1", optional = true }
+serde_json = { version = "1", optional = true }
+rsa = { version = "0.9.6", features = ["serde"] }
+keyring = "2.1.0"
+dirs-next = { version = "2.0.0", optional = true }
+rand = "0.8.5"
+encrypt_config_derive = { workspace = true, optional = true }
+
+[features]
+default = ["serde"]
+serde = ["dep:serde", "dep:serde_json"]
+derive = ["encrypt_config_derive"]
+default_config_dir = ["dep:dirs-next", "encrypt_config_derive/default_config_dir"]
+protobuf = []
diff --git a/encrypt-config/README.md b/encrypt-config/README.md
new file mode 100644
index 0000000..0b039d8
--- /dev/null
+++ b/encrypt-config/README.md
@@ -0,0 +1,245 @@
+
+
+
+
+[![Contributors][contributors-shield]][contributors-url]
+[![Forks][forks-shield]][forks-url]
+[![Stargazers][stars-shield]][stars-url]
+[![Issues][issues-shield]][issues-url]
+[![MIT License][license-shield]][license-url]
+[![LinkedIn][linkedin-shield]][linkedin-url]
+
+
+
+
+
+
+
+
+
+
+
+ Table of Contents
+
+ -
+ About The Project
+
+
+ - Usage
+ - Roadmap
+ - Contributing
+ - License
+ - Contact
+ - Acknowledgments
+
+
+
+
+
+
+## About The Project
+
+Sometimes, we need to store config in our application that we don't want to expose to the public. For example, the database password, the api key, etc.
+
+One solution is to store them in the OS' secret manager, such as `Keychain` on macOS, `Credential Manager` on Windows, `libsecret` on Linux.
+
+However, they usually have limitation on the secret length. For example, `Keychain` only allows 255 bytes for the secret, `Credential Manager` is even shorter. So we can't store a long secret in it.
+
+Another solution is to store the secret in a file and encrypt it with a rsa public key, and store the private key in the OS' secret manager. This is what this crate does.
+
+In other cases, maybe our secret is not a `String`, but a config `struct`. We can also use this crate to manage it. When invoke `Config::get`, it will deserialize the config from the cache and return it.
+
+This crate provides 3 ways to manage your config:
+- `Source`: A normal source, not persisted or encrypted
+- `PersistSource`: A source that will be persisted to local file, not encrypted
+- `SecretSource`: A source that will be persisted to local file and encrypted
+
+This crate also has some optional features:
+- `default_config_dir`: If enabled, the default config dir will be used.
+- `protobuf`: If enabled, protobuf will be used instead of json for better performance. (Not implemented yet)
+
+(back to top)
+
+
+
+### Built With
+
+* Rust
+* Keyring
+
+(back to top)
+
+
+
+
+## Usage
+_(You may see many `#[cfg(feature = "...")]` in the example below, if you are not familar to Rust, you may not know this attribute is for `Conditinal Compile`, so that I can test it in `cargo test --all-features` automatically to ensure all go right.)_
+
+You can implement the `Source`, `PersistSource` and `SecretSource` yourself.
+```rust no_run
+use encrypt_config::{Config, SecretSource};
+use serde::{Deserialize, Serialize};
+
+#[derive(Serialize, Deserialize, PartialEq, Debug)]
+struct Foo(String);
+
+struct SecretSourceImpl;
+
+// impl `SecectSource` trait for `SecretSourceImpl`
+impl SecretSource for SecretSourceImpl {
+ type Value = Foo;
+
+ #[cfg(not(feature = "default_config_dir"))]
+ fn path(&self) -> std::path::PathBuf {
+ std::path::PathBuf::from("tests").join("secret.conf")
+ }
+
+ #[cfg(feature = "default_config_dir")]
+ fn source_name(&self) -> String {
+ "secret.conf".to_owned()
+ }
+}
+
+let mut config = Config::new("test"); // `test` is the name of rsa private key in OS' secret manager
+config.add_secret_source(SecretSourceImpl).unwrap(); // This will read and decrypt the config from local storage. However, it is empty now.
+
+let new_value = Foo("value".to_owned());
+let patch = SecretSourceImpl.upgrade("key", &new_value); // `upgrade` will return a `Patch`
+patch.apply(&mut config).unwrap(); // No change will happen until the `Patch` is applied
+let v: Foo = config.get("key").unwrap();
+assert_eq!(v, Foo("value".to_owned()));
+```
+
+You can also use the derive macros.
+
+```rust no_run
+// To derive [`Source`]
+# #[cfg(feature = "derive")]
+# {
+use encrypt_config::{PersistSource, SecretSource, Source};
+use serde::{Deserialize, Serialize};
+
+#[derive(Serialize, Deserialize, PartialEq, Debug)]
+struct Foo(String);
+
+#[derive(Source)]
+#[source(value(Foo), default([("key".to_owned(), Foo("value".to_owned()))]))]
+struct SourceFoo;
+
+//To derive [`PersistSource`]
+#[cfg(not(feature = "default_config_dir"))]
+#[derive(PersistSource)]
+#[source(value(Foo), path("tests/persist.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
+struct PersistSourceFoo;
+
+// To derive [`SecretSource`]
+#[cfg(not(feature = "default_config_dir"))]
+#[derive(SecretSource)]
+#[source(value(Foo), path("tests/secret.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
+struct SecretSourceFoo;
+# }
+```
+
+_For more examples, please refer to the [Example](examples) or [Documentation](https://docs.rs/encrypt_config)_
+
+(back to top)
+
+
+
+
+## Roadmap
+
+- [ ] Enable protobuf instead of json for better performance
+
+See the [open issues](https://github.com/kingwingfly/encrypt-config/issues) for a full list of proposed features (and known issues).
+
+(back to top)
+
+
+
+
+## Contributing
+
+Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
+
+If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
+Don't forget to give the project a star! Thanks again!
+
+1. Fork the Project
+2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
+3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
+4. Push to the Branch (`git push origin feature/AmazingFeature`)
+5. Open a Pull Request
+
+(back to top)
+
+
+
+
+## License
+
+Distributed under the MIT License. See `LICENSE.txt` for more information.
+
+(back to top)
+
+
+
+
+## Contact
+
+Louis - 836250617@qq.com
+
+Project Link: [https://github.com/kingwingfly/encrypt-config](https://github.com/kingwingfly/encrypt-config)
+
+(back to top)
+
+
+
+
+## Acknowledgments
+
+* None
+* []()
+
+(back to top)
+
+
+
+
+
+[contributors-shield]: https://img.shields.io/github/contributors/kingwingfly/encrypt-config.svg?style=for-the-badge
+[contributors-url]: https://github.com/kingwingfly/encrypt-config/graphs/contributors
+[forks-shield]: https://img.shields.io/github/forks/kingwingfly/encrypt-config.svg?style=for-the-badge
+[forks-url]: https://github.com/kingwingfly/encrypt-config/network/members
+[stars-shield]: https://img.shields.io/github/stars/kingwingfly/encrypt-config.svg?style=for-the-badge
+[stars-url]: https://github.com/kingwingfly/encrypt-config/stargazers
+[issues-shield]: https://img.shields.io/github/issues/kingwingfly/encrypt-config.svg?style=for-the-badge
+[issues-url]: https://github.com/kingwingfly/encrypt-config/issues
+[license-shield]: https://img.shields.io/github/license/kingwingfly/encrypt-config.svg?style=for-the-badge
+[license-url]: https://github.com/kingwingfly/encrypt-config/blob/master/LICENSE.txt
+[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
+[linkedin-url]: https://linkedin.com/in/linkedin_username
+[product-screenshot]: images/screenshot.png
diff --git a/src/config.rs b/encrypt-config/src/config.rs
similarity index 100%
rename from src/config.rs
rename to encrypt-config/src/config.rs
diff --git a/src/encrypt_utils.rs b/encrypt-config/src/encrypt_utils.rs
similarity index 100%
rename from src/encrypt_utils.rs
rename to encrypt-config/src/encrypt_utils.rs
diff --git a/src/error.rs b/encrypt-config/src/error.rs
similarity index 100%
rename from src/error.rs
rename to encrypt-config/src/error.rs
diff --git a/src/lib.rs b/encrypt-config/src/lib.rs
similarity index 95%
rename from src/lib.rs
rename to encrypt-config/src/lib.rs
index a2ecd79..0763554 100644
--- a/src/lib.rs
+++ b/encrypt-config/src/lib.rs
@@ -6,10 +6,12 @@ mod error;
mod source;
pub use config::{Config, ConfigPatch, SecretConfigPatch};
-pub use encrypt_config_derive::*;
pub use error::*;
pub use source::{PersistSource, SecretSource, Source};
+#[cfg(feature = "derive")]
+pub use encrypt_config_derive::*;
+
#[cfg(test)]
mod tests {
use std::collections::HashMap;
@@ -38,7 +40,7 @@ mod tests {
#[cfg(not(feature = "default_config_dir"))]
fn path(&self) -> std::path::PathBuf {
- std::path::PathBuf::from("tests").join("persist.conf")
+ std::path::PathBuf::from("../tests").join("persist.conf")
}
#[cfg(feature = "default_config_dir")]
@@ -53,7 +55,7 @@ mod tests {
#[cfg(not(feature = "default_config_dir"))]
fn path(&self) -> std::path::PathBuf {
- std::path::PathBuf::from("tests").join("secret.conf")
+ std::path::PathBuf::from("../tests").join("secret.conf")
}
#[cfg(feature = "default_config_dir")]
diff --git a/src/source.rs b/encrypt-config/src/source.rs
similarity index 100%
rename from src/source.rs
rename to encrypt-config/src/source.rs
diff --git a/tests/Cargo.toml b/tests/Cargo.toml
new file mode 100644
index 0000000..8ede5fa
--- /dev/null
+++ b/tests/Cargo.toml
@@ -0,0 +1,18 @@
+[package]
+name = "tests"
+version.workspace = true
+edition = "2021"
+publish = false
+
+[dependencies]
+encrypt_config = { workspace = true, features = ["derive"] }
+
+[dev-dependencies]
+serde = "1"
+
+[[test]]
+name = "derive-test"
+path = "derive-test.rs"
+
+[features]
+default_config_dir = ["encrypt_config/default_config_dir"]
diff --git a/tests/derive.rs b/tests/derive-test.rs
similarity index 100%
rename from tests/derive.rs
rename to tests/derive-test.rs