<commit_before>/* eslint-env node */
module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt);

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

        build: {
            dir: 'build',
            name: '<%= pkg.name %>-<%= pkg.version %>'
        },

        connect: {
            server: {
                options: {
                    debug: true,
                    keepalive: true
                }
            }
        },
        eslint: {
            target: ['app/js', 'test'],
            options: {
                config: '.eslintrc'
            }
        },
        karma: {
            options: {
                configFile: 'test/karma.conf.js'
            },
            unit: {},
            single: {
                singleRun: true
            },
            coverage: {
                configFile: 'test/karma-coverage.conf.js'
            },
            travis: {
                configFile: 'test/karma-travis.conf.js'
            }
        },
        protractor: {
            all: {
                options :{
                    configFile: 'test/protractor-conf.js'
                }
            }
        },
        compress: {
            options: {
                pretty: true,
                level: 6
            },
            'build-tar': {
                options: {
                    archive: '<%= build.dir %>/<%= build.name %>.tar.gz'
                },
                files: [{
                    expand: true,
                    cwd: '<%= build.dir %>',
                    src: '<%= build.name %>/**'
                }]
            },
            'build-zip': {
                options: {
                    archive: '<%= build.dir %>/<%= build.name %>.zip'
                },
                files: [{
                    expand: true,
                    cwd: '<%= build.dir %>',
                    src: '<%= build.name %>/**'
                }]
            }
        },
        exec: {
            webdriver: {
                cmd: "node_modules/.bin/webdriver-manager update"
            }
        },

        concat: {
            coverage: {
                src: ['coverage/lcov.info', 'coverage/e2e/lcov.info'],
                dest: 'coverage/merged.info'
            }
        },

        coveralls: {
            target: {
                src: 'coverage/merged.info'
            }
        },

        clean: {
            build: {
                src: ['<%= build.dir %>']
            },
            post_build: {
                src: ['.tmp']
            }
        },

        copy: {
            e2e: {
                src: ['app/**/*', '!**/*.orig', '!**/*~'],
                dest: 'coverage/instrumented/'
            },
            build: {
                files: [
                    {expand: true,
                     src: [
                         'README.md',
                         'LICENSE'
                     ],
                     dest: '<%= build.dir %>/<%= build.name %>'},
                    {expand: true,
                     cwd: 'app',
                     src: [
                         'index.html',
                         'partials/*.html',
                         'css/*.css'
                     ],
                     dest: '<%= build.dir %>/<%= build.name %>'},
                    {expand: true,
                     cwd: 'app/bower_components',
                     src: [
                         'bootstrap/dist/css/bootstrap.css',
                         'bootstrap/dist/fonts/*',
                         'codemirror/lib/codemirror.css',
                         'codemirror/lib/codemirror.js',
                         'codemirror/mode/**/*.js',
                         '!codemirror/mode/**/test.js',
                         'codemirror/addon/mode/loadmode.js',
                         'ng-file-upload/angular-file-upload-html5-shim.js',
                         'angular/angular.js',
                         'ng-file-upload/angular-file-upload.js',
                         'angular-ui-router/release/angular-ui-router.js',
                         'angular-ui-codemirror/ui-codemirror.js',
                         'angular-bootstrap/ui-bootstrap-tpls.js'
                     ],
                     dest: '<%= build.dir %>/<%= build.name %>/bower_components'}
                ]
            }
        },
        instrument: {
            files: 'app/js/**/*.js',
            options: {
                basePath: "coverage/instrumented"
            }
        },
        protractor_coverage: {
            e2e: {
                options: {
                    coverageDir: 'coverage',
                    args: {
                        baseUrl: 'http://localhost:8000/coverage/instrumented/app/',
                        specs: ['test/e2e/*.js']
                    },
                    configFile: 'test/protractor-conf.js',
                }
            }
        },
        makeReport: {
            src: 'coverage/coverage.json',
            options: {
                type: 'lcov',
                dir: 'coverage/e2e'
            }
        },

        useminPrepare: {
            html: 'app/index.html',
            options: {
                dest: '<%= build.dir %>/<%= build.name %>'
            }
        },
        filerev: {
            build: {
                src: '<%= build.dir %>/<%= build.name %>/js/*.js'
            }
        },
        usemin: {
            html: '<%= build.dir %>/<%= build.name %>/index.html'
        }
    });

    grunt.registerTask('update-webdriver', ['exec:webdriver']);
    grunt.registerTask('start', ['connect:server']);
    grunt.registerTask('coverage', [
        'copy:e2e', 'instrument', 'protractor_coverage', 'makeReport'
    ]);
    grunt.registerTask('build', [
        'clean:build',
        'copy:build',
        'useminPrepare',
        'concat:generated',
        'uglify:generated',
        'filerev:build',
        'usemin',
        'compress',
        'clean:post_build'
    ]);
};
<commit_msg>grunt: add e2e-build task (#164)<commit_after>/* eslint-env node */
module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt);

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

        build: {
            dir: 'build',
            name: '<%= pkg.name %>-<%= pkg.version %>'
        },

        connect: {
            server: {
                options: {
                    debug: true,
                    keepalive: true
                }
            }
        },
        eslint: {
            target: ['app/js', 'test'],
            options: {
                config: '.eslintrc'
            }
        },
        karma: {
            options: {
                configFile: 'test/karma.conf.js'
            },
            unit: {},
            single: {
                singleRun: true
            },
            coverage: {
                configFile: 'test/karma-coverage.conf.js'
            },
            travis: {
                configFile: 'test/karma-travis.conf.js'
            }
        },
        protractor: {
            all: {
                options :{
                    configFile: 'test/protractor-conf.js'
                }
            }
        },
        compress: {
            options: {
                pretty: true,
                level: 6
            },
            'build-tar': {
                options: {
                    archive: '<%= build.dir %>/<%= build.name %>.tar.gz'
                },
                files: [{
                    expand: true,
                    cwd: '<%= build.dir %>',
                    src: '<%= build.name %>/**'
                }]
            },
            'build-zip': {
                options: {
                    archive: '<%= build.dir %>/<%= build.name %>.zip'
                },
                files: [{
                    expand: true,
                    cwd: '<%= build.dir %>',
                    src: '<%= build.name %>/**'
                }]
            }
        },
        exec: {
            webdriver: {
                cmd: "node_modules/.bin/webdriver-manager update"
            }
        },

        concat: {
            coverage: {
                src: ['coverage/lcov.info', 'coverage/e2e/lcov.info'],
                dest: 'coverage/merged.info'
            }
        },

        coveralls: {
            target: {
                src: 'coverage/merged.info'
            }
        },

        clean: {
            build: {
                src: ['<%= build.dir %>']
            },
            post_build: {
                src: ['.tmp']
            }
        },

        copy: {
            e2e: {
                src: ['app/**/*', '!**/*.orig', '!**/*~'],
                dest: 'coverage/instrumented/'
            },
            build: {
                files: [
                    {expand: true,
                     src: [
                         'README.md',
                         'LICENSE'
                     ],
                     dest: '<%= build.dir %>/<%= build.name %>'},
                    {expand: true,
                     cwd: 'app',
                     src: [
                         'index.html',
                         'partials/*.html',
                         'css/*.css'
                     ],
                     dest: '<%= build.dir %>/<%= build.name %>'},
                    {expand: true,
                     cwd: 'app/bower_components',
                     src: [
                         'bootstrap/dist/css/bootstrap.css',
                         'bootstrap/dist/fonts/*',
                         'codemirror/lib/codemirror.css',
                         'codemirror/lib/codemirror.js',
                         'codemirror/mode/**/*.js',
                         '!codemirror/mode/**/test.js',
                         'codemirror/addon/mode/loadmode.js',
                         'ng-file-upload/angular-file-upload-html5-shim.js',
                         'angular/angular.js',
                         'ng-file-upload/angular-file-upload.js',
                         'angular-ui-router/release/angular-ui-router.js',
                         'angular-ui-codemirror/ui-codemirror.js',
                         'angular-bootstrap/ui-bootstrap-tpls.js'
                     ],
                     dest: '<%= build.dir %>/<%= build.name %>/bower_components'}
                ]
            }
        },
        instrument: {
            files: 'app/js/**/*.js',
            options: {
                basePath: "coverage/instrumented"
            }
        },
        protractor_coverage: {
            e2e: {
                options: {
                    coverageDir: 'coverage',
                    args: {
                        baseUrl: 'http://localhost:8000/coverage/instrumented/app/',
                        specs: ['test/e2e/*.js']
                    },
                    configFile: 'test/protractor-conf.js',
                }
            }
        },
        makeReport: {
            src: 'coverage/coverage.json',
            options: {
                type: 'lcov',
                dir: 'coverage/e2e'
            }
        },

        useminPrepare: {
            html: 'app/index.html',
            options: {
                dest: '<%= build.dir %>/<%= build.name %>'
            }
        },
        filerev: {
            build: {
                src: '<%= build.dir %>/<%= build.name %>/js/*.js'
            }
        },
        usemin: {
            html: '<%= build.dir %>/<%= build.name %>/index.html'
        }
    });

    grunt.registerTask('update-webdriver', ['exec:webdriver']);
    grunt.registerTask('start', ['connect:server']);
    grunt.registerTask('coverage', [
        'copy:e2e', 'instrument', 'protractor_coverage', 'makeReport'
    ]);
    grunt.registerTask('build', [
        'clean:build',
        'copy:build',
        'useminPrepare',
        'concat:generated',
        'uglify:generated',
        'filerev:build',
        'usemin',
        'compress',
        'clean:post_build'
    ]);
    grunt.registerTask('e2e-build', 'Run E2E tests on build', function () {
        var base = 'http://localhost:8000/<%= build.dir %>/<%= build.name %>/';
        grunt.config.merge({
            protractor: {
                options: {
                    args: {
                        baseUrl: base
                    }
                }
            },
            copy: {
                extra: {
                    files: [{
                        expand: true,
                        cwd: 'app',
                        src: [
                            'bower_components/angular-mocks/angular-mocks.js',
                            'bower_components/spark-md5/spark-md5.js',
                            'js/test/swift-simulator.js'
                        ],
                        dest: '<%= build.dir %>/<%= build.name %>'
                    }]
                }
            }
        });

        grunt.task.run('build');
        grunt.task.run('copy:extra');
        grunt.task.run('protractor');
    });
};
<|endoftext|>


<commit_before>'use strict';

var Generator = require('yeoman-generator'),
    crypto = require('crypto');

module.exports = class extends Generator {
    prompting() {
        return this.prompt([
            {
                type     : 'input',
                name     : 'appName',
                message  : 'Enter project name',
                validate : function (input) {
                            var validateExp = new RegExp('^[0-9a-z]+$', 'i');
                            return validateExp.test(input) ? true : 'The app name must consist only of latin letters and digits.';
                        }
            },
            {
                type     : 'input',
                name     : 'dbName',
                message  : 'Enter database name',
                validate : function (input) {
                    var validateExp = new RegExp('^[0-9a-z]+$', 'i');
                    return validateExp.test(input) ? true : 'The database name must consist only of latin letters and digits.';
                }
            },
            {
                type     : 'input',
                name     : 'version',
                message  : 'Enter a version'
            }
        ]).then((answers) => {
            this.config.set(answers);
            this.config.save();
        });
    }

    writing() {
        var config = this.config.getAll();

        this.config.set('jwtSecret', this._generateJwtSecret());
        this._addBaseProject();
    }

    install() {
        this.log('Installing dependencies');
        this.npmInstall();
    }

    end() {
        this.log('Your app is ready!');
    }

    _generateJwtSecret() {
        this.log('Generated jwtSecret.');
        return crypto.randomBytes(256).toString('hex');
    }

    _addBaseProject() {
        var config = this.config.getAll();

        this.fs.copyTpl(
            [
                this.templatePath()
            ],
            this.destinationRoot(),
            config

        );
        this.log('Added base project');
    }
};<commit_msg>added depended questions<commit_after>'use strict';

var Generator = require('yeoman-generator'),
    crypto = require('crypto');

module.exports = class extends Generator {
    prompting() {
        return this.prompt([
            {
                type     : 'input',
                name     : 'appName',
                message  : 'Enter project name',
                validate : function (input) {
                            var validateExp = new RegExp('^[0-9a-z]+-?[0-9a-z]+$', 'i');
                            return validateExp.test(input) ? true : 'The app name must consist only of latin letters, digits and single dash.';
                        }
            },
            {
                type     : 'input',
                name     : 'dbName',
                message  : 'Enter database name',
                validate : function (input) {
                    var validateExp = new RegExp('^[0-9a-z]+$', 'i');
                    return validateExp.test(input) ? true : 'The database name must consist only of latin letters and digits.';
                }
            },
            {
                type     : 'input',
                name     : 'version',
                message  : 'Enter a version'
            },
            {
                type: 'confirm',
                name: 'useMongo',
                message: 'Would you like to use mongo database?'
            },
            {
                when: function (prompts) {
                    return prompts.useMongo;
                },
                type: 'confirm',
                name: 'useJwt',
                message: 'Would you like to use jwt?'
            }
        ]).then((answers) => {
            this.config.set(answers);
            this.config.save();
        });
    }

    writing() {
        var config = this.config.getAll();

        this.config.set('jwtSecret', this._generateJwtSecret());
        this._addBaseProject();
    }

    install() {
        this.log('Installing dependencies');
        this.npmInstall();
    }

    end() {
        this.log('Your app is ready!');
    }

    _generateJwtSecret() {
        this.log('Generated jwtSecret.');
        return crypto.randomBytes(256).toString('hex');
    }

    _addBaseProject() {
        var config = this.config.getAll();

        this.fs.copyTpl(
            [
                this.templatePath()
            ],
            this.destinationRoot(),
            config

        );
        this.log('Added base project');
    }
};<|endoftext|>


<commit_before>'use strict';
var path = require('path');
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var _ = require('lodash');

module.exports = yeoman.generators.Base.extend({
  initializing: function () {
    this.props = this.config.getAll() || {};
  },
  prompting: function () {
    var done = this.async();
    var defaultAppBaseName = /^[a-zA-Z0-9_]+$/.test(path.basename(process.cwd())) ? path.basename(process.cwd()) : 'sample-aio';
    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the solid ' + chalk.red('generator-alfresco') + ' generator!'
    ));

    var prompts = [{
      type: 'input',
      name: 'name',
      message: 'Name of the project',
      default: defaultAppBaseName
    }, {
      type: 'input',
      name: 'description',
      message: 'Description of the project'
    }, {
      type: 'input',
      name: 'groupId',
      message: 'Enter the groupId',
      default: 'com.example'
    }, {
      type: 'input',
      name: 'artifactId',
      message: 'Enter the artifactId',
      default: function (answers) {
        return answers.name;
      }
    }, {
      type: 'input',
      name: 'package',
      message: 'Enter the package',
      default: function (answers) {
        return answers.groupId + '.' + _.camelCase(answers.name);
      },
      validate: function (input) {
        return (input.match(/[a-zA-Z\.]+/g) || []).length > 0 || 'Doesn\'t match a package name...';
      }
    }, {
      type: 'input',
      name: 'version',
      message: 'Version number',
      default: '1.0-SNAPSHOT'
    }];

    this.prompt(prompts, function (props) {
      this.props = props;
      this.appname = props.name;
      done();
    }.bind(this));
  },
  configuring: function () {
    this.config.set(this.props);
    this.config.save();
  },

  writing: function () {
    var parent = {
      groupId: this.props.groupId,
      artifactId: this.props.artifactId,
      version: this.props.version
    };

    var pkg = {
      package: this.props.package
    };

    var shareAmp = this.props.artifactId + '-share-amp';
    var shareModule = {moduleId: shareAmp};
    var sharePom = _.assign({}, parent, shareModule);
    var sharePkg = _.assign({}, pkg, shareModule);
    var sharePath = shareAmp + '/';

    var repoAmp = this.props.artifactId + '-repo-amp';
    var repoModule = {moduleId: repoAmp};
    var repoPom = _.assign({}, parent, repoModule);
    var repoPkg = _.assign({}, pkg, repoModule);
    var repoPath = repoAmp + '/';

    this.fs.copy(
      this.templatePath('dummyfile.txt'),
      this.destinationPath('dummyfile.txt')
    );

    this.fs.copy(
      this.templatePath('.gitignore'),
      this.destinationPath('.gitignore')
    );
    this.fs.copy(
      this.templatePath('run.bat'),
      this.destinationPath('run.bat')
    );
    this.fs.copy(
      this.templatePath('run.sh'),
      this.destinationPath('run.sh')
    );

    // SolR 4 Config
    this.fs.copyTpl(
      this.templatePath('solr-config/pom.xml'),
      this.destinationPath('solr-config/pom.xml'),
      parent
    );

    // Share config
    this.fs.copy(
      this.templatePath('share/src'),
      this.destinationPath('share/src')
    );

    this.fs.copyTpl(
      this.templatePath('share/pom.xml'),
      this.destinationPath('share/pom.xml'),
      sharePom
    );

    // Alfresco config
    this.fs.copy(
      this.templatePath('repo/src'),
      this.destinationPath('repo/src')
    );

    this.fs.copyTpl(
      this.templatePath('repo/pom.xml'),
      this.destinationPath('repo/pom.xml'),
      repoPom
    );

    // Runner
    this.fs.copy(
      this.templatePath('runner/src'),
      this.destinationPath('runner/src'));
    this.fs.copy(
      this.templatePath('runner/test-ng'),
      this.destinationPath('runner/test-ng')
    );
    this.fs.copy(
      this.templatePath('runner/tomcat/context-solr.xml'),
      this.destinationPath('runner/tomcat/context-solr.xml')
    );
    this.fs.copyTpl(
      this.templatePath('runner/tomcat/context-share.xml'),
      this.destinationPath('runner/tomcat/context-share.xml'),
      shareModule
    );
    this.fs.copyTpl(
      this.templatePath('runner/tomcat/context-repo.xml'),
      this.destinationPath('runner/tomcat/context-repo.xml'),
      repoModule
    );

    this.fs.copyTpl(
      this.templatePath('runner/pom.xml'),
      this.destinationPath('runner/pom.xml'),
      parent
    );

    // Share amp module
    // TODO extract this part to a share amp subgenerator
    this.fs.copyTpl(
      this.templatePath('share-amp/pom.xml'),
      this.destinationPath(sharePath + 'pom.xml'),
      sharePom);

    // tests
    this.fs.copyTpl(
      this.templatePath('share-amp/src/test/resources/testng.xml'),
      this.destinationPath(sharePath + 'src/test/resources/testng.xml'),
      pkg
    );
    this.fs.copyTpl(
      this.templatePath('share-amp/src/test/java/demoamp/DemoPageTestIT.java'),
      this.destinationPath(sharePath + 'src/test/java/' + this.props.package.replace(/\./ig, '/') + '/DemoPageTestIT.java'),
      pkg
    );
    this.fs.copyTpl(
      this.templatePath('share-amp/src/test/java/demoamp/po/DemoPage.java'),
      this.destinationPath(sharePath + 'src/test/java/' + this.props.package.replace(/\./ig, '/') + '/po/DemoPage.java'),
      pkg
    );

    // Main resources
    this.fs.copy(
      this.templatePath('share-amp/src/main/resources'),
      this.destinationPath(sharePath + 'src/main/resources')
    );
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/file-mapping.properties'),
      this.destinationPath(sharePath + 'src/main/amp/file-mapping.properties')
    );
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/module.properties'),
      this.destinationPath(sharePath + 'src/main/amp/module.properties')
    );

    // Spring context
    this.fs.copyTpl(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/slingshot-application-context.xml'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/' + shareAmp + '-slingshot-application-context.xml'),
      sharePkg
    );

    // Messages
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/messages/messages.properties'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/messages/' + shareAmp + '.properties')
    );

    // Extensions
    this.fs.copyTpl(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/site-data/extensions/example-widgets.xml'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/site-data/extensions/' + shareAmp + '-example-widgets.xml'),
      sharePkg
    );

    // Site webscripts
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/site-webscripts/org'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/site-webscripts/org')
    );

    // Composition with Webscript generator
    this.composeWith(
      'alfresco:webscript', {
        options: { // Full options.
          id: 'simple-page',
          shortname: 'Simple Page',
          description: 'Simple Page definition',
          family: 'Share',
          url: '/simple-page',
          method: 'get',
          format: 'html',
          authentication: 'user',
          path: sharePath + 'src/main/amp/config/alfresco/web-extension/site-webscripts' + this.props.package.replace(/\./ig, '/') + '/pages',
          container: false,
          nested: true
        },
        args: []
      }, {
        //local: '../webscript/index.js', // Local subgenerator...
        link: 'strong' // Must apply when scaffolding the main project
      }
    );
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/site-webscripts/com/example'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/site-webscripts/' + this.props.package.replace(/\./ig, '/'))
    );

    // Web assets
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/web'),
      this.destinationPath(sharePath + 'src/main/amp/web')
    );

    // Repo amp module
    // TODO extract this part to a repo amp subgenerator
    this.fs.copyTpl(
      this.templatePath('repo-amp/pom.xml'),
      this.destinationPath(repoPath + 'pom.xml'),
      repoPom
    );

    // tests
    this.fs.copy(
      this.templatePath('repo-amp/src/test/properties'),
      this.destinationPath(repoPath + 'src/test/properties')
    );
    this.fs.copy(
      this.templatePath('repo-amp/src/test/resources'),
      this.destinationPath(repoPath + 'src/test/resources')
    );

    this.fs.copyTpl(
      this.templatePath('repo-amp/src/test/java/demoamp/test/DemoComponentTest.java'),
      this.destinationPath(repoPath + 'src/test/java/' + this.props.package.replace(/\./ig, '/') + 'demoamp/test/DemoComponentTest.java'),
      pkg
    );

    // Java
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/java/demoamp/Demo.java'),
      this.destinationPath(repoPath + 'src/main/java/' + this.props.package.replace(/\./ig, '/') + '/demoamp/Demo.java'),
      pkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/java/demoamp/DemoComponent.java'),
      this.destinationPath(repoPath + 'src/main/java/' + this.props.package.replace(/\./ig, '/') + '/demoamp/DemoComponent.java'),
      pkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/java/demoamp/HelloWorldWebScript.java'),
      this.destinationPath(repoPath + 'src/main/java/' + this.props.package.replace(/\./ig, '/') + '/demoamp/HelloWorldWebScript.java'),
      pkg
    );

    // Main resources
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/module.properties'),
      this.destinationPath(repoPath + 'src/main/amp/module.properties')
    );

    // Amp Module Config
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/alfresco-global.properties'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/alfresco-global.properties')
    );
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/model'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/model')
    );

    // Spring context
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/module-context.xml'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/module-context.xml'),
      repoPkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/context/bootstrap-context.xml'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/context/bootstrap-context.xml'),
      repoPkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/context/service-context.xml'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/context/service-context.xml'),
      repoPkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/context/webscript-context.xml'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/context/webscript-context.xml'),
      repoPkg
    );

    // Repo webscripts
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/extension'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/extension')
    );

    // Web assets (\o/)
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/web'),
      this.destinationPath(repoPath + 'src/main/amp/web')
    );

    // Glob project pom.xml
    this.fs.copyTpl(
      this.templatePath('pom.xml'),
      this.destinationPath('pom.xml'), {
        groupId: this.props.groupId,
        artifactId: this.props.artifactId,
        version: this.props.version,
        name: this.props.name,
        description: this.props.description
      }
    );
  },

  install: function () {
    this.log('You can either ' + chalk.bgBlack.white('mvn package') + ', ' + chalk.bgBlack.white('./run.sh') + ' or ' + chalk.bgBlack.white('.\\run.bat'));
  }
});
<commit_msg>Tests are not fucking OK while when your run it manually, everything's fine.<commit_after>'use strict';
var path = require('path');
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var _ = require('lodash');

module.exports = yeoman.generators.Base.extend({
  initializing: function () {
    this.props = this.config.getAll() || {};
  },
  prompting: function () {
    var done = this.async();
    var defaultAppBaseName = /^[a-zA-Z0-9_-]+$/.test(path.basename(process.cwd())) ? path.basename(process.cwd()) : 'sample-aio';
    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the solid ' + chalk.red('generator-alfresco') + ' generator!'
    ));

    var prompts = [{
      type: 'input',
      name: 'name',
      message: 'Name of the project',
      default: defaultAppBaseName
    }, {
      type: 'input',
      name: 'description',
      message: 'Description of the project'
    }, {
      type: 'input',
      name: 'groupId',
      message: 'Enter the groupId',
      default: 'com.example'
    }, {
      type: 'input',
      name: 'artifactId',
      message: 'Enter the artifactId',
      default: function (answers) {
        return answers.name;
      }
    }, {
      type: 'input',
      name: 'package',
      message: 'Enter the package',
      default: function (answers) {
        return answers.groupId + '.' + _.camelCase(answers.name);
      },
      validate: function (input) {
        return (input.match(/[a-zA-Z\.]+/g) || []).length > 0 || 'Doesn\'t match a package name...';
      }
    }, {
      type: 'input',
      name: 'version',
      message: 'Version number',
      default: '1.0-SNAPSHOT'
    }];

    this.prompt(prompts, function (props) {
      this.props = props;
      this.appname = props.name;
      done();
    }.bind(this));
  },
  configuring: function () {
    this.config.set(this.props);
    this.config.save();
  },

  writing: function () {
    var parent = {
      groupId: this.props.groupId,
      artifactId: this.props.artifactId,
      version: this.props.version
    };

    var pkg = {
      package: this.props.package
    };

    var shareAmp = this.props.artifactId + '-share-amp';
    var shareModule = {moduleId: shareAmp};
    var sharePom = _.assign({}, parent, shareModule);
    var sharePkg = _.assign({}, pkg, shareModule);
    var sharePath = shareAmp + '/';

    var repoAmp = this.props.artifactId + '-repo-amp';
    var repoModule = {moduleId: repoAmp};
    var repoPom = _.assign({}, parent, repoModule);
    var repoPkg = _.assign({}, pkg, repoModule);
    var repoPath = repoAmp + '/';

    this.fs.copy(
      this.templatePath('dummyfile.txt'),
      this.destinationPath('dummyfile.txt')
    );

    this.fs.copy(
      this.templatePath('.gitignore'),
      this.destinationPath('.gitignore')
    );
    this.fs.copy(
      this.templatePath('run.bat'),
      this.destinationPath('run.bat')
    );
    this.fs.copy(
      this.templatePath('run.sh'),
      this.destinationPath('run.sh')
    );

    // SolR 4 Config
    this.fs.copyTpl(
      this.templatePath('solr-config/pom.xml'),
      this.destinationPath('solr-config/pom.xml'),
      parent
    );

    // Share config
    this.fs.copy(
      this.templatePath('share/src'),
      this.destinationPath('share/src')
    );

    this.fs.copyTpl(
      this.templatePath('share/pom.xml'),
      this.destinationPath('share/pom.xml'),
      sharePom
    );

    // Alfresco config
    this.fs.copy(
      this.templatePath('repo/src'),
      this.destinationPath('repo/src')
    );

    this.fs.copyTpl(
      this.templatePath('repo/pom.xml'),
      this.destinationPath('repo/pom.xml'),
      repoPom
    );

    // Runner
    this.fs.copy(
      this.templatePath('runner/src'),
      this.destinationPath('runner/src'));
    this.fs.copy(
      this.templatePath('runner/test-ng'),
      this.destinationPath('runner/test-ng')
    );
    this.fs.copy(
      this.templatePath('runner/tomcat/context-solr.xml'),
      this.destinationPath('runner/tomcat/context-solr.xml')
    );
    this.fs.copyTpl(
      this.templatePath('runner/tomcat/context-share.xml'),
      this.destinationPath('runner/tomcat/context-share.xml'),
      shareModule
    );
    this.fs.copyTpl(
      this.templatePath('runner/tomcat/context-repo.xml'),
      this.destinationPath('runner/tomcat/context-repo.xml'),
      repoModule
    );

    this.fs.copyTpl(
      this.templatePath('runner/pom.xml'),
      this.destinationPath('runner/pom.xml'),
      parent
    );

    // Share amp module
    // TODO extract this part to a share amp subgenerator
    this.fs.copyTpl(
      this.templatePath('share-amp/pom.xml'),
      this.destinationPath(sharePath + 'pom.xml'),
      sharePom);

    // tests
    this.fs.copyTpl(
      this.templatePath('share-amp/src/test/resources/testng.xml'),
      this.destinationPath(sharePath + 'src/test/resources/testng.xml'),
      pkg
    );
    this.fs.copyTpl(
      this.templatePath('share-amp/src/test/java/demoamp/DemoPageTestIT.java'),
      this.destinationPath(sharePath + 'src/test/java/' + this.props.package.replace(/\./ig, '/') + '/DemoPageTestIT.java'),
      pkg
    );
    this.fs.copyTpl(
      this.templatePath('share-amp/src/test/java/demoamp/po/DemoPage.java'),
      this.destinationPath(sharePath + 'src/test/java/' + this.props.package.replace(/\./ig, '/') + '/po/DemoPage.java'),
      pkg
    );

    // Main resources
    this.fs.copy(
      this.templatePath('share-amp/src/main/resources'),
      this.destinationPath(sharePath + 'src/main/resources')
    );
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/file-mapping.properties'),
      this.destinationPath(sharePath + 'src/main/amp/file-mapping.properties')
    );
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/module.properties'),
      this.destinationPath(sharePath + 'src/main/amp/module.properties')
    );

    // Spring context
    this.fs.copyTpl(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/slingshot-application-context.xml'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/' + shareAmp + '-slingshot-application-context.xml'),
      sharePkg
    );

    // Messages
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/messages/messages.properties'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/messages/' + shareAmp + '.properties')
    );

    // Extensions
    this.fs.copyTpl(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/site-data/extensions/example-widgets.xml'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/site-data/extensions/' + shareAmp + '-example-widgets.xml'),
      sharePkg
    );

    // Site webscripts
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/site-webscripts/org'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/site-webscripts/org')
    );

    // Composition with Webscript generator
    this.composeWith(
      'alfresco:webscript', {
        options: { // Full options.
          id: 'simple-page',
          shortname: 'Simple Page',
          description: 'Simple Page definition',
          family: 'Share',
          url: '/simple-page',
          method: 'get',
          format: 'html',
          authentication: 'user',
          path: sharePath + 'src/main/amp/config/alfresco/web-extension/site-webscripts' + this.props.package.replace(/\./ig, '/') + '/pages',
          container: false,
          nested: true
        },
        args: []
      }, {
        //local: '../webscript/index.js', // Local subgenerator...
        link: 'strong' // Must apply when scaffolding the main project
      }
    );
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/config/alfresco/web-extension/site-webscripts/com/example'),
      this.destinationPath(sharePath + 'src/main/amp/config/alfresco/web-extension/site-webscripts/' + this.props.package.replace(/\./ig, '/'))
    );

    // Web assets
    this.fs.copy(
      this.templatePath('share-amp/src/main/amp/web'),
      this.destinationPath(sharePath + 'src/main/amp/web')
    );

    // Repo amp module
    // TODO extract this part to a repo amp subgenerator
    this.fs.copyTpl(
      this.templatePath('repo-amp/pom.xml'),
      this.destinationPath(repoPath + 'pom.xml'),
      repoPom
    );

    // tests
    this.fs.copy(
      this.templatePath('repo-amp/src/test/properties'),
      this.destinationPath(repoPath + 'src/test/properties')
    );
    this.fs.copy(
      this.templatePath('repo-amp/src/test/resources'),
      this.destinationPath(repoPath + 'src/test/resources')
    );

    this.fs.copyTpl(
      this.templatePath('repo-amp/src/test/java/demoamp/test/DemoComponentTest.java'),
      this.destinationPath(repoPath + 'src/test/java/' + this.props.package.replace(/\./ig, '/') + 'demoamp/test/DemoComponentTest.java'),
      pkg
    );

    // Java
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/java/demoamp/Demo.java'),
      this.destinationPath(repoPath + 'src/main/java/' + this.props.package.replace(/\./ig, '/') + '/demoamp/Demo.java'),
      pkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/java/demoamp/DemoComponent.java'),
      this.destinationPath(repoPath + 'src/main/java/' + this.props.package.replace(/\./ig, '/') + '/demoamp/DemoComponent.java'),
      pkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/java/demoamp/HelloWorldWebScript.java'),
      this.destinationPath(repoPath + 'src/main/java/' + this.props.package.replace(/\./ig, '/') + '/demoamp/HelloWorldWebScript.java'),
      pkg
    );

    // Main resources
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/module.properties'),
      this.destinationPath(repoPath + 'src/main/amp/module.properties')
    );

    // Amp Module Config
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/alfresco-global.properties'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/alfresco-global.properties')
    );
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/model'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/model')
    );

    // Spring context
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/module-context.xml'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/module-context.xml'),
      repoPkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/context/bootstrap-context.xml'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/context/bootstrap-context.xml'),
      repoPkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/context/service-context.xml'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/context/service-context.xml'),
      repoPkg
    );
    this.fs.copyTpl(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/module/repo-amp/context/webscript-context.xml'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/module/' + repoAmp + '/context/webscript-context.xml'),
      repoPkg
    );

    // Repo webscripts
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/config/alfresco/extension'),
      this.destinationPath(repoPath + 'src/main/amp/config/alfresco/extension')
    );

    // Web assets (\o/)
    this.fs.copy(
      this.templatePath('repo-amp/src/main/amp/web'),
      this.destinationPath(repoPath + 'src/main/amp/web')
    );

    // Glob project pom.xml
    this.fs.copyTpl(
      this.templatePath('pom.xml'),
      this.destinationPath('pom.xml'), {
        groupId: this.props.groupId,
        artifactId: this.props.artifactId,
        version: this.props.version,
        name: this.props.name,
        description: this.props.description
      }
    );
  },

  install: function () {
    this.log('You can either ' + chalk.bgBlack.white('mvn package') + ', ' + chalk.bgBlack.white('./run.sh') + ' or ' + chalk.bgBlack.white('.\\run.bat'));
  }
});
<|endoftext|>


<commit_before>var globalDefaults = {
  guess:               0,
  iterations:          100,
  temperature:         1.0,
  stepSize:            0.5,
  includeAllMinsFound: false,
  interval:            50
};

var extendNoOverwrite = function (obj, defaults){
  for (key in defaults) {
    if (obj[key] === undefined) {
      obj[key] = defaults[key];
    }
  }
}

var extractFunc = function (func, multipleParams) {
  // if function given is a function,
  // extract the argument name, extract the return value,
  // replace the argument name with 'x'
  // return the return value as a string, with x as the independent variable
  func = func.toString();
  if (!multipleParams) {
    var arg = func.match(/^function\s*[^\(]*\(\s*([^\)\,]*)[\,\)]/m)[1];
    var regex = new RegExp('\\b' + arg.trim() + '\\b', 'g')
    func = func.replace(regex, 'x');
  } else {
    // args are going to be f(x, a, b, c...) - x is independent variable, a, b... are parameters
    var args = func.match(/^function\s*[^\(]*\(\s*([^\)]*)[\)]/m)[1];
    args = args.split(',');
    var ch = 'a';
    for (var i = 0; i < args.length; i++) {
      var regex = new RegExp('\\b' + args[i].trim() + '\\b', 'g');
      if (i === 0) {
        func = func.replace(regex, 'x');
      } else {
        func = func.replace(regex, ch);
        ch = String.fromCharCode(ch.charCodeAt(0) + 1);
      }
    }
  }
  func = func.match(/return\s*([^\;}]*)[\;}]/m)[1];
  return {
    func   : func,
    numArgs: args.length
  }
}

var cleanFunc = function (func, newVarName, multipleParams){
  var numArgs;
  if (typeof func === 'function') {
    f = extractFunc(func, multipleParams);
    func = f.func;
    numArgs = f.numArgs;
  } else if (typeof func === 'string') {
    if (newVarName && typeof newVarName === 'string' && !multipleParams) {
      var regex = new RegExp('\\b' + newVarName + '\\b', 'g');
      func = func.replace(regex, 'x');
    } else if (newVarName && typeof newVarName === 'object' && multipleParams) {
      numArgs = newVarName.length;
      var ch = 'a';
      for (var i = 0; i < newVarName.length; i++) {
        var regex = new RegExp('\\b' + newVarName[i] + '\\b', 'g');
        if (i === 0) {
          func = func.replace(regex, 'x');
        } else {
          func = func.replace(regex, ch);
          ch = String.fromCharCode(ch.charCodeAt(0) + 1);
        }
      }
    }
  } else {
    throw 'function to be optimized needs to be a function or a string expression';
  }

  func = func.replace(/Math./gi,'');
  func = func.replace(/LN2/gi, 'ln(2)');
  func = func.replace(/LN10/gi, 'ln(10)');
  func = func.replace(/LOG2E/gi, 'log(e,2)');
  func = func.replace(/LOG10E/gi, 'log(e,10)');
  func = func.replace(/SQRT1_2/gi, 'sqrt(1/2)');
  func = func.replace(/SQRT2/gi, 'sqrt(2)');
  func = func.toLowerCase();

  return {
    func   : func,
    numArgs: numArgs
  };
}

module.exports = {
  cleanMin: function (operation, func, options, callback) {
    if (typeof options === 'function') {
      callback = options;
      options = undefined;
    }
    // provide default callback function (console.log)
    callback = this.cleanCB(callback);

    options = options || {};

    // clean provided function to be accepted by sympy lambdify function
    func = cleanFunc(func, options.variable, false).func;

    // provide sensible defaults for the options object
    if (operation === 'local') {
      options = {
        bracket: null,
        method: 'Brent',
        bounds: options.bounds,
        tol: null,
        options: null
      }

      if (Array.isArray(options.bounds) && options.bounds.length === 2) {
        options.method = 'Bounded';
      } else {
        options.bounds = null;
        options.method = 'Brent';
      }
    } else if (operation === 'global') {
      extendNoOverwrite(options, globalDefaults);
    }

    return {
      func:     func,
      options:  options,
      callback: callback
    }
  },

  cleanFit: function(func, options, callback, xData, yData) {
    if (typeof options === 'function') {
      callback = options;
      options = undefined;
    }
    // provide default callback function (console.log)
    callback = this.cleanCB(callback);

    options = options || {};
    options.xData = xData;
    options.yData = yData;

    f = cleanFunc(func, options.variables, true);
    options.numArgs = f.numArgs;
    func = f.func;

    return {
      func:     func,
      options:  options,
      callback: callback
    }
  },

  cleanRoot: function(func, options, callback, lower, upper) {
    if (typeof options === 'function') {
      callback = options;
      options = undefined;
    }
    callback = this.cleanCB(callback);

    options = options || {};
    options.lower = lower;
    options.upper = upper;
    options.method = options.method || 'brentq'

    func = cleanFunc(func, options.variable, false).func;

    return {
      func:     func,
      options:  options,
      callback: callback
    }
  },

  cleanCB: function(callback) {
    return callback || function (results){
      console.log(results);
    };
  }
}<commit_msg>Remodularize clean, add clean for derivative<commit_after>var globalDefaults = {
  guess:               0,
  iterations:          100,
  temperature:         1.0,
  stepSize:            0.5,
  includeAllMinsFound: false,
  interval:            50
};

var extendNoOverwrite = function (obj, defaults){
  for (key in defaults) {
    if (obj[key] === undefined) {
      obj[key] = defaults[key];
    }
  }
}

var extractFuncFromFunction = function (func, multipleParams) {
  // if function given is a function,
  // extract the argument name, extract the return value,
  // replace the argument name with 'x'
  // return the return value as a string, with x as the independent variable
  func = func.toString();
  var args;
  if (!multipleParams) {
    var arg = func.match(/^function\s*[^\(]*\(\s*([^\)\,]*)[\,\)]/m)[1];
    var regex = new RegExp('\\b' + arg.trim() + '\\b', 'g')
    func = func.replace(regex, 'x');
  } else {
    // args are going to be f(x, a, b, c...) - x is independent variable, a, b... are parameters
    args = func.match(/^function\s*[^\(]*\(\s*([^\)]*)[\)]/m)[1];
    args = args.split(',');
    var ch = 'a';
    for (var i = 0; i < args.length; i++) {
      var regex = new RegExp('\\b' + args[i].trim() + '\\b', 'g');
      if (i === 0) {
        func = func.replace(regex, 'x');
      } else {
        func = func.replace(regex, ch);
        ch = String.fromCharCode(ch.charCodeAt(0) + 1);
      }
    }
  }
  func = func.match(/return\s*([^\;}]*)[\;}]/m)[1];
  args = args || {};
  return {
    func   : func,
    numArgs: args.length
  }
};

var extractFuncFromString = function (func, newVarName, multipleParams) {
  if (newVarName && typeof newVarName === 'string' && !multipleParams) {
    var regex = new RegExp('\\b' + newVarName + '\\b', 'g');
    func = func.replace(regex, 'x');
    return {
      func: func,
      numArgs: 1
    };
  } else if (newVarName && typeof newVarName === 'object' && multipleParams) {
    numArgs = newVarName.length;
    var ch = 'a';
    for (var i = 0; i < newVarName.length; i++) {
      var regex = new RegExp('\\b' + newVarName[i] + '\\b', 'g');
      if (i === 0) {
        func = func.replace(regex, 'x');
      } else {
        func = func.replace(regex, ch);
        ch = String.fromCharCode(ch.charCodeAt(0) + 1);
      }
    }
    return {
      func: func,
      numArgs: numArgs
    }
  }
}

var cleanFunc = function (func, newVarName, multipleParams){
  var f;
  if (typeof func === 'function') {
    f = extractFuncFromFunction(func, multipleParams);
  } else if (typeof func === 'string') {
    f = extractFuncFromString(func, newVarName, multipleParams);
  } else {
    throw 'function to be optimized needs to be a function or a string expression';
  }
  func = f.func;
  var numArgs = f.numArgs;

  func = func.replace(/Math./gi,'');
  func = func.replace(/LN2/gi, 'ln(2)');
  func = func.replace(/LN10/gi, 'ln(10)');
  func = func.replace(/LOG2E/gi, 'log(e,2)');
  func = func.replace(/LOG10E/gi, 'log(e,10)');
  func = func.replace(/SQRT1_2/gi, 'sqrt(1/2)');
  func = func.replace(/SQRT2/gi, 'sqrt(2)');
  func = func.toLowerCase();

  return {
    func   : func,
    numArgs: numArgs
  };
}

var optionalArgs = function (options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = undefined;
  }
  // provide default callback function (console.log)
  callback = cleanInputs.cleanCB(callback);

  options = options || {};

  return {
    callback: callback,
    options: options
  };
};

var cleanInputs = module.exports = {
  cleanMin: function (operation, func, options, callback) {
    var optional = optionalArgs(options, callback);
    options  = optional.options;
    callback = optional.callback;

    // clean provided function to be accepted by sympy lambdify function
    func = cleanFunc(func, options.variable, false).func;
    // provide sensible defaults for the options object
    if (operation === 'local') {
      options = {
        bracket: null,
        method: 'Brent',
        bounds: options.bounds,
        tol: null,
        options: null
      }

      if (Array.isArray(options.bounds) && options.bounds.length === 2) {
        options.method = 'Bounded';
      } else {
        options.bounds = null;
        options.method = 'Brent';
      }
    } else if (operation === 'global') {
      extendNoOverwrite(options, globalDefaults);
    }

    return {
      func:     func,
      options:  options,
      callback: callback
    }
  },

  cleanFit: function(func, options, callback, xData, yData) {
    var optional = optionalArgs(options, callback);
    options  = optional.options;
    callback = optional.callback;

    options.xData = xData;
    options.yData = yData;

    f = cleanFunc(func, options.variables, true);
    options.numArgs = f.numArgs;
    func = f.func;

    return {
      func:     func,
      options:  options,
      callback: callback
    }
  },

  cleanRoot: function(func, options, callback, lower, upper) {
    var optional = optionalArgs(options, callback);
    options  = optional.options;
    callback = optional.callback;

    options.lower = lower;
    options.upper = upper;
    options.method = options.method || 'brentq'

    func = cleanFunc(func, options.variable, false).func;

    return {
      func:     func,
      options:  options,
      callback: callback
    }
  },

  cleanVector: function(func, options, callback, guess) {
    var optional = optionalArgs(options, callback);
    options  = optional.options;
    callback = optional.callback;

    options.guess = guess;

    func = cleanFunc(func, options.variable, false).func;

    return {
      func:     func,
      options:  options,
      callback: callback
    }
  },

  cleanDerivative: function(func, options, callback, point) {
    var optional = optionalArgs(options, callback);
    options  = optional.options;
    callback = optional.callback;

    options.point = point;
    options.epsilon = options.epsilon || 0.000001;

    func = cleanFunc(func, options.variable, false).func;

    return {
      func:     func,
      options:  options,
      callback: callback
    }
  },

  cleanCB: function (callback){
    return callback || function (results){
      console.log(results);
    };
  }
}<|endoftext|>


<commit_before>/* Copyright (C) 2015 by frePPLe bvba
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
 * General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

function themeconfig(themefolder, themename) {
  // Auxilary function to generate the task configuration for a single theme.
  var cfg = {
    options: {
      paths: [
        themefolder + '/static/css/' + themename, // frePPLe theme folder
        'freppledb/common/static/css', // frePPLe folder
        'node_modules/bootstrap/less' // bootstrap folder
        ],
      strictMath: true,
      sourceMap: true,
      compress: true,
      relativeUrls: true,
      plugins: [
        new(require('less-plugin-autoprefix'))({
          browsers: ["last 2 versions"]
        })
      ]
    },
    files: {}
  }
  cfg.files[themefolder + '/static/css/' + themename + '/bootstrap.min.css'] = [
    'freppledb/common/static/css/frepple.less', // Generic frePPLe styles
    themefolder + '/static/css/' + themename + '/frepple.less' // Theme specific styles
    ]
  return cfg;
}

// Grunt configuration
module.exports = function (grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    // Less compilation
    less: {
      odoo: themeconfig('freppledb/common', 'odoo'),
      grass: themeconfig('freppledb/common', 'grass'),
      earth: themeconfig('freppledb/common', 'earth'),
      lemon: themeconfig('freppledb/common', 'lemon'),
      snow: themeconfig('freppledb/common', 'snow'),
      strawberry: themeconfig('freppledb/common', 'strawberry'),
      water: themeconfig('freppledb/common', 'water'),
      orange: themeconfig('freppledb/common', 'orange'),
      openbravo: themeconfig('freppledb/common', 'openbravo'),
    },
    // When any .less file changes we automatically run the "less"-task.
    watch: {
      files: ["**/*.less"],
      tasks: ["less"]
    },

    // Extract translations
    nggettext_extract: {
      pot: {
        options: {
          msgmerge: true
        },
        files: {
          'freppledb/common/static/common/po/template.pot': [
            'freppledb/input/static/operationplandetail/*.html',
            'freppledb/input/static/operationplandetail/src/*.js'
            ]
        }
      },
    },

    // Compile translations
    nggettext_compile: {
      all: {
        files: {
          'freppledb/common/static/js/i18n/angular-freppletranslations.js': [
            'freppledb/common/static/common/po/*.po'
          ]
        }
      },
    },

    // Concatenate javascript files
    concat: {
      common: {
        src: [
              'freppledb/common/static/common/src/module.js',
              'freppledb/common/static/common/src/webfactory.js',
              'freppledb/common/static/common/src/preferences.js'
              ],
        dest: 'freppledb/common/static/js/frepple-common.js'
      },
      input: {
        src: [
              'freppledb/input/static/input/src/module.js',
              'freppledb/input/static/input/src/buffer.js',
              'freppledb/input/static/input/src/demand.js',
              'freppledb/input/static/input/src/customer.js',
              'freppledb/input/static/input/src/item.js',
              'freppledb/input/static/input/src/location.js',
              'freppledb/input/static/input/src/operation.js',
              'freppledb/input/static/input/src/operationplan.js',
              'freppledb/input/static/input/src/resource.js',
              'freppledb/input/static/input/src/model.js',
              ],
        dest: 'freppledb/input/static/js/frepple-input.js'
      },
      operationplandetail: {
        src: [
              'freppledb/input/static/operationplandetail/src/module.js',
              'freppledb/input/static/operationplandetail/src/operationplandetailCtrl.js',
              'freppledb/input/static/operationplandetail/src/problemspanelDrv.js',
              'freppledb/input/static/operationplandetail/src/resourcespanelDrv.js',
              'freppledb/input/static/operationplandetail/src/bufferspanelDrv.js',
              'freppledb/input/static/operationplandetail/src/demandpeggingpanelDrv.js',
              'freppledb/input/static/operationplandetail/src/operationplanpanelDrv.js',
              'freppledb/input/static/operationplandetail/src/supplyinformationDrv.js',
              'freppledb/input/static/operationplandetail/src/networkstatusDrv.js'
              ],
        dest: 'freppledb/input/static/js/frepple-operationplandetail.js'
      }
    },

    // Uglify the javascript files
    uglify: {
      options: {
        sourceMap: true,
        banner: '/* frePPLe <%= pkg.version %>\n' +
          'Copyright (C) 2010-2019 by frePPLe bvba\n\n' +
          'This library is free software; you can redistribute it and/or modify it\n' +
          'under the terms of the GNU Affero General Public License as published\n' +
          'by the Free Software Foundation; either version 3 of the License, or\n' +
          '(at your option) any later version.\n\n' +
          'This library is distributed in the hope that it will be useful,\n' +
          'but WITHOUT ANY WARRANTY; without even the implied warranty of\n' +
          'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n' +
          'General Public License for more details.\n\n' +
          'You should have received a copy of the GNU Affero General Public\n' +
          'License along with this program.  If not, see <http://www.gnu.org/licenses/>.\n' +
          '*/\n'
      },
      js: {
        src: ['freppledb/common/static/js/frepple.js'],
        dest: 'freppledb/common/static/js/frepple.min.js'
      },
      common: {
        src: ['freppledb/common/static/js/frepple-common.js'],
        dest: 'freppledb/common/static/js/frepple-common.min.js'
      },
      input: {
        src: ['freppledb/input/static/js/frepple-input.js'],
        dest: 'freppledb/input/static/js/frepple-input.min.js'
      },
      operationplandetail: {
        src: ['freppledb/input/static/js/frepple-operationplandetail.js'],
        dest: 'freppledb/input/static/js/frepple-operationplandetail.min.js'
      }
    },

    // Clean intermediate files
    clean: [
      'freppledb/common/static/js/frepple-common.js',
      'freppledb/input/static/js/frepple-input.js',
      'freppledb/input/static/js/frepple-operationplandetail.js'
      ]
  });

  // Load tasks
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-angular-gettext');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify-es');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-exec');

  // Register our tasks
  grunt.registerTask('minify', ['concat', 'uglify', 'clean']);
  grunt.registerTask('default', ['less', 'concat', 'uglify', 'clean']);

};
<commit_msg>adding pegging panel to minify grunt task<commit_after>/* Copyright (C) 2015 by frePPLe bvba
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
 * General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

function themeconfig(themefolder, themename) {
  // Auxilary function to generate the task configuration for a single theme.
  var cfg = {
    options: {
      paths: [
        themefolder + '/static/css/' + themename, // frePPLe theme folder
        'freppledb/common/static/css', // frePPLe folder
        'node_modules/bootstrap/less' // bootstrap folder
        ],
      strictMath: true,
      sourceMap: true,
      compress: true,
      relativeUrls: true,
      plugins: [
        new(require('less-plugin-autoprefix'))({
          browsers: ["last 2 versions"]
        })
      ]
    },
    files: {}
  }
  cfg.files[themefolder + '/static/css/' + themename + '/bootstrap.min.css'] = [
    'freppledb/common/static/css/frepple.less', // Generic frePPLe styles
    themefolder + '/static/css/' + themename + '/frepple.less' // Theme specific styles
    ]
  return cfg;
}

// Grunt configuration
module.exports = function (grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    // Less compilation
    less: {
      odoo: themeconfig('freppledb/common', 'odoo'),
      grass: themeconfig('freppledb/common', 'grass'),
      earth: themeconfig('freppledb/common', 'earth'),
      lemon: themeconfig('freppledb/common', 'lemon'),
      snow: themeconfig('freppledb/common', 'snow'),
      strawberry: themeconfig('freppledb/common', 'strawberry'),
      water: themeconfig('freppledb/common', 'water'),
      orange: themeconfig('freppledb/common', 'orange'),
      openbravo: themeconfig('freppledb/common', 'openbravo'),
    },
    // When any .less file changes we automatically run the "less"-task.
    watch: {
      files: ["**/*.less"],
      tasks: ["less"]
    },

    // Extract translations
    nggettext_extract: {
      pot: {
        options: {
          msgmerge: true
        },
        files: {
          'freppledb/common/static/common/po/template.pot': [
            'freppledb/input/static/operationplandetail/*.html',
            'freppledb/input/static/operationplandetail/src/*.js'
            ]
        }
      },
    },

    // Compile translations
    nggettext_compile: {
      all: {
        files: {
          'freppledb/common/static/js/i18n/angular-freppletranslations.js': [
            'freppledb/common/static/common/po/*.po'
          ]
        }
      },
    },

    // Concatenate javascript files
    concat: {
      common: {
        src: [
              'freppledb/common/static/common/src/module.js',
              'freppledb/common/static/common/src/webfactory.js',
              'freppledb/common/static/common/src/preferences.js'
              ],
        dest: 'freppledb/common/static/js/frepple-common.js'
      },
      input: {
        src: [
              'freppledb/input/static/input/src/module.js',
              'freppledb/input/static/input/src/buffer.js',
              'freppledb/input/static/input/src/demand.js',
              'freppledb/input/static/input/src/customer.js',
              'freppledb/input/static/input/src/item.js',
              'freppledb/input/static/input/src/location.js',
              'freppledb/input/static/input/src/operation.js',
              'freppledb/input/static/input/src/operationplan.js',
              'freppledb/input/static/input/src/resource.js',
              'freppledb/input/static/input/src/model.js',
              ],
        dest: 'freppledb/input/static/js/frepple-input.js'
      },
      operationplandetail: {
        src: [
              'freppledb/input/static/operationplandetail/src/module.js',
              'freppledb/input/static/operationplandetail/src/operationplandetailCtrl.js',
              'freppledb/input/static/operationplandetail/src/problemspanelDrv.js',
              'freppledb/input/static/operationplandetail/src/resourcespanelDrv.js',
              'freppledb/input/static/operationplandetail/src/bufferspanelDrv.js',
              'freppledb/input/static/operationplandetail/src/demandpeggingpanelDrv.js',
              'freppledb/input/static/operationplandetail/src/operationplanpanelDrv.js',
              'freppledb/input/static/operationplandetail/src/supplyinformationDrv.js',
              'freppledb/input/static/operationplandetail/src/downstreamoperationplansDrv.js',
              'freppledb/input/static/operationplandetail/src/networkstatusDrv.js'
              ],
        dest: 'freppledb/input/static/js/frepple-operationplandetail.js'
      }
    },

    // Uglify the javascript files
    uglify: {
      options: {
        sourceMap: true,
        banner: '/* frePPLe <%= pkg.version %>\n' +
          'Copyright (C) 2010-2019 by frePPLe bvba\n\n' +
          'This library is free software; you can redistribute it and/or modify it\n' +
          'under the terms of the GNU Affero General Public License as published\n' +
          'by the Free Software Foundation; either version 3 of the License, or\n' +
          '(at your option) any later version.\n\n' +
          'This library is distributed in the hope that it will be useful,\n' +
          'but WITHOUT ANY WARRANTY; without even the implied warranty of\n' +
          'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n' +
          'General Public License for more details.\n\n' +
          'You should have received a copy of the GNU Affero General Public\n' +
          'License along with this program.  If not, see <http://www.gnu.org/licenses/>.\n' +
          '*/\n'
      },
      js: {
        src: ['freppledb/common/static/js/frepple.js'],
        dest: 'freppledb/common/static/js/frepple.min.js'
      },
      common: {
        src: ['freppledb/common/static/js/frepple-common.js'],
        dest: 'freppledb/common/static/js/frepple-common.min.js'
      },
      input: {
        src: ['freppledb/input/static/js/frepple-input.js'],
        dest: 'freppledb/input/static/js/frepple-input.min.js'
      },
      operationplandetail: {
        src: ['freppledb/input/static/js/frepple-operationplandetail.js'],
        dest: 'freppledb/input/static/js/frepple-operationplandetail.min.js'
      }
    },

    // Clean intermediate files
    clean: [
      'freppledb/common/static/js/frepple-common.js',
      'freppledb/input/static/js/frepple-input.js',
      'freppledb/input/static/js/frepple-operationplandetail.js'
      ]
  });

  // Load tasks
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-angular-gettext');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify-es');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-exec');

  // Register our tasks
  grunt.registerTask('minify', ['concat', 'uglify', 'clean']);
  grunt.registerTask('default', ['less', 'concat', 'uglify', 'clean']);

};
<|endoftext|>


<commit_before>'use strict';
var util            = require('util');
var yeoman          = require('yeoman-generator');
var chalk           = require('chalk');
var updateNotifier  = require('update-notifier');
var pkg             = require('../../package.json');
var opn             = require('opn');
var _s              = require('underscore.string');

var KickoffGenerator = module.exports = function KickoffGenerator(args, options) {
	yeoman.Base.apply(this, arguments);
};

util.inherits(KickoffGenerator, yeoman.generators.Base);

KickoffGenerator.prototype.askFor = function () {
	var done = this.async();

	// Checks for available update and returns an instance
	var notifier = updateNotifier({
		packageName: pkg.name,
		packageVersion: pkg.version,
		updateCheckInterval: 1000 * 60 // Every hour
	});

	var kickoffWelcome = chalk.white('\n ##  ## ######  ####  ##  ##  ') + chalk.yellow('####  ###### ######') + chalk.white('\n ## ##    ##   ##  ## ## ##  ') + chalk.yellow('##  ## ##     ##') + chalk.white('\n ####     ##   ##     ####   ') + chalk.yellow('##  ## ####   ####') + chalk.white('\n ## ##    ##   ##  ## ## ##  ') + chalk.yellow('##  ## ##     ##') + chalk.white('\n ##  ## ######  ####  ##  ##  ') + chalk.yellow('####  ##     ##') + '\n\n ' + chalk.white.bold('A Yeoman generator for the Kickoff front-end framework') + '\n\n Find out more at ' + chalk.cyan('trykickoff.com') + '\n Yeoman Generator version:  ' + pkg.version + '\n\n Kickoff is free and open-source and maintained by ' + chalk.yellow('@MrMartineau') + ',\n ' + chalk.green('@AshNolan_') + ', ' + chalk.red('@nicbell') + ' & the ' + chalk.blue('@tmwTechTeam') + '. \n';

	// Have Yeoman greet the user.
	this.log(kickoffWelcome);

	if (notifier.update) {
		// Check for npm package update and print message if needed
		var updateMessage = chalk.yellow('   ┌────────────────────────────────────────────────┐\n   │') + ' Update available: '  + chalk.green(notifier.update.latest) + chalk.gray(' (current: ' + pkg.version + ')') + '       '+ chalk.yellow('│\n   │') + ' Run ' + chalk.cyan('npm update -g ' + pkg.name) + ' to update. ' + chalk.yellow('│\n   └────────────────────────────────────────────────┘\n');

		this.log(updateMessage);
	}

	var prompts = [
		{
			name: 'projectName',
			message: 'Project name',
			default: 'Your project name'
		},
		{
			name: 'projectDescription',
			message: 'Description',
			default: 'Project description'
		},
		{
			name: 'devNames',
			message: 'Developer\'s names?',
			default: 'Tom, Dick and Harry'
		},
		{
			name: 'features',
			type: 'checkbox',
			message: 'Which features would you like?',
			choices: [
				{
					name: 'Does this project support IE8?',
					value: 'oldIE',
					default: false,
				},
				{
					name: 'Include Kickoff\'s styleguide?',
					value: 'styleguide'
				},
				{
					name: 'Use Kickoff Statix?',
					value: 'statix'
				},
				{
					name: 'Use Grunticon?',
					value: 'grunticon'
				}
			],
			store: true
		},
		{
			name: 'browserify',
			type: 'confirm',
			message: 'Use Browserify to bundle your Javascript?',
			default: true,
			store: true
		},
		{
			name: 'jsNamespace',
			message: 'Choose your javascript namespace',
			default: 'KO',
			store: true,
			when: function(response) {
				return !response.browserify;
			}
		},
		{
			name: 'jsLibs',
			type: 'checkbox',
			message: 'Which Javascript libraries would you like to use?',
			choices: [
				{
					name: 'jQuery 1.x - only choose one jQuery version',
					value: 'jquery1'
				},
				{
					name: 'jQuery 2.x - only choose one jQuery version',
					value: 'jquery2'
				},
				{
					name: 'trak.js - Universal event tracking API',
					value: 'trak'
				},
				{
					name: 'Swiftclick - Eliminates the 300ms click event delay on touch devices',
					value: 'swiftclick'
				},
				{
					name: 'Include some Javascript polyfills/shims? (These are generated by the \'grunt shimly\' command)',
					value: 'shims'
				},
				{
					name: 'Use Modernizr?',
					value: 'modernizr'
				}
			],
			store: true
		}
	];

	this.prompt(prompts, function (answers) {
		for (var key in answers) {
			this[key] = answers[key];
		}

		var jsLibs = answers.jsLibs;
		var features = answers.features;

		function hasFeature(feat, prop) {
			return prop && prop.indexOf(feat) !== -1;
		}

		console.log('jsLibs', jsLibs);
		console.log('features', features);

		// JS Libs
		this.includeTrak       = hasFeature('trak', jsLibs);
		this.includeJquery1    = hasFeature('jquery1', jsLibs);
		this.includeJquery2    = hasFeature('jquery2', jsLibs);
		this.includeSwiftclick = hasFeature('swiftclick', jsLibs);
		this.includeShims      = hasFeature('shims', jsLibs);
		this.includeModernizr  = hasFeature('modernizr', jsLibs);

		// Features
		this.includeGrunticon  = hasFeature('grunticon', features);
		this.includeStatix     = hasFeature('statix', features);
		this.includeStyleguide = hasFeature('styleguide', features);
		this.oldIE = hasFeature('oldIE', features);

		done();
	}.bind(this));
};

/**
 * Info
 * http://yeoman.io/generator/actions_actions.html
 * http://yeoman.io/authoring/file-system.html
 */
KickoffGenerator.prototype.packageFiles = function packageFiles() {

	this.fs.copyTpl(
		this.templatePath('_index.html'),
		this.destinationPath('index.html'),
		{
			projectName: this.projectName,
			projectNameSlugified: _s.slugify(this.projectName),
			oldIE: this.oldIE,
			grunticon: this.includeGrunticon,
			modernizr: this.includeModernizr,
			shims: this.includeShims
		}
	);

	if (this.includeStyleguide && !this.includeStatix) {
		this.fs.copyTpl(
			this.templatePath('styleguide/_index.html'),
			this.destinationPath('styleguide/index.html'),
			{
				projectName: this.projectName,
				projectNameSlugified: _s.slugify(this.projectName),
				oldIE: this.oldIE,
				grunticon: this.includeGrunticon,
				modernizr: this.includeModernizr,
				shims: this.includeShims
			}
		);
	}

	// CSS, SCSS, images & grunticon source directory
	this.directory('assets/dist/css', 'assets/dist/css');
	this.directory('assets/src/scss', 'assets/src/scss');
	this.directory('assets/src/img', 'assets/src/img');
	this.directory('assets/src/grunticon', 'assets/src/grunticon');

	// Javascript
	if (this.browserify) {
		this.fs.copyTpl(
			this.templatePath('assets/src/js/_script-browserify.js'),
			this.destinationPath('assets/src/js/script.js'),
			{
				projectName: this.projectName,
				devNames: this.devNames,
				browserify: this.browserify,
				includeSwiftclick: this.includeSwiftclick,
				includeTrak: this.includeTrak,
				includeJquery1: this.includeJquery1,
				includeJquery2: this.includeJquery2,
				statix: this.includeStatix,
				shims: this.includeShims
			}
		);

		this.directory('assets/src/js/modules', 'assets/src/js/modules');

	} else {
		this.fs.copyTpl(
			this.templatePath('assets/src/js/_script-fileArray.js'),
			this.destinationPath('assets/src/js/script.js'),
			{
				projectName: this.projectName,
				devNames: this.devNames,
				includeJquery1: this.includeJquery1,
				includeJquery2: this.includeJquery2,
				jsNamespace: this.jsNamespace
			}
		);
	}

	if (this.modernizr) {
		this.copy('assets/src/js/standalone/modernizr.js', 'assets/src/js/standalone/modernizr.js');
	}

	if (this.shims) {
		this.copy('assets/src/js/standalone/shims.js', 'assets/src/js/standalone/shims.js');
	}

	// Grunt configs
	this.fs.copyTpl(
		this.templatePath('_Gruntfile.js'),
		this.destinationPath('Gruntfile.js'),
		{
			browserify: this.browserify,
			grunticon: this.includeGrunticon,
			modernizr: this.includeModernizr,
			statix: this.includeStatix,
			shims: this.includeShims,
			styleguide: this.includeStyleguide
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_config.js'),
		this.destinationPath('_grunt-configs/config.js'),
		{
			projectName: this.projectName,
			projectNameSlugified: _s.slugify(this.projectName),
			browserify: this.browserify,
			includeSwiftclick: this.includeSwiftclick,
			includeTrak: this.includeTrak,
			includeJquery1: this.includeJquery1,
			includeJquery2: this.includeJquery2,
			statix: this.includeStatix
		}
	);

	this.copy('_grunt-configs/css.js', '_grunt-configs/css.js');

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_images.js'),
		this.destinationPath('_grunt-configs/images.js'),
		{
			grunticon: this.includeGrunticon
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_javascript.js'),
		this.destinationPath('_grunt-configs/javascript.js'),
		{
			browserify: this.browserify,
			includeJquery1: this.includeJquery1,
			includeJquery2: this.includeJquery2,
			includeShims: this.includeShims
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_server.js'),
		this.destinationPath('_grunt-configs/server.js'),
		{
			statix: this.includeStatix,
			styleguide: this.includeStyleguide
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_utilities.js'),
		this.destinationPath('_grunt-configs/utilities.js'),
		{
			browserify: this.browserify,
			statix: this.includeStatix,
			styleguide: this.includeStyleguide,
			shims: this.includeShims,
			modernizr: this.includeModernizr
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_watch.js'),
		this.destinationPath('_grunt-configs/watch.js'),
		{
			browserify: this.browserify,
			statix: this.includeStatix,
			grunticon: this.includeGrunticon
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_tests.js'),
		this.destinationPath('_grunt-configs/tests.js'),
		{}
	);
	this.copy('_grunt-configs/grunticon-tpl.hbs', '_grunt-configs/grunticon-tpl.hbs');

	this.fs.copyTpl(
		this.templatePath('_package.json'),
		this.destinationPath('package.json'),
		{
			projectName: this.projectName,
			projectNameSlugified: _s.slugify(this.projectName),
			projectDescription: this.projectDescription,
			devNames: this.devNames,
			browserify: this.browserify,
			includeSwiftclick: this.includeSwiftclick,
			includeTrak: this.includeTrak,
			includeJquery1: this.includeJquery1,
			includeJquery2: this.includeJquery2,
			statix: this.includeStatix
		}
	);

	this.fs.copyTpl(
		this.templatePath('_readme.md'),
		this.destinationPath('readme.md'),
		{
			projectName: this.projectName,
			projectDescription: this.projectDescription,
			devNames: this.devNames
		}
	);

	this.fs.copyTpl(
		this.templatePath('_humans.txt'),
		this.destinationPath('humans.txt'),
		{
			projectName: this.projectName,
			projectDescription: this.projectDescription,
			devNames: this.devNames
		}
	);

	this.fs.copyTpl(
		this.templatePath('_jshintrc'),
		this.destinationPath('.jshintrc'),
		{
			includeJquery1: this.includeJquery1,
			includeJquery2: this.includeJquery2
		}
	);

	this.copy('editorconfig', '.editorconfig');
	this.copy('gitignore', '.gitignore');
	this.copy('gitattributes', '.gitattributes');
	this.copy('scss-lint.yml', '.scss-lint.yml');

	if (this.includeStatix) {
		this.directory('statix/dist', 'statix/dist');

		this.directory('statix/src/data', 'statix/src/data');
		this.directory('statix/src/helpers', 'statix/src/helpers');

		if (this.includeStyleguide) {
			this.directory('statix/src/templates/layouts', 'statix/src/templates/layouts');
			this.directory('statix/src/templates/views', 'statix/src/templates/views');
		} else {
			this.copy('statix/src/templates/views/index.hbs', 'statix/src/templates/views/index.hbs');
			this.copy('statix/src/templates/layouts/default.hbs', 'statix/src/templates/layouts/default.hbs');
		}

		this.directory('statix/src/templates/partials', 'statix/src/templates/partials');

		this.fs.copyTpl(
			this.templatePath('statix/src/templates/_html_start.hbs'),
			this.destinationPath('statix/src/templates/partials/html_start.hbs'),
			{
				projectName: this.projectName,
				projectNameSlugified: _s.slugify(this.projectName),
				projectDescription: this.projectDescription,
				oldIE: this.oldIE,
				grunticon: this.includeGrunticon,
				modernizr: this.includeModernizr
			}
		);
	}
};

KickoffGenerator.prototype.install = function packageFiles() {
	opn('http://trykickoff.com/learn/checklist.html');
	this.installDependencies();
};
<commit_msg>change statix question<commit_after>'use strict';
var util            = require('util');
var yeoman          = require('yeoman-generator');
var chalk           = require('chalk');
var updateNotifier  = require('update-notifier');
var pkg             = require('../../package.json');
var opn             = require('opn');
var _s              = require('underscore.string');

var KickoffGenerator = module.exports = function KickoffGenerator(args, options) {
	yeoman.Base.apply(this, arguments);
};

util.inherits(KickoffGenerator, yeoman.generators.Base);

KickoffGenerator.prototype.askFor = function () {
	var done = this.async();

	// Checks for available update and returns an instance
	var notifier = updateNotifier({
		packageName: pkg.name,
		packageVersion: pkg.version,
		updateCheckInterval: 1000 * 60 // Every hour
	});

	var kickoffWelcome = chalk.white('\n ##  ## ######  ####  ##  ##  ') + chalk.yellow('####  ###### ######') + chalk.white('\n ## ##    ##   ##  ## ## ##  ') + chalk.yellow('##  ## ##     ##') + chalk.white('\n ####     ##   ##     ####   ') + chalk.yellow('##  ## ####   ####') + chalk.white('\n ## ##    ##   ##  ## ## ##  ') + chalk.yellow('##  ## ##     ##') + chalk.white('\n ##  ## ######  ####  ##  ##  ') + chalk.yellow('####  ##     ##') + '\n\n ' + chalk.white.bold('A Yeoman generator for the Kickoff front-end framework') + '\n\n Find out more at ' + chalk.cyan('trykickoff.com') + '\n Yeoman Generator version:  ' + pkg.version + '\n\n Kickoff is free and open-source and maintained by ' + chalk.yellow('@MrMartineau') + ',\n ' + chalk.green('@AshNolan_') + ', ' + chalk.red('@nicbell') + ' & the ' + chalk.blue('@tmwTechTeam') + '. \n';

	// Have Yeoman greet the user.
	this.log(kickoffWelcome);

	if (notifier.update) {
		// Check for npm package update and print message if needed
		var updateMessage = chalk.yellow('   ┌────────────────────────────────────────────────┐\n   │') + ' Update available: '  + chalk.green(notifier.update.latest) + chalk.gray(' (current: ' + pkg.version + ')') + '       '+ chalk.yellow('│\n   │') + ' Run ' + chalk.cyan('npm update -g ' + pkg.name) + ' to update. ' + chalk.yellow('│\n   └────────────────────────────────────────────────┘\n');

		this.log(updateMessage);
	}

	var prompts = [
		{
			name: 'projectName',
			message: 'Project name',
			default: 'Your project name'
		},
		{
			name: 'projectDescription',
			message: 'Description',
			default: 'Project description'
		},
		{
			name: 'devNames',
			message: 'Developer\'s names?',
			default: 'Tom, Dick and Harry'
		},
		{
			name: 'features',
			type: 'checkbox',
			message: 'Which features would you like?',
			choices: [
				{
					name: 'Does this project support IE8?',
					value: 'oldIE',
					default: false,
				},
				{
					name: 'Include Kickoff\'s styleguide?',
					value: 'styleguide'
				},
				{
					name: 'Use Kickoff Statix for static templating and rapid prototyping?',
					value: 'statix'
				},
				{
					name: 'Use Grunticon?',
					value: 'grunticon'
				}
			],
			store: true
		},
		{
			name: 'browserify',
			type: 'confirm',
			message: 'Use Browserify to bundle your Javascript?',
			default: true,
			store: true
		},
		{
			name: 'jsNamespace',
			message: 'Choose your javascript namespace',
			default: 'KO',
			store: true,
			when: function(response) {
				return !response.browserify;
			}
		},
		{
			name: 'jsLibs',
			type: 'checkbox',
			message: 'Which Javascript libraries would you like to use?',
			choices: [
				{
					name: 'jQuery 1.x - only choose one jQuery version',
					value: 'jquery1'
				},
				{
					name: 'jQuery 2.x - only choose one jQuery version',
					value: 'jquery2'
				},
				{
					name: 'trak.js - Universal event tracking API',
					value: 'trak'
				},
				{
					name: 'Swiftclick - Eliminates the 300ms click event delay on touch devices',
					value: 'swiftclick'
				},
				{
					name: 'Include some Javascript polyfills/shims? (These are generated by the \'grunt shimly\' command)',
					value: 'shims'
				},
				{
					name: 'Use Modernizr?',
					value: 'modernizr'
				}
			],
			store: true
		}
	];

	this.prompt(prompts, function (answers) {
		for (var key in answers) {
			this[key] = answers[key];
		}

		var jsLibs = answers.jsLibs;
		var features = answers.features;

		function hasFeature(feat, prop) {
			return prop && prop.indexOf(feat) !== -1;
		}

		// JS Libs
		this.includeTrak       = hasFeature('trak', jsLibs);
		this.includeJquery1    = hasFeature('jquery1', jsLibs);
		this.includeJquery2    = hasFeature('jquery2', jsLibs);
		this.includeSwiftclick = hasFeature('swiftclick', jsLibs);
		this.includeShims      = hasFeature('shims', jsLibs);
		this.includeModernizr  = hasFeature('modernizr', jsLibs);

		// Features
		this.includeGrunticon  = hasFeature('grunticon', features);
		this.includeStatix     = hasFeature('statix', features);
		this.includeStyleguide = hasFeature('styleguide', features);
		this.oldIE = hasFeature('oldIE', features);

		done();
	}.bind(this));
};

/**
 * Info
 * http://yeoman.io/generator/actions_actions.html
 * http://yeoman.io/authoring/file-system.html
 */
KickoffGenerator.prototype.packageFiles = function packageFiles() {

	this.fs.copyTpl(
		this.templatePath('_index.html'),
		this.destinationPath('index.html'),
		{
			projectName: this.projectName,
			projectNameSlugified: _s.slugify(this.projectName),
			oldIE: this.oldIE,
			grunticon: this.includeGrunticon,
			modernizr: this.includeModernizr,
			shims: this.includeShims
		}
	);

	if (this.includeStyleguide && !this.includeStatix) {
		this.fs.copyTpl(
			this.templatePath('styleguide/_index.html'),
			this.destinationPath('styleguide/index.html'),
			{
				projectName: this.projectName,
				projectNameSlugified: _s.slugify(this.projectName),
				oldIE: this.oldIE,
				grunticon: this.includeGrunticon,
				modernizr: this.includeModernizr,
				shims: this.includeShims
			}
		);
	}

	// CSS, SCSS, images & grunticon source directory
	this.directory('assets/dist/css', 'assets/dist/css');
	this.directory('assets/src/scss', 'assets/src/scss');
	this.directory('assets/src/img', 'assets/src/img');
	this.directory('assets/src/grunticon', 'assets/src/grunticon');

	// Javascript
	if (this.browserify) {
		this.fs.copyTpl(
			this.templatePath('assets/src/js/_script-browserify.js'),
			this.destinationPath('assets/src/js/script.js'),
			{
				projectName: this.projectName,
				devNames: this.devNames,
				browserify: this.browserify,
				includeSwiftclick: this.includeSwiftclick,
				includeTrak: this.includeTrak,
				includeJquery1: this.includeJquery1,
				includeJquery2: this.includeJquery2,
				statix: this.includeStatix,
				shims: this.includeShims
			}
		);

		this.directory('assets/src/js/modules', 'assets/src/js/modules');

	} else {
		this.fs.copyTpl(
			this.templatePath('assets/src/js/_script-fileArray.js'),
			this.destinationPath('assets/src/js/script.js'),
			{
				projectName: this.projectName,
				devNames: this.devNames,
				includeJquery1: this.includeJquery1,
				includeJquery2: this.includeJquery2,
				jsNamespace: this.jsNamespace
			}
		);
	}

	if (this.modernizr) {
		this.copy('assets/src/js/standalone/modernizr.js', 'assets/src/js/standalone/modernizr.js');
	}

	if (this.shims) {
		this.copy('assets/src/js/standalone/shims.js', 'assets/src/js/standalone/shims.js');
	}

	// Grunt configs
	this.fs.copyTpl(
		this.templatePath('_Gruntfile.js'),
		this.destinationPath('Gruntfile.js'),
		{
			browserify: this.browserify,
			grunticon: this.includeGrunticon,
			modernizr: this.includeModernizr,
			statix: this.includeStatix,
			shims: this.includeShims,
			styleguide: this.includeStyleguide
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_config.js'),
		this.destinationPath('_grunt-configs/config.js'),
		{
			projectName: this.projectName,
			projectNameSlugified: _s.slugify(this.projectName),
			browserify: this.browserify,
			includeSwiftclick: this.includeSwiftclick,
			includeTrak: this.includeTrak,
			includeJquery1: this.includeJquery1,
			includeJquery2: this.includeJquery2,
			statix: this.includeStatix
		}
	);

	this.copy('_grunt-configs/css.js', '_grunt-configs/css.js');

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_images.js'),
		this.destinationPath('_grunt-configs/images.js'),
		{
			grunticon: this.includeGrunticon
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_javascript.js'),
		this.destinationPath('_grunt-configs/javascript.js'),
		{
			browserify: this.browserify,
			includeJquery1: this.includeJquery1,
			includeJquery2: this.includeJquery2,
			includeShims: this.includeShims
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_server.js'),
		this.destinationPath('_grunt-configs/server.js'),
		{
			statix: this.includeStatix,
			styleguide: this.includeStyleguide
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_utilities.js'),
		this.destinationPath('_grunt-configs/utilities.js'),
		{
			browserify: this.browserify,
			statix: this.includeStatix,
			styleguide: this.includeStyleguide,
			shims: this.includeShims,
			modernizr: this.includeModernizr
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_watch.js'),
		this.destinationPath('_grunt-configs/watch.js'),
		{
			browserify: this.browserify,
			statix: this.includeStatix,
			grunticon: this.includeGrunticon
		}
	);

	this.fs.copyTpl(
		this.templatePath('_grunt-configs/_tests.js'),
		this.destinationPath('_grunt-configs/tests.js'),
		{}
	);
	this.copy('_grunt-configs/grunticon-tpl.hbs', '_grunt-configs/grunticon-tpl.hbs');

	this.fs.copyTpl(
		this.templatePath('_package.json'),
		this.destinationPath('package.json'),
		{
			projectName: this.projectName,
			projectNameSlugified: _s.slugify(this.projectName),
			projectDescription: this.projectDescription,
			devNames: this.devNames,
			browserify: this.browserify,
			includeSwiftclick: this.includeSwiftclick,
			includeTrak: this.includeTrak,
			includeJquery1: this.includeJquery1,
			includeJquery2: this.includeJquery2,
			statix: this.includeStatix
		}
	);

	this.fs.copyTpl(
		this.templatePath('_readme.md'),
		this.destinationPath('readme.md'),
		{
			projectName: this.projectName,
			projectDescription: this.projectDescription,
			devNames: this.devNames
		}
	);

	this.fs.copyTpl(
		this.templatePath('_humans.txt'),
		this.destinationPath('humans.txt'),
		{
			projectName: this.projectName,
			projectDescription: this.projectDescription,
			devNames: this.devNames
		}
	);

	this.fs.copyTpl(
		this.templatePath('_jshintrc'),
		this.destinationPath('.jshintrc'),
		{
			includeJquery1: this.includeJquery1,
			includeJquery2: this.includeJquery2
		}
	);

	this.copy('editorconfig', '.editorconfig');
	this.copy('gitignore', '.gitignore');
	this.copy('gitattributes', '.gitattributes');
	this.copy('scss-lint.yml', '.scss-lint.yml');

	if (this.includeStatix) {
		this.directory('statix/dist', 'statix/dist');

		this.directory('statix/src/data', 'statix/src/data');
		this.directory('statix/src/helpers', 'statix/src/helpers');

		if (this.includeStyleguide) {
			this.directory('statix/src/templates/layouts', 'statix/src/templates/layouts');
			this.directory('statix/src/templates/views', 'statix/src/templates/views');
		} else {
			this.copy('statix/src/templates/views/index.hbs', 'statix/src/templates/views/index.hbs');
			this.copy('statix/src/templates/layouts/default.hbs', 'statix/src/templates/layouts/default.hbs');
		}

		this.directory('statix/src/templates/partials', 'statix/src/templates/partials');

		this.fs.copyTpl(
			this.templatePath('statix/src/templates/_html_start.hbs'),
			this.destinationPath('statix/src/templates/partials/html_start.hbs'),
			{
				projectName: this.projectName,
				projectNameSlugified: _s.slugify(this.projectName),
				projectDescription: this.projectDescription,
				oldIE: this.oldIE,
				grunticon: this.includeGrunticon,
				modernizr: this.includeModernizr
			}
		);
	}
};

KickoffGenerator.prototype.install = function packageFiles() {
	opn('http://trykickoff.com/learn/checklist.html');
	this.installDependencies();
};
<|endoftext|>