souls 2.0.4 → 3.0.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/README.md +6 -28
- data/lib/souls/app/utils/firebase_id_token.rb +1 -1
- data/lib/souls/cli/create/index.rb +0 -62
- data/lib/souls/cli/db/create_migration.rb +0 -1
- data/lib/souls/cli/db/index.rb +0 -2
- data/lib/souls/cli/delete/application.rb +2 -18
- data/lib/souls/cli/delete/job.rb +0 -1
- data/lib/souls/cli/delete/manager.rb +0 -1
- data/lib/souls/cli/delete/migration_file.rb +0 -1
- data/lib/souls/cli/gcloud/iam/index.rb +17 -19
- data/lib/souls/cli/gcloud/sql/index.rb +2 -0
- data/lib/souls/cli/generate/application.rb +2 -27
- data/lib/souls/cli/generate/job.rb +0 -1
- data/lib/souls/cli/generate/manager.rb +0 -1
- data/lib/souls/cli/generate/mutation.rb +2 -2
- data/lib/souls/cli/init/index.rb +0 -9
- data/lib/souls/cli/update/index.rb +0 -7
- data/lib/souls/cli/upgrade/index.rb +0 -1
- data/lib/souls/cli.rb +2 -20
- data/lib/souls/utils/index.rb +0 -13
- 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 +5 -26
- data/lib/souls/cli/db/create_migration_rbs.rb +0 -25
- data/lib/souls/cli/db/model_rbs.rb +0 -22
- data/lib/souls/cli/delete/connection_rbs.rb +0 -16
- data/lib/souls/cli/delete/edge_rbs.rb +0 -15
- data/lib/souls/cli/delete/job_rbs.rb +0 -22
- data/lib/souls/cli/delete/manager_rbs.rb +0 -17
- data/lib/souls/cli/delete/mutation_rbs.rb +0 -15
- data/lib/souls/cli/delete/query_rbs.rb +0 -16
- data/lib/souls/cli/delete/resolver_rbs.rb +0 -16
- data/lib/souls/cli/delete/type_rbs.rb +0 -16
- data/lib/souls/cli/generate/connection_rbs.rb +0 -25
- data/lib/souls/cli/generate/edge_rbs.rb +0 -28
- data/lib/souls/cli/generate/job_rbs.rb +0 -40
- data/lib/souls/cli/generate/manager_rbs.rb +0 -32
- data/lib/souls/cli/generate/mutation_rbs.rb +0 -241
- data/lib/souls/cli/generate/query_rbs.rb +0 -38
- data/lib/souls/cli/generate/resolver_rbs.rb +0 -42
- data/lib/souls/cli/generate/type_rbs.rb +0 -56
- data/lib/souls/cli/update/mutation_rbs.rb +0 -126
- data/lib/souls/cli/update/type_rbs.rb +0 -44
- data/lib/souls/cli/upgrade/submodule.rb +0 -8
@@ -1,241 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "mutation_rbs [CLASS_NAME]", "Generate GraphQL Mutation RBS from schema.rb"
|
4
|
-
def mutation_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.underscore.singularize
|
6
|
-
create_rbs_mutation(class_name: singularized_class_name)
|
7
|
-
update_rbs_mutation(class_name: singularized_class_name)
|
8
|
-
delete_rbs_mutation(class_name: singularized_class_name)
|
9
|
-
destroy_delete_rbs_mutation(class_name: singularized_class_name)
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def create_rbs_mutation(class_name: "user")
|
15
|
-
file_path = ""
|
16
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
17
|
-
file_dir = "./sig/api/app/graphql/mutations/base/#{class_name}"
|
18
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
19
|
-
file_path = "#{file_dir}/create_#{class_name}.rbs"
|
20
|
-
raise(Thor::Error, "Mutation RBS already exist! #{file_path}") if File.exist?(file_path)
|
21
|
-
|
22
|
-
params = SOULs.get_relation_params(class_name:, col: "mutation")
|
23
|
-
File.open(file_path, "w") do |f|
|
24
|
-
f.write(<<~TEXT)
|
25
|
-
class Boolean
|
26
|
-
end
|
27
|
-
module Mutations
|
28
|
-
module Base
|
29
|
-
module #{class_name.camelize}
|
30
|
-
class Create#{class_name.camelize} < BaseMutation
|
31
|
-
String: String
|
32
|
-
Boolean: Boolean
|
33
|
-
Integer: Integer
|
34
|
-
def resolve: ({
|
35
|
-
TEXT
|
36
|
-
end
|
37
|
-
File.open(file_path, "a") do |f|
|
38
|
-
params[:params].each_with_index do |param, i|
|
39
|
-
type = SOULs.rbs_type_check(param[:type])
|
40
|
-
type = "[#{type}]" if param[:array]
|
41
|
-
if i == params[:params].size - 1
|
42
|
-
f.write(" #{param[:column_name]}: #{type}?\n")
|
43
|
-
elsif param[:column_name].match?(/$*_id\z/)
|
44
|
-
f.write(" #{param[:column_name]}: String?,\n")
|
45
|
-
else
|
46
|
-
f.write(" #{param[:column_name]}: #{type}?,\n")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
# rubocop:disable Layout/LineLength
|
51
|
-
File.open(file_path, "a") do |f|
|
52
|
-
f.write(" }) -> ({ :#{class_name}_edge => { :node => String } } | ::GraphQL::ExecutionError )\n\n")
|
53
|
-
end
|
54
|
-
# rubocop:enable Layout/LineLength
|
55
|
-
|
56
|
-
File.open(file_path, "a") do |f|
|
57
|
-
params[:params].each_with_index do |param, i|
|
58
|
-
type = SOULs.type_check(param[:type])
|
59
|
-
rbs_type = SOULs.rbs_type_check(param[:type])
|
60
|
-
type = "[#{type}]" if param[:array]
|
61
|
-
if i.zero?
|
62
|
-
if param[:column_name].match?(/$*_id\z/)
|
63
|
-
f.write(
|
64
|
-
" def self.argument: (:#{param[:column_name]}, String, " \
|
65
|
-
"required: false ) -> #{rbs_type}\n"
|
66
|
-
)
|
67
|
-
else
|
68
|
-
f.write(
|
69
|
-
" def self.argument: (:#{param[:column_name]}, #{type}, " \
|
70
|
-
"required: false ) -> #{rbs_type}\n"
|
71
|
-
)
|
72
|
-
end
|
73
|
-
elsif param[:column_name].match?(/$*_id\z/)
|
74
|
-
f.write(" | (:#{param[:column_name]}, String, required: false ) -> String\n")
|
75
|
-
else
|
76
|
-
f.write(
|
77
|
-
" | (:#{param[:column_name]}, #{type}, " \
|
78
|
-
"required: false ) -> #{rbs_type}\n"
|
79
|
-
)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
File.open(file_path, "a") do |f|
|
85
|
-
f.write(<<~TEXT)
|
86
|
-
|
87
|
-
def self.field: (*untyped) -> String
|
88
|
-
attr_accessor context: {user:{
|
89
|
-
id: Integer,
|
90
|
-
username: String,
|
91
|
-
email: String
|
92
|
-
}}
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
TEXT
|
98
|
-
end
|
99
|
-
end
|
100
|
-
SOULs::Painter.create_file(file_path.to_s)
|
101
|
-
file_path
|
102
|
-
end
|
103
|
-
|
104
|
-
def update_rbs_mutation(class_name: "user")
|
105
|
-
file_path = ""
|
106
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
107
|
-
file_dir = "./sig/api/app/graphql/mutations/base/#{class_name}"
|
108
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
109
|
-
file_path = "#{file_dir}/update_#{class_name}.rbs"
|
110
|
-
params = SOULs.get_relation_params(class_name:, col: "mutation")
|
111
|
-
params[:params] << { column_name: "id", type: "string", array: false }
|
112
|
-
File.open(file_path, "w") do |f|
|
113
|
-
f.write(<<~TEXT)
|
114
|
-
module Mutations
|
115
|
-
module Base
|
116
|
-
module #{class_name.camelize}
|
117
|
-
class Update#{class_name.camelize} < BaseMutation
|
118
|
-
String: String
|
119
|
-
Boolean: Boolean
|
120
|
-
Integer: Integer
|
121
|
-
def resolve: ({
|
122
|
-
id: String,
|
123
|
-
TEXT
|
124
|
-
end
|
125
|
-
File.open(file_path, "a") do |f|
|
126
|
-
cols = params[:params].reject { |n| n[:column_name] == "user_id" }
|
127
|
-
cols.each_with_index do |param, i|
|
128
|
-
type = SOULs.rbs_type_check(param[:type])
|
129
|
-
type = "[#{type}]" if param[:array]
|
130
|
-
type = "String" if param[:column_name].match?(/$*_id\z/)
|
131
|
-
|
132
|
-
if i == params[:params].size - 1
|
133
|
-
f.write(" #{param[:column_name]}: #{type}?\n")
|
134
|
-
else
|
135
|
-
f.write(" #{param[:column_name]}: #{type}?,\n")
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
# rubocop:disable Layout/LineLength
|
140
|
-
File.open(file_path, "a") do |f|
|
141
|
-
f.write(" }) -> ({ :#{class_name}_edge => { :node => String } } | ::GraphQL::ExecutionError )\n\n")
|
142
|
-
end
|
143
|
-
# rubocop:enable Layout/LineLength
|
144
|
-
|
145
|
-
File.open(file_path, "a") do |f|
|
146
|
-
cols = params[:params].reject { |n| n[:column_name] == "user_id" }
|
147
|
-
cols.each_with_index do |param, i|
|
148
|
-
type = SOULs.type_check(param[:type])
|
149
|
-
rbs_type = SOULs.rbs_type_check(param[:type])
|
150
|
-
type = "[#{type}]" if param[:array]
|
151
|
-
type = "String" if param[:column_name].match?(/$*_id\z/)
|
152
|
-
rbs_type = "String" if param[:column_name].match?(/$*_id\z/)
|
153
|
-
|
154
|
-
required = param[:column_name] == "id" ? "required: true" : "required: false"
|
155
|
-
if i.zero?
|
156
|
-
f.write(" def self.argument: (:#{param[:column_name]}, #{type}, #{required} ) -> #{rbs_type}\n")
|
157
|
-
else
|
158
|
-
f.write(" | (:#{param[:column_name]}, #{type}, #{required} ) -> #{rbs_type}\n")
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
File.open(file_path, "a") do |f|
|
164
|
-
f.write(<<~TEXT)
|
165
|
-
|
166
|
-
def self.field: (*untyped) -> String
|
167
|
-
attr_accessor context: {user:{
|
168
|
-
id: Integer,
|
169
|
-
username: String,
|
170
|
-
email: String
|
171
|
-
}}
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
TEXT
|
177
|
-
end
|
178
|
-
end
|
179
|
-
SOULs::Painter.create_file(file_path.to_s)
|
180
|
-
file_path
|
181
|
-
end
|
182
|
-
|
183
|
-
def delete_rbs_mutation(class_name: "user")
|
184
|
-
file_path = ""
|
185
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
186
|
-
file_dir = "./sig/api/app/graphql/mutations/base/#{class_name}"
|
187
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
188
|
-
file_path = "#{file_dir}/delete_#{class_name}.rbs"
|
189
|
-
File.open(file_path, "w") do |f|
|
190
|
-
f.write(<<~TEXT)
|
191
|
-
module Mutations
|
192
|
-
module Base
|
193
|
-
module #{class_name.camelize}
|
194
|
-
class Delete#{class_name.camelize}
|
195
|
-
def resolve: ({
|
196
|
-
id: String
|
197
|
-
}) -> ( Hash[Symbol, untyped] | ::GraphQL::ExecutionError )
|
198
|
-
#{' '}
|
199
|
-
def self.argument: (*untyped) -> String
|
200
|
-
def self.field: (*untyped) -> String
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
TEXT
|
206
|
-
end
|
207
|
-
SOULs::Painter.create_file(file_path.to_s)
|
208
|
-
end
|
209
|
-
file_path
|
210
|
-
end
|
211
|
-
|
212
|
-
def destroy_delete_rbs_mutation(class_name: "user")
|
213
|
-
file_path = ""
|
214
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
215
|
-
file_dir = "./sig/api/app/graphql/mutations/base/#{class_name}"
|
216
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
217
|
-
file_path = "#{file_dir}/destroy_delete_#{class_name}.rbs"
|
218
|
-
File.open(file_path, "w") do |f|
|
219
|
-
f.write(<<~TEXT)
|
220
|
-
module Mutations
|
221
|
-
module Base
|
222
|
-
module #{class_name.camelize}
|
223
|
-
class DestroyDelete#{class_name.camelize}
|
224
|
-
def resolve: ({
|
225
|
-
id: String
|
226
|
-
}) -> ( Hash[Symbol, untyped] | ::GraphQL::ExecutionError )
|
227
|
-
#{' '}
|
228
|
-
def self.argument: (*untyped) -> String
|
229
|
-
def self.field: (*untyped) -> String
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
234
|
-
TEXT
|
235
|
-
end
|
236
|
-
SOULs::Painter.create_file(file_path.to_s)
|
237
|
-
end
|
238
|
-
file_path
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "query_rbs [CLASS_NAME]", "Generate GraphQL Query RBS"
|
4
|
-
def query_rbs(class_name)
|
5
|
-
single_query_rbs(class_name)
|
6
|
-
end
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def single_query_rbs(class_name)
|
11
|
-
file_path = ""
|
12
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
13
|
-
file_dir = "./sig/api/app/graphql/queries/"
|
14
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
15
|
-
singularized_class_name = class_name.underscore.singularize
|
16
|
-
file_path = "#{file_dir}#{singularized_class_name}.rbs"
|
17
|
-
File.open(file_path, "w") do |f|
|
18
|
-
f.write(<<~TEXT)
|
19
|
-
module Queries
|
20
|
-
class BaseQuery
|
21
|
-
end
|
22
|
-
class #{singularized_class_name.camelize} < Queries::BaseQuery
|
23
|
-
def resolve: ({
|
24
|
-
id: String?
|
25
|
-
}) -> ( Hash[Symbol, ( String | Integer | bool )] | ::GraphQL::ExecutionError )
|
26
|
-
|
27
|
-
def self.argument: (*untyped) -> String
|
28
|
-
def self.type: (*untyped) -> String
|
29
|
-
end
|
30
|
-
end
|
31
|
-
TEXT
|
32
|
-
end
|
33
|
-
SOULs::Painter.create_file(file_path.to_s)
|
34
|
-
end
|
35
|
-
file_path
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "resolver_rbs [CLASS_NAME]", "Generate GraphQL Resolver RBS from schema.rb"
|
4
|
-
def resolver_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.underscore.singularize
|
6
|
-
file_path = ""
|
7
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
8
|
-
file_dir = "./sig/api/app/graphql/resolvers"
|
9
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
10
|
-
file_path = "#{file_dir}/#{singularized_class_name}_search.rbs"
|
11
|
-
raise(Thor::Error, "Mutation RBS already exist! #{file_path}") if File.exist?(file_path)
|
12
|
-
|
13
|
-
File.open(file_path, "w") do |f|
|
14
|
-
f.write(<<~TEXT)
|
15
|
-
module Resolvers
|
16
|
-
class BaseResolver
|
17
|
-
end
|
18
|
-
class #{singularized_class_name.camelize}Search < BaseResolver
|
19
|
-
include SearchObject
|
20
|
-
def self.scope: () ?{ () -> nil } -> [Hash[Symbol, untyped]]
|
21
|
-
def self.type: (*untyped) -> String
|
22
|
-
def self.option: (:filter, type: untyped, with: :apply_filter) -> String
|
23
|
-
def self.description: (String) -> String
|
24
|
-
def self.types: (*untyped) -> String
|
25
|
-
def decode_global_key: (String value) -> Integer
|
26
|
-
def apply_filter: (untyped scope, untyped value) -> untyped
|
27
|
-
|
28
|
-
class #{singularized_class_name.camelize}Filter
|
29
|
-
String: String
|
30
|
-
Boolean: Boolean
|
31
|
-
Integer: Integer
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
TEXT
|
36
|
-
end
|
37
|
-
end
|
38
|
-
SOULs::Painter.create_file(file_path.to_s)
|
39
|
-
file_path
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Generate < Thor
|
3
|
-
desc "type_rbs [CLASS_NAME]", "Generate GraphQL Type RBS from schema.rb"
|
4
|
-
def type_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.underscore.singularize
|
6
|
-
file_path = ""
|
7
|
-
Dir.chdir(SOULs.get_mother_path.to_s) do
|
8
|
-
file_dir = "./sig/api/app/graphql/types"
|
9
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
10
|
-
file_path = "#{file_dir}/#{singularized_class_name}_type.rbs"
|
11
|
-
raise(Thor::Error, "Type RBS already exist! #{file_path}") if File.exist?(file_path)
|
12
|
-
|
13
|
-
params = SOULs.get_relation_params(class_name: singularized_class_name)
|
14
|
-
File.open(file_path, "w") do |f|
|
15
|
-
f.write(<<~TEXT)
|
16
|
-
module Types
|
17
|
-
class #{singularized_class_name.camelize}Type < BaseObject
|
18
|
-
def self.implements: (*untyped) -> untyped
|
19
|
-
def self.global_id_field: (:id) -> String
|
20
|
-
TEXT
|
21
|
-
end
|
22
|
-
File.open(file_path, "a") do |f|
|
23
|
-
params[:params].each_with_index do |param, i|
|
24
|
-
type = SOULs.type_check(param[:type])
|
25
|
-
type = "[#{type}]" if param[:array]
|
26
|
-
rbs_type = SOULs.rbs_type_check(param[:type])
|
27
|
-
if i.zero?
|
28
|
-
if param[:column_name].match?(/$*_id\z/)
|
29
|
-
col_name = param[:column_name].gsub("_id", "")
|
30
|
-
f.write(" def self.field: (:#{col_name}, untyped, null: false) -> untyped\n")
|
31
|
-
else
|
32
|
-
f.write(" def self.field: (:#{param[:column_name]}, #{type}, null: true) -> #{rbs_type}\n")
|
33
|
-
end
|
34
|
-
elsif param[:column_name].match?(/$*_id\z/)
|
35
|
-
col_name = param[:column_name].gsub("_id", "")
|
36
|
-
f.write(" | (:#{col_name}, untyped, null: false) -> untyped\n")
|
37
|
-
else
|
38
|
-
f.write(" | (:#{param[:column_name]}, #{type}, null: true) -> #{rbs_type}\n")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
File.open(file_path, "a") do |f|
|
44
|
-
f.write(<<~TEXT)
|
45
|
-
def self.edge_type: () -> untyped
|
46
|
-
def self.connection_type: () -> untyped
|
47
|
-
end
|
48
|
-
end
|
49
|
-
TEXT
|
50
|
-
end
|
51
|
-
end
|
52
|
-
SOULs::Painter.create_file(file_path.to_s)
|
53
|
-
file_path
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Update < Thor
|
3
|
-
desc "create_mutation_rbs [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
4
|
-
def create_mutation_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.singularize.underscore
|
6
|
-
new_cols = ""
|
7
|
-
Dir.chdir(SOULs.get_api_path.to_s) do
|
8
|
-
new_cols = SOULs.get_columns_num(class_name: singularized_class_name)
|
9
|
-
end
|
10
|
-
dir_name = "./sig/api/app/graphql/mutations/base/#{singularized_class_name}"
|
11
|
-
file_path = "#{dir_name}/create_#{singularized_class_name}.rbs"
|
12
|
-
argument = false
|
13
|
-
resolve = false
|
14
|
-
write_txt = ""
|
15
|
-
File.open(file_path, "r") do |f|
|
16
|
-
f.each_line do |line|
|
17
|
-
next if line.include?("| (:") && argument
|
18
|
-
|
19
|
-
if line.include?("{ :node => String } } | ::GraphQL::ExecutionError )")
|
20
|
-
write_txt += line
|
21
|
-
resolve = false
|
22
|
-
elsif resolve
|
23
|
-
next
|
24
|
-
elsif line.include?("def resolve:") && !resolve
|
25
|
-
new_cols.each_with_index do |col, i|
|
26
|
-
type = SOULs.type_check(col[:type])
|
27
|
-
type = "[#{type}]" if col[:array]
|
28
|
-
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
29
|
-
|
30
|
-
write_txt +=
|
31
|
-
if i.zero?
|
32
|
-
line
|
33
|
-
else
|
34
|
-
" #{col[:column_name]}: #{type}?,\n"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
resolve = true
|
38
|
-
elsif line.include?("def self.argument:") && !argument
|
39
|
-
new_cols.each_with_index do |col, i|
|
40
|
-
type = SOULs.type_check(col[:type])
|
41
|
-
type = "[#{type}]" if col[:array]
|
42
|
-
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
43
|
-
|
44
|
-
if i.zero?
|
45
|
-
write_txt +=
|
46
|
-
" def self.argument: (:#{col[:column_name]}, #{type}, required: false ) -> #{type}\n"
|
47
|
-
else
|
48
|
-
write_txt +=
|
49
|
-
" | (:#{col[:column_name]}, #{type}, required: false ) -> #{type}\n"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
argument = true
|
53
|
-
else
|
54
|
-
write_txt += line
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
File.open(file_path, "w") { |f| f.write(write_txt) }
|
59
|
-
SOULs::Painter.update_file(file_path.to_s)
|
60
|
-
end
|
61
|
-
|
62
|
-
desc "update_mutation [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
63
|
-
def update_mutation_rbs(class_name)
|
64
|
-
singularized_class_name = class_name.singularize.underscore
|
65
|
-
new_cols = ""
|
66
|
-
Dir.chdir(SOULs.get_api_path.to_s) do
|
67
|
-
new_cols = SOULs.get_columns_num(class_name: singularized_class_name)
|
68
|
-
end
|
69
|
-
dir_name = "./sig/api/app/graphql/mutations/base/#{singularized_class_name}"
|
70
|
-
new_file_path = "config/update_mutation.rbs"
|
71
|
-
file_path = "#{dir_name}/update_#{singularized_class_name}.rbs"
|
72
|
-
argument = false
|
73
|
-
resolve = false
|
74
|
-
File.open(file_path) do |f|
|
75
|
-
File.open(new_file_path, "w") do |new_line|
|
76
|
-
f.each_line do |line|
|
77
|
-
next if line.include?("| (:") && argument
|
78
|
-
|
79
|
-
if line.include?("{ :node => String } } | ::GraphQL::ExecutionError )")
|
80
|
-
new_line.write(line)
|
81
|
-
resolve = false
|
82
|
-
elsif resolve
|
83
|
-
next
|
84
|
-
elsif line.include?("def resolve:") && !resolve
|
85
|
-
new_cols.each_with_index do |col, i|
|
86
|
-
type = SOULs.type_check(col[:type])
|
87
|
-
type = "[#{type}]" if col[:array]
|
88
|
-
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
89
|
-
|
90
|
-
if i.zero?
|
91
|
-
new_line.write(line)
|
92
|
-
new_line.write(" id: String,\n")
|
93
|
-
else
|
94
|
-
new_line.write(" #{col[:column_name]}: #{type}?,\n")
|
95
|
-
end
|
96
|
-
end
|
97
|
-
resolve = true
|
98
|
-
elsif line.include?("def self.argument:") && !argument
|
99
|
-
new_cols.each_with_index do |col, i|
|
100
|
-
type = SOULs.type_check(col[:type])
|
101
|
-
type = "[#{type}]" if col[:array]
|
102
|
-
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
103
|
-
|
104
|
-
if i.zero?
|
105
|
-
new_line.write(
|
106
|
-
" def self.argument: (:#{col[:column_name]}, #{type}, required: false ) -> #{type}\n"
|
107
|
-
)
|
108
|
-
else
|
109
|
-
new_line.write(
|
110
|
-
" | (:#{col[:column_name]}, #{type}, required: false ) -> #{type}\n"
|
111
|
-
)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
argument = true
|
115
|
-
else
|
116
|
-
new_line.write(line)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
FileUtils.rm(file_path)
|
122
|
-
FileUtils.mv(new_file_path, file_path)
|
123
|
-
SOULs::Painter.update_file(file_path.to_s)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module SOULs
|
2
|
-
class Update < Thor
|
3
|
-
desc "type_rbs [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
4
|
-
def type_rbs(class_name)
|
5
|
-
singularized_class_name = class_name.singularize.underscore
|
6
|
-
new_cols = ""
|
7
|
-
Dir.chdir(SOULs.get_api_path.to_s) do
|
8
|
-
new_cols = SOULs.get_columns_num(class_name: singularized_class_name)
|
9
|
-
end
|
10
|
-
dir_name = "./sig/api/app/graphql/types"
|
11
|
-
new_file_path = "config/create_type.rbs"
|
12
|
-
file_path = "#{dir_name}/#{singularized_class_name}_type.rbs"
|
13
|
-
argument = false
|
14
|
-
File.open(file_path) do |f|
|
15
|
-
File.open(new_file_path, "w") do |new_line|
|
16
|
-
f.each_line do |line|
|
17
|
-
next if line.include?("| (:") && argument
|
18
|
-
|
19
|
-
if line.include?(" def self.edge_type:")
|
20
|
-
new_line.write(line)
|
21
|
-
argument = false
|
22
|
-
elsif line.include?("def self.field:") && !argument
|
23
|
-
new_cols.each_with_index do |col, i|
|
24
|
-
type = SOULs.get_type(col[:type])
|
25
|
-
type = "[#{type}]" if col[:array]
|
26
|
-
if i.zero?
|
27
|
-
new_line.write(" def self.field: (:#{col[:column_name]}, #{type}, null: true) -> #{type}\n")
|
28
|
-
else
|
29
|
-
new_line.write(" | (:#{col[:column_name]}, #{type}, null: true) -> #{type}\n")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
argument = true
|
33
|
-
else
|
34
|
-
new_line.write(line)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
FileUtils.rm(file_path)
|
40
|
-
FileUtils.mv(new_file_path, file_path)
|
41
|
-
SOULs::Painter.update_file(file_path.to_s)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|