mirror of
https://github.com/wassname/generator-react-webpack.git
synced 2026-08-30 11:23:47 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35ef93138c | ||
|
|
4e698c51b4 | ||
|
|
832907f2fd | ||
|
|
6344984d65 | ||
|
|
6b9e24c85a | ||
|
|
561e072a9c | ||
|
|
56d6b9cd48 | ||
|
|
43f3bce786 | ||
|
|
f6327e1904 | ||
|
|
bd5748bb89 |
@@ -1,5 +1,18 @@
|
|||||||
# generator-react-webpack - Changelog
|
# generator-react-webpack - Changelog
|
||||||
|
|
||||||
|
## 3.3.0
|
||||||
|
|
||||||
|
1. Added new yeoman key "generatedWithVersion". Will be used for backwards compatibility of new major releases.
|
||||||
|
|
||||||
|
## 3.2.4
|
||||||
|
|
||||||
|
1. Added whitespaces to generated unit tests (made problems when using it with various eslint rules)
|
||||||
|
|
||||||
|
## 3.2.3
|
||||||
|
|
||||||
|
1. Adjusted postcss to work with react-webpack-template 1.4 upwards
|
||||||
|
2. Improved styling output (provided by [thewtex](https://github.com/thewtex))
|
||||||
|
|
||||||
## 3.2.2
|
## 3.2.2
|
||||||
|
|
||||||
1. Cleaned up formatting of unit tests
|
1. Cleaned up formatting of unit tests
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ let utils = require('../../utils/all');
|
|||||||
let prompts = require('./prompts');
|
let prompts = require('./prompts');
|
||||||
let path = require('path');
|
let path = require('path');
|
||||||
let fs = require('fs');
|
let fs = require('fs');
|
||||||
|
const packageInfo = require('../../package.json');
|
||||||
|
|
||||||
// Set the base root directory for our files
|
// Set the base root directory for our files
|
||||||
let baseRootPath = path.dirname(require.resolve('react-webpack-template'));
|
let baseRootPath = path.dirname(require.resolve('react-webpack-template'));
|
||||||
@@ -47,12 +48,14 @@ module.exports = generator.Base.extend({
|
|||||||
this.appName = props.appName;
|
this.appName = props.appName;
|
||||||
this.style = props.style;
|
this.style = props.style;
|
||||||
this.postcss = props.postcss
|
this.postcss = props.postcss
|
||||||
|
this.generatedWithVersion = packageInfo.version.split('.').unshift();
|
||||||
|
|
||||||
// Set needed keys into config
|
// Set needed keys into config
|
||||||
this.config.set('appName', this.appName);
|
this.config.set('appName', this.appName);
|
||||||
this.config.set('appPath', this.appPath);
|
this.config.set('appPath', this.appPath);
|
||||||
this.config.set('style', this.style);
|
this.config.set('style', this.style);
|
||||||
this.config.set('postcss', this.postcss);
|
this.config.set('postcss', this.postcss);
|
||||||
|
this.config.set('generatedWithVersion', this.generatedWithVersion);
|
||||||
|
|
||||||
this.config.save();
|
this.config.save();
|
||||||
|
|
||||||
@@ -138,7 +141,7 @@ module.exports = generator.Base.extend({
|
|||||||
install: function() {
|
install: function() {
|
||||||
if(this.postcss) {
|
if(this.postcss) {
|
||||||
let postcss = require('./postcss');
|
let postcss = require('./postcss');
|
||||||
postcss.write(path.join(this.destinationRoot(), 'cfg/base.js'));
|
postcss.write(path.join(this.destinationRoot(), 'cfg/defaults.js'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.options['skip-install']) {
|
if(!this.options['skip-install']) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
let utils = require('../../utils/all');
|
const utils = require('../../utils/all');
|
||||||
|
|
||||||
module.exports = [
|
module.exports = [
|
||||||
{
|
{
|
||||||
@@ -11,7 +11,7 @@ module.exports = [
|
|||||||
{
|
{
|
||||||
type: 'list',
|
type: 'list',
|
||||||
name: 'style',
|
name: 'style',
|
||||||
message: 'Which styles language you want to use?',
|
message: 'Which style language do you want to use?',
|
||||||
choices: utils.config.getChoices('style'),
|
choices: utils.config.getChoices('style'),
|
||||||
default: utils.config.getDefaultChoice('style')
|
default: utils.config.getDefaultChoice('style')
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*eslint-env node, mocha */
|
/* eslint-env node, mocha */
|
||||||
/*global expect */
|
/* global expect */
|
||||||
/*eslint no-console: 0*/
|
/* eslint no-console: 0 */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Uncomment the following lines to use the react test utilities
|
// Uncomment the following lines to use the react test utilities
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "generator-react-webpack",
|
"name": "generator-react-webpack",
|
||||||
"version": "3.2.2",
|
"version": "3.3.0",
|
||||||
"description": "Yeoman generator for using React with Webpack via Babel",
|
"description": "Yeoman generator for using React with Webpack via Babel",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"yeoman-generator",
|
"yeoman-generator",
|
||||||
|
|||||||
@@ -4,34 +4,48 @@ let expect = require('chai').expect;
|
|||||||
let assert = require('yeoman-assert');
|
let assert = require('yeoman-assert');
|
||||||
let helpers = require('yeoman-test');
|
let helpers = require('yeoman-test');
|
||||||
|
|
||||||
|
// Default globals, used in all tests
|
||||||
|
const defaultPrompts = require('../../../generators/app/prompts.js');
|
||||||
|
let generator;
|
||||||
|
const generatorBase = path.join(__dirname, '../../../generators/app');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global before load function. Run in the before callbacks
|
||||||
|
* @param {Object} prompts List of prompts to use
|
||||||
|
* @param {Function} done Done callback
|
||||||
|
*/
|
||||||
|
const beforeLoad = (prompts, done) => {
|
||||||
|
|
||||||
|
helpers.run(generatorBase)
|
||||||
|
.inTmpDir()
|
||||||
|
.withOptions({
|
||||||
|
'skip-welcome-message': true,
|
||||||
|
'skip-install': true
|
||||||
|
})
|
||||||
|
.withPrompts(prompts)
|
||||||
|
.on('ready', (instance) => {
|
||||||
|
generator = instance;
|
||||||
|
})
|
||||||
|
.on('end', done);
|
||||||
|
};
|
||||||
|
|
||||||
describe('react-webpack:app', () => {
|
describe('react-webpack:app', () => {
|
||||||
|
|
||||||
let defaultPrompts = require('../../../generators/app/prompts.js');
|
|
||||||
let prompts = {};
|
let prompts = {};
|
||||||
for(let p of defaultPrompts) {
|
for(let p of defaultPrompts) {
|
||||||
prompts[p.name] = p.default;
|
prompts[p.name] = p.default;
|
||||||
}
|
}
|
||||||
|
|
||||||
let generator;
|
|
||||||
let generatorBase = path.join(__dirname, '../../../generators/app');
|
|
||||||
|
|
||||||
before((done) => {
|
before((done) => {
|
||||||
|
beforeLoad(prompts, done);
|
||||||
helpers.run(generatorBase)
|
|
||||||
.inTmpDir()
|
|
||||||
.withOptions({
|
|
||||||
'skip-welcome-message': true,
|
|
||||||
'skip-install': true
|
|
||||||
})
|
|
||||||
.withPrompts(prompts)
|
|
||||||
.on('ready', (instance) => {
|
|
||||||
generator = instance;
|
|
||||||
})
|
|
||||||
.on('end', done);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#config', () => {
|
describe('#config', () => {
|
||||||
|
|
||||||
|
it('should set the generatedWith key to the current generator major version', () => {
|
||||||
|
expect(generator.config.get('generatedWithVersion')).to.equal(3);
|
||||||
|
});
|
||||||
|
|
||||||
it('should use "css" as default style language', () => {
|
it('should use "css" as default style language', () => {
|
||||||
expect(generator.config.get('style')).to.equal('css');
|
expect(generator.config.get('style')).to.equal('css');
|
||||||
});
|
});
|
||||||
@@ -65,6 +79,7 @@ describe('react-webpack:app', () => {
|
|||||||
|
|
||||||
assert.file([
|
assert.file([
|
||||||
'cfg/base.js',
|
'cfg/base.js',
|
||||||
|
'cfg/defaults.js',
|
||||||
'cfg/dev.js',
|
'cfg/dev.js',
|
||||||
'cfg/dist.js',
|
'cfg/dist.js',
|
||||||
'cfg/test.js',
|
'cfg/test.js',
|
||||||
@@ -100,9 +115,8 @@ describe('react-webpack:app', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('react-webpack:app non-default-prompts', () => {
|
describe('react-webpack:app with PostCSS support', () => {
|
||||||
|
|
||||||
let defaultPrompts = require('../../../generators/app/prompts.js');
|
|
||||||
let prompts = {};
|
let prompts = {};
|
||||||
for(let p of defaultPrompts) {
|
for(let p of defaultPrompts) {
|
||||||
prompts[p.name] = p.default;
|
prompts[p.name] = p.default;
|
||||||
@@ -110,29 +124,23 @@ describe('react-webpack:app non-default-prompts', () => {
|
|||||||
|
|
||||||
prompts.postcss = true;
|
prompts.postcss = true;
|
||||||
|
|
||||||
let generator;
|
|
||||||
let generatorBase = path.join(__dirname, '../../../generators/app');
|
|
||||||
|
|
||||||
before((done) => {
|
before((done) => {
|
||||||
|
beforeLoad(prompts, done);
|
||||||
helpers.run(generatorBase)
|
|
||||||
.inTmpDir()
|
|
||||||
.withOptions({
|
|
||||||
'skip-welcome-message': true,
|
|
||||||
'skip-install': true
|
|
||||||
})
|
|
||||||
.withPrompts(prompts)
|
|
||||||
.on('ready', (instance) => {
|
|
||||||
generator = instance;
|
|
||||||
})
|
|
||||||
.on('end', done);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#config', () => {
|
describe('#config', () => {
|
||||||
|
|
||||||
|
it('should set the generatedWith key to the current generator major version', () => {
|
||||||
|
expect(generator.config.get('generatedWithVersion')).to.equal(3);
|
||||||
|
});
|
||||||
|
|
||||||
it('should use "css" as default style language', () => {
|
it('should use "css" as default style language', () => {
|
||||||
expect(generator.config.get('style')).to.equal('css');
|
expect(generator.config.get('style')).to.equal('css');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should enable "PostCSS"', () => {
|
||||||
|
expect(generator.config.get('postcss')).to.equal(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#createFiles', () => {
|
describe('#createFiles', () => {
|
||||||
@@ -159,6 +167,7 @@ describe('react-webpack:app non-default-prompts', () => {
|
|||||||
|
|
||||||
assert.file([
|
assert.file([
|
||||||
'cfg/base.js',
|
'cfg/base.js',
|
||||||
|
'cfg/defaults.js',
|
||||||
'cfg/dev.js',
|
'cfg/dev.js',
|
||||||
'cfg/dist.js',
|
'cfg/dist.js',
|
||||||
'cfg/test.js',
|
'cfg/test.js',
|
||||||
@@ -169,16 +178,16 @@ describe('react-webpack:app non-default-prompts', () => {
|
|||||||
|
|
||||||
it('should insert the postcss loader into the style pipes', () => {
|
it('should insert the postcss loader into the style pipes', () => {
|
||||||
|
|
||||||
assert.fileContent('cfg/base.js', 'loader: \'style-loader!css-loader!postcss-loader\'');
|
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader\'');
|
||||||
assert.fileContent('cfg/base.js', 'loader: \'style-loader!css-loader!postcss-loader!sass-loader?outputStyle=expanded&indentedSyntax\'');
|
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!sass-loader?outputStyle=expanded&indentedSyntax\'');
|
||||||
assert.fileContent('cfg/base.js', 'loader: \'style-loader!css-loader!postcss-loader!sass-loader?outputStyle=expanded\'');
|
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!sass-loader?outputStyle=expanded\'');
|
||||||
assert.fileContent('cfg/base.js', 'loader: \'style-loader!css-loader!postcss-loader!less-loader\'');
|
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!less-loader\'');
|
||||||
assert.fileContent('cfg/base.js', 'loader: \'style-loader!css-loader!postcss-loader!stylus-loader\'');
|
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!stylus-loader\'');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should append the postcss function to the base config', () => {
|
it('should append the postcss function to the base config', () => {
|
||||||
|
|
||||||
assert.fileContent('cfg/base.js', ',\n postcss: function () {\n return [];\n }');
|
assert.fileContent('cfg/defaults.js', ',\n postcss: function () {\n return [];\n }');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate required source files', () => {
|
it('should generate required source files', () => {
|
||||||
|
|||||||
+4
-4
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let config = require('./config');
|
const config = require('./config');
|
||||||
let yeoman = require('./yeoman');
|
const yeoman = require('./yeoman');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
config: config,
|
config,
|
||||||
yeoman: yeoman
|
yeoman
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-7
@@ -57,12 +57,9 @@ let getDefaultChoice = (setting) => {
|
|||||||
return config && config.default !== undefined && config.default.length > 0 ? config.default : null;
|
return config && config.default !== undefined && config.default.length > 0 ? config.default : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// getChoices
|
|
||||||
// getDefault
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getSetting: getSetting,
|
getSetting,
|
||||||
getChoices: getChoices,
|
getChoices,
|
||||||
getChoiceByKey: getChoiceByKey,
|
getChoiceByKey,
|
||||||
getDefaultChoice: getDefaultChoice
|
getDefaultChoice
|
||||||
};
|
};
|
||||||
|
|||||||
+10
-10
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let path = require('path');
|
const path = require('path');
|
||||||
let configUtils = require('./config');
|
const configUtils = require('./config');
|
||||||
let _ = require('underscore.string');
|
const _ = require('underscore.string');
|
||||||
|
|
||||||
// Needed directory paths
|
// Needed directory paths
|
||||||
const baseName = path.basename(process.cwd());
|
const baseName = path.basename(process.cwd());
|
||||||
@@ -157,11 +157,11 @@ let getDestinationClassName = (name, type, suffix) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getBaseDir: getBaseDir,
|
getBaseDir,
|
||||||
getAllSettingsFromComponentName: getAllSettingsFromComponentName,
|
getAllSettingsFromComponentName,
|
||||||
getAppName: getAppName,
|
getAppName,
|
||||||
getCleanedPathName: getCleanedPathName,
|
getCleanedPathName,
|
||||||
getComponentStyleName: getComponentStyleName,
|
getComponentStyleName,
|
||||||
getDestinationPath: getDestinationPath,
|
getDestinationPath,
|
||||||
getDestinationClassName: getDestinationClassName
|
getDestinationClassName
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user