souls 0.28.12 → 0.29.3
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/exe/souls +41 -12
- data/lib/souls.rb +3 -27
- data/lib/souls/api.rb +5 -0
- data/lib/souls/{generate.rb → api/generate.rb} +3 -2
- data/lib/souls/{generate → api/generate}/application.rb +9 -1
- data/lib/souls/{generate → api/generate}/connection.rb +1 -1
- data/lib/souls/{generate → api/generate}/edge.rb +1 -1
- data/lib/souls/api/generate/manager.rb +26 -0
- data/lib/souls/api/generate/migration.rb +10 -0
- data/lib/souls/api/generate/model.rb +24 -0
- data/lib/souls/{generate → api/generate}/mutation.rb +1 -1
- data/lib/souls/{generate → api/generate}/policy.rb +1 -1
- data/lib/souls/{generate → api/generate}/query.rb +1 -1
- data/lib/souls/{generate → api/generate}/resolver.rb +7 -3
- data/lib/souls/{generate → api/generate}/rspec_factory.rb +1 -1
- data/lib/souls/{generate → api/generate}/rspec_model.rb +1 -1
- data/lib/souls/{generate → api/generate}/rspec_mutation.rb +19 -6
- data/lib/souls/{generate → api/generate}/rspec_policy.rb +1 -1
- data/lib/souls/{generate → api/generate}/rspec_query.rb +1 -1
- data/lib/souls/{generate → api/generate}/rspec_resolver.rb +1 -1
- data/lib/souls/{generate → api/generate}/type.rb +0 -0
- data/lib/souls/docker.rb +5 -0
- data/lib/souls/docker/docker.rb +31 -0
- data/lib/souls/gcloud/iam.rb +2 -2
- 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
- data/lib/souls/worker.rb +6 -0
- data/lib/souls/worker/generate.rb +7 -0
- data/lib/souls/worker/generate/application.rb +150 -0
- data/lib/souls/worker/generate/mailer.rb +59 -0
- metadata +27 -19
- data/lib/souls/generate/methods.rb +0 -64
- data/lib/souls/generate/model.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 676dd947f68cd5f0fc4d8971a560308151010d39fcb71bd07d2f7c5bb5d9410f
|
4
|
+
data.tar.gz: c1216a0b9cbf4a35722728164caa4cdf4a11b7ea4749a5de290cea66cb0ecb65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 271aaf367d445863910ed8973cfb7cbcb8fcad5fa05d64ce985b67d2042dcf333c4aa2c600a7de0ce299fdc660bc37c5036444e8512c19fdfd8e61ced4a1903e
|
7
|
+
data.tar.gz: c47be0a5c8489bc71155bb46b15ded04aa5ef761298edd1c72ed6b401dbd0c7336df2939debdf37f61d7c91c016e505fae5ffc611f210912f952c3e681c95273
|
data/exe/souls
CHANGED
@@ -1,13 +1,43 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "souls"
|
3
3
|
begin
|
4
|
-
|
4
|
+
souls_command = ARGV[0]
|
5
|
+
require("./config/souls") unless ["new", "i", "-v", "deploy"].include?(souls_command)
|
5
6
|
rescue StandardError
|
6
7
|
puts("Make sure you are at SOULs APP directory!")
|
7
8
|
end
|
8
9
|
begin
|
9
|
-
souls_command = ARGV[0]
|
10
10
|
case souls_command
|
11
|
+
when "api"
|
12
|
+
api_command = ARGV[1]
|
13
|
+
case api_command
|
14
|
+
when "generate", "g"
|
15
|
+
method_name = ARGV[2]
|
16
|
+
class_name = ARGV[3]
|
17
|
+
status = Paint["Running SOULs Generate Commands...", :yellow]
|
18
|
+
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
19
|
+
Whirly.status = status
|
20
|
+
Souls::Api::Generate.public_send(method_name, class_name: class_name)
|
21
|
+
Whirly.status = "Done!"
|
22
|
+
end
|
23
|
+
else
|
24
|
+
puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
|
25
|
+
end
|
26
|
+
when "worker"
|
27
|
+
api_command = ARGV[1]
|
28
|
+
case api_command
|
29
|
+
when "generate", "g"
|
30
|
+
method_name = ARGV[2]
|
31
|
+
class_name = ARGV[3]
|
32
|
+
status = Paint["Running SOULs Generate Commands...", :yellow]
|
33
|
+
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
34
|
+
Whirly.status = status
|
35
|
+
Souls::Worker::Generate.public_send(method_name, class_name: class_name)
|
36
|
+
Whirly.status = "Done!"
|
37
|
+
end
|
38
|
+
else
|
39
|
+
puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
|
40
|
+
end
|
11
41
|
when "new"
|
12
42
|
args = ARGV
|
13
43
|
Souls::Init.return_method(args)
|
@@ -27,9 +57,9 @@ begin
|
|
27
57
|
system("bundle exec irb")
|
28
58
|
end
|
29
59
|
end
|
30
|
-
when "i", "infra"
|
60
|
+
when "i", "infra", "docker"
|
31
61
|
send_method = ARGV[1]
|
32
|
-
Souls.public_send(send_method)
|
62
|
+
Souls::Docker.public_send(send_method)
|
33
63
|
when "gcloud"
|
34
64
|
args = ARGV
|
35
65
|
status = Paint["Running Gcloud Commands...", :yellow]
|
@@ -73,17 +103,16 @@ begin
|
|
73
103
|
puts(Paint["Wrong Argument!", :red])
|
74
104
|
end
|
75
105
|
when "g", "generate"
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
Whirly.status = done
|
106
|
+
g_command = ARGV[1]
|
107
|
+
case g_command
|
108
|
+
when "worker"
|
109
|
+
Souls::Init.download_worker
|
110
|
+
else
|
111
|
+
puts(Paint["Coming Soon...", :green])
|
83
112
|
end
|
84
113
|
when "d", "delete"
|
85
114
|
class_name = ARGV[1]
|
86
|
-
Souls::Generate.delete_all(class_name: class_name)
|
115
|
+
Souls::Api::Generate.delete_all(class_name: class_name)
|
87
116
|
when "db:create"
|
88
117
|
rack_env = ARGV[1]
|
89
118
|
case rack_env
|
data/lib/souls.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require_relative "souls/version"
|
2
2
|
require "active_support/core_ext/string/inflections"
|
3
3
|
require_relative "souls/init"
|
4
|
-
require_relative "souls/
|
4
|
+
require_relative "souls/api"
|
5
|
+
require_relative "souls/worker"
|
5
6
|
require_relative "souls/gcloud"
|
6
7
|
require_relative "souls/release"
|
8
|
+
require_relative "souls/docker"
|
7
9
|
require "date"
|
8
10
|
require "dotenv/load"
|
9
11
|
require "json"
|
@@ -33,32 +35,6 @@ module Souls
|
|
33
35
|
class << self
|
34
36
|
attr_accessor :configuration
|
35
37
|
|
36
|
-
def psql
|
37
|
-
system(
|
38
|
-
"docker run --rm -d \
|
39
|
-
-p 5433:5432 \
|
40
|
-
-v postgres-tmp:/var/lib/postgresql/data \
|
41
|
-
-e POSTGRES_USER=postgres \
|
42
|
-
-e POSTGRES_PASSWORD=postgres \
|
43
|
-
-e POSTGRES_DB=souls_test \
|
44
|
-
postgres:13-alpine"
|
45
|
-
)
|
46
|
-
system("docker ps")
|
47
|
-
end
|
48
|
-
|
49
|
-
def mysql
|
50
|
-
system(
|
51
|
-
"docker run --rm -d \
|
52
|
-
-p 3306:3306 \
|
53
|
-
-v mysql-tmp:/var/lib/mysql \
|
54
|
-
-e MYSQL_USER=mysql \
|
55
|
-
-e MYSQL_ROOT_PASSWORD=mysql \
|
56
|
-
-e MYSQL_DB=souls_test \
|
57
|
-
mysql:latest"
|
58
|
-
)
|
59
|
-
system("docker ps")
|
60
|
-
end
|
61
|
-
|
62
38
|
def gemfile_latest_version
|
63
39
|
file_path = "./Gemfile"
|
64
40
|
updated_gems = []
|
data/lib/souls/api.rb
ADDED
@@ -15,9 +15,10 @@ require_relative "./generate/type"
|
|
15
15
|
require_relative "./generate/edge"
|
16
16
|
require_relative "./generate/connection"
|
17
17
|
require_relative "./generate/application"
|
18
|
-
require_relative "./generate/
|
18
|
+
require_relative "./generate/migration"
|
19
|
+
require_relative "./generate/manager"
|
19
20
|
|
20
21
|
module Souls
|
21
|
-
module Generate
|
22
|
+
module Api::Generate
|
22
23
|
end
|
23
24
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Souls
|
2
|
-
module Generate
|
2
|
+
module Api::Generate
|
3
3
|
## Common Methods
|
4
4
|
def self.generated_paths(class_name: "user")
|
5
5
|
singularized_class_name = class_name.singularize.underscore
|
@@ -116,6 +116,14 @@ module Souls
|
|
116
116
|
raise(StandardError, e)
|
117
117
|
end
|
118
118
|
|
119
|
+
def self.migrate_all
|
120
|
+
puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
|
121
|
+
Souls::Api::Generate.get_tables.each do |table|
|
122
|
+
Souls::Api::Generate.migrate(class_name: table.singularize)
|
123
|
+
puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
119
127
|
def self.delete_all(class_name: "souls")
|
120
128
|
singularized_class_name = class_name.singularize.underscore
|
121
129
|
pluralized_class_name = class_name.pluralize.underscore
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api::Generate
|
3
|
+
def self.manager(class_name: "souls")
|
4
|
+
singularized_class_name = class_name.underscore.singularize
|
5
|
+
file_dir = "./app/graphql/mutations/managers/#{singularized_class_name}_manager"
|
6
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
7
|
+
file_path = "#{file_dir}/#{singularized_class_name}.rb"
|
8
|
+
File.open(file_path, "w") do |f|
|
9
|
+
f.write(<<~TEXT)
|
10
|
+
class Types::#{singularized_class_name.camelize}Edge < module Mutations
|
11
|
+
module Mailers
|
12
|
+
class #{singularized_class_name.camelize}Mailer < BaseMutation
|
13
|
+
description "Mail を送信します。"
|
14
|
+
field :response, String, null: false
|
15
|
+
|
16
|
+
node_type(Types::#{singularized_class_name.camelize}Type)
|
17
|
+
end
|
18
|
+
TEXT
|
19
|
+
end
|
20
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
21
|
+
file_path
|
22
|
+
rescue StandardError => e
|
23
|
+
raise(StandardError, e)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Souls
|
2
|
+
module Api
|
3
|
+
module Generate
|
4
|
+
## Generate Model
|
5
|
+
def self.model(class_name: "souls")
|
6
|
+
file_dir = "./app/models/"
|
7
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
8
|
+
file_path = "#{file_dir}#{class_name.singularize}.rb"
|
9
|
+
return "Model already exist! #{file_path}" if File.exist?(file_path)
|
10
|
+
|
11
|
+
File.open(file_path, "w") do |f|
|
12
|
+
f.write(<<~TEXT)
|
13
|
+
class #{class_name.camelize} < ActiveRecord::Base
|
14
|
+
end
|
15
|
+
TEXT
|
16
|
+
end
|
17
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
18
|
+
file_path
|
19
|
+
rescue StandardError => e
|
20
|
+
raise(StandardError, e)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Souls
|
2
|
-
module Generate
|
2
|
+
module Api::Generate
|
3
3
|
## Generate Resolver
|
4
4
|
def self.resolver_head(class_name: "souls")
|
5
5
|
FileUtils.mkdir_p("./app/graphql/resolvers") unless Dir.exist?("./app/graphql/resolvers")
|
@@ -90,7 +90,9 @@ module Souls
|
|
90
90
|
|
91
91
|
type, name = get_type_and_name(line)
|
92
92
|
if line.include?("array: true")
|
93
|
-
new_line.write(
|
93
|
+
new_line.write(
|
94
|
+
" scope = scope.where(\"#{name} @> ARRAY[?]::text[]\", value[:#{name}]) if value[:#{name}]\n"
|
95
|
+
)
|
94
96
|
next
|
95
97
|
end
|
96
98
|
case name
|
@@ -98,7 +100,9 @@ module Souls
|
|
98
100
|
@user_exist = true
|
99
101
|
when /$*_id\z/
|
100
102
|
@relation_params << name
|
101
|
-
new_line.write(
|
103
|
+
new_line.write(
|
104
|
+
" scope = scope.where(#{name}: decode_global_key(value[:#{name}])) if value[:#{name}]\n"
|
105
|
+
)
|
102
106
|
when "created_at", "updated_at"
|
103
107
|
next
|
104
108
|
else
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Souls
|
2
|
-
module Generate
|
2
|
+
module Api::Generate
|
3
3
|
## Generate Rspec Mutation
|
4
4
|
def self.rspec_mutation_head(class_name: "souls")
|
5
5
|
file_dir = "./spec/mutations/base/"
|
@@ -73,7 +73,9 @@ module Souls
|
|
73
73
|
f.each_line.with_index do |line, _i|
|
74
74
|
if @on
|
75
75
|
if line.include?("t.index") || line.strip == "end"
|
76
|
-
new_line.write(
|
76
|
+
new_line.write(
|
77
|
+
" }) {\n #{class_name.singularize.camelize(:lower)}Edge {\n node {\n"
|
78
|
+
)
|
77
79
|
new_line.write(" id\n")
|
78
80
|
break
|
79
81
|
end
|
@@ -85,17 +87,28 @@ module Souls
|
|
85
87
|
when "user_id"
|
86
88
|
@user_exist = true
|
87
89
|
when /$*_id\z/
|
88
|
-
|
90
|
+
camel = name.singularize.camelize(:lower)
|
91
|
+
new_line.write(
|
92
|
+
" #{camel}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
93
|
+
)
|
89
94
|
else
|
90
95
|
case type
|
91
96
|
when "string", "text", "date", "datetime"
|
97
|
+
camel = name.singularize.camelize(:lower)
|
98
|
+
camels = name.pluralize.camelize(:lower)
|
92
99
|
if array_true
|
93
|
-
new_line.write(
|
100
|
+
new_line.write(
|
101
|
+
" #{camels}: \#{#{class_name.singularize}[:#{name.pluralize.underscore}]}\n"
|
102
|
+
)
|
94
103
|
else
|
95
|
-
new_line.write(
|
104
|
+
new_line.write(
|
105
|
+
" #{camel}: \"\#{#{class_name.singularize}[:#{name.singularize.underscore}]}\"\n"
|
106
|
+
)
|
96
107
|
end
|
97
108
|
when "bigint", "integer", "float", "boolean"
|
98
|
-
new_line.write(
|
109
|
+
new_line.write(
|
110
|
+
" #{camel}: \#{#{class_name.singularize}[:#{name.singularize.underscore}]}\n"
|
111
|
+
)
|
99
112
|
end
|
100
113
|
end
|
101
114
|
end
|
File without changes
|
data/lib/souls/docker.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Souls
|
2
|
+
module Docker
|
3
|
+
class << self
|
4
|
+
def psql
|
5
|
+
system(
|
6
|
+
"docker run --rm -d \
|
7
|
+
-p 5433:5432 \
|
8
|
+
-v postgres-tmp:/var/lib/postgresql/data \
|
9
|
+
-e POSTGRES_USER=postgres \
|
10
|
+
-e POSTGRES_PASSWORD=postgres \
|
11
|
+
-e POSTGRES_DB=souls_test \
|
12
|
+
postgres:13-alpine"
|
13
|
+
)
|
14
|
+
system("docker ps")
|
15
|
+
end
|
16
|
+
|
17
|
+
def mysql
|
18
|
+
system(
|
19
|
+
"docker run --rm -d \
|
20
|
+
-p 3306:3306 \
|
21
|
+
-v mysql-tmp:/var/lib/mysql \
|
22
|
+
-e MYSQL_USER=mysql \
|
23
|
+
-e MYSQL_ROOT_PASSWORD=mysql \
|
24
|
+
-e MYSQL_DB=souls_test \
|
25
|
+
mysql:latest"
|
26
|
+
)
|
27
|
+
system("docker ps")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/souls/gcloud/iam.rb
CHANGED
@@ -63,8 +63,8 @@ module Souls
|
|
63
63
|
roles = [
|
64
64
|
"roles/cloudsql.instanceUser",
|
65
65
|
"roles/containerregistry.ServiceAgent",
|
66
|
-
"roles/pubsub.
|
67
|
-
"roles/firestore.
|
66
|
+
"roles/pubsub.serviceAdmin",
|
67
|
+
"roles/firestore.serviceAdmin",
|
68
68
|
"roles/iam.serviceAccountUser",
|
69
69
|
"roles/storage.objectAdmin",
|
70
70
|
"roles/run.admin"
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.3
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.3
|
data/lib/souls/worker.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
module Souls
|
2
|
+
module Worker
|
3
|
+
module Generate
|
4
|
+
## Common Methods
|
5
|
+
def self.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/edges/#{singularized_class_name}_edge.rb",
|
20
|
+
"./app/graphql/types/connections/#{singularized_class_name}_connection.rb",
|
21
|
+
"./spec/factories/#{pluralized_class_name}.rb",
|
22
|
+
"./spec/mutations/#{singularized_class_name}_spec.rb",
|
23
|
+
"./spec/models/#{singularized_class_name}_spec.rb",
|
24
|
+
"./spec/queries/#{singularized_class_name}_spec.rb",
|
25
|
+
"./spec/policies/#{singularized_class_name}_policy_spec.rb",
|
26
|
+
"./spec/resolvers/#{singularized_class_name}_search_spec.rb"
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.get_type_and_name(line)
|
31
|
+
line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.get_tables
|
35
|
+
path = "./db/schema.rb"
|
36
|
+
tables = []
|
37
|
+
File.open(path, "r") do |f|
|
38
|
+
f.each_line.with_index do |line, _i|
|
39
|
+
tables << line.split("\"")[1] if line.include?("create_table")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
tables
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.type_check(type)
|
46
|
+
{
|
47
|
+
bigint: "Integer",
|
48
|
+
string: "String",
|
49
|
+
float: "Float",
|
50
|
+
text: "String",
|
51
|
+
datetime: "String",
|
52
|
+
date: "String",
|
53
|
+
boolean: "Boolean",
|
54
|
+
integer: "Integer"
|
55
|
+
}[type.to_sym]
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.get_test_type(type)
|
59
|
+
{
|
60
|
+
bigint: 1,
|
61
|
+
float: 4.2,
|
62
|
+
string: '"MyString"',
|
63
|
+
text: '"MyString"',
|
64
|
+
datetime: "Time.now",
|
65
|
+
date: "Time.now",
|
66
|
+
boolean: false,
|
67
|
+
integer: 1
|
68
|
+
}[type.to_sym]
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.table_check(line: "", class_name: "")
|
72
|
+
if line.include?("create_table") && (line.split[1].gsub("\"", "").gsub(",", "") == class_name.pluralize.to_s)
|
73
|
+
|
74
|
+
return true
|
75
|
+
end
|
76
|
+
|
77
|
+
false
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.migrate(class_name: "souls")
|
81
|
+
singularized_class_name = class_name.singularize
|
82
|
+
model(class_name: singularized_class_name)
|
83
|
+
type(class_name: singularized_class_name)
|
84
|
+
edge(class_name: singularized_class_name)
|
85
|
+
connection(class_name: singularized_class_name)
|
86
|
+
resolver(class_name: singularized_class_name)
|
87
|
+
rspec_factory(class_name: singularized_class_name)
|
88
|
+
rspec_model(class_name: singularized_class_name)
|
89
|
+
rspec_mutation(class_name: singularized_class_name)
|
90
|
+
rspec_query(class_name: singularized_class_name)
|
91
|
+
rspec_resolver(class_name: singularized_class_name)
|
92
|
+
query(class_name: singularized_class_name)
|
93
|
+
mutation(class_name: singularized_class_name)
|
94
|
+
policy(class_name: singularized_class_name)
|
95
|
+
rspec_policy(class_name: singularized_class_name)
|
96
|
+
rescue StandardError => e
|
97
|
+
raise(StandardError, e)
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.migrate_all
|
101
|
+
puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
|
102
|
+
Souls::Api::Generate.get_tables.each do |table|
|
103
|
+
Souls::Api::Generate.migrate(class_name: table.singularize)
|
104
|
+
puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.delete_all(class_name: "souls")
|
109
|
+
singularized_class_name = class_name.singularize.underscore
|
110
|
+
pluralized_class_name = class_name.pluralize.underscore
|
111
|
+
FileUtils.rm("./app/models/#{singularized_class_name}.rb")
|
112
|
+
FileUtils.rm("./app/policies/#{singularized_class_name}_policy.rb")
|
113
|
+
FileUtils.rm_rf("./app/graphql/mutations/base/#{singularized_class_name}")
|
114
|
+
FileUtils.rm("./app/graphql/queries/#{singularized_class_name}.rb")
|
115
|
+
FileUtils.rm("./app/graphql/queries/#{pluralized_class_name}.rb")
|
116
|
+
FileUtils.rm("./app/graphql/resolvers/#{singularized_class_name}_search.rb")
|
117
|
+
FileUtils.rm("./app/graphql/types/#{singularized_class_name}_type.rb")
|
118
|
+
FileUtils.rm("./app/graphql/types/edges/#{singularized_class_name}_edge.rb")
|
119
|
+
FileUtils.rm("./app/graphql/types/connections/#{singularized_class_name}_connection.rb")
|
120
|
+
FileUtils.rm("./spec/factories/#{pluralized_class_name}.rb")
|
121
|
+
FileUtils.rm("./spec/mutations/base/#{singularized_class_name}_spec.rb")
|
122
|
+
FileUtils.rm("./spec/models/#{singularized_class_name}_spec.rb")
|
123
|
+
FileUtils.rm("./spec/queries/#{singularized_class_name}_spec.rb")
|
124
|
+
FileUtils.rm("./spec/policies/#{singularized_class_name}_policy_spec.rb")
|
125
|
+
FileUtils.rm("./spec/resolvers/#{singularized_class_name}_search_spec.rb")
|
126
|
+
puts(Paint["deleted #{class_name.camelize} CRUD!", :yellow])
|
127
|
+
rescue StandardError => e
|
128
|
+
raise(StandardError, e)
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.update_delete(class_name: "souls")
|
132
|
+
singularized_class_name = class_name.singularize.underscore
|
133
|
+
pluralized_class_name = class_name.pluralize.underscore
|
134
|
+
FileUtils.rm_rf("./app/graphql/mutations/#{singularized_class_name}")
|
135
|
+
FileUtils.rm("./app/graphql/queries/#{singularized_class_name}.rb")
|
136
|
+
FileUtils.rm("./app/graphql/queries/#{pluralized_class_name}.rb")
|
137
|
+
FileUtils.rm("./app/graphql/resolvers/#{singularized_class_name}_search.rb")
|
138
|
+
FileUtils.rm("./app/graphql/types/#{singularized_class_name}_type.rb")
|
139
|
+
FileUtils.rm("./app/graphql/types/edges/#{singularized_class_name}_edge.rb")
|
140
|
+
FileUtils.rm("./app/graphql/types/connections/#{singularized_class_name}_connection.rb")
|
141
|
+
FileUtils.rm("./spec/mutations/#{singularized_class_name}_spec.rb")
|
142
|
+
FileUtils.rm("./spec/queries/#{singularized_class_name}_spec.rb")
|
143
|
+
FileUtils.rm("./spec/resolvers/#{singularized_class_name}_search_spec.rb")
|
144
|
+
puts("deleted #{class_name.camelize} CRUD!")
|
145
|
+
rescue StandardError => e
|
146
|
+
raise(StandardError, e)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Souls
|
2
|
+
module Worker
|
3
|
+
module Generate
|
4
|
+
class << self
|
5
|
+
def mailer(class_name: "mailer", option: :mailgun)
|
6
|
+
if option == :sendgrid
|
7
|
+
sendgrid_mailer(class_name: class_name)
|
8
|
+
else
|
9
|
+
mailgun_mailer(class_name: class_name)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def mailgun_mailer(class_name: "mailer")
|
16
|
+
file_dir = "./app/graphql/mutations/mailers/"
|
17
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
18
|
+
file_path = "#{file_dir}#{class_name.singularize}_mailer.rb"
|
19
|
+
raise(StandardError, "Mailer already exist! #{file_path}") if File.exist?(file_path)
|
20
|
+
|
21
|
+
File.open(file_path, "w") do |f|
|
22
|
+
f.write(<<~TEXT)
|
23
|
+
module Mutations
|
24
|
+
module Mailers
|
25
|
+
class #{class_name.camelize}Mailer < BaseMutation
|
26
|
+
description "Mail を送信します。"
|
27
|
+
field :response, String, null: false
|
28
|
+
|
29
|
+
def resolve
|
30
|
+
# First, instantiate the Mailgun Client with your API key
|
31
|
+
mg_client = ::Mailgun::Client.new("YOUR-API-KEY")
|
32
|
+
|
33
|
+
# Define your message parameters
|
34
|
+
message_params = {
|
35
|
+
from: "postmaster@YOUR-DOMAIN",
|
36
|
+
to: "sending@to.mail.com",
|
37
|
+
subject: "SOULs Mailer test!",
|
38
|
+
text: "It is really easy to send a message!"
|
39
|
+
}
|
40
|
+
|
41
|
+
# Send your message through the client
|
42
|
+
mg_client.send_message("YOUR-MAILGUN-DOMAIN", message_params)
|
43
|
+
{ response: "Job done!" }
|
44
|
+
rescue StandardError => e
|
45
|
+
GraphQL::ExecutionError.new(e.to_s)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
TEXT
|
50
|
+
end
|
51
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
52
|
+
file_path
|
53
|
+
end
|
54
|
+
|
55
|
+
def sendgrid_mailer; end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
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.
|
4
|
+
version: 0.29.3
|
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-08-
|
13
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -101,35 +101,43 @@ files:
|
|
101
101
|
- README.md
|
102
102
|
- exe/souls
|
103
103
|
- lib/souls.rb
|
104
|
+
- lib/souls/api.rb
|
105
|
+
- lib/souls/api/generate.rb
|
106
|
+
- lib/souls/api/generate/application.rb
|
107
|
+
- lib/souls/api/generate/connection.rb
|
108
|
+
- lib/souls/api/generate/edge.rb
|
109
|
+
- lib/souls/api/generate/manager.rb
|
110
|
+
- lib/souls/api/generate/migration.rb
|
111
|
+
- lib/souls/api/generate/model.rb
|
112
|
+
- lib/souls/api/generate/mutation.rb
|
113
|
+
- lib/souls/api/generate/policy.rb
|
114
|
+
- lib/souls/api/generate/query.rb
|
115
|
+
- lib/souls/api/generate/resolver.rb
|
116
|
+
- lib/souls/api/generate/rspec_factory.rb
|
117
|
+
- lib/souls/api/generate/rspec_model.rb
|
118
|
+
- lib/souls/api/generate/rspec_mutation.rb
|
119
|
+
- lib/souls/api/generate/rspec_policy.rb
|
120
|
+
- lib/souls/api/generate/rspec_query.rb
|
121
|
+
- lib/souls/api/generate/rspec_resolver.rb
|
122
|
+
- lib/souls/api/generate/type.rb
|
123
|
+
- lib/souls/docker.rb
|
124
|
+
- lib/souls/docker/docker.rb
|
104
125
|
- lib/souls/gcloud.rb
|
105
126
|
- lib/souls/gcloud/compute.rb
|
106
127
|
- lib/souls/gcloud/iam.rb
|
107
128
|
- lib/souls/gcloud/methods.rb
|
108
129
|
- lib/souls/gcloud/pubsub.rb
|
109
130
|
- lib/souls/gcloud/run.rb
|
110
|
-
- lib/souls/generate.rb
|
111
|
-
- lib/souls/generate/application.rb
|
112
|
-
- lib/souls/generate/connection.rb
|
113
|
-
- lib/souls/generate/edge.rb
|
114
|
-
- lib/souls/generate/methods.rb
|
115
|
-
- lib/souls/generate/model.rb
|
116
|
-
- lib/souls/generate/mutation.rb
|
117
|
-
- lib/souls/generate/policy.rb
|
118
|
-
- lib/souls/generate/query.rb
|
119
|
-
- lib/souls/generate/resolver.rb
|
120
|
-
- lib/souls/generate/rspec_factory.rb
|
121
|
-
- lib/souls/generate/rspec_model.rb
|
122
|
-
- lib/souls/generate/rspec_mutation.rb
|
123
|
-
- lib/souls/generate/rspec_policy.rb
|
124
|
-
- lib/souls/generate/rspec_query.rb
|
125
|
-
- lib/souls/generate/rspec_resolver.rb
|
126
|
-
- lib/souls/generate/type.rb
|
127
131
|
- lib/souls/init.rb
|
128
132
|
- lib/souls/release.rb
|
129
133
|
- lib/souls/release/methods.rb
|
130
134
|
- lib/souls/version.rb
|
131
135
|
- lib/souls/versions/.souls_api_version
|
132
136
|
- lib/souls/versions/.souls_worker_version
|
137
|
+
- lib/souls/worker.rb
|
138
|
+
- lib/souls/worker/generate.rb
|
139
|
+
- lib/souls/worker/generate/application.rb
|
140
|
+
- lib/souls/worker/generate/mailer.rb
|
133
141
|
homepage: https://souls.elsoul.nl
|
134
142
|
licenses:
|
135
143
|
- Apache-2.0
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module Souls
|
2
|
-
module Generate
|
3
|
-
class << self
|
4
|
-
def return_method(args)
|
5
|
-
graphql_class = args[1]
|
6
|
-
class_name = args[2]
|
7
|
-
case graphql_class
|
8
|
-
when "test_dir"
|
9
|
-
Souls::Generate.test_dir
|
10
|
-
when "model"
|
11
|
-
Souls::Generate.model(class_name: class_name)
|
12
|
-
when "mutation"
|
13
|
-
Souls::Generate.mutation(class_name: class_name)
|
14
|
-
when "query"
|
15
|
-
Souls::Generate.query(class_name: class_name)
|
16
|
-
when "type"
|
17
|
-
Souls::Generate.type(class_name: class_name)
|
18
|
-
when "edge"
|
19
|
-
Souls::Generate.edge(class_name: class_name)
|
20
|
-
when "connection"
|
21
|
-
Souls::Generate.connection(class_name: class_name)
|
22
|
-
when "resolver"
|
23
|
-
Souls::Generate.resolver(class_name: class_name)
|
24
|
-
when "policy"
|
25
|
-
Souls::Generate.policy(class_name: class_name)
|
26
|
-
when "rspec_factory"
|
27
|
-
Souls::Generate.rspec_factory(class_name: class_name)
|
28
|
-
when "rspec_model"
|
29
|
-
Souls::Generate.rspec_model(class_name: class_name)
|
30
|
-
when "rspec_mutation"
|
31
|
-
Souls::Generate.rspec_mutation(class_name: class_name)
|
32
|
-
when "rspec_query"
|
33
|
-
Souls::Generate.rspec_query(class_name: class_name)
|
34
|
-
when "rspec_resolver"
|
35
|
-
Souls::Generate.rspec_resolver(class_name: class_name)
|
36
|
-
when "rspec_policy"
|
37
|
-
Souls::Generate.rspec_policy(class_name: class_name)
|
38
|
-
when "node_type"
|
39
|
-
Souls::Generate.node_type(class_name: class_name)
|
40
|
-
when "job"
|
41
|
-
Souls::Generate.job(class_name: class_name)
|
42
|
-
when "migrate"
|
43
|
-
Souls::Generate.migrate(class_name: class_name)
|
44
|
-
when "migrate_all"
|
45
|
-
puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
|
46
|
-
Souls::Generate.get_tables.each do |table|
|
47
|
-
Souls::Generate.migrate(class_name: table.singularize)
|
48
|
-
puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
|
49
|
-
end
|
50
|
-
when "migration"
|
51
|
-
pluralized_class_name = class_name.underscore.pluralize
|
52
|
-
system("rake db:create_migration NAME=create_#{pluralized_class_name}")
|
53
|
-
when "update"
|
54
|
-
Souls::Generate.update_delete(class_name: class_name)
|
55
|
-
Souls::Generate.migrate(class_name: class_name)
|
56
|
-
when "worker"
|
57
|
-
Souls::Init.download_worker
|
58
|
-
else
|
59
|
-
"SOULs!"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/lib/souls/generate/model.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Souls
|
2
|
-
module Generate
|
3
|
-
## Generate Model
|
4
|
-
def self.model(class_name: "souls")
|
5
|
-
file_dir = "./app/models/"
|
6
|
-
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
7
|
-
file_path = "#{file_dir}#{class_name.singularize}.rb"
|
8
|
-
return "Model already exist! #{file_path}" if File.exist?(file_path)
|
9
|
-
|
10
|
-
File.open(file_path, "w") do |f|
|
11
|
-
f.write(<<~TEXT)
|
12
|
-
class #{class_name.camelize} < ActiveRecord::Base
|
13
|
-
end
|
14
|
-
TEXT
|
15
|
-
end
|
16
|
-
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
17
|
-
file_path
|
18
|
-
rescue StandardError => e
|
19
|
-
raise(StandardError, e)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|