souls 0.9.4 → 0.9.6
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/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/exe/souls +2 -4
- data/lib/souls/init.rb +113 -41
- 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: 76d16e22f896d21fad8dee314b75ddc65e42507d8fdabd494ed8f250ec785457
|
4
|
+
data.tar.gz: 022b54f4f66325a19fb8877662411d6d4d00cf667bc2c04d83222dd77bffa1da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c3a5949f7b388f5bdd8863070e2704d25f4e94bc62f7434838b24b11c2cddacbe68d009ab6d089d518e5343e3f6c40d969333c926fc445df034435418ba450a
|
7
|
+
data.tar.gz: 0d0131a7ac137d5fb15f502b2b863e7d666e7aa71796981f93b0b5c60dd1738cf6e5a40bded2e33c9fd766b2458a3d1e501f9b94716206d37c21bf163dd9210d
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/exe/souls
CHANGED
@@ -58,11 +58,9 @@ begin
|
|
58
58
|
when "type"
|
59
59
|
Souls::Init.type class_name: ARGV[2]
|
60
60
|
when "migrate"
|
61
|
-
Souls::Init.
|
61
|
+
Souls::Init.migrate class_name: ARGV[2]
|
62
62
|
when "migrate_all"
|
63
|
-
Souls::Init.
|
64
|
-
Souls::Init.migration class_name: class_name
|
65
|
-
end
|
63
|
+
Souls::Init.migrate_all
|
66
64
|
when "migration"
|
67
65
|
`rake db:create_migration NAME=#{ARGV[3]}`
|
68
66
|
when "rspec_factory"
|
data/lib/souls/init.rb
CHANGED
@@ -115,11 +115,11 @@ module Souls
|
|
115
115
|
system "cp -r #{repository_name}-#{folder}/ #{app_name}/"
|
116
116
|
system "rm -rf #{version}.tar.gz && rm -rf #{repository_name}-#{folder}"
|
117
117
|
txt = <<~TEXT
|
118
|
-
_____ ____ __ ____
|
118
|
+
_____ ____ __ ____#{' '}
|
119
119
|
/ ___// __ \\/ / / / / _____
|
120
120
|
\\__ \\/ / / / / / / / / ___/
|
121
|
-
___/ / /_/ / /_/ / /___(__ )
|
122
|
-
/____/\\____/\\____/_____/____
|
121
|
+
___/ / /_/ / /_/ / /___(__ )#{' '}
|
122
|
+
/____/\\____/\\____/_____/____/#{' '}
|
123
123
|
TEXT
|
124
124
|
puts txt
|
125
125
|
puts "=============================="
|
@@ -251,13 +251,14 @@ module Souls
|
|
251
251
|
end
|
252
252
|
EOS
|
253
253
|
end
|
254
|
-
|
254
|
+
[file_path]
|
255
255
|
end
|
256
256
|
|
257
257
|
def type_check type
|
258
258
|
{
|
259
259
|
bigint: "Integer",
|
260
260
|
string: "String",
|
261
|
+
float: "Float",
|
261
262
|
text: "String",
|
262
263
|
datetime: "GraphQL::Types::ISO8601DateTime",
|
263
264
|
boolean: "Boolean",
|
@@ -277,8 +278,8 @@ module Souls
|
|
277
278
|
end
|
278
279
|
|
279
280
|
def table_check line: "", class_name: ""
|
280
|
-
if line.include?("create_table")
|
281
|
-
return true
|
281
|
+
if line.include?("create_table") && (line.split(" ")[1].gsub("\"", "").gsub(",", "") == class_name.pluralize.to_s)
|
282
|
+
return true
|
282
283
|
end
|
283
284
|
false
|
284
285
|
end
|
@@ -341,7 +342,7 @@ module Souls
|
|
341
342
|
end
|
342
343
|
EOS
|
343
344
|
end
|
344
|
-
|
345
|
+
file_path
|
345
346
|
end
|
346
347
|
|
347
348
|
def update_mutation_head class_name: "souls"
|
@@ -398,7 +399,7 @@ module Souls
|
|
398
399
|
end
|
399
400
|
EOS
|
400
401
|
end
|
401
|
-
|
402
|
+
file_path
|
402
403
|
end
|
403
404
|
|
404
405
|
def update_mutation class_name: "souls"
|
@@ -429,7 +430,7 @@ module Souls
|
|
429
430
|
end
|
430
431
|
EOS
|
431
432
|
end
|
432
|
-
|
433
|
+
file_path
|
433
434
|
end
|
434
435
|
|
435
436
|
def create_confirm
|
@@ -442,22 +443,17 @@ module Souls
|
|
442
443
|
def mutation class_name: "souls"
|
443
444
|
singularized_class_name = class_name.singularize
|
444
445
|
if Dir.exist? "./app/graphql/mutations/#{singularized_class_name}"
|
445
|
-
create_confirm
|
446
|
+
# create_confirm
|
446
447
|
FileUtils.rm_r("./app/graphql/mutations/#{singularized_class_name}")
|
447
448
|
end
|
448
449
|
Dir.mkdir "./app/graphql/mutations/#{singularized_class_name}"
|
449
450
|
create_mutation_head class_name: singularized_class_name
|
450
451
|
create_mutation_params class_name: singularized_class_name
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
puts "\n\n"
|
457
|
-
puts "field :create_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Create#{singularized_class_name.camelize}"
|
458
|
-
puts "field :update_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Update#{singularized_class_name.camelize}"
|
459
|
-
puts "field :delete_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Delete#{singularized_class_name.camelize}"
|
460
|
-
puts "\n\n#############################################################################################################"
|
452
|
+
[
|
453
|
+
create_mutation_end(class_name: singularized_class_name),
|
454
|
+
update_mutation(class_name: singularized_class_name),
|
455
|
+
delete_mutation(class_name: singularized_class_name)
|
456
|
+
]
|
461
457
|
end
|
462
458
|
|
463
459
|
def create_query class_name: "souls"
|
@@ -477,7 +473,7 @@ module Souls
|
|
477
473
|
end
|
478
474
|
EOS
|
479
475
|
end
|
480
|
-
|
476
|
+
file_path
|
481
477
|
end
|
482
478
|
|
483
479
|
def create_queries class_name: "souls"
|
@@ -497,20 +493,13 @@ module Souls
|
|
497
493
|
end
|
498
494
|
end
|
499
495
|
EOS
|
500
|
-
|
496
|
+
file_path
|
501
497
|
end
|
502
498
|
end
|
503
499
|
|
504
500
|
def query class_name: "souls"
|
505
501
|
singularized_class_name = class_name.singularize
|
506
|
-
create_query class_name: singularized_class_name
|
507
|
-
create_queries class_name: singularized_class_name
|
508
|
-
puts "\n#############################################################################################################"
|
509
|
-
puts "\nAdd these lines at `./app/graphql/types/query_type.rb`"
|
510
|
-
puts "\n\n"
|
511
|
-
puts "field :#{singularized_class_name}, resolber: Queries::#{singularized_class_name.camelize}"
|
512
|
-
puts "field :#{singularized_class_name.pluralize}, Types::#{singularized_class_name.camelize}Type.connection_type, null: true"
|
513
|
-
puts "\n\n#############################################################################################################"
|
502
|
+
[create_query(class_name: singularized_class_name), create_queries(class_name: singularized_class_name)]
|
514
503
|
end
|
515
504
|
|
516
505
|
def create_type_head class_name: "souls"
|
@@ -555,7 +544,7 @@ module Souls
|
|
555
544
|
end
|
556
545
|
EOS
|
557
546
|
end
|
558
|
-
|
547
|
+
[file_path]
|
559
548
|
end
|
560
549
|
|
561
550
|
def type class_name: "souls"
|
@@ -604,7 +593,7 @@ module Souls
|
|
604
593
|
end
|
605
594
|
EOS
|
606
595
|
end
|
607
|
-
|
596
|
+
[file_path]
|
608
597
|
end
|
609
598
|
|
610
599
|
def rspec_factory class_name: "souls"
|
@@ -630,7 +619,7 @@ module Souls
|
|
630
619
|
end
|
631
620
|
EOS
|
632
621
|
end
|
633
|
-
|
622
|
+
[file_path]
|
634
623
|
end
|
635
624
|
|
636
625
|
def rspec_mutation class_name: "souls"
|
@@ -673,15 +662,98 @@ module Souls
|
|
673
662
|
# let's do this later
|
674
663
|
end
|
675
664
|
|
676
|
-
def
|
665
|
+
def migrate class_name: "souls"
|
677
666
|
# `rake db:migrate`
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
667
|
+
singularized_class_name = class_name.singularize
|
668
|
+
model_paths = model class_name: singularized_class_name
|
669
|
+
type_paths = type class_name: singularized_class_name
|
670
|
+
rspec_factory_paths = rspec_factory class_name: singularized_class_name
|
671
|
+
rspec_model_paths = rspec_model class_name: singularized_class_name
|
672
|
+
query_path = query class_name: singularized_class_name
|
673
|
+
mutation_path = mutation class_name: singularized_class_name
|
674
|
+
[
|
675
|
+
model: model_paths,
|
676
|
+
type: type_paths,
|
677
|
+
rspec_factory: rspec_factory_paths,
|
678
|
+
rspec_model: rspec_model_paths,
|
679
|
+
query: query_path,
|
680
|
+
mutation: mutation_path,
|
681
|
+
add_query_type: [
|
682
|
+
"field :#{singularized_class_name}, resolver: Queries::#{singularized_class_name.camelize}",
|
683
|
+
"field :#{singularized_class_name.pluralize}, Types::#{singularized_class_name.camelize}Type.connection_type, null: true"
|
684
|
+
],
|
685
|
+
add_mutation_type: [
|
686
|
+
"field :create_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Create#{singularized_class_name.camelize}",
|
687
|
+
"field :update_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Update#{singularized_class_name.camelize}",
|
688
|
+
"field :delete_#{singularized_class_name}, mutation: Mutations::#{singularized_class_name.camelize}::Delete#{singularized_class_name.camelize}"
|
689
|
+
]
|
690
|
+
]
|
691
|
+
end
|
692
|
+
|
693
|
+
def migrate_all
|
694
|
+
puts "◆◆◆ Let's Auto Generate CRUD API ◆◆◆\n"
|
695
|
+
paths = get_tables.map do |class_name|
|
696
|
+
migrate class_name: class_name
|
697
|
+
end
|
698
|
+
puts "\n============== Model ======================\n\n"
|
699
|
+
paths.each do |class_name|
|
700
|
+
class_name.each do |path|
|
701
|
+
path[:model].each { |line| puts line }
|
702
|
+
end
|
703
|
+
end
|
704
|
+
puts "\n============== Type =======================\n\n"
|
705
|
+
paths.each do |class_name|
|
706
|
+
class_name.each do |path|
|
707
|
+
path[:type].each { |line| puts line }
|
708
|
+
end
|
709
|
+
end
|
710
|
+
puts "\n============== FactoryBot =================\n\n"
|
711
|
+
paths.each do |class_name|
|
712
|
+
class_name.each do |path|
|
713
|
+
path[:rspec_factory].each { |line| puts line }
|
714
|
+
end
|
715
|
+
end
|
716
|
+
puts "\n============== RspecModel =================\n\n"
|
717
|
+
paths.each do |class_name|
|
718
|
+
class_name.each do |path|
|
719
|
+
path[:rspec_model].each { |line| puts line }
|
720
|
+
end
|
721
|
+
end
|
722
|
+
puts "\n============== Query ======================\n\n"
|
723
|
+
paths.each do |class_name|
|
724
|
+
class_name.each do |path|
|
725
|
+
path[:query].each { |line| puts line }
|
726
|
+
end
|
727
|
+
end
|
728
|
+
puts "\n============== Mutation ===================\n\n"
|
729
|
+
paths.each do |class_name|
|
730
|
+
class_name.each do |path|
|
731
|
+
path[:mutation].each { |line| puts line }
|
732
|
+
end
|
733
|
+
end
|
734
|
+
puts "\nAll files created from ./db/schema.rb"
|
735
|
+
puts "\n\n"
|
736
|
+
puts "\n##########################################################\n"
|
737
|
+
puts "# #\n"
|
738
|
+
puts "# Add These Lines at ./app/graphql/types/query_type.rb #\n"
|
739
|
+
puts "# #\n"
|
740
|
+
puts "##########################################################\n\n\n"
|
741
|
+
paths.each do |class_name|
|
742
|
+
class_name.each do |path|
|
743
|
+
path[:add_query_type].each { |line| puts line }
|
744
|
+
end
|
745
|
+
end
|
746
|
+
puts "\n#############################################################\n"
|
747
|
+
puts "# #\n"
|
748
|
+
puts "# Add These Lines at ./app/graphql/types/mutation_type.rb #\n"
|
749
|
+
puts "# #\n"
|
750
|
+
puts "#############################################################\n\n\n"
|
751
|
+
paths.each do |class_name|
|
752
|
+
class_name.each do |path|
|
753
|
+
path[:add_mutation_type].each { |line| puts line }
|
754
|
+
end
|
755
|
+
end
|
684
756
|
end
|
685
757
|
end
|
686
758
|
end
|
687
|
-
end
|
759
|
+
end
|
data/lib/souls/version.rb
CHANGED