From 1ab720c9b2f181cf05b0402a3675227a241147ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zaporski?= Date: Tue, 9 Sep 2025 16:33:52 +0200 Subject: [PATCH] Add the `--no-asset-precompilation` flag and update README --- README.md | 10 ++++++++++ lib/capistrano/data_plane_api/deploy/args.rb | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c19541..33d1ad1 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ This script can be used to deploy this app to remote servers. -h, --help Prints this help -b, --branch=BRANCH Deploy the code from the passed Git branch --no-migrations Do not carry out migrations + --no-asset-precompilation Skip asset precompilation during deployment ``` ### Example of commands @@ -197,6 +198,15 @@ deploy These tasks will only run when the `:web` role is added to the deployment stage. +## Database migrations and asset precompilation + +In order for the `--no-migrations` and `--no-asset-precompilation` flags to work correctly, you need to use this configuration in your `Capfile`: + +```rb +require 'capistrano/rails/assets' if ::ENV['NO_ASSET_PRECOMPILATION'].nil? +require 'capistrano/rails/migrations' if ::ENV['NO_MIGRATIONS'].nil? +``` + ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. diff --git a/lib/capistrano/data_plane_api/deploy/args.rb b/lib/capistrano/data_plane_api/deploy/args.rb index 9b224b0..eb049c6 100644 --- a/lib/capistrano/data_plane_api/deploy/args.rb +++ b/lib/capistrano/data_plane_api/deploy/args.rb @@ -11,7 +11,7 @@ module Deploy # passed to the deployment script and saves them in # an object. class Args - PRINTABLE_ENV_VARS = %w[BRANCH NO_MIGRATIONS].freeze + PRINTABLE_ENV_VARS = %w[BRANCH NO_MIGRATIONS NO_ASSET_PRECOMPILATION].freeze #: (Array[untyped]?) -> instance def self.parse(options = nil) # rubocop:disable Metrics/MethodLength, Style/ClassMethodsDefinitions @@ -156,6 +156,13 @@ def self.parse(options = nil) # rubocop:disable Metrics/MethodLength, Style/Clas args.no_migrations = val ::ENV['NO_MIGRATIONS'] = 'true' end + + parser.on( + '--no-asset-precompilation', + 'Skip asset precompilation during deployment', + ) do + ::ENV['NO_ASSET_PRECOMPILATION'] = 'true' + end end opt_parser.parse!(options || ::ARGV)