Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curriculum change: track sequence (round 1) #590

Merged
merged 11 commits into from
Jan 25, 2019
35 changes: 35 additions & 0 deletions bin/generate-config-tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

const { exercises } = require('../config.json')
const TAG_CORE = '__core'
const TAG_BONUS = '__bonus'

// node inter-opt exports
exports.TAG_CORE = TAG_CORE
exports.TAG_BONUS = TAG_BONUS

exports.tree = exercises.reduce((result, exercise) => {
const tag = exercise.slug
const item = {
slug: tag,
difficulty: exercise.difficulty,
}

if (exercise.core) {
const current = result[TAG_CORE] || []

if (result[tag]) {
console.warn(`${tag} is not ordered correctly in config.json`)
}

return {
...result,
__core: current.concat([item]),
[tag]: result[tag] || []
}
}

const parent = exercise.unlocked_by || TAG_BONUS
const current = result[parent] || []
return { ...result, [parent]: current.concat([item]) }
}, {})
34 changes: 34 additions & 0 deletions bin/print-config-tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env node

const actions = require('./generate-config-tree')

const { tree, TAG_BONUS, TAG_CORE } = actions
const { [TAG_BONUS]: __bonus, [TAG_CORE]: __core, ...track } = tree

function printLn(line) {
process.stdout.write(`${line}\n`)
}

function printList(items) {
items.forEach(item => {
printLn(`- ${item.slug} (${item.difficulty})`)
})
}

printLn('Core (matches config.json) of this track:')
printList(__core)
printLn('\n')
printLn('core')
printLn('----')
Object.keys(track).forEach(slug => {
printLn(`├─ ${slug}`)
track[slug].forEach((side, index, self) => {
junction = index === self.length - 1 ? '└─' : '├─'
printLn(`│ ${junction} ${side.slug} (${side.difficulty})`)
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

printLn('│')
})

printLn('bonus')
printLn('----')
printList(__bonus)
Loading