souls 0.36.1 → 0.37.0

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: d6a59673cbe8fbbc5fd02e75a7ca5d04d5e190e0555be86f721c3ef3c1d33624
4
- data.tar.gz: c4f4e094d3bc26d79c9d1bc37c2f15361f191335cc15fcc29a74e3c85af392ae
3
+ metadata.gz: 7f843f3295ec17169c7824a495e36bd0575a598622dd0f103e1f7aed2bf9336b
4
+ data.tar.gz: ce6c1e59f43dc68b4ec422a882afe5fe3181e45de743470c3c836caf137edf43
5
5
  SHA512:
6
- metadata.gz: 1957d2a8a3a1389a2c6306c3a695f2c4e5e7b6ff03c46c9e552961a77c8f277a9a58c12a92ba27b5dc6d2791bfdf2a85a888decab54c0481ac2df8464fcdf6c4
7
- data.tar.gz: 936917a7190919b9fb48b0aa69a08e09cfa9225b12bbbf94209bfc70e6acbca4a0e1d3f2568851e2dba2c88906315ca3673d7f676c4c436a974611fdf3be6558
6
+ metadata.gz: 2508e23509136d0ca103d9b818d51c36f570d7d0c5795121fe30eace9be3d514f9e8f3f72e90dc20b180d060b71260ea747f5c4284a31d3af1556fa945701d71
7
+ data.tar.gz: 38abb11be46fb55b3fea8a1bee97bfbf81fb8abd08b767bc706066e282dc3f992fb44f26bbc91677eca18ebe0142beb2cb35d52b565bbbc6011a1399e2eac172
@@ -2,6 +2,9 @@ module Souls
2
2
  module Create
3
3
  class << self
4
4
  def worker(worker_name: "mailer")
5
+ file_dir = "apps/#{worker_name}"
6
+ raise(StandardError, "Same Worker Already Exist!") if Dir.exist?(file_dir)
7
+
5
8
  workers = Souls.configuration.workers
6
9
  port = 3000 + workers.size
7
10
  download_worker(worker_name: worker_name)
@@ -10,6 +13,7 @@ module Souls
10
13
  workflow(worker_name: worker_name)
11
14
  procfile(worker_name: worker_name, port: port)
12
15
  mother_procfile(worker_name: worker_name)
16
+ souls_config_init(worker_name: worker_name)
13
17
  end
14
18
 
15
19
  def procfile(worker_name: "mailer", port: 3000)
@@ -173,6 +177,28 @@ end
173
177
  raise(StandardError, e)
174
178
  end
175
179
 
180
+ def souls_config_init(worker_name: "mailer")
181
+ app_name = Souls.configuration.app
182
+ project_id = Souls.configuration.project_id
183
+ config_dir = "apps/#{worker_name}/config"
184
+ FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
185
+ FileUtils.touch("#{config_dir}/souls.rb")
186
+ file_path = "#{config_dir}/souls.rb"
187
+ File.open(file_path, "w") do |f|
188
+ f.write(<<~TEXT)
189
+ Souls.configure do |config|
190
+ config.app = "#{app_name}"
191
+ config.project_id = "#{project_id}"
192
+ config.strain = "worker"
193
+ config.fixed_gems = ["excluded_gem"]
194
+ config.workers = []
195
+ end
196
+ TEXT
197
+ end
198
+ rescue StandardError => e
199
+ puts(e)
200
+ end
201
+
176
202
  def download_worker(worker_name: "mailer")
177
203
  raise(StandardError, "Can't use `worker` for worker. Change Name.") if worker_name == "worker"
178
204
 
@@ -2,88 +2,23 @@ module Souls
2
2
  module Sync
3
3
  class << self
4
4
  def model
5
- current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
6
- permitted_dirs = %w[worker api]
7
- unless permitted_dirs.include?(current_dir_name)
8
- raise(StandardError, "You are at wrong directory!Go to API or Worker Directory!")
9
- end
10
-
11
- cp_dir = get_models_path(service_name: current_dir_name)
12
- cp_dir.each do |path|
13
- cp_and_dl_files(api_dir: path[:api], worker_dir: path[:worker])
5
+ cp_dir = %w[db app/models spec/factories]
6
+ cp_dir.each do |dir|
7
+ cp_and_dl_files(dir: dir)
14
8
  end
15
9
  end
16
10
 
17
11
  private
18
12
 
19
- def file_diff(paths = [])
20
- paths.map do |path|
21
- stat(path)[:last_update]
22
- end
23
- end
24
-
25
- def stat(path)
26
- s = File::Stat.new(path)
27
- last_update = s.mtime.to_s
28
- last_status_change = s.ctime.to_s
29
- last_access = s.atime.to_s
30
- {
31
- last_update: last_update,
32
- last_status_change: last_status_change,
33
- last_access: last_access
34
- }
35
- end
36
-
37
- def cp_and_dl_files(api_dir: "", worker_dir: "")
38
- if Dir["#{worker_dir}/*.rb"].blank?
39
-
40
- api_latest_date = 1
41
- worker_latest_date = 0
42
- else
43
- api_file_data = file_diff(Dir["#{api_dir}/*.rb"])
44
- worker_file_data = file_diff(Dir["#{worker_dir}/*.rb"])
45
- # rubocop:disable Style/DateTime
46
- api_latest_date = DateTime.parse(api_file_data.max)
47
- worker_latest_date = DateTime.parse(worker_file_data.max)
48
- # rubocop:enable Style/DateTime
49
- end
50
-
51
- if api_latest_date < worker_latest_date
52
- FileUtils.rm_rf(api_dir) if Dir.exist?(api_dir)
53
- FileUtils.mkdir(api_dir) unless Dir.exist?(api_dir)
54
- system("cp -r #{worker_dir}/* #{api_dir}")
55
- else
56
- FileUtils.rm_rf(worker_dir) if Dir.exist?(worker_dir)
57
- FileUtils.mkdir(worker_dir) unless Dir.exist?(worker_dir)
58
- system("cp -r #{api_dir}/* #{worker_dir}")
59
- end
60
- rescue StandardError => e
61
- puts(Paint[e, :red])
62
- end
63
-
64
- def get_models_path(service_name: "api")
65
- case service_name
66
- when "api"
67
- api_path = "."
68
- worker_path = "../worker"
69
- when "worker"
70
- api_path = "../api"
71
- worker_path = "."
13
+ def cp_and_dl_files(dir: "db")
14
+ worker_paths = Souls.configuration.workers.map { |n| n[:name] }
15
+ worker_paths.each do |path|
16
+ cp_path = "./apps/api/#{dir}"
17
+ old_path = "./apps/#{path}/#{dir}"
18
+ FileUtils.rm_rf(old_path) if Dir.exist?(old_path)
19
+ FileUtils.mkdir(old_path) unless Dir.exist?(old_path)
20
+ system("cp -r #{cp_path}/* #{old_path}", chdir: Souls.get_mother_path)
72
21
  end
73
- [
74
- {
75
- api: "#{api_path}/db",
76
- worker: "#{worker_path}/db"
77
- },
78
- {
79
- api: "#{api_path}/app/models",
80
- worker: "#{worker_path}/app/models"
81
- },
82
- {
83
- api: "#{api_path}/spec/factories",
84
- worker: "#{worker_path}/spec/factories"
85
- }
86
- ]
87
22
  end
88
23
  end
89
24
  end
data/lib/souls/index.rb CHANGED
@@ -3,6 +3,7 @@ require_relative "./cli/index"
3
3
  require_relative "./init"
4
4
  require_relative "./version"
5
5
  require_relative "./worker/index"
6
+ require_relative "./utils/index"
6
7
 
7
8
  module Souls
8
9
  module Api
@@ -0,0 +1,11 @@
1
+ module Souls
2
+ module Utils
3
+ def get_mother_path
4
+ FileUtils.pwd.split(Souls.configuration.app)[0] + Souls.configuration.app
5
+ end
6
+
7
+ def get_api_path
8
+ FileUtils.pwd.split(Souls.configuration.app)[0] + Souls.configuration.app + "/apps/api"
9
+ end
10
+ end
11
+ end
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.36.1".freeze
2
+ VERSION = "0.37.0".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.15.1
1
+ 0.16.0
@@ -1 +1 @@
1
- 0.15.1
1
+ 0.16.0
data/lib/souls.rb CHANGED
@@ -9,6 +9,7 @@ require "whirly"
9
9
  require "tty-prompt"
10
10
 
11
11
  module Souls
12
+ extend Souls::Utils
12
13
  SOULS_METHODS = %w[
13
14
  model
14
15
  query
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.1
4
+ version: 0.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
8
8
  - KishiTheMechanic
9
9
  - James Neve
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-09-01 00:00:00.000000000 Z
13
+ date: 2021-09-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -144,6 +144,7 @@ files:
144
144
  - lib/souls/cli/upgrade/index.rb
145
145
  - lib/souls/index.rb
146
146
  - lib/souls/init.rb
147
+ - lib/souls/utils/index.rb
147
148
  - lib/souls/version.rb
148
149
  - lib/souls/versions/.souls_api_version
149
150
  - lib/souls/versions/.souls_worker_version
@@ -158,7 +159,7 @@ metadata:
158
159
  homepage_uri: https://souls.elsoul.nl
159
160
  source_code_uri: https://github.com/elsoul/souls
160
161
  changelog_uri: https://github.com/elsoul/souls
161
- post_install_message:
162
+ post_install_message:
162
163
  rdoc_options: []
163
164
  require_paths:
164
165
  - lib
@@ -174,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
175
  version: '0'
175
176
  requirements: []
176
177
  rubygems_version: 3.2.22
177
- signing_key:
178
+ signing_key:
178
179
  specification_version: 4
179
180
  summary: SOULs はサーバーレスフルスタックフレームワークです。柔軟な Ruby GraphQL API と Worker はルーティングの必要がありません。
180
181
  クラウド環境への自動デプロイ、CI/CD ワークフローを標準装備。開発者がビジネスロジックに集中し、楽しくコードが書けるような環境を目指しています。