File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
lib/inertia_rails/generators Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,16 @@ module InertiaRails
4
4
module Generators
5
5
module Helper
6
6
class << self
7
- def guess_the_default_framework ( package_json_path = Rails . root . join ( "package.json" ) )
8
- package = File . read ( package_json_path )
9
- case package
10
- when %r{@inertiajs/react}
7
+ def guess_the_default_framework ( package_json_path = Rails . root . join ( 'package.json' ) )
8
+ package_json = JSON . parse ( package_json_path . read )
9
+ dependencies = package_json [ 'dependencies' ] || { }
10
+
11
+ if dependencies [ '@inertiajs/react' ]
11
12
'react'
12
- when %r{@inertiajs/svelte}
13
- package . match? ( /"svelte": "\^ 5/ ) ? 'svelte' : 'svelte4'
14
- when %r{@inertiajs/vue3}
13
+ elsif dependencies [ '@inertiajs/svelte' ]
14
+ version = dependencies [ 'svelte' ] . gsub ( /[\^ ~]/ , '' ) # Remove ^ or ~ from version
15
+ version . start_with? ( '5' ) ? 'svelte' : 'svelte4'
16
+ elsif dependencies [ '@inertiajs/vue3' ]
15
17
'vue'
16
18
else
17
19
Thor ::Shell ::Basic . new . say_error 'Could not determine the Inertia.js framework you are using.'
You can’t perform that action at this time.
0 commit comments