Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: check tailwindcss integration with github repo #2325

Merged
merged 28 commits into from Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/feature-tests.yml
Expand Up @@ -97,8 +97,8 @@ jobs:
NODE_ENV: production
run: |
yarn build:js
yarn build:custom-js
yarn build:css
yarn build:custom-js

- name: Run tests
id: run_tests
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/system-tests.yml
Expand Up @@ -90,18 +90,18 @@ jobs:
- name: Yarn install
run: yarn

- name: Run avo:sym_link
run: |
bundle exec rake avo:sym_link

- name: Build assets
env:
RAILS_ENV: production
NODE_ENV: production
run: |
yarn build:js
yarn build:custom-js
yarn build:css
yarn build:custom-js

- name: Run avo:sym_link
run: |
bundle exec rake avo:sym_link

- name: Run tests
id: run_tests
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/test-tailwindcss-integration.yml
Expand Up @@ -35,14 +35,26 @@ jobs:
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3

- name: Set up repo
- name: Add Avo
run: |
bundle add "avo" --git='https://github.com/avo-hq/avo.git' --ref="${{ github.sha }}"
bundle install
bin/rails generate avo:install
bundle exec rake avo:build-assets

- name: Add the TailwindCSS integration
run: |
bin/rails app:template LOCATION='https://avohq.io/app-template'
yarn init --yes
bin/rails generate avo:tailwindcss:install
bin/rails generate avo:tool custom_tool

- name: Add custom CSS
run: |
echo '<div class="aspect-video break-before-avoid float-end order-9 col-end-13 box-decoration-slice bg-gradient-to-r from-indigo-600 to-pink-500 text-white text-2xl font-bold">Test<br>DIV</div>' >> ./app/views/avo/tools/custom_tool.html.erb
rake assets:precompile

- name: Compile assets
run: |
bundle exec rake assets:precompile

- name: Write test file
uses: DamianReeves/write-file-action@master
Expand Down Expand Up @@ -74,6 +86,7 @@ jobs:
# Test if the built assets containe these classes
test_classes.each do |class_name|
raise "Failed to find the custom classes." unless contents.include?(class_name)
puts "[Avo->] Found #{class_name}."
end
write-mode: append

Expand Down
2 changes: 1 addition & 1 deletion lib/generators/avo/templates/tailwindcss/avo.tailwind.css
@@ -1,6 +1,6 @@
@import 'tailwindcss/base';
/* Have all of Avo's custom and plugins styles available. */
@import '../../../../tmp/avo/base.css';
@import '../../../../tmp/avo/avo.base.css';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

Expand Down
36 changes: 29 additions & 7 deletions lib/tasks/avo_tasks.rake
Expand Up @@ -82,20 +82,42 @@ task "avo:sym_link" do
end

puts "[Avo->] Linking #{gem} to #{path}"
`ln -s #{path} #{packages_path}/#{gem}`
symlink_path path, "#{packages_path}/#{gem}"
end

base_css_path = Avo::Engine.root.join("app", "assets", "builds", "avo.base.css")
dest_css_path = "#{base_path}/base.css"
`rm #{dest_css_path}` if File.exist?("#{dest_css_path}")
builds_css_path = Avo::Engine.root.join("app", "assets", "builds", "avo.base.css")
public_css_path = Avo::Engine.root.join("public", "avo-assets", "avo.base.css")

base_css_path = if File.exist?(builds_css_path.to_s)
builds_css_path
elsif File.exist?(public_css_path.to_s)
public_css_path
else
raise "[Avo->] Failed to find avo.base.css."
end

dest_css_path = "#{base_path}/avo.base.css"
remove_file_if_exists dest_css_path

puts "[Avo->] Linking avo.base.css to #{base_css_path}"
`ln -s #{base_css_path} #{dest_css_path}`
symlink_path base_css_path, dest_css_path

base_preset_path = Avo::Engine.root.join("tailwind.preset.js")
dest_preset_path = "#{base_path}/tailwind.preset.js"
`rm #{dest_preset_path}` if File.exist?("#{dest_preset_path}")
remove_file_if_exists dest_preset_path

puts "[Avo->] Linking tailwind.preset.js to #{base_preset_path}"
`ln -s #{base_preset_path} #{dest_preset_path}`
symlink_path base_preset_path, dest_preset_path
end

def remove_file_if_exists(path)
`rm #{path}` if File.exist?(path) || File.symlink?(path)
end

def symlink_path(from, to)
remove_file_if_exists to

`ln -s #{from} #{to}`
end

desc "Installs yarn dependencies for Avo"
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/application.rb
Expand Up @@ -16,7 +16,7 @@
Bundler.require(*Rails.groups)

# Tell spring where the new dummy ap is located
Spring.application_root = "."
Spring.application_root = "." if defined?(Spring)

module Avo3Dummy
class Application < Rails::Application
Expand Down
2 changes: 1 addition & 1 deletion tailwind.preset.js
Expand Up @@ -2,8 +2,8 @@ const plugin = require('tailwindcss/plugin')
const colors = require('tailwindcss/colors')
const defaultTheme = require('tailwindcss/defaultTheme')

const { primary, blue, gray } = require('./tailwind.custom')
const avoPath = require('child_process').execSync('bundle show avo', { encoding: 'utf-8' }).trim()
const { primary, blue, gray } = require('./tailwind.custom')

function contentPaths(basePath) {
return [
Expand Down