Class: ElderDocs::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/elder_docs/cli.rb

Instance Method Summary collapse

Instance Method Details

#deployObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/elder_docs/cli.rb', line 16

def deploy
  say '🚀 Building ElderDocs frontend...', :green
  say '📝 Note: definitions.json and articles.json are loaded dynamically at runtime', :cyan
  say '   No need to rebuild when you update your API definitions!', :cyan
  say ''
  
  output_path = File.expand_path(options[:output] || default_output_path, Dir.pwd)
  ElderDocs.config.output_path = output_path
  
  # Reload config to get latest settings
  ElderDocs.config.load_config_file
  
  # Build frontend only (no data compilation needed)
  generator = Generator.new(
    definitions_path: nil,  # Not needed for dynamic mode
    articles_path: nil,      # Not needed for dynamic mode
    output_path: output_path,
    api_server: options[:api_server],
    skip_build: options[:skip_build],
    force_build: options[:force_build]
  )
  
  begin
    generator.build_frontend_only!
    say '✅ Frontend built successfully!', :green
    say "📦 Assets placed in: #{generator.output_path}", :cyan
    say ''
    say '✨ Your documentation is now live!', :green
    say '   Edit definitions.json and articles.json - changes appear instantly!', :cyan
  rescue Generator::ValidationError => e
    say "❌ Validation Error: #{e.message}", :red
    exit 1
  rescue StandardError => e
    say "❌ Error: #{e.message}", :red
    say e.backtrace.first(5).join("\n"), :yellow if options[:verbose]
    exit 1
  end
end

#versionObject



56
57
58
# File 'lib/elder_docs/cli.rb', line 56

def version
  say "ElderDocs version #{ElderDocs::VERSION}", :green
end