<commit_before>//All Requires
var gulp = require('gulp'),
    autoprefixer = require('gulp-autoprefixer'),
    minifycss = require('gulp-minify-css'),
    jshint = require('gulp-jshint'),
    uglify = require('gulp-uglify'),
    csslint = require('gulp-csslint'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    notify = require('gulp-notify'),
    livereload = require('gulp-livereload'),
    open = require('open'),
    del = require('del'),
    http = require('http'),
    ecstatic = require('ecstatic'),
    util = require('gulp-util'),
    prettify = require('gulp-prettify'),
    beautify = require('gulp-beautify'),
    stylus = require('gulp-stylus'),
    include = require('gulp-include'),
    fs = require('fs'),
    path = require('path'),
    prompt = require('gulp-prompt'),
    yuidoc = require('gulp-yuidoc'),
    bower = require('gulp-bower'),
    unzip = require('gulp-unzip'),
    zip = require('gulp-zip'),
    gzip = require('gulp-gzip'),
    tar = require('gulp-tar'),
    run = require('gulp-run'),
    git = require('gift'),
    repo = git('./'),
    webserverPort = 8080,
    isWin = /^win/.test(process.platform),
    appRoot = path.resolve('.');
    //config = require('./gulp/config');



/* Tasks (will be extracted to separated files) */

//Sideshow's main stylesheet
gulp.task('style', function(){
  compileSideshowStylesheets()
});

//Examples pages Style task
gulp.task('examples-style', function(){
  compileExamplesStylesheet();
});

//Bundle Nexit modules with Browserify
gulp.task('bundle-scripts', function(){
  bundleScripts();
});

//Clean task
gulp.task('clean', function(cb) {
  cleanFiles(cb);
});

//Watch Task
gulp.task('watch', function() {
  pollForChanges();
});

//Webserver task
gulp.task('webserver', function(){
  runDevelopmentWebServer();
});

//Default task
gulp.task('default', function() {
  compileSideshowStylesheets();
  compileExamplesStylesheet();
  // gulp.start('examples-partials');
  runDevelopmentWebServer();
  pollForChanges();

  setTimeout(function(){
    openInBrowser(util.env.browser);
  }, 3000);
});

gulp.task('update-version', function(){
  updateVersionNumberReferences();
});

gulp.task('update-bower', function(){
  updateBowerDependencies();
});

gulp.task('generate-docs', function() {
  generateDocumentation();
});

gulp.task('prepare-build', ['update-version', 'update-bower','clean'], function() {
  console.log('Remember to edit the CHANGELOG file before doing a complete build.');
});

gulp.task('complete-build', function() {
  if(prompt.confirm('Did you run the prepare-build before this?')){
    compileSideshowStylesheets();
    compileExamplesStylesheet();
    bundleScripts(function(){
      generateDocumentation();
    });
  } 
});


gulp.task('pack', function() {
  zipDistributableFiles();
  generatePackages();
});

function zipDistributableFiles(){
  var distr = gulp.src(['./distr*/**/*', './examples*/**/*', 'example.html']);

  distr
  .pipe(zip('sideshow.zip'))
  .pipe(gulp.dest('./'));

  distr
  .pipe(tar('sideshow.tar'))
  .pipe(gzip())
  .pipe(gulp.dest('./'));
}

function generatePackages(){
  del(['*.gem', '*.nupkg'], function(){
    repo.status(function(err, status){
      if(Object.keys(status.files).length === 0){
        var versionFilePath = path.join(appRoot, 'VERSION');

        fs.readFile(versionFilePath, 'utf8', function(err, version) {
          gulp.src('./')
          .pipe(run('git tag -a ' + version + ' -m \'' + version + '\''))
          .pipe(run('git push --all origin'));
          

          console.log('Building and pushing Sideshow gem');
          gulp.src('./')
          .pipe(run('gem build sideshow.gemspec'))
          .pipe(run('gem push sideshow*.gem'));

          if(isWin){
            console.log('Packing and pushing Sideshow nuget package');
            gulp.src('./')
            .pipe(run('nuget pack sideshow.nuspec'))
            .pipe(run('nuget push sideshow*.nupkg'));
          }
        });
      } else {
        console.log('Before packing a new version you must commit your changes.')
      }
    });
  });
}

function updateBowerDependencies(){
  bower()
  .on('end', function(){
    gulp.src('./bower_components/pagedown/index.zip')
    .pipe(unzip())
    .pipe(gulp.dest('./bower_components/pagedown'))<commit_msg>fixing Gulpfile for pushing gem and nuget package<commit_after>//All Requires
var gulp = require('gulp'),
    autoprefixer = require('gulp-autoprefixer'),
    minifycss = require('gulp-minify-css'),
    jshint = require('gulp-jshint'),
    uglify = require('gulp-uglify'),
    csslint = require('gulp-csslint'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    notify = require('gulp-notify'),
    livereload = require('gulp-livereload'),
    open = require('open'),
    del = require('del'),
    http = require('http'),
    ecstatic = require('ecstatic'),
    util = require('gulp-util'),
    prettify = require('gulp-prettify'),
    beautify = require('gulp-beautify'),
    stylus = require('gulp-stylus'),
    include = require('gulp-include'),
    fs = require('fs'),
    path = require('path'),
    prompt = require('gulp-prompt'),
    yuidoc = require('gulp-yuidoc'),
    bower = require('gulp-bower'),
    unzip = require('gulp-unzip'),
    zip = require('gulp-zip'),
    gzip = require('gulp-gzip'),
    tar = require('gulp-tar'),
    run = require('gulp-run'),
    git = require('gift'),
    repo = git('./'),
    webserverPort = 8080,
    isWin = /^win/.test(process.platform),
    appRoot = path.resolve('.');
    //config = require('./gulp/config');



/* Tasks (will be extracted to separated files) */

//Sideshow's main stylesheet
gulp.task('style', function(){
  compileSideshowStylesheets()
});

//Examples pages Style task
gulp.task('examples-style', function(){
  compileExamplesStylesheet();
});

//Bundle Nexit modules with Browserify
gulp.task('bundle-scripts', function(){
  bundleScripts();
});

//Clean task
gulp.task('clean', function(cb) {
  cleanFiles(cb);
});

//Watch Task
gulp.task('watch', function() {
  pollForChanges();
});

//Webserver task
gulp.task('webserver', function(){
  runDevelopmentWebServer();
});

//Default task
gulp.task('default', function() {
  compileSideshowStylesheets();
  compileExamplesStylesheet();
  // gulp.start('examples-partials');
  runDevelopmentWebServer();
  pollForChanges();

  setTimeout(function(){
    openInBrowser(util.env.browser);
  }, 3000);
});

gulp.task('update-version', function(){
  updateVersionNumberReferences();
});

gulp.task('update-bower', function(){
  updateBowerDependencies();
});

gulp.task('generate-docs', function() {
  generateDocumentation();
});

gulp.task('prepare-build', ['update-version', 'update-bower','clean'], function() {
  console.log('Remember to edit the CHANGELOG file before doing a complete build.');
});

gulp.task('complete-build', function() {
  if(prompt.confirm('Did you run the prepare-build before this?')){
    compileSideshowStylesheets();
    compileExamplesStylesheet();
    bundleScripts(function(){
      generateDocumentation();
    });
  } 
});


gulp.task('pack', function() {
  zipDistributableFiles();
  generatePackages();
});

function zipDistributableFiles(){
  var distr = gulp.src(['./distr*/**/*', './examples*/**/*', 'example.html']);

  distr
  .pipe(zip('sideshow.zip'))
  .pipe(gulp.dest('./'));

  distr
  .pipe(tar('sideshow.tar'))
  .pipe(gzip())
  .pipe(gulp.dest('./'));
}

function generatePackages(){
  del(['*.gem', '*.nupkg'], function(){
    repo.status(function(err, status){
      if(Object.keys(status.files).length === 0){
        var versionFilePath = path.join(appRoot, 'VERSION'),
            versionNumber = versionFilePath.match(/[\d.]+/);

        fs.readFile(versionFilePath, 'utf8', function(err, version) {
          gulp.src('./')
          .pipe(run('git tag -a ' + version + ' -m \'' + version + '\''))
          .pipe(run('git push --all origin'));
          

          console.log('Building and pushing Sideshow gem');
          gulp.src('./')
          .pipe(run('gem build sideshow.gemspec'))
          .pipe(run('gem push sideshow- ' + versionNumber + '.gem'));

          if(isWin){
            console.log('Packing and pushing Sideshow nuget package');
            gulp.src('./')
            .pipe(run('nuget pack sideshow.nuspec'))
            .pipe(run('nuget push sideshow.' + versionNumber + '.nupkg'));
          }
        });
      } else {
        console.log('Before packing a new version you must commit your changes.')
      }
    });
  });
}

function updateBowerDependencies(){
  bower()
  .on('end', function(){
    gulp.src('./bower_components/pagedown/index.zip')
    .pipe(unzip())
    .pipe(gulp.dest('./bower_components/pagedown'))
{'fraction_non_alphanumeric': 0.19033508092090268, 'fraction_numerical': 0.0022794620469569183, 'mean_word_length': 3.434057604850935, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '702538', 'n_tokens_mistral': 2865, 'n_tokens_neox': 2799, 'n_words': 524}