forked from opensourcepos/opensourcepos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
270 lines (231 loc) · 14.8 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
// Gulp Build Script
import gulp from 'gulp'
import clean from 'gulp-clean'
import rev from 'gulp-rev'
import concat from 'gulp-concat'
import cleanCSS from 'gulp-clean-css'
import rename from 'gulp-rename'
import uglify from 'gulp-uglify'
import inject from 'gulp-inject'
import logStream from 'gulp-debug'
import series from 'stream-series'
import header from 'gulp-header'
import tar from 'gulp-tar'
import gzip from 'gulp-gzip'
import zip from 'gulp-zip'
import { Stream } from 'readable-stream'
const {finished, pipeline} = Stream.promises
var prod0js;
var prod1js;
// Clear and remove the resources folder
gulp.task('clean', function () {
return pipeline(
gulp.src('./public/resources', {read: false, allowEmpty: true}),
clean()
);
});
gulp.task('compress', function() {
const sources = ['public/**', 'vendor/**', '*.md', 'LICENSE', 'docker*', 'docker/**', 'Dockerfile', '**/.htaccess', 'writable/*'] ;
gulp.src(sources).pipe(tar('opensourcepos.tar')).pipe(gzip()).pipe(gulp.dest('dist'));
return gulp.src(sources).pipe(zip('opensourcepos.zip')).pipe(gulp.dest('dist'));
});
// Copy the bootswatch styles into their own folder so OSPOS can select one from the collection
gulp.task('copy-bootswatch', function() {
pipeline(gulp.src('./node_modules/bootswatch/cerulean/*.min.css'),gulp.dest('public/resources/bootswatch/cerulean'));
pipeline(gulp.src('./node_modules/bootswatch/cosmo/*.min.css'),gulp.dest('public/resources/bootswatch/cosmo'));
pipeline(gulp.src('./node_modules/bootswatch/cyborg/*.min.css'),gulp.dest('public/resources/bootswatch/cyborg'));
pipeline(gulp.src('./node_modules/bootswatch/darkly/*.min.css'),gulp.dest('public/resources/bootswatch/darkly'));
pipeline(gulp.src('./node_modules/bootswatch/flatly/*.min.css'),gulp.dest('public/resources/bootswatch/flatly'));
pipeline(gulp.src('./node_modules/bootswatch/journal/*.min.css'),gulp.dest('public/resources/bootswatch/journal'));
pipeline(gulp.src('./node_modules/bootswatch/lumen/*.min.css'),gulp.dest('public/resources/bootswatch/lumen'));
pipeline(gulp.src('./node_modules/bootswatch/paper/*.min.css'),gulp.dest('public/resources/bootswatch/paper'));
pipeline(gulp.src('./node_modules/bootswatch/readable/*.min.css'),gulp.dest('public/resources/bootswatch/readable'));
pipeline(gulp.src('./node_modules/bootswatch/sandstone/*.min.css'),gulp.dest('public/resources/bootswatch/sandstone'));
pipeline(gulp.src('./node_modules/bootswatch/simplex/*.min.css'),gulp.dest('public/resources/bootswatch/simplex'));
pipeline(gulp.src('./node_modules/bootswatch/slate/*.min.css'),gulp.dest('public/resources/bootswatch/slate'));
pipeline(gulp.src('./node_modules/bootswatch/spacelab/*.min.css'),gulp.dest('public/resources/bootswatch/spacelab'));
pipeline(gulp.src('./node_modules/bootswatch/superhero/*.min.css'),gulp.dest('public/resources/bootswatch/superhero'));
pipeline(gulp.src('./node_modules/bootswatch/united/*.min.css'),gulp.dest('public/resources/bootswatch/united'));
pipeline(gulp.src('./node_modules/bootswatch/yeti/*.min.css'),gulp.dest('public/resources/bootswatch/yeti'));
return pipeline(gulp.src('./node_modules/bootswatch/fonts/*.*', {encoding:false}),gulp.dest('public/resources/bootswatch/fonts'));
});
// Copy the bootswatch styles into their own folder so OSPOS can select one from the collection
gulp.task('copy-bootswatch5', function() {
pipeline(gulp.src('./node_modules/bootswatch5/dist/cerulean/*.min.css'),gulp.dest('public/resources/bootswatch5/cerulean'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/cosmo/*.min.css'),gulp.dest('public/resources/bootswatch5/cosmo'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/cyborg/*.min.css'),gulp.dest('public/resources/bootswatch5/cyborg'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/darkly/*.min.css'),gulp.dest('public/resources/bootswatch5/darkly'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/flatly/*.min.css'),gulp.dest('public/resources/bootswatch5/flatly'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/journal/*.min.css'),gulp.dest('public/resources/bootswatch5/journal'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/lumen/*.min.css'),gulp.dest('public/resources/bootswatch5/lumen'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/sandstone/*.min.css'),gulp.dest('public/resources/bootswatch5/sandstone'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/simplex/*.min.css'),gulp.dest('public/resources/bootswatch5/simplex'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/slate/*.min.css'),gulp.dest('public/resources/bootswatch5/slate'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/spacelab/*.min.css'),gulp.dest('public/resources/bootswatch5/spacelab'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/superhero/*.min.css'),gulp.dest('public/resources/bootswatch5/superhero'));
pipeline(gulp.src('./node_modules/bootswatch5/dist/united/*.min.css'),gulp.dest('public/resources/bootswatch5/united'));
return pipeline(gulp.src('./node_modules/bootswatch5/dist/yeti/*.min.css'),gulp.dest('public/resources/bootswatch5/yeti'));
});
// /public/resources/ospos - contains the minimized files to be packed into opensourcepos.min.[css/js]
// /public/resources/[css/js] - contains the unpacked versions to be used in development mode
// /public/resources - contains the packed opensourcepos.min.[css/js] and the jquery.min.js
// Copy JavaScript into a folder which will be used as the source to create opensourcepos.min.js (except for jquery.mn.js)
// Inject will be in the sequence of the files in the stream. So make sure dependencies are in their proper order
gulp.task('debug-js', function() {
var debugjs = gulp.src(['./node_modules/jquery/dist/jquery.js',
'./node_modules/jquery-form/src/jquery.form.js',
'./node_modules/jquery-validation/dist/jquery.validate.js',
'./node_modules/jquery-ui-dist/jquery-ui.js',
'./node_modules/bootstrap/dist/js/bootstrap.js',
'./node_modules/bootstrap3-dialog/dist/js/bootstrap-dialog.js',
'./node_modules/jasny-bootstrap/dist/js/jasny-bootstrap.js',
'./node_modules/bootstrap-datetime-picker/js/bootstrap-datetimepicker.js',
'./node_modules/bootstrap-select/dist/js/bootstrap-select.js',
'./node_modules/bootstrap-table/dist/bootstrap-table.js',
'./node_modules/bootstrap-table/dist/extensions/export/bootstrap-table-export.js',
'./node_modules/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile.js',
'./node_modules/bootstrap-table/dist/extensions/sticky-header/bootstrap-table-sticky-header.js',
'./node_modules/moment/min/moment.min.js',
'./node_modules/bootstrap-daterangepicker/daterangepicker.js',
'./node_modules/es6-promise/dist/es6-promise.js',
'./node_modules/file-saver/dist/FileSaver.js',
'./node_modules/html2canvas/dist/html2canvas.js',
'./node_modules/jspdf/dist/jspdf.umd.js',
'./node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js',
'./node_modules/tableexport.jquery.plugin/tableExport.min.js',
'./node_modules/chartist/dist/chartist.js',
'./node_modules/chartist-plugin-pointlabels/dist/chartist-plugin-pointlabels.js',
'./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.js',
'./node_modules/chartist-plugin-axistitle/dist/chartist-plugin-axistitle.js',
'./node_modules/chartist-plugin-barlabels/dist/chartist-plugin-barlabels.js',
'./node_modules/bootstrap-notify/bootstrap-notify.js',
'./node_modules/js-cookie/src/js.cookie.js',
'./node_modules/bootstrap-tagsinput-2021/dist/bootstrap-tagsinput.js',
'./node_modules/bootstrap-toggle/js/bootstrap-toggle.js',
'./node_modules/clipboard/dist/clipboard.js',
'./public/js/imgpreview.full.jquery.js',
'./public/js/manage_tables.js',
'./public/js/nominatim.autocomplete.js']).pipe(rev()).pipe(gulp.dest('public/resources/js'));
return gulp.src('./app/Views/partial/header.php').pipe(inject(debugjs,{addRootSlash: false, ignorePath: '/public/', starttag: '<!-- inject:debug:js -->'})).pipe(gulp.dest('./app/Views/partial'));
});
gulp.task('prod-js', function() {
var prod0js = gulp.src('./node_modules/jquery/dist/jquery.min.js').pipe(rev()).pipe(gulp.dest('public/resources'));
var opensourcepos1js = gulp.src(['./node_modules/bootstrap/dist/js/bootstrap.min.js',
'./node_modules/bootstrap-table/dist/bootstrap-table.min.js',
'./node_modules/moment/min/moment.min.js',
'./node_modules/jquery-ui-dist/jquery-ui.min.js',
'./node_modules/bootstrap3-dialog/dist/js/bootstrap-dialog.min.js',
'./node_modules/jasny-bootstrap/dist/js/jasny-bootstrap.min.js',
'./node_modules/bootstrap-select/dist/js/bootstrap-select.min.js',
'./node_modules/bootstrap-table/dist/extensions/sticky-header/bootstrap-table-sticky-header.min.js',
'./node_modules/bootstrap-tagsinput-2021/dist/bootstrap-tagsinput.min.js',
'./node_modules/bootstrap-toggle/js/bootstrap-toggle.min.js',
'./node_modules/bootstrap-table/dist/extensions/export/bootstrap-table-export.min.js',
'./node_modules/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile.min.js',
'./node_modules/bootstrap-notify/bootstrap-notify.min.js',
'./node_modules/clipboard/dist/clipboard.min.js',
'./node_modules/jquery-form/dist/jquery.form.min.js',
'./node_modules/jquery-validation/dist/jquery.validate.min.js',
'./node_modules/bootstrap-datetime-picker/js/bootstrap-datetimepicker.min.js',
'./node_modules/es6-promise/dist/es6-promise.min.js',
'./node_modules/file-saver/dist/FileSaver.min.js',
'./node_modules/file-saver/dist/FileSaver.js',
'./node_modules/html2canvas/dist/html2canvas.min.js',
'./node_modules/chartist/dist/chartist.min.js',
'./node_modules/jspdf/dist/jspdf.umd.min.js',
'./node_modules/chartist/dist/chartist.min.js',
'./node_modules/chartist-plugin-pointlabels/dist/chartist-plugin-pointlabels.min.js',
'./node_modules/chartist-plugin-axistitle/dist/chartist-plugin-axistitle.min.js',
'./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.min.js',
'./node_modules/chartist-plugin-barlabels/dist/chartist-plugin-barlabels.min.js',
'./node_modules/tableexport.jquery.plugin/tableExport.min.js'], { allowEmpty: true });
var opensourcepos2js = gulp.src(['./node_modules/bootstrap-daterangepicker/daterangepicker.js',
'./node_modules/js-cookie/src/js.cookie.js',
'./public/js/imgpreview.full.jquery.js',
'./public/js/manage_tables.js',
'./public/js/nominatim.autocomplete.js']).pipe(uglify());
var prod1js = series(opensourcepos1js, opensourcepos2js).pipe(concat('opensourcepos.min.js'))
.pipe(rev())
.pipe(gulp.dest('./public/resources/'));
return gulp.src('./app/Views/partial/header.php').pipe(inject(
series(prod0js, prod1js), {addRootSlash: false, ignorePath: '/public/', starttag: '<!-- inject:prod:js -->'})).pipe(gulp.dest('./app/Views/partial'));
});
gulp.task('debug-css', function() {
var debugcss = gulp.src(['./node_modules/jquery-ui-dist/jquery-ui.css',
'./node_modules/bootstrap3-dialog/dist/css/bootstrap-dialog.css',
'./node_modules/jasny-bootstrap/dist/css/jasny-bootstrap.css',
'./node_modules/bootstrap-datetime-picker/css/bootstrap-datetimepicker.css',
'./node_modules/bootstrap-select/dist/css/bootstrap-select.css',
'./node_modules/bootstrap-table/dist/bootstrap-table.css',
'./node_modules/bootstrap-table/dist/extensions/sticky-header/bootstrap-table-sticky-header.css',
'./node_modules/bootstrap-daterangepicker/daterangepicker.css',
'./node_modules/chartist/dist/chartist.css',
'./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.css',
'./node_modules/bootstrap-tagsinput-2021/src/bootstrap-tagsinput.css',
'./node_modules/bootstrap-toggle/css/bootstrap-toggle.css',
'./public/css/bootstrap.autocomplete.css',
'./public/css/invoice.css',
'./public/css/ospos_print.css',
'./public/css/ospos.css',
'./public/css/popupbox.css',
'./public/css/receipt.css',
'./public/css/register.css',
'./public/css/reports.css'
]).pipe(rev()).pipe(gulp.dest('public/resources/css'));
return gulp.src('./app/Views/partial/header.php').pipe(inject(debugcss,{addRootSlash: false, ignorePath: '/public/', starttag: '<!-- inject:debug:css -->'})).pipe(gulp.dest('./app/Views/partial'));
});
gulp.task('prod-css', function() {
var opensourcepos1css = gulp.src(['./node_modules/jquery-ui-dist/jquery-ui.min.css',
'./node_modules/bootstrap3-dialog/dist/css/bootstrap-dialog.min.css',
'./node_modules/jasny-bootstrap/dist/css/jasny-bootstrap.min.css',
'./node_modules/bootstrap-datetime-picker/css/bootstrap-datetimepicker.min.css']);
var opensourcepos2css = gulp.src(['./node_modules/bootstrap-daterangepicker/daterangepicker.css',
'./node_modules/bootstrap-tagsinput-2021/src/bootstrap-tagsinput.css']).pipe(cleanCSS({compatibility: 'ie8'}));
var opensourcepos3css = gulp.src(['./node_modules/bootstrap-select/dist/css/bootstrap-select.min.css',
'./node_modules/bootstrap-table/dist/bootstrap-table.min.css',
'./node_modules/bootstrap-table/dist/extensions/sticky-header/bootstrap-table-sticky-header.min.css',
'./node_modules/bootstrap-toggle/css/bootstrap-toggle.min.css',
'./node_modules/chartist/dist/chartist.min.css']);
var opensourcepos4css = gulp.src('./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.css').pipe(cleanCSS({compatibility: 'ie8'}));
var opensourcepos5css = gulp.src(['./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.css',
'./public/css/bootstrap.autocomplete.css',
'./public/css/invoice.css',
'./public/css/ospos.css',
'./public/css/ospos_print.css',
'./public/css/popupbox.css',
'./public/css/receipt.css',
'./public/css/register.css',
'./public/css/reports.css'
]).pipe(cleanCSS({compatibility: 'ie8'}));
var prodcss = series(opensourcepos1css, opensourcepos2css, opensourcepos3css, opensourcepos4css, opensourcepos5css)
.pipe(concat('opensourcepos.min.css')).pipe(rev()).pipe(gulp.dest('public/resources'));
return gulp.src('./app/Views/partial/header.php').pipe(inject(prodcss,{addRootSlash: false, ignorePath: '/public/', starttag: '<!-- inject:prod:css -->'})).pipe(gulp.dest('./app/Views/partial'));
});
gulp.task('copy-fonts', function() {
return pipeline(gulp.src('./node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.*', {encoding: false}),rev(),gulp.dest('public/resources'));
});
gulp.task('inject-login', function() {
return pipeline(gulp.src('./app/Views/login.php'),
inject(gulp.src('./public/css/login.min.css', {read: false}), {addRootSlash: false, ignorePath: '/public/', starttag: '<!-- inject:login:{{ext}} -->'}),
gulp.dest('./app/Views')
);
});
gulp.task('build-database', function() {
return gulp.src(['./app/Database/tables.sql','./app/Database/constraints.sql'])
.pipe(header('-- >> This file is autogenerated from tables.sql and constraints.sql. Do not modify directly << --'))
.pipe(concat('database.sql'))
.pipe(gulp.dest('./app/Database'));
});
// Run all required tasks
gulp.task('default',
gulp.series('clean',
'copy-bootswatch',
'copy-bootswatch5',
'debug-js',
'prod-js',
'debug-css',
'prod-css',
'copy-fonts',
'inject-login',
'build-database'
));