chore(tools): update mongodb in seed script (#50519)

This commit is contained in:
Oliver Eyton-Williams
2023-05-25 23:13:37 +02:00
committed by GitHub
parent 4a9c0a4886
commit 41372c31cd
4 changed files with 97 additions and 97 deletions
+54 -25
View File
@@ -1232,8 +1232,8 @@ importers:
specifier: 4.17.21
version: 4.17.21
mongodb:
specifier: 3.7.3
version: 3.7.3
specifier: 5.5.0
version: 5.5.0
tools/ui-components:
dependencies:
@@ -10374,7 +10374,6 @@ packages:
/@types/webidl-conversions@7.0.0:
resolution: {integrity: sha512-xTE1E+YF4aWPJJeUzaZI5DRntlkY3+BCVJi0axFptnjGmAoWxkyREIh/XMrfxVLejwQxMCfDXdICo0VLxThrog==}
dev: false
/@types/webpack-env@1.18.0:
resolution: {integrity: sha512-56/MAlX5WMsPVbOg7tAxnYvNYMMWr/QJiIp6BxVSW3JJXUVzzOn64qW8TzQyMSqSUFM2+PVI4aUHcHOzIz/1tg==}
@@ -10409,7 +10408,6 @@ packages:
dependencies:
'@types/node': 18.16.0
'@types/webidl-conversions': 7.0.0
dev: false
/@types/ws@8.5.4:
resolution: {integrity: sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg==}
@@ -13106,6 +13104,7 @@ packages:
dependencies:
readable-stream: 2.3.8
safe-buffer: 5.2.1
dev: false
/bl@4.1.0:
resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}
@@ -13463,6 +13462,7 @@ packages:
/bson@1.1.6:
resolution: {integrity: sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg==}
engines: {node: '>=0.6.19'}
dev: false
/bson@4.7.2:
resolution: {integrity: sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==}
@@ -13471,6 +13471,11 @@ packages:
buffer: 5.7.1
dev: false
/bson@5.3.0:
resolution: {integrity: sha512-ukmCZMneMlaC5ebPHXIkP8YJzNl5DC41N5MAIvKDqLggdao342t4McltoJBQfQya/nHBWAcSsYRqlXPoQkTJag==}
engines: {node: '>=14.20.1'}
dev: true
/buffer-crc32@0.2.13:
resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==}
dev: true
@@ -15251,6 +15256,7 @@ packages:
dependencies:
ms: 2.1.3
supports-color: 8.1.1
dev: true
/debug@4.3.1:
resolution: {integrity: sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==}
@@ -15449,6 +15455,7 @@ packages:
/denque@1.5.1:
resolution: {integrity: sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==}
engines: {node: '>=0.10'}
dev: false
/depd@1.1.2:
resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==}
@@ -15564,7 +15571,7 @@ packages:
'@types/tmp': 0.0.33
application-config-path: 0.1.1
command-exists: 1.2.9
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
eol: 0.9.1
get-port: 3.2.0
glob: 7.2.3
@@ -16462,7 +16469,7 @@ packages:
/eslint-import-resolver-node@0.3.7:
resolution: {integrity: sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==}
dependencies:
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
is-core-module: 2.11.0
resolve: 1.22.2
transitivePeerDependencies:
@@ -16490,7 +16497,7 @@ packages:
optional: true
dependencies:
'@typescript-eslint/parser': 4.33.0(eslint@7.32.0)(typescript@4.9.5)
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
eslint: 7.32.0
eslint-import-resolver-node: 0.3.7
transitivePeerDependencies:
@@ -16518,7 +16525,7 @@ packages:
optional: true
dependencies:
'@typescript-eslint/parser': 5.54.0(eslint@8.37.0)(typescript@4.9.5)
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
eslint: 8.37.0
eslint-import-resolver-node: 0.3.7
transitivePeerDependencies:
@@ -16591,7 +16598,7 @@ packages:
array-includes: 3.1.6
array.prototype.flat: 1.3.1
array.prototype.flatmap: 1.3.1
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
doctrine: 2.1.0
eslint: 7.32.0
eslint-import-resolver-node: 0.3.7
@@ -16623,7 +16630,7 @@ packages:
array-includes: 3.1.6
array.prototype.flat: 1.3.1
array.prototype.flatmap: 1.3.1
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
doctrine: 2.1.0
eslint: 8.37.0
eslint-import-resolver-node: 0.3.7
@@ -17895,7 +17902,7 @@ packages:
debug:
optional: true
dependencies:
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
/follow-redirects@1.15.2(debug@4.3.4):
resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==}
@@ -18757,7 +18764,7 @@ packages:
css-minimizer-webpack-plugin: 2.0.0(webpack@5.80.0)
css.escape: 1.5.1
date-fns: 2.30.0
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
deepmerge: 4.3.0
del: 5.1.0
detect-port: 1.5.1
@@ -22912,7 +22919,7 @@ packages:
dependencies:
async: 0.9.2
commondir: 1.0.1
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
lodash: 4.17.21
semver: 5.7.1
strong-globalize: 4.1.3
@@ -22925,7 +22932,7 @@ packages:
resolution: {integrity: sha512-vDRR4gqkvGOEXh5yL383xGuGxUW9xtF+NCY6/lJu1VAgupKltZxEx3Vw+L3nsGvQrlkJTSmiK3jk72qxkoBtbw==}
engines: {node: '>=6'}
dependencies:
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
lodash: 4.17.21
loopback-swagger: 5.9.0
strong-globalize: 4.1.3
@@ -22940,7 +22947,7 @@ packages:
dependencies:
async: 2.6.4
bson: 1.1.6
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
loopback-connector: 4.11.1
mongodb: 3.7.3
strong-globalize: 4.1.3
@@ -22984,7 +22991,7 @@ packages:
dependencies:
async: 2.6.4
bluebird: 3.7.2
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
depd: 1.1.2
inflection: 1.13.4
lodash: 4.17.21
@@ -23008,7 +23015,7 @@ packages:
resolution: {integrity: sha512-p0qSzuuX7eATe5Bxy+RqCj3vSfSFfdCtqyf3yuC+DpchMvgal33XlhEi2UmywyK/Ym28oVnZxxWmfrwFMzSwLQ==}
engines: {node: '>=4.0.0'}
dependencies:
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
transitivePeerDependencies:
- supports-color
dev: false
@@ -23018,7 +23025,7 @@ packages:
engines: {node: '>=8.9'}
dependencies:
async: 2.6.4
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
strong-globalize: 4.1.3
transitivePeerDependencies:
- supports-color
@@ -23029,7 +23036,7 @@ packages:
engines: {node: '>=8'}
dependencies:
async: 2.6.4
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
ejs: 2.7.4
lodash: 4.17.21
strong-globalize: 4.1.3
@@ -24356,7 +24363,6 @@ packages:
dependencies:
'@types/whatwg-url': 8.2.2
whatwg-url: 11.0.0
dev: false
/mongodb@3.6.9:
resolution: {integrity: sha512-1nSCKgSunzn/CXwgOWgbPHUWOO5OfERcuOWISmqd610jn0s8BU9K4879iJVabqgpPPbA6hO7rG48eq+fGED3Mg==}
@@ -24422,6 +24428,7 @@ packages:
safe-buffer: 5.2.1
optionalDependencies:
saslprep: 1.0.3
dev: false
/mongodb@4.15.0:
resolution: {integrity: sha512-1iM2fF2fSNVrecOq4pW9zaJHFNuk63RX3SsppIjC2df8JkBv6odGOIu9FuqnI6gQD0KAF2az4zZdQdabqGSLDQ==}
@@ -24437,6 +24444,28 @@ packages:
- aws-crt
dev: false
/mongodb@5.5.0:
resolution: {integrity: sha512-XgrkUgAAdfnZKQfk5AsYL8j7O99WHd4YXPxYxnh8dZxD+ekYWFRA3JktUsBnfg+455Smf75/+asoU/YLwNGoQQ==}
engines: {node: '>=14.20.1'}
peerDependencies:
'@aws-sdk/credential-providers': ^3.201.0
mongodb-client-encryption: '>=2.3.0 <3'
snappy: ^7.2.2
peerDependenciesMeta:
'@aws-sdk/credential-providers':
optional: true
mongodb-client-encryption:
optional: true
snappy:
optional: true
dependencies:
bson: 5.3.0
mongodb-connection-string-url: 2.6.0
socks: 2.7.1
optionalDependencies:
saslprep: 1.0.3
dev: true
/moo@0.5.2:
resolution: {integrity: sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==}
dev: false
@@ -24630,7 +24659,7 @@ packages:
engines: {node: '>= 4.4.x'}
hasBin: true
dependencies:
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
iconv-lite: 0.4.24
sax: 1.2.4
transitivePeerDependencies:
@@ -25175,6 +25204,7 @@ packages:
engines: {node: '>=4'}
dependencies:
require-at: 1.0.6
dev: false
/optionator@0.8.3:
resolution: {integrity: sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==}
@@ -28798,6 +28828,7 @@ packages:
/require-at@1.0.6:
resolution: {integrity: sha512-7i1auJbMUrXEAZCOQ0VNJgmcT2VOKPRl2YGJwgpHpC9CE91Mv4/4UYIUm4chGJaI381ZDq1JUicFii64Hapd8g==}
engines: {node: '>=4'}
dev: false
/require-directory@2.1.1:
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
@@ -29672,7 +29703,6 @@ packages:
/smart-buffer@4.2.0:
resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==}
engines: {node: '>= 6.0.0', npm: '>= 3.0.0'}
dev: false
/smee-client@1.2.3:
resolution: {integrity: sha512-uDrU8u9/Ln7aRXyzGHgVaNUS8onHZZeSwQjCdkMoSL7U85xI+l+Y2NgjibkMJAyXkW7IAbb8rw9RMHIjS6lAwA==}
@@ -29794,7 +29824,6 @@ packages:
dependencies:
ip: 2.0.0
smart-buffer: 4.2.0
dev: false
/sonic-boom@3.2.1:
resolution: {integrity: sha512-iITeTHxy3B9FGu8aVdiDXUVAcHMF9Ss0cCsAOo2HfCrmVGT3/DT5oYaeu0M/YKZDlKTvChEyPq0zI9Hf33EX6A==}
@@ -32698,7 +32727,7 @@ packages:
/webpack-virtual-modules@0.2.2:
resolution: {integrity: sha512-kDUmfm3BZrei0y+1NTHJInejzxfhtU8eDj2M7OKb2IWrPFAeO1SOH2KuQ68MSZu9IGEHcxbkKKR1v18FrUSOmA==}
dependencies:
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
transitivePeerDependencies:
- supports-color
dev: true
@@ -32706,7 +32735,7 @@ packages:
/webpack-virtual-modules@0.3.2:
resolution: {integrity: sha512-RXQXioY6MhzM4CNQwmBwKXYgBs6ulaiQ8bkNQEl2J6Z+V+s7lgl/wGvaI/I0dLnYKB8cKsxQc17QOAVIphPLDw==}
dependencies:
debug: 3.2.7(supports-color@8.1.1)
debug: 3.2.7(supports-color@5.5.0)
transitivePeerDependencies:
- supports-color
+2 -2
View File
@@ -1,8 +1,8 @@
/* eslint-disable max-len */
const ObjectId = require('mongodb').ObjectID;
const { ObjectId } = require('mongodb');
module.exports = {
_id: ObjectId('5fa2db00a25c1c1fa49ce067'),
_id: new ObjectId('5fa2db00a25c1c1fa49ce067'),
email: 'foo@bar.com',
emailVerified: true,
progressTimestamps: [],
+1 -1
View File
@@ -22,6 +22,6 @@
"debug": "4.3.4",
"dotenv": "16.0.3",
"lodash": "4.17.21",
"mongodb": "3.7.3"
"mongodb": "5.5.0"
}
}
+40 -69
View File
@@ -25,7 +25,7 @@ function handleError(err, client) {
}
const demoUser = {
_id: ObjectId('5bd30e0f1caf6ac3ddddddb5'),
_id: new ObjectId('5bd30e0f1caf6ac3ddddddb5'),
email: 'foo@bar.com',
emailVerified: true,
progressTimestamps: [],
@@ -91,7 +91,7 @@ const demoUser = {
};
const blankUser = {
_id: ObjectId('5bd30e0f1caf6ac3ddddddb9'),
_id: new ObjectId('5bd30e0f1caf6ac3ddddddb9'),
email: 'bar@bar.com',
emailVerified: true,
progressTimestamps: [],
@@ -151,77 +151,48 @@ const blankUser = {
unsubscribeId: 'ecJxUi7OM49f24hTpauP8'
};
MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, (err, client) => {
handleError(err, client);
const client = new MongoClient(MONGOHQ_URL, { useNewUrlParser: true });
log('Connected successfully to mongo');
log('Connected successfully to mongo');
const db = client.db('freecodecamp');
const user = db.collection('user');
const db = client.db('freecodecamp');
const user = db.collection('user');
const dropUserTokens = async function () {
await db.collection('UserToken').deleteMany({
userId: {
$in: [
ObjectId('5fa2db00a25c1c1fa49ce067'),
ObjectId('5bd30e0f1caf6ac3ddddddb5'),
ObjectId('5bd30e0f1caf6ac3ddddddb9')
]
}
});
};
const userIds = [
new ObjectId('5fa2db00a25c1c1fa49ce067'),
new ObjectId('5bd30e0f1caf6ac3ddddddb5'),
new ObjectId('5bd30e0f1caf6ac3ddddddb9')
];
const dropUserTokens = async function () {
await db.collection('UserToken').deleteMany({
userId: {
$in: userIds
}
});
};
const dropUsers = async function () {
await db.collection('user').deleteMany({
_id: {
$in: userIds
}
});
};
const run = async () => {
await dropUserTokens();
await dropUsers();
if (process.argv[2] === 'certified-user') {
dropUserTokens();
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();
}
}
);
await user.insertOne(fullyCertifiedUser);
await user.insertOne(blankUser);
} else {
dropUserTokens();
user.deleteMany(
{
_id: {
$in: [
ObjectId('5fa2db00a25c1c1fa49ce067'),
ObjectId('5bd30e0f1caf6ac3ddddddb5'),
ObjectId('5bd30e0f1caf6ac3ddddddb9')
]
}
},
err => {
handleError(err, client);
try {
user.insertOne(demoUser);
user.insertOne(blankUser);
} catch (e) {
handleError(e, client);
} finally {
log('local auth user seed complete');
client.close();
}
}
);
await user.insertOne(demoUser);
await user.insertOne(blankUser);
}
});
log('local auth user seed complete');
};
run()
.then(() => client.close())
.catch(err => handleError(err, client));