From 614ef52889c2d1915d96c681fad6c4e1973e0b1a Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Tue, 12 Sep 2023 21:48:26 -0500 Subject: [PATCH 1/2] Namespace helper methods for css:build command so they don't conflict with jsbundling or other rake tasks --- lib/tasks/cssbundling/build.rake | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/tasks/cssbundling/build.rake b/lib/tasks/cssbundling/build.rake index 90033e2..dcdd429 100644 --- a/lib/tasks/cssbundling/build.rake +++ b/lib/tasks/cssbundling/build.rake @@ -1,7 +1,7 @@ namespace :css do desc "Install JavaScript dependencies" task :install do - command = install_command + command = Cssbundling::Tasks.install_command unless system(command) raise "cssbundling-rails: Command install failed, ensure #{command.split.first} is installed" end @@ -9,7 +9,7 @@ namespace :css do desc "Build your CSS bundle" build_task = task :build do - command = build_command + command = Cssbundling::Tasks.build_command unless system(command) raise "cssbundling-rails: Command build failed, ensure `#{command}` runs without errors" end @@ -17,20 +17,26 @@ namespace :css do build_task.prereqs << :install unless ENV["SKIP_YARN_INSTALL"] || ENV["SKIP_BUN_INSTALL"] end -def install_command - return "bun install" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock')) - return "yarn install" if File.exist?('yarn.lock') || tool_exists?('yarn') - raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies" -end +module Cssbundling + module Tasks + extend self -def build_command - return "bun run build:css" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock')) - return "yarn build:css" if File.exist?('yarn.lock') || tool_exists?('yarn') - raise "cssbundling-rails: No suitable tool found for building CSS" -end + def install_command + return "bun install" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock')) + return "yarn install" if File.exist?('yarn.lock') || tool_exists?('yarn') + raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies" + end -def tool_exists?(tool) - system "command -v #{tool} > /dev/null" + def build_command + return "bun run build:css" if File.exist?('bun.lockb') || (tool_exists?('bun') && !File.exist?('yarn.lock')) + return "yarn build:css" if File.exist?('yarn.lock') || tool_exists?('yarn') + raise "cssbundling-rails: No suitable tool found for building CSS" + end + + def tool_exists?(tool) + system "command -v #{tool} > /dev/null" + end + end end unless ENV["SKIP_CSS_BUILD"] From 87a7dcaabeebd2118298635b5fbcda9876605f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 13 Sep 2023 15:20:28 +0000 Subject: [PATCH 2/2] Prepare for 1.3.1 --- Gemfile.lock | 2 +- lib/cssbundling/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c1dd78c..702e3e7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - cssbundling-rails (1.3.0) + cssbundling-rails (1.3.1) railties (>= 6.0.0) GEM diff --git a/lib/cssbundling/version.rb b/lib/cssbundling/version.rb index e7f28db..ddf163a 100644 --- a/lib/cssbundling/version.rb +++ b/lib/cssbundling/version.rb @@ -1,3 +1,3 @@ module Cssbundling - VERSION = "1.3.0" + VERSION = "1.3.1" end