rails_template_18f 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +4 -1
  5. data/README.md +16 -19
  6. data/exe/rails_template_18f +60 -0
  7. data/lib/generators/rails_template18f/active_storage/active_storage_generator.rb +135 -0
  8. data/lib/generators/rails_template18f/active_storage/templates/app/jobs/file_scan_job.rb +33 -0
  9. data/lib/generators/rails_template18f/active_storage/templates/app/models/file_upload.rb +25 -0
  10. data/lib/generators/rails_template18f/active_storage/templates/doc/adr/clamav.md.tt +30 -0
  11. data/lib/generators/rails_template18f/active_storage/templates/spec/jobs/file_scan_job_spec.rb +35 -0
  12. data/lib/generators/rails_template18f/active_storage/templates/spec/models/file_upload_spec.rb +38 -0
  13. data/lib/generators/rails_template18f/circleci/circleci_generator.rb +26 -10
  14. data/lib/generators/rails_template18f/cloud_gov_config/cloud_gov_config_generator.rb +28 -0
  15. data/lib/generators/rails_template18f/cloud_gov_config/templates/app/models/cloud_gov_config.rb +15 -0
  16. data/lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb +44 -0
  17. data/lib/generators/rails_template18f/dap/dap_generator.rb +72 -0
  18. data/lib/generators/rails_template18f/github_actions/github_actions_generator.rb +27 -11
  19. data/lib/generators/rails_template18f/i18n/i18n_generator.rb +107 -0
  20. data/{templates → lib/generators/rails_template18f/i18n/templates}/config/locales/en.yml.tt +3 -3
  21. data/{templates → lib/generators/rails_template18f/i18n/templates}/config/locales/es.yml +3 -3
  22. data/{templates → lib/generators/rails_template18f/i18n/templates}/config/locales/fr.yml +3 -6
  23. data/{templates → lib/generators/rails_template18f/i18n/templates}/config/locales/zh.yml +0 -0
  24. data/lib/generators/rails_template18f/i18n_js/i18n_js_generator.rb +60 -0
  25. data/lib/generators/rails_template18f/i18n_js/templates/lib/tasks/i18n.rake +9 -0
  26. data/lib/generators/rails_template18f/newrelic/newrelic_generator.rb +79 -0
  27. data/{templates/config/newrelic.yml → lib/generators/rails_template18f/newrelic/templates/config/newrelic.yml.tt} +7 -7
  28. data/lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb +70 -0
  29. data/lib/generators/rails_template18f/sidekiq/templates/config/initializers/redis.rb +14 -0
  30. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/README.md.tt +0 -0
  31. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/bootstrap/import.sh +0 -0
  32. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/bootstrap/main.tf.tt +3 -3
  33. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/bootstrap/providers.tf +0 -0
  34. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/bootstrap/run.sh.tt +1 -1
  35. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/teardown_creds.sh.tt +5 -0
  36. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/bootstrap/variables.tf +0 -0
  37. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/create_space_deployer.sh +0 -0
  38. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/destroy_space_deployer.sh +0 -0
  39. data/lib/generators/rails_template18f/terraform/templates/terraform/production/main.tf.tt +82 -0
  40. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/production/providers.tf.tt +0 -0
  41. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/production/variables.tf +0 -0
  42. data/lib/generators/rails_template18f/terraform/templates/terraform/shared/clamav/main.tf.tt +50 -0
  43. data/{templates/terraform/shared/database → lib/generators/rails_template18f/terraform/templates/terraform/shared/clamav}/providers.tf +0 -0
  44. data/lib/generators/rails_template18f/terraform/templates/terraform/shared/clamav/variables.tf +47 -0
  45. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/shared/database/main.tf.tt +0 -0
  46. data/{templates/terraform/shared/domain → lib/generators/rails_template18f/terraform/templates/terraform/shared/database}/providers.tf +0 -0
  47. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/shared/database/variables.tf +0 -0
  48. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/shared/domain/main.tf.tt +1 -1
  49. data/{templates/terraform/shared/s3 → lib/generators/rails_template18f/terraform/templates/terraform/shared/domain}/providers.tf +0 -0
  50. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/shared/domain/variables.tf +0 -0
  51. data/lib/generators/rails_template18f/terraform/templates/terraform/shared/redis/main.tf.tt +23 -0
  52. data/lib/generators/rails_template18f/terraform/templates/terraform/shared/redis/providers.tf +16 -0
  53. data/lib/generators/rails_template18f/terraform/templates/terraform/shared/redis/variables.tf +42 -0
  54. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/shared/s3/main.tf +0 -0
  55. data/lib/generators/rails_template18f/terraform/templates/terraform/shared/s3/providers.tf +16 -0
  56. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/shared/s3/variables.tf +0 -0
  57. data/lib/generators/rails_template18f/terraform/templates/terraform/staging/main.tf.tt +62 -0
  58. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/staging/providers.tf.tt +0 -0
  59. data/{templates → lib/generators/rails_template18f/terraform/templates}/terraform/staging/variables.tf +0 -0
  60. data/lib/generators/rails_template18f/terraform/terraform_generator.rb +84 -0
  61. data/lib/rails_template18f/app_updater.rb +19 -0
  62. data/lib/rails_template18f/generators/base.rb +53 -0
  63. data/lib/rails_template18f/generators/cloud_gov_options.rb +53 -0
  64. data/lib/rails_template18f/generators/pipeline_options.rb +18 -0
  65. data/lib/rails_template18f/generators.rb +11 -0
  66. data/lib/rails_template18f/version.rb +1 -1
  67. data/lib/rails_template_18f.rb +1 -4
  68. data/rails-template-18f.gemspec +1 -0
  69. data/template.rb +84 -148
  70. data/templates/README.md.tt +7 -44
  71. data/templates/config/deployment/staging.yml +1 -1
  72. data/templates/config/environments/ci.rb +0 -1
  73. data/templates/doc/compliance/apps/application.boundary.md.tt +4 -31
  74. data/templates/githooks/{pre-commit.tt → pre-commit} +0 -15
  75. data/templates/manifest.yml.tt +1 -2
  76. metadata +77 -34
  77. data/lib/rails_template18f/terraform_options.rb +0 -68
  78. data/templates/terraform/bootstrap/teardown_creds.sh.tt +0 -5
  79. data/templates/terraform/production/main.tf.tt +0 -50
  80. data/templates/terraform/staging/main.tf.tt +0 -30
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_template_18f
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Ahearn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-14 00:00:00.000000000 Z
11
+ date: 2022-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 7.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -83,7 +97,8 @@ dependencies:
83
97
  description:
84
98
  email:
85
99
  - ryan.ahearn@gsa.gov
86
- executables: []
100
+ executables:
101
+ - rails_template_18f
87
102
  extensions: []
88
103
  extra_rdoc_files: []
89
104
  files:
@@ -98,11 +113,22 @@ files:
98
113
  - Rakefile
99
114
  - bin/console
100
115
  - bin/setup
116
+ - exe/rails_template_18f
117
+ - lib/generators/rails_template18f/active_storage/active_storage_generator.rb
118
+ - lib/generators/rails_template18f/active_storage/templates/app/jobs/file_scan_job.rb
119
+ - lib/generators/rails_template18f/active_storage/templates/app/models/file_upload.rb
120
+ - lib/generators/rails_template18f/active_storage/templates/doc/adr/clamav.md.tt
121
+ - lib/generators/rails_template18f/active_storage/templates/spec/jobs/file_scan_job_spec.rb
122
+ - lib/generators/rails_template18f/active_storage/templates/spec/models/file_upload_spec.rb
101
123
  - lib/generators/rails_template18f/circleci/circleci_generator.rb
102
124
  - lib/generators/rails_template18f/circleci/templates/Dockerfile.tt
103
125
  - lib/generators/rails_template18f/circleci/templates/bin/ci-server-start
104
126
  - lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt
105
127
  - lib/generators/rails_template18f/circleci/templates/docker-compose.ci.yml
128
+ - lib/generators/rails_template18f/cloud_gov_config/cloud_gov_config_generator.rb
129
+ - lib/generators/rails_template18f/cloud_gov_config/templates/app/models/cloud_gov_config.rb
130
+ - lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb
131
+ - lib/generators/rails_template18f/dap/dap_generator.rb
106
132
  - lib/generators/rails_template18f/github_actions/github_actions_generator.rb
107
133
  - lib/generators/rails_template18f/github_actions/templates/github/actions/run-server/action.yml
108
134
  - lib/generators/rails_template18f/github_actions/templates/github/actions/setup-languages/action.yml.tt
@@ -117,7 +143,53 @@ files:
117
143
  - lib/generators/rails_template18f/github_actions/templates/github/workflows/rspec.yml.tt
118
144
  - lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml
119
145
  - lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml
120
- - lib/rails_template18f/terraform_options.rb
146
+ - lib/generators/rails_template18f/i18n/i18n_generator.rb
147
+ - lib/generators/rails_template18f/i18n/templates/config/locales/en.yml.tt
148
+ - lib/generators/rails_template18f/i18n/templates/config/locales/es.yml
149
+ - lib/generators/rails_template18f/i18n/templates/config/locales/fr.yml
150
+ - lib/generators/rails_template18f/i18n/templates/config/locales/zh.yml
151
+ - lib/generators/rails_template18f/i18n_js/i18n_js_generator.rb
152
+ - lib/generators/rails_template18f/i18n_js/templates/lib/tasks/i18n.rake
153
+ - lib/generators/rails_template18f/newrelic/newrelic_generator.rb
154
+ - lib/generators/rails_template18f/newrelic/templates/config/newrelic.yml.tt
155
+ - lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb
156
+ - lib/generators/rails_template18f/sidekiq/templates/config/initializers/redis.rb
157
+ - lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt
158
+ - lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/import.sh
159
+ - lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/main.tf.tt
160
+ - lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/providers.tf
161
+ - lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/run.sh.tt
162
+ - lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/teardown_creds.sh.tt
163
+ - lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/variables.tf
164
+ - lib/generators/rails_template18f/terraform/templates/terraform/create_space_deployer.sh
165
+ - lib/generators/rails_template18f/terraform/templates/terraform/destroy_space_deployer.sh
166
+ - lib/generators/rails_template18f/terraform/templates/terraform/production/main.tf.tt
167
+ - lib/generators/rails_template18f/terraform/templates/terraform/production/providers.tf.tt
168
+ - lib/generators/rails_template18f/terraform/templates/terraform/production/variables.tf
169
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/clamav/main.tf.tt
170
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/clamav/providers.tf
171
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/clamav/variables.tf
172
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/database/main.tf.tt
173
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/database/providers.tf
174
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/database/variables.tf
175
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/domain/main.tf.tt
176
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/domain/providers.tf
177
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/domain/variables.tf
178
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/redis/main.tf.tt
179
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/redis/providers.tf
180
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/redis/variables.tf
181
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/s3/main.tf
182
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/s3/providers.tf
183
+ - lib/generators/rails_template18f/terraform/templates/terraform/shared/s3/variables.tf
184
+ - lib/generators/rails_template18f/terraform/templates/terraform/staging/main.tf.tt
185
+ - lib/generators/rails_template18f/terraform/templates/terraform/staging/providers.tf.tt
186
+ - lib/generators/rails_template18f/terraform/templates/terraform/staging/variables.tf
187
+ - lib/generators/rails_template18f/terraform/terraform_generator.rb
188
+ - lib/rails_template18f/app_updater.rb
189
+ - lib/rails_template18f/generators.rb
190
+ - lib/rails_template18f/generators/base.rb
191
+ - lib/rails_template18f/generators/cloud_gov_options.rb
192
+ - lib/rails_template18f/generators/pipeline_options.rb
121
193
  - lib/rails_template18f/version.rb
122
194
  - lib/rails_template_18f.rb
123
195
  - rails-template-18f.gemspec
@@ -139,11 +211,6 @@ files:
139
211
  - templates/config/deployment/staging.yml
140
212
  - templates/config/environments/ci.rb
141
213
  - templates/config/environments/staging.rb
142
- - templates/config/locales/en.yml.tt
143
- - templates/config/locales/es.yml
144
- - templates/config/locales/fr.yml
145
- - templates/config/locales/zh.yml
146
- - templates/config/newrelic.yml
147
214
  - templates/doc/adr/0001-record-architecture-decisions.md.tt
148
215
  - templates/doc/adr/0002-initial-architecture-decisions.md.tt
149
216
  - templates/doc/adr/0003-security-scans.md.tt
@@ -154,35 +221,11 @@ files:
154
221
  - templates/doc/compliance/rendered/apps/.keep
155
222
  - templates/editorconfig
156
223
  - templates/env
157
- - templates/githooks/pre-commit.tt
224
+ - templates/githooks/pre-commit
158
225
  - templates/lib/tasks/cf.rake
159
226
  - templates/lib/tasks/scanning.rake
160
227
  - templates/manifest.yml.tt
161
228
  - templates/pa11yci
162
- - templates/terraform/README.md.tt
163
- - templates/terraform/bootstrap/import.sh
164
- - templates/terraform/bootstrap/main.tf.tt
165
- - templates/terraform/bootstrap/providers.tf
166
- - templates/terraform/bootstrap/run.sh.tt
167
- - templates/terraform/bootstrap/teardown_creds.sh.tt
168
- - templates/terraform/bootstrap/variables.tf
169
- - templates/terraform/create_space_deployer.sh
170
- - templates/terraform/destroy_space_deployer.sh
171
- - templates/terraform/production/main.tf.tt
172
- - templates/terraform/production/providers.tf.tt
173
- - templates/terraform/production/variables.tf
174
- - templates/terraform/shared/database/main.tf.tt
175
- - templates/terraform/shared/database/providers.tf
176
- - templates/terraform/shared/database/variables.tf
177
- - templates/terraform/shared/domain/main.tf.tt
178
- - templates/terraform/shared/domain/providers.tf
179
- - templates/terraform/shared/domain/variables.tf
180
- - templates/terraform/shared/s3/main.tf
181
- - templates/terraform/shared/s3/providers.tf
182
- - templates/terraform/shared/s3/variables.tf
183
- - templates/terraform/staging/main.tf.tt
184
- - templates/terraform/staging/providers.tf.tt
185
- - templates/terraform/staging/variables.tf
186
229
  - templates/zap.conf
187
230
  homepage: https://github.com/18f/rails-template
188
231
  licenses: []
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RailsTemplate18f
4
- module TerraformOptions
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- class_option :cg_org, desc: "cloud.gov organization name"
9
- class_option :cg_staging, desc: "cloud.gov space name for staging"
10
- class_option :cg_prod, desc: "cloud.gov space name for production"
11
- class_option :terraform, type: :boolean, desc: "Generate actions for planning and applying terraform"
12
- end
13
-
14
- private
15
-
16
- def ruby_version
17
- RUBY_VERSION
18
- end
19
-
20
- def terraform?
21
- options[:terraform].nil? ? terraform_dir_exists? : options[:terraform]
22
- end
23
-
24
- def cloud_gov_organization
25
- if options[:cg_org].present?
26
- return options[:cg_org]
27
- elsif terraform_dir_exists?
28
- staging_main = File.read(terraform_path.join("staging", "main.tf"))
29
- if (matches = staging_main.match(/cf_org_name\s+= "(?<org_name>.*)"/))
30
- return matches[:org_name]
31
- end
32
- end
33
- "TKTK-cloud.gov-org-name"
34
- end
35
-
36
- def cloud_gov_staging_space
37
- if options[:cg_staging].present?
38
- return options[:cg_staging]
39
- elsif terraform_dir_exists?
40
- staging_main = File.read(terraform_path.join("staging", "main.tf"))
41
- if (matches = staging_main.match(/cf_space_name\s+= "(?<space_name>.*)"/))
42
- return matches[:space_name]
43
- end
44
- end
45
- "staging"
46
- end
47
-
48
- def cloud_gov_production_space
49
- if options[:cg_prod].present?
50
- return options[:cg_prod]
51
- elsif terraform_dir_exists?
52
- prod_main = File.read(terraform_path.join("production", "main.tf"))
53
- if (matches = prod_main.match(/cf_space_name\s+= "(?<space_name>.*)"/))
54
- return matches[:space_name]
55
- end
56
- end
57
- "prod"
58
- end
59
-
60
- def terraform_path
61
- Pathname.new File.expand_path("terraform", destination_root)
62
- end
63
-
64
- def terraform_dir_exists?
65
- Dir.exist? terraform_path
66
- end
67
- end
68
- end
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- ../destroy_space_deployer.sh <%= @cloud_gov_production_space %> config-bootstrap-deployer
4
-
5
- rm secrets.auto.tfvars
@@ -1,50 +0,0 @@
1
- locals {
2
- cf_org_name = "<%= @cloud_gov_organization %>"
3
- cf_space_name = "<%= @cloud_gov_production_space %>"
4
- env = "production"
5
- recursive_delete = false
6
- }
7
-
8
- module "database" {
9
- source = "../shared/database"
10
-
11
- cf_user = var.cf_user
12
- cf_password = var.cf_password
13
- cf_org_name = local.cf_org_name
14
- cf_space_name = local.cf_space_name
15
- env = local.env
16
- recursive_delete = local.recursive_delete
17
- rds_plan_name = "TKTK-production-rds-plan"
18
- }
19
-
20
- <% if !skip_active_storage? %>
21
- module "s3" {
22
- source = "../shared/s3"
23
-
24
- cf_user = var.cf_user
25
- cf_password = var.cf_password
26
- cf_org_name = local.cf_org_name
27
- cf_space_name = local.cf_space_name
28
- s3_service_name = "<%= app_name %>-s3-${local.env}"
29
- }
30
- <% end %>
31
-
32
- ###########################################################################
33
- # The following lines need to be commented out for the initial `terraform apply`
34
- # It can be re-enabled after:
35
- # 1) the app has first been deployed
36
- # 2) the route has been manually created by an OrgManager:
37
- # `cf create-domain <%= @cloud_gov_organization %> TKTK-production-domain-name`
38
- ###########################################################################
39
- # module "domain" {
40
- # source = "../shared/domain"
41
- #
42
- # cf_user = var.cf_user
43
- # cf_password = var.cf_password
44
- # cf_org_name = local.cf_org_name
45
- # cf_space_name = local.cf_space_name
46
- # env = local.env
47
- # recursive_delete = local.recursive_delete
48
- # cdn_plan_name = "domain"
49
- # domain_name = "TKTK-production-domain-name"
50
- # }
@@ -1,30 +0,0 @@
1
- locals {
2
- cf_org_name = "<%= @cloud_gov_organization %>"
3
- cf_space_name = "<%= @cloud_gov_staging_space %>"
4
- env = "staging"
5
- recursive_delete = true
6
- }
7
-
8
- module "database" {
9
- source = "../shared/database"
10
-
11
- cf_user = var.cf_user
12
- cf_password = var.cf_password
13
- cf_org_name = local.cf_org_name
14
- cf_space_name = local.cf_space_name
15
- env = local.env
16
- recursive_delete = local.recursive_delete
17
- rds_plan_name = "micro-psql"
18
- }
19
-
20
- <% if !skip_active_storage? %>
21
- module "s3" {
22
- source = "../shared/s3"
23
-
24
- cf_user = var.cf_user
25
- cf_password = var.cf_password
26
- cf_org_name = local.cf_org_name
27
- cf_space_name = local.cf_space_name
28
- s3_service_name = "<%= app_name %>-s3-${local.env}"
29
- }
30
- <% end %>