-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
134 lines (106 loc) · 3.34 KB
/
Gulpfile.js
File metadata and controls
134 lines (106 loc) · 3.34 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
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
'use strict';
var gulp = require('gulp');
var loadPlugins = require('gulp-load-plugins');
var $ = loadPlugins({
lazy: true
});
//var gutil = require('gulp-util');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var vendorLibs = [
'react',
'jquery',
'couch-promise',
'react-bootstrap',
'moment',
'underscore',
'nchart',
'ramda'
];
function testMochaPhantom() {
return gulp.src(['./web/runner.html'])
.pipe($.mochaPhantomjs());
}
gulp.task('test-node', function () {
return gulp.src(['./test/model/**/*.js'], {read: false})
.pipe($.mocha({reporter:'spec'}));
});
gulp.task('create-db', function () {
var dbFactory = require('./create_storage/create-db');
dbFactory.create('http://localhost:5984/billy-test');
});
gulp.task('test', ['vendor','jsxify','browserify-test','test-node'], testMochaPhantom);
gulp.task('test-browser', ['vendor','jsxify','browserify-test'], testMochaPhantom);
gulp.task('testMochaPhantom', testMochaPhantom);
gulp.task('browserify-test', function() {
var b = browserify('./test/billpanel_test.js');
vendorLibs.forEach(function(lib) {
b.external(lib);
});
return b
.bundle({
insertGlobals: true
})
.pipe(source('test.js'))
.pipe(gulp.dest('web/js'));
});
gulp.task('browserify', function() {
var b = browserify('./lib/app.js');
vendorLibs.forEach(function(lib) {
b.external(lib);
});
return b
.bundle({
insertGlobals: true
})
.pipe(source('index.js'))
.pipe(gulp.dest('web/js'));
});
gulp.task('jsxify', function() {
return gulp.src('./lib/templates/**/*.html')
.pipe($.jsxify({
requires: {
Row: 'react-bootstrap/Row',
Col: 'react-bootstrap/Col',
Panel: 'react-bootstrap/Panel',
Table: 'react-bootstrap/Table',
TabbedArea: 'react-bootstrap/TabbedArea',
TabPane: 'react-bootstrap/TabPane',
Button: 'react-bootstrap/Button',
LineChart: '../LineChart',
TotalsTable: '../TotalsTable',
BillsTable: '../BillsTable',
SetPayed: '../SetPayed',
BillsTotals: '../BillsTotals',
BillCharts: '../BillCharts',
BillsTabs: '../BillsTabs',
Status: '../Status',
Spinner: '../Spinner'
}
}))
.pipe($.react())
.pipe(gulp.dest('./lib/built-templates'));
});
gulp.task('vendor', function() {
var b = browserify(vendorLibs);
vendorLibs.forEach(function(lib) {
b.require(lib);
});
return b
.bundle({
insertGlobals: true
})
.pipe(source('vendor.js'))
.pipe(gulp.dest('web/js'));
});
gulp.task('watch-test', ['test'] ,function() {
gulp.watch(['./lib/**/*.js', './test/**/*.js'], ['browserify-test']);
gulp.watch(['./web/js/test.js'], ['testMochaPhantom']);
});
gulp.task('watch-browserify', function() {
return gulp.watch(['./lib/**/*.js'], ['browserify']);
});
gulp.task('watch-jsxify', function() {
return gulp.watch(['./lib/templates/**/*.html'], ['jsxify']);
});
gulp.task('serve', ['browserify', 'watch-browserify'], $.serve(['web','node_modules']));