react-email-rails 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f53daab3807503144d3acc647a0d82c164e7c580a01a6c515131eee0f1dbfd9
4
- data.tar.gz: 4e6529c8d47c16201f929c4c3a4486ec2d8bcf5965ac459b0c99b47bd8d88760
3
+ metadata.gz: d5d324a8d629ad252aa11946478dd3b610c78920675bb027aedabf8c96c36239
4
+ data.tar.gz: eaa690f2caecb96ef322bac6e587bb1dbf2bfe51e9c601a8b1b9dceb4d43d7a8
5
5
  SHA512:
6
- metadata.gz: 395b4fb684b90dc42d154d2a85138ac4aad707e0789f3e5d980a5fd809049643e9255db6bdb6b255650e71288d6c4a8c2d9e81e3b01841e9649991844fe0a2f1
7
- data.tar.gz: 0360e86df8ed619d6f6ab4294bbbd2c0659bb942d0cb906c68389b17e1541515e1ba1ae5c0f8cb6a8b2ae439d4c87d4d1b649c8e609f8f62893834351c867735
6
+ metadata.gz: ca696714d6b95038f96fc579c8040fb9eaf6e98b213ddf42ba7ab92fdb49e5ab8d1dc3bb6b8a095d8fc91573314df6f4ae06136c4af41f3ec9cf66ea2bd22c85
7
+ data.tar.gz: 77c513dfda5a19d5296396433d4adb79e198cffcda518311e4fe5f780efb19f532baba3743dd0b0d08928528eece7d74047280f0d3bde34a89a565ab06ddd975
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.3
4
+
5
+ - Remove the `verify_render_on_boot` configuration option, which only logged on failure and duplicated the render-time `ReactEmailRails::RenderError`.
6
+ - Add the `react_email_rails:verify` rake task that checks the renderer and exits non-zero on failure.
7
+
3
8
  ## 0.1.2
4
9
 
5
10
  - Support Vite 8 hook filters while keeping production email bundles standalone by default.
data/README.md CHANGED
@@ -19,7 +19,7 @@ Build and send emails using React and Rails — a seamless integration between [
19
19
 
20
20
  ## Why
21
21
 
22
- Building HTML emails is painfully archaic. [React Email](https://react.email) is a collection of unstyled components for building emails with React, Tailwind, and TypeScript. This gem brings that power directly into your Rails app: write emails as React components and send them through Action Mailer.
22
+ Building HTML emails is painfully archaic. [React Email](https://react.email) is a collection of unstyled components for building emails with React, Tailwind, and TypeScript. This gem brings that power directly into your Rails app. Write emails as React components, send them through Action Mailer, and recipients get automatically generated HTML and text emails.
23
23
 
24
24
  ## How
25
25
 
@@ -27,7 +27,7 @@ Building HTML emails is painfully archaic. [React Email](https://react.email) is
27
27
 
28
28
  **In production,** Rails builds a server-side email bundle during `assets:precompile`. The bundled rake task runs an isolated email-only Vite build, using `reactEmailRails()` in your app's Vite config for discovery and options.
29
29
 
30
- Delivery, headers, multipart parts, previews, queues, and callbacks all stay normal Action Mailer. If rendering fails, no email is sent and `ReactEmailRails::RenderError` is raised.
30
+ React Email Rails automatically renders both HTML and plain-text versions from the same component. Delivery, headers, previews, queues, and callbacks all stay normal Action Mailer. If rendering fails, no email is sent and `ReactEmailRails::RenderError` is raised.
31
31
 
32
32
  ## Status
33
33
 
@@ -308,7 +308,6 @@ If the defaults don't fit, override them in `config/initializers/react_email_rai
308
308
  | `render_timeout` | `10` seconds |
309
309
  | `render_process_max_requests` | `1_000` |
310
310
  | `on_render_error` | `nil` |
311
- | `verify_render_on_boot` | `false` |
312
311
 
313
312
  #### Prop Transformation
314
313
 
@@ -391,8 +390,6 @@ Every render emits an [ActiveSupport::Notifications](https://guides.rubyonrails.
391
390
 
392
391
  ```ruby
393
392
  ActiveSupport::Notifications.subscribe("render.react-email-rails") do |event|
394
- next if event.payload[:exception]
395
-
396
393
  Rails.logger.info("[react-email-rails] Rendered #{event.payload[:component]} (Duration: #{event.duration.round}ms | Size: #{event.payload[:html_bytes]} bytes)")
397
394
  end
398
395
  ```
@@ -495,18 +492,23 @@ The Ruby gem and npm package must stay on the same version. The renderer include
495
492
 
496
493
  The build command preserves `emails.path`, `emails.extension`, `emails.ignore`, `standalone`, and email-only `vite` options.
497
494
 
498
- ### Runtime Dependencies
495
+ ### Renderer Verification
496
+
497
+ To confirm the renderer is ready before relying on it, run:
499
498
 
500
- For runtime dependency tradeoffs, see [Standalone Builds](#standalone-builds).
499
+ ```sh
500
+ bin/rails react_email_rails:verify
501
+ ```
501
502
 
502
- ### Boot Verification
503
+ It checks that the render command runs and that the npm package version matches the gem, then exits non-zero with an actionable message on failure. Wire it into your CI or release step to catch a missing bundle or version drift before a deploy ships — a renderer failure won't otherwise surface until the first email is sent.
503
504
 
504
- Boot verification is disabled by default. If you want the app to check the renderer during boot, scope it to the same processes that build or ship the bundle:
505
+ For programmatic checks (for example, a health endpoint), `ReactEmailRails.healthy?` returns a boolean. If you specifically want a check at boot, call it from your own initializer and scope it to the processes that send mail so others don't pay the cost:
505
506
 
506
507
  ```ruby
507
- ReactEmailRails.configure do |config|
508
- config.render_mode = :persistent if Rails.env.production? && Sidekiq.server?
509
- config.verify_render_on_boot = -> { Rails.env.production? && Sidekiq.server? }
508
+ Rails.application.config.after_initialize do
509
+ if Rails.env.production? && Sidekiq.server? && !ReactEmailRails.healthy?
510
+ Rails.logger.error("[react-email-rails] renderer verification failed")
511
+ end
510
512
  end
511
513
  ```
512
514
 
@@ -27,14 +27,11 @@ class ReactEmailRails::Configuration
27
27
  end
28
28
  end
29
29
 
30
- DEFAULT_VERIFY_RENDER_ON_BOOT = false
31
-
32
30
  attr_accessor(
33
31
  :component_path_resolver,
34
32
  :render_options,
35
33
  :transform_props,
36
34
  :on_render_error,
37
- :verify_render_on_boot,
38
35
  )
39
36
  attr_reader(
40
37
  :render_mode,
@@ -52,15 +49,10 @@ class ReactEmailRails::Configuration
52
49
  config.render_process_max_requests = DEFAULT_RENDER_PROCESS_MAX_REQUESTS
53
50
  config.transform_props = :lower_camel
54
51
  config.on_render_error = nil
55
- config.verify_render_on_boot = DEFAULT_VERIFY_RENDER_ON_BOOT
56
52
  end
57
53
  end
58
54
  end
59
55
 
60
- def verify_render_on_boot?
61
- verify_render_on_boot.respond_to?(:call) ? !!verify_render_on_boot.call : !!verify_render_on_boot
62
- end
63
-
64
56
  def render_mode=(value)
65
57
  if (value.is_a?(Symbol) || value.is_a?(String)) && !RENDER_MODES.key?(value.to_sym)
66
58
  raise(ArgumentError, "Unknown react-email-rails render mode: #{value.inspect}")
@@ -6,13 +6,4 @@ class ReactEmailRails::Railtie < Rails::Railtie
6
6
  end
7
7
 
8
8
  rake_tasks { load(File.expand_path("../tasks/react_email_rails/build.rake", __dir__)) }
9
-
10
- config.after_initialize do
11
- if ReactEmailRails.configuration.verify_render_on_boot? && !ReactEmailRails.healthy?
12
- Rails.logger.error(
13
- "[react-email-rails] render verification failed for command: " \
14
- "#{ReactEmailRails.configuration.send(:resolved_render_command).inspect}",
15
- )
16
- end
17
- end
18
9
  end
@@ -14,6 +14,13 @@ module ReactEmailRails::Tasks
14
14
  FileUtils.rm_rf(Rails.root.join(File.dirname(ReactEmailRails::Configuration::BUNDLE_PATH)))
15
15
  end
16
16
 
17
+ def verify
18
+ return if ReactEmailRails.healthy?
19
+
20
+ command = ReactEmailRails.configuration.send(:resolved_render_command)
21
+ raise("react-email-rails renderer verification failed for command: #{command.inspect}")
22
+ end
23
+
17
24
  private
18
25
 
19
26
  def build_command
@@ -1,3 +1,3 @@
1
1
  module ReactEmailRails
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -4,6 +4,9 @@ namespace(:react_email_rails) do
4
4
 
5
5
  desc("Remove the React Email Rails production bundle")
6
6
  task(clobber: :environment) { ReactEmailRails::Tasks.clobber }
7
+
8
+ desc("Verify the React Email Rails renderer is healthy (exits non-zero on failure)")
9
+ task(verify: :environment) { ReactEmailRails::Tasks.verify }
7
10
  end
8
11
 
9
12
  unless ENV["SKIP_REACT_EMAIL_RAILS_BUILD"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react-email-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Supertape