lib/tasks/strada_tasks.rake in strada-rails-0.0.2 vs lib/tasks/strada_tasks.rake in strada-rails-0.0.3

- old
+ new

@@ -1,15 +1,29 @@ def run_strada_install_template(path) system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb", __dir__)}" end +def install_strada_with_importmap? + Rails.root.join("config/importmap.rb").exist? +end + +def install_strada_with_bun? + Rails.root.join("package.json").exist? && Rails.root.join("bun.config.js").exist? +end + +def install_strada_with_node? + Rails.root.join("package.json").exist? && !Rails.root.join("bun.config.js").exist? +end + namespace :strada do desc "Install Strada into the app" task :install do - if Rails.root.join("config/importmap.rb").exist? + if install_strada_with_importmap? Rake::Task["strada:install:importmap"].invoke - elsif Rails.root.join("package.json").exist? + elsif install_strada_with_bun? + Rake::Task["strada:install:bun"].invoke + elsif install_strada_with_node? Rake::Task["strada:install:node"].invoke else puts "You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem." end end @@ -21,8 +35,13 @@ end desc "Install Strada on an app running node" task :node do run_strada_install_template "strada_with_node" + end + + desc "Install Stimulus on an app running bun" + task :bun do + run_strada_install_template "strada_with_bun" end end end