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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9b239d8337484aa068e9a7746e248138dadafa12f7cdcdf04f715c896f94188
4
- data.tar.gz: a8edefdb6f72c353a76e99807b39ae60882860336bf6cb6fc9d4511bf4ba551f
3
+ metadata.gz: b052d6dae1a6c0847f3fcb32dc77bde6ea698c642f2e3e667bffb940e6e2ed54
4
+ data.tar.gz: 556817e4f1cd69a831a08d59e6498b8472351c786e6c9f97f489f03b8a29e3f9
5
5
  SHA512:
6
- metadata.gz: '09a772d76110044534c362babea22cabe480686806b6bd5505741b389f69bacdc86dcd72ebcf068e7be0e4c384df1f3218034aa36fac49f8890785be3f212498'
7
- data.tar.gz: 87caf77681a745b9a5d57e7e5532c2cfe7f15bc0b8d8198c1bbcbbd5d7c67eb208cbd82808ce1d062688ebdd87da691f0221fc8c68ecb5ee483237dde6bf1c08
6
+ metadata.gz: 5240e15e169064d3bf6b91a91be906a996079bcf625211b51c10bc07aefde0d62830956a8a7a2ff1e2ba0012dad4453ad7240a3dd1439ea20eca585a69514038
7
+ data.tar.gz: 0641f3caf5426483944c66f77258bca8739f720e02b9451d33a04ab3e6bb5942bf12795c1d12a3a1fe460b2835fad732c5d8c27a8b650c7cf0a383cda210d5e1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.23.6)
4
+ souls (0.23.9)
5
5
  paint (= 2.2.1)
6
6
  whirly (= 0.3.0)
7
7
 
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. SOULs has four strains, API, Worker, Console, Media, 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 and Amazon Web Services
25
- You can focus on business logic. No more infra problems.
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 4 types of framework.
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. Media Web Client - Media web client with SSG (TypeScript)
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
- ### Choose SOULs Type:
77
+ ## Choose SOULs Type:
69
78
 
70
- 1. API
71
- 2. Worker
72
- 3. Media Web
73
- 4. Admin Web
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
- ## SOULs Document
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 `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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-app"
3
- config.project_id = "souls-app"
4
- config.strain = "api"
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
- Souls::Gcloud.public_send(send_method)
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, :worker_name, :api_name
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
- @worker_name = nil
195
- @api_name = nil
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
@@ -1,5 +1,6 @@
1
1
  require_relative "./gcloud/compute"
2
2
  require_relative "./gcloud/iam"
3
+ require_relative "./gcloud/pubsub"
3
4
 
4
5
  module Souls
5
6
  module Gcloud
@@ -1,71 +1,73 @@
1
1
  module Souls
2
2
  module Gcloud
3
- def self.auth_login
4
- project_id = Souls.configuration.project_id
5
- system("gcloud config set project #{project_id}")
6
- system("gcloud auth login")
7
- end
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
- def self.enable_permissions
10
- system("gcloud services enable compute.googleapis.com")
11
- puts("Operating permission to compute.googleapis.com ...")
12
- system("gcloud services enable iam.googleapis.com")
13
- puts("Operating permission to iam.googleapis.com ...")
14
- system("gcloud services enable dns.googleapis.com")
15
- puts("Operating permission to dns.googleapis.com ...")
16
- system("gcloud services enable sqladmin.googleapis.com")
17
- puts("Operating permission to sqladmin.googleapis.com ...")
18
- system("gcloud services enable sql-component.googleapis.com")
19
- puts("Operating permission to sql-component.googleapis.com ...")
20
- system("gcloud services enable servicenetworking.googleapis.com")
21
- puts("Operating permission to servicenetworking.googleapis.com ...")
22
- system("gcloud services enable containerregistry.googleapis.com")
23
- puts("Operating permission to containerregistry.googleapis.com")
24
- system("gcloud services enable run.googleapis.com")
25
- puts("Operating permission to run.googleapis.com")
26
- end
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
- def self.create_network
29
- return "Error: Please Set Souls.configuration" if Souls.configuration.app.nil?
29
+ def create_network
30
+ return "Error: Please Set Souls.configuration" if Souls.configuration.app.nil?
30
31
 
31
- network = Souls.configuration.app
32
- system("gcloud compute networks create #{network}")
33
- rescue StandardError => e
34
- raise(StandardError, e)
35
- end
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
- def self.create_firewall(ip_range: "10.140.0.0/20")
38
- network = Souls.configuration.app
39
- system(
40
- "gcloud compute firewall-rules create #{network}
41
- --network #{network}
42
- --allow tcp,udp,icmp
43
- --source-ranges #{ip_range}"
44
- )
45
- system("gcloud compute firewall-rules create #{network}-ssh --network #{network} --allow tcp:22,tcp:3389,icmp")
46
- end
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
- def self.create_private_access
49
- network = Souls.configuration.app
50
- project_id = Souls.configuration.project_id
51
- system(
52
- "gcloud compute addresses create #{network}-my-network \
53
- --global \
54
- --purpose=VPC_PEERING \
55
- --prefix-length=16 \
56
- --description='peering range for SOULs' \
57
- --network=#{network} \
58
- --project=#{project_id}"
59
- )
60
- end
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
- def self.create_sql_instance(root_pass: "Postgre123!", zone: "asia-northeast1-b")
63
- app = "#{Souls.configuration.app}-db"
64
- system(
65
- "gcloud sql instances create #{app}
66
- --database-version=POSTGRES_13 --cpu=2 --memory=7680MB --zone=#{zone}
67
- --root-password='#{root_pass}' --database-flags cloudsql.iam_authentication=on"
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
@@ -1,30 +1,32 @@
1
1
  module Souls
2
2
  module Gcloud
3
- def self.create_service_account(service_account: "souls-app")
4
- `gcloud iam service-accounts create #{service_account} \
5
- --description="Souls Service Account" \
6
- --display-name="#{service_account}"`
7
- end
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
- def self.create_service_account_key(service_account: "souls-app")
10
- project_id = Souls.configuration.project_id
11
- `gcloud iam service-accounts keys create ./config/keyfile.json \
12
- --iam-account #{service_account}@#{project_id}.iam.gserviceaccount.com`
13
- end
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
- def self.add_service_account_role(service_account: "souls-app", role: "roles/firebase.admin")
16
- project_id = Souls.configuration.project_id
17
- `gcloud projects add-iam-policy-binding #{project_id} \
18
- --member="serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com" \
19
- --role="#{role}"`
20
- end
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
- def self.add_permissions(service_account: "souls-app")
23
- add_service_account_role(service_account: service_account, role: "roles/cloudsql.serviceAgent")
24
- add_service_account_role(service_account: service_account, role: "roles/containerregistry.ServiceAgent")
25
- add_service_account_role(service_account: service_account, role: "roles/pubsub.serviceAgent")
26
- add_service_account_role(service_account: service_account, role: "roles/firestore.serviceAgent")
27
- add_service_account_role(service_account: service_account, role: "roles/iam.serviceAccountUser")
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
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.23.6".freeze
2
+ VERSION = "0.24.0".freeze
3
3
  public_constant :VERSION
4
4
  end
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.23.6
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-14 00:00:00.000000000 Z
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