Class: Unmagic::Passkeys::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/unmagic/passkeys/install_generator.rb

Overview

Installs unmagic-passkeys into a host app: copies the credentials migration (matching the host’s primary-key type), imports the JavaScript, and prints the remaining controller/route/view wiring to do.

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject



19
20
21
22
# File 'lib/generators/unmagic/passkeys/install_generator.rb', line 19

def create_migration_file
  migration_template "create_unmagic_passkeys_credentials.rb.tt",
    "db/migrate/create_unmagic_passkeys_credentials.rb"
end

#import_javascriptObject



24
25
26
27
28
29
30
# File 'lib/generators/unmagic/passkeys/install_generator.rb', line 24

def import_javascript
  application_js = "app/javascript/application.js"

  if File.exist?(File.join(destination_root, application_js))
    append_to_file application_js, %(import "unmagic/passkeys"\n)
  end
end

#show_post_installObject



32
33
34
# File 'lib/generators/unmagic/passkeys/install_generator.rb', line 32

def show_post_install
  readme "POST_INSTALL" if behavior == :invoke
end