Skip to content

Commit

Permalink
refacto: extract the core crate from the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics committed Apr 26, 2024
1 parent 7f3fe89 commit b61c765
Show file tree
Hide file tree
Showing 44 changed files with 95 additions and 94 deletions.
68 changes: 25 additions & 43 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ version = "0.8.0"
resolver = "2"
members = [
"crates/buffrs",
"crates/buffrs-core",
]

[workspace.dependencies]
# Our own
buffrs = { version = "0.8.0", path = "crates/buffrs/" }
buffrs-core = { version = "0.8.0", path = "crates/buffrs-core/" }

# Main deps
anyhow = "1.0"
Expand Down
51 changes: 51 additions & 0 deletions crates/buffrs-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[package]
name = "buffrs-core"
documentation = "https://docs.rs/buffrs-core"
categories = ["command-line-utilities"]

authors.workspace = true
description.workspace = true
edition.workspace = true
exclude.workspace = true
keywords.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
version.workspace = true

[features]
default = ["git", "validation"]
validation = ["dep:anyhow", "dep:protobuf", "dep:protobuf-parse", "dep:diff-struct"]
git = []

[dependencies]
async-recursion.workspace = true
bytes.workspace = true
flate2.workspace = true
hex.workspace = true
home.workspace = true
miette.workspace = true
reqwest.workspace = true
semver.workspace = true
serde.workspace = true
serde_json.workspace = true
tar.workspace = true
thiserror.workspace = true
tokio.workspace = true
toml.workspace = true
tracing.workspace = true
url.workspace = true
walkdir.workspace = true
sha2.workspace = true
strum.workspace = true

anyhow = { workspace = true, optional = true }
diff-struct = { workspace = true, optional = true }
protobuf = { workspace = true, optional = true }
protobuf-parse = { workspace = true, optional = true }

[dev-dependencies]
paste.workspace = true
serde_test.workspace = true
similar-asserts.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread"] }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn can_display_digest_algorithm() {
/// A representation of a cryptographic digest for data integrity validation
///
/// ```rust
/// use buffrs::lock::{Digest, DigestAlgorithm};
/// use buffrs_core::lock::{Digest, DigestAlgorithm};
///
/// let algorithm = DigestAlgorithm::SHA256;
/// let hello = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ mod tests {
let mut parser = super::Parser::new(Path::new("tests/data/parsing"));
parser.input(std::path::Path::new(concat!("tests/data/parsing/", stringify!($name), ".proto")));
let packages = parser.parse().unwrap();
let expected = include_str!(concat!("../tests/data/parsing/", stringify!($name), ".json"));
let expected = include_str!(concat!("../../tests/data/parsing/", stringify!($name), ".json"));
let expected = serde_json::from_str(&expected).unwrap();
similar_asserts::assert_eq!(packages, expected);
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 5 additions & 39 deletions crates/buffrs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,30 @@ readme.workspace = true
repository.workspace = true
version.workspace = true

[[bin]]
name = "buffrs"
path = "src/main.rs"
required-features = ["git", "validation"]

[[test]]
name = "e2e"
path = "tests/lib.rs"
test = true

[features]
default = ["git", "validation"]
validation = ["dep:anyhow", "dep:protobuf", "dep:protobuf-parse", "dep:diff-struct"]
git = []


[dependencies]
async-recursion.workspace = true
bytes.workspace = true
buffrs-core = { workspace = true, features = ["git", "validation"] }

clap.workspace = true
flate2.workspace = true
hex.workspace = true
home.workspace = true
human-panic.workspace = true
miette.workspace = true
reqwest.workspace = true
semver.workspace = true
serde.workspace = true
serde_json.workspace = true
tar.workspace = true
thiserror.workspace = true
tokio.workspace = true
toml.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
url.workspace = true
walkdir.workspace = true
sha2.workspace = true
strum.workspace = true

anyhow = { workspace = true, optional = true }
diff-struct = { workspace = true, optional = true }
protobuf = { workspace = true, optional = true }
protobuf-parse = { workspace = true, optional = true }

[dev-dependencies]
assert_cmd.workspace = true
assert_fs.workspace = true
axum.workspace = true
bytes.workspace = true
fs_extra.workspace = true
hex.workspace = true
paste.workspace = true
predicates.workspace = true
pretty_assertions.workspace = true
serde_json.workspace = true
serde_test.workspace = true
similar-asserts.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread"] }
reqwest.workspace = true
tracing.workspace = true

[package.metadata.deb]
section = "utils"
Expand Down
10 changes: 5 additions & 5 deletions crates/buffrs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use buffrs::command;
use buffrs::manifest::Manifest;
use buffrs::package::{PackageName, PackageStore};
use buffrs::registry::RegistryUri;
use buffrs::{manifest::MANIFEST_FILE, package::PackageType};
use buffrs_core::command;
use buffrs_core::manifest::Manifest;
use buffrs_core::package::{PackageName, PackageStore};
use buffrs_core::registry::RegistryUri;
use buffrs_core::{manifest::MANIFEST_FILE, package::PackageType};
use clap::{Parser, Subcommand};
use miette::{miette, WrapErr};
use semver::Version;
Expand Down
2 changes: 1 addition & 1 deletion crates/buffrs/tests/cmd/tuto/in/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::Path;

use buffrs::package::PackageStore;
use buffrs_core::package::PackageStore;

#[tokio::main]
async fn main() {
Expand Down
6 changes: 3 additions & 3 deletions crates/buffrs/tests/cmd/tuto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ fn fixture() {
)
.unwrap();

let buffrs_path = env!("CARGO_MANIFEST_DIR");
let buffrs_path = concat!(env!("CARGO_MANIFEST_DIR"), "/../buffrs-core");
dbg!(buffrs_path);

// cargo add buffrs --no-default-features
assert!(Command::new("cargo")
.args([
"add",
"buffrs",
"buffrs-core",
"--no-default-features",
"--path",
buffrs_path
Expand All @@ -153,7 +153,7 @@ fn fixture() {
assert!(Command::new("cargo")
.args([
"add",
"buffrs",
"buffrs-core",
"--build",
"--no-default-features",
"--path",
Expand Down
2 changes: 1 addition & 1 deletion crates/buffrs/tests/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use buffrs::package::Package;
use buffrs_core::package::Package;

use std::{
fs,
Expand Down

0 comments on commit b61c765

Please sign in to comment.