Skip to content

Commit

Permalink
build system cleanup. consistent with scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Oct 1, 2016
1 parent 363db44 commit d9661b3
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 81 deletions.
35 changes: 18 additions & 17 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,18 @@ require('./tasks/bump');
// when running just `gulp`
gulp.task('default', [ 'dist' ]);

gulp.task('clean', [
'modules:clean',
'locale:clean',
'minify:clean',
'archive:clean'
], function() {
return del([ // kill these directories, and anything leftover in them
'dist/',
'tmp/'
]);
});

gulp.task('watch', [
'modules:watch',
'locale:watch'
]);

// everything needed for running demos and developing
gulp.task('dev', [
'modules',
'locale'
]);

// watch anything that needs to be built
gulp.task('watch', [
'modules:watch',
'locale:watch'
]);

// generates all files that end up in package manager release
gulp.task('dist', [
'modules',
Expand All @@ -49,3 +38,15 @@ gulp.task('release', [
'archive',
'test:single' // headless, single run
]);

gulp.task('clean', [
'modules:clean',
'locale:clean',
'minify:clean',
'archive:clean'
], function() {
return del([ // kill these directories, and anything leftover in them
'dist/',
'tmp/'
]);
});
48 changes: 28 additions & 20 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,49 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
'node_modules/native-promise-only/lib/npo.src.js',

// dependencies for main lib
'node_modules/moment/moment.js',
'node_modules/jquery/dist/jquery.js',
'node_modules/components-jqueryui/jquery-ui.js',
'node_modules/components-jqueryui/themes/cupertino/jquery-ui.css',

'node_modules/jquery-simulate/jquery.simulate.js',
// main lib files
'dist/fullcalendar.js',
'dist/fullcalendar.css',
'dist/gcal.js',
'dist/locale-all.js',

// For testing if scheduler's JS, even when not actived, screws anything up
//'../fullcalendar-scheduler/dist/scheduler.js',
//'../fullcalendar-scheduler/dist/scheduler.css',

// dependencies for tests
'node_modules/native-promise-only/lib/npo.src.js',
'node_modules/jquery-mockjax/dist/jquery.mockjax.js',
'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
'node_modules/jasmine-fixture/dist/jasmine-fixture.js',
'node_modules/jquery-simulate/jquery.simulate.js',

'tests/lib/jasmine-ext.js',
'tests/lib/simulate.js',
'tests/lib/dom-utils.js',
'tests/lib/dnd-resize-utils.js',
'tests/lib/time-grid.js',
'tests/base.css',

'dist/fullcalendar.js',
'dist/gcal.js',
'dist/locale-all.js',
'dist/fullcalendar.css',

// For testing if scheduler's JS, even when not actived, screws anything up
//'../fullcalendar-scheduler/dist/scheduler.js',
//'../fullcalendar-scheduler/dist/scheduler.css',

// we want everything in these directories to be served, but not included as script tags:
// dist - for sourcemap files
// src - for source files the sourcemap references
// node_modules - 3rd party lib dependencies, like jquery-ui theme images
// (don't let the webserver cache the results)
{ pattern: '{dist,src,node_modules}/**/*', included: false, watched: false, nocache: true },

'tests/automated/*.js'
'tests/automated/*.js',

// serve misc files, but don't watch
{
included: false, // don't immediately execute
nocache: true, // don't let the webserver cache
watched: false, // don't let changes trigger tests to restart
pattern: '{' + [
'dist', // for sourcemap files
'src', // for files referenced by sourcemaps
'node_modules' // 3rd party lib dependencies, like jquery-ui theme images
].join(',') + '}/**/*'
}
],

// list of files to exclude
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"files": [
"dist/*.js",
"dist/*.css",
"dist/locale",
"dist/locale/*.js",
"README.*",
"LICENSE.*",
"CHANGELOG.*",
Expand Down
67 changes: 36 additions & 31 deletions tasks/archive.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var gulp = require('gulp');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var filter = require('gulp-filter');
var replace = require('gulp-replace');
var zip = require('gulp-zip');
Expand Down Expand Up @@ -37,43 +36,43 @@ gulp.task('archive:dist', [ 'modules', 'minify' ], function() {

gulp.task('archive:locale', [ 'locale' ], function() {
return gulp.src([
'dist/locale-all.js',
'dist/locale/*.js'
], {
base: 'dist/'
})
.pipe(gulp.dest('tmp/' + packageId + '/'));
'dist/locale-all.js',
'dist/locale/*.js'
], {
base: 'dist/'
})
.pipe(gulp.dest('tmp/' + packageId + '/'));
});

gulp.task('archive:misc', function() {
return gulp.src([
'LICENSE.*',
'CHANGELOG.*',
'CONTRIBUTING.*'
])
.pipe(rename({ extname: '.txt' }))
.pipe(gulp.dest('tmp/' + packageId + '/'));
'LICENSE.*',
'CHANGELOG.*',
'CONTRIBUTING.*'
])
.pipe(rename({ extname: '.txt' }))
.pipe(gulp.dest('tmp/' + packageId + '/'));
});

gulp.task('archive:deps', [ 'archive:jqui:theme' ], function() {
return gulp.src([
'node_modules/moment/min/moment.min.js',
'node_modules/jquery/dist/jquery.min.js',
'node_modules/components-jqueryui/jquery-ui.min.js'
])
.pipe(gulp.dest('tmp/' + packageId + '/lib/'));
'node_modules/moment/min/moment.min.js',
'node_modules/jquery/dist/jquery.min.js',
'node_modules/components-jqueryui/jquery-ui.min.js'
])
.pipe(gulp.dest('tmp/' + packageId + '/lib/'));
});

// transfers a single jQuery UI theme
gulp.task('archive:jqui:theme', function() {
return gulp.src([
'jquery-ui.min.css',
'images/*'
], {
cwd: 'node_modules/components-jqueryui/themes/cupertino/',
base: 'node_modules/components-jqueryui/themes/'
})
.pipe(gulp.dest('tmp/' + packageId + '/lib/'));
'jquery-ui.min.css',
'images/*'
], {
cwd: 'node_modules/components-jqueryui/themes/cupertino/',
base: 'node_modules/components-jqueryui/themes/'
})
.pipe(gulp.dest('tmp/' + packageId + '/lib/'));
});

// transfers demo files, transforming their paths to dependencies
Expand All @@ -94,12 +93,18 @@ var demoPathReplace = replace(
);

function transformDemoPath(path) {
path = path.replace('../node_modules/moment/moment.js', '../lib/moment.min.js');
path = path.replace('../node_modules/jquery/dist/jquery.js', '../lib/jquery.min.js');
path = path.replace('../node_modules/components-jqueryui/jquery-ui.js', '../lib/jquery-ui.min.js');
path = path.replace('../node_modules/components-jqueryui/themes/cupertino/', '../lib/cupertino/');
path = path.replace('/jquery-ui.css', '/jquery-ui.min.css'); // within the above theme
// reroot 3rd party libs
path = path.replace('../node_modules/moment/', '../lib/');
path = path.replace('../node_modules/jquery/dist/', '../lib/');
path = path.replace('../node_modules/components-jqueryui/themes/cupertino/', '../lib/cupertino/'); // must be first
path = path.replace('../node_modules/components-jqueryui/', '../lib/');

// reroot dist files to archive root
path = path.replace('../dist/', '../');
path = path.replace('/fullcalendar.js', '/fullcalendar.min.js');

// always use minified
// won't mutate .print.css thankfully
path = path.replace(/\/([^\.]+)\.(js|css)/, '/$1.min.$2');

return path;
}
26 changes: 14 additions & 12 deletions tasks/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,23 @@ gulp.task('minify:clean', function() {
// minifies the core modules's js
gulp.task('minify:js', [ 'modules' ], function() {
return gulp.src([
'dist/fullcalendar.js'
])
.pipe(uglify({
preserveComments: 'some' // keep comments starting with !
}))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('dist/'));
'dist/*.js',
'!dist/*.min.js' // avoid double minify
])
.pipe(uglify({
preserveComments: 'some' // keep comments starting with !
}))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest('dist/'));
});

// minifies the core modules's css
gulp.task('minify:css', [ 'modules' ], function() {
return gulp.src([
'dist/fullcalendar.css'
])
.pipe(cssmin())
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('dist/'));
'dist/*.css',
'!dist/*.min.css' // avoid double minify
])
.pipe(cssmin())
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('dist/'));
});

0 comments on commit d9661b3

Please sign in to comment.