<commit_before>import express from 'express';
import http from 'http';
import swaggerTools from 'swagger-tools';
import chalk from 'chalk';
import config from './config';
const app = express();
// Swagger
let swaggerConfig = require('./core/swagger/config').default(app);
// Init
swaggerTools.initializeMiddleware(swaggerConfig, (middleware) => {
  // Core
  require('./core/engine').default(app);
  // Routers Express
  require('./core/router').default(app);
  // Mongo
  require('./core/mongoose');
  // Swagger
  require('./core/swagger').default(app, swaggerConfig, middleware);
  // Paths
  require('./core/path').default(app);
  // Create HTTP server.
  const server = http.createServer(app);
  // Listen Server
  server.listen(config.server.port, config.server.ip, () => {
    process.env.NODE_ENV = config.mode;
    console.log(chalk.greenBright(`\n\n-------\nServer-> listening on http://${config.server.ip}:${config.server.port} in mode [${config.mode}]\n-------`));
  });
});
<commit_msg>added Redis<commit_after>import express from 'express';
import http from 'http';
import swaggerTools from 'swagger-tools';
import chalk from 'chalk';
import config from './config';
const app = express();
// Swagger
let swaggerConfig = require('./core/swagger/config').default(app);
// Init
swaggerTools.initializeMiddleware(swaggerConfig, (middleware) => {
  // Core
  require('./core/engine').default(app);
  // Routers Express
  require('./core/router').default(app);
  // Mongo
  require('./core/mongoose');
  // Redis
  require('./lib/redis');
  // Swagger
  require('./core/swagger').default(app, swaggerConfig, middleware);
  // Paths
  require('./core/path').default(app);
  // Create HTTP server.
  const server = http.createServer(app);
  // Listen Server
  server.listen(config.server.port, config.server.ip, () => {
    process.env.NODE_ENV = config.mode;
    console.log(chalk.greenBright(`\n\n-------\nServer-> listening on http://${config.server.ip}:${config.server.port} in mode [${config.mode}]\n-------`));
  });
});
<|endoftext|>


<commit_before>'use strict'

var gulp = require('gulp')
var livereload = require('gulp-livereload')

var paths = {
  styles: 'src/css/**/*'
}

gulp.task('css', function () {
  var postcss = require('gulp-postcss')
  var cssnext = require('cssnext')
  var nested = require('postcss-nested')
  var simplevars = require('postcss-simple-vars')
  var sourcemaps = require('gulp-sourcemaps')
  var reporter = require('postcss-reporter')

  var options = {
    browsers: ['last 2 versions', 'IE >= 11'],
    compress: {
      comments: { removeAll: true },
      zindex: false
    },
    url: false, // TODO: Figure this out
    plugins: [
      nested,
      simplevars
    ]
  }

  var plugins = [
    cssnext(options),
    reporter()
  ]

  return gulp.src('./src/css/main.css')
    .pipe(sourcemaps.init())
    .pipe(postcss(plugins))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./css'))
    .pipe(livereload())
})

// Rerun the task when a file changes
gulp.task('watch', function () {
  livereload.listen()
  gulp.watch(paths.styles, ['css'])
})
<commit_msg>Make gulpfile pass jshint<commit_after>'use strict';

var gulp = require('gulp');
var livereload = require('gulp-livereload');

var paths = {
    styles: 'src/css/**/*'
};

gulp.task('css', function () {
    var postcss = require('gulp-postcss');
    var cssnext = require('cssnext');
    var nested = require('postcss-nested');
    var simplevars = require('postcss-simple-vars');
    var sourcemaps = require('gulp-sourcemaps');
    var reporter = require('postcss-reporter');

    var options = {
        browsers: ['last 2 versions', 'IE >= 11'],
        compress: {
            comments: { removeAll: true },
            zindex: false
        },
        url: false, // TODO: Figure this out
        plugins: [
            nested,
            simplevars
        ]
    };

    var plugins = [
        cssnext(options),
        reporter()
    ];

    return gulp.src('./src/css/main.css')
        .pipe(sourcemaps.init())
        .pipe(postcss(plugins))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest('./css'))
        .pipe(livereload());
});

// Rerun the task when a file changes
gulp.task('watch', function () {
    livereload.listen();
    gulp.watch(paths.styles, ['css']);
});
<|endoftext|>


<commit_before>/*!
 * SUI Mobile
 */

/* jshint node: true */
module.exports = function (grunt) {
  'use strict';

  // Force use of Unix newlines
  grunt.util.linefeed = '\n';

  RegExp.quote = function (string) {
    return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
  };

  var generateRatchiconsData = require('./grunt/ratchicons-data-generator.js');

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

    // Metadata.
    meta: {
      distPath:       'dist/',
      doclessetsPath: 'docs/assets/',
      docsDistPath:   'docs/dist/',
      docsPath:       'docs/',
      jsPath:         'js/',
      srcPath:        'less/'
    },

    banner: '/*!\n' +
            ' * =====================================================\n' +
            ' * SUI Mobile v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
            ' *\n' +
            ' * =====================================================\n' +
            ' */\n',

    clean: {
      dist: ['<%= meta.distPath %>', '<%= meta.docsDistPath %>']
    },

    concat: {
      sm: {
        options: {
          banner: '<%= banner %>'
        },
        src: [
          'js/common.js',
          'js/modals.js',
          'js/popovers.js',
          'js/push.js',
          'js/segmented-controllers.js',
          'js/sliders.js',
          'js/toggles.js'
        ],
        dest: '<%= meta.distPath %>js/<%= pkg.name %>.js'
      }
    },

    less: {
      core: {
        src: 'less/sm.less',
        dest: '<%= meta.distPath %>css/<%= pkg.name %>.css'
      },
      docs: {
        src: 'less/docs.less',
        dest: '<%= meta.doclessetsPath %>css/docs.css'
      }
    },

    usebanner: {
      dist: {
        options: {
          position: 'top',
          banner: '<%= banner %>'
        },
        files: {
          src: [
            '<%= meta.distPath %>css/*.css',
            '<%= meta.doclessetsPath %>css/docs.css'
          ]
        }
      }
    },

    csscomb: {
      options: {
        config: 'less/.csscomb.json'
      },
      core: {
        files: {
          '<%= less.core.dest %>': '<%= less.core.dest %>'
        }
      },
      docs: {
        files: {
          '<%= less.docs.dest %>': '<%= less.docs.dest %>'
        }
      }
    },

    copy: {
      fonts: {
        expand: true,
        src: 'fonts/*',
        dest: '<%= meta.distPath %>'
      },
      img: {
        expand: true,
        src: 'img/*',
        dest: '<%= meta.distPath %>'
      },
      docs: {
        expand: true,
        cwd: '<%= meta.distPath %>',
        src: [
          '**/*'
        ],
        dest: '<%= meta.docsDistPath %>'
      }
    },

    autoprefixer: {
      options: {
        browsers: [
          'Android 2.3',
          'Android >= 4',
          'Chrome >= 20',
          'Firefox >= 24', // Firefox 24 is the latest ESR
          'Explorer >= 9',
          'iOS >= 6',
          'Opera >= 12',
          'Safari >= 6'
        ]
      },
      core: {
        src: '<%= less.core.dest %>'
      },
      docs: {
        src: '<%= less.docs.dest %>'
      }
    },

    cssmin: {
      options: {
        keepSpecialComments: '*' // keep all important comments
      },
      sm: {
        src: '<%= meta.distPath %>css/<%= pkg.name %>.css',
        dest: '<%= meta.distPath %>css/<%= pkg.name %>.min.css'
      },
      docs: {
        src: [
          '<%= meta.doclessetsPath %>css/docs.css',
          '<%= meta.doclessetsPath %>css/pygments-manni.css'
        ],
        dest: '<%= meta.doclessetsPath %>css/docs.min.css'
      }
    },

    uglify: {
      options: {
        banner: '<%= banner %>',
        compress: {
          warnings: false
        },
        mangle: true,
        preserveComments: false
      },
      sm: {
        src: '<%= concat.sm.dest %>',
        dest: '<%= meta.distPath %>js/<%= pkg.name %>.min.js'
      },
      docs: {
        src: [
          '<%= meta.doclessetsPath %>js/docs.js',
          '<%= meta.doclessetsPath %>js/fingerblast.js'
        ],
        dest: '<%= meta.doclessetsPath %>js/docs.min.js'
      }
    },

    watch: {
      options: {
        hostname: 'localhost',
        livereload: true,
        port: 8000
      },
      js: {
        files: '<%= meta.jsPath %>**/*.js',
        tasks: ['dist-js', 'copy']
      },
      css: {
        files: '<%= meta.srcPath %>**/*.less',
        tasks: ['dist-css', 'copy']
      },
      html: {
        files: '<%= meta.docsPath %>**',
        tasks: ['jekyll']
      }
    },

    jekyll: {
      docs: {}
    },

    jshint: {
      options: {
        jshintrc: 'js/.jshintrc'
      },
      grunt: {
        src: ['Gruntfile.js', 'grunt/*.js']
      },
      src: {
        src: 'js/*.js'
      },
      docs: {
        src: ['<%= meta.doclessetsPath %>/js/docs.js', '<%= meta.doclessetsPath %>/js/fingerblast.js']
      }
    },

    jscs: {
      options: {
        config: 'js/.jscsrc'
      },
      grunt: {
        src: '<%= jshint.grunt.src %>'
      },
      src: {
        src: '<%= jshint.src.src %>'
      },
      docs: {
        src: '<%= jshint.docs.src %>'
      }
    },

    csslint: {
      options: {
        csslintrc: 'less/.csslintrc'
      },
      src: [
        '<%= meta.distPath %>/css/<%= pkg.name %>.css'
      ],
      docs: {
        options: {
          ids: false
        },
        src: ['<%= meta.doclessetsPath %>/css/docs.css']
      }
    },

    sed: {
      versionNumber: {
        pattern: (function () {
          var old = grunt.option('oldver');
          return old ? RegExp.quote(old) : old;
        })(),
        replacement: grunt.option('newver'),
        recursive: true
      }
    },

    connect: {
      site: {
        options: {
          base: '_site/',
          hostname: 'localhost',
          livereload: true,
          open: true,
          port: 8000
        }
      }
    }
  });

  // Load the plugins
  require('load-grunt-tasks')(grunt);
  require('time-grunt')(grunt);

  // Default task(s).
  grunt.registerTask('dist-css', ['less', 'autoprefixer', 'usebanner', 'csscomb', 'cssmin']);
  grunt.registerTask('dist-js', ['concat', 'uglify']);
  grunt.registerTask('dist', ['clean', 'dist-css', 'dist-js', 'copy', 'build-ratchicons-data']);
  grunt.registerTask('validate-html', ['jekyll']);
  grunt.registerTask('build', ['dist']);
  grunt.registerTask('default', ['dist']);
  grunt.registerTask('test', ['dist', 'csslint', 'jshint', 'jscs', 'validate-html']);
  grunt.registerTask('server', ['dist', 'jekyll', 'connect', 'watch']);

  grunt.registerTask('build-ratchicons-data', generateRatchiconsData);

  // Version numbering task.
  // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
  // This can be overzealous, so its changes should always be manually reviewed!
  grunt.registerTask('change-version-number', 'sed');
};
<commit_msg>update<commit_after>/*!
 * SUI Mobile
 */

/* jshint node: true */
module.exports = function (grunt) {
  'use strict';

  // Force use of Unix newlines
  grunt.util.linefeed = '\n';

  RegExp.quote = function (string) {
    return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
  };

  var generateRatchiconsData = require('./grunt/ratchicons-data-generator.js');

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

    // Metadata.
    meta: {
      distPath:       grunt.option('target') || 'dist/',
      doclessetsPath: 'docs/assets/',
      docsDistPath:   'docs/dist/',
      docsPath:       'docs/',
      jsPath:         'js/',
      srcPath:        'less/'
    },

    banner: '/*!\n' +
            ' * =====================================================\n' +
            ' * SUI Mobile v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
            ' *\n' +
            ' * =====================================================\n' +
            ' */\n',

    clean: {
      dist: ['<%= meta.distPath %>', '<%= meta.docsDistPath %>']
    },

    concat: {
      sm: {
        options: {
          banner: '<%= banner %>'
        },
        src: [
          'js/common.js',
          'js/modals.js',
          'js/popovers.js',
          'js/push.js',
          'js/segmented-controllers.js',
          'js/sliders.js',
          'js/toggles.js'
        ],
        dest: '<%= meta.distPath %>js/<%= pkg.name %>.js'
      }
    },

    less: {
      core: {
        src: 'less/sm.less',
        dest: '<%= meta.distPath %>css/<%= pkg.name %>.css'
      },
      docs: {
        src: 'less/docs.less',
        dest: '<%= meta.doclessetsPath %>css/docs.css'
      }
    },

    usebanner: {
      dist: {
        options: {
          position: 'top',
          banner: '<%= banner %>'
        },
        files: {
          src: [
            '<%= meta.distPath %>css/*.css',
            '<%= meta.doclessetsPath %>css/docs.css'
          ]
        }
      }
    },

    csscomb: {
      options: {
        config: 'less/.csscomb.json'
      },
      core: {
        files: {
          '<%= less.core.dest %>': '<%= less.core.dest %>'
        }
      },
      docs: {
        files: {
          '<%= less.docs.dest %>': '<%= less.docs.dest %>'
        }
      }
    },

    copy: {
      fonts: {
        expand: true,
        src: 'fonts/*',
        dest: '<%= meta.distPath %>'
      },
      img: {
        expand: true,
        src: 'img/*',
        dest: '<%= meta.distPath %>'
      },
      docs: {
        expand: true,
        cwd: '<%= meta.distPath %>',
        src: [
          '**/*'
        ],
        dest: '<%= meta.docsDistPath %>'
      }
    },

    autoprefixer: {
      options: {
        browsers: [
          'Android 2.3',
          'Android >= 4',
          'Chrome >= 20',
          'Firefox >= 24', // Firefox 24 is the latest ESR
          'Explorer >= 9',
          'iOS >= 6',
          'Opera >= 12',
          'Safari >= 6'
        ]
      },
      core: {
        src: '<%= less.core.dest %>'
      },
      docs: {
        src: '<%= less.docs.dest %>'
      }
    },

    cssmin: {
      options: {
        keepSpecialComments: '*' // keep all important comments
      },
      sm: {
        src: '<%= meta.distPath %>css/<%= pkg.name %>.css',
        dest: '<%= meta.distPath %>css/<%= pkg.name %>.min.css'
      },
      docs: {
        src: [
          '<%= meta.doclessetsPath %>css/docs.css',
          '<%= meta.doclessetsPath %>css/pygments-manni.css'
        ],
        dest: '<%= meta.doclessetsPath %>css/docs.min.css'
      }
    },

    uglify: {
      options: {
        banner: '<%= banner %>',
        compress: {
          warnings: false
        },
        mangle: true,
        preserveComments: false
      },
      sm: {
        src: '<%= concat.sm.dest %>',
        dest: '<%= meta.distPath %>js/<%= pkg.name %>.min.js'
      },
      docs: {
        src: [
          '<%= meta.doclessetsPath %>js/docs.js',
          '<%= meta.doclessetsPath %>js/fingerblast.js'
        ],
        dest: '<%= meta.doclessetsPath %>js/docs.min.js'
      }
    },

    watch: {
      options: {
        hostname: 'localhost',
        livereload: true,
        port: 8000
      },
      js: {
        files: '<%= meta.jsPath %>**/*.js',
        tasks: ['dist-js', 'copy']
      },
      css: {
        files: '<%= meta.srcPath %>**/*.less',
        tasks: ['dist-css', 'copy']
      },
      html: {
        files: '<%= meta.docsPath %>**',
        tasks: ['jekyll']
      }
    },

    jekyll: {
      docs: {}
    },

    jshint: {
      options: {
        jshintrc: 'js/.jshintrc'
      },
      grunt: {
        src: ['Gruntfile.js', 'grunt/*.js']
      },
      src: {
        src: 'js/*.js'
      },
      docs: {
        src: ['<%= meta.doclessetsPath %>/js/docs.js', '<%= meta.doclessetsPath %>/js/fingerblast.js']
      }
    },

    jscs: {
      options: {
        config: 'js/.jscsrc'
      },
      grunt: {
        src: '<%= jshint.grunt.src %>'
      },
      src: {
        src: '<%= jshint.src.src %>'
      },
      docs: {
        src: '<%= jshint.docs.src %>'
      }
    },

    csslint: {
      options: {
        csslintrc: 'less/.csslintrc'
      },
      src: [
        '<%= meta.distPath %>/css/<%= pkg.name %>.css'
      ],
      docs: {
        options: {
          ids: false
        },
        src: ['<%= meta.doclessetsPath %>/css/docs.css']
      }
    },

    sed: {
      versionNumber: {
        pattern: (function () {
          var old = grunt.option('oldver');
          return old ? RegExp.quote(old) : old;
        })(),
        replacement: grunt.option('newver'),
        recursive: true
      }
    },

    connect: {
      site: {
        options: {
          base: '_site/',
          hostname: 'localhost',
          livereload: true,
          open: true,
          port: 8000
        }
      }
    }
  });

  // Load the plugins
  require('load-grunt-tasks')(grunt);
  require('time-grunt')(grunt);

  // Default task(s).
  grunt.registerTask('dist-css', ['less', 'autoprefixer', 'usebanner', 'csscomb', 'cssmin']);
  grunt.registerTask('dist-js', ['concat', 'uglify']);
  grunt.registerTask('dist', ['clean', 'dist-css', 'dist-js', 'copy', 'build-ratchicons-data']);
  grunt.registerTask('validate-html', ['jekyll']);
  grunt.registerTask('build', ['dist']);
  grunt.registerTask('default', ['dist']);
  grunt.registerTask('test', ['dist', 'csslint', 'jshint', 'jscs', 'validate-html']);
  grunt.registerTask('server', ['dist', 'jekyll', 'connect', 'watch']);

  grunt.registerTask('build-ratchicons-data', generateRatchiconsData);

  // Version numbering task.
  // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
  // This can be overzealous, so its changes should always be manually reviewed!
  grunt.registerTask('change-version-number', 'sed');
};
<|endoftext|>


<commit_before>require('./shared/environment').applyEnvironment();

const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');

const db = require('./database');
db.connect();

const app = express();
console.log('Adding CORS access for:', process.env.ALLOW_ORIGIN);
app.use(cors({
  methods: 'GET,POST,PATCH,DELETE,OPTIONS',
  optionsSuccessStatus: 200,
  origin: process.env.ALLOW_ORIGIN
}));
app.set('port', process.env.PORT);
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

const passport = require('passport');
passport.use(require('./strategies/jwt'));
passport.use(require('./strategies/local'));
app.use(passport.initialize());

app.use('/v1', require('./routes'));

app.use(require('./middleware/404'));
app.use(require('./middleware/format-schema-validation-error'));
app.use(require('./middleware/format-schema-cast-error'));
app.use(require('./middleware/error-handler'));

module.exports = app;
<commit_msg>Trying a different approach to cors<commit_after>require('./shared/environment').applyEnvironment();

const express = require('express');
const bodyParser = require('body-parser');
// const cors = require('cors');

const db = require('./database');
db.connect();

const app = express();
app.all('*', (req, res, next) => {
  console.log('origin:', req.get('origin'));
  // const origin = req.get('origin');
  res.header('Access-Control-Allow-Origin', process.env.ALLOW_ORIGIN);
  res.header('Access-Control-Allow-Headers', 'X-Requested-With');
  res.header('Access-Control-Allow-Headers', 'Content-Type');
  next();
});
// console.log('Adding CORS access for:', process.env.ALLOW_ORIGIN);
// app.use(cors({
//   methods: 'GET,POST,PATCH,DELETE,OPTIONS',
//   optionsSuccessStatus: 200,
//   origin: process.env.ALLOW_ORIGIN
// }));
app.set('port', process.env.PORT);
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

const passport = require('passport');
passport.use(require('./strategies/jwt'));
passport.use(require('./strategies/local'));
app.use(passport.initialize());

app.use('/v1', require('./routes'));

app.use(require('./middleware/404'));
app.use(require('./middleware/format-schema-validation-error'));
app.use(require('./middleware/format-schema-cast-error'));
app.use(require('./middleware/error-handler'));

module.exports = app;
<|endoftext|>


<commit_before>module.exports = function (grunt) {
  grunt.initConfig({
    connect: {
      server: {
        options: {
          base: '.',
          hostname: '*',
          port: 9999
        }
      }
    },
    'saucelabs-mocha': {
      all: {
        options: {
          build: process.env.TRAVIS_JOB_ID,
          urls: ['http://localhost:9999/test/'],
          testname: 'Mocha Unit Test for with-promise',
          sauceConfig: {
              tags: [process.env.TRAVIS_JOB_ID, process.env.TRAVIS_COMMIT, 'withPromise', 'mocha'],
              public: 'public'
          },
          detailedError: true,
          concurrency: 2,
          maxPollRetries: 3,
          'max-duration': 180,
          browsers: [
            {browserName: 'chrome'},
            {browserName: 'firefox'},
            {browserName: 'safari', version: 7, platform: 'OS X 10.9'},
            {browserName: 'safari', version: 6, platform: 'OS X 10.8'},
            {browserName: 'internet explorer', version: 11, platform: 'Windows 8.1'},
            {browserName: 'internet explorer', version: 10, platform: 'Windows 8'},
            {browserName: 'internet explorer', version: 9, platform: 'Windows 7'},
            {browserName: 'Android', version:'4.4', platform: 'Linux'},
            {browserName: 'Android', version:'4.1', platform: 'Linux'},
            {browserName: 'Android', version:'4.0', platform: 'Linux'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'8.1'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'8.0'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'7.1'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'7.0'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'6.1'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'8.1'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'8.0'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'7.1'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'7.0'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'6.1'}
          ]
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-saucelabs');

  grunt.registerTask('default', ['connect:server', 'saucelabs-mocha']);
};
<commit_msg>longer timeout<commit_after>module.exports = function (grunt) {
  grunt.initConfig({
    connect: {
      server: {
        options: {
          base: '.',
          hostname: '*',
          port: 9999
        }
      }
    },
    'saucelabs-mocha': {
      all: {
        options: {
          build: process.env.TRAVIS_JOB_ID,
          urls: ['http://localhost:9999/test/'],
          testname: 'Mocha Unit Test for with-promise',
          sauceConfig: {
              tags: [process.env.TRAVIS_JOB_ID, process.env.TRAVIS_COMMIT, 'withPromise', 'mocha'],
              public: 'public'
          },
          detailedError: true,
          concurrency: 2,
          maxPollRetries: 3,
          'max-duration': 300,
          browsers: [
            {browserName: 'chrome'},
            {browserName: 'firefox'},
            {browserName: 'safari', version: 7, platform: 'OS X 10.9'},
            {browserName: 'safari', version: 6, platform: 'OS X 10.8'},
            {browserName: 'internet explorer', version: 11, platform: 'Windows 8.1'},
            {browserName: 'internet explorer', version: 10, platform: 'Windows 8'},
            {browserName: 'internet explorer', version: 9, platform: 'Windows 7'},
            {browserName: 'Android', version:'4.4', platform: 'Linux'},
            {browserName: 'Android', version:'4.1', platform: 'Linux'},
            {browserName: 'Android', version:'4.0', platform: 'Linux'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'8.1'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'8.0'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'7.1'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'7.0'},
            {browserName: 'iphone', deviceName: 'iPhone Simulator', version:'6.1'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'8.1'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'8.0'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'7.1'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'7.0'},
            {browserName: 'ipad', deviceName: 'iPad Simulator', version:'6.1'}
          ]
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-saucelabs');

  grunt.registerTask('default', ['connect:server', 'saucelabs-mocha']);
};
<|endoftext|>


<commit_before>/**
 * Created by nuintun on 2015/5/5.
 */

'use strict';

var path = require('path');
var gulp = require('gulp');
var rimraf = require('del');
var transport = require('gulp-cmd');
var uglify = require('gulp-uglify');
var css = require('gulp-minify-css');
var plumber = require('gulp-plumber');
var colors = transport.colors;

// alias
var alias = {
  'jquery': 'base/jquery/1.11.2/jquery',
  'base': 'base/base/1.2.0/base',
  'class': 'base/class/1.2.0/class',
  'events': 'base/events/1.2.0/events',
  'widget': 'base/widget/1.2.0/widget',
  'template': 'base/template/3.0.3/template',
  'templatable': 'base/templatable/0.10.0/templatable',
  'iframe-shim': 'util/iframe-shim/1.1.0/iframe-shim',
  'position': 'util/position/1.1.0/position',
  'messenger': 'util/messenger/2.1.0/messenger',
  'mask': 'common/overlay/1.2.0/mask',
  'overlay': 'common/overlay/1.2.0/overlay',
  'dialog': 'common/dialog/1.5.1/dialog',
  'confirmbox': 'common/dialog/1.5.1/confirmbox'
};

var startTime = Date.now();

// complete callback
function complete(){
  var now = new Date();

  console.log(
    '  %s [%s] build complete ... %s%s',
    colors.verbose('gulp-cmd'),
    now.toLocaleString(),
    colors.info(now - startTime),
    colors.verbose('ms')
  );
}

// clean task
gulp.task('clean', function (callback){
  rimraf('online', callback);
});

// runtime task
gulp.task('runtime', ['clean'], function (){
  gulp.src('assets/loader/**/*.js', { base: 'assets' })
    .pipe(uglify())
    .pipe(gulp.dest('online'));

  gulp.src('assets/?(loader|images)/**/*.!(js)', { base: 'assets' })
    .pipe(gulp.dest('online'));
});

// online task
gulp.task('online', ['runtime'], function (){
  // all js
  gulp.src('assets/js/**/*.js', { base: 'assets/js' })
    .pipe(transport({
      alias: alias,
      ignore: ['jquery'],
      include: function (id){
        return id.indexOf('view') === 0 ? 'all' : 'relative';
      },
      css: {
        onpath: function (path){
          return path.replace('assets/', 'online/')
        }
      }
    }))
    .pipe(uglify())
    .pipe(gulp.dest('online/js'))
    .on('end', complete);

  // other file
  gulp.src('assets/js/**/*.!(js|css|json|tpl|html)')
    .pipe(gulp.dest('online/js'));

  // css
  gulp.src('assets/css/**/*.*')
    .pipe(css({ compatibility: 'ie8' }))
    .pipe(gulp.dest('online/css'));
});

// develop task
gulp.task('default', ['runtime'], function (){
  // all file
  gulp.src('assets/js/**/*.*', { base: 'assets/js' })
    .pipe(transport({
      alias: alias,
      include: 'self',
      oncsspath: function (path){
        return path.replace('assets/', 'online/')
      }
    }))
    .pipe(gulp.dest('online/js'))
    .on('end', complete);

  gulp.src('assets/css/**/*.*', { base: 'assets' })
    .pipe(gulp.dest('online'));
});

// develop watch task
gulp.task('watch', ['default'], function (){
  var base = path.join(process.cwd(), 'assets');

  // watch all file
  gulp.watch('assets/js/**/*.*', function (e){
    if (e.type === 'deleted') {
      rimraf(path.resolve('online', path.relative(base, e.path)));
    } else {
      startTime = Date.now();

      gulp.src(e.path, { base: 'assets/js' })
        .pipe(plumber())
        .pipe(transport({
          alias: alias,
          include: 'self',
          cache: false,
          oncsspath: function (path){
            return path.replace('assets/', 'online/')
          }
        }))
        .pipe(gulp.dest('online/js'))
        .on('end', complete);
    }
  });

  // watch all file
  gulp.watch('assets/?(images|loader|css)/**/*.*', function (e){
    if (e.type === 'deleted') {
      rimraf(path.resolve('online', path.relative(base, e.path)));
    } else {
      startTime = Date.now();

      gulp.src(e.path, { base: 'assets' })
        .pipe(plumber())
        .pipe(gulp.dest('online'))
        .on('end', complete);
    }
  });
});
<commit_msg>add source<commit_after>/**
 * Created by nuintun on 2015/5/5.
 */

'use strict';

var path = require('path');
var gulp = require('gulp');
var rimraf = require('del');
var transport = require('gulp-cmd');
var uglify = require('gulp-uglify');
var css = require('gulp-minify-css');
var plumber = require('gulp-plumber');
var colors = transport.colors;

// alias
var alias = {
  'jquery': 'base/jquery/1.11.2/jquery',
  'base': 'base/base/1.2.0/base',
  'class': 'base/class/1.2.0/class',
  'events': 'base/events/1.2.0/events',
  'widget': 'base/widget/1.2.0/widget',
  'template': 'base/template/3.0.3/template',
  'templatable': 'base/templatable/0.10.0/templatable',
  'iframe-shim': 'util/iframe-shim/1.1.0/iframe-shim',
  'position': 'util/position/1.1.0/position',
  'messenger': 'util/messenger/2.1.0/messenger',
  'mask': 'common/overlay/1.2.0/mask',
  'overlay': 'common/overlay/1.2.0/overlay',
  'dialog': 'common/dialog/1.5.1/dialog',
  'confirmbox': 'common/dialog/1.5.1/confirmbox'
};

var startTime = Date.now();

// complete callback
function complete(){
  var now = new Date();

  console.log(
    '  %s [%s] build complete ... %s%s',
    colors.cyan.bold('gulp-cmd'),
    now.toLocaleString(),
    colors.green(now - startTime),
    colors.cyan('ms')
  );
}

// clean task
gulp.task('clean', function (callback){
  rimraf('online', callback);
});

// runtime task
gulp.task('runtime', ['clean'], function (){
  gulp.src('assets/loader/**/*.js', { base: 'assets' })
    .pipe(uglify())
    .pipe(gulp.dest('online'));

  gulp.src('assets/?(loader|images)/**/*.!(js)', { base: 'assets' })
    .pipe(gulp.dest('online'));
});

// online task
gulp.task('online', ['runtime'], function (){
  // all js
  gulp.src('assets/js/**/*.js', { base: 'assets/js' })
    .pipe(transport({
      alias: alias,
      ignore: ['jquery'],
      include: function (id){
        return id.indexOf('view') === 0 ? 'all' : 'relative';
      },
      css: {
        onpath: function (path){
          return path.replace('assets/', 'online/')
        }
      }
    }))
    .pipe(uglify())
    .pipe(gulp.dest('online/js'))
    .on('end', complete);

  // other file
  gulp.src('assets/js/**/*.!(js|css|json|tpl|html)')
    .pipe(gulp.dest('online/js'));

  // css
  gulp.src('assets/css/**/*.*')
    .pipe(css({ compatibility: 'ie8' }))
    .pipe(gulp.dest('online/css'));
});

// develop task
gulp.task('default', ['runtime'], function (){
  // all file
  gulp.src('assets/js/**/*.*', { base: 'assets/js' })
    .pipe(transport({
      alias: alias,
      include: 'self',
      oncsspath: function (path){
        return path.replace('assets/', 'online/')
      }
    }))
    .pipe(gulp.dest('online/js'))
    .on('end', complete);

  gulp.src('assets/css/**/*.*', { base: 'assets' })
    .pipe(gulp.dest('online'));
});

// develop watch task
gulp.task('watch', ['default'], function (){
  var base = path.join(process.cwd(), 'assets');

  // watch all file
  gulp.watch('assets/js/**/*.*', function (e){
    if (e.type === 'deleted') {
      rimraf(path.resolve('online', path.relative(base, e.path)));
    } else {
      startTime = Date.now();

      gulp.src(e.path, { base: 'assets/js' })
        .pipe(plumber())
        .pipe(transport({
          alias: alias,
          include: 'self',
          cache: false,
          oncsspath: function (path){
            return path.replace('assets/', 'online/')
          }
        }))
        .pipe(gulp.dest('online/js'))
        .on('end', complete);
    }
  });

  // watch all file
  gulp.watch('assets/?(images|loader|css)/**/*.*', function (e){
    if (e.type === 'deleted') {
      rimraf(path.resolve('online', path.relative(base, e.path)));
    } else {
      startTime = Date.now();

      gulp.src(e.path, { base: 'assets' })
        .pipe(plumber())
        .pipe(gulp.dest('online'))
        .on('end', complete);
    }
  });
});
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {

    var htmlminOptions = {
        collapseWhitespace: true,
        collapseBooleanAttributes: true,
        removeOptionalTags: true
    };

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

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

    grunt.initConfig({

        yeoman: {
            app: require('./bower.json').appPath || 'client/app',
            build: 'build'
        },

        watch: {
            less: {
                files: ['<%= yeoman.app %>/styles/less/**/*.less'],
                tasks: ['less']
            },
            express: {
                files: ['server/**/*.js'],
                tasks: ['express:dev'],
                options: {
                    spawn: false // Without this option specified express won't be reloaded
                }
            }
        },

        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            gruntfile: ['Gruntfile.js'],
            client: {
                options: {
                    jshintrc: 'client/.jshintrc'
                },
                src: ['<%= yeoman.app %>/scripts/**/*.js', 'client/test/**/*.js']
            },
            server: {
                options: {
                    jshintrc: 'server/.jshintrc'
                },
                src: ['server/**/*.js']
            }
        },

        clean: {
            build: '<%= yeoman.build %>/*',
            tmp: '.tmp'
        },

        bower: {
            install: {
                // just run 'grunt bower:install' and you'll see files from your Bower packages in lib directory
            }
        },

        'bower_postinst': {
            'angular-bootstrap': {
                options: {
                    components: {
                        'angular-bootstrap': [
                            'npm',
                            { grunt: 'html2js' },
                            { grunt: 'build:modal' }
                        ]
                    }
                }
            }
        },

        wiredep: {
            app: {
                src: '<%= yeoman.app %>/index.html',
                ignorePath: '<%= yeoman.app %>/',
                exclude: [
                    /bootstrap\.js/
                ]
            }
        },

        less: {
            styles: {
                files: {
                    '<%= yeoman.app %>/styles/main.css': '<%= yeoman.app %>/styles/less/main.less'
                }
            },
            bootstrap: {
                files: {
                    '<%= yeoman.app %>/bower_components/bootstrap/dist/css/bootstrap.css': [
                        '<%= yeoman.app %>/styles/less/bootstrap/modals.less'
                    ]
                }
            }
        },

        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            build: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/styles/',
                        src: '**/*.css',
                        dest: '.tmp/styles/'
                    }
                ]
            }
        },

        copy: {
            build: {
                expand: true,
                dot: true,
                cwd: '<%= yeoman.app %>',
                dest: '<%= yeoman.build %>',
                src: ['*.{ico,png,txt}', '*.html']
            },
            fontAwesome: {
                expand: true,
                cwd: '<%= yeoman.app %>/bower_components/font-awesome/fonts',
                dest: '<%= yeoman.build %>/fonts',
                src: '*'
            }
        },

        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.build %>'
            }
        },

        usemin: {
            html: ['<%= yeoman.build %>/**/*.html'],
            css: ['<%= yeoman.build %>/styles/**/*.css'],
            options: {
                assetsDirs: ['<%= yeoman.build %>']
            }
        },

        ngtemplates: {
            app: {
                cwd: '<%= yeoman.app %>',
                src: 'views/**/*.html',
                dest: '.tmp/templates.js',
                options:  {
                    usemin: 'scripts/scripts.js',
                    module: 'catenaccio',
                    htmlmin:  htmlminOptions
                }
            }
        },

        htmlrefs: {
            build: {
                src: '<%= yeoman.build %>/index.html',
                dest: '<%= yeoman.build %>/index.html'
            }
        },

        htmlmin: {
            build: {
                options: htmlminOptions,
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.build %>',
                        src: ['*.html'],
                        dest: '<%= yeoman.build %>'
                    }
                ]
            }
        },

        ngmin: {
            build: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/concat/scripts',
                        src: '*.js',
                        dest: '.tmp/concat/scripts'
                    }
                ]
            }
        },

        rev: {
            build: {
                files: {
                    src: [
                        '<%= yeoman.build %>/scripts/**/*.js',
                        '<%= yeoman.build %>/styles/**/*.css',
                        '<%= yeoman.build %>/styles/fonts/*'
                    ]
                }
            }
        },

        express: {
            options: {
                script: 'server/server.js'
            },
            dev: {
                options: {
                    'node_env': 'development',
                    port: 3000
                }
            },
            test: {
                options: {
                    'node_env': 'test',
                    port: 8000
                }
            },
            travis: {
                options: {
                    'node_env': 'travis',
                    port: 8000
                }
            }
        },

        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            }
        },

        mochaTest: {
            options: {
                reporter: 'spec'
            },
            src: ['server/test/**/*.js']
        },

        protractor: {
            options: {
                keepAlive: false
            },
            test: {
                options: {
                    configFile: 'protractor.conf.js'
                }
            },
            travis: {
                options: {
                    configFile: 'protractor-sauce.conf.js'
                }
            }
        }
    });

    grunt.registerTask('styles', ['less', 'autoprefixer']);

    grunt.registerTask('start', ['styles', 'express:dev', 'watch']);

    grunt.registerTask('e2e-test', ['express:test', 'protractor:test']);

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

    grunt.registerTask('test:travis', [
        'jshint',
        'karma',
        'mochaTest',
        'express:travis',
        'protractor:travis'
    ]);

    grunt.registerTask('build', [
        'clean',
        'bower',
        'bower_postinst',
        'wiredep',
        'styles',
        'copy:build',
        'copy:fontAwesome',
        'useminPrepare',
        'ngtemplates',
        'concat',
        'cssmin',
        'htmlrefs',
        'ngmin',
        'uglify',
        'rev',
        'usemin',
        'htmlmin'
    ]);

    grunt.registerTask('default', ['test', 'build']);
};
<commit_msg>Don't copy bower components into lib<commit_after>'use strict';

module.exports = function (grunt) {

    var htmlminOptions = {
        collapseWhitespace: true,
        collapseBooleanAttributes: true,
        removeOptionalTags: true
    };

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

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

    grunt.initConfig({

        yeoman: {
            app: require('./bower.json').appPath || 'client/app',
            build: 'build'
        },

        watch: {
            less: {
                files: ['<%= yeoman.app %>/styles/less/**/*.less'],
                tasks: ['less']
            },
            express: {
                files: ['server/**/*.js'],
                tasks: ['express:dev'],
                options: {
                    spawn: false // Without this option specified express won't be reloaded
                }
            }
        },

        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            gruntfile: ['Gruntfile.js'],
            client: {
                options: {
                    jshintrc: 'client/.jshintrc'
                },
                src: ['<%= yeoman.app %>/scripts/**/*.js', 'client/test/**/*.js']
            },
            server: {
                options: {
                    jshintrc: 'server/.jshintrc'
                },
                src: ['server/**/*.js']
            }
        },

        clean: {
            build: '<%= yeoman.build %>/*',
            tmp: '.tmp'
        },

        bower: {
            install: {
                options: {
                    copy: false
                }
            }
        },

        'bower_postinst': {
            'angular-bootstrap': {
                options: {
                    components: {
                        'angular-bootstrap': [
                            'npm',
                            { grunt: 'html2js' },
                            { grunt: 'build:modal' }
                        ]
                    }
                }
            }
        },

        wiredep: {
            app: {
                src: '<%= yeoman.app %>/index.html',
                ignorePath: '<%= yeoman.app %>/',
                exclude: [
                    /bootstrap\.js/
                ]
            }
        },

        less: {
            styles: {
                files: {
                    '<%= yeoman.app %>/styles/main.css': '<%= yeoman.app %>/styles/less/main.less'
                }
            },
            bootstrap: {
                files: {
                    '<%= yeoman.app %>/bower_components/bootstrap/dist/css/bootstrap.css': [
                        '<%= yeoman.app %>/styles/less/bootstrap/modals.less'
                    ]
                }
            }
        },

        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            build: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/styles/',
                        src: '**/*.css',
                        dest: '.tmp/styles/'
                    }
                ]
            }
        },

        copy: {
            build: {
                expand: true,
                dot: true,
                cwd: '<%= yeoman.app %>',
                dest: '<%= yeoman.build %>',
                src: ['*.{ico,png,txt}', '*.html']
            },
            fontAwesome: {
                expand: true,
                cwd: '<%= yeoman.app %>/bower_components/font-awesome/fonts',
                dest: '<%= yeoman.build %>/fonts',
                src: '*'
            }
        },

        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.build %>'
            }
        },

        usemin: {
            html: ['<%= yeoman.build %>/**/*.html'],
            css: ['<%= yeoman.build %>/styles/**/*.css'],
            options: {
                assetsDirs: ['<%= yeoman.build %>']
            }
        },

        ngtemplates: {
            app: {
                cwd: '<%= yeoman.app %>',
                src: 'views/**/*.html',
                dest: '.tmp/templates.js',
                options:  {
                    usemin: 'scripts/scripts.js',
                    module: 'catenaccio',
                    htmlmin:  htmlminOptions
                }
            }
        },

        htmlrefs: {
            build: {
                src: '<%= yeoman.build %>/index.html',
                dest: '<%= yeoman.build %>/index.html'
            }
        },

        htmlmin: {
            build: {
                options: htmlminOptions,
                files: [
                    {
                        expand: true,
                        cwd: '<%= yeoman.build %>',
                        src: ['*.html'],
                        dest: '<%= yeoman.build %>'
                    }
                ]
            }
        },

        ngmin: {
            build: {
                files: [
                    {
                        expand: true,
                        cwd: '.tmp/concat/scripts',
                        src: '*.js',
                        dest: '.tmp/concat/scripts'
                    }
                ]
            }
        },

        rev: {
            build: {
                files: {
                    src: [
                        '<%= yeoman.build %>/scripts/**/*.js',
                        '<%= yeoman.build %>/styles/**/*.css',
                        '<%= yeoman.build %>/styles/fonts/*'
                    ]
                }
            }
        },

        express: {
            options: {
                script: 'server/server.js'
            },
            dev: {
                options: {
                    'node_env': 'development',
                    port: 3000
                }
            },
            test: {
                options: {
                    'node_env': 'test',
                    port: 8000
                }
            },
            travis: {
                options: {
                    'node_env': 'travis',
                    port: 8000
                }
            }
        },

        karma: {
            unit: {
                configFile: 'karma.conf.js',
                singleRun: true
            }
        },

        mochaTest: {
            options: {
                reporter: 'spec'
            },
            src: ['server/test/**/*.js']
        },

        protractor: {
            options: {
                keepAlive: false
            },
            test: {
                options: {
                    configFile: 'protractor.conf.js'
                }
            },
            travis: {
                options: {
                    configFile: 'protractor-sauce.conf.js'
                }
            }
        }
    });

    grunt.registerTask('styles', ['less', 'autoprefixer']);

    grunt.registerTask('start', ['styles', 'express:dev', 'watch']);

    grunt.registerTask('e2e-test', ['express:test', 'protractor:test']);

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

    grunt.registerTask('test:travis', [
        'jshint',
        'karma',
        'mochaTest',
        'express:travis',
        'protractor:travis'
    ]);

    grunt.registerTask('build', [
        'clean',
        'bower',
        'bower_postinst',
        'wiredep',
        'styles',
        'copy:build',
        'copy:fontAwesome',
        'useminPrepare',
        'ngtemplates',
        'concat',
        'cssmin',
        'htmlrefs',
        'ngmin',
        'uglify',
        'rev',
        'usemin',
        'htmlmin'
    ]);

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


<commit_before>import {computedFrom, inject} from 'aurelia-framework';
import {Redirect} from 'aurelia-router';
import Store from 'common/shooting-log-store';

@inject(Store)
export class App {

  constructor(_store) {
    this.store = _store;
    let lsStore = null;
    try { lsStore = JSON.parse(sessionStorage.store)}
    catch(e){}

    if(lsStore) {
      this.store = _.extend(this.store, lsStore);
    }
  }

  configureRouter(config, router) {
    config.title = 'My Shooting Log';
    config.addPipelineStep('authorize', AuthorizeStep);
    config.map([
      { route: ['', 'welcome'], name: 'home',      moduleId: 'welcome',         auth: true,  nav: true,  title: 'Home', cs: this.store },
      { route: ['scorecard'],   name: 'scorecard', moduleId: 'round/scorecard', auth: true,  nav: true,  title: 'Scorecard', cs: this.store },
      { route: ['round'],       name: 'round',     moduleId: 'round/round',     auth: true,  nav: false, title: 'Round', cs: this.store },
      { route: ['bow_list'],    name: 'bow_list',  moduleId: 'bow/bow_list',    auth: true,  nav: true,  title: 'Bows', cs: this.store },
      { route: ['bow'],         name: 'bow',       moduleId: 'bow/bow',         auth: true,  nav: false, title: 'Bow Details', cs: this.store },
      { route: ['profile'],     name: 'profile',   moduleId: 'user/profile',    auth: true,  nav: true,  title: 'Profile', cs: this.store },
      { route: ['login'],       name: 'login',     moduleId: 'user/login',      auth: false, nav: false, title: 'Login', cs: this.store },
      { route: ['register'],    name: 'register',  moduleId: 'user/register',   auth: false, nav: false, title: 'Register', cs: this.store },
    ]);

    this.router = router;
  }
}

class AuthorizeStep {

  run(navigationInstruction, next) {
    // Check if the route has an "auth" key
    // The reason for using `nextInstructions` is because
    // this includes child routes.
    if (navigationInstruction.getAllInstructions().some(i => i.config.auth)) {
      var auth = JSON.parse(sessionStorage.getItem('auth-token'));
      if(auth == null) {
        return next.cancel(new Redirect('login'));
      }
    }

    return next();
  }
}
<commit_msg>Updated to include missing import<commit_after>import {computedFrom, inject} from 'aurelia-framework';
import {Redirect} from 'aurelia-router';
import Store from 'common/shooting-log-store';
import _ from 'underscore';

@inject(Store)
export class App {

  constructor(_store) {
    this.store = _store;
    let lsStore = null;
    try { lsStore = JSON.parse(sessionStorage.store)}
    catch(e){}

    if(lsStore) {
      this.store = _.extend(this.store, lsStore);
    }
  }

  configureRouter(config, router) {
    config.title = 'My Shooting Log';
    config.addPipelineStep('authorize', AuthorizeStep);
    config.map([
      { route: ['', 'welcome'], name: 'home',      moduleId: 'welcome',         auth: true,  nav: true,  title: 'Home', cs: this.store },
      { route: ['scorecard'],   name: 'scorecard', moduleId: 'round/scorecard', auth: true,  nav: true,  title: 'Scorecard', cs: this.store },
      { route: ['round'],       name: 'round',     moduleId: 'round/round',     auth: true,  nav: false, title: 'Round', cs: this.store },
      { route: ['bow_list'],    name: 'bow_list',  moduleId: 'bow/bow_list',    auth: true,  nav: true,  title: 'Bows', cs: this.store },
      { route: ['bow'],         name: 'bow',       moduleId: 'bow/bow',         auth: true,  nav: false, title: 'Bow Details', cs: this.store },
      { route: ['profile'],     name: 'profile',   moduleId: 'user/profile',    auth: true,  nav: true,  title: 'Profile', cs: this.store },
      { route: ['login'],       name: 'login',     moduleId: 'user/login',      auth: false, nav: false, title: 'Login', cs: this.store },
      { route: ['register'],    name: 'register',  moduleId: 'user/register',   auth: false, nav: false, title: 'Register', cs: this.store },
    ]);

    this.router = router;
  }
}

class AuthorizeStep {

  run(navigationInstruction, next) {
    // Check if the route has an "auth" key
    // The reason for using `nextInstructions` is because
    // this includes child routes.
    if (navigationInstruction.getAllInstructions().some(i => i.config.auth)) {
      var auth = JSON.parse(sessionStorage.getItem('auth-token'));
      if(auth == null) {
        return next.cancel(new Redirect('login'));
      }
    }

    return next();
  }
}
<|endoftext|>


<commit_before>module.exports = function (grunt) {
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-mocha-test');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.initConfig({
        paths: {
            src: {
                app: {
                    ussd_registration: 'src/ussd_registration.js',
                    voice_registration: 'src/voice_registration.js',
                    ussd_public: 'src/ussd_public.js',
                    voice_public: 'src/voice_public.js',
                    sms_inbound: 'src/sms_inbound.js',
                    train_ussd_reg_unrecognised: 'src/train_ussd_reg_unrecognised.js',
                    train_ussd_reg_recognised: 'src/train_ussd_reg_recognised.js',
                    train_ussd_public: 'src/train_ussd_public.js',
                    train_ivr_reg: 'src/train_ivr_reg.js',
                    train_ivr_public: 'src/train_ivr_public.js',
                },
                ussd_registration: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.ussd_registration %>',
                    'src/init.js'
                ],
                voice_registration: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.voice_registration %>',
                    'src/init.js'
                ],
                ussd_public: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.ussd_public %>',
                    'src/init.js'
                ],
                voice_public: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.voice_public %>',
                    'src/init.js'
                ],
                sms_inbound: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.sms_inbound %>',
                    'src/init.js'
                ],
                train_ivr_reg: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ivr_reg %>',
                    'src/init.js'
                ],
                train_ivr_public: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ivr_public %>',
                    'src/init.js'
                ],
                train_ussd_reg_unrecognised: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_reg_unrecognised %>',
                    'src/init.js'
                ],
                train_ussd_reg_recognised: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_reg_recognised %>',
                    'src/init.js'
                ],
                train_ussd_public: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_public %>',
                    'src/init.js'
                ],
                all: [
                    'src/**/*.js'
                ]
            },
            dest: {
                ussd_registration: 'go-ussd_registration.js',
                voice_registration: 'go-voice_registration.js',
                ussd_public: 'go-ussd_public.js',
                voice_public: 'go-voice_public.js',
                sms_inbound: 'go-sms_inbound.js',
                train_ivr_reg: 'go-train_ivr_reg.js',
                train_ivr_public: 'go-train_ivr_public.js',
                train_ussd_reg_unrecognised: 'go-train_ussd_reg_unrecognised.js',
                train_ussd_reg_recognised: 'go-train_ussd_reg_recognised.js',
                train_ussd_public: 'go-train_ussd_public.js',
            },
            test: {
                ussd_registration: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.ussd_registration %>',
                    'test/ussd_registration.test.js'
                ],
                voice_registration: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.voice_registration %>',
                    'test/voice_registration.test.js'
                ],
                ussd_public: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.ussd_public %>',
                    'test/ussd_public.test.js'
                ],
                voice_public: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.voice_public %>',
                    'test/voice_public.test.js'
                ],
                sms_inbound: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.sms_inbound %>',
                    'test/sms_inbound.test.js'
                ],
                train_ivr_reg: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ivr_reg %>',
                    'test/train_ivr_reg.test.js'
                ],
                train_ivr_public: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ivr_public %>',
                    'test/train_ivr_public.test.js'
                ],
                train_ussd_reg_unrecognised: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_reg_unrecognised %>',
                    'test/train_ussd_reg_unrecognised.test.js'
                ],
                train_ussd_reg_recognised: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_reg_recognised %>',
                    'test/train_ussd_reg_recognised.test.js'
                ],
                train_ussd_public: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_public %>',
                    'test/train_ussd_public.test.js'
                ],
            }
        },

        jshint: {
            options: {jshintrc: '.jshintrc'},
            all: [
                'Gruntfile.js',
                '<%= paths.src.all %>'
            ]
        },

        watch: {
            src: {
                files: [
                    '<%= paths.src.all %>'
                ],
                tasks: ['default'],
                options: {
                    atBegin: true
                }
            }
        },

        concat: {
            options: {
                banner: [
                    '// WARNING: This is a generated file.',
                    '//          If you edit it you will be sad.',
                    '//          Edit src/app.js instead.',
                    '\n' // Newline between banner and content.
                ].join('\n')
            },
            voice_registration: {
                src: ['<%= paths.src.voice_registration %>'],
                dest: '<%= paths.dest.voice_registration %>'
            },
            voice_public: {
                src: ['<%= paths.src.voice_public %>'],
                dest: '<%= paths.dest.voice_public %>'
            },
            ussd_registration: {
                src: ['<%= paths.src.ussd_registration %>'],
                dest: '<%= paths.dest.ussd_registration %>'
            },
            ussd_public: {
                src: ['<%= paths.src.ussd_public %>'],
                dest: '<%= paths.dest.ussd_public %>'
            },
            sms_inbound: {
                src: ['<%= paths.src.sms_inbound %>'],
                dest: '<%= paths.dest.sms_inbound %>'
            },
            train_ivr_reg: {
                src: ['<%= paths.src.train_ivr_reg %>'],
                dest: '<%= paths.dest.train_ivr_reg %>'
            },
            train_ivr_public: {
                src: ['<%= paths.src.train_ivr_public %>'],
                dest: '<%= paths.dest.train_ivr_public %>'
            },
            train_ussd_reg_unrecognised: {
                src: ['<%= paths.src.train_ussd_reg_unrecognised %>'],
                dest: '<%= paths.dest.train_ussd_reg_unrecognised %>'
            },
            train_ussd_reg_recognised: {
                src: ['<%= paths.src.train_ussd_reg_recognised %>'],
                dest: '<%= paths.dest.train_ussd_reg_recognised %>'
            },
            train_ussd_public: {
                src: ['<%= paths.src.train_ussd_public %>'],
                dest: '<%= paths.dest.train_ussd_public %>'
            },

        },

        mochaTest: {
            options: {
                reporter: 'spec'
            },
            // test_ussd_registration: {
            //     src: ['<%= paths.test.ussd_registration %>']
            // },
            // test_voice_registration: {
            //     src: ['<%= paths.test.voice_registration %>']
            // },
            // test_ussd_public: {
            //     src: ['<%= paths.test.ussd_public %>']
            // },
            // test_voice_public: {
            //     src: ['<%= paths.test.voice_public %>']
            // },
            // test_sms_inbound: {
            //      src: ['<%= paths.test.sms_inbound %>']
            // },
            test_train_ivr_reg: {
                src: ['<%= paths.test.train_ivr_reg %>']
            },
            // test_train_ivr_public: {
            //     src: ['<%= paths.test.train_ivr_public %>']
            // },
            // test_train_ussd_reg_unrecognised: {
            //     src: ['<%= paths.test.train_ussd_reg_unrecognised %>']
            // },
            // test_train_ussd_reg_recognised: {
            //     src: ['<%= paths.test.train_ussd_reg_recognised %>']
            // },
            // test_train_ussd_public: {
            //     src: ['<%= paths.test.train_ussd_public %>']
            // },
        }
    });

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

    grunt.registerTask('build', [
        'concat',
    ]);

    grunt.registerTask('default', [
        'build',
        'test'
    ]);
};
<commit_msg>reduce local tests for dev<commit_after>module.exports = function (grunt) {
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-mocha-test');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.initConfig({
        paths: {
            src: {
                app: {
                    ussd_registration: 'src/ussd_registration.js',
                    voice_registration: 'src/voice_registration.js',
                    ussd_public: 'src/ussd_public.js',
                    voice_public: 'src/voice_public.js',
                    sms_inbound: 'src/sms_inbound.js',
                    train_ussd_reg_unrecognised: 'src/train_ussd_reg_unrecognised.js',
                    train_ussd_reg_recognised: 'src/train_ussd_reg_recognised.js',
                    train_ussd_public: 'src/train_ussd_public.js',
                    train_ivr_reg: 'src/train_ivr_reg.js',
                    train_ivr_public: 'src/train_ivr_public.js',
                },
                ussd_registration: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.ussd_registration %>',
                    'src/init.js'
                ],
                voice_registration: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.voice_registration %>',
                    'src/init.js'
                ],
                ussd_public: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.ussd_public %>',
                    'src/init.js'
                ],
                voice_public: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.voice_public %>',
                    'src/init.js'
                ],
                sms_inbound: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.sms_inbound %>',
                    'src/init.js'
                ],
                train_ivr_reg: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ivr_reg %>',
                    'src/init.js'
                ],
                train_ivr_public: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ivr_public %>',
                    'src/init.js'
                ],
                train_ussd_reg_unrecognised: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_reg_unrecognised %>',
                    'src/init.js'
                ],
                train_ussd_reg_recognised: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_reg_recognised %>',
                    'src/init.js'
                ],
                train_ussd_public: [
                    'src/index.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_public %>',
                    'src/init.js'
                ],
                all: [
                    'src/**/*.js'
                ]
            },
            dest: {
                ussd_registration: 'go-ussd_registration.js',
                voice_registration: 'go-voice_registration.js',
                ussd_public: 'go-ussd_public.js',
                voice_public: 'go-voice_public.js',
                sms_inbound: 'go-sms_inbound.js',
                train_ivr_reg: 'go-train_ivr_reg.js',
                train_ivr_public: 'go-train_ivr_public.js',
                train_ussd_reg_unrecognised: 'go-train_ussd_reg_unrecognised.js',
                train_ussd_reg_recognised: 'go-train_ussd_reg_recognised.js',
                train_ussd_public: 'go-train_ussd_public.js',
            },
            test: {
                ussd_registration: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.ussd_registration %>',
                    'test/ussd_registration.test.js'
                ],
                voice_registration: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.voice_registration %>',
                    'test/voice_registration.test.js'
                ],
                ussd_public: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.ussd_public %>',
                    'test/ussd_public.test.js'
                ],
                voice_public: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.voice_public %>',
                    'test/voice_public.test.js'
                ],
                sms_inbound: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.sms_inbound %>',
                    'test/sms_inbound.test.js'
                ],
                train_ivr_reg: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ivr_reg %>',
                    'test/train_ivr_reg.test.js'
                ],
                train_ivr_public: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ivr_public %>',
                    'test/train_ivr_public.test.js'
                ],
                train_ussd_reg_unrecognised: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_reg_unrecognised %>',
                    'test/train_ussd_reg_unrecognised.test.js'
                ],
                train_ussd_reg_recognised: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_reg_recognised %>',
                    'test/train_ussd_reg_recognised.test.js'
                ],
                train_ussd_public: [
                    'test/setup.js',
                    'src/utils.js',
                    'src/utils_project.js',
                    '<%= paths.src.app.train_ussd_public %>',
                    'test/train_ussd_public.test.js'
                ],
            }
        },

        jshint: {
            options: {jshintrc: '.jshintrc'},
            all: [
                'Gruntfile.js',
                '<%= paths.src.all %>'
            ]
        },

        watch: {
            src: {
                files: [
                    '<%= paths.src.all %>'
                ],
                tasks: ['default'],
                options: {
                    atBegin: true
                }
            }
        },

        concat: {
            options: {
                banner: [
                    '// WARNING: This is a generated file.',
                    '//          If you edit it you will be sad.',
                    '//          Edit src/app.js instead.',
                    '\n' // Newline between banner and content.
                ].join('\n')
            },
            voice_registration: {
                src: ['<%= paths.src.voice_registration %>'],
                dest: '<%= paths.dest.voice_registration %>'
            },
            voice_public: {
                src: ['<%= paths.src.voice_public %>'],
                dest: '<%= paths.dest.voice_public %>'
            },
            ussd_registration: {
                src: ['<%= paths.src.ussd_registration %>'],
                dest: '<%= paths.dest.ussd_registration %>'
            },
            ussd_public: {
                src: ['<%= paths.src.ussd_public %>'],
                dest: '<%= paths.dest.ussd_public %>'
            },
            sms_inbound: {
                src: ['<%= paths.src.sms_inbound %>'],
                dest: '<%= paths.dest.sms_inbound %>'
            },
            train_ivr_reg: {
                src: ['<%= paths.src.train_ivr_reg %>'],
                dest: '<%= paths.dest.train_ivr_reg %>'
            },
            train_ivr_public: {
                src: ['<%= paths.src.train_ivr_public %>'],
                dest: '<%= paths.dest.train_ivr_public %>'
            },
            train_ussd_reg_unrecognised: {
                src: ['<%= paths.src.train_ussd_reg_unrecognised %>'],
                dest: '<%= paths.dest.train_ussd_reg_unrecognised %>'
            },
            train_ussd_reg_recognised: {
                src: ['<%= paths.src.train_ussd_reg_recognised %>'],
                dest: '<%= paths.dest.train_ussd_reg_recognised %>'
            },
            train_ussd_public: {
                src: ['<%= paths.src.train_ussd_public %>'],
                dest: '<%= paths.dest.train_ussd_public %>'
            },

        },

        mochaTest: {
            options: {
                reporter: 'spec'
            },
            // test_ussd_registration: {
            //     src: ['<%= paths.test.ussd_registration %>']
            // },
            // test_voice_registration: {
            //     src: ['<%= paths.test.voice_registration %>']
            // },
            // test_ussd_public: {
            //     src: ['<%= paths.test.ussd_public %>']
            // },
            // test_voice_public: {
            //     src: ['<%= paths.test.voice_public %>']
            // },
            // test_sms_inbound: {
            //      src: ['<%= paths.test.sms_inbound %>']
            // },
            // test_train_ivr_reg: {
            //     src: ['<%= paths.test.train_ivr_reg %>']
            // },
            test_train_ivr_public: {
                src: ['<%= paths.test.train_ivr_public %>']
            },
            // test_train_ussd_reg_unrecognised: {
            //     src: ['<%= paths.test.train_ussd_reg_unrecognised %>']
            // },
            // test_train_ussd_reg_recognised: {
            //     src: ['<%= paths.test.train_ussd_reg_recognised %>']
            // },
            // test_train_ussd_public: {
            //     src: ['<%= paths.test.train_ussd_public %>']
            // },
        }
    });

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

    grunt.registerTask('build', [
        'concat',
    ]);

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


<commit_before>'use strict';

var gulp = require('gulp'),
	nodemon = require('gulp-nodemon'),
	uglify = require('gulp-uglify'),
	sass = require('gulp-sass'),
	minifyCSS = require('gulp-minify-css'),
	rename = require('gulp-rename'),
	concat = require('gulp-concat');

function restartTime () {
	function checkTime(i) {
		return (i < 10) ? '0' + i : i;
	}

	var today = new Date(),
		hrs = checkTime(today.getHours()),
		min = checkTime(today.getMinutes()),
		sec = checkTime(today.getMinutes());

	return hrs + ':' + min + ':' + sec;
}

gulp.task('watch', function () {
	nodemon({ script: 'server.js', ext: 'jade js'})
		.on('restart', function () {
			console.log('Server restarted at ' + restartTime + '!');
			});
});

gulp.task('minify', function () {
	gulp.src('./app/css/*.sass')
		.pipe(sass({
			indentedSyntax: true,
			errLogToConsole: true
			}))
		.pipe(minifyCSS())
		.pipe(rename('main.min.css'))
		.pipe(gulp.dest('./public/css'));

	gulp.src(['./app/controllers/clickController.client.js'])
		.pipe(uglify())
		.pipe(rename('site.min.js'))
		.pipe(gulp.dest('./public/scripts'));

});

gulp.task('default', ['watch']);<commit_msg>Use wildcard in Gulp minify task.<commit_after>'use strict';

var gulp = require('gulp'),
	nodemon = require('gulp-nodemon'),
	uglify = require('gulp-uglify'),
	sass = require('gulp-sass'),
	minifyCSS = require('gulp-minify-css'),
	rename = require('gulp-rename'),
	concat = require('gulp-concat');

function restartTime () {
	function checkTime(i) {
		return (i < 10) ? '0' + i : i;
	}

	var today = new Date(),
		hrs = checkTime(today.getHours()),
		min = checkTime(today.getMinutes()),
		sec = checkTime(today.getMinutes());

	return hrs + ':' + min + ':' + sec;
}

gulp.task('watch', function () {
	nodemon({ script: 'server.js', ext: 'jade js'})
		.on('restart', function () {
			console.log('Server restarted at ' + restartTime + '!');
			});
});

gulp.task('minify', function () {
	gulp.src('./app/css/*.sass')
		.pipe(sass({
			indentedSyntax: true,
			errLogToConsole: true
			}))
		.pipe(minifyCSS())
		.pipe(rename('main.min.css'))
		.pipe(gulp.dest('./public/css'));

	gulp.src(['./app/controllers/**/*.client.js'])
		.pipe(uglify())
		.pipe(rename('site.min.js'))
		.pipe(gulp.dest('./public/scripts'));

});

gulp.task('default', ['watch']);<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {
  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  // configurable paths
  var uikitConfig = {
    src: 'src',
    srcRelution: 'src-relution',
    dist: 'dist',
    fileName: 'mw-uikit',
    fileNameRelution: 'mw-uikit.relution',
    getVersion: function () {
      var packageJson = grunt.file.readJSON('package.json');
      return packageJson.version;
    },
    getGruntParam: function (paramName, defaultValue) {
      var gruntParam = grunt.option(paramName);
      // For any reasons the useminPrepare task calls all subtasks of copy and then it will crash because some copy tasks need a param name
      if (!gruntParam && !defaultValue) {
        throw new Error('The param "' + paramName + '" is required for the task ' + grunt.task.current.name + ' and was not passed as argument. Please pass the argument --' + paramName);
      } else {
        return gruntParam || defaultValue;
      }
    },
    getversionWithBuildNumber: function () {
      return uikitConfig.getVersion() + '-b' + uikitConfig.getGruntParam('buildNumber', 'LOCAL');
    },
    getReleaseNameWithBuildNum: function () {
      return uikitConfig.fileName +
        '-v' + uikitConfig.getversionWithBuildNumber() +
        '-sha.c' + uikitConfig.getGruntParam('commitHash', 'none').toString().substr(0,5);
    }
  };

  grunt.initConfig({
    uikit: uikitConfig,
    regarde: {
      all: {
        files: [
          'src/**/*.js',
          'src/**/*.json',
          'src/**/*.html'
        ],
        tasks: ['process']
      }
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },
      all: [
        'Gruntfile.js',
        'src/**/*.js'
      ]
    },
    preprocess: {
      js: {
        src: 'src/mw_ui.js',
        dest: '<%= uikit.dist %>/<%= uikit.fileName %>.js'
      }
    },
    concat: {
      dist: {
        src: [
          'src-relution/mwUI.js',
          'src-relution/**/*.js',
          '!src-relution/test/**/*.js',
          '.tmp/templates.js',
          '.tmp/templates-relution.js',
          'libs/angular-sanitize/angular-sanitize.js',
          'libs/showdown/dist/showdown.js',
          'libs/jquery-ui/ui/jquery.ui.widget.js',
          'libs/blueimp-file-upload/js/jquery.fileupload.js',
          'libs/blueimp-file-upload/js/jquery.iframe-transport.js',
          'libs/bootstrap-sass-datepicker/js/bootstrap-sass-datepicker.js',
          'libs/bootstrap-sass-datepicker/js/locales/bootstrap-datepicker.de.js'
        ],
        dest: '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js'
      }
    },
    copy: {
      distToSamplePortal: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.dist %>',
            dest: 'sample_portal/app/components/mw-ui',
            src: [
              '<%= uikit.fileName %>.js'
            ]
          }
        ]
      },
      relutionScssToDistfolder: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.srcRelution %>/styles',
            dest: '<%= uikit.dist %>/styles/relution',
            src: [
              '**/*.scss'
            ]
          }
        ]
      },
      scssToDistfolder: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.src %>',
            dest: '<%= uikit.dist %>/styles',
            src: [
              '_mw_uis.scss',
              '**/*.scss',
              '**/styles/*.scss'
            ]
          }
        ]
      }
    },
    uglify: {
      js: {
        files: {
          '<%= uikit.dist %>/<%= uikit.fileName %>.min.js': ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
          '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.min.js': ['<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js']
        }
      }
    },
    ngAnnotate: {
      options: {
        singleQuotes: true
      },
      dist: {
        files: [
          {
            '<%= uikit.dist %>/<%= uikit.fileName %>.js': ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
            '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js': ['<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js']
          }
        ]
      }
    },
    ngtemplates: {
      old: {
        src: [
          'src-relution/templates/**/*.html'
        ],
        dest: '.tmp/templates-relution.js',
        options: {
          url: function (url) {
            return 'uikit/' + url.replace('src-relution/', '');
          },
          bootstrap: function (module, script) {
            return 'angular.module("mwUI").run(["$templateCache", function($templateCache) {' + script + '}]);';
          },
          htmlmin: {collapseWhitespace: true, collapseBooleanAttributes: true}
        }
      },
      new: {
        src: [
          'src/**/templates/**/*.html',
          'src/**/i18n/**/*.json',
          'src/mw_ui_icons.json'
        ],
        dest: '.tmp/templates.js',
        options: {
          url: function (url) {
            return 'uikit/' + url.replace('src/', '');
          },
          bootstrap: function (module, script) {
            return 'angular.module("mwUI").run(["$templateCache", function($templateCache) {' + script + '}]);';
          },
          htmlmin: {collapseWhitespace: true, collapseBooleanAttributes: true}
        }
      }
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js'
      }
    },
    replace: {
      setBuildNumber: {
        src: ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
        overwrite: true,
        replacements: [
          {
            from: /UIKITVERSIONNUMBER/,
            to: function () {
              return uikitConfig.getversionWithBuildNumber();
            }
          }
        ]
      }
    },
    shell: {
      zipUiKit: {
        options: {
          stdout: true,
          failOnError: true
        },
        command: function () {
          return [
            'mkdir -p zip',
            'cp -r dist zip/' + uikitConfig.getReleaseNameWithBuildNum(),
            'cd zip',
            'zip -r ' + uikitConfig.getReleaseNameWithBuildNum() + '.zip ' + uikitConfig.getReleaseNameWithBuildNum(),
            'rm -rf ' + uikitConfig.getReleaseNameWithBuildNum()
          ].join('&&');
        }
      },
      gitRelease: {
        options: {
          stdout: true
        },
        command: function(){
          return [
            'git config user.name "Bob Builder"',
            'git config user.email "info@mwaysolutions.com"',
            'if [ `git branch --list release` ]; then git checkout release; else git checkout --orphan release; fi',
            'git reset',
            'git add dist/* -f',
            'git commit -m "release build v' + uikitConfig.getReleaseNameWithBuildNum()+'"',
            'git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" release  > /dev/null 2>&1',
            'git tag ' + uikitConfig.getReleaseNameWithBuildNum(),
            'git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" ' + uikitConfig.getReleaseNameWithBuildNum() + ' > /dev/null 2>&1'
          ].join('&&');
        }
      }
    },
    clean: ['dist', 'zip']
  });

  grunt.registerTask('test', ['build', 'karma']);
  grunt.registerTask('test:codequality', ['jshint', 'test']);
  grunt.registerTask('watch', ['process', 'regarde']);
  grunt.registerTask('process', ['ngtemplates:new', 'preprocess:js', 'ngAnnotate:dist', 'copy:distToSamplePortal']);
  grunt.registerTask('process-old', ['ngtemplates:old', 'concat', 'ngAnnotate:dist', 'copy:distToSamplePortal']);
  grunt.registerTask('build', ['jshint', 'process', 'process-old']);
  grunt.registerTask('release', ['clean', 'build', 'replace:setBuildNumber', 'uglify', 'copy:scssToDistfolder', 'copy:relutionScssToDistfolder', 'shell:zipUiKit', 'shell:gitRelease']);
};
<commit_msg>adds git fetch to get branch list<commit_after>'use strict';

module.exports = function (grunt) {
  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  // configurable paths
  var uikitConfig = {
    src: 'src',
    srcRelution: 'src-relution',
    dist: 'dist',
    fileName: 'mw-uikit',
    fileNameRelution: 'mw-uikit.relution',
    getVersion: function () {
      var packageJson = grunt.file.readJSON('package.json');
      return packageJson.version;
    },
    getGruntParam: function (paramName, defaultValue) {
      var gruntParam = grunt.option(paramName);
      // For any reasons the useminPrepare task calls all subtasks of copy and then it will crash because some copy tasks need a param name
      if (!gruntParam && !defaultValue) {
        throw new Error('The param "' + paramName + '" is required for the task ' + grunt.task.current.name + ' and was not passed as argument. Please pass the argument --' + paramName);
      } else {
        return gruntParam || defaultValue;
      }
    },
    getversionWithBuildNumber: function () {
      return uikitConfig.getVersion() + '-b' + uikitConfig.getGruntParam('buildNumber', 'LOCAL');
    },
    getReleaseNameWithBuildNum: function () {
      return uikitConfig.fileName +
        '-v' + uikitConfig.getversionWithBuildNumber() +
        '-sha.c' + uikitConfig.getGruntParam('commitHash', 'none').toString().substr(0,5);
    }
  };

  grunt.initConfig({
    uikit: uikitConfig,
    regarde: {
      all: {
        files: [
          'src/**/*.js',
          'src/**/*.json',
          'src/**/*.html'
        ],
        tasks: ['process']
      }
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },
      all: [
        'Gruntfile.js',
        'src/**/*.js'
      ]
    },
    preprocess: {
      js: {
        src: 'src/mw_ui.js',
        dest: '<%= uikit.dist %>/<%= uikit.fileName %>.js'
      }
    },
    concat: {
      dist: {
        src: [
          'src-relution/mwUI.js',
          'src-relution/**/*.js',
          '!src-relution/test/**/*.js',
          '.tmp/templates.js',
          '.tmp/templates-relution.js',
          'libs/angular-sanitize/angular-sanitize.js',
          'libs/showdown/dist/showdown.js',
          'libs/jquery-ui/ui/jquery.ui.widget.js',
          'libs/blueimp-file-upload/js/jquery.fileupload.js',
          'libs/blueimp-file-upload/js/jquery.iframe-transport.js',
          'libs/bootstrap-sass-datepicker/js/bootstrap-sass-datepicker.js',
          'libs/bootstrap-sass-datepicker/js/locales/bootstrap-datepicker.de.js'
        ],
        dest: '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js'
      }
    },
    copy: {
      distToSamplePortal: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.dist %>',
            dest: 'sample_portal/app/components/mw-ui',
            src: [
              '<%= uikit.fileName %>.js'
            ]
          }
        ]
      },
      relutionScssToDistfolder: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.srcRelution %>/styles',
            dest: '<%= uikit.dist %>/styles/relution',
            src: [
              '**/*.scss'
            ]
          }
        ]
      },
      scssToDistfolder: {
        files: [
          {
            expand: true,
            dot: true,
            cwd: '<%= uikit.src %>',
            dest: '<%= uikit.dist %>/styles',
            src: [
              '_mw_uis.scss',
              '**/*.scss',
              '**/styles/*.scss'
            ]
          }
        ]
      }
    },
    uglify: {
      js: {
        files: {
          '<%= uikit.dist %>/<%= uikit.fileName %>.min.js': ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
          '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.min.js': ['<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js']
        }
      }
    },
    ngAnnotate: {
      options: {
        singleQuotes: true
      },
      dist: {
        files: [
          {
            '<%= uikit.dist %>/<%= uikit.fileName %>.js': ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
            '<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js': ['<%= uikit.dist %>/<%= uikit.fileNameRelution %>.js']
          }
        ]
      }
    },
    ngtemplates: {
      old: {
        src: [
          'src-relution/templates/**/*.html'
        ],
        dest: '.tmp/templates-relution.js',
        options: {
          url: function (url) {
            return 'uikit/' + url.replace('src-relution/', '');
          },
          bootstrap: function (module, script) {
            return 'angular.module("mwUI").run(["$templateCache", function($templateCache) {' + script + '}]);';
          },
          htmlmin: {collapseWhitespace: true, collapseBooleanAttributes: true}
        }
      },
      new: {
        src: [
          'src/**/templates/**/*.html',
          'src/**/i18n/**/*.json',
          'src/mw_ui_icons.json'
        ],
        dest: '.tmp/templates.js',
        options: {
          url: function (url) {
            return 'uikit/' + url.replace('src/', '');
          },
          bootstrap: function (module, script) {
            return 'angular.module("mwUI").run(["$templateCache", function($templateCache) {' + script + '}]);';
          },
          htmlmin: {collapseWhitespace: true, collapseBooleanAttributes: true}
        }
      }
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js'
      }
    },
    replace: {
      setBuildNumber: {
        src: ['<%= uikit.dist %>/<%= uikit.fileName %>.js'],
        overwrite: true,
        replacements: [
          {
            from: /UIKITVERSIONNUMBER/,
            to: function () {
              return uikitConfig.getversionWithBuildNumber();
            }
          }
        ]
      }
    },
    shell: {
      zipUiKit: {
        options: {
          stdout: true,
          failOnError: true
        },
        command: function () {
          return [
            'mkdir -p zip',
            'cp -r dist zip/' + uikitConfig.getReleaseNameWithBuildNum(),
            'cd zip',
            'zip -r ' + uikitConfig.getReleaseNameWithBuildNum() + '.zip ' + uikitConfig.getReleaseNameWithBuildNum(),
            'rm -rf ' + uikitConfig.getReleaseNameWithBuildNum()
          ].join('&&');
        }
      },
      gitRelease: {
        options: {
          stdout: true
        },
        command: function(){
          return [
            'git config user.name "Bob Builder"',
            'git config user.email "info@mwaysolutions.com"',
            'git fetch',
            'if [ `git branch --list release` ]; then git checkout release; else git checkout --orphan release; fi',
            'git reset',
            'git add dist/* -f',
            'git commit -m "release build v' + uikitConfig.getReleaseNameWithBuildNum()+'"',
            'git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" release  > /dev/null 2>&1',
            'git tag ' + uikitConfig.getReleaseNameWithBuildNum(),
            'git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" ' + uikitConfig.getReleaseNameWithBuildNum() + ' > /dev/null 2>&1'
          ].join('&&');
        }
      }
    },
    clean: ['dist', 'zip']
  });

  grunt.registerTask('test', ['build', 'karma']);
  grunt.registerTask('test:codequality', ['jshint', 'test']);
  grunt.registerTask('watch', ['process', 'regarde']);
  grunt.registerTask('process', ['ngtemplates:new', 'preprocess:js', 'ngAnnotate:dist', 'copy:distToSamplePortal']);
  grunt.registerTask('process-old', ['ngtemplates:old', 'concat', 'ngAnnotate:dist', 'copy:distToSamplePortal']);
  grunt.registerTask('build', ['jshint', 'process', 'process-old']);
  grunt.registerTask('release', ['clean', 'build', 'replace:setBuildNumber', 'uglify', 'copy:scssToDistfolder', 'copy:relutionScssToDistfolder', 'shell:zipUiKit', 'shell:gitRelease']);
};
<|endoftext|>