souls 1.6.15 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/souls/cli/gcloud/compute/index.rb +21 -1
- data/lib/souls/cli/gcloud/sql/index.rb +1 -1
- data/lib/souls/cli/init/index.rb +3 -1
- data/lib/souls/cli/release/release.rb +74 -23
- 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
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32302ba2e0fd1c7f83b719c9dce0ab98c34a38f988f7f2b6f384fab8819a9990
|
4
|
+
data.tar.gz: cdd9b060a8fdbf9ced59a1ec2398387a7a44ad6d885d4027c0d4c75ada92c065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90b63307663021f3885fa96f09a49b784a3a5fd7c22f260e2602442342ad8fd630ef9e6ba76361548fce88afcb50240dec170cc3d895988b0b84d3dd8daf5e54
|
7
|
+
data.tar.gz: 2546afbd6fce7bd1c08beb29b622cb851bc3ccb0fa138f6f729b05af7c38e1af168f57cb6c6d3634730a2f246c9c8787bb8ca7c89cc862996e1102de44d1102a
|
@@ -3,7 +3,8 @@ module Souls
|
|
3
3
|
desc "setup_vpc_nat", "Set Up VPC Cloud Nat"
|
4
4
|
method_option :range, default: "10.124.0.0/28", aliases: "--range", desc: "GCP VPC Network IP Range"
|
5
5
|
def setup_vpc_nat
|
6
|
-
puts(Paint["Initializing NAT Setup This process might take about
|
6
|
+
puts(Paint["Initializing NAT Setup This process might take about 10 min...", :yellow])
|
7
|
+
Souls::Gcloud.new.config_set
|
7
8
|
create_network
|
8
9
|
create_firewall_tcp(range: options[:range])
|
9
10
|
create_firewall_ssh
|
@@ -14,7 +15,9 @@ module Souls
|
|
14
15
|
create_nat
|
15
16
|
Souls::Sql.new.invoke(:setup_private_ip)
|
16
17
|
update_workflows
|
18
|
+
update_env
|
17
19
|
puts(Paint["Cloud NAT is All Set!", :green])
|
20
|
+
puts(Paint["\nYou need to deploy to update production DB_HOST environment!", :yellow])
|
18
21
|
true
|
19
22
|
rescue Thor::Error => e
|
20
23
|
raise(Thor::Error, e)
|
@@ -22,6 +25,23 @@ module Souls
|
|
22
25
|
|
23
26
|
private
|
24
27
|
|
28
|
+
def update_env
|
29
|
+
instance_name = Souls.configuration.instance_name
|
30
|
+
private_instance_ip = `gcloud sql instances list | grep #{instance_name} | awk '{print $6}'`.strip
|
31
|
+
Dir.chdir(Souls.get_mother_path.to_s) do
|
32
|
+
file_path = ".env.production"
|
33
|
+
env_production = File.readlines(file_path)
|
34
|
+
env_production[0] = "SOULS_DB_HOST=#{private_instance_ip}\n"
|
35
|
+
File.open(file_path, "w") { |f| f.write(env_production.join) }
|
36
|
+
end
|
37
|
+
system("gh secret set DB_HOST -b #{private_instance_ip}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_external_ip
|
41
|
+
app_name = Souls.configuration.app
|
42
|
+
`gcloud compute addresses list | grep #{app_name}-worker-ip | awk '{print $2}'`.strip
|
43
|
+
end
|
44
|
+
|
25
45
|
def create_network
|
26
46
|
app_name = Souls.configuration.app
|
27
47
|
system("gcloud compute networks create #{app_name}")
|
@@ -122,7 +122,7 @@ module Souls
|
|
122
122
|
instance_name = Souls.configuration.instance_name if instance_name.blank?
|
123
123
|
system(
|
124
124
|
"
|
125
|
-
gcloud
|
125
|
+
gcloud sql instances patch #{instance_name} \
|
126
126
|
--project=#{project_id} \
|
127
127
|
--assign-ip \
|
128
128
|
--authorized-networks=#{ip}
|
data/lib/souls/cli/init/index.rb
CHANGED
@@ -115,6 +115,8 @@ module Souls
|
|
115
115
|
|
116
116
|
def get_latest_gem(app_name)
|
117
117
|
file_path = "./#{app_name}/Gemfile"
|
118
|
+
souls_gem = "gem \"souls\", \"#{Souls::VERSION}\""
|
119
|
+
souls_gem = "gem \"souls\", \"#{Souls::VERSION}\", path: \"~/.local_souls/\"" if Souls::VERSION.length > 20
|
118
120
|
File.open(file_path, "w") do |f|
|
119
121
|
f.write(<<~TEXT)
|
120
122
|
source "https://rubygems.org"
|
@@ -130,7 +132,7 @@ module Souls
|
|
130
132
|
gem "rubocop", "1.22.3"
|
131
133
|
gem "sinatra-activerecord", "2.0.23"
|
132
134
|
gem "solargraph", "0.44.0"
|
133
|
-
|
135
|
+
#{souls_gem}
|
134
136
|
gem "steep", "0.46.0"
|
135
137
|
gem "thor", "1.1.0"
|
136
138
|
gem "tty-prompt", "0.23.1"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "securerandom"
|
2
|
+
|
1
3
|
module Souls
|
2
4
|
class CLI < Thor
|
3
5
|
desc "release", "Release Gem"
|
@@ -22,7 +24,7 @@ module Souls
|
|
22
24
|
Whirly.status = status
|
23
25
|
%w[api worker].each do |s_name|
|
24
26
|
update_service_gemfile(service_name: s_name, version: souls_new_ver)
|
25
|
-
result = Paint[update_repo(service_name: s_name,
|
27
|
+
result = Paint[update_repo(service_name: s_name, version: souls_new_ver), :green]
|
26
28
|
Whirly.status = result
|
27
29
|
end
|
28
30
|
overwrite_version(new_version: souls_new_ver)
|
@@ -40,6 +42,46 @@ module Souls
|
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
45
|
+
desc "release_local", "Release gem for local use"
|
46
|
+
def release_local
|
47
|
+
unless `git status`.include?("nothing to commit")
|
48
|
+
raise(
|
49
|
+
StandardError,
|
50
|
+
"You can only release to local with a clean working directory. Please commit your changes."
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
local_dir = "~/.local_souls/"
|
55
|
+
|
56
|
+
system("mkdir -p #{local_dir}")
|
57
|
+
souls_local_ver = generate_local_version
|
58
|
+
|
59
|
+
status = Paint["Saving Repo...", :yellow]
|
60
|
+
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
61
|
+
Whirly.status = status
|
62
|
+
|
63
|
+
%w[api worker].each do |s_name|
|
64
|
+
update_service_gemfile(service_name: s_name, version: souls_local_ver, local: true)
|
65
|
+
result = Paint[update_repo(service_name: s_name, version: souls_local_ver), :green]
|
66
|
+
Whirly.status = result
|
67
|
+
end
|
68
|
+
|
69
|
+
Whirly.status = Paint["Creating local gem..."]
|
70
|
+
|
71
|
+
overwrite_version(new_version: souls_local_ver)
|
72
|
+
system("gem build souls.gemspec --output #{local_dir}souls-#{souls_local_ver}.gem")
|
73
|
+
Whirly.status = Paint["Done. Created gem at #{local_dir}souls-#{souls_local_ver}.gem"]
|
74
|
+
Whirly.status = Paint["Removing previous versions...", :white]
|
75
|
+
system("gem uninstall souls -x --force")
|
76
|
+
|
77
|
+
Whirly.status = Paint["Installing local gem..."]
|
78
|
+
system("gem install #{local_dir}souls-#{souls_local_ver}.gem")
|
79
|
+
|
80
|
+
Whirly.status = Paint["Cleaning up..."]
|
81
|
+
system("git checkout .")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
43
85
|
private
|
44
86
|
|
45
87
|
def write_changelog(current_souls_ver:)
|
@@ -58,22 +100,20 @@ module Souls
|
|
58
100
|
File.open("./CHANGELOG.md", "w") { |f| f.write(md) }
|
59
101
|
end
|
60
102
|
|
61
|
-
def update_repo(service_name: "api",
|
103
|
+
def update_repo(service_name: "api", version: "0.0.1")
|
62
104
|
current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
|
63
|
-
current_ver = Souls.get_latest_version_txt(service_name: service_name)
|
64
|
-
new_ver = Souls.version_detector(current_ver: current_ver, update_kind: update_kind)
|
65
105
|
bucket_url = "gs://souls-bucket/boilerplates"
|
66
|
-
file_name = "#{service_name}-v#{
|
106
|
+
file_name = "#{service_name}-v#{version}.tgz"
|
67
107
|
release_name = "#{service_name}-latest.tgz"
|
68
108
|
|
69
109
|
case current_dir_name
|
70
110
|
when "souls"
|
71
|
-
system("echo '#{
|
72
|
-
system("echo '#{
|
111
|
+
system("echo '#{version}' > lib/souls/versions/.souls_#{service_name}_version")
|
112
|
+
system("echo '#{version}' > apps/#{service_name}/.souls_#{service_name}_version")
|
73
113
|
system("cd apps/ && tar -czf ../#{service_name}.tgz #{service_name}/ && cd ..")
|
74
114
|
when "api", "worker", "console", "admin", "media"
|
75
|
-
system("echo '#{
|
76
|
-
system("echo '#{
|
115
|
+
system("echo '#{version}' > lib/souls/versions/.souls_#{service_name}_version")
|
116
|
+
system("echo '#{version}' > .souls_#{service_name}_version")
|
77
117
|
system("cd .. && tar -czf ../#{service_name}.tgz #{service_name}/ && cd #{service_name}")
|
78
118
|
else
|
79
119
|
raise(StandardError, "You are at wrong directory!")
|
@@ -83,31 +123,33 @@ module Souls
|
|
83
123
|
system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{release_name}")
|
84
124
|
system("gsutil cp .rubocop.yml #{bucket_url}/.rubocop.yml")
|
85
125
|
FileUtils.rm("#{service_name}.tgz")
|
86
|
-
"#{service_name}-v#{
|
126
|
+
"#{service_name}-v#{version} Succefully Stored to GCS! "
|
87
127
|
end
|
88
128
|
|
89
|
-
def update_service_gemfile(service_name: "api", version: "0.0.1")
|
129
|
+
def update_service_gemfile(service_name: "api", version: "0.0.1", local: false)
|
90
130
|
file_dir = "./apps/#{service_name}"
|
91
131
|
file_path = "#{file_dir}/Gemfile"
|
92
|
-
|
93
|
-
|
132
|
+
|
133
|
+
write_txt = ""
|
94
134
|
File.open(file_path, "r") do |f|
|
95
|
-
|
96
|
-
|
97
|
-
|
135
|
+
f.each_line do |line|
|
136
|
+
gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
|
137
|
+
write_txt +=
|
98
138
|
if gem[0] == "souls"
|
99
|
-
|
100
|
-
|
101
|
-
|
139
|
+
if local
|
140
|
+
" gem \"souls\", \"#{version}\", path: \"~/.local_souls/\"\n"
|
141
|
+
else
|
142
|
+
" gem \"souls\", \"#{version}\"\n"
|
143
|
+
end
|
102
144
|
else
|
103
|
-
|
145
|
+
line
|
104
146
|
end
|
105
|
-
end
|
106
147
|
end
|
107
148
|
end
|
108
|
-
|
149
|
+
File.open(file_path, "w") { |f| f.write(write_txt) }
|
150
|
+
|
151
|
+
gemfile_lock = "#{file_dir}/Gemfile.lock"
|
109
152
|
FileUtils.rm(gemfile_lock) if File.exist?(gemfile_lock)
|
110
|
-
FileUtils.mv(tmp_file, file_path)
|
111
153
|
puts(Paint["\nSuccessfully Updated #{service_name} Gemfile!", :green])
|
112
154
|
end
|
113
155
|
|
@@ -145,5 +187,14 @@ module Souls
|
|
145
187
|
FileUtils.rm(file_path)
|
146
188
|
FileUtils.mv(new_file_path, file_path)
|
147
189
|
end
|
190
|
+
|
191
|
+
def generate_local_version
|
192
|
+
max = 99_999_999_999
|
193
|
+
a = SecureRandom.random_number(max) + 9999
|
194
|
+
b = SecureRandom.random_number(max)
|
195
|
+
c = SecureRandom.random_number(max)
|
196
|
+
|
197
|
+
"#{a}.#{b}.#{c}"
|
198
|
+
end
|
148
199
|
end
|
149
200
|
end
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.7.0
|
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.7.0
|
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.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
@@ -232,7 +232,7 @@ 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/v1.
|
235
|
+
changelog_uri: https://github.com/elsoul/souls/releases/tag/v1.7.0
|
236
236
|
post_install_message:
|
237
237
|
rdoc_options: []
|
238
238
|
require_paths:
|