jets 1.5.10 → 1.6.0

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: 39b6cde7b66e43e4c253e0f055952680298287d9e7c534c4a465ca075b3dfb62
4
- data.tar.gz: d3312104416979ca67bd31cebd3a7c2ba604185349c2c368de438d50a68914ef
3
+ metadata.gz: 525a55f0013d6870b5bd4a0fa2f63b981c8af0f82e1fbf6b2cabc847a9e6cb76
4
+ data.tar.gz: 17171ba50a0c0e422d7d128465c21c529b13ddfbe7513a7d752f20112a5f81b9
5
5
  SHA512:
6
- metadata.gz: 1b670d6b6a2c0189fd608d4a7ba61a02206a4ddf78d2c8eda2c4f06d8c4c1beddb2588b417211e697ea0b24f8c426975c9ab08819a56fc3da41f6c959fb272ca
7
- data.tar.gz: c84383ea55a03f9b0576fb5ea7c4a895a9e5ae818bd79df008a9e7f621f93ce2d5e4e189d7f4aa9a9a2c0fef12ae7a668747308b263785de0b8d0c46da8330f7
6
+ metadata.gz: ea140c8868652da36b15d10da8a681792d6623cfb76e8480841900e76a2ea7ce9fd0a7fbe30c570d0d51b7d514bc8d0c6a5d8f3259a9f97ff7df6ee85b484df9
7
+ data.tar.gz: cc4b2ac99cbb56a2ec20d276d57e6b3a232ca8e292decd9ceb26af704d668acdca1329ae29fdcb4d0b44317c4b6a77747d194c5d767f5fd9b10240388607f6cb
data/CHANGELOG.md CHANGED
@@ -3,6 +3,11 @@
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.0]
7
+ - #158 from mmyoji/fix-docs-urls
8
+ - #159 from patchkit-net/bugfix/invalid-longpath-collision Fix invalid collision detection on paths that already contains path variables
9
+ - #161 from tongueroo/iam-role-name remove pretty iam role name, let CloudFormation generate
10
+
6
11
  ## [1.5.10]
7
12
  - #157 Improve Route Change Detection: Path Variables
8
13
 
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- jets (1.5.10)
14
+ jets (1.6.0)
15
15
  activerecord (~> 5.2.1)
16
16
  activesupport (~> 5.2.1)
17
17
  aws-sdk-apigateway
data/README.md CHANGED
@@ -164,8 +164,8 @@ For more documentation, check out the official docs: [Ruby on Jets](http://rubyo
164
164
  * [Quick Start](http://rubyonjets.com/quick-start/)
165
165
  * [Local Jets Server](http://rubyonjets.com/docs/local-server/)
166
166
  * [REPL Console](http://rubyonjets.com/docs/repl-console/)
167
- * [Project Structure](http://rubyonjets.com/project-structure/)
168
- * [App Configuration](http://rubyonjets.com/app-config/)
167
+ * [Project Structure](http://rubyonjets.com/docs/structure/)
168
+ * [App Configuration](http://rubyonjets.com/docs/app-config/)
169
169
  * [Database Support](http://rubyonjets.com/docs/database-support/)
170
170
  * [Polymorphic Support](http://rubyonjets.com/docs/polymorphic-support/)
171
171
  * [Rails Support](http://rubyonjets.com/docs/rails-support/)
@@ -108,6 +108,7 @@ module Jets::Commands
108
108
  end
109
109
 
110
110
  def update_webpack_binstubs
111
+ return unless File.exist?("bin/webpack")
111
112
  lines = IO.readlines("bin/webpack")
112
113
  already_upgraded = lines.detect { |l| l =~ /WebpackRunner/ }
113
114
  return if already_upgraded
@@ -68,13 +68,43 @@ class Jets::Resource::ApiGateway::RestApi::Routes::Change
68
68
  # posts#new
69
69
  def recreate_to(method_uri)
70
70
  md = method_uri.match(/function:(.*)\//)
71
- function_name = md[1] # IE: demo-dev-posts_controller-new
72
- controller_action = function_name.sub("#{Jets.project_namespace}-", '')
71
+ function_arn = md[1] # IE: demo-dev-posts_controller-new
72
+ controller, action = get_controller_action(function_arn)
73
+ "#{controller}##{action}" # IE: posts#new
74
+ end
75
+
76
+ def get_controller_action(function_arn)
77
+ if function_arn.include?('_controller-')
78
+ controller_action_from_string(function_arn)
79
+ else
80
+ controller_action_from_api(function_arn)
81
+ end
82
+ end
83
+
84
+ # TODO: If this hits the Lambda Rate limit, then list_functions also contains the Lambda
85
+ # function description. So we can paginate through list_functions results and store
86
+ # description from there if needed.
87
+ # Dont think this will be needed though because controller_action_from_string gets called
88
+ # most of the time. Also, user might be able to request their Lambda limit to be increased.
89
+ def controller_action_from_api(function_arn)
90
+ desc = lambda_function_description(function_arn)
91
+ controller, action = desc.split('#')
92
+ controller = controller.underscore.sub(/_controller$/,'')
93
+ [controller, action]
94
+ end
95
+
96
+ def controller_action_from_string(function_arn)
97
+ controller_action = function_arn.sub("#{Jets.project_namespace}-", '')
73
98
  md = controller_action.match(/(.*)_controller-(.*)/)
74
99
  controller = md[1]
75
100
  controller = controller.gsub('-','/')
76
101
  action = md[2]
77
- "#{controller}##{action}" # IE: posts#new
102
+ [controller, action]
103
+ end
104
+
105
+ def lambda_function_description(function_arn)
106
+ resp = lambda.get_function(function_name: function_arn)
107
+ resp.configuration.description # contains full info: PostsController#index
78
108
  end
79
109
 
80
110
  # Duplicated in rest_api/change_detection.rb, base_path/role.rb, rest_api/routes.rb
@@ -68,6 +68,8 @@ class Jets::Resource::ApiGateway::RestApi::Routes
68
68
  end
69
69
 
70
70
  def parent?(parent, path)
71
+ return false if parent == path
72
+
71
73
  parent_parts = parent.split('/')
72
74
  path_parts = path.split('/')
73
75
 
@@ -14,8 +14,8 @@ module Jets::Resource::Iam
14
14
  "iam_role"
15
15
  end
16
16
 
17
- def role_name
18
- "#{Jets.config.project_namespace}-application-role"
17
+ def policy_name
18
+ "#{Jets.config.project_namespace}-application-policy"
19
19
  end
20
20
 
21
21
  def outputs
@@ -5,11 +5,12 @@ module Jets::Resource::Iam
5
5
  def definition
6
6
  logical_id = role_logical_id
7
7
 
8
+ # Do not assign pretty role_name because long controller names might hit the 64-char
9
+ # limit. Also, IAM roles are global, so assigning role names prevents cross region deploys.
8
10
  definition = {
9
11
  logical_id => {
10
12
  type: "AWS::IAM::Role",
11
13
  properties: {
12
- role_name: role_name,
13
14
  path: "/",
14
15
  assume_role_policy_document: {
15
16
  version: "2012-10-17",
@@ -24,7 +25,7 @@ module Jets::Resource::Iam
24
25
  }
25
26
 
26
27
  definition[logical_id][:properties][:policies] = [
27
- policy_name: "#{role_name}-policy",
28
+ policy_name: "#{policy_name[0..127]}", # required, limited to 128-chars
28
29
  policy_document: policy_document,
29
30
  ] unless policy_document['Statement'].empty?
30
31
 
@@ -12,9 +12,9 @@ module Jets::Resource::Iam
12
12
  "{namespace}_iam_role".underscore
13
13
  end
14
14
 
15
- def role_name
15
+ def policy_name
16
16
  class_namespace = replacements[:namespace].underscore.dasherize
17
- "#{Jets.config.project_namespace}-#{class_namespace}-role" # camelized because used as template value
17
+ "#{Jets.config.project_namespace}-#{class_namespace}-policy" # camelized because used as template value
18
18
  end
19
19
 
20
20
  def replacements
@@ -12,9 +12,9 @@ module Jets::Resource::Iam
12
12
  "{namespace}_iam_role".underscore
13
13
  end
14
14
 
15
- def role_name
15
+ def policy_name
16
16
  funcion_namespace = replacements[:namespace].underscore.dasherize
17
- "#{Jets.config.project_namespace}-#{funcion_namespace}-role" # camelized because used as template value
17
+ "#{Jets.config.project_namespace}-#{funcion_namespace}-policy" # camelized because used as template value
18
18
  end
19
19
 
20
20
  def replacements
@@ -125,10 +125,11 @@ module Jets::Resource::Lambda
125
125
  handler = full_handler(props)
126
126
  runtime = get_runtime(props)
127
127
  managed = {
128
- function_name: function_name,
129
128
  handler: handler,
130
129
  runtime: runtime,
130
+ description: description,
131
131
  }
132
+ managed[:function_name] = function_name if function_name
132
133
  layers = get_layers(runtime)
133
134
  managed[:layers] = layers if layers
134
135
  props.merge!(managed)
@@ -184,6 +185,7 @@ module Jets::Resource::Lambda
184
185
  "jets/code/code-#{checksum}.zip" # s3_key
185
186
  end
186
187
 
188
+ MAX_FUNCTION_NAME_SIZE = 64
187
189
  # Examples:
188
190
  # "#{Jets.config.project_namespace}-sleep_job-perform"
189
191
  # "demo-dev-sleep_job-perform"
@@ -195,7 +197,20 @@ module Jets::Resource::Lambda
195
197
  # method: admin-pages_controller-index
196
198
  method = @app_class.underscore
197
199
  method = method.sub('/','-').gsub(/[^0-9a-z\-_]/i, '') + "-#{@task.meth}"
198
- "#{Jets.config.project_namespace}-#{method}"
200
+ function_name = "#{Jets.config.project_namespace}-#{method}"
201
+ # Returns nil if function name is too long.
202
+ # CloudFormation will managed the the function name in this case.
203
+ # A pretty function name won't be generated but the deploy will be successful.
204
+ function_name.size > MAX_FUNCTION_NAME_SIZE ? nil : function_name
205
+ end
206
+
207
+ def description
208
+ # Example values:
209
+ # @app_class: Admin/PagesController
210
+ # @task.meth: index
211
+ # Returns:
212
+ # Admin/PagesController#index
213
+ "#{@app_class}##{@task.meth}"
199
214
  end
200
215
  end
201
216
  end
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "1.5.10"
2
+ VERSION = "1.6.0"
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: 1.5.10
4
+ version: 1.6.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: 2019-01-18 00:00:00.000000000 Z
11
+ date: 2019-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord