souls 1.19.9 → 1.20.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/souls/app/graphql/souls_mutation.rb +19 -0
- data/lib/souls/app/graphql/souls_query.rb +5 -0
- data/lib/souls/cli/create/functions.rb +16 -3
- data/lib/souls/cli/create/templates/{functions_env_yaml.rb → functions/functions_env_yaml.rb} +0 -0
- data/lib/souls/cli/create/templates/{go → functions/go}/function.rb +0 -0
- data/lib/souls/cli/create/templates/{go → functions/go}/go.rb +0 -0
- data/lib/souls/cli/create/templates/{nodejs → functions/nodejs}/index.rb +0 -0
- data/lib/souls/cli/create/templates/{nodejs → functions/nodejs}/package.rb +0 -0
- data/lib/souls/cli/create/templates/{python → functions/python}/main.rb +0 -0
- data/lib/souls/cli/create/templates/{python → functions/python}/requirements.rb +0 -0
- data/lib/souls/cli/create/templates/{ruby → functions/ruby}/app.rb +0 -0
- data/lib/souls/cli/create/templates/{ruby → functions/ruby}/gemfile.rb +0 -0
- data/lib/souls/cli/gcloud/functions/index.rb +15 -2
- data/lib/souls/cli/gcloud/scheduler/index.rb +7 -8
- data/lib/souls/cli/gcloud/sql/index.rb +30 -8
- data/lib/souls/cli/release/release.rb +2 -0
- data/lib/souls/cli/sync/pubsub.rb +0 -1
- data/lib/souls/version.rb +1 -1
- data/lib/souls/versions/.souls_api_version +1 -1
- data/lib/souls/versions/.souls_worker_version +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0946f596e96e2c08ba61f98665d3fc2bf8c61a8663c4c2b67362b1403e6ab280'
|
4
|
+
data.tar.gz: 8b756a0ef09f8c69b1510efd87c3dc182e21dda316bbb171e1efaa8bc2e75611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 956e561c42dda0190e62098bc92e37c7ed9bf13f8e0a15202309d97dc59d8d2647f001b34bb750df56c62f2018a8ebc4c478c90fe56b51d8ff9bc2b3e2bc7556
|
7
|
+
data.tar.gz: 3ef473d0c5e2e3599039ae56bd4fd717795d50f63ce6fcbe7d356fd4e69b5aef1ec75d8bf48d65b0d3cccfedb976f520b84e94fbc103aa0f744870b5b00fecf4
|
@@ -1,5 +1,24 @@
|
|
1
1
|
module SOULs
|
2
2
|
class SOULsMutation < GraphQL::Schema::RelayClassicMutation
|
3
|
+
def self.post(url:, payload: {}, content_type: "application/json")
|
4
|
+
response = Faraday.post(url, payload.to_json, "Content-Type": content_type)
|
5
|
+
response.body
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.souls_worker_trigger(query_name:)
|
9
|
+
query_name = query_name.gsub("_", "-")
|
10
|
+
worker_name = FileUtils.pwd.split("/").last
|
11
|
+
topic_name = "souls-#{worker_name}-#{query_name}"
|
12
|
+
query = query_name.underscore.camelize(:lower)
|
13
|
+
query_string = souls_make_graphql_query(query: query)
|
14
|
+
case ENV["RACK_ENV"]
|
15
|
+
when "production"
|
16
|
+
souls_publish_pubsub_queue(topic_name: topic_name, message: query_string)
|
17
|
+
when "development"
|
18
|
+
puts(souls_post_to_dev(worker_name: worker_name, query_string: query_string))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
3
22
|
def self.souls_check_user_permissions(user, obj, method)
|
4
23
|
raise(StandardError, "Invalid or Missing Token") unless user
|
5
24
|
|
@@ -5,6 +5,11 @@ module SOULs
|
|
5
5
|
attr_accessor :schedule
|
6
6
|
end
|
7
7
|
|
8
|
+
def self.post(url:, payload: {}, content_type: "application/json")
|
9
|
+
response = Faraday.post(url, payload.to_json, "Content-Type": content_type)
|
10
|
+
response.body
|
11
|
+
end
|
12
|
+
|
8
13
|
def self.check_user_permissions(user, obj, method)
|
9
14
|
raise(StandardError, "Invalid or Missing Token") unless user
|
10
15
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative "./templates/functions_env_yaml"
|
1
|
+
require_relative "./templates/functions/functions_env_yaml"
|
2
2
|
|
3
|
-
Dir["#{SOULs::SOULS_PATH}/lib/souls/cli/create/templates/*/*.rb"].map do |f|
|
3
|
+
Dir["#{SOULs::SOULS_PATH}/lib/souls/cli/create/templates/functions/*/*.rb"].map do |f|
|
4
4
|
require f
|
5
5
|
end
|
6
6
|
|
@@ -47,6 +47,19 @@ module SOULs
|
|
47
47
|
SOULs::Painter.create_file(file_path)
|
48
48
|
end
|
49
49
|
create_env_yaml(file_dir: file_dir)
|
50
|
+
endroll = <<~TEXT
|
51
|
+
|
52
|
+
♤ Deploy Cloud Functions ♤
|
53
|
+
|
54
|
+
$ cd apps/cf-#{version_string}-#{function_name}
|
55
|
+
$ souls functions deploy
|
56
|
+
|
57
|
+
$ souls functions help
|
58
|
+
|
59
|
+
|
60
|
+
Doc: https://souls.elsoul.nl
|
61
|
+
TEXT
|
62
|
+
puts(Paint[endroll, :white])
|
50
63
|
end
|
51
64
|
|
52
65
|
private
|
@@ -62,7 +75,7 @@ module SOULs
|
|
62
75
|
end
|
63
76
|
|
64
77
|
def get_runtime_create_method(runtime:)
|
65
|
-
Dir["#{SOULs::SOULS_PATH}/lib/souls/cli/create/templates/#{runtime}/*"].map do |n|
|
78
|
+
Dir["#{SOULs::SOULS_PATH}/lib/souls/cli/create/templates/functions/#{runtime}/*"].map do |n|
|
66
79
|
n.split("/").last.gsub(".rb", "")
|
67
80
|
end
|
68
81
|
end
|
data/lib/souls/cli/create/templates/{functions_env_yaml.rb → functions/functions_env_yaml.rb}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -11,9 +11,22 @@ module SOULs
|
|
11
11
|
end
|
12
12
|
|
13
13
|
runtime = current_dir.match(/cf-(\D+\d+)-/)[1]
|
14
|
+
runtime_lang = current_dir.match(/^cf-(\D+)\d+-/)[1]
|
15
|
+
entry_point =
|
16
|
+
case runtime_lang
|
17
|
+
when "nodejs"
|
18
|
+
current_dir.underscore.camelize(:lower)
|
19
|
+
when "python"
|
20
|
+
current_dir.underscore
|
21
|
+
when "go"
|
22
|
+
current_dir.underscore.camelize
|
23
|
+
else
|
24
|
+
system("bundle install")
|
25
|
+
current_dir
|
26
|
+
end
|
14
27
|
system(
|
15
28
|
"
|
16
|
-
gcloud functions deploy #{current_dir} --project=#{project_id} \
|
29
|
+
gcloud functions deploy #{current_dir} --entry-point='#{entry_point}' --project=#{project_id} \
|
17
30
|
--runtime #{runtime} --trigger-http --allow-unauthenticated --env-vars-file .env.yaml
|
18
31
|
"
|
19
32
|
)
|
@@ -35,7 +48,7 @@ module SOULs
|
|
35
48
|
Dir.chdir(SOULs.get_mother_path.to_s) do
|
36
49
|
FileUtils.rm_rf("apps/#{name}")
|
37
50
|
end
|
38
|
-
SOULs::Painter.
|
51
|
+
SOULs::Painter.warning("Deleted #{name} functions!", "✨")
|
39
52
|
end
|
40
53
|
|
41
54
|
desc "url", "Get SOULs Functions URL"
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module SOULs
|
2
2
|
class CloudScheduler < Thor
|
3
|
-
desc "awake", "Set Ping Every 15min by Google Cloud Scheduler"
|
4
|
-
|
5
|
-
def awake
|
3
|
+
desc "awake [url]", "Set Ping Every 15min by Google Cloud Scheduler"
|
4
|
+
def awake(url)
|
6
5
|
app_name = SOULs.configuration.app
|
7
6
|
system(
|
8
7
|
"gcloud scheduler jobs create http #{app_name}-awake
|
9
|
-
--schedule '0,10,20,30,40,50 * * * *' --uri #{
|
8
|
+
--schedule '0,10,20,30,40,50 * * * *' --uri #{url} --http-method GET"
|
10
9
|
)
|
11
10
|
end
|
12
11
|
|
@@ -18,11 +17,11 @@ module SOULs
|
|
18
17
|
project_id = SOULs.configuration.project_id
|
19
18
|
|
20
19
|
schedules_list = current_schedules
|
21
|
-
worker_name = FileUtils.pwd.split("/").last
|
20
|
+
worker_name = FileUtils.pwd.split("/").last.underscore
|
22
21
|
Queries::BaseQuery.all_schedules.each do |k, v|
|
23
22
|
worker_name = FileUtils.pwd.split("/").last
|
24
|
-
job_name = "
|
25
|
-
topic = "
|
23
|
+
job_name = "souls-#{worker_name}-#{k.to_s.underscore}".to_sym
|
24
|
+
topic = "souls-#{worker_name}-#{k.to_s.underscore}"
|
26
25
|
message_body = "query { #{k.to_s.camelize(:lower)} { response }}"
|
27
26
|
|
28
27
|
if schedules_list.include?(job_name)
|
@@ -43,7 +42,7 @@ module SOULs
|
|
43
42
|
end
|
44
43
|
|
45
44
|
schedules_list.each do |k, _|
|
46
|
-
next unless k.match?(/^
|
45
|
+
next unless k.match?(/^souls-#{worker_name}/)
|
47
46
|
|
48
47
|
system("gcloud scheduler jobs delete #{k} -q >/dev/null 2>&1")
|
49
48
|
end
|
@@ -13,19 +13,41 @@ module SOULs
|
|
13
13
|
|
14
14
|
zone = "#{region}-b"
|
15
15
|
system("gcloud config set project #{project_id} >/dev/null 2>&1")
|
16
|
-
|
17
|
-
|
18
|
-
"gcloud sql instances create #{instance_name} \
|
16
|
+
system(
|
17
|
+
"gcloud sql instances create #{instance_name} \
|
19
18
|
--database-version=#{db_type} --cpu=1 --memory=4096MB --zone=#{zone} \
|
20
19
|
--root-password='#{password}' --database-flags cloudsql.iam_authentication=on"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
20
|
+
)
|
21
|
+
SOULs::Sql.new.env(password: password)
|
22
|
+
SOULs::Github.new.secret_set
|
23
|
+
SOULs::Painter.success("Cloud SQL #{instance_name} is successfully created! You can push to deploy!")
|
26
24
|
true
|
27
25
|
end
|
28
26
|
|
27
|
+
desc "stop", "Stop Cloud SQL Instance"
|
28
|
+
def stop
|
29
|
+
project_id = SOULs.configuration.project_id
|
30
|
+
instance_name = SOULs.configuration.instance_name
|
31
|
+
system("gcloud sql instances patch #{instance_name} --project=#{project_id} --activation-policy=NEVER")
|
32
|
+
SOULs::Painter.warning("Cloud SQL #{instance_name} is stopped!")
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "restart", "Restart Cloud SQL Instance"
|
36
|
+
def restart
|
37
|
+
project_id = SOULs.configuration.project_id
|
38
|
+
instance_name = SOULs.configuration.instance_name
|
39
|
+
system("gcloud sql instances restart #{instance_name} --project=#{project_id}")
|
40
|
+
SOULs::Painter.success("Cloud SQL #{instance_name} is restarted!")
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "delete", "Delete Cloud SQL Instance"
|
44
|
+
def delete
|
45
|
+
project_id = SOULs.configuration.project_id
|
46
|
+
instance_name = SOULs.configuration.instance_name
|
47
|
+
system("gcloud sql instances delete #{instance_name} --project=#{project_id}")
|
48
|
+
SOULs::Painter.warning("Cloud SQL #{instance_name} is deleted!", "✨")
|
49
|
+
end
|
50
|
+
|
29
51
|
desc "env", "Generate .env.production file to deploy"
|
30
52
|
def env(password: "Password")
|
31
53
|
require(SOULs.get_mother_path.to_s + "/config/souls")
|
@@ -5,6 +5,8 @@ module SOULs
|
|
5
5
|
desc "release", "Release Gem"
|
6
6
|
def release
|
7
7
|
SOULs::Painter.error("hey! It's Broken!") unless system("rspec")
|
8
|
+
FileUtils.rm("apps/api/Gemfile.lock") if File.exist?("apps/api/Gemfile.lock")
|
9
|
+
FileUtils.rm("apps/worker/Gemfile.lock") if File.exist?("apps/worker/Gemfile.lock")
|
8
10
|
|
9
11
|
system("gem install souls")
|
10
12
|
sleep(3)
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.20.3
|
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.20.3
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: souls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.20.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
8
8
|
- KishiTheMechanic
|
9
9
|
- James Neve
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-01-
|
13
|
+
date: 2022-01-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -190,15 +190,15 @@ files:
|
|
190
190
|
- lib/souls/cli/console/index.rb
|
191
191
|
- lib/souls/cli/create/functions.rb
|
192
192
|
- lib/souls/cli/create/index.rb
|
193
|
-
- lib/souls/cli/create/templates/functions_env_yaml.rb
|
194
|
-
- lib/souls/cli/create/templates/go/function.rb
|
195
|
-
- lib/souls/cli/create/templates/go/go.rb
|
196
|
-
- lib/souls/cli/create/templates/nodejs/index.rb
|
197
|
-
- lib/souls/cli/create/templates/nodejs/package.rb
|
198
|
-
- lib/souls/cli/create/templates/python/main.rb
|
199
|
-
- lib/souls/cli/create/templates/python/requirements.rb
|
200
|
-
- lib/souls/cli/create/templates/ruby/app.rb
|
201
|
-
- lib/souls/cli/create/templates/ruby/gemfile.rb
|
193
|
+
- lib/souls/cli/create/templates/functions/functions_env_yaml.rb
|
194
|
+
- lib/souls/cli/create/templates/functions/go/function.rb
|
195
|
+
- lib/souls/cli/create/templates/functions/go/go.rb
|
196
|
+
- lib/souls/cli/create/templates/functions/nodejs/index.rb
|
197
|
+
- lib/souls/cli/create/templates/functions/nodejs/package.rb
|
198
|
+
- lib/souls/cli/create/templates/functions/python/main.rb
|
199
|
+
- lib/souls/cli/create/templates/functions/python/requirements.rb
|
200
|
+
- lib/souls/cli/create/templates/functions/ruby/app.rb
|
201
|
+
- lib/souls/cli/create/templates/functions/ruby/gemfile.rb
|
202
202
|
- lib/souls/cli/db/create_migration.rb
|
203
203
|
- lib/souls/cli/db/create_migration_rbs.rb
|
204
204
|
- lib/souls/cli/db/index.rb
|
@@ -299,7 +299,7 @@ licenses:
|
|
299
299
|
- Apache-2.0
|
300
300
|
metadata:
|
301
301
|
rubygems_mfa_required: 'true'
|
302
|
-
post_install_message:
|
302
|
+
post_install_message:
|
303
303
|
rdoc_options: []
|
304
304
|
require_paths:
|
305
305
|
- lib
|
@@ -315,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
315
|
version: '0'
|
316
316
|
requirements: []
|
317
317
|
rubygems_version: 3.2.32
|
318
|
-
signing_key:
|
318
|
+
signing_key:
|
319
319
|
specification_version: 4
|
320
320
|
summary: Ruby Serverless Framework 'SOULs' | Ruby サーバーレスフレームワーク SOULs. Powered by
|
321
321
|
Ruby GraphQL, RBS/Steep, Active Record, RSpec, RuboCop, and Google Cloud.
|