Skip to content

Commit

Permalink
Merge pull request #59 from atSistemas/feat/ci
Browse files Browse the repository at this point in the history
Feat/ci
  • Loading branch information
pmagaz authored Aug 29, 2016
2 parents 52b3754 + c7329e5 commit 4ea5069
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 72 deletions.
72 changes: 37 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,77 +42,78 @@
"postinstall": "npm run yo && npm run test:coverage"
},
"dependencies": {
"babel-core": "^6.10.4",
"css-modules-require-hook": "^4.0.1",
"babel-core": "^6.14.0",
"compression": "^1.6.2",
"css-modules-require-hook": "^4.0.2",
"express": "^4.14.0",
"react": "^15.1.0",
"react-dom": "^15.1.0",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"react-redux": "^4.4.5",
"react-router": "^2.5.1",
"react-router": "^2.7.0",
"redux": "^3.5.2"
},
"devDependencies": {
"assets-webpack-plugin": "^3.4.0",
"babel-cli": "^6.10.1",
"babel-eslint": "^6.1.0",
"babel-loader": "^6.2.4",
"babel-plugin-transform-class-properties": "^6.10.2",
"babel-cli": "^6.14.0",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.2.5",
"babel-plugin-transform-class-properties": "^6.11.5",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"babel-plugin-webpack-alias": "^1.3.1",
"babel-preset-es2015": "^6.9.0",
"babel-plugin-webpack-alias": "1.6.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.9.0",
"babel-register": "^6.14.0",
"chai": "^3.5.0",
"classnames": "^2.2.5",
"copy-webpack-plugin": "^3.0.1",
"coveralls": "^2.11.9",
"coveralls": "^2.11.12",
"cross-env": "^2.0.0",
"css-loader": "^0.23.1",
"css-modules-require-hook": "^4.0.1",
"cssnano": "^3.7.1",
"css-loader": "^0.24.0",
"css-modules-require-hook": "^4.0.2",
"cssnano": "^3.7.4",
"cssrecipes-defaults": "^0.5.0",
"enzyme": "^2.4.1",
"eslint": "3.3.1",
"eslint-config-airbnb": "^10.0.0",
"eslint-loader": "^1.4.1",
"eslint-plugin-import": "^1.9.2",
"eslint-plugin-jsx-a11y": "^2.0.1",
"eslint-plugin-react": "^6.0.0",
"eslint": "3.4.0",
"eslint-config-airbnb": "^10.0.1",
"eslint-loader": "^1.5.0",
"eslint-plugin-import": "^1.14.0",
"eslint-plugin-jsx-a11y": "^2.2.0",
"eslint-plugin-react": "^6.2.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"generator-webapp": "^2.1.0",
"google-map-react": "^0.17.0",
"ignore-styles": "^4.0.0",
"google-map-react": "^0.18.3",
"ignore-styles": "^5.0.1",
"immutable": "^3.8.1",
"install": "^0.8.1",
"isomorphic-fetch": "^2.2.1",
"istanbul": "^0.4.4",
"mocha": "^3.0.0",
"normalize.css": "^4.1.1",
"nyc": "^7.1.0",
"istanbul": "^0.4.5",
"mocha": "^3.0.2",
"normalize.css": "^4.2.0",
"nyc": "7.1.0",
"postcss-browser-reporter": "^0.5.0",
"postcss-cssnext": "^2.7.0",
"postcss-import": "^8.1.2",
"postcss-loader": "^0.10.1",
"postcss-loader": "^0.11.0",
"postcss-modules-extract-imports": "^1.0.1",
"postcss-nested": "^1.0.0",
"postcss-url": "^5.1.2",
"react-addons-linked-state-mixin": "^15.1.0",
"react-addons-test-utils": "~15.3.0",
"react-addons-linked-state-mixin": "^15.3.1",
"react-addons-test-utils": "~15.3.1",
"react-controllables": "^0.6.0",
"react-ink": "^5.1.1",
"react-pure-render": "^1.0.2",
"redux-logger": "^2.6.1",
"sinon": "^1.17.5",
"style-loader": "^0.13.1",
"stylelint": "^7.1.0",
"stylelint": "^7.2.0",
"supports-color": "^3.1.2",
"webpack": "^1.13.1",
"webpack": "^1.13.2",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "^1.14.1",
"webpack-hot-middleware": "^2.12.1",
"webpack-dev-server": "^1.15.0",
"webpack-hot-middleware": "^2.12.2",
"yeoman-option-or-prompt": "^1.0.2",
"yo": "^1.8.4"
},
Expand Down Expand Up @@ -147,6 +148,7 @@
"css-modules",
"webpack",
"enzyme",
"testing",
"yeoman",
"istambul"
]
Expand Down
6 changes: 5 additions & 1 deletion server/middleware/dev-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const serverOptions = {
progress: false,
stats: { colors: true },
publicPath: config.output.publicPath,
headers: { 'Access-Control-Allow-Origin': '*' }
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With , Accept-Language, Content-type, Authorization'
}
};

const bundleStart = Date.now();
Expand Down
13 changes: 12 additions & 1 deletion server/middleware/prod-middleware.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import webpack from 'webpack';
import compression from 'compression';

const config = require('../../webpack/webpack.config.babel');
const compiler = webpack(config);
Expand All @@ -9,8 +10,18 @@ compiler.plugin('done', function() {
console.log('[BASE] Bundled project in ' + (Date.now() - bundleStart) + 'ms!');
});

const allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
};

const applyProdMiddleware = function(){
return [];
return [
compression(),
allowCrossDomain
];
};

module.exports = applyProdMiddleware;
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { symbols, color } from '../src/base/shared/console';
const port = 8000;
const app = express();
const context = 'server';
const staticPaths = setStaticsPaths(statics);
const envMiddleware = applyEnvMiddleWare(ENV, app);
const staticPaths = setStaticsPaths(statics);
const serverStore = applyMiddleware( requestMiddleware )( createStore );

import routes from '../src/base/routes';
Expand Down
45 changes: 16 additions & 29 deletions src/app/containers/Calculator/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import CreateReducer from 'base/shared/CreateReducer';
import { CalculatorModel } from '../models';
import Types from '../types';

const actionHandlers = {
[Types.RESULT]: result,
[Types.INPUT_NUMBER]: inputNumber,
[Types.INPUT_DECIMAL]: inputDecimal,
[Types.INPUT_OPERATOR]: inputOperator,
[Types.INPUT_OPERATION]: inputOperation
};

function inputOperator(state, action) {
const currentOperator = action.operator;
const prevOperator = state.get('operator');
Expand Down Expand Up @@ -78,27 +86,14 @@ function inputOperation( state, action ) {
}

function calculate( operator, prevValue, nextValue) {
let result = 0;

switch (operator) {
case Types.SUM:
result = prevValue + nextValue;
break;

case Types.SUBSTRACT:
result = prevValue - nextValue;
break;

case Types.MULTIPLY:
result = prevValue * nextValue;
break;

case Types.DIVIDE:
result = prevValue / nextValue;
break;
}

return result;
const result = {
[Types.SUM]: () => prevValue + nextValue,
[Types.DIVIDE]: () => prevValue / nextValue,
[Types.MULTIPLY]: () => prevValue * nextValue,
[Types.SUBSTRACT]: () => prevValue - nextValue
};

return result[operator]();
}

function result(state) {
Expand All @@ -114,12 +109,4 @@ function result(state) {
.set('resetDisplay', true);
}

const actionHandlers = {
[Types.RESULT]: result,
[Types.INPUT_NUMBER]: inputNumber,
[Types.INPUT_DECIMAL]: inputDecimal,
[Types.INPUT_OPERATOR]: inputOperator,
[Types.INPUT_OPERATION]: inputOperation
};

export default CreateReducer(actionHandlers, new CalculatorModel());
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"url": ""
},
"dependencies": {
"yeoman-generator": "^0.20.3",
"fs":"*"
"yeoman-generator": "^0.24.1"
}
}
7 changes: 4 additions & 3 deletions webpack/webpack-prod-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export const devTool = 'cheap-module-source-map';
export const context = path.resolve(__dirname, '../src/app');

export const plugins = [
new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"production"'}}),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('bundle.css'),
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({compressor: { warnings: false }, output: {comments: false}}),
new webpack.optimize.CommonsChunkPlugin('common', 'common.js'),
new copyWebpackPlugin([{ from: 'assets', to: 'assets' }]),
new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"production"'}}),
new webpack.optimize.UglifyJsPlugin({compressor: { warnings: false }, output: {comments: false}}),
function() {
this.plugin('done', function(stats) {
if (stats.compilation.errors && stats.compilation.errors.length && process.argv.indexOf('--watch') == -1) {
Expand Down Expand Up @@ -53,6 +53,7 @@ export const postCss = (webpack) =>
require('postcss-import')({ addDependencyTo: webpack }),
require('postcss-modules-extract-imports'),
require('postcss-url')(),
require('postcss-nested')(),
require('postcss-cssnext')(),
require('postcss-reporter')(),
require('cssnano')({autoprefixer: false})
Expand Down

0 comments on commit 4ea5069

Please sign in to comment.