jets 2.1.1 → 2.1.2
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/.codebuild/README.md +10 -60
- data/.codebuild/docs/bin/build.sh +6 -0
- data/.codebuild/docs/bin/cli_docs.sh +5 -0
- data/.codebuild/docs/bin/git_commit.sh +27 -0
- data/.codebuild/docs/bin/git_setup.sh +19 -0
- data/.codebuild/docs/bin/subnav.sh +14 -0
- data/.codebuild/docs/buildspec.yml +8 -0
- data/.codebuild/docs/project.rb +10 -0
- data/.gitignore +5 -5
- data/CHANGELOG.md +8 -0
- data/jets.gemspec +5 -5
- data/lib/jets/aws_services/stack_status.rb +5 -1
- data/lib/jets/cfn/builders/api_gateway_builder.rb +10 -19
- data/lib/jets/cfn/builders/api_resources_builder.rb +46 -0
- data/lib/jets/cfn/builders/parent_builder.rb +15 -0
- data/lib/jets/cfn/built_template.rb +15 -0
- data/lib/jets/commands/clean/log.rb +18 -1
- data/lib/jets/commands/delete.rb +14 -1
- data/lib/jets/commands/deploy.rb +43 -12
- data/lib/jets/commands/help/build.md +1 -1
- data/lib/jets/commands/help/{destroy.md → degenerate.md} +1 -1
- data/lib/jets/commands/help/upgrade.md +2 -0
- data/lib/jets/commands/main.rb +2 -1
- data/lib/jets/commands/templates/skeleton/Gemfile.tt +1 -0
- data/lib/jets/naming.rb +4 -0
- data/lib/jets/resource/api_gateway/resource.rb +7 -3
- data/lib/jets/resource/api_gateway/rest_api/change_detection.rb +0 -32
- data/lib/jets/resource/api_gateway/rest_api/routes/change.rb +9 -1
- data/lib/jets/resource/api_gateway/rest_api/routes/change/base.rb +26 -5
- data/lib/jets/resource/api_gateway/rest_api/routes/change/media_types.rb +36 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change/page.rb +93 -0
- data/lib/jets/resource/api_gateway/rest_api/routes/change/to.rb +0 -4
- data/lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb +0 -4
- data/lib/jets/resource/child_stack/api_resource.rb +60 -0
- data/lib/jets/resource/child_stack/api_resource/page.rb +20 -0
- data/lib/jets/resource/child_stack/app_class.rb +14 -3
- data/lib/jets/router.rb +57 -40
- data/lib/jets/router/method_creator/code.rb +3 -1
- data/lib/jets/router/method_creator/edit.rb +6 -1
- data/lib/jets/router/method_creator/index.rb +9 -3
- data/lib/jets/router/method_creator/new.rb +6 -1
- data/lib/jets/router/method_creator/show.rb +6 -1
- data/lib/jets/router/route.rb +1 -0
- data/lib/jets/version.rb +1 -1
- metadata +22 -17
- data/.codebuild/bin/jets +0 -3
- data/.codebuild/buildspec-base.yml +0 -14
- data/.codebuild/integration.sh +0 -72
- data/.codebuild/jets.postman_collection.json +0 -323
- data/.codebuild/scripts/install-docker.sh +0 -12
- data/.codebuild/scripts/install-dynamodb-local.sh +0 -22
- data/.codebuild/scripts/install-java.sh +0 -22
- data/.codebuild/scripts/install-node.sh +0 -4
@@ -0,0 +1,60 @@
|
|
1
|
+
# Implements:
|
2
|
+
#
|
3
|
+
# definition
|
4
|
+
# template_filename
|
5
|
+
#
|
6
|
+
module Jets::Resource::ChildStack
|
7
|
+
class ApiResource < Base
|
8
|
+
def initialize(*)
|
9
|
+
super
|
10
|
+
@page = @options[:page]
|
11
|
+
end
|
12
|
+
|
13
|
+
def definition
|
14
|
+
{
|
15
|
+
"api_resources_#{@page}" => {
|
16
|
+
type: "AWS::CloudFormation::Stack",
|
17
|
+
# depends_on: "ApiGateway", # CloudFormation seems to be smart enough
|
18
|
+
properties: {
|
19
|
+
template_url: template_url,
|
20
|
+
parameters: parameters,
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def parameters
|
27
|
+
params = {}
|
28
|
+
# Since dont have all the info required.
|
29
|
+
# Read the template back to find the parameters required.
|
30
|
+
# Actually might be easier to rationalize this approach.
|
31
|
+
template_path = Jets::Naming.api_resources_template_path(@page)
|
32
|
+
template = Jets::Cfn::BuiltTemplate.get(template_path)
|
33
|
+
template['Parameters'].keys.each do |p|
|
34
|
+
case p
|
35
|
+
when "RestApi"
|
36
|
+
params[p] = "!GetAtt ApiGateway.Outputs.RestApi"
|
37
|
+
when "RootResourceId"
|
38
|
+
params[p] = "!GetAtt ApiGateway.Outputs.RootResourceId"
|
39
|
+
else
|
40
|
+
params[p] = "!GetAtt #{api_resource_page(p)}.Outputs.#{p}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
params
|
44
|
+
end
|
45
|
+
|
46
|
+
def api_resource_page(parameter)
|
47
|
+
Page.logical_id(parameter)
|
48
|
+
end
|
49
|
+
|
50
|
+
def outputs
|
51
|
+
{
|
52
|
+
logical_id => "!Ref #{logical_id}",
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def template_filename
|
57
|
+
"#{Jets.config.project_namespace}-api-resources-#{@page}.yml"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Jets::Resource::ChildStack::ApiResource
|
2
|
+
# Find the ApiResource Page that contains the AWS::ApiGateway::Resource
|
3
|
+
# Returns: logical id of ApiResource Page
|
4
|
+
class Page
|
5
|
+
def self.logical_id(parameter)
|
6
|
+
expression = "#{Jets::Naming.template_path_prefix}-api-resources-*"
|
7
|
+
# IE: path: #{Jets.build_root}/templates/demo-dev-2-api-resources-1.yml"
|
8
|
+
template_paths = Dir.glob(expression).sort.to_a
|
9
|
+
found_template = template_paths.detect do |path|
|
10
|
+
next unless File.file?(path)
|
11
|
+
|
12
|
+
template = Jets::Cfn::BuiltTemplate.get(path)
|
13
|
+
template['Outputs'].keys.include?(parameter)
|
14
|
+
end
|
15
|
+
md = found_template.match(/-(api-resources-\d+)/)
|
16
|
+
|
17
|
+
md[1].underscore.camelize # IE: ApiResources1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -62,13 +62,24 @@ module Jets::Resource::ChildStack
|
|
62
62
|
params = {
|
63
63
|
RestApi: "!GetAtt ApiGateway.Outputs.RestApi",
|
64
64
|
}
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
|
66
|
+
template_path = @path
|
67
|
+
template = Jets::Cfn::BuiltTemplate.get(template_path)
|
68
|
+
template['Parameters'].keys.each do |p|
|
69
|
+
case p
|
70
|
+
when /Resource$/ # AWS::ApiGateway::Resource in api-resources templates. IE: demo-dev-api-resources-2.yml
|
71
|
+
params[p] = "!GetAtt #{api_resource_page(p)}.Outputs.#{p}"
|
72
|
+
when 'RootResourceId'
|
73
|
+
params[p] = "!GetAtt ApiGateway.Outputs.RootResourceId"
|
74
|
+
end
|
68
75
|
end
|
69
76
|
params
|
70
77
|
end
|
71
78
|
|
79
|
+
def api_resource_page(parameter)
|
80
|
+
ApiResource::Page.logical_id(parameter)
|
81
|
+
end
|
82
|
+
|
72
83
|
def controller?
|
73
84
|
@path.include?('_controller.yml')
|
74
85
|
end
|
data/lib/jets/router.rb
CHANGED
@@ -107,57 +107,74 @@ module Jets
|
|
107
107
|
simple_routes + capture_routes + wildcard_routes
|
108
108
|
end
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
110
|
+
class << self
|
111
|
+
def has_controller?(name)
|
112
|
+
routes.detect { |r| r.controller_name == name }
|
113
|
+
end
|
113
114
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
115
|
+
# Class methods
|
116
|
+
def draw
|
117
|
+
drawn_router
|
118
|
+
end
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
|
120
|
+
@@drawn_router = nil
|
121
|
+
def drawn_router
|
122
|
+
return @@drawn_router if @@drawn_router
|
122
123
|
|
123
|
-
|
124
|
-
|
125
|
-
|
124
|
+
router = Jets.application.routes
|
125
|
+
@@drawn_router = router
|
126
|
+
end
|
126
127
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
128
|
+
def clear!
|
129
|
+
@@drawn_router = nil
|
130
|
+
Jets::Router::Helpers::NamedRoutesHelper.clear!
|
131
|
+
end
|
131
132
|
|
132
|
-
|
133
|
-
|
134
|
-
|
133
|
+
def routes
|
134
|
+
drawn_router.routes
|
135
|
+
end
|
135
136
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
137
|
+
# Returns all paths including subpaths.
|
138
|
+
# Example:
|
139
|
+
# Input: ["posts/:id/edit"]
|
140
|
+
# Output: ["posts", "posts/:id", "posts/:id/edit"]
|
141
|
+
def all_paths
|
142
|
+
drawn_router.all_paths
|
143
|
+
end
|
143
144
|
|
144
|
-
|
145
|
-
|
145
|
+
def help(routes)
|
146
|
+
return "Your routes table is empty." if routes.empty?
|
146
147
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
148
|
+
table = Text::Table.new
|
149
|
+
table.head = %w[As Verb Path Controller#action]
|
150
|
+
routes.each do |route|
|
151
|
+
table.rows << [route.as, route.method, route.path, route.to]
|
152
|
+
end
|
153
|
+
table
|
151
154
|
end
|
152
|
-
table
|
153
|
-
end
|
154
155
|
|
155
|
-
|
156
|
-
|
157
|
-
|
156
|
+
def all_routes_valid?
|
157
|
+
invalid_routes.empty?
|
158
|
+
end
|
159
|
+
|
160
|
+
def invalid_routes
|
161
|
+
routes.select { |r| !r.valid? }
|
162
|
+
end
|
163
|
+
|
164
|
+
def validate_routes!
|
165
|
+
check_route_connected_functions
|
166
|
+
end
|
158
167
|
|
159
|
-
|
160
|
-
|
168
|
+
# Checks that all routes are validate and have corresponding lambda functions
|
169
|
+
def check_route_connected_functions
|
170
|
+
return true if all_routes_valid?
|
171
|
+
|
172
|
+
puts "Please double check the routes below map to valid controllers:".color(:red)
|
173
|
+
invalid_routes.each do |route|
|
174
|
+
puts " /#{route.path} => #{route.controller_name}##{route.action_name}"
|
175
|
+
end
|
176
|
+
false
|
177
|
+
end
|
161
178
|
end
|
162
179
|
end
|
163
180
|
end
|
@@ -33,7 +33,7 @@ class Jets::Router::MethodCreator
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def action
|
36
|
-
@action || self.class.name.split('::').last.downcase
|
36
|
+
@action || self.class.name.split('::').last.downcase # MethodCreator::Edit, MethodCreator::New, etc
|
37
37
|
end
|
38
38
|
|
39
39
|
def full_as
|
@@ -55,6 +55,7 @@ class Jets::Router::MethodCreator
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def path_method
|
58
|
+
return if @as == :disabled
|
58
59
|
<<~EOL
|
59
60
|
def #{full_meth_name(:path)}#{meth_args}
|
60
61
|
"#{meth_result}"
|
@@ -63,6 +64,7 @@ class Jets::Router::MethodCreator
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def url_method
|
67
|
+
return if @as == :disabled
|
66
68
|
path_method_call = "#{full_meth_name(:path)}#{meth_args}"
|
67
69
|
# Note: It is important lazily get the value of ENV['JETS_HOST'] within the method.
|
68
70
|
# Since it is not set until the requrest goes through the main middleware.
|
@@ -1,7 +1,12 @@
|
|
1
1
|
class Jets::Router::MethodCreator
|
2
2
|
class Edit < Code
|
3
3
|
def meth_name
|
4
|
-
|
4
|
+
path_items = @path.to_s.split('/')
|
5
|
+
if method_name_leaf && path_items.size != 3
|
6
|
+
nil # fallback: do not define url method
|
7
|
+
else # comes from resources
|
8
|
+
join(action, singularize(full_as), singularize(method_name_leaf))
|
9
|
+
end
|
5
10
|
end
|
6
11
|
end
|
7
12
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Jets::Router::MethodCreator
|
2
2
|
class Index < Code
|
3
3
|
def meth_name
|
4
|
-
#
|
4
|
+
# TODO: figure out how to improve this and make easier to follow.
|
5
5
|
#
|
6
6
|
# Example 1:
|
7
7
|
#
|
@@ -32,9 +32,15 @@ class Jets::Router::MethodCreator
|
|
32
32
|
# all the info we need. In this tricky case, the method_name_leaf is set.
|
33
33
|
# We then have to reconstruct the meth_name.
|
34
34
|
#
|
35
|
+
|
35
36
|
if method_name_leaf
|
36
|
-
|
37
|
-
|
37
|
+
path_items = @path.to_s.split('/')
|
38
|
+
if path_items.size == 1
|
39
|
+
join(singularize(full_as), method_name_leaf) # reconstruct
|
40
|
+
else
|
41
|
+
nil # fallback: do not define url method
|
42
|
+
end
|
43
|
+
else # comes from resources
|
38
44
|
join(full_as) # construct entirely from scope info
|
39
45
|
end
|
40
46
|
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
class Jets::Router::MethodCreator
|
2
2
|
class New < Code
|
3
3
|
def meth_name
|
4
|
-
|
4
|
+
path_items = @path.to_s.split('/')
|
5
|
+
if method_name_leaf && path_items.size != 2
|
6
|
+
nil # fallback: do not define url method
|
7
|
+
else # comes from resources
|
8
|
+
join(action, singularize(full_as), singularize(method_name_leaf))
|
9
|
+
end
|
5
10
|
end
|
6
11
|
end
|
7
12
|
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
class Jets::Router::MethodCreator
|
2
2
|
class Show < Code
|
3
3
|
def meth_name
|
4
|
-
|
4
|
+
path_items = @path.to_s.split('/')
|
5
|
+
if method_name_leaf && path_items.size != 2
|
6
|
+
nil # fallback: do not define url method
|
7
|
+
else # comes from resources
|
8
|
+
join(singularize(full_as), singularize(method_name_leaf))
|
9
|
+
end
|
5
10
|
end
|
6
11
|
end
|
7
12
|
end
|
data/lib/jets/router/route.rb
CHANGED
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: 2.1.
|
4
|
+
version: 2.1.2
|
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-08-
|
11
|
+
date: 2019-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -529,10 +529,10 @@ dependencies:
|
|
529
529
|
- !ruby/object:Gem::Version
|
530
530
|
version: '0'
|
531
531
|
description: 'Jets is a framework that allows you to create serverless applications
|
532
|
-
with a beautiful language: Ruby. It includes everything required to build
|
533
|
-
|
534
|
-
|
535
|
-
|
532
|
+
with a beautiful language: Ruby. It includes everything required to build and deploy
|
533
|
+
an application. Jets leverages the power of Ruby to make serverless joyful for
|
534
|
+
everyone.'
|
535
|
+
email: tongueroo@gmail.com
|
536
536
|
executables:
|
537
537
|
- jets
|
538
538
|
extensions: []
|
@@ -540,14 +540,13 @@ extra_rdoc_files: []
|
|
540
540
|
files:
|
541
541
|
- ".circleci/config.yml"
|
542
542
|
- ".codebuild/README.md"
|
543
|
-
- ".codebuild/bin/
|
544
|
-
- ".codebuild/
|
545
|
-
- ".codebuild/
|
546
|
-
- ".codebuild/
|
547
|
-
- ".codebuild/
|
548
|
-
- ".codebuild/
|
549
|
-
- ".codebuild/
|
550
|
-
- ".codebuild/scripts/install-node.sh"
|
543
|
+
- ".codebuild/docs/bin/build.sh"
|
544
|
+
- ".codebuild/docs/bin/cli_docs.sh"
|
545
|
+
- ".codebuild/docs/bin/git_commit.sh"
|
546
|
+
- ".codebuild/docs/bin/git_setup.sh"
|
547
|
+
- ".codebuild/docs/bin/subnav.sh"
|
548
|
+
- ".codebuild/docs/buildspec.yml"
|
549
|
+
- ".codebuild/docs/project.rb"
|
551
550
|
- ".github/ISSUE_TEMPLATE.md"
|
552
551
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
553
552
|
- ".github/ISSUE_TEMPLATE/documentation.md"
|
@@ -609,6 +608,7 @@ files:
|
|
609
608
|
- lib/jets/camelizer.rb
|
610
609
|
- lib/jets/cfn/builders/api_deployment_builder.rb
|
611
610
|
- lib/jets/cfn/builders/api_gateway_builder.rb
|
611
|
+
- lib/jets/cfn/builders/api_resources_builder.rb
|
612
612
|
- lib/jets/cfn/builders/base_child_builder.rb
|
613
613
|
- lib/jets/cfn/builders/controller_builder.rb
|
614
614
|
- lib/jets/cfn/builders/function_builder.rb
|
@@ -617,6 +617,7 @@ files:
|
|
617
617
|
- lib/jets/cfn/builders/parent_builder.rb
|
618
618
|
- lib/jets/cfn/builders/rule_builder.rb
|
619
619
|
- lib/jets/cfn/builders/shared_builder.rb
|
620
|
+
- lib/jets/cfn/built_template.rb
|
620
621
|
- lib/jets/cfn/ship.rb
|
621
622
|
- lib/jets/cfn/status.rb
|
622
623
|
- lib/jets/cfn/upload.rb
|
@@ -653,9 +654,9 @@ files:
|
|
653
654
|
- lib/jets/commands/help/console.md
|
654
655
|
- lib/jets/commands/help/db/generate.md
|
655
656
|
- lib/jets/commands/help/dbconsole.md
|
657
|
+
- lib/jets/commands/help/degenerate.md
|
656
658
|
- lib/jets/commands/help/delete.md
|
657
659
|
- lib/jets/commands/help/deploy.md
|
658
|
-
- lib/jets/commands/help/destroy.md
|
659
660
|
- lib/jets/commands/help/dynamodb/generate.md
|
660
661
|
- lib/jets/commands/help/dynamodb/migrate.md
|
661
662
|
- lib/jets/commands/help/gems/check.md
|
@@ -856,6 +857,8 @@ files:
|
|
856
857
|
- lib/jets/resource/api_gateway/rest_api/routes.rb
|
857
858
|
- lib/jets/resource/api_gateway/rest_api/routes/change.rb
|
858
859
|
- lib/jets/resource/api_gateway/rest_api/routes/change/base.rb
|
860
|
+
- lib/jets/resource/api_gateway/rest_api/routes/change/media_types.rb
|
861
|
+
- lib/jets/resource/api_gateway/rest_api/routes/change/page.rb
|
859
862
|
- lib/jets/resource/api_gateway/rest_api/routes/change/to.rb
|
860
863
|
- lib/jets/resource/api_gateway/rest_api/routes/change/variable.rb
|
861
864
|
- lib/jets/resource/api_gateway/rest_api/routes/collision.rb
|
@@ -864,6 +867,8 @@ files:
|
|
864
867
|
- lib/jets/resource/base.rb
|
865
868
|
- lib/jets/resource/child_stack/api_deployment.rb
|
866
869
|
- lib/jets/resource/child_stack/api_gateway.rb
|
870
|
+
- lib/jets/resource/child_stack/api_resource.rb
|
871
|
+
- lib/jets/resource/child_stack/api_resource/page.rb
|
867
872
|
- lib/jets/resource/child_stack/app_class.rb
|
868
873
|
- lib/jets/resource/child_stack/base.rb
|
869
874
|
- lib/jets/resource/child_stack/shared.rb
|
@@ -967,7 +972,7 @@ files:
|
|
967
972
|
- readme/testing.md
|
968
973
|
- vendor/aws_data/Gemfile.lock
|
969
974
|
- vendor/aws_data/pkg/aws_data-0.1.0.gem
|
970
|
-
homepage:
|
975
|
+
homepage: https://rubyonjets.com
|
971
976
|
licenses:
|
972
977
|
- MIT
|
973
978
|
metadata: {}
|
@@ -1029,5 +1034,5 @@ requirements: []
|
|
1029
1034
|
rubygems_version: 3.0.3
|
1030
1035
|
signing_key:
|
1031
1036
|
specification_version: 4
|
1032
|
-
summary: Ruby Serverless Framework
|
1037
|
+
summary: Ruby Serverless Framework
|
1033
1038
|
test_files: []
|