Upgrade to mongoose 7 (#14971)

* remove some unused dependencies

* update mongoose version

* make common tests pass

* Make unit tests pass

* make api v3 integration tests pass

* fix lint issues

* fix issue with package-lock

* fix(lint): we don't need no .js

* fix(lint): update to latest config-habitrpg

* chore(npm): update package locks

* fix(test): replace deprecated fn

* chore(package): update eslint-habitrpg again

* fix(lint): server linting

* fix(lint): client linting

* fix(client): correct mangled common imports

* chore(npm): update package-locks

* fix(lint): punctuation, module

---------

Co-authored-by: SabreCat <sabrecat@gmail.com>
Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
Phillip Thelen
2024-01-16 22:18:47 +01:00
committed by GitHub
parent d0e4b533e3
commit f8d315ff6e
189 changed files with 2645 additions and 1423 deletions

View File

@@ -1,5 +1,7 @@
/* eslint-disable import/no-commonjs */
module.exports = {
extends: [
"habitrpg/lib/node",
]
}
'habitrpg/lib/node',
],
};

View File

@@ -15,10 +15,8 @@ import * as wonderconGear from './special-wondercon';
import t from '../../../translation';
import { getClassName } from '../../../../libs/getClassName';
const CURRENT_EVENT = find(
EVENTS, event => moment().isBetween(event.start, event.end)
&& ['winter', 'spring', 'summer', 'fall'].includes(event.season),
);
const CURRENT_EVENT = find(EVENTS, event => moment().isBetween(event.start, event.end)
&& ['winter', 'spring', 'summer', 'fall'].includes(event.season));
const gearEvents = pickBy(EVENTS, event => event.gear);

View File

@@ -3,9 +3,8 @@ import moment from 'moment';
import { EVENTS } from '../constants/events';
import t from '../translation';
const CURRENT_EVENT = find(
EVENTS, event => moment().isBetween(event.start, event.end) && Boolean(event.season),
);
const CURRENT_EVENT = find(EVENTS, event => moment()
.isBetween(event.start, event.end) && Boolean(event.season));
const QUEST_SEASONAL = {
// winter

View File

@@ -48,9 +48,13 @@ function calculateBonus (value, stat, critVal = 1, statScale = 0.5) {
}
export function stealthBuffsToAdd (user) {
return Math.ceil(diminishingReturns(
statsComputed(user).per, user.tasksOrder.dailys.length * 0.64, 55,
));
return Math.ceil(
diminishingReturns(
statsComputed(user).per,
user.tasksOrder.dailys.length * 0.64,
55,
),
);
}
const spells = {};

View File

@@ -257,7 +257,7 @@ export function getPlanMonths (plan) {
// (which doesn't matter because we don't need to reapply perks
// for them and by this point they should have expired anyway)
if (!plan.planId) return 1;
const planIdRegExp = new RegExp('_([0-9]+)mo'); // e.g., matches 'google_6mo' / 'basic_12mo' and captures '6' / '12'
const planIdRegExp = /_([0-9]+)mo/; // e.g., matches 'google_6mo' / 'basic_12mo' and captures '6' / '12'
const match = plan.planId.match(planIdRegExp);
if (match !== null && match[0] !== null) {
// 3 for 3-month recurring subscription, etc

View File

@@ -57,7 +57,8 @@ export default function randomDrop (user, options, req = {}, analytics) {
// +50% per checklist item complete. TODO: make this into X individual drop chances instead
* (user._tmp.crit || 1)
* (1 + 0.5 * (reduce(
task.checklist, (m, i) => m + (i.completed ? 1 : 0), // eslint-disable-line indent
task.checklist,
(m, i) => m + (i.completed ? 1 : 0), // eslint-disable-line indent
0,
) || 0)); // eslint-disable-line indent
chance = diminishingReturns(chance, 0.75);

View File

@@ -5,7 +5,7 @@ import _template from 'lodash/template';
import messages from '../errors/commonErrorMessages';
export default function (msgKey, vars = {}) {
export default function errorMessage (msgKey, vars = {}) {
const message = messages[msgKey];
if (!message) throw new Error(`Error processing the common message "${msgKey}".`);

View File

@@ -6,10 +6,8 @@ import {
SEASONAL_SETS,
} from '../content/constants';
const CURRENT_EVENT = find(
EVENTS, event => moment().isBetween(event.start, event.end)
&& ['winter', 'spring', 'summer', 'fall'].includes(event.season),
);
const CURRENT_EVENT = find(EVENTS, event => moment().isBetween(event.start, event.end)
&& ['winter', 'spring', 'summer', 'fall'].includes(event.season));
export default {
opened: CURRENT_EVENT,

View File

@@ -405,8 +405,11 @@ shops.getTimeTravelersCategories = function getTimeTravelersCategories (user, la
const flatGearArray = toArray(content.gear.flat);
shops.getSeasonalGearBySet = function getSeasonalGearBySet (
user, set, officialPinnedItems,
language, ignoreAlreadyOwned = false,
user,
set,
officialPinnedItems,
language,
ignoreAlreadyOwned = false,
) {
return flatGearArray.filter(gear => {
if (!ignoreAlreadyOwned && user.items.gear.owned[gear.key] !== undefined) return false;

View File

@@ -22,7 +22,10 @@ import { BuyHourglassMountOperation } from './buyMount';
// @TODO: when we are sure buy is the only function used, let's move the buy files to a folder
export default async function buy (
user, req = {}, analytics, options = { quantity: 1, hourglass: false },
user,
req = {},
analytics,
options = { quantity: 1, hourglass: false },
) {
const key = get(req, 'params.key');
const { hourglass } = options;

View File

@@ -249,7 +249,7 @@ export default function scoreTask (options = {}, req = {}, analytics) {
// Thanks to open group tasks, userId is not guaranteed. Don't allow scoring inaccessible tasks
if (task.userId && task.userId !== user._id) {
throw new BadRequest('Cannot score task belonging to another user.');
} else if (task.group.id && user.guilds.indexOf(task.group.id) === -1
} else if (task.group && task.group.id && user.guilds.indexOf(task.group.id) === -1
&& user.party._id !== task.group.id) {
throw new BadRequest('Cannot score task belonging to another user.');
}

View File

@@ -1,8 +1,10 @@
export default async function updateUserBalance (user,
export default async function updateUserBalance (
user,
amount,
transactionType,
reference,
referenceText) {
referenceText,
) {
if (user.constructor.name === 'model') {
await user.updateBalance(amount, transactionType, reference, referenceText);
} else {

View File

@@ -1,14 +1,18 @@
export default async function updateUserHourglasses (user,
export default async function updateUserHourglasses (
user,
amount,
transactionType,
reference,
referenceText) {
referenceText,
) {
if (user.constructor.name === 'model') {
await user.purchased.plan.updateHourglasses(user._id,
await user.purchased.plan.updateHourglasses(
user._id,
amount,
transactionType,
reference,
referenceText);
referenceText,
);
} else {
user.purchased.plan.consecutive.trinkets += amount;
}