Class: StandardId::Google::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- StandardId::Google::Generators::InstallGenerator
- Defined in:
- lib/generators/standard_id/google/install/install_generator.rb
Overview
Installs the Google provider's credentials block in a host Rails app.
Writes config/initializers/standard_id_google.rb — a separate file
from config/initializers/standard_id.rb on purpose. The provider is
opt-in per app, so its credentials should be removable by deleting one
file, and standard_id's own install generator must stay free to
overwrite its initializer without clobbering these values.
Initializers load alphabetically, so standard_id.rb runs before
standard_id_google.rb — the base configuration is already applied by
the time this file sets the social.google_* fields.
Idempotent: re-running skips an initializer that is already there.
--skip-initializer opts out; --force overwrites.
Constant Summary collapse
- INITIALIZER_PATH =
"config/initializers/standard_id_google.rb"
Instance Method Summary collapse
Instance Method Details
#copy_initializer ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/generators/standard_id/google/install/install_generator.rb', line 41 def copy_initializer if [:skip_initializer] say_status("skip", "#{INITIALIZER_PATH} (--skip-initializer)", :yellow) return end if File.exist?(File.join(destination_root, INITIALIZER_PATH)) && ![:force] say_status("identical", "#{INITIALIZER_PATH} (already exists; pass --force to overwrite)", :blue) return end template "initializer.rb.erb", INITIALIZER_PATH, force: [:force] end |
#print_env_hint ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/generators/standard_id/google/install/install_generator.rb', line 55 def print_env_hint return if [:skip_initializer] say "" say "=" * 79 say "StandardId Google installed." say "" say "Set these in the host's environment (1Password / DO app spec / .env):" say "" say " GOOGLE_OAUTH_CLIENT_ID the OAuth 2.0 Web application client ID" say " GOOGLE_OAUTH_CLIENT_SECRET its client secret" say "" say "Register /auth/callback/google as an authorized redirect URI in the" say "Google Cloud console for EVERY origin you serve — the console matches" say "the redirect exactly, so staging and production each need their own." say "=" * 79 say "" end |