souls 0.51.2 → 0.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/exe/souls +4 -202
- 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 +97 -93
- 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,52 +1,53 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
next unless line.include?("{") && !argument
|
2
|
+
class Update < Thor
|
3
|
+
desc "rspec_factory [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
4
|
+
def rspec_factory(class_name)
|
5
|
+
singularized_class_name = class_name.singularize.underscore
|
6
|
+
pluralized_class_name = class_name.pluralize.underscore
|
7
|
+
new_cols = Souls.get_columns_num(class_name: singularized_class_name)
|
8
|
+
dir_name = "./spec/factories"
|
9
|
+
new_file_path = "tmp/create_factory.rb"
|
10
|
+
file_path = "#{dir_name}/#{pluralized_class_name}.rb"
|
11
|
+
argument = false
|
12
|
+
File.open(file_path) do |f|
|
13
|
+
File.open(new_file_path, "w") do |new_line|
|
14
|
+
f.each_line do |line|
|
15
|
+
new_line.write(line)
|
16
|
+
next unless line.include?("{") && !argument
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
new_cols.each do |col|
|
19
|
+
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
type = Souls.get_test_type(col[:type])
|
22
|
+
type = "[#{type}]" if col[:array]
|
23
|
+
args = check_factory_argument(class_name: class_name)
|
25
24
|
|
26
|
-
|
27
|
-
end
|
28
|
-
argument = true
|
29
|
-
end
|
25
|
+
new_line.write(" #{col[:column_name]} { #{type} }\n") unless args.include?(col[:column_name])
|
30
26
|
end
|
27
|
+
argument = true
|
31
28
|
end
|
32
|
-
FileUtils.rm(file_path)
|
33
|
-
FileUtils.mv(new_file_path, file_path)
|
34
|
-
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
35
29
|
end
|
30
|
+
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
|
+
rescue Thor::Error => e
|
35
|
+
raise(Thor::Error, e)
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
args
|
38
|
+
private
|
39
|
+
|
40
|
+
def check_factory_argument(class_name: "user")
|
41
|
+
pluralized_class_name = class_name.pluralize.underscore
|
42
|
+
dir_name = "./spec/factories"
|
43
|
+
file_path = "#{dir_name}/#{pluralized_class_name}.rb"
|
44
|
+
args = []
|
45
|
+
File.open(file_path) do |f|
|
46
|
+
f.each_line do |line|
|
47
|
+
args << line.split("{")[0].strip.underscore if line.include?("{")
|
48
48
|
end
|
49
49
|
end
|
50
|
+
args
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
@@ -1,100 +1,101 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
test_res = false if test_res && line.strip == ")"
|
2
|
+
class Update < Thor
|
3
|
+
desc "rspec_mutation [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
4
|
+
def rspec_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 = "./spec/mutations/base"
|
8
|
+
new_file_path = "tmp/rspec_mutation.rb"
|
9
|
+
file_path = "#{dir_name}/#{singularized_class_name}_spec.rb"
|
10
|
+
argument = false
|
11
|
+
node_res = false
|
12
|
+
test_res = false
|
13
|
+
File.open(file_path) do |f|
|
14
|
+
File.open(new_file_path, "w") do |new_line|
|
15
|
+
f.each_line do |line|
|
16
|
+
new_line.write(line)
|
17
|
+
node_res = true if line.include?("node {")
|
18
|
+
test_res = true if line.include?("include(")
|
19
|
+
node_res = false if node_res && line.include?("}")
|
20
|
+
test_res = false if test_res && line.strip == ")"
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
if line.include?('#{') && !argument
|
23
|
+
new_cols.each do |col|
|
24
|
+
type = Souls.type_check(col[:type])
|
25
|
+
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
args = check_rspec_mutation_argument(class_name: class_name)
|
35
|
-
new_line.write(type_line) unless args.include?(col[:column_name].underscore)
|
27
|
+
type_line =
|
28
|
+
if type == "String" && !col[:array]
|
29
|
+
" #{col[:column_name].camelize(:lower)}: \"\#{#{class_name}[:#{col[:column_name].underscore}]}\"\n"
|
30
|
+
else
|
31
|
+
" #{col[:column_name].camelize(:lower)}: \#{#{class_name}[:#{col[:column_name].underscore}]}\n"
|
36
32
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
33
|
+
args = check_rspec_mutation_argument(class_name: class_name)
|
34
|
+
new_line.write(type_line) unless args.include?(col[:column_name].underscore)
|
35
|
+
end
|
36
|
+
argument = true
|
37
|
+
elsif node_res && !line.include?("{")
|
38
|
+
node_args = check_rspec_mutation_argument(class_name: class_name, action: "node_args")
|
39
|
+
new_cols.each do |col|
|
40
|
+
unless node_args.include?(col[:column_name])
|
41
|
+
new_line.write(" #{col[:column_name].camelize(:lower)}\n")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
node_res = false
|
45
|
+
elsif test_res && line.include?("=> be_")
|
46
|
+
test_args = check_rspec_mutation_argument(class_name: class_name, action: "test_args")
|
47
|
+
new_cols.each do |col|
|
48
|
+
type = Souls.type_check(col[:type])
|
49
|
+
text =
|
50
|
+
case type
|
51
|
+
when "Integer", "Float"
|
52
|
+
col[:array] ? "be_all(Integer)" : "be_a(Integer)"
|
53
|
+
when "Boolean"
|
54
|
+
col[:array] ? "be_all([true, false])" : "be_in([true, false])"
|
55
|
+
else
|
56
|
+
col[:array] ? "be_all(String)" : "be_a(String)"
|
62
57
|
end
|
63
|
-
|
58
|
+
unless test_args.include?(col[:column_name])
|
59
|
+
new_line.write(" \"#{col[:column_name].camelize(:lower)}\" => #{text},\n")
|
64
60
|
end
|
65
61
|
end
|
62
|
+
test_res = false
|
66
63
|
end
|
67
64
|
end
|
68
|
-
FileUtils.rm(file_path)
|
69
|
-
FileUtils.mv(new_file_path, file_path)
|
70
|
-
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
71
65
|
end
|
66
|
+
end
|
67
|
+
FileUtils.rm(file_path)
|
68
|
+
FileUtils.mv(new_file_path, file_path)
|
69
|
+
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
70
|
+
rescue Thor::Error => e
|
71
|
+
raise(Thor::Error, e)
|
72
|
+
end
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
74
|
+
private
|
75
|
+
|
76
|
+
def check_rspec_mutation_argument(class_name: "user", action: "argument")
|
77
|
+
singularized_class_name = class_name.singularize.underscore
|
78
|
+
dir_name = "./spec/mutations/base"
|
79
|
+
file_path = "#{dir_name}/#{singularized_class_name}_spec.rb"
|
80
|
+
node_res = false
|
81
|
+
test_res = false
|
82
|
+
args = []
|
83
|
+
File.open(file_path) do |f|
|
84
|
+
f.each_line do |line|
|
85
|
+
node_res = true if line.include?("node {")
|
86
|
+
test_res = true if line.include?("include(")
|
87
|
+
node_res = false if node_res && line.include?("}")
|
88
|
+
test_res = false if test_res && line.strip == ")"
|
89
|
+
if action == "node_args"
|
90
|
+
args << line.strip.underscore if node_res && !line.include?("{")
|
91
|
+
elsif action == "test_args"
|
92
|
+
args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
|
93
|
+
elsif line.include?('#{')
|
94
|
+
args << line.split(":")[0].strip.underscore
|
94
95
|
end
|
95
|
-
args
|
96
96
|
end
|
97
97
|
end
|
98
|
+
args
|
98
99
|
end
|
99
100
|
end
|
100
101
|
end
|
@@ -1,84 +1,85 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
test_res = false if test_res && line.strip == ")"
|
2
|
+
class Update < Thor
|
3
|
+
desc "rspec_resolver [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
4
|
+
def rspec_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 = "./spec/resolvers"
|
8
|
+
new_file_path = "tmp/rspec_resolver.rb"
|
9
|
+
file_path = "#{dir_name}/#{singularized_class_name}_search_spec.rb"
|
10
|
+
node_res = false
|
11
|
+
test_res = false
|
12
|
+
File.open(file_path) do |f|
|
13
|
+
File.open(new_file_path, "w") do |new_line|
|
14
|
+
f.each_line do |line|
|
15
|
+
new_line.write(line)
|
16
|
+
node_res = true if line.include?("node {")
|
17
|
+
test_res = true if line.include?("include(")
|
18
|
+
node_res = false if node_res && line.include?("}")
|
19
|
+
test_res = false if test_res && line.strip == ")"
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
unless test_args.include?(col[:column_name])
|
44
|
-
new_line.write(" \"#{col[:column_name].camelize(:lower)}\" => #{text},\n")
|
45
|
-
end
|
21
|
+
if node_res && !line.include?("{")
|
22
|
+
node_args = check_rspec_resolver_argument(class_name: class_name, action: "node_args")
|
23
|
+
new_cols.each do |col|
|
24
|
+
unless node_args.include?(col[:column_name])
|
25
|
+
new_line.write(" #{col[:column_name].camelize(:lower)}\n")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
node_res = false
|
29
|
+
elsif test_res && line.include?("=> be_")
|
30
|
+
test_args = check_rspec_resolver_argument(class_name: class_name, action: "test_args")
|
31
|
+
new_cols.each do |col|
|
32
|
+
type = Souls.type_check(col[:type])
|
33
|
+
text =
|
34
|
+
case type
|
35
|
+
when "Integer", "Float"
|
36
|
+
col[:array] ? "be_all(Integer)" : "be_a(Integer)"
|
37
|
+
when "Boolean"
|
38
|
+
col[:array] ? "be_all([true, false])" : "be_in([true, false])"
|
39
|
+
else
|
40
|
+
col[:array] ? "be_all(String)" : "be_a(String)"
|
46
41
|
end
|
47
|
-
|
42
|
+
unless test_args.include?(col[:column_name])
|
43
|
+
new_line.write(" \"#{col[:column_name].camelize(:lower)}\" => #{text},\n")
|
48
44
|
end
|
49
45
|
end
|
46
|
+
test_res = false
|
50
47
|
end
|
51
48
|
end
|
52
|
-
FileUtils.rm(file_path)
|
53
|
-
FileUtils.mv(new_file_path, file_path)
|
54
|
-
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
55
49
|
end
|
50
|
+
end
|
51
|
+
FileUtils.rm(file_path)
|
52
|
+
FileUtils.mv(new_file_path, file_path)
|
53
|
+
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
54
|
+
rescue Thor::Error => e
|
55
|
+
raise(Thor::Error, e)
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
58
|
+
private
|
59
|
+
|
60
|
+
def check_rspec_resolver_argument(class_name: "user", action: "node_args")
|
61
|
+
singularized_class_name = class_name.singularize.underscore
|
62
|
+
dir_name = "./spec/resolvers"
|
63
|
+
file_path = "#{dir_name}/#{singularized_class_name}_search_spec.rb"
|
64
|
+
node_res = false
|
65
|
+
test_res = false
|
66
|
+
args = []
|
67
|
+
File.open(file_path) do |f|
|
68
|
+
f.each_line do |line|
|
69
|
+
node_res = true if line.include?("node {")
|
70
|
+
test_res = true if line.include?("include(")
|
71
|
+
node_res = false if node_res && line.include?("}")
|
72
|
+
test_res = false if test_res && line.strip == ")"
|
73
|
+
if action == "node_args"
|
74
|
+
args << line.strip.underscore if node_res && !line.include?("{")
|
75
|
+
elsif action == "test_args"
|
76
|
+
args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
|
77
|
+
elsif line.include?('#{')
|
78
|
+
args << line.split(":")[0].strip.underscore
|
78
79
|
end
|
79
|
-
args
|
80
80
|
end
|
81
81
|
end
|
82
|
+
args
|
82
83
|
end
|
83
84
|
end
|
84
85
|
end
|
@@ -1,50 +1,51 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
next unless line.include?("field") && !argument
|
2
|
+
class Update < Thor
|
3
|
+
desc "type [CLASS_NAME]", "Update GraphQL Type from schema.rb"
|
4
|
+
def type(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/types"
|
8
|
+
new_file_path = "tmp/create_type.rb"
|
9
|
+
file_path = "#{dir_name}/#{singularized_class_name}_type.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?("field") && !argument
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
argument = true
|
17
|
+
new_cols.each do |col|
|
18
|
+
type = Souls.get_type(col[:type])
|
19
|
+
type = "[#{type}]" if col[:array]
|
20
|
+
args = check_type_argument(class_name: class_name)
|
21
|
+
unless args.include?(col[:column_name])
|
22
|
+
new_line.write(" field :#{col[:column_name]}, #{type}, null: true\n")
|
27
23
|
end
|
28
24
|
end
|
25
|
+
argument = true
|
29
26
|
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
27
|
end
|
28
|
+
end
|
29
|
+
FileUtils.rm(file_path)
|
30
|
+
FileUtils.mv(new_file_path, file_path)
|
31
|
+
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
32
|
+
rescue Thor::Error => e
|
33
|
+
raise(Thor::Error, e)
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
args
|
36
|
+
private
|
37
|
+
|
38
|
+
def check_type_argument(class_name: "user")
|
39
|
+
singularized_class_name = class_name.singularize.underscore
|
40
|
+
dir_name = "./app/graphql/types"
|
41
|
+
file_path = "#{dir_name}/#{singularized_class_name}_type.rb"
|
42
|
+
args = []
|
43
|
+
File.open(file_path) do |f|
|
44
|
+
f.each_line do |line|
|
45
|
+
args << line.split(",")[0].gsub("field :", "").strip if line.include?(" field :")
|
46
46
|
end
|
47
47
|
end
|
48
|
+
args
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|