jets 2.0.6 → 2.1.0
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/jets.gemspec +6 -6
- data/lib/jets/application.rb +5 -4
- data/lib/jets/booter.rb +35 -24
- data/lib/jets/commands/db/tasks/dummy/app.rb +21 -0
- data/lib/jets/commands/db/tasks/dummy/config.rb +14 -0
- data/lib/jets/commands/db/tasks.rb +2 -12
- data/lib/jets/commands/import/templates/config/database.yml +1 -1
- data/lib/jets/commands/templates/skeleton/config/database.yml.tt +2 -1
- data/lib/jets/turbo/templates/config/database.yml +1 -1
- data/lib/jets/version.rb +1 -1
- metadata +15 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7210442948a1180913859f3afbd0aebb049560adfdf53faf02357c4f299bb246
|
4
|
+
data.tar.gz: b94be0bc50ec242e9c6e908050a4ddd342874e9026cdf12f28ae54e465d12303
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95f6b7c61d0867b09c6af7f099fc84ec3de07defec86707f8aaadc8aac2da318557260b828142133384350163bd0bcbccc0a0f5bd204eb1c2645be0791e9637e
|
7
|
+
data.tar.gz: 0cb91a7f2593103a557a59f0d3d8b2732f9ba196725ed2825d12b34db2f2879e72bff137e8193411aecb0e31522c704bacbf2bbf9b5329242dad514655f38b5d
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
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
|
+
## [2.1.0]
|
7
|
+
- #345 upgrade to use rails 6 components
|
8
|
+
|
6
9
|
## [2.0.6]
|
7
10
|
- #344 controller `helper_method` macro
|
8
11
|
|
data/jets.gemspec
CHANGED
@@ -27,11 +27,11 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_dependency "actionmailer", "~>
|
31
|
-
spec.add_dependency "actionpack", "~>
|
32
|
-
spec.add_dependency "actionview", "~>
|
33
|
-
spec.add_dependency "activerecord", "~>
|
34
|
-
spec.add_dependency "activesupport", "~>
|
30
|
+
spec.add_dependency "actionmailer", "~> 6.0.0"
|
31
|
+
spec.add_dependency "actionpack", "~> 6.0.0"
|
32
|
+
spec.add_dependency "actionview", "~> 6.0.0"
|
33
|
+
spec.add_dependency "activerecord", "~> 6.0.0"
|
34
|
+
spec.add_dependency "activesupport", "~> 6.0.0"
|
35
35
|
spec.add_dependency "aws-sdk-apigateway"
|
36
36
|
spec.add_dependency "aws-sdk-cloudformation"
|
37
37
|
spec.add_dependency "aws-sdk-cloudwatchlogs"
|
@@ -53,7 +53,7 @@ Gem::Specification.new do |spec|
|
|
53
53
|
spec.add_dependency "memoist"
|
54
54
|
spec.add_dependency "mimemagic"
|
55
55
|
spec.add_dependency "rack"
|
56
|
-
spec.add_dependency "railties", "~>
|
56
|
+
spec.add_dependency "railties", "~> 6.0.0" # for ActiveRecord database_tasks.rb
|
57
57
|
spec.add_dependency "rainbow"
|
58
58
|
spec.add_dependency "recursive-open-struct"
|
59
59
|
spec.add_dependency "shotgun"
|
data/lib/jets/application.rb
CHANGED
@@ -175,15 +175,16 @@ class Jets::Application
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
def load_db_config
|
178
|
+
def load_db_config(database_yml="#{Jets.root}/config/database.yml")
|
179
179
|
config.database = {}
|
180
180
|
|
181
181
|
Jets::Dotenv.load!
|
182
|
-
database_yml = "#{Jets.root}/config/database.yml"
|
183
182
|
if File.exist?(database_yml)
|
183
|
+
require "active_record/database_configurations" # lazy require
|
184
184
|
text = Jets::Erb.result(database_yml)
|
185
|
-
|
186
|
-
|
185
|
+
db_configs = YAML.load(text)
|
186
|
+
configurations = ActiveRecord::DatabaseConfigurations.new(db_configs)
|
187
|
+
config.database = configurations
|
187
188
|
end
|
188
189
|
end
|
189
190
|
|
data/lib/jets/booter.rb
CHANGED
@@ -23,16 +23,48 @@ class Jets::Booter
|
|
23
23
|
run_turbines(:after_initializers)
|
24
24
|
Jets.application.finish!
|
25
25
|
|
26
|
-
#
|
27
|
-
|
26
|
+
setup_db # establish db connections in Lambda Execution Context.
|
27
|
+
# The eager load calls connects_to in models and establish those connections in Lambda Execution Context also.
|
28
|
+
Jets::Autoloaders.main.eager_load # Eager load project code. Rather have user find out early than later on AWS Lambda.
|
28
29
|
|
29
|
-
setup_db
|
30
30
|
# TODO: Figure out how to build middleware during Jets.boot without breaking jets new and webpacker:install
|
31
31
|
# build_middleware_stack
|
32
32
|
|
33
33
|
@booted = true
|
34
34
|
end
|
35
35
|
|
36
|
+
# Using ActiveRecord outside of Rails, so we need to set up the db connection ourself.
|
37
|
+
#
|
38
|
+
# Only connects to database for ActiveRecord and when config/database.yml exists.
|
39
|
+
# Dynomite handles connecting to the clients lazily.
|
40
|
+
def setup_db
|
41
|
+
return unless File.exist?("#{Jets.root}/config/database.yml")
|
42
|
+
|
43
|
+
db_configs = Jets.application.config.database
|
44
|
+
# DatabaseTasks.database_configuration for db:create db:migrate tasks
|
45
|
+
# Documented in DatabaseTasks that this is the right way to set it when
|
46
|
+
# using ActiveRecord rake tasks outside of Rails.
|
47
|
+
ActiveRecord::Tasks::DatabaseTasks.database_configuration = db_configs
|
48
|
+
|
49
|
+
if db_configs[Jets.env].blank?
|
50
|
+
abort("ERROR: config/database.yml exists but no environment section configured for #{Jets.env}")
|
51
|
+
end
|
52
|
+
ActiveRecord::Base.configurations = db_configs
|
53
|
+
connect_db
|
54
|
+
end
|
55
|
+
|
56
|
+
# Eager connect to database, so connections are established in the Lambda Execution Context and get reused.
|
57
|
+
# Interestingly, the connections info is stored in the shared state but the connection doesnt show up on
|
58
|
+
# `show processlist` until after a query. Have confirmed that the connection is reused and the connection count stays
|
59
|
+
# the same.
|
60
|
+
def connect_db
|
61
|
+
primary_hash_config = ActiveRecord::Base.configurations.configs_for(env_name: Jets.env).find { |hash_config|
|
62
|
+
hash_config.spec_name == "primary"
|
63
|
+
}
|
64
|
+
primary_config = primary_hash_config.config # config is a normal Ruby Hash
|
65
|
+
ActiveRecord::Base.establish_connection(primary_config)
|
66
|
+
end
|
67
|
+
|
36
68
|
def load_internal_turbines
|
37
69
|
Dir.glob("#{__dir__}/internal/turbines/**/*.rb").each do |path|
|
38
70
|
Jets::Autoloaders.once.preload(path)
|
@@ -72,27 +104,6 @@ class Jets::Booter
|
|
72
104
|
Jets.application.build_stack
|
73
105
|
end
|
74
106
|
|
75
|
-
# Only connects connect to database for ActiveRecord and when
|
76
|
-
# config/database.yml exists.
|
77
|
-
# Dynomite handles connecting to the clients lazily.
|
78
|
-
def setup_db
|
79
|
-
return unless File.exist?("#{Jets.root}/config/database.yml")
|
80
|
-
|
81
|
-
db_configs = Jets.application.config.database
|
82
|
-
# DatabaseTasks.database_configuration for db:create db:migrate tasks
|
83
|
-
# Documented in DatabaseTasks that this is the right way to set it when
|
84
|
-
# using ActiveRecord rake tasks outside of Rails.
|
85
|
-
ActiveRecord::Tasks::DatabaseTasks.database_configuration = db_configs
|
86
|
-
|
87
|
-
current_config = db_configs[Jets.env]
|
88
|
-
if current_config.blank?
|
89
|
-
abort("ERROR: config/database.yml exists but no environment section configured for #{Jets.env}")
|
90
|
-
end
|
91
|
-
# Using ActiveRecord rake tasks outside of Rails, so we need to set up the
|
92
|
-
# db connection ourselves
|
93
|
-
ActiveRecord::Base.establish_connection(current_config)
|
94
|
-
end
|
95
|
-
|
96
107
|
# Cannot call this for the jets new
|
97
108
|
def confirm_jets_project!
|
98
109
|
unless File.exist?("#{Jets.root}/config/application.rb")
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "recursive-open-struct"
|
2
|
+
|
3
|
+
module Jets::Commands::Db::Tasks::Dummy
|
4
|
+
class App
|
5
|
+
def config
|
6
|
+
Config.new(
|
7
|
+
paths: {
|
8
|
+
db: ["db"],
|
9
|
+
}
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def paths
|
14
|
+
RecursiveOpenStruct.new(
|
15
|
+
paths: {
|
16
|
+
"db/migrate": ["db/migrate"]
|
17
|
+
}
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "recursive-open-struct"
|
2
|
+
|
3
|
+
module Jets::Commands::Db::Tasks::Dummy
|
4
|
+
class Config < RecursiveOpenStruct
|
5
|
+
def load_database_yaml # :nodoc:
|
6
|
+
require "rails/application/dummy_erb_compiler"
|
7
|
+
|
8
|
+
path = "#{Jets.root}/config/database.yml"
|
9
|
+
yaml = Pathname.new(path)
|
10
|
+
erb = DummyERB.new(yaml.read)
|
11
|
+
YAML.load(erb.result) || {}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -4,7 +4,6 @@ class Jets::Commands::Db::Tasks
|
|
4
4
|
# Lazy require rails so Rails const is only defined in jets db:* tasks
|
5
5
|
require "rails"
|
6
6
|
require "active_record"
|
7
|
-
require "recursive-open-struct"
|
8
7
|
|
9
8
|
# Jets.boot # Jets.boot here screws up jets -h, the db_config doesnt seem to match exactly
|
10
9
|
# but seems to be working anyway.
|
@@ -15,21 +14,12 @@ class Jets::Commands::Db::Tasks
|
|
15
14
|
|
16
15
|
# Need to mock out the usage of Rails.application in:
|
17
16
|
# activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb
|
18
|
-
Rails.application =
|
19
|
-
config: {
|
20
|
-
paths: {
|
21
|
-
db: ["db"],
|
22
|
-
}
|
23
|
-
},
|
24
|
-
paths: {
|
25
|
-
"db/migrate": ["db/migrate"]
|
26
|
-
}
|
27
|
-
)
|
17
|
+
Rails.application = Dummy::App.new
|
28
18
|
load "active_record/railties/databases.rake"
|
29
|
-
|
30
19
|
load File.expand_path("../environment-task.rake", __FILE__)
|
31
20
|
end
|
32
21
|
|
22
|
+
|
33
23
|
# Thanks: https://stackoverflow.com/questions/19206764/how-can-i-load-activerecord-database-tasks-on-a-ruby-project-outside-rails/24840749
|
34
24
|
class Seeder
|
35
25
|
def initialize(seed_file)
|
@@ -1,9 +1,10 @@
|
|
1
1
|
default: &default
|
2
2
|
adapter: <%= @database == 'mysql' ? 'mysql2' : 'postgresql' %>
|
3
|
-
encoding:
|
3
|
+
encoding: utf8mb4
|
4
4
|
pool: <%%= ENV["DB_POOL"] || 5 %>
|
5
5
|
database: <%%= ENV['DB_NAME'] || '<%= @project_name %>_development' %>
|
6
6
|
<% if @database == 'mysql' -%>
|
7
|
+
encoding: utf8mb4
|
7
8
|
username: <%%= ENV['DB_USER'] || 'root' %>
|
8
9
|
<% else -%>
|
9
10
|
username: <%%= ENV['DB_USER'] || ENV['USER'] %>
|
data/lib/jets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 6.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: actionview
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 6.0.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 6.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activerecord
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 6.0.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 6.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 6.0.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 6.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: aws-sdk-apigateway
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -380,14 +380,14 @@ dependencies:
|
|
380
380
|
requirements:
|
381
381
|
- - "~>"
|
382
382
|
- !ruby/object:Gem::Version
|
383
|
-
version:
|
383
|
+
version: 6.0.0
|
384
384
|
type: :runtime
|
385
385
|
prerelease: false
|
386
386
|
version_requirements: !ruby/object:Gem::Requirement
|
387
387
|
requirements:
|
388
388
|
- - "~>"
|
389
389
|
- !ruby/object:Gem::Version
|
390
|
-
version:
|
390
|
+
version: 6.0.0
|
391
391
|
- !ruby/object:Gem::Dependency
|
392
392
|
name: rainbow
|
393
393
|
requirement: !ruby/object:Gem::Requirement
|
@@ -636,6 +636,8 @@ files:
|
|
636
636
|
- lib/jets/commands/db.rb
|
637
637
|
- lib/jets/commands/db/environment-task.rake
|
638
638
|
- lib/jets/commands/db/tasks.rb
|
639
|
+
- lib/jets/commands/db/tasks/dummy/app.rb
|
640
|
+
- lib/jets/commands/db/tasks/dummy/config.rb
|
639
641
|
- lib/jets/commands/dbconsole.rb
|
640
642
|
- lib/jets/commands/delete.rb
|
641
643
|
- lib/jets/commands/deploy.rb
|