-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.old.js
179 lines (160 loc) · 5.49 KB
/
gulpfile.old.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
// include gulp
var gulp = require('gulp');
// include plug-ins
var jshint = require('gulp-jshint');
var coffeelint = require('gulp-coffeelint');
var packageJSON = require('./package');
var jshintConfig = packageJSON.jshintConfig;
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var htmlreplace = require('gulp-html-replace');
var uglify = require('gulp-uglify');
var coffee = require("gulp-coffee");
var rename = require("gulp-rename");
var jade = require('gulp-jade');
var less = require('gulp-less');
var concatCss = require('gulp-concat-css');
var dist = "build/";
//register automatically coffee files
require('coffee-script/register');
console.log("version ",packageJSON.version);
gulp.task('templates', function() {
var YOUR_LOCALS = {};
return gulp.src('src/client/**/*.jade')
.pipe(jade({
locals: YOUR_LOCALS
}))
.pipe(gulp.dest('./public/'))
});
gulp.task('compileLess', function() {
return gulp.src('src/client/**/*.less')
.pipe(less())
.pipe(gulp.dest('./temp/css'))
});
gulp.task('css', ['compileLess'], function () {
return gulp.src([
'temp/css/*.css',
'public/bower_components/angular-tree-control/css/tree-control.css',
'public/bower_components/angular-tree-control/css/tree-control-attribute.css',
'public/bower_components/ng-tags-input/ng-tags-input.css',
'public/bower_components/angular-chart.js/dist/angular-chart.css',
'public/bower_components/angular-bootstrap-calendar/dist/css/angular-bootstrap-calendar.css'
])
.pipe(concatCss("bundle.css"))
.pipe(gulp.dest('public/'));
});
gulp.task('TestUnitTests', function () {
return gulp.src(['src/server/**/*.coffee'])
// Covering files
.pipe(istanbul({includeUntested: true}))
// Force `require` to return covered files
.pipe(istanbul.hookRequire())
.on('finish', function() {
gulp.src('test/server/**/*.coffee')
.pipe(mocha(
{reporter: 'spec'}
))
.pipe(istanbul.writeReports());
});
});
gulp.task('pre-test', ['compileCoffee'], function () {
return gulp.src(['temp/server/**/*.js'])
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('unitTests', ['pre-test'], function () {
return gulp.src('test/server/**/*.coffee', {read: false})
// gulp-mocha needs filepaths so you can't have any plugins before it {reporter: 'nyan'}
.pipe(mocha({
compilers: {
coffee:'coffee-script/register'
},
reporter: 'spec',
ui : 'bdd'
}))
.pipe(istanbul.writeReports());
});
gulp.task('frontEndTests'/*, ['unitTests']*/, function () {
return gulp.src(['./public/test/*.js'])//,
// gulp-mocha needs filepaths so you can't have any plugins before it {reporter: 'nyan'}
.pipe(mocha());
});
gulp.task("compileCoffee", function() {
return gulp.src(["./src/server/coffee/**/*.coffee"]) // Read the files
.pipe(
coffee({bare:true}) // Compile coffeescript
.on("error", function(err) {
console.error(err);
})
)
.pipe(gulp.dest("./temp/server"));// Write complied to disk
});
gulp.task("compileAngularCoffee", function() {
return gulp.src(["./src/client/**/*.coffee"]) // Read the files
.pipe(
coffee({bare:true}) // Compile coffeescript
.on("error", function(err) {
console.error(err);
})
)
.pipe(gulp.dest("./temp/client"));// Write complied to disk
});
gulp.task("minifyServer", ['compileCoffee'], function() {
return gulp.src(["./temp/server/**/*.js"])// Read the files
//.pipe(stripDebug()) // remove logs
.pipe(uglify()) // Minify
//.pipe(rename({extname: ".min.js"})) // Rename to ng-quick-date.min.js
.pipe(gulp.dest("./server")); // Write minified to disk
//TODO remove temp files
});
gulp.task("minifyClient", ['compileAngularCoffee'], function() {
return gulp.src(["./temp/client/**/*.js"])// Read the files
//.pipe(stripDebug()) // remove logs
.pipe(uglify()) // Minify
//.pipe(rename({extname: ".min.js"})) // Rename to ng-quick-date.min.js
.pipe(gulp.dest("./public")); // Write minified to disk
//TODO remove temp files
});
gulp.task('jshintAngular'/*, ['unitTests']*/, function() {
jshintConfig.node=false;
jshintConfig.esnext=false;
jshintConfig.browser=true;
jshintConfig.globals = {browser:true};
return gulp.src(['./public/js/**/*.js', './require.js'])
.pipe(jshint(jshintConfig))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('coffeelintNode', function() {
var opt = {
max_line_length : {
value: 120
}
};
return gulp.src(['src/server/js/**/*.coffee'])
.pipe(coffeelint(opt))
.pipe(coffeelint.reporter());
});
gulp.task('minify', function() {
return gulp.src('public/js/**/*.js')
.pipe(uglify())
.pipe(gulp.dest('public/dist'));
});
gulp.task('prod', ['minify'],function() {
gulp.src('./public/index.html')
//js/app/main.js
.pipe(htmlreplace({
js: {
src: [['dist/app/main.js', './require.js']],
tpl: '<script data-main="%s" src="%s"></script>'
},
version : {
src : [[packageJSON.version]],
tpl : '%s'
}
}))
.pipe(gulp.dest(dist));
});
gulp.task('default', ['coffeelintNode', 'unitTests', 'minifyServer', 'minifyClient', 'templates', 'css']);