souls 0.22.0 → 0.22.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/.gitignore +0 -1
- data/Gemfile +3 -2
- data/Gemfile.lock +8 -6
- data/README.md +1 -3
- data/exe/souls +20 -1
- data/lib/souls.rb +81 -3
- data/lib/souls/gcloud/compute.rb +14 -0
- data/lib/souls/gcloud/iam.rb +8 -0
- data/lib/souls/generate.rb +2 -0
- data/lib/souls/generate/application.rb +26 -21
- data/lib/souls/generate/connection.rb +21 -0
- data/lib/souls/generate/edge.rb +21 -0
- data/lib/souls/generate/model.rb +3 -0
- data/lib/souls/generate/mutation.rb +10 -11
- data/lib/souls/generate/policy.rb +7 -7
- data/lib/souls/generate/query.rb +10 -4
- data/lib/souls/generate/resolver.rb +4 -1
- data/lib/souls/generate/rspec_factory.rb +4 -0
- data/lib/souls/generate/rspec_model.rb +3 -0
- data/lib/souls/generate/rspec_mutation.rb +4 -0
- data/lib/souls/generate/rspec_policy.rb +8 -13
- data/lib/souls/generate/rspec_query.rb +4 -0
- data/lib/souls/generate/rspec_resolver.rb +4 -0
- data/lib/souls/generate/type.rb +7 -22
- data/lib/souls/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 528a4d39a90460bdc9a89980c07ae18301013df362646bcc39fc2bb8f24e4c3e
|
4
|
+
data.tar.gz: 8eef3a84012274225e698c8abfdde1908a1b363f38b4356eca61974e05569553
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da9769f157ced4c02c859d5630dc511c125136f7304796274a7717431bfa11c0788bf2db8dc9aacfe2757e953ae00619052a2199fedbc1be90192ed9fb4ad3f7
|
7
|
+
data.tar.gz: b1d6c97485513c180e47bf388fd4db863ece5fa657af211470025b3c796674e6894df6d6625cee41b125df51bc9f5da611217fa5b0750658f4b79e16b5e06253
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -4,8 +4,9 @@ source "https://rubygems.org"
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
gem "activesupport", "6.1.4"
|
7
|
-
gem "
|
8
|
-
gem "
|
7
|
+
gem "paint", "2.2.1"
|
8
|
+
gem "parser", "3.0.2.0"
|
9
|
+
gem "rake", "13.0.6"
|
9
10
|
gem "rspec", "3.10.0"
|
10
11
|
gem "rubocop", "1.18.3"
|
11
12
|
gem "steep", "0.44.1"
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
souls (0.
|
4
|
+
souls (0.22.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -23,11 +23,12 @@ GEM
|
|
23
23
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
24
24
|
rb-inotify (~> 0.9, >= 0.9.10)
|
25
25
|
minitest (5.14.4)
|
26
|
+
paint (2.2.1)
|
26
27
|
parallel (1.20.1)
|
27
|
-
parser (3.0.
|
28
|
+
parser (3.0.2.0)
|
28
29
|
ast (~> 2.4.1)
|
29
30
|
rainbow (3.0.0)
|
30
|
-
rake (13.0.
|
31
|
+
rake (13.0.6)
|
31
32
|
rb-fsevent (0.11.0)
|
32
33
|
rb-inotify (0.10.1)
|
33
34
|
ffi (~> 1.0)
|
@@ -80,12 +81,13 @@ PLATFORMS
|
|
80
81
|
|
81
82
|
DEPENDENCIES
|
82
83
|
activesupport (= 6.1.4)
|
83
|
-
|
84
|
-
|
84
|
+
paint (= 2.2.1)
|
85
|
+
parser (= 3.0.2.0)
|
86
|
+
rake (= 13.0.6)
|
85
87
|
rspec (= 3.10.0)
|
86
88
|
rubocop (= 1.18.3)
|
87
89
|
souls!
|
88
90
|
steep (= 0.44.1)
|
89
91
|
|
90
92
|
BUNDLED WITH
|
91
|
-
2.2.
|
93
|
+
2.2.23
|
data/README.md
CHANGED
@@ -21,9 +21,7 @@
|
|
21
21
|
|
22
22
|
Welcome to SOULs Framework!
|
23
23
|
|
24
|
-
|
25
|
-
This is Cloud Based APP Framework. Easy Deployment.
|
26
|
-
Microservices on Multi Cloud Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud. Auto deploy with scalable condition.
|
24
|
+
SOULs is a Serverless Application Framework. SOULs has four strains, API, Worker, Console, Media, and can be used in combination according to the purpose. SOULs Backend GraphQL Ruby & Frontend Relay are Scalable and Easy to deploy to Google Cloud and Amazon Web Services
|
27
25
|
You can focus on business logic. No more infra problems.
|
28
26
|
|
29
27
|
SOULs creates 4 types of framework.
|
data/exe/souls
CHANGED
@@ -47,6 +47,8 @@ begin
|
|
47
47
|
Souls::Gcloud.send ARGV[1]
|
48
48
|
when "-v", "--version"
|
49
49
|
puts Souls::VERSION
|
50
|
+
when "gem:update", "gemfile:update"
|
51
|
+
Souls.update_gemfile
|
50
52
|
when "add"
|
51
53
|
case ARGV[1]
|
52
54
|
when "mutation"
|
@@ -74,6 +76,10 @@ begin
|
|
74
76
|
Souls::Generate.query class_name: ARGV[2]
|
75
77
|
when "type"
|
76
78
|
Souls::Generate.type class_name: ARGV[2]
|
79
|
+
when "edge"
|
80
|
+
Souls::Generate.edge class_name: ARGV[2]
|
81
|
+
when "connection"
|
82
|
+
Souls::Generate.connection class_name: ARGV[2]
|
77
83
|
when "resolver"
|
78
84
|
Souls::Generate.resolver class_name: ARGV[2]
|
79
85
|
when "policy"
|
@@ -99,7 +105,8 @@ begin
|
|
99
105
|
when "migrate_all"
|
100
106
|
Souls::Generate.migrate_all
|
101
107
|
when "migration"
|
102
|
-
|
108
|
+
class_name = ARGV[2].underscore.pluralize
|
109
|
+
system "rake db:create_migration NAME=create_#{class_name}"
|
103
110
|
when "update"
|
104
111
|
Souls::Generate.update_delete class_name: ARGV[2]
|
105
112
|
Souls::Generate.single_migrate class_name: ARGV[2]
|
@@ -136,6 +143,18 @@ begin
|
|
136
143
|
else
|
137
144
|
system "rake db:migrate:reset && rake db:migrate:reset RACK_ENV=test"
|
138
145
|
end
|
146
|
+
when "db:update"
|
147
|
+
strain = Souls.configuration.strain
|
148
|
+
case strain
|
149
|
+
when "api"
|
150
|
+
other_app = Souls.configuration.worker_name
|
151
|
+
when "worker"
|
152
|
+
other_app = Souls.configuration.api_name
|
153
|
+
else
|
154
|
+
raise StandardError, "Unknown app name!"
|
155
|
+
end
|
156
|
+
system "rm -rf ../#{other_app}/db/*"
|
157
|
+
system "cp -r ./db/* ../#{other_app}/db/*"
|
139
158
|
when "t", "test"
|
140
159
|
system "rubocop -a"
|
141
160
|
system "bundle exec rspec"
|
data/lib/souls.rb
CHANGED
@@ -5,6 +5,8 @@ require_relative "souls/generate"
|
|
5
5
|
require_relative "souls/gcloud"
|
6
6
|
require "json"
|
7
7
|
require "fileutils"
|
8
|
+
require "net/http"
|
9
|
+
require "paint"
|
8
10
|
|
9
11
|
module Souls
|
10
12
|
SOULS_METHODS = [
|
@@ -39,9 +41,9 @@ module Souls
|
|
39
41
|
def run_mysql
|
40
42
|
system "docker run --rm -d \
|
41
43
|
-p 3306:3306 \
|
42
|
-
-v mysql-tmp:/var/lib/
|
44
|
+
-v mysql-tmp:/var/lib/mysql \
|
43
45
|
-e MYSQL_USER=mysql \
|
44
|
-
-e
|
46
|
+
-e MYSQL_ROOT_PASSWORD=mysql \
|
45
47
|
-e MYSQL_DB=souls_test \
|
46
48
|
mysql:latest"
|
47
49
|
system "docker ps"
|
@@ -51,6 +53,80 @@ module Souls
|
|
51
53
|
app = Souls.configuration.app
|
52
54
|
system "gcloud scheduler jobs create http #{app}-awake --schedule '0,10,20,30,40,50 * * * *' --uri #{url} --http-method GET"
|
53
55
|
end
|
56
|
+
|
57
|
+
def gemfile_latest_version
|
58
|
+
file_path = "./Gemfile"
|
59
|
+
updated_gems = []
|
60
|
+
updated_gem_versions = []
|
61
|
+
updated_lines = []
|
62
|
+
console_log = []
|
63
|
+
from_dev = false
|
64
|
+
File.open(file_path, "r") do |f|
|
65
|
+
f.each_line do |line|
|
66
|
+
from_dev = true if line.include? "group"
|
67
|
+
next unless line.include? "gem "
|
68
|
+
gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
|
69
|
+
url = URI("https://rubygems.org/api/v1/versions/#{gem[0]}/latest.json")
|
70
|
+
res = Net::HTTP.get_response(url)
|
71
|
+
data = JSON.parse res.body
|
72
|
+
next if data["version"].to_s == gem[1].to_s
|
73
|
+
updated_lines << if from_dev
|
74
|
+
" gem \"#{gem[0]}\", \"#{data["version"]}\""
|
75
|
+
else
|
76
|
+
"gem \"#{gem[0]}\", \"#{data["version"]}\""
|
77
|
+
end
|
78
|
+
updated_gems << (gem[0]).to_s
|
79
|
+
updated_gem_versions << data["version"]
|
80
|
+
system "gem update #{gem[0]}"
|
81
|
+
console_log << "#{gem[0]} v#{gem[1]} → v#{data["version"]}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
{
|
85
|
+
gems: updated_gems,
|
86
|
+
lines: updated_lines,
|
87
|
+
console_log: console_log,
|
88
|
+
updated_gem_versions: updated_gem_versions
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def update_gemfile
|
93
|
+
file_path = "./Gemfile"
|
94
|
+
tmp_file = "./tmp/Gemfile"
|
95
|
+
new_gems = gemfile_latest_version
|
96
|
+
logs = []
|
97
|
+
return "Already Up to date!" && puts("Already Up to date!") if new_gems[:gems].blank?
|
98
|
+
@i = 0
|
99
|
+
File.open(file_path, "r") do |f|
|
100
|
+
File.open(tmp_file, "w") do |new_line|
|
101
|
+
f.each_line do |line|
|
102
|
+
gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
|
103
|
+
if new_gems[:gems].include? gem[0]
|
104
|
+
logs << Paint % [
|
105
|
+
"#{gem[0]} %{yellow_text} → %{green_text}",
|
106
|
+
:blue,
|
107
|
+
{
|
108
|
+
yellow_text: ["v#{gem[1]}", :yellow],
|
109
|
+
green_text: ["v#{new_gems[:updated_gem_versions][@i]}", :green]
|
110
|
+
}
|
111
|
+
]
|
112
|
+
new_line.write "#{new_gems[:lines][@i]}\n"
|
113
|
+
@i += 1
|
114
|
+
else
|
115
|
+
new_line.write line
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
FileUtils.rm "./Gemfile"
|
121
|
+
FileUtils.rm "./Gemfile.lock"
|
122
|
+
FileUtils.mv "./tmp/Gemfile", "./Gemfile"
|
123
|
+
system "bundle update"
|
124
|
+
success = Paint["\n\nSuccessfully Updated These Gems!\n", :green]
|
125
|
+
puts success
|
126
|
+
logs.each do |line|
|
127
|
+
puts line
|
128
|
+
end
|
129
|
+
end
|
54
130
|
end
|
55
131
|
|
56
132
|
def self.configure
|
@@ -59,12 +135,14 @@ module Souls
|
|
59
135
|
end
|
60
136
|
|
61
137
|
class Configuration
|
62
|
-
attr_accessor :app, :strain, :project_id
|
138
|
+
attr_accessor :app, :strain, :project_id, :worker_name, :api_name
|
63
139
|
|
64
140
|
def initialize
|
65
141
|
@app = nil
|
66
142
|
@project_id = nil
|
67
143
|
@strain = nil
|
144
|
+
@worker_name = nil
|
145
|
+
@api_name = nil
|
68
146
|
end
|
69
147
|
end
|
70
148
|
end
|
data/lib/souls/gcloud/compute.rb
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
module Souls
|
2
2
|
module Gcloud
|
3
3
|
class << self
|
4
|
+
def auth_login
|
5
|
+
project_id = Souls.configuration.project_id
|
6
|
+
system "gcloud config set project #{project_id}"
|
7
|
+
system "gcloud auth login"
|
8
|
+
end
|
9
|
+
|
4
10
|
def enable_permissions
|
5
11
|
system "gcloud services enable compute.googleapis.com"
|
6
12
|
puts "Operating permission to compute.googleapis.com ..."
|
13
|
+
system "gcloud services enable iam.googleapis.com"
|
14
|
+
puts "Operating permission to iam.googleapis.com ..."
|
15
|
+
system "gcloud services enable dns.googleapis.com"
|
16
|
+
puts "Operating permission to dns.googleapis.com ..."
|
7
17
|
system "gcloud services enable sqladmin.googleapis.com"
|
8
18
|
puts "Operating permission to sqladmin.googleapis.com ..."
|
9
19
|
system "gcloud services enable sql-component.googleapis.com"
|
10
20
|
puts "Operating permission to sql-component.googleapis.com ..."
|
11
21
|
system "gcloud services enable servicenetworking.googleapis.com"
|
12
22
|
puts "Operating permission to servicenetworking.googleapis.com ..."
|
23
|
+
system "gcloud services enable containerregistry.googleapis.com"
|
24
|
+
puts "Operating permission to containerregistry.googleapis.com"
|
25
|
+
system "gcloud services enable run.googleapis.com"
|
26
|
+
puts "Operating permission to run.googleapis.com"
|
13
27
|
end
|
14
28
|
|
15
29
|
def create_network
|
data/lib/souls/gcloud/iam.rb
CHANGED
@@ -19,6 +19,14 @@ module Souls
|
|
19
19
|
--member="serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com" \
|
20
20
|
--role="#{role}"`
|
21
21
|
end
|
22
|
+
|
23
|
+
def add_permissions service_account: "souls-app"
|
24
|
+
self.add_service_account_role service_account: service_account, role: "roles/cloudsql.serviceAgent"
|
25
|
+
self.add_service_account_role service_account: service_account, role: "roles/containerregistry.ServiceAgent"
|
26
|
+
self.add_service_account_role service_account: service_account, role: "roles/pubsub.serviceAgent"
|
27
|
+
self.add_service_account_role service_account: service_account, role: "roles/firestore.serviceAgent"
|
28
|
+
self.add_service_account_role service_account: service_account, role: "roles/iam.serviceAccountUser"
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
data/lib/souls/generate.rb
CHANGED
@@ -12,6 +12,8 @@ require_relative "./generate/rspec_policy"
|
|
12
12
|
require_relative "./generate/rspec_query"
|
13
13
|
require_relative "./generate/rspec_resolver"
|
14
14
|
require_relative "./generate/type"
|
15
|
+
require_relative "./generate/edge"
|
16
|
+
require_relative "./generate/connection"
|
15
17
|
require_relative "./generate/application"
|
16
18
|
|
17
19
|
module Souls
|
@@ -16,7 +16,8 @@ module Souls
|
|
16
16
|
"./app/graphql/queries/#{pluralized_class_name}.rb",
|
17
17
|
"./app/graphql/resolvers/#{singularized_class_name}_search.rb",
|
18
18
|
"./app/graphql/types/#{singularized_class_name}_type.rb",
|
19
|
-
"./app/graphql/types/#{singularized_class_name}
|
19
|
+
"./app/graphql/types/edges/#{singularized_class_name}_edge.rb",
|
20
|
+
"./app/graphql/types/connections/#{singularized_class_name}_connection.rb",
|
20
21
|
"./spec/factories/#{pluralized_class_name}.rb",
|
21
22
|
"./spec/mutations/#{singularized_class_name}_spec.rb",
|
22
23
|
"./spec/models/#{singularized_class_name}_spec.rb",
|
@@ -67,8 +68,8 @@ module Souls
|
|
67
68
|
string: "String",
|
68
69
|
float: "Float",
|
69
70
|
text: "String",
|
70
|
-
datetime: "
|
71
|
-
date: "
|
71
|
+
datetime: "String",
|
72
|
+
date: "String",
|
72
73
|
boolean: "Boolean",
|
73
74
|
integer: "Integer"
|
74
75
|
}[type.to_sym]
|
@@ -96,20 +97,22 @@ module Souls
|
|
96
97
|
|
97
98
|
def migrate class_name: "souls"
|
98
99
|
singularized_class_name = class_name.singularize
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
100
|
+
model(class_name: singularized_class_name)
|
101
|
+
type(class_name: singularized_class_name)
|
102
|
+
edge(class_name: singularized_class_name)
|
103
|
+
connection(class_name: singularized_class_name)
|
104
|
+
resolver(class_name: singularized_class_name)
|
105
|
+
rspec_factory(class_name: singularized_class_name)
|
106
|
+
rspec_model(class_name: singularized_class_name)
|
107
|
+
rspec_mutation(class_name: singularized_class_name)
|
108
|
+
rspec_query(class_name: singularized_class_name)
|
109
|
+
rspec_resolver(class_name: singularized_class_name)
|
110
|
+
query(class_name: singularized_class_name)
|
111
|
+
mutation(class_name: singularized_class_name)
|
112
|
+
policy(class_name: singularized_class_name)
|
113
|
+
rspec_policy(class_name: singularized_class_name)
|
114
|
+
rescue StandardError => e
|
115
|
+
raise StandardError, e
|
113
116
|
end
|
114
117
|
|
115
118
|
def delete_all class_name: "souls"
|
@@ -122,7 +125,8 @@ module Souls
|
|
122
125
|
FileUtils.rm "./app/graphql/queries/#{pluralized_class_name}.rb"
|
123
126
|
FileUtils.rm "./app/graphql/resolvers/#{singularized_class_name}_search.rb"
|
124
127
|
FileUtils.rm "./app/graphql/types/#{singularized_class_name}_type.rb"
|
125
|
-
FileUtils.rm "./app/graphql/types/#{singularized_class_name}
|
128
|
+
FileUtils.rm "./app/graphql/types/edges/#{singularized_class_name}_edge.rb"
|
129
|
+
FileUtils.rm "./app/graphql/types/connections/#{singularized_class_name}_connection.rb"
|
126
130
|
FileUtils.rm "./spec/factories/#{pluralized_class_name}.rb"
|
127
131
|
FileUtils.rm "./spec/mutations/#{singularized_class_name}_spec.rb"
|
128
132
|
FileUtils.rm "./spec/models/#{singularized_class_name}_spec.rb"
|
@@ -142,7 +146,8 @@ module Souls
|
|
142
146
|
FileUtils.rm "./app/graphql/queries/#{pluralized_class_name}.rb"
|
143
147
|
FileUtils.rm "./app/graphql/resolvers/#{singularized_class_name}_search.rb"
|
144
148
|
FileUtils.rm "./app/graphql/types/#{singularized_class_name}_type.rb"
|
145
|
-
FileUtils.rm "./app/graphql/types/#{singularized_class_name}
|
149
|
+
FileUtils.rm "./app/graphql/types/edges/#{singularized_class_name}_edge.rb"
|
150
|
+
FileUtils.rm "./app/graphql/types/connections/#{singularized_class_name}_connection.rb"
|
146
151
|
FileUtils.rm "./spec/mutations/#{singularized_class_name}_spec.rb"
|
147
152
|
FileUtils.rm "./spec/queries/#{singularized_class_name}_spec.rb"
|
148
153
|
FileUtils.rm "./spec/resolvers/#{singularized_class_name}_search_spec.rb"
|
@@ -161,14 +166,14 @@ module Souls
|
|
161
166
|
end
|
162
167
|
|
163
168
|
def migrate_all
|
164
|
-
puts "◆◆◆
|
169
|
+
puts "◆◆◆ SOULs CRUD Assist ◆◆◆\n"
|
165
170
|
get_tables.each do |class_name|
|
166
171
|
migrate class_name: class_name.singularize
|
167
172
|
puts "Generated #{class_name.camelize} CRUD Files\n"
|
168
173
|
Souls::Generate.generated_paths(class_name: class_name).each { |f| puts f }
|
169
174
|
puts "\n"
|
170
175
|
end
|
171
|
-
puts "\nAll files created from ./db/schema.rb"
|
176
|
+
puts "\nAll files created from ./db/schema.rb\n\n You're all set ;)"
|
172
177
|
end
|
173
178
|
end
|
174
179
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Souls
|
2
|
+
module Generate
|
3
|
+
class << self
|
4
|
+
def connection class_name: "souls"
|
5
|
+
singularized_class_name = class_name.underscore.singularize
|
6
|
+
file_path = "./app/graphql/types/connections/#{singularized_class_name}_connection.rb"
|
7
|
+
File.open(file_path, "w") do |f|
|
8
|
+
f.write <<~EOS
|
9
|
+
class Types::#{singularized_class_name.camelize}Connection < Types::BaseConnection
|
10
|
+
edge_type(Types::#{singularized_class_name.camelize}Edge)
|
11
|
+
end
|
12
|
+
EOS
|
13
|
+
end
|
14
|
+
puts "Created file! : #{file_path}"
|
15
|
+
file_path
|
16
|
+
rescue StandardError => e
|
17
|
+
raise StandardError, e
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Souls
|
2
|
+
module Generate
|
3
|
+
class << self
|
4
|
+
def edge class_name: "souls"
|
5
|
+
singularized_class_name = class_name.underscore.singularize
|
6
|
+
file_path = "./app/graphql/types/edges/#{singularized_class_name}_edge.rb"
|
7
|
+
File.open(file_path, "w") do |f|
|
8
|
+
f.write <<~EOS
|
9
|
+
class Types::#{singularized_class_name.camelize}Edge < Types::BaseEdge
|
10
|
+
node_type(Types::#{singularized_class_name.camelize}Type)
|
11
|
+
end
|
12
|
+
EOS
|
13
|
+
end
|
14
|
+
puts "Created file! : #{file_path}"
|
15
|
+
file_path
|
16
|
+
rescue StandardError => e
|
17
|
+
raise StandardError, e
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/souls/generate/model.rb
CHANGED
@@ -13,7 +13,7 @@ module Souls
|
|
13
13
|
module Mutations
|
14
14
|
module #{singularized_class_name.camelize}
|
15
15
|
class Create#{singularized_class_name.camelize} < BaseMutation
|
16
|
-
field :#{singularized_class_name}_edge, Types::#{singularized_class_name.camelize}
|
16
|
+
field :#{singularized_class_name}_edge, Types::#{singularized_class_name.camelize}.edge_type, null: false
|
17
17
|
field :error, String, null: true
|
18
18
|
|
19
19
|
EOS
|
@@ -108,7 +108,7 @@ module Souls
|
|
108
108
|
module Mutations
|
109
109
|
module #{class_name.camelize}
|
110
110
|
class Update#{class_name.camelize} < BaseMutation
|
111
|
-
field :#{class_name}_edge, Types::#{class_name.camelize}
|
111
|
+
field :#{class_name}_edge, Types::#{class_name.camelize}.edge_type, null: false
|
112
112
|
|
113
113
|
argument :id, String, required: true
|
114
114
|
EOS
|
@@ -268,15 +268,14 @@ module Souls
|
|
268
268
|
create_mutation_head class_name: singularized_class_name
|
269
269
|
relation_params = create_mutation_params class_name: singularized_class_name
|
270
270
|
create_mutation_after_params class_name: singularized_class_name, relation_params: relation_params
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
puts error
|
271
|
+
create_mutation_end(class_name: singularized_class_name)
|
272
|
+
update_mutation(class_name: singularized_class_name)
|
273
|
+
delete_mutation(class_name: singularized_class_name)
|
274
|
+
destroy_delete_mutation(class_name: singularized_class_name)
|
275
|
+
puts "Created file! : #{file_path}"
|
276
|
+
file_path
|
277
|
+
rescue StandardError => e
|
278
|
+
raise StandardError, e
|
280
279
|
end
|
281
280
|
end
|
282
281
|
end
|
@@ -19,11 +19,11 @@ module Souls
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def create?
|
22
|
-
|
22
|
+
user_permissions?
|
23
23
|
end
|
24
24
|
|
25
25
|
def update?
|
26
|
-
|
26
|
+
user_permissions?
|
27
27
|
end
|
28
28
|
|
29
29
|
def delete?
|
@@ -32,8 +32,8 @@ module Souls
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
def
|
36
|
-
@user.master? or @user.admin? or @user.
|
35
|
+
def user_permissions?
|
36
|
+
@user.master? or @user.admin? or @user.user?
|
37
37
|
end
|
38
38
|
|
39
39
|
def admin_permissions?
|
@@ -42,10 +42,10 @@ module Souls
|
|
42
42
|
end
|
43
43
|
EOS
|
44
44
|
end
|
45
|
+
puts "Created file! : #{file_path}"
|
45
46
|
file_path
|
46
|
-
rescue StandardError =>
|
47
|
-
|
48
|
-
puts error.backtrace
|
47
|
+
rescue StandardError => e
|
48
|
+
raise StandardError, e
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/souls/generate/query.rb
CHANGED
@@ -20,7 +20,10 @@ module Souls
|
|
20
20
|
end
|
21
21
|
EOS
|
22
22
|
end
|
23
|
+
puts "Created file! : #{file_path}"
|
23
24
|
file_path
|
25
|
+
rescue StandardError => e
|
26
|
+
raise StandardError, e
|
24
27
|
end
|
25
28
|
|
26
29
|
def create_query class_name: "souls"
|
@@ -42,16 +45,19 @@ module Souls
|
|
42
45
|
end
|
43
46
|
end
|
44
47
|
EOS
|
48
|
+
puts "Created file! : #{file_path}"
|
45
49
|
file_path
|
50
|
+
rescue StandardError => e
|
51
|
+
raise StandardError, e
|
46
52
|
end
|
47
53
|
end
|
48
54
|
|
49
55
|
def query class_name: "souls"
|
50
56
|
singularized_class_name = class_name.singularize
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
57
|
+
create_query(class_name: singularized_class_name)
|
58
|
+
create_queries(class_name: singularized_class_name)
|
59
|
+
rescue StandardError => e
|
60
|
+
raise StandardError, e
|
55
61
|
end
|
56
62
|
end
|
57
63
|
end
|
@@ -144,8 +144,11 @@ module Souls
|
|
144
144
|
resolver_params class_name: singularized_class_name
|
145
145
|
resolver_after_params class_name: singularized_class_name
|
146
146
|
resolver_before_end class_name: singularized_class_name
|
147
|
-
# puts "File Created!\n#{file_path}"
|
148
147
|
resolver_end class_name: singularized_class_name
|
148
|
+
puts "Created file! : #{file_path}"
|
149
|
+
file_path
|
150
|
+
rescue StandardError => e
|
151
|
+
raise StandardError, e
|
149
152
|
end
|
150
153
|
end
|
151
154
|
end
|
@@ -58,6 +58,10 @@ module Souls
|
|
58
58
|
rspec_factory_head class_name: singularized_class_name
|
59
59
|
rspec_factory_params class_name: singularized_class_name
|
60
60
|
rspec_factory_end class_name: singularized_class_name
|
61
|
+
puts "Created file! : #{file_path}"
|
62
|
+
file_path
|
63
|
+
rescue StandardError => e
|
64
|
+
raise StandardError, e
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
@@ -243,6 +243,10 @@ module Souls
|
|
243
243
|
rspec_mutation_params class_name: singularized_class_name
|
244
244
|
rspec_mutation_params_response class_name: singularized_class_name
|
245
245
|
rspec_mutation_end class_name: singularized_class_name
|
246
|
+
puts "Created file! : #{file_path}"
|
247
|
+
file_path
|
248
|
+
rescue StandardError => e
|
249
|
+
raise StandardError, e
|
246
250
|
end
|
247
251
|
end
|
248
252
|
end
|
@@ -15,36 +15,31 @@ module Souls
|
|
15
15
|
let(:#{class_name.underscore}) { FactoryBot.create(:#{class_name.underscore}) }
|
16
16
|
|
17
17
|
context "being a visitor" do
|
18
|
-
let(:user) { FactoryBot.create(:user) }
|
18
|
+
let(:user) { FactoryBot.create(:user, user_role: :normal) }
|
19
19
|
|
20
20
|
it { is_expected.to permit_action(:index) }
|
21
21
|
it { is_expected.to permit_action(:show) }
|
22
22
|
it { is_expected.to forbid_actions([:create, :update, :delete]) }
|
23
23
|
end
|
24
24
|
|
25
|
-
context "being a
|
26
|
-
let(:user) { FactoryBot.create(:user, user_role:
|
27
|
-
|
28
|
-
it { is_expected.to permit_action(:index) }
|
29
|
-
it { is_expected.to permit_action(:show) }
|
30
|
-
it { is_expected.to forbid_actions([:create, :update, :delete]) }
|
31
|
-
end
|
32
|
-
|
33
|
-
context "being a staff" do
|
34
|
-
let(:user) { FactoryBot.create(:user, user_role: 3) }
|
25
|
+
context "being a user" do
|
26
|
+
let(:user) { FactoryBot.create(:user, user_role: :user) }
|
35
27
|
|
36
28
|
it { is_expected.to permit_actions([:create, :update]) }
|
37
29
|
end
|
38
30
|
|
39
|
-
context "being an
|
40
|
-
let(:user) { FactoryBot.create(:user, user_role:
|
31
|
+
context "being an admin" do
|
32
|
+
let(:user) { FactoryBot.create(:user, user_role: :admin) }
|
41
33
|
|
42
34
|
it { is_expected.to permit_actions([:create, :update, :delete]) }
|
43
35
|
end
|
44
36
|
end
|
45
37
|
EOS
|
46
38
|
end
|
39
|
+
puts "Created file! : #{file_path}"
|
47
40
|
file_path
|
41
|
+
rescue StandardError => e
|
42
|
+
raise StandardError, e
|
48
43
|
end
|
49
44
|
end
|
50
45
|
end
|
@@ -164,6 +164,10 @@ break
|
|
164
164
|
rspec_query_after_head class_name: singularized_class_name
|
165
165
|
rspec_query_params class_name: singularized_class_name
|
166
166
|
rspec_query_end class_name: singularized_class_name
|
167
|
+
puts "Created file! : #{file_path}"
|
168
|
+
file_path
|
169
|
+
rescue StandardError => e
|
170
|
+
raise StandardError, e
|
167
171
|
end
|
168
172
|
end
|
169
173
|
end
|
@@ -183,6 +183,10 @@ module Souls
|
|
183
183
|
rspec_resolver_after_head class_name: singularized_class_name
|
184
184
|
rspec_resolver_params class_name: singularized_class_name
|
185
185
|
rspec_resolver_end class_name: singularized_class_name
|
186
|
+
puts "Created file! : #{file_path}"
|
187
|
+
file_path
|
188
|
+
rescue StandardError => e
|
189
|
+
raise StandardError, e
|
186
190
|
end
|
187
191
|
end
|
188
192
|
end
|
data/lib/souls/generate/type.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module Souls
|
2
2
|
module Generate
|
3
3
|
class << self
|
4
|
-
## Generate
|
5
|
-
## 1. Type
|
6
|
-
## 2. Node Type
|
4
|
+
## Generate Type
|
7
5
|
def create_type_head class_name: "souls"
|
8
6
|
file_path = "./app/graphql/types/#{class_name}_type.rb"
|
9
7
|
File.open(file_path, "w") do |f|
|
@@ -55,30 +53,17 @@ module Souls
|
|
55
53
|
file_path
|
56
54
|
end
|
57
55
|
|
58
|
-
def node_type class_name: "souls"
|
59
|
-
file_path = "./app/graphql/types/#{class_name.singularize}_node_type.rb"
|
60
|
-
File.open(file_path, "w") do |f|
|
61
|
-
f.write <<~EOS
|
62
|
-
module Types
|
63
|
-
class #{class_name.camelize}NodeType < BaseObject
|
64
|
-
field :node, Types::#{class_name.camelize}Type, null: true
|
65
|
-
end
|
66
|
-
end
|
67
|
-
EOS
|
68
|
-
end
|
69
|
-
file_path
|
70
|
-
end
|
71
|
-
|
72
56
|
def type class_name: "souls"
|
73
57
|
singularized_class_name = class_name.singularize
|
74
|
-
file_path = "./app/graphql/types/#{singularized_class_name}
|
58
|
+
file_path = "./app/graphql/types/#{singularized_class_name}_type.rb"
|
75
59
|
return "Type already exist! #{file_path}" if File.exist? file_path
|
76
60
|
create_type_head class_name: singularized_class_name
|
77
61
|
create_type_params class_name: singularized_class_name
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
62
|
+
create_type_end class_name: singularized_class_name
|
63
|
+
puts "Created file! : #{file_path}"
|
64
|
+
file_path
|
65
|
+
rescue StandardError => e
|
66
|
+
raise StandardError, e
|
82
67
|
end
|
83
68
|
end
|
84
69
|
end
|
data/lib/souls/version.rb
CHANGED
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.22.
|
4
|
+
version: 0.22.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-07-
|
13
|
+
date: 2021-07-14 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: SOULs is a Serverless Application Framework. SOULs has four strains,
|
16
16
|
API, Worker, Console, Media, and can be used in combination according to the purpose.
|
@@ -49,6 +49,8 @@ files:
|
|
49
49
|
- lib/souls/gcloud/iam.rb
|
50
50
|
- lib/souls/generate.rb
|
51
51
|
- lib/souls/generate/application.rb
|
52
|
+
- lib/souls/generate/connection.rb
|
53
|
+
- lib/souls/generate/edge.rb
|
52
54
|
- lib/souls/generate/model.rb
|
53
55
|
- lib/souls/generate/mutation.rb
|
54
56
|
- lib/souls/generate/policy.rb
|