jets 5.0.0.beta1 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -2
- data/CONTRIBUTING.md +1 -1
- data/README.md +27 -43
- data/jets.gemspec +2 -1
- data/lib/jets/aws_services/stack_status.rb +1 -1
- data/lib/jets/builders/code_builder.rb +4 -5
- data/lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb +1 -1
- data/lib/jets/cfn/deployment.rb +58 -18
- data/lib/jets/cfn/resource/api_gateway/rest_api/logical_id.rb +2 -2
- data/lib/jets/cfn/resource/api_gateway/rest_api/routes/change/base.rb +2 -1
- data/lib/jets/cfn/resource/api_gateway/rest_api/routes/change.rb +11 -5
- data/lib/jets/cfn/resource/s3/jets_bucket.rb +2 -2
- data/lib/jets/command/api_helpers.rb +1 -0
- data/lib/jets/command/base.rb +5 -0
- data/lib/jets/command/help/gems/check.md +1 -6
- data/lib/jets/command/help/logs.md +1 -1
- data/lib/jets/command/help/releases.md +7 -25
- data/lib/jets/command/rake_decorate.rb +38 -0
- data/lib/jets/command.rb +10 -1
- data/lib/jets/commands/delete/delete_command.rb +2 -3
- data/lib/jets/commands/releases/releases_command.rb +58 -5
- data/lib/jets/commands/rollback/rollback_command.rb +1 -9
- data/lib/jets/core.rb +7 -1
- data/lib/jets/dotenv/ssm.rb +4 -1
- data/lib/jets/generators/overrides/app/helpers.rb +0 -4
- data/lib/jets/generators/overrides/app/templates/.env +10 -0
- data/lib/jets/generators/overrides/app/templates/.jetsignore +6 -0
- data/lib/jets/generators/overrides/app/templates/config/environments/development.rb.tt +1 -1
- data/lib/jets/generators/overrides/app/templates/config/environments/production.rb.tt +1 -1
- data/lib/jets/job/base.rb +1 -1
- data/lib/jets/job/dsl/dynamodb_event.rb +1 -1
- data/lib/jets/router/matcher.rb +7 -3
- data/lib/jets/version.rb +1 -1
- data/lib/jets.rb +1 -0
- metadata +22 -5
- /data/lib/jets/generators/overrides/app/templates/{.gitignore → .gitignore.tt} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4a384d3b0e4d6523695e38deddbb180904b542b7e03cc095ead1844f02a3571
|
4
|
+
data.tar.gz: b01933003b19b5ae79c4e6e82427e930a1c82197ebf7efb125d150ea405ef3f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b40b236e756e6a93649082776f7ea948250619703a51cd98425cc7876085933975011120547bedc098c3a5fe0000aecfe545adb01b8d9c1de76cb4f4e3a36ae
|
7
|
+
data.tar.gz: 4cc1b4cdc76eb7fd9d4397b2194300a4974c3d3afe94e954c2073a300ccfcc612f16fee657e86214c0c5c96fb983d1003c88db7e2e04d176516fbc9518f5c37a
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,17 @@
|
|
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
|
-
## [5.0.
|
6
|
+
## [5.0.1] - 2023-12-11
|
7
|
+
- [#680](https://github.com/rubyonjets/jets/pull/680) fix apigw gateway replacement warning prompt
|
8
|
+
- [#682](https://github.com/rubyonjets/jets/pull/682) Replace puts with Jets.logger.info in jobs
|
9
|
+
- [#683](https://github.com/rubyonjets/jets/pull/683) Fix broken links in README and CONTRIBUTING
|
10
|
+
- [#684](https://github.com/rubyonjets/jets/pull/684) improve cli usage invalid command and options handling
|
11
|
+
- [#685](https://github.com/rubyonjets/jets/pull/685) rollback usage cleanup
|
12
|
+
- [#686](https://github.com/rubyonjets/jets/pull/686) remove need for sprockets-jets dependency
|
13
|
+
- [#687](https://github.com/rubyonjets/jets/pull/687) jets releases:info command
|
14
|
+
- default logging.event to false for generated production
|
15
|
+
|
16
|
+
## [5.0.0] - 2023-12-05
|
7
17
|
Single Lambda Function for Controllers
|
8
18
|
* For controllers, a single Lambda function is deployed going forward.
|
9
19
|
* APIGW serves as proxy endpoint for requests to the single Lambda function. Techniquely, there are 2 APIGW endpoints.
|
@@ -55,10 +65,13 @@ Breaking changes:
|
|
55
65
|
* Jets.config.prewarm.concurrency option removed.
|
56
66
|
* dynomite decoupling and integration improvements
|
57
67
|
|
68
|
+
## [4.0.10] - 2023-12-04
|
69
|
+
- [#678](https://github.com/boltops-tools/jets/pull/678) handle option method or http_method from route state
|
58
70
|
|
59
71
|
## [4.0.9] - 2023-12-03
|
60
72
|
- [#674](https://github.com/boltops-tools/jets/pull/674) Fix broken --mode jobs new project generation
|
61
73
|
- [#675](https://github.com/boltops-tools/jets/pull/675) Add resource tags to CloudFormation stack
|
74
|
+
|
62
75
|
## [4.0.8] - 2023-12-03
|
63
76
|
- [#677](https://github.com/boltops-tools/jets/pull/677) pin dynomite 1.2.7
|
64
77
|
|
@@ -327,7 +340,7 @@ Breaking Changes:
|
|
327
340
|
- #424 md5 fix subtle bug when code doesnt get uploaded from newly generated shims
|
328
341
|
- #425 add hosted zone id support
|
329
342
|
- #426 use headers origin for actual host in case of cloudfront in front
|
330
|
-
- #428 fixes to
|
343
|
+
- #428 fixes to JETS_NO_INTERNET env var option
|
331
344
|
- #429 fix simple function tmp_loader
|
332
345
|
|
333
346
|
## [2.3.11]
|
data/CONTRIBUTING.md
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
https://rubyonjets.com/docs/more/contributing/
|
data/README.md
CHANGED
@@ -16,12 +16,13 @@ Please **watch/star** this repo to help grow and support the project.
|
|
16
16
|
|
17
17
|
## What is Ruby on Jets?
|
18
18
|
|
19
|
-
Jets is a Ruby Serverless Framework.
|
19
|
+
Jets is a Ruby Serverless Framework. Jets allows you to create serverless applications with a beautiful language: Ruby. It includes everything required to build and deploy an application to AWS Lambda.
|
20
20
|
|
21
|
-
|
21
|
+
Understanding AWS Lambda and API Gateway is key to understanding Jets conceptually. Jets map your code to Lambda functions and other AWS Resources like API Gateway and Event Rules.
|
22
22
|
|
23
|
-
* **AWS Lambda** is
|
23
|
+
* **AWS Lambda** is functions as a service. It allows you to upload and run functions without worrying about the underlying infrastructure.
|
24
24
|
* **API Gateway** is the routing layer for Lambda. It is used to route REST URL endpoints to Lambda functions.
|
25
|
+
* **EventBridge Rules** are events as a service. You can automatically run Lambda functions triggered from AWS services. You decide what events to catch and how to react to them.
|
25
26
|
|
26
27
|
The official documentation is at [Ruby on Jets](http://rubyonjets.com).
|
27
28
|
|
@@ -42,14 +43,14 @@ end
|
|
42
43
|
|
43
44
|
Here's the function in the Lambda console:
|
44
45
|
|
45
|
-
![Code Example in AWS Lambda console](https://
|
46
|
+
![Code Example in AWS Lambda console](https://img.boltops.com/tools/jets/readme/simple-lambda-function.png)
|
46
47
|
|
47
48
|
|
48
|
-
Though simple functions are supported by Jets, they do not add much value as other ways to write Ruby code with Jets. Classes like [Controllers](http://rubyonjets.com/docs/controllers/) and [Jobs](http://rubyonjets.com/docs/jobs/) add many conveniences and are more powerful to use. We’ll cover them next.
|
49
|
+
Though simple functions are supported by Jets, they do not add as much value as other ways to write Ruby code with Jets. Classes like [Controllers](http://rubyonjets.com/docs/controllers/) and [Jobs](http://rubyonjets.com/docs/jobs/) add many conveniences and are more powerful to use. We’ll cover them next.
|
49
50
|
|
50
51
|
### Jets Controllers
|
51
52
|
|
52
|
-
A Jets controller handles a web request and renders a response.
|
53
|
+
A Jets controller handles a web request and renders a response. Here's an example:
|
53
54
|
|
54
55
|
app/controllers/posts_controller.rb:
|
55
56
|
|
@@ -69,11 +70,9 @@ class PostsController < ApplicationController
|
|
69
70
|
end
|
70
71
|
```
|
71
72
|
|
72
|
-
Helper methods like `params` provide the parameters from the API Gateway event. The `render` method
|
73
|
+
Helper methods like `params` provide the parameters from the API Gateway event. The `render` method returns a Lambda Proxy structure that API Gateway understands.
|
73
74
|
|
74
|
-
Jets creates Lambda functions
|
75
|
-
|
76
|
-
![Lambda Functions for each public method in AWS Console](https://raw.githubusercontent.com/tongueroo/jets/master/docs/img/docs/demo-lambda-functions-controller.png)
|
75
|
+
Jets creates single Lambda functions to handle your Jets Controller requests. The Lambda Function handler is a shim that routes to your controller action.
|
77
76
|
|
78
77
|
### Jets Routing
|
79
78
|
|
@@ -83,23 +82,14 @@ config/routes.rb:
|
|
83
82
|
|
84
83
|
```ruby
|
85
84
|
Jets.application.routes.draw do
|
86
|
-
|
87
|
-
get "posts/new", to: "posts#new"
|
88
|
-
get "posts/:id", to: "posts#show"
|
89
|
-
post "posts", to: "posts#create"
|
90
|
-
get "posts/:id/edit", to: "posts#edit"
|
91
|
-
put "posts", to: "posts#update"
|
92
|
-
delete "posts", to: "posts#delete"
|
93
|
-
|
94
|
-
resources :comments # expands to the RESTful routes above
|
95
|
-
|
85
|
+
resources :posts
|
96
86
|
any "posts/hot", to: "posts#hot" # GET, POST, PUT, etc request all work
|
97
87
|
end
|
98
88
|
```
|
99
89
|
|
100
90
|
The `routes.rb` gets translated to API Gateway resources:
|
101
91
|
|
102
|
-
![API Gateway Resources generated from routes in AWS console](https://
|
92
|
+
![API Gateway Resources generated from routes in AWS console](https://img.boltops.com/tools/jets/readme/apigw.png)
|
103
93
|
|
104
94
|
Test your API Gateway endpoints with curl or postman. Note, replace the URL endpoint with the one that is created:
|
105
95
|
|
@@ -111,7 +101,7 @@ Test your API Gateway endpoints with curl or postman. Note, replace the URL endp
|
|
111
101
|
|
112
102
|
### Jets Jobs
|
113
103
|
|
114
|
-
A Jets job handles asynchronous background jobs
|
104
|
+
A Jets job handles asynchronous background jobs outside the web request/response cycle. Here's an example:
|
115
105
|
|
116
106
|
app/jobs/hard_job.rb:
|
117
107
|
|
@@ -129,9 +119,13 @@ class HardJob < ApplicationJob
|
|
129
119
|
end
|
130
120
|
```
|
131
121
|
|
132
|
-
|
122
|
+
![Jets Jobs in AWS Lambda Console](https://img.boltops.com/tools/jets/readme/jets-jobs.png)
|
123
|
+
|
124
|
+
`HardJob#dig` runs every 10 hours, and `HardJob#lift` runs every 12 hours. The `rate` and `cron` methods created CloudWatch Event Rules. Example:
|
125
|
+
|
126
|
+
![CloudWatch Event Rules in AWS Console](https://img.boltops.com/tools/jets/readme/jets-jobs-event-rules.png)
|
133
127
|
|
134
|
-
|
128
|
+
This simple example uses Scheduled Events. There are many more possibilities, see the [Events Docs](https://docs.rubyonjets.com/docs/events/).
|
135
129
|
|
136
130
|
### Jets Deployment
|
137
131
|
|
@@ -141,46 +135,36 @@ You can test your application with a local server that mimics API Gateway: [Jets
|
|
141
135
|
|
142
136
|
After deployment, you can test the Lambda functions with the AWS Lambda console or the CLI.
|
143
137
|
|
144
|
-
### AWS Lambda Console
|
145
|
-
|
146
|
-
![Lambda Console](https://s3.amazonaws.com/boltops-demo/images/screenshots/lambda-console-posts-controller-index.png)
|
147
|
-
|
148
138
|
### Live Demos
|
149
139
|
|
150
140
|
Here are some demos of Jets applications:
|
151
141
|
|
152
142
|
* [Quintessential CRUD Jets app](https://demo.rubyonjets.com/)
|
153
143
|
* [API Demo](https://api.demo.rubyonjets.com/)
|
154
|
-
* [Jets Afterburner: Easy Rails Support](https://afterburner.demo.rubyonjets.com/)
|
155
|
-
* [Mega Mode: Jets and Rails Combined](https://mega.demo.rubyonjets.com/)
|
156
144
|
* [Image Upload with CarrierWave](https://upload.demo.rubyonjets.com/)
|
157
145
|
|
158
|
-
Please feel free to add your
|
159
|
-
|
160
|
-
### Rails Support
|
161
|
-
|
162
|
-
[Jets Afterburner Mode](http://rubyonjets.com/docs/rails-support/) provides Rails support with little effort. This allows you to run a Rails application on AWS Lambda. Also here's a Tutorial Blog Post: [Jets Afterburner: Rails Support](https://blog.boltops.com/2018/12/21/jets-afterburner-serverless-rails-on-aws-lambda-in-5-minutes).
|
146
|
+
Please feel free to add your examples to the [rubyonjets/examples](https://github.com/rubyonjets/examples) repo.
|
163
147
|
|
164
148
|
### More Info
|
165
149
|
|
166
|
-
For more documentation, check out the official docs: [Ruby on Jets](http://rubyonjets.com/).
|
150
|
+
For more documentation, check out the official docs: [Ruby on Jets](http://rubyonjets.com/). Here's a list of useful links:
|
167
151
|
|
168
152
|
* [Quick Start](http://rubyonjets.com/quick-start/)
|
169
153
|
* [Local Jets Server](http://rubyonjets.com/docs/local-server/)
|
170
154
|
* [REPL Console](http://rubyonjets.com/docs/repl-console/)
|
171
155
|
* [Project Structure](http://rubyonjets.com/docs/structure/)
|
172
|
-
* [App Configuration](http://rubyonjets.com/docs/
|
173
|
-
* [Database Support](http://rubyonjets.com/docs/database
|
174
|
-
* [Polymorphic Support](http://rubyonjets.com/docs/polymorphic
|
156
|
+
* [App Configuration](http://rubyonjets.com/docs/config/)
|
157
|
+
* [Database Support](http://rubyonjets.com/docs/database/)
|
158
|
+
* [Polymorphic Support](http://rubyonjets.com/docs/polymorphic/)
|
175
159
|
* [Rails Support](http://rubyonjets.com/docs/rails-support/)
|
176
160
|
* [Tutorials](http://rubyonjets.com/docs/tutorials/)
|
177
161
|
* [Prewarming](http://rubyonjets.com/docs/prewarming/)
|
178
|
-
* [Custom Resources](http://rubyonjets.com/docs/
|
179
|
-
* [Shared Resources](http://rubyonjets.com/docs/shared-resources/)
|
162
|
+
* [Custom Resources](http://rubyonjets.com/docs/custom/)
|
163
|
+
* [Shared Resources](http://rubyonjets.com/docs/custom/shared-resources/)
|
180
164
|
* [Installation](http://rubyonjets.com/docs/install/)
|
181
165
|
* [CLI Reference](http://rubyonjets.com/reference/)
|
182
|
-
* [Contributing](http://rubyonjets.com/docs/contributing/)
|
183
|
-
* [Support Jets](http://rubyonjets.com/
|
166
|
+
* [Contributing](http://rubyonjets.com/docs/more/contributing/)
|
167
|
+
* [Support Jets](http://rubyonjets.com/donate/)
|
184
168
|
* [Example Projects](https://github.com/tongueroo/jets-examples)
|
185
169
|
|
186
170
|
## Learning Content
|
data/jets.gemspec
CHANGED
@@ -54,7 +54,8 @@ Gem::Specification.new do |spec|
|
|
54
54
|
spec.add_dependency "dsl_evaluator", ">= 0.3.0" # for DslEvaluator.print_code
|
55
55
|
spec.add_dependency "gems"
|
56
56
|
spec.add_dependency "hashie"
|
57
|
-
spec.add_dependency "jets-api"
|
57
|
+
spec.add_dependency "jets-api", ">= 0.1.4"
|
58
|
+
spec.add_dependency "jets-git"
|
58
59
|
spec.add_dependency "jets-html-sanitizer"
|
59
60
|
spec.add_dependency "kramdown"
|
60
61
|
spec.add_dependency "memoist"
|
@@ -4,7 +4,7 @@ module Jets::AwsServices
|
|
4
4
|
@@stack_exists_cache = [] # helps with CloudFormation rate limit
|
5
5
|
def stack_exists?(stack_name)
|
6
6
|
return false if Jets.env.test?
|
7
|
-
return true if ENV['
|
7
|
+
return true if ENV['JETS_NO_INTERNET']
|
8
8
|
return true if @@stack_exists_cache.include?(stack_name)
|
9
9
|
|
10
10
|
exist = nil
|
@@ -76,7 +76,7 @@ module Jets::Builders
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def exist_on_s3?(filename)
|
79
|
-
return false if ENV['
|
79
|
+
return false if ENV['JETS_NO_INTERNET']
|
80
80
|
s3_key = "jets/code/#{filename}"
|
81
81
|
begin
|
82
82
|
Jets.logger.debug "Checking s3://#{s3_bucket}/#{s3_key}"
|
@@ -131,6 +131,7 @@ module Jets::Builders
|
|
131
131
|
# We do not want to grab this as part of the live request because it is slow.
|
132
132
|
def store_s3_base_url
|
133
133
|
return if Jets.config.mode == "job"
|
134
|
+
return unless gemfile_include?("sprockets-jets")
|
134
135
|
write_s3_base_url("#{stage_area}/code/config/s3_base_url.txt")
|
135
136
|
end
|
136
137
|
|
@@ -192,9 +193,7 @@ module Jets::Builders
|
|
192
193
|
puts "Skip compiling assets".color(:yellow) # useful for debugging
|
193
194
|
return true
|
194
195
|
end
|
195
|
-
|
196
|
-
return true unless Jets.config.respond_to?(:assets)
|
197
|
-
Jets.config.assets.enable_webpack
|
196
|
+
Jets.config.mode == "job"
|
198
197
|
end
|
199
198
|
|
200
199
|
# Different url for these. Examples:
|
@@ -233,7 +232,7 @@ module Jets::Builders
|
|
233
232
|
# Checking this way because when using jets standalone for Afterburner mode we don't want to run into
|
234
233
|
# bundler gem collisions. TODO: figure out the a better way to handle the collisions.
|
235
234
|
lines = IO.readlines("#{Jets.root}/Gemfile")
|
236
|
-
lines.detect { |l| l =~ /#{name}/ }
|
235
|
+
lines.detect { |l| l =~ /#{name}/ && l !~ /\s.*#/ }
|
237
236
|
end
|
238
237
|
|
239
238
|
# Cleans out non-cached files like code-*.zip in Jets.build_root
|
@@ -8,7 +8,7 @@ def lambda_handler(event:, context:)
|
|
8
8
|
return
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
<% if @vars.process_type == "controller" -%>
|
12
12
|
route = Jets::Router.find_route_by_event(event)
|
13
13
|
controller = route.controller_name
|
14
14
|
action = route.action_name
|
data/lib/jets/cfn/deployment.rb
CHANGED
@@ -13,33 +13,73 @@ module Jets::Cfn
|
|
13
13
|
|
14
14
|
def create
|
15
15
|
Jets.boot # needed since Jets is lazy loaded
|
16
|
-
return if
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
return if disabled?
|
17
|
+
@stack = find_stack(@stack_name)
|
18
|
+
record_deployment if @stack
|
19
|
+
end
|
20
20
|
|
21
|
-
|
21
|
+
def delete
|
22
|
+
Jets.boot # needed since Jets is lazy loaded
|
23
|
+
return if disabled?
|
24
|
+
@stack = find_stack(@stack_name)
|
25
|
+
delete_deployment if @stack
|
22
26
|
end
|
23
27
|
|
24
|
-
def
|
25
|
-
|
26
|
-
resp
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
def delete_deployment
|
29
|
+
resp = Jets::Api::Stack.retrieve("current")
|
30
|
+
return if resp["error"] == "not_found"
|
31
|
+
return unless resp["id"]
|
32
|
+
resp = Jets::Api::Stack.delete(resp["id"])
|
33
|
+
puts resp["message"] # IE: Stack demo-dev deleted
|
34
|
+
resp
|
35
|
+
rescue Jets::Api::RequestError => e
|
36
|
+
puts "WARNING: Unable to delete release and stack. #{e.class}: #{e.message}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def record_deployment
|
40
|
+
params = stack_params.merge(git_info.params)
|
41
|
+
params["message"] = create_message
|
42
|
+
resp = Jets::Api::Release.create(params)
|
43
|
+
# Instead of check_for_error_message!(resp) we want to customize it a bit
|
44
|
+
if resp && resp["error"]
|
45
|
+
$stderr.puts "WARN: There was an error creating the release."
|
46
|
+
$stderr.puts "WARN: #{resp["error"]}"
|
47
|
+
exit 1
|
48
|
+
end
|
33
49
|
puts "Release version: #{resp["version"]}" if resp["version"]
|
34
50
|
resp
|
35
51
|
rescue Jets::Api::RequestError => e
|
36
52
|
puts "WARNING: Unable to create release. #{e.class}: #{e.message}"
|
37
53
|
end
|
38
54
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
55
|
+
def stack_params
|
56
|
+
{
|
57
|
+
stack_arn: @stack.stack_id,
|
58
|
+
stack_status: @stack.stack_status,
|
59
|
+
message: create_message,
|
60
|
+
deploy_user: deploy_user,
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def deploy_user
|
65
|
+
ENV['JETS_DEPLOY_USER'] || git_info.user.first_name || ENV['USER']
|
66
|
+
end
|
67
|
+
|
68
|
+
def git_info
|
69
|
+
Jets::Git::Info.new(@options)
|
70
|
+
end
|
71
|
+
memoize :git_info
|
72
|
+
|
73
|
+
def create_message
|
74
|
+
if @options[:message]
|
75
|
+
@options[:message][0..255]
|
76
|
+
else
|
77
|
+
@rollback_version ? "Rollback to #{@rollback_version}" : "Deploy"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def disabled?
|
82
|
+
Jets.config.pro.disable || !Jets::Api.token
|
43
83
|
end
|
44
84
|
end
|
45
85
|
end
|
@@ -4,7 +4,7 @@ class Jets::Cfn::Resource::ApiGateway::RestApi
|
|
4
4
|
include Jets::AwsServices
|
5
5
|
|
6
6
|
def get
|
7
|
-
return default if ENV['
|
7
|
+
return default if ENV['JETS_NO_INTERNET']
|
8
8
|
return default unless stack_exists?(parent_stack_name) && api_gateway_exists?
|
9
9
|
|
10
10
|
if changed?
|
@@ -17,7 +17,7 @@ class Jets::Cfn::Resource::ApiGateway::RestApi
|
|
17
17
|
|
18
18
|
def auto_replace_prompt
|
19
19
|
return if ENV['JETS_API_AUTO_REPLACE']
|
20
|
-
return unless
|
20
|
+
return unless Jets::Command.original_cli_command == "deploy"
|
21
21
|
case Jets.config.api.auto_replace
|
22
22
|
when nil
|
23
23
|
puts message.routes_changed
|
@@ -14,8 +14,9 @@ class Jets::Cfn::Resource::ApiGateway::RestApi::Routes::Change
|
|
14
14
|
return [] if data.nil?
|
15
15
|
|
16
16
|
data.map do |item|
|
17
|
+
http_method = item.dig('options','method') || item.dig('options','http_method')
|
17
18
|
Jets::Router::Route.new(
|
18
|
-
http_method:
|
19
|
+
http_method: http_method,
|
19
20
|
path: item['path'],
|
20
21
|
to: item['to'],
|
21
22
|
engine: item['engine'],
|
@@ -5,13 +5,19 @@ class Jets::Cfn::Resource::ApiGateway::RestApi::Routes
|
|
5
5
|
|
6
6
|
def changed?
|
7
7
|
return false unless parent_stack_exists?
|
8
|
-
return
|
8
|
+
return true if reset?
|
9
|
+
|
9
10
|
# Note: Variable.changed? will likely always true in one_apigw_method_for_all_routes mode
|
10
|
-
# since parent variables are allowed to vary.
|
11
|
+
# since parent variables are allowed to vary in Jets v5.
|
12
|
+
if Jets.config.cfn.build.routes == "one_apigw_method_for_all_routes"
|
13
|
+
MediaTypes.changed? || To.changed?
|
14
|
+
else
|
15
|
+
MediaTypes.changed? || To.changed? || Variable.changed? || Page.changed?
|
16
|
+
end
|
17
|
+
end
|
11
18
|
|
12
|
-
|
13
|
-
|
14
|
-
ENV['JETS_RESET'] || ENV['JETS_API_REPLACE'] || ENV['JETS_REPLACE_API']
|
19
|
+
def reset?
|
20
|
+
ENV['JETS_RESET'] || ENV['JETS_API_REPLACE'] || ENV['JETS_REPLACE_API']
|
15
21
|
end
|
16
22
|
|
17
23
|
def parent_stack_exists?
|
@@ -47,13 +47,13 @@ module Jets::Cfn::Resource::S3
|
|
47
47
|
@@name = nil
|
48
48
|
def name
|
49
49
|
return @@name if @@name
|
50
|
-
return "fake-bucket" if ENV['
|
50
|
+
return "fake-bucket" if ENV['JETS_NO_INTERNET'] || ENV['JETS_TEMPLATES']
|
51
51
|
|
52
52
|
resp = nil
|
53
53
|
begin
|
54
54
|
resp = cfn.describe_stacks(stack_name: Jets::Names.parent_stack_name)
|
55
55
|
rescue Aws::CloudFormation::Errors::ValidationError => e
|
56
|
-
if e.message.include?('does not exist') &&
|
56
|
+
if e.message.include?('does not exist') && Jets::Command.original_cli_command == 'build' # jets build
|
57
57
|
return "no-bucket-yet" # for jets build without s3 bucket yet
|
58
58
|
else
|
59
59
|
raise
|
data/lib/jets/command/base.rb
CHANGED
@@ -99,6 +99,11 @@ module Jets
|
|
99
99
|
end
|
100
100
|
|
101
101
|
dispatch(command, args.dup, nil, config)
|
102
|
+
rescue Thor::InvocationError => e
|
103
|
+
puts e.message.color(:red) # message already has ERROR prefix
|
104
|
+
self.full_namespace = full_namespace # store for help. clean:log => log
|
105
|
+
dispatch("help", [], nil, config)
|
106
|
+
exit 1
|
102
107
|
end
|
103
108
|
|
104
109
|
def printing_commands
|
@@ -1,6 +1 @@
|
|
1
|
-
Check if
|
2
|
-
|
3
|
-
# Sources for check for pre-compiled Lambda gems. Checks the list in order.
|
4
|
-
Jets.application.configure do
|
5
|
-
config.gems.source = "https://api.serverlessgems.com/api/v1"
|
6
|
-
end
|
1
|
+
Check if precompiled gems are available from Jets Pro.
|
@@ -7,7 +7,7 @@ This defaults to the controller Lambda function in the `one_lambda_for_all_contr
|
|
7
7
|
|
8
8
|
If you want to follow the logs use the `-f` flag.
|
9
9
|
|
10
|
-
❯ jets logs
|
10
|
+
❯ jets logs -f
|
11
11
|
Tailing logs for /aws/lambda/demo-dev-controller
|
12
12
|
|
13
13
|
If you want to see the production logs:
|
@@ -5,33 +5,15 @@
|
|
5
5
|
+---------+-----------------+--------------+---------+
|
6
6
|
| Version | Status | Released At | Message |
|
7
7
|
+---------+-----------------+--------------+---------+
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
| 24 | UPDATE_COMPLETE | 11 hours ago | Deploy |
|
12
|
-
| 23 | DELETE_COMPLETE | 14 hours ago | Deleted |
|
13
|
-
| 22 | UPDATE_COMPLETE | 14 hours ago | Deploy |
|
14
|
-
| 21 | UPDATE_COMPLETE | 14 hours ago | Deploy |
|
15
|
-
| 20 | UPDATE_COMPLETE | 14 hours ago | Deploy |
|
16
|
-
| 19 | DELETE_COMPLETE | 14 hours ago | Deleted |
|
17
|
-
| 18 | UPDATE_COMPLETE | 14 hours ago | Deploy |
|
18
|
-
| 17 | UPDATE_COMPLETE | 17 hours ago | Deploy |
|
19
|
-
| 16 | UPDATE_COMPLETE | 18 hours ago | Deploy |
|
20
|
-
| 15 | UPDATE_COMPLETE | 18 hours ago | Deploy |
|
21
|
-
| 14 | DELETE_COMPLETE | 18 hours ago | Deleted |
|
22
|
-
| 13 | UPDATE_COMPLETE | 19 hours ago | Deploy |
|
23
|
-
| 12 | UPDATE_COMPLETE | 19 hours ago | Deploy |
|
24
|
-
| 11 | UPDATE_COMPLETE | 19 hours ago | Deploy |
|
25
|
-
| 10 | DELETE_COMPLETE | 19 hours ago | Deleted |
|
26
|
-
| 9 | UPDATE_COMPLETE | 21 hours ago | Deploy |
|
27
|
-
| 8 | UPDATE_COMPLETE | 21 hours ago | Deploy |
|
28
|
-
| 7 | DELETE_COMPLETE | 21 hours ago | Deleted |
|
29
|
-
| 6 | UPDATE_COMPLETE | 21 hours ago | Deploy |
|
30
|
-
| 5 | DELETE_COMPLETE | 22 hours ago | Deleted |
|
31
|
-
| 4 | UPDATE_COMPLETE | 22 hours ago | Deploy |
|
32
|
-
| 3 | UPDATE_COMPLETE | 22 hours ago | Deploy |
|
8
|
+
| 3 | UPDATE_COMPLETE | 10 hours ago | Deploy |
|
9
|
+
| 2 | UPDATE_COMPLETE | 18 hours ago | Deploy |
|
10
|
+
| 1 | UPDATE_COMPLETE | 22 hours ago | Deploy |
|
33
11
|
+---------+-----------------+--------------+---------+
|
34
12
|
|
35
13
|
The shown releases are paginated. If you need to see more releases you can use the `--page` option.
|
36
14
|
|
37
15
|
$ jets releases --page 2
|
16
|
+
|
17
|
+
## Other Commands
|
18
|
+
|
19
|
+
releases:info View detailed information for a release
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Jets::Command
|
2
|
+
module RakeDecorate
|
3
|
+
# Decorate this method because this does not get called until runtime.
|
4
|
+
# It's "lazy loaded" so we can avoid the Rails const being defined in general.
|
5
|
+
def [](task_name, scopes=nil)
|
6
|
+
super # => Rake::TaskManager#[]
|
7
|
+
rescue RuntimeError => e
|
8
|
+
# We require dummy/rails since this time because all the rake tasks have been loaded
|
9
|
+
# and we need to load dummy/rails to get the database configurations. Normally,
|
10
|
+
# we do not want to require dummy/rails because it defines the Rails.
|
11
|
+
# However, a "command not found" error, more accurately,
|
12
|
+
# a "rake task not found" error, has already been encountered.
|
13
|
+
# Also:
|
14
|
+
# require "dummy/rails" to prevent another error.
|
15
|
+
# from lib/active_record/railties/databases.rake
|
16
|
+
#
|
17
|
+
# NoMethodError: undefined method `env' for Rails:Module (NoMethodError)
|
18
|
+
# database_configs = ActiveRecord::DatabaseConfigurations.new(databases).configs_for(env_name: Rails.env)
|
19
|
+
#
|
20
|
+
require "jets/overrides/dummy/rails"
|
21
|
+
|
22
|
+
# Original error message from rake is something like this
|
23
|
+
#
|
24
|
+
# Don't know how to build task 'foo:bar' (See the list of available tasks with `jets --tasks`)
|
25
|
+
#
|
26
|
+
# With an ugly backtrace.
|
27
|
+
# We override the error message to be more user friendly.
|
28
|
+
#
|
29
|
+
# All of that in order for
|
30
|
+
# jets foo:bar
|
31
|
+
# to show a pretty error message.
|
32
|
+
$stderr.puts "ERROR: Could not find command: #{task_name.inspect}".color(:red)
|
33
|
+
require "jets/commands/help/help_command"
|
34
|
+
Jets::Command::HelpCommand.new.help
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/jets/command.rb
CHANGED
@@ -17,6 +17,8 @@ module Jets
|
|
17
17
|
|
18
18
|
HELP_MAPPINGS = %w(-h -? --help)
|
19
19
|
|
20
|
+
cattr_accessor :original_cli_command
|
21
|
+
|
20
22
|
class << self
|
21
23
|
def hidden_commands # :nodoc:
|
22
24
|
@hidden_commands ||= []
|
@@ -29,6 +31,7 @@ module Jets
|
|
29
31
|
# Receives a namespace, arguments, and the behavior to invoke the command.
|
30
32
|
def invoke(full_namespace, args = [], **config)
|
31
33
|
namespace = full_namespace = full_namespace.to_s
|
34
|
+
Jets::Command.original_cli_command = full_namespace
|
32
35
|
|
33
36
|
if char = namespace =~ /:(\w+)$/
|
34
37
|
command_name, namespace = $1, namespace.slice(0, char)
|
@@ -47,6 +50,12 @@ module Jets
|
|
47
50
|
if command && command.all_commands[command_name]
|
48
51
|
command.perform(full_namespace, command_name, args, config)
|
49
52
|
else
|
53
|
+
# Decorate the rake [] method in order to rescue the error and print out
|
54
|
+
# a user friendly message. This works to catch rake errors but
|
55
|
+
# unsure why cannot just rescue RuntimeError here.
|
56
|
+
# More details in the RakeDecorate module.
|
57
|
+
require "rake/application"
|
58
|
+
Rake::Application.send(:include, RakeDecorate)
|
50
59
|
args = ["--describe", full_namespace] if HELP_MAPPINGS.include?(args[0])
|
51
60
|
find_by_namespace("rake").perform(full_namespace, args, config)
|
52
61
|
end
|
@@ -89,7 +98,6 @@ module Jets
|
|
89
98
|
commands.each { |command| puts(" #{command}") }
|
90
99
|
end
|
91
100
|
|
92
|
-
private
|
93
101
|
COMMANDS_IN_USAGE = %w(
|
94
102
|
generate
|
95
103
|
console
|
@@ -117,6 +125,7 @@ module Jets
|
|
117
125
|
(visible_commands - COMMANDS_IN_USAGE - PRO_COMMANDS).sort
|
118
126
|
end
|
119
127
|
|
128
|
+
private
|
120
129
|
def command_type # :doc:
|
121
130
|
@command_type ||= "command"
|
122
131
|
end
|
@@ -33,14 +33,13 @@ module Jets::Command
|
|
33
33
|
cfn.delete_stack(stack_name: parent_stack_name)
|
34
34
|
puts "Deleting #{Jets.project_namespace.color(:green)}..."
|
35
35
|
|
36
|
+
stack = find_stack(parent_stack_name)
|
36
37
|
if @options[:wait]
|
37
|
-
stack = find_stack(parent_stack_name)
|
38
38
|
wait_for_stack
|
39
|
-
Jets::Cfn::Deployment.new(stack_name: stack.stack_id, message: "Deleted").create
|
40
39
|
end
|
40
|
+
Jets::Cfn::Deployment.new(stack_name: stack.stack_id).delete
|
41
41
|
|
42
42
|
delete_logs
|
43
|
-
|
44
43
|
puts "Project #{Jets.project_namespace.color(:green)} deleted!"
|
45
44
|
end
|
46
45
|
|
@@ -1,11 +1,27 @@
|
|
1
1
|
module Jets::Command
|
2
2
|
class ReleasesCommand < Base # :nodoc:
|
3
|
-
desc "
|
4
|
-
long_desc Help.text(:
|
3
|
+
desc "releases", "List releases"
|
4
|
+
long_desc Help.text(:releases)
|
5
5
|
paging_options(order: 'desc').call
|
6
|
+
option :sha, desc: "Show release git sha"
|
6
7
|
def perform
|
7
8
|
Release.new(options.merge(paging_params)).list
|
8
9
|
end
|
10
|
+
|
11
|
+
desc "releases:info", "View detailed information for a release"
|
12
|
+
long_desc Help.text(:info)
|
13
|
+
def info(version=nil)
|
14
|
+
if version.nil?
|
15
|
+
puts "ERROR: Must provide a version".color(:red)
|
16
|
+
puts <<~EOL
|
17
|
+
Example:
|
18
|
+
|
19
|
+
jets releases:info 3
|
20
|
+
EOL
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
Release.new(options.merge(version: version)).show
|
24
|
+
end
|
9
25
|
end
|
10
26
|
|
11
27
|
class Release
|
@@ -35,19 +51,26 @@ module Jets::Command
|
|
35
51
|
show_items(data)
|
36
52
|
end
|
37
53
|
rescue Jets::Api::RequestError => e
|
38
|
-
puts "ERROR: Unable to list
|
54
|
+
puts "ERROR: Unable to list releases. #{e.class}: #{e.message}"
|
39
55
|
end
|
40
56
|
|
41
57
|
def show_items(items)
|
42
58
|
presenter = CliFormat::Presenter.new
|
43
|
-
|
59
|
+
header = ["Version", "Status", "Released At", "Message"]
|
60
|
+
header << "Git Sha" if @options[:sha]
|
61
|
+
presenter.header = header
|
44
62
|
items.each do |item|
|
45
63
|
version = item["version"]
|
46
64
|
status = item["stack_status"]
|
47
65
|
released_at = item["pretty_created_at"] || item["created_at"]
|
48
66
|
message = item["message"] || "Deployed"
|
67
|
+
message = message[0..50]
|
49
68
|
|
50
69
|
row = [version, status, format_time(released_at), message]
|
70
|
+
if @options[:sha]
|
71
|
+
sha = item["git_sha"].to_s[0..7] if item["git_sha"]
|
72
|
+
row << sha
|
73
|
+
end
|
51
74
|
presenter.rows << row
|
52
75
|
end
|
53
76
|
presenter.show
|
@@ -66,7 +89,37 @@ module Jets::Command
|
|
66
89
|
resp = Jets::Api::Release.retrieve(version)
|
67
90
|
check_for_error_message!(resp)
|
68
91
|
rescue Jets::Api::RequestError => e
|
69
|
-
puts "ERROR: Unable to get
|
92
|
+
puts "ERROR: Unable to get release. #{e.class}: #{e.message}"
|
93
|
+
end
|
94
|
+
|
95
|
+
def show
|
96
|
+
release = get(@options[:version])
|
97
|
+
release_at = release['pretty_created_at'] || release['created_at']
|
98
|
+
|
99
|
+
data = [
|
100
|
+
["Version", release['version']],
|
101
|
+
["Status", release['stack_status']],
|
102
|
+
["Released At", format_time(release_at)],
|
103
|
+
["Message", release['message']],
|
104
|
+
["User", release['deploy_user']],
|
105
|
+
["Git Branch", release['git_branch']],
|
106
|
+
["Git Sha", release['git_sha']],
|
107
|
+
["Git Message", release['git_message']],
|
108
|
+
["Git Url", release['git_url']],
|
109
|
+
["Git Dirty", release['git_dirty']],
|
110
|
+
["Jets Env", release['jets_env']],
|
111
|
+
["Jets Extra", release['jets_extra']],
|
112
|
+
["Jets Version", release['jets_version']],
|
113
|
+
["Ruby Version", release['ruby_version']],
|
114
|
+
["Region", release['region']],
|
115
|
+
]
|
116
|
+
column1_width = data.map { |row| row[1].nil? ? 0 : row[0].to_s.length }.max
|
117
|
+
column2_width = data.map { |row| row[1].nil? ? 0 : row[1].to_s.length }.max
|
118
|
+
|
119
|
+
puts Jets.project_namespace
|
120
|
+
data.each do |row|
|
121
|
+
puts "#{row[0].ljust(column1_width)} #{row[1]}" unless row[1].nil?
|
122
|
+
end
|
70
123
|
end
|
71
124
|
end
|
72
125
|
end
|
@@ -4,7 +4,7 @@ module Jets::Command
|
|
4
4
|
class RollbackCommand < Base # :nodoc:
|
5
5
|
desc "rollback", "Rollback to a previous release"
|
6
6
|
long_desc Help.text(:rollback)
|
7
|
-
def perform(version
|
7
|
+
def perform(version)
|
8
8
|
Rollback.new(options.merge(version: version)).run
|
9
9
|
end
|
10
10
|
end
|
@@ -15,14 +15,6 @@ module Jets::Command
|
|
15
15
|
def initialize(options={})
|
16
16
|
@options = options
|
17
17
|
@version = options[:version]
|
18
|
-
# Handle more gracefully than the way Jets does it currently
|
19
|
-
if @version.nil?
|
20
|
-
puts <<~EOL
|
21
|
-
ERROR: version required
|
22
|
-
Usage: jets rollback VERSION
|
23
|
-
EOL
|
24
|
-
exit 1
|
25
|
-
end
|
26
18
|
end
|
27
19
|
|
28
20
|
def run
|
data/lib/jets/core.rb
CHANGED
@@ -88,7 +88,13 @@ module Jets::Core
|
|
88
88
|
def parsed_project_name
|
89
89
|
lines = IO.readlines("#{Jets.root}/config/application.rb")
|
90
90
|
project_name_line = lines.find { |l| l =~ /config\.project_name.*=/ && l !~ /^\s+#/ }
|
91
|
-
|
91
|
+
if project_name_line
|
92
|
+
parsed = project_name_line.gsub(/.*=/,'').strip
|
93
|
+
# The +? makes it non-greedy
|
94
|
+
# See: https://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Repetition
|
95
|
+
md = parsed.match(/['"](.+?)['"]/)
|
96
|
+
md ? md[1] : raise("Unable to parse project name from config/application.rb: #{project_name_line}")
|
97
|
+
end
|
92
98
|
end
|
93
99
|
memoize :parsed_project_name
|
94
100
|
|
data/lib/jets/dotenv/ssm.rb
CHANGED
@@ -37,7 +37,7 @@ class Jets::Dotenv
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def fetch_ssm_value(key, value)
|
40
|
-
return "fake-ssm-value" if ENV['
|
40
|
+
return "fake-ssm-value" if ENV['JETS_NO_INTERNET']
|
41
41
|
|
42
42
|
name = ssm_name(key, value)
|
43
43
|
response = ssm.get_parameter(name: name, with_decryption: true)
|
@@ -45,6 +45,9 @@ class Jets::Dotenv
|
|
45
45
|
rescue Aws::SSM::Errors::ParameterNotFound
|
46
46
|
@missing << [key, value, name]
|
47
47
|
''
|
48
|
+
rescue Aws::SSM::Errors::ValidationException
|
49
|
+
puts "ERROR: Invalid SSM parameter name: #{name.inspect}".color(:red)
|
50
|
+
raise
|
48
51
|
end
|
49
52
|
|
50
53
|
def ssm_name(key, value)
|
@@ -56,7 +56,6 @@ module Jets::Generators::Overrides::App
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def copy_project
|
59
|
-
# directory ".", project_folder, copy_options
|
60
59
|
directory ".", ".", copy_options
|
61
60
|
end
|
62
61
|
|
@@ -69,9 +68,6 @@ module Jets::Generators::Overrides::App
|
|
69
68
|
excludes.uniq!
|
70
69
|
|
71
70
|
unless @database
|
72
|
-
# Do not even generate the config/database.yml because
|
73
|
-
# Jets webpacker:install bombs and tries to load the db since it sees a
|
74
|
-
# config/database.yml but there's no database pg gem configured.
|
75
71
|
excludes += %w[
|
76
72
|
database.yml
|
77
73
|
db
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Variables in here are available and shared across all environments: development, production, etc
|
2
|
+
# Docs: https://docs.rubyonjets.com/docs/env-files/
|
3
|
+
|
4
|
+
# Examples:
|
5
|
+
# DATABASE_URL="mysql2://user:pass@host.com/db_name?pool=5" # raw value as-is
|
6
|
+
# SSM can be use to reference a parameter store value
|
7
|
+
# DATABASE_URL=SSM # conventionally references /PROJECT_NAME/JETS_ENV/DATABASE_URL
|
8
|
+
# DATABASE_URL=SSM # /demo/development/DATABASE_URL
|
9
|
+
# DATABASE_URL=SSM:database-url # /demo/development/database-url
|
10
|
+
# DATABASE_URL=SSM:/path/to/database-url # /path/to/database-url
|
@@ -3,7 +3,7 @@ Jets.application.configure do
|
|
3
3
|
|
4
4
|
config.cache_classes = false
|
5
5
|
config.eager_load = false
|
6
|
-
config.logging.event = false #
|
6
|
+
config.logging.event = false # can be useful for CloudWatch
|
7
7
|
|
8
8
|
<%- unless options[:mode] == 'job' -%>
|
9
9
|
# Show full error reports.
|
@@ -2,7 +2,7 @@ Jets.application.configure do
|
|
2
2
|
config.cache_classes = true
|
3
3
|
config.eager_load = true
|
4
4
|
config.log_level = :info
|
5
|
-
config.logging.event =
|
5
|
+
config.logging.event = false # can be useful for CloudWatch
|
6
6
|
|
7
7
|
<%- unless options[:mode] == 'job' -%>
|
8
8
|
config.consider_all_requests_local = false
|
data/lib/jets/job/base.rb
CHANGED
@@ -38,7 +38,7 @@ module Jets::Job
|
|
38
38
|
call = Jets::Commands::Call::Caller.new(function_name, JSON.dump(event), invocation_type: "Event")
|
39
39
|
call.run
|
40
40
|
else
|
41
|
-
|
41
|
+
Jets.logger.info "INFO: Not on AWS Lambda. In local mode perform_later executes the job with perform_now instead."
|
42
42
|
perform_now(meth, event, context)
|
43
43
|
end
|
44
44
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Jets::Job::Dsl
|
2
2
|
module DynamodbEvent
|
3
3
|
def dynamodb_event(table_name_without_namespace, options={})
|
4
|
-
return if ENV['
|
4
|
+
return if ENV['JETS_NO_INTERNET'] # Disable during build since jets build tries to init this
|
5
5
|
|
6
6
|
table_name = add_dynamodb_table_namespace(table_name_without_namespace)
|
7
7
|
stream_arn = full_dynamodb_stream_arn(table_name)
|
data/lib/jets/router/matcher.rb
CHANGED
@@ -32,7 +32,7 @@ module Jets::Router
|
|
32
32
|
# Checking the request_method_from_hidden_method_field so that handler can find the right route
|
33
33
|
# super early in the process. Otherwise lambda routes to the wrong controller action.
|
34
34
|
@request_method = request_method || @request.request_method_from_hidden_method_field || @request.request_method.to_s.upcase
|
35
|
-
@request_path = @request.path
|
35
|
+
@request_path = strip_format(@request.path)
|
36
36
|
route = find_route
|
37
37
|
match_constraints(route) if route
|
38
38
|
end
|
@@ -43,7 +43,7 @@ module Jets::Router
|
|
43
43
|
def find_by_env(env)
|
44
44
|
@env = env
|
45
45
|
@request_method = env["REQUEST_METHOD"] || "GET"
|
46
|
-
@request_path = env["PATH_INFO"]
|
46
|
+
@request_path = strip_format(env["PATH_INFO"])
|
47
47
|
find_route
|
48
48
|
end
|
49
49
|
|
@@ -87,12 +87,16 @@ module Jets::Router
|
|
87
87
|
end
|
88
88
|
memoize :mount
|
89
89
|
|
90
|
+
def strip_format(path)
|
91
|
+
path.sub(/\..+$/, '') # Remove format from the end of the path
|
92
|
+
end
|
93
|
+
|
90
94
|
def match?(route)
|
91
95
|
# Immediately stop checking when the request http_method: GET, POST, ANY, etc
|
92
96
|
# doesnt match.
|
93
97
|
return false if request_method != route.http_method && route.http_method != "ANY"
|
94
98
|
|
95
|
-
route_path = route.path
|
99
|
+
route_path = strip_format(route.path)
|
96
100
|
route_path = "#{mount.at}#{route_path}" if mount
|
97
101
|
|
98
102
|
if request_path == route_path
|
data/lib/jets/version.rb
CHANGED
data/lib/jets.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: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -376,6 +376,20 @@ dependencies:
|
|
376
376
|
version: '0'
|
377
377
|
- !ruby/object:Gem::Dependency
|
378
378
|
name: jets-api
|
379
|
+
requirement: !ruby/object:Gem::Requirement
|
380
|
+
requirements:
|
381
|
+
- - ">="
|
382
|
+
- !ruby/object:Gem::Version
|
383
|
+
version: 0.1.4
|
384
|
+
type: :runtime
|
385
|
+
prerelease: false
|
386
|
+
version_requirements: !ruby/object:Gem::Requirement
|
387
|
+
requirements:
|
388
|
+
- - ">="
|
389
|
+
- !ruby/object:Gem::Version
|
390
|
+
version: 0.1.4
|
391
|
+
- !ruby/object:Gem::Dependency
|
392
|
+
name: jets-git
|
379
393
|
requirement: !ruby/object:Gem::Requirement
|
380
394
|
requirements:
|
381
395
|
- - ">="
|
@@ -859,6 +873,7 @@ files:
|
|
859
873
|
- lib/jets/command/help/upgrade.md
|
860
874
|
- lib/jets/command/help/url.md
|
861
875
|
- lib/jets/command/helpers/editor.rb
|
876
|
+
- lib/jets/command/rake_decorate.rb
|
862
877
|
- lib/jets/commands.rb
|
863
878
|
- lib/jets/commands/application/application_command.rb
|
864
879
|
- lib/jets/commands/build/build_command.rb
|
@@ -962,7 +977,9 @@ files:
|
|
962
977
|
- lib/jets/generators/overrides/app/USAGE
|
963
978
|
- lib/jets/generators/overrides/app/app_generator.rb
|
964
979
|
- lib/jets/generators/overrides/app/helpers.rb
|
965
|
-
- lib/jets/generators/overrides/app/templates/.
|
980
|
+
- lib/jets/generators/overrides/app/templates/.env
|
981
|
+
- lib/jets/generators/overrides/app/templates/.gitignore.tt
|
982
|
+
- lib/jets/generators/overrides/app/templates/.jetsignore
|
966
983
|
- lib/jets/generators/overrides/app/templates/.rspec
|
967
984
|
- lib/jets/generators/overrides/app/templates/Gemfile.tt
|
968
985
|
- lib/jets/generators/overrides/app/templates/README.md
|
@@ -1187,9 +1204,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1187
1204
|
version: 2.7.0
|
1188
1205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1189
1206
|
requirements:
|
1190
|
-
- - "
|
1207
|
+
- - ">="
|
1191
1208
|
- !ruby/object:Gem::Version
|
1192
|
-
version:
|
1209
|
+
version: '0'
|
1193
1210
|
requirements: []
|
1194
1211
|
rubygems_version: 3.4.20
|
1195
1212
|
signing_key:
|
File without changes
|