<commit_before>/**
 *
 * gulpfile
 *
 * @description auto build JavaScript and Stylesheets for Tiny
 * @author Fantasy <fantasyshao@icloud.com>
 * @create 2014-11-14
 * @update 2014-11-23
 */

var gulp = require('gulp');

var coffee = require('gulp-coffee'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    sass = require('gulp-ruby-sass'),
    rename = require('gulp-rename');

var paths = {
  scripts: 'src/coffee/*.coffee',
  sass: 'src/sass/*.sass',
  js: 'dist/js/*.js',
  tiny_sass: 'src/sass/tiny.sass'
};

gulp.task('default', ['scripts', 'sass']);

gulp.task('scripts', function () {
  gulp.src(paths.scripts)
    .pipe(coffee({ bare: true }))
    .pipe(gulp.dest('dist/js'));
});

gulp.task('sass', function () {
  gulp.src(paths.sass)
    .pipe(sass({ style: 'compressed', noCache: true, 'sourcemap=none': true }))
    .on('error', function (err) { console.log(err.message); })
    .pipe(gulp.dest('dist/css'));
});

// Build files into production folder
gulp.task('build', ['scripts'], function () {
  gulp.src(paths.js)
    .pipe(uglify())
    .pipe(concat('tiny.min.js'))
    .pipe(gulp.dest('production'));

  gulp.src(paths.tiny_sass)
    .pipe(sass({ style: 'compressed', noCache: true, 'sourcemap=none': true }))
    .on('error', function (err) { console.log(err.message); })
    .pipe(rename('tiny.min.css'))
    .pipe(gulp.dest('production'));
});

// Example
gulp.task('eg', ['build'], function () {
  gulp.src('production/tiny.min.js')
    .pipe(gulp.dest('examples/js'));

  gulp.src('production/tiny.min.css')
    .pipe(gulp.dest('examples/css'));
});

gulp.task('watch', function () {
  gulp.watch(paths.scripts, ['scripts']);
  gulp.watch(paths.sass, ['sass']);
});

gulp.task('watch-eg', function () {
  gulp.watch('src', ['eg']);
});
<commit_msg>Update gulpfile<commit_after>/**
 *
 * gulpfile
 *
 * @description auto build JavaScript and Stylesheets for Tiny
 * @author Fantasy <fantasyshao@icloud.com>
 * @create 2014-11-14
 * @update 2014-11-23
 */

var gulp = require('gulp');

var coffee = require('gulp-coffee'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    sass = require('gulp-ruby-sass'),
    rename = require('gulp-rename');

var paths = {
  scripts: 'src/coffee/*.coffee',
  sass: 'src/sass/*.sass',
  js: 'dist/js/*.js',
  tiny_sass: 'src/sass/tiny.sass'
};

gulp.task('default', ['scripts', 'sass']);

gulp.task('scripts', function () {
  gulp.src(paths.scripts)
    .pipe(coffee({ bare: true }))
    .pipe(gulp.dest('dist/js'));
});

gulp.task('sass', function () {
  gulp.src(paths.sass)
    .pipe(sass({ style: 'compressed', noCache: true, 'sourcemap=none': true }))
    .on('error', function (err) { console.log(err.message); })
    .pipe(gulp.dest('dist/css'));
});

// Build files into production folder
gulp.task('build', ['scripts', 'sass'], function () {
  gulp.src(paths.js)
    .pipe(uglify())
    .pipe(concat('tiny.min.js'))
    .pipe(gulp.dest('production'));

  gulp.src(paths.tiny_sass)
    .pipe(sass({ style: 'compressed', noCache: true, 'sourcemap=none': true }))
    .on('error', function (err) { console.log(err.message); })
    .pipe(rename('tiny.min.css'))
    .pipe(gulp.dest('production'));
});

// Example
gulp.task('eg', function () {
  gulp.src('production/tiny.min.js')
    .pipe(gulp.dest('examples/js'));

  gulp.src('production/tiny.min.css')
    .pipe(gulp.dest('examples/css'));
});

gulp.task('watch', function () {
  gulp.watch(paths.scripts, ['scripts']);
  gulp.watch(paths.sass, ['sass']);
});

gulp.task('watch-eg', function () {
  gulp.watch(paths.scripts, ['build', 'eg']);
  gulp.watch(paths.sass, ['build', 'eg']);
});
<|endoftext|>


<commit_before>/* eslint-disable global-require */
const gulp = require('gulp');
const gutil = require('gulp-util');
const del = require('del');
const fs = require('fs.extra');
const config = require('./config/assets.config');
const WebpackWatcher = require('./config/webpack.watcher');
const { spawn } = require('child_process');

// Change current working dir to root app
process.chdir(config.appPath);

/**
 * Lint both CSS and JS files
 */
gulp.task('lint', ['lint:css', 'lint:js']);

/**
 * Runs the whole build pipeline
 */
gulp.task('build', ['lint', 'test', 'compile']);

/**
 * Default action is build
 */
gulp.task('default', ['build']);

/**
 * Uses stylelint to lint project's CSS & SCSS files
 */
gulp.task('lint:css', (cb) => {
  const stylelint = require('stylelint');

  stylelint.lint({
    configFile: '.stylelintrc.yml',
    configBasedir: config.appPath,
    files: [`${config.appPath}/**/*.?(vue|scss|css)`],
    syntax: 'scss',
    formatter: 'string',
  }).then((lintResult) => {
    console.log(lintResult.output); // eslint-disable-line no-console

    if (lintResult.errored === true) {
      const totalWarnings = lintResult.results
        .map(r => r.warnings)
        .reduce((entry, result) => result.concat(entry), [])
        .length;
      const errorWord = totalWarnings === 1 ? 'problem' : 'problems';
      const error = {
        showStack: false,
        toString: () => `Failed with ${gutil.colors.red(totalWarnings)} ${errorWord}`,
      };

      return cb(error);
    }

    return cb();
  }).catch(cb);
});

/**
 * Uses eslint to lint project's JS files
 */
gulp.task('lint:js', () => {
  const ESLint = require('eslint');
  const cli = new ESLint.CLIEngine({
    extensions: ['.js', '.vue'],
  });

  const consoleFormatter = cli.getFormatter();
  const htmlFormatter = cli.getFormatter('html');
  const output = cli.executeOnFiles(['.']);

  // Save HTML report
  const outputPath = 'report/javascript/eslint.html';
  if (!fs.existsSync('report/javascript')) {
    fs.mkdirRecursiveSync('report/javascript');
  }
  fs.writeFileSync(outputPath, htmlFormatter(output.results));

  // Output the result
  console.log(consoleFormatter(output.results)); // eslint-disable-line no-console

  if (output.errorCount >= 1) {
    const errorWord = output.errorCount === 1 ? 'problem' : 'problems';
    const error = {
      showStack: false,
      toString: () => `Failed with ${gutil.colors.red(output.errorCount)} ${errorWord}`,
    };

    throw error;
  }
});

/**
 * Run all test suite and coverage
 */
gulp.task('test', ['test:run']);

/**
 * This function returns a new function to be used as
 * a gulp callback.
 */
function executableRunner(args) {
  return (cb) => {
    const proc = spawn(process.execPath, args, { stdio: 'inherit', env: { NODE_ENV: 'test' } });
    proc.on('exit', (code, signal) => {
      // Informs gulp that we've exited
      cb();

      process.on('exit', () => {
        if (signal) {
          process.kill(process.pid, signal);
        } else {
          process.exit(code);
        }
      });
    });

    // terminate children.
    process.on('SIGINT', () => {
      proc.kill('SIGINT'); // calls runner.abort()
      proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
    });
  };
}

/**
 * Run the test suite
 */
gulp.task('test:watch', executableRunner([
  'node_modules/.bin/karma',
  'start',
  'config/karma.conf.js',
]));

/**
 * Run the test coverage
 */
gulp.task('test:run', executableRunner([
  'node_modules/.bin/karma',
  'start',
  'config/karma.conf.js',
  '--single-run',
]));

/**
 * Delete all generated assets and reports
 */
gulp.task('clean', ['clean:assets', 'clean:reports']);

/**
 * Delete all files in the assets output folder
 */
gulp.task('clean:assets', () => del(`${config.appPath}/${config.outputRelativePath}`));

/**
 * Delete all files in the reports output folder
 */
gulp.task('clean:reports', () => {
  del([`${config.appPath}/report/ruby`, `${config.appPath}/report/javascript`]);
});

/**
 * Starts webpack in watching mode
 */
gulp.task('watch', ['clean:assets'], (cb) => { // eslint-disable-line no-unused-vars
  const watcher = new WebpackWatcher({
    basePath: config.appPath,
    webpackConfigFile: 'config/webpack.config.js',
    writeErrorFile: 'tmp/webpack-error.txt',
    watchFolders: [`${config.entryPointsRelativePath}/**/*.*`],
    watchFiles: ['package.json', 'config/webpack.config.js', 'config/assets.config.js'],
    onCompile: ({ errors, warnings, time }) => {
      const totalTime = gutil.colors.magenta(`${time || '?'} ms`);

      if (warnings) {
        console.log(`\n${warnings}\n`); // eslint-disable-line no-console
      }

      if (errors) {
        console.log(`\n${errors}\n`); // eslint-disable-line no-console
        gutil.log('Compilation failed in', totalTime);
      } else {
        gutil.log('Compiled in', totalTime);
      }
    },
  });

  try {
    const outputDir = `${config.appPath}/${config.outputRelativePath}`;
    if (!fs.existsSync(outputDir)) {
      fs.mkdirSync(outputDir);
    }

    watcher.start();
  } catch (e) {
    gutil.log(gutil.colors.red.bold('Error while loading Webpack Watcher:'));
    console.log(e.toString()); // eslint-disable-line no-console
    console.log(e.stack); // eslint-disable-line no-console
  }
});

/**
 * Compiles all assets
 */
gulp.task('compile', (cb) => {
  const webpack = require('webpack');
  // eslint-disable-next-line global-require, import/no-dynamic-require
  const compiler = webpack(require(`${config.appPath}/config/webpack.config.js`));
  const outputDir = `${config.appPath}/${config.outputRelativePath}`;

  if (!fs.existsSync(outputDir)) {
    fs.mkdirSync(outputDir);
  }

  compiler.run((err, stats) => {
    if (err) {
      cb(err.stack || err);
    } else if (stats.hasErrors() || stats.hasWarnings()) {
      cb(stats.toString('verbose'));
    } else {
      cb();
    }
  });
});
<commit_msg>Fix renaming of stylelintrc.yml to stylelintrc<commit_after>/* eslint-disable global-require */
const gulp = require('gulp');
const gutil = require('gulp-util');
const del = require('del');
const fs = require('fs.extra');
const config = require('./config/assets.config');
const WebpackWatcher = require('./config/webpack.watcher');
const { spawn } = require('child_process');

// Change current working dir to root app
process.chdir(config.appPath);

/**
 * Lint both CSS and JS files
 */
gulp.task('lint', ['lint:css', 'lint:js']);

/**
 * Runs the whole build pipeline
 */
gulp.task('build', ['lint', 'test', 'compile']);

/**
 * Default action is build
 */
gulp.task('default', ['build']);

/**
 * Uses stylelint to lint project's CSS & SCSS files
 */
gulp.task('lint:css', (cb) => {
  const stylelint = require('stylelint');

  stylelint.lint({
    configFile: '.stylelintrc',
    configBasedir: config.appPath,
    files: [`${config.appPath}/**/*.?(vue|scss|css)`],
    syntax: 'scss',
    formatter: 'string',
  }).then((lintResult) => {
    console.log(lintResult.output); // eslint-disable-line no-console

    if (lintResult.errored === true) {
      const totalWarnings = lintResult.results
        .map(r => r.warnings)
        .reduce((entry, result) => result.concat(entry), [])
        .length;
      const errorWord = totalWarnings === 1 ? 'problem' : 'problems';
      const error = {
        showStack: false,
        toString: () => `Failed with ${gutil.colors.red(totalWarnings)} ${errorWord}`,
      };

      return cb(error);
    }

    return cb();
  }).catch(cb);
});

/**
 * Uses eslint to lint project's JS files
 */
gulp.task('lint:js', () => {
  const ESLint = require('eslint');
  const cli = new ESLint.CLIEngine({
    extensions: ['.js', '.vue'],
  });

  const consoleFormatter = cli.getFormatter();
  const htmlFormatter = cli.getFormatter('html');
  const output = cli.executeOnFiles(['.']);

  // Save HTML report
  const outputPath = 'report/javascript/eslint.html';
  if (!fs.existsSync('report/javascript')) {
    fs.mkdirRecursiveSync('report/javascript');
  }
  fs.writeFileSync(outputPath, htmlFormatter(output.results));

  // Output the result
  console.log(consoleFormatter(output.results)); // eslint-disable-line no-console

  if (output.errorCount >= 1) {
    const errorWord = output.errorCount === 1 ? 'problem' : 'problems';
    const error = {
      showStack: false,
      toString: () => `Failed with ${gutil.colors.red(output.errorCount)} ${errorWord}`,
    };

    throw error;
  }
});

/**
 * Run all test suite and coverage
 */
gulp.task('test', ['test:run']);

/**
 * This function returns a new function to be used as
 * a gulp callback.
 */
function executableRunner(args) {
  return (cb) => {
    const proc = spawn(process.execPath, args, { stdio: 'inherit', env: { NODE_ENV: 'test' } });
    proc.on('exit', (code, signal) => {
      // Informs gulp that we've exited
      cb();

      process.on('exit', () => {
        if (signal) {
          process.kill(process.pid, signal);
        } else {
          process.exit(code);
        }
      });
    });

    // terminate children.
    process.on('SIGINT', () => {
      proc.kill('SIGINT'); // calls runner.abort()
      proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
    });
  };
}

/**
 * Run the test suite
 */
gulp.task('test:watch', executableRunner([
  'node_modules/.bin/karma',
  'start',
  'config/karma.conf.js',
]));

/**
 * Run the test coverage
 */
gulp.task('test:run', executableRunner([
  'node_modules/.bin/karma',
  'start',
  'config/karma.conf.js',
  '--single-run',
]));

/**
 * Delete all generated assets and reports
 */
gulp.task('clean', ['clean:assets', 'clean:reports']);

/**
 * Delete all files in the assets output folder
 */
gulp.task('clean:assets', () => del(`${config.appPath}/${config.outputRelativePath}`));

/**
 * Delete all files in the reports output folder
 */
gulp.task('clean:reports', () => {
  del([`${config.appPath}/report/ruby`, `${config.appPath}/report/javascript`]);
});

/**
 * Starts webpack in watching mode
 */
gulp.task('watch', ['clean:assets'], (cb) => { // eslint-disable-line no-unused-vars
  const watcher = new WebpackWatcher({
    basePath: config.appPath,
    webpackConfigFile: 'config/webpack.config.js',
    writeErrorFile: 'tmp/webpack-error.txt',
    watchFolders: [`${config.entryPointsRelativePath}/**/*.*`],
    watchFiles: ['package.json', 'config/webpack.config.js', 'config/assets.config.js'],
    onCompile: ({ errors, warnings, time }) => {
      const totalTime = gutil.colors.magenta(`${time || '?'} ms`);

      if (warnings) {
        console.log(`\n${warnings}\n`); // eslint-disable-line no-console
      }

      if (errors) {
        console.log(`\n${errors}\n`); // eslint-disable-line no-console
        gutil.log('Compilation failed in', totalTime);
      } else {
        gutil.log('Compiled in', totalTime);
      }
    },
  });

  try {
    const outputDir = `${config.appPath}/${config.outputRelativePath}`;
    if (!fs.existsSync(outputDir)) {
      fs.mkdirSync(outputDir);
    }

    watcher.start();
  } catch (e) {
    gutil.log(gutil.colors.red.bold('Error while loading Webpack Watcher:'));
    console.log(e.toString()); // eslint-disable-line no-console
    console.log(e.stack); // eslint-disable-line no-console
  }
});

/**
 * Compiles all assets
 */
gulp.task('compile', (cb) => {
  const webpack = require('webpack');
  // eslint-disable-next-line global-require, import/no-dynamic-require
  const compiler = webpack(require(`${config.appPath}/config/webpack.config.js`));
  const outputDir = `${config.appPath}/${config.outputRelativePath}`;

  if (!fs.existsSync(outputDir)) {
    fs.mkdirSync(outputDir);
  }

  compiler.run((err, stats) => {
    if (err) {
      cb(err.stack || err);
    } else if (stats.hasErrors() || stats.hasWarnings()) {
      cb(stats.toString('verbose'));
    } else {
      cb();
    }
  });
});
<|endoftext|>


<commit_before>var gulp     = require('gulp'),
     plugins = require('gulp-load-plugins')({camelize: true});

// Lets us type "gulp" on the command line and run all of our tasks
gulp.task('default', ['jshint', 'vendor', 'scripts']);

// Hint all user-developed JS
gulp.task('jshint', function() {
  return gulp.src(['src/*.js'])
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter('default'))
    .pipe(plugins.notify({ message: 'JS Hinting task complete' }));
});

// Combine, minify all vendor JS
gulp.task('vendor', function() {
  return gulp.src(['src/vendor/jquery.history.js', 'src/vendor/jquery.imagesloaded.js'])
    .pipe(plugins.concat('wpajax-vendor.min.js'))
    .pipe(plugins.uglify())
    .pipe(gulp.dest('js/'))
    .pipe(plugins.notify({ message: 'Vendor JS task complete' }));
});

// JS concat, strip debugging and minify
gulp.task('scripts', function() {
  return gulp.src(['src/*.js', '!src/vendor{,/**}'])
    .pipe(plugins.concat('wpajax.min.js'))
    //.pipe(plugins.stripDebug())
    //.pipe(plugins.uglify())
    .pipe(gulp.dest('js/'))
    .pipe(plugins.notify({ message: 'Scripts task complete' }));
});
<commit_msg>Concat and don't uglify vendor files.<commit_after>var gulp     = require('gulp'),
     plugins = require('gulp-load-plugins')({camelize: true});

// Lets us type "gulp" on the command line and run all of our tasks
gulp.task('default', ['jshint', 'vendor', 'scripts']);

// Hint all user-developed JS
gulp.task('jshint', function() {
  return gulp.src(['src/*.js'])
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter('default'))
    .pipe(plugins.notify({ message: 'JS Hinting task complete' }));
});

// Combine, minify all vendor JS
gulp.task('vendor', function() {
  return gulp.src(['src/vendor/jquery.history.js', 'src/vendor/jquery.imagesloaded.js'])
    .pipe(plugins.concat('wpajax-vendor.min.js'))
    //.pipe(plugins.uglify())
    .pipe(gulp.dest('js/'))
    .pipe(plugins.notify({ message: 'Vendor JS task complete' }));
});

// JS concat, strip debugging and minify
gulp.task('scripts', function() {
  return gulp.src(['src/*.js', '!src/vendor{,/**}'])
    .pipe(plugins.concat('wpajax.min.js'))
    .pipe(plugins.stripDebug())
    .pipe(plugins.uglify())
    .pipe(gulp.dest('js/'))
    .pipe(plugins.notify({ message: 'Scripts task complete' }));
});
<|endoftext|>


<commit_before>const gulp = require('gulp');
const cleanCss = require('gulp-clean-css');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const browserify = require('browserify');

const css = [
  'static/css/chessground.css',
  'static/css/cburnett.css',
  'static/css/style.css'
];

gulp.task('css', () => {
  return gulp.src(css)
    .pipe(cleanCss({
      compability: 'ie8',
      level: {
        1: {
          specialComments: 0
        }
      }
    }, (details) => {
      console.log(`${details.name}: ${details.stats.originalSize} -> ${details.stats.minifiedSize}`);
    }))
    .pipe(concat('style.min.css'))
    .pipe(gulp.dest('static/css'));
});

gulp.task('js', () => {
  return browserify('src/client.js', { debug: true })
    .bundle()
    .pipe(source('client.min.js'))
    .pipe(buffer())
    .pipe(babel({
      presets: ['@babel/env']
    }))
    .pipe(uglify())
    .on('error', (err) => { console.log(`[ERROR] ${err.toString()}`); })
    .pipe(gulp.dest('static/js'));
});

gulp.task('watch', () => {
  gulp.watch(css, { ignoreInitial: false }, gulp.series('css'));
  gulp.watch('src/client.js', { ignoreInitial: false }, gulp.series('js'));
});

gulp.task('default', gulp.parallel('css', 'js'));
<commit_msg>ie8 is no longer supported<commit_after>const gulp = require('gulp');
const cleanCss = require('gulp-clean-css');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const browserify = require('browserify');

const css = [
  'static/css/chessground.css',
  'static/css/cburnett.css',
  'static/css/style.css'
];

gulp.task('css', () => {
  return gulp.src(css)
    .pipe(cleanCss({
      level: {
        1: {
          specialComments: 0
        }
      }
    }, (details) => {
      console.log(`${details.name}: ${details.stats.originalSize} -> ${details.stats.minifiedSize}`);
    }))
    .pipe(concat('style.min.css'))
    .pipe(gulp.dest('static/css'));
});

gulp.task('js', () => {
  return browserify('src/client.js', { debug: true })
    .bundle()
    .pipe(source('client.min.js'))
    .pipe(buffer())
    .pipe(babel({
      presets: ['@babel/env']
    }))
    .pipe(uglify())
    .on('error', (err) => { console.log(`[ERROR] ${err.toString()}`); })
    .pipe(gulp.dest('static/js'));
});

gulp.task('watch', () => {
  gulp.watch(css, { ignoreInitial: false }, gulp.series('css'));
  gulp.watch('src/client.js', { ignoreInitial: false }, gulp.series('js'));
});

gulp.task('default', gulp.parallel('css', 'js'));
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');

gulp.task('release', function () {
    var NwBuilder = require('node-webkit-builder');
    var nw = new NwBuilder({
        files: ['./css/**/*.*', './fonts/**/*.*', './img/**/*.*', './js/**/*.*', './node_modules/**/*.*', './index.html', './package.json'],
        version: 'v0.11.4',
        winIco: './img/favicon.png',
        macIcns: './img/favicon.png',
        macZip: true,
        platforms: ['osx32', 'osx64', 'win32', 'win64']
    });

    nw.build().then(function () {
        console.log('all done!');
    }).catch(function (error) {
        console.error(error);
    });
});<commit_msg>remove icons<commit_after>'use strict';

var gulp = require('gulp');

gulp.task('release', function() {
    var NwBuilder = require('node-webkit-builder');
    var nw = new NwBuilder({
        files: ['./css/**/*.*', './fonts/**/*.*', './img/**/*.*', './js/**/*.*', './node_modules/**/*.*', './index.html', './package.json'],
        version: 'v0.11.4',
        winIco: './img/favicon.png',
        macZip: true,
        platforms: ['osx32', 'osx64', 'win32', 'win64']
    });

    nw.build().then(function() {
        console.log('all done!');
    }).catch(function(error) {
        console.error(error);
    });
});
<|endoftext|>


<commit_before>var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var exec = require('child_process').exec;
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var plumber = require('gulp-plumber');
var reload = browserSync.reload;
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var scsslint = require('gulp-scss-lint');
var stylish = require('jshint-stylish');

// Target these browsers for adding vendor prefixes to CSS
var BROWSERS = [
  "> 5%",
  "ie > 0",
  "Firefox > 0",
  "Chrome > 0",
  "Opera > 0",
  "OperaMobile > 0",
  "OperaMini > 0",
  "Safari > 0",
  "iOS > 0",
  "Blackberry > 0",
  "Android > 0"
];

// Initialize browser-sync and proxy web server
gulp.task('browser-sync', function() {
  browserSync.init({
    logPrefix: "Pattern Library",
    server: {
      baseDir: "./dev/patterns"
    }
  });
});

// Get the patterns ready for distribution
gulp.task('dist', function() {
  gulp.src(['dev/patterns/**/*.scss', 'dev/patterns/**/*.md'])
    .pipe(plumber())
    .pipe(gulp.dest('dist/patterns'));

  gulp.src('dev/*.scss')
    .pipe(plumber())
    .pipe(rename('_pattern-library.scss'))
    .pipe(gulp.dest('dist'));
});

// Lint JavaScript and JSON files.
gulp.task('jslint', function() {
  return gulp.src(['*.json', '*.js', 'dist/patterns/**/*.json'])
    .pipe(jshint())
    .pipe(jshint.reporter(stylish));
});

// Full Browser Reload (HTML, JS, JSON files)
gulp.task('reload', reload);

// Lint Sass files (.scss)
gulp.task('scss-lint', function() {
  gulp.src(['dev/*.scss', 'dev/patterns/**/*.scss'])
    .pipe(scsslint());
});

// Compile and prefix Sass code into CSS,
// then reload the browser (stream when possible).
gulp.task('sass', function() {
  gulp.src(['dev/*.scss', 'dev/patterns/**/*.scss'])
    .pipe(plumber())
    .pipe(sass())
    .pipe(autoprefixer({
      browsers: BROWSERS
    }))
    .pipe(gulp.dest('dev/patterns'))
    .pipe(browserSync.stream());
});

// Watch for changes on these files
// Run these specific tasks when files change.
gulp.task('watch', function() {
  gulp.watch(['dev/patterns/**/html/*.html', 'dev/patterns/*.html']).on('change', reload);
  gulp.watch(['*.json', '*.js', 'dist/patterns/**/*.json'], ['jslint']).on('change', reload);
  gulp.watch(['dev/*.scss', 'dev/patterns/**/*.scss'], ['sass', 'scss-lint', 'dist']);
});

// Default task -- run these tasks.
gulp.task('default', ['browser-sync', 'sass', 'dist', 'watch']);
<commit_msg>Add patterns.js to gulpfile watch task<commit_after>var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync').create();
var exec = require('child_process').exec;
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var plumber = require('gulp-plumber');
var reload = browserSync.reload;
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var scsslint = require('gulp-scss-lint');
var stylish = require('jshint-stylish');

// Target these browsers for adding vendor prefixes to CSS
var BROWSERS = [
  "> 5%",
  "ie > 0",
  "Firefox > 0",
  "Chrome > 0",
  "Opera > 0",
  "OperaMobile > 0",
  "OperaMini > 0",
  "Safari > 0",
  "iOS > 0",
  "Blackberry > 0",
  "Android > 0"
];

// Initialize browser-sync and proxy web server
gulp.task('browser-sync', function() {
  browserSync.init({
    logPrefix: "Pattern Library",
    server: {
      baseDir: "./dev/patterns"
    }
  });
});

// Get the patterns ready for distribution
gulp.task('dist', function() {
  gulp.src(['dev/patterns/**/*.scss', 'dev/patterns/**/*.md'])
    .pipe(plumber())
    .pipe(gulp.dest('dist/patterns'));

  gulp.src('dev/*.scss')
    .pipe(plumber())
    .pipe(rename('_pattern-library.scss'))
    .pipe(gulp.dest('dist'));
});

// Lint JavaScript and JSON files.
gulp.task('jslint', function() {
  return gulp.src(['*.json', '*.js', 'dist/patterns/**/*.json'])
    .pipe(jshint())
    .pipe(jshint.reporter(stylish));
});

// Full Browser Reload (HTML, JS, JSON files)
gulp.task('reload', reload);

// Lint Sass files (.scss)
gulp.task('scss-lint', function() {
  gulp.src(['dev/*.scss', 'dev/patterns/**/*.scss'])
    .pipe(scsslint());
});

// Compile and prefix Sass code into CSS,
// then reload the browser (stream when possible).
gulp.task('sass', function() {
  gulp.src(['dev/*.scss', 'dev/patterns/**/*.scss'])
    .pipe(plumber())
    .pipe(sass())
    .pipe(autoprefixer({
      browsers: BROWSERS
    }))
    .pipe(gulp.dest('dev/patterns'))
    .pipe(browserSync.stream());
});

// Watch for changes on these files
// Run these specific tasks when files change.
gulp.task('watch', function() {
  gulp.watch(['dev/patterns/**/html/*.html', 'dev/patterns/*.html']).on('change', reload);
  gulp.watch(['*.json', '*.js', 'dist/patterns/**/*.json', 'dev/patterns/*.js'], ['jslint']).on('change', reload);
  gulp.watch(['dev/*.scss', 'dev/patterns/**/*.scss'], ['sass', 'scss-lint', 'dist']);
});

// Default task -- run these tasks.
gulp.task('default', ['browser-sync', 'sass', 'dist', 'watch']);
<|endoftext|>


<commit_before>'use strict';
/* jshint node:true */

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

var packageJson = require('./src/package.json');

process.NODE_ENV = 'test';

gulp.task('electron', function() {

    gulp.src("")
    .pipe(electron({
        src: './src',
        packageJson: packageJson,
        release: './release',
        cache: './cache',
        version: 'v0.35.2',
        rebuild: false,
        packaging: true,
        asar: false,
        platforms: ['linux-x64'],
        platformResources: {
            darwin: {
                CFBundleDisplayName: packageJson.name,
                CFBundleIdentifier: packageJson.name,
                CFBundleName: packageJson.name,
                CFBundleVersion: packageJson.version,
                icon: 'gulp-electron.icns'
            },
            win: {
                "version-string": packageJson.version,
                "file-version": packageJson.version,
                "product-version": packageJson.version,
                "icon": 'gulp-electron.ico'
            }
        }
    }))
    .pipe(gulp.dest(""));
});

gulp.task('default', ['electron']);
<commit_msg>update build script<commit_after>'use strict';
/* jshint node:true */

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

var packageJson = require('./src/package.json');

process.NODE_ENV = 'test';

gulp.task('electron', function() {

    gulp.src("")
    .pipe(electron({
        src: './src',
        packageJson: packageJson,
        release: './release',
        cache: './cache',
        version: 'v0.35.2',
        rebuild: false,
        packaging: true,
        asar: false,
        platforms: ['linux-ia32', 'linux-x64', 'win32-ia32', 'darwin-x64'],
        platformResources: {
            darwin: {
                CFBundleDisplayName: packageJson.name,
                CFBundleIdentifier: packageJson.name,
                CFBundleName: packageJson.name,
                CFBundleVersion: packageJson.version,
                icon: './resources/cheatsheet.icns'
            },
            win: {
                "version-string": packageJson.version,
                "file-version": packageJson.version,
                "product-version": packageJson.version,
                "icon": './resources/cheatsheet.ico'
            }
        }
    }))
    .pipe(gulp.dest(""));
});

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


<commit_before>var gulp = require("gulp");
var sourcemaps = require("gulp-sourcemaps");
var babel = require("gulp-babel");
var plumber = require('gulp-plumber');
var concat = require("gulp-concat");

gulp.task("default", function() {
  return gulp.src("src/*.jsx")
    .pipe(plumber())
    //.pipe(sourcemaps.init())
    .pipe(babel())
    //.pipe(concat("app.js"))
    //.pipe(sourcemaps.write("."))
    .pipe(gulp.dest("dist"))
    .on('error', function(err){ console.log(err.message); });
});

gulp.watch('src/*.jsx', ['default']);
<commit_msg>Remove gulp-sourcemaps and gulp-concat<commit_after>var gulp = require('gulp');
var babel = require('gulp-babel');
var plumber = require('gulp-plumber');

gulp.task('default', function() {
  return gulp.src('src/*.jsx')
    .pipe(plumber())
    .pipe(babel())
    .pipe(gulp.dest('dist'))
    .on('error', function(err){ console.log(err.message); });
});

gulp.watch('src/*.jsx', ['default']);
<|endoftext|>


<commit_before>"use strict";
/*global require*/
var _                = require("lodash");
var del              = require("del");
var path             = require("path");
var runSequence      = require("run-sequence");

var gulp             = require("gulp");
var harmonize        = require("harmonize");
var awspublish       = require("gulp-awspublish");
var rename           = require("gulp-rename");
var parallelize      = require("concurrent-transform");
var gutil            = require("gulp-util");
var deploy           = require("gulp-gh-pages");
var cloudfront       = require('gulp-invalidate-cloudfront');
var notifier         = require("node-notifier");
var merge            = require('merge-stream');

var ngrok            = require('ngrok');
var webpack          = require("webpack");
var WebpackDevServer = require("webpack-dev-server");

// Get our Config.
var config           = require("./config");
var webpackConfig    = require("./webpack.config");

harmonize();

var notify = function(message){
  notifier.notify({title: config.displayName+" Gulp",message:message});
};

// Setup a Ngrok server
var ngrokServe = function(subdomain){
  var options = { port: config.serverPort };
  var env = process.env;
  if (env.NGROK_AUTHTOKEN) {
    options.authtoken = env.NGROK_AUTHTOKEN;

    if(env.NGROK_SUBDOMAIN || subdomain){
      options.subdomain = (env.NGROK_SUBDOMAIN || subdomain).replace(/-/g,'');
    }
  }
  ngrok.connect(options, function (error, url) {
    if (error) {
      throw new gutil.PluginError('ship:server', error);
    }

    url = url.replace('https', 'http');
    notify({message:"Ngrok Started on "+url});

    gutil.log('[ship:server]', url);
  });
}

gulp.task("default", ["server"]);
gulp.task("serve",   ["server"]);
gulp.task("clean",   function(callback) {del(["./"+config.outputFolder+"/**/*"], callback); });

gulp.task("server",  function(callback) {runSequence("clean", "copy-files:watch", "webpack:server", callback); });
gulp.task("build",   function(callback) {runSequence("clean", "copy-files", "webpack:build", callback); });
gulp.task("deploy",  function(callback) {runSequence("build", "publish:sha", callback); });
gulp.task("deploy:release",  function(callback) {runSequence("build", "publish:release", callback); });

var notify = function(message){
  notifier.notify({title: config.displayName+" Gulp", message: message});
};
var handleError = function(err, taskName){
  if(err){
    notify(taskName+" Error: "+ err);
    throw new gutil.PluginError("webpack:build", err);
  }
};
// Copy static files from the source to the destination
var copyFiles = function(callback){
  _.map(config.files, function(dest, src){
    gulp.src(src).pipe(gulp.dest(dest));
  });
  notify("Vendors Updated");
  if (_.isFunction(callback)){
    callback();
  }
};

gulp.task("copy-files", copyFiles);

gulp.task("copy-files:watch", function(){
  copyFiles();
  gulp.watch(_.keys(config.files), copyFiles);
});

//Production Build.
//Minified, clean code. No demo keys inside.
//demo.html WILL NOT WORK with this build.
//
//Webpack handles CSS/SCSS, JS, and HTML files.
var afterBuild = function(err, stats){
  if (!!err) {throw new gutil.PluginError("webpack:build", err); }

  var jsonStats = stats.toJson();

  if (jsonStats.errors.length > 0) {
    return new gutil.PluginError("webpack:build", JSON.stringify(jsonStats.errors));
  }

  if (jsonStats.warnings.length > 0) {
    new gutil.PluginError("webpack:build", JSON.stringify(jsonStats.warnings));
  }

  gutil.log("[webpack:build]", stats.toString({colors: true}));
  notify("App Built");
};
gulp.task("webpack:build", function(callback) {
  // Then, use Webpack to bundle all JS and html files to the destination folder
  notify("Building App");
  webpack(_.values(webpackConfig.production), function(err, stats) {
    afterBuild(err, stats);
    webpack(_.values(webpackConfig.debug), function(err, stats){
      afterBuild(err, stats);
      callback();
    });
  });
});

// Dev Build
// Create the webpack compiler here for caching and performance.
var devCompiler = webpack(webpackConfig.development.browser);

// Build a Dev version of the project. Launched once on startup so we can have eveything copied.
gulp.task("webpack:build:dev", function(callback) {
  // run webpack with Dev profile.
  // Embeds the Hull config keys, and the necessary stuff to make demo.html work
  devCompiler.run(function(err, stats) {
    if (err){
      throw new gutil.PluginError("webpack:build:dev", err);
    }

    var jsonStats = stats.toJson();

    if(jsonStats.errors.length > 0){
      return new gutil.PluginError("webpack:build:dev", JSON.stringify(jsonStats.errors));
    }

    if(jsonStats.warnings.length > 0){
      new gutil.PluginError("webpack:build:dev", JSON.stringify(jsonStats.warnings));
    }

    gutil.log("[webpack:build:dev]", stats.toString({colors: true}));
    notify({message: "Webpack Updated"});
    callback();
  });
});

// Launch webpack dev server.
gulp.task("webpack:server", function() {
  var taskName = "webpack:server";
  new WebpackDevServer(devCompiler, {
    contentBase: config.outputFolder,
    publicPath: config.assetsFolder+"/",
    hot: config.hotReload,
    stats: {colors: true }
  }).listen(config.serverPort, function(err) {
    handleError(err, taskName);
    // Dump the preview URL in the console, and open Chrome when launched for convenience.
    notify({message: "Dev Server Started"});
    var url = webpackConfig.development.browser.output.publicPath+"webpack-dev-server/";
    ngrokServe(config.libName)
    gutil.log("["+taskName+"]", url);
  });
});

var publish = function(versions){
  var aws = config.aws
  var publisher = awspublish.create(aws.config);
  var files  = path.join(config.outputFolder, config.assetsFolder, "*")
  var streams = [];
  var cloudfrontInvalidations = []
  for (var i = 0; i < versions.length; i++) {
    var version = versions[i];
    if(version){
      console.log('Deploying to ',version);
      var plain = gulp.src(files)
      .pipe(rename(function(p){
        p.dirname += '/'+version;
        console.log('Publishing '+path.join(p.dirname,p.basename+p.extname))
      }))
      var gzip = gulp.src(files)
      .pipe(rename(function(p){
        p.dirname += '/'+version;
        console.log('Publishing '+path.join(p.dirname,p.basename+p.extname))
      }))
      .pipe(awspublish.gzip(aws.gzip))
      cloudfrontInvalidations.push('/'+version+'/*');
      streams.push(plain);
      streams.push(gzip);
    }
  };

  var invalidationBatch = {
    CallerReference: new Date().toString(),
    Paths:{
      Quantity:1,
      Items:cloudfrontInvalidations
    }
  }
  return merge.apply(merge,streams)
  .pipe(parallelize(publisher.publish(aws.publish.headers,aws.publish.options)))
  .pipe(publisher.cache())
  // .pipe(cloudfront(invalidationBatch, aws.cloudfront))
  .pipe(awspublish.reporter())
}

// Deploys to S3
gulp.task('publish:sha',function(){
  var SHA1 = process.env.CIRCLE_SHA1;
  if( !SHA1 ){ return; }
  return publish([SHA1]);
});

gulp.task('publish:release',function(){
  var SHA1 = process.env.CIRCLE_SHA1;
  var RELEASE = config.pkg.version;
  if( !SHA1 || !RELEASE ){ return; }
  return publish([SHA1,RELEASE]);
});
<commit_msg>re-enable cloudfront invalidation<commit_after>"use strict";
/*global require*/
var _                = require("lodash");
var del              = require("del");
var path             = require("path");
var runSequence      = require("run-sequence");

var gulp             = require("gulp");
var harmonize        = require("harmonize");
var awspublish       = require("gulp-awspublish");
var rename           = require("gulp-rename");
var parallelize      = require("concurrent-transform");
var gutil            = require("gulp-util");
var deploy           = require("gulp-gh-pages");
var cloudfront       = require('gulp-invalidate-cloudfront');
var notifier         = require("node-notifier");
var merge            = require('merge-stream');

var ngrok            = require('ngrok');
var webpack          = require("webpack");
var WebpackDevServer = require("webpack-dev-server");

// Get our Config.
var config           = require("./config");
var webpackConfig    = require("./webpack.config");

harmonize();

var notify = function(message){
  notifier.notify({title: config.displayName+" Gulp",message:message});
};

// Setup a Ngrok server
var ngrokServe = function(subdomain){
  var options = { port: config.serverPort };
  var env = process.env;
  if (env.NGROK_AUTHTOKEN) {
    options.authtoken = env.NGROK_AUTHTOKEN;

    if(env.NGROK_SUBDOMAIN || subdomain){
      options.subdomain = (env.NGROK_SUBDOMAIN || subdomain).replace(/-/g,'');
    }
  }
  ngrok.connect(options, function (error, url) {
    if (error) {
      throw new gutil.PluginError('ship:server', error);
    }

    url = url.replace('https', 'http');
    notify({message:"Ngrok Started on "+url});

    gutil.log('[ship:server]', url);
  });
}

gulp.task("default", ["server"]);
gulp.task("serve",   ["server"]);
gulp.task("clean",   function(callback) {del(["./"+config.outputFolder+"/**/*"], callback); });

gulp.task("server",  function(callback) {runSequence("clean", "copy-files:watch", "webpack:server", callback); });
gulp.task("build",   function(callback) {runSequence("clean", "copy-files", "webpack:build", callback); });
gulp.task("deploy",  function(callback) {runSequence("build", "publish:sha", callback); });
gulp.task("deploy:release",  function(callback) {runSequence("build", "publish:release", callback); });

var notify = function(message){
  notifier.notify({title: config.displayName+" Gulp", message: message});
};
var handleError = function(err, taskName){
  if(err){
    notify(taskName+" Error: "+ err);
    throw new gutil.PluginError("webpack:build", err);
  }
};
// Copy static files from the source to the destination
var copyFiles = function(callback){
  _.map(config.files, function(dest, src){
    gulp.src(src).pipe(gulp.dest(dest));
  });
  notify("Vendors Updated");
  if (_.isFunction(callback)){
    callback();
  }
};

gulp.task("copy-files", copyFiles);

gulp.task("copy-files:watch", function(){
  copyFiles();
  gulp.watch(_.keys(config.files), copyFiles);
});

//Production Build.
//Minified, clean code. No demo keys inside.
//demo.html WILL NOT WORK with this build.
//
//Webpack handles CSS/SCSS, JS, and HTML files.
var afterBuild = function(err, stats){
  if (!!err) {throw new gutil.PluginError("webpack:build", err); }

  var jsonStats = stats.toJson();

  if (jsonStats.errors.length > 0) {
    return new gutil.PluginError("webpack:build", JSON.stringify(jsonStats.errors));
  }

  if (jsonStats.warnings.length > 0) {
    new gutil.PluginError("webpack:build", JSON.stringify(jsonStats.warnings));
  }

  gutil.log("[webpack:build]", stats.toString({colors: true}));
  notify("App Built");
};
gulp.task("webpack:build", function(callback) {
  // Then, use Webpack to bundle all JS and html files to the destination folder
  notify("Building App");
  webpack(_.values(webpackConfig.production), function(err, stats) {
    afterBuild(err, stats);
    webpack(_.values(webpackConfig.debug), function(err, stats){
      afterBuild(err, stats);
      callback();
    });
  });
});

// Dev Build
// Create the webpack compiler here for caching and performance.
var devCompiler = webpack(webpackConfig.development.browser);

// Build a Dev version of the project. Launched once on startup so we can have eveything copied.
gulp.task("webpack:build:dev", function(callback) {
  // run webpack with Dev profile.
  // Embeds the Hull config keys, and the necessary stuff to make demo.html work
  devCompiler.run(function(err, stats) {
    if (err){
      throw new gutil.PluginError("webpack:build:dev", err);
    }

    var jsonStats = stats.toJson();

    if(jsonStats.errors.length > 0){
      return new gutil.PluginError("webpack:build:dev", JSON.stringify(jsonStats.errors));
    }

    if(jsonStats.warnings.length > 0){
      new gutil.PluginError("webpack:build:dev", JSON.stringify(jsonStats.warnings));
    }

    gutil.log("[webpack:build:dev]", stats.toString({colors: true}));
    notify({message: "Webpack Updated"});
    callback();
  });
});

// Launch webpack dev server.
gulp.task("webpack:server", function() {
  var taskName = "webpack:server";
  new WebpackDevServer(devCompiler, {
    contentBase: config.outputFolder,
    publicPath: config.assetsFolder+"/",
    hot: config.hotReload,
    stats: {colors: true }
  }).listen(config.serverPort, function(err) {
    handleError(err, taskName);
    // Dump the preview URL in the console, and open Chrome when launched for convenience.
    notify({message: "Dev Server Started"});
    var url = webpackConfig.development.browser.output.publicPath+"webpack-dev-server/";
    ngrokServe(config.libName)
    gutil.log("["+taskName+"]", url);
  });
});

var publish = function(versions){
  var aws = config.aws
  var publisher = awspublish.create(aws.config);
  var files  = path.join(config.outputFolder, config.assetsFolder, "*")
  var streams = [];
  var cloudfrontInvalidations = []
  for (var i = 0; i < versions.length; i++) {
    var version = versions[i];
    if(version){
      console.log('Deploying to ',version);
      var plain = gulp.src(files)
      .pipe(rename(function(p){
        p.dirname += '/'+version;
        console.log('Publishing '+path.join(p.dirname,p.basename+p.extname))
      }))
      var gzip = gulp.src(files)
      .pipe(rename(function(p){
        p.dirname += '/'+version;
        console.log('Publishing '+path.join(p.dirname,p.basename+p.extname))
      }))
      .pipe(awspublish.gzip(aws.gzip))
      cloudfrontInvalidations.push('/'+version+'/*');
      streams.push(plain);
      streams.push(gzip);
    }
  };

  var invalidationBatch = {
    CallerReference: new Date().toString(),
    Paths:{
      Quantity:1,
      Items:cloudfrontInvalidations
    }
  }
  return merge.apply(merge,streams)
  .pipe(parallelize(publisher.publish(aws.publish.headers,aws.publish.options)))
  .pipe(publisher.cache())
  .pipe(cloudfront(invalidationBatch, aws.cloudfront))
  .pipe(awspublish.reporter())
}

// Deploys to S3
gulp.task('publish:sha',function(){
  var SHA1 = process.env.CIRCLE_SHA1;
  if( !SHA1 ){ return; }
  return publish([SHA1]);
});

gulp.task('publish:release',function(){
  var SHA1 = process.env.CIRCLE_SHA1;
  var RELEASE = config.pkg.version;
  if( !SHA1 || !RELEASE ){ return; }
  return publish([SHA1,RELEASE]);
});
<|endoftext|>


<commit_before>    //Gulp and plugins
var gulp        = require('gulp'),
    mocha       = require('gulp-mocha'),
    plumber     = require('gulp-plumber'),
    watch       = require('gulp-watch');

gulp.task('exercises:language:runner', function() {
  gulp.src('exercises/language/*.js', {read: false})
    .pipe(plumber())
    .pipe(mocha({reporter: 'spec', bail: true}));
});

gulp.task('exercises:language:watcher', function() {
  gulp.watch('exercises/language/*.js', ['exercises:language:runner']);
});

gulp.task('exercises:language', ['exercises:language:watcher']);
<commit_msg>Update gulp tasks to use mocha-phantom<commit_after>    //Gulp and plugins
var gulp        = require('gulp'),
    concat      = require('gulp-concat'),
    plumber     = require('gulp-plumber'),
    watch       = require('gulp-watch'),
    runner      = require('gulp-mocha-phantomjs');

gulp.task('exercises:language:watcher', function() {
  gulp.watch('exercises/language/*_spec.js', ['exercises:language:builder', 'exercises:language:runner']);
});

gulp.task('exercises:language:builder', function() {
  gulp.src(['exercises/language/*.js'])
    .pipe(plumber())
    .pipe(concat('tests.js'))
    .pipe(gulp.dest('exercises/test_runner'))
});

gulp.task('exercises:language:runner', function () {
  gulp.src('exercises/test_runner/index.html')
    .pipe(plumber())
    .pipe(runner({mocha:{bail:true}}));
});

gulp.task('exercises:language', ['exercises:language:watcher']);
<|endoftext|>


<commit_before>'use strict';

var gulp          = require('gulp');
var $             = require('gulp-load-plugins')();
var bowerFiles    = require('bower-files')({'dev': true});
var runSequence   = require('run-sequence');
var browserSync   = require('browser-sync');
var reload        = browserSync.reload;

var AUTOPREFIXER_BROWSERS = [
    'ie >= 10',
    'ie_mob >= 10',
    'ff >= 30',
    'chrome >= 34',
    'safari >= 7',
    'opera >= 23',
    'ios >= 7',
    'android >= 4.4',
    'bb >= 10'
];

/**
 * gulp build:styles
 */
gulp.task('build:styles', function () {
    return gulp.src(['app/styles/less/style.less'])
        .pipe($.less())
        .on('error', console.error.bind(console))
        .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
        .pipe($.csslint())
        .pipe($.minifyCss())
        .pipe($.concat('style.css'))
        .pipe(gulp.dest('./'))
        .pipe($.size({title: 'styles'}));
});

/**
 * gulp build:scripts
 */
gulp.task('build:scripts', function () {
    return gulp.src('app/**/*.js')
        .pipe($.changed('dist/'))
        .pipe($.uglify())
        .pipe(gulp.dest('dist/'))
        .pipe($.size({title: 'scripts'}));
});

/**
 * gulp build:templates
 */
gulp.task('build:templates', function () {
    return gulp.src('app/templates/**/*.{html,dust}')
        .pipe($.changed('dist/templates/'))
        .pipe($.dust())
        .pipe(gulp.dest('dist/templates/'))
        .pipe($.size({title: 'templates'}));
});

/**
 * gulp build:images
 */
gulp.task('build:images', function () {
    return gulp.src('app/assets/images/**/*')
        .pipe($.changed('dist/assets/images/'))
        .pipe($.cache($.imagemin({
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('dist/assets/images/'))
        .pipe($.size({title: 'images'}));
});

/**
 * gulp build:fonts
 */
gulp.task('build:fonts', function () {
    return gulp.src('app/assets/fonts/**/*.{eot,svg,ttf,woff}')
        .pipe($.flatten())
        .pipe(gulp.dest('dist/assets/fonts/'))
        .pipe($.size({title: 'fonts'}));
});

/**
 * gulp bower
 */
gulp.task('bower', function () {
    // console.log(bowerFiles);

    gulp.src(bowerFiles.js)
        .pipe($.uglify())
        .pipe(gulp.dest('lib/'));

    gulp.src(bowerFiles.css)
        .pipe($.minifyCss())
        .pipe(gulp.dest('lib/css/'));

    gulp.src(bowerFiles.eot + bowerFiles.svg + bowerFiles.ttf + bowerFiles.woff)
        .pipe(gulp.dest('fonts/'));
});

/**
 * gulp jshint
 */
gulp.task('jshint', function () {
    return gulp.src('app/**/*.js')
        .pipe(reload({stream: true, once: true}))
        .pipe($.jshint())
        .pipe($.jshint.reporter('jshint-stylish'))
        .pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});

/**
 * gulp jasmine
 */
gulp.task('jasmine', function () {

    // var specRunner = require('./test/jasmine/config/test-init.js');

    // TODO: Jasmine + RequireJS
    return gulp.src('test/jasmine/config/test-init.js')
        .pipe($.coverage.instrument({
            pattern: ['**/*.spec.js'],
            debugDirectory: 'debug'
        }))
        .pipe($.jasmine())
        .pipe($.coverage.report({
            outFile: 'test/jasmine/coverage.html'
        }));
});

/**
 * gulp phpunit
 */
gulp.task('phpunit', function () {
    return gulp.src('test/phpunit/**/test*.php')
        .pipe($.phpunit());
});

/**
 * gulp test
 */
gulp.task('test', ['jasmine', 'phpunit']);

/**
 * gulp watch
 */
gulp.task('watch', function () {

    browserSync({
        notify: false,
        server: {
            baseDir: './',
            directory: true,
        },
        host: 'localhost',
        port: 3000,
        // browser: ["google chrome", "firefox"],
        logLevel: 'debug'
    });

    /**
     * Rebuild on changed sources.
     */

    gulp.watch('test/jasmine/specs/**/*.spec.js',
        reload);

    gulp.watch(['index.html', '*.php'],
        reload);

    gulp.watch(['app/**/*.js', 'lib/**/*.js'],
        ['build:scripts', reload]);

    gulp.watch('app/templates/**/*.{html,dust}',
        ['build:templates', reload]);

    gulp.watch(['app/assets/**/*.css',
                'app/assets/**/*.less',
                'app/assets/**/*.scss',
                'lib/**/*.css',
                'lib/**/*.less',
                'lib/**/*.scss'],
        ['build:styles', reload]);

    gulp.watch(['app/assets/fonts/**/*.eot',
                'app/assets/fonts/**/*.svg',
                'app/assets/fonts/**/*.ttf',
                'app/assets/fonts/**/*.woff',
                'lib/fonts/**/*.eot',
                'lib/fonts/**/*.svg',
                'lib/fonts/**/*.ttf',
                'lib/fonts/**/*.woff'],
        ['build:fonts', reload]);

    gulp.watch('app/assets/images/**/*',
        ['build:images', reload]);
});

/**
 * gulp clean
 */
gulp.task('clean', function () {
    return gulp.src(['dist/', 'lib/'], { read: false })
        .pipe($.rimraf());
});

/**
 * gulp build
 */
gulp.task('build', function (cb) {
    runSequence('bower', ['jshint', 'build:scripts', 'build:templates', 'build:styles', 'build:images', 'build:fonts'], cb);
});

/**
 * gulp
 */
gulp.task('default', ['clean'], function () {
    gulp.start(['build']);
});
<commit_msg>Fixed styles path<commit_after>'use strict';

var gulp          = require('gulp');
var $             = require('gulp-load-plugins')();
var bowerFiles    = require('bower-files')({'dev': true});
var runSequence   = require('run-sequence');
var browserSync   = require('browser-sync');
var reload        = browserSync.reload;

var AUTOPREFIXER_BROWSERS = [
    'ie >= 10',
    'ie_mob >= 10',
    'ff >= 30',
    'chrome >= 34',
    'safari >= 7',
    'opera >= 23',
    'ios >= 7',
    'android >= 4.4',
    'bb >= 10'
];

/**
 * gulp build:styles
 */
gulp.task('build:styles', function () {
    return gulp.src(['app/styles/less/style.less'])
        .pipe($.less())
        .on('error', console.error.bind(console))
        .pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
        .pipe($.csslint())
        .pipe($.minifyCss())
        .pipe($.concat('style.css'))
        .pipe(gulp.dest('./'))
        .pipe($.size({title: 'styles'}));
});

/**
 * gulp build:scripts
 */
gulp.task('build:scripts', function () {
    return gulp.src('app/**/*.js')
        .pipe($.changed('dist/'))
        .pipe($.uglify())
        .pipe(gulp.dest('dist/'))
        .pipe($.size({title: 'scripts'}));
});

/**
 * gulp build:templates
 */
gulp.task('build:templates', function () {
    return gulp.src('app/templates/**/*.{html,dust}')
        .pipe($.changed('dist/templates/'))
        .pipe($.dust())
        .pipe(gulp.dest('dist/templates/'))
        .pipe($.size({title: 'templates'}));
});

/**
 * gulp build:images
 */
gulp.task('build:images', function () {
    return gulp.src('app/assets/images/**/*')
        .pipe($.changed('dist/assets/images/'))
        .pipe($.cache($.imagemin({
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('dist/assets/images/'))
        .pipe($.size({title: 'images'}));
});

/**
 * gulp build:fonts
 */
gulp.task('build:fonts', function () {
    return gulp.src('app/assets/fonts/**/*.{eot,svg,ttf,woff}')
        .pipe($.flatten())
        .pipe(gulp.dest('dist/assets/fonts/'))
        .pipe($.size({title: 'fonts'}));
});

/**
 * gulp bower
 */
gulp.task('bower', function () {
    // console.log(bowerFiles);

    gulp.src(bowerFiles.js)
        .pipe($.uglify())
        .pipe(gulp.dest('lib/'));

    gulp.src(bowerFiles.css)
        .pipe($.minifyCss())
        .pipe(gulp.dest('lib/css/'));

    gulp.src(bowerFiles.eot + bowerFiles.svg + bowerFiles.ttf + bowerFiles.woff)
        .pipe(gulp.dest('fonts/'));
});

/**
 * gulp jshint
 */
gulp.task('jshint', function () {
    return gulp.src('app/**/*.js')
        .pipe(reload({stream: true, once: true}))
        .pipe($.jshint())
        .pipe($.jshint.reporter('jshint-stylish'))
        .pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});

/**
 * gulp jasmine
 */
gulp.task('jasmine', function () {

    // var specRunner = require('./test/jasmine/config/test-init.js');

    // TODO: Jasmine + RequireJS
    return gulp.src('test/jasmine/config/test-init.js')
        .pipe($.coverage.instrument({
            pattern: ['**/*.spec.js'],
            debugDirectory: 'debug'
        }))
        .pipe($.jasmine())
        .pipe($.coverage.report({
            outFile: 'test/jasmine/coverage.html'
        }));
});

/**
 * gulp phpunit
 */
gulp.task('phpunit', function () {
    return gulp.src('test/phpunit/**/test*.php')
        .pipe($.phpunit());
});

/**
 * gulp test
 */
gulp.task('test', ['jasmine', 'phpunit']);

/**
 * gulp watch
 */
gulp.task('watch', function () {

    browserSync({
        notify: false,
        server: {
            baseDir: './',
            directory: true,
        },
        host: 'localhost',
        port: 3000,
        // browser: ["google chrome", "firefox"],
        logLevel: 'debug'
    });

    /**
     * Rebuild on changed sources.
     */

    gulp.watch('test/jasmine/specs/**/*.spec.js',
        reload);

    gulp.watch(['index.html', '*.php'],
        reload);

    gulp.watch(['app/**/*.js', 'lib/**/*.js'],
        ['build:scripts', reload]);

    gulp.watch('app/templates/**/*.{html,dust}',
        ['build:templates', reload]);

    gulp.watch(['app/styles/**/*.{css,less,scss}', 'lib/**/*.{css,less,scss}'],
        ['build:styles', reload]);

    gulp.watch(['app/assets/fonts/**/*.{eot,svg,ttf,woff}', 'lib/fonts/**/*.{eot,svg,ttf,woff}'],
        ['build:fonts', reload]);

    gulp.watch('app/assets/images/**/*',
        ['build:images', reload]);
});

/**
 * gulp clean
 */
gulp.task('clean', function () {
    return gulp.src(['dist/', 'lib/'], { read: false })
        .pipe($.rimraf());
});

/**
 * gulp build
 */
gulp.task('build', function (cb) {
    runSequence('bower', ['jshint', 'build:scripts', 'build:templates', 'build:styles', 'build:images', 'build:fonts'], cb);
});

/**
 * gulp
 */
gulp.task('default', ['clean'], function () {
    gulp.start(['build']);
});
<|endoftext|>


<commit_before>'use strict';

let babelify = require('babelify');
let browserify = require('browserify');
let childProcess = require('child_process');
let concat = require('gulp-concat');
let gulp = require('gulp');
let path = require('path');
let source = require('vinyl-source-stream');
let uglify = require('gulp-uglifyjs');

const isRelease = process.env.NODE_ENV === 'production';

const SRC = [
    'client/js/libs/favico.js',
    'client/js/libs/handlebars.js',
    'client/js/libs/handlebars/**/*.js',
    'client/js/libs/jquery.js',
    'client/js/libs/jquery/**/*.js',
    'client/js/libs/moment.js',
    'client/js/libs/notification.js',
    'client/js/libs/socket.io.js',
    'client/js/libs/string.contains.js',
    'client/js/libs/stringcolor.js',
    'client/js/libs/uri.js',
];

gulp.task('uglify', function () {
    return gulp.src(SRC)
        .pipe(uglify('libs.min.js', {
            compress: false,
        }))
        .pipe(gulp.dest('client/dist/js/'));
});

gulp.task('build', function () {
    let handlebars = path.relative(__dirname, './node_modules/handlebars/bin/handlebars');
    let args = [
        String(handlebars),
        'client/views/',
        '-e', 'tpl',
        '-f', 'client/dist/js/shout.templates.js',
    ];

    let option = {
        cwd: path.relative(__dirname, ''),
        stdio: 'inherit',
    };
    childProcess.spawn('node', args, option);
});

gulp.task('build2', function () {
    const SRC_JS = ['./client/script/shout.js'];

    let option = {
        insertGlobals: false,
        debug: isRelease ? false : true,
    };

    let babel = babelify.configure({
        optional: [
            'utility.inlineEnvironmentVariables',
        ],
    });

    browserify(SRC_JS, option)
        .transform(babel)
        .bundle()
        .pipe(source('bundle.js'))
        .pipe(gulp.dest('client/dist/'));
});

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

gulp.task('watch', ['uglify'], function () {
    gulp.watch(SRC, ['uglify']);
});
<commit_msg>Add license header to gulpfile.js<commit_after>/**
 * @license MIT License
 *
 * Copyright (c) 2015 Tetsuharu OHZEKI <saneyuki.snyk@gmail.com>
 *
 * 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.
 */

'use strict';

let babelify = require('babelify');
let browserify = require('browserify');
let childProcess = require('child_process');
let concat = require('gulp-concat');
let gulp = require('gulp');
let path = require('path');
let source = require('vinyl-source-stream');
let uglify = require('gulp-uglifyjs');

const isRelease = process.env.NODE_ENV === 'production';

const SRC = [
    'client/js/libs/favico.js',
    'client/js/libs/handlebars.js',
    'client/js/libs/handlebars/**/*.js',
    'client/js/libs/jquery.js',
    'client/js/libs/jquery/**/*.js',
    'client/js/libs/moment.js',
    'client/js/libs/notification.js',
    'client/js/libs/socket.io.js',
    'client/js/libs/string.contains.js',
    'client/js/libs/stringcolor.js',
    'client/js/libs/uri.js',
];

gulp.task('uglify', function () {
    return gulp.src(SRC)
        .pipe(uglify('libs.min.js', {
            compress: false,
        }))
        .pipe(gulp.dest('client/dist/js/'));
});

gulp.task('build', function () {
    let handlebars = path.relative(__dirname, './node_modules/handlebars/bin/handlebars');
    let args = [
        String(handlebars),
        'client/views/',
        '-e', 'tpl',
        '-f', 'client/dist/js/shout.templates.js',
    ];

    let option = {
        cwd: path.relative(__dirname, ''),
        stdio: 'inherit',
    };
    childProcess.spawn('node', args, option);
});

gulp.task('build2', function () {
    const SRC_JS = ['./client/script/shout.js'];

    let option = {
        insertGlobals: false,
        debug: isRelease ? false : true,
    };

    let babel = babelify.configure({
        optional: [
            'utility.inlineEnvironmentVariables',
        ],
    });

    browserify(SRC_JS, option)
        .transform(babel)
        .bundle()
        .pipe(source('bundle.js'))
        .pipe(gulp.dest('client/dist/'));
});

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

gulp.task('watch', ['uglify'], function () {
    gulp.watch(SRC, ['uglify']);
});
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    less = require('gulp-less'),
    path = require('path'),
    runSequence = require('run-sequence'),
    uglify = require('gulp-uglify'),
    concat = require('gulp-concat'),
    minifyHTML = require('gulp-minify-html')
    ;

gulp.task('less', function () {
  gulp.src('./src/less/site.less')
    .pipe(less({
      paths: [ path.join(__dirname, 'less', 'includes') ]
    }))
    .pipe(gulp.dest('./www/wp-content/themes/AngularJs/css'));
});

gulp.task('compress', function() {
    gulp.src('./src/js/*.js')
        .pipe(uglify())
        .pipe(gulp.dest('./www/wp-content/themes/AngularJs/js'))
});

/*
    WATCH
*/
gulp.task('watch', function() {

    // Watch the less files
    gulp.watch('./src/less/*.less', ['less']);
    gulp.watch('./src/js/*.js', ['compress']);

});

/*
    BUILD
*/
gulp.task('build', function() {
    runSequence(
        'less',
        function() {
            console.log('built ok')
        });

});

gulp.task('default', ['watch']);<commit_msg>Added new compress and compress_build tasks<commit_after>var gulp = require('gulp'),
    less = require('gulp-less'),
    path = require('path'),
    runSequence = require('run-sequence'),
    uglify = require('gulp-uglify'),
    concat = require('gulp-concat'),
    minifyHTML = require('gulp-minify-html')
    ;

gulp.task('less', function () {
  gulp.src('./src/less/site.less')
    .pipe(less({
      paths: [ path.join(__dirname, 'less', 'includes') ]
    }))
    .pipe(gulp.dest('./www/wp-content/themes/AngularJs/css'));
});

gulp.task('compress', function() {
    gulp.src(
        './src/js/*.js'
    )
        .pipe(uglify())
        .pipe(gulp.dest('./src/dist'))
});

gulp.task('compress_build', function() {
    gulp.src([
        './src/js/lib/angular/angular.min.js',
        './src/js/*.js'
    ])
        .pipe(uglify())
        .pipe(gulp.dest('./www/wp-content/themes/AngularJs/js'))
});

/*
    WATCH
*/
gulp.task('watch', function() {

    // Watch the less files
    gulp.watch('./src/less/*.less', ['less']);
    gulp.watch('./src/js/*.js', ['compress']);

});

/*
    BUILD
*/
gulp.task('build', function() {
    runSequence(
        'less',
        'compress_build',
        function() {
            console.log('built ok')
        });

});

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


<commit_before>'use strict';

var gulp = require('gulp');
var watch = require('gulp-watch');
var sync = require('gulp-sync')(gulp);
var sass = require('gulp-sass');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var clean = require('gulp-clean');

gulp.task('dist-clean', function () {
  return gulp.src('dist/', {read: false})
      .pipe(clean());
});

gulp.task('jquery', function () {
  return gulp.src(['assets/bower_components/jquery/dist/jquery.min.js'])
      .pipe(gulp.dest('static/dist/js'));
});

gulp.task('semantic-ui', function () {
  gulp.src(['assets/bower_components/semantic/dist/semantic.min.js'])
      .pipe(gulp.dest('static/dist/js'));

  return gulp.src(['assets/bower_components/semantic/dist/semantic.min.css'])
      .pipe(gulp.dest('static/dist/css'));
});

gulp.task('uglify', function () {
  return gulp.src(['assets/js/**/*.js'])
      .pipe(jshint())
      .pipe(jshint.reporter('jshint-stylish'))
      .pipe(uglify())
      .pipe(gulp.dest('static/dist/js'));
});

gulp.task('sass', function () {
  return gulp.src([
    'assets/scss/**/*.scss',
    '!assets/scss/import/*.scss'
  ])
      .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
      .pipe(gulp.dest('assets/css'));
});

gulp.task('css', function () {
  return gulp.src(['assets/css/**/*.css'])
      .pipe(rename({suffix: '.min'}))
      .pipe(gulp.dest('static/dist/css'));
});

gulp.task('build', sync.sync([
  'dist-clean',
  [
    'jquery',
    'semantic-ui',
    'uglify',
    'sass'
  ],
  'css'
]));

gulp.task('build:watch', function () {
  gulp.watch('static/assets/scss/**/*.scss', ['sass']);
  gulp.watch('static/assets/css/**/*.css', ['minify']);
  gulp.watch('static/assets/js/**/*.js', ['uglify']);
});
<commit_msg><commit_after>'use strict';

var gulp = require('gulp');
var watch = require('gulp-watch');
var sync = require('gulp-sync')(gulp);
var sass = require('gulp-sass');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var clean = require('gulp-clean');

gulp.task('dist-clean', function () {
  return gulp.src('dist/', {read: false})
      .pipe(clean());
});

gulp.task('jquery', function () {
  return gulp.src(['assets/bower_components/jquery/dist/jquery.min.js'])
      .pipe(gulp.dest('static/dist/js'));
});

gulp.task('semantic-ui', function () {
  gulp.src(['assets/bower_components/semantic/dist/semantic.min.js'])
      .pipe(gulp.dest('static/dist/js'));

  return gulp.src(['assets/bower_components/semantic/dist/semantic.min.css'])
      .pipe(gulp.dest('static/dist/css'));
});

gulp.task('uglify', function () {
  return gulp.src(['assets/js/**/*.js'])
      .pipe(jshint())
      .pipe(jshint.reporter('jshint-stylish'))
      .pipe(uglify())
      .pipe(gulp.dest('static/dist/js'));
});

gulp.task('sass', function () {
  return gulp.src([
    'assets/scss/**/*.scss'
  ])
      .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
      .pipe(rename({suffix: '.min'}))
      .pipe(gulp.dest('static/dist/css'));
});

gulp.task('build', sync.sync([
  'dist-clean',
  [
    'jquery',
    'semantic-ui',
    'uglify',
    'sass'
  ]
]));

gulp.task('build:watch', function () {
  gulp.watch('static/assets/scss/**/*.scss', ['sass']);
  gulp.watch('static/assets/js/**/*.js', ['uglify']);
});
<|endoftext|>


<commit_before>'use strict';

var es           = require( 'event-stream' );
var del          = require( 'del' );
var browserSync  = require( 'browser-sync' ).create();
var reload       = browserSync.reload;

var gulp         = require( 'gulp' );
var aigis        = require( 'gulp-aigis' );
var autoprefixer = require( 'gulp-autoprefixer' );
var concat       = require( 'gulp-concat' );
var consolidate  = require( 'gulp-consolidate' );
var iconfont     = require( 'gulp-iconfont' );
var minifyCSS    = require( 'gulp-minify-css' );
var plumber      = require( 'gulp-plumber' );
var rename       = require( 'gulp-rename' );
var sass         = require( 'gulp-sass' );
var uglify       = require( 'gulp-uglify' );
var watch        = require( 'gulp-watch' );
var awspublish   = require('gulp-awspublish');

var runSequence  = require( 'run-sequence' ).use( gulp );

gulp.task( 'browser-sync', function () {

  browserSync.init({
    server: {
      baseDir: './',
      directory: true
    }
  } );

} );

gulp.task( 'clean', function () {

  del( './build/' );

} );

gulp.task( 'copy-font', function () {

  return gulp.src( [
          './src/assets2/font/zero-width.eot',
          './src/assets2/font/zero-width.otf',
          './src/assets2/font/zero-width.svg',
          './src/assets2/font/zero-width.ttf',
          './src/assets2/font/zero-width.woff'
         ] )
         .pipe( gulp.dest( './build/assets2/font/' ) );

} );

gulp.task( 'copy-img', function () {

  return gulp.src( [
          './src/assets2/img/*/**'
         ] )
         .pipe( gulp.dest( './build/assets2/img/' ) );

} );

gulp.task( 'copy-static', function () {

  return gulp.src( [
          './static/*/**',
         ] )
         .pipe( gulp.dest( './build/' ) );

} );

gulp.task( 'js', function () {

  return gulp.src( [
          './src/assets2/js/vendor/prism.js',
          './src/assets2/js/CG2-drawer.js',
          './src/assets2/js/CG2-compactNav.js',
          './src/assets2/js/CG2-searchOption.js'
         ] )
         .pipe( plumber() )
         .pipe( concat( 'codegrid-ui.js' ) )
         .pipe( gulp.dest( './build/assets2/js/' ) )
         .pipe( uglify() )
         .pipe( rename( { extname: '.min.js' } ) )
         .pipe( gulp.dest( './build/assets2/js/' ) );

} );

gulp.task( 'sass', function () {

  return gulp.src( './src/assets2/scss/codegrid-ui.scss' )
         .pipe( sass( { bundleExec: true } ) )
         .pipe( gulp.dest( './build/assets2/css/' ) )
         .pipe( rename( { extname: '.min.css' } ) )
         .pipe( minifyCSS() )
         .pipe( gulp.dest( './build/assets2/css/' ) );

} );

gulp.task( 'iconfont', function () {

  var fontName = 'codegrid-icon';

  return gulp.src( [ './src/assets2/font/codegrid-icon/*.svg' ] )
  .pipe( iconfont( {
    fontName: fontName,
    appendCodepoints: true
  } ) )
  .on( 'codepoints', function( codepoints, options ) {

    gulp.src( './src/assets2/font/codegrid-icon/_icon.scss' )
    .pipe( consolidate( 'underscore', {
      glyphs: codepoints,
      fontName: fontName,
      fontPath: '../font/',
      prefix: 'CG2-icon'
    } ) )
    .pipe( gulp.dest( './src/assets2/scss/' ) );

  } )
  .pipe( gulp.dest( './build/assets2/font/' ) );

} );

gulp.task( 'numfont', function () {

  var fontName = 'codegrid-num';

  return gulp.src( [ './src/assets2/font/codegrid-num/*.svg' ] )
  .pipe( iconfont( {
    fontName: fontName,
    fontHeight: 256,
    descent: 24
  } ) )
  .pipe( gulp.dest( './build/assets2/font/' ) );

} );

gulp.task( 'guide', function () {

  return gulp.src( './aigis_config.yml' )
         .pipe( aigis() )
         .pipe( gulp.dest( '' ) );

} );

gulp.task( 'watch', function () {

  // watch( [ './**/*.html' ], function () {
  //   runSequence( browserSync.reload );
  // } );

  watch( [ './src/assets2/js/*.js' ], function () {
    runSequence( 'js', browserSync.reload );
  } );

  watch( [ './src/assets2/scss/*.scss' ], function () {
    runSequence( 'sass', browserSync.reload );
  } );

  // watch( [ './src/assets2/font/codegrid-icon/*.svg' ], function () {
  //   runSequence( 'iconfont', 'sass', browserSync.reload );
  // } );

} );

gulp.task( 'default', function( callback ) {

  runSequence( 'browser-sync', 'iconfont', [ 'numfont', 'copy-font', 'copy-img', 'copy-static', 'js', 'sass' ], 'watch', callback );

} );

gulp.task( 'build', function( callback ) {

  runSequence( 'clean', 'iconfont', [ 'numfont', 'copy-font', 'copy-img', 'copy-static', 'js', 'sass' ], 'guide', callback );

} );

gulp.task('deploy', ['build'], function() {
  var publisher = awspublish.create({
    "params": {
      "Bucket": "ui.codegrid.net"
    },
    "endpoint": "s3-ap-northeast-1.amazonaws.com"
  });
  gulp.src('./build/**/*')
    .pipe(publisher.publish())
    .pipe(publisher.sync())
    .pipe(awspublish.reporter());
})
<commit_msg>deploy時にbuildしない（circle ci エラー対策）<commit_after>'use strict';

var es           = require( 'event-stream' );
var del          = require( 'del' );
var browserSync  = require( 'browser-sync' ).create();
var reload       = browserSync.reload;

var gulp         = require( 'gulp' );
var aigis        = require( 'gulp-aigis' );
var autoprefixer = require( 'gulp-autoprefixer' );
var concat       = require( 'gulp-concat' );
var consolidate  = require( 'gulp-consolidate' );
var iconfont     = require( 'gulp-iconfont' );
var minifyCSS    = require( 'gulp-minify-css' );
var plumber      = require( 'gulp-plumber' );
var rename       = require( 'gulp-rename' );
var sass         = require( 'gulp-sass' );
var uglify       = require( 'gulp-uglify' );
var watch        = require( 'gulp-watch' );
var awspublish   = require('gulp-awspublish');

var runSequence  = require( 'run-sequence' ).use( gulp );

gulp.task( 'browser-sync', function () {

  browserSync.init({
    server: {
      baseDir: './',
      directory: true
    }
  } );

} );

gulp.task( 'clean', function () {

  del( './build/' );

} );

gulp.task( 'copy-font', function () {

  return gulp.src( [
          './src/assets2/font/zero-width.eot',
          './src/assets2/font/zero-width.otf',
          './src/assets2/font/zero-width.svg',
          './src/assets2/font/zero-width.ttf',
          './src/assets2/font/zero-width.woff'
         ] )
         .pipe( gulp.dest( './build/assets2/font/' ) );

} );

gulp.task( 'copy-img', function () {

  return gulp.src( [
          './src/assets2/img/*/**'
         ] )
         .pipe( gulp.dest( './build/assets2/img/' ) );

} );

gulp.task( 'copy-static', function () {

  return gulp.src( [
          './static/*/**',
         ] )
         .pipe( gulp.dest( './build/' ) );

} );

gulp.task( 'js', function () {

  return gulp.src( [
          './src/assets2/js/vendor/prism.js',
          './src/assets2/js/CG2-drawer.js',
          './src/assets2/js/CG2-compactNav.js',
          './src/assets2/js/CG2-searchOption.js'
         ] )
         .pipe( plumber() )
         .pipe( concat( 'codegrid-ui.js' ) )
         .pipe( gulp.dest( './build/assets2/js/' ) )
         .pipe( uglify() )
         .pipe( rename( { extname: '.min.js' } ) )
         .pipe( gulp.dest( './build/assets2/js/' ) );

} );

gulp.task( 'sass', function () {

  return gulp.src( './src/assets2/scss/codegrid-ui.scss' )
         .pipe( sass( { bundleExec: true } ) )
         .pipe( gulp.dest( './build/assets2/css/' ) )
         .pipe( rename( { extname: '.min.css' } ) )
         .pipe( minifyCSS() )
         .pipe( gulp.dest( './build/assets2/css/' ) );

} );

gulp.task( 'iconfont', function () {

  var fontName = 'codegrid-icon';

  return gulp.src( [ './src/assets2/font/codegrid-icon/*.svg' ] )
  .pipe( iconfont( {
    fontName: fontName,
    appendCodepoints: true
  } ) )
  .on( 'codepoints', function( codepoints, options ) {

    gulp.src( './src/assets2/font/codegrid-icon/_icon.scss' )
    .pipe( consolidate( 'underscore', {
      glyphs: codepoints,
      fontName: fontName,
      fontPath: '../font/',
      prefix: 'CG2-icon'
    } ) )
    .pipe( gulp.dest( './src/assets2/scss/' ) );

  } )
  .pipe( gulp.dest( './build/assets2/font/' ) );

} );

gulp.task( 'numfont', function () {

  var fontName = 'codegrid-num';

  return gulp.src( [ './src/assets2/font/codegrid-num/*.svg' ] )
  .pipe( iconfont( {
    fontName: fontName,
    fontHeight: 256,
    descent: 24
  } ) )
  .pipe( gulp.dest( './build/assets2/font/' ) );

} );

gulp.task( 'guide', function () {

  return gulp.src( './aigis_config.yml' )
         .pipe( aigis() )
         .pipe( gulp.dest( '' ) );

} );

gulp.task( 'watch', function () {

  // watch( [ './**/*.html' ], function () {
  //   runSequence( browserSync.reload );
  // } );

  watch( [ './src/assets2/js/*.js' ], function () {
    runSequence( 'js', browserSync.reload );
  } );

  watch( [ './src/assets2/scss/*.scss' ], function () {
    runSequence( 'sass', browserSync.reload );
  } );

  // watch( [ './src/assets2/font/codegrid-icon/*.svg' ], function () {
  //   runSequence( 'iconfont', 'sass', browserSync.reload );
  // } );

} );

gulp.task( 'default', function( callback ) {

  runSequence( 'browser-sync', 'iconfont', [ 'numfont', 'copy-font', 'copy-img', 'copy-static', 'js', 'sass' ], 'watch', callback );

} );

gulp.task( 'build', function( callback ) {

  runSequence( 'clean', 'iconfont', [ 'numfont', 'copy-font', 'copy-img', 'copy-static', 'js', 'sass' ], 'guide', callback );

} );

gulp.task('deploy', function() {
  var publisher = awspublish.create({
    "params": {
      "Bucket": "ui.codegrid.net"
    },
    "endpoint": "s3-ap-northeast-1.amazonaws.com"
  });
  gulp.src('./build/**/*')
    .pipe(publisher.publish())
    .pipe(publisher.sync())
    .pipe(awspublish.reporter());
})
<|endoftext|>


<commit_before>var gulp = require('gulp');
var mocha = require('gulp-mocha');
var jshint = require('gulp-jshint');
var webpack = require('webpack-stream');
var concatCSS = require('gulp-concat-css');
var minifyCSS = require('gulp-minify-css');

var appFiles = ['server.js', __dirname + '/routes/**/*.js',
                __dirname + '/models/**/*.js',
                __dirname + '/lib/**/*.js',
                __dirname + '/lib/**/*.js'
                ];

var testFiles = [__dirname + '/test/**/*.js'];
var htmlFiles = [__dirname + '/app/**/*.html'];
var cssFiles = ['/app/css/reset.css', '/app/css/base.css', '/app/css/layout.css', '/app/css/modules.css', '/app/css/state.css'];

/* * * * * * * * * * * * * * * * * *
            BUILD TASKS
 * * * * * * * * * * * * * * * * * */

// place all html in build folder.
gulp.task('static:dev', function() {
  return gulp.src(htmlFiles)
  .pipe(gulp.dest('build/'))
});

// generate entry.js, run through webpack, send to build folder.
gulp.task('webpack:dev', function() {
  return gulp.src('app/js/entry.js')
  .pipe(webpack({
    output: {
      filename: 'bundle.js'
    }
  }))
  .pipe(gulp.dest('build/'));
});

// for client tests.
gulp.task('webpack:test', function() {
  return gulp.src('test/client/test_entry.js')
  .pipe(webpack({
    output: {
      file: 'test_bundle.js'
    }
  }))
  .pipe(gulp.dest('test/client'));
})

gulp.task('css:dev', function() {
  gulp.src(cssFiles)
  .pipe(concatCSS('styles.min.css'))
  .pipe(minifyCSS())
  .pipe(gulp.dest('/build'));
});

 /* * * * * * * * * * * * * * * * * *
            LINT TASKS
 * * * * * * * * * * * * * * * * * */

gulp.task('jshint:appfiles', function() {
  gulp.src(appFiles)
  .pipe(jshint({
    node: true
  }))
  .pipe(jshint.reporter('default'));
});

//does not include client tests
gulp.task('jshint:testfiles', function() {
  gulp.src('test/*.js')
  .pipe(jshint({
      node: true,
      globals: {
        before: true,
        after: true,
        it: true,
        expect: true
      }
    }))
  .pipe(jshint.reporter('default'));
});

 /* * * * * * * * * * * * * * * * * *
            TEST TASKS
 * * * * * * * * * * * * * * * * * */
gulp.task('mocha', function() {
  gulp.src('/test/routes-test', {read: false})
  .pipe(mocha());
  console.log('**********************************');
  console.log('FOR CLIENT TESTS, RUN $karma start');
  console.log('**********************************');

});
 /* * * * * * * * * * * * * * * * * *
            WATCH TASKS
 * * * * * * * * * * * * * * * * * */

gulp.task('watch:build', function() {
  gulp.watch(htmlFiles, ['static:dev']);
  gulp.watch(cssFiles, ['css:dev']);
  gulp.watch('app/**/*.js', ['webpack:dev']);
  //gulp.watch('test/client/**/*.js', ['webpack:test']);    UNCOMMENT WHEN CLIENT TESTS BUILT
});

gulp.task('watch:check', function() {
  gulp.watch(appFiles, ['mocha'])
})

 /* * * * * * * * * * * * * * * * * *
        QUICK TASKS & DEFAULT
 * * * * * * * * * * * * * * * * * */

 gulp.task('jshint', ['jshint:appfiles', 'jshint:testfiles']);
 gulp.task('build', ['static:dev', 'css:dev', 'webpack:dev']);    // ADD webpack:tests WHEN CLIENT TESTS BUILT

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

<commit_msg>update gulpfile again<commit_after>var gulp = require('gulp');
var mocha = require('gulp-mocha');
var jshint = require('gulp-jshint');
var webpack = require('webpack-stream');
var concatCSS = require('gulp-concat-css');
var minifyCSS = require('gulp-minify-css');

var appFiles = ['server.js', __dirname + '/routes/**/*.js',
                __dirname + '/models/**/*.js',
                __dirname + '/lib/**/*.js',
                __dirname + '/lib/**/*.js'
                ];

var testFiles = [__dirname + '/test/**/*.js'];
var htmlFiles = [__dirname + '/app/**/*.html'];
var cssFiles = ['app/css/reset.css', 'app/css/base.css', 'app/css/layout.css', 'app/css/modules.css', 'app/css/state.css'];

/* * * * * * * * * * * * * * * * * *
            BUILD TASKS
 * * * * * * * * * * * * * * * * * */

// place all html in build folder.
gulp.task('static:dev', function() {
  return gulp.src(htmlFiles)
  .pipe(gulp.dest('build/'))
});

// generate entry.js, run through webpack, send to build folder.
gulp.task('webpack:dev', function() {
  return gulp.src('app/js/entry.js')
  .pipe(webpack({
    output: {
      filename: 'bundle.js'
    }
  }))
  .pipe(gulp.dest('build/'));
});

// for client tests.
gulp.task('webpack:test', function() {
  return gulp.src('test/client/test_entry.js')
  .pipe(webpack({
    output: {
      file: 'test_bundle.js'
    }
  }))
  .pipe(gulp.dest('test/client'));
})

gulp.task('css:dev', function() {
  gulp.src(cssFiles)
  .pipe(concatCSS('styles.min.css'))
  .pipe(minifyCSS())
  .pipe(gulp.dest('build/'));
});

 /* * * * * * * * * * * * * * * * * *
            LINT TASKS
 * * * * * * * * * * * * * * * * * */

gulp.task('jshint:appfiles', function() {
  gulp.src(appFiles)
  .pipe(jshint({
    node: true
  }))
  .pipe(jshint.reporter('default'));
});

//does not include client tests
gulp.task('jshint:testfiles', function() {
  gulp.src('test/*.js')
  .pipe(jshint({
      node: true,
      globals: {
        before: true,
        after: true,
        it: true,
        expect: true
      }
    }))
  .pipe(jshint.reporter('default'));
});

 /* * * * * * * * * * * * * * * * * *
            TEST TASKS
 * * * * * * * * * * * * * * * * * */
gulp.task('mocha', function() {
  gulp.src('/test/routes-test', {read: false})
  .pipe(mocha());
  console.log('**********************************');
  console.log('FOR CLIENT TESTS, RUN $karma start');
  console.log('**********************************');

});
 /* * * * * * * * * * * * * * * * * *
            WATCH TASKS
 * * * * * * * * * * * * * * * * * */

gulp.task('watch:build', function() {
  gulp.watch(htmlFiles, ['static:dev']);
  gulp.watch(cssFiles, ['css:dev']);
  gulp.watch('app/**/*.js', ['webpack:dev']);
  //gulp.watch('test/client/**/*.js', ['webpack:test']);    UNCOMMENT WHEN CLIENT TESTS BUILT
});

gulp.task('watch:check', function() {
  gulp.watch(appFiles, ['mocha'])
})

 /* * * * * * * * * * * * * * * * * *
        QUICK TASKS & DEFAULT
 * * * * * * * * * * * * * * * * * */

 gulp.task('jshint', ['jshint:appfiles', 'jshint:testfiles']);
 gulp.task('build', ['static:dev', 'css:dev', 'webpack:dev']);    // ADD webpack:tests WHEN CLIENT TESTS BUILT

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

<|endoftext|>


<commit_before>'use strict';

var pngquant = require('imagemin-pngquant');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

// Object with directory paths
var dirs = {
  bower: './bower_components',
  css: './assets/css',
  fonts: './assets/fonts',
  images: './assets/images',
  icons: './assets/icons',
  js: './assets/js'
};

// Autoprefixer options
var autoprefixerOptions = {
  browsers: ['last 2 versions']
};

// Imagemin options
var imageminOptions = {
  progressive: true,
  svgoPlugins: [{removeViewBox: false}],
  use: [pngquant()]
};

// Compile sass for development (uncompressed)
gulp.task('styles:dev', function () {
  gulp.src(dirs.css + '/**/*.scss')
    .pipe($.sourcemaps.init())
    .pipe($.sass().on('error', $.sass.logError))
    .pipe($.autoprefixer(autoprefixerOptions))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest(dirs.css));
});

// Compile sass for production (compressed)
gulp.task('styles', function () {
  gulp.src(dirs.css + '/**/*.scss')
    .pipe($.sass({outputStyle: 'compressed'}).on('error', $.sass.logError))
    .pipe($.autoprefixer(autoprefixerOptions))
    .pipe(gulp.dest(dirs.css));
});

// Copy fonts
gulp.task('fonts', function () {
  gulp.src([dirs.bower + '/font-awesome/fonts/*'])
    .pipe(gulp.dest(dirs.fonts + '/'));
});

// Concat JavaScript
gulp.task('scripts', function () {
  // Copy modernizr from bower_components
  gulp.src([dirs.bower + '/modernizr/modernizr.js'])
      .pipe(gulp.dest(dirs.js + '/'));

  // Process JavaScript files
  gulp.src([
    dirs.bower + '/jquery/dist/jquery.js',
    dirs.bower + '/AdminLTE/bootstrap/js/bootstrap.js',
    dirs.bower + '/AdminLTE/plugins/fastclick/fastclick.js',
    dirs.bower + '/AdminLTE/plugins/slimScroll/jquery.slimscroll.js',
    dirs.bower + '/AdminLTE/dist/js/app.js',
    dirs.js + '/*.js',
    '!' + dirs.js + '/modernizr.js',
    '!' + dirs.js + '/build.js'
  ])
  .pipe($.concat('build.js'))
  .pipe($.uglify())
  .pipe(gulp.dest(dirs.js + '/'));
});

// Copy and optimize images
gulp.task('images', function () {
  gulp.src([dirs.bower + '/AdminLTE/dist/img/*'])
    .pipe(gulp.dest(dirs.images + '/'));

  gulp.src(dirs.images + '/*')
    .pipe($.imagemin(imageminOptions))
    .pipe(gulp.dest(dirs.images));
});

// Watch task
gulp.task('watch', function () {
  gulp.watch(dirs.css + '/**/*.scss', ['styles:dev']);
  gulp.watch([
    dirs.js + '/*.js',
    '!' + dirs.js + '/build.js'
  ], ['scripts']);
});

// Clean task
gulp.task('clean', function () {
  gulp.src([
    dirs.js + '/build.js',
    dirs.css + '/style.css'
  ], {read: false})
    .pipe($.clean());
});

// Register default and dev task
gulp.task('default', ['styles', 'fonts', 'scripts', 'images'], function () {});
gulp.task('dev', ['default', 'watch'], function () {});
<commit_msg>Copy bootstrap fonts<commit_after>'use strict';

var pngquant = require('imagemin-pngquant');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

// Object with directory paths
var dirs = {
  bower: './bower_components',
  css: './assets/css',
  fonts: './assets/fonts',
  images: './assets/images',
  icons: './assets/icons',
  js: './assets/js'
};

// Autoprefixer options
var autoprefixerOptions = {
  browsers: ['last 2 versions']
};

// Imagemin options
var imageminOptions = {
  progressive: true,
  svgoPlugins: [{removeViewBox: false}],
  use: [pngquant()]
};

// Compile sass for development (uncompressed)
gulp.task('styles:dev', function () {
  gulp.src(dirs.css + '/**/*.scss')
    .pipe($.sourcemaps.init())
    .pipe($.sass().on('error', $.sass.logError))
    .pipe($.autoprefixer(autoprefixerOptions))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest(dirs.css));
});

// Compile sass for production (compressed)
gulp.task('styles', function () {
  gulp.src(dirs.css + '/**/*.scss')
    .pipe($.sass({outputStyle: 'compressed'}).on('error', $.sass.logError))
    .pipe($.autoprefixer(autoprefixerOptions))
    .pipe(gulp.dest(dirs.css));
});

// Copy fonts
gulp.task('fonts', function () {
  gulp.src([dirs.bower + '/font-awesome/fonts/*'])
    .pipe(gulp.dest(dirs.fonts + '/'));
  gulp.src([dirs.bower + '/AdminLTE/bootstrap/fonts/*'])
    .pipe(gulp.dest(dirs.fonts + '/'));
});

// Concat JavaScript
gulp.task('scripts', function () {
  // Copy modernizr from bower_components
  gulp.src([dirs.bower + '/modernizr/modernizr.js'])
      .pipe(gulp.dest(dirs.js + '/'));

  // Process JavaScript files
  gulp.src([
    dirs.bower + '/jquery/dist/jquery.js',
    dirs.bower + '/AdminLTE/bootstrap/js/bootstrap.js',
    dirs.bower + '/AdminLTE/plugins/fastclick/fastclick.js',
    dirs.bower + '/AdminLTE/plugins/slimScroll/jquery.slimscroll.js',
    dirs.bower + '/AdminLTE/dist/js/app.js',
    dirs.js + '/*.js',
    '!' + dirs.js + '/modernizr.js',
    '!' + dirs.js + '/build.js'
  ])
  .pipe($.concat('build.js'))
  .pipe($.uglify())
  .pipe(gulp.dest(dirs.js + '/'));
});

// Copy and optimize images
gulp.task('images', function () {
  gulp.src([dirs.bower + '/AdminLTE/dist/img/*'])
    .pipe(gulp.dest(dirs.images + '/'));

  gulp.src(dirs.images + '/*')
    .pipe($.imagemin(imageminOptions))
    .pipe(gulp.dest(dirs.images));
});

// Watch task
gulp.task('watch', function () {
  gulp.watch(dirs.css + '/**/*.scss', ['styles:dev']);
  gulp.watch([
    dirs.js + '/*.js',
    '!' + dirs.js + '/build.js'
  ], ['scripts']);
});

// Clean task
gulp.task('clean', function () {
  gulp.src([
    dirs.js + '/build.js',
    dirs.css + '/style.css'
  ], {read: false})
    .pipe($.clean());
});

// Register default and dev task
gulp.task('default', ['styles', 'fonts', 'scripts', 'images'], function () {});
gulp.task('dev', ['default', 'watch'], function () {});
<|endoftext|>