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 sourcemaps = require('gulp-sourcemaps');
|
10 | var common = require('./common');
|
11 | var _ = require('lodash');
|
12 | var path = require('path');
|
13 | var shelljs = require('shelljs');
|
14 |
|
15 | gulp.task('plugin_concat', ['compile-main', 'templates'], function() {
|
16 | return gulp.src([common.dist.main + "/**/*.js", common.dist.main + "/templates/*.js"])
|
17 | .pipe(concat( common.bundles.main ))
|
18 | .pipe(gulpif(common.watch, replace('/dist/', '/')))
|
19 | .pipe(gulpif(common.watch, replace('http://localhost:' + common.port + '/../', 'http://localhost:' + common.port + '/')))
|
20 | .pipe(debug())
|
21 | .pipe(gulp.dest('build/'))
|
22 | });
|
23 |
|
24 | function packagePlugin() {
|
25 | var file = common.module.main + (common.pkg.plugin ? ".zip" : ".war");
|
26 | var distDir = 'tmp';
|
27 | shelljs.rm('-rf', distDir);
|
28 | var pluginDir = path.join(distDir, "System", "plugins", common.pkg.plugin);
|
29 | shelljs.mkdir("-p", pluginDir);
|
30 | shelljs.cp("build/*.js", pluginDir);
|
31 | var metaInfPluginDir = path.join(distDir, "META-INF");
|
32 | shelljs.mkdir("-p", metaInfPluginDir);
|
33 | shelljs.cp("package.json", metaInfPluginDir);
|
34 | return gulp.src(["tmp/**/*"])
|
35 | .pipe(zip(file))
|
36 | .pipe(gulp.dest(common.deploy))
|
37 | .pipe(gulp.dest('.'))
|
38 | }
|
39 |
|
40 | gulp.task('plugin', ['plugin_concat'], function() {
|
41 | return packagePlugin();
|
42 | });
|
43 |
|
44 | gulp.task('plugin-dev-package', ['dev-bundle-main', 'styles', 'resources'], function() {
|
45 | return packagePlugin();
|
46 | });
|
47 |
|
48 | gulp.task('plugin_watch', ['plugin-dev-package', 'dev-bundle-tests', 'webserver'], function() {
|
49 | _.each(common.bundleKinds, function(kind) {
|
50 | gulp.watch([common.srcDirs[kind] + '/**/*.js'], ['dev-recompile-' + kind]);
|
51 | gulp.watch([common.srcDirs[kind] + '/.lib-exports.js'], ['dev-recompile-' + kind, 'generate-systemjs-' + kind + '-index']);
|
52 | });
|
53 | gulp.watch('src/.dev-loader.js', ['plugin-dev-package']);
|
54 | gulp.watch('src/**/*.hbs', ['templates']);
|
55 | gulp.watch('style/**/*.*', ['styles']);
|
56 | });
|