File tree Expand file tree Collapse file tree 3 files changed +30
-13
lines changed Expand file tree Collapse file tree 3 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -680,19 +680,7 @@ def target_rails_prerelease(self_command = "new")
680
680
end
681
681
682
682
def run_bundle
683
- if bundle_install?
684
- bundle_command ( "install" , "BUNDLE_IGNORE_MESSAGES" => "1" )
685
-
686
- # The vast majority of Rails apps will be deployed on `x86_64-linux`.
687
- platforms = [ "--add-platform=x86_64-linux" ]
688
-
689
- # Users that develop on M1 mac may use docker and would need `aarch64-linux` as well.
690
- platforms << "--add-platform=aarch64-linux" if RUBY_PLATFORM . start_with? ( "arm64" )
691
-
692
- platforms . each do |platform |
693
- bundle_command ( "lock #{ platform } " , "BUNDLE_IGNORE_MESSAGES" => "1" )
694
- end
695
- end
683
+ bundle_command ( "install" , "BUNDLE_IGNORE_MESSAGES" => "1" ) if bundle_install?
696
684
end
697
685
698
686
def run_javascript
@@ -722,6 +710,16 @@ def run_css
722
710
end
723
711
end
724
712
713
+ def add_bundler_platforms
714
+ if bundle_install?
715
+ # The vast majority of Rails apps will be deployed on `x86_64-linux`.
716
+ bundle_command ( "lock --add-platform=x86_64-linux" )
717
+
718
+ # Users that develop on M1 mac may use docker and would need `aarch64-linux` as well.
719
+ bundle_command ( "lock --add-platform=aarch64-linux" ) if RUBY_PLATFORM . start_with? ( "arm64" )
720
+ end
721
+ end
722
+
725
723
def generate_bundler_binstub
726
724
if bundle_install?
727
725
bundle_command ( "binstubs bundler" )
Original file line number Diff line number Diff line change @@ -539,6 +539,7 @@ def finish_template
539
539
540
540
public_task :apply_rails_template
541
541
public_task :run_bundle
542
+ public_task :add_bundler_platforms
542
543
public_task :generate_bundler_binstub
543
544
public_task :run_javascript
544
545
public_task :run_hotwire
Original file line number Diff line number Diff line change @@ -1085,6 +1085,24 @@ def test_apply_rails_template_class_method_runs_bundle_and_after_bundle_callback
1085
1085
end
1086
1086
end
1087
1087
1088
+ def test_apply_rails_template_class_method_does_not_add_bundler_platforms
1089
+ run_generator
1090
+
1091
+ FileUtils . cd ( destination_root ) do
1092
+ FileUtils . touch ( "lib/template.rb" )
1093
+
1094
+ generator_class . no_commands do
1095
+ # There isn't an easy way to access the generator instance in order to
1096
+ # assert that we don't run `bundle lock --add-platform`, so the
1097
+ # following assertion assumes that the sole call to `bundle_command` is
1098
+ # for `bundle install`.
1099
+ assert_called_on_instance_of ( generator_class , :bundle_command , times : 1 ) do
1100
+ quietly { generator_class . apply_rails_template ( "lib/template.rb" , destination_root ) }
1101
+ end
1102
+ end
1103
+ end
1104
+ end
1105
+
1088
1106
def test_gitignore
1089
1107
run_generator
1090
1108
You can’t perform that action at this time.
0 commit comments