|
| 1 | +class Lucky130Release < BasePost |
| 2 | + title "Lucky v1.3.0 has been released" |
| 3 | + slug "lucky-1_3_0-release" |
| 4 | + |
| 5 | + def published_at : Time |
| 6 | + Time.utc(year: 2024, month: 10, day: 23) |
| 7 | + end |
| 8 | + |
| 9 | + def summary : String |
| 10 | + <<-TEXT |
| 11 | + Closing out the final quarter of 2024 with improved attack protection, better Windows compatibility, |
| 12 | + arbitrary CLI tasks, and more. |
| 13 | + TEXT |
| 14 | + end |
| 15 | + |
| 16 | + def content : String |
| 17 | + <<-MD |
| 18 | + Lucky v1.3.0 has been released. This is a smaller release to fix compatibility with Crystal 1.13.x and later. |
| 19 | +
|
| 20 | + Read through the [CHANGELOG](https://github.com/luckyframework/lucky/blob/main/CHANGELOG.md) |
| 21 | + for all of the changes, but we will discuss some of the highlights here. |
| 22 | +
|
| 23 | + ### How to upgrade |
| 24 | +
|
| 25 | + See the [UPGRADE_NOTES](https://github.com/luckyframework/lucky/blob/main/UPGRADE_NOTES.md#upgrading-from-120-to-130). |
| 26 | +
|
| 27 | + You can also view the changes using [LuckyDiff](https://luckydiff.com/?from=1.2.0&to=1.3.0). |
| 28 | +
|
| 29 | + ## Here's what's new |
| 30 | +
|
| 31 | + ### New MaximumRequestSizeHandler |
| 32 | +
|
| 33 | + This is a new handler you can add to your server middleware stack allowing you to customize |
| 34 | + the maximum size your requests should allow. This may help you to prevent your app from being |
| 35 | + attacked with extra large file sizes or payloads. |
| 36 | +
|
| 37 | + Add `Lucky::MaximumRequestSizeHandler.new` to your `src/app_server.cr` |
| 38 | +
|
| 39 | + ```crystal |
| 40 | + def middleware : Array(HTTP::Handler) |
| 41 | + [ |
| 42 | + Lucky::RequestIdHandler.new, |
| 43 | + #... |
| 44 | + Lucky::MaximumRequestSizeHandler.new, |
| 45 | + #... |
| 46 | + ] |
| 47 | + end |
| 48 | + ``` |
| 49 | +
|
| 50 | + Then add a configuration for it in `config/server.cr` |
| 51 | +
|
| 52 | + ```crystal |
| 53 | + Lucky::MaximumRequestSizeHandler.configure do |settings| |
| 54 | + settings.enabled = true |
| 55 | + settings.max_size = 10_485_760 # 10MB |
| 56 | + end |
| 57 | + ``` |
| 58 | +
|
| 59 | + ### More support for Windows |
| 60 | +
|
| 61 | + Our previous release 1.2.0 added the ability to install the Lucky CLI on Windows using [Scoop](https://scoop.sh/), |
| 62 | + but booting the Lucky app still had quite a few issues. |
| 63 | +
|
| 64 | + This release has put a lot more focus in to Windows compatibility with most of the eco system shards fully working. |
| 65 | +
|
| 66 | + The following shards all now have Windows compatibility: |
| 67 | +
|
| 68 | + * [Lucky](https://github.com/luckyframework/lucky) |
| 69 | + * [LuckyFlow](https://github.com/luckyframework/lucky_flow) |
| 70 | + * [Carbon](https://github.com/luckyframework/carbon) |
| 71 | + * [Pulsar](https://github.com/luckyframework/pulsar) |
| 72 | + * [LuckyCache](https://github.com/luckyframework/lucky_cache) |
| 73 | + * [LuckyRouter](https://github.com/luckyframework/lucky_router) |
| 74 | + * [Habitat](https://github.com/luckyframework/habitat) |
| 75 | + * [LuckyEnv](https://github.com/luckyframework/lucky_env) |
| 76 | + * [LuckyTask](https://github.com/luckyframework/lucky_task) |
| 77 | + * [Wordsmith](https://github.com/luckyframework/wordsmith) |
| 78 | + * [LuckyTemplate](https://github.com/luckyframework/lucky_template) |
| 79 | + * [LuckySecTester](https://github.com/luckyframework/lucky_sec_tester) |
| 80 | +
|
| 81 | + The final shard missing is [Avram](https://github.com/luckyframework/avram) (which is mainly held back by [this issue on PG](https://github.com/will/crystal-pg/issues/291)), and |
| 82 | + the [CLI itself](https://github.com/luckyframework/lucky_cli) which will be finalized once Avram is updated. |
| 83 | +
|
| 84 | + If you're a developer using Windows, we would love the additional assistance. Reach out on [Discord](#{Chat::Index.path}) |
| 85 | + if you have questions. |
| 86 | +
|
| 87 | + ### Arbitrary CLI tasks |
| 88 | +
|
| 89 | + One major issue that held Lucky back on Windows compatibility was the use of the `postinstall` scripts on Lucky, Carbon, and Avram. |
| 90 | + Previously, when installing these shards, they would need to run a bash script that would then precompile a few binaries |
| 91 | + for use with your app. For example, the `lucky gen.secret_key` task which generates a random unique key. |
| 92 | +
|
| 93 | + Aside from these bash scripts not being directly usable on Windows, there's also been discussion that [postinstall can be "harmful"](https://forum.crystal-lang.org/t/shards-postinstall-considered-harmful/3910) |
| 94 | + and may possibly removed in a future version of Crystal. By removing the use of the postinstall, |
| 95 | + Lucky was able to do a few things: |
| 96 | +
|
| 97 | + * Installing the shards is **way** faster since it no longer needs to stop and precompile several binaries |
| 98 | + * No more need for bash scripts to install Lucky making the installation process more portable and cross platform accessible |
| 99 | + * A refactor led to a new feature of arbitrary CLI tasks |
| 100 | +
|
| 101 | + You can now create a simple Crystal file script and place it in your app's `bin` directory and name it `lucky.your.custom.task.cr`. |
| 102 | + To execute this script, just run `lucky your.custom.task`. You can compile this task in to a binary at any time you wish by running |
| 103 | +
|
| 104 | + ``` |
| 105 | + crystal build --release bin/lucky.your.custom.task.cr -o bin/lucky.your.custom.task |
| 106 | + ``` |
| 107 | +
|
| 108 | + Next time you execute this call, it'll run the compiled version instantly. |
| 109 | +
|
| 110 | + > The next release, a new `lucky build` command will make this easier. |
| 111 | +
|
| 112 | + ## Parting words |
| 113 | +
|
| 114 | + Thank you for sticking with Lucky. While there's many options out there to choose from, |
| 115 | + it means a lot that you've chosen this framework. If you're using Lucky in production, and would like |
| 116 | + to add your application to our [Awesome Lucky](https://luckyframework.org/awesome) "built-with" |
| 117 | + section, feel free to open an issue on the [Website](https://github.com/luckyframework/website/issues) |
| 118 | + or a PR! |
| 119 | +
|
| 120 | + ### Follow and spread the word |
| 121 | +
|
| 122 | + If you haven't already, give us a [star on GitHub](https://github.com/luckyframework/lucky), |
| 123 | + and be sure to follow us on [X (formerly Twitter)](https://x.com/luckyframework/). |
| 124 | +
|
| 125 | + Learn tips and tricks with [LuckyCasts](https://luckycasts.com/). |
| 126 | +
|
| 127 | + If you have any questions, or just want to chat, please join us on [Discord](#{Chat::Index.path}). |
| 128 | + MD |
| 129 | + end |
| 130 | +end |
0 commit comments