summaryrefslogtreecommitdiffstats
path: root/js/gulpfile.js
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2016-02-11 22:36:29 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2016-02-11 22:36:29 +0100
commit13e6e80281a0c7ddc980006ae39ae3bae4cb03d1 (patch)
tree767d7556cb419ab48bbb75e2563eeb1623ebd225 /js/gulpfile.js
parentc191ea52765c2515560eee01c62c61485b1ff6af (diff)
migrate js build system to gulp
Diffstat (limited to 'js/gulpfile.js')
-rw-r--r--js/gulpfile.js93
1 files changed, 93 insertions, 0 deletions
diff --git a/js/gulpfile.js b/js/gulpfile.js
new file mode 100644
index 000000000..497fd6959
--- /dev/null
+++ b/js/gulpfile.js
@@ -0,0 +1,93 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+
+'use strict';
+
+let gulp = require('gulp'),
+ ngAnnotate = require('gulp-ng-annotate'),
+ uglify = require('gulp-uglify'),
+ jshint = require('gulp-jshint'),
+ KarmaServer = require('karma').Server,
+ phpunit = require('gulp-phpunit'),
+ concat = require('gulp-concat'),
+ sourcemaps = require('gulp-sourcemaps');
+
+/**
+ * Configuration
+ */
+let phpunitConfig = __dirname + '/../phpunit.xml';
+let karmaConfig = __dirname + '/karma.conf.js';
+let destinationFolder = __dirname + '/build/';
+let sources = [
+ 'app/App.js', 'app/Config.js', 'app/Run.js',
+ 'controller/**/*.js',
+ 'filter/**/*.js',
+ 'service/**/*.js',
+ 'gui/**/*.js',
+ 'plugin/**/*.js',
+ 'utility/**/*.js',
+ 'directive/**/*.js'
+];
+
+let testSources = [
+ 'tests/**/*.js'
+];
+
+let phpSources = [
+ '../*/**.php',
+ '!../js/*/**',
+ '!../vendor/*/**'
+];
+
+gulp.task('default', ['lint'], () => {
+ return gulp.src(sources)
+ .pipe(ngAnnotate())
+ .pipe(sourcemaps.init())
+ .pipe(concat('app.min.js'))
+ .pipe(uglify())
+ .pipe(sourcemaps.write())
+ .pipe(gulp.dest(destinationFolder));
+});
+
+gulp.task('lint', () => {
+ return gulp.src('*/**.js')
+ .pipe(jshint())
+ .pipe(jshint.reporter('jshint-stylish'))
+ .pipe(jshint.reporter('fail'));
+});
+
+gulp.task('watch', () => {
+ gulp.watch(sources.concat(testSources).concat('*.js'), ['default']);
+});
+
+gulp.task('karma', (done) => {
+ new KarmaServer({
+ configFile: karmaConfig,
+ singleRun: true
+ }, done).start();
+})
+
+gulp.task('watch-karma', (done) => {
+ new KarmaServer({
+ configFile: karmaConfig,
+ autoWatch: true
+ }, done).start();
+})
+
+gulp.task('phpunit', () => {
+ gulp.src(phpSources)
+ .pipe(phpunit('phpunit', {
+ configurationFile: phpunitConfig
+ }));
+});
+
+gulp.task('watch-phpunit', () => {
+ gulp.watch(phpSources, ['phpunit']);
+});