fix linting of migrations

This commit is contained in:
Matteo Pagliazzi
2019-10-08 18:36:55 +02:00
parent 621787915c
commit 0d90a1db4c
40 changed files with 219 additions and 176 deletions

View File

@@ -1,11 +0,0 @@
{
"root": true,
"extends": [
"habitrpg/lib/node"
],
"rules": {
'no-param-reassign': ['error', {
props: false,
}],
}
}

View File

@@ -29,8 +29,8 @@ const testCount = (stdout, regexp) => {
const testBin = (string, additionalEnvVariables = '') => { const testBin = (string, additionalEnvVariables = '') => {
if (os.platform() === 'win32') { if (os.platform() === 'win32') {
if (additionalEnvVariables !== '') { if (additionalEnvVariables !== '') {
additionalEnvVariables = additionalEnvVariables.split(' ').join('&&set '); additionalEnvVariables = additionalEnvVariables.split(' ').join('&&set '); // eslint-disable-line no-param-reassign
additionalEnvVariables = `set ${additionalEnvVariables}&&`; additionalEnvVariables = `set ${additionalEnvVariables}&&`; // eslint-disable-line no-param-reassign
} }
return `set NODE_ENV=test&&${additionalEnvVariables}${string}`; return `set NODE_ENV=test&&${additionalEnvVariables}${string}`;
} }
@@ -46,9 +46,9 @@ gulp.task('test:nodemon', gulp.series(done => {
gulp.task('test:prepare:mongo', cb => { gulp.task('test:prepare:mongo', cb => {
mongoose.connect(TEST_DB_URI, err => { mongoose.connect(TEST_DB_URI, err => {
if (err) return cb(`Unable to connect to mongo database. Are you sure it's running? \n\n${err}`); if (err) return cb(`Unable to connect to mongo database. Are you sure it's running? \n\n${err}`);
mongoose.connection.dropDatabase(err2 => { return mongoose.connection.dropDatabase(err2 => {
if (err2) return cb(err2); if (err2) return cb(err2);
mongoose.connection.close(cb); return mongoose.connection.close(cb);
}); });
}); });
}); });

View File

@@ -44,7 +44,7 @@ function eachTranslationFile (languages, cb) {
const englishFile = fs.readFileSync(ENGLISH_LOCALE + filename); const englishFile = fs.readFileSync(ENGLISH_LOCALE + filename);
const parsedEnglishFile = JSON.parse(englishFile); const parsedEnglishFile = JSON.parse(englishFile);
cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile); return cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile);
}); });
}); });
} }

View File

@@ -1,7 +0,0 @@
{
"root": false,
"rules": {
"no-console": 0,
"no-use-before-define": ["error", { "functions": false }]
}
}

View File

@@ -18,7 +18,7 @@ async function syncChallengeToMembers (challenges) {
return Promise.all(promises); return Promise.all(promises);
}); });
return await Promise.all(challengSyncPromises); return Promise.all(challengSyncPromises);
} }
async function syncChallenges (lastChallengeDate) { async function syncChallenges (lastChallengeDate) {

View File

@@ -1,6 +1,7 @@
// mongo habitrpg ./node_modules/moment/moment.js ./migrations/cancelSubscription.js // mongo habitrpg ./node_modules/moment/moment.js ./migrations/cancelSubscription.js
// For some reason people often to contact me to cancel their sub, rather than do it online. Even when I point them to // For some reason people often to contact me to cancel their sub,
// rather than do it online. Even when I point them to
// the FAQ (http://goo.gl/1uoPGQ) they insist... // the FAQ (http://goo.gl/1uoPGQ) they insist...
db.users.update( db.users.update(

View File

@@ -1,6 +1,5 @@
// Give contrib.level 7+ free subscription for life // Give contrib.level 7+ free subscription for life
db.users.update( db.users.update(
{ {
'contributor.level': { $gte: 7 }, 'contributor.level': { $gte: 7 },
'purchased.plan.customerId': null, 'purchased.plan.customerId': null,

View File

@@ -84,7 +84,7 @@ db.users.aggregate([
]).forEach(data => { ]).forEach(data => {
// print( "\n" ); printjson(data); // print( "\n" ); printjson(data);
data.troublesomeIds.forEach(taskid => { data.troublesomeIds.forEach(taskid => {
print(`non-unique task: ${taskid}`); print(`non-unique task: ${taskid}`); // eslint-disable-line no-restricted-globals
db.users.update({ db.users.update({
_id: uuid, _id: uuid,
todos: { $elemMatch: { id: taskid } }, todos: { $elemMatch: { id: taskid } },

View File

@@ -4,6 +4,7 @@ const newUser = db.users.findOne({ _id: newId });
db.users.update({ _id: oldId }, { $set: { auth: newUser.auth } }); db.users.update({ _id: oldId }, { $set: { auth: newUser.auth } });
// remove the auth on the new user (which is a template account). The account will be preened automatically later, // remove the auth on the new user (which is a template account).
// The account will be preened automatically later,
// this allows us to keep the account around a few days in case there was a mistake // this allows us to keep the account around a few days in case there was a mistake
db.users.update({ _id: newId }, { $unset: { auth: 1 } }); db.users.update({ _id: newId }, { $unset: { auth: 1 } });

View File

@@ -15,20 +15,20 @@ db.users.update(
// db.users.update( // db.users.update(
// {_id:''}, // {_id:''},
// {$set:{'purchased.plan':{ // {$set:{'purchased.plan':{
// planId: 'basic_'+m+'mo', // planId: 'basic_'+m+'mo',
// paymentMethod: 'Paypal', // paymentMethod: 'Paypal',
// customerId: 'Gift', // customerId: 'Gift',
// dateCreated: new Date(), // dateCreated: new Date(),
// dateTerminated: moment().add('month',m).toDate(), // dateTerminated: moment().add('month',m).toDate(),
// dateUpdated: new Date(), // dateUpdated: new Date(),
// extraMonths: 0, // extraMonths: 0,
// gemsBought: 0, // gemsBought: 0,
// mysteryItems: [], // mysteryItems: [],
// consecutive: { // consecutive: {
// count: 0, // count: 0,
// offset: m, // offset: m,
// gemCapExtra: m/3*5, // gemCapExtra: m/3*5,
// trinkets: m/3 // trinkets: m/3
// } // }
// }}} // }}}
// ) // )

View File

@@ -1,7 +1,8 @@
/* let migrationName = 'Jackalopes for Unlimited Subscribers'; */ /* let migrationName = 'Jackalopes for Unlimited Subscribers'; */
/* /*
* This migration will find users with unlimited subscriptions who are also eligible for Jackalope mounts, and award them * This migration will find users with unlimited subscriptions who are also eligible
* for Jackalope mounts, and award them
*/ */
import { model as Group } from '../../website/server/models/group'; import { model as Group } from '../../website/server/models/group';
@@ -35,7 +36,7 @@ async function handOutJackalopes () {
cursor.on('close', async () => { cursor.on('close', async () => {
console.log('done'); console.log('done');
return await Promise.all(promises); return Promise.all(promises);
}); });
} }

View File

@@ -8,7 +8,7 @@
*/ */
import { model as Group } from '../../website/server/models/group'; import { model as Group } from '../../website/server/models/group';
import { model as Chat } from '../../website/server/models/chat'; import { chatModel as Chat } from '../../website/server/models/message';
async function moveGroupChatToModel (skip = 0) { async function moveGroupChatToModel (skip = 0) {
const groups = await Group.find({}) const groups = await Group.find({})
@@ -40,7 +40,7 @@ async function moveGroupChatToModel (skip = 0) {
const reducedPromises = promises.reduce((acc, curr) => { const reducedPromises = promises.reduce((acc, curr) => {
acc = acc.concat(curr); acc = acc.concat(curr); // eslint-disable-line no-param-reassign
return acc; return acc;
}, []); }, []);

View File

@@ -1,4 +1,4 @@
import monk from 'monk'; import monk from 'monk'; // eslint-disable-line import/no-extraneous-dependencies
import nconf from 'nconf'; import nconf from 'nconf';
import stripePayments from '../../website/server/libs/payments/stripe'; import stripePayments from '../../website/server/libs/payments/stripe';
@@ -43,7 +43,7 @@ async function fixGroupPlanMembers () {
}, },
).each(async (group, { close, pause, resume }) => { // eslint-disable-line no-unused-vars ).each(async (group, { close, pause, resume }) => { // eslint-disable-line no-unused-vars
pause(); pause();
groupPlanCount++; groupPlanCount += 1;
const canonicalMemberCount = await dbUsers.count( const canonicalMemberCount = await dbUsers.count(
{ {
@@ -78,7 +78,7 @@ async function fixGroupPlanMembers () {
if (!groupUpdate) return; if (!groupUpdate) return;
fixedGroupCount++; fixedGroupCount += 1;
if (group.purchased.plan.paymentMethod === 'Stripe') { if (group.purchased.plan.paymentMethod === 'Stripe') {
await stripePayments.chargeForAdditionalGroupMember(group); await stripePayments.chargeForAdditionalGroupMember(group);
await dbGroups.update( await dbGroups.update(

View File

@@ -5,12 +5,12 @@ let authorUuid = ''; // ... own data is done
*/ */
/* /*
* This migrations will iterate through all groups with a group plan a subscription and resync the free * This migrations will iterate through all groups with a group plan
* subscription to all members * a subscription and resync the free subscription to all members
*/ */
import { model as Group } from '../../website/server/models/group'; import { model as Group } from '../../website/server/models/group';
import * as payments from '../../website/server/libs/payments'; import payments from '../../website/server/libs/payments/payments';
async function updateGroupsWithGroupPlans () { async function updateGroupsWithGroupPlans () {
const cursor = Group.find({ const cursor = Group.find({
@@ -25,7 +25,7 @@ async function updateGroupsWithGroupPlans () {
promises.push(group.save()); promises.push(group.save());
}); });
cursor.on('close', async () => await Promise.all(promises)); cursor.on('close', async () => Promise.all(promises));
} }
module.exports = updateGroupsWithGroupPlans; module.exports = updateGroupsWithGroupPlans;

View File

@@ -1,4 +1,4 @@
require('babel-register'); require('@babel/register'); // eslint-disable-line import/no-extraneous-dependencies
// This file must use ES5, everything required can be in ES6 // This file must use ES5, everything required can be in ES6
@@ -17,7 +17,7 @@ function setUpServer () {
setUpServer(); setUpServer();
// Replace this with your migration // Replace this with your migration
const processUsers = require(''); const processUsers = () => {}; // require('');
processUsers() processUsers()
.then(() => { .then(() => {

View File

@@ -6,7 +6,7 @@ const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is do
* set the newStuff flag in all user accounts so they see a Bailey message * set the newStuff flag in all user accounts so they see a Bailey message
*/ */
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
const dbUsers = monk(connectionString).get('users', { castIds: false }); const dbUsers = monk(connectionString).get('users', { castIds: false });
@@ -26,7 +26,9 @@ function processUsers (lastId) {
dbUsers.find(query, { dbUsers.find(query, {
sort: { _id: 1 }, sort: { _id: 1 },
limit: 250, limit: 250,
fields: [], // specify fields we are interested in to limit retrieved data (empty if we're not reading data): // specify fields we are interested in to limit retrieved data
// (empty if we're not reading data):
fields: [],
}) })
.then(updateUsers) .then(updateUsers)
.catch(err => { .catch(err => {
@@ -42,7 +44,7 @@ function updateUsers (users) {
if (!users || users.length === 0) { if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.'); console.warn('All appropriate users found and modified.');
displayData(); displayData();
return; return null;
} }
const userPromises = users.map(updateUser); const userPromises = users.map(updateUser);
@@ -55,7 +57,7 @@ function updateUsers (users) {
} }
function updateUser (user) { function updateUser (user) {
count++; count += 1;
const set = { 'flags.newStuff': true }; const set = { 'flags.newStuff': true };
@@ -71,9 +73,10 @@ function displayData () {
} }
function exiting (code, msg) { function exiting (code, msg) {
code = code || 0; // 0 = success // 0 = success
code = code || 0; // eslint-disable-line no-param-reassign
if (code && !msg) { if (code && !msg) {
msg = 'ERROR!'; msg = 'ERROR!'; // eslint-disable-line no-param-reassign
} }
if (msg) { if (msg) {
if (code) { if (code) {

View File

@@ -6,7 +6,7 @@ const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is do
* Remove flag stating that the Enchanted Armoire is empty, for when new equipment is added * Remove flag stating that the Enchanted Armoire is empty, for when new equipment is added
*/ */
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
const dbUsers = monk(connectionString).get('users', { castIds: false }); const dbUsers = monk(connectionString).get('users', { castIds: false });
@@ -26,7 +26,9 @@ function processUsers (lastId) {
dbUsers.find(query, { dbUsers.find(query, {
sort: { _id: 1 }, sort: { _id: 1 },
limit: 250, limit: 250,
fields: [], // specify fields we are interested in to limit retrieved data (empty if we're not reading data): // specify fields we are interested in to limit retrieved data
// (empty if we're not reading data):
fields: [],
}) })
.then(updateUsers) .then(updateUsers)
.catch(err => { .catch(err => {
@@ -42,7 +44,7 @@ function updateUsers (users) {
if (!users || users.length === 0) { if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.'); console.warn('All appropriate users found and modified.');
displayData(); displayData();
return; return null;
} }
const userPromises = users.map(updateUser); const userPromises = users.map(updateUser);
@@ -55,7 +57,7 @@ function updateUsers (users) {
} }
function updateUser (user) { function updateUser (user) {
count++; count += 1;
const set = { migration: migrationName, 'flags.armoireEmpty': false }; const set = { migration: migrationName, 'flags.armoireEmpty': false };
@@ -71,9 +73,10 @@ function displayData () {
} }
function exiting (code, msg) { function exiting (code, msg) {
code = code || 0; // 0 = success // 0 = success
code = code || 0; // eslint-disable-line no-param-reassign
if (code && !msg) { if (code && !msg) {
msg = 'ERROR!'; msg = 'ERROR!'; // eslint-disable-line no-param-reassign
} }
if (msg) { if (msg) {
if (code) { if (code) {

View File

@@ -20,7 +20,7 @@ const authorUuid = '3e595299-3d8a-4a10-bfe0-88f555e4aa0c'; // ... own data is do
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const dbUsers = monk(connectionString).get('users', { castIds: false }); const dbUsers = monk(connectionString).get('users', { castIds: false });
@@ -47,10 +47,12 @@ function processUsers (lastId) {
dbUsers.find(query, { dbUsers.find(query, {
sort: { _id: 1 }, sort: { _id: 1 },
limit: 250, limit: 250,
// specify fields we are interested in to limit retrieved data
// (empty if we're not reading data):
fields: { fields: {
'flags.armoireEmpty': 1, 'flags.armoireEmpty': 1,
'items.gear.owned': 1, 'items.gear.owned': 1,
}, // specify fields we are interested in to limit retrieved data (empty if we're not reading data): },
}) })
.then(updateUsers) .then(updateUsers)
.catch(err => { .catch(err => {
@@ -66,7 +68,7 @@ function updateUsers (users) {
if (!users || users.length === 0) { if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.'); console.warn('All appropriate users found and modified.');
displayData(); displayData();
return; return null;
} }
const userPromises = users.map(updateUser); const userPromises = users.map(updateUser);
@@ -79,14 +81,64 @@ function updateUsers (users) {
} }
function updateUser (user) { function updateUser (user) {
count++; count += 1;
const set = { migration: migrationName, 'flags.armoireEmpty': false }; const set = { migration: migrationName, 'flags.armoireEmpty': false };
if (user.flags.armoireEmpty) { if (user.flags.armoireEmpty) {
// this user believes their armoire has no more items in it // this user believes their armoire has no more items in it
if (user.items.gear.owned.weapon_armoire_barristerGavel && user.items.gear.owned.armor_armoire_barristerRobes && user.items.gear.owned.head_armoire_jesterCap && user.items.gear.owned.armor_armoire_jesterCostume && user.items.gear.owned.head_armoire_barristerWig && user.items.gear.owned.weapon_armoire_jesterBaton && user.items.gear.owned.weapon_armoire_lunarSceptre && user.items.gear.owned.armor_armoire_gladiatorArmor && user.items.gear.owned.weapon_armoire_basicCrossbow && user.items.gear.owned.head_armoire_gladiatorHelm && user.items.gear.owned.armor_armoire_lunarArmor && user.items.gear.owned.head_armoire_redHairbow && user.items.gear.owned.head_armoire_violetFloppyHat && user.items.gear.owned.head_armoire_rancherHat && user.items.gear.owned.shield_armoire_gladiatorShield && user.items.gear.owned.head_armoire_blueHairbow && user.items.gear.owned.weapon_armoire_mythmakerSword && user.items.gear.owned.head_armoire_royalCrown && user.items.gear.owned.head_armoire_hornedIronHelm && user.items.gear.owned.weapon_armoire_rancherLasso && user.items.gear.owned.armor_armoire_rancherRobes && user.items.gear.owned.armor_armoire_hornedIronArmor && user.items.gear.owned.armor_armoire_goldenToga && user.items.gear.owned.weapon_armoire_ironCrook && user.items.gear.owned.head_armoire_goldenLaurels && user.items.gear.owned.head_armoire_redFloppyHat && user.items.gear.owned.armor_armoire_plagueDoctorOvercoat && user.items.gear.owned.head_armoire_plagueDoctorHat && user.items.gear.owned.weapon_armoire_goldWingStaff && user.items.gear.owned.head_armoire_yellowHairbow && user.items.gear.owned.eyewear_armoire_plagueDoctorMask && user.items.gear.owned.head_armoire_blackCat && user.items.gear.owned.weapon_armoire_batWand && user.items.gear.owned.head_armoire_orangeCat && user.items.gear.owned.shield_armoire_midnightShield && user.items.gear.owned.armor_armoire_royalRobes && user.items.gear.owned.head_armoire_blueFloppyHat && user.items.gear.owned.shield_armoire_royalCane && user.items.gear.owned.weapon_armoire_shepherdsCrook && user.items.gear.owned.armor_armoire_shepherdRobes && user.items.gear.owned.head_armoire_shepherdHeaddress && user.items.gear.owned.weapon_armoire_blueLongbow && user.items.gear.owned.weapon_armoire_crystalCrescentStaff && user.items.gear.owned.head_armoire_crystalCrescentHat && user.items.gear.owned.armor_armoire_dragonTamerArmor && user.items.gear.owned.head_armoire_dragonTamerHelm && user.items.gear.owned.armor_armoire_crystalCrescentRobes && user.items.gear.owned.shield_armoire_dragonTamerShield && user.items.gear.owned.weapon_armoire_glowingSpear) { if (
user.items.gear.owned.weapon_armoire_barristerGavel
&& user.items.gear.owned.armor_armoire_barristerRobes
&& user.items.gear.owned.head_armoire_jesterCap
&& user.items.gear.owned.armor_armoire_jesterCostume
&& user.items.gear.owned.head_armoire_barristerWig
&& user.items.gear.owned.weapon_armoire_jesterBaton
&& user.items.gear.owned.weapon_armoire_lunarSceptre
&& user.items.gear.owned.armor_armoire_gladiatorArmor
&& user.items.gear.owned.weapon_armoire_basicCrossbow
&& user.items.gear.owned.head_armoire_gladiatorHelm
&& user.items.gear.owned.armor_armoire_lunarArmor
&& user.items.gear.owned.head_armoire_redHairbow
&& user.items.gear.owned.head_armoire_violetFloppyHat
&& user.items.gear.owned.head_armoire_rancherHat
&& user.items.gear.owned.shield_armoire_gladiatorShield
&& user.items.gear.owned.head_armoire_blueHairbow
&& user.items.gear.owned.weapon_armoire_mythmakerSword
&& user.items.gear.owned.head_armoire_royalCrown
&& user.items.gear.owned.head_armoire_hornedIronHelm
&& user.items.gear.owned.weapon_armoire_rancherLasso
&& user.items.gear.owned.armor_armoire_rancherRobes
&& user.items.gear.owned.armor_armoire_hornedIronArmor
&& user.items.gear.owned.armor_armoire_goldenToga
&& user.items.gear.owned.weapon_armoire_ironCrook
&& user.items.gear.owned.head_armoire_goldenLaurels
&& user.items.gear.owned.head_armoire_redFloppyHat
&& user.items.gear.owned.armor_armoire_plagueDoctorOvercoat
&& user.items.gear.owned.head_armoire_plagueDoctorHat
&& user.items.gear.owned.weapon_armoire_goldWingStaff
&& user.items.gear.owned.head_armoire_yellowHairbow
&& user.items.gear.owned.eyewear_armoire_plagueDoctorMask
&& user.items.gear.owned.head_armoire_blackCat
&& user.items.gear.owned.weapon_armoire_batWand
&& user.items.gear.owned.head_armoire_orangeCat
&& user.items.gear.owned.shield_armoire_midnightShield
&& user.items.gear.owned.armor_armoire_royalRobes
&& user.items.gear.owned.head_armoire_blueFloppyHat
&& user.items.gear.owned.shield_armoire_royalCane
&& user.items.gear.owned.weapon_armoire_shepherdsCrook
&& user.items.gear.owned.armor_armoire_shepherdRobes
&& user.items.gear.owned.head_armoire_shepherdHeaddress
&& user.items.gear.owned.weapon_armoire_blueLongbow
&& user.items.gear.owned.weapon_armoire_crystalCrescentStaff
&& user.items.gear.owned.head_armoire_crystalCrescentHat
&& user.items.gear.owned.armor_armoire_dragonTamerArmor
&& user.items.gear.owned.head_armoire_dragonTamerHelm
&& user.items.gear.owned.armor_armoire_crystalCrescentRobes
&& user.items.gear.owned.shield_armoire_dragonTamerShield
&& user.items.gear.owned.weapon_armoire_glowingSpear
) {
// this user does have all the armoire items so we don't change the flag // this user does have all the armoire items so we don't change the flag
// console.log("don't change: " + user._id); // FOR TESTING // console.log("don't change: " + user._id); // FOR TESTING
} else { } else {
@@ -109,9 +161,10 @@ function displayData () {
} }
function exiting (code, msg) { function exiting (code, msg) {
code = code || 0; // 0 = success // 0 = success
code = code || 0; // eslint-disable-line no-param-reassign
if (code && !msg) { if (code && !msg) {
msg = 'ERROR!'; msg = 'ERROR!'; // eslint-disable-line no-param-reassign
} }
if (msg) { if (msg) {
if (code) { if (code) {

View File

@@ -6,12 +6,12 @@ const authorUuid = ''; // ... own data is done
* Check if users have empty profile data in new database and update it with old database info * Check if users have empty profile data in new database and update it with old database info
*/ */
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const connectionString = ''; // FOR TEST DATABASE const connectionString = ''; // FOR TEST DATABASE
const dbUsers = monk(connectionString).get('users', { castIds: false }); const dbUsers = monk(connectionString).get('users', { castIds: false });
const monk2 = require('monk'); const monk2 = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const oldDbConnectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE const oldDbConnectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
const olDbUsers = monk2(oldDbConnectionString).get('users', { castIds: false }); const olDbUsers = monk2(oldDbConnectionString).get('users', { castIds: false });
@@ -49,7 +49,7 @@ function updateUsers (users) {
if (!users || users.length === 0) { if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.'); console.warn('All appropriate users found and modified.');
setTimeout(displayData, 300000); setTimeout(displayData, 300000);
return; return null;
} }
const userPaymentPromises = users.map(updateUser); const userPaymentPromises = users.map(updateUser);
@@ -60,16 +60,16 @@ function updateUsers (users) {
} }
function updateUser (user) { function updateUser (user) {
count++; count += 1;
if (!user.profile.name || user.profile.name === 'profile name not found' || !user.profile.imageUrl || !user.profile.blurb) { if (!user.profile.name || user.profile.name === 'profile name not found' || !user.profile.imageUrl || !user.profile.blurb) {
return olDbUsers.findOne({ _id: user._id }, '_id profile') return olDbUsers.findOne({ _id: user._id }, '_id profile')
.then(oldUserData => { .then(oldUserData => {
if (!oldUserData) return; if (!oldUserData) return null;
// specify user data to change: // specify user data to change:
const set = {}; const set = {};
if (oldUserData.profile.name === 'profile name not found') return; if (oldUserData.profile.name === 'profile name not found') return null;
const userNeedsProfileName = !user.profile.name || user.profile.name === 'profile name not found'; const userNeedsProfileName = !user.profile.name || user.profile.name === 'profile name not found';
if (userNeedsProfileName && oldUserData.profile.name) { if (userNeedsProfileName && oldUserData.profile.name) {
@@ -88,11 +88,15 @@ function updateUser (user) {
console.log(set); console.log(set);
return dbUsers.update({ _id: user._id }, { $set: set }); return dbUsers.update({ _id: user._id }, { $set: set });
} }
return null;
}); });
} }
if (count % progressCount === 0) console.warn(`${count} ${user._id}`); if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
if (user._id === authorUuid) console.warn(`${authorName} processed`); if (user._id === authorUuid) console.warn(`${authorName} processed`);
return null;
} }
function displayData () { function displayData () {
@@ -101,9 +105,10 @@ function displayData () {
} }
function exiting (code, msg) { function exiting (code, msg) {
code = code || 0; // 0 = success // 0 = success
code = code || 0; // eslint-disable-line no-param-reassign
if (code && !msg) { if (code && !msg) {
msg = 'ERROR!'; msg = 'ERROR!'; // eslint-disable-line no-param-reassign
} }
if (msg) { if (msg) {
if (code) { if (code) {

View File

@@ -46,7 +46,7 @@ function getFileFromUrl (url) {
request.get(url).end((err, res) => { request.get(url).end((err, res) => {
if (err) return reject(err); if (err) return reject(err);
const file = res.body; const file = res.body;
resolve(file); return resolve(file);
}); });
}); });
} }
@@ -70,7 +70,7 @@ function uploadToS3 (start, end, filesUrls) {
.then(buffer => uploadFile(buffer, getFileName(fullUrl)))); .then(buffer => uploadFile(buffer, getFileName(fullUrl))));
console.log(promises.length); console.log(promises.length);
return Promise.all(promises) Promise.all(promises)
.then(() => { .then(() => {
currentIndex += 50; currentIndex += 50;
uploadToS3(currentIndex, currentIndex + 50, filesUrls); uploadToS3(currentIndex, currentIndex + 50, filesUrls);

View File

@@ -3,10 +3,10 @@
// const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is done // const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is done
/* /*
* Iterates over all habits and condense multiple history entries for the same day into a single entry * Iterates over all habits and condense multiple history entries for the same day into a single one
*/ */
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const _ = require('lodash'); const _ = require('lodash');
const moment = require('moment'); const moment = require('moment');
@@ -44,7 +44,7 @@ function updateChallengeHabits (habits) {
if (!habits || habits.length === 0) { if (!habits || habits.length === 0) {
console.warn('All appropriate challenge habits found and modified.'); console.warn('All appropriate challenge habits found and modified.');
displayData(); displayData();
return; return null;
} }
const habitsPromises = habits.map(updateChallengeHabit); const habitsPromises = habits.map(updateChallengeHabit);
@@ -55,7 +55,7 @@ function updateChallengeHabits (habits) {
} }
function updateChallengeHabit (habit) { function updateChallengeHabit (habit) {
count++; count += 1;
if (habit && habit.history && habit.history.length > 0) { if (habit && habit.history && habit.history.length > 0) {
// First remove missing entries // First remove missing entries
@@ -75,8 +75,8 @@ function updateChallengeHabit (habit) {
entry.scoreDirection = entry.value > previousValue ? 'up' : 'down'; entry.scoreDirection = entry.value > previousValue ? 'up' : 'down';
} }
}) })
.groupBy(entry => // group entries by aggregateBy // group entries by aggregateBy
moment(entry.date).format('YYYYMMDD')) .groupBy(entry => moment(entry.date).format('YYYYMMDD'))
.toPairs() // [key, entry] .toPairs() // [key, entry]
.sortBy(([key]) => key) // sort by date .sortBy(([key]) => key) // sort by date
.map(keyEntryPair => { .map(keyEntryPair => {
@@ -111,6 +111,7 @@ function updateChallengeHabit (habit) {
} }
if (count % progressCount === 0) console.warn(`${count} habits processed`); if (count % progressCount === 0) console.warn(`${count} habits processed`);
return null;
} }
function displayData () { function displayData () {
@@ -119,9 +120,10 @@ function displayData () {
} }
function exiting (code, msg) { function exiting (code, msg) {
code = code || 0; // 0 = success // 0 = success
code = code || 0; // eslint-disable-line no-param-reassign
if (code && !msg) { if (code && !msg) {
msg = 'ERROR!'; msg = 'ERROR!'; // eslint-disable-line no-param-reassign
} }
if (msg) { if (msg) {
if (code) { if (code) {

View File

@@ -3,10 +3,10 @@ const authorName = 'paglias'; // in case script author needs to know when their
const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is done const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is done
/* /*
* Iterates over all habits and condense multiple history entries for the same day into a single entry * Iterates over all habits and condense multiple history entries for the same day into a single one
*/ */
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const _ = require('lodash'); const _ = require('lodash');
const moment = require('moment'); const moment = require('moment');
@@ -44,7 +44,7 @@ function updateUsers (users) {
if (!users || users.length === 0) { if (!users || users.length === 0) {
console.warn('All appropriate users and their tasks found and modified.'); console.warn('All appropriate users and their tasks found and modified.');
displayData(); displayData();
return; return null;
} }
const usersPromises = users.map(updateUser); const usersPromises = users.map(updateUser);
@@ -110,10 +110,12 @@ function updateHabit (habit, timezoneOffset, dayStart) {
$set: { history: habit.history }, $set: { history: habit.history },
}); });
} }
return null;
} }
function updateUser (user) { function updateUser (user) {
count++; count += 1;
const { timezoneOffset } = user.preferences; const { timezoneOffset } = user.preferences;
const { dayStart } = user.preferences; const { dayStart } = user.preferences;
@@ -141,9 +143,10 @@ function displayData () {
} }
function exiting (code, msg) { function exiting (code, msg) {
code = code || 0; // 0 = success // 0 = success
code = code || 0; // eslint-disable-line no-param-reassign
if (code && !msg) { if (code && !msg) {
msg = 'ERROR!'; msg = 'ERROR!'; // eslint-disable-line no-param-reassign
} }
if (msg) { if (msg) {
if (code) { if (code) {

View File

@@ -3,10 +3,11 @@ const authorName = 'Sabe'; // in case script author needs to know when their ...
const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done
/* /*
* Iterates over all tasks and sets invalid everyX values (less than 0 or more than 9999 or not an int) field to 0 * Iterates over all tasks and sets invalid everyX values
* (less than 0 or more than 9999 or not an int) field to 0
*/ */
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true';
const dbTasks = monk(connectionString).get('tasks', { castIds: false }); const dbTasks = monk(connectionString).get('tasks', { castIds: false });
@@ -49,7 +50,7 @@ function updateTasks (tasks) {
if (!tasks || tasks.length === 0) { if (!tasks || tasks.length === 0) {
console.warn('All appropriate tasks found and modified.'); console.warn('All appropriate tasks found and modified.');
displayData(); displayData();
return; return null;
} }
const taskPromises = tasks.map(updatetask); const taskPromises = tasks.map(updatetask);
@@ -60,7 +61,7 @@ function updateTasks (tasks) {
} }
function updatetask (task) { function updatetask (task) {
count++; count += 1;
const set = { everyX: 0 }; const set = { everyX: 0 };
dbTasks.update({ _id: task._id }, { $set: set }); dbTasks.update({ _id: task._id }, { $set: set });
@@ -75,9 +76,10 @@ function displayData () {
} }
function exiting (code, msg) { function exiting (code, msg) {
code = code || 0; // 0 = success // 0 = success
code = code || 0; // eslint-disable-line no-param-reassign
if (code && !msg) { if (code && !msg) {
msg = 'ERROR!'; msg = 'ERROR!'; // eslint-disable-line no-param-reassign
} }
if (msg) { if (msg) {
if (code) { if (code) {

View File

@@ -5,7 +5,7 @@
* Iterates over all tasks and sets the yseterDaily field to True * Iterates over all tasks and sets the yseterDaily field to True
*/ */
import monk from 'monk'; import monk from 'monk'; // eslint-disable-line import/no-extraneous-dependencies
const authorName = 'TheHollidayInn'; // in case script author needs to know when their ... const authorName = 'TheHollidayInn'; // in case script author needs to know when their ...
const authorUuid = ''; const authorUuid = '';
@@ -17,9 +17,10 @@ const progressCount = 1000;
let count = 0; let count = 0;
function exiting (code, msg) { function exiting (code, msg) {
code = code || 0; // 0 = success // 0 = success
code = code || 0; // eslint-disable-line no-param-reassign
if (code && !msg) { if (code && !msg) {
msg = 'ERROR!'; msg = 'ERROR!'; // eslint-disable-line no-param-reassign
} }
if (msg) { if (msg) {
if (code) { if (code) {
@@ -37,7 +38,7 @@ function displayData () {
} }
function updatetask (task) { function updatetask (task) {
count++; count += 1;
const set = { yesterDaily: true }; const set = { yesterDaily: true };
dbTasks.update({ _id: task._id }, { $set: set }); dbTasks.update({ _id: task._id }, { $set: set });
@@ -50,15 +51,14 @@ function updateTasks (tasks) {
if (!tasks || tasks.length === 0) { if (!tasks || tasks.length === 0) {
console.warn('All appropriate tasks found and modified.'); console.warn('All appropriate tasks found and modified.');
displayData(); displayData();
return; return null;
} }
const taskPromises = tasks.map(updatetask); const taskPromises = tasks.map(updatetask);
const lasttask = tasks[tasks.length - 1]; const lasttask = tasks[tasks.length - 1];
return Promise.all(taskPromises) return Promise.all(taskPromises)
.then(() => processTasks(lasttask._id), // eslint-disable-line no-use-before-define .then(() => processTasks(lasttask._id)); // eslint-disable-line no-use-before-define
);
} }
function processTasks (lastId) { function processTasks (lastId) {
@@ -76,7 +76,9 @@ function processTasks (lastId) {
dbTasks.find(query, { dbTasks.find(query, {
sort: { _id: 1 }, sort: { _id: 1 },
limit: 250, limit: 250,
fields: [ // specify fields we are interested in to limit retrieved data (empty if we're not reading data): // specify fields we are interested in to limit retrieved data
// (empty if we're not reading data):
fields: [
], ],
}) })
.then(updateTasks) .then(updateTasks)

View File

@@ -8,7 +8,7 @@ let authorUuid = ''; // ... own data is done
* This migraition will copy user data from prod to test * This migraition will copy user data from prod to test
*/ */
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const connectionString = ''; const connectionString = '';
const Users = monk(connectionString).get('users', { castIds: false }); const Users = monk(connectionString).get('users', { castIds: false });

View File

@@ -8,7 +8,7 @@ const authorUuid = ''; // ... own data is done
* This migraition will copy user data from prod to test * This migraition will copy user data from prod to test
*/ */
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const connectionString = 'mongodb://localhost/new-habit'; const connectionString = 'mongodb://localhost/new-habit';
const Users = monk(connectionString).get('users', { castIds: false }); const Users = monk(connectionString).get('users', { castIds: false });
@@ -26,9 +26,11 @@ function getAchievementUpdate (newUser, oldUser) {
if (!achievementsUpdate.ultimateGearSets && oldAchievements.ultimateGearSets) { if (!achievementsUpdate.ultimateGearSets && oldAchievements.ultimateGearSets) {
achievementsUpdate.ultimateGearSets = oldAchievements.ultimateGearSets; achievementsUpdate.ultimateGearSets = oldAchievements.ultimateGearSets;
} else if (oldAchievements.ultimateGearSets) { } else if (oldAchievements.ultimateGearSets) {
for (const index in oldAchievements.ultimateGearSets) { Object.keys(oldAchievements.ultimateGearSets).forEach(index => {
if (oldAchievements.ultimateGearSets[index]) achievementsUpdate.ultimateGearSets[index] = true; if (oldAchievements.ultimateGearSets[index]) {
} achievementsUpdate.ultimateGearSets[index] = true;
}
});
} }
// challenges // challenges
@@ -38,35 +40,37 @@ function getAchievementUpdate (newUser, oldUser) {
// Quests // Quests
if (!achievementsUpdate.quests) achievementsUpdate.quests = {}; if (!achievementsUpdate.quests) achievementsUpdate.quests = {};
for (const index in oldAchievements.quests) { Object.keys(oldAchievements.quests).forEach(index => {
if (!achievementsUpdate.quests[index]) { if (!achievementsUpdate.quests[index]) {
achievementsUpdate.quests[index] = oldAchievements.quests[index]; achievementsUpdate.quests[index] = oldAchievements.quests[index];
} else { } else {
achievementsUpdate.quests[index] += oldAchievements.quests[index]; achievementsUpdate.quests[index] += oldAchievements.quests[index];
} }
} });
// Rebirth level // Rebirth level
if (achievementsUpdate.rebirthLevel) { if (achievementsUpdate.rebirthLevel) {
achievementsUpdate.rebirthLevel = Math.max(achievementsUpdate.rebirthLevel, oldAchievements.rebirthLevel); achievementsUpdate.rebirthLevel = Math.max(
achievementsUpdate.rebirthLevel, oldAchievements.rebirthLevel,
);
} else if (oldAchievements.rebirthLevel) { } else if (oldAchievements.rebirthLevel) {
achievementsUpdate.rebirthLevel = oldAchievements.rebirthLevel; achievementsUpdate.rebirthLevel = oldAchievements.rebirthLevel;
} }
// All others // All others
const indexsToIgnore = ['ultimateGearSets', 'challenges', 'quests', 'rebirthLevel']; const indexsToIgnore = ['ultimateGearSets', 'challenges', 'quests', 'rebirthLevel'];
for (const index in oldAchievements) { Object.keys(oldAchievements).forEach(index => {
if (indexsToIgnore.indexOf(index) !== -1) continue; // eslint-disable-line no-continue if (indexsToIgnore.indexOf(index) !== -1) return;
if (!achievementsUpdate[index]) { if (!achievementsUpdate[index]) {
achievementsUpdate[index] = oldAchievements[index]; achievementsUpdate[index] = oldAchievements[index];
continue; // eslint-disable-line no-continue return;
} }
if (Number.isInteger(oldAchievements[index])) { if (Number.isInteger(oldAchievements[index])) {
achievementsUpdate[index] += oldAchievements[index]; achievementsUpdate[index] += oldAchievements[index];
} else if (oldAchievements[index] === true) achievementsUpdate[index] = true; } else if (oldAchievements[index] === true) achievementsUpdate[index] = true;
} });
return achievementsUpdate; return achievementsUpdate;
} }
@@ -75,9 +79,7 @@ module.exports = async function achievementRestore () {
const userIds = [ const userIds = [
]; ];
/* eslint-disable no-await-in-loop */ Promise.all(userIds.map(userId => (async () => {
for (const index in userIds) {
const userId = userIds[index];
const oldUser = await UsersOld.findOne({ _id: userId }, 'achievements'); const oldUser = await UsersOld.findOne({ _id: userId }, 'achievements');
const newUser = await Users.findOne({ _id: userId }, 'achievements'); const newUser = await Users.findOne({ _id: userId }, 'achievements');
const achievementUpdate = getAchievementUpdate(newUser, oldUser); const achievementUpdate = getAchievementUpdate(newUser, oldUser);
@@ -90,6 +92,5 @@ module.exports = async function achievementRestore () {
}, },
); );
console.log(`Updated ${userId}`); console.log(`Updated ${userId}`);
/* eslint-enable no-await-in-loop */ })()));
}
}; };

View File

@@ -12,7 +12,7 @@ const progressCount = 1000;
let count = 0; let count = 0;
async function updateUser (user) { async function updateUser (user) {
count++; count += 1;
if (count % progressCount === 0) console.warn(`${count} ${user._id}`); if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
@@ -22,7 +22,7 @@ async function updateUser (user) {
[{ name: 'BASE_URL', content: BASE_URL }], // Add variables from template [{ name: 'BASE_URL', content: BASE_URL }], // Add variables from template
); );
return await User.update({ _id: user._id }, { $set: { migration: MIGRATION_NAME } }).exec(); return User.update({ _id: user._id }, { $set: { migration: MIGRATION_NAME } }).exec();
} }
module.exports = async function processUsers () { module.exports = async function processUsers () {

View File

@@ -15,7 +15,7 @@ let count = 0;
*/ */
async function updateUser (user) { async function updateUser (user) {
count++; count += 1;
const set = {}; const set = {};
@@ -48,7 +48,7 @@ async function updateUser (user) {
if (count % progressCount === 0) console.warn(`${count} ${user._id}`); if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
return await User.update({ _id: user._id }, { $set: set }).exec(); return User.update({ _id: user._id }, { $set: set }).exec();
} }
module.exports = async function processUsers () { module.exports = async function processUsers () {

View File

@@ -9,7 +9,7 @@ const progressCount = 1000;
let count = 0; let count = 0;
async function updateUser (user) { async function updateUser (user) {
count++; count += 1;
const addToSet = { const addToSet = {
'purchased.plan.mysteryItems': { 'purchased.plan.mysteryItems': {
@@ -30,7 +30,7 @@ async function updateUser (user) {
if (count % progressCount === 0) console.warn(`${count} ${user._id}`); if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
return await User.update({ _id: user._id }, { $set: set, $push: push, $addToSet: addToSet }).exec(); return User.update({ _id: user._id }, { $set: set, $push: push, $addToSet: addToSet }).exec();
} }
module.exports = async function processUsers () { module.exports = async function processUsers () {

View File

@@ -9,7 +9,7 @@ const progressCount = 1000;
let count = 0; let count = 0;
async function updateUser (user) { async function updateUser (user) {
count++; count *= 1;
const inc = { const inc = {
'items.food.Pie_Skeleton': 1, 'items.food.Pie_Skeleton': 1,
@@ -36,7 +36,9 @@ async function updateUser (user) {
if (count % progressCount === 0) console.warn(`${count} ${user._id}`); if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
return await User.update({ _id: user._id }, { $inc: inc, $set: set, $push: { pinnedItems: { $each: push } } }).exec(); return User
.update({ _id: user._id }, { $inc: inc, $set: set, $push: { pinnedItems: { $each: push } } })
.exec();
} }
module.exports = async function processUsers () { module.exports = async function processUsers () {

View File

@@ -7,7 +7,7 @@ const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is do
*/ */
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const dbUsers = monk(connectionString).get('users', { castIds: false }); const dbUsers = monk(connectionString).get('users', { castIds: false });
@@ -45,7 +45,7 @@ function updateUsers (users) {
if (!users || users.length === 0) { if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.'); console.warn('All appropriate users found and modified.');
displayData(); displayData();
return; return null;
} }
const userPromises = users.map(updateUser); const userPromises = users.map(updateUser);
@@ -58,7 +58,7 @@ function updateUsers (users) {
} }
function updateUser (user) { function updateUser (user) {
count++; count *= 1;
const isFacebook = user.auth.facebook && user.auth.facebook.id; const isFacebook = user.auth.facebook && user.auth.facebook.id;
const isGoogle = user.auth.google && user.auth.google.id; const isGoogle = user.auth.google && user.auth.google.id;
@@ -93,9 +93,10 @@ function displayData () {
} }
function exiting (code, msg) { function exiting (code, msg) {
code = code || 0; // 0 = success // 0 = success
code = code || 0; // eslint-disable-line no-param-reassign
if (code && !msg) { if (code && !msg) {
msg = 'ERROR!'; msg = 'ERROR!'; // eslint-disable-line no-param-reassign
} }
if (msg) { if (msg) {
if (code) { if (code) {

View File

@@ -9,7 +9,7 @@ const progressCount = 1000;
let count = 0; let count = 0;
async function updateUser (user) { async function updateUser (user) {
count++; count += 1;
const set = {}; const set = {};
let push; let push;
@@ -41,9 +41,9 @@ async function updateUser (user) {
if (count % progressCount === 0) console.warn(`${count} ${user._id}`); if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
if (push) { if (push) {
return await User.update({ _id: user._id }, { $set: set, $push: push }).exec(); return User.update({ _id: user._id }, { $set: set, $push: push }).exec();
} }
return await User.update({ _id: user._id }, { $set: set }).exec(); return User.update({ _id: user._id }, { $set: set }).exec();
} }
module.exports = async function processUsers () { module.exports = async function processUsers () {

View File

@@ -10,7 +10,7 @@ let authorUuid = ''; // ... own data is done
import uniq from 'lodash/uniq'; import uniq from 'lodash/uniq';
const monk = require('monk'); const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const testConnectionSting = ''; // FOR TEST DATABASE const testConnectionSting = ''; // FOR TEST DATABASE
const usersTest = monk(testConnectionSting).get('users', { castIds: false }); const usersTest = monk(testConnectionSting).get('users', { castIds: false });
@@ -18,7 +18,7 @@ const groupsTest = monk(testConnectionSting).get('groups', { castIds: false });
const challengesTest = monk(testConnectionSting).get('challenges', { castIds: false }); const challengesTest = monk(testConnectionSting).get('challenges', { castIds: false });
const tasksTest = monk(testConnectionSting).get('tasks', { castIds: false }); const tasksTest = monk(testConnectionSting).get('tasks', { castIds: false });
const monk2 = require('monk'); const monk2 = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
const liveConnectString = ''; // FOR TEST DATABASE const liveConnectString = ''; // FOR TEST DATABASE
const userLive = monk2(liveConnectString).get('users', { castIds: false }); const userLive = monk2(liveConnectString).get('users', { castIds: false });

View File

@@ -1,5 +1,4 @@
const { MongoClient } = require('mongodb'); // eslint-disable-line import/no-extraneous-dependencies
const { MongoClient } = require('mongodb');
const logger = require('./logger'); const logger = require('./logger');
let dbConnection; let dbConnection;
@@ -16,7 +15,7 @@ function connectToDb (dbUri) {
logger.success(`Connected to ${dbUri}`); logger.success(`Connected to ${dbUri}`);
resolve(database); return resolve(database);
}); });
}); });
} }

View File

@@ -1,9 +1,10 @@
const chalk = require('chalk'); // eslint-disable-line import/no-extraneous-dependencies
const chalk = require('chalk');
function loggerGenerator (type, color) { function loggerGenerator (type, color) {
return function logger () { return function logger () {
const args = Array.from(arguments).map(arg => chalk[color](arg)); const args = Array
.from(arguments) // eslint-disable-line prefer-rest-params
.map(arg => chalk[color](arg));
console[type].apply(null, args); console[type].apply(null, args);
}; };
} }

View File

@@ -1,9 +1,7 @@
const logger = require('./logger'); const logger = require('./logger');
class Timer { class Timer {
constructor (options) { constructor (options = {}) {
options = options || {};
const warningThreshold = options.minutesWarningThreshold || 10; const warningThreshold = options.minutesWarningThreshold || 10;
this.count = 0; this.count = 0;
@@ -14,7 +12,7 @@ class Timer {
start () { start () {
this._internalTimer = setInterval(() => { this._internalTimer = setInterval(() => {
this.count++; this.count *= 1;
const shouldWarn = this._minutesWarningThreshold < this.count; const shouldWarn = this._minutesWarningThreshold < this.count;
const logStyle = shouldWarn ? 'error' : 'warn'; const logStyle = shouldWarn ? 'error' : 'warn';

View File

@@ -1,4 +1,3 @@
function unique (array) { function unique (array) {
return Array.from(new Set(array)); return Array.from(new Set(array));
} }

View File

@@ -72,7 +72,7 @@
"npm": "^6" "npm": "^6"
}, },
"scripts": { "scripts": {
"lint": "eslint --ext .js ./website/common --fix", "lint": "eslint --ext .js ./migrations --fix",
"test": "npm run lint && gulp test && gulp apidoc", "test": "npm run lint && gulp test && gulp apidoc",
"test:build": "gulp test:prepare:build", "test:build": "gulp test:prepare:build",
"test:api-v3": "gulp test:api-v3", "test:api-v3": "gulp test:api-v3",

View File

@@ -1,11 +1,7 @@
{ {
"extends": [ "extends": [
"habitrpg/mocha", "habitrpg/lib/mocha",
"habitrpg/esnext"
], ],
"env": {
"node": true,
},
"globals": { "globals": {
"_": true, "_": true,
} }

View File

@@ -1,11 +0,0 @@
{
"env": {
"node": true,
"browser": true,
},
"extends": [
"habitrpg/browser",
"habitrpg/mocha",
"habitrpg/esnext",
],
}