souls 0.51.2 → 0.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/exe/souls +4 -202
- data/lib/souls/api/generate/application.rb +97 -94
- data/lib/souls/api/generate/connection.rb +5 -4
- data/lib/souls/api/generate/edge.rb +5 -4
- data/lib/souls/api/generate/index.rb +0 -1
- data/lib/souls/api/generate/manager.rb +9 -7
- data/lib/souls/api/generate/model.rb +16 -18
- data/lib/souls/api/generate/mutation.rb +217 -218
- data/lib/souls/api/generate/policy.rb +5 -5
- data/lib/souls/api/generate/query.rb +51 -51
- data/lib/souls/api/generate/resolver.rb +115 -115
- data/lib/souls/api/generate/rspec_factory.rb +53 -53
- data/lib/souls/api/generate/rspec_model.rb +5 -5
- data/lib/souls/api/generate/rspec_mutation.rb +178 -178
- data/lib/souls/api/generate/rspec_policy.rb +5 -5
- data/lib/souls/api/generate/rspec_query.rb +111 -111
- data/lib/souls/api/generate/rspec_resolver.rb +163 -163
- data/lib/souls/api/generate/type.rb +66 -66
- data/lib/souls/api/index.rb +7 -4
- data/lib/souls/api/update/index.rb +15 -0
- data/lib/souls/api/update/mutation.rb +68 -64
- data/lib/souls/api/update/resolver.rb +59 -60
- data/lib/souls/api/update/rspec_factory.rb +40 -39
- data/lib/souls/api/update/rspec_mutation.rb +84 -83
- data/lib/souls/api/update/rspec_resolver.rb +70 -69
- data/lib/souls/api/update/type.rb +39 -38
- data/lib/souls/cli/console/index.rb +13 -1
- data/lib/souls/cli/create/index.rb +97 -93
- data/lib/souls/cli/db/index.rb +122 -1
- data/lib/souls/cli/docker/index.rb +30 -38
- data/lib/souls/cli/gcloud/compute/index.rb +100 -98
- data/lib/souls/cli/gcloud/iam/index.rb +84 -69
- data/lib/souls/cli/gcloud/index.rb +36 -35
- data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +40 -27
- data/lib/souls/cli/gcloud/pubsub/topics.rb +16 -10
- data/lib/souls/cli/gcloud/run/index.rb +23 -17
- data/lib/souls/cli/gcloud/sql/index.rb +66 -47
- data/lib/souls/cli/index.rb +3 -20
- data/lib/souls/cli/init/index.rb +140 -140
- data/lib/souls/cli/release/release.rb +106 -105
- data/lib/souls/cli/server/index.rb +12 -1
- data/lib/souls/cli/sync/conf.rb +39 -38
- data/lib/souls/cli/sync/model.rb +19 -20
- data/lib/souls/cli/sync/pubsub.rb +69 -70
- data/lib/souls/cli/upgrade/gemfile.rb +108 -0
- data/lib/souls/cli/upgrade/index.rb +1 -1
- data/lib/souls/cli.rb +57 -0
- data/lib/souls/index.rb +1 -5
- 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/generate/index.rb +1 -1
- data/lib/souls/worker/generate/job.rb +45 -0
- data/lib/souls/worker/generate/mailer.rb +38 -43
- data/lib/souls/worker/index.rb +3 -1
- data/lib/souls.rb +2 -0
- metadata +19 -5
- data/lib/souls/api/generate/migration.rb +0 -51
- data/lib/souls/cli/upgrade/gem_update.rb +0 -107
- data/lib/souls/worker/generate/mutation.rb +0 -44
@@ -1,4 +1,16 @@
|
|
1
1
|
module Souls
|
2
|
-
|
2
|
+
class CLI < Thor
|
3
|
+
desc "console", "Run IRB Console"
|
4
|
+
method_option :env, aliases: "--e", default: "development", desc: "Difine APP Enviroment - development | production"
|
5
|
+
def console
|
6
|
+
case options[:env]
|
7
|
+
when "production"
|
8
|
+
system("RACK_ENV=production bundle exec irb")
|
9
|
+
else
|
10
|
+
system("bundle exec irb")
|
11
|
+
end
|
12
|
+
rescue Thor::Error => e
|
13
|
+
raise(Thor::Error, e)
|
14
|
+
end
|
3
15
|
end
|
4
16
|
end
|
@@ -1,69 +1,74 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
2
|
+
class Create < Thor
|
3
|
+
desc "worker", "Create SOULs Worker"
|
4
|
+
method_option :name, aliases: "--name", desc: "Worker Name", required: true
|
5
|
+
def worker
|
6
|
+
require("#{Souls.get_mother_path}/config/souls")
|
7
|
+
Dir.chdir(Souls.get_mother_path.to_s) do
|
8
|
+
file_dir = "apps/#{options[:name]}"
|
9
|
+
raise(StandardError, "Same Worker Already Exist!") if Dir.exist?(file_dir)
|
10
|
+
|
11
|
+
workers = Souls.configuration.workers
|
12
|
+
port = 3000 + workers.size
|
13
|
+
download_worker(worker_name: options[:name])
|
14
|
+
souls_conf_update(worker_name: options[:name])
|
15
|
+
souls_conf_update(worker_name: options[:name], strain: "api")
|
16
|
+
workflow(worker_name: options[:name])
|
17
|
+
procfile(worker_name: options[:name], port: port)
|
18
|
+
mother_procfile(worker_name: options[:name])
|
19
|
+
souls_config_init(worker_name: options[:name])
|
20
20
|
end
|
21
|
+
rescue Thor::Error => e
|
22
|
+
raise(Thor::Error, e)
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
private
|
26
|
+
|
27
|
+
def procfile(worker_name: "mailer", port: 3000)
|
28
|
+
file_dir = "apps/#{worker_name}"
|
29
|
+
file_path = "#{file_dir}/Procfile.dev"
|
30
|
+
File.open(file_path, "w") do |f|
|
31
|
+
f.write("#{worker_name}: bundle exec puma -p #{port} -e development")
|
28
32
|
end
|
33
|
+
end
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
+
def mother_procfile(worker_name: "mailer")
|
36
|
+
file_path = "Procfile.dev"
|
37
|
+
File.open(file_path, "a") do |f|
|
38
|
+
f.write("\n#{worker_name}: foreman start -f ./apps/#{worker_name}/Procfile.dev")
|
35
39
|
end
|
40
|
+
end
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
def souls_conf_update(worker_name: "", strain: "mother")
|
43
|
+
workers = Souls.configuration.workers
|
44
|
+
port = 3000 + workers.size
|
45
|
+
file_path = strain == "mother" ? "config/souls.rb" : "apps/api/config/souls.rb"
|
46
|
+
new_file_path = "souls.rb"
|
47
|
+
worker_switch = false
|
48
|
+
File.open(new_file_path, "w") do |new_line|
|
49
|
+
File.open(file_path, "r") do |f|
|
50
|
+
f.each_line do |line|
|
51
|
+
worker_switch = true if line.include?("config.workers")
|
52
|
+
next if line.strip == "end"
|
53
|
+
|
54
|
+
new_line.write(line) unless worker_switch
|
55
|
+
|
56
|
+
next unless worker_switch
|
57
|
+
|
58
|
+
new_line.write(" config.workers = [\n")
|
59
|
+
workers.each do |worker|
|
60
|
+
new_line.write(<<-TEXT)
|
56
61
|
{
|
57
62
|
name: "#{worker[:name]}",
|
58
63
|
endpoint: "#{worker[:endpoint]}",
|
59
64
|
port: #{worker[:port]}
|
60
65
|
},
|
61
|
-
|
62
|
-
end
|
63
|
-
break
|
66
|
+
TEXT
|
64
67
|
end
|
68
|
+
break
|
65
69
|
end
|
66
|
-
|
70
|
+
end
|
71
|
+
new_line.write(<<-TEXT)
|
67
72
|
{
|
68
73
|
name: "#{worker_name}",
|
69
74
|
endpoint: "",
|
@@ -71,20 +76,20 @@ module Souls
|
|
71
76
|
}
|
72
77
|
]
|
73
78
|
end
|
74
|
-
|
75
|
-
end
|
76
|
-
FileUtils.rm(file_path)
|
77
|
-
FileUtils.mv(new_file_path, file_path)
|
79
|
+
TEXT
|
78
80
|
end
|
81
|
+
FileUtils.rm(file_path)
|
82
|
+
FileUtils.mv(new_file_path, file_path)
|
83
|
+
end
|
79
84
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
85
|
+
def workflow(worker_name: "")
|
86
|
+
file_dir = ".github/workflows"
|
87
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
88
|
+
file_path = "#{file_dir}/#{worker_name}.yml"
|
89
|
+
worker_name = worker_name.underscore
|
90
|
+
worker_name_camelize = worker_name.camelize
|
91
|
+
File.open(file_path, "w") do |f|
|
92
|
+
f.write(<<~TEXT)
|
88
93
|
name: #{worker_name_camelize}
|
89
94
|
|
90
95
|
on:
|
@@ -172,23 +177,23 @@ end
|
|
172
177
|
--set-env-vars="SLACK=${{ secrets.SLACK }}" \\
|
173
178
|
--set-env-vars="SECRET_KEY_BASE=${{ secrets.SECRET_KEY_BASE }}" \\
|
174
179
|
--set-env-vars="PROJECT_ID=${{ secrets.GCP_PROJECT_ID }}"
|
175
|
-
|
176
|
-
end
|
177
|
-
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
178
|
-
file_path
|
179
|
-
rescue StandardError => e
|
180
|
-
raise(StandardError, e)
|
180
|
+
TEXT
|
181
181
|
end
|
182
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
183
|
+
file_path
|
184
|
+
rescue StandardError => e
|
185
|
+
raise(StandardError, e)
|
186
|
+
end
|
182
187
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
188
|
+
def souls_config_init(worker_name: "mailer")
|
189
|
+
app_name = Souls.configuration.app
|
190
|
+
project_id = Souls.configuration.project_id
|
191
|
+
config_dir = "apps/#{worker_name}/config"
|
192
|
+
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
|
193
|
+
FileUtils.touch("#{config_dir}/souls.rb")
|
194
|
+
file_path = "#{config_dir}/souls.rb"
|
195
|
+
File.open(file_path, "w") do |f|
|
196
|
+
f.write(<<~TEXT)
|
192
197
|
Souls.configure do |config|
|
193
198
|
config.app = "#{app_name}"
|
194
199
|
config.project_id = "#{project_id}"
|
@@ -198,22 +203,21 @@ end
|
|
198
203
|
config.fixed_gems = ["spring"]
|
199
204
|
config.workers = []
|
200
205
|
end
|
201
|
-
|
202
|
-
end
|
203
|
-
rescue StandardError => e
|
204
|
-
puts(e)
|
206
|
+
TEXT
|
205
207
|
end
|
208
|
+
rescue StandardError => e
|
209
|
+
puts(e)
|
210
|
+
end
|
206
211
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
end
|
212
|
+
def download_worker(worker_name: "mailer")
|
213
|
+
version = Souls.get_latest_version_txt(service_name: "worker").join(".")
|
214
|
+
file_name = "worker-v#{version}.tgz"
|
215
|
+
url = "https://storage.googleapis.com/souls-bucket/boilerplates/workers/#{file_name}"
|
216
|
+
system("curl -OL #{url}")
|
217
|
+
system("tar -zxvf ./#{file_name}")
|
218
|
+
system("mv ./worker apps/#{worker_name}")
|
219
|
+
system("cp ./apps/api/config/database.yml ./apps/#{worker_name}/config/")
|
220
|
+
FileUtils.rm(file_name)
|
217
221
|
end
|
218
222
|
end
|
219
223
|
end
|
data/lib/souls/cli/db/index.rb
CHANGED
@@ -1,4 +1,125 @@
|
|
1
1
|
module Souls
|
2
|
-
|
2
|
+
class CLI < Thor
|
3
|
+
desc "db:migrate [CLASS_NAME]", "Migrate Database"
|
4
|
+
method_option :env, aliases: "--e", default: "development", desc: "Difine APP Enviroment - development | production"
|
5
|
+
def migrate
|
6
|
+
case options[:env]
|
7
|
+
when "production"
|
8
|
+
system("rake db:migrate RACK_ENV=production")
|
9
|
+
when "development"
|
10
|
+
system("rake db:migrate")
|
11
|
+
when "test"
|
12
|
+
system("rake db:migrate RACK_ENV=test")
|
13
|
+
end
|
14
|
+
rescue Thor::Error => e
|
15
|
+
raise(Thor::Error, e)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "db:create [CLASS_NAME]", "Create Database"
|
19
|
+
method_option :env, aliases: "--e", default: "development", desc: "Difine APP Enviroment - development | production"
|
20
|
+
def db_create
|
21
|
+
case options[:env]
|
22
|
+
when "production"
|
23
|
+
system("rake db:create RACK_ENV=production")
|
24
|
+
when "development"
|
25
|
+
system("rake db:create")
|
26
|
+
when "test"
|
27
|
+
system("rake db:create RACK_ENV=test")
|
28
|
+
end
|
29
|
+
rescue Thor::Error => e
|
30
|
+
raise(Thor::Error, e)
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "db:seed [CLASS_NAME]", "Insert Seed Data"
|
34
|
+
method_option :env, aliases: "--e", default: "development", desc: "Difine APP Enviroment - development | production"
|
35
|
+
def seed
|
36
|
+
case options[:env]
|
37
|
+
when "production"
|
38
|
+
system("rake db:seed RACK_ENV=production")
|
39
|
+
when "development"
|
40
|
+
system("rake db:seed")
|
41
|
+
when "test"
|
42
|
+
system("rake db:seed RACK_ENV=test")
|
43
|
+
end
|
44
|
+
rescue Thor::Error => e
|
45
|
+
raise(Thor::Error, e)
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "db:migrate:reset [CLASS_NAME]", "Reset Database"
|
49
|
+
method_option :env, aliases: "--e", default: "development", desc: "Difine APP Enviroment - development | production"
|
50
|
+
def migrate_reset
|
51
|
+
case options[:env]
|
52
|
+
when "production"
|
53
|
+
system("rake db:migrate:reset RACK_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=1")
|
54
|
+
when "development"
|
55
|
+
system("rake db:migrate:reset")
|
56
|
+
when "test"
|
57
|
+
system("rake db:migrate:reset RACK_ENV=test")
|
58
|
+
end
|
59
|
+
rescue Thor::Error => e
|
60
|
+
raise(Thor::Error, e)
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "db:create_migration [CLASS_NAME]", "Create ActiveRecord Migration File"
|
64
|
+
def create_migration(class_name)
|
65
|
+
pluralized_class_name = class_name.underscore.pluralize
|
66
|
+
system("rake db:create_migration NAME=create_#{pluralized_class_name}")
|
67
|
+
file_path = Dir["db/migrate/*create_#{pluralized_class_name}.rb"].first
|
68
|
+
File.open(file_path, "w") do |f|
|
69
|
+
f.write(<<~TEXT)
|
70
|
+
class Create#{pluralized_class_name.camelize} < ActiveRecord::Migration[6.1]
|
71
|
+
def change
|
72
|
+
create_table :#{pluralized_class_name} do |t|
|
73
|
+
|
74
|
+
t.boolean :is_deleted, null: false, default: false
|
75
|
+
t.timestamps
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
TEXT
|
80
|
+
end
|
81
|
+
rescue Thor::Error => e
|
82
|
+
raise(Thor::Error, e)
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "db:add_column [CLASS_NAME]", "Create ActiveRecord Migration File"
|
86
|
+
def add_column(class_name)
|
87
|
+
pluralized_class_name = class_name.underscore.pluralize
|
88
|
+
system("rake db:create_migration NAME=add_column_to_#{pluralized_class_name}")
|
89
|
+
rescue Thor::Error => e
|
90
|
+
raise(Thor::Error, e)
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "db:rename_column [CLASS_NAME]", "Create ActiveRecord Migration File"
|
94
|
+
def rename_column(class_name)
|
95
|
+
pluralized_class_name = class_name.underscore.pluralize
|
96
|
+
system("rake db:create_migration NAME=rename_column_to_#{pluralized_class_name}")
|
97
|
+
rescue Thor::Error => e
|
98
|
+
raise(Thor::Error, e)
|
99
|
+
end
|
100
|
+
|
101
|
+
desc "db:change_column [CLASS_NAME]", "Create ActiveRecord Migration File"
|
102
|
+
def change_column(class_name)
|
103
|
+
pluralized_class_name = class_name.underscore.pluralize
|
104
|
+
system("rake db:create_migration NAME=change_column_to_#{pluralized_class_name}")
|
105
|
+
rescue Thor::Error => e
|
106
|
+
raise(Thor::Error, e)
|
107
|
+
end
|
108
|
+
|
109
|
+
desc "db:remove_column [CLASS_NAME]", "Create ActiveRecord Migration File"
|
110
|
+
def remove_column(class_name)
|
111
|
+
pluralized_class_name = class_name.underscore.pluralize
|
112
|
+
system("rake db:create_migration NAME=remove_column_to_#{pluralized_class_name}")
|
113
|
+
rescue Thor::Error => e
|
114
|
+
raise(Thor::Error, e)
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "db:drop_table [CLASS_NAME]", "Create ActiveRecord Migration File"
|
118
|
+
def drop_table(class_name)
|
119
|
+
pluralized_class_name = class_name.underscore.pluralize
|
120
|
+
system("rake db:create_migration NAME=drop_table_to_#{pluralized_class_name}")
|
121
|
+
rescue Thor::Error => e
|
122
|
+
raise(Thor::Error, e)
|
123
|
+
end
|
3
124
|
end
|
4
125
|
end
|
@@ -1,43 +1,35 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
2
|
+
class Docker < Thor
|
3
|
+
desc "psql", "Run PostgreSQL13 Docker Container"
|
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
|
+
rescue Thor::Error => e
|
16
|
+
raise(Thor::Error, e)
|
17
|
+
end
|
29
18
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
19
|
+
desc "mysql", "Run MySQL Docker Container"
|
20
|
+
def mysql
|
21
|
+
system(
|
22
|
+
"docker run --rm -d \
|
23
|
+
-p 3306:3306 \
|
24
|
+
-v mysql-tmp:/var/lib/mysql \
|
25
|
+
-e MYSQL_USER=mysql \
|
26
|
+
-e MYSQL_ROOT_PASSWORD=mysql \
|
27
|
+
-e MYSQL_DB=souls_test \
|
28
|
+
mysql:latest"
|
29
|
+
)
|
30
|
+
system("docker ps")
|
31
|
+
rescue Thor::Error => e
|
32
|
+
raise(Thor::Error, e)
|
41
33
|
end
|
42
34
|
end
|
43
35
|
end
|