|
|
|
@ -1,25 +1,30 @@
|
|
|
|
|
watchify = require('watchify')
|
|
|
|
|
browserify = require('browserify')
|
|
|
|
|
browserSync = require('browser-sync')
|
|
|
|
|
gulp = require('gulp')
|
|
|
|
|
source = require('vinyl-source-stream')
|
|
|
|
|
gutil = require('gulp-util')
|
|
|
|
|
coffeify = require('coffeeify')
|
|
|
|
|
coffee = require("gulp-coffee")
|
|
|
|
|
sass = require('gulp-sass')
|
|
|
|
|
uglify = require('gulp-uglify')
|
|
|
|
|
buffer = require('vinyl-buffer')
|
|
|
|
|
zip = require('gulp-zip')
|
|
|
|
|
concat = require('gulp-concat')
|
|
|
|
|
rename = require('gulp-rename')
|
|
|
|
|
fs = require 'fs'
|
|
|
|
|
CSON = require 'cson'
|
|
|
|
|
glob = require 'glob'
|
|
|
|
|
|
|
|
|
|
reload = browserSync.reload
|
|
|
|
|
|
|
|
|
|
html = (target) ->
|
|
|
|
|
html = (target, debug) ->
|
|
|
|
|
return () ->
|
|
|
|
|
return gulp.src(['html/*.html']).pipe(gulp.dest(target))
|
|
|
|
|
sources = [
|
|
|
|
|
'html/index.html'
|
|
|
|
|
'html/ru.html'
|
|
|
|
|
]
|
|
|
|
|
if (debug)
|
|
|
|
|
sources.push('html/test.html')
|
|
|
|
|
gulp.src(sources)
|
|
|
|
|
.pipe(gulp.dest(target))
|
|
|
|
|
#gulp.src(['game/gamepad.min.js']).pipe(gulp.dest(target+"/game"))
|
|
|
|
|
gulp.src(['node_modules/salet/lib/index.min.js'])
|
|
|
|
|
.pipe(rename('salet.min.js'))
|
|
|
|
|
.pipe(gulp.dest(target+"/game"))
|
|
|
|
|
|
|
|
|
|
# Images
|
|
|
|
|
img = (target) ->
|
|
|
|
@ -31,68 +36,65 @@ audio = (target) ->
|
|
|
|
|
return () ->
|
|
|
|
|
return gulp.src(['audio/*.mp3']).pipe(gulp.dest(target))
|
|
|
|
|
|
|
|
|
|
gulp.task('html', html('./build'))
|
|
|
|
|
gulp.task('html', html('./build', true))
|
|
|
|
|
gulp.task('img', img('./build/img'))
|
|
|
|
|
gulp.task('audio', audio('./build/audio'))
|
|
|
|
|
|
|
|
|
|
# SCSS styles
|
|
|
|
|
gulp.task('sass', () ->
|
|
|
|
|
gulp.src('sass/main.scss')
|
|
|
|
|
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
|
|
|
|
|
.pipe(gulp.dest('./build/css'))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
bundler = watchify(browserify({
|
|
|
|
|
entries: ["./build/game/main.coffee"]
|
|
|
|
|
debug: true
|
|
|
|
|
transform: [coffeify]
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
bundle = () ->
|
|
|
|
|
return bundler.bundle()
|
|
|
|
|
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
|
|
|
|
|
.pipe(source('bundle.js'))
|
|
|
|
|
.pipe(gulp.dest('./build/game'))
|
|
|
|
|
# Autotests
|
|
|
|
|
gulp.task('tests', () ->
|
|
|
|
|
gulp.src('test/*.js')
|
|
|
|
|
.pipe(gulp.dest('./build/test/'))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
gulp.task('concatCoffee', () ->
|
|
|
|
|
for language in ['ru', 'en']
|
|
|
|
|
files = glob.sync('game/procgen/'+language+'/*.cson')
|
|
|
|
|
spec = {}
|
|
|
|
|
for file in files
|
|
|
|
|
data = CSON.parseCSONFile(file)
|
|
|
|
|
if not data.groups?
|
|
|
|
|
data.groups = []
|
|
|
|
|
if data.phrases?
|
|
|
|
|
data.groups.push({
|
|
|
|
|
tags: [],
|
|
|
|
|
phrases: data.phrases
|
|
|
|
|
})
|
|
|
|
|
data.phrases = undefined
|
|
|
|
|
key = file.substr(0, file.lastIndexOf('.')) || file
|
|
|
|
|
key = key.replace('game/procgen/'+language+'/', '')
|
|
|
|
|
spec[key] = data
|
|
|
|
|
|
|
|
|
|
json = JSON.stringify(spec) + '\n'
|
|
|
|
|
fs.writeFileSync("./build/game/procgen/"+language+".json", json)
|
|
|
|
|
|
|
|
|
|
return gulp.src([
|
|
|
|
|
'./game/begin.coffee',
|
|
|
|
|
'./game/story.coffee',
|
|
|
|
|
]).pipe(concat('./main.coffee')).pipe(gulp.dest('./build/game'))
|
|
|
|
|
gulp.src([
|
|
|
|
|
# language
|
|
|
|
|
'./game/language/ru.coffee'
|
|
|
|
|
'./game/language/en.coffee'
|
|
|
|
|
# Improv
|
|
|
|
|
'./game/improv/index.coffee'
|
|
|
|
|
'./game/improv/filters.coffee'
|
|
|
|
|
'./game/improv/template.coffee'
|
|
|
|
|
## additional functions
|
|
|
|
|
"./lib/oneOf.coffee"
|
|
|
|
|
"./lib/phrase.coffee"
|
|
|
|
|
## the actual game
|
|
|
|
|
'./game/begin.coffee'
|
|
|
|
|
'./game/story.coffee'
|
|
|
|
|
]).pipe(concat('./main.coffee'))
|
|
|
|
|
.pipe(gulp.dest('./build/game'))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
gulp.task('coffee', ['concatCoffee'], bundle)
|
|
|
|
|
|
|
|
|
|
bundler.on('update', bundle)
|
|
|
|
|
bundler.on('log', gutil.log)
|
|
|
|
|
gulp.task('coffee', ['concatCoffee'], () ->
|
|
|
|
|
gulp.src('./build/game/main.coffee')
|
|
|
|
|
.pipe(coffee({bare: true}))
|
|
|
|
|
.pipe(gulp.dest('./build/game/'))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
gulp.task('build', ['html', 'img', 'sass', 'coffee', 'audio'])
|
|
|
|
|
gulp.task('build', [
|
|
|
|
|
'html',
|
|
|
|
|
'img',
|
|
|
|
|
'sass',
|
|
|
|
|
'coffee',
|
|
|
|
|
'audio',
|
|
|
|
|
'tests'
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
gulp.task('serve', ['build'], () ->
|
|
|
|
|
browserSync({
|
|
|
|
|
server: {
|
|
|
|
|
baseDir: 'build'
|
|
|
|
|
}
|
|
|
|
|
online: true
|
|
|
|
|
browser: []
|
|
|
|
|
ghostMode: false
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
sassListener = () ->
|
|
|
|
@ -101,8 +103,10 @@ gulp.task('serve', ['build'], () ->
|
|
|
|
|
gulp.watch(['./html/*.html'], ['html'])
|
|
|
|
|
gulp.watch(['./sass/*.scss'], ['sass'])
|
|
|
|
|
gulp.watch(['./img/*.png', './img/*.jpeg', './img/*.jpg'], ['img'])
|
|
|
|
|
gulp.watch(['./game/*.coffee'], ['coffee']);
|
|
|
|
|
gulp.watch(['./game/procgen/*/*.cson'], ['concatCoffee']);
|
|
|
|
|
gulp.watch([
|
|
|
|
|
'./game/*.coffee'
|
|
|
|
|
'./game/translations/*.cson'
|
|
|
|
|
], ['coffee'])
|
|
|
|
|
|
|
|
|
|
gulp.watch(['./build/css/main.css'], sassListener)
|
|
|
|
|
gulp.watch(
|
|
|
|
@ -110,47 +114,35 @@ gulp.task('serve', ['build'], () ->
|
|
|
|
|
browserSync.reload)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
gulp.task('html-dist', html('./dist'))
|
|
|
|
|
gulp.task('html-dist', html('./dist', false))
|
|
|
|
|
gulp.task('img-dist', img('./dist/img'))
|
|
|
|
|
gulp.task('audio-dist', audio('./dist/audio'))
|
|
|
|
|
gulp.task('legal-dist', () ->
|
|
|
|
|
return gulp.src(['LICENSE.txt'])
|
|
|
|
|
.pipe(gulp.dest("./dist"))
|
|
|
|
|
.pipe(gulp.dest("./dist"))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
gulp.task('sass-dist', () ->
|
|
|
|
|
return gulp.src('./sass/main.scss')
|
|
|
|
|
.pipe(sass({outputStyle: 'compressed'}))
|
|
|
|
|
.pipe(sass({outputStyle: 'compressed'}))
|
|
|
|
|
.pipe(gulp.dest('./dist/css'))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
distBundler = browserify({
|
|
|
|
|
debug: false,
|
|
|
|
|
entries: ['./build/game/main.coffee'],
|
|
|
|
|
transform: ['coffeeify']
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
gulp.task('coffee-dist', ['concatCoffee'], () ->
|
|
|
|
|
return distBundler.bundle()
|
|
|
|
|
.pipe(source('bundle.js'))
|
|
|
|
|
.pipe(buffer())
|
|
|
|
|
gulp.src('./build/game/main.coffee', {sourcemaps: false})
|
|
|
|
|
.pipe(coffee())
|
|
|
|
|
.pipe(uglify())
|
|
|
|
|
.on('error', gutil.log)
|
|
|
|
|
.pipe(gulp.dest('./dist/game'))
|
|
|
|
|
.pipe(gulp.dest('./dist/game/'))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
gulp.task('dist', [
|
|
|
|
|
'html-dist',
|
|
|
|
|
'img-dist',
|
|
|
|
|
'sass-dist',
|
|
|
|
|
'coffee-dist',
|
|
|
|
|
'audio-dist',
|
|
|
|
|
'html-dist'
|
|
|
|
|
'img-dist'
|
|
|
|
|
'sass-dist'
|
|
|
|
|
'coffee-dist'
|
|
|
|
|
'audio-dist'
|
|
|
|
|
'legal-dist'
|
|
|
|
|
], () ->
|
|
|
|
|
return gulp.src([
|
|
|
|
|
'./build/game/procgen/*.json'
|
|
|
|
|
]).pipe(gulp.dest("./dist/game/procgen"))
|
|
|
|
|
)
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
gulp.task('zip', ['dist'], () ->
|
|
|
|
|
return gulp.src('dist/**')
|
|
|
|
|