jets 1.6.2 → 1.6.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75898252d0d7ef29286086cca3e59433da914f67bd9b42e66927beb9bd4b72e0
4
- data.tar.gz: 6d535ce82983daee425f36a670fcca6d7d2650fce3714fa196dbdd4be685a8c5
3
+ metadata.gz: c87194c6d0b415b564a28726756577210d6464cc0622300daf24126ff9d226d0
4
+ data.tar.gz: 7c0cc6ec4aff9f5e453a357953949b726613e57b240b8bf3b5e72b3eff98f48b
5
5
  SHA512:
6
- metadata.gz: e2b412fdc2e7271eb998359bc501d76539d683d332ef8545c6ed5d1572bcd833ec2c963d115ba0bbbaa2662e922c4b88760884cae1a3424446097b6a812d932c
7
- data.tar.gz: f57fa1a144e8b4328abfebc181d3bf7fd8df4dbed084ae7882eeee734ab1fa4557cd9d1d0733f115b675e7a9ad723b8b3199b1fe290d65177eabd115569b4261
6
+ metadata.gz: '0998620a1d9e0fd826361c781d0e68a524c94347480b2e28524a501cda53c823a4482acdf7d274044709b2999467188c9dc4eb2349666bbfb573efca5d2c33d0'
7
+ data.tar.gz: 51367be08a6964660d5c5211e37ae21d04a8f1cabe3d9de519db5229bac8c356010c6826ebaf6380bacc033da9534efb55a2210227b48088e257bb44110cca75
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/), even before v1.0.
5
5
 
6
+ ## [1.6.3]
7
+ - #168 cors specific authorization_type, default none
8
+
6
9
  ## [1.6.2]
7
10
  - #165 remove always trailing slash from Jets.root
8
11
  - #166 fix cors headers
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- jets (1.6.2)
14
+ jets (1.6.3)
15
15
  activerecord (~> 5.2.1)
16
16
  activesupport (~> 5.2.1)
17
17
  aws-sdk-apigateway
@@ -32,7 +32,7 @@ class Jets::Application
32
32
  def default_config
33
33
  config = ActiveSupport::OrderedOptions.new
34
34
  config.project_name = parse_project_name # must set early because other configs requires this
35
- config.cors = true
35
+ config.cors = false
36
36
  config.autoload_paths = default_autoload_paths
37
37
  config.extra_autoload_paths = []
38
38
  config.logger = Jets::Logger.new($stderr)
@@ -75,6 +75,7 @@ class Jets::Application
75
75
 
76
76
  config.api = ActiveSupport::OrderedOptions.new
77
77
  config.api.authorization_type = "NONE"
78
+ config.api.cors_authorization_type = nil # nil so ApiGateway::Cors#cors_authorization_type handles
78
79
  config.api.binary_media_types = ['multipart/form-data']
79
80
  config.api.endpoint_type = 'EDGE' # PRIVATE, EDGE, REGIONAL
80
81
 
@@ -144,10 +144,20 @@ class Jets::Builders
144
144
  # And this can cause issues with require 'bundler/setup'
145
145
  def remove_bundled_with(gemfile_lock)
146
146
  lines = IO.readlines(gemfile_lock)
147
- n = lines.index { |l| l.include?("BUNDLED WITH") }
148
- return unless n
149
147
 
150
- new_lines = lines[0..n-1]
148
+ # amount is the number of lines to remove
149
+ new_lines, capture, count, amount = [], true, 0, 2
150
+ lines.each do |l|
151
+ capture = false if l.include?('BUNDLED WITH')
152
+ if capture
153
+ new_lines << l
154
+ end
155
+ if capture == false
156
+ count += 1
157
+ capture = count > amount # renable capture
158
+ end
159
+ end
160
+
151
161
  content = new_lines.join('')
152
162
  IO.write(gemfile_lock, content)
153
163
  end
@@ -22,6 +22,19 @@
22
22
  jets deploy
23
23
  $
24
24
 
25
+ ## Mode Option
26
+
27
+ The `--mode` is a notable option. With it, you can generate different starter Jets projects. Examples:
28
+
29
+ jets new demo --mode html # default
30
+ jets new api --mode api
31
+ jets new cron --mode job
32
+
33
+ * The html mode generates a starter app useful for html web application.
34
+ * The api mode is useful for building an API.
35
+ * The job mode creates a very lightweight project. It is useful when you just need to run a Lambda function.
36
+
37
+ ## Repo Option
25
38
  Use the `--repo` flag to clone an example project from GitHub instead. With this flag, jets new command clones a jets project repo from GitHub:
26
39
 
27
40
  $ jets new blog --repo tongueroo/tutorial
@@ -37,7 +37,8 @@ private
37
37
  end
38
38
 
39
39
  def copy_options
40
- excludes = if @options[:mode] == 'job'
40
+ excludes = case @options[:mode]
41
+ when 'job'
41
42
  # For job mode: list of words to include in the exclude pattern and will not be generated.
42
43
  %w[
43
44
  Procfile
@@ -55,16 +56,22 @@ private
55
56
  yarn
56
57
  public
57
58
  ]
58
- elsif !@database
59
+ when 'api'
60
+ %w[
61
+ views
62
+ ]
63
+ else # html
64
+ []
65
+ end
66
+
67
+ unless @database
59
68
  # Do not even generated the config/database.yml because
60
69
  # jets webpacker:install bombs and tries to load the db since it sees a
61
70
  # config/database.yml but has there's no database pg gem configured.
62
- %w[
71
+ excludes += %w[
63
72
  database.yml
64
73
  models/application_record
65
74
  ]
66
- else
67
- []
68
75
  end
69
76
 
70
77
  if excludes.empty?
@@ -10,7 +10,7 @@ module Jets::Resource::ApiGateway
10
10
  properties: {
11
11
  resource_id: "!Ref #{resource_id}",
12
12
  rest_api_id: "!Ref #{RestApi.logical_id}",
13
- authorization_type: authorization_type,
13
+ authorization_type: cors_authorization_type,
14
14
  http_method: "OPTIONS",
15
15
  method_responses: [{
16
16
  status_code: '200',
@@ -46,6 +46,10 @@ module Jets::Resource::ApiGateway
46
46
  } # closes definition
47
47
  end
48
48
 
49
+ def cors_authorization_type
50
+ Jets.config.api.cors_authorization_type || @route.authorization_type || "NONE"
51
+ end
52
+
49
53
  def cors_logical_id
50
54
  "#{resource_logical_id}_cors_api_method"
51
55
  end
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "1.6.2"
2
+ VERSION = "1.6.3"
3
3
  end
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: 1.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen