souls 0.17.9 → 0.20.2
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/.gitignore +0 -1
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +2 -2
- data/README.md +8 -10
- data/Rakefile +17 -0
- data/config/souls.rb +4 -0
- data/db/schema.rb +67 -0
- data/exe/souls +36 -34
- data/lib/souls.rb +24 -45
- data/lib/souls/generate/app/policies/user_policy.rb +31 -0
- data/lib/souls/generate/application.rb +156 -0
- data/lib/souls/generate/model.rb +20 -0
- data/lib/souls/generate/mutation.rb +276 -0
- data/lib/souls/generate/policy.rb +51 -0
- data/lib/souls/generate/query.rb +56 -0
- data/lib/souls/generate/resolver.rb +153 -0
- data/lib/souls/generate/rspec_factory.rb +63 -0
- data/lib/souls/generate/rspec_model.rb +23 -0
- data/lib/souls/generate/rspec_mutation.rb +247 -0
- data/lib/souls/generate/rspec_policy.rb +50 -0
- data/lib/souls/generate/rspec_query.rb +169 -0
- data/lib/souls/generate/rspec_resolver.rb +189 -0
- data/lib/souls/generate/type.rb +83 -0
- data/lib/souls/init.rb +18 -1134
- data/lib/souls/version.rb +1 -1
- data/souls.gemspec +1 -1
- metadata +25 -11
- data/config/initializers/souls.rb +0 -14
- data/lib/souls/generate.rb +0 -520
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c601eafb73b63d6e33669df897351013682a7f4f125654aa34a39cdbef50a620
|
4
|
+
data.tar.gz: 56535bdf58fad20856452b4334a4982964d6d413f83a06c0f47d8c32d11e0228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 367b0ea47850a460a2a75553019fa75864ae1563fbbf64d8228125ec395d1ad7715b9783a1426e65c7ce62dc114503ee3e330a18d06216885dbbcde429ea485f
|
7
|
+
data.tar.gz: 050d94b53177c274aef211c45c75f0224feb9cae55e5f2ede1c52b7468dd54a04698071ac1f216cf16a4bff543bccef576b88a9600e571d2bc3fb4cbb8bf030a
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -26,13 +26,12 @@ This is Cloud Based APP Framework. Easy Deployment.
|
|
26
26
|
Microservices on Multi Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud. Auto deploy with scalable condition.
|
27
27
|
You can focus on business logic. No more infra problems.
|
28
28
|
|
29
|
-
SOULs creates
|
29
|
+
SOULs creates 4 types of framework.
|
30
30
|
|
31
|
-
1. API - GraphQL (Ruby) - Simple API
|
32
|
-
2.
|
33
|
-
3.
|
34
|
-
4.
|
35
|
-
5. Admin Web Client - Admin Console and CMS (TypeScript)
|
31
|
+
1. API - GraphQL (Ruby) - Simple API - Cloud Run
|
32
|
+
2. Worker - Google Pub/Sub Worker API (Ruby) - Cloud Run
|
33
|
+
3. Media Web Client - Media web client with SSG (TypeScript)
|
34
|
+
4. Admin Web Client - Admin Console and CMS (TypeScript)
|
36
35
|
|
37
36
|
## Dependency
|
38
37
|
|
@@ -71,10 +70,9 @@ And Create Your APP
|
|
71
70
|
### Choose SOULs Type:
|
72
71
|
|
73
72
|
1. API
|
74
|
-
2.
|
75
|
-
3.
|
76
|
-
4.
|
77
|
-
5. Admin Web
|
73
|
+
2. Worker
|
74
|
+
3. Media Web
|
75
|
+
4. Admin Web
|
78
76
|
|
79
77
|
|
80
78
|
## SOULs Document
|
data/Rakefile
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require "./lib/souls"
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
7
|
task :default => :spec
|
8
|
+
|
9
|
+
namespace :task do
|
10
|
+
task :g do
|
11
|
+
file_path = "./lib/souls/generate/"
|
12
|
+
Souls::SOULS_METHODS.each do |f|
|
13
|
+
FileUtils.touch "#{file_path}#{f}.rb"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
task :a do
|
18
|
+
file_path = "./spec/generate/"
|
19
|
+
Souls::SOULS_METHODS.each do |f|
|
20
|
+
FileUtils.touch "#{file_path}#{f}_spec.rb"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/config/souls.rb
ADDED
data/db/schema.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# This is Test Schema
|
2
|
+
# All the files created by this schema.rb
|
3
|
+
|
4
|
+
ActiveRecord::Schema.define(version: 20_210_308_070_947) do
|
5
|
+
enable_extension "plpgsql"
|
6
|
+
|
7
|
+
create_table "article_categories", force: :cascade do |t|
|
8
|
+
t.string "name", null: false
|
9
|
+
t.text "tags", default: [], array: true
|
10
|
+
t.boolean "is_deleted", default: false, null: false
|
11
|
+
t.datetime "created_at", precision: 6, null: false
|
12
|
+
t.datetime "updated_at", precision: 6, null: false
|
13
|
+
t.index ["is_deleted"], name: "index_article_categories_on_is_deleted"
|
14
|
+
t.index ["name"], name: "index_article_categories_on_name"
|
15
|
+
end
|
16
|
+
|
17
|
+
create_table "articles", force: :cascade do |t|
|
18
|
+
t.bigint "user_id"
|
19
|
+
t.string "title", null: false
|
20
|
+
t.text "body", default: "", null: false
|
21
|
+
t.string "thumnail_url", default: "", null: false
|
22
|
+
t.datetime "public_date", default: "2021-05-07 11:45:23", null: false
|
23
|
+
t.bigint "article_category_id", null: false
|
24
|
+
t.boolean "is_public", default: false, null: false
|
25
|
+
t.boolean "just_created", default: true, null: false
|
26
|
+
t.string "slag", null: false
|
27
|
+
t.text "tags", default: [], array: true
|
28
|
+
t.boolean "is_deleted", default: false, null: false
|
29
|
+
t.datetime "created_at", precision: 6, null: false
|
30
|
+
t.datetime "updated_at", precision: 6, null: false
|
31
|
+
t.index ["article_category_id"], name: "index_articles_on_article_category_id"
|
32
|
+
t.index ["is_deleted"], name: "index_articles_on_is_deleted"
|
33
|
+
t.index ["is_public"], name: "index_articles_on_is_public"
|
34
|
+
t.index ["slag"], name: "index_articles_on_slag", unique: true
|
35
|
+
t.index ["title"], name: "index_articles_on_title", unique: true
|
36
|
+
t.index ["user_id"], name: "index_articles_on_user_id"
|
37
|
+
end
|
38
|
+
|
39
|
+
create_table "users", force: :cascade do |t|
|
40
|
+
t.integer "retailer_uid"
|
41
|
+
t.string "uid", null: false
|
42
|
+
t.string "username", default: "", null: false
|
43
|
+
t.string "screen_name", default: "", null: false
|
44
|
+
t.string "last_name", default: "", null: false
|
45
|
+
t.string "first_name", default: "", null: false
|
46
|
+
t.string "last_name_kanji", default: "", null: false
|
47
|
+
t.string "first_name_kanji", default: "", null: false
|
48
|
+
t.string "last_name_kana", default: "", null: false
|
49
|
+
t.string "first_name_kana", default: "", null: false
|
50
|
+
t.string "email", null: false
|
51
|
+
t.string "tel", default: "", null: false
|
52
|
+
t.string "icon_url", default: "", null: false
|
53
|
+
t.string "birthday", default: "", null: false
|
54
|
+
t.string "gender", default: "", null: false
|
55
|
+
t.string "lang", default: "ja", null: false
|
56
|
+
t.string "category", default: "user", null: false
|
57
|
+
t.integer "user_role", default: 0, null: false
|
58
|
+
t.boolean "is_deleted", default: false, null: false
|
59
|
+
t.datetime "created_at", precision: 6, null: false
|
60
|
+
t.datetime "updated_at", precision: 6, null: false
|
61
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
62
|
+
t.index ["is_deleted"], name: "index_users_on_is_deleted"
|
63
|
+
t.index ["screen_name"], name: "index_users_on_screen_name"
|
64
|
+
t.index ["uid"], name: "index_users_on_uid"
|
65
|
+
t.index ["username"], name: "index_users_on_username"
|
66
|
+
end
|
67
|
+
end
|
data/exe/souls
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "souls"
|
3
|
-
|
3
|
+
begin
|
4
|
+
require "./config/souls" unless ARGV[0] == "new" || ARGV[0] == "i" || ARGV[0] == "-v"
|
5
|
+
rescue
|
6
|
+
puts "Make sure you are at SOULs APP directory!"
|
7
|
+
end
|
4
8
|
begin
|
5
9
|
case ARGV[0]
|
6
10
|
when "new"
|
11
|
+
STRAINS = ["api", "worker", "media", "admin"]
|
7
12
|
if ARGV[1].nil?
|
8
13
|
puts "you need to specify your app name \n `souls new app_name`"
|
9
14
|
exit
|
@@ -12,6 +17,7 @@ begin
|
|
12
17
|
strain = STDIN.gets.chomp.to_i
|
13
18
|
(1..4).include?(strain) ? puts("Generating SOULs.. \n") : raise(StandardError, "Choose Number 1..4")
|
14
19
|
Souls::Init.download_souls app_name: ARGV[1], repository_name: "souls_#{STRAINS[strain.to_i - 1]}"
|
20
|
+
Souls::Init.initial_config_init app_name: ARGV[1], strain: STRAINS[strain.to_i - 1]
|
15
21
|
when "s", "server"
|
16
22
|
strain = Souls.configuration.strain
|
17
23
|
case strain
|
@@ -37,8 +43,6 @@ begin
|
|
37
43
|
end
|
38
44
|
when "i", "infra"
|
39
45
|
Souls.send ARGV[1]
|
40
|
-
when "init"
|
41
|
-
Souls::Init.config_init
|
42
46
|
when "-v", "--version"
|
43
47
|
puts Souls::VERSION
|
44
48
|
when "add"
|
@@ -59,51 +63,49 @@ begin
|
|
59
63
|
when "g", "generate"
|
60
64
|
case ARGV[1]
|
61
65
|
when "test_dir"
|
62
|
-
Souls::
|
63
|
-
when "policy"
|
64
|
-
Souls::Init.policy class_name: ARGV[2]
|
65
|
-
when "rspec_policy"
|
66
|
-
Souls::Init.rspec_policy class_name: ARGV[2]
|
67
|
-
when "node_type"
|
68
|
-
Souls::Init.node_type class_name: ARGV[2]
|
69
|
-
when "resolver"
|
70
|
-
Souls::Init.resolver class_name: ARGV[2]
|
71
|
-
when "job"
|
72
|
-
Souls::Init.job class_name: ARGV[2]
|
66
|
+
Souls::Generate.test_dir
|
73
67
|
when "model"
|
74
|
-
Souls::
|
68
|
+
Souls::Generate.model class_name: ARGV[2]
|
75
69
|
when "mutation"
|
76
|
-
Souls::
|
70
|
+
Souls::Generate.mutation class_name: ARGV[2]
|
77
71
|
when "query"
|
78
|
-
Souls::
|
72
|
+
Souls::Generate.query class_name: ARGV[2]
|
79
73
|
when "type"
|
80
|
-
Souls::
|
81
|
-
when "
|
82
|
-
Souls::
|
83
|
-
when "
|
84
|
-
Souls::
|
85
|
-
when "migration"
|
86
|
-
system "rake db:create_migration NAME=create_#{ARGV[2]}"
|
74
|
+
Souls::Generate.type class_name: ARGV[2]
|
75
|
+
when "resolver"
|
76
|
+
Souls::Generate.resolver class_name: ARGV[2]
|
77
|
+
when "policy"
|
78
|
+
Souls::Generate.policy class_name: ARGV[2]
|
87
79
|
when "rspec_factory"
|
88
|
-
Souls::
|
80
|
+
Souls::Generate.rspec_factory class_name: ARGV[2]
|
89
81
|
when "rspec_model"
|
90
|
-
Souls::
|
82
|
+
Souls::Generate.rspec_model class_name: ARGV[2]
|
91
83
|
when "rspec_mutation"
|
92
|
-
Souls::
|
84
|
+
Souls::Generate.rspec_mutation class_name: ARGV[2]
|
93
85
|
when "rspec_query"
|
94
|
-
Souls::
|
95
|
-
when "rspec_type"
|
96
|
-
Souls::Init.rspec_type class_name: ARGV[2]
|
86
|
+
Souls::Generate.rspec_query class_name: ARGV[2]
|
97
87
|
when "rspec_resolver"
|
98
|
-
Souls::
|
88
|
+
Souls::Generate.rspec_resolver class_name: ARGV[2]
|
89
|
+
when "rspec_policy"
|
90
|
+
Souls::Generate.rspec_policy class_name: ARGV[2]
|
91
|
+
when "node_type"
|
92
|
+
Souls::Generate.node_type class_name: ARGV[2]
|
93
|
+
when "job"
|
94
|
+
Souls::Generate.job class_name: ARGV[2]
|
95
|
+
when "migrate"
|
96
|
+
Souls::Generate.single_migrate class_name: ARGV[2]
|
97
|
+
when "migrate_all"
|
98
|
+
Souls::Generate.migrate_all
|
99
|
+
when "migration"
|
100
|
+
system "rake db:create_migration NAME=create_#{ARGV[2]}"
|
99
101
|
else
|
100
102
|
"SOULs!"
|
101
103
|
end
|
102
104
|
when "d"
|
103
|
-
Souls::
|
105
|
+
Souls::Generate.delete_all class_name: ARGV[1]
|
104
106
|
when "update"
|
105
|
-
Souls::
|
106
|
-
Souls::
|
107
|
+
Souls::Generate.add_delete class_name: ARGV[1]
|
108
|
+
Souls::Generate.single_migrate class_name: ARGV[1]
|
107
109
|
when "db:create"
|
108
110
|
system "rake db:create && rake db:create RACK_ENV=test"
|
109
111
|
when "db:migrate"
|
data/lib/souls.rb
CHANGED
@@ -1,65 +1,43 @@
|
|
1
|
-
|
1
|
+
require_relative "souls/version"
|
2
2
|
require "active_support/core_ext/string/inflections"
|
3
|
-
|
4
|
-
require "souls/generate"
|
3
|
+
require_relative "souls/init"
|
5
4
|
require "json"
|
6
5
|
require "fileutils"
|
6
|
+
Dir["./lib/souls/generate/*.rb"].each { |f| require f }
|
7
7
|
|
8
8
|
module Souls
|
9
|
+
SOULS_METHODS = [
|
10
|
+
"model",
|
11
|
+
"query",
|
12
|
+
"mutation",
|
13
|
+
"type",
|
14
|
+
"resolver",
|
15
|
+
"policy",
|
16
|
+
"rspec_factory",
|
17
|
+
"rspec_model",
|
18
|
+
"rspec_query",
|
19
|
+
"rspec_mutation",
|
20
|
+
"rspec_resolver",
|
21
|
+
"rspec_policy"
|
22
|
+
]
|
9
23
|
class Error < StandardError; end
|
10
24
|
class << self
|
11
25
|
attr_accessor :configuration
|
12
26
|
|
13
27
|
def run_psql
|
14
|
-
|
28
|
+
system "docker run --rm -d \
|
15
29
|
-p 5433:5432 \
|
16
30
|
-v postgres-tmp:/var/lib/postgresql/data \
|
17
31
|
-e POSTGRES_USER=postgres \
|
18
32
|
-e POSTGRES_PASSWORD=postgres \
|
19
33
|
-e POSTGRES_DB=souls_test \
|
20
|
-
postgres:13-alpine
|
21
|
-
|
34
|
+
postgres:13-alpine"
|
35
|
+
system "docker ps"
|
22
36
|
end
|
23
37
|
|
24
|
-
def run_awake
|
38
|
+
def run_awake url
|
25
39
|
app = Souls.configuration.app
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def deploy_local
|
30
|
-
`docker network create --driver bridge shared`
|
31
|
-
|
32
|
-
`docker run -d --name proxy \
|
33
|
-
-p 80:80 -p 443:443 \
|
34
|
-
-v "/var/run/docker.sock:/tmp/docker.sock:ro" \
|
35
|
-
-v "$pwd/certs:/etc/nginx/certs:ro" \
|
36
|
-
-v "/etc/nginx/vhost.d" \
|
37
|
-
-v "/usr/share/nginx/html" \
|
38
|
-
--network shared \
|
39
|
-
--restart always \
|
40
|
-
jwilder/nginx-proxy`
|
41
|
-
|
42
|
-
`docker run -d --name letsencrypt \
|
43
|
-
-v "/home/certs:/etc/nginx/certs" \
|
44
|
-
-v "/var/run/docker.sock:/var/run/docker.sock:ro" \
|
45
|
-
--volumes-from proxy \
|
46
|
-
--network shared \
|
47
|
-
--restart always \
|
48
|
-
jrcs/letsencrypt-nginx-proxy-companion`
|
49
|
-
|
50
|
-
`docker run -d --name nginx \
|
51
|
-
-p 80:80 \
|
52
|
-
-e VIRTUAL_HOST=souls.el-soul.com \
|
53
|
-
-e LETSENCRYPT_HOST=souls.el-soul.com \
|
54
|
-
-e LETSENCRYPT_EMAIL=info@gmail.com \
|
55
|
-
--network shared \
|
56
|
-
--link web \
|
57
|
-
poppinfumi/ruby-nginx:latest`
|
58
|
-
|
59
|
-
`docker run -d --name web \
|
60
|
-
-p 3000:3000 \
|
61
|
-
--network shared \
|
62
|
-
poppinfumi/souls_api`
|
40
|
+
system "gcloud scheduler jobs create http #{app}-awake --schedule '0,10,20,30,40,50 * * * *' --uri #{url} --http-method GET"
|
63
41
|
end
|
64
42
|
end
|
65
43
|
|
@@ -69,10 +47,11 @@ module Souls
|
|
69
47
|
end
|
70
48
|
|
71
49
|
class Configuration
|
72
|
-
attr_accessor :app
|
50
|
+
attr_accessor :app, :strain
|
73
51
|
|
74
52
|
def initialize
|
75
53
|
@app = nil
|
54
|
+
@strain = nil
|
76
55
|
end
|
77
56
|
end
|
78
57
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class UserPolicy < ApplicationPolicy
|
2
|
+
def show?
|
3
|
+
admin_permissions?
|
4
|
+
end
|
5
|
+
|
6
|
+
def index?
|
7
|
+
admin_permissions?
|
8
|
+
end
|
9
|
+
|
10
|
+
def create?
|
11
|
+
admin_permissions?
|
12
|
+
end
|
13
|
+
|
14
|
+
def update?
|
15
|
+
admin_permissions?
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete?
|
19
|
+
admin_permissions?
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def staff_permissions?
|
25
|
+
@user.master? or @user.admin? or @user.staff?
|
26
|
+
end
|
27
|
+
|
28
|
+
def admin_permissions?
|
29
|
+
@user.master? or @user.admin?
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
module Souls
|
2
|
+
module Generate
|
3
|
+
class << self
|
4
|
+
## Common Methods
|
5
|
+
def generated_paths class_name: "user"
|
6
|
+
singularized_class_name = class_name.singularize.underscore
|
7
|
+
pluralized_class_name = class_name.pluralize.underscore
|
8
|
+
[
|
9
|
+
"./app/models/#{singularized_class_name}.rb",
|
10
|
+
"./app/policies/#{singularized_class_name}_policy.rb",
|
11
|
+
"./app/graphql/mutations/create_#{singularized_class_name}.rb",
|
12
|
+
"./app/graphql/mutations/delete_#{singularized_class_name}.rb",
|
13
|
+
"./app/graphql/mutations/destroy_delete_#{singularized_class_name}.rb",
|
14
|
+
"./app/graphql/mutations/update_#{singularized_class_name}.rb",
|
15
|
+
"./app/graphql/queries/#{singularized_class_name}.rb",
|
16
|
+
"./app/graphql/queries/#{pluralized_class_name}.rb",
|
17
|
+
"./app/graphql/resolvers/#{singularized_class_name}_search.rb",
|
18
|
+
"./app/graphql/types/#{singularized_class_name}_type.rb",
|
19
|
+
"./app/graphql/types/#{singularized_class_name}_node_type.rb",
|
20
|
+
"./spec/factories/#{pluralized_class_name}.rb",
|
21
|
+
"./spec/mutations/#{singularized_class_name}_spec.rb",
|
22
|
+
"./spec/models/#{singularized_class_name}_spec.rb",
|
23
|
+
"./spec/queries/#{singularized_class_name}_spec.rb",
|
24
|
+
"./spec/policies/#{singularized_class_name}_policy_spec.rb",
|
25
|
+
"./spec/resolvers/#{singularized_class_name}_search_spec.rb"
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_type_and_name line
|
30
|
+
line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_tables
|
34
|
+
path = "./db/schema.rb"
|
35
|
+
tables = []
|
36
|
+
File.open(path, "r") do |f|
|
37
|
+
f.each_line.with_index do |line, i|
|
38
|
+
tables << line.split("\"")[1] if line.include?("create_table")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
tables
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_dir
|
45
|
+
FileUtils.mkdir_p "./app/graphql/mutations"
|
46
|
+
FileUtils.mkdir_p "./app/graphql/queries"
|
47
|
+
FileUtils.mkdir_p "./app/graphql/types"
|
48
|
+
FileUtils.mkdir_p "./app/graphql/resolvers"
|
49
|
+
FileUtils.mkdir_p "./app/models"
|
50
|
+
FileUtils.mkdir_p "./app/policies"
|
51
|
+
FileUtils.mkdir_p "./spec/factories"
|
52
|
+
FileUtils.mkdir_p "./spec/queries"
|
53
|
+
FileUtils.mkdir_p "./spec/mutations"
|
54
|
+
FileUtils.mkdir_p "./spec/models"
|
55
|
+
FileUtils.mkdir_p "./spec/resolvers"
|
56
|
+
FileUtils.mkdir_p "./spec/policies"
|
57
|
+
FileUtils.mkdir_p "./config"
|
58
|
+
FileUtils.touch "./config/souls.rb"
|
59
|
+
FileUtils.mkdir_p "./db/"
|
60
|
+
FileUtils.touch "./db/schema.rb"
|
61
|
+
puts "test dir created!"
|
62
|
+
end
|
63
|
+
|
64
|
+
def type_check type
|
65
|
+
{
|
66
|
+
bigint: "Integer",
|
67
|
+
string: "String",
|
68
|
+
float: "Float",
|
69
|
+
text: "String",
|
70
|
+
datetime: "GraphQL::Types::ISO8601DateTime",
|
71
|
+
date: "GraphQL::Types::ISO8601DateTime",
|
72
|
+
boolean: "Boolean",
|
73
|
+
integer: "Integer"
|
74
|
+
}[type.to_sym]
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_test_type type
|
78
|
+
{
|
79
|
+
bigint: 1,
|
80
|
+
float: 4.2,
|
81
|
+
string: '"MyString"',
|
82
|
+
text: '"MyString"',
|
83
|
+
datetime: "Time.now",
|
84
|
+
date: "Time.now",
|
85
|
+
boolean: false,
|
86
|
+
integer: 1
|
87
|
+
}[type.to_sym]
|
88
|
+
end
|
89
|
+
|
90
|
+
def table_check line: "", class_name: ""
|
91
|
+
if line.include?("create_table") && (line.split(" ")[1].gsub("\"", "").gsub(",", "") == class_name.pluralize.to_s)
|
92
|
+
return true
|
93
|
+
end
|
94
|
+
false
|
95
|
+
end
|
96
|
+
|
97
|
+
def migrate class_name: "souls"
|
98
|
+
singularized_class_name = class_name.singularize
|
99
|
+
[
|
100
|
+
model: model(class_name: singularized_class_name),
|
101
|
+
types: type(class_name: singularized_class_name),
|
102
|
+
resolver: resolver(class_name: singularized_class_name),
|
103
|
+
rspec_factory: rspec_factory(class_name: singularized_class_name),
|
104
|
+
rspec_model: rspec_model(class_name: singularized_class_name),
|
105
|
+
rspec_mutation: rspec_mutation(class_name: singularized_class_name),
|
106
|
+
rspec_query: rspec_query(class_name: singularized_class_name),
|
107
|
+
rspec_resolver: rspec_resolver(class_name: singularized_class_name),
|
108
|
+
queries: query(class_name: singularized_class_name),
|
109
|
+
mutations: mutation(class_name: singularized_class_name)
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
113
|
+
def delete_all class_name: "souls"
|
114
|
+
singularized_class_name = class_name.singularize.underscore
|
115
|
+
pluralized_class_name = class_name.pluralize.underscore
|
116
|
+
FileUtils.rm "./app/models/#{singularized_class_name}.rb"
|
117
|
+
FileUtils.rm "./app/policies/#{singularized_class_name}_policy.rb"
|
118
|
+
FileUtils.rm_rf "./app/graphql/mutations/#{singularized_class_name}"
|
119
|
+
FileUtils.rm "./app/graphql/queries/#{singularized_class_name}.rb"
|
120
|
+
FileUtils.rm "./app/graphql/queries/#{pluralized_class_name}.rb"
|
121
|
+
FileUtils.rm "./app/graphql/resolvers/#{singularized_class_name}_search.rb"
|
122
|
+
FileUtils.rm "./app/graphql/types/#{singularized_class_name}_type.rb"
|
123
|
+
FileUtils.rm "./app/graphql/types/#{singularized_class_name}_node_type.rb"
|
124
|
+
FileUtils.rm "./spec/factories/#{pluralized_class_name}.rb"
|
125
|
+
FileUtils.rm "./spec/mutations/#{singularized_class_name}_spec.rb"
|
126
|
+
FileUtils.rm "./spec/models/#{singularized_class_name}_spec.rb"
|
127
|
+
FileUtils.rm "./spec/queries/#{singularized_class_name}_spec.rb"
|
128
|
+
FileUtils.rm "./spec/policies/#{singularized_class_name}_policy_spec.rb"
|
129
|
+
FileUtils.rm "./spec/resolvers/#{singularized_class_name}_search_spec.rb"
|
130
|
+
puts "deleted #{class_name.camelize} CRUD!"
|
131
|
+
rescue StandardError => error
|
132
|
+
puts error
|
133
|
+
end
|
134
|
+
|
135
|
+
def single_migrate class_name: "user"
|
136
|
+
puts "◆◆◆ Let's Auto Generate CRUD API SET ◆◆◆\n"
|
137
|
+
migrate class_name: class_name
|
138
|
+
puts "Generated #{class_name.camelize} CRUD Files\n"
|
139
|
+
Souls::Generate.generated_paths(class_name: class_name).each { |f| puts f }
|
140
|
+
puts "\nAll files created from ./db/schema.rb"
|
141
|
+
puts "\n\n"
|
142
|
+
end
|
143
|
+
|
144
|
+
def migrate_all
|
145
|
+
puts "◆◆◆ Let's Auto Generate CRUD API SET ◆◆◆\n"
|
146
|
+
get_tables.each do |class_name|
|
147
|
+
migrate class_name: class_name.singularize
|
148
|
+
puts "Generated #{class_name.camelize} CRUD Files\n"
|
149
|
+
Souls::Generate.generated_paths(class_name: class_name).each { |f| puts f }
|
150
|
+
puts "\n"
|
151
|
+
end
|
152
|
+
puts "\nAll files created from ./db/schema.rb"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|