Class: Kanso::InstallGenerator

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

Overview

lib/generators/kanso/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#installObject



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
# File 'lib/generators/kanso/install/install_generator.rb', line 16

def install
  say "Kanso: Starting installation...", :cyan

  # --- Prerequisite Checks based on observable facts ---
  css_path = application_root.join("app/assets/tailwind/application.css")
  root_config_path = application_root.join("tailwind.config.js")
  legacy_config_path = application_root.join("config/tailwind.config.js")

  unless File.exist?(css_path)
    say "\nKanso Installation Blocked", :red
    say "--------------------------", :red
    say "Could not find the required Tailwind CSS entrypoint at:", :yellow
    say "`app/assets/tailwind/application.css`", :bold
    say "\nThis file is required for Kanso to be installed correctly.", :yellow
    say "Please run `rails tailwindcss:install` to generate it, then re-run this generator.", :cyan
    return
  end

  if File.exist?(legacy_config_path)
    say "\nKanso Installation Blocked", :red
    say "--------------------------", :red
    say "A Tailwind configuration file was found at:", :yellow
    say "`config/tailwind.config.js`", :bold
    say "\nTo ensure a single source of truth, Kanso requires the configuration to be at the project root.", :yellow
    say "Please migrate this file to `tailwind.config.js` at the root of your project, then re-run this generator.", :cyan
    return
  end

  # --- Core Logic ---
  configure_tailwind_config(root_config_path)
  configure_application_css(css_path, root_config_path)

  say "Kanso: Installation complete! ✨", :green
end