souls 0.30.10 → 0.32.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: 662fb44f2b3215a7d00391f43f1634b30252c7906fb46a41e7aa3433e90b80dc
4
- data.tar.gz: ab691832bb96a5b741d7a0408cd235d4b0fb543579d206594a40273d72e1c56b
3
+ metadata.gz: 629d9272b1d1b1f8c09898cb928b72a7ff0077713386911b5e6dd6449b50b919
4
+ data.tar.gz: d67c0a7542abf5daaf1c9c909343ba133a40cd46d576a01e89da432960aa11c0
5
5
  SHA512:
6
- metadata.gz: 8714483b126cd1ee860ef4993c85b2c096532deba10380cee55fbfc00f7d6f65009a9bb4b50995ebab41c7fcc94579425b61eabac8e3909aba5915c919080bb7
7
- data.tar.gz: 98f558afb85dcda6e7ae347622c603683a40c607e4403388743d61439f4895c2c5de0c84e98a5a3857f7352afe8b3ee189e9e102278f66cec6bc4e29720819d5
6
+ metadata.gz: 8a7177bc0f0b933516487a0ebf238c54c9d4ca4a711fa2804c48d5b2bebdb03d10e7ccf81c8989ddcb99a5e089537aab5ab025b8a452ec8b3a5eb5855f844d3f
7
+ data.tar.gz: a50e58aba5430903013f8334922032ef900698a6866fc1b6547bbf3692e945ff90fe82908a5b18f1034e803997a5cd7585f67f5bd031c53f52986c5b681f02d5
data/README.md CHANGED
@@ -21,12 +21,18 @@
21
21
 
22
22
  Welcome to SOULs Serverless Application Framework!
23
23
 
24
- SOULs is a Serverless Application Framework with Ruby GraphQL.
25
- SOULs has 3 strains, API, Worker, and Frontend. It can be used in combination according to the purpose. SOULs Backend GraphQL Ruby & Frontend Relay are Scalable and Easy to deploy to Google Cloud. No more routing for Backends!
26
- You can focus on your business logic.
24
+ SOULs はサーバーレスフルスタックフレームワークです。柔軟な Ruby GraphQL API Worker はルーティングの必要がありません。
25
+ クラウド環境への自動デプロイ、CI/CD ワークフローを標準装備。開発者がビジネスロジックに集中し、楽しくコードが書けるような環境を目指しています。
26
+
27
+ SOULs バックエンドには `API` と `Worker` の 2 つのタイプがあります。
28
+ `API` は主にデータをフロントエンドへ提供します。`Worker` は主に `タスク` の処理を行います
27
29
 
28
30
  ![画像](https://storage.googleapis.com/souls-bucket/imgs/souls-structure.jpg)
29
31
 
32
+ 現在のバージョンでは SOULs `API` と `Worker` を Github Actions を使って Google Cloud Run へそれぞれデプロイします。
33
+
34
+ SOULs フレームワークでは [Monorepo](https://en.wikipedia.org/wiki/Monorepo) によって一つのパッケージでアプリケーションを管理します。
35
+
30
36
  SOULs creates 3 types of framework.
31
37
 
32
38
  1. API - GraphQL (Ruby) - Simple API - Cloud Run
@@ -72,13 +78,11 @@ Or install it yourself as:
72
78
  And Create Your APP
73
79
 
74
80
  $ souls new app_name
81
+ $ cd apps/api/app_name
82
+ $ bundle
83
+ $ souls s
75
84
 
76
- ## Choose SOULs Type:
77
85
 
78
- Select Strain:
79
- 1. SOULs GraphQL API
80
- 2. SOULs Worker
81
- 3. SOULs Frontend Web
82
86
 
83
87
 
84
88
  ## Gemfile 自動更新アップデート
@@ -99,7 +103,7 @@ Souls.configure do |config|
99
103
  config.app = "souls-api"
100
104
  config.project_id = "souls-api"
101
105
  config.strain = "api"
102
- config.worker_endpoint = "https://worker.com"
106
+ config.github_repo = "elsoul/souls"
103
107
  config.fixed_gems = ["selenium-webdriver", "pg"]
104
108
  end
105
109
  ```
data/exe/souls CHANGED
@@ -20,7 +20,7 @@ begin
20
20
  Souls::Api::Generate.public_send(method_name, class_name: class_name)
21
21
  Whirly.status = "Done!"
22
22
  end
23
- when "schema:update"
23
+ when "update"
24
24
  class_name = ARGV[2]
25
25
  status = Paint["Running SOULs Update Commands...", :yellow]
26
26
  Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
@@ -34,6 +34,9 @@ begin
34
34
  Souls::Api::Update.rspec_resolver(class_name: class_name)
35
35
  Whirly.status = "Done!"
36
36
  end
37
+ when "d", "delete"
38
+ class_name = ARGV[2]
39
+ Souls::Api::Generate.delete_all(class_name: class_name)
37
40
  else
38
41
  puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
39
42
  end
@@ -73,62 +76,78 @@ begin
73
76
  system("bundle exec irb")
74
77
  end
75
78
  end
76
- when "i", "infra", "docker"
79
+ when "docker"
77
80
  send_method = ARGV[1]
78
81
  Souls::Docker.public_send(send_method)
79
82
  when "gcloud"
80
- args = ARGV
83
+ command = ARGV[1]
81
84
  status = Paint["Running Gcloud Commands...", :yellow]
82
85
  Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
83
86
  Whirly.status = status
84
- Souls::Gcloud.return_method(args)
87
+ case command
88
+ when "get_iam_key"
89
+ app_name = Souls.configuration.app
90
+ project_id = Souls.configuration.project_id
91
+ Souls::Gcloud::Iam.create_service_account(service_account: app_name)
92
+ Souls::Gcloud::Iam.create_service_account_key(service_account: app_name, project_id: project_id)
93
+ Souls::Gcloud::Iam.export_key_to_console
94
+ Souls::Gcloud.enable_permissions
95
+ Souls::Gcloud::Iam.add_permissions(service_account: app_name, project_id: project_id)
96
+ when "auth_login"
97
+ project_id = Souls.configuration.project_id
98
+ Souls::Gcloud.auth_login(project_id: project_id)
99
+ else
100
+ module_name = ARGV[1]
101
+ method_name = ARGV[2]
102
+ ARGV.shift(3)
103
+ key_strings = []
104
+ keys = []
105
+ ARGV.each { |n| n.include?(":") ? keys << n.gsub(":", "").to_sym : key_strings << n }
106
+ raise(StandardError, "wrong arguments!") unless keys.size == key_strings.size
107
+
108
+ params = keys.zip(key_strings).to_h
109
+ Object.const_get("Souls::Gcloud::#{module_name.camelize}").public_send(method_name.to_sym, **params)
110
+ end
85
111
  Whirly.status = "Done!"
86
112
  end
87
113
  when "-v", "--version", "v", "version", "-version", "--v"
88
114
  puts(Paint[Souls::VERSION, :white])
89
- when "gem:update", "gemfile:update"
90
- status = Paint["Checking for updates...", :yellow]
91
- Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
92
- Whirly.status = status
93
- Souls.update_gemfile
94
- Whirly.status = "Done!"
115
+ when "upgrade"
116
+ method_command = ARGV[1]
117
+ case method_command
118
+ when "gemfile", "gem"
119
+ status = Paint["Checking for updates...", :yellow]
120
+ Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
121
+ Whirly.status = status
122
+ Souls::Upgrade.update_gemfile
123
+ Whirly.status = "Done!"
124
+ end
125
+ else
126
+ puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
95
127
  end
96
128
  when "release"
97
129
  Souls::Release.gem_release
98
- when "model:update"
99
- status = Paint["Syncing Models...", :yellow]
100
- Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
101
- Whirly.status = status
102
- Souls.update_models
103
- Whirly.status = "API and Worker Both Models Synced!"
104
- end
105
- when "add"
106
- graphql_class = ARGV[1]
107
- case graphql_class
108
- when "mutation"
109
- Souls::Init.add_mutation(class_name: "user", file_name: "hoi")
110
- when "type"
111
- Souls::Init.add_type(class_name: "user", file_name: "hoi")
112
- when "connection"
113
- Souls::Init.add_connection(class_name: "user", file_name: "hoi")
114
- when "edge"
115
- Souls::Init.add_edge(class_name: "user", file_name: "hoi")
116
- when "rspec_mutation"
117
- Souls::Init.add_rspec_mutation(class_name: "user", file_name: "hoi")
130
+ when "sync"
131
+ target = ARGV[1]
132
+ case target
133
+ when "model", "m"
134
+ status = Paint["Syncing Models...", :yellow]
135
+ Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
136
+ Whirly.status = status
137
+ Souls::Sync.model
138
+ Whirly.status = "API and Worker Both Models Synced!"
139
+ end
118
140
  else
119
- puts(Paint["Wrong Argument!", :red])
141
+ puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
120
142
  end
121
- when "g", "generate"
122
- g_command = ARGV[1]
123
- case g_command
143
+ when "create"
144
+ service_name = ARGV[1]
145
+ case service_name
124
146
  when "worker"
125
147
  Souls::Init.download_worker
126
148
  else
127
149
  puts(Paint["Coming Soon...", :green])
128
150
  end
129
- when "d", "delete"
130
- class_name = ARGV[1]
131
- Souls::Api::Generate.delete_all(class_name: class_name)
132
151
  when "db:create"
133
152
  rack_env = ARGV[1]
134
153
  case rack_env
@@ -164,9 +183,6 @@ begin
164
183
  when "t", "test"
165
184
  system("rubocop -A")
166
185
  system("bundle exec rspec")
167
- when "run"
168
- system("docker build . -t souls -f Dockerfile.dev")
169
- system("docker run --rm --env-file .env -p 3000:3000 souls:latest")
170
186
  when "deploy"
171
187
  project_id = Souls.configuration.project_id
172
188
  system("gcloud builds submit --config=cloudbuild.yml --project #{project_id}")
data/lib/souls.rb CHANGED
@@ -5,7 +5,6 @@ require_relative "souls/api"
5
5
  require_relative "souls/worker"
6
6
  require_relative "souls/cli"
7
7
  require "date"
8
- require "dotenv/load"
9
8
  require "json"
10
9
  require "fileutils"
11
10
  require "net/http"
@@ -33,108 +32,6 @@ module Souls
33
32
  class << self
34
33
  attr_accessor :configuration
35
34
 
36
- def gemfile_latest_version
37
- file_path = "./Gemfile"
38
- updated_gems = []
39
- updated_gem_versions = []
40
- updated_lines = []
41
- from_dev = false
42
- File.open(file_path, "r") do |f|
43
- f.each_line do |line|
44
- from_dev = true if line.include?("group")
45
- next unless line.include?("gem ")
46
-
47
- gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
48
- url = URI("https://rubygems.org/api/v1/versions/#{gem[0]}/latest.json")
49
- res = Net::HTTP.get_response(url)
50
- data = JSON.parse(res.body)
51
- next if Souls.configuration.fixed_gems.include?(gem[0].to_s)
52
- next if data["version"].to_s == gem[1].to_s
53
-
54
- updated_lines << if from_dev
55
- " gem \"#{gem[0]}\", \"#{data['version']}\""
56
- else
57
- "gem \"#{gem[0]}\", \"#{data['version']}\""
58
- end
59
- updated_gems << (gem[0]).to_s
60
- updated_gem_versions << data["version"]
61
- system("gem update #{gem[0]}")
62
- end
63
- end
64
- {
65
- gems: updated_gems,
66
- lines: updated_lines,
67
- updated_gem_versions: updated_gem_versions
68
- }
69
- end
70
-
71
- def update_gemfile
72
- file_path = "./Gemfile"
73
- tmp_file = "./tmp/Gemfile"
74
- new_gems = gemfile_latest_version
75
- logs = []
76
- message = Paint["\nAlready Up to date!", :green]
77
- return "Already Up to date!" && puts(message) if new_gems[:gems].blank?
78
-
79
- @i = 0
80
- File.open(file_path, "r") do |f|
81
- File.open(tmp_file, "w") do |new_line|
82
- f.each_line do |line|
83
- gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
84
- if new_gems[:gems].include?(gem[0])
85
- old_ver = gem[1].split(".")
86
- new_ver = new_gems[:updated_gem_versions][@i].split(".")
87
- if old_ver[0] < new_ver[0]
88
- logs << Paint % [
89
- "#{gem[0]} v#{gem[1]} → %{red_text}",
90
- :white,
91
- {
92
- red_text: ["v#{new_gems[:updated_gem_versions][@i]}", :red]
93
- }
94
- ]
95
- elsif old_ver[1] < new_ver[1]
96
- logs << Paint % [
97
- "#{gem[0]} v#{gem[1]} → v#{new_ver[0]}.%{yellow_text}",
98
- :white,
99
- {
100
- yellow_text: ["#{new_ver[1]}.#{new_ver[2]}", :yellow]
101
- }
102
- ]
103
- elsif old_ver[2] < new_ver[2]
104
- logs << Paint % [
105
- "#{gem[0]} v#{gem[1]} → v#{new_ver[0]}.#{new_ver[1]}.%{green_text}",
106
- :white,
107
- {
108
- green_text: [(new_ver[2]).to_s, :green]
109
- }
110
- ]
111
- end
112
- if gem[0] == "souls"
113
- logs << Paint % [
114
- "\nSOULs Doc: %{cyan_text}",
115
- :white,
116
- { cyan_text: ["https://souls.elsoul.nl\n", :cyan] }
117
- ]
118
- end
119
- new_line.write("#{new_gems[:lines][@i]}\n")
120
- @i += 1
121
- else
122
- new_line.write(line)
123
- end
124
- end
125
- end
126
- end
127
- FileUtils.rm("./Gemfile")
128
- FileUtils.rm("./Gemfile.lock")
129
- FileUtils.mv("./tmp/Gemfile", "./Gemfile")
130
- system("bundle update")
131
- success = Paint["\n\nSuccessfully Updated These Gems!\n", :green]
132
- puts(success)
133
- logs.each do |line|
134
- puts(line)
135
- end
136
- end
137
-
138
35
  def update_repo(service_name: "api", update_kind: "patch")
139
36
  current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
140
37
  current_ver = get_latest_version_txt(service_name: service_name)
@@ -250,86 +147,6 @@ module Souls
250
147
  puts(Paint["\nSuccessfully Updated #{service_name} Gemfile!", :green])
251
148
  end
252
149
 
253
- def update_models
254
- current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
255
- permitted_dirs = %w[worker api]
256
- unless permitted_dirs.include?(current_dir_name)
257
- raise(StandardError, "You are at wrong directory!Go to API or Worker Directory!")
258
- end
259
-
260
- cp_dir = get_models_path(service_name: current_dir_name)
261
- cp_dir.each do |path|
262
- cp_and_dl_files(api_dir: path[:api], worker_dir: path[:worker])
263
- end
264
- end
265
-
266
- def cp_and_dl_files(api_dir: "", worker_dir: "")
267
- if Dir["#{worker_dir}/*.rb"].blank?
268
-
269
- api_latest_date = 1
270
- worker_latest_date = 0
271
- else
272
- api_file_data = file_diff(Dir["#{api_dir}/*.rb"])
273
- worker_file_data = file_diff(Dir["#{worker_dir}/*.rb"])
274
-
275
- api_latest_date = Date.parse(api_file_data.max)
276
- worker_latest_date = Date.parse(worker_file_data.max)
277
- end
278
-
279
- if api_latest_date < worker_latest_date
280
- FileUtils.rm_rf(api_dir) if Dir.exist?(api_dir)
281
- FileUtils.mkdir(api_dir) unless Dir.exist?(api_dir)
282
- system("cp -r #{worker_dir}/* #{api_dir}")
283
- else
284
- FileUtils.rm_rf(worker_dir) if Dir.exist?(worker_dir)
285
- FileUtils.mkdir(worker_dir) unless Dir.exist?(worker_dir)
286
- system("cp -r #{api_dir}/* #{worker_dir}")
287
- end
288
- end
289
-
290
- def get_models_path(service_name: "api")
291
- case service_name
292
- when "api"
293
- api_path = "."
294
- worker_path = "../worker"
295
- when "worker"
296
- api_path = "../api"
297
- worker_path = "."
298
- end
299
- [
300
- {
301
- api: "#{api_path}/db",
302
- worker: "#{worker_path}/db"
303
- },
304
- {
305
- api: "#{api_path}/app/models",
306
- worker: "#{worker_path}/app/models"
307
- },
308
- {
309
- api: "#{api_path}/spec/factories",
310
- worker: "#{worker_path}/spec/factories"
311
- }
312
- ]
313
- end
314
-
315
- def file_diff(paths = [])
316
- paths.map do |path|
317
- stat(path)[:last_update]
318
- end
319
- end
320
-
321
- def stat(path)
322
- s = File::Stat.new(path)
323
- last_update = s.mtime.to_s
324
- last_status_change = s.ctime.to_s
325
- last_access = s.atime.to_s
326
- {
327
- last_update: last_update,
328
- last_status_change: last_status_change,
329
- last_access: last_access
330
- }
331
- end
332
-
333
150
  def check_schema(class_name: "user")
334
151
  schema_data = get_columns_num(class_name: class_name)
335
152
  create_migration_data = get_create_migration_type(class_name: class_name)
@@ -109,7 +109,7 @@ module Souls
109
109
  false
110
110
  end
111
111
 
112
- def self.migrate(class_name: "souls")
112
+ def self.scaffold(class_name: "souls")
113
113
  singularized_class_name = class_name.singularize
114
114
  model(class_name: singularized_class_name)
115
115
  type(class_name: singularized_class_name)
@@ -130,10 +130,10 @@ module Souls
130
130
  raise(StandardError, e)
131
131
  end
132
132
 
133
- def self.migrate_all
133
+ def self.scaffold_all
134
134
  puts(Paint["Let's Go SOULs AUTO CRUD Assist!\n", :cyan])
135
135
  Souls::Api::Generate.get_tables.each do |table|
136
- Souls::Api::Generate.migrate(class_name: table.singularize)
136
+ Souls::Api::Generate.scaffold(class_name: table.singularize)
137
137
  puts(Paint["Generated #{table.camelize} CRUD Files\n", :yellow])
138
138
  end
139
139
  end
@@ -160,23 +160,5 @@ module Souls
160
160
  rescue StandardError => e
161
161
  raise(StandardError, e)
162
162
  end
163
-
164
- def self.update_delete(class_name: "souls")
165
- singularized_class_name = class_name.singularize.underscore
166
- pluralized_class_name = class_name.pluralize.underscore
167
- FileUtils.rm_rf("./app/graphql/mutations/#{singularized_class_name}")
168
- FileUtils.rm("./app/graphql/queries/#{singularized_class_name}.rb")
169
- FileUtils.rm("./app/graphql/queries/#{pluralized_class_name}.rb")
170
- FileUtils.rm("./app/graphql/resolvers/#{singularized_class_name}_search.rb")
171
- FileUtils.rm("./app/graphql/types/#{singularized_class_name}_type.rb")
172
- FileUtils.rm("./app/graphql/types/edges/#{singularized_class_name}_edge.rb")
173
- FileUtils.rm("./app/graphql/types/connections/#{singularized_class_name}_connection.rb")
174
- FileUtils.rm("./spec/mutations/#{singularized_class_name}_spec.rb")
175
- FileUtils.rm("./spec/queries/#{singularized_class_name}_spec.rb")
176
- FileUtils.rm("./spec/resolvers/#{singularized_class_name}_search_spec.rb")
177
- puts("deleted #{class_name.camelize} CRUD!")
178
- rescue StandardError => e
179
- raise(StandardError, e)
180
- end
181
163
  end
182
164
  end