souls 1.7.27 → 1.7.31

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: 3a290f2d3352519c56e7fc9bd6700e0d2e4491f72baffd2b68c8577a7fb66a79
4
- data.tar.gz: 37cfe63c0027a77d9e0e3d034ea613878400cf2693d76c35a3d92410d78e5680
3
+ metadata.gz: dacaa8204429d10d4c47a1f13dcff780c1e9984314b297d7e99142e34025b4a4
4
+ data.tar.gz: 2f75725f2aa4c2364b2a5590408b964079644add22f104a58d7dc805fb21f5f7
5
5
  SHA512:
6
- metadata.gz: bc96eb79e065a30d1dea1ffd3453ed945e5e685290e02f37afdab0d96b196359c728129d133c311fdbd53736013d46ff38225546fb0d16acb261dd8b4025ff23
7
- data.tar.gz: aa9a78d415b6b0ff15d68033461b56ad38db2e020f41ab7b2936582505f7e9864dc0336d67b4b05198f6adcdaa94f729889d7247ba746f789b1206db3a5ebcdf
6
+ metadata.gz: 60ceef310ddad467a8c0c54461ece1958e6c27cf707804eee71afd6fa0100554c5ef1e8ca58df63dfb0118aacb8e18ed1d03010d30b57261a35c2fc729987ffe
7
+ data.tar.gz: 9da15cc3507dbbbdbc2019dd118d2b674750c08c0ec61737dddc28fe450615b1027149eb56e423cae8796e617d80dcecdf63020197610b513ab1db8477742eb0
data/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  <img alt="" src="https://badgen.net/rubygems/dt/souls">
17
17
  </a>
18
18
  <a aria-label="Test" href="https://rubygems.org/gems/souls">
19
- <img alt="" src="https://github.com/elsoul/souls/actions/workflows/gem-test.yml/badge.svg">
19
+ <img alt="" src="https://github.com/elsoul/souls/actions/workflows/test.yml/badge.svg">
20
20
  </a>
21
21
  <a aria-label="License" href="https://github.com/elsoul/souls/blob/master/LICENSE.txt">
22
22
  <img alt="" src="https://badgen.net/badge/license/Apache/blue">
@@ -0,0 +1,28 @@
1
+ module Souls
2
+ class DB < Thor
3
+ desc "create_migration [CLASS_NAME]", "Create ActiveRecord Migration File"
4
+ def create_migration(class_name)
5
+ pluralized_class_name = class_name.underscore.pluralize
6
+ singularized_class_name = class_name.underscore.singularize
7
+ Souls::DB.new.invoke(:model, [singularized_class_name], {})
8
+ Souls::DB.new.invoke(:rspec_model, [singularized_class_name], {})
9
+ Souls::DB.new.invoke(:model_rbs, [singularized_class_name], {})
10
+ puts(Paint["Created file! : ", :green])
11
+ system("rake db:create_migration NAME=create_#{pluralized_class_name}")
12
+ file_path = Dir["db/migrate/*create_#{pluralized_class_name}.rb"].first
13
+ File.open(file_path, "w") do |f|
14
+ f.write(<<~TEXT)
15
+ class Create#{pluralized_class_name.camelize} < ActiveRecord::Migration[6.1]
16
+ def change
17
+ create_table :#{pluralized_class_name} do |t|
18
+
19
+ t.boolean :is_deleted, null: false, default: false
20
+ t.timestamps
21
+ end
22
+ end
23
+ end
24
+ TEXT
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,4 @@
1
+ require_relative "./create_migration"
1
2
  require_relative "./create_migration_rbs"
2
3
  require_relative "./model"
3
4
  require_relative "./rspec_model"
@@ -17,8 +18,6 @@ module Souls
17
18
  db_system("rake db:migrate RACK_ENV=test")
18
19
  end
19
20
  true
20
- rescue Thor::Error => e
21
- raise(Thor::Error, e)
22
21
  end
23
22
 
24
23
  desc "create", "Create Database"
@@ -30,8 +29,6 @@ module Souls
30
29
  else
31
30
  db_system("rake db:create")
32
31
  end
33
- rescue Thor::Error => e
34
- raise(Thor::Error, e)
35
32
  end
36
33
 
37
34
  desc "seed", "Insert Seed Data"
@@ -44,8 +41,6 @@ module Souls
44
41
  db_system("rake db:seed")
45
42
  db_system("rake db:seed RACK_ENV=test")
46
43
  end
47
- rescue Thor::Error => e
48
- raise(Thor::Error, e)
49
44
  end
50
45
 
51
46
  desc "migrate_reset", "Reset Database"
@@ -57,75 +52,36 @@ module Souls
57
52
  else
58
53
  db_system("rake db:migrate:reset")
59
54
  end
60
- rescue Thor::Error => e
61
- raise(Thor::Error, e)
62
- end
63
-
64
- desc "create_migration [CLASS_NAME]", "Create ActiveRecord Migration File"
65
- def create_migration(class_name)
66
- pluralized_class_name = class_name.underscore.pluralize
67
- singularized_class_name = class_name.underscore.singularize
68
- Souls::DB.new.invoke(:model, [singularized_class_name], {})
69
- Souls::DB.new.invoke(:rspec_model, [singularized_class_name], {})
70
- Souls::DB.new.invoke(:model_rbs, [singularized_class_name], {})
71
- puts(Paint["Created file! : ", :green])
72
- system("rake db:create_migration NAME=create_#{pluralized_class_name}")
73
- file_path = Dir["db/migrate/*create_#{pluralized_class_name}.rb"].first
74
- File.open(file_path, "w") do |f|
75
- f.write(<<~TEXT)
76
- class Create#{pluralized_class_name.camelize} < ActiveRecord::Migration[6.1]
77
- def change
78
- create_table :#{pluralized_class_name} do |t|
79
-
80
- t.boolean :is_deleted, null: false, default: false
81
- t.timestamps
82
- end
83
- end
84
- end
85
- TEXT
86
- end
87
- rescue Thor::Error => e
88
- raise(Thor::Error, e)
89
55
  end
90
56
 
91
57
  desc "add_column [CLASS_NAME]", "Create ActiveRecord Migration File"
92
58
  def add_column(class_name)
93
59
  pluralized_class_name = class_name.underscore.pluralize
94
60
  system("rake db:create_migration NAME=add_column_to_#{pluralized_class_name}")
95
- rescue Thor::Error => e
96
- raise(Thor::Error, e)
97
61
  end
98
62
 
99
63
  desc "rename_column [CLASS_NAME]", "Create ActiveRecord Migration File"
100
64
  def rename_column(class_name)
101
65
  pluralized_class_name = class_name.underscore.pluralize
102
66
  system("rake db:create_migration NAME=rename_column_to_#{pluralized_class_name}")
103
- rescue Thor::Error => e
104
- raise(Thor::Error, e)
105
67
  end
106
68
 
107
69
  desc "change_column [CLASS_NAME]", "Create ActiveRecord Migration File"
108
70
  def change_column(class_name)
109
71
  pluralized_class_name = class_name.underscore.pluralize
110
72
  system("rake db:create_migration NAME=change_column_to_#{pluralized_class_name}")
111
- rescue Thor::Error => e
112
- raise(Thor::Error, e)
113
73
  end
114
74
 
115
75
  desc "remove_column [CLASS_NAME]", "Create ActiveRecord Migration File"
116
76
  def remove_column(class_name)
117
77
  pluralized_class_name = class_name.underscore.pluralize
118
78
  system("rake db:create_migration NAME=remove_column_to_#{pluralized_class_name}")
119
- rescue Thor::Error => e
120
- raise(Thor::Error, e)
121
79
  end
122
80
 
123
81
  desc "drop_table [CLASS_NAME]", "Create ActiveRecord Migration File"
124
82
  def drop_table(class_name)
125
83
  pluralized_class_name = class_name.underscore.pluralize
126
84
  system("rake db:create_migration NAME=drop_table_to_#{pluralized_class_name}")
127
- rescue Thor::Error => e
128
- raise(Thor::Error, e)
129
85
  end
130
86
 
131
87
  private
@@ -24,6 +24,7 @@ module Souls
24
24
  file_path = ".env"
25
25
  File.open(file_path, "w") do |line|
26
26
  line.write(<<~TEXT)
27
+ GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS=1
27
28
  SOULS_DB_HOST=#{instance_ip}
28
29
  SOULS_DB_PW=#{password}
29
30
  SOULS_DB_USER=postgres
@@ -9,7 +9,9 @@ module Souls
9
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
- type_file_path = "./sig/#{worker_name}/app/graphql/types/#{singularized_class_name}_type.rbs"
12
+ sig_type_path = "./sig/#{worker_name}/app/graphql/types"
13
+ FileUtils.mkdir_p(sig_type_path) unless Dir.exist?(sig_type_path)
14
+ type_file_path = "#{sig_type_path}/#{singularized_class_name}_type.rbs"
13
15
  File.open(file_path, "w") do |f|
14
16
  f.write(<<~TEXT)
15
17
  module Queries
@@ -2,23 +2,27 @@ module Souls
2
2
  class Github < Thor
3
3
  desc "secret_set", "Github Secret Set from .env.production"
4
4
  def secret_set
5
- file_path = ".env.production"
6
- File.open(file_path, "r") do |file|
7
- file.each_line do |line|
8
- key_and_value = line.split("=")
9
- system("gh secret set #{key_and_value[0]} -b \"#{key_and_value[1].strip}\"")
5
+ Dir.chdir(Souls.get_mother_path.to_s) do
6
+ file_path = ".env.production"
7
+ File.open(file_path, "r") do |file|
8
+ file.each_line do |line|
9
+ key_and_value = line.split("=")
10
+ system("gh secret set #{key_and_value[0]} -b \"#{key_and_value[1].strip}\"")
11
+ end
10
12
  end
11
13
  end
12
14
  end
13
15
 
14
16
  desc "add_env", "Add New env and Sync Github Secret"
15
- method_option :key, aliases: "--key", required: true, desc: "Key Name"
16
- method_option :value, aliases: "--value", required: true, desc: "Value Name"
17
17
  method_option :dqm, type: :boolean, aliases: "--dqm", default: false, desc: "Enable Double Quotation Mark"
18
18
  def add_env
19
- update_env_production(key: options[:key], value: options[:value], dqm: options[:dqm])
20
- update_api_env(key: options[:key], value: options[:value], dqm: options[:dqm])
21
- update_github_actions(key: options[:key])
19
+ prompt = TTY::Prompt.new
20
+ key = prompt.ask("Set Key:")
21
+ value = prompt.ask("Set Value:")
22
+ update_env_production(key: key, value: value, dqm: options[:dqm])
23
+ update_api_env(key: key, value: value, dqm: options[:dqm])
24
+ update_workers_env(key: key, value: value, dqm: options[:dqm])
25
+ update_github_actions(key: key)
22
26
  Souls::Github.new.invoke(:secret_set)
23
27
  end
24
28
 
@@ -52,13 +56,29 @@ module Souls
52
56
  end
53
57
  end
54
58
 
59
+ def update_workers_env(key:, value:, dqm: false)
60
+ Dir.chdir(Souls.get_mother_path.to_s) do
61
+ workers = Dir["apps/*"]
62
+ workers.delete("apps/api")
63
+ workers.each do |worker_path|
64
+ file_path = "#{worker_path}/.env"
65
+ File.open(file_path, "a") do |line|
66
+ dqm ? line.write("\n#{key.upcase}=\"#{value}\"") : line.write("\n#{key.upcase}=#{value}")
67
+ end
68
+ puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
69
+ end
70
+ end
71
+ end
72
+
55
73
  def update_github_actions(key:)
56
74
  Dir.chdir(Souls.get_mother_path.to_s) do
57
75
  file_paths = Dir[".github/workflows/*.yml"]
76
+ file_paths.delete(".github/workflows/api.yml")
58
77
  file_paths.each do |file_path|
59
- File.open(file_path, "a") do |line|
60
- line.write(" \\ \n --set-env-vars=\"#{key.upcase}=${{ secrets.#{key.upcase} }}\"")
61
- end
78
+ worker_workflow = File.readlines(file_path)
79
+ worker_workflow[worker_workflow.size - 1] = worker_workflow.last.chomp
80
+ worker_workflow << " \\ \n --set-env-vars=\"#{key.upcase}=${{ secrets.#{key.upcase} }}\""
81
+ File.open(file_path, "w") { |f| f.write(worker_workflow.join) }
62
82
  puts(Paint % ["Updated file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
63
83
  end
64
84
  end
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "1.7.27".freeze
2
+ VERSION = "1.7.31".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.7.27
1
+ 1.7.31
@@ -1 +1 @@
1
- 1.7.27
1
+ 1.7.31
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: 1.7.27
4
+ version: 1.7.31
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-11-16 00:00:00.000000000 Z
13
+ date: 2021-11-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -130,6 +130,7 @@ files:
130
130
  - lib/souls/cli/cli_exception.rb
131
131
  - lib/souls/cli/console/index.rb
132
132
  - lib/souls/cli/create/index.rb
133
+ - lib/souls/cli/db/create_migration.rb
133
134
  - lib/souls/cli/db/create_migration_rbs.rb
134
135
  - lib/souls/cli/db/index.rb
135
136
  - lib/souls/cli/db/model.rb