diff --git a/.gitignore b/.gitignore index 431ecff..397b1fc 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ node_modules/ package.json spec/tmp/ yarn.lock +bun.lockb \ No newline at end of file diff --git a/lib/generators/htmx/install_generator.rb b/lib/generators/htmx/install_generator.rb index 22e48d8..21be15f 100644 --- a/lib/generators/htmx/install_generator.rb +++ b/lib/generators/htmx/install_generator.rb @@ -12,17 +12,12 @@ class InstallGenerator < ::Rails::Generators::Base # Setup HTMX def setup - if bun? - setup_bun - elsif importmap? - setup_importmap - elsif webpacker? - setup_webpacker - elsif sprockets? - setup_sprockets - else - raise 'No known asset pipeline detected' - end + return setup_bun if bun? + return setup_importmap if importmap? + return setup_webpacker if webpacker? + return setup_sprockets if sprockets? + + raise 'No known asset pipeline detected.' end private @@ -62,7 +57,7 @@ def setup_bun end def setup_importmap - run "bin/importmap pin htmx.org#{Htmx::Rails::HTMX_VERSION}" + run "bin/importmap pin htmx.org@#{Htmx::Rails::HTMX_VERSION}" add_to_manifest(manifest('app/javascript'), IMPORTMAP_SETUP) end @@ -72,7 +67,7 @@ def setup_sprockets end def setup_webpacker - run "yarn add htmx.org#{Htmx::Rails::HTMX_VERSION}" + run "yarn add htmx.org@#{Htmx::Rails::HTMX_VERSION}" add_to_manifest(manifest(webpack_source_path), WEBPACKER_SETUP) end diff --git a/spec/lib/generators/install_generator_spec.rb b/spec/lib/generators/install_generator_spec.rb index d00a51e..43c4cf2 100644 --- a/spec/lib/generators/install_generator_spec.rb +++ b/spec/lib/generators/install_generator_spec.rb @@ -151,7 +151,7 @@ end it 'raise an error' do - expect { run_generator }.to raise_error('No known asset pipeline detected') + expect { run_generator }.to raise_error('No known asset pipeline detected.') end end end