mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor(api): organise tooling (#59931)
This commit is contained in:
committed by
GitHub
parent
3c822da243
commit
ae387fbd5c
@@ -0,0 +1,52 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { MONGOHQ_URL } from '../../../src/utils/env';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const ENV_EXAM_ID = args[0];
|
||||
|
||||
if (!ENV_EXAM_ID) {
|
||||
throw Error('First argument must be the EnvExam _id');
|
||||
}
|
||||
|
||||
const prisma = new PrismaClient({
|
||||
datasources: {
|
||||
db: {
|
||||
url: MONGOHQ_URL
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function main() {
|
||||
console.info('Connecting to cluster...');
|
||||
await prisma.$connect();
|
||||
console.info('Connected.');
|
||||
|
||||
try {
|
||||
await prisma.envExam.update({
|
||||
where: {
|
||||
id: ENV_EXAM_ID
|
||||
},
|
||||
data: {
|
||||
deprecated: true
|
||||
}
|
||||
});
|
||||
console.info(`Exam "${ENV_EXAM_ID}" deprecated...`);
|
||||
const res = await prisma.envGeneratedExam.updateMany({
|
||||
where: {
|
||||
examId: ENV_EXAM_ID
|
||||
},
|
||||
data: {
|
||||
deprecated: true
|
||||
}
|
||||
});
|
||||
|
||||
console.info(`${res.count} generated exams deprecated...`);
|
||||
} catch (e) {
|
||||
console.error('Unable to deprecate exam due to:');
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
console.info(`Finished deprecating exam.`);
|
||||
}
|
||||
|
||||
void main();
|
||||
Reference in New Issue
Block a user