<commit_before>var gulp = require('gulp'),
    cp = require('child_process'),
    args = require('yargs').argv,
    fs = require('fs');

gulp.task('deploy', () => {
  if(args.name){
    if(fs.existsSync(`deployed-releases/${args.name}`)){
      console.log(`Release "${args.name}" already deployed`);
      return;
    }
    if(!fs.existsSync(`releases/${args.name}.zip`)){
      console.log(`Release "${args.name}" does not exist`);
      return;
    }

    if(fs.existsSync(`releases/${args.name}.zip`)){
      // we unzip the release
      console.log(cp.execSync(`cd releases; unzip ${args.name}.zip -d ../deployed-releases`));
      console.log(`Release "${args.name}" deployed`)
    }
  } else {
    console.log('Parameter --name is required');
  }
});

gulp.task('remove', () => {
  if(args.name){
    if(!fs.existsSync(`deployed-releases/${args.name}`)){
      console.log(`Release "${args.name}" does not exist`);
      return;
    }

    if(fs.existsSync(`web`)){
      const currentRelease = getActiveRelease();

      if(currentRelease === args.name) {
        console.log(`Release "${args.name}" is the current active release, and cannot be removed`);
        return;
      }
    }

    if(fs.existsSync(`deployed-releases/${args.name}`)){
      console.log(cp.execSync(`cd deployed-releases; rm -rf ${args.name}`));
      console.log(`Release "${args.name}" removed`)
    }
  } else {
    console.log('Parameter --name is required');
  }
});

gulp.task('publish', () => {
  if(args.name){
    if(!fs.existsSync(`deployed-releases/${args.name}`)){
      console.log(`Release "${args.name}" does not exist`);
      return;
    }

    //If the web folder already exist, we will first remove the symlink to sites
    removeSymlinks();

    // Next we create new symlinks to the new release
    const root = process.env.PWD;
    console.log(cp.execSync(`ln -s ${root}/deployed-releases/${args.name}/config ${root}/config`));
    console.log(cp.execSync(`ln -s ${root}/deployed-releases/${args.name}/vendor ${root}/vendor`));
    console.log(cp.execSync(`ln -s ${root}/deployed-releases/${args.name}/web ${root}/web`));
    console.log(cp.execSync(`ln -s ${root}/sites ${root}/deployed-releases/${args.name}/web/sites`));
  } else {
    console.log('Parameter --name is required');
  }
});

gulp.task('symlink-remove', () => {
  removeSymlinks();
});

const removeSymlinks = () => {
  const root = process.env.PWD;

  //If the web folder already exist, we will first remove the symlink to sites
  if(fs.existsSync(`web`)){
    const currentWebDir = fs.readlinkSync('web');
    console.log(currentWebDir);
    if(fs.existsSync(`${currentWebDir}/sites`)){
      console.log(cp.execSync(`rm -rf ${currentWebDir}/sites`));
    }
  }

  // // Now we can remove possible existing symlinks
  if(fs.existsSync(`${root}/config`)){
    console.log(cp.execSync(`rm -rf ${root}/config`));
  }
  if(fs.existsSync(`${root}/vendor`)){
    console.log(cp.execSync(`rm -rf ${root}/vendor`));
  }
  if(fs.existsSync(`${root}/web`)){
    console.log(cp.execSync(`rm -rf ${root}/web`));
  }
}

// Helper functions
const getActiveRelease = () => {
  const currentWebDir = fs.readlinkSync('web');
  const currentReleaseDir = currentWebDir.substring(0, currentWebDir.length - 4); // remove /web from path
  const positionOfLastSlash = currentReleaseDir.lastIndexOf('/');
  const currentRelease = currentReleaseDir.substring(positionOfLastSlash+1, currentReleaseDir.length);
  return currentRelease;
}
<commit_msg>Added chmod for config file<commit_after>var gulp = require('gulp'),
    cp = require('child_process'),
    args = require('yargs').argv,
    fs = require('fs');

gulp.task('deploy', () => {
  if(args.name){
    if(fs.existsSync(`deployed-releases/${args.name}`)){
      console.log(`Release "${args.name}" already deployed`);
      return;
    }
    if(!fs.existsSync(`releases/${args.name}.zip`)){
      console.log(`Release "${args.name}" does not exist`);
      return;
    }

    if(fs.existsSync(`releases/${args.name}.zip`)){
      // we unzip the release
      console.log(cp.execSync(`cd releases; unzip ${args.name}.zip -d ../deployed-releases`));
      console.log(cp.execSync(`chmod 0775 deployed-releases/${args.name}/config/sync`));
      console.log(`Release "${args.name}" deployed`)
    }
  } else {
    console.log('Parameter --name is required');
  }
});

gulp.task('remove', () => {
  if(args.name){
    if(!fs.existsSync(`deployed-releases/${args.name}`)){
      console.log(`Release "${args.name}" does not exist`);
      return;
    }

    if(fs.existsSync(`web`)){
      const currentRelease = getActiveRelease();

      if(currentRelease === args.name) {
        console.log(`Release "${args.name}" is the current active release, and cannot be removed`);
        return;
      }
    }

    if(fs.existsSync(`deployed-releases/${args.name}`)){
      console.log(cp.execSync(`cd deployed-releases; rm -rf ${args.name}`));
      console.log(`Release "${args.name}" removed`)
    }
  } else {
    console.log('Parameter --name is required');
  }
});

gulp.task('publish', () => {
  if(args.name){
    if(!fs.existsSync(`deployed-releases/${args.name}`)){
      console.log(`Release "${args.name}" does not exist`);
      return;
    }

    //If the web folder already exist, we will first remove the symlink to sites
    removeSymlinks();

    // Next we create new symlinks to the new release
    const root = process.env.PWD;
    console.log(cp.execSync(`ln -s ${root}/deployed-releases/${args.name}/config ${root}/config`));
    console.log(cp.execSync(`ln -s ${root}/deployed-releases/${args.name}/vendor ${root}/vendor`));
    console.log(cp.execSync(`ln -s ${root}/deployed-releases/${args.name}/web ${root}/web`));
    console.log(cp.execSync(`ln -s ${root}/sites ${root}/deployed-releases/${args.name}/web/sites`));
  } else {
    console.log('Parameter --name is required');
  }
});

gulp.task('symlink-remove', () => {
  removeSymlinks();
});

const removeSymlinks = () => {
  const root = process.env.PWD;

  //If the web folder already exist, we will first remove the symlink to sites
  if(fs.existsSync(`web`)){
    const currentWebDir = fs.readlinkSync('web');
    console.log(currentWebDir);
    if(fs.existsSync(`${currentWebDir}/sites`)){
      console.log(cp.execSync(`rm -rf ${currentWebDir}/sites`));
    }
  }

  // // Now we can remove possible existing symlinks
  if(fs.existsSync(`${root}/config`)){
    console.log(cp.execSync(`rm -rf ${root}/config`));
  }
  if(fs.existsSync(`${root}/vendor`)){
    console.log(cp.execSync(`rm -rf ${root}/vendor`));
  }
  if(fs.existsSync(`${root}/web`)){
    console.log(cp.execSync(`rm -rf ${root}/web`));
  }
}

// Helper functions
const getActiveRelease = () => {
  const currentWebDir = fs.readlinkSync('web');
  const currentReleaseDir = currentWebDir.substring(0, currentWebDir.length - 4); // remove /web from path
  const positionOfLastSlash = currentReleaseDir.lastIndexOf('/');
  const currentRelease = currentReleaseDir.substring(positionOfLastSlash+1, currentReleaseDir.length);
  return currentRelease;
}
<|endoftext|>


<commit_before>var elixir = require('laravel-elixir')
require('laravel-elixir-vue-2')

elixir(function (mix) {
    mix.copy('./node_modules/font-awesome/fonts/**', 'public/fonts')
    mix.copy('./assets/images/**', './public/images')
    mix.sass('./assets/scss/app.scss', './public/css/app.css')
    mix.webpack('./app/index.js', './public/js/app.js')
})
<commit_msg>remove font-awesome from build process<commit_after>var elixir = require('laravel-elixir')
require('laravel-elixir-vue-2')

elixir(function (mix) {
    mix.copy('./assets/images/**', './public/images')
    mix.sass('./assets/scss/app.scss', './public/css/app.css')
    mix.webpack('./app/index.js', './public/js/app.js')
})
<|endoftext|>


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

// Gulp plugins
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var cssBase64 = require('gulp-css-base64');
var postcss = require('gulp-postcss');
var uglify = require('gulp-uglify');
var gif = require('gulp-if');
var rename = require('gulp-rename');
var tslint = require('gulp-tslint');
var sassLint = require('gulp-sass-lint');
var ts = require('gulp-typescript');
var replace = require('gulp-replace');

// PostCSS plugins
var postcssSVG = require('postcss-svg');
var autoprefixer = require('autoprefixer');
var cssnano = require('cssnano');

// Browserify
var browserify = require('browserify');
var tsify = require('tsify');
var watchify = require('watchify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');

// Various stuff
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var merge = require('merge2');
var nativeTslint = require('tslint');
var npmPackage = require('./package.json');
var path = require('path');
var combine = require('stream-combiner2');

const globalNamespace = 'bitmovin.playerui';
const filename = 'bitmovinplayer-ui';

var paths = {
  source: {
    html: ['./src/html/*.html'],
    tsmain: ['./src/ts/main.ts'],
    ts: ['./src/ts/**/*.ts'],
    sass: ['./src/scss/**/*.scss']
  },
  target: {
    html: './dist',
    js: './dist/js',
    jsframework: './dist/js/framework',
    jsmain: `${filename}.js`,
    css: './dist/css'
  }
};

var replacements = [
  ['{{VERSION}}', npmPackage.version],
];

var browserifyInstance = browserify({
  basedir: '.',
  debug: true,
  entries: paths.source.tsmain,
  cache: {},
  packageCache: {},
  standalone: globalNamespace,
}).plugin(tsify);

var catchBrowserifyErrors = false;
var production = false;

function replaceAll() {
  var replacementStreams = replacements.map(function(replacement) { return replace(replacement[0], replacement[1]); });
  return combine.apply(this, replacementStreams);
}

// Deletes the target directory containing all generated files
gulp.task('clean', function() {
  return del([paths.target.html]);
});

// TypeScript linting
gulp.task('lint-ts', function() {
  // The program is required for type checking rules to work: https://palantir.github.io/tslint/usage/type-checking/
  var program = nativeTslint.Linter.createProgram("./tsconfig.json");

  return gulp.src(paths.source.ts)
  .pipe(tslint({
    formatter: 'verbose',
    program: program,
  }))
  .pipe(tslint.report({
    // Print just the number of errors (instead of printing all errors again)
    summarizeFailureOutput: true
  }))
});

// Sass/SCSS linting
gulp.task('lint-sass', function() {
  return gulp.src(paths.source.sass)
  .pipe(sassLint({
    rules: {
      'no-css-comments': 0
    }
  }))
  .pipe(sassLint.format())
  .pipe(sassLint.failOnError())
});

// Runs all linters
gulp.task('lint', function(callback) {
  // this fails at first error so we can't run all linters sequentially with runSequence and then print the errors
  runSequence('lint-ts', 'lint-sass', callback);
  // TODO check in Gulp 4.0 if all linters can be run sequentially before aborting due to an error
});

// Copies html files to the target directory
gulp.task('html', function() {
  return gulp.src(paths.source.html)
  .pipe(gulp.dest(paths.target.html));
});

// Compiles JS and TypeScript to JS in the target directory
gulp.task('browserify', function() {
  var browserifyBundle = browserifyInstance.bundle();

  if (catchBrowserifyErrors) {
    // Normally an error breaks a running task. For permanent tasks like watch/serve, we want the task to
    // stay alive and ignore errors, so we catch them here and print them to the console.
    browserifyBundle.on('error', console.error.bind(console));
  }

  // Compile output JS file
  var stream = browserifyBundle
  .pipe(source(paths.target.jsmain))
  .pipe(replaceAll())
  .pipe(buffer()) // required for production/sourcemaps
  .pipe(gulp.dest(paths.target.js));

  if (production) {
    // Minify JS
    stream.pipe(sourcemaps.init({loadMaps: true}))
    .pipe(uglify())
    .pipe(rename({extname: '.min.js'}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(paths.target.js));
  }

  return stream.pipe(browserSync.reload({stream: true}));
});

// Compiles SASS stylesheets to CSS stylesheets in the target directory, adds autoprefixes and creates sourcemaps
gulp.task('sass', function() {
  var stream = gulp.src(paths.source.sass)
  .pipe(sourcemaps.init())
  .pipe(sass({
    includePaths: [
      // Includes node_modules of the current module
      path.join(__dirname, 'node_modules'),
      // Includes node_modules of the current module, or, if used as a dependency in a supermodule where this
      // gulpfile is reused, includes node_modules of the supermodule
      './node_modules'],
  }).on('error', sass.logError))
  .pipe(postcss([
    autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}),
    postcssSVG()
  ]))
  .pipe(cssBase64())
  .pipe(sourcemaps.write())
  .pipe(gulp.dest(paths.target.css));

  if (production) {
    // Minify CSS
    stream.pipe(postcss([cssnano({
      // Disable svg optimizer because output is not a valid URI and does not work in IE11
      // TODO check if it works in a later version, because disabling increases file size substantially
      svgo: false
    })]))
    .pipe(rename({extname: '.min.css'}))
    .pipe(gulp.dest(paths.target.css));
  }

  return stream.pipe(browserSync.reload({stream: true}));
});

// Builds the complete project from the sources into the target directory
gulp.task('build', function(callback) {
  // First run 'clean', then the other tasks
  // TODO remove runSequence on Gulp 4.0 and use built in serial execution instead
  runSequence('clean',
    ['html', 'browserify', 'sass'],
    callback);
});

gulp.task('build-prod', function(callback) {
  production = true;
  runSequence('lint', 'build', callback);
});

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

// Watches files for changes and runs their build tasks
gulp.task('watch', function() {
  // Watch for changed html files
  gulp.watch(paths.source.html, ['html']);

  // Watch SASS files
  gulp.watch(paths.source.sass, ['sass']);

  // Watch files for changes through Browserify with Watchify
  catchBrowserifyErrors = true;
  return browserifyInstance
  .plugin(watchify)
  // When a file has changed, rerun the browserify task to create an updated bundle
  .on('update', function() {
    gulp.start('browserify');
  })
  .bundle();
});

// Serves the project in the browser and updates it automatically on changes
gulp.task('serve', function() {
  runSequence(['build'], function() {
    browserSync({
      notify: false,
      port: 9000,
      server: {
        baseDir: [paths.target.html]
      }
    });

    gulp.watch(paths.source.sass, ['sass']);
    gulp.watch(paths.source.html).on('change', function() { runSequence('html', browserSync.reload); });
    catchBrowserifyErrors = true;
    gulp.watch(paths.source.ts, ['browserify']);
  });
});

// Prepares the project for a npm release
// After running this task, the project can be published to npm or installed from this folder.
gulp.task('npm-prepare', ['build-prod'], function() {
  // https://www.npmjs.com/package/gulp-typescript
  var tsProject = ts.createProject('tsconfig.json');
  var tsResult = gulp.src(paths.source.ts).pipe(tsProject());

  return merge([
    tsResult.dts.pipe(gulp.dest(paths.target.jsframework)),
    tsResult.js.pipe(replaceAll()).pipe(gulp.dest(paths.target.jsframework))
  ]);
});

// Export the paths object to allow customization (e.g. js output filename) from other gulpfiles that import
// and reuse the tasks from here.
module.exports.paths = paths;
<commit_msg>Move CSS output filename to variable<commit_after>var gulp = require('gulp');

// Gulp plugins
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var cssBase64 = require('gulp-css-base64');
var postcss = require('gulp-postcss');
var uglify = require('gulp-uglify');
var gif = require('gulp-if');
var rename = require('gulp-rename');
var tslint = require('gulp-tslint');
var sassLint = require('gulp-sass-lint');
var ts = require('gulp-typescript');
var replace = require('gulp-replace');

// PostCSS plugins
var postcssSVG = require('postcss-svg');
var autoprefixer = require('autoprefixer');
var cssnano = require('cssnano');

// Browserify
var browserify = require('browserify');
var tsify = require('tsify');
var watchify = require('watchify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');

// Various stuff
var del = require('del');
var runSequence = require('run-sequence');
var browserSync = require('browser-sync');
var merge = require('merge2');
var nativeTslint = require('tslint');
var npmPackage = require('./package.json');
var path = require('path');
var combine = require('stream-combiner2');

const globalNamespace = 'bitmovin.playerui';
const filename = 'bitmovinplayer-ui';

var paths = {
  source: {
    html: ['./src/html/*.html'],
    tsmain: ['./src/ts/main.ts'],
    ts: ['./src/ts/**/*.ts'],
    sass: ['./src/scss/**/*.scss']
  },
  target: {
    html: './dist',
    js: './dist/js',
    jsframework: './dist/js/framework',
    jsmain: `${filename}.js`,
    css: './dist/css'
  }
};

var replacements = [
  ['{{VERSION}}', npmPackage.version],
];

var browserifyInstance = browserify({
  basedir: '.',
  debug: true,
  entries: paths.source.tsmain,
  cache: {},
  packageCache: {},
  standalone: globalNamespace,
}).plugin(tsify);

var catchBrowserifyErrors = false;
var production = false;

function replaceAll() {
  var replacementStreams = replacements.map(function(replacement) { return replace(replacement[0], replacement[1]); });
  return combine.apply(this, replacementStreams);
}

// Deletes the target directory containing all generated files
gulp.task('clean', function() {
  return del([paths.target.html]);
});

// TypeScript linting
gulp.task('lint-ts', function() {
  // The program is required for type checking rules to work: https://palantir.github.io/tslint/usage/type-checking/
  var program = nativeTslint.Linter.createProgram("./tsconfig.json");

  return gulp.src(paths.source.ts)
  .pipe(tslint({
    formatter: 'verbose',
    program: program,
  }))
  .pipe(tslint.report({
    // Print just the number of errors (instead of printing all errors again)
    summarizeFailureOutput: true
  }))
});

// Sass/SCSS linting
gulp.task('lint-sass', function() {
  return gulp.src(paths.source.sass)
  .pipe(sassLint({
    rules: {
      'no-css-comments': 0
    }
  }))
  .pipe(sassLint.format())
  .pipe(sassLint.failOnError())
});

// Runs all linters
gulp.task('lint', function(callback) {
  // this fails at first error so we can't run all linters sequentially with runSequence and then print the errors
  runSequence('lint-ts', 'lint-sass', callback);
  // TODO check in Gulp 4.0 if all linters can be run sequentially before aborting due to an error
});

// Copies html files to the target directory
gulp.task('html', function() {
  return gulp.src(paths.source.html)
  .pipe(gulp.dest(paths.target.html));
});

// Compiles JS and TypeScript to JS in the target directory
gulp.task('browserify', function() {
  var browserifyBundle = browserifyInstance.bundle();

  if (catchBrowserifyErrors) {
    // Normally an error breaks a running task. For permanent tasks like watch/serve, we want the task to
    // stay alive and ignore errors, so we catch them here and print them to the console.
    browserifyBundle.on('error', console.error.bind(console));
  }

  // Compile output JS file
  var stream = browserifyBundle
  .pipe(source(paths.target.jsmain))
  .pipe(replaceAll())
  .pipe(buffer()) // required for production/sourcemaps
  .pipe(gulp.dest(paths.target.js));

  if (production) {
    // Minify JS
    stream.pipe(sourcemaps.init({loadMaps: true}))
    .pipe(uglify())
    .pipe(rename({extname: '.min.js'}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest(paths.target.js));
  }

  return stream.pipe(browserSync.reload({stream: true}));
});

// Compiles SASS stylesheets to CSS stylesheets in the target directory, adds autoprefixes and creates sourcemaps
gulp.task('sass', function() {
  var stream = gulp.src(paths.source.sass)
  .pipe(sourcemaps.init())
  .pipe(sass({
    includePaths: [
      // Includes node_modules of the current module
      path.join(__dirname, 'node_modules'),
      // Includes node_modules of the current module, or, if used as a dependency in a supermodule where this
      // gulpfile is reused, includes node_modules of the supermodule
      './node_modules'],
  }).on('error', sass.logError))
  .pipe(postcss([
    autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}),
    postcssSVG()
  ]))
  .pipe(cssBase64())
  .pipe(rename(function(path) {
    // The original filename is defined by the scss source file
    if (path.basename === 'bitmovinplayer-ui') {
      path.basename = filename;
    }
  }))
  .pipe(sourcemaps.write())
  .pipe(gulp.dest(paths.target.css));

  if (production) {
    // Minify CSS
    stream.pipe(postcss([cssnano({
      // Disable svg optimizer because output is not a valid URI and does not work in IE11
      // TODO check if it works in a later version, because disabling increases file size substantially
      svgo: false
    })]))
    .pipe(rename({extname: '.min.css'}))
    .pipe(gulp.dest(paths.target.css));
  }

  return stream.pipe(browserSync.reload({stream: true}));
});

// Builds the complete project from the sources into the target directory
gulp.task('build', function(callback) {
  // First run 'clean', then the other tasks
  // TODO remove runSequence on Gulp 4.0 and use built in serial execution instead
  runSequence('clean',
    ['html', 'browserify', 'sass'],
    callback);
});

gulp.task('build-prod', function(callback) {
  production = true;
  runSequence('lint', 'build', callback);
});

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

// Watches files for changes and runs their build tasks
gulp.task('watch', function() {
  // Watch for changed html files
  gulp.watch(paths.source.html, ['html']);

  // Watch SASS files
  gulp.watch(paths.source.sass, ['sass']);

  // Watch files for changes through Browserify with Watchify
  catchBrowserifyErrors = true;
  return browserifyInstance
  .plugin(watchify)
  // When a file has changed, rerun the browserify task to create an updated bundle
  .on('update', function() {
    gulp.start('browserify');
  })
  .bundle();
});

// Serves the project in the browser and updates it automatically on changes
gulp.task('serve', function() {
  runSequence(['build'], function() {
    browserSync({
      notify: false,
      port: 9000,
      server: {
        baseDir: [paths.target.html]
      }
    });

    gulp.watch(paths.source.sass, ['sass']);
    gulp.watch(paths.source.html).on('change', function() { runSequence('html', browserSync.reload); });
    catchBrowserifyErrors = true;
    gulp.watch(paths.source.ts, ['browserify']);
  });
});

// Prepares the project for a npm release
// After running this task, the project can be published to npm or installed from this folder.
gulp.task('npm-prepare', ['build-prod'], function() {
  // https://www.npmjs.com/package/gulp-typescript
  var tsProject = ts.createProject('tsconfig.json');
  var tsResult = gulp.src(paths.source.ts).pipe(tsProject());

  return merge([
    tsResult.dts.pipe(gulp.dest(paths.target.jsframework)),
    tsResult.js.pipe(replaceAll()).pipe(gulp.dest(paths.target.jsframework))
  ]);
});

// Export the paths object to allow customization (e.g. js output filename) from other gulpfiles that import
// and reuse the tasks from here.
module.exports.paths = paths;
<|endoftext|>


<commit_before>// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

const BuildLangTask = require('./gulp/task-build-lang');
const BuildBehatPluginTask = require('./gulp/task-build-behat-plugin');
const BuildEnvTask = require('./gulp/task-build-env');
const PushTask = require('./gulp/task-push');
const Utils = require('./gulp/utils');
const gulp = require('gulp');

const paths = {
    lang: [
        './src/addons/**/',
        './src/assets/countries.json',
        './src/assets/mimetypes.json',
        './src/core/features/**/',
        './src/core/',
    ],
};

const args = Utils.getCommandLineArguments();

// Build the language files into a single file per language.
gulp.task('lang', (done) => {
    new BuildLangTask().run(paths.lang, done);
});

// Build an env file depending on the current environment.
gulp.task('env', (done) => {
    new BuildEnvTask().run(done);
});

// Build a Moodle plugin to run Behat tests.
if (BuildBehatPluginTask.isBehatConfigured()) {
    gulp.task('behat', (done) => {
        new BuildBehatPluginTask().run(done);
    });
}

gulp.task('push', (done) => {
    new PushTask().run(args, done);
});

gulp.task(
    'default',
    gulp.parallel([
        'lang',
        'env',
        ...(BuildBehatPluginTask.isBehatConfigured() ? ['behat'] : [])
    ]),
);

gulp.task('watch', () => {
    gulp.watch(paths.lang, { interval: 500 }, gulp.parallel('lang'));
    gulp.watch(['./moodle.config.json', './moodle.config.*.json'], { interval: 500 }, gulp.parallel('env'));

    if (BuildBehatPluginTask.isBehatConfigured()) {
        gulp.watch(['./tests/behat'], { interval: 500 }, gulp.parallel('behat'));
    }
});
<commit_msg>MOBILE-3833 DX: Implement watch-behat gulp task<commit_after>// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

const BuildLangTask = require('./gulp/task-build-lang');
const BuildBehatPluginTask = require('./gulp/task-build-behat-plugin');
const BuildEnvTask = require('./gulp/task-build-env');
const PushTask = require('./gulp/task-push');
const Utils = require('./gulp/utils');
const gulp = require('gulp');

const paths = {
    lang: [
        './src/addons/**/',
        './src/assets/countries.json',
        './src/assets/mimetypes.json',
        './src/core/features/**/',
        './src/core/',
    ],
};

const args = Utils.getCommandLineArguments();

// Build the language files into a single file per language.
gulp.task('lang', (done) => {
    new BuildLangTask().run(paths.lang, done);
});

// Build an env file depending on the current environment.
gulp.task('env', (done) => {
    new BuildEnvTask().run(done);
});

// Build a Moodle plugin to run Behat tests.
if (BuildBehatPluginTask.isBehatConfigured()) {
    gulp.task('behat', (done) => {
        new BuildBehatPluginTask().run(done);
    });
}

gulp.task('push', (done) => {
    new PushTask().run(args, done);
});

gulp.task(
    'default',
    gulp.parallel([
        'lang',
        'env',
        ...(BuildBehatPluginTask.isBehatConfigured() ? ['behat'] : [])
    ]),
);

gulp.task('watch', () => {
    gulp.watch(paths.lang, { interval: 500 }, gulp.parallel('lang'));
    gulp.watch(['./moodle.config.json', './moodle.config.*.json'], { interval: 500 }, gulp.parallel('env'));

    if (BuildBehatPluginTask.isBehatConfigured()) {
        gulp.watch(['./tests/behat'], { interval: 500 }, gulp.parallel('behat'));
    }
});

gulp.task('watch-behat', () => {
    gulp.watch(['./tests/behat'], { interval: 500 }, gulp.parallel('behat'));
});
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var del = require('del');
var autoprefixer = require('gulp-autoprefixer');
var sass = require('gulp-sass');
var svgmin = require('gulp-svgmin');
var rename = require('gulp-rename');
var handlebars = require('gulp-handlebars');
var wrap = require('gulp-wrap');
var declare = require('gulp-declare');
var order = require('gulp-order');
var es = require('event-stream');
var compress = require('compression');
var path = require('path');
var htmlReplace = require('gulp-html-replace');

//- Libraries
var lib = {
    min: ['lib/three.js/build/three.min.js', 'lib/handlebars/handlebars.runtime.min.js', 'lib/isMobile/isMobile.min.js'],
    src: ['lib/colladaLoader/index.js', 'lib/detector/index.js']
};

//- SASS
var scssIdx = ['src/scss/index.scss'];
var scss = ['src/scss/**/*.scss'];

//- HTML
var htmlIdx = ['src/index.html'];
var html = ['src/**/*.html'];

//- Images
var img = ['src/images/**/*', '!src/images/**/*.svg'];

//- SVG
var svg = ['src/images/**/*.svg'];

//- Handlebars
var hbs = {
    templates: ['src/handlebars/templates/**/*.hbs'],
    partials: ['src/handlebars/partials/**/*.hbs']
};

//- Javascript
var js = [
    'src/javascript/helpers/**/*.js',
    'src/handlebars/**/*.js',
    'src/javascript/control/**/*.js',
    'src/javascript/models/**/*.js',
    'src/javascript/scene/**/*.js',
    'src/javascript/simulator/**/*.js',
    'src/javascript/settings/**/*.js',
    'src/javascript/app.js',
];

//- Images tasks
gulp.task('img', function() {
    return gulp.src(img)
                .pipe(imagemin())
                .pipe(gulp.dest('dist/img'));
});

gulp.task('svg', function () {
    return gulp.src(svg)
                .pipe(svgmin())
                .pipe(gulp.dest('dist/img'));
});

//- Handlebars tasks
gulp.task('hbs', function () {
    var partials = gulp.src(hbs.partials)
            .pipe(handlebars())
            .pipe(wrap('Handlebars.registerPartial(<%= processPartialName(file.relative) %>, Handlebars.template(<%= contents %>));', {}, {
                imports: {
                    processPartialName: function(fileName) {
                        return JSON.stringify(path.basename(fileName, '.js').substr(1));
                    }
                }
            }));

    var templates = gulp.src(hbs.templates)
            .pipe(handlebars())
            .pipe(wrap('Handlebars.template(<%= contents %>)'))
            .pipe(declare({
                namespace: 'decoraki.templates',
                noRedeclare: true
            }));

    return es.merge([partials, templates])
                .pipe(concat('all.hbs.js'))
                .pipe(gulp.dest('dist/temporary-cache/hbs/'));
});

//- Javascript tasks
gulp.task('lib', function() {
    var min = gulp.src(lib.min)
                .pipe(concat('min.js'));

    var src = gulp.src(lib.src)
                .pipe(concat('src.js'))
                .pipe(uglify());

    return es.merge([min, src])
                .pipe(order(['min.js', 'src.js']))
                .pipe(concat('index.min.js'))
                .pipe(gulp.dest('dist/lib/'));
});

gulp.task('js', ['lib', 'hbs'], function() {
    js.unshift('dist/temporary-cache/hbs/**/*.js');

    return gulp.src(js)
                .pipe(concat('index.min.js'))
                .pipe(sourcemaps.init())
                .pipe(uglify())
                .pipe(sourcemaps.write('.'))
                .pipe(gulp.dest('dist/js/'))
                .on('end', function() {
                    del.sync(['./dist/temporary-cache']);
                });
});

gulp.task('deploy-js', ['lib', 'hbs'], function() {
    js.unshift('dist/temporary-cache/hbs/**/*.js');
    js.unshift('dist/lib/**/*.js');

    return gulp.src(js)
                .pipe(concat('index.min.js'))
                .pipe(uglify())
                .pipe(gulp.dest('dist/js/'))
                .on('end', function() {
                    del.sync(['./dist/temporary-cache']);
                    del.sync(['./dist/lib']);
                });
});

//- SASS tasks
gulp.task('sass', function() {
    return gulp.src(scssIdx)
                .pipe(sourcemaps.init())
                .pipe(sass({outputStyle: 'compressed'}))
                .pipe(rename({basename: 'index.min'}))
                .pipe(autoprefixer({browsers: ['last 2 versions']}))
                .pipe(sourcemaps.write('.'))
                .pipe(gulp.dest('dist/css/'));
});

gulp.task('deploy-sass', function() {
    return gulp.src(scssIdx)
                .pipe(sass({outputStyle: 'compressed'}))
                .pipe(rename({basename: 'index.min'}))
                .pipe(autoprefixer({browsers: ['last 2 versions']}))
                .pipe(gulp.dest('dist/css/'));
});

//- HTML tasks
gulp.task('html', function() {
    return gulp.src(htmlIdx)
                .pipe(htmlReplace({
                    'js': ['lib/index.min.js', 'js/index.min.js'],
                    'css': 'css/index.min.css'
                }))
                .pipe(gulp.dest('dist/'));
});

gulp.task('deploy-html', function() {
    return gulp.src(htmlIdx)
                .pipe(htmlReplace({
                    'js': ['js/index.min.js'],
                    'css': 'css/index.min.css'
                }))
                .pipe(gulp.dest('dist/'));
});

//- Sync tasks
gulp.task('bsync', function() {
    browserSync.init('dist/**/*',{
        server: {
            baseDir: './dist/',
            middleware: [compress()]
        },
        startPath: "/"
    });
});

gulp.task('watch', ['bsync'], function() {
    var hbspt = hbs.partials.concat(hbs.templates);

    gulp.watch(js, ['js']);
    gulp.watch(hbspt, ['js']);
    gulp.watch(img, ['img']);
    gulp.watch(svg, ['svg']);
    gulp.watch(scss, ['sass']);
    gulp.watch(html, ['html']);
});

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

gulp.task('default', ['clean'], function() {
    gulp.start('html', 'img', 'svg', 'sass', 'js');
});

gulp.task('deploy', ['clean'], function() {
    gulp.start('img', 'svg','deploy-html', 'deploy-sass', 'deploy-js');
});

<commit_msg>Cosmetic changes<commit_after>'use strict';

var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync');
var del = require('del');
var autoprefixer = require('gulp-autoprefixer');
var sass = require('gulp-sass');
var svgmin = require('gulp-svgmin');
var rename = require('gulp-rename');
var handlebars = require('gulp-handlebars');
var wrap = require('gulp-wrap');
var declare = require('gulp-declare');
var order = require('gulp-order');
var es = require('event-stream');
var compress = require('compression');
var path = require('path');
var htmlReplace = require('gulp-html-replace');

//- Libraries
var lib = {
    min: ['lib/three.js/build/three.min.js', 'lib/handlebars/handlebars.runtime.min.js', 'lib/isMobile/isMobile.min.js'],
    src: ['lib/colladaLoader/index.js', 'lib/detector/index.js']
};

//- SASS
var scssIdx = ['src/scss/index.scss'];
var scss = ['src/scss/**/*.scss'];

//- HTML
var htmlIdx = ['src/index.html'];
var html = ['src/**/*.html'];

//- Images
var img = ['src/images/**/*', '!src/images/**/*.svg'];

//- SVG
var svg = ['src/images/**/*.svg'];

//- Handlebars
var hbs = {
    templates: ['src/handlebars/templates/**/*.hbs'],
    partials: ['src/handlebars/partials/**/*.hbs']
};

//- Javascript
var js = [
    'src/javascript/helpers/**/*.js',
    'src/handlebars/**/*.js',
    'src/javascript/control/**/*.js',
    'src/javascript/models/**/*.js',
    'src/javascript/scene/**/*.js',
    'src/javascript/simulator/**/*.js',
    'src/javascript/settings/**/*.js',
    'src/javascript/app.js',
];

//- Images tasks
gulp.task('img', function() {
    return gulp.src(img)
                .pipe(imagemin())
                .pipe(gulp.dest('dist/img'));
});

gulp.task('svg', function () {
    return gulp.src(svg)
                .pipe(svgmin())
                .pipe(gulp.dest('dist/img'));
});

//- Handlebars tasks
gulp.task('hbs', function () {
    var partials = gulp.src(hbs.partials)
            .pipe(handlebars())
            .pipe(wrap('Handlebars.registerPartial(<%= processPartialName(file.relative) %>, Handlebars.template(<%= contents %>));', {}, {
                imports: {
                    processPartialName: function(fileName) {
                        return JSON.stringify(path.basename(fileName, '.js').substr(1));
                    }
                }
            }));

    var templates = gulp.src(hbs.templates)
            .pipe(handlebars())
            .pipe(wrap('Handlebars.template(<%= contents %>)'))
            .pipe(declare({
                namespace: 'decoraki.templates',
                noRedeclare: true
            }));

    return es.merge([partials, templates])
                .pipe(concat('all.hbs.js'))
                .pipe(gulp.dest('dist/temporary-cache/hbs/'));
});

//- Javascript tasks
gulp.task('lib', function() {
    var min = gulp.src(lib.min)
                .pipe(concat('min.js'));

    var src = gulp.src(lib.src)
                .pipe(concat('src.js'))
                .pipe(uglify());

    return es.merge([min, src])
                .pipe(order(['min.js', 'src.js']))
                .pipe(concat('index.min.js'))
                .pipe(gulp.dest('dist/lib/'));
});

gulp.task('js', ['lib', 'hbs'], function() {
    js.unshift('dist/temporary-cache/hbs/**/*.js');

    return gulp.src(js)
                .pipe(concat('index.min.js'))
                .pipe(sourcemaps.init())
                .pipe(uglify())
                .pipe(sourcemaps.write('.'))
                .pipe(gulp.dest('dist/js/'))
                .on('end', function() {
                    del.sync(['./dist/temporary-cache']);
                });
});

gulp.task('deploy-js', ['lib', 'hbs'], function() {
    js.unshift('dist/temporary-cache/hbs/**/*.js');
    js.unshift('dist/lib/**/*.js');

    return gulp.src(js)
                .pipe(concat('index.min.js'))
                .pipe(uglify())
                .pipe(gulp.dest('dist/js/'))
                .on('end', function() {
                    del.sync(['./dist/temporary-cache']);
                    del.sync(['./dist/lib']);
                });
});

//- SASS tasks
gulp.task('sass', function() {
    return gulp.src(scssIdx)
                .pipe(sourcemaps.init())
                .pipe(sass({outputStyle: 'compressed'}))
                .pipe(rename({basename: 'index.min'}))
                .pipe(autoprefixer({browsers: ['last 2 versions']}))
                .pipe(sourcemaps.write('.'))
                .pipe(gulp.dest('dist/css/'));
});

gulp.task('deploy-sass', function() {
    return gulp.src(scssIdx)
                .pipe(sass({outputStyle: 'compressed'}))
                .pipe(rename({basename: 'index.min'}))
                .pipe(autoprefixer({browsers: ['last 2 versions']}))
                .pipe(gulp.dest('dist/css/'));
});

//- HTML tasks
gulp.task('html', function() {
    return gulp.src(htmlIdx)
                .pipe(htmlReplace({
                    'js': ['lib/index.min.js', 'js/index.min.js'],
                    'css': 'css/index.min.css'
                }))
                .pipe(gulp.dest('dist/'));
});

gulp.task('deploy-html', function() {
    return gulp.src(htmlIdx)
                .pipe(htmlReplace({
                    'js': ['js/index.min.js'],
                    'css': 'css/index.min.css'
                }))
                .pipe(gulp.dest('dist/'));
});

//- Sync tasks
gulp.task('bsync', function() {
    browserSync.init('dist/**/*',{
        server: {
            baseDir: './dist/',
            middleware: [compress()]
        },
        startPath: "/"
    });
});

gulp.task('watch', ['bsync'], function() {
    var hbspt = hbs.partials.concat(hbs.templates);

    gulp.watch(js, ['js']);
    gulp.watch(hbspt, ['js']);
    gulp.watch(img, ['img']);
    gulp.watch(svg, ['svg']);
    gulp.watch(scss, ['sass']);
    gulp.watch(html, ['html']);
});

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

gulp.task('default', ['clean'], function() {
    gulp.start('html', 'img', 'svg', 'sass', 'js');
});

gulp.task('deploy', ['clean'], function() {
    gulp.start('deploy-html', 'deploy-sass', 'deploy-js', 'img', 'svg');
});

<|endoftext|>


<commit_before>var gulp        = require('gulp'),
    imagemin    = require('gulp-imagemin'),
    notify      = require('gulp-notify'),
    cssimport   = require('gulp-cssimport'),
    include     = require("gulp-include"),
    shell       = require('gulp-shell'),
    zip         = require('gulp-zip'),
    open        = require('gulp-open'),
    runSequence = require('run-sequence'),
    del         = require('del'),
    pkg         = require('./package.json')
    browserSync = require('browser-sync').create(),
    fs          = require('fs'),
    yaml        = require('js-yaml'),
    argv        = require('yargs').argv,
    gulpif      = require('gulp-if');

/**
 *
 *  All the paths used by all the tasks
 *
 */

var paths = {
  srcScss: 'src/stylesheets/**/*.*',
  srcJs: 'src/javascripts/**/*.*',
  parentIncludeScss: [
    'src/stylesheets/[^_]*.*'
  ],
  parentIncludeJs: [
    'src/javascripts/*.*'
  ],
  images: 'src/images/*.{png,jpg,gif}',
  destAssets: 'assets',
  uploadFiles: [
    'config/*',
    'layout/*',
    'locales/*',
    'snippets/*',
    'templates/**/*'
  ],
  config: 'config.yml',
  watch: 'src/theme.update'
};

/**
 *   CONCAT CSS:
 *
 *   Concatenate css together into a single scss file for use in the theme
 */

gulp.task('concat-css', function () {
  gulp.src(paths.parentIncludeScss)
    .pipe(cssimport())
    .pipe(gulp.dest(paths.destAssets));
});

/**
 *   CONCAT JS:
 *
 *   Concatenate JS together into a single file for use in the theme
 */

gulp.task('concat-js', function () {
  gulp.src(paths.parentIncludeJs)
    .pipe(include())
      .on('error', console.log)
    .pipe(gulp.dest(paths.destAssets));
});

/**
 *    IMAGEMIN
 *
 *    Minify Images
 */

gulp.task('imagemin', function () {
  gulp.src(paths.images)
    .pipe(imagemin({
        optimizationLevel: 3
    }))
    .pipe(gulp.dest(paths.destAssets))
});

/**
 *  BROWSERSYNC
 */

gulp.task('browser-sync', function(options) {
  // read the shop url from the config file
  var config = yaml.safeLoad(fs.readFileSync(paths.config, 'utf8'));

  //remove this if theme gem used instead
  //of theme kit
  config = config.development;

  browserSync.init({
    proxy: config.store
  });
});

/**
 *  THEME WATCH
 *
 *  Run the theme gem watch to upload any changed files to your store
 */

gulp.task('theme-watch', function () {
  return gulp.src('')
    .pipe(gulpif(argv.themekit, shell('theme watch --notify=src/theme.update'), shell('theme watch')));
});

/**
 *  REPLACE
 *
 *  Replace your existing theme using the theme gem.  It's best
 *  to use `gulp build` before running this task so it also builds the
 *  CSS, and images first.
 */

gulp.task('replace', function () {
  gulp.src('')
    .pipe(shell('theme replace'));
});

/**
 *  UPLOAD
 *
 *  Upload your existing theme using the theme gem.  Unlike the `replace` task,
 *  the upload task doesn't remove any files from your store before uploading
 *  your theme. It's best to use `gulp build` before running this task so it also builds the
 *  CSS, and images first.
 */

gulp.task('upload', function () {
  gulp.src('')
    .pipe(shell('theme upload'));
});

/**
 *  CONCURRENT
 *
 *  Run both the gulp watch to build CSS, and images along side the theme gem watch
 *  to upload any changes to your store after being built
 */

gulp.task('concurrent', function (cb) {
  runSequence(['watch', 'theme-watch'], cb);
});

/**
 *  CLEAN
 *
 *  Clean up any stray files that might be created by other gulp tasks
 */

gulp.task('clean', function (cb) {
  del([
    '*.zip',
    'assets/**/*',
    '!assets/*.*'
  ], cb)
});

/**
 *  ZIP
 *
 *  compress theme and prepare it for the theme store
 */

gulp.task('compress', function () {
  return gulp.src(paths.uploadFiles)
    .pipe(zip(pkg.name + '.zip'))
    .pipe(gulp.dest('./'))
    .pipe(notify('Zip File Created'));
});

/**
 *  OPEN
 *
 *  Open the theme editor page for your theme when you need to mass upgrade or
 *  deploy a theme.
 *
 *  Config.yml is passed in as the src for placeholder purposes only so the task
 *  will run.  Can be any file really.
 */

gulp.task('open', function () {
  gulp.src(paths.config, {read: false})
    .pipe(open('', { url : 'https://themes.shopify.com/services/internal/themes/' + pkg.name + '/edit' }));
});

/**
 *  WATCH
 *
 *  Watch Task
 */

gulp.task('watch', function () {
  gulp.watch(paths.srcScss, ['concat-css']);
  gulp.watch(paths.srcJs, ['concat-js']);
  gulp.watch(paths.config, ['config', 'browser-sync']);
  gulp.watch(paths.images, ['imagemin']);

  if (argv.themekit) {
    gulp.watch(paths.watch).on('change', browserSync.reload);
  }
});

/**
 *  Set default tasks depending on which upload tool we're using
 */

function defaultTasks() {
  if (argv.themekit) {
    return ['build', 'browser-sync', 'concurrent'];
  } else {
    return ['build', 'concurrent']
  }
}

gulp.task('default', defaultTasks());
gulp.task('build', ['concat-css', 'concat-js', 'imagemin', 'clean']);
gulp.task('deploy', ['build', 'replace']);
gulp.task('zip', ['build', 'compress', 'open']);
<commit_msg>Whitespace fixes in gulpfile<commit_after>var gulp        = require('gulp'),
    imagemin    = require('gulp-imagemin'),
    notify      = require('gulp-notify'),
    cssimport   = require('gulp-cssimport'),
    include     = require("gulp-include"),
    shell       = require('gulp-shell'),
    zip         = require('gulp-zip'),
    open        = require('gulp-open'),
    runSequence = require('run-sequence'),
    del         = require('del'),
    pkg         = require('./package.json')
    browserSync = require('browser-sync').create(),
    fs          = require('fs'),
    yaml        = require('js-yaml'),
    argv        = require('yargs').argv,
    gulpif      = require('gulp-if');

/**
 *
 *  All paths used by tasks
 *
 */
var paths = {
  srcScss: 'src/stylesheets/**/*.*',
  srcJs: 'src/javascripts/**/*.*',
  parentIncludeScss: [
    'src/stylesheets/[^_]*.*'
  ],
  parentIncludeJs: [
    'src/javascripts/*.*'
  ],
  images: 'src/images/*.{png,jpg,gif}',
  destAssets: 'assets',
  uploadFiles: [
    'config/*',
    'layout/*',
    'locales/*',
    'snippets/*',
    'templates/**/*'
  ],
  config: 'config.yml',
  watch: 'src/theme.update'
};

/**
 *   CONCAT CSS:
 *
 *   Concatenate css together into a single scss file for use in the theme
 */
gulp.task('concat-css', function () {
  gulp.src(paths.parentIncludeScss)
    .pipe(cssimport())
    .pipe(gulp.dest(paths.destAssets));
});

/**
 *   CONCAT JS:
 *
 *   Concatenate JS together into a single file for use in the theme
 */
gulp.task('concat-js', function () {
  gulp.src(paths.parentIncludeJs)
    .pipe(include())
      .on('error', console.log)
    .pipe(gulp.dest(paths.destAssets));
});

/**
 *    IMAGEMIN
 *
 *    Minify Images
 */
gulp.task('imagemin', function () {
  gulp.src(paths.images)
    .pipe(imagemin({
        optimizationLevel: 3
    }))
    .pipe(gulp.dest(paths.destAssets))
});

/**
 *  BROWSERSYNC
 */
gulp.task('browser-sync', function(options) {
  // read the shop url from the config file
  var config = yaml.safeLoad(fs.readFileSync(paths.config, 'utf8'));

  //remove this if theme gem used instead
  //of theme kit
  config = config.development;

  browserSync.init({
    proxy: config.store
  });
});

/**
 *  THEME WATCH
 *
 *  Run the theme gem watch to upload any changed files to your store
 */
gulp.task('theme-watch', function () {
  return gulp.src('')
    .pipe(gulpif(argv.themekit, shell('theme watch --notify=src/theme.update'), shell('theme watch')));
});

/**
 *  REPLACE
 *
 *  Replace your existing theme using the theme gem.  It's best
 *  to use `gulp build` before running this task so it also builds the
 *  CSS, and images first.
 */
gulp.task('replace', function () {
  gulp.src('')
    .pipe(shell('theme replace'));
});

/**
 *  UPLOAD
 *
 *  Upload your existing theme using the theme gem.  Unlike the `replace` task,
 *  the upload task doesn't remove any files from your store before uploading
 *  your theme. It's best to use `gulp build` before running this task so it also builds the
 *  CSS, and images first.
 */
gulp.task('upload', function () {
  gulp.src('')
    .pipe(shell('theme upload'));
});

/**
 *  CONCURRENT
 *
 *  Run both the gulp watch to build CSS, and images along side the theme gem watch
 *  to upload any changes to your store after being built
 */
gulp.task('concurrent', function (cb) {
  runSequence(['watch', 'theme-watch'], cb);
});

/**
 *  CLEAN
 *
 *  Clean up any stray files that might be created by other gulp tasks
 */
gulp.task('clean', function (cb) {
  del([
    '*.zip',
    'assets/**/*',
    '!assets/*.*'
  ], cb)
});

/**
 *  ZIP
 *
 *  compress theme and prepare it for the theme store
 */
gulp.task('compress', function () {
  return gulp.src(paths.uploadFiles)
    .pipe(zip(pkg.name + '.zip'))
    .pipe(gulp.dest('./'))
    .pipe(notify('Zip File Created'));
});

/**
 *  OPEN
 *
 *  Open the theme editor page for your theme when you need to mass upgrade or
 *  deploy a theme.
 *
 *  config.yml is passed in as the src for placeholder purposes only so the task
 *  will run.  Can be any file really.
 */
gulp.task('open', function () {
  gulp.src(paths.config, {read: false})
    .pipe(open('', { url : 'https://themes.shopify.com/services/internal/themes/' + pkg.name + '/edit' }));
});

/**
 *  WATCH
 */
gulp.task('watch', function () {
  gulp.watch(paths.srcScss, ['concat-css']);
  gulp.watch(paths.srcJs, ['concat-js']);
  gulp.watch(paths.config, ['config', 'browser-sync']);
  gulp.watch(paths.images, ['imagemin']);

  if (argv.themekit) {
    gulp.watch(paths.watch).on('change', browserSync.reload);
  }
});

/**
 *  Set default tasks depending on which upload tool we're using
 */
function defaultTasks() {
  if (argv.themekit) {
    return ['build', 'browser-sync', 'concurrent'];
  } else {
    return ['build', 'concurrent']
  }
}

gulp.task('default', defaultTasks());
gulp.task('build', ['concat-css', 'concat-js', 'imagemin', 'clean']);
gulp.task('deploy', ['build', 'replace']);
gulp.task('zip', ['build', 'compress', 'open']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var concat = require('gulp-concat');
var git = require('gulp-git');
var del = require('del');

gulp.task('build-wrappers', function() {
  del(['temp']).then(paths => {
    git.clone('https://github.com/crossrails/javascriptcore.swift.git', {args: 'temp'}, (err) => {
      if (err) {
        throw err;
      }
      gulp.src('temp/Source/*.swift')
        .pipe(concat('javascriptcore.swift'))
        .pipe(gulp.dest('src/swift/'));
    })
  });
});
<commit_msg>Adjusted gulpfile to delete temp folder<commit_after>var gulp = require('gulp');
var concat = require('gulp-concat');
var git = require('gulp-git');
var del = require('del');

gulp.task('build-wrappers', function() {
  del(['temp']).then(paths => {
    git.clone('https://github.com/crossrails/javascriptcore.swift.git', {args: 'temp'}, (err) => {
      if (err) {
        throw err;
      } else {
          gulp.src('temp/Source/*.swift')
          .pipe(concat('javascriptcore.swift'))
          .pipe(gulp.dest('src/swift/'))
          .on('end', function() {
            del(['temp']);
          })
      }
    })
  });
});

<|endoftext|>


<commit_before>var gulp = require('gulp');
var browserify = require('browserify');
var del = require('del');
var es = require('event-stream');
var fs = require('fs');
var ghPages = require('gulp-gh-pages');
var gutil = require('gulp-util');
var inject = require('gulp-inject');
var markdown = require('gulp-markdown');
var path = require('path');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var source = require('vinyl-source-stream');
var through = require('through2');

gulp.task('assets', copyAssets);
gulp.task('sass', compileScss);
gulp.task('scripts', compileScripts);
gulp.task('build:core', ['assets', 'sass', 'scripts']);
gulp.task('build:examples', ['build:core'], buildIndexFile);
gulp.task('build', ['build:core', 'build:examples']);
gulp.task('clean', cleanOutDir);
gulp.task('deploy', ['build:examples'], deployGhPages);
gulp.task('default', ['build:examples']);

var outDir = 'out';

function copyAssets() {
  return gulp.src(['src/examples/**/*', '!src/examples/index.html', '!src/examples/**/*.scss', '!src/examples/**/*.js'])
    .pipe(gulp.dest(outDir));
}

function compileScss() {
  return gulp.src('src/examples/**/*.scss')
    .pipe(sass())
    .pipe(gulp.dest(outDir));
}

function compileScripts(cb) {
  var scriptStreams = [];
  var basePath = path.resolve('src/examples');

  gulp.src('src/examples/**/main.js')
    .pipe(through.obj(function (file, enc, callback) {
      var relativePath = path.dirname(file.path).substring(basePath.length);

      var stream = browserify(file.path)
        .transform('babelify')
        .bundle()
        .on('error', gutil.log)
        .pipe(source('main.js'))
        .pipe(gulp.dest(outDir + '/' + relativePath))

      scriptStreams.push(stream);

      callback();
    }))
    .on('data', gutil.log)
    .on('end', function () {
      es.merge.apply(null, scriptStreams)
        .on('end', cb);
    });
}

function buildIndexFile(cb) {
  return gulp.src('src/index.html')
    // Examples
    .pipe(inject(gulp.src('src/examples/**/index.html').pipe(markdown()), {
      starttag : '',
      transform : function (filePath, file) {
        // return file contents as string
        return '
' + file.relative + '
\n';
      }
    }))
    // Documentation
    .pipe(inject(gulp.src('README.md').pipe(markdown()), {
      starttag : '',
      transform : function (filePath, file) {
        // return file contents as string
        return file.contents.toString('utf8');
      }
    }))
    .pipe(gulp.dest(outDir));
}

function deployGhPages() {
  return gulp.src(outDir + '/**')
    .pipe(ghPages());
}

function cleanOutDir(cb) {
  del([outDir, '.publish'], cb);
}<commit_msg>Use nicer path for examples<commit_after>var gulp = require('gulp');
var browserify = require('browserify');
var del = require('del');
var es = require('event-stream');
var fs = require('fs');
var ghPages = require('gulp-gh-pages');
var gutil = require('gulp-util');
var inject = require('gulp-inject');
var markdown = require('gulp-markdown');
var path = require('path');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var source = require('vinyl-source-stream');
var through = require('through2');

gulp.task('assets', copyAssets);
gulp.task('sass', compileScss);
gulp.task('scripts', compileScripts);
gulp.task('build:core', ['assets', 'sass', 'scripts']);
gulp.task('build:examples', ['build:core'], buildIndexFile);
gulp.task('build', ['build:core', 'build:examples']);
gulp.task('clean', cleanOutDir);
gulp.task('deploy', ['build:examples'], deployGhPages);
gulp.task('default', ['build:examples']);

var outDir = 'out';

function copyAssets() {
  return gulp.src(['src/examples/**/*', '!src/examples/index.html', '!src/examples/**/*.scss', '!src/examples/**/*.js'])
    .pipe(gulp.dest(outDir));
}

function compileScss() {
  return gulp.src('src/examples/**/*.scss')
    .pipe(sass())
    .pipe(gulp.dest(outDir));
}

function compileScripts(cb) {
  var scriptStreams = [];
  var basePath = path.resolve('src/examples');

  gulp.src('src/examples/**/main.js')
    .pipe(through.obj(function (file, enc, callback) {
      var relativePath = path.dirname(file.path).substring(basePath.length);

      var stream = browserify(file.path)
        .transform('babelify')
        .bundle()
        .on('error', gutil.log)
        .pipe(source('main.js'))
        .pipe(gulp.dest(outDir + '/' + relativePath))

      scriptStreams.push(stream);

      callback();
    }))
    .on('data', gutil.log)
    .on('end', function () {
      es.merge.apply(null, scriptStreams)
        .on('end', cb);
    });
}

function buildIndexFile(cb) {
  return gulp.src('src/index.html')
    // Examples
    .pipe(inject(gulp.src('src/examples/**/index.html').pipe(markdown()), {
      starttag : '',
      transform : function (filePath, file) {
        // return file contents as string
        console.log(nameFromPath(file.relative));
        return '
' + nameFromPath(file.relative) + '
';
      }
    }))
    // Documentation
    .pipe(inject(gulp.src('README.md').pipe(markdown()), {
      starttag : '',
      transform : function (filePath, file) {
        // return file contents as string
        return file.contents.toString('utf8');
      }
    }))
    .pipe(gulp.dest(outDir));

  function nameFromPath(relativePath) {
    return relativePath.substring(0, relativePath.indexOf('/'));
  }
}

function deployGhPages() {
  return gulp.src(outDir + '/**')
    .pipe(ghPages());
}

function cleanOutDir(cb) {
  del([outDir, '.publish'], cb);
}<|endoftext|>


<commit_before>'use strict';
// generated on 2014-05-09 using generator-gulp-webapp 0.1.0

var gulp = require('gulp');
var mocha = require('gulp-mocha');
var gutil = require('gulp-util');

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

gulp.task('styles', function () {
    return gulp.src('app/styles/main.scss')
        .pipe($.rubySass({
            style: 'expanded',
            precision: 10
        }))
        .pipe($.autoprefixer('last 1 version'))
        .pipe(gulp.dest('.tmp/styles'))
        .pipe($.size());
});

gulp.task('scripts', function () {
    return gulp.src('app/scripts/**/*.js')
        .pipe($.jshint())
        .pipe($.jshint.reporter(require('jshint-stylish')))
        .pipe($.size());
});

gulp.task('html', ['styles', 'scripts'], function () {
    var jsFilter = $.filter('**/*.js');
    var cssFilter = $.filter('**/*.css');

    return gulp.src('app/*.html')
        .pipe($.useref.assets({searchPath: '{.tmp,app}'}))
        .pipe(jsFilter)
        .pipe($.uglify())
        .pipe(jsFilter.restore())
        .pipe(cssFilter)
        .pipe($.csso())
        .pipe(cssFilter.restore())
        .pipe($.useref.restore())
        .pipe($.useref())
        .pipe(gulp.dest('dist'))
        .pipe($.size());
});

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

gulp.task('fonts', function () {
    return $.bowerFiles()
        .pipe($.filter('**/*.{eot,svg,ttf,woff}'))
        .pipe($.flatten())
        .pipe(gulp.dest('dist/fonts'))
        .pipe($.size());
});

gulp.task('extras', function () {
    return gulp.src(['app/*.*', '!app/*.html'], { dot: true })
        .pipe(gulp.dest('dist'));
});

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

gulp.task('build', ['html', 'images', 'fonts', 'extras']);

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

gulp.task('connect', function () {
    var connect = require('connect');
    var app = connect()
        .use(require('connect-livereload')({ port: 35729 }))
        .use(connect.static('app'))
        .use(connect.static('.tmp'))
        .use(connect.directory('app'));

    require('http').createServer(app)
        .listen(9000)
        .on('listening', function () {
            console.log('Started connect web server on http://localhost:9000');
        })
        .on('error', gutil.log);
});

gulp.task('serve', ['connect', 'styles'], function () {
    //require('opn')('http://localhost:9000');
});

// inject bower components
gulp.task('wiredep', function () {
    var wiredep = require('wiredep').stream;

    gulp.src('app/styles/*.scss')
        .pipe(wiredep({
            directory: 'app/bower_components'
        }))
        .pipe(gulp.dest('app/styles'));

    gulp.src('app/*.html')
        .pipe(wiredep({
            directory: 'app/bower_components',
            exclude: ['bootstrap-sass-official']
        }))
        .pipe(gulp.dest('app'));
});

gulp.task('mocha', function() {
    return gulp.src(['test/spec/*.js'], { read: false })
    .pipe(mocha({
        reporter: 'spec'
    }))
    .on('error', gutil.log);
});

gulp.task('watch-mocha', function() {
    gulp.watch(['app/scripts/**', 'lib/**', 'test/spec/**'], ['mocha']);
});

gulp.task('watch', ['connect', 'serve'], function () {
    var server = $.livereload();

    // watch for changes

    gulp.watch([
        'app/*.html',
        '.tmp/styles/**/*.css',
        'app/scripts/**/*.js',
        'app/images/**/*'
    ]).on('change', function (file) {
        server.changed(file.path);
    });

    gulp.watch('app/styles/**/*.scss', ['styles']);
    gulp.watch('app/scripts/**/*.js', ['scripts']);
    gulp.watch('app/images/**/*', ['images']);
    gulp.watch('bower.json', ['wiredep']);
});
<commit_msg>fixed tabbing<commit_after>'use strict';

var gulp  = require('gulp');
var mocha = require('gulp-mocha');
var gutil = require('gulp-util');

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

gulp.task('styles', function () {
    return gulp.src('app/styles/main.scss')
    .pipe($.rubySass({
        style: 'expanded',
        precision: 10
    }))
    .pipe($.autoprefixer('last 1 version'))
    .pipe(gulp.dest('.tmp/styles'))
    .pipe($.size());
});

gulp.task('scripts', function () {
    return gulp.src('app/scripts/**/*.js')
    .pipe($.jshint())
    .pipe($.jshint.reporter(require('jshint-stylish')))
    .pipe($.size());
});

gulp.task('html', ['styles', 'scripts'], function () {
    var jsFilter = $.filter('**/*.js');
    var cssFilter = $.filter('**/*.css');

    return gulp.src('app/*.html')
    .pipe($.useref.assets({searchPath: '{.tmp,app}'}))
    .pipe(jsFilter)
    .pipe($.uglify())
    .pipe(jsFilter.restore())
    .pipe(cssFilter)
    .pipe($.csso())
    .pipe(cssFilter.restore())
    .pipe($.useref.restore())
    .pipe($.useref())
    .pipe(gulp.dest('dist'))
    .pipe($.size());
});

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

gulp.task('fonts', function () {
    return $.bowerFiles()
    .pipe($.filter('**/*.{eot,svg,ttf,woff}'))
    .pipe($.flatten())
    .pipe(gulp.dest('dist/fonts'))
    .pipe($.size());
});

gulp.task('extras', function () {
    return gulp.src(['app/*.*', '!app/*.html'], { dot: true })
    .pipe(gulp.dest('dist'));
});

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

gulp.task('build', ['html', 'images', 'fonts', 'extras']);

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

gulp.task('connect', function () {
    var connect = require('connect');
    var app = connect()
    .use(require('connect-livereload')({ port: 35729 }))
    .use(connect.static('app'))
    .use(connect.static('.tmp'))
    .use(connect.directory('app'));

    require('http').createServer(app)
    .listen(9000)
    .on('listening', function () {
        console.log('Started connect web server on http://localhost:9000');
    })
    .on('error', gutil.log);
});

gulp.task('serve', ['connect', 'styles'], function () {
    //require('opn')('http://localhost:9000');
});

// inject bower components
gulp.task('wiredep', function () {
    var wiredep = require('wiredep').stream;

    gulp.src('app/styles/*.scss')
    .pipe(wiredep({
        directory: 'app/bower_components'
    }))
    .pipe(gulp.dest('app/styles'));

    gulp.src('app/*.html')
    .pipe(wiredep({
        directory: 'app/bower_components',
        exclude: ['bootstrap-sass-official']
    }))
    .pipe(gulp.dest('app'));
});

gulp.task('mocha', function() {
    return gulp.src(['test/spec/*.js'], { read: false })
    .pipe(mocha({
        reporter: 'spec'
    }))
    .on('error', gutil.log);
});

gulp.task('watch-mocha', function() {
    gulp.watch(['app/scripts/**', 'lib/**', 'test/spec/**'], ['mocha']);
});

gulp.task('watch', ['connect', 'serve'], function () {
    var server = $.livereload();

    // watch for changes

    gulp.watch([
        'app/*.html',
        '.tmp/styles/**/*.css',
        'app/scripts/**/*.js',
        'app/images/**/*'
    ]).on('change', function (file) {
        server.changed(file.path);
    });

    gulp.watch('app/styles/**/*.scss', ['styles']);
    gulp.watch('app/scripts/**/*.js', ['scripts']);
    gulp.watch('app/images/**/*', ['images']);
    gulp.watch('bower.json', ['wiredep']);
});
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp'),
    ts = require('gulp-typescript'),
    clean = require('gulp-clean'),
	processhtml = require('gulp-processhtml'),
	uglify = require('gulp-uglify'),
	fs = require('fs'),
	replace = require('gulp-replace');

var releaseFolder = "release";
var packageJson = JSON.parse(fs.readFileSync('./package.json'));

gulp.task('clean', function (callback) {
	return gulp.src(releaseFolder, {read: false})
		.pipe(clean());

	callback();
});

/**
 * Compile TypeScript and include references to library and app .d.ts files.
 */
gulp.task('compile-ts', ['clean'], function (callback) {
	var tsProject = ts.createProject('tsconfig.json', {outFile: "app.js"});
    var tsResult = tsProject.src().pipe(ts(tsProject));

    return tsResult.js.pipe(gulp.dest("./"));

	callback();
});

gulp.task('copy-release', ['clean'], function () {
	gulp.src([
		'./templates/**/*.html',
		'./lib/**/*.js',
		'./assets/**/*.*',
		'./css/**/*.css'
	], {base: './'})
  		.pipe(gulp.dest(releaseFolder));
});

gulp.task('process-html', ['clean'], function () {
	return gulp.src("index.html")
		   .pipe(processhtml())
		   .pipe(gulp.dest(releaseFolder));
});

gulp.task('uglify', ['compile-ts'], function () {
	return gulp.src("app.js")
		   .pipe(uglify())
		   .pipe(gulp.dest(releaseFolder));
});

gulp.task('replace', ['uglify','process-html'], function () {
	return gulp.src([releaseFolder + '/index.html',releaseFolder + '/app.js'])
		   .pipe(replace( "__applicationVersionNumber__", packageJson.version ))
		   .pipe(gulp.dest(releaseFolder));
});

gulp.task('default', ['clean','compile-ts','copy-release','process-html','uglify','replace']);
<commit_msg>include templates in replace<commit_after>'use strict';

var gulp = require('gulp'),
    ts = require('gulp-typescript'),
    clean = require('gulp-clean'),
	processhtml = require('gulp-processhtml'),
	uglify = require('gulp-uglify'),
	fs = require('fs'),
	replace = require('gulp-replace');

var releaseFolder = "release";
var packageJson = JSON.parse(fs.readFileSync('./package.json'));

gulp.task('clean', function (callback) {
	return gulp.src(releaseFolder, {read: false})
		.pipe(clean());

	callback();
});

/**
 * Compile TypeScript and include references to library and app .d.ts files.
 */
gulp.task('compile-ts', ['clean'], function (callback) {
	var tsProject = ts.createProject('tsconfig.json', {outFile: "app.js"});
    var tsResult = tsProject.src().pipe(ts(tsProject));

    return tsResult.js.pipe(gulp.dest("./"));

	callback();
});

gulp.task('copy-release', ['clean'], function (callback) {
	gulp.src([
		'./templates/**/*.html',
		'./lib/**/*.js',
		'./assets/**/*.*',
		'./css/**/*.css'
	], {base: './'})
  		.pipe(gulp.dest(releaseFolder));

		callback();
});

gulp.task('process-html', ['clean'], function (callback) {
	return gulp.src("index.html")
		   .pipe(processhtml())
		   .pipe(gulp.dest(releaseFolder));

	   	callback();
});

gulp.task('uglify', ['compile-ts'], function (callback) {
	return gulp.src("app.js")
		   .pipe(uglify())
		   .pipe(gulp.dest(releaseFolder));

	   	callback();
});

gulp.task('replace', ['uglify','process-html','copy-release'], function () {
	return gulp.src([releaseFolder + '/**/*.html',releaseFolder + '/app.js'])
		   .pipe(replace( "__applicationVersionNumber__", packageJson.version ))
		   .pipe(gulp.dest(releaseFolder));
});

gulp.task('default', ['clean','compile-ts','copy-release','process-html','uglify','replace']);
<|endoftext|>


<commit_before>var path = require('path');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
var coveralls = require('gulp-coveralls');
var babel = require('gulp-babel');
var del = require('del');
var isparta = require('isparta');

// Initialize the babel transpiler so ES2015 files gets compiled
// when they're loaded
require('babel-core/register');

gulp.task('static', function () {
  return gulp.src('**/*.js')
    .pipe(excludeGitignore())
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task('nsp', function (cb) {
  nsp({package: path.resolve('package.json')}, cb);
});

gulp.task('pre-test', function () {
  return gulp.src('lib/**/*.js')
    .pipe(istanbul({
      includeUntested: true,
      instrumenter: isparta.Instrumenter
    }))
    .pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-test'], function (cb) {
  var mochaErr;

  gulp.src('test/**/*.js')
    .pipe(plumber())
    .pipe(mocha({reporter: 'spec'}))
    .on('error', function (err) {
      mochaErr = err;
    })
    .pipe(istanbul.writeReports())
    .on('end', function () {
      cb(mochaErr);
    });
});

gulp.task('coveralls', ['test'], function () {
  if (!process.env.CI) {
    return;
  }

  return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
    .pipe(coveralls());
});

gulp.task('babel', ['clean'], function () {
  return gulp.src('lib/**/*.js')
    .pipe(babel())
    .pipe(gulp.dest('dist'));
});

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

gulp.task('prepublish', ['nsp', 'babel']);
gulp.task('default', ['static', 'test', 'coveralls']);
<commit_msg>temporary remove nsp from publish.<commit_after>var path = require('path');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
var coveralls = require('gulp-coveralls');
var babel = require('gulp-babel');
var del = require('del');
var isparta = require('isparta');

// Initialize the babel transpiler so ES2015 files gets compiled
// when they're loaded
require('babel-core/register');

gulp.task('static', function () {
  return gulp.src('**/*.js')
    .pipe(excludeGitignore())
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task('nsp', function (cb) {
  nsp({package: path.resolve('package.json')}, cb);
});

gulp.task('pre-test', function () {
  return gulp.src('lib/**/*.js')
    .pipe(istanbul({
      includeUntested: true,
      instrumenter: isparta.Instrumenter
    }))
    .pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-test'], function (cb) {
  var mochaErr;

  gulp.src('test/**/*.js')
    .pipe(plumber())
    .pipe(mocha({reporter: 'spec'}))
    .on('error', function (err) {
      mochaErr = err;
    })
    .pipe(istanbul.writeReports())
    .on('end', function () {
      cb(mochaErr);
    });
});

gulp.task('coveralls', ['test'], function () {
  if (!process.env.CI) {
    return;
  }

  return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
    .pipe(coveralls());
});

gulp.task('babel', ['clean'], function () {
  return gulp.src('lib/**/*.js')
    .pipe(babel())
    .pipe(gulp.dest('dist'));
});

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

gulp.task('prepublish', ['babel']);
gulp.task('default', ['static', 'test', 'coveralls']);
<|endoftext|>


<commit_before>'use strict';
var path = require('path');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
var coveralls = require('gulp-coveralls');

gulp.task('static', function () {
  return gulp.src('**/*.js')
    .pipe(excludeGitignore())
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task('nsp', function (cb) {
  nsp({package: path.resolve('package.json')}, cb);
});

gulp.task('pre-test', function () {
  return gulp.src('generators/**/*.js')
    .pipe(excludeGitignore())
    .pipe(istanbul({
      includeUntested: true
    }))
    .pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-test'], function (cb) {
  var mochaErr;

  gulp.src('test/**/*.js')
    .pipe(plumber())
    .pipe(mocha({reporter: 'spec'}))
    .on('error', function (err) {
      mochaErr = err;
    })
    .pipe(istanbul.writeReports())
    .on('end', function () {
      cb(mochaErr);
    });
});

gulp.task('watch', function () {
  gulp.watch(['generators/**/*.js', 'test/**'], ['test']);
});

gulp.task('coveralls', ['test'], function () {
  if (!process.env.CI) {
    return;
  }

  return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
    .pipe(coveralls());
});

gulp.task('prepublish', ['nsp']);
gulp.task('default', ['static', 'test', 'coveralls']);
<commit_msg>Skipping "coveralls"<commit_after>'use strict';
var path = require('path');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var excludeGitignore = require('gulp-exclude-gitignore');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var nsp = require('gulp-nsp');
var plumber = require('gulp-plumber');
var coveralls = require('gulp-coveralls');

gulp.task('static', function () {
  return gulp.src('**/*.js')
    .pipe(excludeGitignore())
    .pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task('nsp', function (cb) {
  nsp({package: path.resolve('package.json')}, cb);
});

gulp.task('pre-test', function () {
  return gulp.src('generators/**/*.js')
    .pipe(excludeGitignore())
    .pipe(istanbul({
      includeUntested: true
    }))
    .pipe(istanbul.hookRequire());
});

gulp.task('test', ['pre-test'], function (cb) {
  var mochaErr;

  gulp.src('test/**/*.js')
    .pipe(plumber())
    .pipe(mocha({reporter: 'spec'}))
    .on('error', function (err) {
      mochaErr = err;
    })
    .pipe(istanbul.writeReports())
    .on('end', function () {
      cb(mochaErr);
    });
});

gulp.task('watch', function () {
  gulp.watch(['generators/**/*.js', 'test/**'], ['test']);
});

gulp.task('coveralls', ['test'], function () {
  if (!process.env.CI) {
    return;
  }

  return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
    .pipe(coveralls());
});

gulp.task('prepublish', ['nsp']);
gulp.task('default', ['static', 'test']);
<|endoftext|>


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

console.time('Loading plugins');

var gulp = require('gulp');

gulp.task('lint', function() {
	var jshint = require('gulp-jshint');

	return gulp.src(['api/**/*.js', 'public/js/**/*.js', '*.js'])
		.pipe(jshint())
		.pipe(jshint.reporter('jshint-stylish'));
});

gulp.task('stylus', function() {
	var stylus 	= require('gulp-stylus'),
			nib		  = require('nib');

	return gulp.src('public/styles/stylus/main.styl')
		.pipe(stylus({use: [nib()]}))
		.pipe(gulp.dest('./public/styles'));
});

gulp.task('css-min', function() {
	var stylus 		= require('gulp-stylus'),
			nib			  = require('nib'),
			minifycss  = require('gulp-minify-css');

	return gulp.src('public/styles/stylus/main.styl')
		.pipe(stylus({use: [nib()]}))
		.pipe(minifycss())
		.pipe(gulp.dest('./public/styles'));
});

gulp.task('default', ['lint', 'stylus']);

console.timeEnd('Loading plugins');<commit_msg>Configuring sass<commit_after>/*jshint node: true */
"use strict";

console.time('Loading plugins');

var gulp = require('gulp');

gulp.task('lint', function() {
	var jshint = require('gulp-jshint');

	return gulp.src(['api/**/*.js', 'public/js/**/*.js', '*.js'])
		.pipe(jshint())
		.pipe(jshint.reporter('jshint-stylish'));
});

gulp.task('sass', function() {
	var sass 	= require('gulp-sass');

	return gulp.src('app/styles/sass/main.scss')
		.pipe(sass())
		.pipe(gulp.dest('./app/styles'));
});

gulp.task('css-min', function() {
	var sass 		= require('gulp-sass'),
			minifycss  = require('gulp-minify-css');

	return gulp.src('app/styles/sass/main.styl')
		.pipe(sass())
		.pipe(minifycss())
		.pipe(gulp.dest('./app/styles'));
});

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

console.timeEnd('Loading plugins');<|endoftext|>


<commit_before>var gulp = require('gulp');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var fs = require('fs');
var git = require('gulp-git');
var shell = require('gulp-shell');
var uglify = require('gulp-uglify');
var bump = require('gulp-bump');

gulp.task('default', function() {
  // watch for JS changes and run tests
  gulp.watch('./src/lib/*.js', function() {
  	gulp.run('build');
    gulp.run('test');
  });
});

/*
 * Testing related tasks
 */

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

// run the mocha tests
gulp.task('mocha', function () {
    return gulp.src('./test/integration/index.js', {read: false})
        .pipe(mocha());
});

// run the mocha tests
gulp.task('cov', function () {
    return gulp.src('./test/integration/cov.js', {read: false})
        .pipe(mocha({reporter: 'html-cov'}))
        .pipe(gulp.dest('./dist/'));

});

// run the tests
gulp.task('test', ['lint', 'mocha'], function () {
    return;
});

/*
 * Distribution related tasks
 */

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

// Basic usage
gulp.task('build', function() {
    // Single entry point to browserify
    gulp.src('src/getstream.js')
        .pipe(browserify({
          insertGlobals : false,
          debug : false,
          standalone : 'stream'
        }))
        .pipe(uglify())
        .pipe(gulp.dest('./dist/js'));
});

gulp.task('bump', function () {
  return gulp.src(['./package.json'])
    .pipe(bump())
    .pipe(gulp.dest('./'));
});

// release to bower
gulp.task('release', function () {
	// read version from package.json
	// update bower to match package.json
    // git tag and push
    // npm publish .
    //TODO: use something gulp instead of make, gulp-git seems broken
    // TODO: why does bower read from master?
	var packageJSON = require('./package.json');
	var bowerJSON = require('./bower.json');
	var version = packageJSON.version;
	var message = 'Released version ' + versionName;
	var versionName = 'v' + version;

	console.log('Releasing version ' + versionName);
	console.log(process.cwd());
	// write the new bower.json file
	console.log('Updating bower.json');
	bowerJSON.version = version;
	fs.writeFileSync('bower.json', JSON.stringify(bowerJSON, null, '  '));
	// push to github (which also impacts bower)
	console.log('Git tagging and releasing');
	return gulp.src('./')
	    .pipe(git.commit(message))
	    .pipe(git.tag(versionName, message))
	    .pipe(git.push('origin', 'master', '--tags'))
	    .pipe(gulp.dest('./'));
	//.pipe(shell.task(['npm publish .']));

});

// full publish flow
gulp.task('publish', ['build', 'test', 'release'], function () {
    return;
});<commit_msg>Released version undefined<commit_after>var gulp = require('gulp');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var fs = require('fs');
var git = require('gulp-git');
var shell = require('gulp-shell');
var uglify = require('gulp-uglify');
var bump = require('gulp-bump');

gulp.task('default', function() {
  // watch for JS changes and run tests
  gulp.watch('./src/lib/*.js', function() {
  	gulp.run('build');
    gulp.run('test');
  });
});

/*
 * Testing related tasks
 */

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

// run the mocha tests
gulp.task('mocha', function () {
    return gulp.src('./test/integration/index.js', {read: false})
        .pipe(mocha());
});

// run the mocha tests
gulp.task('cov', function () {
    return gulp.src('./test/integration/cov.js', {read: false})
        .pipe(mocha({reporter: 'html-cov'}))
        .pipe(gulp.dest('./dist/'));

});

// run the tests
gulp.task('test', ['lint', 'mocha'], function () {
    return;
});

/*
 * Distribution related tasks
 */

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

// Basic usage
gulp.task('build', function() {
    // Single entry point to browserify
    gulp.src('src/getstream.js')
        .pipe(browserify({
          insertGlobals : false,
          debug : false,
          standalone : 'stream'
        }))
        .pipe(uglify())
        .pipe(gulp.dest('./dist/js'));
});

gulp.task('bump', function () {
  return gulp.src(['./package.json'])
    .pipe(bump())
    .pipe(gulp.dest('./'));
});

// release to bower
gulp.task('release', function () {
	// read version from package.json
	// update bower to match package.json
    // git tag and push
    // npm publish .
    //TODO: use something gulp instead of make, gulp-git seems broken
    // TODO: why does bower read from master?
	var packageJSON = require('./package.json');
	var bowerJSON = require('./bower.json');
	var version = packageJSON.version;
	var message = 'Released version ' + versionName;
	var versionName = 'v' + version;

	console.log('Releasing version ' + versionName);
	console.log(process.cwd());
	// write the new bower.json file
	console.log('Updating bower.json');
	bowerJSON.version = version;
	fs.writeFileSync('bower.json', JSON.stringify(bowerJSON, null, '  '));
	// push to github (which also impacts bower)
	console.log('Git tagging and releasing');
	return gulp.src('./', {read: false})
	    .pipe(git.commit(message))
	    .pipe(git.tag(versionName, message))
	    .pipe(git.push('origin', 'master', '--tags'))
	    .pipe(gulp.dest('./'));
	//.pipe(shell.task(['npm publish .']));

});

// full publish flow
gulp.task('publish', ['build', 'test', 'release'], function () {
    return;
});<|endoftext|>


<commit_before>const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const cleanCSS = require('gulp-clean-css');
const imagemin = require('gulp-imagemin');
const fileInclude = require('gulp-file-include');
const concat = require('gulp-concat');
const babel = require('gulp-babel');

// **UIKit Only** scripts to concatenate and minify.
const UIKitScripts = [
    'src/uikit/js/uikit.js',
    'src/uikit/js/components/slideshow.js'
    ];

// **Created Only** scripts to concatenate and minify.
const scripts = [
    'src/js/main.js'
    ];

gulp.task('sass', () => {
    return gulp.src('src/sass/main.scss')
        .pipe(sass())
        .pipe(autoprefixer({
            browsers: ['last 3 versions']
        }))
        .pipe(cleanCSS())
        .pipe(concat('main.min.css'))
        .pipe(gulp.dest('build/css'));
});

gulp.task('uk-scripts', () => {
    return gulp.src(UIKitScripts)
        .pipe(concat('uikit.min.js'))
        .pipe(gulp.dest('build/js'))
        .pipe(uglify())
        .pipe(gulp.dest('build/js'));
});

gulp.task('scripts', () => {
    return gulp.src(scripts)
        .pipe(concat('main.min.js'))
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(gulp.dest('build/js'))
        .pipe(uglify())
        .pipe(gulp.dest('build/js'));
});

gulp.task('html', () => {
    return gulp.src(['src/index.html'])
        .pipe(fileInclude({
            prefix: '@@',
            basepath: '@file'
        }))
        .pipe(gulp.dest('build'));
});

gulp.task('img', () => {
    return gulp.src('src/img/*')
        .pipe(imagemin())
        .pipe(gulp.dest('build/img'));
});

gulp.task('default', ['sass', 'uk-scripts', 'scripts', 'html', 'img'], () => {
    gulp.watch('src/sass/*.scss', ['sass']);
    gulp.watch('src/js/*.js', ['scripts']);
    gulp.watch(['src/index.html', 'src/partials/*.html'], ['html']);
});
<commit_msg>Add events.js to scripts array to compile<commit_after>const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const cleanCSS = require('gulp-clean-css');
const imagemin = require('gulp-imagemin');
const fileInclude = require('gulp-file-include');
const concat = require('gulp-concat');
const babel = require('gulp-babel');

// **UIKit Only** scripts to concatenate and minify.
const UIKitScripts = [
    'src/uikit/js/uikit.js',
    'src/uikit/js/components/slideshow.js'
    ];

// **Created Only** scripts to concatenate and minify.
const scripts = [
    'src/js/events.js'
    ];

gulp.task('sass', () => {
    return gulp.src('src/sass/main.scss')
        .pipe(sass())
        .pipe(autoprefixer({
            browsers: ['last 3 versions']
        }))
        .pipe(cleanCSS())
        .pipe(concat('main.min.css'))
        .pipe(gulp.dest('build/css'));
});

gulp.task('uk-scripts', () => {
    return gulp.src(UIKitScripts)
        .pipe(concat('uikit.min.js'))
        .pipe(gulp.dest('build/js'))
        .pipe(uglify())
        .pipe(gulp.dest('build/js'));
});

gulp.task('scripts', () => {
    return gulp.src(scripts)
        .pipe(concat('main.min.js'))
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(gulp.dest('build/js'))
        .pipe(uglify())
        .pipe(gulp.dest('build/js'));
});

gulp.task('html', () => {
    return gulp.src(['src/index.html'])
        .pipe(fileInclude({
            prefix: '@@',
            basepath: '@file'
        }))
        .pipe(gulp.dest('build'));
});

gulp.task('img', () => {
    return gulp.src('src/img/*')
        .pipe(imagemin())
        .pipe(gulp.dest('build/img'));
});

gulp.task('default', ['sass', 'uk-scripts', 'scripts', 'html', 'img'], () => {
    gulp.watch('src/sass/*.scss', ['sass']);
    gulp.watch('src/js/*.js', ['scripts']);
    gulp.watch(['src/index.html', 'src/partials/*.html'], ['html']);
});
<|endoftext|>


<commit_before>'use strict';
/* eslint-disable no-console, no-invalid-this */

var gulp = require('gulp');
var browserify = require('browserify');
var uglify = require('gulp-uglify');
var through2 = require('through2');
var eslint = require('gulp-eslint');
var tape = require('gulp-tape');
var tapSpec = require('tap-spec');
var bundleStyles = require('substance/util/bundleStyles');
var examples = require('./examples/config').examples;
var fs = require('fs');
var path = require('path');
var gulpFile = require('gulp-file');

gulp.task('assets', function () {
  examples.forEach(function(exampleFolder) {
    gulp.src('./examples/'+exampleFolder+'/index.html')
          .pipe(gulp.dest('dist/'+exampleFolder));
  });
  gulp.src('examples/data/*')
    .pipe(gulp.dest('./dist/data'));
  gulp.src('node_modules/font-awesome/fonts/*')
    .pipe(gulp.dest('./dist/fonts'));
});

gulp.task('sass', function(done) {
  Promise.all(examples.map(function(exampleFolder) {
    return bundleStyles({
      rootDir: __dirname,
      configuratorPath: require.resolve('./packages/common/BaseConfigurator'),
      configPath: require.resolve('./examples/'+exampleFolder+'/package')
    }).then(function(css) {
      var distPath = path.join(__dirname, 'dist', exampleFolder);
      gulpFile('app.css', css, { src: true })
        .pipe(gulp.dest(distPath));
    }).catch(function(err) {
      console.error(err);
    });
  })).then(function() {
    done();
  });
});

gulp.task('browserify', function() {
  examples.forEach(function(exampleFolder) {
    gulp.src('./examples/'+exampleFolder+'/app.js')
      .pipe(through2.obj(function (file, enc, next) {
        browserify(file.path)
          .bundle(function (err, res) {
            if (err) { return next(err); }
            file.contents = res;
            next(null, file);
          });
      }))
      .on('error', function (error) {
        console.log(error.stack);
        this.emit('end');
      })
      .pipe(uglify().on('error', function(err){console.log(err); }))
      .pipe(gulp.dest('./dist/'+exampleFolder));
  });
});

gulp.task('lint', function() {
  return gulp.src([
    './examples/**/*.js',
    './packages/**/*.js',
    './test/**/*.js',
  ]).pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task('test:server', ['lint'], function() {
  return gulp.src([
    'test/jats/*.test.js'
  ])
  .pipe(tape({
    reporter: tapSpec()
  }));
});

gulp.task('test', ['test:server']);

gulp.task('default', ['assets', 'sass', 'browserify']);
<commit_msg>Simplified sass bundle config.<commit_after>'use strict';
/* eslint-disable no-console, no-invalid-this */

var gulp = require('gulp');
var browserify = require('browserify');
var uglify = require('gulp-uglify');
var through2 = require('through2');
var eslint = require('gulp-eslint');
var tape = require('gulp-tape');
var tapSpec = require('tap-spec');
var bundleStyles = require('substance/util/bundleStyles');
var examples = require('./examples/config').examples;
var fs = require('fs');
var path = require('path');
var gulpFile = require('gulp-file');

gulp.task('assets', function () {
  examples.forEach(function(exampleFolder) {
    gulp.src('./examples/'+exampleFolder+'/index.html')
          .pipe(gulp.dest('dist/'+exampleFolder));
  });
  gulp.src('examples/data/*')
    .pipe(gulp.dest('./dist/data'));
  gulp.src('node_modules/font-awesome/fonts/*')
    .pipe(gulp.dest('./dist/fonts'));
});

gulp.task('sass', function(done) {
  Promise.all(examples.map(function(exampleFolder) {
    return bundleStyles({
      rootDir: __dirname,
      configuratorPath: require.resolve('./packages/common/BaseConfigurator'),
      configPath: require.resolve('./examples/'+exampleFolder+'/package'),
      sass: {
        sourceMap: false,
        outputStyle: 'compressed'
      }
    }).then(function(css) {
      var distPath = path.join(__dirname, 'dist', exampleFolder);
      gulpFile('app.css', css, { src: true })
        .pipe(gulp.dest(distPath));
    }).catch(function(err) {
      console.error(err);
    });
  })).then(function() {
    done();
  });
});

gulp.task('browserify', function() {
  examples.forEach(function(exampleFolder) {
    gulp.src('./examples/'+exampleFolder+'/app.js')
      .pipe(through2.obj(function (file, enc, next) {
        browserify(file.path)
          .bundle(function (err, res) {
            if (err) { return next(err); }
            file.contents = res;
            next(null, file);
          });
      }))
      .on('error', function (error) {
        console.log(error.stack);
        this.emit('end');
      })
      .pipe(uglify().on('error', function(err){console.log(err); }))
      .pipe(gulp.dest('./dist/'+exampleFolder));
  });
});

gulp.task('lint', function() {
  return gulp.src([
    './examples/**/*.js',
    './packages/**/*.js',
    './test/**/*.js',
  ]).pipe(eslint())
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

gulp.task('test:server', ['lint'], function() {
  return gulp.src([
    'test/jats/*.test.js'
  ])
  .pipe(tape({
    reporter: tapSpec()
  }));
});

gulp.task('test', ['test:server']);

gulp.task('default', ['assets', 'sass', 'browserify']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var modRewrite = require('connect-modrewrite');
var qunit = require('node-qunit-phantomjs');
var gulp = require('gulp');

var config = {
	paths: {
		scripts: ['./js/jquery.responsiveTabs.js'],
		images: 'client/img/**/*'
	}
};

// Build
gulp.task('build', function() {
	return gulp.src(config.paths.scripts)
		.pipe(uglify({
			preserveComments: 'some'
		}))
		.pipe(rename({
			extname: '.min.js'
		}))
		.pipe(gulp.dest('js/'));
	});

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

// Test
gulp.task('test', function() {
	qunit('./test/fixture.html');
});

// Watch
gulp.task('watch', function() {
	gulp.watch(config.paths.scripts, ['lint']);
});

// Serve
gulp.task('serve', ['watch'], function() {
    browserSync.init({
        server: {
            baseDir: './',
            middleware: [
				modRewrite([
					'^/$ /demo.html'
				])
			]
        }
    });
});

gulp.task('default', ['serve']);<commit_msg>Added browsersync reload on html change<commit_after>var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var modRewrite = require('connect-modrewrite');
var qunit = require('node-qunit-phantomjs');
var gulp = require('gulp');

var config = {
	paths: {
		scripts: ['./js/jquery.responsiveTabs.js'],
		images: 'client/img/**/*'
	}
};

// Build
gulp.task('build', function() {
	return gulp.src(config.paths.scripts)
		.pipe(uglify({
			preserveComments: 'some'
		}))
		.pipe(rename({
			extname: '.min.js'
		}))
		.pipe(gulp.dest('js/'));
	});

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

// Test
gulp.task('test', function() {
	qunit('./test/fixture.html');
});

// Watch
gulp.task('watch', function() {
	gulp.watch(config.paths.scripts, ['lint']);
});

// Serve
gulp.task('serve', ['watch'], function() {
    browserSync.init({
        server: {
            baseDir: './',
            middleware: [
				modRewrite([
					'^/$ /demo.html'
				])
			]
        }
    });

    gulp.watch('*.html').on('change', browserSync.reload);
});

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