souls 0.26.4 → 0.26.8

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: ae0f756645176179171c222fa964f834b33eabb0682c9e52746ab04190cc50fa
4
- data.tar.gz: 6bc7df88728c49e170403ee72cacf2d3201d1ff2f19f8df4aa80d00ac3bf646b
3
+ metadata.gz: a5e58498e4d755e83b5b9244c9eebdfa08e9c9bbd2f6d006cbea2e87be99a463
4
+ data.tar.gz: 3148268dccdb03f49bd29105867ac5dcca44fdef43ed85855e93b0d9f30199d4
5
5
  SHA512:
6
- metadata.gz: 35bb79ed3fe0403f4653d363b9cfa8c787c3d5320bdec04beb2b86920a61e10cb7b9f4ad844898a7859b6096e52543f314aa47a7966d0b8ea859aad7345188f3
7
- data.tar.gz: 6a806db17149e8cbabcd06b840611a4c0b3e83e0442198e83a60a80ad979cc827ff42ebed93b23a7299493cc83f4002f67a515ad44f8832d8929ff70f67a5288
6
+ metadata.gz: 2ab89d13dc49261853b81780a105e672830410b3dc836e8a605e37f5359bffb82abfe4bb8ff8abcf813a0089efea78536cd6c113663bf7d033584f2f8da2611d
7
+ data.tar.gz: 9aa074b6bb0d4ff2c2f50808abcc4b6750d88c55ec6f7d2381535001e73c6c813e34a84cda7d87a173619c26a1f61aa9193d44bafe5a21af707f19b57b01b168
data/exe/souls CHANGED
@@ -54,39 +54,14 @@ begin
54
54
  Whirly.status = "Done!"
55
55
  end
56
56
  when "release"
57
- system("gem install souls")
58
- sleep(3)
59
- current_souls_ver = Souls::VERSION.strip.split(".").map(&:to_i)
60
- prompt = TTY::Prompt.new
61
- choices = [
62
- "1. Patch(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'patch')})",
63
- "2. Minor(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'minor')})",
64
- "3. Major(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'major')})"
65
- ]
66
- choice_num = prompt.select("Select Version: ", choices)[0].to_i
67
- update_kinds = %w[patch minor major]
68
- update_kind = update_kinds[choice_num - 1]
69
- souls_new_ver = Souls.version_detector(current_ver: current_souls_ver, update_kind: update_kind)
70
-
71
- status = Paint["Saving Repo...", :yellow]
57
+ Souls::Release.return_method
58
+ when "model:update"
59
+ status = Paint["Updating Models...", :yellow]
72
60
  Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
73
61
  Whirly.status = status
74
- %w[api worker].each do |s_name|
75
- result = Paint[Souls.update_repo(service_name: s_name, update_kind: update_kind), :green]
76
- Whirly.status = result
77
- end
78
- Souls.overwrite_version(new_version: souls_new_ver)
79
- puts("before add")
80
- system("git add .")
81
- puts("before commit")
82
- system("git commit -m 'souls update v#{souls_new_ver}'")
83
- puts("before build")
84
- system("rake build")
85
- system("rake release")
86
- Whirly.status = Paint["soul-v#{souls_new_ver} successfully updated!"]
62
+ Souls.update_models
63
+ Whirly.status = "Done!"
87
64
  end
88
- when "update"
89
- puts(Paint["Coming soon..", :cyan])
90
65
  when "add"
91
66
  graphql_class = ARGV[1]
92
67
  case graphql_class
data/lib/souls.rb CHANGED
@@ -3,6 +3,7 @@ require "active_support/core_ext/string/inflections"
3
3
  require_relative "souls/init"
4
4
  require_relative "souls/generate"
5
5
  require_relative "souls/gcloud"
6
+ require_relative "souls/release"
6
7
  require "dotenv/load"
7
8
  require "json"
8
9
  require "fileutils"
@@ -174,7 +175,6 @@ module Souls
174
175
  bucket_url = "gs://souls-bucket/boilerplates"
175
176
  file_name = "#{service_name}-v#{new_ver}.tgz"
176
177
  release_name = "#{service_name}-latest.tgz"
177
- update_service_gemfile(service_name: service_name)
178
178
 
179
179
  case current_dir_name
180
180
  when "souls"
@@ -257,7 +257,7 @@ module Souls
257
257
  end
258
258
  end
259
259
 
260
- def update_service_gemfile(service_name: "api")
260
+ def update_service_gemfile(service_name: "api", version: "0.0.1")
261
261
  file_dir = "./apps/#{service_name}"
262
262
  file_path = "#{file_dir}/Gemfile"
263
263
  gemfile_lock = "#{file_dir}/Gemfile.lock"
@@ -269,7 +269,7 @@ module Souls
269
269
  if gem[0] == "souls"
270
270
  old_ver = gem[1].split(".")
271
271
  old_ver[2] = (old_ver[2].to_i + 1).to_s
272
- new_line.write(" gem \"souls\", \"#{old_ver.join('.')}\"\n")
272
+ new_line.write(" gem \"souls\", \"#{version}\"\n")
273
273
  else
274
274
  new_line.write(line)
275
275
  end
@@ -282,6 +282,72 @@ module Souls
282
282
  puts(Paint["\nSuccessfully Updated #{service_name} Gemfile!", :green])
283
283
  end
284
284
 
285
+ def update_models
286
+ current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
287
+ permitted_dirs = %w[worker api]
288
+ unless permitted_dirs.include?(current_dir_name)
289
+ raise(StandardError, "You are at wrong directory!Go to API or Worker Directory!")
290
+ end
291
+
292
+ cp_dir = get_models_path(service_name: current_dir_name)
293
+ cp_dir.each do |path|
294
+ cp_and_dl_files(api_dir: path[:api], worker_dir: path[:worker])
295
+ end
296
+ end
297
+
298
+ def cp_and_dl_files(api_dir: "", worker_dir: "")
299
+ api_file_data = file_diff(Dir["#{api_dir}/*.rb"])
300
+ worker_file_data = file_diff(Dir["#{worker_dir}/*.rb"])
301
+
302
+ api_latest_date = Date.parse(api_file_data.max)
303
+ worker_latest_date = Date.parse(worker_file_data.max)
304
+
305
+ if api_latest_date > worker_latest_date
306
+ FileUtils.rm_rf(api_dir)
307
+ FileUtils.mkdir(api_dir) unless Dir.exist?(api_dir)
308
+ system("cp -r #{worker_dir}/* #{api_dir}")
309
+ else
310
+ FileUtils.rm_rf(worker_dir)
311
+ FileUtils.mkdir(worker_dir) unless Dir.exist?(worker_dir)
312
+ system("cp -r #{api_dir}/* #{worker_dir}")
313
+ end
314
+ end
315
+
316
+ def get_models_path(service_name: "api")
317
+ [
318
+ {
319
+ api: "../#{service_name}/db",
320
+ worker: "./db"
321
+ },
322
+ {
323
+ api: "../#{service_name}/app/models",
324
+ worker: "./app/models"
325
+ },
326
+ {
327
+ api: "../#{service_name}/spec/factories",
328
+ worker: "./spec/factories"
329
+ }
330
+ ]
331
+ end
332
+
333
+ def file_diff(paths = [])
334
+ paths.map do |path|
335
+ stat(path)[:last_update]
336
+ end
337
+ end
338
+
339
+ def stat(path)
340
+ s = File::Stat.new(path)
341
+ last_update = s.mtime.to_s
342
+ last_status_change = s.ctime.to_s
343
+ last_access = s.atime.to_s
344
+ {
345
+ last_update: last_update,
346
+ last_status_change: last_status_change,
347
+ last_access: last_access
348
+ }
349
+ end
350
+
285
351
  def detect_change
286
352
  git_status = `git status`
287
353
  result =
data/lib/souls/init.rb CHANGED
@@ -34,7 +34,7 @@ module Souls
34
34
  url = "https://storage.googleapis.com/souls-bucket/github_actions/github.tgz"
35
35
  system("curl -OL #{url}")
36
36
  FileUtils.mkdir_p("#{app_name}/github")
37
- system("tar -zxvf ./#{file_name} -C #{app_name}/github/")
37
+ system("tar -zxvf ./#{file_name} -C #{app_name}/")
38
38
  FileUtils.rm(file_name)
39
39
  end
40
40
 
@@ -74,12 +74,13 @@ module Souls
74
74
  choices = ["1. SOULs GraphQL API", "2. SOULs Pub/Sub Worker", "3. SOULs Frontend Web"]
75
75
  choice_num = prompt.select(Paint["Select Strain: ", :cyan], choices)[0].to_i
76
76
  case choice_num
77
- when 1, 2
77
+ when 1
78
78
  service_name = (strains[choice_num.to_i - 1]).to_s
79
79
  Souls::Init.download_souls(app_name: app_name, service_name: service_name)
80
80
  Souls::Init.mother_config_init(app_name: app_name)
81
81
  Souls::Init.download_github_actions(app_name: app_name)
82
82
  Souls::Init.initial_config_init(app_name: app_name, service_name: service_name)
83
+ Souls::Init.souls_api_credit(app_name: app_name, service_name: service_name)
83
84
  else
84
85
  puts(Paint["Coming Soon...", :blue])
85
86
  end
@@ -93,6 +94,9 @@ module Souls
93
94
  system("mkdir -p #{app_name}/apps/#{service_name}")
94
95
  system("tar -zxvf ./#{file_name} -C #{app_name}/apps/")
95
96
  FileUtils.rm(file_name)
97
+ end
98
+
99
+ def self.souls_api_credit(app_name: "souls", service_name: "api")
96
100
  line = Paint["====================================", :yellow]
97
101
  puts("\n")
98
102
  puts(line)
@@ -131,6 +135,9 @@ module Souls
131
135
 
132
136
  def self.download_worker
133
137
  current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
138
+ wrong_dir = %w[apps api worker]
139
+ raise(StandardError, "You are at wrong directory!Go to Mother Directory!") if wrong_dir.include?(current_dir_name)
140
+
134
141
  version = Souls.get_latest_version_txt(service_name: "worker").join(".")
135
142
  file_name = "worker-v#{version}.tgz"
136
143
  url = "https://storage.googleapis.com/souls-bucket/boilerplates/workers/#{file_name}"
@@ -0,0 +1,6 @@
1
+ require_relative "./release/methods"
2
+
3
+ module Souls
4
+ module Release
5
+ end
6
+ end
@@ -0,0 +1,39 @@
1
+ module Souls
2
+ module Release
3
+ class << self
4
+ def return_method
5
+ system("gem install souls")
6
+ sleep(3)
7
+ current_souls_ver = Souls::VERSION.strip.split(".").map(&:to_i)
8
+ prompt = TTY::Prompt.new
9
+ choices = [
10
+ "1. Patch(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'patch')})",
11
+ "2. Minor(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'minor')})",
12
+ "3. Major(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'major')})"
13
+ ]
14
+ choice_num = prompt.select("Select Version: ", choices)[0].to_i
15
+ update_kinds = %w[patch minor major]
16
+ update_kind = update_kinds[choice_num - 1]
17
+ souls_new_ver = Souls.version_detector(current_ver: current_souls_ver, update_kind: update_kind)
18
+ status = Paint["Saving Repo...", :yellow]
19
+ Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
20
+ Whirly.status = status
21
+ %w[api worker].each do |s_name|
22
+ Souls.update_service_gemfile(service_name: s_name, version: souls_new_ver)
23
+ result = Paint[Souls.update_repo(service_name: s_name, update_kind: update_kind), :green]
24
+ Whirly.status = result
25
+ end
26
+ Souls.overwrite_version(new_version: souls_new_ver)
27
+ puts("before add")
28
+ system("git add .")
29
+ puts("before commit")
30
+ system("git commit -m 'souls update v#{souls_new_ver}'")
31
+ puts("before build")
32
+ system("rake build")
33
+ system("rake release")
34
+ Whirly.status = Paint["soul-v#{souls_new_ver} successfully updated!"]
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.26.4".freeze
2
+ VERSION = "0.26.8".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.5.4
1
+ 0.5.8
@@ -1 +1 @@
1
- 0.5.4
1
+ 0.5.8
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.4
4
+ version: 0.26.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-08-03 00:00:00.000000000 Z
13
+ date: 2021-08-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -124,6 +124,8 @@ files:
124
124
  - lib/souls/generate/rspec_resolver.rb
125
125
  - lib/souls/generate/type.rb
126
126
  - lib/souls/init.rb
127
+ - lib/souls/release.rb
128
+ - lib/souls/release/methods.rb
127
129
  - lib/souls/version.rb
128
130
  - lib/souls/versions/.souls_api_version
129
131
  - lib/souls/versions/.souls_worker_version