Skip to content

Commit

Permalink
Build: upgrade build environment (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxwolf authored Aug 23, 2016
1 parent c14789b commit e80f4bc
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 72 deletions.
30 changes: 3 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules

# Users Environment Variables
.lock-wscript
coverage/
dist/
old/
3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
.eslintrc
gulpfile.js

runas
env/
coverage/
dist/
test/
83 changes: 46 additions & 37 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var ARGV = require("yargs").
help("help").
argv;

var browserify = require("browserify"),
var webpack = require("webpack-stream"),
clone = require("lodash.clone"),
del = require("del"),
doctoc = require("gulp-doctoc"),
Expand Down Expand Up @@ -117,58 +117,46 @@ gulp.task("test:nodejs", function(cb) {
});

// ### BROWSER TASKS ###
function doBrowserify(suffix, steps) {
var source = require("vinyl-source-stream"),
buffer = require("vinyl-buffer"),
sourcemaps = require("gulp-sourcemaps");

function doBrowserify(suffix, plugins) {
var pkg = require("./package.json");

suffix = suffix || ".js";
steps = steps || [];

var stream = browserify({
entries: require("path").resolve(pkg.main),
standalone: "kms"
}).bundle().
pipe(source(pkg.name + suffix)).
pipe(buffer());

steps.forEach(function(s) {
stream = stream.pipe(s);
});

return stream.pipe(sourcemaps.init({ loadMaps: true })).
pipe(sourcemaps.write("./")).
pipe(gulp.dest("./dist"));
plugins = plugins || [];

return gulp.src(require("path").resolve(pkg.main)).
pipe(webpack({
output: {
filename: pkg.name + suffix
},
plugins: plugins,
devtool: "source-map"
})).
pipe(gulp.dest("./dist"));
}

gulp.task("bundle", function() {
return doBrowserify();
});

gulp.task("minify", function() {
var uglify = require("gulp-uglify");

return doBrowserify(".min.js", [
uglify()
new webpack.webpack.optimize.UglifyJsPlugin({
minimize: true
})
]);
});

var KARMA_CONFIG = {
frameworks: ["mocha", "browserify"],
frameworks: ["mocha"],
basePath: ".",
browserNoActivityTimeout: 600000,
client: {
mocha: MOCHA_CONFIG
},
preprocessors: {
"test/**/*-test.js": ["browserify"]
"test/**/*-test.js": ["webpack"]
},
reporters: ["mocha"],
browserify: {
debug: true
},
customLaunchers: {
"SL_Chrome": {
base: "SauceLabs",
Expand All @@ -178,32 +166,53 @@ var KARMA_CONFIG = {
base: "SauceLabs",
browserName: "firefox"
},
"SL_Safari": {
"SL_Safari_8": {
base: "SauceLabs",
platform: "OS X 10.10",
browserName: "safari",
version: "8"
},
"SL_Safari_9": {
base: "SauceLabs",
platform: "OS X 10.9",
platform: "OS X 10.11",
browserName: "safari",
version: "7"
version: "9"
},
"SL_IE": {
"SL_IE_10": {
base: "SauceLabs",
browserName: "internet explorer",
version: "10"
},
"SL_IE_11": {
base: "SauceLabs",
browserName: "internet explorer",
platform: "Windows 8.1",
version: "11"
},
"SL_EDGE": {
base: "SauceLabs",
browserName: "microsoftedge",
platform: "Windows 10"
}
},
captureTimeout: 600000,
sauceLabs: {
testName: "node-kms"
testName: require("./package.json").name
},
files: [TESTS]
};
var KARMA_BROWSERS = {
local: ["Chrome", "Firefox", "Safari"],
saucelabs: ["SL_Chrome", "SL_Firefox", "SL_IE", "SL_Safari"]
local: ["Chrome", "Firefox"],
saucelabs: ["SL_Chrome", "SL_Firefox", "SL_Safari_8", "SL_Safari_9", "SL_IE_10", "SL_IE_11", "SL_EDGE"]
};
// allow for IE on windows
if (/^win/.test(process.platform)) {
KARMA_BROWSERS.local.push("IE");
}
// allow for Safari on Mac OS X
if (/^darwin/.test(process.platform)) {
KARMA_BROWSERS.local.push("Safari");
}

gulp.task("test:browser:single", function(done) {
var browsers = ARGV.browsers.split(/\s*,\s*/g).
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"uuid": "^2.0.1"
},
"devDependencies": {
"browserify": "^8.1.3",
"chai": "^1.10.0",
"del": "^1.1.1",
"gulp": "^3.8.10",
Expand All @@ -38,23 +37,22 @@
"gulp-istanbul": "^0.6.0",
"gulp-mocha": "^2.0.0",
"gulp-rename": "^1.2.0",
"gulp-sourcemaps": "^1.3.0",
"gulp-uglify": "^1.1.0",
"istanbul": "^0.3.5",
"karma": "^0.12.31",
"karma-browserify": "^3.0.1",
"karma": "^1.2.0",
"karma-chrome-launcher": "^0.1.7",
"karma-firefox-launcher": "^0.1.4",
"karma-mocha": "^0.1.10",
"karma-mocha-reporter": "^0.3.1",
"karma-safari-launcher": "^0.1.1",
"karma-sauce-launcher": "^0.2.14",
"karma-webpack": "^1.8.0",
"lodash.merge": "^3.3.1",
"lodash.omit": "^3.1.0",
"mocha": "^2.1.0",
"run-sequence": "^1.0.2",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.0.0",
"webpack": "^1.13.2",
"webpack-stream": "^3.2.0",
"yargs": "^3.18.0"
}
}

0 comments on commit e80f4bc

Please sign in to comment.