Class: SpreePacketa::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/spree_packeta/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_initializerObject



10
11
12
13
# File 'lib/generators/spree_packeta/install_generator.rb', line 10

def copy_initializer
  template 'initializer.rb', 'config/initializers/spree_packeta.rb'
  say 'Initializer created at config/initializers/spree_packeta.rb', :green
end

#copy_migrationsObject



15
16
17
18
# File 'lib/generators/spree_packeta/install_generator.rb', line 15

def copy_migrations
  rake 'railties:install:migrations FROM=spree_packeta'
  say 'Migrations copied', :green
end

#install_shipping_methodObject



29
30
31
32
33
34
35
36
37
# File 'lib/generators/spree_packeta/install_generator.rb', line 29

def install_shipping_method
  if options[:skip_shipping_method]
    say 'Skipping shipping method installation', :yellow
  elsif yes?('Install Packeta shipping method now? (yes/no)')
    rake 'spree_packeta:install'
  else
    say 'You can install the shipping method later with: rake spree_packeta:install', :yellow
  end
end

#run_migrationsObject



20
21
22
23
24
25
26
27
# File 'lib/generators/spree_packeta/install_generator.rb', line 20

def run_migrations
  if options[:auto_run_migrations] || yes?('Run migrations now? (yes/no)')
    rake 'db:migrate'
    say 'Migrations completed', :green
  else
    say 'Skipping migrations. Run `rails db:migrate` manually', :yellow
  end
end

#show_readmeObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/generators/spree_packeta/install_generator.rb', line 39

def show_readme
  say ''
  say '=' * 80, :green
  say 'Spree Packeta Installation Complete!', :green
  say '=' * 80, :green
  say ''
  say 'Next steps:', :yellow
  say ''
  say '  1. Add your Packeta credentials to .env:', :cyan
  say '     PACKETA_API_PASSWORD=your_api_password'
  say '     PACKETA_ESHOP=your_eshop_id'
  say '     PACKETA_WSDL_PATH=file:///path/to/soap.wsdl'
  say '     [email protected]'
  say ''
  say '  2. Restart your Rails server', :cyan
  say ''
  say '  3. Configure shipping method in Spree admin', :cyan
  say '     or run: rake spree_packeta:install (if you skipped it)'
  say ''
  say '  4. Frontend integration:', :cyan
  say '     See FRONTEND_INTEGRATION.md for React/frontend setup'
  say ''
  say 'Documentation:', :yellow
  say '  - README.md - General usage'
  say '  - FRONTEND_INTEGRATION.md - Frontend setup guide'
  say ''
end