<commit_before>var gulp = require('gulp');
var debug = require('gulp-debug');
var jasmine = require('gulp-jasmine');

var paths = {
	//scripts: ['client/js/**/*.coffee', '!client/external/**/*.coffee'],
  //images: 'client/img/**/*'
	tests: ['spec/**/*Spec.js']
};

gulp.task('test', function () {
	return gulp.src(paths.tests)
		.pipe(debug({title: 'jasmine:'}))
    .pipe(jasmine({verbose:true}));
});

// Rerun the task when a file changes
gulp.task('watch', function() {
  gulp.watch(paths.tests, ['test']);
});
<commit_msg>gulp should now watch lib files as well<commit_after>var gulp = require('gulp');
var debug = require('gulp-debug');
var jasmine = require('gulp-jasmine');

var paths = {
	//scripts: ['client/js/**/*.coffee', '!client/external/**/*.coffee'],
  //images: 'client/img/**/*'
	libs: ['lib/**/*.js'],
	tests: ['spec/**/*Spec.js']
};

gulp.task('test', function () {
	return gulp.src(paths.tests)
		.pipe(debug({title: 'jasmine:'}))
    .pipe(jasmine({verbose:true}));
});

// Rerun the task when a file changes
gulp.task('watch', function() {
  gulp.watch(paths.tests, ['test']);
  gulp.watch(paths.libs, ['test']);
});
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    typescript = require('gulp-typescript'),
    merge = require('merge2'),
    webserver = require('gulp-webserver'),
    less = require('gulp-less'),
    gulputil = require('gulp-util'),
    gulpFilter = require('gulp-filter');

/// ********

/// GLOBAL

gulp.task('default', function(){
  return gulp.start('default-server-all');
});

gulp.task('default-server-all', ['default-plugins', 'copyDTS-plugins'], function(){
  return gulp.start('default-server');
});

//// *****

//****

// PLUGIN PART

// ***

/**
 * Compile typescript files to their js respective files
 */
gulp.task('typescript-to-js-plugins', function() {
  //Compile all ts file into their respective js file.

  var tsResult = gulp.src(['Plugins/Vorlon/**/*.ts', 'Plugins/libs/**.ts'])
                       .pipe(typescript({
                            declarationFiles: true,
                            noExternalResolve: true, target: 'ES5'}
                          ));

   return merge([
      tsResult.dts.pipe(gulp.dest('Plugins/release')),
      tsResult.js.pipe(gulp.dest('Plugins/release'))
      ]);
});

 /* Compile less files to their css respective files
 */
gulp.task('less-to-css-plugins', function() {
  return gulp.src(['Plugins/Vorlon/**/*.less'], { base : '.' })
    .pipe(less())
    .pipe(gulp.dest(''));
});

/**
 * Concat all js files in order into one big js file and minify it.
 * Do not hesitate to update it if you need to add your own files.
 */
gulp.task('scripts-noplugin-plugins', ['typescript-to-js-plugins'], function() {
    return gulp.src([
            'Plugins/libs/css.js',
            'Plugins/release/vorlon.tools.js',
            'Plugins/release/vorlon.enums.js',
            'Plugins/release/vorlon.basePlugin.js',
            'Plugins/release/vorlon.clientPlugin.js',
            'Plugins/release/vorlon.dashboardPlugin.js',
            'Plugins/release/vorlon.clientMessenger.js',
            'Plugins/release/vorlon.core.js'
        ])
        .pipe(concat('vorlon-noplugin.max.js'))
        .pipe(gulp.dest('Plugins/release/'))
        .pipe(rename('vorlon-noplugin.js'))
        .pipe(uglify())
        .pipe(gulp.dest('Plugins/release/'));
});

gulp.task('concat-webstandards-rules-plugins', ['typescript-to-js-plugins'], function () {
	return gulp.src(['./Plugins/release/**/webstandards/rules/*.js', './Plugins/release/**/webstandards/client.js'])
		.pipe(concat('vorlon.webstandards.client.js'))
		.pipe(gulp.dest('Plugins/release/plugins/webstandards/'));
});

/**
 * Specific task that need to be handled for specific plugins.
 * Do not hesitate to update it if you need to add your own files
 */
gulp.task('scripts-specific-plugins-plugins', function() {
    // Babylon Inspector
    gulp.src([
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.interfaces.js',
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.client.js'
    ])
        .pipe(concat('vorlon.babylonInspector.client.min.js'))
        .pipe(gulp.dest('Plugins/release/plugins/babylonInspector/'));

    return gulp.src([
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.interfaces.js',
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.dashboard.js'
    ])
        .pipe(concat('vorlon.babylonInspector.dashboard.min.js'))
        .pipe(gulp.dest('Plugins/release/plugins/babylonInspector/'));

});

/**
 * Minify all plugins.
 * Do not hesitate to update it if you need to add your own files.
 */
gulp.task('scripts-plugins', ['concat-webstandards-rules-plugins'], function () {

    gulp.start('scripts-specific-plugins-plugins');

    return gulp.src([
            './Plugins/**/vorlon.interactiveConsole.interfaces.js',
            './Plugins/**/vorlon.interactiveConsole.client.js',
            './Plugins/**/vorlon.interactiveConsole.dashboard.js',
            './Plugins/**/vorlon.domExplorer.interfaces.js',
            './Plugins/**/vorlon.domExplorer.client.js',
            './Plugins/**/vorlon.domExplorer.dashboard.js',
            './Plugins/**/vorlon.modernizrReport.interfaces.js',
            './Plugins/**/vorlon.modernizrReport.client.js',
            './Plugins/**/vorlon.modernizrReport.dashboard.js',
            './Plugins/**/objectExplorer/vorlon.objectExplorer.interfaces.js',
            './Plugins/**/objectExplorer/vorlon.objectExplorer.client.js',
            './Plugins/**/objectExplorer/vorlon.objectExplorer.dashboard.js',
            './Plugins/**/xhrPanel/vorlon.xhrPanel.interfaces.js',
            './Plugins/**/xhrPanel/vorlon.xhrPanel.client.js',
            './Plugins/**/xhrPanel/vorlon.xhrPanel.dashboard.js',
            './Plugins/**/vorlon.ngInspector.interfaces.js',
            './Plugins/**/vorlon.ngInspector.client.js',
            './Plugins/**/vorlon.ngInspector.dashboard.js',
            './Plugins/**/networkMonitor/vorlon.networkMonitor.interfaces.js',
            './Plugins/**/networkMonitor/vorlon.networkMonitor.client.js',
            './Plugins/**/networkMonitor/vorlon.networkMonitor.dashboard.js',
            './Plugins/**/resourcesExplorer/vorlon.resourcesExplorer.interfaces.js',
            './Plugins/**/resourcesExplorer/vorlon.resourcesExplorer.client.js',
            './Plugins/**/resourcesExplorer/vorlon.resourcesExplorer.dashboard.js',
            './Plugins/**/unitTestRunner/vorlon.unitTestRunner.interfaces.js',
            './Plugins/**/unitTestRunner/vorlon.unitTestRunner.client.js',
            './Plugins/**/unitTestRunner/vorlon.unitTestRunner.dashboard.js',
            './Plugins/**/sample/vorlon.sample.client.js',
            './Plugins/**/sample/vorlon.sample.dashboard.js',
            './Plugins/**/device/vorlon.device.interfaces.js',
            './Plugins/**/device/vorlon.device.client.js',
            './Plugins/**/device/vorlon.device.dashboard.js',
            './Plugins/**/webstandards/vorlon.webstandards.client.js',
            './Plugins/**/webstandards/vorlon.webstandards.interfaces.js',
            './Plugins/**/webstandards/vorlon.webstandards.dashboard.js'
        ])
        .pipe(rename(function (path) {
                path.extname = ".min.js";
              })
            )
/*   .pipe(uglify())*/
        .pipe(gulp.dest('./Plugins'));
});

/**
 * Move all files from Plugins to Server
 */
gulp.task('copy-plugins', function () {

    return gulp.src([
            'Plugins/release/vorlon-noplugin.max.js',
            'Plugins/release/vorlon-noplugin.js'
        ])
        .pipe(gulp.dest('./Server/public/vorlon'));

});

gulp.task('copyPlugins-plugins', function () {

   return  gulp.src([
          'Plugins/Vorlon/plugins/**/*.js',
          'Plugins/Vorlon/plugins/**/*.css',
          'Plugins/Vorlon/plugins/**/*.html',
          'Plugins/Vorlon/plugins/**/*.png',
          'Plugins/release/plugins/**/*.js'
    ])
        .pipe(gulp.dest('./Server/public/vorlon/plugins'));

});

gulp.task('copyDTS-plugins', function () {

    return  gulp.src(['Plugins/release/*.d.ts'])
      .pipe(gulp.dest('./Server/Scripts/typings/Vorlon'));

});

/**
 * The default task, call the tasks: scripts, scripts-noplugin, copy, copyPlugins
 */
gulp.task('default-plugins', ['scripts-plugins', 'scripts-noplugin-plugins', 'less-to-css-plugins'], function() {
    return gulp.start('copy-plugins', 'copyPlugins-plugins', 'copyDTS-plugins');
});

/**
 * Watch task, will call the default task if a js file is updated.
 */
//gulp.task('watch', function() {
//  gulp.watch('src/**/*.js', ['default']);
//});

/**
 * Watch typescript task, will call the default typescript task if a typescript file is updated.
 */
gulp.task('watch-plugins', function() {
  return gulp.watch([
    'Plugins/Vorlon/**/*.ts',
    'Plugins/Vorlon/**/*.less',
    'Plugins/Vorlon/**/*.html'
    //'Vorlon/plugins/**/*.*',
  ], ['default-plugins']);
});

/**
 * Web server task to serve a local test page
 */
gulp.task('webserver', function() {
  return gulp.src('Plugins/samples')
    .pipe(webserver({
      livereload: false,
      open: 'http://localhost:1338/index.html',
      port: 1338,
      fallback: 'index.html'
    }));
});

//****

// SERVER PART

// ***

gulp.task('typescript-to-js-server', function() {
  var tsResult = gulp.src(['./Server/**/*.ts', '!./Server/node_modules', '!./Server/node_modules/**'], { base: './' })
                      .pipe(typescript({ noExternalResolve: true, target: 'ES5', module: 'commonjs' }));

  return tsResult.js
            .pipe(gulp.dest('.'));
});

gulp.task('build-server', ['typescript-to-js-server'], function() {
	//copy server files to desktop app
  return gulp.src([
  		'./config.json',
  		'cert/**',
  		'config/**',
  		'public/**',
  		'Scripts/**',
  		'views/**',
  	], { base: './Plugins' })
  	.pipe(gulp.dest('./desktop/app/vorlon'));
});

gulp.task('default-server', ['build-server'], function() {
});

/**
 * Watch typescript task, will call the default typescript task if a typescript file is updated.
 */
gulp.task('watch-server', function() {
  gulp.watch([
    './Server/**/*.ts',
  ], ['default-server']);
});

gulp.task('watch', function() {
  gulp.run("watch-server");
  gulp.run("watch-plugins");
  gulp.run("webserver");
});<commit_msg>fixing build process (minification and bundling for interfaces needed on prod)<commit_after>var gulp = require('gulp'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    typescript = require('gulp-typescript'),
    merge = require('merge2'),
    webserver = require('gulp-webserver'),
    less = require('gulp-less'),
    gulputil = require('gulp-util'),
    gulpFilter = require('gulp-filter');

/// ********

/// GLOBAL

gulp.task('default', function(){
  return gulp.start('default-server-all');
});

gulp.task('default-server-all', ['default-plugins', 'copyDTS-plugins'], function(){
  return gulp.start('default-server');
});

//// *****

//****

// PLUGIN PART

// ***

/**
 * Compile typescript files to their js respective files
 */
gulp.task('typescript-to-js-plugins', function() {
  //Compile all ts file into their respective js file.

  var tsResult = gulp.src(['Plugins/Vorlon/**/*.ts', 'Plugins/libs/**.ts'])
                       .pipe(typescript({
                            declarationFiles: true,
                            noExternalResolve: true, target: 'ES5'}
                          ));

   return merge([
      tsResult.dts.pipe(gulp.dest('Plugins/release')),
      tsResult.js.pipe(gulp.dest('Plugins/release'))
      ]);
});

 /* Compile less files to their css respective files
 */
gulp.task('less-to-css-plugins', function() {
  return gulp.src(['Plugins/Vorlon/**/*.less'], { base : '.' })
    .pipe(less())
    .pipe(gulp.dest(''));
});

/**
 * Concat all js files in order into one big js file and minify it.
 * Do not hesitate to update it if you need to add your own files.
 */
gulp.task('scripts-noplugin-plugins', ['typescript-to-js-plugins'], function() {
    return gulp.src([
            'Plugins/libs/css.js',
            'Plugins/release/vorlon.tools.js',
            'Plugins/release/vorlon.enums.js',
            'Plugins/release/vorlon.basePlugin.js',
            'Plugins/release/vorlon.clientPlugin.js',
            'Plugins/release/vorlon.dashboardPlugin.js',
            'Plugins/release/vorlon.clientMessenger.js',
            'Plugins/release/vorlon.core.js'
        ])
        .pipe(concat('vorlon-noplugin.max.js'))
        .pipe(gulp.dest('Plugins/release/'))
        .pipe(rename('vorlon-noplugin.js'))
        .pipe(uglify())
        .pipe(gulp.dest('Plugins/release/'));
});

gulp.task('concat-webstandards-rules-plugins', ['typescript-to-js-plugins'], function () {
	return gulp.src(['./Plugins/release/**/webstandards/rules/*.js', './Plugins/release/**/webstandards/client.js'])
		.pipe(concat('vorlon.webstandards.client.js'))
		.pipe(gulp.dest('Plugins/release/plugins/webstandards/'));
});

/**
 * Specific task that need to be handled for specific plugins.
 * Do not hesitate to update it if you need to add your own files
 */
gulp.task('scripts-specific-plugins-plugins', ['scripts-plugins'], function() {
    // Babylon Inspector
    gulp.src([
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.interfaces.js',
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.client.js'
    ])
        .pipe(concat('vorlon.babylonInspector.client.js'))
        .pipe(gulp.dest('Plugins/release/plugins/babylonInspector/'));

    gulp.src([
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.interfaces.js',
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.dashboard.js'
    ])
        .pipe(concat('vorlon.babylonInspector.dashboard.js'))
        .pipe(gulp.dest('Plugins/release/plugins/babylonInspector/'));

    gulp.src([
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.interfaces.min.js',
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.client.min.js'
    ])
        .pipe(concat('vorlon.babylonInspector.client.min.js'))
        .pipe(gulp.dest('Plugins/release/plugins/babylonInspector/'));

    gulp.src([
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.interfaces.min.js',
        'Plugins/release/plugins/babylonInspector/vorlon.babylonInspector.dashboard.min.js'
    ])
        .pipe(concat('vorlon.babylonInspector.dashboard.min.js'))
        .pipe(gulp.dest('Plugins/release/plugins/babylonInspector/'));

    // NG Inspector
    gulp.src([
        'Plugins/release/plugins/ngInspector/vorlon.ngInspector.interfaces.js',
        'Plugins/release/plugins/ngInspector/vorlon.ngInspector.client.js'
    ])
        .pipe(concat('vorlon.ngInspector.client.js'))
        .pipe(gulp.dest('Plugins/release/plugins/ngInspector/'));

    return gulp.src([
        'Plugins/release/plugins/ngInspector/vorlon.ngInspector.interfaces.js',
        'Plugins/release/plugins/ngInspector/vorlon.ngInspector.dashboard.js'
    ])
        .pipe(concat('vorlon.ngInspector.dashboard.js'))
        .pipe(gulp.dest('Plugins/release/plugins/ngInspector/'));

    gulp.src([
        'Plugins/release/plugins/ngInspector/vorlon.ngInspector.interfaces.min.js',
        'Plugins/release/plugins/ngInspector/vorlon.ngInspector.client.min.js'
    ])
        .pipe(concat('vorlon.ngInspector.client.min.js'))
        .pipe(gulp.dest('Plugins/release/plugins/ngInspector/'));

    return gulp.src([
        'Plugins/release/plugins/ngInspector/vorlon.ngInspector.interfaces.min.js',
        'Plugins/release/plugins/ngInspector/vorlon.ngInspector.dashboard.min.js'
    ])
        .pipe(concat('vorlon.ngInspector.dashboard.min.js'))
        .pipe(gulp.dest('Plugins/release/plugins/ngInspector/'));

});

/**
 * Minify all plugins.
 * Do not hesitate to update it if you need to add your own files.
 */
gulp.task('scripts-plugins', ['concat-webstandards-rules-plugins'], function () {

    return gulp.src([
            './Plugins/**/vorlon.interactiveConsole.interfaces.js',
            './Plugins/**/vorlon.interactiveConsole.client.js',
            './Plugins/**/vorlon.interactiveConsole.dashboard.js',
            './Plugins/**/vorlon.domExplorer.interfaces.js',
            './Plugins/**/vorlon.domExplorer.client.js',
            './Plugins/**/vorlon.domExplorer.dashboard.js',
            './Plugins/**/vorlon.modernizrReport.interfaces.js',
            './Plugins/**/vorlon.modernizrReport.client.js',
            './Plugins/**/vorlon.modernizrReport.dashboard.js',
            './Plugins/**/objectExplorer/vorlon.objectExplorer.interfaces.js',
            './Plugins/**/objectExplorer/vorlon.objectExplorer.client.js',
            './Plugins/**/objectExplorer/vorlon.objectExplorer.dashboard.js',
            './Plugins/**/xhrPanel/vorlon.xhrPanel.interfaces.js',
            './Plugins/**/xhrPanel/vorlon.xhrPanel.client.js',
            './Plugins/**/xhrPanel/vorlon.xhrPanel.dashboard.js',
            './Plugins/**/vorlon.ngInspector.interfaces.js',
            './Plugins/**/vorlon.ngInspector.client.js',
            './Plugins/**/vorlon.ngInspector.dashboard.js',
            './Plugins/**/networkMonitor/vorlon.networkMonitor.interfaces.js',
            './Plugins/**/networkMonitor/vorlon.networkMonitor.client.js',
            './Plugins/**/networkMonitor/vorlon.networkMonitor.dashboard.js',
            './Plugins/**/resourcesExplorer/vorlon.resourcesExplorer.interfaces.js',
            './Plugins/**/resourcesExplorer/vorlon.resourcesExplorer.client.js',
            './Plugins/**/resourcesExplorer/vorlon.resourcesExplorer.dashboard.js',
            './Plugins/**/unitTestRunner/vorlon.unitTestRunner.interfaces.js',
            './Plugins/**/unitTestRunner/vorlon.unitTestRunner.client.js',
            './Plugins/**/unitTestRunner/vorlon.unitTestRunner.dashboard.js',
            './Plugins/**/sample/vorlon.sample.client.js',
            './Plugins/**/sample/vorlon.sample.dashboard.js',
            './Plugins/**/device/vorlon.device.interfaces.js',
            './Plugins/**/device/vorlon.device.client.js',
            './Plugins/**/device/vorlon.device.dashboard.js',
            './Plugins/**/webstandards/vorlon.webstandards.client.js',
            './Plugins/**/webstandards/vorlon.webstandards.interfaces.js',
            './Plugins/**/webstandards/vorlon.webstandards.dashboard.js',
            './Plugins/**/babylonInspector/vorlon.babylonInspector.client.js',
            './Plugins/**/babylonInspector/vorlon.babylonInspector.interfaces.js',
            './Plugins/**/babylonInspector/vorlon.babylonInspector.dashboard.js'
        ])
        .pipe(rename(function (path) {
                path.extname = ".min.js";
              })
            )
        .pipe(uglify())
        .pipe(gulp.dest('./Plugins'));
});

/**
 * Move all files from Plugins to Server
 */
gulp.task('copy-plugins', function () {

    return gulp.src([
            'Plugins/release/vorlon-noplugin.max.js',
            'Plugins/release/vorlon-noplugin.js'
        ])
        .pipe(gulp.dest('./Server/public/vorlon'));

});

gulp.task('copyPlugins-plugins', function () {

   return  gulp.src([
          'Plugins/Vorlon/plugins/**/*.js',
          'Plugins/Vorlon/plugins/**/*.css',
          'Plugins/Vorlon/plugins/**/*.html',
          'Plugins/Vorlon/plugins/**/*.png',
          'Plugins/release/plugins/**/*.js'
    ])
        .pipe(gulp.dest('./Server/public/vorlon/plugins'));

});

gulp.task('copyDTS-plugins', function () {

    return  gulp.src(['Plugins/release/*.d.ts'])
      .pipe(gulp.dest('./Server/Scripts/typings/Vorlon'));

});

/**
 * The default task, call the tasks: scripts, scripts-noplugin, copy, copyPlugins
 */
gulp.task('default-plugins', ['scripts-plugins', 'scripts-noplugin-plugins', 'less-to-css-plugins', 'scripts-specific-plugins-plugins'], function() {
    return gulp.start('copy-plugins', 'copyPlugins-plugins', 'copyDTS-plugins');
});

/**
 * Watch task, will call the default task if a js file is updated.
 */
//gulp.task('watch', function() {
//  gulp.watch('src/**/*.js', ['default']);
//});

/**
 * Watch typescript task, will call the default typescript task if a typescript file is updated.
 */
gulp.task('watch-plugins', function() {
  return gulp.watch([
    'Plugins/Vorlon/**/*.ts',
    'Plugins/Vorlon/**/*.less',
    'Plugins/Vorlon/**/*.html'
    //'Vorlon/plugins/**/*.*',
  ], ['default-plugins']);
});

/**
 * Web server task to serve a local test page
 */
gulp.task('webserver', function() {
  return gulp.src('Plugins/samples')
    .pipe(webserver({
      livereload: false,
      open: 'http://localhost:1338/index.html',
      port: 1338,
      fallback: 'index.html'
    }));
});

//****

// SERVER PART

// ***

gulp.task('typescript-to-js-server', function() {
  var tsResult = gulp.src(['./Server/**/*.ts', '!./Server/node_modules', '!./Server/node_modules/**'], { base: './' })
                      .pipe(typescript({ noExternalResolve: true, target: 'ES5', module: 'commonjs' }));

  return tsResult.js
            .pipe(gulp.dest('.'));
});

gulp.task('build-server', ['typescript-to-js-server'], function() {
	//copy server files to desktop app
  return gulp.src([
  		'./config.json',
  		'cert/**',
  		'config/**',
  		'public/**',
  		'Scripts/**',
  		'views/**',
  	], { base: './Plugins' })
  	.pipe(gulp.dest('./desktop/app/vorlon'));
});

gulp.task('default-server', ['build-server'], function() {
});

/**
 * Watch typescript task, will call the default typescript task if a typescript file is updated.
 */
gulp.task('watch-server', function() {
  gulp.watch([
    './Server/**/*.ts',
  ], ['default-server']);
});

gulp.task('watch', function() {
  gulp.run("watch-server");
  gulp.run("watch-plugins");
  gulp.run("webserver");
});<|endoftext|>


<commit_before>'use strict';

// Include gulp
let gulp = require('gulp');

// Include Plugins
let clean = require('gulp-clean');
let jshint = require('gulp-jshint');
let uglify = require('gulp-uglify');
let rename = require('gulp-rename');
let sourcemaps = require('gulp-sourcemaps');
let filter = require('gulp-filter');
let merge = require('merge-stream');
let jasmine = require('gulp-jasmine');
let karmaServer = require('karma').Server;

let pathToKarmaConf = __dirname + '/test/conf/';

let config = {
  src: './src/',
  dest: './dist/'
};

// Clean dist folder
gulp.task('clean', function () {
    return gulp.src(config.dest)
		.pipe(clean());
});

// Lint Task
gulp.task('jshint', ['clean'], function() {
    return gulp.src(config.src + '*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

// Minify JS
gulp.task('scripts', ['jshint'], function() {
    return gulp.src(config.src + '*.js')
		.pipe(sourcemaps.init())
		.pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(config.dest))
		.pipe(filter('**/*.js')) // only let JavaScript files through here
        .pipe(rename({ extname: '.min.js' }))
        .pipe(uglify())
		.pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(config.dest));
});

// Clean tests lib folder
gulp.task('clean-tests-lib', function () {
    return gulp.src('test/lib/')
		.pipe(clean());
});

// Copy test lib
gulp.task('copy-tests-lib', ['clean-tests-lib'], function() {
	let componentsPath = "bower_components/";
	let testsLibPath = "test/lib/";
	return merge(
		gulp.src(componentsPath + 'jasmine/lib/jasmine-core/*')
			.pipe(gulp.dest(testsLibPath + 'jasmine')),
		gulp.src(componentsPath + 'jasmine/images/*')
			.pipe(gulp.dest(testsLibPath + 'jasmine')),
		gulp.src(componentsPath + 'jquery/dist/*.js')
			.pipe(gulp.dest(testsLibPath + 'jquery')),
		gulp.src(componentsPath + 'angular/*.js')
			.pipe(gulp.dest(testsLibPath + 'angular')),
		gulp.src(componentsPath + 'angular-mocks/*.js')
			.pipe(gulp.dest(testsLibPath + 'angular-mocks'))
	);
});

gulp.task('test', function (done) {
  return new karmaServer({
    configFile: pathToKarmaConf + 'karma.conf.js',
    singleRun: true
  }, done).start();
});

/*
gulp.task('test', function() {
  // Be sure to return the stream
  // NOTE: Using the fake './foobar' so as to run the files
  // listed in karma.conf.js INSTEAD of what was passed to
  // gulp.src !
  return gulp.src('./foobar')
    .pipe(karma({
      configFile: pathToKarmaConf + 'karma.conf.js',
      action: 'run'
    }))
    .on('error', function(err) {
      // Make sure failed tests cause gulp to exit non-zero
      console.log(err);
      this.emit('end'); //instead of erroring the stream, end it
    });
});
*/

// Default Task
gulp.task('default', ['scripts', 'copy-tests-lib']);<commit_msg>modify gulpfile.js to not use ES6<commit_after>'use strict';

// Include gulp
var gulp = require('gulp');

// Include Plugins
var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var filter = require('gulp-filter');
var merge = require('merge-stream');
var jasmine = require('gulp-jasmine');
var karmaServer = require('karma').Server;

var pathToKarmaConf = __dirname + '/test/conf/';

var config = {
  src: './src/',
  dest: './dist/'
};

// Clean dist folder
gulp.task('clean', function () {
    return gulp.src(config.dest)
		.pipe(clean());
});

// Lint Task
gulp.task('jshint', ['clean'], function() {
    return gulp.src(config.src + '*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

// Minify JS
gulp.task('scripts', ['jshint'], function() {
    return gulp.src(config.src + '*.js')
		.pipe(sourcemaps.init())
		.pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(config.dest))
		.pipe(filter('**/*.js')) // only let JavaScript files through here
        .pipe(rename({ extname: '.min.js' }))
        .pipe(uglify())
		.pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(config.dest));
});

// Clean tests lib folder
gulp.task('clean-tests-lib', function () {
    return gulp.src('test/lib/')
		.pipe(clean());
});

// Copy test lib
gulp.task('copy-tests-lib', ['clean-tests-lib'], function() {
	var componentsPath = "bower_components/";
	var testsLibPath = "test/lib/";
	return merge(
		gulp.src(componentsPath + 'jasmine/lib/jasmine-core/*')
			.pipe(gulp.dest(testsLibPath + 'jasmine')),
		gulp.src(componentsPath + 'jasmine/images/*')
			.pipe(gulp.dest(testsLibPath + 'jasmine')),
		gulp.src(componentsPath + 'jquery/dist/*.js')
			.pipe(gulp.dest(testsLibPath + 'jquery')),
		gulp.src(componentsPath + 'angular/*.js')
			.pipe(gulp.dest(testsLibPath + 'angular')),
		gulp.src(componentsPath + 'angular-mocks/*.js')
			.pipe(gulp.dest(testsLibPath + 'angular-mocks'))
	);
});

// Test task (run Karma)
gulp.task('test', function (done) {
  return new karmaServer({
    configFile: pathToKarmaConf + 'karma.conf.js',
    singleRun: true
  }, done).start();
});

// Default Task
gulp.task('default', ['scripts', 'copy-tests-lib']);<|endoftext|>


<commit_before>var gulp = require('gulp'),
	autoprefix = require('gulp-autoprefixer'),
	cleanCSS = require('gulp-clean-css'),
	less = require('gulp-less'),
	livereload = require('gulp-livereload'),
	sourcemaps = require('gulp-sourcemaps'),
	watch = require('gulp-watch');

gulp.task('less', function() {
	gulp.src('styles/docs-default.less')
		.pipe(sourcemaps.init())
		.pipe(less())
		// .pipe(cleanCSS())
		.pipe(autoprefix('last 2 version'))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('static/css/'))
		.pipe(livereload())
});

gulp.task('watch', function () {
	livereload.listen();
	gulp.watch('styles/*.less', ['less']);
});<commit_msg>Turning on minification<commit_after>var gulp = require('gulp'),
	autoprefix = require('gulp-autoprefixer'),
	cleanCSS = require('gulp-clean-css'),
	less = require('gulp-less'),
	livereload = require('gulp-livereload'),
	sourcemaps = require('gulp-sourcemaps'),
	watch = require('gulp-watch');

gulp.task('less', function() {
	gulp.src('styles/docs-default.less')
		.pipe(sourcemaps.init())
		.pipe(less())
		.pipe(cleanCSS())
		.pipe(autoprefix('last 2 version'))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest('static/css/'))
		.pipe(livereload())
});

gulp.task('watch', function () {
	livereload.listen();
	gulp.watch('styles/*.less', ['less']);
});<|endoftext|>


<commit_before>( function() {

    "use strict";

    var gulp = require('gulp'),
        runSequence = require('run-sequence'),
        source;

    function bundle( b, output ) {
        source = source || require('vinyl-source-stream');
        return b.bundle()
            .on( 'error', function( err ) {
                console.log( err );
                this.emit( 'end' );
            })
            .pipe( source( output ) )
            .pipe( gulp.dest( 'build' ) );
    }

    function bundleMin( b, output ) {
        var buffer = require('vinyl-buffer'),
            uglify = require('gulp-uglify');
        source = source || require('vinyl-source-stream');
        return b.bundle()
            .on( 'error', function( err ) {
                console.log( err );
                this.emit( 'end' );
            })
            .pipe( source( output ) )
            .pipe( buffer() )
            .pipe( uglify() )
            .pipe( gulp.dest( 'build' ) );
    }

    function build( root, output, minify ) {
        var browserify = require('browserify'),
            b = browserify( root, {
                debug: !minify,
                standalone: 'alfador'
            });
        if ( minify ) {
            return bundleMin( b, output );
        } else {
            return bundle( b, output );
        }
    }

    function handleError( err ) {
        console.error( err.toString() );
        setTimeout( function() {
            // set delay for full mocha error message
            process.exit( 1 );
        });
    }

    gulp.task('clean', function () {
        var del = require('del');
        del([ 'build/*']);
    });

    gulp.task('lint', function() {
        var jshint = require('gulp-jshint');
        return gulp.src( [ './src/**/*.js', './test/**/*.js' ] )
            .pipe( jshint() )
            .pipe( jshint('.jshintrc') )
            .pipe( jshint.reporter('jshint-stylish') );
    });

    gulp.task('test', function() {
        var istanbul = require('gulp-istanbul'),
            mocha = require('gulp-mocha');
        return gulp.src( './src/*.js' )
            .pipe( istanbul( { includeUntested: false } ) ) // Covering files
            .pipe( istanbul.hookRequire() )
            .on( 'finish', function () {
                return gulp.src( [ './test/*.js' ] )
                    .pipe( mocha( { reporter: 'list' } )
                        .on( 'error', handleError ) ) // print mocha error message
                    .pipe( istanbul.writeReports() ); // Creating the reports after tests runned
            });
    });

    gulp.task('coveralls', function() {
        var coveralls = require('gulp-coveralls');
        return gulp.src('./coverage/**/lcov.info')
            .pipe( coveralls() );
    });

    gulp.task('build-min-js', function() {
        return build( './src/exports.js', 'alfador.min.js', true, false );
    });

    gulp.task('build-js', function() {
        return build( './src/exports.js', 'alfador.js', false, false );
    });

    gulp.task('build', function( done ) {
        runSequence(
            [ 'clean', 'lint' ],
            [ 'build-js', 'build-min-js' ],
            done );
    });

    gulp.task('default', [ 'build' ], function() {
    });

}());
<commit_msg>Refactored gulpfile.<commit_after>( function() {

    'use strict';

    var gulp = require('gulp');
    var runSequence = require('run-sequence');
    var uglify = require('gulp-uglify');
    var buffer = require('vinyl-buffer');
    var source = require('vinyl-source-stream');
    var browserify = require('browserify');
    var istanbul = require('gulp-istanbul');
    var mocha = require('gulp-mocha');
    var del = require('del');
    var jshint = require('gulp-jshint');
    var coveralls = require('gulp-coveralls');

    var project = 'alfador';
    var paths = {
        root: 'src/exports.js',
        src: 'src/**/*.js',
        tests: 'test/**/*.js',
        build: 'build'
    };

    function handleError( err ) {
        console.error( err );
        this.emit( 'end' );
    }

    function handleErrorTimeout( err ) {
        console.error( err );
        setTimeout( function() {
            // set delay for full mocha error message
            process.exit( 1 );
        });
    }

    function bundle( b, output ) {
        return b.bundle()
            .on( 'error', handleError )
            .pipe( source( output ) )
            .pipe( gulp.dest( paths.build ) );
    }

    function bundleMin( b, output ) {
        return b.bundle()
            .on( 'error', handleError )
            .pipe( source( output ) )
            .pipe( buffer() )
            .pipe( uglify() )
            .pipe( gulp.dest( paths.build ) );
    }

    function build( root, output, minify ) {
        var b = browserify( root, {
            debug: !minify,
            standalone: project
        });
        return ( minify ) ? bundleMin( b, output ) : bundle( b, output );
    }

    gulp.task('clean', function () {
        del([ 'build/*']);
    });

    gulp.task('lint', function() {
        return gulp.src( paths.src )
            .pipe( jshint('.jshintrc') )
            .pipe( jshint.reporter('jshint-stylish') );
    });

    gulp.task('test', function() {
        return gulp.src( paths.src )
            .pipe( istanbul({ includeUntested: false }) ) // Covering files
            .pipe( istanbul.hookRequire() )
            .on( 'finish', function () {
                return gulp.src([ paths.tests ])
                    .pipe( mocha({ reporter: 'list' })
                        .on( 'error', handleErrorTimeout ) ) // print mocha error message
                    .pipe( istanbul.writeReports() ); // Creating the reports after tests runned
            });
    });

    gulp.task('coveralls', function() {
        return gulp.src('./coverage/**/lcov.info')
            .pipe( coveralls() );
    });

    gulp.task('build-min-js', function() {
        return build( paths.root, project + '.min.js', true );
    });

    gulp.task('build-js', function() {
        return build( paths.root, project + '.js', false );
    });

    gulp.task('build', function( done ) {
        runSequence(
            [ 'clean', 'lint' ],
            [ 'build-js', 'build-min-js' ],
            done );
    });

    gulp.task('default', [ 'build' ], function() {
    });

}());
<|endoftext|>


<commit_before>const style = {
  flexColumn: {
    display: 'flex',
    flexDirection: 'column',

  },
  flexRow: {
    display: 'flex',

  },
  h1: {
    width: '99vw',
    justifyContent: 'center',
    textAlign: 'center',
  },
  logo: {
    justifyContent: 'center',
    textAlign: 'center',
    fontSize: '25px',
  },
  warningShow: {
    fontSize: '18px',
    fontFamily: 'Ubuntu Medium',
    fontWeight: 'bold',
    color: 'rgba(130, 11, 11, 0.89)',
    textAlign: 'center',
  },
  buttonWrapper: {
    display: 'flex',
  },
  warningNotShow: {
    display: 'none',
  },
  scheduleAdd: {
    display: 'block',
    marginTop:'0.5%',
    marginLeft:'2%',
    marginBottom:'0.5%',

    },
  inputs: {

  },
  classInput: {
    fontSize: '12px',
    fontFamily: 'ruly',
    color: '#062520',
  },
  timeInput: {

  },
  dayInput: {

  },
  homeworkInput: {
    fontSize: '12px',
    fontFamily: 'ruly',
    color: '#062520',
  },
  buttonDate: {
    minWidth: '80px',
    height: '25px',
    fontSize: '14px',
    padding: '0 25px',
    lineHeight: '25px',
    letterSpacing: '1px',
    color: '#fff',
    fontWeight: '500',
    backgroundColor: '#0a3461',
    border: 'solid rgba(53, 53, 53, 0)',
    borderWidth: '4px 4px 4px 4px',
    borderRadius: '8px 8px 8px 8px',
  },
  eventBox: {
    border: '2px solid #062520',
    width: 'calc(100% / 8)',
    textAlign: 'center',
    },
    eventli: {
    height: '30px',
    border: '1px solid #062520',
    background:'rgba(44, 91, 105, 0.81)',
    margin:'1px',
  },
  eventul: {
    listStyleType: 'none',
  },
  daysContainer: {
    display: 'flex',
  },
  flexColumn: {
    display: 'flex',
    flexDirection: 'column',
  },
  mainSchedule: {
    display: 'flex',
    height: '85vh',
  },
  timeSchedule: {
    border: '2px solid #062520',
    width: '65%',
    height: '100%',
    overflowY: 'scroll',
    marginLeft: '2%',
  },
  homeworkTab: {
    border: '5px solid #062520',
    width: '30%',
    height: '100%',
    display: 'flex',
    flexDirection: 'column',
    textAlign: 'center',
    marginLeft: '1%',
    background: 'rgba(241, 241, 89, 0.81)',
  },

  homeworkItem: {
    fontSize: '14px',
    fontWeight:'bold',
    color: '#03695f',
    textDecoration:'blink',

  },
  homeworkLogo: {
    fontSize: '32px',
    fontFamily: 'Ubuntu Medium',
    fontStyle: 'oblique',
  },
  dontShow: {
    display: 'none',
  },
  boxClose: {
    float: 'right',
    cursor: 'pointer',
    color: '#fff',
    border: '1px solid #AEAEAE',
    borderRadius: '30px',
    background: '#605F61',
    fontSize: '31px',
    fontWeight: 'bold',
    display: 'inline-block',
    lineHeight: '0px',
    padding: '11px 3px',}
};
module.exports = style;
<commit_msg>cuter delete button and margin/font update<commit_after>const style = {
  flexColumn: {
    display: 'flex',
    flexDirection: 'column',

  },
  flexRow: {
    display: 'flex',

  },

    logo: {
    justifyContent: 'center',
    textAlign: 'center',
    fontSize: '25px',
  },
  warningShow: {
    fontSize: '18px',
    fontFamily: 'Ubuntu Medium',
    fontWeight: 'bold',
    color: 'rgba(130, 11, 11, 0.89)',
    textAlign: 'center',
  },
  buttonWrapper: {
    display: 'flex',
  },
  warningNotShow: {
    display: 'none',
  },
  scheduleAdd: {
    display: 'block',
    marginTop:'0.5%',
    marginLeft:'1%',
    marginBottom:'0.5%',

    },
  inputs: {

  },
  classInput: {
    fontSize: '15px',
    fontFamily: 'ruly',
    color: '#062520',
  },
  timeInput: {

  },
  dayInput: {

  },
  homeworkInput: {
    fontSize: '15px',
    fontFamily: 'ruly',
    color: '#062520',
  },
  buttonDate: {
    minWidth: '80px',
    height: '25px',
    fontSize: '15px',
    padding: '0 25px',
    lineHeight: '25px',
    letterSpacing: '1px',
    color: '#fff',
    fontWeight: '500',
    backgroundColor: '#0a3461',
    border: 'solid rgba(53, 53, 53, 0)',
    borderWidth: '4px 4px 4px 4px',
    borderRadius: '8px 8px 8px 8px',
  },
  eventBox: {
    border: '2px solid #062520',
    width: 'calc(100% / 8)',
    textAlign: 'center',
    },
    eventli: {
    height: '30px',
    border: '1px solid #062520',
    background:'rgba(44, 91, 105, 0.81)',
    margin:'1px',
    font: 'Lato',
    fontSize: '14px',
  },
  eventul: {
    listStyleType: 'none',
  },
  daysContainer: {
    display: 'flex',
  },
  flexColumn: {
    display: 'flex',
    flexDirection: 'column',
  },
  mainSchedule: {
    display: 'flex',
    height: '85vh',
  },
  timeSchedule: {
    border: '2px solid #062520',
    width: '67%',
    height: '100%',
    overflowY: 'scroll',
    marginLeft: '1%',
  },
  homeworkTab: {
    border: '5px solid #062520',
    width: '30%',
    height: '100%',
    display: 'flex',
    flexDirection: 'column',
    textAlign: 'center',
    marginLeft: '1%',
    background: 'rgba(241, 241, 89, 0.81)',
  },

  homeworkItem: {
    fontSize: '14px',
    fontWeight:'bold',
    color: '#03695f',
    textDecoration:'blink',

  },
  homeworkLogo: {
    fontSize: '32px',
    fontFamily: 'Ubuntu Medium',
    fontStyle: 'oblique',
  },
  dontShow: {
    display: 'none',
  },
  boxClose: {
    float: 'right',
    height: '13px',
    width:'40px',
    cursor: 'pointer',
    color: 'rgba(189, 216, 91, 0.87)',
    border: '2px solid rgba(32, 61, 86, 0.42)',
    borderRadius: '15px',
    background: 'rgba(0, 0, 0, 0.82)',
    fontSize: '23.5px',
    font: 'Lucida Consola',
    fontWeight: 'bold',
    display: 'inline-block',
    lineHeight: '0px',
    padding: '8px 8px',
    marginBottom: '1px',
  }
};
module.exports = style;
<|endoftext|>


<commit_before>'use strict';

var gulp    = require('gulp');
var plugins = require('gulp-load-plugins')();
var extend  = require('xtend');
var argv    = require('yargs').argv;

gulp.task('lint', function () {
  gulp.src(['./src/**/*.js', './test/**/*.js', './gulpfile.js'])
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter('jshint-stylish'))
    .pipe(plugins.jshint.reporter('fail'));
});

var testConfig = {
  frameworks: ['browserify', 'mocha', 'chai-sinon'],
  files: [
    'node_modules/es5-shim/es5-shim.js',
    'node_modules/chai-as-promised/lib/chai-as-promised.js',
    'components/angular/angular.js',
    'components/angular-mocks/angular-mocks.js',
    'test/**/*.js'
  ],
  preprocessors: {
    'test/**/*.js': 'browserify'
  },
  browserify: {
    debug: true,
    transform: ['browserify-shim']
  },
  coverageReporter: {
    type: 'html',
    dir: './coverage',
    subdir: './'
  },
  reporters: ['progress', 'coverage'],
  browsers: ['PhantomJS'],
  singleRun: !!process.env.CI
};

gulp.task('test', function () {
  return require('karma-as-promised').server.start(extend({}, testConfig, {
    browserify: {
      debug: true,
      transform: ['browserify-istanbul', 'browserify-shim']
    },
    coverageReporter: {
      type: 'html',
      dir: './coverage',
      subdir: './'
    }
  }));
});

var launchers = require('./sauce.json');
gulp.task('sauce', function () {
  return require('karma-as-promised').server.start(extend({}, testConfig, {
    sauceLabs: {
      testName: 'Convex Unit Tests',
      startConnect: false,
      recordScreenshots: false,
      tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
    },
    transports: ['xhr-polling'],
    captureTimeout: 0,
    browserNoActivityTimeout: 120000,
    reporters: ['dots', 'saucelabs'],
    browsers: Object.keys(launchers),
    customLaunchers: launchers
  }));
});

gulp.task('bump', function () {
  gulp.src(['./package.json', './bower.json'])
    .pipe(plugins.bump({
      type: argv.type
    }))
    .pipe(gulp.dest('./'));
});
<commit_msg>Force exit process b/c karma-sauce-launcher doesn't clean up after itself<commit_after>'use strict';

var gulp    = require('gulp');
var plugins = require('gulp-load-plugins')();
var extend  = require('xtend');
var argv    = require('yargs').argv;

gulp.task('lint', function () {
  gulp.src(['./src/**/*.js', './test/**/*.js', './gulpfile.js'])
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter('jshint-stylish'))
    .pipe(plugins.jshint.reporter('fail'));
});

var testConfig = {
  frameworks: ['browserify', 'mocha', 'chai-sinon'],
  files: [
    'node_modules/es5-shim/es5-shim.js',
    'node_modules/chai-as-promised/lib/chai-as-promised.js',
    'components/angular/angular.js',
    'components/angular-mocks/angular-mocks.js',
    'test/**/*.js'
  ],
  preprocessors: {
    'test/**/*.js': 'browserify'
  },
  browserify: {
    debug: true,
    transform: ['browserify-shim']
  },
  coverageReporter: {
    type: 'html',
    dir: './coverage',
    subdir: './'
  },
  reporters: ['progress', 'coverage'],
  browsers: ['PhantomJS'],
  singleRun: !!process.env.CI
};

gulp.task('test', function () {
  return require('karma-as-promised').server.start(extend({}, testConfig, {
    browserify: {
      debug: true,
      transform: ['browserify-istanbul', 'browserify-shim']
    },
    coverageReporter: {
      type: 'html',
      dir: './coverage',
      subdir: './'
    }
  }));
});

var launchers = require('./sauce.json');
gulp.task('sauce', function () {
  return require('karma-as-promised').server.start(extend({}, testConfig, {
    sauceLabs: {
      testName: 'Convex Unit Tests',
      startConnect: false,
      recordScreenshots: false,
      tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
    },
    transports: ['xhr-polling'],
    captureTimeout: 0,
    browserNoActivityTimeout: 120000,
    reporters: ['dots', 'saucelabs'],
    browsers: Object.keys(launchers),
    customLaunchers: launchers
  }))
  .then(function () {
    process.exit(0);
  })
  .catch(function () {
    process.exit(1);
  });
});

gulp.task('bump', function () {
  gulp.src(['./package.json', './bower.json'])
    .pipe(plugins.bump({
      type: argv.type
    }))
    .pipe(gulp.dest('./'));
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var plugin = require("gulp-load-plugins")({
   pattern: ['gulp-*', 'gulp.*', 'main-bower-files'],
   replaceString: /\bgulp[\-.]/
});
var browserSync = require('browser-sync').create();

var root = "site/";
var destination = "dest/";
var paths = {
    watch: {
        scss: root + "**/*.scss",
        js:   root + "**/*.js",
        html: root + "**/*.html"
    },
    compile: {
        scss: root + "pages/**/*.scss",
        js:   root + "pages/**/*.js",
        html: root + "pages/**/*.html"
    }
};

// Compile Our Sass
gulp.task('scss', function() {
    return gulp.src(paths.compile.scss)
        .pipe(plugin.sass())
        .pipe(gulp.dest(destination))
        .pipe(browserSync.stream());
});

// Move our html to the destination folder
gulp.task('html', function() {
    return gulp.src(paths.compile.html)
        .pipe(gulp.dest(destination))
        .pipe(browserSync.stream());
})

// Concatenate & Minify JS
gulp.task('scripts', function() {
    return gulp.src(paths.compile.js)
        .pipe(gulp.dest(destination))
        .pipe(browserSync.stream());
});

// serve up the page on a browser
gulp.task('serve', function() {
    browserSync.init({
        server: {
            baseDir: destination
        },
        browser: "google chrome"
    });
    gulp.watch(paths.watch.js, gulp.series('scripts'));
    gulp.watch(paths.watch.scss, gulp.series('scss'));
    gulp.watch(paths.watch.html, gulp.series('html'));
});

// Watch Files For Changes
gulp.task('watch', function() {
    gulp.watch(paths.watch.js, gulp.series('scripts'));
    gulp.watch(paths.watch.scss, gulp.series('scss'));
});

//remove .DS_Store files
gulp.task('clean:ds', function() {
  return gulp.src(root+"/**/.DS_Store", { read: false })
    .pipe( plugin.clean() );
});

//remove the destination folder
gulp.task('clean:dest', function() {
   return gulp.src(destination, {read: false})
      .pipe(plugin.clean());
});

// Default Task
gulp.task('build', gulp.parallel('scss', 'scripts', 'html'));
gulp.task('clean', gulp.parallel('clean:ds', 'clean:dest'));
gulp.task('rebuild', gulp.series('clean', 'build'));

gulp.task('default', gulp.series('build', 'watch'));
<commit_msg>set gulps default task to build and serve<commit_after>var gulp = require('gulp');
var plugin = require("gulp-load-plugins")({
   pattern: ['gulp-*', 'gulp.*', 'main-bower-files'],
   replaceString: /\bgulp[\-.]/
});
var browserSync = require('browser-sync').create();

var root = "site/";
var destination = "dest/";
var paths = {
    watch: {
        scss: root + "**/*.scss",
        js:   root + "**/*.js",
        html: root + "**/*.html"
    },
    compile: {
        scss: root + "pages/**/*.scss",
        js:   root + "pages/**/*.js",
        html: root + "pages/**/*.html"
    }
};

// Compile Our Sass
gulp.task('scss', function() {
    return gulp.src(paths.compile.scss)
        .pipe(plugin.sass())
        .pipe(gulp.dest(destination))
        .pipe(browserSync.stream());
});

// Move our html to the destination folder
gulp.task('html', function() {
    return gulp.src(paths.compile.html)
        .pipe(gulp.dest(destination))
        .pipe(browserSync.stream());
});

// Concatenate & Minify JS
gulp.task('scripts', function() {
    return gulp.src(paths.compile.js)
        .pipe(gulp.dest(destination))
        .pipe(browserSync.stream());
});

// serve up the page on a browser
gulp.task('serve', function() {
    browserSync.init({
        server: {
            baseDir: destination
        },
        browser: "google chrome"
    });
    gulp.watch(paths.watch.js, gulp.series('scripts'));
    gulp.watch(paths.watch.scss, gulp.series('scss'));
    gulp.watch(paths.watch.html, gulp.series('html'));
});

// Watch Files For Changes
gulp.task('watch', function() {
    gulp.watch(paths.watch.js, gulp.series('scripts'));
    gulp.watch(paths.watch.scss, gulp.series('scss'));
    gulp.watch(paths.watch.html, gulp.series('html'));
});

//remove .DS_Store files
gulp.task('clean:ds', function() {
  return gulp.src(root+"/**/.DS_Store", { read: false })
    .pipe( plugin.clean() );
});

//remove the destination folder
gulp.task('clean:dest', function() {
   return gulp.src(destination, {read: false})
      .pipe(plugin.clean());
});

// Default Task
gulp.task('build', gulp.parallel('scss', 'scripts', 'html'));
gulp.task('clean', gulp.parallel('clean:ds', 'clean:dest'));
gulp.task('rebuild', gulp.series('clean', 'build'));

gulp.task('default', gulp.series('build', 'serve'));
<|endoftext|>


<commit_before>
'use strict';

var gulp = require('gulp-help')(require('gulp')),
  bower = require('bower'),
  generateIndexPage = require('./gulp/lib/generateIndexPage');

require('./gulp/assets');
require('./gulp/init');
require('./gulp/watch');
require('./gulp/vendor');
require('./gulp/app');
require('./gulp/lint');
require('./gulp/test');
require('./gulp/rules');
require('./gulp/populate');

gulp.task('indexpage', false, ['app', 'vendor'], generateIndexPage);

gulp.task('bower', false, function() {
  return bower.commands.update();
});

gulp.task('build', 'Build all assets.', ['app', 'assets', 'vendor', 'indexpage']);

gulp.task('build:watch', false, ['build'], function() {
  gulp.start('watch');
});

gulp.task('dev', 'Rebuild and reload the app on changes. Develop away!', ['bower'], function() {

  gulp.start('build:watch');
  gulp.start('test:unit:run');

});

gulp.task('default', false, ['dev']);
<commit_msg>[seed] always make sure build/ exists<commit_after>
'use strict';

var gulp = require('gulp-help')(require('gulp')),
  fs = require('fs'),
  bower = require('bower'),
  generateIndexPage = require('./gulp/lib/generateIndexPage');

require('./gulp/assets');
require('./gulp/init');
require('./gulp/watch');
require('./gulp/vendor');
require('./gulp/app');
require('./gulp/lint');
require('./gulp/test');
require('./gulp/rules');
require('./gulp/populate');

// create "build" if it doesn't exist
try {
  fs.mkdirSync('build');
} catch(e) {}

gulp.task('indexpage', false, ['app', 'vendor'], generateIndexPage);

gulp.task('bower', false, function() {
  return bower.commands.update();
});

gulp.task('build', 'Build all assets.', ['app', 'assets', 'vendor', 'indexpage']);

gulp.task('build:watch', false, ['build'], function() {
  gulp.start('watch');
});

gulp.task('dev', 'Rebuild and reload the app on changes. Develop away!', ['bower'], function() {

  gulp.start('build:watch');
  gulp.start('test:unit:run');

});

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


<commit_before>'use strict';
var Promise = require('bluebird');
var auth = Promise.promisify(require('google-auth2-service-account').auth);
var scope = 'https://www.googleapis.com/auth/mapsengine';
var rawRequest = Promise.promisify(require('request'));
var Deque = require('double-ended-queue');
var fs = require('fs');
var Bulk = require('./bulk');
var limits = require('./limits.json');
var Stream = require('./stream');
var FeatureStream = require('./featureStream');
var readFile = Promise.promisify(fs.readFile, fs);
var TRUE = Promise.resolve(true);
module.exports = GME;
function GME(key, email, table, opts) {
  if (Buffer.isBuffer(key)) {
    this.key = Promise.resolve(key);
  } else {
    this.key = readFile(key);
  }
  if (typeof opts === 'string') {
    opts = {
      primary: opts
    };
  }
  this.iss = email;
  this.tableid = table;
  opts = opts || {};
  this.primary = opts.primary || 'gx_id';
  this.verbose = !!opts.verbose;
  this.nogeo = !!opts.nogeo;
  this.stopOnError = !!opts.stopOnError;
  if (opts.trace) {
    this.trace = opts.trace;
  } else {
    this.trace = false;
  }
  this.baseurl = 'https://www.googleapis.com/mapsengine/v1/';
  this.queue = new Deque();
  this.inProgress = false;
  if (opts.limits && typeof opts.limits === 'object') {
    this.limits = opts.limits;
  } else if (typeof opts.limits === 'string') {
    if (limits[opts.limits]) {
      this.limits = limits[opts.limits];
    }
  }
}

GME.prototype._request = function (opts) {
  return rawRequest(opts).then(function (resp) {
    resp = resp[1];
    if (resp && resp.error) {
      throw resp.error;
    }
    return resp;
  });
};
GME.prototype.request = function (opts) {
  if (this.inProgress) {
    var resolver = Promise.defer();
    this.queue.push({
      resolver: resolver,
      opts: opts
    });
    return resolver.promise;
  }
  return this.createRequest(opts);
};
GME.prototype.createRequest = function (opts) {
  var self = this;
  this.inProgress = true;
  var tries = 1;
  function attemptDownload(){
    return self.auth().then(function (auth) {
      opts.headers = {
        Authorization: 'Bearer ' + auth
      };
      return self._request(opts);
    }).catch(function (err) {
      if (tries++ > 10 || [401, 403].indexOf(err.code) === -1 || self.stopOnError) {
        var error = new Error(err.message);
        error.code = err.code;
        error.errors = err.errors;
        if (self.verbose) {
          if (self.nogeo) {
            try {
              opts.body.features = opts.body.features.map(function (feature) {
                delete feature.geometry;
                return feature;
              });
            } catch(e) {}
          }
          console.log(new Date());
          console.log(err);
          console.log(JSON.stringify(opts, false, 4));
        }
        throw error;
      }
      return Promise.delay(tries * 1000).then(function () {
        return attemptDownload();
      });
    });
  }
  return attemptDownload().finally(function () {
    if (self.queue.length) {
      var next = self.queue.shift();
      next.resolver.resolve(self.createRequest(next.opts));
      return;
    }
    self.inProgress = false;
  });
};

GME.prototype.init = function () {
  var self = this;
  return this.key.then(function (key) {
    return auth(key, {
      iss: self.iss,
      scope: scope
    }).then(function (token) {
      if (self.timeout) {
        clearTimeout(self.timeout);
        self.timeout = null;
      }
      self.token = token;
      self.timeout = setTimeout(function () {
        self.token = null;
        self.timeout = null;
      }, 5 * 60 * 1000);
      return token;
    });
  });
};
GME.prototype.auth = function () {
  if (this.token) {
    return Promise.resolve(this.token);
  } else {
    return this.init();
  }
};
GME.prototype.get = function (url, qs) {
  qs = qs || {};
  url = this.baseurl + url;
  var self = this;
  if (this.trace) {
    qs.trace = this.trace;
  }

  return self.request({
    url: url,
    qs: qs,
    json: true
  });
};
GME.prototype.post = function (url, body) {
  url = this.baseurl + url;
  var self = this;
  var opts = {
    url: url,

    body: body,
    json: true,
    method: 'POST'
  };
  if (self.trace) {
    opts.qs = {
      trace: self.trace
    };
  }
  return self.request(opts);
};
GME.prototype.info = function () {
  return this.get('tables/' + this.tableid);
};
GME.prototype.features = function (query) {
  var self = this;
  return new Promise(function (resolve, reject) {
    var out = {
      type: 'FeatureCollection',
      features: []
    };
    self.readStream(query).on('data', function (d) {
      out.features.push(d);
    }).on('finish', function () {
      resolve(out);
    }).on('error', reject);
  });
};
GME.prototype.featureStream = GME.prototype.readStream = function (query) {
  query = query || {};
  return new FeatureStream(this, query);
};
GME.prototype.feature = function (id) {
  return this.get('tables/' + this.tableid + '/features/' + id);
};
GME.prototype.create = function(arr) {
  if (this.verbose && arr.length) {
    console.log(new Date());
    console.log('create', arr.length);
    arr.forEach(function (item) {
      console.log(item.properties[this.primary]);
    }, this);
  }
  if (!arr.length) {
    return TRUE;
  }
  return this.post('tables/' + this.tableid + '/features/batchInsert', {features: arr});
};
GME.prototype.update = function(arr) {
  if (this.verbose && arr.length) {
    console.log(new Date());
    console.log('update', arr.length);
  }
  if (!arr.length) {
    return TRUE;
  }
  return this.post('tables/' + this.tableid + '/features/batchPatch', {features: arr});
};
GME.prototype.remove = function(arr) {
  if (this.verbose && arr.length) {
    console.log(new Date());
    console.log('remove', arr.length);
    arr.forEach(function (item) {
      console.log(item);
    }, this);
  }
  if (!arr.length) {
    return TRUE;
  }
  return this.post('tables/' + this.tableid + '/features/batchDelete', {gx_ids: arr});
};

GME.prototype.bulk = function() {
  return new Bulk(this);
};
GME.prototype.writeStream = function() {
  return new Stream(this);
};<commit_msg>actually remove log<commit_after>'use strict';
var Promise = require('bluebird');
var auth = Promise.promisify(require('google-auth2-service-account').auth);
var scope = 'https://www.googleapis.com/auth/mapsengine';
var rawRequest = Promise.promisify(require('request'));
var Deque = require('double-ended-queue');
var fs = require('fs');
var Bulk = require('./bulk');
var limits = require('./limits.json');
var Stream = require('./stream');
var FeatureStream = require('./featureStream');
var readFile = Promise.promisify(fs.readFile, fs);
var TRUE = Promise.resolve(true);
module.exports = GME;
function GME(key, email, table, opts) {
  if (Buffer.isBuffer(key)) {
    this.key = Promise.resolve(key);
  } else {
    this.key = readFile(key);
  }
  if (typeof opts === 'string') {
    opts = {
      primary: opts
    };
  }
  this.iss = email;
  this.tableid = table;
  opts = opts || {};
  this.primary = opts.primary || 'gx_id';
  this.verbose = !!opts.verbose;
  this.nogeo = !!opts.nogeo;
  this.stopOnError = !!opts.stopOnError;
  if (opts.trace) {
    this.trace = opts.trace;
  } else {
    this.trace = false;
  }
  this.baseurl = 'https://www.googleapis.com/mapsengine/v1/';
  this.queue = new Deque();
  this.inProgress = false;
  if (opts.limits && typeof opts.limits === 'object') {
    this.limits = opts.limits;
  } else if (typeof opts.limits === 'string') {
    if (limits[opts.limits]) {
      this.limits = limits[opts.limits];
    }
  }
}

GME.prototype._request = function (opts) {
  return rawRequest(opts).then(function (resp) {
    resp = resp[1];
    if (resp && resp.error) {
      throw resp.error;
    }
    return resp;
  });
};
GME.prototype.request = function (opts) {
  if (this.inProgress) {
    var resolver = Promise.defer();
    this.queue.push({
      resolver: resolver,
      opts: opts
    });
    return resolver.promise;
  }
  return this.createRequest(opts);
};
GME.prototype.createRequest = function (opts) {
  var self = this;
  this.inProgress = true;
  var tries = 1;
  function attemptDownload(){
    return self.auth().then(function (auth) {
      opts.headers = {
        Authorization: 'Bearer ' + auth
      };
      return self._request(opts);
    }).catch(function (err) {
      if (tries++ > 10 || [401, 403].indexOf(err.code) === -1 || self.stopOnError) {
        var error = new Error(err.message);
        error.code = err.code;
        error.errors = err.errors;
        if (self.verbose) {
          if (self.nogeo) {
            try {
              opts.body.features = opts.body.features.map(function (feature) {
                delete feature.geometry;
                return feature;
              });
            } catch(e) {}
          }
          console.log(new Date());
          console.log(err);
          console.log(JSON.stringify(opts, false, 4));
        }
        throw error;
      }
      return Promise.delay(tries * 1000).then(function () {
        return attemptDownload();
      });
    });
  }
  return attemptDownload().finally(function () {
    if (self.queue.length) {
      var next = self.queue.shift();
      next.resolver.resolve(self.createRequest(next.opts));
      return;
    }
    self.inProgress = false;
  });
};

GME.prototype.init = function () {
  var self = this;
  return this.key.then(function (key) {
    return auth(key, {
      iss: self.iss,
      scope: scope
    }).then(function (token) {
      if (self.timeout) {
        clearTimeout(self.timeout);
        self.timeout = null;
      }
      self.token = token;
      self.timeout = setTimeout(function () {
        self.token = null;
        self.timeout = null;
      }, 5 * 60 * 1000);
      return token;
    });
  });
};
GME.prototype.auth = function () {
  if (this.token) {
    return Promise.resolve(this.token);
  } else {
    return this.init();
  }
};
GME.prototype.get = function (url, qs) {
  qs = qs || {};
  url = this.baseurl + url;
  var self = this;
  if (this.trace) {
    qs.trace = this.trace;
  }

  return self.request({
    url: url,
    qs: qs,
    json: true
  });
};
GME.prototype.post = function (url, body) {
  url = this.baseurl + url;
  var self = this;
  var opts = {
    url: url,

    body: body,
    json: true,
    method: 'POST'
  };
  if (self.trace) {
    opts.qs = {
      trace: self.trace
    };
  }
  return self.request(opts);
};
GME.prototype.info = function () {
  return this.get('tables/' + this.tableid);
};
GME.prototype.features = function (query) {
  var self = this;
  return new Promise(function (resolve, reject) {
    var out = {
      type: 'FeatureCollection',
      features: []
    };
    self.readStream(query).on('data', function (d) {
      out.features.push(d);
    }).on('finish', function () {
      resolve(out);
    }).on('error', reject);
  });
};
GME.prototype.featureStream = GME.prototype.readStream = function (query) {
  query = query || {};
  return new FeatureStream(this, query);
};
GME.prototype.feature = function (id) {
  return this.get('tables/' + this.tableid + '/features/' + id);
};
GME.prototype.create = function(arr) {
  if (this.verbose && arr.length) {
    console.log(new Date());
    console.log('create', arr.length);
  }
  if (!arr.length) {
    return TRUE;
  }
  return this.post('tables/' + this.tableid + '/features/batchInsert', {features: arr});
};
GME.prototype.update = function(arr) {
  if (this.verbose && arr.length) {
    console.log(new Date());
    console.log('update', arr.length);
  }
  if (!arr.length) {
    return TRUE;
  }
  return this.post('tables/' + this.tableid + '/features/batchPatch', {features: arr});
};
GME.prototype.remove = function(arr) {
  if (this.verbose && arr.length) {
    console.log(new Date());
    console.log('remove', arr.length);
  }
  if (!arr.length) {
    return TRUE;
  }
  return this.post('tables/' + this.tableid + '/features/batchDelete', {gx_ids: arr});
};

GME.prototype.bulk = function() {
  return new Bulk(this);
};
GME.prototype.writeStream = function() {
  return new Stream(this);
};<|endoftext|>


<commit_before>
var gulp = require('gulp');
var less = require('gulp-less');
var del = require('del');
var cssnano = require('gulp-cssnano');
var concatCss = require('gulp-concat-css');
var browserSync = require('browser-sync');
var childProcess = require('child_process');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var spritesmith = require('gulp.spritesmith');
var imagemin = require('gulp-imagemin');
var htmlmin = require('gulp-htmlmin');
var filter = require('gulp-filter');

var paths = {
  jekyll: [
    '_data/*.yml',
    '_includes/*.html',
    '_layouts/*.html',
    '_posts/*.md',
    '*.md',
    '_config.yml',
    '.htaccess'
  ],
  css: [
    'fontello/build/css/fontello.css',
    'css/main.less'
  ],
  fonts: [
    'fontello/build/font/*.*'
  ],
  site: [
    '_site/**/*.*',
    '_site/**/.*'
  ]
};

gulp.task('clean', function(callback) {
  del(['_build/*', '_site/*'], callback)
});

gulp.task('watch', function() {
  gulp.watch(paths.site, ['site']);
  gulp.watch(paths.jekyll, ['jekyll']);
  gulp.watch(paths.css, ['css']);
  gulp.watch(paths.fonts, ['fonts']);
});

gulp.task('jekyll', function(callback) {
  browserSync.notify('jekyll');
  childProcess.spawn('jekyll', ['build', '-d', '../_site'], {
    cwd: './app',
    stdio: 'inherit'
  })
  .on('close', callback);
});

gulp.task('jekyll-incremental', function(callback) {
  browserSync.notify('jekyll');
  childProcess.spawn('jekyll', ['build', '-d', '../_site', '-I'], {
        cwd: './app',
        stdio: 'inherit'
      })
      .on('close', callback);
});

gulp.task('fonts', function() {
  return gulp.src(paths.fonts)
    .pipe(gulp.dest('_build/font'));
});

gulp.task('css', function() {
  return gulp.src(paths.css)
    .pipe(less())
    .pipe(concatCss("main.css"))
    .pipe(cssnano())
    .pipe(gulp.dest('_build/css'))
    .pipe(rev())
    .pipe(gulp.dest('_build/css'))
    .pipe(rev.manifest())
    .pipe(gulp.dest('_build/css'))
    .pipe(browserSync.reload({stream:true}))
});

gulp.task('site', function() {
  var htmlFilter = filter('**/*.html', {restore: true});
  return gulp.src(paths.site)
    .pipe(htmlFilter)
    .pipe(htmlmin({
      collapseWhitespace: true,
      conservativeCollapse: true
    }))
    .pipe(htmlFilter.restore)
    .pipe(gulp.dest('_build'));
});

gulp.task('sprite', function () {
  var spriteData = gulp.src(['images/speakers/*.*']).pipe(spritesmith({
    imgName: 'sprite.png',
    cssName: 'sprite.css'
  }));
  return spriteData.pipe(imagemin())
    .pipe(gulp.dest('images/speakers/sprite'));
});

gulp.task("revreplace", [], function() {
  var manifest = gulp.src('_build/css/rev-manifest.json');
  return gulp.src('_build/**/*.html')
    .pipe(revReplace({manifest: manifest}))
    .pipe(gulp.dest('_build'))
});

gulp.task('browser-sync', [], function() {
  browserSync({
    server: {
      baseDir: '_build'
    },
    host: "localhost",
    port: 4000
  });
});

gulp.task('default', ['jekyll', 'css', 'fonts', 'sprite'], function() {
  gulp.start('site', 'watch', 'browser-sync');
});
<commit_msg>Use jekyll-incremental task while watching. Updated watched paths.<commit_after>
var gulp = require('gulp');
var less = require('gulp-less');
var del = require('del');
var cssnano = require('gulp-cssnano');
var concatCss = require('gulp-concat-css');
var browserSync = require('browser-sync');
var childProcess = require('child_process');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');
var spritesmith = require('gulp.spritesmith');
var imagemin = require('gulp-imagemin');
var htmlmin = require('gulp-htmlmin');
var filter = require('gulp-filter');

var paths = {
  jekyll: [
    'app/**/*.md',
    'app/**/*.html',
    'app/**/*.yml',
    'app/**/.htaccess'
  ],
  css: [
    'fontello/build/css/fontello.css',
    'css/main.less'
  ],
  fonts: [
    'fontello/build/font/*.*'
  ],
  site: [
    '_site/**/*.*',
    '_site/**/.*'
  ]
};

gulp.task('clean', function(callback) {
  del(['_build/*', '_site/*'], callback)
});

gulp.task('watch', function() {
  gulp.watch(paths.site, ['site']);
  gulp.watch(paths.jekyll, ['jekyll-incremental']);
  gulp.watch(paths.css, ['css']);
  gulp.watch(paths.fonts, ['fonts']);
});

gulp.task('jekyll', function(callback) {
  browserSync.notify('jekyll');
  childProcess.spawn('jekyll', ['build', '-d', '../_site'], {
    cwd: './app',
    stdio: 'inherit'
  })
  .on('close', callback);
});

gulp.task('jekyll-incremental', function(callback) {
  browserSync.notify('jekyll');
  childProcess.spawn('jekyll', ['build', '-d', '../_site', '-I'], {
        cwd: './app',
        stdio: 'inherit'
      })
      .on('close', callback);
});

gulp.task('fonts', function() {
  return gulp.src(paths.fonts)
    .pipe(gulp.dest('_build/font'));
});

gulp.task('css', function() {
  return gulp.src(paths.css)
    .pipe(less())
    .pipe(concatCss("main.css"))
    .pipe(cssnano())
    .pipe(gulp.dest('_build/css'))
    .pipe(rev())
    .pipe(gulp.dest('_build/css'))
    .pipe(rev.manifest())
    .pipe(gulp.dest('_build/css'))
    .pipe(browserSync.reload({stream:true}))
});

gulp.task('site', function() {
  var htmlFilter = filter('**/*.html', {restore: true});
  return gulp.src(paths.site)
    .pipe(htmlFilter)
    .pipe(htmlmin({
      collapseWhitespace: true,
      conservativeCollapse: true
    }))
    .pipe(htmlFilter.restore)
    .pipe(gulp.dest('_build'));
});

gulp.task('sprite', function () {
  var spriteData = gulp.src(['images/speakers/*.*']).pipe(spritesmith({
    imgName: 'sprite.png',
    cssName: 'sprite.css'
  }));
  return spriteData.pipe(imagemin())
    .pipe(gulp.dest('images/speakers/sprite'));
});

gulp.task("revreplace", [], function() {
  var manifest = gulp.src('_build/css/rev-manifest.json');
  return gulp.src('_build/**/*.html')
    .pipe(revReplace({manifest: manifest}))
    .pipe(gulp.dest('_build'))
});

gulp.task('browser-sync', [], function() {
  browserSync({
    server: {
      baseDir: '_build'
    },
    host: "localhost",
    port: 4000
  });
});

gulp.task('default', ['jekyll', 'css', 'fonts', 'sprite'], function() {
  gulp.start('site', 'watch', 'browser-sync');
});
<|endoftext|>


<commit_before>'use strict';

var gulp         = require('gulp'),
    concat       = require('gulp-concat'),
    uglify       = require('gulp-uglify'),
    rename       = require('gulp-rename'),
    autoprefixer = require('gulp-autoprefixer'),
    browserSync  = require('browser-sync').create();
var minifyCSS    = require('gulp-minify-css');
var order        = require("gulp-order");
var print        = require('gulp-print');
var htmlmin = require('gulp-htmlmin');
var sourcemaps = require('gulp-sourcemaps');
var htmlreplace = require('gulp-html-replace');

var DEST = 'release/';

gulp.task('scripts', function () {
    return gulp.src([
                        'src/js/**/*.js'
                    ])
               .pipe(order([
                               'jquery-1.11.0.min.js',
                               'bootstrap.min.js',
                               'bootstrap-hover-dropdown.js',
                               'bootstrapValidator.min.js',
                               'jquery.sticky.js',
                               'jquery.flexslider-min.js',
                               'overlay/modernizr.js',
                               'jquery.flexisel.js',
                               'jquery.prettyPhoto.js',
                               'jquery.mixitup.min.js',
                               'jquery.fitvids.js',
                               'jquery.easing.1.3.js',
                               'jquery.appear.js',
                               'effect.js',
                               'tweet/carousel.js',
                               'tweet/scripts.js',
                               'tweet/tweetie.min.js',
                               'custom.js',
                               'color-panel.js'
                           ]), {base: './src/js/'})
               .pipe(sourcemaps.init())
               .pipe(concat('bundle.js'))
               .pipe(gulp.dest(DEST + 'js'))
               .pipe(rename({suffix: '.min'}))
               .pipe(uglify())
               .pipe(sourcemaps.write('./'))
               .pipe(gulp.dest(DEST + 'js'))
               .pipe(browserSync.stream());
});

gulp.task('styles', function () {
    gulp.src('src/css/**/*.css')
        .pipe(order([
                        'flaticon.css',
                        'bootstrap.min.css',
                        'portfolio.css',
                        'animate.min.css',
                        'prettyPhoto.css',
                        'flexslider.css',
                        'tweet-carousel.css',
                        'style.css',
                        'responsive.css',
                        'color_panel.css',
                        'color-schemes/red.css'
                    ]), {base: './src/css/'})
        .pipe(sourcemaps.init())
        .pipe(concat('bundle.css'))
        .pipe(autoprefixer('last 2 version', '> 5%'))
        .pipe(gulp.dest(DEST + '/css'))
        .pipe(rename({suffix: '.min'}))
        .pipe(minifyCSS())
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(DEST + 'css'))
        .pipe(browserSync.stream());
});

gulp.task('html', function () {
    gulp.src(['./src/**/*.html', '!./src/index.html'])
        .pipe(htmlmin({removeComments: true, collapseWhitespace:true, conservativeCollapse: true}))
        .pipe(gulp.dest(DEST))
        .pipe(browserSync.stream());
    gulp.src(['./src/index.html'])
        .pipe(htmlreplace({
                              'css': 'css/bundle.min.css',
                              'js': 'js/bundle.min.js'
                          }))
        .pipe(htmlmin({removeComments: true, collapseWhitespace:true, conservativeCollapse: true}))
        .pipe(gulp.dest(DEST))
        .pipe(browserSync.stream());
});

gulp.task('copyFiles', function () {
    gulp.src([
                 './src/**/*',
                 './api/**/*',
                 '!./src/**/*.{css,js,html}'
             ])
        .pipe(gulp.dest(DEST ));
});

gulp.task('build', ['styles', 'scripts', 'copyFiles', 'html'], function () {

});

gulp.task('browser-sync', function () {
    browserSync.init({
                         server   : {
                             baseDir: './'
                         },
                         startPath: './release/index.html'
                     });
});

gulp.task('watch', function () {
    // Watch .html files
    gulp.watch('src/*.html', browserSync.reload);
    // Watch .js files
    gulp.watch('src/js/**/*.js', ['scripts']);
    // Watch .css files
    gulp.watch('src/css/**/*.css', ['styles']);
});

gulp.task('serve', ['build', 'browser-sync', 'watch']);

// Default Task
gulp.task('default', ['build']);
<commit_msg>tweet<commit_after>'use strict';

var gulp         = require('gulp'),
    concat       = require('gulp-concat'),
    uglify       = require('gulp-uglify'),
    rename       = require('gulp-rename'),
    autoprefixer = require('gulp-autoprefixer'),
    browserSync  = require('browser-sync').create();
var minifyCSS    = require('gulp-minify-css');
var order        = require("gulp-order");
var print        = require('gulp-print');
var htmlmin = require('gulp-htmlmin');
var sourcemaps = require('gulp-sourcemaps');
var htmlreplace = require('gulp-html-replace');

var DEST = 'release/';

gulp.task('scripts', function () {
    return gulp.src([
                        'src/js/**/*.js'
                    ])
               .pipe(order([
                               'jquery-1.11.0.min.js',
                               'bootstrap.min.js',
                               'bootstrap-hover-dropdown.js',
                               'bootstrapValidator.min.js',
                               'jquery.sticky.js',
                               'jquery.flexslider-min.js',
                               'overlay/modernizr.js',
                               'jquery.flexisel.js',
                               'jquery.prettyPhoto.js',
                               'jquery.mixitup.min.js',
                               'jquery.fitvids.js',
                               'jquery.easing.1.3.js',
                               'jquery.appear.js',
                               'effect.js',
                               'tweet/carousel.js',
                               'tweet/scripts.js',
                               'tweet/tweetie.min.js',
                               'custom.js',
                               'color-panel.js'
                           ]), {base: './src/js/'})
               .pipe(sourcemaps.init())
               .pipe(concat('bundle.js'))
               .pipe(gulp.dest(DEST + 'js'))
               .pipe(rename({suffix: '.min'}))
               .pipe(uglify())
               .pipe(sourcemaps.write('./'))
               .pipe(gulp.dest(DEST + 'js'))
               .pipe(browserSync.stream());
});

gulp.task('styles', function () {
    gulp.src('src/css/**/*.css')
        .pipe(order([
                        'flaticon.css',
                        'bootstrap.min.css',
                        'portfolio.css',
                        'animate.min.css',
                        'prettyPhoto.css',
                        'flexslider.css',
                        'tweet-carousel.css',
                        'style.css',
                        'responsive.css',
                        'color_panel.css',
                        'color-schemes/red.css'
                    ]), {base: './src/css/'})
        .pipe(sourcemaps.init())
        .pipe(concat('bundle.css'))
        .pipe(autoprefixer('last 2 version', '> 5%'))
        .pipe(gulp.dest(DEST + '/css'))
        .pipe(rename({suffix: '.min'}))
        .pipe(minifyCSS())
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(DEST + 'css'))
        .pipe(browserSync.stream());
});

gulp.task('html', function () {
    gulp.src(['./src/**/*.html', '!./src/index.html'])
        .pipe(htmlmin({removeComments: true, collapseWhitespace:true, conservativeCollapse: true}))
        .pipe(gulp.dest(DEST))
        .pipe(browserSync.stream());
    gulp.src(['./src/index.html'])
        .pipe(htmlreplace({
                              'css': 'css/bundle.min.css',
                              'js': 'js/bundle.min.js'
                          }))
        .pipe(htmlmin({removeComments: true, collapseWhitespace:true, conservativeCollapse: true}))
        .pipe(gulp.dest(DEST))
        .pipe(browserSync.stream());
});

gulp.task('copyFiles', function () {
    gulp.src([
                 './src/**/*',
                 '!./src/**/*.{css,js,html}'
             ])
        .pipe(gulp.dest(DEST));
    gulp.src([
                 './api/**/*'
             ])
        .pipe(gulp.dest(DEST + 'api'));
});

gulp.task('build', ['styles', 'scripts', 'copyFiles', 'html'], function () {

});

gulp.task('browser-sync', function () {
    browserSync.init({
                         server   : {
                             baseDir: './'
                         },
                         startPath: './release/index.html'
                     });
});

gulp.task('watch', function () {
    // Watch .html files
    gulp.watch('src/*.html', browserSync.reload);
    // Watch .js files
    gulp.watch('src/js/**/*.js', ['scripts']);
    // Watch .css files
    gulp.watch('src/css/**/*.css', ['styles']);
});

gulp.task('serve', ['build', 'browser-sync', 'watch']);

// Default Task
gulp.task('default', ['build']);
<|endoftext|>


<commit_before>// Include gulp
var gulp = require('gulp');

// Include Our Plugins
var jshint = require('gulp-jshint');
var closure = require('gulp-closure-compiler');
var browserify = require('gulp-browserify');
var jsdoc = require('gulp-jsdoc');

// Lint
gulp.task('lint', function() {
    return gulp.src('src/**/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('check', function(){
    // Perform type checking, etc. with closure compiler
    gulp.src('build/wireframe.js')
        .pipe(closure({
            compilerPath: '/usr/share/java/closure-compiler/closure-compiler.jar',
            fileName: 'wireframe.min.js',
            compilerFlags: {
                warning_level: 'VERBOSE',
                summary_detail_level: 1
            }
        }))
});

// Compress/minify
gulp.task('compress', function(){
    gulp.src('build/wireframe.js')
        .pipe(closure({
            compilerPath: '/usr/share/java/closure-compiler/closure-compiler.jar',
            fileName: 'wireframe.min.js',
            compilerFlags: {
                warning_level: 'QUIET',
                compilation_level: 'SIMPLE_OPTIMIZATIONS'
            }
        }))
        .pipe(gulp.dest('build'));
});

gulp.task('browserify', function() {
    gulp.src('src/wireframe.js')
        .pipe(browserify({
            standalone: 'wireframe'
        }))
        .pipe(gulp.dest('build'));
});

// Build documentation
gulp.task('builddocs', function() {
    gulp.src('src/**/*.js')
        .pipe(jsdoc('docs'));
});

gulp.task('watch', function() {
    gulp.watch('src/**/*.(js|html)', ['lint', 'browserify']);
});

// Default Task
gulp.task('default', ['lint', 'browserify', 'watch']);
gulp.task('compile', ['browserify', 'compress']);
gulp.task('check', ['lint', 'browserify', 'check']);
gulp.task('docs', ['builddocs']);<commit_msg>Revert gulpfile docs task change<commit_after>// Include gulp
var gulp = require('gulp');

// Include Our Plugins
var jshint = require('gulp-jshint');
var closure = require('gulp-closure-compiler');
var browserify = require('gulp-browserify');
var jsdoc = require('gulp-jsdoc');

// Lint
gulp.task('lint', function() {
    return gulp.src('src/**/*.js')
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('check', function(){
    // Perform type checking, etc. with closure compiler
    gulp.src('build/wireframe.js')
        .pipe(closure({
            compilerPath: '/usr/share/java/closure-compiler/closure-compiler.jar',
            fileName: 'wireframe.min.js',
            compilerFlags: {
                warning_level: 'VERBOSE',
                summary_detail_level: 1
            }
        }))
});

// Compress/minify
gulp.task('compress', function(){
    gulp.src('build/wireframe.js')
        .pipe(closure({
            compilerPath: '/usr/share/java/closure-compiler/closure-compiler.jar',
            fileName: 'wireframe.min.js',
            compilerFlags: {
                warning_level: 'QUIET',
                compilation_level: 'SIMPLE_OPTIMIZATIONS'
            }
        }))
        .pipe(gulp.dest('build'));
});

gulp.task('browserify', function() {
    gulp.src('src/wireframe.js')
        .pipe(browserify({
            standalone: 'wireframe'
        }))
        .pipe(gulp.dest('build'));
});

// Build documentation
gulp.task('docs', function() {
    gulp.src('src/**/*.js')
        .pipe(jsdoc('docs'));
});

gulp.task('watch', function() {
    gulp.watch('src/**/*.(js|html)', ['lint', 'browserify']);
});

// Default Task
gulp.task('default', ['lint', 'browserify', 'watch']);
gulp.task('compile', ['browserify', 'compress']);
gulp.task('check', ['lint', 'browserify', 'check']);<|endoftext|>


<commit_before>var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var replace = require('gulp-replace');

var files = [
  'src/entry',

  // utils
  'src/utils/PathUtil.js',
  'src/utils/StringUtil.js',
  'src/utils/LiteralUtil.js',

  // share
  'src/share/constants.js',
  'src/share/functions.js',
  'src/share/RES.js',
  //'src/share/Dep.js',

  // skins
  //'src/skins/Skin.js',
  //'src/skins/Skin-jQuery.js',
  //'src/skins/Skin-cheerio.js',

  // base modules
  'src/base/Watcher.js',
  'src/base/Accessor.js',
  'src/base/Schedule.js',
  'src/base/Validator.js',
  'src/base/Evaluator.js',
  'src/base/Expression.js',
  'src/base/DirtyMarker.js',

  // core modules
  'src/core/models/Collection.js',
  'src/core/models/Container.js',
  'src/core/models/Store.js',

  'src/core/shadows/Shadow.js',
  'src/core/shadows/Text.js',
  'src/core/shadows/Element.js',
  'src/core/shadows/Component.js',

  'src/core/bindings/Binding.js',
  'src/core/bindings/DataBinding.js',
  'src/core/bindings/TextBinding.js',
  'src/core/bindings/EventBinding.js',

  'src/core/template/HTMXEngine.js',
  'src/core/template/HTMXTemplate.js',
  'src/core/template/parsers/EvaluatorParser.js',
  'src/core/template/parsers/EventBindingParser.js',
  'src/core/template/parsers/DataBindingParser.js',
  'src/core/template/parsers/TextBindingParser.js',
  'src/core/template/parsers/HTMLParser.js',
  'src/core/template/parsers/HTMXParser.js',

  'src/more/updaters/HTMXUpdater.js',
  //'src/more/inputs/Input.js',
  //'src/more/inputs/TextBox.js',
  //'src/more/inputs/CheckBox.js',
  //'src/more/inputs/Radio.js',
  //'src/more/inputs/Select.js',
  //'src/more/inputs/TextArea.js',

  'src/exit'
];

gulp.task('build', function() {
  return gulp.src(files)
    .pipe(concat('exact.js'))
    .pipe(replace(/__DEV__/g, "development"))
    //.pipe(replace(/Exact.env/g, "<ES5"))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename('exact.min.js'))
    .pipe(replace(/__DEV__/g, "production"))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

gulp.task('build-skin', function() {
  return gulp.src('./src/skins/Skin.js')
    .pipe(concat('exact-skin.js'))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename('exact-skin.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

gulp.task('build-skin-jquery', function() {
  return gulp.src('./src/skins/Skin-jQuery.js')
    .pipe(concat('exact-skin-jquery.js'))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename('exact-skin-jquery.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

gulp.task('build-skin-cheerio', function() {
  return gulp.src('./src/skins/Skin-cheerio.js')
    .pipe(concat('exact-skin-cheerio.js'))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename('exact-skin-cheerio.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

//gulp.task('default',['build']);

//gulp.watch('src/**/*.js')<commit_msg>update gulpfile<commit_after>var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var replace = require('gulp-replace');

var files = [
  'src/entry',

  // utils
  'src/utils/PathUtil.js',
  'src/utils/StringUtil.js',
  'src/utils/LiteralUtil.js',

  // share
  'src/share/constants.js',
  'src/share/functions.js',
  'src/share/RES.js',
  //'src/share/Dep.js',

  // skins
  //'src/skins/Skin.js',
  //'src/skins/Skin-jQuery.js',
  //'src/skins/Skin-cheerio.js',

  // base modules
  'src/base/Watcher.js',
  'src/base/Accessor.js',
  'src/base/Schedule.js',
  'src/base/Validator.js',
  'src/base/Evaluator.js',
  'src/base/Expression.js',
  'src/base/DirtyMarker.js',

  // core modules
  'src/core/models/Collection.js',
  'src/core/models/Container.js',
  'src/core/models/Store.js',

  'src/core/shadows/Shadow.js',
  'src/core/shadows/Text.js',
  'src/core/shadows/Element.js',
  'src/core/shadows/Component.js',

  'src/core/bindings/Binding.js',
  'src/core/bindings/DataBinding.js',
  'src/core/bindings/TextBinding.js',
  'src/core/bindings/EventBinding.js',

  'src/core/template/HTMXEngine.js',
  'src/core/template/HTMXTemplate.js',
  'src/core/template/parsers/EvaluatorParser.js',
  'src/core/template/parsers/EventBindingParser.js',
  'src/core/template/parsers/DataBindingParser.js',
  'src/core/template/parsers/TextBindingParser.js',
  'src/core/template/parsers/HTMLParser.js',
  'src/core/template/parsers/HTMXParser.js',

  'src/more/updaters/HTMXUpdater.js',

  'src/exit'
];

gulp.task('build', function() {
  return gulp.src(files)
    .pipe(concat('exact.js'))
    .pipe(replace(/__DEV__/g, "development"))
    //.pipe(replace(/Exact.env/g, "<ES5"))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename('exact.min.js'))
    .pipe(replace(/__DEV__/g, "production"))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

gulp.task('build-skin', function() {
  return gulp.src('./src/skins/Skin.js')
    .pipe(concat('exact-skin.js'))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename('exact-skin.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

gulp.task('build-skin-jquery', function() {
  return gulp.src('./src/skins/Skin-jQuery.js')
    .pipe(concat('exact-skin-jquery.js'))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename('exact-skin-jquery.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

gulp.task('build-skin-cheerio', function() {
  return gulp.src('./src/skins/Skin-cheerio.js')
    .pipe(concat('exact-skin-cheerio.js'))
    .pipe(gulp.dest('./dist/'))
    .pipe(rename('exact-skin-cheerio.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'));
});

//gulp.task('default',['build']);

//gulp.watch('src/**/*.js')<|endoftext|>


<commit_before>/* eslint-env node */
/* eslint-disable no-console */

/**
 * Copyright 2017 Chialab. All Rights Reserved.
 *
 * The MIT License (MIT)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

const env = process.env;
const project = require('./package.json');

const path = require('path');
const del = require('del');
const mkdirp = require('mkdirp');
const gulp = require('gulp');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const rollup = require('rollup-stream');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha');
const sourcemaps = require('gulp-sourcemaps');
const exec = require('child-process-promise').exec;
const karma = require('karma');

const DIST_PATH = 'dist';
const SRC_PATH = 'src';
const TMP_PATH = '.tmp';
const ENTRY = path.basename(project.main || project.module);

function clean() {
    let paths = [DIST_PATH, TMP_PATH];
    return del(paths).then(() => {
        paths.forEach((p) => mkdirp.sync(p));
        return Promise.resolve();
    });
}

function lint() {
    return gulp.src(SRC_PATH)
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
}

function compile() {
    env.NODE_ENV = 'production';
    return rollup('rollup.config.js')
        .on('error', (err) => {
            // eslint-disable-next-line
            console.error(err);
            process.exit(1);
        })
        .pipe(source(ENTRY))
        .pipe(buffer())
        .pipe(sourcemaps.init({
            loadMaps: true,
        }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(DIST_PATH));
}

function compileUnitTests() {
    return rollup('rollup.config.js')
        .on('error', (err) => {
            // eslint-disable-next-line
            console.error(err);
            process.exit(1);
        })
        .pipe(source('specs.js', TMP_PATH))
        .pipe(buffer())
        .pipe(gulp.dest(TMP_PATH));
}

function unitNode() {
    env.NODE_ENV = 'test';
    env.TARGET = 'node';
    return compileUnitTests().pipe(mocha());
}

function unitKarma(done) {
    env.NODE_ENV = 'test';
    env.TARGET = 'browser';
    compileUnitTests()
        .on('end', () => {
            new karma.Server({
                configFile: path.join(__dirname, 'karma.conf.js'),
                singleRun: true,
            }, done).start();
        });
}

function execAndLog(cmd) {
    let promise = exec(cmd);
    let childProcess = promise.childProcess;
    childProcess.stdout.on('data', (data) => {
        console.log(data.toString());
    });
    childProcess.stderr.on('data', (data) => {
        console.error(data.toString());
    });
    return promise;
}

function unitNativescipt(platform, done) {
    env.NODE_ENV = 'test';
    env.TARGET = 'node';
    compileUnitTests()
        .on('end', () => {
            execAndLog('tns create Test --path .tmp')
                .then(() => execAndLog('tns test init --path .tmp/Test --framework mocha'))
                .then(() => execAndLog('cp .tmp/specs.js .tmp/Test/app/tests'))
                .then(() => execAndLog(`tns test ${platform} --emulator --justlaunch --path .tmp/Test`))
                .then(() => done())
                .catch(() => {
                    process.exit(1);
                });
        });
}

function unitNativesciptIOS(done) {
    unitNativescipt('ios', done);
}

function unitNativesciptAndroid(done) {
    unitNativescipt('android', done);
}

gulp.task('clean', clean);
gulp.task('lint', lint);
gulp.task('js', ['clean', 'lint'], compile);
gulp.task('unit-node', ['clean', 'lint'], unitNode);
gulp.task('unit-browsers', ['clean', 'lint'], unitKarma);
gulp.task('unit-nativescript-ios', ['clean', 'lint'], unitNativesciptIOS);
gulp.task('unit-nativescript-android', ['clean', 'lint'], unitNativesciptAndroid);
gulp.task('dist', ['js']);

gulp.task('default', ['dist']);
<commit_msg>test: trying to fix ios nativescript test<commit_after>/* eslint-env node */
/* eslint-disable no-console */

/**
 * Copyright 2017 Chialab. All Rights Reserved.
 *
 * The MIT License (MIT)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

const env = process.env;
const project = require('./package.json');

const path = require('path');
const del = require('del');
const mkdirp = require('mkdirp');
const gulp = require('gulp');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const rollup = require('rollup-stream');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha');
const sourcemaps = require('gulp-sourcemaps');
const exec = require('child-process-promise').exec;
const karma = require('karma');

const DIST_PATH = 'dist';
const SRC_PATH = 'src';
const TMP_PATH = '.tmp';
const ENTRY = path.basename(project.main || project.module);

function clean() {
    let paths = [DIST_PATH, TMP_PATH];
    return del(paths).then(() => {
        paths.forEach((p) => mkdirp.sync(p));
        return Promise.resolve();
    });
}

function lint() {
    return gulp.src(SRC_PATH)
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
}

function compile() {
    env.NODE_ENV = 'production';
    return rollup('rollup.config.js')
        .on('error', (err) => {
            // eslint-disable-next-line
            console.error(err);
            process.exit(1);
        })
        .pipe(source(ENTRY))
        .pipe(buffer())
        .pipe(sourcemaps.init({
            loadMaps: true,
        }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(DIST_PATH));
}

function compileUnitTests() {
    return rollup('rollup.config.js')
        .on('error', (err) => {
            // eslint-disable-next-line
            console.error(err);
            process.exit(1);
        })
        .pipe(source('specs.js', TMP_PATH))
        .pipe(buffer())
        .pipe(gulp.dest(TMP_PATH));
}

function unitNode() {
    env.NODE_ENV = 'test';
    env.TARGET = 'node';
    return compileUnitTests().pipe(mocha());
}

function unitKarma(done) {
    env.NODE_ENV = 'test';
    env.TARGET = 'browser';
    compileUnitTests()
        .on('end', () => {
            new karma.Server({
                configFile: path.join(__dirname, 'karma.conf.js'),
                singleRun: true,
            }, done).start();
        });
}

function execAndLog(cmd) {
    let promise = exec(cmd);
    let childProcess = promise.childProcess;
    childProcess.stdout.on('data', (data) => {
        console.log(data.toString());
    });
    childProcess.stderr.on('data', (data) => {
        console.error(data.toString());
    });
    return promise;
}

function unitNativescipt(platform, done) {
    env.NODE_ENV = 'test';
    env.TARGET = 'node';
    compileUnitTests()
        .on('end', () => {
            execAndLog('tns create Test --path .tmp')
                .then(() => execAndLog('tns test init --path .tmp/Test --framework mocha'))
                .then(() => execAndLog('cp .tmp/specs.js .tmp/Test/app/tests'))
                .then(() => execAndLog('ls .tmp/Test/app/tests'))
                .then(() => execAndLog(`tns test ${platform} --emulator --justlaunch --path .tmp/Test`))
                .then(() => done())
                .catch(() => {
                    process.exit(1);
                });
        });
}

function unitNativesciptIOS(done) {
    unitNativescipt('ios', done);
}

function unitNativesciptAndroid(done) {
    unitNativescipt('android', done);
}

gulp.task('clean', clean);
gulp.task('lint', lint);
gulp.task('js', ['clean', 'lint'], compile);
gulp.task('unit-node', ['clean', 'lint'], unitNode);
gulp.task('unit-browsers', ['clean', 'lint'], unitKarma);
gulp.task('unit-nativescript-ios', ['clean', 'lint'], unitNativesciptIOS);
gulp.task('unit-nativescript-android', ['clean', 'lint'], unitNativesciptAndroid);
gulp.task('dist', ['js']);

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