Skip to content

Commit da75146

Browse files
committed
prepare 0.8 release
1 parent 489951e commit da75146

File tree

14 files changed

+125
-89
lines changed

14 files changed

+125
-89
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## [0.7.0] - WIP
5+
## [0.8.0] - 2016-08-13
6+
- parser fixes and updates
7+
- sample tutorial updated for mocha-coderoad@0.10
8+
9+
## [0.7.0] - 2016-07-28
610
- validate function for package.json & coderoad.json
711
- repair README creator on build
812

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# CodeRoad CLI
2-
Command line interface for [CodeRoad](http://coderoad.github.io). See the [docs](https://coderoad.github.io/docs) for more.
2+
Command line interface for [CodeRoad](http://coderoad.github.io). See the [docs](https://coderoad.github.io/tutorial-docs.html) for more.
33

44
### Install
55

6-
Use [CodeRoad CLI](https://github.com/coderoad/coderoad-cli) to setup and build a project data file.
6+
Use CodeRoad CLI to setup and build a project data file.
77

88
Install *CodeRoad-CLI*. Make sure [NodeJS](nodejs.org) is already installed
99

@@ -33,12 +33,13 @@ Running **create** generates:
3333
"main": "coderoad.json",
3434
"keywords": ["coderoad", "tutorial"],
3535
"dependencies": {
36-
"mocha-coderoad": "^0.3.1"
36+
"mocha-coderoad": "0.10.0"
3737
},
3838
"config": {
39+
"language": "JS",
3940
"dir": "tutorial",
4041
"runner": "mocha-coderoad",
41-
"testSuffix": ".spec.js"
42+
"testSuffix": ".js"
4243
}
4344
}
4445
```
@@ -93,8 +94,6 @@ Inside of your demo root directory, connect the link.
9394

9495
Open *Atom-Coderoad* to view your tutorial. Your package should appear as a loaded package. Click on it.
9596

96-
![CodeRoad Loaded Packages](https://coderoad.github.io/img/docs/loaded-packages.png)
97-
9897
Reload *Atom* to view changes. You can use the Atom [command-palette](https://atom.io/docs/latest/getting-started-atom-basics#command-palette) to find "reload" or simply use the reload hot-key.
9998

10099
* Windows & Linux: alt-ctrl-r

lib/build/parser/actions.js

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,51 @@
11
"use strict";
22
var cleanup_1 = require('./cleanup');
33
var match_1 = require('./match');
4-
function doAction(type, isArray, actionValue, result, line, _a) {
5-
var page = _a.page, task = _a.task;
4+
function doAction(_a) {
5+
var type = _a.type, isArray = _a.isArray, actionValue = _a.actionValue, result = _a.result, page = _a.page, task = _a.task;
66
if (result.pages[page].tasks[task][type] === undefined) {
77
result.pages[page].tasks[task][type] = [];
88
}
9-
var current = result.pages[page].tasks[task][type];
9+
var current = new Set(result.pages[page].tasks[task][type]);
1010
if (!!isArray) {
11-
var values_1 = cleanup_1.trimArray(actionValue);
12-
values_1.forEach(function (value) {
13-
if (current.indexOf(value) === -1 && values_1.indexOf(value) === -1) {
14-
result.pages[page].tasks[task][type].push(value);
15-
}
11+
var values = cleanup_1.trimArray(actionValue);
12+
values.forEach(function (v) {
13+
current.add(v);
1614
});
1715
}
1816
else {
19-
if (current.indexOf(actionValue) === -1) {
20-
result.pages[page].tasks[task][type].push(actionValue);
21-
}
17+
current.add(actionValue);
2218
}
19+
result.pages[page].tasks[task][type] = Array.from(current);
2320
return result;
2421
}
25-
function addToTasks(result, line, index) {
22+
function addToTasks(_a) {
23+
var result = _a.result, line = _a.line, _b = _a.index, page = _b.page, task = _b.task;
2624
var action = match_1.isAction(line);
27-
var page = index.page, task = index.task;
2825
var currentTask = result.pages[page].tasks[task];
2926
var trimmedContent = line.slice(action.length + 2, line.length - 1);
3027
var actionValue = cleanup_1.trimQuotes(trimmedContent);
3128
var isActionArray = match_1.isArray(cleanup_1.trimQuotes(actionValue));
3229
switch (action) {
3330
case 'test':
34-
result = doAction('tests', isActionArray, actionValue, result, line, index);
31+
result = doAction({
32+
type: 'tests',
33+
isArray: isActionArray,
34+
actionValue: actionValue,
35+
result: result,
36+
page: page,
37+
task: task,
38+
});
3539
break;
3640
case 'hint':
37-
result = doAction('hints', isActionArray, actionValue, result, line, index);
41+
result = doAction({
42+
type: 'hints',
43+
isArray: isActionArray,
44+
actionValue: actionValue,
45+
result: result,
46+
page: page,
47+
task: task,
48+
});
3849
break;
3950
case 'continue':
4051
break;
@@ -44,8 +55,8 @@ function addToTasks(result, line, index) {
4455
}
4556
if (!!isActionArray) {
4657
var arrayOfActions = JSON.parse(isActionArray);
47-
arrayOfActions.forEach(function (value) {
48-
value = cleanup_1.trimCommandValue(cleanup_1.trimQuotes(value.trim()));
58+
arrayOfActions.forEach(function (v) {
59+
var value = cleanup_1.trimCommandValue(cleanup_1.trimQuotes(v.trim()));
4960
result.pages[page].tasks[task].actions.push(value);
5061
});
5162
}

lib/build/parser/cleanup.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
"use strict";
22
function bracketTracker(line) {
3-
var l = (line.match(/\(/g) || []).length;
4-
var r = (line.match(/\)/g) || []).length;
5-
return l - r;
3+
return line.split('').reduce(function (t, c) {
4+
switch (c) {
5+
case '(':
6+
return t + 1;
7+
case ')':
8+
return t - 1;
9+
}
10+
return t;
11+
}, 0);
612
}
713
exports.bracketTracker = bracketTracker;
814
function trimLineBreaks(text) {

lib/build/parser/task.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function task(_a) {
4242
}
4343
else {
4444
currentAction += line;
45-
result = actions_1.addToTasks(result, currentAction, index);
45+
result = actions_1.addToTasks({ result: result, line: currentAction, index: index });
4646
currentAction = null;
4747
bracketCount = 0;
4848
}
@@ -62,7 +62,7 @@ function task(_a) {
6262
currentAction = line;
6363
bracketCount = cleanup_1.bracketTracker(line);
6464
if (bracketCount === 0) {
65-
result = actions_1.addToTasks(result, currentAction, index);
65+
result = actions_1.addToTasks({ result: result, line: currentAction, index: index });
6666
currentAction = null;
6767
}
6868
continue;

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
22
"name": "coderoad-cli",
3-
"version": "0.7.1",
3+
"version": "0.8.0",
44
"description": "Command line interface for CodeRoad. Build project files.",
55
"keywords": [
66
"coderoad"
77
],
8+
"homepage": "https://github.com/coderoad/coderoad-cli#readme",
9+
"bugs": {
10+
"url": "https://github.com/coderoad/coderoad-cli/issues"
11+
},
812
"license": "ISC",
913
"author": "Shawn McKay <shawn.j.mckay@gmail.com>",
1014
"files": [
@@ -20,22 +24,26 @@
2024
"directories": {
2125
"test": "test"
2226
},
27+
"repository": {
28+
"type": "git",
29+
"url": "git+https://github.com/coderoad/coderoad-cli.git"
30+
},
2331
"scripts": {
2432
"test": "echo \"Error: no test specified\" && exit 1"
2533
},
2634
"dependencies": {
2735
"atom-plugin-command-line": "1.0.2",
2836
"chalk": "1.1.3",
2937
"commander": "2.9.0",
30-
"lodash.kebabcase": "4.0.1",
38+
"lodash.kebabcase": "4.1.0",
3139
"node-file-exists": "1.1.0",
3240
"prompt": "1.0.0",
3341
"sort-package-json": "^1.4.0",
3442
"validate-npm-package-name": "2.2.2"
3543
},
3644
"devDependencies": {
3745
"chai": "3.5.0",
38-
"mocha": "2.5.3"
46+
"mocha": "3.0.2"
3947
},
4048
"preferGlobal": true
4149
}

setup/tutorial/01/01.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const expect = require('chai').expect;
1+
const { expect } = require('chai');
22

33
const page = require('BASE/page-01.js');
44

src/build/parser/actions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import {trimQuotes, trimCommandValue, trimArray} from './cleanup';
22
import {isAction, isArray} from './match';
33

44
function doAction({
5-
type, isArray, actionValue, result,
6-
index: {page, task}
5+
type, isArray, actionValue, result, page, task
76
}): CR.Output {
87
// set to array
98
if (result.pages[page].tasks[task][type] === undefined) {
@@ -24,9 +23,8 @@ function doAction({
2423
return result;
2524
}
2625

27-
export function addToTasks({ result, line, index }) {
26+
export function addToTasks({ result, line, index: {page, task} }) {
2827
let action: CR.TaskAction | string = isAction(line); // 'action'|'test'|'hint'|'openConsole'
29-
const {page, task} = index;
3028
let currentTask: CR.Task = result.pages[page].tasks[task];
3129
let trimmedContent: string = line.slice(action.length + 2, line.length - 1); // content between brackets
3230
let actionValue: string = trimQuotes(trimmedContent);
@@ -38,7 +36,8 @@ export function addToTasks({ result, line, index }) {
3836
isArray: isActionArray,
3937
actionValue,
4038
result,
41-
index
39+
page,
40+
task,
4241
});
4342
break;
4443
case 'hint':
@@ -47,7 +46,8 @@ export function addToTasks({ result, line, index }) {
4746
isArray: isActionArray,
4847
actionValue,
4948
result,
50-
index
49+
page,
50+
task,
5151
});
5252
break;
5353
case 'continue':

src/build/parser/cleanup.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
export function bracketTracker(line: string): number {
2-
let l = (line.match(/\(/g) || []).length;
3-
let r = (line.match(/\)/g) || []).length;
4-
return l - r;
2+
return line.split('').reduce((t, c) => {
3+
switch (c) {
4+
case '(':
5+
return t + 1;
6+
case ')':
7+
return t - 1;
8+
}
9+
return t;
10+
}, 0);
511
}
612

713
export function trimLineBreaks(text: string): string {

src/build/parser/task.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { addToTasks } from './actions';
44
import { trimLeadingSpaces, bracketTracker, trimValue } from './cleanup';
55
import { loadImport } from './import';
66

7-
export function task({
8-
dir, result, lines, index
9-
}) {
7+
export function task({ dir, result, lines, index }) {
108
result.pages[index.page].tasks.push({
119
description: trimLeadingSpaces(Match.task(lines[0]))
1210
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy