Skip to content

Commit c2b9049

Browse files
committed
feat: v0.1.5
1 parent 5b62380 commit c2b9049

File tree

11 files changed

+438
-5
lines changed

11 files changed

+438
-5
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hyperlane-cli"
3-
version = "0.1.3"
3+
version = "0.1.5"
44
readme = "README.md"
55
edition = "2024"
66
authors = ["root@ltpp.vip"]
@@ -12,7 +12,8 @@ categories = ["command-line-interface", "development-tools", "visualization"]
1212
exclude = ["target", "Cargo.lock", "sh", ".github"]
1313

1414
[dependencies]
15-
tokio = { version = "1", features = ["process", "rt-multi-thread", "macros"] }
15+
toml = "0.9.8"
16+
tokio = { version = "1.49.0", features = ["full"] }
1617

1718
[profile.dev]
1819
incremental = false

src/command/enum.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ pub(crate) enum CommandType {
77
Watch,
88
/// Bump version in Cargo.toml
99
Bump,
10+
/// Publish packages in monorepo
11+
Publish,
1012
/// Show help
1113
Help,
1214
/// Show version

src/config/fn.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub(crate) fn parse_args() -> Args {
1111
let mut check: bool = false;
1212
let mut manifest_path: Option<String> = None;
1313
let mut bump_type: Option<BumpVersionType> = None;
14+
let mut max_retries: u32 = 3;
1415
let mut i: usize = 1;
1516
while i < raw_args.len() {
1617
let arg: &str = raw_args[i].as_str();
@@ -36,6 +37,11 @@ pub(crate) fn parse_args() -> Args {
3637
command = CommandType::Bump;
3738
}
3839
}
40+
"publish" => {
41+
if command == CommandType::Help || command == CommandType::Version {
42+
command = CommandType::Publish;
43+
}
44+
}
3945
"--patch" => {
4046
bump_type = Some(BumpVersionType::Patch);
4147
}
@@ -66,6 +72,14 @@ pub(crate) fn parse_args() -> Args {
6672
manifest_path = Some(raw_args[i].clone());
6773
}
6874
}
75+
"--max-retries" => {
76+
i += 1;
77+
if i < raw_args.len() {
78+
if let Ok(n) = raw_args[i].parse::<u32>() {
79+
max_retries = n;
80+
}
81+
}
82+
}
6983
_ => {}
7084
}
7185
i += 1;
@@ -75,5 +89,6 @@ pub(crate) fn parse_args() -> Args {
7589
check,
7690
manifest_path,
7791
bump_type,
92+
max_retries,
7893
}
7994
}

src/config/struct.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ pub struct Args {
77
pub command: CommandType,
88
/// Check mode for fmt
99
pub check: bool,
10-
/// Manifest path for fmt and bump
10+
/// Manifest path for fmt, bump and publish
1111
pub manifest_path: Option<String>,
1212
/// Bump type for bump command
1313
pub bump_type: Option<BumpVersionType>,
14+
/// Maximum retry attempts for publish command
15+
pub max_retries: u32,
1416
}

src/help/fn.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub(crate) fn print_help() {
66
println!(" bump Bump version in Cargo.toml");
77
println!(" fmt Format Rust code using cargo fmt");
88
println!(" watch Watch files and run cargo run using cargo-watch");
9+
println!(" publish Publish packages in monorepo with topological ordering");
910
println!(" -h, --help Print this help message");
1011
println!(" -v, --version Print version information");
1112
println!();
@@ -28,4 +29,8 @@ pub(crate) fn print_help() {
2829
println!("Fmt Options:");
2930
println!(" --check Check formatting without making changes");
3031
println!(" --manifest-path <PATH> Path to Cargo.toml");
32+
println!();
33+
println!("Publish Options:");
34+
println!(" --manifest-path <PATH> Path to workspace Cargo.toml [default: Cargo.toml]");
35+
println!(" --max-retries <N> Maximum retry attempts per package [default: 3]");
3136
}

src/main.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ mod command;
77
mod config;
88
mod fmt;
99
mod help;
10+
mod publish;
1011
mod version;
1112
mod watch;
1213

13-
pub(crate) use {bump::*, command::*, config::*, fmt::*, help::*, version::*, watch::*};
14+
pub(crate) use {
15+
bump::*, command::*, config::*, fmt::*, help::*, publish::*, version::*, watch::*,
16+
};
1417

1518
pub(crate) use std::{
19+
collections::{HashMap, VecDeque},
1620
env::args,
1721
fs::{read_to_string, write},
18-
path::Path,
22+
path::{Path, PathBuf},
1923
process::{ExitStatus, Stdio, exit},
2024
};
2125

@@ -52,6 +56,30 @@ async fn main() {
5256
}
5357
}
5458
}
59+
CommandType::Publish => {
60+
let manifest_path: String = args
61+
.manifest_path
62+
.unwrap_or_else(|| "Cargo.toml".to_string());
63+
let max_retries: u32 = args.max_retries;
64+
match execute_publish(&manifest_path, max_retries).await {
65+
Ok(results) => {
66+
let failed_count: usize = results
67+
.iter()
68+
.filter(|r: &&PublishResult| !r.success)
69+
.count();
70+
if failed_count > 0 {
71+
eprintln!("Publish completed with {failed_count} failures");
72+
exit(1);
73+
} else {
74+
println!("All packages published successfully");
75+
}
76+
}
77+
Err(error) => {
78+
eprintln!("publish failed: {error}");
79+
exit(1);
80+
}
81+
}
82+
}
5583
CommandType::Help => print_help(),
5684
CommandType::Version => print_version(),
5785
}

src/publish/enum.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// Error types for publish operation
2+
#[derive(Clone, Debug, Eq, PartialEq)]
3+
pub(crate) enum PublishError {
4+
/// Failed to parse Cargo.toml
5+
ManifestParseError,
6+
/// Circular dependency detected
7+
CircularDependency,
8+
/// IO error
9+
IoError,
10+
}

0 commit comments

Comments
 (0)