From 94f91784a004c02c4f6cf44f04d5cae6939682de Mon Sep 17 00:00:00 2001 From: Rheydskey Date: Wed, 17 Aug 2022 19:00:05 +0200 Subject: [PATCH 1/3] Add cli feature on sea-orm-migration --- sea-orm-cli/Cargo.toml | 53 +++++++++++++++++++++++--------- sea-orm-migration/Cargo.toml | 28 +++++++++-------- sea-orm-migration/src/lib.rs | 1 + sea-orm-migration/src/prelude.rs | 2 ++ 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/sea-orm-cli/Cargo.toml b/sea-orm-cli/Cargo.toml index 45633a4d0..013f01645 100644 --- a/sea-orm-cli/Cargo.toml +++ b/sea-orm-cli/Cargo.toml @@ -4,13 +4,13 @@ [package] name = "sea-orm-cli" version = "0.9.1" -authors = [ "Billy Chan " ] +authors = ["Billy Chan "] edition = "2021" description = "Command line utility for SeaORM" license = "MIT OR Apache-2.0" documentation = "https://docs.rs/sea-orm" repository = "https://github.com/SeaQL/sea-orm" -categories = [ "database" ] +categories = ["database"] keywords = ["async", "orm", "mysql", "postgres", "sqlite"] default-run = "sea-orm-cli" rust-version = "1.60" @@ -22,20 +22,26 @@ path = "src/lib.rs" [[bin]] name = "sea-orm-cli" path = "src/bin/main.rs" -required-features = ["codegen"] +required-features = ["async_std", "codegen"] [[bin]] name = "sea" path = "src/bin/sea.rs" -required-features = ["codegen"] +required-features = ["async_std", "codegen"] [dependencies] clap = { version = "^3.2", features = ["env", "derive"] } dotenv = { version = "^0.15" } -async-std = { version = "^1.9", features = [ "attributes", "tokio1" ] } +async-std = { version = "^1.9", features = [ + "attributes", + "tokio1", +], optional = true } sea-orm-codegen = { version = "^0.9.1", path = "../sea-orm-codegen", optional = true } sea-schema = { version = "^0.9.3" } -sqlx = { version = "^0.6", default-features = false, features = [ "mysql", "postgres" ], optional = true } +sqlx = { version = "^0.6", default-features = false, features = [ + "mysql", + "postgres", +], optional = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing = { version = "0.1" } url = "^2.2" @@ -46,11 +52,30 @@ regex = "1" smol = "1.2.5" [features] -default = [ "codegen", "runtime-async-std-native-tls" ] -codegen = [ "sea-schema/sqlx-all", "sea-orm-codegen" ] -runtime-actix-native-tls = [ "sqlx/runtime-actix-native-tls", "sea-schema/runtime-actix-native-tls" ] -runtime-async-std-native-tls = [ "sqlx/runtime-async-std-native-tls", "sea-schema/runtime-async-std-native-tls" ] -runtime-tokio-native-tls = [ "sqlx/runtime-tokio-native-tls", "sea-schema/runtime-tokio-native-tls" ] -runtime-actix-rustls = [ "sqlx/runtime-actix-rustls", "sea-schema/runtime-actix-rustls" ] -runtime-async-std-rustls = [ "sqlx/runtime-async-std-rustls", "sea-schema/runtime-async-std-rustls" ] -runtime-tokio-rustls = [ "sqlx/runtime-tokio-rustls", "sea-schema/runtime-tokio-rustls" ] +default = ["codegen", "runtime-async-std-native-tls"] +async_std = ["async-std"] +codegen = ["sea-schema/sqlx-all", "sea-orm-codegen"] +runtime-actix-native-tls = [ + "sqlx/runtime-actix-native-tls", + "sea-schema/runtime-actix-native-tls", +] +runtime-async-std-native-tls = [ + "sqlx/runtime-async-std-native-tls", + "sea-schema/runtime-async-std-native-tls", +] +runtime-tokio-native-tls = [ + "sqlx/runtime-tokio-native-tls", + "sea-schema/runtime-tokio-native-tls", +] +runtime-actix-rustls = [ + "sqlx/runtime-actix-rustls", + "sea-schema/runtime-actix-rustls", +] +runtime-async-std-rustls = [ + "sqlx/runtime-async-std-rustls", + "sea-schema/runtime-async-std-rustls", +] +runtime-tokio-rustls = [ + "sqlx/runtime-tokio-rustls", + "sea-schema/runtime-tokio-rustls", +] diff --git a/sea-orm-migration/Cargo.toml b/sea-orm-migration/Cargo.toml index c2ffdd506..e4f0d8a1b 100644 --- a/sea-orm-migration/Cargo.toml +++ b/sea-orm-migration/Cargo.toml @@ -4,13 +4,13 @@ [package] name = "sea-orm-migration" version = "0.9.1" -authors = [ "Billy Chan " ] +authors = ["Billy Chan "] edition = "2021" description = "Migration utility for SeaORM" license = "MIT OR Apache-2.0" documentation = "https://docs.rs/sea-orm" repository = "https://github.com/SeaQL/sea-orm" -categories = [ "database" ] +categories = ["database"] keywords = ["async", "orm", "mysql", "postgres", "sqlite"] rust-version = "1.60" @@ -20,10 +20,12 @@ path = "src/lib.rs" [dependencies] async-trait = { version = "^0.1" } -clap = { version = "^3.2", features = ["env", "derive"] } -dotenv = { version = "^0.15" } -sea-orm = { version = "^0.9.1", path = "../", default-features = false, features = ["macros"] } -sea-orm-cli = { version = "^0.9.1", path = "../sea-orm-cli", default-features = false } +clap = { version = "^3.2", features = ["env", "derive"], optional = true } +dotenv = { version = "^0.15", optional = true } +sea-orm = { version = "^0.9.1", path = "../", default-features = false, features = [ + "macros", +] } +sea-orm-cli = { version = "^0.9.1", path = "../sea-orm-cli", default-features = false, optional = true } sea-schema = { version = "^0.9.3" } tracing = { version = "0.1", features = ["log"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } @@ -32,12 +34,14 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } async-std = { version = "^1", features = ["attributes", "tokio1"] } [features] +default = ["cli"] +cli = ["clap", "dotenv", "sea-orm-cli"] sqlx-mysql = ["sea-orm/sqlx-mysql"] sqlx-postgres = ["sea-orm/sqlx-postgres"] sqlx-sqlite = ["sea-orm/sqlx-sqlite"] -runtime-actix-native-tls = [ "sea-orm/runtime-actix-native-tls" ] -runtime-async-std-native-tls = [ "sea-orm/runtime-async-std-native-tls" ] -runtime-tokio-native-tls = [ "sea-orm/runtime-tokio-native-tls" ] -runtime-actix-rustls = [ "sea-orm/runtime-actix-rustls" ] -runtime-async-std-rustls = [ "sea-orm/runtime-async-std-rustls" ] -runtime-tokio-rustls = [ "sea-orm/runtime-tokio-rustls" ] +runtime-actix-native-tls = ["sea-orm/runtime-actix-native-tls"] +runtime-async-std-native-tls = ["sea-orm/runtime-async-std-native-tls"] +runtime-tokio-native-tls = ["sea-orm/runtime-tokio-native-tls"] +runtime-actix-rustls = ["sea-orm/runtime-actix-rustls"] +runtime-async-std-rustls = ["sea-orm/runtime-async-std-rustls"] +runtime-tokio-rustls = ["sea-orm/runtime-tokio-rustls"] diff --git a/sea-orm-migration/src/lib.rs b/sea-orm-migration/src/lib.rs index 53b51342d..6a7f8547f 100644 --- a/sea-orm-migration/src/lib.rs +++ b/sea-orm-migration/src/lib.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "cli")] pub mod cli; pub mod manager; pub mod migrator; diff --git a/sea-orm-migration/src/prelude.rs b/sea-orm-migration/src/prelude.rs index 836ab1685..fd78117e4 100644 --- a/sea-orm-migration/src/prelude.rs +++ b/sea-orm-migration/src/prelude.rs @@ -1,4 +1,6 @@ +#[cfg(feature = "cli")] pub use super::cli; + pub use super::manager::SchemaManager; pub use super::migrator::MigratorTrait; pub use super::{MigrationName, MigrationTrait}; From 805f67783e45fbe9d0cb5c1d7fa25b926d11f495 Mon Sep 17 00:00:00 2001 From: Rheydskey Date: Fri, 19 Aug 2022 12:07:22 +0200 Subject: [PATCH 2/3] Add cli feature on sea-orm-cli --- sea-orm-cli/Cargo.toml | 11 ++++++----- sea-orm-cli/src/commands/migrate.rs | 2 ++ sea-orm-cli/src/lib.rs | 2 ++ sea-orm-migration/Cargo.toml | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sea-orm-cli/Cargo.toml b/sea-orm-cli/Cargo.toml index 013f01645..c1bfea4fb 100644 --- a/sea-orm-cli/Cargo.toml +++ b/sea-orm-cli/Cargo.toml @@ -22,16 +22,16 @@ path = "src/lib.rs" [[bin]] name = "sea-orm-cli" path = "src/bin/main.rs" -required-features = ["async_std", "codegen"] +required-features = ["async_std", "cli", "codegen"] [[bin]] name = "sea" path = "src/bin/sea.rs" -required-features = ["async_std", "codegen"] +required-features = ["async_std", "cli", "codegen"] [dependencies] -clap = { version = "^3.2", features = ["env", "derive"] } -dotenv = { version = "^0.15" } +clap = { version = "^3.2", features = ["env", "derive"], optional = true } +dotenv = { version = "^0.15", optional = true } async-std = { version = "^1.9", features = [ "attributes", "tokio1", @@ -52,9 +52,10 @@ regex = "1" smol = "1.2.5" [features] -default = ["codegen", "runtime-async-std-native-tls"] +default = ["codegen", "cli", "runtime-async-std-native-tls"] async_std = ["async-std"] codegen = ["sea-schema/sqlx-all", "sea-orm-codegen"] +cli = ["clap", "dotenv"] runtime-actix-native-tls = [ "sqlx/runtime-actix-native-tls", "sea-schema/runtime-actix-native-tls", diff --git a/sea-orm-cli/src/commands/migrate.rs b/sea-orm-cli/src/commands/migrate.rs index 8855c0cd2..62de0139e 100644 --- a/sea-orm-cli/src/commands/migrate.rs +++ b/sea-orm-cli/src/commands/migrate.rs @@ -2,8 +2,10 @@ use chrono::Local; use regex::Regex; use std::{error::Error, fs, io::Write, path::Path, process::Command}; +#[cfg(feature = "cli")] use crate::MigrateSubcommands; +#[cfg(feature = "cli")] pub fn run_migrate_command( command: Option, migration_dir: &str, diff --git a/sea-orm-cli/src/lib.rs b/sea-orm-cli/src/lib.rs index 366b8fa65..4cbb29701 100644 --- a/sea-orm-cli/src/lib.rs +++ b/sea-orm-cli/src/lib.rs @@ -1,5 +1,7 @@ +#[cfg(feature = "cli")] pub mod cli; pub mod commands; +#[cfg(feature = "cli")] pub use cli::*; pub use commands::*; diff --git a/sea-orm-migration/Cargo.toml b/sea-orm-migration/Cargo.toml index e4f0d8a1b..9cf970cde 100644 --- a/sea-orm-migration/Cargo.toml +++ b/sea-orm-migration/Cargo.toml @@ -35,7 +35,7 @@ async-std = { version = "^1", features = ["attributes", "tokio1"] } [features] default = ["cli"] -cli = ["clap", "dotenv", "sea-orm-cli"] +cli = ["clap", "dotenv", "sea-orm-cli/cli"] sqlx-mysql = ["sea-orm/sqlx-mysql"] sqlx-postgres = ["sea-orm/sqlx-postgres"] sqlx-sqlite = ["sea-orm/sqlx-sqlite"] From 95f2dd8cb3f6ea677f22cf25f61ff55db67535af Mon Sep 17 00:00:00 2001 From: Rheydskey Date: Tue, 30 Aug 2022 00:25:07 +0200 Subject: [PATCH 3/3] Remove async-std feature and add async-std in the default feature --- sea-orm-cli/Cargo.toml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sea-orm-cli/Cargo.toml b/sea-orm-cli/Cargo.toml index 49bc1927e..e63678be5 100644 --- a/sea-orm-cli/Cargo.toml +++ b/sea-orm-cli/Cargo.toml @@ -22,12 +22,12 @@ path = "src/lib.rs" [[bin]] name = "sea-orm-cli" path = "src/bin/main.rs" -required-features = ["async_std", "cli", "codegen"] +required-features = ["cli", "codegen"] [[bin]] name = "sea" path = "src/bin/sea.rs" -required-features = ["async_std", "cli", "codegen"] +required-features = ["cli", "codegen"] [dependencies] clap = { version = "^3.2", features = ["env", "derive"], optional = true } @@ -52,8 +52,7 @@ regex = "1" smol = "1.2.5" [features] -default = ["codegen", "cli", "runtime-async-std-native-tls"] -async_std = ["async-std"] +default = ["codegen", "async-std", "cli", "runtime-async-std-native-tls"] codegen = ["sea-schema/sqlx-all", "sea-orm-codegen"] cli = ["clap", "dotenv"] runtime-actix-native-tls = [