souls 0.60.3 → 0.61.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/souls/cli/db/index.rb +12 -12
- data/lib/souls/{api → cli}/generate/application.rb +48 -24
- data/lib/souls/{api → cli}/generate/connection.rb +0 -0
- data/lib/souls/{api → cli}/generate/connection_rbs.rb +0 -0
- data/lib/souls/{api → cli}/generate/edge.rb +0 -0
- data/lib/souls/{api → cli}/generate/edge_rbs.rb +0 -0
- data/lib/souls/{api → cli}/generate/index.rb +7 -2
- data/lib/souls/{worker → cli}/generate/job.rb +3 -2
- data/lib/souls/{worker → cli}/generate/job_rbs.rb +0 -0
- data/lib/souls/{api → cli}/generate/manager.rb +4 -2
- data/lib/souls/{api → cli}/generate/manager_rbs.rb +0 -0
- data/lib/souls/{api → cli}/generate/model.rb +0 -0
- data/lib/souls/{api → cli}/generate/model_rbs.rb +0 -0
- data/lib/souls/{api → cli}/generate/mutation.rb +44 -92
- data/lib/souls/{api → cli}/generate/mutation_rbs.rb +0 -0
- data/lib/souls/{api → cli}/generate/policy.rb +0 -0
- data/lib/souls/{api → cli}/generate/policy_rbs.rb +0 -0
- data/lib/souls/{api → cli}/generate/query.rb +0 -0
- data/lib/souls/{api → cli}/generate/query_rbs.rb +0 -0
- data/lib/souls/{api → cli}/generate/resolver.rb +0 -0
- data/lib/souls/{api → cli}/generate/resolver_rbs.rb +0 -0
- data/lib/souls/{api → cli}/generate/rspec_factory.rb +0 -0
- data/lib/souls/cli/generate/rspec_job.rb +48 -0
- data/lib/souls/cli/generate/rspec_manager.rb +49 -0
- data/lib/souls/{api → cli}/generate/rspec_model.rb +0 -0
- data/lib/souls/{api → cli}/generate/rspec_mutation.rb +0 -0
- data/lib/souls/{api → cli}/generate/rspec_policy.rb +0 -0
- data/lib/souls/{api → cli}/generate/rspec_query.rb +0 -0
- data/lib/souls/{api → cli}/generate/rspec_resolver.rb +0 -0
- data/lib/souls/{api → cli}/generate/type.rb +0 -0
- data/lib/souls/{api → cli}/generate/type_rbs.rb +0 -0
- data/lib/souls/cli/index.rb +2 -0
- data/lib/souls/cli/init/index.rb +1 -1
- data/lib/souls/{api → cli}/update/index.rb +0 -0
- data/lib/souls/{api → cli}/update/mutation.rb +0 -0
- data/lib/souls/{api → cli}/update/resolver.rb +0 -0
- data/lib/souls/{api → cli}/update/rspec_factory.rb +0 -0
- data/lib/souls/{api → cli}/update/rspec_mutation.rb +0 -0
- data/lib/souls/{api → cli}/update/rspec_resolver.rb +0 -0
- data/lib/souls/{api → cli}/update/type.rb +0 -0
- data/lib/souls/cli.rb +14 -20
- data/lib/souls/index.rb +0 -2
- 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 +39 -40
- data/lib/souls/api/index.rb +0 -14
- data/lib/souls/worker/generate/index.rb +0 -2
- data/lib/souls/worker/index.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 630be09191b9f58ffab7b304d247f4c5b8bc07e6f75c224badce92e946d4e35a
|
4
|
+
data.tar.gz: aec39e44cc2a9bf871290b5abd310d7b287b0dabb2c774a7ad4bf19fe5eb837a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7f386e93badfffc73c33a66079765644592357a18314f801299e7a3f63293b7379738fe874601263734e1cd658337862e378375221a897c7188dc79ee4c35f9
|
7
|
+
data.tar.gz: df0659b22c6a7d76b15c3413535c80fb014bfd497ced5ebbd01184bafacdca24a6c460097b39698f4e5bf56ceeb102c863b860ba12ac81130e844b41382fb33e
|
data/lib/souls/cli/db/index.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Souls
|
2
|
-
class
|
3
|
-
desc "
|
2
|
+
class DB < Thor
|
3
|
+
desc "migrate", "Migrate Database"
|
4
4
|
method_option :env, aliases: "--e", default: "development", desc: "Difine APP Enviroment - development | production"
|
5
5
|
def migrate
|
6
6
|
case options[:env]
|
@@ -15,9 +15,9 @@ module Souls
|
|
15
15
|
raise(Thor::Error, e)
|
16
16
|
end
|
17
17
|
|
18
|
-
desc "
|
18
|
+
desc "create", "Create Database"
|
19
19
|
method_option :env, aliases: "--e", default: "development", desc: "Difine APP Enviroment - development | production"
|
20
|
-
def
|
20
|
+
def create
|
21
21
|
case options[:env]
|
22
22
|
when "production"
|
23
23
|
system("rake db:create RACK_ENV=production")
|
@@ -29,7 +29,7 @@ module Souls
|
|
29
29
|
raise(Thor::Error, e)
|
30
30
|
end
|
31
31
|
|
32
|
-
desc "
|
32
|
+
desc "seed", "Insert Seed Data"
|
33
33
|
method_option :env, aliases: "--e", default: "development", desc: "Difine APP Enviroment - development | production"
|
34
34
|
def seed
|
35
35
|
case options[:env]
|
@@ -43,7 +43,7 @@ module Souls
|
|
43
43
|
raise(Thor::Error, e)
|
44
44
|
end
|
45
45
|
|
46
|
-
desc "
|
46
|
+
desc "migrate_reset", "Reset Database"
|
47
47
|
method_option :env, aliases: "--e", default: "development", desc: "Difine APP Enviroment - development | production"
|
48
48
|
def migrate_reset
|
49
49
|
case options[:env]
|
@@ -57,7 +57,7 @@ module Souls
|
|
57
57
|
raise(Thor::Error, e)
|
58
58
|
end
|
59
59
|
|
60
|
-
desc "
|
60
|
+
desc "create_migration [CLASS_NAME]", "Create ActiveRecord Migration File"
|
61
61
|
def create_migration(class_name)
|
62
62
|
pluralized_class_name = class_name.underscore.pluralize
|
63
63
|
system("rake db:create_migration NAME=create_#{pluralized_class_name}")
|
@@ -79,7 +79,7 @@ module Souls
|
|
79
79
|
raise(Thor::Error, e)
|
80
80
|
end
|
81
81
|
|
82
|
-
desc "
|
82
|
+
desc "add_column [CLASS_NAME]", "Create ActiveRecord Migration File"
|
83
83
|
def add_column(class_name)
|
84
84
|
pluralized_class_name = class_name.underscore.pluralize
|
85
85
|
system("rake db:create_migration NAME=add_column_to_#{pluralized_class_name}")
|
@@ -87,7 +87,7 @@ module Souls
|
|
87
87
|
raise(Thor::Error, e)
|
88
88
|
end
|
89
89
|
|
90
|
-
desc "
|
90
|
+
desc "rename_column [CLASS_NAME]", "Create ActiveRecord Migration File"
|
91
91
|
def rename_column(class_name)
|
92
92
|
pluralized_class_name = class_name.underscore.pluralize
|
93
93
|
system("rake db:create_migration NAME=rename_column_to_#{pluralized_class_name}")
|
@@ -95,7 +95,7 @@ module Souls
|
|
95
95
|
raise(Thor::Error, e)
|
96
96
|
end
|
97
97
|
|
98
|
-
desc "
|
98
|
+
desc "change_column [CLASS_NAME]", "Create ActiveRecord Migration File"
|
99
99
|
def change_column(class_name)
|
100
100
|
pluralized_class_name = class_name.underscore.pluralize
|
101
101
|
system("rake db:create_migration NAME=change_column_to_#{pluralized_class_name}")
|
@@ -103,7 +103,7 @@ module Souls
|
|
103
103
|
raise(Thor::Error, e)
|
104
104
|
end
|
105
105
|
|
106
|
-
desc "
|
106
|
+
desc "remove_column [CLASS_NAME]", "Create ActiveRecord Migration File"
|
107
107
|
def remove_column(class_name)
|
108
108
|
pluralized_class_name = class_name.underscore.pluralize
|
109
109
|
system("rake db:create_migration NAME=remove_column_to_#{pluralized_class_name}")
|
@@ -111,7 +111,7 @@ module Souls
|
|
111
111
|
raise(Thor::Error, e)
|
112
112
|
end
|
113
113
|
|
114
|
-
desc "
|
114
|
+
desc "drop_table [CLASS_NAME]", "Create ActiveRecord Migration File"
|
115
115
|
def drop_table(class_name)
|
116
116
|
pluralized_class_name = class_name.underscore.pluralize
|
117
117
|
system("rake db:create_migration NAME=drop_table_to_#{pluralized_class_name}")
|
@@ -1,41 +1,29 @@
|
|
1
1
|
module Souls
|
2
2
|
class Generate < Thor
|
3
3
|
desc "scaffold [CLASS_NAME]", "Generate Scaffold from schema.rb"
|
4
|
-
method_option :
|
4
|
+
method_option :rbs, type: :boolean, aliases: "--rbs", default: false, desc: "Generates Only RBS Files"
|
5
5
|
def scaffold(class_name)
|
6
6
|
singularized_class_name = class_name.singularize
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
query_rbs(singularized_class_name)
|
13
|
-
mutation(singularized_class_name)
|
14
|
-
mutation_rbs(singularized_class_name)
|
15
|
-
policy(singularized_class_name)
|
16
|
-
policy_rbs(singularized_class_name)
|
17
|
-
edge(singularized_class_name)
|
18
|
-
edge_rbs(singularized_class_name)
|
19
|
-
connection(singularized_class_name)
|
20
|
-
connection_rbs(singularized_class_name)
|
21
|
-
resolver(singularized_class_name)
|
22
|
-
resolver_rbs(singularized_class_name)
|
23
|
-
rspec_factory(singularized_class_name)
|
24
|
-
rspec_model(singularized_class_name)
|
25
|
-
rspec_mutation(singularized_class_name)
|
26
|
-
rspec_query(singularized_class_name)
|
27
|
-
rspec_resolver(singularized_class_name)
|
28
|
-
rspec_policy(singularized_class_name)
|
7
|
+
if options[:rbs]
|
8
|
+
run_scaffold(class_name: singularized_class_name)
|
9
|
+
else
|
10
|
+
run_rbs_scaffold(class_name: singularized_class_name)
|
11
|
+
end
|
29
12
|
true
|
30
13
|
rescue Thor::Error => e
|
31
14
|
raise(Thor::Error, e)
|
32
15
|
end
|
33
16
|
|
34
17
|
desc "scaffold_all", "Generate Scaffold All Tables from schema.rb"
|
18
|
+
method_option :rbs, type: :boolean, aliases: "--rbs", default: false, desc: "Generates Only RBS All Schema Files"
|
35
19
|
def scaffold_all
|
36
20
|
puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
|
37
21
|
Souls.get_tables.each do |table|
|
38
|
-
|
22
|
+
if options[:rbs]
|
23
|
+
Souls::Generate.new.invoke(:scaffold_all, [table.singularize], { rbs: options[:rbs] })
|
24
|
+
else
|
25
|
+
Souls::Generate.new.invoke(:scaffold_all, [table.singularize], {})
|
26
|
+
end
|
39
27
|
puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
|
40
28
|
end
|
41
29
|
true
|
@@ -69,6 +57,42 @@ module Souls
|
|
69
57
|
|
70
58
|
private
|
71
59
|
|
60
|
+
def run_scaffold(class_name: "user")
|
61
|
+
model(class_name: class_name)
|
62
|
+
model_rbs(class_name: class_name)
|
63
|
+
type(class_name: class_name)
|
64
|
+
type_rbs(class_name: class_name)
|
65
|
+
query(class_name: class_name)
|
66
|
+
query_rbs(class_name: class_name)
|
67
|
+
mutation(class_name: class_name)
|
68
|
+
mutation_rbs(class_name: class_name)
|
69
|
+
policy(class_name: class_name)
|
70
|
+
policy_rbs(class_name: class_name)
|
71
|
+
edge(class_name: class_name)
|
72
|
+
edge_rbs(class_name: class_name)
|
73
|
+
connection(class_name: class_name)
|
74
|
+
connection_rbs(class_name: class_name)
|
75
|
+
resolver(class_name: class_name)
|
76
|
+
resolver_rbs(class_name: class_name)
|
77
|
+
rspec_factory(class_name: class_name)
|
78
|
+
rspec_model(class_name: class_name)
|
79
|
+
rspec_mutation(class_name: class_name)
|
80
|
+
rspec_query(class_name: class_name)
|
81
|
+
rspec_resolver(class_name: class_name)
|
82
|
+
rspec_policy(class_name: class_name)
|
83
|
+
end
|
84
|
+
|
85
|
+
def run_rbs_scaffold(class_name: "user")
|
86
|
+
model_rbs(class_name: class_name)
|
87
|
+
type_rbs(class_name: class_name)
|
88
|
+
query_rbs(class_name: class_name)
|
89
|
+
mutation_rbs(class_name: class_name)
|
90
|
+
policy_rbs(class_name: class_name)
|
91
|
+
edge_rbs(class_name: class_name)
|
92
|
+
connection_rbs(class_name: class_name)
|
93
|
+
resolver_rbs(class_name: class_name)
|
94
|
+
end
|
95
|
+
|
72
96
|
def generated_paths(class_name: "user")
|
73
97
|
singularized_class_name = class_name.singularize.underscore
|
74
98
|
pluralized_class_name = class_name.pluralize.underscore
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_paths = []
|
2
|
-
dev_path = "lib/souls/
|
2
|
+
dev_path = "lib/souls/cli/generate/*"
|
3
3
|
souls_path = Dir["#{Gem.dir}/gems/souls-*"].last
|
4
|
-
gem_path = "#{souls_path}/lib/souls/
|
4
|
+
gem_path = "#{souls_path}/lib/souls/cli/generate/*"
|
5
5
|
file_paths = File.exist?("souls.gemspec") ? dev_path : gem_path
|
6
6
|
Dir[file_paths].map do |n|
|
7
7
|
next if n.include?("index.rb")
|
@@ -11,3 +11,8 @@ end
|
|
11
11
|
require_paths.each do |path|
|
12
12
|
require_relative "./#{path}"
|
13
13
|
end
|
14
|
+
|
15
|
+
module Souls
|
16
|
+
class Generate < Thor
|
17
|
+
end
|
18
|
+
end
|
@@ -6,16 +6,17 @@ module Souls
|
|
6
6
|
if options[:mailer]
|
7
7
|
mailgun_mailer(class_name: class_name)
|
8
8
|
else
|
9
|
-
|
9
|
+
create_job_mutation(class_name: class_name)
|
10
10
|
end
|
11
11
|
Souls::Generate.new.invoke(:job_rbs, [class_name], {})
|
12
|
+
Souls::Generate.new.invoke(:rspec_job, [class_name], {})
|
12
13
|
rescue Thor::Error => e
|
13
14
|
raise(Thor::Error, e)
|
14
15
|
end
|
15
16
|
|
16
17
|
private
|
17
18
|
|
18
|
-
def
|
19
|
+
def create_job_mutation(class_name: "send-mailer")
|
19
20
|
file_dir = "./app/graphql/mutations/"
|
20
21
|
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
21
22
|
file_path = "#{file_dir}#{class_name.singularize}.rb"
|
File without changes
|
@@ -16,14 +16,15 @@ module Souls
|
|
16
16
|
class #{options[:mutation].underscore.camelize} < BaseMutation
|
17
17
|
description "#{options[:mutation]} description"
|
18
18
|
## Edit `argument` and `field`
|
19
|
-
argument :
|
19
|
+
argument :argument, String, required: true
|
20
20
|
|
21
21
|
field :response, String, null: false
|
22
22
|
|
23
23
|
def resolve(args)
|
24
24
|
# Define Here
|
25
|
+
{ response: "success!" }
|
25
26
|
rescue StandardError => e
|
26
|
-
GraphQL::ExecutionError.new(e.
|
27
|
+
GraphQL::ExecutionError.new(e.message)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -32,6 +33,7 @@ module Souls
|
|
32
33
|
end
|
33
34
|
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
34
35
|
Souls::Generate.new.invoke(:manager_rbs, [singularized_class_name], { mutation: options[:mutation] })
|
36
|
+
Souls::Generate.new.invoke(:rspec_manager, [singularized_class_name], { mutation: options[:mutation] })
|
35
37
|
file_path
|
36
38
|
rescue Thor::Error => e
|
37
39
|
raise(Thor::Error, e)
|
File without changes
|
File without changes
|
File without changes
|
@@ -8,10 +8,7 @@ module Souls
|
|
8
8
|
file_path = "./app/graphql/mutations/base/#{singularized_class_name}/create_#{singularized_class_name}.rb"
|
9
9
|
return "Mutation already exist! #{file_path}" if File.exist?(file_path)
|
10
10
|
|
11
|
-
|
12
|
-
relation_params = create_mutation_params(class_name: singularized_class_name)
|
13
|
-
create_mutation_after_params(class_name: singularized_class_name, relation_params: relation_params)
|
14
|
-
create_mutation_end(class_name: singularized_class_name)
|
11
|
+
create_mutation(class_name: singularized_class_name)
|
15
12
|
update_mutation(class_name: singularized_class_name)
|
16
13
|
delete_mutation(class_name: singularized_class_name)
|
17
14
|
destroy_delete_mutation(class_name: singularized_class_name)
|
@@ -23,103 +20,58 @@ module Souls
|
|
23
20
|
|
24
21
|
private
|
25
22
|
|
26
|
-
def
|
23
|
+
def create_mutation(class_name: "user")
|
24
|
+
file_path = ""
|
27
25
|
singularized_class_name = class_name.singularize.underscore
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
File.open(path, "r") do |f|
|
52
|
-
f.each_line.with_index do |line, _i|
|
53
|
-
if @on
|
54
|
-
if line.include?("t.index") || line.strip == "end"
|
55
|
-
if @user_exist
|
56
|
-
new_line.write(<<-TEXT)
|
57
|
-
|
58
|
-
def resolve(args)
|
59
|
-
params = args.dup
|
60
|
-
params[:user_id] = context[:user][:id]
|
61
|
-
data = ::#{class_name.camelize}.new(args)
|
62
|
-
TEXT
|
63
|
-
else
|
64
|
-
new_line.write(<<-TEXT)
|
26
|
+
Dir.chdir(Souls.get_mother_path.to_s) do
|
27
|
+
file_dir = "./app/graphql/mutations/base/#{singularized_class_name}"
|
28
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
29
|
+
file_path = "#{file_dir}/create_#{singularized_class_name}.rb"
|
30
|
+
raise(Thor::Error, "Mutation RBS already exist! #{file_path}") if File.exist?(file_path)
|
31
|
+
|
32
|
+
params = Souls.get_relation_params(class_name: singularized_class_name, col: "mutation")
|
33
|
+
File.open(file_path, "w") do |f|
|
34
|
+
f.write(<<~TEXT)
|
35
|
+
module Mutations
|
36
|
+
module Base::#{singularized_class_name.camelize}
|
37
|
+
class Create#{singularized_class_name.camelize} < BaseMutation
|
38
|
+
field :#{singularized_class_name}_edge, Types::#{singularized_class_name.camelize}Type.edge_type, null: false
|
39
|
+
field :error, String, null: true
|
40
|
+
#{' '}
|
41
|
+
def resolve(args)
|
42
|
+
TEXT
|
43
|
+
end
|
44
|
+
File.open(file_path, "a") do |f|
|
45
|
+
if params[:relation_params]
|
46
|
+
f.write(" user_id = context[:user][:id]\n") if params[:user_exist]
|
47
|
+
params[:relation_params].each_with_index do |col, _i|
|
48
|
+
next if col[:column_name] == "user_id"
|
65
49
|
|
66
|
-
|
67
|
-
params = args.dup
|
68
|
-
data = ::#{class_name.camelize}.new(args)
|
69
|
-
TEXT
|
70
|
-
end
|
71
|
-
break
|
72
|
-
end
|
73
|
-
field = "[String]" if line.include?("array: true")
|
74
|
-
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
75
|
-
field ||= Souls.type_check(type)
|
76
|
-
case name
|
77
|
-
when "user_id"
|
78
|
-
@user_exist = true
|
79
|
-
when /$*_id\z/
|
80
|
-
@relation_params << name
|
81
|
-
new_line.write(" argument :#{name}, String, required: false\n")
|
82
|
-
when "created_at", "updated_at"
|
83
|
-
next
|
84
|
-
else
|
85
|
-
new_line.write(" argument :#{name}, #{field}, required: false\n")
|
86
|
-
end
|
50
|
+
f.write(" #{col[:column_name]} = SoulsApiSchema.from_global_id(args[:#{col[:column_name]}])\n")
|
87
51
|
end
|
88
|
-
|
52
|
+
relation_params =
|
53
|
+
params[:relation_params].map do |n|
|
54
|
+
", #{n[:column_name]}: #{n[:column_name]}"
|
55
|
+
end
|
56
|
+
f.write(" new_record = { **args #{relation_params.compact.join} }\n")
|
57
|
+
f.write(" data = ::#{singularized_class_name.camelize}.new(new_record)\n")
|
58
|
+
else
|
59
|
+
f.write(" data = ::#{singularized_class_name.camelize}.new(args)\n")
|
89
60
|
end
|
90
61
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
def create_mutation_after_params(class_name: "user", relation_params: [])
|
96
|
-
return false if relation_params.empty?
|
97
|
-
|
98
|
-
file_path = "./app/graphql/mutations/base/#{class_name}/create_#{class_name}.rb"
|
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")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
true
|
107
|
-
end
|
108
|
-
|
109
|
-
def create_mutation_end(class_name: "user")
|
110
|
-
file_path = "./app/graphql/mutations/base/#{class_name}/create_#{class_name}.rb"
|
111
|
-
File.open(file_path, "a") do |new_line|
|
112
|
-
new_line.write(<<~TEXT)
|
113
|
-
raise(StandardError, data.errors.full_messages) unless data.save
|
62
|
+
File.open(file_path, "a") do |new_line|
|
63
|
+
new_line.write(<<~TEXT)
|
64
|
+
raise(StandardError, data.errors.full_messages) unless data.save
|
114
65
|
|
115
|
-
|
116
|
-
|
117
|
-
|
66
|
+
{ #{singularized_class_name}_edge: { node: data } }
|
67
|
+
rescue StandardError => error
|
68
|
+
GraphQL::ExecutionError.new(error.message)
|
69
|
+
end
|
118
70
|
end
|
119
71
|
end
|
120
72
|
end
|
121
|
-
|
122
|
-
|
73
|
+
TEXT
|
74
|
+
end
|
123
75
|
end
|
124
76
|
file_path
|
125
77
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Souls
|
2
|
+
class Generate < Thor
|
3
|
+
desc "rspec_job [CLASS_NAME]", "Generate Rspec Job Test Template"
|
4
|
+
def rspec_job(class_name)
|
5
|
+
singularized_class_name = class_name.underscore.singularize
|
6
|
+
file_dir = "./spec/mutations/jobs/"
|
7
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
8
|
+
file_path = "#{file_dir}/#{singularized_class_name}_spec.rb"
|
9
|
+
return "RspecJob already exist! #{file_path}" if File.exist?(file_path)
|
10
|
+
|
11
|
+
File.open(file_path, "w") do |f|
|
12
|
+
f.write(<<~TEXT)
|
13
|
+
RSpec.describe("#{class_name.singularize.camelize}") do
|
14
|
+
describe "Define #{class_name.singularize.camelize}" do
|
15
|
+
|
16
|
+
let(:mutation) do
|
17
|
+
%(mutation {
|
18
|
+
#{class_name.singularize.camelize(:lower)}(input: {}) {
|
19
|
+
response
|
20
|
+
}
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
subject(:result) do
|
26
|
+
SoulsApiSchema.execute(mutation).as_json
|
27
|
+
end
|
28
|
+
|
29
|
+
it "return StockSheet Data" do
|
30
|
+
begin
|
31
|
+
a1 = result.dig("data", "#{options[:mutation].singularize.camelize(:lower)}", "response")
|
32
|
+
raise unless a1.present?
|
33
|
+
rescue StandardError
|
34
|
+
raise(StandardError, result)
|
35
|
+
end
|
36
|
+
expect(a1).to(include("response" => be_a(String)))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
TEXT
|
41
|
+
end
|
42
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
43
|
+
file_path
|
44
|
+
rescue Thor::Error => e
|
45
|
+
raise(Thor::Error, e)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Souls
|
2
|
+
class Generate < Thor
|
3
|
+
desc "rspec_manager [CLASS_NAME]", "Generate Rspec Manager Test Template"
|
4
|
+
method_option :mutation, aliases: "--mutation", required: true, desc: "Mutation File Name"
|
5
|
+
def rspec_manager(class_name)
|
6
|
+
singularized_class_name = class_name.underscore.singularize
|
7
|
+
file_dir = "./spec/managers/"
|
8
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
9
|
+
file_path = "./spec/mutations/managers/#{singularized_class_name}/#{options[:mutation]}_spec.rb"
|
10
|
+
return "RspecManager already exist! #{file_path}" if File.exist?(file_path)
|
11
|
+
|
12
|
+
File.open(file_path, "w") do |f|
|
13
|
+
f.write(<<~TEXT)
|
14
|
+
RSpec.describe("#{options[:mutation].singularize.camelize}") do
|
15
|
+
describe "Define #{options[:mutation].singularize.camelize}" do
|
16
|
+
|
17
|
+
let(:mutation) do
|
18
|
+
%(mutation {
|
19
|
+
#{options[:mutation].singularize.camelize(:lower)}(input: {}) {
|
20
|
+
response
|
21
|
+
}
|
22
|
+
}
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
subject(:result) do
|
27
|
+
SoulsApiSchema.execute(mutation).as_json
|
28
|
+
end
|
29
|
+
|
30
|
+
it "return StockSheet Data" do
|
31
|
+
begin
|
32
|
+
a1 = result.dig("data", "#{options[:mutation].singularize.camelize(:lower)}", "response")
|
33
|
+
raise unless a1.present?
|
34
|
+
rescue StandardError
|
35
|
+
raise(StandardError, result)
|
36
|
+
end
|
37
|
+
expect(a1).to(include("response" => be_a(String)))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
TEXT
|
42
|
+
end
|
43
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
44
|
+
file_path
|
45
|
+
rescue Thor::Error => e
|
46
|
+
raise(Thor::Error, e)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/souls/cli/index.rb
CHANGED
data/lib/souls/cli/init/index.rb
CHANGED
@@ -18,7 +18,7 @@ module Souls
|
|
18
18
|
souls_api_credit(app_name: app_name, service_name: service_name)
|
19
19
|
end
|
20
20
|
|
21
|
-
desc "
|
21
|
+
desc "add_submodule", "Run git submodule add RBS collection"
|
22
22
|
def add_submodule
|
23
23
|
system("git submodule add https://github.com/ruby/gem_rbs_collection.git vendor/rbs/gem_rbs_collection")
|
24
24
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/souls/cli.rb
CHANGED
@@ -1,40 +1,34 @@
|
|
1
1
|
require "souls"
|
2
2
|
module Souls
|
3
3
|
class CLI < Thor
|
4
|
-
desc "
|
5
|
-
subcommand "
|
4
|
+
desc "generate [COMMAND]", "SOULs Generate Commands"
|
5
|
+
subcommand "generate", Generate
|
6
6
|
|
7
|
-
desc "
|
8
|
-
subcommand "
|
7
|
+
desc "update [COMMAND]", "SOULs Update Commands"
|
8
|
+
subcommand "update", Update
|
9
|
+
|
10
|
+
desc "create [COMMAND]", "SOULs Create Worker"
|
11
|
+
subcommand "create", Create
|
12
|
+
|
13
|
+
desc "db [COMMAND]", "SOULs DB Commands"
|
14
|
+
subcommand "db", DB
|
9
15
|
|
10
16
|
desc "docker [COMMAND]", "SOULs Docker Commands"
|
11
17
|
subcommand "docker", Docker
|
12
18
|
|
13
|
-
desc "
|
14
|
-
subcommand "
|
19
|
+
desc "gcloud [COMMAND]", "SOULs Gcloud Commands"
|
20
|
+
subcommand "gcloud", Gcloud
|
15
21
|
|
16
22
|
desc "sync", " SOULs Sync Commands"
|
17
23
|
subcommand "sync", Sync
|
18
24
|
|
19
|
-
desc "upgrade", "SOULs Upgrade
|
25
|
+
desc "upgrade gemfile", "SOULs Upgrade Gemfile & Gemfile.lock"
|
20
26
|
subcommand "upgrade", Upgrade
|
21
27
|
|
22
|
-
desc "worker [COMMAND]", "SOULs Worker Commands"
|
23
|
-
subcommand "worker", Worker
|
24
|
-
|
25
28
|
# rubocop:disable Style/StringHashKeys
|
26
29
|
map "c" => :console
|
27
30
|
map "s" => :server
|
28
|
-
map "
|
29
|
-
map "db:migrate" => :migrate
|
30
|
-
map "db:create_migration" => :create_migration
|
31
|
-
map "db:add_column" => :add_column
|
32
|
-
map "db:rename_column" => :rename_column
|
33
|
-
map "db:change_column" => :change_column
|
34
|
-
map "db:remove_column" => :remove_column
|
35
|
-
map "db:drop_table" => :drop_table
|
36
|
-
map "db:create" => :db_create
|
37
|
-
map "db:seed" => :seed
|
31
|
+
map "g" => :generate
|
38
32
|
map "t" => :test
|
39
33
|
map ["-v", "--v", "--version", "-version"] => :version
|
40
34
|
# rubocop:enable Style/StringHashKeys
|
data/lib/souls/index.rb
CHANGED
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.40.0
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.40.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.
|
4
|
+
version: 0.61.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-
|
13
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -127,40 +127,6 @@ files:
|
|
127
127
|
- README.md
|
128
128
|
- exe/souls
|
129
129
|
- lib/souls.rb
|
130
|
-
- lib/souls/api/generate/application.rb
|
131
|
-
- lib/souls/api/generate/connection.rb
|
132
|
-
- lib/souls/api/generate/connection_rbs.rb
|
133
|
-
- lib/souls/api/generate/edge.rb
|
134
|
-
- lib/souls/api/generate/edge_rbs.rb
|
135
|
-
- lib/souls/api/generate/index.rb
|
136
|
-
- lib/souls/api/generate/manager.rb
|
137
|
-
- lib/souls/api/generate/manager_rbs.rb
|
138
|
-
- lib/souls/api/generate/model.rb
|
139
|
-
- lib/souls/api/generate/model_rbs.rb
|
140
|
-
- lib/souls/api/generate/mutation.rb
|
141
|
-
- lib/souls/api/generate/mutation_rbs.rb
|
142
|
-
- lib/souls/api/generate/policy.rb
|
143
|
-
- lib/souls/api/generate/policy_rbs.rb
|
144
|
-
- lib/souls/api/generate/query.rb
|
145
|
-
- lib/souls/api/generate/query_rbs.rb
|
146
|
-
- lib/souls/api/generate/resolver.rb
|
147
|
-
- lib/souls/api/generate/resolver_rbs.rb
|
148
|
-
- lib/souls/api/generate/rspec_factory.rb
|
149
|
-
- lib/souls/api/generate/rspec_model.rb
|
150
|
-
- lib/souls/api/generate/rspec_mutation.rb
|
151
|
-
- lib/souls/api/generate/rspec_policy.rb
|
152
|
-
- lib/souls/api/generate/rspec_query.rb
|
153
|
-
- lib/souls/api/generate/rspec_resolver.rb
|
154
|
-
- lib/souls/api/generate/type.rb
|
155
|
-
- lib/souls/api/generate/type_rbs.rb
|
156
|
-
- lib/souls/api/index.rb
|
157
|
-
- lib/souls/api/update/index.rb
|
158
|
-
- lib/souls/api/update/mutation.rb
|
159
|
-
- lib/souls/api/update/resolver.rb
|
160
|
-
- lib/souls/api/update/rspec_factory.rb
|
161
|
-
- lib/souls/api/update/rspec_mutation.rb
|
162
|
-
- lib/souls/api/update/rspec_resolver.rb
|
163
|
-
- lib/souls/api/update/type.rb
|
164
130
|
- lib/souls/cli.rb
|
165
131
|
- lib/souls/cli/console/index.rb
|
166
132
|
- lib/souls/cli/create/index.rb
|
@@ -174,6 +140,36 @@ files:
|
|
174
140
|
- lib/souls/cli/gcloud/pubsub/topics.rb
|
175
141
|
- lib/souls/cli/gcloud/run/index.rb
|
176
142
|
- lib/souls/cli/gcloud/sql/index.rb
|
143
|
+
- lib/souls/cli/generate/application.rb
|
144
|
+
- lib/souls/cli/generate/connection.rb
|
145
|
+
- lib/souls/cli/generate/connection_rbs.rb
|
146
|
+
- lib/souls/cli/generate/edge.rb
|
147
|
+
- lib/souls/cli/generate/edge_rbs.rb
|
148
|
+
- lib/souls/cli/generate/index.rb
|
149
|
+
- lib/souls/cli/generate/job.rb
|
150
|
+
- lib/souls/cli/generate/job_rbs.rb
|
151
|
+
- lib/souls/cli/generate/manager.rb
|
152
|
+
- lib/souls/cli/generate/manager_rbs.rb
|
153
|
+
- lib/souls/cli/generate/model.rb
|
154
|
+
- lib/souls/cli/generate/model_rbs.rb
|
155
|
+
- lib/souls/cli/generate/mutation.rb
|
156
|
+
- lib/souls/cli/generate/mutation_rbs.rb
|
157
|
+
- lib/souls/cli/generate/policy.rb
|
158
|
+
- lib/souls/cli/generate/policy_rbs.rb
|
159
|
+
- lib/souls/cli/generate/query.rb
|
160
|
+
- lib/souls/cli/generate/query_rbs.rb
|
161
|
+
- lib/souls/cli/generate/resolver.rb
|
162
|
+
- lib/souls/cli/generate/resolver_rbs.rb
|
163
|
+
- lib/souls/cli/generate/rspec_factory.rb
|
164
|
+
- lib/souls/cli/generate/rspec_job.rb
|
165
|
+
- lib/souls/cli/generate/rspec_manager.rb
|
166
|
+
- lib/souls/cli/generate/rspec_model.rb
|
167
|
+
- lib/souls/cli/generate/rspec_mutation.rb
|
168
|
+
- lib/souls/cli/generate/rspec_policy.rb
|
169
|
+
- lib/souls/cli/generate/rspec_query.rb
|
170
|
+
- lib/souls/cli/generate/rspec_resolver.rb
|
171
|
+
- lib/souls/cli/generate/type.rb
|
172
|
+
- lib/souls/cli/generate/type_rbs.rb
|
177
173
|
- lib/souls/cli/index.rb
|
178
174
|
- lib/souls/cli/init/index.rb
|
179
175
|
- lib/souls/cli/release/index.rb
|
@@ -183,6 +179,13 @@ files:
|
|
183
179
|
- lib/souls/cli/sync/index.rb
|
184
180
|
- lib/souls/cli/sync/model.rb
|
185
181
|
- lib/souls/cli/sync/pubsub.rb
|
182
|
+
- lib/souls/cli/update/index.rb
|
183
|
+
- lib/souls/cli/update/mutation.rb
|
184
|
+
- lib/souls/cli/update/resolver.rb
|
185
|
+
- lib/souls/cli/update/rspec_factory.rb
|
186
|
+
- lib/souls/cli/update/rspec_mutation.rb
|
187
|
+
- lib/souls/cli/update/rspec_resolver.rb
|
188
|
+
- lib/souls/cli/update/type.rb
|
186
189
|
- lib/souls/cli/upgrade/gemfile.rb
|
187
190
|
- lib/souls/cli/upgrade/index.rb
|
188
191
|
- lib/souls/index.rb
|
@@ -190,10 +193,6 @@ files:
|
|
190
193
|
- lib/souls/version.rb
|
191
194
|
- lib/souls/versions/.souls_api_version
|
192
195
|
- lib/souls/versions/.souls_worker_version
|
193
|
-
- lib/souls/worker/generate/index.rb
|
194
|
-
- lib/souls/worker/generate/job.rb
|
195
|
-
- lib/souls/worker/generate/job_rbs.rb
|
196
|
-
- lib/souls/worker/index.rb
|
197
196
|
homepage: https://souls.elsoul.nl
|
198
197
|
licenses:
|
199
198
|
- Apache-2.0
|
data/lib/souls/api/index.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require_relative "./generate/index"
|
2
|
-
require_relative "./update/index"
|
3
|
-
module Souls
|
4
|
-
class API < Thor
|
5
|
-
desc "generate [COMMAND]", "souls api generate Commands"
|
6
|
-
subcommand "generate", Generate
|
7
|
-
|
8
|
-
desc "update [COMMAND]", "souls api update Commands"
|
9
|
-
subcommand "update", Update
|
10
|
-
# rubocop:disable Style/StringHashKeys
|
11
|
-
map "g" => :generate
|
12
|
-
# rubocop:enable Style/StringHashKeys
|
13
|
-
end
|
14
|
-
end
|
data/lib/souls/worker/index.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require_relative "./generate/index"
|
2
|
-
|
3
|
-
module Souls
|
4
|
-
class Worker < Thor
|
5
|
-
desc "generate [COMMAND]", "souls worker generate Commands"
|
6
|
-
subcommand "generate", Generate
|
7
|
-
|
8
|
-
# rubocop:disable Style/StringHashKeys
|
9
|
-
map "g" => :generate
|
10
|
-
# rubocop:enable Style/StringHashKeys
|
11
|
-
end
|
12
|
-
end
|