<commit_before>// Gruntfile.js
module.exports = function(grunt) {
  require('time-grunt')(grunt);
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    watch: {
      sass: {
        files: 'scss/**/**/*.scss',
        tasks: ['build', 'docs']
      },
      eslint: {
        files: 'js/**/*.js',
        tasks: ['eslint']
      },
      docs: {
        files: ['docs/**/*.*', 'scss/**/**/*.scss'],
        tasks: ['docs']
      }
    },
    clean: {
      grunticon: ['dist/assets/icons/ui', 'dist/assets/icons/thematic'],
      svg: ['icons/ui/dist']
    },
    pure_grids: {
      responsive: {
        dest: 'scss/css/_grid-units.scss',
        options: {
          units: [5,12,24],
          includeOldIEWidths: false,
          mediaQueries: {
            sm: 'screen and (min-width: 36.5em)', //584px
            md: 'screen and (min-width: 48em)', //768px
            lg: 'screen and (min-width: 64em)', //1024px
            xl: 'screen and (min-width: 80em)'  //1200px
          },
          selectorPrefix: '.wfp-u-'
        }
      }
    },
    sass: {
      options: {
        outputStyle: 'expanded',
        sourceMap: true,
        indentedSyntax: true,
        sassDir: 'scss',
        cssDir: 'dist/css',
        includePaths: [
          'bower_components/normalize-scss',
          'bower_components/mathsass/dist'
        ]
      },
      dev: {
        files: [{
          expand: true,
          cwd: 'scss/',
          src: ['*.scss'],
          dest: 'dist/css/',
          ext: '.css'
        }]
      },
      dist: {
        options: {
          sourceMap: false
        },
        files: [{
          expand: true,
          cwd: 'scss/',
          src: ['*.scss'],
          dest: 'dist/css/',
          ext: '.css'
        }]
      },
      docs: {
        files: {
          'docs/css/main.css': 'docs/_sass/main.scss',
          'docs/css/bootstrap-theme.css': 'scss/bootstrap-theme.scss'
        }
      },
      docsDist: {
        options: {
          sourceMap: false
        },
        files: {
          'docs/css/main.css': 'docs/_sass/main.scss',
          'docs/css/bootstrap-theme.css': 'scss/bootstrap-theme.scss'
        }
      }
    },
    postcss: {
      options: {
        syntax: require('postcss-scss'),
        processors: [
          require('autoprefixer')({ browsers: ['last 2 version'] }),
          require('pixrem')(),
          require('postcss-wcag-contrast')()
        ],
        map: {
          inline: false,
        }
      },
      dist: {
        options: {
          processors: [
            require('autoprefixer')({ browsers: ['last 2 version'] }),
            require('pixrem')(),
            require('postcss-wcag-contrast')(),
            require('cssnano')()
          ],
          map: false
        },
        src: 'dist/css/*.css'
      },
      dev: {
        src: 'dist/css/*.css'
      },
      docs: {
        options: {
          processors: [
            require('autoprefixer')({ browsers: ['last 2 version'] }),
            require('pixrem')()
          ]
        },
        src: 'docs/css/*.css'
      },
      docsDist: {
        options: {
          processors: [
            require('autoprefixer')({ browsers: ['last 2 version'] }),
            require('pixrem')(),
            require('cssnano')()
          ],
          map: false
        },
        src: 'docs/css/*.css'
      }
    },
    grunticon: {
      ui: {
        files: [{
          expand: true,
          cwd: 'icons/ui/src',
          src: ['*.svg'],
          dest: 'dist/assets/icons/ui'
        }],
        options: {
          dynamicColorOnly: true,
          colors: {
            light: '#ffffff',
            dark: '#000000'
          },
          datasvgcss: 'ui-icons.svg.css',
          datapngcss: 'ui-icons.png.css',
          urlpngcss: 'ui-icons.fallback.css'
        }
      },
      thematic: {
        files: [{
          expand: true,
          cwd: 'icons/thematic',
          src: ['*.svg'],
          dest: 'dist/assets/icons/thematic'
        }],
        options: {
          datasvgcss: 'thematic-icons.svg.css',
          datapngcss: 'thematic-icons.png.css',
          urlpngcss: 'thematic-icons.fallback.css',
          cssprefix: '.thematic-'
        }
      }
    },
    svgtoolkit: {
      light: {
        options: {
          generatePNGs: false,
          colorize: '#ffffff'
        },
        files: [{
          expand: true,
          cwd: 'icons/ui/src',
          src: '*.svg',
          dest: 'icons/ui/dist/light'
        }]
      },
      dark: {
        options: {
          generatePNGs: false,
          colorize: '#232323'
        },
        files: [{
          expand: true,
          cwd: 'icons/ui/src',
          src: '*.svg',
          dest: 'icons/ui/dist/dark'
        }]
      },
      primary: {
        options: {
          generatePNGs: false,
          colorize: '#2A93FC'
        },
        files: [{
          expand: true,
          cwd: 'icons/ui/src',
          src: '*.svg',
          dest: 'icons/ui/dist/primary'
        }]
      }
    },
    datauri: {
      light: {
        options: {
          classPrefix: 'icon-light-',
          usePlaceholder: true
        },
        files: [{
          src: 'icons/ui/dist/light/**/*.svg',
          dest: 'scss/icons/_icons-light.scss'
        }]
      },
      dark: {
        options: {
          classPrefix: 'icon-dark-',
          usePlaceholder: true
        },
        files: [{
          src: 'icons/ui/dist/dark/**/*.svg',
          dest: 'scss/icons/_icons-dark.scss'
        }]
      },
      primary: {
        options: {
          classPrefix: 'icon-primary-',
          usePlaceholder: true
        },
        files: [{
          src: 'icons/ui/dist/primary/**/*.svg',
          dest: 'scss/icons/_icons-primary.scss'
        }]
      }
    },
    jekyll: {
      dist: {
        options: {
          src: './docs',
          config: './docs/_config.yml',
          dest: './dist/docs'
        }
      }
    },
    uglify: {
      options: {
        mangle: false,
        wrap: false,
        screwIE8: true
      },
      dist: {
        files: {
          'dist/js/responsive-nav.min.js': ['js/responsive-nav.js']
        }
      },
      docs: {
        options: {
          compress: false,
          beautify: {
            beautify: true,
            indent_level: 2
          },
          preserveComments: 'all',
          screwIE8: true
        },
        files: {
          'docs/js/lib/responsive-nav.js': ['js/responsive-nav.js']
        }
      }
    },
    eslint: {
      target: ['js/**/**/*.js'],
      options: {
        ignorePattern: ['js/lib/**/*.js']
      }
    },
    sasslint: {
      options: {
        config: '.sass-lint.yml',
      },
      target: ['scss/**/**/*.scss']
    },
    htmlaudit: {
      default: {
        options: {
          baseUri: 'http://cdn.wfp.org/guides/ui/v0.11.0/'
        },
        src: './dist/docs/*.html'
      },
      ci: {
        options: {
          tests: {
            a11y: true,
            html5: true,
            link: false
          },
          showSummaryOnly: true
        },
        src: './dist/docs/*.html'
      }
    },
    copy: {
      docsJS: {
        src: './dist/js/responsive-nav.min.js',
        dest: './docs/js/lib/responsive-nav.min.js'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-datauri');
  grunt.loadNpmTasks('grunt-eslint');
  grunt.loadNpmTasks('grunt-grunticon');
  grunt.loadNpmTasks('grunt-html-auditor');
  grunt.loadNpmTasks('grunt-jekyll');
  grunt.loadNpmTasks('grunt-postcss');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-sass-lint');
  grunt.loadNpmTasks('grunt-svg-toolkit');
  grunt.loadNpmTasks('grunt-pure-grids');

  // Build SVGs and SCSS
  grunt.registerTask('gen-svg', ['clean:svg', 'svgtoolkit', 'datauri', 'clean:svg']);
  // Build Grunticon Icons
  grunt.registerTask('gen-icons', ['clean:grunticon', 'grunticon']);
  // Build WFP UI Docs locally
  grunt.registerTask('docs', ['sass:docs', 'copy', 'postcss:docs', 'uglify:docs', 'jekyll']);
  // Build WFP UI Docs
  grunt.registerTask('docs-build', ['sasslint', 'sass:docs', 'copy', 'uglify:docs', 'postcss:docs', 'jekyll']);
  // Build dist-ready WFP UI Docs
  grunt.registerTask('docs-dist', ['sass:docsDist', 'copy', 'postcss:docsDist', 'uglify:docs', 'jekyll']);
  // Build WFP UI
  grunt.registerTask('build', ['eslint', 'sasslint', 'sass:dev', 'postcss:dev']);
  // Build all assets for distribution
  grunt.registerTask('dist-assets', ['gen-svg', 'gen-icons']);
  // Build a dist-ready WFP UI with all stati resources
  grunt.registerTask('dist', ['sass:dist', 'postcss:dist', 'uglify:dist']);
  // Run build and dist task in sequence (for Travis CI)
  grunt.registerTask('test', ['eslint', 'sasslint', 'htmlaudit:ci']);
  // Set default grunt task to `dist`
  grunt.registerTask('default', ['dist']);
};
<commit_msg>fix broken `uglify` path<commit_after>// Gruntfile.js
module.exports = function(grunt) {
  require('time-grunt')(grunt);
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    watch: {
      sass: {
        files: 'scss/**/**/*.scss',
        tasks: ['build', 'docs']
      },
      eslint: {
        files: 'js/**/*.js',
        tasks: ['eslint']
      },
      docs: {
        files: ['docs/**/*.*', 'scss/**/**/*.scss'],
        tasks: ['docs']
      }
    },
    clean: {
      grunticon: ['dist/assets/icons/ui', 'dist/assets/icons/thematic'],
      svg: ['icons/ui/dist']
    },
    pure_grids: {
      responsive: {
        dest: 'scss/css/_grid-units.scss',
        options: {
          units: [5,12,24],
          includeOldIEWidths: false,
          mediaQueries: {
            sm: 'screen and (min-width: 36.5em)', //584px
            md: 'screen and (min-width: 48em)', //768px
            lg: 'screen and (min-width: 64em)', //1024px
            xl: 'screen and (min-width: 80em)'  //1200px
          },
          selectorPrefix: '.wfp-u-'
        }
      }
    },
    sass: {
      options: {
        outputStyle: 'expanded',
        sourceMap: true,
        indentedSyntax: true,
        sassDir: 'scss',
        cssDir: 'dist/css',
        includePaths: [
          'bower_components/normalize-scss',
          'bower_components/mathsass/dist'
        ]
      },
      dev: {
        files: [{
          expand: true,
          cwd: 'scss/',
          src: ['*.scss'],
          dest: 'dist/css/',
          ext: '.css'
        }]
      },
      dist: {
        options: {
          sourceMap: false
        },
        files: [{
          expand: true,
          cwd: 'scss/',
          src: ['*.scss'],
          dest: 'dist/css/',
          ext: '.css'
        }]
      },
      docs: {
        files: {
          'docs/css/main.css': 'docs/_sass/main.scss',
          'docs/css/bootstrap-theme.css': 'scss/bootstrap-theme.scss'
        }
      },
      docsDist: {
        options: {
          sourceMap: false
        },
        files: {
          'docs/css/main.css': 'docs/_sass/main.scss',
          'docs/css/bootstrap-theme.css': 'scss/bootstrap-theme.scss'
        }
      }
    },
    postcss: {
      options: {
        syntax: require('postcss-scss'),
        processors: [
          require('autoprefixer')({ browsers: ['last 2 version'] }),
          require('pixrem')(),
          require('postcss-wcag-contrast')()
        ],
        map: {
          inline: false,
        }
      },
      dist: {
        options: {
          processors: [
            require('autoprefixer')({ browsers: ['last 2 version'] }),
            require('pixrem')(),
            require('postcss-wcag-contrast')(),
            require('cssnano')()
          ],
          map: false
        },
        src: 'dist/css/*.css'
      },
      dev: {
        src: 'dist/css/*.css'
      },
      docs: {
        options: {
          processors: [
            require('autoprefixer')({ browsers: ['last 2 version'] }),
            require('pixrem')()
          ]
        },
        src: 'docs/css/*.css'
      },
      docsDist: {
        options: {
          processors: [
            require('autoprefixer')({ browsers: ['last 2 version'] }),
            require('pixrem')(),
            require('cssnano')()
          ],
          map: false
        },
        src: 'docs/css/*.css'
      }
    },
    grunticon: {
      ui: {
        files: [{
          expand: true,
          cwd: 'icons/ui/src',
          src: ['*.svg'],
          dest: 'dist/assets/icons/ui'
        }],
        options: {
          dynamicColorOnly: true,
          colors: {
            light: '#ffffff',
            dark: '#000000'
          },
          datasvgcss: 'ui-icons.svg.css',
          datapngcss: 'ui-icons.png.css',
          urlpngcss: 'ui-icons.fallback.css'
        }
      },
      thematic: {
        files: [{
          expand: true,
          cwd: 'icons/thematic',
          src: ['*.svg'],
          dest: 'dist/assets/icons/thematic'
        }],
        options: {
          datasvgcss: 'thematic-icons.svg.css',
          datapngcss: 'thematic-icons.png.css',
          urlpngcss: 'thematic-icons.fallback.css',
          cssprefix: '.thematic-'
        }
      }
    },
    svgtoolkit: {
      light: {
        options: {
          generatePNGs: false,
          colorize: '#ffffff'
        },
        files: [{
          expand: true,
          cwd: 'icons/ui/src',
          src: '*.svg',
          dest: 'icons/ui/dist/light'
        }]
      },
      dark: {
        options: {
          generatePNGs: false,
          colorize: '#232323'
        },
        files: [{
          expand: true,
          cwd: 'icons/ui/src',
          src: '*.svg',
          dest: 'icons/ui/dist/dark'
        }]
      },
      primary: {
        options: {
          generatePNGs: false,
          colorize: '#2A93FC'
        },
        files: [{
          expand: true,
          cwd: 'icons/ui/src',
          src: '*.svg',
          dest: 'icons/ui/dist/primary'
        }]
      }
    },
    datauri: {
      light: {
        options: {
          classPrefix: 'icon-light-',
          usePlaceholder: true
        },
        files: [{
          src: 'icons/ui/dist/light/**/*.svg',
          dest: 'scss/icons/_icons-light.scss'
        }]
      },
      dark: {
        options: {
          classPrefix: 'icon-dark-',
          usePlaceholder: true
        },
        files: [{
          src: 'icons/ui/dist/dark/**/*.svg',
          dest: 'scss/icons/_icons-dark.scss'
        }]
      },
      primary: {
        options: {
          classPrefix: 'icon-primary-',
          usePlaceholder: true
        },
        files: [{
          src: 'icons/ui/dist/primary/**/*.svg',
          dest: 'scss/icons/_icons-primary.scss'
        }]
      }
    },
    jekyll: {
      dist: {
        options: {
          src: './docs',
          config: './docs/_config.yml',
          dest: './dist/docs'
        }
      }
    },
    uglify: {
      options: {
        mangle: false,
        wrap: false,
        screwIE8: true
      },
      dist: {
        files: {
          'dist/js/responsive-nav.min.js': ['js/lib/responsive-nav.js']
        }
      },
      docs: {
        options: {
          compress: false,
          beautify: {
            beautify: true,
            indent_level: 2
          },
          preserveComments: 'all',
          screwIE8: true
        },
        files: {
          'docs/js/lib/responsive-nav.js': ['js/lib/responsive-nav.js']
        }
      }
    },
    eslint: {
      target: ['js/**/**/*.js'],
      options: {
        ignorePattern: ['js/lib/**/*.js']
      }
    },
    sasslint: {
      options: {
        config: '.sass-lint.yml',
      },
      target: ['scss/**/**/*.scss']
    },
    htmlaudit: {
      default: {
        options: {
          baseUri: 'http://cdn.wfp.org/guides/ui/v0.11.0/'
        },
        src: './dist/docs/*.html'
      },
      ci: {
        options: {
          tests: {
            a11y: true,
            html5: true,
            link: false
          },
          showSummaryOnly: true
        },
        src: './dist/docs/*.html'
      }
    },
    copy: {
      docsJS: {
        src: './dist/js/responsive-nav.min.js',
        dest: './docs/js/lib/responsive-nav.min.js'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-datauri');
  grunt.loadNpmTasks('grunt-eslint');
  grunt.loadNpmTasks('grunt-grunticon');
  grunt.loadNpmTasks('grunt-html-auditor');
  grunt.loadNpmTasks('grunt-jekyll');
  grunt.loadNpmTasks('grunt-postcss');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-sass-lint');
  grunt.loadNpmTasks('grunt-svg-toolkit');
  grunt.loadNpmTasks('grunt-pure-grids');

  // Build SVGs and SCSS
  grunt.registerTask('gen-svg', ['clean:svg', 'svgtoolkit', 'datauri', 'clean:svg']);
  // Build Grunticon Icons
  grunt.registerTask('gen-icons', ['clean:grunticon', 'grunticon']);
  // Build WFP UI Docs locally
  grunt.registerTask('docs', ['sass:docs', 'copy', 'postcss:docs', 'uglify:docs', 'jekyll']);
  // Build WFP UI Docs
  grunt.registerTask('docs-build', ['sasslint', 'sass:docs', 'copy', 'uglify:docs', 'postcss:docs', 'jekyll']);
  // Build dist-ready WFP UI Docs
  grunt.registerTask('docs-dist', ['sass:docsDist', 'copy', 'postcss:docsDist', 'uglify:docs', 'jekyll']);
  // Build WFP UI
  grunt.registerTask('build', ['eslint', 'sasslint', 'sass:dev', 'postcss:dev']);
  // Build all assets for distribution
  grunt.registerTask('dist-assets', ['gen-svg', 'gen-icons']);
  // Build a dist-ready WFP UI with all stati resources
  grunt.registerTask('dist', ['sass:dist', 'postcss:dist', 'uglify:dist']);
  // Run build and dist task in sequence (for Travis CI)
  grunt.registerTask('test', ['eslint', 'sasslint', 'htmlaudit:ci']);
  // Set default grunt task to `dist`
  grunt.registerTask('default', ['dist']);
};
<|endoftext|>


<commit_before>#!/usr/bin/env node

const minimist = require('minimist');
const webpack = require('webpack');
const webpackDevServer = require('webpack-dev-server');
const webpackConfig = require('../config/webpack.config.cmd');

const options = minimist(process.argv.slice(2));
const port = options.p || 3000;

let compiler = webpack(webpackConfig);
let webpackServer = new webpackDevServer(compiler, {
    clientLogLevel: 'error',
    quiet: true,
});

webpackServer.listen(port, error => {
    if (error) {
        console.error(error.message);
        process.exit(1);
    }
    global.console.log(`
    launching admin on http://localhost:${port}
    press Ctrl+C to end`);
});
<commit_msg>open tab automatically<commit_after>#!/usr/bin/env node

const minimist = require('minimist');
const webpack = require('webpack');
const webpackDevServer = require('webpack-dev-server');
const exec = require('child_process').exec;

const runCommand = cmd =>
    new Promise((resolve, reject) => {
        exec(cmd, error => {
            if (error) {
                reject(error);
                return;
            }

            resolve();
        });
    });

const webpackConfig = require('../config/webpack.config.cmd');

const options = minimist(process.argv.slice(2));
const port = options.p || 3000;

let compiler = webpack(webpackConfig);
let webpackServer = new webpackDevServer(compiler, {
    clientLogLevel: 'error',
    quiet: true,
});

webpackServer.listen(port, error => {
    if (error) {
        console.error(error.message);
        process.exit(1);
    }
    global.console.log(`
    launching admin on http://localhost:${port}
    press Ctrl+C to end`);

    runCommand(`python -m webbrowser http://localhost:${port}`).catch(() => {
        // python -m webbrowser is not supported (rare), the user will just need to open the browser by hand
    });
});
<|endoftext|>


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

    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]
            },
            sourceSolidApi17Jar: {
                src: [outDir + "/framework/assets/bindings/WORKINGDIR/"]
            },
            javaRuntime: {
                src: ["./src/libs/nativescript.jar"]
            }
        },
        mkdir: {
            build: {
                options: {
                    create: [outDir]
                }
            },
            solidApi17JarDir: {
                options: {
                    mode: 0777,
                    create: [outDir + "/framework/assets/bindings/WORKINGDIR/"]
                }
            },
        },
        copy: {
            pkgDef: {
                src: [
                    rootDir + "/package.json"
                ],
                dest: outDir + "/",
                options: {
                    process: updatePackageVersion
                }
            },
            templateProject: {
                expand: true,
                dot: true,
                cwd: rootDir + "/build/project-template/",
                src: [
                    "**/*.*"
                ],
                dest: outDir + "/"
            },
            baseLibJars: {
                expand: true,
                cwd: generatorDir + "/jars/",
                src: [
                    "*.jar",
                    "!android17.jar"
                ],
                dest: outDir + "/framework/libs/"
            },
            internalFolder: {
                expand: true,
                cwd: rootDir + "/src/assets",
                src: ["internal/**/*.*"],
                dest: 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 + "/"
            },
            createNativeRuntimeAntBuildFiles: {
                cmd: "android update project --target 1 --name NativeScriptRuntime --path ./",
                cwd: rootDir + "/src/"
            },
            revertToCustomizedBuildFiles: {
                cmd: "git checkout -- src/project.properties src/proguard-project.txt",
            },
            revert_ndk_configuration: {
                cmd: "git checkout -- src/jni/Application.mk",
            },
            buildCPPRuntime: {
                cmd: "ndk-build",
                cwd: rootDir + "/src/"
            },
            buildJavaRuntimeClasses: {
                cmd: "ant release",
                cwd: rootDir + "/src/"
            },
            ensureOriginalVersionFile: {
                cmd: "git checkout -- " + localCfg.runtimeVersionHFile
            },
            ensureOriginalManifestFile: {
                cmd: "git checkout -- ./src/manifest.mf"
            },
            jarJavaRuntime: {
                cmd: "jar cfm ../../" + "/libs/nativescript.jar ../../manifest.mf com",
                cwd: rootDir + "/src/bin/classes/"
            }
        }
    });

    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("updateVersionFile", [
        "exec:ensureOriginalVersionFile",
        "copy:updateVersionFile"
    ]);

    grunt.registerTask("generateBindingsAndMetadata", [
                            "copy:internalFolder",
                            "exec:createNativeRuntimeAntBuildFiles",
                            "exec:revertToCustomizedBuildFiles",
                            "exec:buildJavaRuntimeClasses",
                            "exec:ensureOriginalManifestFile",
                            "copy:updateManifestFile",
                            "clean:javaRuntime",
                            "exec:jarJavaRuntime",
//                            "exec:generateMetadata",
//                            "copy:metadata",
//                            "exec:generateNormalJars",
//                            "generateApi17Jars",
//                            "copy:normalJars",
                            "exec:ensureOriginalManifestFile"
                        ]);

    grunt.registerTask("generateCPPRuntime", [
                            "replace:ndk_configuration",
                            "updateVersionFile",
                            "exec:buildCPPRuntime",
                            "copy:CPPRuntime",
                            "exec:revert_ndk_configuration",
                            "exec:ensureOriginalVersionFile"
                       ]);

    grunt.registerTask("generateApi17Jars", [
                "mkdir:solidApi17JarDir",
                "rename:solidApi17Jar",
                "exec:splitSolidApi17Jar",
                "clean:sourceSolidApi17Jar",
                "renameDexFile:3",
                "renameDexFile:2",
                "renameDexFile:1"
            ]);

    grunt.registerTask("default", [
                            "clean:build",
                            "mkdir:build",
                            "copy:templateProject",
                            "copy:pkgDef",
                            "generateCPPRuntime",
                            "generateBindingsAndMetadata",
//                            "copy:baseLibJars",
                            "clean:javaRuntime",
//                            "exec:npmPack"
                        ]);

}
<commit_msg>Call the runtime build. Define tasks to collect the rest of the package files<commit_after>module.exports = function(grunt) {

    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: rootDir + "/build/project-template/",
                src: [
                    "**/*.*"
                ],
                dest: outDir + "/"
            },
            internalFolder: {
                expand: true,
                cwd: rootDir + "/src/assets",
                src: ["internal/**/*.*"],
                dest: 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:pkgDef",
                            "generateRuntime",
//                            "generateMetadata",
//                            "collectBindings",
                            "exec:npmPack"
                        ]);

}
<|endoftext|>


<commit_before>import React from 'react';
import ListenerMixin from 'alt/mixins/ListenerMixin'
import mixin from 'react-mixin';
import SettingsStore from '../stores/settings-store';
import MenuItem from './menu-item';

function getStateFromStores() {
    return {settings: SettingsStore.getState()};
}

class Menu extends React.Component {
    constructor(props) {
        super(props);
        this.state = {settings: props.settings};
        console.log('menu state', this.state);
        //this.onChange = this.onChange.bind(this);
    }
    componentDidMount () {
        this.listenTo(SettingsStore, this._onChange.bind(this));
    }
    _onChange () {

        this.setState(getStateFromStores().settings);
    }
    onSelect () {

    }
    onMenuClick (e) {

    }
    render() {
        console.log('menu state',this.state.settings);
        let self = this;
        let settingNodes = this.state.settings.map((setting) => {
            return (<MenuItem setting={setting}></MenuItem>)
        })
        return (

                Menu

                    <button className="compose-button">Compose</button>

                            {settingNodes}

Labels

Personal

Work

Travel

        );
    }
}

Menu.defaultProps = { settings: [{name:''}]}

mixin(Menu.prototype, ListenerMixin);

export default Menu;<commit_msg>events<commit_after>'use strict';
import React from 'react';
import ListenerMixin from 'alt/mixins/ListenerMixin';
import mixin from 'react-mixin';
import SettingsStore from '../stores/settings-store';
import MenuItem from './menu-item';

function getStateFromStores() {
    return {settings: SettingsStore.getState()};
}

class Menu extends React.Component {
    constructor(props) {
        super(props);
        this.state = {settings: props.settings};
        console.log('menu state', this.state);
        this._composeClicked = this._composeClicked.bind(this);
        //this.onChange = this.onChange.bind(this);
    }
    componentDidMount () {
        this.listenTo(SettingsStore, this._onChange.bind(this));
    }
    _composeClicked() {

    }
    _onChange () {

        this.setState(getStateFromStores().settings);
    }
    onSelect () {

    }
    onMenuClick (e) {

    }
    render() {
        console.log('menu state',this.state.settings);
        let self = this;
        let settingNodes = this.state.settings.map((setting) => {
            return (<MenuItem setting={setting}></MenuItem>)
        })
        return (

                Menu

                    <button className="compose-button" onClick={this._composeClicked}>Compose</button>

                            {settingNodes}

Labels

Personal

Work

Travel

        );
    }
}

Menu.defaultProps = { settings: [{name:''}]}

mixin(Menu.prototype, ListenerMixin);

export default Menu;<|endoftext|>


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

  var sourceOrigin = 'src/**/*.js';

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      dist: {
        src: [sourceOrigin],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */\n',
        report: 'gzip'
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
        }
      }
    },
    jshint: {
      files: ['gruntfile.js', sourceOrigin],
      options: grunt.file.readJSON('.jshintrc')
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  grunt.registerTask('test', 'Lints and unit tests', ['jshint']);
  grunt.registerTask('default', 'Default task', ['test', 'concat', 'uglify']);

};
<commit_msg>Updated gruntfile using udefine<commit_after>module.exports = function(grunt) {

  var udefine = 'udefine/**/*.js';
  var sourceOrigin = 'src/**/*.js';

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      dist: {
        src: [udefine, sourceOrigin],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */\n',
        report: 'gzip'
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
        }
      }
    },
    jshint: {
      files: ['gruntfile.js', sourceOrigin],
      options: grunt.file.readJSON('.jshintrc')
    }
  });

  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');

  grunt.registerTask('test', 'Lints and unit tests', ['jshint']);
  grunt.registerTask('default', 'Default task', ['test', 'concat', 'uglify']);

};
<|endoftext|>


<commit_before>

module.exports = function(grunt) {

    grunt.initConfig({

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

        sass: {

            dist: {
                files: {
                    'style.css': 'style.scss'
                }
            },

            lib: {
                files: {
                    './src/style/style.css': './src/style/style.scss'
                }
            }
        },

        requirejs: {
            compile: {
                options: {

                    name: "graph", // assumes a production build using almond
                    exclude: [ 'jquery' ],
                    out: "dist/dist/graph-minimal.min.js",

                    paths: {
                        'jquery': 'empty:',
                        'jqueryui': 'empty:',
                        'highlightjs': 'empty:',
                        'forms': 'empty:',
                        'components': 'empty:'
                    },

                    baseUrl: "./src/",
                    //mainConfigFile: "path/to/config.js",

                }
            }
        },

        copy: {

            sourcefiles: {

                files: [
                    {
                        expand: true,
                        cwd: './src/',
                        src: './**',
                        dest: './dist/src/'
                    }
                ]
            }

        },

        clean: {

            build: {
                src: './dist/**'
            }
        },

        bump: {

            options: {
                files: ['package.json'],
                updateConfigs: [ 'pkg' ]
            }

        }
    });

    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-requirejs');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-bump');

    grunt.registerTask('default', ['clean:build', 'sass', 'requirejs', 'copy:sourcefiles', 'addcopyright']);

    grunt.registerTask('addcopyright', function () {

        var fileRead, firstLine, counter = 0, fileExtension, commentWrapper;
        copyright = '/*Copyright by Norman Pellet @2013*/';

        grunt.log.writeln( grunt.config('pkg.version') );
//copyright = [ '!', 'Graphing JavaScript Library v' +
/*!
 * jQuery JavaScript Library v1.11.1
 * http://jquery.com/
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 *
 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: 2014-05-01T17:42Z
 */

        grunt.file.expand( { filter: 'isFile', cwd: 'dist/src/' }, ["**/*.js" ] ).forEach( function( dir ) {

            fileRead = grunt.file.read( 'dist/src/' + dir ).split( '\n' );
            fileRead.unshift( copyright );
            fileRead = fileRead.join('\n');
            grunt.file.write( 'dist/src/' + dir, fileRead );

        });
    })
};<commit_msg>Some releases just for fun<commit_after>

module.exports = function(grunt) {

    grunt.initConfig({

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

        sass: {

            dist: {
                files: {
                    'style.css': 'style.scss'
                }
            },

            lib: {
                files: {
                    './src/style/style.css': './src/style/style.scss'
                }
            }
        },

        requirejs: {
            compile: {
                options: {

                    name: "graph", // assumes a production build using almond
                    exclude: [ 'jquery' ],
                    out: "dist/dist/graph-minimal.min.js",

                    paths: {
                        'jquery': 'empty:',
                        'jqueryui': 'empty:',
                        'highlightjs': 'empty:',
                        'forms': 'empty:',
                        'components': 'empty:'
                    },

                    baseUrl: "./src/",
                    //mainConfigFile: "path/to/config.js",

                }
            }
        },

        copy: {

            sourcefiles: {

                files: [
                    {
                        expand: true,
                        cwd: './src/',
                        src: './**',
                        dest: './dist/src/'
                    }
                ]
            }

        },

        clean: {

            build: {
                src: './dist/**'
            }
        },

        bump: {

            options: {
                files: ['package.json'],
                updateConfigs: [ 'pkg' ],
                push: false
            }

        }
    });

    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-requirejs');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-bump');

    grunt.registerTask('default', ['clean:build', 'sass', 'requirejs', 'copy:sourcefiles', 'addcopyright']);

    grunt.registerTask('addcopyright', function () {

        var fileRead, firstLine, counter = 0, fileExtension, commentWrapper;
        copyright = '/*Copyright by Norman Pellet @2013*/';

        grunt.log.writeln( grunt.config('pkg.version') );
//copyright = [ '!', 'Graphing JavaScript Library v' +
/*!
 * jQuery JavaScript Library v1.11.1
 * http://jquery.com/
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 *
 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: 2014-05-01T17:42Z
 */

        grunt.file.expand( { filter: 'isFile', cwd: 'dist/src/' }, ["**/*.js" ] ).forEach( function( dir ) {

            fileRead = grunt.file.read( 'dist/src/' + dir ).split( '\n' );
            fileRead.unshift( copyright );
            fileRead = fileRead.join('\n');
            grunt.file.write( 'dist/src/' + dir, fileRead );

        });
    })
};<|endoftext|>


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

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        copy: {
            dist: {
                files: [
                    {expand: true, src: ['src/**/*'],     dest: 'dist/'},
                    {expand: true, src: ['package.json'], dest: 'dist/'},
                    {expand: true, src: ['LICENSE'],      dest: 'dist/'},
                    {expand: true, src: ['README.md'],    dest: 'dist/'}
                ]
            }
        },
        clean: {
            dist: ['dist/'],
            doc: ['docs/']
        },
        nodeunit: {
            all: ['Tests/*.js']
        },
        mochaTest: {
            test: {
                options: {
                    reporter: 'spec',
                    captureFile: 'test/results/tests.txt',
                    require: 'test/coverage/blanket'
                },
                src: ['./test/tests/**/*.js']
            },
            coverage: {
                options: {
                    reporter: 'html-cov',
                    quiet: true,
                    captureFile: 'test/results/coverage.html'
                },
                src: ['./test/tests/**/*.js']
            }
        },
        jsdoc : {
            dist : {
                src: ['src/**/*.js'],
                options: {
                    destination: 'docs',
                    private: false
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-nodeunit');
    grunt.loadNpmTasks('grunt-jsdoc');
    grunt.loadNpmTasks('grunt-mocha-test');

    grunt.registerTask('default', ['nodeunit:all', 'clean:dist', 'copy:dist']);
    grunt.registerTask('doc', ['clean:doc', 'jsdoc']);
    grunt.registerTask('test', ['nodeunit']);
};
<commit_msg>Added clearing require cache after tests for testresults that doesn't influence each other<commit_after>module.exports = function(grunt) {
    'use strict';

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        copy: {
            dist: {
                files: [
                    {expand: true, src: ['src/**/*'],     dest: 'dist/'},
                    {expand: true, src: ['package.json'], dest: 'dist/'},
                    {expand: true, src: ['LICENSE'],      dest: 'dist/'},
                    {expand: true, src: ['README.md'],    dest: 'dist/'}
                ]
            }
        },
        clean: {
            dist: ['dist/'],
            doc: ['docs/']
        },
        nodeunit: {
            all: ['Tests/*.js']
        },
        mochaTest: {
            test: {
                options: {
                    reporter: 'spec',
                    captureFile: 'test/results/tests.txt',
                    require: 'test/coverage/blanket',
                    clearRequireCache: true
                },
                src: ['./test/tests/**/*.js']
            },
            coverage: {
                options: {
                    reporter: 'html-cov',
                    quiet: true,
                    captureFile: 'test/results/coverage.html'
                },
                src: ['./test/tests/**/*.js']
            }
        },
        jsdoc : {
            dist : {
                src: ['src/**/*.js'],
                options: {
                    destination: 'docs',
                    private: false
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-nodeunit');
    grunt.loadNpmTasks('grunt-jsdoc');
    grunt.loadNpmTasks('grunt-mocha-test');

    grunt.registerTask('default', ['nodeunit:all', 'clean:dist', 'copy:dist']);
    grunt.registerTask('doc', ['clean:doc', 'jsdoc']);
    grunt.registerTask('test', ['nodeunit']);
};
<|endoftext|>


<commit_before>define(['Ti/_/browser', 'Ti/_/declare', 'Ti/UI/View', 'Ti/_/lang', 'Ti/_/dom', 'Ti/_/style', 'Ti/UI'],
	function(browser, declare, View, lang, dom, style, UI) {

	var setStyle = style.set,
		is = require.is,
		unitize = dom.unitize,
		on = require.on,
		once = on.once,
		global = window,

		useTouch = 'ontouchstart' in global,

		// Maximum time that a gesture can be considered a flick
		maxFlickTime = 200,

		// Minimum distance that must be traveled to register the flick
		flickThreshold = 10,

		minAnimationTime = 25,

		maxAnimationTime = 1000,

		flickAnimationScaleFactor = 0.5,

		dragAnimationScaleFactor = 2;

	return declare('Ti.UI.ScrollableView', View, {

		constructor: function(){

			// Create the content container
			var containerDomNode,
				self = this,
				animating,
				offsetX = 0;
			self._add(self._contentContainer = UI.createView({
				left: 0,
				top: 0,
				width: UI.SIZE,
				height: '100%',
				layout: 'constrainingHorizontal'
			}));
			containerDomNode = self._contentContainer.domNode;

			// Create the paging control container
			self._add(self._pagingControlContainer = UI.createView({
				width: '100%',
				height: 20,
				bottom: 0,
				backgroundColor: 'black',
				opacity: 0,
				touchEnabled: false
			}));

			self._pagingControlContainer._add(self._pagingControlContentContainer = UI.createView({
				width: UI.SIZE,
				height: '100%',
				top: 0,
				touchEnabled: false,
				layout: 'constrainingHorizontal'
			}));

			// State variables
			self.properties.__values__.views = [];
			self._viewToRemoveAfterScroll = -1;

			on(self, 'postlayout', function() {
				animating || self._setTranslation(self.currentPage * -self._measuredWidth);
			});

			on(containerDomNode, useTouch ? 'touchstart' : 'mousedown', function(e) {
				var startX = e.touches ? e.touches[0].clientX : e.clientX,
					currentX,
					startTime = Date.now(),
					width = self._measuredWidth,
					mouseMoveListener = function(e) {
						width = self._measuredWidth;
						e.preventDefault();
						currentX = e.touches ? e.touches[0].clientX : e.clientX;
						self._setTranslation((self.currentPage * -width) + currentX - startX + offsetX);
					},
					mouseUpListener = function(e) {
						var	now = Date.now(),
							isFlick = now - startTime < maxFlickTime,
							currentPage = self.currentPage,
							thresholdMet = Math.abs(startX - currentX) > (isFlick ? flickThreshold : width / 2),
							props = self.properties.__values__,
							duration = Math.abs(currentX - startX);
						global.removeEventListener(useTouch ? 'touchmove' : 'mousemove', mouseMoveListener);
						global.removeEventListener(useTouch ? 'touchend' : 'mouseup', mouseUpListener);
						width = self._measuredWidth;
						animating = 1;
						e.preventDefault();

						if (thresholdMet) {
							if (startX > currentX) {
								currentPage !== props.views.length - 1 && currentPage++;
							} else {
								currentPage !== 0 && currentPage--;
							}
							duration = width - duration;
						}
						self._showPagingControl(currentPage);
						offsetX = currentX - startX + offsetX;
						duration = Math.max(minAnimationTime, Math.min(maxAnimationTime,
							(isFlick ? flickAnimationScaleFactor : dragAnimationScaleFactor) * duration));
						setStyle(containerDomNode, 'transition', duration + 'ms ease-out');
						setTimeout(function(){
							once(containerDomNode, 'transitionEnd', function() {
								setStyle(containerDomNode, 'transition', '');
								animating = 0;
								props.currentPage = currentPage;
								self._updatePagingControl();
							});
							self._setTranslation(currentPage * -width);
						}, 1);
					};
				self._showPagingControl(self.currentPage, 1);
				e.preventDefault();
				offsetX = animating ? offsetX || 0 : 0;
				setStyle(containerDomNode, 'transition', '');
				self._setTranslation((self.currentPage * -width) + offsetX);
				animating = 0;
				global.addEventListener(useTouch ? 'touchmove' : 'mousemove', mouseMoveListener);
				global.addEventListener(useTouch ? 'touchend' : 'mouseup', mouseUpListener);
			});
		},

		_setTranslation: function(offset) {
			setStyle(this._contentContainer.domNode, 'transform', 'translatez(0) translatex(' + offset + 'px)');
		},

		_showPagingControl: function(newIndex, indefinite) {
			var self = this;
			if (!self.showPagingControl) {
				self._pagingControlContainer.opacity = 0;
				return;
			}
			self._pagingAnimation && self._pagingAnimation.cancel();
			self._pagingAnimation = self._pagingControlContainer.animate({
				duration: 250,
				opacity: 0.75
			});
			clearInterval(self._pagingTimeout);
			if (!indefinite && self.pagingControlTimeout > 0) {
				self._pagingTimeout = setTimeout(function() {
					self._pagingAnimation && self._pagingAnimation.cancel();
					self._pagingAnimation = self._pagingControlContainer.animate({
						duration: 750,
						opacity: 0
					}, function() {
						self._pagingAnimation = void 0;
					});
				}, self.pagingControlTimeout);
			}
		},

		_updatePagingControl: function() {
			var contentContainer = this._pagingControlContentContainer,
				numViews = this.views.length,
				diameter = this.pagingControlHeight / 2;
			if (numViews !== contentContainer._numViews || diameter !== contentContainer._diameter) {
				contentContainer._numViews = numViews;
				contentContainer._diameter = diameter;
				contentContainer._removeAllChildren();
				for (var i = 0; i < this.views.length; i++) {
					contentContainer._add(UI.createView({
						width: diameter,
						height: diameter,
						left: 5,
						right: 5,
						backgroundColor: '#aaa',
						borderRadius: unitize(diameter / 2)
					}));
				}
				contentContainer._highlightedPage = -1;
			}
			if (contentContainer._highlightedPage !== this.currentPage) {
				contentContainer._highlightedPage < 0 ||
					(contentContainer._children[contentContainer._highlightedPage].backgroundColor = '#aaa');
				contentContainer._children[this.currentPage].backgroundColor = '#fff';
				contentContainer._highlightedPage = this.currentPage;
			}
		},

		addView: function(view) {
			if (view) {
				this.views.push(view);
				this._contentContainer._add(view);
				if (this.views.length == 1) {
					this.properties.__values__.currentPage = 0;
				}
				this._updatePagingControl();
			}
		},

		removeView: function(view) {

			// Get and validate the location of the view
			var viewIndex = is(view,'Number') ? view : this.views.indexOf(view);
			if (viewIndex < 0 || viewIndex >= this.views.length) {
				return;
			}

			// Update the view if this view was currently visible
			if (viewIndex == this.currentPage && this.views.length !== 1) {
				this._viewToRemoveAfterScroll = viewIndex;
				this.scrollToView(viewIndex == this.views.length - 1 ? --viewIndex : ++viewIndex);
			} else {
				this._removeViewFromList(viewIndex);
			}
		},

		_removeViewFromList: function(viewIndex) {

			var contentContainer = this._contentContainer,
				self = this;

			// Update the current view if necessary once everything has been re-laid out.
			if (viewIndex < this.currentPage) {
				self.properties.__values__.currentPage--;
			}

			// Remove the view and update the paging control
			contentContainer._remove(self.views.splice(viewIndex,1)[0]);
			self.views.length || (self.properties.__values__.currentPage = -1);
			once(UI, 'postlayout', function() {
				setTimeout(function(){
					self._setTranslation(self.currentPage * -self._measuredWidth);
				}, 1);
			});
		},

		scrollToView: function(view) {
			var viewIndex = is(view,'Number') ? view : this.views.indexOf(view),
				self = this;

			// Sanity check
			if (viewIndex < 0 || viewIndex >= this.views.length || viewIndex == this.currentPage) {
				return;
			}

			function scroll(){

				// Calculate the views to be scrolled
				var contentContainer = self._contentContainer,
					currentPage = self.currentPage,
					destination = -self.views[viewIndex]._measuredLeft,
					i,

					// Calculate a weighted duration so that larger views take longer to scroll.
					duration = 400 + 0.3 * (Math.abs(viewIndex - self.currentPage) * contentContainer._measuredWidth);

				// Make the views that will be seen visible
				if (currentPage < viewIndex) {
					for(i = currentPage + 1; i <= viewIndex; i++) {
						self._showView(i);
					}
				} else {
					for(i = viewIndex; i < currentPage; i++) {
						self._showView(i);
					}
				}

				// Animate the views
				self._updatePagingControl();
				self._showPagingControl(viewIndex);
				self._animateToPosition(destination, 0, duration, UI.ANIMATION_CURVE_EASE_IN_OUT, function(){
					self.properties.__values__.currentPage = viewIndex;
					if (currentPage < viewIndex) {
						for(i = currentPage; i < viewIndex; i++) {
							self._hideView(i);
						}
					} else {
						for(i = viewIndex + 1; i <= currentPage; i++) {
							self._hideView(i);
						}
					}
					if (self._viewToRemoveAfterScroll !== -1) {
						destination += self.views[self._viewToRemoveAfterScroll]._measuredWidth;
						self._removeViewFromList(self._viewToRemoveAfterScroll);
						self._viewToRemoveAfterScroll = -1;
					}
					self.fireEvent('scrollend',{
						currentPage: viewIndex,
						view: self.views[viewIndex]
					});
				});
			}

			// If the scrollableView hasn't been laid out yet, we must wait until it is
			if (self._contentContainer.domNode.offsetWidth) {
				scroll();
			} else {
				once(self, 'postlayout', scroll);
			}
		},

		_defaultWidth: UI.FILL,

		_defaultHeight: UI.FILL,

		properties: {
			currentPage: {
				set: function(value, oldValue) {
					if (value >= 0 && value < this.views.length) {
						this.scrollToView(value);
						return value;
					}
					return oldValue;
				},
				value: -1
			},
			pagingControlColor: {
				set: function(value) {
					this._pagingControlContainer.backgroundColor = value;
					return value;
				},
				value: 'black'
			},
			pagingControlHeight: {
				set: function(value) {
					this._pagingControlContainer.height = value;
					return value;
				},
				value: 20
			},
			pagingControlTimeout: 3000,
			showPagingControl: false,
			views: {
				set: function(value) {

					// Value must be an array
					if (!is(value,'Array')) {
						return;
					}

					// Add the views to the content container
					var i = 0,
						len = value.length,
						contentContainer = this._contentContainer,
						view;
					contentContainer._removeAllChildren();
					for(; i < len; i++) {
						(view = value[i]).width = '100%';
						view.height = '100%';
						contentContainer._add(view);
					}
					this.properties.__values__.currentPage = len ? 0 : -1;

					return value;
				},
				post: '_updatePagingControl'
			}
		}

	});

});<commit_msg>[TIMOB-12067] Code cleanup<commit_after>/*global define window*/
define(['Ti/_/declare', 'Ti/UI/View', 'Ti/_/dom', 'Ti/_/style', 'Ti/UI'],
	function(declare, View, dom, style, UI) {

	var setStyle = style.set,
		is = require.is,
		unitize = dom.unitize,
		on = require.on,
		once = on.once,
		global = window,

		useTouch = 'ontouchstart' in global,

		// Maximum time that a gesture can be considered a flick
		maxFlickTime = 200,

		// Minimum distance that must be traveled to register the flick
		flickThreshold = 10,

		minAnimationTime = 25,

		maxAnimationTime = 1000,

		flickAnimationScaleFactor = 0.5,

		dragAnimationScaleFactor = 2;

	return declare('Ti.UI.ScrollableView', View, {

		constructor: function(){

			// Create the content container
			var containerDomNode,
				self = this,
				animating,
				offsetX = 0;
			self._add(self._contentContainer = UI.createView({
				left: 0,
				top: 0,
				width: UI.SIZE,
				height: '100%',
				layout: 'constrainingHorizontal'
			}));
			containerDomNode = self._contentContainer.domNode;

			// Create the paging control container
			self._add(self._pagingControlContainer = UI.createView({
				width: '100%',
				height: 20,
				bottom: 0,
				backgroundColor: 'black',
				opacity: 0,
				touchEnabled: false
			}));

			self._pagingControlContainer._add(self._pagingControlContentContainer = UI.createView({
				width: UI.SIZE,
				height: '100%',
				top: 0,
				touchEnabled: false,
				layout: 'constrainingHorizontal'
			}));

			// State variables
			self.properties.__values__.views = [];
			self._viewToRemoveAfterScroll = -1;

			on(self, 'postlayout', function() {
				animating || self._setTranslation(self.currentPage * -self._measuredWidth);
			});

			on(containerDomNode, useTouch ? 'touchstart' : 'mousedown', function(e) {
				var startX = e.touches ? e.touches[0].clientX : e.clientX,
					currentX,
					startTime = Date.now(),
					width = self._measuredWidth,
					mouseMoveListener = function(e) {
						width = self._measuredWidth;
						e.preventDefault();
						currentX = e.touches ? e.touches[0].clientX : e.clientX;
						self._setTranslation((self.currentPage * -width) + currentX - startX + offsetX);
					},
					mouseUpListener = function(e) {
						var	now = Date.now(),
							isFlick = now - startTime < maxFlickTime,
							currentPage = self.currentPage,
							thresholdMet = Math.abs(startX - currentX) > (isFlick ? flickThreshold : width / 2),
							props = self.properties.__values__,
							duration = Math.abs(currentX - startX);
						global.removeEventListener(useTouch ? 'touchmove' : 'mousemove', mouseMoveListener);
						global.removeEventListener(useTouch ? 'touchend' : 'mouseup', mouseUpListener);
						width = self._measuredWidth;
						animating = 1;
						e.preventDefault();

						if (thresholdMet) {
							if (startX > currentX) {
								currentPage !== props.views.length - 1 && currentPage++;
							} else {
								currentPage !== 0 && currentPage--;
							}
							duration = width - duration;
						}
						self._showPagingControl(currentPage);
						offsetX = currentX - startX + offsetX;
						duration = Math.max(minAnimationTime, Math.min(maxAnimationTime,
							(isFlick ? flickAnimationScaleFactor : dragAnimationScaleFactor) * duration));
						setStyle(containerDomNode, 'transition', duration + 'ms ease-out');
						setTimeout(function(){
							once(containerDomNode, 'transitionEnd', function() {
								setStyle(containerDomNode, 'transition', '');
								animating = 0;
								props.currentPage = currentPage;
								self._updatePagingControl();
							});
							self._setTranslation(currentPage * -width);
						}, 1);
					};
				self._showPagingControl(self.currentPage, 1);
				e.preventDefault();
				offsetX = animating ? offsetX || 0 : 0;
				setStyle(containerDomNode, 'transition', '');
				self._setTranslation((self.currentPage * -width) + offsetX);
				animating = 0;
				global.addEventListener(useTouch ? 'touchmove' : 'mousemove', mouseMoveListener);
				global.addEventListener(useTouch ? 'touchend' : 'mouseup', mouseUpListener);
			});
		},

		_setTranslation: function(offset) {
			setStyle(this._contentContainer.domNode, 'transform', 'translatez(0) translatex(' + offset + 'px)');
		},

		_showPagingControl: function(newIndex, indefinite) {
			var self = this;
			if (!self.showPagingControl) {
				self._pagingControlContainer.opacity = 0;
				return;
			}
			self._pagingAnimation && self._pagingAnimation.cancel();
			self._pagingAnimation = self._pagingControlContainer.animate({
				duration: 250,
				opacity: 0.75
			});
			clearInterval(self._pagingTimeout);
			if (!indefinite && self.pagingControlTimeout > 0) {
				self._pagingTimeout = setTimeout(function() {
					self._pagingAnimation && self._pagingAnimation.cancel();
					self._pagingAnimation = self._pagingControlContainer.animate({
						duration: 750,
						opacity: 0
					}, function() {
						self._pagingAnimation = void 0;
					});
				}, self.pagingControlTimeout);
			}
		},

		_updatePagingControl: function() {
			var contentContainer = this._pagingControlContentContainer,
				numViews = this.views.length,
				diameter = this.pagingControlHeight / 2;
			if (numViews !== contentContainer._numViews || diameter !== contentContainer._diameter) {
				contentContainer._numViews = numViews;
				contentContainer._diameter = diameter;
				contentContainer._removeAllChildren();
				for (var i = 0; i < this.views.length; i++) {
					contentContainer._add(UI.createView({
						width: diameter,
						height: diameter,
						left: 5,
						right: 5,
						backgroundColor: '#aaa',
						borderRadius: unitize(diameter / 2)
					}));
				}
				contentContainer._highlightedPage = -1;
			}
			if (contentContainer._highlightedPage !== this.currentPage) {
				contentContainer._highlightedPage < 0 ||
					(contentContainer._children[contentContainer._highlightedPage].backgroundColor = '#aaa');
				contentContainer._children[this.currentPage].backgroundColor = '#fff';
				contentContainer._highlightedPage = this.currentPage;
			}
		},

		addView: function(view) {
			if (view) {
				this.views.push(view);
				this._contentContainer._add(view);
				if (this.views.length == 1) {
					this.properties.__values__.currentPage = 0;
				}
				this._updatePagingControl();
			}
		},

		removeView: function(view) {

			// Get and validate the location of the view
			var viewIndex = is(view,'Number') ? view : this.views.indexOf(view);
			if (viewIndex < 0 || viewIndex >= this.views.length) {
				return;
			}

			// Update the view if this view was currently visible
			if (viewIndex == this.currentPage && this.views.length !== 1) {
				this._viewToRemoveAfterScroll = viewIndex;
				this.scrollToView(viewIndex == this.views.length - 1 ? --viewIndex : ++viewIndex);
			} else {
				this._removeViewFromList(viewIndex);
			}
		},

		_removeViewFromList: function(viewIndex) {

			var contentContainer = this._contentContainer,
				self = this;

			// Update the current view if necessary once everything has been re-laid out.
			if (viewIndex < this.currentPage) {
				self.properties.__values__.currentPage--;
			}

			// Remove the view and update the paging control
			contentContainer._remove(self.views.splice(viewIndex,1)[0]);
			self.views.length || (self.properties.__values__.currentPage = -1);
			once(UI, 'postlayout', function() {
				setTimeout(function(){
					self._setTranslation(self.currentPage * -self._measuredWidth);
				}, 1);
			});
		},

		scrollToView: function(view) {
			var viewIndex = is(view,'Number') ? view : this.views.indexOf(view),
				self = this;

			// Sanity check
			if (viewIndex < 0 || viewIndex >= this.views.length || viewIndex == this.currentPage) {
				return;
			}

			function scroll(){

				// Calculate the views to be scrolled
				var contentContainer = self._contentContainer,
					currentPage = self.currentPage,
					destination = -self.views[viewIndex]._measuredLeft,
					i,

					// Calculate a weighted duration so that larger views take longer to scroll.
					duration = 400 + 0.3 * (Math.abs(viewIndex - self.currentPage) * contentContainer._measuredWidth);

				// Make the views that will be seen visible
				if (currentPage < viewIndex) {
					for(i = currentPage + 1; i <= viewIndex; i++) {
						self._showView(i);
					}
				} else {
					for(i = viewIndex; i < currentPage; i++) {
						self._showView(i);
					}
				}

				// Animate the views
				self._updatePagingControl();
				self._showPagingControl(viewIndex);
				self._animateToPosition(destination, 0, duration, UI.ANIMATION_CURVE_EASE_IN_OUT, function(){
					self.properties.__values__.currentPage = viewIndex;
					if (currentPage < viewIndex) {
						for(i = currentPage; i < viewIndex; i++) {
							self._hideView(i);
						}
					} else {
						for(i = viewIndex + 1; i <= currentPage; i++) {
							self._hideView(i);
						}
					}
					if (self._viewToRemoveAfterScroll !== -1) {
						destination += self.views[self._viewToRemoveAfterScroll]._measuredWidth;
						self._removeViewFromList(self._viewToRemoveAfterScroll);
						self._viewToRemoveAfterScroll = -1;
					}
					self.fireEvent('scrollend',{
						currentPage: viewIndex,
						view: self.views[viewIndex]
					});
				});
			}

			// If the scrollableView hasn't been laid out yet, we must wait until it is
			if (self._contentContainer.domNode.offsetWidth) {
				scroll();
			} else {
				once(self, 'postlayout', scroll);
			}
		},

		_defaultWidth: UI.FILL,

		_defaultHeight: UI.FILL,

		properties: {
			currentPage: {
				set: function(value, oldValue) {
					if (value >= 0 && value < this.views.length) {
						this.scrollToView(value);
						return value;
					}
					return oldValue;
				},
				value: -1
			},
			pagingControlColor: {
				set: function(value) {
					this._pagingControlContainer.backgroundColor = value;
					return value;
				},
				value: 'black'
			},
			pagingControlHeight: {
				set: function(value) {
					this._pagingControlContainer.height = value;
					return value;
				},
				value: 20
			},
			pagingControlTimeout: 3000,
			showPagingControl: false,
			views: {
				set: function(value) {

					// Value must be an array
					if (!is(value,'Array')) {
						return;
					}

					// Add the views to the content container
					var i = 0,
						len = value.length,
						contentContainer = this._contentContainer,
						view;
					contentContainer._removeAllChildren();
					for(; i < len; i++) {
						(view = value[i]).width = '100%';
						view.height = '100%';
						contentContainer._add(view);
					}
					this.properties.__values__.currentPage = len ? 0 : -1;

					return value;
				},
				post: '_updatePagingControl'
			}
		}

	});

});<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function (grunt) {
    'use strict';

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        meta: {
            version: '<%= pkg.version %>',
            srcPath: 'src/',
            deployPath: 'deploy/',
            banner:
                '// Fly.js \n' +
                '// Distributed under MIT license\n'
        },
        concat: {
            options: {
                stripBanners: true
            },
            dist: {
                src: ['<%= meta.srcPath %>core/*.js', '<%= meta.srcPath %>render/*.js'],
                dest: '<%= meta.deployPath %>cocat.js'
            }
        },
        uglify: {
            options: {

            },
            dist: {
                src: '<%= meta.deployPath %>cocat.js',
                dest: '<%= meta.deployPath %>cocat.min.js'
            }
        },
        yuidoc: {
            name: '<%= pkg.name %>',
            description: '<%= pkg.description %>',
            version: '<%= pkg.version %>',
            url: '<%= pkg.homepage %>',
            options: {
                paths: '<%= meta.srcPath %>core',
                outdir: 'docs/'
            }
        },
        jslint: {
            directives: {
                nomen: true,
                vars: true,
                eqeq: true,
                plusplus: true,
                globals: {
                    flyjs: true,
                    window: true,
                    createjs: true
                }
            },
            files: [
                'Gruntfile.js',
                'example/*.js',
                'example/entities/*.js',
                'src/core/*.js',
                'src/render/*.js',
                'src/utils/*.js'
            ]
        }
    });

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-yuidoc');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-jslint');

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

    grunt.registerTask('release', ['jslint']);
};<commit_msg>updated jslint<commit_after>/*global module:false*/
module.exports = function (grunt) {
    'use strict';

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        meta: {
            version: '<%= pkg.version %>',
            srcPath: 'src/',
            deployPath: 'deploy/',
            banner:
                '// Fly.js \n' +
                '// Distributed under MIT license\n'
        },
        concat: {
            options: {
                stripBanners: true
            },
            dist: {
                src: ['<%= meta.srcPath %>core/*.js', '<%= meta.srcPath %>render/*.js'],
                dest: '<%= meta.deployPath %>cocat.js'
            }
        },
        uglify: {
            options: {

            },
            dist: {
                src: '<%= meta.deployPath %>cocat.js',
                dest: '<%= meta.deployPath %>cocat.min.js'
            }
        },
        yuidoc: {
            name: '<%= pkg.name %>',
            description: '<%= pkg.description %>',
            version: '<%= pkg.version %>',
            url: '<%= pkg.homepage %>',
            options: {
                paths: '<%= meta.srcPath %>core',
                outdir: 'docs/'
            }
        },
        jslint: {
            directives: {
                nomen: true,
                vars: true,
                eqeq: true,
                plusplus: true,
                globals: {
                    flyjs: true,
                    window: true,
                    createjs: true
                }
            },
            files: [
                'Gruntfile.js',
                'example/*.js',
                'example/entities/*.js',
                'src/core/*.js',
                'src/render/*.js',
                'src/utils/*.js',
                'src/collection/*.js'
            ]
        }
    });

    // These plugins provide necessary tasks.
    grunt.loadNpmTasks('grunt-contrib-yuidoc');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-jslint');

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

    grunt.registerTask('release', ['jslint']);
};<|endoftext|>


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

  grunt.initConfig({
    //-----------------------------------------------------
    jshint: {     // Validate .js file syntax
      all: [
        'server/**/*.js',   // server files
        'www/**/*.js'    // client files
      ],
      options: {
        force: 'true',
        jshintrc: '.jshintrc',
        ignores: [
          'www/dist/**/*.js'
        ]
      }
    },
    //-----------------------------------------------------
    mochaTest: {  // Run spec tests
      test: {
        options: {
          reporter: 'spec'
        },
        src: ['test/**/*.js']
      }
    },
    //-----------------------------------------------------
    concat: {     // Join .js files
      src: {
        src: 'www/app/**/*.js',
        dest: 'www/dist/src.js',
      },
      lib: {
        src: [
          'bower_components/angular/angular.min.js',
          'bower_components/angular-route/angular-route.min.js',
          'bower_components/jquery/dist/jquery.min.js',
          'bower_components/ng-table/dist/ng-table.min.js',
          'bower_components/angular-jwt/dist/angular-jwt.min.js',
          'bower_components/angular-ui-router/release/angular-ui-router.min.js',
          'bower_components/bootstrap/dist/js/bootstrap.min.js'
        ],
        dest: 'www/dist/lib.min.js',
      }
    },
    //-----------------------------------------------------
    uglify: {     // Minify .js files
      options: {
          mangle: false
        },
        js_files: {
          files: {
            'www/dist/src.min.js': ['www/dist/src.js']
          }
        }
    },
    //-----------------------------------------------------
    cssmin: {     // Minify .css files
      target: {
        files: [{
          expand: true,
          cwd: 'bower_components/bootstrap/dist/css/',
          src: ['bootstrap.css', '!*.min.css'],
          dest: 'www/dist/',
          ext: '.min.css'
        }]
      },
      stylesheet: {
        files: [{
          expand: true,
          cwd: 'www/styles/',
          src: ['styles.css', '!*.min.css'],
          dest: 'www/dist/',
          ext: '.min.css'
        }]
      },
      ngTable: {
        files: [{
          expand: true,
          cwd: 'bower_components/ng-table/dist/',
          src: ['ng-table.css', '!*.min.css'],
          dest: 'www/dist/',
          ext: '.min.css'
        }]
      }
    },
    //-----------------------------------------------------
    nodemon: {    // Start server
      dev: {
        script: 'server/server.js'
      }
    },
    //-----------------------------------------------------
    shell: {
      delsrc: {
        command: 'rm ./www/dist/src.js'
      }
    },
    //-----------------------------------------------------
    watch: {
      scripts: {
        files: [
          'server/**/*.js',   // server files
          'www/**/*.js'    // www files
        ],
        tasks: ['build']
      },
      css: {
        files: 'www/styles/*.css',
        tasks: ['cssmin']
      }
    }
  });

  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  grunt.registerTask('server-dev', function (target) {
    // Running nodejs in a different process and displaying output on the main console
    var nodemon = grunt.util.spawn({
         cmd: 'grunt',
         grunt: true,
         args: 'nodemon'
    });
    nodemon.stdout.pipe(process.stdout);
    nodemon.stderr.pipe(process.stderr);

    grunt.task.run(['watch']);
  });

  ////////////////////////////////////////////////////
  // Main grunt tasks
  ////////////////////////////////////////////////////

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

  grunt.registerTask('build', [
    'test',
    'concat',
    'uglify',
    'shell:delsrc',
    'cssmin'
  ]);

  // grunt.registerTask('upload', function(n) {
  //   if(grunt.option('git')) {
  //     // add support for git push
  //   } else {
  //     grunt.task.run([ 'server-dev' ]);
  //   }
  // });

  // grunt.registerTask('deploy', [
  //     'build',
  //     'upload'
  // ]);
};<commit_msg>added cytoscape graph dependency to grunt build<commit_after>module.exports = function(grunt) {

  grunt.initConfig({
    //-----------------------------------------------------
    jshint: {     // Validate .js file syntax
      all: [
        'server/**/*.js',   // server files
        'www/**/*.js'    // client files
      ],
      options: {
        force: 'true',
        jshintrc: '.jshintrc',
        ignores: [
          'www/dist/**/*.js'
        ]
      }
    },
    //-----------------------------------------------------
    mochaTest: {  // Run spec tests
      test: {
        options: {
          reporter: 'spec'
        },
        src: ['test/**/*.js']
      }
    },
    //-----------------------------------------------------
    concat: {     // Join .js files
      src: {
        src: 'www/app/**/*.js',
        dest: 'www/dist/src.js',
      },
      lib: {
        src: [
          'bower_components/angular/angular.min.js',
          'bower_components/angular-route/angular-route.min.js',
          'bower_components/jquery/dist/jquery.min.js',
          'bower_components/ng-table/dist/ng-table.min.js',
          'bower_components/angular-jwt/dist/angular-jwt.min.js',
          'bower_components/angular-ui-router/release/angular-ui-router.min.js',
          'bower_components/bootstrap/dist/js/bootstrap.min.js'
        ],
        dest: 'www/dist/lib.min.js',
      }
    },
    //-----------------------------------------------------
    uglify: {     // Minify .js files
      options: {
          mangle: false
        },
        js_files: {
          files: {
            'www/dist/src.min.js': ['www/dist/src.js'],
            'www/dist/cytoscape.min.js': ['bower_components/cytoscape/dist/cytoscape.js']
          }
        }
    },
    //-----------------------------------------------------
    cssmin: {     // Minify .css files
      target: {
        files: [{
          expand: true,
          cwd: 'bower_components/bootstrap/dist/css/',
          src: ['bootstrap.css', '!*.min.css'],
          dest: 'www/dist/',
          ext: '.min.css'
        }]
      },
      stylesheet: {
        files: [{
          expand: true,
          cwd: 'www/styles/',
          src: ['styles.css', '!*.min.css'],
          dest: 'www/dist/',
          ext: '.min.css'
        }]
      },
      ngTable: {
        files: [{
          expand: true,
          cwd: 'bower_components/ng-table/dist/',
          src: ['ng-table.css', '!*.min.css'],
          dest: 'www/dist/',
          ext: '.min.css'
        }]
      }
    },
    //-----------------------------------------------------
    nodemon: {    // Start server
      dev: {
        script: 'server/server.js'
      }
    },
    //-----------------------------------------------------
    shell: {
      delsrc: {
        command: 'rm ./www/dist/src.js'
      }
    },
    //-----------------------------------------------------
    watch: {
      scripts: {
        files: [
          'server/**/*.js',   // server files
          'www/**/*.js'    // www files
        ],
        tasks: ['build']
      },
      css: {
        files: 'www/styles/*.css',
        tasks: ['cssmin']
      }
    }
  });

  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  grunt.registerTask('server-dev', function (target) {
    // Running nodejs in a different process and displaying output on the main console
    var nodemon = grunt.util.spawn({
         cmd: 'grunt',
         grunt: true,
         args: 'nodemon'
    });
    nodemon.stdout.pipe(process.stdout);
    nodemon.stderr.pipe(process.stderr);

    grunt.task.run(['watch']);
  });

  ////////////////////////////////////////////////////
  // Main grunt tasks
  ////////////////////////////////////////////////////

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

  grunt.registerTask('build', [
    'test',
    'concat',
    'uglify',
    'shell:delsrc',
    'cssmin'
  ]);

  // grunt.registerTask('upload', function(n) {
  //   if(grunt.option('git')) {
  //     // add support for git push
  //   } else {
  //     grunt.task.run([ 'server-dev' ]);
  //   }
  // });

  // grunt.registerTask('deploy', [
  //     'build',
  //     'upload'
  // ]);
};<|endoftext|>


<commit_before>"use strict";
/*jshint node: true*/
/*eslint-env node*/

// https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V8.md#2017-10-24-version-880-current-mylesborins
process.env.NODE_NO_HTTP2 = 1; //eslint-disable-line no-process-env

module.exports = function (grunt) {

    require("time-grunt")(grunt);

    // Since the tasks are split using load-grunt-config, a global object contains the configuration
    /*global configFile, configuration*/
    var ConfigFile = require("./make/configFile.js");
    global.configFile = new ConfigFile();
    global.configuration = Object.create(configFile.content);
    if (configFile.isNew()) {
        grunt.registerTask("default", function (params) {
            var done = this.async(); //eslint-disable-line no-invalid-this
            grunt.util.spawn({
                cmd: "node",
                args: ["make/config"].concat(params),
                opts: {
                    stdio: "inherit"
                }
            }, function (error) {
                if (error) {
                    done();
                    return;
                }
                grunt.util.spawn({
                    grunt: true,
                    args: ["check", "jsdoc", "default"],
                    opts: {
                        stdio: "inherit"
                    }
                }, done);
            });
        });
        return;
    }

    configFile.readSourceFiles();

    // Amend the configuration with internal settings
    configuration.pkg = grunt.file.readJSON("./package.json");

    // As well as known path
    configuration.path = {
        plato: "tmp/plato/"
    };

    require("load-grunt-config")(grunt);
    grunt.task.loadTasks("grunt/tasks");

};
<commit_msg>adds configurations handlers (#218)<commit_after>"use strict";
/*jshint node: true*/
/*eslint-env node*/
/*eslint-disable no-sync*/

// https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V8.md#2017-10-24-version-880-current-mylesborins
process.env.NODE_NO_HTTP2 = 1; //eslint-disable-line no-process-env

module.exports = function (grunt) {

    require("time-grunt")(grunt);

    // Since the tasks are split using load-grunt-config, a global object contains the configuration
    /*global configFile, configuration*/
    var ConfigFile = require("./make/configFile.js");
    global.configFile = new ConfigFile();
    global.configuration = Object.create(configFile.content);
    if (configFile.isNew()) {
        require("fs").readdirSync("./grunt/config").forEach(function (fileName) {
            grunt.registerTask(fileName.split(".")[0], require("./grunt/config/" + fileName)(grunt));
        });
        return;
    }

    configFile.readSourceFiles();

    // Amend the configuration with internal settings
    configuration.pkg = grunt.file.readJSON("./package.json");

    // As well as known path
    configuration.path = {
        plato: "tmp/plato/"
    };

    require("load-grunt-config")(grunt);
    grunt.task.loadTasks("grunt/tasks");

};
<|endoftext|>