souls 0.24.4 → 0.24.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: 949cc1a83a8fd104832c205db7f8eab135bc3298523751538a7d767769b7ac27
4
- data.tar.gz: 2fa4257d0231d0363989a9ec85028276e68e33752c3a57067b1e5f5895dcdb24
3
+ metadata.gz: 5e1ce66f5d9dc4581e6283e4585ebaaa91dcbbf6595f9c723f1110ecefaf9683
4
+ data.tar.gz: c6b20a59319f44a24beea293c5ea4c5948d121230d2220cfe6292fa789cfbfdf
5
5
  SHA512:
6
- metadata.gz: ef3ab7e883db0805b78b41e5f51dfb2666617e99a07b490b84c36622c216efd81ac0346dbb9dd226db06704ca24828dc2cdb40c699516add438c318512736ce9
7
- data.tar.gz: 0ec076686c79072c96978a55430d00a59cca6c1978077e8a48dd3108dc074fc2770f4a8a9c42d4b490308380fa5ab7d4cc6c2e410ab34f376fefcd35a87e468b
6
+ metadata.gz: 301c64176cb961f8e88532e06761c97d894c3c878674773e950275ecf7e83fad4ccd5d8a8985ab9178306d647716679dfcca391081ce59bf838a070e18510888
7
+ data.tar.gz: 4df80954681e798712153e297c6662d3faf9d8c6241bcb7ac8dc8094b65b204a336f6eeff375743de5fe3715b5045cf07d1daf45a2a2ef3f4a69e52a7fe847ee
data/exe/souls CHANGED
@@ -32,8 +32,9 @@ begin
32
32
  strain = $stdin.gets.chomp.to_i
33
33
  case strain
34
34
  when 1, 2
35
- Souls::Init.download_souls(app_name: app_name, repository_name: "souls_#{STRAINS[strain.to_i - 1]}")
36
- Souls::Init.initial_config_init(app_name: app_name, strain: STRAINS[strain.to_i - 1])
35
+ service_name = (STRAINS[strain.to_i - 1]).to_s
36
+ Souls::Init.download_souls(app_name: app_name, service_name: service_name)
37
+ Souls::Init.initial_config_init(app_name: app_name, service_name: service_name)
37
38
  else
38
39
  puts(Paint["Coming Soon...", :blue])
39
40
  end
@@ -94,6 +95,33 @@ begin
94
95
  Souls.update_gemfile
95
96
  Whirly.status = "Done!"
96
97
  end
98
+ when "release"
99
+ current_souls_ver = Souls::VERSION.strip.split(".").map(&:to_i)
100
+ prompt = TTY::Prompt.new
101
+ choices = [
102
+ "1. Patch(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'patch')})",
103
+ "2. Minor(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'minor')})",
104
+ "3. Major(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'major')})"
105
+ ]
106
+ choice_num = prompt.select("Select Version: ", choices)[0].to_i
107
+ update_kinds = %w[patch minor major]
108
+ update_kind = update_kinds[choice_num - 1]
109
+ souls_new_ver = Souls.version_detector(current_ver: current_souls_ver, update_kind: update_kind)
110
+
111
+ status = Paint["Saving Repo...", :yellow]
112
+ Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
113
+ Whirly.status = status
114
+ %w[api worker].each do |s_name|
115
+ result = Paint[Souls.update_repo(service_name: s_name, update_kind: update_kind), :green]
116
+ Whirly.status = result
117
+ end
118
+ Souls.overwrite_version(new_version: souls_new_ver)
119
+ system("rake build")
120
+ system("rake release")
121
+ Whirly.status = Paint["soul-v#{souls_new_ver} successfully updated!"]
122
+ end
123
+ when "update"
124
+ puts(Paint["Coming soon..", :cyan])
97
125
  when "add"
98
126
  graphql_class = ARGV[1]
99
127
  case graphql_class
@@ -222,4 +250,5 @@ begin
222
250
  end
223
251
  rescue StandardError => e
224
252
  puts(Paint[e, :red])
253
+ puts(e.backtrace)
225
254
  end
data/lib/souls.rb CHANGED
@@ -3,11 +3,14 @@ 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 "dotenv/load"
6
7
  require "json"
7
8
  require "fileutils"
8
9
  require "net/http"
9
10
  require "paint"
10
11
  require "whirly"
12
+ require "google/cloud/firestore"
13
+ require "tty-prompt"
11
14
 
12
15
  module Souls
13
16
  SOULS_METHODS = %w[
@@ -165,6 +168,107 @@ module Souls
165
168
  end
166
169
  end
167
170
 
171
+ def update_repo(service_name: "api", update_kind: "patch")
172
+ current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
173
+ current_ver = get_latest_version_txt(service_name: service_name)
174
+ new_ver = version_detector(current_ver: current_ver, update_kind: update_kind)
175
+ bucket_url = "gs://souls-bucket/boilerplates"
176
+ file_name = "#{service_name}-v#{new_ver}.tgz"
177
+ release_name = "#{service_name}-latest.tgz"
178
+
179
+ case current_dir_name
180
+ when "souls"
181
+ system("echo 'v#{new_ver}' > lib/souls/versions/.souls_#{service_name}_version")
182
+ system("cd apps/ && tar -czf ../#{service_name}.tgz #{service_name}/ && cd ..")
183
+ when "api", "worker", "console", "admin", "media"
184
+ system("echo 'v#{new_ver}' > lib/souls/versions/.souls_#{service_name}_version")
185
+ system("cd .. && tar -czf ../#{service_name}.tgz #{service_name}/ && cd #{service_name}")
186
+ else
187
+ raise(StandardError, "You are at wrong directory!")
188
+ end
189
+
190
+ system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{file_name}")
191
+ system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{release_name}")
192
+ FileUtils.rm("#{service_name}.tgz")
193
+ "#{service_name}-v#{new_ver} Succefully Stored to GCS! "
194
+ end
195
+
196
+ def version_detector(current_ver: [0, 0, 1], update_kind: "patch")
197
+ case update_kind
198
+ when "patch"
199
+ "#{current_ver[0]}.#{current_ver[1]}.#{current_ver[2] + 1}"
200
+ when "minor"
201
+ "#{current_ver[0]}.#{current_ver[1] + 1}.0"
202
+ when "major"
203
+ "#{current_ver[0] + 1}.0.0"
204
+ else
205
+ raise(StandardError, "Wrong version!")
206
+ end
207
+ end
208
+
209
+ def overwrite_version(new_version: "0.1.1")
210
+ FileUtils.rm("./lib/souls/version.rb")
211
+ file_path = "./lib/souls/version.rb"
212
+ File.open(file_path, "w") do |f|
213
+ f.write(<<~TEXT)
214
+ module Souls
215
+ VERSION = "#{new_version}".freeze
216
+ public_constant :VERSION
217
+ end
218
+ TEXT
219
+ end
220
+ true
221
+ rescue StandardError, e
222
+ raise(StandardError, e)
223
+ end
224
+
225
+ def get_latest_version_txt(service_name: "api")
226
+ current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
227
+ case current_dir_name
228
+ when "souls"
229
+ file_path = "./lib/souls/versions/.souls_version"
230
+ when "api", "worker", "console", "admin", "media"
231
+ file_path = ".../lib/souls/versions/.souls_#{service_name}_version"
232
+ else
233
+ raise(StandardError, "You are at wrong directory!")
234
+ end
235
+ File.open(file_path, "r") do |f|
236
+ f.readlines[0].strip.split(".").map(&:to_i)
237
+ end
238
+ end
239
+
240
+ def get_latest_version(service_name: "api")
241
+ firestore = Google::Cloud::Firestore.new(project_id: ENV["FIRESTORE_PID"])
242
+ versions = firestore.doc("#{service_name}/1")
243
+ if versions.get.exists?
244
+ versions = firestore.col(service_name.to_s)
245
+ query = versions.order("version_counter", "desc").limit(1)
246
+ query.get do |v|
247
+ return {
248
+ version_counter: v.data[:version_counter],
249
+ version: v.data[:version],
250
+ file_url: v.data[:file_url],
251
+ create_at: v.data[:create_at]
252
+ }
253
+ end
254
+ else
255
+ { version_counter: 0 }
256
+ end
257
+ end
258
+
259
+ def detect_change
260
+ git_status = `git status`
261
+ result =
262
+ %w[api worker].map do |service_name|
263
+ if git_status.include?("apps/#{service_name}/")
264
+ service_name
265
+ else
266
+ next
267
+ end
268
+ end
269
+ result.compact
270
+ end
271
+
168
272
  def configure
169
273
  self.configuration ||= Configuration.new
170
274
  yield(configuration)
data/lib/souls/init.rb CHANGED
@@ -9,14 +9,17 @@ module Souls
9
9
  data[0]["tag_name"]
10
10
  end
11
11
 
12
- def self.initial_config_init(app_name: "souls", strain: "api")
13
- FileUtils.touch("./#{app_name}/config/souls.rb")
14
- file_path = "./#{app_name}/config/souls.rb"
12
+ def self.initial_config_init(app_name: "souls", service_name: "api")
13
+ FileUtils.touch("./#{app_name}/#{service_name}/config/souls.rb")
14
+ file_path = "./#{app_name}/#{service_name}/config/souls.rb"
15
15
  File.open(file_path, "w") do |f|
16
16
  f.write(<<~TEXT)
17
17
  Souls.configure do |config|
18
18
  config.app = "#{app_name}"
19
- config.strain = "#{strain}"
19
+ config.project_id = "souls-api"
20
+ config.strain = "#{service_name}"
21
+ config.worker_endpoint = "https://worker.com"
22
+ config.fixed_gems = ["excluded_gem"]
20
23
  end
21
24
  TEXT
22
25
  end
@@ -24,33 +27,36 @@ module Souls
24
27
  puts(e)
25
28
  end
26
29
 
27
- def self.download_souls(app_name: "souls", repository_name: "souls_api ")
28
- version = get_version(repository_name: repository_name)
29
- system("curl -OL https://github.com/elsoul/#{repository_name}/archive/#{version}.tar.gz")
30
- system("tar -zxvf ./#{version}.tar.gz")
31
- system("mkdir #{app_name}")
32
- folder = version.delete("v")
33
- `cp -r #{repository_name}-#{folder}/. #{app_name}/`
34
- `rm -rf #{version}.tar.gz && rm -rf #{repository_name}-#{folder}`
30
+ def self.download_souls(app_name: "souls", service_name: "api")
31
+ file_name = "#{service_name}-latest.tgz"
32
+ url = "https://storage.googleapis.com/souls-bucket/boilerplates/#{service_name.pluralize}/#{file_name}"
33
+ system("curl -OL #{url}")
34
+ system("mkdir -p #{app_name}/#{service_name}")
35
+ system("tar -zxvf ./#{file_name} -C #{app_name}/")
36
+ FileUtils.rm(file_name)
35
37
  line = Paint["====================================", :yellow]
36
38
  puts("\n")
37
39
  puts(line)
38
- txt = <<~TEXT
40
+ txt2 = <<~TEXT
39
41
  _____ ____ __ ____#{' '}
40
- / ___// __ \\/ / / / / _____
41
- \\__ \\/ / / / / / / / / ___/
42
- ___/ / /_/ / /_/ / /___(__ )#{' '}
43
- /____/\\____/\\____/_____/____/#{' '}
42
+ / ___// __ \\/ / / / / %{red1}
43
+ \\__ \\/ / / / / / / / %{red2}
44
+ ___/ / /_/ / /_/ / /___%{red3}#{' '}
45
+ /____/\\____/\\____/_____%{red4}#{' '}
44
46
  TEXT
45
- message = Paint[txt, :cyan]
46
- puts(message)
47
+ red1 = ["_____", :red]
48
+ red2 = ["/ ___/", :red]
49
+ red3 = ["(__ )", :red]
50
+ red4 = ["/____/", :red]
51
+ ms = Paint % [txt2, :cyan, { red1: red1, red2: red2, red3: red3, red4: red4 }]
52
+ puts(ms)
47
53
  puts(line)
48
54
  welcome = Paint["Welcome to SOULs!", :white]
49
55
  puts(welcome)
50
56
  souls_ver = Paint["SOULs Version: #{Souls::VERSION}", :white]
51
57
  puts(souls_ver)
52
58
  puts(line)
53
- cd = Paint["Easy to Run\n$ cd #{app_name}\n$ bundle\n$ souls s\nGo To : http://localhost:3000\n\nDoc: https://souls.elsoul.nl",
59
+ cd = Paint["Easy to Run\n$ cd #{app_name}/#{service_name}\n$ bundle\n$ souls s\nGo To : http://localhost:3000\n\nDoc: https://souls.elsoul.nl",
54
60
  :white]
55
61
  puts(cd)
56
62
  puts(line)
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.24.4".freeze
2
+ VERSION = "0.24.8".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -0,0 +1 @@
1
+ v0.24.8
@@ -0,0 +1 @@
1
+ 0.24.7
@@ -0,0 +1 @@
1
+ v0.24.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.24.4
4
+ version: 0.24.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -12,6 +12,20 @@ bindir: exe
12
12
  cert_chain: []
13
13
  date: 2021-07-22 00:00:00.000000000 Z
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: google-cloud-firestore
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.6.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 2.6.1
15
29
  - !ruby/object:Gem::Dependency
16
30
  name: paint
17
31
  requirement: !ruby/object:Gem::Requirement
@@ -26,6 +40,20 @@ dependencies:
26
40
  - - '='
27
41
  - !ruby/object:Gem::Version
28
42
  version: 2.2.1
43
+ - !ruby/object:Gem::Dependency
44
+ name: tty-prompt
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '='
48
+ - !ruby/object:Gem::Version
49
+ version: 0.23.1
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '='
55
+ - !ruby/object:Gem::Version
56
+ version: 0.23.1
29
57
  - !ruby/object:Gem::Dependency
30
58
  name: whirly
31
59
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +108,9 @@ files:
80
108
  - lib/souls/generate/type.rb
81
109
  - lib/souls/init.rb
82
110
  - lib/souls/version.rb
111
+ - lib/souls/versions/.souls_api_version
112
+ - lib/souls/versions/.souls_version
113
+ - lib/souls/versions/.souls_worker_version
83
114
  homepage: https://souls.elsoul.nl
84
115
  licenses:
85
116
  - Apache-2.0