Skip to content

Commit b864d61

Browse files
committed
swap out workshopper for workshopper-adventure
1 parent 6937186 commit b864d61

File tree

5 files changed

+27
-42
lines changed

5 files changed

+27
-42
lines changed

i18n/en.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"title": "NodeBot Workshop",
3+
"subtitle": "Make your Ardunio alive with Johnny-Five",
34
"exercise": {
45
"blink_blink": "Blink Blink",
56
"servo_wave": "Servo Wave",
@@ -10,12 +11,5 @@
1011
"robot_arm": "Robot Arm",
1112
"remote_temperature": "Remote Temperature",
1213
"fire_alarm": "Fire Alarm"
13-
},
14-
"common": {
15-
"exercise": {
16-
"pass": {},
17-
"fail": {}
18-
}
19-
},
20-
"exercises": {}
14+
}
2115
}

i18n/ja.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "JavaScriptでのハードウェア制御を楽しもう!",
2+
"subtitle": "JavaScriptでのハードウェア制御を楽しもう!",
33
"exercise": {
44
"blink_blink": "Lチカ",
55
"servo_wave": "サーボウェーブ",
@@ -10,12 +10,5 @@
1010
"robot_arm": "ロボットアーム",
1111
"remote_temperature": "遠隔地の温度",
1212
"fire_alarm": "火災報知器"
13-
},
14-
"common": {
15-
"exercise": {
16-
"pass": {},
17-
"fail": {}
18-
}
19-
},
20-
"exercises": {}
13+
}
2114
}

nodebot-workshop.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
#!/usr/bin/env node
22

3-
const workshopper = require('workshopper')
4-
, path = require('path')
5-
, name = 'nodebot-workshop'
6-
, title = 'Nodebot Workshop'
7-
, subtitle = '\x1b[23mSelect an exercise and hit \x1b[3mEnter\x1b[23m to begin'
3+
const workshop = require('workshopper-adventure')({
4+
appDir: __dirname,
5+
languages: ['en', 'ja'],
6+
menu: {fg: 'black', bg: /^win/.test(process.platform) ? 'yellow' : 220},
7+
header: require('workshopper-adventure/default/header'),
8+
footer: require('workshopper-adventure/default/footer')
9+
})
810

9-
function fpath (f) {
10-
return path.join(__dirname, f)
11-
}
11+
workshop.addAll(require('./exercises/menu.json'))
1212

13-
workshopper({
14-
name : name
15-
, title : title
16-
, subtitle : subtitle
17-
, exerciseDir : fpath('./exercises/')
18-
, appDir : __dirname
19-
, languages : ['en', 'ja']
20-
, helpFile : fpath('help.txt')
21-
, menuItems : []
22-
, menu : {fg: 'black', bg: /^win/.test(process.platform) ? 'yellow' : 220}
23-
})
13+
workshop.execute(process.argv.slice(2))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"johnny-five": "^0.9.11",
4141
"proxyquire": "^1.0.0",
4242
"sinon": "^1.9",
43-
"workshopper": "^2.7.0",
43+
"workshopper-adventure": "^4.4.6",
4444
"workshopper-exercise": "^2.5.3"
4545
},
4646
"optionalDependencies": {

tests/verify-solutions.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
* Test all the exercises defined in `menu.json` have valid solutions. Run them in series, in a child process.
1414
*
1515
*/
16-
const workshopper = require('workshopper')
16+
const workshopper = require('workshopper-adventure')
17+
, workshopperUtils = require('workshopper-adventure/util')
1718
, spawn = require('child_process').spawn
1819
, async = require('async')
1920
, path = require('path')
@@ -40,24 +41,31 @@ var nodebot = workshopper({
4041
, helpFile : fpath('help.txt')
4142
, menuItems : []
4243
, menu : {fg: "black", bg: 220}
44+
, menuFactory: {
45+
options: {},
46+
create: function () {
47+
return true
48+
}
49+
}
4350
})
51+
nodebot.addAll(require('../exercises/menu.json'))
4452

4553
function testSolution(name) {
4654

4755
if(fs.existsSync(name)){ // we got a file name not an exercise name
4856
name = nameFromPath(name)
4957
}
5058

51-
console.log(nodebot.dirFromName(name))
52-
5359
nodebot.getData = function(){
5460
return name
5561
}
5662

5763
var exercise = nodebot.loadExercise(name)
58-
var solution = path.relative(__dirname, nodebot.dirFromName(name) + '/solution/solution.js')
5964

60-
nodebot.execute(exercise, 'verify', [solution])
65+
var solution = path.relative(__dirname, path.join(__dirname, '..', 'exercises', workshopperUtils.dirFromName(name), 'solution', 'solution.js'))
66+
67+
nodebot.execute(['select', name])
68+
nodebot.execute(['verify', solution])
6169
}
6270

6371
if (process.argv.length > 2){

0 commit comments

Comments
 (0)