Module: Ariadne::ViewComponents::Commands
- Defined in:
- lib/ariadne/view_components/commands.rb
Overview
commands related to the upstream Tailwindcss project
Defined Under Namespace
Classes: ExecutableNotFoundException, UnsupportedPlatformException
Class Method Summary
collapse
Class Method Details
.compile_command(debug: false, **kwargs) ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/ariadne/view_components/commands.rb', line 62
def compile_command(debug: false, **kwargs)
[
executable(**kwargs),
"-i", local_path("app/assets/stylesheets/ariadne_view_components.css"),
"-o", "app/assets/builds/ariadne_view_components.css",
"-c", local_path("tailwind.config.js"),
].tap do |command|
command << "--minify" unless debug
end
end
|
.executable(exe_path: File.expand_path(File.join(__dir__, "..", "..", "..", "exe"))) ⇒ Object
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
54
55
56
57
58
59
60
|
# File 'lib/ariadne/view_components/commands.rb', line 22
def executable(
exe_path: File.expand_path(File.join(__dir__, "..", "..", "..", "exe"))
)
if Ariadne::ViewComponents::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match(p) }
raise UnsupportedPlatformException, " ariadne_view_components does not support the \#{platform} platform\n Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation\n MESSAGE\n end\n\n exe_path = Dir.glob(File.expand_path(File.join(exe_path, \"*\", \"tailwindcss\"))).find do |f|\n Gem::Platform.match(File.basename(File.dirname(f)))\n end\n\n if exe_path.nil?\n raise ExecutableNotFoundException, <<~MESSAGE\n Cannot find the tailwindcss executable for \#{platform} in \#{exe_path}\n\n If you're using bundler, please make sure you're on the latest bundler version:\n\n gem install bundler\n bundle update --bundler\n\n Then make sure your lock file includes this platform by running:\n\n bundle lock --add-platform \#{platform}\n bundle install\n\n See `bundle lock --help` output for details.\n\n If you're still seeing this message after taking those steps, try running\n `bundle config` and ensure `force_ruby_platform` isn't set to `true`. See\n https://github.com/rails/tailwindcss-rails#check-bundle_force_ruby_platform\n for more details.\n MESSAGE\n end\n\n exe_path\nend\n"
|
.local_path(path) ⇒ Object
80
81
82
83
|
# File 'lib/ariadne/view_components/commands.rb', line 80
def local_path(path)
root = File.expand_path(File.join(__dir__, "..", "..", ".."))
File.join(root, path)
end
|
18
19
20
|
# File 'lib/ariadne/view_components/commands.rb', line 18
def platform
[:cpu, :os].map { |m| Gem::Platform.local.send(m) }.join("-")
end
|
.watch_command(poll: false, **kwargs) ⇒ Object
73
74
75
76
77
78
|
# File 'lib/ariadne/view_components/commands.rb', line 73
def watch_command(poll: false, **kwargs)
compile_command(**kwargs).tap do |command|
command << "-w"
command << "-p" if poll
end
end
|