Description
I added flowbite with support for Importmaps as per their documentation: https://flowbite.com/docs/getting-started/rails/#importmap:
pin "flowbite", to: "https://cdn.jsdelivr.net/npm/[email protected]/dist/flowbite.turbo.min.js"
I wanted to add the version number at the end in a comment, just like importmap-rails
already added for all the other packages. For example:
pin "@rails/ujs", to: "@rails--ujs.js" # @7.1.400
So I added:
pin "flowbite", to: "https://cdn.jsdelivr.net/npm/[email protected]/dist/flowbite.turbo.min.js" # @2.5.2
Unfortunately, this breaks importmap outdated
as the regex matches the whole pin "flowbite"...
line:
importmap-rails/lib/importmap/npm.rb
Lines 47 to 53 in d91d5e1
Here's the regex tester:
https://rubular.com/r/uzRSGTsdzOLRXW
I've updated the regex here:
https://rubular.com/r/xuUcWPo4r3ePMa
Not sure if this should be the solution. The difference is that, instead of matching any character .*
until the end of the line $
, I match any non-whitespace character \S
and I don't match until the end of the line.
Before:
> importmap outdated
/Users/viktor/.rvm/gems/ruby-3.4.1/gems/uri-1.0.2/lib/uri/generic.rb:770:in 'URI::Generic#check_path': bad component(expected absolute path component): /[email protected]/dist/flowbite.turbo.min.js" # (URI::InvalidComponentError)
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/uri-1.0.2/lib/uri/generic.rb:816:in 'URI::Generic#path='
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/importmap-rails-2.1.0/lib/importmap/npm.rb:67:in 'Importmap::Npm#get_package'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/importmap-rails-2.1.0/lib/importmap/npm.rb:21:in 'block in Importmap::Npm#outdated_packages'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/importmap-rails-2.1.0/lib/importmap/npm.rb:17:in 'Array#each'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/importmap-rails-2.1.0/lib/importmap/npm.rb:17:in 'Enumerator#with_object'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/importmap-rails-2.1.0/lib/importmap/npm.rb:17:in 'Importmap::Npm#outdated_packages'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/importmap-rails-2.1.0/lib/importmap/commands.rb:96:in 'Importmap::Commands#outdated'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/thor-1.3.2/lib/thor/command.rb:28:in 'Thor::Command#run'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/thor-1.3.2/lib/thor/invocation.rb:127:in 'Thor::Invocation#invoke_command'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/thor-1.3.2/lib/thor.rb:538:in 'Thor.dispatch'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/thor-1.3.2/lib/thor/base.rb:584:in 'Thor::Base::ClassMethods#start'
from /Users/viktor/.rvm/gems/ruby-3.4.1/gems/importmap-rails-2.1.0/lib/importmap/commands.rb:159:in '<main>'
After:
> importmap outdated
No outdated packages found
Should I make a PR? Should I add a test? What would be a good location for this test? Should I add a line to https://github.com/rails/importmap-rails/blob/main/test/fixtures/files/outdated_import_map.rb
and then add a test to test/npm_test.rb
?