<commit_before>/**
 * Copyright 2014 aixigo AG
 * Released under the MIT license.
 * http://laxarjs.org/license
 */
/*jshint node: true*/
'use strict';

var path = require( 'path' );

var staticConfig = {
   deps: [
      'es5-shim/es5-shim',
      'json2/json2',
      'modernizr/modernizr'
   ],
   shims: {
      'angular': {},
      'angular-mocks': {},
      'angular-route': {},
      'angular-sanitize': {},
      'jquery': {},
      'underscore': {}
   }
};

function defaultConfig( baseUrl ) {
   return {
      baseUrl: baseUrl,
      deps: [],
      shims: {},
      paths: {
         // LaxarJS Core:
         'requirejs': 'requirejs/require',

         // LaxarJS Core Testing:
         'jasmine': 'jasmine/lib/jasmine-core/jasmine',
         'q_mock': 'q_mock/q',

         // LaxarJS Core Legacy:
         'text': 'requirejs-plugins/lib/text',
         'json': 'requirejs-plugins/src/json',

         // UIKit:
         'bootstrap-tooltip': 'bootstrap-sass-official/vendor/assets/javascripts/bootstrap/tooltip'
      },
      packages: []
   };
}

/**
 * Add a single component
 */
function addComponent( config, component ) {
   var pkg = component.pkgMeta;
   var name = pkg.name;
   var location = path.relative( config.baseUrl, component.canonicalDir );
   var main = typeof pkg.main === 'string' ? path.join( location, pkg.main ).replace( /\.js$/, '' ) : path.join( location, name );

   if( staticConfig.shims.hasOwnProperty( name ) ) {
      config.paths[ name ] = main;
   } else if( staticConfig.deps.indexOf( main ) >= 0 ) {
      config.deps.push( main );
   } else if( !config.paths.hasOwnProperty( name ) ) {
      var names = config.packages.map( function( pkg ) {
         return pkg.name;
      } );

      if( names.indexOf( name ) < 0 ) {
         config.packages.push( {
            name: pkg.name,
            main: path.relative( location, main ),
            location: location,
            path: main
         } );
      }
   }
}

/**
 * Add a list of bower components
 */
function addComponents( config, components ) {
   for( var component in components ) {
      if( components.hasOwnProperty( component ) ) {
         addComponent( config, components[ component ] );
      }
   }
}

/**
 * Add the dependencies of a single bower component
 */<commit_msg>(#8) no duplicate deps<commit_after>/**
 * Copyright 2014 aixigo AG
 * Released under the MIT license.
 * http://laxarjs.org/license
 */
/*jshint node: true*/
'use strict';

var path = require( 'path' );

var staticConfig = {
   deps: [
      'es5-shim/es5-shim',
      'json2/json2',
      'modernizr/modernizr'
   ],
   shims: {
      'angular': {},
      'angular-mocks': {},
      'angular-route': {},
      'angular-sanitize': {},
      'jquery': {},
      'underscore': {}
   }
};

function defaultConfig( baseUrl ) {
   return {
      baseUrl: baseUrl,
      deps: [],
      shims: {},
      paths: {
         // LaxarJS Core:
         'requirejs': 'requirejs/require',

         // LaxarJS Core Testing:
         'jasmine': 'jasmine/lib/jasmine-core/jasmine',
         'q_mock': 'q_mock/q',

         // LaxarJS Core Legacy:
         'text': 'requirejs-plugins/lib/text',
         'json': 'requirejs-plugins/src/json',

         // UIKit:
         'bootstrap-tooltip': 'bootstrap-sass-official/vendor/assets/javascripts/bootstrap/tooltip'
      },
      packages: []
   };
}

/**
 * Add a single component
 */
function addComponent( config, component ) {
   var pkg = component.pkgMeta;
   var name = pkg.name;
   var location = path.relative( config.baseUrl, component.canonicalDir );
   var main = typeof pkg.main === 'string' ? path.join( location, pkg.main ).replace( /\.js$/, '' ) : path.join( location, name );

   if( staticConfig.shims.hasOwnProperty( name ) ) {
      config.paths[ name ] = main;
   } else if( staticConfig.deps.indexOf( main ) >= 0 ) {
      if( config.deps.indexOf( main ) < 0 ) {
         config.deps.push( main );
      }
   } else if( !config.paths.hasOwnProperty( name ) ) {
      var names = config.packages.map( function( pkg ) {
         return pkg.name;
      } );

      if( names.indexOf( name ) < 0 ) {
         config.packages.push( {
            name: pkg.name,
            main: path.relative( location, main ),
            location: location,
            path: main
         } );
      }
   }
}

/**
 * Add a list of bower components
 */
function addComponents( config, components ) {
   for( var component in components ) {
      if( components.hasOwnProperty( component ) ) {
         addComponent( config, components[ component ] );
      }
   }
}

/**
 * Add the dependencies of a single bower component
 */
{'fraction_non_alphanumeric': 0.15242593387720052, 'fraction_numerical': 0.0047230571060541005, 'mean_word_length': 2.1437246963562755, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '637028', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1466, 'n_words': 337}