<commit_before>const gulp = require("gulp"),
      connect = require("gulp-connect"),
      pug = require("gulp-pug"),
      data = require("gulp-data"),
      path = require("path"),
      less = require("gulp-less"),
      minify = require("gulp-clean-css"),
      sourcemaps = require("gulp-sourcemaps"),
      rename = require("gulp-rename"),
      tsc = require("gulp-typescript"),
      uglify = require("gulp-uglify");

const sources = {
  templates: {
    watch: "src/templates/**/*.pug",
    source: "src/templates/pages/**/*.pug",
    destination: "dist/"
  },
  less: {
    watch: "src/less/**/*.less",
    source: "src/less/stylesheet.less",
    destination: "dist/assets/css/"
  },
  js: {
    watch: "src/ts/**/*.ts",
    source: "src/ts/**/*.ts",
    destination: "dist/assets/js/"
  },
  copy: [
    {
        watch: "src/images/**/*",
        source: "src/images/**/*",
        destination: "dist/assets/images/"
    }
  ]
};

gulp.task("serve", () => {
  connect.server({
    root: "dist/",
    livereload: true
  });
});

gulp.task("templates", () => {
  gulp.src(sources.templates.source)
    .pipe(data((file) => {
        return {
            filename: path.basename(file.path)
        };
    }))
    .pipe(pug({
        pretty: true
    }))
    .pipe(gulp.dest(sources.templates.destination))
    .pipe(connect.reload());
});

gulp.task("css", () => {
  gulp.src(sources.less.source)
    .pipe(sourcemaps.init())
    .pipe(less({
        plugins: [
            require("less-plugin-glob")
        ]
    }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(sources.less.destination))
    .pipe(minify({
        level: {
            2: {
                mergeAdjacentRules: true,
                mergeIntoShorthands: true,
                mergeMedia: true,
                mergeNonAdjacentRules: true,
                mergeSemantically: false,
                overrideProperties: true,
                reduceNonAdjacentRules: true,
                removeDuplicateFontRules: true,
                removeDuplicateMediaBlocks: true,
                removeDuplicateRules: true,
                restructureRules: false
            }
        }
    }))
    .pipe(rename({
        suffix: ".min"
    }))
    .pipe(gulp.dest(sources.less.destination))
    .pipe(connect.reload());
});

gulp.task("js", () => {
  const tsconfig = require("./tsconfig.json");

  gulp.src(sources.js.source)
    .pipe(sourcemaps.init())
    .pipe(tsc(tsconfig.compilerOptions))
    .pipe(sourcemaps.write())
    .pipe(rename({ suffix: ".min" }))
    .pipe(uglify())
    .pipe(gulp.dest(sources.js.destination))
    .pipe(connect.reload());
});

gulp.task("copy", () => {
  for (const item of sources.copy) {
    gulp.src(item.source)
        .pipe(gulp.dest(item.destination));
  }
});

gulp.task("watch", ["default", "serve"], () => {
  gulp.watch(sources.less.watch, ["css"]);
  gulp.watch(sources.js.watch, ["js"]);

  gulp.watch(sources.templates.watch, (event) => {
    if (event.type == "changed") {
        sources.templates.source = event.path;

        gulp.start("templates");
    }
  });

  for (const item of sources.copy) {
    gulp.watch(item.watch, (event) => {
        if (event.type != "deleted") {
            gulp.src(event.path)
                .pipe(gulp.dest(item.destination));
        }
    });
  }
});

gulp.task("default", ["css", "templates", "copy", "js"]);<commit_msg>reload dev server on asset copy<commit_after>const gulp = require("gulp"),
      connect = require("gulp-connect"),
      pug = require("gulp-pug"),
      data = require("gulp-data"),
      path = require("path"),
      less = require("gulp-less"),
      minify = require("gulp-clean-css"),
      sourcemaps = require("gulp-sourcemaps"),
      rename = require("gulp-rename"),
      tsc = require("gulp-typescript"),
      uglify = require("gulp-uglify");

const sources = {
  templates: {
    watch: "src/templates/**/*.pug",
    source: "src/templates/pages/**/*.pug",
    destination: "dist/"
  },
  less: {
    watch: "src/less/**/*.less",
    source: "src/less/stylesheet.less",
    destination: "dist/assets/css/"
  },
  js: {
    watch: "src/ts/**/*.ts",
    source: "src/ts/**/*.ts",
    destination: "dist/assets/js/"
  },
  copy: [
    {
        watch: "src/images/**/*",
        source: "src/images/**/*",
        destination: "dist/assets/images/"
    }
  ]
};

gulp.task("serve", () => {
  connect.server({
    root: "dist/",
    livereload: true
  });
});

gulp.task("templates", () => {
  gulp.src(sources.templates.source)
    .pipe(data((file) => {
        return {
            filename: path.basename(file.path)
        };
    }))
    .pipe(pug({
        pretty: true
    }))
    .pipe(gulp.dest(sources.templates.destination))
    .pipe(connect.reload());
});

gulp.task("css", () => {
  gulp.src(sources.less.source)
    .pipe(sourcemaps.init())
    .pipe(less({
        plugins: [
            require("less-plugin-glob")
        ]
    }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(sources.less.destination))
    .pipe(minify({
        level: {
            2: {
                mergeAdjacentRules: true,
                mergeIntoShorthands: true,
                mergeMedia: true,
                mergeNonAdjacentRules: true,
                mergeSemantically: false,
                overrideProperties: true,
                reduceNonAdjacentRules: true,
                removeDuplicateFontRules: true,
                removeDuplicateMediaBlocks: true,
                removeDuplicateRules: true,
                restructureRules: false
            }
        }
    }))
    .pipe(rename({
        suffix: ".min"
    }))
    .pipe(gulp.dest(sources.less.destination))
    .pipe(connect.reload());
});

gulp.task("js", () => {
  const tsconfig = require("./tsconfig.json");

  gulp.src(sources.js.source)
    .pipe(sourcemaps.init())
    .pipe(tsc(tsconfig.compilerOptions))
    .pipe(sourcemaps.write())
    .pipe(rename({ suffix: ".min" }))
    .pipe(uglify())
    .pipe(gulp.dest(sources.js.destination))
    .pipe(connect.reload());
});

gulp.task("copy", () => {
  for (const item of sources.copy) {
    gulp.src(item.source)
        .pipe(gulp.dest(item.destination));
  }
});

gulp.task("watch", ["default", "serve"], () => {
  gulp.watch(sources.less.watch, ["css"]);
  gulp.watch(sources.js.watch, ["js"]);

  gulp.watch(sources.templates.watch, (event) => {
    if (event.type == "changed") {
        sources.templates.source = event.path;

        gulp.start("templates");
    }
  });

  for (const item of sources.copy) {
    gulp.watch(item.watch, (event) => {
        if (event.type != "deleted") {
            gulp.src(event.path)
                .pipe(gulp.dest(item.destination))
                .pipe(connect.reload());
        }
    });
  }
});

gulp.task("default", ["css", "templates", "copy", "js"]);
{'fraction_non_alphanumeric': 0.18923661889441357, 'fraction_numerical': 0.0002924831822170225, 'mean_word_length': 2.209291412482403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1112255', 'n_tokens_mistral': 2286, 'n_tokens_neox': 2246, 'n_words': 329}