jets 2.3.14 → 2.3.19

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: ddbf1726e80a44319389bf13b4b22323517ae715d552fc503fe3b48dbc89160b
4
- data.tar.gz: 4671ee27bbb47bb3c413de748cc0c01ef3bdf14289f4cf28d0690f9019e7f269
3
+ metadata.gz: 67a692a8d7ee829132db3e1e89d656b5b7885c6f280185cfe7bd6c9a3b9ebc59
4
+ data.tar.gz: e2e410d872acf41f19284e610043c5b39159469eb7f576b395b27c2db0ab6dde
5
5
  SHA512:
6
- metadata.gz: ad4a8ceb595f021253d2f93bb3ec70c06a58d574478d3be3503756926ee1d3ca85e39f633aadba9499c8d741d86bccd44cd249a3d063a109e6c77397bbfad74c
7
- data.tar.gz: f00bcab89a774abea67c64a3b9aaf96a1b64ac0778303ac11a38043c343a7fd3cf9b2966bb92e1ee39603dc76d5b5eacdad157dcd0908e3c1bdc681d0bd892bc
6
+ metadata.gz: 9f05d1c81c5d69b3a2921301c69a5522a8b81e3be48515e7219f8ffdb76e90e441a1a5234c1465403545b3034a4073c82a478229f02fed1506b6bafca57bb1f6
7
+ data.tar.gz: 15ff2fdda4c2bc469f9cd08ebcbac4e393a29fdca7ac1980274d7ffcf9a4669b919af596e29088411a8896914a57acf7fe4f06ffcd9377fa72422eec764b36f0
@@ -3,6 +3,38 @@
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.3.19] - 2021-01-28
7
+ - #529 fix gem detection for some gems
8
+
9
+ ## [2.3.18]
10
+ - #514 Allow to define route that contains dot
11
+ - #515 set content type on upload by using extension so cloudfront will compress when serving
12
+ - #517 support nested query params in tests
13
+
14
+ ## [2.3.17]
15
+ - #472 Docs: Update cors-support.md
16
+ - #475 Docs: Update activerecord.md to include db:create step
17
+ - #476 Docs: Update authorizer-cognito.md
18
+ - #482 Docs: Fixed description for "jetpacker" gem in Gemfile
19
+ - #483 Docs: controllers Fix minor typo
20
+ - #489 Docs: call typo
21
+ - #490 Docs: authorizers typo
22
+ - #504 Docs: tutorial series
23
+ - #505 Docs: display more tutorial articles
24
+ - #509 Docs: Update lamdba permissions for minimal-iam-policy doc
25
+ - #512 Bug fix: fix on_lambda? check allow testing #512
26
+
27
+ ## [2.3.16]
28
+ - #466 fix application_config typo
29
+ - #467 Handle forbidden error from s3
30
+ - #468 authorization_scopes
31
+ - #469 Fixed typo from STMP to SMTP
32
+ - #470 remove json dependency
33
+ - #471 use `Bundler.with_unbundled_env` remove bundler deprecation
34
+
35
+ ## [2.3.15]
36
+ - #461 fix guesser lookup for long function names
37
+
6
38
  ## [2.3.14]
7
39
  - #432 filtered_parameters support
8
40
  - #447 improve nested routes support. order routes so that nested resources always work
data/backers.md CHANGED
@@ -15,4 +15,5 @@ Funds donated via Patreon go directly to support Tung Nguyen's full-time work on
15
15
  - Nate Clark
16
16
  - Hirokatsu Endo
17
17
  - Michael Choi
18
+ - Phan Lam
18
19
  <!--10 end-->
@@ -48,9 +48,8 @@ Gem::Specification.new do |spec|
48
48
  spec.add_dependency "dotenv"
49
49
  spec.add_dependency "gems" # jets-gems dependency
50
50
  spec.add_dependency "hashie"
51
- spec.add_dependency "jets-gems"
51
+ spec.add_dependency "jets-gems", "~> 0.2.3"
52
52
  spec.add_dependency "jets-html-sanitizer"
53
- spec.add_dependency "json"
54
53
  spec.add_dependency "kramdown"
55
54
  spec.add_dependency "memoist"
56
55
  spec.add_dependency "mimemagic"
@@ -67,4 +66,5 @@ Gem::Specification.new do |spec|
67
66
  spec.add_development_dependency "bundler"
68
67
  spec.add_development_dependency "rake"
69
68
  spec.add_development_dependency "rspec"
69
+ spec.add_development_dependency "cfn-status"
70
70
  end
@@ -18,6 +18,8 @@ $:.unshift("#{gem_root}/lib")
18
18
  $:.unshift("#{gem_root}/vendor/cfn-status/lib")
19
19
  require "cfn_status"
20
20
 
21
+ require "jets/core_ext/bundler"
22
+
21
23
  require "jets/autoloaders"
22
24
  Jets::Autoloaders.log! if ENV["JETS_AUTOLOAD_LOG"]
23
25
  Jets::Autoloaders.once.setup
@@ -82,7 +82,7 @@ module Jets::Builders
82
82
  begin
83
83
  s3.head_object(bucket: s3_bucket, key: s3_key)
84
84
  true
85
- rescue Aws::S3::Errors::NotFound
85
+ rescue Aws::S3::Errors::NotFound, Aws::S3::Errors::Forbidden
86
86
  false
87
87
  end
88
88
  end
@@ -235,7 +235,7 @@ module Jets::Builders
235
235
 
236
236
  # Need to capture JETS_ROOT since can be changed by Turbo mode
237
237
  jets_root = Jets.root
238
- Bundler.with_clean_env do
238
+ Bundler.with_unbundled_env do
239
239
  # Switch gemfile for Afterburner mode
240
240
  gemfile = ENV['BUNDLE_GEMFILE']
241
241
  ENV['BUNDLE_GEMFILE'] = "#{jets_root}/rack/Gemfile"
@@ -21,11 +21,23 @@ module Jets::Builders
21
21
  options = @options.merge(source_url: source)
22
22
  gem_extractor = Jets::Gems::Extract::Gem.new(gem_name, options)
23
23
  gem_extractor.run
24
+ rename_gem(gem_name)
24
25
  end
25
26
 
26
27
  tidy
27
28
  end
28
29
 
30
+ def rename_gem(gem_name)
31
+ ruby_folder = "#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Gems.ruby_folder}"
32
+ gems_folder = "#{ruby_folder}/gems"
33
+ expr = "#{gems_folder}/#{gem_name}-x*-{darwin,linux}"
34
+ src = Dir.glob(expr).first
35
+ return unless src
36
+
37
+ dest = src.sub("-darwin", "-linux")
38
+ FileUtils.mv(src, dest) unless File.exist?(dest) # looks like rename_gem actually runs twice
39
+ end
40
+
29
41
  def sh(command)
30
42
  puts "=> #{command}".color(:green)
31
43
  success = system(command)
@@ -59,14 +59,14 @@ module Jets::Builders
59
59
 
60
60
  FileUtils.rm_rf("#{cache_area}/.bundle")
61
61
  require "bundler" # dynamically require bundler so user can use any bundler
62
- Bundler.with_clean_env do
62
+ Bundler.with_unbundled_env do
63
63
  sh(
64
64
  "cd #{cache_area} && " \
65
65
  "env bundle install --path #{cache_area}/vendor/gems --without development test"
66
66
  )
67
67
  end
68
68
 
69
- remove_bundled_with("#{cache_area}/Gemfile.lock")
69
+ rewrite_gemfile_lock("#{cache_area}/Gemfile.lock")
70
70
 
71
71
  # Copy the Gemfile.lock back to the project in case it was updated.
72
72
  # For example we add the jets-rails to the Gemfile.
@@ -150,9 +150,10 @@ module Jets::Builders
150
150
 
151
151
  # Remove the BUNDLED WITH line since we don't control the bundler gem version on AWS Lambda
152
152
  # And this can cause issues with require 'bundler/setup'
153
- def remove_bundled_with(gemfile_lock)
153
+ def rewrite_gemfile_lock(gemfile_lock)
154
154
  lines = IO.readlines(gemfile_lock)
155
155
 
156
+ # Remove BUNDLED WITH
156
157
  # amount is the number of lines to remove
157
158
  new_lines, capture, count, amount = [], true, 0, 2
158
159
  lines.each do |l|
@@ -166,6 +167,27 @@ module Jets::Builders
166
167
  end
167
168
  end
168
169
 
170
+ # Replace things like nokogiri (1.11.1-x86_64-darwin) => nokogiri (1.11.1)
171
+ lines, new_lines = new_lines, []
172
+ lines.each do |l|
173
+ if l.include?("-x86_64-darwin")
174
+ l = l.sub('-x86_64-darwin','')
175
+ end
176
+ new_lines << l
177
+ end
178
+
179
+ # Make sure platform is ruby
180
+ lines, new_lines, marker = new_lines, [], false
181
+ lines.each do |l|
182
+ if marker # the next loop has the platform we want to replace
183
+ new_lines << " ruby\n"
184
+ marker = false
185
+ next
186
+ end
187
+ marker = l.include?('PLATFORMS')
188
+ new_lines << l
189
+ end
190
+
169
191
  content = new_lines.join('')
170
192
  IO.write(gemfile_lock, content)
171
193
  end
@@ -7,6 +7,13 @@ module Jets::Cfn
7
7
  include ActionView::Helpers::NumberHelper # number_to_human_size
8
8
 
9
9
  attr_reader :bucket_name
10
+
11
+ CONTENT_TYPES_BY_EXTENSION = {
12
+ '.css' => 'text/css',
13
+ '.js' => 'application/javascript',
14
+ '.html' => 'text/html'
15
+ }
16
+
10
17
  def initialize(bucket_name)
11
18
  @bucket_name = bucket_name
12
19
  end
@@ -90,8 +97,17 @@ module Jets::Cfn
90
97
 
91
98
  key = s3_key(full_path)
92
99
  obj = s3_resource.bucket(bucket_name).object(key)
93
- puts "Uploading s3://#{bucket_name}/#{key}" # uncomment to see and debug
94
- obj.upload_file(full_path, acl: "public-read", cache_control: cache_control)
100
+ puts "Uploading and setting content type for s3://#{bucket_name}/#{key}" # uncomment to see and debug
101
+ obj.upload_file(full_path, { acl: "public-read", cache_control: cache_control }.merge(content_type_headers(full_path)))
102
+ end
103
+
104
+ def content_type_headers(full_path)
105
+ content_type = CONTENT_TYPES_BY_EXTENSION[File.extname(full_path)]
106
+ if content_type
107
+ { content_type: content_type }
108
+ else
109
+ {}
110
+ end
95
111
  end
96
112
 
97
113
  def s3_key(full_path)
@@ -140,7 +140,7 @@ class Jets::Commands::Call
140
140
  puts "Pro tip: The Lambda Console Link to the #{function_name} function has been added to your clipboard." unless @options[:mute]
141
141
  end
142
142
 
143
- # TODO: Hook client_context up and maek sure it works. Think I've figure out how to sign client_context below.
143
+ # TODO: Hook client_context up and make sure it works. Think I've figure out how to sign client_context below.
144
144
  # Client context must be a valid Base64-encoded JSON object
145
145
  # Example: http://docs.aws.amazon.com/mobileanalytics/latest/ug/PutEvents.html
146
146
  def client_context
@@ -36,9 +36,11 @@ class Jets::Commands::Call
36
36
  def generated_function_name(function_name)
37
37
  if function_name.size > Jets::MAX_FUNCTION_NAME_SIZE # name generated by CloudFormation
38
38
  logical_id = @class_name.gsub('::','')
39
- app_stack_arn = lookup(parent_stack[:outputs], logical_id)
40
39
 
41
- resources = stack_resources(app_stack_arn)
40
+ parent_resources = stack_resources(parent_stack.stack_id)
41
+ app_stack = parent_resources.find { |s| s.logical_resource_id == logical_id }
42
+
43
+ resources = stack_resources(app_stack.physical_resource_id)
42
44
  resource = resources.find { |r| r.logical_resource_id == method_name.camelize + "LambdaFunction" } # method_name only contains the method
43
45
  resource.physical_resource_id # actual function name
44
46
  else
@@ -41,7 +41,7 @@ class Jets::Commands::Import
41
41
  end
42
42
 
43
43
  def bundle_install
44
- Bundler.with_clean_env do
44
+ Bundler.with_unbundled_env do
45
45
  run "cd rack && bundle install"
46
46
  end
47
47
  end
@@ -43,7 +43,7 @@ module Jets::Commands
43
43
  puts Jets::Booter.message
44
44
  Jets::Booter.check_config_ru!
45
45
  Jets::RackServer.start(options) unless ENV['JETS_RACK'] == '0' # rack server runs in background by default
46
- Bundler.with_clean_env do
46
+ Bundler.with_unbundled_env do
47
47
  system(command)
48
48
  end
49
49
  end
@@ -61,7 +61,7 @@ module Jets::Commands
61
61
  end
62
62
 
63
63
  def bundle_install
64
- Bundler.with_clean_env do
64
+ Bundler.with_unbundled_env do
65
65
  system("BUNDLE_IGNORE_CONFIG=1 bundle install")
66
66
  end
67
67
  end
@@ -1,9 +1,9 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "jets", git: "https://github.com/tongueroo/jets.git", submodules: true, branch: "master"
3
+ gem "jets"
4
4
 
5
5
  <% if @webpacker -%>
6
- # Include jetpacker if you are you are building html pages
6
+ # Include jetpacker if you are building html pages
7
7
  gem "jetpacker"
8
8
  <% end -%>
9
9
  <% if @database == 'postgresql' %>
@@ -6,7 +6,8 @@ class Jets::Controller
6
6
  class_attribute :auth_type,
7
7
  :auth_to,
8
8
  :auth_options, # for only and except filters
9
- :api_key_needed
9
+ :api_key_needed,
10
+ :authorization_scopes_value
10
11
  end
11
12
 
12
13
  class_methods do
@@ -31,6 +32,14 @@ class Jets::Controller
31
32
  end
32
33
  end
33
34
 
35
+ def authorization_scopes(value=nil)
36
+ if !value.nil?
37
+ self.authorization_scopes_value = value
38
+ else
39
+ self.authorization_scopes_value
40
+ end
41
+ end
42
+
34
43
  def authorizer_metadata
35
44
  Jets::Router::Route::Authorizer.metadata(auth_to)
36
45
  end
@@ -0,0 +1,7 @@
1
+ # Bundler 2.0 does yet not have with_unbundled_env
2
+ # Bundler 2.1 deprecates with_unbundled_env for with_unbundled_env
3
+
4
+ require "bundler"
5
+ def Bundler.with_unbundled_env(&block)
6
+ with_clean_env(&block)
7
+ end unless Bundler.respond_to?(:with_unbundled_env)
@@ -42,7 +42,7 @@ module Jets::Job
42
42
 
43
43
  private
44
44
  def on_lambda?
45
- !!ENV['AWS_LAMBDA_FUNCTION_NAME'] || Jets.env.test?
45
+ !!ENV['AWS_LAMBDA_FUNCTION_NAME']
46
46
  end
47
47
  end
48
48
  end
@@ -34,7 +34,7 @@ module Jets
34
34
  def serve
35
35
  # Note, looks like stopping jets server with Ctrl-C sends the TERM signal
36
36
  # down to the sub bin/rackup command cleans up the child process fine.
37
- Bundler.with_clean_env do
37
+ Bundler.with_unbundled_env do
38
38
  args = ''
39
39
  # only forward the host option, port is always 9292 for simplicity
40
40
  if @options[:host]
@@ -36,6 +36,8 @@ module Jets::Resource::ApiGateway
36
36
  method_responses: []
37
37
  }
38
38
  props[:authorizer_id] = authorizer_id if authorizer_id
39
+ props[:authorization_scopes] = authorization_scopes if authorization_scopes
40
+
39
41
  props
40
42
  end
41
43
 
@@ -94,7 +96,7 @@ module Jets::Resource::ApiGateway
94
96
  def camelized_path
95
97
  path = @route.path
96
98
  path = "homepage" if path == ''
97
- path.gsub('/','_').gsub(':','').gsub('*','').camelize
99
+ path.gsub('/','_').gsub(':','').gsub('*','').gsub('.','').camelize
98
100
  end
99
101
  end
100
102
  end
@@ -28,5 +28,14 @@ class Jets::Resource::ApiGateway::Method
28
28
  controller_klass.api_key_required ||
29
29
  Jets.config.api.api_key_required
30
30
  end
31
+
32
+ def authorization_scopes
33
+ if @route.authorization_scopes
34
+ authorization_scopes = @route.authorization_scopes
35
+ elsif controller_klass.authorization_scopes
36
+ authorization_scopes = controller_klass.authorization_scopes
37
+ end
38
+ authorization_scopes
39
+ end
31
40
  end
32
41
  end
@@ -76,7 +76,7 @@ module Jets::Resource::ApiGateway
76
76
  private
77
77
  # Similar path_logical_id method in resource/route.rb
78
78
  def path_logical_id(path)
79
- path.gsub('/','_').gsub(':','').gsub('*','').gsub('-','_').camelize
79
+ path.gsub('/','_').gsub(':','').gsub('*','').gsub('-','_').gsub('.','_').camelize
80
80
  end
81
81
  end
82
82
  end
@@ -52,8 +52,8 @@ module Jets::Resource::Lambda
52
52
  environment: { variables: environment },
53
53
  }
54
54
 
55
- appplication_config = Jets.application.config.function.to_h
56
- baseline.merge(appplication_config)
55
+ application_config = Jets.application.config.function.to_h
56
+ baseline.merge(application_config)
57
57
  end
58
58
 
59
59
  # Class properties example:
@@ -211,4 +211,4 @@ module Jets::Resource::Lambda
211
211
  "#{@app_class}##{@task.meth}"
212
212
  end
213
213
  end
214
- end
214
+ end
@@ -16,6 +16,10 @@ class Jets::Router::Route
16
16
  @options[:authorizer]
17
17
  end
18
18
 
19
+ def authorization_scopes
20
+ @options[:authorization_scopes]
21
+ end
22
+
19
23
  def authorization_type
20
24
  @options[:authorization_type] || inferred_authorization_type
21
25
  end
@@ -46,7 +46,7 @@ module Jets::SpecHelpers::Controllers
46
46
 
47
47
  params.query_params.each do |key, value|
48
48
  json['queryStringParameters'] ||= {}
49
- json['queryStringParameters'][key.to_s] = value.to_s
49
+ json['queryStringParameters'][key.to_s] = value
50
50
  end
51
51
 
52
52
  json
@@ -110,7 +110,7 @@ class Jets::Turbo
110
110
  # TODO: remove duplication, copied from jets/commands/import/base.rb
111
111
  # And modified it slightly
112
112
  def bundle_install
113
- Bundler.with_clean_env do
113
+ Bundler.with_unbundled_env do
114
114
  sh "cd #{build_area}/#{@project_folder}/rack && bundle install"
115
115
  end
116
116
  end
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "2.3.14"
2
+ VERSION = "2.3.19"
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: 2.3.14
4
+ version: 2.3.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-18 00:00:00.000000000 Z
11
+ date: 2021-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -308,16 +308,16 @@ dependencies:
308
308
  name: jets-gems
309
309
  requirement: !ruby/object:Gem::Requirement
310
310
  requirements:
311
- - - ">="
311
+ - - "~>"
312
312
  - !ruby/object:Gem::Version
313
- version: '0'
313
+ version: 0.2.3
314
314
  type: :runtime
315
315
  prerelease: false
316
316
  version_requirements: !ruby/object:Gem::Requirement
317
317
  requirements:
318
- - - ">="
318
+ - - "~>"
319
319
  - !ruby/object:Gem::Version
320
- version: '0'
320
+ version: 0.2.3
321
321
  - !ruby/object:Gem::Dependency
322
322
  name: jets-html-sanitizer
323
323
  requirement: !ruby/object:Gem::Requirement
@@ -332,20 +332,6 @@ dependencies:
332
332
  - - ">="
333
333
  - !ruby/object:Gem::Version
334
334
  version: '0'
335
- - !ruby/object:Gem::Dependency
336
- name: json
337
- requirement: !ruby/object:Gem::Requirement
338
- requirements:
339
- - - ">="
340
- - !ruby/object:Gem::Version
341
- version: '0'
342
- type: :runtime
343
- prerelease: false
344
- version_requirements: !ruby/object:Gem::Requirement
345
- requirements:
346
- - - ">="
347
- - !ruby/object:Gem::Version
348
- version: '0'
349
335
  - !ruby/object:Gem::Dependency
350
336
  name: kramdown
351
337
  requirement: !ruby/object:Gem::Requirement
@@ -556,6 +542,20 @@ dependencies:
556
542
  - - ">="
557
543
  - !ruby/object:Gem::Version
558
544
  version: '0'
545
+ - !ruby/object:Gem::Dependency
546
+ name: cfn-status
547
+ requirement: !ruby/object:Gem::Requirement
548
+ requirements:
549
+ - - ">="
550
+ - !ruby/object:Gem::Version
551
+ version: '0'
552
+ type: :development
553
+ prerelease: false
554
+ version_requirements: !ruby/object:Gem::Requirement
555
+ requirements:
556
+ - - ">="
557
+ - !ruby/object:Gem::Version
558
+ version: '0'
559
559
  description: 'Jets is a framework that allows you to create serverless applications
560
560
  with a beautiful language: Ruby. It includes everything required to build and deploy
561
561
  an application. Jets leverages the power of Ruby to make serverless joyful for
@@ -797,6 +797,7 @@ files:
797
797
  - lib/jets/controller/response.rb
798
798
  - lib/jets/controller/stage.rb
799
799
  - lib/jets/core.rb
800
+ - lib/jets/core_ext/bundler.rb
800
801
  - lib/jets/core_ext/kernel.rb
801
802
  - lib/jets/db.rb
802
803
  - lib/jets/dotenv.rb
@@ -1102,7 +1103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1102
1103
  - !ruby/object:Gem::Version
1103
1104
  version: '0'
1104
1105
  requirements: []
1105
- rubygems_version: 3.1.2
1106
+ rubygems_version: 3.2.5
1106
1107
  signing_key:
1107
1108
  specification_version: 4
1108
1109
  summary: Ruby Serverless Framework