souls 2.0.3 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -28
- 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/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,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
|