souls 0.23.6 → 0.24.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/Gemfile.lock +1 -1
- data/README.md +55 -14
- data/config/souls.rb +7 -3
- data/exe/souls +23 -7
- data/lib/souls.rb +6 -3
- data/lib/souls/gcloud.rb +1 -0
- data/lib/souls/gcloud/compute.rb +62 -60
- data/lib/souls/gcloud/iam.rb +24 -22
- data/lib/souls/gcloud/pubsub.rb +21 -0
- data/lib/souls/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b052d6dae1a6c0847f3fcb32dc77bde6ea698c642f2e3e667bffb940e6e2ed54
|
4
|
+
data.tar.gz: 556817e4f1cd69a831a08d59e6498b8472351c786e6c9f97f489f03b8a29e3f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5240e15e169064d3bf6b91a91be906a996079bcf625211b51c10bc07aefde0d62830956a8a7a2ff1e2ba0012dad4453ad7240a3dd1439ea20eca585a69514038
|
7
|
+
data.tar.gz: 0641f3caf5426483944c66f77258bca8739f720e02b9451d33a04ab3e6bb5942bf12795c1d12a3a1fe460b2835fad732c5d8c27a8b650c7cf0a383cda210d5e1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -19,31 +19,40 @@
|
|
19
19
|
|
20
20
|
## What's SOULs?
|
21
21
|
|
22
|
-
Welcome to SOULs Framework!
|
22
|
+
Welcome to SOULs Serverless Application Framework!
|
23
23
|
|
24
|
-
SOULs is a Serverless Application Framework
|
25
|
-
|
24
|
+
SOULs is a Serverless Application Framework with GraphQL.
|
25
|
+
SOULs has six strains, API, Worker, Console, Admin, Media, Doc, and can be used in combination according to the purpose. SOULs Backend GraphQL Ruby & Frontend Relay are Scalable and Easy to deploy to Google Cloud. No more routing for Backends!
|
26
|
+
You can focus on your business logic. No more infra problems.
|
26
27
|
|
27
|
-
SOULs creates
|
28
|
+
SOULs creates 6 types of framework.
|
28
29
|
|
29
30
|
1. API - GraphQL (Ruby) - Simple API - Cloud Run
|
30
31
|
2. Worker - Google Pub/Sub Worker API (Ruby) - Cloud Run
|
31
|
-
3.
|
32
|
+
3. Console Web Client - User Console and CMS (TypeScript)
|
32
33
|
4. Admin Web Client - Admin Console and CMS (TypeScript)
|
34
|
+
5. Media Web Client - Media web client with SSG (TypeScript)
|
35
|
+
6. Doc Web Client - Doc web client with SSG (TypeScript)
|
33
36
|
|
34
37
|
## Dependency
|
35
38
|
|
36
39
|
- [Google SDK](https://cloud.google.com/sdk/docs)
|
37
40
|
- [Docker](https://www.docker.com/)
|
38
41
|
- [Firebase CLI](https://firebase.google.com/docs/cli)
|
42
|
+
- [Ruby](https://www.ruby-lang.org)
|
39
43
|
|
40
44
|
## Cloud Infrastructure
|
41
45
|
|
42
|
-
- [Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine)
|
43
|
-
- [Google Traffic Director](https://cloud.google.com/traffic-director)
|
44
46
|
- [Google Cloud Run](https://cloud.google.com/run)
|
47
|
+
- [Google Cloud SQL](https://cloud.google.com/sql)
|
48
|
+
- [Google Cloud Pub/Sub](https://cloud.google.com/pubsub)
|
49
|
+
- [Google Cloud Storage](https://cloud.google.com/run)
|
50
|
+
- [Google Cloud IAM](https://cloud.google.com/iam)
|
51
|
+
- [Google Cloud DNS](https://cloud.google.com/dns)
|
52
|
+
- [Google Cloud Container Registry](https://cloud.google.com/container-registry)
|
45
53
|
- [Google Firebase](https://firebase.google.com/)
|
46
54
|
- [Google Cloud Scheduler](https://cloud.google.com/scheduler)
|
55
|
+
- [Github Actions](https://github.com/features/actions)
|
47
56
|
|
48
57
|
## Installation
|
49
58
|
|
@@ -65,23 +74,55 @@ And Create Your APP
|
|
65
74
|
|
66
75
|
$ souls new app_name
|
67
76
|
|
68
|
-
|
77
|
+
## Choose SOULs Type:
|
69
78
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
79
|
+
Select Strain:
|
80
|
+
1. SOULs GraphQL API
|
81
|
+
2. SOULs Worker
|
82
|
+
3. SOULs Console Web
|
83
|
+
4. SOULs Admin Web
|
84
|
+
5. SOULs Media Web
|
85
|
+
6. SOULs Doc Web
|
74
86
|
|
75
87
|
|
76
|
-
##
|
88
|
+
## Gemfile 自動更新アップデート
|
77
89
|
|
90
|
+
`Gemfile`, `Gemfile.lock` を最新のバージョンに自動更新します。
|
91
|
+
|
92
|
+
```
|
93
|
+
souls gem:update
|
94
|
+
```
|
95
|
+
|
96
|
+
|
97
|
+
除外したい `gem` は `config/souls.rb` 内の
|
98
|
+
`config.fixed_gems` の配列に追加します。
|
99
|
+
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
Souls.configure do |config|
|
103
|
+
config.app = "souls-api"
|
104
|
+
config.project_id = "souls-api"
|
105
|
+
config.strain = "worker"
|
106
|
+
config.api_repo = "elsoul/souls_api"
|
107
|
+
config.worker_repo = "elsoul/souls_worker"
|
108
|
+
config.worker_endpoint = "https://worker.com"
|
109
|
+
config.fixed_gems = ["selenium-webdriver", "pg"]
|
110
|
+
end
|
111
|
+
```
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
## SOULs Serverless Application Framework Document
|
116
|
+
|
117
|
+
SOULs サーバーレスアプリケーションフレームワーク
|
118
|
+
ドキュメントはこちらから
|
78
119
|
- [SOULs Document](https://souls.elsoul.nl/)
|
79
120
|
|
80
121
|
|
81
122
|
|
82
123
|
## Development
|
83
124
|
|
84
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `
|
125
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `souls t` to run the tests. You can also run `souls c` for an interactive prompt that will allow you to experiment.
|
85
126
|
|
86
127
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org/gems/souls).
|
87
128
|
|
data/config/souls.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
Souls.configure do |config|
|
2
|
-
config.app = "souls-
|
3
|
-
config.project_id = "souls-
|
4
|
-
config.strain = "
|
2
|
+
config.app = "souls-api"
|
3
|
+
config.project_id = "souls-api"
|
4
|
+
config.strain = "worker"
|
5
|
+
config.api_repo = "elsoul/souls_api"
|
6
|
+
config.worker_repo = "elsoul/souls_worker"
|
7
|
+
config.worker_endpoint = "https://worker.com"
|
8
|
+
config.fixed_gems = []
|
5
9
|
end
|
data/exe/souls
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
souls_command = ARGV[0]
|
10
10
|
case souls_command
|
11
11
|
when "new"
|
12
|
-
STRAINS = %w[api worker console admin media].freeze
|
12
|
+
STRAINS = %w[api worker console admin media doc].freeze
|
13
13
|
app_name = ARGV[1]
|
14
14
|
if app_name.nil?
|
15
15
|
puts(Paint["you need to specify your app name", :red])
|
@@ -17,14 +17,15 @@ begin
|
|
17
17
|
exit
|
18
18
|
end
|
19
19
|
first_message = Paint % [
|
20
|
-
"Select Strain: %{red_text} %{yellow_text} %{green_text} %{blue_text} %{cyan_text}",
|
20
|
+
"Select Strain: %{red_text} %{yellow_text} %{green_text} %{blue_text} %{cyan_text} %{magenta_text}",
|
21
21
|
:white,
|
22
22
|
{
|
23
23
|
red_text: ["\n1. SOULs GraphQL API", :red],
|
24
|
-
yellow_text: ["\n2. SOULs Worker", :yellow],
|
24
|
+
yellow_text: ["\n2. SOULs Pub/Sub Worker", :yellow],
|
25
25
|
green_text: ["\n3. SOULs Console Web", :green],
|
26
26
|
blue_text: ["\n4. SOULs Admin Web", :blue],
|
27
|
-
cyan_text: ["\n5. SOULs Media Web", :cyan]
|
27
|
+
cyan_text: ["\n5. SOULs Media Web", :cyan],
|
28
|
+
magenta_text: ["\n6. SOULs Doc Web", :magenta]
|
28
29
|
}
|
29
30
|
]
|
30
31
|
puts(first_message)
|
@@ -39,7 +40,7 @@ begin
|
|
39
40
|
when "s", "server"
|
40
41
|
strain = Souls.configuration.strain
|
41
42
|
case strain
|
42
|
-
when "media", "admin", "console"
|
43
|
+
when "media", "admin", "console", "doc"
|
43
44
|
system("yarn dev")
|
44
45
|
when "worker"
|
45
46
|
system("bundle exec puma -p 3000 -e development")
|
@@ -49,7 +50,7 @@ begin
|
|
49
50
|
when "c", "console"
|
50
51
|
strain = Souls.configuration.strain
|
51
52
|
case strain
|
52
|
-
when "media", "admin"
|
53
|
+
when "media", "admin", "console", "doc"
|
53
54
|
system("yarn dev")
|
54
55
|
else
|
55
56
|
rack_env = ARGV[1]
|
@@ -68,7 +69,22 @@ begin
|
|
68
69
|
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
69
70
|
Whirly.status = status
|
70
71
|
send_method = ARGV[1]
|
71
|
-
|
72
|
+
|
73
|
+
case send_method
|
74
|
+
when "create_pubsub_topic"
|
75
|
+
topic_name = ARGV[2]
|
76
|
+
args = { topic_name: topic_name }
|
77
|
+
Souls::Gcloud.public_send(send_method, args)
|
78
|
+
when "create_pubsub_subscription"
|
79
|
+
project_id = Souls.configuration.project_id
|
80
|
+
topic_name = ARGV[2]
|
81
|
+
service_account = "#{Souls.configuration.app}@#{project_id}iam.gserviceaccount.com"
|
82
|
+
endpoint = Souls.configuration.endpoint
|
83
|
+
args = { project_id: project_id, topic_name: topic_name, service_account: service_account, endpoint: endpoint }
|
84
|
+
Souls::Gcloud.public_send(send_method, args)
|
85
|
+
else
|
86
|
+
Souls::Gcloud.public_send(send_method)
|
87
|
+
end
|
72
88
|
Whirly.status = "Done!"
|
73
89
|
end
|
74
90
|
when "-v", "--version"
|
data/lib/souls.rb
CHANGED
@@ -97,6 +97,7 @@ module Souls
|
|
97
97
|
url = URI("https://rubygems.org/api/v1/versions/#{gem[0]}/latest.json")
|
98
98
|
res = Net::HTTP.get_response(url)
|
99
99
|
data = JSON.parse(res.body)
|
100
|
+
next if Souls.configuration.fixed_gems.include?(gem[0].to_s)
|
100
101
|
next if data["version"].to_s == gem[1].to_s
|
101
102
|
|
102
103
|
updated_lines << if from_dev
|
@@ -185,14 +186,16 @@ module Souls
|
|
185
186
|
end
|
186
187
|
|
187
188
|
class Configuration
|
188
|
-
attr_accessor :app, :strain, :project_id, :
|
189
|
+
attr_accessor :app, :strain, :project_id, :worker_repo, :api_repo, :worker_endpoint, :fixed_gems
|
189
190
|
|
190
191
|
def initialize
|
191
192
|
@app = nil
|
192
193
|
@project_id = nil
|
193
194
|
@strain = nil
|
194
|
-
@
|
195
|
-
@
|
195
|
+
@worker_repo = nil
|
196
|
+
@api_repo = nil
|
197
|
+
@worker_endpoint = nil
|
198
|
+
@fixed_gems = nil
|
196
199
|
end
|
197
200
|
end
|
198
201
|
end
|
data/lib/souls/gcloud.rb
CHANGED
data/lib/souls/gcloud/compute.rb
CHANGED
@@ -1,71 +1,73 @@
|
|
1
1
|
module Souls
|
2
2
|
module Gcloud
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class << self
|
4
|
+
def auth_login
|
5
|
+
project_id = Souls.configuration.project_id
|
6
|
+
system("gcloud config set project #{project_id}")
|
7
|
+
system("gcloud auth login")
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
10
|
+
def enable_permissions
|
11
|
+
system("gcloud services enable compute.googleapis.com")
|
12
|
+
puts("Operating permission to compute.googleapis.com ...")
|
13
|
+
system("gcloud services enable iam.googleapis.com")
|
14
|
+
puts("Operating permission to iam.googleapis.com ...")
|
15
|
+
system("gcloud services enable dns.googleapis.com")
|
16
|
+
puts("Operating permission to dns.googleapis.com ...")
|
17
|
+
system("gcloud services enable sqladmin.googleapis.com")
|
18
|
+
puts("Operating permission to sqladmin.googleapis.com ...")
|
19
|
+
system("gcloud services enable sql-component.googleapis.com")
|
20
|
+
puts("Operating permission to sql-component.googleapis.com ...")
|
21
|
+
system("gcloud services enable servicenetworking.googleapis.com")
|
22
|
+
puts("Operating permission to servicenetworking.googleapis.com ...")
|
23
|
+
system("gcloud services enable containerregistry.googleapis.com")
|
24
|
+
puts("Operating permission to containerregistry.googleapis.com")
|
25
|
+
system("gcloud services enable run.googleapis.com")
|
26
|
+
puts("Operating permission to run.googleapis.com")
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
def create_network
|
30
|
+
return "Error: Please Set Souls.configuration" if Souls.configuration.app.nil?
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
network = Souls.configuration.app
|
33
|
+
system("gcloud compute networks create #{network}")
|
34
|
+
rescue StandardError => e
|
35
|
+
raise(StandardError, e)
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
def create_firewall(ip_range: "10.140.0.0/20")
|
39
|
+
network = Souls.configuration.app
|
40
|
+
system(
|
41
|
+
"gcloud compute firewall-rules create #{network}
|
42
|
+
--network #{network}
|
43
|
+
--allow tcp,udp,icmp
|
44
|
+
--source-ranges #{ip_range}"
|
45
|
+
)
|
46
|
+
system("gcloud compute firewall-rules create #{network}-ssh --network #{network} --allow tcp:22,tcp:3389,icmp")
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
49
|
+
def create_private_access
|
50
|
+
network = Souls.configuration.app
|
51
|
+
project_id = Souls.configuration.project_id
|
52
|
+
system(
|
53
|
+
"gcloud compute addresses create #{network}-my-network \
|
54
|
+
--global \
|
55
|
+
--purpose=VPC_PEERING \
|
56
|
+
--prefix-length=16 \
|
57
|
+
--description='peering range for SOULs' \
|
58
|
+
--network=#{network} \
|
59
|
+
--project=#{project_id}"
|
60
|
+
)
|
61
|
+
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
def create_sql_instance(root_pass: "Postgre123!", zone: "asia-northeast1-b")
|
64
|
+
app = "#{Souls.configuration.app}-db"
|
65
|
+
system(
|
66
|
+
"gcloud sql instances create #{app}
|
67
|
+
--database-version=POSTGRES_13 --cpu=2 --memory=7680MB --zone=#{zone}
|
68
|
+
--root-password='#{root_pass}' --database-flags cloudsql.iam_authentication=on"
|
69
|
+
)
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
data/lib/souls/gcloud/iam.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
module Souls
|
2
2
|
module Gcloud
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class << self
|
4
|
+
def create_service_account(service_account: "souls-app")
|
5
|
+
`gcloud iam service-accounts create #{service_account} \
|
6
|
+
--description="Souls Service Account" \
|
7
|
+
--display-name="#{service_account}"`
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def create_service_account_key(service_account: "souls-app")
|
11
|
+
project_id = Souls.configuration.project_id
|
12
|
+
`gcloud iam service-accounts keys create ./config/keyfile.json \
|
13
|
+
--iam-account #{service_account}@#{project_id}.iam.gserviceaccount.com`
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def add_service_account_role(service_account: "souls-app", role: "roles/firebase.admin")
|
17
|
+
project_id = Souls.configuration.project_id
|
18
|
+
`gcloud projects add-iam-policy-binding #{project_id} \
|
19
|
+
--member="serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com" \
|
20
|
+
--role="#{role}"`
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def add_permissions(service_account: "souls-app")
|
24
|
+
add_service_account_role(service_account: service_account, role: "roles/cloudsql.serviceAgent")
|
25
|
+
add_service_account_role(service_account: service_account, role: "roles/containerregistry.ServiceAgent")
|
26
|
+
add_service_account_role(service_account: service_account, role: "roles/pubsub.serviceAgent")
|
27
|
+
add_service_account_role(service_account: service_account, role: "roles/firestore.serviceAgent")
|
28
|
+
add_service_account_role(service_account: service_account, role: "roles/iam.serviceAccountUser")
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Souls
|
2
|
+
module Gcloud
|
3
|
+
class << self
|
4
|
+
def create_pubsub_topic(args)
|
5
|
+
system("gcloud pubsub topics create #{args[:topic_name]}")
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_pubsub_subscription(args)
|
9
|
+
system(
|
10
|
+
"gcloud pubsub subscriptions create #{args[:topic_name]}-sub \
|
11
|
+
--topic #{args[:topic_name]} \
|
12
|
+
--topic-project #{args[:project_id]} \
|
13
|
+
--push-auth-service-account #{args[:service_account]} \
|
14
|
+
--push-endpoint #{args[:endpoint]} \
|
15
|
+
--expiration-period never
|
16
|
+
"
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/souls/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.24.0
|
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-07-
|
13
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: paint
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/souls/gcloud.rb
|
76
76
|
- lib/souls/gcloud/compute.rb
|
77
77
|
- lib/souls/gcloud/iam.rb
|
78
|
+
- lib/souls/gcloud/pubsub.rb
|
78
79
|
- lib/souls/generate.rb
|
79
80
|
- lib/souls/generate/application.rb
|
80
81
|
- lib/souls/generate/connection.rb
|