Upgrade tests tools and lint migrations and scripts (part 2) (#9998)

* upgrade gulp-babel

* upgrade babel-eslint

* upgrade eslint-friendly-formatter

* start upgrading chai

* start to upgrade eslint

* restore skipped tests

* start to upgrqde monk

* fix linting and remove unused file

* fix mocha notifications, and common tests

* fix unit tests

* start to fix initrgration tests

* more integration tests fixes

* upgrade monk to latest version

* lint /scripts

* migrations: start moving to /archive unused migrations and run eslint with --fix

* lint migrations

* fix more integration tests

* fix test
This commit is contained in:
Matteo Pagliazzi
2018-02-17 18:11:24 +01:00
committed by GitHub
parent b0ae0ef4da
commit 74ba55c20b
362 changed files with 8041 additions and 7813 deletions

View File

@@ -1,17 +1,17 @@
/*
const migrationName = 'AchievementRestore';
const authorName = 'TheHollidayInn'; // in case script author needs to know when their ...
const authorUuid = ''; //... own data is done
const authorUuid = ''; // ... own data is done
*/
/*
* This migraition will copy user data from prod to test
*/
import Bluebird from 'bluebird';
const monk = require('monk');
const connectionString = 'mongodb://localhost/new-habit';
const Users = monk(connectionString).get('users', { castIds: false });
const monkOld = require('monk');
const oldConnectionSting = 'mongodb://localhost/old-habit';
const UsersOld = monk(oldConnectionSting).get('users', { castIds: false });
@@ -52,21 +52,19 @@ function getAchievementUpdate (newUser, oldUser) {
achievementsUpdate.rebirthLevel = oldAchievements.rebirthLevel;
}
//All others
// All others
const indexsToIgnore = ['ultimateGearSets', 'challenges', 'quests', 'rebirthLevel'];
for (let index in oldAchievements) {
if (indexsToIgnore.indexOf(index) !== -1) continue;
if (indexsToIgnore.indexOf(index) !== -1) continue; // eslint-disable-line no-continue
if (!achievementsUpdate[index]) {
achievementsUpdate[index] = oldAchievements[index];
continue;
continue; // eslint-disable-line no-continue
}
if (Number.isInteger(oldAchievements[index])) {
achievementsUpdate[index] += oldAchievements[index];
} else {
if (oldAchievements[index] === true) achievementsUpdate[index] = true;
}
} else if (oldAchievements[index] === true) achievementsUpdate[index] = true;
}
return achievementsUpdate;
@@ -77,6 +75,7 @@ module.exports = async function achievementRestore () {
];
for (let index in userIds) {
/* eslint-disable no-await-in-loop */
const userId = userIds[index];
const oldUser = await UsersOld.findOne({_id: userId}, 'achievements');
const newUser = await Users.findOne({_id: userId}, 'achievements');
@@ -85,9 +84,10 @@ module.exports = async function achievementRestore () {
{_id: userId},
{
$set: {
'achievements': achievementUpdate,
achievements: achievementUpdate,
},
});
console.log(`Updated ${userId}`);
/* eslint-enable no-await-in-loop */
}
};