souls 0.30.11 → 0.32.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f38dfac57a8b3a98a3ae32b48998897daa2b28261a6122f32f7304150b2b8823
4
- data.tar.gz: f8a82211d490d1fd8b1e66ef9d73f4a706dfdd13e39a4a813f897ac3df8612aa
3
+ metadata.gz: dec6cfe7521dc0e26b87ca6f5b2344f4d992a84baa14d1ca7b689c257192c778
4
+ data.tar.gz: 98b431c8d87a1ab432797e950b8ac4972388f7c46fdc25069b6f9d263ea3b57b
5
5
  SHA512:
6
- metadata.gz: 8e1c020a1ffba4bf351ac780d49d2bcf718bcc5e751285d90c837cf3f650ae1271e451c87e9a31f7c13ec209aeb78d7b4e2fa7b77ccf103f56a4246e4466b155
7
- data.tar.gz: 222e487819450db435505e66b282ae8aabba487ecd50de08ffeb33a071e612aa843c1d6e148f17613b9e25ffa27b08a6f49ce2a864dff1d08827343b5490c2df
6
+ metadata.gz: 136fbbffda73809fcce2eb54b60c2ea9e1249ff7137d9c6b5ea7cc18a039d3102a0139c34adc852bc249310635b0cfcaba93f64b02e580a5d4d9e46e690802bf
7
+ data.tar.gz: 65cee48c8b7eedfe779de232f09b356b88f8191c2a582c972848361af700b0f9c36e0db06b8a912d5e640fa8529dfe78290daf4a7d14e07c73969d3af7e1a6a4
data/exe/souls CHANGED
@@ -2,7 +2,7 @@
2
2
  require "souls"
3
3
  begin
4
4
  souls_command = ARGV[0]
5
- require("./config/souls") unless ["new", "i", "-v", "deploy"].include?(souls_command)
5
+ require("./config/souls") unless ["new", "docker", "-v", "deploy"].include?(souls_command)
6
6
  rescue StandardError
7
7
  puts("Make sure you are at SOULs APP directory!")
8
8
  end
@@ -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
+ args = keys.zip(key_strings).to_h
109
+ Object.const_get("Souls::Gcloud::#{module_name.camelize}").public_send(method_name.to_sym, **args)
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
@@ -32,108 +32,6 @@ module Souls
32
32
  class << self
33
33
  attr_accessor :configuration
34
34
 
35
- def gemfile_latest_version
36
- file_path = "./Gemfile"
37
- updated_gems = []
38
- updated_gem_versions = []
39
- updated_lines = []
40
- from_dev = false
41
- File.open(file_path, "r") do |f|
42
- f.each_line do |line|
43
- from_dev = true if line.include?("group")
44
- next unless line.include?("gem ")
45
-
46
- gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
47
- url = URI("https://rubygems.org/api/v1/versions/#{gem[0]}/latest.json")
48
- res = Net::HTTP.get_response(url)
49
- data = JSON.parse(res.body)
50
- next if Souls.configuration.fixed_gems.include?(gem[0].to_s)
51
- next if data["version"].to_s == gem[1].to_s
52
-
53
- updated_lines << if from_dev
54
- " gem \"#{gem[0]}\", \"#{data['version']}\""
55
- else
56
- "gem \"#{gem[0]}\", \"#{data['version']}\""
57
- end
58
- updated_gems << (gem[0]).to_s
59
- updated_gem_versions << data["version"]
60
- system("gem update #{gem[0]}")
61
- end
62
- end
63
- {
64
- gems: updated_gems,
65
- lines: updated_lines,
66
- updated_gem_versions: updated_gem_versions
67
- }
68
- end
69
-
70
- def update_gemfile
71
- file_path = "./Gemfile"
72
- tmp_file = "./tmp/Gemfile"
73
- new_gems = gemfile_latest_version
74
- logs = []
75
- message = Paint["\nAlready Up to date!", :green]
76
- return "Already Up to date!" && puts(message) if new_gems[:gems].blank?
77
-
78
- @i = 0
79
- File.open(file_path, "r") do |f|
80
- File.open(tmp_file, "w") do |new_line|
81
- f.each_line do |line|
82
- gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
83
- if new_gems[:gems].include?(gem[0])
84
- old_ver = gem[1].split(".")
85
- new_ver = new_gems[:updated_gem_versions][@i].split(".")
86
- if old_ver[0] < new_ver[0]
87
- logs << Paint % [
88
- "#{gem[0]} v#{gem[1]} → %{red_text}",
89
- :white,
90
- {
91
- red_text: ["v#{new_gems[:updated_gem_versions][@i]}", :red]
92
- }
93
- ]
94
- elsif old_ver[1] < new_ver[1]
95
- logs << Paint % [
96
- "#{gem[0]} v#{gem[1]} → v#{new_ver[0]}.%{yellow_text}",
97
- :white,
98
- {
99
- yellow_text: ["#{new_ver[1]}.#{new_ver[2]}", :yellow]
100
- }
101
- ]
102
- elsif old_ver[2] < new_ver[2]
103
- logs << Paint % [
104
- "#{gem[0]} v#{gem[1]} → v#{new_ver[0]}.#{new_ver[1]}.%{green_text}",
105
- :white,
106
- {
107
- green_text: [(new_ver[2]).to_s, :green]
108
- }
109
- ]
110
- end
111
- if gem[0] == "souls"
112
- logs << Paint % [
113
- "\nSOULs Doc: %{cyan_text}",
114
- :white,
115
- { cyan_text: ["https://souls.elsoul.nl\n", :cyan] }
116
- ]
117
- end
118
- new_line.write("#{new_gems[:lines][@i]}\n")
119
- @i += 1
120
- else
121
- new_line.write(line)
122
- end
123
- end
124
- end
125
- end
126
- FileUtils.rm("./Gemfile")
127
- FileUtils.rm("./Gemfile.lock")
128
- FileUtils.mv("./tmp/Gemfile", "./Gemfile")
129
- system("bundle update")
130
- success = Paint["\n\nSuccessfully Updated These Gems!\n", :green]
131
- puts(success)
132
- logs.each do |line|
133
- puts(line)
134
- end
135
- end
136
-
137
35
  def update_repo(service_name: "api", update_kind: "patch")
138
36
  current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
139
37
  current_ver = get_latest_version_txt(service_name: service_name)
@@ -249,86 +147,6 @@ module Souls
249
147
  puts(Paint["\nSuccessfully Updated #{service_name} Gemfile!", :green])
250
148
  end
251
149
 
252
- def update_models
253
- current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
254
- permitted_dirs = %w[worker api]
255
- unless permitted_dirs.include?(current_dir_name)
256
- raise(StandardError, "You are at wrong directory!Go to API or Worker Directory!")
257
- end
258
-
259
- cp_dir = get_models_path(service_name: current_dir_name)
260
- cp_dir.each do |path|
261
- cp_and_dl_files(api_dir: path[:api], worker_dir: path[:worker])
262
- end
263
- end
264
-
265
- def cp_and_dl_files(api_dir: "", worker_dir: "")
266
- if Dir["#{worker_dir}/*.rb"].blank?
267
-
268
- api_latest_date = 1
269
- worker_latest_date = 0
270
- else
271
- api_file_data = file_diff(Dir["#{api_dir}/*.rb"])
272
- worker_file_data = file_diff(Dir["#{worker_dir}/*.rb"])
273
-
274
- api_latest_date = Date.parse(api_file_data.max)
275
- worker_latest_date = Date.parse(worker_file_data.max)
276
- end
277
-
278
- if api_latest_date < worker_latest_date
279
- FileUtils.rm_rf(api_dir) if Dir.exist?(api_dir)
280
- FileUtils.mkdir(api_dir) unless Dir.exist?(api_dir)
281
- system("cp -r #{worker_dir}/* #{api_dir}")
282
- else
283
- FileUtils.rm_rf(worker_dir) if Dir.exist?(worker_dir)
284
- FileUtils.mkdir(worker_dir) unless Dir.exist?(worker_dir)
285
- system("cp -r #{api_dir}/* #{worker_dir}")
286
- end
287
- end
288
-
289
- def get_models_path(service_name: "api")
290
- case service_name
291
- when "api"
292
- api_path = "."
293
- worker_path = "../worker"
294
- when "worker"
295
- api_path = "../api"
296
- worker_path = "."
297
- end
298
- [
299
- {
300
- api: "#{api_path}/db",
301
- worker: "#{worker_path}/db"
302
- },
303
- {
304
- api: "#{api_path}/app/models",
305
- worker: "#{worker_path}/app/models"
306
- },
307
- {
308
- api: "#{api_path}/spec/factories",
309
- worker: "#{worker_path}/spec/factories"
310
- }
311
- ]
312
- end
313
-
314
- def file_diff(paths = [])
315
- paths.map do |path|
316
- stat(path)[:last_update]
317
- end
318
- end
319
-
320
- def stat(path)
321
- s = File::Stat.new(path)
322
- last_update = s.mtime.to_s
323
- last_status_change = s.ctime.to_s
324
- last_access = s.atime.to_s
325
- {
326
- last_update: last_update,
327
- last_status_change: last_status_change,
328
- last_access: last_access
329
- }
330
- end
331
-
332
150
  def check_schema(class_name: "user")
333
151
  schema_data = get_columns_num(class_name: class_name)
334
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
@@ -49,8 +49,6 @@ module Souls
49
49
  type = Souls::Api::Generate.type_check(col[:type])
50
50
  text =
51
51
  case type
52
- when "String"
53
- col[:array] ? "be_all(String)" : "be_a(String)"
54
52
  when "Integer", "Float"
55
53
  col[:array] ? "be_all(Integer)" : "be_a(Integer)"
56
54
  when "Boolean"
@@ -59,7 +57,7 @@ module Souls
59
57
  col[:array] ? "be_all(String)" : "be_a(String)"
60
58
  end
61
59
  unless test_args.include?(col[:column_name])
62
- new_line.write(" \"#{col[:column_name].camelize(:lower)}\" => #{text},\n")
60
+ new_line.write(" \"#{col[:column_name].camelize(:lower)}\" => #{text},\n")
63
61
  end
64
62
  end
65
63
  test_res = false
@@ -33,8 +33,6 @@ module Souls
33
33
  type = Souls::Api::Generate.type_check(col[:type])
34
34
  text =
35
35
  case type
36
- when "String"
37
- col[:array] ? "be_all(String)" : "be_a(String)"
38
36
  when "Integer", "Float"
39
37
  col[:array] ? "be_all(Integer)" : "be_a(Integer)"
40
38
  when "Boolean"
data/lib/souls/cli.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require_relative "./cli/docker"
2
2
  require_relative "./cli/gcloud"
3
3
  require_relative "./cli/release"
4
+ require_relative "./cli/sync"
5
+ require_relative "./cli/upgrade"
4
6
 
5
7
  module Souls
6
8
  end
@@ -26,6 +26,18 @@ module Souls
26
26
  )
27
27
  system("docker ps")
28
28
  end
29
+
30
+ def run
31
+ current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
32
+ port =
33
+ if current_dir_name == "api"
34
+ "4000:4000"
35
+ else
36
+ "3000:3000"
37
+ end
38
+ system("docker build . -t souls-app -f Dockerfile.dev")
39
+ system("docker run --name souls-app --rm --env-file .env -p #{port} souls-app:latest")
40
+ end
29
41
  end
30
42
  end
31
43
  end