Module: Inertia::Generators::Helpers
- Included in:
- InstallGenerator
- Defined in:
- lib/generators/inertia/install/helpers.rb
Instance Method Summary collapse
-
#ask ⇒ Object
Interactivity Helpers.
- #file?(*relative_path) ⇒ Boolean
- #file_path(*relative_path) ⇒ Object
-
#js_destination_path ⇒ Object
FS Helpers.
- #js_destination_root ⇒ Object
- #js_file_path(*relative_path) ⇒ Object
- #yes? ⇒ Boolean
Instance Method Details
#ask ⇒ Object
Interactivity Helpers
35 36 37 38 39 40 41 42 |
# File 'lib/generators/inertia/install/helpers.rb', line 35 def ask(*) unless [:interactive] say_error 'Specify all options when running the generator non-interactively.', :red exit(1) end super end |
#file?(*relative_path) ⇒ Boolean
26 27 28 |
# File 'lib/generators/inertia/install/helpers.rb', line 26 def file?(*relative_path) File.file?(file_path(*relative_path)) end |
#file_path(*relative_path) ⇒ Object
30 31 32 |
# File 'lib/generators/inertia/install/helpers.rb', line 30 def file_path(*relative_path) File.join(destination_root, *relative_path) end |
#js_destination_path ⇒ Object
FS Helpers
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/inertia/install/helpers.rb', line 7 def js_destination_path return ViteRuby.config.source_code_dir if defined?(ViteRuby) if file?('config/vite.json') source_code_dir = JSON.parse(File.read(file_path('config/vite.json'))).dig('all', 'sourceCodeDir') return source_code_dir if source_code_dir end 'app/frontend' end |
#js_destination_root ⇒ Object
18 19 20 |
# File 'lib/generators/inertia/install/helpers.rb', line 18 def js_destination_root file_path(js_destination_path) end |
#js_file_path(*relative_path) ⇒ Object
22 23 24 |
# File 'lib/generators/inertia/install/helpers.rb', line 22 def js_file_path(*relative_path) File.join(js_destination_root, *relative_path) end |
#yes? ⇒ Boolean
44 45 46 47 48 |
# File 'lib/generators/inertia/install/helpers.rb', line 44 def yes?(*) return false unless [:interactive] super end |