Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate action cannot find slice in certain code formatting styles #1284

Open
gstark opened this issue Feb 5, 2023 · 0 comments
Open

Generate action cannot find slice in certain code formatting styles #1284

gstark opened this issue Feb 5, 2023 · 0 comments

Comments

@gstark
Copy link

gstark commented Feb 5, 2023

When using hanamismith the generated routes.rb looks like:

  # Configures application routes.
  class Routes < Hanami::Routes
    slice(:health, at: "/status") { root to: "show" }
    slice(:main, at: "/") { root to: "home.show" }
  end

When running a command such as hanami g action home.subscribe --slice=main --url='/subscribe' --http=post, the following error is raised:

/Users/me/.gem/ruby/3.2.0/gems/dry-files-1.0.1/lib/dry/files.rb:957:in `index': cannot find `(?-mix:slice[[:space:]]*:main)' in `config/routes.rb' (Dry::Files::MissingTargetError)
	from /Users/me/.gem/ruby/3.2.0/gems/dry-files-1.0.1/lib/dry/files.rb:685:in `inject_line_at_block_bottom'
	from /Users/me/.gem/ruby/3.2.0/gems/hanami-cli-2.0.3/lib/hanami/cli/generators/app/action.rb:73:in `generate_for_slice'
	from /Users/me/.gem/ruby/3.2.0/gems/hanami-cli-2.0.3/lib/hanami/cli/generators/app/action.rb:28:in `call'
	from /Users/me/.gem/ruby/3.2.0/gems/hanami-cli-2.0.3/lib/hanami/cli/commands/app/generate/action.rb:72:in `call'
	from /Users/me/.gem/ruby/3.2.0/gems/hanami-cli-2.0.3/lib/hanami/cli/commands/app/command.rb:40:in `call'
	from /Users/me/.gem/ruby/3.2.0/gems/dry-cli-1.0.0/lib/dry/cli.rb:116:in `perform_registry'
	from /Users/me/.gem/ruby/3.2.0/gems/dry-cli-1.0.0/lib/dry/cli.rb:65:in `call'
	from /Users/me/.gem/ruby/3.2.0/gems/hanami-cli-2.0.3/exe/hanami:11:in `<top (required)>'
	from /Users/me/.gem/ruby/3.2.0/bin/hanami:25:in `load'
	from /Users/me/.gem/ruby/3.2.0/bin/hanami:25:in `<main>'

I believe this happens because the regular expression below expects a form without parenthesis.

def slice_matcher(slice)
  /slice[[:space:]]*:#{slice}/
end

Reference: PR on hanamismith

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants