souls 0.51.1 → 0.52.2

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -1
  3. data/exe/souls +3 -200
  4. data/lib/souls/api/generate/application.rb +97 -94
  5. data/lib/souls/api/generate/connection.rb +5 -4
  6. data/lib/souls/api/generate/edge.rb +5 -4
  7. data/lib/souls/api/generate/index.rb +0 -1
  8. data/lib/souls/api/generate/manager.rb +9 -7
  9. data/lib/souls/api/generate/model.rb +16 -18
  10. data/lib/souls/api/generate/mutation.rb +217 -218
  11. data/lib/souls/api/generate/policy.rb +5 -5
  12. data/lib/souls/api/generate/query.rb +51 -51
  13. data/lib/souls/api/generate/resolver.rb +115 -115
  14. data/lib/souls/api/generate/rspec_factory.rb +53 -53
  15. data/lib/souls/api/generate/rspec_model.rb +5 -5
  16. data/lib/souls/api/generate/rspec_mutation.rb +178 -178
  17. data/lib/souls/api/generate/rspec_policy.rb +5 -5
  18. data/lib/souls/api/generate/rspec_query.rb +111 -111
  19. data/lib/souls/api/generate/rspec_resolver.rb +163 -163
  20. data/lib/souls/api/generate/type.rb +66 -66
  21. data/lib/souls/api/index.rb +7 -4
  22. data/lib/souls/api/update/index.rb +15 -0
  23. data/lib/souls/api/update/mutation.rb +68 -64
  24. data/lib/souls/api/update/resolver.rb +59 -60
  25. data/lib/souls/api/update/rspec_factory.rb +40 -39
  26. data/lib/souls/api/update/rspec_mutation.rb +84 -83
  27. data/lib/souls/api/update/rspec_resolver.rb +70 -69
  28. data/lib/souls/api/update/type.rb +39 -38
  29. data/lib/souls/cli/console/index.rb +13 -1
  30. data/lib/souls/cli/create/index.rb +98 -94
  31. data/lib/souls/cli/db/index.rb +122 -1
  32. data/lib/souls/cli/docker/index.rb +30 -38
  33. data/lib/souls/cli/gcloud/compute/index.rb +100 -98
  34. data/lib/souls/cli/gcloud/iam/index.rb +84 -69
  35. data/lib/souls/cli/gcloud/index.rb +36 -35
  36. data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +40 -27
  37. data/lib/souls/cli/gcloud/pubsub/topics.rb +16 -10
  38. data/lib/souls/cli/gcloud/run/index.rb +23 -17
  39. data/lib/souls/cli/gcloud/sql/index.rb +66 -47
  40. data/lib/souls/cli/index.rb +3 -20
  41. data/lib/souls/cli/init/index.rb +140 -140
  42. data/lib/souls/cli/release/release.rb +106 -105
  43. data/lib/souls/cli/server/index.rb +12 -1
  44. data/lib/souls/cli/sync/conf.rb +39 -38
  45. data/lib/souls/cli/sync/model.rb +19 -20
  46. data/lib/souls/cli/sync/pubsub.rb +69 -70
  47. data/lib/souls/cli/upgrade/gemfile.rb +108 -0
  48. data/lib/souls/cli/upgrade/index.rb +1 -1
  49. data/lib/souls/cli.rb +57 -0
  50. data/lib/souls/index.rb +1 -5
  51. data/lib/souls/version.rb +1 -1
  52. data/lib/souls/versions/.souls_api_version +1 -1
  53. data/lib/souls/versions/.souls_worker_version +1 -1
  54. data/lib/souls/worker/generate/index.rb +1 -1
  55. data/lib/souls/worker/generate/job.rb +45 -0
  56. data/lib/souls/worker/generate/mailer.rb +38 -43
  57. data/lib/souls/worker/index.rb +3 -1
  58. data/lib/souls.rb +2 -0
  59. metadata +19 -5
  60. data/lib/souls/api/generate/migration.rb +0 -51
  61. data/lib/souls/cli/upgrade/gem_update.rb +0 -107
  62. data/lib/souls/worker/generate/mutation.rb +0 -44
@@ -1,125 +1,127 @@
1
1
  module Souls
2
- module Gcloud
3
- module Compute
4
- class << self
5
- def setup_vpc_nat(range: "10.124.0.0/28")
6
- create_network
7
- create_firewall_tcp(range: range)
8
- create_firewall_ssh
9
- create_subnet(range: range)
10
- create_connector
11
- create_router
12
- create_external_ip
13
- create_nat
14
- nat_credit
15
- end
2
+ class Compute < Thor
3
+ desc "setup_vpc_nat", "Set Up VPC Cloud Nat"
4
+ method_option :range, default: "10.124.0.0/28", aliases: "--range", desc: "GCP VPC Network IP Range"
5
+ def setup_vpc_nat
6
+ create_network
7
+ create_firewall_tcp(range: options[:range])
8
+ create_firewall_ssh
9
+ create_subnet(range: options[:range])
10
+ create_connector
11
+ create_router
12
+ create_external_ip
13
+ create_nat
14
+ nat_credit
15
+ rescue Thor::Error => e
16
+ raise(Thor::Error, e)
17
+ end
18
+
19
+ private
16
20
 
17
- def create_network
18
- app_name = Souls.configuration.app
19
- system("gcloud compute networks create #{app_name}")
20
- end
21
+ def create_network
22
+ app_name = Souls.configuration.app
23
+ system("gcloud compute networks create #{app_name}")
24
+ end
21
25
 
22
- def create_firewall_tcp(range: "10.124.0.0/28")
23
- app_name = Souls.configuration.app
24
- system(
25
- "gcloud compute firewall-rules create #{app_name} \
26
+ def create_firewall_tcp(range: "10.124.0.0/28")
27
+ app_name = Souls.configuration.app
28
+ system(
29
+ "gcloud compute firewall-rules create #{app_name} \
26
30
  --network #{app_name} --allow tcp,udp,icmp --source-ranges #{range}"
27
- )
28
- end
31
+ )
32
+ end
29
33
 
30
- def create_firewall_ssh
31
- app_name = Souls.configuration.app
32
- system(
33
- "gcloud compute firewall-rules create #{app_name}-ssh --network #{app_name} \
34
+ def create_firewall_ssh
35
+ app_name = Souls.configuration.app
36
+ system(
37
+ "gcloud compute firewall-rules create #{app_name}-ssh --network #{app_name} \
34
38
  --allow tcp:22,tcp:3389,icmp"
35
- )
36
- end
39
+ )
40
+ end
37
41
 
38
- def create_subnet(range: "10.124.0.0/28")
39
- app_name = Souls.configuration.app
40
- region = Souls.configuration.region
41
- system(
42
- "gcloud compute networks subnets create #{app_name}-subnet \
42
+ def create_subnet(range: "10.124.0.0/28")
43
+ app_name = Souls.configuration.app
44
+ region = Souls.configuration.region
45
+ system(
46
+ "gcloud compute networks subnets create #{app_name}-subnet \
43
47
  --range=#{range} --network=#{app_name} --region=#{region}"
44
- )
45
- end
48
+ )
49
+ end
46
50
 
47
- def create_connector
48
- app_name = Souls.configuration.app
49
- project_id = Souls.configuration.project_id
50
- region = Souls.configuration.region
51
- system(
52
- "gcloud compute networks vpc-access connectors create #{app_name}-connector \
51
+ def create_connector
52
+ app_name = Souls.configuration.app
53
+ project_id = Souls.configuration.project_id
54
+ region = Souls.configuration.region
55
+ system(
56
+ "gcloud compute networks vpc-access connectors create #{app_name}-connector \
53
57
  --region=#{region} \
54
58
  --subnet-project=#{project_id} \
55
59
  --subnet=#{app_name}-subnet"
56
- )
57
- end
60
+ )
61
+ end
58
62
 
59
- def create_router
60
- app_name = Souls.configuration.app
61
- region = Souls.configuration.region
62
- system("gcloud compute routers create #{app_name}-router --network=#{app_name} --region=#{region}")
63
- end
63
+ def create_router
64
+ app_name = Souls.configuration.app
65
+ region = Souls.configuration.region
66
+ system("gcloud compute routers create #{app_name}-router --network=#{app_name} --region=#{region}")
67
+ end
64
68
 
65
- def create_external_ip
66
- app_name = Souls.configuration.app
67
- region = Souls.configuration.region
68
- system("gcloud compute addresses create #{app_name}-worker-ip --region=#{region}")
69
- end
69
+ def create_external_ip
70
+ app_name = Souls.configuration.app
71
+ region = Souls.configuration.region
72
+ system("gcloud compute addresses create #{app_name}-worker-ip --region=#{region}")
73
+ end
70
74
 
71
- def create_nat
72
- app_name = Souls.configuration.app
73
- region = Souls.configuration.region
74
- system(
75
- "gcloud compute routers nats create #{app_name}-worker-nat \
75
+ def create_nat
76
+ app_name = Souls.configuration.app
77
+ region = Souls.configuration.region
78
+ system(
79
+ "gcloud compute routers nats create #{app_name}-worker-nat \
76
80
  --router=#{app_name}-router \
77
81
  --region=#{region} \
78
82
  --nat-custom-subnet-ip-ranges=#{app_name}-subnet \
79
83
  --nat-external-ip-pool=#{app_name}-worker-ip"
80
- )
81
- end
84
+ )
85
+ end
82
86
 
83
- def network_list
84
- system("gcloud compute network list")
85
- end
87
+ def network_list
88
+ system("gcloud compute network list")
89
+ end
86
90
 
87
- def nat_credit
88
- app_name = Souls.configuration.app
89
- line = Paint["====================================", :yellow]
90
- puts("\n")
91
- puts(line)
92
- txt2 = <<~TEXT
93
- _____ ____ __ ____#{' '}
94
- / ___// __ \\/ / / / / %{red1}
95
- \\__ \\/ / / / / / / / %{red2}
96
- ___/ / /_/ / /_/ / /___%{red3}#{' '}
97
- /____/\\____/\\____/_____%{red4}#{' '}
98
- TEXT
99
- red1 = ["_____", :red]
100
- red2 = ["/ ___/", :red]
101
- red3 = ["(__ )", :red]
102
- red4 = ["/____/", :red]
103
- ms = Paint % [txt2, :cyan, { red1: red1, red2: red2, red3: red3, red4: red4 }]
104
- puts(ms)
105
- puts(line)
106
- welcome = Paint["VPC Network is All Set!", :white]
107
- puts(welcome)
108
- puts(line)
109
- endroll = <<~TEXT
91
+ def nat_credit
92
+ app_name = Souls.configuration.app
93
+ line = Paint["====================================", :yellow]
94
+ puts("\n")
95
+ puts(line)
96
+ txt2 = <<~TEXT
97
+ _____ ____ __ ____#{' '}
98
+ / ___// __ \\/ / / / / %{red1}
99
+ \\__ \\/ / / / / / / / %{red2}
100
+ ___/ / /_/ / /_/ / /___%{red3}#{' '}
101
+ /____/\\____/\\____/_____%{red4}#{' '}
102
+ TEXT
103
+ red1 = ["_____", :red]
104
+ red2 = ["/ ___/", :red]
105
+ red3 = ["(__ )", :red]
106
+ red4 = ["/____/", :red]
107
+ ms = Paint % [txt2, :cyan, { red1: red1, red2: red2, red3: red3, red4: red4 }]
108
+ puts(ms)
109
+ puts(line)
110
+ welcome = Paint["VPC Network is All Set!", :white]
111
+ puts(welcome)
112
+ puts(line)
113
+ endroll = <<~TEXT
110
114
 
111
- Edit `.github/workflow/worker.yml`
115
+ Edit `.github/workflow/worker.yml`
112
116
 
113
- Add these 2 options in \n`- name: Deploy to Cloud Run` step
114
- \n--vpc-connector=#{app_name}-connector \
115
- \n--vpc-egress=all \
117
+ Add these 2 options in \n`- name: Deploy to Cloud Run` step
118
+ \n--vpc-connector=#{app_name}-connector \
119
+ \n--vpc-egress=all \
116
120
 
117
- TEXT
118
- cd = Paint[endroll, :white]
119
- puts(cd)
120
- puts(line)
121
- end
122
- end
121
+ TEXT
122
+ cd = Paint[endroll, :white]
123
+ puts(cd)
124
+ puts(line)
123
125
  end
124
126
  end
125
127
  end
@@ -1,83 +1,98 @@
1
1
  module Souls
2
- module Gcloud
3
- module Iam
4
- class << self
5
- def create_service_account(service_account: "souls-app")
6
- system(
7
- "gcloud iam service-accounts create #{service_account} \
2
+ class Iam < Thor
3
+ desc "setup_key", "Create Google Cloud IAM Service Account Key And Set All Permissions"
4
+ def setup_key
5
+ Souls::Gcloud.new.auth_login
6
+ create_service_account
7
+ create_service_account_key
8
+ Souls::Gcloud.new.enable_permissions
9
+ add_permissions
10
+ export_key_to_console
11
+ rescue Thor::Error => e
12
+ raise(Thor::Error, e)
13
+ end
14
+
15
+ private
16
+
17
+ desc "create_service_account", "Create Google Cloud IAM Service Account"
18
+ def create_service_account
19
+ app_name = Souls.configuration.app
20
+ system(
21
+ "gcloud iam service-accounts create #{app_name} \
8
22
  --description='Souls Service Account' \
9
- --display-name=#{service_account}"
10
- )
11
- end
23
+ --display-name=#{app_name}"
24
+ )
25
+ end
12
26
 
13
- def create_service_account_key(service_account: "souls-app", project_id: "souls-app")
14
- system(
15
- "gcloud iam service-accounts keys create ./config/keyfile.json \
16
- --iam-account #{service_account}@#{project_id}.iam.gserviceaccount.com"
17
- )
18
- end
27
+ desc "create_service_account_key", "Create Google Cloud Service Account Key"
28
+ def create_service_account_key
29
+ app_name = Souls.configuration.app
30
+ project_id = Souls.configuration.project_id
31
+ system(
32
+ "gcloud iam service-accounts keys create ./config/keyfile.json \
33
+ --iam-account #{app_name}@#{project_id}.iam.gserviceaccount.com"
34
+ )
35
+ end
19
36
 
20
- def export_key_to_console
21
- file_path = "config/keyfile.json"
22
- puts(Paint["======= below(ここから)=======", :cyan])
23
- text = []
24
- File.open(file_path, "r") do |line|
25
- line.each_line do |l|
26
- text << l
27
- end
28
- end
29
- key = text.join(",").gsub(/^,/, "").chomp!
30
- github_repo = `git remote show origin -n | grep 'Fetch URL:' | awk '{print $3}'`.strip
31
- github_repo = "https://github.com/#{github_repo.match(/:(.+).git/)[1]}" if github_repo.include?("git@github")
32
- puts(Paint[key, :white])
33
- puts(Paint["======= above(ここまで)=======", :cyan])
34
- github_secret_url = "#{github_repo}/settings/secrets/actions"
35
- souls_doc_url = "https://souls.elsoul.nl/docs/tutorial/zero-to-deploy/#github-シークレットキーの登録"
36
- txt1 = <<~TEXT
37
+ def export_key_to_console
38
+ file_path = "config/keyfile.json"
39
+ puts(Paint["======= below(ここから)=======", :cyan])
40
+ text = []
41
+ File.open(file_path, "r") do |line|
42
+ line.each_line do |l|
43
+ text << l
44
+ end
45
+ end
46
+ key = text.join(",").gsub(/^,/, "").chomp!
47
+ github_repo = `git remote show origin -n | grep 'Fetch URL:' | awk '{print $3}'`.strip
48
+ github_repo = "https://github.com/#{github_repo.match(/:(.+).git/)[1]}" if github_repo.include?("git@github")
49
+ puts(Paint[key, :white])
50
+ puts(Paint["======= above(ここまで)=======", :cyan])
51
+ github_secret_url = "#{github_repo}/settings/secrets/actions"
52
+ souls_doc_url = "https://souls.elsoul.nl/docs/tutorial/zero-to-deploy/#github-シークレットキーの登録"
53
+ txt1 = <<~TEXT
37
54
 
38
- ⬆⬆⬆ Copy the service account key above ⬆⬆⬆⬆
55
+ ⬆⬆⬆ Copy the service account key above ⬆⬆⬆⬆
39
56
 
40
- And
57
+ And
41
58
 
42
- Go to %{yellow_text}
59
+ Go to %{yellow_text}
43
60
 
44
- Reference: %{yellow_text2}
45
- TEXT
46
- puts(
47
- Paint % [
48
- txt1,
49
- :white,
50
- { yellow_text: [github_secret_url, :yellow], yellow_text2: [souls_doc_url, :yellow] }
51
- ]
52
- )
53
- FileUtils.rm(file_path)
54
- end
61
+ Reference: %{yellow_text2}
62
+ TEXT
63
+ puts(
64
+ Paint % [
65
+ txt1,
66
+ :white,
67
+ { yellow_text: [github_secret_url, :yellow], yellow_text2: [souls_doc_url, :yellow] }
68
+ ]
69
+ )
70
+ FileUtils.rm(file_path)
71
+ end
55
72
 
56
- def add_service_account_role(
57
- service_account: "souls-app", project_id: "souls-app", role: "roles/firebase.admin"
58
- )
59
- system(
60
- "gcloud projects add-iam-policy-binding #{project_id} \
61
- --member='serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com' \
73
+ def add_service_account_role(role: "roles/firebase.admin")
74
+ app_name = Souls.configuration.app
75
+ project_id = Souls.configuration.project_id
76
+ system(
77
+ "gcloud projects add-iam-policy-binding #{project_id} \
78
+ --member='serviceAccount:#{app_name}@#{project_id}.iam.gserviceaccount.com' \
62
79
  --role=#{role}"
63
- )
64
- end
80
+ )
81
+ end
65
82
 
66
- def add_permissions(service_account: "souls-app", project_id: "souls-app")
67
- roles = [
68
- "roles/cloudsql.editor",
69
- "roles/containerregistry.ServiceAgent",
70
- "roles/pubsub.editor",
71
- "roles/datastore.user",
72
- "roles/iam.serviceAccountUser",
73
- "roles/run.admin",
74
- "roles/storage.admin",
75
- "roles/storage.objectAdmin"
76
- ]
77
- roles.each do |role|
78
- add_service_account_role(service_account: service_account, project_id: project_id, role: role)
79
- end
80
- end
83
+ def add_permissions
84
+ roles = [
85
+ "roles/cloudsql.editor",
86
+ "roles/containerregistry.ServiceAgent",
87
+ "roles/pubsub.editor",
88
+ "roles/datastore.user",
89
+ "roles/iam.serviceAccountUser",
90
+ "roles/run.admin",
91
+ "roles/storage.admin",
92
+ "roles/storage.objectAdmin"
93
+ ]
94
+ roles.each do |role|
95
+ add_service_account_role(role: role)
81
96
  end
82
97
  end
83
98
  end
@@ -5,45 +5,46 @@ require_relative "./sql/index"
5
5
  require_relative "./compute/index"
6
6
 
7
7
  module Souls
8
- module Gcloud
9
- class << self
10
- def auth_login(project_id: "")
11
- project_id = Souls.configuration.project_id if project_id.blank?
12
- system("gcloud config set project #{project_id}")
13
- system("gcloud auth login")
14
- end
15
-
16
- def enable_permissions
17
- system("gcloud services enable compute.googleapis.com")
18
- puts("Operating permission to compute.googleapis.com ...")
19
- system("gcloud services enable iam.googleapis.com")
20
- puts("Operating permission to iam.googleapis.com ...")
21
- system("gcloud services enable dns.googleapis.com")
22
- puts("Operating permission to dns.googleapis.com ...")
23
- system("gcloud services enable sqladmin.googleapis.com")
24
- puts("Operating permission to sqladmin.googleapis.com ...")
25
- system("gcloud services enable sql-component.googleapis.com")
26
- puts("Operating permission to sql-component.googleapis.com ...")
27
- system("gcloud services enable servicenetworking.googleapis.com")
28
- puts("Operating permission to servicenetworking.googleapis.com ...")
29
- system("gcloud services enable containerregistry.googleapis.com")
30
- puts("Operating permission to containerregistry.googleapis.com")
31
- system("gcloud services enable run.googleapis.com")
32
- puts("Operating permission to run.googleapis.com")
33
- system("gcloud services enable vpcaccess.googleapis.com")
34
- puts("Operating permission to vpcaccess.googleapis.com")
35
- end
36
- end
37
- module Iam
38
- end
8
+ class Gcloud < Thor
9
+ desc "iam [COMMAND]", "souls gcloud iam Commands"
10
+ subcommand "iam", Iam
39
11
 
40
- module Pubsub
41
- end
12
+ desc "pubsub [COMMAND]", "souls gcloud pubsub Commands"
13
+ subcommand "pubsub", Pubsub
14
+
15
+ desc "sql [COMMAND]", "souls gcloud sql Commands"
16
+ subcommand "sql", Sql
17
+
18
+ desc "compute [COMMAND]", "souls gcloud compute Commands"
19
+ subcommand "compute", Compute
20
+
21
+ desc "run [COMMAND]", "souls gcloud run Commands"
22
+ subcommand "cloud_run", CloudRun
23
+
24
+ map run: "cloud_run"
42
25
 
43
- module Run
26
+ desc "auth_login", "gcloud config set and gcloud auth login"
27
+ def auth_login
28
+ project_id = Souls.configuration.project_id
29
+ system("gcloud config set project #{project_id}")
30
+ system("gcloud auth login")
31
+ rescue Thor::Error => e
32
+ raise(Thor::Error, e)
44
33
  end
45
34
 
46
- module Sql
35
+ desc "enable_permissions", "Enable Google Cloud APIs for SOULs Framework"
36
+ def enable_permissions
37
+ system("gcloud services enable compute.googleapis.com")
38
+ system("gcloud services enable iam.googleapis.com")
39
+ system("gcloud services enable dns.googleapis.com")
40
+ system("gcloud services enable sqladmin.googleapis.com")
41
+ system("gcloud services enable sql-component.googleapis.com")
42
+ system("gcloud services enable servicenetworking.googleapis.com")
43
+ system("gcloud services enable containerregistry.googleapis.com")
44
+ system("gcloud services enable run.googleapis.com")
45
+ system("gcloud services enable vpcaccess.googleapis.com")
46
+ rescue Thor::Error => e
47
+ raise(Thor::Error, e)
47
48
  end
48
49
  end
49
50
  end