Compare commits

...
4 Commits
Author SHA1 Message Date
Chris 35ef93138c 3.3.0 2016-03-29 23:24:14 +02:00
Chris 4e698c51b4 Added new changelog for 3.3.0 2016-03-29 23:09:07 +02:00
Chris 832907f2fd Added minor es2015 tweaks 2016-03-29 23:01:42 +02:00
Chris 6344984d65 Added ability to save generator version for future updates 2016-03-29 23:00:55 +02:00
8 changed files with 68 additions and 56 deletions
+5
View File
@@ -1,6 +1,11 @@
# 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 ## 3.2.4
1. Added whitespaces to generated unit tests (made problems when using it with various eslint rules) 1. Added whitespaces to generated unit tests (made problems when using it with various eslint rules)
## 3.2.3 ## 3.2.3
+3
View File
@@ -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();
+1 -1
View File
@@ -1,5 +1,5 @@
'use strict'; 'use strict';
let utils = require('../../utils/all'); const utils = require('../../utils/all');
module.exports = [ module.exports = [
{ {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "generator-react-webpack", "name": "generator-react-webpack",
"version": "3.2.4", "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",
+40 -33
View File
@@ -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');
}); });
@@ -101,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;
@@ -111,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', () => {
+4 -4
View File
@@ -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
View File
@@ -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
View File
@@ -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
}; };