<commit_before>'use strict';

module.exports = function (grunt) {

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

    require('./tasks/patterns')(grunt);

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

    var yaml = require('js-yaml'),
        fs = require('fs');

    // Configurable paths
    var paths = {
        tmp: '.tmp',
        app: 'docs',
        dist: 'docs/dist'
    };

    var config = yaml.safeLoad(fs.readFileSync('./config.yaml', 'utf8'));

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

        // Project settings
        paths: paths,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['bowerInstall']
            },
            js: {
                files: ['<%= paths.app %>/scripts/{,*/}*.js'],
                tasks: ['jshint'],
                options: {
                    livereload: true
                }
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            patterns: {
                files: ['<%= paths.app %>/content/**/*.md'],
                tasks: ['patterns']
            },
            // template: {
            //     files: ['<%= paths.app %>/{,*/}*.html'],
            //     tasks: ['template']
            // },
            less: {
                files: ['less/**.less', '<%= paths.app %>/styles/**.less'],
                tasks: ['less:server', 'autoprefixer']
            },
            styles: {
                files: ['<%= paths.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= paths.tmp %>/{,*/}*.html',
                    '<%= paths.tmp %>/styles/{,*/}*.css',
                    '<%= paths.app %>/images/{,*/}*'
                ]
            }
        },

        template: {
            dist: {
                engine: 'ejs',
                variables: config,
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>',
                    dest: '<%= paths.tmp %>',
                    src: '*.html',
                    ext: '.html'
                }]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: grunt.option('port') || 9000,
                open: true,
                livereload: 35729,
                // Change this to '0.0.0.0' to access the server from outside
                hostname: '0.0.0.0'
            },
            livereload: {
                options: {
                    middleware: function(connect) {
                        return [
                            connect.static(paths.tmp),
                            connect().use('/bower_components', connect.static('./bower_components')),
                            connect.static(paths.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    base: '<%= paths.dist %>',
                    livereload: false
                }
            }
        },

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

        lesslint: {
            src: ['less/_*.less', '<%= paths.app %>/styles/_*.less'],
            options: {
                csslint: {
                    'box-model': false,
                    'adjoining-classes': false,
                    'qualified-headings': false,
                    'empty-rules': false,
                    'outline-none': false,
                    'unique-headings': false
                }
            }
        },

        // 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',
                '<%= paths.app %>/scripts/{,*/}*.js',
                '!<%= paths.app %>/scripts/vendor/*'
            ]
        },

        // Compiles LESS to CSS and generates necessary files if requested
        less: {
            theme: {
                files: [{
                    expand: true,
                    cwd: 'less',
                    src: ['usptostrap.less'],
                    dest: 'dist',
                    ext: '.css'
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>/styles',
                    src: ['pattern-library.less'],
                    dest: '<%= paths.tmp %>/styles',
                    ext: '.css'
                }]
            },
            server: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>/styles',
                    src: ['pattern-library.less'],
                    dest: '<%= paths.tmp %>/styles',
                    ext: '.css'
                }]
            }
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.tmp %>/styles/',
                    src: '{,*/}*.css',
                    dest: '<%= paths.tmp %>/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the HTML file
        bowerInstall: {
            app: {
                src: ['<%= paths.app %>/index.html'],
                exclude: ['bower_components/bootstrap/js/bootstrap.js']
            },
            less: {
                src: ['<%= paths.app %>/styles/{,*/}*.{less}']
            }
        },

        // Renames files for browser caching purposes
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= paths.dist %>/scripts/{,*/}*.js',
                        '<%= paths.dist %>/styles/{,*/}*.css',
                        '<%= paths.dist %>/images/{,*/}*.*',
                        '<%= paths.dist %>/styles/fonts/{,*/}*.*',
                        '<%= paths.dist %>/*.{ico,png}'
                    ]
                }
            }
        },

        // 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: {
            options: {
                dest: '<%= paths.dist %>'
            },
            html: ['<%= paths.tmp %>/**/*.tpl.ejs']
        },

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

        // The following *-min tasks produce minified files in the dist folder
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>/images',
                    src: '{,*/}*.{gif,jpeg,jpg,png}',
                    dest: '<%= paths.dist %>/images'
                }]
            }
        },

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

        htmlmin: {
            dist: {
                options: {
                    // collapseBooleanAttributes: true,
                    // collapseWhitespace: true,
                    // removeAttributeQuotes: true,
                    // removeCommentsFromCDATA: true,
                    // removeEmptyAttributes: true,
                    // removeOptionalTags: true,
                    // removeRedundantAttributes: true,
                    // useShortDoctype: true
                },
                files: [{
                    expand: true,
                    cwd: '.tmp',
                    src: '{,*/}*.html',
                    dest: '<%= paths.dist %>'
                }]
            }
        },

        patterns: {
            server: {
                options: {
                    variables: config,
                    patternRoot: '<%= paths.app %>/content',
                    urlRoot: '/',
                    template: '<%= paths.tmp %>/pattern.tpl.ejs'
                },
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>/content',
                    src: '**/*.md',
                    dest: '<%= paths.tmp %>'
                }]
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {

            // copy the tpl to the tmp folder so we can usemin it
            tpl: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= paths.app %>',
                    dest: '<%= paths.tmp %>',
                    src: '*.tpl.ejs'
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= paths.app %>',
                    dest: '<%= paths.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'images/{,*/}*.webp',
                        '{,*/}*.html',
                        'styles/fonts/{,*/}*.*'
                    ]
                }, {
                    expand: true,
                    dot: true,
                    cwd: '.',
                    src: ['bower_components/bootstrap/vendor/assets/fonts/bootstrap/*.*'],
                    dest: '<%= paths.dist %>'
                }, {
                    dot: true,
                    expand: true,
                    cwd: 'bower_components/font-awesome/fonts/',
                    src: ['*.*'],
                    dest: '<%= paths.dist %>/fonts/'
                }]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%= paths.app %>/styles',
                dest: '<%= paths.tmp %>/styles/',
                src: '{,*/}*.css'
            }
        },

        // Run some tasks in parallel to speed up build process
        concurrent: {
            server: [
                // 'lesslint',
                'jshint',
                'less:theme',
                'less:server',
                'patterns',
                // 'template',
                'copy:styles'
            ],
            dist: [
                // 'lesslint',
                'jshint',
                'less',
                // 'patterns',
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        }
    });

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

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

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

    grunt.registerTask('default', [
        'newer:jshint',
        'build'
    ]);
};
<commit_msg>Watch for template changes and recompile<commit_after>'use strict';

module.exports = function (grunt) {

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

    require('./tasks/patterns')(grunt);

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

    var yaml = require('js-yaml'),
        fs = require('fs');

    // Configurable paths
    var paths = {
        tmp: '.tmp',
        app: 'docs',
        dist: 'docs/dist'
    };

    var config = yaml.safeLoad(fs.readFileSync('./config.yaml', 'utf8'));

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

        // Project settings
        paths: paths,

        // Watches files for changes and runs tasks based on the changed files
        watch: {
            bower: {
                files: ['bower.json'],
                tasks: ['bowerInstall']
            },
            js: {
                files: ['<%= paths.app %>/scripts/{,*/}*.js'],
                tasks: ['jshint'],
                options: {
                    livereload: true
                }
            },
            gruntfile: {
                files: ['Gruntfile.js']
            },
            patterns: {
                files: ['<%= paths.app %>/*.tpl.ejs', '<%= paths.app %>/content/**/*.md'],
                tasks: ['copy:tpl', 'patterns']
            },
            // template: {
            //     files: ['<%= paths.app %>/{,*/}*.html'],
            //     tasks: ['template']
            // },
            less: {
                files: ['less/**.less', '<%= paths.app %>/styles/**.less'],
                tasks: ['less:server', 'autoprefixer']
            },
            styles: {
                files: ['<%= paths.app %>/styles/{,*/}*.css'],
                tasks: ['newer:copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= paths.tmp %>/{,*/}*.html',
                    '<%= paths.tmp %>/styles/{,*/}*.css',
                    '<%= paths.app %>/images/{,*/}*'
                ]
            }
        },

        template: {
            dist: {
                engine: 'ejs',
                variables: config,
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>',
                    dest: '<%= paths.tmp %>',
                    src: '*.html',
                    ext: '.html'
                }]
            }
        },

        // The actual grunt server settings
        connect: {
            options: {
                port: grunt.option('port') || 9000,
                open: true,
                livereload: 35729,
                // Change this to '0.0.0.0' to access the server from outside
                hostname: '0.0.0.0'
            },
            livereload: {
                options: {
                    middleware: function(connect) {
                        return [
                            connect.static(paths.tmp),
                            connect().use('/bower_components', connect.static('./bower_components')),
                            connect.static(paths.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    base: '<%= paths.dist %>',
                    livereload: false
                }
            }
        },

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

        lesslint: {
            src: ['less/_*.less', '<%= paths.app %>/styles/_*.less'],
            options: {
                csslint: {
                    'box-model': false,
                    'adjoining-classes': false,
                    'qualified-headings': false,
                    'empty-rules': false,
                    'outline-none': false,
                    'unique-headings': false
                }
            }
        },

        // 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',
                '<%= paths.app %>/scripts/{,*/}*.js',
                '!<%= paths.app %>/scripts/vendor/*'
            ]
        },

        // Compiles LESS to CSS and generates necessary files if requested
        less: {
            theme: {
                files: [{
                    expand: true,
                    cwd: 'less',
                    src: ['usptostrap.less'],
                    dest: 'dist',
                    ext: '.css'
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>/styles',
                    src: ['pattern-library.less'],
                    dest: '<%= paths.tmp %>/styles',
                    ext: '.css'
                }]
            },
            server: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>/styles',
                    src: ['pattern-library.less'],
                    dest: '<%= paths.tmp %>/styles',
                    ext: '.css'
                }]
            }
        },

        // Add vendor prefixed styles
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.tmp %>/styles/',
                    src: '{,*/}*.css',
                    dest: '<%= paths.tmp %>/styles/'
                }]
            }
        },

        // Automatically inject Bower components into the HTML file
        bowerInstall: {
            app: {
                src: ['<%= paths.app %>/index.html'],
                exclude: ['bower_components/bootstrap/js/bootstrap.js']
            },
            less: {
                src: ['<%= paths.app %>/styles/{,*/}*.{less}']
            }
        },

        // Renames files for browser caching purposes
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= paths.dist %>/scripts/{,*/}*.js',
                        '<%= paths.dist %>/styles/{,*/}*.css',
                        '<%= paths.dist %>/images/{,*/}*.*',
                        '<%= paths.dist %>/styles/fonts/{,*/}*.*',
                        '<%= paths.dist %>/*.{ico,png}'
                    ]
                }
            }
        },

        // 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: {
            options: {
                dest: '<%= paths.dist %>'
            },
            html: ['<%= paths.tmp %>/**/*.tpl.ejs']
        },

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

        // The following *-min tasks produce minified files in the dist folder
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>/images',
                    src: '{,*/}*.{gif,jpeg,jpg,png}',
                    dest: '<%= paths.dist %>/images'
                }]
            }
        },

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

        htmlmin: {
            dist: {
                options: {
                    // collapseBooleanAttributes: true,
                    // collapseWhitespace: true,
                    // removeAttributeQuotes: true,
                    // removeCommentsFromCDATA: true,
                    // removeEmptyAttributes: true,
                    // removeOptionalTags: true,
                    // removeRedundantAttributes: true,
                    // useShortDoctype: true
                },
                files: [{
                    expand: true,
                    cwd: '.tmp',
                    src: '{,*/}*.html',
                    dest: '<%= paths.dist %>'
                }]
            }
        },

        patterns: {
            server: {
                options: {
                    variables: config,
                    patternRoot: '<%= paths.app %>/content',
                    urlRoot: '/',
                    template: '<%= paths.tmp %>/pattern.tpl.ejs'
                },
                files: [{
                    expand: true,
                    cwd: '<%= paths.app %>/content',
                    src: '**/*.md',
                    dest: '<%= paths.tmp %>'
                }]
            }
        },

        // Copies remaining files to places other tasks can use
        copy: {

            // copy the tpl to the tmp folder so we can usemin it
            tpl: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= paths.app %>',
                    dest: '<%= paths.tmp %>',
                    src: '*.tpl.ejs'
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= paths.app %>',
                    dest: '<%= paths.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'images/{,*/}*.webp',
                        '{,*/}*.html',
                        'styles/fonts/{,*/}*.*'
                    ]
                }, {
                    expand: true,
                    dot: true,
                    cwd: '.',
                    src: ['bower_components/bootstrap/vendor/assets/fonts/bootstrap/*.*'],
                    dest: '<%= paths.dist %>'
                }, {
                    dot: true,
                    expand: true,
                    cwd: 'bower_components/font-awesome/fonts/',
                    src: ['*.*'],
                    dest: '<%= paths.dist %>/fonts/'
                }]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%= paths.app %>/styles',
                dest: '<%= paths.tmp %>/styles/',
                src: '{,*/}*.css'
            }
        },

        // Run some tasks in parallel to speed up build process
        concurrent: {
            server: [
                // 'lesslint',
                'jshint',
                'less:theme',
                'less:server',
                'patterns',
                // 'template',
                'copy:styles'
            ],
            dist: [
                // 'lesslint',
                'jshint',
                'less',
                // 'patterns',
                'copy:styles',
                'imagemin',
                'svgmin'
            ]
        }
    });

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

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

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

    grunt.registerTask('default', [
        'newer:jshint',
        'build'
    ]);
};
<|endoftext|>


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

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

	var jsCustom = [
		'src/js/head.js',
		'tmp/html/geochart.tpl.js',
		'src/js/map.js',
		'src/js/tail.js'
	];

	var libraries = [
		'bower_components/jquery/dist/jquery.min.js',
		'bower_components/jquery/dist/jquery.min.map',
		'bower_components/jquery-load-template/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js',
		'bower_components/jScrollPane/script/jquery.mousewheel.js',
		'bower_components/jScrollPane/script/jquery.jscrollpane.min.js',
		'bower_components/jScrollPane/style/jquery.jscrollpane.css',
		'bower_components/d3/d3.min.js',
		'bower_components/topojson/topojson.js',
		'bower_components/moment/min/moment.min.js'
	];

	grunt.initConfig({

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

		minifyHtml: {
			options: {
				empty: true,
				loose: true,
				conditionals: true,
				quotes: true
			},
			prod: {
				files: [{
					expand: true,
					cwd: 'src/html/',
					src: ['*.html'],
					dest: 'tmp/html-not-concat',
				}]
			}
		},

		htmlConvert: {
			options: {
				quoteChar: '\'',
				module: 'htmlTemplate',
				indentString: '	',
				rename: function(moduleName) {
					return moduleName.replace('.html', '');
				}
			},
			dev: {
				options: {
					base: 'src/html/'
				},
				src: ['src/html/*.html'],
				dest: 'tmp/html/geochart.tpl.js'
			},
			prod: {
				options: {
					base: 'tmp/html-not-concat/'
				},
				src: ['tmp/html-not-concat/*.html'],
				dest: 'tmp/html/geochart.tpl.js'
			}
		},

		concat: {
			jsCustom: {
				options: {
					process: function(src, filepath) {
						if(filepath !== 'src/js/head.js' && filepath !== 'src/js/head.js') {
							var lines = [];
							src.split('\n').forEach(function(line) {
								return lines.push((line.length > 0 ? '	' : '') + line);
							});
							src = lines.join('\n');
						}
						return src;
					}
				},
				src: jsCustom,
				dest: 'tmp/js/<%= pkg.name %>.js'
			},
			css: {
				src: ['tmp/styles/*.css'],
				dest: 'dist/<%= pkg.name %>.css'
			}
		},

		jshint: {
			options: {
				curly: true,
				eqeqeq: true,
				unused: true,
				bitwise: true,
				forin: true,
				freeze: true,
				undef: true,
			},
			dev: {
				options: {
					globals: {
						// console is allowed in dev mode
						console: true,
						window: true,
						document: true,
						d3: true,
						jQuery: true,
						topojson: true,
						moment: true
					}
				},
				src: ['<%= concat.jsCustom.dest %>']
			},
			dist: {
				options: {
					globals: {
						window: true,
						document: true,
						d3: true,
						jQuery: true,
						topojson: true,
						moment: true
					}
				},
				src: ['<%= concat.jsCustom.dest %>']
			}

		},

		sass: {
			dist: {
				files: [{
					expand: true,
					cwd: 'src/scss',
					src: ['*.{scss,sass}'],
					dest: 'tmp/styles',
					ext: '.css'
				}]
			}
		},

		copy: {
			jsCustom: {
				src: '<%= concat.jsCustom.dest %>',
				dest: 'dist/<%= pkg.name %>.js'
			},
			libraries: {
				expand: true,
				flatten: true,
				src: libraries,
				dest: 'dist/lib/'
			},
			json: {
				expand: true,
				flatten: true,
				rename: function(dest, src) {
					var nameAndVersion = grunt.template.process('<%= pkg.name %>-');
					return dest + nameAndVersion + src;
				},
				src: ['src/json/*.json'],
				dest: 'dist/'
			},
			htmlExample: {
				expand: true,
				flatten: true,
				src: 'src/example/*',
				dest: 'dist/example/'
			}
		},

		clean: {
			dist: ['dist/'],
			tmp: ['tmp/']
		},

		uglify: {
			dist: {
				files: {
					'dist/<%= pkg.name %>.min.js': '<%= concat.jsCustom.dest %>'
				}
			}
		},

		autoprefixer: {
			options: {
				browsers: '> 2% in CH'
			},
			css: {
				src: 'dist/<%= pkg.name %>.css'
			}
		},

		csslint: {
			options: {
				"adjoining-classes": false,
				"box-model": false,
				"box-sizing": false,
				"compatible-vendor-prefixes": false,
				"fallback-colors": false,
				"vendor-prefix": false,
				"namespaced": false,
				"important": false,
				"font-sizes": false,
				"universal-selector": false,
				"qualified-headings": false,
				"outline-none": false
			},
			dist: {
				src: ['dist/*.css']
			}
		},

		cssmin: {
			options: {
				keepSpecialComments: 0
			},
			target: {
				files: {
					'dist/<%= pkg.name %>.min.css': 'dist/<%= pkg.name %>.css'
				}
			}
		},

		watch: {
			options: {
				livereload: true
			},
			all: {
				files: ['src/**/*.*', 'example/*'],
				tasks: ['default']
			}
		},

		connect: {
			dist: {
				options: {
					port: 9000,
					base: 'dist/',
					open: 'http://<%= connect.dist.options.hostname %>:<%= connect.dist.options.port %>/example',
					hostname: 'localhost',
					livereload: true
				}
			}
		}

	});

	grunt.registerTask('default', [
		'clean',
		'htmlConvert:dev',
		'concat:jsCustom',
		'jshint:dev',
		'copy:jsCustom',
		'copy:libraries',
		'sass',
		'concat:css',
		'autoprefixer',
		'csslint',
		'copy:htmlExample',
		'copy:json',
		'clean:tmp'
	]);

	grunt.registerTask('productive', [
		'default',
		'minifyHtml:prod',
		'htmlConvert:prod',
		'concat:jsCustom',
		'jshint:dist',
		'uglify',
		'cssmin',
		'clean:tmp'
	]);

	grunt.registerTask('serve', [
		'default',
		'connect',
		'watch'
	]);
};<commit_msg>fix grunt file<commit_after>module.exports = function(grunt) {

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

	var jsCustom = [
		'src/js/head.js',
		'tmp/html/geochart.tpl.js',
		'src/js/map.js',
		'src/js/tail.js'
	];

	var libraries = [
		'bower_components/jquery/dist/jquery.min.js',
		'bower_components/jquery/dist/jquery.min.map',
		'bower_components/jquery-load-template/jquery-loadTemplate/jquery.loadTemplate-1.4.5.min.js',
		'bower_components/jScrollPane/script/jquery.mousewheel.js',
		'bower_components/jScrollPane/script/jquery.jscrollpane.min.js',
		'bower_components/jScrollPane/style/jquery.jscrollpane.css',
		'bower_components/d3/d3.min.js',
		'bower_components/topojson/topojson.js',
		'bower_components/moment/min/moment.min.js'
	];

	grunt.initConfig({

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

		minifyHtml: {
			options: {
				empty: true,
				loose: true,
				conditionals: true,
				quotes: true
			},
			prod: {
				files: [{
					expand: true,
					cwd: 'src/html/',
					src: ['*.html'],
					dest: 'tmp/html-not-concat',
				}]
			}
		},

		htmlConvert: {
			options: {
				quoteChar: '\'',
				module: 'htmlTemplate',
				indentString: '	',
				rename: function(moduleName) {
					return moduleName.replace('.html', '');
				}
			},
			dev: {
				options: {
					base: 'src/html/'
				},
				src: ['src/html/*.html'],
				dest: 'tmp/html/geochart.tpl.js'
			},
			prod: {
				options: {
					base: 'tmp/html-not-concat/'
				},
				src: ['tmp/html-not-concat/*.html'],
				dest: 'tmp/html/geochart.tpl.js'
			}
		},

		concat: {
			jsCustom: {
				options: {
					process: function(src, filepath) {
						if(filepath !== 'src/js/head.js' && filepath !== 'src/js/tail.js') {
							var lines = [];
							src.split('\n').forEach(function(line) {
								return lines.push((line.length > 0 ? '	' : '') + line);
							});
							src = lines.join('\n');
						}
						return src;
					}
				},
				src: jsCustom,
				dest: 'tmp/js/<%= pkg.name %>.js'
			},
			css: {
				src: ['tmp/styles/*.css'],
				dest: 'dist/<%= pkg.name %>.css'
			}
		},

		jshint: {
			options: {
				curly: true,
				eqeqeq: true,
				unused: true,
				bitwise: true,
				forin: true,
				freeze: true,
				undef: true,
			},
			dev: {
				options: {
					globals: {
						// console is allowed in dev mode
						console: true,
						window: true,
						document: true,
						d3: true,
						jQuery: true,
						topojson: true,
						moment: true
					}
				},
				src: ['<%= concat.jsCustom.dest %>']
			},
			dist: {
				options: {
					globals: {
						window: true,
						document: true,
						d3: true,
						jQuery: true,
						topojson: true,
						moment: true
					}
				},
				src: ['<%= concat.jsCustom.dest %>']
			}

		},

		sass: {
			dist: {
				files: [{
					expand: true,
					cwd: 'src/scss',
					src: ['*.{scss,sass}'],
					dest: 'tmp/styles',
					ext: '.css'
				}]
			}
		},

		copy: {
			jsCustom: {
				src: '<%= concat.jsCustom.dest %>',
				dest: 'dist/<%= pkg.name %>.js'
			},
			libraries: {
				expand: true,
				flatten: true,
				src: libraries,
				dest: 'dist/lib/'
			},
			json: {
				expand: true,
				flatten: true,
				rename: function(dest, src) {
					var nameAndVersion = grunt.template.process('<%= pkg.name %>-');
					return dest + nameAndVersion + src;
				},
				src: ['src/json/*.json'],
				dest: 'dist/'
			},
			htmlExample: {
				expand: true,
				flatten: true,
				src: 'src/example/*',
				dest: 'dist/example/'
			}
		},

		clean: {
			dist: ['dist/'],
			tmp: ['tmp/']
		},

		uglify: {
			dist: {
				files: {
					'dist/<%= pkg.name %>.min.js': '<%= concat.jsCustom.dest %>'
				}
			}
		},

		autoprefixer: {
			options: {
				browsers: '> 2% in CH'
			},
			css: {
				src: 'dist/<%= pkg.name %>.css'
			}
		},

		csslint: {
			options: {
				"adjoining-classes": false,
				"box-model": false,
				"box-sizing": false,
				"compatible-vendor-prefixes": false,
				"fallback-colors": false,
				"vendor-prefix": false,
				"namespaced": false,
				"important": false,
				"font-sizes": false,
				"universal-selector": false,
				"qualified-headings": false,
				"outline-none": false
			},
			dist: {
				src: ['dist/*.css']
			}
		},

		cssmin: {
			options: {
				keepSpecialComments: 0
			},
			target: {
				files: {
					'dist/<%= pkg.name %>.min.css': 'dist/<%= pkg.name %>.css'
				}
			}
		},

		watch: {
			options: {
				livereload: true
			},
			all: {
				files: ['src/**/*.*', 'example/*'],
				tasks: ['default']
			}
		},

		connect: {
			dist: {
				options: {
					port: 9000,
					base: 'dist/',
					open: 'http://<%= connect.dist.options.hostname %>:<%= connect.dist.options.port %>/example',
					hostname: 'localhost',
					livereload: true
				}
			}
		}

	});

	grunt.registerTask('default', [
		'clean',
		'htmlConvert:dev',
		'concat:jsCustom',
		'jshint:dev',
		'copy:jsCustom',
		'copy:libraries',
		'sass',
		'concat:css',
		'autoprefixer',
		'csslint',
		'copy:htmlExample',
		'copy:json',
		'clean:tmp'
	]);

	grunt.registerTask('productive', [
		'default',
		'minifyHtml:prod',
		'htmlConvert:prod',
		'concat:jsCustom',
		'jshint:dist',
		'uglify',
		'cssmin',
		'clean:tmp'
	]);

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


<commit_before>'use strict';

var _ = require('lodash');

module.exports = function(grunt) {

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

    var pkg = grunt.file.readJSON('package.json');
    var banner = _.template('/*! <%= pkg.title %> v<%= pkg.version %> - <%= pkg.description %>  <%= grunt.template.today("yyyy-mm-dd") %> \n\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n */\n')({ pkg: pkg, grunt: grunt });

    // Ignore webpack in node v5, until webpack is fixed for that version.
    var ignoreWebpack = process.version.substr(0, 'v5'.length) === 'v5';

    var js = {

        core: [
            'src/core.js',
            'src/joint.mvc.view.js',
            'src/joint.dia.graph.js',
            'src/joint.dia.cell.js',
            'src/joint.dia.element.js',
            'src/joint.dia.link.js',
            'src/joint.dia.paper.js',
            'plugins/shapes/joint.shapes.basic.js',
            'plugins/routers/joint.routers.orthogonal.js',
            'plugins/routers/joint.routers.manhattan.js',
            'plugins/routers/joint.routers.metro.js',
            'plugins/routers/joint.routers.oneSide.js',
            'plugins/connectors/joint.connectors.normal.js',
            'plugins/connectors/joint.connectors.rounded.js',
            'plugins/connectors/joint.connectors.smooth.js',
            'plugins/connectors/joint.connectors.jumpover.js'
        ],

        geometry: ['src/geometry.js'],
        vectorizer: ['src/vectorizer.js'],

        plugins: {

            'shapes.erd': ['plugins/shapes/joint.shapes.erd.js'],
            'shapes.fsa': ['plugins/shapes/joint.shapes.fsa.js'],
            'shapes.org': ['plugins/shapes/joint.shapes.org.js'],
            'shapes.chess': ['plugins/shapes/joint.shapes.chess.js'],
            'shapes.pn': ['plugins/shapes/joint.shapes.pn.js'],
            'shapes.devs': ['plugins/shapes/joint.shapes.devs.js'],
            'shapes.uml': ['plugins/shapes/joint.shapes.uml.js'],
            'shapes.logic': ['plugins/shapes/joint.shapes.logic.js'],

            'layout.DirectedGraph': ['plugins/layout/DirectedGraph/joint.layout.DirectedGraph.js']
        }
    };

    var css = {

        core: [
            'css/layout.css',
            'css/themes/*.css'
        ],

        plugins: {

        }
    };

    function allJSPlugins() {

        var ret = [];
        for (var name in js.plugins) {
            ret = ret.concat(js.plugins[name]);
        }
        return ret;
    }

    function allCSSPlugins() {

        var ret = [];
        for (var name in css.plugins) {
            ret = ret.concat(css.plugins[name]);
        }
        return ret;
    }

    function allMinifiedJSPlugins() {

        var files = [];

        for (var name in js.plugins) {
            files.push('build/min/joint.' + name + '.min.js');
        }

        return files;
    }

    function allMinifiedCSSPlugins() {

        var files = [];

        for (var name in css.plugins) {
            files.push('build/min/joint.' + name + '.min.css');
        }

        return files;
    }

    grunt.template.addDelimiters('square', '[%', '%]');

    var config = {

        pkg: pkg,

        webpack: {
            joint: {
                files: {
                   './build/joint.webpack-bundle.js' : './build/joint.min.js'
                },
                entry: './build/joint.min.js',
                output: {
                    path: './build/',
                    filename: 'joint.webpack-bundle.js',
                    library: 'joint'
                },
                resolve: {
                    alias: {
                        g: './geometry.min.js',
                        V: './vectorizer.min.js'
                    }
                }
            }
        },
        browserify: {
            joint: {
                files: {
                    'build/joint.browserify-bundle.js': 'build/joint.min.js'
                },
                options: {
                    browserifyOptions: {
                        standalone: 'joint'
                    }
                }
            }
        },
        clean: {
            dist: ['dist']
        },
        concat: {
            geometry: {
                files: {
                    'build/geometry.js': [].concat(
                        ['wrappers/geometry.head.js'],
                        js.geometry,
                        ['wrappers/geometry.foot.js']
                    ),
                    'build/geometry.min.js': [].concat(
                        ['wrappers/geometry.head.js'],
                        ['build/min/geometry.min.js'],
                        ['wrappers/geometry.foot.js']
                    )
                }
            },
            vectorizer: {
                files: {
                    'build/vectorizer.js': [].concat(
                        ['wrappers/vectorizer.head.js'],
                        js.vectorizer,
                        ['wrappers/vectorizer.foot.js']
                    ),
                    'build/vectorizer.min.js': [].concat(
                        ['wrappers/vectorizer.head.js'],
                        ['build/min/vectorizer.min.js'],
                        ['wrappers/vectorizer.foot.js']
                    )
                }
            },
            joint: {
                files: {
                    'build/joint.core.js': [].concat(
                        ['wrappers/joint.head.js'],
                        js.geometry,
                        js.vectorizer,
                        js.core,
                        ['wrappers/joint.foot.js']
                    ),
                    'build/joint.core.min.js': [].concat(
                        ['wrappers/joint.head.js'],
                        ['build/min/geometry.min.js'],
                        ['build/min/vectorizer.min.js'],
                        ['build/min/joint.min.js'],
                        ['wrappers/joint.foot.js']
                    ),
                    'build/joint.core.css': [].concat(
                        css.core
                    ),
                    'build/joint.core.min.css': [].concat(
                        ['build/min/joint.min.css']
                    ),
                    'build/joint.js': [].concat(
                        ['wrappers/joint.head.js'],
                        js.geometry,
                        js.vectorizer,
                        js.core,
                        allJSPlugins(),
                        ['wrappers/joint.foot.js']
                    ),
                    'build/joint.min.js': [].concat(
                        ['wrappers/joint.head.js'],
                        ['build/min/geometry.min.js'],
                        ['build/min/vectorizer.min.js'],
                        ['build/min/joint.min.js'],
                        allMinifiedJSPlugins(),
                        ['wrappers/joint.foot.js']
                    ),
                    'build/joint.css': [].concat(
                        css.core,
                        allCSSPlugins()
                    ),
                    'build/joint.min.css': [].concat(
                        ['build/min/joint.min.css'],
                        allMinifiedCSSPlugins()
                    ),
                    'build/joint.nowrap.js': [].concat(
                        js.geometry,
                        js.vectorizer,
                        js.core,
                        allJSPlugins()
                    ),
                    'build/joint.nowrap.min.js': [].concat(
                        ['build/min/geometry.min.js'],
                        ['build/min/vectorizer.min.js'],
                        ['build/min/joint.min.js'],
                        allMinifiedJSPlugins()
                    )
                }
            }
        },
        copy: {
            dist: {
                files: [{
                    nonull: true,
                    expand: true,
                    cwd: 'build/',
                    src: [
                        '*',
                        '!min'
                    ],
                    dest: 'dist/'
                }],
                options: {
                    process: function(content) {
                        // Add JointJS banner to all distribution files.
                        return banner + content;
                    }
                }
            }
        },
        cssmin: {
            joint: {
                files: {
                    'build/min/joint.min.css': [].concat(
                        css.core
                    )
                }
            }
        },
        jscs: {
            options: {
                config: '.jscsrc'
            },
            src: [
                // All plugins:
                'plugins/**/*.js',

                // Ignore third-party dependencies in plugins:
                '!plugins/**/lib/**/*.js',

                // Core jointjs:
                'src/**/*.js',

                // Tests:
                'test/**/*.js'
            ]
        },
        mochaTest: {
            server: {
                src: [
                    'test/*-nodejs/*'
                ],
                options: {
                    reporter: 'spec'
                }
            }
        },
        qunit: {
            all: [
                'test/**/*.html',
                '!test/**/coverage.html'
            ],
            all_coverage: ['test/**/coverage.html'],
            joint: [
                'test/jointjs/*.html',
                '!test/jointjs/coverage.html'
            ],
            joint_coverage: ['test/jointjs/coverage.html'],
            geometry: ['test/geometry/*.html'],
            vectorizer: ['test/vectorizer/*.html']
        },
        shell: {

            /*
                Run `bower install` in the context of the given directory.
            */
            bowerInstall: {
                command: function(dir, environment) {

                    var flags = environment && environment === 'production' ? ' --production': '';
                    var cmd = 'cd ' + dir + ' && bower --allow-root install' + flags;

                    return cmd;
                }
            }
        },
        uglify: {
            geometry: {
                src: js.geometry,
                dest: 'build/min/geometry.min.js'
            },
            joint: {
                src: js.core,
                dest: 'build/min/joint.min.js'
            },
            vectorizer: {
                src: js.vectorizer,
                dest: 'build/min/vectorizer.min.js'
            }
        },
        watch: {
            joint: {
                files: [].concat(
                    js.geometry,
                    js.vectorizer,
                    js.core,
                    allJSPlugins(),
                    css.core,
                    allCSSPlugins()
                ),
                tasks: ['build']
            }
        }
    };

    if (ignoreWebpack) {
        config.qunit.all.push('!test/**/webpack.html');
        config.qunit.joint.push('!test/jointjs/webpack.html');
    }

    function enableCodeCoverage() {

        // Replace all qunit configurations with the 'urls' method.
        // Append all URLs with ?coverage=true&grunt
        // This will run all qunit tests with test coverage enabled and report results back to grunt.

        var reporter = grunt.option('reporter') || 'lcov';

        // Serve up the test files via an express app.
        var express = require('express');
        var serveStatic = require('serve-static');
        var app = express();
        var host = 'localhost';
        var port = 3000;

        app.use('/', serveStatic(__dirname));
        app.listen(port, host);

        var name, files;

        for (name in config.qunit) {

            // Resolve the paths for all files referenced in the task.
            files = grunt.file.expand(config.qunit[name + '_coverage'] || config.qunit[name]);

            config.qunit[name] = { options: { urls: [] } };

            files.forEach(function(file) {

                var url = 'http://' + host + ':' + port + '/' + file + '?coverage=true&reporter=' + reporter;

                config.qunit[name].options.urls.push(url);
            });
        }

        var reporterToFileExtension = {
            lcov: 'info'
        };

        var reports = [];

        grunt.event.on('qunit.report', function(data) {

            reports.push(data);
        });

        var fs = require('fs');

        process.on('exit', function() {

            var ext = reporterToFileExtension[reporter];
            var outputFile = grunt.option('output') || 'coverage' + (ext ? '.' + ext : '');
            var data;

            switch (reporter) {
                case 'lcov':
                    data = reports.join('\n');
                break;
            }

            fs.writeFileSync(outputFile, data);
        });
    }

    // Create targets for all the plugins.
    Object.keys(js.plugins).forEach(function(name) {

        config.concat[name] = { files: {} };
        config.uglify[name] = { files: {} };

        config.uglify[name].files['build/min/joint.' + name + '.min.js'] = js.plugins[name];
        config.concat[name].files['build/joint.' + name + '.js'] = js.plugins[name];
        config.concat[name].files['build/joint.' + name + '.min.js'] = ['build/min/joint.' + name + '.min.js'];

        if (css.plugins[name]) {

            config.cssmin[name] = { files: {} };
            config.cssmin[name].files['build/min/joint.' + name + '.min.css'] = css.plugins[name];
            config.concat[name].files['build/joint.' + name + '.css'] = css.plugins[name];
            config.concat[name].files['build/joint.' + name + '.min.css'] = ['build/min/joint.' + name + '.min.css'];
        }
    });

    grunt.initConfig(config);

    var allPluginTasks = {
        concat: [],
        cssmin: [],
        uglify: []
    };

    // Register tasks for all the plugins.
    Object.keys(js.plugins).forEach(function(name) {

        var pluginTasks = [
            'newer:concat:' + name,
            'newer:uglify:' + name
        ];

        allPluginTasks.concat.push('newer:concat:' + name);
        allPluginTasks.uglify.push('newer:uglify:' + name);

        if (css.plugins[name]) {
            pluginTasks.push('newer:cssmin:' + name);
            allPluginTasks.cssmin.push('newer:cssmin:' + name);
        }

        grunt.registerTask(name, pluginTasks);
    });

    if (grunt.option('coverage')) {
        enableCodeCoverage();
    }

    grunt.registerTask('concat:plugins', allPluginTasks.concat);
    grunt.registerTask('cssmin:plugins', allPluginTasks.cssmin);
    grunt.registerTask('uglify:plugins', allPluginTasks.uglify);

    grunt.registerTask('build:plugins', [
        'uglify:plugins',
        'cssmin:plugins',
        'concat:plugins'
    ]);

    grunt.registerTask('build:joint', [
        'build:plugins',
        'newer:uglify:geometry',
        'newer:uglify:vectorizer',
        'newer:uglify:joint',
        'newer:cssmin:joint',
        'newer:concat:geometry',
        'newer:concat:vectorizer',
        'newer:concat:joint'
    ]);

    grunt.registerTask('build', ['build:joint']);

    grunt.registerTask('build:bundles', ignoreWebpack ? [
        'newer:browserify'
    ] : [
        'newer:browserify',
        'newer:webpack'
    ]);

    grunt.registerTask('build:all', [
        'build:joint',
        'build:bundles'
    ]);

    grunt.registerTask('dist', [
        'build:all',
        'clean:dist',
        'copy:dist'
    ]);

    grunt.registerTask('test:server', ['mochaTest:server']);
    grunt.registerTask('test:client', ['qunit:all']);
    grunt.registerTask('test:code-style', ['jscs']);
    grunt.registerTask('test', ['test:server', 'test:client', 'test:code-style']);

    grunt.registerTask('bowerInstall', [
        'shell:bowerInstall:.'
    ]);

    grunt.registerTask('install', ['bowerInstall', 'build:all']);
    grunt.registerTask('default', ['install', 'build', 'watch']);
};
<commit_msg>Add hard-coded joint version number to build files.<commit_after>'use strict';

module.exports = function(grunt) {

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

    grunt.template.addDelimiters('square', '[%', '%]');

    var pkg = grunt.file.readJSON('package.json');
    var banner = grunt.template.process('/*! <%= pkg.title %> v<%= pkg.version %> - <%= pkg.description %>  <%= grunt.template.today("yyyy-mm-dd") %> \n\n\nThis Source Code Form is subject to the terms of the Mozilla Public\nLicense, v. 2.0. If a copy of the MPL was not distributed with this\nfile, You can obtain one at http://mozilla.org/MPL/2.0/.\n */\n', { data: { pkg: pkg }, delimiter: 'default' });

    // Ignore webpack in node v5, until webpack is fixed for that version.
    var ignoreWebpack = process.version.substr(0, 'v5'.length) === 'v5';

    var js = {

        core: [
            'src/core.js',
            'src/joint.mvc.view.js',
            'src/joint.dia.graph.js',
            'src/joint.dia.cell.js',
            'src/joint.dia.element.js',
            'src/joint.dia.link.js',
            'src/joint.dia.paper.js',
            'plugins/shapes/joint.shapes.basic.js',
            'plugins/routers/joint.routers.orthogonal.js',
            'plugins/routers/joint.routers.manhattan.js',
            'plugins/routers/joint.routers.metro.js',
            'plugins/routers/joint.routers.oneSide.js',
            'plugins/connectors/joint.connectors.normal.js',
            'plugins/connectors/joint.connectors.rounded.js',
            'plugins/connectors/joint.connectors.smooth.js',
            'plugins/connectors/joint.connectors.jumpover.js'
        ],

        geometry: ['src/geometry.js'],
        vectorizer: ['src/vectorizer.js'],

        plugins: {

            'shapes.erd': ['plugins/shapes/joint.shapes.erd.js'],
            'shapes.fsa': ['plugins/shapes/joint.shapes.fsa.js'],
            'shapes.org': ['plugins/shapes/joint.shapes.org.js'],
            'shapes.chess': ['plugins/shapes/joint.shapes.chess.js'],
            'shapes.pn': ['plugins/shapes/joint.shapes.pn.js'],
            'shapes.devs': ['plugins/shapes/joint.shapes.devs.js'],
            'shapes.uml': ['plugins/shapes/joint.shapes.uml.js'],
            'shapes.logic': ['plugins/shapes/joint.shapes.logic.js'],

            'layout.DirectedGraph': ['plugins/layout/DirectedGraph/joint.layout.DirectedGraph.js']
        }
    };

    var css = {

        core: [
            'css/layout.css',
            'css/themes/*.css'
        ],

        plugins: {

        }
    };

    function allJSPlugins() {

        var ret = [];
        for (var name in js.plugins) {
            ret = ret.concat(js.plugins[name]);
        }
        return ret;
    }

    function allCSSPlugins() {

        var ret = [];
        for (var name in css.plugins) {
            ret = ret.concat(css.plugins[name]);
        }
        return ret;
    }

    function allMinifiedJSPlugins() {

        var files = [];

        for (var name in js.plugins) {
            files.push('build/min/joint.' + name + '.min.js');
        }

        return files;
    }

    function allMinifiedCSSPlugins() {

        var files = [];

        for (var name in css.plugins) {
            files.push('build/min/joint.' + name + '.min.css');
        }

        return files;
    }

    var config = {

        pkg: pkg,

        webpack: {
            joint: {
                files: {
                   './build/joint.webpack-bundle.js' : './build/joint.min.js'
                },
                entry: './build/joint.min.js',
                output: {
                    path: './build/',
                    filename: 'joint.webpack-bundle.js',
                    library: 'joint'
                },
                resolve: {
                    alias: {
                        g: './geometry.min.js',
                        V: './vectorizer.min.js'
                    }
                }
            }
        },
        browserify: {
            joint: {
                files: {
                    'build/joint.browserify-bundle.js': 'build/joint.min.js'
                },
                options: {
                    browserifyOptions: {
                        standalone: 'joint'
                    }
                }
            }
        },
        clean: {
            dist: ['dist']
        },
        concat: {
            geometry: {
                files: {
                    'build/geometry.js': [].concat(
                        ['wrappers/geometry.head.js'],
                        js.geometry,
                        ['wrappers/geometry.foot.js']
                    ),
                    'build/geometry.min.js': [].concat(
                        ['wrappers/geometry.head.js'],
                        ['build/min/geometry.min.js'],
                        ['wrappers/geometry.foot.js']
                    )
                }
            },
            vectorizer: {
                files: {
                    'build/vectorizer.js': [].concat(
                        ['wrappers/vectorizer.head.js'],
                        js.vectorizer,
                        ['wrappers/vectorizer.foot.js']
                    ),
                    'build/vectorizer.min.js': [].concat(
                        ['wrappers/vectorizer.head.js'],
                        ['build/min/vectorizer.min.js'],
                        ['wrappers/vectorizer.foot.js']
                    )
                }
            },
            joint: {
                options: {
                    process: {
                        options: {
                            data: pkg,
                        },
                        delimiters: 'square'
                    }
                },
                files: {
                    'build/joint.core.js': [].concat(
                        ['wrappers/joint.head.js'],
                        js.geometry,
                        js.vectorizer,
                        js.core,
                        ['wrappers/joint.foot.js']
                    ),
                    'build/joint.core.min.js': [].concat(
                        ['wrappers/joint.head.js'],
                        ['build/min/geometry.min.js'],
                        ['build/min/vectorizer.min.js'],
                        ['build/min/joint.min.js'],
                        ['wrappers/joint.foot.js']
                    ),
                    'build/joint.core.css': [].concat(
                        css.core
                    ),
                    'build/joint.core.min.css': [].concat(
                        ['build/min/joint.min.css']
                    ),
                    'build/joint.js': [].concat(
                        ['wrappers/joint.head.js'],
                        js.geometry,
                        js.vectorizer,
                        js.core,
                        allJSPlugins(),
                        ['wrappers/joint.foot.js']
                    ),
                    'build/joint.min.js': [].concat(
                        ['wrappers/joint.head.js'],
                        ['build/min/geometry.min.js'],
                        ['build/min/vectorizer.min.js'],
                        ['build/min/joint.min.js'],
                        allMinifiedJSPlugins(),
                        ['wrappers/joint.foot.js']
                    ),
                    'build/joint.css': [].concat(
                        css.core,
                        allCSSPlugins()
                    ),
                    'build/joint.min.css': [].concat(
                        ['build/min/joint.min.css'],
                        allMinifiedCSSPlugins()
                    ),
                    'build/joint.nowrap.js': [].concat(
                        js.geometry,
                        js.vectorizer,
                        js.core,
                        allJSPlugins()
                    ),
                    'build/joint.nowrap.min.js': [].concat(
                        ['build/min/geometry.min.js'],
                        ['build/min/vectorizer.min.js'],
                        ['build/min/joint.min.js'],
                        allMinifiedJSPlugins()
                    )
                }
            }
        },
        copy: {
            dist: {
                files: [{
                    nonull: true,
                    expand: true,
                    cwd: 'build/',
                    src: [
                        '*',
                        '!min'
                    ],
                    dest: 'dist/'
                }],
                options: {
                    process: function(content) {
                        // Add JointJS banner to all distribution files.
                        return banner + content;
                    }
                }
            }
        },
        cssmin: {
            joint: {
                files: {
                    'build/min/joint.min.css': [].concat(
                        css.core
                    )
                }
            }
        },
        jscs: {
            options: {
                config: '.jscsrc'
            },
            src: [
                // All plugins:
                'plugins/**/*.js',

                // Ignore third-party dependencies in plugins:
                '!plugins/**/lib/**/*.js',

                // Core jointjs:
                'src/**/*.js',

                // Tests:
                'test/**/*.js'
            ]
        },
        mochaTest: {
            server: {
                src: [
                    'test/*-nodejs/*'
                ],
                options: {
                    reporter: 'spec'
                }
            }
        },
        qunit: {
            all: [
                'test/**/*.html',
                '!test/**/coverage.html'
            ],
            all_coverage: ['test/**/coverage.html'],
            joint: [
                'test/jointjs/*.html',
                '!test/jointjs/coverage.html'
            ],
            joint_coverage: ['test/jointjs/coverage.html'],
            geometry: ['test/geometry/*.html'],
            vectorizer: ['test/vectorizer/*.html']
        },
        shell: {

            /*
                Run `bower install` in the context of the given directory.
            */
            bowerInstall: {
                command: function(dir, environment) {

                    var flags = environment && environment === 'production' ? ' --production': '';
                    var cmd = 'cd ' + dir + ' && bower --allow-root install' + flags;

                    return cmd;
                }
            }
        },
        uglify: {
            geometry: {
                src: js.geometry,
                dest: 'build/min/geometry.min.js'
            },
            joint: {
                src: js.core,
                dest: 'build/min/joint.min.js'
            },
            vectorizer: {
                src: js.vectorizer,
                dest: 'build/min/vectorizer.min.js'
            }
        },
        watch: {
            joint: {
                files: [].concat(
                    js.geometry,
                    js.vectorizer,
                    js.core,
                    allJSPlugins(),
                    css.core,
                    allCSSPlugins()
                ),
                tasks: ['build']
            }
        }
    };

    if (ignoreWebpack) {
        config.qunit.all.push('!test/**/webpack.html');
        config.qunit.joint.push('!test/jointjs/webpack.html');
    }

    function enableCodeCoverage() {

        // Replace all qunit configurations with the 'urls' method.
        // Append all URLs with ?coverage=true&grunt
        // This will run all qunit tests with test coverage enabled and report results back to grunt.

        var reporter = grunt.option('reporter') || 'lcov';

        // Serve up the test files via an express app.
        var express = require('express');
        var serveStatic = require('serve-static');
        var app = express();
        var host = 'localhost';
        var port = 3000;

        app.use('/', serveStatic(__dirname));
        app.listen(port, host);

        var name, files;

        for (name in config.qunit) {

            // Resolve the paths for all files referenced in the task.
            files = grunt.file.expand(config.qunit[name + '_coverage'] || config.qunit[name]);

            config.qunit[name] = { options: { urls: [] } };

            files.forEach(function(file) {

                var url = 'http://' + host + ':' + port + '/' + file + '?coverage=true&reporter=' + reporter;

                config.qunit[name].options.urls.push(url);
            });
        }

        var reporterToFileExtension = {
            lcov: 'info'
        };

        var reports = [];

        grunt.event.on('qunit.report', function(data) {

            reports.push(data);
        });

        var fs = require('fs');

        process.on('exit', function() {

            var ext = reporterToFileExtension[reporter];
            var outputFile = grunt.option('output') || 'coverage' + (ext ? '.' + ext : '');
            var data;

            switch (reporter) {
                case 'lcov':
                    data = reports.join('\n');
                break;
            }

            fs.writeFileSync(outputFile, data);
        });
    }

    // Create targets for all the plugins.
    Object.keys(js.plugins).forEach(function(name) {

        config.concat[name] = { files: {} };
        config.uglify[name] = { files: {} };

        config.uglify[name].files['build/min/joint.' + name + '.min.js'] = js.plugins[name];
        config.concat[name].files['build/joint.' + name + '.js'] = js.plugins[name];
        config.concat[name].files['build/joint.' + name + '.min.js'] = ['build/min/joint.' + name + '.min.js'];

        if (css.plugins[name]) {

            config.cssmin[name] = { files: {} };
            config.cssmin[name].files['build/min/joint.' + name + '.min.css'] = css.plugins[name];
            config.concat[name].files['build/joint.' + name + '.css'] = css.plugins[name];
            config.concat[name].files['build/joint.' + name + '.min.css'] = ['build/min/joint.' + name + '.min.css'];
        }
    });

    grunt.initConfig(config);

    var allPluginTasks = {
        concat: [],
        cssmin: [],
        uglify: []
    };

    // Register tasks for all the plugins.
    Object.keys(js.plugins).forEach(function(name) {

        var pluginTasks = [
            'newer:concat:' + name,
            'newer:uglify:' + name
        ];

        allPluginTasks.concat.push('newer:concat:' + name);
        allPluginTasks.uglify.push('newer:uglify:' + name);

        if (css.plugins[name]) {
            pluginTasks.push('newer:cssmin:' + name);
            allPluginTasks.cssmin.push('newer:cssmin:' + name);
        }

        grunt.registerTask(name, pluginTasks);
    });

    if (grunt.option('coverage')) {
        enableCodeCoverage();
    }

    grunt.registerTask('concat:plugins', allPluginTasks.concat);
    grunt.registerTask('cssmin:plugins', allPluginTasks.cssmin);
    grunt.registerTask('uglify:plugins', allPluginTasks.uglify);

    grunt.registerTask('build:plugins', [
        'uglify:plugins',
        'cssmin:plugins',
        'concat:plugins'
    ]);

    grunt.registerTask('build:joint', [
        'build:plugins',
        'newer:uglify:geometry',
        'newer:uglify:vectorizer',
        'newer:uglify:joint',
        'newer:cssmin:joint',
        'newer:concat:geometry',
        'newer:concat:vectorizer',
        'newer:concat:joint'
    ]);

    grunt.registerTask('build', ['build:joint']);

    grunt.registerTask('build:bundles', ignoreWebpack ? [
        'newer:browserify'
    ] : [
        'newer:browserify',
        'newer:webpack'
    ]);

    grunt.registerTask('build:all', [
        'build:joint',
        'build:bundles'
    ]);

    grunt.registerTask('dist', [
        'build:all',
        'clean:dist',
        'copy:dist'
    ]);

    grunt.registerTask('test:server', ['mochaTest:server']);
    grunt.registerTask('test:client', ['qunit:all']);
    grunt.registerTask('test:code-style', ['jscs']);
    grunt.registerTask('test', ['test:server', 'test:client', 'test:code-style']);

    grunt.registerTask('bowerInstall', [
        'shell:bowerInstall:.'
    ]);

    grunt.registerTask('install', ['bowerInstall', 'build:all']);
    grunt.registerTask('default', ['install', 'build', 'watch']);
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		// Metadata.
		pkg: grunt.file.readJSON('launchly-cart.jquery.json'),
		banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
			'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
			'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
			'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
			' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
		// Task configuration.
		clean: {
			files: ['dist', 'build']
		},
		concat: {
			options: {
				banner: '<%= banner %>',
				stripBanners: true
			},
			dist: {
				src: ['src/js/cart.js', 'src/js/events/*.js', 'src/js/handlers/*.js', 'src/js/initialise.js'],
				dest: 'dist/<%= pkg.name %>.js'
			},
			templates: {
				src: ['src/templates/*.html'],
				dest: 'dist/<%= pkg.name %>.templates.html'
			}
		},
		uglify: {
			options: {
				banner: '<%= banner %>'
			},
			dist: {
				src: '<%= concat.dist.dest %>',
				dest: 'dist/<%= pkg.name %>.min.js'
			}
		},
		qunit: {
			files: ['test/**/*.html']
		},
		jshint: {
			gruntfile: {
				options: {
					jshintrc: '.jshintrc'
				},
				src: 'Gruntfile.js'
			},
			src: {
				options: {
					jshintrc: 'src/.jshintrc'
				},
				src: ['src/js/**/*.js', 'src/events/**/*.js']
			},
			test: {
				options: {
					jshintrc: 'test/.jshintrc'
				},
				src: ['test/**/*.js']
			}
		},
		watch: {
			gruntfile: {
				files: '<%= jshint.gruntfile.src %>',
				tasks: ['jshint:gruntfile']
			},
			src: {
				files: '<%= jshint.src.src %>',
				tasks: ['jshint:src', 'qunit']
			},
			test: {
				files: '<%= jshint.test.src %>',
				tasks: ['jshint:test', 'qunit']
			}
		},
		less: {
			development: {
				files: {
					'dist/cart.css': 'src/less/cart.less'
				}
			},
			production: {
				options: {
					cleancss: true
				},
				files: {
					'dist/cart.min.css': 'src/less/cart.less'
				}
			}
		}
	});

	// These plugins provide necessary tasks.
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-less');

	// Default task.
//	grunt.registerTask('default', ['jshint', 'qunit', 'clean', 'concat', 'uglify']);
	grunt.registerTask('default', ['jshint', 'clean', 'concat', 'uglify', 'less']);
};<commit_msg>Banner change<commit_after>'use strict';

module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		// Metadata.
		pkg: grunt.file.readJSON('launchly-cart.jquery.json'),
		banner: '/* <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
			'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
			'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
			' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
			' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n\n',
		// Task configuration.
		clean: {
			files: ['dist']
		},
		concat: {
			options: {
				banner: '<%= banner %>',
				stripBanners: true
			},
			dist: {
				src: ['src/js/cart.js', 'src/js/events/*.js', 'src/js/handlers/*.js', 'src/js/initialise.js'],
				dest: 'dist/<%= pkg.name %>.js'
			},
			templates: {
				src: ['src/templates/*.html'],
				dest: 'dist/<%= pkg.name %>.templates.html'
			}
		},
		uglify: {
			options: {
				banner: '<%= banner %>'
			},
			dist: {
				src: '<%= concat.dist.dest %>',
				dest: 'dist/<%= pkg.name %>.min.js'
			}
		},
		qunit: {
			files: ['test/**/*.html']
		},
		jshint: {
			gruntfile: {
				options: {
					jshintrc: '.jshintrc'
				},
				src: 'Gruntfile.js'
			},
			src: {
				options: {
					jshintrc: 'src/.jshintrc'
				},
				src: ['src/js/**/*.js', 'src/events/**/*.js']
			},
			test: {
				options: {
					jshintrc: 'test/.jshintrc'
				},
				src: ['test/**/*.js']
			}
		},
		watch: {
			gruntfile: {
				files: '<%= jshint.gruntfile.src %>',
				tasks: ['jshint:gruntfile']
			},
			src: {
				files: '<%= jshint.src.src %>',
				tasks: ['jshint:src', 'qunit']
			},
			test: {
				files: '<%= jshint.test.src %>',
				tasks: ['jshint:test', 'qunit']
			}
		},
		less: {
			development: {
				files: {
					'dist/cart.css': 'src/less/cart.less'
				}
			},
			production: {
				options: {
					cleancss: true
				},
				files: {
					'dist/cart.min.css': 'src/less/cart.less'
				}
			}
		}
	});

	// These plugins provide necessary tasks.
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-qunit');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-less');

	// Default task.
//	grunt.registerTask('default', ['jshint', 'qunit', 'clean', 'concat', 'uglify']);
	grunt.registerTask('default', ['jshint', 'clean', 'concat', 'uglify', 'less']);
};<|endoftext|>


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

  // Package configuration
  grunt.initConfig({

    // Metadata
    pkg: grunt.file.readJSON('package.json'),

    sass: {
      dist: {
        options: {
          style: 'compressed'
        },
        files: {
          'stylesheets/style.min.css' : 'stylesheets/style.scss'
        }
      },
      dev: {
        options: {
          style: 'expanded'
        },
          files: {
            'stylesheets/style.css': 'stylesheets/style.scss'
        }
      }
    },

    exec: {
      build: {
        cmd: 'jekyll build'
      },
      serve: {
        cmd: 'jekyll serve --watch'
      }
    },

    watch: {
      css: {
        files: '**/*.scss',
        tasks: ['sass']
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-exec');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // Default task(s).
  grunt.registerTask('default', ['sass', 'exec:serve']);

};
<commit_msg>sass watch only stylguide folder<commit_after>module.exports = function (grunt) {

  // Package configuration
  grunt.initConfig({

    // Metadata
    pkg: grunt.file.readJSON('package.json'),

    sass: {
      dist: {
        options: {
          style: 'compressed'
        },
        files: {
          'stylesheets/style.min.css' : 'stylesheets/style.scss'
        }
      },
      dev: {
        options: {
          style: 'expanded'
        },
          files: {
            'stylesheets/style.css': 'stylesheets/style.scss'
        }
      }
    },

    exec: {
      build: {
        cmd: 'jekyll build'
      },
      serve: {
        cmd: 'jekyll serve --watch'
      }
    },

    watch: {
      css: {
        files: 'stylesheets/**/*.scss',
        tasks: ['sass']
      }
    }

  });

  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-exec');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // Default task(s).
  grunt.registerTask('default', ['sass', 'exec:serve']);

};
<|endoftext|>


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

  /**
   * read optional JSON from filepath
   * @param {String} filepath
   * @return {Object}
   */
  var readOptionalJSON = function (filepath) {
    var data = {};
    try {
      data = grunt.file.readJSON(filepath);
      // The concatenated file won't pass onevar
      // But our modules can
      delete data.onever;
    } catch (e) { }
    return data;
  };

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

    // bulid source(grunt-build.js).
    build: {
      all: {
        baseUrl: 'src/js',        // base url
        startFile: 'intro.js',    // intro part
        endFile: 'outro.js',      // outro part
        outFile: 'dist/summernote.js' // out file
      }
    },

    // for javascript convention.
    jshint: {
      all: {
        src: [
          'src/**/*.js',
          'plugin/**/*.js',
          'lang/**/*.js',
          'Gruntfile.js',
          'test/**/*.js',
          'build/*.js'
        ],
        options: {
          jshintrc: true
        }
      },
      dist: {
        src: 'dist/summernote.js',
        options: readOptionalJSON('.jshintrc')
      }
    },

    // qunit: javascript unit test.
    qunit: {
      all: [ 'test/*.html' ]
    },

    // uglify: minify javascript
    uglify: {
      options: {
        banner: '/*! Summernote v<%=pkg.version%> | (c) 2013-2015 Alan Hong and other contributors | MIT license */\n'
      },
      all: {
        files: { 'dist/summernote.min.js': ['dist/summernote.js'] }
      }
    },

    // recess: minify stylesheets
    recess: {
      dist: {
        options: { compile: true, compress: true },
        files: {
          'dist/summernote.css': ['src/less/summernote.less']
        }
      }
    },

    // compress: summernote-{{version}}-dist.zip
    compress: {
      main: {
        options: {
          archive: function () {
            return 'dist/summernote-{{version}}-dist.zip'.replace(
              '{{version}}',
              grunt.config('pkg.version')
            );
          }
        },
        files: [{
          expand: true,
          src: [
            'dist/*.js',
            'dist/summernote.css'
          ]
        }, {
          src: ['plugin/*.js'],
          dest: 'dist/'
        }]
      }
    },

    // connect configuration.
    connect: {
      all: {
        options: {
          port: 3000,
          livereload: true,
          middleware: function (connect, options, middlewares) {
            var base = options.base[0];
            middlewares = middlewares || [];
            return middlewares.concat([
              require('connect-livereload')(), // livereload middleware
              connect['static'](base),    // serve static files
              connect.directory(base)  // make empty directories browsable
            ]);
          }
        }
      }
    },

    // watch source code change
    watch: {
      all: {
        files: ['src/less/*.less', 'src/js/**/*.js'],
        tasks: ['recess', 'jshint', 'qunit'],
        options: {
          livereload: true
        }
      }
    },

    // Meteor commands to test and publish package
    exec: {
      'meteor-test': {
        command: 'meteor/runtests.sh'
      },
      'meteor-publish': {
        command: 'meteor/publish.sh'
      }
    },

    'saucelabs-qunit': {
      'all': {
        options: {
          urls: ['http://localhost:3000/test/unit.html'],
          build: process.env.CI_BUILD_NUMBER,
          browsers: [{
            browserName: 'firefox',
            version: '38',
            platform: 'windows 8'
          }],
          testname: 'qunit tests',
          tags: ['master']
        }
      }
    }
  });

  // load all tasks from the grunt plugins used in this file
  require('load-grunt-tasks')(grunt);

  // load all grunts/*.js
  grunt.loadTasks('grunts');

  // server: runt server for development
  grunt.registerTask('server', ['connect', 'watch']);

  // test: unit test on test folder
  grunt.registerTask('test', ['jshint', 'qunit']);

  // test: saucelab test
  grunt.registerTask('saucelab-test', ['connect', 'saucelabs-qunit']);

  // dist: make dist files
  grunt.registerTask('dist', ['build', 'test', 'uglify', 'recess']);

  // deploy: compress dist files
  grunt.registerTask('deploy', ['dist', 'compress']);

  // default: server
  grunt.registerTask('default', ['server']);

  // Meteor tasks
  grunt.registerTask('meteor-test', 'exec:meteor-test');
  grunt.registerTask('meteor-publish', 'exec:meteor-publish');
  grunt.registerTask('meteor', ['meteor-test', 'meteor-publish']);

};
<commit_msg>Fixed typo sauce labs test.<commit_after>module.exports = function (grunt) {
  'use strict';

  /**
   * read optional JSON from filepath
   * @param {String} filepath
   * @return {Object}
   */
  var readOptionalJSON = function (filepath) {
    var data = {};
    try {
      data = grunt.file.readJSON(filepath);
      // The concatenated file won't pass onevar
      // But our modules can
      delete data.onever;
    } catch (e) { }
    return data;
  };

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

    // bulid source(grunt-build.js).
    build: {
      all: {
        baseUrl: 'src/js',        // base url
        startFile: 'intro.js',    // intro part
        endFile: 'outro.js',      // outro part
        outFile: 'dist/summernote.js' // out file
      }
    },

    // for javascript convention.
    jshint: {
      all: {
        src: [
          'src/**/*.js',
          'plugin/**/*.js',
          'lang/**/*.js',
          'Gruntfile.js',
          'test/**/*.js',
          'build/*.js'
        ],
        options: {
          jshintrc: true
        }
      },
      dist: {
        src: 'dist/summernote.js',
        options: readOptionalJSON('.jshintrc')
      }
    },

    // qunit: javascript unit test.
    qunit: {
      all: [ 'test/*.html' ]
    },

    // uglify: minify javascript
    uglify: {
      options: {
        banner: '/*! Summernote v<%=pkg.version%> | (c) 2013-2015 Alan Hong and other contributors | MIT license */\n'
      },
      all: {
        files: { 'dist/summernote.min.js': ['dist/summernote.js'] }
      }
    },

    // recess: minify stylesheets
    recess: {
      dist: {
        options: { compile: true, compress: true },
        files: {
          'dist/summernote.css': ['src/less/summernote.less']
        }
      }
    },

    // compress: summernote-{{version}}-dist.zip
    compress: {
      main: {
        options: {
          archive: function () {
            return 'dist/summernote-{{version}}-dist.zip'.replace(
              '{{version}}',
              grunt.config('pkg.version')
            );
          }
        },
        files: [{
          expand: true,
          src: [
            'dist/*.js',
            'dist/summernote.css'
          ]
        }, {
          src: ['plugin/*.js'],
          dest: 'dist/'
        }]
      }
    },

    // connect configuration.
    connect: {
      all: {
        options: {
          port: 3000,
          livereload: true,
          middleware: function (connect, options, middlewares) {
            var base = options.base[0];
            middlewares = middlewares || [];
            return middlewares.concat([
              require('connect-livereload')(), // livereload middleware
              connect['static'](base),    // serve static files
              connect.directory(base)  // make empty directories browsable
            ]);
          }
        }
      }
    },

    // watch source code change
    watch: {
      all: {
        files: ['src/less/*.less', 'src/js/**/*.js'],
        tasks: ['recess', 'jshint', 'qunit'],
        options: {
          livereload: true
        }
      }
    },

    // Meteor commands to test and publish package
    exec: {
      'meteor-test': {
        command: 'meteor/runtests.sh'
      },
      'meteor-publish': {
        command: 'meteor/publish.sh'
      }
    },

    'saucelabs-qunit': {
      'all': {
        options: {
          urls: ['http://localhost:3000/test/unit.html'],
          build: process.env.CI_BUILD_NUMBER,
          browsers: [{
            browserName: 'firefox',
            version: '38',
            platform: 'windows 8'
          }],
          testname: 'qunit tests',
          tags: ['master']
        }
      }
    }
  });

  // load all tasks from the grunt plugins used in this file
  require('load-grunt-tasks')(grunt);

  // load all grunts/*.js
  grunt.loadTasks('grunts');

  // server: runt server for development
  grunt.registerTask('server', ['connect', 'watch']);

  // test: unit test on test folder
  grunt.registerTask('test', ['jshint', 'qunit']);

  // test: saucelab test
  grunt.registerTask('saucelabs-test', ['connect', 'saucelabs-qunit']);

  // dist: make dist files
  grunt.registerTask('dist', ['build', 'test', 'uglify', 'recess']);

  // deploy: compress dist files
  grunt.registerTask('deploy', ['dist', 'compress']);

  // default: server
  grunt.registerTask('default', ['server']);

  // Meteor tasks
  grunt.registerTask('meteor-test', 'exec:meteor-test');
  grunt.registerTask('meteor-publish', 'exec:meteor-publish');
  grunt.registerTask('meteor', ['meteor-test', 'meteor-publish']);

};
<|endoftext|>