From 20087529b9e3bfbfe34330e538b968048324ab95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ellison=20Lea=CC=83o?= Date: Tue, 25 Feb 2014 20:58:32 -0300 Subject: [PATCH] initial files --- .editorconfig | 13 +++++++++ .gitattributes | 1 + .gitignore | 2 ++ .jshintrc | 21 ++++++++++++++ .travis.yml | 7 +++++ README.md | 49 ++++++++++++++++++++++++++++++-- app/index.js | 56 +++++++++++++++++++++++++++++++++++++ app/templates/_bower.json | 6 ++++ app/templates/_package.json | 5 ++++ app/templates/editorconfig | 13 +++++++++ app/templates/jshintrc | 21 ++++++++++++++ package.json | 35 +++++++++++++++++++++++ test/test-creation.js | 36 ++++++++++++++++++++++++ test/test-load.js | 10 +++++++ 14 files changed, 272 insertions(+), 3 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 .travis.yml create mode 100644 app/index.js create mode 100644 app/templates/_bower.json create mode 100644 app/templates/_package.json create mode 100644 app/templates/editorconfig create mode 100644 app/templates/jshintrc create mode 100644 package.json create mode 100644 test/test-creation.js create mode 100644 test/test-load.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e717f5e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..31226a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +temp/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..0cd291c --- /dev/null +++ b/.jshintrc @@ -0,0 +1,21 @@ +{ + "node": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "white": true +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e6ce520 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - '0.10' +before_install: + - currentfolder=${PWD##*/} + - if [ "$currentfolder" != 'generator-melonjs' ]; then cd .. && eval "mv $currentfolder generator-melonjs" && cd generator-melonjs; fi + diff --git a/README.md b/README.md index 9513308..ff70b25 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,47 @@ -generator-melonjs -================= +# generator-melonjs [![Build Status](https://secure.travis-ci.org/ellisonleao/generator-melonjs.png?branch=master)](https://travis-ci.org/ellisonleao/generator-melonjs) -A Yeoman generator for MelonJS projects +> [Yeoman](http://yeoman.io) generator + + +## Getting Started + +### What is Yeoman? + +Trick question. It's not a thing. It's this guy: + +![](http://i.imgur.com/JHaAlBJ.png) + +Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create. + +Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.* + +``` +$ npm install -g yo +``` + +### Yeoman Generators + +Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension. + +To install generator-melonjs from npm, run: + +``` +$ npm install -g generator-melonjs +``` + +Finally, initiate the generator: + +``` +$ yo melonjs +``` + +### Getting To Know Yeoman + +Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced. + +If you'd like to get to know Yeoman better and meet some of his friends, [Grunt](http://gruntjs.com) and [Bower](http://bower.io), check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started). + + +## License + +MIT diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..519a422 --- /dev/null +++ b/app/index.js @@ -0,0 +1,56 @@ +'use strict'; +var util = require('util'); +var path = require('path'); +var yeoman = require('yeoman-generator'); +var chalk = require('chalk'); + + +var MelonjsGenerator = yeoman.generators.Base.extend({ + init: function () { + this.pkg = yeoman.file.readJSON(path.join(__dirname, '../package.json')); + + this.on('end', function () { + if (!this.options['skip-install']) { + this.npmInstall(); + } + }); + }, + + askFor: function () { + var done = this.async(); + + // have Yeoman greet the user + console.log(this.yeoman); + + // replace it with a short and sweet description of your generator + console.log(chalk.magenta('Hello! I hope you can make great games')); + + var prompts = [ + { + name: 'gameName', + message: 'What\'s the name of your game?' + }, + ]; + + this.prompt(prompts, function (props) { + this.gameName = props.gameName; + + done(); + }.bind(this)); + }, + + app: function () { + this.mkdir('app'); + this.mkdir('app/templates'); + + this.copy('_package.json', 'package.json'); + this.copy('_bower.json', 'bower.json'); + }, + + projectfiles: function () { + this.copy('editorconfig', '.editorconfig'); + this.copy('jshintrc', '.jshintrc'); + } +}); + +module.exports = MelonjsGenerator; \ No newline at end of file diff --git a/app/templates/_bower.json b/app/templates/_bower.json new file mode 100644 index 0000000..2b4eb38 --- /dev/null +++ b/app/templates/_bower.json @@ -0,0 +1,6 @@ +{ + "name": "package", + "version": "0.0.0", + "dependencies": {} +} + diff --git a/app/templates/_package.json b/app/templates/_package.json new file mode 100644 index 0000000..fba8e01 --- /dev/null +++ b/app/templates/_package.json @@ -0,0 +1,5 @@ +{ + "name": "package", + "version": "0.0.0", + "dependencies": {} +} diff --git a/app/templates/editorconfig b/app/templates/editorconfig new file mode 100644 index 0000000..e717f5e --- /dev/null +++ b/app/templates/editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/app/templates/jshintrc b/app/templates/jshintrc new file mode 100644 index 0000000..0cd291c --- /dev/null +++ b/app/templates/jshintrc @@ -0,0 +1,21 @@ +{ + "node": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "white": true +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..69c3295 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "generator-melonjs", + "version": "0.1.0", + "description": "A MelonJS Yeoman generator", + "license": "MIT", + "main": "app/index.js", + "repository": "ellisonleao/generator-melonjs", + "author": { + "name": "Ellison Leão", + "email": "ellisonleao@gmail.com", + "url": "https://github.com/ellisonleao" + }, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha" + }, + "files": [ + "app" + ], + "keywords": [ + "yeoman-generator" + ], + "dependencies": { + "yeoman-generator": "~0.16.0", + "chalk": "~0.4.0" + }, + "devDependencies": { + "mocha": "*" + }, + "peerDependencies": { + "yo": ">=1.0.0" + } +} diff --git a/test/test-creation.js b/test/test-creation.js new file mode 100644 index 0000000..ea40257 --- /dev/null +++ b/test/test-creation.js @@ -0,0 +1,36 @@ +/*global describe, beforeEach, it */ +'use strict'; +var path = require('path'); +var helpers = require('yeoman-generator').test; + +describe('melonjs generator', function () { + beforeEach(function (done) { + helpers.testDirectory(path.join(__dirname, 'temp'), function (err) { + if (err) { + return done(err); + } + + this.app = helpers.createGenerator('melonjs:app', [ + '../../app' + ]); + done(); + }.bind(this)); + }); + + it('creates expected files', function (done) { + var expected = [ + // add files you expect to exist here. + '.jshintrc', + '.editorconfig' + ]; + + helpers.mockPrompt(this.app, { + 'someOption': true + }); + this.app.options['skip-install'] = true; + this.app.run({}, function () { + helpers.assertFile(expected); + done(); + }); + }); +}); diff --git a/test/test-load.js b/test/test-load.js new file mode 100644 index 0000000..3dc7364 --- /dev/null +++ b/test/test-load.js @@ -0,0 +1,10 @@ +/*global describe, beforeEach, it*/ +'use strict'; +var assert = require('assert'); + +describe('melonjs generator', function () { + it('can be imported without blowing up', function () { + var app = require('../app'); + assert(app !== undefined); + }); +});