* fix: remove circular dependency redux depended on templates/Challenges/redux and vice versa. This meant that import order mattered and confusing bugs could arise. (cherry picked from commit 7d67a4e70922bbb3051f2f9982dcc69e240d43dc) * feat: require imports to be in alphabetical order Import order generally does not matter, but there are edge cases (circular imports and css imports, for example) where changing order changes behaviour (cherry picked from commit b8d1393a91ec6e068caf8e8498a5c95df68c2b2c) * chore: order imports * fix: lift up challenge description + title comps This brings the classic Show closer to the others as they now all create the description and title components * fix: remove donation-saga/index circular import (cherry picked from commit 51a44ca668a700786d2744feffeae4fdba5fd207) * refactor: extract action-types from settings (cherry picked from commit 25e26124d691c84a0d0827d41dafb761c686fadd) * fix: lint errors * feat: prevent useless renames
204 lines
4.8 KiB
JavaScript
204 lines
4.8 KiB
JavaScript
const path = require('path');
|
|
const debug = require('debug');
|
|
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });
|
|
const { MongoClient, ObjectId } = require('mongodb');
|
|
const defaultUserImage = require('../../../config/misc').defaultUserImage;
|
|
const fullyCertifiedUser = require('./certifiedUserData');
|
|
|
|
const envVariables = process.argv;
|
|
|
|
const log = debug('fcc:tools:seedLocalAuthUser');
|
|
const { MONGOHQ_URL } = process.env;
|
|
|
|
function handleError(err, client) {
|
|
if (err) {
|
|
console.error('Oh noes!! Error seeding local auth user.');
|
|
console.error(err);
|
|
try {
|
|
client.close();
|
|
} catch (e) {
|
|
// no-op
|
|
} finally {
|
|
/* eslint-disable-next-line no-process-exit */
|
|
process.exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* eslint-disable max-len */
|
|
const authUser = {
|
|
_id: ObjectId('5bd30e0f1caf6ac3ddddddb5'),
|
|
email: 'foo@bar.com',
|
|
emailVerified: true,
|
|
progressTimestamps: [],
|
|
isBanned: false,
|
|
isCheater: false,
|
|
username: 'developmentuser',
|
|
about: '',
|
|
name: 'Development User',
|
|
location: '',
|
|
picture: defaultUserImage,
|
|
acceptedPrivacyTerms: true,
|
|
sendQuincyEmail: false,
|
|
currentChallengeId: '',
|
|
isHonest: false,
|
|
isFrontEndCert: false,
|
|
isDataVisCert: false,
|
|
isBackEndCert: false,
|
|
isFullStackCert: false,
|
|
isRespWebDesignCert: false,
|
|
is2018DataVisCert: false,
|
|
isFrontEndLibsCert: false,
|
|
isJsAlgoDataStructCert: false,
|
|
isApisMicroservicesCert: false,
|
|
isInfosecQaCert: false,
|
|
isQaCertV7: false,
|
|
isInfosecCertV7: false,
|
|
is2018FullStackCert: false,
|
|
isSciCompPyCertV7: false,
|
|
isDataAnalysisPyCertV7: false,
|
|
isMachineLearningPyCertV7: false,
|
|
completedChallenges: [],
|
|
portfolio: [],
|
|
yearsTopContributor: envVariables.includes('--top-contributor')
|
|
? ['2017', '2018', '2019']
|
|
: [],
|
|
rand: 0.6126749173148205,
|
|
theme: 'default',
|
|
profileUI: {
|
|
isLocked: true,
|
|
showAbout: false,
|
|
showCerts: false,
|
|
showDonation: false,
|
|
showHeatMap: false,
|
|
showLocation: false,
|
|
showName: false,
|
|
showPoints: false,
|
|
showPortfolio: false,
|
|
showTimeLine: false
|
|
},
|
|
badges: {
|
|
coreTeam: []
|
|
},
|
|
isDonating: envVariables.includes('--donor'),
|
|
emailAuthLinkTTL: null,
|
|
emailVerifyTTL: null
|
|
};
|
|
const blankUser = {
|
|
_id: ObjectId('5bd30e0f1caf6ac3ddddddb9'),
|
|
email: 'bar@bar.com',
|
|
emailVerified: true,
|
|
progressTimestamps: [],
|
|
isBanned: false,
|
|
isCheater: false,
|
|
username: 'twaha',
|
|
about: '',
|
|
name: 'Development User',
|
|
location: '',
|
|
picture: defaultUserImage,
|
|
acceptedPrivacyTerms: true,
|
|
sendQuincyEmail: false,
|
|
currentChallengeId: '',
|
|
isHonest: false,
|
|
isFrontEndCert: false,
|
|
isDataVisCert: false,
|
|
isBackEndCert: false,
|
|
isFullStackCert: false,
|
|
isRespWebDesignCert: false,
|
|
is2018DataVisCert: false,
|
|
isFrontEndLibsCert: false,
|
|
isJsAlgoDataStructCert: false,
|
|
isApisMicroservicesCert: false,
|
|
isInfosecQaCert: false,
|
|
isQaCertV7: false,
|
|
isInfosecCertV7: false,
|
|
is2018FullStackCert: false,
|
|
isSciCompPyCertV7: false,
|
|
isDataAnalysisPyCertV7: false,
|
|
isMachineLearningPyCertV7: false,
|
|
completedChallenges: [],
|
|
portfolio: [],
|
|
yearsTopContributor: [],
|
|
rand: 0.6126749173148205,
|
|
theme: 'default',
|
|
profileUI: {
|
|
isLocked: true,
|
|
showAbout: false,
|
|
showCerts: false,
|
|
showDonation: false,
|
|
showHeatMap: false,
|
|
showLocation: false,
|
|
showName: false,
|
|
showPoints: false,
|
|
showPortfolio: false,
|
|
showTimeLine: false
|
|
},
|
|
badges: {
|
|
coreTeam: []
|
|
},
|
|
isDonating: false,
|
|
emailAuthLinkTTL: null,
|
|
emailVerifyTTL: null
|
|
};
|
|
|
|
MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, (err, client) => {
|
|
handleError(err, client);
|
|
|
|
log('Connected successfully to mongo');
|
|
|
|
const db = client.db('freecodecamp');
|
|
const user = db.collection('user');
|
|
|
|
if (process.argv[2] === 'certUser') {
|
|
user.deleteMany(
|
|
{
|
|
_id: {
|
|
$in: [
|
|
ObjectId('5fa2db00a25c1c1fa49ce067'),
|
|
ObjectId('5bd30e0f1caf6ac3ddddddb5'),
|
|
ObjectId('5bd30e0f1caf6ac3ddddddb9')
|
|
]
|
|
}
|
|
},
|
|
err => {
|
|
handleError(err, client);
|
|
|
|
try {
|
|
user.insertOne(fullyCertifiedUser);
|
|
user.insertOne(blankUser);
|
|
} catch (e) {
|
|
handleError(e, client);
|
|
} finally {
|
|
log('local auth user seed complete');
|
|
client.close();
|
|
}
|
|
}
|
|
);
|
|
} else {
|
|
user.deleteMany(
|
|
{
|
|
_id: {
|
|
$in: [
|
|
ObjectId('5fa2db00a25c1c1fa49ce067'),
|
|
ObjectId('5bd30e0f1caf6ac3ddddddb5'),
|
|
ObjectId('5bd30e0f1caf6ac3ddddddb9')
|
|
]
|
|
}
|
|
},
|
|
err => {
|
|
handleError(err, client);
|
|
|
|
try {
|
|
user.insertOne(authUser);
|
|
user.insertOne(blankUser);
|
|
} catch (e) {
|
|
handleError(e, client);
|
|
} finally {
|
|
log('local auth user seed complete');
|
|
client.close();
|
|
}
|
|
}
|
|
);
|
|
}
|
|
});
|