File tree 3 files changed +733
-661
lines changed 3 files changed +733
-661
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+
3
+ const { exercises } = require ( '../config.json' )
4
+ const TAG_CORE = '__core'
5
+ const TAG_BONUS = '__bonus'
6
+
7
+ // node inter-opt exports
8
+ exports . TAG_CORE = TAG_CORE
9
+ exports . TAG_BONUS = TAG_BONUS
10
+
11
+ exports . tree = exercises . reduce ( ( result , exercise ) => {
12
+ const tag = exercise . slug
13
+ const item = {
14
+ slug : tag ,
15
+ difficulty : exercise . difficulty ,
16
+ }
17
+
18
+ if ( exercise . core ) {
19
+ const current = result [ TAG_CORE ] || [ ]
20
+
21
+ if ( result [ tag ] ) {
22
+ console . warn ( `${ tag } is not ordered correctly in config.json` )
23
+ }
24
+
25
+ return {
26
+ ...result ,
27
+ __core : current . concat ( [ item ] ) ,
28
+ [ tag ] : result [ tag ] || [ ]
29
+ }
30
+ }
31
+
32
+ const parent = exercise . unlocked_by || TAG_BONUS
33
+ const current = result [ parent ] || [ ]
34
+ return { ...result , [ parent ] : current . concat ( [ item ] ) }
35
+ } , { } )
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+
3
+ const actions = require ( './generate-config-tree' )
4
+
5
+ const { tree, TAG_BONUS , TAG_CORE } = actions
6
+ const { [ TAG_BONUS ] : __bonus , [ TAG_CORE ] : __core , ...track } = tree
7
+
8
+ function printLn ( line ) {
9
+ process . stdout . write ( `${ line } \n` )
10
+ }
11
+
12
+ function printList ( items ) {
13
+ items . forEach ( item => {
14
+ printLn ( `- ${ item . slug } (${ item . difficulty } )` )
15
+ } )
16
+ }
17
+
18
+ printLn ( 'Core (matches config.json) of this track:' )
19
+ printList ( __core )
20
+ printLn ( '\n' )
21
+ printLn ( 'core' )
22
+ printLn ( '----' )
23
+ Object . keys ( track ) . forEach ( slug => {
24
+ printLn ( `├─ ${ slug } ` )
25
+ track [ slug ] . forEach ( ( side , index , self ) => {
26
+ junction = index === self . length - 1 ? '└─' : '├─'
27
+ printLn ( `│ ${ junction } ${ side . slug } (${ side . difficulty } )` )
28
+ } )
29
+ printLn ( '│' )
30
+ } )
31
+
32
+ printLn ( 'bonus' )
33
+ printLn ( '----' )
34
+ printList ( __bonus )
You can’t perform that action at this time.
0 commit comments