Class: WhatsAppNotifier::Generators::InstallServiceGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_to_gitignoreObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/whatsapp_notifier/install_service_generator.rb', line 12

def add_to_gitignore
  entries = [
    "# WhatsApp Service",
    "/whatsapp_service/node_modules",
    "/whatsapp_service/.wwebjs_cache",
    "/whatsapp_service/.wwebjs_auth"
  ]
  content = File.exist?(".gitignore") ? File.read(".gitignore") : ""
  missing_entries = entries.reject { |entry| content.include?(entry) }
  return if missing_entries.empty?

  append_to_file ".gitignore", "\n#{missing_entries.join("\n")}\n"
end

#copy_service_filesObject



8
9
10
# File 'lib/generators/whatsapp_notifier/install_service_generator.rb', line 8

def copy_service_files
  directory '.', 'whatsapp_service'
end

#show_readmeObject



26
27
28
29
30
# File 'lib/generators/whatsapp_notifier/install_service_generator.rb', line 26

def show_readme
  say "\nWhatsApp Service installed in /whatsapp_service", :green
  say "Make sure you have Bun installed: https://bun.sh", :yellow
  say "To start the service manually: cd whatsapp_service && bun index.ts", :yellow
end