<commit_before>/*
This is our Gulpfile.

Current functionality pipelines:
- TypeScript -> JS (Server)
- TypeScript -> JS -> Browserify (Client)
- Sass -> CSS -> autoprefixer -> minify
*/

"use strict";

// Core dependencies
let path = require("path");
let gulp = require("gulp");
let fs = require("fs");
let _ = require("lodash");

// Constants
const systemPath = path.join(__dirname, "/node_modules/systemjs/dist/system.js");

let singleBuild = true;
let userConfig;
let config;

let plumberopts = {
	errorHandler: function(err) {
		notify.onError("Error: <%= error.message %>")(err);
		this.emit("end");
	}
};

console.log("Loading dependencies...");

// Utility dependencies
let gutil = require("gulp-util");
let plumber = require("gulp-plumber");
let merge = require("merge-stream");
let source = require("vinyl-source-stream");
let buffer = require("vinyl-buffer");
let gulpif = require("gulp-if");
let concat = require("gulp-concat");
let notify = require("gulp-notify");
let livereload = require("gulp-livereload");
let watch = require("gulp-watch");
let sourcemaps = require("gulp-sourcemaps");
let rename = require("gulp-rename");
let shell = require("gulp-shell");

// Scripts
var browserify = require("browserify");
var watchify = require("watchify");
var tsify = require("tsify");
let uglify = require("gulp-uglify");
let gulpTypescript = require("gulp-typescript");

// Styles
let sass = require("gulp-ruby-sass");
let minifyCSS = require("gulp-minify-css");
let autoprefixer = require("gulp-autoprefixer");

function ensureModule(module) {
	module.name = module.name || "unnamed module";
	module.path = module.path || __dirname;
	module.transforms = module.transforms || {};

	return module;
}

let configPresets = {
	production: {
		minify: true,
		sourcemaps: false
	},

	development: {
		minify: false,
		sourcemaps: true
	}
}

// Load configuration from our config file
gulp.task("config", function() {
	gutil.log("Loading configuration...");

	delete require.cache[path.resolve("./build.conf.js")];

	config = {
		modules: [],
		client: {
			module: "commonjs",
			sortOutput: true,
			target: "ES5"
		},
		server: {
			module: "commonjs",
			target: "ES5"
		},
		styles: {
		}
	};

	try {
		userConfig = require("./build.conf.js");
	} catch(e) {
		userConfig = {
			preset: "development"
		};
	}

	if (userConfig.preset != undefined) {
		if (configPresets[userConfig.preset] != undefined) {
			_.defaultsDeep(userConfig, configPresets[userConfig.preset]);
		}
	}

	_.assign(config, userConfig);

	if (config.styles.sourcemap === undefined && config.sourcemaps !== undefined) {
		config.styles.sourcemap = config.sourcemaps;
	}
	
	config.modules = _.map(config.modules, ensureModule);
});

// Build server scripts
gulp.task("build:server", function() {
	let merged = merge();

	config.modules.forEach(function(module) {
		if (!module.transforms.server) {
			return;
		}<commit_msg>Remove extraneous gulp-shell dependency<commit_after>/*
This is our Gulpfile.

Current functionality pipelines:
- TypeScript -> JS (Server)
- TypeScript -> JS -> Browserify (Client)
- Sass -> CSS -> autoprefixer -> minify
*/

"use strict";

// Core dependencies
let path = require("path");
let gulp = require("gulp");
let fs = require("fs");
let _ = require("lodash");

// Constants
const systemPath = path.join(__dirname, "/node_modules/systemjs/dist/system.js");

let singleBuild = true;
let userConfig;
let config;

let plumberopts = {
	errorHandler: function(err) {
		notify.onError("Error: <%= error.message %>")(err);
		this.emit("end");
	}
};

console.log("Loading dependencies...");

// Utility dependencies
let gutil = require("gulp-util");
let plumber = require("gulp-plumber");
let merge = require("merge-stream");
let source = require("vinyl-source-stream");
let buffer = require("vinyl-buffer");
let gulpif = require("gulp-if");
let concat = require("gulp-concat");
let notify = require("gulp-notify");
let livereload = require("gulp-livereload");
let watch = require("gulp-watch");
let sourcemaps = require("gulp-sourcemaps");
let rename = require("gulp-rename");

// Scripts
var browserify = require("browserify");
var watchify = require("watchify");
var tsify = require("tsify");
let uglify = require("gulp-uglify");
let gulpTypescript = require("gulp-typescript");

// Styles
let sass = require("gulp-ruby-sass");
let minifyCSS = require("gulp-minify-css");
let autoprefixer = require("gulp-autoprefixer");

function ensureModule(module) {
	module.name = module.name || "unnamed module";
	module.path = module.path || __dirname;
	module.transforms = module.transforms || {};

	return module;
}

let configPresets = {
	production: {
		minify: true,
		sourcemaps: false
	},

	development: {
		minify: false,
		sourcemaps: true
	}
}

// Load configuration from our config file
gulp.task("config", function() {
	gutil.log("Loading configuration...");

	delete require.cache[path.resolve("./build.conf.js")];

	config = {
		modules: [],
		client: {
			module: "commonjs",
			sortOutput: true,
			target: "ES5"
		},
		server: {
			module: "commonjs",
			target: "ES5"
		},
		styles: {
		}
	};

	try {
		userConfig = require("./build.conf.js");
	} catch(e) {
		userConfig = {
			preset: "development"
		};
	}

	if (userConfig.preset != undefined) {
		if (configPresets[userConfig.preset] != undefined) {
			_.defaultsDeep(userConfig, configPresets[userConfig.preset]);
		}
	}

	_.assign(config, userConfig);

	if (config.styles.sourcemap === undefined && config.sourcemaps !== undefined) {
		config.styles.sourcemap = config.sourcemaps;
	}

	config.modules = _.map(config.modules, ensureModule);
});

// Build server scripts
gulp.task("build:server", function() {
	let merged = merge();

	config.modules.forEach(function(module) {
		if (!module.transforms.server) {
			return;
		}
{'fraction_non_alphanumeric': 0.1682210708117444, 'fraction_numerical': 0.000690846286701209, 'mean_word_length': 4.427366447985005, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '558460', 'n_tokens_mistral': 2016, 'n_tokens_neox': 1899, 'n_words': 428}