Skip to content

Commit 8086c61

Browse files
committed
update tutorial create
1 parent f304963 commit 8086c61

File tree

12 files changed

+105
-67
lines changed

12 files changed

+105
-67
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coderoad-cli",
3-
"version": "0.3.12",
3+
"version": "0.3.13",
44
"description": "Command line interface for CodeRoad. Build project files.",
55
"keywords": [
66
"coderoad"
@@ -20,8 +20,8 @@
2020
"dependencies": {
2121
"chalk": "1.1.1",
2222
"commander": "2.9.0",
23-
"lodash": "4.2.1",
24-
"prompt": "^0.2.14"
23+
"lodash": "4.5.0",
24+
"prompt": "1.0.0"
2525
},
2626
"devDependencies": {
2727
"chai": "3.5.0",

src/create/setup/package.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,24 @@
22
"name": "coderoad-package-name",
33
"version": "0.1.0",
44
"description": "Coderoad tutorial",
5-
"author": "",
5+
"author": "Name <email> (site)",
66
"contributers": [],
77
"main": "coderoad.json",
8+
"files": [
9+
"coderoad.json",
10+
"tutorial"
11+
],
812
"keywords": ["coderoad", "tutorial"],
9-
"dependencies": {},
10-
"devDependencies": {},
13+
"engines": {
14+
"node" : ">=0.10.3"
15+
},
16+
"dependencies": {
17+
"mocha-coderoad": "^0.3.1"
18+
},
1119
"license": "MIT",
12-
"coderoad": {
20+
"config": {
1321
"testDir": "tutorial",
14-
"testSuffix": ".spec.js"
22+
"testSuffix": ".spec.js",
23+
"testRunner": "mocha-coderoad"
1524
}
1625
}

src/create/setup/tutorial/chapter-01/page-01/task-01.spec.js renamed to src/create/setup/tutorial/1/01/01.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
var expect = require('chai').expect;
2-
var context = require('test-context');
3-
var filePath = '../../../example.js';
4-
context(filePath);
52

6-
describe('addOne', function() {
3+
var loadJS = require('./common/loadJS').default;
4+
loadJS('page-01.js')
5+
6+
describe('01 addOne', function() {
77

88
it('doesn\'t exist', function() {
99
expect(addOne).to.not.be.undefined;
1010
});
1111

12-
it('doesn\'t take any parameters', function() {
13-
expect(addOne.length).to.be.above(0);
12+
it('should take a parameter', function() {
13+
expect(addOne).to.have.length(1);
1414
});
1515

1616
it('doesn\'t return anything', function() {
1717
expect(addOne(1)).to.exist;
1818
});
1919

20-
it('doesn\'t output a number', function() {
20+
it('should output a number', function() {
2121
expect(addOne(1)).to.be.a('number');
2222
});
2323

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
describe('02 subtractOne', function() {
2+
3+
it('doesn\'t exist', function () {
4+
expect(subtractOne).to.not.be.undefined;
5+
});
6+
7+
it('should take a parameter', function() {
8+
expect(subtractOne).to.have.length(1);
9+
});
10+
11+
it('should output a number', function () {
12+
expect(subtractOne(1)).to.be.a('number');
13+
});
14+
15+
it('doesn\'t subtract 1', function() {
16+
expect(subtractOne(1)).to.equal(0);
17+
expect(subtractOne(10)).to.equal(9);
18+
});
19+
20+
});

src/create/setup/tutorial/chapter-01/page-01/page-one.md renamed to src/create/setup/tutorial/1/01/page-one.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,19 @@ function doSomething(parameter) {
1616
Try making your own basic functions.
1717

1818
+ write a function `addOne` that adds one to a number
19-
@test('chapter-01/page-01/task-01')
19+
@test('1/01/01')
20+
@action(open('page-01.js'))
21+
@action(set(
22+
```
23+
// addOne
24+
```
25+
))
2026

2127
+ write a function `subtractOne` that subtracts one from a number
22-
@test('chapter-01/page-01/task-02')
28+
@test('1/01/02')
29+
@action(insert(
30+
```
31+
32+
// subtractOne
33+
```
34+
))

src/create/setup/tutorial/chapter-01/page-02/task-01.spec.js renamed to src/create/setup/tutorial/1/02/01.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
var expect = require('chai').expect;
2-
var context = require('test-context');
3-
context('../../../example.js');
42

5-
describe('divideOne', function() {
3+
var loadJS = require('./common/loadJS').default;
4+
loadJS('page-02.js')
5+
6+
7+
describe('01 divideOne', function() {
68

79
it('doesn\'t exist', function () {
810
expect(divideOne).to.not.be.undefined;
911
});
1012

11-
it('doesn\'t take any parameters', function() {
12-
expect(divideOne.length).to.be.above(0);
13+
it('should take a parameter', function() {
14+
expect(divideOne).to.have.length(1);
1315
});
1416

1517
it('doesn\'t output a number', function () {

src/create/setup/tutorial/chapter-01/page-02/task-02.spec.js renamed to src/create/setup/tutorial/1/02/02.spec.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
var expect = require('chai').expect;
2-
var context = require('test-context');
3-
context('../../../example.js');
4-
5-
describe('multiplyOne', function() {
1+
describe('02 multiplyOne', function() {
62

73
it('doesn\'t exist', function () {
84
expect(multiplyOne).to.not.be.undefined;
95
});
106

11-
it('doesn\'t take any parameters', function() {
12-
expect(multiplyOne.length).to.be.above(0);
7+
it('should take a parameter', function() {
8+
expect(multiplyOne).to.have.length(1);
139
});
1410

15-
it('doesn\'t output a number', function () {
11+
it('should output a number', function () {
1612
expect(multiplyOne(1)).to.be.a('number');
1713
});
1814

src/create/setup/tutorial/chapter-01/page-02/page-two.md renamed to src/create/setup/tutorial/1/02/page-two.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ Writing basic functions continued.
44
We'll write two more basic functions, this time without any help.
55

66
+ write a function `divideOne` divides a number by 1
7-
@test('chapter-01/page-02/task-01')
7+
@test('1/02/01')
8+
@action(open('page-02.js'))
9+
@action(set(
10+
```
11+
// divideOne
12+
```
13+
))
814

915
+ write a function `mutiplyone` that multiplies a number by 1
10-
@test('chapter-01/page-02/task-02')
16+
@test('1/02/02')
17+
@action(insert(
18+
```
19+
20+
// multiplyOne
21+
```
22+
))

src/create/setup/tutorial/chapter-01/page-01/task-02.spec.js

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
var vm = require('vm');
3+
var fs = require('fs');
4+
var path = require('path');
5+
function loadContext(pathToContext) {
6+
var absPath = path.join(process.env.DIR, pathToContext);
7+
var context = fs.readFileSync(absPath, 'utf8');
8+
vm.runInThisContext(context);
9+
}
10+
Object.defineProperty(exports, "__esModule", { value: true });
11+
exports.default = loadContext;

src/create/setup/tutorial/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Project description.
44
## Chapter One Title
55
Chapter one description.
66

7-
@import('tutorial/chapter-01/page-01/page-one')
7+
@import('tutorial/1/01/page-one')
88

9-
@import('tutorial/chapter-01/page-02/page-two')
9+
@import('tutorial/1/02/page-two')

src/create/write-demo.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ function createFolder(pathToFolder) {
1717
function createTutorialMd() {
1818
createFolder('tutorial');
1919
createFile('tutorial/tutorial.md');
20-
createFolder('tutorial/chapter-01');
21-
createFolder('tutorial/chapter-01/page-01');
22-
createFile('tutorial/chapter-01/page-01/page-one.md');
23-
createFolder('tutorial/chapter-01/page-02');
24-
createFile('tutorial/chapter-01/page-02/page-two.md');
20+
createFolder('tutorial/1');
21+
createFolder('tutorial/1/01');
22+
createFile('tutorial/1/01/page-one.md');
23+
createFolder('tutorial/1/02');
24+
createFile('tutorial/1/02/page-two.md');
2525
}
2626
exports.createTutorialMd = createTutorialMd;
2727
function createPackageJson(name) {
@@ -35,9 +35,9 @@ function createPackageJson(name) {
3535
}
3636
exports.createPackageJson = createPackageJson;
3737
function createTestFiles() {
38-
createFile('tutorial/chapter-01/page-01/task-01.spec.js');
39-
createFile('tutorial/chapter-01/page-01/task-02.spec.js');
40-
createFile('tutorial/chapter-01/page-02/task-01.spec.js');
41-
createFile('tutorial/chapter-01/page-02/task-02.spec.js');
38+
createFile('tutorial/1/01/01.spec.js');
39+
createFile('tutorial/1/01/02.spec.js');
40+
createFile('tutorial/1/02/01.spec.js');
41+
createFile('tutorial/1/02/02.spec.js');
4242
}
4343
exports.createTestFiles = createTestFiles;

0 commit comments

Comments
 (0)