Basic project generator setup

TODO:

- App tests
- Generator tests
- Component generator

Signed-off-by: Simon Bailey <simon@newtriks.com>
This commit is contained in:
Simon Bailey
2014-01-07 20:00:49 +00:00
commit b1562cd74c
29 changed files with 17271 additions and 0 deletions
+74
View File
@@ -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);
};
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+41
View File
@@ -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;
}
+48
View File
@@ -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;
}