Compare commits

..
9 Commits
Author SHA1 Message Date
Chris 47f1273828 2.1.0 2015-09-29 13:53:05 +02:00
Chris 56ff5c6281 Added new helper method #getDestinationPath to make path management in subcomponents easier 2015-09-29 13:52:58 +02:00
Chris 7269a0a315 2.0.2 2015-09-25 11:38:31 +02:00
Chris 6a3da576fa Added changes to make pr compatible with coding guidelines. 2015-09-25 11:38:24 +02:00
Chris e7bbcb1fe7 Merge pull request #146 from halkeye/patch-1
update baseRootPath to be happier with npm@3
2015-09-25 11:34:27 +02:00
Gavin Mogan 8a2fc142ba update baseRootPath to be happier with npm@3
npm@3 now flattens node_modules directory
This should be happy no matter where the module ends up
2015-09-24 23:45:12 -07:00
Chris 76f0e8e672 Added correct node version for travis 2015-09-21 21:13:28 +02:00
Chris a5c4ea4c74 2.0.1 2015-09-21 20:58:11 +02:00
Chris 9c61be0c24 Added updated readme 2015-09-21 20:58:00 +02:00
6 changed files with 56 additions and 15 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
language: node_js
node_js:
- '0.10'
- '4.1.0'
before_install:
- currentfolder=${PWD##*/}
- if [ "$currentfolder" != 'generator-react-webpack' ]; then cd .. && eval "mv $currentfolder generator-react-webpack" && cd generator-react-webpack; fi
+10 -10
View File
@@ -3,7 +3,7 @@
> Yeoman generator for [ReactJS](http://facebook.github.io/react/) - lets you quickly set up a project including karma test runner and [Webpack](http://webpack.github.io/) module system.
# About
Generator-React-Webpack will help you build new Reactprojects using modern technologies.
Generator-React-Webpack will help you build new React projects using modern technologies.
Out of the box it comes with support for:
- Webpack
@@ -12,11 +12,14 @@ Out of the box it comes with support for:
- Automatic code linting via esLint
- Ability to unit test components via Karma and Mocha/Chai
## Subgenerators
This generator is also the base project for some other generators that depend on it:
### Generator-React-Webpack-Alt
(https://github.com/weblogixx/generator-react-webpack-alt)
Generator based on generator-react-webpack, providing support for Alt.js.
## Changes in Version 2.0
The new version of generator-react-webpack does __NOT__ include support for Flux-Frameworks directly. Instead, we will use it as a base to provide own generators that use it as a base. This will make the base generator easier to use and update.
Currently, there are no stable flux implementation based on generator-react-webpack v2. We are working on an implementation for alt.js.
If you are interested, feel free to write your own generator and use generator-react-webpack as a base (via composition).
If you have build a generator using generator-react-webpack, tell us and we will add a link to our README.
---
@@ -73,11 +76,9 @@ npm run copy
```
### Naming Components
I have opted to follow [@floydophone](https://twitter.com/floydophone) convention of uppercase for component file naming e.g. [Component.js](https://github.com/petehunt/ReactHack/tree/master/src/components). I am open to suggestions if there is a general objection to this decision.
We have opted to follow [@floydophone](https://twitter.com/floydophone) convention of uppercase for component file naming e.g. [Component.js](https://github.com/petehunt/ReactHack/tree/master/src/components). I am open to suggestions if there is a general objection to this decision.
### Modules
Each component is a module and can be required using the [Webpack](http://webpack.github.io/) module system. [Webpack](http://webpack.github.io/) uses [Loaders](http://webpack.github.io/docs/loaders.html) which means you can also require CSS and a host of other file types. Read the [Webpack documentation](http://webpack.github.io/docs/home.html) to find out more.
## Props
@@ -91,7 +92,6 @@ Thanks to [Edd Hannay](https://github.com/eddhannay) for his Webpack optimisatio
Contributions are welcomed. When submitting a bugfix, write a test that exposes the bug and fails before applying your fix. Submit the test alongside the fix.
### Running Tests
`npm test` or `node node_modules/.bin/mocha`
## License
+1 -1
View File
@@ -6,7 +6,7 @@ let path = require('path');
let fs = require('fs');
// Set the base root directory for our files
let baseRootPath = path.join(__dirname, '../../node_modules/react-webpack-template');
let baseRootPath = path.dirname(require.resolve('react-webpack-template'));
module.exports = generator.Base.extend({
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "generator-react-webpack",
"version": "2.0.0",
"version": "2.1.0",
"description": "Yeoman generator for ReactJS and Webpack",
"keywords": [
"yeoman-generator",
+15
View File
@@ -94,4 +94,19 @@ describe('Utilities:Yeoman', () => {
});
});
describe('#getDestinationPath', () => {
it('should return the correct filesystem path for all components', () => {
expect(utils.getDestinationPath('test', 'action', 'Actions')).to.equal('src/actions/TestActions.js');
expect(utils.getDestinationPath('subfolder/test', 'action', 'Actions')).to.equal('src/actions/subfolder/TestActions.js');
expect(utils.getDestinationPath('test', 'source', 'Source')).to.equal('src/sources/TestSource.js');
expect(utils.getDestinationPath('subfolder/test', 'source', 'Source')).to.equal('src/sources/subfolder/TestSource.js');
expect(utils.getDestinationPath('test', 'store', 'Store')).to.equal('src/stores/TestStore.js');
expect(utils.getDestinationPath('subfolder/test', 'store', 'Store')).to.equal('src/stores/subfolder/TestStore.js');
});
});
});
+28 -1
View File
@@ -113,10 +113,37 @@ let getAppName = (appName) => {
return _.camelize(_.slugify(_.humanize(appName)));
};
/**
* Get the wanted destination path
* @param {String} name Name of the file
* @param {String} type The type to use (e.g. action, store, ...)
* @param {Suffix} suffix The suffix to use for the file (e.g. Store, Actions, ...)
* @return {String} Final path
*/
let getDestinationPath = (name, type, suffix) => {
let cleanedPaths = getCleanedPathName(name, suffix);
let fsParts = cleanedPaths.split('/');
let actionBaseName = _.capitalize(fsParts.pop());
let partPath = fsParts.join('/');
let fsPath = configUtils.getChoiceByKey('path', type).path;
let parts = [ fsPath ];
if(partPath.length > 0) {
parts.push(partPath);
}
parts.push(actionBaseName);
let fullPath = parts.join('/');
return `${fullPath}.js`;
};
module.exports = {
getBaseDir: getBaseDir,
getAllSettingsFromComponentName: getAllSettingsFromComponentName,
getAppName: getAppName,
getCleanedPathName: getCleanedPathName,
getComponentStyleName: getComponentStyleName
getComponentStyleName: getComponentStyleName,
getDestinationPath: getDestinationPath
};