diff --git a/Cargo.toml b/Cargo.toml index 12ef9c541..c264918cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0" [package] name = "loco-rs" -version = "0.13.2" +version = "0.14.0" description = "The one-person framework for Rust" homepage = "https://loco.rs/" documentation = "https://docs.rs/loco-rs" @@ -49,7 +49,7 @@ bg_sqlt = ["dep:sqlx", "dep:ulid"] integration_test = [] [dependencies] -loco-gen = { version = "0.13.2", path = "./loco-gen" } +loco-gen = { version = "0.14.0", path = "./loco-gen" } backtrace_printer = { version = "1.3.0" } # cli diff --git a/docs-site/content/docs/extras/upgrades.md b/docs-site/content/docs/extras/upgrades.md index 755b866e0..5a47c050d 100644 --- a/docs-site/content/docs/extras/upgrades.md +++ b/docs-site/content/docs/extras/upgrades.md @@ -33,3 +33,91 @@ These are the major ones: * [SeaORM](https://www.sea-ql.org/SeaORM), [CHANGELOG](https://github.com/SeaQL/sea-orm/blob/master/CHANGELOG.md) * [Axum](https://github.com/tokio-rs/axum), [CHANGELOG](https://github.com/tokio-rs/axum/blob/main/axum/CHANGELOG.md) + +## Upgrade from 0.13.x to 0.14.x + +### Upgrading from Axum 0.7 to 0.8 + +PR: [#1130](https://github.com/loco-rs/loco/pull/1130) +The upgrade to Axum 0.8 introduces a breaking change. For more details, refer to the [announcement](https://tokio.rs/blog/2025-01-01-announcing-axum-0-8-0). +#### Steps to Upgrade +* In your `Cargo.toml`, update the Axum version from `0.7.5` to `0.8.1`. +* Replace use `axum::async_trait`; with use `async_trait::async_trait;`. For more information, see [here](https://tokio.rs/blog/2025-01-01-announcing-axum-0-8-0#async_trait-removal). +* The URL parameter syntax has changed. Refer to [this section](https://tokio.rs/blog/2025-01-01-announcing-axum-0-8-0#path-parameter-syntax-changes) for the updated syntax. The new path parameter format is: +The path parameter syntax has changed from `/:single` and `/*many` to `/{single}` and `/{*many}`. + + +### Extending the `boot` Function Hook +PR: [#1143](https://github.com/loco-rs/loco/pull/1143) + +The `boot` hook function now accepts an additional Config parameter. The function signature has changed from: + +From +```rust +async fn boot(mode: StartMode, environment: &Environment) -> Result { + create_app::(mode, environment).await +} +``` +To: +```rust +async fn boot(mode: StartMode, environment: &Environment, config: Config) -> Result { + create_app::(mode, environment, config).await +} +``` +Make sure to import the `Config` type as needed. + +### Upgrade validator crate +PR: [#993](https://github.com/loco-rs/loco/pull/993) + +Update the `validator` crate version in your `Cargo.toml`: + +From +``` +validator = { version = "0.18" } +``` +To +``` +validator = { version = "0.19" } +``` + +### Extend truncate and seed hooks +PR: [#1158](https://github.com/loco-rs/loco/pull/1158) + +The `truncate` and `seed` functions now receive `AppContext` instead of `DatabaseConnection` as their argument. + +From +```rust +async fn truncate(db: &DatabaseConnection) -> Result<()> {} +async fn seed(db: &DatabaseConnection, base: &Path) -> Result<()> {} +``` +To +```rust +async fn truncate(ctx: &AppContext) -> Result<()> {} +async fn seed(_ctx: &AppContext, base: &Path) -> Result<()> {} +``` + +Impact on Testing: + +Testing code involving the seed function must also be updated accordingly. + +from: +```rust +async fn load_page() { + request::(|request, ctx| async move { + seed::(&ctx.db).await.unwrap(); + ... + }) + .await; +} +``` + +to +```rust +async fn load_page() { + request::(|request, ctx| async move { + seed::(&ctx).await.unwrap(); + ... + }) + .await; +} +``` \ No newline at end of file diff --git a/loco-gen/Cargo.toml b/loco-gen/Cargo.toml index f5388b15c..a0d83fbeb 100644 --- a/loco-gen/Cargo.toml +++ b/loco-gen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "loco-gen" -version = "0.13.2" +version = "0.14.0" description = "Loco generators" license.workspace = true edition.workspace = true diff --git a/loco-new/Cargo.toml b/loco-new/Cargo.toml index 03bee0710..be8928b4d 100644 --- a/loco-new/Cargo.toml +++ b/loco-new/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "loco" -version = "0.13.3" +version = "0.14.0" edition = "2021" description = "Loco new app generator" license = "Apache-2.0" diff --git a/loco-new/src/lib.rs b/loco-new/src/lib.rs index cbf437d29..31b50d531 100644 --- a/loco-new/src/lib.rs +++ b/loco-new/src/lib.rs @@ -9,7 +9,7 @@ pub mod wizard; pub type Result = std::result::Result; /// Matching minimal Loco version. -pub const LOCO_VERSION: &str = "0.13.2"; +pub const LOCO_VERSION: &str = "0.14.0"; #[derive(thiserror::Error, Debug)] pub enum Error {