├── .gitignore ├── AUTHORS ├── LICENSE ├── README.md ├── app ├── index.js └── templates │ ├── _bower.json │ ├── _gulpfile.js │ ├── _package.json │ ├── bowerrc │ ├── gitignore │ ├── jshintrc │ └── src │ ├── assets │ ├── preloader.gif │ └── test.png │ ├── css │ └── main.css │ ├── index.html │ └── js │ ├── entities │ └── player.js │ ├── main.js │ ├── states │ ├── boot.js │ ├── game.js │ ├── menu.js │ ├── preloader.js │ └── splash.js │ └── utils.js ├── package.json └── test ├── test-creation.js └── test-load.js /.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | .DS_Store 3 | .listing.html 4 | dist/ 5 | node_modules/ 6 | test/temp/* -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Justin Oblak -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Justin Oblak 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | generator-phaser-browserify 2 | ================= 3 | 4 | A [Yeoman](http://yeoman.io/) generator to generate HTML5 games with [phaser](http://phaser.io/) using Gulp and Browserify. Built off the work by Julien Castelain on [generator-phaser](https://github.com/julien/generator-phaser). Allows the use of browserify (i.e. var player = require('Player.js')) with Phaser. 5 | 6 | Check out [this test game](https://github.com/jroblak/sagdc2014) as an example of project layout / useage. 7 | 8 | **INSTRUCTIONS** 9 | 10 | + Install [Node.js](http://www.nodejs.org) 11 | 12 | + Install the required npm modules by issuing these commands: 13 | 14 | `npm install -g yo generator-phaser-browserify` 15 | 16 | *You can optionally install [Gulp](http://gulpjs.com) globally `npm install -g gulp` but you don't have to.* 17 | 18 | + Create a new directory for your game: 19 | + Unix/OSX : `mkdir ~/Projects/game && cd $_` 20 | + Windows : `mkdir %USERPROFILE%\Projects\game && cd %USERPROFILE%\Projects\game` 21 | 22 | + Invoke the generator: 23 | 24 | `yo phaser-browserify` 25 | 26 | + Run a local development server (livereload, watchify enabled) with this command: 27 | 28 | `npm start` 29 | 30 | *If you have Gulp installed globally you can also use: `gulp`* 31 | 32 | + Package your game (i.e. minify css, html and js) with: 33 | 34 | `npm run build` 35 | 36 | *If you have Gulp installed globally you can also use: `gulp build`* 37 | 38 | 39 | **CREDITS** 40 | 41 | + [@photonstorm](https://github.com/photonstorm/) for creating 42 | [phaser](https://github.com/photonstorm/phaser). 43 | + The guys behind [yeoman](https://github.com/yeoman/yeoman). 44 | + [Gulp.js](http://www.gulpjs.com) 45 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var util = require('util'); 3 | var path = require('path'); 4 | var yeoman = require('yeoman-generator'); 5 | var chalk = require('chalk'); 6 | 7 | 8 | var PhaserGenerator = yeoman.generators.Base.extend({ 9 | init: function () { 10 | this.pkg = require('../package.json'); 11 | 12 | this.on('end', function () { 13 | if (!this.options['skip-install']) { 14 | this.installDependencies(); 15 | } 16 | }); 17 | }, 18 | 19 | askFor: function () { 20 | var done = this.async(); 21 | 22 | this.log(chalk.magenta('... Phaser ...')); 23 | 24 | var prompts = [{ 25 | type: 'input', 26 | name: 'projectName', 27 | message: 'What\'s the name of your game' 28 | }]; 29 | 30 | this.prompt(prompts, function (props) { 31 | this.projectName = props.projectName || ' '; 32 | done(); 33 | }.bind(this)); 34 | }, 35 | 36 | app: function () { 37 | this.mkdir('src'); 38 | this.mkdir('src/assets'); 39 | this.mkdir('src/css'); 40 | this.mkdir('src/js'); 41 | this.mkdir('src/js/entities'); 42 | this.mkdir('src/js/states'); 43 | 44 | this.template('_package.json', 'package.json'); 45 | this.template('_bower.json', 'bower.json'); 46 | 47 | this.copy('bowerrc', '.bowerrc'); 48 | this.copy('_gulpfile.js', 'gulpfile.js'); 49 | }, 50 | 51 | projectfiles: function () { 52 | this.copy('jshintrc', '.jshintrc'); 53 | this.copy('gitignore', '.gitignore'); 54 | 55 | this.copy('src/assets/test.png', 'src/assets/test.png'); 56 | this.copy('src/assets/preloader.gif', 'src/assets/preloader.gif'); 57 | this.copy('src/css/main.css', 'src/css/main.css'); 58 | 59 | this.template('src/js/main.js', 'src/js/main.js'); 60 | this.template('src/js/utils.js', 'src/js/utils.js'); 61 | this.template('src/js/states/boot.js', 'src/js/states/boot.js'); 62 | this.template('src/js/states/game.js', 'src/js/states/game.js'); 63 | this.template('src/js/states/menu.js', 'src/js/states/menu.js'); 64 | this.template('src/js/states/preloader.js', 'src/js/states/preloader.js'); 65 | this.template('src/js/states/splash.js', 'src/js/states/splash.js'); 66 | this.template('src/js/entities/player.js', 'src/js/entities/player.js'); 67 | this.template('src/index.html', 'src/index.html'); 68 | } 69 | }); 70 | 71 | module.exports = PhaserGenerator; 72 | 73 | -------------------------------------------------------------------------------- /app/templates/_bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= _.slugify(projectName) %>", 3 | "version": "0.0.0", 4 | "authors": [ 5 | "" 6 | ], 7 | "dependencies": { 8 | "phaser-official": "latest" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /app/templates/_gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp') 2 | , gutil = require('gulp-util') 3 | , del = require('del') 4 | , concat = require('gulp-concat') 5 | , rename = require('gulp-rename') 6 | , minifycss = require('gulp-minify-css') 7 | , minifyhtml = require('gulp-minify-html') 8 | , processhtml = require('gulp-processhtml') 9 | , jshint = require('gulp-jshint') 10 | , streamify = require('gulp-streamify') 11 | , uglify = require('gulp-uglify') 12 | , connect = require('gulp-connect') 13 | , source = require('vinyl-source-stream') 14 | , browserify = require('browserify') 15 | , watchify = require('watchify') 16 | , gulpif = require('gulp-if') 17 | , vinylPaths = require('vinyl-paths') 18 | , paths; 19 | 20 | var watching = false; 21 | 22 | paths = { 23 | assets: 'src/assets/**/*', 24 | css: 'src/css/*.css', 25 | libs: [ 26 | './node_modules/phaser/dist/phaser.js' 27 | ], 28 | js: ['src/js/*.js', 'src/js/**/*.js'], 29 | entry: './src/js/main.js', 30 | dist: './dist/' 31 | }; 32 | 33 | gulp.task('clean', function () { 34 | return gulp.src(paths.dist) 35 | .pipe(vinylPaths(del)) 36 | .on('error', gutil.log); 37 | }); 38 | 39 | gulp.task('copy', ['clean'], function () { 40 | gulp.src(paths.assets) 41 | .pipe(gulp.dest(paths.dist + 'assets')) 42 | .on('error', gutil.log); 43 | }); 44 | 45 | gulp.task('copylibs', ['clean'], function () { 46 | gulp.src(paths.libs) 47 | .pipe(gulpif(!watching, uglify({outSourceMaps: false}))) 48 | .pipe(gulp.dest(paths.dist + 'js/lib')) 49 | .on('error', gutil.log); 50 | }); 51 | 52 | gulp.task('compile', ['clean'], function () { 53 | var bundler = browserify({ 54 | cache: {}, packageCache: {}, fullPaths: true, 55 | entries: [paths.entry], 56 | debug: watching 57 | }); 58 | 59 | var bundlee = function() { 60 | return bundler 61 | .bundle() 62 | .pipe(source('main.min.js')) 63 | .pipe(jshint('.jshintrc')) 64 | .pipe(jshint.reporter('default')) 65 | .pipe(gulpif(!watching, streamify(uglify({outSourceMaps: false})))) 66 | .pipe(gulp.dest(paths.dist)) 67 | .on('error', gutil.log); 68 | }; 69 | 70 | if (watching) { 71 | bundler = watchify(bundler); 72 | bundler.on('update', bundlee); 73 | } 74 | 75 | return bundlee(); 76 | }); 77 | 78 | gulp.task('minifycss', ['clean'], function () { 79 | gulp.src(paths.css) 80 | .pipe(gulpif(!watching, minifycss({ 81 | keepSpecialComments: false, 82 | removeEmpty: true 83 | }))) 84 | .pipe(rename({suffix: '.min'})) 85 | .pipe(gulp.dest(paths.dist)) 86 | .on('error', gutil.log); 87 | }); 88 | 89 | gulp.task('processhtml', ['clean'], function() { 90 | return gulp.src('src/index.html') 91 | .pipe(processhtml({})) 92 | .pipe(gulp.dest(paths.dist)); 93 | }); 94 | 95 | gulp.task('minifyhtml', ['processhtml'], function() { 96 | gulp.src('dist/index.html') 97 | .pipe(gulpif(!watching, minifyhtml())) 98 | .pipe(gulp.dest(paths.dist)) 99 | .on('error', gutil.log); 100 | }); 101 | 102 | gulp.task('html', ['build'], function(){ 103 | gulp.src('dist/*.html') 104 | .pipe(connect.reload()) 105 | .on('error', gutil.log); 106 | }); 107 | 108 | gulp.task('connect', function () { 109 | connect.server({ 110 | root: ['./dist'], 111 | port: 9000, 112 | livereload: true 113 | }); 114 | }); 115 | 116 | gulp.task('watch', function () { 117 | watching = true; 118 | return gulp.watch(['./src/index.html', paths.css, paths.js], ['build', 'html']); 119 | }); 120 | 121 | gulp.task('default', ['connect', 'watch', 'build']); 122 | gulp.task('build', ['clean', 'copy', 'copylibs', 'compile', 'minifycss', 'processhtml', 'minifyhtml']); 123 | -------------------------------------------------------------------------------- /app/templates/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= _.slugify(projectName) %>", 3 | "description": "", 4 | "readme": "", 5 | "repository": "", 6 | "version": "0.0.0", 7 | "readme": "", 8 | "repository": "", 9 | 10 | "devDependencies": { 11 | "bower": "*", 12 | "gulp": "*", 13 | "gulp-util": "*", 14 | "del": "*", 15 | "gulp-concat": "*", 16 | "gulp-download": "*", 17 | "gulp-rename": "*", 18 | "gulp-minify-css": "*", 19 | "gulp-minify-html": "*", 20 | "gulp-processhtml": "*", 21 | "gulp-jshint": "*", 22 | "gulp-uglify": "*", 23 | "gulp-connect": "*", 24 | "gulp-watch": "*", 25 | "jshint": "^2.9.1", 26 | "browserify": "*", 27 | "tiny-lr": "*", 28 | "vinyl-source-stream": "*", 29 | "gulp-streamify": "*", 30 | "watchify": "*", 31 | "gulp-if": "*", 32 | "vinyl-paths": "*", 33 | "phaser": "*" 34 | }, 35 | 36 | "scripts": { 37 | "start": "node ./node_modules/gulp/bin/gulp.js", 38 | "build": "node ./node_modules/gulp/bin/gulp.js build" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/templates/bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "src/bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /app/templates/gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.db 3 | node_modules/ 4 | bower_components/ 5 | 6 | -------------------------------------------------------------------------------- /app/templates/jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": true, 3 | "laxcomma": true, 4 | "camelcase": true, 5 | "curly": true, 6 | "eqeqeq": true, 7 | "forin": true, 8 | "immed": true, 9 | "latedef": true, 10 | "newcap": true, 11 | "noarg": true, 12 | "nonew": false, 13 | "quotmark": "single", 14 | "undef": true, 15 | "unused": true, 16 | "devel": true, 17 | "trailing": true, 18 | "browser": true, 19 | "sub": true, 20 | "debug": true, 21 | "globals": { 22 | "Phaser": false 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/templates/src/assets/preloader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jroblak/generator-phaser-browserify/24b4df3e2d61e3ad82bc5c089ee6f0ad84a87079/app/templates/src/assets/preloader.gif -------------------------------------------------------------------------------- /app/templates/src/assets/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jroblak/generator-phaser-browserify/24b4df3e2d61e3ad82bc5c089ee6f0ad84a87079/app/templates/src/assets/test.png -------------------------------------------------------------------------------- /app/templates/src/css/main.css: -------------------------------------------------------------------------------- 1 | * { 2 | -webkit-user-select: none; 3 | user-select: none; 4 | } 5 | 6 | html, body { 7 | width: 100%; 8 | height: 100%; 9 | overflow: hidden; 10 | background: #000; 11 | } 12 | 13 | .game { 14 | width: 640px; 15 | height: 480px; 16 | margin: 20px auto; 17 | } 18 | 19 | h1,h2,h3 { 20 | color: #fff; 21 | } 22 | -------------------------------------------------------------------------------- /app/templates/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= _.slugify(projectName) %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/templates/src/js/entities/player.js: -------------------------------------------------------------------------------- 1 | var Player = function (game, x, y) { 2 | Phaser.Sprite.call(this, game, x, y, 'testsprite'); 3 | game.add.existing(this); 4 | } 5 | 6 | Player.prototype = Object.create(Phaser.Sprite.prototype); 7 | Player.prototype.constructor = Player; 8 | 9 | /** 10 | * Automatically called by World.update 11 | */ 12 | Player.prototype.update = function() { 13 | }; 14 | 15 | module.exports = Player; 16 | -------------------------------------------------------------------------------- /app/templates/src/js/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var game = new Phaser.Game(800, 600, Phaser.AUTO, '<%= _.slugify(projectName) %>-game'); 4 | 5 | window.Utils = require('./utils'); 6 | window.playerState = { 7 | currentLevel: 'Game' 8 | } 9 | 10 | game.state.add('Boot', require('./states/boot')); 11 | game.state.add('Splash', require('./states/splash')); 12 | game.state.add('Preloader', require('./states/preloader')); 13 | game.state.add('Menu', require('./states/menu')); 14 | game.state.add('Game', require('./states/game')); 15 | 16 | game.state.start('Boot'); 17 | -------------------------------------------------------------------------------- /app/templates/src/js/states/boot.js: -------------------------------------------------------------------------------- 1 | var Boot = function () {}; 2 | 3 | module.exports = Boot; 4 | 5 | Boot.prototype = { 6 | 7 | preload: function () { 8 | this.load.image('preloader', 'assets/preloader.gif'); 9 | }, 10 | 11 | create: function () { 12 | this.game.input.maxPointers = 1; 13 | 14 | if (this.game.device.desktop) { 15 | this.game.stage.scale.pageAlignHorizontally = true; 16 | } else { 17 | this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; 18 | this.game.scale.minWidth = 480; 19 | this.game.scale.minHeight = 260; 20 | this.game.scale.maxWidth = 640; 21 | this.game.scale.maxHeight = 480; 22 | this.game.scale.forceLandscape = true; 23 | this.game.scale.pageAlignHorizontally = true; 24 | this.game.scale.setScreenSize(true); 25 | } 26 | 27 | this.game.state.start('Preloader'); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /app/templates/src/js/states/game.js: -------------------------------------------------------------------------------- 1 | var Player = require('../entities/player'); 2 | 3 | var Game = function () { 4 | this.testentity = null; 5 | }; 6 | 7 | module.exports = Game; 8 | 9 | Game.prototype = { 10 | 11 | create: function () { 12 | var x = (this.game.width / 2) - 100; 13 | var y = (this.game.height / 2) - 50; 14 | 15 | this.testentity = new Player(this.game, x, y); 16 | this.testentity.anchor.setTo(0.5, 0.5); 17 | 18 | this.input.onDown.add(this.onInputDown, this); 19 | }, 20 | 21 | update: function () { 22 | var x, y, cx, cy, dx, dy, angle, scale; 23 | 24 | x = this.input.position.x; 25 | y = this.input.position.y; 26 | cx = this.world.centerX; 27 | cy = this.world.centerY; 28 | 29 | angle = Math.atan2(y - cy, x - cx) * (180 / Math.PI); 30 | this.testentity.angle = angle; 31 | 32 | dx = x - cx; 33 | dy = y - cy; 34 | scale = Math.sqrt(dx * dx + dy * dy) / 100; 35 | 36 | this.testentity.scale.x = scale * 0.6; 37 | this.testentity.scale.y = scale * 0.6; 38 | }, 39 | 40 | onInputDown: function () { 41 | this.game.state.start('Menu'); 42 | } 43 | }; 44 | -------------------------------------------------------------------------------- /app/templates/src/js/states/menu.js: -------------------------------------------------------------------------------- 1 | var Menu = function () { 2 | this.text = null; 3 | }; 4 | 5 | module.exports = Menu; 6 | 7 | Menu.prototype = { 8 | 9 | create: function () { 10 | var x = this.game.width / 2; 11 | var y = this.game.height / 2; 12 | 13 | var style = { font: "65px Arial", fill: "#ffffff", align: "center" }; 14 | 15 | this.text = this.add.text(x - 300, y - 200, "Press to Start", style); 16 | 17 | this.input.onDown.add(this.onDown, this); 18 | }, 19 | 20 | update: function () { 21 | }, 22 | 23 | onDown: function () { 24 | this.game.state.start(playerState.currentLevel); 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /app/templates/src/js/states/preloader.js: -------------------------------------------------------------------------------- 1 | var Preloader = function (game) { 2 | this.asset = null; 3 | this.ready = false; 4 | }; 5 | 6 | module.exports = Preloader; 7 | 8 | Preloader.prototype = { 9 | 10 | preload: function () { 11 | this.asset = this.add.sprite(320, 240, 'preloader'); 12 | this.asset.anchor.setTo(0.5, 0.5); 13 | 14 | this.load.onLoadComplete.addOnce(this.onLoadComplete, this); 15 | this.load.setPreloadSprite(this.asset); 16 | this.load.image('testsprite', 'assets/test.png'); 17 | }, 18 | 19 | create: function () { 20 | this.asset.cropEnabled = false; 21 | }, 22 | 23 | update: function () { 24 | if (!!this.ready) { 25 | this.game.state.start('Menu'); 26 | } 27 | }, 28 | 29 | onLoadComplete: function () { 30 | this.ready = true; 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /app/templates/src/js/states/splash.js: -------------------------------------------------------------------------------- 1 | var Splash = function () { 2 | }; 3 | 4 | module.exports = Splash; 5 | 6 | Splash.prototype = { 7 | create: function () { 8 | } 9 | }; -------------------------------------------------------------------------------- /app/templates/src/js/utils.js: -------------------------------------------------------------------------------- 1 | var Utils = { 2 | containsObject: function(obj, list) { 3 | var i; 4 | for (i = 0; i < list.length; i++) { 5 | if (list[i] === obj) { 6 | return true; 7 | } 8 | } 9 | 10 | return false; 11 | } 12 | }; 13 | 14 | module.exports = Utils; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-phaser-browserify", 3 | "version": "0.3.6", 4 | "description": "A Yeoman generator to generate HTML5 games with phaser.js using Gulp and Browserify", 5 | 6 | "keywords": [ 7 | "yeoman-generator", 8 | "phaser", 9 | "yeoman-generator-gulp", 10 | "phaser gulp", 11 | "phaser browserify" 12 | ], 13 | 14 | "homepage": "https://github.com/jroblak/generator-phaser-browserify", 15 | "bugs": "https://github.com/jroblak/generator-phaser-browserify/issues", 16 | 17 | "author": { 18 | "name": "Justin Oblak", 19 | "email": "j@justinoblak.com", 20 | "url": "http://justinoblak.com" 21 | }, 22 | 23 | "contributors": [{ 24 | "name": "Justin Oblak", 25 | "email": "j@justinoblak.com", 26 | "url": "http://justinoblak.com" 27 | }], 28 | 29 | "main": "app/index.js", 30 | 31 | "files": [ 32 | "app" 33 | ], 34 | 35 | "repository": { 36 | "type": "git", 37 | "url": "git://github.com/jroblak/generator-phaser-browserify.git" 38 | }, 39 | 40 | "scripts": { 41 | "test": "mocha" 42 | }, 43 | 44 | "dependencies": { 45 | "yeoman-generator": "~0.16.0", 46 | "chalk": "~0.4.0" 47 | }, 48 | 49 | "devDependencies": { 50 | "mocha": "*" 51 | }, 52 | 53 | "peerDependencies": { 54 | "yo": ">=1.0.0" 55 | }, 56 | 57 | "engines": { 58 | "node": ">=0.8.0", 59 | "npm": ">=1.2.10" 60 | }, 61 | 62 | "licenses": [ 63 | { 64 | "type": "MIT" 65 | } 66 | ] 67 | } 68 | -------------------------------------------------------------------------------- /test/test-creation.js: -------------------------------------------------------------------------------- 1 | /*global describe, beforeEach, it */ 2 | 'use strict'; 3 | var path = require('path'); 4 | var helpers = require('yeoman-generator').test; 5 | 6 | describe('phaser generator', function () { 7 | beforeEach(function (done) { 8 | helpers.testDirectory(path.join(__dirname, 'temp'), function (err) { 9 | if (err) { 10 | return done(err); 11 | } 12 | 13 | this.app = helpers.createGenerator('phaser:app', [ 14 | '../../app' 15 | ]); 16 | done(); 17 | }.bind(this)); 18 | }); 19 | 20 | it('creates expected files', function (done) { 21 | var expected = [ 22 | // add files you expect to exist here. 23 | '.jshintrc', 24 | '.gitignore', 25 | '.bowerrc', 26 | 'gulpfile.js', 27 | 'src/assets/test.png', 28 | 'src/assets/preloader.gif', 29 | 'src/css/main.css', 30 | 'src/js/main.js', 31 | 'src/js/util.js', 32 | 'src/js/states/boot.js', 33 | 'src/js/states/menu.js', 34 | 'src/js/states/preloader.js', 35 | 'src/js/states/splash.js', 36 | 'src/js/states/game.js', 37 | 'src/js/entities/player.js', 38 | 'src/index.html' 39 | ]; 40 | 41 | helpers.mockPrompt(this.app, { 42 | 'someOption': true 43 | }); 44 | this.app.options['skip-install'] = true; 45 | this.app.run({}, function () { 46 | helpers.assertFile(expected); 47 | done(); 48 | }); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /test/test-load.js: -------------------------------------------------------------------------------- 1 | /*global describe, beforeEach, it*/ 2 | 'use strict'; 3 | var assert = require('assert'); 4 | 5 | describe('phaser generator', function () { 6 | it('can be imported without blowing up', function () { 7 | var app = require('../app'); 8 | assert(app !== undefined); 9 | }); 10 | }); 11 | --------------------------------------------------------------------------------