<commit_before>/**
 * RMC gulpfile
 *
 * @license
 * Copyright (c) 2017 Rogers Manufacturing Company. All rights reserved.
 */

'use strict';

// include gulp & tools
import gulp from 'gulp';
import del from 'del';
import rename from 'gulp-rename';
import replace from 'gulp-replace';
import header from 'gulp-header';
import fs from 'fs';
import path from 'path';
import sass from 'gulp-sass';
import purifyCSS from 'gulp-purifycss';
import cleanCSS from 'gulp-clean-css';
import stripCSSComments from 'gulp-strip-css-comments';
import webp from 'gulp-webp';
import swPrecache from 'sw-precache';
import sftp from 'gulp-sftp';
import minimist from 'minimist';
import browserSync from 'browser-sync';
import historyFallback from 'connect-history-api-fallback';
import pkg from './package.json';

const banner = ['<!--',
  '<%= pkg.name %> - <%= pkg.description %>',
  '@version v<%= pkg.version %>',
  '@license <%= pkg.license %>',
  '@copyright 2017 The Rogers Manufacturing Company',
  '@link <%= pkg.homepage %>',
  '-->',
  ''].join('\n');

const reload = browserSync.reload;
const FONTS = ['node_modules/components-font-awesome/fonts/*.*'];
const IMAGES = [
  'images/**/*',
  '!images/manifest/**/*',
  '!images/favicon.ico',
  '!images/**/*.webp',
];

/**
 * Defines the list of resources to watch for changes.
 */
function watch() {
  gulp.watch(['scss/**/*.scss'], ['css', reload]);
  gulp.watch(IMAGES, ['webp', reload]);
  gulp.watch(['src/**/*'], reload);
  gulp.watch(['index.html'], reload);
}

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

// Minify CSS
gulp.task('clean-css', ['sass'], function() {
  return gulp.src('css/rmc-theme.css')
    .pipe(purifyCSS([
      'node_modules/bootstrap/dist/js/bootstrap.min.js',
      'src/**/*.html',
      'index.html',
    ]))
    .pipe(stripCSSComments({
      preserve: false,
    }))
    .pipe(cleanCSS({
      level: 2,
    }))
    .pipe(rename({suffix: '.min'}))
    .pipe(gulp.dest('css/'));
});

// WebP
gulp.task('webp', function() {
  return gulp.src(IMAGES)
    .pipe(webp())
    .pipe(gulp.dest('images/'));
});

// Copy fonts
gulp.task('fonts', function() {
  return gulp.src(FONTS)
    .pipe(gulp.dest('build/es5-bundled/fonts/'));
});

// Copy fonts locally
gulp.task('fonts:local', function() {
  return gulp.src(FONTS)
    .pipe(gulp.dest('fonts/'));
});

// Inline CSS & banner
gulp.task('inline', function() {
  return gulp.src('build/es5-bundled/index.html')
    .pipe(replace('<link rel="stylesheet" href="css/rmc-theme.min.css">', function(s) {
      let style = fs.readFileSync('css/rmc-theme.min.css', 'utf8');
      return '<style>' + style + '</style>';
    }))
    .pipe(header(banner, {pkg: pkg}))
    .pipe(gulp.dest('build/es5-bundled/'));
});

// Generate precaching service worker
gulp.task('generate-service-worker', ['inline', 'fonts', 'del'], function(callback) {
  let rootDir = 'build/es5-bundled/';
  
  swPrecache.write(path.join(rootDir, 'sw.js'), {
  staticFileGlobs: [rootDir + '/**/*.{html,css,js,otf,eot,svg,ttf,woff,woff2,png,jpg,webp,ico}'],
  stripPrefix: rootDir,
  }, callback);
});

// Copy app indexeddb mirror worker
gulp.task('app-indexeddb', function() {
  return gulp.src('node_modules/@npm-polymer/app-storage/app-indexeddb-mirror/app-indexeddb-mirror-worker.js')
    .pipe(gulp.dest('build/es5-bundled/'));
});

// Delete unneccessary build files
gulp.task('del', function() {
  return del([
    'build/es5-bundled/bower_components/',
  ]);
});

// Watch resources for changes.
gulp.task('watch', function() {
  watch();
});

/**
 * Serves local landing page from "./" directory.
 */
gulp.task('serve:browsersync:local', () => {
  browserSync({
      server: {
        baseDir: '.',
        middleware: [
            historyFallback()
        ]
      },
      browser: 'chrome',
  });

  watch();
});

/**
 * Serves production landing page from "build/es5-bundled/" directory.
 */
gulp.task('serve:browsersync:build', () => {
  browserSync({
      server: {
        baseDir: 'build/es5-bundled/',
        middleware: [
            historyFallback()
        ]
      },
      browser: 'chrome',
  });<commit_msg>Fix eslint Missing trailing comma comma-dangle<commit_after>/**
 * RMC gulpfile
 *
 * @license
 * Copyright (c) 2017 Rogers Manufacturing Company. All rights reserved.
 */

'use strict';

// include gulp & tools
import gulp from 'gulp';
import del from 'del';
import rename from 'gulp-rename';
import replace from 'gulp-replace';
import header from 'gulp-header';
import fs from 'fs';
import path from 'path';
import sass from 'gulp-sass';
import purifyCSS from 'gulp-purifycss';
import cleanCSS from 'gulp-clean-css';
import stripCSSComments from 'gulp-strip-css-comments';
import webp from 'gulp-webp';
import swPrecache from 'sw-precache';
import sftp from 'gulp-sftp';
import minimist from 'minimist';
import browserSync from 'browser-sync';
import historyFallback from 'connect-history-api-fallback';
import pkg from './package.json';

const banner = ['<!--',
  '<%= pkg.name %> - <%= pkg.description %>',
  '@version v<%= pkg.version %>',
  '@license <%= pkg.license %>',
  '@copyright 2017 The Rogers Manufacturing Company',
  '@link <%= pkg.homepage %>',
  '-->',
  ''].join('\n');

const reload = browserSync.reload;
const FONTS = ['node_modules/components-font-awesome/fonts/*.*'];
const IMAGES = [
  'images/**/*',
  '!images/manifest/**/*',
  '!images/favicon.ico',
  '!images/**/*.webp',
];

/**
 * Defines the list of resources to watch for changes.
 */
function watch() {
  gulp.watch(['scss/**/*.scss'], ['css', reload]);
  gulp.watch(IMAGES, ['webp', reload]);
  gulp.watch(['src/**/*'], reload);
  gulp.watch(['index.html'], reload);
}

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

// Minify CSS
gulp.task('clean-css', ['sass'], function() {
  return gulp.src('css/rmc-theme.css')
    .pipe(purifyCSS([
      'node_modules/bootstrap/dist/js/bootstrap.min.js',
      'src/**/*.html',
      'index.html',
    ]))
    .pipe(stripCSSComments({
      preserve: false,
    }))
    .pipe(cleanCSS({
      level: 2,
    }))
    .pipe(rename({suffix: '.min'}))
    .pipe(gulp.dest('css/'));
});

// WebP
gulp.task('webp', function() {
  return gulp.src(IMAGES)
    .pipe(webp())
    .pipe(gulp.dest('images/'));
});

// Copy fonts
gulp.task('fonts', function() {
  return gulp.src(FONTS)
    .pipe(gulp.dest('build/es5-bundled/fonts/'));
});

// Copy fonts locally
gulp.task('fonts:local', function() {
  return gulp.src(FONTS)
    .pipe(gulp.dest('fonts/'));
});

// Inline CSS & banner
gulp.task('inline', function() {
  return gulp.src('build/es5-bundled/index.html')
    .pipe(replace('<link rel="stylesheet" href="css/rmc-theme.min.css">', function(s) {
      let style = fs.readFileSync('css/rmc-theme.min.css', 'utf8');
      return '<style>' + style + '</style>';
    }))
    .pipe(header(banner, {pkg: pkg}))
    .pipe(gulp.dest('build/es5-bundled/'));
});

// Generate precaching service worker
gulp.task('generate-service-worker', ['inline', 'fonts', 'del'], function(callback) {
  let rootDir = 'build/es5-bundled/';
  
  swPrecache.write(path.join(rootDir, 'sw.js'), {
  staticFileGlobs: [rootDir + '/**/*.{html,css,js,otf,eot,svg,ttf,woff,woff2,png,jpg,webp,ico}'],
  stripPrefix: rootDir,
  }, callback);
});

// Copy app indexeddb mirror worker
gulp.task('app-indexeddb', function() {
  return gulp.src('node_modules/@npm-polymer/app-storage/app-indexeddb-mirror/app-indexeddb-mirror-worker.js')
    .pipe(gulp.dest('build/es5-bundled/'));
});

// Delete unneccessary build files
gulp.task('del', function() {
  return del([
    'build/es5-bundled/bower_components/',
  ]);
});

// Watch resources for changes.
gulp.task('watch', function() {
  watch();
});

/**
 * Serves local landing page from "./" directory.
 */
gulp.task('serve:browsersync:local', () => {
  browserSync({
      server: {
        baseDir: '.',
        middleware: [
            historyFallback(),
        ],
      },
      browser: 'chrome',
  });

  watch();
});

/**
 * Serves production landing page from "build/es5-bundled/" directory.
 */
gulp.task('serve:browsersync:build', () => {
  browserSync({
      server: {
        baseDir: 'build/es5-bundled/',
        middleware: [
            historyFallback(),
        ],
      },
      browser: 'chrome',
  });
{'fraction_non_alphanumeric': 0.20656891495601173, 'fraction_numerical': 0.004457478005865103, 'mean_word_length': 3.523076923076923, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '461683', 'n_tokens_mistral': 3111, 'n_tokens_neox': 2999, 'n_words': 589}