souls 0.51.0 → 0.52.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 +5 -1
- data/exe/souls +3 -200
- data/lib/souls/api/generate/application.rb +97 -94
- data/lib/souls/api/generate/connection.rb +5 -4
- data/lib/souls/api/generate/edge.rb +5 -4
- data/lib/souls/api/generate/index.rb +0 -1
- data/lib/souls/api/generate/manager.rb +9 -7
- data/lib/souls/api/generate/model.rb +16 -18
- data/lib/souls/api/generate/mutation.rb +217 -218
- data/lib/souls/api/generate/policy.rb +5 -5
- data/lib/souls/api/generate/query.rb +51 -51
- data/lib/souls/api/generate/resolver.rb +115 -115
- data/lib/souls/api/generate/rspec_factory.rb +53 -53
- data/lib/souls/api/generate/rspec_model.rb +5 -5
- data/lib/souls/api/generate/rspec_mutation.rb +178 -178
- data/lib/souls/api/generate/rspec_policy.rb +5 -5
- data/lib/souls/api/generate/rspec_query.rb +111 -111
- data/lib/souls/api/generate/rspec_resolver.rb +163 -163
- data/lib/souls/api/generate/type.rb +66 -66
- data/lib/souls/api/index.rb +7 -4
- data/lib/souls/api/update/index.rb +15 -0
- data/lib/souls/api/update/mutation.rb +68 -64
- data/lib/souls/api/update/resolver.rb +59 -60
- data/lib/souls/api/update/rspec_factory.rb +40 -39
- data/lib/souls/api/update/rspec_mutation.rb +84 -83
- data/lib/souls/api/update/rspec_resolver.rb +70 -69
- data/lib/souls/api/update/type.rb +39 -38
- data/lib/souls/cli/console/index.rb +13 -1
- data/lib/souls/cli/create/index.rb +98 -94
- data/lib/souls/cli/db/index.rb +122 -1
- data/lib/souls/cli/docker/index.rb +30 -38
- data/lib/souls/cli/gcloud/compute/index.rb +100 -98
- data/lib/souls/cli/gcloud/iam/index.rb +84 -69
- data/lib/souls/cli/gcloud/index.rb +36 -35
- data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +40 -27
- data/lib/souls/cli/gcloud/pubsub/topics.rb +16 -10
- data/lib/souls/cli/gcloud/run/index.rb +23 -17
- data/lib/souls/cli/gcloud/sql/index.rb +66 -47
- data/lib/souls/cli/index.rb +3 -20
- data/lib/souls/cli/init/index.rb +140 -140
- data/lib/souls/cli/release/release.rb +106 -105
- data/lib/souls/cli/server/index.rb +12 -1
- data/lib/souls/cli/sync/conf.rb +39 -38
- data/lib/souls/cli/sync/model.rb +19 -20
- data/lib/souls/cli/sync/pubsub.rb +69 -70
- data/lib/souls/cli/upgrade/gemfile.rb +108 -0
- data/lib/souls/cli/upgrade/index.rb +1 -1
- data/lib/souls/cli.rb +57 -0
- data/lib/souls/index.rb +1 -5
- 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
- data/lib/souls/worker/generate/index.rb +1 -1
- data/lib/souls/worker/generate/job.rb +45 -0
- data/lib/souls/worker/generate/mailer.rb +38 -43
- data/lib/souls/worker/index.rb +3 -1
- data/lib/souls.rb +2 -0
- metadata +19 -5
- data/lib/souls/api/generate/migration.rb +0 -51
- data/lib/souls/cli/upgrade/gem_update.rb +0 -107
- data/lib/souls/worker/generate/mutation.rb +0 -44
@@ -1,7 +1,7 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
def
|
2
|
+
class Generate < Thor
|
3
|
+
desc "rspec_model [CLASS_NAME]", "Generate Rspec Model Test from schema.rb"
|
4
|
+
def rspec_model(class_name)
|
5
5
|
file_dir = "./spec/models/"
|
6
6
|
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
7
7
|
file_path = "./spec/models/#{class_name}_spec.rb"
|
@@ -20,8 +20,8 @@ module Souls
|
|
20
20
|
end
|
21
21
|
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
22
22
|
file_path
|
23
|
-
rescue
|
24
|
-
raise(
|
23
|
+
rescue Thor::Error => e
|
24
|
+
raise(Thor::Error, e)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,135 +1,152 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
class Generate < Thor
|
3
|
+
desc "rspec_mutation [CLASS_NAME]", "Generate Rspec Mutation Test from schema.rb"
|
4
|
+
def rspec_mutation(class_name)
|
5
|
+
singularized_class_name = class_name.singularize
|
6
|
+
file_path = "./spec/mutations/base/#{singularized_class_name}_spec.rb"
|
7
|
+
return "RspecMutation already exist! #{file_path}" if File.exist?(file_path)
|
8
|
+
|
9
|
+
rspec_mutation_head(class_name: singularized_class_name)
|
10
|
+
rspec_mutation_after_head(class_name: singularized_class_name)
|
11
|
+
rspec_mutation_params(class_name: singularized_class_name)
|
12
|
+
rspec_mutation_params_response(class_name: singularized_class_name)
|
13
|
+
rspec_mutation_end(class_name: singularized_class_name)
|
14
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
15
|
+
file_path
|
16
|
+
rescue StandardError => e
|
17
|
+
raise(StandardError, e)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def rspec_mutation_head(class_name: "user")
|
23
|
+
file_dir = "./spec/mutations/base/"
|
24
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
25
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
26
|
+
File.open(file_path, "w") do |f|
|
27
|
+
f.write(<<~TEXT)
|
28
|
+
RSpec.describe \"#{class_name.camelize} Mutation テスト\" do
|
29
|
+
describe "#{class_name.camelize} データを登録する" do
|
30
|
+
TEXT
|
15
31
|
end
|
32
|
+
end
|
16
33
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
def rspec_mutation_after_head(class_name: "user")
|
35
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
36
|
+
path = "./db/schema.rb"
|
37
|
+
@on = false
|
38
|
+
@user_exist = false
|
39
|
+
@relation_params = []
|
40
|
+
File.open(file_path, "a") do |new_line|
|
41
|
+
File.open(path, "r") do |f|
|
42
|
+
f.each_line.with_index do |line, _i|
|
43
|
+
if @on
|
44
|
+
if line.include?("t.index") || line.strip == "end"
|
45
|
+
if @relation_params.empty?
|
46
|
+
new_line.write(<<-TEXT)
|
30
47
|
let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}) }
|
31
48
|
|
32
49
|
let(:mutation) do
|
33
50
|
%(mutation {
|
34
51
|
create#{class_name.camelize}(input: {
|
35
|
-
|
36
|
-
|
37
|
-
|
52
|
+
TEXT
|
53
|
+
else
|
54
|
+
new_line.write(<<-TEXT)
|
38
55
|
let(:#{class_name}) { FactoryBot.attributes_for(:#{class_name}, #{@relation_params.join(', ')}) }
|
39
56
|
|
40
57
|
let(:mutation) do
|
41
58
|
%(mutation {
|
42
59
|
create#{class_name.camelize}(input: {
|
43
|
-
|
44
|
-
end
|
45
|
-
break
|
46
|
-
end
|
47
|
-
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
48
|
-
case name
|
49
|
-
when "user_id"
|
50
|
-
relation_col = name.gsub("_id", "")
|
51
|
-
new_line.write(" let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n")
|
52
|
-
when /$*_id\z/
|
53
|
-
relation_col = name.gsub("_id", "")
|
54
|
-
@relation_params << "#{name}: get_global_key(\"#{name.singularize.camelize.gsub(
|
55
|
-
'Id',
|
56
|
-
''
|
57
|
-
)}\", #{relation_col}.id)"
|
58
|
-
new_line.write(" let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n")
|
60
|
+
TEXT
|
59
61
|
end
|
62
|
+
break
|
63
|
+
end
|
64
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
65
|
+
case name
|
66
|
+
when "user_id"
|
67
|
+
relation_col = name.gsub("_id", "")
|
68
|
+
new_line.write(" let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n")
|
69
|
+
when /$*_id\z/
|
70
|
+
relation_col = name.gsub("_id", "")
|
71
|
+
@relation_params << "#{name}: get_global_key(\"#{name.singularize.camelize.gsub(
|
72
|
+
'Id',
|
73
|
+
''
|
74
|
+
)}\", #{relation_col}.id)"
|
75
|
+
new_line.write(" let(:#{relation_col}) { FactoryBot.create(:#{relation_col}) }\n")
|
60
76
|
end
|
61
|
-
@on = true if Souls.table_check(line: line, class_name: class_name)
|
62
77
|
end
|
78
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
63
79
|
end
|
64
80
|
end
|
65
81
|
end
|
82
|
+
end
|
66
83
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
new_line.write(
|
106
|
-
" #{camel}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
107
|
-
)
|
108
|
-
end
|
109
|
-
when "bigint", "integer", "float", "boolean"
|
84
|
+
def rspec_mutation_params(class_name: "user")
|
85
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
86
|
+
path = "./db/schema.rb"
|
87
|
+
@on = false
|
88
|
+
@user_exist = false
|
89
|
+
File.open(file_path, "a") do |new_line|
|
90
|
+
File.open(path, "r") do |f|
|
91
|
+
f.each_line.with_index do |line, _i|
|
92
|
+
if @on
|
93
|
+
if line.include?("t.index") || line.strip == "end"
|
94
|
+
new_line.write(
|
95
|
+
" }) {\n #{class_name.singularize.camelize(:lower)}Edge {\n node {\n"
|
96
|
+
)
|
97
|
+
new_line.write(" id\n")
|
98
|
+
break
|
99
|
+
end
|
100
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
101
|
+
array_true = line.include?("array: true")
|
102
|
+
case name
|
103
|
+
when "created_at", "updated_at"
|
104
|
+
next
|
105
|
+
when "user_id"
|
106
|
+
@user_exist = true
|
107
|
+
when /$*_id\z/
|
108
|
+
camel = name.singularize.camelize(:lower)
|
109
|
+
new_line.write(
|
110
|
+
" #{camel}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
111
|
+
)
|
112
|
+
else
|
113
|
+
camel = name.singularize.camelize(:lower)
|
114
|
+
camels = name.pluralize.camelize(:lower)
|
115
|
+
case type
|
116
|
+
when "string", "text", "date", "datetime"
|
117
|
+
if array_true
|
118
|
+
new_line.write(
|
119
|
+
" #{camels}: \#{#{class_name.singularize}[:#{name.pluralize.underscore}]}\n"
|
120
|
+
)
|
121
|
+
else
|
110
122
|
new_line.write(
|
111
|
-
" #{camel}: \#{#{class_name.singularize}[:#{name.singularize.underscore}]}\n"
|
123
|
+
" #{camel}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
112
124
|
)
|
113
125
|
end
|
126
|
+
when "bigint", "integer", "float", "boolean"
|
127
|
+
new_line.write(
|
128
|
+
" #{camel}: \#{#{class_name.singularize}[:#{name.singularize.underscore}]}\n"
|
129
|
+
)
|
114
130
|
end
|
115
131
|
end
|
116
|
-
@on = true if Souls.table_check(line: line, class_name: class_name)
|
117
132
|
end
|
133
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
118
134
|
end
|
119
135
|
end
|
120
136
|
end
|
137
|
+
end
|
121
138
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
139
|
+
def rspec_mutation_params_response(class_name: "user")
|
140
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
141
|
+
path = "./db/schema.rb"
|
142
|
+
@on = false
|
143
|
+
File.open(file_path, "a") do |new_line|
|
144
|
+
File.open(path, "r") do |f|
|
145
|
+
f.each_line.with_index do |line, _i|
|
146
|
+
if @on
|
147
|
+
if line.include?("t.index") || line.strip == "end"
|
148
|
+
if @user_exist
|
149
|
+
new_line.write(<<-TEXT)
|
133
150
|
}
|
134
151
|
}
|
135
152
|
}
|
@@ -153,9 +170,9 @@ module Souls
|
|
153
170
|
end
|
154
171
|
expect(a1).to include(
|
155
172
|
"id" => be_a(String),
|
156
|
-
|
157
|
-
|
158
|
-
|
173
|
+
TEXT
|
174
|
+
else
|
175
|
+
new_line.write(<<-TEXT)
|
159
176
|
}
|
160
177
|
}
|
161
178
|
}
|
@@ -176,97 +193,80 @@ module Souls
|
|
176
193
|
end
|
177
194
|
expect(a1).to include(
|
178
195
|
"id" => be_a(String),
|
179
|
-
|
180
|
-
end
|
181
|
-
break
|
196
|
+
TEXT
|
182
197
|
end
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
198
|
+
break
|
199
|
+
end
|
200
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
201
|
+
array_true = line.include?("array: true")
|
202
|
+
case name
|
203
|
+
when "user_id", "created_at", "updated_at", /$*_id\z/
|
204
|
+
next
|
205
|
+
else
|
206
|
+
if array_true
|
207
|
+
new_line.write(" #{name.pluralize.camelize(:lower)}\n")
|
188
208
|
else
|
189
|
-
|
190
|
-
new_line.write(" #{name.pluralize.camelize(:lower)}\n")
|
191
|
-
else
|
192
|
-
new_line.write(" #{name.singularize.camelize(:lower)}\n")
|
193
|
-
end
|
209
|
+
new_line.write(" #{name.singularize.camelize(:lower)}\n")
|
194
210
|
end
|
195
211
|
end
|
196
|
-
@on = true if Souls.table_check(line: line, class_name: class_name)
|
197
212
|
end
|
213
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
198
214
|
end
|
199
215
|
end
|
200
216
|
end
|
217
|
+
end
|
201
218
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
end
|
219
|
+
def rspec_mutation_end(class_name: "user")
|
220
|
+
file_path = "./spec/mutations/base/#{class_name.singularize}_spec.rb"
|
221
|
+
path = "./db/schema.rb"
|
222
|
+
@on = false
|
223
|
+
File.open(file_path, "a") do |new_line|
|
224
|
+
File.open(path, "r") do |f|
|
225
|
+
f.each_line.with_index do |line, _i|
|
226
|
+
if @on
|
227
|
+
if line.include?("t.index") || line.strip == "end"
|
228
|
+
new_line.write(<<~TEXT)
|
229
|
+
)
|
214
230
|
end
|
215
231
|
end
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
232
|
+
end
|
233
|
+
TEXT
|
234
|
+
break
|
235
|
+
end
|
236
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
237
|
+
field ||= Souls.type_check(type)
|
238
|
+
array_true = line.include?("array: true")
|
239
|
+
case name
|
240
|
+
when "user_id", "created_at", "updated_at", /$*_id\z/
|
241
|
+
next
|
242
|
+
else
|
243
|
+
case type
|
244
|
+
when "text", "date", "datetime"
|
245
|
+
if array_true
|
246
|
+
new_line.write(" \"#{name.pluralize.camelize(:lower)}\" => be_all(String),\n")
|
247
|
+
else
|
248
|
+
new_line.write(" \"#{name.singularize.camelize(:lower)}\" => be_a(String),\n")
|
249
|
+
end
|
250
|
+
when "boolean"
|
251
|
+
if array_true
|
252
|
+
new_line.write(" \"#{name.pluralize.camelize(:lower)}\" => be_all([true, false]),\n")
|
253
|
+
else
|
254
|
+
new_line.write(" \"#{name.singularize.camelize(:lower)}\" => be_in([true, false]),\n")
|
255
|
+
end
|
256
|
+
when "string", "bigint", "integer", "float"
|
257
|
+
if array_true
|
258
|
+
new_line.write(" \"#{name.pluralize.camelize(:lower)}\" => be_all(#{field}),\n")
|
259
|
+
else
|
260
|
+
new_line.write(" \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n")
|
245
261
|
end
|
246
262
|
end
|
247
263
|
end
|
248
|
-
@on = true if Souls.table_check(line: line, class_name: class_name)
|
249
264
|
end
|
265
|
+
@on = true if Souls.table_check(line: line, class_name: class_name)
|
250
266
|
end
|
251
267
|
end
|
252
|
-
file_path
|
253
|
-
end
|
254
|
-
|
255
|
-
def rspec_mutation(class_name: "user")
|
256
|
-
singularized_class_name = class_name.singularize
|
257
|
-
file_path = "./spec/mutations/base/#{singularized_class_name}_spec.rb"
|
258
|
-
return "RspecMutation already exist! #{file_path}" if File.exist?(file_path)
|
259
|
-
|
260
|
-
rspec_mutation_head(class_name: singularized_class_name)
|
261
|
-
rspec_mutation_after_head(class_name: singularized_class_name)
|
262
|
-
rspec_mutation_params(class_name: singularized_class_name)
|
263
|
-
rspec_mutation_params_response(class_name: singularized_class_name)
|
264
|
-
rspec_mutation_end(class_name: singularized_class_name)
|
265
|
-
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
266
|
-
file_path
|
267
|
-
rescue StandardError => e
|
268
|
-
raise(StandardError, e)
|
269
268
|
end
|
269
|
+
file_path
|
270
270
|
end
|
271
271
|
end
|
272
272
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
def
|
2
|
+
class Generate < Thor
|
3
|
+
desc "rspec_policy [CLASS_NAME]", "Generate Rspec Policy Test from schema.rb"
|
4
|
+
def rspec_policy(class_name)
|
5
5
|
dir_name = "./spec/policies"
|
6
6
|
FileUtils.mkdir_p(dir_name) unless Dir.exist?(dir_name)
|
7
7
|
file_path = "./spec/policies/#{class_name}_policy_spec.rb"
|
@@ -38,8 +38,8 @@ module Souls
|
|
38
38
|
end
|
39
39
|
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
40
40
|
file_path
|
41
|
-
rescue
|
42
|
-
raise(
|
41
|
+
rescue Thor::Error => e
|
42
|
+
raise(Thor::Error, e)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|