souls 0.17.9 → 0.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +7 -9
- data/Rakefile +9 -0
- data/config/souls.rb +4 -0
- data/exe/souls +36 -34
- data/lib/souls.rb +22 -43
- data/lib/souls/generate/application.rb +156 -0
- data/lib/souls/generate/model.rb +18 -0
- data/lib/souls/generate/mutation.rb +274 -0
- data/lib/souls/generate/policy.rb +50 -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 +20 -8
- 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: ca8fbb93a58807023f4193ad924fe5bc936a4defcf4c2ee9dbb4a3942f0fec6e
|
4
|
+
data.tar.gz: 9082d31dd6eb72bffedbb7537970c93272025c8dec0b54bf6a046dce106ebb9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 763fdcd7c085e397b514ba5776392ade03c04e102fc73d0c7316e5675f46272cb24e290114e7df7753dc4f8706c53f6840acc683b3d2c5f9ea2f888b96f4de03
|
7
|
+
data.tar.gz: 036e35ecbed48018fe4677cd680d5897ae0518a52cab3e3d8cbab6df26ac3f81976f9fd04260f06f6250c76503f55f06c01a9721ffc7d54aba05d3cc239093de
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -28,11 +28,10 @@ You can focus on business logic. No more infra problems.
|
|
28
28
|
|
29
29
|
SOULs creates 5 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
@@ -4,3 +4,12 @@ require "rspec/core/rake_task"
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
6
|
task :default => :spec
|
7
|
+
|
8
|
+
namespace :task do
|
9
|
+
task :g do
|
10
|
+
file_path = "./lib/souls/generate/"
|
11
|
+
Souls::SOULS_METHODS.each do |f|
|
12
|
+
FileUtils.touch "#{file_path}#{f}.rb"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/config/souls.rb
ADDED
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 "souls/version"
|
2
2
|
require "active_support/core_ext/string/inflections"
|
3
3
|
require "souls/init"
|
4
|
-
require "souls/generate"
|
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,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
|