<commit_before>import gulp from 'gulp';
import mocha from 'gulp-mocha';
import istanbul from 'gulp-istanbul';
import babelIstanbul from 'babel-istanbul';
import yargs from 'yargs';
import through from 'through2';
import path from 'path';
import fs from 'fs-promise';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import babel from 'gulp-babel';
import sourcemaps from 'gulp-sourcemaps';
import Loganberry from 'loganberry';
import cp from 'child_process';
import semver from 'semver';

const TIMEOUT = 30000;
const argv = yargs.argv;
const logger = new Loganberry('gulp');

function getTestSources() {
  const src = new Set();

  // check --folder
  if (argv.folder) {
    if (Array.isArray(argv.folder)) {
      argv.folder.forEach(str => {
        str.split(',').forEach(f => {
          src.add(`${f}/**/*.test.js`);
        });
      });
    } else {
      argv.folder.split(',').forEach(f => {
        src.add(`${f}/**/*.test.js`);
      });
    }
  }

  // check --file
  if (argv.file) {
    if (Array.isArray(argv.file)) {
      argv.file.forEach(str => {
        str.split(',').forEach(f => {
          src.add(f);
        });
      });
    } else {
      argv.file.split(',').forEach(f => {
        src.add(f);
      });
    }
  }

  if (!src.size) {
    src.add('src/**/*.test.js');
  }

  return [...src];
}

gulp.task('pre-coverage', () => {
  const testSources = getTestSources();

  return gulp.src(['src/**/*.js', '!src/**/*.test.js', '!src/integration-test/**/*.js'])
    .pipe(istanbul({
      includeUntested: testSources.length === 1 && testSources[0] === 'src/**/*.test.js',
      instrumenter: babelIstanbul.Instrumenter,
    }))
    .pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-coverage'], () => (
  gulp.src(getTestSources())
    .pipe(mocha({
      timeout: TIMEOUT,
    }))
    .pipe(istanbul.writeReports())
));

gulp.task('quick-test', () => (
  gulp.src(getTestSources())
    .pipe(mocha({
      timeout: TIMEOUT,
    }))
));

const jsExt = /\.js$/;
function ensurePosixPath(str) {
  return str.split(path.sep).join('/');
}

// gulp.task('test-server', done => {
//   const files = new Set();
//   const testServerPath = path.resolve(__dirname, 'test-server');
//   gulp.src(getTestSources())
//     .pipe(through.obj((file, enc, cb) => {
//       files.add(ensurePosixPath(path.relative(testServerPath, file.path).replace(jsExt, '')));
//       cb();
//     }))
//     .on('finish', async () => {
//       const loaderScript = `mocha.setup('bdd');
//         mocha.timeout(${TIMEOUT});
//         ${[...files].map(f => `require('${f}');`).join('\n')}
//         mocha.run();
//       `;

//       await fs.writeFile(path.resolve(__dirname, './test-server/auto-loader.js'), loaderScript);

//       await new Promise((resolve, reject) => {
//         const compiler = webpack(testServerConfig, err => {
//           if (err) return reject(err);

//           new WebpackDevServer(compiler, {
//             contentBase: testServerPath,
//             publicPath: testServerConfig.output.publicPath,
//             hot: true,
//           }).listen(8190);
//           return resolve();
//         });
//       });
//       done();
//     });
// });

gulp.task('dev-server', async () => {
  // if (!(await fs.exists('dev-server'))) {
  //   await new Promise(resolve => {
  //     gulp.src('dev-server-template/**')
  //       .pipe(gulp.dest('dev-server'))
  //       .on('end', resolve);
  //   });
  // }
  // eslint-disable-next-line global-require
  const devWebpackConfig = require('./dev-server/webpack.config').default;
  const compiler = webpack(devWebpackConfig);
  const server = new WebpackDevServer(compiler, {
    contentBase: path.resolve('dev-server'),
    publicPath: '/build',
    hot: true,
    inline: true,
    noInfo: true,
    stats: {
      warnings: false,
      chunks: false,
      colors: true,
    },
  });
  server.listen(8190);
  console.log('server listening to 8190...');
});

async function rm(filepath) {
  if (await fs.exists(filepath)) {
    if ((await fs.stat(filepath)).isDirectory()) {
      await Promise.all(
        (await fs.readdir(filepath))
          .map(item => rm(path.resolve(filepath, item)))
      );
      await fs.rmdir(filepath);
    } else {
      await fs.unlink(filepath);
    }
  }
}

gulp.task('clean', async () => (
  rm(path.resolve(__dirname, 'build'))
));

gulp.task('build', ['clean'], () => (
  gulp.src(['src/**/*.js', '!src/**/*.test.js'])
    .pipe(sourcemaps.init())
    .pipe(babel())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('build'))
));

function splitCmd(cmd) {
  const quotes = [];
  const quoteReg = /(".*?"|'.*?')/;
  const replacementReg = /\{\{([0-9]*)\}\}/;
  let pCmd = cmd;
  let match = quoteReg.exec(pCmd);
  while (match) {
    const replaceStr = `{{${quotes.length}}}`;
    quotes.push(match[0]);
    pCmd = pCmd.replace(match[0], replaceStr);
    match = quoteReg.exec(pCmd);
  }
  return pCmd.split(' ').map(token => {
    const quoteMatch = replacementReg.exec(token);
    if (quoteMatch && quoteMatch[1]) {
      const number = parseInt(quoteMatch[1], 10);
      if (quotes[number]) {
        return quotes[number];
      }
    }
    return token;
  });
}

async function spawn(cmd, opts = {}) {
  return new Promise((resolve, reject) => {
    const [program, ...args] = splitCmd(cmd);
    const options = {
      stdio: 'inherit',
    };
    Object.assign(options, opts);
    cp.spawn(program, args, options).on('exit', code => {
      if (code === 0) {
        resolve();
      } else {
        reject(code);
      }
    }).on('error', reject);
  });
}

async function exec(command) {
  return new Promise((resolve, reject) => {
    cp.exec(command, (error, stdout, stderr) => {
      if (error) {
        reject(error);
        return;
      }
      resolve(stdout);
    });
  });
}

async function getVersionFromTag() {
  try {
    let tag = await exec('git describe --exact-match --tags $(git rev-parse HEAD)');
    tag = tag.replace(/\r?\n|\r/g, '');
    if (/^\d+.\d+.\d+/.test(tag)) {
      return tag;
    }
    return null;
  } catch (e) {
    return null;
  }
}

gulp.task('release-clean', async () => {
  if (!await fs.exists('release')) {
    await fs.mkdir('release');
  }
  const files = (await fs.readdir('release')).filter(file => !/^\./.test(file));
  for (const file of files) {
    await rm(path.resolve(__dirname, 'release', file));
  }
});

gulp.task('release-copy', ['build', 'release-clean'], () => (
  gulp.src(['build/**', 'README.md'])
    .pipe(gulp.dest('release'))
));

gulp.task('release', ['release-copy'], async () => {
  const packageInfo = JSON.parse(await fs.readFile('package.json'));
  delete packageInfo.scripts;
  packageInfo.main = 'rc-phone.js';
  const version = await getVersionFromTag();
  if (version) {
    packageInfo.version = version;
  }
  await fs.writeFile('release/package.json', JSON.stringify(packageInfo, null, 2));
});
<commit_msg>log tag and version for test ci npm publish<commit_after>import gulp from 'gulp';
import mocha from 'gulp-mocha';
import istanbul from 'gulp-istanbul';
import babelIstanbul from 'babel-istanbul';
import yargs from 'yargs';
import through from 'through2';
import path from 'path';
import fs from 'fs-promise';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import babel from 'gulp-babel';
import sourcemaps from 'gulp-sourcemaps';
import Loganberry from 'loganberry';
import cp from 'child_process';
import semver from 'semver';

const TIMEOUT = 30000;
const argv = yargs.argv;
const logger = new Loganberry('gulp');

function getTestSources() {
  const src = new Set();

  // check --folder
  if (argv.folder) {
    if (Array.isArray(argv.folder)) {
      argv.folder.forEach(str => {
        str.split(',').forEach(f => {
          src.add(`${f}/**/*.test.js`);
        });
      });
    } else {
      argv.folder.split(',').forEach(f => {
        src.add(`${f}/**/*.test.js`);
      });
    }
  }

  // check --file
  if (argv.file) {
    if (Array.isArray(argv.file)) {
      argv.file.forEach(str => {
        str.split(',').forEach(f => {
          src.add(f);
        });
      });
    } else {
      argv.file.split(',').forEach(f => {
        src.add(f);
      });
    }
  }

  if (!src.size) {
    src.add('src/**/*.test.js');
  }

  return [...src];
}

gulp.task('pre-coverage', () => {
  const testSources = getTestSources();

  return gulp.src(['src/**/*.js', '!src/**/*.test.js', '!src/integration-test/**/*.js'])
    .pipe(istanbul({
      includeUntested: testSources.length === 1 && testSources[0] === 'src/**/*.test.js',
      instrumenter: babelIstanbul.Instrumenter,
    }))
    .pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-coverage'], () => (
  gulp.src(getTestSources())
    .pipe(mocha({
      timeout: TIMEOUT,
    }))
    .pipe(istanbul.writeReports())
));

gulp.task('quick-test', () => (
  gulp.src(getTestSources())
    .pipe(mocha({
      timeout: TIMEOUT,
    }))
));

const jsExt = /\.js$/;
function ensurePosixPath(str) {
  return str.split(path.sep).join('/');
}

// gulp.task('test-server', done => {
//   const files = new Set();
//   const testServerPath = path.resolve(__dirname, 'test-server');
//   gulp.src(getTestSources())
//     .pipe(through.obj((file, enc, cb) => {
//       files.add(ensurePosixPath(path.relative(testServerPath, file.path).replace(jsExt, '')));
//       cb();
//     }))
//     .on('finish', async () => {
//       const loaderScript = `mocha.setup('bdd');
//         mocha.timeout(${TIMEOUT});
//         ${[...files].map(f => `require('${f}');`).join('\n')}
//         mocha.run();
//       `;

//       await fs.writeFile(path.resolve(__dirname, './test-server/auto-loader.js'), loaderScript);

//       await new Promise((resolve, reject) => {
//         const compiler = webpack(testServerConfig, err => {
//           if (err) return reject(err);

//           new WebpackDevServer(compiler, {
//             contentBase: testServerPath,
//             publicPath: testServerConfig.output.publicPath,
//             hot: true,
//           }).listen(8190);
//           return resolve();
//         });
//       });
//       done();
//     });
// });

gulp.task('dev-server', async () => {
  // if (!(await fs.exists('dev-server'))) {
  //   await new Promise(resolve => {
  //     gulp.src('dev-server-template/**')
  //       .pipe(gulp.dest('dev-server'))
  //       .on('end', resolve);
  //   });
  // }
  // eslint-disable-next-line global-require
  const devWebpackConfig = require('./dev-server/webpack.config').default;
  const compiler = webpack(devWebpackConfig);
  const server = new WebpackDevServer(compiler, {
    contentBase: path.resolve('dev-server'),
    publicPath: '/build',
    hot: true,
    inline: true,
    noInfo: true,
    stats: {
      warnings: false,
      chunks: false,
      colors: true,
    },
  });
  server.listen(8190);
  console.log('server listening to 8190...');
});

async function rm(filepath) {
  if (await fs.exists(filepath)) {
    if ((await fs.stat(filepath)).isDirectory()) {
      await Promise.all(
        (await fs.readdir(filepath))
          .map(item => rm(path.resolve(filepath, item)))
      );
      await fs.rmdir(filepath);
    } else {
      await fs.unlink(filepath);
    }
  }
}

gulp.task('clean', async () => (
  rm(path.resolve(__dirname, 'build'))
));

gulp.task('build', ['clean'], () => (
  gulp.src(['src/**/*.js', '!src/**/*.test.js'])
    .pipe(sourcemaps.init())
    .pipe(babel())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('build'))
));

function splitCmd(cmd) {
  const quotes = [];
  const quoteReg = /(".*?"|'.*?')/;
  const replacementReg = /\{\{([0-9]*)\}\}/;
  let pCmd = cmd;
  let match = quoteReg.exec(pCmd);
  while (match) {
    const replaceStr = `{{${quotes.length}}}`;
    quotes.push(match[0]);
    pCmd = pCmd.replace(match[0], replaceStr);
    match = quoteReg.exec(pCmd);
  }
  return pCmd.split(' ').map(token => {
    const quoteMatch = replacementReg.exec(token);
    if (quoteMatch && quoteMatch[1]) {
      const number = parseInt(quoteMatch[1], 10);
      if (quotes[number]) {
        return quotes[number];
      }
    }
    return token;
  });
}

async function spawn(cmd, opts = {}) {
  return new Promise((resolve, reject) => {
    const [program, ...args] = splitCmd(cmd);
    const options = {
      stdio: 'inherit',
    };
    Object.assign(options, opts);
    cp.spawn(program, args, options).on('exit', code => {
      if (code === 0) {
        resolve();
      } else {
        reject(code);
      }
    }).on('error', reject);
  });
}

async function exec(command) {
  return new Promise((resolve, reject) => {
    cp.exec(command, (error, stdout, stderr) => {
      if (error) {
        reject(error);
        return;
      }
      resolve(stdout);
    });
  });
}

async function getVersionFromTag() {
  try {
    let tag = await exec('git describe --exact-match --tags $(git rev-parse HEAD)');
    console.log(tag);
    tag = tag.replace(/\r?\n|\r/g, '');
    if (/^\d+.\d+.\d+/.test(tag)) {
      return tag;
    }
    return null;
  } catch (e) {
    return null;
  }
}

gulp.task('release-clean', async () => {
  if (!await fs.exists('release')) {
    await fs.mkdir('release');
  }
  const files = (await fs.readdir('release')).filter(file => !/^\./.test(file));
  for (const file of files) {
    await rm(path.resolve(__dirname, 'release', file));
  }
});

gulp.task('release-copy', ['build', 'release-clean'], () => (
  gulp.src(['build/**', 'README.md'])
    .pipe(gulp.dest('release'))
));

gulp.task('release', ['release-copy'], async () => {
  const packageInfo = JSON.parse(await fs.readFile('package.json'));
  delete packageInfo.scripts;
  packageInfo.main = 'rc-phone.js';
  const version = await getVersionFromTag();
  console.log(version);
  if (version) {
    packageInfo.version = version;
  }
  await fs.writeFile('release/package.json', JSON.stringify(packageInfo, null, 2));
});
<|endoftext|>


<commit_before>'use strict';

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

gulp.task('sass', function () {
  gulp.src('scss/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('css'));
});

gulp.task('sass:watch', function () {
  gulp.watch('scss/*.scss', ['sass']);
});
<commit_msg>autoreload server<commit_after>'use strict';

var        gulp = require('gulp'),
    browserSync = require('browser-sync'),
         reload = browserSync.reload;
var        sass = require('gulp-sass');

gulp.task('sass', function () {
  gulp.src('scss/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('css'));
});

// Start a server with Live Reload
gulp.task('serve', ['sass'], function () {
  browserSync({
    server: ['.tmp', './']
  });

  gulp.watch(['sass/**/*.scss'], ['sass']);
  gulp.watch(['css/*.css'], reload);

});

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


<commit_before>/*
	Tasks:

	$ gulp 			: Runs the "js" and "css" tasks.
	$ gulp js		: Runs the "js" tasks.
	$ gulp css		: Runs the "css" tasks.
	$ gulp watch	: Starts a watch on the "js" and "css" tasks.
	$ gulp polyfill : Creates the polyfill file.

	Flags for the custom task:

	--i ../path/to 	: Create a custom build using "mmenu.module.ts", "_includes.scss" and "_variables.scss" from the specified directory.
	--o ../path/to 	: Sets the "output" directory to the specified directory.

	Example:

	$ gulp custom --i ../my-custom-input --o ../my-custom-output
	$ gulp polyfill --i ../my-custom-input --o ../my-custom-output
*/

const { parallel, series } = require('gulp');

const js = require('./gulp/js');
const css = require('./gulp/css');
const polyfills = require('./gulp/polyfills');

/*
	$ gulp
*/
exports.default = cb => {
    parallel(js.all, css.all)(cb);
};

/*
	$ gulp js
*/
exports.js = cb => {
    js.all(cb);
};

/*
	$ gulp css
*/
exports.css = cb => {
    css.all(cb);
};

/*
	$ gulp custom
*/
exports.custom = cb => {
    parallel(js.custom, css.custom)(cb);
};

/*
	$ gulp watch
*/
exports.watch = cb => {
    parallel(series(js.all, js.watch), series(css.all, css.watch))(cb);
};

/*
	$ gulp polyfill
*/
exports.polyfill = cb => {
    parallel(polyfills)(cb);
};
<commit_msg>gulpfile<commit_after>/*
	Tasks:

	$ gulp 			: Runs the "js" and "css" tasks.
	$ gulp js		: Runs the "js" tasks.
	$ gulp css		: Runs the "css" tasks.
	$ gulp watch	: Starts a watch on the "js" and "css" tasks.
	$ gulp polyfill : Creates the polyfill file.

	Flags for the custom task:

	--i ../path/to 	: Create a custom build using "mmenu.module.ts", "_includes.scss" and "_variables.scss" from the specified directory.
	--o ../path/to 	: Sets the "output" directory to the specified directory.

	Example:

	$ gulp custom --i ../my-custom-input --o ../my-custom-output
	$ gulp polyfill --i ../my-custom-input --o ../my-custom-output
*/

const { parallel, series } = require('gulp');

const js = require('./gulp/js');
const css = require('./gulp/css');
const polyfills = require('./gulp/polyfills');

/*
	$ gulp
*/
exports.default = (cb) => {
    parallel(js.all, css.all)(cb);
};

/*
	$ gulp js
*/
exports.js = (cb) => {
    js.all(cb);
};

/*
	$ gulp css
*/
exports.css = (cb) => {
    css.all(cb);
};

/*
	$ gulp custom
*/
exports.custom = (cb) => {
    parallel(js.custom, css.custom)(cb);
};

/*
	$ gulp watch
*/
exports.watch = (cb) => {
    parallel(series(js.all, js.watch), series(css.all, css.watch))(cb);
};

/*
	$ gulp polyfill
*/
exports.polyfill = (cb) => {
    parallel(polyfills)(cb);
};
<|endoftext|>


<commit_before>var asyncDone = require('async-done');
var gulp = require('gulp');
var gutil = require('gulp-util');
var ddescribeIit = require('gulp-ddescribe-iit');
var shell = require('gulp-shell');
var ghPages = require('gulp-gh-pages');
var gulpFile = require('gulp-file');
var del = require('del');
var clangFormat = require('clang-format');
var gulpFormat = require('gulp-clang-format');
var runSequence = require('run-sequence');
var tslint = require('gulp-tslint');
var webpack = require('webpack');
var typescript = require('typescript');
var exec = require('child_process').exec;
var path = require('path');
var os = require('os');
var remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');

var PATHS = {
  src: 'src/**/*.ts',
  srcIndex: 'src/index.ts',
  specs: 'src/**/*.spec.ts',
  testHelpers: 'src/test/**/*.ts',
  demo: 'demo/**/*.ts',
  demoDist: 'demo/dist/**/*',
  typings: 'typings/index.d.ts',
  jasmineTypings: 'typings/globals/jasmine/index.d.ts',
  demoApiDocs: 'demo/src',
  coverageJson: 'coverage/json/coverage-final.json'
};

function platformPath(path) {
  return /^win/.test(os.platform()) ? `${path}.cmd` : path;
}

function webpackCallBack(taskName, gulpDone) {
  return function(err, stats) {
    if (err) throw new gutil.PluginError(taskName, err);
    gutil.log(`[${taskName}]`, stats.toString());
    gulpDone();
  }
}

// Transpiling & Building

gulp.task('clean:build', function() { return del('dist/'); });

gulp.task('ngc', function(cb) {
  var executable = path.join(__dirname, platformPath('/node_modules/.bin/ngc'));
  exec(`${executable} -p ./tsconfig-es2015.json`, (e) => {
    if (e) console.log(e);
    del('./dist/waste');
    cb();
  }).stdout.on('data', function(data) { console.log(data); });
});

gulp.task('umd', function(cb) {
  function ngExternal(ns) {
    var ng2Ns = `@angular/${ns}`;
    return {root: ['ng', ns], commonjs: ng2Ns, commonjs2: ng2Ns, amd: ng2Ns};
  }

  function rxjsExternal(context, request, cb) {
    if (/^rxjs\/add\/observable\//.test(request)) {
      return cb(null, {root: ['Rx', 'Observable'], commonjs: request, commonjs2: request, amd: request});
    } else if (/^rxjs\/add\/operator\//.test(request)) {
      return cb(null, {root: ['Rx', 'Observable', 'prototype'], commonjs: request, commonjs2: request, amd: request});
    } else if (/^rxjs\//.test(request)) {
      return cb(null, {root: ['Rx'], commonjs: request, commonjs2: request, amd: request});
    }
    cb();
  }

  webpack(
      {
        entry: './temp/index.js',
        output: {filename: 'dist/bundles/ng-bootstrap.js', library: 'ngb', libraryTarget: 'umd'},
        devtool: 'source-map',
        externals: [
          {
            '@angular/core': ngExternal('core'),
            '@angular/common': ngExternal('common'),
            '@angular/forms': ngExternal('forms')
          },
          rxjsExternal
        ]
      },
      webpackCallBack('webpack', cb));
});

gulp.task('npm', function() {
  var pkgJson = require('./package.json');
  var targetPkgJson = {};
  var fieldsToCopy = ['version', 'description', 'keywords', 'author', 'repository', 'license', 'bugs', 'homepage'];

  targetPkgJson['name'] = '@ng-bootstrap/ng-bootstrap';

  fieldsToCopy.forEach(function(field) { targetPkgJson[field] = pkgJson[field]; });

  targetPkgJson['main'] = 'bundles/ng-bootstrap.js';
  targetPkgJson['module'] = 'index.js';
  targetPkgJson['typings'] = 'index.d.ts';

  targetPkgJson.peerDependencies = {};
  Object.keys(pkgJson.dependencies).forEach(function(dependency) {
    targetPkgJson.peerDependencies[dependency] = `^${pkgJson.dependencies[dependency]}`;
  });

  return gulp.src('README.md')
      .pipe(gulpFile('package.json', JSON.stringify(targetPkgJson, null, 2)))
      .pipe(gulp.dest('dist'));
});

gulp.task('changelog', function() {
  var conventionalChangelog = require('gulp-conventional-changelog');
  return gulp.src('CHANGELOG.md', {})
      .pipe(conventionalChangelog({preset: 'angular', releaseCount: 1}, {
        // Override release version to avoid `v` prefix for git comparison
        // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
        currentTag: require('./package.json').version
      }))
      .pipe(gulp.dest('./'));
});

// Testing

function startKarmaServer(isTddMode, isSaucelabs, done) {
  var karmaServer = require('karma').Server;
  var travis = process.env.TRAVIS;

  var config = {configFile: `${__dirname}/karma.conf.js`, singleRun: !isTddMode, autoWatch: isTddMode};

  if (travis) {
    config['reporters'] = ['dots'];
    config['browsers'] = ['Firefox'];
  }

  if (isSaucelabs) {
    config['reporters'] = ['dots', 'saucelabs'];
    config['browsers'] =
        ['SL_CHROME', 'SL_FIREFOX', 'SL_IE10', 'SL_IE11', 'SL_EDGE13', 'SL_EDGE14', 'SL_SAFARI9', 'SL_SAFARI10'];

    if (process.env.TRAVIS) {
      var buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`;
      config['sauceLabs'] = {build: buildId, tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER};
      process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join('');
    }
  }

  new karmaServer(config, done).start();
}

gulp.task('clean:tests', function() { return del(['temp/', 'coverage/']); });

gulp.task('build:tests', ['clean:tests'], (cb) => {
  exec(path.join(__dirname, platformPath('/node_modules/.bin/tsc')), (e) => {
    if (e) console.log(e);
    cb();
  }).stdout.on('data', function(data) { console.log(data); });
});

gulp.task(
    'ddescribe-iit', function() { return gulp.src(PATHS.specs).pipe(ddescribeIit({allowDisabledTests: false})); });

gulp.task('test', ['build:tests'], function(done) {
  startKarmaServer(false, false, () => {
    asyncDone(
        () => { return gulp.src(PATHS.coverageJson).pipe(remapIstanbul({reports: {'html': 'coverage/html'}})); }, done);
  });
});

gulp.task('remap-coverage', function() {
  return gulp.src(PATHS.coverageJson).pipe(remapIstanbul({reports: {'html': 'coverage/html'}}));
});

gulp.task('tdd', ['clean:tests'], (cb) => {
  var executable = path.join(__dirname, platformPath('/node_modules/.bin/tsc'));
  var startedKarma = false;

  exec(`${executable} -w`, (e) => {
    cb(e && e.signal !== 'SIGINT' ? e : undefined);
  }).stdout.on('data', function(data) {

    console.log(data);

    // starting karma in tdd as soon as 'tsc -w' finishes first compilation
    if (!startedKarma) {
      startedKarma = true;
      startKarmaServer(true, false, function(err) { process.exit(err ? 1 : 0); });
    }
  });
});

gulp.task('saucelabs', ['build:tests'], function(done) {
  startKarmaServer(false, true, function(err) {
    done(err);
    process.exit(err ? 1 : 0);
  });
});

// Formatting

gulp.task('lint', function() {
  return gulp.src([PATHS.src, PATHS.demo, '!demo/src/api-docs.ts'])
      .pipe(tslint({configuration: require('./tslint.json'), formatter: 'prose'}))
      .pipe(tslint.report({summarizeFailureOutput: true}));
});

gulp.task('check-format', function() {
  return doCheckFormat().on(
      'warning', function(e) { console.log("NOTE: this will be promoted to an ERROR in the continuous build"); });
});

gulp.task('enforce-format', function() {
  return doCheckFormat().on('warning', function(e) {
    console.log("ERROR: You forgot to run clang-format on your change.");
    console.log("See https://github.com/ng-bootstrap/ng-bootstrap/blob/master/DEVELOPER.md#clang-format");
    process.exit(1);
  });
});

function doCheckFormat() {
  return gulp
      .src([
        'gulpfile.js', 'karma-test-shim.js', 'misc/api-doc.js', 'misc/api-doc.spec.js', 'misc/demo-gen.js', PATHS.src
      ])
      .pipe(gulpFormat.checkFormat('file', clangFormat));
}

// Demo

gulp.task('generate-docs', function() {
  var getApiDocs = require('./misc/get-doc');
  var docs = `const API_DOCS = ${JSON.stringify(getApiDocs(), null, 2)};\n\nexport default API_DOCS;`;

  return gulpFile('api-docs.ts', docs, {src: true}).pipe(gulp.dest(PATHS.demoApiDocs));
});

gulp.task('generate-plunks', function() {
  var getPlunker = require('./misc/plunk-gen');
  var demoGenUtils = require('./misc/demo-gen-utils');
  var plunks = [];

  demoGenUtils.getDemoComponentNames().forEach(function(componentName) {
    plunks = plunks.concat(demoGenUtils.getDemoNames(componentName).reduce(function(soFar, demoName) {
      soFar.push({name: `${componentName}/demos/${demoName}/plnkr.html`, source: getPlunker(componentName, demoName)});
      return soFar;
    }, []));
  });

  return gulpFile(plunks, {src: true}).pipe(gulp.dest('demo/src/public/app/components'));
});

gulp.task('clean:demo', function() { return del('demo/dist'); });

gulp.task('clean:demo-cache', function() { return del('.publish/'); });

gulp.task(
    'demo-server', ['generate-docs', 'generate-plunks'],
    shell.task(['webpack-dev-server --port 9090 --config webpack.demo.js --inline --progress']));

gulp.task(
    'build:demo', ['clean:demo', 'generate-docs', 'generate-plunks'],
    shell.task(['webpack --config webpack.demo.js --progress --profile --bail'], {env: {MODE: 'build'}}));

gulp.task(
    'demo-server:aot', ['generate-docs', 'generate-plunks'],
    shell.task(
        ['webpack-dev-server --port 9090 --config webpack.demo.js --inline --progress'], {env: {MODE: 'build'}}));

gulp.task('demo-push', function() {
  return gulp.src(PATHS.demoDist)
      .pipe(ghPages({remoteUrl: "https://github.com/ng-bootstrap/ng-bootstrap.github.io.git", branch: "master"}));
});

// Public Tasks
gulp.task('clean', ['clean:build', 'clean:tests', 'clean:demo', 'clean:demo-cache']);

gulp.task('build', function(done) {
  runSequence('lint', 'enforce-format', 'ddescribe-iit', 'test', 'clean:build', 'ngc', 'umd', 'npm', done);
});

gulp.task(
    'deploy-demo', function(done) { runSequence('clean:demo', 'build:demo', 'demo-push', 'clean:demo-cache', done); });

gulp.task('default', function(done) { runSequence('lint', 'enforce-format', 'ddescribe-iit', 'test', done); });

gulp.task('ci', function(done) { runSequence('default', 'build:demo', done); });
<commit_msg>chore: relax peerDependencies to support Angular 4.x<commit_after>var asyncDone = require('async-done');
var gulp = require('gulp');
var gutil = require('gulp-util');
var ddescribeIit = require('gulp-ddescribe-iit');
var shell = require('gulp-shell');
var ghPages = require('gulp-gh-pages');
var gulpFile = require('gulp-file');
var del = require('del');
var clangFormat = require('clang-format');
var gulpFormat = require('gulp-clang-format');
var runSequence = require('run-sequence');
var tslint = require('gulp-tslint');
var webpack = require('webpack');
var typescript = require('typescript');
var exec = require('child_process').exec;
var path = require('path');
var os = require('os');
var remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');

var PATHS = {
  src: 'src/**/*.ts',
  srcIndex: 'src/index.ts',
  specs: 'src/**/*.spec.ts',
  testHelpers: 'src/test/**/*.ts',
  demo: 'demo/**/*.ts',
  demoDist: 'demo/dist/**/*',
  typings: 'typings/index.d.ts',
  jasmineTypings: 'typings/globals/jasmine/index.d.ts',
  demoApiDocs: 'demo/src',
  coverageJson: 'coverage/json/coverage-final.json'
};

function platformPath(path) {
  return /^win/.test(os.platform()) ? `${path}.cmd` : path;
}

function webpackCallBack(taskName, gulpDone) {
  return function(err, stats) {
    if (err) throw new gutil.PluginError(taskName, err);
    gutil.log(`[${taskName}]`, stats.toString());
    gulpDone();
  }
}

// Transpiling & Building

gulp.task('clean:build', function() { return del('dist/'); });

gulp.task('ngc', function(cb) {
  var executable = path.join(__dirname, platformPath('/node_modules/.bin/ngc'));
  exec(`${executable} -p ./tsconfig-es2015.json`, (e) => {
    if (e) console.log(e);
    del('./dist/waste');
    cb();
  }).stdout.on('data', function(data) { console.log(data); });
});

gulp.task('umd', function(cb) {
  function ngExternal(ns) {
    var ng2Ns = `@angular/${ns}`;
    return {root: ['ng', ns], commonjs: ng2Ns, commonjs2: ng2Ns, amd: ng2Ns};
  }

  function rxjsExternal(context, request, cb) {
    if (/^rxjs\/add\/observable\//.test(request)) {
      return cb(null, {root: ['Rx', 'Observable'], commonjs: request, commonjs2: request, amd: request});
    } else if (/^rxjs\/add\/operator\//.test(request)) {
      return cb(null, {root: ['Rx', 'Observable', 'prototype'], commonjs: request, commonjs2: request, amd: request});
    } else if (/^rxjs\//.test(request)) {
      return cb(null, {root: ['Rx'], commonjs: request, commonjs2: request, amd: request});
    }
    cb();
  }

  webpack(
      {
        entry: './temp/index.js',
        output: {filename: 'dist/bundles/ng-bootstrap.js', library: 'ngb', libraryTarget: 'umd'},
        devtool: 'source-map',
        externals: [
          {
            '@angular/core': ngExternal('core'),
            '@angular/common': ngExternal('common'),
            '@angular/forms': ngExternal('forms')
          },
          rxjsExternal
        ]
      },
      webpackCallBack('webpack', cb));
});

gulp.task('npm', function() {
  var pkgJson = require('./package.json');
  var targetPkgJson = {};
  var fieldsToCopy = ['version', 'description', 'keywords', 'author', 'repository', 'license', 'bugs', 'homepage'];

  targetPkgJson['name'] = '@ng-bootstrap/ng-bootstrap';

  fieldsToCopy.forEach(function(field) { targetPkgJson[field] = pkgJson[field]; });

  targetPkgJson['main'] = 'bundles/ng-bootstrap.js';
  targetPkgJson['module'] = 'index.js';
  targetPkgJson['typings'] = 'index.d.ts';

  targetPkgJson.peerDependencies = {};
  Object.keys(pkgJson.dependencies).forEach(function(dependency) {
    targetPkgJson.peerDependencies[dependency] = `^${pkgJson.dependencies[dependency]} || ^4.0.0`;
  });

  return gulp.src('README.md')
      .pipe(gulpFile('package.json', JSON.stringify(targetPkgJson, null, 2)))
      .pipe(gulp.dest('dist'));
});

gulp.task('changelog', function() {
  var conventionalChangelog = require('gulp-conventional-changelog');
  return gulp.src('CHANGELOG.md', {})
      .pipe(conventionalChangelog({preset: 'angular', releaseCount: 1}, {
        // Override release version to avoid `v` prefix for git comparison
        // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10
        currentTag: require('./package.json').version
      }))
      .pipe(gulp.dest('./'));
});

// Testing

function startKarmaServer(isTddMode, isSaucelabs, done) {
  var karmaServer = require('karma').Server;
  var travis = process.env.TRAVIS;

  var config = {configFile: `${__dirname}/karma.conf.js`, singleRun: !isTddMode, autoWatch: isTddMode};

  if (travis) {
    config['reporters'] = ['dots'];
    config['browsers'] = ['Firefox'];
  }

  if (isSaucelabs) {
    config['reporters'] = ['dots', 'saucelabs'];
    config['browsers'] =
        ['SL_CHROME', 'SL_FIREFOX', 'SL_IE10', 'SL_IE11', 'SL_EDGE13', 'SL_EDGE14', 'SL_SAFARI9', 'SL_SAFARI10'];

    if (process.env.TRAVIS) {
      var buildId = `TRAVIS #${process.env.TRAVIS_BUILD_NUMBER} (${process.env.TRAVIS_BUILD_ID})`;
      config['sauceLabs'] = {build: buildId, tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER};
      process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join('');
    }
  }

  new karmaServer(config, done).start();
}

gulp.task('clean:tests', function() { return del(['temp/', 'coverage/']); });

gulp.task('build:tests', ['clean:tests'], (cb) => {
  exec(path.join(__dirname, platformPath('/node_modules/.bin/tsc')), (e) => {
    if (e) console.log(e);
    cb();
  }).stdout.on('data', function(data) { console.log(data); });
});

gulp.task(
    'ddescribe-iit', function() { return gulp.src(PATHS.specs).pipe(ddescribeIit({allowDisabledTests: false})); });

gulp.task('test', ['build:tests'], function(done) {
  startKarmaServer(false, false, () => {
    asyncDone(
        () => { return gulp.src(PATHS.coverageJson).pipe(remapIstanbul({reports: {'html': 'coverage/html'}})); }, done);
  });
});

gulp.task('remap-coverage', function() {
  return gulp.src(PATHS.coverageJson).pipe(remapIstanbul({reports: {'html': 'coverage/html'}}));
});

gulp.task('tdd', ['clean:tests'], (cb) => {
  var executable = path.join(__dirname, platformPath('/node_modules/.bin/tsc'));
  var startedKarma = false;

  exec(`${executable} -w`, (e) => {
    cb(e && e.signal !== 'SIGINT' ? e : undefined);
  }).stdout.on('data', function(data) {

    console.log(data);

    // starting karma in tdd as soon as 'tsc -w' finishes first compilation
    if (!startedKarma) {
      startedKarma = true;
      startKarmaServer(true, false, function(err) { process.exit(err ? 1 : 0); });
    }
  });
});

gulp.task('saucelabs', ['build:tests'], function(done) {
  startKarmaServer(false, true, function(err) {
    done(err);
    process.exit(err ? 1 : 0);
  });
});

// Formatting

gulp.task('lint', function() {
  return gulp.src([PATHS.src, PATHS.demo, '!demo/src/api-docs.ts'])
      .pipe(tslint({configuration: require('./tslint.json'), formatter: 'prose'}))
      .pipe(tslint.report({summarizeFailureOutput: true}));
});

gulp.task('check-format', function() {
  return doCheckFormat().on(
      'warning', function(e) { console.log("NOTE: this will be promoted to an ERROR in the continuous build"); });
});

gulp.task('enforce-format', function() {
  return doCheckFormat().on('warning', function(e) {
    console.log("ERROR: You forgot to run clang-format on your change.");
    console.log("See https://github.com/ng-bootstrap/ng-bootstrap/blob/master/DEVELOPER.md#clang-format");
    process.exit(1);
  });
});

function doCheckFormat() {
  return gulp
      .src([
        'gulpfile.js', 'karma-test-shim.js', 'misc/api-doc.js', 'misc/api-doc.spec.js', 'misc/demo-gen.js', PATHS.src
      ])
      .pipe(gulpFormat.checkFormat('file', clangFormat));
}

// Demo

gulp.task('generate-docs', function() {
  var getApiDocs = require('./misc/get-doc');
  var docs = `const API_DOCS = ${JSON.stringify(getApiDocs(), null, 2)};\n\nexport default API_DOCS;`;

  return gulpFile('api-docs.ts', docs, {src: true}).pipe(gulp.dest(PATHS.demoApiDocs));
});

gulp.task('generate-plunks', function() {
  var getPlunker = require('./misc/plunk-gen');
  var demoGenUtils = require('./misc/demo-gen-utils');
  var plunks = [];

  demoGenUtils.getDemoComponentNames().forEach(function(componentName) {
    plunks = plunks.concat(demoGenUtils.getDemoNames(componentName).reduce(function(soFar, demoName) {
      soFar.push({name: `${componentName}/demos/${demoName}/plnkr.html`, source: getPlunker(componentName, demoName)});
      return soFar;
    }, []));
  });

  return gulpFile(plunks, {src: true}).pipe(gulp.dest('demo/src/public/app/components'));
});

gulp.task('clean:demo', function() { return del('demo/dist'); });

gulp.task('clean:demo-cache', function() { return del('.publish/'); });

gulp.task(
    'demo-server', ['generate-docs', 'generate-plunks'],
    shell.task(['webpack-dev-server --port 9090 --config webpack.demo.js --inline --progress']));

gulp.task(
    'build:demo', ['clean:demo', 'generate-docs', 'generate-plunks'],
    shell.task(['webpack --config webpack.demo.js --progress --profile --bail'], {env: {MODE: 'build'}}));

gulp.task(
    'demo-server:aot', ['generate-docs', 'generate-plunks'],
    shell.task(
        ['webpack-dev-server --port 9090 --config webpack.demo.js --inline --progress'], {env: {MODE: 'build'}}));

gulp.task('demo-push', function() {
  return gulp.src(PATHS.demoDist)
      .pipe(ghPages({remoteUrl: "https://github.com/ng-bootstrap/ng-bootstrap.github.io.git", branch: "master"}));
});

// Public Tasks
gulp.task('clean', ['clean:build', 'clean:tests', 'clean:demo', 'clean:demo-cache']);

gulp.task('build', function(done) {
  runSequence('lint', 'enforce-format', 'ddescribe-iit', 'test', 'clean:build', 'ngc', 'umd', 'npm', done);
});

gulp.task(
    'deploy-demo', function(done) { runSequence('clean:demo', 'build:demo', 'demo-push', 'clean:demo-cache', done); });

gulp.task('default', function(done) { runSequence('lint', 'enforce-format', 'ddescribe-iit', 'test', done); });

gulp.task('ci', function(done) { runSequence('default', 'build:demo', done); });
<|endoftext|>


<commit_before>var gulp = require('gulp');
  watch = require('gulp-watch'),
  rename = require('gulp-rename'),
  notify = require('gulp-notify'),
  util = require('gulp-util'),
  plumber = require('gulp-plumber'),
  concat = require('gulp-concat'),

  jshint = require('gulp-jshint'),
  jscs = require('gulp-jscs'),
  uglify = require('gulp-uglify'),
  sourcemaps = require('gulp-sourcemaps'),

  cache = require('gulp-cached'),

  stylus = require('gulp-stylus'),
  autoprefixer = require('gulp-autoprefixer'),
  minifycss = require('gulp-minify-css'),
  swiss = require('kouto-swiss'),

  webserver = require('gulp-webserver'),

  imagemin = require('gulp-imagemin');

function errorNotify(error){
  notify.onError("Error: <%= error.message %>")
  util.log(util.colors.red('Error'), error.message);
}

gulp.task('javascript', function() {
  gulp.src('js/main.js')
  .pipe(sourcemaps.init())
  .pipe(jshint())
  .pipe(jshint.reporter('jshint-stylish'))
  .pipe(jscs('.jscsrc'))
  .on('error', errorNotify)
  .pipe(uglify())
  .on('error', errorNotify)
  .pipe(rename({suffix: '.min'}))
  .pipe(sourcemaps.write('/'))
  .on('error', errorNotify)
  .pipe(gulp.dest('js'))
  .pipe(notify({ message: 'Javascript task complete' }));
});

gulp.task('javascript-library', function() {
  gulp.src('js/library/*.js')
  .pipe(concat('library.js'))
  .pipe(gulp.dest('js'))
  .pipe(notify({ message: 'Javascript Library task complete' }));
});

gulp.task('style', function() {
  return gulp.src('css/site.styl')
  .pipe(plumber())
  .pipe(stylus({
      use: [
        swiss()
      ],
    }))
  .on('error', errorNotify)
  .pipe(autoprefixer())
  .on('error', errorNotify)
  .pipe(gulp.dest('css'))
  .pipe(rename({suffix: '.min'}))
  .pipe(minifycss())
  .on('error', errorNotify)
  .pipe(gulp.dest('css'))
  .pipe(notify({ message: 'Style task complete' }));
});

gulp.task('images', function () {
    return gulp.src('src/images/*.*')
    .pipe(cache('images'))
    .pipe(imagemin({
      progressive: false
    }))
    .on('error', errorNotify)
    .pipe(gulp.dest('img/dist'))
		.pipe(notify({ message: 'Images task complete' }));
});

gulp.task('watch', function() {
  gulp.watch(['js/main.js'], ['javascript']);
  gulp.watch(['js/library/*.js'], ['javascript-library']);
  gulp.watch(['css/site.styl'], ['style']);
  gulp.watch(['img/src/**'], ['images']);
});

gulp.task('webserver', function() {
  gulp.src('')
    .pipe(webserver({
      livereload: true,
      port: 3000,
      fallback: 'index.html',
      open: true
    }));
});

gulp.task('default', ['webserver', 'watch']);
gulp.task('build', ['images', 'style', 'javascript-library', 'javascript']);
<commit_msg>change webserver port<commit_after>var gulp = require('gulp');
  watch = require('gulp-watch'),
  rename = require('gulp-rename'),
  notify = require('gulp-notify'),
  util = require('gulp-util'),
  plumber = require('gulp-plumber'),
  concat = require('gulp-concat'),

  jshint = require('gulp-jshint'),
  jscs = require('gulp-jscs'),
  uglify = require('gulp-uglify'),
  sourcemaps = require('gulp-sourcemaps'),

  cache = require('gulp-cached'),

  stylus = require('gulp-stylus'),
  autoprefixer = require('gulp-autoprefixer'),
  minifycss = require('gulp-minify-css'),
  swiss = require('kouto-swiss'),

  webserver = require('gulp-webserver'),

  imagemin = require('gulp-imagemin');

function errorNotify(error){
  notify.onError("Error: <%= error.message %>")
  util.log(util.colors.red('Error'), error.message);
}

gulp.task('javascript', function() {
  gulp.src('js/main.js')
  .pipe(sourcemaps.init())
  .pipe(jshint())
  .pipe(jshint.reporter('jshint-stylish'))
  .pipe(jscs('.jscsrc'))
  .on('error', errorNotify)
  .pipe(uglify())
  .on('error', errorNotify)
  .pipe(rename({suffix: '.min'}))
  .pipe(sourcemaps.write('/'))
  .on('error', errorNotify)
  .pipe(gulp.dest('js'))
  .pipe(notify({ message: 'Javascript task complete' }));
});

gulp.task('javascript-library', function() {
  gulp.src('js/library/*.js')
  .pipe(concat('library.js'))
  .pipe(gulp.dest('js'))
  .pipe(notify({ message: 'Javascript Library task complete' }));
});

gulp.task('style', function() {
  return gulp.src('css/site.styl')
  .pipe(plumber())
  .pipe(stylus({
      use: [
        swiss()
      ],
    }))
  .on('error', errorNotify)
  .pipe(autoprefixer())
  .on('error', errorNotify)
  .pipe(gulp.dest('css'))
  .pipe(rename({suffix: '.min'}))
  .pipe(minifycss())
  .on('error', errorNotify)
  .pipe(gulp.dest('css'))
  .pipe(notify({ message: 'Style task complete' }));
});

gulp.task('images', function () {
    return gulp.src('src/images/*.*')
    .pipe(cache('images'))
    .pipe(imagemin({
      progressive: false
    }))
    .on('error', errorNotify)
    .pipe(gulp.dest('img/dist'))
		.pipe(notify({ message: 'Images task complete' }));
});

gulp.task('watch', function() {
  gulp.watch(['js/main.js'], ['javascript']);
  gulp.watch(['js/library/*.js'], ['javascript-library']);
  gulp.watch(['css/site.styl'], ['style']);
  gulp.watch(['img/src/**'], ['images']);
});

gulp.task('webserver', function() {
  gulp.src('')
    .pipe(webserver({
      livereload: true,
      port: 4444,
      fallback: 'index.html',
      open: true
    }));
});

gulp.task('default', ['webserver', 'watch']);
gulp.task('build', ['images', 'style', 'javascript-library', 'javascript']);
<|endoftext|>


<commit_before>require('babel-core/register');
var Rx = require('rx'),
  gulp = require('gulp'),
  path = require('path'),

  // utils
  notify = require('gulp-notify'),
  debug = require('debug')('freecc:gulp'),
  bower = require('bower-main-files'),

  // loopback client
  browserify = require('browserify'),
  boot = require('loopback-boot'),
  envify = require('envify/custom'),
  toVinylWithName = require('vinyl-source-stream'),

  // react app
  webpack = require('gulp-webpack'),
  webpackConfig = require('./webpack.config.js'),
  webpackConfigNode = require('./webpack.config.node.js'),

  // server process
  nodemon = require('gulp-nodemon'),
  sync = require('browser-sync'),

  inject = require('gulp-inject'),
  // css
  less = require('gulp-less'),

  // lint
  eslint = require('gulp-eslint');

Rx.longStackSupport = true;
var reloadDelay = 1000;
var reload = sync.reload;
var paths = {
  server: './server/server.js',
  serverIgnore: [
    'gulpfile.js',
    'public/',
    'node_modules/',
    'client/'
  ],
  publicJs: './public/js',

  loopback: {
    client: './client/loopbackClient',
    root: path.join(__dirname, 'client/'),
    clientName: 'lbApp'
  },

  client: {
    src: './client',
    dest: 'public/js'
  },

  node: {
    src: './client',
    dest: 'common/app'
  },

  syncWatch: [
    'public/**/*.*'
  ]
};

gulp.task('inject', function() {
  gulp.src('views/home.jade')
    .pipe(inject(gulp.src(bower()), {
      //ignorePath: '/public'
    }))
    .pipe(gulp.dest('views'));
});

// NOTE(berks): not using this for now as loopback client is just too large
gulp.task('loopback', function() {
  var config = {
    basedir: __dirname,
    debug: true,
    cache: {},
    packageCache: {},
    fullPaths: true,
    standalone: paths.loopback.clientName
  };

  var b = browserify(config);

  // compile loopback for the client
  b.require(paths.loopback.client);

  boot.compileToBrowserify(paths.loopback.root, b);

  // sub process.env for proper strings
  b.transform(envify({
    NODE_ENV: 'development'
  }));

  return b.bundle()
    .on('error', errorNotifier)
    .pipe(toVinylWithName(paths.loopback.clientName + '.js'))
    .pipe(gulp.dest(paths.publicJs));
});

gulp.task('pack-client', function() {
  return gulp.src(webpackConfig.entry)
    .pipe(webpack(webpackConfig))
    .pipe(gulp.dest(webpackConfig.output.path));
});

gulp.task('pack-watch', function() {
  return gulp.src(webpackConfig.entry)
    .pipe(webpack(Object.assign(webpackConfig, { watch: true })))
    .pipe(gulp.dest(webpackConfig.output.path));
});

gulp.task('pack-node', function() {
  return gulp.src(webpackConfigNode.entry)
    .pipe(webpack(webpackConfigNode))
    .pipe(gulp.dest(webpackConfigNode.output.path));
});

gulp.task('pack', ['pack-client', 'pack-node']);

gulp.task('serve', function(cb) {
  var called = false;
  nodemon({
    script: paths.server,
    ext: '.js .json',
    ignore: paths.serverIgnore,
    exec: './node_modules/.bin/babel-node',
    env: {
      'NODE_ENV': 'development',
      'DEBUG': process.env.DEBUG || 'freecc:*'
    }
  })
    .on('start', function() {
      if (!called) {
        called = true;
        setTimeout(function() {
          cb();
        }, reloadDelay);
      }
    })
    .on('restart', function(files) {
      if (files) {
        debug('Files that changes: ', files);
      }
      setTimeout(function() {
        debug('Restarting browsers');
        reload();
      }, reloadDelay);
    });
});

gulp.task('sync', ['serve'], function() {
  sync.init(null, {
    proxy: 'http://localhost:3000',
    logLeval: 'debug',
    files: paths.syncWatch,
    port: 3001,
    open: false,
    reloadDelay: reloadDelay
  });
});

gulp.task('lint', function() {
  return gulp.src(['public/js/lib/**/*'])
    .pipe(eslint())
    .pipe(eslint.format());
});

gulp.task('less', function() {
  return gulp.src('./public/css/*.less')
    .pipe(less({
      paths: [ path.join(__dirname, 'less', 'includes') ]
    }))
    .pipe(gulp.dest('./public/css/'));
});

gulp.task('build', ['less']);

gulp.task('watch', ['less', 'serve', 'sync'], function() {
  gulp.watch('./public/css/*.less', ['less']);
});

gulp.task('default', ['less', 'serve', 'sync', 'watch', 'pack-watch']);

function errorNotifier() {
  var args = Array.prototype.slice.call(arguments);

  // Send error to notification center with gulp-notify
  notify.onError({
    title: 'Compile Error',
    message: '<%= error %>'
  }).apply(this, args);

  // Keep gulp from hanging on this task
  this.emit('end');
}
<commit_msg>restart on bundle complete<commit_after>require('babel-core/register');
var Rx = require('rx'),
  gulp = require('gulp'),
  path = require('path'),

  // utils
  notify = require('gulp-notify'),
  debug = require('debug')('freecc:gulp'),
  bower = require('bower-main-files'),

  // loopback client
  browserify = require('browserify'),
  boot = require('loopback-boot'),
  envify = require('envify/custom'),
  toVinylWithName = require('vinyl-source-stream'),

  // react app
  webpack = require('gulp-webpack'),
  webpackConfig = require('./webpack.config.js'),
  webpackConfigNode = require('./webpack.config.node.js'),

  // server process
  nodemon = require('gulp-nodemon'),
  sync = require('browser-sync'),

  inject = require('gulp-inject'),
  // css
  less = require('gulp-less'),

  // lint
  eslint = require('gulp-eslint');

Rx.longStackSupport = true;
var reloadDelay = 1000;
var reload = sync.reload;
var paths = {
  server: './server/server.js',
  serverIgnore: [
    'gulpfile.js',
    'public/',
    '!public/js/bundle.js',
    'node_modules/',
    'client/'
  ],
  publicJs: './public/js',

  loopback: {
    client: './client/loopbackClient',
    root: path.join(__dirname, 'client/'),
    clientName: 'lbApp'
  },

  client: {
    src: './client',
    dest: 'public/js'
  },

  node: {
    src: './client',
    dest: 'common/app'
  },

  syncWatch: [
    'public/**/*.*'
  ]
};

gulp.task('inject', function() {
  gulp.src('views/home.jade')
    .pipe(inject(gulp.src(bower()), {
      //ignorePath: '/public'
    }))
    .pipe(gulp.dest('views'));
});

// NOTE(berks): not using this for now as loopback client is just too large
gulp.task('loopback', function() {
  var config = {
    basedir: __dirname,
    debug: true,
    cache: {},
    packageCache: {},
    fullPaths: true,
    standalone: paths.loopback.clientName
  };

  var b = browserify(config);

  // compile loopback for the client
  b.require(paths.loopback.client);

  boot.compileToBrowserify(paths.loopback.root, b);

  // sub process.env for proper strings
  b.transform(envify({
    NODE_ENV: 'development'
  }));

  return b.bundle()
    .on('error', errorNotifier)
    .pipe(toVinylWithName(paths.loopback.clientName + '.js'))
    .pipe(gulp.dest(paths.publicJs));
});

gulp.task('pack-client', function() {
  return gulp.src(webpackConfig.entry)
    .pipe(webpack(webpackConfig))
    .pipe(gulp.dest(webpackConfig.output.path));
});

gulp.task('pack-watch', function() {
  return gulp.src(webpackConfig.entry)
    .pipe(webpack(Object.assign(webpackConfig, { watch: true })))
    .pipe(gulp.dest(webpackConfig.output.path));
});

gulp.task('pack-node', function() {
  return gulp.src(webpackConfigNode.entry)
    .pipe(webpack(webpackConfigNode))
    .pipe(gulp.dest(webpackConfigNode.output.path));
});

gulp.task('pack', ['pack-client', 'pack-node']);

gulp.task('serve', function(cb) {
  var called = false;
  nodemon({
    script: paths.server,
    ext: '.js .json',
    ignore: paths.serverIgnore,
    exec: './node_modules/.bin/babel-node',
    env: {
      'NODE_ENV': 'development',
      'DEBUG': process.env.DEBUG || 'freecc:*'
    }
  })
    .on('start', function() {
      if (!called) {
        called = true;
        setTimeout(function() {
          cb();
        }, reloadDelay);
      }
    })
    .on('restart', function(files) {
      if (files) {
        debug('Files that changes: ', files);
      }
      setTimeout(function() {
        debug('Restarting browsers');
        reload();
      }, reloadDelay);
    });
});

gulp.task('sync', ['serve'], function() {
  sync.init(null, {
    proxy: 'http://localhost:3000',
    logLeval: 'debug',
    files: paths.syncWatch,
    port: 3001,
    open: false,
    reloadDelay: reloadDelay
  });
});

gulp.task('lint', function() {
  return gulp.src(['public/js/lib/**/*'])
    .pipe(eslint())
    .pipe(eslint.format());
});

gulp.task('less', function() {
  return gulp.src('./public/css/*.less')
    .pipe(less({
      paths: [ path.join(__dirname, 'less', 'includes') ]
    }))
    .pipe(gulp.dest('./public/css/'));
});

gulp.task('build', ['less']);

gulp.task('watch', ['less', 'serve', 'sync'], function() {
  gulp.watch('./public/css/*.less', ['less']);
});

gulp.task('default', ['less', 'serve', 'sync', 'watch', 'pack-watch']);

function errorNotifier() {
  var args = Array.prototype.slice.call(arguments);

  // Send error to notification center with gulp-notify
  notify.onError({
    title: 'Compile Error',
    message: '<%= error %>'
  }).apply(this, args);

  // Keep gulp from hanging on this task
  this.emit('end');
}
<|endoftext|>


<commit_before>const gulp = require('gulp')
const gulpif = require('gulp-if')
const source = require('vinyl-source-stream')
const buffer = require('vinyl-buffer')
const babel = require('gulp-babel')
const rename = require('gulp-rename')
const rollup = require('rollup-stream')
const uglify = require('gulp-uglify')
const flow = require('rollup-plugin-flow')
const replace = require('rollup-plugin-replace')
const merge = require('merge-stream')

const paths = {
  src: {
    index: 'src/index.js',
    jqueryPlugin: 'src/plugins/jquery-plugin.js',
    debugPlugin: 'src/plugins/debug-plugin.js'
  },
  dist: 'dist'
}

const replaceVars = isProduction => replace({ __DEV__: `${!isProduction}` })

const rollupStream = ({ input, format, name, output, mode }) => rollup({
  input,
  format,
  name,
  plugins: [flow(), replaceVars(mode === 'production')]
})
  .pipe(source(output))
  .pipe(gulpif(mode !== 'production', rename({ suffix: `.${mode}` })))

const build = ({ input, format, name, output, minify, modes }) => {
  const pipeline = merge.apply(null, modes.map(mode => rollupStream({
    input, format, name, output, mode
  })))
    .pipe(buffer())
    .pipe(babel())
    .pipe(gulp.dest(paths.dist))

  if (!minify) { return pipeline }

  return pipeline
    .pipe(uglify())
    .pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest(paths.dist))
}

gulp.task('browser', () => build({
  input: paths.src.index,
  format: 'iife',
  name: 'capsid',
  output: 'capsid.js',
  minify: true,
  modes: ['production', 'development']
}))

gulp.task('cjs', () => build({
  input: paths.src.index,
  format: 'cjs',
  output: 'capsid-cjs.js',
  minify: false,
  modes: ['production', 'development']
}))

gulp.task('jquery-plugin', () => build({
  input: paths.src.jqueryPlugin,
  format: 'iife',
  output: 'capsid-jquery.js',
  minify: true,
  modes: ['production']
}))

gulp.task('debug-plugin', () => build({
  input: paths.src.debugPlugin,
  format: 'umd',
  output: 'capsid-debug.js',
  name: 'capsidDebugMessage',
  minify: false,
  modes: ['production']
}))

gulp.task('dist', ['browser', 'cjs', 'jquery-plugin', 'debug-plugin'])
<commit_msg>chore: add build script for outside-events-plugin<commit_after>const gulp = require('gulp')
const gulpif = require('gulp-if')
const source = require('vinyl-source-stream')
const buffer = require('vinyl-buffer')
const babel = require('gulp-babel')
const rename = require('gulp-rename')
const rollup = require('rollup-stream')
const uglify = require('gulp-uglify')
const flow = require('rollup-plugin-flow')
const replace = require('rollup-plugin-replace')
const merge = require('merge-stream')

const paths = {
  src: {
    index: 'src/index.js',
    jqueryPlugin: 'src/plugins/jquery-plugin.js',
    outsideEventsPlugin: 'src/plugins/outside-events-plugin.js',
    debugPlugin: 'src/plugins/debug-plugin.js'
  },
  dist: 'dist'
}

const replaceVars = isProduction => replace({ __DEV__: `${!isProduction}` })

const rollupStream = ({ input, format, name, output, mode }) => rollup({
  input,
  format,
  name,
  plugins: [flow(), replaceVars(mode === 'production')]
})
  .pipe(source(output))
  .pipe(gulpif(mode !== 'production', rename({ suffix: `.${mode}` })))

const build = ({ input, format, name, output, minify, modes }) => {
  const pipeline = merge.apply(null, modes.map(mode => rollupStream({
    input, format, name, output, mode
  })))
    .pipe(buffer())
    .pipe(babel())
    .pipe(gulp.dest(paths.dist))

  if (!minify) { return pipeline }

  return pipeline
    .pipe(uglify())
    .pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest(paths.dist))
}

gulp.task('browser', () => build({
  input: paths.src.index,
  format: 'iife',
  name: 'capsid',
  output: 'capsid.js',
  minify: true,
  modes: ['production', 'development']
}))

gulp.task('cjs', () => build({
  input: paths.src.index,
  format: 'cjs',
  output: 'capsid-cjs.js',
  minify: false,
  modes: ['production', 'development']
}))

gulp.task('jquery-plugin', () => build({
  input: paths.src.jqueryPlugin,
  format: 'iife',
  output: 'capsid-jquery.js',
  minify: true,
  modes: ['production']
}))

gulp.task('debug-plugin', () => build({
  input: paths.src.debugPlugin,
  format: 'umd',
  output: 'capsid-debug.js',
  name: 'capsidDebugMessage',
  minify: false,
  modes: ['production']
}))

gulp.task('outside-events-plugin', () => build({
  input: paths.src.outsideEventsPlugin,
  format: 'iife',
  output: 'capsid-outside-events.js',
  minify: true,
  modes: ['production', 'development']
}))

gulp.task('dist', [
  'browser',
  'cjs',
  'jquery-plugin',
  'debug-plugin',
  'outside-events-plugin'
])
<|endoftext|>


<commit_before>var Gulp = require('gulp');
var GulpUtil = require('gulp-util');
var GulpArthur = require('gulp-arthur');
var GulpValidate = require('gulp-jsvalidate');
var Build = require('./build.js').build;

// takes each *.arthur file in `/arthur/` and compiles
// it to JavaScript, placing the output data inside
// `/bin/modules/` directory
Gulp.task('arthur', function () {
	// Gulp.src('./arthur/*.arthur')
	// 	.pipe(GulpArthur({
	// 		bare: true
	// 	}).on('error', GulpUtil.log))
	// 	.pipe(Gulp.dest('./bin/modules/'));
	Gulp.src('./arthur/*.arthur')
		.pipe(GulpArthur({
			bare: true
		}).on('error', GulpUtil.log))
		.pipe(Gulp.dest('./bin/modules/'));
});

// ensure that the JavaScript output by the parser
// is valid before packaging into `arthur.js` else
// the entire process becomes corrupted. no new files
// can be written because the parser is corrupt making
// it impossible to correct the mistake
Gulp.task('validate', function () {
	Gulp.src('./bin/modules/*.js')
		.pipe(GulpValidate());
});

// runs `build.js` which concatenates all raw JavaScript
// source files, wrapping them in a sercret sauce that
// allows them to run in Node.js or client-side seamlessly
Gulp.task('build', function () {
	Build();
});

// different than `build`, `mayday` uses the previously generated
// JavaScript files to creat the parser. this is in case the latest
// files get malformed and therefore the parser becomes malformed
// making it impossible to correct the files
Gulp.task('mayday', function () {
	Build(true);
});

// watches *.arthur files for changes
// when detected, compiles the new file and
// builds full `arthur.js`
Gulp.task('watch', function () {
	Gulp.watch('./src/**', ['arthur', 'validate', 'build']);
});

Gulp.task('default', ['arthur', 'validate', 'build']);<commit_msg>clarify code purpose<commit_after>var Gulp = require('gulp');
var GulpUtil = require('gulp-util');
var GulpArthur = require('gulp-arthur');
var GulpValidate = require('gulp-jsvalidate');
var Build = require('./build.js').build;

// takes each *.arthur file in `/arthur/` and compiles
// it to JavaScript, placing the output data inside
// `/bin/modules/` directory
Gulp.task('arthur', function () {
	Gulp.src('./arthur/*.arthur')
		.pipe(GulpArthur({
			bare: true,
			basic: true
		}).on('error', GulpUtil.log))
		.pipe(Gulp.dest('./bin/modules/'));
});

// ensure that the JavaScript output by the parser
// is valid before packaging into `arthur.js` else
// the entire process becomes corrupted. no new files
// can be written because the parser is corrupt making
// it impossible to correct the mistake
Gulp.task('validate', function () {
	Gulp.src('./bin/modules/*.js')
		.pipe(GulpValidate());
});

// runs `build.js` which concatenates all raw JavaScript
// source files, wrapping them in a sercret sauce that
// allows them to run in Node.js or client-side seamlessly
Gulp.task('build', function () {
	Build(false);
});

// different than `build`, `mayday` uses the previously generated
// JavaScript files to creat the parser. this is in case the latest
// files get malformed and therefore the parser becomes malformed
// making it impossible to correct the files
Gulp.task('mayday', function () {
	Build(true);
});

// watches *.arthur files for changes
// when detected, compiles the new file and
// builds full `arthur.js`
Gulp.task('watch', function () {
	Gulp.watch('./src/**', ['arthur', 'validate', 'build']);
});

// the default task
// builds all the *.arthur files in the arthur directory,
// saving them into the modules folder. when completed,
// it validates their JavaScript, checking for malformed
// code. if the tests pass, it builds them all into a new
// Arthur compiler
Gulp.task('default', ['arthur', 'validate', 'build']);<|endoftext|>


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

var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var bowerFiles = require('gulp-bower-files');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var watch = require('gulp-watch');
var notify = require('gulp-notify');
var concatCSS = require('gulp-concat-css');

var paths = {
  bowerCopy: {
    dest: 'app/assets/components'
  },

  scripts: {
    src: [
      'src/components/jquery/dist/jquery.js',
      'src/components/bootstrap-sass/vendor/assets/javascripts/bootstrap.js',
      'src/js/app.js'
    ],
    fullDir: 'app/assets/js/scripts.js',
    dir: 'app/assets/js',
    dest: 'scripts.js',
    jsHint: [
      'src/js/app.js',
      'src/js/**/*.js'
    ]
  },
  images: {
    src: 'app/assets/img/**/*',
    dest: 'app/assets/img'
  },

  scss: {
    src: [
      'src/scss/style.scss',
      'src/components/bootstrap-sass/vendor/assets/stylesheets/bootstrap.scss'
    ],
    dest: 'app/assets/components/css',
    finalDest: 'app/assets/css'
  },

  watch: {
    styles: [
      'src/scss/style.scss',
      'src/scss/**/*.scss'
    ],
    js: [
      'src/js/app.js',
      'src/js/**/*.js'
    ]
  }
};

/**
 * Stylesheets tasks
 */
gulp.task('styles', function () {
  gulp.src(paths.watch.styles)
    .pipe(watch(function (files) {
      gulp.src(paths.scss.src).pipe(sass())
        .pipe(gulp.dest(paths.scss.dest))
        .pipe(concatCSS("styles.css"))
        .pipe(gulp.dest(paths.scss.finalDest))
        .pipe(rename({suffix: '.min'}))
        .pipe(minifyCSS())
        .pipe(gulp.dest(paths.scss.finalDest));
    }));

});

/**
 * Stylesheets one time task
 */
gulp.task('styles-one-time', function () {
  return gulp.src(paths.scss.src).pipe(sass())
    .pipe(gulp.dest(paths.scss.dest))
    .pipe(rename({suffix: '.min'}))
    .pipe(minifyCSS())
    .pipe(gulp.dest(paths.scss.dest));
});

/**
 * Javascript tasks
 */
gulp.task('js', function () {
  gulp.src(paths.watch.js)
    .pipe(watch(function (files) {
      gulp.src(paths.scripts.src)
        .pipe(concat(paths.scripts.dest))
        .pipe(gulp.dest(paths.scripts.dir));

      gulp.src(paths.scripts.fullDir)
        .pipe(uglify({outSourceMap: false}))
        .pipe(concat("scripts.min.js"))
        .pipe(gulp.dest(paths.scripts.dir));
    }));
});

/**
 * Javascript one time tasks
 */
gulp.task('js-one-time', function () {
  gulp.src(paths.scripts.src)
    .pipe(concat(paths.scripts.dest))
    .pipe(gulp.dest(paths.scripts.dir));

  gulp.src(paths.scripts.fullDir)
    .pipe(uglify({outSourceMap: false}))
    .pipe(concat("scripts.min.js"))
    .pipe(gulp.dest(paths.scripts.dir));
});

/**
 * Imagemin task
 */
gulp.task('images', function () {
  return gulp.src(paths.images.src)
    // Pass in options to the task
    .pipe(imagemin({optimizationLevel: 5}))
    .pipe(gulp.dest(paths.images.dest));
});

/**
 * JSHint task
 */
gulp.task('lint', function () {
  gulp.src(paths.scripts.jsHint)
    .pipe(jshint())
    .pipe(jshint.reporter('default'));
});

/**
 * Bower task
 */
gulp.task('bowerFiles', function () {
  bowerFiles().pipe(gulp.dest(paths.bowerCopy.dest))
});

gulp.task('default', ['styles', 'js']);

gulp.task('prod', ['styles-one-time', 'js-one-time', 'images', 'lint']);<commit_msg>add bowercopy<commit_after>var gulp = require('gulp');

var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var bowerFiles = require('gulp-bower-files');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var watch = require('gulp-watch');
var notify = require('gulp-notify');
var concatCSS = require('gulp-concat-css');

var paths = {
  bowerCopy: {
    dest: 'app/assets/components'
  },

  scripts: {
    src: [
      'src/components/jquery/dist/jquery.js',
      'src/components/bootstrap-sass/vendor/assets/javascripts/bootstrap.js',
      'src/js/app.js'
    ],
    fullDir: 'app/assets/js/scripts.js',
    dir: 'app/assets/js',
    dest: 'scripts.js',
    jsHint: [
      'src/js/app.js',
      'src/js/**/*.js'
    ]
  },
  images: {
    src: 'app/assets/img/**/*',
    dest: 'app/assets/img'
  },

  scss: {
    src: [
      'src/scss/style.scss',
      'src/components/bootstrap-sass/vendor/assets/stylesheets/bootstrap.scss'
    ],
    dest: 'app/assets/components/css',
    finalDest: 'app/assets/css'
  },

  watch: {
    styles: [
      'src/scss/style.scss',
      'src/scss/**/*.scss'
    ],
    js: [
      'src/js/app.js',
      'src/js/**/*.js'
    ]
  }
};

/**
 * Stylesheets tasks
 */
gulp.task('styles', function () {
  gulp.src(paths.watch.styles)
    .pipe(watch(function (files) {
      gulp.src(paths.scss.src).pipe(sass())
        .pipe(gulp.dest(paths.scss.dest))
        .pipe(concatCSS("styles.css"))
        .pipe(gulp.dest(paths.scss.finalDest))
        .pipe(rename({suffix: '.min'}))
        .pipe(minifyCSS())
        .pipe(gulp.dest(paths.scss.finalDest));
    }));

});

/**
 * Stylesheets one time task
 */
gulp.task('styles-one-time', function () {
  return gulp.src(paths.scss.src).pipe(sass())
    .pipe(gulp.dest(paths.scss.dest))
    .pipe(rename({suffix: '.min'}))
    .pipe(minifyCSS())
    .pipe(gulp.dest(paths.scss.dest));
});

/**
 * Javascript tasks
 */
gulp.task('js', function () {
  gulp.src(paths.watch.js)
    .pipe(watch(function (files) {
      gulp.src(paths.scripts.src)
        .pipe(concat(paths.scripts.dest))
        .pipe(gulp.dest(paths.scripts.dir));

      gulp.src(paths.scripts.fullDir)
        .pipe(uglify({outSourceMap: false}))
        .pipe(concat("scripts.min.js"))
        .pipe(gulp.dest(paths.scripts.dir));
    }));
});

/**
 * Javascript one time tasks
 */
gulp.task('js-one-time', function () {
  gulp.src(paths.scripts.src)
    .pipe(concat(paths.scripts.dest))
    .pipe(gulp.dest(paths.scripts.dir));

  gulp.src(paths.scripts.fullDir)
    .pipe(uglify({outSourceMap: false}))
    .pipe(concat("scripts.min.js"))
    .pipe(gulp.dest(paths.scripts.dir));
});

/**
 * Imagemin task
 */
gulp.task('images', function () {
  return gulp.src(paths.images.src)
    // Pass in options to the task
    .pipe(imagemin({optimizationLevel: 5}))
    .pipe(gulp.dest(paths.images.dest));
});

/**
 * JSHint task
 */
gulp.task('lint', function () {
  gulp.src(paths.scripts.jsHint)
    .pipe(jshint())
    .pipe(jshint.reporter('default'));
});

/**
 * Bower task
 */
gulp.task('bowerFiles', function () {
  bowerFiles().pipe(gulp.dest(paths.bowerCopy.dest))
});

gulp.task('default', ['styles', 'js', 'bowerFiles']);

gulp.task('prod', ['styles-one-time', 'js-one-time', 'images', 'lint']);<|endoftext|>


<commit_before>/*global require*/
var gulp = require('gulp'),
    concat = require("gulp-concat-util"),
    ts = require('gulp-typescript'),
    insert = require('gulp-insert'),
    gnf = require('gulp-npm-files'),
    sass = require('gulp-sass'),
    qunit = require("gulp-qunit"),
    serve = require("gulp-serve"),
    uglify = require("gulp-uglify"),
    rename = require("gulp-rename"),
    html2ts = require("gulp-html-to-ts"),
    sequence = require("gulp-sequence"),
    jsonTransform = require('gulp-json-transform'),
    project = require("./project.json"),
    webpackStream = require('webpack-stream'),
    getWebpackConfig = require('./webpack/webpack.config'),
    getWebpackUniversalConfig = require('./webpack/webpack.universal.config');

var Server = require("karma").Server;

var libraryVersion = "0.10.3";

var paths = {
    webroot: "./" + project.webroot + "/",
    dist: "./dist/",
    dist_dts: "./dist/typings/",
    tsTests: "./tests/*.ts",
    package_ko: "./packages/survey-knockout/",
    package_react: "./packages/survey-react/",
    package_angular: "./packages/survey-angular/",
    package_jquery: "./packages/survey-jquery/",
    typings: "./typings/**/*.d.ts",
    styles: "./src/*.scss",
};
paths.jsFolder = paths.webroot + "js/";
paths.testsFolder = paths.webroot + "tests/";

var copyright = ["/*!",
    "* surveyjs - Survey JavaScript library v" + libraryVersion,
    "* (c) Andrew Telnov - http://surveyjs.org/",
    "* License: MIT (http://www.opensource.org/licenses/mit-license.php)",
    "*/", "", ""].join("\n");

var tdHeader = ["// Type definitions for Survey JavaScript library v" + libraryVersion,
    "// Project: http://surveyjs.org/",
    "// Definitions by: Andrew Telnov <https://github.com/andrewtelnov/>",
    "",""].join("\n");

var config_ko = {
    name: "survey-knockout",
    keywords: ["Knockout"],
    dependencies: {"knockout": "^3.4.0"},
    templates: [{ path: ["./src/knockout/templates/*.html", "./src/plugins/knockout/templates/*.html"], fileName: "template.ko.html", dest: "./src/knockout/" },
        { path: "./src/knockout/templates/window/*.html", fileName: "template.window.ko.html", dest: "./src/knockout/" }],
    src: [
        "./src/*.ts",
        "./src/localization/*.ts",
        "./src/defaultCss/cssstandard.ts",
        "./src/defaultCss/cssbootstrap.ts",
        "./src/knockout/*.ts",
        "./src/entries/chunks/**/*.ts",
        "./src/plugins/*.ts",
        "./src/plugins/knockout/*.ts",
        "./src/entries/ko.ts"
    ],
    mainJSfile: "survey.ko.js",
    dtsfile: "ko.d.ts",
    packagePath: "./packages/survey-knockout/",
    bundleName: "survey.ko",
    entryPoint: "../src/entries/ko"
};

var config_react = {
    name: "survey-react",
    keywords: ["react", "react-component"],
    dependencies: { "react": "^15.0.1", "react-dom": "^15.0.1" },
    src: [
        "./src/*.ts",
        "./src/localization/*.ts",
        "./src/defaultCss/*.ts",
        "./src/react/*.tsx",
        "./src/entries/chunks/**/*.ts",
        "./src/plugins/*.ts",
        "./src/plugins/react/*.tsx",
        "./src/entries/react.ts"
    ],
    mainJSfile: "survey.react.js",
    dtsfile: "react.d.ts",
    packagePath: "./packages/survey-react/",
    bundleName: "survey.react",
    entryPoint: "../src/entries/react"
};

var config_angular = {
    name: "survey-angular",
    keywords: ["angular", "angular-component"],
    dependencies: { "@types/react": "0.0.0" },
    src: [
        "./src/*.ts",
        "./src/localization/*.ts",
        "./src/defaultCss/*.ts",
        "./src/entries/chunks/**/*.ts",
        "./src/react/*.tsx",
        "./src/angular/*.ts",
        "./src/angular/*.tsx",
        "./src/entries/react.ts",
        "./src/entries/angular.ts"
    ],
    mainJSfile: "survey.angular.js",
    dtsfile: "angular.d.ts",
    packagePath: "./packages/survey-angular/",
    bundleName: "survey.angular",
    entryPoint: "../src/entries/angular"
};

var config_jquery = {
    name: "survey-jquery",
    keywords: ["jquery", "jquery-plugin"],
    dependencies: { "jquery": "^3.1.1", "@types/react": "0.0.0" },
    src: [
        "./src/*.ts",
        "./src/localization/*.ts",
        "./src/defaultCss/*.ts",
        "./src/entries/chunks/**/*.ts",
        "./src/react/*.tsx",
        "./src/angular/*.ts",
        "./src/angular/*.tsx",
        "./src/entries/react.ts",
        "./src/entries/jquery.tsx"
    ],
    mainJSfile: "survey.jquery.js",
    dtsfile: "jquery.d.ts",
    packagePath: "./packages/survey-jquery/",
    bundleName: "survey.jquery",
    entryPoint: "../src/entries/jquery"
};

var config_test_ko = {
    dtsfile: "survey.d.ts",
    src: "./tests/ko/*.ts",
    entryPoint: "../tests/entries/testKo",
    bundleName: "survey.tests.ko",
    htmlFile: "./tests/ko/index_tests_ko.html"
};

var configs = {};
configs["ko"] = config_ko;
configs["react"] = config_react;
configs["angular"] = config_angular;
configs["jquery"] = config_jquery;
var testconfigs = {};
testconfigs["ko"] = config_test_ko;

function buildTemplates(configName, index) {
    var curConfig = configs[configName];
    var curTemplate = curConfig.templates[index];
    return gulp.src(curTemplate.path)
        .pipe(concat(curTemplate.fileName))
        .pipe(html2ts())
        .pipe(insert.transform(function(contents, file) {
            contents = contents.slice(0, -1); //remove last symbol '}'
            contents = contents.replace('module template.window.ko { ', '');
            contents = contents.replace('export var html', 'export var koTemplate = { html : ""}; koTemplate.html');
            return contents.replace('module template.ko { ', '');
        }))
        .pipe(gulp.dest(curTemplate.dest));
}

function buildFromSources(configName) {
    var curConfig = configs[configName];
    var tsResult = gulp.src(curConfig.entryPoint)
        .pipe(webpackStream(configName !== "react" && configName !== "ko"? getWebpackUniversalConfig(curConfig) : getWebpackConfig(curConfig)));
    return tsResult
        .pipe(concat(curConfig.mainJSfile))
        .pipe(insert.prepend(copyright))
        .pipe(gulp.dest(paths.dist))
        .pipe(gulp.dest(paths.jsFolder))
        .pipe(gulp.dest(curConfig.packagePath + "dist/"));
}

function buildTypeDefinition(configName) {
    var curConfig = configs[configName];
    //Build js file
    //Build typescript definition
    var tscResult = gulp.src([
        paths.webroot + "/lib/survey/**/*.d.ts",
        paths.typings
    ].concat(curConfig.src))
        .pipe(ts({
            target: "ES5",
            noExternalResolve: true,
            allowSyntheticDefaultImports: true,
            outDir: "./some/dir/TODO/", // TODO we need any value of outDir for save folders structure for d.ts. BUT WHY?
            declaration: true,
            jsx: "react"
        }));
    return tscResult.dts
        .pipe(concat.header(tdHeader))
        .pipe(gulp.dest(paths.dist_dts))
        .pipe(gulp.dest(curConfig.packagePath + "dist/typings"));
}

function compressMainJS(configName) {
    var curConfig = configs[configName];
    gulp.src(paths.dist + curConfig.mainJSfile)
        .pipe(uglify())
        .pipe(rename({
            extname: ".min.js"
        }))
        .pipe(concat.header(copyright))
        .pipe(gulp.dest(curConfig.packagePath + "dist/"))
        .pipe(gulp.dest(curConfig.packagePath + "js/"))
        .pipe(gulp.dest(paths.dist));
}

function buildTests(configName) {
    var curConfig = testconfigs[configName];
    var tsResult = gulp.src(curConfig.entryPoint)
        .pipe(webpackStream(configName !== "react" && configName !== "ko"? getWebpackUniversalConfig(curConfig) : getWebpackConfig(curConfig)));
    return tsResult
        .pipe(concat(curConfig.mainJSfile))
        .pipe(gulp.dest(paths.testsFolder));
}

function createPackageJson(configName) {
    var curConfig = configs[configName];
    return gulp.src("packagetemplate.json")
        .pipe(jsonTransform(function (data) {
            data.name = curConfig.name;
            data.version = libraryVersion;
            if (curConfig.keywords) {
                for (var i = 0; i < curConfig.keywords.length; i++) {
                    data.keywords.push(curConfig.keywords[i]);
                }
            }
            data.main = './js/' + curConfig.mainJSfile.replace(".js", ".min.js");
            data.typings = './dist/typings/entries/' + curConfig.dtsfile;
            if (curConfig.dependencies) {
                for (var key in curConfig.dependencies) {
                    data.dependencies[key] = curConfig.dependencies[key];
                }
            }
            return data;
        }, "  "))
        .pipe(rename("package.json"))
        .pipe(gulp.dest(curConfig.packagePath));
}

gulp.task("ko_tempates", function () {
    return buildTemplates("ko", 0);
});
gulp.task("ko_windowtempates", function () {
    return buildTemplates("ko", 1);
});
gulp.task("ko_source", function () {
    buildTypeDefinition("ko");
    return buildFromSources("ko");
});
gulp.task("ko_compress", function () {
    compressMainJS("ko");
});
gulp.task("ko_createPackageJson", function () {
    createPackageJson("ko");
});

gulp.task("build_ko", sequence("ko_tempates", "ko_windowtempates", "ko_source", "ko_compress", "ko_createPackageJson"));

gulp.task("buildTests_ko", function () {
    return buildTests("ko");
});

gulp.task("react_source", function () {
    buildTypeDefinition("react");
    return buildFromSources("react");
});
gulp.task("react_compress", function () {
    compressMainJS("react");
});
gulp.task("react_createPackageJson", function () {
    createPackageJson("react");
});
gulp.task("build_react", sequence("react_source", "react_compress", "react_createPackageJson"));

gulp.task("angular_source", function () {
    buildTypeDefinition("angular");
    return buildFromSources("angular");
});
gulp.task("angular_compress", function () {
    compressMainJS("angular");
});
gulp.task("angular_createPackageJson", function () {
    createPackageJson("angular");
});
gulp.task("build_angular", sequence("angular_source", "angular_compress", "angular_createPackageJson"));

gulp.task("jquery_source", function () {
    buildTypeDefinition("jquery");
    return buildFromSources("jquery");
});
gulp.task("jquery_compress", function () {
    compressMainJS("jquery");
});
gulp.task("jquery_createPackageJson", function () {
    createPackageJson("jquery");
});
gulp.task("build_jquery", sequence("jquery_source", "jquery_compress", "jquery_createPackageJson"));

gulp.task('copyfiles', function (callback) {
    gulp.src(gnf(null, 'package.json'), { base: './' })
        .pipe(rename(function (path) {
            path.dirname = "";
            path.basename = path.basename.replace("-latest", "");
        }))
        .pipe(gulp.dest(paths.jsFolder));
});

gulp.task('sass', function () {
    "use strict";
    gulp.src(paths.styles)
        .pipe(sass.sync().on('error', sass.logError))
        .pipe(concat("survey.css"))
        .pipe(gulp.dest(paths.webroot + 'css'))
        .pipe(gulp.dest(paths.package_ko + 'dist/css'))
        .pipe(gulp.dest(paths.package_ko + 'css'))
        .pipe(gulp.dest(paths.package_react + 'dist/css'))
        .pipe(gulp.dest(paths.package_react + 'css'))
        .pipe(gulp.dest(paths.package_angular + 'dist/css'))
        .pipe(gulp.dest(paths.package_angular + 'css'))
        .pipe(gulp.dest(paths.package_jquery + 'dist/css'))
        .pipe(gulp.dest(paths.package_jquery + 'css'))
        .pipe(gulp.dest(paths.dist + 'css'));
});
gulp.task("makedist", sequence(["sass", "build_ko"], "buildTests_ko", "build_react", "build_angular", "build_jquery"));

gulp.task("test_ci", function (done) {
    new Server({
        configFile: __dirname + "/karma.conf.js",
        singleRun: true
    }, done).start();
});

gulp.task("server", serve({
    root: ["wwwroot"],
    port: 30001
}));<commit_msg>fixed required jQuery version to >=1.12.4 (#182)<commit_after>/*global require*/
var gulp = require('gulp'),
    concat = require("gulp-concat-util"),
    ts = require('gulp-typescript'),
    insert = require('gulp-insert'),
    gnf = require('gulp-npm-files'),
    sass = require('gulp-sass'),
    qunit = require("gulp-qunit"),
    serve = require("gulp-serve"),
    uglify = require("gulp-uglify"),
    rename = require("gulp-rename"),
    html2ts = require("gulp-html-to-ts"),
    sequence = require("gulp-sequence"),
    jsonTransform = require('gulp-json-transform'),
    project = require("./project.json"),
    webpackStream = require('webpack-stream'),
    getWebpackConfig = require('./webpack/webpack.config'),
    getWebpackUniversalConfig = require('./webpack/webpack.universal.config');

var Server = require("karma").Server;

var libraryVersion = "0.10.3";

var paths = {
    webroot: "./" + project.webroot + "/",
    dist: "./dist/",
    dist_dts: "./dist/typings/",
    tsTests: "./tests/*.ts",
    package_ko: "./packages/survey-knockout/",
    package_react: "./packages/survey-react/",
    package_angular: "./packages/survey-angular/",
    package_jquery: "./packages/survey-jquery/",
    typings: "./typings/**/*.d.ts",
    styles: "./src/*.scss",
};
paths.jsFolder = paths.webroot + "js/";
paths.testsFolder = paths.webroot + "tests/";

var copyright = ["/*!",
    "* surveyjs - Survey JavaScript library v" + libraryVersion,
    "* (c) Andrew Telnov - http://surveyjs.org/",
    "* License: MIT (http://www.opensource.org/licenses/mit-license.php)",
    "*/", "", ""].join("\n");

var tdHeader = ["// Type definitions for Survey JavaScript library v" + libraryVersion,
    "// Project: http://surveyjs.org/",
    "// Definitions by: Andrew Telnov <https://github.com/andrewtelnov/>",
    "",""].join("\n");

var config_ko = {
    name: "survey-knockout",
    keywords: ["Knockout"],
    dependencies: {"knockout": "^3.4.0"},
    templates: [{ path: ["./src/knockout/templates/*.html", "./src/plugins/knockout/templates/*.html"], fileName: "template.ko.html", dest: "./src/knockout/" },
        { path: "./src/knockout/templates/window/*.html", fileName: "template.window.ko.html", dest: "./src/knockout/" }],
    src: [
        "./src/*.ts",
        "./src/localization/*.ts",
        "./src/defaultCss/cssstandard.ts",
        "./src/defaultCss/cssbootstrap.ts",
        "./src/knockout/*.ts",
        "./src/entries/chunks/**/*.ts",
        "./src/plugins/*.ts",
        "./src/plugins/knockout/*.ts",
        "./src/entries/ko.ts"
    ],
    mainJSfile: "survey.ko.js",
    dtsfile: "ko.d.ts",
    packagePath: "./packages/survey-knockout/",
    bundleName: "survey.ko",
    entryPoint: "../src/entries/ko"
};

var config_react = {
    name: "survey-react",
    keywords: ["react", "react-component"],
    dependencies: { "react": "^15.0.1", "react-dom": "^15.0.1" },
    src: [
        "./src/*.ts",
        "./src/localization/*.ts",
        "./src/defaultCss/*.ts",
        "./src/react/*.tsx",
        "./src/entries/chunks/**/*.ts",
        "./src/plugins/*.ts",
        "./src/plugins/react/*.tsx",
        "./src/entries/react.ts"
    ],
    mainJSfile: "survey.react.js",
    dtsfile: "react.d.ts",
    packagePath: "./packages/survey-react/",
    bundleName: "survey.react",
    entryPoint: "../src/entries/react"
};

var config_angular = {
    name: "survey-angular",
    keywords: ["angular", "angular-component"],
    dependencies: { "@types/react": "0.0.0" },
    src: [
        "./src/*.ts",
        "./src/localization/*.ts",
        "./src/defaultCss/*.ts",
        "./src/entries/chunks/**/*.ts",
        "./src/react/*.tsx",
        "./src/angular/*.ts",
        "./src/angular/*.tsx",
        "./src/entries/react.ts",
        "./src/entries/angular.ts"
    ],
    mainJSfile: "survey.angular.js",
    dtsfile: "angular.d.ts",
    packagePath: "./packages/survey-angular/",
    bundleName: "survey.angular",
    entryPoint: "../src/entries/angular"
};

var config_jquery = {
    name: "survey-jquery",
    keywords: ["jquery", "jquery-plugin"],
    dependencies: { "jquery": ">=1.12.4", "@types/react": "0.0.0" },
    src: [
        "./src/*.ts",
        "./src/localization/*.ts",
        "./src/defaultCss/*.ts",
        "./src/entries/chunks/**/*.ts",
        "./src/react/*.tsx",
        "./src/angular/*.ts",
        "./src/angular/*.tsx",
        "./src/entries/react.ts",
        "./src/entries/jquery.tsx"
    ],
    mainJSfile: "survey.jquery.js",
    dtsfile: "jquery.d.ts",
    packagePath: "./packages/survey-jquery/",
    bundleName: "survey.jquery",
    entryPoint: "../src/entries/jquery"
};

var config_test_ko = {
    dtsfile: "survey.d.ts",
    src: "./tests/ko/*.ts",
    entryPoint: "../tests/entries/testKo",
    bundleName: "survey.tests.ko",
    htmlFile: "./tests/ko/index_tests_ko.html"
};

var configs = {};
configs["ko"] = config_ko;
configs["react"] = config_react;
configs["angular"] = config_angular;
configs["jquery"] = config_jquery;
var testconfigs = {};
testconfigs["ko"] = config_test_ko;

function buildTemplates(configName, index) {
    var curConfig = configs[configName];
    var curTemplate = curConfig.templates[index];
    return gulp.src(curTemplate.path)
        .pipe(concat(curTemplate.fileName))
        .pipe(html2ts())
        .pipe(insert.transform(function(contents, file) {
            contents = contents.slice(0, -1); //remove last symbol '}'
            contents = contents.replace('module template.window.ko { ', '');
            contents = contents.replace('export var html', 'export var koTemplate = { html : ""}; koTemplate.html');
            return contents.replace('module template.ko { ', '');
        }))
        .pipe(gulp.dest(curTemplate.dest));
}

function buildFromSources(configName) {
    var curConfig = configs[configName];
    var tsResult = gulp.src(curConfig.entryPoint)
        .pipe(webpackStream(configName !== "react" && configName !== "ko"? getWebpackUniversalConfig(curConfig) : getWebpackConfig(curConfig)));
    return tsResult
        .pipe(concat(curConfig.mainJSfile))
        .pipe(insert.prepend(copyright))
        .pipe(gulp.dest(paths.dist))
        .pipe(gulp.dest(paths.jsFolder))
        .pipe(gulp.dest(curConfig.packagePath + "dist/"));
}

function buildTypeDefinition(configName) {
    var curConfig = configs[configName];
    //Build js file
    //Build typescript definition
    var tscResult = gulp.src([
        paths.webroot + "/lib/survey/**/*.d.ts",
        paths.typings
    ].concat(curConfig.src))
        .pipe(ts({
            target: "ES5",
            noExternalResolve: true,
            allowSyntheticDefaultImports: true,
            outDir: "./some/dir/TODO/", // TODO we need any value of outDir for save folders structure for d.ts. BUT WHY?
            declaration: true,
            jsx: "react"
        }));
    return tscResult.dts
        .pipe(concat.header(tdHeader))
        .pipe(gulp.dest(paths.dist_dts))
        .pipe(gulp.dest(curConfig.packagePath + "dist/typings"));
}

function compressMainJS(configName) {
    var curConfig = configs[configName];
    gulp.src(paths.dist + curConfig.mainJSfile)
        .pipe(uglify())
        .pipe(rename({
            extname: ".min.js"
        }))
        .pipe(concat.header(copyright))
        .pipe(gulp.dest(curConfig.packagePath + "dist/"))
        .pipe(gulp.dest(curConfig.packagePath + "js/"))
        .pipe(gulp.dest(paths.dist));
}

function buildTests(configName) {
    var curConfig = testconfigs[configName];
    var tsResult = gulp.src(curConfig.entryPoint)
        .pipe(webpackStream(configName !== "react" && configName !== "ko"? getWebpackUniversalConfig(curConfig) : getWebpackConfig(curConfig)));
    return tsResult
        .pipe(concat(curConfig.mainJSfile))
        .pipe(gulp.dest(paths.testsFolder));
}

function createPackageJson(configName) {
    var curConfig = configs[configName];
    return gulp.src("packagetemplate.json")
        .pipe(jsonTransform(function (data) {
            data.name = curConfig.name;
            data.version = libraryVersion;
            if (curConfig.keywords) {
                for (var i = 0; i < curConfig.keywords.length; i++) {
                    data.keywords.push(curConfig.keywords[i]);
                }
            }
            data.main = './js/' + curConfig.mainJSfile.replace(".js", ".min.js");
            data.typings = './dist/typings/entries/' + curConfig.dtsfile;
            if (curConfig.dependencies) {
                for (var key in curConfig.dependencies) {
                    data.dependencies[key] = curConfig.dependencies[key];
                }
            }
            return data;
        }, "  "))
        .pipe(rename("package.json"))
        .pipe(gulp.dest(curConfig.packagePath));
}

gulp.task("ko_tempates", function () {
    return buildTemplates("ko", 0);
});
gulp.task("ko_windowtempates", function () {
    return buildTemplates("ko", 1);
});
gulp.task("ko_source", function () {
    buildTypeDefinition("ko");
    return buildFromSources("ko");
});
gulp.task("ko_compress", function () {
    compressMainJS("ko");
});
gulp.task("ko_createPackageJson", function () {
    createPackageJson("ko");
});

gulp.task("build_ko", sequence("ko_tempates", "ko_windowtempates", "ko_source", "ko_compress", "ko_createPackageJson"));

gulp.task("buildTests_ko", function () {
    return buildTests("ko");
});

gulp.task("react_source", function () {
    buildTypeDefinition("react");
    return buildFromSources("react");
});
gulp.task("react_compress", function () {
    compressMainJS("react");
});
gulp.task("react_createPackageJson", function () {
    createPackageJson("react");
});
gulp.task("build_react", sequence("react_source", "react_compress", "react_createPackageJson"));

gulp.task("angular_source", function () {
    buildTypeDefinition("angular");
    return buildFromSources("angular");
});
gulp.task("angular_compress", function () {
    compressMainJS("angular");
});
gulp.task("angular_createPackageJson", function () {
    createPackageJson("angular");
});
gulp.task("build_angular", sequence("angular_source", "angular_compress", "angular_createPackageJson"));

gulp.task("jquery_source", function () {
    buildTypeDefinition("jquery");
    return buildFromSources("jquery");
});
gulp.task("jquery_compress", function () {
    compressMainJS("jquery");
});
gulp.task("jquery_createPackageJson", function () {
    createPackageJson("jquery");
});
gulp.task("build_jquery", sequence("jquery_source", "jquery_compress", "jquery_createPackageJson"));

gulp.task('copyfiles', function (callback) {
    gulp.src(gnf(null, 'package.json'), { base: './' })
        .pipe(rename(function (path) {
            path.dirname = "";
            path.basename = path.basename.replace("-latest", "");
        }))
        .pipe(gulp.dest(paths.jsFolder));
});

gulp.task('sass', function () {
    "use strict";
    gulp.src(paths.styles)
        .pipe(sass.sync().on('error', sass.logError))
        .pipe(concat("survey.css"))
        .pipe(gulp.dest(paths.webroot + 'css'))
        .pipe(gulp.dest(paths.package_ko + 'dist/css'))
        .pipe(gulp.dest(paths.package_ko + 'css'))
        .pipe(gulp.dest(paths.package_react + 'dist/css'))
        .pipe(gulp.dest(paths.package_react + 'css'))
        .pipe(gulp.dest(paths.package_angular + 'dist/css'))
        .pipe(gulp.dest(paths.package_angular + 'css'))
        .pipe(gulp.dest(paths.package_jquery + 'dist/css'))
        .pipe(gulp.dest(paths.package_jquery + 'css'))
        .pipe(gulp.dest(paths.dist + 'css'));
});
gulp.task("makedist", sequence(["sass", "build_ko"], "buildTests_ko", "build_react", "build_angular", "build_jquery"));

gulp.task("test_ci", function (done) {
    new Server({
        configFile: __dirname + "/karma.conf.js",
        singleRun: true
    }, done).start();
});

gulp.task("server", serve({
    root: ["wwwroot"],
    port: 30001
}));<|endoftext|>