-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate
executable file
·202 lines (153 loc) · 7.34 KB
/
generate
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
#echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
#echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
while getopts "f:" opt; do
case $opt in
f) framework="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2
;;
esac
done
if [ -z "$framework" ]; then
printf "\n%s\n\n" "@@@@Barebones is not yet available, sorry!@@@"
exit -3;
# echo No framework selected. Generating Core JS-Gulp Project without a framework.
elif [ "$framework" == "bootstrap" ]; then
echo Generating Core JS-Gulp Project with Bootstrap!
elif [ "$framework" == "materialize" ]; then
printf "\n%s\n\n" "@@@@Materialize is not yet available, sorry!@@@"
exit -3;
# echo Generating Core JS-Gulp Project with Materialize!
elif [ "$framework" == "tailwind" ]; then
echo Generating Core JS-Gulp Project with Tailwind!
else
echo "Sorry $framework is not a valid option!" >&2
fi
echo @@@@@@Starting project boilerplate@@@@@@
read -p "What will you call this project? " PROJECT_NAME
if [ -z "$PROJECT_NAME" ]; then
echo No project name given. The default 'Test' will be used.
export PROJECT_NAME="Test"
fi
printf '\n%s\n' "*Please note that if you wish to use a custom path DO NOT start with '~/'*"
printf '\n%s\n' "Example:"
echo -------------
echo Let\'s say we have a folder called \'Epicodus\' on your desktop and we want to generate our project inside of it.
printf '\n%s\n\n' "Our path will simply be: Desktop/Epicodus"
read -p "Project path (default: ~/Desktop): " PROJECT_DIR
if [ -z "$PROJECT_DIR" ]; then
echo No Project path given. Creating project using the default '~/Desktop' path.
export PROJECT_DIR=$HOME/Desktop
else
export PROJECT_DIR=$HOME/$PROJECT_DIR
fi
if [ -e "$PROJECT_DIR/$PROJECT_NAME" ]; then
echo $PROJECT_DIR/$PROJECT_NAME already exists!
echo Please choose a different project name/directory and try again!
exit 1;
else
echo Creating project under the given path: $HOME/$PROJECT_DIR
mkdir -p $PROJECT_DIR/$PROJECT_NAME && cd $PROJECT_DIR/$PROJECT_NAME
fi
if [ $(pwd) == "$PROJECT_DIR/$PROJECT_NAME" ]; then
echo Successfully created $PROJECT_NAME under $PROJECT_DIR/$PROJECT_NAME
else
echo Failed to create project root.
exit -1;
fi
echo $(pwd)
echo Initializing git
git init
echo Generating basic gitignore file
echo \#\# This file was automatically generated by js-gulp-gen $(date +'%a %b %d %Y @ %r') > .gitignore
cat $DIR/src/gitignore > .gitignore
echo Creating basic project structure
echo // This file was automatically generated by js-gulp-gen $(date +'%a %b %d %Y @ %r') > index.html
mkdir -p assets/js && mkdir -p assets/css && mkdir -p assets/images
touch assets/css/app.css && touch assets/js/app.js && touch assets/js/app-interface.js
echo /\* This file was automatically generated by js-gulp-gen $(date +'%a %b %d %Y @ %r') \*/ > assets/css/app.css
echo // This file was automatically generated by js-gulp-gen $(date +'%a %b %d %Y @ %r') > assets/js/app.js
cp $DIR/src/media/js_gulp_gen_logo.png assets/images/js_gulp_gen_logo.png
echo Initializing npm, after project setup you may edit your package.json as you see fit.
npm init -y
echo Initializing bower, after project setup you may edit your bower.json as you see fit.
yes '' | bower init
echo Installing bower jquery package
bower install jquery --save
echo Creating gulpfile
echo // This file was automatically generated by js-gulp-gen $(date +'%a %b %d %Y @ %r') > gulpfile.js
if [ -z "$framework" ]; then
echo Tailoring index for Core usage
cat $DIR/src/core/index > index.html
echo Installing dev npm packages
# npm install --save-dev .......
echo Tailoring gulpfile for Core
cat $DIR/src/core/gulpfile > gulpfile.js
elif [ "$framework" == "bootstrap" ]; then
echo Tailoring index for Bootstrap usage
cat $DIR/src/bootstrap/index > index.html
echo Installing dev npm packages
npm install --save-dev babel-core babel-preset-env babelify bower-files browser-sync browserify del gulp gulp-clean-css gulp-concat gulp-imagemin gulp-jshint gulp-uglify gulp-util [email protected] [email protected] jshint karma karma-browserify karma-chrome-launcher karma-cli karma-jasmine karma-jasmine-html-reporter karma-jquery vinyl-source-stream watchify
echo Installing bower bootstrap package
bower install bootstrap --save
echo Tailoring gulpfile for Bootstrap
cat $DIR/src/bootstrap/gulpfile > gulpfile.js
elif [ "$framework" == "materialize" ]; then
echo Tailoring index for Materialize usage
cat $DIR/src/materialize/index > index.html
echo Installing dev npm packages
# npm install --save-dev ......
echo Installing bower materialize package
# bower install .... -save
echo Tailoring gulpfile for Materialize
cat $DIR/src/materialize/gulpfile > gulpfile.js
elif [ "$framework" == "tailwind" ]; then
echo Tailoring index for Taiwind usage
cat $DIR/src/tailwind/index > index.html
echo /* This file was automatically generated by js-gulp-gen $(date +'%a %b %d %Y @ %r') */ > assets/css/tailwind.css
echo "@tailwind preflight; @tailwind utilities;" > assets/css/tailwind.css
echo Installing dev npm packages
npm install --save-dev autoprefixer babel-core babel-preset-env babelify bower-files browser-sync browserify del gulp gulp-clean-css gulp-concat gulp-imagemin gulp-jshint gulp-postcss gulp-uglify gulp-util [email protected] [email protected] jshint karma karma-browserify karma-chrome-launcher karma-cli karma-jasmine karma-jasmine-html-reporter karma-jquery tailwindcss vinyl-source-stream watchify
echo Tailoring gulpfile for Tailwind
cat $DIR/src/tailwind/gulpfile > gulpfile.js
echo Initializing tailwindcss
./node_modules/.bin/tailwind init tailwind.js
fi
echo Creating .jshintrc
echo "{ \"esversion\": 6 }" > .jshintrc
echo Initializing Jasmine
./node_modules/.bin/jasmine init -y
echo Deleting default jasmine.json
rm spec/support/jasmine.json
echo Creating new default jasmine.json
cat $DIR/src/jasmine > spec/support/jasmine.json
echo Adding sample test spec to pass karma test run
echo // This file was automatically generated by js-gulp-gen $(date +'%a %b %d %Y @ %r') > spec/app-spec.js
cat $DIR/src/test-spec > spec/app-spec.js
echo Initializing karma
yes '' | karma init
echo Deleting generated karma.conf.js
rm karma.conf.js
echo Creating new karma.conf.js
echo // This file was automatically generated by js-gulp-gen $(date +'%a %b %d %Y @ %r') > karma.conf.js
cat $DIR/src/karma.conf > karma.conf.js
echo Running gulp task:jshint
gulp jshint
# echo ***Following command will only work for mac users**
# osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' -e 'tell application "Terminal" to do scriptcd ~/$("$projectNamevar") && gulp serve --prod in tab 2 of window 1'
echo *Please note, npm test will not work by default*
echo *You must add karma start karma.conf.js to your package.json 'test' variable*
echo Running gulp task:serve with '\--prod\' tag
gulp serve --prod