From 09e264535cc69404fd6b2ec89dafaa702c476317 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 26 Oct 2017 20:09:18 -0400 Subject: [PATCH 001/155] mods --- nodegame-installer.js | 679 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 679 insertions(+) create mode 100644 nodegame-installer.js diff --git a/nodegame-installer.js b/nodegame-installer.js new file mode 100644 index 00000000..d304683a --- /dev/null +++ b/nodegame-installer.js @@ -0,0 +1,679 @@ +#!/usr/local/bin/node +/** + * # nodeGame Installer + * Copyright(c) 2017 Stefano Balietti + * MIT Licensed + * + * + * http://www.nodegame.org + */ + +"use strict"; + +// Modules. + +const isWin = /^win/.test(process.platform); + +const path = require('path'); +const fs = require('fs'); +const execFile = require('child_process').execFile; +const readline = require('readline'); + +const logList = txt => { + console.log(' - ' + txt); +}; +const log = txt => { + if ('undefined' === typeof txt) console.log(); + else console.log(' ' + txt); +}; +const err = txt => { + console.error(' ' + txt); +}; + +if (process.argv.indexOf('--help') !== -1) { + printHelp(); + return; +} + +var verbose = false; +var nodeModulesExisting = false; +var isDev = false; +var doSSH = false; +var noSpinner = false; +var doNotMoveInstall = false; +var yes; +var branch; +var warnings; + +const MAIN_MODULE = 'nodegame-test'; + +// Installer default version. +const INSTALLER_VERSION = "4.0.8"; + +// The actual version being installed, user can change it. +var version = INSTALLER_VERSION; +// User requested version; +var requestedVersion = requestedVersion = '@' + version; + +for (let i = 0; i < process.argv.length; i++) { + if (process.argv[i].charAt(0) === '@') { + requestedVersion = process.argv[i].substr(1); + + if (requestedVersion === 'dev') { + isDev = true; + version = INSTALLER_VERSION; + requestedVersion = '@' + version; + if (process.argv.indexOf('--ssh') !== -1) doSSH = true; + branch = process.argv.indexOf('--branch'); + if (branch !== -1) { + branch = process.argv[branch+1]; + if (!branch) { + err('--branch option found, ' + + 'but no value provided.'); + log(); + return; + } + } + else { + branch = undefined; + } + } + else { + version = requestedVersion; + if (version.length < 1 || version.length > 5) { + err('Error: invalid version number: ', version); + log(); + return; + } + requestedVersion = '@' + requestedVersion; + } + break; + } +} + +if (process.argv.indexOf('--no-spinner') !== -1) noSpinner = true; +if (process.argv.indexOf('--yes') !== -1) yes = true; + +// nodeGame version. +const VERSION = isDev ? "v" + version + '-dev' : "v" + version; + +const NODEGAME_AND_VERSION = 'nodegame-' + VERSION; + +const ROOT_DIR = process.cwd() +const NODE_MODULES_DIR = path.resolve(ROOT_DIR, 'node_modules'); + +let installDir = process.argv.indexOf('--install-dir'); +if (installDir !== -1) { + installDir = process.argv[installDir+1]; + if (!installDir) { + err('--install-dir option found, but no value provided.'); + log(); + return; + } + installDir = path.join(ROOT_DIR, installDir); + if (installDir === NODE_MODULES_DIR) doNotMoveInstall = true; +} +else { + installDir = NODEGAME_AND_VERSION; +} + +const INSTALL_DIR = doNotMoveInstall ? + path.resolve(NODE_MODULES_DIR, MAIN_MODULE) : + path.resolve(ROOT_DIR, installDir); + +const INSTALL_DIR_MODULES = doNotMoveInstall ? + NODE_MODULES_DIR : path.resolve(INSTALL_DIR, 'node_modules'); + +const NODEGAME_MODULES = [ + 'nodegame-server', 'nodegame-client', + 'nodegame-window', 'nodegame-widgets', + 'nodegame-monitor', 'nodegame-game-template', + 'nodegame-requirements', 'nodegame-generator', + // No need to replace these now. + // 'nodegame-db', 'nodegame-mondodb', + 'JSUS', 'NDDB', + 'ultimatum-game' +]; +const N_MODULES = NODEGAME_MODULES.length; + +const GAMES_AVAILABLE_DIR = path.resolve(INSTALL_DIR, + 'games_available'); +const GAMES_ENABLED_DIR = path.resolve(INSTALL_DIR, 'games'); + +// Printing Info. + +// Print cool nodegame logo. +printNodeGameInfo(); + +// Print node and nodeGame version (npm too?). +printInstallInfo(); + + +// Check node version is. +var nodeVersion = process.versions.node.split('.'); +if (parseInt(nodeVersion[0], 10) < 4) { + err('Error: node version >= 4.x is required.'); + err('Please upgrade your Node.Js installation, ' + + 'visit: http://nodejs.org'); + log(); + return; +} + +// Check if install dir exists (abort). +if (fs.existsSync(INSTALL_DIR)) { + err('Error: installation directory already existing.'); + log(); + return; +} + +// Check if node_modules exists (prompt continue?) +if (fs.existsSync(NODE_MODULES_DIR)) { + nodeModulesExisting = true; + err('Warning: node_modules directory already existing.'); + console.log('YES is: ', yes); + if (!yes) { + confirm(' Continue? [y/n] ', function(ok) { + if (ok) { + process.stdin.destroy(); + log(); + doInstall(); + } + else { + err('Installation aborted.'); + log(); + } + }) + return; + } + else { + log('Continue? [y/n] --yes'); + log(); + } +} + +// Install. +doInstall(); + + + +// Helper functions. +/////////////////////////////////////////////////////////////////////////////// + +function doInstall() { + var sp; + // Create spinner. + log('Downloading and installing nodeGame packages.'); + + if (!noSpinner) { + sp = new Spinner(' This might take a few minutes %s '); + sp.start(); + } + else { + log('This might take a few minutes...'); + } + + let child = execFile( + isWin ? 'npm.cmd' : 'npm', + [ 'install', MAIN_MODULE + requestedVersion ], + { cwd: ROOT_DIR }, + (error, stdout, stderr) => { + // Stop spinner. + if (!noSpinner) sp.stop(); + + if (error) { + log(); + log(); + log('Oops! The following error/s occurred: '); + log(); + logList(stderr.trim()); + log(); + return; + } + else { + if (verbose) logList(stdout.trim()); + log(); + log('Done! Now some finishing magics...'); + try { + someMagic(); + } + catch(e) { + // execFile( + // 'ls', + // [ '-la' ], + // (error, stdout, stderr) => { + // if (error) { + // logList(stderr.trim()); + // log(); + // } + // else { + // logList(stdout.trim()); + // } + // }); + // execFile( + // 'ls', + // [ '../node_modules/', '-la' ], + // (error, stdout, stderr) => { + // if (error) { + // logList(stderr.trim()); + // log(); + // } + // else { + // logList(stdout.trim()); + // } + // }); + err('Oops! The following error/s occurred: '); + log(); + console.error(e); + installationFailed(); + return; + } + } + }); +} + +// Helper stuff. +//////////////// + +function printNodeGameInfo() { + log(); + log('*********************************************** '); + log('** WELCOME TO NODEGAME INSTALLER v' + INSTALLER_VERSION + + ' ** '); + log('*********************************************** '); + log(); + log('nodeGame: fast, scalable JavaScript for online, large-scale,'); + log('multiplayer, real-time games and experiments in the browser.'); + + log(); + log('creator: Stefano Balietti'); + log('website: http://nodegame.org'); + log('license: MIT'); + log('mail: info@nodegame.org'); + log('twitter: @nodegameorg'); + log('bugs: https://github.com/nodeGame/nodegame/issues'); + log('forum: https://groups.google.com/' + + 'forum/?fromgroups#!forum/nodegame'); +} + +function printInstallInfo() { + let str; + log(); + log('----------------------------------------------'); + log(); + + log('node version: ' + process.version); + str = 'nodeGame version: ' + VERSION; + if (branch) str += ' (' + branch + ')'; + log(str); + str = 'install directory: ' + INSTALL_DIR; + if (doNotMoveInstall) str += ' (npm structure)'; + log(str); + log(); + log(); +} + +function printFinalInfo() { + log(); + let str = ' Installation complete!'; + if (warnings) str += ' (with warnings)'; + log(str); + log('----------------------------------------------'); + + log('Enter the installation directory and start the server:'); + if (!doNotMoveInstall) { + log(' cd ' + NODEGAME_AND_VERSION); + } + else { + log(' cd ' + path.join('node_modules', MAIN_MODULE)); + } + log(' node launcher.js'); + log(); + + log('Open a browser tab at the address:'); + log(' http://localhost:8080/ultimatum'); + log(); + + log('Open another tab with an autoplay player:'); + log(' http://localhost:8080/ultimatum?clientType=autoplay'); + log(); + + log('Check the monitor interface:'); + log(' http://localhost:8080/ultimatum/monitor'); + log(); + + log('Create a new game:'); + log(' bin/nodegame create-game mygame'); + log(); + + log('Please cite as:'); + log('----------------------------------------------'); + log(' Balietti (2017) "nodeGame: Real-Time, Synchronous, ' + + 'Online Experiments '); + log(' in the Browser." Behavior Research Methods ' + + '49(5) pp. 1696–1715'); + log(); +} + + +function someMagic() { + + if (!doNotMoveInstall) { + // Move nodegame folder outside node_modules. + fs.renameSync(path.resolve(NODE_MODULES_DIR, MAIN_MODULE), INSTALL_DIR); + + // Old npms put already all modules under nodegame. + if (!fs.existsSync(INSTALL_DIR_MODULES)) { + fs.renameSync(NODE_MODULES_DIR, + INSTALL_DIR_MODULES); + } + else if (!nodeModulesExisting) { + fs.rmdirSync(NODE_MODULES_DIR); + } + } + + // nodeGame generator: make link and store conf. + + makeLink(path.resolve(INSTALL_DIR_MODULES, + 'nodegame-generator', + 'bin', 'nodegame'), + path.resolve(INSTALL_DIR, 'bin', 'nodegame'), + 'file'); + + + fs.writeFileSync(path.resolve(INSTALL_DIR_MODULES, + 'nodegame-generator', + 'conf', + 'generator.conf.json'), + JSON.stringify({ + author: "", + email: "", + gamesFolder: GAMES_AVAILABLE_DIR + }, 4)); + + + if (isDev) { + getAllGitModules(function() { + // Move games from node_modules. + copyGameFromNodeModules('ultimatum-game'); + // Print final Information. + printFinalInfo(); + }); + } + else { + // Move games from node_modules. + copyGameFromNodeModules('ultimatum-game'); + // Print final Information. + printFinalInfo(); + } +} + +function getAllGitModules(cb) { + let counter = NODEGAME_MODULES.length; + if (verbose) log('Converting modules into git repos.'); + for (let i = 0; i < NODEGAME_MODULES.length; i++) { + (function(i) { + var nodeModulesCopy; + let module = NODEGAME_MODULES[i]; + let modulePath = path.resolve(INSTALL_DIR_MODULES, module); + let nodeModulesPath = path.resolve(modulePath, 'node_modules'); + + // Keep node_modules, if any. + if (fs.existsSync(nodeModulesPath)) { + + // Remove nodegame modules (if any) will be get by git. + fs.readdirSync(nodeModulesPath).forEach(function(file, index) { + if (inArray(file, NODEGAME_MODULES)) { + let modulePath = path.join(nodeModulesPath, file); + removeDirRecursiveSync(modulePath); + } + }); + + nodeModulesCopy = path.resolve(NODE_MODULES_DIR, + ('_node_modules-' + module)); + fs.renameSync(nodeModulesPath, nodeModulesCopy); + } + + // Remove npm folder. + removeDirRecursiveSync(modulePath); + + setTimeout(function() { + getGitModule(module, INSTALL_DIR_MODULES, function(err) { + if (err) throw new Error(err); + // Put back node_modules, if it was copied before. + if (nodeModulesCopy) { + fs.renameSync(nodeModulesCopy, nodeModulesPath); + } + counter--; + if (counter == 0 && cb) cb(); + }); + }, 100); + })(i); + } +} + +function getGitModule(module, cwd, cb, noBranch) { + let repo = doSSH ? 'git@github.com:' : 'https://github.com/'; + repo += 'nodeGame/' + module + '.git'; + if (verbose) log('Cloning git module: ' + module); + let params = !noBranch && branch ? + [ 'clone', '-b', branch, repo ] : [ 'clone', repo ]; + let child = execFile( + 'git', + params, + { cwd: cwd }, + (error, stdout, stderr) => { + if (error) { + // If it could not checkout a branch, it could just + // be that the branch does not exists, so just warning. + if (!noBranch && branch && + stderr.indexOf('Remote branch') !== -1 && + stderr.indexOf('not found in upstream') !== -1) { + + error = null; + let warnStr = ' Warning! module ' + module + + ' branch not found: ' + branch; + log(warnStr); + warnings = true; + getGitModule(module, cwd, cb, true); + return; + } + else { + logList('Could not clone: ' + module); + logList(stderr.trim()); + } + log(); + } + else if (verbose) { + logList(stdout.trim()); + } + if (cb) cb(error); + }); +} + +function makeLink(from, to, type) { + if (isWin) { + if (type === 'file') fs.linkSync(from, to, 'file'); + else fs.symlinkSync(from, to, 'junction'); + } + else { + fs.symlinkSync(from, to); + } +} + +function copyGameFromNodeModules(game, enable) { + enable = 'undefined' === typeof enable ? true : enable; + let gameDir = path.resolve(GAMES_AVAILABLE_DIR, game); + + // Move game from node_modules into games_available directory. + fs.renameSync(path.resolve(INSTALL_DIR_MODULES, game), gameDir); + + // Make sure that the test command works. + let tmpPath = path.join(gameDir, 'node_modules'); + if (!fs.existsSync(tmpPath)) fs.mkdirSync(tmpPath); + tmpPath = path.join(tmpPath, '.bin'); + if (!fs.existsSync(tmpPath)) fs.mkdirSync(tmpPath); + tmpPath = path.join(tmpPath, 'mocha'); + if (!fs.existsSync(tmpPath)) { + makeLink(path.join(INSTALL_DIR_MODULES, '.bin/mocha'), tmpPath); + } + + if (!enable) return; + + // Enable gapath.resolve(GAMES_AVAILABLE_DIR, game). + makeLink(gameDir, path.resolve(GAMES_ENABLED_DIR, game)); +} + +function confirm(msg, callback) { + var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + + rl.question(msg, function(input) { + rl.close(); + callback(/^y|yes|ok|true$/i.test(input)); + }); +} + +function removeDirRecursiveSync(dir) { + if (dir === '/') { + throw new Error(' removeDirRecursiveSync error: cannot remove "/"'); + } + if (dir.indexOf(INSTALL_DIR_MODULES) === -1) { + err(' removeDirRecursiveSync error: there seems to be ' + + 'an error with the path to remove: '); + console.error(dir); + } + if (fs.existsSync(dir)) { + fs.readdirSync(dir).forEach(function(file, index){ + let curPath = path.join(dir, file); + // Recurse. + if (fs.lstatSync(curPath).isDirectory()) { + removeDirRecursiveSync(curPath); + } + else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(dir); + } +}; + +function installationFailed() { + + log(); + + err('Installation did not complete successfully.'); + log('----------------------------------------------'); + log(); + + err('If you think this might be a bug, please report it. ' + + 'You can either:'); + err(' - open an issue at: ' + + 'https://github.com/nodeGame/nodegame/issues'); + err(' - send an email to info@nodegame.org'); + log(); +} + + +function printHelp() { + + log(); + log('@ Install a specific version (>=3.5.1)'); + log('@dev Install from git repos, when available'); + log('--branch Checkout this branch on all git repos'); + log('--yes Answer yes to all questions'); + log('--install-dir Set the name of the installation directory;'); + log(' if equals to node_modules, the npm structure'); + log(' stays unchanged'); + log('--no-spinner Does not start the spinner'); + log('--help Print this help'); + log(); +} + +// Kudos: cli-spinner package. + +function Spinner(text) { + var that; + that = this; + + this.spinners = [ + "|/-\\", + "⠂-–—–-", + "◐◓◑◒", + "◴◷◶◵", + "◰◳◲◱", + "▖▘▝▗", + "■□▪▫", + "▌▀▐▄", + "▉▊▋▌▍▎▏▎▍▌▋▊▉", + "▁▃▄▅▆▇█▇▆▅▄▃", + "←↖↑↗→↘↓↙", + "┤┘┴└├┌┬┐", + "◢◣◤◥", + ".oO°Oo.", + ".oO@*", + "🌍🌎🌏", + "◡◡ ⊙⊙ ◠◠", + "☱☲☴", + "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏", + "⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓", + "⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆", + "⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋", + "⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁", + "⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈", + "⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈", + "⢄⢂⢁⡁⡈⡐⡠", + "⢹⢺⢼⣸⣇⡧⡗⡏", + "⣾⣽⣻⢿⡿⣟⣯⣷", + "⠁⠂⠄⡀⢀⠠⠐⠈" + ]; + + this.text = text || ''; + + this.chars = this.spinners[isWin ? 0 : 4].split(''); + + this.delay = 60; + + this.onTick = function(msg) { + this.clearLine(this.stream); + this.stream.write(msg); + }; + + this.stream = process.stdout; + + this.start = function() { + var current = 0; + var self = this; + this.id = setInterval(function() { + var msg = self.text.indexOf('%s') > -1 + ? self.text.replace('%s', self.chars[current]) + : self.chars[current] + ' ' + self.text; + self.onTick(msg); + + current = ++current % self.chars.length; + }, this.delay); + }; + + this.stop = function(clear) { + clearInterval(this.id); + this.id = undefined; + if (clear && this.enabled) this.clearLine(this.stream); + }; + + this.clearLine = function(stream) { + readline.clearLine(stream, 0); + readline.cursorTo(stream, 0); + }; +}; + +function inArray(needle, haystack) { + var func, i, len; + len = haystack.length; + for (i = 0; i < len; i++) { + if (needle === haystack[i]) { + return needle; + } + } + return false; +} From eb4c7c14e2862b3a2b23bf01a663d2dc65b7ff10 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 26 Oct 2017 20:43:12 -0400 Subject: [PATCH 002/155] 3.5.1 --- .../nodegame-installer.js | 0 package.json | 47 ++++++++++++------- 2 files changed, 30 insertions(+), 17 deletions(-) rename nodegame-installer.js => bin/nodegame-installer.js (100%) diff --git a/nodegame-installer.js b/bin/nodegame-installer.js similarity index 100% rename from nodegame-installer.js rename to bin/nodegame-installer.js diff --git a/package.json b/package.json index 89772db7..50c24fb7 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,38 @@ { "name": "nodegame" - , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "3.5.0" - , "homepage": "http://nodegame.org" - , "author": "Stefano Balietti " - , "contributors": [ + , "description": "Starter package for nodegame: install scripts, configurations and development files." + , "version": "3.5.1" + , "homepage": "http://nodegame.org" + , "author": "Stefano Balietti " + , "contributors": [ { "name": "Stefano Balietti", "email": "futur.dorko@gmail.com" } ] - , "repository": { + , "repository": { "type": "git" - , "url": "https://github.com/nodeGame/nodegame.git" + , "url": "https://github.com/nodeGame/nodegame.git" } - , "engines": { "node": ">= 0.10.0" } - , "dependencies" : { - "commander": "*", - "fs-extra": "*", - "ya-csv": "*", - "smoosh": "0.4.0" + , "engines": { "node": ">= 0.10.0" } + , "dependencies" : { + "commander": "*", + "fs-extra": "*", + "smoosh": "0.4.0", + "nodegame-server": "*", + "nodegame-client": "*", + "nodegame-window": "*", + "nodegame-widgets": "*", + "nodegame-requirements": "*", + "nodegame-game-template": "*", + "nodegame-monitor": "*", + "nodegame-db": "*", + "nodegame-mongodb": "*", + "nodegame-generator": "*", + "nodegame-mturk": "*", + "JSUS": "*", + "NDDB": "*", + "ultimatum-game": "*" } - , "license": "MIT" - , "scripts": { - "start": "node launcher.js" - } + , "license": "MIT" + , "scripts": { + "start": "node launcher.js" + } } From bc4d9a4bc4c902d27d5bdf4aafc1f4f8b8aff847 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 26 Oct 2017 21:11:50 -0400 Subject: [PATCH 003/155] mods --- nodegame.js => bin/nodegame-cli-new.js | 0 bin/nodegame-installer.js | 10 +- nodegame-installer.js | 678 ------------------------- 3 files changed, 6 insertions(+), 682 deletions(-) rename nodegame.js => bin/nodegame-cli-new.js (100%) mode change 100644 => 100755 bin/nodegame-installer.js delete mode 100755 nodegame-installer.js diff --git a/nodegame.js b/bin/nodegame-cli-new.js similarity index 100% rename from nodegame.js rename to bin/nodegame-cli-new.js diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js old mode 100644 new mode 100755 index d7a8a7aa..d092d914 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -45,10 +45,10 @@ var yes; var branch; var warnings; -const MAIN_MODULE = 'nodegame'; +const MAIN_MODULE = 'nodegame-test'; // Installer default version. -const INSTALLER_VERSION = "4.0.0"; +const INSTALLER_VERSION = "4.0.8"; // The actual version being installed, user can change it. var version = INSTALLER_VERSION; @@ -170,7 +170,6 @@ if (fs.existsSync(INSTALL_DIR)) { if (fs.existsSync(NODE_MODULES_DIR)) { nodeModulesExisting = true; err('Warning: node_modules directory already existing.'); - console.log('YES is: ', yes); if (!yes) { confirm(' Continue? [y/n] ', function(ok) { if (ok) { @@ -358,6 +357,7 @@ function printFinalInfo() { function someMagic() { if (!doNotMoveInstall) { + debugger // Move nodegame folder outside node_modules. fs.renameSync(path.resolve(NODE_MODULES_DIR, MAIN_MODULE), INSTALL_DIR); @@ -428,7 +428,9 @@ function getAllGitModules(cb) { } }); - nodeModulesCopy = path.resolve(NODE_MODULES_DIR, + let destDir = doNotMoveInstall ? + NODE_MODULES_DIR : INSTALL_DIR_MODULES; + nodeModulesCopy = path.resolve(destDir, ('_node_modules-' + module)); fs.renameSync(nodeModulesPath, nodeModulesCopy); } diff --git a/nodegame-installer.js b/nodegame-installer.js deleted file mode 100755 index 4aaac46f..00000000 --- a/nodegame-installer.js +++ /dev/null @@ -1,678 +0,0 @@ -#!/usr/local/bin/node -/** - * # nodeGame Installer - * Copyright(c) 2017 Stefano Balietti - * MIT Licensed - * - * - * http://www.nodegame.org - */ - -"use strict"; - -// Modules. - -const isWin = /^win/.test(process.platform); - -const path = require('path'); -const fs = require('fs'); -const execFile = require('child_process').execFile; -const readline = require('readline'); - -const logList = txt => { - console.log(' - ' + txt); -}; -const log = txt => { - if ('undefined' === typeof txt) console.log(); - else console.log(' ' + txt); -}; -const err = txt => { - console.error(' ' + txt); -}; - -if (process.argv.indexOf('--help') !== -1) { - printHelp(); - return; -} - -var verbose = false; -var nodeModulesExisting = false; -var isDev = false; -var doSSH = false; -var noSpinner = false; -var doNotMoveInstall = false; -var yes; -var branch; -var warnings; - -const MAIN_MODULE = 'nodegame-test'; - -// Installer default version. -const INSTALLER_VERSION = "4.0.8"; - -// The actual version being installed, user can change it. -var version = INSTALLER_VERSION; -// User requested version; -var requestedVersion = requestedVersion = '@' + version; - -for (let i = 0; i < process.argv.length; i++) { - if (process.argv[i].charAt(0) === '@') { - requestedVersion = process.argv[i].substr(1); - - if (requestedVersion === 'dev') { - isDev = true; - version = INSTALLER_VERSION; - requestedVersion = '@' + version; - if (process.argv.indexOf('--ssh') !== -1) doSSH = true; - branch = process.argv.indexOf('--branch'); - if (branch !== -1) { - branch = process.argv[branch+1]; - if (!branch) { - err('--branch option found, ' + - 'but no value provided.'); - log(); - return; - } - } - else { - branch = undefined; - } - } - else { - version = requestedVersion; - if (version.length < 1 || version.length > 5) { - err('Error: invalid version number: ', version); - log(); - return; - } - requestedVersion = '@' + requestedVersion; - } - break; - } -} - -if (process.argv.indexOf('--no-spinner') !== -1) noSpinner = true; -if (process.argv.indexOf('--yes') !== -1) yes = true; - -// nodeGame version. -const VERSION = isDev ? "v" + version + '-dev' : "v" + version; - -const NODEGAME_AND_VERSION = 'nodegame-' + VERSION; - -const ROOT_DIR = process.cwd() -const NODE_MODULES_DIR = path.resolve(ROOT_DIR, 'node_modules'); - -let installDir = process.argv.indexOf('--install-dir'); -if (installDir !== -1) { - installDir = process.argv[installDir+1]; - if (!installDir) { - err('--install-dir option found, but no value provided.'); - log(); - return; - } - installDir = path.join(ROOT_DIR, installDir); - if (installDir === NODE_MODULES_DIR) doNotMoveInstall = true; -} -else { - installDir = NODEGAME_AND_VERSION; -} - -const INSTALL_DIR = doNotMoveInstall ? - path.resolve(NODE_MODULES_DIR, MAIN_MODULE) : - path.resolve(ROOT_DIR, installDir); - -const INSTALL_DIR_MODULES = doNotMoveInstall ? - NODE_MODULES_DIR : path.resolve(INSTALL_DIR, 'node_modules'); - -const NODEGAME_MODULES = [ - 'nodegame-server', 'nodegame-client', - 'nodegame-window', 'nodegame-widgets', - 'nodegame-monitor', 'nodegame-game-template', - 'nodegame-requirements', 'nodegame-generator', - // No need to replace these now. - // 'nodegame-db', 'nodegame-mondodb', - 'JSUS', 'NDDB', - 'ultimatum-game' -]; -const N_MODULES = NODEGAME_MODULES.length; - -const GAMES_AVAILABLE_DIR = path.resolve(INSTALL_DIR, - 'games_available'); -const GAMES_ENABLED_DIR = path.resolve(INSTALL_DIR, 'games'); - -// Printing Info. - -// Print cool nodegame logo. -printNodeGameInfo(); - -// Print node and nodeGame version (npm too?). -printInstallInfo(); - - -// Check node version is. -var nodeVersion = process.versions.node.split('.'); -if (parseInt(nodeVersion[0], 10) < 4) { - err('Error: node version >= 4.x is required.'); - err('Please upgrade your Node.Js installation, ' + - 'visit: http://nodejs.org'); - log(); - return; -} - -// Check if install dir exists (abort). -if (fs.existsSync(INSTALL_DIR)) { - err('Error: installation directory already existing.'); - log(); - return; -} - -// Check if node_modules exists (prompt continue?) -if (fs.existsSync(NODE_MODULES_DIR)) { - nodeModulesExisting = true; - err('Warning: node_modules directory already existing.'); - if (!yes) { - confirm(' Continue? [y/n] ', function(ok) { - if (ok) { - process.stdin.destroy(); - log(); - doInstall(); - } - else { - err('Installation aborted.'); - log(); - } - }) - return; - } - else { - log('Continue? [y/n] --yes'); - log(); - } -} - -// Install. -doInstall(); - - - -// Helper functions. -/////////////////////////////////////////////////////////////////////////////// - -function doInstall() { - var sp; - // Create spinner. - log('Downloading and installing nodeGame packages.'); - - if (!noSpinner) { - sp = new Spinner(' This might take a few minutes %s '); - sp.start(); - } - else { - log('This might take a few minutes...'); - } - - let child = execFile( - isWin ? 'npm.cmd' : 'npm', - [ 'install', MAIN_MODULE + requestedVersion ], - { cwd: ROOT_DIR }, - (error, stdout, stderr) => { - // Stop spinner. - if (!noSpinner) sp.stop(); - - if (error) { - log(); - log(); - log('Oops! The following error/s occurred: '); - log(); - logList(stderr.trim()); - log(); - return; - } - else { - if (verbose) logList(stdout.trim()); - log(); - log('Done! Now some finishing magics...'); - try { - someMagic(); - } - catch(e) { - // execFile( - // 'ls', - // [ '-la' ], - // (error, stdout, stderr) => { - // if (error) { - // logList(stderr.trim()); - // log(); - // } - // else { - // logList(stdout.trim()); - // } - // }); - // execFile( - // 'ls', - // [ '../node_modules/', '-la' ], - // (error, stdout, stderr) => { - // if (error) { - // logList(stderr.trim()); - // log(); - // } - // else { - // logList(stdout.trim()); - // } - // }); - err('Oops! The following error/s occurred: '); - log(); - console.error(e); - installationFailed(); - return; - } - } - }); -} - -// Helper stuff. -//////////////// - -function printNodeGameInfo() { - log(); - log('*********************************************** '); - log('** WELCOME TO NODEGAME INSTALLER v' + INSTALLER_VERSION + - ' ** '); - log('*********************************************** '); - log(); - log('nodeGame: fast, scalable JavaScript for online, large-scale,'); - log('multiplayer, real-time games and experiments in the browser.'); - - log(); - log('creator: Stefano Balietti'); - log('website: http://nodegame.org'); - log('license: MIT'); - log('mail: info@nodegame.org'); - log('twitter: @nodegameorg'); - log('bugs: https://github.com/nodeGame/nodegame/issues'); - log('forum: https://groups.google.com/' + - 'forum/?fromgroups#!forum/nodegame'); -} - -function printInstallInfo() { - let str; - log(); - log('----------------------------------------------'); - log(); - - log('node version: ' + process.version); - str = 'nodeGame version: ' + VERSION; - if (branch) str += ' (' + branch + ')'; - log(str); - str = 'install directory: ' + INSTALL_DIR; - if (doNotMoveInstall) str += ' (npm structure)'; - log(str); - log(); - log(); -} - -function printFinalInfo() { - log(); - let str = ' Installation complete!'; - if (warnings) str += ' (with warnings)'; - log(str); - log('----------------------------------------------'); - - log('Enter the installation directory and start the server:'); - if (!doNotMoveInstall) { - log(' cd ' + NODEGAME_AND_VERSION); - } - else { - log(' cd ' + path.join('node_modules', MAIN_MODULE)); - } - log(' node launcher.js'); - log(); - - log('Open a browser tab at the address:'); - log(' http://localhost:8080/ultimatum'); - log(); - - log('Open another tab with an autoplay player:'); - log(' http://localhost:8080/ultimatum?clientType=autoplay'); - log(); - - log('Check the monitor interface:'); - log(' http://localhost:8080/ultimatum/monitor'); - log(); - - log('Create a new game:'); - log(' bin/nodegame create-game mygame'); - log(); - - log('Please cite as:'); - log('----------------------------------------------'); - log(' Balietti (2017) "nodeGame: Real-Time, Synchronous, ' + - 'Online Experiments '); - log(' in the Browser." Behavior Research Methods ' + - '49(5) pp. 1696–1715'); - log(); -} - - -function someMagic() { - - if (!doNotMoveInstall) { - // Move nodegame folder outside node_modules. - fs.renameSync(path.resolve(NODE_MODULES_DIR, MAIN_MODULE), INSTALL_DIR); - - // Old npms put already all modules under nodegame. - if (!fs.existsSync(INSTALL_DIR_MODULES)) { - fs.renameSync(NODE_MODULES_DIR, - INSTALL_DIR_MODULES); - } - else if (!nodeModulesExisting) { - fs.rmdirSync(NODE_MODULES_DIR); - } - } - - // nodeGame generator: make link and store conf. - - makeLink(path.resolve(INSTALL_DIR_MODULES, - 'nodegame-generator', - 'bin', 'nodegame'), - path.resolve(INSTALL_DIR, 'bin', 'nodegame'), - 'file'); - - - fs.writeFileSync(path.resolve(INSTALL_DIR_MODULES, - 'nodegame-generator', - 'conf', - 'generator.conf.json'), - JSON.stringify({ - author: "", - email: "", - gamesFolder: GAMES_AVAILABLE_DIR - }, 4)); - - - if (isDev) { - getAllGitModules(function() { - // Move games from node_modules. - copyGameFromNodeModules('ultimatum-game'); - // Print final Information. - printFinalInfo(); - }); - } - else { - // Move games from node_modules. - copyGameFromNodeModules('ultimatum-game'); - // Print final Information. - printFinalInfo(); - } -} - -function getAllGitModules(cb) { - let counter = NODEGAME_MODULES.length; - if (verbose) log('Converting modules into git repos.'); - for (let i = 0; i < NODEGAME_MODULES.length; i++) { - (function(i) { - var nodeModulesCopy; - let module = NODEGAME_MODULES[i]; - let modulePath = path.resolve(INSTALL_DIR_MODULES, module); - let nodeModulesPath = path.resolve(modulePath, 'node_modules'); - - // Keep node_modules, if any. - if (fs.existsSync(nodeModulesPath)) { - - // Remove nodegame modules (if any) will be get by git. - fs.readdirSync(nodeModulesPath).forEach(function(file, index) { - if (inArray(file, NODEGAME_MODULES)) { - let modulePath = path.join(nodeModulesPath, file); - removeDirRecursiveSync(modulePath); - } - }); - - nodeModulesCopy = path.resolve(NODE_MODULES_DIR, - ('_node_modules-' + module)); - fs.renameSync(nodeModulesPath, nodeModulesCopy); - } - - // Remove npm folder. - removeDirRecursiveSync(modulePath); - - setTimeout(function() { - getGitModule(module, INSTALL_DIR_MODULES, function(err) { - if (err) throw new Error(err); - // Put back node_modules, if it was copied before. - if (nodeModulesCopy) { - fs.renameSync(nodeModulesCopy, nodeModulesPath); - } - counter--; - if (counter == 0 && cb) cb(); - }); - }, 100); - })(i); - } -} - -function getGitModule(module, cwd, cb, noBranch) { - let repo = doSSH ? 'git@github.com:' : 'https://github.com/'; - repo += 'nodeGame/' + module + '.git'; - if (verbose) log('Cloning git module: ' + module); - let params = !noBranch && branch ? - [ 'clone', '-b', branch, repo ] : [ 'clone', repo ]; - let child = execFile( - 'git', - params, - { cwd: cwd }, - (error, stdout, stderr) => { - if (error) { - // If it could not checkout a branch, it could just - // be that the branch does not exists, so just warning. - if (!noBranch && branch && - stderr.indexOf('Remote branch') !== -1 && - stderr.indexOf('not found in upstream') !== -1) { - - error = null; - let warnStr = ' Warning! module ' + module + - ' branch not found: ' + branch; - log(warnStr); - warnings = true; - getGitModule(module, cwd, cb, true); - return; - } - else { - logList('Could not clone: ' + module); - logList(stderr.trim()); - } - log(); - } - else if (verbose) { - logList(stdout.trim()); - } - if (cb) cb(error); - }); -} - -function makeLink(from, to, type) { - if (isWin) { - if (type === 'file') fs.linkSync(from, to, 'file'); - else fs.symlinkSync(from, to, 'junction'); - } - else { - fs.symlinkSync(from, to); - } -} - -function copyGameFromNodeModules(game, enable) { - enable = 'undefined' === typeof enable ? true : enable; - let gameDir = path.resolve(GAMES_AVAILABLE_DIR, game); - - // Move game from node_modules into games_available directory. - fs.renameSync(path.resolve(INSTALL_DIR_MODULES, game), gameDir); - - // Make sure that the test command works. - let tmpPath = path.join(gameDir, 'node_modules'); - if (!fs.existsSync(tmpPath)) fs.mkdirSync(tmpPath); - tmpPath = path.join(tmpPath, '.bin'); - if (!fs.existsSync(tmpPath)) fs.mkdirSync(tmpPath); - tmpPath = path.join(tmpPath, 'mocha'); - if (!fs.existsSync(tmpPath)) { - makeLink(path.join(INSTALL_DIR_MODULES, '.bin/mocha'), tmpPath); - } - - if (!enable) return; - - // Enable gapath.resolve(GAMES_AVAILABLE_DIR, game). - makeLink(gameDir, path.resolve(GAMES_ENABLED_DIR, game)); -} - -function confirm(msg, callback) { - var rl = readline.createInterface({ - input: process.stdin, - output: process.stdout - }); - - rl.question(msg, function(input) { - rl.close(); - callback(/^y|yes|ok|true$/i.test(input)); - }); -} - -function removeDirRecursiveSync(dir) { - if (dir === '/') { - throw new Error(' removeDirRecursiveSync error: cannot remove "/"'); - } - if (dir.indexOf(INSTALL_DIR_MODULES) === -1) { - err(' removeDirRecursiveSync error: there seems to be ' + - 'an error with the path to remove: '); - console.error(dir); - } - if (fs.existsSync(dir)) { - fs.readdirSync(dir).forEach(function(file, index){ - let curPath = path.join(dir, file); - // Recurse. - if (fs.lstatSync(curPath).isDirectory()) { - removeDirRecursiveSync(curPath); - } - else { // delete file - fs.unlinkSync(curPath); - } - }); - fs.rmdirSync(dir); - } -}; - -function installationFailed() { - - log(); - - err('Installation did not complete successfully.'); - log('----------------------------------------------'); - log(); - - err('If you think this might be a bug, please report it. ' + - 'You can either:'); - err(' - open an issue at: ' + - 'https://github.com/nodeGame/nodegame/issues'); - err(' - send an email to info@nodegame.org'); - log(); -} - - -function printHelp() { - - log(); - log('@ Install a specific version (>=3.5.1)'); - log('@dev Install from git repos, when available'); - log('--branch Checkout this branch on all git repos'); - log('--yes Answer yes to all questions'); - log('--install-dir Set the name of the installation directory;'); - log(' if equals to node_modules, the npm structure'); - log(' stays unchanged'); - log('--no-spinner Does not start the spinner'); - log('--help Print this help'); - log(); -} - -// Kudos: cli-spinner package. - -function Spinner(text) { - var that; - that = this; - - this.spinners = [ - "|/-\\", - "⠂-–—–-", - "◐◓◑◒", - "◴◷◶◵", - "◰◳◲◱", - "▖▘▝▗", - "■□▪▫", - "▌▀▐▄", - "▉▊▋▌▍▎▏▎▍▌▋▊▉", - "▁▃▄▅▆▇█▇▆▅▄▃", - "←↖↑↗→↘↓↙", - "┤┘┴└├┌┬┐", - "◢◣◤◥", - ".oO°Oo.", - ".oO@*", - "🌍🌎🌏", - "◡◡ ⊙⊙ ◠◠", - "☱☲☴", - "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏", - "⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓", - "⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆", - "⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋", - "⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁", - "⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈", - "⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈", - "⢄⢂⢁⡁⡈⡐⡠", - "⢹⢺⢼⣸⣇⡧⡗⡏", - "⣾⣽⣻⢿⡿⣟⣯⣷", - "⠁⠂⠄⡀⢀⠠⠐⠈" - ]; - - this.text = text || ''; - - this.chars = this.spinners[isWin ? 0 : 4].split(''); - - this.delay = 60; - - this.onTick = function(msg) { - this.clearLine(this.stream); - this.stream.write(msg); - }; - - this.stream = process.stdout; - - this.start = function() { - var current = 0; - var self = this; - this.id = setInterval(function() { - var msg = self.text.indexOf('%s') > -1 - ? self.text.replace('%s', self.chars[current]) - : self.chars[current] + ' ' + self.text; - self.onTick(msg); - - current = ++current % self.chars.length; - }, this.delay); - }; - - this.stop = function(clear) { - clearInterval(this.id); - this.id = undefined; - if (clear && this.enabled) this.clearLine(this.stream); - }; - - this.clearLine = function(stream) { - readline.clearLine(stream, 0); - readline.cursorTo(stream, 0); - }; -}; - -function inArray(needle, haystack) { - var func, i, len; - len = haystack.length; - for (i = 0; i < len; i++) { - if (needle === haystack[i]) { - return needle; - } - } - return false; -} From 5715aa7d22cc28bbc56df6a55742f3859456c132 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 26 Oct 2017 21:18:35 -0400 Subject: [PATCH 004/155] mods --- .gitignore | 15 +++++++++++++-- bin/nodegame-installer.js | 4 ++-- games_available/README.md | 3 +++ 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 games_available/README.md diff --git a/.gitignore b/.gitignore index c313df80..56af3c76 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,18 @@ descil.conf.js imgscore +log/*.log + + +games_available/dictator +games_available/meritocracy +games_available/ultimatum +games_available/stopgo +games_available/artex +games_available/MiniSvo +games_available/car-sharing +games_available/DCL + games/dictator games/meritocracy games/ultimatum @@ -34,10 +46,9 @@ games/artex games/MiniSvo games/car-sharing games/DCL + games_new/ -games_available/ start/ -log/*.log bin/nodegame diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index d092d914..ae5f86b7 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -45,10 +45,10 @@ var yes; var branch; var warnings; -const MAIN_MODULE = 'nodegame-test'; +const MAIN_MODULE = 'nodegame'; // Installer default version. -const INSTALLER_VERSION = "4.0.8"; +const INSTALLER_VERSION = "4.0.0"; // The actual version being installed, user can change it. var version = INSTALLER_VERSION; diff --git a/games_available/README.md b/games_available/README.md new file mode 100644 index 00000000..8aab11c2 --- /dev/null +++ b/games_available/README.md @@ -0,0 +1,3 @@ +## Games Available Directory + +Games need to be symlinked from games/ folder to be enabled. From f571d49af159e3cf40ea0a2bb72760665618834b Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 26 Oct 2017 21:19:43 -0400 Subject: [PATCH 005/155] 4.0.1 --- bin/nodegame-installer.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index ae5f86b7..9af07ba1 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -48,7 +48,7 @@ var warnings; const MAIN_MODULE = 'nodegame'; // Installer default version. -const INSTALLER_VERSION = "4.0.0"; +const INSTALLER_VERSION = "4.0.1"; // The actual version being installed, user can change it. var version = INSTALLER_VERSION; diff --git a/package.json b/package.json index 5840e9ae..bd9a0057 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.0.0" + , "version": "4.0.1" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From 9e7700ace59054fee2c1f3f99a81458a3057fd8a Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 30 Oct 2017 12:26:48 -0400 Subject: [PATCH 006/155] mods --- test/launcher-autoplay.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/launcher-autoplay.js b/test/launcher-autoplay.js index 805c17aa..b1d67799 100644 --- a/test/launcher-autoplay.js +++ b/test/launcher-autoplay.js @@ -16,10 +16,6 @@ if (process.argv.length < 3) { var gameName = process.argv[2]; var gameFolder = process.argv[3] || gameName; -console.log(process.argv); -console.log('---------------------------'); - - // Load the Node.js path object. var path = require('path'); From 8f295ec3b46d6fde2faeb9f878c1277a1c74b2ad Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 30 Oct 2017 12:29:19 -0400 Subject: [PATCH 007/155] travis --- .travis.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0eacd4bb..98091f09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,17 +7,16 @@ node_js: before_install: # Get installer script. - - wget https://github.com/nodeGame/nodegame-test/raw/master/nodegame-installer.js + - wget https://raw.githubusercontent.com/nodeGame/nodegame/master/bin/nodegame-installer.js - chmod a+x nodegame-installer.js install: - - node nodegame-installer.js @dev --install-dir node_modules --no-spinner --branch v4 - - npm install -g should - - npm install -g mocha + - npm install --only=dev + - node nodegame-installer.js @dev --install-dir node_modules --no-spinner --branch v4 --yes script: # Add extra tests here. # Test Ultimatum game. - - cd node_modules/nodegame-test/games/ultimatum-game + - cd node_modules/nodegame/games/ultimatum-game - ./bin/run-standalone-test-v4.sh From 47e10b3cd55d3fd8a65d0dc383e66db41fd48d5e Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 30 Oct 2017 14:17:47 -0400 Subject: [PATCH 008/155] travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98091f09..69a449e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,8 @@ before_install: - chmod a+x nodegame-installer.js install: - - npm install --only=dev + ## Remove package json, otherwise npm does not install nodegame as dependency. + - rm package.json - node nodegame-installer.js @dev --install-dir node_modules --no-spinner --branch v4 --yes script: From e0a89662e9e0ea673e25f028809ba054d7bd27d9 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 30 Oct 2017 14:37:33 -0400 Subject: [PATCH 009/155] travis --- .travis.yml | 1 + bin/nodegame-installer.js | 46 +++++++++++++++++++++++---------------- package.json | 6 ++++- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69a449e5..4b077900 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ before_install: install: ## Remove package json, otherwise npm does not install nodegame as dependency. + - npm install --only=dev - rm package.json - node nodegame-installer.js @dev --install-dir node_modules --no-spinner --branch v4 --yes diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 9af07ba1..f373b0a6 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -56,29 +56,18 @@ var version = INSTALLER_VERSION; var requestedVersion = requestedVersion = '@' + version; for (let i = 0; i < process.argv.length; i++) { - if (process.argv[i].charAt(0) === '@') { + let option = process.argv[i]; + + if (option.charAt(0) === '@') { requestedVersion = process.argv[i].substr(1); if (requestedVersion === 'dev') { isDev = true; version = INSTALLER_VERSION; requestedVersion = '@' + version; - if (process.argv.indexOf('--ssh') !== -1) doSSH = true; - branch = process.argv.indexOf('--branch'); - if (branch !== -1) { - branch = process.argv[branch+1]; - if (!branch) { - err('--branch option found, ' + - 'but no value provided.'); - log(); - return; - } - } - else { - branch = undefined; - } + } - else { + else { version = requestedVersion; if (version.length < 1 || version.length > 5) { err('Error: invalid version number: ', version); @@ -87,12 +76,31 @@ for (let i = 0; i < process.argv.length; i++) { } requestedVersion = '@' + requestedVersion; } - break; } + else if (option === '--no-spinner') { + noSpinner = true; + } + else if (option === '--yes') { + yes = true; + } + else if (option === '--branch') { + branch = process.argv[i+1]; + if (!branch) { + err('--branch option found, but no value provided.'); + log(); + return; + } + + } + else if (option === '--ssh') { + doSSH = true; + } } -if (process.argv.indexOf('--no-spinner') !== -1) noSpinner = true; -if (process.argv.indexOf('--yes') !== -1) yes = true; +if ((doSSH || branch) && !isDev) { + err('Error: --branch and --doSSH options are available only with @dev'); + return; +} // nodeGame version. const VERSION = isDev ? "v" + version + '-dev' : "v" + version; diff --git a/package.json b/package.json index bd9a0057..854f41a2 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,11 @@ "JSUS": "*", "NDDB": "*", "ultimatum-game": "*" - } + } + , "devDependencies": { + "mocha": ">= 0.3.0", + "should": "4.4.1" + } , "license": "MIT" , "scripts": { "start": "node launcher.js" From c003c997003a847e01b5574fae2b4c56728de01f Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 26 Dec 2017 04:08:55 -0500 Subject: [PATCH 010/155] installer and gitignore --- .gitignore | 5 ++++ bin/nodegame-installer.js | 59 +++++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 56af3c76..1e73e3f0 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,9 @@ games_available/artex games_available/MiniSvo games_available/car-sharing games_available/DCL +games_available/rules +games_available/prisonersgame + games/dictator games/meritocracy @@ -46,6 +49,8 @@ games/artex games/MiniSvo games/car-sharing games/DCL +games/rules +games/prisonersgame games_new/ start/ diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index f373b0a6..deaff539 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -27,7 +27,10 @@ const log = txt => { else console.log(' ' + txt); }; const err = txt => { - console.error(' ' + txt); + console.error(' Error: ' + txt); +}; +const warn = txt => { + console.error(' Warning: ' + txt); }; if (process.argv.indexOf('--help') !== -1) { @@ -70,7 +73,7 @@ for (let i = 0; i < process.argv.length; i++) { else { version = requestedVersion; if (version.length < 1 || version.length > 5) { - err('Error: invalid version number: ', version); + err('invalid version number: ', version); log(); return; } @@ -98,7 +101,7 @@ for (let i = 0; i < process.argv.length; i++) { } if ((doSSH || branch) && !isDev) { - err('Error: --branch and --doSSH options are available only with @dev'); + err('--branch and --doSSH options are available only with @dev'); return; } @@ -160,8 +163,8 @@ printInstallInfo(); // Check node version is. var nodeVersion = process.versions.node.split('.'); if (parseInt(nodeVersion[0], 10) < 4) { - err('Error: node version >= 4.x is required.'); - err('Please upgrade your Node.Js installation, ' + + err('node version >= 4.x is required.\n' + + 'Please upgrade your Node.Js installation, ' + 'visit: http://nodejs.org'); log(); return; @@ -169,7 +172,7 @@ if (parseInt(nodeVersion[0], 10) < 4) { // Check if install dir exists (abort). if (fs.existsSync(INSTALL_DIR)) { - err('Error: installation directory already existing.'); + err('installation directory already existing.'); log(); return; } @@ -177,7 +180,7 @@ if (fs.existsSync(INSTALL_DIR)) { // Check if node_modules exists (prompt continue?) if (fs.existsSync(NODE_MODULES_DIR)) { nodeModulesExisting = true; - err('Warning: node_modules directory already existing.'); + warn('node_modules directory already existing.'); if (!yes) { confirm(' Continue? [y/n] ', function(ok) { if (ok) { @@ -186,7 +189,7 @@ if (fs.existsSync(NODE_MODULES_DIR)) { doInstall(); } else { - err('Installation aborted.'); + log('Installation aborted.'); log(); } }) @@ -199,8 +202,8 @@ if (fs.existsSync(NODE_MODULES_DIR)) { } // Install. -doInstall(); - +if (isDev) checkGitExists(doInstall); +else doInstall(); // Helper functions. @@ -268,7 +271,7 @@ function doInstall() { // logList(stdout.trim()); // } // }); - err('Oops! The following error/s occurred: '); + log('Oops! The following error/s occurred: '); log(); console.error(e); installationFailed(); @@ -278,8 +281,22 @@ function doInstall() { }); } -// Helper stuff. -//////////////// +function checkGitExists(cb) { + let child = execFile( + 'git', + [ '--version' ], + { cwd: ROOT_DIR }, + (error, stdout, stderr) => { + if (error) { + err('git not found, cannot install @dev version.'); + log('Install git from: https://git-scm.com/ and retry.'); + installationFailed(); + } + else { + if (cb) cb(); + } + }); +} function printNodeGameInfo() { log(); @@ -365,7 +382,6 @@ function printFinalInfo() { function someMagic() { if (!doNotMoveInstall) { - debugger // Move nodegame folder outside node_modules. fs.renameSync(path.resolve(NODE_MODULES_DIR, MAIN_MODULE), INSTALL_DIR); @@ -550,7 +566,7 @@ function removeDirRecursiveSync(dir) { throw new Error(' removeDirRecursiveSync error: cannot remove "/"'); } if (dir.indexOf(INSTALL_DIR_MODULES) === -1) { - err(' removeDirRecursiveSync error: there seems to be ' + + err('removeDirRecursiveSync error: there seems to be ' + 'an error with the path to remove: '); console.error(dir); } @@ -573,15 +589,15 @@ function installationFailed() { log(); - err('Installation did not complete successfully.'); + log('Installation did not complete successfully.'); log('----------------------------------------------'); log(); - err('If you think this might be a bug, please report it. ' + + log('If you think this might be a bug, please report it. ' + 'You can either:'); - err(' - open an issue at: ' + + log(' - open an issue at: ' + 'https://github.com/nodeGame/nodegame/issues'); - err(' - send an email to info@nodegame.org'); + log(' - send an email to info@nodegame.org'); log(); } @@ -590,8 +606,9 @@ function printHelp() { log(); log('@ Install a specific version (>=3.5.1)'); - log('@dev Install from git repos, when available'); - log('--branch Checkout this branch on all git repos'); + log('@dev Install latest nodeGame from git repos'); + log(' --branch Checkout this branch on all git repos'); + log(' --ssh Use ssh to get all git repos'); log('--yes Answer yes to all questions'); log('--install-dir Set the name of the installation directory;'); log(' if equals to node_modules, the npm structure'); From daed84bee67692f650d73f3a8d62c6d6e648f5b0 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sat, 28 Apr 2018 10:47:03 -0400 Subject: [PATCH 011/155] gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1e73e3f0..b54685ab 100644 --- a/.gitignore +++ b/.gitignore @@ -39,8 +39,9 @@ games_available/car-sharing games_available/DCL games_available/rules games_available/prisonersgame +games_available/testergame - +games/testergame games/dictator games/meritocracy games/ultimatum From 7d0dadb2ac69dcdad5d2353d795aa9dc9a996d94 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 7 May 2018 22:23:19 -0400 Subject: [PATCH 012/155] updated README --- README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0dd5f3e8..8337161f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# nodeGame +# nodeGame: Online Real-Time Synchronous Experiments -nodeGame is a free, open source, real-time javascript framework for -online, multiplayer games in the browser. +Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games +and experiments. --- @@ -18,8 +18,10 @@ it specially designed to conduct _social experiments_. [NDDB](http://nodegame.github.com/NDDB/docs/nddb.js.html) Javascript database - Server can run multiple games at the same time - - Customizable waiting rooms for online games + - Powerful and customizible waiting rooms + - Monitor interface - Works on mobile devices and tablets + - Bots and Phantoms - Installation is required only for the server, clients just need their browser windows - Integrates smoothly with other libraries (e.g. jQuery, D3.js, etc.) and web services, such as Amazon Mechanical Turk @@ -31,16 +33,13 @@ of game theory. It is called the [Ultimatum](http://en.wikipedia.org/wiki/Ultimatum_game) game. To play it follows the steps: + 1. Download the latest version of [node.js](http://nodejs.org) for your platform 2. Download the latest version of [git](http://www.git-scm.com) for your platform - 3. Download the development version of nodeGame using the install - script for - [Mac/Linux](https://raw.githubusercontent.com/nodeGame/nodegame/master/bin/install.latest.sh) - or - [Windows](https://raw.githubusercontent.com/nodeGame/nodegame/master/bin/install.latest.cmd) - 4. Open a terminal and browse to the `nodegame/` folder + 3. Download [installer](http://nodegame.org/nodegame-installer.js), and install nodegame: `node nodegame-installer` + 4. Enter installation directory. 5. Start the server with the command: `node launcher.js` 6. Open two or more browser tabs pointing to `localhost:8080/ultimatum` From c7fc636c4ade11e27772ef6b5c9e5f6b4436c329 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 7 May 2018 22:24:51 -0400 Subject: [PATCH 013/155] 4.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 854f41a2..fcd84c11 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.0.1" + , "version": "4.0.2" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From de926c32ee9a5015340afe3f63f0834b6e321305 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 5 Jul 2018 06:41:12 -0400 Subject: [PATCH 014/155] 4.0.3 --- CHANGELOG | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 8c5874bd..66267cc1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,11 @@ # nodeGame Changelog +# 4.0.3 +- Improved monitor error logging. + +# 4.0.2 +- Big release, check CHANGELOG on website. + # 3.5 - Printing version on startup (launcher). diff --git a/package.json b/package.json index fcd84c11..87599118 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.0.2" + , "version": "4.0.3" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From 5237c735f4ec9a7c48e4345dbaa4550af428487a Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 5 Jul 2018 06:43:15 -0400 Subject: [PATCH 015/155] 4.0.4 --- CHANGELOG | 3 ++- bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 66267cc1..66541f5b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,8 @@ # nodeGame Changelog -# 4.0.3 +# 4.0.4 - Improved monitor error logging. +- Updated installer version. # 4.0.2 - Big release, check CHANGELOG on website. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index deaff539..ae2d71c9 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -51,7 +51,7 @@ var warnings; const MAIN_MODULE = 'nodegame'; // Installer default version. -const INSTALLER_VERSION = "4.0.1"; +const INSTALLER_VERSION = "4.0.4"; // The actual version being installed, user can change it. var version = INSTALLER_VERSION; diff --git a/package.json b/package.json index 87599118..69867845 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.0.3" + , "version": "4.0.4" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From f5e212a773969fc6c947e9e164789cfa9661908b Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 16 Aug 2018 09:58:54 -0400 Subject: [PATCH 016/155] Minor Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8337161f..4bedfaa5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ it specially designed to conduct _social experiments_. - Powerful and customizible waiting rooms - Monitor interface - Works on mobile devices and tablets - - Bots and Phantoms + - Bots (for playing) and Phantoms (for testing) - Installation is required only for the server, clients just need their browser windows - Integrates smoothly with other libraries (e.g. jQuery, D3.js, etc.) and web services, such as Amazon Mechanical Turk From 095f84d75d5fe19b2f50bb28353e750b4782a84d Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 16 Aug 2018 10:03:16 -0400 Subject: [PATCH 017/155] updated nodegame-installer to install dev of nodegame-mturk --- bin/nodegame-installer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index ae2d71c9..5583cd90 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -1,7 +1,7 @@ #!/usr/local/bin/node /** * # nodeGame Installer - * Copyright(c) 2017 Stefano Balietti + * Copyright(c) 2018 Stefano Balietti * MIT Licensed * * @@ -140,6 +140,7 @@ const NODEGAME_MODULES = [ 'nodegame-window', 'nodegame-widgets', 'nodegame-monitor', 'nodegame-game-template', 'nodegame-requirements', 'nodegame-generator', + 'nodegame-mturk', // No need to replace these now. // 'nodegame-db', 'nodegame-mondodb', 'JSUS', 'NDDB', From 444dd6fe3e597bfd92136b0e795882c3fb05f322 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 16 Aug 2018 13:56:19 -0400 Subject: [PATCH 018/155] minor launcher --- .gitignore | 2 ++ launcher.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b54685ab..43f3eba5 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ imgscore log/*.log +games_available/ultimatum-game games_available/dictator games_available/meritocracy games_available/ultimatum @@ -41,6 +42,7 @@ games_available/rules games_available/prisonersgame games_available/testergame +games/ultimatum-game games/testergame games/dictator games/meritocracy diff --git a/launcher.js b/launcher.js index 8d947ac1..6c86e15e 100644 --- a/launcher.js +++ b/launcher.js @@ -439,7 +439,9 @@ function startServer() { // Print warnings, if any. printIgnoredOptions(); - console.log('nodeGame v.' + require('./package.json').version); + console.log('nodeGame v.' + version); + // Add nodeGame version (might be higher than server version) to options. + options.nodeGameVersion = version; // Start server, options parameter is optional. sn = new ServerNode(options); From 4d0aafee42c68b5396d442cb5240e8c39cf2ec83 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 7 Sep 2018 08:20:00 -0400 Subject: [PATCH 019/155] 4.1.0 --- bin/nodegame-installer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 5583cd90..6812c2f5 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -51,7 +51,7 @@ var warnings; const MAIN_MODULE = 'nodegame'; // Installer default version. -const INSTALLER_VERSION = "4.0.4"; +const INSTALLER_VERSION = "4.1.0"; // The actual version being installed, user can change it. var version = INSTALLER_VERSION; @@ -355,10 +355,10 @@ function printFinalInfo() { log(); log('Open a browser tab at the address:'); - log(' http://localhost:8080/ultimatum'); + log(' http://localhost:8080/'); log(); - log('Open another tab with an autoplay player:'); + log('Start a bot from the waiting room interface, or open another tab:'); log(' http://localhost:8080/ultimatum?clientType=autoplay'); log(); @@ -531,7 +531,7 @@ function copyGameFromNodeModules(game, enable) { enable = 'undefined' === typeof enable ? true : enable; let gameDir = path.resolve(GAMES_AVAILABLE_DIR, game); - // Move game from node_modules into games_available directory. + // Move game from node_modules into games_available directory. fs.renameSync(path.resolve(INSTALL_DIR_MODULES, game), gameDir); // Make sure that the test command works. @@ -546,7 +546,7 @@ function copyGameFromNodeModules(game, enable) { if (!enable) return; - // Enable gapath.resolve(GAMES_AVAILABLE_DIR, game). + // Enable it. makeLink(gameDir, path.resolve(GAMES_ENABLED_DIR, game)); } From eb75bb6cec7b9c3f61aac0a556b29089a4575835 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 7 Sep 2018 08:26:44 -0400 Subject: [PATCH 020/155] cleanup in bin --- bin/{ => legacy}/build.sh | 0 bin/{ => legacy}/install-nodegame-for-module-node5.beta.sh | 0 bin/{ => legacy}/install-nodegame-for-module.sh | 0 bin/{ => legacy}/install.dev.sh | 0 bin/{ => legacy}/install.latest.cmd | 0 bin/{ => legacy}/install.latest.sh | 0 bin/{ => legacy}/install.stable.cmd | 0 bin/{ => legacy}/install.stable.sh | 0 bin/{ => legacy}/pull-all.sh | 0 bin/{nodegame-cli-new.js => nodegame-cli-experimental.js} | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename bin/{ => legacy}/build.sh (100%) rename bin/{ => legacy}/install-nodegame-for-module-node5.beta.sh (100%) rename bin/{ => legacy}/install-nodegame-for-module.sh (100%) rename bin/{ => legacy}/install.dev.sh (100%) rename bin/{ => legacy}/install.latest.cmd (100%) rename bin/{ => legacy}/install.latest.sh (100%) rename bin/{ => legacy}/install.stable.cmd (100%) rename bin/{ => legacy}/install.stable.sh (100%) rename bin/{ => legacy}/pull-all.sh (100%) rename bin/{nodegame-cli-new.js => nodegame-cli-experimental.js} (100%) diff --git a/bin/build.sh b/bin/legacy/build.sh similarity index 100% rename from bin/build.sh rename to bin/legacy/build.sh diff --git a/bin/install-nodegame-for-module-node5.beta.sh b/bin/legacy/install-nodegame-for-module-node5.beta.sh similarity index 100% rename from bin/install-nodegame-for-module-node5.beta.sh rename to bin/legacy/install-nodegame-for-module-node5.beta.sh diff --git a/bin/install-nodegame-for-module.sh b/bin/legacy/install-nodegame-for-module.sh similarity index 100% rename from bin/install-nodegame-for-module.sh rename to bin/legacy/install-nodegame-for-module.sh diff --git a/bin/install.dev.sh b/bin/legacy/install.dev.sh similarity index 100% rename from bin/install.dev.sh rename to bin/legacy/install.dev.sh diff --git a/bin/install.latest.cmd b/bin/legacy/install.latest.cmd similarity index 100% rename from bin/install.latest.cmd rename to bin/legacy/install.latest.cmd diff --git a/bin/install.latest.sh b/bin/legacy/install.latest.sh similarity index 100% rename from bin/install.latest.sh rename to bin/legacy/install.latest.sh diff --git a/bin/install.stable.cmd b/bin/legacy/install.stable.cmd similarity index 100% rename from bin/install.stable.cmd rename to bin/legacy/install.stable.cmd diff --git a/bin/install.stable.sh b/bin/legacy/install.stable.sh similarity index 100% rename from bin/install.stable.sh rename to bin/legacy/install.stable.sh diff --git a/bin/pull-all.sh b/bin/legacy/pull-all.sh similarity index 100% rename from bin/pull-all.sh rename to bin/legacy/pull-all.sh diff --git a/bin/nodegame-cli-new.js b/bin/nodegame-cli-experimental.js similarity index 100% rename from bin/nodegame-cli-new.js rename to bin/nodegame-cli-experimental.js From 1f7e62cfe9c158d7d35a34d3f5ec6774560a76e9 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 7 Sep 2018 08:28:14 -0400 Subject: [PATCH 021/155] 4.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 69867845..79844f7f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.0.4" + , "version": "4.1.0" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From e3dfe7448b2a935116d333502e8f8c38a73637b8 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 7 Sep 2018 09:11:57 -0400 Subject: [PATCH 022/155] 4.1.1 --- bin/nodegame-installer.js | 49 ++++++++++++++++++++++----------------- package.json | 2 +- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 6812c2f5..8146f420 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -51,7 +51,7 @@ var warnings; const MAIN_MODULE = 'nodegame'; // Installer default version. -const INSTALLER_VERSION = "4.1.0"; +const INSTALLER_VERSION = "4.1.1"; // The actual version being installed, user can change it. var version = INSTALLER_VERSION; @@ -243,7 +243,7 @@ function doInstall() { else { if (verbose) logList(stdout.trim()); log(); - log('Done! Now some finishing magics...'); + log('Done! Now some final magic...'); try { someMagic(); } @@ -396,15 +396,38 @@ function someMagic() { } } - // nodeGame generator: make link and store conf. + if (isDev) { + getAllGitModules(function() { + // Move games from node_modules. + copyGameFromNodeModules('ultimatum-game'); + + // Generator. + fixGenerator(); + + // Print final Information. + printFinalInfo(); + }); + } + else { + // Move games from node_modules. + copyGameFromNodeModules('ultimatum-game'); + + // Generator. + fixGenerator(); + + // Print final Information. + printFinalInfo(); + } +} +function fixGenerator() { + // nodeGame generator: make link and store conf. makeLink(path.resolve(INSTALL_DIR_MODULES, 'nodegame-generator', 'bin', 'nodegame'), path.resolve(INSTALL_DIR, 'bin', 'nodegame'), 'file'); - fs.writeFileSync(path.resolve(INSTALL_DIR_MODULES, 'nodegame-generator', 'conf', @@ -412,24 +435,8 @@ function someMagic() { JSON.stringify({ author: "", email: "", - gamesFolder: GAMES_AVAILABLE_DIR + ngDir: INSTALL_DIR }, 4)); - - - if (isDev) { - getAllGitModules(function() { - // Move games from node_modules. - copyGameFromNodeModules('ultimatum-game'); - // Print final Information. - printFinalInfo(); - }); - } - else { - // Move games from node_modules. - copyGameFromNodeModules('ultimatum-game'); - // Print final Information. - printFinalInfo(); - } } function getAllGitModules(cb) { diff --git a/package.json b/package.json index 79844f7f..b895c811 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.1.0" + , "version": "4.1.1" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From 022053fb8ae45a036811d3c24b5049c200370495 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 7 Sep 2018 10:00:36 -0400 Subject: [PATCH 023/155] 4.1.2 --- bin/nodegame-installer.js | 13 +++++++++++-- package.json | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 8146f420..3f73f5c1 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -51,7 +51,7 @@ var warnings; const MAIN_MODULE = 'nodegame'; // Installer default version. -const INSTALLER_VERSION = "4.1.1"; +const INSTALLER_VERSION = "4.1.2"; // The actual version being installed, user can change it. var version = INSTALLER_VERSION; @@ -381,10 +381,19 @@ function printFinalInfo() { function someMagic() { + let mainNgDir = path.resolve(NODE_MODULES_DIR, MAIN_MODULE); + // Check if log and private directories have been created. + if (!fs.existsSync(path.resolve(mainNgDir, 'log'))) { + fs.mkdirSync(path.resolve(mainNgDir, 'log')); + } + if (!fs.existsSync(path.resolve(mainNgDir, 'private'))) { + fs.mkdirSync(path.resolve(mainNgDir, 'private')); + } + if (!doNotMoveInstall) { // Move nodegame folder outside node_modules. - fs.renameSync(path.resolve(NODE_MODULES_DIR, MAIN_MODULE), INSTALL_DIR); + fs.renameSync(mainNgDir, INSTALL_DIR); // Old npms put already all modules under nodegame. if (!fs.existsSync(INSTALL_DIR_MODULES)) { diff --git a/package.json b/package.json index b895c811..623cf0a0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.1.1" + , "version": "4.1.2" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From 7b86182cd7251537e45a80adc307897f52314ac7 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 7 Sep 2018 15:12:36 -0400 Subject: [PATCH 024/155] copying pre-commit hook into .git @dev --- bin/nodegame-installer.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 3f73f5c1..56c88d66 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -38,6 +38,8 @@ if (process.argv.indexOf('--help') !== -1) { return; } +const versions = [ '3.5.1', '4.0.0', '4.0.4', '4.1.3' ]; + var verbose = false; var nodeModulesExisting = false; var isDev = false; @@ -449,6 +451,7 @@ function fixGenerator() { } function getAllGitModules(cb) { + let gitPrecommitHook = path.resolve(INSTALL_DIR, 'git-hooks', 'pre-commit'); let counter = NODEGAME_MODULES.length; if (verbose) log('Converting modules into git repos.'); for (let i = 0; i < NODEGAME_MODULES.length; i++) { @@ -486,6 +489,10 @@ function getAllGitModules(cb) { if (nodeModulesCopy) { fs.renameSync(nodeModulesCopy, nodeModulesPath); } + // Copy pre-commit hook. + fs.copyFileSync(gitPrecommitHook, + path.resolve(modulePath, '.git', 'hooks', + 'pre-commit')); counter--; if (counter == 0 && cb) cb(); }); From 32ac6a7d34c2c559b7b31b7fcbfa391a262ff74a Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 7 Sep 2018 15:26:56 -0400 Subject: [PATCH 025/155] improved help --- bin/nodegame-installer.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 56c88d66..950996c6 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -33,13 +33,18 @@ const warn = txt => { console.error(' Warning: ' + txt); }; +const MAIN_MODULE = 'nodegame'; + +// All stable versions. +const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.3' ]; +// Installer default version. +const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; + if (process.argv.indexOf('--help') !== -1) { printHelp(); return; } -const versions = [ '3.5.1', '4.0.0', '4.0.4', '4.1.3' ]; - var verbose = false; var nodeModulesExisting = false; var isDev = false; @@ -50,11 +55,6 @@ var yes; var branch; var warnings; -const MAIN_MODULE = 'nodegame'; - -// Installer default version. -const INSTALLER_VERSION = "4.1.2"; - // The actual version being installed, user can change it. var version = INSTALLER_VERSION; // User requested version; @@ -627,9 +627,10 @@ function installationFailed() { function printHelp() { - log(); log('@ Install a specific version (>=3.5.1)'); + log(' Stable versions: ' + + STABLE_VERSIONS.join(' ')); log('@dev Install latest nodeGame from git repos'); log(' --branch Checkout this branch on all git repos'); log(' --ssh Use ssh to get all git repos'); From 0f35bfc9d37d41e22841fb6d340462a10f9139c1 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 7 Sep 2018 16:42:02 -0400 Subject: [PATCH 026/155] list-versions --- bin/nodegame-installer.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 950996c6..e53332b7 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -40,10 +40,17 @@ const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.3' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; -if (process.argv.indexOf('--help') !== -1) { +if (process.argv[2] === '--help') { printHelp(); return; } +else if (process.argv[2] === '--list-versions') { + console.log(' List of stable versions:'); + for (let i=0 ; i < STABLE_VERSIONS.length ; i++) { + console.log(' - ' + STABLE_VERSIONS[i]); + } + return; +} var verbose = false; var nodeModulesExisting = false; @@ -629,8 +636,6 @@ function installationFailed() { function printHelp() { log(); log('@ Install a specific version (>=3.5.1)'); - log(' Stable versions: ' + - STABLE_VERSIONS.join(' ')); log('@dev Install latest nodeGame from git repos'); log(' --branch Checkout this branch on all git repos'); log(' --ssh Use ssh to get all git repos'); @@ -639,6 +644,7 @@ function printHelp() { log(' if equals to node_modules, the npm structure'); log(' stays unchanged'); log('--no-spinner Does not start the spinner'); + log('--list-versions Lists stable versions'); log('--help Print this help'); log(); } From d69f01cb8707e3861b757e70d4f7702b9808f109 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 7 Sep 2018 16:44:53 -0400 Subject: [PATCH 027/155] 4.1.3 --- CHANGELOG | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 66541f5b..787ecc2c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,14 @@ # nodeGame Changelog +# 4.1.3 +- Improved installer +- Msg anti-spoofing support +- Fixed bug on Chrome with flickering scrollbar +- More options on Monitor, including display of last error +- Improved nodegame-mturk support +- Fixed tests +- Smaller fixes + # 4.0.4 - Improved monitor error logging. - Updated installer version. diff --git a/package.json b/package.json index 623cf0a0..dd2b4a94 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.1.2" + , "version": "4.1.3" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From 402fc736517fbaec3da8f87e34afff6f619a4566 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 13 Sep 2018 01:16:04 -0400 Subject: [PATCH 028/155] minor --- launcher.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/launcher.js b/launcher.js index 6c86e15e..a593fe8c 100644 --- a/launcher.js +++ b/launcher.js @@ -1,6 +1,6 @@ /** * # Launcher file for nodeGame Server - * Copyright(c) 2017 Stefano Balietti + * Copyright(c) 2011-2018 Stefano Balietti * MIT Licensed * * Load configuration options and start the server @@ -409,8 +409,8 @@ if (program.build) { all: true, output: out }); - J.copyFile(info.modulesDir.client + 'build/' + out, - info.serverDir.build + out); + J.copyFile(path.resolve(info.modulesDir.client, 'build', out), + path.resolve(info.serverDir.build, 'out'); console.log(info.serverDir.build + out + ' rebuilt.'); console.log(''); } @@ -482,7 +482,7 @@ function startServer() { console.log(); if (runTests) { - command = gameDir + 'node_modules/.bin/mocha'; + command = path.resolve(gameDir, 'node_modules', '.bin', 'mocha'); if (fs.existsSync(command)) { // Write and backup settings file. @@ -580,14 +580,14 @@ function printErr(err) { function writeSettingsFile(gameDir) { var settings, settingsFile, bak; settings = 'module.exports = { numPlayers: ' + nClients + ' };'; - settingsFile = gameDir + 'test/settings.js'; + settingsFile = path.resolve(gameDir, 'test', 'settings.js'); // Make a backup of existing settings file, if found. if (fs.existsSync(settingsFile)) { bak = fs.readFileSync(settingsFile).toString(); fs.writeFileSync(settingsFile + '.bak', bak); } // Write updated settings file. - fs.writeFileSync(gameDir + 'test/settings.js', settings); + fs.writeFileSync(path.resolve(gameDir, 'test', 'settings.js'), settings); } // Exports the ServerNode instance. From 29353bc3043da41a036374d3a41ca0792187ad0e Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 13 Sep 2018 02:10:29 -0400 Subject: [PATCH 029/155] readme update --- README.md | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4bedfaa5..e6c38a24 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,10 @@ -# nodeGame: Online Real-Time Synchronous Experiments +# nodeGame Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments. --- -nodeGame is a general framework to play any kind of game online, but -it specially designed to conduct _social experiments_. - ## The Good parts - Open source and open standard (HTML5) @@ -41,14 +38,12 @@ it follows the steps: 3. Download [installer](http://nodegame.org/nodegame-installer.js), and install nodegame: `node nodegame-installer` 4. Enter installation directory. 5. Start the server with the command: `node launcher.js` - 6. Open two or more browser tabs pointing to - `localhost:8080/ultimatum` - 7. Open a browser tab pointing to + 6. Open one tab pointing to `localhost:8080` + 7. Select Ultimatum game + 8. Open more tabs, or start a bot through the waiting room interface + 7. Check the monitor interface at `localhost:8080/ultimatum/monitor` -To keep your development version code base up to date you can use the -script in `bin/pull-all.sh` (Mac/Linux only). - ## Documentation Complete documentation is available in the nodeGame From 9fb6c18a41c3e44eca43a2577063a2153fde187b Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 13 Sep 2018 02:10:47 -0400 Subject: [PATCH 030/155] fix copyFileSync on Node < 8 --- bin/nodegame-installer.js | 82 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index e53332b7..c4d19d50 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -1,10 +1,9 @@ #!/usr/local/bin/node /** * # nodeGame Installer - * Copyright(c) 2018 Stefano Balietti + * Copyright(c) 2011-2018 Stefano Balietti * MIT Licensed * - * * http://www.nodegame.org */ @@ -497,9 +496,9 @@ function getAllGitModules(cb) { fs.renameSync(nodeModulesCopy, nodeModulesPath); } // Copy pre-commit hook. - fs.copyFileSync(gitPrecommitHook, - path.resolve(modulePath, '.git', 'hooks', - 'pre-commit')); + copyFileSync(gitPrecommitHook, + path.resolve(modulePath, '.git', 'hooks', + 'pre-commit')); counter--; if (counter == 0 && cb) cb(); }); @@ -735,3 +734,76 @@ function inArray(needle, haystack) { } return false; } + + + +// Kudos. Adapted from: +// https://github.com/coderaiser/ +// fs-copy-file-sync/blob/master/lib/fs-copy-file-sync.js +function _copyFileSync(src, dest, flag) { + const SIZE = 65536; + + const COPYFILE_EXCL = 1; + const COPYFILE_FICLONE = 2; + const COPYFILE_FICLONE_FORCE = 4; + + const constants = { + COPYFILE_EXCL, + COPYFILE_FICLONE, + COPYFILE_FICLONE_FORCE, + }; + + const isNumber = (a) => typeof a === 'number'; + const or = (a, b) => a | b; + const getValue = (obj) => (key) => obj[key]; + + const getMaxMask = (obj) => Object + .keys(obj) + .map(getValue(obj)) + .reduce(or); + + const MAX_MASK = getMaxMask(constants); + const isExcl = (flags) => flags & COPYFILE_EXCL; + + + const writeFlag = isExcl(flag) ? 'wx' : 'w'; + + const { + size, + mode, + } = fs.statSync(src); + + const fdSrc = fs.openSync(src, 'r'); + const fdDest = fs.openSync(dest, writeFlag, mode); + + const length = size < SIZE ? size : SIZE; + + let pos = 0; + const peaceSize = size < SIZE ? 0 : size % SIZE; + const offset = 0; + + let buffer = Buffer.allocUnsafe(length); + for (let i = 0; length + pos + peaceSize <= size; i++, pos = length * i) { + fs.readSync(fdSrc, buffer, offset, length, pos); + fs.writeSync(fdDest, buffer, offset, length, pos); + } + + if (peaceSize) { + const length = peaceSize; + buffer = Buffer.allocUnsafe(length); + fs.readSync(fdSrc, buffer, offset, length, pos); + fs.writeSync(fdDest, buffer, offset, length, pos); + } + + fs.closeSync(fdSrc); + fs.closeSync(fdDest); +} + +function copyFileSync(from, to) { + if ('function' === typeof fs.copyFileSync) { + fs.copyFileSync(from, to); + } + else { + _copyFileSync(from, to); + } +} From 96c80415704b6404ad98efcde95dc12c463027bb Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 13 Sep 2018 02:29:40 -0400 Subject: [PATCH 031/155] travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4b077900..9f0e0501 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: - 6 - 7 - 8 + - 10 before_install: # Get installer script. From cd56dad7b204002fb44347f06af0fb236a60e401 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 13 Sep 2018 02:30:38 -0400 Subject: [PATCH 032/155] 4.1.4 --- CHANGELOG | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 787ecc2c..16abbb87 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 4.1.4 +- Fixed installer on Node < 8.x + # 4.1.3 - Improved installer - Msg anti-spoofing support diff --git a/package.json b/package.json index dd2b4a94..6baf2ca7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.1.3" + , "version": "4.1.4" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From e15615e3ac7a16c98acb6ede6a4cd63c729f540c Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 13 Sep 2018 11:47:50 -0400 Subject: [PATCH 033/155] 4.1.5 --- CHANGELOG | 2 +- launcher.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 16abbb87..7754afc3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 4.1.4 +# 4.1.5 - Fixed installer on Node < 8.x # 4.1.3 diff --git a/launcher.js b/launcher.js index a593fe8c..4d0fa7b6 100644 --- a/launcher.js +++ b/launcher.js @@ -410,7 +410,7 @@ if (program.build) { output: out }); J.copyFile(path.resolve(info.modulesDir.client, 'build', out), - path.resolve(info.serverDir.build, 'out'); + path.resolve(info.serverDir.build, 'out')); console.log(info.serverDir.build + out + ' rebuilt.'); console.log(''); } diff --git a/package.json b/package.json index 6baf2ca7..c35ab2fb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.1.4" + , "version": "4.1.5" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From cb176d8f8817ccf74dddbd50ea0f199110006d95 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 13 Sep 2018 11:48:30 -0400 Subject: [PATCH 034/155] installer --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index c4d19d50..07ba791b 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -35,7 +35,7 @@ const warn = txt => { const MAIN_MODULE = 'nodegame'; // All stable versions. -const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.3' ]; +const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; From abaada3d37a1ed4c705e94ad1222b7925ba661a7 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 14 Sep 2018 11:37:28 -0400 Subject: [PATCH 035/155] cleanup in bin and update-steps reminder --- bin/nodegame-cli-experimental.js | 3 +++ bin/update/nodegame-update-steps.js | 38 +++++++++++++++++++++++++++++ bin/{ => update}/update_version.sh | 0 3 files changed, 41 insertions(+) create mode 100644 bin/update/nodegame-update-steps.js rename bin/{ => update}/update_version.sh (100%) diff --git a/bin/nodegame-cli-experimental.js b/bin/nodegame-cli-experimental.js index 8b7b7399..cf450447 100755 --- a/bin/nodegame-cli-experimental.js +++ b/bin/nodegame-cli-experimental.js @@ -11,6 +11,9 @@ "use strict"; +console.log('not ready yet!'); +return; + // Modules. const fs = require('fs-extra'); const path = require('path'); diff --git a/bin/update/nodegame-update-steps.js b/bin/update/nodegame-update-steps.js new file mode 100644 index 00000000..5c40b143 --- /dev/null +++ b/bin/update/nodegame-update-steps.js @@ -0,0 +1,38 @@ +const readline = require('readline'); +let rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + terminal: true +}); + +var steps = [ + 'Update version in package.json in nodegame', + 'Update version in nodegame-installer', + 'Upload nodegame-installer to website', + 'Update version in index.htm and upload it to website', + 'Update changelog.htm and upload it to website', + 'Tweet about new version :)' +]; + +var counter = 0; +function step(str) { + return new Promise((resolve) => { + rl.question(' ' + (counter + 1) + '. ' + steps[counter++], () => { + resolve(); + if (counter >= steps.length) { + console.log(); + console.log(' Done!'); + rl.close(); + } + }); + }); +}; + +console.log(); + +step() + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }); diff --git a/bin/update_version.sh b/bin/update/update_version.sh similarity index 100% rename from bin/update_version.sh rename to bin/update/update_version.sh From e98a546374e084da2248d0e42403f663deb0f230 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 14 Sep 2018 11:53:55 -0400 Subject: [PATCH 036/155] minor --- bin/nodegame-installer.js | 2 +- bin/nodegame-update-steps.js | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 bin/nodegame-update-steps.js diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 07ba791b..85c506f1 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -35,7 +35,7 @@ const warn = txt => { const MAIN_MODULE = 'nodegame'; // All stable versions. -const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5' ]; +const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', '4.2.0' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; diff --git a/bin/nodegame-update-steps.js b/bin/nodegame-update-steps.js new file mode 100644 index 00000000..23d7f225 --- /dev/null +++ b/bin/nodegame-update-steps.js @@ -0,0 +1,44 @@ +const readline = require('readline'); +let rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + terminal: true +}); + +var steps = [ + 'Update version in package.json in nodegame', + 'Update CHANGELOG file in nodegame', + 'Update version in nodegame-installer', + 'Git push nodegame to master', + 'Check tests on Travis', + 'Upload nodegame-installer to website', + 'Update version in index.htm and upload it to website', + 'Update changelog.htm and upload it to website', + 'Tweet about new version :)' +]; + +var counter = 0; +function step(str) { + return new Promise((resolve) => { + rl.question(' ' + (counter + 1) + '. ' + steps[counter++], () => { + resolve(); + if (counter >= steps.length) { + console.log(); + console.log(' Done!'); + rl.close(); + } + }); + }); +}; + +console.log(); + +step() + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }); From 1620f18896d53c3796050d0c4a5a1852fa76d62d Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 14 Sep 2018 11:59:37 -0400 Subject: [PATCH 037/155] 4.2.0 --- .travis.yml | 2 +- bin/update/{nodegame-update-steps.js => update-steps.js} | 6 ++++++ package.json | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) rename bin/update/{nodegame-update-steps.js => update-steps.js} (82%) diff --git a/.travis.yml b/.travis.yml index 9f0e0501..4c590578 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ install: ## Remove package json, otherwise npm does not install nodegame as dependency. - npm install --only=dev - rm package.json - - node nodegame-installer.js @dev --install-dir node_modules --no-spinner --branch v4 --yes + - node nodegame-installer.js @dev --install-dir node_modules --no-spinner --yes script: # Add extra tests here. diff --git a/bin/update/nodegame-update-steps.js b/bin/update/update-steps.js similarity index 82% rename from bin/update/nodegame-update-steps.js rename to bin/update/update-steps.js index 5c40b143..23d7f225 100644 --- a/bin/update/nodegame-update-steps.js +++ b/bin/update/update-steps.js @@ -7,7 +7,10 @@ let rl = readline.createInterface({ var steps = [ 'Update version in package.json in nodegame', + 'Update CHANGELOG file in nodegame', 'Update version in nodegame-installer', + 'Git push nodegame to master', + 'Check tests on Travis', 'Upload nodegame-installer to website', 'Update version in index.htm and upload it to website', 'Update changelog.htm and upload it to website', @@ -31,6 +34,9 @@ function step(str) { console.log(); step() + .then(() => { return step(); }) + .then(() => { return step(); }) + .then(() => { return step(); }) .then(() => { return step(); }) .then(() => { return step(); }) .then(() => { return step(); }) diff --git a/package.json b/package.json index c35ab2fb..e0d386a8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame" - , "description": "Starter package for nodegame: install scripts, configurations and development files." - , "version": "4.1.5" + , "description": "Starter package for nodegame: installer, configurations and development files." + , "version": "4.2.0" , "homepage": "http://nodegame.org" , "author": "Stefano Balietti " , "contributors": [ From 34bf216fb797d94ec5508fd66e802d5a0f8a3b5b Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 14 Sep 2018 12:00:16 -0400 Subject: [PATCH 038/155] minor --- CHANGELOG | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 7754afc3..bfae2403 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ # nodeGame Changelog +# 4.2.0 +- Improved create-game command. +- Cleanup +- Small fixes. + # 4.1.5 - Fixed installer on Node < 8.x From b08eb639d306aa770f8811fc7fd59982daef4a13 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 14 Sep 2018 12:09:55 -0400 Subject: [PATCH 039/155] minor --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4c590578..f5188f25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ install: ## Remove package json, otherwise npm does not install nodegame as dependency. - npm install --only=dev - rm package.json + # --branch v4 - node nodegame-installer.js @dev --install-dir node_modules --no-spinner --yes script: From ef23fa942a4b0926c98081c4e0337a36df67f966 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 14 Sep 2018 12:17:58 -0400 Subject: [PATCH 040/155] minor --- bin/nodegame-update-steps.js | 44 ------------------------------------ 1 file changed, 44 deletions(-) delete mode 100644 bin/nodegame-update-steps.js diff --git a/bin/nodegame-update-steps.js b/bin/nodegame-update-steps.js deleted file mode 100644 index 23d7f225..00000000 --- a/bin/nodegame-update-steps.js +++ /dev/null @@ -1,44 +0,0 @@ -const readline = require('readline'); -let rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - terminal: true -}); - -var steps = [ - 'Update version in package.json in nodegame', - 'Update CHANGELOG file in nodegame', - 'Update version in nodegame-installer', - 'Git push nodegame to master', - 'Check tests on Travis', - 'Upload nodegame-installer to website', - 'Update version in index.htm and upload it to website', - 'Update changelog.htm and upload it to website', - 'Tweet about new version :)' -]; - -var counter = 0; -function step(str) { - return new Promise((resolve) => { - rl.question(' ' + (counter + 1) + '. ' + steps[counter++], () => { - resolve(); - if (counter >= steps.length) { - console.log(); - console.log(' Done!'); - rl.close(); - } - }); - }); -}; - -console.log(); - -step() - .then(() => { return step(); }) - .then(() => { return step(); }) - .then(() => { return step(); }) - .then(() => { return step(); }) - .then(() => { return step(); }) - .then(() => { return step(); }) - .then(() => { return step(); }) - .then(() => { return step(); }); From d8a6020febb689cc2e0e5276f220a68d115979da Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 14 Sep 2018 12:29:09 -0400 Subject: [PATCH 041/155] Little extra cleanup in bin/ and test for patch --- package.json | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index e0d386a8..3f8ff92b 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,26 @@ { - "name": "nodegame" - , "description": "Starter package for nodegame: installer, configurations and development files." - , "version": "4.2.0" - , "homepage": "http://nodegame.org" - , "author": "Stefano Balietti " - , "contributors": [ - { "name": "Stefano Balietti", "email": "futur.dorko@gmail.com" } - ] - , "repository": { - "type": "git" - , "url": "https://github.com/nodeGame/nodegame.git" - } - , "engines": { "node": ">= 0.10.0" } - , "dependencies" : { + "name": "nodegame", + "description": "Starter package for nodegame: installer, configurations and development files.", + "version": "4.2.1", + "homepage": "http://nodegame.org", + "author": "Stefano Balietti ", + "contributors": [ + { + "name": "Stefano Balietti", + "email": "futur.dorko@gmail.com" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/nodeGame/nodegame.git" + }, + "engines": { + "node": ">= 0.10.0" + }, + "dependencies": { "commander": "*", "fs-extra": "*", - "smoosh": "0.4.0", + "smoosh": "0.4.0", "nodegame-server": "*", "nodegame-client": "*", "nodegame-window": "*", @@ -30,13 +35,13 @@ "JSUS": "*", "NDDB": "*", "ultimatum-game": "*" - } - , "devDependencies": { + }, + "devDependencies": { "mocha": ">= 0.3.0", "should": "4.4.1" - } - , "license": "MIT" - , "scripts": { + }, + "license": "MIT", + "scripts": { "start": "node launcher.js" } } From 768151a48abce1c2057aa591e2e47c5e8801c6b1 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sun, 16 Sep 2018 11:37:57 -0400 Subject: [PATCH 042/155] updated descr and node version in package.json --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3f8ff92b..b846d4a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "nodegame", - "description": "Starter package for nodegame: installer, configurations and development files.", + "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games +and experiments.", "version": "4.2.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", @@ -15,7 +16,7 @@ "url": "https://github.com/nodeGame/nodegame.git" }, "engines": { - "node": ">= 0.10.0" + "node": ">= 6.0.0" }, "dependencies": { "commander": "*", From cd8a46892313e85981d2e2c9c67fca6053373f11 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sun, 16 Sep 2018 11:40:07 -0400 Subject: [PATCH 043/155] minor --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index bfae2403..4aab698f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ # nodeGame Changelog +# 4.2.1 (current, not npm) + # 4.2.0 - Improved create-game command. - Cleanup From 660afccc1e8c7bb1171553a9e88884c852ae4909 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 18 Sep 2018 03:39:38 -0400 Subject: [PATCH 044/155] fixed rebuild client --- launcher.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/launcher.js b/launcher.js index 4d0fa7b6..01953274 100644 --- a/launcher.js +++ b/launcher.js @@ -11,10 +11,10 @@ "use strict"; // Modules. -var fs = require('fs'); -var path = require('path'); -var exec = require('child_process').exec; -var J = require('JSUS').JSUS; +const fs = require('fs'); +const path = require('path'); +const exec = require('child_process').exec; +const J = require('JSUS').JSUS; var NDDB; @@ -410,7 +410,7 @@ if (program.build) { output: out }); J.copyFile(path.resolve(info.modulesDir.client, 'build', out), - path.resolve(info.serverDir.build, 'out')); + path.resolve(info.serverDir.build, 'nodegame-full.js')); console.log(info.serverDir.build + out + ' rebuilt.'); console.log(''); } From 128d4e4166a4b3f235035c713d2edcc64013e909 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 18 Sep 2018 03:40:29 -0400 Subject: [PATCH 045/155] minor --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 4aab698f..36f5ecba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ # nodeGame Changelog # 4.2.1 (current, not npm) +- Fixed building client. # 4.2.0 - Improved create-game command. From f8951c042a0b634ab6bc19a0124ecfc3cce9606c Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 20 Sep 2018 06:31:14 -0400 Subject: [PATCH 046/155] 4.3.0 --- CHANGELOG | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 36f5ecba..9b6bd073 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,11 @@ # nodeGame Changelog +# 4.3.0 +- Treatment selection in waiting room. If ALLOW_SELECT_TREATMENT is true in +waitroom.setttings.js then a small dropdown menu allows user to select the +treatment for the game. +- Small fixes. + # 4.2.1 (current, not npm) - Fixed building client. diff --git a/package.json b/package.json index b846d4a7..6869e055 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "4.2.1", + "version": "4.3.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From ae7619c9870eb8bf80eca8654b893e8ae6bd5cb5 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 20 Sep 2018 06:32:22 -0400 Subject: [PATCH 047/155] updated-installer-version --- bin/nodegame-installer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 85c506f1..ae4fb73d 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -35,7 +35,8 @@ const warn = txt => { const MAIN_MODULE = 'nodegame'; // All stable versions. -const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', '4.2.0' ]; +const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', + '4.2.0', '4.3.0' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; From af96f4da0f897e4d05e3d5b29f0d77a6a2bed865 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 20 Sep 2018 06:42:47 -0400 Subject: [PATCH 048/155] minor --- CHANGELOG | 2 +- bin/update/update-steps.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9b6bd073..4323eeec 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,7 +2,7 @@ # 4.3.0 - Treatment selection in waiting room. If ALLOW_SELECT_TREATMENT is true in -waitroom.setttings.js then a small dropdown menu allows user to select the +waitroom.settings.js then a small dropdown menu allows user to select the treatment for the game. - Small fixes. diff --git a/bin/update/update-steps.js b/bin/update/update-steps.js index 23d7f225..c8f8c7f2 100644 --- a/bin/update/update-steps.js +++ b/bin/update/update-steps.js @@ -14,6 +14,8 @@ var steps = [ 'Upload nodegame-installer to website', 'Update version in index.htm and upload it to website', 'Update changelog.htm and upload it to website', + 'Commit and push changes to nodegame-website', + 'Update nodegame-heroku package.json version', 'Tweet about new version :)' ]; From 6fcb83687ad3b8435257c650806227877c9d3fe5 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 20 Sep 2018 06:43:34 -0400 Subject: [PATCH 049/155] fix-pjson --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 6869e055..d7e243aa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "nodegame", - "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games -and experiments.", + "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", "version": "4.3.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", From 97a8383358dfc6cbbbff2964c8efd271e97fb754 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sun, 30 Sep 2018 11:54:19 -0400 Subject: [PATCH 050/155] 4.3.1 --- CHANGELOG | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4323eeec..72f8acc2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # nodeGame Changelog +# 4.3.1 +- Re-enabled support for games without treatment description (bug introduced +in 4.3.0) + # 4.3.0 - Treatment selection in waiting room. If ALLOW_SELECT_TREATMENT is true in waitroom.settings.js then a small dropdown menu allows user to select the diff --git a/package.json b/package.json index d7e243aa..3e43fb0f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "4.3.0", + "version": "4.3.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From fd018193e1b4566a22d12991c20ad5a3ce3a769a Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sun, 30 Sep 2018 11:55:56 -0400 Subject: [PATCH 051/155] updated installer --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index ae4fb73d..e558d9c6 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -36,7 +36,7 @@ const MAIN_MODULE = 'nodegame'; // All stable versions. const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', - '4.2.0', '4.3.0' ]; +A '4.2.0', '4.3.1' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; From 5d608f113b69a7c2ea5705a6e4933427fbde902f Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sun, 30 Sep 2018 12:03:22 -0400 Subject: [PATCH 052/155] fixed --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index e558d9c6..2a5077c6 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -36,7 +36,7 @@ const MAIN_MODULE = 'nodegame'; // All stable versions. const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', -A '4.2.0', '4.3.1' ]; + '4.2.0', '4.3.1' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; From e185e72fa190e9fefb71e0471d197382a42871c2 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sun, 30 Sep 2018 12:04:30 -0400 Subject: [PATCH 053/155] 4.3.2 --- CHANGELOG | 2 +- bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 72f8acc2..caced743 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 4.3.1 +# 4.3.2 - Re-enabled support for games without treatment description (bug introduced in 4.3.0) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 2a5077c6..b650f095 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -36,7 +36,7 @@ const MAIN_MODULE = 'nodegame'; // All stable versions. const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', - '4.2.0', '4.3.1' ]; + '4.2.0', '4.3.2' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; diff --git a/package.json b/package.json index 3e43fb0f..b7649b44 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "4.3.1", + "version": "4.3.2", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 2bd01e8531843f876e759355e456b0b640c326eb Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 10 Dec 2018 11:56:56 -0500 Subject: [PATCH 054/155] minor on installer --- bin/nodegame-installer.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index b650f095..e555b0c6 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -40,17 +40,23 @@ const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; -if (process.argv[2] === '--help') { +// Check if it is a help call. +let p = process.argv[2]; +if (p === '--help' || p === '-h') { printHelp(); return; } -else if (process.argv[2] === '--list-versions') { +else if (p === '--list-versions') { console.log(' List of stable versions:'); for (let i=0 ; i < STABLE_VERSIONS.length ; i++) { console.log(' - ' + STABLE_VERSIONS[i]); } return; } +else if (p === '--version' || p === '-v') { + console.log('nodegame-installer v' + INSTALLER_VERSION); + return; +} var verbose = false; var nodeModulesExisting = false; @@ -106,7 +112,7 @@ for (let i = 0; i < process.argv.length; i++) { } else if (option === '--ssh') { doSSH = true; - } + } } if ((doSSH || branch) && !isDev) { @@ -645,6 +651,7 @@ function printHelp() { log(' stays unchanged'); log('--no-spinner Does not start the spinner'); log('--list-versions Lists stable versions'); + log('--version Print installer version'); log('--help Print this help'); log(); } From 0b91dada125bf5979fbfbad14fa6d9bc263bd1ab Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 10 Dec 2018 11:57:28 -0500 Subject: [PATCH 055/155] minor --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index caced743..6f96feb1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# current +- Installer checks better for -v and -h options. + # 4.3.2 - Re-enabled support for games without treatment description (bug introduced in 4.3.0) From dcf5e0c4b8da8bb029dc82a81f0413bb51b6a824 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 11 Mar 2019 15:21:49 -0400 Subject: [PATCH 056/155] v5 --- bin/nodegame-installer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index e555b0c6..4d52e55c 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -1,7 +1,7 @@ #!/usr/local/bin/node /** * # nodeGame Installer - * Copyright(c) 2011-2018 Stefano Balietti + * Copyright(c) 2011-2019 Stefano Balietti * MIT Licensed * * http://www.nodegame.org @@ -32,11 +32,11 @@ const warn = txt => { console.error(' Warning: ' + txt); }; -const MAIN_MODULE = 'nodegame'; +const MAIN_MODULE = 'nodegame-test'; // All stable versions. const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', - '4.2.0', '4.3.2' ]; + '4.2.0', '4.3.2', '5.0.0' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; From 7aad346bfe4263d04130bb5a54e2c6ad86652592 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 11 Mar 2019 15:50:07 -0400 Subject: [PATCH 057/155] relative path for games --- bin/nodegame-installer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 4d52e55c..79332298 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -583,7 +583,11 @@ function copyGameFromNodeModules(game, enable) { if (!enable) return; // Enable it. - makeLink(gameDir, path.resolve(GAMES_ENABLED_DIR, game)); + + // Make it relative + let gameEnabledPath = path.resolve(GAMES_ENABLED_DIR, game); + gameDir = path.join('..', 'games_available', game); + makeLink(gameDir, gameEnabledPath); } function confirm(msg, callback) { From ea48d32ff5e4f55d8a52132f482e5b5c1f0fbe18 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 11 Mar 2019 16:41:54 -0400 Subject: [PATCH 058/155] verbose and checks for node_modules folder --- bin/nodegame-installer.js | 71 ++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 79332298..b79956b0 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -32,11 +32,11 @@ const warn = txt => { console.error(' Warning: ' + txt); }; -const MAIN_MODULE = 'nodegame-test'; +const MAIN_MODULE = 'nodegame'; // All stable versions. const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', - '4.2.0', '4.3.2', '5.0.0' ]; + '4.2.0', '4.3.2' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; @@ -48,7 +48,7 @@ if (p === '--help' || p === '-h') { } else if (p === '--list-versions') { console.log(' List of stable versions:'); - for (let i=0 ; i < STABLE_VERSIONS.length ; i++) { + for (let i=0 ; i < STABLE_VERSIONS.length ; i++) { console.log(' - ' + STABLE_VERSIONS[i]); } return; @@ -75,7 +75,7 @@ var requestedVersion = requestedVersion = '@' + version; for (let i = 0; i < process.argv.length; i++) { let option = process.argv[i]; - + if (option.charAt(0) === '@') { requestedVersion = process.argv[i].substr(1); @@ -85,7 +85,7 @@ for (let i = 0; i < process.argv.length; i++) { requestedVersion = '@' + version; } - else { + else { version = requestedVersion; if (version.length < 1 || version.length > 5) { err('invalid version number: ', version); @@ -108,11 +108,14 @@ for (let i = 0; i < process.argv.length; i++) { log(); return; } - + } else if (option === '--ssh') { doSSH = true; } + else if (option === '--verbose') { + verbose = true; + } } if ((doSSH || branch) && !isDev) { @@ -211,7 +214,7 @@ if (fs.existsSync(NODE_MODULES_DIR)) { }) return; } - else { + else { log('Continue? [y/n] --yes'); log(); } @@ -227,6 +230,20 @@ else doInstall(); function doInstall() { var sp; + + // Check if a node_modules folder exists above or two folders above. + if (fs.existsSync(path.resolve('..', 'node_modules')) || + fs.existsSync(path.resolve('..', '..', 'node_modules'))) { + + log('Attention! A "node_modules" folder was detected in a ' + + 'parent directory.'); + log('Installation cannot continue. Please move the "node_modules" '); + log('folder or try to install nodeGame on another directory.'); + log(); + installationFailed(); + return; + } + // Create spinner. log('Downloading and installing nodeGame packages.'); @@ -256,7 +273,22 @@ function doInstall() { return; } else { - if (verbose) logList(stdout.trim()); + if (verbose) { + log(); + logList(stdout.trim()); + } + if (!fs.existsSync(path.resolve(NODE_MODULES_DIR))) { + log(); + log(); + log('Doh! It looks like npm has a different default ' + + 'installation folder.'); + log('This can happen if you have a directory called '+ + '"node_modules" in any of '); + log('the parent folders. Please try using a ' + + 'different path.'); + installationFailed(); + return; + } log(); log('Done! Now some final magic...'); try { @@ -309,7 +341,7 @@ function checkGitExists(cb) { installationFailed(); } else { - if (cb) cb(); + if (cb) cb(); } }); } @@ -405,7 +437,7 @@ function someMagic() { if (!fs.existsSync(path.resolve(mainNgDir, 'private'))) { fs.mkdirSync(path.resolve(mainNgDir, 'private')); } - + if (!doNotMoveInstall) { // Move nodegame folder outside node_modules. fs.renameSync(mainNgDir, INSTALL_DIR); @@ -505,7 +537,7 @@ function getAllGitModules(cb) { // Copy pre-commit hook. copyFileSync(gitPrecommitHook, path.resolve(modulePath, '.git', 'hooks', - 'pre-commit')); + 'pre-commit')); counter--; if (counter == 0 && cb) cb(); }); @@ -656,6 +688,7 @@ function printHelp() { log('--no-spinner Does not start the spinner'); log('--list-versions Lists stable versions'); log('--version Print installer version'); + log('--verbose Print more output'); log('--help Print this help'); log(); } @@ -777,36 +810,36 @@ function _copyFileSync(src, dest, flag) { const MAX_MASK = getMaxMask(constants); const isExcl = (flags) => flags & COPYFILE_EXCL; - + const writeFlag = isExcl(flag) ? 'wx' : 'w'; - + const { size, mode, } = fs.statSync(src); - + const fdSrc = fs.openSync(src, 'r'); const fdDest = fs.openSync(dest, writeFlag, mode); - + const length = size < SIZE ? size : SIZE; - + let pos = 0; const peaceSize = size < SIZE ? 0 : size % SIZE; const offset = 0; - + let buffer = Buffer.allocUnsafe(length); for (let i = 0; length + pos + peaceSize <= size; i++, pos = length * i) { fs.readSync(fdSrc, buffer, offset, length, pos); fs.writeSync(fdDest, buffer, offset, length, pos); } - + if (peaceSize) { const length = peaceSize; buffer = Buffer.allocUnsafe(length); fs.readSync(fdSrc, buffer, offset, length, pos); fs.writeSync(fdDest, buffer, offset, length, pos); } - + fs.closeSync(fdSrc); fs.closeSync(fdDest); } From f9605a70d3c8e91c8a0f1ccc4de68c5afe0369e8 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 12 Mar 2019 13:08:47 -0400 Subject: [PATCH 059/155] mods --- bin/nodegame-installer.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index b79956b0..da3285f0 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -36,7 +36,7 @@ const MAIN_MODULE = 'nodegame'; // All stable versions. const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', - '4.2.0', '4.3.2' ]; + '4.2.0', '4.3.2' ]; // , '5.0.0' // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; diff --git a/package.json b/package.json index b7649b44..d5a3512c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "4.3.2", + "version": "5.0.0-beta.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 2368d8c47cc180c96b48530c76cdb7b1168235c6 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 12 Mar 2019 13:18:53 -0400 Subject: [PATCH 060/155] 4.3.3 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 32 ++++++++++++++++---------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6f96feb1..89ab75ca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,9 @@ # current - Installer checks better for -v and -h options. +# 4.3.3 +- Updated package.json to fix the version numbers of v4 + # 4.3.2 - Re-enabled support for games without treatment description (bug introduced in 4.3.0) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index e555b0c6..22205b47 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -36,7 +36,7 @@ const MAIN_MODULE = 'nodegame'; // All stable versions. const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', - '4.2.0', '4.3.2' ]; + '4.2.0', '4.3.2', '4.3.3' ]; // Installer default version. const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; diff --git a/package.json b/package.json index b7649b44..f982448e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "4.3.2", + "version": "4.3.3", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ @@ -18,23 +18,23 @@ "node": ">= 6.0.0" }, "dependencies": { - "commander": "*", - "fs-extra": "*", + "commander": "2.19.0", + "fs-extra": "7.0.1", "smoosh": "0.4.0", - "nodegame-server": "*", - "nodegame-client": "*", - "nodegame-window": "*", - "nodegame-widgets": "*", - "nodegame-requirements": "*", - "nodegame-game-template": "*", - "nodegame-monitor": "*", + "nodegame-server": "^4.2.2", + "nodegame-client": "^4.1.1", + "nodegame-window": "^4.0.0", + "nodegame-widgets": "^4.1.0", + "nodegame-requirements": "^4.0.0", + "nodegame-game-template": "^4.2.2", + "nodegame-monitor": "^4.1.0", + "nodegame-generator": "^4.2.1", + "nodegame-mturk": "^4.2.0", + "ultimatum-game": "^4.0.3", + "JSUS": "1.1.0", + "NDDB": "1.18.1", "nodegame-db": "*", - "nodegame-mongodb": "*", - "nodegame-generator": "*", - "nodegame-mturk": "*", - "JSUS": "*", - "NDDB": "*", - "ultimatum-game": "*" + "nodegame-mongodb": "*" }, "devDependencies": { "mocha": ">= 0.3.0", From 4a95eac7cc1d1be06d4487abc19f6ceaf71d4d3f Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 12 Mar 2019 14:02:02 -0400 Subject: [PATCH 061/155] improved installer --- bin/nodegame-installer.js | 114 +++++++++++++++----------------------- 1 file changed, 44 insertions(+), 70 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index da3285f0..2a22dad4 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -1,7 +1,7 @@ #!/usr/local/bin/node /** * # nodeGame Installer - * Copyright(c) 2011-2019 Stefano Balietti + * Copyright(c) 2011-2018 Stefano Balietti * MIT Licensed * * http://www.nodegame.org @@ -35,10 +35,20 @@ const warn = txt => { const MAIN_MODULE = 'nodegame'; // All stable versions. -const STABLE_VERSIONS = [ '3.5.1', '4.0.0', '4.0.4', '4.1.5', - '4.2.0', '4.3.2' ]; // , '5.0.0' +// Versions below < 3 are not available. +const STABLE_VERSIONS = { + v3: '3.5.3', + v4: '4.3.3', + v5: '5.0.0' +}; + +const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); + // Installer default version. -const INSTALLER_VERSION = STABLE_VERSIONS[STABLE_VERSIONS.length-1]; +const INSTALLER_VERSION = 'v4'; + +// The actual version being installed, user can change it. +var version = STABLE_VERSIONS[INSTALLER_VERSION]; // Check if it is a help call. let p = process.argv[2]; @@ -48,13 +58,15 @@ if (p === '--help' || p === '-h') { } else if (p === '--list-versions') { console.log(' List of stable versions:'); - for (let i=0 ; i < STABLE_VERSIONS.length ; i++) { - console.log(' - ' + STABLE_VERSIONS[i]); + for (let i in STABLE_VERSIONS) { + if (STABLE_VERSIONS.hasOwnProperty(i)) { + console.log(' - ' + i + ': ' + STABLE_VERSIONS[i]); + } } return; } else if (p === '--version' || p === '-v') { - console.log('nodegame-installer v' + INSTALLER_VERSION); + console.log('nodegame-installer ' + version); return; } @@ -68,14 +80,12 @@ var yes; var branch; var warnings; -// The actual version being installed, user can change it. -var version = INSTALLER_VERSION; -// User requested version; -var requestedVersion = requestedVersion = '@' + version; +// User requested version. +var requestedVersion = '@' + version; for (let i = 0; i < process.argv.length; i++) { let option = process.argv[i]; - + if (option.charAt(0) === '@') { requestedVersion = process.argv[i].substr(1); @@ -85,14 +95,15 @@ for (let i = 0; i < process.argv.length; i++) { requestedVersion = '@' + version; } - else { - version = requestedVersion; - if (version.length < 1 || version.length > 5) { - err('invalid version number: ', version); + else { + version = STABLE_VERSIONS[requestedVersion]; + if (!version) { + err('invalid version: ', version); + log('available version options: ' + AVAILABLE_VERSIONS); log(); return; } - requestedVersion = '@' + requestedVersion; + requestedVersion = '@' + version; } } else if (option === '--no-spinner') { @@ -108,14 +119,11 @@ for (let i = 0; i < process.argv.length; i++) { log(); return; } - + } else if (option === '--ssh') { doSSH = true; } - else if (option === '--verbose') { - verbose = true; - } } if ((doSSH || branch) && !isDev) { @@ -214,7 +222,7 @@ if (fs.existsSync(NODE_MODULES_DIR)) { }) return; } - else { + else { log('Continue? [y/n] --yes'); log(); } @@ -230,20 +238,6 @@ else doInstall(); function doInstall() { var sp; - - // Check if a node_modules folder exists above or two folders above. - if (fs.existsSync(path.resolve('..', 'node_modules')) || - fs.existsSync(path.resolve('..', '..', 'node_modules'))) { - - log('Attention! A "node_modules" folder was detected in a ' + - 'parent directory.'); - log('Installation cannot continue. Please move the "node_modules" '); - log('folder or try to install nodeGame on another directory.'); - log(); - installationFailed(); - return; - } - // Create spinner. log('Downloading and installing nodeGame packages.'); @@ -273,22 +267,7 @@ function doInstall() { return; } else { - if (verbose) { - log(); - logList(stdout.trim()); - } - if (!fs.existsSync(path.resolve(NODE_MODULES_DIR))) { - log(); - log(); - log('Doh! It looks like npm has a different default ' + - 'installation folder.'); - log('This can happen if you have a directory called '+ - '"node_modules" in any of '); - log('the parent folders. Please try using a ' + - 'different path.'); - installationFailed(); - return; - } + if (verbose) logList(stdout.trim()); log(); log('Done! Now some final magic...'); try { @@ -341,7 +320,7 @@ function checkGitExists(cb) { installationFailed(); } else { - if (cb) cb(); + if (cb) cb(); } }); } @@ -349,7 +328,7 @@ function checkGitExists(cb) { function printNodeGameInfo() { log(); log('*********************************************** '); - log('** WELCOME TO NODEGAME INSTALLER v' + INSTALLER_VERSION + + log('** WELCOME TO NODEGAME INSTALLER v' + version + ' ** '); log('*********************************************** '); log(); @@ -437,7 +416,7 @@ function someMagic() { if (!fs.existsSync(path.resolve(mainNgDir, 'private'))) { fs.mkdirSync(path.resolve(mainNgDir, 'private')); } - + if (!doNotMoveInstall) { // Move nodegame folder outside node_modules. fs.renameSync(mainNgDir, INSTALL_DIR); @@ -537,7 +516,7 @@ function getAllGitModules(cb) { // Copy pre-commit hook. copyFileSync(gitPrecommitHook, path.resolve(modulePath, '.git', 'hooks', - 'pre-commit')); + 'pre-commit')); counter--; if (counter == 0 && cb) cb(); }); @@ -615,11 +594,7 @@ function copyGameFromNodeModules(game, enable) { if (!enable) return; // Enable it. - - // Make it relative - let gameEnabledPath = path.resolve(GAMES_ENABLED_DIR, game); - gameDir = path.join('..', 'games_available', game); - makeLink(gameDir, gameEnabledPath); + makeLink(gameDir, path.resolve(GAMES_ENABLED_DIR, game)); } function confirm(msg, callback) { @@ -688,7 +663,6 @@ function printHelp() { log('--no-spinner Does not start the spinner'); log('--list-versions Lists stable versions'); log('--version Print installer version'); - log('--verbose Print more output'); log('--help Print this help'); log(); } @@ -810,36 +784,36 @@ function _copyFileSync(src, dest, flag) { const MAX_MASK = getMaxMask(constants); const isExcl = (flags) => flags & COPYFILE_EXCL; - + const writeFlag = isExcl(flag) ? 'wx' : 'w'; - + const { size, mode, } = fs.statSync(src); - + const fdSrc = fs.openSync(src, 'r'); const fdDest = fs.openSync(dest, writeFlag, mode); - + const length = size < SIZE ? size : SIZE; - + let pos = 0; const peaceSize = size < SIZE ? 0 : size % SIZE; const offset = 0; - + let buffer = Buffer.allocUnsafe(length); for (let i = 0; length + pos + peaceSize <= size; i++, pos = length * i) { fs.readSync(fdSrc, buffer, offset, length, pos); fs.writeSync(fdDest, buffer, offset, length, pos); } - + if (peaceSize) { const length = peaceSize; buffer = Buffer.allocUnsafe(length); fs.readSync(fdSrc, buffer, offset, length, pos); fs.writeSync(fdDest, buffer, offset, length, pos); } - + fs.closeSync(fdSrc); fs.closeSync(fdDest); } From 1524ed63160b0fe4411aa457ff858ef61a6d233e Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 12 Mar 2019 14:17:26 -0400 Subject: [PATCH 062/155] 5.0.0 --- CHANGELOG | 9 ++++++--- package.json | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6f96feb1..b41d64b4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,14 @@ # nodeGame Changelog -# current -- Installer checks better for -v and -h options. +# 5.0.0 +- Updated installer, now installing latest versions of v3, v4, v5. +- Updated installer, checks for node_modules folder above the current folder. +- Updated package.json with stricter version numbers. -# 4.3.2 +# 4.3.3 - Re-enabled support for games without treatment description (bug introduced in 4.3.0) +- Installer checks better for -v and -h options. # 4.3.0 - Treatment selection in waiting room. If ALLOW_SELECT_TREATMENT is true in diff --git a/package.json b/package.json index d5a3512c..edf06b7f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.0.0-beta.0", + "version": "5.0.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ @@ -18,23 +18,23 @@ "node": ">= 6.0.0" }, "dependencies": { - "commander": "*", - "fs-extra": "*", - "smoosh": "0.4.0", - "nodegame-server": "*", - "nodegame-client": "*", - "nodegame-window": "*", - "nodegame-widgets": "*", - "nodegame-requirements": "*", - "nodegame-game-template": "*", - "nodegame-monitor": "*", + "nodegame-server": "^5.0.0", + "nodegame-client": "^5.0.0", + "nodegame-window": "^5.0.0", + "nodegame-widgets": "^5.0.0", + "nodegame-requirements": "^5.0.0", + "nodegame-game-template": "^5.0.0", + "nodegame-monitor": "^5.0.0", + "nodegame-generator": "^5.0.0", + "nodegame-mturk": "^5.0.0", + "ultimatum-game": "^5.0.0", + "JSUS": ">= 1.1.0", + "NDDB": ">= 1.18.1", "nodegame-db": "*", "nodegame-mongodb": "*", - "nodegame-generator": "*", - "nodegame-mturk": "*", - "JSUS": "*", - "NDDB": "*", - "ultimatum-game": "*" + "commander": "*", + "fs-extra": "*", + "smoosh": "0.4.0" }, "devDependencies": { "mocha": ">= 0.3.0", From b46417696724444131b88a67599ed1706b53e8b1 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 12 Mar 2019 16:58:42 -0400 Subject: [PATCH 063/155] v5-default --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 2a22dad4..433f9628 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -45,7 +45,7 @@ const STABLE_VERSIONS = { const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); // Installer default version. -const INSTALLER_VERSION = 'v4'; +const INSTALLER_VERSION = 'v5'; // The actual version being installed, user can change it. var version = STABLE_VERSIONS[INSTALLER_VERSION]; From d36160c2e1cec55153ea3a65da541c855fa76f9a Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 12 Mar 2019 17:48:29 -0400 Subject: [PATCH 064/155] minor fix on display of install @dev --- bin/nodegame-installer.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 433f9628..2f4d6c30 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -85,17 +85,16 @@ var requestedVersion = '@' + version; for (let i = 0; i < process.argv.length; i++) { let option = process.argv[i]; - + if (option.charAt(0) === '@') { requestedVersion = process.argv[i].substr(1); if (requestedVersion === 'dev') { isDev = true; - version = INSTALLER_VERSION; requestedVersion = '@' + version; } - else { + else { version = STABLE_VERSIONS[requestedVersion]; if (!version) { err('invalid version: ', version); @@ -119,7 +118,7 @@ for (let i = 0; i < process.argv.length; i++) { log(); return; } - + } else if (option === '--ssh') { doSSH = true; @@ -222,7 +221,7 @@ if (fs.existsSync(NODE_MODULES_DIR)) { }) return; } - else { + else { log('Continue? [y/n] --yes'); log(); } @@ -320,7 +319,7 @@ function checkGitExists(cb) { installationFailed(); } else { - if (cb) cb(); + if (cb) cb(); } }); } @@ -416,7 +415,7 @@ function someMagic() { if (!fs.existsSync(path.resolve(mainNgDir, 'private'))) { fs.mkdirSync(path.resolve(mainNgDir, 'private')); } - + if (!doNotMoveInstall) { // Move nodegame folder outside node_modules. fs.renameSync(mainNgDir, INSTALL_DIR); @@ -516,7 +515,7 @@ function getAllGitModules(cb) { // Copy pre-commit hook. copyFileSync(gitPrecommitHook, path.resolve(modulePath, '.git', 'hooks', - 'pre-commit')); + 'pre-commit')); counter--; if (counter == 0 && cb) cb(); }); @@ -784,36 +783,36 @@ function _copyFileSync(src, dest, flag) { const MAX_MASK = getMaxMask(constants); const isExcl = (flags) => flags & COPYFILE_EXCL; - + const writeFlag = isExcl(flag) ? 'wx' : 'w'; - + const { size, mode, } = fs.statSync(src); - + const fdSrc = fs.openSync(src, 'r'); const fdDest = fs.openSync(dest, writeFlag, mode); - + const length = size < SIZE ? size : SIZE; - + let pos = 0; const peaceSize = size < SIZE ? 0 : size % SIZE; const offset = 0; - + let buffer = Buffer.allocUnsafe(length); for (let i = 0; length + pos + peaceSize <= size; i++, pos = length * i) { fs.readSync(fdSrc, buffer, offset, length, pos); fs.writeSync(fdDest, buffer, offset, length, pos); } - + if (peaceSize) { const length = peaceSize; buffer = Buffer.allocUnsafe(length); fs.readSync(fdSrc, buffer, offset, length, pos); fs.writeSync(fdDest, buffer, offset, length, pos); } - + fs.closeSync(fdSrc); fs.closeSync(fdDest); } From 15b9ccd11345041b867750424f7f393129bc5f4a Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 15 Mar 2019 11:57:45 -0400 Subject: [PATCH 065/155] 5.0.1 --- CHANGELOG | 6 ++++++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ca3d5fb7..d63a52a1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,11 @@ # nodeGame Changelog +# 5.0.1 +- Minor update to installer. +- Fixed VisualTimer.restart bug introduced in v5. +- Server does not scan hidden folders inside the games directory. +- Generator does not allow to create games starting with a dot. + # 5.0.0 - Updated installer, now installing latest versions of v3, v4, v5. - Updated installer, checks for node_modules folder above the current folder. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 2f4d6c30..7648ebcc 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.0.0' + v5: '5.0.1' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index edf06b7f..60a6a8fc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.0.0", + "version": "5.0.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From a4bdf5d28c8931bf9e8661e804d62b162eda9c86 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 19 Mar 2019 17:25:36 -0400 Subject: [PATCH 066/155] put back node_modules checks --- bin/nodegame-installer.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 7648ebcc..db217ed1 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -1,7 +1,7 @@ #!/usr/local/bin/node /** * # nodeGame Installer - * Copyright(c) 2011-2018 Stefano Balietti + * Copyright(c) 2011-2019 Stefano Balietti * MIT Licensed * * http://www.nodegame.org @@ -237,6 +237,20 @@ else doInstall(); function doInstall() { var sp; + + // Check if a node_modules folder exists above or two folders above. + if (fs.existsSync(path.resolve('..', 'node_modules')) || + fs.existsSync(path.resolve('..', '..', 'node_modules'))) { + + log('Attention! A "node_modules" folder was detected in a ' + + 'parent directory.'); + log('Installation cannot continue. Please move the "node_modules" '); + log('folder or try to install nodeGame on another directory.'); + log(); + installationFailed(); + return; + } + // Create spinner. log('Downloading and installing nodeGame packages.'); @@ -266,7 +280,22 @@ function doInstall() { return; } else { - if (verbose) logList(stdout.trim()); + if (verbose) { + log(); + logList(stdout.trim()); + } + if (!fs.existsSync(path.resolve(NODE_MODULES_DIR))) { + log(); + log(); + log('Doh! It looks like npm has a different default ' + + 'installation folder.'); + log('This can happen if you have a directory called '+ + '"node_modules" in any of '); + log('the parent folders. Please try using a ' + + 'different path.'); + installationFailed(); + return; + } log(); log('Done! Now some final magic...'); try { From 63d69e026a4b991d34e069a0ed01df00c160536c Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 1 Apr 2019 11:47:40 -0400 Subject: [PATCH 067/155] installer help improved --- bin/nodegame-installer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index db217ed1..292c9653 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -60,7 +60,7 @@ else if (p === '--list-versions') { console.log(' List of stable versions:'); for (let i in STABLE_VERSIONS) { if (STABLE_VERSIONS.hasOwnProperty(i)) { - console.log(' - ' + i + ': ' + STABLE_VERSIONS[i]); + console.log(' @' + i + ': ' + STABLE_VERSIONS[i]); } } return; @@ -680,7 +680,7 @@ function installationFailed() { function printHelp() { log(); - log('@ Install a specific version (>=3.5.1)'); + log('@ Install a specific version (v3, v4, v5)'); log('@dev Install latest nodeGame from git repos'); log(' --branch Checkout this branch on all git repos'); log(' --ssh Use ssh to get all git repos'); From 3793ec9714180682e985765d203736694c661813 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 1 Apr 2019 14:12:16 -0400 Subject: [PATCH 068/155] 5.1.0 --- CHANGELOG | 5 +++++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d63a52a1..22ad28a4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ # nodeGame Changelog +# 5.1.0 +- Minor update to installer. +- Widgets: CustomInput, and garbage collection. +- Window and Client: check frame height automatically. + # 5.0.1 - Minor update to installer. - Fixed VisualTimer.restart bug introduced in v5. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 292c9653..f6bde3d3 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.0.1' + v5: '5.1.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index 60a6a8fc..38b17914 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.0.1", + "version": "5.1.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 90917017e2093dd38d627e16de2791dd29078c3e Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 2 Apr 2019 16:17:26 -0400 Subject: [PATCH 069/155] improved servernode conf file --- conf/servernode.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/servernode.js b/conf/servernode.js index 54ad0e89..a218413b 100644 --- a/conf/servernode.js +++ b/conf/servernode.js @@ -12,8 +12,9 @@ module.exports = configure; function configure(servernode) { // Extra configuration goes here, e.g.: // servernode.port = 80; + // servernode.homePage = false; - // Default configuration set already in: + // See the full set of configuration options in: // node_modules/nodegame-server/conf/servernode.js return true; From fdf79776cfe4c0f51b7933f4a104843be11bb532 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 2 Apr 2019 16:17:54 -0400 Subject: [PATCH 070/155] mods --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 22ad28a4..20a3e635 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# current +- Improved servernode.js conf file. + # 5.1.0 - Minor update to installer. - Widgets: CustomInput, and garbage collection. From 2e2bdf5f55c5470759a4944150fa4f3615a09ec7 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 5 Apr 2019 11:14:35 -0400 Subject: [PATCH 071/155] minor help launcher fix --- launcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher.js b/launcher.js index 01953274..ef051e7e 100644 --- a/launcher.js +++ b/launcher.js @@ -113,11 +113,11 @@ program '(overwrites settings.js in test/ folder') .option('-k, --killServer', 'Kill server after all phantoms have reached game over') - .option('-a --auth [option]', + .option('-a, --auth [option]', 'Phantoms pass through /auth/. Options: createNew|new|' + 'nextAvailable|next|code|id:code&pwd:password|file:path/to/file. ' + 'Default: "new".') - .option('-w --wait [milliseconds]', + .option('-w, --wait [milliseconds]', 'Waits before connecting the next phantom. Default: 1000') From 5490735efcbfe35f9e3dc1560b9470b25ab4b4bb Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 17 Apr 2019 16:09:30 -0400 Subject: [PATCH 072/155] merged --- launcher.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/launcher.js b/launcher.js index ef051e7e..884793db 100644 --- a/launcher.js +++ b/launcher.js @@ -1,6 +1,6 @@ /** * # Launcher file for nodeGame Server - * Copyright(c) 2011-2018 Stefano Balietti + * Copyright(c) 2011-2019 Stefano Balietti * MIT Licensed * * Load configuration options and start the server @@ -88,6 +88,8 @@ program 'Sets the configuration directory') .option('-l, --logDir ', 'Sets the log directory') + .option('-L, --logLevel ', + 'Sets the log level. Values: error(default)|warn|info|silly') .option('-g, --gamesDir ', 'Sets the games directory') .option('-d, --debug', @@ -98,6 +100,9 @@ program 'Rebuilds the specified components', list) .option('-s, --ssl [path-to-ssl-dir]', 'Starts the server with SSL encryption') + .option('-f, --default [channel]', + 'Sets the default channel') + // Connect phantoms. @@ -109,14 +114,13 @@ program .option('-t, --clientType ', 'Sets the client type of connecting phantoms (default: autoplay)') .option('-T, --runTests', - 'Run tests after all phantoms have reached game over ' + - '(overwrites settings.js in test/ folder') + 'Run tests after all phantoms are game-over ' + + '(overwrites settings.js in test/)') .option('-k, --killServer', - 'Kill server after all phantoms have reached game over') + 'Kill server after all phantoms are game-over') .option('-a, --auth [option]', - 'Phantoms pass through /auth/. Options: createNew|new|' + - 'nextAvailable|next|code|id:code&pwd:password|file:path/to/file. ' + - 'Default: "new".') + 'Phantoms auth options. Values: new(default)|createNew|' + + 'nextAvailable|next|code|id:code&pwd:password|file:path/to/file.') .option('-w, --wait [milliseconds]', 'Waits before connecting the next phantom. Default: 1000') @@ -246,6 +250,14 @@ else if ('string' === typeof program.ssl) { if (!options.ssl) return; } +if (program['default']) { + options.defaultChannel = program['default']; +} + +if (program.logLevel) { + options.logLevel = program.logLevel; +} + if (program.nClients) { if (!program.phantoms) ignoredOptions.push('--nClients'); else { From d54d1bb307d574ca02028b16a0a6cd2d58ee293f Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 17 Apr 2019 16:12:48 -0400 Subject: [PATCH 073/155] proper log levels --- launcher.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/launcher.js b/launcher.js index 884793db..9247bd9f 100644 --- a/launcher.js +++ b/launcher.js @@ -89,7 +89,8 @@ program .option('-l, --logDir ', 'Sets the log directory') .option('-L, --logLevel ', - 'Sets the log level. Values: error(default)|warn|info|silly') + 'Sets the log level. Values: error(default)|warn|info|' + + 'verbose|debug|silly') .option('-g, --gamesDir ', 'Sets the games directory') .option('-d, --debug', From 55fe1037eb0b85c521b3e04eafcca25f50119ac0 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 6 May 2019 10:02:00 -0400 Subject: [PATCH 074/155] installer improvements, specially to handle parent node_modules --- bin/nodegame-installer.js | 144 ++++++++++++++++++++++++++++++++------ 1 file changed, 124 insertions(+), 20 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index f6bde3d3..e595bf97 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.1.0' + v5: '5.3.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); @@ -47,6 +47,10 @@ const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); // Installer default version. const INSTALLER_VERSION = 'v5'; +// If node_modules folders are detected, their paths (without node_modules) +// is stored in here. +var parentNodeModules; + // The actual version being installed, user can change it. var version = STABLE_VERSIONS[INSTALLER_VERSION]; @@ -79,6 +83,7 @@ var doNotMoveInstall = false; var yes; var branch; var warnings; +var dry; // User requested version. var requestedVersion = '@' + version; @@ -123,6 +128,9 @@ for (let i = 0; i < process.argv.length; i++) { else if (option === '--ssh') { doSSH = true; } + else if (option === '--dry') { + dry = true; + } } if ((doSSH || branch) && !isDev) { @@ -177,6 +185,13 @@ const GAMES_AVAILABLE_DIR = path.resolve(INSTALL_DIR, 'games_available'); const GAMES_ENABLED_DIR = path.resolve(INSTALL_DIR, 'games'); +// Making sure we do not slip out on an exception. + +process.on('uncaughtException', function(err) { + warn('A generic error occurred during the installation:\n' + err.stack); + installationFailed(); +}); + // Printing Info. // Print cool nodegame logo. @@ -208,11 +223,11 @@ if (fs.existsSync(NODE_MODULES_DIR)) { nodeModulesExisting = true; warn('node_modules directory already existing.'); if (!yes) { - confirm(' Continue? [y/n] ', function(ok) { + confirm('Continue? [y/n] ', function(ok) { if (ok) { process.stdin.destroy(); log(); - doInstall(); + checkParentNodeModules(); } else { log('Installation aborted.'); @@ -228,32 +243,68 @@ if (fs.existsSync(NODE_MODULES_DIR)) { } // Install. -if (isDev) checkGitExists(doInstall); -else doInstall(); +if (isDev) checkGitExists(checkParentNodeModules); +else checkParentNodeModules(); // Helper functions. /////////////////////////////////////////////////////////////////////////////// +function checkParentNodeModules(cb) { + parentNodeModules = getParentNodeModules(); + + // Check if a node_modules folder exists in any folder from the one above. + // to top /. + + if (parentNodeModules.length) { + let str; + str = 'A "node_modules" folder was detected in '; + str += parentNodeModules.length === 1 ? 'this parent directory: ' : + ' these parent directories: '; + warn(str); + parentNodeModules.forEach(dir => logList(dir)); + log(); + + log('You should quit the installation and manually move the parent'); + log('"node_modules" folder/s, or install nodeGame on another path.'); + log(); + log('You may also try to continue the installation, but this is not'); + log('recommended if another live node process is running from those ' + + 'folders.'); + log(); + confirm('Continue? [y/n] ', function(ok) { + if (ok) { + let res = renameParentNodeModules(parentNodeModules); + if (res !== true) { + err('Could not rename ' + res[0]); + installationFailed(); + } + log(); + doInstall(); + } + else { + log('Installation aborted.'); + return; + } + }); + } + else { + doInstall(); + } +} + function doInstall() { var sp; + + // Create spinner. + log('Downloading and installing nodeGame packages.'); - // Check if a node_modules folder exists above or two folders above. - if (fs.existsSync(path.resolve('..', 'node_modules')) || - fs.existsSync(path.resolve('..', '..', 'node_modules'))) { - - log('Attention! A "node_modules" folder was detected in a ' + - 'parent directory.'); - log('Installation cannot continue. Please move the "node_modules" '); - log('folder or try to install nodeGame on another directory.'); + if (dry) { log(); - installationFailed(); + warn('Dry run: aborting.'); return; } - // Create spinner. - log('Downloading and installing nodeGame packages.'); - if (!noSpinner) { sp = new Spinner(' This might take a few minutes %s '); sp.start(); @@ -277,6 +328,7 @@ function doInstall() { log(); logList(stderr.trim()); log(); + installationFailed(); return; } else { @@ -299,7 +351,7 @@ function doInstall() { log(); log('Done! Now some final magic...'); try { - someMagic(); + someMagic(cb); } catch(e) { // execFile( @@ -434,7 +486,7 @@ function printFinalInfo() { } -function someMagic() { +function someMagic(cb) { let mainNgDir = path.resolve(NODE_MODULES_DIR, MAIN_MODULE); // Check if log and private directories have been created. @@ -467,6 +519,9 @@ function someMagic() { // Generator. fixGenerator(); + // Restore any parent node_modules folder that was renamed. + restoreParentNodeModules(); + // Print final Information. printFinalInfo(); }); @@ -478,6 +533,9 @@ function someMagic() { // Generator. fixGenerator(); + // Restore any parent node_modules folder that was renamed. + restoreParentNodeModules(); + // Print final Information. printFinalInfo(); } @@ -631,7 +689,7 @@ function confirm(msg, callback) { output: process.stdout }); - rl.question(msg, function(input) { + rl.question(' ' + msg, function(input) { rl.close(); callback(/^y|yes|ok|true$/i.test(input)); }); @@ -661,6 +719,48 @@ function removeDirRecursiveSync(dir) { } }; +function getParentNodeModules() { + let tks = ROOT_DIR.split(path.sep); + let found = []; + let dirPath = tks[0]; + for (let i = 0 ; i < (tks.length - 1) ; i++) { + if (i !== 0) dirPath = path.join(dirPath, tks[i]); + if (fs.existsSync(path.join(dirPath, 'node_modules'))) { + found.push(dirPath); + } + } + return found; +} + +function renameParentNodeModules(parents, restore) { + let out = []; + for (let i = 0; i < parents.length; i++) { + try { + let f1 = path.join(parents[i], 'node_modules'); + let f2 = f1 + '_backup'; + // Add _bak or remove _bak from parent node_modules folders. + if (restore) fs.renameSync(f2, f1); + else fs.renameSync(f1, f2); + } + catch(e) { + out.push(parents[i]); + // If we are not restoring original folders, exit immediately. + if (!restore) return(out); + } + } + return true; +} + +function restoreParentNodeModules() { + if (!parentNodeModules || !parentNodeModules.length) return; + let res = renameParentNodeModules(parentNodeModules, true); + if (res !== true) { + log(); + warn('Could not restore parent "node_modules" folder in: '); + res.forEach(dir => logList(dir)); + } +} + function installationFailed() { log(); @@ -675,6 +775,9 @@ function installationFailed() { 'https://github.com/nodeGame/nodegame/issues'); log(' - send an email to info@nodegame.org'); log(); + + // Restore any parent node_modules folder that was renamed. + restoreParentNodeModules(); } @@ -689,6 +792,7 @@ function printHelp() { log(' if equals to node_modules, the npm structure'); log(' stays unchanged'); log('--no-spinner Does not start the spinner'); + log('--dry Does not actually install anything'); log('--list-versions Lists stable versions'); log('--version Print installer version'); log('--help Print this help'); From 514ea5c7e0aa6a9b3d0d50503ec1048ac06a994c Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 6 May 2019 10:03:37 -0400 Subject: [PATCH 075/155] 5.3.0 --- CHANGELOG | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 20a3e635..1bc7f408 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,9 @@ # nodeGame Changelog -# current +# 5.3.0 - Improved servernode.js conf file. +- Improved installer: --dry option. +- Improved installer: better handling of parent node_modules folders. # 5.1.0 - Minor update to installer. diff --git a/package.json b/package.json index 38b17914..bbd0dc83 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.1.0", + "version": "5.3.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 9b88dfd1edd74092f3c5dfad18d4c547ac091d74 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 6 May 2019 10:24:21 -0400 Subject: [PATCH 076/155] fixes-to-installer --- bin/nodegame-installer.js | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index e595bf97..2a7fa822 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -51,6 +51,11 @@ const INSTALLER_VERSION = 'v5'; // is stored in here. var parentNodeModules; +var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + // The actual version being installed, user can change it. var version = STABLE_VERSIONS[INSTALLER_VERSION]; @@ -221,8 +226,9 @@ if (fs.existsSync(INSTALL_DIR)) { // Check if node_modules exists (prompt continue?) if (fs.existsSync(NODE_MODULES_DIR)) { nodeModulesExisting = true; - warn('node_modules directory already existing.'); + warn('A "node_modules" folder was detected in this directory.'); if (!yes) { + log(); confirm('Continue? [y/n] ', function(ok) { if (ok) { process.stdin.destroy(); @@ -230,7 +236,7 @@ if (fs.existsSync(NODE_MODULES_DIR)) { checkParentNodeModules(); } else { - log('Installation aborted.'); + installationAborted(); log(); } }) @@ -260,7 +266,7 @@ function checkParentNodeModules(cb) { let str; str = 'A "node_modules" folder was detected in '; str += parentNodeModules.length === 1 ? 'this parent directory: ' : - ' these parent directories: '; + 'these parent directories: '; warn(str); parentNodeModules.forEach(dir => logList(dir)); log(); @@ -283,7 +289,7 @@ function checkParentNodeModules(cb) { doInstall(); } else { - log('Installation aborted.'); + installationAborted(); return; } }); @@ -351,7 +357,7 @@ function doInstall() { log(); log('Done! Now some final magic...'); try { - someMagic(cb); + someMagic(); } catch(e) { // execFile( @@ -487,6 +493,8 @@ function printFinalInfo() { function someMagic(cb) { + rl.close(); + let mainNgDir = path.resolve(NODE_MODULES_DIR, MAIN_MODULE); // Check if log and private directories have been created. @@ -510,7 +518,7 @@ function someMagic(cb) { fs.rmdirSync(NODE_MODULES_DIR); } } - + if (isDev) { getAllGitModules(function() { // Move games from node_modules. @@ -684,13 +692,7 @@ function copyGameFromNodeModules(game, enable) { } function confirm(msg, callback) { - var rl = readline.createInterface({ - input: process.stdin, - output: process.stdout - }); - rl.question(' ' + msg, function(input) { - rl.close(); callback(/^y|yes|ok|true$/i.test(input)); }); } @@ -761,8 +763,15 @@ function restoreParentNodeModules() { } } -function installationFailed() { +function installationAborted() { + rl.close(); + log(); + log('Installation aborted.'); +} +function installationFailed() { + rl.close(); + log(); log('Installation did not complete successfully.'); From eb7bd291ebe84e23761e18bef2852dda567387cb Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 6 May 2019 18:17:29 -0400 Subject: [PATCH 077/155] fixed installer --- bin/nodegame-installer.js | 106 +++++++++++++++++++++++--------------- 1 file changed, 64 insertions(+), 42 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 2a7fa822..1a91dc12 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -193,7 +193,8 @@ const GAMES_ENABLED_DIR = path.resolve(INSTALL_DIR, 'games'); // Making sure we do not slip out on an exception. process.on('uncaughtException', function(err) { - warn('A generic error occurred during the installation:\n' + err.stack); + warn('A generic error occurred during the installation:\n'); + log(err.stack) installationFailed(); }); @@ -212,14 +213,14 @@ if (parseInt(nodeVersion[0], 10) < 4) { err('node version >= 4.x is required.\n' + 'Please upgrade your Node.Js installation, ' + 'visit: http://nodejs.org'); - log(); + installationAborted(); return; } // Check if install dir exists (abort). if (fs.existsSync(INSTALL_DIR)) { err('installation directory already existing.'); - log(); + installationAborted(); return; } @@ -227,16 +228,21 @@ if (fs.existsSync(INSTALL_DIR)) { if (fs.existsSync(NODE_MODULES_DIR)) { nodeModulesExisting = true; warn('A "node_modules" folder was detected in this directory.'); + log(); + log('If you continue, it will become a subfolder of the nodeGame '); + log('installation. This might affect live node processes, as well as '); + log('other Node.JS packages relying on this node_modules folder. If '); + log('unsure, choose No and try to install nodeGame on another path.'); if (!yes) { log(); - confirm('Continue? [y/n] ', function(ok) { + confirm('Continue? [y/n]', function(ok) { if (ok) { - process.stdin.destroy(); + log(); log(); checkParentNodeModules(); } else { - installationAborted(); + installationAborted(true); log(); } }) @@ -257,42 +263,47 @@ else checkParentNodeModules(); /////////////////////////////////////////////////////////////////////////////// function checkParentNodeModules(cb) { - parentNodeModules = getParentNodeModules(); + parentNodeModules = getParentNodeModules(); // Check if a node_modules folder exists in any folder from the one above. // to top /. - if (parentNodeModules.length) { let str; str = 'A "node_modules" folder was detected in '; - str += parentNodeModules.length === 1 ? 'this parent directory: ' : + str += parentNodeModules.length === 1 ? 'a parent directory: ' : 'these parent directories: '; warn(str); parentNodeModules.forEach(dir => logList(dir)); log(); - - log('You should quit the installation and manually move the parent'); - log('"node_modules" folder/s, or install nodeGame on another path.'); - log(); - log('You may also try to continue the installation, but this is not'); - log('recommended if another live node process is running from those ' + - 'folders.'); + + str = 'If you continue, ' + (parentNodeModules.length === 1 ? + 'that folder' : 'those folders'); + log(str + ' will be temporarily renamed. This'); + log('might affect only live node processes. If unsure, choose No '); + log('and try to install nodeGame on another path.'); log(); - confirm('Continue? [y/n] ', function(ok) { - if (ok) { - let res = renameParentNodeModules(parentNodeModules); - if (res !== true) { - err('Could not rename ' + res[0]); - installationFailed(); + if (!yes) { + confirm('Continue? [y/n]', function(ok) { + if (ok) { + log(); + let res = renameParentNodeModules(parentNodeModules); + if (res !== true) { + err('Could not rename ' + res[0]); + installationFailed(); + } + log(); + doInstall(); } - log(); - doInstall(); - } - else { - installationAborted(); - return; - } - }); + else { + installationAborted(true); + return; + } + }); + } + else { + log('Continue? [y/n] --yes'); + log(); + } } else { doInstall(); @@ -301,13 +312,14 @@ function checkParentNodeModules(cb) { function doInstall() { var sp; - + // Create spinner. log('Downloading and installing nodeGame packages.'); if (dry) { log(); warn('Dry run: aborting.'); + closeRL(2); return; } @@ -391,6 +403,7 @@ function doInstall() { return; } } + return; }); } @@ -491,10 +504,14 @@ function printFinalInfo() { log(); } - -function someMagic(cb) { +function closeRL(code) { + // rl.clearLine(); rl.close(); + // if (force) process.stdin.destroy(); + process.exit(code); +} +function someMagic(cb) { let mainNgDir = path.resolve(NODE_MODULES_DIR, MAIN_MODULE); // Check if log and private directories have been created. @@ -518,7 +535,7 @@ function someMagic(cb) { fs.rmdirSync(NODE_MODULES_DIR); } } - + if (isDev) { getAllGitModules(function() { // Move games from node_modules. @@ -532,6 +549,8 @@ function someMagic(cb) { // Print final Information. printFinalInfo(); + + closeRL(0); }); } else { @@ -543,9 +562,11 @@ function someMagic(cb) { // Restore any parent node_modules folder that was renamed. restoreParentNodeModules(); - + // Print final Information. printFinalInfo(); + + closeRL(0); } } @@ -692,7 +713,7 @@ function copyGameFromNodeModules(game, enable) { } function confirm(msg, callback) { - rl.question(' ' + msg, function(input) { + rl.question(' ' + msg + ' ', function(input) { callback(/^y|yes|ok|true$/i.test(input)); }); } @@ -754,7 +775,7 @@ function renameParentNodeModules(parents, restore) { } function restoreParentNodeModules() { - if (!parentNodeModules || !parentNodeModules.length) return; + if (!parentNodeModules || !parentNodeModules.length) return; let res = renameParentNodeModules(parentNodeModules, true); if (res !== true) { log(); @@ -763,15 +784,15 @@ function restoreParentNodeModules() { } } -function installationAborted() { - rl.close(); +function installationAborted(byUser) { + let str = 'Installation aborted' + (byUser ? ' by user.' : '.'); log(); - log('Installation aborted.'); + log(str); + closeRL(1); + return; } function installationFailed() { - rl.close(); - log(); log('Installation did not complete successfully.'); @@ -787,6 +808,7 @@ function installationFailed() { // Restore any parent node_modules folder that was renamed. restoreParentNodeModules(); + closeRL(1); } From e5e1eb5d69db7392ce893d187004e92292b21b3d Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 7 May 2019 03:44:19 -0400 Subject: [PATCH 078/155] 5.3.1 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1bc7f408..79ba7610 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.3.1 +- Minor fixes to installer. + # 5.3.0 - Improved servernode.js conf file. - Improved installer: --dry option. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 1a91dc12..b4c6d005 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.3.0' + v5: '5.3.1' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index bbd0dc83..890be0ad 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.3.0", + "version": "5.3.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From ce7f5262fabcb98f171811e66e3f097bedcaf989 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sun, 12 May 2019 09:15:10 -0400 Subject: [PATCH 079/155] updated installer 5.4.0 --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index b4c6d005..6a8e6eb7 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.3.1' + v5: '5.4.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From 3b07b2a3bb5dba050899441fcb9084020abf4333 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Mon, 13 May 2019 07:29:21 -0400 Subject: [PATCH 080/155] 5.4.0 --- CHANGELOG | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 79ba7610..3cfc7ad1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.4.0 +- New release, updated server, widgets, window. + # 5.3.1 - Minor fixes to installer. diff --git a/package.json b/package.json index 890be0ad..9563b27d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.3.1", + "version": "5.4.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 12c8b130a3d7491431d2492e09613b9838f378f2 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sun, 15 Dec 2019 00:20:33 +0100 Subject: [PATCH 081/155] 5.6.0 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3cfc7ad1..f5382ca2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.6.0 +- New release, updated installer. + # 5.4.0 - New release, updated server, widgets, window. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 6a8e6eb7..237d14dc 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.4.0' + v5: '5.6.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index 9563b27d..85d17e8b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.4.0", + "version": "5.6.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 3ff4826c17154e5991ccf1742f54450d82a1ebd1 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 20 Dec 2019 14:55:09 +0100 Subject: [PATCH 082/155] 5.6.1 --- bin/nodegame-installer.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 237d14dc..77fa6014 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.6.0' + v5: '5.6.1' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index 85d17e8b..6d7896a4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.6.0", + "version": "5.6.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From eec33e793060e06a24c7e1e99114514c71802c08 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 9 Jan 2020 23:38:13 +0100 Subject: [PATCH 083/155] 5.6.2 --- CHANGELOG | 4 ++-- bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f5382ca2..8aa627b1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,12 +1,12 @@ # nodeGame Changelog -# 5.6.0 +# 5.6.0..2 - New release, updated installer. # 5.4.0 - New release, updated server, widgets, window. -# 5.3.1 +:# 5.3.1 - Minor fixes to installer. # 5.3.0 diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 77fa6014..b228be45 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.6.1' + v5: '5.6.2' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index 6d7896a4..f0614279 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.6.1", + "version": "5.6.2", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 78e2d490141f9dee4cdc271595c23fdd86d5f51c Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 10 Jan 2020 22:23:05 +0100 Subject: [PATCH 084/155] 5.6.3 --- CHANGELOG | 2 +- bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8aa627b1..73b298ad 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 5.6.0..2 +# 5.6.0-3 - New release, updated installer. # 5.4.0 diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index b228be45..f4d925c5 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.6.2' + v5: '5.6.3' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index f0614279..ef73cab5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.6.2", + "version": "5.6.3", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From c4f0afc0a979fbfabd3fe1b29032164b71c41f0d Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 16 Jan 2020 14:57:00 +0100 Subject: [PATCH 085/155] 5.6.4 --- CHANGELOG | 2 +- bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 73b298ad..a2c4bbaf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 5.6.0-3 +# 5.6.0-4 - New release, updated installer. # 5.4.0 diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index f4d925c5..1e8b92e8 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.6.3' + v5: '5.6.4' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index ef73cab5..d57a9a78 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.6.3", + "version": "5.6.4", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 987093ab446936ffd44a0e8b83593b18d3b86b52 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 17 Jan 2020 12:46:25 +0100 Subject: [PATCH 086/155] 5.6.5 --- CHANGELOG | 2 +- bin/nodegame-installer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a2c4bbaf..802298f3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 5.6.0-4 +# 5.6.0-5 - New release, updated installer. # 5.4.0 diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 1e8b92e8..47ad970f 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.6.4' + v5: '5.6.5' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From cacd880f0702bf198bdabd3b2b057d05ac6147e8 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 17 Jan 2020 12:46:56 +0100 Subject: [PATCH 087/155] 5.6.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d57a9a78..0b6773a2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.6.4", + "version": "5.6.5", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From aa7b3bdcc9d767b010660b10c701d797195fd4c0 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 17 Jan 2020 12:49:41 +0100 Subject: [PATCH 088/155] 5.7.0 --- CHANGELOG | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 802298f3..5b9a6f5b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.7.0 +- GameRoom.computeBonus handles disconnected players in dump file. + # 5.6.0-5 - New release, updated installer. diff --git a/package.json b/package.json index 0b6773a2..ab87b7b6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.6.5", + "version": "5.7.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From eb65e403f0f4e637cf21eace529a7a9dc06830ef Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 17 Jan 2020 12:50:24 +0100 Subject: [PATCH 089/155] updated installer --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 47ad970f..e730a7ed 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.6.5' + v5: '5.7.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From ba7cb264ca4445da76fec544a7dfca0da748bb4d Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 21 Jan 2020 13:47:24 +0100 Subject: [PATCH 090/155] 5.8.0 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5b9a6f5b..98434e96 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.8.0 +- Game.stepBack. + # 5.7.0 - GameRoom.computeBonus handles disconnected players in dump file. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index e730a7ed..dfa445b4 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.7.0' + v5: '5.8.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From ccfa36508c6ee603044abc79f35de0809be17570 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 21 Jan 2020 13:47:54 +0100 Subject: [PATCH 091/155] 5.8.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ab87b7b6..940387fd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.7.0", + "version": "5.8.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From e30df1239ad44d9c6136772001fdb1ef54ae68aa Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 29 Jan 2020 23:57:48 +0100 Subject: [PATCH 092/155] 5.8.1 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 98434e96..fc9f64ce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.8.1 +- New release, updated installer. + # 5.8.0 - Game.stepBack. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index dfa445b4..403109d9 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.8.0' + v5: '5.8.1' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index 940387fd..14db3967 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.8.0", + "version": "5.8.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From a584e6c0da3a1b64b3f804eb9cffcdfcb4af57c4 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 31 Mar 2020 18:59:44 +0200 Subject: [PATCH 093/155] 5.9.0 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fc9f64ce..e0913c67 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.9.0 +- New release, updated installer. + # 5.8.1 - New release, updated installer. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 403109d9..639a9397 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.8.1' + v5: '5.9.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index 14db3967..7b52c44d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.8.1", + "version": "5.9.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 4d712351c2788a9265d104d7d9dc6016e6097d38 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 1 Apr 2020 17:29:03 +0200 Subject: [PATCH 094/155] Better node_modules parent dir check with --yes option, option --no-parent-dir-check to skip it --- bin/nodegame-installer.js | 46 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 639a9397..ebe57d3d 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -86,6 +86,7 @@ var doSSH = false; var noSpinner = false; var doNotMoveInstall = false; var yes; +var noParentDirCheck; var branch; var warnings; var dry; @@ -121,6 +122,9 @@ for (let i = 0; i < process.argv.length; i++) { else if (option === '--yes') { yes = true; } + else if (option === '--no-parent-dir-check') { + noParentDirCheck = true; + } else if (option === '--branch') { branch = process.argv[i+1]; if (!branch) { @@ -267,7 +271,7 @@ function checkParentNodeModules(cb) { // Check if a node_modules folder exists in any folder from the one above. // to top /. - if (parentNodeModules.length) { + if (!noParentDirCheck && parentNodeModules.length) { let str; str = 'A "node_modules" folder was detected in '; str += parentNodeModules.length === 1 ? 'a parent directory: ' : @@ -283,26 +287,12 @@ function checkParentNodeModules(cb) { log('and try to install nodeGame on another path.'); log(); if (!yes) { - confirm('Continue? [y/n]', function(ok) { - if (ok) { - log(); - let res = renameParentNodeModules(parentNodeModules); - if (res !== true) { - err('Could not rename ' + res[0]); - installationFailed(); - } - log(); - doInstall(); - } - else { - installationAborted(true); - return; - } - }); + confirm('Continue? [y/n]', renameParentCb); } else { log('Continue? [y/n] --yes'); log(); + renameParentCb(true); } } else { @@ -712,9 +702,9 @@ function copyGameFromNodeModules(game, enable) { makeLink(gameDir, path.resolve(GAMES_ENABLED_DIR, game)); } -function confirm(msg, callback) { +function confirm(msg, callback, ...params) { rl.question(' ' + msg + ' ', function(input) { - callback(/^y|yes|ok|true$/i.test(input)); + callback(/^y|yes|ok|true$/i.test(input, ...params)); }); } @@ -755,6 +745,24 @@ function getParentNodeModules() { return found; } +// Need this wrapper because --yes option +function renameParentCb(ok) { + if (ok) { + log(); + let res = renameParentNodeModules(parentNodeModules); + if (res !== true) { + err('Could not rename "node_modules" folder in: ' + res[0]); + installationFailed(); + } + log(); + doInstall(); + } + else { + installationAborted(true); + return; + } +} + function renameParentNodeModules(parents, restore) { let out = []; for (let i = 0; i < parents.length; i++) { From 8af46d10861e74f6e005a9594720d15102fcac4d Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 29 Apr 2020 15:35:48 +0200 Subject: [PATCH 095/155] minor --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index ebe57d3d..d15c276c 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -426,7 +426,7 @@ function printNodeGameInfo() { log(); log('creator: Stefano Balietti'); - log('website: http://nodegame.org'); + log('website: https://nodegame.org'); log('license: MIT'); log('mail: info@nodegame.org'); log('twitter: @nodegameorg'); From 894e2fa86bae0c51121d714bf0ceb84cc01c2562 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 29 Apr 2020 16:39:40 +0200 Subject: [PATCH 096/155] pull-all --- bin/legacy/pull-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/legacy/pull-all.sh b/bin/legacy/pull-all.sh index 0fc564cc..816f4a64 100755 --- a/bin/legacy/pull-all.sh +++ b/bin/legacy/pull-all.sh @@ -10,7 +10,7 @@ echo_and_pull() { GAMES=(ultimatum) MODULES=(nodegame-client nodegame-server nodegame-window nodegame-widgets nodegame-requirements nodegame-game-template nodegame-monitor JSUS NDDB - shelf.js descil-mturk nodegame-db nodegame-mongodb nodegame-generator) + nodegame-db nodegame-mongodb nodegame-generator nodegame-mturk) # Change the current working directory to the parent directory of the script, # i.e. the nodegame directory. Using the below command instead of simply From 819566b385e03c5f837a4cb2a7d7d4e90c4de279 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 29 Apr 2020 17:33:53 +0200 Subject: [PATCH 097/155] pull-all --- bin/legacy/pull-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/legacy/pull-all.sh b/bin/legacy/pull-all.sh index 816f4a64..5d1afd30 100755 --- a/bin/legacy/pull-all.sh +++ b/bin/legacy/pull-all.sh @@ -15,7 +15,7 @@ MODULES=(nodegame-client nodegame-server nodegame-window nodegame-widgets # Change the current working directory to the parent directory of the script, # i.e. the nodegame directory. Using the below command instead of simply # "cd .." makes sure that it does not matter from where the script is executed -cd "$(dirname "${BASH_SOURCE[0]}")/.." +# cd "$(dirname "${BASH_SOURCE[0]}")/.." echo_and_pull nodegame From 6c6c08fef30021d790b1012c378ad22f6b3c34a8 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 19 Jun 2020 15:52:18 +0200 Subject: [PATCH 098/155] fixed problem with some default parameters passed to servernode --- launcher.js | 94 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/launcher.js b/launcher.js index 9247bd9f..9cfa710a 100644 --- a/launcher.js +++ b/launcher.js @@ -1,6 +1,6 @@ /** * # Launcher file for nodeGame Server - * Copyright(c) 2011-2019 Stefano Balietti + * Copyright(c) 2011-2020 Stefano Balietti * MIT Licensed * * Load configuration options and start the server @@ -64,8 +64,8 @@ confFile = null; confDir = './conf'; logDir = './log'; gamesDir = './games'; -debug = false; -infoQuery = false; +debug = undefined; +infoQuery = undefined; nClients = 4; clientType = 'autoplay'; @@ -89,13 +89,12 @@ program .option('-l, --logDir ', 'Sets the log directory') .option('-L, --logLevel ', - 'Sets the log level. Values: error(default)|warn|info|' + - 'verbose|debug|silly') + 'Sets the log level. Values: error(default)|warn|info|silly') .option('-g, --gamesDir ', 'Sets the games directory') .option('-d, --debug', 'Enables the debug mode') - .option('-i, --infoQuery', + .option('-i, --infoQuery [false]', 'Enables getting information via query-string ?q=') .option('-b, --build [components]', 'Rebuilds the specified components', list) @@ -119,10 +118,10 @@ program '(overwrites settings.js in test/)') .option('-k, --killServer', 'Kill server after all phantoms are game-over') - .option('-a, --auth [option]', + .option('-a --auth [option]', 'Phantoms auth options. Values: new(default)|createNew|' + 'nextAvailable|next|code|id:code&pwd:password|file:path/to/file.') - .option('-w, --wait [milliseconds]', + .option('-w --wait [milliseconds]', 'Waits before connecting the next phantom. Default: 1000') @@ -160,36 +159,41 @@ else { // Adds a new game directory (Default is nodegame-server/games). servernode.gamesDirs.push(gamesDir); - // Sets the debug mode, exceptions will be thrown. - servernode.debug = debug; - // Can get information from /?q= - servernode.enableInfoQuery = infoQuery; + + // Sets the debug mode, exceptions will be thrown, if TRUE. + if ('undefined' !== typeof debug) { + servernode.debug = debug; + } + // Can get information from /?q=, if TRUE + if ('undefined' !== typeof infoQuery) { + servernode.enableInfoQuery = infoQuery; + } // Basepath (without trailing slash). // servernode.basepath = '/mybasepath'; return true; }, - http: function(http) { - // Special configuration for Express goes here. - return true; - }, - sio: function(sio) { - // Special configuration for Socket.Io goes here here. - // Might not work in Socket.IO 1.x (check). - - // sio.set('transports', ['xhr-polling']); - // sio.set('transports', ['jsonp-polling']); - - // sio.set('transports', [ - // 'websocket' - // , 'flashsocket' - // , 'htmlfile' - // , 'xhr-polling' - // , 'jsonp-polling' - // ]); - - return true; - } + // http: function(http) { + // // Special configuration for Express goes here. + // return true; + // }, + // sio: function(sio) { + // // Special configuration for Socket.Io goes here here. + // // Might not work in Socket.IO 1.x (check). + // + // // sio.set('transports', ['xhr-polling']); + // // sio.set('transports', ['jsonp-polling']); + // + // // sio.set('transports', [ + // // 'websocket' + // // , 'flashsocket' + // // , 'htmlfile' + // // , 'xhr-polling' + // // , 'jsonp-polling' + // // ]); + // + // return true; + // } }; // Validate other options. @@ -212,7 +216,17 @@ else { gamesDir = program.gamesDir; } if (program.debug) debug = true; - if (program.infoQuery) infoQuery = true; + + // Parse infoQuery. + if (program.infoQuery) { + if ('boolean' === typeof program.infoQuery) { + infoQuery = program.infoQuery; + } + else { + let i = program.infoQuery.toLowerCase(); + infoQuery = i === 'f' || i === 'false' || i === '0' ? false : true; + } + } } // Validate general options. @@ -375,10 +389,10 @@ if (program.build) { cssOnly = true; } } - + info = J.resolveModuleDir('nodegame-server', __dirname); info = require(path.resolve(info, 'bin', 'info.js')); - + if (!cssOnly) { out = 'nodegame-full.js'; @@ -390,7 +404,7 @@ if (program.build) { NDDB: 'NDDB', css: 'css' }; - + // Starting build. i = -1, len = program.build.length; for ( ; ++i < len ; ) { @@ -427,7 +441,7 @@ if (program.build) { console.log(info.serverDir.build + out + ' rebuilt.'); console.log(''); } - + if (cssAlso || cssOnly) { info.build.css(info.serverDir.css, function(err) { if (!err) { @@ -519,7 +533,7 @@ function startServer() { }; } - + startPhantom = function(i) { var str, config; str = 'Connecting phantom #' + (i+1) + '/' + nClients; @@ -554,7 +568,7 @@ function startServer() { phantoms = [], numFinished = 0; for (i = 0; i < nClients; ++i) { if (i > 0 && wait) { - (function(i) { + (function(i) { setTimeout(function() { startPhantom(i); }, wait * i); })(i); } From 33bedd5f939fcb9a7908229869a81b818bd02753 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 13 Aug 2020 13:29:44 +0200 Subject: [PATCH 099/155] 5.10.0 --- CHANGELOG | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e0913c67..ed43fe00 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.10.0 +- New release, updated installer. + # 5.9.0 - New release, updated installer. diff --git a/package.json b/package.json index 7b52c44d..fb093aa3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.9.0", + "version": "5.10.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 557c465e71db0f4084949eff64fabcf5e50aa4c1 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 13 Aug 2020 13:32:33 +0200 Subject: [PATCH 100/155] 5.10.1 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ed43fe00..f57138e5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.10.1 +- Now really updated installer, as claimed in 5.10.0 + # 5.10.0 - New release, updated installer. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index d15c276c..0cdaccf1 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.9.0' + v5: '5.10.1' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index fb093aa3..a882d446 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.10.0", + "version": "5.10.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From da5808a6ba6ab079bd586f7a4ae85fba9d24b275 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 20 Aug 2020 10:41:03 +0200 Subject: [PATCH 101/155] 5.11.0 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f57138e5..eb92c925 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.11.0 +- Small update to client and bug fixes. + # 5.10.1 - Now really updated installer, as claimed in 5.10.0 diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 0cdaccf1..010df6a7 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -39,7 +39,7 @@ const MAIN_MODULE = 'nodegame'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.10.1' + v5: '5.11.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index a882d446..8181462f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.10.1", + "version": "5.11.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From f7b824b60f3b1f64a1bf22e998baba8b274b445b Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 16 Sep 2020 11:14:31 +0200 Subject: [PATCH 102/155] option --port in launcher --- CHANGELOG | 3 +++ launcher.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index eb92c925..fb0b1627 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 5.12.0 current +- Option --port to specify the port of the server in launcher. + # 5.11.0 - Small update to client and bug fixes. diff --git a/launcher.js b/launcher.js index 9cfa710a..073d845b 100644 --- a/launcher.js +++ b/launcher.js @@ -38,7 +38,7 @@ var confFile; // Other local options. var confDir, logDir, gamesDir, debug, infoQuery, runTests; -var nClients, clientType, killServer, auth, wait; +var nClients, clientType, killServer, auth, wait, port; var codesDb; var cert, key; @@ -102,6 +102,8 @@ program 'Starts the server with SSL encryption') .option('-f, --default [channel]', 'Sets the default channel') + .option('-P, --port [port]', + 'Sets the port of the server') @@ -269,6 +271,15 @@ if (program['default']) { options.defaultChannel = program['default']; } +if (program.port) { + port = J.isInt(program.port, 0); + if (!port) { + return printErr('--port ' + program.port + + ' is not a positive number.'); + } + options.port = port; +} + if (program.logLevel) { options.logLevel = program.logLevel; } From 55bfe74b49cc64e62f58efdb1329c15b70e3c467 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 21 Oct 2020 23:41:15 +0200 Subject: [PATCH 103/155] 6.0.0 --- CHANGELOG | 2 +- bin/nodegame-installer.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fb0b1627..2e8b124e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 5.12.0 current +# 6.0.0 - Option --port to specify the port of the server in launcher. # 5.11.0 diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 010df6a7..75a33a8f 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -1,7 +1,7 @@ #!/usr/local/bin/node /** * # nodeGame Installer - * Copyright(c) 2011-2019 Stefano Balietti + * Copyright(c) 2011-2020 Stefano Balietti * MIT Licensed * * http://www.nodegame.org @@ -32,20 +32,22 @@ const warn = txt => { console.error(' Warning: ' + txt); }; -const MAIN_MODULE = 'nodegame'; +// const MAIN_MODULE = 'nodegame'; +const MAIN_MODULE = 'nodegame-test'; // All stable versions. // Versions below < 3 are not available. const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.11.0' + v5: '5.11.0', + v6: '6.0.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); // Installer default version. -const INSTALLER_VERSION = 'v5'; +const INSTALLER_VERSION = 'v6'; // If node_modules folders are detected, their paths (without node_modules) // is stored in here. From 1a8692c5a6fc7427b5d25ff5d8c111cdfbf4219e Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 28 Oct 2020 23:55:36 +0100 Subject: [PATCH 104/155] minor --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 8181462f..1736b11c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.11.0", + "version": "5.11.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ @@ -26,7 +26,6 @@ "nodegame-game-template": "^5.0.0", "nodegame-monitor": "^5.0.0", "nodegame-generator": "^5.0.0", - "nodegame-mturk": "^5.0.0", "ultimatum-game": "^5.0.0", "JSUS": ">= 1.1.0", "NDDB": ">= 1.18.1", From b070869c8280eb4ffaec940588cc479be94b24a6 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 29 Oct 2020 00:04:39 +0100 Subject: [PATCH 105/155] 5.12.2 (fixing version numbers for 5) --- CHANGELOG | 3 +++ package.json | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2e8b124e..5b2c4b9e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,9 @@ # 6.0.0 - Option --port to specify the port of the server in launcher. +# 5.11.2 +- Fixing version numbers. + # 5.11.0 - Small update to client and bug fixes. diff --git a/package.json b/package.json index 1736b11c..ab8794fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.11.1", + "version": "5.11.2", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ @@ -27,8 +27,9 @@ "nodegame-monitor": "^5.0.0", "nodegame-generator": "^5.0.0", "ultimatum-game": "^5.0.0", - "JSUS": ">= 1.1.0", - "NDDB": ">= 1.18.1", + "nodegame-mturk": "^5.0.0", + "JSUS": "^1.1.0", + "NDDB": "^1.18.1", "nodegame-db": "*", "nodegame-mongodb": "*", "commander": "*", From f8798b3a3514eebca908da17efd36e1de09d26d8 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 29 Oct 2020 00:17:23 +0100 Subject: [PATCH 106/155] minor --- bin/nodegame-installer.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 75a33a8f..4c26d3d8 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -40,7 +40,7 @@ const MAIN_MODULE = 'nodegame-test'; const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', - v5: '5.11.0', + v5: '5.11.2', v6: '6.0.0' }; diff --git a/package.json b/package.json index ab8794fe..7beaacae 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "5.11.2", + "version": "6.0.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 7616fb10f3f74118c4ec92b8d048b2bc24ae42f3 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 29 Oct 2020 00:23:22 +0100 Subject: [PATCH 107/155] updated package.json dependencies --- package.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 7beaacae..a3168437 100644 --- a/package.json +++ b/package.json @@ -18,18 +18,18 @@ "node": ">= 6.0.0" }, "dependencies": { - "nodegame-server": "^5.0.0", - "nodegame-client": "^5.0.0", - "nodegame-window": "^5.0.0", - "nodegame-widgets": "^5.0.0", - "nodegame-requirements": "^5.0.0", - "nodegame-game-template": "^5.0.0", - "nodegame-monitor": "^5.0.0", - "nodegame-generator": "^5.0.0", - "ultimatum-game": "^5.0.0", - "nodegame-mturk": "^5.0.0", + "nodegame-server": "^6.0.0", + "nodegame-client": "^6.0.0", + "nodegame-window": "^6.0.0", + "nodegame-widgets": "^6.0.0", + "nodegame-requirements": "^6.0.0", + "nodegame-game-template": "^6.0.0", + "nodegame-monitor": "^6.0.0", + "nodegame-generator": "^6.0.0", + "ultimatum-game": "^6.0.0", + "nodegame-mturk": "^6.0.0", "JSUS": "^1.1.0", - "NDDB": "^1.18.1", + "NDDB": "^2.0.0", "nodegame-db": "*", "nodegame-mongodb": "*", "commander": "*", From b06ba2c2f8ef1204e1cb820884fcf0a2f845e63c Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 29 Oct 2020 00:37:17 +0100 Subject: [PATCH 108/155] 6.0.1 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5b2c4b9e..a3d9da4a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 6.0.1 +- Updated server. + # 6.0.0 - Option --port to specify the port of the server in launcher. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 4c26d3d8..b6805ec6 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -33,7 +33,7 @@ const warn = txt => { }; // const MAIN_MODULE = 'nodegame'; -const MAIN_MODULE = 'nodegame-test'; +const MAIN_MODULE = 'nodegame'; // All stable versions. // Versions below < 3 are not available. @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.0.0' + v6: '6.0.1' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From 919f69a257e12c17332ee88680dc3e422421a6f5 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 29 Oct 2020 00:46:38 +0100 Subject: [PATCH 109/155] 6.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a3168437..c1336b71 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.0.0", + "version": "6.0.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From f6c51939b628999ae7be86ee1d82729b4cbc8d71 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 29 Oct 2020 10:26:19 +0100 Subject: [PATCH 110/155] 6.0.2 --- CHANGELOG | 4 ++++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a3d9da4a..a3083779 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # nodeGame Changelog +# 6.0.2 +- Fixed bug create-game missing private folder in stable version (thanks +jjensenius3). + # 6.0.1 - Updated server. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index b6805ec6..38626632 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.0.1' + v6: '6.0.2' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index c1336b71..b8be12a5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.0.1", + "version": "6.0.2", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 2426551dcb6dcbf0f3812493f25cffa2d00c3c5a Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Fri, 30 Oct 2020 16:07:46 +0100 Subject: [PATCH 111/155] 6.0.3 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a3083779..9e6ec3fa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 6.0.3 +- Fixed corrupted build in 6.0.2 (thanks jjensenius3). + # 6.0.2 - Fixed bug create-game missing private folder in stable version (thanks jjensenius3). diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 38626632..8b56f3ee 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.0.2' + v6: '6.0.3' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index b8be12a5..2a8be7b5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.0.2", + "version": "6.0.3", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From d4a612cdb12f4f627abf3ea7ee4ffa0f7cf2d145 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 23 Dec 2020 00:46:46 +0100 Subject: [PATCH 112/155] minor in conf --- conf/http.js | 7 ++-- conf/loggers.js | 94 ++++++++++++++++++++++++++-------------------- conf/servernode.js | 9 +++-- conf/sio.js | 7 ++-- 4 files changed, 67 insertions(+), 50 deletions(-) diff --git a/conf/http.js b/conf/http.js index 5f5f9c17..c2e17367 100644 --- a/conf/http.js +++ b/conf/http.js @@ -1,7 +1,7 @@ /** * # http.js * - * Copyright(c) 2013 Stefano Balietti + * Copyright(c) 2020 Stefano Balietti * MIT Licensed * * Configuration file for ServerNode in nodegame-server. @@ -10,8 +10,9 @@ module.exports = configure; function configure(app, servernode) { - // Nothing extra to configure. - // Default configuration set already in: + + // Edit this file to modify the default configuration options in: // node_modules/nodegame-server/conf/http.js + return true; }; diff --git a/conf/loggers.js b/conf/loggers.js index 3d1e7eac..472aa322 100644 --- a/conf/loggers.js +++ b/conf/loggers.js @@ -1,46 +1,60 @@ +/** + * # servernode.js + * + * Copyright(c) 2020 Stefano Balietti + * MIT Licensed + * + * Configuration file for ServerNode in nodegame-server. + * --- + */ module.exports = configure; -var path = require('path'); +const path = require('path'); -function configure (loggers) { +function configure(loggers) { -// var config = { -// levels: { -// silly: 0, -// verbose: 1, -// info: 2, -// data: 3, -// warn: 4, -// debug: 5, -// error: 6 -// }, -// colors: { -// silly: 'magenta', -// verbose: 'cyan', -// info: 'green', -// data: 'grey', -// warn: 'yellow', -// debug: 'blue', -// error: 'red' -// } -// }; + // Edit this file to modify the default configuration options in: + // node_modules/nodegame-server/conf/loggers.js -// var rootDir = path.resolve(__dirname, '..'); -// var logDir = rootDir + '/log/'; -// -// loggers.add('ultimatumchannel', { -// console: { -// level: 'silly', -// colorize: true, -// }, -// file: { -// level: 'silly', -// timestamp: true, -// filename: logDir + 'channel', -// maxsize: 1000, -// maxFiles: 10, -// }, -// }); -// - return true; + // For instance: + + // let config = { + // levels: { + // silly: 0, + // verbose: 1, + // info: 2, + // data: 3, + // warn: 4, + // debug: 5, + // error: 6 + // }, + // colors: { + // silly: 'magenta', + // verbose: 'cyan', + // info: 'green', + // data: 'grey', + // warn: 'yellow', + // debug: 'blue', + // error: 'red' + // } + // }; + + // let rootDir = path.resolve(__dirname, '..'); + // let logDir = rootDir + '/log/'; + // + // loggers.add('ultimatumchannel', { + // console: { + // level: 'silly', + // colorize: true, + // }, + // file: { + // level: 'silly', + // timestamp: true, + // filename: logDir + 'channel', + // maxsize: 1000, + // maxFiles: 10, + // }, + // }); + + return true; } diff --git a/conf/servernode.js b/conf/servernode.js index a218413b..645c5f2c 100644 --- a/conf/servernode.js +++ b/conf/servernode.js @@ -1,7 +1,7 @@ /** * # servernode.js * - * Copyright(c) 2017 Stefano Balietti + * Copyright(c) 2020 Stefano Balietti * MIT Licensed * * Configuration file for ServerNode in nodegame-server. @@ -10,12 +10,13 @@ module.exports = configure; function configure(servernode) { + + // Edit this file to modify the default configuration options in: + // node_modules/nodegame-server/conf/servernode.js + // Extra configuration goes here, e.g.: // servernode.port = 80; // servernode.homePage = false; - // See the full set of configuration options in: - // node_modules/nodegame-server/conf/servernode.js - return true; } diff --git a/conf/sio.js b/conf/sio.js index 64012fa7..ba122f02 100644 --- a/conf/sio.js +++ b/conf/sio.js @@ -1,7 +1,7 @@ /** * # sio.js * - * Copyright(c) 2013 Stefano Balietti + * Copyright(c) 2020 Stefano Balietti * MIT Licensed * * Configuration file for the Socket.io server in nodegame-server. @@ -10,8 +10,9 @@ module.exports = configure; function configure(sio, servernode) { - // Nothing extra to configure. - // Default configuration set already in: + + // Edit this file to modify the default configuration options in: // node_modules/nodegame-server/conf/sio.js + return true; }; From 010dff5843f2810c2b476e3b55a272b887be0b29 Mon Sep 17 00:00:00 2001 From: shakty Date: Thu, 21 Jan 2021 11:21:09 +0100 Subject: [PATCH 113/155] Update pull-all.sh Updated pull-all (removed problematic packages on DO) --- bin/legacy/pull-all.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/legacy/pull-all.sh b/bin/legacy/pull-all.sh index 5d1afd30..8ff7dde8 100755 --- a/bin/legacy/pull-all.sh +++ b/bin/legacy/pull-all.sh @@ -10,14 +10,18 @@ echo_and_pull() { GAMES=(ultimatum) MODULES=(nodegame-client nodegame-server nodegame-window nodegame-widgets nodegame-requirements nodegame-game-template nodegame-monitor JSUS NDDB - nodegame-db nodegame-mongodb nodegame-generator nodegame-mturk) + nodegame-generator nodegame-mturk) + +## Removed modules for now. +## nodegame-db nodegame-mongodb # Change the current working directory to the parent directory of the script, # i.e. the nodegame directory. Using the below command instead of simply # "cd .." makes sure that it does not matter from where the script is executed # cd "$(dirname "${BASH_SOURCE[0]}")/.." -echo_and_pull nodegame +## Not yet. +## echo_and_pull nodegame for GAME in "${GAMES[@]}"; do ( From 8d1c18568fef912dca94c9f7e1bee1b8b85378d0 Mon Sep 17 00:00:00 2001 From: shakty Date: Thu, 21 Jan 2021 11:21:58 +0100 Subject: [PATCH 114/155] Update pull-all.sh --- bin/legacy/pull-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/legacy/pull-all.sh b/bin/legacy/pull-all.sh index 8ff7dde8..b4779fff 100755 --- a/bin/legacy/pull-all.sh +++ b/bin/legacy/pull-all.sh @@ -7,7 +7,7 @@ echo_and_pull() { git pull || echo ' FAILED!' } -GAMES=(ultimatum) +GAMES=(ultimatum-game) MODULES=(nodegame-client nodegame-server nodegame-window nodegame-widgets nodegame-requirements nodegame-game-template nodegame-monitor JSUS NDDB nodegame-generator nodegame-mturk) From dfd7f76230df69015a8fa95c20dd68f147fe899e Mon Sep 17 00:00:00 2001 From: shakty Date: Thu, 21 Jan 2021 11:23:53 +0100 Subject: [PATCH 115/155] Update pull-all.sh Minor. --- bin/legacy/pull-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/legacy/pull-all.sh b/bin/legacy/pull-all.sh index b4779fff..364f8961 100755 --- a/bin/legacy/pull-all.sh +++ b/bin/legacy/pull-all.sh @@ -20,7 +20,7 @@ MODULES=(nodegame-client nodegame-server nodegame-window nodegame-widgets # "cd .." makes sure that it does not matter from where the script is executed # cd "$(dirname "${BASH_SOURCE[0]}")/.." -## Not yet. +## Not yet, this fails, we just update the modules. ## echo_and_pull nodegame for GAME in "${GAMES[@]}"; do From 029a85cfe4e702751641226b93c9353a838fe55a Mon Sep 17 00:00:00 2001 From: shakty Date: Sun, 7 Feb 2021 11:22:29 +0100 Subject: [PATCH 116/155] pull-all simplified --- bin/legacy/pull-all.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/legacy/pull-all.sh b/bin/legacy/pull-all.sh index 5d1afd30..8ff7dde8 100755 --- a/bin/legacy/pull-all.sh +++ b/bin/legacy/pull-all.sh @@ -10,14 +10,18 @@ echo_and_pull() { GAMES=(ultimatum) MODULES=(nodegame-client nodegame-server nodegame-window nodegame-widgets nodegame-requirements nodegame-game-template nodegame-monitor JSUS NDDB - nodegame-db nodegame-mongodb nodegame-generator nodegame-mturk) + nodegame-generator nodegame-mturk) + +## Removed modules for now. +## nodegame-db nodegame-mongodb # Change the current working directory to the parent directory of the script, # i.e. the nodegame directory. Using the below command instead of simply # "cd .." makes sure that it does not matter from where the script is executed # cd "$(dirname "${BASH_SOURCE[0]}")/.." -echo_and_pull nodegame +## Not yet. +## echo_and_pull nodegame for GAME in "${GAMES[@]}"; do ( From 8a5f2a53a2f8473b03c9d6495107bfd23982e15b Mon Sep 17 00:00:00 2001 From: shakty Date: Sun, 7 Feb 2021 11:22:39 +0100 Subject: [PATCH 117/155] eslintrc --- .eslintrc.js | 232 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..c16c082c --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,232 @@ +var OFF = 0, WARN = 1, ERROR = 2; + +module.exports = exports = { + "env": { + "es6": true, + "node": true, + "browser": true + }, + + "extends": "eslint:recommended", + + // "ecmaFeatures": { + // // env=es6 doesn't include modules, which we are using + // "modules": true + // }, + // + + "rules": { + "no-console": "off" + }, + + "globals": { + "W": "writable", + "node": "writable", + "J": "writable", + "JSUS": "writable" + } + + // + // "rules": { + // // Possible Errors (overrides from recommended set) + // "no-extra-parens": ERROR, + // "no-unexpected-multiline": ERROR, + // // All JSDoc comments must be valid + // "valid-jsdoc": [ ERROR, { + // "requireReturn": false, + // "requireReturnDescription": false, + // "requireParamDescription": true, + // "prefer": { + // "return": "returns" + // } + // }], + // + // // Best Practices + // + // // Allowed a getter without setter, but all setters require getters + // "accessor-pairs": [ ERROR, { + // "getWithoutSet": false, + // "setWithoutGet": true + // }], + // "block-scoped-var": WARN, + // "consistent-return": ERROR, + // "curly": ERROR, + // "default-case": WARN, + // // the dot goes with the property when doing multiline + // "dot-location": [ WARN, "property" ], + // "dot-notation": WARN, + // "eqeqeq": [ ERROR, "smart" ], + // "guard-for-in": WARN, + // "no-alert": ERROR, + // "no-caller": ERROR, + // "no-case-declarations": WARN, + // "no-div-regex": WARN, + // "no-else-return": WARN, + // "no-empty-label": WARN, + // "no-empty-pattern": WARN, + // "no-eq-null": WARN, + // "no-eval": ERROR, + // "no-extend-native": ERROR, + // "no-extra-bind": WARN, + // "no-floating-decimal": WARN, + // "no-implicit-coercion": [ WARN, { + // "boolean": true, + // "number": true, + // "string": true + // }], + // "no-implied-eval": ERROR, + // "no-invalid-this": ERROR, + // "no-iterator": ERROR, + // "no-labels": WARN, + // "no-lone-blocks": WARN, + // "no-loop-func": ERROR, + // "no-magic-numbers": WARN, + // "no-multi-spaces": ERROR, + // "no-multi-str": WARN, + // "no-native-reassign": ERROR, + // "no-new-func": ERROR, + // "no-new-wrappers": ERROR, + // "no-new": ERROR, + // "no-octal-escape": ERROR, + // "no-param-reassign": ERROR, + // "no-process-env": WARN, + // "no-proto": ERROR, + // "no-redeclare": ERROR, + // "no-return-assign": ERROR, + // "no-script-url": ERROR, + // "no-self-compare": ERROR, + // "no-throw-literal": ERROR, + // "no-unused-expressions": ERROR, + // "no-useless-call": ERROR, + // "no-useless-concat": ERROR, + // "no-void": WARN, + // // Produce warnings when something is commented as TODO or FIXME + // "no-warning-comments": [ WARN, { + // "terms": [ "TODO", "FIXME" ], + // "location": "start" + // }], + // "no-with": WARN, + // "radix": WARN, + // "vars-on-top": ERROR, + // // Enforces the style of wrapped functions + // "wrap-iife": [ ERROR, "outside" ], + // "yoda": ERROR, + // + // // Strict Mode - for ES6, never use strict. + // "strict": [ ERROR, "never" ], + // + // // Variables + // "init-declarations": [ ERROR, "always" ], + // "no-catch-shadow": WARN, + // "no-delete-var": ERROR, + // "no-label-var": ERROR, + // "no-shadow-restricted-names": ERROR, + // "no-shadow": WARN, + // // We require all vars to be initialized (see init-declarations) + // // If we NEED a var to be initialized to undefined, + // // it needs to be explicit + // "no-undef-init": OFF, + // "no-undef": ERROR, + // "no-undefined": OFF, + // "no-unused-vars": WARN, + // // Disallow hoisting - let & const don't allow hoisting anyhow + // "no-use-before-define": ERROR, + // + // // Node.js and CommonJS + // "callback-return": [ WARN, [ "callback", "next" ]], + // "global-require": ERROR, + // "handle-callback-err": WARN, + // "no-mixed-requires": WARN, + // "no-new-require": ERROR, + // // Use path.concat instead + // "no-path-concat": ERROR, + // "no-process-exit": ERROR, + // "no-restricted-modules": OFF, + // "no-sync": WARN, + // + // // ECMAScript 6 support + // "arrow-body-style": [ ERROR, "always" ], + // "arrow-parens": [ ERROR, "always" ], + // "arrow-spacing": [ ERROR, { "before": true, "after": true }], + // "constructor-super": ERROR, + // "generator-star-spacing": [ ERROR, "before" ], + // "no-arrow-condition": ERROR, + // "no-class-assign": ERROR, + // "no-const-assign": ERROR, + // "no-dupe-class-members": ERROR, + // "no-this-before-super": ERROR, + // "no-var": WARN, + // "object-shorthand": [ WARN, "never" ], + // "prefer-arrow-callback": WARN, + // "prefer-spread": WARN, + // "prefer-template": WARN, + // "require-yield": ERROR, + // + // // Stylistic - everything here is a warning because of style. + // "array-bracket-spacing": [ WARN, "always" ], + // "block-spacing": [ WARN, "always" ], + // "brace-style": [ WARN, "1tbs", { "allowSingleLine": false } ], + // "camelcase": WARN, + // "comma-spacing": [ WARN, { "before": false, "after": true } ], + // "comma-style": [ WARN, "last" ], + // "computed-property-spacing": [ WARN, "never" ], + // "consistent-this": [ WARN, "self" ], + // "eol-last": WARN, + // "func-names": WARN, + // "func-style": [ WARN, "declaration" ], + // "id-length": [ WARN, { "min": 2, "max": 32 } ], + // "indent": [ WARN, 4 ], + // "jsx-quotes": [ WARN, "prefer-double" ], + // // "linebreak-style": [ WARN, "unix" ], + // "lines-around-comment": [ WARN, { "beforeBlockComment": true } ], + // "max-depth": [ WARN, 8 ], + // "max-len": [ WARN, 132 ], + // "max-nested-callbacks": [ WARN, 8 ], + // "max-params": [ WARN, 8 ], + // "new-cap": WARN, + // "new-parens": WARN, + // "no-array-constructor": WARN, + // "no-bitwise": OFF, + // "no-continue": OFF, + // "no-inline-comments": OFF, + // "no-lonely-if": WARN, + // "no-mixed-spaces-and-tabs": WARN, + // "no-multiple-empty-lines": WARN, + // "no-negated-condition": OFF, + // "no-nested-ternary": WARN, + // "no-new-object": WARN, + // "no-plusplus": OFF, + // "no-spaced-func": WARN, + // "no-ternary": OFF, + // "no-trailing-spaces": WARN, + // "no-underscore-dangle": WARN, + // "no-unneeded-ternary": WARN, + // "object-curly-spacing": [ WARN, "always" ], + // "one-var": OFF, + // "operator-assignment": [ WARN, "never" ], + // "operator-linebreak": [ WARN, "after" ], + // "padded-blocks": [ WARN, "never" ], + // "quote-props": [ WARN, "consistent-as-needed" ], + // // "quotes": [ WARN, "single" ], + // "require-jsdoc": [ WARN, { + // "require": { + // "FunctionDeclaration": true, + // "MethodDefinition": true, + // "ClassDeclaration": false + // } + // }], + // "semi-spacing": [ WARN, { "before": false, "after": true }], + // "semi": [ ERROR, "always" ], + // "sort-vars": OFF, + // "space-after-keywords": [ WARN, "always" ], + // "space-before-blocks": [ WARN, "always" ], + // "space-before-function-paren": [ WARN, "never" ], + // "space-before-keywords": [ WARN, "always" ], + // "space-in-parens": [ WARN, "never" ], + // "space-infix-ops": [ WARN, { "int32Hint": true } ], + // "space-return-throw-case": ERROR, + // "space-unary-ops": ERROR, + // "spaced-comment": [ WARN, "always" ], + // "wrap-regex": WARN + // } +}; From aefe63008698c0e508f6bd5ece93157f43764123 Mon Sep 17 00:00:00 2001 From: shakty Date: Sun, 7 Feb 2021 20:01:18 +0100 Subject: [PATCH 118/155] Fixed launcher for commander 7 --- launcher.js | 183 +++++++++++++++++++++++++-------------------------- package.json | 2 +- 2 files changed, 92 insertions(+), 93 deletions(-) diff --git a/launcher.js b/launcher.js index 073d845b..5d263f80 100644 --- a/launcher.js +++ b/launcher.js @@ -16,7 +16,7 @@ const path = require('path'); const exec = require('child_process').exec; const J = require('JSUS').JSUS; -var NDDB; +// TODO: refactor, eliminate var; check new Commander options. // Load commander. var program = require('commander'); @@ -129,22 +129,25 @@ program .parse(process.argv); +debugger +// User options (Commander >= 7). +let opts = program.opts(); -if (program.confFile) { - if (!fs.existsSync(program.ConfFile)) { - return printErr('--confFile ' + program.confFile + ' not found.'); +if (opts.confFile) { + if (!fs.existsSync(opts.confFile)) { + return printErr('--confFile ' + opts.confFile + ' not found.'); } - options = require(program.confFile); + options = require(opts.confFile); if ('object' !== typeof options) { - return printErr('--confFile ' + program.confFile + ' did not return ' + + return printErr('--confFile ' + opts.confFile + ' did not return ' + 'a configuration object.'); } - if (program.confDir) ignoredOptions.push('--confDir'); - if (program.logDir) ignoredOptions.push('--logDir'); - if (program.gamesDir) ignoredOptions.push('--gamesDir'); - if (program.debug) ignoredOptions.push('--debug'); - if (program.infoQuery) ignoredOptions.push('--infoQuery'); + if (opts.confDir) ignoredOptions.push('--confDir'); + if (opts.logDir) ignoredOptions.push('--logDir'); + if (opts.gamesDir) ignoredOptions.push('--gamesDir'); + if (opts.debug) ignoredOptions.push('--debug'); + if (opts.infoQuery) ignoredOptions.push('--infoQuery'); } else { @@ -199,33 +202,33 @@ else { }; // Validate other options. - if (program.confDir) { - if (!fs.existsSync(program.confDir)) { - return printErr('--confDir ' + program.confDir + ' not found.'); + if (opts.confDir) { + if (!fs.existsSync(opts.confDir)) { + return printErr('--confDir ' + opts.confDir + ' not found.'); } - confDir = program.confDir; + confDir = opts.confDir; } - if (program.logDir) { - if (!fs.existsSync(program.logDir)) { - return printErr('--logDir ' + program.logDir + ' not found.'); + if (opts.logDir) { + if (!fs.existsSync(opts.logDir)) { + return printErr('--logDir ' + opts.logDir + ' not found.'); } - logDir = program.logDir; + logDir = opts.logDir; } - if (program.gamesDir) { - if (!fs.existsSync(program.gamesDir)) { - return printErr('--gamesDir ' + program.gamesDir + ' not found.'); + if (opts.gamesDir) { + if (!fs.existsSync(opts.gamesDir)) { + return printErr('--gamesDir ' + opts.gamesDir + ' not found.'); } - gamesDir = program.gamesDir; + gamesDir = opts.gamesDir; } - if (program.debug) debug = true; + if (opts.debug) debug = true; // Parse infoQuery. - if (program.infoQuery) { - if ('boolean' === typeof program.infoQuery) { - infoQuery = program.infoQuery; + if (opts.infoQuery) { + if ('boolean' === typeof opts.infoQuery) { + infoQuery = opts.infoQuery; } else { - let i = program.infoQuery.toLowerCase(); + let i = opts.infoQuery.toLowerCase(); infoQuery = i === 'f' || i === 'false' || i === '0' ? false : true; } } @@ -233,10 +236,10 @@ else { // Validate general options. -if ('boolean' === typeof program.ssl) { +if ('boolean' === typeof opts.ssl) { options.ssl = true; } -else if ('string' === typeof program.ssl) { +else if ('string' === typeof opts.ssl) { options.ssl = (function(dir) { var ssl; @@ -263,7 +266,7 @@ else if ('string' === typeof program.ssl) { return ssl; - })(program.ssl); + })(opts.ssl); if (!options.ssl) return; } @@ -271,74 +274,74 @@ if (program['default']) { options.defaultChannel = program['default']; } -if (program.port) { - port = J.isInt(program.port, 0); +if (opts.port) { + port = J.isInt(opts.port, 0); if (!port) { - return printErr('--port ' + program.port + + return printErr('--port ' + opts.port + ' is not a positive number.'); } options.port = port; } -if (program.logLevel) { - options.logLevel = program.logLevel; +if (opts.logLevel) { + options.logLevel = opts.logLevel; } -if (program.nClients) { - if (!program.phantoms) ignoredOptions.push('--nClients'); +if (opts.nClients) { + if (!opts.phantoms) ignoredOptions.push('--nClients'); else { - nClients = parseInt(program.nClients, 10); + nClients = parseInt(opts.nClients, 10); if (isNaN(nClients)) { - return printErr('--nClients ' + program.nClients + + return printErr('--nClients ' + opts.nClients + ' is invalid.'); } } } -if (program.clientType) { - if (!program.phantoms) ignoredOptions.push('--clientType'); - else clientType = program.clientType; +if (opts.clientType) { + if (!opts.phantoms) ignoredOptions.push('--clientType'); + else clientType = opts.clientType; } -if (program.runTests) { - if (!program.runTests) ignoredOptions.push('--runTests'); - else runTests = program.runTests; +if (opts.runTests) { + if (!opts.runTests) ignoredOptions.push('--runTests'); + else runTests = opts.runTests; } -if (program.killServer) { - if (!program.phantoms) ignoredOptions.push('--killServer'); +if (opts.killServer) { + if (!opts.phantoms) ignoredOptions.push('--killServer'); else killServer = true; } -if (program.wait) { - if (!program.phantoms) { +if (opts.wait) { + if (!opts.phantoms) { ignoredOptions.push('--wait'); } else { - if (true === program.wait) { + if (true === opts.wait) { wait = 1000; } else { - wait = J.isInt(program.wait, 0); + wait = J.isInt(opts.wait, 0); if (false === wait) { printErr('--wait must be a positive number or undefined. ' + - 'Found:' + program.wait); + 'Found:' + opts.wait); process.exit(); } } } } -if (program.auth) { - if (!program.phantoms) { +if (opts.auth) { + if (!opts.phantoms) { ignoredOptions.push('--auth'); } - else if ('string' === typeof program.auth) { + else if ('string' === typeof opts.auth) { auth = (function(idIdx, pwdIdx) { var auth; - idIdx = program.auth.indexOf('id:'); + idIdx = opts.auth.indexOf('id:'); if (idIdx === 0) { - pwdIdx = program.auth.indexOf('&pwd:'); + pwdIdx = opts.auth.indexOf('&pwd:'); if (pwdIdx !== -1) { auth = { - id: program.auth.substr(3, (pwdIdx-3)), - pwd: program.auth.substr(pwdIdx+5) + id: opts.auth.substr(3, (pwdIdx-3)), + pwd: opts.auth.substr(pwdIdx+5) }; } else { @@ -347,67 +350,65 @@ if (program.auth) { process.exit(); } } - else if (program.auth === 'new') { + else if (opts.auth === 'new') { auth = 'createNew'; } - else if (program.auth === 'next') { + else if (opts.auth === 'next') { auth = 'nextAvailable'; } - else if (program.auth.indexOf('file:') === 0) { - NDDB = require('NDDB').NDDB; + else if (opts.auth.indexOf('file:') === 0) { + const NDDB = require('NDDB').NDDB; codesDb = new NDDB(); - codesDb.loadSync(program.auth.substr(5)); + codesDb.loadSync(opts.auth.substr(5)); if (!codesDb.size()) { - printErr('--auth no auth codes found: program.auth'); + printErr('--auth no auth codes found: opts.auth'); process.exit(); } codesDb = codesDb.db; } else { - auth = program.auth; + auth = opts.auth; } return auth; })(); } - else if ('boolean' === typeof program.auth) { + else if ('boolean' === typeof opts.auth) { auth = 'createNew'; } - else if ('number' === typeof program.auth || - 'object' === typeof program.auth) { + else if ('number' === typeof opts.auth || + 'object' === typeof opts.auth) { - auth = program.auth; + auth = opts.auth; } } // Rebuild server files as needed. -if (program.build) { +if (opts.build) { (function() { - var i, len, opts, modules; - var info, module, out; - var cssAlso, cssOnly; + let cssAlso, cssOnly; - len = program.build.length; + let len = opts.build.length; if (!len) { - program.build = [ 'client' ]; + opts.build = [ 'client' ]; } else if (len === 1) { - if (program.build[0] === 'all') { + if (opts.build[0] === 'all') { // Client will be done anyway. - program.build = [ 'window', 'widgets', 'JSUS', 'NDDB' ]; + opts.build = [ 'window', 'widgets', 'JSUS', 'NDDB' ]; } - else if (program.build[0] === 'css') { + else if (opts.build[0] === 'css') { cssOnly = true; } } - info = J.resolveModuleDir('nodegame-server', __dirname); + let info = J.resolveModuleDir('nodegame-server', __dirname); info = require(path.resolve(info, 'bin', 'info.js')); if (!cssOnly) { - out = 'nodegame-full.js'; + let out = 'nodegame-full.js'; - modules = { + let modules = { window: 'window', client: 'client', widgets: 'widgets', @@ -417,9 +418,9 @@ if (program.build) { }; // Starting build. - i = -1, len = program.build.length; + let i = -1; for ( ; ++i < len ; ) { - module = program.build[i]; + let module = opts.build[i]; if (!modules[module]) { throw new Error('unknown build component: ' + module); } @@ -436,9 +437,7 @@ if (program.build) { continue; } - opts = { all: true, clean: true }; - - info.build[module](opts); + info.build[module]({ all: true, clean: true }); console.log(''); } // Do client last. @@ -448,7 +447,7 @@ if (program.build) { output: out }); J.copyFile(path.resolve(info.modulesDir.client, 'build', out), - path.resolve(info.serverDir.build, 'nodegame-full.js')); + path.resolve(info.serverDir.build, out)); console.log(info.serverDir.build + out + ' rebuilt.'); console.log(''); } @@ -465,7 +464,7 @@ if (program.build) { startServer(); } - })(program.build); + })(); } else { startServer(); @@ -492,9 +491,9 @@ function startServer() { var numFinished; // If there are not bots to add returns. - if (!program.phantoms) return; + if (!opts.phantoms) return; - gameName = program.phantoms; + gameName = opts.phantoms; channel = sn.channels[gameName]; if (!channel) { printErr('channel ' + gameName + ' was not found.'); diff --git a/package.json b/package.json index 2a8be7b5..266b50c4 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "NDDB": "^2.0.0", "nodegame-db": "*", "nodegame-mongodb": "*", - "commander": "*", + "commander": "^7.0.0", "fs-extra": "*", "smoosh": "0.4.0" }, From 5923ca46d77ef30281743b44b4999fa4ba863179 Mon Sep 17 00:00:00 2001 From: shakty Date: Sun, 7 Feb 2021 20:02:19 +0100 Subject: [PATCH 119/155] 6.1.0 --- CHANGELOG | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9e6ec3fa..fd9cf473 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # nodeGame Changelog +# 6.1.0 +- Fixed launcher for Commander v7. +- Updated server,client,window,widgets. + # 6.0.3 - Fixed corrupted build in 6.0.2 (thanks jjensenius3). diff --git a/package.json b/package.json index 266b50c4..4dd9ae7a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.0.3", + "version": "6.1.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 4a2b8dffc2ecc3a5d78e755d38588b9ee8dce058 Mon Sep 17 00:00:00 2001 From: shakty Date: Sun, 7 Feb 2021 20:02:47 +0100 Subject: [PATCH 120/155] updated installer --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 8b56f3ee..29b5e24d 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.0.3' + v6: '6.1.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From f4dad854de5f0c4c3ad5b4a17040c93150f6e5ab Mon Sep 17 00:00:00 2001 From: shakty Date: Sun, 7 Feb 2021 20:52:31 +0100 Subject: [PATCH 121/155] 6.1.1 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fd9cf473..c27c95de 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 6.1.1 +- Built widgets. + # 6.1.0 - Fixed launcher for Commander v7. - Updated server,client,window,widgets. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 29b5e24d..1a2a9e55 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.1.0' + v6: '6.1.1' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index 4dd9ae7a..74b1e455 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.1.0", + "version": "6.1.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 58a4c04df564125ca3d29b1e3a953c5f48a0de70 Mon Sep 17 00:00:00 2001 From: Stefano Baietti Date: Tue, 9 Feb 2021 15:29:12 +0100 Subject: [PATCH 122/155] removed debugger from launcher --- bin/nodegame-installer.js | 2 +- launcher.js | 1 - package.json | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 1a2a9e55..04adc507 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.1.1' + v6: '6.2.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/launcher.js b/launcher.js index 5d263f80..dae772b3 100644 --- a/launcher.js +++ b/launcher.js @@ -129,7 +129,6 @@ program .parse(process.argv); -debugger // User options (Commander >= 7). let opts = program.opts(); diff --git a/package.json b/package.json index 74b1e455..fe22d827 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.1.1", + "version": "6.2.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From c7129696a9ac6cb2a87b06ae343e4de948248fa1 Mon Sep 17 00:00:00 2001 From: Stefano Baietti Date: Tue, 9 Feb 2021 15:29:57 +0100 Subject: [PATCH 123/155] changelog --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index c27c95de..b13901e3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # nodeGame Changelog +# 6.2.0 +- Removed debugger from launcher. +- Updated server with more options for WaitingRoom. + # 6.1.1 - Built widgets. From 04d0ef23c2d3ceb07734e3ddbbaf0d29d3edccce Mon Sep 17 00:00:00 2001 From: Stefano Baietti Date: Tue, 9 Feb 2021 15:47:24 +0100 Subject: [PATCH 124/155] 6.2.0 --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index b13901e3..df7ba249 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ # nodeGame Changelog # 6.2.0 -- Removed debugger from launcher. +- Removed debugger from launcher.js. - Updated server with more options for WaitingRoom. # 6.1.1 From f15dfe6fa843b73d92de366e8c45780e09451036 Mon Sep 17 00:00:00 2001 From: Stefano Baietti Date: Wed, 10 Feb 2021 15:39:24 +0100 Subject: [PATCH 125/155] 6.2.1 --- CHANGELOG | 3 +++ bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index df7ba249..8cf0a307 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # nodeGame Changelog +# 6.2.1 +- New release, fixed support for images loaded in mainframe. + # 6.2.0 - Removed debugger from launcher.js. - Updated server with more options for WaitingRoom. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 04adc507..f552586d 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.2.0' + v6: '6.2.1' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index fe22d827..593ad5dc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.2.0", + "version": "6.2.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From a980ed8db6d03d9645450f18f261163af217aff1 Mon Sep 17 00:00:00 2001 From: shakty Date: Wed, 10 Feb 2021 16:05:45 +0100 Subject: [PATCH 126/155] 6.2.2 --- CHANGELOG | 2 +- bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8cf0a307..2fbfd7fa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 6.2.1 +# 6.2.2 - New release, fixed support for images loaded in mainframe. # 6.2.0 diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index f552586d..d7ff5393 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.2.1' + v6: '6.2.2' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index 593ad5dc..fc2ecdd4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.2.1", + "version": "6.2.2", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 67db78d405c5b4732cf486cf468a78492d4b13cb Mon Sep 17 00:00:00 2001 From: shakty Date: Wed, 10 Feb 2021 16:15:26 +0100 Subject: [PATCH 127/155] Fixed 'default' option in launcher for Commander 7 --- launcher.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher.js b/launcher.js index dae772b3..40e68c94 100644 --- a/launcher.js +++ b/launcher.js @@ -269,8 +269,8 @@ else if ('string' === typeof opts.ssl) { if (!options.ssl) return; } -if (program['default']) { - options.defaultChannel = program['default']; +if (opts['default']) { + options.defaultChannel = opts['default']; } if (opts.port) { From a789f8d2712f73e462a04f6b3cf779d56fae51f2 Mon Sep 17 00:00:00 2001 From: shakty Date: Wed, 10 Feb 2021 16:16:08 +0100 Subject: [PATCH 128/155] 6.2.3 --- CHANGELOG | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2fbfd7fa..fca75643 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ # nodeGame Changelog -# 6.2.2 +# 6.2.3 +- Fixed "default" option in launcher for Commander v7. - New release, fixed support for images loaded in mainframe. # 6.2.0 diff --git a/package.json b/package.json index fc2ecdd4..e44217d1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.2.2", + "version": "6.2.3", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From bae9ca1f6e72791166e11a3f3d24bfe738ea3270 Mon Sep 17 00:00:00 2001 From: shakty Date: Wed, 10 Feb 2021 16:18:20 +0100 Subject: [PATCH 129/155] 6.2.4 --- CHANGELOG | 2 +- bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fca75643..6fab16ad 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 6.2.3 +# 6.2.4 (6.2.1-6.2.3 deprecated) - Fixed "default" option in launcher for Commander v7. - New release, fixed support for images loaded in mainframe. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index d7ff5393..3013004b 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.2.2' + v6: '6.2.4' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index e44217d1..ec917fd7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.2.3", + "version": "6.2.4", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 703133fa6b3c7b2d982cdffba6580b15da03e26d Mon Sep 17 00:00:00 2001 From: Stefano Balieti Date: Thu, 8 Apr 2021 11:19:41 +0200 Subject: [PATCH 130/155] no-games option in installer --- bin/nodegame-installer.js | 46 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 3013004b..9995dca3 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -93,6 +93,9 @@ var branch; var warnings; var dry; +// Add default games in games/ and games_available/. +var addGames = true; + // User requested version. var requestedVersion = '@' + version; @@ -142,6 +145,9 @@ for (let i = 0; i < process.argv.length; i++) { else if (option === '--dry') { dry = true; } + else if (option === '--no-games') { + addGames = false; + } } if ((doSSH || branch) && !isDev) { @@ -190,7 +196,6 @@ const NODEGAME_MODULES = [ 'JSUS', 'NDDB', 'ultimatum-game' ]; -const N_MODULES = NODEGAME_MODULES.length; const GAMES_AVAILABLE_DIR = path.resolve(INSTALL_DIR, 'games_available'); @@ -530,8 +535,11 @@ function someMagic(cb) { if (isDev) { getAllGitModules(function() { - // Move games from node_modules. - copyGameFromNodeModules('ultimatum-game'); + + if (addGames) { + // Move games from node_modules. + copyGameFromNodeModules('ultimatum-game'); + } // Generator. fixGenerator(); @@ -546,8 +554,11 @@ function someMagic(cb) { }); } else { - // Move games from node_modules. - copyGameFromNodeModules('ultimatum-game'); + + if (addGames) { + // Move games from node_modules. + copyGameFromNodeModules('ultimatum-game'); + } // Generator. fixGenerator(); @@ -568,17 +579,15 @@ function fixGenerator() { 'nodegame-generator', 'bin', 'nodegame'), path.resolve(INSTALL_DIR, 'bin', 'nodegame'), - 'file'); + 'file'); fs.writeFileSync(path.resolve(INSTALL_DIR_MODULES, - 'nodegame-generator', - 'conf', - 'generator.conf.json'), - JSON.stringify({ - author: "", - email: "", - ngDir: INSTALL_DIR - }, 4)); + 'nodegame-generator', 'conf', 'generator.conf.json'), + JSON.stringify({ + author: "", + email: "", + ngDir: INSTALL_DIR + }, 4)); } function getAllGitModules(cb) { @@ -732,7 +741,7 @@ function removeDirRecursiveSync(dir) { }); fs.rmdirSync(dir); } -}; +} function getParentNodeModules() { let tks = ROOT_DIR.split(path.sep); @@ -843,8 +852,6 @@ function printHelp() { // Kudos: cli-spinner package. function Spinner(text) { - var that; - that = this; this.spinners = [ "|/-\\", @@ -914,10 +921,10 @@ function Spinner(text) { readline.clearLine(stream, 0); readline.cursorTo(stream, 0); }; -}; +} function inArray(needle, haystack) { - var func, i, len; + var i, len; len = haystack.length; for (i = 0; i < len; i++) { if (needle === haystack[i]) { @@ -945,7 +952,6 @@ function _copyFileSync(src, dest, flag) { COPYFILE_FICLONE_FORCE, }; - const isNumber = (a) => typeof a === 'number'; const or = (a, b) => a | b; const getValue = (obj) => (key) => obj[key]; From 0ee509aa3ec76f38b9336195b5d68889997a8881 Mon Sep 17 00:00:00 2001 From: Stefano Balieti Date: Thu, 8 Apr 2021 11:21:58 +0200 Subject: [PATCH 131/155] updated help install --- bin/nodegame-installer.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 9995dca3..de3d598e 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -833,19 +833,20 @@ function installationFailed() { function printHelp() { log(); - log('@ Install a specific version (v3, v4, v5)'); - log('@dev Install latest nodeGame from git repos'); - log(' --branch Checkout this branch on all git repos'); - log(' --ssh Use ssh to get all git repos'); - log('--yes Answer yes to all questions'); - log('--install-dir Set the name of the installation directory;'); + log('@ Installs a specific version (v3, v4, v5, v6)'); + log('@dev Installs latest nodeGame from git repos'); + log('--branch Checkouts this branch on all git repos'); + log('--ssh Uses ssh to get all git repos'); + log('--yes Answers yes to all questions'); + log('--install-dir Sets the name of the installation directory;'); log(' if equals to node_modules, the npm structure'); log(' stays unchanged'); log('--no-spinner Does not start the spinner'); log('--dry Does not actually install anything'); log('--list-versions Lists stable versions'); - log('--version Print installer version'); - log('--help Print this help'); + log('--no-games Does not install default games'); + log('--version Prints installer version'); + log('--help Prints this help'); log(); } From ec18f405c3f03d765bdeb95cb3c085ded21f7f91 Mon Sep 17 00:00:00 2001 From: Stefano Balieti Date: Thu, 8 Apr 2021 11:25:17 +0200 Subject: [PATCH 132/155] fixed installer getting stuck on help and versions --- bin/nodegame-installer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index de3d598e..720dd10f 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -53,11 +53,6 @@ const INSTALLER_VERSION = 'v6'; // is stored in here. var parentNodeModules; -var rl = readline.createInterface({ - input: process.stdin, - output: process.stdout -}); - // The actual version being installed, user can change it. var version = STABLE_VERSIONS[INSTALLER_VERSION]; @@ -81,6 +76,11 @@ else if (p === '--version' || p === '-v') { return; } +var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + var verbose = false; var nodeModulesExisting = false; var isDev = false; From 803598b3c44bc2aade7b07c38beaf2f84a8c15a9 Mon Sep 17 00:00:00 2001 From: Stefano Balieti Date: Thu, 8 Apr 2021 11:27:44 +0200 Subject: [PATCH 133/155] changelog --- CHANGELOG | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6fab16ad..a9588b7b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ # nodeGame Changelog +# 6.3.0 +- Fixed installer getting stuck on versions and help. +- Added installer option --no-games to skip installing default games. +- New release. + # 6.2.4 (6.2.1-6.2.3 deprecated) - Fixed "default" option in launcher for Commander v7. - New release, fixed support for images loaded in mainframe. From 4a768af08c29e9c80bdc80bcc569e3df37e0ca3a Mon Sep 17 00:00:00 2001 From: Stefano Balieti Date: Thu, 8 Apr 2021 14:46:35 +0200 Subject: [PATCH 134/155] 6.3.0 --- bin/nodegame-installer.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 720dd10f..ddd51d99 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,7 +41,7 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.2.4' + v6: '6.3.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index ec917fd7..f917fab8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.2.4", + "version": "6.3.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 3d967861e8c81ee42dac74a55e5aca8110a8ef42 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 26 Aug 2021 10:55:59 +0200 Subject: [PATCH 135/155] adding nodeGameRoot in launcher --- launcher.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/launcher.js b/launcher.js index 40e68c94..4a3ed5d5 100644 --- a/launcher.js +++ b/launcher.js @@ -479,6 +479,8 @@ function startServer() { // Add nodeGame version (might be higher than server version) to options. options.nodeGameVersion = version; + options.nodeGameRoot = __dirname; + // Start server, options parameter is optional. sn = new ServerNode(options); From e5afdbaf2f76bffe01ca4e8489fa5decc3c1dd32 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 26 Aug 2021 11:10:52 +0200 Subject: [PATCH 136/155] more robust paths --- launcher.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launcher.js b/launcher.js index 4a3ed5d5..783ff51a 100644 --- a/launcher.js +++ b/launcher.js @@ -61,9 +61,9 @@ ignoredOptions = []; confFile = null; -confDir = './conf'; -logDir = './log'; -gamesDir = './games'; +confDir = path.resolve(__dirname, 'conf'); +logDir = path.resolve(__dirname, 'log'); +gamesDir = path.resolve(__dirname, 'games'); debug = undefined; infoQuery = undefined; From 55f90ebf3a379d8cea0ddcb55e75fc79769eecaa Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 31 Aug 2021 12:11:06 +0200 Subject: [PATCH 137/155] installer support alpha --- bin/nodegame-installer.js | 143 ++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 85 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index ddd51d99..4e768baf 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -33,7 +33,7 @@ const warn = txt => { }; // const MAIN_MODULE = 'nodegame'; -const MAIN_MODULE = 'nodegame'; +let MAIN_MODULE = 'nodegame'; // All stable versions. // Versions below < 3 are not available. @@ -81,6 +81,7 @@ var rl = readline.createInterface({ output: process.stdout }); +var alpha = false; var verbose = false; var nodeModulesExisting = false; var isDev = false; @@ -109,6 +110,13 @@ for (let i = 0; i < process.argv.length; i++) { isDev = true; requestedVersion = '@' + version; + + MAIN_MODULE = 'nodegame-test'; + + version = '7.0.4'; + requestedVersion = '@' + version; + + alpha = true; } else { version = STABLE_VERSIONS[requestedVersion]; @@ -158,7 +166,7 @@ if ((doSSH || branch) && !isDev) { // nodeGame version. const VERSION = isDev ? "v" + version + '-dev' : "v" + version; -const NODEGAME_AND_VERSION = 'nodegame-' + VERSION; +const NODEGAME_AND_VERSION = 'nodegame-' + VERSION + (alpha ? '-alpha' : ''); const ROOT_DIR = process.cwd() const NODE_MODULES_DIR = path.resolve(ROOT_DIR, 'node_modules'); @@ -220,8 +228,8 @@ printInstallInfo(); // Check node version is. var nodeVersion = process.versions.node.split('.'); -if (parseInt(nodeVersion[0], 10) < 4) { - err('node version >= 4.x is required.\n' + +if (parseInt(nodeVersion[0], 10) < 10) { + err('node version >= 10.x is required.\n' + 'Please upgrade your Node.Js installation, ' + 'visit: http://nodejs.org'); installationAborted(); @@ -273,7 +281,7 @@ else checkParentNodeModules(); // Helper functions. /////////////////////////////////////////////////////////////////////////////// -function checkParentNodeModules(cb) { +function checkParentNodeModules() { parentNodeModules = getParentNodeModules(); // Check if a node_modules folder exists in any folder from the one above. @@ -423,10 +431,18 @@ function checkGitExists(cb) { function printNodeGameInfo() { log(); - log('*********************************************** '); - log('** WELCOME TO NODEGAME INSTALLER v' + version + - ' ** '); - log('*********************************************** '); + if (alpha) { + log('***************************************************** '); + log('** WELCOME TO NODEGAME INSTALLER v' + version + + (alpha ? '-alpha' : '') + ' ** '); + log('***************************************************** '); + } + else { + log('*********************************************** '); + log('** WELCOME TO NODEGAME INSTALLER v' + version + ' ** '); + log('*********************************************** '); + } + log(); log('nodeGame: fast, scalable JavaScript for online, large-scale,'); log('multiplayer, real-time games and experiments in the browser.'); @@ -518,18 +534,27 @@ function someMagic(cb) { if (!fs.existsSync(path.resolve(mainNgDir, 'private'))) { fs.mkdirSync(path.resolve(mainNgDir, 'private')); } + if (!fs.existsSync(path.resolve(mainNgDir, 'export'))) { + fs.mkdirSync(path.resolve(mainNgDir, 'export')); + } if (!doNotMoveInstall) { // Move nodegame folder outside node_modules. fs.renameSync(mainNgDir, INSTALL_DIR); - // Old npms put already all modules under nodegame. - if (!fs.existsSync(INSTALL_DIR_MODULES)) { - fs.renameSync(NODE_MODULES_DIR, - INSTALL_DIR_MODULES); + try { + // Old npms put already all modules under nodegame. + if (!fs.existsSync(INSTALL_DIR_MODULES)) { + fs.renameSync(NODE_MODULES_DIR, + INSTALL_DIR_MODULES); + } + else if (!nodeModulesExisting) { + fs.rmdirSync(NODE_MODULES_DIR); + } } - else if (!nodeModulesExisting) { - fs.rmdirSync(NODE_MODULES_DIR); + catch(e) { + let keep = nodeModulesExisting; + moveFolderSync(NODE_MODULES_DIR, INSTALL_DIR_MODULES, keep); } } @@ -630,9 +655,9 @@ function getAllGitModules(cb) { fs.renameSync(nodeModulesCopy, nodeModulesPath); } // Copy pre-commit hook. - copyFileSync(gitPrecommitHook, - path.resolve(modulePath, '.git', 'hooks', - 'pre-commit')); + fs.copyFileSync(gitPrecommitHook, + path.resolve(modulePath, '.git', 'hooks', + 'pre-commit')); counter--; if (counter == 0 && cb) cb(); }); @@ -935,74 +960,22 @@ function inArray(needle, haystack) { return false; } +function moveFolderSync(from, to, copy) { + if (!fs.existsSync(to)) fs.mkdirSync(to); + fs.readdirSync(from).forEach(element => { + let fileFrom = path.join(from, element); + let fileTo = path.join(to, element); -// Kudos. Adapted from: -// https://github.com/coderaiser/ -// fs-copy-file-sync/blob/master/lib/fs-copy-file-sync.js -function _copyFileSync(src, dest, flag) { - const SIZE = 65536; - - const COPYFILE_EXCL = 1; - const COPYFILE_FICLONE = 2; - const COPYFILE_FICLONE_FORCE = 4; - - const constants = { - COPYFILE_EXCL, - COPYFILE_FICLONE, - COPYFILE_FICLONE_FORCE, - }; - - const or = (a, b) => a | b; - const getValue = (obj) => (key) => obj[key]; - - const getMaxMask = (obj) => Object - .keys(obj) - .map(getValue(obj)) - .reduce(or); - - const MAX_MASK = getMaxMask(constants); - const isExcl = (flags) => flags & COPYFILE_EXCL; - - - const writeFlag = isExcl(flag) ? 'wx' : 'w'; - - const { - size, - mode, - } = fs.statSync(src); - - const fdSrc = fs.openSync(src, 'r'); - const fdDest = fs.openSync(dest, writeFlag, mode); - - const length = size < SIZE ? size : SIZE; - - let pos = 0; - const peaceSize = size < SIZE ? 0 : size % SIZE; - const offset = 0; - - let buffer = Buffer.allocUnsafe(length); - for (let i = 0; length + pos + peaceSize <= size; i++, pos = length * i) { - fs.readSync(fdSrc, buffer, offset, length, pos); - fs.writeSync(fdDest, buffer, offset, length, pos); - } - - if (peaceSize) { - const length = peaceSize; - buffer = Buffer.allocUnsafe(length); - fs.readSync(fdSrc, buffer, offset, length, pos); - fs.writeSync(fdDest, buffer, offset, length, pos); - } - - fs.closeSync(fdSrc); - fs.closeSync(fdDest); -} + if (fs.lstatSync(fileFrom).isFile()) { + if (copy) fs.copyFileSync(fileFrom, fileTo); + else fs.renameSync(fileFrom, fileTo); + } + else { + moveFolderSync(fileFrom, fileTo); + } + }); + // ALl files moved, removed dir. + if (!copy) fs.rmdirSync(from); -function copyFileSync(from, to) { - if ('function' === typeof fs.copyFileSync) { - fs.copyFileSync(from, to); - } - else { - _copyFileSync(from, to); - } } From 1d360b56ff9b933bbd8d80dbe1f8153be85704cd Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Tue, 31 Aug 2021 12:19:18 +0200 Subject: [PATCH 138/155] dropped --phantoms --- launcher.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/launcher.js b/launcher.js index 783ff51a..4c9baac7 100644 --- a/launcher.js +++ b/launcher.js @@ -33,9 +33,6 @@ var sn; // ServerNode options. var options; -// Conf file for all variables. -var confFile; - // Other local options. var confDir, logDir, gamesDir, debug, infoQuery, runTests; var nClients, clientType, killServer, auth, wait, port; @@ -59,8 +56,6 @@ ignoredOptions = []; // Defaults. -confFile = null; - confDir = path.resolve(__dirname, 'conf'); logDir = path.resolve(__dirname, 'log'); gamesDir = path.resolve(__dirname, 'games'); @@ -110,7 +105,7 @@ program // Connect phantoms. .option('-p, --phantoms ', - 'Connect phantoms to the specified channel') + 'Connect phantoms to the specified channel **DISCONTINUED**') .option('-n, --nClients ', 'Sets the number of clients phantoms to connect (default: 4)') .option('-t, --clientType ', @@ -132,6 +127,12 @@ program // User options (Commander >= 7). let opts = program.opts(); +if (opts.phantoms) { + console.log('***Err: option --phantoms no longer supported. ' + + 'PhantomJS support discontinued.'); + return false; +} + if (opts.confFile) { if (!fs.existsSync(opts.confFile)) { return printErr('--confFile ' + opts.confFile + ' not found.'); From e5af730fe8ceda1090956dbbf5ff1b6d40e32154 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 10:57:53 +0200 Subject: [PATCH 139/155] 7.0.0 --- CHANGELOG | 8 +++++++- package.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a9588b7b..553e90dc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,11 @@ # nodeGame Changelog +# 7.0.0 +- Dropped --phantoms option in launcher. +- More robust paths in launcher. +- Added nodeGameRoot path in launcher. +- Installer adapted to support alpha releases. + # 6.3.0 - Fixed installer getting stuck on versions and help. - Added installer option --no-games to skip installing default games. @@ -143,7 +149,7 @@ treatment for the game. # 2.0.2 - Fixed install.stable script. -- Fixing launcher options. +- Fixing launcher options. # 2.0.0 (current) - Added -s option to launcher. Starts the server in SSL mode. Can be empty (loads nodegame-server/ssl/), or a path to a SSL directory. diff --git a/package.json b/package.json index f917fab8..816f2b57 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "6.3.0", + "version": "7.0.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 168304851fae299de01cc2f40b708d240a4f720f Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 11:06:03 +0200 Subject: [PATCH 140/155] updated-installer --- bin/nodegame-installer.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 4e768baf..2c0deefe 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -41,13 +41,14 @@ const STABLE_VERSIONS = { v3: '3.5.3', v4: '4.3.3', v5: '5.11.2', - v6: '6.3.0' + v6: '6.3.0', + v7: '7.0.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); // Installer default version. -const INSTALLER_VERSION = 'v6'; +const INSTALLER_VERSION = 'v7'; // If node_modules folders are detected, their paths (without node_modules) // is stored in here. @@ -110,13 +111,11 @@ for (let i = 0; i < process.argv.length; i++) { isDev = true; requestedVersion = '@' + version; - - MAIN_MODULE = 'nodegame-test'; - - version = '7.0.4'; - requestedVersion = '@' + version; - - alpha = true; + // For testing alpha versions. + // MAIN_MODULE = 'nodegame-test'; + // version = '7.0.4'; + // requestedVersion = '@' + version; + // alpha = true; } else { version = STABLE_VERSIONS[requestedVersion]; From 7f7cb19b99852189809d414365d557a07a9d496e Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 11:08:37 +0200 Subject: [PATCH 141/155] updated v7 --- package.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 816f2b57..2fbc1765 100644 --- a/package.json +++ b/package.json @@ -15,19 +15,19 @@ "url": "https://github.com/nodeGame/nodegame.git" }, "engines": { - "node": ">= 6.0.0" + "node": ">= 10.0.0" }, "dependencies": { - "nodegame-server": "^6.0.0", - "nodegame-client": "^6.0.0", - "nodegame-window": "^6.0.0", - "nodegame-widgets": "^6.0.0", - "nodegame-requirements": "^6.0.0", - "nodegame-game-template": "^6.0.0", - "nodegame-monitor": "^6.0.0", - "nodegame-generator": "^6.0.0", - "ultimatum-game": "^6.0.0", - "nodegame-mturk": "^6.0.0", + "nodegame-client": "^7.0.0", + "nodegame-server": "^7.0.0", + "nodegame-window": "^7.0.0", + "nodegame-widgets": "^7.0.0", + "nodegame-requirements": "^7.0.0", + "nodegame-game-template": "^7.0.0", + "nodegame-monitor": "^7.0.0", + "nodegame-generator": "^7.0.0", + "ultimatum-game": "^7.0.0", + "nodegame-mturk": "^7.0.0", "JSUS": "^1.1.0", "NDDB": "^2.0.0", "nodegame-db": "*", From 61cbf8613abb40f15df149cf60c2d722d7efaab6 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 11:09:30 +0200 Subject: [PATCH 142/155] minor --- CHANGELOG | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 553e90dc..89bd5277 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 7.0.0 +# 7.0.1 - Dropped --phantoms option in launcher. - More robust paths in launcher. - Added nodeGameRoot path in launcher. diff --git a/package.json b/package.json index 2fbc1765..6a105396 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "7.0.0", + "version": "7.0.1", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 96fc4fd7af1c538cc0c69f54061931b76a550163 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 11:09:56 +0200 Subject: [PATCH 143/155] 7.0.1 --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 89bd5277..70be548a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ # nodeGame Changelog -# 7.0.1 +# 7.0.0 (.1) - Dropped --phantoms option in launcher. - More robust paths in launcher. - Added nodeGameRoot path in launcher. From 5cd8a91408e8ac0db3907af2bee338aeefd85a02 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 11:10:29 +0200 Subject: [PATCH 144/155] 7.0.1 --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 2c0deefe..ba462d33 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -42,7 +42,7 @@ const STABLE_VERSIONS = { v4: '4.3.3', v5: '5.11.2', v6: '6.3.0', - v7: '7.0.0' + v7: '7.0.1' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From 215916b9475d52d80889a9728a913f8de2231ce4 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 14:33:30 +0200 Subject: [PATCH 145/155] 7.0.2 --- bin/nodegame-installer.js | 3 +-- package.json | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index ba462d33..355c683e 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -458,13 +458,12 @@ function printNodeGameInfo() { } function printInstallInfo() { - let str; log(); log('----------------------------------------------'); log(); log('node version: ' + process.version); - str = 'nodeGame version: ' + VERSION; + let str = 'nodeGame version: ' + VERSION; if (branch) str += ' (' + branch + ')'; log(str); str = 'install directory: ' + INSTALL_DIR; diff --git a/package.json b/package.json index 6a105396..875b573a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "7.0.1", + "version": "7.0.2", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ @@ -29,7 +29,7 @@ "ultimatum-game": "^7.0.0", "nodegame-mturk": "^7.0.0", "JSUS": "^1.1.0", - "NDDB": "^2.0.0", + "NDDB": "^3.0.0", "nodegame-db": "*", "nodegame-mongodb": "*", "commander": "^7.0.0", From 204ed93d97091c92e15071e4061971175b38dbdf Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 14:33:59 +0200 Subject: [PATCH 146/155] minor --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 355c683e..a0696f86 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -42,7 +42,7 @@ const STABLE_VERSIONS = { v4: '4.3.3', v5: '5.11.2', v6: '6.3.0', - v7: '7.0.1' + v7: '7.0.2' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From 944e369049f9134100eecff594bd3721cea5ff2d Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 17:33:43 +0200 Subject: [PATCH 147/155] 7.0.3 --- CHANGELOG | 5 ++++- package.json | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 70be548a..560cfff8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ # nodeGame Changelog -# 7.0.0 (.1) +# 7.0.3 +- Minor, installation fixes. + +# 7.0.0 - Dropped --phantoms option in launcher. - More robust paths in launcher. - Added nodeGameRoot path in launcher. diff --git a/package.json b/package.json index 875b573a..6aba8ee9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "7.0.2", + "version": "7.0.3", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ @@ -18,18 +18,18 @@ "node": ">= 10.0.0" }, "dependencies": { - "nodegame-client": "^7.0.0", - "nodegame-server": "^7.0.0", - "nodegame-window": "^7.0.0", - "nodegame-widgets": "^7.0.0", - "nodegame-requirements": "^7.0.0", - "nodegame-game-template": "^7.0.0", - "nodegame-monitor": "^7.0.0", - "nodegame-generator": "^7.0.0", - "ultimatum-game": "^7.0.0", - "nodegame-mturk": "^7.0.0", - "JSUS": "^1.1.0", - "NDDB": "^3.0.0", + "nodegame-client": ">=7.0.0", + "nodegame-server": ">=7.0.1", + "nodegame-window": ">=7.0.0", + "nodegame-widgets": ">=7.0.0", + "nodegame-requirements": ">=7.0.0", + "nodegame-game-template": ">=7.0.0", + "nodegame-monitor": ">=7.0.0", + "nodegame-generator": ">=7.0.0", + "ultimatum-game": ">=7.0.0", + "nodegame-mturk": ">=7.0.0", + "JSUS": ">=1.1.0", + "NDDB": ">=3.0.0", "nodegame-db": "*", "nodegame-mongodb": "*", "commander": "^7.0.0", From dfacda3b09db0a688844a43eae880fbb01b397c3 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Wed, 20 Oct 2021 17:34:26 +0200 Subject: [PATCH 148/155] installer --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index a0696f86..31093be0 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -42,7 +42,7 @@ const STABLE_VERSIONS = { v4: '4.3.3', v5: '5.11.2', v6: '6.3.0', - v7: '7.0.2' + v7: '7.0.3' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From 96da231ad25fb96278c4a59fd1e7bade9a394ede Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sat, 23 Oct 2021 14:05:54 +0200 Subject: [PATCH 149/155] 7.0.4 --- CHANGELOG | 4 ++++ bin/nodegame-installer.js | 3 ++- launcher.js | 28 ++++++++++++++-------------- package.json | 2 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 560cfff8..d824d290 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # nodeGame Changelog +- 7.0.4 +- Updated installer. +- Minor fixes. + # 7.0.3 - Minor, installation fixes. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 31093be0..aea65496 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -965,7 +965,8 @@ function moveFolderSync(from, to, copy) { let fileFrom = path.join(from, element); let fileTo = path.join(to, element); - if (fs.lstatSync(fileFrom).isFile()) { + let stats = fs.lstatSync(fileFrom); + if (stats.isFile() || stats.isSymbolicLink()) { if (copy) fs.copyFileSync(fileFrom, fileTo); else fs.renameSync(fileFrom, fileTo); } diff --git a/launcher.js b/launcher.js index 4c9baac7..6251ed8e 100644 --- a/launcher.js +++ b/launcher.js @@ -106,20 +106,20 @@ program .option('-p, --phantoms ', 'Connect phantoms to the specified channel **DISCONTINUED**') - .option('-n, --nClients ', - 'Sets the number of clients phantoms to connect (default: 4)') - .option('-t, --clientType ', - 'Sets the client type of connecting phantoms (default: autoplay)') - .option('-T, --runTests', - 'Run tests after all phantoms are game-over ' + - '(overwrites settings.js in test/)') - .option('-k, --killServer', - 'Kill server after all phantoms are game-over') - .option('-a --auth [option]', - 'Phantoms auth options. Values: new(default)|createNew|' + - 'nextAvailable|next|code|id:code&pwd:password|file:path/to/file.') - .option('-w --wait [milliseconds]', - 'Waits before connecting the next phantom. Default: 1000') + // .option('-n, --nClients ', + // 'Sets the number of clients phantoms to connect (default: 4)') + // .option('-t, --clientType ', + // 'Sets the client type of connecting phantoms (default: autoplay)') + // .option('-T, --runTests', + // 'Run tests after all phantoms are game-over ' + + // '(overwrites settings.js in test/)') + // .option('-k, --killServer', + // 'Kill server after all phantoms are game-over') + // .option('-a --auth [option]', + // 'Phantoms auth options. Values: new(default)|createNew|' + + // 'nextAvailable|next|code|id:code&pwd:password|file:path/to/file.') + // .option('-w --wait [milliseconds]', + // 'Waits before connecting the next phantom. Default: 1000') .parse(process.argv); diff --git a/package.json b/package.json index 6aba8ee9..3876f4d5 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "nodegame-client": ">=7.0.0", - "nodegame-server": ">=7.0.1", + "nodegame-server": ">=7.0.2", "nodegame-window": ">=7.0.0", "nodegame-widgets": ">=7.0.0", "nodegame-requirements": ">=7.0.0", From f07fe60d4df97d7e269a12467306ab90f483b0cd Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sat, 23 Oct 2021 14:06:25 +0200 Subject: [PATCH 150/155] minor --- bin/nodegame-installer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index aea65496..fa76c752 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -42,7 +42,7 @@ const STABLE_VERSIONS = { v4: '4.3.3', v5: '5.11.2', v6: '6.3.0', - v7: '7.0.3' + v7: '7.0.4' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); From a54cbd3260403ee2ddd01b4784bb329abaf4e7bf Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sat, 23 Oct 2021 14:06:50 +0200 Subject: [PATCH 151/155] 7.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3876f4d5..b58feb7a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "7.0.3", + "version": "7.0.4", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From 0e567027706ad3ea2a94a107c4309295f9ffe45e Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sat, 6 Nov 2021 23:22:40 +0100 Subject: [PATCH 152/155] 7.1.0 --- CHANGELOG | 5 ++++- bin/nodegame-installer.js | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d824d290..c0f95498 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ # nodeGame Changelog -- 7.0.4 +# 7.1.0 +- New release, updated installer. + +# 7.0.4 - Updated installer. - Minor fixes. diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index fa76c752..eb568ccb 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -42,7 +42,7 @@ const STABLE_VERSIONS = { v4: '4.3.3', v5: '5.11.2', v6: '6.3.0', - v7: '7.0.4' + v7: '7.1.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); diff --git a/package.json b/package.json index b58feb7a..f11d9d6e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegame", "description": "Fast, scalable JavaScript for large-scale, online, multiplayer, real-time games and experiments.", - "version": "7.0.4", + "version": "7.1.0", "homepage": "http://nodegame.org", "author": "Stefano Balietti ", "contributors": [ From a172fd0a2b9e9187b4db3400ffbf0ca2d7905608 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Sat, 6 Nov 2021 23:27:21 +0100 Subject: [PATCH 153/155] minor --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f11d9d6e..a912f1f5 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,10 @@ "node": ">= 10.0.0" }, "dependencies": { - "nodegame-client": ">=7.0.0", - "nodegame-server": ">=7.0.2", + "nodegame-client": ">=7.1.0", + "nodegame-server": ">=7.0.3", "nodegame-window": ">=7.0.0", - "nodegame-widgets": ">=7.0.0", + "nodegame-widgets": ">=7.0.2", "nodegame-requirements": ">=7.0.0", "nodegame-game-template": ">=7.0.0", "nodegame-monitor": ">=7.0.0", @@ -29,7 +29,7 @@ "ultimatum-game": ">=7.0.0", "nodegame-mturk": ">=7.0.0", "JSUS": ">=1.1.0", - "NDDB": ">=3.0.0", + "NDDB": ">=3.0.2", "nodegame-db": "*", "nodegame-mongodb": "*", "commander": "^7.0.0", From a17c69576a2e7d5d3c86e1d36ec5fb81cf7cd580 Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 21 Sep 2023 16:49:52 +0200 Subject: [PATCH 154/155] updating installer --- bin/nodegame-installer.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index eb568ccb..23ac717e 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -1,7 +1,7 @@ #!/usr/local/bin/node /** * # nodeGame Installer - * Copyright(c) 2011-2020 Stefano Balietti + * Copyright(c) 2011-2023 Stefano Balietti * MIT Licensed * * http://www.nodegame.org @@ -43,6 +43,7 @@ const STABLE_VERSIONS = { v5: '5.11.2', v6: '6.3.0', v7: '7.1.0' + // v8: '8.0.0' }; const AVAILABLE_VERSIONS = Object.keys(STABLE_VERSIONS).concat(['dev']); @@ -117,6 +118,13 @@ for (let i = 0; i < process.argv.length; i++) { // requestedVersion = '@' + version; // alpha = true; } + else if (requestedVersion === 'alpha') { + // For testing alpha versions. + isDev = true; + MAIN_MODULE = 'nodegame-test'; + requestedVersion = '@latest'; + alpha = true; + } else { version = STABLE_VERSIONS[requestedVersion]; if (!version) { From 8e0945c8036fe8fc7fe00157394a5466baf1eebd Mon Sep 17 00:00:00 2001 From: Stefano Balietti Date: Thu, 21 Sep 2023 16:51:44 +0200 Subject: [PATCH 155/155] minor --- bin/nodegame-installer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/nodegame-installer.js b/bin/nodegame-installer.js index 23ac717e..91c0cfbf 100755 --- a/bin/nodegame-installer.js +++ b/bin/nodegame-installer.js @@ -120,7 +120,6 @@ for (let i = 0; i < process.argv.length; i++) { } else if (requestedVersion === 'alpha') { // For testing alpha versions. - isDev = true; MAIN_MODULE = 'nodegame-test'; requestedVersion = '@latest'; alpha = true;