rails_template_18f 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3b689fcfbc4d7ed1a476adc0b415ed0cbbfc24828937431820b5850db77e564
4
- data.tar.gz: 5f95740853330bc904b23c67059a578b3f616cea6228c7c99a19d4eee5c26518
3
+ metadata.gz: 6c732c75ebc9f84d2f730c43042eb922392954f18e8a2500722e4f2e070f329a
4
+ data.tar.gz: 0fca28e40b443de8032d7a76f38f889449238c62ffeb15444b78a73d9482eaf0
5
5
  SHA512:
6
- metadata.gz: 6c350c36aeddf44806c2ddbd36dbacd626f361890a9a648ec6e58e4dbeba5b60928ece499542bae318f7f7f644af52b55c7b9e9f6639291f7dd00c00229f5334
7
- data.tar.gz: 75079b3718a90069ae1484b54b86dac37c89be836bd132afc8bd936fb0e1451aa85882a5fafa8a980f60094ce352fb933d7ae0179a557a9b6196d018d2a681c1
6
+ metadata.gz: c3900e08a7ae9227bad8e4f341b867556ddbaae1614a526ab64be758cd0c78ad0b09e4be1587da1038623151a045f05aa7a7fe3ea82676479f29d54d4cc4d94f
7
+ data.tar.gz: 7da9792ec9280f443a5bfa2bfc6ffca23a60cf984cb64c0773019dd27ea130b02fcd331647493b81ffcac434fbc8bb5cdf064c1d3e5a5714617a4bcac5335c90
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2022-02-17
4
+
5
+ - i18n generator
6
+ - helper script to run rails new without cloning repo
7
+
3
8
  ## [0.2.0] - 2022-02-16
4
9
 
5
10
  - terraform generator
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_template_18f (0.2.0)
4
+ rails_template_18f (0.3.0)
5
5
  activesupport (~> 7.0.0)
6
6
  railties (~> 7.0.0)
7
+ thor (~> 1.0)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -7,35 +7,32 @@ See the `rails-6` branch for Rails 6.1.x
7
7
 
8
8
  ## Use for new Rails Project
9
9
 
10
- 1. Clone this repository to your computer
11
- 1. Change directory into the clone
12
- 1. Run `rails new <<PATH_TO_PROJECT>> --rc=<<RC_FILE>>` with the appropriate rc file for your needs. The path should not be a subdirectory of this repository.
10
+ 1. `gem install rails_template_18f`
11
+ 1. `rails_template_18f help new` for usage instructions
13
12
 
14
- ### Choosing which RC file to use
15
-
16
- You should run this template with either `railsrc` or `railsrc-hotwire` depending on your development needs.
13
+ ### Choosing whether to use `--hotwire`
17
14
 
18
15
  #### Server Rendered _or_ Single Page Applications
19
16
 
20
- `rails new <<PATH_TO_PROJECT>> --rc=railsrc`
17
+ `rails_template_18f new <<PATH_TO_PROJECT>>` _or_ `rails_template_18f new <<PATH_TO_PROJECT>> --no-hotwire`
21
18
 
22
- The base `railsrc` file creates a Rails application that is appropriate for both server-rendered applications,
19
+ This creates a Rails application that is appropriate for both server-rendered applications,
23
20
  as well as a basis for installing a separate Single Page Application (SPA) library such as React.
24
21
 
25
22
  #### A bit more JavaScript needed
26
23
 
27
- `rails new <<PATH_TO_PROJECT>> --rc=railsrc-hotwire`
24
+ `rails_template_18f new <<PATH_TO_PROJECT>> --hotwire`
28
25
 
29
- The `railsrc-hotwire` file creates a Rails application that includes the [Hotwire](https://hotwired.dev/) JavaScript framework.
26
+ This creates a Rails application that includes the [Hotwire](https://hotwired.dev/) JavaScript framework.
30
27
 
31
28
  Hotwire can be used to add [a bit of JavaScript](https://engineering.18f.gov/web-architecture/#:~:text=are%20more%20complex-,If%20your%20use%20case%20requires%20a%20bit%20of%20client%2Dside%20interactivity%2C%20use%20the%20above%20options%20with%20a%20bit%20of%20JavaScript.,-You%20might%20use)
32
29
  for more interactivity than server-rendered apps, but less than a full SPA.
33
30
 
34
31
  ### Available Options
35
32
 
36
- The following options can be added after `--rc=<<RC_FILE>>` to change how the template behaves.
33
+ The following options can be added to change how the template behaves.
37
34
 
38
- **Important:** You must not pass `--skip-bundle` or `--skip-javascript` to `rails new` or various aspects of the template will be broken
35
+ **Important:** You must not pass `--skip-bundle` or `--skip-javascript` to `rails_template_18f` or various aspects of the template will be broken
39
36
 
40
37
  #### `--javascript=esbuild`
41
38
 
@@ -46,7 +43,7 @@ maintaining IE11 support with esbuild may be tricky.
46
43
 
47
44
  Each of the skipped frameworks in `railsrc` can be overridden on the command line. For example: `--no-skip-active-storage` will include support for `ActiveStorage` document uploads
48
45
 
49
- ### What `railsrc` does
46
+ ### What default use or `--no-hotwire` does
50
47
 
51
48
  ```
52
49
  --skip-active-storage # don't include ActiveStorage for document upload
@@ -61,9 +58,9 @@ Each of the skipped frameworks in `railsrc` can be overridden on the command lin
61
58
  --database=postgresql # default to PostgreSQL
62
59
  ```
63
60
 
64
- ### What `railsrc-hotwire` does
61
+ ### What `--hotwire` does
65
62
 
66
- `railsrc-hotwire` is identical to `railsrc` except that [Hotwire](https://hotwired.dev/) and [ActionCable](https://guides.rubyonrails.org/action_cable_overview.html) are not skipped.
63
+ Identical to `--no-hotwire` except that [Hotwire](https://hotwired.dev/) and [ActionCable](https://guides.rubyonrails.org/action_cable_overview.html) are not skipped.
67
64
 
68
65
  ActionCable is included to enable the [Turbo Streams](https://turbo.hotwired.dev/handbook/streams) functionality of Hotwire.
69
66
 
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "thor"
5
+
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+ desc "new APP_DIRECTORY [options] [rails new arguments]", "Run rails new with 18F flavor"
10
+ option :hotwire, type: :boolean, default: false, desc: "Enable hotwire JS framework"
11
+ long_desc <<-LONGDESC
12
+ Create a new rails application in <APP_DIRECTORY> as customized by
13
+
14
+ * railsrc: https://github.com/18F/rails-template/blob/main/railsrc
15
+
16
+ * template.rb: https://github.com/18F/rails-template/blob/main/template.rb
17
+
18
+ with --hotwire option, includes the Hotwire JS framework
19
+
20
+ all other arguments will be passed as-is to `rails new`
21
+ LONGDESC
22
+ def new(app_directory, *rails_arguments)
23
+ gem_path = File.expand_path("..", __dir__)
24
+ railsrc = options[:hotwire] ? "railsrc-hotwire" : "railsrc"
25
+ run "rails new #{app_directory} --rc=#{File.join(gem_path, railsrc)} --template=#{File.join(gem_path, "template.rb")} #{rails_arguments.join(" ")}"
26
+ end
27
+ end
28
+
29
+ CLI.start(ARGV)
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+ require "bundler"
5
+
6
+ module RailsTemplate18f
7
+ module Generators
8
+ class I18nGenerator < ::Rails::Generators::Base
9
+ include Base
10
+
11
+ class_option :languages, default: "es,fr,zh", desc: "Comma separated list of supported language short codes"
12
+
13
+ desc <<~DESC
14
+ Description:
15
+ Install translation framework and configuration for given languages.
16
+ Always installs configuration for English
17
+ DESC
18
+
19
+ def install_helper_gem_and_tasks
20
+ return if file_content("Gemfile").match?(/gem "i18n-tasks"/)
21
+ gem_group :development, :test do
22
+ gem "i18n-tasks", "~> 0.9"
23
+ end
24
+ Bundler.with_original_env do
25
+ in_root do
26
+ run "bundle install"
27
+ run "cp $(i18n-tasks gem-path)/templates/config/i18n-tasks.yml config/"
28
+ run "cp $(i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/"
29
+ end
30
+ end
31
+ insert_into_file "config/i18n-tasks.yml", "\n#{indent("- app/assets/builds", 4)}", after: "exclude:"
32
+ uncomment_lines "config/i18n-tasks.yml", "ignore_missing:"
33
+ insert_into_file "config/i18n-tasks.yml", indent(<<~EOM), after: "ignore_missing:\n"
34
+ - 'shared.languages.*'
35
+ - 'shared.header.{title,close,demo_banner,menu}'
36
+ EOM
37
+ end
38
+
39
+ def install_translations
40
+ inside "config/locales" do
41
+ template "en.yml"
42
+ languages.each do |lang|
43
+ copy_file "#{lang}.yml"
44
+ end
45
+ end
46
+ end
47
+
48
+ def configure_i18n
49
+ application "config.i18n.fallbacks = [:en]"
50
+ available_regex = /^(\s*config.i18n.available_locales).*$/
51
+ if file_content("config/application.rb").match?(available_regex)
52
+ gsub_file "config/application.rb", available_regex, "\\1 = #{supported_languages}"
53
+ else
54
+ application "config.i18n.available_locales = #{supported_languages}"
55
+ end
56
+ end
57
+
58
+ def install_nav_helper
59
+ inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper", indent(<<~'EOH')
60
+ def format_active_locale(locale_string)
61
+ link_classes = "usa-nav__link"
62
+ if locale_string.to_sym == I18n.locale
63
+ link_classes = "#{link_classes} usa-current"
64
+ end
65
+ link_to t("shared.languages.#{locale_string}"), root_path(locale: locale_string), class: link_classes
66
+ end
67
+ EOH
68
+ end
69
+
70
+ def install_around_action
71
+ return if languages.empty?
72
+ inject_into_class "app/controllers/application_controller.rb", "ApplicationController", indent(<<~EOM)
73
+ around_action :switch_locale
74
+
75
+ def switch_locale(&action)
76
+ locale = params[:locale] || I18n.default_locale
77
+ I18n.with_locale(locale, &action)
78
+ end
79
+ EOM
80
+ end
81
+
82
+ def install_route
83
+ return if languages.empty?
84
+ return if file_content("config/routes.rb").match?(/scope "\(:locale\)"/)
85
+ regex = /(^.+\.routes\.draw do\s*$)\n(.*)^end$/m
86
+ gsub_file "config/routes.rb", regex, <<~'EOR'
87
+ \1
88
+ scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
89
+ # Your application routes go here
90
+ \2
91
+ end
92
+ end
93
+ EOR
94
+ end
95
+
96
+ private
97
+
98
+ def supported_languages
99
+ @supported_languages ||= [:en, *languages]
100
+ end
101
+
102
+ def languages
103
+ @languages ||= options[:languages].split(",").map(&:to_sym)
104
+ end
105
+ end
106
+ end
107
+ end
@@ -12,11 +12,11 @@ en:
12
12
  secure_heading: Secure .gov websites use HTTPS
13
13
  us_flag: U.S. Flag
14
14
  header:
15
- title: <%= app_name.titleize %>
16
- menu: Menu
17
15
  close: Close
18
- primary: Primary navigation
19
16
  demo_banner: TEST SITE - Do not use real personal information (demo purposes only) - TEST SITE
17
+ menu: Menu
18
+ primary: Primary navigation
19
+ title: <%= app_name.titleize %>
20
20
  languages:
21
21
  en: English
22
22
  es: Español
@@ -12,8 +12,8 @@ es:
12
12
  secure_heading: Los sitios web seguros .gov usan HTTPS
13
13
  us_flag: Bandera de Estados Unidos
14
14
  header:
15
- menu: Menú
16
15
  close: Cerrar
17
- primary: Navegacion primaria
18
16
  demo_banner: SITIO DE PRUEBA - No utilice información personal real (sólo para propósitos de demostración) - SITIO DE PRUEBA
19
- skip_link: Salte al contenido principal
17
+ menu: Menú
18
+ primary: Navegacion primaria
19
+ skip_link: Salte al contenido principal
@@ -8,15 +8,12 @@ fr:
8
8
  lock: Verrou
9
9
  locked_padlock: Verrou fermé
10
10
  official_site: Un site web officiel du gouvernement des États-Unis
11
- secure_description_html: Un <strong>verrou</strong> (%{lock_icon}) ou
12
- <strong>https://</strong> signifie que vous êtes connecté en toute
13
- sécurité au site Web .gov. Partagez des informations sensibles
14
- uniquement sur des sites Web officiels et sécurisés.
11
+ secure_description_html: Un <strong>verrou</strong> (%{lock_icon}) ou <strong>https://</strong> signifie que vous êtes connecté en toute sécurité au site Web .gov. Partagez des informations sensibles uniquement sur des sites Web officiels et sécurisés.
15
12
  secure_heading: Les sites Web sécurisés .gov utilisent HTTPS
16
13
  us_flag: Drapeau américain
17
14
  header:
18
- menu: Menu
19
15
  close: Fermer
20
- primary: Navigation primaire
21
16
  demo_banner: SITE DE TEST - N’utilisez pas de véritables données personnelles (il s’agit d’une démonstration seulement) - SITE DE TEST
17
+ menu: Menu
18
+ primary: Navigation primaire
22
19
  skip_link: Passer au contenu principal
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsTemplate18f
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
  # guide at: https://bundler.io/guides/creating_gem.html
34
34
  spec.add_dependency "railties", "~> 7.0.0"
35
35
  spec.add_dependency "activesupport", "~> 7.0.0"
36
+ spec.add_dependency "thor", "~> 1.0"
36
37
 
37
38
  spec.add_development_dependency "rspec", "~> 3.11"
38
39
  spec.add_development_dependency "ammeter", "~> 1.1"
data/template.rb CHANGED
@@ -48,24 +48,24 @@ unless Gem::Dependency.new("rails", "~> 7.0.0").match?("rails", Rails.gem_versio
48
48
  end
49
49
 
50
50
  # ask setup questions
51
- @terraform = yes?("Create terraform files for cloud.gov services? (y/n)")
51
+ terraform = yes?("Create terraform files for cloud.gov services? (y/n)")
52
52
  @cloud_gov_organization = ask("What is your cloud.gov organization name? (Leave blank to fill in later)")
53
53
  default_staging_space = "staging"
54
- @cloud_gov_staging_space = ask("What is your cloud.gov staging space name? (Default: #{default_staging_space})")
54
+ cloud_gov_staging_space = ask("What is your cloud.gov staging space name? (Default: #{default_staging_space})")
55
55
  default_prod_space = "prod"
56
- @cloud_gov_production_space = ask("What is your cloud.gov production space name? (Default: #{default_prod_space})")
56
+ cloud_gov_production_space = ask("What is your cloud.gov production space name? (Default: #{default_prod_space})")
57
57
  @cloud_gov_organization = "TKTK-cloud.gov-org-name" if @cloud_gov_organization.blank?
58
- @cloud_gov_staging_space = default_staging_space if @cloud_gov_staging_space.blank?
59
- @cloud_gov_production_space = default_prod_space if @cloud_gov_production_space.blank?
58
+ cloud_gov_staging_space = default_staging_space if cloud_gov_staging_space.blank?
59
+ cloud_gov_production_space = default_prod_space if cloud_gov_production_space.blank?
60
60
 
61
61
  @github_actions = yes?("Create Github Actions? (y/n)")
62
62
  @circleci_pipeline = yes?("Create CircleCI config? (y/n)")
63
- @newrelic = yes?("Create FEDRAMP New Relic config files? (y/n)")
64
- @dap = yes?("If this will be a public site, should we include Digital Analytics Program code? (y/n)")
65
- @supported_languages = [:en]
66
- @supported_languages.push(:es) if yes?("Add Spanish to supported locales, with starter es.yml? (y/n)")
67
- @supported_languages.push(:fr) if yes?("Add French to supported locales, with starter fr.yml? (y/n)")
68
- @supported_languages.push(:zh) if yes?("Add Simplified Chinese to supported locales, with starter zh.yml? (y/n)")
63
+ newrelic = yes?("Create FEDRAMP New Relic config files? (y/n)")
64
+ dap = yes?("If this will be a public site, should we include Digital Analytics Program code? (y/n)")
65
+ supported_languages = []
66
+ supported_languages.push(:es) if yes?("Add Spanish to supported locales, with starter es.yml? (y/n)")
67
+ supported_languages.push(:fr) if yes?("Add French to supported locales, with starter fr.yml? (y/n)")
68
+ supported_languages.push(:zh) if yes?("Add Simplified Chinese to supported locales, with starter zh.yml? (y/n)")
69
69
 
70
70
  running_node_version = `node --version`.gsub(/^v/, "").strip
71
71
  @node_version = ask("What version of NodeJS are you using? (Default: #{running_node_version})")
@@ -168,24 +168,13 @@ uncomment_lines csp_initializer, "Rails.application"
168
168
  uncomment_lines csp_initializer, /end$/
169
169
  uncomment_lines csp_initializer, "content_security_policy_nonce"
170
170
 
171
- if @newrelic
172
- after_bundle do
173
- generate "rails_template18f:newrelic"
174
- end
175
- register_announcement("New Relic", <<~EOM)
176
- A New Relic config file has been written to `config/newrelic.yml`
177
-
178
- See instructions in README to get started sending data to New Relic
179
- EOM
180
- end
181
-
171
+ # install development & testing gems
182
172
  gem_group :development, :test do
183
173
  gem "rspec-rails", "~> 5.1"
184
174
  gem "dotenv-rails", "~> 2.7"
185
175
  gem "brakeman", "~> 5.2"
186
176
  gem "bundler-audit", "~> 0.9"
187
177
  gem "standard", "~> 1.7"
188
- gem "i18n-tasks", "~> 0.9"
189
178
  end
190
179
  if ENV["RT_DEV"] == "true"
191
180
  gem "rails_template_18f", group: :development, path: ENV["PWD"]
@@ -213,27 +202,7 @@ unless skip_git?
213
202
  EOM
214
203
  end
215
204
 
216
- # Setup translations
217
- @supported_languages.each do |language|
218
- template "config/locales/#{language}.yml", force: true
219
- end
220
- application "config.i18n.available_locales = #{@supported_languages}"
221
- application "config.i18n.fallbacks = [:en]"
222
- after_bundle do
223
- # Recommended by i18n-tasks
224
- run "cp $(i18n-tasks gem-path)/templates/config/i18n-tasks.yml config/"
225
- end
226
- insert_into_file "app/helpers/application_helper.rb", <<'EOH', before: /^end$/
227
- def format_active_locale(locale_string)
228
- link_classes = "usa-nav__link"
229
- if locale_string.to_sym == I18n.locale
230
- link_classes = "#{link_classes} usa-current"
231
- end
232
- link_to t("shared.languages.#{locale_string}"), root_path(locale: locale_string), class: link_classes
233
- end
234
- EOH
235
-
236
- # setup USWDS
205
+ # setup USWDS and asset pipeline
237
206
  copy_file "browserslistrc", ".browserslistrc" if webpack?
238
207
  uncomment_lines "Gemfile", "sassc-rails" # use sassc-rails for asset minification in prod
239
208
  after_bundle do
@@ -285,7 +254,7 @@ after_bundle do
285
254
  @import "uswds-settings.scss";
286
255
  @import "../../../node_modules/uswds/dist/scss/uswds.scss";
287
256
  EOCSS
288
- gsub_file "app/views/layouts/application.html.erb", "<html>", "<html lang=\"en\">"
257
+ gsub_file "app/views/layouts/application.html.erb", "<html>", '<html lang="<%= I18n.locale %>">'
289
258
  gsub_file "app/views/layouts/application.html.erb", /^\s+<%= yield %>/, <<-EOHTML
290
259
  <%= render "application/usa_banner" %>
291
260
  <%= render "application/header" %>
@@ -300,32 +269,14 @@ end
300
269
  directory "app/views/application"
301
270
 
302
271
  after_bundle do
272
+ # install and configure RSpec
303
273
  generate "rspec:install"
304
274
  gsub_file "spec/spec_helper.rb", /^=(begin|end)$/, ""
305
275
 
306
- # Setup the PagesController, locale routes, and home (root) route
276
+ # Setup the PagesController and home (root) route
307
277
  generate :controller, "pages", "home", "--skip-routes", "--no-helper", "--no-assets"
278
+ route "root 'pages#home'"
308
279
 
309
- if @supported_languages.count > 1
310
- locale_switching = <<~EOM
311
- around_action :switch_locale
312
-
313
- def switch_locale(&action)
314
- locale = params[:locale] || I18n.default_locale
315
- I18n.with_locale(locale, &action)
316
- end
317
- EOM
318
- insert_into_file "app/controllers/application_controller.rb", locale_switching, before: /^end/
319
-
320
- route <<-'EOM'
321
- scope "(:locale)", locale: /#{I18n.available_locales.join('|')}/ do
322
- # Your application routes here
323
- root 'pages#home'
324
- end
325
- EOM
326
- else
327
- route "root 'pages#home'"
328
- end
329
280
  gsub_file "spec/requests/pages_spec.rb", "/pages/home", "/"
330
281
  gsub_file "spec/views/pages/home.html.erb_spec.rb", " pending \"add some examples to (or delete) \#{__FILE__}\"", <<-EOM
331
282
  it "displays the gov banner" do
@@ -334,26 +285,46 @@ after_bundle do
334
285
  end
335
286
  EOM
336
287
 
337
- if run_db_setup
338
- rails_command "db:create"
339
- rails_command "db:migrate"
288
+ # Setup translations
289
+ generate "rails_template18f:i18n", "--languages=#{supported_languages.join(",")}", "--force"
290
+ end
291
+
292
+ # install ADRs and compliance documentation
293
+ directory "doc"
294
+ register_announcement("Documentation", <<~EOM)
295
+ * Include a short description of your application in doc/compliance/apps/application.boundary.md
296
+ * Remember to keep your Logical Data Model up to date in doc/compliance/apps/data.logical.md
297
+ EOM
298
+
299
+ if newrelic
300
+ after_bundle do
301
+ generate "rails_template18f:newrelic"
302
+ end
303
+ register_announcement("New Relic", <<~EOM)
304
+ A New Relic config file has been written to `config/newrelic.yml`
305
+
306
+ See instructions in README to get started sending data to New Relic
307
+ EOM
308
+ end
309
+
310
+ if dap
311
+ after_bundle do
312
+ generate "rails_template18f:dap"
340
313
  end
314
+ register_announcement("Digital Analytics Program", "Update the DAP agency code in app/views/layouts/application.html.erb")
341
315
  end
342
316
 
343
317
  # infrastructure & deploy
344
318
  template "manifest.yml"
345
319
  copy_file "lib/tasks/cf.rake"
346
320
  directory "config/deployment"
347
- after_bundle do
348
- run "cp .gitignore .cfignore" unless skip_git?
349
- end
350
321
 
351
- if @terraform
322
+ if terraform
352
323
  after_bundle do
353
324
  generator_arguments = [
354
325
  "--cg-org=#{@cloud_gov_organization}",
355
- "--cg-staging=#{@cloud_gov_staging_space}",
356
- "--cg-prod=#{@cloud_gov_production_space}"
326
+ "--cg-staging=#{cloud_gov_staging_space}",
327
+ "--cg-prod=#{cloud_gov_production_space}"
357
328
  ]
358
329
  generate "rails_template18f:terraform", *generator_arguments
359
330
  end
@@ -371,10 +342,10 @@ end
371
342
  if @github_actions
372
343
  after_bundle do
373
344
  generator_arguments = [
374
- (@terraform ? "--terraform" : "--no-terraform"),
345
+ (terraform ? "--terraform" : "--no-terraform"),
375
346
  "--cg-org=#{@cloud_gov_organization}",
376
- "--cg-staging=#{@cloud_gov_staging_space}",
377
- "--cg-prod=#{@cloud_gov_production_space}"
347
+ "--cg-staging=#{cloud_gov_staging_space}",
348
+ "--cg-prod=#{cloud_gov_production_space}"
378
349
  ]
379
350
  generate "rails_template18f:github_actions", *generator_arguments
380
351
  end
@@ -391,10 +362,10 @@ end
391
362
  if @circleci_pipeline
392
363
  after_bundle do
393
364
  generator_arguments = [
394
- (@terraform ? "--terraform" : "--no-terraform"),
365
+ (terraform ? "--terraform" : "--no-terraform"),
395
366
  "--cg-org=#{@cloud_gov_organization}",
396
- "--cg-staging=#{@cloud_gov_staging_space}",
397
- "--cg-prod=#{@cloud_gov_production_space}"
367
+ "--cg-staging=#{cloud_gov_staging_space}",
368
+ "--cg-prod=#{cloud_gov_production_space}"
398
369
  ]
399
370
  generate "rails_template18f:circleci", *generator_arguments
400
371
  end
@@ -403,19 +374,6 @@ if @circleci_pipeline
403
374
  EOM
404
375
  end
405
376
 
406
- directory "doc"
407
- register_announcement("Documentation", <<~EOM)
408
- * Include a short description of your application in doc/compliance/apps/application.boundary.md
409
- * Remember to keep your Logical Data Model up to date in doc/compliance/apps/data.logical.md
410
- EOM
411
-
412
- if @dap
413
- after_bundle do
414
- generate "rails_template18f:dap"
415
- end
416
- register_announcement("Digital Analytics Program", "Update the DAP agency code in app/views/layouts/application.html.erb")
417
- end
418
-
419
377
  # setup production credentials file
420
378
  require "rails/generators"
421
379
  require "rails/generators/rails/encryption_key_file/encryption_key_file_generator"
@@ -444,6 +402,11 @@ EOM
444
402
 
445
403
  # ensure this is the very last step
446
404
  after_bundle do
405
+ if run_db_setup
406
+ rails_command "db:create"
407
+ rails_command "db:migrate"
408
+ end
409
+
447
410
  # x86_64-linux is required to install gems on any linux system such as cloud.gov or CI pipelines
448
411
  run "bundle lock --add-platform x86_64-linux"
449
412
 
@@ -453,10 +416,11 @@ after_bundle do
453
416
  run "bundle exec standardrb --fix"
454
417
 
455
418
  unless skip_git?
419
+ run "cp .gitignore .cfignore"
456
420
  git add: "."
457
421
  git commit: "-a -m 'Initial commit'"
458
422
  end
459
423
 
460
- # Post-install announcement
424
+ # Post-install announcements
461
425
  print_announcements
462
426
  end
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.2.0
4
+ version: 0.3.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-16 00:00:00.000000000 Z
11
+ date: 2022-02-17 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,6 +113,7 @@ files:
98
113
  - Rakefile
99
114
  - bin/console
100
115
  - bin/setup
116
+ - exe/rails_template_18f
101
117
  - lib/generators/rails_template18f/circleci/circleci_generator.rb
102
118
  - lib/generators/rails_template18f/circleci/templates/Dockerfile.tt
103
119
  - lib/generators/rails_template18f/circleci/templates/bin/ci-server-start
@@ -118,6 +134,11 @@ files:
118
134
  - lib/generators/rails_template18f/github_actions/templates/github/workflows/rspec.yml.tt
119
135
  - lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml
120
136
  - lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml
137
+ - lib/generators/rails_template18f/i18n/i18n_generator.rb
138
+ - lib/generators/rails_template18f/i18n/templates/config/locales/en.yml.tt
139
+ - lib/generators/rails_template18f/i18n/templates/config/locales/es.yml
140
+ - lib/generators/rails_template18f/i18n/templates/config/locales/fr.yml
141
+ - lib/generators/rails_template18f/i18n/templates/config/locales/zh.yml
121
142
  - lib/generators/rails_template18f/newrelic/newrelic_generator.rb
122
143
  - lib/generators/rails_template18f/newrelic/templates/config/newrelic.yml.tt
123
144
  - lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt
@@ -170,10 +191,6 @@ files:
170
191
  - templates/config/deployment/staging.yml
171
192
  - templates/config/environments/ci.rb
172
193
  - templates/config/environments/staging.rb
173
- - templates/config/locales/en.yml.tt
174
- - templates/config/locales/es.yml
175
- - templates/config/locales/fr.yml
176
- - templates/config/locales/zh.yml
177
194
  - templates/doc/adr/0001-record-architecture-decisions.md.tt
178
195
  - templates/doc/adr/0002-initial-architecture-decisions.md.tt
179
196
  - templates/doc/adr/0003-security-scans.md.tt