souls 0.25.7 → 0.25.11

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: 39ab25820e905bd7de5599a2999c0626ae6e4fba3339422ace80dc2f73463dae
4
- data.tar.gz: '0114896c2677c6159a7f08e6e5f7ca3e018b3e0ecaa8a1cfb724c2eb9b14c67b'
3
+ metadata.gz: a221f361ce49b70801f14ae68c5fa7013031c9b198e20f24df08903ad865db02
4
+ data.tar.gz: bb493dae0b44d01adcd96675619bdba96d878ff3a4a5501ef0f080ab9c56d2aa
5
5
  SHA512:
6
- metadata.gz: 051ea023c447b555155bd7c1af5be6fdb6d31337d677f94658d816747735ddcc00491b30cdd45c4ee56f5cf5b254633bfae0b8d0fd9b18b92b0acdeab0fb6e7f
7
- data.tar.gz: 12bd68ddb00bee64da2667d3ec1592f4ef3ac4d6574c7045fac0b28c7fca3c2d058a62d26d59a5a10e0928fa7144ad05c614ec74e82ac69839479c57dc247e05
6
+ metadata.gz: ce44a5e5515c343cc6900c2e88510a0f9d09928dbd2296ba1415592a638c8ed01544a66c87c44c9fbd5ab87d70f4b48c086d56243caa309dce340e4dc24f7f94
7
+ data.tar.gz: 2a6ef85f8aba382f8a4246cebf6336b15445fec56c26389cd7f6ca2113b220db2f42b7de15971fae22a79bb61835f7491e7541d7a30a88a1ff60ebff31dded54
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,8 +78,8 @@ begin
93
78
  Whirly.status = "Done!"
94
79
  end
95
80
  when "release"
96
- system("gem uninstall -x --force")
97
81
  system("gem install souls")
82
+ sleep(3)
98
83
  current_souls_ver = Souls::VERSION.strip.split(".").map(&:to_i)
99
84
  prompt = TTY::Prompt.new
100
85
  choices = [
@@ -254,5 +239,4 @@ begin
254
239
  end
255
240
  rescue StandardError => e
256
241
  puts(Paint[e, :red])
257
- puts(e.backtrace)
258
242
  end
data/lib/souls.rb CHANGED
@@ -178,9 +178,11 @@ module Souls
178
178
  case current_dir_name
179
179
  when "souls"
180
180
  system("echo '#{new_ver}' > lib/souls/versions/.souls_#{service_name}_version")
181
+ system("echo '#{new_ver}' > apps/#{service_name}/.souls_#{service_name}_version")
181
182
  system("cd apps/ && tar -czf ../#{service_name}.tgz #{service_name}/ && cd ..")
182
183
  when "api", "worker", "console", "admin", "media"
183
184
  system("echo '#{new_ver}' > lib/souls/versions/.souls_#{service_name}_version")
185
+ system("echo '#{new_ver}' > .souls_#{service_name}_version")
184
186
  system("cd .. && tar -czf ../#{service_name}.tgz #{service_name}/ && cd #{service_name}")
185
187
  else
186
188
  raise(StandardError, "You are at wrong directory!")
@@ -258,11 +260,9 @@ module Souls
258
260
  git_status = `git status`
259
261
  result =
260
262
  %w[api worker].map do |service_name|
261
- if git_status.include?("apps/#{service_name}/")
262
- service_name
263
- else
264
- next
265
- end
263
+ next unless git_status.include?("apps/#{service_name}/")
264
+
265
+ service_name
266
266
  end
267
267
  result.compact
268
268
  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.7".freeze
2
+ VERSION = "0.25.11".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.4.10
1
+ 0.4.14
@@ -1 +1 @@
1
- 0.4.10
1
+ 0.4.14
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.7
4
+ version: 0.25.11
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,