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

    // Load Grunt tasks declared in the package.json file.
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // Project configuration.
    grunt.initConfig({

        /**
         * This will load in our package.json file so we can have access
         * to the project name and appVersion number.
         */
        pkg: grunt.file.readJSON('package.json'),

        /**
         * Constants for the Gruntfile so we can easily change the path for our environments.
         */
        BASE_PATH: '',
        DEVELOPMENT_PATH: 'src/',
        PRODUCTION_PATH: 'web/',

        /**
         * A code block that will be added to our minified code files.
         * Gets the name and appVersion and other info from the above loaded 'package.json' file.
         * @example <%= banner.join("\\n") %>
         */
        banner: [
                 '/*',
                 '* Project: <%= pkg.name %>',
                 '* Version: <%= pkg.appVersion %> (<%= grunt.template.today("yyyy-mm-dd") %>)',
                 '* Development By: <%= pkg.developedBy %>',
                 '* Copyright(c): <%= grunt.template.today("yyyy") %>',
                 '*/'
        ],

        /**
         * The different constant names that will be use to build our html files.
         * @example <!-- @if NODE_ENV == 'DEVELOPMENT' -->
         */
        env: {
            src: {
                NODE_ENV : 'DEVELOPMENT'
            },
            web : {
                NODE_ENV : 'PRODUCTION'
            }
        },

        /**
         * Allows us to pass in variables to files that have place holders so we can similar files with different data.
         * This plugin works with the 'env' plugin above.
         * @example <!-- @echo appVersion --> or <!-- @echo filePath -->
         */
        preprocess : {
            // Task to create the index.html file that will be used during development.
            // Passes the app version and creates the /index.html
            src : {
                src : '<%= DEVELOPMENT_PATH %>' + 'config.html',
                dest : '<%= DEVELOPMENT_PATH %>' + 'index.html',
                options : {
                    context : {
                        appVersion : '<%= pkg.appVersion %>',
                        filePath: ''
                    }
                }
            },
            // Task to create the index.html file that will be used in production.
            // Passes the app version and creates the /index.html
            web : {
                src : '<%= DEVELOPMENT_PATH %>' + 'config.html',
                dest : '<%= PRODUCTION_PATH %>' + 'index.html',
                options : {
                    context : {
                        appVersion : '<%= pkg.appVersion %>',
                        filePath: ''
                    }
                }
            }
        },

        /**
         * Cleans or deletes our production folder before we create a new production build.
         */
        clean: {
            dist: ['<%= PRODUCTION_PATH %>']
        },

        /**
         * Copies certain files over from the development folder to the production folder so we don't have to do it manually.
         */
        copy: {
            web:  {
                files: [
                    // Copy favicon.ico file from development to production
                    { expand: true, cwd: '<%= DEVELOPMENT_PATH %>', src: 'favicon.ico', dest: '<%= PRODUCTION_PATH %>' },
                    // Copy the media folder from development to production
                    { expand: true, cwd: '<%= DEVELOPMENT_PATH %>', src: ['assets/media/**'], dest: '<%= PRODUCTION_PATH %>' },
                    // Copy the index.html file from development to production
                    { expand: true, cwd: '<%= DEVELOPMENT_PATH %>', dest: '<%= PRODUCTION_PATH %>', src: ['index.html'], filter: 'isFile', dot: true }
                ]
            }
        },

        /**
         * Prepends the banner above to the minified files.
         */
        usebanner: {
            dist: {
                options: {
                    position: 'top',
                    banner: '<%= banner.join("\\n") %>',
                    linebreak: true
                },
                files: {
                    src: [
                        '<%= PRODUCTION_PATH %>' + 'assets/scripts/app.min.js',
                        '<%= PRODUCTION_PATH %>' + 'assets/styles/app.min.css'
                    ]
                }
            }
        },

        /**
         * Turns any JSON files into JavaScript files.
         */
        json: {
            web: {
                options: {
                    namespace: 'JSON_DATA',
                    includePath: false,
                    processName: function(filename) {
                        return filename.toLowerCase();
                    }
                },
                src: ['<%= DEVELOPMENT_PATH %>' + 'assets/data/**/*.json'],
                dest:  '<%= DEVELOPMENT_PATH %>' + 'assets/scripts/compiled/json.js'
            }
        },

        /**
         * Compiles the Handlebars templates into Javascript.
         * http://handlebarsjs.com/
         */
        handlebars: {
            compile: {
                options: {
                    namespace: 'JST',
                    // Registers all files that start with '_' as a partial.
                    partialRegex: /^_/,
                    // Shortens the file path for the templates.
                    processName: function(filename) {
                        return filename.slice(filename.indexOf("template"), filename.length);
                    },
                    // Shortens the file path for the partials.
                    processPartialName: function(filePath) {
                        return filePath.slice(filePath.indexOf("template"), filePath.length);
                    }
                },
                files: {
                    '<%= DEVELOPMENT_PATH %>assets/scripts/compiled/templates.tmpl.js': ['<%= DEVELOPMENT_PATH %>' + 'assets/templates/**/*.hbs']
                }
            }
        },

        /**
         * Compiles the TypeScript files into one JavaScript file.
         */
        typescript: {
            main: {
                src: ['<%= DEVELOPMENT_PATH %>' + 'assets/scripts/TestApp.ts'],
                dest: '<%= DEVELOPMENT_PATH %>' + 'assets/scripts/compiled/app.js',
                options: {
                    target: 'es3', //or es5
                    base_path: '',
                    sourcemap: true,
                    declaration: false,
                    nolib: false,
                    comments: false
                }
            }
        },

        /**
         * The useminPrepare part of the usemin plugin looks at the html file and checks for a build:js or build:css code block.
         * It will take those files found in the code block(s) and concat them together and then runs uglify for js and/or cssmin for css files.
         * useminPrepare requires grunt-contrib-uglify, grunt-contrib-concat, and grunt-contrib-cssmin plugins to be installed. Which is listed in the package.json file.
         *
         * The usemin part will remove the code block(s) and replace that area with the single file path in the html file.
         */
        useminPrepare: {
            html: ['<%= DEVELOPMENT_PATH %>' + 'index.html'],
            options: {
                dest: '<%= PRODUCTION_PATH %>'// Moves the single concatenated files to production.
            }
        },
        usemin: {
            html: ['<%= PRODUCTION_PATH %>' + 'index.html'],
            options: {
                dirs: ['<%= PRODUCTION_PATH %>']
            }
        },

        /**
         * Removes all comments from the production index.html file. I can also remove all whitespace if desired.
         */
        htmlmin: {
            dist: {
                options: {
                    removeComments: true,
                    collapseWhitespace: false
                },
                files: {
                    '<%= PRODUCTION_PATH %>index.html': '<%= PRODUCTION_PATH %>' + 'index.html'
                }
            }
        },

        /**
         * Creates a Cache Manifest file.
         */
        manifest: {
            generate: {
                options: {
                    basePath: '<%= PRODUCTION_PATH %>',
                    exclude: [
                        'assets/media/images/moblie-icons/icon-144x144.png',
                        'assets/media/images/moblie-icons/icon-100x100.png',
                        'assets/media/images/moblie-icons/icon-29x29.png',
                        'assets/media/images/moblie-icons/icon-50x50.png',
                        'assets/media/images/moblie-icons/icon-58x58.png',
                        'assets/media/images/moblie-icons/icon-72x72.png'
                    ],
                    preferOnline: false,
                    verbose: true,
                    timestamp: true,
                    master: []
                },
                src: [
                    'assets/data/**/*.json',
                    'assets/media/images/**/*.jpg',
                    'assets/media/images/**/*.png',
                    'assets/scripts/**/*.js',
                    'assets/styles/**/*.css'
                ],
                dest: '<%= PRODUCTION_PATH %>' + 'offline.appcache'
            }
        },

        /**
         * YUIDoc plugin that will generate documentation from our YUI comments.
         */
        yuidoc: {
            compile: {
                name: '<%= pkg.name %>',
                description: '<%= pkg.description %>',
                version: '<%= pkg.appVersion %>',
                url: '<%= pkg.homepage %>',
                options: {
                    paths: '<%= DEVELOPMENT_PATH %>' + 'assets/scripts/',
                    outdir: '<%= BASE_PATH %>docs',
                    themedir: '',
                    extension: '.ts',                                   // Default '.js' <comma-separated list of file extensions>
                    exclude: ''
                }
            }
        },

        /**
         * Creates a node.js Express Server to test our code in a server like environment.
         * Note: We are using the watch task to keep the server running.
         */
        express: {
            src: {
                options: {
                    port: 8000,
                    hostname: "0.0.0.0",
                    bases: ['<%= DEVELOPMENT_PATH %>'],
                    livereload: true
                }
            },
            web: {
                options: {
                    port: 8001,
                    hostname: "0.0.0.1",
                    bases: ['<%= PRODUCTION_PATH %>'],
                    livereload: true
                }
            }
        },

        /**
         * Opens the index.html file in the default browser after the node.js Express Server is running.
         */
        open: {
            src: {
                // Gets the port from the connect configuration
                path: 'http://localhost:<%= express.src.options.port%>'
            },
            web: {
                // Gets the port from the connect configuration
                path: 'http://localhost:<%= express.web.options.port%>'
            }
        },

        /**
         * Watches files and will run task(s) when files are changed. It will also reload/refresh the browser.
         */
        watch: {
            css: {
                options: {
                    livereload: true
                },
                files: [
                    '<%= DEVELOPMENT_PATH %>' + 'assets/styles/**/*.css',
                ]
            },
            src: {
                options: {
                    livereload: true
                },
                files: [
                    '<%= DEVELOPMENT_PATH %>' + 'assets/scripts/**/*.ts',
                    '<%= DEVELOPMENT_PATH %>' + 'config.html',
                    '<%= DEVELOPMENT_PATH %>' + 'assets/templates/**/*.hbs'
                ],
                tasks: ['src']
            }
        }

    });

    /**
     * Grunt tasks:
     *
     * grunt        (Will build and run your development code/server)
     * grunt web    (Will build and run your production code/server)
     * grunt doc    (Will generate the YUI documentation from the code comments)
     */
    grunt.registerTask('default', [
        'server'
    ]);

    grunt.registerTask('server', [
        'src',
        'express:src',
        'open:src',
        'watch'
    ]);

    grunt.registerTask('src', [
        'env:src',
        'preprocess:src',
        'json',
        'handlebars',
        'typescript'
    ]);

    grunt.registerTask('web', [
        'env:web',
        'preprocess',
        'json',
        'handlebars',
        'typescript',
        'clean',
        'copy',
        'useminPrepare', 'concat', 'uglify', 'cssmin',
        'usemin',
        'usebanner',
        'htmlmin',
        'manifest',
        'open:web',
        'express:web',
        'express-keepalive'
    ]);

    grunt.registerTask('doc', [
        'yuidoc'
    ]);

};<commit_msg>Make clean delete the .tmp folder.<commit_after>module.exports = function(grunt) {

    // Load Grunt tasks declared in the package.json file.
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // Project configuration.
    grunt.initConfig({

        /**
         * This will load in our package.json file so we can have access
         * to the project name and appVersion number.
         */
        pkg: grunt.file.readJSON('package.json'),

        /**
         * Constants for the Gruntfile so we can easily change the path for our environments.
         */
        BASE_PATH: '',
        DEVELOPMENT_PATH: 'src/',
        PRODUCTION_PATH: 'web/',

        /**
         * A code block that will be added to our minified code files.
         * Gets the name and appVersion and other info from the above loaded 'package.json' file.
         * @example <%= banner.join("\\n") %>
         */
        banner: [
                 '/*',
                 '* Project: <%= pkg.name %>',
                 '* Version: <%= pkg.appVersion %> (<%= grunt.template.today("yyyy-mm-dd") %>)',
                 '* Development By: <%= pkg.developedBy %>',
                 '* Copyright(c): <%= grunt.template.today("yyyy") %>',
                 '*/'
        ],

        /**
         * The different constant names that will be use to build our html files.
         * @example <!-- @if NODE_ENV == 'DEVELOPMENT' -->
         */
        env: {
            src: {
                NODE_ENV : 'DEVELOPMENT'
            },
            web : {
                NODE_ENV : 'PRODUCTION'
            }
        },

        /**
         * Allows us to pass in variables to files that have place holders so we can similar files with different data.
         * This plugin works with the 'env' plugin above.
         * @example <!-- @echo appVersion --> or <!-- @echo filePath -->
         */
        preprocess : {
            // Task to create the index.html file that will be used during development.
            // Passes the app version and creates the /index.html
            src : {
                src : '<%= DEVELOPMENT_PATH %>' + 'config.html',
                dest : '<%= DEVELOPMENT_PATH %>' + 'index.html',
                options : {
                    context : {
                        appVersion : '<%= pkg.appVersion %>',
                        filePath: ''
                    }
                }
            },
            // Task to create the index.html file that will be used in production.
            // Passes the app version and creates the /index.html
            web : {
                src : '<%= DEVELOPMENT_PATH %>' + 'config.html',
                dest : '<%= PRODUCTION_PATH %>' + 'index.html',
                options : {
                    context : {
                        appVersion : '<%= pkg.appVersion %>',
                        filePath: ''
                    }
                }
            }
        },

        /**
         * Cleans or deletes our production folder before we create a new production build.
         */
        clean: {
            web: ['<%= PRODUCTION_PATH %>'],
            temp: ['.tmp']
        },

        /**
         * Copies certain files over from the development folder to the production folder so we don't have to do it manually.
         */
        copy: {
            web:  {
                files: [
                    // Copy favicon.ico file from development to production
                    { expand: true, cwd: '<%= DEVELOPMENT_PATH %>', src: 'favicon.ico', dest: '<%= PRODUCTION_PATH %>' },
                    // Copy the media folder from development to production
                    { expand: true, cwd: '<%= DEVELOPMENT_PATH %>', src: ['assets/media/**'], dest: '<%= PRODUCTION_PATH %>' },
                    // Copy the index.html file from development to production
                    { expand: true, cwd: '<%= DEVELOPMENT_PATH %>', dest: '<%= PRODUCTION_PATH %>', src: ['index.html'], filter: 'isFile', dot: true }
                ]
            }
        },

        /**
         * Prepends the banner above to the minified files.
         */
        usebanner: {
            dist: {
                options: {
                    position: 'top',
                    banner: '<%= banner.join("\\n") %>',
                    linebreak: true
                },
                files: {
                    src: [
                        '<%= PRODUCTION_PATH %>' + 'assets/scripts/app.min.js',
                        '<%= PRODUCTION_PATH %>' + 'assets/styles/app.min.css'
                    ]
                }
            }
        },

        /**
         * Turns any JSON files into JavaScript files.
         */
        json: {
            web: {
                options: {
                    namespace: 'JSON_DATA',
                    includePath: false,
                    processName: function(filename) {
                        return filename.toLowerCase();
                    }
                },
                src: ['<%= DEVELOPMENT_PATH %>' + 'assets/data/**/*.json'],
                dest:  '<%= DEVELOPMENT_PATH %>' + 'assets/scripts/compiled/json.js'
            }
        },

        /**
         * Compiles the Handlebars templates into Javascript.
         * http://handlebarsjs.com/
         */
        handlebars: {
            compile: {
                options: {
                    namespace: 'JST',
                    // Registers all files that start with '_' as a partial.
                    partialRegex: /^_/,
                    // Shortens the file path for the templates.
                    processName: function(filename) {
                        return filename.slice(filename.indexOf("template"), filename.length);
                    },
                    // Shortens the file path for the partials.
                    processPartialName: function(filePath) {
                        return filePath.slice(filePath.indexOf("template"), filePath.length);
                    }
                },
                files: {
                    '<%= DEVELOPMENT_PATH %>assets/scripts/compiled/templates.tmpl.js': ['<%= DEVELOPMENT_PATH %>' + 'assets/templates/**/*.hbs']
                }
            }
        },

        /**
         * Compiles the TypeScript files into one JavaScript file.
         */
        typescript: {
            main: {
                src: ['<%= DEVELOPMENT_PATH %>' + 'assets/scripts/TestApp.ts'],
                dest: '<%= DEVELOPMENT_PATH %>' + 'assets/scripts/compiled/app.js',
                options: {
                    target: 'es3', //or es5
                    base_path: '',
                    sourcemap: true,
                    declaration: false,
                    nolib: false,
                    comments: false
                }
            }
        },

        /**
         * The useminPrepare part of the usemin plugin looks at the html file and checks for a build:js or build:css code block.
         * It will take those files found in the code block(s) and concat them together and then runs uglify for js and/or cssmin for css files.
         * useminPrepare requires grunt-contrib-uglify, grunt-contrib-concat, and grunt-contrib-cssmin plugins to be installed. Which is listed in the package.json file.
         *
         * The usemin part will remove the code block(s) and replace that area with the single file path in the html file.
         */
        useminPrepare: {
            html: ['<%= DEVELOPMENT_PATH %>' + 'index.html'],
            options: {
                dest: '<%= PRODUCTION_PATH %>'// Moves the single concatenated files to production.
            }
        },
        usemin: {
            html: ['<%= PRODUCTION_PATH %>' + 'index.html'],
            options: {
                dirs: ['<%= PRODUCTION_PATH %>']
            }
        },

        /**
         * Removes all comments from the production index.html file. I can also remove all whitespace if desired.
         */
        htmlmin: {
            dist: {
                options: {
                    removeComments: true,
                    collapseWhitespace: false
                },
                files: {
                    '<%= PRODUCTION_PATH %>index.html': '<%= PRODUCTION_PATH %>' + 'index.html'
                }
            }
        },

        /**
         * Creates a Cache Manifest file.
         */
        manifest: {
            generate: {
                options: {
                    basePath: '<%= PRODUCTION_PATH %>',
                    exclude: [
                        'assets/media/images/moblie-icons/icon-144x144.png',
                        'assets/media/images/moblie-icons/icon-100x100.png',
                        'assets/media/images/moblie-icons/icon-29x29.png',
                        'assets/media/images/moblie-icons/icon-50x50.png',
                        'assets/media/images/moblie-icons/icon-58x58.png',
                        'assets/media/images/moblie-icons/icon-72x72.png'
                    ],
                    preferOnline: false,
                    verbose: true,
                    timestamp: true,
                    master: []
                },
                src: [
                    'assets/data/**/*.json',
                    'assets/media/images/**/*.jpg',
                    'assets/media/images/**/*.png',
                    'assets/scripts/**/*.js',
                    'assets/styles/**/*.css'
                ],
                dest: '<%= PRODUCTION_PATH %>' + 'offline.appcache'
            }
        },

        /**
         * YUIDoc plugin that will generate documentation from our YUI comments.
         */
        yuidoc: {
            compile: {
                name: '<%= pkg.name %>',
                description: '<%= pkg.description %>',
                version: '<%= pkg.appVersion %>',
                url: '<%= pkg.homepage %>',
                options: {
                    paths: '<%= DEVELOPMENT_PATH %>' + 'assets/scripts/',
                    outdir: '<%= BASE_PATH %>docs',
                    themedir: '',
                    extension: '.ts',                                   // Default '.js' <comma-separated list of file extensions>
                    exclude: ''
                }
            }
        },

        /**
         * Creates a node.js Express Server to test our code in a server like environment.
         * Note: We are using the watch task to keep the server running.
         */
        express: {
            src: {
                options: {
                    port: 8000,
                    hostname: "0.0.0.0",
                    bases: ['<%= DEVELOPMENT_PATH %>'],
                    livereload: true
                }
            },
            web: {
                options: {
                    port: 8001,
                    hostname: "0.0.0.1",
                    bases: ['<%= PRODUCTION_PATH %>'],
                    livereload: true
                }
            }
        },

        /**
         * Opens the index.html file in the default browser after the node.js Express Server is running.
         */
        open: {
            src: {
                // Gets the port from the connect configuration
                path: 'http://localhost:<%= express.src.options.port%>'
            },
            web: {
                // Gets the port from the connect configuration
                path: 'http://localhost:<%= express.web.options.port%>'
            }
        },

        /**
         * Watches files and will run task(s) when files are changed. It will also reload/refresh the browser.
         */
        watch: {
            css: {
                options: {
                    livereload: true
                },
                files: [
                    '<%= DEVELOPMENT_PATH %>' + 'assets/styles/**/*.css',
                ]
            },
            src: {
                options: {
                    livereload: true
                },
                files: [
                    '<%= DEVELOPMENT_PATH %>' + 'assets/scripts/**/*.ts',
                    '<%= DEVELOPMENT_PATH %>' + 'config.html',
                    '<%= DEVELOPMENT_PATH %>' + 'assets/templates/**/*.hbs'
                ],
                tasks: ['src']
            }
        }

    });

    /**
     * Grunt tasks:
     *
     * grunt        (Will build and run your development code/server)
     * grunt web    (Will build and run your production code/server)
     * grunt doc    (Will generate the YUI documentation from the code comments)
     */
    grunt.registerTask('default', [
        'server'
    ]);

    grunt.registerTask('server', [
        'src',
        'express:src',
        'open:src',
        'watch'
    ]);

    grunt.registerTask('src', [
        'env:src',
        'preprocess:src',
        'json',
        'handlebars',
        'typescript'
    ]);

    grunt.registerTask('web', [
        'env:web',
        'preprocess',
        'json',
        'handlebars',
        'typescript',
        'clean',
        'copy',
        'useminPrepare', 'concat', 'uglify', 'cssmin',
        'usemin',
        'usebanner',
        'htmlmin',
        'manifest',
        'open:web',
        'express:web',
        'express-keepalive'
    ]);

    grunt.registerTask('doc', [
        'yuidoc'
    ]);

};<|endoftext|>


<commit_before>import color from './color';

var Empty = [];

export default function(context, item, opacity) {
  var lw = (lw = item.strokeWidth) != null ? lw : 1,
      lc, lj, ml;

  if (lw <= 0) return false;

  opacity *= (item.strokeOpacity==null ? 1 : item.strokeOpacity);
  if (opacity > 0) {
    context.globalAlpha = opacity;
    context.strokeStyle = color(context, item, item.stroke);

    context.lineWidth = lw;
    context.lineCap = item.strokeCap || 'butt';
    context.lineJoin = item.strokeJoin || 'miter';
    context.miterLimit = item.strokeMiterLimit || 10;

    if (context.setLineDash) {
      context.setLineDash(item.strokeDash || Empty);
      context.lineDashOffset = item.strokeDashOffset || 0;
    }
    return true;
  } else {
    return false;
  }
}
<commit_msg>Code clean up.<commit_after>import color from './color';

var Empty = [];

export default function(context, item, opacity) {
  var lw = (lw = item.strokeWidth) != null ? lw : 1;

  if (lw <= 0) return false;

  opacity *= (item.strokeOpacity==null ? 1 : item.strokeOpacity);
  if (opacity > 0) {
    context.globalAlpha = opacity;
    context.strokeStyle = color(context, item, item.stroke);

    context.lineWidth = lw;
    context.lineCap = item.strokeCap || 'butt';
    context.lineJoin = item.strokeJoin || 'miter';
    context.miterLimit = item.strokeMiterLimit || 10;

    if (context.setLineDash) {
      context.setLineDash(item.strokeDash || Empty);
      context.lineDashOffset = item.strokeDashOffset || 0;
    }
    return true;
  } else {
    return false;
  }
}
<|endoftext|>


<commit_before>/*
 * grunt-dps
 * https://github.com/SixDimensions/grunt-dps
 *
 * Copyright (c) 2015 Charlie Wagner
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc'
      }
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      tests: ['tmp']
    },

    // Configuration to be run (and then tested).
    dps: {
      options: {
        config: {
          "publication_id": "cd9463b5-a779-4a32-b488-462ffa1cf17a",
          "device_id": "***REMOVED***",
          "device_secret": "***REMOVED***",
          "client_id": "***REMOVED***",
          "client_secret": "***REMOVED***",
          "access_token": "***REMOVED***",
          "refresh_token": "***REMOVED***",
          "expires_in": 86399986,
          "token_time": 1442850671114
        }
      },
      main: {
        options: {
          /*putArticle: {
            entityName: 'completelynew',
            title: 'what??'
          },
          putArticleImage: {
            entityName: 'completelynew',
            imagePath: 'creativecloud_small.png'
          },
          uploadArticle: {
            entityName: 'completelynew',
            articlePath: 'login.article'
          },*/
          addArticleToCollection: {
            articleName: 'completelynew',
            collectionName: 'Itineraries'
          },
          publish: {
            entities: [
              "article/completelynew",
              "collection/Itineraries"
            ]
          }
        }
      }
    },

    // Unit tests.
    nodeunit: {
      tests: ['test/*_test.js']
    }

  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['clean', 'dps', 'nodeunit']);

  // By default, lint and run all tests.
  grunt.registerTask('default', ['jshint', 'test']);

};
<commit_msg>removing the test oauth credentials<commit_after>/*
 * grunt-dps
 * https://github.com/SixDimensions/grunt-dps
 *
 * Copyright (c) 2015 Charlie Wagner
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    jshint: {
      all: [
        'Gruntfile.js',
        'tasks/*.js',
        '<%= nodeunit.tests %>'
      ],
      options: {
        jshintrc: '.jshintrc'
      }
    },

    // Before generating any new files, remove any previously-created files.
    clean: {
      tests: ['tmp']
    },

    // Configuration to be run (and then tested).
    dps: {
      options: {
        config: {

        }
      },
      main: {
        options: {
          /*putArticle: {
            entityName: 'completelynew',
            title: 'what??'
          },
          putArticleImage: {
            entityName: 'completelynew',
            imagePath: 'creativecloud_small.png'
          },
          uploadArticle: {
            entityName: 'completelynew',
            articlePath: 'login.article'
          },*/
          addArticleToCollection: {
            articleName: 'completelynew',
            collectionName: 'Itineraries'
          },
          publish: {
            entities: [
              "article/completelynew",
              "collection/Itineraries"
            ]
          }
        }
      }
    },

    // Unit tests.
    nodeunit: {
      tests: ['test/*_test.js']
    }

  });

  // Actually load this plugin's task(s).
  grunt.loadTasks('tasks');

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-nodeunit');

  // Whenever the "test" task is run, first clean the "tmp" dir, then run this
  // plugin's task(s), then test the result.
  grunt.registerTask('test', ['clean', 'dps', 'nodeunit']);

  // By default, lint and run all tests.
  grunt.registerTask('default', ['jshint', 'test']);

};
<|endoftext|>


<commit_before>/* global module */

var bs = require('browser-sync');

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

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    bwr: grunt.file.readJSON('bower.json'),
    project: {
      src: './src',
      dist: './dist',
      index: '<%= project.dist %>/index.html',
      assets: '<%= project.dist %>/assets',
      components: 'bower_components',
      banner: '/*!\n' +
      ' * <%= pkg.title %> v<%= pkg.version %> (<%= grunt.template.today("dd.mm.yyyy") %>)\n' +
      ' * Copyright by <%= pkg.author %>\n' +
      ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
      ' */\n'
    },

    clean: {
      options: {
        force: true
      },
      dist: {
        src: ['<%= project.dist %>']
      }
    },

    sass: {
      dist: {
        options: {
          noLineComments: false,
          relativeAssets: true,
          sourceMap: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.src %>/styles',
            dest: '<%= project.assets %>/styles',
            src: '**/*.{scss,sass}',
            ext: '.css'
          }
        ]
      }
    },

    wiredep: {
      html: {
        src: '<%= project.index %>',
        exclude: ['<%= project.components %>/bootstrap/dist/css/bootstrap.css', '<%= project.components %>/bootstrap/dist/js/bootstrap.js', '<%= project.components %>/modernizr/modernizr.js']
      },
      scss: {
        src: '<%= project.src %>/styles/main.scss'
      }
    },

    modernizr: {
      dist: {
        options: {
          preserveComments: false
        },
        uglify: true,
        devFile: '<%= project.components %>/modernizr/modernizr.js',
        outputFile: '<%= project.assets %>/scripts/modernizr.custom.min.js',
        extra: {
          shiv: true,
          printshiv: true,
          load: true,
          mq: false,
          cssclasses: true
        },
        extensibility: {
          addtest: false,
          prefixed: true,
          teststyles: false,
          testprops: false,
          testallprops: false,
          hasevents: false,
          prefixes: true,
          domprefixes: true
        }
      }
    },

    jshint: {
      options: {
        jshintrc: '<%= project.src %>/scripts/.jshintrc'
      },
      dist: ['Gruntfile.js', '<%= project.src %>/scripts/**/*.js', '!<%= project.src %>/scripts/vendor/**/*.js']
    },

    jscs: {
      options: {
        config: '<%= project.src %>/scripts/.jscsrc'
      },
      dist: {
        src: ['<%= project.src %>/scripts/**/*.js', '!<%= project.src %>/scripts/vendor/**/*.js']
      }
    },

    ngAnnotate: {
      dist: {
        options: {
          sourceMap: false,
          singleQuotes: true
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.src %>/scripts',
            src: ['*.js', '!*.min.js'],
            dest: '<%= project.assets %>/scripts'
          }
        ]
      }
    },

    uglify: {
      dist: {
        options: {
          sourceMap: false,
          preserveComments: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/scripts',
            src: ['*.js', '!*.min.js'],
            dest: '<%= project.assets %>/scripts',
            ext: '.min.js'
          }
        ]
      }
    },

    autoprefixer: {
      options: {
        browsers: ['Android 2.3', 'Android >= 4', 'Chrome >= 20', 'Firefox >= 24', 'Explorer >= 8', 'iOS >= 6', 'Opera >= 12', 'Safari >= 6']
      },
      dist: {
        options: {
          map: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    csslint: {
      options: {
        csslintrc: '<%= project.src %>/styles/.csslintrc'
      },
      dist: {
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css', '!bootstrap.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    cssmin: {
      dist: {
        options: {
          sourceMap: false,
          compatibility: 'ie8',
          keepSpecialComments: '*',
          advanced: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles',
            ext: '.min.css'
          }
        ]
      }
    },

    usebanner: {
      options: {
        position: 'top',
        banner: '<%= project.banner %>'
      },
      css: {
        files: {
          src: ['<%= project.assets %>/styles/main.css', '<%= project.assets %>/styles/main.min.css']
        }
      },
      js: {
        files: {
          src: ['<%= project.assets %>/scripts/main.js', '<%= project.assets %>/scripts/main.min.js']
        }
      }
    },

    csscomb: {
      options: {
        config: '<%= project.src %>/styles/.csscomb.json'
      },
      dist: {
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    copy: {
      fonts: {
        expand: true,
        cwd: '<%= project.src %>/fonts',
        src: '*',
        dest: '<%= project.assets %>/fonts'
      },
      vendor: {
        expand: true,
        cwd: '<%= project.src %>/scripts/vendor',
        src: '*',
        dest: '<%= project.assets %>/scripts/vendor'
      },
      svg: {
        expand: true,
        cwd: '<%= project.src %>/images',
        src: ['**/*.svg'],
        dest: '<%= project.assets %>/images'
      }
    },

    jade: {
      options: {
        pretty: true
      },
      dist: {
        expand: true,
        cwd: '<%= project.src %>/templates',
        src: ['**/*.jade', '!**/_*.jade'],
        dest: '<%= project.dist %>',
        ext: '.html'
      }
    },

    useminPrepare: {
      options: {
        dest: '<%= project.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      },
      html: '<%= project.index %>'
    },

    usemin: {
      options: {
        assetsDirs: ['<%= project.components %>']
      },
      html: '<%= project.index %>',
      css: ['<%= project.assets %>/styles/**/*.css']
    },

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

    uncss: {
      bootstrap: {
        options: {
          stylesheets: ['../<%= project.components %>/bootstrap/dist/css/bootstrap.css'],
          ignore: []
        },
        files: {
          '<%= project.assets %>/styles/bootstrap.css': ['<%= project.index %>']
        }
      }
    },

    watch: {
      options: {
        spawn: false
      },
      scripts: {
        files: '<%= project.src %>/scripts/**/*.js',
        tasks: ['ngAnnotate', 'uglify:dist', 'usebanner:js', 'bs-inject']
      },
      styles: {
        files: '<%= project.src %>/styles/**/*.{scss,sass}',
        tasks: ['newer:imagemin', 'newer:copy', 'sass', 'csscomb', 'autoprefixer', 'cssmin:dist', 'usebanner:css', 'bs-inject']
      },
      templates: {
        files: '<%= project.src %>/templates/**/*.jade',
        tasks: ['newer:imagemin', 'newer:copy', 'jade', 'uncss', 'wiredep', 'useminPrepare', 'usemin', 'ngAnnotate', 'uglify:dist', 'csscomb', 'cssmin:dist', 'usebanner:css', 'bs-inject']
      },
      images: {
        files: '<%= project.src %>/images',
        tasks: ['newer:imagemin', 'newer:copy', 'bs-inject']
      }
    }
  });

  require('time-grunt')(grunt);

  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    usebanner: 'grunt-banner'
  });

  grunt.registerTask('bs-init', 'Start BrowserSync Server', function () {
    var done;
    done = this.async();
    bs({
      server: './dist',
      notify: false,
      ghostMode: false
    }, function () {
      done();
    });
  });

  grunt.registerTask('bs-inject', 'Reload Files in Browser', function () {
    return bs.reload();
  });

  grunt.registerTask('default', ['build', 'lint', 'serve']);

  grunt.registerTask('lint', ['jshint', 'jscs', 'csslint']);

  grunt.registerTask('serve', ['bs-init', 'watch']);

  grunt.registerTask('build', ['clean', 'imagemin', 'copy', 'jade', 'uncss', 'wiredep', 'useminPrepare', 'sass', 'modernizr', 'autoprefixer', 'cssmin:generated', 'ngAnnotate', 'concat:generated', 'uglify:generated', 'usemin', 'uglify:dist', 'csscomb', 'cssmin:dist', 'usebanner']);
};
<commit_msg>Improved the Grunt-build<commit_after>/* global module */

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

  var bs = require('browser-sync');

  require('time-grunt')(grunt);

  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    usebanner: 'grunt-banner'
  });

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    bwr: grunt.file.readJSON('bower.json'),
    project: {
      src: './src',
      dist: './dist',
      index: '<%= project.dist %>/index.html',
      assets: '<%= project.dist %>/assets',
      components: 'bower_components',
      banner: '/*!\n' +
      ' * <%= pkg.title %> v<%= pkg.version %> (<%= grunt.template.today("dd.mm.yyyy") %>)\n' +
      ' * Copyright by <%= pkg.author %>\n' +
      ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
      ' */\n'
    },

    clean: {
      options: {
        force: true
      },
      dist: {
        src: ['<%= project.dist %>']
      }
    },

    sass: {
      dist: {
        options: {
          noLineComments: false,
          relativeAssets: true,
          sourceMap: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.src %>/styles',
            dest: '<%= project.assets %>/styles',
            src: '**/*.{scss,sass}',
            ext: '.css'
          }
        ]
      }
    },

    wiredep: {
      html: {
        src: '<%= project.index %>',
        exclude: ['<%= project.components %>/bootstrap-sass-official/assets/javascripts/bootstrap.js', '<%= project.components %>/modernizr/modernizr.js']
      },
      scss: {
        src: '<%= project.src %>/styles/**/*.{scss,sass}'
      }
    },

    modernizr: {
      dist: {
        options: {
          preserveComments: false
        },
        uglify: true,
        devFile: '<%= project.components %>/modernizr/modernizr.js',
        outputFile: '<%= project.assets %>/scripts/modernizr.custom.min.js',
        extra: {
          shiv: true,
          printshiv: true,
          load: true,
          mq: false,
          cssclasses: true
        },
        extensibility: {
          addtest: false,
          prefixed: true,
          teststyles: false,
          testprops: false,
          testallprops: false,
          hasevents: false,
          prefixes: true,
          domprefixes: true
        }
      }
    },

    jshint: {
      options: {
        jshintrc: '<%= project.src %>/scripts/.jshintrc'
      },
      dist: ['Gruntfile.js', '<%= project.src %>/scripts/**/*.js', '!<%= project.src %>/scripts/vendor/**/*.js']
    },

    jscs: {
      options: {
        config: '<%= project.src %>/scripts/.jscsrc'
      },
      dist: {
        src: ['<%= project.src %>/scripts/**/*.js', '!<%= project.src %>/scripts/vendor/**/*.js']
      }
    },

    ngAnnotate: {
      dist: {
        options: {
          sourceMap: false,
          singleQuotes: true
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.src %>/scripts',
            src: ['*.js', '!*.min.js'],
            dest: '<%= project.assets %>/scripts'
          }
        ]
      }
    },

    uglify: {
      dist: {
        options: {
          sourceMap: false,
          preserveComments: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/scripts',
            src: ['*.js', '!*.min.js'],
            dest: '<%= project.assets %>/scripts',
            ext: '.min.js'
          }
        ]
      }
    },

    autoprefixer: {
      options: {
        browsers: ['Android 2.3', 'Android >= 4', 'Chrome >= 20', 'Firefox >= 24', 'Explorer >= 8', 'iOS >= 6', 'Opera >= 12', 'Safari >= 6']
      },
      dist: {
        options: {
          map: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    csslint: {
      options: {
        csslintrc: '<%= project.src %>/styles/.csslintrc'
      },
      dist: {
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css', '!bootstrap.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    cssmin: {
      dist: {
        options: {
          sourceMap: false,
          compatibility: 'ie8',
          keepSpecialComments: '*',
          advanced: false
        },
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles',
            ext: '.min.css'
          }
        ]
      }
    },

    usebanner: {
      options: {
        position: 'top',
        banner: '<%= project.banner %>'
      },
      css: {
        files: {
          src: ['<%= project.assets %>/styles/main.css', '<%= project.assets %>/styles/main.min.css']
        }
      },
      js: {
        files: {
          src: ['<%= project.assets %>/scripts/main.js', '<%= project.assets %>/scripts/main.min.js']
        }
      }
    },

    csscomb: {
      options: {
        config: '<%= project.src %>/styles/.csscomb.json'
      },
      dist: {
        files: [
          {
            expand: true,
            cwd: '<%= project.assets %>/styles',
            src: ['*.css', '!*.min.css'],
            dest: '<%= project.assets %>/styles'
          }
        ]
      }
    },

    copy: {
      fonts: {
        expand: true,
        cwd: '<%= project.src %>/fonts',
        src: '*',
        dest: '<%= project.assets %>/fonts'
      },
      vendor: {
        expand: true,
        cwd: '<%= project.src %>/scripts/vendor',
        src: '*',
        dest: '<%= project.assets %>/scripts/vendor'
      },
      svg: {
        expand: true,
        cwd: '<%= project.src %>/images',
        src: ['**/*.svg'],
        dest: '<%= project.assets %>/images'
      },
      glyphicons: {
        expand: true,
        cwd: '<%= project.vendor %>/bootstrap-sass-official/assets/fonts/bootstrap/*',
        src: '*',
        dest: '<%= project.assets %>/fonts'
      }
    },

    jade: {
      options: {
        pretty: true
      },
      dist: {
        expand: true,
        cwd: '<%= project.src %>/templates',
        src: ['**/*.jade', '!**/_*.jade'],
        dest: '<%= project.dist %>',
        ext: '.html'
      }
    },

    useminPrepare: {
      options: {
        dest: '<%= project.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      },
      html: '<%= project.index %>'
    },

    usemin: {
      options: {
        assetsDirs: ['<%= project.components %>']
      },
      html: '<%= project.index %>',
      css: ['<%= project.assets %>/styles/**/*.css']
    },

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

    uncss: {
      dist: {
        options: {
          stylesheets: ['../<%= project.assets %>/styles/main.css']
        },
        files: {
          '<%= project.assets %>/styles/main.css': ['<%= project.dist %>/**/*.html']
        }
      }
    },

    watch: {
      options: {
        spawn: false
      },
      scripts: {
        files: '<%= project.src %>/scripts/**/*.js',
        tasks: ['ngAnnotate', 'uglify:dist', 'usebanner:js', 'bs-inject']
      },
      styles: {
        files: '<%= project.src %>/styles/**/*.{scss,sass}',
        tasks: ['newer:imagemin', 'newer:copy', 'sass', 'uncss', 'csscomb', 'autoprefixer', 'cssmin:dist', 'usebanner:css', 'bs-inject']
      },
      templates: {
        files: '<%= project.src %>/templates/**/*.jade',
        tasks: ['newer:imagemin', 'newer:copy', 'jade', 'wiredep', 'useminPrepare', 'usemin', 'ngAnnotate', 'uglify:dist', 'csscomb', 'cssmin:dist', 'usebanner:css', 'bs-inject']
      },
      images: {
        files: '<%= project.src %>/images',
        tasks: ['newer:imagemin', 'newer:copy', 'bs-inject']
      }
    }
  });

  grunt.registerTask('bs-init', 'Start BrowserSync Server', function () {
    var done = this.async();

    bs({
      server: './dist',
      notify: false,
      ghostMode: false
    }, function () {
      done();
    });
  });

  grunt.registerTask('bs-inject', 'Reload Files in Browser', function () {
    return bs.reload();
  });

  grunt.registerTask('default', ['lint', 'build', 'serve']);

  grunt.registerTask('lint', ['jshint', 'jscs', 'csslint']);

  grunt.registerTask('serve', ['bs-init', 'watch']);

  grunt.registerTask('build', ['clean', 'imagemin', 'copy', 'jade', 'wiredep', 'useminPrepare', 'sass', 'uncss', 'modernizr', 'autoprefixer', 'cssmin:generated', 'ngAnnotate', 'concat:generated', 'uglify:generated', 'usemin', 'uglify:dist', 'csscomb', 'cssmin:dist', 'usebanner']);
};
<|endoftext|>


<commit_before>import parser from 'minimist'
import pkginfo from 'pkginfo'
import camelcase from 'camelcase'
import path from 'path'
import { spawn } from 'child_process'

class Args {
  constructor() {
    this.details = {
      options: [],
      commands: []
    }

    this.config = {
      help: true,
      version: true,
      errors: true
    }

    this.option('help', 'Output usage information')
    this.command('help', 'Display help')
  }

  option (name, description, init, defaultValue) {
    let usage = []

    switch (name.constructor) {
      case String:
        usage[0] = name.charAt(0)
        usage[1] = name

        break
      case Array:
        usage = usage.concat(name)
        break
      default:
        throw new Error('Invalid name for option')
    }

    if (usage.length > 0 && usage[0].length > 1) {
      throw new Error('Short version of option is longer than 1 char')
    }

    let optionDetails = {
      defaultValue,
      usage,
      description
    }

    if (defaultValue) {
      let initFunction = typeof init === 'function'
      optionDetails.init = initFunction ? init : this.handleType(defaultValue)[1]
    }

    this.details.options.push(optionDetails)
    return this
  }

  command (usage, description) {
    this.details.commands.push({
      usage,
      description
    })

    return this
  }

  handleType (value) {
    const type = value.constructor

    switch (type) {
      case String:
        return ['[value]', toString]
        break
      case Array:
        return ['<list>']
        break
      case Number:
        return ['<n>', parseInt]
        break
      default:
        return false
    }
  }

  readOption (option) {
    let value = false,
        contents = {}

    for (let name of option.usage) {
      let fromArgs = this.raw[name]

      if (fromArgs) {
        value = fromArgs
      }
    }

    for (let name of option.usage) {
      let propVal = value || option.defaultValue,
          condition = true

      if (option.init) {
        if (option.init === toString) {
          condition = propVal.constructor === Number
        }

        if (condition) {
          propVal = option.init(propVal)
        }
      }

      name = camelcase(name)
      if (propVal) contents[name] = propVal
    }

    return contents
  }

  getOptions () {
    let args = this.raw,
        options = {}

    delete args._

    for (let option in args) {
      let related = this.isDefined(option, 'options')

      if (related) {
        let details = this.readOption(related)
        Object.assign(options, details)
      } else if (this.config.errors) {
        console.error(`Option "${option}" not known`)
      }
    }

    for (let option in options) {
      this[option] = options[option]
    }

    return options
  }

  generateDetails (kind) {
    const items = this.details[kind]
    let parts = []

    for (let item in items) {
      let usage = items[item].usage,
          initial = items[item].defaultValue

      if (usage.constructor === Array) {
        usage = `-${usage[0]}, --${usage[1]}`
        usage += initial ? ' ' + this.handleType(initial)[0] : ''
      }

      items[item].usage = usage
    }

    const longest = items.sort((a, b) => {
      return b.usage.length - a.usage.length
    })[0].usage.length

    for (let item of items) {
      let usage = item.usage,
          difference = longest - usage.length

      usage += ' '.repeat(difference)
      parts.push('  ' + usage + '  ' + item.description)
    }

    return parts
  }

  runCommand (name) {
    if (this.config.help && name === 'help') {
      this.showHelp()
      return
    }

    const full = this.binary + '-' + name

    let args = process.argv,
        i = 0

    while (i < 3) {
      args.shift()
      i++
    }

    this.child = spawn(full, args, {
      stdio: 'inherit',
      detached: true
    })

    this.child.on('error', err => {
      throw err
    })
  }

  checkVersion () {
    const parent = module.parent

    pkginfo(parent)
    const version = parent.exports.version

    if (version) {
      this.option('version', 'Output the version number', version)

      if (this.raw.v || this.raw.version) {
        console.log(version)
        process.exit()
      }
    }
  }

  isDefined (name, list) {
    const children = this.details[list]

    for (let child of children) {
      let usage = child.usage,
          type = usage.constructor

      if (type === Array && usage.includes(name)) {
        return child
      }

      if (type === String && usage === name) {
        return child
      }
    }

    return false
  }

  parse (argv, options) {
    Object.assign(this.config, options)

    this.raw = parser(argv.slice(1))
    this.binary = path.basename(this.raw._[0])

    if (this.config.version) {
      this.checkVersion()
    }

    const subCommand = this.raw._[1] || false,
          helpTriggered = this.raw.h || this.raw.help

    if (this.isDefined(subCommand, 'commands')) {
      this.runCommand(subCommand)
      return {}
    }

    if (this.config.help && helpTriggered) {
      this.showHelp()
    }

    return Object.assign(this.getOptions(), this.raw)
  }

  showHelp () {
    const binary = path.basename(this.raw._[0]).replace('-', ' ')

    let details = [
      '',
      `Usage: ${binary} [options] [command]`,
      '',
      '',
      'Commands:',
      ''
    ]

    const commands = this.generateDetails('commands'),
          options = this.generateDetails('options')

    details = details.concat(
      commands,
      [
        '',
        'Options:',
        ''
      ],
      options,
      ''
    )

    console.log(details.join('\n  '))
    process.exit()
  }
}

export default new Args
<commit_msg>Create a new instance of .raw<commit_after>import parser from 'minimist'
import pkginfo from 'pkginfo'
import camelcase from 'camelcase'
import path from 'path'
import { spawn } from 'child_process'

class Args {
  constructor() {
    this.details = {
      options: [],
      commands: []
    }

    this.config = {
      help: true,
      version: true,
      errors: true
    }

    this.option('help', 'Output usage information')
    this.command('help', 'Display help')
  }

  option (name, description, init, defaultValue) {
    let usage = []

    switch (name.constructor) {
      case String:
        usage[0] = name.charAt(0)
        usage[1] = name

        break
      case Array:
        usage = usage.concat(name)
        break
      default:
        throw new Error('Invalid name for option')
    }

    if (usage.length > 0 && usage[0].length > 1) {
      throw new Error('Short version of option is longer than 1 char')
    }

    let optionDetails = {
      defaultValue,
      usage,
      description
    }

    if (defaultValue) {
      let initFunction = typeof init === 'function'
      optionDetails.init = initFunction ? init : this.handleType(defaultValue)[1]
    }

    this.details.options.push(optionDetails)
    return this
  }

  command (usage, description) {
    this.details.commands.push({
      usage,
      description
    })

    return this
  }

  handleType (value) {
    const type = value.constructor

    switch (type) {
      case String:
        return ['[value]', toString]
        break
      case Array:
        return ['<list>']
        break
      case Number:
        return ['<n>', parseInt]
        break
      default:
        return false
    }
  }

  readOption (option) {
    let value = false,
        contents = {}

    for (let name of option.usage) {
      let fromArgs = this.raw[name]

      if (fromArgs) {
        value = fromArgs
      }
    }

    for (let name of option.usage) {
      let propVal = value || option.defaultValue,
          condition = true

      if (option.init) {
        if (option.init === toString) {
          condition = propVal.constructor === Number
        }

        if (condition) {
          propVal = option.init(propVal)
        }
      }

      name = camelcase(name)
      if (propVal) contents[name] = propVal
    }

    return contents
  }

  getOptions () {
    let args = {},
        options = {}

    Object.assign(args, this.raw)
    delete args._

    for (let option in args) {
      let related = this.isDefined(option, 'options')

      if (related) {
        let details = this.readOption(related)
        Object.assign(options, details)
      } else if (this.config.errors) {
        console.error(`Option "${option}" not known`)
      }
    }

    for (let option in options) {
      this[option] = options[option]
    }

    return options
  }

  generateDetails (kind) {
    const items = this.details[kind]
    let parts = []

    for (let item in items) {
      let usage = items[item].usage,
          initial = items[item].defaultValue

      if (usage.constructor === Array) {
        usage = `-${usage[0]}, --${usage[1]}`
        usage += initial ? ' ' + this.handleType(initial)[0] : ''
      }

      items[item].usage = usage
    }

    const longest = items.sort((a, b) => {
      return b.usage.length - a.usage.length
    })[0].usage.length

    for (let item of items) {
      let usage = item.usage,
          difference = longest - usage.length

      usage += ' '.repeat(difference)
      parts.push('  ' + usage + '  ' + item.description)
    }

    return parts
  }

  runCommand (name) {
    if (this.config.help && name === 'help') {
      this.showHelp()
      return
    }

    const full = this.binary + '-' + name

    let args = process.argv,
        i = 0

    while (i < 3) {
      args.shift()
      i++
    }

    this.child = spawn(full, args, {
      stdio: 'inherit',
      detached: true
    })

    this.child.on('error', err => {
      throw err
    })
  }

  checkVersion () {
    const parent = module.parent

    pkginfo(parent)
    const version = parent.exports.version

    if (version) {
      this.option('version', 'Output the version number', version)

      if (this.raw.v || this.raw.version) {
        console.log(version)
        process.exit()
      }
    }
  }

  isDefined (name, list) {
    const children = this.details[list]

    for (let child of children) {
      let usage = child.usage,
          type = usage.constructor

      if (type === Array && usage.includes(name)) {
        return child
      }

      if (type === String && usage === name) {
        return child
      }
    }

    return false
  }

  parse (argv, options) {
    Object.assign(this.config, options)

    this.raw = parser(argv.slice(1))
    this.binary = path.basename(this.raw._[0])

    if (this.config.version) {
      this.checkVersion()
    }

    const subCommand = this.raw._[1] || false,
          helpTriggered = this.raw.h || this.raw.help

    if (this.isDefined(subCommand, 'commands')) {
      this.runCommand(subCommand)
      return {}
    }

    if (this.config.help && helpTriggered) {
      this.showHelp()
    }

    return this.getOptions()
  }

  showHelp () {
    const binary = path.basename(this.raw._[0]).replace('-', ' ')

    let details = [
      '',
      `Usage: ${binary} [options] [command]`,
      '',
      '',
      'Commands:',
      ''
    ]

    const commands = this.generateDetails('commands'),
          options = this.generateDetails('options')

    details = details.concat(
      commands,
      [
        '',
        'Options:',
        ''
      ],
      options,
      ''
    )

    console.log(details.join('\n  '))
    process.exit()
  }
}

export default new Args
<|endoftext|>


<commit_before>var extend = require("xtend");

var getRequirejsConfig = function () {
  var requirejsConfig;
  global.define = function (config) {
    requirejsConfig = config({ isBuild: true });
  };
  require('./app/config');

  return extend(requirejsConfig, {
    baseUrl: 'app',
    name: "client",
    include: ["vendor/almond"],
    deps: [
      'client',
      'client/client_bootstrap'
    ],
    wrap: true,
    optimize: 'none'
  });
};

var requirejsConfig = getRequirejsConfig();

module.exports = function(grunt) {
  "use strict";

  // Project configuration.
  grunt.initConfig({
    clean: ["public/"],
    sass: {
      development: {
        files: {
          'public/stylesheets/spotlight.css': 'styles/index.scss'
        },
        options: {
          loadPath: [
            'node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/stylesheets'
          ],
          style: 'nested'
        }
      },
      production: {
        files: [
          { 'public/stylesheets/spotlight.css': 'styles/index.scss' },
          {
            expand: true,
            cwd: 'node_modules/govuk_template_mustache/assets/stylesheets',
            src: ['*.css'],
            dest: 'public/stylesheets',
            ext: '.css'
          }
        ],
        options: {
          loadPath: [
            'node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/stylesheets'
          ],
          style: 'compressed'
        }
      }
    },
    jasmine: {
      spotlight: {
        src: ['app/**/*.js'],
        options: {
          helpers: ['spec/helpers/*.js'],
          specs: [
            'spec/shared/**/spec.*.js',
            'spec/client/**/spec.*.js'
          ],
          template: 'spec/index.html',
          keepRunner: true
        }
      }
    },
    jasmine_node: {
      useHelpers: true,
      specFolders: [
        "./spec/shared",
        "./spec/server"
      ],
      projectRoot: "./spec/",
      options: {
        specNameMatcher: "spec\..*", // load only specs containing specNameMatcher
        match: ".*",
        useRequireJs: "spec/requirejs-setup.js",
        forceExit: true,
        jUnit: {
          report: false,
          savePath : "./build/reports/jasmine/",
          useDotNotation: true,
          consolidate: true
        }
      }
    },
    cucumber: {
        test: {
            features: 'features/'
        },
        options: {
            prefix: 'bundle exec',
            format: 'progress',
            tags: ['~@wip']
        }
    },
    jshint: {
      files: "app/**/*.js",
      options: {
        ignores: ['app/vendor/**'],
        eqnull: true,
        es3: true,
        es5: false
      }
    },
    requirejs: {
      production: {
        options: extend({}, requirejsConfig, {
          out: "public/javascripts/spotlight.js",
          d3: true
        })
      },
      'production-no-d3': {
        options: extend({}, requirejsConfig, {
          out: "public/javascripts/spotlight-no-d3.js",
          d3: false
        })
      }
    },
    copy: {
      govuk_template: {
        src: 'node_modules/govuk_template_mustache/views/layouts/govuk_template.html',
        dest: 'app/common/templates/',
        expand: true,
        flatten: true,
        filter: 'isFile'
      },
      govuk_assets: {
        files: [
          {
            expand: true,
            src: '**',
            cwd: 'node_modules/govuk_template_mustache/assets',
            dest: 'public/'
          }
        ]
      },
      vendor: {
        files: [
          {
            src: 'node_modules/backbone/backbone.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/d3/d3.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/moment-timezone/moment-timezone.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          }
        ]
      }
    },
    watch: {
      css: {
        files: ['styles/**/*.scss'],
        tasks: ['sass:development'],
        options: { nospawn: true }
      },
      spec: {
        files: ['spec/**/spec.*.js'],
        tasks: ['jasmine:spotlight:build']
      }
    },
    shell: {
      supervisor: {
        options: {
          stdout: true
        },
        command: 'supervisor -w app app/server'
      }
    },
    nodemon: {
      dev: {
        options: {
          file: 'app/server.js',
          watchedExtensions: ['js'],
          watchedFolders: ['app', 'support'],
          delayTime: 1,
          legacyWatch: true
        }
      }
    },
    concurrent: {
      dev: {
        tasks: ['shell:supervisor', 'watch'],
        options: {
          logConcurrentOutput: true
        }
      }
    }
  });

  [
    'grunt-contrib-jasmine',
    'grunt-jasmine-node-coverage',
    'grunt-contrib-jshint',
    'grunt-contrib-clean',
    'grunt-contrib-sass',
    'grunt-contrib-requirejs',
    'grunt-rcukes',
    'grunt-contrib-copy',
    'grunt-contrib-watch',
    'grunt-shell',
    'grunt-concurrent'
  ].forEach(function (task) {
    grunt.loadNpmTasks(task);
  });

  grunt.registerTask('build:development', [
    'copy:vendor', 'copy:govuk_template', 'jshint', 'clean', 'copy:govuk_assets', 'sass:development'
  ]);
  grunt.registerTask('build:production', [
    'copy:vendor', 'copy:govuk_template', 'jshint', 'clean', 'copy:govuk_assets', 'sass:production', 'requirejs:production', 'requirejs:production-no-d3'
  ]);
  grunt.registerTask('test:all', ['copy:vendor', 'cucumber', 'jasmine', 'jasmine_node']);
  // Default task.
  grunt.registerTask('default', ['build:development', 'jasmine:spotlight:build', 'concurrent']);

};

<commit_msg>Re-enable minification of application<commit_after>var extend = require("xtend");

var getRequirejsConfig = function () {
  var requirejsConfig;
  global.define = function (config) {
    requirejsConfig = config({ isBuild: true });
  };
  require('./app/config');

  return extend(requirejsConfig, {
    baseUrl: 'app',
    name: "client",
    include: ["vendor/almond"],
    deps: [
      'client',
      'client/client_bootstrap'
    ],
    wrap: true,
    optimize: 'uglify'
  });
};

var requirejsConfig = getRequirejsConfig();

module.exports = function(grunt) {
  "use strict";

  // Project configuration.
  grunt.initConfig({
    clean: ["public/"],
    sass: {
      development: {
        files: {
          'public/stylesheets/spotlight.css': 'styles/index.scss'
        },
        options: {
          loadPath: [
            'node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/stylesheets'
          ],
          style: 'nested'
        }
      },
      production: {
        files: [
          { 'public/stylesheets/spotlight.css': 'styles/index.scss' },
          {
            expand: true,
            cwd: 'node_modules/govuk_template_mustache/assets/stylesheets',
            src: ['*.css'],
            dest: 'public/stylesheets',
            ext: '.css'
          }
        ],
        options: {
          loadPath: [
            'node_modules/govuk_frontend_toolkit/govuk_frontend_toolkit/stylesheets'
          ],
          style: 'compressed'
        }
      }
    },
    jasmine: {
      spotlight: {
        src: ['app/**/*.js'],
        options: {
          helpers: ['spec/helpers/*.js'],
          specs: [
            'spec/shared/**/spec.*.js',
            'spec/client/**/spec.*.js'
          ],
          template: 'spec/index.html',
          keepRunner: true
        }
      }
    },
    jasmine_node: {
      useHelpers: true,
      specFolders: [
        "./spec/shared",
        "./spec/server"
      ],
      projectRoot: "./spec/",
      options: {
        specNameMatcher: "spec\..*", // load only specs containing specNameMatcher
        match: ".*",
        useRequireJs: "spec/requirejs-setup.js",
        forceExit: true,
        jUnit: {
          report: false,
          savePath : "./build/reports/jasmine/",
          useDotNotation: true,
          consolidate: true
        }
      }
    },
    cucumber: {
        test: {
            features: 'features/'
        },
        options: {
            prefix: 'bundle exec',
            format: 'progress',
            tags: ['~@wip']
        }
    },
    jshint: {
      files: "app/**/*.js",
      options: {
        ignores: ['app/vendor/**'],
        eqnull: true,
        es3: true,
        es5: false
      }
    },
    requirejs: {
      production: {
        options: extend({}, requirejsConfig, {
          out: "public/javascripts/spotlight.js",
          d3: true
        })
      },
      'production-no-d3': {
        options: extend({}, requirejsConfig, {
          out: "public/javascripts/spotlight-no-d3.js",
          d3: false
        })
      }
    },
    copy: {
      govuk_template: {
        src: 'node_modules/govuk_template_mustache/views/layouts/govuk_template.html',
        dest: 'app/common/templates/',
        expand: true,
        flatten: true,
        filter: 'isFile'
      },
      govuk_assets: {
        files: [
          {
            expand: true,
            src: '**',
            cwd: 'node_modules/govuk_template_mustache/assets',
            dest: 'public/'
          }
        ]
      },
      vendor: {
        files: [
          {
            src: 'node_modules/backbone/backbone.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/d3/d3.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          },
          {
            src: 'node_modules/moment-timezone/moment-timezone.js',
            dest: 'app/vendor/',
            flatten: true,
            expand: true
          }
        ]
      }
    },
    watch: {
      css: {
        files: ['styles/**/*.scss'],
        tasks: ['sass:development'],
        options: { nospawn: true }
      },
      spec: {
        files: ['spec/**/spec.*.js'],
        tasks: ['jasmine:spotlight:build']
      }
    },
    shell: {
      supervisor: {
        options: {
          stdout: true
        },
        command: 'supervisor -w app app/server'
      }
    },
    nodemon: {
      dev: {
        options: {
          file: 'app/server.js',
          watchedExtensions: ['js'],
          watchedFolders: ['app', 'support'],
          delayTime: 1,
          legacyWatch: true
        }
      }
    },
    concurrent: {
      dev: {
        tasks: ['shell:supervisor', 'watch'],
        options: {
          logConcurrentOutput: true
        }
      }
    }
  });

  [
    'grunt-contrib-jasmine',
    'grunt-jasmine-node-coverage',
    'grunt-contrib-jshint',
    'grunt-contrib-clean',
    'grunt-contrib-sass',
    'grunt-contrib-requirejs',
    'grunt-rcukes',
    'grunt-contrib-copy',
    'grunt-contrib-watch',
    'grunt-shell',
    'grunt-concurrent'
  ].forEach(function (task) {
    grunt.loadNpmTasks(task);
  });

  grunt.registerTask('build:development', [
    'copy:vendor', 'copy:govuk_template', 'jshint', 'clean', 'copy:govuk_assets', 'sass:development'
  ]);
  grunt.registerTask('build:production', [
    'copy:vendor', 'copy:govuk_template', 'jshint', 'clean', 'copy:govuk_assets', 'sass:production', 'requirejs:production', 'requirejs:production-no-d3'
  ]);
  grunt.registerTask('test:all', ['copy:vendor', 'cucumber', 'jasmine', 'jasmine_node']);
  // Default task.
  grunt.registerTask('default', ['build:development', 'jasmine:spotlight:build', 'concurrent']);

};

<|endoftext|>


<commit_before>'use strict'

import {Map} from 'immutable'

export default class ValueMap {
  constructor (value) {
    this.__value__ = arguments.length ? value : new Map()
    this.__valueMap__ = true
  }
  static isValueMap (map) {
    return !!(map && map.__valueMap__)
  }
  isMap () {
    return Map.isMap(this.__value__)
  }
  get size () {
    return this.isMap() ? this.__value__.size : 0
  }
  set (key, value) {
    if (arguments.length === 1) {
      value = key
      if (this.__value__ === value) return this
      return new this.constructor(value)
    }
    const map = this.isMap() ? this.__value__ : new Map()
    const updated = map.set(key, value)
    return updated === map ? this : new this.constructor(updated)
  }
  delete (key) {
    if (!this.isMap()) {
      if (key != null) return this
      if (this.__value__ === undefined) return this
      return new this.constructor(undefined)
    }
    const updated = this.__value__.delete(key)
    return updated === this.__value__ ? this : new this.constructor(updated)
  }
  clear () {
    return new this.constructor()
  }
  update () {
    if (!this.isMap()) return new this.constructor().update(...arguments)
    const updated = this.__value__.update(...arguments)
    return updated === this.__value__ ? this : new this.constructor(updated)
  }
  merge (...iterables) {
    if (!this.isMap()) return new this.constructor().merge(...iterables)
    const updated = this.__value__.merge(...iterables)
    return updated === this.__value__ ? this : new this.constructor(updated)
  }
  mergeDeep (...iterables) {
    if (!this.isMap()) return new this.constructor().mergeDeep(...iterables)
    const updated = this.__value__.mergeDeep(...iterables)
    return updated === this.__value__ ? this : new this.constructor(updated)
  }
  mergeDeepWith (merger, ...iterables) {
    if (!this.isMap()) return new this.constructor().mergeDeepWith(merger, ...iterables)
    const updated = this.__value__.mergeDeepWith(merger, ...iterables)
    return updated === this.__value__ ? this : new this.constructor(updated)
  }
  get (key, notSetValue) {
    if (key == null) return this.__value__
    return this.isMap() ? this.__value__.get(key, notSetValue) : notSetValue
  }
  has (key) {
    return this.isMap() ? this.__value__.has(key) : false
  }
  includes (key) {
    return this.isMap() ? this.__value__.includes(key) : false
  }
  first () {
    return this.isMap() ? this.__value__.first() : undefined
  }
  last () {
    return this.isMap() ? this.__value__.last() : undefined
  }
  getIn (keyPath, notSetValue) {
    if (this.isMap()) return this.__value__.getIn(keyPath, notSetValue)
    return !keyPath.length ? this.__value__ : notSetValue
  }
  hasIn (keyPath) {
    if (this.isMap()) return this.__value__.hasIn(keyPath)
    return !keyPath.length
  }
}
<commit_msg>Extract equality check used in write methods to __set__<commit_after>'use strict'

import {Map} from 'immutable'
import assert from 'assert'

export default class ValueMap {
  constructor (value) {
    this.__value__ = arguments.length ? value : new Map()
    this.__valueMap__ = true
  }
  static isValueMap (map) {
    return !!(map && map.__valueMap__)
  }
  isMap () {
    return Map.isMap(this.__value__)
  }
  get size () {
    return this.isMap() ? this.__value__.size : 0
  }
  __set__ (updater) {
    if (typeof updater !== 'function') {
      const value = updater
      return value === this.__value__ ? this : new this.constructor(value)
    }
    const updated = updater.call(this, this.__value__)
    return updated === this.__value__ ? this : new this.constructor(updated)
  }
  set (key, value) {
    assert(typeof key !== 'function', 'key may not be a function')
    if (arguments.length === 1) {
      value = key
      return this.__set__(value)
    }
    return this.__set__((oldValue) => {
      return (this.isMap() ? oldValue : new Map()).set(key, value)
    })
  }
  delete (key) {
    if (!this.isMap()) {
      if (key != null) return this
      if (this.__value__ === undefined) return this
      return new this.constructor(undefined)
    }
    return this.__set__(value => value.delete(key))
  }
  clear () {
    return new this.constructor()
  }
  update () {
    if (!this.isMap()) return new this.constructor().update(...arguments)
    return this.__set__(value => value.update(...arguments))
  }
  merge (...iterables) {
    if (!this.isMap()) return new this.constructor().merge(...iterables)
    return this.__set__(value => value.merge(...iterables))
  }
  mergeDeep (...iterables) {
    if (!this.isMap()) return new this.constructor().mergeDeep(...iterables)
    return this.__set__(value => value.mergeDeep(...iterables))
  }
  mergeDeepWith (merger, ...iterables) {
    if (!this.isMap()) return new this.constructor().mergeDeepWith(merger, ...iterables)
    return this.__set__(value => value.mergeDeepWith(merger, ...iterables))
  }
  get (key, notSetValue) {
    if (key == null) return this.__value__
    return this.isMap() ? this.__value__.get(key, notSetValue) : notSetValue
  }
  has (key) {
    return this.isMap() ? this.__value__.has(key) : false
  }
  includes (key) {
    return this.isMap() ? this.__value__.includes(key) : false
  }
  first () {
    return this.isMap() ? this.__value__.first() : undefined
  }
  last () {
    return this.isMap() ? this.__value__.last() : undefined
  }
  getIn (keyPath, notSetValue) {
    if (this.isMap()) return this.__value__.getIn(keyPath, notSetValue)
    return !keyPath.length ? this.__value__ : notSetValue
  }
  hasIn (keyPath) {
    if (this.isMap()) return this.__value__.hasIn(keyPath)
    return !keyPath.length
  }
}
<|endoftext|>


<commit_before>/**
* CONFIDENTIAL
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
* This is unpublished proprietary source code of Red Hat.
**/
// Generated on 2014-03-05 using generator-angular 0.7.1
'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'

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({

    // Project settings
    app: {
      // configurable paths
      src: 'src',
      dist: 'www',
      url: '',
      default_local_server_url: 'http://localhost:8001'
    },

    copy: {
      static: {
        files: [
          {expand: true, cwd: '<%= app.src %>/', src: ['**/*.html'], dest: '<%= app.dist %>', filter: 'isFile'},
          {expand: true, cwd: '<%= app.src %>/', src: ['**/*.json'], dest: '<%= app.dist %>', filter: 'isFile'},
        ],
      },
      css: {
        files: [
          {src: 'node_modules/angular-material/angular-material.css', dest: '<%= app.dist %>/css/', expand: true, flatten: true },
        ]
      }
    },

    sass: {
        options: {
            sourceMap: true
        },
        dist: {
            files: {
                '<%= app.dist %>/css/app.css': '<%= app.src %>/sass/app.scss'
            }
        }
    },

    browserify: {
      options: {
        browserifyOptions: {
           debug: true
        }
      },
      all: {
        files: {
          "<%= app.dist %>/app/bundle.js": ["<%= app.src %>/app/app.js"]
        },
        options: {
          watch: true
        }
      }
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      js: {
        files: ['<%= app.dist %>/app/bundle.js'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      html: {
<<<<<<< HEAD
        files: ['<%= app.src %>/{,*/}*.html'],
=======
        files: ['<%= app.src %>/**/*.html'],
>>>>>>> ef2984af0c13c46584640b0a66168c8423c0360c
        tasks: ['copy:static']
      },
      sass: {
        files: ['**/*.scss'],
        tasks: ['sass']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= app.dist %>/**/*.html',
          '<%= app.dist %>/css/{,*/}*.css',
          '<%= app.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9002,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35730
      },
      livereload: {
        options: {
          open: {
            target: '<%= app.url %>'
          },
          base: [
            '.tmp',
            '<%= app.dist %>'
          ]
        }
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: ['<%= app.dist %>'],
      server: '.tmp'
    }
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'local') {
      var conn = 'http://' + grunt.config.get('connect.options.hostname') + ':' +
        grunt.config.get('connect.options.port');
      var url = grunt.option('url') || grunt.config.get('app.default_local_server_url');
      grunt.config.set('app.url', conn + '/?url=' + url);
    } else {
      // open with no url passed to fh-js-sdk
      grunt.config.set('connect.livereload.options.open', true);
    }

    grunt.task.run([
      'clean:dist',
      'sass',
      'copy',
      'clean:server',
      'browserify',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('default', ['serve']);
};
<commit_msg>Fixed a failed merge on the Gruntfile<commit_after>/**
* CONFIDENTIAL
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
* This is unpublished proprietary source code of Red Hat.
**/
// Generated on 2014-03-05 using generator-angular 0.7.1
'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'

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({

    // Project settings
    app: {
      // configurable paths
      src: 'src',
      dist: 'www',
      url: '',
      default_local_server_url: 'http://localhost:8001'
    },

    copy: {
      static: {
        files: [
          {expand: true, cwd: '<%= app.src %>/', src: ['**/*.html'], dest: '<%= app.dist %>', filter: 'isFile'},
          {expand: true, cwd: '<%= app.src %>/', src: ['**/*.json'], dest: '<%= app.dist %>', filter: 'isFile'},
        ],
      },
      css: {
        files: [
          {src: 'node_modules/angular-material/angular-material.css', dest: '<%= app.dist %>/css/', expand: true, flatten: true },
        ]
      }
    },

    sass: {
        options: {
            sourceMap: true
        },
        dist: {
            files: {
                '<%= app.dist %>/css/app.css': '<%= app.src %>/sass/app.scss'
            }
        }
    },

    browserify: {
      options: {
        browserifyOptions: {
           debug: true
        }
      },
      all: {
        files: {
          "<%= app.dist %>/app/bundle.js": ["<%= app.src %>/app/app.js"]
        },
        options: {
          watch: true
        }
      }
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      js: {
        files: ['<%= app.dist %>/app/bundle.js'],
        options: {
          livereload: '<%= connect.options.livereload %>'
        }
      },
      html: {
        files: ['<%= app.src %>/**/*.html'],
        tasks: ['copy:static']
      },
      sass: {
        files: ['**/*.scss'],
        tasks: ['sass']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= app.dist %>/**/*.html',
          '<%= app.dist %>/css/{,*/}*.css',
          '<%= app.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9002,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35730
      },
      livereload: {
        options: {
          open: {
            target: '<%= app.url %>'
          },
          base: [
            '.tmp',
            '<%= app.dist %>'
          ]
        }
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: ['<%= app.dist %>'],
      server: '.tmp'
    }
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'local') {
      var conn = 'http://' + grunt.config.get('connect.options.hostname') + ':' +
        grunt.config.get('connect.options.port');
      var url = grunt.option('url') || grunt.config.get('app.default_local_server_url');
      grunt.config.set('app.url', conn + '/?url=' + url);
    } else {
      // open with no url passed to fh-js-sdk
      grunt.config.set('connect.livereload.options.open', true);
    }

    grunt.task.run([
      'clean:dist',
      'sass',
      'copy',
      'clean:server',
      'browserify',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('default', ['serve']);
};
<|endoftext|>


<commit_before>const _ = require('lodash')
const config = require('config')
const resolve = require('resolve-dir')

const source = './data'
const destination = resolve(config.data_sync_destination)
const experiments = config.experiments
const experiment_tasks = _.map(experiments, function(name) {
  return `shell:run:${name}`
})

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

  grunt.initConfig({
    sync: {
      main: {
        files: [{
          cwd: source,
          src: ['**'],
          dest: destination,
        }],
        // pretend: true, // Don't do real IO; log only
        // verbose: true // Display log messages when copying files
      }
    },

    watch: {
      data: {
        files: `${source}/**`,
        tasks: ['sync']
      }
    },

    shell: {
      options: {
        execOptions: {
          killSignal: 'SIGINT',
          env: process.env
        }
      },
      run: {
        command: function(experiment_name) {
          var cmd = `python3 main.py -bgp -e ${experiment_name} -t 5`
          if (_.includes(experiment_name, 'python')) {
            // override with custom command
            cmd = experiment_name
          }
          return `(${cmd} | tee -a ./data/terminal.log) & NOTI_SLACK_DEST='${config.NOTI_SLACK_DEST}' NOTI_SLACK_TOK='${config.NOTI_SLACK_TOK}' noti -k -t '${experiment_name}' -pwatch $! &`
        }
      },
      dev: {
        command: function(a) {
          return `echo ${a} & echo $!`
        }
      }
    },

    concurrent: {
      target: ['watch', 'lab'],
      options: {
        logConcurrentOutput: true
      }
    },
  })

  grunt.registerTask('lab', 'run all the experiments', experiment_tasks)
  grunt.registerTask('lab_sync', 'run lab with auto file syncing', ['concurrent'])
  grunt.registerTask('default', ['lab_sync'])
}
<commit_msg>stylefix for js<commit_after>const _ = require('lodash')
const config = require('config')
const resolve = require('resolve-dir')

const source = './data'
const destination = resolve(config.data_sync_destination)
const experiments = config.experiments
const experimentTasks = _.map(experiments, function(name) {
  return `shell:run:${name}`
})

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

  grunt.initConfig({
    sync: {
      main: {
        files: [{
          cwd: source,
          src: ['**'],
          dest: destination,
        }],
        // pretend: true, // Don't do real IO; log only
        // verbose: true // Display log messages when copying files
      }
    },

    watch: {
      data: {
        files: `${source}/**`,
        tasks: ['sync']
      }
    },

    shell: {
      options: {
        execOptions: {
          killSignal: 'SIGINT',
          env: process.env
        }
      },
      run: {
        command (experiment) {
          var cmd = `python3 main.py -bgp -e ${experiment} -t 5`
          if (_.includes(experiment, 'python')) {
            // override with custom command
            cmd = experiment
          }
          return `(${cmd} | tee -a ./data/terminal.log) & NOTI_SLACK_DEST='${config.NOTI_SLACK_DEST}' NOTI_SLACK_TOK='${config.NOTI_SLACK_TOK}' noti -k -t '${experiment}' -pwatch $! &`
        }
      },
    },

    concurrent: {
      target: ['watch', 'lab'],
      options: {
        logConcurrentOutput: true
      }
    },
  })

  grunt.registerTask('lab', 'run all the experiments', experimentTasks)
  grunt.registerTask('lab_sync', 'run lab with auto file syncing', ['concurrent'])
  grunt.registerTask('default', ['lab_sync'])
}
<|endoftext|>