Commit 5323741d by Alexander Bazo

Merge branch 'dev' into 'master'

Update build system

See merge request !3
parents 004593f6 91d05c72
...@@ -3,3 +3,6 @@ node_modules ...@@ -3,3 +3,6 @@ node_modules
# dependencies # dependencies
vendors/ vendors/
# build
build/
\ No newline at end of file
# Star Gazer # Star Gazer
## Usage StarGazer is a multiplayer game using gaze data as an input source. This demo showcases the eye tracking classroom's abilities to utilize gaze based real time collaboration.
Run `npm install` to install dependencies and `npm start` to run the game. ## Requirements
\ No newline at end of file
To play the game using gaze data for input a local [gaze-server](https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-server.cs) must be running at `ws://localhost:8001`.
## Playing
Hosted versions of the game are available here:
- [Release version](https://regensburger-forscher.de/stargazer/game/)
- [Beta version](https://regensburger-forscher.de/stargazer/game/)
## Building and Testing
- Run `npm install` to install dependencies and build game to `build/`
- Run `npm start` to run the game on a local test server
\ No newline at end of file
#!/usr/bin/env node
/* eslint-env node */
/* eslint-disable no-console */
// Build deployable version to TARGET_DIR
const fs = require("fs-extra"),
https = require("https"),
TARGET_DIR = "build/",
CONFIG_FILE = "build/resources/js/Config.js",
VERSION_PLACEHOLDER = "$VERSION",
version = require("./package.json").version,
fileList = [{
url: "https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-client.js/raw/master/build/gazeclient.js",
localPath: "build/vendors/gazeclient.js",
},
{
url: "https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-client.js/raw/master/build/gazeclient.js.map",
localPath: "build/vendors/gazeclient.js.map",
},
{
url: "https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-client.js/raw/master/build/gazeclient.min.js",
localPath: "build/vendors/gazeclient.min.js",
},
];
function run() {
createTargetDir();
downloadLibrary();
copyFiles();
insertVersionNumber();
}
function onError(error) {
console.log(error);
}
function createTargetDir() {
console.log(`Ensure target directory [${TARGET_DIR}] exists and is empty`);
fs.ensureDirSync(TARGET_DIR);
fs.emptyDirSync(TARGET_DIR);
}
function downloadLibrary() {
console.log(`Downloading client library (${fileList.length} files]`);
let vendorsFolder = `${TARGET_DIR}vendors`;
fs.ensureDirSync(vendorsFolder);
for (let i = 0; i < fileList.length; i++) {
let file = fileList[i];
downloadFile(file.url, file.localPath);
}
}
function downloadFile(source, target) {
let file;
console.log(`Downloading [${source}] to ${target}`);
file = fs.createWriteStream(target);
https.get(source, function(response) {
response.pipe(file);
});
}
function copyFiles() {
console.log(`Copying files to ${TARGET_DIR}`);
fs.copySync("resources/", `${TARGET_DIR}resources`);
fs.copySync("index.html", `${TARGET_DIR}index.html`);
}
function insertVersionNumber() {
console.log(`Replacing version placeholder in ${CONFIG_FILE}`);
let result;
fs.readFile(CONFIG_FILE, "utf8", function(err, data) {
if (err) {
onError(err);
}
result = data.replace(VERSION_PLACEHOLDER, version);
fs.writeFile(CONFIG_FILE, result, "utf8", function(err) {
if (err) {
onError(err);
}
});
});
}
run();
\ No newline at end of file
/* eslint-env node */
// Downloads gaze client library from https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-client.js
const https = require("https"),
fs = require("fs"),
fileList = [{
url: "https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-client.js/raw/master/build/gazeclient.js",
localPath: "vendors/gazeclient.js",
},
{
url: "https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-client.js/raw/master/build/gazeclient.js.map",
localPath: "vendors/gazeclient.js.map",
},
{
url: "https://lab.las3.de/gitlab/eye-tracking-classroom/gaze-client.js/raw/master/build/gazeclient.min.js",
localPath: "vendors/gazeclient.min.js",
},
];
function downloadFile(source, target) {
let file = fs.createWriteStream(target);
https.get(source, function(response) {
response.pipe(file);
});
}
// Make sure vendors folder exists
if (!fs.existsSync("vendors")){
fs.mkdirSync("vendors");
}
// Download all file
for (let i = 0; i < fileList.length; i++) {
let file = fileList[i];
downloadFile(file.url, file.localPath);
}
\ No newline at end of file
{ {
"name": "stargazer", "name": "stargazer",
"version": "1.0.0", "version": "0.1.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
...@@ -51,6 +51,21 @@ ...@@ -51,6 +51,21 @@
"debug": "^3.2.6" "debug": "^3.2.6"
} }
}, },
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"graceful-fs": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz",
"integrity": "sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q=="
},
"he": { "he": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
...@@ -81,6 +96,14 @@ ...@@ -81,6 +96,14 @@
"union": "~0.4.3" "union": "~0.4.3"
} }
}, },
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"requires": {
"graceful-fs": "^4.1.6"
}
},
"mime": { "mime": {
"version": "1.6.0", "version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
...@@ -175,6 +198,11 @@ ...@@ -175,6 +198,11 @@
"qs": "~2.3.3" "qs": "~2.3.3"
} }
}, },
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
},
"url-join": { "url-join": {
"version": "2.0.5", "version": "2.0.5",
"resolved": "https://registry.npmjs.org/url-join/-/url-join-2.0.5.tgz", "resolved": "https://registry.npmjs.org/url-join/-/url-join-2.0.5.tgz",
......
{ {
"name": "stargazer", "name": "stargazer",
"version": "1.0.0", "version": "0.1.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "node get-gaze-client.js", "postinstall": "node build.js",
"start": "http-server -o" "start": "http-server ./build -o"
}, },
"author": "Alexander Bazo <alexanderbazo@googlemail.com>", "author": "Alexander Bazo <alexanderbazo@googlemail.com>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"fs-extra": "^8.1.0",
"http-server": "^0.11.1" "http-server": "^0.11.1"
} }
} }
...@@ -3,7 +3,7 @@ var Config = { ...@@ -3,7 +3,7 @@ var Config = {
TARGET_FPS: 60, TARGET_FPS: 60,
SCREEN_WIDTH: screen.width, SCREEN_WIDTH: screen.width,
SCREEN_HEIGHT: screen.height, SCREEN_HEIGHT: screen.height,
GAME_VERSION: 0.1, GAME_VERSION: "$VERSION",
}; };
Object.freeze(Config); Object.freeze(Config);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment