souls 0.35.4 → 0.36.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 +2 -1
- data/lib/souls/cli/create/index.rb +213 -0
- data/lib/souls/cli/gcloud/compute/index.rb +3 -2
- data/lib/souls/init.rb +0 -50
- 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
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e172a062be20012e3571aa688bc8110c311346e4d6b8dfb58717ffca1c3a26ff
|
4
|
+
data.tar.gz: 3b967b956ff328c0cfa31e576160734919fa13bedf1797ef244f3e37c42029d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb222dd9b80ecbd9001b03633a22c94ab214f40cd8e7967ebadb3d053d894721f3f8caea7ddc3d1342c61b441f31004b1cdb508c06d4c3e5f4a56b2bcc9cec2b
|
7
|
+
data.tar.gz: 786b0b7aaf9a7ff2f1f815de106ed9f7bcf3203374d2b12703a66e8843c23c8631f2152e05934505a44298a9887a9e76c776fac94387f4ed98c8da358511d5b5
|
data/exe/souls
CHANGED
@@ -1,6 +1,219 @@
|
|
1
1
|
module Souls
|
2
2
|
module Create
|
3
3
|
class << self
|
4
|
+
def worker(worker_name: "mailer")
|
5
|
+
workers = Souls.configuration.workers
|
6
|
+
port = 3000 + workers.size
|
7
|
+
download_worker(worker_name: worker_name)
|
8
|
+
souls_conf_update(worker_name: worker_name)
|
9
|
+
souls_conf_update(worker_name: worker_name, strain: "api")
|
10
|
+
workflow(worker_name: worker_name)
|
11
|
+
procfile(worker_name: worker_name, port: port)
|
12
|
+
mother_procfile(worker_name: worker_name)
|
13
|
+
souls_config_init(worker_name: worker_name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def procfile(worker_name: "mailer", port: 3000)
|
17
|
+
file_dir = "apps/#{worker_name}"
|
18
|
+
file_path = "#{file_dir}/Procfile.dev"
|
19
|
+
File.open(file_path, "w") do |f|
|
20
|
+
f.write("web: bundle exec puma -p #{port} -e development")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def mother_procfile(worker_name: "mailer")
|
25
|
+
file_path = "Procfile.dev"
|
26
|
+
File.open(file_path, "a") do |f|
|
27
|
+
f.write("\n#{worker_name}: foreman start -f ./apps/#{worker_name}/Procfile")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def souls_conf_update(worker_name: "", strain: "mother")
|
32
|
+
workers = Souls.configuration.workers
|
33
|
+
port = 3000 + workers.size
|
34
|
+
file_path = strain == "mother" ? "config/souls.rb" : "apps/api/config/souls.rb"
|
35
|
+
new_file_path = "souls.rb"
|
36
|
+
worker_switch = false
|
37
|
+
File.open(new_file_path, "w") do |new_line|
|
38
|
+
File.open(file_path, "r") do |f|
|
39
|
+
f.each_line do |line|
|
40
|
+
worker_switch = true if line.include?("config.workers")
|
41
|
+
next if line.strip == "end"
|
42
|
+
|
43
|
+
new_line.write(line) unless worker_switch
|
44
|
+
|
45
|
+
next unless worker_switch
|
46
|
+
|
47
|
+
new_line.write(" config.workers = [\n")
|
48
|
+
workers.each do |worker|
|
49
|
+
new_line.write(<<-TEXT)
|
50
|
+
{
|
51
|
+
name: "#{worker[:name]}",
|
52
|
+
endpoint: "#{worker[:endpoint]}",
|
53
|
+
port: #{worker[:port]}
|
54
|
+
},
|
55
|
+
TEXT
|
56
|
+
end
|
57
|
+
break
|
58
|
+
end
|
59
|
+
end
|
60
|
+
new_line.write(<<-TEXT)
|
61
|
+
{
|
62
|
+
name: "#{worker_name}",
|
63
|
+
endpoint: "",
|
64
|
+
port: #{port}
|
65
|
+
}
|
66
|
+
]
|
67
|
+
end
|
68
|
+
TEXT
|
69
|
+
end
|
70
|
+
FileUtils.rm(file_path)
|
71
|
+
FileUtils.mv(new_file_path, file_path)
|
72
|
+
end
|
73
|
+
|
74
|
+
def workflow(worker_name: "")
|
75
|
+
file_dir = ".github/workflows"
|
76
|
+
FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
|
77
|
+
file_path = "#{file_dir}/#{worker_name}.yml"
|
78
|
+
worker_name = worker_name.underscore
|
79
|
+
worker_name_camelize = worker_name.camelize
|
80
|
+
File.open(file_path, "w") do |f|
|
81
|
+
f.write(<<~TEXT)
|
82
|
+
name: #{worker_name_camelize}
|
83
|
+
|
84
|
+
on:
|
85
|
+
push:
|
86
|
+
branches:
|
87
|
+
- master
|
88
|
+
paths:
|
89
|
+
- "apps/#{worker_name}/**"
|
90
|
+
- ".github/workflows/#{worker_name}.yml"
|
91
|
+
|
92
|
+
jobs:
|
93
|
+
build:
|
94
|
+
|
95
|
+
runs-on: ubuntu-20.04
|
96
|
+
|
97
|
+
services:
|
98
|
+
db:
|
99
|
+
image: postgres:13
|
100
|
+
ports: ["5433:5432"]
|
101
|
+
env:
|
102
|
+
POSTGRES_PASSWORD: postgres
|
103
|
+
options: >-
|
104
|
+
--health-cmd pg_isready
|
105
|
+
--health-interval 10s
|
106
|
+
--health-timeout 5s
|
107
|
+
--health-retries 5
|
108
|
+
|
109
|
+
steps:
|
110
|
+
- uses: actions/checkout@v2
|
111
|
+
- name: Set up Ruby 3.0
|
112
|
+
uses: actions/setup-ruby@v1
|
113
|
+
with:
|
114
|
+
ruby-version: 3.0
|
115
|
+
- name: Build and test with Rake
|
116
|
+
env:
|
117
|
+
PGHOST: 127.0.0.1
|
118
|
+
PGUSER: postgres
|
119
|
+
RACK_ENV: test
|
120
|
+
run: |
|
121
|
+
sudo apt-get -yqq install libpq-dev
|
122
|
+
cd apps/worker
|
123
|
+
gem install bundler
|
124
|
+
bundle install --jobs 4 --retry 3
|
125
|
+
bundle exec rake db:create RACK_ENV=test
|
126
|
+
bundle exec rake db:migrate RACK_ENV=test
|
127
|
+
bundle exec rspec
|
128
|
+
|
129
|
+
- name: Checkout the repository
|
130
|
+
uses: actions/checkout@v2
|
131
|
+
|
132
|
+
- name: GCP Authenticate
|
133
|
+
uses: google-github-actions/setup-gcloud@master
|
134
|
+
with:
|
135
|
+
version: "323.0.0"
|
136
|
+
project_id: ${{ secrets.GCP_PROJECT_ID }}
|
137
|
+
service_account_key: ${{ secrets.GCP_SA_KEY }}
|
138
|
+
export_default_credentials: true
|
139
|
+
|
140
|
+
- name: Configure Docker
|
141
|
+
run: gcloud auth configure-docker --quiet
|
142
|
+
|
143
|
+
- name: Build Docker container
|
144
|
+
run: docker build -f ./apps/#{worker_name}/Dockerfile ./apps/#{worker_name} -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}-#{worker_name}
|
145
|
+
|
146
|
+
- name: Push to Container Resistory
|
147
|
+
run: docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}-#{worker_name}
|
148
|
+
|
149
|
+
- name: Deploy to Cloud Run
|
150
|
+
run: |
|
151
|
+
gcloud run deploy ${{ secrets.APP_NAME }}-#{worker_name} \\
|
152
|
+
--service-account=${{ secrets.APP_NAME }}@${{ secrets.GCP_PROJECT_ID }}.iam.gserviceaccount.com \\
|
153
|
+
--image=gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}-#{worker_name} \\
|
154
|
+
--memory=4Gi \\
|
155
|
+
--region=asia-northeast1 \\
|
156
|
+
--allow-unauthenticated \\
|
157
|
+
--platform=managed \\
|
158
|
+
--quiet \\
|
159
|
+
--concurrency=80 \\
|
160
|
+
--port=8080 \\
|
161
|
+
--set-cloudsql-instances=${{ secrets.GCLOUDSQL_INSTANCE }} \\
|
162
|
+
--set-env-vars="DB_USER=${{ secrets.DB_USER }}" \\
|
163
|
+
--set-env-vars="DB_PW=${{ secrets.DB_PW }}" \\
|
164
|
+
--set-env-vars="DB_HOST=${{ secrets.DB_HOST }}" \\
|
165
|
+
--set-env-vars="TZ=${{ secrets.TZ }}" \\
|
166
|
+
--set-env-vars="SLACK=${{ secrets.SLACK }}" \\
|
167
|
+
--set-env-vars="SECRET_KEY_BASE=${{ secrets.SECRET_KEY_BASE }}" \\
|
168
|
+
--set-env-vars="PROJECT_ID=${{ secrets.GCP_PROJECT_ID }}"
|
169
|
+
TEXT
|
170
|
+
end
|
171
|
+
puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
|
172
|
+
file_path
|
173
|
+
rescue StandardError => e
|
174
|
+
raise(StandardError, e)
|
175
|
+
end
|
176
|
+
|
177
|
+
def souls_config_init(worker_name: "mailer")
|
178
|
+
app_name = Souls.configuration.app
|
179
|
+
project_id = Souls.configuration.project_id
|
180
|
+
config_dir = "apps/#{worker_name}/config"
|
181
|
+
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
|
182
|
+
FileUtils.touch("#{config_dir}/souls.rb")
|
183
|
+
file_path = "#{config_dir}/souls.rb"
|
184
|
+
File.open(file_path, "w") do |f|
|
185
|
+
f.write(<<~TEXT)
|
186
|
+
Souls.configure do |config|
|
187
|
+
config.app = "#{app_name}"
|
188
|
+
config.project_id = "#{project_id}"
|
189
|
+
config.strain = "worker"
|
190
|
+
config.fixed_gems = ["excluded_gem"]
|
191
|
+
config.workers = []
|
192
|
+
end
|
193
|
+
TEXT
|
194
|
+
end
|
195
|
+
rescue StandardError => e
|
196
|
+
puts(e)
|
197
|
+
end
|
198
|
+
|
199
|
+
def download_worker(worker_name: "mailer")
|
200
|
+
raise(StandardError, "Can't use `worker` for worker. Change Name.") if worker_name == "worker"
|
201
|
+
|
202
|
+
current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
|
203
|
+
wrong_dir = %w[apps api worker]
|
204
|
+
if wrong_dir.include?(current_dir_name)
|
205
|
+
raise(StandardError, "You are at wrong directory!Go to Mother Directory!")
|
206
|
+
end
|
207
|
+
|
208
|
+
version = Souls.get_latest_version_txt(service_name: "worker").join(".")
|
209
|
+
file_name = "worker-v#{version}.tgz"
|
210
|
+
url = "https://storage.googleapis.com/souls-bucket/boilerplates/workers/#{file_name}"
|
211
|
+
system("curl -OL #{url}")
|
212
|
+
system("tar -zxvf ./#{file_name} -C ./apps/")
|
213
|
+
system("mv apps/worker apps/#{worker_name}")
|
214
|
+
system("cp ./apps/api/config/database.yml ./apps/#{worker_name}/config/")
|
215
|
+
FileUtils.rm(file_name)
|
216
|
+
end
|
4
217
|
end
|
5
218
|
end
|
6
219
|
end
|
@@ -44,10 +44,11 @@ module Souls
|
|
44
44
|
|
45
45
|
def create_connector(app_name: "", region: "asia-northeast1")
|
46
46
|
app_name = Souls.configuration.app if app_name.blank?
|
47
|
+
project_id = Souls.configuration.project_id
|
47
48
|
system(
|
48
49
|
"gcloud compute networks vpc-access connectors create #{app_name}-connector \
|
49
50
|
--region=#{region} \
|
50
|
-
--subnet-project=#{
|
51
|
+
--subnet-project=#{project_id} \
|
51
52
|
--subnet=#{app_name}-subnet"
|
52
53
|
)
|
53
54
|
end
|
@@ -72,7 +73,7 @@ module Souls
|
|
72
73
|
system("gcloud compute network list")
|
73
74
|
end
|
74
75
|
|
75
|
-
def nat_credit(app_name: ""
|
76
|
+
def nat_credit(app_name: "")
|
76
77
|
app_name = Souls.configuration.app if app_name.blank?
|
77
78
|
line = Paint["====================================", :yellow]
|
78
79
|
puts("\n")
|
data/lib/souls/init.rb
CHANGED
@@ -147,55 +147,5 @@ module Souls
|
|
147
147
|
puts(cd)
|
148
148
|
puts(line)
|
149
149
|
end
|
150
|
-
|
151
|
-
def self.download_worker
|
152
|
-
current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
|
153
|
-
wrong_dir = %w[apps api worker]
|
154
|
-
raise(StandardError, "You are at wrong directory!Go to Mother Directory!") if wrong_dir.include?(current_dir_name)
|
155
|
-
|
156
|
-
version = Souls.get_latest_version_txt(service_name: "worker").join(".")
|
157
|
-
file_name = "worker-v#{version}.tgz"
|
158
|
-
url = "https://storage.googleapis.com/souls-bucket/boilerplates/workers/#{file_name}"
|
159
|
-
system("curl -OL #{url}")
|
160
|
-
system("mkdir -p ./apps/worker")
|
161
|
-
system("tar -zxvf ./#{file_name} -C ./apps/")
|
162
|
-
system("cp ./apps/api/config/database.yml ./apps/worker/config/")
|
163
|
-
FileUtils.rm(file_name)
|
164
|
-
line = Paint["====================================", :yellow]
|
165
|
-
puts("\n")
|
166
|
-
puts(line)
|
167
|
-
txt2 = <<~TEXT
|
168
|
-
_____ ____ __ ____#{' '}
|
169
|
-
/ ___// __ \\/ / / / / %{red1}
|
170
|
-
\\__ \\/ / / / / / / / %{red2}
|
171
|
-
___/ / /_/ / /_/ / /___%{red3}#{' '}
|
172
|
-
/____/\\____/\\____/_____%{red4}#{' '}
|
173
|
-
TEXT
|
174
|
-
red1 = ["_____", :red]
|
175
|
-
red2 = ["/ ___/", :red]
|
176
|
-
red3 = ["(__ )", :red]
|
177
|
-
red4 = ["/____/", :red]
|
178
|
-
ms = Paint % [txt2, :cyan, { red1: red1, red2: red2, red3: red3, red4: red4 }]
|
179
|
-
puts(ms)
|
180
|
-
puts(line)
|
181
|
-
welcome = Paint["SOULs Worker Activated!", :white]
|
182
|
-
puts(welcome)
|
183
|
-
souls_ver = Paint["SOULs Version: #{Souls::VERSION}", :white]
|
184
|
-
puts(souls_ver)
|
185
|
-
puts(line)
|
186
|
-
endroll = <<~TEXT
|
187
|
-
Easy to Run
|
188
|
-
$ cd ./apps/worker
|
189
|
-
$ bundle
|
190
|
-
$ souls sync model
|
191
|
-
$ souls s
|
192
|
-
Go To : http://localhost:3000
|
193
|
-
|
194
|
-
Doc: https://souls.elsoul.nl
|
195
|
-
TEXT
|
196
|
-
cd = Paint[endroll, :white]
|
197
|
-
puts(cd)
|
198
|
-
puts(line)
|
199
|
-
end
|
200
150
|
end
|
201
151
|
end
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.15.3
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.15.3
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: souls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.36.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
8
8
|
- KishiTheMechanic
|
9
9
|
- James Neve
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -158,7 +158,7 @@ metadata:
|
|
158
158
|
homepage_uri: https://souls.elsoul.nl
|
159
159
|
source_code_uri: https://github.com/elsoul/souls
|
160
160
|
changelog_uri: https://github.com/elsoul/souls
|
161
|
-
post_install_message:
|
161
|
+
post_install_message:
|
162
162
|
rdoc_options: []
|
163
163
|
require_paths:
|
164
164
|
- lib
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
176
|
rubygems_version: 3.2.22
|
177
|
-
signing_key:
|
177
|
+
signing_key:
|
178
178
|
specification_version: 4
|
179
179
|
summary: SOULs はサーバーレスフルスタックフレームワークです。柔軟な Ruby GraphQL API と Worker はルーティングの必要がありません。
|
180
180
|
クラウド環境への自動デプロイ、CI/CD ワークフローを標準装備。開発者がビジネスロジックに集中し、楽しくコードが書けるような環境を目指しています。
|