<commit_before>import styled, { css } from 'styled-components';
import { getters as g } from '../util';
import { typoButton, shadow2dp, shadow4dp, focusShadow } from '../mixins';

const base = css`
  background: transparent;
  border: none;
  border-radius: ${g.buttonBorderRadius};
  color: ${g.buttonSecondaryColor};
  position: relative;
  height: ${g.buttonHeight}px;
  margin: 0;
  min-width: ${g.buttonMinWidth}px;
  padding: 0 ${g.buttonPadding}px;
  white-space: nowrap;
  display: inline-flex;
  ${typoButton()}
  overflow: hidden;
  will-change: box-shadow;
  transition: box-shadow 0.2s ${g.animationCurveFastOutLinearIn},
              background-color 0.2s ${g.animationCurveDefault},
              color 0.2s ${g.animationCurveDefault};
  outline: none;
  cursor: pointer;
  text-decoration: none;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  &::-moz-focus-inner { border: 0; }
  &:hover { background-color: ${g.buttonHoverColor} }
  &:focus:not(:active) { background-color: ${g.buttonFocusColor} }
  &:active { background-color: ${g.buttonActiveColor} }
`;

const mods = css`
  ${({ colored }) => colored && css`
    color: ${g.buttonPrimaryColorAlt};
    &:focus:not(:active) {
      background-color: ${g.buttonFocusColorAlt};
    }
  `}
  ${({ raised }) => raised && css`
    background: ${g.buttonPrimaryColor};
    ${shadow2dp()}

    &:active {
      ${shadow4dp()}
      background-color: ${g.buttonActiveColor};
    }

    &:focus:not(:active) {
      ${focusShadow()}
      background-color: ${g.buttonActiveColor};
    }

    ${({ colored }) => colored && css`
      background: ${g.buttonPrimaryColorAlt};
      color: ${g.buttonSecondaryColorAlt};

      &:hover {
        background-color: ${g.buttonHoverColorAlt};
      }

      &:active {
        background-color: ${g.buttonActiveColorAlt};
      }

      &:focus:not(:active) {
        background-color: ${g.buttonActiveColorAlt};
      }
    `}
  `}
  ${({ fab }) => fab && css`
    border-radius: 50%;
    font-size: ${g.buttonFabFontSize}px;
    height: ${g.buttonFabSize}px;
    margin: auto;
    min-width: ${g.buttonFabSize}px;
    width: ${g.buttonFabSize}px;
    padding: 0;
    overflow: hidden;
    background: ${g.buttonPrimaryColor};
    ${shadow2dp()}
    position: relative;
    line-height: normal;

    ${({ mini }) => mini && css`
      height: ${g.buttonFabSizeMini}px;
      min-width: ${g.buttonFabSizeMini}px;
      width: ${g.buttonFabSizeMini}px;
    `}

    &:active {
      ${shadow4dp()}
      background-color: ${g.buttonActiveColor};
    }

    &:focus:not(:active) {
      ${focusShadow()}
      background-color: ${g.buttonActiveColor};
    }

    ${({ colored }) => colored && css`
      background: ${g.buttonFabColorAlt};
      color: ${g.buttonFabTextColorAlt};

      &:hover {
        background-color: ${g.buttonFabHoverColorAlt};
      }

      &:focus:not(:active) {
        background-color: ${g.buttonFabActiveColorAlt};
      }

      &:active {
        background-color: ${g.buttonFabActiveColorAlt};
      }
    `}
  `}
  ${({ icon }) => icon && css`
    border-radius: 50%;
    font-size: ${g.buttonFabFontSize}px;
    height: ${g.buttonIconSize}px;
    margin-left: 0;
    margin-right: 0;
    min-width: ${g.buttonIconSize}px;
    width: ${g.buttonIconSize}px;
    padding: 0;
    overflow: hidden;
    color: inherit;
    line-height: normal;

    ${({ mini }) => mini && css`
      height: ${g.buttonIconSizeMini}px;
      min-width: ${g.buttonIconSizeMini}px;
      width: ${g.buttonIconSizeMini}px;
    `}
  `}
  ${({ primary }) => primary && css`
    color: ${g.buttonPrimaryColorAlt};
    ${({ raised, fab }) => (raised || fab) && css`
      color: ${g.buttonSecondaryColorAlt};
      background-color: ${g.buttonPrimaryColorAlt};;
      &:hover, &:active, &:focus:not(:active) {
        background-color: ${g.buttonPrimaryColorAlt};
      }
    `}
  `}
  ${({ accent }) => accent && css`
    color: ${g.buttonFabColorAlt};
    ${({ raised, fab }) => (raised || fab) && css`
      color: ${g.buttonFabTextColorAlt};
      background-color: ${g.buttonFabColorAlt};
      &:hover, &:active, &:focus:not(:active) {
        background-color: ${g.buttonFabColorAlt};
      }
    `}
  `}
  ${({ disabled }) => disabled && css`
    color: ${g.buttonSecondaryColorDisabled};
    cursor: default;
    background-color: transparent;
    &:hover {
      background-color: transparent;
    }
    ${({ fab }) => fab && css`
      background-color: ${g.buttonPrimaryColorDisabled};
      color: ${g.buttonSecondaryColorDisabled};
      &:hover, &:active, &:focus:not(:active) {
        background-color: ${g.buttonPrimaryColorDisabled};
        ${shadow2dp()}
      }
    `}
    ${({ colored }) => colored && css`
      color: ${g.buttonSecondaryColorDisabled};
      &:hover, &:active, &:focus:not(:active) {
        color: ${g.buttonSecondaryColorDisabled};
      }
    `}
    ${({ raised }) => raised && css`
      background-color: ${g.buttonPrimaryColorDisabled};
      color: ${g.buttonSecondaryColorDisabled};
      box-shadow: none;
      &:hover, &:active, &:focus:not(:active) {
        color: ${g.buttonSecondaryColorDisabled};
        background-color: ${g.buttonPrimaryColorDisabled};
      }
    `}
  `}
`;

export default styled.button`${base}${mods}`;
<commit_msg>Make button text centering more reliable<commit_after>import styled, { css } from 'styled-components';
import { getters as g } from '../util';
import { typoButton, shadow2dp, shadow4dp, focusShadow } from '../mixins';

const base = css`
  background: transparent;
  border: none;
  border-radius: ${g.buttonBorderRadius};
  color: ${g.buttonSecondaryColor};
  position: relative;
  height: ${g.buttonHeight}px;
  line-height: ${g.buttonHeight}px;
  margin: 0;
  min-width: ${g.buttonMinWidth}px;
  padding: 0 ${g.buttonPadding}px;
  white-space: nowrap;
  display: inline-flex;
  ${typoButton()}
  overflow: hidden;
  will-change: box-shadow;
  transition: box-shadow 0.2s ${g.animationCurveFastOutLinearIn},
              background-color 0.2s ${g.animationCurveDefault},
              color 0.2s ${g.animationCurveDefault};
  outline: none;
  cursor: pointer;
  text-decoration: none;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  &::-moz-focus-inner { border: 0; }
  &:hover { background-color: ${g.buttonHoverColor} }
  &:focus:not(:active) { background-color: ${g.buttonFocusColor} }
  &:active { background-color: ${g.buttonActiveColor} }
`;

const mods = css`
  ${({ colored }) => colored && css`
    color: ${g.buttonPrimaryColorAlt};
    &:focus:not(:active) {
      background-color: ${g.buttonFocusColorAlt};
    }
  `}
  ${({ raised }) => raised && css`
    background: ${g.buttonPrimaryColor};
    ${shadow2dp()}

    &:active {
      ${shadow4dp()}
      background-color: ${g.buttonActiveColor};
    }

    &:focus:not(:active) {
      ${focusShadow()}
      background-color: ${g.buttonActiveColor};
    }

    ${({ colored }) => colored && css`
      background: ${g.buttonPrimaryColorAlt};
      color: ${g.buttonSecondaryColorAlt};

      &:hover {
        background-color: ${g.buttonHoverColorAlt};
      }

      &:active {
        background-color: ${g.buttonActiveColorAlt};
      }

      &:focus:not(:active) {
        background-color: ${g.buttonActiveColorAlt};
      }
    `}
  `}
  ${({ fab }) => fab && css`
    border-radius: 50%;
    font-size: ${g.buttonFabFontSize}px;
    height: ${g.buttonFabSize}px;
    margin: auto;
    min-width: ${g.buttonFabSize}px;
    width: ${g.buttonFabSize}px;
    padding: 0;
    overflow: hidden;
    background: ${g.buttonPrimaryColor};
    ${shadow2dp()}
    position: relative;
    line-height: normal;

    ${({ mini }) => mini && css`
      height: ${g.buttonFabSizeMini}px;
      min-width: ${g.buttonFabSizeMini}px;
      width: ${g.buttonFabSizeMini}px;
    `}

    &:active {
      ${shadow4dp()}
      background-color: ${g.buttonActiveColor};
    }

    &:focus:not(:active) {
      ${focusShadow()}
      background-color: ${g.buttonActiveColor};
    }

    ${({ colored }) => colored && css`
      background: ${g.buttonFabColorAlt};
      color: ${g.buttonFabTextColorAlt};

      &:hover {
        background-color: ${g.buttonFabHoverColorAlt};
      }

      &:focus:not(:active) {
        background-color: ${g.buttonFabActiveColorAlt};
      }

      &:active {
        background-color: ${g.buttonFabActiveColorAlt};
      }
    `}
  `}
  ${({ icon }) => icon && css`
    border-radius: 50%;
    font-size: ${g.buttonFabFontSize}px;
    height: ${g.buttonIconSize}px;
    margin-left: 0;
    margin-right: 0;
    min-width: ${g.buttonIconSize}px;
    width: ${g.buttonIconSize}px;
    padding: 0;
    overflow: hidden;
    color: inherit;
    line-height: normal;

    ${({ mini }) => mini && css`
      height: ${g.buttonIconSizeMini}px;
      min-width: ${g.buttonIconSizeMini}px;
      width: ${g.buttonIconSizeMini}px;
    `}
  `}
  ${({ primary }) => primary && css`
    color: ${g.buttonPrimaryColorAlt};
    ${({ raised, fab }) => (raised || fab) && css`
      color: ${g.buttonSecondaryColorAlt};
      background-color: ${g.buttonPrimaryColorAlt};;
      &:hover, &:active, &:focus:not(:active) {
        background-color: ${g.buttonPrimaryColorAlt};
      }
    `}
  `}
  ${({ accent }) => accent && css`
    color: ${g.buttonFabColorAlt};
    ${({ raised, fab }) => (raised || fab) && css`
      color: ${g.buttonFabTextColorAlt};
      background-color: ${g.buttonFabColorAlt};
      &:hover, &:active, &:focus:not(:active) {
        background-color: ${g.buttonFabColorAlt};
      }
    `}
  `}
  ${({ disabled }) => disabled && css`
    color: ${g.buttonSecondaryColorDisabled};
    cursor: default;
    background-color: transparent;
    &:hover {
      background-color: transparent;
    }
    ${({ fab }) => fab && css`
      background-color: ${g.buttonPrimaryColorDisabled};
      color: ${g.buttonSecondaryColorDisabled};
      &:hover, &:active, &:focus:not(:active) {
        background-color: ${g.buttonPrimaryColorDisabled};
        ${shadow2dp()}
      }
    `}
    ${({ colored }) => colored && css`
      color: ${g.buttonSecondaryColorDisabled};
      &:hover, &:active, &:focus:not(:active) {
        color: ${g.buttonSecondaryColorDisabled};
      }
    `}
    ${({ raised }) => raised && css`
      background-color: ${g.buttonPrimaryColorDisabled};
      color: ${g.buttonSecondaryColorDisabled};
      box-shadow: none;
      &:hover, &:active, &:focus:not(:active) {
        color: ${g.buttonSecondaryColorDisabled};
        background-color: ${g.buttonPrimaryColorDisabled};
      }
    `}
  `}
`;

export default styled.button`${base}${mods}`;
<|endoftext|>


<commit_before>'use strict';

var LIVERELOAD_PORT = 35730;
var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT });
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};
module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    // configurable paths
    var config = {
        app: 'app',
        dist: 'dist'
    };

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

    grunt.initConfig({
        config: config,
        watch: {
            styles: {
                files: ['<%= config.app %>/styles/{,*/}*.css', '<%= config.app %>/lib/bootstrap/dist/css/*.css'],
                tasks: ['copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: LIVERELOAD_PORT
                },
                files: [
                    '<%= config.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '{.tmp,<%= config.app %>}/js/{,*/}*.js',
                    '<%= config.app %>/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },
        autoprefixer: {
            options: ['last 1 version'],

            dist: {

                files: [
                    {
                        expand: true,
                        cwd: '.tmp/styles/',
                        src: '{,*/}*.css',
                        dest: '.tmp/styles/'
                    }
                ]
            }
        },
        connect: {
            options: {
                port: 9001,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, config.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test')
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, config.dist)
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            '<%= config.dist %>/*',
                            '!<%= config.dist %>/.git*'
                        ]
                    }
                ]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                '<%= config.app %>/js/{,*/}*.js'
            ]
        },
        // not used since Uglify task does concat,
        // but still available if needed
        /*concat: {
         dist: {}
         },*/
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= config.dist %>/js/{,*/}*.js',
                        '<%= config.dist %>/css/{,*/}*.css',
                        '<%= config.dist %>/img/{,*/}*.{jpg,jpeg,gif,webp,svg}'
                    ]
                }
            }
        },
        useminPrepare: {
            html: '<%= config.app %>/index.html',
            options: {
                dest: '<%= config.dist %>'
            }
        },
        usemin: {
            html: ['<%= config.dist %>/{,*/}*.html'],
            css: ['<%= config.dist %>/css/{,*/}*.css'],
            options: {
                dirs: ['<%= config.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= config.app %>/img',
                        src: '{,*/}*.{png,jpg,jpeg}',
                        dest: '<%= config.dist %>/img'
                    }
                ]
            }
        },
        svgmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= config.app %>/img',
                        src: '{,*/}*.svg',
                        dest: '<%= config.dist %>/img'
                    }
                ]
            }
        },
        cssmin: {
            // By default, your `index.html` <!-- Usemin Block --> will take care of
            // minification. This option is pre-configured if you do not wish to use
            // Usemin blocks.
            // dist: {
            //   files: {
            //     '<%= config.dist %>/styles/main.css': [
            //       '.tmp/styles/{,*/}*.css',
            //       '<%= config.app %>/styles/{,*/}*.css'
            //     ]
            //   }
            // }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                     // https://github.com/config/grunt-usemin/issues/44
                     //collapseWhitespace: true,
                     collapseBooleanAttributes: true,
                     removeAttributeQuotes: true,
                     removeRedundantAttributes: true,
                     useShortDoctype: true,
                     removeEmptyAttributes: true,
                     removeOptionalTags: true*/
                },
                files: [
                    {
                        expand: true,
                        cwd: '<%= config.app %>',
                        src: ['*.html', 'partials/{,*/}*.html'],
                        dest: '<%= config.dist %>'
                    }
                ]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= config.app %>',
                        dest: '<%= config.dist %>',
                        src: [
                            '*.{txt}',
                            'img/{,*/}*.{gif,webp,ico}'
                        ]
                    },
                    {
                        expand: true,
                        cwd: '.tmp/images',
                        dest: '<%= config.dist %>/images',
                        src: [
                            'generated/*'
                        ]
                    },
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= config.app %>',
                        dest: '<%= config.dist %>',
                        src: [
                            'i18n/*.json'
                        ]
                    },
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= config.app %>',
                        dest: '<%= config.dist %>',
                        src: [
                            'lib/*angular-i18n/*.js'
                        ]
                    }
                ]
            },
            styles: {
                expand: true,
                cwd: '<%= config.app %>/styles',
                dest: '.tmp/css/',
                src: '{,*/}*.css'
            }
        },
        concurrent: {
            server: [
                'copy:styles'
            ],
            test: [
                'copy:styles'
            ],
            dist: [
                'copy:styles',
                'imagemin',
                'svgmin',
                'htmlmin'
            ]
        },

        karma: {
            options: {
                configFile: 'config/karma.conf.js'
            },
            dev: {
                browsers: ['Chrome']
            },
            ci: {
                browsers: ['PhantomJS'],
                singleRun: true
            },
            coverage: {
                browsers: ['PhantomJS'],
                reporters: ['coverage'],
                preprocessors: {
                    'app/js/**/*.js': ['coverage'],
                    'app/partials/directives/**/*.html': ['ng-html2js']
                },
                coverageReporter: {
                    type: "lcov",
                    dir: "coverage/"
                },
                singleRun: true
            }
        },
        coveralls: {
            options: {
                debug: true,
                coverage_dir: 'coverage'
            }
        },
        cdnify: {
            dist: {
                html: ['<%= config.dist %>/*.html']
            }
        },
        ngmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= config.dist %>/js',
                        src: '*.js',
                        dest: '<%= config.dist %>/js'
                    }
                ]
            }
        },
        uglify: {
            dist: {
                files: {
                    '<%= config.dist %>/js/application.js': [
                        '<%= config.dist %>/js/application.js'
                    ]
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-karma-coveralls');

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'open',
            'watch'
        ]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'karma'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'copy:dist',
        'cdnify',
        'ngmin',
        'cssmin',
        'uglify',
        'rev',
        'usemin'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);

    grunt.registerTask('coverage', [
        'karma:coverage',
        'coveralls'
    ]);
};
<commit_msg>Remove unused configuration<commit_after>'use strict';

var LIVERELOAD_PORT = 35730;
var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT });
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};
module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    // configurable paths
    var config = {
        app: 'app',
        dist: 'dist'
    };

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

    grunt.initConfig({
        config: config,
        watch: {
            styles: {
                files: ['<%= config.app %>/styles/{,*/}*.css', '<%= config.app %>/lib/bootstrap/dist/css/*.css'],
                tasks: ['copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: LIVERELOAD_PORT
                },
                files: [
                    '<%= config.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '{.tmp,<%= config.app %>}/js/{,*/}*.js',
                    '<%= config.app %>/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },
        autoprefixer: {
            options: ['last 1 version'],

            dist: {

                files: [
                    {
                        expand: true,
                        cwd: '.tmp/styles/',
                        src: '{,*/}*.css',
                        dest: '.tmp/styles/'
                    }
                ]
            }
        },
        connect: {
            options: {
                port: 9001,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, config.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test')
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, config.dist)
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= connect.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            '<%= config.dist %>/*',
                            '!<%= config.dist %>/.git*'
                        ]
                    }
                ]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                '<%= config.app %>/js/{,*/}*.js'
            ]
        },
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= config.dist %>/js/{,*/}*.js',
                        '<%= config.dist %>/css/{,*/}*.css',
                        '<%= config.dist %>/img/{,*/}*.{jpg,jpeg,gif,webp,svg}'
                    ]
                }
            }
        },
        useminPrepare: {
            html: '<%= config.app %>/index.html',
            options: {
                dest: '<%= config.dist %>'
            }
        },
        usemin: {
            html: ['<%= config.dist %>/{,*/}*.html'],
            css: ['<%= config.dist %>/css/{,*/}*.css'],
            options: {
                dirs: ['<%= config.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= config.app %>/img',
                        src: '{,*/}*.{png,jpg,jpeg}',
                        dest: '<%= config.dist %>/img'
                    }
                ]
            }
        },
        svgmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= config.app %>/img',
                        src: '{,*/}*.svg',
                        dest: '<%= config.dist %>/img'
                    }
                ]
            }
        },
        htmlmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= config.app %>',
                        src: ['*.html', 'partials/{,*/}*.html'],
                        dest: '<%= config.dist %>'
                    }
                ]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= config.app %>',
                        dest: '<%= config.dist %>',
                        src: [
                            '*.{txt}',
                            'img/{,*/}*.{gif,webp,ico}'
                        ]
                    },
                    {
                        expand: true,
                        cwd: '.tmp/images',
                        dest: '<%= config.dist %>/images',
                        src: [
                            'generated/*'
                        ]
                    },
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= config.app %>',
                        dest: '<%= config.dist %>',
                        src: [
                            'i18n/*.json'
                        ]
                    },
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= config.app %>',
                        dest: '<%= config.dist %>',
                        src: [
                            'lib/*angular-i18n/*.js'
                        ]
                    }
                ]
            },
            styles: {
                expand: true,
                cwd: '<%= config.app %>/styles',
                dest: '.tmp/css/',
                src: '{,*/}*.css'
            }
        },
        concurrent: {
            server: [
                'copy:styles'
            ],
            test: [
                'copy:styles'
            ],
            dist: [
                'copy:styles',
                'imagemin',
                'svgmin',
                'htmlmin'
            ]
        },

        karma: {
            options: {
                configFile: 'config/karma.conf.js'
            },
            dev: {
                browsers: ['Chrome']
            },
            ci: {
                browsers: ['PhantomJS'],
                singleRun: true
            },
            coverage: {
                browsers: ['PhantomJS'],
                reporters: ['coverage'],
                preprocessors: {
                    'app/js/**/*.js': ['coverage'],
                    'app/partials/directives/**/*.html': ['ng-html2js']
                },
                coverageReporter: {
                    type: "lcov",
                    dir: "coverage/"
                },
                singleRun: true
            }
        },
        coveralls: {
            options: {
                debug: true,
                coverage_dir: 'coverage'
            }
        },
        cdnify: {
            dist: {
                html: ['<%= config.dist %>/*.html']
            }
        },
        ngmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= config.dist %>/js',
                        src: '*.js',
                        dest: '<%= config.dist %>/js'
                    }
                ]
            }
        }
    });

    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-karma-coveralls');

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'open',
            'watch'
        ]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'concurrent:test',
        'autoprefixer',
        'connect:test',
        'karma'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat',
        'copy:dist',
        'cdnify',
        'ngmin',
        'cssmin',
        'uglify',
        'rev',
        'usemin'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);

    grunt.registerTask('coverage', [
        'karma:coverage',
        'coveralls'
    ]);
};
<|endoftext|>


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

    var version = 0.1;

    var babel = require('rollup-plugin-babel');
	var exposedFiles = ['engine/Story.js'];

    // Project configuration.
    grunt.initConfig( {
        pkg: grunt.file.readJSON('package.json'),
        watch: {
            files: ['engine/*.js'],
            tasks: ['rollup:cjs', 'rollup:iife']
        },
        rollup: {
            options: {
                plugins: [
                    babel({ exclude: 'node_modules/**' }),
                ],
                moduleId: 'inkjs',
                moduleName: 'inkjs',
            },
//			amd: {
//                options : { format: 'amd' },
//                dest: 'dist/ink.amd.js',
//                src: exposedFiles
//            },
            cjs: {
                options : { format: 'cjs' },
                dest: 'dist/ink.cjs.js',
                src: exposedFiles
            },
			iife: {
                options : { format: 'iife' },
                dest: 'dist/ink.iife.js',
                src: exposedFiles
            },
        },
		jasmine_node: {
        	options: {
				specFolders: ['tests/']
			},
        	all: [],
        },
    });

    // Load the plugin that provides tasks.
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-rollup');
    grunt.loadNpmTasks('grunt-jasmine-node');

    // Default task(s).
    grunt.registerTask('default', ['rollup']);
    grunt.registerTask('test', ['rollup:cjs', 'jasmine_node']);
};
<commit_msg>Build amd & umd files<commit_after>module.exports = function(grunt) {

    var version = 0.1;

    var babel = require('rollup-plugin-babel');
	var exposedFiles = ['engine/Story.js'];

    // Project configuration.
    grunt.initConfig( {
        pkg: grunt.file.readJSON('package.json'),
        watch: {
            files: ['engine/*.js'],
            tasks: ['rollup:cjs', 'rollup:iife']
        },
        rollup: {
            options: {
                plugins: [
                    babel({ exclude: 'node_modules/**' }),
                ],
                moduleId: 'inkjs',
                moduleName: 'inkjs',
            },
			amd: {
                options : { format: 'amd' },
                dest: 'dist/ink.amd.js',
                src: exposedFiles
            },
			umd: {
                options : { format: 'umd' },
                dest: 'dist/ink.umd.js',
                src: exposedFiles
            },
            cjs: {
                options : { format: 'cjs' },
                dest: 'dist/ink.cjs.js',
                src: exposedFiles
            },
			iife: {
                options : { format: 'iife' },
                dest: 'dist/ink.iife.js',
                src: exposedFiles
            },
        },
		jasmine_node: {
        	options: {
				specFolders: ['tests/']
			},
        	all: [],
        },
    });

    // Load the plugin that provides tasks.
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-rollup');
    grunt.loadNpmTasks('grunt-jasmine-node');

    // Default task(s).
    grunt.registerTask('default', ['rollup']);
    grunt.registerTask('test', ['rollup:cjs', 'jasmine_node']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
	'use strict';

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

		qunit: {
			dist: 'http://localhost:9537/test/widget.html'
		},

		connect: {
			server: {
				options: {
					port: 9537,
					base: '.'
				}
			}
		},

		watch: {
			gruntfile: {
				files: '<%= jshint.gruntfile %>',
				tasks: 'jshint:gruntfile'
			},

			dist: {
				files: '<%= jshint.dist %>',
				tasks: ['jshint:dist', 'uglify:dist']
			},

			test: {
				files: '<%= jshint.test %>',
				tasks: 'jshint:test'
			}
		},

		uglify: {
			options: {
				banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
			},

			dist: {
				expand: true,
				cwd: 'lib/',
				src: '**/*.js',
				dest: 'www/'
			}
		},

		minjson: {
			dist: {
				expand: true,
				cwd: 'lib/',
				src: '**/*.json',
				dest: 'www/'
			}
		},

		jshint: {
			gruntfile: 'Gruntfile.js',
			dist: 'lib/**/*.{js,json}',
			test: 'test/**/*.js',

			options: {
				immed: true,
				latedef: true,
				newcap: true,
				noarg: true,
				quotmark: true,
				sub: true,
				undef: true,
				boss: true,
				eqnull: false,
				regexdash: true,
				smarttabs: true,
				strict: true,
				node: true,
				browser: true,

				globals: {
					Gittip: true,

					// JSHint doesn't like XDomainRequest otherwise
					XDomainRequest: true
				}
			}
		}
	});

	grunt.loadNpmTasks('grunt-minjson');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-contrib-connect');

	grunt.registerTask('default', ['test', 'minify']);
	grunt.registerTask('minify', ['uglify', 'minjson']);
	grunt.registerTask('test', ['jshint']); //, 'connect', 'qunit']);
};
<commit_msg>Have JSHint warn if we have any unused variables<commit_after>module.exports = function(grunt) {
	'use strict';

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

		qunit: {
			dist: 'http://localhost:9537/test/widget.html'
		},

		connect: {
			server: {
				options: {
					port: 9537,
					base: '.'
				}
			}
		},

		watch: {
			gruntfile: {
				files: '<%= jshint.gruntfile %>',
				tasks: 'jshint:gruntfile'
			},

			dist: {
				files: '<%= jshint.dist %>',
				tasks: ['jshint:dist', 'uglify:dist']
			},

			test: {
				files: '<%= jshint.test %>',
				tasks: 'jshint:test'
			}
		},

		uglify: {
			options: {
				banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
			},

			dist: {
				expand: true,
				cwd: 'lib/',
				src: '**/*.js',
				dest: 'www/'
			}
		},

		minjson: {
			dist: {
				expand: true,
				cwd: 'lib/',
				src: '**/*.json',
				dest: 'www/'
			}
		},

		jshint: {
			gruntfile: 'Gruntfile.js',
			dist: 'lib/**/*.{js,json}',
			test: 'test/**/*.js',

			options: {
				immed: true,
				latedef: true,
				newcap: true,
				noarg: true,
				quotmark: true,
				sub: true,
				undef: true,
				unused: true,
				boss: true,
				eqnull: false,
				regexdash: true,
				smarttabs: true,
				strict: true,
				node: true,
				browser: true,

				globals: {
					Gittip: true,

					// JSHint doesn't like XDomainRequest otherwise
					XDomainRequest: true
				}
			}
		}
	});

	grunt.loadNpmTasks('grunt-minjson');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-contrib-connect');

	grunt.registerTask('default', ['test', 'minify']);
	grunt.registerTask('minify', ['uglify', 'minjson']);
	grunt.registerTask('test', ['jshint']); //, 'connect', 'qunit']);
};
<|endoftext|>


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

    var frameworkFiles = [
        'src/functions.js',
        /* interfaces first */
        'src/ConfiguratorInterface.js',
        'src/ControllerInterface.js',
        'src/EntityInterface.js',
        'src/FactoryInterface.js',
        'src/HTTP/RequestInterface.js',
        'src/HTTP/ResponseInterface.js',
        'src/Lib/Generator/Interface.js',
        'src/Lib/Logger/Handler/Interface.js',
        'src/Lib/Logger/Interface.js',
        'src/StateRegistryInterface.js',
        'src/RegistryInterface.js',
        'src/ServiceContainerInterface.js',
        'src/Storage/RepositoryInterface.js',
        'src/Storage/EngineInterface.js',
        'src/Storage/StoreMapperInterface.js',
        'src/View/LayoutFactoryInterface.js',
        'src/View/ListFactoryInterface.js',
        'src/View/TemplateEngineInterface.js',
        'src/View/ViewScreenFactoryInterface.js',
        /* kernel */
        'src/Kernel/ActionDispatcher.js',
        'src/Kernel/AppParser.js',
        'src/Kernel/ControllerManager.js',
        'src/Kernel/Core.js',
        'src/Kernel/FeatureTester.js',
        /* libs */
        'src/Lib/Generator/UUID.js',
        'src/Lib/Logger/CoreLogger.js',
        'src/Lib/Logger/Handler/Console.js',
        'src/Lib/Mediator.js',
        /* http */
        'src/HTTP/Request.js',
        'src/HTTP/Response.js',
        'src/HTTP/JSONRequest.js',
        'src/HTTP/JSONResponse.js',
        'src/HTTP/HeaderParser.js',
        'src/HTTP/HTMLRequest.js',
        'src/HTTP/HTMLResponse.js',
        'src/HTTP/Manager.js',
        'src/HTTP/REST.js',
        /* storage */
        'src/Storage/Core.js',
        'src/Storage/Event/LifecycleEvent.js',
        'src/Storage/Engine/IndexedDB.js',
        'src/Storage/Engine/Localstorage.js',
        'src/Storage/Engine/Rest.js',
        'src/Storage/EngineFactory/AbstractFactory.js',
        'src/Storage/EngineFactory/Core.js',
        'src/Storage/EngineFactory/IndexedDBFactory.js',
        'src/Storage/EngineFactory/LocalstorageFactory.js',
        'src/Storage/EngineFactory/RestFactory.js',
        'src/Storage/Manager.js',
        'src/Storage/ManagerFactory.js',
        'src/Storage/Repository.js',
        'src/Storage/RepositoryFactory.js',
        'src/Storage/StoreMapper/IndexedDBMapper.js',
        'src/Storage/StoreMapper/LocalstorageMapper.js',
        'src/Storage/StoreMapper/RestMapper.js',
        'src/Storage/UnitOfWork.js',
        'src/Storage/UnitOfWorkFactory.js',
        /* view */
        'src/View/Event/ViewPortEvent.js',
        'src/View/NodeWrapper.js',
        'src/View/Layout.js',
        'src/View/LayoutFactory.js',
        'src/View/List.js',
        'src/View/ListFactory.js',
        'src/View/Manager.js',
        'src/View/Parser.js',
        'src/View/TemplateEngine.js',
        'src/View/ViewPort.js',
        'src/View/ViewScreen.js',
        'src/View/ViewScreenFactory.js',
        /* events */
        'src/Event/AppShutdownEvent.js',
        'src/Event/ControllerEvent.js',
        /* top objects */
        'src/Configurator.js',
        'src/Controller.js',
        'src/DOM.js',
        'src/Entity.js',
        'src/ParamProxy.js',
        'src/StateRegistry.js',
        'src/StateRegistryFactory.js',
        'src/Registry.js',
        'src/RegistryFactory.js',
        'src/ServiceContainer.js',
        'src/Translator.js',
        'bootstrap.js'
    ];

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %>#<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */'
            },
            build: {
                files: {
                    'dist/framework.min.js': frameworkFiles
                }
            },
            concat: {
                files: {
                    'dist/framework.js': frameworkFiles
                },
                options: {
                    mangle: false,
                    beautify: true
                }
            }
        },
        'bower-install': {
            target: {
                html: 'index.html',
                jsPattern: '<script src="{{filePath}}"></script>'
            }
        },
        exec: {
            test: {
                cmd: function (pkg) {
                    var path;

                    switch (pkg) {
                        case 'lib':
                            path = 'lib/';
                            break;
                        case 'storage':
                            path = 'storage/';
                            break;
                        case 'view':
                            path = 'view/';
                            break;
                        case 'kernel':
                            path = 'kernel';
                            break;
                        case 'event':
                            path = 'event';
                            break;
                        case 'topLevel':
                            path = [
                                'entity.js',
                                'functions.js',
                                'stateregistry.js',
                                'stateregistryfactory.js',
                                'registry.js',
                                'registryfactory.js',
                                'servicecontainer.js',
                                'translator.js',
                            ].join(',tests/');
                            break;
                    }

                    return './node_modules/venus/bin/venus run -t tests/' + path + ' -c -n --singleton';
                }
            }
        },
        watch: {
            js: {
                files: ['src/*.js'],
                tasks: [],
                options: {
                    livereload: true
                }
            }
        },
        jscs: {
            src: 'src/**/*.js',
            options: {
                requireCurlyBraces: [
                    'if',
                    'else',
                    'for',
                    'do',
                    'while',
                    'try',
                    'catch',
                ],
                requireSpaceAfterKeywords: [
                    'if',
                    'else',
                    'for',
                    'do',
                    'while',
                    'switch',
                    'try',
                    'catch'
                ],
                requireParenthesesAroundIIFE: true,
                requireSpacesInFunctionExpression: {
                    beforeOpeningRoundBrace: true,
                    beforeOpeningCurlyBrace: true
                },
                disallowSpacesInsideObjectBrackets: true,
                disallowSpacesInsideArrayBrackets: true,
                disallowSpacesInsideParentheses: true,
                disallowQuotedKeysInObjects: true,
                disallowSpaceAfterObjectKeys: true,
                requireCommaBeforeLineBreak: true,
                requireOperatorBeforeLineBreak: [
                    '?',
                    '+',
                    '-',
                    '/',
                    '*',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!==',
                    '>',
                    '>=',
                    '<',
                    '<='
                ],
                disallowLeftStickedOperators: [
                    '?',
                    '+',
                    '-',
                    '/',
                    '*',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!==',
                    '>',
                    '>=',
                    '<',
                    '<='
                ],
                requireRightStickedOperators: ['!'],
                disallowRightStickedOperators: [
                    '?',
                    '+',
                    '/',
                    '*',
                    ':',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!==',
                    '>',
                    '>=',
                    '<',
                    '<='
                ],
                requireLeftStickedOperators: [','],
                disallowSpaceAfterPrefixUnaryOperators: [
                    '++',
                    '--',
                    '+',
                    '-',
                    '~',
                    '!'
                ],
                disallowSpaceBeforePostfixUnaryOperators: [
                    '++',
                    '--'
                ],
                requireSpaceBeforeBinaryOperators: [
                    '+',
                    '-',
                    '/',
                    '*',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!=='
                ],
                requireSpaceAfterBinaryOperators: [
                    '+',
                    '-',
                    '/',
                    '*',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!=='
                ],
                requireCamelCaseOrUpperCaseIdentifiers: true,
                disallowKeywords: ["with"],
                disallowMultipleLineBreaks: true,
                validateQuoteMarks: '\'',
                disallowMixedSpacesAndTabs: true,
                disallowTrailingWhitespace: true,
                disallowKeywordsOnNewLine: ['else'],
                requireDotNotation: true,
                validateJSDoc: {
                    checkParamNames: true,
                    checkRedundantParams: true,
                    requireParamTypes: true
                }
            }
        }
    });

    require('load-grunt-tasks')(grunt);

    grunt.registerTask('default', ['bower-install']);
    grunt.registerTask('build', ['jscs', 'uglify']);
    grunt.registerTask('test', [
        'jscs',
        'exec:test:lib',
        'exec:test:storage',
        'exec:test:view',
        'exec:test:topLevel'
    ]);

};
<commit_msg>#15 added option to only run validator's tests via grunt<commit_after>module.exports = function (grunt) {

    var frameworkFiles = [
        'src/functions.js',
        /* interfaces first */
        'src/ConfiguratorInterface.js',
        'src/ControllerInterface.js',
        'src/EntityInterface.js',
        'src/FactoryInterface.js',
        'src/HTTP/RequestInterface.js',
        'src/HTTP/ResponseInterface.js',
        'src/Lib/Generator/Interface.js',
        'src/Lib/Logger/Handler/Interface.js',
        'src/Lib/Logger/Interface.js',
        'src/StateRegistryInterface.js',
        'src/RegistryInterface.js',
        'src/ServiceContainerInterface.js',
        'src/Storage/RepositoryInterface.js',
        'src/Storage/EngineInterface.js',
        'src/Storage/StoreMapperInterface.js',
        'src/View/LayoutFactoryInterface.js',
        'src/View/ListFactoryInterface.js',
        'src/View/TemplateEngineInterface.js',
        'src/View/ViewScreenFactoryInterface.js',
        /* kernel */
        'src/Kernel/ActionDispatcher.js',
        'src/Kernel/AppParser.js',
        'src/Kernel/ControllerManager.js',
        'src/Kernel/Core.js',
        'src/Kernel/FeatureTester.js',
        /* libs */
        'src/Lib/Generator/UUID.js',
        'src/Lib/Logger/CoreLogger.js',
        'src/Lib/Logger/Handler/Console.js',
        'src/Lib/Mediator.js',
        /* http */
        'src/HTTP/Request.js',
        'src/HTTP/Response.js',
        'src/HTTP/JSONRequest.js',
        'src/HTTP/JSONResponse.js',
        'src/HTTP/HeaderParser.js',
        'src/HTTP/HTMLRequest.js',
        'src/HTTP/HTMLResponse.js',
        'src/HTTP/Manager.js',
        'src/HTTP/REST.js',
        /* storage */
        'src/Storage/Core.js',
        'src/Storage/Event/LifecycleEvent.js',
        'src/Storage/Engine/IndexedDB.js',
        'src/Storage/Engine/Localstorage.js',
        'src/Storage/Engine/Rest.js',
        'src/Storage/EngineFactory/AbstractFactory.js',
        'src/Storage/EngineFactory/Core.js',
        'src/Storage/EngineFactory/IndexedDBFactory.js',
        'src/Storage/EngineFactory/LocalstorageFactory.js',
        'src/Storage/EngineFactory/RestFactory.js',
        'src/Storage/Manager.js',
        'src/Storage/ManagerFactory.js',
        'src/Storage/Repository.js',
        'src/Storage/RepositoryFactory.js',
        'src/Storage/StoreMapper/IndexedDBMapper.js',
        'src/Storage/StoreMapper/LocalstorageMapper.js',
        'src/Storage/StoreMapper/RestMapper.js',
        'src/Storage/UnitOfWork.js',
        'src/Storage/UnitOfWorkFactory.js',
        /* view */
        'src/View/Event/ViewPortEvent.js',
        'src/View/NodeWrapper.js',
        'src/View/Layout.js',
        'src/View/LayoutFactory.js',
        'src/View/List.js',
        'src/View/ListFactory.js',
        'src/View/Manager.js',
        'src/View/Parser.js',
        'src/View/TemplateEngine.js',
        'src/View/ViewPort.js',
        'src/View/ViewScreen.js',
        'src/View/ViewScreenFactory.js',
        /* events */
        'src/Event/AppShutdownEvent.js',
        'src/Event/ControllerEvent.js',
        /* top objects */
        'src/Configurator.js',
        'src/Controller.js',
        'src/DOM.js',
        'src/Entity.js',
        'src/ParamProxy.js',
        'src/StateRegistry.js',
        'src/StateRegistryFactory.js',
        'src/Registry.js',
        'src/RegistryFactory.js',
        'src/ServiceContainer.js',
        'src/Translator.js',
        'bootstrap.js'
    ];

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %>#<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */'
            },
            build: {
                files: {
                    'dist/framework.min.js': frameworkFiles
                }
            },
            concat: {
                files: {
                    'dist/framework.js': frameworkFiles
                },
                options: {
                    mangle: false,
                    beautify: true
                }
            }
        },
        'bower-install': {
            target: {
                html: 'index.html',
                jsPattern: '<script src="{{filePath}}"></script>'
            }
        },
        exec: {
            test: {
                cmd: function (pkg) {
                    var path;

                    switch (pkg) {
                        case 'lib':
                            path = 'lib/';
                            break;
                        case 'storage':
                            path = 'storage/';
                            break;
                        case 'view':
                            path = 'view/';
                            break;
                        case 'kernel':
                            path = 'kernel';
                            break;
                        case 'event':
                            path = 'event';
                            break;
                        case 'validator':
                            path = 'vaidator/';
                            break;
                        case 'topLevel':
                            path = [
                                'entity.js',
                                'functions.js',
                                'stateregistry.js',
                                'stateregistryfactory.js',
                                'registry.js',
                                'registryfactory.js',
                                'servicecontainer.js',
                                'translator.js',
                            ].join(',tests/');
                            break;
                    }

                    return './node_modules/venus/bin/venus run -t tests/' + path + ' -c -n --singleton';
                }
            }
        },
        watch: {
            js: {
                files: ['src/*.js'],
                tasks: [],
                options: {
                    livereload: true
                }
            }
        },
        jscs: {
            src: 'src/**/*.js',
            options: {
                requireCurlyBraces: [
                    'if',
                    'else',
                    'for',
                    'do',
                    'while',
                    'try',
                    'catch',
                ],
                requireSpaceAfterKeywords: [
                    'if',
                    'else',
                    'for',
                    'do',
                    'while',
                    'switch',
                    'try',
                    'catch'
                ],
                requireParenthesesAroundIIFE: true,
                requireSpacesInFunctionExpression: {
                    beforeOpeningRoundBrace: true,
                    beforeOpeningCurlyBrace: true
                },
                disallowSpacesInsideObjectBrackets: true,
                disallowSpacesInsideArrayBrackets: true,
                disallowSpacesInsideParentheses: true,
                disallowQuotedKeysInObjects: true,
                disallowSpaceAfterObjectKeys: true,
                requireCommaBeforeLineBreak: true,
                requireOperatorBeforeLineBreak: [
                    '?',
                    '+',
                    '-',
                    '/',
                    '*',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!==',
                    '>',
                    '>=',
                    '<',
                    '<='
                ],
                disallowLeftStickedOperators: [
                    '?',
                    '+',
                    '-',
                    '/',
                    '*',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!==',
                    '>',
                    '>=',
                    '<',
                    '<='
                ],
                requireRightStickedOperators: ['!'],
                disallowRightStickedOperators: [
                    '?',
                    '+',
                    '/',
                    '*',
                    ':',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!==',
                    '>',
                    '>=',
                    '<',
                    '<='
                ],
                requireLeftStickedOperators: [','],
                disallowSpaceAfterPrefixUnaryOperators: [
                    '++',
                    '--',
                    '+',
                    '-',
                    '~',
                    '!'
                ],
                disallowSpaceBeforePostfixUnaryOperators: [
                    '++',
                    '--'
                ],
                requireSpaceBeforeBinaryOperators: [
                    '+',
                    '-',
                    '/',
                    '*',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!=='
                ],
                requireSpaceAfterBinaryOperators: [
                    '+',
                    '-',
                    '/',
                    '*',
                    '=',
                    '==',
                    '===',
                    '!=',
                    '!=='
                ],
                requireCamelCaseOrUpperCaseIdentifiers: true,
                disallowKeywords: ["with"],
                disallowMultipleLineBreaks: true,
                validateQuoteMarks: '\'',
                disallowMixedSpacesAndTabs: true,
                disallowTrailingWhitespace: true,
                disallowKeywordsOnNewLine: ['else'],
                requireDotNotation: true,
                validateJSDoc: {
                    checkParamNames: true,
                    checkRedundantParams: true,
                    requireParamTypes: true
                }
            }
        }
    });

    require('load-grunt-tasks')(grunt);

    grunt.registerTask('default', ['bower-install']);
    grunt.registerTask('build', ['jscs', 'uglify']);
    grunt.registerTask('test', [
        'jscs',
        'exec:test:lib',
        'exec:test:storage',
        'exec:test:view',
        'exec:test:topLevel'
    ]);

};
<|endoftext|>


<commit_before>/*
 * Copyright 2016 e-UCM (http://www.e-ucm.es/)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * This project has received funding from the European Union’s Horizon
 * 2020 research and innovation programme under grant agreement No 644187.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0 (link is external)
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';
var Collection = require('easy-collections');

function backup(config, callback) {
    callback(null, config);
}

function upgrade(config, callback) {
    // Transformers
    var classesCollection = config.mongodb.db.collection('classes');
    var sessionscollection = config.mongodb.db.collection('sessions');

    // Remove the unnecesary fields from class
    classesCollection.updateMany({},
        { $unset: { gameId: '', versionId: ''} }
    ).then(function() {
        // Rename activities collection to activities
        sessionscollection.rename('activities', function(err, newColl) {
            if(err) {
                return callback(err);
            }
            callback(null, config);
        });
    });

}

function check(config, callback) {

    config.mongodb.db.db.listCollections().toArray(function(err, collections) {
        if (err) {
            console.log('Unexpected error while checking collections names!', err);
            return callback(err);
        }

        var activitiesExists = false;
        for (var key in collections) {
            var collection = collections[key];
            if (collection.name === 'activities') {
                activitiesExists = true;
            }
            if (collection.name === 'sessions') {
                return callback(new Error('Sessions collection found!'));
            }
        }

        if (!activitiesExists) {
            return callback(new Error('Activities collection not found!'));
        }

        var classesCollection = config.mongodb.db.collection('classes');

        classesCollection.find().forEach(function(classDoc) {
            if (classDoc.gameId) {
                return callback(new Error('A class contains a gameId'));
            }
            if (classDoc.versionId) {
                return callback(new Error('A class contains a versionId'));
            }
        });

        var activitiesCollection = config.mongodb.db.collection('activities');
        activitiesCollection.find().forEach(function(activity) {
            if (!activity.gameId) {
                return callback(new Error('An activity does not contain a gameId'));
            }
            if (!activity.versionId) {
                return callback(new Error('An activity does not contain a versionId'));
            }
        });
        callback(null, config);
    });
}

function clean(config, callback) {
    callback(null, config);
}

function restore(config, callback) {
    callback(null, config);
}

module.exports = {
    backup: backup,
    upgrade: upgrade,
    check: check,
    clean: clean,
    restore: restore,
    requires: {}, // Depends on nothing
    version: {
        origin: '2',
        destination: '3'
    }
};

<commit_msg>Checks if Activities collection already exists<commit_after>/*
 * Copyright 2016 e-UCM (http://www.e-ucm.es/)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * This project has received funding from the European Union’s Horizon
 * 2020 research and innovation programme under grant agreement No 644187.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0 (link is external)
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';
var Collection = require('easy-collections');

function backup(config, callback) {
    callback(null, config);
}

function upgrade(config, callback) {
    // Transformers
    var classesCollection = config.mongodb.db.collection('classes');
    var sessionsCollection = config.mongodb.db.collection('sessions');
    var activitiesCollection = config.mongodb.db.collection('activities');

    var cleanClasses = function(){
        // Remove the unnecesary fields from class
        classesCollection.updateMany({},
            { $unset: { gameId: '', versionId: ''} }
        ).then(function() {
            // Rename activities collection to activities
            sessionsCollection.rename('activities', function(err, newColl) {
                if(err) {
                    return callback(err);
                }
                callback(null, config);
            });
        });
    }

    activitiesCollection.find({}, function(err, iterator){
        iterator.toArray(function(err, docs) {
            if(docs.length > 0){
                var ts = new Date().getTime();
                console.log('WARNING MongoTransformerTo3: Activities collection already exists, creating backup in "activities_' + ts + '"');
                activitiesCollection.rename('activities_' + ts, function(err, newColl) {
                    if(err) {
                        console.log('WARNING MongoTransformerTo3: Cant create backup, aborting');
                        return callback(err);
                    }
                    console.log('MongoTransformerTo3: Activities collection backup created');

                    cleanClasses();
                });
            }else{
                console.log('MongoTransformerTo3: Activities collection may exist, but is empty. Trying to drop it.');
                activitiesCollection.drop(function(err, result){
                    if(err)
                        console.log('MongoTransformerTo3: Cant drop it. Probably dont exists.');
                    else
                        console.log('MongoTransformerTo3: Activities collection successfully dropped');

                    cleanClasses();
                })
            }
        });
    });

}

function check(config, callback) {

    config.mongodb.db.db.listCollections().toArray(function(err, collections) {
        if (err) {
            console.log('Unexpected error while checking collections names!', err);
            return callback(err);
        }

        var activitiesExists = false;
        for (var key in collections) {
            var collection = collections[key];
            if (collection.name === 'activities') {
                activitiesExists = true;
            }
            if (collection.name === 'sessions') {
                return callback(new Error('Sessions collection found!'));
            }
        }

        if (!activitiesExists) {
            return callback(new Error('Activities collection not found!'));
        }

        var classesCollection = config.mongodb.db.collection('classes');

        classesCollection.find().forEach(function(classDoc) {
            if (classDoc.gameId) {
                return callback(new Error('A class contains a gameId'));
            }
            if (classDoc.versionId) {
                return callback(new Error('A class contains a versionId'));
            }
        });

        var activitiesCollection = config.mongodb.db.collection('activities');
        activitiesCollection.find().forEach(function(activity) {
            if (!activity.gameId) {
                return callback(new Error('An activity does not contain a gameId'));
            }
            if (!activity.versionId) {
                return callback(new Error('An activity does not contain a versionId'));
            }
        });
        callback(null, config);
    });
}

function clean(config, callback) {
    callback(null, config);
}

function restore(config, callback) {
    callback(null, config);
}

module.exports = {
    backup: backup,
    upgrade: upgrade,
    check: check,
    clean: clean,
    restore: restore,
    requires: {}, // Depends on nothing
    version: {
        origin: '2',
        destination: '3'
    }
};

<|endoftext|>


<commit_before>// Generated on 2014-05-01 using generator-angular 0.8.0
'use strict';

// # 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'
//
var untildify = require('untildify');

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    hostname: process.env.SSO_DEV_HOST || 'localhost',
    port: process.env.SSO_DEV_PORT || 9000,

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['bowerInstall']
      },
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all','karma:liveunit:run'],
        options: {
          livereload: true
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma:liveunit:run']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.{less,css}'],
        tasks: ['less','autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      html: {
        files: ['<%= yeoman.app %>/{,*/}*.html'],
        tasks: ['includes:html']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: '<%=port %>',
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: '0.0.0.0',
        livereload: 35729
      },
      livereload: {
        options: {
          open: 'http://<%=hostname %>:<%=port %>',
          base: [
            '.tmp',
            '<%= yeoman.app %>'
          ]
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

    less: {
      development:{
        files: {
          '.tmp/styles/main.css':'<%= yeoman.app %>/styles/main.less'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ],
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 3 versions']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    bowerInstall: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath: '<%= yeoman.app %>/'
      }
    },

    // Renames files for browser caching purposes
    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/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      dist:{
        src: '<%= yeoman.app %>/index.html',
        options: {
          dest: '<%= yeoman.dist %>',
          flow: {
            html: {
              steps: {
                js: ['concat', 'uglifyjs'],
                css: ['cssmin']
              },
              post: {}
            }
          }
        }
      },
      debug:{
        src: '<%= yeoman.app %>/index.html',
        options: {
          dest: '<%= yeoman.dist %>',
          flow: {
            html: {
              steps: {
                js: ['concat'],
                css: ['cssmin']
              },
              post: {}
            }
          }
        }
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    cssmin: {
      options: {
        root: '<%= yeoman.app %>'
      }
    },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // ngmin tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            'images/{,*/}*.{webp}',
            'fonts/*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        },{
          expand: true,
          cwd: '.tmp',
          dest: '<%= yeoman.dist %>',
          src: ['*.html']
        },{
          expand: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: ['error.html']
        }]
      },
      less: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.{less}'
      },
      debug: {
        expand: true,
        cwd: '.tmp/concat/scripts',
        dest: '<%= yeoman.dist %>/scripts',
        src: '{,*/}*.js'
      },
      dest:{
        cwd: '<%= yeoman.dist %>',
        src: '**/*',
        dest: grunt.option('dest') ? untildify(grunt.option('dest')):'',
        expand: true
      },
    },
    includes: {
      html:{

        src: ['<%= yeoman.app %>/index.html'], // Source files
        dest: '.tmp/index.html', // Destination directory
        options: {
          // flatten: true,
          silent: false,
          banner: ''
        }
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:less',
        'less',
        'includes:html'
      ],
      test: [
        'copy:less'
      ],
      dist: [
        'copy:less',
        'less',
        'includes:html',
        'imagemin',
        'svgmin'
      ]
    },

    protractor: {
      options: {
        configFile: 'protractor.conf.js', // Default config file
        keepAlive: false, // If false, the grunt process stops when the test fails.
        noColor: false, // If true, protractor will not use colors in its output.
      },
      dev: {
        options: {
          args: {
            baseUrl: 'http://<%=hostname %>:<%=port %>',
            params: {
              appUrl: '/',
              apiUrl: 'http://fakeapi.stormpath.com:1337'
            }
          }
        }
      },
      sauce: {
        options: {
          configFile: 'protractor.conf.sauce.js',
          args: {
            sauceUser: process.env.SAUCE_USER,
            sauceKey: process.env.SAUCE_API_KEY,
            baseUrl: 'http://<%=hostname %>:<%=port %>',
            params: {
              appUrl: '/',
              apiUrl: 'http://fakeapi.stormpath.com:1337'
            }
          }
        }
      }
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Test settings

    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      },
      liveunit: { // starts a karma server in the background
        configFile: 'karma.conf.js',
        background: true
      }
    },
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'bowerInstall',
      'concurrent:server',
      'autoprefixer',
      'connect:livereload',
      'karma:liveunit',
      'watch'
    ]);
  });

  grunt.registerTask('server', function (target) {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', 'Build the project, assets are placed in dist/',
    [
      'clean:dist',
      'bowerInstall',
      'useminPrepare:dist',
      'concurrent:dist',
      'autoprefixer',
      'concat',
      'ngmin',
      'copy:dist',
      'cdnify',
      'cssmin',
      'uglify',
      // 'rev',
      'usemin'
      // 'htmlmin'
    ]
  );

  grunt.registerTask('build:debug', [
    'clean:dist',
    'bowerInstall',
    'useminPrepare:debug',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'usemin',
    'copy:debug'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);

  grunt.registerTask('dist',
    'Use this task to build a distro and copy it to the directoroy sepcified by --dist on the command line',
    function(){
      if(grunt.option('dest')){
        return grunt.task.run(['build','copy:dest']);
      }else{
        throw new Error('Must specify destination with --dest option');
      }
    }
  );
};
<commit_msg>disabling karma tests until i can fix the runner<commit_after>// Generated on 2014-05-01 using generator-angular 0.8.0
'use strict';

// # 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'
//
var untildify = require('untildify');

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    hostname: process.env.SSO_DEV_HOST || 'localhost',
    port: process.env.SSO_DEV_PORT || 9000,

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      bower: {
        files: ['bower.json'],
        tasks: ['bowerInstall']
      },
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all','karma:liveunit:run'],
        options: {
          livereload: true
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma:liveunit:run']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.{less,css}'],
        tasks: ['less','autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      html: {
        files: ['<%= yeoman.app %>/{,*/}*.html'],
        tasks: ['includes:html']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: '<%=port %>',
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: '0.0.0.0',
        livereload: 35729
      },
      livereload: {
        options: {
          open: 'http://<%=hostname %>:<%=port %>',
          base: [
            '.tmp',
            '<%= yeoman.app %>'
          ]
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

    less: {
      development:{
        files: {
          '.tmp/styles/main.css':'<%= yeoman.app %>/styles/main.less'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ],
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 3 versions']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    bowerInstall: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        ignorePath: '<%= yeoman.app %>/'
      }
    },

    // Renames files for browser caching purposes
    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/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      dist:{
        src: '<%= yeoman.app %>/index.html',
        options: {
          dest: '<%= yeoman.dist %>',
          flow: {
            html: {
              steps: {
                js: ['concat', 'uglifyjs'],
                css: ['cssmin']
              },
              post: {}
            }
          }
        }
      },
      debug:{
        src: '<%= yeoman.app %>/index.html',
        options: {
          dest: '<%= yeoman.dist %>',
          flow: {
            html: {
              steps: {
                js: ['concat'],
                css: ['cssmin']
              },
              post: {}
            }
          }
        }
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    cssmin: {
      options: {
        root: '<%= yeoman.app %>'
      }
    },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // ngmin tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            'images/{,*/}*.{webp}',
            'fonts/*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        },{
          expand: true,
          cwd: '.tmp',
          dest: '<%= yeoman.dist %>',
          src: ['*.html']
        },{
          expand: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: ['error.html']
        }]
      },
      less: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.{less}'
      },
      debug: {
        expand: true,
        cwd: '.tmp/concat/scripts',
        dest: '<%= yeoman.dist %>/scripts',
        src: '{,*/}*.js'
      },
      dest:{
        cwd: '<%= yeoman.dist %>',
        src: '**/*',
        dest: grunt.option('dest') ? untildify(grunt.option('dest')):'',
        expand: true
      },
    },
    includes: {
      html:{

        src: ['<%= yeoman.app %>/index.html'], // Source files
        dest: '.tmp/index.html', // Destination directory
        options: {
          // flatten: true,
          silent: false,
          banner: ''
        }
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:less',
        'less',
        'includes:html'
      ],
      test: [
        'copy:less'
      ],
      dist: [
        'copy:less',
        'less',
        'includes:html',
        'imagemin',
        'svgmin'
      ]
    },

    protractor: {
      options: {
        configFile: 'protractor.conf.js', // Default config file
        keepAlive: false, // If false, the grunt process stops when the test fails.
        noColor: false, // If true, protractor will not use colors in its output.
      },
      dev: {
        options: {
          args: {
            baseUrl: 'http://<%=hostname %>:<%=port %>',
            params: {
              appUrl: '/',
              apiUrl: 'http://fakeapi.stormpath.com:1337'
            }
          }
        }
      },
      sauce: {
        options: {
          configFile: 'protractor.conf.sauce.js',
          args: {
            sauceUser: process.env.SAUCE_USER,
            sauceKey: process.env.SAUCE_API_KEY,
            baseUrl: 'http://<%=hostname %>:<%=port %>',
            params: {
              appUrl: '/',
              apiUrl: 'http://fakeapi.stormpath.com:1337'
            }
          }
        }
      }
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Test settings

    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      },
      liveunit: { // starts a karma server in the background
        configFile: 'karma.conf.js',
        background: true
      }
    },
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'bowerInstall',
      'concurrent:server',
      'autoprefixer',
      'connect:livereload',
      // 'karma:liveunit',  // disabled until karama test runner is fixed
      'watch'
    ]);
  });

  grunt.registerTask('server', function (target) {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', 'Build the project, assets are placed in dist/',
    [
      'clean:dist',
      'bowerInstall',
      'useminPrepare:dist',
      'concurrent:dist',
      'autoprefixer',
      'concat',
      'ngmin',
      'copy:dist',
      'cdnify',
      'cssmin',
      'uglify',
      // 'rev',
      'usemin'
      // 'htmlmin'
    ]
  );

  grunt.registerTask('build:debug', [
    'clean:dist',
    'bowerInstall',
    'useminPrepare:debug',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'usemin',
    'copy:debug'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);

  grunt.registerTask('dist',
    'Use this task to build a distro and copy it to the directoroy sepcified by --dist on the command line',
    function(){
      if(grunt.option('dest')){
        return grunt.task.run(['build','copy:dest']);
      }else{
        throw new Error('Must specify destination with --dest option');
      }
    }
  );
};
<|endoftext|>