<commit_before>import NpmDir from '../npm/npm-dir';
import Config from '../question/config';
import fs from 'fs-extra';
import path from 'path';
import * as elementBundle from '../code-gen/element-bundle';
import * as controllerMap from '../code-gen/controller-map';
import * as markupExample from '../code-gen/markup-example';
import _ from 'lodash';

import {fileLogger} from '../log-factory'; 

let logger = fileLogger(__filename);

export const DEFAULTS = {
  configFile: 'config.json',
  dependenciesFile: 'dependencies.json',
  markupFile: 'index.html',
  exampleFile: 'example.html',
  buildExample: false,
  keepBuildAssets: false,
  pieJs: 'pie.js',
  controllersJs: 'controllers.js'
};

export function clean(root, opts){

  opts = _.extend({}, DEFAULTS, opts);

  logger.info('clean...', root);
  let npmDir = new NpmDir(root);
  return npmDir.clean()
      .then(() => elementBundle.clean(root, opts.pieJs)) 
      .then(() => controllerMap.clean(root, opts.controllersJs))
      .then(() => markupExample.clean(root, opts.exampleFile));
}

export function build(root, opts){
  logger.info('build...', root);

  opts = _.extend({}, DEFAULTS, opts);
  
  logger.silly('build:opts: ', opts);
  
  let npmDir = new NpmDir(root);
  let rawConfig = fs.readJsonSync(path.join(root, opts.configFile));
  let lookup = fs.readJsonSync(path.join(root, opts.dependenciesFile)) || {};
  let config = new Config(rawConfig, lookup);

  let npmDependencies = _.extend({}, config.npmDependencies, {
    'pie-player': 'PieLabs/pie-player#scoring',
    'pie-controller' : 'PieLabs/pie-controller#scoring-processor',
    'pie-control-panel' : 'PieLabs/pie-control-panel',
    'babel-loader' : '^6.2.5',
    'babel-preset-es2015' : '^6.14.0',
    'babel-preset-react' : '^6.11.1'
  });
  
  let pieNames = _.keys(config.npmDependencies);<commit_msg>Updated dependencies<commit_after>import NpmDir from '../npm/npm-dir';
import Config from '../question/config';
import fs from 'fs-extra';
import path from 'path';
import * as elementBundle from '../code-gen/element-bundle';
import * as controllerMap from '../code-gen/controller-map';
import * as markupExample from '../code-gen/markup-example';
import _ from 'lodash';

import {fileLogger} from '../log-factory'; 

let logger = fileLogger(__filename);

export const DEFAULTS = {
  configFile: 'config.json',
  dependenciesFile: 'dependencies.json',
  markupFile: 'index.html',
  exampleFile: 'example.html',
  buildExample: false,
  keepBuildAssets: false,
  pieJs: 'pie.js',
  controllersJs: 'controllers.js'
};

export function clean(root, opts){

  opts = _.extend({}, DEFAULTS, opts);

  logger.info('clean...', root);
  let npmDir = new NpmDir(root);
  return npmDir.clean()
      .then(() => elementBundle.clean(root, opts.pieJs)) 
      .then(() => controllerMap.clean(root, opts.controllersJs))
      .then(() => markupExample.clean(root, opts.exampleFile));
}

export function build(root, opts){
  logger.info('build...', root);

  opts = _.extend({}, DEFAULTS, opts);
  
  logger.silly('build:opts: ', opts);
  
  let npmDir = new NpmDir(root);
  let rawConfig = fs.readJsonSync(path.join(root, opts.configFile));
  let lookup = fs.readJsonSync(path.join(root, opts.dependenciesFile)) || {};
  let config = new Config(rawConfig, lookup);

  let npmDependencies = _.extend({}, config.npmDependencies, {
    'pie-player': 'PieLabs/pie-player',
    'pie-controller' : 'PieLabs/pie-controller',
    'pie-control-panel' : 'PieLabs/pie-control-panel',
    'babel-loader' : '^6.2.5',
    'babel-preset-es2015' : '^6.14.0',
    'babel-preset-react' : '^6.11.1'
  });
  
  let pieNames = _.keys(config.npmDependencies);
{'fraction_non_alphanumeric': 0.174993174993175, 'fraction_numerical': 0.00819000819000819, 'mean_word_length': 4.067773167358229, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1035951', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1211, 'n_words': 266}