souls 0.51.0 → 0.52.1

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -1
  3. data/exe/souls +3 -200
  4. data/lib/souls/api/generate/application.rb +97 -94
  5. data/lib/souls/api/generate/connection.rb +5 -4
  6. data/lib/souls/api/generate/edge.rb +5 -4
  7. data/lib/souls/api/generate/index.rb +0 -1
  8. data/lib/souls/api/generate/manager.rb +9 -7
  9. data/lib/souls/api/generate/model.rb +16 -18
  10. data/lib/souls/api/generate/mutation.rb +217 -218
  11. data/lib/souls/api/generate/policy.rb +5 -5
  12. data/lib/souls/api/generate/query.rb +51 -51
  13. data/lib/souls/api/generate/resolver.rb +115 -115
  14. data/lib/souls/api/generate/rspec_factory.rb +53 -53
  15. data/lib/souls/api/generate/rspec_model.rb +5 -5
  16. data/lib/souls/api/generate/rspec_mutation.rb +178 -178
  17. data/lib/souls/api/generate/rspec_policy.rb +5 -5
  18. data/lib/souls/api/generate/rspec_query.rb +111 -111
  19. data/lib/souls/api/generate/rspec_resolver.rb +163 -163
  20. data/lib/souls/api/generate/type.rb +66 -66
  21. data/lib/souls/api/index.rb +7 -4
  22. data/lib/souls/api/update/index.rb +15 -0
  23. data/lib/souls/api/update/mutation.rb +68 -64
  24. data/lib/souls/api/update/resolver.rb +59 -60
  25. data/lib/souls/api/update/rspec_factory.rb +40 -39
  26. data/lib/souls/api/update/rspec_mutation.rb +84 -83
  27. data/lib/souls/api/update/rspec_resolver.rb +70 -69
  28. data/lib/souls/api/update/type.rb +39 -38
  29. data/lib/souls/cli/console/index.rb +13 -1
  30. data/lib/souls/cli/create/index.rb +98 -94
  31. data/lib/souls/cli/db/index.rb +122 -1
  32. data/lib/souls/cli/docker/index.rb +30 -38
  33. data/lib/souls/cli/gcloud/compute/index.rb +100 -98
  34. data/lib/souls/cli/gcloud/iam/index.rb +84 -69
  35. data/lib/souls/cli/gcloud/index.rb +36 -35
  36. data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +40 -27
  37. data/lib/souls/cli/gcloud/pubsub/topics.rb +16 -10
  38. data/lib/souls/cli/gcloud/run/index.rb +23 -17
  39. data/lib/souls/cli/gcloud/sql/index.rb +66 -47
  40. data/lib/souls/cli/index.rb +3 -20
  41. data/lib/souls/cli/init/index.rb +140 -140
  42. data/lib/souls/cli/release/release.rb +106 -105
  43. data/lib/souls/cli/server/index.rb +12 -1
  44. data/lib/souls/cli/sync/conf.rb +39 -38
  45. data/lib/souls/cli/sync/model.rb +19 -20
  46. data/lib/souls/cli/sync/pubsub.rb +69 -70
  47. data/lib/souls/cli/upgrade/gemfile.rb +108 -0
  48. data/lib/souls/cli/upgrade/index.rb +1 -1
  49. data/lib/souls/cli.rb +57 -0
  50. data/lib/souls/index.rb +1 -5
  51. data/lib/souls/version.rb +1 -1
  52. data/lib/souls/versions/.souls_api_version +1 -1
  53. data/lib/souls/versions/.souls_worker_version +1 -1
  54. data/lib/souls/worker/generate/index.rb +1 -1
  55. data/lib/souls/worker/generate/job.rb +45 -0
  56. data/lib/souls/worker/generate/mailer.rb +38 -43
  57. data/lib/souls/worker/index.rb +3 -1
  58. data/lib/souls.rb +2 -0
  59. metadata +19 -5
  60. data/lib/souls/api/generate/migration.rb +0 -51
  61. data/lib/souls/cli/upgrade/gem_update.rb +0 -107
  62. data/lib/souls/worker/generate/mutation.rb +0 -44
@@ -0,0 +1,108 @@
1
+ module Souls
2
+ class Upgrade < Thor
3
+ desc "gemfile", "Update Gemfile/Gemfile.lock Version"
4
+ def gemfile
5
+ file_path = "./Gemfile"
6
+ tmp_file = "./tmp/Gemfile"
7
+ new_gems = gemfile_latest_version
8
+ logs = []
9
+ message = Paint["\nAlready Up to date!", :green]
10
+ return "Already Up to date!" && puts(message) if new_gems[:gems].blank?
11
+
12
+ @i = 0
13
+ File.open(file_path, "r") do |f|
14
+ File.open(tmp_file, "w") do |new_line|
15
+ f.each_line do |line|
16
+ gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
17
+ if new_gems[:gems].include?(gem[0])
18
+ old_ver = gem[1].split(".")
19
+ new_ver = new_gems[:updated_gem_versions][@i].split(".")
20
+ if old_ver[0] < new_ver[0]
21
+ logs << (Paint % [
22
+ "#{gem[0]} v#{gem[1]} → %{red_text}",
23
+ :white,
24
+ {
25
+ red_text: ["v#{new_gems[:updated_gem_versions][@i]}", :red]
26
+ }
27
+ ])
28
+ elsif old_ver[1] < new_ver[1]
29
+ logs << (Paint % [
30
+ "#{gem[0]} v#{gem[1]} → v#{new_ver[0]}.%{yellow_text}",
31
+ :white,
32
+ {
33
+ yellow_text: ["#{new_ver[1]}.#{new_ver[2]}", :yellow]
34
+ }
35
+ ])
36
+ elsif old_ver[2] < new_ver[2]
37
+ logs << (Paint % [
38
+ "#{gem[0]} v#{gem[1]} → v#{new_ver[0]}.#{new_ver[1]}.%{green_text}",
39
+ :white,
40
+ {
41
+ green_text: [(new_ver[2]).to_s, :green]
42
+ }
43
+ ])
44
+ end
45
+ if gem[0] == "souls"
46
+ logs << (Paint % [
47
+ "\nSOULs Doc: %{cyan_text}",
48
+ :white,
49
+ { cyan_text: ["https://souls.elsoul.nl\n", :cyan] }
50
+ ])
51
+ end
52
+ new_line.write("#{new_gems[:lines][@i]}\n")
53
+ @i += 1
54
+ else
55
+ new_line.write(line)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ FileUtils.rm("./Gemfile")
61
+ FileUtils.rm("./Gemfile.lock")
62
+ FileUtils.mv("./tmp/Gemfile", "./Gemfile")
63
+ system("bundle update")
64
+ success = Paint["\n\nSuccessfully Updated These Gems!\n", :green]
65
+ puts(success)
66
+ logs.each do |line|
67
+ puts(line)
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def gemfile_latest_version
74
+ file_path = "./Gemfile"
75
+ updated_gems = []
76
+ updated_gem_versions = []
77
+ updated_lines = []
78
+ from_dev = false
79
+ File.open(file_path, "r") do |f|
80
+ f.each_line do |line|
81
+ from_dev = true if line.include?("group")
82
+ next unless line.include?("gem ")
83
+
84
+ gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
85
+ url = URI("https://rubygems.org/api/v1/versions/#{gem[0]}/latest.json")
86
+ res = Net::HTTP.get_response(url)
87
+ data = JSON.parse(res.body)
88
+ next if Souls.configuration.fixed_gems.include?(gem[0].to_s)
89
+ next if data["version"].to_s == gem[1].to_s
90
+
91
+ updated_lines << if from_dev
92
+ " gem \"#{gem[0]}\", \"#{data['version']}\""
93
+ else
94
+ "gem \"#{gem[0]}\", \"#{data['version']}\""
95
+ end
96
+ updated_gems << (gem[0]).to_s
97
+ updated_gem_versions << data["version"]
98
+ system("gem update #{gem[0]}")
99
+ end
100
+ end
101
+ {
102
+ gems: updated_gems,
103
+ lines: updated_lines,
104
+ updated_gem_versions: updated_gem_versions
105
+ }
106
+ end
107
+ end
108
+ end
@@ -1 +1 @@
1
- require_relative "./gem_update"
1
+ require_relative "./gemfile"
data/lib/souls/cli.rb ADDED
@@ -0,0 +1,57 @@
1
+ require "souls"
2
+ module Souls
3
+ class CLI < Thor
4
+ desc "api [COMMAND]", "souls api Commands"
5
+ subcommand "api", API
6
+
7
+ desc "gcloud [COMMAND]", "souls gcloud Commands"
8
+ subcommand "gcloud", Gcloud
9
+
10
+ desc "docker [COMMAND]", "souls docker Commands"
11
+ subcommand "docker", Docker
12
+
13
+ desc "create [COMMAND]", "souls create worker $worker_name"
14
+ subcommand "create", Create
15
+
16
+ desc "sync", "souls sync Commands"
17
+ subcommand "sync", Sync
18
+
19
+ desc "upgrade", "souls upgrade Commands"
20
+ subcommand "upgrade", Upgrade
21
+
22
+ desc "worker [COMMAND]", "souls worker Commands"
23
+ subcommand "worker", Worker
24
+
25
+ # rubocop:disable Style/StringHashKeys
26
+ map "c" => :console
27
+ map "s" => :server
28
+ map "db:migrate" => :migrate
29
+ map "db:create_migration" => :create_migration
30
+ map "db:add_column" => :add_column
31
+ map "db:rename_column" => :rename_column
32
+ map "db:change_column" => :change_column
33
+ map "db:remove_column" => :remove_column
34
+ map "db:drop_table" => :drop_table
35
+ map "db:create" => :db_create
36
+ map "db:migrate:reset" => :mirgate_reset
37
+ map "db:seed" => :seed
38
+ map "t" => :test
39
+ map ["-v", "--v", "--version", "-version"] => :version
40
+ # rubocop:enable Style/StringHashKeys
41
+
42
+ desc "version", "SOULs Version"
43
+ def version
44
+ puts(Souls::VERSION)
45
+ end
46
+
47
+ desc "test", "Run Rspec & Rubocop"
48
+ def test
49
+ system("rubocop -A")
50
+ system("bundle exec rspec")
51
+ end
52
+
53
+ def self.exit_on_failure?
54
+ false
55
+ end
56
+ end
57
+ end
data/lib/souls/index.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "thor"
1
2
  require_relative "./api/index"
2
3
  require_relative "./cli/index"
3
4
  require_relative "./version"
@@ -5,9 +6,4 @@ require_relative "./worker/index"
5
6
  require_relative "./utils/index"
6
7
 
7
8
  module Souls
8
- module Api
9
- end
10
-
11
- module Worker
12
- end
13
9
  end
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.51.0".freeze
2
+ VERSION = "0.52.1".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.30.0
1
+ 0.31.1
@@ -1 +1 @@
1
- 0.30.0
1
+ 0.31.1
@@ -1,2 +1,2 @@
1
1
  require_relative "./mailer"
2
- require_relative "./mutation"
2
+ require_relative "./job"
@@ -0,0 +1,45 @@
1
+ module Souls
2
+ class Generate < Thor
3
+ desc "job [CLASS_NAME]", "Generate Job File in Worker"
4
+ method_option mailer: :boolean, aliases: "--mailer", default: false, desc: "Generate Mailer Template"
5
+ def job(class_name)
6
+ if options[:mailer]
7
+ mailer(class_name)
8
+ else
9
+ create_mutation(class_name: class_name)
10
+ end
11
+ rescue Thor::Error => e
12
+ raise(Thor::Error, e)
13
+ end
14
+
15
+ private
16
+
17
+ def create_mutation(class_name: "send-mailer")
18
+ file_dir = "./app/graphql/mutations/"
19
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
20
+ file_path = "#{file_dir}#{class_name.singularize}.rb"
21
+ raise(StandardError, "Mutation already exist! #{file_path}") if File.exist?(file_path)
22
+
23
+ File.open(file_path, "w") do |f|
24
+ f.write(<<~TEXT)
25
+ module Mutations
26
+ class #{class_name.camelize} < BaseMutation
27
+ description "Job Description"
28
+ field :response, String, null: false
29
+
30
+ def resolve
31
+ # Define Job Here
32
+
33
+ { response: "Job done!" }
34
+ rescue StandardError => e
35
+ GraphQL::ExecutionError.new(e.to_s)
36
+ end
37
+ end
38
+ end
39
+ TEXT
40
+ end
41
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
42
+ file_path
43
+ end
44
+ end
45
+ end
@@ -1,56 +1,51 @@
1
1
  module Souls
2
- module Worker
3
- module Generate
4
- class << self
5
- def mailer(class_name: "mailer", option: "")
6
- if option.to_sym == :sendgrid
7
- sendgrid_mailer(class_name: class_name)
8
- else
9
- mailgun_mailer(class_name: class_name)
10
- end
11
- end
2
+ class Generate < Thor
3
+ desc "mailer [MAILER_NAME]", "Generate Mailer Template in Worker"
4
+ def mailer(class_name)
5
+ mailgun_mailer(class_name: class_name)
6
+ rescue Thor::Error => e
7
+ raise(Thor::Error, e)
8
+ end
12
9
 
13
- private
10
+ private
14
11
 
15
- def mailgun_mailer(class_name: "mailer")
16
- file_dir = "./app/graphql/mutations/"
17
- FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
18
- file_path = "#{file_dir}#{class_name.singularize}.rb"
19
- raise(StandardError, "Mailer already exist! #{file_path}") if File.exist?(file_path)
12
+ def mailgun_mailer(class_name: "mailer")
13
+ file_dir = "./app/graphql/mutations/"
14
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
15
+ file_path = "#{file_dir}#{class_name.singularize}.rb"
16
+ raise(StandardError, "Mailer already exist! #{file_path}") if File.exist?(file_path)
20
17
 
21
- File.open(file_path, "w") do |f|
22
- f.write(<<~TEXT)
23
- module Mutations
24
- class #{class_name.camelize} < BaseMutation
25
- description "Mail を送信します。"
26
- field :response, String, null: false
18
+ File.open(file_path, "w") do |f|
19
+ f.write(<<~TEXT)
20
+ module Mutations
21
+ class #{class_name.camelize} < BaseMutation
22
+ description "Mail を送信します。"
23
+ field :response, String, null: false
27
24
 
28
- def resolve
29
- # First, instantiate the Mailgun Client with your API key
30
- mg_client = ::Mailgun::Client.new("YOUR-API-KEY")
25
+ def resolve
26
+ # First, instantiate the Mailgun Client with your API key
27
+ mg_client = ::Mailgun::Client.new("YOUR-API-KEY")
31
28
 
32
- # Define your message parameters
33
- message_params = {
34
- from: "postmaster@YOUR-DOMAIN",
35
- to: "sending@to.mail.com",
36
- subject: "SOULs Mailer test!",
37
- text: "It is really easy to send a message!"
38
- }
29
+ # Define your message parameters
30
+ message_params = {
31
+ from: "postmaster@YOUR-DOMAIN",
32
+ to: "sending@to.mail.com",
33
+ subject: "SOULs Mailer test!",
34
+ text: "It is really easy to send a message!"
35
+ }
39
36
 
40
- # Send your message through the client
41
- mg_client.send_message("YOUR-MAILGUN-DOMAIN", message_params)
42
- { response: "Job done!" }
43
- rescue StandardError => e
44
- GraphQL::ExecutionError.new(e.to_s)
45
- end
46
- end
37
+ # Send your message through the client
38
+ mg_client.send_message("YOUR-MAILGUN-DOMAIN", message_params)
39
+ { response: "Job done!" }
40
+ rescue StandardError => e
41
+ GraphQL::ExecutionError.new(e.to_s)
47
42
  end
48
- TEXT
43
+ end
49
44
  end
50
- puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
51
- file_path
52
- end
45
+ TEXT
53
46
  end
47
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
48
+ file_path
54
49
  end
55
50
  end
56
51
  end
@@ -1,6 +1,8 @@
1
1
  require_relative "./generate/index"
2
2
 
3
3
  module Souls
4
- module Worker::Generate
4
+ class Worker < Thor
5
+ desc "generate [COMMAND]", "souls worker generate Commands"
6
+ subcommand "generate", Generate
5
7
  end
6
8
  end
data/lib/souls.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require_relative "souls/index"
2
+ require_relative "souls/cli"
2
3
  require "active_support/core_ext/string/inflections"
3
4
  require "date"
4
5
  require "json"
@@ -7,6 +8,7 @@ require "net/http"
7
8
  require "paint"
8
9
  require "whirly"
9
10
  require "tty-prompt"
11
+ require "thor"
10
12
 
11
13
  module Souls
12
14
  extend Souls::Utils
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.51.0
4
+ version: 0.52.1
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-09-10 00:00:00.000000000 Z
13
+ date: 2021-09-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -96,6 +96,20 @@ dependencies:
96
96
  - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: 0.3.0
99
+ - !ruby/object:Gem::Dependency
100
+ name: thor
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 1.1.0
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 1.1.0
99
113
  description: |-
100
114
  SOULs はサーバーレスフルスタックフレームワークです。柔軟な Ruby GraphQL API と Worker はルーティングの必要がありません。
101
115
  クラウド環境への自動デプロイ、CI/CD ワークフローを標準装備。開発者がビジネスロジックに集中し、楽しくコードが書けるような環境を目指しています。
@@ -118,7 +132,6 @@ files:
118
132
  - lib/souls/api/generate/edge.rb
119
133
  - lib/souls/api/generate/index.rb
120
134
  - lib/souls/api/generate/manager.rb
121
- - lib/souls/api/generate/migration.rb
122
135
  - lib/souls/api/generate/model.rb
123
136
  - lib/souls/api/generate/mutation.rb
124
137
  - lib/souls/api/generate/policy.rb
@@ -139,6 +152,7 @@ files:
139
152
  - lib/souls/api/update/rspec_mutation.rb
140
153
  - lib/souls/api/update/rspec_resolver.rb
141
154
  - lib/souls/api/update/type.rb
155
+ - lib/souls/cli.rb
142
156
  - lib/souls/cli/console/index.rb
143
157
  - lib/souls/cli/create/index.rb
144
158
  - lib/souls/cli/db/index.rb
@@ -160,7 +174,7 @@ files:
160
174
  - lib/souls/cli/sync/index.rb
161
175
  - lib/souls/cli/sync/model.rb
162
176
  - lib/souls/cli/sync/pubsub.rb
163
- - lib/souls/cli/upgrade/gem_update.rb
177
+ - lib/souls/cli/upgrade/gemfile.rb
164
178
  - lib/souls/cli/upgrade/index.rb
165
179
  - lib/souls/index.rb
166
180
  - lib/souls/utils/index.rb
@@ -168,8 +182,8 @@ files:
168
182
  - lib/souls/versions/.souls_api_version
169
183
  - lib/souls/versions/.souls_worker_version
170
184
  - lib/souls/worker/generate/index.rb
185
+ - lib/souls/worker/generate/job.rb
171
186
  - lib/souls/worker/generate/mailer.rb
172
- - lib/souls/worker/generate/mutation.rb
173
187
  - lib/souls/worker/index.rb
174
188
  homepage: https://souls.elsoul.nl
175
189
  licenses: