-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
146 lines (122 loc) · 4.33 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
/* jshint node: true */
(function (console) {
"use strict";
var gulp = require("gulp");
var gutil = require("gulp-util");
var concat = require("gulp-concat");
var bump = require("gulp-bump");
var html2js = require("gulp-html2js");
var jshint = require("gulp-jshint");
var uglify = require("gulp-uglify");
var runSequence = require("run-sequence");
var path = require("path");
var rename = require("gulp-rename");
var factory = require("widget-tester").gulpTaskFactory;
var del = require("del");
var bower = require("gulp-bower");
var colors = require("colors");
gulp.task("clean-dist", function (cb) {
del(['./dist/**'], cb);
});
gulp.task("clean-tmp", function (cb) {
del(['./tmp/**'], cb);
});
gulp.task("clean", ["clean-dist", "clean-tmp"]);
gulp.task("clean-bower", function(cb){
del(["./components/**"], cb);
});
gulp.task("config", function() {
var env = process.env.NODE_ENV || "dev";
gutil.log("Environment is", env);
return gulp.src(["./src/config/" + env + ".js"])
.pipe(rename("config.js"))
.pipe(gulp.dest("./src/config"));
});
gulp.task("bump", function(){
return gulp.src(["./package.json", "./bower.json"])
.pipe(bump({type:"patch"}))
.pipe(gulp.dest("./"));
});
gulp.task("lint", function() {
return gulp.src("src/**/*.js")
.pipe(jshint())
.pipe(jshint.reporter("jshint-stylish"))
.pipe(jshint.reporter("fail"));
});
gulp.task("angular:html2js", function() {
return gulp.src("src/angular/*.html")
.pipe(html2js({
outputModuleName: "risevision.widget.common.google-spreadsheet-controls",
useStrict: true,
base: "src/angular"
}))
.pipe(rename({extname: ".js"}))
.pipe(gulp.dest("tmp/ng-templates"));
});
gulp.task("angular", ["angular:html2js", "lint"], function () {
return gulp.src([
"src/config/config.js",
"src/angular/dtv-spreadsheet-controls.js",
"tmp/ng-templates/*.js",
"src/angular/svc-spreadsheet-controls.js"])
.pipe(concat("google-spreadsheet-controls.js"))
.pipe(gulp.dest("dist/js/angular"));
});
gulp.task("js-uglify", ["angular"], function () {
gulp.src("dist/js/**/*.js")
.pipe(uglify())
.pipe(rename(function (path) {
path.basename += ".min";
}))
.pipe(gulp.dest("dist/js"));
});
gulp.task("e2e:server-close", factory.testServerClose());
gulp.task("e2e:server", factory.testServer());
gulp.task("webdriver_update", factory.webdriveUpdate());
gulp.task("test:ensure-directory", factory.ensureReportDirectory());
gulp.task("test:e2e:ng:core", factory.testE2EAngular({
testFiles: "./test/e2e/spreadsheet-controls-test.js"
}));
gulp.task("test:metrics", factory.metrics());
gulp.task("test:e2e:ng", ["test:ensure-directory", "webdriver_update"], function (cb) {
return runSequence("e2e:server", "test:e2e:ng:core",
function (err) {
gulp.run("e2e:server-close");
cb(err);
});
});
gulp.task("test:unit:ng", factory.testUnitAngular({
testFiles: [
"components/q/q.js",
"components/angular/angular.js",
"components/angular-mocks/angular-mocks.js",
"node_modules/widget-tester/mocks/common-mock.js",
"node_modules/widget-tester/mocks/spreadsheet-controls-http-mock.js",
"src/config/test.js",
"src/angular/*.js",
"test/unit/**/*spec.js",
"test/unit/mock-modules/*mock.js"
]
}));
// ***** Primary Tasks ***** //
gulp.task("bower-clean-install", ["clean-bower"], function(cb){
return bower().on("error", function(err) {
console.log(err);
cb();
});
});
gulp.task("test", ["build"], function (cb) {
return runSequence("test:unit:ng", "test:e2e:ng", "test:metrics", cb);
});
gulp.task("build", function (cb) {
runSequence(["clean", "config"], "js-uglify", cb);
});
gulp.task("default", [], function() {
console.log("********************************************************************".yellow);
console.log(" gulp bower-clean-install: delete and re-install bower components".yellow);
console.log(" gulp build: build a distribution version".yellow);
console.log(" gulp test: run e2e and unit tests".yellow);
console.log("********************************************************************".yellow);
return true;
});
})(console);