|
| 1 | +#! /usr/bin/env bash |
| 2 | +# reproduce the documented user journey for installing and running tailwindcss-rails |
| 3 | +# this is run in the CI pipeline, non-zero exit code indicates a failure |
| 4 | + |
| 5 | +set -o pipefail |
| 6 | +set -eux |
| 7 | + |
| 8 | +# set up dependencies |
| 9 | +rm -f Gemfile.lock |
| 10 | +bundle remove actionmailer |
| 11 | +bundle add rails --skip-install ${RAILSOPTS:-} |
| 12 | +bundle install --prefer-local |
| 13 | + |
| 14 | +# do our work a directory with spaces in the name (#176, #184) |
| 15 | +rm -rf "My Workspace" |
| 16 | +mkdir "My Workspace" |
| 17 | +pushd "My Workspace" |
| 18 | + |
| 19 | +# create a rails app |
| 20 | +bundle exec rails -v |
| 21 | +bundle exec rails new test-upgrade --skip-bundle |
| 22 | +pushd test-upgrade |
| 23 | + |
| 24 | +# make sure to use the same version of rails (e.g., install from git source if necessary) |
| 25 | +bundle remove rails --skip-install |
| 26 | +bundle add rails --skip-install ${RAILSOPTS:-} |
| 27 | + |
| 28 | +# set up app with tailwindcss-rails v3 and tailwindcss-ruby v3 |
| 29 | +bundle add tailwindcss-rails --skip-install --version 3.3.0 |
| 30 | +bundle add tailwindcss-ruby --skip-install --version 3.4.17 |
| 31 | +bundle install --prefer-local |
| 32 | +bundle show --paths |
| 33 | +bundle binstubs --all |
| 34 | + |
| 35 | +# install tailwindcss |
| 36 | +bin/rails tailwindcss:install |
| 37 | +grep -q inter-font app/views/layouts/application.html.erb |
| 38 | + |
| 39 | +if [[ $(rails -v) > "Rails 8.0.0.beta" ]] ; then |
| 40 | + # install auth templates |
| 41 | + bin/rails generate authentication |
| 42 | + grep -q PasswordsController app/controllers/passwords_controller.rb |
| 43 | +fi |
| 44 | + |
| 45 | +# install scaffold templates |
| 46 | +bin/rails generate scaffold post title:string body:text published:boolean |
| 47 | +grep -q "Show this post" app/views/posts/index.html.erb |
| 48 | + |
| 49 | +# upgrade time! |
| 50 | +bundle remove tailwindcss-rails --skip-install |
| 51 | +bundle remove tailwindcss-ruby --skip-install |
| 52 | + |
| 53 | +bundle add tailwindcss-rails --skip-install --path="../.." |
| 54 | +bundle add tailwindcss-ruby --skip-install --version 4.0.0 |
| 55 | + |
| 56 | +bundle install --prefer-local |
| 57 | +bundle show --paths |
| 58 | +bundle binstubs --all |
| 59 | + |
| 60 | +bin/rails tailwindcss:upgrade |
| 61 | + |
| 62 | +# TEST: removal of inter-font CSS |
| 63 | +if grep -q inter-font app/views/layouts/application.html.erb ; then |
| 64 | + echo "FAIL: inter-font CSS not removed" |
| 65 | + exit 1 |
| 66 | +fi |
| 67 | + |
| 68 | +# generate CSS |
| 69 | +bin/rails tailwindcss:build[verbose] |
| 70 | +grep -q "py-2" app/assets/builds/tailwind.css |
| 71 | + |
| 72 | +echo "OK" |
0 commit comments