souls 0.51.2 → 0.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/exe/souls +4 -202
- data/lib/souls/api/generate/application.rb +97 -94
- data/lib/souls/api/generate/connection.rb +5 -4
- data/lib/souls/api/generate/edge.rb +5 -4
- data/lib/souls/api/generate/index.rb +0 -1
- data/lib/souls/api/generate/manager.rb +9 -7
- data/lib/souls/api/generate/model.rb +16 -18
- data/lib/souls/api/generate/mutation.rb +217 -218
- data/lib/souls/api/generate/policy.rb +5 -5
- data/lib/souls/api/generate/query.rb +51 -51
- data/lib/souls/api/generate/resolver.rb +115 -115
- data/lib/souls/api/generate/rspec_factory.rb +53 -53
- data/lib/souls/api/generate/rspec_model.rb +5 -5
- data/lib/souls/api/generate/rspec_mutation.rb +178 -178
- data/lib/souls/api/generate/rspec_policy.rb +5 -5
- data/lib/souls/api/generate/rspec_query.rb +111 -111
- data/lib/souls/api/generate/rspec_resolver.rb +163 -163
- data/lib/souls/api/generate/type.rb +66 -66
- data/lib/souls/api/index.rb +7 -4
- data/lib/souls/api/update/index.rb +15 -0
- data/lib/souls/api/update/mutation.rb +68 -64
- data/lib/souls/api/update/resolver.rb +59 -60
- data/lib/souls/api/update/rspec_factory.rb +40 -39
- data/lib/souls/api/update/rspec_mutation.rb +84 -83
- data/lib/souls/api/update/rspec_resolver.rb +70 -69
- data/lib/souls/api/update/type.rb +39 -38
- data/lib/souls/cli/console/index.rb +13 -1
- data/lib/souls/cli/create/index.rb +97 -93
- data/lib/souls/cli/db/index.rb +122 -1
- data/lib/souls/cli/docker/index.rb +30 -38
- data/lib/souls/cli/gcloud/compute/index.rb +100 -98
- data/lib/souls/cli/gcloud/iam/index.rb +84 -69
- data/lib/souls/cli/gcloud/index.rb +36 -35
- data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +40 -27
- data/lib/souls/cli/gcloud/pubsub/topics.rb +16 -10
- data/lib/souls/cli/gcloud/run/index.rb +23 -17
- data/lib/souls/cli/gcloud/sql/index.rb +66 -47
- data/lib/souls/cli/index.rb +3 -20
- data/lib/souls/cli/init/index.rb +140 -140
- data/lib/souls/cli/release/release.rb +106 -105
- data/lib/souls/cli/server/index.rb +12 -1
- data/lib/souls/cli/sync/conf.rb +39 -38
- data/lib/souls/cli/sync/model.rb +19 -20
- data/lib/souls/cli/sync/pubsub.rb +69 -70
- data/lib/souls/cli/upgrade/gemfile.rb +108 -0
- data/lib/souls/cli/upgrade/index.rb +1 -1
- data/lib/souls/cli.rb +57 -0
- data/lib/souls/index.rb +1 -5
- 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
- data/lib/souls/worker/generate/index.rb +1 -1
- data/lib/souls/worker/generate/job.rb +45 -0
- data/lib/souls/worker/generate/mailer.rb +38 -43
- data/lib/souls/worker/index.rb +3 -1
- data/lib/souls.rb +2 -0
- metadata +19 -5
- data/lib/souls/api/generate/migration.rb +0 -51
- data/lib/souls/cli/upgrade/gem_update.rb +0 -107
- data/lib/souls/worker/generate/mutation.rb +0 -44
@@ -1,37 +1,50 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
2
|
+
class Pubsub < Thor
|
3
|
+
desc "create_subscription", "Create Google Cloud PubSub Subscription"
|
4
|
+
method_option :topic_name,
|
5
|
+
default: "send-user-mailer",
|
6
|
+
aliases: "--topic_name",
|
7
|
+
desc: "Google Cloud Pubsub Topic Name"
|
8
|
+
method_option :endpoint,
|
9
|
+
default: "https:://test.com",
|
10
|
+
aliases: "--endpoint",
|
11
|
+
desc: "Google Cloud Pubsub Push Subscription Endpoint"
|
12
|
+
def create_subscription
|
13
|
+
project_id = Souls.configuration.project_id
|
14
|
+
service_account = "#{Souls.configuration.app}@#{project_id}.iam.gserviceaccount.com"
|
15
|
+
system(
|
16
|
+
"gcloud pubsub subscriptions create #{options[:topic_name]}-sub \
|
17
|
+
--topic #{options[:topic_name]} \
|
16
18
|
--topic-project #{project_id} \
|
17
19
|
--push-auth-service-account #{service_account} \
|
18
|
-
--push-endpoint #{endpoint} \
|
20
|
+
--push-endpoint #{options[:endpoint]} \
|
19
21
|
--expiration-period never
|
20
22
|
"
|
21
|
-
|
22
|
-
|
23
|
+
)
|
24
|
+
rescue Thor::Error => e
|
25
|
+
raise(Thor::Error, e)
|
26
|
+
end
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
desc "subscription_list", "Show Google Cloud Pubsub Subscription List"
|
29
|
+
def subscription_list
|
30
|
+
system("gcloud pubsub subscriptions list")
|
31
|
+
rescue Thor::Error => e
|
32
|
+
raise(Thor::Error, e)
|
33
|
+
end
|
27
34
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
desc "update_subscription", "Update Google Cloud Pubsub Subscription Endpoint"
|
36
|
+
method_option :topic_name,
|
37
|
+
default: "send-user-mailer",
|
38
|
+
aliases: "--topic_name",
|
39
|
+
desc: "Google Cloud Pubsub Topic Name"
|
40
|
+
method_option :endpoint,
|
41
|
+
default: "https:://test.com",
|
42
|
+
aliases: "--endpoint",
|
43
|
+
desc: "Google Cloud Pubsub Push Subscription Endpoint"
|
44
|
+
def update_subscription
|
45
|
+
system("gcloud pubsub subscriptions update #{options[:topic_name]}-sub --push-endpoint #{options[:endpoint]} ")
|
46
|
+
rescue Thor::Error => e
|
47
|
+
raise(Thor::Error, e)
|
35
48
|
end
|
36
49
|
end
|
37
50
|
end
|
@@ -1,15 +1,21 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
class Pubsub < Thor
|
3
|
+
desc "create_topic", "Create Google Cloud Pubsub Topic"
|
4
|
+
method_option :topic_name,
|
5
|
+
default: "send-user-mailer",
|
6
|
+
aliases: "--topic_name",
|
7
|
+
desc: "Google Cloud Pubsub Topic Name"
|
8
|
+
def create_topic
|
9
|
+
system("gcloud pubsub topics create #{options[:topic_name]}")
|
10
|
+
rescue Thor::Error => e
|
11
|
+
raise(Thor::Error, e)
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
14
|
+
desc "topic_list", "Show Google Cloud Topic List"
|
15
|
+
def topic_list
|
16
|
+
system("gcloud pubsub topics list")
|
17
|
+
rescue Thor::Error => e
|
18
|
+
raise(Thor::Error, e)
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
@@ -1,24 +1,30 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class CloudRun < Thor
|
3
|
+
desc "awake", "Set Ping Every 15min by Google Cloud Scheduler"
|
4
|
+
method_option :url, default: "https://souls.souls.nl", aliases: "--url", desc: "Set URL"
|
5
|
+
def awake
|
6
|
+
app_name = Souls.configuration.app
|
7
|
+
system(
|
8
|
+
"gcloud scheduler jobs create http #{app_name}-awake
|
9
9
|
--schedule '0,10,20,30,40,50 * * * *' --uri #{url} --http-method GET"
|
10
|
-
|
11
|
-
|
10
|
+
)
|
11
|
+
rescue Thor::Error => e
|
12
|
+
raise(Thor::Error, e)
|
13
|
+
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
desc "list", "Show Google Cloud Run List"
|
16
|
+
def list(project_id: "")
|
17
|
+
project_id = Souls.configuration.project_id if project_id.blank?
|
18
|
+
system("gcloud run services list --project #{project_id} --platform managed")
|
19
|
+
rescue Thor::Error => e
|
20
|
+
raise(Thor::Error, e)
|
21
|
+
end
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
desc "get_endpoint", "Show Worker's Endpoint"
|
24
|
+
def get_endpoint(worker_name: "")
|
25
|
+
`gcloud run services list | grep #{worker_name} | awk '{print $4}'`
|
26
|
+
rescue Thor::Error => e
|
27
|
+
raise(Thor::Error, e)
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -1,39 +1,52 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
class Sql < Thor
|
3
|
+
desc "create_instance", "Create Google Cloud SQL - PostgreSQL13"
|
4
|
+
method_option :region, default: "", aliases: "--region", desc: "Google Cloud Platform Region"
|
5
|
+
method_option :root_password, default: "", aliases: "--root-password", desc: "Set Cloud SQL Root Password"
|
6
|
+
def create_instance
|
7
|
+
instance_name = "#{Souls.configuration.app}-db" if instance_name.blank?
|
8
|
+
region = Souls.configuration.region if options[:region].blank?
|
9
|
+
zone = "#{region}-b"
|
10
|
+
system(
|
11
|
+
"gcloud sql instances create #{instance_name} \
|
11
12
|
--database-version=POSTGRES_13 --cpu=2 --memory=7680MB --zone=#{zone} \
|
12
|
-
--root-password='#{
|
13
|
-
|
14
|
-
|
13
|
+
--root-password='#{options[:root_password]}' --database-flags cloudsql.iam_authentication=on"
|
14
|
+
)
|
15
|
+
rescue Thor::Error => e
|
16
|
+
raise(Thor::Error, e)
|
17
|
+
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
desc "list", "Show Cloud SQL Instances List"
|
20
|
+
def list
|
21
|
+
system("gcloud sql instances list")
|
22
|
+
rescue Thor::Error => e
|
23
|
+
raise(Thor::Error, e)
|
24
|
+
end
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
desc "setup_private_ip", "Enable Private IP"
|
27
|
+
def setup_private_ip
|
28
|
+
create_ip_range
|
29
|
+
create_vpc_connector
|
30
|
+
assign_network
|
31
|
+
rescue Thor::Error => e
|
32
|
+
raise(Thor::Error, e)
|
33
|
+
end
|
25
34
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
35
|
+
desc "assign_network", "Assign Network"
|
36
|
+
def assign_network
|
37
|
+
app_name = Souls.configuration.app
|
38
|
+
instance_name = "#{Souls.configuration.app}-db"
|
39
|
+
project_id = Souls.configuration.project_id
|
40
|
+
system("gcloud beta sql instances patch #{instance_name} --project=#{project_id} --network=#{app_name}")
|
41
|
+
rescue Thor::Error => e
|
42
|
+
raise(Thor::Error, e)
|
43
|
+
end
|
32
44
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
45
|
+
desc "create_ip_range", "Create VPC Adress Range"
|
46
|
+
def create_ip_range
|
47
|
+
app_name = Souls.configuration.app
|
48
|
+
system(
|
49
|
+
"
|
37
50
|
gcloud compute addresses create #{app_name}-ip-range \
|
38
51
|
--global \
|
39
52
|
--purpose=VPC_PEERING \
|
@@ -41,37 +54,43 @@ module Souls
|
|
41
54
|
--description='peering range for SOULs' \
|
42
55
|
--network=#{app_name} \
|
43
56
|
--project=#{app_name}"
|
44
|
-
|
45
|
-
|
57
|
+
)
|
58
|
+
rescue Thor::Error => e
|
59
|
+
raise(Thor::Error, e)
|
60
|
+
end
|
46
61
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
62
|
+
desc "create_vpc_connector", "Create VPC-PEERING Connect"
|
63
|
+
def create_vpc_connector
|
64
|
+
app_name = Souls.configuration.app
|
65
|
+
system(
|
66
|
+
"
|
51
67
|
gcloud services vpc-peerings connect \
|
52
68
|
--service=servicenetworking.googleapis.com \
|
53
69
|
--ranges=#{app_name}-ip-range \
|
54
70
|
--network=#{app_name} \
|
55
71
|
--project=#{app_name}
|
56
72
|
"
|
57
|
-
|
58
|
-
|
73
|
+
)
|
74
|
+
rescue Thor::Error => e
|
75
|
+
raise(Thor::Error, e)
|
76
|
+
end
|
59
77
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
78
|
+
desc "assgin_ip", "Add Current Grobal IP to White List"
|
79
|
+
def assign_ip(instance_name: "", ip: "")
|
80
|
+
ip = `curl inet-ip.info` if ip.blank?
|
81
|
+
project_id = Souls.configuration.project_id
|
82
|
+
instance_name = "#{Souls.configuration.app}-db" if instance_name.blank?
|
83
|
+
system(
|
84
|
+
"
|
66
85
|
gcloud beta sql instances patch #{instance_name} \
|
67
86
|
--project=#{project_id} \
|
68
87
|
--assign-ip \
|
69
88
|
--authorized-networks=#{ip} \
|
70
89
|
--quiet
|
71
90
|
"
|
72
|
-
|
73
|
-
|
74
|
-
|
91
|
+
)
|
92
|
+
rescue Thor::Error => e
|
93
|
+
raise(Thor::Error, e)
|
75
94
|
end
|
76
95
|
end
|
77
96
|
end
|
data/lib/souls/cli/index.rb
CHANGED
@@ -1,30 +1,13 @@
|
|
1
|
+
require_relative "./console/index"
|
1
2
|
require_relative "./create/index"
|
3
|
+
require_relative "./db/index"
|
2
4
|
require_relative "./docker/index"
|
3
5
|
require_relative "./gcloud/index"
|
4
6
|
require_relative "./init/index"
|
5
7
|
require_relative "./release/index"
|
6
8
|
require_relative "./sync/index"
|
7
9
|
require_relative "./upgrade/index"
|
10
|
+
require_relative "./server/index"
|
8
11
|
|
9
12
|
module Souls
|
10
|
-
module Create
|
11
|
-
end
|
12
|
-
|
13
|
-
module Docker
|
14
|
-
end
|
15
|
-
|
16
|
-
module Gcloud
|
17
|
-
end
|
18
|
-
|
19
|
-
module Init
|
20
|
-
end
|
21
|
-
|
22
|
-
module Release
|
23
|
-
end
|
24
|
-
|
25
|
-
module Sync
|
26
|
-
end
|
27
|
-
|
28
|
-
module Upgrade
|
29
|
-
end
|
30
13
|
end
|
data/lib/souls/cli/init/index.rb
CHANGED
@@ -1,157 +1,157 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
)
|
10
|
-
data[0]["tag_name"]
|
2
|
+
class CLI < Thor
|
3
|
+
desc "new [APP_NAME]", "Create SOULs APP"
|
4
|
+
def new(app_name)
|
5
|
+
if app_name.nil?
|
6
|
+
puts(Paint["you need to specify your app name", :red])
|
7
|
+
puts(Paint["`souls new souls-app`", :yellow])
|
8
|
+
exit
|
11
9
|
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
system("echo '\nalias api=\'cd apps/api\'' >> ~/.#{rc}")
|
22
|
-
system("echo 'alias mother=\'...\'' >> ~/.#{rc}")
|
23
|
-
system("echo 'alias worker=\'cd apps/worker\'' >> ~/.#{rc}")
|
24
|
-
puts(Paint["run `source ~/.#{rc}` to reflect your .#{rc}", :yellow])
|
25
|
-
puts(Paint["You can move to mother/api/worker just type", :green])
|
26
|
-
puts(Paint["\nmother\n", :white])
|
27
|
-
puts(
|
28
|
-
Paint["to go back to mother dir from api/worker\n\nYou can also go to api/worker from mother dir by typing",
|
29
|
-
:green]
|
30
|
-
)
|
31
|
-
puts(Paint["\napi\n", :white])
|
32
|
-
puts(Paint["or\n", :green])
|
33
|
-
puts(Paint["worker", :white])
|
34
|
-
end
|
11
|
+
service_name = "api"
|
12
|
+
download_souls(app_name: app_name, service_name: service_name)
|
13
|
+
mother_config_init(app_name: app_name)
|
14
|
+
download_github_actions(app_name: app_name)
|
15
|
+
initial_config_init(app_name: app_name, service_name: service_name)
|
16
|
+
souls_api_credit(app_name: app_name, service_name: service_name)
|
17
|
+
end
|
35
18
|
|
36
|
-
|
37
|
-
config_dir = "./#{app_name}/apps/#{service_name}/config"
|
38
|
-
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
|
39
|
-
FileUtils.touch("#{config_dir}/souls.rb")
|
40
|
-
file_path = "#{config_dir}/souls.rb"
|
41
|
-
File.open(file_path, "w") do |f|
|
42
|
-
f.write(<<~TEXT)
|
43
|
-
Souls.configure do |config|
|
44
|
-
config.app = "#{app_name}"
|
45
|
-
config.project_id = "#{app_name}"
|
46
|
-
config.region = "asia-northeast1"
|
47
|
-
config.endpoint = "/endpoint"
|
48
|
-
config.strain = "api"
|
49
|
-
config.fixed_gems = ["spring"]
|
50
|
-
config.workers = []
|
51
|
-
end
|
52
|
-
TEXT
|
53
|
-
end
|
54
|
-
rescue StandardError => e
|
55
|
-
puts(e)
|
56
|
-
end
|
19
|
+
private
|
57
20
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
21
|
+
def get_version(repository_name: "souls_api")
|
22
|
+
data = JSON.parse(
|
23
|
+
`curl \
|
24
|
+
-H "Accept: application/vnd.github.v3+json" \
|
25
|
+
-s https://api.github.com/repos/elsoul/#{repository_name}/releases`
|
26
|
+
)
|
27
|
+
data[0]["tag_name"]
|
28
|
+
end
|
66
29
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
Souls.configure do |config|
|
75
|
-
config.app = "#{app_name}"
|
76
|
-
config.project_id = "#{app_name}"
|
77
|
-
config.region = "asia-northeast1"
|
78
|
-
config.endpoint = "/endpoint"
|
79
|
-
config.strain = "mother"
|
80
|
-
config.fixed_gems = ["spring"]
|
81
|
-
config.workers = []
|
82
|
-
end
|
83
|
-
TEXT
|
30
|
+
def generate_cd
|
31
|
+
shell = `echo $SHELL`.strip
|
32
|
+
rc =
|
33
|
+
if shell.include?("zsh")
|
34
|
+
"zshrc"
|
35
|
+
else
|
36
|
+
"bash"
|
84
37
|
end
|
85
|
-
|
86
|
-
|
38
|
+
system("echo '\nalias api=\'cd apps/api\'' >> ~/.#{rc}")
|
39
|
+
system("echo 'alias mother=\'...\'' >> ~/.#{rc}")
|
40
|
+
system("echo 'alias worker=\'cd apps/worker\'' >> ~/.#{rc}")
|
41
|
+
puts(Paint["run `source ~/.#{rc}` to reflect your .#{rc}", :yellow])
|
42
|
+
puts(Paint["You can move to mother/api/worker just type", :green])
|
43
|
+
puts(Paint["\nmother\n", :white])
|
44
|
+
puts(
|
45
|
+
Paint["to go back to mother dir from api/worker\n\nYou can also go to api/worker from mother dir by typing",
|
46
|
+
:green]
|
47
|
+
)
|
48
|
+
puts(Paint["\napi\n", :white])
|
49
|
+
puts(Paint["or\n", :green])
|
50
|
+
puts(Paint["worker", :white])
|
51
|
+
end
|
52
|
+
|
53
|
+
def initial_config_init(app_name: "souls", service_name: "api")
|
54
|
+
config_dir = "./#{app_name}/apps/#{service_name}/config"
|
55
|
+
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
|
56
|
+
FileUtils.touch("#{config_dir}/souls.rb")
|
57
|
+
file_path = "#{config_dir}/souls.rb"
|
58
|
+
File.open(file_path, "w") do |f|
|
59
|
+
f.write(<<~TEXT)
|
60
|
+
Souls.configure do |config|
|
61
|
+
config.app = "#{app_name}"
|
62
|
+
config.project_id = "#{app_name}"
|
63
|
+
config.region = "asia-northeast1"
|
64
|
+
config.endpoint = "/endpoint"
|
65
|
+
config.strain = "api"
|
66
|
+
config.fixed_gems = ["spring"]
|
67
|
+
config.workers = []
|
68
|
+
end
|
69
|
+
TEXT
|
87
70
|
end
|
71
|
+
rescue StandardError => e
|
72
|
+
puts(e)
|
73
|
+
end
|
88
74
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
75
|
+
def download_github_actions(app_name: "souls-app")
|
76
|
+
file_name = "github.tgz"
|
77
|
+
url = "https://storage.googleapis.com/souls-bucket/github_actions/github.tgz"
|
78
|
+
system("curl -OL #{url}")
|
79
|
+
FileUtils.mkdir_p("#{app_name}/github")
|
80
|
+
system("tar -zxvf ./#{file_name} -C #{app_name}/")
|
81
|
+
FileUtils.rm(file_name)
|
82
|
+
end
|
96
83
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
84
|
+
def mother_config_init(app_name: "souls-app")
|
85
|
+
config_dir = "./#{app_name}/config"
|
86
|
+
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
|
87
|
+
FileUtils.touch("#{config_dir}/souls.rb")
|
88
|
+
file_path = "#{config_dir}/souls.rb"
|
89
|
+
File.open(file_path, "w") do |f|
|
90
|
+
f.write(<<~TEXT)
|
91
|
+
Souls.configure do |config|
|
92
|
+
config.app = "#{app_name}"
|
93
|
+
config.project_id = "#{app_name}"
|
94
|
+
config.region = "asia-northeast1"
|
95
|
+
config.endpoint = "/endpoint"
|
96
|
+
config.strain = "mother"
|
97
|
+
config.fixed_gems = ["spring"]
|
98
|
+
config.workers = []
|
99
|
+
end
|
100
|
+
TEXT
|
103
101
|
end
|
102
|
+
rescue StandardError => e
|
103
|
+
puts(e)
|
104
|
+
end
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
106
|
+
def download_souls(app_name: "souls", service_name: "api")
|
107
|
+
version = Souls.get_latest_version_txt(service_name: service_name).join(".")
|
108
|
+
file_name = "#{service_name}-v#{version}.tgz"
|
109
|
+
url = "https://storage.googleapis.com/souls-bucket/boilerplates/#{service_name.pluralize}/#{file_name}"
|
110
|
+
system("curl -OL #{url}")
|
111
|
+
system("mkdir -p #{app_name}/apps/#{service_name}")
|
112
|
+
system("tar -zxvf ./#{file_name} -C #{app_name}/apps/")
|
113
|
+
system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/.rubocop.yml")
|
114
|
+
system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/Gemfile")
|
115
|
+
system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/Procfile.dev")
|
116
|
+
system("cd #{app_name} && curl -OL https://storage.googleapis.com/souls-bucket/boilerplates/Procfile")
|
117
|
+
FileUtils.rm(file_name)
|
118
|
+
end
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
120
|
+
def souls_api_credit(app_name: "souls", service_name: "api")
|
121
|
+
line = Paint["====================================", :yellow]
|
122
|
+
puts("\n")
|
123
|
+
puts(line)
|
124
|
+
txt2 = <<~TEXT
|
125
|
+
_____ ____ __ ____#{' '}
|
126
|
+
/ ___// __ \\/ / / / / %{red1}
|
127
|
+
\\__ \\/ / / / / / / / %{red2}
|
128
|
+
___/ / /_/ / /_/ / /___%{red3}#{' '}
|
129
|
+
/____/\\____/\\____/_____%{red4}#{' '}
|
130
|
+
TEXT
|
131
|
+
red1 = ["_____", :red]
|
132
|
+
red2 = ["/ ___/", :red]
|
133
|
+
red3 = ["(__ )", :red]
|
134
|
+
red4 = ["/____/", :red]
|
135
|
+
ms = Paint % [txt2, :cyan, { red1: red1, red2: red2, red3: red3, red4: red4 }]
|
136
|
+
puts(ms)
|
137
|
+
puts(line)
|
138
|
+
welcome = Paint["Welcome to SOULs!", :white]
|
139
|
+
puts(welcome)
|
140
|
+
souls_ver = Paint["SOULs Version: #{Souls::VERSION}", :white]
|
141
|
+
puts(souls_ver)
|
142
|
+
puts(line)
|
143
|
+
endroll = <<~TEXT
|
144
|
+
Easy to Run
|
145
|
+
$ cd #{app_name}/apps/#{service_name}
|
146
|
+
$ bundle
|
147
|
+
$ souls s
|
148
|
+
Go To : http://localhost:4000
|
148
149
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
end
|
150
|
+
Doc: https://souls.elsoul.nl
|
151
|
+
TEXT
|
152
|
+
cd = Paint[endroll, :white]
|
153
|
+
puts(cd)
|
154
|
+
puts(line)
|
155
155
|
end
|
156
156
|
end
|
157
157
|
end
|