From b4f14e83ff22dc04a1cf51c3f89910dd3b6b7b06 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Tue, 23 Jan 2024 16:48:39 +0100 Subject: [PATCH 1/2] Append to .gitignore only when file exists This prevent the following error when the `.gitignore` file is not present, for example when creating sandbox app: Rails::Generators::Error: The template [/path/to/solidus/admin/lib/solidus_admin/install_tailwindcss.rb] could not be loaded. Error: The file /path/to/solidus/sandbox/.gitignore does not appear to exist (Rails::Generators::Error) Caused by: Thor::Error: The file /path/to/solidus/sandbox/.gitignore does not appear to exist (Thor::Error) --- admin/lib/solidus_admin/install_tailwindcss.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/admin/lib/solidus_admin/install_tailwindcss.rb b/admin/lib/solidus_admin/install_tailwindcss.rb index d6267684cf9..1b882a068ed 100644 --- a/admin/lib/solidus_admin/install_tailwindcss.rb +++ b/admin/lib/solidus_admin/install_tailwindcss.rb @@ -73,7 +73,9 @@ end RUBY -append_file ".gitignore", "app/assets/builds/solidus_admin/" +if Rails.root.join(".gitignore").exist? + append_file ".gitignore", "app/assets/builds/solidus_admin/" +end unless Rails.root.join("Procfile.dev").exist? create_file "Procfile.dev", <<~YAML From 17647e5afaa64f65bc6b84beaa568f138b3f672c Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Tue, 23 Jan 2024 17:21:49 +0100 Subject: [PATCH 2/2] Run `bundle add solidus_admin` only when missing This avoids errors when running the installer on apps that already include that gem, for example when creating the sandbox. --- core/lib/generators/solidus/install/install_generator.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/lib/generators/solidus/install/install_generator.rb b/core/lib/generators/solidus/install/install_generator.rb index c8c16452dfa..44794d4b35e 100644 --- a/core/lib/generators/solidus/install/install_generator.rb +++ b/core/lib/generators/solidus/install/install_generator.rb @@ -179,7 +179,9 @@ def install_solidus_admin return unless options[:admin_preview] say_status :installing, "SolidusAdmin", :blue - bundle_command 'add solidus_admin -v ">= 0.2"' + unless File.read(app_path.join('Gemfile')).include?('solidus_admin') + bundle_command 'add solidus_admin -v ">= 0.2"' + end generate 'solidus_admin:install' end