railpack 1.2.12 → 1.2.13

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: 21ff002773c07ac74af2a193632392fd1530c3ff81c1fcc4e98fc6aee54c685a
4
- data.tar.gz: a1e8080cb6ad3b1e0ec5918212c0f412cb44e8a2d510848b5e400e11e35e3d8a
3
+ metadata.gz: 7d46c8ec7498a0fb02c689c31efebb07356d887ceb4f2c71b37bc1df4fbf88c2
4
+ data.tar.gz: 2c72739906a7b8639929cf79262d5da8df504449e33c7b9aee6a49af25058550
5
5
  SHA512:
6
- metadata.gz: 3b1167de6777d81b2ba4d1818ad323eba5310fc32e0cf592f777db16a9d276c75451a6c2e372570e2d367e8fabb91055efe68e356d68932f6074c72ef535e47d
7
- data.tar.gz: 07f6a5a9438f11a53cf552c4bdc302a9be6a83938d595d416a3051ec4c2398ca2569ad9c9882413acfb1aa165581a7c872a4cdb90a5c57fc523079732fc1750f
6
+ metadata.gz: 95345502072a45a61e3e1b4524c9a49958a7d67c9f99164ddf9e57cefb3fd7beebefcc38e2fd8869bf080151f37003a267a2e92998b9681ef6794b7ed6f5559d
7
+ data.tar.gz: c5a2e13d273eb5a3c765fa02cc0287b35a5600af8723564bef78caa571a5ff34e7cd690d56b61a5695264881fb0c538858088e7fc46e86a8561ad32415044431
@@ -1,6 +1,24 @@
1
1
  require "yaml"
2
2
 
3
3
  module Railpack
4
+ # Configuration handler for Railpack bundling settings.
5
+ #
6
+ # This class provides immutable, environment-aware configuration management with:
7
+ # - YAML-based config loading from config/railpack.yml
8
+ # - Three-level merge order: defaults → bundler-specific → environment-specific
9
+ # - Deep-frozen configs for immutability and thread safety
10
+ # - Explicit accessors for common config keys with method_missing fallback
11
+ #
12
+ # Example config/railpack.yml:
13
+ # default:
14
+ # bundler: bun
15
+ # outdir: app/assets/builds
16
+ # development:
17
+ # sourcemap: true
18
+ # production:
19
+ # minify: true
20
+ #
21
+ # All configs are immutable after loading. Set values in config/railpack.yml only.
4
22
  class Config
5
23
  class Error < StandardError; end
6
24
 
@@ -41,11 +59,21 @@ module Railpack
41
59
  # Merge: default <- bundler <- environment
42
60
  merged = deep_merge(deep_merge(base_config, bundler_config), env_config)
43
61
 
62
+ # Validate critical config values
63
+ validate_config!(merged, env)
64
+
44
65
  # Deep freeze for immutability
45
66
  deep_freeze(merged)
46
67
  end
47
68
  end
48
69
 
70
+ # Reload configuration (useful for development/testing)
71
+ def reload!
72
+ @config = load_config
73
+ @merged_cache.clear
74
+ self
75
+ end
76
+
49
77
  def bundler(env = current_env)
50
78
  # Look directly in config to avoid circular dependency
51
79
  env_config = @config[env.to_s] || {}
@@ -179,6 +207,26 @@ module Railpack
179
207
  end
180
208
  end
181
209
 
210
+ def validate_config!(config, env)
211
+ # Validate critical config values in production
212
+ if env.to_s == 'production'
213
+ if config['outdir'].nil? || config['outdir'].to_s.empty?
214
+ raise Error, "Production config must specify 'outdir'"
215
+ end
216
+
217
+ bundler_name = config['bundler']
218
+ if bundler_name.nil? || bundler_name.to_s.empty?
219
+ raise Error, "Production config must specify 'bundler'"
220
+ end
221
+ end
222
+
223
+ # Validate bundler name exists in known bundlers
224
+ bundler_name = config['bundler']
225
+ if bundler_name && !@config.key?(bundler_name)
226
+ warn "Warning: Unknown bundler '#{bundler_name}'. Known bundlers: #{@config.keys.grep(/^(bun|esbuild|rollup|webpack)$/).join(', ')}"
227
+ end
228
+ end
229
+
182
230
  def deep_freeze(object)
183
231
  case object
184
232
  when Hash
@@ -1,3 +1,3 @@
1
1
  module Railpack
2
- VERSION = "1.2.12"
2
+ VERSION = "1.2.13"
3
3
  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.2.12
4
+ version: 1.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - 21tycoons LLC