From e8cce2fca50c6a559825ed15abb6666549ddf356 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Fri, 5 Feb 2021 01:37:25 +0300 Subject: [PATCH] chore: merge cli with core --- Cargo.toml | 1 - migra-cli/Cargo.toml | 2 +- migra-cli/src/config.rs | 2 +- {migra-core => migra-cli}/src/database.rs | 0 migra-cli/src/main.rs | 8 +++++--- {migra-core => migra-cli}/src/path.rs | 6 ------ migra-core/Cargo.toml | 8 -------- migra-core/src/lib.rs | 4 ---- 8 files changed, 7 insertions(+), 24 deletions(-) rename {migra-core => migra-cli}/src/database.rs (100%) rename {migra-core => migra-cli}/src/path.rs (93%) delete mode 100644 migra-core/Cargo.toml delete mode 100644 migra-core/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 0878c07..dfca278 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,4 @@ [workspace] members = [ - "migra-core", "migra-cli" ] \ No newline at end of file diff --git a/migra-cli/Cargo.toml b/migra-cli/Cargo.toml index fdd1de5..6b62b9e 100644 --- a/migra-cli/Cargo.toml +++ b/migra-cli/Cargo.toml @@ -10,8 +10,8 @@ name = "migra" path = "src/main.rs" [dependencies] -migra-core = { path = '../migra-core' } structopt = "0.3" serde = { version = "1.0", features = ["derive"] } toml = "0.5" chrono = "0.4.19" +postgres = "0.19.0" diff --git a/migra-cli/src/config.rs b/migra-cli/src/config.rs index 01a09b1..d87afb1 100644 --- a/migra-cli/src/config.rs +++ b/migra-cli/src/config.rs @@ -1,4 +1,4 @@ -use migra_core::path::PathBuilder; +use crate::path::PathBuilder; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; use std::{fs, io}; diff --git a/migra-core/src/database.rs b/migra-cli/src/database.rs similarity index 100% rename from migra-core/src/database.rs rename to migra-cli/src/database.rs diff --git a/migra-cli/src/main.rs b/migra-cli/src/main.rs index acfe7db..3782944 100644 --- a/migra-cli/src/main.rs +++ b/migra-cli/src/main.rs @@ -1,12 +1,14 @@ #![deny(clippy::all)] mod config; +mod database; mod opts; +mod path; use chrono::Local; use config::Config; -use migra_core::path::PathBuilder; use opts::{AppOpt, ApplyCommandOpt, Command, MakeCommandOpt, StructOpt}; +use path::PathBuilder; use std::fs; fn main() -> Result<(), Box> { @@ -19,7 +21,7 @@ fn main() -> Result<(), Box> { Command::Apply(ApplyCommandOpt { file_name }) => { let config = Config::read(opt.config)?; - let mut client = migra_core::database::connect(&config.database.connection)?; + let mut client = database::connect(&config.database.connection)?; let file_path = PathBuilder::from(config.directory_path()) .append(file_name) @@ -28,7 +30,7 @@ fn main() -> Result<(), Box> { let content = fs::read_to_string(file_path)?; - match migra_core::database::apply_sql(&mut client, &content) { + match database::apply_sql(&mut client, &content) { Ok(_) => { println!("File was applied successfully") } diff --git a/migra-core/src/path.rs b/migra-cli/src/path.rs similarity index 93% rename from migra-core/src/path.rs rename to migra-cli/src/path.rs index f05be98..c15e0c8 100644 --- a/migra-core/src/path.rs +++ b/migra-cli/src/path.rs @@ -15,12 +15,6 @@ impl> From

for PathBuilder { } impl PathBuilder { - pub fn new>() -> Self { - PathBuilder { - buf: PathBuf::new(), - } - } - pub fn append>(&mut self, path: P) -> &mut Self { self.buf.push(path); self diff --git a/migra-core/Cargo.toml b/migra-core/Cargo.toml deleted file mode 100644 index 465e9f8..0000000 --- a/migra-core/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "migra-core" -version = "0.1.0" -authors = ["Dmitriy Pleshevskiy "] -edition = "2018" - -[dependencies] -postgres = "0.19.0" diff --git a/migra-core/src/lib.rs b/migra-core/src/lib.rs deleted file mode 100644 index 99766a7..0000000 --- a/migra-core/src/lib.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![deny(clippy::all)] - -pub mod database; -pub mod path;