Commit 53eb6a12f528f585888158c3dc10934bfd9d6c1c

Authored by Jose Pinto
Exists in master

Merge remote-tracking branch 'upstream/develop'

1 const gulp = require('gulp'); 1 const gulp = require('gulp');
2 const sass = require('gulp-sass'); 2 const sass = require('gulp-sass');
3 const concat = require('gulp-concat'); 3 const concat = require('gulp-concat');
4 const rename = require('gulp-rename'); 4 const rename = require('gulp-rename');
5 const uglify = require('gulp-uglify'); 5 const uglify = require('gulp-uglify');
6 const pump = require('pump'); 6 const pump = require('pump');
7 const jshint = require('gulp-jshint'); 7 const jshint = require('gulp-jshint');
8 const replace = require('gulp-replace'); 8 const replace = require('gulp-replace');
9 const connect = require('gulp-connect'); 9 const connect = require('gulp-connect');
10 const watch = require('gulp-watch'); 10 const watch = require('gulp-watch');
11 11
12 var paths = { 12 var paths = {
13 srcHTML : 'src/views/*.html', 13 srcHTML : 'src/views/*.html',
14 srcJS : 'src/js/*.js', 14 srcJS : 'src/js/*.js',
15 confJS : 'src/etc/develop.js', 15 confJS : 'src/etc/develop.js',
16 dist : 'dist/', 16 dist : 'dist/',
17 distHTML : 'dist/views/' 17 distHTML : 'dist/views/'
18 }; 18 };
19 19
20 gulp.task('uglify', function() { 20 gulp.task('uglify', function() {
21 pump( 21 pump(
22 [ 22 [
23 gulp.src([paths.srcJS, paths.confJS]), 23 gulp.src([paths.srcJS, paths.confJS]),
24 concat('wrapper-demo.js'), 24 concat('wrapper-demo.js'),
25 replace('/src/', '/dist/'), 25 replace('/src/', '/dist/'),
26 gulp.dest(paths.dist), 26 gulp.dest(paths.dist),
27 rename('wrapper-demo.min.js'), 27 rename('wrapper-demo.min.js'),
28 uglify(), 28 uglify(),
29 gulp.dest(paths.dist) 29 gulp.dest(paths.dist)
30 ] 30 ]
31 ); 31 );
32 }); 32 });
33 33
34 gulp.task('html', function() { 34 gulp.task('html', function() {
35 pump([ 35 pump([
36 gulp.src('index.html'), 36 gulp.src('index.html'),
37 replace(/\<!\-\- BUILD \-\-\>.*\<!\-\- \/BUILD \-\-\>/sgm, '<script src="wrapper-demo.min.js"></script>'), 37 replace(/\<!\-\- BUILD \-\-\>.*\<!\-\- \/BUILD \-\-\>/sgm, '<script src="wrapper-demo.min.js"></script>'),
38 gulp.dest(paths.dist) 38 gulp.dest(paths.dist)
39 ]); 39 ]);
40 pump([ 40 pump([
41 gulp.src(paths.srcHTML), 41 gulp.src(paths.srcHTML),
42 gulp.dest(paths.distHTML) 42 gulp.dest(paths.distHTML)
43 ]); 43 ]);
44 }); 44 });
45 45
46 gulp.task('sass', function() { 46 gulp.task('sass', function() {
47 return gulp.src('src/sass/*.scss') 47 return gulp.src('src/sass/*.scss')
48 .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) 48 .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
49 .pipe(gulp.dest('css')); 49 .pipe(gulp.dest('css'));
50 }); 50 });
51 51
52 gulp.task('pre-install', function() { 52 gulp.task('pre-install', function() {
53 pump([ 53 pump([
54 gulp.src('package.json'), 54 gulp.src('package.json'),
55 replace('ssh://git@debonline.dyndns.org:', 'http://git.focasoftware.com/'), 55 replace('ssh://git@debonline.dyndns.org:', 'http://git.focasoftware.com/'),
56 replace('.git', '.git#develop'),
56 gulp.dest('') 57 gulp.dest('')
57 ]); 58 ]);
58 }); 59 });
59 60
60 gulp.task('post-install', function() { 61 gulp.task('post-install', function() {
61 pump([ 62 pump([
62 gulp.src('package.json'), 63 gulp.src('package.json'),
63 replace('http://git.focasoftware.com/', 'ssh://git@debonline.dyndns.org:'), 64 replace('http://git.focasoftware.com/', 'ssh://git@debonline.dyndns.org:'),
65 replace('#develop', ''),
64 gulp.dest('') 66 gulp.dest('')
65 ]); 67 ]);
66 }); 68 });
67 69
68 gulp.task('pre-commit', function() { 70 gulp.task('pre-commit', function() {
69 return pump( 71 return pump(
70 [ 72 [
71 gulp.src(paths.srcJS), 73 gulp.src(paths.srcJS),
72 jshint('.jshintrc'), 74 jshint('.jshintrc'),
73 jshint.reporter('default'), 75 jshint.reporter('default'),
74 jshint.reporter('fail') 76 jshint.reporter('fail')
75 ] 77 ]
76 ); 78 );
77 gulp.start('uglify'); 79 gulp.start('uglify');
78 gulp.start('sass'); 80 gulp.start('sass');
79 }); 81 });
80 82
81 gulp.task('webserver', function() { 83 gulp.task('webserver', function() {
82 pump [ 84 pump [
83 connect.server( 85 connect.server(
84 { 86 {
85 port: 8086, 87 port: 8086,
86 host: '0.0.0.0', 88 host: '0.0.0.0',
87 livereload: true 89 livereload: true
88 } 90 }
89 ) 91 )
90 ] 92 ]
91 }); 93 });
92 94
93 gulp.task('watch', function() { 95 gulp.task('watch', function() {
94 gulp.watch([paths.srcJS], ['uglify']); 96 gulp.watch([paths.srcJS], ['uglify']);
95 gulp.watch('src/sass/*.scss', ['sass']); 97 gulp.watch('src/sass/*.scss', ['sass']);
96 }); 98 });
97 99
98 gulp.task('reload', function() { 100 gulp.task('reload', function() {
99 gulp.src(['src/sass/*.scss', 'index.html']) 101 gulp.src(['src/sass/*.scss', 'index.html'])
100 .pipe(connect.reload()); 102 .pipe(connect.reload());
101 }); 103 });
102 104
103 gulp.task('livereload', function() { 105 gulp.task('livereload', function() {
104 gulp.watch('css/*.css', ['reload']); 106 gulp.watch('css/*.css', ['reload']);
105 gulp.watch('js/dist/*.js', ['reload']); 107 gulp.watch('js/dist/*.js', ['reload']);
106 gulp.watch('vistas/**/*.html', ['reload']); 108 gulp.watch('vistas/**/*.html', ['reload']);
107 gulp.watch('index.html', ['reload']); 109 gulp.watch('index.html', ['reload']);
108 }); 110 });
109 111
110 gulp.task('default', ['sass', 'webserver', 'livereload', 'watch']); 112 gulp.task('default', ['sass', 'webserver', 'livereload', 'watch']);
111 113