mirror of
https://github.com/wassname/generator-react-webpack.git
synced 2026-08-30 11:23:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b95fc4344a | ||
|
|
66b85f48d8 | ||
|
|
bf2df82159 | ||
|
|
d729c3caa8 | ||
|
|
4f99a5a9db | ||
|
|
190cfdac06 | ||
|
|
ca3f923bf0 | ||
|
|
57a2ac9325 | ||
|
|
de5cca9866 | ||
|
|
4e8d7af872 | ||
|
|
85470145f5 | ||
|
|
520db61333 | ||
|
|
260758f93b | ||
|
|
361ea7409d | ||
|
|
47f1273828 | ||
|
|
56ff5c6281 |
@@ -13,3 +13,4 @@ $RECYCLE.BIN/
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
.idea/
|
||||
test/temp-test
|
||||
|
||||
@@ -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.
|
||||
@@ -1,5 +1,4 @@
|
||||
# generator-react-webpack V2.0 [](https://travis-ci.org/newtriks/generator-react-webpack) [](http://gruntjs.com/)
|
||||
|
||||
# generator-react-webpack V2.0 [](https://travis-ci.org/newtriks/generator-react-webpack) [](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.
|
||||
|
||||
# About
|
||||
@@ -13,13 +12,16 @@ Out of the box it comes with support for:
|
||||
- Ability to unit test components via Karma and Mocha/Chai
|
||||
|
||||
## 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.
|
||||
This generator is written in ES2015. This means it is ___not compatible with node.js versions before 4.0___.
|
||||
|
||||
Currently, there are no stable flux implementation based on generator-react-webpack v2. We are working on an implementation for alt.js.
|
||||
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.
|
||||
|
||||
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.
|
||||
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))
|
||||
|
||||
---
|
||||
|
||||
@@ -82,13 +84,9 @@ We have opted to follow [@floydophone](https://twitter.com/floydophone) conventi
|
||||
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
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
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
|
||||
@@ -97,5 +95,3 @@ Contributions are welcomed. When submitting a bugfix, write a test that exposes
|
||||
## License
|
||||
|
||||
[BSD license](http://opensource.org/licenses/bsd-license.php)
|
||||
|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
||||
@@ -91,6 +91,7 @@ module.exports = generator.Base.extend({
|
||||
let excludeList = [
|
||||
'LICENCE',
|
||||
'README.md',
|
||||
'CHANGELOG.md',
|
||||
'node_modules',
|
||||
'package.json'
|
||||
];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import React from 'react';
|
||||
|
||||
require('<%= style.webpackPath %>');
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
'use strict';
|
||||
|
||||
// Uncomment the following lines to use the react test utilities
|
||||
// import React from 'react/addons';
|
||||
// const TestUtils = React.addons.TestUtils;
|
||||
// import TestUtils from 'react-addons-test-utils';
|
||||
import createComponent from 'helpers/shallowRenderHelper';
|
||||
|
||||
import <%= component.className %> from '<%= component.webpackPath %>';
|
||||
@@ -18,6 +17,6 @@ describe('<%= component.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
@@ -1,14 +1,16 @@
|
||||
{
|
||||
"name": "generator-react-webpack",
|
||||
"version": "2.0.2",
|
||||
"description": "Yeoman generator for ReactJS and Webpack",
|
||||
"version": "2.2.2",
|
||||
"description": "Yeoman generator for using React with Webpack via Babel",
|
||||
"keywords": [
|
||||
"yeoman-generator",
|
||||
"react",
|
||||
"reactjs",
|
||||
"webpack",
|
||||
"scaffold",
|
||||
"framework",
|
||||
"component",
|
||||
"frontend",
|
||||
"front-end",
|
||||
"app"
|
||||
],
|
||||
@@ -35,7 +37,7 @@
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-webpack-template": "^0.1.0",
|
||||
"react-webpack-template": "^0.2.0",
|
||||
"underscore.string": "^3.2.2",
|
||||
"yeoman-generator": "^0.20.3",
|
||||
"yeoman-welcome": "^1.0.1"
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"value": "sass",
|
||||
"suffix": ".sass",
|
||||
"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",
|
||||
"suffix": ".scss",
|
||||
"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",
|
||||
"suffix": ".less",
|
||||
"packages": [
|
||||
{ "name": "less-loader", "version": "^2.0.0" }
|
||||
{ "name": "less-loader", "version": "^2.0.0" },
|
||||
{ "name": "less", "version": "^2.5.3" }
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
+42
-1
@@ -113,10 +113,51 @@ 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`;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 = {
|
||||
getBaseDir: getBaseDir,
|
||||
getAllSettingsFromComponentName: getAllSettingsFromComponentName,
|
||||
getAppName: getAppName,
|
||||
getCleanedPathName: getCleanedPathName,
|
||||
getComponentStyleName: getComponentStyleName
|
||||
getComponentStyleName: getComponentStyleName,
|
||||
getDestinationPath: getDestinationPath,
|
||||
getDestinationClassName: getDestinationClassName
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user