Class: Wabi::Generators::ThemeGenerator

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

Instance Method Summary collapse

Instance Method Details

#fetch_and_writeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/wabi/generators/theme_generator.rb', line 15

def fetch_and_write
  lockfile = Wabi::Lockfile.load(File.join(destination_root, "config/wabi.lock.json"))
  base = lockfile.registry  # e.g. https://wabikit.dev/r OR file:///abs/path

  shared = fetch("#{base}/themes/_shared.css", label: "_shared")
  body   = fetch("#{base}/themes/#{slug}.css", label: slug)

  target = File.join(destination_root, "app/assets/tailwind/wabi/tokens.css")
  FileUtils.mkdir_p(File.dirname(target))
  File.write(target, [shared, body].join("\n"))

  say "  theme  → #{slug}", :green
  say "  wrote  app/assets/tailwind/wabi/tokens.css", :green
  say "         Run `bin/rails tailwindcss:build` to compile the new palette.", :cyan
end