Permalink
Browse files

Basic project generator setup

TODO:

- App tests
- Generator tests
- Component generator

Signed-off-by: Simon Bailey <simon@newtriks.com>
  • Loading branch information...
0 parents commit b1562cd74c8b7332c82bbdeaea0dbd2df8e33705 @newtriks newtriks committed Jan 7, 2014
@@ -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
@@ -0,0 +1 @@
+* text=auto
@@ -0,0 +1,31 @@
+### SublimeText ###
+*.sublime-workspace
+
+### OSX ###
+.DS_Store
+.AppleDouble
+.LSOverride
+Icon
+
+# Thumbnails
+._*
+
+# Files that might appear on external disk
+.Spotlight-V100
+.Trashes
+
+### Windows ###
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+
+# Folder config file
+Desktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# App specific
+
+node_modules/
+temp/
@@ -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
+}
@@ -0,0 +1,8 @@
+language: node_js
+node_js:
+ - '0.8'
+ - '0.10'
+before_install:
+ - currentfolder=${PWD##*/}
+ - if [ "$currentfolder" != 'generator-react-webpack' ]; then cd .. && eval "mv $currentfolder generator-react-webpack" && cd generator-react-webpack; fi
+
@@ -0,0 +1,20 @@
+Copyright 2014 Simon Bailey
+
+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.
@@ -0,0 +1,47 @@
+# generator-react-webpack [![Build Status](https://secure.travis-ci.org/newtriks/generator-react-webpack.png?branch=master)](https://travis-ci.org/newtriks/generator-react-webpack)
+
+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-react-webpack from npm, run:
+
+```
+$ npm install -g generator-react-webpack
+```
+
+Finally, initiate the generator:
+
+```
+$ yo react-webpack
+```
+
+### 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)
@@ -0,0 +1,74 @@
+'use strict';
+var util = require('util');
+var path = require('path');
+var yeoman = require('yeoman-generator');
+var generalUtils = require('../util.js');
+
+var ReactWebpackGenerator = module.exports = function ReactWebpackGenerator(args, options, config) {
+ yeoman.generators.Base.apply(this, arguments);
+
+ this.argument('appname', { type: String, required: false });
+ this.appname = this.appname || path.basename(process.cwd());
+ this.appname = this._.camelize(this._.slugify(this._.humanize(this.appname)));
+ this.scriptAppName = this._.capitalize(this.appname) + generalUtils.appName(this);
+
+ args = ['main'];
+
+ if (typeof this.env.options.appPath === 'undefined') {
+ this.env.options.appPath = this.env.options.appPath || 'src';
+ }
+
+ this.appPath = this.env.options.appPath;
+
+ this.hookFor('react-webpack:common', {
+ args: args
+ });
+
+ this.hookFor('react-webpack:main', {
+ args: args
+ });
+
+ this.on('end', function () {
+ this.installDependencies({ skipInstall: options['skip-install'] });
+ });
+
+ this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
+};
+
+util.inherits(ReactWebpackGenerator, yeoman.generators.Base);
+
+ReactWebpackGenerator.prototype.welcome = function welcome() {
+ // welcome message
+ if (!this.options['skip-welcome-message']) {
+ console.log(this.yeoman);
+ console.log(
+ 'Out of the box I include Webpack and some default React components.\n'
+ );
+ }
+};
+
+ReactWebpackGenerator.prototype.readIndex = function readIndex() {
+ this.indexFile = this.engine(this.read('../../templates/common/index.html'), this);
+};
+
+ReactWebpackGenerator.prototype.createIndexHtml = function createIndexHtml() {
+ this.indexFile = this.indexFile.replace(/&apos;/g, "'");
+ this.write(path.join(this.appPath, 'index.html'), this.indexFile);
+};
+
+ReactWebpackGenerator.prototype.packageFiles = function () {
+ this.template('../../templates/common/_package.json', 'package.json');
+ this.copy('../../templates/common/Gruntfile.js', 'Gruntfile.js');
+};
+
+ReactWebpackGenerator.prototype.styleFiles = function styleFiles() {
+ var mainFile = 'main.css';
+ var resetFile = 'reset.css';
+ this.copy('styles/' + mainFile, 'src/styles/' + mainFile);
+ this.copy('styles/' + resetFile, 'src/styles/' + resetFile);
+};
+
+ReactWebpackGenerator.prototype.imageFiles = function () {
+ this.sourceRoot(path.join(__dirname, 'templates'));
+ this.directory('images', 'src/images', true);
+};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,41 @@
+/* Stiziles */
+
+html, body {
+ background: #222222;
+}
+
+/* main */
+
+.main {
+ width: 100%;
+ height: 100%;
+ background: #222222;
+ color: #fff;
+}
+
+.main img {
+ width: 103px;
+ height: 89px;
+ margin-bottom: 10px;
+ text-align: center;
+}
+
+/* transitions */
+
+.fade-enter {
+ opacity: 0.01;
+ transition: opacity .5s ease-in;
+}
+
+.fade-enter.fade-enter-active {
+ opacity: 1;
+}
+
+.fade-leave {
+ opacity: 1;
+ transition: opacity .5s ease-in;
+}
+
+.fade-leave.fade-leave-active {
+ opacity: 0.01;
+}
@@ -0,0 +1,48 @@
+/* http://meyerweb.com/eric/tools/css/reset/
+ v2.0 | 20110126
+ License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed,
+figure, figcaption, footer, header, hgroup,
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ font-size: 100%;
+ font: inherit;
+ vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure,
+footer, header, hgroup, menu, nav, section {
+ display: block;
+}
+body {
+ line-height: 1;
+}
+ol, ul {
+ list-style: none;
+}
+blockquote, q {
+ quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+ content: '';
+ content: none;
+}
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
@@ -0,0 +1,17 @@
+'use strict';
+var path = require('path');
+var util = require('util');
+var yeoman = require('yeoman-generator');
+
+var CommonGenerator = module.exports = function CommonGenerator(args, options, config) {
+ yeoman.generators.NamedBase.apply(this, arguments);
+};
+
+util.inherits(CommonGenerator, yeoman.generators.NamedBase);
+
+CommonGenerator.prototype.setupEnv = function setupEnv() {
+ // Copies the contents of the generator `templates`
+ // directory into your users new application path
+ this.sourceRoot(path.join(__dirname, '../templates/common'));
+ this.directory('root', '.', true);
+};
@@ -0,0 +1,13 @@
+'use strict';
+var util = require('util');
+var ScriptBase = require('../script-base.js');
+
+var MainGenerator = module.exports = function MainGenerator(args, options, config) {
+ ScriptBase.apply(this, arguments);
+};
+
+util.inherits(MainGenerator, ScriptBase);
+
+MainGenerator.prototype.createAppFile = function createAppFile() {
+ this.appTemplate('app', 'scripts/components/'+this.scriptAppName);
+};
@@ -0,0 +1,41 @@
+{
+ "name": "generator-react-webpack",
+ "version": "0.0.0",
+ "description": "A generator for Yeoman",
+ "keywords": [
+ "yeoman-generator"
+ ],
+ "homepage": "https://github.com/newtriks/generator-react-webpack",
+ "bugs": "https://github.com/newtriks/generator-react-webpack/issues",
+ "author": {
+ "name": "Simon Bailey",
+ "email": "simon@newtriks.com",
+ "url": "https://github.com/newtriks"
+ },
+ "main": "app/index.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/newtriks/generator-react-webpack.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"
+ }
+ ]
+}
Oops, something went wrong.

0 comments on commit b1562cd

Please sign in to comment.