/* You'll need NodeJS installed to run this script. Place this script in your track's root folder: track/ + config.json + json2csv.js <----- + exercises/ + hello_world + bob + ... Simply run the command: $ node json2csv.js You'll get a file named `core.csv` in the same folder. */ const fs = require('fs'); // read `config.json` file const jsonContent = fs.readFileSync('./config.json'); // get the array of exercises const exercises = JSON.parse(jsonContent.toString()).exercises; // create the header and generate a line by each exercise const header = 'Slug,Core,Unlocked by'; const csvLines = exercises.map(exercise => `${exercise.slug},${exercise.core},${exercise.unlocked_by}`); // write a CSV file named `core.csv`, easy to import on a spreadsheet const csvContent = [header].concat(csvLines).join('\n'); fs.writeFileSync('core.csv', csvContent);