souls 0.26.8 → 0.27.1
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/lib/souls.rb +31 -16
- data/lib/souls/gcloud/iam.rb +35 -0
- data/lib/souls/gcloud/methods.rb +7 -0
- data/lib/souls/init.rb +5 -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
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a6217d4f7de4eb318ea7b8ab7c68091b285749e82b9ed49b98eebb848e2e4c7
|
4
|
+
data.tar.gz: c7d3444c03e7f788b14d52b7d5f9558fecf87013c06f82aba7a66672f259f59d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c2bcae747194927bfa913663d2646a17b924163dda87002b445d5d4069e229011caeb319eeed5014dd7888b1f98c063798f2fdc805ed91f7b206431944997f
|
7
|
+
data.tar.gz: 9a69b61b4b3359b93466c1e1aa103470417d6013eba2a8190928b59474a3b0adb5512ad83d42463c779f11867d73e3fc85770fcebe6ff04a52baae590754208b
|
data/lib/souls.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative "souls/init"
|
|
4
4
|
require_relative "souls/generate"
|
5
5
|
require_relative "souls/gcloud"
|
6
6
|
require_relative "souls/release"
|
7
|
+
require "date"
|
7
8
|
require "dotenv/load"
|
8
9
|
require "json"
|
9
10
|
require "fileutils"
|
@@ -191,6 +192,7 @@ module Souls
|
|
191
192
|
|
192
193
|
system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{file_name}")
|
193
194
|
system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{release_name}")
|
195
|
+
system("gsutil cp .rubocop.yml #{bucket_url}/.rubocop.yml")
|
194
196
|
FileUtils.rm("#{service_name}.tgz")
|
195
197
|
"#{service_name}-v#{new_ver} Succefully Stored to GCS! "
|
196
198
|
end
|
@@ -296,36 +298,50 @@ module Souls
|
|
296
298
|
end
|
297
299
|
|
298
300
|
def cp_and_dl_files(api_dir: "", worker_dir: "")
|
299
|
-
|
300
|
-
worker_file_data = file_diff(Dir["#{worker_dir}/*.rb"])
|
301
|
+
if Dir["#{worker_dir}/*.rb"].blank?
|
301
302
|
|
302
|
-
|
303
|
-
|
303
|
+
api_latest_date = 1
|
304
|
+
worker_latest_date = 0
|
305
|
+
else
|
306
|
+
api_file_data = file_diff(Dir["#{api_dir}/*.rb"])
|
307
|
+
worker_file_data = file_diff(Dir["#{worker_dir}/*.rb"])
|
308
|
+
|
309
|
+
api_latest_date = Date.parse(api_file_data.max)
|
310
|
+
worker_latest_date = Date.parse(worker_file_data.max)
|
311
|
+
end
|
304
312
|
|
305
|
-
if api_latest_date
|
306
|
-
FileUtils.rm_rf(api_dir)
|
313
|
+
if api_latest_date < worker_latest_date
|
314
|
+
FileUtils.rm_rf(api_dir) if Dir.exist?(api_dir)
|
307
315
|
FileUtils.mkdir(api_dir) unless Dir.exist?(api_dir)
|
308
316
|
system("cp -r #{worker_dir}/* #{api_dir}")
|
309
317
|
else
|
310
|
-
FileUtils.rm_rf(worker_dir)
|
318
|
+
FileUtils.rm_rf(worker_dir) if Dir.exist?(worker_dir)
|
311
319
|
FileUtils.mkdir(worker_dir) unless Dir.exist?(worker_dir)
|
312
320
|
system("cp -r #{api_dir}/* #{worker_dir}")
|
313
321
|
end
|
314
322
|
end
|
315
323
|
|
316
324
|
def get_models_path(service_name: "api")
|
325
|
+
case service_name
|
326
|
+
when "api"
|
327
|
+
api_path = "."
|
328
|
+
worker_path = "../worker"
|
329
|
+
when "worker"
|
330
|
+
api_path = "../api"
|
331
|
+
worker_path = "."
|
332
|
+
end
|
317
333
|
[
|
318
334
|
{
|
319
|
-
api: "
|
320
|
-
worker: "
|
335
|
+
api: "#{api_path}/db",
|
336
|
+
worker: "#{worker_path}/db"
|
321
337
|
},
|
322
338
|
{
|
323
|
-
api: "
|
324
|
-
worker: "
|
339
|
+
api: "#{api_path}/app/models",
|
340
|
+
worker: "#{worker_path}/app/models"
|
325
341
|
},
|
326
342
|
{
|
327
|
-
api: "
|
328
|
-
worker: "
|
343
|
+
api: "#{api_path}/spec/factories",
|
344
|
+
worker: "#{worker_path}/spec/factories"
|
329
345
|
}
|
330
346
|
]
|
331
347
|
end
|
@@ -366,14 +382,13 @@ module Souls
|
|
366
382
|
end
|
367
383
|
|
368
384
|
class Configuration
|
369
|
-
attr_accessor :app, :strain, :project_id, :
|
385
|
+
attr_accessor :app, :strain, :project_id, :github_repo, :worker_endpoint, :fixed_gems
|
370
386
|
|
371
387
|
def initialize
|
372
388
|
@app = nil
|
373
389
|
@project_id = nil
|
374
390
|
@strain = nil
|
375
|
-
@
|
376
|
-
@api_repo = nil
|
391
|
+
@github_repo = nil
|
377
392
|
@worker_endpoint = nil
|
378
393
|
@fixed_gems = nil
|
379
394
|
end
|
data/lib/souls/gcloud/iam.rb
CHANGED
@@ -16,6 +16,41 @@ module Souls
|
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
|
+
def export_key_to_console
|
20
|
+
github_repo = Souls.configuration.github_repo || "elsoul/souls"
|
21
|
+
file_path = "config/keyfile.json"
|
22
|
+
puts(Paint["======= below(ここから)=======", :cyan])
|
23
|
+
text = []
|
24
|
+
File.open(file_path, "r") do |line|
|
25
|
+
line.each_line do |l|
|
26
|
+
text << l
|
27
|
+
end
|
28
|
+
end
|
29
|
+
key = text.join(",").gsub(/^,/, "").chomp!
|
30
|
+
puts(Paint[key, :white])
|
31
|
+
puts(Paint["======= above(ここまで)=======", :cyan])
|
32
|
+
github_secret_url = "https://github.com/#{github_repo}/#{app_name}/settings/secrets/actions"
|
33
|
+
souls_doc_url = "https://souls.elsoul.nl/docs/chapter2/#43-github-シークレットキーの登録"
|
34
|
+
txt1 = <<~TEXT
|
35
|
+
|
36
|
+
⬆⬆⬆ Copy the service account key above ⬆⬆⬆⬆
|
37
|
+
|
38
|
+
And
|
39
|
+
|
40
|
+
Go to %{yellow_text}
|
41
|
+
|
42
|
+
Reference: %{yellow_text2}
|
43
|
+
TEXT
|
44
|
+
puts(
|
45
|
+
Paint % [
|
46
|
+
txt1,
|
47
|
+
:white,
|
48
|
+
{ yellow_text: [github_secret_url, :yellow], yellow_text2: [souls_doc_url, :yellow] }
|
49
|
+
]
|
50
|
+
)
|
51
|
+
fileutils.rm(file_path)
|
52
|
+
end
|
53
|
+
|
19
54
|
def add_service_account_role(service_account: "souls-app", project_id: "souls-app", role: "roles/firebase.admin")
|
20
55
|
system(
|
21
56
|
"gcloud projects add-iam-policy-binding #{project_id} \
|
data/lib/souls/gcloud/methods.rb
CHANGED
@@ -4,6 +4,13 @@ module Souls
|
|
4
4
|
def return_method(args)
|
5
5
|
method = args[1]
|
6
6
|
case method
|
7
|
+
when "get_iam_key"
|
8
|
+
app_name = Souls.configuration.app
|
9
|
+
project_id = Souls.configuration.project_id
|
10
|
+
Souls::Gcloud.create_service_account(service_account: app_name)
|
11
|
+
Souls::Gcloud.create_service_account_key(service_account: app_name, project_id: project_id)
|
12
|
+
Souls::Gcloud.export_key_to_console
|
13
|
+
Souls::Gcloud.enable_permissions
|
7
14
|
when "auth_login"
|
8
15
|
project_id = Souls.configuration.project_id
|
9
16
|
Souls::Gcloud.auth_login(project_id: project_id)
|
data/lib/souls/init.rb
CHANGED
@@ -20,7 +20,8 @@ module Souls
|
|
20
20
|
config.app = "#{app_name}"
|
21
21
|
config.project_id = "souls-app"
|
22
22
|
config.strain = "#{service_name}"
|
23
|
-
config.
|
23
|
+
config.github_repo = "elsoul/souls"
|
24
|
+
config.worker_endpoint = "https://worker.test.com"
|
24
25
|
config.fixed_gems = ["excluded_gem"]
|
25
26
|
end
|
26
27
|
TEXT
|
@@ -49,10 +50,8 @@ module Souls
|
|
49
50
|
config.app = "#{app_name}"
|
50
51
|
config.project_id = "souls-app"
|
51
52
|
config.strain = "mother"
|
52
|
-
config.
|
53
|
-
config.
|
54
|
-
config.frontend = false
|
55
|
-
config.worker_endpoint = ""
|
53
|
+
config.github_repo = "elsoul/souls"
|
54
|
+
config.worker_endpoint = "https://worker.test.com"
|
56
55
|
config.fixed_gems = ["excluded_gem"]
|
57
56
|
end
|
58
57
|
TEXT
|
@@ -93,6 +92,7 @@ module Souls
|
|
93
92
|
system("curl -OL #{url}")
|
94
93
|
system("mkdir -p #{app_name}/apps/#{service_name}")
|
95
94
|
system("tar -zxvf ./#{file_name} -C #{app_name}/apps/")
|
95
|
+
system("curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/.rubocop.yml #{app_name}")
|
96
96
|
FileUtils.rm(file_name)
|
97
97
|
end
|
98
98
|
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.1
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.1
|