jets 3.1.4 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50e281f1856a1a82508629d805afe52156c44dc360f38d49528ca67e586ae8a4
4
- data.tar.gz: ee5c33fe1a4f6929d1b285ba6a16acbfedcba1f229f34501f45c0983d4c71d6f
3
+ metadata.gz: fc8976a98ceaa55f97512b3b0e78cec5f28e1d0ade29d23270894cbcfa1ef5c3
4
+ data.tar.gz: 149caed9e86daea3f45e745e6f32c28aa0a15b6b938237305e41bc85c774adc4
5
5
  SHA512:
6
- metadata.gz: 531f6ccbc1f750cd08b4ac8575017c12de6f21104d014b983a14270e9b6a2760e097a03c5672de4ec989cbbefb52cf6f25d37a2a2459743c2c49e72c1b715985
7
- data.tar.gz: 116483cc99bb26c464de5665a7abfaba09c95710a298026a25acfbcb4c42bfce0df48a6efba6f937031fb54db7b91485f83e18b0c048ec4c10837682c89d8076
6
+ metadata.gz: e9a49470b973e8b927c5921a5e373f18d66141d2af0c288fa6a2d0cac4f59fa7a534e1e52bf949d56482f8987843b9f5628d3699f0c27cf4c9cc9f271d6a33c8
7
+ data.tar.gz: 43e8734b1f3e7b2a7cfb16a1c4d74957fac5e4c1deb090d816d003655775374a8e3c03d473dbd7bc2166a05412562d74f811fe6dbe944237a958c9428f76167a
data/CHANGELOG.md CHANGED
@@ -3,6 +3,11 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [3.1.5] - 2022-08-08
7
+ - [#628](https://github.com/boltops-tools/jets/pull/628) Multiple Databases
8
+ - [#629](https://github.com/boltops-tools/jets/pull/629) loosen zeitwerk dependency in generated project Gemfile
9
+ - [#630](https://github.com/boltops-tools/jets/pull/630) compile assets with WEBPACKER_ASSET_HOST as s3 endpoint url
10
+
6
11
  ## [3.1.4] - 2022-07-02
7
12
  - [#627](https://github.com/boltops-tools/jets/pull/627) use >= for most gem dependencies
8
13
 
@@ -77,10 +77,11 @@ class Jets::Application
77
77
  config.inflections.irregular = {}
78
78
 
79
79
  config.assets = ActiveSupport::OrderedOptions.new
80
- config.assets.folders = %w[assets images packs]
81
80
  config.assets.base_url = nil # IE: https://cloudfront.com/my/base/path
82
- config.assets.max_age = 3600
83
81
  config.assets.cache_control = nil # IE: public, max-age=3600 , max_age is a shorter way to set cache_control.
82
+ config.assets.folders = %w[assets images packs]
83
+ config.assets.max_age = 3600
84
+ config.assets.webpacker_asset_host = "s3_endpoint" # true = use conventional by default
84
85
 
85
86
  config.ruby = ActiveSupport::OrderedOptions.new
86
87
 
data/lib/jets/booter.rb CHANGED
@@ -94,11 +94,23 @@ class Jets::Booter
94
94
  # `show processlist` until after a query. Have confirmed that the connection is reused and the connection count stays
95
95
  # the same.
96
96
  def connect_db
97
- primary_hash_config = ActiveRecord::Base.configurations.configs_for(env_name: Jets.env).find { |hash_config|
98
- hash_config.name == "primary"
99
- }
100
- primary_config = primary_hash_config.configuration_hash # configuration_hash is a normal Ruby Hash
101
- ActiveRecord::Base.establish_connection(primary_config)
97
+ if ActiveRecord::Base.legacy_connection_handling
98
+ primary_hash_config = ActiveRecord::Base.configurations.configs_for(env_name: Jets.env).find { |hash_config|
99
+ hash_config.name == "primary"
100
+ }
101
+
102
+ primary_config = primary_hash_config.configuration_hash # configuration_hash is a normal Ruby Hash
103
+
104
+ ActiveRecord::Base.establish_connection(primary_config)
105
+ else
106
+ configs = ActiveRecord::Base.configurations.configs_for(env_name: Jets.env, include_replicas: true)
107
+
108
+ databases = { }
109
+ databases[:writing] = :primary if configs.any? { |config| config.name == "primary" }
110
+ databases[:reading] = :primary_replica if configs.any? { |config| config.name == "primary_replica" }
111
+
112
+ ActiveRecord::Base.connects_to database: databases
113
+ end
102
114
  end
103
115
 
104
116
  def load_internal_turbines
@@ -205,12 +205,45 @@ module Jets::Builders
205
205
  return unless webpacker_included?
206
206
 
207
207
  sh("yarn install")
208
+
209
+ ENV['WEBPACKER_ASSET_HOST'] = webpacker_asset_host if Jets.config.assets.webpacker_asset_host
208
210
  webpack_command = File.exist?("#{Jets.root}/bin/webpack") ?
209
211
  "bin/webpack" :
210
212
  `which webpack`.strip
211
213
  sh "JETS_ENV=#{Jets.env} #{webpack_command}"
212
214
  end
213
215
 
216
+ # Different url for these. Examples:
217
+ #
218
+ # webpacker_asset_host https://demo-dev-s3bucket-lw5vq7ht8ip4.s3.us-west-2.amazonaws.com/jets/public/packs/media/images/boltops-0dd1c6bd.png
219
+ # s3_base_url https://s3-us-west-2.amazonaws.com/demo-dev-s3bucket-lw5vq7ht8ip4/jets/packs/media/images/boltops-0dd1c6bd.png
220
+ #
221
+ # Interesting: webpacker_asset_host works but s3_base_url does not for CORs. IE: reactjs or vuejs requests
222
+ # Thinking AWS configures the non-subdomain url endpoint to be more restrictive.
223
+ #
224
+ def webpacker_asset_host
225
+ # Allow user to set assets.webpacker_asset_host
226
+ #
227
+ # Jets.application.configure do
228
+ # config.assets.webpacker_asset_host = "https://cloudfront.com/my/base/path"
229
+ # end
230
+ #
231
+ assets = Jets.config.assets
232
+ return assets.webpacker_asset_host if assets.webpacker_asset_host && assets.webpacker_asset_host != "s3_endpoint"
233
+ return assets.base_url if assets.base_url
234
+
235
+ # By default, will use the s3 url endpoint directly by convention
236
+ return unless assets.webpacker_asset_host == "s3_endpoint"
237
+
238
+ region = Jets.aws.region
239
+
240
+ asset_base_url = region == 'us-east-1' ?
241
+ "https://#{s3_bucket}.s3.amazonaws.com" :
242
+ "https://#{s3_bucket}.s3.#{region}.amazonaws.com"
243
+
244
+ "#{asset_base_url}/jets/public" # s3_base_url
245
+ end
246
+
214
247
  def webpacker_included?
215
248
  # Old code, leaving around for now:
216
249
  # Thanks: https://stackoverflow.com/questions/4195735/get-list-of-gems-being-used-by-a-bundler-project
@@ -18,7 +18,7 @@ gem "mysql2", "~> 0.5.3"
18
18
  <% unless options[:mode] == 'job' -%>
19
19
  gem "dynomite"
20
20
  <% end -%>
21
- gem "zeitwerk", "~> 2.5.0"
21
+ gem "zeitwerk", ">= 2.5.0"
22
22
 
23
23
  # development and test groups are not bundled as part of the deployment
24
24
  group :development, :test do
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "3.1.4"
2
+ VERSION = "3.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-02 00:00:00.000000000 Z
11
+ date: 2022-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer