/**
 * Gruntfile for dorabella, a freedom.js-powered encrypted chat app
 **/

var path = require('path');
var pgpPath = path.dirname(require.resolve('freedom-pgp-e2e/package.json'));
var freedomPath = path.dirname(require.resolve('freedom'));
var providersPath = path.dirname(require.resolve('radiatus-providers'));
var hexPath = path.dirname(require.resolve('hex2words'));
var tabPath = path.dirname(require.resolve('tab-strip'));

module.exports = function(grunt) {
  grunt.initConfig({
    copy: {
      app: {
        cwd: 'src/',
        src: ['**/**'],
        dest: 'build/',
        expand: true
      },
      freedom: {
        src: [freedomPath + '/dist/freedom.min.js*'],
        dest: 'build/',
        flatten: true,
        filter: 'isFile',
        expand: true
      },
      radiatusWsServer: {
        src: [providersPath + '/src/providers/social.radiatus.js*'],
        dest: 'build/websocket-server/',
        flatten: true,
        filter: 'isFile',
        expand: true
      },
      freedomPgpE2e: {
        cwd: pgpPath + '/dist/',
        src: ['*.js', 'pgpapi.json'],
        dest: 'build/freedom-pgp-e2e/',
        flatten: true,
        filter: 'isFile',
        expand: true
      },
      tabStrip: {
        cwd: tabPath,
        src: ['TabStrip.js'],
        dest: 'build/',
        flatten: true,
        filter: 'isFile',
        expand: true
      },
      dist: {
	      cwd: 'build/',
	      src: ['**/**'],
	      dest: 'dist/',
	      expand: true
      }
    },

    browserify: {
      hex2words: {
        files: {
          'build/hex2words.js': [require.resolve('hex2words')]
        },
        options: {
          browserifyOptions: {
            standalone: 'hex2words'
          }
        }
      }
    },

    jshint: {
      all: ['src/*.js', 'spec/*.js', 'spec/integration/*.js'],
      options: {
        jshintrc: true
      }
    },

    connect: {
      demo: {
        options: {
          port: 8000,
          keepalive: true,
          base: ['./', 'build/'],
          open: 'http://localhost:8000/build/'
        }
      }
    },

    buildcontrol: {
      options: {
	      dir: 'dist/',
	      commit: true,
	      push: true,
	      message: 'Built %sourceName% from commit %sourceCommit% on branch ' +
	        '%sourceBranch%'
      },
      pages: {
	      options: {
          remote: 'https://github.com/soycode/dorabella.git',
          branch: 'gh-pages'
	      }
      }
    },

    clean: ['build/']
  });

  grunt.loadNpmTasks('grunt-browserify');
  grunt.loadNpmTasks('grunt-build-control');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-jshint');

  grunt.registerTask('build', [
    'jshint',
    'browserify',
    'copy'
  ]);
  grunt.registerTask('demo', [
    'build',
    'connect'
  ]);
  grunt.registerTask('deploy', [
    'build',
    'buildcontrol'
  ]);
  grunt.registerTask('default', [
    'build'
  ]);

};

@@ -1391,25 +1391,26 @@
     dist: %7B%0A
-%09
+  
       cwd: '
@@ -1414,25 +1414,26 @@
 : 'build/',%0A
-%09
+  
       src: %5B
@@ -1442,17 +1442,18 @@
 */**'%5D,%0A
-%09
+  
       de
@@ -1461,25 +1461,26 @@
 t: 'dist/',%0A
-%09
+  
       expand
@@ -2124,25 +2124,26 @@
  options: %7B%0A
-%09
+  
       dir: '
@@ -2150,17 +2150,18 @@
 dist/',%0A
-%09
+  
       co
@@ -2168,25 +2168,26 @@
 mmit: true,%0A
-%09
+  
       push: 
@@ -2192,17 +2192,18 @@
 : true,%0A
-%09
+  
       me
@@ -2270,17 +2270,18 @@
 nch ' +%0A
-%09
+  
         
@@ -2321,17 +2321,18 @@
 ages: %7B%0A
-%09
+  
       op
@@ -2435,9 +2435,10 @@
 es'%0A
-%09
+  
     

switch tabs to spaces