diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-11-12 20:29:35 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2017-11-12 20:29:35 +0100 |
commit | 5744d00f5d22bbf1efde180431eb3daac76007e8 (patch) | |
tree | 1fe1b68f9c91b341fe016d6e5a31363d6d59ef33 /railties | |
parent | bb30f05f3858f97791f0e1530e625b7ea2c6c5e2 (diff) | |
download | rails-5744d00f5d22bbf1efde180431eb3daac76007e8.tar.gz rails-5744d00f5d22bbf1efde180431eb3daac76007e8.tar.bz2 rails-5744d00f5d22bbf1efde180431eb3daac76007e8.zip |
Revert displaying master key generation info on `rails new`.
It's already a default for new apps, like so many others, so
no need to flaunt it.
Diffstat (limited to 'railties')
3 files changed, 20 insertions, 23 deletions
diff --git a/railties/lib/rails/commands/credentials/credentials_command.rb b/railties/lib/rails/commands/credentials/credentials_command.rb index 1ef7c1f343..e5d3d01431 100644 --- a/railties/lib/rails/commands/credentials/credentials_command.rb +++ b/railties/lib/rails/commands/credentials/credentials_command.rb @@ -53,6 +53,7 @@ module Rails def ensure_master_key_has_been_added master_key_generator.add_master_key_file + master_key_generator.ignore_master_key_file end def ensure_credentials_have_been_added diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index b7357025ef..a99037576d 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -162,20 +162,14 @@ module Rails return if options[:pretend] || options[:dummy_app] require "rails/generators/rails/master_key/master_key_generator" - - after_bundle do - Rails::Generators::MasterKeyGenerator.new([], quiet: options[:quiet]).add_master_key_file - end + Rails::Generators::MasterKeyGenerator.new([], quiet: options[:quiet]).add_master_key_file_silently end def credentials return if options[:pretend] || options[:dummy_app] require "rails/generators/rails/credentials/credentials_generator" - - after_bundle do - Rails::Generators::CredentialsGenerator.new([], quiet: options[:quiet]).add_credentials_file_silently - end + Rails::Generators::CredentialsGenerator.new([], quiet: options[:quiet]).add_credentials_file_silently end def database_yml diff --git a/railties/lib/rails/generators/rails/master_key/master_key_generator.rb b/railties/lib/rails/generators/rails/master_key/master_key_generator.rb index 23dbed20ac..29d83f5d81 100644 --- a/railties/lib/rails/generators/rails/master_key/master_key_generator.rb +++ b/railties/lib/rails/generators/rails/master_key/master_key_generator.rb @@ -20,29 +20,31 @@ module Rails log "If you lose the key, no one, including you, can access anything encrypted with it." log "" - create_file MASTER_KEY_PATH, key + add_master_key_file_silently key log "" - - ignore_master_key_file end end - private - def ignore_master_key_file - if File.exist?(".gitignore") - unless File.read(".gitignore").include?(key_ignore) - log "Ignoring #{MASTER_KEY_PATH} so it won't end up in Git history:" - log "" - append_to_file ".gitignore", key_ignore - log "" - end - else - log "IMPORTANT: Don't commit #{MASTER_KEY_PATH}. Add this to your ignore file:" - log key_ignore, :on_green + def add_master_key_file_silently(key = nil) + create_file MASTER_KEY_PATH, key || ActiveSupport::EncryptedFile.generate_key + end + + def ignore_master_key_file + if File.exist?(".gitignore") + unless File.read(".gitignore").include?(key_ignore) + log "Ignoring #{MASTER_KEY_PATH} so it won't end up in Git history:" + log "" + append_to_file ".gitignore", key_ignore log "" end + else + log "IMPORTANT: Don't commit #{MASTER_KEY_PATH}. Add this to your ignore file:" + log key_ignore, :on_green + log "" end + end + private def key_ignore [ "", "# Ignore master key for decrypting credentials and more.", "/#{MASTER_KEY_PATH}", "" ].join("\n") end |