@@ -26,13 +26,17 @@ OptionParser.new do |opts|
26
26
opts . on ( '--[no-]tailwind' , 'Enable/disable Tailwind' ) do |t |
27
27
options [ :tailwind ] = t
28
28
end
29
+
30
+ opts . on ( '--inertia-version VERSION' , 'Specify Inertia version' ) do |v |
31
+ options [ :inertia_version ] = v
32
+ end
29
33
end . parse!
30
34
31
35
# Build generator args string
32
36
generator_args = "--framework=#{ options [ :framework ] } "
33
37
generator_args += ' --typescript' if options [ :typescript ]
34
- generator_args += ' --install-vite'
35
- generator_args += ' --install-tailwind' if options [ :tailwind ]
38
+ generator_args += ' --tailwind' if options [ :tailwind ]
39
+ generator_args += " --inertia-version= #{ options [ :inertia_version ] } " if options [ :inertia_version ]
36
40
37
41
# Setup paths relative to project root
38
42
project_root = File . expand_path ( '..' , __dir__ )
@@ -57,25 +61,28 @@ system("rails new #{app_dir} -J")
57
61
# Install and configure with caching
58
62
Dir . chdir ( app_dir ) do
59
63
# Configure bundler to use cache in project root
60
- system ( "bundle config set --local path '#{ gem_cache } '" )
64
+ system ( "bundle config set --local path '#{ gem_cache } '" , exception : true )
61
65
62
66
# Configure npm to use cache in project root
63
- system ( "npm config set cache '#{ npm_cache } '" )
67
+ system ( "npm config set cache '#{ npm_cache } '" , exception : true )
64
68
65
69
# Install dependencies
66
- system ( 'bundle add inertia_rails --path ../../' )
67
- system ( 'bundle add bcrypt' )
68
- system ( 'bin/rails active_storage:install' )
70
+ system ( 'bundle add inertia_rails --path ../../' , exception : true )
71
+ system ( 'bundle add bcrypt' , exception : true )
72
+ system ( 'bin/rails active_storage:install' , exception : true )
69
73
70
74
# Run install generator with configured options
71
- system ( "bin/rails g inertia:install --no-interactive --force #{ generator_args } " )
75
+ system ( "bin/rails g inertia:install --no-interactive --force --vite #{ generator_args } --verbose" , exception : true )
72
76
73
77
# Generate a scaffold
74
- system ( 'bin/rails g inertia:scaffold user name email admin:boolean password:digest avatar:attachment' )
75
- system ( 'bin/rails g inertia:scaffold post content:text published_at:date gallery:attachments' )
76
- system ( 'bin/rails db:migrate' )
78
+ system ( 'bin/rails g inertia:scaffold user name email admin:boolean password:digest avatar:attachment' , exception : true )
79
+ system ( 'bin/rails g inertia:scaffold post content:text published_at:date gallery:attachments' , exception : true )
80
+ system ( 'bin/rails db:migrate' , exception : true )
77
81
78
82
# Run tests
79
- system ( 'bin/rails test' )
80
- system ( 'bin/rails test:system' )
83
+ system ( 'bin/rails test' , exception : true )
84
+ system ( 'bin/rails test:system' , exception : true )
85
+
86
+ # Lint code
87
+ system ( 'npm run check' , exception : true ) if options [ :typescript ]
81
88
end
0 commit comments