souls 0.48.2 → 0.51.1
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/README.md +1 -0
- data/lib/souls/api/generate/application.rb +1 -64
- data/lib/souls/api/generate/mutation.rb +4 -4
- data/lib/souls/api/generate/resolver.rb +5 -5
- data/lib/souls/api/generate/rspec_factory.rb +2 -2
- data/lib/souls/api/generate/rspec_mutation.rb +5 -5
- data/lib/souls/api/generate/rspec_query.rb +4 -4
- data/lib/souls/api/generate/rspec_resolver.rb +4 -4
- data/lib/souls/api/generate/type.rb +2 -2
- data/lib/souls/api/update/mutation.rb +2 -2
- data/lib/souls/api/update/resolver.rb +2 -2
- data/lib/souls/api/update/rspec_factory.rb +1 -1
- data/lib/souls/api/update/rspec_mutation.rb +2 -2
- data/lib/souls/api/update/rspec_resolver.rb +1 -1
- data/lib/souls/api/update/type.rb +1 -1
- data/lib/souls/cli/create/index.rb +3 -2
- data/lib/souls/cli/gcloud/compute/index.rb +33 -28
- data/lib/souls/cli/gcloud/sql/index.rb +11 -5
- data/lib/souls/cli/init/index.rb +6 -4
- data/lib/souls/cli/sync/pubsub.rb +2 -1
- data/lib/souls/utils/index.rb +65 -2
- data/lib/souls/version.rb +1 -1
- data/lib/souls/versions/.souls_api_version +1 -1
- data/lib/souls/versions/.souls_worker_version +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f33e396906a4395206a96f9a03b7307834a97ad6e822c2096b975d5d955f801b
|
4
|
+
data.tar.gz: 264989a25039e9c2204c43da8f9d56c743296380b09816b8e2af39be54d836e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d302fbbb23b4d012feebc0a048dcc5927ff131fe443485aacf3545d220ac724133f281bb2630f4a042392df5d4d058a9f0b85c53ccbeb824ab2bf329729be9a6
|
7
|
+
data.tar.gz: 4b204a8528595595aa2cf255d6060ccd7ba34265ac2d08e3c3e06c8163ce66f788ef2e83073762cc63138bbfe32d4b72e867a8c5b6b0d7199e9fbcf364b81a12
|
data/README.md
CHANGED
@@ -102,6 +102,7 @@ souls upgrade gemfile
|
|
102
102
|
Souls.configure do |config|
|
103
103
|
config.app = "souls-api"
|
104
104
|
config.project_id = "souls-api"
|
105
|
+
config.region = "asia-northeast1"
|
105
106
|
config.endpoint = "/endpoint"
|
106
107
|
config.strain = "api"
|
107
108
|
config.fixed_gems = ["selenium-webdriver", "pg"]
|
@@ -27,21 +27,6 @@ module Souls
|
|
27
27
|
]
|
28
28
|
end
|
29
29
|
|
30
|
-
def get_type_and_name(line)
|
31
|
-
line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
32
|
-
end
|
33
|
-
|
34
|
-
def get_tables
|
35
|
-
path = "./db/schema.rb"
|
36
|
-
tables = []
|
37
|
-
File.open(path, "r") do |f|
|
38
|
-
f.each_line.with_index do |line, _i|
|
39
|
-
tables << line.split("\"")[1] if line.include?("create_table")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
tables
|
43
|
-
end
|
44
|
-
|
45
30
|
def test_dir
|
46
31
|
FileUtils.mkdir_p("./app/graphql/mutations")
|
47
32
|
FileUtils.mkdir_p("./app/graphql/queries")
|
@@ -62,54 +47,6 @@ module Souls
|
|
62
47
|
puts("test dir created!")
|
63
48
|
end
|
64
49
|
|
65
|
-
def type_check(type)
|
66
|
-
{
|
67
|
-
bigint: "Integer",
|
68
|
-
string: "String",
|
69
|
-
float: "Float",
|
70
|
-
text: "String",
|
71
|
-
datetime: "String",
|
72
|
-
date: "String",
|
73
|
-
boolean: "Boolean",
|
74
|
-
integer: "Integer"
|
75
|
-
}[type.to_sym]
|
76
|
-
end
|
77
|
-
|
78
|
-
def get_type(type)
|
79
|
-
{
|
80
|
-
bigint: "Integer",
|
81
|
-
string: "String",
|
82
|
-
float: "Float",
|
83
|
-
text: "String",
|
84
|
-
datetime: "GraphQL::Types::ISO8601DateTime",
|
85
|
-
date: "GraphQL::Types::ISO8601DateTime",
|
86
|
-
boolean: "Boolean",
|
87
|
-
integer: "Integer"
|
88
|
-
}[type.to_sym]
|
89
|
-
end
|
90
|
-
|
91
|
-
def get_test_type(type)
|
92
|
-
{
|
93
|
-
bigint: "rand(1..10)",
|
94
|
-
float: 4.2,
|
95
|
-
string: '"MyString"',
|
96
|
-
text: '"MyString"',
|
97
|
-
datetime: "Time.now",
|
98
|
-
date: "Time.now.strftime('%F')",
|
99
|
-
boolean: false,
|
100
|
-
integer: "rand(1..10)"
|
101
|
-
}[type.to_sym]
|
102
|
-
end
|
103
|
-
|
104
|
-
def table_check(line: "", class_name: "")
|
105
|
-
if line.include?("create_table") && (line.split[1].gsub("\"", "").gsub(",", "") == class_name.pluralize.to_s)
|
106
|
-
|
107
|
-
return true
|
108
|
-
end
|
109
|
-
|
110
|
-
false
|
111
|
-
end
|
112
|
-
|
113
50
|
def scaffold(class_name: "user")
|
114
51
|
singularized_class_name = class_name.singularize
|
115
52
|
model(class_name: singularized_class_name)
|
@@ -133,7 +70,7 @@ module Souls
|
|
133
70
|
|
134
71
|
def scaffold_all
|
135
72
|
puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
|
136
|
-
Souls
|
73
|
+
Souls.get_tables.each do |table|
|
137
74
|
Souls::Api::Generate.scaffold(class_name: table.singularize)
|
138
75
|
puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
|
139
76
|
end
|
@@ -48,7 +48,7 @@ module Souls
|
|
48
48
|
end
|
49
49
|
field = "[String]" if line.include?("array: true")
|
50
50
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
51
|
-
field ||= type_check(type)
|
51
|
+
field ||= Souls.type_check(type)
|
52
52
|
case name
|
53
53
|
when "user_id"
|
54
54
|
@user_exist = true
|
@@ -61,7 +61,7 @@ module Souls
|
|
61
61
|
new_line.write(" argument :#{name}, #{field}, required: false\n")
|
62
62
|
end
|
63
63
|
end
|
64
|
-
@on = true if table_check(line: line, class_name: class_name)
|
64
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -144,7 +144,7 @@ module Souls
|
|
144
144
|
end
|
145
145
|
field = "[String]" if line.include?("array: true")
|
146
146
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
147
|
-
field ||= type_check(type)
|
147
|
+
field ||= Souls.type_check(type)
|
148
148
|
case name
|
149
149
|
when "user_id"
|
150
150
|
@user_exist = true
|
@@ -157,7 +157,7 @@ module Souls
|
|
157
157
|
new_line.write(" argument :#{name}, #{field}, required: false\n")
|
158
158
|
end
|
159
159
|
end
|
160
|
-
@on = true if table_check(line: line, class_name: class_name)
|
160
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
161
161
|
end
|
162
162
|
end
|
163
163
|
end
|
@@ -34,8 +34,8 @@ module Souls
|
|
34
34
|
break if line.include?("t.index") || line.strip == "end"
|
35
35
|
|
36
36
|
field = "[String]" if line.include?("array: true")
|
37
|
-
type, name = get_type_and_name(line)
|
38
|
-
field ||= type_check(type)
|
37
|
+
type, name = Souls.get_type_and_name(line)
|
38
|
+
field ||= Souls.type_check(type)
|
39
39
|
case name
|
40
40
|
when "user_id"
|
41
41
|
@user_exist = true
|
@@ -48,7 +48,7 @@ module Souls
|
|
48
48
|
new_line.write(" argument :#{name}, #{field}, required: false\n")
|
49
49
|
end
|
50
50
|
end
|
51
|
-
@on = true if table_check(line: line, class_name: class_name)
|
51
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -89,7 +89,7 @@ module Souls
|
|
89
89
|
if @on
|
90
90
|
break if line.include?("t.index") || line.strip == "end"
|
91
91
|
|
92
|
-
type, name = get_type_and_name(line)
|
92
|
+
type, name = Souls.get_type_and_name(line)
|
93
93
|
if line.include?("array: true")
|
94
94
|
new_line.write(
|
95
95
|
" scope = scope.where(\"#{name} @> ARRAY[?]::text[]\", value[:#{name}]) if value[:#{name}]\n"
|
@@ -115,7 +115,7 @@ module Souls
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
118
|
-
@on = true if table_check(line: line, class_name: class_name)
|
118
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -24,7 +24,7 @@ module Souls
|
|
24
24
|
new_line.write("\n" && break) if line.include?("t.index") || line.strip == "end"
|
25
25
|
field = '["tag1", "tag2", "tag3"]' if line.include?("array: true")
|
26
26
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
27
|
-
field ||= get_test_type(type)
|
27
|
+
field ||= Souls.get_test_type(type)
|
28
28
|
if type == "bigint" && name.include?("_id")
|
29
29
|
id_name = name.gsub("_id", "")
|
30
30
|
new_line.write(" association :#{id_name}, factory: :#{id_name}\n")
|
@@ -32,7 +32,7 @@ module Souls
|
|
32
32
|
new_line.write(" #{name} { #{field} }\n")
|
33
33
|
end
|
34
34
|
end
|
35
|
-
@on = true if table_check(line: line, class_name: class_name)
|
35
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -58,7 +58,7 @@ module Souls
|
|
58
58
|
new_line.write(" let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n")
|
59
59
|
end
|
60
60
|
end
|
61
|
-
@on = true if table_check(line: line, class_name: class_name)
|
61
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -113,7 +113,7 @@ module Souls
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
116
|
-
@on = true if table_check(line: line, class_name: class_name)
|
116
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -193,7 +193,7 @@ module Souls
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
end
|
196
|
-
@on = true if table_check(line: line, class_name: class_name)
|
196
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
197
197
|
end
|
198
198
|
end
|
199
199
|
end
|
@@ -217,7 +217,7 @@ module Souls
|
|
217
217
|
break
|
218
218
|
end
|
219
219
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
220
|
-
field ||= type_check(type)
|
220
|
+
field ||= Souls.type_check(type)
|
221
221
|
array_true = line.include?("array: true")
|
222
222
|
case name
|
223
223
|
when "user_id", "created_at", "updated_at", /$*_id\z/
|
@@ -245,7 +245,7 @@ module Souls
|
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
248
|
-
@on = true if table_check(line: line, class_name: class_name)
|
248
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
249
249
|
end
|
250
250
|
end
|
251
251
|
end
|
@@ -56,7 +56,7 @@ module Souls
|
|
56
56
|
new_line.write(" let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n")
|
57
57
|
end
|
58
58
|
end
|
59
|
-
@on = true if table_check(line: line, class_name: class_name)
|
59
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -101,7 +101,7 @@ module Souls
|
|
101
101
|
new_line.write(" #{name.camelize(:lower)}\n")
|
102
102
|
end
|
103
103
|
end
|
104
|
-
@on = true if table_check(line: line, class_name: class_name)
|
104
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
@@ -125,7 +125,7 @@ module Souls
|
|
125
125
|
break
|
126
126
|
end
|
127
127
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
128
|
-
field ||= type_check(type)
|
128
|
+
field ||= Souls.type_check(type)
|
129
129
|
array_true = line.include?("array: true")
|
130
130
|
case name
|
131
131
|
when "user_id", "created_at", "updated_at", /$*_id\z/
|
@@ -145,7 +145,7 @@ module Souls
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
148
|
-
@on = true if table_check(line: line, class_name: class_name)
|
148
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|
@@ -64,7 +64,7 @@ module Souls
|
|
64
64
|
new_line.write(" let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n")
|
65
65
|
end
|
66
66
|
end
|
67
|
-
@on = true if table_check(line: line, class_name: class_name)
|
67
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -120,7 +120,7 @@ module Souls
|
|
120
120
|
new_line.write(" #{name.camelize(:lower)}\n")
|
121
121
|
end
|
122
122
|
end
|
123
|
-
@on = true if table_check(line: line, class_name: class_name)
|
123
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -144,7 +144,7 @@ module Souls
|
|
144
144
|
break
|
145
145
|
end
|
146
146
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
147
|
-
field ||= type_check(type)
|
147
|
+
field ||= Souls.type_check(type)
|
148
148
|
array_true = line.include?("array: true")
|
149
149
|
case name
|
150
150
|
when "user_id", "created_at", "updated_at", /$*_id\z/
|
@@ -172,7 +172,7 @@ module Souls
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
end
|
175
|
-
@on = true if table_check(line: line, class_name: class_name)
|
175
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
@@ -27,7 +27,7 @@ module Souls
|
|
27
27
|
new_line.write("\n" && break) if line.include?("t.index") || line.strip == "end"
|
28
28
|
field = "[String]" if line.include?("array: true")
|
29
29
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
30
|
-
field ||= type_check(type)
|
30
|
+
field ||= Souls.type_check(type)
|
31
31
|
case name
|
32
32
|
when /$*_id\z/
|
33
33
|
new_line.write(
|
@@ -43,7 +43,7 @@ module Souls
|
|
43
43
|
new_line.write(" field :#{name}, #{field}, null: true\n")
|
44
44
|
end
|
45
45
|
end
|
46
|
-
if table_check(line: line, class_name: class_name)
|
46
|
+
if Souls.table_check(line: line, class_name: class_name)
|
47
47
|
@on = true
|
48
48
|
new_line.write(" global_id_field :id\n")
|
49
49
|
end
|
@@ -16,7 +16,7 @@ module Souls
|
|
16
16
|
next unless line.include?("argument") && !argument
|
17
17
|
|
18
18
|
new_cols.each do |col|
|
19
|
-
type = Souls
|
19
|
+
type = Souls.type_check(col[:type])
|
20
20
|
type = "[#{type}]" if col[:array]
|
21
21
|
args = check_mutation_argument(class_name: class_name)
|
22
22
|
next if args.include?(col[:column_name])
|
@@ -47,7 +47,7 @@ module Souls
|
|
47
47
|
next unless line.include?("argument") && !argument
|
48
48
|
|
49
49
|
new_cols.each do |col|
|
50
|
-
type = Souls
|
50
|
+
type = Souls.type_check(col[:type])
|
51
51
|
type = "[#{type}]" if col[:array]
|
52
52
|
args = check_mutation_argument(class_name: class_name, action: "update")
|
53
53
|
next if args.include?(col[:column_name])
|
@@ -18,7 +18,7 @@ module Souls
|
|
18
18
|
new_line.write(line)
|
19
19
|
if line.include?("argument") && !argument
|
20
20
|
new_cols.each do |col|
|
21
|
-
type = Souls
|
21
|
+
type = Souls.type_check(col[:type])
|
22
22
|
type = "[#{type}]" if col[:array]
|
23
23
|
add_line = " argument :#{col[:column_name]}, #{type}, required: false\n"
|
24
24
|
new_line.write(add_line) unless args.include?(col[:column_name])
|
@@ -26,7 +26,7 @@ module Souls
|
|
26
26
|
argument = true
|
27
27
|
elsif line.include?("scope = ::") && !scope
|
28
28
|
new_cols.each do |col|
|
29
|
-
type = Souls
|
29
|
+
type = Souls.type_check(col[:type])
|
30
30
|
type = "[#{type}]" if col[:array]
|
31
31
|
|
32
32
|
if type.include?("[")
|
@@ -19,7 +19,7 @@ module Souls
|
|
19
19
|
new_cols.each do |col|
|
20
20
|
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
21
21
|
|
22
|
-
type = Souls
|
22
|
+
type = Souls.get_test_type(col[:type])
|
23
23
|
type = "[#{type}]" if col[:array]
|
24
24
|
args = check_factory_argument(class_name: class_name)
|
25
25
|
|
@@ -22,7 +22,7 @@ module Souls
|
|
22
22
|
|
23
23
|
if line.include?('#{') && !argument
|
24
24
|
new_cols.each do |col|
|
25
|
-
type = Souls
|
25
|
+
type = Souls.type_check(col[:type])
|
26
26
|
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
27
27
|
|
28
28
|
type_line =
|
@@ -46,7 +46,7 @@ module Souls
|
|
46
46
|
elsif test_res && line.include?("=> be_")
|
47
47
|
test_args = check_rspec_mutation_argument(class_name: class_name, action: "test_args")
|
48
48
|
new_cols.each do |col|
|
49
|
-
type = Souls
|
49
|
+
type = Souls.type_check(col[:type])
|
50
50
|
text =
|
51
51
|
case type
|
52
52
|
when "Integer", "Float"
|
@@ -30,7 +30,7 @@ module Souls
|
|
30
30
|
elsif test_res && line.include?("=> be_")
|
31
31
|
test_args = check_rspec_resolver_argument(class_name: class_name, action: "test_args")
|
32
32
|
new_cols.each do |col|
|
33
|
-
type = Souls
|
33
|
+
type = Souls.type_check(col[:type])
|
34
34
|
text =
|
35
35
|
case type
|
36
36
|
when "Integer", "Float"
|
@@ -16,7 +16,7 @@ module Souls
|
|
16
16
|
next unless line.include?("field") && !argument
|
17
17
|
|
18
18
|
new_cols.each do |col|
|
19
|
-
type = Souls
|
19
|
+
type = Souls.get_type(col[:type])
|
20
20
|
type = "[#{type}]" if col[:array]
|
21
21
|
args = check_type_argument(class_name: class_name)
|
22
22
|
unless args.include?(col[:column_name])
|
@@ -23,7 +23,7 @@ module Souls
|
|
23
23
|
file_dir = "apps/#{worker_name}"
|
24
24
|
file_path = "#{file_dir}/Procfile.dev"
|
25
25
|
File.open(file_path, "w") do |f|
|
26
|
-
f.write("
|
26
|
+
f.write("#{worker_name}: bundle exec puma -p #{port} -e development")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -192,9 +192,10 @@ end
|
|
192
192
|
Souls.configure do |config|
|
193
193
|
config.app = "#{app_name}"
|
194
194
|
config.project_id = "#{project_id}"
|
195
|
+
config.region = "asia-northeast1"
|
195
196
|
config.endpoint = "/endpoint"
|
196
197
|
config.strain = "worker"
|
197
|
-
config.fixed_gems = ["
|
198
|
+
config.fixed_gems = ["spring"]
|
198
199
|
config.workers = []
|
199
200
|
end
|
200
201
|
TEXT
|
@@ -2,50 +2,52 @@ module Souls
|
|
2
2
|
module Gcloud
|
3
3
|
module Compute
|
4
4
|
class << self
|
5
|
-
def setup_vpc_nat(
|
6
|
-
create_network
|
7
|
-
create_firewall_tcp(
|
8
|
-
create_firewall_ssh
|
9
|
-
create_subnet(
|
10
|
-
create_connector
|
11
|
-
create_router
|
12
|
-
create_external_ip
|
13
|
-
create_nat
|
14
|
-
nat_credit
|
5
|
+
def setup_vpc_nat(range: "10.124.0.0/28")
|
6
|
+
create_network
|
7
|
+
create_firewall_tcp(range: range)
|
8
|
+
create_firewall_ssh
|
9
|
+
create_subnet(range: range)
|
10
|
+
create_connector
|
11
|
+
create_router
|
12
|
+
create_external_ip
|
13
|
+
create_nat
|
14
|
+
nat_credit
|
15
15
|
end
|
16
16
|
|
17
|
-
def create_network
|
18
|
-
app_name = Souls.configuration.app
|
17
|
+
def create_network
|
18
|
+
app_name = Souls.configuration.app
|
19
19
|
system("gcloud compute networks create #{app_name}")
|
20
20
|
end
|
21
21
|
|
22
|
-
def create_firewall_tcp(
|
23
|
-
app_name = Souls.configuration.app
|
22
|
+
def create_firewall_tcp(range: "10.124.0.0/28")
|
23
|
+
app_name = Souls.configuration.app
|
24
24
|
system(
|
25
25
|
"gcloud compute firewall-rules create #{app_name} \
|
26
26
|
--network #{app_name} --allow tcp,udp,icmp --source-ranges #{range}"
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
30
|
-
def create_firewall_ssh
|
31
|
-
app_name = Souls.configuration.app
|
30
|
+
def create_firewall_ssh
|
31
|
+
app_name = Souls.configuration.app
|
32
32
|
system(
|
33
33
|
"gcloud compute firewall-rules create #{app_name}-ssh --network #{app_name} \
|
34
34
|
--allow tcp:22,tcp:3389,icmp"
|
35
35
|
)
|
36
36
|
end
|
37
37
|
|
38
|
-
def create_subnet(
|
39
|
-
app_name = Souls.configuration.app
|
38
|
+
def create_subnet(range: "10.124.0.0/28")
|
39
|
+
app_name = Souls.configuration.app
|
40
|
+
region = Souls.configuration.region
|
40
41
|
system(
|
41
42
|
"gcloud compute networks subnets create #{app_name}-subnet \
|
42
43
|
--range=#{range} --network=#{app_name} --region=#{region}"
|
43
44
|
)
|
44
45
|
end
|
45
46
|
|
46
|
-
def create_connector
|
47
|
-
app_name = Souls.configuration.app
|
47
|
+
def create_connector
|
48
|
+
app_name = Souls.configuration.app
|
48
49
|
project_id = Souls.configuration.project_id
|
50
|
+
region = Souls.configuration.region
|
49
51
|
system(
|
50
52
|
"gcloud compute networks vpc-access connectors create #{app_name}-connector \
|
51
53
|
--region=#{region} \
|
@@ -54,18 +56,21 @@ module Souls
|
|
54
56
|
)
|
55
57
|
end
|
56
58
|
|
57
|
-
def create_router
|
58
|
-
app_name = Souls.configuration.app
|
59
|
+
def create_router
|
60
|
+
app_name = Souls.configuration.app
|
61
|
+
region = Souls.configuration.region
|
59
62
|
system("gcloud compute routers create #{app_name}-router --network=#{app_name} --region=#{region}")
|
60
63
|
end
|
61
64
|
|
62
|
-
def create_external_ip
|
63
|
-
app_name = Souls.configuration.app
|
65
|
+
def create_external_ip
|
66
|
+
app_name = Souls.configuration.app
|
67
|
+
region = Souls.configuration.region
|
64
68
|
system("gcloud compute addresses create #{app_name}-worker-ip --region=#{region}")
|
65
69
|
end
|
66
70
|
|
67
|
-
def create_nat
|
68
|
-
app_name = Souls.configuration.app
|
71
|
+
def create_nat
|
72
|
+
app_name = Souls.configuration.app
|
73
|
+
region = Souls.configuration.region
|
69
74
|
system(
|
70
75
|
"gcloud compute routers nats create #{app_name}-worker-nat \
|
71
76
|
--router=#{app_name}-router \
|
@@ -79,8 +84,8 @@ module Souls
|
|
79
84
|
system("gcloud compute network list")
|
80
85
|
end
|
81
86
|
|
82
|
-
def nat_credit
|
83
|
-
app_name = Souls.configuration.app
|
87
|
+
def nat_credit
|
88
|
+
app_name = Souls.configuration.app
|
84
89
|
line = Paint["====================================", :yellow]
|
85
90
|
puts("\n")
|
86
91
|
puts(line)
|
@@ -2,8 +2,10 @@ module Souls
|
|
2
2
|
module Gcloud
|
3
3
|
module Sql
|
4
4
|
class << self
|
5
|
-
def create_instance(
|
5
|
+
def create_instance(root_pass: "PassWord")
|
6
6
|
instance_name = "#{Souls.configuration.app}-db" if instance_name.blank?
|
7
|
+
region = Souls.configuration.region
|
8
|
+
zone = "#{region}-b"
|
7
9
|
system(
|
8
10
|
"gcloud sql instances create #{instance_name} \
|
9
11
|
--database-version=POSTGRES_13 --cpu=2 --memory=7680MB --zone=#{zone} \
|
@@ -15,12 +17,16 @@ module Souls
|
|
15
17
|
system("gcloud sql instances list")
|
16
18
|
end
|
17
19
|
|
18
|
-
def setup_private_ip
|
19
|
-
app_name = Souls.configuration.app
|
20
|
-
instance_name = "#{Souls.configuration.app}-db" if instance_name.blank?
|
21
|
-
project_id = Souls.configuration.project_id
|
20
|
+
def setup_private_ip
|
22
21
|
create_ip_range
|
23
22
|
create_vpc_connector
|
23
|
+
assign_network
|
24
|
+
end
|
25
|
+
|
26
|
+
def assign_network
|
27
|
+
app_name = Souls.configuration.app
|
28
|
+
instance_name = "#{Souls.configuration.app}-db"
|
29
|
+
project_id = Souls.configuration.project_id
|
24
30
|
system("gcloud beta sql instances patch #{instance_name} --project=#{project_id} --network=#{app_name}")
|
25
31
|
end
|
26
32
|
|
data/lib/souls/cli/init/index.rb
CHANGED
@@ -42,10 +42,11 @@ module Souls
|
|
42
42
|
f.write(<<~TEXT)
|
43
43
|
Souls.configure do |config|
|
44
44
|
config.app = "#{app_name}"
|
45
|
-
config.project_id = "#{app_name}
|
45
|
+
config.project_id = "#{app_name}"
|
46
|
+
config.region = "asia-northeast1"
|
46
47
|
config.endpoint = "/endpoint"
|
47
48
|
config.strain = "api"
|
48
|
-
config.fixed_gems = ["
|
49
|
+
config.fixed_gems = ["spring"]
|
49
50
|
config.workers = []
|
50
51
|
end
|
51
52
|
TEXT
|
@@ -72,10 +73,11 @@ module Souls
|
|
72
73
|
f.write(<<~TEXT)
|
73
74
|
Souls.configure do |config|
|
74
75
|
config.app = "#{app_name}"
|
75
|
-
config.project_id = "#{app_name}
|
76
|
+
config.project_id = "#{app_name}"
|
77
|
+
config.region = "asia-northeast1"
|
76
78
|
config.endpoint = "/endpoint"
|
77
79
|
config.strain = "mother"
|
78
|
-
config.fixed_gems = ["
|
80
|
+
config.fixed_gems = ["spring"]
|
79
81
|
config.workers = []
|
80
82
|
end
|
81
83
|
TEXT
|
@@ -59,7 +59,8 @@ module Souls
|
|
59
59
|
pubsub = Google::Cloud::Pubsub.new
|
60
60
|
|
61
61
|
topic = pubsub.topic(topic_id)
|
62
|
-
topic.subscribe(subscription_id, endpoint: endpoint)
|
62
|
+
sub = topic.subscribe(subscription_id, endpoint: endpoint, deadline: 20)
|
63
|
+
sub.expires_in = nil
|
63
64
|
puts("Push subscription #{subscription_id} created.")
|
64
65
|
end
|
65
66
|
|
data/lib/souls/utils/index.rb
CHANGED
@@ -8,6 +8,69 @@ module Souls
|
|
8
8
|
FileUtils.pwd.split(Souls.configuration.app)[0] + Souls.configuration.app + "/apps/api"
|
9
9
|
end
|
10
10
|
|
11
|
+
def type_check(type)
|
12
|
+
{
|
13
|
+
bigint: "Integer",
|
14
|
+
string: "String",
|
15
|
+
float: "Float",
|
16
|
+
text: "String",
|
17
|
+
datetime: "String",
|
18
|
+
date: "String",
|
19
|
+
boolean: "Boolean",
|
20
|
+
integer: "Integer"
|
21
|
+
}[type.to_sym]
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_type_and_name(line)
|
25
|
+
line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_type(type)
|
29
|
+
{
|
30
|
+
bigint: "Integer",
|
31
|
+
string: "String",
|
32
|
+
float: "Float",
|
33
|
+
text: "String",
|
34
|
+
datetime: "GraphQL::Types::ISO8601DateTime",
|
35
|
+
date: "GraphQL::Types::ISO8601DateTime",
|
36
|
+
boolean: "Boolean",
|
37
|
+
integer: "Integer"
|
38
|
+
}[type.to_sym]
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_test_type(type)
|
42
|
+
{
|
43
|
+
bigint: "rand(1..10)",
|
44
|
+
float: 4.2,
|
45
|
+
string: '"MyString"',
|
46
|
+
text: '"MyString"',
|
47
|
+
datetime: "Time.now",
|
48
|
+
date: "Time.now.strftime('%F')",
|
49
|
+
boolean: false,
|
50
|
+
integer: "rand(1..10)"
|
51
|
+
}[type.to_sym]
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_tables
|
55
|
+
path = "./db/schema.rb"
|
56
|
+
tables = []
|
57
|
+
File.open(path, "r") do |f|
|
58
|
+
f.each_line.with_index do |line, _i|
|
59
|
+
tables << line.split("\"")[1] if line.include?("create_table")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
tables
|
63
|
+
end
|
64
|
+
|
65
|
+
def table_check(line: "", class_name: "")
|
66
|
+
if line.include?("create_table") && (line.split[1].gsub("\"", "").gsub(",", "") == class_name.pluralize.to_s)
|
67
|
+
|
68
|
+
return true
|
69
|
+
end
|
70
|
+
|
71
|
+
false
|
72
|
+
end
|
73
|
+
|
11
74
|
def version_detector(current_ver: [0, 0, 1], update_kind: "patch")
|
12
75
|
case update_kind
|
13
76
|
when "patch"
|
@@ -45,7 +108,7 @@ module Souls
|
|
45
108
|
if class_check_flag == true && !line.include?("create_table")
|
46
109
|
return cols if line.include?("t.index") || line.strip == "end"
|
47
110
|
|
48
|
-
types = Souls
|
111
|
+
types = Souls.get_type_and_name(line)
|
49
112
|
array = line.include?("array: true")
|
50
113
|
cols << { column_name: types[1], type: types[0], array: array }
|
51
114
|
end
|
@@ -69,7 +132,7 @@ module Souls
|
|
69
132
|
next unless class_check_flag == true && !line.include?("create_table")
|
70
133
|
return response if line.include?("t.timestamps") || line.strip == "end"
|
71
134
|
|
72
|
-
types = Souls
|
135
|
+
types = Souls.get_type_and_name(line)
|
73
136
|
types.map { |n| n.gsub!(":", "") }
|
74
137
|
array = line.include?("array: true")
|
75
138
|
response << { column_name: types[1], type: types[0], array: array }
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.30.1
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.30.1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: souls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.51.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-09-
|
13
|
+
date: 2021-09-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|