Browse Source

Update all dependencies apart from React, so app can be run on Node v4

Remove 'use strict' from code that is transpiled with Babel
Remove dist/ dir, clean up
Roman Matiasko 4 years ago
parent
commit
ca76a8e37c
47 changed files with 117 additions and 142 deletions
  1. 1 0
      .gitignore
  2. 6 7
      README.md
  3. 7 7
      app.js
  4. 2 2
      bin/www
  5. 0 1
      dist/css/main.css
  6. BIN
      dist/fonts/smart-regular.eot
  7. BIN
      dist/fonts/smart-regular.ttf
  8. BIN
      dist/fonts/smart-regular.woff
  9. BIN
      dist/fonts/smart-regular.woff2
  10. 0 1
      dist/img/chat.svg
  11. BIN
      dist/img/favicon.png
  12. BIN
      dist/img/knight.png
  13. 0 8
      dist/js/index.js
  14. 0 12
      dist/js/play.js
  15. BIN
      dist/snd/check.mp3
  16. BIN
      dist/snd/message.mp3
  17. BIN
      dist/snd/move.mp3
  18. 1 1
      gulpfile.js
  19. 17 18
      package.json
  20. 1 3
      routes/routes.js
  21. 2 2
      spec/io-spec.js
  22. 1 0
      src/css/_chat.scss
  23. 5 4
      src/js/actions/ChatActions.js
  24. 8 7
      src/js/actions/GameActions.js
  25. 3 3
      src/js/components/CapturedPieces.js
  26. 3 3
      src/js/components/Chat.js
  27. 6 6
      src/js/components/Chessboard.js
  28. 4 4
      src/js/components/ChessboardInterface.js
  29. 3 3
      src/js/components/Clock.js
  30. 1 3
      src/js/components/CreateGameForm.js
  31. 4 4
      src/js/components/GameHeader.js
  32. 4 4
      src/js/components/GameInterface.js
  33. 3 3
      src/js/components/Index.js
  34. 3 3
      src/js/components/Modal.js
  35. 3 3
      src/js/components/TableOfMoves.js
  36. 2 1
      src/js/constants/ChatConstants.js
  37. 1 1
      src/js/constants/ChessPieces.js
  38. 2 1
      src/js/constants/GameConstants.js
  39. 2 1
      src/js/dispatcher/AppDispatcher.js
  40. 3 3
      src/js/index.js
  41. 4 5
      src/js/io.js
  42. 3 4
      src/js/play.js
  43. 4 4
      src/js/stores/ChatStore.js
  44. 5 5
      src/js/stores/GameStore.js
  45. 1 1
      src/js/stores/__tests__/ChatStore-test.js
  46. 1 1
      src/js/stores/__tests__/GameStore-test.js
  47. 1 3
      winston.js

+ 1 - 0
.gitignore

@@ -2,4 +2,5 @@
 node_modules/
 logs/
 build/
+dist/
 npm-debug.log

+ 6 - 7
README.md

@@ -5,15 +5,14 @@ A lightweight, real-time chess app built in [Node](http://nodejs.org/), [Express
 
 You can play the game on [www.retichess.com](http://www.retichess.com/).
 
-If you want to run it locally (with node **v0.12**):
+If you want to run it locally (with node **v4.2**):
 * Clone the repo
 * Install dependencies
 ```sh
 npm install
-```
-* Set NODE_ENV to developement
-```sh
-export NODE_ENV=development
+# create empty logfile for winston
+mkdir logs
+touch logs/games.log
 ```
 * Run the server
 ```sh
@@ -22,11 +21,11 @@ npm start
 * Preferred way is to run the server with nodemon
 ```sh
 npm install -g nodemon # if you don't have nodemon installed yet
-nodemon --harmony bin/www
+nodemon bin/www
 ```
 * Run gulp if you want to recompile static assets when you save a file
 ```sh
-gulp
+npm run build
 ```
 * App will run on **localhost:3000**
 

+ 7 - 7
app.js

@@ -1,20 +1,20 @@
-'use strict';
-
 import express from 'express';
 import path from 'path';
-import winston from './winston';
 import bodyParser from 'body-parser';
 import favicon from 'serve-favicon';
 import logger from 'morgan';
+
+import winston from './winston';
 import routes from './routes/routes';
 
-const staticPath =  path.join(__dirname,
-  process.env.NODE_ENV === 'development' ? 'build' : 'dist');
+
+const rootDir = process.env.NODE_ENV === 'development' ? 'build' : 'dist';
+const staticPath =  path.join(__dirname, rootDir);
 const app = express();
 
 app.set('views', path.join(__dirname, 'views'));
 app.set('view engine', 'jade');
-app.use(favicon(path.join(__dirname, 'dist/img/favicon.png')));
+app.use(favicon(path.join(__dirname, rootDir + '/img/favicon.png')));
 app.use(logger('dev'));
 app.use(bodyParser.json());
 app.use(bodyParser.urlencoded({extended: true}));
@@ -37,4 +37,4 @@ app.use((err, req, res, next) => {
   });
 });
   
-export default app;
+export default app;

+ 2 - 2
bin/www

@@ -1,4 +1,4 @@
-#!/usr/bin/env node --harmony
+#!/usr/bin/env node
 
 'use strict';
 
@@ -37,4 +37,4 @@ server.on('error', error => {
   }
 });
 
-io.attach(server);
+io.attach(server);

File diff suppressed because it is too large
+ 0 - 1
dist/css/main.css


BIN
dist/fonts/smart-regular.eot


BIN
dist/fonts/smart-regular.ttf


BIN
dist/fonts/smart-regular.woff


BIN
dist/fonts/smart-regular.woff2


File diff suppressed because it is too large
+ 0 - 1
dist/img/chat.svg


BIN
dist/img/favicon.png


BIN
dist/img/knight.png


File diff suppressed because it is too large
+ 0 - 8
dist/js/index.js


File diff suppressed because it is too large
+ 0 - 12
dist/js/play.js


BIN
dist/snd/check.mp3


BIN
dist/snd/message.mp3


BIN
dist/snd/move.mp3


+ 1 - 1
gulpfile.js

@@ -178,4 +178,4 @@ gulp.task('default', function() {
   cssTask();
   imageminTask();
   copyTask();
-});
+});

+ 17 - 18
package.json

@@ -1,19 +1,19 @@
 {
   "name": "retichess",
-  "version": "0.3.1",
+  "version": "0.4.1",
   "scripts": {
-    "start": "node --harmony ./bin/www",
-    "test": "node --harmony ./node_modules/jasmine/bin/jasmine.js && jest",
+    "start": "NODE_ENV=development node ./bin/www",
+    "test": "node ./node_modules/jasmine/bin/jasmine.js && jest",
     "build": "NODE_ENV=development gulp",
     "deploy": "NODE_ENV=production gulp"
   },
   "dependencies": {
-    "babel": "^4.7.16",
+    "babel": "^5.8.23",
     "body-parser": "^1.12.2",
     "chess.js": "jhlywa/chess.js",
-    "classnames": "^1.2.0",
+    "classnames": "^2.2.0",
     "debug": "^2.1.3",
-    "es6-shim": "^0.27.1",
+    "es6-shim": "^0.33.7",
     "eventemitter2": "^0.4.14",
     "express": "^4.12.3",
     "flux": "^2.0.1",
@@ -24,31 +24,30 @@
     "react": "^0.13.1",
     "serve-favicon": "^2.2.0",
     "socket.io": "^1.3.5",
-    "socket.io-client": "^1.3.5",
-    "winston": "^0.9.0"
+    "socket.io-client": "^1.3.5"
   },
   "devDependencies": {
-    "babel-jest": "^4.0.0",
-    "babelify": "^5.0.4",
-    "browserify": "^9.0.3",
+    "babel-jest": "^5.3.0",
+    "babelify": "^6.4.0",
+    "browserify": "^11.2.0",
     "gulp": "^3.8.11",
-    "gulp-autoprefixer": "^2.1.0",
+    "gulp-autoprefixer": "^3.1.0",
     "gulp-cssmin": "^0.1.6",
-    "gulp-if": "^1.2.5",
+    "gulp-if": "^2.0.0",
     "gulp-imagemin": "^2.2.1",
     "gulp-notify": "^2.2.0",
-    "gulp-sass": "^1.3.3",
+    "gulp-sass": "^2.0.4",
     "gulp-sourcemaps": "^1.5.1",
-    "gulp-streamify": "0.0.5",
+    "gulp-streamify": "1.0.2",
     "gulp-uglify": "^1.1.0",
     "gulp-util": "^3.0.4",
     "jasmine": "^2.2.1",
-    "jest-cli": "^0.4.0",
+    "jest-cli": "^0.6.0",
     "vinyl-source-stream": "^1.1.0",
-    "watchify": "2.6.2"
+    "watchify": "3.4.0"
   },
   "engines": {
-    "node": "^0.12.0"
+    "node": "^4.2.1"
   },
   "jest": {
     "scriptPreprocessor": "<rootDir>/node_modules/babel-jest",

+ 1 - 3
routes/routes.js

@@ -1,5 +1,3 @@
-'use strict';
-
 import express from 'express';
 import path from 'path';
 import fs from 'fs';
@@ -41,4 +39,4 @@ router.get('/logs', (req, res) => {
   });
 });
 
-export default router;
+export default router;

+ 2 - 2
spec/io-spec.js

@@ -223,7 +223,7 @@ describe('io', () => {
         getGames();
         expect(games.size).toBe(0);
         done();
-      }, 0);
+      }, 100);
     });
   });
-});
+});

+ 1 - 0
src/css/_chat.scss

@@ -5,6 +5,7 @@
   top: 99px;
   border: 4px solid #fff;
   background: lighten($grey, 5%);
+  z-index: 10;
 
   &.hidden {
     display: none;

+ 5 - 4
src/js/actions/ChatActions.js

@@ -1,6 +1,7 @@
 import ChatConstants from '../constants/ChatConstants';
 import AppDispatcher from '../dispatcher/AppDispatcher';
 
+
 const ChatActions = {
   toggleVisibility() {
     AppDispatcher.handleViewAction({
@@ -10,11 +11,11 @@ const ChatActions = {
   submitMessage(message, className, received) {
     AppDispatcher.handleViewAction({
       actionType: ChatConstants.SUBMIT_MESSAGE,
-      message: message,
-      className: className,
-      received: received
+      message,
+      className,
+      received
     });
   }
 };
 
-export default ChatActions;
+export default ChatActions;

+ 8 - 7
src/js/actions/GameActions.js

@@ -1,14 +1,15 @@
 import GameConstants from '../constants/GameConstants';
 import AppDispatcher from '../dispatcher/AppDispatcher';
 
+
 const GameActions = {
   makeMove(from, to, capture, emitMove) {
     AppDispatcher.handleViewAction({
       actionType: GameConstants.MAKE_MOVE,
-      from: from,
-      to: to,
-      capture: capture,
-      emitMove: emitMove
+      from,
+      to,
+      capture,
+      emitMove
     });
   },
   rematch() {
@@ -19,15 +20,15 @@ const GameActions = {
   gameOver(options) {
     AppDispatcher.handleViewAction({
       actionType: GameConstants.GAME_OVER,
-      options: options
+      options
     });
   },
   changePromotion(promotion) {
     AppDispatcher.handleViewAction({
       actionType: GameConstants.CHANGE_PROMOTION,
-      promotion: promotion
+      promotion
     });
   }
 };
 
-export default GameActions;
+export default GameActions;

+ 3 - 3
src/js/components/CapturedPieces.js

@@ -1,9 +1,9 @@
-'use strict';
-
 import React from 'react/addons';
+
 import GameStore from '../stores/GameStore';
 import onGameChange from '../mixins/onGameChange';
 
+
 const CapturedPieces = React.createClass({
   
   mixins: [React.addons.PureRenderMixin, onGameChange],
@@ -33,4 +33,4 @@ const CapturedPieces = React.createClass({
   }
 });
 
-export default CapturedPieces;
+export default CapturedPieces;

+ 3 - 3
src/js/components/Chat.js

@@ -1,9 +1,9 @@
-'use strict';
-
 import React from 'react/addons';
+
 import ChatStore from '../stores/ChatStore';
 import ChatActions from '../actions/ChatActions';
 
+
 const Chat = React.createClass({
   
   propTypes: {
@@ -111,4 +111,4 @@ const Chat = React.createClass({
   }
 });
 
-export default Chat;
+export default Chat;

+ 6 - 6
src/js/components/Chessboard.js

@@ -1,14 +1,14 @@
-'use strict';
-
 import React from 'react/addons';
+import omit from 'lodash.omit';
+import cx from 'classnames';
+import {Seq, Repeat, List, Set} from 'immutable';
+
 import GameStore from '../stores/GameStore';
 import GameActions from '../actions/GameActions';
 import ChessPieces from '../constants/ChessPieces';
 import onGameChange from '../mixins/onGameChange';
 import maybeReverse from '../mixins/maybeReverse';
-import omit from 'lodash.omit';
-import cx from 'classnames';
-import {Seq, Repeat, List, Set} from 'immutable';
+
 
 const FILES = Seq.Indexed('abcdefgh');
 const RANKS = Seq.Indexed('12345678');
@@ -240,4 +240,4 @@ const Column = React.createClass({
   }
 });
 
-export default Chessboard;
+export default Chessboard;

+ 4 - 4
src/js/components/ChessboardInterface.js

@@ -1,13 +1,13 @@
-'use strict';
-
 import React from 'react/addons';
+import omit from 'lodash.omit';
+
 import GameStore from '../stores/GameStore';
 import GameActions from '../actions/GameActions';
 import onGameChange from '../mixins/onGameChange';
 import Chessboard from './Chessboard';
 import CapturedPieces from './CapturedPieces';
 import TableOfMoves from './TableOfMoves';
-import omit from 'lodash.omit';
+
 
 const ChessboardInterface = React.createClass({
   
@@ -114,4 +114,4 @@ const ChessboardInterface = React.createClass({
   }
 });
 
-export default ChessboardInterface;
+export default ChessboardInterface;

+ 3 - 3
src/js/components/Clock.js

@@ -1,8 +1,8 @@
-'use strict';
-
 import React from 'react/addons';
+
 import GameActions from '../actions/GameActions';
 
+
 const PureRenderMixin = React.addons.PureRenderMixin;
 
 const Clock = React.createClass({
@@ -80,4 +80,4 @@ const Timer = React.createClass({
   }
 });
 
-export default Clock;
+export default Clock;

+ 1 - 3
src/js/components/CreateGameForm.js

@@ -1,5 +1,3 @@
-'use strict';
-
 import React from 'react/addons';
 
 const CreateGameForm = React.createClass({
@@ -52,4 +50,4 @@ const CreateGameForm = React.createClass({
   }
 });
 
-export default CreateGameForm;
+export default CreateGameForm;

+ 4 - 4
src/js/components/GameHeader.js

@@ -1,10 +1,10 @@
-'use strict';
-
 import React from 'react/addons';
+import omit from 'lodash.omit';
+
 import Clock from './Clock';
 import ChatStore from '../stores/ChatStore';
 import ChatActions from '../actions/ChatActions';
-import omit from 'lodash.omit';
+
 
 const GameHeader = React.createClass({
   
@@ -98,4 +98,4 @@ const GameHeader = React.createClass({
   }
 });
 
-export default GameHeader;
+export default GameHeader;

+ 4 - 4
src/js/components/GameInterface.js

@@ -1,13 +1,13 @@
-'use strict';
-
 import React from 'react/addons';
+import {Map} from 'immutable';
+
 import GameHeader from './GameHeader';
 import Chat from './Chat';
 import Modal from './Modal';
 import GameActions from '../actions/GameActions';
 import GameStore from '../stores/GameStore';
 import ChessboardInterface from './ChessboardInterface';
-import {Map} from 'immutable';
+
 
 const GameInterface = React.createClass({
   
@@ -191,4 +191,4 @@ const GameInterface = React.createClass({
   },
 });
 
-export default GameInterface;
+export default GameInterface;

+ 3 - 3
src/js/components/Index.js

@@ -1,9 +1,9 @@
-'use strict';
-
 import React from 'react';
+
 import CreateGameForm from './CreateGameForm';
 import io from '../io';
 
+
 const Index = React.createClass({
   
   propTypes: {
@@ -97,4 +97,4 @@ const Index = React.createClass({
   }
 });
 
-export default Index;
+export default Index;

+ 3 - 3
src/js/components/Modal.js

@@ -1,8 +1,8 @@
-'use strict';
-
 import React from 'react/addons';
+
 import cx from 'classnames';
 
+
 const Modal = React.createClass({
   
   propTypes: {
@@ -85,4 +85,4 @@ const Modal = React.createClass({
   }
 });
 
-export default Modal;
+export default Modal;

+ 3 - 3
src/js/components/TableOfMoves.js

@@ -1,9 +1,9 @@
-'use strict';
-
 import React from 'react/addons';
+
 import GameStore from '../stores/GameStore';
 import onGameChange from '../mixins/onGameChange';
 
+
 const TableOfMoves = React.createClass({
   
   mixins: [React.addons.PureRenderMixin, onGameChange],
@@ -45,4 +45,4 @@ const TableOfMoves = React.createClass({
   }
 });
 
-export default TableOfMoves;
+export default TableOfMoves;

+ 2 - 1
src/js/constants/ChatConstants.js

@@ -1,6 +1,7 @@
 import keyMirror from 'react/lib/keyMirror';
 
+
 export default keyMirror({
   TOGGLE_VISIBILITY: null,
   SUBMIT_MESSAGE: null
-});
+});

+ 1 - 1
src/js/constants/ChessPieces.js

@@ -18,4 +18,4 @@ const ChessPieces = {
   '-': undefined
 };
 
-export default ChessPieces;
+export default ChessPieces;

+ 2 - 1
src/js/constants/GameConstants.js

@@ -1,8 +1,9 @@
 import keyMirror from 'react/lib/keyMirror';
 
+
 export default keyMirror({
   MAKE_MOVE: null,
   REMATCH: null,
   GAME_OVER: null,
   CHANGE_PROMOTION: null
-});
+});

+ 2 - 1
src/js/dispatcher/AppDispatcher.js

@@ -1,5 +1,6 @@
 import {Dispatcher} from 'flux';
 
+
 export default Object.assign(new Dispatcher(), {
   // @param {object} action The data coming from the view.
   handleViewAction: function(action) {
@@ -8,4 +9,4 @@ export default Object.assign(new Dispatcher(), {
       action: action
     });
   }
-});
+});

+ 3 - 3
src/js/index.js

@@ -1,10 +1,10 @@
-'use strict';
-
 import React from 'react';
+
 import io from './io';
 import Index from './components/Index';
 
+
 React.render(
   <Index io={io} />,
   document.getElementById('container')
-);
+);

+ 4 - 5
src/js/io.js

@@ -1,7 +1,6 @@
-'use strict';
-
 import io from 'socket.io-client';
-const ORIGIN = 'http://localhost:3000';
-const WS = ORIGIN;
 
-export default io.connect(WS);
+
+const HOST = 'http://localhost:3000';
+
+export default io.connect(HOST);

+ 3 - 4
src/js/play.js

@@ -1,10 +1,9 @@
-'use strict';
-
-import 'es6-shim';
 import React from 'react';
+
 import io from './io';
 import GameInterface from './components/GameInterface';
 
+
 let params = window.location.pathname.replace('/play/', '').split('/');
 params[1] = parseInt(params[1], 10);
 params[2] = parseInt(params[2], 10);
@@ -12,4 +11,4 @@ params[2] = parseInt(params[2], 10);
 React.render(
   <GameInterface io={io} params={params} />,
   document.getElementById('container')
-);
+);

+ 4 - 4
src/js/stores/ChatStore.js

@@ -1,9 +1,9 @@
-'use strict';
+import {EventEmitter2 as EventEmitter} from 'eventemitter2';
+import {List, Map} from 'immutable';
 
 import AppDispatcher from '../dispatcher/AppDispatcher';
-import {EventEmitter2 as EventEmitter} from 'eventemitter2';
 import ChatConstants from '../constants/ChatConstants';
-import {List, Map} from 'immutable';
+
 
 const CHANGE_EVENT = 'change';
   
@@ -57,4 +57,4 @@ AppDispatcher.register(payload => {
   return true;
 });
 
-export default ChatStore;
+export default ChatStore;

+ 5 - 5
src/js/stores/GameStore.js

@@ -1,11 +1,11 @@
-'use strict';
+import {EventEmitter2 as EventEmitter} from 'eventemitter2';
+import {Chess} from 'chess.js';
+import {List, Map, OrderedMap, Set} from 'immutable';
 
 import AppDispatcher from '../dispatcher/AppDispatcher';
-import {EventEmitter2 as EventEmitter} from 'eventemitter2';
 import GameConstants from '../constants/GameConstants';
 import ChessPieces from '../constants/ChessPieces';
-import {Chess} from 'chess.js';
-import {List, Map, OrderedMap, Set} from 'immutable';
+
 
 const CHANGE_EVENT = 'change';
 const MOVE_EVENT = 'new-move';
@@ -161,4 +161,4 @@ AppDispatcher.register(payload => {
   return true;
 });
 
-export default GameStore;
+export default GameStore;

+ 1 - 1
src/js/stores/__tests__/ChatStore-test.js

@@ -76,4 +76,4 @@ describe('ChatStore', () => {
     callback(actionToggleVisibility);
     expect(state.unseenCount).toBe(0);
   });
-});
+});

+ 1 - 1
src/js/stores/__tests__/GameStore-test.js

@@ -145,4 +145,4 @@ describe('GameStore', () => {
     expect(cp.get('w').isEmpty()).toBeTruthy();
     expect(cp.get('b').isEmpty()).toBeTruthy();
   });
-});
+});

+ 1 - 3
winston.js

@@ -1,5 +1,3 @@
-'use strict';
-
 const path = require('path');
 const winston = require('winston');
  
@@ -13,4 +11,4 @@ winston.remove(winston.transports.Console);
 winston.handleExceptions(new winston.transports.Console());
 winston.exitOnError = false;
 
-module.exports = winston;
+module.exports = winston;