forked from dfulgham/widget-web-page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
171 lines (143 loc) · 5.38 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
/* jshint node: true */
(function () {
"use strict";
var gulp = require("gulp");
var gutil = require("gulp-util");
var rimraf = require("gulp-rimraf");
var concat = require("gulp-concat");
var bump = require("gulp-bump");
var jshint = require("gulp-jshint");
var minifyCSS = require("gulp-minify-css");
var usemin = require("gulp-usemin");
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 sourcemaps = require("gulp-sourcemaps");
var html2js = require("gulp-html2js");
var appJSFiles = [
"src/**/*.js",
"!./src/components/**/*"
];
gulp.task("clean-dist", function () {
return gulp.src("dist", {read: false})
.pipe(rimraf());
});
gulp.task("clean-tmp", function () {
return gulp.src("tmp", {read: false})
.pipe(rimraf());
});
gulp.task("clean", ["clean-dist", "clean-tmp"]);
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(appJSFiles)
.pipe(jshint())
.pipe(jshint.reporter("jshint-stylish"))
.pipe(jshint.reporter("fail"));
});
gulp.task("source", ["lint"], function () {
return gulp.src(['./src/settings.html', './src/widget.html'])
.pipe(usemin({
css: [minifyCSS()],
js: [sourcemaps.init(), uglify(), sourcemaps.write()]
}))
.pipe(gulp.dest("dist/"));
});
gulp.task("unminify", function () {
return gulp.src(['./src/settings.html', './src/widget.html'])
.pipe(usemin({
css: [rename(function (path) {
path.basename = path.basename.substring(0, path.basename.indexOf(".min"))
}), gulp.dest("dist")],
js: [rename(function (path) {
path.basename = path.basename.substring(0, path.basename.indexOf(".min"))
}), gulp.dest("dist")]
}))
});
gulp.task("fonts", function() {
return gulp.src("src/components/common-style/dist/fonts/**/*")
.pipe(gulp.dest("dist/fonts"));
});
gulp.task("images", function() {
return gulp.src("src/components/rv-bootstrap-formhelpers/img/bootstrap-formhelpers-googlefonts.png")
.pipe(gulp.dest("dist/img"));
});
gulp.task("i18n", function(cb) {
return gulp.src(["src/components/rv-common-i18n/dist/locales/**/*"])
.pipe(gulp.dest("dist/locales"));
});
gulp.task("build", function (cb) {
runSequence(["clean", "config"], ["source", "fonts", "images", "i18n"], ["unminify"], cb);
});
gulp.task("html:e2e",
factory.htmlE2E({
files: ["./src/settings.html", "./src/widget.html"],
e2eMockData: "../test/mock-data.js"
}));
gulp.task("test:unit:settings", factory.testUnitAngular(
{testFiles: [
"src/components/jquery/dist/jquery.js",
"src/components/q/q.js",
"src/components/angular/angular.js",
"src/components/angular-translate/angular-translate.js",
"src/components/angular-translate-loader-static-files/angular-translate-loader-static-files.js",
"src/components/angular-route/angular-route.js",
"src/components/angular-mocks/angular-mocks.js",
"node_modules/widget-tester/mocks/common-mock.js",
"src/components/bootstrap-sass-official/assets/javascripts/bootstrap.js",
"src/components/angular-bootstrap/ui-bootstrap-tpls.js",
"src/components/component-storage-selector/dist/storage-selector.js",
"src/components/widget-settings-ui-components/dist/js/**/*.js",
"src/components/widget-settings-ui-core/dist/*.js",
"src/components/bootstrap-form-components/dist/js/**/*.js",
"src/config/test.js",
"src/settings/settings-app.js",
"src/settings/**/*.js",
"test/mock-data.js",
"test/unit/settings/**/*spec.js"]}
));
gulp.task("test:unit:widget", factory.testUnitAngular(
{testFiles: [
"src/components/jquery/dist/jquery.js",
"test/mock-data.js",
"node_modules/widget-tester/mocks/gadget-mocks.js",
"src/config/test.js",
"src/widget/webpage.js",
"src/widget/main.js",
"test/unit/widget/**/*spec.js"]}
));
gulp.task("webdriver_update", factory.webdriveUpdate());
gulp.task("e2e:server-close", factory.testServerClose());
gulp.task("test:metrics", factory.metrics());
gulp.task("e2e:server", ["config", "html:e2e"], factory.testServer());
gulp.task("test:e2e:widget", factory.testE2E({
testFiles: "test/e2e/widget-scenarios.js"}
));
gulp.task("test:e2e:settings", ["webdriver_update"], factory.testE2EAngular({
testFiles: "test/e2e/settings-scenarios.js"}
));
gulp.task("test:e2e", function(cb) {
runSequence(["html:e2e", "e2e:server"], "test:e2e:widget", "test:e2e:settings", "e2e:server-close", cb);
});
gulp.task("test:unit", function(cb) {
runSequence("test:unit:widget", "test:unit:settings", cb);
});
gulp.task("test", function(cb) {
runSequence("build", "test:unit", "test:e2e", "test:metrics", cb);
});
gulp.task("default", function(cb) {
runSequence("test", "build", cb);
});
})();