2017-06-02 22:31:51 +02:00
|
|
|
var ts = require('gulp-typescript');
|
|
|
|
var gulp = require('gulp');
|
2017-06-02 23:21:05 +02:00
|
|
|
var zip = require('gulp-zip');
|
2017-06-02 22:31:51 +02:00
|
|
|
var runSequence = require('run-sequence');
|
2017-07-11 22:10:36 +02:00
|
|
|
var jsonModify = require('gulp-json-modify');
|
|
|
|
var exec = require('child_process').exec;
|
2017-06-02 22:31:51 +02:00
|
|
|
|
2017-06-02 23:48:46 +02:00
|
|
|
var tsProject = ts.createProject('tsconfig.json');
|
2017-07-11 22:10:36 +02:00
|
|
|
gulp.task('build-backend', function () {
|
|
|
|
return gulp.src([
|
|
|
|
"common/**/*.ts",
|
|
|
|
"backend/**/*.ts"], {base: "."})
|
|
|
|
.pipe(tsProject())
|
|
|
|
.js
|
|
|
|
.pipe(gulp.dest("./release"))
|
2017-06-02 22:31:51 +02:00
|
|
|
|
|
|
|
});
|
2017-07-11 22:10:36 +02:00
|
|
|
gulp.task('build-frontend', function (cb) {
|
|
|
|
exec("ng build -prod --output-path=./release/dist --no-progress", function (err, stdout, stderr) {
|
|
|
|
console.log(stdout);
|
|
|
|
console.log(stderr);
|
|
|
|
cb(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('copy-static', function () {
|
|
|
|
return gulp.src([
|
|
|
|
"README.md",
|
|
|
|
"LICENSE"], {base: "."})
|
|
|
|
.pipe(gulp.dest('./release'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('copy-package', function () {
|
|
|
|
return gulp.src([
|
|
|
|
"package.json"], {base: "."})
|
|
|
|
.pipe(jsonModify({
|
|
|
|
key: 'devDependencies',
|
|
|
|
value: {}
|
|
|
|
}))
|
|
|
|
.pipe(jsonModify({
|
|
|
|
key: 'scripts',
|
|
|
|
value: {"start": "node ./backend/index.js"}
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('./release'));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-06-02 23:21:05 +02:00
|
|
|
gulp.task('zip-release', function () {
|
2017-07-11 22:23:07 +02:00
|
|
|
return gulp.src(['release/**/*'], {base: "./release"})
|
2017-07-11 22:10:36 +02:00
|
|
|
.pipe(zip('pigallery2.zip'))
|
|
|
|
.pipe(gulp.dest('.'));
|
2017-06-02 23:21:05 +02:00
|
|
|
});
|
2017-06-02 22:31:51 +02:00
|
|
|
|
|
|
|
gulp.task('build-release', function (done) {
|
2017-07-11 22:10:36 +02:00
|
|
|
runSequence('build-frontend', 'build-backend', 'copy-static', 'copy-package', 'zip-release', function () {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|