-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgulpfile.js
More file actions
198 lines (168 loc) · 5.43 KB
/
Copy pathgulpfile.js
File metadata and controls
198 lines (168 loc) · 5.43 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
var gulp = require('gulp');
var exec = require('child_process').exec;
// Gulp task to generate development documentation;
gulp.task('doc', function (done) {
console.log('Generating documentation...');
exec('node_modules/.bin/jsdoc -R readme.md -d docs src/js/*', function (err, stdout, stderr) {
if (err) return done(err);
console.log('Documentation generated in "docs" directory');
done();
});
});
// Task and dependencies to convert ES6 to ES5 with babel;
//var babel = require('babelify');
//var browserify = require('browserify');
//var source = require('vinyl-source-stream');
//
//gulp.task('build', function() {
// var bundler = browserify('./src/js/NodejsProtoStub.js', {
// standalone: 'activate',
// debug: false
// }).transform(babel);
//
// function rebundle() {
// bundler.bundle()
// .on('error', function(err) {
// console.error(err);
// this.emit('end');
// })
// .pipe(source('NodejsProtoStub.js'))
// .pipe(gulp.dest('./target'));
// }
//
// rebundle();
//});
gulp.task('build', function () {
return browserify('./src/js/NodejsProtoStub.js', {
standalone: 'activate',
bare: true,
browserField: false,
builtins: false
})
.transform(babel)
.bundle()
.on('error', function (err) {
console.error(err);
this.emit('end');
})
.pipe(source('NodejsProtoStub.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(insert.prepend('// Node JS ProtoStub \n\n// version: {{version}}\n\n'))
.pipe(replace('{{version}}', pkg.version))
.pipe(gulp.dest('./target'));
});
// Task and dependencies to convert ES6 to ES5 with babel distribute for all environments;
var babel = require('babelify');
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var replace = require('gulp-replace');
var insert = require('gulp-insert');
var uglify = require('gulp-uglify');
var bump = require('gulp-bump');
var pkg = require('./package.json');
gulp.task('build', function () {
return browserify('./src/js/NodejsProtoStub.js', {
standalone: 'activate',
debug: false,
})
.transform(babel)
.bundle()
.on('error', function (err) {
console.error(err);
this.emit('end');
})
.pipe(source('NodejsProtoStub.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(insert.prepend('// Node JS ProtoStub \n\n// version: {{version}}\n\n'))
.pipe(replace('{{version}}', pkg.version))
.pipe(gulp.dest('./target'));
});
/**
* Bumping version number and tagging the repository with it.
* Please read http://semver.org/
*
* You can use the commands
*
* gulp patch # makes v0.1.0 → v0.1.1
* gulp feature # makes v0.1.1 → v0.2.0
* gulp release # makes v0.2.1 → v1.0.0
*
* To bump the version numbers accordingly after you did a patch,
* introduced a feature or made a backwards-incompatible release.
*/
function inc(importance) {
// get all the files to bump version in
return gulp.src(['./package.json'])
// bump the version number in those files
.pipe(bump({ type: importance }))
// save it back to filesystem
.pipe(gulp.dest('./'));
}
gulp.task('patch', ['test'], function () { return inc('patch'); });
gulp.task('feature', ['test'], function () { return inc('minor'); });
gulp.task('release', ['test'], function () { return inc('major'); });
var Server = require('karma').Server;
/**
* Run test once and exit
*/
gulp.task('test', function (done) {
new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true,
}, done).start();
});
var replace = require('gulp-replace');
var argv = require('yargs').argv;
var through = require('through2');
var path = require('path');
var gulpif = require('gulp-if');
var insert = require('gulp-insert');
gulp.task('license', function () {
var clean = argv.clean;
if (!clean) clean = false;
return gulp.src(['src/**/*.java', 'src/**/*.js'])
.pipe(prependLicense(clean));
});
function prependLicense(clean) {
var license = '/**\n' +
'* Copyright 2016 PT Inovação e Sistemas SA\n' +
'* Copyright 2016 INESC-ID\n' +
'* Copyright 2016 QUOBIS NETWORKS SL\n' +
'* Copyright 2016 FRAUNHOFER-GESELLSCHAFT ZUR FOERDERUNG DER ANGEWANDTEN FORSCHUNG E.V\n' +
'* Copyright 2016 ORANGE SA\n' +
'* Copyright 2016 Deutsche Telekom AG\n' +
'* Copyright 2016 Apizee\n' +
'* Copyright 2016 TECHNISCHE UNIVERSITAT BERLIN\n' +
'*\n' +
'* Licensed under the Apache License, Version 2.0 (the "License");\n' +
'* you may not use this file except in compliance with the License.\n' +
'* You may obtain a copy of the License at\n' +
'*\n' +
'* http://www.apache.org/licenses/LICENSE-2.0\n' +
'*\n' +
'* Unless required by applicable law or agreed to in writing, software\n' +
'* distributed under the License is distributed on an "AS IS" BASIS,\n' +
'* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' +
'* See the License for the specific language governing permissions and\n' +
'* limitations under the License.\n' +
'**/\n\n';
return through.obj(function (file, enc, cb) {
if (file.isNull()) {
return cb(new Error('Fil is null'));
}
if (file.isStream()) {
return cb(new Error('Streaming not supported'));
}
var dest = path.dirname(file.path);
return gulp.src(file.path)
.pipe(replace(license, ''))
.pipe(gulpif(!clean, insert.prepend(license)))
.pipe(gulp.dest(dest))
.on('end', function () {
cb();
});
});
}