belt 0.1.6 → 0.1.8
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/lib/belt/cli/app_detection.rb +6 -0
- data/lib/belt/cli/deploy_command.rb +15 -0
- data/lib/belt/cli/destroy_command.rb +320 -0
- data/lib/belt/cli/environment_command.rb +11 -0
- data/lib/belt/cli/frontend_command.rb +35 -3
- data/lib/belt/cli/frontend_setup_command.rb +35 -2
- data/lib/belt/cli/generate_command.rb +79 -38
- data/lib/belt/cli/new_command.rb +1 -3
- data/lib/belt/cli/routes_command/route_inference.rb +4 -0
- data/lib/belt/cli/routes_command.rb +1 -9
- data/lib/belt/cli/tables_command.rb +53 -15
- data/lib/belt/cli/views_command.rb +11 -8
- data/lib/belt/cli.rb +24 -3
- data/lib/belt/inflector.rb +58 -0
- data/lib/belt/lambda_handler.rb +11 -0
- data/lib/belt/route_dsl.rb +3 -11
- data/lib/belt/table_inference.rb +4 -18
- data/lib/belt/version.rb +1 -1
- data/lib/templates/environment/main.tf.erb +1 -1
- data/lib/templates/environment/outputs.tf.erb +5 -0
- data/lib/templates/frontend_infra/frontend.tf.erb +0 -4
- data/lib/templates/generate/controller.rb.erb +0 -1
- data/lib/templates/generate/model.rb.erb +0 -2
- data/lib/templates/new_app/lambda/config/environment.rb.erb +7 -1
- metadata +17 -2
- data/lib/templates/new_app/lambda/models/concerns/timestampable.rb.erb +0 -23
data/lib/belt/route_dsl.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative 'inflector'
|
|
4
|
+
|
|
3
5
|
module Belt
|
|
4
6
|
# DSL for defining API Gateway routes.
|
|
5
7
|
# Ported from terraform-provider-conveyor-belt/scripts/lib/route_dsl.rb
|
|
@@ -256,17 +258,7 @@ module Belt
|
|
|
256
258
|
end
|
|
257
259
|
|
|
258
260
|
def singularize(word)
|
|
259
|
-
|
|
260
|
-
"#{word[0..-4]}y"
|
|
261
|
-
elsif word.end_with?('xes') || word.end_with?('zes') || word.end_with?('ses')
|
|
262
|
-
word[0..-3]
|
|
263
|
-
elsif word.end_with?('ches') || word.end_with?('shes')
|
|
264
|
-
word[0..-3]
|
|
265
|
-
elsif word.end_with?('s') && !word.end_with?('ss')
|
|
266
|
-
word[0..-2]
|
|
267
|
-
else
|
|
268
|
-
word
|
|
269
|
-
end
|
|
261
|
+
Belt::Inflector.singularize(word)
|
|
270
262
|
end
|
|
271
263
|
end
|
|
272
264
|
|
data/lib/belt/table_inference.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative 'inflector'
|
|
4
|
+
|
|
3
5
|
module Belt
|
|
4
6
|
# Infers DynamoDB table names from route paths by matching against
|
|
5
7
|
# tables defined in a Terraform file containing aws_dynamodb_table resources.
|
|
@@ -45,27 +47,11 @@ module Belt
|
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
def pluralize(word)
|
|
48
|
-
|
|
49
|
-
"#{word[0..-2]}ies"
|
|
50
|
-
elsif word.end_with?('s', 'x', 'z', 'ch', 'sh')
|
|
51
|
-
"#{word}es"
|
|
52
|
-
else
|
|
53
|
-
"#{word}s"
|
|
54
|
-
end
|
|
50
|
+
Belt::Inflector.pluralize(word)
|
|
55
51
|
end
|
|
56
52
|
|
|
57
53
|
def singularize(word)
|
|
58
|
-
|
|
59
|
-
"#{word[0..-4]}y"
|
|
60
|
-
elsif word.end_with?('xes', 'zes', 'ses')
|
|
61
|
-
word[0..-3]
|
|
62
|
-
elsif word.end_with?('ches', 'shes')
|
|
63
|
-
word[0..-3]
|
|
64
|
-
elsif word.end_with?('s') && !word.end_with?('ss')
|
|
65
|
-
word[0..-2]
|
|
66
|
-
else
|
|
67
|
-
word
|
|
68
|
-
end
|
|
54
|
+
Belt::Inflector.singularize(word)
|
|
69
55
|
end
|
|
70
56
|
end
|
|
71
57
|
end
|
data/lib/belt/version.rb
CHANGED
|
@@ -38,7 +38,7 @@ resource "conveyor_belt" "main" {
|
|
|
38
38
|
app_name = var.app_name
|
|
39
39
|
lambda_source_dir = "${path.module}/../../lambda"
|
|
40
40
|
lambda_shared_dirs = ["controllers", "helpers", "lib", "models", "views"]
|
|
41
|
-
frontend_urls = ["http://localhost:3000"]
|
|
41
|
+
frontend_urls = var.environment == "prod" ? [] : ["http://localhost:3000"]
|
|
42
42
|
friendly_errors = var.environment != "prod"
|
|
43
43
|
|
|
44
44
|
# Per-lambda configuration: env vars, timeouts, memory
|
|
@@ -15,4 +15,10 @@ end
|
|
|
15
15
|
|
|
16
16
|
# Load lib and models
|
|
17
17
|
Dir[File.join(__dir__, '..', 'lib', '**', '*.rb')].sort.each { |f| require f }
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
models_dir = File.join(__dir__, '..', 'models')
|
|
20
|
+
all_models = Dir[File.join(models_dir, '**', '*.rb')].sort
|
|
21
|
+
app_record = all_models.find { |f| File.basename(f) == 'application_record.rb' }
|
|
22
|
+
rest = all_models - [app_record].compact
|
|
23
|
+
require app_record if app_record
|
|
24
|
+
rest.each { |f| require f }
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: belt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stowzilla
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: activesupport
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '7.0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '7.0'
|
|
26
40
|
- !ruby/object:Gem::Dependency
|
|
27
41
|
name: lambda_loadout
|
|
28
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -59,6 +73,7 @@ files:
|
|
|
59
73
|
- lib/belt/cli/bucket_security.rb
|
|
60
74
|
- lib/belt/cli/console_command.rb
|
|
61
75
|
- lib/belt/cli/deploy_command.rb
|
|
76
|
+
- lib/belt/cli/destroy_command.rb
|
|
62
77
|
- lib/belt/cli/env_resolver.rb
|
|
63
78
|
- lib/belt/cli/environment_command.rb
|
|
64
79
|
- lib/belt/cli/frontend_command.rb
|
|
@@ -79,6 +94,7 @@ files:
|
|
|
79
94
|
- lib/belt/helpers/cors_origin.rb
|
|
80
95
|
- lib/belt/helpers/error_logging.rb
|
|
81
96
|
- lib/belt/helpers/response.rb
|
|
97
|
+
- lib/belt/inflector.rb
|
|
82
98
|
- lib/belt/lambda_handler.rb
|
|
83
99
|
- lib/belt/observability.rb
|
|
84
100
|
- lib/belt/parameters.rb
|
|
@@ -117,7 +133,6 @@ files:
|
|
|
117
133
|
- lib/templates/new_app/lambda/controllers/application_controller.rb.erb
|
|
118
134
|
- lib/templates/new_app/lambda/lib/routes/routes.rb.erb
|
|
119
135
|
- lib/templates/new_app/lambda/models/application_record.rb.erb
|
|
120
|
-
- lib/templates/new_app/lambda/models/concerns/timestampable.rb.erb
|
|
121
136
|
- lib/templates/views/Edit.jsx.erb
|
|
122
137
|
- lib/templates/views/Form.jsx.erb
|
|
123
138
|
- lib/templates/views/Index.jsx.erb
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Concerns
|
|
4
|
-
module Timestampable
|
|
5
|
-
def self.included(base)
|
|
6
|
-
base.attr_accessor :created_at, :updated_at
|
|
7
|
-
base.set_callback :create, :before, :set_timestamps
|
|
8
|
-
base.set_callback :update, :before, :set_updated_at
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
def set_timestamps
|
|
14
|
-
now = Time.now.utc.iso8601
|
|
15
|
-
self.created_at ||= now
|
|
16
|
-
self.updated_at = now
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def set_updated_at
|
|
20
|
-
self.updated_at = Time.now.utc.iso8601
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|