/* eslint-disable */
import path     from 'path';
import { argv } from 'yargs';
import dotenv   from 'dotenv';
import chalk    from 'chalk';
import pkg      from '../package.json';

dotenv.load();
const config = new Map();

// ------------------------------------
// Project Customization
// ------------------------------------

// Should source maps be generated when the application is compiled
// for production?
config.set('production_enable_source_maps', false);

// What dependencies should be compiled separately from the core
// application code?
config.set('vendor_dependencies', [
  'history',
  'react',
  'react-redux',
  'react-router',
  'redux',
  'redux-simple-router'
]);

// ------------------------------------
// Project Structure
// ------------------------------------

// Where is the root of the project in relation to this file?
config.set('dir_base', path.resolve(__dirname, '../'));

config.set('dir_client', 'src');    // where React app source code lives
config.set('dir_server', 'server'); // where server source code lives
config.set('dir_dist',   'dist');   // where to deploy compiled code
config.set('dir_test',   'tests');  // where tests live

// ------------------------------------
// Server Configuration
// ------------------------------------
config.set('server_host', 'localhost');
config.set('server_port', process.env.PORT || 3000);

// ------------------------------------
// Test Configuration
// ------------------------------------
config.set('coverage_enabled', !argv.watch); // enabled if not in watch mode
config.set('coverage_reporters', [
  { type : 'text-summary' },
  { type : 'html', dir : 'coverage' }
]);

/*  *********************************************
-------------------------------------------------

All Internal Configuration Below
Edit at Your Own Risk

-------------------------------------------------
************************************************/
// ------------------------------------
// Environment
// ------------------------------------
config.set('env', process.env.NODE_ENV);
config.set('globals', {
  'process.env'  : {
    'NODE_ENV' : JSON.stringify(config.get('env'))
  },
  'NODE_ENV'     : config.get('env'),
  '__DEV__'      : config.get('env') === 'development',
  '__PROD__'     : config.get('env') === 'production',
  '__DEBUG__'    : config.get('env') === 'development' && !argv.no_debug,
  '__DEBUG_NW__' : !!argv.nw
});

// ------------------------------------
// Verify Vendor Dependencies
// ------------------------------------
const vendor = config.get('vendor_dependencies')

const validVendor = vendor.filter(dep => {
  if (pkg.dependencies[dep]) return true;

  console.log(chalk.yellow(
    `Package "${dep}" was not found as an npm dependency in package.json; ` +
    `it won't be included in the webpack vendor bundle.\n` +
    `Consider removing it from vendor_dependencies in ~/config/index.js`
  ));
});
config.set('vendor_dependencies', validVendor);

// ------------------------------------
// Utilities
// ------------------------------------
const paths = (() => {
  const resolve  = path.resolve;

  const base = (...args) =>
    resolve.apply(resolve, [config.get('dir_base'), ...args]);

  return {
    base   : base,
    client : base.bind(null, config.get('dir_client')),
    dist   : base.bind(null, config.get('dir_dist'))
  };
})();

config.set('utils_paths', paths);
config.set('utils_aliases', [
  'actions',
  'components',
  'constants',
  'containers',
  'layouts',
  'reducers',
  'routes',
  'services',
  'store',
  'styles',
  'utils',
  'views'
].reduce((acc, dir) => ((acc[dir] = paths.client(dir)) && acc), {}));

export default config;
/* eslint-enable */

@@ -2457,13 +2457,15 @@
 // V
-erify
+alidate
  Ven
@@ -2528,19 +2528,38 @@
 %0Acon
-st vendor =
+fig.set('vendor_dependencies',
  con
@@ -2593,35 +2593,10 @@
 s')%0A
-%0Aconst validVendor = vendor
+  
 .fil
@@ -2608,16 +2608,18 @@
 ep =%3E %7B%0A
+  
   if (pk
@@ -2649,24 +2649,26 @@
 turn true;%0A%0A
+  
   console.lo
@@ -2687,16 +2687,18 @@
 ow(%0A    
+ 
+ 
 %60Package
@@ -2767,16 +2767,18 @@
 %60 +%0A    
+  
 %60it won'
@@ -2830,16 +2830,18 @@
 %60 +%0A    
+ 
+ 
 %60Conside
@@ -2905,63 +2905,21 @@
 js%60%0A
+  
   ));%0A
-%7D);%0Aconfig.set('vendor_dependencies', validVendor
+  %7D)%0A
 );%0A%0A

remove unnecessary validVendor assignment