souls 1.6.2 → 1.6.6

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: 0a354c5d180157242c8b5c5b8fb5bd7c2043a58422cae6e5b7659f1bf45c3dfa
4
- data.tar.gz: adb6666a22e608e98bd39ba83bcc1d47d077d4d222bddacc15a1f51fcf33ebd2
3
+ metadata.gz: ed868d84c673b87fa30bd5551fff5914c9262013177ef209eb7dd57bb20a1fdf
4
+ data.tar.gz: a292621677b313f73605bcc85e5ffd3e332b85bf405e07267de23487572e8083
5
5
  SHA512:
6
- metadata.gz: 2ae8068d41a970c7aa81073ed67029e9124d466dfff2bb36760e90f1808f280e4936a95898bc93764f88bee39636ede7e255e12f0abf73e13598d335fddbc211
7
- data.tar.gz: 1fea94540ec3ed5621200abd564474ffa7af29e2b1e9136e47dca41f39590542b6431af7348424f6c5b58a9109490e5f81c4b2277d3e02813db308ddc485bd1e
6
+ metadata.gz: 86fc4188dfd8b9104365dfb7fa2cd2e2805a60fea39a595dc38c4837179c1d68849db3b922cf657eb067c7c73c564ea3c6e2d4a32aa31b0e6bd336a5f2f6ce98
7
+ data.tar.gz: bcab2634608df31fef8a3686fab692936b0ab8fc6d71fba99dbba50298d1e7aa97cd4e6c5ee6c10212bcb0a6bd17544ca9a70c5e21f6f5b86fb824b3409be3fb
data/exe/souls CHANGED
@@ -5,7 +5,7 @@ begin
5
5
  souls_command = ARGV[0]
6
6
  require("./config/souls") unless ["new", "docker", "-v", "help", "", nil].include?(souls_command)
7
7
  rescue StandardError
8
- raise(StandardError, "No confif! Please make `./config/souls.rb` File!")
8
+ raise(StandardError, "No config! Please make `./config/souls.rb` File!")
9
9
  end
10
10
 
11
11
  Souls::CLI.start
@@ -4,37 +4,35 @@ module Souls
4
4
  method_option :mailer, type: :boolean, aliases: "--mailer", default: false, desc: "Mailer Option"
5
5
  def job(class_name)
6
6
  if options[:mailer]
7
+ create_job_mailer_type(class_name)
7
8
  mailgun_mailer(class_name)
8
9
  else
9
- create_job_mutation(class_name)
10
+ create_job_type(class_name)
11
+ create_job(class_name)
10
12
  end
13
+ update_query_type(class_name)
11
14
  Souls::Generate.new.invoke(:job_rbs, [class_name], {})
12
- Souls::Generate.new.invoke(:rspec_job, [class_name], {})
15
+ Souls::Generate.new.invoke(:rspec_job, [class_name], { mailer: options[:mailer] })
13
16
  rescue Thor::Error => e
14
17
  raise(Thor::Error, e)
15
18
  end
16
19
 
17
20
  private
18
21
 
19
- def create_job_mutation(class_name)
20
- file_dir = "./app/graphql/mutations/"
22
+ def create_job(class_name)
23
+ file_dir = "./app/graphql/queries/"
21
24
  FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
22
25
  file_path = "#{file_dir}#{class_name.singularize}.rb"
23
- raise(StandardError, "Mutation already exist! #{file_path}") if File.exist?(file_path)
26
+ raise(StandardError, "Query already exist! #{file_path}") if File.exist?(file_path)
24
27
 
25
28
  File.open(file_path, "w") do |f|
26
29
  f.write(<<~TEXT)
27
- module Mutations
28
- class #{class_name.camelize} < BaseMutation
29
- description "Job Description"
30
- field :response, String, null: false
31
-
30
+ module Queries
31
+ class #{class_name.camelize} < BaseQuery
32
+ description ""
33
+ type Types::#{class_name.camelize}Type, null: false
34
+
32
35
  def resolve
33
- # Define Job Here
34
-
35
- { response: "Job done!" }
36
- rescue StandardError => e
37
- GraphQL::ExecutionError.new(e.to_s)
38
36
  end
39
37
  end
40
38
  end
@@ -43,32 +41,50 @@ module Souls
43
41
  puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
44
42
  file_path
45
43
  end
44
+
45
+ def create_job_type(class_name)
46
+ file_dir = "./app/graphql/types/"
47
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
48
+ file_path = "#{file_dir}#{class_name.singularize}_type.rb"
49
+ raise(StandardError, "Type already exists! #{file_path}") if File.exist?(file_path)
50
+
51
+ File.open(file_path, "w") do |f|
52
+ f.write(<<~TEXT)
53
+ module Types
54
+ class #{class_name.camelize}Type < BaseObject
55
+ end
56
+ end
57
+ TEXT
58
+ end
59
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
60
+ file_path
61
+ end
46
62
 
47
63
  def mailgun_mailer(class_name)
48
- file_dir = "./app/graphql/mutations/"
64
+ file_dir = "./app/graphql/queries/"
49
65
  FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
50
66
  file_path = "#{file_dir}#{class_name.singularize}.rb"
51
- raise(StandardError, "Mailer already exist! #{file_path}") if File.exist?(file_path)
67
+ raise(StandardError, "Mailer already exists! #{file_path}") if File.exist?(file_path)
52
68
 
53
69
  File.open(file_path, "w") do |f|
54
70
  f.write(<<~TEXT)
55
- module Mutations
56
- class #{class_name.camelize} < BaseMutation
57
- description "Mail を送信します。"
58
- field :response, String, null: false
59
-
71
+ module Queries
72
+ class #{class_name.camelize} < BaseQuery
73
+ description ""
74
+ type Types::#{class_name.camelize}Type, null: false
75
+
60
76
  def resolve
61
77
  # First, instantiate the Mailgun Client with your API key
62
78
  mg_client = ::Mailgun::Client.new("YOUR-API-KEY")
63
-
79
+
64
80
  # Define your message parameters
65
81
  message_params = {
66
- from: "postmaster@YOUR-DOMAIN",
82
+ from: "postmaster@from.mail.com",
67
83
  to: "sending@to.mail.com",
68
84
  subject: "SOULs Mailer test!",
69
85
  text: "It is really easy to send a message!"
70
86
  }
71
-
87
+
72
88
  # Send your message through the client
73
89
  mg_client.send_message("YOUR-MAILGUN-DOMAIN", message_params)
74
90
  { response: "Job done!" }
@@ -82,5 +98,44 @@ module Souls
82
98
  puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
83
99
  file_path
84
100
  end
101
+
102
+ def create_job_mailer_type(class_name)
103
+ file_dir = "./app/graphql/types/"
104
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
105
+ file_path = "#{file_dir}#{class_name.singularize}_type.rb"
106
+ raise(StandardError, "Type already exists! #{file_path}") if File.exist?(file_path)
107
+
108
+ File.open(file_path, "w") do |f|
109
+ f.write(<<~TEXT)
110
+ module Types
111
+ class #{class_name.camelize}Type < BaseObject
112
+ field :response, String, null: true
113
+ end
114
+ end
115
+ TEXT
116
+ end
117
+ puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
118
+ file_path
119
+ end
120
+
121
+ def update_query_type(class_name)
122
+ file_dir = "./app/graphql/types/base/"
123
+ FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
124
+ file_path = "#{file_dir}query_type.rb"
125
+ raise(StandardError, "Query type doesn't exist, please re-create it") unless File.exist?(file_path)
126
+
127
+ lines = File.readlines(file_path)
128
+ unless lines[-1].strip == "end" and lines[-2].strip == "end"
129
+ puts(Paint % ["Base query file has changed significantly and cannot be modified automatically, please update routes manually"], :yellow)
130
+ return
131
+ end
132
+
133
+ insert_string = " field :#{class_name.singularize}, resolver: Queries::#{class_name.camelize}\n"
134
+ lines.insert(-3, insert_string)
135
+ File.open(file_path, "w") { |f| f.write(lines.join) }
136
+
137
+ puts(Paint % ["Updated file : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
138
+ file_path
139
+ end
85
140
  end
86
141
  end
@@ -6,7 +6,7 @@ module Souls
6
6
  worker_name = FileUtils.pwd.split("/").last
7
7
  Dir.chdir(Souls.get_mother_path.to_s) do
8
8
  singularized_class_name = class_name.underscore.singularize
9
- file_dir = "./sig/#{worker_name}/app/graphql/mutations/"
9
+ file_dir = "./sig/#{worker_name}/app/graphql/queries/"
10
10
  FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
11
11
  file_path = "#{file_dir}#{singularized_class_name}.rbs"
12
12
  File.open(file_path, "w") do |f|
@@ -1,6 +1,7 @@
1
1
  module Souls
2
2
  class Generate < Thor
3
3
  desc "rspec_job [CLASS_NAME]", "Generate Rspec Job Test Template"
4
+ method_option :mailer, type: :boolean, aliases: "--mailer", default: false, desc: "Mailgun Template"
4
5
  def rspec_job(class_name)
5
6
  singularized_class_name = class_name.underscore.singularize
6
7
  file_dir = "./spec/mutations/jobs/"
@@ -8,36 +9,72 @@ module Souls
8
9
  file_path = "#{file_dir}/#{singularized_class_name}_spec.rb"
9
10
  return "RspecJob already exist! #{file_path}" if File.exist?(file_path)
10
11
 
11
- File.open(file_path, "w") do |f|
12
- f.write(<<~TEXT)
13
- RSpec.describe("#{singularized_class_name.camelize}") do
14
- describe "Define #{singularized_class_name.camelize}" do
12
+ if options[:mailer]
13
+ File.open(file_path, "w") do |f|
14
+ f.write(<<~TEXT)
15
+ RSpec.describe("#{singularized_class_name.camelize}") do
16
+ describe "Define #{singularized_class_name.camelize}" do
15
17
 
16
- let(:mutation) do
17
- %(mutation {
18
- #{singularized_class_name.camelize(:lower)}(input: {}) {
19
- response
18
+ let(:mutation) do
19
+ %(mutation {
20
+ #{singularized_class_name.camelize(:lower)}(input: {}) {
21
+ response
22
+ }
20
23
  }
21
- }
22
- )
23
- end
24
+ )
25
+ end
26
+
27
+ subject(:result) do
28
+ SoulsApiSchema.execute(mutation).as_json
29
+ end
24
30
 
25
- subject(:result) do
26
- SoulsApiSchema.execute(mutation).as_json
31
+ it "return #{singularized_class_name.camelize} response" do
32
+ stub_request(:post, "https://api.mailgun.net/v3/YOUR-MAILGUN-DOMAIN/messages")
33
+ .to_return(status: 200, body: "", headers: {})
34
+ begin
35
+ a1 = result.dig("data", "#{singularized_class_name.camelize(:lower)}")
36
+ raise unless a1.present?
37
+ rescue StandardError
38
+ raise(StandardError, result)
39
+ end
40
+ expect(a1).to(include("response" => be_a(String)))
41
+ end
27
42
  end
43
+ end
44
+ TEXT
45
+ end
46
+ else
47
+ File.open(file_path, "w") do |f|
48
+ f.write(<<~TEXT)
49
+ RSpec.describe("#{singularized_class_name.camelize}") do
50
+ describe "Define #{singularized_class_name.camelize}" do
51
+
52
+ let(:mutation) do
53
+ %(mutation {
54
+ #{singularized_class_name.camelize(:lower)}(input: {}) {
55
+ response
56
+ }
57
+ }
58
+ )
59
+ end
60
+
61
+ subject(:result) do
62
+ SoulsApiSchema.execute(mutation).as_json
63
+ end
28
64
 
29
- it "return StockSheet Data" do
30
- begin
31
- a1 = result.dig("data", "#{singularized_class_name.camelize(:lower)}")
32
- raise unless a1.present?
33
- rescue StandardError
34
- raise(StandardError, result)
65
+ it "return #{singularized_class_name.camelize} response" do
66
+ begin
67
+ a1 = result.dig("data", "#{singularized_class_name.camelize(:lower)}")
68
+ raise unless a1.present?
69
+ rescue StandardError
70
+ raise(StandardError, result)
71
+ end
72
+ expect(a1).to(include("response" => be_a(String)))
35
73
  end
36
- expect(a1).to(include("response" => be_a(String)))
37
74
  end
38
75
  end
39
- end
40
- TEXT
76
+ TEXT
77
+ end
41
78
  end
42
79
  puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
43
80
  file_path
@@ -27,7 +27,7 @@ module Souls
27
27
  SoulsApiSchema.execute(mutation).as_json
28
28
  end
29
29
 
30
- it "return StockSheet Data" do
30
+ it "return User response" do
31
31
  begin
32
32
  a1 = result.dig("data", "#{options[:mutation].singularize.camelize(:lower)}", "response")
33
33
  raise unless a1.present?
@@ -22,6 +22,14 @@ module Souls
22
22
  Souls::Github.new.invoke(:secret_set)
23
23
  end
24
24
 
25
+ desc "watch", "Watch GitHub Actions Workflow"
26
+ def watch
27
+ run_id = `gh run list | grep Mailer | awk '{print $7}'`.strip
28
+ raise(StandardError, "No workflow is running.") if run_id.include?("push")
29
+
30
+ system("gh run watch #{run_id}")
31
+ end
32
+
25
33
  private
26
34
 
27
35
  def update_env_production(key:, value:, dqm: false)
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "1.6.2".freeze
2
+ VERSION = "1.6.6".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.6.2
1
+ 1.6.6
@@ -1 +1 @@
1
- 1.6.2
1
+ 1.6.6
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: 1.6.2
4
+ version: 1.6.6
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-11-09 00:00:00.000000000 Z
13
+ date: 2021-11-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -232,8 +232,8 @@ licenses:
232
232
  metadata:
233
233
  homepage_uri: https://souls.elsoul.nl
234
234
  source_code_uri: https://github.com/elsoul/souls
235
- changelog_uri: https://github.com/elsoul/souls/releases/tag/1.6.2
236
- post_install_message:
235
+ changelog_uri: https://github.com/elsoul/souls/releases/tag/v1.6.6
236
+ post_install_message:
237
237
  rdoc_options: []
238
238
  require_paths:
239
239
  - lib
@@ -249,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
249
  version: '0'
250
250
  requirements: []
251
251
  rubygems_version: 3.2.22
252
- signing_key:
252
+ signing_key:
253
253
  specification_version: 4
254
254
  summary: Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, RBS/Steep,
255
255
  Active Record, RSpec, RuboCop, and Google Cloud.