@@ -26,13 +26,17 @@ OptionParser.new do |opts|
2626 opts . on ( '--[no-]tailwind' , 'Enable/disable Tailwind' ) do |t |
2727 options [ :tailwind ] = t
2828 end
29+
30+ opts . on ( '--inertia-version VERSION' , 'Specify Inertia version' ) do |v |
31+ options [ :inertia_version ] = v
32+ end
2933end . parse!
3034
3135# Build generator args string
3236generator_args = "--framework=#{ options [ :framework ] } "
3337generator_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 ]
3640
3741# Setup paths relative to project root
3842project_root = File . expand_path ( '..' , __dir__ )
@@ -57,25 +61,28 @@ system("rails new #{app_dir} -J")
5761# Install and configure with caching
5862Dir . chdir ( app_dir ) do
5963 # 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 )
6165
6266 # 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 )
6468
6569 # 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 )
6973
7074 # 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 )
7276
7377 # 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 )
7781
7882 # 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 ]
8188end
0 commit comments