/*eslint-env node */
/*global require: true, module: true */

'use strict';

var options = require('../gulp-options.js'), gulp = require('gulp'),

    // Base dependencies
    clean = require('gulp-clean'), rename = require('gulp-rename'),
    util = require('gulp-util'),

    // Angular gulp dependencies
    ngTemplateCache = require('gulp-angular-templatecache'),
    ngAnnotate = require('gulp-ng-annotate'),
    ngConstant = require('gulp-ng-constant'),

    // Classical gulp dependencies
    stripDebug = require('gulp-strip-debug'), uglify = require('gulp-uglify'),
    sass = require('gulp-sass'), cleanCss = require('gulp-clean-css'),
    rev = require('gulp-rev'), revReplace = require('gulp-rev-replace'),
    gulpIf = require('gulp-if'), useref = require('gulp-useref'),
    jsoncombine = require('gulp-jsoncombine'),
    htmlParser = require('gulp-htmlparser');


var runSequence = require('run-sequence'), es = require('event-stream');

gulp.task('webapp:clean', function() {
  return gulp
      .src(
          [options.targetFolderPath + '/webapp', options.dirname + '/.temp'],
          {'read': false})
      .pipe(clean({'force': true}));
});

gulp.task('webapp:sasscompile', function() {
  return gulp.src('app/styles/index.scss')
      .pipe(sass.sync().on('error', util.log))
      .pipe(gulp.dest(options.srcFolderPath + '/styles'));
});

// ----- To .temp from app
gulp.task('webapp:copyjs', function() {
  return gulp.src(options.srcFolderPath + '/**/*.js')
      .pipe(ngAnnotate())  // Check angular dependencies injection
      .pipe(stripDebug())  // Remove all logs
      .pipe(uglify({'mangle': false}))
      .pipe(gulp.dest(options.dirname + '/.temp'));
});

gulp.task('webapp:copyothers', function() {
  return gulp
      .src(
          ['**/*', '!**/*.js', '!**/*.css', '!**/*.scss'],
          {'cwd': options.srcFolderPath})  // All except JS files
      .pipe(gulp.dest(options.tempFolderPath));
});

gulp.task('webapp:copycss', function() {
  return gulp.src('app/styles/index.css')
      .pipe(cleanCss())
      .pipe(gulp.dest(options.tempFolderPath + '/styles'));
});

gulp.task('webapp:constants', function() {
  return gulp.src('environment-constants.json')
      .pipe(ngConstant({'name': 'app.constants', 'deps': false}))
      .pipe(rename('environment-constants.js'))
      .pipe(gulp.dest(options.tempFolderPath + '/constants'));
});

// ----- To target/webapp from .temp and bower_components
gulp.task('webapp:template', function() {
  return gulp
      .src([
        options.srcFolderPath + '/**/*.html',
        '!' + options.srcFolderPath + '/index.html'
      ])
      .pipe(ngTemplateCache(
          'templates.js', {'module': 'app.templates', 'standalone': true}))
      .pipe(gulp.dest(options.tempFolderPath));
});

gulp.task('webapp:useref', function() {
  var tasks = ['index.html'].map(function(indexPage) {
    var assets = useref.assets({});

    return gulp.src(options.tempFolderPath + '/' + indexPage)
        .pipe(assets)
        .pipe(assets.restore())
        .pipe(useref())
        .pipe(revReplace())  // Force useref to apply the 'rev' method
        .pipe(gulp.dest(options.targetFolderPath + '/webapp'));
  });

  return es.concat.apply(null, tasks);
});

gulp.task('webapp:copyresources', function() {
  return gulp
      .src(
          ['**/*.*', '!**/*.js', '!**/*.css', '!**/*.html', '!**/*.log'],
          {'cwd': options.tempFolderPath})
      .pipe(gulp.dest(options.targetFolderPath + '/webapp'));
});

module.exports = function(callback) {
  return runSequence(
      'webapp:clean', 'webapp:sasscompile',
      ['webapp:copyjs', 'webapp:copycss', 'webapp:copyothers'],
      ['webapp:constants', 'webapp:template'], ['webapp:useref'],
      ['webapp:copyresources'], callback);
};
