souls 0.29.7 → 0.29.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/souls +5 -1
- data/lib/souls.rb +52 -7
- data/lib/souls/api/generate/application.rb +3 -3
- data/lib/souls/api/update.rb +5 -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/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 +6 -2
- 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: 850fd970ee0932d65bed38e8bc32570a029ad30f6a936d7cb38e0515659164e2
|
4
|
+
data.tar.gz: 79c5e659716710e31c369050de2dff5c8c8b36e9ff52f8a54cdbd43dfda4a5b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 454d9847007e1390fb7fd0ee3a544a37c2a022e0fefa48b912efde577e2c8f897a03d0e3f5f57399fcefadaa320578090e7a6a0f23ee267caf4a2aaf2847d307
|
7
|
+
data.tar.gz: a6576810a7fb39d97fbc310039a643fd2dbc65124279965de480863f38163b0fa18bd7d1eb16713f04065834507984178bf5b6f3762de228158acf8ca99a30f1
|
data/exe/souls
CHANGED
@@ -21,7 +21,11 @@ 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)
|
25
29
|
else
|
26
30
|
puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
|
27
31
|
end
|
data/lib/souls.rb
CHANGED
@@ -332,6 +332,17 @@ module Souls
|
|
332
332
|
}
|
333
333
|
end
|
334
334
|
|
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
|
345
|
+
|
335
346
|
def get_columns_num(class_name: "user")
|
336
347
|
file_path = "./db/schema.rb"
|
337
348
|
class_check_flag = false
|
@@ -351,28 +362,62 @@ module Souls
|
|
351
362
|
cols
|
352
363
|
end
|
353
364
|
|
354
|
-
def
|
365
|
+
def get_create_migration_type(class_name: "user")
|
366
|
+
pluralized_class_name = class_name.pluralize
|
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")
|
355
389
|
pluralized_class_name = class_name.pluralize
|
356
|
-
file_paths = Dir["db/migrate/*
|
357
|
-
|
390
|
+
file_paths = Dir["db/migrate/*_#{action}_column_to_#{pluralized_class_name}.rb"]
|
391
|
+
|
358
392
|
new_columns =
|
359
393
|
file_paths.map do |file_path|
|
360
|
-
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)
|
361
395
|
end
|
362
396
|
new_columns.flatten
|
363
397
|
end
|
364
398
|
|
365
|
-
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
|
+
)
|
366
411
|
pluralized_class_name = class_name.pluralize
|
367
412
|
response = []
|
368
413
|
File.open(file_path) do |line|
|
369
414
|
line.each_line do |file_line|
|
370
|
-
next unless file_line.include?("
|
415
|
+
next unless file_line.include?("#{action}_column")
|
371
416
|
|
372
417
|
array = file_line.include?("array: true")
|
373
418
|
types = file_line.split(",").map(&:strip)
|
374
419
|
types.map { |n| n.gsub!(":", "") }
|
375
|
-
types[0].gsub!("
|
420
|
+
types[0].gsub!("#{action}_column ", "")
|
376
421
|
unless types[0].to_s == pluralized_class_name
|
377
422
|
raise(StandardError, "Wrong class_name!Please Check your migration file!")
|
378
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
|
|
data/lib/souls/api/update.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
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"
|
2
6
|
|
3
7
|
module Souls
|
4
8
|
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 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]
|
61
|
+
end
|
62
|
+
elsif action == "argument" && line.include?("argument")
|
63
|
+
args << line.split(",")[0].gsub("argument :", "").strip
|
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 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] 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,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.8
|
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.8
|
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.29.
|
4
|
+
version: 0.29.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
@@ -121,7 +121,11 @@ 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/type.rb
|
125
129
|
- lib/souls/docker.rb
|
126
130
|
- lib/souls/docker/docker.rb
|
127
131
|
- lib/souls/gcloud.rb
|