Skip to content

Commit 9fe4296

Browse files
committed
refactor: remove cargo workspaces
1 parent 686157f commit 9fe4296

File tree

22 files changed

+77
-202
lines changed

22 files changed

+77
-202
lines changed

Cargo.toml

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,46 @@ description = """
1111
code input cli.
1212
"""
1313

14-
[workspace]
15-
members = ["utils", "cli", "core"]
16-
1714
[features]
18-
nightly = ["utils/nightly"]
19-
termlog = ["utils/termlog"]
20-
journald = ["utils/journald"]
21-
syslog = ["utils/syslog"]
15+
nightly = []
16+
termlog = ["slog-term"]
17+
journald = ["slog-journald"]
18+
syslog = ["slog-syslog"]
2219

2320
[dependencies]
24-
utils = { path = "utils", version = "0.0.1-beta" }
25-
cli = { path = "cli" , version = "0.0.1-beta"}
26-
core = { path = "core" , version = "0.0.1-beta"}
2721
human-panic = "2.0.0"
2822
better-panic = "0.3.0"
2923
log = "0.4.27"
24+
clap_complete = "4.5.50"
25+
rand = "0.9.1"
26+
ignore = "0.4.23"
27+
serde = { version = "1.0.219", features = ["derive"] }
28+
serde_json = "1.0.140"
29+
bincode = {version= "2.0.1", features = ["serde"] }
30+
git2 = { version = "0.20.2" }
31+
sha2 = { version = "0.10.9" }
32+
thiserror = "2.0.12"
33+
backtrace = "0.3.75"
34+
color-backtrace = "0.7.0"
35+
config = "0.15.11"
36+
lazy_static = "1.5.0"
37+
slog = "2.7.0"
38+
slog-syslog = { version="0.13.0", optional = true }
39+
slog-term = {version = "2.9.1", optional = true }
40+
slog-scope = "4.4.0"
41+
slog-async = "2.8.0"
42+
slog-stdlog = "4.1.1"
43+
[target.'cfg(target_os = "linux")'.dependencies]
44+
slog-journald = {version = "2.2.0", optional = true }
45+
46+
[dependencies.clap]
47+
version = "4.5.38"
48+
features = ["cargo", "derive"]
3049

3150
[dev-dependencies]
3251
assert_cmd = "2.0.17"
3352
predicates = "3.1.3"
53+
tempfile = "3.20"
3454

3555
[profile.dev]
3656
opt-level = 0

cli/Cargo.toml

Lines changed: 0 additions & 20 deletions
This file was deleted.

core/Cargo.toml

Lines changed: 0 additions & 22 deletions
This file was deleted.

core/benches/01_default.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

cli/src/lib.rs renamed to src/cli/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use clap_complete::{
55
};
66
use std::path::PathBuf;
77

8-
use core::{
8+
use crate::core::{
99
commands,
1010
types::{CacheEncoding, OutputFormat},
1111
};
12-
use utils::app_config::AppConfig;
13-
use utils::error::Result;
14-
use utils::types::LogLevel;
12+
use crate::utils::app_config::AppConfig;
13+
use crate::utils::error::Result;
14+
use crate::utils::types::LogLevel;
1515

1616
#[derive(Parser, Debug)]
1717
#[command(
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::io::{Read, Write};
22
use std::path::{Path, PathBuf};
33

4-
use crate::common::{
4+
use super::common::{
55
collect_owners, collect_tags, find_owners_for_file, find_tags_for_file, get_repo_hash,
66
};
7-
use crate::parse::parse_repo;
8-
use crate::types::{CacheEncoding, CodeownersCache, CodeownersEntry, FileEntry};
9-
use utils::error::{Error, Result};
7+
use super::parse::parse_repo;
8+
use super::types::{CacheEncoding, CodeownersCache, CodeownersEntry, FileEntry};
9+
use crate::utils::error::{Error, Result};
1010

1111
/// Create a cache from parsed CODEOWNERS entries and files
1212
pub fn build_cache(
@@ -135,7 +135,9 @@ pub fn load_cache(path: &Path) -> Result<CodeownersCache> {
135135
pub fn sync_cache(
136136
repo: &std::path::Path, cache_file: Option<&std::path::Path>,
137137
) -> Result<CodeownersCache> {
138-
let config_cache_file = utils::app_config::AppConfig::fetch()?.cache_file.clone();
138+
let config_cache_file = crate::utils::app_config::AppConfig::fetch()?
139+
.cache_file
140+
.clone();
139141

140142
let cache_file: &std::path::Path = match cache_file {
141143
Some(file) => file.into(),
@@ -150,7 +152,7 @@ pub fn sync_cache(
150152

151153
// Load the cache from the specified file
152154
let cache = load_cache(&repo.join(cache_file)).map_err(|e| {
153-
utils::error::Error::new(&format!(
155+
crate::utils::error::Error::new(&format!(
154156
"Failed to load cache from {}: {}",
155157
cache_file.display(),
156158
e
Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::io::{self, Write};
22

3-
use crate::cache::{build_cache, load_cache, store_cache, sync_cache};
4-
use crate::common::{find_files, get_repo_hash};
5-
use crate::types::{CacheEncoding, CodeownersEntry, OutputFormat};
3+
use super::cache::{build_cache, load_cache, store_cache, sync_cache};
4+
use super::common::{find_files, get_repo_hash};
5+
use super::types::{CacheEncoding, CodeownersEntry, OutputFormat};
66

7-
use utils::app_config::AppConfig;
8-
use utils::error::Result;
7+
use crate::utils::app_config::AppConfig;
8+
use crate::utils::error::{Error, Result};
99

1010
/// Show the configuration file
1111
pub fn config() -> Result<()> {
@@ -24,19 +24,19 @@ pub fn codeowners_parse(
2424
let cache_file = match cache_file {
2525
Some(file) => path.join(file),
2626
None => {
27-
let config = utils::app_config::AppConfig::fetch()?;
27+
let config = AppConfig::fetch()?;
2828
path.join(config.cache_file)
2929
}
3030
};
3131

3232
// Collect all CODEOWNERS files in the specified path
33-
let codeowners_files = crate::common::find_codeowners_files(path)?;
33+
let codeowners_files = super::common::find_codeowners_files(path)?;
3434

3535
// Parse each CODEOWNERS file and collect entries
3636
let parsed_codeowners: Vec<CodeownersEntry> = codeowners_files
3737
.iter()
3838
.filter_map(|file| {
39-
let parsed = crate::common::parse_codeowners(file).ok()?;
39+
let parsed = super::common::parse_codeowners(file).ok()?;
4040
Some(parsed)
4141
})
4242
.flatten()
@@ -220,14 +220,12 @@ pub fn codeowners_list_files(
220220
OutputFormat::Bincode => {
221221
let encoded =
222222
bincode::serde::encode_to_vec(&filtered_files, bincode::config::standard())
223-
.map_err(|e| {
224-
utils::error::Error::new(&format!("Serialization error: {}", e))
225-
})?;
223+
.map_err(|e| Error::new(&format!("Serialization error: {}", e)))?;
226224

227225
// Write raw binary bytes to stdout
228226
io::stdout()
229227
.write_all(&encoded)
230-
.map_err(|e| utils::error::Error::new(&format!("IO error: {}", e)))?;
228+
.map_err(|e| Error::new(&format!("IO error: {}", e)))?;
231229
}
232230
}
233231

@@ -347,14 +345,12 @@ pub fn codeowners_list_owners(
347345
OutputFormat::Bincode => {
348346
let encoded =
349347
bincode::serde::encode_to_vec(&cache.owners_map, bincode::config::standard())
350-
.map_err(|e| {
351-
utils::error::Error::new(&format!("Serialization error: {}", e))
352-
})?;
348+
.map_err(|e| Error::new(&format!("Serialization error: {}", e)))?;
353349

354350
// Write raw binary bytes to stdout
355351
io::stdout()
356352
.write_all(&encoded)
357-
.map_err(|e| utils::error::Error::new(&format!("IO error: {}", e)))?;
353+
.map_err(|e| Error::new(&format!("IO error: {}", e)))?;
358354
}
359355
}
360356

@@ -477,14 +473,12 @@ pub fn codeowners_list_tags(
477473
OutputFormat::Bincode => {
478474
let encoded =
479475
bincode::serde::encode_to_vec(&cache.tags_map, bincode::config::standard())
480-
.map_err(|e| {
481-
utils::error::Error::new(&format!("Serialization error: {}", e))
482-
})?;
476+
.map_err(|e| Error::new(&format!("Serialization error: {}", e)))?;
483477

484478
// Write raw binary bytes to stdout
485479
io::stdout()
486480
.write_all(&encoded)
487-
.map_err(|e| utils::error::Error::new(&format!("IO error: {}", e)))?;
481+
.map_err(|e| Error::new(&format!("IO error: {}", e)))?;
488482
}
489483
}
490484

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
use crate::utils::error::{Error, Result};
12
use git2::{DiffFormat, DiffOptions, Repository};
23
use ignore::{
34
Walk,
45
overrides::{Override, OverrideBuilder},
56
};
67
use sha2::{Digest, Sha256};
78
use std::path::{Path, PathBuf};
8-
use utils::error::{Error, Result};
99

10-
use crate::types::{CodeownersEntry, FileEntry, Owner, OwnerType, Tag};
10+
use super::types::{CodeownersEntry, FileEntry, Owner, OwnerType, Tag};
1111

1212
/// Find CODEOWNERS files recursively in the given directory and its subdirectories
1313
pub fn find_codeowners_files<P: AsRef<Path>>(base_path: P) -> Result<Vec<PathBuf>> {

core/src/lib.rs renamed to src/core/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
#[macro_use]
2-
extern crate log;
3-
41
pub mod cache;
52
pub mod commands;
63
pub mod common;
74
pub mod parse;
85
pub mod types;
96

10-
use utils::error::Result;
7+
use crate::utils::error::Result;
118

129
pub fn start() -> Result<()> {
1310
// does nothing
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use utils::error::Result;
1+
use crate::utils::error::Result;
22

3-
use crate::{
3+
use super::{
44
cache::{build_cache, store_cache},
55
common::{find_codeowners_files, find_files, get_repo_hash, parse_codeowners},
66
types::{CacheEncoding, CodeownersCache, CodeownersEntry},

0 commit comments

Comments
 (0)