diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c308ed0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 4 +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..fa51fc3 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,21 @@ +{ + "node": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 4, + "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..aececc5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - '0.8' + - '0.10' +before_install: + - currentfolder=${PWD##*/} + - if [ "$currentfolder" != 'generator-ionic' ]; then cd .. && eval "mv $currentfolder generator-ionic" && cd generator-ionic; fi + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..208b5c4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright 2013 Diego Netto + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0c04ae1 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# generator-ionic [![Build Status](https://secure.travis-ci.org/diegonetto/generator-ionic.png?branch=master)](https://travis-ci.org/diegonetto/generator-ionic) + +A generator for [Yeoman](http://yeoman.io). + + +## 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-ionic from npm, run: + +``` +$ npm install -g generator-ionic +``` + +Finally, initiate the generator: + +``` +$ yo ionic +``` + +### 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 License](http://en.wikipedia.org/wiki/MIT_License) diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..6e60f90 --- /dev/null +++ b/app/index.js @@ -0,0 +1,50 @@ +'use strict'; +var util = require('util'); +var path = require('path'); +var yeoman = require('yeoman-generator'); + + +var IonicGenerator = module.exports = function IonicGenerator(args, options, config) { + yeoman.generators.Base.apply(this, arguments); + + this.on('end', function () { + this.installDependencies({ skipInstall: options['skip-install'] }); + }); + + this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); +}; + +util.inherits(IonicGenerator, yeoman.generators.Base); + +IonicGenerator.prototype.askFor = function askFor() { + var cb = this.async(); + + // have Yeoman greet the user. + console.log(this.yeoman); + + var prompts = [{ + type: 'confirm', + name: 'someOption', + message: 'Would you like to enable this option?', + default: true + }]; + + this.prompt(prompts, function (props) { + this.someOption = props.someOption; + + cb(); + }.bind(this)); +}; + +IonicGenerator.prototype.app = function app() { + this.mkdir('app'); + this.mkdir('app/templates'); + + this.copy('_package.json', 'package.json'); + this.copy('_bower.json', 'bower.json'); +}; + +IonicGenerator.prototype.projectfiles = function projectfiles() { + this.copy('editorconfig', '.editorconfig'); + this.copy('jshintrc', '.jshintrc'); +}; 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..c308ed0 --- /dev/null +++ b/app/templates/editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 4 +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..fa51fc3 --- /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": 4, + "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..e0c94d9 --- /dev/null +++ b/package.json @@ -0,0 +1,41 @@ +{ + "name": "generator-ionic", + "version": "0.0.0", + "description": "A generator for Yeoman", + "keywords": [ + "yeoman-generator" + ], + "homepage": "https://github.com/diegonetto/generator-ionic", + "bugs": "https://github.com/diegonetto/generator-ionic/issues", + "author": { + "name": "Diego Netto", + "email": "diegormnetto@gmail.com", + "url": "https://github.com/diegonetto" + }, + "main": "app/index.js", + "repository": { + "type": "git", + "url": "git://github.com/diegonetto/generator-ionic.git" + }, + "scripts": { + "test": "mocha" + }, + "dependencies": { + "yeoman-generator": "~0.14.0" + }, + "devDependencies": { + "mocha": "~1.14.0" + }, + "peerDependencies": { + "yo": ">=1.0.0" + }, + "engines": { + "node": ">=0.8.0", + "npm": ">=1.2.10" + }, + "licenses": [ + { + "type": "MIT" + } + ] +} diff --git a/test/test-creation.js b/test/test-creation.js new file mode 100644 index 0000000..7738dbb --- /dev/null +++ b/test/test-creation.js @@ -0,0 +1,38 @@ +/*global describe, beforeEach, it*/ +'use strict'; + +var path = require('path'); +var helpers = require('yeoman-generator').test; + + +describe('ionic generator', function () { + beforeEach(function (done) { + helpers.testDirectory(path.join(__dirname, 'temp'), function (err) { + if (err) { + return done(err); + } + + this.app = helpers.createGenerator('ionic: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.assertFiles(expected); + done(); + }); + }); +}); diff --git a/test/test-load.js b/test/test-load.js new file mode 100644 index 0000000..e32ae4a --- /dev/null +++ b/test/test-load.js @@ -0,0 +1,11 @@ +/*global describe, beforeEach, it*/ +'use strict'; + +var assert = require('assert'); + +describe('ionic generator', function () { + it('can be imported without blowing up', function () { + var app = require('../app'); + assert(app !== undefined); + }); +});