souls 0.25.6 → 0.25.10

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: be5bcefe806cbd1e4c8bc1ab799454bd721b8c73f477ca1464ea4470e074f1e9
4
- data.tar.gz: '098151d1afa7977cdc6e40d94a0f17d94df41344c049026714107bf0e92eaf56'
3
+ metadata.gz: 6131ac7dbacce29869acdddcbf7f95fdeffd648e2bc05e91e24b506a97549c10
4
+ data.tar.gz: 60fabbac02cd1bb688c8304feb1889a7dd2c881dad20a3ed2fe59e092607a208
5
5
  SHA512:
6
- metadata.gz: b87697617500a30edb165939fce43d145e80629e3a79ce329fc07c72697d70638a7f7fa98c982cd378d5c6f423c890d9cdf717525e3e333c0b7cd1fa12db2e08
7
- data.tar.gz: 44772472fc8a50085cde7df9aaccdfa75aa15429e2903ba270bc820f2f0abaf392ba132a03ad037afe8a603e436ab7f1ae4a7f6533a9cf3f34b6fb9eb0690590
6
+ metadata.gz: 57e1edbcc388c5256dfebc4ce277ab29c63bb7c45e0369db616e33a1e8098933ae14bf410ab049dfb8aec72dc34c66107bb799c7845e6b2964976cd2b995bc7b
7
+ data.tar.gz: '019f27084234e886327fb84f431bd70fd0a0b3fa7616b5feccccb0b387c9f796c1c724bb816be8f1a314d1581f0e49db86b56c8d698155571c59d02cad1df64c'
data/exe/souls CHANGED
@@ -61,26 +61,11 @@ begin
61
61
  send_method = ARGV[1]
62
62
  Souls.public_send(send_method)
63
63
  when "gcloud"
64
+ args = ARGV
64
65
  status = Paint["Running Gcloud Commands...", :yellow]
65
66
  Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
66
67
  Whirly.status = status
67
- send_method = ARGV[1]
68
-
69
- case send_method
70
- when "create_pubsub_topic"
71
- topic_name = ARGV[2]
72
- args = { topic_name: topic_name }
73
- Souls::Gcloud.public_send(send_method, args)
74
- when "create_pubsub_subscription"
75
- project_id = Souls.configuration.project_id
76
- topic_name = ARGV[2]
77
- service_account = "#{Souls.configuration.app}@#{project_id}iam.gserviceaccount.com"
78
- endpoint = Souls.configuration.endpoint
79
- args = { project_id: project_id, topic_name: topic_name, service_account: service_account, endpoint: endpoint }
80
- Souls::Gcloud.public_send(send_method, args)
81
- else
82
- Souls::Gcloud.public_send(send_method)
83
- end
68
+ Souls::Gcloud.return_method(args)
84
69
  Whirly.status = "Done!"
85
70
  end
86
71
  when "-v", "--version"
@@ -93,7 +78,10 @@ begin
93
78
  Whirly.status = "Done!"
94
79
  end
95
80
  when "release"
81
+ `gem uninstall -x --force`
82
+ sleep(1)
96
83
  system("gem install souls")
84
+ sleep(3)
97
85
  current_souls_ver = Souls::VERSION.strip.split(".").map(&:to_i)
98
86
  prompt = TTY::Prompt.new
99
87
  choices = [
@@ -253,5 +241,4 @@ begin
253
241
  end
254
242
  rescue StandardError => e
255
243
  puts(Paint[e, :red])
256
- puts(e.backtrace)
257
244
  end
data/lib/souls.rb CHANGED
@@ -181,6 +181,7 @@ module Souls
181
181
  system("cd apps/ && tar -czf ../#{service_name}.tgz #{service_name}/ && cd ..")
182
182
  when "api", "worker", "console", "admin", "media"
183
183
  system("echo '#{new_ver}' > lib/souls/versions/.souls_#{service_name}_version")
184
+ system("echo '#{new_ver}' > .souls_#{service_name}_version")
184
185
  system("cd .. && tar -czf ../#{service_name}.tgz #{service_name}/ && cd #{service_name}")
185
186
  else
186
187
  raise(StandardError, "You are at wrong directory!")
@@ -258,11 +259,9 @@ module Souls
258
259
  git_status = `git status`
259
260
  result =
260
261
  %w[api worker].map do |service_name|
261
- if git_status.include?("apps/#{service_name}/")
262
- service_name
263
- else
264
- next
265
- end
262
+ next unless git_status.include?("apps/#{service_name}/")
263
+
264
+ service_name
266
265
  end
267
266
  result.compact
268
267
  end
data/lib/souls/gcloud.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative "./gcloud/compute"
2
2
  require_relative "./gcloud/iam"
3
3
  require_relative "./gcloud/pubsub"
4
+ require_relative "./gcloud/methods"
4
5
 
5
6
  module Souls
6
7
  module Gcloud
@@ -1,8 +1,7 @@
1
1
  module Souls
2
2
  module Gcloud
3
3
  class << self
4
- def auth_login
5
- project_id = Souls.configuration.project_id
4
+ def auth_login(project_id: "souls-app")
6
5
  system("gcloud config set project #{project_id}")
7
6
  system("gcloud auth login")
8
7
  end
@@ -26,44 +25,9 @@ module Souls
26
25
  puts("Operating permission to run.googleapis.com")
27
26
  end
28
27
 
29
- def create_network
30
- return "Error: Please Set Souls.configuration" if Souls.configuration.app.nil?
31
-
32
- network = Souls.configuration.app
33
- system("gcloud compute networks create #{network}")
34
- rescue StandardError => e
35
- raise(StandardError, e)
36
- end
37
-
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
48
-
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
62
-
63
- def create_sql_instance(root_pass: "Postgre123!", zone: "asia-northeast1-b")
64
- app = "#{Souls.configuration.app}-db"
28
+ def create_sql_instance(instance_name: "souls-db", root_pass: "Postgre123!", zone: "asia-northeast1-b")
65
29
  system(
66
- "gcloud sql instances create #{app}
30
+ "gcloud sql instances create #{instance_name}
67
31
  --database-version=POSTGRES_13 --cpu=2 --memory=7680MB --zone=#{zone}
68
32
  --root-password='#{root_pass}' --database-flags cloudsql.iam_authentication=on"
69
33
  )
@@ -1,8 +1,7 @@
1
1
  module Souls
2
2
  module Gcloud
3
3
  class << self
4
- def create_service_account(args)
5
- service_account = args[:service_account] || "souls-app"
4
+ def create_service_account(service_account: "souls-app")
6
5
  system(
7
6
  "gcloud iam service-accounts create #{service_account} \
8
7
  --description='Souls Service Account' \
@@ -10,26 +9,22 @@ module Souls
10
9
  )
11
10
  end
12
11
 
13
- def create_service_account_key(args)
14
- service_account = args[:service_account] || "souls-app"
15
- project_id = args[:project_id] || "souls-app"
12
+ def create_service_account_key(service_account: "souls-app", project_id: "souls-app")
16
13
  system(
17
14
  "gcloud iam service-accounts keys create ./config/keyfile.json \
18
15
  --iam-account #{service_account}@#{project_id}.iam.gserviceaccount.com"
19
16
  )
20
17
  end
21
18
 
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"
26
- `gcloud projects add-iam-policy-binding #{project_id} \
27
- --member="serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com" \
28
- --role="#{role}"`
19
+ def add_service_account_role(service_account: "souls-app", project_id: "souls-app", role: "roles/firebase.admin")
20
+ system(
21
+ "gcloud projects add-iam-policy-binding #{project_id} \
22
+ --member='serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com' \
23
+ --role=#{role}"
24
+ )
29
25
  end
30
26
 
31
- def add_permissions(args)
32
- service_account = args[:service_account] || "souls-app"
27
+ def add_permissions(service_account: "souls-app")
33
28
  roles = [
34
29
  "roles/cloudsql.serviceAgent",
35
30
  "roles/containerregistry.ServiceAgent",
@@ -0,0 +1,52 @@
1
+ module Souls
2
+ module Gcloud
3
+ class << self
4
+ def return_method(args)
5
+ method = args[1]
6
+ case method
7
+ when "auth_login"
8
+ project_id = Souls.configuration.project_id
9
+ Souls::Gcloud.auth_login(project_id: project_id)
10
+ when "enable_permissions"
11
+ Souls::Gcloud.enable_permissions
12
+ when "create_pubsub_topic"
13
+ topic_name = args[2] || "send-user-mail"
14
+ Souls::Gcloud.create_pubsub_topic(topic_name: topic_name)
15
+ when "create_pubsub_subscription"
16
+ project_id = Souls.configuration.project_id
17
+ topic_name = args[2] || "send-user-mail"
18
+ service_account = "#{Souls.configuration.app}@#{project_id}.iam.gserviceaccount.com"
19
+ endpoint = Souls.configuration.worker_endpoint
20
+ Souls::Gcloud.create_pubsub_subscription(
21
+ topic_name: topic_name,
22
+ project_id: project_id,
23
+ service_account: service_account,
24
+ endpoint: endpoint
25
+ )
26
+ when "create_sql_instance"
27
+ instance_name = "#{Souls.configuration.app}-db"
28
+ root_pass = args[2] || "password"
29
+ zone = args[3] || "asia-northeast1-b"
30
+ Souls::Gcloud.create_sql_instance(instance_name: instance_name, root_pass: root_pass, zone: zone)
31
+ when "create_service_account"
32
+ service_account = Souls.configuration.app
33
+ Souls::Gcloud.create_service_account(service_account: service_account)
34
+ when "create_service_account_key"
35
+ service_account = Souls.configuration.app
36
+ project_id = Souls.configuration.project_id
37
+ Souls::Gcloud.create_service_account_key(service_account: service_account, project_id: project_id)
38
+ when "add_service_account_role"
39
+ service_account = Souls.configuration.app
40
+ project_id = Souls.configuration.project_id
41
+ role = args[2] || "roles/firebase.admin"
42
+ Souls::Gcloud.add_service_account_role(service_account: service_account, project_id: project_id, role: role)
43
+ when "add_permissions"
44
+ service_account = Souls.configuration.app
45
+ Souls::Gcloud.add_permissions(service_account: service_account)
46
+ else
47
+ raise(StandardError, "Wrong Method!")
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,17 +1,22 @@
1
1
  module Souls
2
2
  module Gcloud
3
3
  class << self
4
- def create_pubsub_topic(args)
5
- system("gcloud pubsub topics create #{args[:topic_name]}")
4
+ def create_pubsub_topic(topic_name: "send-user-mail")
5
+ system("gcloud pubsub topics create #{topic_name}")
6
6
  end
7
7
 
8
- def create_pubsub_subscription(args)
8
+ def create_pubsub_subscription(
9
+ topic_name: "send-user-mail",
10
+ project_id: "souls-app",
11
+ service_account: "souls-app",
12
+ endpoint: "https:://test.com"
13
+ )
9
14
  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
+ "gcloud pubsub subscriptions create #{topic_name}-sub \
16
+ --topic #{topic_name} \
17
+ --topic-project #{project_id} \
18
+ --push-auth-service-account #{service_account} \
19
+ --push-endpoint #{endpoint} \
15
20
  --expiration-period never
16
21
  "
17
22
  )
@@ -136,7 +136,7 @@ module Souls
136
136
  def self.resolver(class_name: "souls")
137
137
  singularized_class_name = class_name.singularize.underscore
138
138
  file_path = "./app/graphql/resolvers/#{singularized_class_name}_search.rb"
139
- return "Resolver already exist! #{file_path}" if File.exist?(file_path)
139
+ raise(StandardError, "Resolver already exist! #{file_path}") if File.exist?(file_path)
140
140
 
141
141
  resolver_head(class_name: singularized_class_name)
142
142
  resolver_params(class_name: singularized_class_name)
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.25.6".freeze
2
+ VERSION = "0.25.10".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.4.9
1
+ 0.4.13
@@ -1 +1 @@
1
- 0.4.9
1
+ 0.4.13
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.25.6
4
+ version: 0.25.10
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-22 00:00:00.000000000 Z
13
+ date: 2021-07-27 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/methods.rb
78
79
  - lib/souls/gcloud/pubsub.rb
79
80
  - lib/souls/generate.rb
80
81
  - lib/souls/generate/application.rb
@@ -118,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  - !ruby/object:Gem::Version
119
120
  version: '0'
120
121
  requirements: []
121
- rubygems_version: 3.2.15
122
+ rubygems_version: 3.2.22
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: SOULs is a Serverless Application Framework. SOULs has four strains, API,