avo 3.0.1.beta9 → 3.0.1.beta11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -0
- data/app/assets/builds/avo.base.css +278 -36
- data/app/controllers/avo/application_controller.rb +12 -0
- data/app/views/layouts/avo/application.html.erb +1 -2
- data/avo.gemspec +1 -1
- data/bin/dev +2 -0
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/tailwindcss/install_generator.rb +58 -12
- data/lib/generators/avo/templates/tailwindcss/avo.tailwind.css +5 -3
- data/lib/generators/avo/templates/tailwindcss/tailwind.config.js +11 -0
- data/lib/tasks/avo_tasks.rake +33 -5
- data/public/avo-assets/avo.base.css +51 -3957
- data/tailwind.preset.js +144 -0
- metadata +4 -2
|
@@ -11,17 +11,30 @@ module Generators
|
|
|
11
11
|
|
|
12
12
|
def create_files
|
|
13
13
|
unless tailwindcss_installed?
|
|
14
|
+
say "Installing Tailwindcss"
|
|
14
15
|
system "./bin/bundle add tailwindcss-rails"
|
|
15
16
|
system "./bin/rails tailwindcss:install"
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
unless Rails.root.join("
|
|
19
|
-
say "
|
|
20
|
-
copy_file template_path("
|
|
19
|
+
unless (path = Rails.root.join("config", "avo", "tailwind.config.js")).exist?
|
|
20
|
+
say "Generating the Avo config file."
|
|
21
|
+
copy_file template_path("tailwind.config.js"), path
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
unless (path = Rails.root.join("app", "assets", "stylesheets", "avo", "tailwindcss")).exist?
|
|
25
|
+
say "Generating the tailwindcss directory."
|
|
26
|
+
directory ::Avo::Engine.root.join("app", "assets", "stylesheets", "css", "tailwindcss"), path
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
unless (path = Rails.root.join("app", "assets", "stylesheets", "avo" ,"tailwind.css")).exist?
|
|
31
|
+
say "Add default tailwind.css"
|
|
32
|
+
copy_file template_path("avo.tailwind.css"), path
|
|
21
33
|
end
|
|
22
34
|
|
|
23
35
|
if Rails.root.join("Procfile.dev").exist?
|
|
24
|
-
|
|
36
|
+
say "Add #{cmd = "avo_css: yarn avo:tailwindcss --watch"} to Procfile.dev"
|
|
37
|
+
append_to_file "Procfile.dev", "#{cmd}\n"
|
|
25
38
|
else
|
|
26
39
|
say "Add default Procfile.dev"
|
|
27
40
|
copy_file template_path("Procfile.dev"), "Procfile.dev"
|
|
@@ -30,17 +43,50 @@ module Generators
|
|
|
30
43
|
run "gem install foreman"
|
|
31
44
|
end
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
script_name = "avo:tailwindcss"
|
|
47
|
+
script_command = "tailwindcss -i ./app/assets/stylesheets/avo/tailwind.css -o ./app/assets/builds/avo.tailwind.css -c ./config/avo/tailwind.config.js --minify"
|
|
48
|
+
pretty_script_command = "\"#{script_name}\": \"#{script_command}\""
|
|
49
|
+
|
|
50
|
+
if (path = Rails.root.join("package.json")).exist?
|
|
51
|
+
say "Add #{pretty_script_command} to package.json"
|
|
52
|
+
json_data = JSON.parse(File.read(path))
|
|
53
|
+
json_data["scripts"] ||= {}
|
|
54
|
+
json_data["scripts"][script_name] = script_command
|
|
55
|
+
|
|
56
|
+
File.open(path, 'w') do |file|
|
|
57
|
+
file.write(JSON.pretty_generate(json_data) + "\n")
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
say "package.json not found.", :yellow
|
|
61
|
+
say "Ensure you have the following script in your package.json file.", :yellow
|
|
62
|
+
say "\"scripts\": {\n" \
|
|
63
|
+
" #{pretty_script_command}\n" \
|
|
64
|
+
"}", :green
|
|
37
65
|
end
|
|
38
66
|
|
|
39
|
-
|
|
40
|
-
prepend_to_file Rails.root.join("app", "views", "avo", "partials", "_pre_head.html.erb"), "<%= stylesheet_link_tag \"avo.tailwind.css\", media: \"all\" %>"
|
|
67
|
+
rake_enhance = <<~RUBY
|
|
41
68
|
|
|
42
|
-
|
|
43
|
-
|
|
69
|
+
Rake::Task["assets:precompile"].enhance(["avo:sym_link"])
|
|
70
|
+
RUBY
|
|
71
|
+
|
|
72
|
+
if (path = Rails.root.join("Rakefile")).exist?
|
|
73
|
+
say "Add #{rake_enhance.strip} to Rakefile"
|
|
74
|
+
append_to_file path, rake_enhance
|
|
75
|
+
else
|
|
76
|
+
say "Rakefile not found.", :yellow
|
|
77
|
+
say "Ensure you have the following code in your Rakefile file.", :yellow
|
|
78
|
+
say rake_enhance, :green
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
say "Make sure you run \"bundle exec rake avo:sym_link\" before compiling the assets with the \"#{script_name}\" task.", :green
|
|
82
|
+
if (path = Rails.root.join("bin", "dev")).exist?
|
|
83
|
+
lines = File.read(path).lines
|
|
84
|
+
|
|
85
|
+
# Insert the task after the shebang line (the first line)
|
|
86
|
+
lines.insert(1, "bundle exec rake avo:sym_link")
|
|
87
|
+
|
|
88
|
+
File.write(path, lines.join)
|
|
89
|
+
end
|
|
44
90
|
end
|
|
45
91
|
|
|
46
92
|
no_tasks do
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
@
|
|
2
|
-
|
|
3
|
-
@
|
|
1
|
+
@import 'tailwindcss/base';
|
|
2
|
+
# Have all of Avo's custom and plugins styles available.
|
|
3
|
+
@import '../../../../tmp/avo/base.css';
|
|
4
|
+
@import 'tailwindcss/components';
|
|
5
|
+
@import 'tailwindcss/utilities';
|
|
4
6
|
|
|
5
7
|
/*
|
|
6
8
|
|
data/lib/tasks/avo_tasks.rake
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
# desc 'Explaining what the task does'
|
|
2
|
-
# task :avo do
|
|
3
|
-
# # Task goes here
|
|
4
|
-
# end
|
|
5
|
-
|
|
6
1
|
desc "Runs the update command for all Avo gems."
|
|
7
2
|
task "avo:update" do
|
|
8
3
|
system "bundle update avo avo-pro avo-advanced avo-dashboards avo_filters avo-menu avo_upgrade"
|
|
@@ -63,3 +58,36 @@ task "avo:gem_paths" do
|
|
|
63
58
|
# avo:/Users/adrian/work/avocado/avo-3,avo_filters:/Users/adrian/work/avocado/advanced/avo_filters
|
|
64
59
|
puts result
|
|
65
60
|
end
|
|
61
|
+
|
|
62
|
+
desc "Symlinks all Avo gems to tmp/avo/packages"
|
|
63
|
+
task "avo:sym_link" do
|
|
64
|
+
base_path = Rails.root.join("tmp", "avo").to_s.gsub("/spec/dummy", "")
|
|
65
|
+
packages_path = "#{base_path}/packages"
|
|
66
|
+
if Dir.exist?(packages_path)
|
|
67
|
+
`rm -rf #{packages_path}/*`
|
|
68
|
+
else
|
|
69
|
+
`mkdir -p #{packages_path}`
|
|
70
|
+
`touch #{packages_path}/.keep`
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
["avo", "avo-advanced", "avo-pro", "avo-dynamic_filters", "avo-dashboards", "avo-menu"].each do |gem|
|
|
74
|
+
path = `bundle show #{gem} 2> /dev/null`.chomp
|
|
75
|
+
|
|
76
|
+
unless path.empty?
|
|
77
|
+
puts "[Avo->] Linking #{gem} to #{path}"
|
|
78
|
+
`ln -s #{path} #{packages_path}/#{gem}`
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
base_css_path = Avo::Engine.root.join("app", "assets", "builds", "avo.base.css")
|
|
83
|
+
dest_css_path = "#{base_path}/base.css"
|
|
84
|
+
`rm #{dest_css_path}` if File.exist?("#{dest_css_path}")
|
|
85
|
+
puts "[Avo->] Linking avo.base.css to #{base_css_path}"
|
|
86
|
+
`ln -s #{base_css_path} #{dest_css_path}`
|
|
87
|
+
|
|
88
|
+
base_preset_path = Avo::Engine.root.join("tailwind.preset.js")
|
|
89
|
+
dest_preset_path = "#{base_path}/tailwind.preset.js"
|
|
90
|
+
`rm #{dest_preset_path}` if File.exist?("#{dest_preset_path}")
|
|
91
|
+
puts "[Avo->] Linking tailwind.preset.js to #{base_preset_path}"
|
|
92
|
+
`ln -s #{base_preset_path} #{dest_preset_path}`
|
|
93
|
+
end
|