-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdaisify.sh
More file actions
executable file
·65 lines (47 loc) · 1.82 KB
/
daisify.sh
File metadata and controls
executable file
·65 lines (47 loc) · 1.82 KB
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
#!/bin/bash
## check if inside a Rails project at root
if [ ! -f "Gemfile" ] || [ ! -d "app" ]; then
echo "This script must be run from the root of a Rails project."
exit 1
fi
theme=$1
valid_themes=(
"light" "dark" "cupcake" "bumblebee" "emerald" "corporate" "synthwave" "retro"
"cyberpunk" "valentine" "halloween" "garden" "forest" "aqua" "lofi"
"pastel" "fantasy" "wireframe" "black" "luxury" "dracula"
"cmyk" "autumn" "business" "acid" "lemonade" "night" "coffee" "winter"
"dim" "nord" "sunset" "caramallatte" "abyss" "silk"
)
if [ -z "$theme" ]; then
theme="cupcake"
fi
if [[ ! " ${valid_themes[@]} " =~ " ${theme} " ]]; then
echo "Invalid theme: $theme"
echo "Valid themes are: ${valid_themes[*]}"
exit 1
fi
echo "Downloading DaisyUI..."
curl -sLo app/assets/tailwind/daisyui.js https://github.com/saadeghi/daisyui/releases/latest/download/daisyui.js
curl -sLo app/assets/tailwind/daisyui-theme.js https://github.com/saadeghi/daisyui/releases/latest/download/daisyui-theme.js
echo "Writing to application.css..."
app_css="
@import \"tailwindcss\" source(none);
@source \"../../../public/*.html\";
@source \"../../../app/helpers/**/*.rb\";
@source \"../../../app/javascript/**/*.js\";
@source \"../../../app/views/**/*\";
@plugin \"./daisyui.js\" {
themes: all;
}
/* Optional for custom themes – Docs: https://daisyui.com/docs/themes/#how-to-add-a-new-custom-theme */
@plugin \"./daisyui-theme.js\"{
/* custom theme here */
};
";
echo "$app_css" > app/assets/tailwind/application.css
echo "Updating application layout..."
sed -i "s|<html>|<html data-theme=\"$theme\">|g" app/views/layouts/application.html.erb
echo "Copying scaffold templates into project..."
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cp -r "$SCRIPT_DIR/lib/templates" ./lib/
echo "DaisyUI has been added with the '$theme' theme!"