Class: Wabi::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_theme_controllerObject



21
22
23
24
25
# File 'lib/wabi/generators/install_generator.rb', line 21

def copy_theme_controller
  copy_file "controllers/wabi/theme_controller.js",
            "app/javascript/controllers/wabi/theme_controller.js",
            force: options[:force], skip: !options[:force]
end

#copy_tokensObject



16
17
18
19
# File 'lib/wabi/generators/install_generator.rb', line 16

def copy_tokens
  copy_file "tokens.css", "app/assets/tailwind/wabi/tokens.css",
            force: options[:force], skip: !options[:force]
end

#init_lockfileObject



27
28
29
30
31
32
33
# File 'lib/wabi/generators/install_generator.rb', line 27

def init_lockfile
  path = File.join(destination_root, "config/wabi.lock.json")
  FileUtils.mkdir_p(File.dirname(path))
  return if File.exist?(path)
  lockfile = Wabi::Lockfile.load(path)
  lockfile.save
end


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/wabi/generators/install_generator.rb', line 35

def print_next_steps
  say "\n  Wabi installed. Next steps:", :green
  say ""
  say "    1. Import tokens AFTER the Tailwind import in app/assets/tailwind/application.css:"
  say "         @import \"tailwindcss\";"
  say "         @import \"./wabi/tokens.css\";"
  say ""
  say "    2. Use 'tailwind' (not 'application') in your stylesheet link tag:"
  say "         stylesheet_link_tag \"tailwind\", \"data-turbo-track\": \"reload\""
  say "       (Rails 8.1's :app symbol also works if you keep the default ERB layout.)"
  say ""
  say "    3. Mount the theme controller on <html> in your layout:"
  say "         <html data-controller=\"wabi--theme\">"
  say ""
  say "    4. Add components from the registry:"
  say "         bin/rails g wabi:add button input card"
  say "       Components autoload under Components::UI::* (Phlex 2.x convention)."
  say "       Render them as:  render Components::UI::Button.new"
  say ""
  say "    5. If Tailwind doesn't pick up component classes, add this near the top of"
  say "       application.css (Tailwind 4 normally auto-detects .rb files, but in"
  say "       unusual asset paths an explicit @source helps):"
  say "         @source \"../../components/**/*.rb\";"
  say ""
  say "    Run wabi:install --force later to refresh tokens.css and theme_controller.js"
  say "    after a gem upgrade (your wabi.lock.json is preserved)."
end