souls 0.50.0 → 0.52.0

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 +5 -1
  3. data/exe/souls +4 -202
  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 +100 -95
  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 -93
  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 -45
  40. data/lib/souls/cli/index.rb +3 -20
  41. data/lib/souls/cli/init/index.rb +140 -138
  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,120 +1,127 @@
1
1
  module Souls
2
- module Gcloud
3
- module Compute
4
- class << self
5
- def setup_vpc_nat(app_name: "", region: "asia-northeast1", range: "10.124.0.0/28")
6
- create_network(app_name: app_name)
7
- create_firewall_tcp(app_name: app_name, range: range)
8
- create_firewall_ssh(app_name: app_name)
9
- create_subnet(app_name: app_name, region: region, range: range)
10
- create_connector(app_name: app_name, region: region)
11
- create_router(app_name: app_name, region: region)
12
- create_external_ip(app_name: app_name, region: region)
13
- create_nat(app_name: app_name, region: region)
14
- nat_credit(app_name: app_name)
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(app_name: "")
18
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "", range: "10.124.0.0/28")
23
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "")
31
- app_name = Souls.configuration.app if app_name.blank?
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(app_name: "", region: "asia-northeast1", range: "10.124.0.0/28")
39
- app_name = Souls.configuration.app if app_name.blank?
40
- system(
41
- "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 \
42
47
  --range=#{range} --network=#{app_name} --region=#{region}"
43
- )
44
- end
48
+ )
49
+ end
45
50
 
46
- def create_connector(app_name: "", region: "asia-northeast1")
47
- app_name = Souls.configuration.app if app_name.blank?
48
- project_id = Souls.configuration.project_id
49
- system(
50
- "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 \
51
57
  --region=#{region} \
52
58
  --subnet-project=#{project_id} \
53
59
  --subnet=#{app_name}-subnet"
54
- )
55
- end
60
+ )
61
+ end
56
62
 
57
- def create_router(app_name: "", region: "asia-northeast1")
58
- app_name = Souls.configuration.app if app_name.blank?
59
- system("gcloud compute routers create #{app_name}-router --network=#{app_name} --region=#{region}")
60
- 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
61
68
 
62
- def create_external_ip(app_name: "", region: "asia-northeast1")
63
- app_name = Souls.configuration.app if app_name.blank?
64
- system("gcloud compute addresses create #{app_name}-worker-ip --region=#{region}")
65
- 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
66
74
 
67
- def create_nat(app_name: "", region: "asia-northeast1")
68
- app_name = Souls.configuration.app if app_name.blank?
69
- system(
70
- "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 \
71
80
  --router=#{app_name}-router \
72
81
  --region=#{region} \
73
82
  --nat-custom-subnet-ip-ranges=#{app_name}-subnet \
74
83
  --nat-external-ip-pool=#{app_name}-worker-ip"
75
- )
76
- end
84
+ )
85
+ end
77
86
 
78
- def network_list
79
- system("gcloud compute network list")
80
- end
87
+ def network_list
88
+ system("gcloud compute network list")
89
+ end
81
90
 
82
- def nat_credit(app_name: "")
83
- app_name = Souls.configuration.app if app_name.blank?
84
- line = Paint["====================================", :yellow]
85
- puts("\n")
86
- puts(line)
87
- txt2 = <<~TEXT
88
- _____ ____ __ ____#{' '}
89
- / ___// __ \\/ / / / / %{red1}
90
- \\__ \\/ / / / / / / / %{red2}
91
- ___/ / /_/ / /_/ / /___%{red3}#{' '}
92
- /____/\\____/\\____/_____%{red4}#{' '}
93
- TEXT
94
- red1 = ["_____", :red]
95
- red2 = ["/ ___/", :red]
96
- red3 = ["(__ )", :red]
97
- red4 = ["/____/", :red]
98
- ms = Paint % [txt2, :cyan, { red1: red1, red2: red2, red3: red3, red4: red4 }]
99
- puts(ms)
100
- puts(line)
101
- welcome = Paint["VPC Network is All Set!", :white]
102
- puts(welcome)
103
- puts(line)
104
- 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
105
114
 
106
- Edit `.github/workflow/worker.yml`
115
+ Edit `.github/workflow/worker.yml`
107
116
 
108
- Add these 2 options in \n`- name: Deploy to Cloud Run` step
109
- \n--vpc-connector=#{app_name}-connector \
110
- \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 \
111
120
 
112
- TEXT
113
- cd = Paint[endroll, :white]
114
- puts(cd)
115
- puts(line)
116
- end
117
- end
121
+ TEXT
122
+ cd = Paint[endroll, :white]
123
+ puts(cd)
124
+ puts(line)
118
125
  end
119
126
  end
120
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