jets 6.0.0.beta1 → 6.0.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 +1 -1
- data/lib/jets/autoloaders/main.rb +18 -4
- data/lib/jets/cli/delete.rb +5 -1
- data/lib/jets/cli/functions.rb +1 -1
- data/lib/jets/cli/group/helpers.rb +3 -3
- data/lib/jets/cli/init/templates/config/jets/deploy.rb.tt +29 -31
- data/lib/jets/cli/init/templates/env/.env.tt +5 -3
- data/lib/jets/cli/init.rb +40 -16
- data/lib/jets/cli/stop.rb +2 -2
- data/lib/jets/cli/waf/templates/waf.rb.tt +11 -11
- data/lib/jets/core/config/project.rb +17 -6
- data/lib/jets/framework.rb +51 -0
- data/lib/jets/git/codebuild.rb +1 -1
- data/lib/jets/shim/adapter/fallback.rb +11 -6
- data/lib/jets/shim/config.rb +26 -31
- data/lib/jets/version.rb +1 -1
- metadata +6 -6
- data/lib/jets/cli/init/detect.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ea57049f7d7ee0153aac387f0feb438ee5a9e9816f8aeab7e21a9a6d4e33d69
|
4
|
+
data.tar.gz: 2a6e9de21b85674322a8adcfb234204272aefe2e30ae6babc77244ab9f4d8635
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2584bc53863cef64744101705db2b65a312d4f332745b8d0ca8a41558b5f3e0dacae87ec1169dcdc4c2bfa1af75de7156c24015b212fd6e3eccc522a2b5f0da5
|
7
|
+
data.tar.gz: 1fcfc2dc86ff24cec62eb34b0559229a47ebbc868e49fc2f1e9d39c7cd8836c70e1cff4adf8fbb3eee9af96610fdabea7dc21d342eda96ff0b0afa8405e2b7ff
|
data/CHANGELOG.md
CHANGED
@@ -14,16 +14,13 @@ module Jets
|
|
14
14
|
memoize :loader
|
15
15
|
|
16
16
|
def configure(root = Jets.root)
|
17
|
-
all_loaders = Zeitwerk::Registry.loaders
|
18
|
-
already_configured_dirs = all_loaders.map(&:dirs).flatten
|
19
|
-
|
20
17
|
full_path = proc { |path| "#{root}/#{path}" }
|
21
18
|
autoload_paths = config.autoload_paths.map(&full_path)
|
22
19
|
extension_paths = config.extension_paths.map(&full_path)
|
23
20
|
load_paths = autoload_paths + extension_paths
|
24
21
|
|
25
22
|
load_paths.each do |path|
|
26
|
-
next if
|
23
|
+
next if already_configured_dir?(path)
|
27
24
|
next unless File.directory?(path)
|
28
25
|
loader.push_dir(path)
|
29
26
|
end
|
@@ -34,6 +31,23 @@ module Jets
|
|
34
31
|
end
|
35
32
|
end
|
36
33
|
|
34
|
+
def already_configured_dir?(path)
|
35
|
+
all_loaders = Zeitwerk::Registry.loaders
|
36
|
+
already_configured_dirs = all_loaders.map(&:dirs).flatten
|
37
|
+
|
38
|
+
# Normalize the path to avoid trailing slashes issues
|
39
|
+
normalized_path = File.expand_path(path)
|
40
|
+
|
41
|
+
# Check the path and its parent directories
|
42
|
+
while normalized_path != "/"
|
43
|
+
return true if already_configured_dirs.include?(normalized_path)
|
44
|
+
normalized_path = File.dirname(normalized_path)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Check the root directory explicitly
|
48
|
+
already_configured_dirs.include?("/")
|
49
|
+
end
|
50
|
+
|
37
51
|
# Call at end
|
38
52
|
def setup
|
39
53
|
loader.on_load do |cpath, value, abspath|
|
data/lib/jets/cli/delete.rb
CHANGED
@@ -8,7 +8,11 @@ class Jets::CLI
|
|
8
8
|
|
9
9
|
def are_you_sure?
|
10
10
|
stack_name = Jets.project.namespace
|
11
|
-
message =
|
11
|
+
message = <<~EOL
|
12
|
+
Will delete #{stack_name.color(:green)}
|
13
|
+
|
14
|
+
Uses remote runner to delete the stack and resources.
|
15
|
+
EOL
|
12
16
|
unless stack_exists?(stack_name)
|
13
17
|
message << <<~EOL
|
14
18
|
|
data/lib/jets/cli/functions.rb
CHANGED
@@ -14,7 +14,7 @@ class Jets::CLI
|
|
14
14
|
resources = cfn.describe_stack_resources(stack_name: stack_name).stack_resources
|
15
15
|
resources.each do |r|
|
16
16
|
if r.resource_type == "AWS::Lambda::Function"
|
17
|
-
functions << r.physical_resource_id
|
17
|
+
functions << r.physical_resource_id if r.physical_resource_id # race condition. can be nil for a brief moment while provisioning
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -11,13 +11,13 @@ module Jets::CLI::Group
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def init_project_name
|
14
|
-
|
14
|
+
# inferred from the folder name
|
15
|
+
Dir.pwd.split("/").last.gsub(/[^a-zA-Z0-9_]/, "-").squeeze("-")
|
15
16
|
end
|
16
17
|
|
17
18
|
def framework
|
18
|
-
Jets::
|
19
|
+
Jets::Framework.name
|
19
20
|
end
|
20
|
-
memoize :framework
|
21
21
|
|
22
22
|
def package_type
|
23
23
|
(framework == "rails") ? "image" : "zip"
|
@@ -1,7 +1,36 @@
|
|
1
1
|
Jets.deploy.configure do
|
2
|
+
# CloudFront Lambda URL https://docs.rubyonjets.com/docs/routing/lambda/cloudfront/distribution/
|
3
|
+
# config.lambda.url.cloudfront.enable = true
|
4
|
+
# config.lambda.url.cloudfront.cert.arn = acm_cert_arn(domain: "domain.com", region: "us-east-1")
|
5
|
+
# config.lambda.url.cloudfront.route53.enable = true
|
6
|
+
|
7
|
+
# CloudFront Assets
|
8
|
+
# config.assets.cloudfront.enable = true
|
9
|
+
# config.assets.cloudfront.cert.arn = acm_cert_arn(domain: "domain.com", region: "us-east-1")
|
10
|
+
# config.assets.cloudfront.route53.enable = true
|
11
|
+
|
12
|
+
# Release phase https://docs.rubyonjets.com/docs/hooks/remote/release/
|
13
|
+
# config.release.phase.command = "bundle exec rails db:migrate"
|
14
|
+
|
15
|
+
# Scaling https://docs.rubyonjets.com/docs/config/concurrency/
|
16
|
+
# config.lambda.controller.provisioned_concurrency = 1 # costs money, no cold start
|
17
|
+
# config.lambda.controller.reserved_concurrency = 25 # free and limits scaling
|
18
|
+
|
19
|
+
# IAM https://docs.rubyonjets.com/docs/iam/app/iam-policies/
|
20
|
+
# config.lambda.iam.policy = ["sns"]
|
21
|
+
# config.lambda.iam.managed_policy = ["AmazonS3FullAccess"]
|
22
|
+
|
23
|
+
# Docker https://docs.rubyonjets.com/docs/docker/dockerfile/managed/
|
24
|
+
# config.dockerfile.packages.apt.build_stage = ["default-libmysqlclient-dev"]
|
25
|
+
# config.dockerfile.packages.apt.deployment_stage = ["default-mysql-client"]
|
26
|
+
|
2
27
|
<% unless framework == "rails" -%>
|
3
28
|
# https://docs.rubyonjets.com/docs/config/package-type/
|
29
|
+
<% if %w[rack sinatra].include?(framework) -%>
|
30
|
+
# config.package_type = "zip" # default: image IE: image or zip
|
31
|
+
<% else -%>
|
4
32
|
# config.package_type = "image" # default: image IE: image or zip
|
33
|
+
<% end -%>
|
5
34
|
|
6
35
|
<% end -%>
|
7
36
|
<% if framework == "rails" -%>
|
@@ -9,35 +38,4 @@ Jets.deploy.configure do
|
|
9
38
|
# config.job.enable = true
|
10
39
|
|
11
40
|
<% end -%>
|
12
|
-
# Docker https://docs.rubyonjets.com/docs/docker/dockerfile/managed/
|
13
|
-
# config.dockerfile.packages.apt.build_stage = ["default-libmysqlclient-dev"]
|
14
|
-
# config.dockerfile.packages.apt.deployment_stage = ["default-mysql-client"]
|
15
|
-
|
16
|
-
# CloudFront Lambda URL https://docs.rubyonjets.com/docs/routing/lambda/cloudfront/distribution/
|
17
|
-
# config.lambda.url.cloudfront.enable = true
|
18
|
-
# config.lambda.url.cloudfront.cert.arn = acm_cert_arn("domain.com", region: "us-east-1")
|
19
|
-
# config.lambda.url.cloudfront.route53.enable = true
|
20
|
-
|
21
|
-
# WAF https://docs.rubyonjets.com/docs/routing/lambda/cloudfront/waf/
|
22
|
-
# config.lambda.url.cloudfront.web_acl_id = web_acl_arn(ssm_env, scope: "CLOUDFRONT")
|
23
|
-
# config.waf.rules = ["AWSManagedRulesSQLiRuleSet"]
|
24
|
-
|
25
|
-
# Scaling https://docs.rubyonjets.com/docs/config/provisioned-concurrency/
|
26
|
-
# config.lambda.controller.provisioned_concurrency = 1 # costs money, no cold start
|
27
|
-
# config.lambda.controller.reserved_concurrency = 10 # free and limits scaling
|
28
|
-
|
29
|
-
# Release phase https://docs.rubyonjets.com/docs/hooks/remote/release/
|
30
|
-
# config.release.phase.command = "bundle exec rails db:migrate"
|
31
|
-
|
32
|
-
# CI https://docs.rubyonjets.com/docs/ci/getting-started/
|
33
|
-
# use jets ci:init to add these settings automatically
|
34
|
-
# config.ci.source = {
|
35
|
-
# Type: "GITHUB",
|
36
|
-
# Location: "https://github.com/ORG/REPO"
|
37
|
-
# }
|
38
|
-
# config.ci.source_version = "main"
|
39
|
-
# config.ci.env.vars = {
|
40
|
-
# BUNDLE_GITHUB__COM: "SSM:/#{ssm_env}/BUNDLE_GITHUB__COM",
|
41
|
-
# JETS_API_KEY: "SSM:/#{ssm_env}/JETS_API_KEY"
|
42
|
-
# }
|
43
41
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<% if framework == "rails" -%>
|
6
6
|
RAILS_ENV=production
|
7
7
|
RAILS_LOG_TO_STDOUT=1
|
8
|
-
# SECRET_KEY_BASE=SSM # SSM:/<%= init_project_name %>/dev/SECRET_KEY_BASE remember to set a secret key base
|
8
|
+
# SECRET_KEY_BASE=SSM # => SSM:/<%= init_project_name %>/dev/SECRET_KEY_BASE remember to set a secret key base
|
9
9
|
<% end -%>
|
10
10
|
|
11
11
|
# Examples:
|
@@ -14,5 +14,7 @@ RAILS_LOG_TO_STDOUT=1
|
|
14
14
|
# KEY2=SSM:/abs/path/to/KEY2
|
15
15
|
# Conventions https://docs.rubyonjets/docs/env/ssm/conventions/
|
16
16
|
# SSM path under /<%= init_project_name %>/dev/ are autoloaded.
|
17
|
-
#
|
18
|
-
#
|
17
|
+
# For example, DATABASE_URL does not need to be declared here.
|
18
|
+
# It can be conventionally autoloaded.
|
19
|
+
# Below is an example of how to manually declare but it's not needed.
|
20
|
+
# DATABASE_URL=SSM # => SSM:/<%= init_project_name %>/dev/DATABASE_URL
|
data/lib/jets/cli/init.rb
CHANGED
@@ -16,7 +16,7 @@ class Jets::CLI
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def sure_message
|
19
|
-
detected_message = "Detected #{framework} framework.\n" if framework
|
19
|
+
detected_message = "Detected #{framework.titleize} framework.\n" if framework
|
20
20
|
<<~EOL
|
21
21
|
#{detected_message}This will initialize the project for Jets.
|
22
22
|
|
@@ -26,6 +26,39 @@ class Jets::CLI
|
|
26
26
|
EOL
|
27
27
|
end
|
28
28
|
|
29
|
+
def configure_rails
|
30
|
+
# config/environments/production.rb adjustments
|
31
|
+
# Comment out public_file_server.enabled on new Rails 7.0 apps
|
32
|
+
# config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
|
33
|
+
comment_out_line("config.public_file_server.enabled = ENV", env: "production")
|
34
|
+
config_environment("config.public_file_server.enabled = false\n\n", env: "production")
|
35
|
+
# Comment out config.asset_host = "http://assets.example.com" on new Rails 7.0 apps
|
36
|
+
# config.asset_host = "http://assets.example.com"
|
37
|
+
comment_out_line('config.asset_host = "', env: "production")
|
38
|
+
asset_host = <<~EOL
|
39
|
+
|
40
|
+
# Assets https://docs.rubyonjets.com/docs/assets/cloudfront/
|
41
|
+
config.asset_host = ENV["JETS_ASSET_HOST"] unless ENV["JETS_ASSET_HOST"].blank?
|
42
|
+
EOL
|
43
|
+
config_environment(asset_host, env: "production")
|
44
|
+
|
45
|
+
jets_job = <<~EOL
|
46
|
+
# Jobs https://docs.rubyonjets.com/docs/jobs/enable/
|
47
|
+
# config.active_job.queue_adapter = :jets_job
|
48
|
+
EOL
|
49
|
+
config_environment(jets_job, env: "production")
|
50
|
+
end
|
51
|
+
|
52
|
+
def configure_hanami
|
53
|
+
after = " class App < Hanami::App\n"
|
54
|
+
data = <<~EOL
|
55
|
+
# https://guides.hanamirb.org/v2.1/assets/using-a-cdn/
|
56
|
+
# https://docs.rubyonjets.com/docs/assets/cloudfront/
|
57
|
+
config.assets.base_url = ENV["JETS_ASSET_HOST"] if ENV["JETS_ASSET_HOST"]
|
58
|
+
EOL
|
59
|
+
inject_into_file "config/app.rb", optimize_indentation(data, 4), after: after, verbose: true
|
60
|
+
end
|
61
|
+
|
29
62
|
public
|
30
63
|
|
31
64
|
def are_you_sure?
|
@@ -46,21 +79,12 @@ class Jets::CLI
|
|
46
79
|
end
|
47
80
|
|
48
81
|
def configure_environment
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
# Comment out config.asset_host = "http://assets.example.com" on new Rails 7.0 apps
|
56
|
-
# config.asset_host = "http://assets.example.com"
|
57
|
-
comment_out_line('config.asset_host = "', env: "production")
|
58
|
-
config_environment('config.asset_host = ENV["JETS_ASSET_HOST"] unless ENV["JETS_ASSET_HOST"].blank?', env: "production")
|
59
|
-
jets_job = <<~EOL
|
60
|
-
# Docs: https://docs.rubyonjets.com/docs/jobs/enable/
|
61
|
-
# config.active_job.queue_adapter = :jets_job
|
62
|
-
EOL
|
63
|
-
config_environment(jets_job, env: "production")
|
82
|
+
case framework
|
83
|
+
when "rails"
|
84
|
+
configure_rails
|
85
|
+
when "hanami"
|
86
|
+
configure_hanami
|
87
|
+
end
|
64
88
|
end
|
65
89
|
end
|
66
90
|
end
|
data/lib/jets/cli/stop.rb
CHANGED
@@ -8,8 +8,8 @@ class Jets::CLI
|
|
8
8
|
if stopped
|
9
9
|
log.info <<~EOL
|
10
10
|
Deploy has been stopped: #{build_id}
|
11
|
-
|
12
|
-
|
11
|
+
If the deploy has already started the CloudFormation update it will continue.
|
12
|
+
Please check the logs.
|
13
13
|
|
14
14
|
EOL
|
15
15
|
show_console_log_url(build_id)
|
@@ -9,18 +9,18 @@ Jets.deploy.configure do
|
|
9
9
|
# config.waf.rules = []
|
10
10
|
|
11
11
|
# Jets WAF Managed Rules
|
12
|
-
# config.waf.
|
13
|
-
# config.waf.
|
14
|
-
# config.waf.
|
15
|
-
# config.waf.
|
12
|
+
# config.waf.custom_rules.blanket_rate_limiter.enable = true # default: true
|
13
|
+
# config.waf.custom_rules.blanket_rate_limiter.limit = 1000
|
14
|
+
# config.waf.custom_rules.blanket_rate_limiter.evaluation_window_sec = 300
|
15
|
+
# config.waf.custom_rules.blanket_rate_limiter.aggregate_key_type = "IP"
|
16
16
|
|
17
|
-
# config.waf.
|
18
|
-
# config.waf.
|
19
|
-
# config.waf.
|
20
|
-
# config.waf.
|
21
|
-
# config.waf.
|
22
|
-
# config.waf.
|
23
|
-
# config.waf.
|
17
|
+
# config.waf.custom_rules.uri_rate_limiter.enable = true # default: false
|
18
|
+
# config.waf.custom_rules.uri_rate_limiter.limit = 100
|
19
|
+
# config.waf.custom_rules.uri_rate_limiter.logical_statement = "Or"
|
20
|
+
# config.waf.custom_rules.uri_rate_limiter.paths = ["/login", "/signup"] # default: ["/"]
|
21
|
+
# config.waf.custom_rules.uri_rate_limiter.evaluation_window_sec = 300
|
22
|
+
# config.waf.custom_rules.uri_rate_limiter.aggregate_key_type = "IP"
|
23
|
+
# config.waf.custom_rules.uri_rate_limiter.string_match_condition = "STARTS_WITH"
|
24
24
|
|
25
25
|
# Docs: https://docs.rubyonjets.com/docs/routing/lambda/cloudfront/waf/
|
26
26
|
end
|
@@ -62,12 +62,23 @@ module Jets::Core::Config
|
|
62
62
|
Jets::Core::Booter.require_config(:project)
|
63
63
|
return @name if @name
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
project_name = jets_info_project_name
|
66
|
+
unless project_name
|
67
|
+
puts "ERROR: Jets project name not set".color(:red)
|
68
|
+
abort <<~EOL
|
69
|
+
Please set config.name in config/jets/project.rb or the JETS_PROJECT environment variable
|
70
|
+
Example:
|
71
|
+
|
72
|
+
config/jets/project.rb
|
73
|
+
|
74
|
+
Jets.project.configure do
|
75
|
+
config.name = "demo"
|
76
|
+
end
|
77
|
+
|
78
|
+
Or set the JETS_PROJECT environment variable:
|
79
|
+
|
80
|
+
export JETS_PROJECT=demo
|
81
|
+
EOL
|
71
82
|
end
|
72
83
|
end
|
73
84
|
memoize :name
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Jets
|
2
|
+
class Framework
|
3
|
+
class << self
|
4
|
+
extend Memoist
|
5
|
+
def env_var
|
6
|
+
"#{name.upcase}_ENV" if name # can be nil
|
7
|
+
end
|
8
|
+
|
9
|
+
def env
|
10
|
+
return unless env_var
|
11
|
+
ENV[env_var] || "production" # for Dockerfile default to production
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
gems.each do |gem|
|
16
|
+
frameworks.each do |framework|
|
17
|
+
if gem == framework
|
18
|
+
# Special case for puma. If puma is detected, it means it is a rack app.
|
19
|
+
if framework == "puma"
|
20
|
+
return "rack"
|
21
|
+
else
|
22
|
+
return framework
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
memoize :name
|
30
|
+
|
31
|
+
def frameworks
|
32
|
+
%w[
|
33
|
+
rails
|
34
|
+
sinatra
|
35
|
+
hanami
|
36
|
+
rack
|
37
|
+
puma
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def gems
|
42
|
+
return [] unless File.exist?("Gemfile")
|
43
|
+
Bundler.with_unbundled_env do
|
44
|
+
gemfile_content = File.read("Gemfile")
|
45
|
+
dsl = Bundler::Dsl.evaluate(Bundler.default_gemfile, gemfile_content, {})
|
46
|
+
dsl.dependencies.map(&:name)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/jets/git/codebuild.rb
CHANGED
@@ -11,18 +11,22 @@ module Jets::Shim::Adapter
|
|
11
11
|
|
12
12
|
class << self
|
13
13
|
def handler(event, context = nil, target = nil)
|
14
|
-
puts
|
15
|
-
|
14
|
+
puts <<~EOL
|
15
|
+
WARN: handler for it could not be found. The default fallback handler is being used.
|
16
|
+
The default fallback handler simply prints out the event payload for debugging, it will be printed below.
|
17
|
+
Usually the default handler is not what you want.
|
18
|
+
You might be using a test event payload for testing which does not represent a real event.
|
19
|
+
Please double check the event payload.
|
20
|
+
EOL
|
16
21
|
if ENV["_HANDLER"] # on AWS Lambda
|
17
22
|
puts "event: #{JSON.dump(event)}"
|
18
23
|
else
|
19
24
|
puts "event:"
|
20
25
|
puts JSON.pretty_generate(event)
|
21
26
|
end
|
22
|
-
puts "Please double check the event payload.\n\n"
|
23
27
|
|
24
28
|
if target
|
25
|
-
puts "
|
29
|
+
puts "WARN: Event handler target not found: #{target}".color(:red)
|
26
30
|
target_class, target_method = target.split(".")
|
27
31
|
target_class = target_class.camelize
|
28
32
|
target_method ||= "perform"
|
@@ -40,7 +44,8 @@ module Jets::Shim::Adapter
|
|
40
44
|
|
41
45
|
else
|
42
46
|
puts <<~EOL
|
43
|
-
You can also configure a custom fallback handler
|
47
|
+
You can also configure a custom fallback handler with a config/jets/shim.rb file.
|
48
|
+
Though custom handlers rarely needed and you should double check the event payload.
|
44
49
|
Example:
|
45
50
|
|
46
51
|
config/jets/shim.rb
|
@@ -55,7 +60,7 @@ module Jets::Shim::Adapter
|
|
55
60
|
end
|
56
61
|
# Custom Jets error message
|
57
62
|
{
|
58
|
-
errorMessage: "
|
63
|
+
errorMessage: "Event handler not found. Look at logs for details",
|
59
64
|
errorType: "JetsEventHandlerNotFound"
|
60
65
|
}
|
61
66
|
end
|
data/lib/jets/shim/config.rb
CHANGED
@@ -21,51 +21,46 @@ module Jets::Shim
|
|
21
21
|
elsif @rack_app
|
22
22
|
@rack_app
|
23
23
|
else
|
24
|
-
|
25
|
-
# Possible that boot_path is nil.
|
26
|
-
# Case: Jets events app only.
|
27
|
-
if boot_path
|
28
|
-
require_boot_path(boot_path) if boot_path # in case boot_path is not set
|
29
|
-
infer_rack_app(boot_path) # IE: Rails.application or App
|
30
|
-
end
|
24
|
+
framework_app
|
31
25
|
end
|
32
26
|
end
|
33
27
|
alias_method :app, :rack_app
|
34
28
|
alias_method :app=, :rack_app=
|
35
29
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
"
|
30
|
+
def framework_app
|
31
|
+
# Explicitly set boot_path takes precedence
|
32
|
+
# IE: my_app.rb => MyApp
|
33
|
+
if @boot_path && File.exist?(@boot_path)
|
34
|
+
app_class = @boot_path.sub(/\.rb$/, "").camelize.constantize
|
35
|
+
return app_class
|
41
36
|
end
|
42
|
-
end
|
43
37
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
38
|
+
# Infer app.rb boot_path
|
39
|
+
# IE: app.rb => App
|
40
|
+
if File.exist?("app.rb")
|
41
|
+
require_boot_path("app")
|
42
|
+
return App
|
43
|
+
end
|
49
44
|
|
50
|
-
|
51
|
-
|
45
|
+
# Infer rack app from config.ru
|
46
|
+
case framework
|
47
|
+
when "rails"
|
48
|
+
require_boot_path "config/environment"
|
52
49
|
Rails.application
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
when "hanami"
|
51
|
+
require "hanami/boot"
|
52
|
+
Hanami.app
|
56
53
|
end
|
57
54
|
end
|
58
55
|
|
59
|
-
def
|
60
|
-
|
56
|
+
def require_boot_path(path)
|
57
|
+
path = path.starts_with?(".") ? path : "./#{path}"
|
58
|
+
path = path.ends_with?(".rb") ? path : "#{path}.rb"
|
59
|
+
require path # IE: config/environment.rb (Rails) or app.rb (generic rack app)
|
61
60
|
end
|
62
61
|
|
63
|
-
def framework
|
64
|
-
|
65
|
-
# IE: Jets.application or Rails.application
|
66
|
-
IO.readlines("config.ru").any? { |l| l.include?("#{name.to_s.camelize}.application") }
|
67
|
-
end
|
62
|
+
def framework
|
63
|
+
Jets::Framework.name
|
68
64
|
end
|
69
|
-
memoize :framework?
|
70
65
|
end
|
71
66
|
end
|
data/lib/jets/version.rb
CHANGED
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: 6.0.0
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-logs
|
@@ -756,7 +756,6 @@ files:
|
|
756
756
|
- lib/jets/cli/help/status.md
|
757
757
|
- lib/jets/cli/help/url.md
|
758
758
|
- lib/jets/cli/init.rb
|
759
|
-
- lib/jets/cli/init/detect.rb
|
760
759
|
- lib/jets/cli/init/templates/config/jets/bootstrap.rb.tt
|
761
760
|
- lib/jets/cli/init/templates/config/jets/deploy.rb.tt
|
762
761
|
- lib/jets/cli/init/templates/config/jets/project.rb.tt
|
@@ -850,6 +849,7 @@ files:
|
|
850
849
|
- lib/jets/event/helpers/sqs_event.rb
|
851
850
|
- lib/jets/event/s3.rb
|
852
851
|
- lib/jets/exception_reporting.rb
|
852
|
+
- lib/jets/framework.rb
|
853
853
|
- lib/jets/git.rb
|
854
854
|
- lib/jets/git/azure.rb
|
855
855
|
- lib/jets/git/base.rb
|
@@ -981,11 +981,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
981
981
|
version: 2.7.0
|
982
982
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
983
983
|
requirements:
|
984
|
-
- - "
|
984
|
+
- - ">="
|
985
985
|
- !ruby/object:Gem::Version
|
986
|
-
version:
|
986
|
+
version: '0'
|
987
987
|
requirements: []
|
988
|
-
rubygems_version: 3.
|
988
|
+
rubygems_version: 3.5.10
|
989
989
|
signing_key:
|
990
990
|
specification_version: 4
|
991
991
|
summary: Serverless Deployment Service
|
data/lib/jets/cli/init/detect.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
class Jets::CLI::Init
|
2
|
-
class Detect
|
3
|
-
def framework
|
4
|
-
gems.each do |gem|
|
5
|
-
frameworks.each do |framework|
|
6
|
-
return framework if gem == framework
|
7
|
-
end
|
8
|
-
end
|
9
|
-
nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def frameworks
|
13
|
-
%w[
|
14
|
-
rails
|
15
|
-
sinatra
|
16
|
-
hanami
|
17
|
-
grape
|
18
|
-
]
|
19
|
-
end
|
20
|
-
|
21
|
-
def gems
|
22
|
-
return [] unless File.exist?("Gemfile")
|
23
|
-
Bundler.with_unbundled_env do
|
24
|
-
gemfile_content = File.read("Gemfile")
|
25
|
-
dsl = Bundler::Dsl.evaluate(Bundler.default_gemfile, gemfile_content, {})
|
26
|
-
dsl.dependencies.map(&:name)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|