Class: RailsForge::Wizard

Inherits:
Object
  • Object
show all
Defined in:
lib/railsforge/wizard.rb

Overview

Wizard class provides interactive project setup

Constant Summary collapse

PROJECT_TYPES =

Project types available

{
  "saas" => {
    name: "SaaS Application",
    description: "Full-featured SaaS with auth, admin, payments",
    features: %w[authentication admin background_jobs]
  },
  "blog" => {
    name: "Blog",
    description: "Content blog with articles and comments",
    features: %w[authentication comments]
  },
  "api" => {
    name: "API Only",
    description: "RESTful API with JWT authentication",
    features: %w[jwt_auth background_jobs]
  },
  "admin_app" => {
    name: "Admin Dashboard",
    description: "Admin panel with CRUD operations",
    features: %w[authentication admin]
  },
  "standard" => {
    name: "Standard Rails",
    description: "Basic Rails application",
    features: []
  }
}.freeze

Instance Method Summary collapse

Constructor Details

#initializeWizard

Initialize wizard



39
40
41
42
43
44
45
46
47
# File 'lib/railsforge/wizard.rb', line 39

def initialize
  @options = {
    project_name: nil,
    project_type: nil,
    features: [],
    generators: [],
    analyze_after: false
  }
end

Instance Method Details

#executeObject

Execute the wizard choices



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/railsforge/wizard.rb', line 80

def execute
  return unless @options[:project_name]

  puts ""
  puts "Creating Rails app: #{@options[:project_name]}"
  puts ""

  # Build options for RailsForge::Generator
  generator_options = {
    profile: @options[:project_type]
  }

  # Add features
  generator_options[:auth] = "devise" if @options[:features].include?("authentication")
  generator_options[:admin] = "activeadmin" if @options[:features].include?("admin")
  generator_options[:jobs] = "sidekiq" if @options[:features].include?("background_jobs")

  begin
    # Create the Rails app
    result = RailsForge::Generator.create_app(@options[:project_name], generator_options)
    puts result
    puts ""

    # Run selected generators
    run_generators if @options[:generators].any?

    # Run analysis if requested
    run_analysis if @options[:analyze_after]

    puts ""
    puts "✓ Project created successfully!"
  rescue => e
    puts "Error: #{e.message}"
  end
end

#runHash

Run the interactive wizard

Returns:

  • (Hash)

    Selected options



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/railsforge/wizard.rb', line 51

def run
  puts ""
  puts "=" * 60
  puts "RailsForge Project Wizard"
  puts "=" * 60
  puts ""

  # Step 1: Project name
  ask_project_name

  # Step 2: Project type
  ask_project_type

  # Step 3: Features
  ask_features

  # Step 4: Generators
  ask_generators

  # Step 5: Analysis
  ask_analysis

  # Summary
  show_summary

  @options
end