souls 0.24.1 → 0.24.5
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 +12 -1
- data/lib/souls.rb +181 -123
- data/lib/souls/gcloud/iam.rb +30 -16
- data/lib/souls/init.rb +22 -16
- data/lib/souls/version.rb +1 -1
- metadata +16 -193
- data/.gitignore +0 -15
- data/.irbrc +0 -2
- data/.rspec +0 -3
- data/.rubocop.yml +0 -152
- data/.ruby-version +0 -1
- data/.travis.yml +0 -6
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -98
- data/Rakefile +0 -23
- data/Steepfile +0 -8
- data/api_v0.0.1.tar.gz +0 -0
- data/apps/api/.env.sample +0 -7
- data/apps/api/.gitignore +0 -32
- data/apps/api/.irbrc +0 -1
- data/apps/api/.rspec +0 -3
- data/apps/api/.rubocop.yml +0 -132
- data/apps/api/.ruby-version +0 -1
- data/apps/api/CODE_OF_CONDUCT.md +0 -74
- data/apps/api/Dockerfile +0 -16
- data/apps/api/Dockerfile.dev +0 -17
- data/apps/api/Gemfile +0 -50
- data/apps/api/Gemfile.lock +0 -412
- data/apps/api/LICENSE.txt +0 -67
- data/apps/api/Procfile +0 -2
- data/apps/api/Procfile.dev +0 -2
- data/apps/api/README.md +0 -37
- data/apps/api/Rakefile +0 -5
- data/apps/api/app.rb +0 -114
- data/apps/api/app/engines/notification_engine.rb +0 -5
- data/apps/api/app/graphql/mutations/.keep +0 -0
- data/apps/api/app/graphql/mutations/base/article/create_article.rb +0 -30
- data/apps/api/app/graphql/mutations/base/article/delete_article.rb +0 -17
- data/apps/api/app/graphql/mutations/base/article/destroy_delete_article.rb +0 -17
- data/apps/api/app/graphql/mutations/base/article/update_article.rb +0 -30
- data/apps/api/app/graphql/mutations/base/article_category/create_article_category.rb +0 -21
- data/apps/api/app/graphql/mutations/base/article_category/delete_article_category.rb +0 -17
- data/apps/api/app/graphql/mutations/base/article_category/destroy_delete_article_category.rb +0 -17
- data/apps/api/app/graphql/mutations/base/article_category/update_article_category.rb +0 -21
- data/apps/api/app/graphql/mutations/base/user/create_user.rb +0 -31
- data/apps/api/app/graphql/mutations/base/user/delete_user.rb +0 -17
- data/apps/api/app/graphql/mutations/base/user/destroy_delete_user.rb +0 -17
- data/apps/api/app/graphql/mutations/base/user/update_user.rb +0 -31
- data/apps/api/app/graphql/mutations/base_mutation.rb +0 -65
- data/apps/api/app/graphql/mutations/managers/user_manager/add_user_role.rb +0 -22
- data/apps/api/app/graphql/mutations/managers/user_manager/remove_user_role.rb +0 -22
- data/apps/api/app/graphql/mutations/managers/user_manager/sign_in_user.rb +0 -45
- data/apps/api/app/graphql/queries/article.rb +0 -13
- data/apps/api/app/graphql/queries/article_categories.rb +0 -11
- data/apps/api/app/graphql/queries/article_category.rb +0 -13
- data/apps/api/app/graphql/queries/articles.rb +0 -11
- data/apps/api/app/graphql/queries/base_query.rb +0 -12
- data/apps/api/app/graphql/queries/me.rb +0 -11
- data/apps/api/app/graphql/queries/user.rb +0 -13
- data/apps/api/app/graphql/queries/users.rb +0 -11
- data/apps/api/app/graphql/resolvers/article_category_search.rb +0 -41
- data/apps/api/app/graphql/resolvers/article_search.rb +0 -57
- data/apps/api/app/graphql/resolvers/base.rb +0 -17
- data/apps/api/app/graphql/resolvers/user_search.rb +0 -63
- data/apps/api/app/graphql/souls_api_schema.rb +0 -43
- data/apps/api/app/graphql/types/.keep +0 -0
- data/apps/api/app/graphql/types/article_category_type.rb +0 -12
- data/apps/api/app/graphql/types/article_type.rb +0 -30
- data/apps/api/app/graphql/types/base/base_argument.rb +0 -4
- data/apps/api/app/graphql/types/base/base_enum.rb +0 -4
- data/apps/api/app/graphql/types/base/base_field.rb +0 -5
- data/apps/api/app/graphql/types/base/base_input_object.rb +0 -5
- data/apps/api/app/graphql/types/base/base_interface.rb +0 -7
- data/apps/api/app/graphql/types/base/base_object.rb +0 -6
- data/apps/api/app/graphql/types/base/base_scalar.rb +0 -4
- data/apps/api/app/graphql/types/base/base_union.rb +0 -4
- data/apps/api/app/graphql/types/base/mutation_type.rb +0 -26
- data/apps/api/app/graphql/types/base/query_type.rb +0 -18
- data/apps/api/app/graphql/types/connections/article_category_connection.rb +0 -3
- data/apps/api/app/graphql/types/connections/article_connection.rb +0 -3
- data/apps/api/app/graphql/types/connections/base_connection.rb +0 -14
- data/apps/api/app/graphql/types/connections/user_connection.rb +0 -3
- data/apps/api/app/graphql/types/edges/article_category_edge.rb +0 -5
- data/apps/api/app/graphql/types/edges/article_edge.rb +0 -5
- data/apps/api/app/graphql/types/edges/base_edge.rb +0 -4
- data/apps/api/app/graphql/types/edges/user_edge.rb +0 -5
- data/apps/api/app/graphql/types/user_type.rb +0 -24
- data/apps/api/app/models/article.rb +0 -4
- data/apps/api/app/models/article_category.rb +0 -3
- data/apps/api/app/models/user.rb +0 -19
- data/apps/api/app/policies/application_policy.rb +0 -40
- data/apps/api/app/policies/article_category_policy.rb +0 -31
- data/apps/api/app/policies/article_policy.rb +0 -31
- data/apps/api/app/policies/user_policy.rb +0 -35
- data/apps/api/app/utils/association_loader.rb +0 -50
- data/apps/api/app/utils/fire_store.rb +0 -9
- data/apps/api/app/utils/firebase_id_token.rb +0 -4
- data/apps/api/app/utils/json_web_token.rb +0 -13
- data/apps/api/app/utils/record_loader.rb +0 -10
- data/apps/api/app/utils/souls_helper.rb +0 -18
- data/apps/api/cloudbuild.yml +0 -32
- data/apps/api/config.ru +0 -17
- data/apps/api/config/database.yml +0 -33
- data/apps/api/config/souls.rb +0 -10
- data/apps/api/constants/areas.rb +0 -71
- data/apps/api/constants/column_name_ja.rb +0 -27
- data/apps/api/db/migrate/20200006095538_create_users.rb +0 -30
- data/apps/api/db/migrate/20200712180236_create_article_categories.rb +0 -12
- data/apps/api/db/migrate/20200714215521_create_articles.rb +0 -22
- data/apps/api/db/schema.rb +0 -78
- data/apps/api/db/seeds.rb +0 -44
- data/apps/api/github/workflows/delivery.yml +0 -81
- data/apps/api/log/.keep +0 -0
- data/apps/api/spec/factories/article_categories.rb +0 -9
- data/apps/api/spec/factories/articles.rb +0 -17
- data/apps/api/spec/factories/users.rb +0 -23
- data/apps/api/spec/models/article_category_spec.rb +0 -7
- data/apps/api/spec/models/article_spec.rb +0 -7
- data/apps/api/spec/models/user_spec.rb +0 -7
- data/apps/api/spec/mutations/base/article_category_spec.rb +0 -46
- data/apps/api/spec/mutations/base/article_spec.rb +0 -70
- data/apps/api/spec/mutations/base/user_spec.rb +0 -76
- data/apps/api/spec/policies/article_category_policy_spec.rb +0 -25
- data/apps/api/spec/policies/article_policy_spec.rb +0 -25
- data/apps/api/spec/policies/user_policy_spec.rb +0 -5
- data/apps/api/spec/queries/article_category_spec.rb +0 -39
- data/apps/api/spec/queries/article_spec.rb +0 -53
- data/apps/api/spec/queries/user_spec.rb +0 -59
- data/apps/api/spec/resolvers/article_category_search_spec.rb +0 -54
- data/apps/api/spec/resolvers/article_search_spec.rb +0 -68
- data/apps/api/spec/resolvers/user_search_spec.rb +0 -74
- data/apps/api/spec/spec_helper.rb +0 -110
- data/apps/api/tmp/.keep +0 -0
- data/apps/worker/.env.sample +0 -9
- data/apps/worker/.gitignore +0 -32
- data/apps/worker/.irbrc +0 -1
- data/apps/worker/.rspec +0 -3
- data/apps/worker/.rubocop.yml +0 -132
- data/apps/worker/.ruby-version +0 -1
- data/apps/worker/CODE_OF_CONDUCT.md +0 -74
- data/apps/worker/Dockerfile +0 -16
- data/apps/worker/Dockerfile.dev +0 -17
- data/apps/worker/Gemfile +0 -49
- data/apps/worker/Gemfile.lock +0 -396
- data/apps/worker/LICENSE.txt +0 -67
- data/apps/worker/Procfile +0 -1
- data/apps/worker/Procfile.dev +0 -1
- data/apps/worker/README.md +0 -37
- data/apps/worker/Rakefile +0 -5
- data/apps/worker/app.rb +0 -101
- data/apps/worker/app/engines/notification_engine.rb +0 -5
- data/apps/worker/app/graphql/mutations/.keep +0 -0
- data/apps/worker/app/graphql/mutations/base_mutation.rb +0 -16
- data/apps/worker/app/graphql/mutations/workers/send_user_mail_job.rb +0 -31
- data/apps/worker/app/graphql/souls_api_schema.rb +0 -43
- data/apps/worker/app/graphql/types/.keep +0 -0
- data/apps/worker/app/graphql/types/base/base_argument.rb +0 -4
- data/apps/worker/app/graphql/types/base/base_enum.rb +0 -4
- data/apps/worker/app/graphql/types/base/base_field.rb +0 -5
- data/apps/worker/app/graphql/types/base/base_input_object.rb +0 -5
- data/apps/worker/app/graphql/types/base/base_interface.rb +0 -7
- data/apps/worker/app/graphql/types/base/base_object.rb +0 -5
- data/apps/worker/app/graphql/types/base/base_scalar.rb +0 -4
- data/apps/worker/app/graphql/types/base/base_union.rb +0 -4
- data/apps/worker/app/graphql/types/base/mutation_type.rb +0 -12
- data/apps/worker/app/graphql/types/base/query_type.rb +0 -6
- data/apps/worker/app/models/article.rb +0 -4
- data/apps/worker/app/models/article_category.rb +0 -3
- data/apps/worker/app/models/user.rb +0 -19
- data/apps/worker/app/utils/fire_store.rb +0 -9
- data/apps/worker/app/utils/souls_helper.rb +0 -96
- data/apps/worker/cloudbuild.yml +0 -32
- data/apps/worker/config.ru +0 -17
- data/apps/worker/config/database.yml +0 -33
- data/apps/worker/config/souls.rb +0 -10
- data/apps/worker/db/migrate/20200006095538_create_users.rb +0 -30
- data/apps/worker/db/migrate/20200712180236_create_article_categories.rb +0 -12
- data/apps/worker/db/migrate/20200714215521_create_articles.rb +0 -22
- data/apps/worker/db/schema.rb +0 -78
- data/apps/worker/db/seeds.rb +0 -44
- data/apps/worker/github/workflows/delivery.yml +0 -81
- data/apps/worker/log/.keep +0 -0
- data/apps/worker/spec/factories/article_categories.rb +0 -9
- data/apps/worker/spec/factories/articles.rb +0 -17
- data/apps/worker/spec/factories/users.rb +0 -23
- data/apps/worker/spec/models/article_category_spec.rb +0 -7
- data/apps/worker/spec/models/article_spec.rb +0 -7
- data/apps/worker/spec/models/user_spec.rb +0 -7
- data/apps/worker/spec/spec_helper.rb +0 -110
- data/apps/worker/tmp/.keep +0 -0
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/config/souls.rb +0 -9
- data/db/schema.rb +0 -67
- data/rbs/init.rbs +0 -2
- data/souls.gemspec +0 -34
- data/souls_api2.tar.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67f7e7198ec3b50441d76d83f17500df4a1f92f7c49e23143626a6229279aaae
|
4
|
+
data.tar.gz: c20d8e26c040f6132a06e854f30c9c5ea2f15c87945407df1e0d8effac427c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5790b5cde1a9f507df76250ec89896b43b747eaaffdf17c3a7c8533bdca27a50afe2185585f37fbdca34cdfc48a1add8a4b42f0069f41ab867352ed836d7c74
|
7
|
+
data.tar.gz: 63d1cb575a722d2e045039bf6e7f091c48dfff4a57b76cbf3752009250c87d090ec31c48fa17607c3782aabc148ac12c0509b365cd1d7c27fb424ede32541c62
|
data/exe/souls
CHANGED
@@ -32,7 +32,7 @@ begin
|
|
32
32
|
strain = $stdin.gets.chomp.to_i
|
33
33
|
case strain
|
34
34
|
when 1, 2
|
35
|
-
Souls::Init.download_souls(app_name: app_name,
|
35
|
+
Souls::Init.download_souls(app_name: app_name, service_name: (STRAINS[strain.to_i - 1]).to_s)
|
36
36
|
Souls::Init.initial_config_init(app_name: app_name, strain: STRAINS[strain.to_i - 1])
|
37
37
|
else
|
38
38
|
puts(Paint["Coming Soon...", :blue])
|
@@ -94,6 +94,17 @@ begin
|
|
94
94
|
Souls.update_gemfile
|
95
95
|
Whirly.status = "Done!"
|
96
96
|
end
|
97
|
+
when "update"
|
98
|
+
service_name = ARGV[1]
|
99
|
+
permit_services = %w[api worker console admin media]
|
100
|
+
raise(StandardError, "Wrong Service Name!") unless permit_services.include?(service_name)
|
101
|
+
|
102
|
+
status = Paint["Saving Repo...", :yellow]
|
103
|
+
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
104
|
+
Whirly.status = status
|
105
|
+
result = Paint[Souls.update_repo(service_name: service_name), :green]
|
106
|
+
Whirly.status = result
|
107
|
+
end
|
97
108
|
when "add"
|
98
109
|
graphql_class = ARGV[1]
|
99
110
|
case graphql_class
|
data/lib/souls.rb
CHANGED
@@ -3,11 +3,13 @@ require "active_support/core_ext/string/inflections"
|
|
3
3
|
require_relative "souls/init"
|
4
4
|
require_relative "souls/generate"
|
5
5
|
require_relative "souls/gcloud"
|
6
|
+
require "dotenv/load"
|
6
7
|
require "json"
|
7
8
|
require "fileutils"
|
8
9
|
require "net/http"
|
9
10
|
require "paint"
|
10
11
|
require "whirly"
|
12
|
+
require "google/cloud/firestore"
|
11
13
|
|
12
14
|
module Souls
|
13
15
|
SOULS_METHODS = %w[
|
@@ -28,143 +30,199 @@ module Souls
|
|
28
30
|
class Error < StandardError; end
|
29
31
|
class << self
|
30
32
|
attr_accessor :configuration
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.run_psql
|
34
|
-
system(
|
35
|
-
"docker run --rm -d \
|
36
|
-
-p 5433:5432 \
|
37
|
-
-v postgres-tmp:/var/lib/postgresql/data \
|
38
|
-
-e POSTGRES_USER=postgres \
|
39
|
-
-e POSTGRES_PASSWORD=postgres \
|
40
|
-
-e POSTGRES_DB=souls_test \
|
41
|
-
postgres:13-alpine"
|
42
|
-
)
|
43
|
-
system("docker ps")
|
44
|
-
end
|
45
33
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
34
|
+
def run_psql
|
35
|
+
system(
|
36
|
+
"docker run --rm -d \
|
37
|
+
-p 5433:5432 \
|
38
|
+
-v postgres-tmp:/var/lib/postgresql/data \
|
39
|
+
-e POSTGRES_USER=postgres \
|
40
|
+
-e POSTGRES_PASSWORD=postgres \
|
41
|
+
-e POSTGRES_DB=souls_test \
|
42
|
+
postgres:13-alpine"
|
43
|
+
)
|
44
|
+
system("docker ps")
|
45
|
+
end
|
58
46
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
47
|
+
def run_mysql
|
48
|
+
system(
|
49
|
+
"docker run --rm -d \
|
50
|
+
-p 3306:3306 \
|
51
|
+
-v mysql-tmp:/var/lib/mysql \
|
52
|
+
-e MYSQL_USER=mysql \
|
53
|
+
-e MYSQL_ROOT_PASSWORD=mysql \
|
54
|
+
-e MYSQL_DB=souls_test \
|
55
|
+
mysql:latest"
|
56
|
+
)
|
57
|
+
system("docker ps")
|
58
|
+
end
|
66
59
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
File.open(file_path, "r") do |f|
|
74
|
-
f.each_line do |line|
|
75
|
-
from_dev = true if line.include?("group")
|
76
|
-
next unless line.include?("gem ")
|
77
|
-
|
78
|
-
gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
|
79
|
-
url = URI("https://rubygems.org/api/v1/versions/#{gem[0]}/latest.json")
|
80
|
-
res = Net::HTTP.get_response(url)
|
81
|
-
data = JSON.parse(res.body)
|
82
|
-
next if Souls.configuration.fixed_gems.include?(gem[0].to_s)
|
83
|
-
next if data["version"].to_s == gem[1].to_s
|
84
|
-
|
85
|
-
updated_lines << if from_dev
|
86
|
-
" gem \"#{gem[0]}\", \"#{data['version']}\""
|
87
|
-
else
|
88
|
-
"gem \"#{gem[0]}\", \"#{data['version']}\""
|
89
|
-
end
|
90
|
-
updated_gems << (gem[0]).to_s
|
91
|
-
updated_gem_versions << data["version"]
|
92
|
-
system("gem update #{gem[0]}")
|
93
|
-
end
|
60
|
+
def run_awake(url)
|
61
|
+
app = Souls.configuration.app
|
62
|
+
system(
|
63
|
+
"gcloud scheduler jobs create http #{app}-awake
|
64
|
+
--schedule '0,10,20,30,40,50 * * * *' --uri #{url} --http-method GET"
|
65
|
+
)
|
94
66
|
end
|
95
|
-
{
|
96
|
-
gems: updated_gems,
|
97
|
-
lines: updated_lines,
|
98
|
-
updated_gem_versions: updated_gem_versions
|
99
|
-
}
|
100
|
-
end
|
101
67
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
@i = 0
|
111
|
-
File.open(file_path, "r") do |f|
|
112
|
-
File.open(tmp_file, "w") do |new_line|
|
68
|
+
def gemfile_latest_version
|
69
|
+
file_path = "./Gemfile"
|
70
|
+
updated_gems = []
|
71
|
+
updated_gem_versions = []
|
72
|
+
updated_lines = []
|
73
|
+
from_dev = false
|
74
|
+
File.open(file_path, "r") do |f|
|
113
75
|
f.each_line do |line|
|
76
|
+
from_dev = true if line.include?("group")
|
77
|
+
next unless line.include?("gem ")
|
78
|
+
|
114
79
|
gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
80
|
+
url = URI("https://rubygems.org/api/v1/versions/#{gem[0]}/latest.json")
|
81
|
+
res = Net::HTTP.get_response(url)
|
82
|
+
data = JSON.parse(res.body)
|
83
|
+
next if Souls.configuration.fixed_gems.include?(gem[0].to_s)
|
84
|
+
next if data["version"].to_s == gem[1].to_s
|
85
|
+
|
86
|
+
updated_lines << if from_dev
|
87
|
+
" gem \"#{gem[0]}\", \"#{data['version']}\""
|
88
|
+
else
|
89
|
+
"gem \"#{gem[0]}\", \"#{data['version']}\""
|
90
|
+
end
|
91
|
+
updated_gems << (gem[0]).to_s
|
92
|
+
updated_gem_versions << data["version"]
|
93
|
+
system("gem update #{gem[0]}")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
{
|
97
|
+
gems: updated_gems,
|
98
|
+
lines: updated_lines,
|
99
|
+
updated_gem_versions: updated_gem_versions
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
def update_gemfile
|
104
|
+
file_path = "./Gemfile"
|
105
|
+
tmp_file = "./tmp/Gemfile"
|
106
|
+
new_gems = gemfile_latest_version
|
107
|
+
logs = []
|
108
|
+
message = Paint["\nAlready Up to date!", :green]
|
109
|
+
return "Already Up to date!" && puts(message) if new_gems[:gems].blank?
|
110
|
+
|
111
|
+
@i = 0
|
112
|
+
File.open(file_path, "r") do |f|
|
113
|
+
File.open(tmp_file, "w") do |new_line|
|
114
|
+
f.each_line do |line|
|
115
|
+
gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
|
116
|
+
if new_gems[:gems].include?(gem[0])
|
117
|
+
old_ver = gem[1].split(".")
|
118
|
+
new_ver = new_gems[:updated_gem_versions][@i].split(".")
|
119
|
+
if old_ver[0] < new_ver[0]
|
120
|
+
logs << Paint % [
|
121
|
+
"#{gem[0]} v#{gem[1]} → %{red_text}",
|
122
|
+
:white,
|
123
|
+
{
|
124
|
+
red_text: ["v#{new_gems[:updated_gem_versions][@i]}", :red]
|
125
|
+
}
|
126
|
+
]
|
127
|
+
elsif old_ver[1] < new_ver[1]
|
128
|
+
logs << Paint % [
|
129
|
+
"#{gem[0]} v#{gem[1]} → v#{new_ver[0]}.%{yellow_text}",
|
130
|
+
:white,
|
131
|
+
{
|
132
|
+
yellow_text: ["#{new_ver[1]}.#{new_ver[2]}", :yellow]
|
133
|
+
}
|
134
|
+
]
|
135
|
+
elsif old_ver[2] < new_ver[2]
|
136
|
+
logs << Paint % [
|
137
|
+
"#{gem[0]} v#{gem[1]} → v#{new_ver[0]}.#{new_ver[1]}.%{green_text}",
|
138
|
+
:white,
|
139
|
+
{
|
140
|
+
green_text: [(new_ver[2]).to_s, :green]
|
141
|
+
}
|
142
|
+
]
|
143
|
+
end
|
144
|
+
if gem[0] == "souls"
|
145
|
+
logs << Paint % [
|
146
|
+
"\nSOULs Doc: %{cyan_text}",
|
147
|
+
:white,
|
148
|
+
{ cyan_text: ["https://souls.elsoul.nl\n", :cyan] }
|
149
|
+
]
|
150
|
+
end
|
151
|
+
new_line.write("#{new_gems[:lines][@i]}\n")
|
152
|
+
@i += 1
|
153
|
+
else
|
154
|
+
new_line.write(line)
|
145
155
|
end
|
146
|
-
new_line.write("#{new_gems[:lines][@i]}\n")
|
147
|
-
@i += 1
|
148
|
-
else
|
149
|
-
new_line.write(line)
|
150
156
|
end
|
151
157
|
end
|
152
158
|
end
|
159
|
+
FileUtils.rm("./Gemfile")
|
160
|
+
FileUtils.rm("./Gemfile.lock")
|
161
|
+
FileUtils.mv("./tmp/Gemfile", "./Gemfile")
|
162
|
+
system("bundle update")
|
163
|
+
success = Paint["\n\nSuccessfully Updated These Gems!\n", :green]
|
164
|
+
puts(success)
|
165
|
+
logs.each do |line|
|
166
|
+
puts(line)
|
167
|
+
end
|
153
168
|
end
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
169
|
+
|
170
|
+
def update_repo(service_name: "api")
|
171
|
+
current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
|
172
|
+
latest_gem = get_latest_version(service_name: service_name)
|
173
|
+
new_ver = latest_gem[:version_counter] + 1
|
174
|
+
bucket_url = "gs://souls-bucket/boilerplates"
|
175
|
+
file_name = "#{service_name}-v#{new_ver}.tgz"
|
176
|
+
|
177
|
+
case current_dir_name
|
178
|
+
when "souls"
|
179
|
+
system("echo 'v#{new_ver}' > apps/#{service_name}/.souls_version")
|
180
|
+
system("cd apps/ && tar -czf ../#{service_name}.tgz #{service_name}/ && cd ..")
|
181
|
+
when "api", "worker", "console", "admin", "media"
|
182
|
+
system("echo 'v#{new_ver}' > .souls_version")
|
183
|
+
system("cd .. && tar -czf ../#{service_name}.tgz #{service_name}/ && cd #{service_name}")
|
184
|
+
else
|
185
|
+
raise(StandardError, "You are at wrong directory!")
|
186
|
+
end
|
187
|
+
|
188
|
+
system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{file_name}")
|
189
|
+
file_url = "https://storage.googleapis.com/souls-bucket/boilerplates/#{service_name.pluralize}/#{file_name}"
|
190
|
+
version_log(service_name: service_name, version_counter: new_ver, file_url: file_url)
|
191
|
+
FileUtils.rm("#{service_name}.tgz")
|
192
|
+
"#{service_name}-v#{new_ver} Succefully Stored to GCS! "
|
162
193
|
end
|
163
|
-
end
|
164
194
|
|
165
|
-
|
166
|
-
|
167
|
-
|
195
|
+
def version_log(service_name: "api", version_counter: 1, file_url: "")
|
196
|
+
version = "v#{version_counter}"
|
197
|
+
time = Time.now.strftime("%F-%H-%M-%S")
|
198
|
+
firestore = Google::Cloud::Firestore.new(project_id: ENV["FIRESTORE_PID"])
|
199
|
+
doc_ref = firestore.doc("#{service_name}/#{version_counter}")
|
200
|
+
doc_ref.set({ version: version, version_counter: version_counter, file_url: file_url, created_at: time })
|
201
|
+
end
|
202
|
+
|
203
|
+
def get_latest_version(service_name: "api")
|
204
|
+
firestore = Google::Cloud::Firestore.new(project_id: ENV["FIRESTORE_PID"])
|
205
|
+
versions = firestore.doc("#{service_name}/1")
|
206
|
+
if versions.get.exists?
|
207
|
+
versions = firestore.col(service_name.to_s)
|
208
|
+
query = versions.order("version_counter", "desc").limit(1)
|
209
|
+
query.get do |v|
|
210
|
+
return {
|
211
|
+
version_counter: v.data[:version_counter],
|
212
|
+
version: v.data[:version],
|
213
|
+
file_url: v.data[:file_url],
|
214
|
+
create_at: v.data[:create_at]
|
215
|
+
}
|
216
|
+
end
|
217
|
+
else
|
218
|
+
{ version_counter: 0 }
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def configure
|
223
|
+
self.configuration ||= Configuration.new
|
224
|
+
yield(configuration)
|
225
|
+
end
|
168
226
|
end
|
169
227
|
|
170
228
|
class Configuration
|
data/lib/souls/gcloud/iam.rb
CHANGED
@@ -1,31 +1,45 @@
|
|
1
1
|
module Souls
|
2
2
|
module Gcloud
|
3
3
|
class << self
|
4
|
-
def create_service_account(
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
def create_service_account(args)
|
5
|
+
service_account = args[:service_account] || "souls-app"
|
6
|
+
system(
|
7
|
+
"gcloud iam service-accounts create #{service_account} \
|
8
|
+
--description='Souls Service Account' \
|
9
|
+
--display-name=#{service_account}"
|
10
|
+
)
|
8
11
|
end
|
9
12
|
|
10
|
-
def create_service_account_key(
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
def create_service_account_key(args)
|
14
|
+
service_account = args[:service_account] || "souls-app"
|
15
|
+
project_id = args[:project_id] || "souls-app"
|
16
|
+
system(
|
17
|
+
"gcloud iam service-accounts keys create ./config/keyfile.json \
|
18
|
+
--iam-account #{service_account}@#{project_id}.iam.gserviceaccount.com"
|
19
|
+
)
|
14
20
|
end
|
15
21
|
|
16
|
-
def add_service_account_role(
|
17
|
-
|
22
|
+
def add_service_account_role(args)
|
23
|
+
service_account = args[:service_account] || "souls-app"
|
24
|
+
project_id = args[:project_id] || "souls-app"
|
25
|
+
role = args[:role] || "roles/firebase.admin"
|
18
26
|
`gcloud projects add-iam-policy-binding #{project_id} \
|
19
27
|
--member="serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com" \
|
20
28
|
--role="#{role}"`
|
21
29
|
end
|
22
30
|
|
23
|
-
def add_permissions(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
def add_permissions(args)
|
32
|
+
service_account = args[:service_account] || "souls-app"
|
33
|
+
roles = [
|
34
|
+
"roles/cloudsql.serviceAgent",
|
35
|
+
"roles/containerregistry.ServiceAgent",
|
36
|
+
"roles/pubsub.serviceAgent",
|
37
|
+
"roles/firestore.serviceAgent",
|
38
|
+
"roles/iam.serviceAccountUser"
|
39
|
+
]
|
40
|
+
roles.each do |role|
|
41
|
+
add_service_account_role(service_account: service_account, role: role)
|
42
|
+
end
|
29
43
|
end
|
30
44
|
end
|
31
45
|
end
|
data/lib/souls/init.rb
CHANGED
@@ -16,7 +16,10 @@ module Souls
|
|
16
16
|
f.write(<<~TEXT)
|
17
17
|
Souls.configure do |config|
|
18
18
|
config.app = "#{app_name}"
|
19
|
+
config.project_id = "souls-api"
|
19
20
|
config.strain = "#{strain}"
|
21
|
+
config.worker_endpoint = "https://worker.com"
|
22
|
+
config.fixed_gems = ["excluded_gem"]
|
20
23
|
end
|
21
24
|
TEXT
|
22
25
|
end
|
@@ -24,33 +27,36 @@ module Souls
|
|
24
27
|
puts(e)
|
25
28
|
end
|
26
29
|
|
27
|
-
def self.download_souls(app_name: "souls",
|
28
|
-
|
29
|
-
|
30
|
-
system("
|
31
|
-
system("mkdir #{app_name}")
|
32
|
-
|
33
|
-
|
34
|
-
`rm -rf #{version}.tar.gz && rm -rf #{repository_name}-#{folder}`
|
30
|
+
def self.download_souls(app_name: "souls", service_name: "api")
|
31
|
+
latest_gem = Souls.get_latest_version(service_name: service_name)
|
32
|
+
file_name = latest_gem[:file_url].to_s.match(%r{/([^/]+)/?$})[1]
|
33
|
+
system("curl -OL #{latest_gem[:file_url]}")
|
34
|
+
system("mkdir -p #{app_name}/#{service_name}")
|
35
|
+
system("tar -zxvf ./#{file_name} -C #{app_name}/")
|
36
|
+
FileUtils.rm(file_name)
|
35
37
|
line = Paint["====================================", :yellow]
|
36
38
|
puts("\n")
|
37
39
|
puts(line)
|
38
|
-
|
40
|
+
txt2 = <<~TEXT
|
39
41
|
_____ ____ __ ____#{' '}
|
40
|
-
/ ___// __ \\/ / / / /
|
41
|
-
\\__ \\/ / / / / / / /
|
42
|
-
___/ / /_/ / /_/ / /___
|
43
|
-
/____/\\____/\\____/_____
|
42
|
+
/ ___// __ \\/ / / / / %{red1}
|
43
|
+
\\__ \\/ / / / / / / / %{red2}
|
44
|
+
___/ / /_/ / /_/ / /___%{red3}#{' '}
|
45
|
+
/____/\\____/\\____/_____%{red4}#{' '}
|
44
46
|
TEXT
|
45
|
-
|
46
|
-
|
47
|
+
red1 = ["_____", :red]
|
48
|
+
red2 = ["/ ___/", :red]
|
49
|
+
red3 = ["(__ )", :red]
|
50
|
+
red4 = ["/____/", :red]
|
51
|
+
ms = Paint % [txt2, :cyan, { red1: red1, red2: red2, red3: red3, red4: red4 }]
|
52
|
+
puts(ms)
|
47
53
|
puts(line)
|
48
54
|
welcome = Paint["Welcome to SOULs!", :white]
|
49
55
|
puts(welcome)
|
50
56
|
souls_ver = Paint["SOULs Version: #{Souls::VERSION}", :white]
|
51
57
|
puts(souls_ver)
|
52
58
|
puts(line)
|
53
|
-
cd = Paint["Easy to Run\n$ cd #{app_name}\n$ bundle\n$ souls s\nGo To : http://localhost:3000\n\nDoc: https://souls.elsoul.nl",
|
59
|
+
cd = Paint["Easy to Run\n$ cd #{app_name}/#{service_name}\n$ bundle\n$ souls s\nGo To : http://localhost:3000\n\nDoc: https://souls.elsoul.nl",
|
54
60
|
:white]
|
55
61
|
puts(cd)
|
56
62
|
puts(line)
|