<commit_before>var gulp = require('gulp'),
   ts = require('gulp-typescript'),
   sourcemaps = require('gulp-sourcemaps'),
   clean = require('gulp-clean'),
   changed = require('gulp-changed'),
   concat = require('gulp-concat'),
   wiredep = require('wiredep').stream,
   inject = require('gulp-inject');

var config = require('./gulp.config');
var tsProject = ts.createProject({
    declarationFiles: false,
    noExternalResolve: false,
    module: 'commonjs'
});

var tsPublicProject = ts.createProject({
    declarationFiles: false,
    noExternalResolve: false
});

var tsPublicGameProject = ts.createProject({
    declarationFiles: false,
    noExternalResolve: false
});

//main task for dev
gulp.task('start', ['browser-sync','watch-game']);

//main task for deploy to heroku
gulp.task('heroku-build',['clean-deploy','copy-package','compile-all'], postBuild);


gulp.task('browser-sync',['start-server'], browserSyncTask);
gulp.task('start-server', ['compile-all'], startServer);

gulp.task('compile-all',['compile-server', 'compile-public', 'compile-game']);
gulp.task('compile-server', compileServer);
gulp.task('compile-public', compilePublic);
gulp.task('compile-game', compileGame);

gulp.task('watch-all', ['watch-server','watch-public','watch-game']);
gulp.task('watch-server', ['compile-server'],watchServer);
gulp.task('watch-public', ['compile-public'], watchPublic);
gulp.task('watch-game',['compile-game'], watchGame);

gulp.task('clean-deploy', cleanDeploy);
gulp.task('clean-js', cleanJs);
gulp.task('copy-package', copyPackage);

gulp.task('bower-inject', bowerInject);
gulp.task('custom-inject', customInject);


var browserSync = null;
function browserSyncTask(params){
   browserSync = require('browser-sync').create();
   browserSync.init(null, {
		proxy: "http://localhost:5000",
        files: ["public/**/*.*"],
        browser: "google chrome",
        port: 7000,
	});
}

function compileServer(params) {
   return gulp.src(config.tsServerSrc)
      .pipe(sourcemaps.init())
      .pipe(ts(config.tsCompiler)).js
      .pipe(gulp.dest(config.destServer));
}

function compilePublic(params) {
   var tsResult = gulp.src(config.tsPublicSrc)
      .pipe(sourcemaps.init())
      .pipe(ts(tsPublicProject));

   return tsResult.js
      .pipe(concat('public.js'))
      .pipe(sourcemaps.write('../source-maps'))
      .pipe(gulp.dest(config.destPublic+'app'));
}

function compileGame(params) {
   var tsResult = gulp.src(config.tsGameSrc)
      .pipe(sourcemaps.init())
      .pipe(ts(tsPublicGameProject));

   return tsResult.js
      .pipe(concat('game.js'))
      .pipe(sourcemaps.write('../source-maps'))
      .pipe(gulp.dest(config.destPublic+'app/game/'));
}

function watchServer(params) {
   gulp.watch(config.tsServerSrc, ['compile-server']);
}


function watchPublic(params) {
   gulp.watch(config.tsPublicSrc, ['compile-public']);
}

function watchGame(params) {
   gulp.watch(config.tsGameSrc, ['compile-game']).on('change', function(){
      setTimeout(function(){
         browserSync.reload()
      }, 500)
   });
}

function startServer(cb) {
   
   var started = false;
   var nodemon = require('gulp-nodemon');
   
   return nodemon({
      script: config.mainFile,
      ignore: ["src/public/*.*"],
      ext: 'js',
   }).on('restart', function () {
      
   }).on('start', function () {
      if (!started) {
			cb();
			started = true; 
		} 
   });
   
}

function copyPackage(params){
   return gulp.src(['package.json','Procfile']).pipe(gulp.dest('./deploy'));
}

function cleanDeploy(){
   return gulp.src('./deploy', {read: false})
          .pipe(clean());
}

function postBuild(params) {
   var files = [
      './src/**/*.js',
      './src/**/*.json',
      './src/**/*.png',
      './src/**/*.css',
      './src/**/*.vash'
      ];
      <commit_msg>update gulp<commit_after>var gulp = require('gulp'),
   ts = require('gulp-typescript'),
   sourcemaps = require('gulp-sourcemaps'),
   clean = require('gulp-clean'),
   changed = require('gulp-changed'),
   concat = require('gulp-concat'),
   wiredep = require('wiredep').stream,
   inject = require('gulp-inject');

var config = require('./gulp.config');
var tsProject = ts.createProject({
    declarationFiles: false,
    noExternalResolve: false,
    module: 'commonjs'
});

var tsPublicProject = ts.createProject({
    declarationFiles: false,
    noExternalResolve: false
});

var tsPublicGameProject = ts.createProject({
    declarationFiles: false,
    noExternalResolve: false
});

//main task for dev
gulp.task('start', ['browser-sync','watch-game']);

//main task for deploy to heroku
gulp.task('heroku-build',['clean-deploy','copy-package','compile-all'], postBuild);


gulp.task('browser-sync',['start-server'], browserSyncTask);
gulp.task('start-server', ['compile-all'], startServer);

gulp.task('compile-all',['compile-server', 'compile-public', 'compile-game']);
gulp.task('compile-server', compileServer);
gulp.task('compile-public', compilePublic);
gulp.task('compile-game', compileGame);

gulp.task('watch-all', ['watch-server','watch-public','watch-game']);
gulp.task('watch-server', ['compile-server'],watchServer);
gulp.task('watch-public', ['compile-public'], watchPublic);
gulp.task('watch-game',['compile-game'], watchGame);

gulp.task('clean-deploy', cleanDeploy);
gulp.task('clean-js', cleanJs);
gulp.task('copy-package', copyPackage);

gulp.task('bower-inject', bowerInject);
gulp.task('custom-inject', customInject);


var browserSync = null;
function browserSyncTask(params){
   browserSync = require('browser-sync').create();
   browserSync.init(null, {
		proxy: "http://localhost:5000",
        files: ["public/**/*.*"],
        browser: "google chrome",
        port: 7000,
	});
}

function compileServer(params) {
   return gulp.src(config.tsServerSrc)
      .pipe(sourcemaps.init())
      .pipe(ts(config.tsCompiler)).js
      .pipe(gulp.dest(config.destServer));
}

function compilePublic(params) {
   var tsResult = gulp.src(config.tsPublicSrc)
      .pipe(sourcemaps.init())
      .pipe(ts(tsPublicProject));

   return tsResult.js
      .pipe(concat('public.js'))
      .pipe(sourcemaps.write('../source-maps'))
      .pipe(gulp.dest(config.destPublic+'app'));
}

function compileGame(params) {
   var tsResult = gulp.src(config.tsGameSrc)
      .pipe(sourcemaps.init())
      .pipe(ts(tsPublicGameProject));

   return tsResult.js
      .pipe(concat('game.js'))
      .pipe(sourcemaps.write('../source-maps'))
      .pipe(gulp.dest(config.destPublic+'app/game/'));
}

function watchServer(params) {
   gulp.watch(config.tsServerSrc, ['compile-server']);
}


function watchPublic(params) {
   gulp.watch(config.tsPublicSrc, ['compile-public']);
}

function watchGame(params) {
   gulp.watch(config.tsGameSrc, ['compile-game']).on('change', function(){
      setTimeout(function(){
         browserSync.reload()
      }, 500)
   });
}

function startServer(cb) {
   
   var started = false;
   var nodemon = require('gulp-nodemon');
   
   return nodemon({
      script: config.mainFile,
      ignore: ["src/public/*.*"],
      ext: 'js',
   }).on('restart', function () {
      
   }).on('start', function () {
      if (!started) {
			cb();
			started = true; 
		} 
   });
   
}

function copyPackage(params){
   return gulp.src(['package.json','Procfile']).pipe(gulp.dest('./deploy'));
}

function cleanDeploy(){
   return gulp.src('./deploy', {read: false})
          .pipe(clean());
}

function postBuild(params) {
   var files = [
      './src/**/*.js',
      './src/**/*.json',
      './src/**/*.png',
      './src/**/*.css',
      './src/**/*.vash',
      './src/**/*.wav'
      ];
      
{'fraction_non_alphanumeric': 0.19626046025104602, 'fraction_numerical': 0.002876569037656904, 'mean_word_length': 3.7866082603254068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5467824', 'n_tokens_mistral': 2519, 'n_tokens_neox': 2495, 'n_words': 400}