Add cli feature on sea-orm-migration (#978)

* Add cli feature on sea-orm-migration

* Add cli feature on sea-orm-cli

* Remove async-std feature and add async-std in the default feature

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
This commit is contained in:
Rheydskey 2022-10-26 11:48:06 +02:00 committed by GitHub
parent cb76b8f443
commit 9f2eb3d46c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 26 deletions

View File

@ -4,14 +4,14 @@
[package] [package]
name = "sea-orm-cli" name = "sea-orm-cli"
version = "0.10.0" version = "0.10.0"
authors = [ "Billy Chan <ccw.billy.123@gmail.com>" ] authors = ["Billy Chan <ccw.billy.123@gmail.com>"]
edition = "2021" edition = "2021"
description = "Command line utility for SeaORM" description = "Command line utility for SeaORM"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
homepage = "https://www.sea-ql.org/SeaORM" homepage = "https://www.sea-ql.org/SeaORM"
documentation = "https://docs.rs/sea-orm" documentation = "https://docs.rs/sea-orm"
repository = "https://github.com/SeaQL/sea-orm" repository = "https://github.com/SeaQL/sea-orm"
categories = [ "database" ] categories = ["database"]
keywords = ["async", "orm", "mysql", "postgres", "sqlite"] keywords = ["async", "orm", "mysql", "postgres", "sqlite"]
default-run = "sea-orm-cli" default-run = "sea-orm-cli"
rust-version = "1.60" rust-version = "1.60"
@ -23,20 +23,20 @@ path = "src/lib.rs"
[[bin]] [[bin]]
name = "sea-orm-cli" name = "sea-orm-cli"
path = "src/bin/main.rs" path = "src/bin/main.rs"
required-features = ["codegen"] required-features = ["cli", "codegen"]
[[bin]] [[bin]]
name = "sea" name = "sea"
path = "src/bin/sea.rs" path = "src/bin/sea.rs"
required-features = ["codegen"] required-features = ["cli", "codegen"]
[dependencies] [dependencies]
clap = { version = "^3.2", features = ["env", "derive"] } clap = { version = "^3.2", features = ["env", "derive"], optional = true }
dotenvy = { version = "^0.15", optional = true } dotenvy = { version = "^0.15", optional = true }
async-std = { version = "^1.9", features = [ "attributes", "tokio1" ], optional = true } async-std = { version = "^1.9", features = ["attributes", "tokio1"], optional = true }
sea-orm-codegen = { version = "^0.10.0", path = "../sea-orm-codegen", optional = true } sea-orm-codegen = { version = "^0.10.0", path = "../sea-orm-codegen", optional = true }
sea-schema = { version = "^0.10.2", git = "https://github.com/SeaQL/sea-schema" } sea-schema = { version = "^0.10.2", git = "https://github.com/SeaQL/sea-schema" }
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-subscriber = { version = "0.3", features = ["env-filter"] }
tracing = { version = "0.1" } tracing = { version = "0.1" }
url = "^2.2" url = "^2.2"
@ -47,11 +47,12 @@ regex = "1"
smol = "1.2.5" smol = "1.2.5"
[features] [features]
default = [ "codegen", "runtime-async-std-native-tls", "dotenvy", "async-std" ] default = ["codegen", "cli", "runtime-async-std-native-tls", "async-std"]
codegen = [ "sea-schema/sqlx-all", "sea-orm-codegen" ] codegen = ["sea-schema/sqlx-all", "sea-orm-codegen"]
runtime-actix-native-tls = [ "sqlx/runtime-actix-native-tls", "sea-schema/runtime-actix-native-tls" ] cli = ["clap", "dotenvy"]
runtime-async-std-native-tls = [ "sqlx/runtime-async-std-native-tls", "sea-schema/runtime-async-std-native-tls" ] runtime-actix-native-tls = ["sqlx/runtime-actix-native-tls", "sea-schema/runtime-actix-native-tls"]
runtime-tokio-native-tls = [ "sqlx/runtime-tokio-native-tls", "sea-schema/runtime-tokio-native-tls" ] runtime-async-std-native-tls = ["sqlx/runtime-async-std-native-tls", "sea-schema/runtime-async-std-native-tls"]
runtime-actix-rustls = [ "sqlx/runtime-actix-rustls", "sea-schema/runtime-actix-rustls" ] runtime-tokio-native-tls = ["sqlx/runtime-tokio-native-tls", "sea-schema/runtime-tokio-native-tls"]
runtime-async-std-rustls = [ "sqlx/runtime-async-std-rustls", "sea-schema/runtime-async-std-rustls" ] runtime-actix-rustls = ["sqlx/runtime-actix-rustls", "sea-schema/runtime-actix-rustls"]
runtime-tokio-rustls = [ "sqlx/runtime-tokio-rustls", "sea-schema/runtime-tokio-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"]

View File

@ -8,8 +8,10 @@ use std::{
process::Command, process::Command,
}; };
#[cfg(feature = "cli")]
use crate::MigrateSubcommands; use crate::MigrateSubcommands;
#[cfg(feature = "cli")]
pub fn run_migrate_command( pub fn run_migrate_command(
command: Option<MigrateSubcommands>, command: Option<MigrateSubcommands>,
migration_dir: &str, migration_dir: &str,

View File

@ -1,5 +1,7 @@
#[cfg(feature = "cli")]
pub mod cli; pub mod cli;
pub mod commands; pub mod commands;
#[cfg(feature = "cli")]
pub use cli::*; pub use cli::*;
pub use commands::*; pub use commands::*;

View File

@ -4,14 +4,14 @@
[package] [package]
name = "sea-orm-migration" name = "sea-orm-migration"
version = "0.10.0" version = "0.10.0"
authors = [ "Billy Chan <ccw.billy.123@gmail.com>" ] authors = ["Billy Chan <ccw.billy.123@gmail.com>"]
edition = "2021" edition = "2021"
description = "Migration utility for SeaORM" description = "Migration utility for SeaORM"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
homepage = "https://www.sea-ql.org/SeaORM" homepage = "https://www.sea-ql.org/SeaORM"
documentation = "https://docs.rs/sea-orm" documentation = "https://docs.rs/sea-orm"
repository = "https://github.com/SeaQL/sea-orm" repository = "https://github.com/SeaQL/sea-orm"
categories = [ "database" ] categories = ["database"]
keywords = ["async", "orm", "mysql", "postgres", "sqlite"] keywords = ["async", "orm", "mysql", "postgres", "sqlite"]
rust-version = "1.60" rust-version = "1.60"
@ -21,10 +21,10 @@ path = "src/lib.rs"
[dependencies] [dependencies]
async-trait = { version = "^0.1" } async-trait = { version = "^0.1" }
clap = { version = "^3.2", features = ["env", "derive"] } clap = { version = "^3.2", features = ["env", "derive"], optional = true }
dotenvy = { version = "^0.15" } dotenvy = { version = "^0.15", optional = true }
sea-orm = { version = "^0.10.0", path = "../", default-features = false, features = ["macros"] } sea-orm = { version = "^0.10.0", path = "../", default-features = false, features = ["macros"] }
sea-orm-cli = { version = "^0.10.0", path = "../sea-orm-cli", default-features = false } sea-orm-cli = { version = "^0.10.0", path = "../sea-orm-cli", default-features = false, optional = true }
sea-schema = { version = "^0.10.2", git = "https://github.com/SeaQL/sea-schema" } sea-schema = { version = "^0.10.2", git = "https://github.com/SeaQL/sea-schema" }
tracing = { version = "0.1", features = ["log"] } tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] }
@ -33,12 +33,14 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
async-std = { version = "^1", features = ["attributes", "tokio1"] } async-std = { version = "^1", features = ["attributes", "tokio1"] }
[features] [features]
default = ["cli"]
cli = ["clap", "dotenvy", "sea-orm-cli/cli"]
sqlx-mysql = ["sea-orm/sqlx-mysql"] sqlx-mysql = ["sea-orm/sqlx-mysql"]
sqlx-postgres = ["sea-orm/sqlx-postgres"] sqlx-postgres = ["sea-orm/sqlx-postgres"]
sqlx-sqlite = ["sea-orm/sqlx-sqlite"] sqlx-sqlite = ["sea-orm/sqlx-sqlite"]
runtime-actix-native-tls = [ "sea-orm/runtime-actix-native-tls" ] runtime-actix-native-tls = ["sea-orm/runtime-actix-native-tls"]
runtime-async-std-native-tls = [ "sea-orm/runtime-async-std-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-tokio-native-tls = ["sea-orm/runtime-tokio-native-tls"]
runtime-actix-rustls = [ "sea-orm/runtime-actix-rustls" ] runtime-actix-rustls = ["sea-orm/runtime-actix-rustls"]
runtime-async-std-rustls = [ "sea-orm/runtime-async-std-rustls" ] runtime-async-std-rustls = ["sea-orm/runtime-async-std-rustls"]
runtime-tokio-rustls = [ "sea-orm/runtime-tokio-rustls" ] runtime-tokio-rustls = ["sea-orm/runtime-tokio-rustls"]

View File

@ -1,3 +1,4 @@
#[cfg(feature = "cli")]
pub mod cli; pub mod cli;
pub mod manager; pub mod manager;
pub mod migrator; pub mod migrator;

View File

@ -1,4 +1,6 @@
#[cfg(feature = "cli")]
pub use super::cli; pub use super::cli;
pub use super::manager::SchemaManager; pub use super::manager::SchemaManager;
pub use super::migrator::MigratorTrait; pub use super::migrator::MigratorTrait;
pub use super::{MigrationName, MigrationTrait}; pub use super::{MigrationName, MigrationTrait};