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

    var pathModule = require("path");

    var outDir = "./dist";
    var rootDir = ".";

    var args = {
        metadataDir: grunt.option("metadataDir") || "../android-metadata-generator/dist",
        libsDir: grunt.option("libsDir") || "./src/libs",
        dexBindingsDir: grunt.option("dexBindingsDir") || "../android-bindings/dexes"
    };

    var generatorDir = rootDir + "/Bindings/Generator";
    var jarCreationDir = rootDir + "/Bindings/JarCreation";

    var testPackageFile = function(filePath)
    {
        var packageFileTester = /package\.json$/ig;
        return packageFileTester.test(filePath);
    };

    var updatePackageVersion = function(content, srcPath)
    {
        if (!testPackageFile(srcPath))
        {
            return content;
        }

        var contentAsObject = JSON.parse(content);
        contentAsObject.version = localCfg.packageVersion;
        return JSON.stringify(contentAsObject, null, "\t");
    };

    function getPackageVersion(packageFilePath)
    {
        packageContent = grunt.file.readJSON(packageFilePath);
        var buildVersion = process.env.PACKAGE_VERSION;
        if (!buildVersion)
        {
            return packageContent.version;
        }
        return packageContent.version + "-" + buildVersion;
    }

    var localCfg = {
        jniDir: rootDir + "/src/jni",
        runtimeVersionHFile: rootDir + "/src/jni/Version.h",
        packageJsonFilePath: rootDir + "/package.json",
        commitVersion: process.env.GIT_COMMIT || ""
    };

    localCfg.packageVersion = getPackageVersion(localCfg.packageJsonFilePath);

    grunt.initConfig({
        pkg: grunt.file.readJSON(rootDir + "/package.json"),
        clean: {
            build: {
                src: [outDir]
            }
        },
        mkdir: {
            build: {
                options: {
                    create: [outDir]
                }
            }
        },
        copy: {
            pkgDef: {
                src: [
                    rootDir + "/package.json"
                ],
                dest: outDir + "/",
                options: {
                    process: updatePackageVersion
                }
            },
            templateProject: {
                expand: true,
                dot: true,
                cwd: pathModule.join(rootDir, "build/project-template"),
                src: [
                    "**/*.*"
                ],
                dest: pathModule.join(outDir, "framework") + "/"
            },
            internalFolder: {
                expand: true,
                cwd: pathModule.join(rootDir, "src/assets"),
                src: ["internal/**/*.*"],
                dest: pathModule.join(outDir, "framework/assets") + "/"
            },
            metadata: {
                expand: true,
                cwd: generatorDir + "/bin/",
                src: ["*.dat"],
                dest: outDir + "/framework/assets/metadata"
            },
            normalJars: {
                expand: true,
                src: "*.jar",
                cwd: jarCreationDir + "/dist/",
                dest: outDir + "/framework/libs/"
            },
            CPPRuntime: {
                expand: true,
                cwd: rootDir + "/src/",
                src: [
                    "./libs/armeabi-v7a/libNativeScript.so",
                    "./libs/x86/libNativeScript.so"
                ],
                dest: outDir + "/framework/"
            },
            updateVersionFile: {
                expand: true,
                flatten: true,
                src: localCfg.runtimeVersionHFile,
                dest: localCfg.jniDir,
                options: {
                    process: function(content, srcPath)
                    {
                        var updatedContent = content;
                        updatedContent = updatedContent.replace(/RUNTIME_VERSION_PLACEHOLDER/ig, localCfg.packageVersion);
                        updatedContent = updatedContent.replace(/RUNTIME_COMMIT_SHA_PLACEHOLDER/ig, localCfg.commitVersion);

                        return updatedContent;
                    }
                }
            },
            updateManifestFile: {
                expand: true,
                flatten: true,
                src: "./src/manifest.mf",
                dest: "./src/",
                options: {
                    process: function(content, srcPath) {
                        var updatedContent = content;
                        updatedContent = updatedContent.replace(/RUNTIME_VERSION_PLACEHOLDER/ig, localCfg.packageVersion);
                        updatedContent = updatedContent.replace(/RUNTIME_COMMIT_SHA_PLACEHOLDER/ig, localCfg.commitVersion);

                        return updatedContent;
                    }
                }
            }
        },
        replace: {
            ndk_configuration: {
                options: {
                    patterns: [
                        {
                            //match: "^APP_OPTIM\\s*?:=\\s*?debug$",
                            match: /APP_OPTIM\s*?\:=\s*?debug/ig,
                            replacement: "APP_OPTIM := release"
                        }
                    ]
                },
                files: [
                    {src: rootDir + "/src/jni/Application.mk", dest: rootDir + "/src/jni/Application.mk"}
                ]
            }
        },
        exec: {
            npmPack: {
                cmd: "npm pack",
                cwd: outDir + "/"
            },
            generateRuntime: {
                cmd: "npm install && grunt --verbose",
                cwd: "./src"
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-mkdir");
    grunt.loadNpmTasks("grunt-exec");
    grunt.loadNpmTasks("grunt-replace");
    //TODO: NEEDED???
    grunt.loadNpmTasks("grunt-contrib-rename");

    grunt.registerTask("generateRuntime", [
                            "exec:generateRuntime"
                       ]);

    grunt.registerTask("generateMetadata", [
            ]);

    grunt.registerTask("default", [
                            "clean:build",
                            "mkdir:build",
                            "copy:templateProject",
                            "copy:internalFolder",
                            "copy:pkgDef",
                            "generateRuntime",
//                            "generateMetadata",
//                            "collectBindings",
                            "exec:npmPack"
                        ]);

}
<commit_msg>Call packaged metadata-gen. Collect libs and metadata. Use the android.jar from the local android sdk<commit_after>module.exports = function(grunt) {

    var pathModule = require("path");

    var outDir = "./dist";
    var rootDir = ".";

    var args = {
        metadataGen: grunt.option("metadataGen") || "../android-metadata-generator/dist/tns-android-metadata-generator-0.0.1.tgz",
        libsDir: grunt.option("libsDir") || "./src/libs",
        dexBindingsDir: grunt.option("dexBindingsDir") || "../android-bindings/dexes"
    };

    var generatorDir = rootDir + "/Bindings/Generator";
    var jarCreationDir = rootDir + "/Bindings/JarCreation";

    var testPackageFile = function(filePath)
    {
        var packageFileTester = /package\.json$/ig;
        return packageFileTester.test(filePath);
    };

    var updatePackageVersion = function(content, srcPath)
    {
        if (!testPackageFile(srcPath))
        {
            return content;
        }

        var contentAsObject = JSON.parse(content);
        contentAsObject.version = localCfg.packageVersion;
        return JSON.stringify(contentAsObject, null, "\t");
    };

    function getPackageVersion(packageFilePath)
    {
        packageContent = grunt.file.readJSON(packageFilePath);
        var buildVersion = process.env.PACKAGE_VERSION;
        if (!buildVersion)
        {
            return packageContent.version;
        }
        return packageContent.version + "-" + buildVersion;
    }

    var localCfg = {
        jniDir: rootDir + "/src/jni",
        runtimeVersionHFile: rootDir + "/src/jni/Version.h",
        packageJsonFilePath: rootDir + "/package.json",
        commitVersion: process.env.GIT_COMMIT || "",
        metadataGenPath: args.metadataGen,
        android17SrcJar: pathModule.join(process.env.ANDROID_HOME, "platforms/android-17/android.jar"),
        localAndroid17Jar: pathModule.join(rootDir, "src", "libs", "android17.jar"),
        runtimeDir: pathModule.join(rootDir, "src"),
        libsDir: pathModule.join(rootDir, "src", "libs"),
        runtimeBinariesDir: pathModule.join(rootDir, "src", "dist")
    };

    localCfg.packageVersion = getPackageVersion(localCfg.packageJsonFilePath);

    grunt.initConfig({
        pkg: grunt.file.readJSON(rootDir + "/package.json"),
        clean: {
            build: {
                src: [outDir]
            },
            android17Lib: {
                src: localCfg.localAndroid17Jar
            }
        },
        mkdir: {
            build: {
                options: {
                    create: [outDir]
                }
            }
        },
        copy: {
            pkgDef: {
                src: [
                    rootDir + "/package.json"
                ],
                dest: outDir + "/",
                options: {
                    process: updatePackageVersion
                }
            },
            templateProject: {
                expand: true,
                dot: true,
                cwd: pathModule.join(rootDir, "build/project-template"),
                src: [
                    "**/*.*"
                ],
                dest: pathModule.join(outDir, "framework") + "/"
            },
            internalFolder: {
                expand: true,
                cwd: pathModule.join(rootDir, "src/assets"),
                src: ["internal/**/*.*"],
                dest: pathModule.join(outDir, "framework/assets") + "/"
            },
            normalJars: {
                expand: true,
                src: "*.jar",
                cwd: jarCreationDir + "/dist/",
                dest: outDir + "/framework/libs/"
            },
            collectRuntime: {
                expand: true,
                cwd: localCfg.runtimeBinariesDir,
                src: [
                    "**/*.*",
                    "**/*"
                ],
                dest: outDir + "/framework/"
            },
            collectLibs: {
                expand: true,
                cwd: localCfg.libsDir,
                src: ["**/*.*"],
                dest: pathModule.join(outDir, "framework", "libs") + "/"
            },
            updateVersionFile: {
                expand: true,
                flatten: true,
                src: localCfg.runtimeVersionHFile,
                dest: localCfg.jniDir,
                options: {
                    process: function(content, srcPath)
                    {
                        var updatedContent = content;
                        updatedContent = updatedContent.replace(/RUNTIME_VERSION_PLACEHOLDER/ig, localCfg.packageVersion);
                        updatedContent = updatedContent.replace(/RUNTIME_COMMIT_SHA_PLACEHOLDER/ig, localCfg.commitVersion);

                        return updatedContent;
                    }
                }
            },
            updateManifestFile: {
                expand: true,
                flatten: true,
                src: "./src/manifest.mf",
                dest: "./src/",
                options: {
                    process: function(content, srcPath) {
                        var updatedContent = content;
                        updatedContent = updatedContent.replace(/RUNTIME_VERSION_PLACEHOLDER/ig, localCfg.packageVersion);
                        updatedContent = updatedContent.replace(/RUNTIME_COMMIT_SHA_PLACEHOLDER/ig, localCfg.commitVersion);

                        return updatedContent;
                    }
                }
            },
            android17Lib: {
                src: localCfg.android17SrcJar,
                dest: localCfg.localAndroid17Jar
            }
        },
        replace: {
            ndk_configuration: {
                options: {
                    patterns: [
                        {
                            //match: "^APP_OPTIM\\s*?:=\\s*?debug$",
                            match: /APP_OPTIM\s*?\:=\s*?debug/ig,
                            replacement: "APP_OPTIM := release"
                        }
                    ]
                },
                files: [
                    {src: rootDir + "/src/jni/Application.mk", dest: rootDir + "/src/jni/Application.mk"}
                ]
            }
        },
        exec: {
            npmPack: {
                cmd: "npm pack",
                cwd: outDir + "/"
            },
            generateRuntime: {
                cmd: "npm install && grunt --verbose",
                cwd: "./src"
            },
            installMetadataGenerator: {
                cmd: "npm install " + localCfg.metadataGenPath
            },
            runMetadataGenerator: {
                cmd: "./node_modules/.bin/generate-metadata " + localCfg.libsDir + " ./dist/framework/assets/metadata"
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-mkdir");
    grunt.loadNpmTasks("grunt-exec");
    grunt.loadNpmTasks("grunt-replace");
    //TODO: NEEDED???
    grunt.loadNpmTasks("grunt-contrib-rename");

    grunt.registerTask("generateRuntime", [
                            "exec:generateRuntime"
            ]);

    grunt.registerTask("generateMetadata", [
                "exec:installMetadataGenerator",
                "copy:android17Lib",
                "exec:runMetadataGenerator",
                "clean:android17Lib"
            ]);

    grunt.registerTask("default", [
                            "clean:build",
                            "mkdir:build",
                            "copy:templateProject",
                            "copy:internalFolder",
                            "copy:pkgDef",
                            "generateRuntime",
                            "generateMetadata",
                            "copy:collectRuntime",
                            "copy:collectLibs",
//                            "collectBindings",
                            "exec:npmPack"
            ]);

}
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  'use strict';
  var pkg = grunt.file.readJSON('package.json');

  grunt.initConfig({
    sampleDir: "samples",
    libDir: "src",
    destDir: "dest",
    testDir: "test",
    docDir: "doc",

    watch: {
      sample: {
        files: ['<%= sampleDir %>/*.jsx', '<%= libDir %>/*.jsx'],
        tasks: ['jsx:build']
      },
      test: {
        files: ['<%= testDir %>/*.jsx', '<%= libDir %>'],
        tasks: ['jsx:test']
      }
    },

    jsx: {
      sample: {
        src: ['<%= sampleDir %>/*.jsx'],
        add_search_path: ['<%= libDir %>'],
        dest: '<%= sampleDir %>/',
        executable: 'node'
      },

      commonjs: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /lib\/(.+)\.jsx/,
            replace: 'dest\/$1.common.js'
        },
        add_search_path: ['<%= libDir %>'],
        minify: false,
        release: false,
        linker: 'commonjs-lib'
      },

      amd: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /lib\/(.+)\.jsx/,
            replace: 'dest\/$1.amd.js'
        },
        add_search_path: ['<%= libDir %>'],
        minify: false,
        release: false,
        linker: 'amd-lib'
      },

      closure: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /lib\/(.+)\.jsx/,
            replace: 'dest\/$1.closure.js'
        },
        add_search_path: ['<%= libDir %>'],
        minify: false,
        release: false,
        linker: 'closure-lib'
      },

      global: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /lib\/(.+)\.jsx/,
            replace: 'dest\/$1.global.js'
        },
        add_search_path: ['<%= libDir %>'],
        minify: false,
        release: false,
        linker: 'export-global'
      },

      standard: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /lib\/(.+)\.jsx/,
            replace: 'dest\/$1.js'
        },
        add_search_path: ['<%= libDir %>'],
        release: false,
        minify: false
      },

      test: {
        src: ['<%= testDir %>/*.jsx'],
        add_search_path: ['<%= libDir %>'],
        test: false
      },

      doc: {
        src: ['<%= libDir %>/*.jsx'],
        add_search_path: ['<%= libDir %>'],
        dest: '<%= docDir %>',
        mode: 'doc'
      }
    }
  });

  for (var key in pkg.devDependencies) {
    if (/grunt-/.test(key)) {
      grunt.loadNpmTasks(key);
    }
  }

  grunt.registerTask('default', ['jsx:test']);
  grunt.registerTask('build', [
    'jsx:commonjs',
    'jsx:amd',
    'jsx:closure',
    'jsx:standard',
    'jsx:global'
  ]);
  grunt.registerTask('sample', ['jsx:sample']);
  grunt.registerTask('doc', ['jsx:doc']);
};
// vim: set expandtab tabstop=2 shiftwidth=2:
<commit_msg>fix build script<commit_after>module.exports = function(grunt) {
  'use strict';
  var pkg = grunt.file.readJSON('package.json');

  grunt.initConfig({
    sampleDir: "samples",
    libDir: "src",
    destDir: "dest",
    testDir: "test",
    docDir: "doc",

    watch: {
      sample: {
        files: ['<%= sampleDir %>/*.jsx', '<%= libDir %>/*.jsx'],
        tasks: ['jsx:build']
      },
      test: {
        files: ['<%= testDir %>/*.jsx', '<%= libDir %>'],
        tasks: ['jsx:test']
      }
    },

    jsx: {
      sample: {
        src: ['<%= sampleDir %>/*.jsx'],
        add_search_path: ['<%= libDir %>'],
        dest: '<%= sampleDir %>/',
        executable: 'node'
      },

      commonjs: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /src\/(.+)\.jsx/,
            replace: 'dest\/$1.common.js'
        },
        add_search_path: ['<%= libDir %>'],
        minify: false,
        release: false,
        linker: 'commonjs-lib'
      },

      amd: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /src\/(.+)\.jsx/,
            replace: 'dest\/$1.amd.js'
        },
        add_search_path: ['<%= libDir %>'],
        minify: false,
        release: false,
        linker: 'amd-lib'
      },

      closure: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /src\/(.+)\.jsx/,
            replace: 'dest\/$1.closure.js'
        },
        add_search_path: ['<%= libDir %>'],
        minify: false,
        release: true,
        linker: 'closure-lib'
      },

      global: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /src\/(.+)\.jsx/,
            replace: 'dest\/$1.global.js'
        },
        add_search_path: ['<%= libDir %>'],
        minify: true,
        release: true,
        linker: 'export-global'
      },

      standard: {
        src: ['src/danish-stemmer.jsx', 'src/dutch-stemmer.jsx', 'src/english-stemmer.jsx', 'src/finnish-stemmer.jsx', 'src/french-stemmer.jsx',
              'src/german-stemmer.jsx', 'src/hungarian-stemmer.jsx', 'src/italian-stemmer.jsx', 'src/norwegian-stemmer.jsx', 'src/porter-stemmer.jsx',
              'src/portuguese-stemmer.jsx', 'src/romanian-stemmer.jsx', 'src/russian-stemmer.jsx', 'src/spanish-stemmer.jsx', 'src/swedish-stemmer.jsx',
              'src/turkish-stemmer.jsx'],
        output_rule: {
            regexp: /src\/(.+)\.jsx/,
            replace: 'dest\/$1.js'
        },
        add_search_path: ['<%= libDir %>'],
        release: false,
        minify: false
      },

      test: {
        src: ['<%= testDir %>/*.jsx'],
        add_search_path: ['<%= libDir %>'],
        test: false
      },

      doc: {
        src: ['<%= libDir %>/*.jsx'],
        add_search_path: ['<%= libDir %>'],
        dest: '<%= docDir %>',
        mode: 'doc'
      }
    }
  });

  for (var key in pkg.devDependencies) {
    if (/grunt-/.test(key)) {
      grunt.loadNpmTasks(key);
    }
  }

  grunt.registerTask('default', ['jsx:test']);
  grunt.registerTask('build', [
    'jsx:commonjs',
    'jsx:amd',
    'jsx:closure',
    'jsx:standard',
    'jsx:global'
  ]);
  grunt.registerTask('sample', ['jsx:sample']);
  grunt.registerTask('doc', ['jsx:doc']);
};
// vim: set expandtab tabstop=2 shiftwidth=2:
<|endoftext|>


<commit_before>var shell = require("shelljs");

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

    grunt.initConfig({
      jshint: {
        gruntfile: ['gruntfile.js'],
        js: {
          options: {
            node: true,
            browser: true,
            browserify: true,
            globals: {
              '$': true,
              'jQuery': true,
              'tinymce': true
            }
          },
          files: {
            src: ['src/**/*.js']
          }
        }
      },
      browserify: {
        dist: {
          src: 'index.js',
          dest: 'plugin.js'
        }
      },
      uglify: {
        dist: {
          files: {
            'plugin.min.js': ['plugin.js']
          }
        }
      },
      watch: {
        gruntfile: {
          files: 'Gruntfile.js',
          tasks: ['jshint:gruntfile'],
        },
        js: {
          files: ['src/**/*.js'],
          tasks: ['jshint:js'],
        }
      },
      bump: {
        options: {
          files: ['package.json','bower.json'],
          updateConfigs: [],
          commit: true,
          commitMessage: 'Release v%VERSION%',
          commitFiles: ['package.json','bower.json'],
          createTag: true,
          tagName: 'v%VERSION%',
          tagMessage: 'Version %VERSION%',
          push: true,
          pushTo: 'origin',
          gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
          globalReplace: false,
          prereleaseName: false,
          regExp: false
        }
      },
    });

    grunt.registerTask('jsdoc', function(){
      shell.exec('npm run jsdoc');
    });

    grunt.registerTask('build', ['jshint', 'browserify', 'uglify', 'jsdoc']);

    grunt.registerTask('dev', ['jshint', 'browserify', 'watch']);

    grunt.registerTask('default', ['dev']);
};
<commit_msg>push to gh-sirap-group when grunt bump<commit_after>var shell = require("shelljs");

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

    grunt.initConfig({
      jshint: {
        gruntfile: ['gruntfile.js'],
        js: {
          options: {
            node: true,
            browser: true,
            browserify: true,
            globals: {
              '$': true,
              'jQuery': true,
              'tinymce': true
            }
          },
          files: {
            src: ['src/**/*.js']
          }
        }
      },
      browserify: {
        dist: {
          src: 'index.js',
          dest: 'plugin.js'
        }
      },
      uglify: {
        dist: {
          files: {
            'plugin.min.js': ['plugin.js']
          }
        }
      },
      watch: {
        gruntfile: {
          files: 'Gruntfile.js',
          tasks: ['jshint:gruntfile'],
        },
        js: {
          files: ['src/**/*.js'],
          tasks: ['jshint:js'],
        }
      },
      bump: {
        options: {
          files: ['package.json','bower.json'],
          updateConfigs: [],
          commit: true,
          commitMessage: 'Release v%VERSION%',
          commitFiles: ['package.json','bower.json'],
          createTag: true,
          tagName: 'v%VERSION%',
          tagMessage: 'Version %VERSION%',
          push: true,
          pushTo: 'gh-sirap-group',
          gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
          globalReplace: false,
          prereleaseName: false,
          regExp: false
        }
      },
    });

    grunt.registerTask('jsdoc', function(){
      shell.exec('npm run jsdoc');
    });

    grunt.registerTask('build', ['jshint', 'browserify', 'uglify', 'jsdoc']);

    grunt.registerTask('dev', ['jshint', 'browserify', 'watch']);

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


<commit_before>//'use strict';
var path = require('path').resolve('.');

module.exports = function (grunt) {
    grunt.initConfig({
         defaulTheme:'theme1'
        ,pkg: grunt.file.readJSON('package.json'),
          less: {
            dev: {
                options: {
                    sourceMap: true,
                    dumpLineNumbers: 'comments',
                    relativeUrls: true
                }
            }
        },
        cssmin: {
          options: {
            shorthandCompacting: false,
            roundingPrecision: -1
          }

        },

        express: {
            all: {
                options: {
                    bases: [ path + '\\dist\\themes\\<%=defaulTheme%>'],
                    port: 8080,
                    hostname: "0.0.0.0",
                    livereload: true
                }
            }
        },

        // grunt-watch will monitor the projects files
        // https://github.com/gruntjs/grunt-contrib-watch
        watch: {
            all: {
                    files: 'src/<%=defaulTheme%>/*.less',
                    tasks: ['buildthemes:<%=defaulTheme%>','express', 'open', 'watch'],
                    options: {
                        spawn: false,
                    }

            }
        },

        // grunt-open will open your browser at the project's URL
        // https://www.npmjs.org/package/grunt-open
        open: {
            all: {
                path: 'http://localhost:8080/index.html'
            }
        }

        , buildthemes: { theme1:{}, theme2:{},theme3:{}}

    });

    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.loadNpmTasks('grunt-express');
    grunt.loadNpmTasks('grunt-open');

    //grunt.registerTask('default', ['less','cssmin']);
    grunt.registerTask('compile', ['less:dev']);
    grunt.registerTask('dev', ['less:dev']);
    grunt.loadNpmTasks('grunt-contrib-copy');

    grunt.registerTask('default', ['buildthemes','express', 'open', 'watch']);
    //grunt.registerTask('default', ['buildthemes']);

    grunt.registerTask('build', function(theme) {
        grunt.log.writeln( ['building... (' + theme + ')' ] );
        var bs= 'bootstrap';
        var th = 'theme';
        var dist = 'dist/themes/' + theme + '/css/';
        var src = 'src/' + theme + '/';
        var css = ".css";
        var less = ".less";
        var minfile = bs + '.min' + css;

        var files ={};
            files[dist + bs + css] = src + bs + less;
            files[dist + th + css] = src + th + less;

        grunt.config('less.dev.files', files);

        var cssminfiles={};
        cssminfiles[dist + minfile] =  [dist + bs + css, dist + th + css];
        grunt.config('cssmin.target.files', cssminfiles);

        var copyfiles = [
            {
                  expand: true
                , src: ['**']
                , dest: 'dist/themes/'+ theme +'/fonts/'
                , cwd: 'node_modules/bootstrap/dist/fonts/'
                , filter: 'isFile'
            }
            ,{
                  expand: true
                , src: ['**']
                , dest: 'dist/themes/'+ theme +'/'
                , cwd: 'src/templates/'
                , filter: 'isFile'

            }
            ,{
                expand: true
                , src: ['bootstrap*.min.js']
                , dest: 'dist/themes/'+ theme +'/js/'
                , cwd: 'node_modules/bootstrap/dist/js/'
                , filter: 'isFile'

            }
        ];

        grunt.config('copy.main.files',copyfiles);

        grunt.task.run(['less:dev','cssmin','copy']);

    });

    grunt.registerMultiTask('buildthemes', function() {
        grunt.task.run('build:' + this.target);
    });

};<commit_msg>clean up.<commit_after>//'use strict';
var path = require('path').resolve('.');

module.exports = function (grunt) {
    grunt.initConfig({
         defaulTheme:'theme1'
        ,pkg: grunt.file.readJSON('package.json'),
          less: {
            dev: {
                options: {
                    sourceMap: true,
                    dumpLineNumbers: 'comments',
                    relativeUrls: true
                }
            }
        },
        cssmin: {
          options: {
            shorthandCompacting: false,
            roundingPrecision: -1
          }

        },
        express: {
            all: {
                options: {
                    bases: [ path + '\\dist\\themes\\<%=defaulTheme%>'],
                    port: 8080,
                    hostname: "0.0.0.0",
                    livereload: true
                }
            }
        },
        watch: {
            all: {
                    files: 'src/<%=defaulTheme%>/*.less',
                    tasks: ['buildthemes:<%=defaulTheme%>','express', 'open', 'watch'],
                    options: {
                        spawn: false,
                    }

            }
        },
        open: {
            all: {
                path: 'http://localhost:8080/index.html'
            }
        }
        , buildthemes: { theme1:{}, theme2:{},theme3:{}}
    });

    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.loadNpmTasks('grunt-express');
    grunt.loadNpmTasks('grunt-open');

    //grunt.registerTask('default', ['less','cssmin']);
    grunt.registerTask('compile', ['less:dev']);
    grunt.registerTask('dev', ['less:dev']);
    grunt.loadNpmTasks('grunt-contrib-copy');

    grunt.registerTask('default', ['buildthemes','express', 'open', 'watch']);
    //grunt.registerTask('default', ['buildthemes']);

    grunt.registerTask('build', function(theme) {
        grunt.log.writeln( ['building... (' + theme + ')' ] );
        var bs= 'bootstrap';
        var th = 'theme';
        var dist = 'dist/themes/' + theme + '/css/';
        var src = 'src/' + theme + '/';
        var css = ".css";
        var less = ".less";
        var minfile = bs + '.min' + css;

        var files ={};
            files[dist + bs + css] = src + bs + less;
            files[dist + th + css] = src + th + less;

        grunt.config('less.dev.files', files);

        var cssminfiles={};
        cssminfiles[dist + minfile] =  [dist + bs + css, dist + th + css];
        grunt.config('cssmin.target.files', cssminfiles);

        var copyfiles = [
            {
                  expand: true
                , src: ['**']
                , dest: 'dist/themes/'+ theme +'/fonts/'
                , cwd: 'node_modules/bootstrap/dist/fonts/'
                , filter: 'isFile'
            }
            ,{
                  expand: true
                , src: ['**']
                , dest: 'dist/themes/'+ theme +'/'
                , cwd: 'src/templates/'
                , filter: 'isFile'

            }
            ,{
                expand: true
                , src: ['bootstrap*.min.js']
                , dest: 'dist/themes/'+ theme +'/js/'
                , cwd: 'node_modules/bootstrap/dist/js/'
                , filter: 'isFile'

            }
        ];
        grunt.config('copy.main.files',copyfiles);
        grunt.task.run(['less:dev','cssmin','copy']);
    });

    grunt.registerMultiTask('buildthemes', function() {
        grunt.task.run('build:' + this.target);
    });

};<|endoftext|>


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

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

        imagemin: {
            png: {
                options: {
                    optimizationLevel: 7
                },
                files: [
                    {
                        // Set to true to enable the following options…
                        expand: true,
                        // cwd is 'current working directory'
                        cwd: '',
                        src: ['img/*.png', 'img/**/*.png', 'img/**/**/*.png'],
                        // Could also match cwd line above. i.e. project-directory/img/
                        dest: 'media/compressed/',
                        flatten: true,
                        ext: '.png'
                    }
                ]
            },
            jpg: {
                options: {
                    progressive: true
                },
                files: [
                    {
                        // Set to true to enable the following options…
                        expand: true,
                        // cwd is 'current working directory'
                        cwd: '',
                        src: ['img/*.jpg', 'img/**/*.jpg', 'img/**/**/*.jpg', 'img/*.jpeg', 'img/**/*.jpeg', 'img/**/**/*.jpeg'],
                        // Could also match cwd. i.e. project-directory/img/
                        dest: 'media/compressed/',
                        flatten: true,
                        ext: '.jpg'
                    }
                ]
            }
        },

        responsive_images: {
            square: {
                options: {
                    sizes: [{
                        width: 450,
                        height: 450,
                        aspectRatio: false,
                    }]
                },
                files: [{
                    expand: true,
                    flatten: true,
                    src: [
                        'media/compressed/*.{jpg,gif,png}',
                        'media/compressed/!crops/*.{jpg,gif,png}',
                    ],
                    cwd: '',
                    dest: 'media/compressed/crops/450x450/'
                }]
            },
            thumbs: {
                options: {
                    sizes: [{
                        width: 450,
                        height: 253,
                        aspectRatio: false,
                    }]
                },
                files: [{
                    expand: true,
                    flatten: true,
                    src: [
                        'media/compressed/*.{jpg,gif,png}',
                        'media/compressed/!crops/*.{jpg,gif,png}',
                    ],
                    cwd: '',
                    dest: 'media/compressed/crops/450x253/'
                }]
            }
        },

        uglify: {
            build: {
                src: 'js/*.js',
                dest: 'js/build/global.min.js'
            }
        },

        sass: {
            options: {
                outputStyle: 'compressed',
            },
            dist: {
                files: {
                    'css/main.css': 'sass/main.scss',
                    'css/grid.css': 'sass/grid.scss',
                    'css/classic.css': 'sass/classic.scss',
                    // you may remove these for your site
                    'css/main_brown.css': 'sass/main_brown.scss',
                    'css/main_green.css': 'sass/main_green.scss',
                    'css/main_teal.css': 'sass/main_teal.scss'
                }
            }
        },

        autoprefixer: {
            options: {
                browsers: ['> 1%']
            },
            no_dest: {
                src: 'css/*.css' // globbing is also possible here
            },
        },

        copy: {
            css: {
                files: [
                    {
                        expand: true,
                        src: ['css/**'],
                        dest: 'jekyllbuild/'
                    },
                ]
            },
            js: {
                files: [
                    {
                        expand: true,
                        src: ['js/build/**'],
                        dest: 'jekyllbuild/'
                    },
                ]
            }
        },

        open: {
            build: {
                path: 'http://localhost:4000',
            }
        },

        watch: {
            options: {
                livereload: true
            },
            site: {
                files: ["{,*/}{,*/}{,*/}*.html", "{,*/}{,*/}{,*/}*.md", "{,*/}*.yml", "!jekyllbuild/{,*/}{,*/}*.*", "!node_modules/{,*/}*.*"],
                tasks: ["shell:jekyllBuild", "copy"]
            },
            js: {
                files: ['js/{,*/}*.js'],
                tasks: ["uglify", "copy:js"]
            },
            css: {
                files: ["sass/{,*/}{,*/}{,*/}*.scss"],
                tasks: ["sass", "autoprefixer", "copy:css"]
            },
            images: {
                files: ["img/{,*/}{,*/}*.{png,jpg}"],
                tasks: ["newer:imagemin", "responsive_images", "shell:jekyllBuild", "copy"]
            }
        },

        buildcontrol: {
            options: {
                dir: 'jekyllbuild',
                commit: true,
                push: true,
                message: 'Built jekyllbuild from commit %sourceCommit% on branch %sourceBranch%'
            },
            pages: {
                options: {
                    remote: 'https://github.com/user/reponame.git', // change that
                    branch: 'gh-pages' // adjust here
                }
            }
        },

        shell: {
            jekyllServe: {
                command: "jekyll serve  --no-watch"
            },
            jekyllBuild: {
                command: "jekyll build"
            }
        }
    });

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

    grunt.registerTask("serve", ["shell:jekyllServe"]);
    grunt.registerTask("default", ["newer:imagemin", "responsive_images", "uglify", "sass", "autoprefixer", "shell:jekyllBuild", "copy", "open", "watch"]);
    grunt.registerTask("deploy", ["buildcontrol:pages"]);
};<commit_msg>adjust gruntfile<commit_after>module.exports = function (grunt) {

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

        imagemin: {
            png: {
                options: {
                    optimizationLevel: 7
                },
                files: [
                    {
                        // Set to true to enable the following options…
                        expand: true,
                        // cwd is 'current working directory'
                        cwd: '',
                        src: ['img/*.png', 'img/**/*.png', 'img/**/**/*.png'],
                        // Could also match cwd line above. i.e. project-directory/img/
                        dest: 'media/compressed/',
                        flatten: true,
                        ext: '.png'
                    }
                ]
            },
            jpg: {
                options: {
                    progressive: true
                },
                files: [
                    {
                        // Set to true to enable the following options…
                        expand: true,
                        // cwd is 'current working directory'
                        cwd: '',
                        src: ['img/*.jpg', 'img/**/*.jpg', 'img/**/**/*.jpg', 'img/*.jpeg', 'img/**/*.jpeg', 'img/**/**/*.jpeg'],
                        // Could also match cwd. i.e. project-directory/img/
                        dest: 'media/compressed/',
                        flatten: true,
                        ext: '.jpg'
                    }
                ]
            }
        },

        responsive_images: {
            square: {
                options: {
                    sizes: [{
                        width: 450,
                        height: 450,
                        aspectRatio: false,
                    }]
                },
                files: [{
                    expand: true,
                    flatten: true,
                    src: [
                        'media/compressed/*.{jpg,gif,png}',
                        'media/compressed/!crops/*.{jpg,gif,png}',
                    ],
                    cwd: '',
                    dest: 'media/compressed/crops/450x450/'
                }]
            },
            thumbs: {
                options: {
                    sizes: [{
                        width: 450,
                        height: 253,
                        aspectRatio: false,
                    }]
                },
                files: [{
                    expand: true,
                    flatten: true,
                    src: [
                        'media/compressed/*.{jpg,gif,png}',
                        'media/compressed/!crops/*.{jpg,gif,png}',
                    ],
                    cwd: '',
                    dest: 'media/compressed/crops/450x253/'
                }]
            }
        },

        uglify: {
            build: {
                src: 'js/*.js',
                dest: 'js/build/global.min.js'
            }
        },

        sass: {
            options: {
                outputStyle: 'compressed',
            },
            dist: {
                files: {
                    'css/main.css': 'sass/main.scss',
                    'css/grid.css': 'sass/grid.scss',
                    'css/classic.css': 'sass/classic.scss',
                    // you may remove these for your site
                    'css/main_brown.css': 'sass/main_brown.scss',
                    'css/main_green.css': 'sass/main_green.scss',
                    'css/main_teal.css': 'sass/main_teal.scss'
                }
            }
        },

        autoprefixer: {
            options: {
                browsers: ['> 1%']
            },
            no_dest: {
                src: 'css/*.css' // globbing is also possible here
            },
        },

        copy: {
            css: {
                files: [
                    {
                        expand: true,
                        src: ['css/**'],
                        dest: 'jekyllbuild/'
                    },
                ]
            },
            js: {
                files: [
                    {
                        expand: true,
                        src: ['js/build/**'],
                        dest: 'jekyllbuild/'
                    },
                ]
            }
        },

        open: {
            build: {
                path: 'http://localhost:4000',
            }
        },

        watch: {
            options: {
                livereload: true
            },
            site: {
                files: ["{,*/}{,*/}{,*/}*.html", "{,*/}{,*/}{,*/}*.md", "{,*/}*.yml", "!jekyllbuild/{,*/}{,*/}*.*", "!node_modules/{,*/}*.*"],
                tasks: ["shell:jekyllBuild", "copy"]
            },
            js: {
                files: ['js/{,*/}*.js'],
                tasks: ["uglify", "copy:js"]
            },
            css: {
                files: ["sass/{,*/}{,*/}{,*/}*.scss"],
                tasks: ["sass", "autoprefixer", "copy:css"]
            },
            images: {
                files: ["img/{,*/}{,*/}*.{png,jpg}"],
                tasks: ["newer:imagemin", "responsive_images", "shell:jekyllBuild", "copy"]
            }
        },

        buildcontrol: {
            options: {
                dir: 'jekyllbuild',
                commit: true,
                push: true,
                message: 'Built jekyllbuild from commit %sourceCommit% on branch %sourceBranch%'
            },
            pages: {
                options: {
                    remote: 'git@knowtology.com:miri/twister_material.git', // change that
                    branch: 'site' // adjust here
                }
            }
        },

        shell: {
            jekyllServe: {
                command: "jekyll serve  --no-watch"
            },
            jekyllBuild: {
                command: "jekyll build"
            }
        }
    });

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

    grunt.registerTask("serve", ["shell:jekyllServe"]);
    grunt.registerTask("default", ["newer:imagemin", "responsive_images", "uglify", "sass", "autoprefixer", "shell:jekyllBuild", "copy", "open", "watch"]);
    grunt.registerTask("deploy", ["buildcontrol:pages"]);
};<|endoftext|>


<commit_before>var module, require;

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

    // Configuration goes here
    grunt.initConfig({

        // Retrieve project's metadata
        pkg: grunt.file.readJSON('package.json'),

        mybanner:   '-------------------------------------\n' +
                    '         <%= pkg.name %>\n' +
                    'Copyright © <%= pkg.author.name %>  2015-<%= grunt.template.today("yyyy") %>\n' +
                    '-------------------------------------\n' +
                    '     Version: <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd") %>)',

        // Compiles Sass files into CSS files
        sass: {
            scss: {
                options: {
                    sourceMap: true
                },
                files: [{
                    expand: true,
                    cwd: 'src/scss/',
                    src: [
                        '**/*.sass',
                        '**/*.scss'
                    ],
                    dest: 'src/_compiled/css/',
                    ext: '.css'
                }]
            }
        },

        // Enhances CSS in order to be compatible with more browsers
        postcss: {
            css: {
                options: {
                    map: true,
                    processors: [
                        require('autoprefixer')({browsers: 'last 2 versions'})
                    ]
                },
                dist: {
                    files: [{
                        expand: true,
                        cwd: 'src/css/',
                        src: [
                            '**/*.css',
                            '../_compiled/css/**/*.css',
                            '!../_compiled/css/**/*.postcss.css'
                        ],
                        dest: 'src/_compiled/css/',
                        ext: '.postcss.css',
                        rename: function (dest, src) {
                            return dest + src.replace(/^\.\.\/_compiled\/css\//, '');
                        }
                    }]
                }
            }
        },

        // Minify CSS
        cssmin: {
            css: {
                options: {
                    //banner: '/*\n<%= mybanner %>\n*/\n',
                    sourceMap: true
                },
                files: [{
                    expand: true,
                    cwd: 'src/_compiled/css/',
                    src: ['**/*.postcss.css'],
                    dest: 'src/_compiled/css/',
                    ext: '.min.css'
                }]
            }
        },

        // Minify JavaScript
        uglify: {
            js: {
                options: {
                    //banner: '/*\n<%= mybanner %>\n*/\n',
                    preserveComments: false,
                    sourceMap: true
                },
                files: [{
                    expand: true,
                    cwd: 'src/js/',
                    src: ['**/*.js'],
                    dest: 'src/_compiled/js/',
                    ext: '.min.js'
                }]
            }
        },

        // Minify HTML
        minifyHtml: {
            html_minified: {
                options: {
                    conditionals: true
                },
                files: [{
                    expand: true,
                    cwd: 'src/_compiled/html/',
                    src: ['**/*.processed.html'],
                    dest: 'src/_compiled/html/',
                    ext: '.html',
                    filter: 'isFile'
                }]
            }
        },

        // Copies files from 3rd party sources to the `src` folder
        // Copies files from `src` folder to `dist` folder on production
        copy: {
            components: {
                files: [{
                    expand: true,
                    cwd: 'components/bootswatch/',
                    src: ['superhero/**'],
                    dest: 'src/scss/',
                    filter: function (dest) {
                        var output = grunt.task.current.data.files[0].dest + dest.replace(new RegExp('^' + this.cwd), '');
                        if (!grunt.file.isFile(dest)) { console.log('Not a file: ' + dest); return false; }
                        else if (grunt.file.exists(output)) { console.log('Already exists: ' + output); return false; }
                        else { return true; }
                    }
                }]
            },
            bootstrap_assets: {
                files: [{
                    expand: true,
                    cwd: 'bower_components/bootstrap-sass/assets/',
                    src: [
                        'stylesheets/bootstrap/**',
                        'stylesheets/_bootstrap.scss',
                        'fonts/bootstrap/**',
                        'javascripts/bootstrap.js'
                    ],
                    dest: 'src/',
                    filter: function (dest) {
                        var output = grunt.task.current.data.files[0].dest + dest.replace(new RegExp('^' + this.cwd), '').replace(/^stylesheets\//, 'scss/').replace(/^scss\/_/, 'scss/').replace(/^javascripts\//, 'js/');
                        if (!grunt.file.isFile(dest)) { console.log('Not a file: ' + dest); return false; }
                        else if (grunt.file.exists(output)) { console.log('Already exists: ' + output); return false; }
                        else { return true; }
                    },
                    rename: function (dest, src) {
                        return dest + src.replace(/^stylesheets\//, 'scss/').replace(/^scss\/_/, 'scss/').replace(/^javascripts\//, 'js/');
                    }
                }]
            },
            bower_components: {
                files: [{
                    expand: true,
                    cwd: 'bower_components/',
                    src: [
                        'font-awesome/scss/_**',
                        '!font-awesome/scss/_variables.scss',
                        'font-awesome/fonts/**',
                        'jquery/dist/jquery.js',
                        'html5shiv/dist/html5shiv.js',
                        'respond/dest/respond.src.js'
                    ],
                    dest: 'src/',
                    filter: function (dest) {
                        var output = grunt.task.current.data.files[0].dest + dest.replace(new RegExp('^' + this.cwd), '').replace(/^font-awesome\/(.*)\//, '$1/font-awesome/').replace(/^jquery\/dist\//, 'js/').replace(/^html5shiv\/dist\//, 'js/polyfill/').replace(/^respond\/dest\/respond.src.js/, 'js/polyfill/respond.js');
                        if (!grunt.file.isFile(dest)) { console.log('Not a file: ' + dest); return false; }
                        else if (grunt.file.exists(output)) { console.log('Already exists: ' + output); return false; }
                        else { return true; }
                    },
                    rename: function (dest, src) {
                        return dest + src.replace(/^font-awesome\/(.*)\//, '$1/font-awesome/').replace(/^jquery\/dist\//, 'js/').replace(/^html5shiv\/dist\//, 'js/polyfill/').replace(/^respond\/dest\/respond.src.js/, 'js/polyfill/respond.js');
                    }
                }]
            },
            process__fontawesome: {
                options: {
                    process: function (content, path) {
                        if (~path.indexOf('font-awesome.scss')) {
                            return content.replace(/@import "/g, '@import "font-awesome/');
                        } else if (~path.indexOf('_variables.scss')) {
                            return content.replace(/"\.\.\/fonts"/, '"../fonts/font-awesome"');
                        }
                    }
                },
                files: [{
                    expand: true,
                    cwd: 'bower_components/font-awesome/scss/',
                    src: [
                        'font-awesome.scss',
                        '_variables.scss'
                    ],
                    dest: 'src/scss/',
                    filter: function (dest) {
                        var output = grunt.task.current.data.files[0].dest + dest.replace(new RegExp('^' + this.cwd), '').replace(/^_/, 'font-awesome/_');
                        if (!grunt.file.isFile(dest)) { console.log('Not a file: ' + dest); return false; }
                        else if (grunt.file.exists(output)) { console.log('Already exists: ' + output); return false; }
                        else { return true; }
                    },
                    rename: function (dest, src) {
                        return dest + src.replace(/^_/, 'font-awesome/_');
                    }
                }]
            },
            process__html: {
                options: {
                    process: function (content, path) {
                        var strDepth = '../';
                        for (var i = path.match(/\//g).length - 2; i; i--) {
                            strDepth = strDepth + '../';
                        }
                        // RegExp to find an opening and closing custom tag
                        // The closing tag is mentioned twice; this helps the opening tag match with the first available closing tag (as opposed to the last found tag)
                        return content.replace(/<!--concat:css-->(?:(?!<!--\/concat-->)(?:.|\n))*<!--\/concat-->/g, '<link href="' + strDepth + 'css/master.min.css" rel="stylesheet">').replace(/<!--concat:js-->(?:(?!<!--\/concat-->)(?:.|\n))*<!--\/concat-->/g, '<link href="' + strDepth + 'js/master.min.js" rel="stylesheet">').replace(/<!--concat:polyfill-->(?:(?!<!--\/concat-->)(?:.|\n))*<!--\/concat-->/g, '<!--[if lt IE 9]><link href="' + strDepth + 'js/polyfill/master.min.js" rel="stylesheet"><![endif]-->').replace(/<!--concat:css_bootswatch-->(?:(?!<!--\/concat-->)(?:.|\n))*<!--\/concat-->/g, '<link href="' + strDepth + 'css/master_bootswatch.min.css" rel="stylesheet">');
                    }
                },
                files: [{
                    expand: true,
                    cwd: 'src/html/',
                    src: ['**'],
                    dest: 'src/_compiled/html/',
                    ext: '.processed.html',
                    filter: 'isFile'
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: 'src/_compiled/',
                    src: [
                        'css/**/*.min.css',
                        '../fonts/**',
                        'html/**/*.html', '!html/**/*.processed.html',
                        '../images/**',
                        'js/**/*.min.js',
                        '../../LICENSE',
                        '../../README.md'
                    ],
                    dest: 'dist/',
                    filter: 'isFile',
                    rename: function (dest, src) {
                        return dest + src.replace(/^(\.\.\/)+/, '');
                    }
                }]
            }
        },

        // Merges all CSS files, JS files, and polyfill files into single files
        // Allows for fewer HTTP requests, and faster browser load speeds
        concat: {
            css: {
                files: [{
                    'src/_compiled/css/master.min.css': [
                        'src/_compiled/css/bootstrap.min.css',
                        'src/_compiled/css/font-awesome.min.css'
                    ]
                }]
            },
            css_bootswatch: {
                files: [{
                    'src/_compiled/css/master_bootswatch.min.css': [
                        'src/_compiled/css/bootswatch.min.css',
                        'src/_compiled/css/font-awesome.min.css'
                    ]
                }]
            },
            js: {
                files: [{
                    'src/_compiled/js/master.min.js': [
                        'src/_compiled/js/jquery.min.js',
                        'src/_compiled/js/bootstrap.min.js'
                    ]
                }]
            },
            polyfill: {
                files: [{
                    'src/_compiled/js/polyfill/master.min.js': [
                        'src/_compiled/js/polyfill/html5shiv.min.js',
                        'src/_compiled/js/polyfill/respond.min.js'
                    ]
                }]
            }
        },

        // Cleans directories which only contain minified files
        clean: {
            dist: {
                src: ['dist']
            },
            css: {
                src: ['src/_compiled/css/*']
            },
            js: {
                src: ['src/_compiled/js/*']
            },
            html: {
                src: ['src/_compiled/html/*']
            }
        },

        // Watches `src` files for changes, and performs appropriate tasks on-the-fly
        watch: {
            configFiles: {
                options: {
                    reload: true
                },
                files: ['gruntfile.js']
            },
            css: {
                files: ['src/css/**/*'],
                tasks: ['cssmin']
            },
            scss: {
                files: ['src/scss/**/*.sass', 'src/scss/**/*.scss'],
                tasks: ['sass:scss']
            },
            js: {
                files: ['src/js/**/*'],
                tasks: ['uglify']
            }
        },

        // Create directory template
        mkdir: {
            src: {
                options: {
                    create: [
                        'src/js',
                        'src/css',
                        'src/html',
                        'src/image'
                    ]
                }
            },
            dist: {
                options: {
                    create: [
                        'dist/js',
                        'dist/css',
                        'dist/html',
                        'dist/image'
                    ]
                }
            },
            test: {
                options: {
                    create: ['test']
                }
            },
            docs: {
                options: {
                    create: ['docs/image']
                }
            }
        }

    });

    // Load Grunt plugins
    require('time-grunt')(grunt);
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-minify-html');
    grunt.loadNpmTasks('grunt-mkdir');
    grunt.loadNpmTasks('grunt-postcss');
    grunt.loadNpmTasks('grunt-sass');

    // Register Grunt tasks
    //grunt.registerTask('default', ['Compilation-Tasks', 'watch']);

    grunt.registerTask('Make-Directories', ['mkdir:docs']);

    grunt.registerTask('Distribute', [
        'clean:dist',
        'concat',
        'copy:dist'
    ]);

    grunt.registerTask('Compilation-Tasks', [
        'Import-Missing-Assets',
        'Process-Files',
        'Minify-SRC'
    ]);

    grunt.registerTask('Import-Missing-Assets', [
        'copy:process__fontawesome',
        'copy:bower_components',
        'copy:bootstrap_assets',
        'copy:components'
    ]);

    grunt.registerTask('Process-Files', [
        'copy:process__html',
        'sass:scss',
        'postcss:css'
    ]);

    grunt.registerTask('Minify-SRC', [
        'cssmin',
        'uglify',
        'minifyHtml'
    ]);

};
<commit_msg>Simplified `postcss:css` code<commit_after>var module, require;

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

    // Configuration goes here
    grunt.initConfig({

        // Retrieve project's metadata
        pkg: grunt.file.readJSON('package.json'),

        mybanner:   '-------------------------------------\n' +
                    '         <%= pkg.name %>\n' +
                    'Copyright © <%= pkg.author.name %>  2015-<%= grunt.template.today("yyyy") %>\n' +
                    '-------------------------------------\n' +
                    '     Version: <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd") %>)',

        // Compiles Sass files into CSS files
        sass: {
            scss: {
                options: {
                    sourceMap: true
                },
                files: [{
                    expand: true,
                    cwd: 'src/scss/',
                    src: [
                        '**/*.sass',
                        '**/*.scss'
                    ],
                    dest: 'src/_compiled/css/',
                    ext: '.css'
                }]
            }
        },

        // Enhances CSS in order to be compatible with more browsers
        postcss: {
            css: {
                options: {
                    map: true,
                    processors: [
                        require('autoprefixer')({browsers: 'last 2 versions'})
                    ]
                },
                dist: {
                    files: [{
                        expand: true,
                        cwd: 'src/',
                        src: [
                            'css/**/*.css',
                            '_compiled/css/**/*.css',
                            '!_compiled/css/**/*.postcss.css'
                        ],
                        dest: 'src/_compiled/css/',
                        ext: '.postcss.css',
                        rename: function (dest, src) {
                            return dest + src.replace(/^_compiled\//, '').replace(/^css\//, '');
                        }
                    }]
                }
            }
        },

        // Minify CSS
        cssmin: {
            css: {
                options: {
                    //banner: '/*\n<%= mybanner %>\n*/\n',
                    sourceMap: true
                },
                files: [{
                    expand: true,
                    cwd: 'src/_compiled/css/',
                    src: ['**/*.postcss.css'],
                    dest: 'src/_compiled/css/',
                    ext: '.min.css'
                }]
            }
        },

        // Minify JavaScript
        uglify: {
            js: {
                options: {
                    //banner: '/*\n<%= mybanner %>\n*/\n',
                    preserveComments: false,
                    sourceMap: true
                },
                files: [{
                    expand: true,
                    cwd: 'src/js/',
                    src: ['**/*.js'],
                    dest: 'src/_compiled/js/',
                    ext: '.min.js'
                }]
            }
        },

        // Minify HTML
        minifyHtml: {
            html_minified: {
                options: {
                    conditionals: true
                },
                files: [{
                    expand: true,
                    cwd: 'src/_compiled/html/',
                    src: ['**/*.processed.html'],
                    dest: 'src/_compiled/html/',
                    ext: '.html',
                    filter: 'isFile'
                }]
            }
        },

        // Copies files from 3rd party sources to the `src` folder
        // Copies files from `src` folder to `dist` folder on production
        copy: {
            components: {
                files: [{
                    expand: true,
                    cwd: 'components/bootswatch/',
                    src: ['superhero/**'],
                    dest: 'src/scss/',
                    filter: function (dest) {
                        var output = grunt.task.current.data.files[0].dest + dest.replace(new RegExp('^' + this.cwd), '');
                        if (!grunt.file.isFile(dest)) { console.log('Not a file: ' + dest); return false; }
                        else if (grunt.file.exists(output)) { console.log('Already exists: ' + output); return false; }
                        else { return true; }
                    }
                }]
            },
            bootstrap_assets: {
                files: [{
                    expand: true,
                    cwd: 'bower_components/bootstrap-sass/assets/',
                    src: [
                        'stylesheets/bootstrap/**',
                        'stylesheets/_bootstrap.scss',
                        'fonts/bootstrap/**',
                        'javascripts/bootstrap.js'
                    ],
                    dest: 'src/',
                    filter: function (dest) {
                        var output = grunt.task.current.data.files[0].dest + dest.replace(new RegExp('^' + this.cwd), '').replace(/^stylesheets\//, 'scss/').replace(/^scss\/_/, 'scss/').replace(/^javascripts\//, 'js/');
                        if (!grunt.file.isFile(dest)) { console.log('Not a file: ' + dest); return false; }
                        else if (grunt.file.exists(output)) { console.log('Already exists: ' + output); return false; }
                        else { return true; }
                    },
                    rename: function (dest, src) {
                        return dest + src.replace(/^stylesheets\//, 'scss/').replace(/^scss\/_/, 'scss/').replace(/^javascripts\//, 'js/');
                    }
                }]
            },
            bower_components: {
                files: [{
                    expand: true,
                    cwd: 'bower_components/',
                    src: [
                        'font-awesome/scss/_**',
                        '!font-awesome/scss/_variables.scss',
                        'font-awesome/fonts/**',
                        'jquery/dist/jquery.js',
                        'html5shiv/dist/html5shiv.js',
                        'respond/dest/respond.src.js'
                    ],
                    dest: 'src/',
                    filter: function (dest) {
                        var output = grunt.task.current.data.files[0].dest + dest.replace(new RegExp('^' + this.cwd), '').replace(/^font-awesome\/(.*)\//, '$1/font-awesome/').replace(/^jquery\/dist\//, 'js/').replace(/^html5shiv\/dist\//, 'js/polyfill/').replace(/^respond\/dest\/respond.src.js/, 'js/polyfill/respond.js');
                        if (!grunt.file.isFile(dest)) { console.log('Not a file: ' + dest); return false; }
                        else if (grunt.file.exists(output)) { console.log('Already exists: ' + output); return false; }
                        else { return true; }
                    },
                    rename: function (dest, src) {
                        return dest + src.replace(/^font-awesome\/(.*)\//, '$1/font-awesome/').replace(/^jquery\/dist\//, 'js/').replace(/^html5shiv\/dist\//, 'js/polyfill/').replace(/^respond\/dest\/respond.src.js/, 'js/polyfill/respond.js');
                    }
                }]
            },
            process__fontawesome: {
                options: {
                    process: function (content, path) {
                        if (~path.indexOf('font-awesome.scss')) {
                            return content.replace(/@import "/g, '@import "font-awesome/');
                        } else if (~path.indexOf('_variables.scss')) {
                            return content.replace(/"\.\.\/fonts"/, '"../fonts/font-awesome"');
                        }
                    }
                },
                files: [{
                    expand: true,
                    cwd: 'bower_components/font-awesome/scss/',
                    src: [
                        'font-awesome.scss',
                        '_variables.scss'
                    ],
                    dest: 'src/scss/',
                    filter: function (dest) {
                        var output = grunt.task.current.data.files[0].dest + dest.replace(new RegExp('^' + this.cwd), '').replace(/^_/, 'font-awesome/_');
                        if (!grunt.file.isFile(dest)) { console.log('Not a file: ' + dest); return false; }
                        else if (grunt.file.exists(output)) { console.log('Already exists: ' + output); return false; }
                        else { return true; }
                    },
                    rename: function (dest, src) {
                        return dest + src.replace(/^_/, 'font-awesome/_');
                    }
                }]
            },
            process__html: {
                options: {
                    process: function (content, path) {
                        var strDepth = '../';
                        for (var i = path.match(/\//g).length - 2; i; i--) {
                            strDepth = strDepth + '../';
                        }
                        // RegExp to find an opening and closing custom tag
                        // The closing tag is mentioned twice; this helps the opening tag match with the first available closing tag (as opposed to the last found tag)
                        return content.replace(/<!--concat:css-->(?:(?!<!--\/concat-->)(?:.|\n))*<!--\/concat-->/g, '<link href="' + strDepth + 'css/master.min.css" rel="stylesheet">').replace(/<!--concat:js-->(?:(?!<!--\/concat-->)(?:.|\n))*<!--\/concat-->/g, '<link href="' + strDepth + 'js/master.min.js" rel="stylesheet">').replace(/<!--concat:polyfill-->(?:(?!<!--\/concat-->)(?:.|\n))*<!--\/concat-->/g, '<!--[if lt IE 9]><link href="' + strDepth + 'js/polyfill/master.min.js" rel="stylesheet"><![endif]-->').replace(/<!--concat:css_bootswatch-->(?:(?!<!--\/concat-->)(?:.|\n))*<!--\/concat-->/g, '<link href="' + strDepth + 'css/master_bootswatch.min.css" rel="stylesheet">');
                    }
                },
                files: [{
                    expand: true,
                    cwd: 'src/html/',
                    src: ['**'],
                    dest: 'src/_compiled/html/',
                    ext: '.processed.html',
                    filter: 'isFile'
                }]
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: 'src/_compiled/',
                    src: [
                        'css/**/*.min.css',
                        '../fonts/**',
                        'html/**/*.html', '!html/**/*.processed.html',
                        '../images/**',
                        'js/**/*.min.js',
                        '../../LICENSE',
                        '../../README.md'
                    ],
                    dest: 'dist/',
                    filter: 'isFile',
                    rename: function (dest, src) {
                        return dest + src.replace(/^(\.\.\/)+/, '');
                    }
                }]
            }
        },

        // Merges all CSS files, JS files, and polyfill files into single files
        // Allows for fewer HTTP requests, and faster browser load speeds
        concat: {
            css: {
                files: [{
                    'src/_compiled/css/master.min.css': [
                        'src/_compiled/css/bootstrap.min.css',
                        'src/_compiled/css/font-awesome.min.css'
                    ]
                }]
            },
            css_bootswatch: {
                files: [{
                    'src/_compiled/css/master_bootswatch.min.css': [
                        'src/_compiled/css/bootswatch.min.css',
                        'src/_compiled/css/font-awesome.min.css'
                    ]
                }]
            },
            js: {
                files: [{
                    'src/_compiled/js/master.min.js': [
                        'src/_compiled/js/jquery.min.js',
                        'src/_compiled/js/bootstrap.min.js'
                    ]
                }]
            },
            polyfill: {
                files: [{
                    'src/_compiled/js/polyfill/master.min.js': [
                        'src/_compiled/js/polyfill/html5shiv.min.js',
                        'src/_compiled/js/polyfill/respond.min.js'
                    ]
                }]
            }
        },

        // Cleans directories which only contain minified files
        clean: {
            dist: {
                src: ['dist']
            },
            css: {
                src: ['src/_compiled/css/*']
            },
            js: {
                src: ['src/_compiled/js/*']
            },
            html: {
                src: ['src/_compiled/html/*']
            }
        },

        // Watches `src` files for changes, and performs appropriate tasks on-the-fly
        watch: {
            configFiles: {
                options: {
                    reload: true
                },
                files: ['gruntfile.js']
            },
            css: {
                files: ['src/css/**/*'],
                tasks: ['cssmin']
            },
            scss: {
                files: ['src/scss/**/*.sass', 'src/scss/**/*.scss'],
                tasks: ['sass:scss']
            },
            js: {
                files: ['src/js/**/*'],
                tasks: ['uglify']
            }
        },

        // Create directory template
        mkdir: {
            src: {
                options: {
                    create: [
                        'src/js',
                        'src/css',
                        'src/html',
                        'src/image'
                    ]
                }
            },
            dist: {
                options: {
                    create: [
                        'dist/js',
                        'dist/css',
                        'dist/html',
                        'dist/image'
                    ]
                }
            },
            test: {
                options: {
                    create: ['test']
                }
            },
            docs: {
                options: {
                    create: ['docs/image']
                }
            }
        }

    });

    // Load Grunt plugins
    require('time-grunt')(grunt);
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-minify-html');
    grunt.loadNpmTasks('grunt-mkdir');
    grunt.loadNpmTasks('grunt-postcss');
    grunt.loadNpmTasks('grunt-sass');

    // Register Grunt tasks
    //grunt.registerTask('default', ['Compilation-Tasks', 'watch']);

    grunt.registerTask('Make-Directories', ['mkdir:docs']);

    grunt.registerTask('Distribute', [
        'clean:dist',
        'concat',
        'copy:dist'
    ]);

    grunt.registerTask('Compilation-Tasks', [
        'Import-Missing-Assets',
        'Process-Files',
        'Minify-SRC'
    ]);

    grunt.registerTask('Import-Missing-Assets', [
        'copy:process__fontawesome',
        'copy:bower_components',
        'copy:bootstrap_assets',
        'copy:components'
    ]);

    grunt.registerTask('Process-Files', [
        'copy:process__html',
        'sass:scss',
        'postcss:css'
    ]);

    grunt.registerTask('Minify-SRC', [
        'cssmin',
        'uglify',
        'minifyHtml'
    ]);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  /*
   * Include grunt configuration
   */
  var gruntConfig = require( './grunt.config.js' );

  /*
   * Helpers (preparing for grunt util deprecation)
   */
  var glob = require('glob');

  /*
   * Time grunt execution
   */
  require('time-grunt')(grunt);

	/*
   * JIT Grunt will automatically load other npm tasks
   */
  require('jit-grunt')(grunt);

  /*
   * Configuration
   */
	var gruntTasks = {
    //////////////
		pkg: grunt.file.readJSON('package.json'),
    /*
     * Placed at the top of the compiled source files.
     */
    meta: {
      banner:
        '/*\n' +
        ' * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
        ' * <%= pkg.repository.url %>\n' +
        ' *\n' +
        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
        ' * Licensed <%= pkg.licenses.type %> <<%= pkg.licenses.url %>>\n' +
        ' */\n'
    },
    //////////////
    copy: {
      build_app_js: {
        src: [
          findModuleFilesIn('./src/app/'),
          findModuleFilesIn('./src/common/'),
        ],
        dest: '<%= build_dir %>'
      },
      build_vendor_js: {
        src: ['<%= build.vendor_js %>'],
        dest: '<%= build_dir %>'
      },
      build_index: {
        src: ['./src/index.html'],
        dest: '<%= build_dir %>',
        expand: true,
        flatten: true,
        options: {
          process: processIndexBuild
        }
      }
    },
    /////////////////
    jshint: {
      options: {
        jshintrc: true
      },
      src_js: ['./src/**/*.js'],
      gruntfiles: ['./gruntfile.js', 'grunt.config.js']
    },
    /////////////////
    watch: {
      options: {
        livereload: true
      },
      src_js: {
        files: ['./src/**/*.js', './src/**/*.html', '!./src/index.html'],
        tasks: ['newer:jshint:src_js', 'newer:copy:build_app_js']
      },
      src_index: {
        files: ['./src/index.html'],
        tasks: ['copy:build_index']
      },
      gruntfiles: {
        files: ['./gruntfile.js', 'grunt.config.js'],
        tasks: ['newer:jshint:gruntfiles'],
        options: {
          livereload: false
        }
      },
    }
	};

  /////////////////
  grunt.initConfig(
    grunt.util._.extend(gruntTasks, gruntConfig)
  );

  /*
   * Helpers
   */
   /////////////////
  function findModuleFilesIn(modulePath){
    var output = [],
        i;

    for(i = 0; i <= gruntConfig.module_file_order.length-1; i++){
      output.push(modulePath + gruntConfig.module_file_order[i]);
    }

    return output;
  }

  //////////////
  function processIndexBuild(content){
    var buildScripts = [];
    var customModules = gruntConfig.build.vendor_js
                        .concat(findModuleFilesIn('./src/app/'))
                        .concat(findModuleFilesIn('./src/common/'));

    customModules.forEach(function(module){
      glob(module, { sync: true }, function(err, files){
        if(files.length > 0){
          buildScripts = files.concat(buildScripts);
        }
      });
    });

    return grunt.template.process(content, {
      data: {
        scripts: buildScripts.reverse()
      }
    });
  }

	/*
   * Tasks
   */
	grunt.registerTask('default', ['build', 'watch']);
  grunt.registerTask('build', ['copy:build_app_js', 'copy:build_vendor_js', 'copy:build_index']);
  grunt.registerTask('compile', []);
};
<commit_msg>removed some sneaky tabs from the gruntfile<commit_after>module.exports = function(grunt) {
  /*
   * Include grunt configuration
   */
  var gruntConfig = require( './grunt.config.js' );

  /*
   * Helpers (preparing for grunt util deprecation)
   */
  var glob = require('glob');

  /*
   * Time grunt execution
   */
  require('time-grunt')(grunt);

  /*
   * JIT Grunt will automatically load other npm tasks
   */
  require('jit-grunt')(grunt);

  /*
   * Configuration
   */
  var gruntTasks = {
    //////////////
    pkg: grunt.file.readJSON('package.json'),
    /*
     * Placed at the top of the compiled source files.
     */
    meta: {
      banner:
        '/*\n' +
        ' * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
        ' * <%= pkg.repository.url %>\n' +
        ' *\n' +
        ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
        ' * Licensed <%= pkg.licenses.type %> <<%= pkg.licenses.url %>>\n' +
        ' */\n'
    },
    //////////////
    copy: {
      build_app_js: {
        src: [
          findModuleFilesIn('./src/app/'),
          findModuleFilesIn('./src/common/'),
        ],
        dest: '<%= build_dir %>'
      },
      build_vendor_js: {
        src: ['<%= build.vendor_js %>'],
        dest: '<%= build_dir %>'
      },
      build_index: {
        src: ['./src/index.html'],
        dest: '<%= build_dir %>',
        expand: true,
        flatten: true,
        options: {
          process: processIndexBuild
        }
      }
    },
    /////////////////
    jshint: {
      options: {
        jshintrc: true
      },
      src_js: ['./src/**/*.js'],
      gruntfiles: ['./gruntfile.js', 'grunt.config.js']
    },
    /////////////////
    watch: {
      options: {
        livereload: true
      },
      src_js: {
        files: ['./src/**/*.js', './src/**/*.html', '!./src/index.html'],
        tasks: ['newer:jshint:src_js', 'newer:copy:build_app_js']
      },
      src_index: {
        files: ['./src/index.html'],
        tasks: ['copy:build_index']
      },
      gruntfiles: {
        files: ['./gruntfile.js', 'grunt.config.js'],
        tasks: ['newer:jshint:gruntfiles'],
        options: {
          livereload: false
        }
      },
    }
  };

  /////////////////
  grunt.initConfig(
    grunt.util._.extend(gruntTasks, gruntConfig)
  );

  /*
   * Helpers
   */
   /////////////////
  function findModuleFilesIn(modulePath){
    var output = [],
        i;

    for(i = 0; i <= gruntConfig.module_file_order.length-1; i++){
      output.push(modulePath + gruntConfig.module_file_order[i]);
    }

    return output;
  }

  //////////////
  function processIndexBuild(content){
    var buildScripts = [];
    var customModules = gruntConfig.build.vendor_js
                        .concat(findModuleFilesIn('./src/app/'))
                        .concat(findModuleFilesIn('./src/common/'));

    customModules.forEach(function(module){
      glob(module, { sync: true }, function(err, files){
        if(files.length > 0){
          buildScripts = files.concat(buildScripts);
        }
      });
    });

    return grunt.template.process(content, {
      data: {
        scripts: buildScripts.reverse()
      }
    });
  }

  /*
   * Tasks
   */
  grunt.registerTask('default', ['build', 'watch']);
  grunt.registerTask('build', ['copy:build_app_js', 'copy:build_vendor_js', 'copy:build_index']);
  grunt.registerTask('compile', []);
};<|endoftext|>


<commit_before>'use strict';

var DynamoDbLocal = require('dynamodb-local');
var DYNAMO_DB_PORT = 8000;

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      app: {
        src: ['gruntfile.js', 'index.js', 'lib/**/*.js'],
        options: {
          node: true,
          jshintrc: '.jshintrc'
        }
      },
      test: {
        src: ['test/**/*.js' ],
        options: {
          node: true,
          jshintrc: 'test/.jshintrc'
        }
      }
    },
    mochaTest: {
      test: {
        options: {
          reporter: 'spec'
        },
        src: ['test/**/*.js']
      },
      testCoverage: {
        options: {
          reporter: 'spec',
          require: 'test/coverage/blanket'
        },
        src: ['test/**/*.js']
      },
      coverage: {
        options: {
          reporter: 'html-cov',
          // use the quiet flag to suppress the mocha console output
          quiet: true,
          // specify a destination file to capture the mocha
          // output (the quiet option does not suppress this)
          captureFile: 'coverage.html'
        },
        src: ['test/**/*.js']
      },
      'travis-cov': {
        options: {
          reporter: 'travis-cov'
        },
        src: ['test/**/*.js']
      }
    }
  });

  // Load libs
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-mocha-test');

  grunt.registerTask('dynamo:start', function() {
    var done = this.async();
    DynamoDbLocal
        .launch(DYNAMO_DB_PORT)
        .then(function() { done(); })
        .catch(function(e) { done(e); });
  });

  grunt.registerTask('dynamo:stop', function() {
      DynamoDbLocal.stop(DYNAMO_DB_PORT);
  });

  // Register the default tasks
  grunt.registerTask('default', ['jshint', 'dynamo:start', 'mochaTest']);

  grunt.registerTask('test', ['jshint', 'dynamo:start', 'mochaTest:test']);

  grunt.registerTask('coverage', ['jshint', 'dynamo:start', 'mochaTest:testCoverage', 'mochaTest:coverage', 'mochaTest:travis-cov']);

};<commit_msg>Kill existing DynamoDBLocal before starting<commit_after>'use strict';

var DynamoDbLocal = require('dynamodb-local');
var DYNAMO_DB_PORT = 8000;

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jshint: {
      app: {
        src: ['gruntfile.js', 'index.js', 'lib/**/*.js'],
        options: {
          node: true,
          jshintrc: '.jshintrc'
        }
      },
      test: {
        src: ['test/**/*.js' ],
        options: {
          node: true,
          jshintrc: 'test/.jshintrc'
        }
      }
    },
    mochaTest: {
      test: {
        options: {
          reporter: 'spec'
        },
        src: ['test/**/*.js']
      },
      testCoverage: {
        options: {
          reporter: 'spec',
          require: 'test/coverage/blanket'
        },
        src: ['test/**/*.js']
      },
      coverage: {
        options: {
          reporter: 'html-cov',
          // use the quiet flag to suppress the mocha console output
          quiet: true,
          // specify a destination file to capture the mocha
          // output (the quiet option does not suppress this)
          captureFile: 'coverage.html'
        },
        src: ['test/**/*.js']
      },
      'travis-cov': {
        options: {
          reporter: 'travis-cov'
        },
        src: ['test/**/*.js']
      }
    }
  });

  // Load libs
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-mocha-test');

  grunt.registerTask('dynamo:start', function() {
    var getPID = 'ps aux | grep "DynamoDBLocal.jar -port ' +
                 DYNAMO_DB_PORT  +
                 '" | grep -v grep | awk \'{print $2}\'';
    var done = this.async();
    require('child_process').exec(getPID, function (err, pid) {
      if(err) {
        return done(err);
      }
      if(pid) {
        console.log('Killing DynamoDBLocal process');
        process.kill(pid);
      } else {
        console.log('No DynamoDBLocal process running');
      }

      DynamoDbLocal
      .launch(DYNAMO_DB_PORT)
      .then(function() { done(); })
      .catch(function(e) { done(e); });
    });
  });

  // Register the default tasks
  grunt.registerTask('default', ['jshint', 'dynamo:start', 'mochaTest']);

  grunt.registerTask('test', ['jshint', 'dynamo:start', 'mochaTest:test']);

  grunt.registerTask('coverage', ['jshint', 'dynamo:start', 'mochaTest:testCoverage', 'mochaTest:coverage', 'mochaTest:travis-cov']);

};
<|endoftext|>