Skip to content

Commit d2c99f9

Browse files
committed
move setup to lib
1 parent 2012153 commit d2c99f9

File tree

10 files changed

+198
-3
lines changed

10 files changed

+198
-3
lines changed

lib/create/setup/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "coderoad-package-name",
3+
"version": "0.1.0",
4+
"description": "Coderoad tutorial",
5+
"author": "Name <email> (site)",
6+
"contributers": [],
7+
"main": "coderoad.json",
8+
"files": [
9+
"coderoad.json",
10+
"tutorial"
11+
],
12+
"keywords": ["coderoad", "tutorial"],
13+
"engines": {
14+
"node" : ">=0.10.3"
15+
},
16+
"dependencies": {
17+
"mocha-coderoad": "^0.5.0"
18+
},
19+
"license": "MIT",
20+
"config": {
21+
"testDir": "tutorial",
22+
"testSuffix": ".spec.js",
23+
"testRunner": "mocha-coderoad"
24+
}
25+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var expect = require('chai').expect;
2+
3+
var loadJS = require('./common/loadJS').default;
4+
loadJS('page-01.js')
5+
6+
describe('01 addOne', function() {
7+
8+
it('doesn\'t exist', function() {
9+
expect(addOne).to.not.be.undefined;
10+
});
11+
12+
it('should take a parameter', function() {
13+
expect(addOne).to.have.length(1);
14+
});
15+
16+
it('doesn\'t return anything', function() {
17+
expect(addOne(1)).to.exist;
18+
});
19+
20+
it('should output a number', function() {
21+
expect(addOne(1)).to.be.a('number');
22+
});
23+
24+
it('doesn\'t add 1 + 1', function() {
25+
expect(addOne(1)).to.equal(2);
26+
expect(addOne(10)).to.equal(11);
27+
});
28+
29+
});
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+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
### Add & Subtract
2+
Writing basic functions.
3+
4+
A function has inputs and outputs. The inputs we call "parameters" and wrap them in `(` brackets `)`.
5+
6+
The output is `return`ed from the function.
7+
8+
```
9+
// input
10+
function doSomething(parameter) {
11+
// output
12+
return parameter;
13+
}
14+
```
15+
16+
Try making your own basic functions.
17+
18+
+ write a function `addOne` that adds one to a number
19+
@test('1/01/01')
20+
@action(open('page-01.js'))
21+
@action(set(
22+
```
23+
// addOne
24+
```
25+
))
26+
27+
+ write a function `subtractOne` that subtracts one from a number
28+
@test('1/01/02')
29+
@action(insert(
30+
```
31+
32+
// subtractOne
33+
```
34+
))
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var expect = require('chai').expect;
2+
3+
var loadJS = require('./common/loadJS').default;
4+
loadJS('page-02.js')
5+
6+
7+
describe('01 divideOne', function() {
8+
9+
it('doesn\'t exist', function () {
10+
expect(divideOne).to.not.be.undefined;
11+
});
12+
13+
it('should take a parameter', function() {
14+
expect(divideOne).to.have.length(1);
15+
});
16+
17+
it('doesn\'t output a number', function () {
18+
expect(divideOne(1)).to.be.a('number');
19+
});
20+
21+
it('returns the same number', function() {
22+
expect(divideOne(1)).to.equal(1);
23+
expect(divideOne(10)).to.equal(10);
24+
});
25+
26+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
describe('02 multiplyOne', function() {
2+
3+
it('doesn\'t exist', function () {
4+
expect(multiplyOne).to.not.be.undefined;
5+
});
6+
7+
it('should take a parameter', function() {
8+
expect(multiplyOne).to.have.length(1);
9+
});
10+
11+
it('should output a number', function () {
12+
expect(multiplyOne(1)).to.be.a('number');
13+
});
14+
15+
it('returns the multiplied number by one', function() {
16+
expect(multiplyOne(1)).to.equal(1);
17+
expect(multiplyOne(10)).to.equal(10);
18+
});
19+
20+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### Divide & Multiply
2+
Writing basic functions continued.
3+
4+
We'll write two more basic functions, this time without any help.
5+
6+
+ write a function `divideOne` divides a number by 1
7+
@test('1/02/01')
8+
@action(open('page-02.js'))
9+
@action(set(
10+
```
11+
// divideOne
12+
```
13+
))
14+
15+
+ write a function `mutiplyone` that multiplies a number by 1
16+
@test('1/02/02')
17+
@action(insert(
18+
```
19+
20+
// multiplyOne
21+
```
22+
))
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;

lib/create/setup/tutorial/tutorial.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Project Title
2+
Project description.
3+
4+
## Chapter One Title
5+
Chapter one description.
6+
7+
@import('tutorial/1/01/page-one')
8+
9+
@import('tutorial/1/02/page-two')

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coderoad-cli",
3-
"version": "0.3.20",
3+
"version": "0.3.21",
44
"description": "Command line interface for CodeRoad. Build project files.",
55
"keywords": [
66
"coderoad"
@@ -20,8 +20,7 @@
2020
"files": [
2121
"lib",
2222
"package.json",
23-
"README.md",
24-
"LICENSE.md"
23+
"*.md"
2524
],
2625
"dependencies": {
2726
"chalk": "1.1.1",

0 commit comments

Comments
 (0)