Skip to content

Commit

Permalink
Added basic setup, including dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
weblogixx committed Sep 21, 2015
1 parent 2e56046 commit 1e0301f
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .eslintrc
@@ -0,0 +1,22 @@
{
"env": {
"browser": false,
"amd": false,
"es6": true,
"node": true,
"mocha": true
},
"rules": {
"comma-dangle": 1,
"quotes": [ 1, "single" ],
"no-undef": 1,
"global-strict": 0,
"no-extra-semi": 1,
"no-underscore-dangle": 0,
"no-console": 0,
"no-unused-vars": 1,
"no-trailing-spaces": [1, { "skipBlankLines": true }],
"no-unreachable": 1,
"no-alert": 0
}
}
40 changes: 40 additions & 0 deletions generators/app/index.js
@@ -0,0 +1,40 @@
'use strict';

let generator = require('yeoman-generator');

module.exports = generator.Base.extend({

constructor: function() {
generator.Base.apply(this, arguments);

this.option('skip-install');
},

install: function() {

if(!this.options['skip-install']) {
this.installDependencies({ bower: false });
}

// Run the base react-webpack generator, then run the dispatcher
this.composeWith(
'react-webpack',
{
options: {
'skip-install': this.options['skip-install']
}
},
{
local: require.resolve('generator-react-webpack'),
link: 'strong'
}
).on('end', () => {

// Run the create dispatcher method
this.composeWith('react-webpack-alt:dispatcher', {
options: {},
args: ['Dispatcher']
});
});
}
});
16 changes: 16 additions & 0 deletions generators/dispatcher/index.js
@@ -0,0 +1,16 @@
'use strict';
let generator = require('yeoman-generator');

module.exports = generator.NamedBase.extend({

constructor: function() {
generator.NamedBase.apply(this, arguments);
},

writing: function() {
this.fs.copyTpl(
this.templatePath('Dispatcher.js'),
this.destinationPath(`src/components/${this.name}.js`)
);
}
});
4 changes: 4 additions & 0 deletions generators/dispatcher/templates/Dispatcher.js
@@ -0,0 +1,4 @@
var Alt = require('alt');
var alt = new Alt();

module.exports = alt;
42 changes: 42 additions & 0 deletions package.json
@@ -0,0 +1,42 @@
{
"name": "generator-react-webpack-alt",
"version": "0.0.1",
"description": "Yeoman generator for ReactJS and Webpack with Alt.js",
"keywords": [
"yeoman-generator",
"reactjs",
"webpack",
"alt.js",
"scaffold",
"front-end"
],
"homepage": "https://github.com/weblogixx/generator-react-webpack-alt",
"bugs": "https://github.com/weblogixx/generator-react-webpack-altissues",
"author": {
"name": "Christian Schilling",
"email": "cs@weblogixx.de",
"url": "https://github.com/weblogixx"
},
"main": "generators/action/index.js",
"repository": {
"type": "git",
"url": "git://github.com/weblogixx/generator-react-webpack-alt.git"
},
"scripts": {
"test": "mocha"
},
"dependencies": {
"yeoman-generator": "^0.20.3",
"yeoman-welcome": "^1.0.1",
"generator-react-webpack": "https://github.com/weblogixx/generator-react-webpack.git#rewrite"
},
"devDependencies": {
"chai": "^3.2.0",
"mocha": "^2.3.2"
},
"engines": {
"node": ">=4.0.0",
"iojs": ">=1.1.0"
},
"license": "MIT"
}
34 changes: 34 additions & 0 deletions test/generators/dispatcher/indexTest.js
@@ -0,0 +1,34 @@
'use strict';
let path = require('path');
let assert = require('yeoman-generator').assert;
let helpers = require('yeoman-generator').test

describe('react-webpack-alt:dispatcher', () => {

let generatorDispatcher = path.join(__dirname, '../../../generators/dispatcher');

/**
* Return a newly generated dispatcher with given name
* @param {String} name
* @param {Function} callback
*/
function createGeneratedDispatcher(name, callback) {
helpers.run(generatorDispatcher)
.withArguments([name])
.on('end', callback);
}

it('should create the new ALT dispatcher when invoked', (done) => {

createGeneratedDispatcher('Dispatcher', () => {

assert.file([
'src/components/Dispatcher.js'
]);
assert.fileContent('src/components/Dispatcher.js', 'var Alt = require(\'alt\');');

done();
});
});

});
2 changes: 2 additions & 0 deletions test/mocha.opts
@@ -0,0 +1,2 @@
--reporter spec
--recursive

0 comments on commit 1e0301f

Please sign in to comment.