Skip to content

Commit c5890e1

Browse files
committed
make typescript settings available
1 parent cf45a1a commit c5890e1

17 files changed

+2999
-25
lines changed

Diff for: .gitignore

-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
node_modules
2-
tslint.json
3-
tsconfig.json
4-
src/*.md
5-
dist/cr.json
6-
coderoad.json
7-
notes.md
8-
cli.ts
9-
tscompiler-fix.js
102
npm-debug.log

Diff for: .npmignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
src
22
test
3+
typings
4+
tsd.json
5+
tsconfig.json
6+
tslint.json

Diff for: src/build/build.ts

-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ import {project} from './parser/project';
44
import {createReadme} from './readme';
55
import {cleanup} from './parser/cleanup';
66

7-
// function loadImport(result, index, line: string) {
8-
// let pathToFile = trimQuotes(Match.project(line));
9-
// console.log('import called', pathToFile);
10-
// let lines = fs.readFileSync(pathToFile, 'utf8').split('\n');
11-
// let resultImport = chapter(result, lines, index);
12-
// console.log(resultImport)
13-
// return result;
14-
// }
15-
167
function build(lines: string[]) {
178
let result = {
189
project: {},

Diff for: src/build/parser/actions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function doAction(type: 'tests' | 'hints', isArray, actionValue, result, line, i
2929

3030
export function addToTasks(result, line, index) {
3131
let match = Match.isAction(line);
32-
let action = match.action; // action|test|hint|answer
32+
let action = match.action; //: 'action'|'test'|'hint'
3333
let task = result.chapters[index.chapter].pages[index.page].tasks[index.task];
3434
let trimmedContent = line.slice(action.length + 2, line.length - 1); // content between brackets
3535
let actionValue: string = trimQuotes(trimmedContent);

Diff for: src/build/parser/chapter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function chapter(result: Result, lines: string[], index: Index): Result {
1717

1818
let line = lines[i];
1919
// import
20-
let importFile = Match.isImport(line);
20+
let importFile = Match.isImport(line); // return import path || false
2121
if (!!importFile) {
2222
lines = loadImport(lines, importFile);
2323
continue;

Diff for: src/build/parser/match.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const isAction = function(line: string) {
4444
// content: match[2]
4545
} : false;
4646
}
47-
export const isImport = function(line: string) {
47+
export const isImport = function(line: string): string|boolean {
4848
let isMatch = line.match(/^@import\((.+)\)$/);
4949
return isMatch ? isMatch[1] : false;
5050
}

Diff for: src/build/parser/page.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function page(result: Result, lines: string[], index: Index) {
1717
i += 1;
1818
let line = lines[i];
1919

20-
let importFile = Match.isImport(line);
20+
let importFile = Match.isImport(line); // returns string path || boolean
2121
if (!!importFile) {
2222
lines = loadImport(lines, importFile);
2323
continue;

Diff for: src/cli.ts

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#! /usr/bin/env node
2+
3+
import * as program from 'commander';
4+
import * as chalk from 'chalk';
5+
import build from './build/build';
6+
import create from './create/create';
7+
import search from './search/search';
8+
import tutorials from './tutorials/tutorials';
9+
import publish from './publish/publish';
10+
import docs from './docs/docs';
11+
12+
program
13+
.version('0.3.12')
14+
.usage('[options] <keywords>')
15+
.option('-b, --build [path/to/tutorial.md]', 'tutorial markdown file', /^.+\.md$/i)
16+
.option('-c, --create [name]', 'tutorial name')
17+
.option('-p, --publish [version]', 'publish tutorial to npm with new version number')
18+
.option('-t, --tutorials', 'list of tutorial packages')
19+
.option('-s, --search [query]', 'search for tutorial package')
20+
.option('-r, --run', 'run tutorial')
21+
.option('-d, --docs', 'development documentation')
22+
23+
.parse(process.argv);
24+
25+
if (!program.args.length &&
26+
!program.build && !program.tutorials && !program.run && !program.docs ) {
27+
program.help();
28+
} else {
29+
30+
// build
31+
if (program.build) {
32+
const tutorial = program.args[0] || 'tutorial/tutorial.md';
33+
const output = 'coderoad.json';
34+
console.log(chalk.grey(`building from ${tutorial}...`))
35+
build(tutorial, output);
36+
console.log(chalk.grey(`build complete: coderoad.json`))
37+
}
38+
39+
// create
40+
if (program.create) {
41+
const packageName = program.args[0];
42+
create(packageName);
43+
}
44+
45+
if (program.search) {
46+
const query = program.args[0];
47+
search(query);
48+
}
49+
50+
if (program.tutorials) {
51+
tutorials();
52+
}
53+
54+
if (program.publish) {
55+
const version = program.args[0];
56+
publish(version);
57+
}
58+
59+
if (program.docs) {
60+
docs();
61+
}
62+
63+
process.exit(0);
64+
}

Diff for: src/tscompiler-fix.js

-4
This file was deleted.

Diff for: src/typings/chalk/chalk.d.ts

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// Type definitions for chalk v0.4.0
2+
// Project: https://github.com/sindresorhus/chalk
3+
// Definitions by: Diullei Gomes <https://github.com/Diullei>, Bart van der Schoor <https://github.com/Bartvds>, Nico Jansen <https://github.com/nicojs>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
declare module Chalk {
7+
8+
export var enabled: boolean;
9+
export var supportsColor: boolean;
10+
export var styles: ChalkStyleMap;
11+
12+
export function stripColor(value: string): any;
13+
export function hasColor(str: string): boolean;
14+
15+
export interface ChalkChain extends ChalkStyle {
16+
(...text: string[]): string;
17+
}
18+
19+
export interface ChalkStyleElement {
20+
open: string;
21+
close: string;
22+
}
23+
24+
// General
25+
export var reset: ChalkChain;
26+
export var bold: ChalkChain;
27+
export var italic: ChalkChain;
28+
export var underline: ChalkChain;
29+
export var inverse: ChalkChain;
30+
export var strikethrough: ChalkChain;
31+
32+
// Text colors
33+
export var black: ChalkChain;
34+
export var red: ChalkChain;
35+
export var green: ChalkChain;
36+
export var yellow: ChalkChain;
37+
export var blue: ChalkChain;
38+
export var magenta: ChalkChain;
39+
export var cyan: ChalkChain;
40+
export var white: ChalkChain;
41+
export var gray: ChalkChain;
42+
export var grey: ChalkChain;
43+
44+
// Background colors
45+
export var bgBlack: ChalkChain;
46+
export var bgRed: ChalkChain;
47+
export var bgGreen: ChalkChain;
48+
export var bgYellow: ChalkChain;
49+
export var bgBlue: ChalkChain;
50+
export var bgMagenta: ChalkChain;
51+
export var bgCyan: ChalkChain;
52+
export var bgWhite: ChalkChain;
53+
54+
55+
export interface ChalkStyle {
56+
// General
57+
reset: ChalkChain;
58+
bold: ChalkChain;
59+
italic: ChalkChain;
60+
underline: ChalkChain;
61+
inverse: ChalkChain;
62+
strikethrough: ChalkChain;
63+
64+
// Text colors
65+
black: ChalkChain;
66+
red: ChalkChain;
67+
green: ChalkChain;
68+
yellow: ChalkChain;
69+
blue: ChalkChain;
70+
magenta: ChalkChain;
71+
cyan: ChalkChain;
72+
white: ChalkChain;
73+
gray: ChalkChain;
74+
grey: ChalkChain;
75+
76+
// Background colors
77+
bgBlack: ChalkChain;
78+
bgRed: ChalkChain;
79+
bgGreen: ChalkChain;
80+
bgYellow: ChalkChain;
81+
bgBlue: ChalkChain;
82+
bgMagenta: ChalkChain;
83+
bgCyan: ChalkChain;
84+
bgWhite: ChalkChain;
85+
}
86+
87+
export interface ChalkStyleMap {
88+
// General
89+
reset: ChalkStyleElement;
90+
bold: ChalkStyleElement;
91+
italic: ChalkStyleElement;
92+
underline: ChalkStyleElement;
93+
inverse: ChalkStyleElement;
94+
strikethrough: ChalkStyleElement;
95+
96+
// Text colors
97+
black: ChalkStyleElement;
98+
red: ChalkStyleElement;
99+
green: ChalkStyleElement;
100+
yellow: ChalkStyleElement;
101+
blue: ChalkStyleElement;
102+
magenta: ChalkStyleElement;
103+
cyan: ChalkStyleElement;
104+
white: ChalkStyleElement;
105+
gray: ChalkStyleElement;
106+
107+
// Background colors
108+
bgBlack: ChalkStyleElement;
109+
bgRed: ChalkStyleElement;
110+
bgGreen: ChalkStyleElement;
111+
bgYellow: ChalkStyleElement;
112+
bgBlue: ChalkStyleElement;
113+
bgMagenta: ChalkStyleElement;
114+
bgCyan: ChalkStyleElement;
115+
bgWhite: ChalkStyleElement;
116+
}
117+
}
118+
119+
declare module "chalk" {
120+
export = Chalk;
121+
}
122+

0 commit comments

Comments
 (0)