From d775b257368fdfffd4f29673758bec6468cc70b0 Mon Sep 17 00:00:00 2001 From: Shawn Meyer Date: Thu, 17 Oct 2013 08:54:19 -0500 Subject: [PATCH 1/7] Fixing npm tests and adding miss dir structure --- app/index.js | 3 +++ test/test-creation.js | 15 +++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/index.js b/app/index.js index fd3122a..ace9114 100644 --- a/app/index.js +++ b/app/index.js @@ -37,6 +37,9 @@ CraftyGenerator.prototype.app = function app() { }; CraftyGenerator.prototype.projectfiles = function projectfiles() { + this.mkdir('app/web/css'); + this.mkdir('app/web/images'); + this.copy('_.editorconfig', '.editorconfig'); this.copy('_.jshintrc', '.jshintrc'); diff --git a/test/test-creation.js b/test/test-creation.js index 5208a3e..5f3e04c 100644 --- a/test/test-creation.js +++ b/test/test-creation.js @@ -21,24 +21,19 @@ describe('crafty generator', function () { it('creates expected files', function (done) { var expected = [ - '.jshintrc', + '.bowerrc', '.editorconfig', - 'Gruntfile.js', - 'package.json', + '.jshintrc', 'bower.json', - 'index.html', + 'Gruntfile.js', + 'package.json', + 'app/index.html', 'app/src/config.js', 'app/src/game.js', 'app/src/sprites.js', 'app/src/components/MouseHover.js', 'app/src/entities/base/BaseEntity.js', 'app/src/interfaces/info.js', - 'app/src/libs/backbone-0.9.2.min.js', - 'app/src/libs/crafty-0.4.9.js', - 'app/src/libs/jquery-1.7.2.min.js', - 'app/src/libs/modernizr-2.5.3.min.js', - 'app/src/libs/require-jquery.js', - 'app/src/libs/underscore-1.3.4.min.js', 'app/src/scenes/main.js' ]; From f359671c211900d83227dcbf9bb95515e239b55d Mon Sep 17 00:00:00 2001 From: Shawn Meyer Date: Thu, 17 Oct 2013 11:47:53 -0500 Subject: [PATCH 2/7] Adding better build for copy and minify --- app/index.js | 3 + app/templates/_Gruntfile.js | 79 +- app/templates/_bower.json | 3 +- app/templates/_index.html | 12 +- app/templates/src/libs/Crafty/_crafty.js | 10822 +++++++++++++++++ app/templates/src/libs/Crafty/_crafty.min.js | 12 + 6 files changed, 10911 insertions(+), 20 deletions(-) create mode 100644 app/templates/src/libs/Crafty/_crafty.js create mode 100644 app/templates/src/libs/Crafty/_crafty.min.js diff --git a/app/index.js b/app/index.js index ace9114..7c6a7a8 100644 --- a/app/index.js +++ b/app/index.js @@ -50,6 +50,9 @@ CraftyGenerator.prototype.projectfiles = function projectfiles() { this.copy('src/entities/base/_BaseEntity.js', 'app/src/entities/base/BaseEntity.js'); this.copy('src/interfaces/_info.js', 'app/src/interfaces/info.js'); this.copy('src/scenes/_main.js', 'app/src/scenes/main.js'); + + this.copy('src/libs/crafty/_crafty.js', 'app/src/libs/crafty/crafty.js'); + this.copy('src/libs/crafty/_crafty.min.js', 'app/src/libs/crafty/crafty.min.js'); }; CraftyGenerator.prototype.gruntfileJSON = function gruntfile() { diff --git a/app/templates/_Gruntfile.js b/app/templates/_Gruntfile.js index a1b1d38..d43eacb 100644 --- a/app/templates/_Gruntfile.js +++ b/app/templates/_Gruntfile.js @@ -6,21 +6,76 @@ var mountFolder = function (connect, dir) { module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - clean: ['build/'], + clean: { + release:['build/dev/'], + dev:['build/release/'] + }, uglify: { - options: { - banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' - }, - build: { - src: ['src/**/*.js', '!src/libs/**'], - dest: 'build/src/<%= pkg.name %>.min.js' - } + options: { + banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' + }, + build: { + files: [{ + expand: true, + flatten: true, + cwd: 'app/src/libs/', + src: 'jquery/jquery.js', + dest: 'build/dev/src/libs/', + ext: '.min.js' + }, + { + expand: true, + flatten: true, + cwd: 'app/src/libs/', + src: 'modernizr/modernizr.js', + dest: 'build/dev/src/libs/', + ext: '.min.js' + }, + { + 'build/dev/src/libs/requirejs-jquery.min.js': ['app/src/libs/requirejs-jquery/parts/require.js', 'app/src/libs/requirejs-jquery/parts/query.js'] + }] + } }, copy: { dev: { files: [{ - src: 'src/libs/*.js', - dest: 'build/' + expand: true, + flatten: true, + cwd: 'app/src/libs/', + src: 'backbone/backbone-min.js', + dest: 'build/dev/src/libs/', + filter: 'isFile' + }, + { + expand: true, + flatten: true, + cwd: 'app/src/libs/', + src: 'crafty/crafty.min.js', + dest: 'build/dev/src/libs/', + filter: 'isFile' + }, + { + expand: true, + flatten: true, + cwd: 'app/src/libs/', + src: 'underscore/underscore-min.js', + dest: 'build/dev/src/libs/', + filter: 'isFile' + }, + { + expand: true, + cwd: 'app/src/', + src: ['**/*.js', '!libs/**'], + dest: 'build/dev/src/', + filter: 'isFile' + }, + { + expand: true, + flatten: true, + cwd: 'app/', + src: 'index.html', + dest: 'build/dev/', + filter: 'isFile' }] } }, @@ -29,7 +84,7 @@ module.exports = function(grunt) { options: { port: 8888, hostname: 'localhost', - base: "app" + base: "build/dev" } }, livereload: { @@ -72,4 +127,4 @@ module.exports = function(grunt) { grunt.registerTask('build', ['clean', 'uglify', 'copy']); grunt.registerTask('server', ['build', 'connect:server', 'open', 'watch']); grunt.registerTask('default', ['build', 'server']); -} \ No newline at end of file +} diff --git a/app/templates/_bower.json b/app/templates/_bower.json index 2cf8f14..a85f924 100644 --- a/app/templates/_bower.json +++ b/app/templates/_bower.json @@ -8,7 +8,6 @@ "underscore": "~1.5.2", "backbone": "~1.1.0", "modernizr": "~2.6.2", - "requirejs-jquery": "~0.25.0", - "crafty": "~0.5.4" + "requirejs-jquery": "~0.25.0" } } \ No newline at end of file diff --git a/app/templates/_index.html b/app/templates/_index.html index ad0ffd8..db7ff9a 100755 --- a/app/templates/_index.html +++ b/app/templates/_index.html @@ -11,7 +11,7 @@ <%= gameName %> - + @@ -19,11 +19,11 @@ - - - - - + + + + + + @@ -19,13 +19,13 @@ - - - - - + + + + + - + - \ No newline at end of file + From 2c9cb144a8412cf768d5dba19aaf70075aa8177b Mon Sep 17 00:00:00 2001 From: Shawn Meyer Date: Thu, 17 Oct 2013 14:20:53 -0500 Subject: [PATCH 5/7] Fixing grunt server command and adding live reload --- app/templates/_Gruntfile.js | 26 ++++++++++++-------------- app/templates/_index.html | 4 ++-- app/templates/_package.json | 3 +-- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/templates/_Gruntfile.js b/app/templates/_Gruntfile.js index 31f42e5..05a90da 100644 --- a/app/templates/_Gruntfile.js +++ b/app/templates/_Gruntfile.js @@ -52,8 +52,7 @@ module.exports = function(grunt) { livereload: { options: { middleware: function (connect) { - return [ - require('connect-livereload')({port: LIVERELOAD_PORT}), + return [require('connect-livereload')({port: LIVERELOAD_PORT}), mountFolder(connect, '.') ]; } @@ -66,16 +65,14 @@ module.exports = function(grunt) { } }, watch: { - options: { - nospawn: true, - livereload: LIVERELOAD_PORT - }, - livereload: { - files: [ - 'app/index.html' - ], - tasks: ['build'] - } + html: { + options: { livereload: true }, + files: ['app/index.html'], + }, + js: { + options: { livereload: true }, + files: ['app/src/**/*.js'] + } } }); @@ -84,9 +81,10 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-livereload'); grunt.loadNpmTasks('grunt-open'); - grunt.registerTask('build:dev', ['clean', 'uglify', 'copy']); + grunt.registerTask('build', ['clean', 'uglify', 'copy']); grunt.registerTask('server', ['connect:server', 'open', 'watch']); - grunt.registerTask('default', ['build', 'server']); + grunt.registerTask('default', ['server']); } diff --git a/app/templates/_index.html b/app/templates/_index.html index 0dbdce4..219fae4 100755 --- a/app/templates/_index.html +++ b/app/templates/_index.html @@ -8,7 +8,7 @@ - mocha + <<%= gameName % @@ -25,7 +25,6 @@ - + diff --git a/app/templates/_package.json b/app/templates/_package.json index 45795b3..51fc86d 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -13,7 +13,6 @@ "grunt-contrib-copy": "~0.4.1", "grunt-contrib-connect": "~0.5.0", "grunt-contrib-watch": "~0.5.3", - "grunt-open": "~0.2.2", - "connect-livereload": "~0.3.0" + "grunt-open": "~0.2.2" } } From 03de8fb7d098931e6ef170d4843f581717f2532b Mon Sep 17 00:00:00 2001 From: Shawn Meyer Date: Thu, 17 Oct 2013 14:25:13 -0500 Subject: [PATCH 6/7] Fixing game name in the index.html title --- app/templates/_index.html | 2 +- app/templates/_package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/_index.html b/app/templates/_index.html index 219fae4..627d0f1 100755 --- a/app/templates/_index.html +++ b/app/templates/_index.html @@ -8,7 +8,7 @@ - <<%= gameName % + <%= gameName %> diff --git a/app/templates/_package.json b/app/templates/_package.json index 51fc86d..edd85a1 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -15,4 +15,4 @@ "grunt-contrib-watch": "~0.5.3", "grunt-open": "~0.2.2" } -} +} \ No newline at end of file From ede8ab9cbb1d5aa957069f80b25c92e4d399e998 Mon Sep 17 00:00:00 2001 From: Shawn Meyer Date: Thu, 17 Oct 2013 14:33:20 -0500 Subject: [PATCH 7/7] updating package.json for first alpha node deployment. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 756400a..5f94e5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "generator-crafty", - "version": "0.0.0", + "version": "0.1.0", "description": "A Crafty.js generator for Yeoman. Provides Craft.js scaffolding based on CraftyBoilerplate (https://github.com/ahilles107/CraftyBoilerplate)", "keywords": [ "yeoman-generator", @@ -14,8 +14,8 @@ "bugs": "https://github.com/sgmeyer/generator-crafty/issues", "author": { "name": "Shawn Meyer", - "email": "shawn@shawnmeyer.com", - "url": "https://github.com/sgmeyer" + "email": "sgmeyer@gmail.com", + "url": "https://www.shawnmeyer.com" }, "main": "app/index.js", "repository": {