Compare commits

...
23 Commits
Author SHA1 Message Date
Chris b95fc4344a 2.2.2 2015-10-12 16:35:14 +02:00
Chris 66b85f48d8 Fixed missing packages when using sass/less 2015-10-12 16:34:54 +02:00
Chris bf2df82159 2.2.1 2015-10-12 08:42:28 +02:00
Chris d729c3caa8 Added changelog to ignored files. 2015-10-12 08:41:47 +02:00
Chris 4f99a5a9db Added (mis-)spelling fix... again :( 2015-10-12 08:31:40 +02:00
Chris 190cfdac06 2.2.0 2015-10-12 08:29:03 +02:00
Chris ca3f923bf0 Added new version of react-webpack-template as dependency. Now using React 0.14 as base. 2015-10-12 08:28:43 +02:00
Chris 57a2ac9325 Merge pull request #150 from spencer48/patch-1
Made a few grammar and punctuation corrections
2015-10-11 11:15:58 +02:00
Spencer Handley de5cca9866 Made a few grammar and punctuation corrections
I noticed a few errors in the README. I hope you don't mind my corrections. Great repo!
2015-10-09 21:44:05 -07:00
Chris 4e8d7af872 Added new keywords to make generator findeable 2015-10-07 08:58:04 +02:00
Chris 85470145f5 Adjusted readme to include generator-react-webpack-alt 2015-10-02 08:33:09 +02:00
Chris 520db61333 Removed grunt badge. We don't use it anymore 2015-10-01 11:12:31 +02:00
Simon Bailey 260758f93b refactor: ignore temp test dir
Signed-off-by: Simon Bailey <simon@newtriks.com>
2015-10-01 09:17:02 +01:00
Chris 361ea7409d Added another utility #getDestinationClassName to get the final classname of a given path 2015-09-29 14:11:28 +02:00
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
11 changed files with 104 additions and 33 deletions
+1
View File
@@ -13,3 +13,4 @@ $RECYCLE.BIN/
node_modules/ node_modules/
npm-debug.log npm-debug.log
.idea/ .idea/
test/temp-test
+1 -2
View File
@@ -1,7 +1,6 @@
language: node_js language: node_js
node_js: node_js:
- '0.10' - '4.1.0'
before_install: before_install:
- currentfolder=${PWD##*/} - currentfolder=${PWD##*/}
- if [ "$currentfolder" != 'generator-react-webpack' ]; then cd .. && eval "mv $currentfolder generator-react-webpack" && cd generator-react-webpack; fi - if [ "$currentfolder" != 'generator-react-webpack' ]; then cd .. && eval "mv $currentfolder generator-react-webpack" && cd generator-react-webpack; fi
+6
View File
@@ -0,0 +1,6 @@
# generator-react-webpack - Changelog
## 2.2.0:
___Upgrades:___
1. Added new version of react-webpack-template, including support for React 0.14.
+15 -19
View File
@@ -1,9 +1,8 @@
# generator-react-webpack V2.0 [![Build Status](https://secure.travis-ci.org/newtriks/generator-react-webpack.png?branch=master)](https://travis-ci.org/newtriks/generator-react-webpack) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) # generator-react-webpack V2.0 [![Build Status](https://secure.travis-ci.org/newtriks/generator-react-webpack.png?branch=master)](https://travis-ci.org/newtriks/generator-react-webpack) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/newtriks/generator-react-webpack/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
> 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. > 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 # 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: Out of the box it comes with support for:
- Webpack - Webpack
@@ -12,11 +11,17 @@ Out of the box it comes with support for:
- Automatic code linting via esLint - Automatic code linting via esLint
- Ability to unit test components via Karma and Mocha/Chai - Ability to unit test components via Karma and Mocha/Chai
## Subgenerators ## Changes in Version 2.0
This generator is also the base project for some other generators that depend on it: This generator is written in ES2015. This means it is ___not compatible with node.js versions before 4.0___.
### Generator-React-Webpack-Alt
(https://github.com/weblogixx/generator-react-webpack-alt) It also does __NOT__ include support for Flux-Frameworks anymore. Instead, we will use it as a base for other generators to build upon. This will make the base generator easier to use and update.
Generator based on generator-react-webpack, providing support 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 built a generator using generator-react-webpack, tell us and we will add a link to our README.
## Generators that extend generator-react-webpack
- [Generator-React-Webpack-Alt](https://github.com/weblogixx/generator-react-webpack-alt) (Adds ability to create actions, stores and sources for [alt.js](http://alt.js.org))
--- ---
@@ -73,29 +78,20 @@ npm run copy
``` ```
### Naming Components ### Naming Components
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.
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.
### Modules ### 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. 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 ## Props
Thanks to [Edd Hannay](https://github.com/eddhannay) for his Webpack optimisations, my local merge and testing meant his additions lost his signature (my fault, sorry). So, big thanks Edd.
Thanks to all who contributed to [generator-angular](https://github.com/yeoman/generator-angular) as the majority of code here has been shamelessy sourced from that repos.
Thanks to [Edd Hannay](https://github.com/eddhannay) for his Webpack optimisations, my local merge and testing meant his additions lost his signature (my fault sorry) so big thanks Edd.
## Contribute ## Contribute
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. 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 ### Running Tests
`npm test` or `node node_modules/.bin/mocha` `npm test` or `node node_modules/.bin/mocha`
## License ## License
[BSD license](http://opensource.org/licenses/bsd-license.php) [BSD license](http://opensource.org/licenses/bsd-license.php)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/newtriks/generator-react-webpack/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
+2 -1
View File
@@ -6,7 +6,7 @@ let path = require('path');
let fs = require('fs'); let fs = require('fs');
// Set the base root directory for our files // 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({ module.exports = generator.Base.extend({
@@ -91,6 +91,7 @@ module.exports = generator.Base.extend({
let excludeList = [ let excludeList = [
'LICENCE', 'LICENCE',
'README.md', 'README.md',
'CHANGELOG.md',
'node_modules', 'node_modules',
'package.json' 'package.json'
]; ];
@@ -1,6 +1,6 @@
'use strict'; 'use strict';
import React from 'react/addons'; import React from 'react';
require('<%= style.webpackPath %>'); require('<%= style.webpackPath %>');
+2 -3
View File
@@ -4,8 +4,7 @@
'use strict'; 'use strict';
// Uncomment the following lines to use the react test utilities // Uncomment the following lines to use the react test utilities
// import React from 'react/addons'; // import TestUtils from 'react-addons-test-utils';
// const TestUtils = React.addons.TestUtils;
import createComponent from 'helpers/shallowRenderHelper'; import createComponent from 'helpers/shallowRenderHelper';
import <%= component.className %> from '<%= component.webpackPath %>'; import <%= component.className %> from '<%= component.webpackPath %>';
@@ -18,6 +17,6 @@ describe('<%= component.className %>', () => {
}); });
it('should have its component name as default className', () => { it('should have its component name as default className', () => {
expect(component._store.props.className).to.equal('<%= style.className %>'); expect(component.props.className).to.equal('<%= style.className %>');
}); });
}); });
+5 -3
View File
@@ -1,14 +1,16 @@
{ {
"name": "generator-react-webpack", "name": "generator-react-webpack",
"version": "2.0.0", "version": "2.2.2",
"description": "Yeoman generator for ReactJS and Webpack", "description": "Yeoman generator for using React with Webpack via Babel",
"keywords": [ "keywords": [
"yeoman-generator", "yeoman-generator",
"react",
"reactjs", "reactjs",
"webpack", "webpack",
"scaffold", "scaffold",
"framework", "framework",
"component", "component",
"frontend",
"front-end", "front-end",
"app" "app"
], ],
@@ -35,7 +37,7 @@
"test": "mocha" "test": "mocha"
}, },
"dependencies": { "dependencies": {
"react-webpack-template": "^0.1.0", "react-webpack-template": "^0.2.0",
"underscore.string": "^3.2.2", "underscore.string": "^3.2.2",
"yeoman-generator": "^0.20.3", "yeoman-generator": "^0.20.3",
"yeoman-welcome": "^1.0.1" "yeoman-welcome": "^1.0.1"
+23
View File
@@ -94,4 +94,27 @@ 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');
});
});
describe('#getDestinationClassName', () => {
it('should return the correct javascript class name for the given paths', () => {
expect(utils.getDestinationClassName('test', 'action', 'Actions')).to.equal('TestActions');
expect(utils.getDestinationClassName('test', 'source', 'Source')).to.equal('TestSource');
expect(utils.getDestinationClassName('test', 'store', 'Store')).to.equal('TestStore');
});
});
}); });
+6 -3
View File
@@ -51,7 +51,8 @@
"value": "sass", "value": "sass",
"suffix": ".sass", "suffix": ".sass",
"packages": [ "packages": [
{ "name": "sass-loader", "version": "^1.0.1" } { "name": "sass-loader", "version": "^1.0.1" },
{ "name": "node-sass", "version": "^3.3.3" }
] ]
}, },
{ {
@@ -59,7 +60,8 @@
"value": "scss", "value": "scss",
"suffix": ".scss", "suffix": ".scss",
"packages": [ "packages": [
{ "name": "sass-loader", "version": "^1.0.1" } { "name": "sass-loader", "version": "^1.0.1" },
{ "name": "node-sass", "version": "^3.3.3" }
] ]
}, },
{ {
@@ -67,7 +69,8 @@
"value": "less", "value": "less",
"suffix": ".less", "suffix": ".less",
"packages": [ "packages": [
{ "name": "less-loader", "version": "^2.0.0" } { "name": "less-loader", "version": "^2.0.0" },
{ "name": "less", "version": "^2.5.3" }
] ]
}, },
{ {
+42 -1
View File
@@ -113,10 +113,51 @@ let getAppName = (appName) => {
return _.camelize(_.slugify(_.humanize(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`;
};
/**
* Get the destinations class name
* @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} The javascript class name to use
*/
let getDestinationClassName = (name, type, suffix) => {
let fixedName = getDestinationPath(name, type, suffix);
return _.capitalize(fixedName.split('/').pop().split('.js')[0]);
};
module.exports = { module.exports = {
getBaseDir: getBaseDir, getBaseDir: getBaseDir,
getAllSettingsFromComponentName: getAllSettingsFromComponentName, getAllSettingsFromComponentName: getAllSettingsFromComponentName,
getAppName: getAppName, getAppName: getAppName,
getCleanedPathName: getCleanedPathName, getCleanedPathName: getCleanedPathName,
getComponentStyleName: getComponentStyleName getComponentStyleName: getComponentStyleName,
getDestinationPath: getDestinationPath,
getDestinationClassName: getDestinationClassName
}; };