diff --git a/Makefile b/Makefile index c4ba53825..79af4b4e9 100644 --- a/Makefile +++ b/Makefile @@ -142,20 +142,18 @@ appstore: "l10n" \ "templates" \ "timezones" \ + "css/public/app.css" \ "css/public/app.min.css" \ + "css/public/app.min.css.map" \ + "css/public/vendor.css" \ + "css/public/vendor.min.css" \ + "css/public/vendor.min.css.map" \ + "js/public/app.js" \ "js/public/app.min.js" \ - "js/vendor/fullcalendar/dist/fullcalendar.css" \ - "js/vendor/jquery-timepicker/jquery.ui.timepicker.css" \ - "js/vendor/jquery-timepicker/jquery.ui.timepicker.js" \ - "js/vendor/ical.js/build/ical.js" \ - "js/vendor/jstzdetect/jstz.js" \ - "js/vendor/angular/angular.js" \ - "js/vendor/angular-bootstrap/ui-bootstrap.js" \ - "js/vendor/angular-bootstrap/ui-bootstrap-tpls.js" \ - "js/vendor/fullcalendar/dist/fullcalendar.js" \ - "js/vendor/fullcalendar/dist/locale-all.js" \ - "js/vendor/davclient.js/lib/client.js" \ - "js/vendor/hsl_rgb_converter/converter.js" \ + "js/public/app.min.js.map" \ + "js/public/vendor.js" \ + "js/public/vendor.min.js" \ + "js/public/vendor.min.js.map" \ "js/vendor/autosize/dist/autosize.js" \ "COPYING" \ "CHANGELOG.md" \ diff --git a/js/bower.json b/js/bower.json index a0cbc73cc..38bbfb4e6 100644 --- a/js/bower.json +++ b/js/bower.json @@ -6,7 +6,6 @@ "jquery-timepicker": "883bb2cd94", "jstzdetect": "1.0.6", "ical.js": "1.2.2", - "davclient.js": "evert/davclient.js", "fullcalendar": "3.1.0", "hsl_rgb_converter": "https://github.com/kayellpeee/hsl_rgb_converter.git", "autosize": "^3.0.20" diff --git a/js/gulpfile.js b/js/gulpfile.js index 3378cbd78..212a982b0 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -23,14 +23,22 @@ const gulp = require('gulp'), KarmaServer = require('karma').Server, concat = require('gulp-concat'), wrap = require('gulp-wrap'), - strip = require('gulp-strip-banner'), + strip = require('gulp-strip-comments'), + stripCSS = require('gulp-strip-css-comments'), babel = require('gulp-babel'), stylelint = require('gulp-stylelint'), sourcemaps = require('gulp-sourcemaps'); +const gulpsync = require('gulp-sync')(gulp); // configure -const buildTarget = 'app.min.js'; -const cssBuildTarget = 'app.min.css'; +const buildTarget = 'app.js'; +const buildTargetMin = 'app.min.js'; +const cssBuildTarget = 'app.css'; +const cssBuildTargetMin = 'app.min.css'; +const vendorTarget = 'vendor.js'; +const vendorTargetMin = 'vendor.min.js'; +const vendorCssTarget = 'vendor.css'; +const vendorCssTargetMin = 'vendor.min.css'; const karmaConfig = __dirname + '/../tests/js/config/karma.js'; const destinationFolder = __dirname + '/public/'; const cssDestinationFolder = __dirname + '/../css/public/'; @@ -42,20 +50,40 @@ const jsSources = [ const cssSources = [ '../css/app/*.css' ]; +const vendorSources = [ + 'vendor/angular/angular.js', + 'vendor/angular-bootstrap/ui-bootstrap-tpls.js', + 'vendor/fullcalendar/dist/fullcalendar.js', + 'vendor/fullcalendar/dist/locale-all.js', + 'licenses/hsl_rgb_converter.js', + 'vendor/hsl_rgb_converter/converter.js', + 'vendor/ical.js/build/ical.js', + 'vendor/jquery-timepicker/jquery.ui.timepicker.js', + 'vendor/jstzdetect/jstz.js', +]; +const vendorCssSources = [ + 'vendor/fullcalendar/dist/fullcalendar.css', + 'licenses/jquery.timepicker.css', + 'vendor/jquery-timepicker/jquery.ui.timepicker.css' +]; const testSources = ['../tests/js/unit/**/*.js']; const watchSources = jsSources.concat(testSources).concat(['*.js']); const lintSources = watchSources; // tasks -gulp.task('default', ['lint', 'csslint'], () => { - // build css +gulp.task('default', ['lint', 'csslint', 'buildS', 'vendor']); +gulp.task('build', ['lint', 'csslint', 'buildS']); + +gulp.task('buildS', gulpsync.sync(['buildSources', 'minifySources'])); +gulp.task('vendor', gulpsync.sync(['buildVendor', 'minifyVendor'])); + +gulp.task('buildSources', () => { gulp.src(cssSources) - .pipe(strip()) - .pipe(sourcemaps.init({identityMap: true})) + .pipe(stripCSS({ + preserve: false + })) .pipe(concat(cssBuildTarget)) - .pipe(uglifyCSS()) - .pipe(sourcemaps.write('./')) .pipe(gulp.dest(cssDestinationFolder)); return gulp.src(jsSources) @@ -67,15 +95,56 @@ gulp.task('default', ['lint', 'csslint'], () => { })) .pipe(ngAnnotate()) .pipe(strip()) - .pipe(sourcemaps.init({identityMap: true})) .pipe(concat(buildTarget)) .pipe(wrap(`(function(angular, $, oc_requesttoken, undefined){ - 'use strict'; - <%= contents %> })(angular, jQuery, oc_requesttoken);`)) + .pipe(gulp.dest(destinationFolder)); +}); + +gulp.task('minifySources', () => { + gulp.src([cssDestinationFolder + cssBuildTarget]) + .pipe(concat(cssBuildTargetMin)) + .pipe(sourcemaps.init({identityMap: true, largeFile: true})) + .pipe(uglifyCSS()) + .pipe(sourcemaps.write('./', {includeContent: false})) + .pipe(gulp.dest(cssDestinationFolder)); + + return gulp.src([destinationFolder + buildTarget]) + .pipe(concat(buildTargetMin)) + .pipe(sourcemaps.init({identityMap: true, largeFile: true})) + .pipe(uglify()) + .pipe(sourcemaps.write('./', {includeContent: false})) + .pipe(gulp.dest(destinationFolder)); +}); + +gulp.task('buildVendor', () => { + gulp.src(vendorCssSources) + .pipe(concat(vendorCssTarget)) + .pipe(gulp.dest(cssDestinationFolder)); + + return gulp.src(vendorSources) + .pipe(concat(vendorTarget)) + .pipe(gulp.dest(destinationFolder)); +}); + +gulp.task('minifyVendor', () => { + gulp.src([cssDestinationFolder + vendorCssTarget]) + .pipe(concat(vendorCssTargetMin)) + .pipe(sourcemaps.init({identityMap: true, largeFile: true})) + .pipe(stripCSS({ + preserve: false + })) + .pipe(uglifyCSS()) + .pipe(sourcemaps.write('./', {includeContent: false})) + .pipe(gulp.dest(cssDestinationFolder)); + + return gulp.src([destinationFolder + vendorTarget]) + .pipe(concat(vendorTargetMin)) + .pipe(sourcemaps.init({identityMap: true, largeFile: true})) + .pipe(strip()) .pipe(uglify()) - .pipe(sourcemaps.write('./')) + .pipe(sourcemaps.write('./', {includeContent: false})) .pipe(gulp.dest(destinationFolder)); }); diff --git a/js/licenses/hsl_rgb_converter.js b/js/licenses/hsl_rgb_converter.js new file mode 100644 index 000000000..e2b10d963 --- /dev/null +++ b/js/licenses/hsl_rgb_converter.js @@ -0,0 +1,5 @@ +/*! + HSL RGB Converter + author: Keenan Lidral-Porter + license: ISC + */ diff --git a/js/licenses/jquery.timepicker.css b/js/licenses/jquery.timepicker.css new file mode 100644 index 000000000..b8cf10288 --- /dev/null +++ b/js/licenses/jquery.timepicker.css @@ -0,0 +1,9 @@ +/* + * jQuery UI Timepicker + * + * Copyright 2010-2013, Francois Gelinas + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://fgelinas.com/code/timepicker + */ diff --git a/js/package.json b/js/package.json index b50561544..68728cc2c 100644 --- a/js/package.json +++ b/js/package.json @@ -26,8 +26,10 @@ "gulp-jshint": "^2.0.4", "gulp-ng-annotate": "^2.0.0", "gulp-sourcemaps": "^2.4.0", - "gulp-strip-banner": "0.0.2", + "gulp-strip-comments": "^2.4.3", + "gulp-strip-css-comments": "^1.2.0", "gulp-stylelint": "^3.7.0", + "gulp-sync": "^0.1.4", "gulp-uglify": "^2.0.0", "gulp-uglifycss": "^1.0.6", "gulp-wrap": "^0.13.0", diff --git a/js/yarn.lock b/js/yarn.lock index 3d6d19f7b..78a9993a1 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -1051,17 +1051,13 @@ date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" -dateformat@^1.0.6: +dateformat@^1.0.11, dateformat@^1.0.6: version "1.0.12" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" dependencies: get-stdin "^4.0.1" meow "^3.3.0" -dateformat@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.0.0.tgz#2743e3abb5c3fc2462e527dca445e04e9f4dee17" - debug-fabulous@0.0.X: version "0.0.4" resolved "https://registry.yarnpkg.com/debug-fabulous/-/debug-fabulous-0.0.4.tgz#fa071c5d87484685424807421ca4b16b0b1a0763" @@ -1090,6 +1086,12 @@ decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" +decomment@^0.8.6: + version "0.8.7" + resolved "https://registry.yarnpkg.com/decomment/-/decomment-0.8.7.tgz#248f2116f6ce3a8e8dd1b63e5b35aba5ca054ca5" + dependencies: + esprima "3.1" + deep-extend@^0.4.1, deep-extend@~0.4.0: version "0.4.1" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" @@ -1307,6 +1309,10 @@ esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.1: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" +esprima@3.1: + version "3.1.3" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633" + estraverse@^1.9.1: version "1.9.3" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" @@ -1506,12 +1512,6 @@ form-data@~2.1.1: combined-stream "^1.0.5" mime-types "^2.1.12" -fs-access@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a" - dependencies: - null-check "^1.0.0" - fs-exists-sync@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add" @@ -1824,13 +1824,21 @@ gulp-sourcemaps@^2.4.0: through2 "2.X" vinyl "1.X" -gulp-strip-banner@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/gulp-strip-banner/-/gulp-strip-banner-0.0.2.tgz#8d3c046552c13d2d844692349f2db985c61c952b" +gulp-strip-comments@^2.4.3: + version "2.4.3" + resolved "https://registry.yarnpkg.com/gulp-strip-comments/-/gulp-strip-comments-2.4.3.tgz#e219b7c7beac1aba6c36e0aff1db7c5ae2c1c1b0" dependencies: - gulp-util "^3.0.1" - strip-comments "^0.3.2" - through2 "^0.6.1" + decomment "^0.8.6" + gulp-util "3.0.7" + through2 "^2.0.1" + +gulp-strip-css-comments@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/gulp-strip-css-comments/-/gulp-strip-css-comments-1.2.0.tgz#fe79863ce32f50dd4cbe8d0db56f476c86cfb9b8" + dependencies: + gulp-util "^3.0.0" + strip-css-comments "^3.0.0" + through2 "^2.0.0" gulp-stylelint@^3.7.0: version "3.7.0" @@ -1844,6 +1852,10 @@ gulp-stylelint@^3.7.0: stylelint "^7.7.0" through2 "^2.0.3" +gulp-sync@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/gulp-sync/-/gulp-sync-0.1.4.tgz#22eb9528f95737d4715c01272180a08f24133db5" + gulp-uglify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/gulp-uglify/-/gulp-uglify-2.0.0.tgz#cbe4aae4fe0b6bdd760335bc46f200fff699c4af" @@ -1865,15 +1877,15 @@ gulp-uglifycss@^1.0.6: through2 "~2.0.1" uglifycss "~0.0.20" -gulp-util@^3.0.0, gulp-util@^3.0.1, gulp-util@^3.0.3, gulp-util@^3.0.7, gulp-util@~3.0.7: - version "3.0.8" - resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" +gulp-util@3.0.7, gulp-util@^3.0.0, gulp-util@^3.0.3, gulp-util@^3.0.7, gulp-util@~3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.7.tgz#78925c4b8f8b49005ac01a011c557e6218941cbb" dependencies: array-differ "^1.0.0" array-uniq "^1.0.2" beeper "^1.0.0" chalk "^1.0.0" - dateformat "^2.0.0" + dateformat "^1.0.11" fancy-log "^1.1.0" gulplog "^1.0.0" has-gulplog "^0.1.0" @@ -2420,13 +2432,6 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.3.6" -karma-chrome-launcher@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-2.0.0.tgz#c2790c5a32b15577d0fff5a4d5a2703b3b439c25" - dependencies: - fs-access "^1.0.0" - which "^1.2.1" - karma-coverage@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/karma-coverage/-/karma-coverage-1.1.1.tgz#5aff8b39cf6994dc22de4c84362c76001b637cf6" @@ -2991,10 +2996,6 @@ npmlog@^4.0.1: gauge "~2.7.1" set-blocking "~2.0.0" -null-check@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd" - num2fraction@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede" @@ -3401,7 +3402,7 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" -readable-stream@1.1, readable-stream@~1.1.9: +readable-stream@1.1, readable-stream@^1.0.33, readable-stream@~1.1.9: version "1.1.14" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" dependencies: @@ -3410,7 +3411,7 @@ readable-stream@1.1, readable-stream@~1.1.9: isarray "0.0.1" string_decoder "~0.10.x" -"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@^1.0.33, readable-stream@~1.0.2: +"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.2: version "1.0.34" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" dependencies: @@ -3937,9 +3938,11 @@ strip-bom@^2.0.0: dependencies: is-utf8 "^0.2.0" -strip-comments@^0.3.2: - version "0.3.4" - resolved "https://registry.yarnpkg.com/strip-comments/-/strip-comments-0.3.4.tgz#e1cb91b86de432540d13db2da8e81ae0d4e2ecbf" +strip-css-comments@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-css-comments/-/strip-css-comments-3.0.0.tgz#7a5625eff8a2b226cf8947a11254da96e13dae89" + dependencies: + is-regexp "^1.0.0" strip-indent@^1.0.1: version "1.0.1" @@ -4327,7 +4330,7 @@ void-elements@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" -which@^1.1.1, which@^1.2.1, which@^1.2.12, which@~1.2.10: +which@^1.1.1, which@^1.2.12, which@~1.2.10: version "1.2.12" resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192" dependencies: diff --git a/templates/main.php b/templates/main.php index 832c0cea8..06031682c 100644 --- a/templates/main.php +++ b/templates/main.php @@ -31,8 +31,7 @@ OCP\Util::addHeader('meta', ['property' => "og:image", 'content' => $_['previewImage']]); } $styles = [ - '../js/vendor/fullcalendar/dist/fullcalendar', - '../js/vendor/jquery-timepicker/jquery.ui.timepicker', + 'public/vendor.min', 'public/app.min' ]; @@ -41,17 +40,8 @@ } $scripts = [ - 'vendor/jquery-timepicker/jquery.ui.timepicker', - 'vendor/ical.js/build/ical', - 'vendor/jstzdetect/jstz', - 'vendor/angular/angular', - 'vendor/angular-bootstrap/ui-bootstrap', - 'vendor/angular-bootstrap/ui-bootstrap-tpls', - 'vendor/fullcalendar/dist/fullcalendar', - 'vendor/fullcalendar/dist/locale-all', - 'vendor/davclient.js/lib/client', - 'vendor/hsl_rgb_converter/converter', - 'public/app.min' + 'public/vendor.min', + 'public/app.min', ]; if ($_['needsAutosize']) { diff --git a/tests/js/config/karma.js b/tests/js/config/karma.js index db7553b2e..3bdd88fd5 100644 --- a/tests/js/config/karma.js +++ b/tests/js/config/karma.js @@ -31,13 +31,13 @@ module.exports = function (config) { '../../core/vendor/jquery/dist/jquery.js', '../../core/vendor/jquery/jquery.js', '../../core/vendor/moment/min/moment-with-locales.js', + '../../core/vendor/davclient.js/lib/client.js', 'js/vendor/jstzdetect/jstz.min.js', 'js/vendor/fullcalendar/dist/fullcalendar.min.js', 'js/vendor/angular/angular.js', 'js/vendor/angular-mocks/angular-mocks.js', 'js/vendor/ical.js/build/ical.js', 'js/vendor/hsl_rgb_converter/converter.js', - 'js/vendor/davclient.js/lib/client.js', 'tests/js/stubs/app.js', 'js/app/**/*.js', 'tests/js/unit/**/*.js'