forked from monarch-initiative/phenogrid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
168 lines (141 loc) · 4.11 KB
/
Copy pathgulpfile.js
File metadata and controls
168 lines (141 loc) · 4.11 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
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
(function () {
'use strict';
////
//// Usage: node ./node_modules/.bin/gulp <TARGET>
//// Current top targets:
//// - bundle: create the distribution files
//// - tests: run the unit tests
//// Watch targets:
//// - watch-tests: run tests on changes to source files
////
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var rename = require("gulp-rename");
var mocha = require('gulp-mocha');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var concat = require('gulp-concat');
var bump = require('gulp-bump');
var del = require('del');
var shell = require('gulp-shell');
var marked = require('marked');
var jshint = require('gulp-jshint');
var jshints = require('jshint-stylish');
var fileinclude = require('gulp-file-include');
function markdownHelper(text) {
marked.setOptions({
gfm: true,
tables: true,
breaks: true,
pedantic: true,
sanitize: true,
smartLists: true,
smartypants: true
});
return marked.parse(text);
}
var paths = {
readme: ['./README.md'],
transients:[],
js: ['js/*.js'],
tests: ['tests/*.test.js', 'tests/*.tests.js']
};
// The default task is to build the different distributions.
gulp.task('bundle', ['lint', 'create-index', 'js-bundle', 'css-bundle']);
// an alternate task that won't uglify. useful for debugging
gulp.task('dev-bundle', ['lint', 'create-index', 'js-dev-bundle', 'css-bundle']);
gulp.task('create-index', ['clean'], function(cb) {
gulp.src(['templates/index.html'])
.pipe(fileinclude({
filters: {
marked: markdownHelper
}
}))
.pipe(gulp.dest('./'));
});
// Bundle JS together with browserify
gulp.task('js-bundle', function(cb) {
var bundleStream = browserify('./js/phenogrid.js').bundle();
bundleStream
.pipe(source('./js/phenogrid.js'))
.pipe(streamify(uglify())) // Minify JS
.pipe(rename('phenogrid-bundle.js'))
.pipe(gulp.dest('./dist/'))
.on('end', cb);
});
// Bundle JS together with browserify
gulp.task('js-dev-bundle', function(cb) {
var bundleStream = browserify('./js/phenogrid.js').bundle();
bundleStream
.pipe(source('./js/phenogrid.js'))
.pipe(rename('phenogrid-bundle.js'))
.pipe(gulp.dest('./dist/'))
.on('end', cb);
});
// Bundle CSS together with gulp concat
gulp.task('css-bundle', function(cb) {
return gulp.src(['./css/normalize.css', './css/font-awesome-modified.css', './css/jquery-ui-modified.css', './css/phenogrid.css'])
.pipe(concat('phenogrid-bundle.css'))
.pipe(minifyCSS()) //Minify CSS
.pipe(gulp.dest('./dist/'));
});
// Browser runtime environment construction.
gulp.task('build', ['bundle', 'patch-bump']);
gulp.task('patch-bump', function(cb){
gulp.src('./package.json')
.pipe(bump({type: 'patch'}))
.pipe(gulp.dest('./'));
cb(null);
});
gulp.task('minor-bump', function(cb){
gulp.src('./package.json')
.pipe(bump({type: 'minor'}))
.pipe(gulp.dest('./'));
cb(null);
});
gulp.task('major-bump', function(cb){
gulp.src('./package.json')
.pipe(bump({type: 'major'}))
.pipe(gulp.dest('./'));
cb(null);
});
// Get rid of anything that is transient.
gulp.task('clean', function(cb) {
cb(null);
});
// Testing with mocha/chai.
gulp.task('tests', function() {
return gulp.src(paths.tests, { read: false }).pipe(mocha({
reporter: 'spec',
globals: {
// Use a different should.
should: require('chai').should()
}
}));
});
gulp.task('release', ['build', 'publish-npm']);
// Needs to have ""
gulp.task('publish-npm', function() {
var npm = require("npm");
npm.load(function (er, npm) {
// NPM
npm.commands.publish();
});
});
// Rerun test build when a file changes.
gulp.task('watch-tests', function() {
gulp.watch(paths.tests, ['tests', 'bundle']);
});
gulp.task("lint", function() {
return gulp.src(paths.js)
.pipe(jshint())
.pipe(jshint.reporter("jshint-stylish"));
//.pipe(jshint.reporter("fail"));
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', function() {
console.log("'allo 'allo!");
});
}());