Skip to content

Commit 6c4527f

Browse files
committed
change create folder structure, build with optional params
1 parent 95fc32b commit 6c4527f

File tree

12 files changed

+59
-39
lines changed

12 files changed

+59
-39
lines changed

cli.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ var search_1 = require('./src/search/search');
99
var tutorials_1 = require('./src/tutorials/tutorials');
1010
var publish_1 = require('./src/publish/publish');
1111
program
12-
.version('0.3.2')
12+
.version('0.3.3')
1313
.usage('[options] <keywords>')
14-
.option('-b, --build [tutorial.md]', 'tutorial markdown file', /^.+\.md$/i)
14+
.option('-b, --build [path/to/tutorial.md]', 'tutorial markdown file', /^.+\.md$/i)
1515
.option('-c, --create [name]', 'tutorial name')
1616
.option('-p, --publish [version]', 'publish tutorial to npm with new version number')
1717
.option('-t, --tutorials', 'list of tutorial packages')
1818
.option('-s, --search [query]', 'search for tutorial package')
1919
.option('-r, --run', 'run tutorial')
2020
.parse(process.argv);
21-
if (!program.args.length && !program.tutorials) {
21+
if (!program.args.length && !program.tutorials && !program.build) {
2222
program.help();
2323
}
2424
else {
2525
if (program.build) {
26-
var tutorial = program.args[0];
26+
var tutorial = program.args[0] || 'tutorial/tutorial.md';
2727
var output = 'coderoad.json';
2828
console.log(chalk.grey("building from " + tutorial + "..."));
2929
build_1.default(tutorial, output);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coderoad-cli",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "Command line interface for CodeRoad. Build project files.",
55
"keywords": [
66
"coderoad"

src/create/setup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"devDependencies": {},
1111
"license": "MIT",
1212
"coderoad": {
13-
"testDir": "test",
13+
"testDir": "tutorial",
1414
"testSuffix": ".spec.js"
1515
}
1616
}

src/create/setup/tutorial.md

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### Page One Title
2+
Page one description.
3+
4+
More about page one.
5+
6+
+ write a function that does something.
7+
@test('chapter-01/page-01/task-01')
8+
9+
+ write some other function
10+
@test('chapter-01/page-01/task-02')
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### Page Two Title
2+
Page two description.
3+
4+
More about page two.
5+
6+
+ write a function that does something.
7+
@test('chapter-01/page-02/task-01')
8+
9+
+ write some other function
10+
@test('chapter-01/page-02/task-02')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('page one test');

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

Whitespace-only changes.

src/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/chapter-01/page-01/page-one')
8+
9+
@import('tutorial/chapter-01/page-02/page-two')

src/create/write-demo.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22
var fs = require('fs');
33
var path = require('path');
44
var file_1 = require('../tools/file');
5-
function createTutorialMd() {
6-
if (!file_1.fileExists('tutorial.md')) {
7-
console.log('adding tutorial md');
8-
var inputPath = path.join(__dirname, './setup/tutorial.md');
9-
var tutorial = fs.readFileSync(inputPath, 'utf8');
10-
fs.writeFileSync('tutorial.md', tutorial, 'utf8');
5+
function createFile(pathToFile) {
6+
if (!file_1.fileExists(pathToFile)) {
7+
var inputPath = path.join(__dirname, 'setup', pathToFile);
8+
var test = fs.readFileSync(inputPath, 'utf8');
9+
fs.writeFileSync(pathToFile, test, 'utf8');
1110
}
1211
}
12+
function createFolder(pathToFolder) {
13+
if (!file_1.fileExists(pathToFolder)) {
14+
fs.mkdirSync(pathToFolder);
15+
}
16+
}
17+
function createTutorialMd() {
18+
createFolder('tutorial');
19+
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');
25+
}
1326
exports.createTutorialMd = createTutorialMd;
1427
function createPackageJson(name) {
1528
if (!file_1.fileExists('package.json')) {
@@ -22,13 +35,9 @@ function createPackageJson(name) {
2235
}
2336
exports.createPackageJson = createPackageJson;
2437
function createTestFiles() {
25-
if (!file_1.fileExists('./test')) {
26-
fs.mkdirSync('./test');
27-
}
28-
if (!file_1.fileExists('./test/test-example-01.spec.js')) {
29-
var inputPath = path.join(__dirname, './setup/test/test-example-01.spec.js');
30-
var test = fs.readFileSync(inputPath, 'utf8');
31-
fs.writeFileSync('./test/test-example-01.spec.js', test, 'utf8');
32-
}
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');
3342
}
3443
exports.createTestFiles = createTestFiles;

0 commit comments

Comments
 (0)