diff --git a/.gitignore b/.gitignore index 88e3ef3032..94ad5f5766 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,6 @@ website/public/docs *.sublime-workspace coverage coverage.html -common/dist/scripts/habitrpg-shared.js +common/dist/scripts/* test/spec/mocks/translations.js diff --git a/common/script/content/index.coffee b/common/script/content/index.coffee index 0794997d1b..c7dd7d86f4 100644 --- a/common/script/content/index.coffee +++ b/common/script/content/index.coffee @@ -2,7 +2,11 @@ api = module.exports _ = require 'lodash' moment = require 'moment' -t = require './helpers/translator' + +DIST_LOCATION = '../../dist/scripts/content' + +t = require "#{DIST_LOCATION}/helpers/translator" + require('babel/register') @@ -16,9 +20,9 @@ require('babel/register') classes = ['warrior', 'rogue', 'healer', 'wizard'] gearTypes = [ 'weapon', 'armor', 'head', 'shield', 'body', 'back', 'headAccessory', 'eyewear'] -events = require('./events') +events = require("#{DIST_LOCATION}/events") -api.mystery = require('./mystery-sets') +api.mystery = require("#{DIST_LOCATION}/mystery-sets") api.itemList = 'weapon': {localeKey: 'weapon', isEquipment: true} @@ -547,9 +551,9 @@ api.classes = classes api.gearTypes = gearTypes -api.spells = require('./spells/index') +api.spells = require("#{DIST_LOCATION}/spells/index") -api.cardTypes = require('./card-types') +api.cardTypes = require("#{DIST_LOCATION}/card-types") # Intercept all spells to reduce user.stats.mp after casting the spell _.each api.spells, (spellClass) -> @@ -569,7 +573,7 @@ api.special = api.spells.special --------------------------------------------------------------- ### -eggs = require('./eggs/index') +eggs = require("#{DIST_LOCATION}/eggs/index") api.dropEggs = eggs.dropEggs @@ -628,7 +632,7 @@ api.specialMounts = 'Orca-Base': 'orca' 'Gryphon-RoyalPurple': 'royalPurpleGryphon' -api.timeTravelStable = require('./time-traveler-stable') +api.timeTravelStable = require("#{DIST_LOCATION}/time-traveler-stable") api.hatchingPotions = Base: value: 2, text: t('hatchingPotionBase') @@ -1794,4 +1798,4 @@ api.userDefaults = {name: t('defaultTag3')} ] -api.faq = require './faq' +api.faq = require "#{DIST_LOCATION}/faq" diff --git a/common/script/content/card-types.js b/common/script/src/content/card-types.js similarity index 100% rename from common/script/content/card-types.js rename to common/script/src/content/card-types.js diff --git a/common/script/content/eggs/drops.js b/common/script/src/content/eggs/drops.js similarity index 100% rename from common/script/content/eggs/drops.js rename to common/script/src/content/eggs/drops.js diff --git a/common/script/content/eggs/index.js b/common/script/src/content/eggs/index.js similarity index 100% rename from common/script/content/eggs/index.js rename to common/script/src/content/eggs/index.js diff --git a/common/script/content/events.js b/common/script/src/content/events.js similarity index 100% rename from common/script/content/events.js rename to common/script/src/content/events.js diff --git a/common/script/content/faq.js b/common/script/src/content/faq.js similarity index 100% rename from common/script/content/faq.js rename to common/script/src/content/faq.js diff --git a/common/script/content/helpers/translator.js b/common/script/src/content/helpers/translator.js similarity index 83% rename from common/script/content/helpers/translator.js rename to common/script/src/content/helpers/translator.js index 935a377120..5263b530ea 100644 --- a/common/script/content/helpers/translator.js +++ b/common/script/src/content/helpers/translator.js @@ -1,7 +1,7 @@ 'use strict'; require('coffee-script'); -var i18n = require('../../i18n.coffee'); +var i18n = require(__dirname + '/../../../../script/i18n.coffee'); var t = function(string, vars) { var func = function(lang) { diff --git a/common/script/content/mystery-sets.js b/common/script/src/content/mystery-sets.js similarity index 100% rename from common/script/content/mystery-sets.js rename to common/script/src/content/mystery-sets.js diff --git a/common/script/content/spells/index.js b/common/script/src/content/spells/index.js similarity index 100% rename from common/script/content/spells/index.js rename to common/script/src/content/spells/index.js diff --git a/common/script/content/time-traveler-stable.js b/common/script/src/content/time-traveler-stable.js similarity index 100% rename from common/script/content/time-traveler-stable.js rename to common/script/src/content/time-traveler-stable.js diff --git a/package.json b/package.json index 4857c0dba4..e915aefc26 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,7 @@ "deep-diff": "~0.1.4", "event-stream": "^3.2.2", "expect.js": "~0.2.0", + "gulp-babel": "^5.2.1", "istanbul": "^0.3.14", "karma": "~0.10.2", "karma-chai-plugins": "~0.1.0", diff --git a/tasks/gulp-babelify.js b/tasks/gulp-babelify.js new file mode 100644 index 0000000000..a77be47ecc --- /dev/null +++ b/tasks/gulp-babelify.js @@ -0,0 +1,16 @@ +import gulp from 'gulp'; +import babel from 'gulp-babel'; + +const ES2015_SOURCE = 'common/script/src/**/*.js'; +const ES2015_DIST = 'common/dist/scripts/'; + +gulp.task('babel:common', () => { + return gulp.src(ES2015_SOURCE) + .pipe(babel()) + .pipe(gulp.dest(ES2015_DIST)); +}); + +gulp.task('babel:common:watch', () => { + gulp.watch([ES2015_SOURCE], ['babel:common']); +}); +