diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000000..abdb3b030b --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["es2015"], + "plugins": ["syntax-async-functions","transform-regenerator"] +} diff --git a/Gruntfile.js b/Gruntfile.js index b692b6c6bc..8b3d213614 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,5 @@ /*global module:false*/ -require('babel-core/register'); +require('babel-register'); var _ = require('lodash'); module.exports = function(grunt) { diff --git a/common/script/content/appearance/backgrounds.js b/common/script/content/appearance/backgrounds.js index 52f9059150..5a4e33c7ac 100644 --- a/common/script/content/appearance/backgrounds.js +++ b/common/script/content/appearance/backgrounds.js @@ -1,5 +1,5 @@ import {forOwn} from 'lodash'; -let t = require('../translation.js'); +import t from '../translation'; /* eslint-disable camelcase */ let backgrounds = { @@ -320,4 +320,4 @@ forOwn(backgrounds, function prefillBackgroundSet (value) { }); }); -export default backgrounds; +module.exports = backgrounds; diff --git a/common/script/content/appearance/hair/bangs.js b/common/script/content/appearance/hair/bangs.js index ff494c5aee..40f01cdce4 100644 --- a/common/script/content/appearance/hair/bangs.js +++ b/common/script/content/appearance/hair/bangs.js @@ -1,6 +1,6 @@ import prefill from '../prefill.js'; -export default prefill({ +module.exports = prefill({ 0: {}, 1: {}, 2: {}, diff --git a/common/script/content/appearance/hair/base.js b/common/script/content/appearance/hair/base.js index 485e610bc1..1c2325b1b4 100644 --- a/common/script/content/appearance/hair/base.js +++ b/common/script/content/appearance/hair/base.js @@ -1,6 +1,7 @@ import prefill from '../prefill.js'; import sets from '../sets.js'; -export default prefill({ + +module.exports = prefill({ 0: {}, 1: {}, 2: {price: 2, set: sets.baseHair1}, diff --git a/common/script/content/appearance/hair/beard.js b/common/script/content/appearance/hair/beard.js index 120b3358b5..56ef44045b 100644 --- a/common/script/content/appearance/hair/beard.js +++ b/common/script/content/appearance/hair/beard.js @@ -1,7 +1,7 @@ import sets from '../sets.js'; import prefill from '../prefill.js'; -export default prefill({ +module.exports = prefill({ 0: {}, 1: {price: 2, set: sets.facialHair}, 2: {price: 2, set: sets.facialHair}, diff --git a/common/script/content/appearance/hair/color.js b/common/script/content/appearance/hair/color.js index 467da5b165..63dc0496eb 100644 --- a/common/script/content/appearance/hair/color.js +++ b/common/script/content/appearance/hair/color.js @@ -1,7 +1,7 @@ import sets from '../sets.js'; import prefill from '../prefill.js'; -export default prefill({ +module.exports = prefill({ white: {}, brown: {}, blond: {}, diff --git a/common/script/content/appearance/hair/flower.js b/common/script/content/appearance/hair/flower.js index 916a270c53..b1322252bd 100644 --- a/common/script/content/appearance/hair/flower.js +++ b/common/script/content/appearance/hair/flower.js @@ -1,6 +1,6 @@ import prefill from '../prefill.js'; -export default prefill({ +module.exports = prefill({ 0: {}, 1: {}, 2: {}, diff --git a/common/script/content/appearance/hair/index.js b/common/script/content/appearance/hair/index.js index be95107518..35201d8b1c 100644 --- a/common/script/content/appearance/hair/index.js +++ b/common/script/content/appearance/hair/index.js @@ -5,7 +5,7 @@ import color from './color.js'; import flower from './flower.js'; import mustache from './mustache.js'; -export default { +module.exports = { color, base, bangs, diff --git a/common/script/content/appearance/hair/mustache.js b/common/script/content/appearance/hair/mustache.js index 5f13d0f962..972de3e718 100644 --- a/common/script/content/appearance/hair/mustache.js +++ b/common/script/content/appearance/hair/mustache.js @@ -1,7 +1,7 @@ import sets from '../sets.js'; import prefill from '../prefill.js'; -export default prefill({ +module.exports = prefill({ 0: {}, 1: {price: 2, set: sets.facialHair}, 2: {price: 2, set: sets.facialHair}, diff --git a/common/script/content/appearance/prefill.js b/common/script/content/appearance/prefill.js index 21fa45a220..d03df62a35 100644 --- a/common/script/content/appearance/prefill.js +++ b/common/script/content/appearance/prefill.js @@ -1,6 +1,6 @@ import {forOwn} from 'lodash'; -export default function prefillAppearances (obj) { +module.exports = function prefillAppearances (obj) { forOwn(obj, function prefillAppearance (value, key) { value.key = key; if (!value.price) { @@ -8,4 +8,4 @@ export default function prefillAppearances (obj) { } }); return obj; -} +}; diff --git a/common/script/content/appearance/sets.js b/common/script/content/appearance/sets.js index 34d83a474d..18285fa5b4 100644 --- a/common/script/content/appearance/sets.js +++ b/common/script/content/appearance/sets.js @@ -1,7 +1,7 @@ import t from '../translation'; import prefill from './prefill.js'; -export default prefill({ +module.exports = prefill({ baseHair1: {setPrice: 5, text: t('hairSet1')}, baseHair2: {setPrice: 5, text: t('hairSet2')}, facialHair: {setPrice: 5, text: t('bodyFacialHair')}, diff --git a/common/script/content/appearance/shirt.js b/common/script/content/appearance/shirt.js index eac4ce0762..3ab890dd0f 100644 --- a/common/script/content/appearance/shirt.js +++ b/common/script/content/appearance/shirt.js @@ -1,7 +1,7 @@ import sets from './sets.js'; import prefill from './prefill.js'; -export default prefill({ +module.exports = prefill({ black: {}, blue: {}, green: {}, diff --git a/common/script/content/appearance/size.js b/common/script/content/appearance/size.js index b6c53bfa2b..3b9b7433b8 100644 --- a/common/script/content/appearance/size.js +++ b/common/script/content/appearance/size.js @@ -1,6 +1,6 @@ import prefill from './prefill.js'; -export default prefill({ +module.exports = prefill({ slim: {}, broad: {}, }); diff --git a/common/script/content/appearance/skin.js b/common/script/content/appearance/skin.js index b9b0ccb153..4e5e1d8561 100644 --- a/common/script/content/appearance/skin.js +++ b/common/script/content/appearance/skin.js @@ -1,7 +1,7 @@ import prefill from './prefill.js'; import sets from './sets.js'; -export default prefill({ +module.exports = prefill({ /* eslint-disable quote-props */ 'ddc994': {}, 'f5a76e': {}, diff --git a/common/script/content/faq.js b/common/script/content/faq.js index d55f461b89..bacad9c119 100644 --- a/common/script/content/faq.js +++ b/common/script/content/faq.js @@ -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 = {}; - -faq.questions = []; +export const questions = []; for (let i = 0; i <= NUMBER_OF_QUESTIONS; i++) { let question = { @@ -13,12 +11,10 @@ for (let i = 0; i <= NUMBER_OF_QUESTIONS; i++) { web: t(`webFaqAnswer${i}`), }; - faq.questions.push(question); + questions.push(question); } -faq.stillNeedHelp = { +export const stillNeedHelp = { ios: t('iosFaqStillNeedHelp'), web: t('webFaqStillNeedHelp'), }; - -module.exports = faq; diff --git a/common/script/content/gear/armor.js b/common/script/content/gear/armor.js index 53a0a1c7bc..d14d6681bb 100644 --- a/common/script/content/gear/armor.js +++ b/common/script/content/gear/armor.js @@ -22,4 +22,4 @@ let armor = { armoire: armoireArmor, }; -export default armor; +module.exports = armor; diff --git a/common/script/content/gear/back.js b/common/script/content/gear/back.js index 7e0e6cf1bd..dd6bba12bf 100644 --- a/common/script/content/gear/back.js +++ b/common/script/content/gear/back.js @@ -9,5 +9,5 @@ let back = { special: specialBack, }; -export default back; +module.exports = back; diff --git a/common/script/content/gear/body.js b/common/script/content/gear/body.js index caa154b031..1e2fff5373 100644 --- a/common/script/content/gear/body.js +++ b/common/script/content/gear/body.js @@ -7,5 +7,5 @@ let body = { special: specialBody, }; -export default body; +module.exports = body; diff --git a/common/script/content/gear/eyewear.js b/common/script/content/gear/eyewear.js index 073b12ca41..747eed5f84 100644 --- a/common/script/content/gear/eyewear.js +++ b/common/script/content/gear/eyewear.js @@ -11,4 +11,4 @@ let eyewear = { armoire: armoireEyewear, }; -export default eyewear; +module.exports = eyewear; diff --git a/common/script/content/gear/head-accessory.js b/common/script/content/gear/head-accessory.js index 1b0e4da3fb..d87407e3f9 100644 --- a/common/script/content/gear/head-accessory.js +++ b/common/script/content/gear/head-accessory.js @@ -9,5 +9,5 @@ let headAccessory = { mystery: mysteryHeadAccessory, }; -export default headAccessory; +module.exports = headAccessory; diff --git a/common/script/content/gear/head.js b/common/script/content/gear/head.js index a5b550f8cc..f8c58b313b 100644 --- a/common/script/content/gear/head.js +++ b/common/script/content/gear/head.js @@ -22,4 +22,4 @@ let head = { armoire: armoireHead, }; -export default head; +module.exports = head; diff --git a/common/script/content/gear/index.js b/common/script/content/gear/index.js index a9fe254e7b..cf288e89dc 100644 --- a/common/script/content/gear/index.js +++ b/common/script/content/gear/index.js @@ -78,7 +78,7 @@ each(GEAR_TYPES, (type) => { }); }); -export default { +module.exports = { tree: gear, flat, }; diff --git a/common/script/content/gear/sets/armoire.js b/common/script/content/gear/sets/armoire.js index 46bc1a418d..53f1dd47e1 100644 --- a/common/script/content/gear/sets/armoire.js +++ b/common/script/content/gear/sets/armoire.js @@ -495,4 +495,4 @@ let armoireSet = { weapon, }; -export default armoireSet; +module.exports = armoireSet; diff --git a/common/script/content/gear/sets/base.js b/common/script/content/gear/sets/base.js index 4f0e84268a..58d45dda3e 100644 --- a/common/script/content/gear/sets/base.js +++ b/common/script/content/gear/sets/base.js @@ -77,4 +77,4 @@ let baseSet = { weapon, }; -export default baseSet; +module.exports = baseSet; diff --git a/common/script/content/gear/sets/healer.js b/common/script/content/gear/sets/healer.js index 4fa5bc38dc..0bfb6060ca 100644 --- a/common/script/content/gear/sets/healer.js +++ b/common/script/content/gear/sets/healer.js @@ -155,4 +155,4 @@ let healerSet = { weapon, }; -export default healerSet; +module.exports = healerSet; diff --git a/common/script/content/gear/sets/mystery.js b/common/script/content/gear/sets/mystery.js index 8c03c96c09..997fa49780 100644 --- a/common/script/content/gear/sets/mystery.js +++ b/common/script/content/gear/sets/mystery.js @@ -385,4 +385,4 @@ let mysterySet = { weapon, }; -export default mysterySet; +module.exports = mysterySet; diff --git a/common/script/content/gear/sets/rogue.js b/common/script/content/gear/sets/rogue.js index 43d6c7cdaa..45145e9f43 100644 --- a/common/script/content/gear/sets/rogue.js +++ b/common/script/content/gear/sets/rogue.js @@ -167,4 +167,4 @@ let rogueSet = { weapon, }; -export default rogueSet; +module.exports = rogueSet; diff --git a/common/script/content/gear/sets/special/index.js b/common/script/content/gear/sets/special/index.js index 53aa0dad5c..48ed0cbee3 100644 --- a/common/script/content/gear/sets/special/index.js +++ b/common/script/content/gear/sets/special/index.js @@ -1534,4 +1534,4 @@ let specialSet = { weapon, }; -export default specialSet; +module.exports = specialSet; diff --git a/common/script/content/gear/sets/special/special-backer.js b/common/script/content/gear/sets/special/special-backer.js index 3e59f4c035..22f7f98ed5 100644 --- a/common/script/content/gear/sets/special/special-backer.js +++ b/common/script/content/gear/sets/special/special-backer.js @@ -90,4 +90,4 @@ let backerSet = { weaponSpecial3, }; -export default backerSet; +module.exports = backerSet; diff --git a/common/script/content/gear/sets/special/special-contributor.js b/common/script/content/gear/sets/special/special-contributor.js index 8ef95ec38e..5c905a0d58 100644 --- a/common/script/content/gear/sets/special/special-contributor.js +++ b/common/script/content/gear/sets/special/special-contributor.js @@ -76,4 +76,4 @@ let contributorSet = { weaponSpecialCritical, }; -export default contributorSet; +module.exports = contributorSet; diff --git a/common/script/content/gear/sets/special/special-wondercon.js b/common/script/content/gear/sets/special/special-wondercon.js index b321251bf1..80c6148f3b 100644 --- a/common/script/content/gear/sets/special/special-wondercon.js +++ b/common/script/content/gear/sets/special/special-wondercon.js @@ -59,4 +59,4 @@ let wonderconSet = { eyewearSpecialWonderconBlack, }; -export default wonderconSet; +module.exports = wonderconSet; diff --git a/common/script/content/gear/sets/warrior.js b/common/script/content/gear/sets/warrior.js index 4e4f3d2a8e..bb5272f5b9 100644 --- a/common/script/content/gear/sets/warrior.js +++ b/common/script/content/gear/sets/warrior.js @@ -152,4 +152,4 @@ let warriorSet = { weapon, }; -export default warriorSet; +module.exports = warriorSet; diff --git a/common/script/content/gear/sets/wizard.js b/common/script/content/gear/sets/wizard.js index 898e7cac3a..69dd2b51c6 100644 --- a/common/script/content/gear/sets/wizard.js +++ b/common/script/content/gear/sets/wizard.js @@ -138,4 +138,4 @@ let wizardSet = { weapon, }; -export default wizardSet; +module.exports = wizardSet; diff --git a/common/script/content/gear/shield.js b/common/script/content/gear/shield.js index 4050487994..eaf02b6903 100644 --- a/common/script/content/gear/shield.js +++ b/common/script/content/gear/shield.js @@ -26,4 +26,4 @@ let shield = { armoire: armoireShield, }; -export default shield; +module.exports = shield; diff --git a/common/script/content/gear/weapon.js b/common/script/content/gear/weapon.js index 611d2a8ce2..3494a53e95 100644 --- a/common/script/content/gear/weapon.js +++ b/common/script/content/gear/weapon.js @@ -22,4 +22,4 @@ let weapon = { armoire: armoireWeapon, }; -export default weapon; +module.exports = weapon; diff --git a/common/script/content/index.js b/common/script/content/index.js index 93afb6be2c..a8dfeae073 100644 --- a/common/script/content/index.js +++ b/common/script/content/index.js @@ -1,12 +1,6 @@ -var _, api, calculateBonus, diminishingReturns, moment, t; - -api = module.exports; - -_ = require('lodash'); - -moment = require('moment'); - -t = require('./translation.js'); +import _ from 'lodash'; +import moment from 'moment'; +import t from './translation'; import { CLASSES, @@ -16,6 +10,8 @@ import { USER_CAN_OWN_QUEST_CATEGORIES, } from './constants'; +let api = module.exports; + import mysterySets from './mystery-sets'; import gear from './gear'; @@ -23,6 +19,7 @@ import gear from './gear'; import appearances from './appearance'; import backgrounds from './appearance/backgrounds.js' import spells from './spells'; +import faq from './faq'; api.mystery = mysterySets; @@ -32,8 +29,8 @@ api.gear = gear; 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) { 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 = { type: 'potion', @@ -89,7 +86,7 @@ api.armoire = { --------------------------------------------------------------- Classes --------------------------------------------------------------- - */ + */ api.classes = CLASSES; @@ -98,7 +95,7 @@ api.classes = CLASSES; --------------------------------------------------------------- Gear Types --------------------------------------------------------------- - */ + */ api.gearTypes = GEAR_TYPES; @@ -2606,4 +2603,4 @@ api.userDefaults = { ] }; -api.faq = require('./faq.js'); +api.faq = faq; diff --git a/common/script/content/mystery-sets.js b/common/script/content/mystery-sets.js index f921f99ccd..e97e15c9b3 100644 --- a/common/script/content/mystery-sets.js +++ b/common/script/content/mystery-sets.js @@ -1,5 +1,5 @@ import { each } from 'lodash'; -let t = require('./translation.js'); +import t from './translation'; let mysterySets = { 201402: { @@ -122,4 +122,4 @@ each(mysterySets, (value, key) => { value.text = t(`mysterySet${key}`); }); -export default mysterySets; +module.exports = mysterySets; diff --git a/common/script/content/spells.js b/common/script/content/spells.js index aae94aecb5..6aeb3e5cad 100644 --- a/common/script/content/spells.js +++ b/common/script/content/spells.js @@ -522,4 +522,4 @@ _.each(spells, (spellClass) => { }); }); -export default spells; +module.exports = spells; diff --git a/common/script/content/translation.js b/common/script/content/translation.js index eb6a39f8f0..baa93f7a8a 100644 --- a/common/script/content/translation.js +++ b/common/script/content/translation.js @@ -1,6 +1,6 @@ import i18n from '../i18n'; -export default function translator (string, vars = { a: 'a' }) { +module.exports = function translator (string, vars = { a: 'a' }) { function func (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 return func; -} +}; diff --git a/common/script/count.js b/common/script/count.js index f61da83a09..4572e29dd8 100644 --- a/common/script/count.js +++ b/common/script/count.js @@ -67,7 +67,7 @@ function questsOfCategory (userQuests, category) { return count; } -export default { +module.exports = { beastMasterProgress, dropPetsCurrentlyOwned, mountMasterProgress, diff --git a/common/script/i18n.js b/common/script/i18n.js index 41a0e63bc2..ace63de8e1 100644 --- a/common/script/i18n.js +++ b/common/script/i18n.js @@ -60,4 +60,4 @@ function t (stringName) { } } -export default i18n; +module.exports = i18n; diff --git a/common/script/index.js b/common/script/index.js index dd5d2bf2f5..2721a42560 100644 --- a/common/script/index.js +++ b/common/script/index.js @@ -1,3 +1,6 @@ +import moment from 'moment'; +import _ from 'lodash'; + import { daysSince, shouldDo, @@ -9,18 +12,13 @@ import { } from './constants'; 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; }; -moment = require('moment'); +import content from './content/index'; +import i18n from './i18n'; -_ = require('lodash'); - -content = require('./content/index'); - -i18n = require('./i18n'); - -api = module.exports = {}; +let api = module.exports = {}; api.i18n = i18n; api.shouldDo = shouldDo; @@ -471,7 +469,8 @@ api.appliedTags = function(userTags, taskTags) { Various counting functions */ -api.count = require('./count'); +import count from './count'; +api.count = count; /* diff --git a/gulpfile.js b/gulpfile.js index 84da7d11a3..0c399ce7fa 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,7 +6,7 @@ * directory, and it will automatically be included. */ -require('babel-core/register'); +require('babel-register'); if (process.env.NODE_ENV === 'production') { require('./tasks/gulp-newstuff'); diff --git a/package.json b/package.json index ea497f587d..7eb5812901 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,12 @@ "amplitude": "^2.0.3", "async": "~0.9.0", "aws-sdk": "^2.0.25", - "babel-core": "^5.8.34", - "babelify": "^6.x.x", + "babel-plugin-syntax-async-functions": "^6.5.0", + "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", "browserify": "~12.0.1", "connect-ratelimit": "0.0.7", @@ -102,7 +106,7 @@ "coverage": "COVERAGE=true mocha --require register-handlers.js --reporter html-cov > coverage.html; open coverage.html" }, "devDependencies": { - "babel-eslint": "^4.1.6", + "babel-eslint": "^5.0.0", "chai": "^3.4.0", "chai-as-promised": "^5.1.0", "coveralls": "^2.11.2", @@ -115,7 +119,7 @@ "expect.js": "~0.2.0", "istanbul": "^0.3.14", "karma": "~0.13.15", - "karma-babel-preprocessor": "^5.0.0", + "karma-babel-preprocessor": "^6.0.1", "karma-chai-plugins": "~0.6.0", "karma-coverage": "^0.5.3", "karma-mocha": "^0.2.0", diff --git a/tasks/gulp-tests.js b/tasks/gulp-tests.js index ebabb668c6..a1ca38f5e6 100644 --- a/tasks/gulp-tests.js +++ b/tasks/gulp-tests.js @@ -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); }); diff --git a/tasks/taskHelper.js b/tasks/taskHelper.js index cafaa25439..408978efd4 100644 --- a/tasks/taskHelper.js +++ b/tasks/taskHelper.js @@ -20,7 +20,7 @@ export var conf = nconf; * its tasks. */ export function kill(proc) { - ((pid) => { + let killProcess = (pid) => { psTree(pid, (_, pids) => { if(pids.length) { pids.forEach(kill); return @@ -32,7 +32,9 @@ export function kill(proc) { } catch(e) { console.log(e) } }); - }(proc.PID || proc.pid)); + } + + killProcess(proc.PID || proc.pid); }; /* diff --git a/test/mocha.opts b/test/mocha.opts index bcdefd3e55..a2323400d5 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -4,6 +4,7 @@ --check-leaks --growl --globals io ---compilers js:babel-core/register +-r babel-polyfill +--compilers js:babel-register --require test/api-legacy/api-helper --require ./test/helpers/globals.helper diff --git a/website/src/server.js b/website/src/server.js index 494febfb97..9910f22160 100644 --- a/website/src/server.js +++ b/website/src/server.js @@ -1,4 +1,4 @@ -require('babel-core/register'); +require('babel-register'); // Only do the minimal amount of work before forking just in case of a dyno restart var cluster = require("cluster"); var _ = require('lodash');