1 | var utils = require('../utils');
|
2 | var gulp = require('gulp');
|
3 | var debug = require('gulp-debug');
|
4 | var gulpif = require('gulp-if');
|
5 | var replace = require('gulp-replace');
|
6 | var zip = require('gulp-zip');
|
7 | var concat = require('gulp-concat');
|
8 | var exit = require('gulp-exit');
|
9 | var del = require('del');
|
10 | var sourcemaps = require('gulp-sourcemaps');
|
11 | var common = require('./common');
|
12 | var _ = require('lodash');
|
13 |
|
14 | gulp.task('plugin_concat', ['compile-main', 'templates'], function() {
|
15 | return gulp.src([common.dist.main + "/**/*.js", common.dist.main + "/templates/*.js"])
|
16 | .pipe(concat( common.bundles.main ))
|
17 | .pipe(gulpif(common.watch, replace('/dist/', '/')))
|
18 | .pipe(gulpif(common.watch, replace('http://localhost:' + common.port + '/../', 'http://localhost:' + common.port + '/')))
|
19 | .pipe(debug())
|
20 | .pipe(gulp.dest('build/'))
|
21 | });
|
22 |
|
23 | function packagePlugin() {
|
24 | var file = common.module.main + (common.pkg.plugin ? ".zip" : ".war");
|
25 | del.sync('tmp');
|
26 | utils.sh("mkdir -p tmp/System/plugins/" + common.pkg.plugin + "/");
|
27 | utils.sh("cp build/*.js tmp/System/plugins/" + common.pkg.plugin + "/");
|
28 | console.log('Deploying to ' + common.deploy + "/" + file);
|
29 | return gulp.src(["tmp/**/*"])
|
30 | .pipe(zip(file))
|
31 | .pipe(gulp.dest(common.deploy))
|
32 | .pipe(gulp.dest('.'))
|
33 | }
|
34 |
|
35 | gulp.task('plugin', ['plugin_concat'], function() {
|
36 | return packagePlugin();
|
37 | });
|
38 |
|
39 | gulp.task('plugin-dev-package', ['dev-bundle-main', 'styles', 'resources'], function() {
|
40 | return packagePlugin();
|
41 | });
|
42 |
|
43 | gulp.task('plugin_watch', ['plugin-dev-package', 'dev-bundle-tests', 'webserver'], function() {
|
44 | _.each(common.bundleKinds, function(kind) {
|
45 | gulp.watch([common.srcDirs[kind] + '/**/*.js'], ['dev-recompile-' + kind]);
|
46 | gulp.watch([common.srcDirs[kind] + '/.lib-exports.js'], ['dev-recompile-' + kind, 'generate-systemjs-' + kind + '-index']);
|
47 | });
|
48 | gulp.watch(['**/.dev-loader.js'], ['plugin-dev-package']);
|
49 | gulp.watch('src/**/*.hbs', ['templates']);
|
50 | gulp.watch('style/**/*.*', ['styles']);
|
51 | });
|