From 278b173772d0530089708c2913924c41fed21747 Mon Sep 17 00:00:00 2001 From: Trevor John Date: Tue, 10 Dec 2024 09:03:10 -0500 Subject: [PATCH] Add puma plugin on install --- lib/install/bun/install.rb | 5 +++++ lib/install/esbuild/install.rb | 5 +++++ lib/install/rollup/install.rb | 5 +++++ lib/install/webpack/install.rb | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/lib/install/bun/install.rb b/lib/install/bun/install.rb index 707fea1..80c533c 100644 --- a/lib/install/bun/install.rb +++ b/lib/install/bun/install.rb @@ -28,3 +28,8 @@ copy_file "#{__dir__}/.gitattributes", ".gitattributes" end say %(Run `git config diff.lockb.textconv bun && git config diff.lockb.binary true` to enable pretty diffs for Bun's .lockb file), :green + +if (puma_config_path = Rails.root.join("config/puma.rb")).exist? + say %(Adding plugin to puma.rb) + insert_into_file puma_config_path, %|\nplugin :bun if ENV.fetch("RAILS_ENV", "development") == "development"|, after: "plugin :tmp_restart" +end diff --git a/lib/install/esbuild/install.rb b/lib/install/esbuild/install.rb index a9f91bc..ab931e6 100644 --- a/lib/install/esbuild/install.rb +++ b/lib/install/esbuild/install.rb @@ -17,3 +17,8 @@ else say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green end + +if (puma_config_path = Rails.root.join("config/puma.rb")).exist? + say %(Adding plugin to puma.rb) + insert_into_file puma_config_path, %|\nplugin :yarn if ENV.fetch("RAILS_ENV", "development") == "development"|, after: "plugin :tmp_restart" +end diff --git a/lib/install/rollup/install.rb b/lib/install/rollup/install.rb index ef98c48..e6c575a 100644 --- a/lib/install/rollup/install.rb +++ b/lib/install/rollup/install.rb @@ -18,3 +18,8 @@ else say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green end + +if (puma_config_path = Rails.root.join("config/puma.rb")).exist? + say %(Adding plugin to puma.rb) + insert_into_file puma_config_path, %|\nplugin :yarn if ENV.fetch("RAILS_ENV", "development") == "development"|, after: "plugin :tmp_restart" +end diff --git a/lib/install/webpack/install.rb b/lib/install/webpack/install.rb index 665f4cc..3fe7972 100644 --- a/lib/install/webpack/install.rb +++ b/lib/install/webpack/install.rb @@ -18,3 +18,8 @@ else say %(Add "scripts": { "build": "#{build_script}" } to your package.json), :green end + +if (puma_config_path = Rails.root.join("config/puma.rb")).exist? + say %(Adding plugin to puma.rb) + insert_into_file puma_config_path, %|\nplugin :yarn if ENV.fetch("RAILS_ENV", "development") == "development"|, after: "plugin :tmp_restart" +end