From 7386a6d9289a4bd472c3f9524da7075c9bc3a0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9nich=20Bon=20=C4=86iri=C4=87?= Date: Wed, 10 Jun 2026 09:27:25 -0600 Subject: [PATCH] Fix deprecation warnings for modern Crystal compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: None # Why is this change necessary? * Modern Crystal versions generate several deprecation warnings for outdated methods (Process::Status#exit_status, Time.monotonic, splat macro syntax, ::sleep). # How does it address the issue * Updated `exit_status` to `exit_code` in `src/amber/cli/commands/exec.cr`. * Replaced `Time.monotonic` with `Time.instant` in `src/amber/cli/helpers/process_runner.cr`. * Replaced `sleep 1` with `sleep 1.second` in `src/amber/cli/helpers/process_runner.cr`. * Replaced double-brace macro splat syntax `{{*args}}` with `{{args.splat}}` in `src/amber/dsl/router.cr`. # What side effects does this change have? * None. Fixes compilation deprecation warnings when building the amber CLI binary. Co-developed-by: Gemini AI Signed-off-by: Rénich Bon Ćirić --- src/amber/cli/commands/exec.cr | 2 +- src/amber/cli/helpers/process_runner.cr | 8 ++++---- src/amber/dsl/router.cr | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/amber/cli/commands/exec.cr b/src/amber/cli/commands/exec.cr index ad24a1323..a68e6f2cc 100644 --- a/src/amber/cli/commands/exec.cr +++ b/src/amber/cli/commands/exec.cr @@ -53,7 +53,7 @@ module Amber::CLI spawn show process = Process.run(code, shell: true, output: file, error: file) sleep 1.millisecond - process.exit_status + process.exit_code end private def wrap(code) diff --git a/src/amber/cli/helpers/process_runner.cr b/src/amber/cli/helpers/process_runner.cr index aa147443e..ffee669be 100644 --- a/src/amber/cli/helpers/process_runner.cr +++ b/src/amber/cli/helpers/process_runner.cr @@ -13,7 +13,7 @@ module Sentry @build_commands = Hash(String, String).new, # { "task1" => [ ... ], "task2" => [ ... ] } @run_commands = Hash(String, String).new, # { "task1" => [ ... ], "task2" => [ ... ] } @includes = Hash(String, Array(String)).new, # { "task1" => [ ... ], "task2" => [ ... ] } - @excludes = Hash(String, Array(String)).new # { "task1" => [ ... ], "task2" => [ ... ] } + @excludes = Hash(String, Array(String)).new, # { "task1" => [ ... ], "task2" => [ ... ] } ) @app_running = false end @@ -25,7 +25,7 @@ module Sentry loop do scan_files check_processes - sleep 1 + sleep 1.second end end @@ -120,11 +120,11 @@ module Sentry ok_to_run = true else log :run, "Building..." - time = Time.monotonic + time = Time.instant build_result = Amber::CLI::Helpers.run(build_command_run) exit 1 unless build_result.is_a? Process::Status if build_result.success? - log :run, "Compiled in #{(Time.monotonic - time)}" + log :run, "Compiled in #{(Time.instant - time)}" stop_processes("run") if @app_running ok_to_run = true elsif !@app_running # first run diff --git a/src/amber/dsl/router.cr b/src/amber/dsl/router.cr index b851048b5..369a016c9 100644 --- a/src/amber/dsl/router.cr +++ b/src/amber/dsl/router.cr @@ -33,12 +33,12 @@ module Amber::DSL {% for verb in RESOURCES %} macro {{verb.id}}(*args) - route {{verb}}, \{{*args}} + route {{verb}}, \{{args.splat}} {% if verb == :get %} - route :head, \{{*args}} + route :head, \{{args.splat}} {% end %} {% if ![:trace, :connect, :options, :head].includes? verb %} - route :options, \{{*args}} + route :options, \{{args.splat}} {% end %} end {% end %}