souls 0.51.1 → 0.52.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 +4 -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,81 +1,81 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
9
|
-
File.open(file_path, "w") do |f|
|
10
|
-
f.write(<<~TEXT)
|
11
|
-
module Types
|
12
|
-
class #{class_name.camelize}Type < BaseObject
|
13
|
-
implements GraphQL::Types::Relay::Node
|
2
|
+
class Generate < Thor
|
3
|
+
desc "type [CLASS_NAME]", "Generate GraphQL Type from schema.rb"
|
4
|
+
def type(class_name)
|
5
|
+
singularized_class_name = class_name.singularize
|
6
|
+
file_path = "./app/graphql/types/#{singularized_class_name}_type.rb"
|
7
|
+
return "Type already exist! #{file_path}" if File.exist?(file_path)
|
14
8
|
|
15
|
-
|
16
|
-
|
9
|
+
create_type_head(class_name: singularized_class_name)
|
10
|
+
create_type_params(class_name: singularized_class_name)
|
11
|
+
create_type_end(class_name: singularized_class_name)
|
12
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
13
|
+
file_path
|
14
|
+
rescue Thor::Error => e
|
15
|
+
raise(Thor::Error, e)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def create_type_head(class_name: "user")
|
21
|
+
file_dir = "./app/graphql/types/"
|
22
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
23
|
+
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
24
|
+
File.open(file_path, "w") do |f|
|
25
|
+
f.write(<<~TEXT)
|
26
|
+
module Types
|
27
|
+
class #{class_name.camelize}Type < BaseObject
|
28
|
+
implements GraphQL::Types::Relay::Node
|
29
|
+
|
30
|
+
TEXT
|
17
31
|
end
|
32
|
+
end
|
18
33
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
46
|
-
if Souls.table_check(line: line, class_name: class_name)
|
47
|
-
@on = true
|
48
|
-
new_line.write(" global_id_field :id\n")
|
34
|
+
def create_type_params(class_name: "user")
|
35
|
+
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
36
|
+
path = "./db/schema.rb"
|
37
|
+
@on = false
|
38
|
+
File.open(file_path, "a") do |new_line|
|
39
|
+
File.open(path, "r") do |f|
|
40
|
+
f.each_line.with_index do |line, _i|
|
41
|
+
if @on
|
42
|
+
new_line.write("\n" && break) if line.include?("t.index") || line.strip == "end"
|
43
|
+
field = "[String]" if line.include?("array: true")
|
44
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
45
|
+
field ||= Souls.type_check(type)
|
46
|
+
case name
|
47
|
+
when /$*_id\z/
|
48
|
+
new_line.write(
|
49
|
+
" field :#{name.gsub(
|
50
|
+
'_id',
|
51
|
+
''
|
52
|
+
)}, Types::#{name.gsub(
|
53
|
+
'_id',
|
54
|
+
''
|
55
|
+
).singularize.camelize}Type, null: false\n"
|
56
|
+
)
|
57
|
+
else
|
58
|
+
new_line.write(" field :#{name}, #{field}, null: true\n")
|
49
59
|
end
|
50
60
|
end
|
61
|
+
if Souls.table_check(line: line, class_name: class_name)
|
62
|
+
@on = true
|
63
|
+
new_line.write(" global_id_field :id\n")
|
64
|
+
end
|
51
65
|
end
|
52
66
|
end
|
53
67
|
end
|
68
|
+
end
|
54
69
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
70
|
+
def create_type_end(class_name: "user")
|
71
|
+
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
72
|
+
File.open(file_path, "a") do |f|
|
73
|
+
f.write(<<~TEXT)
|
60
74
|
end
|
61
|
-
|
62
|
-
|
63
|
-
file_path
|
64
|
-
end
|
65
|
-
|
66
|
-
def type(class_name: "user")
|
67
|
-
singularized_class_name = class_name.singularize
|
68
|
-
file_path = "./app/graphql/types/#{singularized_class_name}_type.rb"
|
69
|
-
return "Type already exist! #{file_path}" if File.exist?(file_path)
|
70
|
-
|
71
|
-
create_type_head(class_name: singularized_class_name)
|
72
|
-
create_type_params(class_name: singularized_class_name)
|
73
|
-
create_type_end(class_name: singularized_class_name)
|
74
|
-
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
75
|
-
file_path
|
76
|
-
rescue StandardError => e
|
77
|
-
raise(StandardError, e)
|
75
|
+
end
|
76
|
+
TEXT
|
78
77
|
end
|
78
|
+
file_path
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
data/lib/souls/api/index.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require_relative "./generate/index"
|
2
2
|
require_relative "./update/index"
|
3
|
-
|
4
3
|
module Souls
|
5
|
-
|
6
|
-
|
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
|
7
10
|
|
8
|
-
|
11
|
+
map "g" => :generate
|
9
12
|
end
|
10
13
|
end
|
@@ -4,3 +4,18 @@ require_relative "./type"
|
|
4
4
|
require_relative "./rspec_factory"
|
5
5
|
require_relative "./rspec_mutation"
|
6
6
|
require_relative "./rspec_resolver"
|
7
|
+
|
8
|
+
module Souls
|
9
|
+
class Update < Thor
|
10
|
+
desc "scaffold [CLASS_NAME]", "Update Scaffold Params"
|
11
|
+
def scaffold(_class_name)
|
12
|
+
invoke(:create_mutation)
|
13
|
+
invoke(:update_mutation)
|
14
|
+
invoke(:resolver)
|
15
|
+
invoke(:type)
|
16
|
+
invoke(:rspec_factory)
|
17
|
+
invoke(:rspec_mutation)
|
18
|
+
invoke(:rspec_resolver)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,82 +1,86 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
next unless line.include?("argument") && !argument
|
2
|
+
class Update < Thor
|
3
|
+
desc "create_mutation [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
4
|
+
def create_mutation(class_name)
|
5
|
+
singularized_class_name = class_name.singularize.underscore
|
6
|
+
new_cols = Souls.get_columns_num(class_name: singularized_class_name)
|
7
|
+
dir_name = "./app/graphql/mutations/base/#{singularized_class_name}"
|
8
|
+
new_file_path = "tmp/create_mutation.rb"
|
9
|
+
file_path = "#{dir_name}/create_#{singularized_class_name}.rb"
|
10
|
+
argument = false
|
11
|
+
File.open(file_path) do |f|
|
12
|
+
File.open(new_file_path, "w") do |new_line|
|
13
|
+
f.each_line do |line|
|
14
|
+
new_line.write(line)
|
15
|
+
next unless line.include?("argument") && !argument
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
new_cols.each do |col|
|
18
|
+
type = Souls.type_check(col[:type])
|
19
|
+
type = "[#{type}]" if col[:array]
|
20
|
+
args = check_mutation_argument(class_name: class_name)
|
21
|
+
next if args.include?(col[:column_name])
|
22
|
+
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
24
23
|
|
25
|
-
|
26
|
-
end
|
27
|
-
argument = true
|
28
|
-
end
|
24
|
+
new_line.write(" argument :#{col[:column_name]}, #{type}, required: false\n")
|
29
25
|
end
|
26
|
+
argument = true
|
30
27
|
end
|
31
|
-
FileUtils.rm(file_path)
|
32
|
-
FileUtils.mv(new_file_path, file_path)
|
33
|
-
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
34
28
|
end
|
29
|
+
end
|
30
|
+
FileUtils.rm(file_path)
|
31
|
+
FileUtils.mv(new_file_path, file_path)
|
32
|
+
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
33
|
+
rescue Thor::Error => e
|
34
|
+
raise(Thor::Error, e)
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
desc "update_mutation [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
38
|
+
def update_mutation(class_name)
|
39
|
+
singularized_class_name = class_name.singularize.underscore
|
40
|
+
new_cols = Souls.get_columns_num(class_name: singularized_class_name)
|
41
|
+
dir_name = "./app/graphql/mutations/base/#{singularized_class_name}"
|
42
|
+
new_file_path = "tmp/update_mutation.rb"
|
43
|
+
file_path = "#{dir_name}/update_#{singularized_class_name}.rb"
|
44
|
+
argument = false
|
45
|
+
File.open(file_path) do |f|
|
46
|
+
File.open(new_file_path, "w") do |new_line|
|
47
|
+
f.each_line do |line|
|
48
|
+
new_line.write(line)
|
49
|
+
next unless line.include?("argument") && !argument
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
new_cols.each do |col|
|
52
|
+
type = Souls.type_check(col[:type])
|
53
|
+
type = "[#{type}]" if col[:array]
|
54
|
+
args = check_mutation_argument(class_name: class_name, action: "update")
|
55
|
+
next if args.include?(col[:column_name])
|
56
|
+
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
55
57
|
|
56
|
-
|
57
|
-
end
|
58
|
-
argument = true
|
59
|
-
end
|
58
|
+
new_line.write(" argument :#{col[:column_name]}, #{type}, required: false\n")
|
60
59
|
end
|
60
|
+
argument = true
|
61
61
|
end
|
62
|
-
FileUtils.rm(file_path)
|
63
|
-
FileUtils.mv(new_file_path, file_path)
|
64
|
-
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
65
62
|
end
|
63
|
+
end
|
64
|
+
FileUtils.rm(file_path)
|
65
|
+
FileUtils.mv(new_file_path, file_path)
|
66
|
+
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
67
|
+
rescue Thor::Error => e
|
68
|
+
raise(Thor::Error, e)
|
69
|
+
end
|
66
70
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
args
|
71
|
+
private
|
72
|
+
|
73
|
+
def check_mutation_argument(class_name: "user", action: "create")
|
74
|
+
singularized_class_name = class_name.singularize.underscore
|
75
|
+
dir_name = "./app/graphql/mutations/base/#{singularized_class_name}"
|
76
|
+
file_path = "#{dir_name}/#{action}_#{singularized_class_name}.rb"
|
77
|
+
args = []
|
78
|
+
File.open(file_path) do |f|
|
79
|
+
f.each_line do |line|
|
80
|
+
args << line.split(",")[0].gsub("argument :", "").strip.underscore if line.include?("argument")
|
78
81
|
end
|
79
82
|
end
|
83
|
+
args
|
80
84
|
end
|
81
85
|
end
|
82
86
|
end
|
@@ -1,74 +1,73 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
type = "[#{type}]" if col[:array]
|
2
|
+
class Update < Thor
|
3
|
+
desc "resolver [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
4
|
+
def resolver(class_name)
|
5
|
+
singularized_class_name = class_name.singularize.underscore
|
6
|
+
new_cols = Souls.get_columns_num(class_name: singularized_class_name)
|
7
|
+
dir_name = "./app/graphql/resolvers"
|
8
|
+
new_file_path = "tmp/update_resolver.rb"
|
9
|
+
file_path = "#{dir_name}/#{singularized_class_name}_search.rb"
|
10
|
+
args = check_resolver_argument(class_name: class_name)
|
11
|
+
scope_args = check_resolver_argument(class_name: class_name, action: "scope")
|
12
|
+
argument = false
|
13
|
+
scope = 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
|
+
new_line.write(line)
|
18
|
+
if line.include?("argument") && !argument
|
19
|
+
new_cols.each do |col|
|
20
|
+
type = Souls.type_check(col[:type])
|
21
|
+
type = "[#{type}]" if col[:array]
|
22
|
+
add_line = " argument :#{col[:column_name]}, #{type}, required: false\n"
|
23
|
+
new_line.write(add_line) unless args.include?(col[:column_name])
|
24
|
+
end
|
25
|
+
argument = true
|
26
|
+
elsif line.include?("scope = ::") && !scope
|
27
|
+
new_cols.each do |col|
|
28
|
+
type = Souls.type_check(col[:type])
|
29
|
+
type = "[#{type}]" if col[:array]
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
new_line.write(add_line) unless scope_args.include?(col[:column_name])
|
38
|
-
end
|
39
|
-
scope = true
|
31
|
+
if type.include?("[")
|
32
|
+
add_line = " scope = scope.where('#{col[:column_name]} @> ARRAY[?]::#{col[:type]}[]', value[:#{col[:column_name]}]) if value[:#{col[:column_name]}]\n"
|
33
|
+
else
|
34
|
+
add_line = " scope = scope.where(#{col[:column_name]}: value[:#{col[:column_name]}]) if value[:#{col[:column_name]}]\n"
|
40
35
|
end
|
36
|
+
new_line.write(add_line) unless scope_args.include?(col[:column_name])
|
41
37
|
end
|
38
|
+
scope = true
|
42
39
|
end
|
43
40
|
end
|
44
|
-
FileUtils.rm(file_path)
|
45
|
-
FileUtils.mv(new_file_path, file_path)
|
46
|
-
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
47
|
-
rescue StandardError => e
|
48
|
-
p(e)
|
49
41
|
end
|
42
|
+
end
|
43
|
+
FileUtils.rm(file_path)
|
44
|
+
FileUtils.mv(new_file_path, file_path)
|
45
|
+
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
46
|
+
rescue Thor::Error => e
|
47
|
+
raise(Thor::Error, e)
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
50
|
+
private
|
51
|
+
|
52
|
+
def check_resolver_argument(class_name: "user", action: "argument")
|
53
|
+
singularized_class_name = class_name.singularize.underscore
|
54
|
+
dir_name = "./app/graphql/resolvers"
|
55
|
+
file_path = "#{dir_name}/#{singularized_class_name}_search.rb"
|
56
|
+
args = []
|
57
|
+
File.open(file_path) do |f|
|
58
|
+
f.each_line do |line|
|
59
|
+
if action == "scope" && line.include?("scope = scope.where")
|
60
|
+
args << if line.include?("is_deleted")
|
61
|
+
"is_deleted"
|
62
|
+
else
|
63
|
+
line.to_s.match(/if value\[:(.+)\]/)[1].underscore
|
64
|
+
end
|
65
|
+
elsif action == "argument" && line.include?("argument")
|
66
|
+
args << line.split(",")[0].gsub("argument :", "").strip.underscore
|
68
67
|
end
|
69
|
-
args
|
70
68
|
end
|
71
69
|
end
|
70
|
+
args
|
72
71
|
end
|
73
72
|
end
|
74
73
|
end
|