-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathuser_upgrade_test.sh
executable file
·90 lines (71 loc) · 2.48 KB
/
user_upgrade_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! /usr/bin/env bash
# reproduce the documented user journey for installing and running tailwindcss-rails
# this is run in the CI pipeline, non-zero exit code indicates a failure
set -o pipefail
set -eux
# set up dependencies
rm -f Gemfile.lock
bundle remove actionmailer || true
bundle remove rails || true
bundle add rails --skip-install ${RAILSOPTS:-}
bundle install --prefer-local
# do our work a directory with spaces in the name (#176, #184)
rm -rf "My Workspace"
mkdir "My Workspace"
pushd "My Workspace"
# create a rails app
bundle exec rails -v
bundle exec rails new test-upgrade --skip-bundle
pushd test-upgrade
# make sure to use the same version of rails (e.g., install from git source if necessary)
bundle remove rails --skip-install
bundle add rails --skip-install ${RAILSOPTS:-}
# set up app with tailwindcss-rails v3 and tailwindcss-ruby v3
bundle add tailwindcss-rails --skip-install --version 3.3.0
bundle add tailwindcss-ruby --skip-install --version 3.4.17
bundle install --prefer-local
bundle show --paths | fgrep tailwind
bundle binstubs --all
# install tailwindcss
bin/rails tailwindcss:install
grep -q inter-font app/views/layouts/application.html.erb
if [[ $(rails -v) > "Rails 8.0.0.beta" ]] ; then
# install auth templates
bin/rails generate authentication
grep -q PasswordsController app/controllers/passwords_controller.rb
fi
# install scaffold templates
bin/rails generate scaffold post title:string body:text published:boolean
grep -q "Show this post" app/views/posts/index.html.erb
# upgrade time!
bundle remove tailwindcss-rails --skip-install
bundle remove tailwindcss-ruby --skip-install
bundle add tailwindcss-rails --skip-install --path="../.."
bundle add tailwindcss-ruby --skip-install ${TAILWINDCSSOPTS:---version 4.0.0}
bundle install --prefer-local
bundle show --paths | fgrep tailwind
bundle binstubs --all
# create a postcss file
cat <<EOF > config/postcss.config.js
module.exports = {
plugins: {
autoprefixer: {},
},
}
EOF
bin/rails tailwindcss:upgrade
# TEST: removal of inter-font CSS
if grep -q inter-font app/views/layouts/application.html.erb ; then
echo "FAIL: inter-font CSS not removed"
exit 1
fi
# TEST: moving the postcss file
test ! -a config/postcss.config.js
test -a postcss.config.js
# TEST: moving application.tailwind.css
test ! -a app/assets/stylesheets/application.tailwind.css
test -a app/assets/tailwind/application.css
# generate CSS
bin/rails tailwindcss:build[verbose]
grep -q "py-2" app/assets/builds/tailwind.css
echo "OK"