souls 0.48.1 → 0.51.0

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: fa05b4d9e6f1e1dcfa5dc51d60048bf7724cf9bec95febac0426b3a6ea362b9f
4
- data.tar.gz: edcac235aa2f1f760df232a4a2e77805428f1380a26dbafc52257ffa2f7d3c81
3
+ metadata.gz: a7367fa762682e76ba67083cf1b6d602de00187a21a556c1e9a42c92cf50a154
4
+ data.tar.gz: a669713a544dea89c5481049ecd88bcb256cce2d571ba284998205563f3d7fb9
5
5
  SHA512:
6
- metadata.gz: 302038e0b74ebe5552a08708c1f0d483ce0709ec75fee545bed16d056497fcd452d35d3d9f7b7b34b1cc43962fd5117cebe5b95f74f55139ab52e63ec74eafb3
7
- data.tar.gz: 6ee9dc50622a972abc5a2d68b6c006babc4f50c3eb12267697a02e2ebd381e8f0ff635da1e4dadb5b003369f8c7c18dd752b9c9304f7a866b88f25dc3a668176
6
+ metadata.gz: 943d98643861cab7f4a4f6b87f14f3e8704fd25bfff163c57a8998d12379935aea9680b41c7c540470f189878c8eb5dfeace448e2c36c65b73ce89f0b93ce98d
7
+ data.tar.gz: df0a5eaba3954eb7b7c2a2dc1b3f8e9393598a1eb2ec52c47c418f3ad2e7c2ba657c883e6b234c685e3e756c8d1e99d7412df9204851199099f8962dfb8989c6
data/exe/souls CHANGED
@@ -10,37 +10,39 @@ begin
10
10
  case souls_command
11
11
  when "api"
12
12
  api_command = ARGV[1]
13
- case api_command
14
- when "generate", "g"
15
- method_name = ARGV[2]
16
- class_name = ARGV[3]
17
- args = { class_name: class_name }
18
- args[:mutation] = ARGV[4] if ARGV.size > 4
19
- status = Paint["Running SOULs Generate Commands...", :yellow]
20
- Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
21
- Whirly.status = status
22
- Souls::Api::Generate.public_send(method_name, **args)
23
- Whirly.status = "Done!"
24
- end
25
- when "update"
26
- class_name = ARGV[2]
27
- status = Paint["Running SOULs Update Commands...", :yellow]
28
- Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
29
- Whirly.status = status
30
- Souls::Api::Update.create_mutation(class_name: class_name)
31
- Souls::Api::Update.update_mutation(class_name: class_name)
32
- Souls::Api::Update.resolver(class_name: class_name)
33
- Souls::Api::Update.type(class_name: class_name)
34
- Souls::Api::Update.rspec_factory(class_name: class_name)
35
- Souls::Api::Update.rspec_mutation(class_name: class_name)
36
- Souls::Api::Update.rspec_resolver(class_name: class_name)
37
- Whirly.status = "Done!"
13
+ Dir.chdir(Souls.get_api_path.to_s) do
14
+ case api_command
15
+ when "generate", "g"
16
+ method_name = ARGV[2]
17
+ class_name = ARGV[3]
18
+ args = { class_name: class_name }
19
+ args[:mutation] = ARGV[4] if ARGV.size > 4
20
+ status = Paint["Running SOULs Generate Commands...", :yellow]
21
+ Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
22
+ Whirly.status = status
23
+ Souls::Api::Generate.public_send(method_name, **args)
24
+ Whirly.status = "Done!"
25
+ end
26
+ when "update"
27
+ class_name = ARGV[2]
28
+ status = Paint["Running SOULs Update Commands...", :yellow]
29
+ Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
30
+ Whirly.status = status
31
+ Souls::Api::Update.create_mutation(class_name: class_name)
32
+ Souls::Api::Update.update_mutation(class_name: class_name)
33
+ Souls::Api::Update.resolver(class_name: class_name)
34
+ Souls::Api::Update.type(class_name: class_name)
35
+ Souls::Api::Update.rspec_factory(class_name: class_name)
36
+ Souls::Api::Update.rspec_mutation(class_name: class_name)
37
+ Souls::Api::Update.rspec_resolver(class_name: class_name)
38
+ Whirly.status = "Done!"
39
+ end
40
+ when "d", "delete"
41
+ class_name = ARGV[2]
42
+ Souls::Api::Generate.delete_all(class_name: class_name)
43
+ else
44
+ puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
38
45
  end
39
- when "d", "delete"
40
- class_name = ARGV[2]
41
- Souls::Api::Generate.delete_all(class_name: class_name)
42
- else
43
- puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
44
46
  end
45
47
  when "worker"
46
48
  api_command = ARGV[1]
@@ -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::Api::Generate.get_tables.each do |table|
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::Api::Generate.type_check(col[:type])
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::Api::Generate.type_check(col[:type])
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::Api::Generate.type_check(col[:type])
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::Api::Generate.type_check(col[:type])
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::Api::Generate.get_test_type(col[:type])
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::Api::Generate.type_check(col[:type])
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::Api::Generate.type_check(col[:type])
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::Api::Generate.type_check(col[:type])
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::Api::Generate.get_type(col[:type])
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("web: bundle exec puma -p #{port} -e development")
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 = ["excluded_gem"]
198
+ config.fixed_gems = ["spring"]
198
199
  config.workers = []
199
200
  end
200
201
  TEXT
@@ -204,20 +205,12 @@ end
204
205
  end
205
206
 
206
207
  def download_worker(worker_name: "mailer")
207
- raise(StandardError, "Can't use `worker` for worker. Change Name.") if worker_name == "worker"
208
-
209
- current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
210
- wrong_dir = %w[apps api worker]
211
- if wrong_dir.include?(current_dir_name)
212
- raise(StandardError, "You are at wrong directory!Go to Mother Directory!")
213
- end
214
-
215
208
  version = Souls.get_latest_version_txt(service_name: "worker").join(".")
216
209
  file_name = "worker-v#{version}.tgz"
217
210
  url = "https://storage.googleapis.com/souls-bucket/boilerplates/workers/#{file_name}"
218
211
  system("curl -OL #{url}")
219
- system("tar -zxvf ./#{file_name} -C ./apps/")
220
- system("mv apps/worker apps/#{worker_name}")
212
+ system("tar -zxvf ./#{file_name}")
213
+ system("mv ./worker apps/#{worker_name}")
221
214
  system("cp ./apps/api/config/database.yml ./apps/#{worker_name}/config/")
222
215
  FileUtils.rm(file_name)
223
216
  end
@@ -2,50 +2,52 @@ module Souls
2
2
  module Gcloud
3
3
  module Compute
4
4
  class << self
5
- def setup_vpc_nat(app_name: "", region: "asia-northeast1", range: "10.124.0.0/28")
6
- create_network(app_name: app_name)
7
- create_firewall_tcp(app_name: app_name, range: range)
8
- create_firewall_ssh(app_name: app_name)
9
- create_subnet(app_name: app_name, region: region, range: range)
10
- create_connector(app_name: app_name, region: region)
11
- create_router(app_name: app_name, region: region)
12
- create_external_ip(app_name: app_name, region: region)
13
- create_nat(app_name: app_name, region: region)
14
- nat_credit(app_name: app_name)
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(app_name: "")
18
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "", range: "10.124.0.0/28")
23
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "")
31
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "", region: "asia-northeast1", range: "10.124.0.0/28")
39
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "", region: "asia-northeast1")
47
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "", region: "asia-northeast1")
58
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "", region: "asia-northeast1")
63
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "", region: "asia-northeast1")
68
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "")
83
- app_name = Souls.configuration.app if app_name.blank?
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(instance_name: "", root_pass: "Postgre123!", zone: "asia-northeast1-b")
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(instance_name: "")
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
 
@@ -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}-project"
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 = ["excluded_gem"]
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}-project"
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 = ["excluded_gem"]
80
+ config.fixed_gems = ["spring"]
79
81
  config.workers = []
80
82
  end
81
83
  TEXT
@@ -24,16 +24,26 @@ module Souls
24
24
  next unless worker_switch
25
25
 
26
26
  new_line.write(" config.workers = [\n")
27
- workers.each do |worker|
27
+ workers.each_with_index do |worker, i|
28
28
  base_url = Souls::Gcloud::Run.get_endpoint(worker_name: worker[:name])
29
29
  endpoint = Souls.configuration.endpoint
30
- new_line.write(<<-TEXT)
31
- {
32
- name: "#{worker[:name]}",
33
- endpoint: "#{base_url.strip}#{endpoint}",
34
- port: #{worker[:port]}
35
- },
36
- TEXT
30
+ if (i + 1) == workers.size
31
+ new_line.write(<<-TEXT)
32
+ {
33
+ name: "#{worker[:name]}",
34
+ endpoint: "#{base_url.strip}#{endpoint}",
35
+ port: #{worker[:port]}
36
+ }
37
+ TEXT
38
+ else
39
+ new_line.write(<<-TEXT)
40
+ {
41
+ name: "#{worker[:name]}",
42
+ endpoint: "#{base_url.strip}#{endpoint}",
43
+ port: #{worker[:port]}
44
+ },
45
+ TEXT
46
+ end
37
47
  end
38
48
  break
39
49
  end
@@ -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
 
@@ -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::Api::Generate.get_type_and_name(line)
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::Api::Generate.get_type_and_name(line)
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,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.48.1".freeze
2
+ VERSION = "0.51.0".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.27.1
1
+ 0.30.0
@@ -1 +1 @@
1
- 0.27.1
1
+ 0.30.0
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.48.1
4
+ version: 0.51.0
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-09 00:00:00.000000000 Z
13
+ date: 2021-09-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport