From 9b6d3bdd774b39b1cad025fe6ea77f9c7cbc46c9 Mon Sep 17 00:00:00 2001 From: Waleed Khan Date: Thu, 9 Jun 2016 23:09:38 -0700 Subject: [PATCH 1/5] Bugfix: Chat box no longer cuts off last character. Fixes #10 --- public/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/public/style.css b/public/style.css index 5dd6ac6..7b3ac48 100644 --- a/public/style.css +++ b/public/style.css @@ -194,6 +194,7 @@ input[type=button]:disabled:active, button:disabled:active { flex-direction: column; height: 100%; position: fixed; + right: 5px; top: 0; width: 25%; z-index: 0; From 8c35e3bc4bbd0164922f001dba781345b463fefc Mon Sep 17 00:00:00 2001 From: Waleed Khan Date: Fri, 10 Jun 2016 20:21:51 -0700 Subject: [PATCH 2/5] Bugfix: Add 'config' target to 'all'. Fixes #17 Both the client and server config files will be automatically generated by 'make' if they are not present, instead of the server config file being generated only by 'make run'. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ee7f684..6ac2b7d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all install clean cards score js +.PHONY: all install clean cards score js config all: install cards score js node := ${CURDIR}/node_modules @@ -44,6 +44,7 @@ ${client_config}: | ${client_config}.default cp $| $@ ${server_config}: | ${server_config}.default cp $| $@ +config: ${client_config} ${server_config} run: js ${server_config} node run From d81e52d321286a6f4ddd5399e61702dd73d9c33a Mon Sep 17 00:00:00 2001 From: Waleed Khan Date: Thu, 16 Jun 2016 22:42:11 -0700 Subject: [PATCH 3/5] Add version number to startup message --- app.js | 2 +- config.server.js.default | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 7016bcf..003139b 100644 --- a/app.js +++ b/app.js @@ -16,4 +16,4 @@ var server = http.createServer(function(req, res) { var eioServer = eio(server).on('connection', router) require('log-timestamp') -console.log('Started up') +console.log(`Started up ${CONFIG.VERSION.RELEASE}+${CONFIG.VERSION.LOCAL_BUILD}`) diff --git a/config.server.js.default b/config.server.js.default index e799072..d742054 100644 --- a/config.server.js.default +++ b/config.server.js.default @@ -1,5 +1,13 @@ +const execSync = require('child_process').execSync + +const RELEASE = execSync('git describe').toString().trim() +const LOCAL_BUILD = parseInt( + execSync('git rev-list --count "$(git describe)..HEAD"').toString().trim(), + 10) + module.exports = { PORT: 1337, + VERSION: {RELEASE, LOCAL_BUILD}, STRINGS: { BRANDING: { DEFAULT_USERNAME: 'ninja', From 1faa901152cea60e306492c2816ac26c58f6c44f Mon Sep 17 00:00:00 2001 From: Waleed Khan Date: Fri, 17 Jun 2016 22:54:14 -0700 Subject: [PATCH 4/5] Display server version on homepage. Fixes #23 --- app.js | 2 +- config.server.js.default | 10 +++++----- public/src/app.js | 1 + public/src/components/lobby.js | 33 ++++++++++++++++++++++----------- public/src/components/spacer.js | 2 ++ src/router.js | 4 ++-- 6 files changed, 33 insertions(+), 19 deletions(-) diff --git a/app.js b/app.js index 003139b..36f0d00 100644 --- a/app.js +++ b/app.js @@ -16,4 +16,4 @@ var server = http.createServer(function(req, res) { var eioServer = eio(server).on('connection', router) require('log-timestamp') -console.log(`Started up ${CONFIG.VERSION.RELEASE}+${CONFIG.VERSION.LOCAL_BUILD}`) +console.log(`Started up ${CONFIG.VERSION}`) diff --git a/config.server.js.default b/config.server.js.default index d742054..1ae7a81 100644 --- a/config.server.js.default +++ b/config.server.js.default @@ -1,13 +1,13 @@ const execSync = require('child_process').execSync -const RELEASE = execSync('git describe').toString().trim() -const LOCAL_BUILD = parseInt( - execSync('git rev-list --count "$(git describe)..HEAD"').toString().trim(), - 10) +const VERSION = execSync('git describe') + .toString() + .trim() + .replace('-', '/') module.exports = { PORT: 1337, - VERSION: {RELEASE, LOCAL_BUILD}, + VERSION, STRINGS: { BRANDING: { DEFAULT_USERNAME: 'ninja', diff --git a/public/src/app.js b/public/src/app.js index fdee6e6..cd0cf7f 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -14,6 +14,7 @@ let App = { id: null, name: STRINGS.BRANDING.DEFAULT_USERNAME, + serverVersion: null, numUsers: 0, numPlayers: 0, numActiveGames: 0, diff --git a/public/src/components/lobby.js b/public/src/components/lobby.js index 55bfcc7..2731dd4 100644 --- a/public/src/components/lobby.js +++ b/public/src/components/lobby.js @@ -22,17 +22,7 @@ export default React.createClass({ d.header({}, d.h1({ className: 'lobby-header' }, Spaced(...STRINGS.BRANDING.SITE_NAME))), - - d.p({}, - Spaced( - `${App.state.numUsers} - ${App.state.numUsers === 1 ? 'user' : 'users'} - connected`, - `${App.state.numPlayers} - ${App.state.numPlayers === 1 ? 'player' : 'players'} - playing - ${App.state.numActiveGames} - ${App.state.numActiveGames === 1 ? 'game' : 'games'}`)), + ServerInfo(), d.p({ className: 'error' }, App.err), Create(), Join(), @@ -98,6 +88,27 @@ function Motd() { d.div({}, motd)) } +function ServerInfo() { + let numUsers = + `${App.state.numUsers} + ${App.state.numUsers === 1 ? 'user' : 'users'} + connected` + + let numPlayers = + `${App.state.numPlayers} + ${App.state.numPlayers === 1 ? 'player' : 'players'} + playing + ${App.state.numActiveGames} + ${App.state.numActiveGames === 1 ? 'game' : 'games'}` + + let serverVersion = + App.state.serverVersion + ? `Running ${App.state.serverVersion}` + : null + + return d.p({}, Spaced(...[numUsers, numPlayers, serverVersion])) +} + function Create() { let seats = _.seq(100, 2).map(x => d.option({}, x)) diff --git a/public/src/components/spacer.js b/public/src/components/spacer.js index 3af9393..8abe158 100644 --- a/public/src/components/spacer.js +++ b/public/src/components/spacer.js @@ -1,6 +1,8 @@ let d = React.DOM export function Spaced(...elements) { + elements = elements.filter(x => x) + let parts = [] for (let part of elements) { parts.push(d.span({}, part)) diff --git a/src/router.js b/src/router.js index 9fb2fb2..d17a0da 100644 --- a/src/router.js +++ b/src/router.js @@ -1,4 +1,4 @@ -const {MOTD} = require('../config.server') +const {VERSION} = require('../config.server') var Game = require('./game') var Room = require('./room') var Sock = require('./sock') @@ -40,5 +40,5 @@ module.exports = function (ws) { sock.on('create', create) Game.broadcastGameInfo() - sock.send('set', { motd: MOTD }) + sock.send('set', { serverVersion: VERSION }) } From c048c51c13da05d95a82fae428ea33f63cc46b9d Mon Sep 17 00:00:00 2001 From: Waleed Khan Date: Sat, 16 Jul 2016 14:29:19 -0700 Subject: [PATCH 5/5] Update version info to be more human-readable --- config.server.js.default | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/config.server.js.default b/config.server.js.default index 1ae7a81..25021a7 100644 --- a/config.server.js.default +++ b/config.server.js.default @@ -1,9 +1,24 @@ +'use strict'; + const execSync = require('child_process').execSync -const VERSION = execSync('git describe') +let versionInfo = execSync('git describe --always --long') .toString() .trim() - .replace('-', '/') +let versionInfoParts = versionInfo.split('-') + +const VERSION = + versionInfoParts.length === 3 + + // Show the number of commits past the most recent tag, and the commit hash + // identifier. For example, `v2.0.0+3 (123abc)` indicates three commits past + // version 2.0.0, at commit `123abc`. (In the `git-describe` output, there is + // always a `g` before the commit hash, which stands for 'git', so we remove + // that.) + ? `${versionInfoParts[0]}+${versionInfoParts[1]} (${versionInfoParts[2].slice(1)})` + + // If there is no tag, just display the commit hash. + : versionInfo module.exports = { PORT: 1337,