-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitializr
executable file
·142 lines (124 loc) · 2.95 KB
/
initializr
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
#
# Create static sites with Initializr
# https://github.com/verekia/initializr
set -e
initializr () {
set_default_modules
process_options $@
if [[ $# > 0 ]]; then
create_project
remove_the_initializr_folder
display_result
else
display_usage
exit 1
fi
}
process_options () {
while getopts ":h-:" opt; do
case "$opt" in
-)
case "${OPTARG}" in
help)
display_usage
exit 0
;;
bootstrap)
remove_module modernizr
add_module boot-css
add_module boot-hero
add_module boot-scripts
add_module modernizrrespond
add_module izr-emptyscript
;;
h5bp)
add_module h5bp-content
add_module h5bp-404
add_module h5bp-adobecrossdomain
add_module h5bp-css
add_module h5bp-csshelpers
add_module h5bp-htaccess
add_module h5bp-humans
add_module h5bp-mediaqueries
add_module h5bp-mediaqueryprint
add_module h5bp-robots
add_module h5bp-scripts
;;
responsive)
remove_module modernizr
add_module izr-responsive
add_module modernizrrespond
add_module h5bp-css
add_module h5bp-csshelpers
add_module h5bp-mediaqueryprint
add_module izr-emptyscript
;;
*)
echo "Invalid option --${OPTARG}" >&2
display_usage
exit 1
;;
esac;;
h)
display_usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
display_usage
exit 1
;;
esac
done
project_folder="$BASH_ARGV"
}
add_module () {
modules+=($1)
}
remove_module () {
modules=(${modules[@]//$1/})
}
set_default_modules () {
modules=(
jquerymin
modernizr
h5bp-iecond
h5bp-chromeframe
h5bp-analytics
h5bp-favicon
h5bp-appletouchicons
)
}
builder_url () {
local query_string=$(printf "&%s" "${modules[@]}")
query_string=${query_string:1}
echo "http://www.initializr.com/builder?${query_string}"
}
create_project () {
echo "Creating initializr site in '$project_folder'"
mkdir -p $project_folder
tar -zxf <(curl $(builder_url)) -C $project_folder
}
remove_the_initializr_folder () {
rsync -a "$project_folder/initializr/" $project_folder
rm -Rf "$project_folder/initializr"
}
display_result () {
cat <<ResultMessage
Created initializr site in '$project_folder'
ResultMessage
}
display_usage () {
cat <<UsageMessage
Create a new static site with Initializr
https://github.com/verekia/initializr
Usage: $(basename $0) [options] <site-name>
Options:
--bootstrap Bootstrap template
--h5bp HTML5 Boilerplate template
--responsive Responsive template
-h, --help Display this message
UsageMessage
}
initializr $@