Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Commit

Permalink
Updating to latest Phaser version
Browse files Browse the repository at this point in the history
- install script removes our deps
- prettier output
  • Loading branch information
cloakedninjas committed Aug 18, 2016
1 parent fa649b3 commit 8c65243
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 25 deletions.
124 changes: 109 additions & 15 deletions bin/install.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
#!/usr/bin/env node

var exec = require('child_process').exec,
fs = require('fs');
var fs = require('fs'),
util = require('util'),
spawn = require('child_process').spawn,
npmInstall = spawn('npm', ['install']);

console.log('Installing npm dependencies...');
console.log(styleText('Beginning Installtion Process'));
console.log('=============================');
console.log(styleText('Installing npm dependencies...'));

exec('npm install', function (error) {
if (!error) {
console.log('Installing bower dependencies...');
exec('bower install', function (error) {
if (!error) {
npmInstall.stdout.on('data', function (data) {
pipeOutput(data);
});

npmInstall.stderr.on('data', function (data) {
pipeOutput(data);
});

npmInstall.on('exit', function (code) {
if (code === 0) {
console.log(styleText('Installing bower dependencies...'));

var bowerInstall = spawn('bower', ['install']);

bowerInstall.stdout.on('data', function (data) {
pipeOutput(data);
});

bowerInstall.stderr.on('data', function (data) {
pipeOutput(data);
});

bowerInstall.on('exit', function (code) {
if (code === 0) {
promptForNamespace();
}
else {
console.error(styleText('Failed to install bower dependencies', 'red'));
}
});
}
else {
console.error(styleText('Failed to install npm dependencies', 'red'));
}

});

function promptForNamespace() {
Expand All @@ -26,7 +56,7 @@ function promptForNamespace() {

prompt.get([{
name: 'namespace',
description: 'What will your namespace be?'.green,
description: 'What will your namespace be?',
type: 'string',
required: true
}], function (err, result) {
Expand Down Expand Up @@ -71,26 +101,90 @@ function promptForCleanup() {

prompt.get([{
name: 'cleanup',
description: 'Initialize Git? (Y / N)'.green,
description: 'Initialize Git? (Y / N)',
type: 'string',
default: 'Y',
required: true
}], function (err, result) {
if (!err && (result.cleanup === 'Y' || result.cleanup === 'y')) {
cleanup();
cleanupGit();
}
else {
cleanupNode();
}
});
}

function cleanup() {
function cleanupGit() {
var rmrf = require('rimraf');

rmrf('.git', function (error) {
if (!error) {
exec('git init', function () {
console.log('Git initialized.');
console.log('Tip: You might want to adjust bower.json + package.json');
gitInit = spawn('git', ['init']);

gitInit.stdout.on('data', function (data) {
pipeOutput(data);
});

gitInit.stderr.on('data', function (data) {
pipeOutput(data);
});

gitInit.on('exit', function () {
cleanupNode();
});
}
});
}

function cleanupNode() {
var packageJson = require('../package.json'),
npmRm = spawn('npm', ['rm', '-D'].concat(Object.keys(packageJson.devDependencies)));

console.log(styleText('Removing build dependencies...'));

npmRm.stdout.on('data', function (data) {
pipeOutput(data);
});

npmRm.stderr.on('data', function (data) {
pipeOutput(data);
});

npmRm.on('exit', function () {
cleanupBin();
});
}

function cleanupBin() {
var exec = require('child_process').exec;

exec('rm bin/* && rmdir bin/', function () {
showInstallSuccess();
});
}

function showInstallSuccess() {
console.log('==============================');
console.log(styleText('Install completed successfully') + '\n');
console.log('It is recommended to run: `npm init && bower init` to define your own package settings');
console.log('==============================');
}

function pipeOutput(data) {
process.stdout.write(data.toString());
}

function styleText(text, colour) {
if (!colour) {
colour = 'green';
}

var colours = {
green: 32,
red: 31
},
c = colours[colour];

return '\u001b[' + c + 'm' + text + '\u001b[39m';
}
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phaser-typescript-boilerplate",
"version": "1.2.0",
"version": "1.3.0",
"homepage": "https://github.com/cloakedninjas/phaser-typescript-boilerplate",
"authors": [
"cloakedninjas <[email protected]>"
Expand All @@ -23,6 +23,6 @@
"tests"
],
"dependencies": {
"phaser": "~2.4.4"
"phaser": "~2.6.1"
}
}
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phaser-typescript-boilerplate",
"version": "1.2.0",
"version": "1.3.0",
"description": "Boilerplate for Phaser using Typescript",
"main": "index.js",
"scripts": {
Expand All @@ -17,14 +17,14 @@
},
"homepage": "https://github.com/cloakedninjas/phaser-typescript-boilerplate#readme",
"dependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.7.0",
"grunt-contrib-copy": "^0.8.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-ts": "^5.2.0"
"grunt": "^1.0.1",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-ts": "^5.5.1"
},
"devDependencies": {
"prompt": "^0.2.14",
"rimraf": "^2.5.1"
"prompt": "^1.0.0",
"rimraf": "^2.5.4"
}
}

0 comments on commit 8c65243

Please sign in to comment.