railpack 1.5.0 → 1.6.1

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: 3137ba9f8b5a180b12de2863b51222fecc2b68acd4bbe0d810a5feb8fb57ff0a
4
- data.tar.gz: f353a8bb86d73b30492598a2be5208805a63ef32a819f2fcf5b1540f572c9d07
3
+ metadata.gz: ae1510b21cf1b33c253babc803824ea14ed535b6c296ad2b5d2758771294d5f0
4
+ data.tar.gz: a634dd8065bc537c53a25f457921f6303c416c1bf6e2c1195681e1f1a71b925d
5
5
  SHA512:
6
- metadata.gz: 97c615a83cbed4d7b989dc44e9cb1162923679f7604d661138772cc9b610c95cddbd8d01132a8ea28afe395dfbcfe97da799ed6e48e95952438fdbba4e8c3d3f
7
- data.tar.gz: 4300793b2f4a5739bf2b8f7caeb326be5de647bc831fb9b41544d5e7dc5e4deedb0bfc06453d87319dfb5541d2b57fe234dda1e5a1b9a1d822b1e23c7a952c40
6
+ metadata.gz: 2e3ab7c0d56e5a6f5c0f8a57078fad1fdf3749e254e551fd1372453711175a6ed0f74f0ce3896ddf0405b1c137cc7ede8da34e32a7923d1dbaa213b3fed7789d
7
+ data.tar.gz: e604aacfd2c70ce0bc0a20c25743b956755911ac277df64e3a6c5facefdf57ab78c38e35fc1478d8fe72cd6c821e17f292f3a8fe842e9d2351b246763f7e12de
@@ -9,7 +9,6 @@ module Railpack
9
9
  @config = config
10
10
  end
11
11
 
12
- # Common interface all bundlers must implement
13
12
  def build!(args = [])
14
13
  raise NotImplementedError, "#{self.class.name} must implement #build!"
15
14
  end
@@ -64,79 +63,77 @@ module Railpack
64
63
 
65
64
  private
66
65
 
67
- def bundler_command_overrides
68
- return {} unless config.respond_to?(:bundler_command_overrides)
66
+ def bundler_command_overrides
67
+ return {} unless config.respond_to?(:bundler_command_overrides)
69
68
 
70
- begin
71
- config.bundler_command_overrides(current_env) || {}
72
- rescue NoMethodError, KeyError, TypeError, ArgumentError => e
73
- # Log warning for legitimate config issues, but don't crash
74
- if defined?(Rails) && Rails.logger
75
- Rails.logger.warn "Railpack: Invalid bundler_command_overrides config (#{e.class}: #{e.message}) - using defaults"
69
+ begin
70
+ config.bundler_command_overrides(current_env) || {}
71
+ rescue NoMethodError, KeyError, TypeError, ArgumentError => e
72
+ # Log warning for legitimate config issues, but don't crash
73
+ if defined?(Rails) && Rails.logger
74
+ Rails.logger.warn "Railpack: Invalid bundler_command_overrides config (#{e.class}: #{e.message}) - using defaults"
75
+ end
76
+ {}
77
+ rescue => e
78
+ # Re-raise unexpected errors (don't hide bugs)
79
+ raise e
76
80
  end
77
- {}
78
- rescue => e
79
- # Re-raise unexpected errors (don't hide bugs)
80
- raise e
81
81
  end
82
- end
83
-
84
- protected
85
-
86
- def execute(command_array)
87
- system(*command_array)
88
- end
89
82
 
90
- def execute!(command_array)
91
- stdout, stderr, status = Open3.capture3(*command_array)
83
+ def current_env
84
+ if defined?(Rails) && Rails.respond_to?(:env)
85
+ Rails.env
86
+ else
87
+ :development
88
+ end
89
+ end
92
90
 
93
- unless status.success?
94
- command_string = Shellwords.join(command_array)
91
+ protected
95
92
 
96
- error_msg = "Command failed"
97
- error_msg += " (exit status: #{status.exitstatus})" if status.exitstatus
98
- error_msg += " (terminated by signal: #{status.termsig})" if status.termsig
99
- error_msg += ": #{command_string}"
93
+ def execute(command_array)
94
+ system(*command_array)
95
+ end
100
96
 
101
- # Include stderr output for debugging (truncate if too long)
102
- if stderr && !stderr.empty?
103
- stderr_lines = stderr.split("\n")
104
- if stderr_lines.size > 10
105
- stderr_preview = stderr_lines.first(5).join("\n") + "\n... (#{stderr_lines.size - 5} more lines)"
106
- else
107
- stderr_preview = stderr
97
+ def execute!(command_array)
98
+ stdout, stderr, status = Open3.capture3(*command_array)
99
+
100
+ unless status.success?
101
+ command_string = Shellwords.join(command_array)
102
+
103
+ error_msg = "Command failed"
104
+ error_msg += " (exit status: #{status.exitstatus})" if status.exitstatus
105
+ error_msg += " (terminated by signal: #{status.termsig})" if status.termsig
106
+ error_msg += ": #{command_string}"
107
+
108
+ # Include stderr output for debugging (truncate if too long)
109
+ if stderr && !stderr.empty?
110
+ stderr_lines = stderr.split("\n")
111
+ if stderr_lines.size > 10
112
+ stderr_preview = stderr_lines.first(5).join("\n") + "\n... (#{stderr_lines.size - 5} more lines)"
113
+ else
114
+ stderr_preview = stderr
115
+ end
116
+ error_msg += "\n\nSTDERR:\n#{stderr_preview}"
108
117
  end
109
- error_msg += "\n\nSTDERR:\n#{stderr_preview}"
110
- end
111
118
 
112
- raise Error, error_msg
113
- end
114
-
115
- status.success?
116
- end
119
+ raise Error, error_msg
120
+ end
117
121
 
118
- # Build full command args by merging config flags/args with passed args
119
- def build_command_args(operation, args = [])
120
- env = current_env
121
- if config.respond_to?("#{operation}_args")
122
- config_args = config.send("#{operation}_args", env) || []
123
- config_flags = config.send("#{operation}_flags", env) || []
124
- config_args + config_flags + args
125
- else
126
- # Fallback for hash configs (used in tests)
127
- args
122
+ status.success?
128
123
  end
129
- end
130
124
 
131
- private
132
-
133
- def current_env
134
- if defined?(Rails) && Rails.respond_to?(:env)
135
- Rails.env
136
- else
137
- :development
125
+ # Build full command args by merging config flags/args with passed args
126
+ def build_command_args(operation, args = [])
127
+ env = current_env
128
+ if config.respond_to?("#{operation}_args")
129
+ config_args = config.send("#{operation}_args", env) || []
130
+ config_flags = config.send("#{operation}_flags", env) || []
131
+ config_args + config_flags + args
132
+ else
133
+ # Fallback for hash configs (used in tests)
134
+ args
135
+ end
138
136
  end
139
- end
140
137
  end
141
138
 
142
139
  # Intermediate base class for NPM-based bundlers (esbuild, rollup, webpack)
@@ -171,10 +168,10 @@ module Railpack
171
168
 
172
169
  private
173
170
 
174
- def detect_package_manager
175
- return "yarn" if File.exist?("yarn.lock")
176
- return "pnpm" if File.exist?("pnpm-lock.yaml") || File.exist?("pnpm-workspace.yaml")
177
- "npm" # default fallback
178
- end
171
+ def detect_package_manager
172
+ return "yarn" if File.exist?("yarn.lock")
173
+ return "pnpm" if File.exist?("pnpm-lock.yaml") || File.exist?("pnpm-workspace.yaml")
174
+ "npm" # default fallback
175
+ end
179
176
  end
180
177
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Railpack
4
+ module Hooks
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ mattr_accessor :error_hooks, default: []
9
+ mattr_accessor :build_start_hooks, default: []
10
+ mattr_accessor :build_complete_hooks, default: []
11
+ end
12
+
13
+ class_methods do
14
+ def on_error(&block)
15
+ error_hooks << block
16
+ end
17
+
18
+ def on_build_start(&block)
19
+ build_start_hooks << block
20
+ end
21
+
22
+ def on_build_complete(&block)
23
+ build_complete_hooks << block
24
+ end
25
+
26
+ def trigger_error(error)
27
+ error_hooks.each { |hook| hook.call(error) }
28
+ end
29
+
30
+ def trigger_build_start(config)
31
+ build_start_hooks.each { |hook| hook.call(config) }
32
+ end
33
+
34
+ def trigger_build_complete(result)
35
+ build_complete_hooks.each { |hook| hook.call(result) }
36
+ end
37
+ end
38
+ end
39
+ end
@@ -128,7 +128,6 @@ module Railpack
128
128
  end
129
129
  end
130
130
 
131
- # Alias for convenience
132
131
  singleton_class.alias_method :enhance, :enhance_assets_precompile
133
132
 
134
133
  private
@@ -1,3 +1,3 @@
1
1
  module Railpack
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.1"
3
3
  end
data/lib/railpack.rb CHANGED
@@ -1,4 +1,3 @@
1
- # Railpack - Multi-bundler asset pipeline for Rails
2
1
  require 'logger'
3
2
 
4
3
  require 'active_support/concern'
data/test/config_test.rb CHANGED
@@ -173,6 +173,8 @@ class ConfigTest < Minitest::Test
173
173
  Object.const_set(:Rails, Module.new)
174
174
  end
175
175
 
176
+ # Reset any memoized @root and override the method
177
+ rails_module.instance_variable_set(:@root, nil)
176
178
  rails_module.define_singleton_method(:root) { Pathname.new(path) }
177
179
  end
178
180
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 21tycoons LLC
@@ -62,6 +62,7 @@ files:
62
62
  - lib/railpack/bundlers/rollup_bundler.rb
63
63
  - lib/railpack/bundlers/webpack_bundler.rb
64
64
  - lib/railpack/config.rb
65
+ - lib/railpack/hooks.rb
65
66
  - lib/railpack/manager.rb
66
67
  - lib/railpack/manifest.rb
67
68
  - lib/railpack/version.rb