Merge pull request #6811 from crookedneighbor/upgrade_babel

chore: upgrade babel to v6
This commit is contained in:
Blade Barringer
2016-03-04 08:36:08 -06:00
55 changed files with 132 additions and 101 deletions

4
.babelrc Normal file
View File

@@ -0,0 +1,4 @@
{
"presets": ["es2015"],
"plugins": ["syntax-async-functions","transform-regenerator"]
}

2
.gitignore vendored
View File

@@ -1,6 +1,8 @@
.DS_Store .DS_Store
website/public/gen website/public/gen
website/public/common website/public/common
website/transpiled-babel/
common/transpiled-babel/
node_modules node_modules
*.swp *.swp
.idea* .idea*

View File

@@ -1,5 +1,5 @@
/*global module:false*/ /*global module:false*/
require('babel-core/register'); require('babel-register');
var _ = require('lodash'); var _ = require('lodash');
module.exports = function(grunt) { module.exports = function(grunt) {

View File

@@ -1 +1 @@
web: node ./website/src/server.js web: node ./website/transpiled-babel/server.js

7
common/browserify.js Normal file
View File

@@ -0,0 +1,7 @@
var shared = require('./script/index');
var _ = require('lodash');
var moment = require('moment');
window.habitrpgShared = shared;
window._ = _;
window.moment = moment;

View File

@@ -1,9 +1,9 @@
module.exports = require('./script/index'); var pathToCommon;
var _ = require('lodash');
var moment = require('moment');
if (typeof window !== 'undefined') { if (process.env.NODE_ENV === 'production') {
window.habitrpgShared = module.exports; pathToCommon = './transpiled-babel/index';
window._ = _; } else {
window.moment = moment; pathToCommon = './script/index';
} }
module.exports = require(pathToCommon);

View File

@@ -1,5 +1,5 @@
import {forOwn} from 'lodash'; import {forOwn} from 'lodash';
let t = require('../translation.js'); import t from '../translation';
/* eslint-disable camelcase */ /* eslint-disable camelcase */
let backgrounds = { let backgrounds = {
@@ -320,4 +320,4 @@ forOwn(backgrounds, function prefillBackgroundSet (value) {
}); });
}); });
export default backgrounds; module.exports = backgrounds;

View File

@@ -1,6 +1,6 @@
import prefill from '../prefill.js'; import prefill from '../prefill.js';
export default prefill({ module.exports = prefill({
0: {}, 0: {},
1: {}, 1: {},
2: {}, 2: {},

View File

@@ -1,6 +1,7 @@
import prefill from '../prefill.js'; import prefill from '../prefill.js';
import sets from '../sets.js'; import sets from '../sets.js';
export default prefill({
module.exports = prefill({
0: {}, 0: {},
1: {}, 1: {},
2: {price: 2, set: sets.baseHair1}, 2: {price: 2, set: sets.baseHair1},

View File

@@ -1,7 +1,7 @@
import sets from '../sets.js'; import sets from '../sets.js';
import prefill from '../prefill.js'; import prefill from '../prefill.js';
export default prefill({ module.exports = prefill({
0: {}, 0: {},
1: {price: 2, set: sets.facialHair}, 1: {price: 2, set: sets.facialHair},
2: {price: 2, set: sets.facialHair}, 2: {price: 2, set: sets.facialHair},

View File

@@ -1,7 +1,7 @@
import sets from '../sets.js'; import sets from '../sets.js';
import prefill from '../prefill.js'; import prefill from '../prefill.js';
export default prefill({ module.exports = prefill({
white: {}, white: {},
brown: {}, brown: {},
blond: {}, blond: {},

View File

@@ -1,6 +1,6 @@
import prefill from '../prefill.js'; import prefill from '../prefill.js';
export default prefill({ module.exports = prefill({
0: {}, 0: {},
1: {}, 1: {},
2: {}, 2: {},

View File

@@ -5,7 +5,7 @@ import color from './color.js';
import flower from './flower.js'; import flower from './flower.js';
import mustache from './mustache.js'; import mustache from './mustache.js';
export default { module.exports = {
color, color,
base, base,
bangs, bangs,

View File

@@ -1,7 +1,7 @@
import sets from '../sets.js'; import sets from '../sets.js';
import prefill from '../prefill.js'; import prefill from '../prefill.js';
export default prefill({ module.exports = prefill({
0: {}, 0: {},
1: {price: 2, set: sets.facialHair}, 1: {price: 2, set: sets.facialHair},
2: {price: 2, set: sets.facialHair}, 2: {price: 2, set: sets.facialHair},

View File

@@ -1,6 +1,6 @@
import {forOwn} from 'lodash'; import {forOwn} from 'lodash';
export default function prefillAppearances (obj) { module.exports = function prefillAppearances (obj) {
forOwn(obj, function prefillAppearance (value, key) { forOwn(obj, function prefillAppearance (value, key) {
value.key = key; value.key = key;
if (!value.price) { if (!value.price) {
@@ -8,4 +8,4 @@ export default function prefillAppearances (obj) {
} }
}); });
return obj; return obj;
} };

View File

@@ -1,7 +1,7 @@
import t from '../translation'; import t from '../translation';
import prefill from './prefill.js'; import prefill from './prefill.js';
export default prefill({ module.exports = prefill({
baseHair1: {setPrice: 5, text: t('hairSet1')}, baseHair1: {setPrice: 5, text: t('hairSet1')},
baseHair2: {setPrice: 5, text: t('hairSet2')}, baseHair2: {setPrice: 5, text: t('hairSet2')},
facialHair: {setPrice: 5, text: t('bodyFacialHair')}, facialHair: {setPrice: 5, text: t('bodyFacialHair')},

View File

@@ -1,7 +1,7 @@
import sets from './sets.js'; import sets from './sets.js';
import prefill from './prefill.js'; import prefill from './prefill.js';
export default prefill({ module.exports = prefill({
black: {}, black: {},
blue: {}, blue: {},
green: {}, green: {},

View File

@@ -1,6 +1,6 @@
import prefill from './prefill.js'; import prefill from './prefill.js';
export default prefill({ module.exports = prefill({
slim: {}, slim: {},
broad: {}, broad: {},
}); });

View File

@@ -1,7 +1,7 @@
import prefill from './prefill.js'; import prefill from './prefill.js';
import sets from './sets.js'; import sets from './sets.js';
export default prefill({ module.exports = prefill({
/* eslint-disable quote-props */ /* eslint-disable quote-props */
'ddc994': {}, 'ddc994': {},
'f5a76e': {}, 'f5a76e': {},

View File

@@ -1,10 +1,8 @@
let t = require('./translation.js'); import t from './translation';
let NUMBER_OF_QUESTIONS = 12; const NUMBER_OF_QUESTIONS = 12;
let faq = {}; export const questions = [];
faq.questions = [];
for (let i = 0; i <= NUMBER_OF_QUESTIONS; i++) { for (let i = 0; i <= NUMBER_OF_QUESTIONS; i++) {
let question = { let question = {
@@ -13,12 +11,10 @@ for (let i = 0; i <= NUMBER_OF_QUESTIONS; i++) {
web: t(`webFaqAnswer${i}`), web: t(`webFaqAnswer${i}`),
}; };
faq.questions.push(question); questions.push(question);
} }
faq.stillNeedHelp = { export const stillNeedHelp = {
ios: t('iosFaqStillNeedHelp'), ios: t('iosFaqStillNeedHelp'),
web: t('webFaqStillNeedHelp'), web: t('webFaqStillNeedHelp'),
}; };
module.exports = faq;

View File

@@ -22,4 +22,4 @@ let armor = {
armoire: armoireArmor, armoire: armoireArmor,
}; };
export default armor; module.exports = armor;

View File

@@ -9,5 +9,5 @@ let back = {
special: specialBack, special: specialBack,
}; };
export default back; module.exports = back;

View File

@@ -7,5 +7,5 @@ let body = {
special: specialBody, special: specialBody,
}; };
export default body; module.exports = body;

View File

@@ -11,4 +11,4 @@ let eyewear = {
armoire: armoireEyewear, armoire: armoireEyewear,
}; };
export default eyewear; module.exports = eyewear;

View File

@@ -9,5 +9,5 @@ let headAccessory = {
mystery: mysteryHeadAccessory, mystery: mysteryHeadAccessory,
}; };
export default headAccessory; module.exports = headAccessory;

View File

@@ -22,4 +22,4 @@ let head = {
armoire: armoireHead, armoire: armoireHead,
}; };
export default head; module.exports = head;

View File

@@ -78,7 +78,7 @@ each(GEAR_TYPES, (type) => {
}); });
}); });
export default { module.exports = {
tree: gear, tree: gear,
flat, flat,
}; };

View File

@@ -495,4 +495,4 @@ let armoireSet = {
weapon, weapon,
}; };
export default armoireSet; module.exports = armoireSet;

View File

@@ -77,4 +77,4 @@ let baseSet = {
weapon, weapon,
}; };
export default baseSet; module.exports = baseSet;

View File

@@ -155,4 +155,4 @@ let healerSet = {
weapon, weapon,
}; };
export default healerSet; module.exports = healerSet;

View File

@@ -385,4 +385,4 @@ let mysterySet = {
weapon, weapon,
}; };
export default mysterySet; module.exports = mysterySet;

View File

@@ -167,4 +167,4 @@ let rogueSet = {
weapon, weapon,
}; };
export default rogueSet; module.exports = rogueSet;

View File

@@ -1534,4 +1534,4 @@ let specialSet = {
weapon, weapon,
}; };
export default specialSet; module.exports = specialSet;

View File

@@ -90,4 +90,4 @@ let backerSet = {
weaponSpecial3, weaponSpecial3,
}; };
export default backerSet; module.exports = backerSet;

View File

@@ -76,4 +76,4 @@ let contributorSet = {
weaponSpecialCritical, weaponSpecialCritical,
}; };
export default contributorSet; module.exports = contributorSet;

View File

@@ -59,4 +59,4 @@ let wonderconSet = {
eyewearSpecialWonderconBlack, eyewearSpecialWonderconBlack,
}; };
export default wonderconSet; module.exports = wonderconSet;

View File

@@ -152,4 +152,4 @@ let warriorSet = {
weapon, weapon,
}; };
export default warriorSet; module.exports = warriorSet;

View File

@@ -138,4 +138,4 @@ let wizardSet = {
weapon, weapon,
}; };
export default wizardSet; module.exports = wizardSet;

View File

@@ -26,4 +26,4 @@ let shield = {
armoire: armoireShield, armoire: armoireShield,
}; };
export default shield; module.exports = shield;

View File

@@ -22,4 +22,4 @@ let weapon = {
armoire: armoireWeapon, armoire: armoireWeapon,
}; };
export default weapon; module.exports = weapon;

View File

@@ -1,12 +1,6 @@
var _, api, calculateBonus, diminishingReturns, moment, t; import _ from 'lodash';
import moment from 'moment';
api = module.exports; import t from './translation';
_ = require('lodash');
moment = require('moment');
t = require('./translation.js');
import { import {
CLASSES, CLASSES,
@@ -16,6 +10,8 @@ import {
USER_CAN_OWN_QUEST_CATEGORIES, USER_CAN_OWN_QUEST_CATEGORIES,
} from './constants'; } from './constants';
let api = module.exports;
import mysterySets from './mystery-sets'; import mysterySets from './mystery-sets';
import gear from './gear'; import gear from './gear';
@@ -23,6 +19,7 @@ import gear from './gear';
import appearances from './appearance'; import appearances from './appearance';
import backgrounds from './appearance/backgrounds.js' import backgrounds from './appearance/backgrounds.js'
import spells from './spells'; import spells from './spells';
import faq from './faq';
api.mystery = mysterySets; api.mystery = mysterySets;
@@ -32,8 +29,8 @@ api.gear = gear;
api.spells = spells; api.spells = spells;
/* /*
Time Traveler Store, mystery sets need their items mapped in Time Traveler Store, mystery sets need their items mapped in
*/ */
_.each(api.mystery, function(v, k) { _.each(api.mystery, function(v, k) {
return v.items = _.where(api.gear.flat, { return v.items = _.where(api.gear.flat, {
@@ -55,10 +52,10 @@ api.timeTravelerStore = function(owned) {
/* /*
--------------------------------------------------------------- ---------------------------------------------------------------
Unique Rewards: Potion and Armoire Unique Rewards: Potion and Armoire
--------------------------------------------------------------- ---------------------------------------------------------------
*/ */
api.potion = { api.potion = {
type: 'potion', type: 'potion',
@@ -89,7 +86,7 @@ api.armoire = {
--------------------------------------------------------------- ---------------------------------------------------------------
Classes Classes
--------------------------------------------------------------- ---------------------------------------------------------------
*/ */
api.classes = CLASSES; api.classes = CLASSES;
@@ -98,7 +95,7 @@ api.classes = CLASSES;
--------------------------------------------------------------- ---------------------------------------------------------------
Gear Types Gear Types
--------------------------------------------------------------- ---------------------------------------------------------------
*/ */
api.gearTypes = GEAR_TYPES; api.gearTypes = GEAR_TYPES;
@@ -2606,4 +2603,4 @@ api.userDefaults = {
] ]
}; };
api.faq = require('./faq.js'); api.faq = faq;

View File

@@ -1,5 +1,5 @@
import { each } from 'lodash'; import { each } from 'lodash';
let t = require('./translation.js'); import t from './translation';
let mysterySets = { let mysterySets = {
201402: { 201402: {
@@ -122,4 +122,4 @@ each(mysterySets, (value, key) => {
value.text = t(`mysterySet${key}`); value.text = t(`mysterySet${key}`);
}); });
export default mysterySets; module.exports = mysterySets;

View File

@@ -506,4 +506,4 @@ _.each(spells, (spellClass) => {
}); });
}); });
export default spells; module.exports = spells;

View File

@@ -1,6 +1,6 @@
import i18n from '../i18n'; import i18n from '../i18n';
export default function translator (string, vars = { a: 'a' }) { module.exports = function translator (string, vars = { a: 'a' }) {
function func (lang) { function func (lang) {
return i18n.t(string, vars, lang); return i18n.t(string, vars, lang);
} }
@@ -8,4 +8,4 @@ export default function translator (string, vars = { a: 'a' }) {
func.i18nLangFunc = true; // Trick to recognize this type of function func.i18nLangFunc = true; // Trick to recognize this type of function
return func; return func;
} };

View File

@@ -67,7 +67,7 @@ function questsOfCategory (userQuests, category) {
return count; return count;
} }
export default { module.exports = {
beastMasterProgress, beastMasterProgress,
dropPetsCurrentlyOwned, dropPetsCurrentlyOwned,
mountMasterProgress, mountMasterProgress,

View File

@@ -60,4 +60,4 @@ function t (stringName) {
} }
} }
export default i18n; module.exports = i18n;

View File

@@ -1,7 +1,10 @@
import moment from 'moment';
import _ from 'lodash';
import { import {
daysSince, daysSince,
shouldDo, shouldDo,
} from '../../common/script/cron'; } from './cron';
import { import {
MAX_HEALTH, MAX_HEALTH,
MAX_LEVEL, MAX_LEVEL,
@@ -9,18 +12,13 @@ import {
} from './constants'; } from './constants';
import * as statHelpers from './statHelpers'; import * as statHelpers from './statHelpers';
var $w, _, api, content, i18n, preenHistory, moment, sortOrder, var $w, preenHistory, sortOrder,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
moment = require('moment'); import content from './content/index';
import i18n from './i18n';
_ = require('lodash'); let api = module.exports = {};
content = require('./content/index');
i18n = require('./i18n');
api = module.exports = {};
api.i18n = i18n; api.i18n = i18n;
api.shouldDo = shouldDo; api.shouldDo = shouldDo;
@@ -471,7 +469,8 @@ api.appliedTags = function(userTags, taskTags) {
Various counting functions Various counting functions
*/ */
api.count = require('./count'); import count from './count';
api.count = count;
/* /*

View File

@@ -6,7 +6,7 @@
* directory, and it will automatically be included. * directory, and it will automatically be included.
*/ */
require('babel-core/register'); require('babel-register');
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
require('./tasks/gulp-newstuff'); require('./tasks/gulp-newstuff');

View File

@@ -9,8 +9,12 @@
"amplitude": "^2.0.3", "amplitude": "^2.0.3",
"async": "~0.9.0", "async": "~0.9.0",
"aws-sdk": "^2.0.25", "aws-sdk": "^2.0.25",
"babel-core": "^5.8.34", "babel-plugin-syntax-async-functions": "^6.5.0",
"babelify": "^6.x.x", "babel-plugin-transform-regenerator": "^6.6.0",
"babel-polyfill": "^6.6.1",
"babel-preset-es2015": "^6.6.0",
"babel-register": "^6.6.0",
"babelify": "^7.2.0",
"bower": "~1.3.12", "bower": "~1.3.12",
"browserify": "~12.0.1", "browserify": "~12.0.1",
"connect-ratelimit": "0.0.7", "connect-ratelimit": "0.0.7",
@@ -32,6 +36,7 @@
"grunt-hashres": "~0.4.1", "grunt-hashres": "~0.4.1",
"grunt-karma": "~0.12.1", "grunt-karma": "~0.12.1",
"gulp": "^3.9.0", "gulp": "^3.9.0",
"gulp-babel": "^6.1.2",
"gulp-eslint": "^1.0.0", "gulp-eslint": "^1.0.0",
"gulp-grunt": "^0.5.2", "gulp-grunt": "^0.5.2",
"gulp-imagemin": "^2.3.0", "gulp-imagemin": "^2.3.0",
@@ -103,7 +108,7 @@
"coverage": "COVERAGE=true mocha --require register-handlers.js --reporter html-cov > coverage.html; open coverage.html" "coverage": "COVERAGE=true mocha --require register-handlers.js --reporter html-cov > coverage.html; open coverage.html"
}, },
"devDependencies": { "devDependencies": {
"babel-eslint": "^4.1.6", "babel-eslint": "^5.0.0",
"chai": "^3.4.0", "chai": "^3.4.0",
"chai-as-promised": "^5.1.0", "chai-as-promised": "^5.1.0",
"coveralls": "^2.11.2", "coveralls": "^2.11.2",
@@ -116,7 +121,7 @@
"expect.js": "~0.2.0", "expect.js": "~0.2.0",
"istanbul": "^0.3.14", "istanbul": "^0.3.14",
"karma": "~0.13.15", "karma": "~0.13.15",
"karma-babel-preprocessor": "^5.0.0", "karma-babel-preprocessor": "^6.0.1",
"karma-chai-plugins": "~0.6.0", "karma-chai-plugins": "~0.6.0",
"karma-coverage": "^0.5.3", "karma-coverage": "^0.5.3",
"karma-mocha": "^0.2.0", "karma-mocha": "^0.2.0",

View File

@@ -8,7 +8,7 @@ import babel from 'babelify';
gulp.task('browserify', function () { gulp.task('browserify', function () {
let bundler = browserify({ let bundler = browserify({
entries: './common/index.js', entries: './common/browserify.js',
debug: true, debug: true,
transform: [[babel, { compact: false }]], transform: [[babel, { compact: false }]],
}); });

View File

@@ -1,4 +1,5 @@
import gulp from 'gulp'; import gulp from 'gulp';
import babel from 'gulp-babel';
require('gulp-grunt')(gulp); require('gulp-grunt')(gulp);
gulp.task('build', () => { gulp.task('build', () => {
@@ -9,6 +10,20 @@ gulp.task('build', () => {
} }
}); });
gulp.task('build:src', () => {
return gulp.src('website/src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('website/transpiled-babel/'));
});
gulp.task('build:common', () => {
return gulp.src('common/script/**/*.js')
.pipe(babel())
.pipe(gulp.dest('common/transpiled-babel/'));
});
gulp.task('build:server', ['build:src', 'build:common']);
gulp.task('build:dev', ['browserify', 'prepare:staticNewStuff'], (done) => { gulp.task('build:dev', ['browserify', 'prepare:staticNewStuff'], (done) => {
gulp.start('grunt-build:dev', done); gulp.start('grunt-build:dev', done);
}); });
@@ -17,6 +32,6 @@ gulp.task('build:dev:watch', ['build:dev'], () => {
gulp.watch(['website/public/**/*.styl', 'common/script/*']); gulp.watch(['website/public/**/*.styl', 'common/script/*']);
}); });
gulp.task('build:prod', ['browserify', 'prepare:staticNewStuff'], (done) => { gulp.task('build:prod', ['browserify', 'build:server', 'prepare:staticNewStuff'], (done) => {
gulp.start('grunt-build:prod', done); gulp.start('grunt-build:prod', done);
}); });

View File

@@ -72,7 +72,7 @@ gulp.task('test:prepare:server', ['test:prepare:mongo'], () => {
} }
}); });
gulp.task('test:prepare:build', (cb) => { gulp.task('test:prepare:build', ['build'], (cb) => {
exec(testBin('grunt build:test'), cb); exec(testBin('grunt build:test'), cb);
}); });

View File

@@ -20,7 +20,7 @@ export var conf = nconf;
* its tasks. * its tasks.
*/ */
export function kill(proc) { export function kill(proc) {
((pid) => { let killProcess = (pid) => {
psTree(pid, (_, pids) => { psTree(pid, (_, pids) => {
if(pids.length) { if(pids.length) {
pids.forEach(kill); return pids.forEach(kill); return
@@ -32,7 +32,9 @@ export function kill(proc) {
} }
catch(e) { console.log(e) } catch(e) { console.log(e) }
}); });
}(proc.PID || proc.pid)); }
killProcess(proc.PID || proc.pid);
}; };
/* /*

View File

@@ -4,6 +4,7 @@
--check-leaks --check-leaks
--growl --growl
--globals io --globals io
--compilers js:babel-core/register -r babel-polyfill
--compilers js:babel-register
--require test/api-legacy/api-helper --require test/api-legacy/api-helper
--require ./test/helpers/globals.helper --require ./test/helpers/globals.helper

View File

@@ -1,4 +1,6 @@
require('babel-core/register'); if (process.env.NODE_ENV !== 'production') {
require('babel-register');
}
// Only do the minimal amount of work before forking just in case of a dyno restart // Only do the minimal amount of work before forking just in case of a dyno restart
var cluster = require("cluster"); var cluster = require("cluster");
var _ = require('lodash'); var _ = require('lodash');