@@ -10,3 +10,5 @@ tracing.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
clap.workspace = true
|
||||
dotenv.workspace = true
|
||||
serde_yaml = "0.9.25"
|
||||
serde = { version = "1.0.177", features = ["derive"] }
|
||||
|
@@ -1,19 +1,8 @@
|
||||
use std::net::SocketAddr;
|
||||
use std::{net::SocketAddr, path::PathBuf};
|
||||
|
||||
use anyhow::Context;
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None, subcommand_required = true)]
|
||||
struct Command {
|
||||
#[command(subcommand)]
|
||||
command: Option<Commands>,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
Init
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
dotenv::dotenv().ok();
|
||||
@@ -21,11 +10,69 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
let cli = Command::parse();
|
||||
|
||||
match cli.command.unwrap() {
|
||||
Commands::Init => {
|
||||
tracing::info!("hello cuddle-release");
|
||||
}
|
||||
}
|
||||
// 1. Parse the current directory
|
||||
let current_dir = get_current_path(cli.source.clone())?;
|
||||
let get_config = get_config(¤t_dir)?;
|
||||
|
||||
// 2. Parse the cuddle.please.yaml let cuddle.please.yaml take precedence
|
||||
// 2a. if not existing use default.
|
||||
// 2b. if not in a git repo abort. (unless --no-vcs is turned added)
|
||||
|
||||
// 3. Create gitea client and do a health check
|
||||
// 4. Fetch git tags for the current repository
|
||||
// 5. Fetch git commits since last git tag
|
||||
|
||||
// 6. Slice commits since last git tag
|
||||
|
||||
// 7. Create a versioning client
|
||||
// 8. Parse conventional commits and determine next version
|
||||
|
||||
// 9a. Check for open pr.
|
||||
// 10a. If exists parse history, rebase from master and rewrite pr
|
||||
|
||||
// 9b. check for release commit and release, if release exists continue
|
||||
// 10b. create release
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Command {
|
||||
/// token is the personal access token from gitea.
|
||||
#[arg(
|
||||
env = "CUDDLE_PLEASE_TOKEN",
|
||||
long,
|
||||
long_help = "token is the personal access token from gitea. It requires at least repository write access, it isn't required by default, but for most usecases the flow will fail without it"
|
||||
)]
|
||||
token: Option<String>,
|
||||
|
||||
/// Which repository to publish against. If not supplied remote url will be used.
|
||||
#[arg(long)]
|
||||
repo_url: Option<String>,
|
||||
|
||||
/// which source directory to use, if not set `std::env::current_dir` is used instead.
|
||||
#[arg(long)]
|
||||
source: Option<PathBuf>,
|
||||
}
|
||||
|
||||
fn get_current_path(optional_source_path: Option<PathBuf>) -> anyhow::Result<PathBuf> {
|
||||
let path = optional_source_path
|
||||
.or_else(|| std::env::current_dir().ok()) // fall back on current env from environment
|
||||
.filter(|v| v.to_string_lossy() != "") // make sure we don't get empty values
|
||||
.and_then(|p| p.canonicalize().ok()) // Make sure we get the absolute path
|
||||
.context("could not find current dir, pass --source as a replacement")?;
|
||||
|
||||
if !path.exists() {
|
||||
anyhow::bail!("path doesn't exist {}", path.display());
|
||||
}
|
||||
|
||||
Ok(path)
|
||||
}
|
||||
struct PleaseConfig {}
|
||||
|
||||
const CUDDLE_FILE_NAME: &'static str = "cuddle";
|
||||
const CUDDLE_CONFIG_FILE_NAME: &'static str = "cuddle.please";
|
||||
const YAML_EXTENSIONS: Vec<&'static str> = vec!["yaml", "yml"];
|
||||
|
||||
fn get_config(current_dir: &PathBuf) -> anyhow::Result<()> {}
|
||||
|
Reference in New Issue
Block a user