souls 0.26.9 → 0.27.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abb403a2afdcb6e2de2502a8f22ef0977224dbc17cd2145fd8ae6fd1b690595d
4
- data.tar.gz: bdaa332725d41ec2e2c267544d17805cf278d908524309acc8c52724593a0b0e
3
+ metadata.gz: 1cf1ae4a3de56f9fde7d3c7200ba4e7eba448e0a6fe09d577ba7f550aa5e9618
4
+ data.tar.gz: 0bfface843f917a3ec74627e272622524b7887f1597b0782e32b26974391fef5
5
5
  SHA512:
6
- metadata.gz: bc0bd6eb6dffcafdb444b41bd68d93822c366280af9c2a9da59e8e5d2eb402041b51765d3e346590e8c0999ec6161081b75733d04b83641d88787e8f147f1e4e
7
- data.tar.gz: d55eaa383f6107f409c8c2df0192db434ac6307ba578f36be8d20879ba0ec13b4aee54b14fc020d3a05e3fb6d10fa4ce36324ff5b9c616df67e208c09a702609
6
+ metadata.gz: 5f3057f60c46593bee1a501fa0c53e9849afdbe8ee58b23c83e81d44d6bbb82cceea8a6942b00c75bdb24417da511f245156bd6f44507340fd51bf632c68cb10
7
+ data.tar.gz: c83202c8309d651a1c430e4b88a8ac5cd7f91aefcb8fe843d23a5d0e41a0b16e2c49d5cb8f1659f9d61c503c85f51e8ec2282f0e99b040ca129840c2fb64aa30
data/lib/souls.rb CHANGED
@@ -192,6 +192,7 @@ module Souls
192
192
 
193
193
  system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{file_name}")
194
194
  system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{release_name}")
195
+ system("gsutil cp .rubocop.yml #{bucket_url}/.rubocop.yml")
195
196
  FileUtils.rm("#{service_name}.tgz")
196
197
  "#{service_name}-v#{new_ver} Succefully Stored to GCS! "
197
198
  end
@@ -297,36 +298,50 @@ module Souls
297
298
  end
298
299
 
299
300
  def cp_and_dl_files(api_dir: "", worker_dir: "")
300
- api_file_data = file_diff(Dir["#{api_dir}/*.rb"])
301
- worker_file_data = file_diff(Dir["#{worker_dir}/*.rb"])
301
+ if Dir["#{worker_dir}/*.rb"].blank?
302
302
 
303
- api_latest_date = Date.parse(api_file_data.max)
304
- worker_latest_date = Date.parse(worker_file_data.max)
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
305
312
 
306
- if api_latest_date > worker_latest_date
307
- FileUtils.rm_rf(api_dir)
313
+ if api_latest_date < worker_latest_date
314
+ FileUtils.rm_rf(api_dir) if Dir.exist?(api_dir)
308
315
  FileUtils.mkdir(api_dir) unless Dir.exist?(api_dir)
309
316
  system("cp -r #{worker_dir}/* #{api_dir}")
310
317
  else
311
- FileUtils.rm_rf(worker_dir)
318
+ FileUtils.rm_rf(worker_dir) if Dir.exist?(worker_dir)
312
319
  FileUtils.mkdir(worker_dir) unless Dir.exist?(worker_dir)
313
320
  system("cp -r #{api_dir}/* #{worker_dir}")
314
321
  end
315
322
  end
316
323
 
317
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
318
333
  [
319
334
  {
320
- api: "../#{service_name}/db",
321
- worker: "./db"
335
+ api: "#{api_path}/db",
336
+ worker: "#{worker_path}/db"
322
337
  },
323
338
  {
324
- api: "../#{service_name}/app/models",
325
- worker: "./app/models"
339
+ api: "#{api_path}/app/models",
340
+ worker: "#{worker_path}/app/models"
326
341
  },
327
342
  {
328
- api: "../#{service_name}/spec/factories",
329
- worker: "./spec/factories"
343
+ api: "#{api_path}/spec/factories",
344
+ worker: "#{worker_path}/spec/factories"
330
345
  }
331
346
  ]
332
347
  end
@@ -367,14 +382,13 @@ module Souls
367
382
  end
368
383
 
369
384
  class Configuration
370
- attr_accessor :app, :strain, :project_id, :worker_repo, :api_repo, :worker_endpoint, :fixed_gems
385
+ attr_accessor :app, :strain, :project_id, :github_repo, :worker_endpoint, :fixed_gems
371
386
 
372
387
  def initialize
373
388
  @app = nil
374
389
  @project_id = nil
375
390
  @strain = nil
376
- @worker_repo = nil
377
- @api_repo = nil
391
+ @github_repo = nil
378
392
  @worker_endpoint = nil
379
393
  @fixed_gems = nil
380
394
  end
@@ -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} \
@@ -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.worker_endpoint = "https://worker.com"
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.api = true
53
- config.worker = false
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,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.26.9".freeze
2
+ VERSION = "0.27.2".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.5.9
1
+ 0.6.2
@@ -1 +1 @@
1
- 0.5.9
1
+ 0.6.2
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.26.9
4
+ version: 0.27.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI