souls 0.60.2 → 0.60.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/souls/api/generate/application.rb +1 -0
- data/lib/souls/api/generate/manager_rbs.rb +17 -15
- data/lib/souls/api/generate/model_rbs.rb +2 -4
- data/lib/souls/api/generate/mutation.rb +10 -6
- data/lib/souls/api/generate/resolver_rbs.rb +0 -3
- 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 +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec823772e4849a995e22414890aff5a90c6521e369c9e1c31974204b6f82d65a
|
4
|
+
data.tar.gz: b78d324b3ff93c2e3350d2c059020995e7c8a8479dd3293aead47041b5aa3d5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18d97704c8db8e3befb5aafadcf19eec3c92bd7472811063295fe26df2d63e5da3153f1337b6d40983b60d13049cb3ebc16d885c146726bf714f05e6506abf77
|
7
|
+
data.tar.gz: 8ad57a789e18a2bce598705e5a4d296b73c35b3dbecabccec68cd1acdf75abb3147f55fee4efb1f1d0c9ba7d27869d158b5657936d7803da26a798a354642071
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Souls
|
2
2
|
class Generate < Thor
|
3
3
|
desc "scaffold [CLASS_NAME]", "Generate Scaffold from schema.rb"
|
4
|
+
method_option :mutation, type: :boolean, aliases: "--rbs", desc: "Mutation File Name"
|
4
5
|
def scaffold(class_name)
|
5
6
|
singularized_class_name = class_name.singularize
|
6
7
|
model(singularized_class_name)
|
@@ -5,24 +5,26 @@ module Souls
|
|
5
5
|
def manager_rbs(class_name)
|
6
6
|
file_path = ""
|
7
7
|
singularized_class_name = class_name.underscore.singularize
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
module
|
15
|
-
module
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
Dir.chdir(Souls.get_mother_path.to_s) do
|
9
|
+
file_dir = "./sig/api/app/graphql/mutations/managers/#{singularized_class_name}_manager"
|
10
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
11
|
+
file_path = "#{file_dir}/#{options[:mutation]}.rbs"
|
12
|
+
File.open(file_path, "w") do |f|
|
13
|
+
f.write(<<~TEXT)
|
14
|
+
module Mutations
|
15
|
+
module Managers
|
16
|
+
module #{singularized_class_name.camelize}Manager
|
17
|
+
class #{options[:mutation].singularize.camelize}
|
18
|
+
def self.description: (String)-> untyped
|
19
|
+
def self.argument: (untyped, untyped, untyped)-> untyped
|
20
|
+
def self.field: (untyped, untyped, untyped)-> untyped
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
TEXT
|
26
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
27
|
+
end
|
26
28
|
end
|
27
29
|
file_path
|
28
30
|
rescue Thor::Error => e
|
@@ -4,15 +4,13 @@ module Souls
|
|
4
4
|
def model_rbs(class_name)
|
5
5
|
file_path = ""
|
6
6
|
Dir.chdir(Souls.get_mother_path.to_s) do
|
7
|
-
file_dir = "./sig/api/app/
|
7
|
+
file_dir = "./sig/api/app/models/"
|
8
8
|
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
9
9
|
singularized_class_name = class_name.underscore.singularize
|
10
10
|
file_path = "#{file_dir}#{singularized_class_name}_model.rbs"
|
11
11
|
File.open(file_path, "w") do |f|
|
12
12
|
f.write(<<~TEXT)
|
13
|
-
|
14
|
-
class #{singularized_class_name.camelize} < ActiveRecord::Base
|
15
|
-
end
|
13
|
+
class #{singularized_class_name.camelize} < ActiveRecord::Base
|
16
14
|
end
|
17
15
|
TEXT
|
18
16
|
end
|
@@ -55,14 +55,17 @@ module Souls
|
|
55
55
|
if @user_exist
|
56
56
|
new_line.write(<<-TEXT)
|
57
57
|
|
58
|
-
def resolve
|
58
|
+
def resolve(args)
|
59
59
|
params = args.dup
|
60
60
|
params[:user_id] = context[:user][:id]
|
61
|
+
data = ::#{class_name.camelize}.new(args)
|
61
62
|
TEXT
|
62
63
|
else
|
63
64
|
new_line.write(<<-TEXT)
|
64
65
|
|
65
|
-
def resolve
|
66
|
+
def resolve(args)
|
67
|
+
params = args.dup
|
68
|
+
data = ::#{class_name.camelize}.new(args)
|
66
69
|
TEXT
|
67
70
|
end
|
68
71
|
break
|
@@ -93,9 +96,11 @@ module Souls
|
|
93
96
|
return false if relation_params.empty?
|
94
97
|
|
95
98
|
file_path = "./app/graphql/mutations/base/#{class_name}/create_#{class_name}.rb"
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
+
|
100
|
+
File.open(file_path, "a") do |new_line|
|
101
|
+
relation_params.each_with_index do |params_name, i|
|
102
|
+
new_line.write(" params = args.dup\n") if @user_exist && i.zero?
|
103
|
+
new_line.write(" _, params[:#{params_name}] = SoulsApiSchema.from_global_id(args[:#{params_name}])\n")
|
99
104
|
end
|
100
105
|
end
|
101
106
|
true
|
@@ -105,7 +110,6 @@ module Souls
|
|
105
110
|
file_path = "./app/graphql/mutations/base/#{class_name}/create_#{class_name}.rb"
|
106
111
|
File.open(file_path, "a") do |new_line|
|
107
112
|
new_line.write(<<~TEXT)
|
108
|
-
data = ::#{class_name.camelize}.new args
|
109
113
|
raise(StandardError, data.errors.full_messages) unless data.save
|
110
114
|
|
111
115
|
{ #{class_name}_edge: { node: data } }
|
@@ -14,9 +14,6 @@ module Souls
|
|
14
14
|
f.write(<<~TEXT)
|
15
15
|
class Base
|
16
16
|
end
|
17
|
-
module SearchObject
|
18
|
-
def self.module: (Symbol) -> untyped
|
19
|
-
end
|
20
17
|
class #{singularized_class_name.camelize}Search < Base
|
21
18
|
include SearchObject
|
22
19
|
def self.scope: () ?{ () -> nil } -> [Hash[Symbol, untyped]]
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.39.
|
1
|
+
0.39.3
|
@@ -1 +1 @@
|
|
1
|
-
0.39.
|
1
|
+
0.39.3
|