souls 0.26.5 → 0.26.9

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: 0a8d4229808e756b4642678280b1563b041def4ab33e427197741cb6e857becf
4
- data.tar.gz: e6cc0ce93f9a19f00e7709674c8f80e6947c9d698798cd4a703c1ca4d066b408
3
+ metadata.gz: abb403a2afdcb6e2de2502a8f22ef0977224dbc17cd2145fd8ae6fd1b690595d
4
+ data.tar.gz: bdaa332725d41ec2e2c267544d17805cf278d908524309acc8c52724593a0b0e
5
5
  SHA512:
6
- metadata.gz: 4aaaeb7f11a2e3b9279f80ca7ec4803e24eee7e627cd6e4466b09636589cfc3390837841cbc74fda328d2b17808b66fda8db80801425b1292e3da0dfb4b3fb85
7
- data.tar.gz: e96c0bef761a865e576ddf48cf396bcbbb49c5d020504e868c55f032dc05061a9210bc2088dbc71b6acb3b5eacc08478333b2366d22a79f022d35d44a7835dc9
6
+ metadata.gz: bc0bd6eb6dffcafdb444b41bd68d93822c366280af9c2a9da59e8e5d2eb402041b51765d3e346590e8c0999ec6161081b75733d04b83641d88787e8f147f1e4e
7
+ data.tar.gz: d55eaa383f6107f409c8c2df0192db434ac6307ba578f36be8d20879ba0ec13b4aee54b14fc020d3a05e3fb6d10fa4ce36324ff5b9c616df67e208c09a702609
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,8 @@ 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"
7
+ require "date"
6
8
  require "dotenv/load"
7
9
  require "json"
8
10
  require "fileutils"
@@ -174,7 +176,6 @@ module Souls
174
176
  bucket_url = "gs://souls-bucket/boilerplates"
175
177
  file_name = "#{service_name}-v#{new_ver}.tgz"
176
178
  release_name = "#{service_name}-latest.tgz"
177
- update_service_gemfile(service_name: service_name)
178
179
 
179
180
  case current_dir_name
180
181
  when "souls"
@@ -257,7 +258,7 @@ module Souls
257
258
  end
258
259
  end
259
260
 
260
- def update_service_gemfile(service_name: "api")
261
+ def update_service_gemfile(service_name: "api", version: "0.0.1")
261
262
  file_dir = "./apps/#{service_name}"
262
263
  file_path = "#{file_dir}/Gemfile"
263
264
  gemfile_lock = "#{file_dir}/Gemfile.lock"
@@ -269,7 +270,7 @@ module Souls
269
270
  if gem[0] == "souls"
270
271
  old_ver = gem[1].split(".")
271
272
  old_ver[2] = (old_ver[2].to_i + 1).to_s
272
- new_line.write(" gem \"souls\", \"#{old_ver.join('.')}\"\n")
273
+ new_line.write(" gem \"souls\", \"#{version}\"\n")
273
274
  else
274
275
  new_line.write(line)
275
276
  end
@@ -282,6 +283,72 @@ module Souls
282
283
  puts(Paint["\nSuccessfully Updated #{service_name} Gemfile!", :green])
283
284
  end
284
285
 
286
+ def update_models
287
+ current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
288
+ permitted_dirs = %w[worker api]
289
+ unless permitted_dirs.include?(current_dir_name)
290
+ raise(StandardError, "You are at wrong directory!Go to API or Worker Directory!")
291
+ end
292
+
293
+ cp_dir = get_models_path(service_name: current_dir_name)
294
+ cp_dir.each do |path|
295
+ cp_and_dl_files(api_dir: path[:api], worker_dir: path[:worker])
296
+ end
297
+ end
298
+
299
+ 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"])
302
+
303
+ api_latest_date = Date.parse(api_file_data.max)
304
+ worker_latest_date = Date.parse(worker_file_data.max)
305
+
306
+ if api_latest_date > worker_latest_date
307
+ FileUtils.rm_rf(api_dir)
308
+ FileUtils.mkdir(api_dir) unless Dir.exist?(api_dir)
309
+ system("cp -r #{worker_dir}/* #{api_dir}")
310
+ else
311
+ FileUtils.rm_rf(worker_dir)
312
+ FileUtils.mkdir(worker_dir) unless Dir.exist?(worker_dir)
313
+ system("cp -r #{api_dir}/* #{worker_dir}")
314
+ end
315
+ end
316
+
317
+ def get_models_path(service_name: "api")
318
+ [
319
+ {
320
+ api: "../#{service_name}/db",
321
+ worker: "./db"
322
+ },
323
+ {
324
+ api: "../#{service_name}/app/models",
325
+ worker: "./app/models"
326
+ },
327
+ {
328
+ api: "../#{service_name}/spec/factories",
329
+ worker: "./spec/factories"
330
+ }
331
+ ]
332
+ end
333
+
334
+ def file_diff(paths = [])
335
+ paths.map do |path|
336
+ stat(path)[:last_update]
337
+ end
338
+ end
339
+
340
+ def stat(path)
341
+ s = File::Stat.new(path)
342
+ last_update = s.mtime.to_s
343
+ last_status_change = s.ctime.to_s
344
+ last_access = s.atime.to_s
345
+ {
346
+ last_update: last_update,
347
+ last_status_change: last_status_change,
348
+ last_access: last_access
349
+ }
350
+ end
351
+
285
352
  def detect_change
286
353
  git_status = `git status`
287
354
  result =
data/lib/souls/init.rb CHANGED
@@ -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.5".freeze
2
+ VERSION = "0.26.9".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.5.5
1
+ 0.5.9
@@ -1 +1 @@
1
- 0.5.5
1
+ 0.5.9
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.5
4
+ version: 0.26.9
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