-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c9842b
commit 9b0adda
Showing
5 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.sass-cache/ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
Bundle = require('./bundle') | ||
clean = require('gulp-rimraf') | ||
coffee = require('gulp-coffee') | ||
concat = require('gulp-concat') | ||
gulp = require('gulp') | ||
jade = require('gulp-jade') | ||
mocha = require('gulp-mocha') | ||
nib = require('nib') | ||
path = require('path') | ||
plumber = require('gulp-plumber') | ||
stylus = require('gulp-stylus') | ||
|
||
config = | ||
scripts: 'src/scripts/**/*.coffee' | ||
specs: 'spec/**/*.js' | ||
styles: 'src/**/*.styl' | ||
templates: 'src/**/*.jade' | ||
public: './public' | ||
|
||
bundles = | ||
core: new Bundle( | ||
'lib/client/bundle.js', | ||
'public/scripts/wowser.js', | ||
standalone: 'Wowser' | ||
) | ||
ui: new Bundle( | ||
'lib/client/ui/bundle.js', | ||
'public/scripts/wowser-ui.js', | ||
standalone: 'Wowser.UI' | ||
) | ||
|
||
gulp.task 'clean', -> | ||
gulp.src([ | ||
'lib/*', | ||
'public/scripts/*', | ||
'public/styles/*', | ||
'public/templates/*', | ||
'public/index.html' | ||
]).pipe clean() | ||
|
||
gulp.task 'scripts:compile', -> | ||
gulp.src config.scripts | ||
.pipe plumber() | ||
.pipe coffee(bare: true) | ||
.pipe gulp.dest('.') | ||
|
||
gulp.task 'scripts:bundle:core', -> | ||
bundles.core.bundle() | ||
|
||
gulp.task 'scripts:bundle:ui', -> | ||
bundles.ui.bundle() | ||
|
||
gulp.task 'scripts', gulp.series( | ||
'scripts:compile', 'scripts:bundle:core', 'scripts:bundle:ui' | ||
) | ||
|
||
gulp.task 'styles', -> | ||
gulp.src config.styles | ||
.pipe plumber() | ||
.pipe stylus( | ||
use: [nib()] | ||
import: 'nib' | ||
paths: ['node_modules'] | ||
) | ||
.pipe concat('styles/wowser.css') | ||
.pipe gulp.dest(config.public) | ||
|
||
gulp.task 'templates', -> | ||
gulp.src config.templates | ||
.pipe plumber() | ||
.pipe jade(pretty: true) | ||
.pipe gulp.dest(config.public) | ||
|
||
gulp.task 'spec', -> | ||
gulp.src config.specs, read: false | ||
.pipe plumber() | ||
.pipe mocha() | ||
|
||
gulp.task 'watch', -> | ||
gulp.watch config.scripts, gulp.series('scripts', 'spec') | ||
.on 'change', (event) -> | ||
jspath = event.path.replace('src/scripts/', '').replace('.coffee', '.js') | ||
bundles.core.invalidate(jspath) | ||
bundles.ui.invalidate(jspath) | ||
|
||
gulp.watch config.styles, 'styles' | ||
gulp.watch config.templates, 'templates' | ||
|
||
gulp.task 'default', gulp.series( | ||
'scripts', 'spec', 'styles', 'templates', 'watch' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
Server = require('../lib/server'); | ||
|
||
(new Server(__dirname + '/..')).run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
attr = require('attr-accessor') | ||
browserify = require('browserify') | ||
gulp = require('gulp') | ||
gutil = require('gulp-util') | ||
path = require('path') | ||
plumber = require('gulp-plumber') | ||
source = require('vinyl-source-stream') | ||
|
||
class Bundle | ||
module.exports = @ | ||
|
||
[get] = attr.accessors(@) | ||
|
||
constructor: (src, destination, @options = {}) -> | ||
@src = path.resolve(src) | ||
@options.cache = {} | ||
@options.packageCache = {} | ||
@options.fullPaths = true | ||
@target = | ||
name: path.basename(destination) | ||
dir: path.dirname(destination) | ||
|
||
get bundler: -> | ||
unless @_bundler | ||
@_bundler = browserify(@src, @options) | ||
@_bundler.on 'dep', @cache.bind(@) | ||
@_bundler | ||
|
||
bundle: -> | ||
@bundler.bundle() | ||
.on 'error', (error) -> | ||
gutil.log gutil.colors.red("Bundling error:\n"), error.stack | ||
@emit 'end' | ||
.pipe source(@target.name) | ||
.pipe gulp.dest(@target.dir) | ||
|
||
cache: (dependency) -> | ||
@options.cache[dependency.id] = dependency | ||
|
||
invalidate: (path) -> | ||
delete @options.cache[path] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "wowser", | ||
"version": "0.0.0", | ||
"description": "World of Warcraft in the browser using JavaScript and WebGL", | ||
"main": "lib/client/index.js", | ||
"files": [ | ||
"bin", | ||
"lib", | ||
"public", | ||
"LICENSE.md", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"start": "bin/serve", | ||
"serve": "bin/serve", | ||
"serve-dev": "nodemon bin/serve -w lib/server", | ||
"test": "mocha spec" | ||
}, | ||
"repository": "timkurvers/wowser", | ||
"author": "Tim Kurvers <tim@moonsphere.net>", | ||
"license": "MIT", | ||
"private": true, | ||
"keywords": [ | ||
"world of warcraft", | ||
"warcraft", | ||
"blizzard", | ||
"wow" | ||
], | ||
"dependencies": { | ||
"attr-accessor": "^0.2.0", | ||
"byte-buffer": "^1.0.3", | ||
"express": "^4.9.3", | ||
"morgan": "^1.3.2" | ||
}, | ||
"devDependencies": { | ||
"angular": "^1.2.23", | ||
"browserify": "^6.0.3", | ||
"coffee-script": "^1.8.0", | ||
"gulp": "git://github.com/gulpjs/gulp.git#4.0", | ||
"gulp-coffee": "^2.2.0", | ||
"gulp-concat": "^2.4.1", | ||
"gulp-jade": "^0.8.0", | ||
"gulp-mocha": "1.0.0", | ||
"gulp-plumber": "^0.6.6", | ||
"gulp-rimraf": "^0.1.1", | ||
"gulp-stylus": "^1.3.3", | ||
"gulp-util": "^3.0.1", | ||
"mocha": "^1.21.5", | ||
"nib": "^1.0.4", | ||
"sinon-chai": "^2.6.0", | ||
"stylus-normalize": "^3.0.3", | ||
"vinyl-source-stream": "^1.0.0" | ||
} | ||
} |