forked from konvajs/konva
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
158 lines (137 loc) · 4.02 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
'use strict';
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var replace = require('gulp-replace');
var mochaPhantomJS = require('gulp-mocha-phantomjs');
var jsdoc = require('gulp-jsdoc');
var connect = require('gulp-connect');
var jscpd = require('gulp-jscpd');
var eslint = require('gulp-eslint');
var fs = require('fs');
var NodeParams = fs.readFileSync('./resources/doc-includes/NodeParams.txt').toString();
var ContainerParams = fs.readFileSync('./resources/doc-includes/ContainerParams.txt').toString();
var ShapeParams = fs.readFileSync('./resources/doc-includes/ShapeParams.txt').toString();
var conf = require('./package.json');
var sourceFiles = [
// core
'src/Global.js',
'src/Util.js',
'src/Canvas.js',
'src/Context.js',
'src/Factory.js',
'src/Node.js',
// filters
'src/filters/Grayscale.js',
'src/filters/Brighten.js',
'src/filters/Invert.js',
'src/filters/Blur.js',
'src/filters/Mask.js',
'src/filters/RGB.js',
'src/filters/RGBA.js',
'src/filters/HSV.js',
'src/filters/HSL.js',
'src/filters/Emboss.js',
'src/filters/Enhance.js',
'src/filters/Posterize.js',
'src/filters/Noise.js',
'src/filters/Pixelate.js',
'src/filters/Threshold.js',
'src/filters/Sepia.js',
'src/filters/Solarize.js',
'src/filters/Kaleidoscope.js',
// core
'src/Container.js',
'src/Shape.js',
'src/Stage.js',
'src/BaseLayer.js',
'src/Layer.js',
'src/FastLayer.js',
'src/Group.js',
'src/Animation.js',
'src/Tween.js',
'src/DragAndDrop.js',
// shapes
'src/shapes/Rect.js',
'src/shapes/Circle.js',
'src/shapes/Ellipse.js',
'src/shapes/Ring.js',
'src/shapes/Wedge.js',
'src/shapes/Arc.js',
'src/shapes/Image.js',
'src/shapes/Text.js',
'src/shapes/Line.js',
'src/shapes/Sprite.js',
'src/shapes/Path.js',
'src/shapes/TextPath.js',
'src/shapes/RegularPolygon.js',
'src/shapes/Star.js',
'src/shapes/Label.js',
'src/shapes/Arrow.js'
];
function build() {
return gulp.src(sourceFiles)
.pipe(concat('konva-dev.js'))
.pipe(replace('@@shapeParams', ShapeParams))
.pipe(replace('@@nodeParams', NodeParams))
.pipe(replace('@@containerParams', ContainerParams))
.pipe(replace('@@version', conf.version))
.pipe(replace('@@date', new Date().toDateString()));
}
// create development build
gulp.task('dev-build', function() {
return build()
.pipe(gulp.dest('./dist/'));
});
// create usual build konva.js and konva.min.js
gulp.task('build', function() {
return build()
.pipe(rename('konva.js'))
.pipe(gulp.dest('./'))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(rename('konva.min.js'))
.pipe(gulp.dest('./'));
});
// tun tests
gulp.task('test', ['dev-build'], function () {
return gulp
.src('test/runner.html')
.pipe(mochaPhantomJS());
});
// local server for better development
gulp.task('server', function() {
connect.server();
});
// lint files
gulp.task('lint', function() {
return gulp.src('./src/**/*.js')
.pipe(eslint({
configFile: './.eslintrc'
}))
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last.
.pipe(eslint.failOnError());
});
// check code for duplication
gulp.task('inspect', function() {
return gulp.src('./src/**/*.js')
.pipe(jscpd({
'min-lines': 10,
verbose: true
}));
});
// generate documentation
gulp.task('api', function() {
return gulp.src('./src/**/*.js')
.pipe(jsdoc('./api'));
});
gulp.task('watch', function() {
gulp.watch(['src/**/*.js'], ['dev-build']);
});
gulp.task('default', ['dev-build', 'watch', 'server']);