chore(server): Move api-server in to it's own DIR
This commit is contained in:
committed by
mrugesh mohapatra
parent
9fba6bce4c
commit
46a217d0a5
@@ -4,57 +4,71 @@ const { getChallenges } = require('@freecodecamp/curriculum');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { Observable } = require('rx');
|
||||
const { dasherize } = require('../server/utils');
|
||||
const { dasherize } = require('../api-server/server/utils');
|
||||
|
||||
let pathMap = {};
|
||||
|
||||
function createPathMigrationMap() {
|
||||
return new Promise(resolve => {
|
||||
Observable.of(getChallenges())
|
||||
.map(blocks => {
|
||||
blocks.forEach(block => {
|
||||
const {name: blockName, superBlock, challenges } = block;
|
||||
if (!(dasherize(superBlock) in pathMap)) {
|
||||
pathMap[dasherize(superBlock)] = {};
|
||||
}
|
||||
if (!(dasherize(blockName) in pathMap[superBlock])) {
|
||||
pathMap[dasherize(superBlock)][dasherize(blockName)] = challenges
|
||||
.map(({ title, challengeType }) => ({
|
||||
dashedName: dasherize(title),
|
||||
challengeType
|
||||
}));
|
||||
}
|
||||
});
|
||||
})
|
||||
.subscribe(() => {}, console.error, () => {
|
||||
const migMap = Object.keys(pathMap)
|
||||
.filter(key => !key.includes('certificate'))
|
||||
.map(superBlock => {
|
||||
return Object.keys(pathMap[superBlock])
|
||||
.map(block => {
|
||||
return pathMap[superBlock][block]
|
||||
.reduce((map, {dashedName, challengeType}) => ({
|
||||
...map,
|
||||
[dashedName]: challengeType === 7 ?
|
||||
`/${superBlock}/${block}` :
|
||||
`/${superBlock}/${block}/${dashedName}`
|
||||
}), {});
|
||||
}).reduce((acc, current) => ({
|
||||
...acc,
|
||||
...current
|
||||
}), {});
|
||||
}).reduce((acc, current) => ({
|
||||
...acc,
|
||||
...current
|
||||
}), {});
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname, '../server/resources/pathMigration.json'),
|
||||
JSON.stringify(migMap, null, 2)
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
Observable.of(getChallenges())
|
||||
.map(blocks => {
|
||||
blocks.forEach(block => {
|
||||
const { name: blockName, superBlock, challenges } = block;
|
||||
if (!(dasherize(superBlock) in pathMap)) {
|
||||
pathMap[dasherize(superBlock)] = {};
|
||||
}
|
||||
if (!(dasherize(blockName) in pathMap[superBlock])) {
|
||||
pathMap[dasherize(superBlock)][
|
||||
dasherize(blockName)
|
||||
] = challenges.map(({ title, challengeType }) => ({
|
||||
dashedName: dasherize(title),
|
||||
challengeType
|
||||
}));
|
||||
}
|
||||
});
|
||||
})
|
||||
.subscribe(() => {}, console.error, () => {
|
||||
const migMap = Object.keys(pathMap)
|
||||
.filter(key => !key.includes('certificate'))
|
||||
.map(superBlock => {
|
||||
return Object.keys(pathMap[superBlock])
|
||||
.map(block => {
|
||||
return pathMap[superBlock][block].reduce(
|
||||
(map, { dashedName, challengeType }) => ({
|
||||
...map,
|
||||
[dashedName]:
|
||||
challengeType === 7
|
||||
? `/${superBlock}/${block}`
|
||||
: `/${superBlock}/${block}/${dashedName}`
|
||||
}),
|
||||
{}
|
||||
);
|
||||
})
|
||||
.reduce(
|
||||
(acc, current) => ({
|
||||
...acc,
|
||||
...current
|
||||
}),
|
||||
{}
|
||||
);
|
||||
})
|
||||
.reduce(
|
||||
(acc, current) => ({
|
||||
...acc,
|
||||
...current
|
||||
}),
|
||||
{}
|
||||
);
|
||||
fs.writeFileSync(
|
||||
path.resolve(
|
||||
__dirname,
|
||||
'../api-server/server/resources/pathMigration.json'
|
||||
),
|
||||
JSON.stringify(migMap, null, 2)
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
exports.createPathMigrationMap = createPathMigrationMap;
|
||||
exports.createPathMigrationMap = createPathMigrationMap;
|
||||
|
Reference in New Issue
Block a user