souls 0.47.1 → 0.49.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 +4 -4
- data/exe/souls +32 -30
- data/lib/souls/api/generate/application.rb +1 -64
- data/lib/souls/api/generate/index.rb +10 -0
- data/lib/souls/api/generate/mutation.rb +4 -4
- data/lib/souls/api/generate/resolver.rb +5 -5
- data/lib/souls/api/generate/rspec_factory.rb +2 -2
- data/lib/souls/api/generate/rspec_mutation.rb +5 -5
- data/lib/souls/api/generate/rspec_query.rb +4 -4
- data/lib/souls/api/generate/rspec_resolver.rb +4 -4
- data/lib/souls/api/generate/type.rb +2 -2
- data/lib/souls/api/update/mutation.rb +2 -2
- data/lib/souls/api/update/resolver.rb +2 -2
- data/lib/souls/api/update/rspec_factory.rb +1 -1
- data/lib/souls/api/update/rspec_mutation.rb +2 -2
- data/lib/souls/api/update/rspec_resolver.rb +1 -1
- data/lib/souls/api/update/type.rb +1 -1
- data/lib/souls/cli/console/index.rb +4 -0
- data/lib/souls/cli/create/index.rb +2 -10
- data/lib/souls/cli/db/index.rb +4 -0
- data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +4 -0
- data/lib/souls/cli/gcloud/pubsub/topics.rb +4 -0
- data/lib/souls/cli/gcloud/sql/index.rb +12 -4
- data/lib/souls/cli/index.rb +4 -0
- data/lib/souls/cli/init/index.rb +155 -0
- data/lib/souls/cli/release/release.rb +91 -3
- data/lib/souls/cli/server/index.rb +4 -0
- data/lib/souls/cli/sync/conf.rb +18 -8
- data/lib/souls/index.rb +0 -1
- data/lib/souls/utils/index.rb +177 -0
- data/lib/souls/version.rb +1 -1
- data/lib/souls/versions/.souls_api_version +1 -1
- data/lib/souls/versions/.souls_worker_version +1 -1
- data/lib/souls.rb +2 -212
- metadata +9 -6
- data/lib/souls/init.rb +0 -153
@@ -22,7 +22,7 @@ module Souls
|
|
22
22
|
|
23
23
|
if line.include?('#{') && !argument
|
24
24
|
new_cols.each do |col|
|
25
|
-
type = Souls
|
25
|
+
type = Souls.type_check(col[:type])
|
26
26
|
next if col[:column_name] == "created_at" || col[:column_name] == "updated_at"
|
27
27
|
|
28
28
|
type_line =
|
@@ -46,7 +46,7 @@ module Souls
|
|
46
46
|
elsif test_res && line.include?("=> be_")
|
47
47
|
test_args = check_rspec_mutation_argument(class_name: class_name, action: "test_args")
|
48
48
|
new_cols.each do |col|
|
49
|
-
type = Souls
|
49
|
+
type = Souls.type_check(col[:type])
|
50
50
|
text =
|
51
51
|
case type
|
52
52
|
when "Integer", "Float"
|
@@ -30,7 +30,7 @@ module Souls
|
|
30
30
|
elsif test_res && line.include?("=> be_")
|
31
31
|
test_args = check_rspec_resolver_argument(class_name: class_name, action: "test_args")
|
32
32
|
new_cols.each do |col|
|
33
|
-
type = Souls
|
33
|
+
type = Souls.type_check(col[:type])
|
34
34
|
text =
|
35
35
|
case type
|
36
36
|
when "Integer", "Float"
|
@@ -16,7 +16,7 @@ module Souls
|
|
16
16
|
next unless line.include?("field") && !argument
|
17
17
|
|
18
18
|
new_cols.each do |col|
|
19
|
-
type = Souls
|
19
|
+
type = Souls.get_type(col[:type])
|
20
20
|
type = "[#{type}]" if col[:array]
|
21
21
|
args = check_type_argument(class_name: class_name)
|
22
22
|
unless args.include?(col[:column_name])
|
@@ -204,20 +204,12 @@ end
|
|
204
204
|
end
|
205
205
|
|
206
206
|
def download_worker(worker_name: "mailer")
|
207
|
-
raise(StandardError, "Can't use `worker` for worker. Change Name.") if worker_name == "worker"
|
208
|
-
|
209
|
-
current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
|
210
|
-
wrong_dir = %w[apps api worker]
|
211
|
-
if wrong_dir.include?(current_dir_name)
|
212
|
-
raise(StandardError, "You are at wrong directory!Go to Mother Directory!")
|
213
|
-
end
|
214
|
-
|
215
207
|
version = Souls.get_latest_version_txt(service_name: "worker").join(".")
|
216
208
|
file_name = "worker-v#{version}.tgz"
|
217
209
|
url = "https://storage.googleapis.com/souls-bucket/boilerplates/workers/#{file_name}"
|
218
210
|
system("curl -OL #{url}")
|
219
|
-
system("tar -zxvf ./#{file_name}
|
220
|
-
system("mv
|
211
|
+
system("tar -zxvf ./#{file_name}")
|
212
|
+
system("mv ./worker apps/#{worker_name}")
|
221
213
|
system("cp ./apps/api/config/database.yml ./apps/#{worker_name}/config/")
|
222
214
|
FileUtils.rm(file_name)
|
223
215
|
end
|
@@ -11,12 +11,20 @@ module Souls
|
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def list
|
15
|
+
system("gcloud sql instances list")
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup_private_ip
|
18
19
|
create_ip_range
|
19
20
|
create_vpc_connector
|
21
|
+
assign_network
|
22
|
+
end
|
23
|
+
|
24
|
+
def assign_network
|
25
|
+
app_name = Souls.configuration.app
|
26
|
+
instance_name = "#{Souls.configuration.app}-db"
|
27
|
+
project_id = Souls.configuration.project_id
|
20
28
|
system("gcloud beta sql instances patch #{instance_name} --project=#{project_id} --network=#{app_name}")
|
21
29
|
end
|
22
30
|
|
data/lib/souls/cli/index.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative "./create/index"
|
2
2
|
require_relative "./docker/index"
|
3
3
|
require_relative "./gcloud/index"
|
4
|
+
require_relative "./init/index"
|
4
5
|
require_relative "./release/index"
|
5
6
|
require_relative "./sync/index"
|
6
7
|
require_relative "./upgrade/index"
|
@@ -15,6 +16,9 @@ module Souls
|
|
15
16
|
module Gcloud
|
16
17
|
end
|
17
18
|
|
19
|
+
module Init
|
20
|
+
end
|
21
|
+
|
18
22
|
module Release
|
19
23
|
end
|
20
24
|
|
@@ -0,0 +1,155 @@
|
|
1
|
+
module Souls
|
2
|
+
module Init
|
3
|
+
class << self
|
4
|
+
def get_version(repository_name: "souls_api")
|
5
|
+
data = JSON.parse(
|
6
|
+
`curl \
|
7
|
+
-H "Accept: application/vnd.github.v3+json" \
|
8
|
+
-s https://api.github.com/repos/elsoul/#{repository_name}/releases`
|
9
|
+
)
|
10
|
+
data[0]["tag_name"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_cd
|
14
|
+
shell = `echo $SHELL`.strip
|
15
|
+
rc =
|
16
|
+
if shell.include?("zsh")
|
17
|
+
"zshrc"
|
18
|
+
else
|
19
|
+
"bash"
|
20
|
+
end
|
21
|
+
system("echo '\nalias api=\'cd apps/api\'' >> ~/.#{rc}")
|
22
|
+
system("echo 'alias mother=\'...\'' >> ~/.#{rc}")
|
23
|
+
system("echo 'alias worker=\'cd apps/worker\'' >> ~/.#{rc}")
|
24
|
+
puts(Paint["run `source ~/.#{rc}` to reflect your .#{rc}", :yellow])
|
25
|
+
puts(Paint["You can move to mother/api/worker just type", :green])
|
26
|
+
puts(Paint["\nmother\n", :white])
|
27
|
+
puts(
|
28
|
+
Paint["to go back to mother dir from api/worker\n\nYou can also go to api/worker from mother dir by typing",
|
29
|
+
:green]
|
30
|
+
)
|
31
|
+
puts(Paint["\napi\n", :white])
|
32
|
+
puts(Paint["or\n", :green])
|
33
|
+
puts(Paint["worker", :white])
|
34
|
+
end
|
35
|
+
|
36
|
+
def initial_config_init(app_name: "souls", service_name: "api")
|
37
|
+
config_dir = "./#{app_name}/apps/#{service_name}/config"
|
38
|
+
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
|
39
|
+
FileUtils.touch("#{config_dir}/souls.rb")
|
40
|
+
file_path = "#{config_dir}/souls.rb"
|
41
|
+
File.open(file_path, "w") do |f|
|
42
|
+
f.write(<<~TEXT)
|
43
|
+
Souls.configure do |config|
|
44
|
+
config.app = "#{app_name}"
|
45
|
+
config.project_id = "#{app_name}-project"
|
46
|
+
config.endpoint = "/endpoint"
|
47
|
+
config.strain = "api"
|
48
|
+
config.fixed_gems = ["excluded_gem"]
|
49
|
+
config.workers = []
|
50
|
+
end
|
51
|
+
TEXT
|
52
|
+
end
|
53
|
+
rescue StandardError => e
|
54
|
+
puts(e)
|
55
|
+
end
|
56
|
+
|
57
|
+
def download_github_actions(app_name: "souls-app")
|
58
|
+
file_name = "github.tgz"
|
59
|
+
url = "https://storage.googleapis.com/souls-bucket/github_actions/github.tgz"
|
60
|
+
system("curl -OL #{url}")
|
61
|
+
FileUtils.mkdir_p("#{app_name}/github")
|
62
|
+
system("tar -zxvf ./#{file_name} -C #{app_name}/")
|
63
|
+
FileUtils.rm(file_name)
|
64
|
+
end
|
65
|
+
|
66
|
+
def mother_config_init(app_name: "souls-app")
|
67
|
+
config_dir = "./#{app_name}/config"
|
68
|
+
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
|
69
|
+
FileUtils.touch("#{config_dir}/souls.rb")
|
70
|
+
file_path = "#{config_dir}/souls.rb"
|
71
|
+
File.open(file_path, "w") do |f|
|
72
|
+
f.write(<<~TEXT)
|
73
|
+
Souls.configure do |config|
|
74
|
+
config.app = "#{app_name}"
|
75
|
+
config.project_id = "#{app_name}-project"
|
76
|
+
config.endpoint = "/endpoint"
|
77
|
+
config.strain = "mother"
|
78
|
+
config.fixed_gems = ["excluded_gem"]
|
79
|
+
config.workers = []
|
80
|
+
end
|
81
|
+
TEXT
|
82
|
+
end
|
83
|
+
rescue StandardError => e
|
84
|
+
puts(e)
|
85
|
+
end
|
86
|
+
|
87
|
+
def start(args)
|
88
|
+
app_name = args[1]
|
89
|
+
if app_name.nil?
|
90
|
+
puts(Paint["you need to specify your app name", :red])
|
91
|
+
puts(Paint["`souls new souls-app`", :yellow])
|
92
|
+
exit
|
93
|
+
end
|
94
|
+
|
95
|
+
service_name = "api"
|
96
|
+
Souls::Init.download_souls(app_name: app_name, service_name: service_name)
|
97
|
+
Souls::Init.mother_config_init(app_name: app_name)
|
98
|
+
Souls::Init.download_github_actions(app_name: app_name)
|
99
|
+
Souls::Init.initial_config_init(app_name: app_name, service_name: service_name)
|
100
|
+
Souls::Init.souls_api_credit(app_name: app_name, service_name: service_name)
|
101
|
+
end
|
102
|
+
|
103
|
+
def download_souls(app_name: "souls", service_name: "api")
|
104
|
+
version = Souls.get_latest_version_txt(service_name: service_name).join(".")
|
105
|
+
file_name = "#{service_name}-v#{version}.tgz"
|
106
|
+
url = "https://storage.googleapis.com/souls-bucket/boilerplates/#{service_name.pluralize}/#{file_name}"
|
107
|
+
system("curl -OL #{url}")
|
108
|
+
system("mkdir -p #{app_name}/apps/#{service_name}")
|
109
|
+
system("tar -zxvf ./#{file_name} -C #{app_name}/apps/")
|
110
|
+
system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/.rubocop.yml")
|
111
|
+
system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/Gemfile")
|
112
|
+
system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/Procfile.dev")
|
113
|
+
system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/Procfile")
|
114
|
+
FileUtils.rm(file_name)
|
115
|
+
end
|
116
|
+
|
117
|
+
def souls_api_credit(app_name: "souls", service_name: "api")
|
118
|
+
line = Paint["====================================", :yellow]
|
119
|
+
puts("\n")
|
120
|
+
puts(line)
|
121
|
+
txt2 = <<~TEXT
|
122
|
+
_____ ____ __ ____#{' '}
|
123
|
+
/ ___// __ \\/ / / / / %{red1}
|
124
|
+
\\__ \\/ / / / / / / / %{red2}
|
125
|
+
___/ / /_/ / /_/ / /___%{red3}#{' '}
|
126
|
+
/____/\\____/\\____/_____%{red4}#{' '}
|
127
|
+
TEXT
|
128
|
+
red1 = ["_____", :red]
|
129
|
+
red2 = ["/ ___/", :red]
|
130
|
+
red3 = ["(__ )", :red]
|
131
|
+
red4 = ["/____/", :red]
|
132
|
+
ms = Paint % [txt2, :cyan, { red1: red1, red2: red2, red3: red3, red4: red4 }]
|
133
|
+
puts(ms)
|
134
|
+
puts(line)
|
135
|
+
welcome = Paint["Welcome to SOULs!", :white]
|
136
|
+
puts(welcome)
|
137
|
+
souls_ver = Paint["SOULs Version: #{Souls::VERSION}", :white]
|
138
|
+
puts(souls_ver)
|
139
|
+
puts(line)
|
140
|
+
endroll = <<~TEXT
|
141
|
+
Easy to Run
|
142
|
+
$ cd #{app_name}/apps/#{service_name}
|
143
|
+
$ bundle
|
144
|
+
$ souls s
|
145
|
+
Go To : http://localhost:4000
|
146
|
+
|
147
|
+
Doc: https://souls.elsoul.nl
|
148
|
+
TEXT
|
149
|
+
cd = Paint[endroll, :white]
|
150
|
+
puts(cd)
|
151
|
+
puts(line)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -19,11 +19,11 @@ module Souls
|
|
19
19
|
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
20
20
|
Whirly.status = status
|
21
21
|
%w[api worker].each do |s_name|
|
22
|
-
|
23
|
-
result = Paint[
|
22
|
+
update_service_gemfile(service_name: s_name, version: souls_new_ver)
|
23
|
+
result = Paint[update_repo(service_name: s_name, update_kind: update_kind), :green]
|
24
24
|
Whirly.status = result
|
25
25
|
end
|
26
|
-
|
26
|
+
overwrite_version(new_version: souls_new_ver)
|
27
27
|
puts("before add")
|
28
28
|
system("git add .")
|
29
29
|
puts("before commit")
|
@@ -34,6 +34,94 @@ module Souls
|
|
34
34
|
Whirly.status = Paint["soul-v#{souls_new_ver} successfully updated!"]
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
def update_repo(service_name: "api", update_kind: "patch")
|
39
|
+
current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
|
40
|
+
current_ver = Souls.get_latest_version_txt(service_name: service_name)
|
41
|
+
new_ver = Souls.version_detector(current_ver: current_ver, update_kind: update_kind)
|
42
|
+
bucket_url = "gs://souls-bucket/boilerplates"
|
43
|
+
file_name = "#{service_name}-v#{new_ver}.tgz"
|
44
|
+
release_name = "#{service_name}-latest.tgz"
|
45
|
+
|
46
|
+
case current_dir_name
|
47
|
+
when "souls"
|
48
|
+
system("echo '#{new_ver}' > lib/souls/versions/.souls_#{service_name}_version")
|
49
|
+
system("echo '#{new_ver}' > apps/#{service_name}/.souls_#{service_name}_version")
|
50
|
+
system("cd apps/ && tar -czf ../#{service_name}.tgz #{service_name}/ && cd ..")
|
51
|
+
when "api", "worker", "console", "admin", "media"
|
52
|
+
system("echo '#{new_ver}' > lib/souls/versions/.souls_#{service_name}_version")
|
53
|
+
system("echo '#{new_ver}' > .souls_#{service_name}_version")
|
54
|
+
system("cd .. && tar -czf ../#{service_name}.tgz #{service_name}/ && cd #{service_name}")
|
55
|
+
else
|
56
|
+
raise(StandardError, "You are at wrong directory!")
|
57
|
+
end
|
58
|
+
|
59
|
+
system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{file_name}")
|
60
|
+
system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{release_name}")
|
61
|
+
system("gsutil cp .rubocop.yml #{bucket_url}/.rubocop.yml")
|
62
|
+
FileUtils.rm("#{service_name}.tgz")
|
63
|
+
"#{service_name}-v#{new_ver} Succefully Stored to GCS! "
|
64
|
+
end
|
65
|
+
|
66
|
+
def update_service_gemfile(service_name: "api", version: "0.0.1")
|
67
|
+
file_dir = "./apps/#{service_name}"
|
68
|
+
file_path = "#{file_dir}/Gemfile"
|
69
|
+
gemfile_lock = "#{file_dir}/Gemfile.lock"
|
70
|
+
tmp_file = "#{file_dir}/tmp/Gemfile"
|
71
|
+
File.open(file_path, "r") do |f|
|
72
|
+
File.open(tmp_file, "w") do |new_line|
|
73
|
+
f.each_line do |line|
|
74
|
+
gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
|
75
|
+
if gem[0] == "souls"
|
76
|
+
old_ver = gem[1].split(".")
|
77
|
+
old_ver[2] = (old_ver[2].to_i + 1).to_s
|
78
|
+
new_line.write(" gem \"souls\", \"#{version}\"\n")
|
79
|
+
else
|
80
|
+
new_line.write(line)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
FileUtils.rm(file_path)
|
86
|
+
FileUtils.rm(gemfile_lock) if File.exist?(gemfile_lock)
|
87
|
+
FileUtils.mv(tmp_file, file_path)
|
88
|
+
puts(Paint["\nSuccessfully Updated #{service_name} Gemfile!", :green])
|
89
|
+
end
|
90
|
+
|
91
|
+
def overwrite_version(new_version: "0.1.1")
|
92
|
+
FileUtils.rm("./lib/souls/version.rb")
|
93
|
+
file_path = "./lib/souls/version.rb"
|
94
|
+
File.open(file_path, "w") do |f|
|
95
|
+
f.write(<<~TEXT)
|
96
|
+
module Souls
|
97
|
+
VERSION = "#{new_version}".freeze
|
98
|
+
public_constant :VERSION
|
99
|
+
end
|
100
|
+
TEXT
|
101
|
+
end
|
102
|
+
overwrite_gemfile_lock(new_version: new_version)
|
103
|
+
true
|
104
|
+
rescue StandardError, e
|
105
|
+
raise(StandardError, e)
|
106
|
+
end
|
107
|
+
|
108
|
+
def overwrite_gemfile_lock(new_version: "0.1.1")
|
109
|
+
file_path = "Gemfile.lock"
|
110
|
+
new_file_path = "Gemfile.lock.tmp"
|
111
|
+
File.open(file_path, "r") do |f|
|
112
|
+
File.open(new_file_path, "w") do |new_line|
|
113
|
+
f.each_line.with_index do |line, i|
|
114
|
+
if i == 3
|
115
|
+
new_line.write(" souls (#{new_version})\n")
|
116
|
+
else
|
117
|
+
new_line.write(line)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
FileUtils.rm(file_path)
|
123
|
+
FileUtils.mv(new_file_path, file_path)
|
124
|
+
end
|
37
125
|
end
|
38
126
|
end
|
39
127
|
end
|
data/lib/souls/cli/sync/conf.rb
CHANGED
@@ -24,16 +24,26 @@ module Souls
|
|
24
24
|
next unless worker_switch
|
25
25
|
|
26
26
|
new_line.write(" config.workers = [\n")
|
27
|
-
workers.
|
27
|
+
workers.each_with_index do |worker, i|
|
28
28
|
base_url = Souls::Gcloud::Run.get_endpoint(worker_name: worker[:name])
|
29
29
|
endpoint = Souls.configuration.endpoint
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
36
|
-
|
30
|
+
if (i + 1) == workers.size
|
31
|
+
new_line.write(<<-TEXT)
|
32
|
+
{
|
33
|
+
name: "#{worker[:name]}",
|
34
|
+
endpoint: "#{base_url.strip}#{endpoint}",
|
35
|
+
port: #{worker[:port]}
|
36
|
+
}
|
37
|
+
TEXT
|
38
|
+
else
|
39
|
+
new_line.write(<<-TEXT)
|
40
|
+
{
|
41
|
+
name: "#{worker[:name]}",
|
42
|
+
endpoint: "#{base_url.strip}#{endpoint}",
|
43
|
+
port: #{worker[:port]}
|
44
|
+
},
|
45
|
+
TEXT
|
46
|
+
end
|
37
47
|
end
|
38
48
|
break
|
39
49
|
end
|