souls 0.9.8 → 0.10.4
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/Gemfile.lock +1 -1
- data/exe/souls +2 -2
- data/lib/souls/init.rb +30 -20
- data/lib/souls/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8023faaf2fefb8de70e49faaa956c8f554564069bbb7f975433a7fd99a52ed90
|
|
4
|
+
data.tar.gz: afc45d2da26c5de1474907d49ffe47b9436975bb1a3ac7d723e901a5668ab65d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de420d82bf8708dfa0bfb056acf124d124a359082aa54f3acce7c0aadd0948a054ccdfe928842b9c3f8beae3667342798cf742ea29e929739d26efc200a6cb1d
|
|
7
|
+
data.tar.gz: 73b9328d2a04a7f0cd41c775f13d5abf01cdf8f8727c306cec2de2ff8d7917a2ba52c5cc04670b72767e9c6ff86e894212e95f27670c44649cdf65af59da89e2
|
data/Gemfile.lock
CHANGED
data/exe/souls
CHANGED
|
@@ -76,8 +76,8 @@ begin
|
|
|
76
76
|
else
|
|
77
77
|
end
|
|
78
78
|
when "t", "test"
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
`rubocop`
|
|
80
|
+
`bundle exec rspec`
|
|
81
81
|
when "deploy"
|
|
82
82
|
project_id = Souls.configuration.project_id
|
|
83
83
|
`gcloud builds submit --config=cloudbuild.yml --project #{project_id}`
|
data/lib/souls/init.rb
CHANGED
|
@@ -244,7 +244,7 @@ module Souls
|
|
|
244
244
|
end
|
|
245
245
|
|
|
246
246
|
def model class_name: "souls"
|
|
247
|
-
file_path = "./app/models/#{class_name}.rb"
|
|
247
|
+
file_path = "./app/models/#{class_name.singularize}.rb"
|
|
248
248
|
File.open(file_path, "w") do |f|
|
|
249
249
|
f.write <<~EOS
|
|
250
250
|
class #{class_name.camelize} < ActiveRecord::Base
|
|
@@ -261,6 +261,7 @@ module Souls
|
|
|
261
261
|
float: "Float",
|
|
262
262
|
text: "String",
|
|
263
263
|
datetime: "GraphQL::Types::ISO8601DateTime",
|
|
264
|
+
date: "GraphQL::Types::ISO8601DateTime",
|
|
264
265
|
boolean: "Boolean",
|
|
265
266
|
integer: "Integer"
|
|
266
267
|
}[type.to_sym]
|
|
@@ -273,6 +274,7 @@ module Souls
|
|
|
273
274
|
string: '"MyString"',
|
|
274
275
|
text: '"MyString"',
|
|
275
276
|
datetime: "Time.now",
|
|
277
|
+
date: "Time.now",
|
|
276
278
|
boolean: false,
|
|
277
279
|
integer: 1
|
|
278
280
|
}[type.to_sym]
|
|
@@ -330,7 +332,7 @@ module Souls
|
|
|
330
332
|
new_line.write <<~EOS
|
|
331
333
|
|
|
332
334
|
def resolve **args
|
|
333
|
-
#{class_name} =
|
|
335
|
+
#{class_name} = ::#{class_name.camelize}.new args
|
|
334
336
|
if #{class_name}.save
|
|
335
337
|
{ #{class_name}: #{class_name} }
|
|
336
338
|
else
|
|
@@ -391,9 +393,9 @@ module Souls
|
|
|
391
393
|
new_line.write <<~EOS
|
|
392
394
|
|
|
393
395
|
def resolve **args
|
|
394
|
-
#{class_name} =
|
|
396
|
+
#{class_name} = ::#{class_name.camelize}.find args[:id]
|
|
395
397
|
#{class_name}.update args
|
|
396
|
-
{ #{class_name}:
|
|
398
|
+
{ #{class_name}: ::#{class_name.camelize}.find(args[:id]) }
|
|
397
399
|
rescue StandardError => error
|
|
398
400
|
GraphQL::ExecutionError.new error
|
|
399
401
|
end
|
|
@@ -422,7 +424,7 @@ module Souls
|
|
|
422
424
|
argument :id, Integer, required: true
|
|
423
425
|
|
|
424
426
|
def resolve id:
|
|
425
|
-
#{class_name} =
|
|
427
|
+
#{class_name} = ::#{class_name.camelize}.find id
|
|
426
428
|
#{class_name}.destroy
|
|
427
429
|
{ #{class_name}: #{class_name} }
|
|
428
430
|
rescue StandardError => error
|
|
@@ -436,20 +438,20 @@ module Souls
|
|
|
436
438
|
file_path
|
|
437
439
|
end
|
|
438
440
|
|
|
439
|
-
def create_confirm
|
|
440
|
-
puts "Directory already exists, Overwrite?? (Y/N)"
|
|
441
|
+
def create_confirm dir_path: ""
|
|
442
|
+
puts "Directory already exists, Overwrite?? (Y/N)\n#{dir_path}"
|
|
441
443
|
input = STDIN.gets.chomp
|
|
442
444
|
return true if input == "Y"
|
|
443
|
-
raise StandardError.new "Directory Already Exist
|
|
445
|
+
raise StandardError.new "Directory Already Exist!\n#{dir_path}"
|
|
444
446
|
end
|
|
445
447
|
|
|
446
448
|
def mutation class_name: "souls"
|
|
447
449
|
singularized_class_name = class_name.singularize
|
|
448
450
|
if Dir.exist? "./app/graphql/mutations/#{singularized_class_name}"
|
|
449
|
-
|
|
450
|
-
|
|
451
|
+
create_confirm dir_path: "./app/graphql/mutations/#{singularized_class_name}"
|
|
452
|
+
else
|
|
453
|
+
Dir.mkdir "./app/graphql/mutations/#{singularized_class_name}"
|
|
451
454
|
end
|
|
452
|
-
Dir.mkdir "./app/graphql/mutations/#{singularized_class_name}"
|
|
453
455
|
create_mutation_head class_name: singularized_class_name
|
|
454
456
|
create_mutation_params class_name: singularized_class_name
|
|
455
457
|
[
|
|
@@ -526,8 +528,9 @@ module Souls
|
|
|
526
528
|
f.each_line.with_index do |line, i|
|
|
527
529
|
if @on
|
|
528
530
|
new_line.write "\n" && break if line.include?("end") || line.include?("t.index")
|
|
531
|
+
field = "[String]" if line.include?("array: true")
|
|
529
532
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
530
|
-
field
|
|
533
|
+
field ||= type_check type
|
|
531
534
|
new_line.write " field :#{name}, #{field}, null: true\n"
|
|
532
535
|
end
|
|
533
536
|
if table_check(line: line, class_name: class_name)
|
|
@@ -576,8 +579,9 @@ module Souls
|
|
|
576
579
|
f.each_line.with_index do |line, i|
|
|
577
580
|
if @on
|
|
578
581
|
new_line.write "\n" && break if line.include?("end") || line.include?("t.index")
|
|
582
|
+
field = '["tag1", "tag2", "tag3"]' if line.include?("array: true")
|
|
579
583
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
|
580
|
-
field
|
|
584
|
+
field ||= get_test_type type
|
|
581
585
|
new_line.write " #{name} { #{field} }\n"
|
|
582
586
|
end
|
|
583
587
|
if table_check(line: line, class_name: class_name)
|
|
@@ -661,7 +665,6 @@ module Souls
|
|
|
661
665
|
end
|
|
662
666
|
|
|
663
667
|
def migrate class_name: "souls"
|
|
664
|
-
# `rake db:migrate`
|
|
665
668
|
singularized_class_name = class_name.singularize
|
|
666
669
|
model_paths = model class_name: singularized_class_name
|
|
667
670
|
type_paths = type class_name: singularized_class_name
|
|
@@ -677,21 +680,22 @@ module Souls
|
|
|
677
680
|
query: query_path,
|
|
678
681
|
mutation: mutation_path,
|
|
679
682
|
add_query_type: [
|
|
680
|
-
"field :#{singularized_class_name}, resolver: Queries::#{singularized_class_name.camelize}",
|
|
681
|
-
"field :#{singularized_class_name.pluralize}, Types::#{singularized_class_name.camelize}Type.connection_type, null: true"
|
|
683
|
+
" field :#{singularized_class_name}, resolver: Queries::#{singularized_class_name.camelize}",
|
|
684
|
+
" field :#{singularized_class_name.pluralize}, Types::#{singularized_class_name.camelize}Type.connection_type, null: true"
|
|
682
685
|
],
|
|
683
686
|
add_mutation_type: [
|
|
684
|
-
"field :create_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Create#{singularized_class_name.camelize}",
|
|
685
|
-
"field :update_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Update#{singularized_class_name.camelize}",
|
|
686
|
-
"field :delete_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Delete#{singularized_class_name.camelize}"
|
|
687
|
+
" field :create_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Create#{singularized_class_name.camelize}",
|
|
688
|
+
" field :update_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Update#{singularized_class_name.camelize}",
|
|
689
|
+
" field :delete_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Delete#{singularized_class_name.camelize}"
|
|
687
690
|
]
|
|
688
691
|
]
|
|
689
692
|
end
|
|
690
693
|
|
|
691
694
|
def migrate_all
|
|
692
695
|
puts "◆◆◆ Let's Auto Generate CRUD API ◆◆◆\n"
|
|
696
|
+
`rake db:migrate`
|
|
693
697
|
paths = get_tables.map do |class_name|
|
|
694
|
-
migrate class_name: class_name
|
|
698
|
+
migrate class_name: class_name.singularize
|
|
695
699
|
end
|
|
696
700
|
puts "\n============== Model ======================\n\n"
|
|
697
701
|
paths.each do |class_name|
|
|
@@ -741,6 +745,12 @@ module Souls
|
|
|
741
745
|
path[:add_query_type].each { |line| puts line }
|
|
742
746
|
end
|
|
743
747
|
end
|
|
748
|
+
puts "\n ## Connection Type\n\n"
|
|
749
|
+
get_tables.each do |class_name|
|
|
750
|
+
puts " def #{class_name.pluralize}"
|
|
751
|
+
puts " #{class_name.singularize.camelize}.all.order(id: :desc)"
|
|
752
|
+
puts " end\n\n"
|
|
753
|
+
end
|
|
744
754
|
puts "\n#############################################################\n"
|
|
745
755
|
puts "# #\n"
|
|
746
756
|
puts "# Add These Lines at ./app/graphql/types/mutation_type.rb #\n"
|
data/lib/souls/version.rb
CHANGED