souls 0.29.6 → 0.29.10
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/exe/souls +6 -1
- data/lib/souls.rb +67 -13
- data/lib/souls/api/generate/application.rb +3 -3
- data/lib/souls/api/generate/migration.rb +4 -4
- data/lib/souls/api/generate/rspec_mutation.rb +2 -2
- data/lib/souls/api/update.rb +6 -1
- data/lib/souls/api/update/mutation.rb +79 -0
- data/lib/souls/api/update/resolver.rb +72 -0
- data/lib/souls/api/update/rspec_factory.rb +50 -0
- data/lib/souls/api/update/rspec_mutation.rb +97 -0
- data/lib/souls/api/update/rspec_resolver.rb +85 -0
- data/lib/souls/api/update/type.rb +50 -0
- 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 +11 -6
- data/lib/souls/api/update/update_mutation.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89783d118ae3fb409bc17f2aea50b67a213f91d34afb3d56135827466e4da20e
|
4
|
+
data.tar.gz: 2404c4ff229731768621ab122c3d5fe614cc8d54679354664b217ce0493cc28f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f36b58d66ba66b8885fe9ad9b1a04609fdf76d6632bd50b9ece3a1d569107bb29bccaaa11ac1f6c8e4209e625a765d42746085eaf0442c9395792fe7bbd6159
|
7
|
+
data.tar.gz: 554f856869f9336d705477cb621d634ebb7ff2ebf48ab1434bd8c9ecfcec1c8492041bd5275f77f98d376c7541814980fa2d1cf2d955afa981b37c41c477b8c5
|
data/exe/souls
CHANGED
@@ -21,7 +21,12 @@ begin
|
|
21
21
|
Whirly.status = "Done!"
|
22
22
|
end
|
23
23
|
when "schema:update"
|
24
|
-
|
24
|
+
class_name = ARGV[2]
|
25
|
+
Souls::Api::Update.create_mutation(class_name: class_name)
|
26
|
+
Souls::Api::Update.update_mutation(class_name: class_name)
|
27
|
+
Souls::Api::Update.rspec_factory(class_name: class_name)
|
28
|
+
Souls::Api::Update.rspec_mutation(class_name: class_name)
|
29
|
+
Souls::Api::Update.rspec_resolver(class_name: class_name)
|
25
30
|
else
|
26
31
|
puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
|
27
32
|
end
|
data/lib/souls.rb
CHANGED
@@ -332,38 +332,92 @@ module Souls
|
|
332
332
|
}
|
333
333
|
end
|
334
334
|
|
335
|
-
def
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
335
|
+
def check_schema(class_name: "user")
|
336
|
+
schema_data = get_columns_num(class_name: class_name)
|
337
|
+
create_migration_data = get_create_migration_type(class_name: class_name)
|
338
|
+
add_migration_data = get_migration_type(class_name: class_name, action: "add")
|
339
|
+
remove_migration_data = get_migration_type(class_name: class_name, action: "remove")
|
340
|
+
migration_data = create_migration_data + add_migration_data - remove_migration_data
|
341
|
+
return "Already Up to date!" if schema_data.size == migration_data.size
|
342
|
+
|
343
|
+
schema_data - migration_data
|
344
|
+
end
|
340
345
|
|
341
|
-
|
346
|
+
def get_columns_num(class_name: "user")
|
347
|
+
file_path = "./db/schema.rb"
|
348
|
+
class_check_flag = false
|
349
|
+
cols = []
|
350
|
+
File.open(file_path, "r") do |f|
|
351
|
+
f.each_line.with_index do |line, _i|
|
352
|
+
class_check_flag = true if line.include?("create_table") && line.include?(class_name)
|
353
|
+
if class_check_flag == true && !line.include?("create_table")
|
354
|
+
return cols if line.include?("t.index") || line.strip == "end"
|
355
|
+
|
356
|
+
types = Souls::Api::Generate.get_type_and_name(line)
|
357
|
+
array = line.include?("array: true")
|
358
|
+
cols << { column_name: types[1], type: types[0], array: array }
|
359
|
+
end
|
342
360
|
end
|
343
|
-
|
361
|
+
end
|
362
|
+
cols
|
344
363
|
end
|
345
364
|
|
346
|
-
def
|
365
|
+
def get_create_migration_type(class_name: "user")
|
347
366
|
pluralized_class_name = class_name.pluralize
|
348
|
-
|
367
|
+
file_path = Dir["db/migrate/*_create_#{pluralized_class_name}.rb"][0]
|
368
|
+
|
369
|
+
class_check_flag = false
|
370
|
+
response = [
|
371
|
+
{ column_name: "created_at", type: "datetime", array: false },
|
372
|
+
{ column_name: "updated_at", type: "datetime", array: false }
|
373
|
+
]
|
374
|
+
File.open(file_path) do |f|
|
375
|
+
f.each_line do |line|
|
376
|
+
class_check_flag = true if line.include?("create_table")
|
377
|
+
next unless class_check_flag == true && !line.include?("create_table")
|
378
|
+
return response if line.include?("t.timestamps") || line.strip == "end"
|
379
|
+
|
380
|
+
types = Souls::Api::Generate.get_type_and_name(line)
|
381
|
+
types.map { |n| n.gsub!(":", "") }
|
382
|
+
array = line.include?("array: true")
|
383
|
+
response << { column_name: types[1], type: types[0], array: array }
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
def get_migration_type(class_name: "user", action: "add")
|
389
|
+
pluralized_class_name = class_name.pluralize
|
390
|
+
file_paths = Dir["db/migrate/*_#{action}_column_to_#{pluralized_class_name}.rb"]
|
391
|
+
|
349
392
|
new_columns =
|
350
393
|
file_paths.map do |file_path|
|
351
|
-
get_col_name_and_type(class_name: class_name, file_path: file_path)
|
394
|
+
get_col_name_and_type(class_name: class_name, file_path: file_path, action: action)
|
352
395
|
end
|
353
396
|
new_columns.flatten
|
354
397
|
end
|
355
398
|
|
356
|
-
def
|
399
|
+
def get_last_migration_type(class_name: "user", action: "add")
|
400
|
+
pluralized_class_name = class_name.pluralize
|
401
|
+
file_paths = Dir["db/migrate/*_#{action}_column_to_#{pluralized_class_name}.rb"]
|
402
|
+
|
403
|
+
file_paths.max
|
404
|
+
resoponse = get_col_name_and_type(class_name: class_name, file_path: file_paths.max, action: action)
|
405
|
+
resoponse.flatten
|
406
|
+
end
|
407
|
+
|
408
|
+
def get_col_name_and_type(
|
409
|
+
class_name: "user", file_path: "db/migrate/20210816094410_add_column_to_users.rb", action: "add"
|
410
|
+
)
|
357
411
|
pluralized_class_name = class_name.pluralize
|
358
412
|
response = []
|
359
413
|
File.open(file_path) do |line|
|
360
414
|
line.each_line do |file_line|
|
361
|
-
next unless file_line.include?("
|
415
|
+
next unless file_line.include?("#{action}_column")
|
362
416
|
|
363
417
|
array = file_line.include?("array: true")
|
364
418
|
types = file_line.split(",").map(&:strip)
|
365
419
|
types.map { |n| n.gsub!(":", "") }
|
366
|
-
types[0].gsub!("
|
420
|
+
types[0].gsub!("#{action}_column ", "")
|
367
421
|
unless types[0].to_s == pluralized_class_name
|
368
422
|
raise(StandardError, "Wrong class_name!Please Check your migration file!")
|
369
423
|
end
|
@@ -76,14 +76,14 @@ module Souls
|
|
76
76
|
|
77
77
|
def self.get_test_type(type)
|
78
78
|
{
|
79
|
-
bigint: 1,
|
79
|
+
bigint: "rand(1..10)",
|
80
80
|
float: 4.2,
|
81
81
|
string: '"MyString"',
|
82
82
|
text: '"MyString"',
|
83
83
|
datetime: "Time.now",
|
84
|
-
date: "Time.now",
|
84
|
+
date: "Time.now.strftime('%F')",
|
85
85
|
boolean: false,
|
86
|
-
integer: 1
|
86
|
+
integer: "rand(1..10)"
|
87
87
|
}[type.to_sym]
|
88
88
|
end
|
89
89
|
|
@@ -9,7 +9,7 @@ module Souls
|
|
9
9
|
|
10
10
|
def add_column(class_name: "user")
|
11
11
|
pluralized_class_name = class_name.underscore.pluralize
|
12
|
-
system("rake db:create_migration NAME=
|
12
|
+
system("rake db:create_migration NAME=add_column_to_#{pluralized_class_name}")
|
13
13
|
end
|
14
14
|
|
15
15
|
def rename_column(class_name: "user")
|
@@ -19,17 +19,17 @@ module Souls
|
|
19
19
|
|
20
20
|
def change_column(class_name: "user")
|
21
21
|
pluralized_class_name = class_name.underscore.pluralize
|
22
|
-
system("rake db:create_migration NAME=
|
22
|
+
system("rake db:create_migration NAME=change_column_to_#{pluralized_class_name}")
|
23
23
|
end
|
24
24
|
|
25
25
|
def remove_column(class_name: "user")
|
26
26
|
pluralized_class_name = class_name.underscore.pluralize
|
27
|
-
system("rake db:create_migration NAME=
|
27
|
+
system("rake db:create_migration NAME=remove_column_to_#{pluralized_class_name}")
|
28
28
|
end
|
29
29
|
|
30
30
|
def drop_table(class_name: "user")
|
31
31
|
pluralized_class_name = class_name.underscore.pluralize
|
32
|
-
system("rake db:create_migration NAME=
|
32
|
+
system("rake db:create_migration NAME=drop_table_to_#{pluralized_class_name}")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -92,10 +92,10 @@ module Souls
|
|
92
92
|
" #{camel}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
93
93
|
)
|
94
94
|
else
|
95
|
+
camel = name.singularize.camelize(:lower)
|
96
|
+
camels = name.pluralize.camelize(:lower)
|
95
97
|
case type
|
96
98
|
when "string", "text", "date", "datetime"
|
97
|
-
camel = name.singularize.camelize(:lower)
|
98
|
-
camels = name.pluralize.camelize(:lower)
|
99
99
|
if array_true
|
100
100
|
new_line.write(
|
101
101
|
" #{camels}: \#{#{class_name.singularize}[:#{name.pluralize.underscore}]}\n"
|
data/lib/souls/api/update.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
require_relative "./update/
|
1
|
+
require_relative "./update/mutation"
|
2
|
+
require_relative "./update/resolver"
|
3
|
+
require_relative "./update/type"
|
4
|
+
require_relative "./update/rspec_factory"
|
5
|
+
require_relative "./update/rspec_mutation"
|
6
|
+
require_relative "./update/rspec_resolver"
|
2
7
|
|
3
8
|
module Souls
|
4
9
|
module Api::Update
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api
|
3
|
+
module Update
|
4
|
+
class << self
|
5
|
+
def create_mutation(class_name: "user")
|
6
|
+
singularized_class_name = class_name.singularize.underscore
|
7
|
+
new_cols = Souls.get_last_migration_type(class_name: singularized_class_name, action: "add")
|
8
|
+
dir_name = "./app/graphql/mutations/base/#{singularized_class_name}"
|
9
|
+
new_file_path = "tmp/create_mutation.rb"
|
10
|
+
file_path = "#{dir_name}/create_#{singularized_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") && !argument
|
17
|
+
|
18
|
+
new_cols.each do |col|
|
19
|
+
type = col[:array] ? "[#{col[:type].camelize}]" : col[:type].camelize
|
20
|
+
args = check_mutation_argument(class_name: class_name)
|
21
|
+
unless args.include?(col[:column_name])
|
22
|
+
new_line.write(" argument :#{col[:column_name]}, #{type}, required: false\n")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
argument = true
|
26
|
+
end
|
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
|
+
end
|
33
|
+
|
34
|
+
def update_update_mutation(class_name: "user")
|
35
|
+
singularized_class_name = class_name.singularize.underscore
|
36
|
+
new_cols = Souls.get_last_migration_type(class_name: singularized_class_name, action: "add")
|
37
|
+
dir_name = "./app/graphql/mutations/base/#{singularized_class_name}"
|
38
|
+
new_file_path = "tmp/update_mutation.rb"
|
39
|
+
file_path = "#{dir_name}/update_#{singularized_class_name}.rb"
|
40
|
+
argument = false
|
41
|
+
File.open(file_path) do |f|
|
42
|
+
File.open(new_file_path, "w") do |new_line|
|
43
|
+
f.each_line do |line|
|
44
|
+
new_line.write(line)
|
45
|
+
next unless line.include?("argument") && !argument
|
46
|
+
|
47
|
+
new_cols.each do |col|
|
48
|
+
type = Souls::Api::Generate.type_check(col[:type])
|
49
|
+
type = "[#{type}]" if col[:array]
|
50
|
+
args = check_mutation_argument(class_name: class_name, action: "update")
|
51
|
+
unless args.include?(col[:column_name])
|
52
|
+
new_line.write(" argument :#{col[:column_name]}, #{type}, required: false\n")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
argument = true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
FileUtils.rm(file_path)
|
60
|
+
FileUtils.mv(new_file_path, file_path)
|
61
|
+
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_mutation_argument(class_name: "user", action: "create")
|
65
|
+
singularized_class_name = class_name.singularize.underscore
|
66
|
+
dir_name = "./app/graphql/mutations/base/#{singularized_class_name}"
|
67
|
+
file_path = "#{dir_name}/#{action}_#{singularized_class_name}.rb"
|
68
|
+
args = []
|
69
|
+
File.open(file_path) do |f|
|
70
|
+
f.each_line do |line|
|
71
|
+
args << line.split(",")[0].gsub("argument :", "").strip.underscore if line.include?("argument")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
args
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api
|
3
|
+
module Update
|
4
|
+
class << self
|
5
|
+
def resolver(class_name: "user")
|
6
|
+
singularized_class_name = class_name.singularize.underscore
|
7
|
+
new_cols = Souls.get_last_migration_type(class_name: singularized_class_name, action: "add")
|
8
|
+
dir_name = "./app/graphql/resolvers"
|
9
|
+
new_file_path = "tmp/update_resolver.rb"
|
10
|
+
file_path = "#{dir_name}/#{singularized_class_name}_search.rb"
|
11
|
+
args = check_resolver_argument(class_name: class_name)
|
12
|
+
scope_args = check_resolver_argument(class_name: class_name, action: "scope")
|
13
|
+
argument = false
|
14
|
+
scope = false
|
15
|
+
File.open(file_path) do |f|
|
16
|
+
File.open(new_file_path, "w") do |new_line|
|
17
|
+
f.each_line do |line|
|
18
|
+
new_line.write(line)
|
19
|
+
if line.include?("argument") && !argument
|
20
|
+
new_cols.each do |col|
|
21
|
+
type = Souls::Api::Generate.type_check(col[:type])
|
22
|
+
type = "[#{type}]" if col[:array]
|
23
|
+
add_line = " argument :#{col[:column_name]}, #{type}, required: false\n"
|
24
|
+
new_line.write(add_line) unless args.include?(col[:column_name])
|
25
|
+
end
|
26
|
+
argument = true
|
27
|
+
elsif line.include?("scope = ::") && !scope
|
28
|
+
new_cols.each do |col|
|
29
|
+
type = Souls::Api::Generate.type_check(col[:type])
|
30
|
+
type = "[#{type}]" if col[:array]
|
31
|
+
|
32
|
+
if type.include?("[")
|
33
|
+
add_line = " scope = scope.where('#{col[:column_name]} @> ARRAY[?]::#{col[:type]}[]', value[:#{col[:column_name]}]) if value[:#{col[:column_name]}]\n"
|
34
|
+
else
|
35
|
+
add_line = " scope = scope.where(#{col[:column_name]}: value[:#{col[:column_name]}]) if value[:#{col[:column_name]}]\n"
|
36
|
+
end
|
37
|
+
new_line.write(add_line) unless scope_args.include?(col[:column_name])
|
38
|
+
end
|
39
|
+
scope = true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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
|
+
end
|
48
|
+
|
49
|
+
def check_resolver_argument(class_name: "user", action: "argument")
|
50
|
+
singularized_class_name = class_name.singularize.underscore
|
51
|
+
dir_name = "./app/graphql/resolvers"
|
52
|
+
file_path = "#{dir_name}/#{singularized_class_name}_search.rb"
|
53
|
+
args = []
|
54
|
+
File.open(file_path) do |f|
|
55
|
+
f.each_line do |line|
|
56
|
+
if action == "scope" && line.include?("scope = scope.where")
|
57
|
+
args << if line.include?("is_deleted")
|
58
|
+
"is_deleted"
|
59
|
+
else
|
60
|
+
line.to_s.match(/if value\[:(.+)\]/)[1].underscore
|
61
|
+
end
|
62
|
+
elsif action == "argument" && line.include?("argument")
|
63
|
+
args << line.split(",")[0].gsub("argument :", "").strip.underscore
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
args
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api
|
3
|
+
module Update
|
4
|
+
class << self
|
5
|
+
def rspec_factory(class_name: "user")
|
6
|
+
singularized_class_name = class_name.singularize.underscore
|
7
|
+
pluralized_class_name = class_name.pluralize.underscore
|
8
|
+
new_cols = Souls.get_last_migration_type(class_name: singularized_class_name, action: "add")
|
9
|
+
dir_name = "./spec/factories"
|
10
|
+
new_file_path = "tmp/create_factory.rb"
|
11
|
+
file_path = "#{dir_name}/#{pluralized_class_name}.rb"
|
12
|
+
argument = 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
|
+
next unless line.include?("{") && !argument
|
18
|
+
|
19
|
+
new_cols.each do |col|
|
20
|
+
type = Souls::Api::Generate.get_test_type(col[:type])
|
21
|
+
type = "[#{type}]" if col[:array]
|
22
|
+
args = check_factory_argument(class_name: class_name)
|
23
|
+
|
24
|
+
new_line.write(" #{col[:column_name]} { #{type} }\n") unless args.include?(col[:column_name])
|
25
|
+
end
|
26
|
+
argument = true
|
27
|
+
end
|
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
|
+
end
|
34
|
+
|
35
|
+
def check_factory_argument(class_name: "user")
|
36
|
+
pluralized_class_name = class_name.pluralize.underscore
|
37
|
+
dir_name = "./spec/factories"
|
38
|
+
file_path = "#{dir_name}/#{pluralized_class_name}.rb"
|
39
|
+
args = []
|
40
|
+
File.open(file_path) do |f|
|
41
|
+
f.each_line do |line|
|
42
|
+
args << line.split("{")[0].strip.underscore if line.include?("{")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
args
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api
|
3
|
+
module Update
|
4
|
+
class << self
|
5
|
+
def rspec_mutation(class_name: "user")
|
6
|
+
singularized_class_name = class_name.singularize.underscore
|
7
|
+
new_cols = Souls.get_last_migration_type(class_name: singularized_class_name, action: "add")
|
8
|
+
dir_name = "./spec/mutations/base"
|
9
|
+
new_file_path = "tmp/rspec_mutation.rb"
|
10
|
+
file_path = "#{dir_name}/#{singularized_class_name}_spec.rb"
|
11
|
+
argument = false
|
12
|
+
node_res = false
|
13
|
+
test_res = 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
|
+
node_res = true if line.include?("node {")
|
19
|
+
test_res = true if line.include?("include(")
|
20
|
+
node_res = false if node_res && line.include?("}")
|
21
|
+
test_res = false if test_res && line.strip == ")"
|
22
|
+
|
23
|
+
if line.include?('#{') && !argument
|
24
|
+
new_cols.each do |col|
|
25
|
+
type = Souls::Api::Generate.type_check(col[:type])
|
26
|
+
if type == "String" && !col[:array]
|
27
|
+
type_line = " #{col[:column_name].singularize.camelize(:lower)}: \"\#{#{class_name.singularize}[:#{col[:column_name].singularize.underscore}]}\"\n"
|
28
|
+
else
|
29
|
+
type_line = " #{col[:column_name].singularize.camelize(:lower)}: \#{#{class_name.singularize}[:#{col[:column_name].singularize.underscore}]}\n"
|
30
|
+
end
|
31
|
+
args = check_rspec_mutation_argument(class_name: class_name)
|
32
|
+
new_line.write(type_line) unless args.include?(col[:column_name].singularize.underscore)
|
33
|
+
end
|
34
|
+
argument = true
|
35
|
+
elsif node_res && !line.include?("{")
|
36
|
+
node_args = check_rspec_mutation_argument(class_name: class_name, action: "node_args")
|
37
|
+
new_cols.each do |col|
|
38
|
+
new_line.write(" #{col[:column_name]}\n") unless node_args.include?(col[:column_name])
|
39
|
+
end
|
40
|
+
node_res = false
|
41
|
+
elsif test_res && line.include?("=> be_")
|
42
|
+
test_args = check_rspec_mutation_argument(class_name: class_name, action: "test_args")
|
43
|
+
new_cols.each do |col|
|
44
|
+
type = Souls::Api::Generate.type_check(col[:type])
|
45
|
+
text =
|
46
|
+
case type
|
47
|
+
when "String"
|
48
|
+
col[:array] ? "be_all(String)" : "be_a(String)"
|
49
|
+
when "Integer", "Float"
|
50
|
+
col[:array] ? "be_all(Integer)" : "be_a(Integer)"
|
51
|
+
when "Boolean"
|
52
|
+
col[:array] ? "be_all([true, false])" : "be_in([true, false])"
|
53
|
+
else
|
54
|
+
col[:array] ? "be_all(String)" : "be_a(String)"
|
55
|
+
end
|
56
|
+
unless test_args.include?(col[:column_name])
|
57
|
+
new_line.write(" \"#{col[:column_name]}\" => #{text},\n")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
test_res = false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
FileUtils.rm(file_path)
|
66
|
+
FileUtils.mv(new_file_path, file_path)
|
67
|
+
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
68
|
+
end
|
69
|
+
|
70
|
+
def check_rspec_mutation_argument(class_name: "user", action: "argument")
|
71
|
+
singularized_class_name = class_name.singularize.underscore
|
72
|
+
dir_name = "./spec/mutations/base"
|
73
|
+
file_path = "#{dir_name}/#{singularized_class_name}_spec.rb"
|
74
|
+
node_res = false
|
75
|
+
test_res = false
|
76
|
+
args = []
|
77
|
+
File.open(file_path) do |f|
|
78
|
+
f.each_line do |line|
|
79
|
+
node_res = true if line.include?("node {")
|
80
|
+
test_res = true if line.include?("include(")
|
81
|
+
node_res = false if node_res && line.include?("}")
|
82
|
+
test_res = false if test_res && line.strip == ")"
|
83
|
+
if action == "node_args"
|
84
|
+
args << line.strip.underscore if node_res && !line.include?("{")
|
85
|
+
elsif action == "test_args"
|
86
|
+
args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
|
87
|
+
elsif line.include?('#{')
|
88
|
+
args << line.split(":")[0].strip.underscore
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
args
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api
|
3
|
+
module Update
|
4
|
+
class << self
|
5
|
+
def rspec_resolver(class_name: "user")
|
6
|
+
singularized_class_name = class_name.singularize.underscore
|
7
|
+
new_cols = Souls.get_last_migration_type(class_name: singularized_class_name, action: "add")
|
8
|
+
dir_name = "./spec/resolvers"
|
9
|
+
new_file_path = "tmp/rspec_resolver.rb"
|
10
|
+
file_path = "#{dir_name}/#{singularized_class_name}_search_spec.rb"
|
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 == ")"
|
21
|
+
|
22
|
+
if node_res && !line.include?("{")
|
23
|
+
node_args = check_rspec_resolver_argument(class_name: class_name, action: "node_args")
|
24
|
+
new_cols.each do |col|
|
25
|
+
new_line.write(" #{col[:column_name].camelize}\n") unless node_args.include?(col[:column_name])
|
26
|
+
end
|
27
|
+
node_res = false
|
28
|
+
elsif test_res && line.include?("=> be_")
|
29
|
+
test_args = check_rspec_resolver_argument(class_name: class_name, action: "test_args")
|
30
|
+
new_cols.each do |col|
|
31
|
+
type = Souls::Api::Generate.type_check(col[:type])
|
32
|
+
p type
|
33
|
+
text =
|
34
|
+
case type
|
35
|
+
when "String"
|
36
|
+
col[:array] ? "be_all(String)" : "be_a(String)"
|
37
|
+
when "Integer", "Float"
|
38
|
+
col[:array] ? "be_all(Integer)" : "be_a(Integer)"
|
39
|
+
when "Boolean"
|
40
|
+
col[:array] ? "be_all([true, false])" : "be_in([true, false])"
|
41
|
+
else
|
42
|
+
col[:array] ? "be_all(String)" : "be_a(String)"
|
43
|
+
end
|
44
|
+
unless test_args.include?(col[:column_name])
|
45
|
+
new_line.write(" \"#{col[:column_name]}\" => #{text},\n")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
test_res = false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
FileUtils.rm(file_path)
|
54
|
+
FileUtils.mv(new_file_path, file_path)
|
55
|
+
puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
56
|
+
end
|
57
|
+
|
58
|
+
def check_rspec_resolver_argument(class_name: "user", action: "node_args")
|
59
|
+
singularized_class_name = class_name.singularize.underscore
|
60
|
+
dir_name = "./spec/resolvers"
|
61
|
+
file_path = "#{dir_name}/#{singularized_class_name}_search_spec.rb"
|
62
|
+
node_res = false
|
63
|
+
test_res = false
|
64
|
+
args = []
|
65
|
+
File.open(file_path) do |f|
|
66
|
+
f.each_line do |line|
|
67
|
+
node_res = true if line.include?("node {")
|
68
|
+
test_res = true if line.include?("include(")
|
69
|
+
node_res = false if node_res && line.include?("}")
|
70
|
+
test_res = false if test_res && line.strip == ")"
|
71
|
+
if action == "node_args"
|
72
|
+
args << line.strip.underscore if node_res && !line.include?("{")
|
73
|
+
elsif action == "test_args"
|
74
|
+
args << line.split("\"")[1].underscore if test_res && line.include?("=> be_")
|
75
|
+
elsif line.include?('#{')
|
76
|
+
args << line.split(":")[0].strip.underscore
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
args
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api
|
3
|
+
module Update
|
4
|
+
class << self
|
5
|
+
def type(class_name: "user")
|
6
|
+
singularized_class_name = class_name.singularize.underscore
|
7
|
+
new_cols = Souls.get_last_migration_type(class_name: singularized_class_name, action: "add")
|
8
|
+
dir_name = "./app/graphql/types"
|
9
|
+
new_file_path = "tmp/create_type.rb"
|
10
|
+
file_path = "#{dir_name}/#{singularized_class_name}_type.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?("field") && !argument
|
17
|
+
|
18
|
+
new_cols.each do |col|
|
19
|
+
type = Souls::Api::Generate.type_check(col[:type])
|
20
|
+
type = "[#{type}]" if col[:array]
|
21
|
+
args = check_type_argument(class_name: class_name)
|
22
|
+
unless args.include?(col[:column_name])
|
23
|
+
new_line.write(" field :#{col[:column_name]}, #{type}, null: true\n")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
argument = true
|
27
|
+
end
|
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
|
+
end
|
34
|
+
|
35
|
+
def check_type_argument(class_name: "user")
|
36
|
+
singularized_class_name = class_name.singularize.underscore
|
37
|
+
dir_name = "./app/graphql/types"
|
38
|
+
file_path = "#{dir_name}/#{singularized_class_name}_type.rb"
|
39
|
+
args = []
|
40
|
+
File.open(file_path) do |f|
|
41
|
+
f.each_line do |line|
|
42
|
+
args << line.split(",")[0].gsub("field :", "").strip if line.include?(" field :")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
args
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.10
|
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.10
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: souls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.29.
|
4
|
+
version: 0.29.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
8
8
|
- KishiTheMechanic
|
9
9
|
- James Neve
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-08-
|
13
|
+
date: 2021-08-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -121,7 +121,12 @@ files:
|
|
121
121
|
- lib/souls/api/generate/rspec_resolver.rb
|
122
122
|
- lib/souls/api/generate/type.rb
|
123
123
|
- lib/souls/api/update.rb
|
124
|
-
- lib/souls/api/update/
|
124
|
+
- lib/souls/api/update/mutation.rb
|
125
|
+
- lib/souls/api/update/resolver.rb
|
126
|
+
- lib/souls/api/update/rspec_factory.rb
|
127
|
+
- lib/souls/api/update/rspec_mutation.rb
|
128
|
+
- lib/souls/api/update/rspec_resolver.rb
|
129
|
+
- lib/souls/api/update/type.rb
|
125
130
|
- lib/souls/docker.rb
|
126
131
|
- lib/souls/docker/docker.rb
|
127
132
|
- lib/souls/gcloud.rb
|
@@ -147,7 +152,7 @@ metadata:
|
|
147
152
|
homepage_uri: https://souls.elsoul.nl
|
148
153
|
source_code_uri: https://github.com/elsoul/souls
|
149
154
|
changelog_uri: https://github.com/elsoul/souls
|
150
|
-
post_install_message:
|
155
|
+
post_install_message:
|
151
156
|
rdoc_options: []
|
152
157
|
require_paths:
|
153
158
|
- lib
|
@@ -163,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
168
|
version: '0'
|
164
169
|
requirements: []
|
165
170
|
rubygems_version: 3.2.22
|
166
|
-
signing_key:
|
171
|
+
signing_key:
|
167
172
|
specification_version: 4
|
168
173
|
summary: SOULs is a Serverless Application Framework with Ruby GraphQL. SOULs has
|
169
174
|
3 strains, API, Worker, and Frontend. It can be used in combination according to
|