chore: import upstream snapshot with attribution
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"super-block-a": {
|
||||
"blocks": {
|
||||
"block-one": {
|
||||
"meta": {},
|
||||
"challenges": [
|
||||
{
|
||||
"title": "Challenge One",
|
||||
"block": "Block One",
|
||||
"superBlock": "super-block-a"
|
||||
},
|
||||
{
|
||||
"title": "Challenge Two",
|
||||
"block": "Block One",
|
||||
"superBlock": "super-block-a"
|
||||
},
|
||||
{
|
||||
"title": "Challenge Three",
|
||||
"block": "Block One",
|
||||
"superBlock": "super-block-a"
|
||||
},
|
||||
{
|
||||
"title": "Challenge Four",
|
||||
"block": "Block One",
|
||||
"superBlock": "super-block-a"
|
||||
}
|
||||
]
|
||||
},
|
||||
"block-two": {
|
||||
"meta": {},
|
||||
"challenges": [
|
||||
{
|
||||
"title": "Challenge Five",
|
||||
"block": "Block Two",
|
||||
"superBlock": "super-block-a"
|
||||
},
|
||||
{
|
||||
"title": "Challenge Six",
|
||||
"block": "Block Two",
|
||||
"superBlock": "super-block-a"
|
||||
},
|
||||
{
|
||||
"title": "Challenge Seven",
|
||||
"block": "Block Two",
|
||||
"superBlock": "super-block-a"
|
||||
},
|
||||
{
|
||||
"title": "Challenge Eight",
|
||||
"block": "Block Two",
|
||||
"superBlock": "super-block-a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"super-block-b": {
|
||||
"blocks": {
|
||||
"block-one": {
|
||||
"meta": {},
|
||||
"challenges": [
|
||||
{
|
||||
"title": "Challenge Nine",
|
||||
"block": "Block One",
|
||||
"superBlock": "super-block-b"
|
||||
},
|
||||
{
|
||||
"title": "Challenge Ten",
|
||||
"block": "Block One",
|
||||
"superBlock": "super-block-b"
|
||||
},
|
||||
{
|
||||
"title": "Challenge Eleven",
|
||||
"block": "Block One",
|
||||
"superBlock": "super-block-b"
|
||||
},
|
||||
{
|
||||
"title": "Challenge Twelve",
|
||||
"block": "Block One",
|
||||
"superBlock": "super-block-b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { configTypeChecked } from '@freecodecamp/eslint-config/base';
|
||||
import globals from 'globals';
|
||||
|
||||
export default [
|
||||
...configTypeChecked,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node // TODO: migrate to ESM and remove globals
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@freecodecamp/scripts-seed",
|
||||
"version": "0.0.1",
|
||||
"description": "The freeCodeCamp.org open-source codebase and curriculum",
|
||||
"license": "BSD-3-Clause",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=24",
|
||||
"pnpm": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --max-warnings 0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/freeCodeCamp/freeCodeCamp.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/freeCodeCamp/freeCodeCamp/issues"
|
||||
},
|
||||
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme",
|
||||
"author": "freeCodeCamp <team@freecodecamp.org>",
|
||||
"main": "none",
|
||||
"devDependencies": {
|
||||
"@freecodecamp/eslint-config": "workspace:*",
|
||||
"debug": "4.4.3",
|
||||
"dotenv": "16.6.1",
|
||||
"eslint": "^9.39.1",
|
||||
"mongodb": "6.21.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
const { parseArgs } = require('node:util');
|
||||
|
||||
const path = require('path');
|
||||
const debug = require('debug');
|
||||
const { MongoClient } = require('mongodb');
|
||||
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });
|
||||
const {
|
||||
demoUser,
|
||||
blankUser,
|
||||
publicUser,
|
||||
fullyCertifiedUser,
|
||||
userIds,
|
||||
almostFullyCertifiedUser,
|
||||
unclaimedUser
|
||||
} = require('./user-data');
|
||||
|
||||
const options = {
|
||||
'set-true': { type: 'string', multiple: true },
|
||||
'top-contributor': { type: 'boolean' },
|
||||
'set-false': { type: 'string', multiple: true },
|
||||
'seed-trophy-challenges': { type: 'boolean' },
|
||||
'certified-user': { type: 'boolean' },
|
||||
'almost-certified-user': { type: 'boolean' },
|
||||
'unclaimed-user': { type: 'boolean' }
|
||||
};
|
||||
|
||||
const { values: argValues } = parseArgs({ options });
|
||||
|
||||
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 {
|
||||
// no-op
|
||||
} finally {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const trophyChallenges = [
|
||||
{
|
||||
id: '647f85d407d29547b3bee1bb',
|
||||
solution:
|
||||
'https://learn.microsoft.com/api/gamestatus/achievements/learn.wwl.get-started-c-sharp-part-1.trophy?username=moT01&locale=en-us',
|
||||
completedDate: 1695064765244
|
||||
},
|
||||
{
|
||||
id: '647f87dc07d29547b3bee1bf',
|
||||
solution:
|
||||
'https://learn.microsoft.com/api/gamestatus/achievements/learn.wwl.get-started-c-sharp-part-2.trophy?username=moT01&locale=en-us',
|
||||
completedDate: 1695064900926
|
||||
},
|
||||
{
|
||||
id: '647f882207d29547b3bee1c0',
|
||||
solution:
|
||||
'https://learn.microsoft.com/api/gamestatus/achievements/learn.wwl.get-started-c-sharp-part-3.trophy?username=moT01&locale=en-us',
|
||||
completedDate: 1695064949460
|
||||
},
|
||||
{
|
||||
id: '647f867a07d29547b3bee1bc',
|
||||
solution:
|
||||
'https://learn.microsoft.com/api/gamestatus/achievements/learn.wwl.get-started-c-sharp-part-4.trophy?username=moT01&locale=en-us',
|
||||
completedDate: 1695064986634
|
||||
},
|
||||
{
|
||||
id: '647f877f07d29547b3bee1be',
|
||||
solution:
|
||||
'https://learn.microsoft.com/api/gamestatus/achievements/learn.wwl.get-started-c-sharp-part-5.trophy?username=moT01&locale=en-us',
|
||||
completedDate: 1695065026465
|
||||
},
|
||||
{
|
||||
id: '647f86ff07d29547b3bee1bd',
|
||||
solution:
|
||||
'https://learn.microsoft.com/api/gamestatus/achievements/learn.wwl.get-started-c-sharp-part-6.trophy?username=moT01&locale=en-us',
|
||||
completedDate: 1695065060157
|
||||
}
|
||||
];
|
||||
|
||||
[demoUser, blankUser, fullyCertifiedUser].forEach(user => {
|
||||
if (argValues['top-contributor']) {
|
||||
user.yearsTopContributor = ['2017', '2018', '2019'];
|
||||
}
|
||||
for (const key of argValues['set-false'] || []) {
|
||||
user[key] = false;
|
||||
}
|
||||
for (const key of argValues['set-true'] || []) {
|
||||
user[key] = true;
|
||||
}
|
||||
if (argValues['--seed-trophy-challenges']) {
|
||||
user.completedChallenges = trophyChallenges;
|
||||
}
|
||||
});
|
||||
|
||||
const client = new MongoClient(MONGOHQ_URL);
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const user = db.collection('user');
|
||||
|
||||
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 client.db('admin').command({ ping: 1 });
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
await dropUserTokens();
|
||||
await dropUsers();
|
||||
if (argValues['certified-user']) {
|
||||
await user.insertOne(fullyCertifiedUser);
|
||||
} else if (argValues['almost-certified-user']) {
|
||||
await user.insertOne(almostFullyCertifiedUser);
|
||||
} else if (argValues['unclaimed-user']) {
|
||||
await user.insertOne(unclaimedUser);
|
||||
} else {
|
||||
await user.insertOne(demoUser);
|
||||
}
|
||||
|
||||
await user.insertOne(blankUser);
|
||||
await user.insertOne(publicUser);
|
||||
|
||||
log('local auth user seed complete');
|
||||
};
|
||||
|
||||
run()
|
||||
.then(() => client.close())
|
||||
.catch(err => handleError(err, client));
|
||||
@@ -0,0 +1,73 @@
|
||||
const path = require('path');
|
||||
const debug = require('debug');
|
||||
const { MongoClient, ObjectId } = require('mongodb');
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });
|
||||
|
||||
const log = debug('fcc:tools:seedMsUsername');
|
||||
const { MONGOHQ_URL } = process.env;
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
const allowedArgs = ['--delete-only'];
|
||||
|
||||
// Check for invalid arguments
|
||||
args.forEach(arg => {
|
||||
if (!allowedArgs.includes(arg))
|
||||
throw new Error(
|
||||
`Invalid argument ${arg}. Allowed arguments are ${allowedArgs.join(', ')}`
|
||||
);
|
||||
});
|
||||
|
||||
function handleError(err, client) {
|
||||
if (err) {
|
||||
console.error('Oh noes!! Error seeding MS username.');
|
||||
console.error(err);
|
||||
try {
|
||||
client.close();
|
||||
} catch {
|
||||
// no-op
|
||||
} finally {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const msAccountId = new ObjectId('65785b25d4c5bd0565c0184d');
|
||||
|
||||
const certifiedUserAccount = {
|
||||
_id: msAccountId,
|
||||
userId: new ObjectId('5fa2db00a25c1c1fa49ce067'),
|
||||
ttl: 77760000000,
|
||||
msUsername: 'certifieduser'
|
||||
};
|
||||
|
||||
const client = new MongoClient(MONGOHQ_URL);
|
||||
|
||||
const run = async () => {
|
||||
await client.db('admin').command({ ping: 1 });
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const msUsername = db.collection('MsUsername');
|
||||
if (args.includes('--delete-only')) {
|
||||
await msUsername.deleteOne({
|
||||
_id: { $eq: msAccountId }
|
||||
});
|
||||
|
||||
log('MS username deleted');
|
||||
return;
|
||||
}
|
||||
|
||||
// Rewrite if the object exists, create new if it doesn't
|
||||
await msUsername.updateOne(
|
||||
{ _id: msAccountId },
|
||||
{ $set: certifiedUserAccount },
|
||||
{ upsert: true }
|
||||
);
|
||||
|
||||
log('MS username seeded');
|
||||
};
|
||||
|
||||
run()
|
||||
.then(() => client.close())
|
||||
.catch(err => handleError(err, client));
|
||||
@@ -0,0 +1,97 @@
|
||||
const path = require('path');
|
||||
const debug = require('debug');
|
||||
const { MongoClient, ObjectId } = require('mongodb');
|
||||
|
||||
const { userIds } = require('./user-data');
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') });
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
const allowedArgs = ['delete-only'];
|
||||
|
||||
// Check for invalid arguments
|
||||
args.forEach(arg => {
|
||||
if (!allowedArgs.includes(arg))
|
||||
throw new Error(
|
||||
`Invalid argument ${arg}. Allowed arguments are ${allowedArgs.join(', ')}`
|
||||
);
|
||||
});
|
||||
|
||||
const log = debug('fcc:tools:seedSurveyInfo');
|
||||
const { MONGOHQ_URL } = process.env;
|
||||
|
||||
function handleError(err, client) {
|
||||
if (err) {
|
||||
console.error('Oh noes!! Error seeding survey info.');
|
||||
console.error(err);
|
||||
try {
|
||||
client.close();
|
||||
} catch {
|
||||
// no-op
|
||||
} finally {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const surveyIds = [
|
||||
new ObjectId('651c5a2a5f9b639b584028bc'),
|
||||
new ObjectId('651c5a4c5f9b639b584028bd')
|
||||
];
|
||||
|
||||
const defaultUserSurvey = {
|
||||
_id: surveyIds[0],
|
||||
title: 'Foundational C# with Microsoft Survey',
|
||||
responses: [
|
||||
{
|
||||
question: 'Please describe your role:',
|
||||
response: 'Beginner developer (less than 2 years experience)'
|
||||
},
|
||||
{
|
||||
question:
|
||||
'Prior to this course, how experienced were you with .NET and C#?',
|
||||
response: 'Novice (no prior experience)'
|
||||
}
|
||||
],
|
||||
userId: new ObjectId('5bd30e0f1caf6ac3ddddddb5')
|
||||
};
|
||||
|
||||
const certifiedUserSurvey = {
|
||||
_id: surveyIds[1],
|
||||
title: 'Foundational C# with Microsoft Survey',
|
||||
responses: [
|
||||
{
|
||||
question: 'Please describe your role:',
|
||||
response: 'Experienced developer (more than 5 years experience)'
|
||||
},
|
||||
{
|
||||
question:
|
||||
'Prior to this course, how experienced were you with .NET and C#?',
|
||||
response: 'Expert'
|
||||
}
|
||||
],
|
||||
userId: new ObjectId('5fa2db00a25c1c1fa49ce067')
|
||||
};
|
||||
|
||||
const client = new MongoClient(MONGOHQ_URL);
|
||||
|
||||
const run = async () => {
|
||||
await client.db('admin').command({ ping: 1 });
|
||||
log('Connected successfully to mongo');
|
||||
|
||||
const db = client.db('freecodecamp');
|
||||
const survey = db.collection('Survey');
|
||||
|
||||
await survey.deleteMany({ userId: { $in: userIds } });
|
||||
log('Survey info deleted');
|
||||
|
||||
if (!args.includes('delete-only')) {
|
||||
await survey.insertOne(defaultUserSurvey);
|
||||
await survey.insertOne(certifiedUserSurvey);
|
||||
log('Survey info seeded');
|
||||
}
|
||||
};
|
||||
|
||||
run()
|
||||
.then(() => client.close())
|
||||
.catch(err => handleError(err, client));
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user