feat: improve ui/ux learn map (#40579)

Co-authored-by: Kris Koishigawa <scissorsneedfoodtoo@gmail.com>
This commit is contained in:
Tom
2021-01-13 07:09:45 -06:00
committed by Mrugesh Mohapatra
parent 14ca6beb0a
commit 625469c82f
45 changed files with 3297 additions and 965 deletions

View File

@@ -4,6 +4,7 @@ const { translationsSchema } = require('./translations-schema');
const { availableLangs } = require('./allLangs');
const { trendingSchema } = require('./trending-schema');
const { motivationSchema } = require('./motivation-schema');
const { introSchema } = require('./intro-schema');
/**
* Flattens a nested object structure into a single
@@ -103,6 +104,7 @@ const noEmptyObjectValues = (obj, namespace = '') => {
const translationSchemaKeys = Object.keys(flattenAnObject(translationsSchema));
const trendingSchemaKeys = Object.keys(flattenAnObject(trendingSchema));
const motivationSchemaKeys = Object.keys(flattenAnObject(motivationSchema));
const introSchemaKeys = Object.keys(flattenAnObject(introSchema));
/**
* Function that checks the translations.json file
@@ -211,6 +213,30 @@ const motivationSchemaValidation = languages => {
});
};
/**
* Function that checks the intro.json file
* for each available client language.
* @param {String[]} languages List of languages to test
*/
const introSchemaValidation = languages => {
languages.forEach(language => {
const filePath = path.join(__dirname, `/locales/${language}/intro.json`);
const fileData = fs.readFileSync(filePath);
const fileJson = JSON.parse(fileData);
const fileKeys = Object.keys(flattenAnObject(fileJson));
findMissingKeys(fileKeys, introSchemaKeys, `${language}/intro.json`);
findExtraneousKeys(fileKeys, introSchemaKeys, `${language}/intro.json`);
const emptyKeys = noEmptyObjectValues(fileJson);
if (emptyKeys.length) {
throw new Error(
`${language}/intro.json has these empty keys: ${emptyKeys.join(', ')}`
);
}
console.info(`${language} intro.json is correct!`);
});
};
translationSchemaValidation(availableLangs.client);
trendingSchemaValidation(availableLangs.client);
motivationSchemaValidation(availableLangs.client);
introSchemaValidation(availableLangs.client);