This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
249 lines (225 loc) · 7.17 KB
/
gulpfile.js
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// Import modules:
var gulp = require('gulp');
var path = require("path");
var pkg = require('./package.json');
var concat = require('gulp-concat');
var gutils = require('gulp-util');
var ts = require('gulp-typescript');
var beautify = require('gulp-jsbeautifier');
var jshint = require('gulp-jshint');
var jsmin = require('gulp-jsmin');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var colors = require('colors');
var combiner = require('stream-combiner2');
var filePathStart = 'src/';
var osTypes = ['truck-android','truck-ios','truck-windows']
// Files for Truck Wheel, Engine, Chassis & Body:
var Truck_Files = [
/* Truck Wheel Components */
'truck-wheels/wheels-comments.js',
'truck-wheels/domstack.js',
'truck-wheels/selectors.js',
'truck-wheels/utils.js',
'truck-wheels/types.js',
'truck-wheels/strings.js',
'truck-wheels/domstack.js',
'truck-wheels/dom.js',
'truck-wheels/data.js',
'truck-wheels/serialize.js',
'truck-wheels/events.js',
/* Truck Engine Components */
'truck-engine/engine-comments.js',
'truck-engine/environment.js',
'truck-engine/event-aliases.js',
'truck-engine/gestures.js',
'truck-engine/plugins.js',
'truck-engine/dispatcher.js',
'truck-engine/stack.js',
'truck-engine/model.js',
'truck-engine/mediator.js',
'truck-engine/view.js',
'truck-engine/screens.js',
'truck-engine/router.js',
'truck-engine/promises.js',
'truck-engine/fetch.js',
'truck-engine/formatters.js',
'truck-engine/validators.js',
'truck-engine/box.js',
/* Truck Body Components */
'truck-body/body-comments.js',
'truck-body/navbar.js',
'truck-body/setup.js',
'truck-body/buttons.js',
'truck-body/navigation.js',
'truck-body/tabbar.js',
'truck-body/slide-out.js',
'truck-body/editable.js',
'truck-body/form.js',
'truck-body/selectList.js',
'truck-body/multiSelectList.js',
'truck-body/switches.js',
'truck-body/block.js',
'truck-body/popup.js',
'truck-body/segmented.js',
'truck-body/range.js',
'truck-body/sheets.js',
'truck-body/slide-out.js',
'truck-body/paging.js',
'truck-body/stepper.js',
'truck-body/popover.js',
'truck-body/center.js',
'truck-body/activityIndicator.js'
].map(function(file) {
return path.join(filePathStart, file);
});
var Truck_Wheel_Files = [
/* Truck Wheel Components */
'truck-wheels/wheels-comments.js',
'truck-wheels/domstack.js',
'truck-wheels/selectors.js',
'truck-wheels/utils.js',
'truck-wheels/types.js',
'truck-wheels/strings.js',
'truck-wheels/domstack.js',
'truck-wheels/dom.js',
'truck-wheels/data.js',
'truck-wheels/serialize.js',
'truck-wheels/events.js',
'truck-engine/environment.js',
'truck-engine/event-aliases.js',
'truck-engine/gestures.js',
'truck-engine/plugins.js',
'truck-engine/dispatcher.js',
'truck-engine/promises.js',
'truck-engine/fetch.js',
'truck-engine/formatters.js',
'truck-engine/validators.js'
].map(function(file) {
return path.join(filePathStart, file);
});
var Truck_Engine_Files = [
/* Truck Engine Components */
'truck-engine/engine-comments.js',
'truck-engine/environment.js',
'truck-engine/event-aliases.js',
'truck-engine/gestures.js',
'truck-engine/plugins.js',
'truck-engine/dispatcher.js',
'truck-engine/stack.js',
'truck-engine/model.js',
'truck-engine/mediator.js',
'truck-engine/view.js',
'truck-engine/screens.js',
'truck-engine/router.js',
'truck-engine/promises.js',
'truck-engine/fetch.js',
'truck-engine/formatters.js',
'truck-engine/validators.js',
'truck-engine/box.js'
].map(function(file) {
return path.join(filePathStart, file);
});
var Truck_MVC_Files = [
/* Truck MVP Components */
'truck-engine/plugins.js',
'truck-engine/dispatcher.js',
'truck-engine/stack.js',
'truck-engine/model.js',
'truck-engine/mediator.js',
'truck-engine/view.js',
'truck-engine/box.js'
].map(function(file) {
return path.join(filePathStart, file);
});
var Truck_Body_Files = [
{os: 'android', src: 'src/js/truck-body/truck-android.css'},
{os: 'ios', src: 'src/js/truck-body/truck-ios.css'},
{os: 'windows', src: 'src/js/truck-body/truck-windows.css'}
];
// Define CSS paths:
cssDirectory = 'src/truck-chassis/';
var cssFiles = [
'truck-android.css',
'truck-ios.css',
'truck-windows.css'
].map(function (f) {
return path.join(cssDirectory, f);
});
// Concat, minify and output JavaScript:
gulp.task('js', function () {
if (gutils.env.wheels) {
console.log('There\'s some Truck Wheels coming your way.');
gulp.src(Truck_Wheel_Files)
.pipe(concat('truck-wheels.js'))
.pipe(beautify({indentSize: 2, braceStyle: "collapse", spaceBeforeConditional: true}))
.pipe(gulp.dest('dist/'))
.pipe(jsmin())
.pipe(rename("truck-wheels.min.js"))
.pipe(gulp.dest('dist/'));
} else if ( gutils.env.engine) {
console.log('There\'s a Truck Engine coming your way.');
gulp.src(Truck_Engine_Files)
.pipe(concat('truck-engine.js'))
.pipe(beautify({indentSize: 2, braceStyle: "collapse", spaceBeforeConditional: true}))
.pipe(gulp.dest('dist/'))
.pipe(jsmin())
.pipe(rename("truck-engine.min.js"))
.pipe(gulp.dest('dist/'));
} else if ( gutils.env.mvc) {
console.log('We\'re putting together your request for Truck MVC')
gulp.src(Truck_MVC_Files)
.pipe(concat('truck-tank.js'))
.pipe(beautify({indentSize: 2, braceStyle: "collapse", spaceBeforeConditional: true}))
.pipe(gulp.dest('dist/'))
.pipe(jsmin())
.pipe(rename("truck-tank.min.js"))
.pipe(gulp.dest('dist/'));
} else {
// Print out Truck image:
console.log('');
console.log(' \/|||||||||\\'.red);
console.log(' |//-----\\\\|'.red);
console.log(' || '.red + '|'.gray + ' ||'.red);
console.log(' |//-----\\\\|'.red);
console.log(' // //|\\\\ \\\\'.red);
console.log(' ('.red + '[_]'.white + '+===+'.red + '[_]'.white + ')'.red);
console.log(' /_\\'.red + ' |||||'.white + ' /_\\'.red);
console.log(' (( ))'.red + '+===+'.white + '(( ))'.red);
console.log(' \\_/ \\_/'.red);
console.log(' >==>'.green + ' TRUCK '.yellow + '<==<'.green);
console.log(' ');
console.log('Hold on tight. We\'re building your TruckJS now.');
gulp.src(Truck_Files)
.pipe(concat('truck.js'))
.pipe(beautify({indentSize: 2, braceStyle: "collapse", spaceBeforeConditional: true}))
.pipe(gulp.dest('dist/'))
.pipe(jsmin())
.pipe(rename("truck.min.js"))
.pipe(gulp.dest('dist/'));
gulp.src('src/truck-chassis/*.css')
.pipe(gulp.dest('dist/styles'))
.pipe(minifyCSS({}))
.pipe(rename('*.min.css'))
.pipe(gulp.dest('dist/styles'));
}
gulp.src('src/truck-chassis/*.css')
.pipe(gulp.dest('dist/styles'));
cssFiles.forEach(function(file, idx) {
console.log(file)
gulp.src(file)
.pipe(gulp.dest('dist/styles'))
.pipe(minifyCSS({}))
.pipe(rename(osTypes[idx] + '.min.css'))
.pipe(gulp.dest('dist/styles'));
});
});
/*
Four ways to build. Default will build Truck with everything.
Using gulp --mvc will build only the mvc parts.
Using gulp --wheel
Using gulp --tank
Using gulp --engine
*/
// gulp.task('default', ['js','jshint']);
gulp.task('default', ['js']);