<commit_before>/*global module, process, require*/

"use strict";

var request = require("request");

module.exports = function(grunt) {
    var browsers = [
        {platform: "linux", browserName: "chrome", version: "36"},
        {platform: "linux", browserName: "chrome", version: "35"},
        {platform: "linux", browserName: "firefox", version: "31"},
        {platform: "linux", browserName: "firefox", version: "30"},
        {platform: "linux", browserName: "firefox", version: "29"},
        {platform: "WIN8.1", browserName: "firefox", version: "31"},
        {platform: "WIN8.1", browserName: "chrome", version: "36"},
        {platform: "WIN8.1", browserName: "internet explorer", version: "11"},
        {platform: "WIN8", browserName: "internet explorer", version: "10"},
        // {platform: "WIN7", browserName: "internet explorer", version: "9"},
        {platform: "WIN7", browserName: "internet explorer", version: "10"},
        // {platform: "VISTA", browserName: "internet explorer", version: "9"},
        {platform: "OS X 10.8", browserName: "safari", version: "6"},
        {platform: "OS X 10.8", browserName: "chrome", version: "35"},
        {platform: "OS X 10.9", browserName: "chrome", version: "35"},
        {platform: "OS X 10.9", browserName: "safari", version: "7"},
        {platform: "OS X 10.9", browserName: "firefox", version: "28"},
        {platform: "OS X 10.9", browserName: "firefox", version: "29"},
        {platform: "OS X 10.9", browserName: "firefox", version: "30"},
        {platform: "OS X 10.9", browserName: "iphone", version: "7.1"},
        {platform: "linux", browserName: "android", version: "4.3"},
        {platform: "linux", browserName: "android", version: "4.4"}
        ];

        grunt.initConfig({
            connect: {
                server: {
                    options: {
                        base: "",
                        port: 9999
                    }
                }
            },
            "saucelabs-jasmine": {
                all: {
                    options: {
                        urls: ["http://127.0.0.1:9999/jasmine/SpecRunner.html"],
                        tunnelTimeout: 5,
                        build: process.env.TRAVIS_JOB_ID,
                        concurrency: 3,
                        browsers: browsers,
                        testname: "iSat Unit tests",
                        tags: ["master"],
                        sauceConfig: {
                            "video-upload-on-pass": false
                        },
                        onTestComplete: function(result, cb){
                         // returning undefined doesn't alter the test result
                         //   but returning true or false does.
                         //   See: https://github.com/axemclion/grunt-saucelabs

                        var user = process.env.SAUCE_USERNAME;
                        var pass = process.env.SAUCE_ACCESS_KEY;
                        request.put({
                            url: ["https://saucelabs.com/rest/v1", user, "jobs", result.job_id].join("/"),
                            auth: { user: user, pass: pass },
                            json: { passed: !result.passed }
                        }, function (error, response, body) {
                          if (error) {
                            cb(error);
                        } else if (response.statusCode !== 200) {
                            cb(new Error("Unexpected response status:" + response.statusCode));
                        } else {
                            cb(null, !result.passed);
                        }
                        body=body; // Shuts up JSHint
                    });
                        // if (result.passed === false) {
                        //     cb(null, true);
                        // } else {
                        //    cb(null,undefined);
                        // }
                    }
                }
            }
        },
        watch: {}
    });

    // Loading dependencies
    for (var key in grunt.file.readJSON("package.json").devDependencies) {
        if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
    }

    grunt.registerTask("dev", ["connect", "watch"]);
    grunt.registerTask("test", ["connect", "saucelabs-jasmine"]);
};
<commit_msg>Prevent the errors and warnings on sauce configured browsers. #162<commit_after>/*global module, process, require*/

"use strict";

var request = require("request");

module.exports = function(grunt) {
    var browsers = [
        {platform: "linux", browserName: "chrome", version: "36"},
        {platform: "linux", browserName: "chrome", version: "35"},
        {platform: "linux", browserName: "firefox", version: "31"},
        {platform: "linux", browserName: "firefox", version: "30"},
        {platform: "linux", browserName: "firefox", version: "29"},
        {platform: "WIN8.1", browserName: "firefox", version: "31"},
        {platform: "WIN8.1", browserName: "chrome", version: "36"},
        {platform: "WIN8.1", browserName: "internet explorer", version: "11"},
        {platform: "WIN8", browserName: "internet explorer", version: "10"},
        // {platform: "WIN7", browserName: "internet explorer", version: "9"},
        {platform: "WIN7", browserName: "internet explorer", version: "10"},
        // {platform: "VISTA", browserName: "internet explorer", version: "9"},
        {platform: "OS X 10.8", browserName: "safari", version: "6"},
        {platform: "OS X 10.8", browserName: "chrome", version: "35"},
        {platform: "OS X 10.9", browserName: "chrome", version: "35"},
        {platform: "OS X 10.9", browserName: "safari", version: "7"},
        {platform: "OS X 10.9", browserName: "firefox", version: "28"},
        {platform: "OS X 10.9", browserName: "firefox", version: "29"},
        {platform: "OS X 10.9", browserName: "firefox", version: "30"},
        {platform: "OS X 10.9", browserName: "iphone", version: "7.1"},
        {platform: "linux", browserName: "android", version: "4.3"},
        {platform: "linux", browserName: "android", version: "4.4"}
        ];

        grunt.initConfig({
            connect: {
                server: {
                    options: {
                        base: "",
                        port: 9999
                    }
                }
            },
            "saucelabs-jasmine": {
                all: {
                    options: {
                        urls: ["http://127.0.0.1:9999/jasmine/SpecRunner.html"],
                        tunnelTimeout: 5,
                        build: process.env.TRAVIS_JOB_ID,
                        concurrency: 3,
                        browsers: browsers,
                        capabilities: {
                            browserName: "chrome",
                            "chromeOptions":{
                                args: ["--test-type"]
                            }
                        },
                        testname: "iSat Unit tests",
                        tags: ["master"],
                        sauceConfig: {
                            "video-upload-on-pass": false
                        },
                        onTestComplete: function(result, cb){
                         // returning undefined doesn't alter the test result
                         //   but returning true or false does.
                         //   See: https://github.com/axemclion/grunt-saucelabs

                        var user = process.env.SAUCE_USERNAME;
                        var pass = process.env.SAUCE_ACCESS_KEY;
                        request.put({
                            url: ["https://saucelabs.com/rest/v1", user, "jobs", result.job_id].join("/"),
                            auth: { user: user, pass: pass },
                            json: { passed: !result.passed }
                        }, function (error, response, body) {
                          if (error) {
                            cb(error);
                        } else if (response.statusCode !== 200) {
                            cb(new Error("Unexpected response status:" + response.statusCode));
                        } else {
                            cb(null, !result.passed);
                        }
                        body=body; // Shuts up JSHint
                    });
                        // if (result.passed === false) {
                        //     cb(null, true);
                        // } else {
                        //    cb(null,undefined);
                        // }
                    }
                }
            }
        },
        watch: {}
    });

    // Loading dependencies
    for (var key in grunt.file.readJSON("package.json").devDependencies) {
        if (key !== "grunt" && key.indexOf("grunt") === 0) grunt.loadNpmTasks(key);
    }

    grunt.registerTask("dev", ["connect", "watch"]);
    grunt.registerTask("test", ["connect", "saucelabs-jasmine"]);
};
<|endoftext|>


<commit_before>(function () {
    // define GM functions
    var GM_log = function (s) {
        <bridge>.gmLog_(s);
    }
    var GM_getValue = function (k, d) {
        <bridge>.gmValueForKey_defaultValue_(k, d);
    }
    var GM_setValue = function (k, v) {
        <bridge>.gmSetValue_ForKey_(v, k);
    }
    var GM_registerMenuCommand = function (t, c) {
        <bridge>.gmRegisterMenuCommand_callback_(t, c);
    }
    var GM_xmlhttpRequest = function (d) {
        <bridge>.gmXmlhttpRequest_(d);
    }

    // unsafeWindow
    var unsafeWindow = window;
    window = null;

    with ({ document: unsafeWindow.document, location: unsafeWindow.location }) {
        <body>;
    }
})();
<commit_msg>Don't declare "window" as global.<commit_after>(function () {
    // define GM functions
    var GM_log = function (s) {
        <bridge>.gmLog_(s);
    }
    var GM_getValue = function (k, d) {
        <bridge>.gmValueForKey_defaultValue_(k, d);
    }
    var GM_setValue = function (k, v) {
        <bridge>.gmSetValue_ForKey_(v, k);
    }
    var GM_registerMenuCommand = function (t, c) {
        <bridge>.gmRegisterMenuCommand_callback_(t, c);
    }
    var GM_xmlhttpRequest = function (d) {
        <bridge>.gmXmlhttpRequest_(d);
    }

    // unsafeWindow
    var unsafeWindow = window;

    with ({ document: unsafeWindow.document, location: unsafeWindow.location, window: {} }) {
        <body>;
    }
})();
<|endoftext|>


<commit_before>import React, { PropTypes, Component } from 'react';
import { connect } from 'react-redux';
import RaisedButton from 'material-ui/RaisedButton';
import FlatButton from 'material-ui/FlatButton';

import { Card, CardHeader, CardText } from 'material-ui/Card';
import {
  Table,
  TableHeader,
  TableBody,
  TableRow,
  TableRowColumn,
  TableHeaderColumn,
} from 'material-ui/Table';

import AddShoppingCart from 'material-ui/svg-icons/action/add-shopping-cart';
import { createStructuredSelector } from 'reselect';
import {
    selectOffresProduitAvecTotalAchats,
    selectCommandeTypesProduits,
    selectFournisseurProduit,
    selectProduits,
} from 'containers/Commande/selectors';

import { selectCommande } from 'containers/CommandeEdit/selectors';

import {
  ajouter,
} from 'containers/CommandeEdit/actions';
import round from 'lodash/round';

import AffichePrix, { prixAuKg, detailPrix } from 'containers/CommandeEdit/components/components/AffichePrix';
import styles from './styles.css';

class DetailOffres extends Component {
  static propTypes = {
    offres: PropTypes.array,
    commande: PropTypes.object.isRequired,
    utilisateurId: PropTypes.string.isRequired,
    produitsById: PropTypes.object.isRequired,
    typeProduits: PropTypes.array.isRequired,
    params: PropTypes.object.isRequired,
    fournisseur: PropTypes.object,
    ajouter: PropTypes.func.isRequired,
  }

  static contextTypes = {
    muiTheme: PropTypes.object.isRequired,
  };

  constructor(props) {
    super(props);
    this.state = {
      viewOffre: true,
    };
  }

  handleClick = (e, commandeId, offreId, utilisateurId) => {
    e.stopPropagation();
    e.stopPropagation();
    e.nativeEvent.stopImmediatePropagation();
    this.props.ajouter(
      commandeId,
      { offreId, quantite: 1, commandeId, utilisateurId }
    );
  }

  render() {
    const { viewOffre } = this.state;
    const {
      offres,
      fournisseur,
      produitsById,
      typeProduits,
      commande,
      utilisateurId,
      params,
    } = this.props;

    if (!offres || !typeProduits) return null;

    const { produitId, commandeId } = params;
    const produit = produitsById[produitId];
    const contenus = commande.contenus;
    const muiTheme = this.context.muiTheme;

    const generateTarifMin = (tarifications, idx) => {
      if (idx === 0) return 1 à {tarifications[1].qteMinRelais - 1};
      const tarif = tarifications[idx];
      return tarifications[idx + 1]
        ? {tarif.qteMinRelais} à {tarifications[idx + 1].qteMinRelais - 1}
        : {tarif.qteMinRelais} et plus;
    };

    return (

          <div className={`col-md-12 ${styles.fournisseurSwitch}`}>
            <FlatButton
              onClick={() => this.setState((oldState) => ({ viewOffre: !oldState.viewOffre }))}
              primary
              label={viewOffre ? fournisseur.nom : 'Afficher les offres'}
            />

          {viewOffre && <div className={`${styles.produitTitre} col-md-12`}>{produit.nom.toUpperCase()}
}

                {viewOffre && <img src={`https://proxiweb.fr/${produit.photo}`} alt={produit.nom} style={{ width: '100%', height: 'auto', maxWidth: 200 }} />}
                {!viewOffre && <img src={`https://proxiweb.fr/${fournisseur.illustration}`} alt={produit.nom} style={{ width: '100%', height: 'auto', maxWidth: 200 }} />}

                {viewOffre &&
}
                {!viewOffre &&
}

        { viewOffre && offres.map((offre, idx) => {
          const typeProduit = typeProduits.find((typesPdt) => typesPdt.id === produit.typeProduitId);
          const enStock = offre.stock === null || offre.stock > 0;

          const offreCommande = contenus.find((cont) => cont.offreId === offre.id);
          const qteCommande = offreCommande ? offreCommande.quantite : 0;
          const dPrix = detailPrix(offre, qteCommande, 'json');
          const pAuKg = prixAuKg(offre, typeProduit, 'json');
          const tR = offre.tarifications.length > 1;

          return (
            <div key={idx} className={`row ${styles.offre}`}>

                <Card
                  style={{
                    backgroundColor: muiTheme.palette.groupColor,
                    border: `solid 1px ${muiTheme.palette.groupColorBorder}`,
                    boxShadow: 'none',
                    padding: '3px',
                  }}
                >
                  <CardHeader
                    actAsExpander={false}
                    showExpandableButton={tR}
                    style={{ padding: '5px' }}
                    textStyle={{ textAlign: 'left', paddingRight: 215, width: '360px' }}
                    title={
                      {dPrix.descriptionPdt} : {parseFloat(dPrix.prix).toFixed(2)} €
                      {offre.poids && {`${'   '}${pAuKg.prixAuKg} € / Kg`}}
                    }
                  >
                    {
                      enStock ?
                        <RaisedButton
                          onClick={
                            (event) => this.handleClick(event, commandeId, offre.id, utilisateurId)
                          }
                          primary
                          label="Ajouter au panier"
                          icon={<AddShoppingCart />}
                        /> :
                        Non disponible
                    }
                  </CardHeader>
                  <CardText expandable>

                      <TableHeader
                        displaySelectAll={false}
                        adjustForCheckbox={false}
                      >
                        <TableRow>
                          <TableHeaderColumn>Quantité achetée *</TableHeaderColumn>
                          <TableHeaderColumn
                            style={{ textAlign: 'right' }}
                          >
                            Tarif
                          </TableHeaderColumn>
                        </TableRow>
                      </TableHeader>
                      <TableBody displayRowCheckbox={false}>
                        {offre.tarifications.map((t, index, tarifications) =>
                          <TableRow>
                            <TableRowColumn>
                              {generateTarifMin(tarifications, index)}
                            </TableRowColumn>
                            <TableRowColumn
                              style={{ textAlign: 'right' }}
                            >
                              {parseFloat(round((t.prix + t.recolteFond) / 100, 2)).toFixed(2)} €
                            </TableRowColumn>
                          </TableRow>
                        )}
                      </TableBody>

* Quantité globale achetée par tous les participants de la commande

                  </CardText>
                </Card>

);
        })}

    );
  }
}

const mapStateToProps = createStructuredSelector({
  typeProduits: selectCommandeTypesProduits(),
  offres: selectOffresProduitAvecTotalAchats(),
  fournisseur: selectFournisseurProduit(),
  produitsById: selectProduits(),
  commande: selectCommande(), // commande courante en cours d'édition
});

const mapDispatchToProps = (dispatch) => ({
  ajouter: (commandeId, offre) => dispatch(ajouter(commandeId, offre)),
});

export default connect(mapStateToProps, mapDispatchToProps)(DetailOffres);
<commit_msg>suite mep Card Offre<commit_after>import React, { PropTypes, Component } from 'react';
import { connect } from 'react-redux';
import RaisedButton from 'material-ui/RaisedButton';
import FlatButton from 'material-ui/FlatButton';
import MediaQuery from 'components/MediaQuery';

import { Card, CardHeader, CardText } from 'material-ui/Card';
import {
  Table,
  TableHeader,
  TableBody,
  TableRow,
  TableRowColumn,
  TableHeaderColumn,
} from 'material-ui/Table';

import AddShoppingCart from 'material-ui/svg-icons/action/add-shopping-cart';
import { createStructuredSelector } from 'reselect';
import {
    selectOffresProduitAvecTotalAchats,
    selectCommandeTypesProduits,
    selectFournisseurProduit,
    selectProduits,
} from 'containers/Commande/selectors';

import { selectCommande } from 'containers/CommandeEdit/selectors';

import {
  ajouter,
} from 'containers/CommandeEdit/actions';
import round from 'lodash/round';

import AffichePrix, { prixAuKg, detailPrix } from 'containers/CommandeEdit/components/components/AffichePrix';
import styles from './styles.css';

class DetailOffres extends Component {
  static propTypes = {
    offres: PropTypes.array,
    commande: PropTypes.object.isRequired,
    utilisateurId: PropTypes.string.isRequired,
    produitsById: PropTypes.object.isRequired,
    typeProduits: PropTypes.array.isRequired,
    params: PropTypes.object.isRequired,
    fournisseur: PropTypes.object,
    ajouter: PropTypes.func.isRequired,
  }

  static contextTypes = {
    muiTheme: PropTypes.object.isRequired,
  };

  constructor(props) {
    super(props);
    this.state = {
      viewOffre: true,
    };
  }

  handleClick = (e, commandeId, offreId, utilisateurId) => {
    e.stopPropagation();
    e.stopPropagation();
    e.nativeEvent.stopImmediatePropagation();
    this.props.ajouter(
      commandeId,
      { offreId, quantite: 1, commandeId, utilisateurId }
    );
  }

  render() {
    const { viewOffre } = this.state;
    const {
      offres,
      fournisseur,
      produitsById,
      typeProduits,
      commande,
      utilisateurId,
      params,
    } = this.props;

    if (!offres || !typeProduits) return null;

    const { produitId, commandeId } = params;
    const produit = produitsById[produitId];
    const contenus = commande.contenus;
    const muiTheme = this.context.muiTheme;

    const generateTarifMin = (tarifications, idx) => {
      if (idx === 0) return 1 à {tarifications[1].qteMinRelais - 1};
      const tarif = tarifications[idx];
      return tarifications[idx + 1]
        ? {tarif.qteMinRelais} à {tarifications[idx + 1].qteMinRelais - 1}
        : {tarif.qteMinRelais} et plus;
    };

    return (

          <div className={`col-md-12 ${styles.fournisseurSwitch}`}>
            <FlatButton
              onClick={() => this.setState((oldState) => ({ viewOffre: !oldState.viewOffre }))}
              primary
              label={viewOffre ? fournisseur.nom : 'Afficher les offres'}
            />

          {viewOffre && <div className={`${styles.produitTitre} col-md-12`}>{produit.nom.toUpperCase()}
}

                {viewOffre && <img src={`https://proxiweb.fr/${produit.photo}`} alt={produit.nom} style={{ width: '100%', height: 'auto', maxWidth: 200 }} />}
                {!viewOffre && <img src={`https://proxiweb.fr/${fournisseur.illustration}`} alt={produit.nom} style={{ width: '100%', height: 'auto', maxWidth: 200 }} />}

                {viewOffre &&
}
                {!viewOffre &&
}

        { viewOffre && offres.map((offre, idx) => {
          const typeProduit = typeProduits.find((typesPdt) => typesPdt.id === produit.typeProduitId);
          const enStock = offre.stock === null || offre.stock > 0;

          const offreCommande = contenus.find((cont) => cont.offreId === offre.id);
          const qteCommande = offreCommande ? offreCommande.quantite : 0;
          const dPrix = detailPrix(offre, qteCommande, 'json');
          const pAuKg = prixAuKg(offre, typeProduit, 'json');
          const tR = offre.tarifications.length > 1;

          return (
            <div key={idx} className={`row ${styles.offre}`}>

                <Card
                  style={{
                    backgroundColor: muiTheme.palette.groupColor,
                    border: `solid 1px ${muiTheme.palette.groupColorBorder}`,
                    boxShadow: 'none',
                    padding: '3px',
                  }}
                >
                  <CardHeader
                    actAsExpander={false}
                    showExpandableButton={tR}
                    style={{ padding: '5px' }}
                    textStyle={{ textAlign: 'left', paddingRight: 215, width: '360px' }}
                    title={
                      {dPrix.descriptionPdt} : {parseFloat(dPrix.prix).toFixed(2)} €
                      {offre.poids && {`${'   '}${pAuKg.prixAuKg} € / Kg`}}
                    }
                  >
                    <MediaQuery query="(max-device-width: 1600px)">
                      {
                        enStock ?
                          <RaisedButton
                            onClick={
                              (event) => this.handleClick(event, commandeId, offre.id, utilisateurId)
                            }
                            primary
                            label="Ajouter au panier"
                            icon={<AddShoppingCart />}
                          /> :
                          Non disponible
                      }
                    </MediaQuery>
                    <MediaQuery query="(min-device-width: 1600px)">
                      {
                        enStock ?
                          <RaisedButton
                            onClick={
                              (event) => this.handleClick(event, commandeId, offre.id, utilisateurId)
                            }
                            primary
                            icon={<AddShoppingCart />}
                          /> :
                          Non disponible
                      }
                    </MediaQuery>
                  </CardHeader>
                  <CardText expandable>

                      <TableHeader
                        displaySelectAll={false}
                        adjustForCheckbox={false}
                      >
                        <TableRow>
                          <TableHeaderColumn>Quantité achetée *</TableHeaderColumn>
                          <TableHeaderColumn
                            style={{ textAlign: 'right' }}
                          >
                            Tarif
                          </TableHeaderColumn>
                        </TableRow>
                      </TableHeader>
                      <TableBody displayRowCheckbox={false}>
                        {offre.tarifications.map((t, index, tarifications) =>
                          <TableRow>
                            <TableRowColumn>
                              {generateTarifMin(tarifications, index)}
                            </TableRowColumn>
                            <TableRowColumn
                              style={{ textAlign: 'right' }}
                            >
                              {parseFloat(round((t.prix + t.recolteFond) / 100, 2)).toFixed(2)} €
                            </TableRowColumn>
                          </TableRow>
                        )}
                      </TableBody>

* Quantité globale achetée par tous les participants de la commande

                  </CardText>
                </Card>

);
        })}

    );
  }
}

const mapStateToProps = createStructuredSelector({
  typeProduits: selectCommandeTypesProduits(),
  offres: selectOffresProduitAvecTotalAchats(),
  fournisseur: selectFournisseurProduit(),
  produitsById: selectProduits(),
  commande: selectCommande(), // commande courante en cours d'édition
});

const mapDispatchToProps = (dispatch) => ({
  ajouter: (commandeId, offre) => dispatch(ajouter(commandeId, offre)),
});

export default connect(mapStateToProps, mapDispatchToProps)(DetailOffres);
<|endoftext|>


<commit_before>module.exports = function (grunt) {

    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-eslint');

    grunt.initConfig({

      connect: {
        options: {
          hostname: '127.0.0.1',
          keepalive: true,
          open: true,
          port: 8081,
          protocol: 'http'
        },
        unit: {
          options: {
            base: './'
          }
        }
      },

      watch: {
        options: {
          livereload: 35740
        },
        unit: {
          files: ['./lib/index.js', './lib/holdem-sequence.js', './lib/*.js', './tests/*.js', './tests/**/*.js', '!./tests/bundle.js'],
          tasks: ['eslint:js', 'browserify:unit']
        }
      },

      browserify: {
        options: {
          debug: true
        },
        unit: {
          files: {
            'tests/bundle.js': ['tests/*.js', 'tests/**/*.js', '!tests/bundle.js']
          }
        }
      },

      eslint: {
        options: {
          configFile: 'eslint.json'
        },
        js: ['./*.js', '!./Gruntfile.js', './domain/*.js', './holdem/*.js', './lib/*.js']
      }

    });

    grunt.registerTask('unit', ['browserify:unit', 'connect:unit']);

};
<commit_msg>fix Gruntfile path<commit_after>module.exports = function (grunt) {

    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-eslint');

    grunt.initConfig({

      connect: {
        options: {
          hostname: '127.0.0.1',
          keepalive: true,
          open: true,
          port: 8081,
          protocol: 'http'
        },
        unit: {
          options: {
            base: './'
          }
        }
      },

      watch: {
        options: {
          livereload: 35740
        },
        unit: {
          files: ['./*.js', '!./Gruntfile.js', './domain/*.js', './holdem/*.js', './lib/*.js', './tests/*.js', './tests/**/*.js', '!./tests/bundle.js'],
          tasks: ['eslint:js', 'browserify:unit']
        }
      },

      browserify: {
        options: {
          debug: true
        },
        unit: {
          files: {
            'tests/bundle.js': ['./tests/*.js', './tests/**/*.js', '!./tests/bundle.js']
          }
        }
      },

      eslint: {
        options: {
          configFile: 'eslint.json'
        },
        js: ['./*.js', '!./Gruntfile.js', './domain/*.js', './holdem/*.js', './lib/*.js']
      }

    });

    grunt.registerTask('unit', ['browserify:unit', 'connect:unit']);

};
<|endoftext|>


<commit_before>// Load our dependencies
var assert = require('assert');
var async = require('async');
var fs = require('fs');
var path = require('path');
var Readable = require('stream').Readable;
var _ = require('underscore');
var gutil = require('gulp-util');
var Minimatch = require('minimatch').Minimatch;
var templater = require('spritesheet-templates');
var spritesmith = require('spritesmith');
var through2 = require('through2');
var url = require('url2');

var cwd = process.cwd();

function ExtFormat() {
  this.formatObj = {};
}
ExtFormat.prototype = {
  add: function (name, val) {
    this.formatObj[name] = val;
  },
  get: function (filepath) {
    // Grab the extension from the filepath
    var ext = path.extname(filepath);
    var lowerExt = ext.toLowerCase();

    // Look up the file extenion from our format object
    var formatObj = this.formatObj;
    var format = formatObj[lowerExt];
    return format;
  }
};

// Create img and css formats
var imgFormats = new ExtFormat();
var cssFormats = new ExtFormat();

// Add our img formats
imgFormats.add('.png', 'png');
imgFormats.add('.jpg', 'jpeg');
imgFormats.add('.jpeg', 'jpeg');

// Add our css formats
cssFormats.add('.styl', 'stylus');
cssFormats.add('.stylus', 'stylus');
cssFormats.add('.sass', 'sass');
cssFormats.add('.scss', 'scss');
cssFormats.add('.less', 'less');
cssFormats.add('.json', 'json');
cssFormats.add('.css', 'css');

// Copy/paste helper from gulp
// https://github.com/wearefractal/glob-stream/blob/v5.0.0/index.js#L131-L138
function unrelative(cwd, glob) {
  var mod = '';
  if (glob[0] === '!') {
    mod = glob[0];
    glob = glob.slice(1);
  }
  return mod + path.resolve(cwd, glob);
}

// Define helper for coordinate naming
function getCoordinateName(filepath) {
  // Extract the image name (exlcuding extension)
  var fullname = path.basename(filepath);
  var nameParts = fullname.split('.');

  // If there is are more than 2 parts, pop the last one
  if (nameParts.length >= 2) {
    nameParts.pop();
  }

  // Return our modified filename
  return nameParts.join('.');
}

// Create a gulp-spritesmith function
function gulpSpritesmith(params) {
  var imgName = params.imgName;
  var cssName = params.cssName;
  assert(imgName, 'An `imgName` parameter was not provided to `gulp.spritesmith` (required)');
  assert(cssName, 'A `cssName` parameter was not provided to `gulp.spritesmith` (required)');

  // If there are settings for retina, verify our all of them are present
  var retinaSrcFilter = params.retinaSrcFilter;
  var retinaImgName = params.retinaImgName;
  if (retinaSrcFilter || retinaImgName) {
    assert(retinaSrcFilter && retinaImgName, 'Retina settings detected. We must have both `retinaSrcFilter` and ' +
      '`retinaImgName` provided for retina to work');
  }

  // Define our output streams
  var imgStream = new Readable({objectMode: true});
  imgStream._read = function imgRead () {
    // Do nothing, let the `finish` handler take care of this
  };
  var cssStream = new Readable({objectMode: true});
  cssStream._read = function cssRead () {
    // Do nothing, let the `finish` handler take care of this
  };

  // Create a stream to take in images
  var images = [];
  var onData = function (file, encoding, cb) {
    if (file.path) {
      images.push(file);
    }
    cb();
  };

  // When we have completed our input
  var onEnd = function (cb) {
    // If there are no images present, exit early
    // DEV: This is against the behavior of `spritesmith` but pro-gulp
    // DEV: See https://github.com/twolfson/gulp.spritesmith/issues/17
    if (images.length === 0) {
      imgStream.push(null);
      cssStream.push(null);
      return cb();
    }

    // Determine the format of the image
    var imgOpts = params.imgOpts || {};
    var imgFormat = imgOpts.format || imgFormats.get(imgName) || 'png';

    // Set up the defautls for imgOpts
    imgOpts = _.defaults({}, imgOpts, {format: imgFormat});

    // If we have retina settings, filter out the retina images
    var retinaImages;
    if (retinaSrcFilter) {
      // Filter out our retina files
      // https://github.com/wearefractal/glob-stream/blob/v5.0.0/index.js#L84-L87
      retinaImages = [];
      var retinaSrcPatterns = Array.isArray(retinaSrcFilter) ? retinaSrcFilter : [retinaSrcFilter];
      images = images.filter(function filterSrcFile (file) {
        // If we have a retina file, filter it out
        var matched = retinaSrcPatterns.some(function matchMinimatches (retinaSrcPattern) {
          var minimatch = new Minimatch(unrelative(file.cwd, retinaSrcPattern));
          return minimatch.match(file.path);
        });
        if (matched) {
          retinaImages.push(file);
          return false;
        // Otherwise, keep it in the src files
        } else {
          return true;
        }
      });

      // If we have a different amount of normal and retina images, complain and leave
      assert(images.length === retinaImages.length,
        'Retina settings detected but ' + retinaImages.length + ' retina images were found. ' +
        'We have ' + images.length + ' normal images and expect these numbers to line up. ' +
        'Please double check `retinaSrcFilter`.');
    }

    // Decouple vinyl files from filepaths
    images = _.pluck(images, 'path');
    if (retinaImages) {
      retinaImages = _.pluck(retinaImages, 'path');
    }

    // Prepare spritesmith parameters
    var spritesmithParams = {
      src: images,
      engine: params.engine,
      algorithm: params.algorithm,
      padding: params.padding || 0,
      algorithmOpts: params.algorithmOpts || {},
      engineOpts: params.engineOpts || {},
      exportOpts: imgOpts
    };
    var that = this;

    // In parallel
    async.parallel([
      // Run our normal task
      function generateNormalSpritesheet (callback) {
        spritesmith(spritesmithParams, callback);
      },
      // If we have a retina task, run it as well
      function generateRetinaSpritesheet (callback) {
        if (retinaImages) {
          var retinaParams = _.defaults({
            src: retinaImages,
            padding: spritesmithParams.padding * 2
          }, spritesmithParams);
          spritesmith(retinaParams, callback);
        } else {
          process.nextTick(callback);
        }
      }
    ], function handleSpritesheets (err, resultArr) {
      // If an error occurred, emit it
      if (err) {
        return cb(err);
      }

      // Otherwise, write out the image
      var result = resultArr[0];
      var retinaResult = resultArr[1];
      var imgFile = new gutil.File({
        path: imgName,
        contents: new Buffer(result.image, 'binary')
      });
      that.push(imgFile);
      imgStream.push(imgFile);
      if (retinaResult) {
        var retinaImgFile = new gutil.File({
          path: retinaImgName,
          contents: new Buffer(retinaResult.image, 'binary')
        });
        that.push(retinaImgFile);
      }
      imgStream.push(null);

      // START OF DUPLICATE CODE FROM grunt-spritesmith
      // Generate a listing of CSS variables
      var coordinates = result.coordinates;
      var properties = result.properties;
      var spritePath = params.imgPath || url.relative(cssName, imgName);
      var spritesheetData = {
        width: properties.width,
        height: properties.height,
        image: spritePath
      };
      var cssVarMap = params.cssVarMap || function noop () {};
      var cleanCoords = [];

      // Clean up the file name of the file
      Object.getOwnPropertyNames(coordinates).sort().forEach(function (file) {
        // Extract out our name
        var name = getCoordinateName(file);
        var coords = coordinates[file];

        // Specify the image for the sprite
        coords.name = name;
        coords.source_image = file;
        // DEV: `image`, `total_width`, `total_height` are deprecated as they are overwritten in `spritesheet-templates`
        coords.image = spritePath;
        coords.total_width = properties.width;
        coords.total_height = properties.height;

        // Map the coordinates through cssVarMap
        coords = cssVarMap(coords) || coords;

        // Save the cleaned name and coordinates
        cleanCoords.push(coords);
      });

      // If we have retina sprites
      var retinaCleanCoords;
      var retinaGroups;
      var retinaSpritesheetInfo;
      if (retinaResult) {
        // Generate a listing of CSS variables
        var retinaCoordinates = retinaResult.coordinates;
        var retinaProperties = retinaResult.properties;
        var retinaSpritePath = params.retinaImgPath || url.relative(cssName, retinaImgName);
        retinaSpritesheetInfo = {
          width: retinaProperties.width,
          height: retinaProperties.height,
          image: retinaSpritePath
        };
        // DEV: We reuse cssVarMap
        retinaCleanCoords = [];

        // Clean up the file name of the file
        Object.getOwnPropertyNames(retinaCoordinates).sort().forEach(function prepareRetinaTemplateData (file) {
          var name = getCoordinateName(file);
          var coords = retinaCoordinates[file];
          coords.name = name;
          coords.source_image = file;
          coords.image = retinaSpritePath;
          coords.total_width = retinaProperties.width;
          coords.total_height = retinaProperties.height;
          coords = cssVarMap(coords) || coords;
          retinaCleanCoords.push(coords);
        });

        // Generate groups for our coordinates
        retinaGroups = cleanCoords.map(function getRetinaGroups (normalSprite, i) {
          // Assert that image sizes line up for debugging purposes
          var retinaSprite = retinaCleanCoords[i];
          assert(retinaSprite.width === normalSprite.width * 2 || retinaSprite.height !== normalSprite.height * 2,
            'Normal sprite has inconsistent size with retina sprite. ' +
            '"' + normalSprite.name + '" is ' + normalSprite.width + 'x' + normalSprite.height + ' while ' +
            '"' + retinaSprite.name + '" is ' + retinaSprite.width + 'x' + retinaSprite.height + '.');

          // Generate our group
          // DEV: Name is inherited from `cssVarMap` on normal sprite
          return {
            name: normalSprite.name,
            index: i
          };
        });
      }

      // If there is a custom template, use it
      var cssFormat = 'spritesmith-custom';
      var cssTemplate = params.cssTemplate;
      if (cssTemplate) {
        if (typeof cssTemplate === 'function') {
          templater.addTemplate(cssFormat, cssTemplate);
        } else {
          templater.addHandlebarsTemplate(cssFormat, fs.readFileSync(cssTemplate, 'utf8'));
        }
      // Otherwise, override the cssFormat and fallback to 'json'
      } else {
        cssFormat = params.cssFormat;
        if (!cssFormat) {
          cssFormat = cssFormats.get(cssName) || 'json';

          // If we are dealing with retina items, move to retina flavor (e.g. `scss` -> `scss_retina`)
          if (retinaGroups) {
            cssFormat += '_retina';
          }
        }
      }

      // Render the variables via `spritesheet-templates`
      var cssStr = templater({
        sprites: cleanCoords,
        spritesheet: spritesheetData,
        spritesheet_info: {
          name: params.cssSpritesheetName
        },
        retina_groups: retinaGroups,
        retina_sprites: retinaCleanCoords,
        retina_spritesheet: retinaSpritesheetInfo,
        retina_spritesheet_info: {
          name: params.cssRetinaSpritesheetName
        },
        retina_groups_info: {
          name: params.cssRetinaGroupsName
        }
      }, {
        format: cssFormat,
        formatOpts: params.cssOpts || {}
      });
      // END OF DUPLICATE CODE FROM grunt-spritesmith

      // Output the CSS
      var cssFile = new gutil.File({
        path: cssName,
        contents: new Buffer(cssStr)
      });
      that.push(cssFile);
      cssStream.push(cssFile);
      cssStream.push(null);
      cb();
    });
  };

  // Return output stream with two sub-streams:
  // - master stream includes all files
  // - 'css' stream for css only
  // - 'img' stream for images only
  var retStream = through2.obj(onData, onEnd);
  retStream.css = cssStream;
  retStream.img = imgStream;
  return retStream;
}

module.exports = gulpSpritesmith;
<commit_msg>Cleaned up code<commit_after>// Load our dependencies
var assert = require('assert');
var async = require('async');
var fs = require('fs');
var path = require('path');
var Readable = require('stream').Readable;
var _ = require('underscore');
var gutil = require('gulp-util');
var Minimatch = require('minimatch').Minimatch;
var templater = require('spritesheet-templates');
var spritesmith = require('spritesmith');
var through2 = require('through2');
var url = require('url2');

function ExtFormat() {
  this.formatObj = {};
}
ExtFormat.prototype = {
  add: function (name, val) {
    this.formatObj[name] = val;
  },
  get: function (filepath) {
    // Grab the extension from the filepath
    var ext = path.extname(filepath);
    var lowerExt = ext.toLowerCase();

    // Look up the file extenion from our format object
    var formatObj = this.formatObj;
    var format = formatObj[lowerExt];
    return format;
  }
};

// Create img and css formats
var imgFormats = new ExtFormat();
var cssFormats = new ExtFormat();

// Add our img formats
imgFormats.add('.png', 'png');
imgFormats.add('.jpg', 'jpeg');
imgFormats.add('.jpeg', 'jpeg');

// Add our css formats
cssFormats.add('.styl', 'stylus');
cssFormats.add('.stylus', 'stylus');
cssFormats.add('.sass', 'sass');
cssFormats.add('.scss', 'scss');
cssFormats.add('.less', 'less');
cssFormats.add('.json', 'json');
cssFormats.add('.css', 'css');

// Copy/paste helper from gulp
// https://github.com/wearefractal/glob-stream/blob/v5.0.0/index.js#L131-L138
function unrelative(cwd, glob) {
  var mod = '';
  if (glob[0] === '!') {
    mod = glob[0];
    glob = glob.slice(1);
  }
  return mod + path.resolve(cwd, glob);
}

// Define helper for coordinate naming
function getCoordinateName(filepath) {
  // Extract the image name (exlcuding extension)
  var fullname = path.basename(filepath);
  var nameParts = fullname.split('.');

  // If there is are more than 2 parts, pop the last one
  if (nameParts.length >= 2) {
    nameParts.pop();
  }

  // Return our modified filename
  return nameParts.join('.');
}

// Create a gulp-spritesmith function
function gulpSpritesmith(params) {
  var imgName = params.imgName;
  var cssName = params.cssName;
  assert(imgName, 'An `imgName` parameter was not provided to `gulp.spritesmith` (required)');
  assert(cssName, 'A `cssName` parameter was not provided to `gulp.spritesmith` (required)');

  // If there are settings for retina, verify our all of them are present
  var retinaSrcFilter = params.retinaSrcFilter;
  var retinaImgName = params.retinaImgName;
  if (retinaSrcFilter || retinaImgName) {
    assert(retinaSrcFilter && retinaImgName, 'Retina settings detected. We must have both `retinaSrcFilter` and ' +
      '`retinaImgName` provided for retina to work');
  }

  // Define our output streams
  var imgStream = new Readable({objectMode: true});
  imgStream._read = function imgRead () {
    // Do nothing, let the `finish` handler take care of this
  };
  var cssStream = new Readable({objectMode: true});
  cssStream._read = function cssRead () {
    // Do nothing, let the `finish` handler take care of this
  };

  // Create a stream to take in images
  var images = [];
  var onData = function (file, encoding, cb) {
    if (file.path) {
      images.push(file);
    }
    cb();
  };

  // When we have completed our input
  var onEnd = function (cb) {
    // If there are no images present, exit early
    // DEV: This is against the behavior of `spritesmith` but pro-gulp
    // DEV: See https://github.com/twolfson/gulp.spritesmith/issues/17
    if (images.length === 0) {
      imgStream.push(null);
      cssStream.push(null);
      return cb();
    }

    // Determine the format of the image
    var imgOpts = params.imgOpts || {};
    var imgFormat = imgOpts.format || imgFormats.get(imgName) || 'png';

    // Set up the defautls for imgOpts
    imgOpts = _.defaults({}, imgOpts, {format: imgFormat});

    // If we have retina settings, filter out the retina images
    var retinaImages;
    if (retinaSrcFilter) {
      // Filter out our retina files
      // https://github.com/wearefractal/glob-stream/blob/v5.0.0/index.js#L84-L87
      retinaImages = [];
      var retinaSrcPatterns = Array.isArray(retinaSrcFilter) ? retinaSrcFilter : [retinaSrcFilter];
      images = images.filter(function filterSrcFile (file) {
        // If we have a retina file, filter it out
        var matched = retinaSrcPatterns.some(function matchMinimatches (retinaSrcPattern) {
          var minimatch = new Minimatch(unrelative(file.cwd, retinaSrcPattern));
          return minimatch.match(file.path);
        });
        if (matched) {
          retinaImages.push(file);
          return false;
        // Otherwise, keep it in the src files
        } else {
          return true;
        }
      });

      // If we have a different amount of normal and retina images, complain and leave
      assert(images.length === retinaImages.length,
        'Retina settings detected but ' + retinaImages.length + ' retina images were found. ' +
        'We have ' + images.length + ' normal images and expect these numbers to line up. ' +
        'Please double check `retinaSrcFilter`.');
    }

    // Decouple vinyl files from filepaths
    images = _.pluck(images, 'path');
    if (retinaImages) {
      retinaImages = _.pluck(retinaImages, 'path');
    }

    // Prepare spritesmith parameters
    var spritesmithParams = {
      src: images,
      engine: params.engine,
      algorithm: params.algorithm,
      padding: params.padding || 0,
      algorithmOpts: params.algorithmOpts || {},
      engineOpts: params.engineOpts || {},
      exportOpts: imgOpts
    };
    var that = this;

    // In parallel
    async.parallel([
      // Run our normal task
      function generateNormalSpritesheet (callback) {
        spritesmith(spritesmithParams, callback);
      },
      // If we have a retina task, run it as well
      function generateRetinaSpritesheet (callback) {
        if (retinaImages) {
          var retinaParams = _.defaults({
            src: retinaImages,
            padding: spritesmithParams.padding * 2
          }, spritesmithParams);
          spritesmith(retinaParams, callback);
        } else {
          process.nextTick(callback);
        }
      }
    ], function handleSpritesheets (err, resultArr) {
      // If an error occurred, emit it
      if (err) {
        return cb(err);
      }

      // Otherwise, write out the image
      var result = resultArr[0];
      var retinaResult = resultArr[1];
      var imgFile = new gutil.File({
        path: imgName,
        contents: new Buffer(result.image, 'binary')
      });
      that.push(imgFile);
      imgStream.push(imgFile);
      if (retinaResult) {
        var retinaImgFile = new gutil.File({
          path: retinaImgName,
          contents: new Buffer(retinaResult.image, 'binary')
        });
        that.push(retinaImgFile);
      }
      imgStream.push(null);

      // START OF DUPLICATE CODE FROM grunt-spritesmith
      // Generate a listing of CSS variables
      var coordinates = result.coordinates;
      var properties = result.properties;
      var spritePath = params.imgPath || url.relative(cssName, imgName);
      var spritesheetData = {
        width: properties.width,
        height: properties.height,
        image: spritePath
      };
      var cssVarMap = params.cssVarMap || function noop () {};
      var cleanCoords = [];

      // Clean up the file name of the file
      Object.getOwnPropertyNames(coordinates).sort().forEach(function (file) {
        // Extract out our name
        var name = getCoordinateName(file);
        var coords = coordinates[file];

        // Specify the image for the sprite
        coords.name = name;
        coords.source_image = file;
        // DEV: `image`, `total_width`, `total_height` are deprecated as they are overwritten in `spritesheet-templates`
        coords.image = spritePath;
        coords.total_width = properties.width;
        coords.total_height = properties.height;

        // Map the coordinates through cssVarMap
        coords = cssVarMap(coords) || coords;

        // Save the cleaned name and coordinates
        cleanCoords.push(coords);
      });

      // If we have retina sprites
      var retinaCleanCoords;
      var retinaGroups;
      var retinaSpritesheetInfo;
      if (retinaResult) {
        // Generate a listing of CSS variables
        var retinaCoordinates = retinaResult.coordinates;
        var retinaProperties = retinaResult.properties;
        var retinaSpritePath = params.retinaImgPath || url.relative(cssName, retinaImgName);
        retinaSpritesheetInfo = {
          width: retinaProperties.width,
          height: retinaProperties.height,
          image: retinaSpritePath
        };
        // DEV: We reuse cssVarMap
        retinaCleanCoords = [];

        // Clean up the file name of the file
        Object.getOwnPropertyNames(retinaCoordinates).sort().forEach(function prepareRetinaTemplateData (file) {
          var name = getCoordinateName(file);
          var coords = retinaCoordinates[file];
          coords.name = name;
          coords.source_image = file;
          coords.image = retinaSpritePath;
          coords.total_width = retinaProperties.width;
          coords.total_height = retinaProperties.height;
          coords = cssVarMap(coords) || coords;
          retinaCleanCoords.push(coords);
        });

        // Generate groups for our coordinates
        retinaGroups = cleanCoords.map(function getRetinaGroups (normalSprite, i) {
          // Assert that image sizes line up for debugging purposes
          var retinaSprite = retinaCleanCoords[i];
          assert(retinaSprite.width === normalSprite.width * 2 || retinaSprite.height !== normalSprite.height * 2,
            'Normal sprite has inconsistent size with retina sprite. ' +
            '"' + normalSprite.name + '" is ' + normalSprite.width + 'x' + normalSprite.height + ' while ' +
            '"' + retinaSprite.name + '" is ' + retinaSprite.width + 'x' + retinaSprite.height + '.');

          // Generate our group
          // DEV: Name is inherited from `cssVarMap` on normal sprite
          return {
            name: normalSprite.name,
            index: i
          };
        });
      }

      // If there is a custom template, use it
      var cssFormat = 'spritesmith-custom';
      var cssTemplate = params.cssTemplate;
      if (cssTemplate) {
        if (typeof cssTemplate === 'function') {
          templater.addTemplate(cssFormat, cssTemplate);
        } else {
          templater.addHandlebarsTemplate(cssFormat, fs.readFileSync(cssTemplate, 'utf8'));
        }
      // Otherwise, override the cssFormat and fallback to 'json'
      } else {
        cssFormat = params.cssFormat;
        if (!cssFormat) {
          cssFormat = cssFormats.get(cssName) || 'json';

          // If we are dealing with retina items, move to retina flavor (e.g. `scss` -> `scss_retina`)
          if (retinaGroups) {
            cssFormat += '_retina';
          }
        }
      }

      // Render the variables via `spritesheet-templates`
      var cssStr = templater({
        sprites: cleanCoords,
        spritesheet: spritesheetData,
        spritesheet_info: {
          name: params.cssSpritesheetName
        },
        retina_groups: retinaGroups,
        retina_sprites: retinaCleanCoords,
        retina_spritesheet: retinaSpritesheetInfo,
        retina_spritesheet_info: {
          name: params.cssRetinaSpritesheetName
        },
        retina_groups_info: {
          name: params.cssRetinaGroupsName
        }
      }, {
        format: cssFormat,
        formatOpts: params.cssOpts || {}
      });
      // END OF DUPLICATE CODE FROM grunt-spritesmith

      // Output the CSS
      var cssFile = new gutil.File({
        path: cssName,
        contents: new Buffer(cssStr)
      });
      that.push(cssFile);
      cssStream.push(cssFile);
      cssStream.push(null);
      cb();
    });
  };

  // Return output stream with two sub-streams:
  // - master stream includes all files
  // - 'css' stream for css only
  // - 'img' stream for images only
  var retStream = through2.obj(onData, onEnd);
  retStream.css = cssStream;
  retStream.img = imgStream;
  return retStream;
}

module.exports = gulpSpritesmith;
<|endoftext|>


<commit_before>(function() { 'use strict';

    // NPM dependencies
    var _ = require('lodash');
    var request = require('request');
    var YAML = require('yamljs');
    var cheerio = require('cheerio');
    var slug = require('slug');
    var S = require('string');

    module.exports = function(grunt) {

        // Load dependencies
        require('time-grunt')(grunt);

        // grunt.loadnpmtasks shorthand
        var lnpm = function (inputTasks) {
            if (_.isString(inputTasks)) {
                inputTasks = [inputTasks];
            }
            inputTasks.forEach(function(task) {
                grunt.loadNpmTasks(task);
            });
        };

        // Project configuration
        grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),

            tempYAMLDir: '_tempYAML',

            compass: {
                dist: {
                    options: {
                        config: 'config.rb'
                    }
                }
            },

            jekyll: {
                build: {
                    dest: '_site'
                },
            },

            watch: {
                sass: {
                    files: ['_sass/**/*.sass'],
                    tasks: ['compass', 'copy:assets'],
                },
                jekyll: {
                    files: ['_config.yml', '**/*.{html, md, yaml, yml}'],
                    tasks: ['jekyll']
                },
                js: {
                    files: ['_js/**/*.js'],
                    tasks: ['concat:js', 'uglify', 'copy:assets']
                }
            },

            connect: {
                server: {
                    options: {
                       port: 4000,
                        base: '_site'
                    }
                }
            },

            concat: {
                definitions: {
                    src: ['<%= tempYAMLDir %>/*.yaml'],
                    dest: '_data/definitions.yaml',
                },
                js: {
                    src: ['_js/jquery-1.11.0.min.js', '_js/**/*.js'],
                    dest: 'assets/_app.js'
                }
            },

            copy: {
                assets: {
                    src: ['assets/*'],
                    dest: '_site/'
                }
            },

            uglify: {
                dist: {
                    files: {
                        'assets/app.min.js': ['assets/_app.js']
                    }
                }
            }

        });

        grunt.registerTask(
            'scrapePages',
            'Runs the scrapePage task on every page of the Guardian style guide',
            function () {

                // Generate the alphabet
                var letters = [];
                for (var i = 97; i <= 122; i++) {
                    letters[letters.length] = String.fromCharCode(i);
                }

                letters.forEach(function (letter) {
                    grunt.task.run('scrapePage:' + letter);
                });
            }
        );

        grunt.registerTask(
            'scrapePage',
            'Scrape an individual page of the Guardian style guide for data and save as a YAML file',
            function(letter) {
                var filename = grunt.config.get('tempYAMLDir') + '/' + letter + '.yaml';
                var url = 'http://www.theguardian.com/styleguide/' + letter;

                var slugOptions = {
                    charmap: _.extend(slug.charmap, {
                        "'": null,
                        '*': 'star'
                    })
                };

                grunt.log.write('Retrieving ' + url + '... ');

                var done = this.async();
                request(url, function (error, response, body) {
                    if (error || response.statusCode !== 200) {
                        grunt.log.error(error);
                        done(false);
                    } else {

                        grunt.log.ok();

                        // Parse it
                        grunt.log.write('Parsing to YAML... ');
                        var $ = cheerio.load(body);
                        var definitions = [];
                        $('#content').find('li.normal').each(function() {
                            var title = $(this).find('h3').text().trim();

                            // Have to use string because slug doesn't correctly
                            // strip punctuation :/
                            definitions.push({
                                title: _.escape(title),
                                slug: slug(S(title).stripPunctuation().s).toLowerCase(),
                                text: _.escape($(this).find('.trailtext').text().trim())
                            });
                        });
                        grunt.log.ok();

                        // Write the file
                        var output = [{
                            letter: letter,
                            definitions: definitions
                        }];
                        grunt.log.write('Writing to ' + filename + '... ');
                        grunt.file.write(filename, YAML.stringify(output, 4, 4));
                        grunt.log.ok();

                        // Finish
                        grunt.log.ok('Scrape complete!');
                        done();

                    }

                });

            }

        );

        grunt.registerTask(
            'cleanup',
            function () {
                grunt.log.write('Deleting temporary directory... ');
                var path = grunt.config.get('tempYAMLDir');
                if (grunt.file.exists(path)) {
                    grunt.file.delete(path);
                    grunt.log.ok();
                } else {
                    grunt.log.ok('Directory doesn\'t exist!');
                }
            }
        );

        grunt.registerTask(
            'default',
            'Default task: serve',
            ['serve']
        );

        grunt.registerTask(
            'build',
            'Compile the sass, js, and rebuilds Jekyll',
            function() {
                lnpm(['grunt-contrib-concat', 'grunt-contrib-compass', 'grunt-jekyll', 'grunt-contrib-uglify']);
                grunt.task.run(['compass', 'concat:js', 'uglify', 'jekyll']);
            }
        );

        grunt.registerTask(
            'serve',
            'Build the site, start a server on port 4000, and watch for changes',
            function() {
                lnpm(['grunt-contrib-connect', 'grunt-contrib-watch', 'grunt-contrib-copy']);
                grunt.task.run(['build', 'connect', 'watch']);
            }
        );

        grunt.registerTask(
            'scrape',
            'Scrape the Guardian style guide',
            function() {
                lnpm(['grunt-contrib-concat', 'grunt-jekyll']);
                grunt.task.run([
                    'scrapePages',
                    'concat:definitions',
                    'cleanup',
                    'jekyll'
                ]);
            }
        );

    };

})();
<commit_msg>I broke the Gruntfile :(<commit_after>(function() { 'use strict';

    // NPM dependencies
    var _ = require('lodash');
    var request = require('request');
    var YAML = require('yamljs');
    var cheerio = require('cheerio');
    var slug = require('slug');
    var S = require('string');

    module.exports = function(grunt) {

        // Load dependencies
        require('time-grunt')(grunt);
        grunt.loadNpmTasks('grunt-contrib-watch');
        grunt.loadNpmTasks('grunt-contrib-compass');
        grunt.loadNpmTasks('grunt-jekyll');
        grunt.loadNpmTasks('grunt-contrib-connect');
        grunt.loadNpmTasks('grunt-contrib-concat');
        grunt.loadNpmTasks('grunt-contrib-copy');

        // Project configuration
        grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),

            tempYAMLDir: '_tempYAML',

            compass: {
                dist: {
                    options: {
                        config: 'config.rb'
                    }
                }
            },

            jekyll: {
                build: {
                    dest: '_site'
                },
            },

            watch: {
                sass: {
                    files: ['_sass/**/*.sass'],
                    tasks: ['compass', 'copy:assets'],
                },
                jekyll: {
                    files: ['_config.yml', '**/*.{html, md, yaml, yml}'],
                    tasks: ['jekyll']
                },
                js: {
                    files: ['_js/**/*.js'],
                    tasks: ['concat:js', 'copy:assets']
                }
            },

            connect: {
                server: {
                    options: {
                       port: 4000,
                        base: '_site'
                    }
                }
            },

            concat: {
                definitions: {
                    src: ['<%= tempYAMLDir %>/*.yaml'],
                    dest: '_data/definitions.yaml',
                },
                js: {
                    src: ['_js/jquery-1.11.0.min.js', '_js/**/*.js'],
                    dest: 'assets/app.js'
                }
            },

            copy: {
                assets: {
                    src: ['assets/*'],
                    dest: '_site/'
                }
            }

        });

        grunt.registerTask(
            'scrapePages',
            'Runs the scrapePage task on every page of the Guardian style guide',
            function () {

                // Generate the alphabet
                var letters = [];
                for (var i = 97; i <= 122; i++) {
                    letters[letters.length] = String.fromCharCode(i);
                }

                letters.forEach(function (letter) {
                    grunt.task.run('scrapePage:' + letter);
                });
            }
        );

        grunt.registerTask(
            'scrapePage',
            'Scrape an individual page of the Guardian style guide for data and save as a YAML file',
            function(letter) {
                var filename = grunt.config.get('tempYAMLDir') + '/' + letter + '.yaml';
                var url = 'http://www.theguardian.com/styleguide/' + letter;

                var slugOptions = {
                    charmap: _.extend(slug.charmap, {
                        "'": null
                    })
                };

                grunt.log.write('Retrieving ' + url + '... ');

                var done = this.async();
                request(url, function (error, response, body) {
                    if (error || response.statusCode !== 200) {
                        grunt.log.error(error);
                        done(false);
                    } else {

                        grunt.log.ok();

                        // Parse it
                        grunt.log.write('Parsing to YAML... ');
                        var $ = cheerio.load(body);
                        var definitions = [];
                        $('#content').find('li.normal').each(function() {
                            var title = $(this).find('h3').text().trim();

                            // Have to use string because slug doesn't correctly
                            // strip punctuation :/
                            definitions.push({
                                title: _.escape(title),
                                slug: slug(S(title).stripPunctuation().s).toLowerCase(),
                                text: _.escape($(this).find('.trailtext').text().trim())
                            });
                        });
                        grunt.log.ok();

                        // Write the file
                        var output = [{
                            letter: letter,
                            definitions: definitions
                        }];
                        grunt.log.write('Writing to ' + filename + '... ');
                        grunt.file.write(filename, YAML.stringify(output, 4, 4));
                        grunt.log.ok();

                        // Finish
                        grunt.log.ok('Scrape complete!');
                        done();

                    }

                });

            }

        );

        grunt.registerTask(
            'cleanup',
            function () {
                grunt.log.write('Deleting temporary directory... ');
                var path = grunt.config.get('tempYAMLDir');
                if (grunt.file.exists(path)) {
                    grunt.file.delete(path);
                    grunt.log.ok();
                } else {
                    grunt.log.ok('Directory doesn\'t exist!');
                }
            }
        );

        grunt.registerTask(
            'default',
            'Default task: serve',
            ['serve']
        );

        grunt.registerTask(
            'build',
            'Recompiles the sass, js, and rebuilds Jekyll',
            function() {
                grunt.task.run(['compass', 'concat:js', 'jekyll']);
            }
        );

        grunt.registerTask(
            'serve',
            'Start a web server on port 4000, and rebuild after changes',
            function() {
                grunt.task.run(['build', 'connect', 'watch']);
            }
        );

        grunt.registerTask(
            'scrape',
            'Scrape the Guardian style guide',
            function() {
                grunt.task.run([
                    'scrapePages',
                    'concat:definitions',
                    'cleanup',
                    'jekyll'
                ]);
            }
        );

    };

})();
<|endoftext|>


<commit_before>// Generated on 2014-07-09 using generator-angular 0.4.0
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    // configurable paths
    var yeomanConfig = {
        app: 'client',
        server: 'server',
        test: 'test',

        distroot: 'dist',
        dist: 'dist/client',
        distserver: 'dist/server'
    };

    try {
        yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app;
    } catch (e) {
    }

    grunt.initConfig({
        yeoman: yeomanConfig,
        autoprefixer: {
            options: ['last 1 version'],
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/styles/',
                        src: '{,*/}*.css',
                        dest: '.tmp/styles/'
                    }
                ]
            }
        },
        clean: {
            dist: {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            '<%= yeoman.distroot %>/*',
                            '!<%= yeoman.distroot %>/.git*'
                        ]
                    }
                ]
            },
            server: '.tmp'
        },
        tslint: {
            options: {
                configuration: grunt.file.readJSON("tslint.json")
            },
            all: [
                'BerryForms.ts',
                'client/{,**/}*.ts',
                'server/{,**/}*.ts',
                'test/{,**/}*.ts'
            ],
            client: [
                'client/{,**/}*.ts'
            ],
            server: [
                'server/{,**/}*.ts'
            ]
        },
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                        '<%= yeoman.dist %>/styles/fonts/*'
                    ]
                }
            }
        },
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>/images',
                        src: '{,*/}*.{png,jpg,jpeg}',
                        dest: '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },
        svgmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>/images',
                        src: '{,*/}*.svg',
                        dest: '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },
        cssmin: {},
        htmlmin: {
            dist: {
                options: {},
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>',
                        src: ['*.html', 'views/*.html'],
                        dest: '<%= yeoman.dist %>'
                    }
                ]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [
                    //Client
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= yeoman.app %>',
                        dest: '<%= yeoman.dist %>',
                        src: [
                            '*.{ico,png,txt}',
                            '.htaccess',
                            'images/{,*/}*.{gif,webp}',
                            'fonts/{,*/}*',
                            'angular/localization/*/*.js'
                        ]
                    },
                    {
                        expand: true,
                        cwd: '.tmp/images',
                        dest: '<%= yeoman.dist %>/images',
                        src: [
                            'generated/*'
                        ]
                    },
                    //Server
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= yeoman.server %>',
                        dest: '<%= yeoman.distserver %>',
                        src: [
                            '*/{,*/}*.js',

                            //Exclude interfaces
                            '!*/{,*/}I*.js',
                            '*/{,*/}Identifier*.js'
                        ]
                    },
                    //Root
                    {
                        expand: true,
                        dot: true,
                        cwd: '.',
                        dest: '<%= yeoman.distroot %>',
                        src: [
                            'package.json',
                            'BerryForms.js'
                        ]
                    }
                ]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },
        concurrent: {
            dist: [
                'copy:styles',
                'imagemin',
                'svgmin',
                'htmlmin'
            ]
        },
        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            },
            unitTravis: {
                configFile: 'karma.conf.js',
                browsers: ['Firefox'],
                singleRun: true
            },
            e2e: {
                configFile: 'karma-e2e.conf.js',
                singleRun: true
            }
        },
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },
        ngmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.dist %>/scripts',
                        src: '*.js',
                        dest: '<%= yeoman.dist %>/scripts'
                    }
                ]
            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/scripts/scripts.js': [
                        '<%= yeoman.dist %>/scripts/scripts.js'
                    ]
                }
            }
        },
        ngtemplates: {
            app: {
                cwd: '<%= yeoman.app %>',
                src: ['angular/**/*.html', 'template/**/*.html'],
                dest: '<%= yeoman.dist %>/scripts/app-templates.js',
                options: {
                    bootstrap: function (module, script) {
                        return 'var _global = this;' +
                            '_global.BootstrapScripts = _global.BootstrapScripts || [];' +
                            '_global.BootstrapScripts.push(function(angular){' +
                            'angular.module("BerryFormsApp").run(["$templateCache",function($templateCache){' + script + '}]);});';
                    },
                    htmlmin: {
                        collapseWhitespace: true,
                        collapseBooleanAttributes: true
                    }
                }
            }
        },
        less: {
            options: {
                paths: ['<%= yeoman.app %>/styles']
            },
            client: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '<%= yeoman.app %>/styles',
                src: '*.less',
                ext: '.css'
            }
        },
        typescript: {
            client: {
                src: ['<%= yeoman.app %>/**/*.ts', '!<%= yeoman.app %>/angular/localization/*/*.ts'],
                options: {
                    sourceMap: true,
                    module: 'commonjs'
                }
            },
            clientLocalization: {
                src: ['<%= yeoman.app %>/angular/localization/*/*.ts'],
                options: {
                    sourceMap: false,
                    module: 'commonjs'
                }
            },
            server: {
                src: ['<%= yeoman.server %>/**/*.ts', 'BerryForms.ts'],
                options: {
                    sourceMap: true,
                    module: 'commonjs'
                }
            },
            test: {
                src: ['<%= yeoman.test %>/**/*.ts'],
                options: {
                    sourceMap: true,
                    module: 'commonjs'
                }
            }
        }
    });

    //Tasks
    //Lint
    grunt.registerTask('lint', [
        'tslint:all'
    ]);

    //Tests
    grunt.registerTask('unit-test', [
        'karma:unit'
    ]);

    grunt.registerTask('e2e-test', [
        'karma:e2e'
    ]);

    //Compile (less + typescript)
    grunt.registerTask('compile', [
        'less:client',
        'typescript:client',
        'typescript:clientLocalization',
        'typescript:server',
        'typescript:test'
    ]);

    //Build application (compile, bundle, minify)
    grunt.registerTask('build', [
        'compile',
        //'tslint:all',
        'tslint:client',
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'copy:dist',
        'ngtemplates',
        'cdnify',
        'ngmin',
        'cssmin',
        'uglify',
        'rev',
        'usemin',
        'clean:server'
    ]);

    //Travis build server task
    grunt.registerTask('travis', [
        'build',
        'karma:unitTravis'
    ]);
};
<commit_msg>Remove tslint from build<commit_after>// Generated on 2014-07-09 using generator-angular 0.4.0
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    // configurable paths
    var yeomanConfig = {
        app: 'client',
        server: 'server',
        test: 'test',

        distroot: 'dist',
        dist: 'dist/client',
        distserver: 'dist/server'
    };

    try {
        yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app;
    } catch (e) {
    }

    grunt.initConfig({
        yeoman: yeomanConfig,
        autoprefixer: {
            options: ['last 1 version'],
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/styles/',
                        src: '{,*/}*.css',
                        dest: '.tmp/styles/'
                    }
                ]
            }
        },
        clean: {
            dist: {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            '<%= yeoman.distroot %>/*',
                            '!<%= yeoman.distroot %>/.git*'
                        ]
                    }
                ]
            },
            server: '.tmp'
        },
        tslint: {
            options: {
                configuration: grunt.file.readJSON("tslint.json")
            },
            all: [
                'BerryForms.ts',
                'client/{,**/}*.ts',
                'server/{,**/}*.ts',
                'test/{,**/}*.ts'
            ],
            client: [
                'client/{,**/}*.ts'
            ],
            server: [
                'server/{,**/}*.ts'
            ]
        },
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                        '<%= yeoman.dist %>/styles/fonts/*'
                    ]
                }
            }
        },
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>/images',
                        src: '{,*/}*.{png,jpg,jpeg}',
                        dest: '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },
        svgmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>/images',
                        src: '{,*/}*.svg',
                        dest: '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },
        cssmin: {},
        htmlmin: {
            dist: {
                options: {},
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.app %>',
                        src: ['*.html', 'views/*.html'],
                        dest: '<%= yeoman.dist %>'
                    }
                ]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [
                    //Client
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= yeoman.app %>',
                        dest: '<%= yeoman.dist %>',
                        src: [
                            '*.{ico,png,txt}',
                            '.htaccess',
                            'images/{,*/}*.{gif,webp}',
                            'fonts/{,*/}*',
                            'angular/localization/*/*.js'
                        ]
                    },
                    {
                        expand: true,
                        cwd: '.tmp/images',
                        dest: '<%= yeoman.dist %>/images',
                        src: [
                            'generated/*'
                        ]
                    },
                    //Server
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= yeoman.server %>',
                        dest: '<%= yeoman.distserver %>',
                        src: [
                            '*/{,*/}*.js',

                            //Exclude interfaces
                            '!*/{,*/}I*.js',
                            '*/{,*/}Identifier*.js'
                        ]
                    },
                    //Root
                    {
                        expand: true,
                        dot: true,
                        cwd: '.',
                        dest: '<%= yeoman.distroot %>',
                        src: [
                            'package.json',
                            'BerryForms.js'
                        ]
                    }
                ]
            },
            styles: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            }
        },
        concurrent: {
            dist: [
                'copy:styles',
                'imagemin',
                'svgmin',
                'htmlmin'
            ]
        },
        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            },
            unitTravis: {
                configFile: 'karma.conf.js',
                browsers: ['Firefox'],
                singleRun: true
            },
            e2e: {
                configFile: 'karma-e2e.conf.js',
                singleRun: true
            }
        },
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },
        ngmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.dist %>/scripts',
                        src: '*.js',
                        dest: '<%= yeoman.dist %>/scripts'
                    }
                ]
            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/scripts/scripts.js': [
                        '<%= yeoman.dist %>/scripts/scripts.js'
                    ]
                }
            }
        },
        ngtemplates: {
            app: {
                cwd: '<%= yeoman.app %>',
                src: ['angular/**/*.html', 'template/**/*.html'],
                dest: '<%= yeoman.dist %>/scripts/app-templates.js',
                options: {
                    bootstrap: function (module, script) {
                        return 'var _global = this;' +
                            '_global.BootstrapScripts = _global.BootstrapScripts || [];' +
                            '_global.BootstrapScripts.push(function(angular){' +
                            'angular.module("BerryFormsApp").run(["$templateCache",function($templateCache){' + script + '}]);});';
                    },
                    htmlmin: {
                        collapseWhitespace: true,
                        collapseBooleanAttributes: true
                    }
                }
            }
        },
        less: {
            options: {
                paths: ['<%= yeoman.app %>/styles']
            },
            client: {
                expand: true,
                cwd: '<%= yeoman.app %>/styles',
                dest: '<%= yeoman.app %>/styles',
                src: '*.less',
                ext: '.css'
            }
        },
        typescript: {
            client: {
                src: ['<%= yeoman.app %>/**/*.ts', '!<%= yeoman.app %>/angular/localization/*/*.ts'],
                options: {
                    sourceMap: true,
                    module: 'commonjs'
                }
            },
            clientLocalization: {
                src: ['<%= yeoman.app %>/angular/localization/*/*.ts'],
                options: {
                    sourceMap: false,
                    module: 'commonjs'
                }
            },
            server: {
                src: ['<%= yeoman.server %>/**/*.ts', 'BerryForms.ts'],
                options: {
                    sourceMap: true,
                    module: 'commonjs'
                }
            },
            test: {
                src: ['<%= yeoman.test %>/**/*.ts'],
                options: {
                    sourceMap: true,
                    module: 'commonjs'
                }
            }
        }
    });

    //Tasks
    //Lint
    grunt.registerTask('lint', [
        'tslint:all'
    ]);

    //Tests
    grunt.registerTask('unit-test', [
        'karma:unit'
    ]);

    grunt.registerTask('e2e-test', [
        'karma:e2e'
    ]);

    //Compile (less + typescript)
    grunt.registerTask('compile', [
        'less:client',
        'typescript:client',
        'typescript:clientLocalization',
        'typescript:server',
        'typescript:test'
    ]);

    //Build application (compile, bundle, minify)
    grunt.registerTask('build', [
        'compile',
        //'tslint:all',
        //'tslint:client',
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'copy:dist',
        'ngtemplates',
        'cdnify',
        'ngmin',
        'cssmin',
        'uglify',
        'rev',
        'usemin',
        'clean:server'
    ]);

    //Travis build server task
    grunt.registerTask('travis', [
        'build',
        'karma:unitTravis'
    ]);
};
<|endoftext|>